1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

* compilation error fix

This commit is contained in:
mateuszb
2009-06-24 12:14:48 +00:00
parent f0dea8d708
commit 20676e8f95
3 changed files with 203 additions and 200 deletions

View File

@@ -58,6 +58,9 @@ extern TTF_Font * GEOR16;
extern std::queue<SDL_Event*> events; extern std::queue<SDL_Event*> events;
extern boost::mutex eventsM; extern boost::mutex eventsM;
#undef min
#undef max
static StackState* getStackState(const CGObjectInstance *obj, int pos, bool town) static StackState* getStackState(const CGObjectInstance *obj, int pos, bool town)
{ {
const CGHeroInstance *h = dynamic_cast<const CGHeroInstance *>(obj); const CGHeroInstance *h = dynamic_cast<const CGHeroInstance *>(obj);

View File

@@ -103,8 +103,8 @@ CBIKHandler::CBIKHandler()
//binkGetError = FindAddress("_BinkGetError@0"); //binkGetError = FindAddress("_BinkGetError@0");
binkOpen = (BinkOpen)FindAddress("_BinkOpen@8"); binkOpen = (BinkOpen)FindAddress("_BinkOpen@8");
binkSetSoundSystem = (BinkSetSoundSystem)FindAddress("_BinkSetSoundSystem@8"); binkSetSoundSystem = (BinkSetSoundSystem)FindAddress("_BinkSetSoundSystem@8");
//getPalette = (BinkGetPalette)FindAddress("_BinkGetPalette@4"); //getPalette = (BinkGetPalette)FindAddress("_BinkGetPalette@4");
binkNextFrame = (BinkNextFrame)FindAddress("_BinkNextFrame@4"); binkNextFrame = (BinkNextFrame)FindAddress("_BinkNextFrame@4");
binkDoFrame = (BinkDoFrame)FindAddress("_BinkDoFrame@4"); binkDoFrame = (BinkDoFrame)FindAddress("_BinkDoFrame@4");
binkCopyToBuffer = (BinkCopyToBuffer)FindAddress("_BinkCopyToBuffer@28"); binkCopyToBuffer = (BinkCopyToBuffer)FindAddress("_BinkCopyToBuffer@28");
binkWait = (BinkWait)FindAddress("_BinkWait@4"); binkWait = (BinkWait)FindAddress("_BinkWait@4");
@@ -228,8 +228,8 @@ void CSmackPlayer::close()
void CSmackPlayer::open( std::string name ) void CSmackPlayer::open( std::string name )
{ {
Uint32 flags[2] = {0xff400, 0xfe400}; Uint32 flags[2] = {0xff400, 0xfe400};
data = ptrSmackOpen( (void*)name.c_str(), flags[1], -1); data = ptrSmackOpen( (void*)name.c_str(), flags[1], -1);
if (!data) if (!data)
{ {
@@ -301,32 +301,32 @@ void CSmackPlayer::redraw( int x, int y, SDL_Surface *dst, bool update )
SDL_UpdateRect(dst, x, y, w, h); SDL_UpdateRect(dst, x, y, w, h);
} }
CVideoPlayer::CVideoPlayer() CVideoPlayer::CVideoPlayer()
{ {
vidh = new CVidHandler(std::string(DATA_DIR "Data" PATHSEPARATOR "VIDEO.VID")); vidh = new CVidHandler(std::string(DATA_DIR "Data" PATHSEPARATOR "VIDEO.VID"));
current = NULL; current = NULL;
} }
CVideoPlayer::~CVideoPlayer() CVideoPlayer::~CVideoPlayer()
{ {
delete vidh; delete vidh;
} }
void CVideoPlayer::open(std::string name) void CVideoPlayer::open(std::string name)
{ {
if(boost::algorithm::ends_with(name, ".BIK")) if(boost::algorithm::ends_with(name, ".BIK"))
current = &bikPlayer; current = &bikPlayer;
else else
current = &smkPlayer; current = &smkPlayer;
fname = name; fname = name;
first = true; first = true;
//extract video from video.vid so we can play it //extract video from video.vid so we can play it
vidh->extract(name, name); vidh->extract(name, name);
current->open(name); current->open(name);
} }
void CVideoPlayer::close() void CVideoPlayer::close()
{ {
if(!current) if(!current)
@@ -355,16 +355,16 @@ void CVideoPlayer::show(int x, int y, SDL_Surface *dst, bool update)
current->show(x, y, dst, update); current->show(x, y, dst, update);
} }
bool CVideoPlayer::wait() bool CVideoPlayer::wait()
{ {
return current->wait(); return current->wait();
} }
int CVideoPlayer::curFrame() const int CVideoPlayer::curFrame() const
{ {
return current->curFrame(); return current->curFrame();
} }
int CVideoPlayer::frameCount() const int CVideoPlayer::frameCount() const
{ {
return current->frameCount(); return current->frameCount();

View File

@@ -1,103 +1,103 @@
#ifndef __CVIDEOHANDLER_H__ #ifndef __CVIDEOHANDLER_H__
#define __CVIDEOHANDLER_H__ #define __CVIDEOHANDLER_H__
#include "../global.h" #include "../global.h"
#ifdef _WIN32
#include <windows.h>
struct SDL_Surface;
#pragma pack(push,1)
struct BINK_STRUCT
{
si32 width;
si32 height;
si32 frameCount;
si32 currentFrame;
si32 lastFrame;
si32 FPSMul;
si32 FPSDiv;
si32 unknown0;
ui8 flags;
ui8 unknown1[260];
si32 CurPlane; // current plane
void *plane0; // posi32er to plane 0
void *plane1; // posi32er to plane 1
si32 unknown2;
si32 unknown3;
si32 yWidth; // Y plane width
si32 yHeight; // Y plane height
si32 uvWidth; // U&V plane width
si32 uvHeight; // U&V plane height
};
#pragma pack(pop)
typedef BINK_STRUCT* HBINK;
class DLLHandler
{
public:
std::string name;
HINSTANCE dll;
void Instantiate(const char *filename);
const char *GetLibExtension();
void *FindAddress(const char *symbol);
DLLHandler();
virtual ~DLLHandler(); //d-tor
};
typedef void*(__stdcall* BinkSetSoundSystem)(void * soundfun, void*); #ifdef _WIN32
typedef HBINK(__stdcall* BinkOpen)(HANDLE bikfile, int flags);
typedef void(__stdcall* BinkClose)(HBINK); #include <windows.h>
//typedef si32(__stdcall* BinkGetPalette)(HBINK);
typedef void(__stdcall* BinkNextFrame)(HBINK); struct SDL_Surface;
typedef void(__stdcall* BinkDoFrame)(HBINK);
typedef ui8(__stdcall* BinkWait)(HBINK); #pragma pack(push,1)
typedef si32(__stdcall* BinkCopyToBuffer)(HBINK, void* buffer, int stride, int height, int x, int y, int mode); struct BINK_STRUCT
{
si32 width;
si32 height;
si32 frameCount;
si32 currentFrame;
si32 lastFrame;
si32 FPSMul;
si32 FPSDiv;
si32 unknown0;
ui8 flags;
ui8 unknown1[260];
si32 CurPlane; // current plane
void *plane0; // posi32er to plane 0
void *plane1; // posi32er to plane 1
si32 unknown2;
si32 unknown3;
si32 yWidth; // Y plane width
si32 yHeight; // Y plane height
si32 uvWidth; // U&V plane width
si32 uvHeight; // U&V plane height
};
#pragma pack(pop)
typedef BINK_STRUCT* HBINK;
class DLLHandler
{
public:
std::string name;
HINSTANCE dll;
void Instantiate(const char *filename);
const char *GetLibExtension();
void *FindAddress(const char *symbol);
DLLHandler();
virtual ~DLLHandler(); //d-tor
};
typedef void*(__stdcall* BinkSetSoundSystem)(void * soundfun, void*);
typedef HBINK(__stdcall* BinkOpen)(HANDLE bikfile, int flags);
typedef void(__stdcall* BinkClose)(HBINK);
//typedef si32(__stdcall* BinkGetPalette)(HBINK);
typedef void(__stdcall* BinkNextFrame)(HBINK);
typedef void(__stdcall* BinkDoFrame)(HBINK);
typedef ui8(__stdcall* BinkWait)(HBINK);
typedef si32(__stdcall* BinkCopyToBuffer)(HBINK, void* buffer, int stride, int height, int x, int y, int mode);
class IVideoPlayer class IVideoPlayer
{ {
public: public:
virtual void open(std::string name)=0; virtual void open(std::string name)=0;
virtual void close()=0; virtual void close()=0;
virtual void nextFrame()=0; virtual void nextFrame()=0;
virtual void show(int x, int y, SDL_Surface *dst, bool update = true)=0; virtual void show(int x, int y, SDL_Surface *dst, bool update = true)=0;
virtual void redraw(int x, int y, SDL_Surface *dst, bool update = true)=0; //reblits buffer virtual void redraw(int x, int y, SDL_Surface *dst, bool update = true)=0; //reblits buffer
virtual bool wait()=0; virtual bool wait()=0;
virtual int curFrame() const =0; virtual int curFrame() const =0;
virtual int frameCount() const =0; virtual int frameCount() const =0;
}; };
class CBIKHandler : public DLLHandler, public IVideoPlayer class CBIKHandler : public DLLHandler, public IVideoPlayer
{ {
public: public:
HANDLE hBinkFile; HANDLE hBinkFile;
HBINK hBink; HBINK hBink;
char * buffer; char * buffer;
BinkSetSoundSystem binkSetSoundSystem; BinkSetSoundSystem binkSetSoundSystem;
BinkOpen binkOpen; BinkOpen binkOpen;
//BinkGetPalette getPalette; //BinkGetPalette getPalette;
BinkNextFrame binkNextFrame; BinkNextFrame binkNextFrame;
BinkDoFrame binkDoFrame; BinkDoFrame binkDoFrame;
BinkCopyToBuffer binkCopyToBuffer; BinkCopyToBuffer binkCopyToBuffer;
BinkWait binkWait; BinkWait binkWait;
BinkClose binkClose; BinkClose binkClose;
CBIKHandler(); CBIKHandler();
void open(std::string name); void open(std::string name);
void close(); void close();
void nextFrame(); void nextFrame();
void show(int x, int y, SDL_Surface *dst, bool update = true); void show(int x, int y, SDL_Surface *dst, bool update = true);
void redraw(int x, int y, SDL_Surface *dst, bool update = true); //reblits buffer void redraw(int x, int y, SDL_Surface *dst, bool update = true); //reblits buffer
bool wait(); bool wait();
int curFrame() const; int curFrame() const;
int frameCount() const; int frameCount() const;
}; };
//////////SMK Player /////////////////////////////////////////////////////// //////////SMK Player ///////////////////////////////////////////////////////
struct SmackStruct struct SmackStruct
{ {
@@ -124,8 +124,8 @@ typedef bool (__stdcall* SmackWait)(SmackStruct*);
typedef void (__stdcall* SmackSoundOnOff) (SmackStruct*, bool); typedef void (__stdcall* SmackSoundOnOff) (SmackStruct*, bool);
class CSmackPlayer: public DLLHandler, public IVideoPlayer class CSmackPlayer: public DLLHandler, public IVideoPlayer
{ {
public: public:
SmackOpen ptrSmackOpen; SmackOpen ptrSmackOpen;
@@ -140,89 +140,89 @@ public:
SmackStruct* data; SmackStruct* data;
CSmackPlayer(); CSmackPlayer();
~CSmackPlayer(); ~CSmackPlayer();
void open(std::string name); void open(std::string name);
void close(); void close();
void nextFrame(); void nextFrame();
void show(int x, int y, SDL_Surface *dst, bool update = true); void show(int x, int y, SDL_Surface *dst, bool update = true);
void redraw(int x, int y, SDL_Surface *dst, bool update = true); //reblits buffer void redraw(int x, int y, SDL_Surface *dst, bool update = true); //reblits buffer
bool wait(); bool wait();
int curFrame() const; int curFrame() const;
int frameCount() const; int frameCount() const;
}; };
class CVidHandler; class CVidHandler;
class CVideoPlayer : public IVideoPlayer class CVideoPlayer : public IVideoPlayer
{ {
private: private:
CVidHandler * vidh; //.vid file handling CVidHandler * vidh; //.vid file handling
CSmackPlayer smkPlayer; //for .SMK CSmackPlayer smkPlayer; //for .SMK
CBIKHandler bikPlayer; //for .BIK CBIKHandler bikPlayer; //for .BIK
IVideoPlayer *current; //points to bik or smk player, appropriate to type of currently played video IVideoPlayer *current; //points to bik or smk player, appropriate to type of currently played video
std::string fname; //name of current video file (empty if idle) std::string fname; //name of current video file (empty if idle)
bool first; //are we about to display the first frame (blocks update) bool first; //are we about to display the first frame (blocks update)
public: public:
CVideoPlayer(); //c-tor CVideoPlayer(); //c-tor
~CVideoPlayer(); //d-tor ~CVideoPlayer(); //d-tor
void open(std::string name); void open(std::string name);
void close(); void close();
void nextFrame(); //move animation to the next frame void nextFrame(); //move animation to the next frame
void show(int x, int y, SDL_Surface *dst, bool update = true); //blit current frame void show(int x, int y, SDL_Surface *dst, bool update = true); //blit current frame
void redraw(int x, int y, SDL_Surface *dst, bool update = true); //reblits buffer void redraw(int x, int y, SDL_Surface *dst, bool update = true); //reblits buffer
void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true); //moves to next frame if appropriate, and blits it or blits only if redraw paremeter is set true void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true); //moves to next frame if appropriate, and blits it or blits only if redraw paremeter is set true
bool wait(); //true if we should wait before displaying next frame (for keeping FPS) bool wait(); //true if we should wait before displaying next frame (for keeping FPS)
int curFrame() const; //current frame number <1, framecount> int curFrame() const; //current frame number <1, framecount>
int frameCount() const; int frameCount() const;
bool openAndPlayVideo(std::string name, int x, int y, SDL_Surface *dst, bool stopOnKey = false); //opens video, calls playVideo, closes video; returns playVideo result (if whole video has been played) bool openAndPlayVideo(std::string name, int x, int y, SDL_Surface *dst, bool stopOnKey = false); //opens video, calls playVideo, closes video; returns playVideo result (if whole video has been played)
bool playVideo(int x, int y, SDL_Surface *dst, bool stopOnKey = false); //plays whole opened video; returns: true when whole video has been shown, false when it has been interrupted bool playVideo(int x, int y, SDL_Surface *dst, bool stopOnKey = false); //plays whole opened video; returns: true when whole video has been shown, false when it has been interrupted
}; };
#else #else
#include <SDL_video.h> #include <SDL_video.h>
typedef struct AVFormatContext AVFormatContext; typedef struct AVFormatContext AVFormatContext;
typedef struct AVCodecContext AVCodecContext; typedef struct AVCodecContext AVCodecContext;
typedef struct AVCodec AVCodec; typedef struct AVCodec AVCodec;
typedef struct AVFrame AVFrame; typedef struct AVFrame AVFrame;
struct SwsContext; struct SwsContext;
class CVidHandler; class CVidHandler;
class CVideoPlayer class CVideoPlayer
{ {
private: private:
int stream; // stream index in video int stream; // stream index in video
AVFormatContext *format; AVFormatContext *format;
AVCodecContext *codecContext; // codec context for stream AVCodecContext *codecContext; // codec context for stream
AVCodec *codec; AVCodec *codec;
AVFrame *frame; AVFrame *frame;
struct SwsContext *sws; struct SwsContext *sws;
SDL_Overlay *overlay; SDL_Overlay *overlay;
SDL_Rect pos; // overlay position SDL_Rect pos; // overlay position
CVidHandler *vidh; CVidHandler *vidh;
public: public:
CVideoPlayer(); CVideoPlayer();
~CVideoPlayer(); ~CVideoPlayer();
bool init(); bool init();
bool open(std::string fname, int x, int y); bool open(std::string fname, int x, int y);
void close(); void close();
bool nextFrame(); // display next frame bool nextFrame(); // display next frame
const char *data; // video buffer const char *data; // video buffer
int length; // video size int length; // video size
unsigned int offset; // current data offset unsigned int offset; // current data offset
}; };
#endif #endif
#endif // __CVIDEOHANDLER_H__ #endif // __CVIDEOHANDLER_H__