Change all indentation with spaces to use tabs instead

This is a whitespace-only patch. Hopefully, it'll only affect rarely-changed
parts of the engine, since all regularly maintained pieces should already
use tabs.
Günther Brammer 2010-03-27 17:05:02 +01:00
parent b8d2f39fbd
commit b4e37b070b
221 changed files with 12957 additions and 12957 deletions

View File

@ -83,7 +83,7 @@ bool C4Application::DoInit()
assert(AppState == C4AS_None); assert(AppState == C4AS_None);
// Config overwrite by parameter // Config overwrite by parameter
StdStrBuf sConfigFilename; StdStrBuf sConfigFilename;
char szParameter[_MAX_PATH+1]; char szParameter[_MAX_PATH+1];
for (int32_t iPar=0; SGetParameter(GetCommandLine(), iPar, szParameter, _MAX_PATH); iPar++) for (int32_t iPar=0; SGetParameter(GetCommandLine(), iPar, szParameter, _MAX_PATH); iPar++)
if (SEqual2NoCase(szParameter, "/config:")) if (SEqual2NoCase(szParameter, "/config:"))
sConfigFilename.Copy(szParameter + 8); sConfigFilename.Copy(szParameter + 8);
@ -499,19 +499,19 @@ void C4Application::Activate()
// As this is officially not possible any more in new versions of Windows // As this is officially not possible any more in new versions of Windows
// (BringWindowTopTop alone won't have any effect if the calling process is // (BringWindowTopTop alone won't have any effect if the calling process is
// not in the foreground itself), we are using an ugly OS hack. // not in the foreground itself), we are using an ugly OS hack.
DWORD nForeThread = GetWindowThreadProcessId(GetForegroundWindow(), 0); DWORD nForeThread = GetWindowThreadProcessId(GetForegroundWindow(), 0);
DWORD nAppThread = GetCurrentThreadId(); DWORD nAppThread = GetCurrentThreadId();
if (nForeThread != nAppThread) if (nForeThread != nAppThread)
{ {
AttachThreadInput(nForeThread, nAppThread, true); AttachThreadInput(nForeThread, nAppThread, true);
BringWindowToTop(FullScreen.hWindow); BringWindowToTop(FullScreen.hWindow);
ShowWindow(FullScreen.hWindow, SW_SHOW); ShowWindow(FullScreen.hWindow, SW_SHOW);
AttachThreadInput(nForeThread, nAppThread, false); AttachThreadInput(nForeThread, nAppThread, false);
} }
else else
{ {
BringWindowToTop(FullScreen.hWindow); BringWindowToTop(FullScreen.hWindow);
ShowWindow(FullScreen.hWindow, SW_SHOW); ShowWindow(FullScreen.hWindow, SW_SHOW);
} }
#endif #endif
} }

View File

@ -235,7 +235,7 @@ void C4FullScreen::HandleMessage (XEvent &e)
::GraphicsSystem.MouseMove(C4MC_Button_RightUp, e.xbutton.x, e.xbutton.y, e.xbutton.state, NULL); ::GraphicsSystem.MouseMove(C4MC_Button_RightUp, e.xbutton.x, e.xbutton.y, e.xbutton.state, NULL);
break; break;
default: default:
break; break;
} }
break; break;
case MotionNotify: case MotionNotify:
@ -257,75 +257,75 @@ void C4FullScreen::HandleMessage (XEvent &e)
namespace namespace
{ {
void sdlToC4MCBtn(const SDL_MouseButtonEvent &e, void sdlToC4MCBtn(const SDL_MouseButtonEvent &e,
int32_t& button, DWORD& flags) int32_t& button, DWORD& flags)
{ {
static int lastLeftClick = 0, lastRightClick = 0; static int lastLeftClick = 0, lastRightClick = 0;
static int lastX = 0, lastY = 0; static int lastX = 0, lastY = 0;
static const int clickDist = 2; static const int clickDist = 2;
button = C4MC_Button_None; button = C4MC_Button_None;
flags = 0; flags = 0;
switch (e.button) switch (e.button)
{ {
case SDL_BUTTON_LEFT: case SDL_BUTTON_LEFT:
if (e.state == SDL_PRESSED) if (e.state == SDL_PRESSED)
if (timeGetTime() - lastLeftClick < 400 && abs(lastX-e.x) <= clickDist && abs(lastY-e.y) <= clickDist) if (timeGetTime() - lastLeftClick < 400 && abs(lastX-e.x) <= clickDist && abs(lastY-e.y) <= clickDist)
{ {
lastLeftClick = 0; lastLeftClick = 0;
button = C4MC_Button_LeftDouble; button = C4MC_Button_LeftDouble;
} }
else else
{ {
lastLeftClick = timeGetTime(); lastLeftClick = timeGetTime();
button = C4MC_Button_LeftDown; button = C4MC_Button_LeftDown;
} }
else else
button = C4MC_Button_LeftUp; button = C4MC_Button_LeftUp;
break; break;
case SDL_BUTTON_RIGHT: case SDL_BUTTON_RIGHT:
if (e.state == SDL_PRESSED) if (e.state == SDL_PRESSED)
if (timeGetTime() - lastRightClick < 400) if (timeGetTime() - lastRightClick < 400)
{ {
lastRightClick = 0; lastRightClick = 0;
button = C4MC_Button_RightDouble; button = C4MC_Button_RightDouble;
} }
else else
{ {
lastRightClick = timeGetTime(); lastRightClick = timeGetTime();
button = C4MC_Button_RightDown; button = C4MC_Button_RightDown;
} }
else else
button = C4MC_Button_RightUp; button = C4MC_Button_RightUp;
break; break;
case SDL_BUTTON_MIDDLE: case SDL_BUTTON_MIDDLE:
if (e.state == SDL_PRESSED) if (e.state == SDL_PRESSED)
button = C4MC_Button_MiddleDown; button = C4MC_Button_MiddleDown;
else else
button = C4MC_Button_MiddleUp; button = C4MC_Button_MiddleUp;
break; break;
case SDL_BUTTON_WHEELUP: case SDL_BUTTON_WHEELUP:
button = C4MC_Button_Wheel; button = C4MC_Button_Wheel;
flags = (+32) << 16; flags = (+32) << 16;
break; break;
case SDL_BUTTON_WHEELDOWN: case SDL_BUTTON_WHEELDOWN:
button = C4MC_Button_Wheel; button = C4MC_Button_Wheel;
flags = (-32) << 16; flags = (-32) << 16;
break; break;
} }
lastX = e.x; lastX = e.x;
lastY = e.y; lastY = e.y;
} }
bool isSpecialKey(unsigned unicode) bool isSpecialKey(unsigned unicode)
{ {
if (unicode >= 0xe00) if (unicode >= 0xe00)
return true; return true;
if (unicode < 32 || unicode == 127) if (unicode < 32 || unicode == 127)
return true; return true;
return false; return false;
} }
} }
#include "StdGL.h" #include "StdGL.h"
@ -336,18 +336,18 @@ void C4FullScreen::HandleMessage (SDL_Event &e)
{ {
case SDL_KEYDOWN: case SDL_KEYDOWN:
{ {
#ifdef USE_GL #ifdef USE_GL
if (e.key.keysym.sym == SDLK_f && (e.key.keysym.mod & (KMOD_LMETA | KMOD_RMETA))) if (e.key.keysym.sym == SDLK_f && (e.key.keysym.mod & (KMOD_LMETA | KMOD_RMETA)))
{ {
Config.Graphics.Windowed = !Config.Graphics.Windowed; Config.Graphics.Windowed = !Config.Graphics.Windowed;
if (pGL) pGL->fFullscreen = !Config.Graphics.Windowed; if (pGL) pGL->fFullscreen = !Config.Graphics.Windowed;
Application.SetVideoMode(Config.Graphics.ResX, Config.Graphics.ResY, Config.Graphics.BitDepth, Config.Graphics.Monitor, !Config.Graphics.Windowed); Application.SetVideoMode(Config.Graphics.ResX, Config.Graphics.ResY, Config.Graphics.BitDepth, Config.Graphics.Monitor, !Config.Graphics.Windowed);
lpDDraw->InvalidateDeviceObjects(); lpDDraw->InvalidateDeviceObjects();
lpDDraw->RestoreDeviceObjects(); lpDDraw->RestoreDeviceObjects();
break; break;
} }
#endif #endif
// Only forward real characters to UI. (Nothing outside of "private use" range.) // Only forward real characters to UI. (Nothing outside of "private use" range.)
// This works without iconv for some reason. Yay! // This works without iconv for some reason. Yay!
@ -417,7 +417,7 @@ void C4FullScreen::Execute()
{ {
// Execute menu // Execute menu
if (pMenu) pMenu->Execute(); if (pMenu) pMenu->Execute();
// Draw // Draw
::GraphicsSystem.Execute(); ::GraphicsSystem.Execute();
} }

File diff suppressed because it is too large Load Diff

View File

@ -169,7 +169,7 @@ class C4Game
bool Init(); bool Init();
bool PreInit(); bool PreInit();
void ParseCommandLine(const char *szCmdLine); void ParseCommandLine(const char *szCmdLine);
bool Execute(); bool Execute();
class C4Player *JoinPlayer(const char *szFilename, int32_t iAtClient, const char *szAtClientName, C4PlayerInfo *pInfo); class C4Player *JoinPlayer(const char *szFilename, int32_t iAtClient, const char *szAtClientName, C4PlayerInfo *pInfo);
bool DoGameOver(); bool DoGameOver();
bool CanQuickSave(); bool CanQuickSave();
@ -197,18 +197,18 @@ class C4Game
bool ReloadDef(C4ID id); bool ReloadDef(C4ID id);
bool ReloadParticle(const char *szName); bool ReloadParticle(const char *szName);
// Object functions // Object functions
void ClearPointers(C4PropList *cobj); void ClearPointers(C4PropList *cobj);
C4Object *CreateObject(C4PropList * type, C4Object *pCreator, int32_t owner=NO_OWNER, C4Object *CreateObject(C4PropList * type, C4Object *pCreator, int32_t owner=NO_OWNER,
int32_t x=50, int32_t y=50, int32_t r=0, int32_t x=50, int32_t y=50, int32_t r=0,
FIXED xdir=Fix0, FIXED ydir=Fix0, FIXED rdir=Fix0, int32_t iController=NO_OWNER); FIXED xdir=Fix0, FIXED ydir=Fix0, FIXED rdir=Fix0, int32_t iController=NO_OWNER);
C4Object *CreateObject(C4ID type, C4Object *pCreator, int32_t owner=NO_OWNER, C4Object *CreateObject(C4ID type, C4Object *pCreator, int32_t owner=NO_OWNER,
int32_t x=50, int32_t y=50, int32_t r=0, int32_t x=50, int32_t y=50, int32_t r=0,
FIXED xdir=Fix0, FIXED ydir=Fix0, FIXED rdir=Fix0, int32_t iController=NO_OWNER); FIXED xdir=Fix0, FIXED ydir=Fix0, FIXED rdir=Fix0, int32_t iController=NO_OWNER);
C4Object *CreateObjectConstruction(C4PropList * type, C4Object *CreateObjectConstruction(C4PropList * type,
C4Object *pCreator, C4Object *pCreator,
int32_t owner, int32_t owner,
int32_t ctx=0, int32_t bty=0, int32_t ctx=0, int32_t bty=0,
int32_t con=1, bool terrain=false); int32_t con=1, bool terrain=false);
C4Object *CreateInfoObject(C4ObjectInfo *cinf, int32_t owner, C4Object *CreateInfoObject(C4ObjectInfo *cinf, int32_t owner,
int32_t tx=50, int32_t ty=50); int32_t tx=50, int32_t ty=50);
void BlastObjects(int32_t tx, int32_t ty, int32_t level, C4Object *inobj, int32_t iCausedBy, C4Object *pByObj); void BlastObjects(int32_t tx, int32_t ty, int32_t level, C4Object *inobj, int32_t iCausedBy, C4Object *pByObj);
@ -228,7 +228,7 @@ class C4Game
float iX, float iY, float iX, float iY,
DWORD category, DWORD category,
float gui_x, float gui_y); float gui_x, float gui_y);
/* int32_t ObjectCount(C4ID id, /* int32_t ObjectCount(C4ID id,
int32_t x=0, int32_t y=0, int32_t wdt=0, int32_t hgt=0, int32_t x=0, int32_t y=0, int32_t wdt=0, int32_t hgt=0,
DWORD ocf=OCF_All, DWORD ocf=OCF_All,
const char *szAction=NULL, C4Object *pActionTarget=NULL, const char *szAction=NULL, C4Object *pActionTarget=NULL,
@ -262,9 +262,9 @@ class C4Game
void InitValueOverloads(); void InitValueOverloads();
void InitEnvironment(); void InitEnvironment();
void UpdateRules(); void UpdateRules();
void CloseScenario(); void CloseScenario();
void DeleteObjects(bool fDeleteInactive); void DeleteObjects(bool fDeleteInactive);
void ExecObjects(); void ExecObjects();
void Ticks(); void Ticks();
const char *FoldersWithLocalsDefs(const char *szPath); const char *FoldersWithLocalsDefs(const char *szPath);
bool CheckObjectEnumeration(); bool CheckObjectEnumeration();
@ -287,9 +287,9 @@ class C4Game
bool LinkScriptEngine(); bool LinkScriptEngine();
bool InitPlayers(); bool InitPlayers();
bool InitRecord(); bool InitRecord();
bool OpenScenario(); bool OpenScenario();
bool InitDefs(); bool InitDefs();
bool InitMaterialTexture(); bool InitMaterialTexture();
bool GameOverCheck(); bool GameOverCheck();
bool PlaceInEarth(C4ID id); bool PlaceInEarth(C4ID id);
bool Compile(const char *szSource); bool Compile(const char *szSource);
@ -302,14 +302,14 @@ class C4Game
bool StoreParticipantPlayers(); bool StoreParticipantPlayers();
bool RecreatePlayerFiles(); bool RecreatePlayerFiles();
// Object function internals // Object function internals
C4Object *NewObject( C4PropList *ndef, C4Object *pCreator, C4Object *NewObject( C4PropList *ndef, C4Object *pCreator,
int32_t owner, C4ObjectInfo *info, int32_t owner, C4ObjectInfo *info,
int32_t tx, int32_t ty, int32_t tr, int32_t tx, int32_t ty, int32_t tr,
FIXED xdir, FIXED ydir, FIXED rdir, FIXED xdir, FIXED ydir, FIXED rdir,
int32_t con, int32_t iController); int32_t con, int32_t iController);
void ClearObjectPtrs(C4Object *tptr); void ClearObjectPtrs(C4Object *tptr);
void ObjectRemovalCheck(); void ObjectRemovalCheck();
bool ToggleDebugMode(); // dbg modeon/off if allowed bool ToggleDebugMode(); // dbg modeon/off if allowed
bool ActivateMenu(const char *szCommand); // exec given menu command for first local player bool ActivateMenu(const char *szCommand); // exec given menu command for first local player
@ -317,7 +317,7 @@ class C4Game
public: public:
bool ToggleChart(); // chart dlg on/off bool ToggleChart(); // chart dlg on/off
void SetMusicLevel(int32_t iToLvl); // change game music volume; multiplied by config volume for real volume void SetMusicLevel(int32_t iToLvl); // change game music volume; multiplied by config volume for real volume
}; };
const int32_t C4RULE_StructuresNeedEnergy = 1, const int32_t C4RULE_StructuresNeedEnergy = 1,

View File

@ -804,12 +804,12 @@ int32_t C4GraphicsSystem::GetAudibility(int32_t iX, int32_t iY, int32_t *iPan, i
// Accumulate audibility by viewports // Accumulate audibility by viewports
int32_t iAudible=0; *iPan = 0; int32_t iAudible=0; *iPan = 0;
for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next) for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
{ {
iAudible = Max( iAudible, iAudible = Max( iAudible,
BoundBy<int32_t>(100-100*Distance(cvp->ViewX+cvp->ViewWdt/2,cvp->ViewY+cvp->ViewHgt/2,iX,iY)/C4AudibilityRadius,0,100) ); BoundBy<int32_t>(100-100*Distance(cvp->ViewX+cvp->ViewWdt/2,cvp->ViewY+cvp->ViewHgt/2,iX,iY)/C4AudibilityRadius,0,100) );
*iPan += (iX-(cvp->ViewX+cvp->ViewWdt/2)) / 5; *iPan += (iX-(cvp->ViewX+cvp->ViewWdt/2)) / 5;
} }
*iPan = BoundBy<int32_t>(*iPan, -100, 100); *iPan = BoundBy<int32_t>(*iPan, -100, 100);
return iAudible; return iAudible;
} }

View File

@ -49,9 +49,9 @@
// Build Options // Build Options
#ifdef _DEBUG #ifdef _DEBUG
#define C4BUILDDEBUG " dbg" #define C4BUILDDEBUG " dbg"
#else #else
#define C4BUILDDEBUG #define C4BUILDDEBUG
#endif #endif
#define C4BUILDOPT C4BUILDDEBUG #define C4BUILDOPT C4BUILDDEBUG

View File

@ -59,9 +59,9 @@ int GenerateDump(EXCEPTION_POINTERS* pExceptionPointers)
// Write dump // Write dump
MINIDUMP_EXCEPTION_INFORMATION ExpParam; MINIDUMP_EXCEPTION_INFORMATION ExpParam;
ExpParam.ThreadId = GetCurrentThreadId(); ExpParam.ThreadId = GetCurrentThreadId();
ExpParam.ExceptionPointers = pExceptionPointers; ExpParam.ExceptionPointers = pExceptionPointers;
ExpParam.ClientPointers = true; ExpParam.ClientPointers = true;
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),
file, MiniDumpNormal, &ExpParam, NULL, NULL); file, MiniDumpNormal, &ExpParam, NULL, NULL);
@ -76,12 +76,12 @@ int GenerateDump(EXCEPTION_POINTERS* pExceptionPointers)
int WINAPI WinMain (HINSTANCE hInst, int WINAPI WinMain (HINSTANCE hInst,
HINSTANCE hPrevInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdParam, LPSTR lpszCmdParam,
int nCmdShow) int nCmdShow)
{ {
#if defined(_DEBUG) && defined(_MSC_VER) #if defined(_DEBUG) && defined(_MSC_VER)
// enable debugheap! // enable debugheap!
_CrtSetDbgFlag( _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetDbgFlag( _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif #endif
#ifdef GENERATE_MINI_DUMP #ifdef GENERATE_MINI_DUMP

View File

@ -201,8 +201,8 @@ bool C4ComponentHost::Load(const char *szName,
} }
// Truncate any additional segments from stored filename // Truncate any additional segments from stored filename
SReplaceChar(Filename, '|', 0); SReplaceChar(Filename, '|', 0);
// skip full path (unknown) // skip full path (unknown)
FilePath[0] = 0; FilePath[0] = 0;
// Not loaded // Not loaded
return false; return false;
} }

View File

@ -185,9 +185,9 @@
#define C4FLS_Folder "Folder.txt|Title*.txt|Info.txt|Desc*.rtf|Title.png|Title.bmp|Icon.png|Icon.bmp|Author.txt|Version.txt|*.c4s|Loader*.bmp|Loader*.png|Loader*.jpeg|Loader*.jpg|FolderMap.txt|FolderMap.png" #define C4FLS_Folder "Folder.txt|Title*.txt|Info.txt|Desc*.rtf|Title.png|Title.bmp|Icon.png|Icon.bmp|Author.txt|Version.txt|*.c4s|Loader*.bmp|Loader*.png|Loader*.jpeg|Loader*.jpg|FolderMap.txt|FolderMap.png"
#define C4FLS_Material "TexMap.txt|*.bmp|*.png|*.c4m" #define C4FLS_Material "TexMap.txt|*.bmp|*.png|*.c4m"
#define C4FLS_Graphics "Loader*.bmp|Loader*.png|Loader*.jpeg|Loader*.jpg|FontEndeavour12.png|FontEndeavour24.png|FontEndeavour16.png|FontEndeavour10.png|Font*.png"\ #define C4FLS_Graphics "Loader*.bmp|Loader*.png|Loader*.jpeg|Loader*.jpg|FontEndeavour12.png|FontEndeavour24.png|FontEndeavour16.png|FontEndeavour10.png|Font*.png"\
"|*.pal|Control.png|Fire.png|Background.png|Flag.png|Crew.png|Score.png|Wealth.png|Player.png|Rank.png|Entry.png|Captain.png|Cursor.png|CursorSmall.png|CursorMedium.png|CursorLarge.png|SelectMark.png|MenuSymbol.png|Menu.png|Logo.png|Construction.png|Energy.png|Magic.png|Options.png|UpperBoard.png|Arrow.png|Exit.png|Hand.png|Gamepad.png|Build.png|Liquid.png"\ "|*.pal|Control.png|Fire.png|Background.png|Flag.png|Crew.png|Score.png|Wealth.png|Player.png|Rank.png|Entry.png|Captain.png|Cursor.png|CursorSmall.png|CursorMedium.png|CursorLarge.png|SelectMark.png|MenuSymbol.png|Menu.png|Logo.png|Construction.png|Energy.png|Magic.png|Options.png|UpperBoard.png|Arrow.png|Exit.png|Hand.png|Gamepad.png|Build.png|Liquid.png"\
"|GUICaption.png|GUIButton.png|GUIButtonDown.png|GUIButtonHighlight.png|GUIIcons.png|GUIIcons2.png|GUIScroll.png|GUIContext.png|GUISubmenu.png|GUICheckBox.png|GUIBigArrows.png|GUIProgress.png"\ "|GUICaption.png|GUIButton.png|GUIButtonDown.png|GUIButtonHighlight.png|GUIIcons.png|GUIIcons2.png|GUIScroll.png|GUIContext.png|GUISubmenu.png|GUICheckBox.png|GUIBigArrows.png|GUIProgress.png"\
"|StartupScenSelBG.*|StartupPlrSelBG.*|StartupPlrPropBG.*|StartupNetworkBG.*|StartupAboutBG.*|StartupBigButton.png|StartupBigButtonDown.png|StartupBookScroll.png|StartupContext.png|StartupScenSelIcons.png|StartupScenSelTitleOv.png|StartupDlgPaper.png|StartupOptionIcons.png|StartupTabClip.png|StartupNetGetRef.png" "|StartupScenSelBG.*|StartupPlrSelBG.*|StartupPlrPropBG.*|StartupNetworkBG.*|StartupAboutBG.*|StartupBigButton.png|StartupBigButtonDown.png|StartupBookScroll.png|StartupContext.png|StartupScenSelIcons.png|StartupScenSelTitleOv.png|StartupDlgPaper.png|StartupOptionIcons.png|StartupTabClip.png|StartupNetGetRef.png"
#define C4FLS_Objects "Names*.txt|Desc*.txt|*.c4d" #define C4FLS_Objects "Names*.txt|Desc*.txt|*.c4d"
#define C4FLS_Mouse "*.txt|*.rtf|Title.bmp|Title.png|Icon.bmp|Tutorial01.c4s|Tutorial02.c4s|Tutorial03.c4s|Objects.c4d" #define C4FLS_Mouse "*.txt|*.rtf|Title.bmp|Title.png|Icon.bmp|Tutorial01.c4s|Tutorial02.c4s|Tutorial03.c4s|Objects.c4d"
#define C4FLS_Keyboard "*.txt|*.rtf|Title.bmp|Title.png|Icon.bmp|Tutorial01.c4s|Tutorial02.c4s|Tutorial03.c4s|Tutorial04.c4s|Tutorial05.c4s|Tutorial06.c4s|Tutorial07.c4s|Tutorial08.c4s|Tutorial09.c4s|Tutorial10.c4s" #define C4FLS_Keyboard "*.txt|*.rtf|Title.bmp|Title.png|Icon.bmp|Tutorial01.c4s|Tutorial02.c4s|Tutorial03.c4s|Tutorial04.c4s|Tutorial05.c4s|Tutorial06.c4s|Tutorial07.c4s|Tutorial08.c4s|Tutorial09.c4s|Tutorial10.c4s"

File diff suppressed because it is too large Load Diff

View File

@ -61,7 +61,7 @@ extern int iC4GroupRewindFilePtrNoWarn;
const int C4GroupFileVer1=1, C4GroupFileVer2=2; const int C4GroupFileVer1=1, C4GroupFileVer2=2;
const int C4GroupMaxMaker = 30, const int C4GroupMaxMaker = 30,
C4GroupMaxPassword = 30, C4GroupMaxPassword = 30,
C4GroupMaxError = 100; C4GroupMaxError = 100;
const int32_t C4GroupSwapThreshold = 10 * 1024 * 1024; const int32_t C4GroupSwapThreshold = 10 * 1024 * 1024;
@ -95,38 +95,38 @@ extern time_t C4Group_AssumeTimeOffset;
#pragma pack (push, 1) #pragma pack (push, 1)
class C4GroupHeader class C4GroupHeader
{ {
public: public:
C4GroupHeader(); C4GroupHeader();
public: public:
char id[24+4]; char id[24+4];
int Ver1,Ver2; int Ver1,Ver2;
int Entries; int Entries;
char Maker[C4GroupMaxMaker+2]; char Maker[C4GroupMaxMaker+2];
char Password[C4GroupMaxPassword+2]; char Password[C4GroupMaxPassword+2];
int Creation,Original; int Creation,Original;
BYTE fbuf[92]; BYTE fbuf[92];
public: public:
void Init(); void Init();
}; };
const char C4GECS_None = 0, const char C4GECS_None = 0,
C4GECS_Old = 1, C4GECS_Old = 1,
C4GECS_New = 2; C4GECS_New = 2;
class C4GroupEntryCore class C4GroupEntryCore
{ {
public: public:
C4GroupEntryCore(); C4GroupEntryCore();
public: public:
char FileName[260]; char FileName[260];
int32_t Packed,ChildGroup; int32_t Packed,ChildGroup;
int32_t Size, __Unused, Offset; int32_t Size, __Unused, Offset;
uint32_t Time; uint32_t Time;
char HasCRC; unsigned int CRC; char HasCRC; unsigned int CRC;
char Executable; char Executable;
BYTE fbuf[26]; BYTE fbuf[26];
}; };
#pragma pack (pop) #pragma pack (pop)
@ -140,9 +140,9 @@ class C4GroupEntry: public C4GroupEntryCore
public: public:
C4GroupEntry(); C4GroupEntry();
~C4GroupEntry(); ~C4GroupEntry();
public: public:
char DiskPath[_MAX_PATH + 1]; char DiskPath[_MAX_PATH + 1];
int Status; int Status;
bool DeleteOnDisk; bool DeleteOnDisk;
bool HoldBuffer; bool HoldBuffer;
bool BufferIsStdbuf; bool BufferIsStdbuf;
@ -154,106 +154,106 @@ class C4GroupEntry: public C4GroupEntryCore
}; };
const int GRPF_Inactive=0, const int GRPF_Inactive=0,
GRPF_File=1, GRPF_File=1,
GRPF_Folder=2; GRPF_Folder=2;
class C4Group: public CStdStream class C4Group: public CStdStream
{ {
public: public:
C4Group(); C4Group();
~C4Group(); ~C4Group();
protected: protected:
int Status; int Status;
char FileName[_MAX_PATH+1]; char FileName[_MAX_PATH+1];
// Parent status // Parent status
C4Group *Mother; C4Group *Mother;
bool ExclusiveChild; bool ExclusiveChild;
// File & Folder // File & Folder
C4GroupEntry *SearchPtr; C4GroupEntry *SearchPtr;
CStdFile StdFile; CStdFile StdFile;
size_t iCurrFileSize; // size of last accessed file size_t iCurrFileSize; // size of last accessed file
// File only // File only
int FilePtr; int FilePtr;
int MotherOffset; int MotherOffset;
int EntryOffset; int EntryOffset;
bool Modified; bool Modified;
C4GroupHeader Head; C4GroupHeader Head;
C4GroupEntry *FirstEntry; C4GroupEntry *FirstEntry;
// Folder only // Folder only
//struct _finddata_t Fdt; //struct _finddata_t Fdt;
//long hFdt; //long hFdt;
DirectoryIterator FolderSearch; DirectoryIterator FolderSearch;
C4GroupEntry FolderSearchEntry; C4GroupEntry FolderSearchEntry;
C4GroupEntry LastFolderSearchEntry; C4GroupEntry LastFolderSearchEntry;
bool StdOutput; bool StdOutput;
bool (*fnProcessCallback)(const char *, int); bool (*fnProcessCallback)(const char *, int);
char ErrorString[C4GroupMaxError+1]; char ErrorString[C4GroupMaxError+1];
bool MadeOriginal; bool MadeOriginal;
bool NoSort; // If this flag is set, all entries will be marked NoSort in AddEntry bool NoSort; // If this flag is set, all entries will be marked NoSort in AddEntry
public: public:
bool Open(const char *szGroupName, bool fCreate=false); bool Open(const char *szGroupName, bool fCreate=false);
bool Close(); bool Close();
bool Save(bool fReOpen); bool Save(bool fReOpen);
bool OpenAsChild(C4Group *pMother, const char *szEntryName, bool fExclusive=false, bool fCreate=false); bool OpenAsChild(C4Group *pMother, const char *szEntryName, bool fExclusive=false, bool fCreate=false);
bool OpenChild(const char* strEntry); bool OpenChild(const char* strEntry);
bool OpenMother(); bool OpenMother();
bool Add(const char *szFiles); bool Add(const char *szFiles);
bool Add(const char *szFile, const char *szAddAs); bool Add(const char *szFile, const char *szAddAs);
bool Add(const char *szName, void *pBuffer, int iSize, bool fChild = false, bool fHoldBuffer = false, int iTime = 0, bool fExecutable = false); bool Add(const char *szName, void *pBuffer, int iSize, bool fChild = false, bool fHoldBuffer = false, int iTime = 0, bool fExecutable = false);
bool Add(const char *szName, StdBuf &pBuffer, bool fChild = false, bool fHoldBuffer = false, int iTime = 0, bool fExecutable = false); bool Add(const char *szName, StdBuf &pBuffer, bool fChild = false, bool fHoldBuffer = false, int iTime = 0, bool fExecutable = false);
bool Add(const char *szName, StdStrBuf &pBuffer, bool fChild = false, bool fHoldBuffer = false, int iTime = 0, bool fExecutable = false); bool Add(const char *szName, StdStrBuf &pBuffer, bool fChild = false, bool fHoldBuffer = false, int iTime = 0, bool fExecutable = false);
bool Add(const char *szEntryname, C4Group &hSource); bool Add(const char *szEntryname, C4Group &hSource);
bool Merge(const char *szFolders); bool Merge(const char *szFolders);
bool Move(const char *szFiles); bool Move(const char *szFiles);
bool Move(const char *szFile, const char *szAddAs); bool Move(const char *szFile, const char *szAddAs);
bool Extract(const char *szFiles, const char *szExtractTo=NULL, const char *szExclude=NULL); bool Extract(const char *szFiles, const char *szExtractTo=NULL, const char *szExclude=NULL);
bool ExtractEntry(const char *szFilename, const char *szExtractTo=NULL); bool ExtractEntry(const char *szFilename, const char *szExtractTo=NULL);
bool Delete(const char *szFiles, bool fRecursive = false); bool Delete(const char *szFiles, bool fRecursive = false);
bool DeleteEntry(const char *szFilename, bool fRecycle=false); bool DeleteEntry(const char *szFilename, bool fRecycle=false);
bool Rename(const char *szFile, const char *szNewName); bool Rename(const char *szFile, const char *szNewName);
bool Sort(const char *szSortList); bool Sort(const char *szSortList);
bool SortByList(const char **ppSortList, const char *szFilename=NULL); bool SortByList(const char **ppSortList, const char *szFilename=NULL);
bool View(const char *szFiles); bool View(const char *szFiles);
bool GetOriginal(); bool GetOriginal();
bool AccessEntry(const char *szWildCard, bool AccessEntry(const char *szWildCard,
size_t *iSize=NULL, char *sFileName=NULL, size_t *iSize=NULL, char *sFileName=NULL,
bool *fChild=NULL, bool NeedsToBeAGroup = false); bool *fChild=NULL, bool NeedsToBeAGroup = false);
bool AccessNextEntry(const char *szWildCard, bool AccessNextEntry(const char *szWildCard,
size_t *iSize=NULL, char *sFileName=NULL, size_t *iSize=NULL, char *sFileName=NULL,
bool *fChild=NULL); bool *fChild=NULL);
bool LoadEntry(const char *szEntryName, char **lpbpBuf, bool LoadEntry(const char *szEntryName, char **lpbpBuf,
size_t *ipSize=NULL, int iAppendZeros=0); size_t *ipSize=NULL, int iAppendZeros=0);
bool LoadEntry(const char *szEntryName, StdBuf &Buf); bool LoadEntry(const char *szEntryName, StdBuf &Buf);
bool LoadEntryString(const char *szEntryName, StdStrBuf &Buf); bool LoadEntryString(const char *szEntryName, StdStrBuf &Buf);
bool FindEntry(const char *szWildCard, bool FindEntry(const char *szWildCard,
char *sFileName=NULL, char *sFileName=NULL,
size_t *iSize=NULL, size_t *iSize=NULL,
bool *fChild=NULL); bool *fChild=NULL);
bool FindNextEntry(const char *szWildCard, bool FindNextEntry(const char *szWildCard,
char *sFileName=NULL, char *sFileName=NULL,
size_t *iSize=NULL, size_t *iSize=NULL,
bool *fChild=NULL, bool *fChild=NULL,
bool fStartAtFilename=false); bool fStartAtFilename=false);
bool Read(void *pBuffer, size_t iSize); bool Read(void *pBuffer, size_t iSize);
bool Advance(int iOffset); bool Advance(int iOffset);
void SetMaker(const char *szMaker); void SetMaker(const char *szMaker);
void SetPassword(const char *szPassword); void SetPassword(const char *szPassword);
void SetStdOutput(bool fStatus); void SetStdOutput(bool fStatus);
void SetProcessCallback(bool (*fnCallback)(const char *, int)); void SetProcessCallback(bool (*fnCallback)(const char *, int));
void MakeOriginal(bool fOriginal); void MakeOriginal(bool fOriginal);
void ResetSearch(); void ResetSearch();
const char *GetError(); const char *GetError();
const char *GetMaker(); const char *GetMaker();
const char *GetPassword(); const char *GetPassword();
const char *GetName(); const char *GetName();
StdStrBuf GetFullName() const; StdStrBuf GetFullName() const;
int EntryCount(const char *szWildCard=NULL); int EntryCount(const char *szWildCard=NULL);
int EntrySize(const char *szWildCard=NULL); int EntrySize(const char *szWildCard=NULL);
int AccessedEntrySize() { return iCurrFileSize; } // retrieve size of last accessed entry int AccessedEntrySize() { return iCurrFileSize; } // retrieve size of last accessed entry
int EntryTime(const char *szFilename); int EntryTime(const char *szFilename);
unsigned int EntryCRC32(const char *szWildCard=NULL); unsigned int EntryCRC32(const char *szWildCard=NULL);
@ -269,39 +269,39 @@ class C4Group: public CStdStream
void PrintInternals(const char *szIndent=NULL); void PrintInternals(const char *szIndent=NULL);
#endif #endif
protected: protected:
void Init(); void Init();
void Default(); void Default();
void Clear(); void Clear();
void ProcessOut(const char *szMessage, int iProcess=0); void ProcessOut(const char *szMessage, int iProcess=0);
bool EnsureChildFilePtr(C4Group *pChild); bool EnsureChildFilePtr(C4Group *pChild);
bool CloseExclusiveMother(); bool CloseExclusiveMother();
bool Error(const char *szStatus); bool Error(const char *szStatus);
bool OpenReal(const char *szGroupName); bool OpenReal(const char *szGroupName);
bool OpenRealGrpFile(); bool OpenRealGrpFile();
bool SetFilePtr(int iOffset); bool SetFilePtr(int iOffset);
bool RewindFilePtr(); bool RewindFilePtr();
bool AdvanceFilePtr(int iOffset, C4Group *pByChild=NULL); bool AdvanceFilePtr(int iOffset, C4Group *pByChild=NULL);
bool AddEntry(int status, bool AddEntry(int status,
bool childgroup, bool childgroup,
const char *fname, const char *fname,
long size, long size,
time_t time, time_t time,
char cCRC, char cCRC,
unsigned int iCRC, unsigned int iCRC,
const char *entryname = NULL, const char *entryname = NULL,
BYTE *membuf = NULL, BYTE *membuf = NULL,
bool fDeleteOnDisk = false, bool fDeleteOnDisk = false,
bool fHoldBuffer = false, bool fHoldBuffer = false,
bool fExecutable = false, bool fExecutable = false,
bool fBufferIsStdbuf = false); bool fBufferIsStdbuf = false);
bool AddEntryOnDisk(const char *szFilename, const char *szAddAs=NULL, bool fMove=false); bool AddEntryOnDisk(const char *szFilename, const char *szAddAs=NULL, bool fMove=false);
bool SetFilePtr2Entry(const char *szName, C4Group *pByChild=NULL, bool NeedsToBeAGroup = false); bool SetFilePtr2Entry(const char *szName, C4Group *pByChild=NULL, bool NeedsToBeAGroup = false);
bool AppendEntry2StdFile(C4GroupEntry *centry, CStdFile &stdfile); bool AppendEntry2StdFile(C4GroupEntry *centry, CStdFile &stdfile);
C4GroupEntry *GetEntry(const char *szName); C4GroupEntry *GetEntry(const char *szName);
C4GroupEntry *SearchNextEntry(const char *szName); C4GroupEntry *SearchNextEntry(const char *szName);
C4GroupEntry *GetNextFolderEntry(); C4GroupEntry *GetNextFolderEntry();
bool CalcCRC32(C4GroupEntry *pEntry); bool CalcCRC32(C4GroupEntry *pEntry);
}; };
#endif #endif

View File

@ -48,16 +48,16 @@ class C4LanguageInfo
class C4Language class C4Language
{ {
public: public:
C4Language(); C4Language();
~C4Language(); ~C4Language();
protected: protected:
C4Group PackDirectory; C4Group PackDirectory;
C4GroupSet Packs; C4GroupSet Packs;
C4GroupSet PackGroups; C4GroupSet PackGroups;
C4LanguageInfo* Infos; C4LanguageInfo* Infos;
char PackGroupLocation[_MAX_FNAME + 1]; char PackGroupLocation[_MAX_FNAME + 1];
public: public:
bool CloseGroup(const char *strPath); bool CloseGroup(const char *strPath);
void ClearLanguage(); void ClearLanguage();
// Initialization // Initialization

View File

@ -198,17 +198,17 @@ public:
memcpy(&pCore->Time, &SavedCore.Time, (char *)&SavedCore + sizeof(SavedCore) - (char *)&SavedCore.Time); memcpy(&pCore->Time, &SavedCore.Time, (char *)&SavedCore + sizeof(SavedCore) - (char *)&SavedCore.Time);
} }
void SetEntryTime(const char *szEntry, int iEntryTime) void SetEntryTime(const char *szEntry, int iEntryTime)
{ {
C4GroupEntryCore *pCore = GetEntry(szEntry); C4GroupEntryCore *pCore = GetEntry(szEntry);
if(pCore) pCore->Time = iEntryTime; if(pCore) pCore->Time = iEntryTime;
} }
void SetNoSort(const char *szEntry) void SetNoSort(const char *szEntry)
{ {
C4GroupEntry *pEntry = GetEntry(szEntry); C4GroupEntry *pEntry = GetEntry(szEntry);
if(pEntry) pEntry->NoSort = true; if(pEntry) pEntry->NoSort = true;
} }
// close without header update // close without header update
bool Close(bool fHeaderUpdate) bool Close(bool fHeaderUpdate)
@ -350,7 +350,7 @@ bool C4UpdatePackage::Execute(C4Group *pGroup)
uint32_t iCRC32; uint32_t iCRC32;
if(!C4Group_GetFileCRC(TargetGrp.GetFullName().getData(), &iCRC32)) if(!C4Group_GetFileCRC(TargetGrp.GetFullName().getData(), &iCRC32))
return false; return false;
int i = 0; int i = 0;
for(; i < UpGrpCnt; i++) for(; i < UpGrpCnt; i++)
if(iCRC32 == GrpChks1[i]) if(iCRC32 == GrpChks1[i])
break; break;
@ -463,7 +463,7 @@ int C4UpdatePackage::Check(C4Group *pGroup)
// so there's nothing to do // so there's nothing to do
return C4UPD_CHK_ALREADY_UPDATED; return C4UPD_CHK_ALREADY_UPDATED;
// check if it's one of our registered sources // check if it's one of our registered sources
int i = 0; int i = 0;
for(; i < UpGrpCnt; i++) for(; i < UpGrpCnt; i++)
if(iCRC32 == GrpChks1[i]) if(iCRC32 == GrpChks1[i])
break; break;
@ -521,7 +521,7 @@ bool C4UpdatePackage::DoUpdate(C4Group *pGrpFrom, C4GroupEx *pGrpTo, const char
#ifdef _MSC_VER #ifdef _MSC_VER
OutputDebugString(strMsg); OutputDebugString(strMsg);
#elif _DEBUG #elif _DEBUG
puts(strMsg); puts(strMsg);
#endif #endif
if(!C4Group_CopyEntry(pGrpFrom, pGrpTo, strFileName)) if(!C4Group_CopyEntry(pGrpFrom, pGrpTo, strFileName))
return false; return false;
@ -546,33 +546,33 @@ bool C4UpdatePackage::DoGrpUpdate(C4Group *pUpdateData, C4GroupEx *pGrpTo)
{ {
bool fGotIt = false; bool fGotIt = false;
for(int i = 0; (fGotIt = SCopySegment(pData, i, strItemName2, '|', _MAX_FNAME)); i++) for(int i = 0; (fGotIt = SCopySegment(pData, i, strItemName2, '|', _MAX_FNAME)); i++)
{ {
// remove seperator // remove seperator
char *pSep = strchr(strItemName2, '='); char *pSep = strchr(strItemName2, '=');
if(pSep) *pSep = '\0'; if(pSep) *pSep = '\0';
// in list? // in list?
if(SEqual(strItemName, strItemName2)) if(SEqual(strItemName, strItemName2))
break; break;
} }
if(!fGotIt) if(!fGotIt)
pGrpTo->DeleteEntry(strItemName); pGrpTo->DeleteEntry(strItemName);
} }
// set entry times, set sort list // set entry times, set sort list
char strSortList[32767] = ""; char strSortList[32767] = "";
for(int i = 0; SCopySegment(pData, i, strItemName, '|', _MAX_FNAME); i++) for(int i = 0; SCopySegment(pData, i, strItemName, '|', _MAX_FNAME); i++)
{ {
// get time (if given) // get time (if given)
char *pTime = strchr(strItemName, '='); char *pTime = strchr(strItemName, '=');
if(pTime) *pTime++ = '\0'; if(pTime) *pTime++ = '\0';
// set // set
if(pTime) pGrpTo->SetEntryTime(strItemName, atoi(pTime)); if(pTime) pGrpTo->SetEntryTime(strItemName, atoi(pTime));
// update EntryCRC32. This will make updates to old groups invalid // update EntryCRC32. This will make updates to old groups invalid
// however, it's needed so updates will update the EntryCRC of *unchanged* files correctly // however, it's needed so updates will update the EntryCRC of *unchanged* files correctly
pGrpTo->EntryCRC32(strItemName); pGrpTo->EntryCRC32(strItemName);
// copy to sort list // copy to sort list
SAppend(strItemName, strSortList); SAppend(strItemName, strSortList);
SAppendChar('|', strSortList); SAppendChar('|', strSortList);
} }
// sort by list // sort by list
pGrpTo->Sort(strSortList); pGrpTo->Sort(strSortList);
delete[] pData; delete[] pData;
@ -673,7 +673,7 @@ bool C4UpdatePackage::MakeUpdate(const char *strFile1, const char *strFile2, con
// that would mess up the update result... // that would mess up the update result...
{ WriteLog("Error: could not add to update package - target groups don't match (checksum error)\n"); return false; } { WriteLog("Error: could not add to update package - target groups don't match (checksum error)\n"); return false; }
// already supported by this update? // already supported by this update?
int i = 0; int i = 0;
for(; i < UpGrpCnt; i++) for(; i < UpGrpCnt; i++)
if(GrpChks1[UpGrpCnt] == GrpChks1[i]) if(GrpChks1[UpGrpCnt] == GrpChks1[i])
break; break;
@ -729,7 +729,7 @@ bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bo
{ {
// add to entry list // add to entry list
if(!!EntryList) EntryList.AppendChar('|'); if(!!EntryList) EntryList.AppendChar('|');
EntryList.AppendFormat("%s=%d", strItemName, pGrp2->EntryTime(strItemName)); EntryList.AppendFormat("%s=%d", strItemName, pGrp2->EntryTime(strItemName));
// no modification detected yet? then check order // no modification detected yet? then check order
if(!*fModified) if(!*fModified)
{ {

View File

@ -31,7 +31,7 @@ class C4UpdatePackageCore
public: public:
C4UpdatePackageCore(); // ctor C4UpdatePackageCore(); // ctor
public: public:
int32_t RequireVersion[4]; int32_t RequireVersion[4];
char Name[C4MaxName+1]; char Name[C4MaxName+1];
char DestPath[_MAX_PATH+1]; char DestPath[_MAX_PATH+1];
int32_t GrpUpdate; int32_t GrpUpdate;

View File

@ -34,20 +34,20 @@
#include <assert.h> #include <assert.h>
CStdFile::CStdFile() CStdFile::CStdFile()
{ {
Status=false; Status=false;
hFile=NULL; hFile=NULL;
hgzFile=NULL; hgzFile=NULL;
pMemory=NULL; pMemory=NULL;
ClearBuffer(); ClearBuffer();
ModeWrite=false; ModeWrite=false;
Name[0]=0; Name[0]=0;
} }
CStdFile::~CStdFile() CStdFile::~CStdFile()
{ {
Close(); Close();
} }
bool CStdFile::Create(const char *szFilename, bool fCompressed, bool fExecutable, bool fMemory) bool CStdFile::Create(const char *szFilename, bool fCompressed, bool fExecutable, bool fMemory)
{ {
@ -94,45 +94,45 @@ bool CStdFile::Create(const char *szFilename, bool fCompressed, bool fExecutable
} }
bool CStdFile::Open(const char *szFilename, bool fCompressed) bool CStdFile::Open(const char *szFilename, bool fCompressed)
{ {
SCopy(szFilename,Name,_MAX_PATH); SCopy(szFilename,Name,_MAX_PATH);
// Set modes // Set modes
ModeWrite=false; ModeWrite=false;
// Open standard file // Open standard file
if (fCompressed) if (fCompressed)
{ if (!(hgzFile=gzopen(Name,"rb"))) return false; } { if (!(hgzFile=gzopen(Name,"rb"))) return false; }
else else
{ if (!(hFile=fopen(Name,"rb"))) return false; } { if (!(hFile=fopen(Name,"rb"))) return false; }
// Reset buffer // Reset buffer
ClearBuffer(); ClearBuffer();
// Set status // Set status
Status=true; Status=true;
return true; return true;
} }
bool CStdFile::Append(const char *szFilename) bool CStdFile::Append(const char *szFilename)
{ {
SCopy(szFilename,Name,_MAX_PATH); SCopy(szFilename,Name,_MAX_PATH);
// Set modes // Set modes
ModeWrite=true; ModeWrite=true;
// Open standard file // Open standard file
if (!(hFile=fopen(Name,"ab"))) return false; if (!(hFile=fopen(Name,"ab"))) return false;
// Reset buffer // Reset buffer
ClearBuffer(); ClearBuffer();
// Set status // Set status
Status=true; Status=true;
return true; return true;
} }
bool CStdFile::Close(StdBuf **ppMemory) bool CStdFile::Close(StdBuf **ppMemory)
{ {
bool rval=true; bool rval=true;
Status=false; Status=false;
Name[0]=0; Name[0]=0;
// Save buffer if in write mode // Save buffer if in write mode
if (ModeWrite && BufferLoad) if (!SaveBuffer()) rval=false; if (ModeWrite && BufferLoad) if (!SaveBuffer()) rval=false;
// Close file(s) // Close file(s)
if (hgzFile) if (gzclose(hgzFile)!=Z_OK) rval=false; if (hgzFile) if (gzclose(hgzFile)!=Z_OK) rval=false;
if (hFile) if (fclose(hFile)!=0) rval=false; if (hFile) if (fclose(hFile)!=0) rval=false;
if (pMemory) if (pMemory)
{ {
@ -144,11 +144,11 @@ bool CStdFile::Close(StdBuf **ppMemory)
MemoryPtr=0; MemoryPtr=0;
hgzFile=NULL; hFile=NULL; hgzFile=NULL; hFile=NULL;
return !!rval; return !!rval;
} }
bool CStdFile::Default() bool CStdFile::Default()
{ {
Status=false; Status=false;
Name[0]=0; Name[0]=0;
hgzFile=NULL; hgzFile=NULL;
hFile=NULL; hFile=NULL;
@ -184,51 +184,51 @@ bool CStdFile::Read(void *pBuffer, size_t iSize, size_t *ipFSize)
} }
int CStdFile::LoadBuffer() int CStdFile::LoadBuffer()
{ {
if (hFile) BufferLoad = fread(Buffer,1,CStdFileBufSize,hFile); if (hFile) BufferLoad = fread(Buffer,1,CStdFileBufSize,hFile);
if (hgzFile) BufferLoad = gzread(hgzFile, Buffer,CStdFileBufSize); if (hgzFile) BufferLoad = gzread(hgzFile, Buffer,CStdFileBufSize);
BufferPtr=0; BufferPtr=0;
return BufferLoad; return BufferLoad;
} }
bool CStdFile::SaveBuffer() bool CStdFile::SaveBuffer()
{ {
int saved = 0; int saved = 0;
if (hFile) saved=fwrite(Buffer,1,BufferLoad,hFile); if (hFile) saved=fwrite(Buffer,1,BufferLoad,hFile);
if (hgzFile) saved=gzwrite(hgzFile,Buffer,BufferLoad); if (hgzFile) saved=gzwrite(hgzFile,Buffer,BufferLoad);
if (pMemory) { pMemory->Append(Buffer, BufferLoad); saved = BufferLoad; } if (pMemory) { pMemory->Append(Buffer, BufferLoad); saved = BufferLoad; }
if (saved!=BufferLoad) return false; if (saved!=BufferLoad) return false;
BufferLoad=0; BufferLoad=0;
return true; return true;
} }
void CStdFile::ClearBuffer() void CStdFile::ClearBuffer()
{ {
BufferLoad=BufferPtr=0; BufferLoad=BufferPtr=0;
} }
bool CStdFile::Write(const void *pBuffer, int iSize) bool CStdFile::Write(const void *pBuffer, int iSize)
{ {
int transfer; int transfer;
if (!pBuffer) return false; if (!pBuffer) return false;
if (!ModeWrite) return false; if (!ModeWrite) return false;
BYTE *bypBuffer= (BYTE*) pBuffer; BYTE *bypBuffer= (BYTE*) pBuffer;
while (iSize>0) while (iSize>0)
{ {
// Space in buffer: Transfer as much as possible // Space in buffer: Transfer as much as possible
if (BufferLoad<CStdFileBufSize) if (BufferLoad<CStdFileBufSize)
{ {
transfer=Min(CStdFileBufSize-BufferLoad,iSize); transfer=Min(CStdFileBufSize-BufferLoad,iSize);
memcpy(Buffer+BufferLoad,bypBuffer,transfer); memcpy(Buffer+BufferLoad,bypBuffer,transfer);
BufferLoad+=transfer; BufferLoad+=transfer;
bypBuffer+=transfer; bypBuffer+=transfer;
iSize-=transfer; iSize-=transfer;
} }
// Buffer full: Save // Buffer full: Save
else if (!SaveBuffer()) return false; else if (!SaveBuffer()) return false;
} }
return true; return true;
} }
bool CStdFile::WriteString(const char *szStr) bool CStdFile::WriteString(const char *szStr)
{ {
@ -241,9 +241,9 @@ bool CStdFile::WriteString(const char *szStr)
} }
bool CStdFile::Rewind() bool CStdFile::Rewind()
{ {
if (ModeWrite) return false; if (ModeWrite) return false;
ClearBuffer(); ClearBuffer();
if (hFile) rewind(hFile); if (hFile) rewind(hFile);
if (hgzFile) if (hgzFile)
{ {
@ -251,7 +251,7 @@ bool CStdFile::Rewind()
if (!(hgzFile=gzopen(Name,"rb"))) return false; if (!(hgzFile=gzopen(Name,"rb"))) return false;
} }
return true; return true;
} }
bool CStdFile::Advance(int iOffset) bool CStdFile::Advance(int iOffset)
{ {

View File

@ -84,10 +84,10 @@ int dbg_printf(const char *strMessage, ...)
bool ProcessGroup(const char *szFilename) bool ProcessGroup(const char *szFilename)
{ {
C4Group hGroup; C4Group hGroup;
int iArg; int iArg;
bool fDeleteGroup = false; bool fDeleteGroup = false;
hGroup.SetStdOutput(true); hGroup.SetStdOutput(true);
int argc = globalArgC; int argc = globalArgC;
char **argv = globalArgV; char **argv = globalArgV;
@ -97,146 +97,146 @@ bool ProcessGroup(const char *szFilename)
printf("Group: %s\n",szFilename); printf("Group: %s\n",szFilename);
// Open group file // Open group file
if (hGroup.Open(szFilename, true)) if (hGroup.Open(szFilename, true))
{ {
// No commands: display contents // No commands: display contents
if (iFirstCommand<0) if (iFirstCommand<0)
{ {
hGroup.View("*"); hGroup.View("*");
} }
// Process commands // Process commands
else else
for (iArg=iFirstCommand; iArg<argc; iArg++) for (iArg=iFirstCommand; iArg<argc; iArg++)
{ {
// This argument is a command // This argument is a command
if (argv[iArg][0]=='-') if (argv[iArg][0]=='-')
{ {
// Handle commands // Handle commands
switch (argv[iArg][1]) switch (argv[iArg][1])
{ {
// Add // Add
case 'a': case 'a':
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-')) if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
printf("Missing argument for add command\n"); printf("Missing argument for add command\n");
else else
{ {
if ((argv[iArg][2]=='s') || (argv[iArg][2] && (argv[iArg][3]=='s')) ) if ((argv[iArg][2]=='s') || (argv[iArg][2] && (argv[iArg][3]=='s')) )
{ {
if ((iArg+2>=argc) || (argv[iArg+2][0]=='-')) if ((iArg+2>=argc) || (argv[iArg+2][0]=='-'))
printf("Missing argument for add as command\n"); printf("Missing argument for add as command\n");
else else
{ hGroup.Add(argv[iArg+1],argv[iArg+2]); iArg+=2; } { hGroup.Add(argv[iArg+1],argv[iArg+2]); iArg+=2; }
} }
else else
#ifdef _WIN32 #ifdef _WIN32
{ hGroup.Add(argv[iArg+1]); iArg++; } { hGroup.Add(argv[iArg+1]); iArg++; }
#else #else
{ hGroup.Add(argv[iArg+1], argv[iArg+1]); iArg++; } { hGroup.Add(argv[iArg+1], argv[iArg+1]); iArg++; }
#endif #endif
} }
break; break;
// Move // Move
case 'm': case 'm':
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-')) if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
printf("Missing argument for move command\n"); printf("Missing argument for move command\n");
else else
#ifdef _WIN32 #ifdef _WIN32
{ hGroup.Move(argv[iArg+1]); iArg++; } { hGroup.Move(argv[iArg+1]); iArg++; }
#else #else
{ hGroup.Move(argv[iArg+1], argv[iArg+1]); iArg++; } { hGroup.Move(argv[iArg+1], argv[iArg+1]); iArg++; }
#endif #endif
break; break;
// Extract // Extract
case 'e': case 'e':
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-')) if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
printf("Missing argument for extract command\n"); printf("Missing argument for extract command\n");
else else
{ {
if ((argv[iArg][2]=='t') || (argv[iArg][2] && (argv[iArg][3]=='s')) ) if ((argv[iArg][2]=='t') || (argv[iArg][2] && (argv[iArg][3]=='s')) )
{ {
if ((iArg+2>=argc) || (argv[iArg+2][0]=='-')) if ((iArg+2>=argc) || (argv[iArg+2][0]=='-'))
printf("Missing argument for extract as command\n"); printf("Missing argument for extract as command\n");
else else
{ hGroup.Extract(argv[iArg+1],argv[iArg+2]); iArg+=2; } { hGroup.Extract(argv[iArg+1],argv[iArg+2]); iArg+=2; }
} }
else else
{ hGroup.Extract(argv[iArg+1]); iArg++; } { hGroup.Extract(argv[iArg+1]); iArg++; }
} }
break; break;
// Delete // Delete
case 'd': case 'd':
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-')) if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
printf("Missing argument for delete command\n"); printf("Missing argument for delete command\n");
else else
{ hGroup.Delete(argv[iArg+1], fRecursive); iArg++; } { hGroup.Delete(argv[iArg+1], fRecursive); iArg++; }
break; break;
// Sort // Sort
case 's': case 's':
// First sort parameter overrides default Clonk sort list // First sort parameter overrides default Clonk sort list
C4Group_SetSortList(NULL); C4Group_SetSortList(NULL);
// Missing argument // Missing argument
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-')) if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
printf("Missing argument for sort command\n"); printf("Missing argument for sort command\n");
// Sort, advance to next argument // Sort, advance to next argument
else else
{ hGroup.Sort(argv[iArg+1]); iArg++; } { hGroup.Sort(argv[iArg+1]); iArg++; }
break; break;
// Rename // Rename
case 'r': case 'r':
if ((iArg+2>=argc) || (argv[iArg+1][0]=='-') || (argv[iArg+2][0]=='-')) if ((iArg+2>=argc) || (argv[iArg+1][0]=='-') || (argv[iArg+2][0]=='-'))
printf("Missing argument(s) for rename command\n"); printf("Missing argument(s) for rename command\n");
else else
{ hGroup.Rename(argv[iArg+1],argv[iArg+2]); iArg+=2; } { hGroup.Rename(argv[iArg+1],argv[iArg+2]); iArg+=2; }
break; break;
// View // View
case 'v': case 'v':
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-')) if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
{ hGroup.View("*"); } { hGroup.View("*"); }
else else
{ hGroup.View(argv[iArg+1]); iArg++; } { hGroup.View(argv[iArg+1]); iArg++; }
break; break;
// Make original // Make original
case 'o': case 'o':
hGroup.MakeOriginal(true); hGroup.MakeOriginal(true);
break; break;
// Pack // Pack
case 'p': case 'p':
printf("Packing...\n"); printf("Packing...\n");
// Close // Close
if (!hGroup.Close()) printf("Closing failed: %s\n",hGroup.GetError()); if (!hGroup.Close()) printf("Closing failed: %s\n",hGroup.GetError());
// Pack // Pack
else if (!C4Group_PackDirectory(szFilename)) printf("Pack failed\n"); else if (!C4Group_PackDirectory(szFilename)) printf("Pack failed\n");
// Reopen // Reopen
else if (!hGroup.Open(szFilename)) printf("Reopen failed: %s\n",hGroup.GetError()); else if (!hGroup.Open(szFilename)) printf("Reopen failed: %s\n",hGroup.GetError());
break; break;
// Unpack // Unpack
case 'u': case 'u':
printf("Unpacking...\n"); printf("Unpacking...\n");
// Close // Close
if (!hGroup.Close()) printf("Closing failed: %s\n",hGroup.GetError()); if (!hGroup.Close()) printf("Closing failed: %s\n",hGroup.GetError());
// Unpack // Unpack
else if (!C4Group_UnpackDirectory(szFilename)) printf("Unpack failed\n"); else if (!C4Group_UnpackDirectory(szFilename)) printf("Unpack failed\n");
// Reopen // Reopen
else if (!hGroup.Open(szFilename)) printf("Reopen failed: %s\n",hGroup.GetError()); else if (!hGroup.Open(szFilename)) printf("Reopen failed: %s\n",hGroup.GetError());
break; break;
// Unpack // Unpack
case 'x': case 'x':
printf("Exploding...\n"); printf("Exploding...\n");
// Close // Close
if (!hGroup.Close()) printf("Closing failed: %s\n",hGroup.GetError()); if (!hGroup.Close()) printf("Closing failed: %s\n",hGroup.GetError());
// Explode // Explode
else if (!C4Group_ExplodeDirectory(szFilename)) printf("Unpack failed\n"); else if (!C4Group_ExplodeDirectory(szFilename)) printf("Unpack failed\n");
// Reopen // Reopen
else if (!hGroup.Open(szFilename)) printf("Reopen failed: %s\n",hGroup.GetError()); else if (!hGroup.Open(szFilename)) printf("Reopen failed: %s\n",hGroup.GetError());
break; break;
// Print maker // Print maker
case 'k': case 'k':
printf("%s\n",hGroup.GetMaker()); printf("%s\n",hGroup.GetMaker());
break; break;
// Generate update // Generate update
case 'g': case 'g':
if ((iArg + 3 >= argc) || (argv[iArg+1][0] == '-') || (argv[iArg+2][0] == '-') || (argv[iArg+3][0] == '-')) if ((iArg + 3 >= argc) || (argv[iArg+1][0] == '-') || (argv[iArg+2][0] == '-') || (argv[iArg+3][0] == '-'))
printf("Update generation failed: too few arguments\n"); printf("Update generation failed: too few arguments\n");
else else
{ {
@ -261,11 +261,11 @@ bool ProcessGroup(const char *szFilename)
break; break;
// Optimize update generation target // Optimize update generation target
case 'z': case 'z':
if ((iArg + 1 >= argc) || (argv[iArg+1][0] == '-')) if ((iArg + 1 >= argc) || (argv[iArg+1][0] == '-'))
printf("Missing parameter for optimization\n"); printf("Missing parameter for optimization\n");
else else
{ {
printf("Optimizing %s...\n", argv[iArg+1]); printf("Optimizing %s...\n", argv[iArg+1]);
if(!C4UpdatePackage::Optimize(&hGroup, argv[iArg+1])) if(!C4UpdatePackage::Optimize(&hGroup, argv[iArg+1]))
printf("Optimization failed.\n"); printf("Optimization failed.\n");
iArg++; iArg++;
@ -278,11 +278,11 @@ bool ProcessGroup(const char *szFilename)
break; break;
#endif #endif
// Wait // Wait
case 'w': case 'w':
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-')) if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
printf("Missing argument for wait command\n"); printf("Missing argument for wait command\n");
else else
{ {
int iMilliseconds = 0; int iMilliseconds = 0;
sscanf(argv[iArg+1], "%d", &iMilliseconds); sscanf(argv[iArg+1], "%d", &iMilliseconds);
// Wait for specified time // Wait for specified time
@ -303,28 +303,28 @@ bool ProcessGroup(const char *szFilename)
printf("\n"); printf("\n");
} }
iArg++; iArg++;
} }
break; break;
// Undefined // Undefined
default: default:
printf("Unknown command: %s\n",argv[iArg]); printf("Unknown command: %s\n",argv[iArg]);
break; break;
} }
} }
else else
{ {
printf("Invalid parameter %s\n",argv[iArg]); printf("Invalid parameter %s\n",argv[iArg]);
} }
} }
// Error: output status // Error: output status
if (!SEqual(hGroup.GetError(),"No Error")) if (!SEqual(hGroup.GetError(),"No Error"))
printf("Status: %s\n",hGroup.GetError()); printf("Status: %s\n",hGroup.GetError());
// Close group file // Close group file
if (!hGroup.Close()) if (!hGroup.Close())
printf("Closing: %s\n",hGroup.GetError()); printf("Closing: %s\n",hGroup.GetError());
// Delete group file if desired (i.e. after apply update) // Delete group file if desired (i.e. after apply update)
if (fDeleteGroup) if (fDeleteGroup)
@ -333,13 +333,13 @@ bool ProcessGroup(const char *szFilename)
EraseItem(szFilename); EraseItem(szFilename);
} }
} }
// Couldn't open group // Couldn't open group
else else
{ {
printf("Status: %s\n",hGroup.GetError()); printf("Status: %s\n",hGroup.GetError());
} }
// Done // Done
return true; return true;
@ -405,7 +405,7 @@ int UnregisterShellExtensions()
bool Log(const char *msg) bool Log(const char *msg)
{ {
if (!fQuiet) if (!fQuiet)
printf("%s\n", msg); printf("%s\n", msg);
return 1; return 1;
} }
@ -433,7 +433,7 @@ void StdCompilerWarnCallback(void *pData, const char *szPosition, const char *sz
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// Scan options (scan including first parameter - this means the group filename cannot start with a '/'...) // Scan options (scan including first parameter - this means the group filename cannot start with a '/'...)
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
@ -506,18 +506,18 @@ int main(int argc, char *argv[])
printf("Error removing shell extensions.\n"); printf("Error removing shell extensions.\n");
// At least one parameter (filename, not option or command): process file(s) // At least one parameter (filename, not option or command): process file(s)
if ((argc>1) && (argv[1][0] != '/') && (argv[1][0] != '-')) // ...remember filenames cannot start with a forward slash because of options format if ((argc>1) && (argv[1][0] != '/') && (argv[1][0] != '-')) // ...remember filenames cannot start with a forward slash because of options format
{ {
// Wildcard in filename: use file search // Wildcard in filename: use file search
if (SCharCount('*',argv[1])) if (SCharCount('*',argv[1]))
ForEachFile(argv[1], &ProcessGroup); ForEachFile(argv[1], &ProcessGroup);
// Only one file // Only one file
else else
ProcessGroup(argv[1]); ProcessGroup(argv[1]);
} }
// Too few parameters: output help (if we didn't register stuff) // Too few parameters: output help (if we didn't register stuff)
else else
if (!fRegisterShell && !fUnregisterShell) if (!fRegisterShell && !fUnregisterShell)
{ {
printf("\n"); printf("\n");
@ -568,6 +568,6 @@ int main(int argc, char *argv[])
} }
// Done // Done
return iResult; return iResult;
} }

View File

@ -57,13 +57,13 @@ char strExecuteAtEnd[_MAX_PATH + 1] = "";
int iResult = 0; int iResult = 0;
bool EraseItemSafe(const char *szFilename) { bool EraseItemSafe(const char *szFilename) {
return false; return false;
} }
bool Log(const char *msg) { bool Log(const char *msg) {
if (!fQuiet) if (!fQuiet)
printf("%s\n", msg); printf("%s\n", msg);
return 1; return 1;
} }
#define IMPLEMENT_LOGF(func) \ #define IMPLEMENT_LOGF(func) \
bool func(const char *msg, ...) { \ bool func(const char *msg, ...) { \
@ -79,443 +79,443 @@ IMPLEMENT_LOGF(LogSilentF)
bool ProcessGroup(const char *FilenamePar) { bool ProcessGroup(const char *FilenamePar) {
C4Group hGroup; C4Group hGroup;
hGroup.SetStdOutput(!fQuiet); hGroup.SetStdOutput(!fQuiet);
bool fDeleteGroup = false; bool fDeleteGroup = false;
int argc = globalArgC; int argc = globalArgC;
char **argv = globalArgV; char **argv = globalArgV;
// Strip trailing slash // Strip trailing slash
char * szFilename = strdup(FilenamePar); char * szFilename = strdup(FilenamePar);
size_t len = strlen(szFilename); size_t len = strlen(szFilename);
if (szFilename[len-1] == DirectorySeparator) szFilename[len-1] = 0; if (szFilename[len-1] == DirectorySeparator) szFilename[len-1] = 0;
// Current filename // Current filename
LogF("Group: %s", szFilename); LogF("Group: %s", szFilename);
// Open group file // Open group file
if (hGroup.Open(szFilename, true)) { if (hGroup.Open(szFilename, true)) {
// No commands: display contents // No commands: display contents
if (iFirstCommand >= argc) { if (iFirstCommand >= argc) {
hGroup.SetStdOutput(true); hGroup.SetStdOutput(true);
hGroup.View("*"); hGroup.View("*");
hGroup.SetStdOutput(!fQuiet); hGroup.SetStdOutput(!fQuiet);
} }
// Process commands // Process commands
else { else {
for (int iArg = iFirstCommand; iArg < argc; ++iArg) { for (int iArg = iFirstCommand; iArg < argc; ++iArg) {
// This argument is a command // This argument is a command
if (argv[iArg][0] == '-') { if (argv[iArg][0] == '-') {
// Handle commands // Handle commands
switch (argv[iArg][1]) { switch (argv[iArg][1]) {
// Add // Add
case 'a': case 'a':
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-'))
fprintf(stderr, "Missing argument for add command\n"); fprintf(stderr, "Missing argument for add command\n");
else { else {
if ((argv[iArg][2] == 's') || (argv[iArg][2] && (argv[iArg][3] == 's'))) { if ((argv[iArg][2] == 's') || (argv[iArg][2] && (argv[iArg][3] == 's'))) {
if ((iArg + 2 >= argc) || (argv[iArg + 2][0] == '-')) { if ((iArg + 2 >= argc) || (argv[iArg + 2][0] == '-')) {
fprintf(stderr, "Missing argument for add as command\n"); fprintf(stderr, "Missing argument for add as command\n");
} else { } else {
hGroup.Add(argv[iArg + 1], argv[iArg + 2]); hGroup.Add(argv[iArg + 1], argv[iArg + 2]);
iArg += 2; iArg += 2;
} }
} else { } else {
while (iArg + 1 < argc && argv[iArg + 1][0] != '-') { while (iArg + 1 < argc && argv[iArg + 1][0] != '-') {
++iArg; ++iArg;
#ifdef _WIN32 #ifdef _WIN32
// manually expand wildcards // manually expand wildcards
hGroup.Add(argv[iArg]); hGroup.Add(argv[iArg]);
#else #else
hGroup.Add(argv[iArg], GetFilename(argv[iArg])); hGroup.Add(argv[iArg], GetFilename(argv[iArg]));
#endif #endif
} }
} }
} }
break; break;
// Move // Move
case 'm': case 'm':
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) { if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
fprintf(stderr, "Missing argument for move command\n"); fprintf(stderr, "Missing argument for move command\n");
} else { } else {
while (iArg + 1 < argc && argv[iArg + 1][0] != '-') { while (iArg + 1 < argc && argv[iArg + 1][0] != '-') {
++iArg; ++iArg;
#ifdef _WIN32 #ifdef _WIN32
// manually expand wildcards // manually expand wildcards
hGroup.Move(argv[iArg]); hGroup.Move(argv[iArg]);
#else #else
hGroup.Move(argv[iArg], argv[iArg]); hGroup.Move(argv[iArg], argv[iArg]);
#endif #endif
} }
} }
break; break;
// Extract // Extract
case 'e': case 'e':
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) { if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
fprintf(stderr, "Missing argument for extract command\n"); fprintf(stderr, "Missing argument for extract command\n");
} else { } else {
if ((argv[iArg][2] == 't') || (argv[iArg][2] && (argv[iArg][3] == 's'))) { if ((argv[iArg][2] == 't') || (argv[iArg][2] && (argv[iArg][3] == 's'))) {
if ((iArg + 2 >= argc) || (argv[iArg + 2][0] == '-')) { if ((iArg + 2 >= argc) || (argv[iArg + 2][0] == '-')) {
fprintf(stderr, "Missing argument for extract as command\n"); fprintf(stderr, "Missing argument for extract as command\n");
} else { } else {
hGroup.Extract(argv[iArg + 1], argv[iArg + 2]); hGroup.Extract(argv[iArg + 1], argv[iArg + 2]);
iArg += 2; iArg += 2;
} }
} else { } else {
hGroup.Extract(argv[iArg + 1]); hGroup.Extract(argv[iArg + 1]);
iArg++; iArg++;
} }
} }
break; break;
// Delete // Delete
case 'd': case 'd':
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) { if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
fprintf(stderr, "Missing argument for delete command\n"); fprintf(stderr, "Missing argument for delete command\n");
} else { } else {
hGroup.Delete(argv[iArg + 1], fRecursive); hGroup.Delete(argv[iArg + 1], fRecursive);
iArg++; iArg++;
} }
break; break;
// Sort // Sort
case 's': case 's':
// First sort parameter overrides default Clonk sort list // First sort parameter overrides default Clonk sort list
C4Group_SetSortList(NULL); C4Group_SetSortList(NULL);
// Missing argument // Missing argument
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) { if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
fprintf(stderr, "Missing argument for sort command\n"); fprintf(stderr, "Missing argument for sort command\n");
} }
// Sort, advance to next argument // Sort, advance to next argument
else { else {
hGroup.Sort(argv[iArg + 1]); hGroup.Sort(argv[iArg + 1]);
iArg++; iArg++;
} }
break; break;
// Rename // Rename
case 'r': case 'r':
if ((iArg + 2 >= argc) || (argv[iArg + 1][0] == '-') if ((iArg + 2 >= argc) || (argv[iArg + 1][0] == '-')
|| (argv[iArg + 2][0] == '-')) { || (argv[iArg + 2][0] == '-')) {
fprintf(stderr, "Missing argument(s) for rename command\n"); fprintf(stderr, "Missing argument(s) for rename command\n");
} else { } else {
hGroup.Rename(argv[iArg + 1], argv[iArg + 2]); hGroup.Rename(argv[iArg + 1], argv[iArg + 2]);
iArg += 2; iArg += 2;
} }
break; break;
// View // View
case 'l': case 'l':
hGroup.SetStdOutput(true); hGroup.SetStdOutput(true);
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) { if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
hGroup.View("*"); hGroup.View("*");
} else { } else {
hGroup.View(argv[iArg + 1]); hGroup.View(argv[iArg + 1]);
iArg++; iArg++;
} }
hGroup.SetStdOutput(!fQuiet); hGroup.SetStdOutput(!fQuiet);
break; break;
// Make original // Make original
case 'o': case 'o':
hGroup.MakeOriginal(true); hGroup.MakeOriginal(true);
break; break;
// Pack // Pack
case 'p': case 'p':
Log("Packing..."); Log("Packing...");
// Close // Close
if (!hGroup.Close()) { if (!hGroup.Close()) {
fprintf(stderr, "Closing failed: %s\n", hGroup.GetError()); fprintf(stderr, "Closing failed: %s\n", hGroup.GetError());
} }
// Pack // Pack
else if (!C4Group_PackDirectory(szFilename)) { else if (!C4Group_PackDirectory(szFilename)) {
fprintf(stderr, "Pack failed\n"); fprintf(stderr, "Pack failed\n");
} }
// Reopen // Reopen
else if (!hGroup.Open(szFilename)) { else if (!hGroup.Open(szFilename)) {
fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError()); fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError());
} }
break; break;
// Unpack // Unpack
case 'u': case 'u':
LogF("Unpacking..."); LogF("Unpacking...");
// Close // Close
if (!hGroup.Close()) { if (!hGroup.Close()) {
fprintf(stderr, "Closing failed: %s\n", hGroup.GetError()); fprintf(stderr, "Closing failed: %s\n", hGroup.GetError());
} }
// Pack // Pack
else if (!C4Group_UnpackDirectory(szFilename)) { else if (!C4Group_UnpackDirectory(szFilename)) {
fprintf(stderr, "Unpack failed\n"); fprintf(stderr, "Unpack failed\n");
} }
// Reopen // Reopen
else if (!hGroup.Open(szFilename)) { else if (!hGroup.Open(szFilename)) {
fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError()); fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError());
} }
break; break;
// Unpack // Unpack
case 'x': case 'x':
Log("Exploding..."); Log("Exploding...");
// Close // Close
if (!hGroup.Close()) { if (!hGroup.Close()) {
fprintf(stderr, "Closing failed: %s\n", hGroup.GetError()); fprintf(stderr, "Closing failed: %s\n", hGroup.GetError());
} }
// Pack // Pack
else if (!C4Group_ExplodeDirectory(szFilename)) { else if (!C4Group_ExplodeDirectory(szFilename)) {
fprintf(stderr, "Unpack failed\n"); fprintf(stderr, "Unpack failed\n");
} }
// Reopen // Reopen
else if (!hGroup.Open(szFilename)) { else if (!hGroup.Open(szFilename)) {
fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError()); fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError());
} }
break; break;
// Print maker // Print maker
case 'k': case 'k':
printf("%s\n", hGroup.GetMaker()); printf("%s\n", hGroup.GetMaker());
break; break;
// Generate update // Generate update
case 'g': case 'g':
if ((iArg + 3 >= argc) || (argv[iArg + 1][0] == '-') if ((iArg + 3 >= argc) || (argv[iArg + 1][0] == '-')
|| (argv[iArg + 2][0] == '-') || (argv[iArg + 2][0] == '-')
|| (argv[iArg + 3][0] == '-')) { || (argv[iArg + 3][0] == '-')) {
fprintf(stderr, "Update generation failed: too few arguments\n"); fprintf(stderr, "Update generation failed: too few arguments\n");
} else { } else {
C4UpdatePackage Upd; C4UpdatePackage Upd;
// Close // Close
if (!hGroup.Close()) { if (!hGroup.Close()) {
fprintf(stderr, "Closing failed: %s\n", hGroup.GetError()); fprintf(stderr, "Closing failed: %s\n", hGroup.GetError());
} }
// generate // generate
else if (!Upd.MakeUpdate(argv[iArg + 1], argv[iArg + 2], szFilename, argv[iArg + 3])) { else if (!Upd.MakeUpdate(argv[iArg + 1], argv[iArg + 2], szFilename, argv[iArg + 3])) {
fprintf(stderr, "Update generation failed.\n"); fprintf(stderr, "Update generation failed.\n");
} }
// Reopen // Reopen
else if (!hGroup.Open(szFilename)) { else if (!hGroup.Open(szFilename)) {
fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError()); fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError());
} }
iArg += 3; iArg += 3;
} }
break; break;
// Apply an update // Apply an update
case 'y': case 'y':
Log("Applying update..."); Log("Applying update...");
if (C4Group_ApplyUpdate(hGroup)) if (C4Group_ApplyUpdate(hGroup))
{ if (argv[iArg][2]=='d') fDeleteGroup = true; } { if (argv[iArg][2]=='d') fDeleteGroup = true; }
else else
fprintf(stderr,"Update failed.\n"); fprintf(stderr,"Update failed.\n");
break; break;
#ifdef _DEBUG #ifdef _DEBUG
case 'z': case 'z':
hGroup.PrintInternals(); hGroup.PrintInternals();
break; break;
#endif #endif
// Undefined // Undefined
default: default:
fprintf(stderr, "Unknown command: %s\n", argv[iArg]); fprintf(stderr, "Unknown command: %s\n", argv[iArg]);
break; break;
} }
} else { } else {
fprintf(stderr, "Invalid parameter %s\n", argv[iArg]); fprintf(stderr, "Invalid parameter %s\n", argv[iArg]);
} }
} }
} }
// Error: output status // Error: output status
if (!SEqual(hGroup.GetError(), "No Error")) { if (!SEqual(hGroup.GetError(), "No Error")) {
fprintf(stderr, "Status: %s\n", hGroup.GetError()); fprintf(stderr, "Status: %s\n", hGroup.GetError());
} }
// Close group file // Close group file
if (!hGroup.Close()) { if (!hGroup.Close()) {
fprintf(stderr, "Closing: %s\n", hGroup.GetError()); fprintf(stderr, "Closing: %s\n", hGroup.GetError());
} }
// Delete group file if desired (i.e. after apply update) // Delete group file if desired (i.e. after apply update)
if (fDeleteGroup) { if (fDeleteGroup) {
LogF("Deleting %s...\n", GetFilename(szFilename)); LogF("Deleting %s...\n", GetFilename(szFilename));
EraseItem(szFilename); EraseItem(szFilename);
} }
} }
// Couldn't open group // Couldn't open group
else { else {
fprintf(stderr, "Status: %s\n", hGroup.GetError()); fprintf(stderr, "Status: %s\n", hGroup.GetError());
} }
free(szFilename); free(szFilename);
// Done // Done
return true; return true;
} }
int RegisterShellExtensions() { int RegisterShellExtensions() {
#ifdef _WIN32 #ifdef _WIN32
char strModule[2048]; char strModule[2048];
char strCommand[2048]; char strCommand[2048];
char strClass[128]; char strClass[128];
int i; int i;
GetModuleFileName(NULL, strModule, 2048); GetModuleFileName(NULL, strModule, 2048);
// Groups // Groups
const char *strClasses = const char *strClasses =
"Clonk4.Definition;Clonk4.Folder;Clonk4.Group;Clonk4.Player;Clonk4.Scenario;Clonk4.Update;Clonk4.Weblink"; "Clonk4.Definition;Clonk4.Folder;Clonk4.Group;Clonk4.Player;Clonk4.Scenario;Clonk4.Update;Clonk4.Weblink";
for (i = 0; SCopySegment(strClasses, i, strClass); i++) { for (i = 0; SCopySegment(strClasses, i, strClass); i++) {
// Unpack // Unpack
sprintf(strCommand, "\"%s\" \"%%1\" \"-u\"", strModule); sprintf(strCommand, "\"%s\" \"%%1\" \"-u\"", strModule);
if (!SetRegShell(strClass, "MakeFolder", "C4Group Unpack", strCommand)) if (!SetRegShell(strClass, "MakeFolder", "C4Group Unpack", strCommand))
return 0; return 0;
// Explode // Explode
sprintf(strCommand, "\"%s\" \"%%1\" \"-x\"", strModule); sprintf(strCommand, "\"%s\" \"%%1\" \"-x\"", strModule);
if (!SetRegShell(strClass, "ExplodeFolder", "C4Group Explode", strCommand)) if (!SetRegShell(strClass, "ExplodeFolder", "C4Group Explode", strCommand))
return 0; return 0;
} }
// Directories // Directories
const char *strClasses2 = "Directory"; const char *strClasses2 = "Directory";
for (i = 0; SCopySegment(strClasses2, i, strClass); i++) { for (i = 0; SCopySegment(strClasses2, i, strClass); i++) {
// Pack // Pack
sprintf(strCommand, "\"%s\" \"%%1\" \"-p\"", strModule); sprintf(strCommand, "\"%s\" \"%%1\" \"-p\"", strModule);
if (!SetRegShell(strClass, "MakeGroupFile", "C4Group Pack", strCommand)) if (!SetRegShell(strClass, "MakeGroupFile", "C4Group Pack", strCommand))
return 0; return 0;
} }
// Done // Done
#endif #endif
return 1; return 1;
} }
int UnregisterShellExtensions() { int UnregisterShellExtensions() {
#ifdef _WIN32 #ifdef _WIN32
char strModule[2048]; char strModule[2048];
char strClass[128]; char strClass[128];
int i; int i;
GetModuleFileName(NULL, strModule, 2048); GetModuleFileName(NULL, strModule, 2048);
// Groups // Groups
const char *strClasses = const char *strClasses =
"Clonk4.Definition;Clonk4.Folder;Clonk4.Group;Clonk4.Player;Clonk4.Scenario;Clonk4.Update;Clonk4.Weblink"; "Clonk4.Definition;Clonk4.Folder;Clonk4.Group;Clonk4.Player;Clonk4.Scenario;Clonk4.Update;Clonk4.Weblink";
for (i = 0; SCopySegment(strClasses, i, strClass); i++) { for (i = 0; SCopySegment(strClasses, i, strClass); i++) {
// Unpack // Unpack
if (!RemoveRegShell(strClass, "MakeFolder")) if (!RemoveRegShell(strClass, "MakeFolder"))
return 0; return 0;
// Explode // Explode
if (!RemoveRegShell(strClass, "ExplodeFolder")) if (!RemoveRegShell(strClass, "ExplodeFolder"))
return 0; return 0;
} }
// Directories // Directories
const char *strClasses2 = "Directory"; const char *strClasses2 = "Directory";
for (i = 0; SCopySegment(strClasses2, i, strClass); i++) { for (i = 0; SCopySegment(strClasses2, i, strClass); i++) {
// Pack // Pack
if (!RemoveRegShell(strClass, "MakeGroupFile")) if (!RemoveRegShell(strClass, "MakeGroupFile"))
return 0; return 0;
} }
// Done // Done
#endif #endif
return 1; return 1;
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
#ifndef WIN32 #ifndef WIN32
// Always line buffer mode, even if the output is not sent to a terminal // Always line buffer mode, even if the output is not sent to a terminal
setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stdout, NULL, _IOLBF, 0);
#endif #endif
// Scan options // Scan options
int iFirstGroup = 0; int iFirstGroup = 0;
for (int i = 1; i < argc; ++i) { for (int i = 1; i < argc; ++i) {
// Option encountered // Option encountered
if (argv[i][0] == '-') { if (argv[i][0] == '-') {
switch (argv[i][1]) { switch (argv[i][1]) {
// Quiet mode // Quiet mode
case 'v': case 'v':
fQuiet = false; fQuiet = false;
break; break;
// Silent mode // Silent mode
//case 's': fSilent=true; break; //case 's': fSilent=true; break;
// Recursive mode // Recursive mode
case 'r': case 'r':
fRecursive = true; fRecursive = true;
break; break;
// Register shell // Register shell
case 'i': case 'i':
fRegisterShell = true; fRegisterShell = true;
break; break;
// Unregister shell // Unregister shell
case 'u': case 'u':
fUnregisterShell = true; fUnregisterShell = true;
break; break;
// Execute at end // Execute at end
case 'x': SCopy(argv[i] + 3, strExecuteAtEnd, _MAX_PATH); break; case 'x': SCopy(argv[i] + 3, strExecuteAtEnd, _MAX_PATH); break;
// Unknown // Unknown
default: default:
fprintf(stderr, "Unknown option %s\n", argv[i]); fprintf(stderr, "Unknown option %s\n", argv[i]);
break; break;
} }
} else { } else {
// filename encountered: no more options expected // filename encountered: no more options expected
iFirstGroup = i; iFirstGroup = i;
break; break;
} }
} }
iFirstCommand = iFirstGroup; iFirstCommand = iFirstGroup;
while (iFirstCommand < argc && argv[iFirstCommand][0] != '-') while (iFirstCommand < argc && argv[iFirstCommand][0] != '-')
++iFirstCommand; ++iFirstCommand;
// Program info // Program info
LogF("RedWolf Design C4Group %s", C4VERSION); LogF("RedWolf Design C4Group %s", C4VERSION);
// Registration check // Registration check
/* Config.Init(); /* Config.Init();
Config.Load(false);*/ Config.Load(false);*/
// Init C4Group // Init C4Group
/* C4Group_SetMaker(Config.General.Name); /* C4Group_SetMaker(Config.General.Name);
C4Group_SetTempPath(Config.General.TempPath);*/ C4Group_SetTempPath(Config.General.TempPath);*/
C4Group_SetSortList(C4CFN_FLS); C4Group_SetSortList(C4CFN_FLS);
// Store command line parameters // Store command line parameters
globalArgC = argc; globalArgC = argc;
globalArgV = argv; globalArgV = argv;
// Register shell // Register shell
if (fRegisterShell) { if (fRegisterShell) {
if (RegisterShellExtensions()) if (RegisterShellExtensions())
printf("Shell extensions registered.\n"); printf("Shell extensions registered.\n");
else else
printf("Error registering shell extensions.\n"); printf("Error registering shell extensions.\n");
} }
// Unregister shell // Unregister shell
if (fUnregisterShell) { if (fUnregisterShell) {
if (UnregisterShellExtensions()) if (UnregisterShellExtensions())
printf("Shell extensions removed.\n"); printf("Shell extensions removed.\n");
else else
printf("Error removing shell extensions.\n"); printf("Error removing shell extensions.\n");
} }
// At least one parameter (filename, not option or command): process file(s) // At least one parameter (filename, not option or command): process file(s)
if (iFirstGroup) { if (iFirstGroup) {
#ifdef _WIN32 #ifdef _WIN32
// Wildcard in filename: use file search // Wildcard in filename: use file search
if (SCharCount('*', argv[1])) if (SCharCount('*', argv[1]))
ForEachFile(argv[1], &ProcessGroup); ForEachFile(argv[1], &ProcessGroup);
// Only one file // Only one file
else else
ProcessGroup(argv[1]); ProcessGroup(argv[1]);
#else #else
for (int i = iFirstGroup; i < argc && argv[i][0] != '-'; ++i) for (int i = iFirstGroup; i < argc && argv[i][0] != '-'; ++i)
ProcessGroup(argv[i]); ProcessGroup(argv[i]);
#endif #endif
} }
// Too few parameters: output help (if we didn't register stuff) // Too few parameters: output help (if we didn't register stuff)
else if (!fRegisterShell && !fUnregisterShell) { else if (!fRegisterShell && !fUnregisterShell) {
printf("\n"); printf("\n");
printf("Usage: c4group [options] group(s) command(s)\n\n"); printf("Usage: c4group [options] group(s) command(s)\n\n");
printf("Commands: -a[s] Add [as] -m Move -e[t] Extract [to]\n"); printf("Commands: -a[s] Add [as] -m Move -e[t] Extract [to]\n");
printf(" -l List -d Delete -r Rename -s Sort\n"); printf(" -l List -d Delete -r Rename -s Sort\n");
printf(" -p Pack -u Unpack -x Explode\n"); printf(" -p Pack -u Unpack -x Explode\n");
printf(" -k Print maker\n"); printf(" -k Print maker\n");
printf(" -g [source] [target] [title] Make update\n"); printf(" -g [source] [target] [title] Make update\n");
printf(" -y Apply update\n"); printf(" -y Apply update\n");
printf("\n"); printf("\n");
printf("Options: -v Verbose -r Recursive\n"); printf("Options: -v Verbose -r Recursive\n");
printf(" -i Register shell -u Unregister shell\n"); printf(" -i Register shell -u Unregister shell\n");
printf(" -x:<command> Execute shell command when done\n"); printf(" -x:<command> Execute shell command when done\n");
printf("\n"); printf("\n");
printf("Examples: c4group pack.c4g -a myfile.dat -l \"*.dat\"\n"); printf("Examples: c4group pack.c4g -a myfile.dat -l \"*.dat\"\n");
printf(" c4group pack.c4g -as myfile.dat myfile.bin\n"); printf(" c4group pack.c4g -as myfile.dat myfile.bin\n");
printf(" c4group -v pack.c4g -et \"*.dat\" \\data\\mydatfiles\\\n"); printf(" c4group -v pack.c4g -et \"*.dat\" \\data\\mydatfiles\\\n");
printf(" c4group pack.c4g -et myfile.dat myfile.bak\n"); printf(" c4group pack.c4g -et myfile.dat myfile.bak\n");
printf(" c4group pack.c4g -s \"*.bin|*.dat\"\n"); printf(" c4group pack.c4g -s \"*.bin|*.dat\"\n");
printf(" c4group pack.c4g -x\n"); printf(" c4group pack.c4g -x\n");
printf(" c4group pack.c4g -k\n"); printf(" c4group pack.c4g -k\n");
printf(" c4group update.c4u -g ver1.c4f ver2.c4f New_Version\n"); printf(" c4group update.c4u -g ver1.c4f ver2.c4f New_Version\n");
printf(" c4group -i\n"); printf(" c4group -i\n");
} }
// Execute when done // Execute when done
if (strExecuteAtEnd[0]) if (strExecuteAtEnd[0])
@ -547,7 +547,7 @@ int main(int argc, char *argv[]) {
} }
#endif #endif
} }
// Done // Done
return iResult; return iResult;
} }

View File

@ -577,9 +577,9 @@ void C4ConfigGeneral::DeterminePaths(bool forceWorkingDirectory)
else else
SCopy("/tmp/", TempPath); SCopy("/tmp/", TempPath);
#else #else
// Mac: Just use the working directory as ExePath. // Mac: Just use the working directory as ExePath.
SCopy(GetWorkingDirectory(), ExePath); SCopy(GetWorkingDirectory(), ExePath);
AppendBackslash(ExePath); AppendBackslash(ExePath);
SCopy("/tmp/", TempPath); SCopy("/tmp/", TempPath);
#endif #endif
// Force working directory to exe path if desired // Force working directory to exe path if desired
@ -673,35 +673,35 @@ void C4ConfigGeneral::AddAdditionalDataPath(const char *szPath)
char AtPathFilename[_MAX_PATH+1]; char AtPathFilename[_MAX_PATH+1];
const char* C4Config::AtExePath(const char *szFilename) const char* C4Config::AtExePath(const char *szFilename)
{ {
SCopy(General.ExePath,AtPathFilename,_MAX_PATH); SCopy(General.ExePath,AtPathFilename,_MAX_PATH);
SAppend(szFilename,AtPathFilename,_MAX_PATH); SAppend(szFilename,AtPathFilename,_MAX_PATH);
return AtPathFilename; return AtPathFilename;
} }
const char* C4Config::AtUserDataPath(const char *szFilename) const char* C4Config::AtUserDataPath(const char *szFilename)
{ {
SCopy(General.UserDataPath, AtPathFilename, _MAX_PATH); SCopy(General.UserDataPath, AtPathFilename, _MAX_PATH);
SAppend(szFilename, AtPathFilename, _MAX_PATH); SAppend(szFilename, AtPathFilename, _MAX_PATH);
return AtPathFilename; return AtPathFilename;
} }
const char* C4Config::AtSystemDataPath(const char *szFilename) const char* C4Config::AtSystemDataPath(const char *szFilename)
{ {
SCopy(General.SystemDataPath, AtPathFilename, _MAX_PATH); SCopy(General.SystemDataPath, AtPathFilename, _MAX_PATH);
SAppend(szFilename, AtPathFilename, _MAX_PATH); SAppend(szFilename, AtPathFilename, _MAX_PATH);
return AtPathFilename; return AtPathFilename;
} }
const char* C4Config::AtTempPath(const char *szFilename) const char* C4Config::AtTempPath(const char *szFilename)
{ {
SCopy(General.TempPath,AtPathFilename,_MAX_PATH); SCopy(General.TempPath,AtPathFilename,_MAX_PATH);
SAppend(szFilename,AtPathFilename,_MAX_PATH); SAppend(szFilename,AtPathFilename,_MAX_PATH);
return AtPathFilename; return AtPathFilename;
} }
const char* C4Config::AtNetworkPath(const char *szFilename) const char* C4Config::AtNetworkPath(const char *szFilename)
{ {
SCopy(General.UserDataPath,AtPathFilename,_MAX_PATH); SCopy(General.UserDataPath,AtPathFilename,_MAX_PATH);
SAppend(Network.WorkPath,AtPathFilename,_MAX_PATH); SAppend(Network.WorkPath,AtPathFilename,_MAX_PATH);
SAppend(szFilename,AtPathFilename,_MAX_PATH); SAppend(szFilename,AtPathFilename,_MAX_PATH);

View File

@ -145,7 +145,7 @@ class C4ConfigGraphics
class C4ConfigSound class C4ConfigSound
{ {
public: public:
int32_t RXSound; int32_t RXSound;
int32_t RXMusic; int32_t RXMusic;
int32_t FEMusic; int32_t FEMusic;
int32_t FESamples; int32_t FESamples;
@ -165,7 +165,7 @@ class C4ConfigNetwork
int32_t NoRuntimeJoin; int32_t NoRuntimeJoin;
int32_t NoReferenceRequest; int32_t NoReferenceRequest;
int32_t MaxResSearchRecursion; int32_t MaxResSearchRecursion;
char WorkPath[CFG_MaxString+1]; char WorkPath[CFG_MaxString+1];
ValidatedStdCopyStrBuf<C4InVal::VAL_Comment> Comment; ValidatedStdCopyStrBuf<C4InVal::VAL_Comment> Comment;
int32_t MasterServerSignUp; int32_t MasterServerSignUp;
int32_t MasterServerActive; int32_t MasterServerActive;
@ -233,18 +233,18 @@ class C4ConfigExplorer
public: public:
int32_t Mode; int32_t Mode;
int32_t Run; int32_t Run;
char Definitions[CFG_MaxString+1]; char Definitions[CFG_MaxString+1];
char Engines[CFG_MaxString+1]; char Engines[CFG_MaxString+1];
char EditorBitmap[CFG_MaxString+1]; char EditorBitmap[CFG_MaxString+1];
char EditorPNG[CFG_MaxString+1]; char EditorPNG[CFG_MaxString+1];
char EditorMusic[CFG_MaxString+1]; char EditorMusic[CFG_MaxString+1];
char EditorRichText[CFG_MaxString+1]; char EditorRichText[CFG_MaxString+1];
char EditorScript[CFG_MaxString+1]; char EditorScript[CFG_MaxString+1];
char EditorText[CFG_MaxString+1]; char EditorText[CFG_MaxString+1];
char EditorSound[CFG_MaxString+1]; char EditorSound[CFG_MaxString+1];
char EditorZip[CFG_MaxString+1]; char EditorZip[CFG_MaxString+1];
char EditorDefinition[CFG_MaxString+1]; char EditorDefinition[CFG_MaxString+1];
char EditorHtml[CFG_MaxString+1]; char EditorHtml[CFG_MaxString+1];
char CommandLine[CFG_MaxString+1]; char CommandLine[CFG_MaxString+1];
int32_t EditorUseShell; int32_t EditorUseShell;
int32_t Kindersicherung; int32_t Kindersicherung;
@ -275,7 +275,7 @@ class C4ConfigControls
public: public:
int32_t GamepadGuiControl; int32_t GamepadGuiControl;
int32_t MouseAScroll; // auto scroll strength int32_t MouseAScroll; // auto scroll strength
int32_t Keyboard[C4MaxKeyboardSet][C4MaxKey]; int32_t Keyboard[C4MaxKeyboardSet][C4MaxKey];
void CompileFunc(StdCompiler *pComp, bool fKeysOnly=false); void CompileFunc(StdCompiler *pComp, bool fKeysOnly=false);
void ResetKeys(); // reset all keys to default void ResetKeys(); // reset all keys to default
}; };

View File

@ -63,7 +63,7 @@ EVP_PKEY* loadPublicKey(const char *memKey, bool deBase64 = false, bool deXOR =
unsigned int keyDataLen; unsigned int keyDataLen;
memset(keyData, 0, maxKeyDataLen + 1); memset(keyData, 0, maxKeyDataLen + 1);
// De-base64 certificate // De-base64 certificate
if (deBase64) if (deBase64)
{ {
// The man page says that the data memKey points to will not be modified by this // The man page says that the data memKey points to will not be modified by this
@ -80,7 +80,7 @@ EVP_PKEY* loadPublicKey(const char *memKey, bool deBase64 = false, bool deXOR =
memcpy(keyData, memKey, keyDataLen); memcpy(keyData, memKey, keyDataLen);
} }
// De-XOR certificate // De-XOR certificate
if (deXOR) if (deXOR)
{ {
int xorStrLen = strlen(strXOR); int xorStrLen = strlen(strXOR);
@ -102,7 +102,7 @@ EVP_PKEY* loadPublicKey(const char *memKey, bool deBase64 = false, bool deXOR =
void clearPublicKey(EVP_PKEY* pubKey) void clearPublicKey(EVP_PKEY* pubKey)
{ {
EVP_PKEY_free(pubKey); EVP_PKEY_free(pubKey);
} }
// Verifies the specified block of data using the public key provided. // Verifies the specified block of data using the public key provided.
@ -268,7 +268,7 @@ C4ConfigShareware::~C4ConfigShareware()
void C4ConfigShareware::Default() void C4ConfigShareware::Default()
{ {
ZeroMem(this, sizeof (C4ConfigShareware)); ZeroMem(this, sizeof (C4ConfigShareware));
C4Config::Default(); C4Config::Default();
} }

View File

@ -27,7 +27,7 @@
const size_t C4MaxTitle = 512; const size_t C4MaxTitle = 512;
const int const int
C4MaxDefString = 100, C4MaxDefString = 100,
C4MaxMessage = 256, C4MaxMessage = 256,
C4ViewDelay = 100, C4ViewDelay = 100,
@ -56,7 +56,7 @@ const int
#define C4GRI_USER 8 #define C4GRI_USER 8
const int C4M_MaxName = 15, const int C4M_MaxName = 15,
C4M_MaxDefName = 2*C4M_MaxName+1, C4M_MaxDefName = 2*C4M_MaxName+1,
C4M_MaxTexIndex = 127; // last texture map index is reserved for diff C4M_MaxTexIndex = 127; // last texture map index is reserved for diff
const int C4S_MaxPlayer = 4; const int C4S_MaxPlayer = 4;
@ -74,10 +74,10 @@ const int C4P_MaxPosition = 4;
const int C4P_Control_None = -1, const int C4P_Control_None = -1,
C4P_Control_Keyboard1 = 0, C4P_Control_Keyboard1 = 0,
C4P_Control_Keyboard2 = 1, C4P_Control_Keyboard2 = 1,
C4P_Control_Keyboard3 = 2, C4P_Control_Keyboard3 = 2,
C4P_Control_Keyboard4 = 3, C4P_Control_Keyboard4 = 3,
C4P_Control_GamePad1 = 4, C4P_Control_GamePad1 = 4,
C4P_Control_GamePad2 = 5, C4P_Control_GamePad2 = 5,
C4P_Control_GamePad3 = 6, C4P_Control_GamePad3 = 6,
C4P_Control_GamePad4 = 7, C4P_Control_GamePad4 = 7,
@ -96,22 +96,22 @@ const int C4XRV_Completed = 0,
const uint32_t OCF_None=0, const uint32_t OCF_None=0,
OCF_All=~OCF_None, OCF_All=~OCF_None,
OCF_Normal=1, OCF_Normal=1,
OCF_Construct=1<<1, OCF_Construct=1<<1,
OCF_Grab=1<<2, OCF_Grab=1<<2,
OCF_Carryable=1<<3, OCF_Carryable=1<<3,
OCF_OnFire=1<<4, OCF_OnFire=1<<4,
OCF_HitSpeed1=1<<5, OCF_HitSpeed1=1<<5,
OCF_FullCon=1<<6, OCF_FullCon=1<<6,
OCF_Inflammable=1<<7, OCF_Inflammable=1<<7,
OCF_Chop=1<<8, OCF_Chop=1<<8,
OCF_Rotate=1<<9, OCF_Rotate=1<<9,
OCF_Exclusive=1<<10, OCF_Exclusive=1<<10,
OCF_Entrance=1<<11, OCF_Entrance=1<<11,
OCF_HitSpeed2=1<<12, OCF_HitSpeed2=1<<12,
OCF_HitSpeed3=1<<13, OCF_HitSpeed3=1<<13,
OCF_Collection=1<<14, OCF_Collection=1<<14,
OCF_Living=1<<15, OCF_Living=1<<15,
OCF_HitSpeed4=1<<16, OCF_HitSpeed4=1<<16,
OCF_FightReady=1<<17, OCF_FightReady=1<<17,
OCF_LineConstruct=1<<18, OCF_LineConstruct=1<<18,
OCF_Prey=1<<19, OCF_Prey=1<<19,
@ -134,7 +134,7 @@ const BYTE // Directional
CNAT_None = 0, CNAT_None = 0,
CNAT_Left = 1, CNAT_Left = 1,
CNAT_Right = 2, CNAT_Right = 2,
CNAT_Top = 4, CNAT_Top = 4,
CNAT_Bottom = 8, CNAT_Bottom = 8,
CNAT_Center = 16, CNAT_Center = 16,
// Additional flags // Additional flags
@ -163,16 +163,16 @@ const int CON_CursorLeft = 0,
//=================================== Control Commands ====================================================== //=================================== Control Commands ======================================================
const BYTE COM_Single = 64, const BYTE COM_Single = 64,
COM_Double = 128; COM_Double = 128;
const BYTE COM_None = 0; const BYTE COM_None = 0;
const BYTE COM_Left = 1, const BYTE COM_Left = 1,
COM_Right = 2, COM_Right = 2,
COM_Up = 3, COM_Up = 3,
COM_Down = 4, COM_Down = 4,
COM_Throw = 5, COM_Throw = 5,
COM_Dig = 6, COM_Dig = 6,
COM_Special = 7, COM_Special = 7,
COM_Special2 = 8, COM_Special2 = 8,
@ -182,60 +182,60 @@ const BYTE COM_Left = 1,
COM_WheelUp = 10, COM_WheelUp = 10,
COM_WheelDown= 11, COM_WheelDown= 11,
COM_Left_R = COM_Left + 16, COM_Left_R = COM_Left + 16,
COM_Right_R = COM_Right + 16, COM_Right_R = COM_Right + 16,
COM_Up_R = COM_Up + 16, COM_Up_R = COM_Up + 16,
COM_Down_R = COM_Down + 16, COM_Down_R = COM_Down + 16,
COM_Throw_R = COM_Throw + 16, COM_Throw_R = COM_Throw + 16,
COM_Dig_R = COM_Dig + 16, COM_Dig_R = COM_Dig + 16,
COM_Special_R = COM_Special + 16, COM_Special_R = COM_Special + 16,
COM_Special2_R = COM_Special2 + 16, COM_Special2_R = COM_Special2 + 16,
COM_ReleaseFirst = COM_Left_R, COM_ReleaseFirst = COM_Left_R,
COM_ReleaseLast = COM_Special2_R, COM_ReleaseLast = COM_Special2_R,
COM_Left_S = COM_Left | COM_Single, COM_Left_S = COM_Left | COM_Single,
COM_Right_S = COM_Right | COM_Single, COM_Right_S = COM_Right | COM_Single,
COM_Up_S = COM_Up | COM_Single, COM_Up_S = COM_Up | COM_Single,
COM_Down_S = COM_Down | COM_Single, COM_Down_S = COM_Down | COM_Single,
COM_Throw_S = COM_Throw | COM_Single, COM_Throw_S = COM_Throw | COM_Single,
COM_Dig_S = COM_Dig | COM_Single, COM_Dig_S = COM_Dig | COM_Single,
COM_Special_S = COM_Special | COM_Single, COM_Special_S = COM_Special | COM_Single,
COM_Special2_S = COM_Special2 | COM_Single, COM_Special2_S = COM_Special2 | COM_Single,
COM_Left_D = COM_Left | COM_Double, COM_Left_D = COM_Left | COM_Double,
COM_Right_D = COM_Right | COM_Double, COM_Right_D = COM_Right | COM_Double,
COM_Up_D = COM_Up | COM_Double, COM_Up_D = COM_Up | COM_Double,
COM_Down_D = COM_Down | COM_Double, COM_Down_D = COM_Down | COM_Double,
COM_Throw_D = COM_Throw | COM_Double, COM_Throw_D = COM_Throw | COM_Double,
COM_Dig_D = COM_Dig | COM_Double, COM_Dig_D = COM_Dig | COM_Double,
COM_Special_D = COM_Special | COM_Double, COM_Special_D = COM_Special | COM_Double,
COM_Special2_D = COM_Special2 | COM_Double; COM_Special2_D = COM_Special2 | COM_Double;
const BYTE COM_CursorLeft = 30, const BYTE COM_CursorLeft = 30,
COM_CursorRight = 31, COM_CursorRight = 31,
COM_CursorToggle = 32; COM_CursorToggle = 32;
const BYTE COM_CursorToggle_D = COM_CursorToggle | COM_Double; const BYTE COM_CursorToggle_D = COM_CursorToggle | COM_Double;
const BYTE COM_Help = 35, const BYTE COM_Help = 35,
COM_PlayerMenu = 36, COM_PlayerMenu = 36,
COM_Chat = 37; COM_Chat = 37;
const BYTE COM_MenuEnter = 38, const BYTE COM_MenuEnter = 38,
COM_MenuEnterAll = 39, COM_MenuEnterAll = 39,
COM_MenuClose = 40, COM_MenuClose = 40,
COM_MenuShowText = 42, COM_MenuShowText = 42,
COM_MenuLeft = 52, COM_MenuLeft = 52,
COM_MenuRight = 53, COM_MenuRight = 53,
COM_MenuUp = 54, COM_MenuUp = 54,
COM_MenuDown = 55, COM_MenuDown = 55,
COM_MenuSelect = 60, COM_MenuSelect = 60,
COM_MenuFirst = COM_MenuEnter, COM_MenuFirst = COM_MenuEnter,
COM_MenuLast = COM_MenuSelect, COM_MenuLast = COM_MenuSelect,
COM_MenuNavigation1 = COM_MenuShowText, COM_MenuNavigation1 = COM_MenuShowText,
COM_MenuNavigation2 = COM_MenuSelect; COM_MenuNavigation2 = COM_MenuSelect;
//=================================== SendCommand ======================================== //=================================== SendCommand ========================================
const int32_t C4P_Command_None = 0, const int32_t C4P_Command_None = 0,
@ -247,7 +247,7 @@ const int32_t C4P_Command_None = 0,
//=================================== Owners ============================================== //=================================== Owners ==============================================
const int NO_OWNER = -1, const int NO_OWNER = -1,
ANY_OWNER = -2, ANY_OWNER = -2,
BY_OWNER = 10000, BY_OWNER = 10000,
BY_HOSTILE_OWNER = 20000; BY_HOSTILE_OWNER = 20000;
@ -255,9 +255,9 @@ const int NO_OWNER = -1,
enum C4LeagueDisconnectReason enum C4LeagueDisconnectReason
{ {
C4LDR_Unknown, C4LDR_Unknown,
C4LDR_ConnectionFailed, C4LDR_ConnectionFailed,
C4LDR_Desync C4LDR_Desync
}; };
//=================================== Player (included by C4PlayerInfo and C4Player) //=================================== Player (included by C4PlayerInfo and C4Player)
@ -265,7 +265,7 @@ enum C4LeagueDisconnectReason
enum C4PlayerType enum C4PlayerType
{ {
C4PT_None=0, C4PT_None=0,
C4PT_User=1, // Normal player C4PT_User=1, // Normal player
C4PT_Script=2 // AI players, etc. C4PT_Script=2 // AI players, etc.
}; };

View File

@ -59,7 +59,7 @@ C4ControlPacket::~C4ControlPacket()
bool C4ControlPacket::LocalControl() const bool C4ControlPacket::LocalControl() const
{ {
return iByClient == ::Control.ClientID(); return iByClient == ::Control.ClientID();
} }
void C4ControlPacket::SetByClient(int32_t inByClient) void C4ControlPacket::SetByClient(int32_t inByClient)
@ -92,9 +92,9 @@ void C4Control::Clear()
bool C4Control::PreExecute() const bool C4Control::PreExecute() const
{ {
bool fReady = true; bool fReady = true;
for(C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt)) for(C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
{ {
// recheck packet type: Must be control // recheck packet type: Must be control
if (pPkt->getPktType() & CID_First) if (pPkt->getPktType() & CID_First)
{ {
@ -106,14 +106,14 @@ bool C4Control::PreExecute() const
{ {
LogF("C4Control::PreExecute: WARNING: Ignoring packet type %2x (not control.)", pPkt->getPktType()); LogF("C4Control::PreExecute: WARNING: Ignoring packet type %2x (not control.)", pPkt->getPktType());
} }
} }
return fReady; return fReady;
} }
void C4Control::Execute() const void C4Control::Execute() const
{ {
for(C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt)) for(C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
{ {
// recheck packet type: Must be control // recheck packet type: Must be control
if (pPkt->getPktType() & CID_First) if (pPkt->getPktType() & CID_First)
{ {
@ -125,22 +125,22 @@ void C4Control::Execute() const
{ {
LogF("C4Control::Execute: WARNING: Ignoring packet type %2x (not control.)", pPkt->getPktType()); LogF("C4Control::Execute: WARNING: Ignoring packet type %2x (not control.)", pPkt->getPktType());
} }
} }
} }
void C4Control::PreRec(C4Record *pRecord) const void C4Control::PreRec(C4Record *pRecord) const
{ {
for(C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt)) for(C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
{ {
C4ControlPacket *pCtrlPkt = static_cast<C4ControlPacket *>(pPkt->getPkt()); C4ControlPacket *pCtrlPkt = static_cast<C4ControlPacket *>(pPkt->getPkt());
if(pCtrlPkt) if(pCtrlPkt)
pCtrlPkt->PreRec(pRecord); pCtrlPkt->PreRec(pRecord);
} }
} }
void C4Control::CompileFunc(StdCompiler *pComp) void C4Control::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(Pkts); pComp->Value(Pkts);
} }
// *** C4ControlSet // *** C4ControlSet
@ -184,14 +184,14 @@ void C4ControlSet::Execute() const
case C4CVT_MaxPlayer: case C4CVT_MaxPlayer:
// host only // host only
if(iByClient != C4ClientIDHost) break; if(iByClient != C4ClientIDHost) break;
// not in league // not in league
if (Game.Parameters.isLeague()) if (Game.Parameters.isLeague())
{ {
Log("/set maxplayer disabled in league!"); Log("/set maxplayer disabled in league!");
C4GUI::GUISound("Error"); C4GUI::GUISound("Error");
break; break;
} }
// set it // set it
Game.Parameters.MaxPlayers = iData; Game.Parameters.MaxPlayers = iData;
LogF("MaxPlayer = %d", (int)Game.Parameters.MaxPlayers); LogF("MaxPlayer = %d", (int)Game.Parameters.MaxPlayers);
break; break;
@ -210,7 +210,7 @@ void C4ControlSet::Execute() const
Game.Teams.SetTeamColors(!!iData); Game.Teams.SetTeamColors(!!iData);
break; break;
case C4CVT_FairCrew: case C4CVT_FairCrew:
// host only // host only
if(!HostControl()) break; if(!HostControl()) break;
// deny setting if it's fixed by scenario // deny setting if it's fixed by scenario
@ -219,17 +219,17 @@ void C4ControlSet::Execute() const
if (::Control.isCtrlHost()) Log(LoadResStr("IDS_MSG_NOMODIFYFAIRCREW")); if (::Control.isCtrlHost()) Log(LoadResStr("IDS_MSG_NOMODIFYFAIRCREW"));
break; break;
} }
// set new value // set new value
if(iData < 0) if(iData < 0)
{ {
Game.Parameters.UseFairCrew = false; Game.Parameters.UseFairCrew = false;
Game.Parameters.FairCrewStrength = 0; Game.Parameters.FairCrewStrength = 0;
} }
else else
{ {
Game.Parameters.UseFairCrew = true; Game.Parameters.UseFairCrew = true;
Game.Parameters.FairCrewStrength = iData; Game.Parameters.FairCrewStrength = iData;
} }
// runtime updates for runtime fairness adjustments // runtime updates for runtime fairness adjustments
if (Game.IsRunning) if (Game.IsRunning)
{ {
@ -254,15 +254,15 @@ void C4ControlSet::Execute() const
// this setting is part of the reference // this setting is part of the reference
if (::Network.isEnabled() && ::Network.isHost()) if (::Network.isEnabled() && ::Network.isHost())
::Network.InvalidateReference(); ::Network.InvalidateReference();
break; break;
} }
} }
void C4ControlSet::CompileFunc(StdCompiler *pComp) void C4ControlSet::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(mkIntAdapt(eValType), "Type", C4CVT_None)); pComp->Value(mkNamingAdapt(mkIntAdapt(eValType), "Type", C4CVT_None));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iData), "Data", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iData), "Data", 0));
C4ControlPacket::CompileFunc(pComp); C4ControlPacket::CompileFunc(pComp);
} }
// *** C4ControlScript // *** C4ControlScript
@ -311,10 +311,10 @@ void C4ControlScript::Execute() const
void C4ControlScript::CompileFunc(StdCompiler *pComp) void C4ControlScript::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(iTargetObj, "TargetObj", -1)); pComp->Value(mkNamingAdapt(iTargetObj, "TargetObj", -1));
pComp->Value(mkNamingAdapt(fInternal, "Internal", false)); pComp->Value(mkNamingAdapt(fInternal, "Internal", false));
pComp->Value(mkNamingAdapt(Script, "Script", "")); pComp->Value(mkNamingAdapt(Script, "Script", ""));
C4ControlPacket::CompileFunc(pComp); C4ControlPacket::CompileFunc(pComp);
} }
// *** C4ControlPlayerSelect // *** C4ControlPlayerSelect
@ -365,15 +365,15 @@ void C4ControlPlayerSelect::Execute() const
void C4ControlPlayerSelect::CompileFunc(StdCompiler *pComp) void C4ControlPlayerSelect::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(iPlr, "Player", -1)); pComp->Value(mkNamingAdapt(iPlr, "Player", -1));
pComp->Value(mkNamingAdapt(fIsAlt, "IsAlt", false)); pComp->Value(mkNamingAdapt(fIsAlt, "IsAlt", false));
pComp->Value(mkNamingAdapt(iObjCnt, "ObjCnt", 0)); pComp->Value(mkNamingAdapt(iObjCnt, "ObjCnt", 0));
// Compile array // Compile array
if(pComp->isCompiler()) if(pComp->isCompiler())
{ delete[] pObjNrs; pObjNrs = new int32_t [iObjCnt]; } { delete[] pObjNrs; pObjNrs = new int32_t [iObjCnt]; }
pComp->Value(mkNamingAdapt(mkArrayAdapt(pObjNrs, iObjCnt), "Objs", 0)); pComp->Value(mkNamingAdapt(mkArrayAdapt(pObjNrs, iObjCnt), "Objs", 0));
C4ControlPacket::CompileFunc(pComp); C4ControlPacket::CompileFunc(pComp);
} }
@ -443,15 +443,15 @@ void C4ControlPlayerCommand::Execute() const
void C4ControlPlayerCommand::CompileFunc(StdCompiler *pComp) void C4ControlPlayerCommand::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iPlr), "Player", -1)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iPlr), "Player", -1));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iCmd), "Cmd", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iCmd), "Cmd", 0));
pComp->Value(mkNamingAdapt(iX, "X", 0)); pComp->Value(mkNamingAdapt(iX, "X", 0));
pComp->Value(mkNamingAdapt(iY, "Y", 0)); pComp->Value(mkNamingAdapt(iY, "Y", 0));
pComp->Value(mkNamingAdapt(iTarget, "Target", 0)); pComp->Value(mkNamingAdapt(iTarget, "Target", 0));
pComp->Value(mkNamingAdapt(iTarget2, "Target2", 0)); pComp->Value(mkNamingAdapt(iTarget2, "Target2", 0));
pComp->Value(mkNamingAdapt(iData, "Data", 0)); pComp->Value(mkNamingAdapt(iData, "Data", 0));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iAddMode), "AddMode", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iAddMode), "AddMode", 0));
C4ControlPacket::CompileFunc(pComp); C4ControlPacket::CompileFunc(pComp);
} }
// *** C4ControlSyncCheck // *** C4ControlSyncCheck
@ -464,7 +464,7 @@ void C4ControlSyncCheck::Set()
{ {
extern int32_t FRndPtr3; extern int32_t FRndPtr3;
Frame = Game.FrameCounter; Frame = Game.FrameCounter;
ControlTick = ::Control.ControlTick; ControlTick = ::Control.ControlTick;
Random3 = FRndPtr3; Random3 = FRndPtr3;
RandomCount = ::RandomCount; RandomCount = ::RandomCount;
AllCrewPosX = GetAllCrewPosX(); AllCrewPosX = GetAllCrewPosX();
@ -518,7 +518,7 @@ void C4ControlSyncCheck::Execute() const
LogFatal(FormatString("Network: %s Frm %i Ctrl %i Rnc %i Rn3 %i Cpx %i PXS %i MMi %i Obc %i Oei %i Sct %i", szOther, SyncCheck.Frame,SyncCheck.ControlTick,SyncCheck.RandomCount,SyncCheck.Random3,SyncCheck.AllCrewPosX,SyncCheck.PXSCount,SyncCheck.MassMoverIndex,SyncCheck.ObjectCount,SyncCheck.ObjectEnumerationIndex, SyncCheck.SectShapeSum).getData()); LogFatal(FormatString("Network: %s Frm %i Ctrl %i Rnc %i Rn3 %i Cpx %i PXS %i MMi %i Obc %i Oei %i Sct %i", szOther, SyncCheck.Frame,SyncCheck.ControlTick,SyncCheck.RandomCount,SyncCheck.Random3,SyncCheck.AllCrewPosX,SyncCheck.PXSCount,SyncCheck.MassMoverIndex,SyncCheck.ObjectCount,SyncCheck.ObjectEnumerationIndex, SyncCheck.SectShapeSum).getData());
StartSoundEffect("SyncError"); StartSoundEffect("SyncError");
#ifdef _DEBUG #ifdef _DEBUG
// Debug safe // Debug safe
C4GameSaveNetwork SaveGame(false); C4GameSaveNetwork SaveGame(false);
SaveGame.Save(Config.AtExePath("Desync.c4s")); SaveGame.Save(Config.AtExePath("Desync.c4s"));
#endif #endif
@ -538,17 +538,17 @@ void C4ControlSyncCheck::Execute() const
void C4ControlSyncCheck::CompileFunc(StdCompiler *pComp) void C4ControlSyncCheck::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(mkIntPackAdapt(Frame), "Frame", -1)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(Frame), "Frame", -1));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(ControlTick), "ControlTick", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(ControlTick), "ControlTick", 0));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(Random3), "Random3", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(Random3), "Random3", 0));
pComp->Value(mkNamingAdapt(RandomCount, "RandomCount", 0)); pComp->Value(mkNamingAdapt(RandomCount, "RandomCount", 0));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(AllCrewPosX), "AllCrewPosX", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(AllCrewPosX), "AllCrewPosX", 0));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(PXSCount), "PXSCount", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(PXSCount), "PXSCount", 0));
pComp->Value(mkNamingAdapt(MassMoverIndex, "MassMoverIndex", 0)); pComp->Value(mkNamingAdapt(MassMoverIndex, "MassMoverIndex", 0));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(ObjectCount), "ObjectCount", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(ObjectCount), "ObjectCount", 0));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(ObjectEnumerationIndex), "ObjectEnumerationIndex", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(ObjectEnumerationIndex), "ObjectEnumerationIndex", 0));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(SectShapeSum), "SectShapeSum", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(SectShapeSum), "SectShapeSum", 0));
C4ControlPacket::CompileFunc(pComp); C4ControlPacket::CompileFunc(pComp);
} }
// *** C4ControlSynchronize // *** C4ControlSynchronize
@ -556,14 +556,14 @@ void C4ControlSyncCheck::CompileFunc(StdCompiler *pComp)
void C4ControlSynchronize::Execute() const void C4ControlSynchronize::Execute() const
{ {
Game.Synchronize(fSavePlrFiles); Game.Synchronize(fSavePlrFiles);
if(fSyncClearance) Game.SyncClearance(); if(fSyncClearance) Game.SyncClearance();
} }
void C4ControlSynchronize::CompileFunc(StdCompiler *pComp) void C4ControlSynchronize::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(fSavePlrFiles, "SavePlrs", false)); pComp->Value(mkNamingAdapt(fSavePlrFiles, "SavePlrs", false));
pComp->Value(mkNamingAdapt(fSyncClearance, "SyncClear", false)); pComp->Value(mkNamingAdapt(fSyncClearance, "SyncClear", false));
C4ControlPacket::CompileFunc(pComp); C4ControlPacket::CompileFunc(pComp);
} }
// *** C4ControlClientJoin // *** C4ControlClientJoin
@ -608,7 +608,7 @@ void C4ControlClientUpdate::Execute() const
// nothing to do? // nothing to do?
if(pClient->isActivated() == !!iData) break; if(pClient->isActivated() == !!iData) break;
// log // log
LogF(LoadResStr(iData ? "IDS_NET_CLIENT_ACTIVATED" : "IDS_NET_CLIENT_DEACTIVATED"), strClient.getData(), pClient->getName()); LogF(LoadResStr(iData ? "IDS_NET_CLIENT_ACTIVATED" : "IDS_NET_CLIENT_DEACTIVATED"), strClient.getData(), pClient->getName());
// activate/deactivate // activate/deactivate
pClient->SetActivated(!!iData); pClient->SetActivated(!!iData);
// local? // local?
@ -619,7 +619,7 @@ void C4ControlClientUpdate::Execute() const
// nothing to do? // nothing to do?
if(pClient->isObserver()) break; if(pClient->isObserver()) break;
// log // log
LogF(LoadResStr("IDS_NET_CLIENT_OBSERVE"), strClient.getData(), pClient->getName()); LogF(LoadResStr("IDS_NET_CLIENT_OBSERVE"), strClient.getData(), pClient->getName());
// set observer (will deactivate) // set observer (will deactivate)
pClient->SetObserver(); pClient->SetObserver();
// local? // local?
@ -670,7 +670,7 @@ void C4ControlClientRemove::Execute() const
// remove client // remove client
if(!Game.Clients.Remove(pClient)) return; if(!Game.Clients.Remove(pClient)) return;
// log // log
LogF(LoadResStr("IDS_NET_CLIENT_REMOVED"), strClient.getData(), pClient->getName(), strReason.getData()); LogF(LoadResStr("IDS_NET_CLIENT_REMOVED"), strClient.getData(), pClient->getName(), strReason.getData());
// remove all players // remove all players
::Players.RemoveAtClient(iID, true); ::Players.RemoveAtClient(iID, true);
// remove all resources // remove all resources
@ -762,8 +762,8 @@ void C4ControlJoinPlayer::Execute() const
// Local player: Just join from local file // Local player: Just join from local file
Game.JoinPlayer(szFilename, iAtClient, pClient->getName(), pInfo); Game.JoinPlayer(szFilename, iAtClient, pClient->getName(), pInfo);
} }
else if(!fByRes) else if(!fByRes)
{ {
if (PlrData.getSize()) if (PlrData.getSize())
{ {
// create temp file // create temp file
@ -788,7 +788,7 @@ void C4ControlJoinPlayer::Execute() const
assert(false); assert(false);
return; return;
} }
} }
else if(::Control.isNetwork()) else if(::Control.isNetwork())
{ {
// Find ressource // Find ressource
@ -811,12 +811,12 @@ void C4ControlJoinPlayer::Strip()
{ {
// By resource? Can't touch player file, then. // By resource? Can't touch player file, then.
if(fByRes) return; if(fByRes) return;
// create temp file // create temp file
StdStrBuf PlayerFilename; PlayerFilename = GetFilename(Filename.getData()); StdStrBuf PlayerFilename; PlayerFilename = GetFilename(Filename.getData());
PlayerFilename = Config.AtTempPath(PlayerFilename.getData()); PlayerFilename = Config.AtTempPath(PlayerFilename.getData());
// Copy to it // Copy to it
if(PlrData.SaveToFile(PlayerFilename.getData())) if(PlrData.SaveToFile(PlayerFilename.getData()))
{ {
// open as group // open as group
C4Group Grp; C4Group Grp;
if(!Grp.Open(PlayerFilename.getData())) if(!Grp.Open(PlayerFilename.getData()))
@ -836,29 +836,29 @@ void C4ControlJoinPlayer::Strip()
PlrData = NewPlrData; PlrData = NewPlrData;
// Done // Done
EraseFile(PlayerFilename.getData()); EraseFile(PlayerFilename.getData());
} }
} }
bool C4ControlJoinPlayer::PreExecute() const bool C4ControlJoinPlayer::PreExecute() const
{ {
// all data included in control packet? // all data included in control packet?
if(!fByRes) return true; if(!fByRes) return true;
// client lost? // client lost?
if(!Game.Clients.getClientByID(iAtClient)) return true; if(!Game.Clients.getClientByID(iAtClient)) return true;
// network only // network only
if(!::Control.isNetwork()) return true; if(!::Control.isNetwork()) return true;
// search ressource // search ressource
C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(ResCore.getID()); C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(ResCore.getID());
// doesn't exist? start loading // doesn't exist? start loading
if(!pRes) { pRes = ::Network.ResList.AddByCore(ResCore, true); } if(!pRes) { pRes = ::Network.ResList.AddByCore(ResCore, true); }
if(!pRes) return true; if(!pRes) return true;
// is loading or removed? // is loading or removed?
return !pRes->isLoading(); return !pRes->isLoading();
} }
void C4ControlJoinPlayer::PreRec(C4Record *pRecord) void C4ControlJoinPlayer::PreRec(C4Record *pRecord)
{ {
if(!pRecord) return; if(!pRecord) return;
if (fByRes) if (fByRes)
{ {
// get local file by id // get local file by id
@ -882,22 +882,22 @@ void C4ControlJoinPlayer::PreRec(C4Record *pRecord)
void C4ControlJoinPlayer::CompileFunc(StdCompiler *pComp) void C4ControlJoinPlayer::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(mkNetFilenameAdapt(Filename), "Filename", "")); pComp->Value(mkNamingAdapt(mkNetFilenameAdapt(Filename), "Filename", ""));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iAtClient), "AtClient", -1)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iAtClient), "AtClient", -1));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(idInfo), "InfoID", -1)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(idInfo), "InfoID", -1));
pComp->Value(mkNamingAdapt(fByRes, "ByRes", false)); pComp->Value(mkNamingAdapt(fByRes, "ByRes", false));
if(fByRes) if(fByRes)
pComp->Value(mkNamingAdapt(ResCore, "ResCore")); pComp->Value(mkNamingAdapt(ResCore, "ResCore"));
else else
pComp->Value(mkNamingAdapt(PlrData, "PlrData")); pComp->Value(mkNamingAdapt(PlrData, "PlrData"));
C4ControlPacket::CompileFunc(pComp); C4ControlPacket::CompileFunc(pComp);
} }
// *** C4ControlEMMoveObject // *** C4ControlEMMoveObject
C4ControlEMMoveObject::C4ControlEMMoveObject(C4ControlEMObjectAction eAction, int32_t tx, int32_t ty, C4Object *pTargetObj, C4ControlEMMoveObject::C4ControlEMMoveObject(C4ControlEMObjectAction eAction, int32_t tx, int32_t ty, C4Object *pTargetObj,
int32_t iObjectNum, int32_t *pObjects, const char *szScript) int32_t iObjectNum, int32_t *pObjects, const char *szScript)
: eAction(eAction), tx(tx), ty(ty), iTargetObj(::Objects.ObjectNumber(pTargetObj)), : eAction(eAction), tx(tx), ty(ty), iTargetObj(::Objects.ObjectNumber(pTargetObj)),
iObjectNum(iObjectNum), pObjects(pObjects), Script(szScript, true) iObjectNum(iObjectNum), pObjects(pObjects), Script(szScript, true)
{ {
@ -953,26 +953,26 @@ void C4ControlEMMoveObject::Execute() const
} }
// update status // update status
if (fLocalCall) if (fLocalCall)
{ {
Console.EditCursor.SetHold(true); Console.EditCursor.SetHold(true);
Console.PropertyDlg.Update(Console.EditCursor.GetSelection()); Console.PropertyDlg.Update(Console.EditCursor.GetSelection());
} }
} }
break; break;
case EMMO_Script: case EMMO_Script:
{ {
if(!pObjects) return; if(!pObjects) return;
// execute script ... // execute script ...
C4ControlScript ScriptCtrl(Script.getData(), C4ControlScript::SCOPE_Global, false); C4ControlScript ScriptCtrl(Script.getData(), C4ControlScript::SCOPE_Global, false);
ScriptCtrl.SetByClient(iByClient); ScriptCtrl.SetByClient(iByClient);
// ... for each object in selection // ... for each object in selection
for (int i=0; i<iObjectNum; ++i) for (int i=0; i<iObjectNum; ++i)
{ {
ScriptCtrl.SetTargetObj(pObjects[i]); ScriptCtrl.SetTargetObj(pObjects[i]);
ScriptCtrl.Execute(); ScriptCtrl.Execute();
} }
break; break;
} }
case EMMO_Remove: case EMMO_Remove:
{ {
if(!pObjects) return; if(!pObjects) return;
@ -982,7 +982,7 @@ void C4ControlEMMoveObject::Execute() const
if ((pObj = ::Objects.SafeObjectPointer(pObjects[i]))) if ((pObj = ::Objects.SafeObjectPointer(pObjects[i])))
pObj->AssignRemoval(); pObj->AssignRemoval();
} }
break; // Here was fallthrough. Seemed wrong. ck. break; // Here was fallthrough. Seemed wrong. ck.
case EMMO_Exit: case EMMO_Exit:
{ {
if(!pObjects) return; if(!pObjects) return;
@ -992,12 +992,12 @@ void C4ControlEMMoveObject::Execute() const
if ((pObj = ::Objects.SafeObjectPointer(pObjects[i]))) if ((pObj = ::Objects.SafeObjectPointer(pObjects[i])))
pObj->Exit(pObj->GetX(), pObj->GetY(), pObj->r); pObj->Exit(pObj->GetX(), pObj->GetY(), pObj->r);
} }
break; // Same. ck. break; // Same. ck.
} }
// update property dlg & status bar // update property dlg & status bar
if(fLocalCall) if(fLocalCall)
Console.EditCursor.OnSelectionChanged(); Console.EditCursor.OnSelectionChanged();
} }
void C4ControlEMMoveObject::CompileFunc(StdCompiler *pComp) void C4ControlEMMoveObject::CompileFunc(StdCompiler *pComp)
{ {
@ -1006,11 +1006,11 @@ void C4ControlEMMoveObject::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(ty, "ty", 0)); pComp->Value(mkNamingAdapt(ty, "ty", 0));
pComp->Value(mkNamingAdapt(iTargetObj, "TargetObj", -1)); pComp->Value(mkNamingAdapt(iTargetObj, "TargetObj", -1));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iObjectNum), "ObjectNum", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iObjectNum), "ObjectNum", 0));
if(pComp->isCompiler()) { delete [] pObjects; pObjects = new int32_t [iObjectNum]; } if(pComp->isCompiler()) { delete [] pObjects; pObjects = new int32_t [iObjectNum]; }
pComp->Value(mkNamingAdapt(mkArrayAdapt(pObjects, iObjectNum), "Objs", -1)); pComp->Value(mkNamingAdapt(mkArrayAdapt(pObjects, iObjectNum), "Objs", -1));
if(eAction == EMMO_Script) if(eAction == EMMO_Script)
pComp->Value(mkNamingAdapt(Script, "Script", "")); pComp->Value(mkNamingAdapt(Script, "Script", ""));
C4ControlPacket::CompileFunc(pComp); C4ControlPacket::CompileFunc(pComp);
} }
// *** C4ControlEMDrawTool // *** C4ControlEMDrawTool
@ -1098,7 +1098,7 @@ void C4ControlMessage::Execute() const
C4GameLobby::MainDlg *pLobby = ::Network.GetLobby(); C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
StdStrBuf str; StdStrBuf str;
switch(eType) switch(eType)
{ {
case C4CMT_Normal: case C4CMT_Normal:
case C4CMT_Me: case C4CMT_Me:
// log it // log it
@ -1190,23 +1190,23 @@ void C4ControlMessage::Execute() const
Application.NotifyUserIfInactive(); Application.NotifyUserIfInactive();
break; break;
case C4CMT_System: case C4CMT_System:
// sender must be host // sender must be host
if(!HostControl()) break; if(!HostControl()) break;
// show // show
LogF("Network: %s", szMessage); LogF("Network: %s", szMessage);
break; break;
} }
} }
void C4ControlMessage::CompileFunc(StdCompiler *pComp) void C4ControlMessage::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(mkIntAdaptT<uint8_t>(eType), "Type", C4CMT_Normal)); pComp->Value(mkNamingAdapt(mkIntAdaptT<uint8_t>(eType), "Type", C4CMT_Normal));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iPlayer), "Player", -1)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iPlayer), "Player", -1));
if(eType == C4CMT_Private) if(eType == C4CMT_Private)
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iToPlayer), "ToPlayer", -1)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iToPlayer), "ToPlayer", -1));
pComp->Value(mkNamingAdapt(Message, "Message", "")); pComp->Value(mkNamingAdapt(Message, "Message", ""));
C4ControlPacket::CompileFunc(pComp); C4ControlPacket::CompileFunc(pComp);
} }
@ -1234,8 +1234,8 @@ void C4ControlPlayerInfo::Execute() const
void C4ControlPlayerInfo::CompileFunc(StdCompiler *pComp) void C4ControlPlayerInfo::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(PlrInfo); pComp->Value(PlrInfo);
C4ControlPacket::CompileFunc(pComp); C4ControlPacket::CompileFunc(pComp);
} }
// *** C4ControlRemovePlr // *** C4ControlRemovePlr
@ -1250,8 +1250,8 @@ void C4ControlRemovePlr::Execute() const
void C4ControlRemovePlr::CompileFunc(StdCompiler *pComp) void C4ControlRemovePlr::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iPlr), "Plr", -1)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iPlr), "Plr", -1));
pComp->Value(mkNamingAdapt(fDisconnected, "Disconnected", false)); pComp->Value(mkNamingAdapt(fDisconnected, "Disconnected", false));
C4ControlPacket::CompileFunc(pComp); C4ControlPacket::CompileFunc(pComp);
} }
@ -1264,7 +1264,7 @@ void C4ControlDebugRec::Execute() const
void C4ControlDebugRec::CompileFunc(StdCompiler *pComp) void C4ControlDebugRec::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(Data); pComp->Value(Data);
} }
// *** C4ControlVote // *** C4ControlVote
@ -1397,9 +1397,9 @@ void C4ControlVote::Execute() const
void C4ControlVote::CompileFunc(StdCompiler *pComp) void C4ControlVote::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(mkIntAdaptT<uint8_t>(eType), "Type", VT_None)); pComp->Value(mkNamingAdapt(mkIntAdaptT<uint8_t>(eType), "Type", VT_None));
pComp->Value(mkNamingAdapt(fApprove, "Approve", true)); pComp->Value(mkNamingAdapt(fApprove, "Approve", true));
pComp->Value(mkNamingAdapt(iData, "Data", 0)); pComp->Value(mkNamingAdapt(iData, "Data", 0));
C4ControlPacket::CompileFunc(pComp); C4ControlPacket::CompileFunc(pComp);
} }

View File

@ -46,13 +46,13 @@ protected:
public: public:
int32_t getByClient() const { return iByClient; } int32_t getByClient() const { return iByClient; }
bool LocalControl() const; bool LocalControl() const;
bool HostControl() const { return iByClient == C4ClientIDHost; } bool HostControl() const { return iByClient == C4ClientIDHost; }
void SetByClient(int32_t iByClient); void SetByClient(int32_t iByClient);
virtual bool PreExecute() const { return true; } virtual bool PreExecute() const { return true; }
virtual void Execute() const = 0; virtual void Execute() const = 0;
virtual void PreRec(C4Record *pRecord) { } virtual void PreRec(C4Record *pRecord) { }
// allowed in lobby (without dynamic loaded)? // allowed in lobby (without dynamic loaded)?
virtual bool Lobby() const { return false; } virtual bool Lobby() const { return false; }
@ -73,11 +73,11 @@ public:
~C4Control(); ~C4Control();
protected: protected:
C4PacketList Pkts; C4PacketList Pkts;
public: public:
void Clear(); void Clear();
// packet list wrappers // packet list wrappers
C4IDPacket *firstPkt() const { return Pkts.firstPkt(); } C4IDPacket *firstPkt() const { return Pkts.firstPkt(); }
@ -86,9 +86,9 @@ public:
void AddHead(C4PacketType eType, C4ControlPacket *pCtrl) { Pkts.AddHead(eType, pCtrl); } void AddHead(C4PacketType eType, C4ControlPacket *pCtrl) { Pkts.AddHead(eType, pCtrl); }
void Add(C4PacketType eType, C4ControlPacket *pCtrl) { Pkts.Add(eType, pCtrl); } void Add(C4PacketType eType, C4ControlPacket *pCtrl) { Pkts.Add(eType, pCtrl); }
void Take(C4Control &Ctrl) { Pkts.Take(Ctrl.Pkts); } void Take(C4Control &Ctrl) { Pkts.Take(Ctrl.Pkts); }
void Append(const C4Control &Ctrl) { Pkts.Append(Ctrl.Pkts); } void Append(const C4Control &Ctrl) { Pkts.Append(Ctrl.Pkts); }
void Copy(const C4Control &Ctrl) { Clear(); Pkts.Append(Ctrl.Pkts); } void Copy(const C4Control &Ctrl) { Clear(); Pkts.Append(Ctrl.Pkts); }
void Remove(C4IDPacket *pPkt) { Pkts.Remove(pPkt); } void Remove(C4IDPacket *pPkt) { Pkts.Remove(pPkt); }
void Delete(C4IDPacket *pPkt) { Pkts.Delete(pPkt); } void Delete(C4IDPacket *pPkt) { Pkts.Delete(pPkt); }
@ -104,21 +104,21 @@ public:
enum C4CtrlValueType enum C4CtrlValueType
{ {
C4CVT_None = -1, C4CVT_None = -1,
C4CVT_ControlRate = 0, C4CVT_ControlRate = 0,
C4CVT_AllowDebug = 1, C4CVT_AllowDebug = 1,
C4CVT_MaxPlayer = 2, C4CVT_MaxPlayer = 2,
C4CVT_TeamDistribution = 3, C4CVT_TeamDistribution = 3,
C4CVT_TeamColors = 4, C4CVT_TeamColors = 4,
C4CVT_FairCrew = 5 C4CVT_FairCrew = 5
}; };
class C4ControlSet : public C4ControlPacket // sync, lobby class C4ControlSet : public C4ControlPacket // sync, lobby
{ {
public: public:
C4ControlSet() C4ControlSet()
: eValType(C4CVT_None), iData(0) : eValType(C4CVT_None), iData(0)
{ } { }
C4ControlSet(C4CtrlValueType eValType, int32_t iData) C4ControlSet(C4CtrlValueType eValType, int32_t iData)
: eValType(eValType), iData(iData) : eValType(eValType), iData(iData)
{ } { }
@ -137,9 +137,9 @@ class C4ControlScript : public C4ControlPacket // sync
public: public:
enum { SCOPE_Console=-2, SCOPE_Global=-1 }; // special scopes to be passed as target objects enum { SCOPE_Console=-2, SCOPE_Global=-1 }; // special scopes to be passed as target objects
C4ControlScript() C4ControlScript()
: iTargetObj(-1), fInternal(true) : iTargetObj(-1), fInternal(true)
{ } { }
C4ControlScript(const char *szScript, int32_t iTargetObj = SCOPE_Global, bool fInternal = true) C4ControlScript(const char *szScript, int32_t iTargetObj = SCOPE_Global, bool fInternal = true)
: iTargetObj(iTargetObj), fInternal(fInternal), Script(szScript, true) : iTargetObj(iTargetObj), fInternal(fInternal), Script(szScript, true)
{ } { }
@ -155,8 +155,8 @@ public:
class C4ControlPlayerSelect : public C4ControlPacket // sync class C4ControlPlayerSelect : public C4ControlPacket // sync
{ {
public: public:
C4ControlPlayerSelect() C4ControlPlayerSelect()
: iPlr(-1), fIsAlt(false), iObjCnt(0), pObjNrs(NULL) { } : iPlr(-1), fIsAlt(false), iObjCnt(0), pObjNrs(NULL) { }
C4ControlPlayerSelect(int32_t iPlr, const C4ObjectList &Objs, bool fIsAlt); C4ControlPlayerSelect(int32_t iPlr, const C4ObjectList &Objs, bool fIsAlt);
~C4ControlPlayerSelect() { delete[] pObjNrs; } ~C4ControlPlayerSelect() { delete[] pObjNrs; }
protected: protected:
@ -204,8 +204,8 @@ public:
class C4ControlPlayerCommand : public C4ControlPacket // sync class C4ControlPlayerCommand : public C4ControlPacket // sync
{ {
public: public:
C4ControlPlayerCommand() C4ControlPlayerCommand()
: iPlr(-1), iCmd(-1) { } : iPlr(-1), iCmd(-1) { }
C4ControlPlayerCommand(int32_t iPlr, int32_t iCmd, int32_t iX, int32_t iY, C4ControlPlayerCommand(int32_t iPlr, int32_t iCmd, int32_t iX, int32_t iY,
C4Object *pTarget, C4Object *pTarget2, int32_t iData, int32_t iAddMode); C4Object *pTarget, C4Object *pTarget2, int32_t iData, int32_t iAddMode);
protected: protected:
@ -232,7 +232,7 @@ protected:
public: public:
void Set(); void Set();
int32_t getFrame() const { return Frame; } int32_t getFrame() const { return Frame; }
virtual bool Sync() const { return false; } virtual bool Sync() const { return false; }
DECLARE_C4CONTROL_VIRTUALS DECLARE_C4CONTROL_VIRTUALS
protected: protected:
static int32_t GetAllCrewPosX(); static int32_t GetAllCrewPosX();
@ -258,8 +258,8 @@ public:
public: public:
C4ClientCore Core; C4ClientCore Core;
public: public:
virtual bool Sync() const { return false; } virtual bool Sync() const { return false; }
virtual bool Lobby() const { return true; } virtual bool Lobby() const { return true; }
DECLARE_C4CONTROL_VIRTUALS DECLARE_C4CONTROL_VIRTUALS
}; };
@ -280,8 +280,8 @@ public:
C4ControlClientUpdType eType; C4ControlClientUpdType eType;
int32_t iData; int32_t iData;
public: public:
virtual bool Sync() const { return false; } virtual bool Sync() const { return false; }
virtual bool Lobby() const { return true; } virtual bool Lobby() const { return true; }
DECLARE_C4CONTROL_VIRTUALS DECLARE_C4CONTROL_VIRTUALS
}; };
@ -294,8 +294,8 @@ public:
int32_t iID; int32_t iID;
StdCopyStrBuf strReason; StdCopyStrBuf strReason;
public: public:
virtual bool Sync() const { return false; } virtual bool Sync() const { return false; }
virtual bool Lobby() const { return true; } virtual bool Lobby() const { return true; }
DECLARE_C4CONTROL_VIRTUALS DECLARE_C4CONTROL_VIRTUALS
}; };
@ -303,29 +303,29 @@ public:
class C4ControlPlayerInfo : public C4ControlPacket // not sync, lobby class C4ControlPlayerInfo : public C4ControlPacket // not sync, lobby
{ {
public: public:
C4ControlPlayerInfo() C4ControlPlayerInfo()
{ } { }
C4ControlPlayerInfo(const C4ClientPlayerInfos &PlrInfo) C4ControlPlayerInfo(const C4ClientPlayerInfos &PlrInfo)
: PlrInfo(PlrInfo) : PlrInfo(PlrInfo)
{ } { }
protected: protected:
C4ClientPlayerInfos PlrInfo; C4ClientPlayerInfos PlrInfo;
public: public:
const C4ClientPlayerInfos &GetInfo() const { return PlrInfo; } const C4ClientPlayerInfos &GetInfo() const { return PlrInfo; }
virtual bool Sync() const { return false; } virtual bool Sync() const { return false; }
virtual bool Lobby() const { return true; } virtual bool Lobby() const { return true; }
DECLARE_C4CONTROL_VIRTUALS DECLARE_C4CONTROL_VIRTUALS
}; };
struct C4ControlJoinPlayer : public C4ControlPacket // sync struct C4ControlJoinPlayer : public C4ControlPacket // sync
{ {
public: public:
C4ControlJoinPlayer() : iAtClient(-1), idInfo(-1) { } C4ControlJoinPlayer() : iAtClient(-1), idInfo(-1) { }
C4ControlJoinPlayer(const char *szFilename, int32_t iAtClient, int32_t iIDInfo, const C4Network2ResCore &ResCore); C4ControlJoinPlayer(const char *szFilename, int32_t iAtClient, int32_t iIDInfo, const C4Network2ResCore &ResCore);
C4ControlJoinPlayer(const char *szFilename, int32_t iAtClient, int32_t iIDInfo); C4ControlJoinPlayer(const char *szFilename, int32_t iAtClient, int32_t iIDInfo);
protected: protected:
StdStrBuf Filename; StdStrBuf Filename;
int32_t iAtClient; int32_t iAtClient;
int32_t idInfo; int32_t idInfo;
bool fByRes; bool fByRes;
StdBuf PlrData; // for fByRes == false StdBuf PlrData; // for fByRes == false
@ -350,7 +350,7 @@ enum C4ControlEMObjectAction
class C4ControlEMMoveObject : public C4ControlPacket // sync class C4ControlEMMoveObject : public C4ControlPacket // sync
{ {
public: public:
C4ControlEMMoveObject() : pObjects(NULL) { } C4ControlEMMoveObject() : pObjects(NULL) { }
C4ControlEMMoveObject(C4ControlEMObjectAction eAction, int32_t tx, int32_t ty, C4Object *pTargetObj, C4ControlEMMoveObject(C4ControlEMObjectAction eAction, int32_t tx, int32_t ty, C4Object *pTargetObj,
int32_t iObjectNum = 0, int32_t *pObjects = NULL, const char *szScript = NULL); int32_t iObjectNum = 0, int32_t *pObjects = NULL, const char *szScript = NULL);
~C4ControlEMMoveObject(); ~C4ControlEMMoveObject();
@ -360,7 +360,7 @@ protected:
int32_t iTargetObj; // enumerated ptr to target object int32_t iTargetObj; // enumerated ptr to target object
int32_t iObjectNum; // number of objects moved int32_t iObjectNum; // number of objects moved
int32_t *pObjects; // pointer on array of objects moved int32_t *pObjects; // pointer on array of objects moved
StdStrBuf Script; // script to execute StdStrBuf Script; // script to execute
public: public:
DECLARE_C4CONTROL_VIRTUALS DECLARE_C4CONTROL_VIRTUALS
}; };
@ -377,7 +377,7 @@ enum C4ControlEMDrawAction
class C4ControlEMDrawTool : public C4ControlPacket // sync class C4ControlEMDrawTool : public C4ControlPacket // sync
{ {
public: public:
C4ControlEMDrawTool() { } C4ControlEMDrawTool() { }
C4ControlEMDrawTool(C4ControlEMDrawAction eAction, int32_t iMode, C4ControlEMDrawTool(C4ControlEMDrawAction eAction, int32_t iMode,
int32_t iX=-1, int32_t iY=-1, int32_t iX2=-1, int32_t iY2=-1, int32_t iGrade=-1, int32_t iX=-1, int32_t iY=-1, int32_t iX2=-1, int32_t iY2=-1, int32_t iGrade=-1,
bool fIFT=true, const char *szMaterial=NULL, const char *szTexture=NULL); bool fIFT=true, const char *szMaterial=NULL, const char *szTexture=NULL);
@ -407,8 +407,8 @@ enum C4ControlMessageType
class C4ControlMessage : public C4ControlPacket // not sync, lobby class C4ControlMessage : public C4ControlPacket // not sync, lobby
{ {
public: public:
C4ControlMessage() C4ControlMessage()
: eType(C4CMT_Normal), iPlayer(-1) { } : eType(C4CMT_Normal), iPlayer(-1) { }
C4ControlMessage(C4ControlMessageType eType, const char *szMessage, int32_t iPlayer = -1, int32_t iToPlayer = -1) C4ControlMessage(C4ControlMessageType eType, const char *szMessage, int32_t iPlayer = -1, int32_t iToPlayer = -1)
: eType(eType), iPlayer(iPlayer), iToPlayer(iToPlayer), Message(szMessage, true) : eType(eType), iPlayer(iPlayer), iToPlayer(iToPlayer), Message(szMessage, true)
{ } { }
@ -417,16 +417,16 @@ protected:
int32_t iPlayer, iToPlayer; int32_t iPlayer, iToPlayer;
StdStrBuf Message; StdStrBuf Message;
public: public:
virtual bool Sync() const { return false; } virtual bool Sync() const { return false; }
virtual bool Lobby() const { return true; } virtual bool Lobby() const { return true; }
DECLARE_C4CONTROL_VIRTUALS DECLARE_C4CONTROL_VIRTUALS
}; };
class C4ControlRemovePlr : public C4ControlPacket // sync class C4ControlRemovePlr : public C4ControlPacket // sync
{ {
public: public:
C4ControlRemovePlr() C4ControlRemovePlr()
: iPlr(-1) { } : iPlr(-1) { }
C4ControlRemovePlr(int32_t iPlr, bool fDisconnected) C4ControlRemovePlr(int32_t iPlr, bool fDisconnected)
: iPlr(iPlr), fDisconnected(fDisconnected) { } : iPlr(iPlr), fDisconnected(fDisconnected) { }
protected: protected:
@ -439,10 +439,10 @@ public:
class C4ControlDebugRec : public C4ControlPacket // sync class C4ControlDebugRec : public C4ControlPacket // sync
{ {
public: public:
C4ControlDebugRec() C4ControlDebugRec()
{ } { }
C4ControlDebugRec(StdBuf &Data) C4ControlDebugRec(StdBuf &Data)
: Data(Data) { } : Data(Data) { }
protected: protected:
StdBuf Data; StdBuf Data;
public: public:
@ -452,7 +452,7 @@ public:
enum C4ControlVoteType enum C4ControlVoteType
{ {
VT_None = -1, VT_None = -1,
VT_Cancel, VT_Cancel,
VT_Kick, VT_Kick,
VT_Pause VT_Pause
}; };
@ -477,7 +477,7 @@ public:
StdStrBuf getDesc() const; StdStrBuf getDesc() const;
StdStrBuf getDescWarning() const; StdStrBuf getDescWarning() const;
virtual bool Sync() const { return false; } virtual bool Sync() const { return false; }
DECLARE_C4CONTROL_VIRTUALS DECLARE_C4CONTROL_VIRTUALS
}; };

View File

@ -40,7 +40,7 @@
C4GameControl::C4GameControl() C4GameControl::C4GameControl()
: Network(this) : Network(this)
{ {
Default(); Default();
} }
C4GameControl::~C4GameControl() C4GameControl::~C4GameControl()
@ -121,7 +121,7 @@ void C4GameControl::ChangeToLocal()
// (otherwise, clients start game when host disconnected!) // (otherwise, clients start game when host disconnected!)
if (!C4GameOverDlg::IsShown()) Game.HaltCount = 0; if (!C4GameOverDlg::IsShown()) Game.HaltCount = 0;
// set status // set status
eMode = CM_Local; fHost = true; eMode = CM_Local; fHost = true;
ControlRate = 1; ControlRate = 1;
} }
@ -138,7 +138,7 @@ void C4GameControl::OnGameSynchronizing()
bool C4GameControl::StartRecord(bool fInitial, bool fStreaming) bool C4GameControl::StartRecord(bool fInitial, bool fStreaming)
{ {
assert(fInitComplete); assert(fInitComplete);
// already recording? // already recording?
if(pRecord) StopRecord(); if(pRecord) StopRecord();
// start // start
@ -170,7 +170,7 @@ void C4GameControl::StopRecord(StdStrBuf *pRecordName, BYTE *pRecordSHA1)
if(pRecord) if(pRecord)
{ {
::Network.FinishStreaming(); ::Network.FinishStreaming();
pRecord->Stop(pRecordName, pRecordSHA1); pRecord->Stop(pRecordName, pRecordSHA1);
// just delete // just delete
delete pRecord; pRecord = NULL; delete pRecord; pRecord = NULL;
} }
@ -179,7 +179,7 @@ void C4GameControl::StopRecord(StdStrBuf *pRecordName, BYTE *pRecordSHA1)
void C4GameControl::RequestRuntimeRecord() void C4GameControl::RequestRuntimeRecord()
{ {
if (!IsRuntimeRecordPossible()) return; // cannot record if (!IsRuntimeRecordPossible()) return; // cannot record
fRecordNeeded = true; fRecordNeeded = true;
// request through a synchronize-call // request through a synchronize-call
// currnetly do not request, but start record with next gamesync, so network runtime join can be debugged // currnetly do not request, but start record with next gamesync, so network runtime join can be debugged
#ifndef DEBUGREC #ifndef DEBUGREC
@ -209,30 +209,30 @@ void C4GameControl::Clear()
{ {
StopRecord(); StopRecord();
ChangeToLocal(); ChangeToLocal();
Default(); Default();
} }
void C4GameControl::Default() void C4GameControl::Default()
{ {
Input.Clear(); Input.Clear();
Network.Clear(); Network.Clear();
eMode = CM_None; eMode = CM_None;
fHost = fPreInit = fInitComplete = false; fHost = fPreInit = fInitComplete = false;
iClientID = C4ClientIDUnknown; iClientID = C4ClientIDUnknown;
pRecord = NULL; pRecord = NULL;
pPlayback = NULL; pPlayback = NULL;
SyncChecks.Clear(); SyncChecks.Clear();
ControlRate = BoundBy<int>(Config.Network.ControlRate, 1, C4MaxControlRate); ControlRate = BoundBy<int>(Config.Network.ControlRate, 1, C4MaxControlRate);
ControlTick = 0; ControlTick = 0;
SyncRate = C4SyncCheckRate; SyncRate = C4SyncCheckRate;
DoSync = false; DoSync = false;
fRecordNeeded = false; fRecordNeeded = false;
pExecutingControl = NULL; pExecutingControl = NULL;
} }
bool C4GameControl::Prepare() bool C4GameControl::Prepare()
{ {
assert(fInitComplete); assert(fInitComplete);
// Prepare control, return true if everything is ready for GameGo. // Prepare control, return true if everything is ready for GameGo.
bool is_input_prepared = false; bool is_input_prepared = false;
@ -279,7 +279,7 @@ void C4GameControl::Execute()
{ {
// Execute all available control // Execute all available control
assert(fInitComplete); assert(fInitComplete);
// control tick? replay must always be executed. // control tick? replay must always be executed.
if(!isReplay() && Game.FrameCounter % ControlRate) if(!isReplay() && Game.FrameCounter % ControlRate)
@ -329,7 +329,7 @@ void C4GameControl::Execute()
void C4GameControl::Ticks() void C4GameControl::Ticks()
{ {
assert(fInitComplete); assert(fInitComplete);
if(!(Game.FrameCounter % ControlRate)) if(!(Game.FrameCounter % ControlRate))
ControlTick++; ControlTick++;
@ -349,12 +349,12 @@ void C4GameControl::Ticks()
bool C4GameControl::CtrlTickReached(int32_t iTick) bool C4GameControl::CtrlTickReached(int32_t iTick)
{ {
// 1. control tick reached? // 1. control tick reached?
if(ControlTick < iTick) return false; if(ControlTick < iTick) return false;
// 2. control tick? // 2. control tick?
if(Game.FrameCounter % ControlRate) return false; if(Game.FrameCounter % ControlRate) return false;
// ok then // ok then
return true; return true;
} }
int32_t C4GameControl::getCtrlTick(int32_t iFrame) const int32_t C4GameControl::getCtrlTick(int32_t iFrame) const
@ -388,7 +388,7 @@ void C4GameControl::DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4Con
{ {
assert(fPreInit); assert(fPreInit);
// check if the control can be executed // check if the control can be executed
if(eDelivery == CDT_Direct || eDelivery == CDT_Private) if(eDelivery == CDT_Direct || eDelivery == CDT_Private)
assert(!pPkt->Sync()); assert(!pPkt->Sync());
if(!fInitComplete) if(!fInitComplete)
@ -398,8 +398,8 @@ void C4GameControl::DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4Con
if(eDelivery == CDT_Decide) if(eDelivery == CDT_Decide)
eDelivery = DecideControlDelivery(); eDelivery = DecideControlDelivery();
// queue? // queue?
if(eDelivery == CDT_Queue) if(eDelivery == CDT_Queue)
{ {
// add, will be executed/sent later // add, will be executed/sent later
Input.Add(eCtrlType, pPkt); Input.Add(eCtrlType, pPkt);
@ -447,9 +447,9 @@ C4ControlDeliveryType C4GameControl::DecideControlDelivery()
void C4GameControl::DoSyncCheck() void C4GameControl::DoSyncCheck()
{ {
// only once // only once
if(!DoSync) return; if(!DoSync) return;
DoSync = false; DoSync = false;
// create sync check // create sync check
C4ControlSyncCheck *pSyncCheck = new C4ControlSyncCheck(); C4ControlSyncCheck *pSyncCheck = new C4ControlSyncCheck();
pSyncCheck->Set(); pSyncCheck->Set();
@ -477,14 +477,14 @@ void C4GameControl::DoSyncCheck()
void C4GameControl::ExecControl(const C4Control &rCtrl) void C4GameControl::ExecControl(const C4Control &rCtrl)
{ {
// nothing to do? // nothing to do?
if(!rCtrl.firstPkt()) return; if(!rCtrl.firstPkt()) return;
// execute it // execute it
if(!rCtrl.PreExecute()) Log("Control: PreExecute failed for sync control!"); if(!rCtrl.PreExecute()) Log("Control: PreExecute failed for sync control!");
rCtrl.Execute(); rCtrl.Execute();
// record // record
if(pRecord) if(pRecord)
pRecord->Rec(rCtrl, Game.FrameCounter); pRecord->Rec(rCtrl, Game.FrameCounter);
} }
void C4GameControl::ExecControlPacket(C4PacketType eCtrlType, C4ControlPacket *pPkt) void C4GameControl::ExecControlPacket(C4PacketType eCtrlType, C4ControlPacket *pPkt)

View File

@ -35,12 +35,12 @@ enum C4ControlMode
enum C4ControlDeliveryType enum C4ControlDeliveryType
{ {
CDT_Queue = 0, // Send in control queue (sync) CDT_Queue = 0, // Send in control queue (sync)
CDT_Sync = 1, // Send, delay execution until net is sync (sync) CDT_Sync = 1, // Send, delay execution until net is sync (sync)
CDT_Direct = 2, // Send directly to all clients (not sync) CDT_Direct = 2, // Send directly to all clients (not sync)
CDT_Private = 3, // Send only to some clients (not sync, obviously) CDT_Private = 3, // Send only to some clients (not sync, obviously)
CDT_Decide // Use whatever sync mode seems fastest atm (sync) CDT_Decide // Use whatever sync mode seems fastest atm (sync)
}; };
// Additional notes / requirements: // Additional notes / requirements:
@ -72,7 +72,7 @@ public:
protected: protected:
C4ControlMode eMode; C4ControlMode eMode;
bool fPreInit, fInitComplete; bool fPreInit, fInitComplete;
bool fHost; // (set for local, too) bool fHost; // (set for local, too)
bool fActivated; bool fActivated;
bool fRecordNeeded; bool fRecordNeeded;
@ -83,7 +83,7 @@ protected:
C4Control SyncChecks; C4Control SyncChecks;
C4GameControlClient *pClients; C4GameControlClient *pClients;
C4Control *pExecutingControl; // Control that is in the process of being executed - needed by non-initial records C4Control *pExecutingControl; // Control that is in the process of being executed - needed by non-initial records
@ -96,7 +96,7 @@ public:
public: public:
// configuration // configuration
bool isLocal() const { return eMode == CM_Local; } bool isLocal() const { return eMode == CM_Local; }
bool isNetwork() const { return eMode == CM_Network; } bool isNetwork() const { return eMode == CM_Network; }
bool isReplay() const { return eMode == CM_Replay; } bool isReplay() const { return eMode == CM_Replay; }
@ -107,11 +107,11 @@ public:
bool NoInput() const { return isReplay(); } bool NoInput() const { return isReplay(); }
// client list // client list
C4GameControlClient *getClient(int32_t iID); C4GameControlClient *getClient(int32_t iID);
C4GameControlClient *getClient(const char *szName); C4GameControlClient *getClient(const char *szName);
// initialization // initialization
bool InitLocal(C4Client *pLocal); bool InitLocal(C4Client *pLocal);
bool InitNetwork(C4Client *pLocal); bool InitNetwork(C4Client *pLocal);
bool InitReplay(C4Group &rGroup); bool InitReplay(C4Group &rGroup);
@ -121,7 +121,7 @@ public:
void Clear(); void Clear();
void Default(); void Default();
// records // records
bool StartRecord(bool fInitial, bool fStreaming); bool StartRecord(bool fInitial, bool fStreaming);
void StopRecord(StdStrBuf *pRecordName = NULL, BYTE *pRecordSHA1 = NULL); void StopRecord(StdStrBuf *pRecordName = NULL, BYTE *pRecordSHA1 = NULL);
void RequestRuntimeRecord(); void RequestRuntimeRecord();
@ -134,7 +134,7 @@ public:
void Ticks(); void Ticks();
// public helpers // public helpers
bool CtrlTickReached(int32_t iTick); bool CtrlTickReached(int32_t iTick);
int32_t getCtrlTick(int32_t iFrame) const; int32_t getCtrlTick(int32_t iFrame) const;
int32_t getNextControlTick() const; int32_t getNextControlTick() const;
@ -146,13 +146,13 @@ public:
// activation // activation
void SetActivated(bool fActivated); void SetActivated(bool fActivated);
// input // input
void DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4ControlDeliveryType eDelivery); void DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4ControlDeliveryType eDelivery);
void DbgRec(C4RecordChunkType eType, const uint8_t *pData=NULL, size_t iSize=0); // record debug stuff void DbgRec(C4RecordChunkType eType, const uint8_t *pData=NULL, size_t iSize=0); // record debug stuff
C4ControlDeliveryType DecideControlDelivery(); C4ControlDeliveryType DecideControlDelivery();
// sync check // sync check
void DoSyncCheck(); void DoSyncCheck();
// execute and record control (by self or C4GameControlNetwork) // execute and record control (by self or C4GameControlNetwork)
void ExecControl(const C4Control &rCtrl); void ExecControl(const C4Control &rCtrl);

View File

@ -278,14 +278,14 @@ bool C4GameResList::InitNetwork(C4Network2ResList *pNetResList)
void C4GameResList::CalcHashes() void C4GameResList::CalcHashes()
{ {
for (int32_t i = 0; i < iResCount; i++) for (int32_t i = 0; i < iResCount; i++)
pResList[i]->CalcHash(); pResList[i]->CalcHash();
} }
bool C4GameResList::RetrieveFiles() bool C4GameResList::RetrieveFiles()
{ {
// wait for all resources // wait for all resources
for (int32_t i = 0; i < iResCount; i++) for (int32_t i = 0; i < iResCount; i++)
{ {
const C4Network2ResCore &Core = *pResList[i]->getResCore(); const C4Network2ResCore &Core = *pResList[i]->getResCore();
StdStrBuf ResNameBuf = FormatString("%s: %s", LoadResStr("IDS_DLG_DEFINITION"), GetFilename(Core.getFileName())); StdStrBuf ResNameBuf = FormatString("%s: %s", LoadResStr("IDS_DLG_DEFINITION"), GetFilename(Core.getFileName()));
@ -513,7 +513,7 @@ void C4GameParameters::CompileFunc(StdCompiler *pComp, C4Scenario *pScenario)
pComp->Value(mkNamingAdapt(Teams, "Teams" )); pComp->Value(mkNamingAdapt(Teams, "Teams" ));
} }
pComp->Value(Clients); pComp->Value(Clients);
} }

View File

@ -66,7 +66,7 @@ bool C4GameSave::SaveCore()
rC4S = Game.C4S; rC4S = Game.C4S;
// Always mark current engine version // Always mark current engine version
rC4S.Head.C4XVer[0]=C4XVER1; rC4S.Head.C4XVer[1]=C4XVER2; rC4S.Head.C4XVer[0]=C4XVER1; rC4S.Head.C4XVer[1]=C4XVER2;
rC4S.Head.C4XVer[2]=C4XVER3; rC4S.Head.C4XVer[3]=C4XVER4; rC4S.Head.C4XVer[2]=C4XVER3; rC4S.Head.C4XVer[3]=C4XVER4;
// Some flags are not to be set for initial settings: // Some flags are not to be set for initial settings:
// They depend on whether specific runtime data is present, which may simply not be stored into initial // They depend on whether specific runtime data is present, which may simply not be stored into initial
// saves, because they rely on any data present and up-to-date within the scenario! // saves, because they rely on any data present and up-to-date within the scenario!
@ -460,8 +460,8 @@ bool C4GameSave::Save(C4Group &hToGroup, bool fKeepGroup)
pSaveGroup->Delete(C4CFN_Titles); pSaveGroup->Delete(C4CFN_Titles);
pSaveGroup->Delete(C4CFN_Info); pSaveGroup->Delete(C4CFN_Info);
} }
// Always save Game.txt; even for saved scenarios, because global effects need to be saved // Always save Game.txt; even for saved scenarios, because global effects need to be saved
if(!Game.SaveData(*pSaveGroup, false, fInitial, IsExact())) if(!Game.SaveData(*pSaveGroup, false, fInitial, IsExact()))
{ Log(LoadResStr("IDS_ERR_SAVE_RUNTIMEDATA")); return false; } { Log(LoadResStr("IDS_ERR_SAVE_RUNTIMEDATA")); return false; }
// save additional runtime data // save additional runtime data
if (GetSaveRuntimeData()) if (!SaveRuntimeData()) return false; if (GetSaveRuntimeData()) if (!SaveRuntimeData()) return false;

View File

@ -66,7 +66,7 @@ class C4GameSave
virtual bool GetCreateSmallFile() { return false; } // return whether file size should be minimized virtual bool GetCreateSmallFile() { return false; } // return whether file size should be minimized
virtual bool GetForceExactLandscape() { return GetSaveRuntimeData() && IsExact(); } // whether exact landscape shall be saved virtual bool GetForceExactLandscape() { return GetSaveRuntimeData() && IsExact(); } // whether exact landscape shall be saved
virtual bool GetSaveOrigin() { return false; } // return whether C4S.Head.Origin shall be set virtual bool GetSaveOrigin() { return false; } // return whether C4S.Head.Origin shall be set
virtual bool GetClearOrigin() { return !GetSaveOrigin(); } // return whether C4S.Head.Origin shall be cleared if it's set virtual bool GetClearOrigin() { return !GetSaveOrigin(); } // return whether C4S.Head.Origin shall be cleared if it's set
virtual bool GetSaveUserPlayers() { return IsExact(); } // return whether joined user players shall be saved into SavePlayerInfos virtual bool GetSaveUserPlayers() { return IsExact(); } // return whether joined user players shall be saved into SavePlayerInfos
virtual bool GetSaveScriptPlayers() { return IsExact(); } // return whether joined script players shall be saved into SavePlayerInfos virtual bool GetSaveScriptPlayers() { return IsExact(); } // return whether joined script players shall be saved into SavePlayerInfos
virtual bool GetSaveUserPlayerFiles() { return IsExact(); } // return whether .c4p files of joined user players shall be put into the scenario virtual bool GetSaveUserPlayerFiles() { return IsExact(); } // return whether .c4p files of joined user players shall be put into the scenario
@ -122,7 +122,7 @@ class C4GameSaveScenario : public C4GameSave
bool fForceExactLandscape; bool fForceExactLandscape;
bool fSaveOrigin; bool fSaveOrigin;
virtual bool GetSaveOrigin() { return fSaveOrigin; } virtual bool GetSaveOrigin() { return fSaveOrigin; }
virtual bool GetClearOrigin() { return false; } // always keep existing origin virtual bool GetClearOrigin() { return false; } // always keep existing origin
virtual bool GetSaveDesc() { return false; } // should WriteDescData be executed in Save()-call? virtual bool GetSaveDesc() { return false; } // should WriteDescData be executed in Save()-call?
virtual bool GetForceExactLandscape() { return C4GameSave::GetForceExactLandscape() || fForceExactLandscape; } virtual bool GetForceExactLandscape() { return C4GameSave::GetForceExactLandscape() || fForceExactLandscape; }
virtual bool GetSaveScriptPlayers() { return true; } // script players are also saved; but user players aren't! virtual bool GetSaveScriptPlayers() { return true; } // script players are also saved; but user players aren't!

View File

@ -42,7 +42,7 @@ void C4PlayerInfo::Clear()
// del temp file // del temp file
DeleteTempFile(); DeleteTempFile();
// clear fields // clear fields
sName.Clear(); szFilename.Clear(); sName.Clear(); szFilename.Clear();
pRes = NULL; pRes = NULL;
ResCore.Clear(); ResCore.Clear();
// default fields // default fields
@ -66,7 +66,7 @@ void C4PlayerInfo::DeleteTempFile()
EraseItem(szFilename.getData()); EraseItem(szFilename.getData());
// reset flag and filename to prevent double deletion // reset flag and filename to prevent double deletion
dwFlags &= ~PIF_TempFile; dwFlags &= ~PIF_TempFile;
szFilename.Clear(); szFilename.Clear();
} }
} }
@ -179,13 +179,13 @@ bool C4PlayerInfo::HasTeamWon() const
} }
void C4PlayerInfo::CompileFunc(StdCompiler *pComp) void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
{ {
// Names // Names
pComp->Value(mkNamingAdapt(sName, "Name", "")); pComp->Value(mkNamingAdapt(sName, "Name", ""));
pComp->Value(mkNamingAdapt(sForcedName, "ForcedName", "")); pComp->Value(mkNamingAdapt(sForcedName, "ForcedName", ""));
pComp->Value(mkNamingAdapt(szFilename, "Filename", "")); pComp->Value(mkNamingAdapt(szFilename, "Filename", ""));
// Flags // Flags
const StdBitfieldEntry<uint16_t> Entries[] = const StdBitfieldEntry<uint16_t> Entries[] =
{ {
{ "Joined", PIF_Joined }, { "Joined", PIF_Joined },
@ -202,9 +202,9 @@ void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
{ "Invisible", PIF_Invisible}, { "Invisible", PIF_Invisible},
{ NULL, 0 }, { NULL, 0 },
}; };
uint16_t dwSyncFlags = dwFlags & PIF_SyncFlags; // do not store local flags! uint16_t dwSyncFlags = dwFlags & PIF_SyncFlags; // do not store local flags!
pComp->Value(mkNamingAdapt(mkBitfieldAdapt(dwSyncFlags, Entries), "Flags", 0u)); pComp->Value(mkNamingAdapt(mkBitfieldAdapt(dwSyncFlags, Entries), "Flags", 0u));
if(pComp->isCompiler()) dwFlags = dwSyncFlags; if(pComp->isCompiler()) dwFlags = dwSyncFlags;
pComp->Value(mkNamingAdapt(iID, "ID", 0)); pComp->Value(mkNamingAdapt(iID, "ID", 0));
// type // type
@ -224,7 +224,7 @@ void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
} }
// load colors // load colors
pComp->Value(mkNamingAdapt(dwColor, "Color", 0u)); pComp->Value(mkNamingAdapt(dwColor, "Color", 0u));
pComp->Value(mkNamingAdapt(dwOriginalColor, "OriginalColor", dwColor)); pComp->Value(mkNamingAdapt(dwOriginalColor, "OriginalColor", dwColor));
// load savegame ID // load savegame ID
pComp->Value(mkNamingAdapt(mkIntPackAdapt(idSavegamePlayer), "SavgamePlayer", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(idSavegamePlayer), "SavgamePlayer", 0));
@ -234,18 +234,18 @@ void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(szAuthID, "AUID", "")); pComp->Value(mkNamingAdapt(szAuthID, "AUID", ""));
// InGame info // InGame info
if(dwFlags & PIF_Joined) if(dwFlags & PIF_Joined)
{ {
pComp->Value(mkNamingAdapt(iInGameNumber, "GameNumber", -1)); pComp->Value(mkNamingAdapt(iInGameNumber, "GameNumber", -1));
pComp->Value(mkNamingAdapt(iInGameJoinFrame, "GameJoinFrame", -1)); pComp->Value(mkNamingAdapt(iInGameJoinFrame, "GameJoinFrame", -1));
} }
else else
iInGameNumber = iInGameJoinFrame = -1; iInGameNumber = iInGameJoinFrame = -1;
if(dwFlags & PIF_Removed) if(dwFlags & PIF_Removed)
pComp->Value(mkNamingAdapt(iInGamePartFrame, "GamePartFrame", -1)); pComp->Value(mkNamingAdapt(iInGamePartFrame, "GamePartFrame", -1));
else else
iInGamePartFrame = -1; iInGamePartFrame = -1;
// script player extra data // script player extra data
pComp->Value(mkNamingAdapt(idExtraData, "ExtraData", C4ID::None)); pComp->Value(mkNamingAdapt(idExtraData, "ExtraData", C4ID::None));
@ -255,13 +255,13 @@ void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iLeagueScore), "LeagueScore", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iLeagueScore), "LeagueScore", 0));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iLeagueRank), "LeagueRank", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iLeagueRank), "LeagueRank", 0));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iLeagueRankSymbol), "LeagueRankSymbol", 0)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iLeagueRankSymbol), "LeagueRankSymbol", 0));
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iLeagueProjectedGain), "ProjectedGain", -1)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iLeagueProjectedGain), "ProjectedGain", -1));
pComp->Value(mkNamingAdapt(mkParAdapt(sClanTag, StdCompiler::RCT_All), "ClanTag", "")); pComp->Value(mkNamingAdapt(mkParAdapt(sClanTag, StdCompiler::RCT_All), "ClanTag", ""));
// file resource // file resource
if (dwFlags & PIF_HasRes) if (dwFlags & PIF_HasRes)
{ {
// ResCore // ResCore
if (pComp->isDecompiler() && pRes) if (pComp->isDecompiler() && pRes)
{ {
// ensure ResCore is up-to-date // ensure ResCore is up-to-date
@ -270,11 +270,11 @@ void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(ResCore, "ResCore")); pComp->Value(mkNamingAdapt(ResCore, "ResCore"));
} }
} }
void C4PlayerInfo::SetFilename(const char *szToFilename) void C4PlayerInfo::SetFilename(const char *szToFilename)
{ {
szFilename = szToFilename; szFilename = szToFilename;
} }
void C4PlayerInfo::SetToScenarioFilename(const char *szScenFilename) void C4PlayerInfo::SetToScenarioFilename(const char *szScenFilename)
@ -630,10 +630,10 @@ int32_t C4ClientPlayerInfos::GetJoinedPlayerCount() const
} }
void C4ClientPlayerInfos::CompileFunc(StdCompiler *pComp) void C4ClientPlayerInfos::CompileFunc(StdCompiler *pComp)
{ {
bool fCompiler = pComp->isCompiler(); bool fCompiler = pComp->isCompiler();
if(fCompiler) Clear(); if(fCompiler) Clear();
pComp->Value(mkNamingAdapt(iClientID, "ID", C4ClientIDUnknown)); pComp->Value(mkNamingAdapt(iClientID, "ID", C4ClientIDUnknown));
// Flags // Flags
StdBitfieldEntry<uint32_t> Entries[] = StdBitfieldEntry<uint32_t> Entries[] =
@ -645,22 +645,22 @@ void C4ClientPlayerInfos::CompileFunc(StdCompiler *pComp)
{ NULL, 0 } { NULL, 0 }
}; };
pComp->Value(mkNamingAdapt(mkBitfieldAdapt(dwFlags, Entries), "Flags", 0u)); pComp->Value(mkNamingAdapt(mkBitfieldAdapt(dwFlags, Entries), "Flags", 0u));
pComp->Value(mkNamingCountAdapt<int32_t>(iPlayerCount, "Player")); pComp->Value(mkNamingCountAdapt<int32_t>(iPlayerCount, "Player"));
if(iPlayerCount < 0 || iPlayerCount > C4MaxPlayer) if(iPlayerCount < 0 || iPlayerCount > C4MaxPlayer)
{ pComp->excCorrupt("player count out of range"); return; } { pComp->excCorrupt("player count out of range"); return; }
// Grow list, if necessary // Grow list, if necessary
if(fCompiler && iPlayerCount > iPlayerCapacity) if(fCompiler && iPlayerCount > iPlayerCapacity)
{ {
GrowList(iPlayerCount - iPlayerCapacity); GrowList(iPlayerCount - iPlayerCapacity);
ZeroMem(ppPlayers, sizeof(*ppPlayers) * iPlayerCount); ZeroMem(ppPlayers, sizeof(*ppPlayers) * iPlayerCount);
} }
// Compile // Compile
pComp->Value(mkNamingAdapt(mkArrayAdaptMap(ppPlayers, iPlayerCount, mkPtrAdaptNoNull<C4PlayerInfo>), "Player")); pComp->Value(mkNamingAdapt(mkArrayAdaptMap(ppPlayers, iPlayerCount, mkPtrAdaptNoNull<C4PlayerInfo>), "Player"));
// Force specialization // Force specialization
mkPtrAdaptNoNull<C4PlayerInfo>(*ppPlayers); mkPtrAdaptNoNull<C4PlayerInfo>(*ppPlayers);
} }
void C4ClientPlayerInfos::LoadResources() void C4ClientPlayerInfos::LoadResources()
{ {
@ -770,7 +770,7 @@ bool C4PlayerInfoList::DoLocalNonNetworkPlayerInfoUpdate(C4ClientPlayerInfos *pU
UpdatePlayerAttributes(pUpdate, true); UpdatePlayerAttributes(pUpdate, true);
// add through queue: This will add directly, do the record and put player joins into the queue // add through queue: This will add directly, do the record and put player joins into the queue
// in running mode, this call will also put the actual player joins into the queue // in running mode, this call will also put the actual player joins into the queue
::Control.DoInput(CID_PlrInfo, new C4ControlPlayerInfo(*pUpdate), Game.IsRunning ? CDT_Queue : CDT_Direct); ::Control.DoInput(CID_PlrInfo, new C4ControlPlayerInfo(*pUpdate), Game.IsRunning ? CDT_Queue : CDT_Direct);
// done, success // done, success
return true; return true;
} }
@ -1215,11 +1215,11 @@ bool C4PlayerInfoList::Load(C4Group &hGroup, const char *szFromFile, C4LangStrin
return true; return true;
// replace strings // replace strings
if (pLang) pLang->ReplaceStrings(Buf); if (pLang) pLang->ReplaceStrings(Buf);
// (try to) compile // (try to) compile
if(!CompileFromBuf_LogWarn<StdCompilerINIRead>( if(!CompileFromBuf_LogWarn<StdCompilerINIRead>(
mkNamingAdapt(*this, "PlayerInfoList"), mkNamingAdapt(*this, "PlayerInfoList"),
Buf, szFromFile)) Buf, szFromFile))
return false; return false;
// done, success // done, success
return true; return true;
} }
@ -1231,16 +1231,16 @@ bool C4PlayerInfoList::Save(C4Group &hGroup, const char *szToFile)
// anything to save? // anything to save?
if (!iClientCount) return true; if (!iClientCount) return true;
// save it // save it
try try
{ {
// decompile // decompile
StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>( StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(
mkNamingAdapt(*this, "PlayerInfoList")); mkNamingAdapt(*this, "PlayerInfoList"));
// save buffer to group // save buffer to group
hGroup.Add(szToFile, Buf, false, true); hGroup.Add(szToFile, Buf, false, true);
} }
catch(StdCompiler::Exception *) catch(StdCompiler::Exception *)
{ return false; } { return false; }
// done, success // done, success
return true; return true;
} }
@ -1613,7 +1613,7 @@ bool C4PlayerInfoList::RecreatePlayers()
{ {
const char *szName = pInfo->GetName(); const char *szName = pInfo->GetName();
if (!::Network.RetrieveRes(pJoinRes->getCore(), C4NetResRetrieveTimeout, if (!::Network.RetrieveRes(pJoinRes->getCore(), C4NetResRetrieveTimeout,
FormatString(LoadResStr("IDS_NET_RES_PLRFILE"), szName).getData())) FormatString(LoadResStr("IDS_NET_RES_PLRFILE"), szName).getData()))
szFilename=NULL; szFilename=NULL;
} }
// file present? // file present?
@ -1757,49 +1757,49 @@ bool C4PlayerInfoList::SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fS
} }
void C4PlayerInfoList::ResetLeagueProjectedGain(bool fSetUpdated) void C4PlayerInfoList::ResetLeagueProjectedGain(bool fSetUpdated)
{ {
C4ClientPlayerInfos *pClient; int iClient=0; C4ClientPlayerInfos *pClient; int iClient=0;
while ((pClient = GetIndexedInfo(iClient++))) while ((pClient = GetIndexedInfo(iClient++)))
{ {
C4PlayerInfo *pInfo; int iInfo = 0; C4PlayerInfo *pInfo; int iInfo = 0;
while ((pInfo = pClient->GetPlayerInfo(iInfo++))) while ((pInfo = pClient->GetPlayerInfo(iInfo++)))
if (pInfo->IsLeagueProjectedGainValid()) if (pInfo->IsLeagueProjectedGainValid())
{ {
pInfo->ResetLeagueProjectedGain(); pInfo->ResetLeagueProjectedGain();
if (fSetUpdated) if (fSetUpdated)
pClient->SetUpdated(); pClient->SetUpdated();
} }
} }
} }
void C4PlayerInfoList::CompileFunc(StdCompiler *pComp) void C4PlayerInfoList::CompileFunc(StdCompiler *pComp)
{ {
bool fCompiler = pComp->isCompiler(); bool fCompiler = pComp->isCompiler();
if(fCompiler) Clear(); if(fCompiler) Clear();
// skip compiling if there is nothing to compile (cosmentics) // skip compiling if there is nothing to compile (cosmentics)
if(!fCompiler && pComp->hasNaming() && iLastPlayerID == 0 && iClientCount == 0) if(!fCompiler && pComp->hasNaming() && iLastPlayerID == 0 && iClientCount == 0)
return; return;
// header // header
pComp->Value(mkNamingAdapt(iLastPlayerID, "LastPlayerID", 0)); pComp->Value(mkNamingAdapt(iLastPlayerID, "LastPlayerID", 0));
// client count // client count
int32_t iTemp = iClientCount; int32_t iTemp = iClientCount;
pComp->Value(mkNamingCountAdapt<int32_t>(iTemp, "Client")); pComp->Value(mkNamingCountAdapt<int32_t>(iTemp, "Client"));
if(iTemp < 0 || iTemp > C4MaxClient) if(iTemp < 0 || iTemp > C4MaxClient)
{ pComp->excCorrupt("client count out of range"); return; } { pComp->excCorrupt("client count out of range"); return; }
// grow list // grow list
if(fCompiler) if(fCompiler)
{ {
if(iTemp > iClientCapacity) GrowList(iTemp - iClientCapacity); if(iTemp > iClientCapacity) GrowList(iTemp - iClientCapacity);
iClientCount = iTemp; iClientCount = iTemp;
ZeroMem(ppClients, sizeof(*ppClients) * iClientCount); ZeroMem(ppClients, sizeof(*ppClients) * iClientCount);
} }
// client packets // client packets
pComp->Value( pComp->Value(
mkNamingAdapt( mkNamingAdapt(
mkArrayAdaptMap(ppClients, iClientCount, mkPtrAdaptNoNull<C4ClientPlayerInfos>), mkArrayAdaptMap(ppClients, iClientCount, mkPtrAdaptNoNull<C4ClientPlayerInfos>),
"Client")); "Client"));
// force compiler to specialize // force compiler to specialize
mkPtrAdaptNoNull<C4ClientPlayerInfos>(*ppClients); mkPtrAdaptNoNull<C4ClientPlayerInfos>(*ppClients);
} }
int32_t C4PlayerInfoList::GetStartupCount() int32_t C4PlayerInfoList::GetStartupCount()
@ -1839,12 +1839,12 @@ void C4PlayerInfoList::FixIDCounter()
/* -- Player info packets -- */ /* -- Player info packets -- */
void C4PacketPlayerInfoUpdRequest::CompileFunc(StdCompiler *pComp) void C4PacketPlayerInfoUpdRequest::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(Info); pComp->Value(Info);
} }
void C4PacketPlayerInfo::CompileFunc(StdCompiler *pComp) void C4PacketPlayerInfo::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(fIsRecreationInfo, "Recreation", false)); pComp->Value(mkNamingAdapt(fIsRecreationInfo, "Recreation", false));
pComp->Value(mkNamingAdapt(Info, "Info")); pComp->Value(mkNamingAdapt(Info, "Info"));
} }

View File

@ -55,9 +55,9 @@ class C4PlayerInfo
PIF_TempFile = 1<<5, // player file is temporary and to be deleted after join recreation PIF_TempFile = 1<<5, // player file is temporary and to be deleted after join recreation
PIF_InScenarioFile = 1<<6, // player file is present within the scenario; res is not to be used PIF_InScenarioFile = 1<<6, // player file is present within the scenario; res is not to be used
PIF_JoinedForSavegameOnly = 1<<7, // player file has been specified to take over a savegame player; do not join as normal player if association fails PIF_JoinedForSavegameOnly = 1<<7, // player file has been specified to take over a savegame player; do not join as normal player if association fails
PIF_Disconnected = 1<<8, // the player was removed because his client disconnected PIF_Disconnected = 1<<8, // the player was removed because his client disconnected
PIF_Won = 1<<9, // player survived until game end (for game evaluation only) PIF_Won = 1<<9, // player survived until game end (for game evaluation only)
PIF_VotedOut = 1<<10, // player was removed from the round after a successful voting PIF_VotedOut = 1<<10, // player was removed from the round after a successful voting
PIF_AttributesFixed= 1<<11, // player color and name aren't changed on collision PIF_AttributesFixed= 1<<11, // player color and name aren't changed on collision
PIF_NoScenarioInit = 1<<12, // do not call ScenariInit for this player PIF_NoScenarioInit = 1<<12, // do not call ScenariInit for this player
PIF_NoEliminationCheck = 1<<13, // do not eliminate player if crew is empty PIF_NoEliminationCheck = 1<<13, // do not eliminate player if crew is empty
@ -141,8 +141,8 @@ class C4PlayerInfo
{ dwFlags |= PIF_VotedOut; } { dwFlags |= PIF_VotedOut; }
void SetLeagueProjectedGain(int32_t iProjectedGain) void SetLeagueProjectedGain(int32_t iProjectedGain)
{ assert(iProjectedGain>=0); iLeagueProjectedGain = iProjectedGain; } { assert(iProjectedGain>=0); iLeagueProjectedGain = iProjectedGain; }
void ResetLeagueProjectedGain() void ResetLeagueProjectedGain()
{ iLeagueProjectedGain = -1; } { iLeagueProjectedGain = -1; }
void SetForcedName(const char *szNewName) void SetForcedName(const char *szNewName)
{ if (szNewName) sForcedName.CopyValidated(szNewName); else sForcedName.Clear(); } { if (szNewName) sForcedName.CopyValidated(szNewName); else sForcedName.Clear(); }
@ -184,7 +184,7 @@ class C4PlayerInfo
int32_t getLeagueRankSymbol() const { return iLeagueRankSymbol; } // returns rank symbol on league server (0 for not assigned) int32_t getLeagueRankSymbol() const { return iLeagueRankSymbol; } // returns rank symbol on league server (0 for not assigned)
int32_t getLeagueScoreProjected() const { return iLeagueScoreProjected; } // returns score on league server in case of win (0 for not assigned) int32_t getLeagueScoreProjected() const { return iLeagueScoreProjected; } // returns score on league server in case of win (0 for not assigned)
int32_t GetInGameNumber() const { return iInGameNumber; } // returns player number the player had in the game int32_t GetInGameNumber() const { return iInGameNumber; } // returns player number the player had in the game
bool IsLeagueProjectedGainValid() const { return iLeagueProjectedGain>=0; } bool IsLeagueProjectedGainValid() const { return iLeagueProjectedGain>=0; }
int32_t GetLeagueProjectedGain() const { return iLeagueProjectedGain; } // get score gain in primary league if this player's team wins int32_t GetLeagueProjectedGain() const { return iLeagueProjectedGain; } // get score gain in primary league if this player's team wins
int32_t GetID() const { return iID; } // get unique ID, if assigned int32_t GetID() const { return iID; } // get unique ID, if assigned
@ -193,8 +193,8 @@ class C4PlayerInfo
DWORD GetFlags() { return dwFlags; } // for dbg print only DWORD GetFlags() { return dwFlags; } // for dbg print only
void SetDisconnected() { dwFlags |= PIF_Disconnected; } void SetDisconnected() { dwFlags |= PIF_Disconnected; }
void SetWinner() { dwFlags |= PIF_Won; } void SetWinner() { dwFlags |= PIF_Won; }
bool LoadBigIcon(C4FacetSurface &fctTarget); // load BigIcon.png of player into target facet; return false if no bigicon present or player file not yet loaded bool LoadBigIcon(C4FacetSurface &fctTarget); // load BigIcon.png of player into target facet; return false if no bigicon present or player file not yet loaded
}; };
@ -412,7 +412,7 @@ class C4PlayerInfoList
bool SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fSaveUserPlrs, bool fSaveScriptPlrs, bool fSetUserPlrRefToLocalGroup, bool fSetScriptPlrRefToLocalGroup); // copy all joined players from player list bool SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fSaveUserPlrs, bool fSaveScriptPlrs, bool fSetUserPlrRefToLocalGroup, bool fSetScriptPlrRefToLocalGroup); // copy all joined players from player list
bool RemoveUnassociatedPlayers(C4PlayerInfoList &rSavegamePlayers); // remove all savegame players that are not associated to this list from the game bool RemoveUnassociatedPlayers(C4PlayerInfoList &rSavegamePlayers); // remove all savegame players that are not associated to this list from the game
int32_t GetFreePlayerSlotCount(); // get number of players that may still join int32_t GetFreePlayerSlotCount(); // get number of players that may still join
void ResetLeagueProjectedGain(bool fSetUpdated); // reset known projected gains for all players (to be updated by league again) void ResetLeagueProjectedGain(bool fSetUpdated); // reset known projected gains for all players (to be updated by league again)
// network: Load all resources connected with the players that are not being loaded yet // network: Load all resources connected with the players that are not being loaded yet
void LoadResources(); void LoadResources();

View File

@ -151,7 +151,7 @@ bool C4Record::Start(bool fInitial)
Index++; Index++;
// compose record filename // compose record filename
sFilename.Format("%s" DirSep "%03i-%s.c4s", sDemoFolder.getData(), Index, sScenName); sFilename.Format("%s" DirSep "%03i-%s.c4s", sDemoFolder.getData(), Index, sScenName);
// log // log
StdStrBuf sLog; sLog.Format(LoadResStr("IDS_PRC_RECORDINGTO"),sFilename.getData()); StdStrBuf sLog; sLog.Format(LoadResStr("IDS_PRC_RECORDINGTO"),sFilename.getData());
@ -185,9 +185,9 @@ bool C4Record::Start(bool fInitial)
} }
bool C4Record::Stop(StdStrBuf *pRecordName, BYTE *pRecordSHA1) bool C4Record::Stop(StdStrBuf *pRecordName, BYTE *pRecordSHA1)
{ {
// safety // safety
if (!fRecording) return false; if (!fRecording) return false;
if (!DirectoryExists(sFilename.getData())) return false; if (!DirectoryExists(sFilename.getData())) return false;
// streaming finished // streaming finished
@ -220,35 +220,35 @@ bool C4Record::Stop(StdStrBuf *pRecordName, BYTE *pRecordSHA1)
if(!C4Group_GetFileSHA1(sFilename.getData(), pRecordSHA1)) if(!C4Group_GetFileSHA1(sFilename.getData(), pRecordSHA1))
return false; return false;
// ok // ok
fRecording = false; fRecording = false;
return true; return true;
} }
bool C4Record::Rec(const C4Control &Ctrl, int iFrame) bool C4Record::Rec(const C4Control &Ctrl, int iFrame)
{ {
if(!fRecording) return false; if(!fRecording) return false;
// don't record empty control // don't record empty control
if(!Ctrl.firstPkt()) return true; if(!Ctrl.firstPkt()) return true;
// create copy // create copy
C4Control Cpy; Cpy.Copy(Ctrl); C4Control Cpy; Cpy.Copy(Ctrl);
// prepare it for record // prepare it for record
Cpy.PreRec(this); Cpy.PreRec(this);
// record it // record it
return Rec(iFrame, DecompileToBuf<StdCompilerBinWrite>(Cpy), RCT_Ctrl); return Rec(iFrame, DecompileToBuf<StdCompilerBinWrite>(Cpy), RCT_Ctrl);
} }
bool C4Record::Rec(C4PacketType eCtrlType, C4ControlPacket *pCtrl, int iFrame) bool C4Record::Rec(C4PacketType eCtrlType, C4ControlPacket *pCtrl, int iFrame)
{ {
if(!fRecording) return false; if(!fRecording) return false;
// create copy // create copy
C4IDPacket Pkt = C4IDPacket(eCtrlType, pCtrl, false); if(!Pkt.getPkt()) return false; C4IDPacket Pkt = C4IDPacket(eCtrlType, pCtrl, false); if(!Pkt.getPkt()) return false;
C4ControlPacket *pCtrlCpy = static_cast<C4ControlPacket *>(Pkt.getPkt()); C4ControlPacket *pCtrlCpy = static_cast<C4ControlPacket *>(Pkt.getPkt());
// prepare for recording // prepare for recording
pCtrlCpy->PreRec(this); pCtrlCpy->PreRec(this);
// record it // record it
return Rec(iFrame, DecompileToBuf<StdCompilerBinWrite>(Pkt), RCT_CtrlPkt); return Rec(iFrame, DecompileToBuf<StdCompilerBinWrite>(Pkt), RCT_CtrlPkt);
} }
bool C4Record::Rec(int iFrame, const StdBuf &sBuf, C4RecordChunkType eType) bool C4Record::Rec(int iFrame, const StdBuf &sBuf, C4RecordChunkType eType)
{ {
@ -399,7 +399,7 @@ C4Playback::~C4Playback()
} }
bool C4Playback::Open(C4Group &rGrp) bool C4Playback::Open(C4Group &rGrp)
{ {
// clean up // clean up
Clear(); Clear();
fLoadSequential = !rGrp.IsPacked(); fLoadSequential = !rGrp.IsPacked();
@ -513,7 +513,7 @@ bool C4Playback::Open(C4Group &rGrp)
#endif #endif
// ok // ok
return true; return true;
} }
bool C4Playback::ReadBinary(const StdBuf &Buf) bool C4Playback::ReadBinary(const StdBuf &Buf)
{ {
@ -784,7 +784,7 @@ void C4Playback::Strip()
} }
break; break;
default: default:
// TODO // TODO
break; break;
} }
} }
@ -817,7 +817,7 @@ void C4Playback::Strip()
if (fStripMessages) fStripThis=true; if (fStripMessages) fStripThis=true;
break; break;
default: default:
// TODO // TODO
break; break;
} }
if (fStripThis) if (fStripThis)
@ -847,13 +847,13 @@ void C4Playback::Strip()
bool C4Playback::ExecuteControl(C4Control *pCtrl, int iFrame) bool C4Playback::ExecuteControl(C4Control *pCtrl, int iFrame)
{ {
// still playbacking? // still playbacking?
if (currChunk == chunks.end()) return false; if (currChunk == chunks.end()) return false;
if (Finished) { Finish(); return false; } if (Finished) { Finish(); return false; }
#ifdef DEBUGREC #ifdef DEBUGREC
if(DebugRec.firstPkt()) if(DebugRec.firstPkt())
DebugRecError("Debug rec overflow!"); DebugRecError("Debug rec overflow!");
DebugRec.Clear(); DebugRec.Clear();
#endif #endif
// return all control until this frame // return all control until this frame
while(currChunk != chunks.end() && currChunk->Frame <= iFrame) while(currChunk != chunks.end() && currChunk->Frame <= iFrame)
@ -862,9 +862,9 @@ bool C4Playback::ExecuteControl(C4Control *pCtrl, int iFrame)
{ {
case RCT_Ctrl: case RCT_Ctrl:
pCtrl->Append(*currChunk->pCtrl); pCtrl->Append(*currChunk->pCtrl);
break; break;
case RCT_CtrlPkt: case RCT_CtrlPkt:
{ {
C4IDPacket Packet(*currChunk->pPkt); C4IDPacket Packet(*currChunk->pPkt);
pCtrl->Add(Packet.getPktType(), static_cast<C4ControlPacket *>(Packet.getPkt())); pCtrl->Add(Packet.getPktType(), static_cast<C4ControlPacket *>(Packet.getPkt()));
@ -878,7 +878,7 @@ bool C4Playback::ExecuteControl(C4Control *pCtrl, int iFrame)
break; break;
#ifdef DEBUGREC #ifdef DEBUGREC
default: // expect it to be debug rec default: // expect it to be debug rec
// append to debug rec buffer // append to debug rec buffer
if (currChunk->pDbg) if (currChunk->pDbg)
{ {
@ -886,20 +886,20 @@ bool C4Playback::ExecuteControl(C4Control *pCtrl, int iFrame)
// the debugrec buffer is now responsible for deleting the packet // the debugrec buffer is now responsible for deleting the packet
currChunk->pDbg = NULL; currChunk->pDbg = NULL;
} }
break; break;
#endif #endif
} }
// next chunk // next chunk
NextChunk(); NextChunk();
} }
// Debug log // Debug log
#ifdef DEBUGREC #ifdef DEBUGREC
//sprintf(OSTR, "-- Frame %d:", Game.FrameCounter); Log(OSTR); //sprintf(OSTR, "-- Frame %d:", Game.FrameCounter); Log(OSTR);
//char Indent[256+1]; strcpy(Indent, ""); //char Indent[256+1]; strcpy(Indent, "");
//pCtrl->deb_print(Indent); //pCtrl->deb_print(Indent);
#endif #endif
return true; return true;
} }
void C4Playback::Finish() void C4Playback::Finish()
@ -1127,7 +1127,7 @@ bool C4Playback::StreamToRecord(const char *szStream, StdStrBuf *pRecordFile)
{ {
// Initialize stream // Initialize stream
z_stream strm; z_stream strm;
ZeroMem(&strm, sizeof strm); ZeroMem(&strm, sizeof strm);
strm.next_in = getMBufPtr<BYTE>(CompressedData); strm.next_in = getMBufPtr<BYTE>(CompressedData);
strm.avail_in = CompressedData.getSize(); strm.avail_in = CompressedData.getSize();

View File

@ -270,11 +270,11 @@ class C4Record // demo recording
const StdBuf &GetStreamingBuf() const { return StreamingData; } const StdBuf &GetStreamingBuf() const { return StreamingData; }
bool Start(bool fInitial); bool Start(bool fInitial);
bool Stop(StdStrBuf *pRecordName = NULL, BYTE *pRecordSHA1 = NULL); bool Stop(StdStrBuf *pRecordName = NULL, BYTE *pRecordSHA1 = NULL);
bool Rec(const C4Control &Ctrl, int iFrame); // record control bool Rec(const C4Control &Ctrl, int iFrame); // record control
bool Rec(C4PacketType eCtrlType, C4ControlPacket *pCtrl, int iFrame); // record control packet bool Rec(C4PacketType eCtrlType, C4ControlPacket *pCtrl, int iFrame); // record control packet
bool Rec(int iFrame, const StdBuf &sBuf, C4RecordChunkType eType); bool Rec(int iFrame, const StdBuf &sBuf, C4RecordChunkType eType);
bool AddFile(const char *szLocalFilename, const char *szAddAs, bool fDelete = false); bool AddFile(const char *szLocalFilename, const char *szAddAs, bool fDelete = false);
@ -300,7 +300,7 @@ class C4Playback // demo playback
uint32_t iLastSequentialFrame; // frame number of last chunk read uint32_t iLastSequentialFrame; // frame number of last chunk read
void Finish(); // end playback void Finish(); // end playback
#ifdef DEBUGREC #ifdef DEBUGREC
C4PacketList DebugRec; C4PacketList DebugRec;
#endif #endif
public: public:
C4Playback(); // constructor; init playback C4Playback(); // constructor; init playback
@ -319,7 +319,7 @@ class C4Playback // demo playback
void Clear(); void Clear();
#ifdef DEBUGREC #ifdef DEBUGREC
void Check(C4RecordChunkType eType, const uint8_t *pData, int iSize); // compare with debugrec void Check(C4RecordChunkType eType, const uint8_t *pData, int iSize); // compare with debugrec
void DebugRecError(const char *szError); void DebugRecError(const char *szError);
#endif #endif
static bool StreamToRecord(const char *szStream, StdStrBuf *pRecord); static bool StreamToRecord(const char *szStream, StdStrBuf *pRecord);
}; };

View File

@ -42,12 +42,12 @@ void C4RoundResultsPlayer::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(iLeagueScoreGain, "GameScore", -1)); // name used in league reply! pComp->Value(mkNamingAdapt(iLeagueScoreGain, "GameScore", -1)); // name used in league reply!
pComp->Value(mkNamingAdapt(iLeagueRankNew, "Rank", 0)); // name used in league reply! pComp->Value(mkNamingAdapt(iLeagueRankNew, "Rank", 0)); // name used in league reply!
pComp->Value(mkNamingAdapt(iLeagueRankSymbolNew, "RankSymbol", 0)); // name used in league reply! pComp->Value(mkNamingAdapt(iLeagueRankSymbolNew, "RankSymbol", 0)); // name used in league reply!
StdEnumEntry<LeagueStatus> LeagueStatusEntries[] = StdEnumEntry<LeagueStatus> LeagueStatusEntries[] =
{ {
{ "", RRPLS_Unknown }, { "", RRPLS_Unknown },
{ "Lost", RRPLS_Lost }, { "Lost", RRPLS_Lost },
{ "Won", RRPLS_Won }, { "Won", RRPLS_Won },
}; };
pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(eLeagueStatus, LeagueStatusEntries), "Status", RRPLS_Unknown)); // name used in league reply! pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(eLeagueStatus, LeagueStatusEntries), "Status", RRPLS_Unknown)); // name used in league reply!
} }
@ -143,22 +143,22 @@ void C4RoundResultsPlayers::Clear()
void C4RoundResultsPlayers::CompileFunc(StdCompiler *pComp) void C4RoundResultsPlayers::CompileFunc(StdCompiler *pComp)
{ {
bool fCompiler = pComp->isCompiler(); bool fCompiler = pComp->isCompiler();
if(fCompiler) Clear(); if(fCompiler) Clear();
int32_t iTemp = iPlayerCount; int32_t iTemp = iPlayerCount;
pComp->Value(mkNamingCountAdapt<int32_t>(iTemp, "Player")); pComp->Value(mkNamingCountAdapt<int32_t>(iTemp, "Player"));
if(iTemp < 0 || iTemp > C4MaxPlayer) if(iTemp < 0 || iTemp > C4MaxPlayer)
{ pComp->excCorrupt("player count out of range"); return; } { pComp->excCorrupt("player count out of range"); return; }
// Grow list, if necessary // Grow list, if necessary
if(fCompiler && iTemp > iPlayerCapacity) if(fCompiler && iTemp > iPlayerCapacity)
{ {
GrowList(iTemp - iPlayerCapacity); GrowList(iTemp - iPlayerCapacity);
iPlayerCount = iTemp; iPlayerCount = iTemp;
ZeroMem(ppPlayers, sizeof(*ppPlayers) * iPlayerCount); ZeroMem(ppPlayers, sizeof(*ppPlayers) * iPlayerCount);
} }
// Compile // Compile
pComp->Value(mkNamingAdapt(mkArrayAdaptMap(ppPlayers, iPlayerCount, mkPtrAdaptNoNull<C4RoundResultsPlayer>), "Player")); pComp->Value(mkNamingAdapt(mkArrayAdaptMap(ppPlayers, iPlayerCount, mkPtrAdaptNoNull<C4RoundResultsPlayer>), "Player"));
// Force specialization // Force specialization
mkPtrAdaptNoNull<C4RoundResultsPlayer>(*ppPlayers); mkPtrAdaptNoNull<C4RoundResultsPlayer>(*ppPlayers);
} }
C4RoundResultsPlayer *C4RoundResultsPlayers::GetByIndex(int32_t idx) const C4RoundResultsPlayer *C4RoundResultsPlayers::GetByIndex(int32_t idx) const
@ -256,22 +256,22 @@ void C4RoundResults::Init()
void C4RoundResults::CompileFunc(StdCompiler *pComp) void C4RoundResults::CompileFunc(StdCompiler *pComp)
{ {
bool fCompiler = pComp->isCompiler(); bool fCompiler = pComp->isCompiler();
if(fCompiler) Clear(); if(fCompiler) Clear();
pComp->Value(mkNamingAdapt(Goals, "Goals", C4IDList())); pComp->Value(mkNamingAdapt(Goals, "Goals", C4IDList()));
pComp->Value(mkNamingAdapt(iPlayingTime, "PlayingTime", 0u)); pComp->Value(mkNamingAdapt(iPlayingTime, "PlayingTime", 0u));
pComp->Value(mkNamingAdapt(fHideSettlementScore, "HideSettlementScore", Game.C4S.Game.IsMelee())); pComp->Value(mkNamingAdapt(fHideSettlementScore, "HideSettlementScore", Game.C4S.Game.IsMelee()));
pComp->Value(mkNamingAdapt(sCustomEvaluationStrings, "CustomEvaluationStrings", StdCopyStrBuf())); pComp->Value(mkNamingAdapt(sCustomEvaluationStrings, "CustomEvaluationStrings", StdCopyStrBuf()));
pComp->Value(mkNamingAdapt(iLeaguePerformance, "LeaguePerformance", 0)); pComp->Value(mkNamingAdapt(iLeaguePerformance, "LeaguePerformance", 0));
pComp->Value(mkNamingAdapt(Players, "PlayerInfos", C4RoundResultsPlayers())); pComp->Value(mkNamingAdapt(Players, "PlayerInfos", C4RoundResultsPlayers()));
pComp->Value(mkNamingAdapt(sNetResult, "NetResult", StdCopyStrBuf())); pComp->Value(mkNamingAdapt(sNetResult, "NetResult", StdCopyStrBuf()));
StdEnumEntry<NetResult> NetResultEntries[] = StdEnumEntry<NetResult> NetResultEntries[] =
{ {
{ "", NR_None }, { "", NR_None },
{ "LeagueOK", NR_LeagueOK }, { "LeagueOK", NR_LeagueOK },
{ "LeagueError", NR_LeagueError}, { "LeagueError", NR_LeagueError},
{ "NetError", NR_NetError }, { "NetError", NR_NetError },
}; };
pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(eNetResult, NetResultEntries), "NetResult", NR_None)); pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(eNetResult, NetResultEntries), "NetResult", NR_None));
} }
@ -397,16 +397,16 @@ bool C4RoundResults::Save(C4Group &hGroup, const char *szFilename)
// remove previous entry from group // remove previous entry from group
hGroup.DeleteEntry(szFilename); hGroup.DeleteEntry(szFilename);
// decompile // decompile
try try
{ {
StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*this, "RoundResults")); StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*this, "RoundResults"));
// save it, if not empty // save it, if not empty
if (Buf.getLength()) if (Buf.getLength())
if (!hGroup.Add(szFilename, Buf, false, true)) if (!hGroup.Add(szFilename, Buf, false, true))
return false; return false;
} }
catch(StdCompiler::Exception *) catch(StdCompiler::Exception *)
{ return false; } { return false; }
// done, success // done, success
return true; return true;
} }
@ -415,9 +415,9 @@ bool C4RoundResults::Save(C4Group &hGroup, const char *szFilename)
// *** C4PacketLeagueRoundResults // *** C4PacketLeagueRoundResults
void C4PacketLeagueRoundResults::CompileFunc(StdCompiler *pComp) void C4PacketLeagueRoundResults::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(fSuccess, "Success", false)); pComp->Value(mkNamingAdapt(fSuccess, "Success", false));
pComp->Value(mkNamingAdapt(sResultsString, "ResultString", StdCopyStrBuf())); pComp->Value(mkNamingAdapt(sResultsString, "ResultString", StdCopyStrBuf()));
pComp->Value(Players); pComp->Value(Players);
} }

View File

@ -131,12 +131,12 @@ int32_t C4Team::GetFirstUnjoinedPlayerID() const
void C4Team::CompileFunc(StdCompiler *pComp) void C4Team::CompileFunc(StdCompiler *pComp)
{ {
if (pComp->isCompiler()) Clear(); if (pComp->isCompiler()) Clear();
pComp->Value(mkNamingAdapt(iID, "id", 0)); pComp->Value(mkNamingAdapt(iID, "id", 0));
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Name), "Name", "")); pComp->Value(mkNamingAdapt(mkStringAdaptMA(Name), "Name", ""));
pComp->Value(mkNamingAdapt(iPlrStartIndex, "PlrStartIndex", 0)); pComp->Value(mkNamingAdapt(iPlrStartIndex, "PlrStartIndex", 0));
pComp->Value(mkNamingAdapt(iPlayerCount, "PlayerCount", 0)); pComp->Value(mkNamingAdapt(iPlayerCount, "PlayerCount", 0));
if(pComp->isCompiler()) { delete [] piPlayers; piPlayers = new int32_t [iPlayerCapacity = iPlayerCount]; ZeroMem(piPlayers, sizeof(*piPlayers) * iPlayerCount); } if(pComp->isCompiler()) { delete [] piPlayers; piPlayers = new int32_t [iPlayerCapacity = iPlayerCount]; ZeroMem(piPlayers, sizeof(*piPlayers) * iPlayerCount); }
pComp->Value(mkNamingAdapt(mkArrayAdapt(piPlayers, iPlayerCount, -1), "Players")); pComp->Value(mkNamingAdapt(mkArrayAdapt(piPlayers, iPlayerCount, -1), "Players"));
pComp->Value(mkNamingAdapt(dwClr, "Color", 0u)); pComp->Value(mkNamingAdapt(dwClr, "Color", 0u));
pComp->Value(mkNamingAdapt(sIconSpec, "IconSpec", StdCopyStrBuf())); pComp->Value(mkNamingAdapt(sIconSpec, "IconSpec", StdCopyStrBuf()));
pComp->Value(mkNamingAdapt(iMaxPlayer, "MaxPlayer", 0)); pComp->Value(mkNamingAdapt(iMaxPlayer, "MaxPlayer", 0));
@ -542,12 +542,12 @@ bool C4TeamList::IsJoin2TeamAllowed(int32_t idTeam)
void C4TeamList::CompileFunc(StdCompiler *pComp) void C4TeamList::CompileFunc(StdCompiler *pComp)
{ {
// if (pComp->isCompiler()) Clear(); - do not clear, because this would corrupt the fCustom-flag // if (pComp->isCompiler()) Clear(); - do not clear, because this would corrupt the fCustom-flag
pComp->Value(mkNamingAdapt(fActive, "Active", true)); pComp->Value(mkNamingAdapt(fActive, "Active", true));
pComp->Value(mkNamingAdapt(fCustom, "Custom", true)); pComp->Value(mkNamingAdapt(fCustom, "Custom", true));
pComp->Value(mkNamingAdapt(fAllowHostilityChange, "AllowHostilityChange", false)); pComp->Value(mkNamingAdapt(fAllowHostilityChange, "AllowHostilityChange", false));
pComp->Value(mkNamingAdapt(fAllowTeamSwitch, "AllowTeamSwitch", false)); pComp->Value(mkNamingAdapt(fAllowTeamSwitch, "AllowTeamSwitch", false));
pComp->Value(mkNamingAdapt(fAutoGenerateTeams, "AutoGenerateTeams", false)); pComp->Value(mkNamingAdapt(fAutoGenerateTeams, "AutoGenerateTeams", false));
pComp->Value(mkNamingAdapt(iLastTeamID, "LastTeamID", 0)); pComp->Value(mkNamingAdapt(iLastTeamID, "LastTeamID", 0));
StdEnumEntry<TeamDist> TeamDistEntries[] = StdEnumEntry<TeamDist> TeamDistEntries[] =
{ {
@ -563,9 +563,9 @@ void C4TeamList::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(sScriptPlayerNames, "ScriptPlayerNames", StdStrBuf())); pComp->Value(mkNamingAdapt(sScriptPlayerNames, "ScriptPlayerNames", StdStrBuf()));
int32_t iOldTeamCount = iTeamCount; int32_t iOldTeamCount = iTeamCount;
pComp->Value(mkNamingCountAdapt(iTeamCount, "Team")); pComp->Value(mkNamingCountAdapt(iTeamCount, "Team"));
if (pComp->isCompiler()) if (pComp->isCompiler())
{ {
while (iOldTeamCount--) delete ppList[iOldTeamCount]; while (iOldTeamCount--) delete ppList[iOldTeamCount];
delete [] ppList; delete [] ppList;
@ -646,14 +646,14 @@ bool C4TeamList::Save(C4Group &hGroup)
// remove previous entry from group // remove previous entry from group
hGroup.DeleteEntry(C4CFN_Teams); hGroup.DeleteEntry(C4CFN_Teams);
// decompile // decompile
try try
{ {
StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*this, "Teams")); StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*this, "Teams"));
// save it // save it
hGroup.Add(C4CFN_Teams, Buf, false, true); hGroup.Add(C4CFN_Teams, Buf, false, true);
} }
catch(StdCompiler::Exception *) catch(StdCompiler::Exception *)
{ return false; } { return false; }
// done, success // done, success
return true; return true;
} }

View File

@ -102,8 +102,8 @@ namespace {
#endif #endif
#define FILE_SELECT_FILTER_FOR_C4S "Clonk 4 Scenario\0" \ #define FILE_SELECT_FILTER_FOR_C4S "Clonk 4 Scenario\0" \
"*.c4s;*.c4f;Scenario.txt\0" \ "*.c4s;*.c4f;Scenario.txt\0" \
"\0" "\0"
C4Console::C4Console() C4Console::C4Console()
{ {
@ -161,30 +161,30 @@ INT_PTR CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPara
{ {
switch (Msg) switch (Msg)
{ {
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
case WM_ACTIVATEAPP: case WM_ACTIVATEAPP:
Application.Active = wParam != 0; Application.Active = wParam != 0;
return true; return true;
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
case WM_DESTROY: case WM_DESTROY:
StoreWindowPosition(hDlg, "Main", Config.GetSubkeyPath("Console"), false); StoreWindowPosition(hDlg, "Main", Config.GetSubkeyPath("Console"), false);
Application.Quit(); Application.Quit();
return true; return true;
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
case WM_CLOSE: case WM_CLOSE:
Console.Close(); Console.Close();
return true; return true;
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
case MM_MCINOTIFY: case MM_MCINOTIFY:
if (wParam == MCI_NOTIFY_SUCCESSFUL) if (wParam == MCI_NOTIFY_SUCCESSFUL)
Application.MusicSystem.NotifySuccess(); Application.MusicSystem.NotifySuccess();
return true; return true;
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
case WM_INITDIALOG: case WM_INITDIALOG:
SendMessage(hDlg,DM_SETDEFID,(WPARAM)IDOK,(LPARAM)0); SendMessage(hDlg,DM_SETDEFID,(WPARAM)IDOK,(LPARAM)0);
Console.UpdateMenuText(GetMenu(hDlg)); Console.UpdateMenuText(GetMenu(hDlg));
return true; return true;
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
case WM_COMMAND: case WM_COMMAND:
// Evaluate command // Evaluate command
switch (LOWORD(wParam)) switch (LOWORD(wParam))
@ -269,25 +269,25 @@ INT_PTR CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPara
return true; return true;
} }
return false; return false;
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
case WM_USER_LOG: case WM_USER_LOG:
if (SEqual2((const char *)lParam, "IDS_")) if (SEqual2((const char *)lParam, "IDS_"))
Log(LoadResStr((const char *)lParam)); Log(LoadResStr((const char *)lParam));
else else
Log((const char *)lParam); Log((const char *)lParam);
return false; return false;
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
case WM_COPYDATA: case WM_COPYDATA:
COPYDATASTRUCT* pcds = reinterpret_cast<COPYDATASTRUCT *>(lParam); COPYDATASTRUCT* pcds = reinterpret_cast<COPYDATASTRUCT *>(lParam);
if(pcds->dwData == WM_USER_RELOADFILE) if(pcds->dwData == WM_USER_RELOADFILE)
{ {
// get path, ensure proper termination // get path, ensure proper termination
const char *szPath = reinterpret_cast<const char *>(pcds->lpData); const char *szPath = reinterpret_cast<const char *>(pcds->lpData);
if(szPath[pcds->cbData - 1]) break; if(szPath[pcds->cbData - 1]) break;
// reload // reload
Game.ReloadFile(szPath); Game.ReloadFile(szPath);
} }
return false; return false;
} }
return false; return false;
@ -1331,7 +1331,7 @@ void C4Console::EditScript()
{ {
if (::Network.isEnabled()) return; if (::Network.isEnabled()) return;
Game.Script.Open(); Game.Script.Open();
::ScriptEngine.ReLink(&::Definitions); ::ScriptEngine.ReLink(&::Definitions);
} }
void C4Console::EditInfo() void C4Console::EditInfo()

View File

@ -36,8 +36,8 @@
#endif #endif
const int C4CNS_ModePlay = 0, const int C4CNS_ModePlay = 0,
C4CNS_ModeEdit = 1, C4CNS_ModeEdit = 1,
C4CNS_ModeDraw = 2; C4CNS_ModeDraw = 2;
#define IDM_NET_CLIENT1 10000 #define IDM_NET_CLIENT1 10000
#define IDM_NET_CLIENT2 10100 #define IDM_NET_CLIENT2 10100

View File

@ -64,23 +64,23 @@ C4EditCursor::~C4EditCursor()
void C4EditCursor::Execute() void C4EditCursor::Execute()
{ {
// alt check // alt check
bool fAltIsDown = Application.IsAltDown(); bool fAltIsDown = Application.IsAltDown();
if (fAltIsDown != fAltWasDown) if (fAltIsDown != fAltWasDown)
{ {
if ((fAltWasDown = fAltIsDown)) if ((fAltWasDown = fAltIsDown))
AltDown(); AltDown();
else else
AltUp(); AltUp();
} }
// drawing // drawing
switch (Mode) switch (Mode)
{ {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case C4CNS_ModeEdit: case C4CNS_ModeEdit:
// Hold selection // Hold selection
if (Hold) if (Hold)
EMMoveObject(EMMO_Move, 0, 0, NULL, &Selection); EMMoveObject(EMMO_Move, 0, 0, NULL, &Selection);
break; break;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case C4CNS_ModeDraw: case C4CNS_ModeDraw:
@ -398,8 +398,8 @@ bool C4EditCursor::OpenPropTools()
bool C4EditCursor::Duplicate() bool C4EditCursor::Duplicate()
{ {
EMMoveObject(EMMO_Duplicate, 0, 0, NULL, &Selection); EMMoveObject(EMMO_Duplicate, 0, 0, NULL, &Selection);
return true; return true;
} }
void C4EditCursor::Draw(C4TargetFacet &cgo, float Zoom) void C4EditCursor::Draw(C4TargetFacet &cgo, float Zoom)
@ -476,13 +476,13 @@ void C4EditCursor::DrawSelectMark(C4Facet &cgo, FLOAT_RECT frame)
void C4EditCursor::MoveSelection(int32_t iXOff, int32_t iYOff) void C4EditCursor::MoveSelection(int32_t iXOff, int32_t iYOff)
{ {
EMMoveObject(EMMO_Move, iXOff, iYOff, NULL, &Selection); EMMoveObject(EMMO_Move, iXOff, iYOff, NULL, &Selection);
} }
void C4EditCursor::FrameSelection() void C4EditCursor::FrameSelection()
{ {
Selection.Clear(); Selection.Clear();
C4Object *cobj; C4ObjectLink *clnk; C4Object *cobj; C4ObjectLink *clnk;
for (clnk=::Objects.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next) for (clnk=::Objects.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
if (cobj->Status) if (cobj->OCF & OCF_NotContained) if (cobj->Status) if (cobj->OCF & OCF_NotContained)
{ {
@ -494,13 +494,13 @@ void C4EditCursor::FrameSelection()
bool C4EditCursor::In(const char *szText) bool C4EditCursor::In(const char *szText)
{ {
EMMoveObject(EMMO_Script, 0, 0, NULL, &Selection, szText); EMMoveObject(EMMO_Script, 0, 0, NULL, &Selection, szText);
return true; return true;
} }
void C4EditCursor::Default() void C4EditCursor::Default()
{ {
fAltWasDown=false; fAltWasDown=false;
Mode=C4CNS_ModePlay; Mode=C4CNS_ModePlay;
X=Y=X2=Y2=0; X=Y=X2=Y2=0;
Target=DropTarget=NULL; Target=DropTarget=NULL;
@ -587,7 +587,7 @@ void C4EditCursor::ApplyToolBrush()
{ {
if (!EditingOK()) return; if (!EditingOK()) return;
C4ToolsDlg *pTools=&Console.ToolsDlg; C4ToolsDlg *pTools=&Console.ToolsDlg;
// execute/send control // execute/send control
EMControl(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_Brush, ::Landscape.Mode, X,Y,0,0, pTools->Grade, !!pTools->ModeIFT, pTools->Material,pTools->Texture)); EMControl(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_Brush, ::Landscape.Mode, X,Y,0,0, pTools->Grade, !!pTools->ModeIFT, pTools->Material,pTools->Texture));
} }
@ -595,7 +595,7 @@ void C4EditCursor::ApplyToolLine()
{ {
if (!EditingOK()) return; if (!EditingOK()) return;
C4ToolsDlg *pTools=&Console.ToolsDlg; C4ToolsDlg *pTools=&Console.ToolsDlg;
// execute/send control // execute/send control
EMControl(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_Line, ::Landscape.Mode, X,Y,X2,Y2, pTools->Grade, !!pTools->ModeIFT, pTools->Material,pTools->Texture)); EMControl(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_Line, ::Landscape.Mode, X,Y,X2,Y2, pTools->Grade, !!pTools->ModeIFT, pTools->Material,pTools->Texture));
} }
@ -603,7 +603,7 @@ void C4EditCursor::ApplyToolRect()
{ {
if (!EditingOK()) return; if (!EditingOK()) return;
C4ToolsDlg *pTools=&Console.ToolsDlg; C4ToolsDlg *pTools=&Console.ToolsDlg;
// execute/send control // execute/send control
EMControl(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_Rect, ::Landscape.Mode, X,Y,X2,Y2, pTools->Grade, !!pTools->ModeIFT, pTools->Material,pTools->Texture)); EMControl(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_Rect, ::Landscape.Mode, X,Y,X2,Y2, pTools->Grade, !!pTools->ModeIFT, pTools->Material,pTools->Texture));
} }
@ -611,7 +611,7 @@ void C4EditCursor::ApplyToolFill()
{ {
if (!EditingOK()) return; if (!EditingOK()) return;
C4ToolsDlg *pTools=&Console.ToolsDlg; C4ToolsDlg *pTools=&Console.ToolsDlg;
// execute/send control // execute/send control
EMControl(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_Fill, ::Landscape.Mode, X,Y,0,Y2, pTools->Grade, false, pTools->Material)); EMControl(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_Fill, ::Landscape.Mode, X,Y,0,Y2, pTools->Grade, false, pTools->Material));
} }
@ -668,12 +668,12 @@ void C4EditCursor::GrabContents()
Hold=true; Hold=true;
// Exit all objects // Exit all objects
EMMoveObject(EMMO_Exit, 0, 0, NULL, &Selection); EMMoveObject(EMMO_Exit, 0, 0, NULL, &Selection);
} }
void C4EditCursor::UpdateDropTarget(WORD wKeyFlags) void C4EditCursor::UpdateDropTarget(WORD wKeyFlags)
{ {
C4Object *cobj; C4ObjectLink *clnk; C4Object *cobj; C4ObjectLink *clnk;
DropTarget=NULL; DropTarget=NULL;
@ -692,7 +692,7 @@ void C4EditCursor::UpdateDropTarget(WORD wKeyFlags)
void C4EditCursor::PutContents() void C4EditCursor::PutContents()
{ {
if (!DropTarget) return; if (!DropTarget) return;
EMMoveObject(EMMO_Enter, 0, 0, DropTarget, &Selection); EMMoveObject(EMMO_Enter, 0, 0, DropTarget, &Selection);
} }
C4Object *C4EditCursor::GetTarget() C4Object *C4EditCursor::GetTarget()
@ -759,69 +759,69 @@ void C4EditCursor::ApplyToolPicker()
} }
void C4EditCursor::EMMoveObject(C4ControlEMObjectAction eAction, int32_t tx, int32_t ty, C4Object *pTargetObj, const C4ObjectList *pObjs, const char *szScript) void C4EditCursor::EMMoveObject(C4ControlEMObjectAction eAction, int32_t tx, int32_t ty, C4Object *pTargetObj, const C4ObjectList *pObjs, const char *szScript)
{ {
// construct object list // construct object list
int32_t iObjCnt = 0; int32_t *pObjIDs = NULL; int32_t iObjCnt = 0; int32_t *pObjIDs = NULL;
if(pObjs && (iObjCnt = pObjs->ObjectCount())) if(pObjs && (iObjCnt = pObjs->ObjectCount()))
{ {
pObjIDs = new int32_t [iObjCnt]; pObjIDs = new int32_t [iObjCnt];
// fill // fill
int32_t i = 0; int32_t i = 0;
for(C4ObjectLink *pLnk = pObjs->First; pLnk; pLnk = pLnk->Next, i++) for(C4ObjectLink *pLnk = pObjs->First; pLnk; pLnk = pLnk->Next, i++)
if(pLnk->Obj && pLnk->Obj->Status) if(pLnk->Obj && pLnk->Obj->Status)
pObjIDs[i] = pLnk->Obj->Number; pObjIDs[i] = pLnk->Obj->Number;
} }
// execute control // execute control
EMControl(CID_EMMoveObj, new C4ControlEMMoveObject(eAction, tx, ty, pTargetObj, iObjCnt, pObjIDs, szScript)); EMControl(CID_EMMoveObj, new C4ControlEMMoveObject(eAction, tx, ty, pTargetObj, iObjCnt, pObjIDs, szScript));
} }
void C4EditCursor::EMControl(C4PacketType eCtrlType, C4ControlPacket *pCtrl) void C4EditCursor::EMControl(C4PacketType eCtrlType, C4ControlPacket *pCtrl)
{ {
::Control.DoInput(eCtrlType, pCtrl, CDT_Decide); ::Control.DoInput(eCtrlType, pCtrl, CDT_Decide);
} }
#ifdef WITH_DEVELOPER_MODE #ifdef WITH_DEVELOPER_MODE
// GTK+ callbacks // GTK+ callbacks
void C4EditCursor::OnDelete(GtkWidget* widget, gpointer data) void C4EditCursor::OnDelete(GtkWidget* widget, gpointer data)
{ {
static_cast<C4EditCursor*>(data)->Delete(); static_cast<C4EditCursor*>(data)->Delete();
} }
void C4EditCursor::OnDuplicate(GtkWidget* widget, gpointer data) void C4EditCursor::OnDuplicate(GtkWidget* widget, gpointer data)
{ {
static_cast<C4EditCursor*>(data)->Duplicate(); static_cast<C4EditCursor*>(data)->Duplicate();
} }
void C4EditCursor::OnGrabContents(GtkWidget* widget, gpointer data) void C4EditCursor::OnGrabContents(GtkWidget* widget, gpointer data)
{ {
static_cast<C4EditCursor*>(data)->GrabContents(); static_cast<C4EditCursor*>(data)->GrabContents();
} }
void C4EditCursor::OnProperties(GtkWidget* widget, gpointer data) void C4EditCursor::OnProperties(GtkWidget* widget, gpointer data)
{ {
static_cast<C4EditCursor*>(data)->OpenPropTools(); static_cast<C4EditCursor*>(data)->OpenPropTools();
} }
#endif #endif
bool C4EditCursor::AltDown() bool C4EditCursor::AltDown()
{ {
// alt only has an effect in draw mode (picker) // alt only has an effect in draw mode (picker)
if (Mode == C4CNS_ModeDraw) if (Mode == C4CNS_ModeDraw)
{ {
Console.ToolsDlg.SetAlternateTool(); Console.ToolsDlg.SetAlternateTool();
} }
// key not processed - allow further usages of Alt // key not processed - allow further usages of Alt
return false; return false;
} }
bool C4EditCursor::AltUp() bool C4EditCursor::AltUp()
{ {
if (Mode == C4CNS_ModeDraw) if (Mode == C4CNS_ModeDraw)
{ {
Console.ToolsDlg.ResetAlternateTool(); Console.ToolsDlg.ResetAlternateTool();
} }
// key not processed - allow further usages of Alt // key not processed - allow further usages of Alt
return false; return false;
} }

View File

@ -36,7 +36,7 @@ class C4EditCursor
C4EditCursor(); C4EditCursor();
~C4EditCursor(); ~C4EditCursor();
protected: protected:
bool fAltWasDown; bool fAltWasDown;
bool fSelectionChanged; bool fSelectionChanged;
int32_t Mode; int32_t Mode;
int32_t X,Y,X2,Y2; int32_t X,Y,X2,Y2;
@ -79,8 +79,8 @@ class C4EditCursor
C4ObjectList &GetSelection() { return Selection; } C4ObjectList &GetSelection() { return Selection; }
void SetHold(bool fToState) { Hold = fToState; } void SetHold(bool fToState) { Hold = fToState; }
void OnSelectionChanged(); void OnSelectionChanged();
bool AltDown(); bool AltDown();
bool AltUp(); bool AltUp();
protected: protected:
bool UpdateStatusBar(); bool UpdateStatusBar();
void ApplyToolPicker(); void ApplyToolPicker();
@ -96,8 +96,8 @@ class C4EditCursor
void DrawSelectMark(C4Facet &cgo, FLOAT_RECT r); void DrawSelectMark(C4Facet &cgo, FLOAT_RECT r);
void FrameSelection(); void FrameSelection();
void MoveSelection(int32_t iXOff, int32_t iYOff); void MoveSelection(int32_t iXOff, int32_t iYOff);
void EMMoveObject(enum C4ControlEMObjectAction eAction, int32_t tx, int32_t ty, C4Object *pTargetObj, const C4ObjectList *pObjs = NULL, const char *szScript = NULL); void EMMoveObject(enum C4ControlEMObjectAction eAction, int32_t tx, int32_t ty, C4Object *pTargetObj, const C4ObjectList *pObjs = NULL, const char *szScript = NULL);
void EMControl(enum C4PacketType eCtrlType, class C4ControlPacket *pCtrl); void EMControl(enum C4PacketType eCtrlType, class C4ControlPacket *pCtrl);
#ifdef WITH_DEVELOPER_MODE #ifdef WITH_DEVELOPER_MODE
static void OnDelete(GtkWidget* widget, gpointer data); static void OnDelete(GtkWidget* widget, gpointer data);

View File

@ -253,7 +253,7 @@ c4_list_iter_children (GtkTreeModel * tree_model, GtkTreeIter * iter, GtkTreeIte
// Return true if 'parent' has children. // Return true if 'parent' has children.
static gboolean static gboolean
c4_list_iter_has_child (GtkTreeModel *tree_model, c4_list_iter_has_child (GtkTreeModel *tree_model,
GtkTreeIter *parent) GtkTreeIter *parent)
{ {
g_return_val_if_fail (parent == NULL || parent->user_data != NULL, false); g_return_val_if_fail (parent == NULL || parent->user_data != NULL, false);
g_return_val_if_fail (C4_IS_LIST (tree_model), false); g_return_val_if_fail (C4_IS_LIST (tree_model), false);

View File

@ -64,7 +64,7 @@ BOOL CALLBACK PropertyDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
break; break;
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
case WM_INITDIALOG: case WM_INITDIALOG:
SendMessage(hDlg,DM_SETDEFID,(WPARAM)IDOK,(LPARAM)0); SendMessage(hDlg,DM_SETDEFID,(WPARAM)IDOK,(LPARAM)0);
return true; return true;
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
case WM_COMMAND: case WM_COMMAND:
@ -86,7 +86,7 @@ BOOL CALLBACK PropertyDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
} }
return false; return false;
//----------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------
} }
return false; return false;
} }
@ -178,7 +178,7 @@ bool C4PropertyDlg::Update(C4ObjectList &rSelection)
bool IsObjectPointer(int iValue) bool IsObjectPointer(int iValue)
{ {
for (C4ObjectLink *cLnk=::Objects.First; cLnk; cLnk=cLnk->Next) for (C4ObjectLink *cLnk=::Objects.First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj == (C4Object*) iValue) if (cLnk->Obj == (C4Object*) iValue)
return true; return true;
return false; return false;

View File

@ -457,7 +457,7 @@ void C4ToolsDlg::Clear()
bool C4ToolsDlg::SetTool(int32_t iTool, bool fTemp) bool C4ToolsDlg::SetTool(int32_t iTool, bool fTemp)
{ {
Tool=iTool; Tool=iTool;
if (!fTemp) SelectedTool = Tool; if (!fTemp) SelectedTool = Tool;
UpdateToolCtrls(); UpdateToolCtrls();
UpdatePreview(); UpdatePreview();
return true; return true;
@ -680,7 +680,7 @@ void C4ToolsDlg::UpdatePreview()
// Material-Texture // Material-Texture
else else
{ {
bCol=Mat2PixColDefault(::MaterialMap.Get(Material)); bCol=Mat2PixColDefault(::MaterialMap.Get(Material));
// Get/Create TexMap entry // Get/Create TexMap entry
BYTE iTex = ::TextureMap.GetIndex(Material, Texture, true); BYTE iTex = ::TextureMap.GetIndex(Material, Texture, true);
if (iTex) if (iTex)
@ -755,11 +755,11 @@ void C4ToolsDlg::InitGradeCtrl()
#ifdef _WIN32 #ifdef _WIN32
if (!hDialog) return; if (!hDialog) return;
HWND hwndTrack = GetDlgItem(hDialog,IDC_SLIDERGRADE); HWND hwndTrack = GetDlgItem(hDialog,IDC_SLIDERGRADE);
SendMessage(hwndTrack,TBM_SETPAGESIZE,0,(LPARAM)5); SendMessage(hwndTrack,TBM_SETPAGESIZE,0,(LPARAM)5);
SendMessage(hwndTrack,TBM_SETLINESIZE,0,(LPARAM)1); SendMessage(hwndTrack,TBM_SETLINESIZE,0,(LPARAM)1);
SendMessage(hwndTrack,TBM_SETRANGE,(WPARAM)false, SendMessage(hwndTrack,TBM_SETRANGE,(WPARAM)false,
(LPARAM) MAKELONG(C4TLS_GradeMin,C4TLS_GradeMax)); (LPARAM) MAKELONG(C4TLS_GradeMin,C4TLS_GradeMax));
SendMessage(hwndTrack,TBM_SETPOS,(WPARAM)true,(LPARAM)C4TLS_GradeMax-Grade); SendMessage(hwndTrack,TBM_SETPOS,(WPARAM)true,(LPARAM)C4TLS_GradeMax-Grade);
UpdateWindow(hwndTrack); UpdateWindow(hwndTrack);
#else #else
#ifdef WITH_DEVELOPER_MODE #ifdef WITH_DEVELOPER_MODE
@ -1034,16 +1034,16 @@ bool C4ToolsDlg::SelectMaterial(const char *szMaterial)
} }
void C4ToolsDlg::SetAlternateTool() void C4ToolsDlg::SetAlternateTool()
{ {
// alternate tool is the picker in any mode // alternate tool is the picker in any mode
SetTool(C4TLS_Picker, true); SetTool(C4TLS_Picker, true);
} }
void C4ToolsDlg::ResetAlternateTool() void C4ToolsDlg::ResetAlternateTool()
{ {
// reset tool to selected tool in case alternate tool was set // reset tool to selected tool in case alternate tool was set
SetTool(SelectedTool, true); SetTool(SelectedTool, true);
} }
#ifdef WITH_DEVELOPER_MODE #ifdef WITH_DEVELOPER_MODE
// GTK+ callbacks // GTK+ callbacks

View File

@ -150,8 +150,8 @@ class C4ToolsDlg
bool ToggleIFT() { return !!SetIFT(!ModeIFT); } bool ToggleIFT() { return !!SetIFT(!ModeIFT); }
bool SelectTexture(const char *szTexture); bool SelectTexture(const char *szTexture);
bool SelectMaterial(const char *szMaterial); bool SelectMaterial(const char *szMaterial);
void SetAlternateTool(); void SetAlternateTool();
void ResetAlternateTool(); void ResetAlternateTool();
protected: protected:
void AssertValidTexture(); void AssertValidTexture();
void LoadBitmaps(); void LoadBitmaps();

View File

@ -54,13 +54,13 @@ struct C4GameVersion
// helper // helper
inline int CompareVersion(int iVer1, int iVer2, int iVer3, int iVer4, inline int CompareVersion(int iVer1, int iVer2, int iVer3, int iVer4,
int iRVer1 = C4XVER1, int iRVer2 = C4XVER2, int iRVer3 = C4XVER3, int iRVer4 = C4XVER4) int iRVer1 = C4XVER1, int iRVer2 = C4XVER2, int iRVer3 = C4XVER3, int iRVer4 = C4XVER4)
{ {
if(iVer1 > iRVer1) return 1; if(iVer1 < iRVer1) return -1; if(iVer1 > iRVer1) return 1; if(iVer1 < iRVer1) return -1;
if(iVer2 > iRVer2) return 1; if(iVer2 < iRVer2) return -1; if(iVer2 > iRVer2) return 1; if(iVer2 < iRVer2) return -1;
if(iVer3 > iRVer3) return 1; if(iVer3 < iRVer3) return -1; if(iVer3 > iRVer3) return 1; if(iVer3 < iRVer3) return -1;
if(iVer4 > iRVer4) return 1; if(iVer4 < iRVer4) return -1; if(iVer4 > iRVer4) return 1; if(iVer4 < iRVer4) return -1;
return 0; return 0;
} }
#endif // C4GAMEVERSION_H #endif // C4GAMEVERSION_H

File diff suppressed because it is too large Load Diff

View File

@ -31,8 +31,8 @@
#include <C4Material.h> #include <C4Material.h>
const uint8_t GBM = 128, const uint8_t GBM = 128,
GBM_ColNum = 64, GBM_ColNum = 64,
IFT = 0x80, IFT = 0x80,
IFTOld = GBM_ColNum; IFTOld = GBM_ColNum;
const uint8_t CSkyDef1=104,CSkyDef2=123; const uint8_t CSkyDef1=104,CSkyDef2=123;
@ -40,7 +40,7 @@ const uint8_t CSkyDef1=104,CSkyDef2=123;
const int32_t C4MaxMaterial = 125; const int32_t C4MaxMaterial = 125;
const int32_t C4LSC_Undefined = 0, const int32_t C4LSC_Undefined = 0,
C4LSC_Dynamic = 1, C4LSC_Dynamic = 1,
C4LSC_Static = 2, C4LSC_Static = 2,
C4LSC_Exact = 3; C4LSC_Exact = 3;
@ -51,29 +51,29 @@ class C4Object;
class C4PropList; class C4PropList;
class C4Landscape class C4Landscape
{ {
public: public:
C4Landscape(); C4Landscape();
~C4Landscape(); ~C4Landscape();
public: public:
int32_t Mode; int32_t Mode;
int32_t Width,Height; int32_t Width,Height;
int32_t MapWidth,MapHeight,MapZoom; int32_t MapWidth,MapHeight,MapZoom;
CSurface8 * Map; CSurface8 * Map;
DWORD MatCount[C4MaxMaterial]; // NoSave // DWORD MatCount[C4MaxMaterial]; // NoSave //
DWORD EffectiveMatCount[C4MaxMaterial]; // NoSave // DWORD EffectiveMatCount[C4MaxMaterial]; // NoSave //
uint8_t *BridgeMatConversion[C4MaxMaterial]; // NoSave // uint8_t *BridgeMatConversion[C4MaxMaterial]; // NoSave //
int32_t BlastMatCount[C4MaxMaterial]; // SyncClearance-NoSave // int32_t BlastMatCount[C4MaxMaterial]; // SyncClearance-NoSave //
bool NoScan; // ExecuteScan() disabled bool NoScan; // ExecuteScan() disabled
int32_t ScanX,ScanSpeed; // SyncClearance-NoSave // int32_t ScanX,ScanSpeed; // SyncClearance-NoSave //
int32_t LeftOpen,RightOpen,TopOpen,BottomOpen; int32_t LeftOpen,RightOpen,TopOpen,BottomOpen;
FIXED Gravity; FIXED Gravity;
uint32_t Modulation; // landscape blit modulation; 0 means normal uint32_t Modulation; // landscape blit modulation; 0 means normal
int32_t MapSeed; // random seed for MapToLandscape int32_t MapSeed; // random seed for MapToLandscape
C4Sky Sky; C4Sky Sky;
C4MapCreatorS2 *pMapCreator; // map creator for script-generated maps C4MapCreatorS2 *pMapCreator; // map creator for script-generated maps
bool fMapChanged; bool fMapChanged;
BYTE *pInitial; // Initial landscape after creation - used for diff BYTE *pInitial; // Initial landscape after creation - used for diff
protected: protected:
CSurface * Surface32; CSurface * Surface32;
CSurface8 * Surface8; CSurface8 * Surface8;
@ -84,15 +84,15 @@ class C4Landscape
public: public:
void Default(); void Default();
void Clear(bool fClearMapCreator=true, bool fClearSky=true); void Clear(bool fClearMapCreator=true, bool fClearSky=true);
void Execute(); void Execute();
void Synchronize(); void Synchronize();
void Draw(C4TargetFacet &cgo, int32_t iPlayer=-1); void Draw(C4TargetFacet &cgo, int32_t iPlayer=-1);
void ScenarioInit(); void ScenarioInit();
void ClearRect(int32_t iTx, int32_t iTy, int32_t iWdt, int32_t iHgt); void ClearRect(int32_t iTx, int32_t iTy, int32_t iWdt, int32_t iHgt);
void ClearRectDensity(int32_t iTx, int32_t iTy, int32_t iWdt, int32_t iHgt, int32_t iOfDensity); void ClearRectDensity(int32_t iTx, int32_t iTy, int32_t iWdt, int32_t iHgt, int32_t iOfDensity);
void ClearMatCount(); void ClearMatCount();
void ClearBlastMatCount(); void ClearBlastMatCount();
void ScanSideOpen(); void ScanSideOpen();
void CheckInstabilityRange(int32_t tx, int32_t ty); void CheckInstabilityRange(int32_t tx, int32_t ty);
void ShakeFree(int32_t tx, int32_t ty, int32_t rad); void ShakeFree(int32_t tx, int32_t ty, int32_t rad);
void DigFree(int32_t tx, int32_t ty, int32_t rad, bool fRequest=false, C4Object *pByObj=NULL); void DigFree(int32_t tx, int32_t ty, int32_t rad, bool fRequest=false, C4Object *pByObj=NULL);
@ -107,7 +107,7 @@ class C4Landscape
bool Save(C4Group &hGroup); bool Save(C4Group &hGroup);
bool SaveDiff(C4Group &hGroup, bool fSyncSave); bool SaveDiff(C4Group &hGroup, bool fSyncSave);
bool SaveMap(C4Group &hGroup); bool SaveMap(C4Group &hGroup);
bool SaveInitial(); bool SaveInitial();
bool SaveTextures(C4Group &hGroup); bool SaveTextures(C4Group &hGroup);
bool Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bool &rfLoaded, bool fSavegame); bool Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bool &rfLoaded, bool fSavegame);
bool MapToLandscape(); bool MapToLandscape();
@ -192,7 +192,7 @@ class C4Landscape
inline int32_t GetPixMat(BYTE byPix) { return Pix2Mat[byPix]; } inline int32_t GetPixMat(BYTE byPix) { return Pix2Mat[byPix]; }
inline int32_t GetPixDensity(BYTE byPix) { return Pix2Dens[byPix]; } inline int32_t GetPixDensity(BYTE byPix) { return Pix2Dens[byPix]; }
bool _PathFree(int32_t x, int32_t y, int32_t x2, int32_t y2); // quickly checks wether there *might* be pixel in the path. bool _PathFree(int32_t x, int32_t y, int32_t x2, int32_t y2); // quickly checks wether there *might* be pixel in the path.
int32_t GetMatHeight(int32_t x, int32_t y, int32_t iYDir, int32_t iMat, int32_t iMax); int32_t GetMatHeight(int32_t x, int32_t y, int32_t iYDir, int32_t iMat, int32_t iMax);
int32_t DigFreePix(int32_t tx, int32_t ty); int32_t DigFreePix(int32_t tx, int32_t ty);
int32_t ShakeFreePix(int32_t tx, int32_t ty); int32_t ShakeFreePix(int32_t tx, int32_t ty);
int32_t BlastFreePix(int32_t tx, int32_t ty, int32_t grade, int32_t iBlastSize); int32_t BlastFreePix(int32_t tx, int32_t ty, int32_t grade, int32_t iBlastSize);
@ -211,10 +211,10 @@ class C4Landscape
void SetMapChanged() { fMapChanged = true; } void SetMapChanged() { fMapChanged = true; }
void HandleTexMapUpdate(); void HandleTexMapUpdate();
void UpdatePixMaps(); void UpdatePixMaps();
bool DoRelights(); bool DoRelights();
void RemoveUnusedTexMapEntries(); void RemoveUnusedTexMapEntries();
protected: protected:
void ExecuteScan(); void ExecuteScan();
int32_t DoScan(int32_t x, int32_t y, int32_t mat, int32_t dir); int32_t DoScan(int32_t x, int32_t y, int32_t mat, int32_t dir);
int32_t ChunkyRandom(int32_t &iOffset, int32_t iRange); // return static random value, according to offset and MapSeed int32_t ChunkyRandom(int32_t &iOffset, int32_t iRange); // return static random value, according to offset and MapSeed
void DrawChunk(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t mcol, int32_t iChunkType, int32_t cro); void DrawChunk(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t mcol, int32_t iChunkType, int32_t cro);
@ -232,21 +232,21 @@ class C4Landscape
bool ApplyLighting(C4Rect To); bool ApplyLighting(C4Rect To);
DWORD GetClrByTex(int32_t iX, int32_t iY); DWORD GetClrByTex(int32_t iX, int32_t iY);
bool Mat2Pal(); // assign material colors to landscape palette bool Mat2Pal(); // assign material colors to landscape palette
void DigFreeSinglePix(int32_t x, int32_t y, int32_t dx, int32_t dy) void DigFreeSinglePix(int32_t x, int32_t y, int32_t dx, int32_t dy)
{ {
if(GetDensity(x, y) > GetDensity(x + dx, y + dy)) if(GetDensity(x, y) > GetDensity(x + dx, y + dy))
DigFreePix(x, y); DigFreePix(x, y);
} }
void UpdatePixCnt(const class C4Rect &Rect, bool fCheck = false); void UpdatePixCnt(const class C4Rect &Rect, bool fCheck = false);
void UpdateMatCnt(C4Rect Rect, bool fPlus); void UpdateMatCnt(C4Rect Rect, bool fPlus);
void PrepareChange(C4Rect BoundingBox); void PrepareChange(C4Rect BoundingBox);
void FinishChange(C4Rect BoundingBox); void FinishChange(C4Rect BoundingBox);
static bool DrawLineLandscape(int32_t iX, int32_t iY, int32_t iGrade); static bool DrawLineLandscape(int32_t iX, int32_t iY, int32_t iGrade);
uint8_t *GetBridgeMatConversion(int for_material); uint8_t *GetBridgeMatConversion(int for_material);
public: public:
void CompileFunc(StdCompiler *pComp); // without landscape bitmaps and sky void CompileFunc(StdCompiler *pComp); // without landscape bitmaps and sky
bool DebugSave(const char *szFilename); bool DebugSave(const char *szFilename);
}; };
extern C4Landscape Landscape; extern C4Landscape Landscape;
@ -277,31 +277,31 @@ int32_t PixCol2Mat(BYTE pixc);
#define _SBackPixIfMask ::Landscape._SetPixIfMask #define _SBackPixIfMask ::Landscape._SetPixIfMask
inline bool DensitySolid(int32_t dens) inline bool DensitySolid(int32_t dens)
{ {
return (dens>=C4M_Solid); return (dens>=C4M_Solid);
} }
inline bool DensitySemiSolid(int32_t dens) inline bool DensitySemiSolid(int32_t dens)
{ {
return (dens>=C4M_SemiSolid); return (dens>=C4M_SemiSolid);
} }
inline bool DensityLiquid(int32_t dens) inline bool DensityLiquid(int32_t dens)
{ {
return ((dens>=C4M_Liquid) && (dens<C4M_Solid)); return ((dens>=C4M_Liquid) && (dens<C4M_Solid));
} }
inline BYTE PixColIFT(BYTE pixc) inline BYTE PixColIFT(BYTE pixc)
{ {
return pixc & IFT; return pixc & IFT;
} }
// always use OldGfx-version (used for convert) // always use OldGfx-version (used for convert)
inline BYTE PixColIFTOld(BYTE pixc) inline BYTE PixColIFTOld(BYTE pixc)
{ {
if (pixc>=GBM+IFTOld) return IFTOld; if (pixc>=GBM+IFTOld) return IFTOld;
return 0; return 0;
} }
inline int32_t PixCol2Tex(BYTE pixc) inline int32_t PixCol2Tex(BYTE pixc)
{ {
@ -314,32 +314,32 @@ inline int32_t PixCol2Tex(BYTE pixc)
} }
inline BYTE GBackIFT(int32_t x, int32_t y) inline BYTE GBackIFT(int32_t x, int32_t y)
{ {
return PixColIFT(GBackPix(x,y)); return PixColIFT(GBackPix(x,y));
} }
inline int32_t GBackMat(int32_t x, int32_t y) inline int32_t GBackMat(int32_t x, int32_t y)
{ {
return ::Landscape.GetMat(x, y); return ::Landscape.GetMat(x, y);
} }
inline int32_t GBackDensity(int32_t x, int32_t y) inline int32_t GBackDensity(int32_t x, int32_t y)
{ {
return ::Landscape.GetDensity(x, y); return ::Landscape.GetDensity(x, y);
} }
inline bool GBackSolid(int32_t x, int32_t y) inline bool GBackSolid(int32_t x, int32_t y)
{ {
return DensitySolid(GBackDensity(x,y)); return DensitySolid(GBackDensity(x,y));
} }
inline bool GBackSemiSolid(int32_t x, int32_t y) inline bool GBackSemiSolid(int32_t x, int32_t y)
{ {
return DensitySemiSolid(GBackDensity(x,y)); return DensitySemiSolid(GBackDensity(x,y));
} }
inline bool GBackLiquid(int32_t x, int32_t y) inline bool GBackLiquid(int32_t x, int32_t y)
{ {
return DensityLiquid(GBackDensity(x,y)); return DensityLiquid(GBackDensity(x,y));
} }
#endif #endif

View File

@ -31,128 +31,128 @@
#include <Bitmap256.h> #include <Bitmap256.h>
C4MapCreator::C4MapCreator() C4MapCreator::C4MapCreator()
{ {
Reset(); Reset();
} }
void C4MapCreator::Reset() void C4MapCreator::Reset()
{ {
MapIFT=128; MapIFT=128;
MapBuf=NULL; MapBuf=NULL;
Exclusive=-1; Exclusive=-1;
} }
void C4MapCreator::SetPix(int32_t x, int32_t y, BYTE col) void C4MapCreator::SetPix(int32_t x, int32_t y, BYTE col)
{ {
// Safety // Safety
if (!Inside<int32_t>(x,0,MapWdt-1) || !Inside<int32_t>(y,0,MapHgt-1)) return; if (!Inside<int32_t>(x,0,MapWdt-1) || !Inside<int32_t>(y,0,MapHgt-1)) return;
// Exclusive // Exclusive
if (Exclusive>-1) if (GetPix(x,y)!=Exclusive) return; if (Exclusive>-1) if (GetPix(x,y)!=Exclusive) return;
// Set pix // Set pix
MapBuf->SetPix(x,y,col); MapBuf->SetPix(x,y,col);
} }
void C4MapCreator::SetSpot(int32_t x, int32_t y, int32_t rad, BYTE col) void C4MapCreator::SetSpot(int32_t x, int32_t y, int32_t rad, BYTE col)
{ {
int32_t ycnt,xcnt,lwdt,dpy; int32_t ycnt,xcnt,lwdt,dpy;
for (ycnt=-rad; ycnt<=rad; ycnt++) for (ycnt=-rad; ycnt<=rad; ycnt++)
{ {
lwdt= (int32_t) sqrt(double(rad*rad-ycnt*ycnt)); dpy=y+ycnt; lwdt= (int32_t) sqrt(double(rad*rad-ycnt*ycnt)); dpy=y+ycnt;
for (xcnt=-lwdt; xcnt<lwdt+(lwdt==0); xcnt++) for (xcnt=-lwdt; xcnt<lwdt+(lwdt==0); xcnt++)
SetPix(x+xcnt,dpy,col); SetPix(x+xcnt,dpy,col);
} }
} }
void C4MapCreator::DrawLayer(int32_t x, int32_t y, int32_t size, BYTE col) void C4MapCreator::DrawLayer(int32_t x, int32_t y, int32_t size, BYTE col)
{ {
int32_t cnt,cnt2; int32_t cnt,cnt2;
for (cnt=0; cnt<size; cnt++) for (cnt=0; cnt<size; cnt++)
{ {
x+=Random(9)-4; y+=Random(3)-1; x+=Random(9)-4; y+=Random(3)-1;
for (cnt2=Random(3); cnt2<5; cnt2++) for (cnt2=Random(3); cnt2<5; cnt2++)
{ SetPix(x+cnt2,y,col); SetPix(x+cnt2+1,y+1,col); } { SetPix(x+cnt2,y,col); SetPix(x+cnt2+1,y+1,col); }
} }
} }
BYTE C4MapCreator::GetPix(int32_t x, int32_t y) BYTE C4MapCreator::GetPix(int32_t x, int32_t y)
{ {
// Safety // Safety
if (!Inside<int32_t>(x,0,MapWdt-1) || !Inside<int32_t>(y,0,MapHgt-1)) return 0; if (!Inside<int32_t>(x,0,MapWdt-1) || !Inside<int32_t>(y,0,MapHgt-1)) return 0;
// Get pix // Get pix
return MapBuf->GetPix(x,y); return MapBuf->GetPix(x,y);
} }
void C4MapCreator::Create(CSurface8 *sfcMap, void C4MapCreator::Create(CSurface8 *sfcMap,
C4SLandscape &rLScape, C4TextureMap &rTexMap, C4SLandscape &rLScape, C4TextureMap &rTexMap,
bool fLayers, int32_t iPlayerNum) bool fLayers, int32_t iPlayerNum)
{ {
double fullperiod= 20.0 * pi; double fullperiod= 20.0 * pi;
BYTE ccol; BYTE ccol;
int32_t cx,cy; int32_t cx,cy;
// Safeties // Safeties
if (!sfcMap) return; if (!sfcMap) return;
iPlayerNum=BoundBy<int32_t>(iPlayerNum,1,C4S_MaxPlayer); iPlayerNum=BoundBy<int32_t>(iPlayerNum,1,C4S_MaxPlayer);
// Set creator variables // Set creator variables
MapBuf = sfcMap; MapBuf = sfcMap;
MapWdt = MapBuf->Wdt; MapHgt = MapBuf->Hgt; MapWdt = MapBuf->Wdt; MapHgt = MapBuf->Hgt;
// Reset map (0 is sky) // Reset map (0 is sky)
MapBuf->ClearBox8Only(0,0,MapBuf->Wdt, MapBuf->Hgt); MapBuf->ClearBox8Only(0,0,MapBuf->Wdt, MapBuf->Hgt);
// Surface // Surface
ccol=rTexMap.GetIndexMatTex(rLScape.Material)+MapIFT; ccol=rTexMap.GetIndexMatTex(rLScape.Material)+MapIFT;
float amplitude= (float) rLScape.Amplitude.Evaluate(); float amplitude= (float) rLScape.Amplitude.Evaluate();
float phase= (float) rLScape.Phase.Evaluate(); float phase= (float) rLScape.Phase.Evaluate();
float period= (float) rLScape.Period.Evaluate(); float period= (float) rLScape.Period.Evaluate();
if (rLScape.MapPlayerExtend) period *= Min(iPlayerNum, C4S_MaxMapPlayerExtend); if (rLScape.MapPlayerExtend) period *= Min(iPlayerNum, C4S_MaxMapPlayerExtend);
float natural= (float) rLScape.Random.Evaluate(); float natural= (float) rLScape.Random.Evaluate();
int32_t level0= Min(MapWdt,MapHgt)/2; int32_t level0= Min(MapWdt,MapHgt)/2;
int32_t maxrange= level0*3/4; int32_t maxrange= level0*3/4;
double cy_curve,cy_natural; // -1.0 - +1.0 ! double cy_curve,cy_natural; // -1.0 - +1.0 !
double rnd_cy,rnd_tend; // -1.0 - +1.0 ! double rnd_cy,rnd_tend; // -1.0 - +1.0 !
rnd_cy= (double) (Random(2000+1)-1000)/1000.0; rnd_cy= (double) (Random(2000+1)-1000)/1000.0;
rnd_tend= (double) (Random(200+1)-100)/20000.0; rnd_tend= (double) (Random(200+1)-100)/20000.0;
for (cx=0; cx<MapWdt; cx++) for (cx=0; cx<MapWdt; cx++)
{ {
rnd_cy+=rnd_tend; rnd_cy+=rnd_tend;
rnd_tend+= (double) (Random(100+1)-50)/10000; rnd_tend+= (double) (Random(100+1)-50)/10000;
if (rnd_tend>+0.05) rnd_tend=+0.05; if (rnd_tend>+0.05) rnd_tend=+0.05;
if (rnd_tend<-0.05) rnd_tend=-0.05; if (rnd_tend<-0.05) rnd_tend=-0.05;
if (rnd_cy<-0.5) rnd_tend+=0.01; if (rnd_cy<-0.5) rnd_tend+=0.01;
if (rnd_cy>+0.5) rnd_tend-=0.01; if (rnd_cy>+0.5) rnd_tend-=0.01;
cy_natural=rnd_cy*natural/100.0; cy_natural=rnd_cy*natural/100.0;
cy_curve=sin(fullperiod*period/100.0*(float)cx/(float)MapWdt cy_curve=sin(fullperiod*period/100.0*(float)cx/(float)MapWdt
+2.0*pi*phase/100.0) * amplitude/100.0; +2.0*pi*phase/100.0) * amplitude/100.0;
cy=level0+BoundBy((int32_t)((float)maxrange*(cy_curve+cy_natural)), cy=level0+BoundBy((int32_t)((float)maxrange*(cy_curve+cy_natural)),
-maxrange,+maxrange); -maxrange,+maxrange);
SetPix(cx,cy,ccol); SetPix(cx,cy,ccol);
} }
// Raise bottom to surface // Raise bottom to surface
for (cx=0; cx<MapWdt; cx++) for (cx=0; cx<MapWdt; cx++)
for (cy=MapHgt-1; (cy>=0) && !GetPix(cx,cy); cy--) for (cy=MapHgt-1; (cy>=0) && !GetPix(cx,cy); cy--)
SetPix(cx,cy,ccol); SetPix(cx,cy,ccol);
// Raise liquid level // Raise liquid level
Exclusive=0; Exclusive=0;
ccol=rTexMap.GetIndexMatTex(rLScape.Liquid); ccol=rTexMap.GetIndexMatTex(rLScape.Liquid);
int32_t wtr_level=rLScape.LiquidLevel.Evaluate(); int32_t wtr_level=rLScape.LiquidLevel.Evaluate();
for (cx=0; cx<MapWdt; cx++) for (cx=0; cx<MapWdt; cx++)
for (cy=MapHgt*(100-wtr_level)/100; cy<MapHgt; cy++) for (cy=MapHgt*(100-wtr_level)/100; cy<MapHgt; cy++)
SetPix(cx,cy,ccol); SetPix(cx,cy,ccol);
Exclusive=-1; Exclusive=-1;
// Layers // Layers
if (fLayers) if (fLayers)
{ {
// Base material // Base material
Exclusive=rTexMap.GetIndexMatTex(rLScape.Material)+MapIFT; Exclusive=rTexMap.GetIndexMatTex(rLScape.Material)+MapIFT;
@ -180,9 +180,9 @@ void C4MapCreator::Create(CSurface8 *sfcMap,
Exclusive=-1; Exclusive=-1;
} }
} }
/*bool C4MapCreator::Load( /*bool C4MapCreator::Load(
BYTE **pbypBuffer, BYTE **pbypBuffer,

View File

@ -28,29 +28,29 @@ class CSurface8;
class C4TextureMap; class C4TextureMap;
class C4MapCreator class C4MapCreator
{ {
public: public:
C4MapCreator(); C4MapCreator();
protected: protected:
int32_t MapIFT; int32_t MapIFT;
CSurface8 *MapBuf; CSurface8 *MapBuf;
int32_t MapWdt,MapHgt; int32_t MapWdt,MapHgt;
int32_t Exclusive; int32_t Exclusive;
public: public:
void Create(CSurface8 *sfcMap, void Create(CSurface8 *sfcMap,
C4SLandscape &rLScape, C4TextureMap &rTexMap, C4SLandscape &rLScape, C4TextureMap &rTexMap,
bool fLayers=false, int32_t iPlayerNum=1); bool fLayers=false, int32_t iPlayerNum=1);
bool Load(BYTE **pbypBuffer, bool Load(BYTE **pbypBuffer,
int32_t &rBufWdt, int32_t &rMapWdt, int32_t &rMapHgt, int32_t &rBufWdt, int32_t &rMapWdt, int32_t &rMapHgt,
C4Group &hGroup, const char *szEntryName, C4Group &hGroup, const char *szEntryName,
C4TextureMap &rTexMap); C4TextureMap &rTexMap);
protected: protected:
void Reset(); void Reset();
void SetPix(int32_t x, int32_t y, BYTE col); void SetPix(int32_t x, int32_t y, BYTE col);
void SetSpot(int32_t x, int32_t y, int32_t rad, BYTE col); void SetSpot(int32_t x, int32_t y, int32_t rad, BYTE col);
void DrawLayer(int32_t x, int32_t y, int32_t size, BYTE col); void DrawLayer(int32_t x, int32_t y, int32_t size, BYTE col);
void ValidateTextureIndices(C4TextureMap &rTexMap); void ValidateTextureIndices(C4TextureMap &rTexMap);
BYTE GetPix(int32_t x, int32_t y); BYTE GetPix(int32_t x, int32_t y);
}; };
#endif #endif

View File

@ -385,7 +385,7 @@ bool C4MCOverlay::SetField(C4MCParser *pParser, const char *szField, const char
*((C4MCCallbackArray **) pTarget) = new C4MCCallbackArray(pSFunc, MapCreator); *((C4MCCallbackArray **) pTarget) = new C4MCCallbackArray(pSFunc, MapCreator);
} }
default: default:
// TODO // TODO
break; break;
} }
// done // done
@ -818,9 +818,9 @@ CSurface8 * C4MapCreatorS2::Render(const char *szMapName)
} }
static inline void DWordAlign(int &val) static inline void DWordAlign(int &val)
{ {
if (val%4) { val>>=2; val<<=2; val+=4; } if (val%4) { val>>=2; val<<=2; val+=4; }
} }
BYTE *C4MapCreatorS2::RenderBuf(const char *szMapName, int32_t &sfcWdt, int32_t &sfcHgt) BYTE *C4MapCreatorS2::RenderBuf(const char *szMapName, int32_t &sfcWdt, int32_t &sfcHgt)
{ {
@ -1480,7 +1480,7 @@ bool AlgoChecker(C4MCOverlay *pOvrl, int32_t iX, int32_t iY)
bool AlgoBozo(C4MCOverlay *pOvrl, int32_t iX, int32_t iY) bool AlgoBozo(C4MCOverlay *pOvrl, int32_t iX, int32_t iY)
{ {
// do some bozo stuff - keep it regular here, since it may be modified by turbulence // do some bozo stuff - keep it regular here, since it may be modified by turbulence
int32_t iXC=(iX/10+s+(iY/80))%(z*2)-z; int32_t iXC=(iX/10+s+(iY/80))%(z*2)-z;
int32_t iYC=(iY/10+s+(iX/80))%(z*2)-z; int32_t iYC=(iY/10+s+(iX/80))%(z*2)-z;
int32_t id=Abs(iXC*iYC); // ((iSeed^iX^iY)%z) int32_t id=Abs(iXC*iYC); // ((iSeed^iX^iY)%z)

View File

@ -42,19 +42,19 @@
// hardly ever exceeding 1000. October 1997 // hardly ever exceeding 1000. October 1997
C4MassMoverSet::C4MassMoverSet() C4MassMoverSet::C4MassMoverSet()
{ {
Default(); Default();
} }
C4MassMoverSet::~C4MassMoverSet() C4MassMoverSet::~C4MassMoverSet()
{ {
Clear(); Clear();
} }
void C4MassMoverSet::Clear() void C4MassMoverSet::Clear()
{ {
} }
void C4MassMoverSet::Execute() void C4MassMoverSet::Execute()
{ {
@ -69,75 +69,75 @@ void C4MassMoverSet::Execute()
if (cmm->Mat!=MNone) if (cmm->Mat!=MNone)
{ Count++; cmm->Execute(); } { Count++; cmm->Execute(); }
} }
} }
bool C4MassMoverSet::Create(int32_t x, int32_t y, bool fExecute) bool C4MassMoverSet::Create(int32_t x, int32_t y, bool fExecute)
{ {
if(Count == C4MassMoverChunk) return false; if(Count == C4MassMoverChunk) return false;
#ifdef DEBUGREC #ifdef DEBUGREC
C4RCMassMover rc; C4RCMassMover rc;
rc.x=x; rc.y=y; rc.x=x; rc.y=y;
AddDbgRec(RCT_MMC, &rc, sizeof(rc)); AddDbgRec(RCT_MMC, &rc, sizeof(rc));
#endif #endif
int32_t cptr=CreatePtr; int32_t cptr=CreatePtr;
do do
{ {
cptr++; cptr++;
if (cptr>=C4MassMoverChunk) cptr=0; if (cptr>=C4MassMoverChunk) cptr=0;
if (Set[cptr].Mat==MNone) if (Set[cptr].Mat==MNone)
{ {
if (!Set[cptr].Init(x,y)) return false; if (!Set[cptr].Init(x,y)) return false;
CreatePtr=cptr; CreatePtr=cptr;
if (fExecute) Set[cptr].Execute(); if (fExecute) Set[cptr].Execute();
return true; return true;
} }
} }
while (cptr!=CreatePtr); while (cptr!=CreatePtr);
return false; return false;
} }
void C4MassMoverSet::Draw() void C4MassMoverSet::Draw()
{ {
/*int32_t cnt; /*int32_t cnt;
for (cnt=0; cnt<C4MassMoverChunk; cnt++) for (cnt=0; cnt<C4MassMoverChunk; cnt++)
if (Set[cnt].Mat!=MNone)*/ if (Set[cnt].Mat!=MNone)*/
} }
bool C4MassMover::Init(int32_t tx, int32_t ty) bool C4MassMover::Init(int32_t tx, int32_t ty)
{ {
// Out of bounds check // Out of bounds check
if (!Inside<int32_t>(tx,0,GBackWdt-1) || !Inside<int32_t>(ty,0,GBackHgt-1)) if (!Inside<int32_t>(tx,0,GBackWdt-1) || !Inside<int32_t>(ty,0,GBackHgt-1))
return false; return false;
// Check mat // Check mat
Mat=GBackMat(tx,ty); Mat=GBackMat(tx,ty);
x=tx; y=ty; x=tx; y=ty;
::MassMover.Count++; ::MassMover.Count++;
return (Mat!=MNone); return (Mat!=MNone);
} }
void C4MassMover::Cease() void C4MassMover::Cease()
{ {
#ifdef DEBUGREC #ifdef DEBUGREC
C4RCMassMover rc; C4RCMassMover rc;
rc.x=x; rc.y=y; rc.x=x; rc.y=y;
AddDbgRec(RCT_MMD, &rc, sizeof(rc)); AddDbgRec(RCT_MMD, &rc, sizeof(rc));
#endif #endif
::MassMover.Count--; ::MassMover.Count--;
Mat=MNone; Mat=MNone;
} }
bool C4MassMover::Execute() bool C4MassMover::Execute()
{ {
int32_t tx,ty; int32_t tx,ty;
// Lost target material // Lost target material
if (GBackMat(x,y)!=Mat) { Cease(); return false; } if (GBackMat(x,y)!=Mat) { Cease(); return false; }
// Check for transfer target space // Check for transfer target space
C4Material *pMat = ::MaterialMap.Map+Mat; C4Material *pMat = ::MaterialMap.Map+Mat;
tx=x; ty=y; tx=x; ty=y;
if (!::Landscape.FindMatPath(tx,ty,+1,pMat->Density,pMat->MaxSlide)) if (!::Landscape.FindMatPath(tx,ty,+1,pMat->Density,pMat->MaxSlide))
{ {
// Contact material reaction check: corrosion/evaporation/inflammation/etc. // Contact material reaction check: corrosion/evaporation/inflammation/etc.
if (Corrosion(+0,+1) || Corrosion(-1,+0) || Corrosion(+1,+0)) if (Corrosion(+0,+1) || Corrosion(-1,+0) || Corrosion(+1,+0))
{ {
@ -163,7 +163,7 @@ bool C4MassMover::Execute()
if (Game.C4S.Game.Realism.LandscapeInsertThrust) if (Game.C4S.Game.Realism.LandscapeInsertThrust)
omat = GBackMat(tx, ty); omat = GBackMat(tx, ty);
// Transfer mass // Transfer mass
if(Random(10)) if(Random(10))
SBackPix(tx,ty,Mat2PixColDefault(::Landscape.ExtractMaterial(x,y))+GBackIFT(tx,ty)); SBackPix(tx,ty,Mat2PixColDefault(::Landscape.ExtractMaterial(x,y))+GBackIFT(tx,ty));
else else
@ -173,11 +173,11 @@ bool C4MassMover::Execute()
if(Game.C4S.Game.Realism.LandscapeInsertThrust && MatValid(omat) && ::MaterialMap.Map[omat].Density > 0) if(Game.C4S.Game.Realism.LandscapeInsertThrust && MatValid(omat) && ::MaterialMap.Map[omat].Density > 0)
::Landscape.InsertMaterial(omat, tx, ty + 1); ::Landscape.InsertMaterial(omat, tx, ty + 1);
// Create new mover at target // Create new mover at target
::MassMover.Create(tx,ty,!Rnd3()); ::MassMover.Create(tx,ty,!Rnd3());
return true; return true;
} }
bool C4MassMover::Corrosion(int32_t dx, int32_t dy) bool C4MassMover::Corrosion(int32_t dx, int32_t dy)
{ {
@ -195,10 +195,10 @@ bool C4MassMover::Corrosion(int32_t dx, int32_t dy)
void C4MassMoverSet::Default() void C4MassMoverSet::Default()
{ {
int32_t cnt; int32_t cnt;
for (cnt=0; cnt<C4MassMoverChunk; cnt++) Set[cnt].Mat=MNone; for (cnt=0; cnt<C4MassMoverChunk; cnt++) Set[cnt].Mat=MNone;
Count=0; Count=0;
CreatePtr=0; CreatePtr=0;
} }
bool C4MassMoverSet::Save(C4Group &hGroup) bool C4MassMoverSet::Save(C4Group &hGroup)
@ -263,7 +263,7 @@ void C4MassMoverSet::Consolidate()
if (iSpot==iPtr) iSpot=-1; if (iSpot==iPtr) iSpot=-1;
} }
} }
// Reset create ptr // Reset create ptr
CreatePtr=0; CreatePtr=0;
} }
@ -277,7 +277,7 @@ void C4MassMoverSet::Copy(C4MassMoverSet &rSet)
Clear(); Clear();
Count=rSet.Count; Count=rSet.Count;
CreatePtr=rSet.CreatePtr; CreatePtr=rSet.CreatePtr;
for (int32_t cnt=0; cnt<C4MassMoverChunk; cnt++) Set[cnt]=rSet.Set[cnt]; for (int32_t cnt=0; cnt<C4MassMoverChunk; cnt++) Set[cnt]=rSet.Set[cnt];
} }
C4MassMoverSet MassMover; C4MassMoverSet MassMover;

View File

@ -28,40 +28,40 @@ class C4Group;
class C4MassMoverSet; class C4MassMoverSet;
class C4MassMover class C4MassMover
{ {
friend class C4MassMoverSet; friend class C4MassMoverSet;
protected: protected:
int32_t Mat,x,y; int32_t Mat,x,y;
protected: protected:
void Cease(); void Cease();
bool Execute(); bool Execute();
bool Init(int32_t tx, int32_t ty); bool Init(int32_t tx, int32_t ty);
bool Corrosion(int32_t dx, int32_t dy); bool Corrosion(int32_t dx, int32_t dy);
}; };
class C4MassMoverSet class C4MassMoverSet
{ {
public: public:
C4MassMoverSet(); C4MassMoverSet();
~C4MassMoverSet(); ~C4MassMoverSet();
public: public:
int32_t Count; int32_t Count;
int32_t CreatePtr; int32_t CreatePtr;
protected: protected:
C4MassMover Set[C4MassMoverChunk]; C4MassMover Set[C4MassMoverChunk];
public: public:
void Copy(C4MassMoverSet &rSet); void Copy(C4MassMoverSet &rSet);
void Synchronize(); void Synchronize();
void Default(); void Default();
void Clear(); void Clear();
void Draw(); void Draw();
void Execute(); void Execute();
bool Create(int32_t x, int32_t y, bool fExecute=false); bool Create(int32_t x, int32_t y, bool fExecute=false);
bool Load(C4Group &hGroup); bool Load(C4Group &hGroup);
bool Save(C4Group &hGroup); bool Save(C4Group &hGroup);
protected: protected:
void Consolidate(); void Consolidate();
}; };
extern C4MassMoverSet MassMover; extern C4MassMoverSet MassMover;

View File

@ -139,7 +139,7 @@ void C4MaterialCore::Clear()
ColorAnimation = 0; ColorAnimation = 0;
TempConvStrength = 0; TempConvStrength = 0;
MinHeightCount = 0; MinHeightCount = 0;
SplashRate=10; SplashRate=10;
} }
void C4MaterialCore::Default() void C4MaterialCore::Default()
@ -154,7 +154,7 @@ bool C4MaterialCore::Load(C4Group &hGroup,
if (!hGroup.LoadEntryString(szEntryName,Source)) if (!hGroup.LoadEntryString(szEntryName,Source))
return false; return false;
StdStrBuf Name = hGroup.GetFullName() + DirSep + szEntryName; StdStrBuf Name = hGroup.GetFullName() + DirSep + szEntryName;
if(!CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, Source, Name.getData())) if(!CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, Source, Name.getData()))
return false; return false;
// adjust placement, if not specified // adjust placement, if not specified
if (!Placement) if (!Placement)
@ -218,7 +218,7 @@ void C4MaterialCore::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(BelowTempConvertDir, "BelowTempConvertDir",0 )); pComp->Value(mkNamingAdapt(BelowTempConvertDir, "BelowTempConvertDir",0 ));
pComp->Value(mkNamingAdapt(mkParAdapt(sBelowTempConvertTo, StdCompiler::RCT_IdtfAllowEmpty),"BelowTempConvertTo", "" )); pComp->Value(mkNamingAdapt(mkParAdapt(sBelowTempConvertTo, StdCompiler::RCT_IdtfAllowEmpty),"BelowTempConvertTo", "" ));
pComp->Value(mkNamingAdapt(MinHeightCount, "MinHeightCount", 0 )); pComp->Value(mkNamingAdapt(MinHeightCount, "MinHeightCount", 0 ));
pComp->Value(mkNamingAdapt(SplashRate, "SplashRate", 10 )); pComp->Value(mkNamingAdapt(SplashRate, "SplashRate", 10 ));
pComp->NameEnd(); pComp->NameEnd();
// material reactions // material reactions
pComp->Value(mkNamingAdapt( pComp->Value(mkNamingAdapt(
@ -230,12 +230,12 @@ void C4MaterialCore::CompileFunc(StdCompiler *pComp)
// -------------------------------------- C4Material // -------------------------------------- C4Material
C4Material::C4Material() C4Material::C4Material()
{ {
BlastShiftTo=0; BlastShiftTo=0;
InMatConvertTo=MNone; InMatConvertTo=MNone;
BelowTempConvertTo=0; BelowTempConvertTo=0;
AboveTempConvertTo=0; AboveTempConvertTo=0;
} }
void C4Material::UpdateScriptPointers() void C4Material::UpdateScriptPointers()
{ {
@ -248,35 +248,35 @@ void C4Material::UpdateScriptPointers()
C4MaterialMap::C4MaterialMap() : DefReactConvert(&mrfConvert), DefReactPoof(&mrfPoof), DefReactCorrode(&mrfCorrode), DefReactIncinerate(&mrfIncinerate), DefReactInsert(&mrfInsert) C4MaterialMap::C4MaterialMap() : DefReactConvert(&mrfConvert), DefReactPoof(&mrfPoof), DefReactCorrode(&mrfCorrode), DefReactIncinerate(&mrfIncinerate), DefReactInsert(&mrfInsert)
{ {
Default(); Default();
} }
C4MaterialMap::~C4MaterialMap() C4MaterialMap::~C4MaterialMap()
{ {
Clear(); Clear();
} }
void C4MaterialMap::Clear() void C4MaterialMap::Clear()
{ {
if (Map) delete [] Map; Map=NULL; if (Map) delete [] Map; Map=NULL;
delete [] ppReactionMap; ppReactionMap = NULL; delete [] ppReactionMap; ppReactionMap = NULL;
} }
int32_t C4MaterialMap::Load(C4Group &hGroup) int32_t C4MaterialMap::Load(C4Group &hGroup)
{ {
char entryname[256+1]; char entryname[256+1];
// Determine number of materials in files // Determine number of materials in files
int32_t mat_num=hGroup.EntryCount(C4CFN_MaterialFiles); int32_t mat_num=hGroup.EntryCount(C4CFN_MaterialFiles);
// Allocate new map // Allocate new map
C4Material *pNewMap = new C4Material [mat_num + Num]; C4Material *pNewMap = new C4Material [mat_num + Num];
if(!pNewMap) return 0; if(!pNewMap) return 0;
// Load material cores to map // Load material cores to map
hGroup.ResetSearch(); int32_t cnt=0; hGroup.ResetSearch(); int32_t cnt=0;
while (hGroup.FindNextEntry(C4CFN_MaterialFiles,entryname)) while (hGroup.FindNextEntry(C4CFN_MaterialFiles,entryname))
{ {
// Load mat // Load mat
@ -298,8 +298,8 @@ int32_t C4MaterialMap::Load(C4Group &hGroup)
// set material number // set material number
Num+=cnt; Num+=cnt;
return cnt; return cnt;
} }
bool C4MaterialMap::HasMaterials(C4Group &hGroup) const bool C4MaterialMap::HasMaterials(C4Group &hGroup) const
{ {
@ -307,13 +307,13 @@ bool C4MaterialMap::HasMaterials(C4Group &hGroup) const
} }
int32_t C4MaterialMap::Get(const char *szMaterial) int32_t C4MaterialMap::Get(const char *szMaterial)
{ {
int32_t cnt; int32_t cnt;
for (cnt=0; cnt<Num; cnt++) for (cnt=0; cnt<Num; cnt++)
if (SEqualNoCase(szMaterial,Map[cnt].Name)) if (SEqualNoCase(szMaterial,Map[cnt].Name))
return cnt; return cnt;
return MNone; return MNone;
} }
bool C4MaterialMap::CrossMapMaterials() // Called after load bool C4MaterialMap::CrossMapMaterials() // Called after load
@ -465,16 +465,16 @@ bool C4MaterialMap::CrossMapMaterials() // Called after load
} }
} }
// second loop (DefaultMatTex is needed by GetIndexMatTex) // second loop (DefaultMatTex is needed by GetIndexMatTex)
for (cnt=0; cnt<Num; cnt++) for (cnt=0; cnt<Num; cnt++)
{ {
if (Map[cnt].sBlastShiftTo.getLength()) if (Map[cnt].sBlastShiftTo.getLength())
Map[cnt].BlastShiftTo=::TextureMap.GetIndexMatTex(Map[cnt].sBlastShiftTo.getData(), NULL, true, FormatString("BlastShiftTo of mat %s", Map[cnt].Name).getData()); Map[cnt].BlastShiftTo=::TextureMap.GetIndexMatTex(Map[cnt].sBlastShiftTo.getData(), NULL, true, FormatString("BlastShiftTo of mat %s", Map[cnt].Name).getData());
if (Map[cnt].sInMatConvertTo.getLength()) if (Map[cnt].sInMatConvertTo.getLength())
Map[cnt].InMatConvertTo=Get(Map[cnt].sInMatConvertTo.getData()); Map[cnt].InMatConvertTo=Get(Map[cnt].sInMatConvertTo.getData());
if (Map[cnt].sBelowTempConvertTo.getLength()) if (Map[cnt].sBelowTempConvertTo.getLength())
Map[cnt].BelowTempConvertTo=::TextureMap.GetIndexMatTex(Map[cnt].sBelowTempConvertTo.getData(), NULL, true, FormatString("BelowTempConvertTo of mat %s", Map[cnt].Name).getData()); Map[cnt].BelowTempConvertTo=::TextureMap.GetIndexMatTex(Map[cnt].sBelowTempConvertTo.getData(), NULL, true, FormatString("BelowTempConvertTo of mat %s", Map[cnt].Name).getData());
if (Map[cnt].sAboveTempConvertTo.getLength()) if (Map[cnt].sAboveTempConvertTo.getLength())
Map[cnt].AboveTempConvertTo=::TextureMap.GetIndexMatTex(Map[cnt].sAboveTempConvertTo.getData(), NULL, true, FormatString("AboveTempConvertTo of mat %s", Map[cnt].Name).getData()); Map[cnt].AboveTempConvertTo=::TextureMap.GetIndexMatTex(Map[cnt].sAboveTempConvertTo.getData(), NULL, true, FormatString("AboveTempConvertTo of mat %s", Map[cnt].Name).getData());
} }
#if 0 #if 0
int32_t i=0; int32_t i=0;
@ -511,7 +511,7 @@ bool C4MaterialMap::SaveEnumeration(C4Group &hGroup)
char *mapbuf = new char [1000]; char *mapbuf = new char [1000];
mapbuf[0]=0; mapbuf[0]=0;
SAppend("[Enumeration]",mapbuf); SAppend(LineFeed,mapbuf); SAppend("[Enumeration]",mapbuf); SAppend(LineFeed,mapbuf);
for (int32_t cnt=0; cnt<Num; cnt++) for (int32_t cnt=0; cnt<Num; cnt++)
{ {
SAppend(Map[cnt].Name,mapbuf); SAppend(Map[cnt].Name,mapbuf);
SAppend(LineFeed,mapbuf); SAppend(LineFeed,mapbuf);
@ -575,8 +575,8 @@ bool C4MaterialMap::SortEnumeration(int32_t iMat, const char *szMatName)
void C4MaterialMap::Default() void C4MaterialMap::Default()
{ {
Num=0; Num=0;
Map=NULL; Map=NULL;
ppReactionMap=NULL; ppReactionMap=NULL;
} }
@ -871,7 +871,7 @@ int32_t PixCol2MatOld(BYTE pixc)
} }
int32_t PixCol2MatOld2(BYTE pixc) int32_t PixCol2MatOld2(BYTE pixc)
{ {
int32_t iMat = ((int32_t) (pixc&0x7f)) -1; int32_t iMat = ((int32_t) (pixc&0x7f)) -1;
// if above MVehic, don't forget additional vehicle-colors // if above MVehic, don't forget additional vehicle-colors
if (iMat<=MVehic) return iMat; if (iMat<=MVehic) return iMat;
@ -880,6 +880,6 @@ int32_t PixCol2MatOld2(BYTE pixc)
// above: range check // above: range check
iMat-=2; if (iMat >= ::MaterialMap.Num) return MNone; iMat-=2; if (iMat >= ::MaterialMap.Num) return MNone;
return iMat; return iMat;
} }
C4MaterialMap MaterialMap; C4MaterialMap MaterialMap;

View File

@ -74,87 +74,87 @@ struct C4MaterialReaction
}; };
class C4MaterialCore class C4MaterialCore
{ {
public: public:
C4MaterialCore(); C4MaterialCore();
~C4MaterialCore() { Clear(); } ~C4MaterialCore() { Clear(); }
public: public:
std::vector<C4MaterialReaction> CustomReactionList; std::vector<C4MaterialReaction> CustomReactionList;
public: public:
char Name[C4M_MaxName+1]; char Name[C4M_MaxName+1];
int32_t MapChunkType; int32_t MapChunkType;
int32_t Density; int32_t Density;
int32_t Friction; int32_t Friction;
int32_t DigFree; int32_t DigFree;
int32_t BlastFree; int32_t BlastFree;
C4ID Dig2Object; C4ID Dig2Object;
int32_t Dig2ObjectRatio; int32_t Dig2ObjectRatio;
int32_t Dig2ObjectOnRequestOnly; int32_t Dig2ObjectOnRequestOnly;
C4ID Blast2Object; C4ID Blast2Object;
int32_t Blast2ObjectRatio; int32_t Blast2ObjectRatio;
int32_t Blast2PXSRatio; int32_t Blast2PXSRatio;
int32_t Instable; int32_t Instable;
int32_t MaxAirSpeed; int32_t MaxAirSpeed;
int32_t MaxSlide; int32_t MaxSlide;
int32_t WindDrift; int32_t WindDrift;
int32_t Inflammable; int32_t Inflammable;
int32_t Incindiary; int32_t Incindiary;
int32_t Extinguisher; int32_t Extinguisher;
int32_t Corrosive; int32_t Corrosive;
int32_t Corrode; int32_t Corrode;
int32_t Soil; int32_t Soil;
int32_t Placement; // placement order for landscape shading int32_t Placement; // placement order for landscape shading
StdCopyStrBuf sTextureOverlay; // overlayed texture for this material StdCopyStrBuf sTextureOverlay; // overlayed texture for this material
int32_t OverlayType; // defines the way in which the overlay texture is applied int32_t OverlayType; // defines the way in which the overlay texture is applied
StdCopyStrBuf sPXSGfx; // newgfx: picture used for loose pxs StdCopyStrBuf sPXSGfx; // newgfx: picture used for loose pxs
C4TargetRect PXSGfxRt; // newgfx: facet rect of pixture used for loose pixels C4TargetRect PXSGfxRt; // newgfx: facet rect of pixture used for loose pixels
int32_t PXSGfxSize; int32_t PXSGfxSize;
StdCopyStrBuf sBlastShiftTo; StdCopyStrBuf sBlastShiftTo;
StdCopyStrBuf sInMatConvert; StdCopyStrBuf sInMatConvert;
StdCopyStrBuf sInMatConvertTo; StdCopyStrBuf sInMatConvertTo;
int32_t InMatConvertDepth; // material converts only if it finds the same material above int32_t InMatConvertDepth; // material converts only if it finds the same material above
int32_t BelowTempConvert; int32_t BelowTempConvert;
int32_t BelowTempConvertDir; int32_t BelowTempConvertDir;
StdCopyStrBuf sBelowTempConvertTo; StdCopyStrBuf sBelowTempConvertTo;
int32_t AboveTempConvert; int32_t AboveTempConvert;
int32_t AboveTempConvertDir; int32_t AboveTempConvertDir;
StdCopyStrBuf sAboveTempConvertTo; StdCopyStrBuf sAboveTempConvertTo;
int32_t ColorAnimation; int32_t ColorAnimation;
int32_t TempConvStrength; int32_t TempConvStrength;
int32_t MinHeightCount; // minimum material thickness in order for it to be counted int32_t MinHeightCount; // minimum material thickness in order for it to be counted
int32_t SplashRate; int32_t SplashRate;
public: public:
void Clear(); void Clear();
void Default(); void Default();
bool Load(C4Group &hGroup, const char *szEntryName); bool Load(C4Group &hGroup, const char *szEntryName);
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
}; };
class C4Material: public C4MaterialCore class C4Material: public C4MaterialCore
{ {
public: public:
C4Material(); C4Material();
public: public:
// Cross-mapped material values // Cross-mapped material values
int32_t BlastShiftTo; // MatTex int32_t BlastShiftTo; // MatTex
int32_t InMatConvertTo; // Mat int32_t InMatConvertTo; // Mat
int32_t BelowTempConvertTo; // MatTex int32_t BelowTempConvertTo; // MatTex
int32_t AboveTempConvertTo; // MatTex int32_t AboveTempConvertTo; // MatTex
int32_t DefaultMatTex; // texture used for single pixel values int32_t DefaultMatTex; // texture used for single pixel values
C4Facet PXSFace; // loose pixel facet C4Facet PXSFace; // loose pixel facet
void UpdateScriptPointers(); // set all material script pointers void UpdateScriptPointers(); // set all material script pointers
}; };
class C4MaterialMap class C4MaterialMap
{ {
public: public:
C4MaterialMap(); C4MaterialMap();
~C4MaterialMap(); ~C4MaterialMap();
public: public:
int32_t Num; int32_t Num;
C4Material *Map; C4Material *Map;
C4MaterialReaction **ppReactionMap; C4MaterialReaction **ppReactionMap;
C4MaterialReaction DefReactConvert, DefReactPoof, DefReactCorrode, DefReactIncinerate, DefReactInsert; C4MaterialReaction DefReactConvert, DefReactPoof, DefReactCorrode, DefReactIncinerate, DefReactInsert;
@ -167,13 +167,13 @@ class C4MaterialMap
static bool mrfInsert (C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged); static bool mrfInsert (C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
// user-defined actions // user-defined actions
static bool mrfScript(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged); static bool mrfScript(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);
public: public:
void Default(); void Default();
void Clear(); void Clear();
int32_t Load(C4Group &hGroup); int32_t Load(C4Group &hGroup);
bool HasMaterials(C4Group &hGroup) const; bool HasMaterials(C4Group &hGroup) const;
int32_t Get(const char *szMaterial); int32_t Get(const char *szMaterial);
bool SaveEnumeration(C4Group &hGroup); bool SaveEnumeration(C4Group &hGroup);
bool LoadEnumeration(C4Group &hGroup); bool LoadEnumeration(C4Group &hGroup);
C4MaterialReaction *GetReactionUnsafe(int32_t iPXSMat, int32_t iLandscapeMat) C4MaterialReaction *GetReactionUnsafe(int32_t iPXSMat, int32_t iLandscapeMat)
{ assert(ppReactionMap); assert(Inside<int32_t>(iPXSMat,-1,Num-1)); assert(Inside<int32_t>(iLandscapeMat,-1,Num-1)); { assert(ppReactionMap); assert(Inside<int32_t>(iPXSMat,-1,Num-1)); assert(Inside<int32_t>(iLandscapeMat,-1,Num-1));
@ -181,24 +181,24 @@ class C4MaterialMap
C4MaterialReaction *GetReaction(int32_t iPXSMat, int32_t iLandscapeMat); C4MaterialReaction *GetReaction(int32_t iPXSMat, int32_t iLandscapeMat);
void UpdateScriptPointers(); // set all material script pointers void UpdateScriptPointers(); // set all material script pointers
bool CrossMapMaterials(); bool CrossMapMaterials();
protected: protected:
void SetMatReaction(int32_t iPXSMat, int32_t iLSMat, C4MaterialReaction *pReact); void SetMatReaction(int32_t iPXSMat, int32_t iLSMat, C4MaterialReaction *pReact);
bool SortEnumeration(int32_t iMat, const char *szMatName); bool SortEnumeration(int32_t iMat, const char *szMatName);
}; };
extern C4MaterialMap MaterialMap; extern C4MaterialMap MaterialMap;
const int32_t C4M_Flat = 0, const int32_t C4M_Flat = 0,
C4M_TopFlat = 1, C4M_TopFlat = 1,
C4M_Smooth = 2, C4M_Smooth = 2,
C4M_Rough = 3, C4M_Rough = 3,
// Material Density Levels // Material Density Levels
C4M_Vehicle = 100, C4M_Vehicle = 100,
C4M_Solid = 50, C4M_Solid = 50,
C4M_SemiSolid = 25, C4M_SemiSolid = 25,
C4M_Liquid = 25, C4M_Liquid = 25,
C4M_Background= 0; C4M_Background= 0;
const int32_t MNone = -1; const int32_t MNone = -1;
@ -207,9 +207,9 @@ extern int32_t MVehic,MTunnel,MWater,MSnow,MEarth,MGranite,MFlyAshes; // presear
extern BYTE MCVehic; // precalculated material color extern BYTE MCVehic; // precalculated material color
inline bool MatValid(int32_t mat) inline bool MatValid(int32_t mat)
{ {
return Inside<int32_t>(mat,0,::MaterialMap.Num-1); return Inside<int32_t>(mat,0,::MaterialMap.Num-1);
} }
inline bool MatVehicle(int32_t iMat) inline bool MatVehicle(int32_t iMat)
{ {
@ -217,9 +217,9 @@ inline bool MatVehicle(int32_t iMat)
} }
inline BYTE MatTex2PixCol(int32_t tex) inline BYTE MatTex2PixCol(int32_t tex)
{ {
return BYTE(tex); return BYTE(tex);
} }
inline BYTE Mat2PixColDefault(int32_t mat) inline BYTE Mat2PixColDefault(int32_t mat)
{ {
@ -227,22 +227,22 @@ inline BYTE Mat2PixColDefault(int32_t mat)
} }
inline int32_t MatDensity(int32_t mat) inline int32_t MatDensity(int32_t mat)
{ {
if (!MatValid(mat)) return 0; if (!MatValid(mat)) return 0;
return ::MaterialMap.Map[mat].Density; return ::MaterialMap.Map[mat].Density;
} }
inline int32_t MatPlacement(int32_t mat) inline int32_t MatPlacement(int32_t mat)
{ {
if (!MatValid(mat)) return 0; if (!MatValid(mat)) return 0;
return ::MaterialMap.Map[mat].Placement; return ::MaterialMap.Map[mat].Placement;
} }
inline int32_t MatDigFree(int32_t mat) inline int32_t MatDigFree(int32_t mat)
{ {
if (!MatValid(mat)) return 1; if (!MatValid(mat)) return 1;
return ::MaterialMap.Map[mat].DigFree; return ::MaterialMap.Map[mat].DigFree;
} }
int32_t PixCol2MatOld(BYTE pixc); int32_t PixCol2MatOld(BYTE pixc);
int32_t PixCol2MatOld2(BYTE pixc); int32_t PixCol2MatOld2(BYTE pixc);

View File

@ -33,7 +33,7 @@
static const FIXED WindDrift_Factor = itofix(1, 800); static const FIXED WindDrift_Factor = itofix(1, 800);
void C4PXS::Execute() void C4PXS::Execute()
{ {
#ifdef DEBUGREC_PXS #ifdef DEBUGREC_PXS
{ {
C4RCExecPXS rc; C4RCExecPXS rc;
@ -132,19 +132,19 @@ void C4PXS::Execute()
} }
#endif #endif
return; return;
} }
void C4PXS::Deactivate() void C4PXS::Deactivate()
{ {
#ifdef DEBUGREC_PXS #ifdef DEBUGREC_PXS
C4RCExecPXS rc; C4RCExecPXS rc;
rc.x=x; rc.y=y; rc.iMat=Mat; rc.x=x; rc.y=y; rc.iMat=Mat;
rc.pos = 2; rc.pos = 2;
AddDbgRec(RCT_ExecPXS, &rc, sizeof(rc)); AddDbgRec(RCT_ExecPXS, &rc, sizeof(rc));
#endif #endif
Mat=MNone; Mat=MNone;
::PXS.Delete(this); ::PXS.Delete(this);
} }
C4PXSSystem::C4PXSSystem() C4PXSSystem::C4PXSSystem()
{ {
@ -177,19 +177,19 @@ void C4PXSSystem::Clear()
} }
C4PXS* C4PXSSystem::New() C4PXS* C4PXSSystem::New()
{ {
unsigned int cnt,cnt2; unsigned int cnt,cnt2;
C4PXS *pxp; C4PXS *pxp;
// Check chunks for available space // Check chunks for available space
for (cnt=0; cnt<PXSMaxChunk; cnt++) for (cnt=0; cnt<PXSMaxChunk; cnt++)
{ {
// Create new chunk if necessary // Create new chunk if necessary
if (!Chunk[cnt]) if (!Chunk[cnt])
{ {
if (!(Chunk[cnt]=new C4PXS[PXSChunkSize])) return NULL; if (!(Chunk[cnt]=new C4PXS[PXSChunkSize])) return NULL;
iChunkPXS[cnt] = 0; iChunkPXS[cnt] = 0;
} }
// Check this chunk for space // Check this chunk for space
if(iChunkPXS[cnt] < PXSChunkSize) if(iChunkPXS[cnt] < PXSChunkSize)
for (cnt2=0,pxp=Chunk[cnt]; cnt2<PXSChunkSize; cnt2++,pxp++) for (cnt2=0,pxp=Chunk[cnt]; cnt2<PXSChunkSize; cnt2++,pxp++)
if (pxp->Mat==MNone) if (pxp->Mat==MNone)
@ -198,20 +198,20 @@ C4PXS* C4PXSSystem::New()
iChunkPXS[cnt]++; iChunkPXS[cnt]++;
return pxp; return pxp;
} }
} }
return NULL; return NULL;
} }
bool C4PXSSystem::Create(int32_t mat, FIXED ix, FIXED iy, FIXED ixdir, FIXED iydir) bool C4PXSSystem::Create(int32_t mat, FIXED ix, FIXED iy, FIXED ixdir, FIXED iydir)
{ {
C4PXS *pxp; C4PXS *pxp;
if (!MatValid(mat)) return false; if (!MatValid(mat)) return false;
if (!(pxp=New())) return false; if (!(pxp=New())) return false;
pxp->Mat=mat; pxp->Mat=mat;
pxp->x=ix; pxp->y=iy; pxp->x=ix; pxp->y=iy;
pxp->xdir=ixdir; pxp->ydir=iydir; pxp->xdir=ixdir; pxp->ydir=iydir;
return true; return true;
} }
void C4PXSSystem::Execute() void C4PXSSystem::Execute()
{ {
@ -316,17 +316,17 @@ void C4PXSSystem::Draw(C4TargetFacet &cgo)
} }
} }
} }
void C4PXSSystem::Cast(int32_t mat, int32_t num, int32_t tx, int32_t ty, int32_t level) void C4PXSSystem::Cast(int32_t mat, int32_t num, int32_t tx, int32_t ty, int32_t level)
{ {
int32_t cnt; int32_t cnt;
for (cnt=0; cnt<num; cnt++) for (cnt=0; cnt<num; cnt++)
Create(mat, Create(mat,
itofix(tx),itofix(ty), itofix(tx),itofix(ty),
itofix(Random(level+1)-level/2)/10, itofix(Random(level+1)-level/2)/10,
itofix(Random(level+1)-level)/10); itofix(Random(level+1)-level)/10);
} }
bool C4PXSSystem::Save(C4Group &hGroup) bool C4PXSSystem::Save(C4Group &hGroup)
{ {

View File

@ -25,16 +25,16 @@
#include <C4Material.h> #include <C4Material.h>
class C4PXS class C4PXS
{ {
C4PXS(): Mat(MNone), x(Fix0), y(Fix0), xdir(Fix0), ydir(Fix0) {} C4PXS(): Mat(MNone), x(Fix0), y(Fix0), xdir(Fix0), ydir(Fix0) {}
friend class C4PXSSystem; friend class C4PXSSystem;
protected: protected:
int32_t Mat; int32_t Mat;
FIXED x,y,xdir,ydir; FIXED x,y,xdir,ydir;
protected: protected:
void Execute(); void Execute();
void Deactivate(); void Deactivate();
}; };
const size_t PXSChunkSize=500,PXSMaxChunk=20; const size_t PXSChunkSize=500,PXSMaxChunk=20;

View File

@ -415,7 +415,7 @@ C4Particle *C4ParticleSystem::Create(C4ParticleDef *pOfDef,
float x, float y, float x, float y,
float xdir, float ydir, float xdir, float ydir,
float a, int32_t b, C4ParticleList *pPxList, float a, int32_t b, C4ParticleList *pPxList,
C4Object *pObj) C4Object *pObj)
{ {
// safety // safety
if (!pOfDef) return NULL; if (!pOfDef) return NULL;
@ -437,10 +437,10 @@ C4Particle *C4ParticleSystem::Create(C4ParticleDef *pOfDef,
pPrt->xdir=xdir; pPrt->ydir=ydir; pPrt->xdir=xdir; pPrt->ydir=ydir;
pPrt->a=a; pPrt->b=b; pPrt->a=a; pPrt->b=b;
pPrt->pDef = pOfDef; pPrt->pDef = pOfDef;
if(pPrt->pDef->Attach && pObj != NULL) { if(pPrt->pDef->Attach && pObj != NULL) {
pPrt->x -= pObj->GetX(); pPrt->x -= pObj->GetX();
pPrt->y -= pObj->GetY(); pPrt->y -= pObj->GetY();
} }
// call initialization // call initialization
if (!pOfDef->InitProc(pPrt,pObj)) if (!pOfDef->InitProc(pPrt,pObj))
// failed :( // failed :(
@ -651,16 +651,16 @@ bool fxStdInit(C4Particle *pPrt, C4Object *pTarget)
bool fxStdExec(C4Particle *pPrt, C4Object *pTarget) bool fxStdExec(C4Particle *pPrt, C4Object *pTarget)
{ {
float dx = pPrt->x, dy = pPrt->y; float dx = pPrt->x, dy = pPrt->y;
float dxdir = pPrt->xdir, dydir = pPrt->ydir; float dxdir = pPrt->xdir, dydir = pPrt->ydir;
// rel. position & movement // rel. position & movement
if(pPrt->pDef->Attach && pTarget != NULL) if(pPrt->pDef->Attach && pTarget != NULL)
{ {
dx += pTarget->GetX(); dx += pTarget->GetX();
dy += pTarget->GetY(); dy += pTarget->GetY();
dxdir += fixtof(pTarget->xdir); dxdir += fixtof(pTarget->xdir);
dydir += fixtof(pTarget->ydir); dydir += fixtof(pTarget->ydir);
} }
// move // move
if (pPrt->xdir || pPrt->ydir) if (pPrt->xdir || pPrt->ydir)
@ -779,16 +779,16 @@ void fxStdDraw(C4Particle *pPrt, C4TargetFacet &cgo, C4Object *pTarget)
int32_t tx=cgo.TargetX*pDef->Parallaxity[0]/100; int32_t tx=cgo.TargetX*pDef->Parallaxity[0]/100;
int32_t ty=cgo.TargetY*pDef->Parallaxity[1]/100; int32_t ty=cgo.TargetY*pDef->Parallaxity[1]/100;
float dx = pPrt->x, dy = pPrt->y; float dx = pPrt->x, dy = pPrt->y;
float dxdir = pPrt->xdir, dydir = pPrt->ydir; float dxdir = pPrt->xdir, dydir = pPrt->ydir;
// relative position & movement // relative position & movement
if(pPrt->pDef->Attach && pTarget != NULL) if(pPrt->pDef->Attach && pTarget != NULL)
{ {
dx += pTarget->GetX(); dx += pTarget->GetX();
dy += pTarget->GetY(); dy += pTarget->GetY();
dxdir += fixtof(pTarget->xdir); dxdir += fixtof(pTarget->xdir);
dydir += fixtof(pTarget->ydir); dydir += fixtof(pTarget->ydir);
} }
// check if it's in screen range // check if it's in screen range
if (!Inside(dx, tx-pPrt->a, tx+cgo.Wdt+pPrt->a)) return; if (!Inside(dx, tx-pPrt->a, tx+cgo.Wdt+pPrt->a)) return;

View File

@ -22,7 +22,7 @@
/* Notes /* Notes
09-30-99 09-30-99
I have had the concept for this code for more than two years now. I have had the concept for this code for more than two years now.
Finally, it is written. Finally, it is written.
@ -287,15 +287,15 @@ void C4PathFinderRay::Draw(C4TargetFacet &cgo)
bool C4PathFinderRay::PathFree(int32_t &rX, int32_t &rY, int32_t iToX, int32_t iToY, C4TransferZone **ppZone) bool C4PathFinderRay::PathFree(int32_t &rX, int32_t &rY, int32_t iToX, int32_t iToY, C4TransferZone **ppZone)
{ {
int32_t d,dx,dy,aincr,bincr,xincr,yincr,x,y; int32_t d,dx,dy,aincr,bincr,xincr,yincr,x,y;
// Y based // Y based
if (Abs(iToX-rX)<Abs(iToY-rY)) if (Abs(iToX-rX)<Abs(iToY-rY))
{ {
xincr=(iToX>rX) ? +1 : -1; yincr=(iToY>rY) ? +1 : -1; xincr=(iToX>rX) ? +1 : -1; yincr=(iToY>rY) ? +1 : -1;
dy=Abs(iToY-rY); dx=Abs(iToX-rX); dy=Abs(iToY-rY); dx=Abs(iToX-rX);
d=2*dx-dy; aincr=2*(dx-dy); bincr=2*dx; x=rX; y=rY; d=2*dx-dy; aincr=2*(dx-dy); bincr=2*dx; x=rX; y=rY;
for (y=rY; y!=iToY; y+=yincr) for (y=rY; y!=iToY; y+=yincr)
{ {
// Check point free // Check point free
if (PointFree(x,y)) { rY=y; rX=x; } else return false; if (PointFree(x,y)) { rY=y; rX=x; } else return false;
// Check transfer zone intersection // Check transfer zone intersection
@ -305,17 +305,17 @@ bool C4PathFinderRay::PathFree(int32_t &rX, int32_t &rY, int32_t iToX, int32_t i
if ((*ppZone = pPathFinder->TransferZones->Find(rX,rY))) if ((*ppZone = pPathFinder->TransferZones->Find(rX,rY)))
return false; return false;
// Advance // Advance
if (d>=0) { x+=xincr; d+=aincr; } else d+=bincr; if (d>=0) { x+=xincr; d+=aincr; } else d+=bincr;
} }
} }
// X based // X based
else else
{ {
yincr=(iToY>rY) ? +1 : -1; xincr=(iToX>rX) ? +1 : -1; yincr=(iToY>rY) ? +1 : -1; xincr=(iToX>rX) ? +1 : -1;
dx=Abs(iToX-rX); dy=Abs(iToY-rY); dx=Abs(iToX-rX); dy=Abs(iToY-rY);
d=2*dy-dx; aincr=2*(dy-dx); bincr=2*dy; x=rX; y=rY; d=2*dy-dx; aincr=2*(dy-dx); bincr=2*dy; x=rX; y=rY;
for (x=rX; x!=iToX; x+=xincr) for (x=rX; x!=iToX; x+=xincr)
{ {
// Check point free // Check point free
if (PointFree(x,y)) { rY=y; rX=x; } else return false; if (PointFree(x,y)) { rY=y; rX=x; } else return false;
// Check transfer zone intersection // Check transfer zone intersection
@ -325,42 +325,42 @@ bool C4PathFinderRay::PathFree(int32_t &rX, int32_t &rY, int32_t iToX, int32_t i
if ((*ppZone = pPathFinder->TransferZones->Find(rX,rY))) if ((*ppZone = pPathFinder->TransferZones->Find(rX,rY)))
return false; return false;
// Advance // Advance
if (d>=0) { y+=yincr; d+=aincr; } else d+=bincr; if (d>=0) { y+=yincr; d+=aincr; } else d+=bincr;
} }
} }
return true; return true;
} }
/*void C4PathFinderRay::DrawLine(SURFACE sfcSurface, int32_t rX, int32_t rY, int32_t iToX, int32_t iToY, BYTE byCol) /*void C4PathFinderRay::DrawLine(SURFACE sfcSurface, int32_t rX, int32_t rY, int32_t iToX, int32_t iToY, BYTE byCol)
{ {
int32_t d,dx,dy,aincr,bincr,xincr,yincr,x,y; int32_t d,dx,dy,aincr,bincr,xincr,yincr,x,y;
// Y based // Y based
if (Abs(iToX-rX)<Abs(iToY-rY)) if (Abs(iToX-rX)<Abs(iToY-rY))
{ {
xincr=(iToX>rX) ? +1 : -1; xincr=(iToX>rX) ? +1 : -1;
yincr=(iToY>rY) ? +1 : -1; yincr=(iToY>rY) ? +1 : -1;
dy=Abs(iToY-rY); dx=Abs(iToX-rX); dy=Abs(iToY-rY); dx=Abs(iToX-rX);
d=2*dx-dy; aincr=2*(dx-dy); bincr=2*dx; x=rX; y=rY; d=2*dx-dy; aincr=2*(dx-dy); bincr=2*dx; x=rX; y=rY;
for (y=rY; y!=iToY; y+=yincr) for (y=rY; y!=iToY; y+=yincr)
{ {
Application.DDraw->SetPixel(sfcSurface,x,y,byCol); Application.DDraw->SetPixel(sfcSurface,x,y,byCol);
if (d>=0) { x+=xincr; d+=aincr; } else d+=bincr; if (d>=0) { x+=xincr; d+=aincr; } else d+=bincr;
} }
} }
// X based // X based
else else
{ {
yincr=(iToY>rY) ? +1 : -1; yincr=(iToY>rY) ? +1 : -1;
xincr=(iToX>rX) ? +1 : -1; xincr=(iToX>rX) ? +1 : -1;
dx=Abs(iToX-rX); dy=Abs(iToY-rY); dx=Abs(iToX-rX); dy=Abs(iToY-rY);
d=2*dy-dx; aincr=2*(dy-dx); bincr=2*dy; x=rX; y=rY; d=2*dy-dx; aincr=2*(dy-dx); bincr=2*dy; x=rX; y=rY;
for (x=rX; x!=iToX; x+=xincr) for (x=rX; x!=iToX; x+=xincr)
{ {
Application.DDraw->SetPixel(sfcSurface,x,y,byCol); Application.DDraw->SetPixel(sfcSurface,x,y,byCol);
if (d>=0) { y+=yincr; d+=aincr; } else d+=bincr; if (d>=0) { y+=yincr; d+=aincr; } else d+=bincr;
} }
} }
}*/ }*/

View File

@ -33,19 +33,19 @@
//==================================== C4SVal ============================================== //==================================== C4SVal ==============================================
C4SVal::C4SVal(int32_t std, int32_t rnd, int32_t min, int32_t max) C4SVal::C4SVal(int32_t std, int32_t rnd, int32_t min, int32_t max)
: Std(std), Rnd(rnd), Min(min), Max(max) : Std(std), Rnd(rnd), Min(min), Max(max)
{ {
} }
void C4SVal::Set(int32_t std, int32_t rnd, int32_t min, int32_t max) void C4SVal::Set(int32_t std, int32_t rnd, int32_t min, int32_t max)
{ {
Std=std; Rnd=rnd; Min=min; Max=max; Std=std; Rnd=rnd; Min=min; Max=max;
} }
int32_t C4SVal::Evaluate() int32_t C4SVal::Evaluate()
{ {
return BoundBy(Std+Random(2*Rnd+1)-Rnd,Min,Max); return BoundBy(Std+Random(2*Rnd+1)-Rnd,Min,Max);
} }
void C4SVal::Default() void C4SVal::Default()
{ {
@ -53,39 +53,39 @@ void C4SVal::Default()
} }
void C4SVal::CompileFunc(StdCompiler *pComp) void C4SVal::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkDefaultAdapt(Std, 0)); pComp->Value(mkDefaultAdapt(Std, 0));
if (!pComp->Seperator()) return; if (!pComp->Seperator()) return;
pComp->Value(mkDefaultAdapt(Rnd, 0)); pComp->Value(mkDefaultAdapt(Rnd, 0));
if (!pComp->Seperator()) return; if (!pComp->Seperator()) return;
pComp->Value(mkDefaultAdapt(Min, 0)); pComp->Value(mkDefaultAdapt(Min, 0));
if (!pComp->Seperator()) return; if (!pComp->Seperator()) return;
pComp->Value(mkDefaultAdapt(Max, 100)); pComp->Value(mkDefaultAdapt(Max, 100));
} }
//================================ C4Scenario ========================================== //================================ C4Scenario ==========================================
C4Scenario::C4Scenario() C4Scenario::C4Scenario()
{ {
Default(); Default();
} }
void C4Scenario::Default() void C4Scenario::Default()
{ {
int32_t cnt; int32_t cnt;
Head.Default(); Head.Default();
Definitions.Default(); Definitions.Default();
Game.Default(); Game.Default();
for (cnt=0; cnt<C4S_MaxPlayer; cnt++) PlrStart[cnt].Default(); for (cnt=0; cnt<C4S_MaxPlayer; cnt++) PlrStart[cnt].Default();
Landscape.Default(); Landscape.Default();
Animals.Default(); Animals.Default();
Weather.Default(); Weather.Default();
Game.Realism.Default(); Game.Realism.Default();
Environment.Default(); Environment.Default();
} }
bool C4Scenario::Load(C4Group &hGroup, bool fLoadSection) bool C4Scenario::Load(C4Group &hGroup, bool fLoadSection)
{ {
char *pSource; char *pSource;
// Load // Load
if (!hGroup.LoadEntry(C4CFN_ScenarioCore,&pSource,NULL,1)) return false; if (!hGroup.LoadEntry(C4CFN_ScenarioCore,&pSource,NULL,1)) return false;
@ -94,7 +94,7 @@ bool C4Scenario::Load(C4Group &hGroup, bool fLoadSection)
delete [] pSource; delete [] pSource;
// Success // Success
return true; return true;
} }
bool C4Scenario::Save(C4Group &hGroup, bool fSaveSection) bool C4Scenario::Save(C4Group &hGroup, bool fSaveSection)
{ {
@ -107,17 +107,17 @@ bool C4Scenario::Save(C4Group &hGroup, bool fSaveSection)
} }
void C4Scenario::CompileFunc(StdCompiler *pComp, bool fSection) void C4Scenario::CompileFunc(StdCompiler *pComp, bool fSection)
{ {
pComp->Value(mkNamingAdapt(mkParAdapt(Head, fSection), "Head")); pComp->Value(mkNamingAdapt(mkParAdapt(Head, fSection), "Head"));
if (!fSection) pComp->Value(mkNamingAdapt(Definitions, "Definitions")); if (!fSection) pComp->Value(mkNamingAdapt(Definitions, "Definitions"));
pComp->Value(mkNamingAdapt(mkParAdapt(Game, fSection), "Game")); pComp->Value(mkNamingAdapt(mkParAdapt(Game, fSection), "Game"));
for(int32_t i = 0; i < C4S_MaxPlayer; i++) for(int32_t i = 0; i < C4S_MaxPlayer; i++)
pComp->Value(mkNamingAdapt(PlrStart[i], FormatString("Player%d", i+1).getData())); pComp->Value(mkNamingAdapt(PlrStart[i], FormatString("Player%d", i+1).getData()));
pComp->Value(mkNamingAdapt(Landscape, "Landscape")); pComp->Value(mkNamingAdapt(Landscape, "Landscape"));
pComp->Value(mkNamingAdapt(Animals, "Animals")); pComp->Value(mkNamingAdapt(Animals, "Animals"));
pComp->Value(mkNamingAdapt(Weather, "Weather")); pComp->Value(mkNamingAdapt(Weather, "Weather"));
pComp->Value(mkNamingAdapt(Environment, "Environment")); pComp->Value(mkNamingAdapt(Environment, "Environment"));
} }
int32_t C4Scenario::GetMinPlayer() int32_t C4Scenario::GetMinPlayer()
{ {
@ -132,7 +132,7 @@ int32_t C4Scenario::GetMinPlayer()
} }
void C4SDefinitions::Default() void C4SDefinitions::Default()
{ {
LocalOnly=AllowUserChange=false; LocalOnly=AllowUserChange=false;
ZeroMem(Definition,sizeof (Definition)); ZeroMem(Definition,sizeof (Definition));
SkipDefs.Default(); SkipDefs.Default();
@ -141,7 +141,7 @@ void C4SDefinitions::Default()
const int32_t C4S_MaxPlayerDefault = 12; const int32_t C4S_MaxPlayerDefault = 12;
void C4SHead::Default() void C4SHead::Default()
{ {
Origin.Clear(); Origin.Clear();
Icon=18; Icon=18;
*Title = *Loader = *Font = *Engine = *MissionAccess = '\0'; *Title = *Loader = *Font = *Engine = *MissionAccess = '\0';
@ -153,10 +153,10 @@ void C4SHead::Default()
MaxPlayer=MaxPlayerLeague=C4S_MaxPlayerDefault; MaxPlayer=MaxPlayerLeague=C4S_MaxPlayerDefault;
MinPlayer=0; // auto-determine by mode MinPlayer=0; // auto-determine by mode
SCopy("Default Title",Title,C4MaxTitle); SCopy("Default Title",Title,C4MaxTitle);
} }
void C4SHead::CompileFunc(StdCompiler *pComp, bool fSection) void C4SHead::CompileFunc(StdCompiler *pComp, bool fSection)
{ {
if (!fSection) if (!fSection)
{ {
pComp->Value(mkNamingAdapt(Icon, "Icon", 18)); pComp->Value(mkNamingAdapt(Icon, "Icon", 18));
@ -187,17 +187,17 @@ void C4SHead::CompileFunc(StdCompiler *pComp, bool fSection)
// windows needs backslashes in Origin; other systems use forward slashes // windows needs backslashes in Origin; other systems use forward slashes
if (pComp->isCompiler()) Origin.ReplaceChar(AltDirectorySeparator, DirectorySeparator); if (pComp->isCompiler()) Origin.ReplaceChar(AltDirectorySeparator, DirectorySeparator);
} }
} }
void C4SGame::Default() void C4SGame::Default()
{ {
Goals.Clear(); Goals.Clear();
Rules.Clear(); Rules.Clear();
FoWColor=0; FoWColor=0;
} }
void C4SGame::CompileFunc(StdCompiler *pComp, bool fSection) void C4SGame::CompileFunc(StdCompiler *pComp, bool fSection)
{ {
if (!fSection) if (!fSection)
{ {
pComp->Value(mkNamingAdapt(Realism.ValueOverloads, "ValueOverloads", C4IDList())); pComp->Value(mkNamingAdapt(Realism.ValueOverloads, "ValueOverloads", C4IDList()));
@ -205,27 +205,27 @@ void C4SGame::CompileFunc(StdCompiler *pComp, bool fSection)
pComp->Value(mkNamingAdapt(mkRuntimeValueAdapt(Realism.LandscapePushPull), "LandscapePushPull", false)); pComp->Value(mkNamingAdapt(mkRuntimeValueAdapt(Realism.LandscapePushPull), "LandscapePushPull", false));
pComp->Value(mkNamingAdapt(mkRuntimeValueAdapt(Realism.LandscapeInsertThrust), "LandscapeInsertThrust",true)); pComp->Value(mkNamingAdapt(mkRuntimeValueAdapt(Realism.LandscapeInsertThrust), "LandscapeInsertThrust",true));
pComp->Value(mkNamingAdapt(Goals, "Goals", C4IDList())); pComp->Value(mkNamingAdapt(Goals, "Goals", C4IDList()));
pComp->Value(mkNamingAdapt(Rules, "Rules", C4IDList())); pComp->Value(mkNamingAdapt(Rules, "Rules", C4IDList()));
pComp->Value(mkNamingAdapt(FoWColor, "FoWColor", 0u)); pComp->Value(mkNamingAdapt(FoWColor, "FoWColor", 0u));
} }
void C4SPlrStart::Default() void C4SPlrStart::Default()
{ {
NativeCrew=C4ID::None; NativeCrew=C4ID::None;
Crew.Set(1,0,1,10); Crew.Set(1,0,1,10);
Wealth.Set(0,0,0,250); Wealth.Set(0,0,0,250);
Position[0]=Position[1]=-1; Position[0]=Position[1]=-1;
EnforcePosition=0; EnforcePosition=0;
ReadyCrew.Default(); ReadyCrew.Default();
ReadyBase.Default(); ReadyBase.Default();
ReadyVehic.Default(); ReadyVehic.Default();
ReadyMaterial.Default(); ReadyMaterial.Default();
BuildKnowledge.Default(); BuildKnowledge.Default();
HomeBaseMaterial.Default(); HomeBaseMaterial.Default();
HomeBaseProduction.Default(); HomeBaseProduction.Default();
Magic.Default(); Magic.Default();
} }
bool C4SPlrStart::EquipmentEqual(C4SPlrStart &rhs) bool C4SPlrStart::EquipmentEqual(C4SPlrStart &rhs)
{ {
@ -248,44 +248,44 @@ bool C4SPlrStart::operator==(const C4SPlrStart& rhs)
} }
void C4SPlrStart::CompileFunc(StdCompiler *pComp) void C4SPlrStart::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(NativeCrew, "StandardCrew", C4ID::None)); pComp->Value(mkNamingAdapt(NativeCrew, "StandardCrew", C4ID::None));
pComp->Value(mkNamingAdapt(Crew, "Clonks", C4SVal(1, 0, 1, 10), true)); pComp->Value(mkNamingAdapt(Crew, "Clonks", C4SVal(1, 0, 1, 10), true));
pComp->Value(mkNamingAdapt(Wealth, "Wealth", C4SVal(0, 0, 0,250), true)); pComp->Value(mkNamingAdapt(Wealth, "Wealth", C4SVal(0, 0, 0,250), true));
pComp->Value(mkNamingAdapt(mkArrayAdaptDM(Position,-1), "Position" )); pComp->Value(mkNamingAdapt(mkArrayAdaptDM(Position,-1), "Position" ));
pComp->Value(mkNamingAdapt(EnforcePosition, "EnforcePosition", 0)); pComp->Value(mkNamingAdapt(EnforcePosition, "EnforcePosition", 0));
pComp->Value(mkNamingAdapt(ReadyCrew, "Crew", C4IDList())); pComp->Value(mkNamingAdapt(ReadyCrew, "Crew", C4IDList()));
pComp->Value(mkNamingAdapt(ReadyBase, "Buildings", C4IDList())); pComp->Value(mkNamingAdapt(ReadyBase, "Buildings", C4IDList()));
pComp->Value(mkNamingAdapt(ReadyVehic, "Vehicles", C4IDList())); pComp->Value(mkNamingAdapt(ReadyVehic, "Vehicles", C4IDList()));
pComp->Value(mkNamingAdapt(ReadyMaterial, "Material", C4IDList())); pComp->Value(mkNamingAdapt(ReadyMaterial, "Material", C4IDList()));
pComp->Value(mkNamingAdapt(BuildKnowledge, "Knowledge", C4IDList())); pComp->Value(mkNamingAdapt(BuildKnowledge, "Knowledge", C4IDList()));
pComp->Value(mkNamingAdapt(HomeBaseMaterial, "HomeBaseMaterial", C4IDList())); pComp->Value(mkNamingAdapt(HomeBaseMaterial, "HomeBaseMaterial", C4IDList()));
pComp->Value(mkNamingAdapt(HomeBaseProduction, "HomeBaseProduction", C4IDList())); pComp->Value(mkNamingAdapt(HomeBaseProduction, "HomeBaseProduction", C4IDList()));
pComp->Value(mkNamingAdapt(Magic, "Magic", C4IDList())); pComp->Value(mkNamingAdapt(Magic, "Magic", C4IDList()));
} }
void C4SLandscape::Default() void C4SLandscape::Default()
{ {
BottomOpen=0; TopOpen=1; BottomOpen=0; TopOpen=1;
LeftOpen=0; RightOpen=0; LeftOpen=0; RightOpen=0;
AutoScanSideOpen=1; AutoScanSideOpen=1;
SkyDef[0]=0; SkyDef[0]=0;
NoSky=0; NoSky=0;
for (int32_t cnt=0; cnt<6; cnt++) SkyDefFade[cnt]=0; for (int32_t cnt=0; cnt<6; cnt++) SkyDefFade[cnt]=0;
VegLevel.Set(50,30,0,100); VegLevel.Set(50,30,0,100);
Vegetation.Default(); Vegetation.Default();
InEarthLevel.Set(50,0,0,100); InEarthLevel.Set(50,0,0,100);
InEarth.Default(); InEarth.Default();
MapWdt.Set(100,0,64,250); MapWdt.Set(100,0,64,250);
MapHgt.Set(50,0,40,250); MapHgt.Set(50,0,40,250);
MapZoom.Set(10,0,5,15); MapZoom.Set(10,0,5,15);
Amplitude.Set(0,0); Amplitude.Set(0,0);
Phase.Set(50); Phase.Set(50);
Period.Set(15); Period.Set(15);
Random.Set(0); Random.Set(0);
LiquidLevel.Default(); LiquidLevel.Default();
MapPlayerExtend=0; MapPlayerExtend=0;
Layers.Clear(); Layers.Clear();
SCopy("Earth",Material,C4M_MaxName); SCopy("Earth",Material,C4M_MaxName);
SCopy("Water",Liquid,C4M_MaxName); SCopy("Water",Liquid,C4M_MaxName);
ExactLandscape=0; ExactLandscape=0;
@ -307,109 +307,109 @@ void C4SLandscape::GetMapSize(int32_t &rWdt, int32_t &rHgt, int32_t iPlayerNum)
} }
void C4SLandscape::CompileFunc(StdCompiler *pComp) void C4SLandscape::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(ExactLandscape, "ExactLandscape", false)); pComp->Value(mkNamingAdapt(ExactLandscape, "ExactLandscape", false));
pComp->Value(mkNamingAdapt(Vegetation, "Vegetation", C4IDList())); pComp->Value(mkNamingAdapt(Vegetation, "Vegetation", C4IDList()));
pComp->Value(mkNamingAdapt(VegLevel, "VegetationLevel", C4SVal(50,30,0,100), true)); pComp->Value(mkNamingAdapt(VegLevel, "VegetationLevel", C4SVal(50,30,0,100), true));
pComp->Value(mkNamingAdapt(InEarth, "InEarth", C4IDList())); pComp->Value(mkNamingAdapt(InEarth, "InEarth", C4IDList()));
pComp->Value(mkNamingAdapt(InEarthLevel, "InEarthLevel", C4SVal(50,0,0,100), true)); pComp->Value(mkNamingAdapt(InEarthLevel, "InEarthLevel", C4SVal(50,0,0,100), true));
pComp->Value(mkNamingAdapt(mkStringAdaptMA(SkyDef), "Sky", "")); pComp->Value(mkNamingAdapt(mkStringAdaptMA(SkyDef), "Sky", ""));
pComp->Value(mkNamingAdapt(mkArrayAdaptDM(SkyDefFade,0),"SkyFade" )); pComp->Value(mkNamingAdapt(mkArrayAdaptDM(SkyDefFade,0),"SkyFade" ));
pComp->Value(mkNamingAdapt(NoSky, "NoSky", false)); pComp->Value(mkNamingAdapt(NoSky, "NoSky", false));
pComp->Value(mkNamingAdapt(BottomOpen, "BottomOpen", false)); pComp->Value(mkNamingAdapt(BottomOpen, "BottomOpen", false));
pComp->Value(mkNamingAdapt(TopOpen, "TopOpen", true)); pComp->Value(mkNamingAdapt(TopOpen, "TopOpen", true));
pComp->Value(mkNamingAdapt(LeftOpen, "LeftOpen", 0)); pComp->Value(mkNamingAdapt(LeftOpen, "LeftOpen", 0));
pComp->Value(mkNamingAdapt(RightOpen, "RightOpen", 0)); pComp->Value(mkNamingAdapt(RightOpen, "RightOpen", 0));
pComp->Value(mkNamingAdapt(AutoScanSideOpen, "AutoScanSideOpen", true)); pComp->Value(mkNamingAdapt(AutoScanSideOpen, "AutoScanSideOpen", true));
pComp->Value(mkNamingAdapt(MapWdt, "MapWidth", C4SVal(100,0,64,250), true)); pComp->Value(mkNamingAdapt(MapWdt, "MapWidth", C4SVal(100,0,64,250), true));
pComp->Value(mkNamingAdapt(MapHgt, "MapHeight", C4SVal(50,0,40,250), true)); pComp->Value(mkNamingAdapt(MapHgt, "MapHeight", C4SVal(50,0,40,250), true));
pComp->Value(mkNamingAdapt(MapZoom, "MapZoom", C4SVal(10,0,5,15), true)); pComp->Value(mkNamingAdapt(MapZoom, "MapZoom", C4SVal(10,0,5,15), true));
pComp->Value(mkNamingAdapt(Amplitude, "Amplitude", C4SVal(0))); pComp->Value(mkNamingAdapt(Amplitude, "Amplitude", C4SVal(0)));
pComp->Value(mkNamingAdapt(Phase, "Phase", C4SVal(50))); pComp->Value(mkNamingAdapt(Phase, "Phase", C4SVal(50)));
pComp->Value(mkNamingAdapt(Period, "Period", C4SVal(15))); pComp->Value(mkNamingAdapt(Period, "Period", C4SVal(15)));
pComp->Value(mkNamingAdapt(Random, "Random", C4SVal(0))); pComp->Value(mkNamingAdapt(Random, "Random", C4SVal(0)));
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Material),"Material", "Earth")); pComp->Value(mkNamingAdapt(mkStringAdaptMA(Material),"Material", "Earth"));
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Liquid), "Liquid", "Water")); pComp->Value(mkNamingAdapt(mkStringAdaptMA(Liquid), "Liquid", "Water"));
pComp->Value(mkNamingAdapt(LiquidLevel, "LiquidLevel", C4SVal())); pComp->Value(mkNamingAdapt(LiquidLevel, "LiquidLevel", C4SVal()));
pComp->Value(mkNamingAdapt(MapPlayerExtend, "MapPlayerExtend", 0)); pComp->Value(mkNamingAdapt(MapPlayerExtend, "MapPlayerExtend", 0));
pComp->Value(mkNamingAdapt(Layers, "Layers", C4NameList())); pComp->Value(mkNamingAdapt(Layers, "Layers", C4NameList()));
pComp->Value(mkNamingAdapt(Gravity, "Gravity", C4SVal(100,0,10,200), true)); pComp->Value(mkNamingAdapt(Gravity, "Gravity", C4SVal(100,0,10,200), true));
pComp->Value(mkNamingAdapt(NoScan, "NoScan", false)); pComp->Value(mkNamingAdapt(NoScan, "NoScan", false));
pComp->Value(mkNamingAdapt(KeepMapCreator, "KeepMapCreator", false)); pComp->Value(mkNamingAdapt(KeepMapCreator, "KeepMapCreator", false));
pComp->Value(mkNamingAdapt(SkyScrollMode, "SkyScrollMode", 0)); pComp->Value(mkNamingAdapt(SkyScrollMode, "SkyScrollMode", 0));
pComp->Value(mkNamingAdapt(NewStyleLandscape, "NewStyleLandscape", false)); pComp->Value(mkNamingAdapt(NewStyleLandscape, "NewStyleLandscape", false));
pComp->Value(mkNamingAdapt(FoWRes, "FoWRes", static_cast<int32_t>(CClrModAddMap::DefResolutionX))); pComp->Value(mkNamingAdapt(FoWRes, "FoWRes", static_cast<int32_t>(CClrModAddMap::DefResolutionX)));
} }
void C4SWeather::Default() void C4SWeather::Default()
{ {
Climate.Set(50,10); Climate.Set(50,10);
StartSeason.Set(50,50); StartSeason.Set(50,50);
YearSpeed.Set(50); YearSpeed.Set(50);
Rain.Default(); Wind.Set(0,70,-100,+100); Rain.Default(); Wind.Set(0,70,-100,+100);
SCopy("Water",Precipitation,C4M_MaxName); SCopy("Water",Precipitation,C4M_MaxName);
NoGamma=1; NoGamma=1;
} }
void C4SWeather::CompileFunc(StdCompiler *pComp) void C4SWeather::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(Climate, "Climate", C4SVal(50,10), true)); pComp->Value(mkNamingAdapt(Climate, "Climate", C4SVal(50,10), true));
pComp->Value(mkNamingAdapt(StartSeason, "StartSeason", C4SVal(50,50), true)); pComp->Value(mkNamingAdapt(StartSeason, "StartSeason", C4SVal(50,50), true));
pComp->Value(mkNamingAdapt(YearSpeed, "YearSpeed", C4SVal(50))); pComp->Value(mkNamingAdapt(YearSpeed, "YearSpeed", C4SVal(50)));
pComp->Value(mkNamingAdapt(Rain, "Rain", C4SVal())); pComp->Value(mkNamingAdapt(Rain, "Rain", C4SVal()));
pComp->Value(mkNamingAdapt(Wind, "Wind", C4SVal(0,70,-100,+100), true)); pComp->Value(mkNamingAdapt(Wind, "Wind", C4SVal(0,70,-100,+100), true));
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Precipitation),"Precipitation", "Water")); pComp->Value(mkNamingAdapt(mkStringAdaptMA(Precipitation),"Precipitation", "Water"));
pComp->Value(mkNamingAdapt(NoGamma, "NoGamma", true)); pComp->Value(mkNamingAdapt(NoGamma, "NoGamma", true));
} }
void C4SAnimals::Default() void C4SAnimals::Default()
{ {
FreeLife.Clear(); FreeLife.Clear();
EarthNest.Clear(); EarthNest.Clear();
} }
void C4SAnimals::CompileFunc(StdCompiler *pComp) void C4SAnimals::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(FreeLife, "Animal", C4IDList())); pComp->Value(mkNamingAdapt(FreeLife, "Animal", C4IDList()));
pComp->Value(mkNamingAdapt(EarthNest, "Nest", C4IDList())); pComp->Value(mkNamingAdapt(EarthNest, "Nest", C4IDList()));
} }
void C4SEnvironment::Default() void C4SEnvironment::Default()
{ {
Objects.Clear(); Objects.Clear();
} }
void C4SEnvironment::CompileFunc(StdCompiler *pComp) void C4SEnvironment::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(Objects, "Objects", C4IDList())); pComp->Value(mkNamingAdapt(Objects, "Objects", C4IDList()));
} }
void C4SRealism::Default() void C4SRealism::Default()
{ {
LandscapePushPull=0; LandscapePushPull=0;
LandscapeInsertThrust=0; LandscapeInsertThrust=0;
ValueOverloads.Default(); ValueOverloads.Default();
} }
bool C4Scenario::Compile(const char *szSource, bool fLoadSection) bool C4Scenario::Compile(const char *szSource, bool fLoadSection)
{ {
if (!fLoadSection) Default(); if (!fLoadSection) Default();
return CompileFromBuf_LogWarn<StdCompilerINIRead>(mkParAdapt(*this, fLoadSection), StdStrBuf(szSource), C4CFN_ScenarioCore); return CompileFromBuf_LogWarn<StdCompilerINIRead>(mkParAdapt(*this, fLoadSection), StdStrBuf(szSource), C4CFN_ScenarioCore);
} }
bool C4Scenario::Decompile(char **ppOutput, int32_t *ipSize, bool fSaveSection) bool C4Scenario::Decompile(char **ppOutput, int32_t *ipSize, bool fSaveSection)
{ {
try try
{ {
// Decompile // Decompile
StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkParAdapt(*this, fSaveSection)); StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkParAdapt(*this, fSaveSection));
// Return // Return
*ppOutput = Buf.GrabPointer(); *ppOutput = Buf.GrabPointer();
*ipSize = Buf.getSize(); *ipSize = Buf.getSize();
} }
catch(StdCompiler::Exception *) catch(StdCompiler::Exception *)
{ return false; } { return false; }
return true; return true;
} }
void C4Scenario::Clear() void C4Scenario::Clear()
@ -522,13 +522,13 @@ bool C4SDefinitions::AssertModules(const char *szPath, char *sMissing)
} }
void C4SDefinitions::CompileFunc(StdCompiler *pComp) void C4SDefinitions::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(LocalOnly, "LocalOnly", false)); pComp->Value(mkNamingAdapt(LocalOnly, "LocalOnly", false));
pComp->Value(mkNamingAdapt(AllowUserChange, "AllowUserChange", false)); pComp->Value(mkNamingAdapt(AllowUserChange, "AllowUserChange", false));
for(int32_t i = 0; i < C4S_MaxDefinitions; i++) for(int32_t i = 0; i < C4S_MaxDefinitions; i++)
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Definition[i]), FormatString("Definition%i", i+1).getData(), "")); pComp->Value(mkNamingAdapt(mkStringAdaptMA(Definition[i]), FormatString("Definition%i", i+1).getData(), ""));
pComp->Value(mkNamingAdapt(SkipDefs, "SkipDefs", C4IDList())); pComp->Value(mkNamingAdapt(SkipDefs, "SkipDefs", C4IDList()));
} }
bool C4SGame::IsMelee() bool C4SGame::IsMelee()
{ {

View File

@ -29,22 +29,22 @@
class C4Group; class C4Group;
class C4SVal class C4SVal
{ {
public: public:
C4SVal(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100); C4SVal(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100);
public: public:
int32_t Std,Rnd,Min,Max; int32_t Std,Rnd,Min,Max;
public: public:
void Default(); void Default();
void Set(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100); void Set(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100);
int32_t Evaluate(); int32_t Evaluate();
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
public: public:
inline bool operator==(const C4SVal &rhs) const inline bool operator==(const C4SVal &rhs) const
{ {
return rhs.Std == Std && rhs.Rnd == Rnd && rhs.Min == Min && rhs.Max == Max; return rhs.Std == Std && rhs.Rnd == Rnd && rhs.Min == Min && rhs.Max == Max;
} }
}; };
#define C4SGFXMODE_NEWGFX 1 #define C4SGFXMODE_NEWGFX 1
#define C4SGFXMODE_OLDGFX 2 #define C4SGFXMODE_OLDGFX 2
@ -71,12 +71,12 @@ enum C4SFilmMode
}; };
class C4SHead class C4SHead
{ {
public: public:
int32_t C4XVer[4]; int32_t C4XVer[4];
char Title[C4MaxTitle+1]; char Title[C4MaxTitle+1];
char Loader[C4MaxTitle+1]; char Loader[C4MaxTitle+1];
char Font[C4MaxTitle+1]; // scenario specific font; may be 0 char Font[C4MaxTitle+1]; // scenario specific font; may be 0
int32_t Difficulty; int32_t Difficulty;
int32_t Icon; int32_t Icon;
int32_t NoInitialize; int32_t NoInitialize;
@ -93,10 +93,10 @@ class C4SHead
int32_t ForcedFairCrew; // 0: free; 1: force FairCrew; 2: force normal Crew (C4SForceFairCrew) int32_t ForcedFairCrew; // 0: free; 1: force FairCrew; 2: force normal Crew (C4SForceFairCrew)
int32_t FairCrewStrength; int32_t FairCrewStrength;
StdCopyStrBuf Origin; // original oath and filename to scenario (for records and savegames) StdCopyStrBuf Origin; // original oath and filename to scenario (for records and savegames)
public: public:
void Default(); void Default();
void CompileFunc(StdCompiler *pComp, bool fSection); void CompileFunc(StdCompiler *pComp, bool fSection);
}; };
const int32_t C4S_MaxDefinitions = 10; const int32_t C4S_MaxDefinitions = 10;
@ -108,30 +108,30 @@ class C4SDefinitions
int32_t AllowUserChange; int32_t AllowUserChange;
char Definition[C4S_MaxDefinitions][_MAX_PATH+1]; char Definition[C4S_MaxDefinitions][_MAX_PATH+1];
C4IDList SkipDefs; C4IDList SkipDefs;
public: public:
void SetModules(const char *szList, const char *szRelativeToPath=NULL, const char *szRelativeToPath2=NULL); void SetModules(const char *szList, const char *szRelativeToPath=NULL, const char *szRelativeToPath2=NULL);
bool GetModules(StdStrBuf *psOutModules) const; bool GetModules(StdStrBuf *psOutModules) const;
bool AssertModules(const char *szPath=NULL, char *sMissing=NULL); bool AssertModules(const char *szPath=NULL, char *sMissing=NULL);
void Default(); void Default();
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
}; };
class C4SRealism class C4SRealism
{ {
public: public:
C4IDList ValueOverloads; C4IDList ValueOverloads;
int32_t LandscapePushPull; // Use new experimental push-pull-algorithms int32_t LandscapePushPull; // Use new experimental push-pull-algorithms
int32_t LandscapeInsertThrust; // Inserted material may thrust material of lower density aside int32_t LandscapeInsertThrust; // Inserted material may thrust material of lower density aside
public: public:
void Default(); void Default();
}; };
class C4SGame class C4SGame
{ {
public: public:
C4IDList Goals; C4IDList Goals;
C4IDList Rules; C4IDList Rules;
@ -139,10 +139,10 @@ class C4SGame
C4SRealism Realism; C4SRealism Realism;
public: public:
bool IsMelee(); bool IsMelee();
void Default(); void Default();
void CompileFunc(StdCompiler *pComp, bool fSection); void CompileFunc(StdCompiler *pComp, bool fSection);
}; };
// Maximum map player extend factor // Maximum map player extend factor
@ -150,120 +150,120 @@ class C4SGame
const int32_t C4S_MaxMapPlayerExtend = 4; const int32_t C4S_MaxMapPlayerExtend = 4;
class C4SPlrStart class C4SPlrStart
{ {
public: public:
C4ID NativeCrew; // Obsolete C4ID NativeCrew; // Obsolete
C4SVal Crew; // Obsolete C4SVal Crew; // Obsolete
C4SVal Wealth; C4SVal Wealth;
int32_t Position[2]; int32_t Position[2];
int32_t EnforcePosition; int32_t EnforcePosition;
C4IDList ReadyCrew; C4IDList ReadyCrew;
C4IDList ReadyBase; C4IDList ReadyBase;
C4IDList ReadyVehic; C4IDList ReadyVehic;
C4IDList ReadyMaterial; C4IDList ReadyMaterial;
C4IDList BuildKnowledge; C4IDList BuildKnowledge;
C4IDList HomeBaseMaterial; C4IDList HomeBaseMaterial;
C4IDList HomeBaseProduction; C4IDList HomeBaseProduction;
C4IDList Magic; C4IDList Magic;
public: public:
void Default(); void Default();
bool EquipmentEqual(C4SPlrStart &rhs); bool EquipmentEqual(C4SPlrStart &rhs);
bool operator==(const C4SPlrStart& rhs); bool operator==(const C4SPlrStart& rhs);
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
}; };
class C4SLandscape class C4SLandscape
{ {
public: public:
int32_t ExactLandscape; int32_t ExactLandscape;
C4SVal VegLevel; C4SVal VegLevel;
C4IDList Vegetation; C4IDList Vegetation;
C4SVal InEarthLevel; C4SVal InEarthLevel;
C4IDList InEarth; C4IDList InEarth;
int32_t BottomOpen,TopOpen; int32_t BottomOpen,TopOpen;
int32_t LeftOpen,RightOpen; int32_t LeftOpen,RightOpen;
int32_t AutoScanSideOpen; int32_t AutoScanSideOpen;
char SkyDef[C4MaxDefString+1]; char SkyDef[C4MaxDefString+1];
int32_t SkyDefFade[6]; int32_t SkyDefFade[6];
int32_t NoSky; int32_t NoSky;
int32_t NoScan; int32_t NoScan;
C4SVal Gravity; C4SVal Gravity;
// Dynamic map // Dynamic map
C4SVal MapWdt,MapHgt,MapZoom; C4SVal MapWdt,MapHgt,MapZoom;
C4SVal Amplitude,Phase,Period,Random; C4SVal Amplitude,Phase,Period,Random;
C4SVal LiquidLevel; C4SVal LiquidLevel;
int32_t MapPlayerExtend; int32_t MapPlayerExtend;
C4NameList Layers; C4NameList Layers;
char Material[C4M_MaxDefName+1]; char Material[C4M_MaxDefName+1];
char Liquid[C4M_MaxDefName+1]; char Liquid[C4M_MaxDefName+1];
int32_t KeepMapCreator; // set if the mapcreator will be needed in the scenario (for DrawDefMap) int32_t KeepMapCreator; // set if the mapcreator will be needed in the scenario (for DrawDefMap)
int32_t SkyScrollMode; // sky scrolling mode for newgfx int32_t SkyScrollMode; // sky scrolling mode for newgfx
int32_t NewStyleLandscape; // if set to 2, the landscape uses up to 125 mat/texture pairs int32_t NewStyleLandscape; // if set to 2, the landscape uses up to 125 mat/texture pairs
int32_t FoWRes; // chunk size of FoGOfWar int32_t FoWRes; // chunk size of FoGOfWar
public: public:
void Default(); void Default();
void GetMapSize(int32_t &rWdt, int32_t &rHgt, int32_t iPlayerNum); void GetMapSize(int32_t &rWdt, int32_t &rHgt, int32_t iPlayerNum);
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
}; };
class C4SWeather class C4SWeather
{ {
public: public:
C4SVal Climate; C4SVal Climate;
C4SVal StartSeason,YearSpeed; C4SVal StartSeason,YearSpeed;
C4SVal Rain,Wind; C4SVal Rain,Wind;
char Precipitation[C4M_MaxName+1]; char Precipitation[C4M_MaxName+1];
int32_t NoGamma; int32_t NoGamma;
public: public:
void Default(); void Default();
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
}; };
class C4SAnimals class C4SAnimals
{ {
public: public:
C4IDList FreeLife; C4IDList FreeLife;
C4IDList EarthNest; C4IDList EarthNest;
public: public:
void Default(); void Default();
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
}; };
class C4SEnvironment class C4SEnvironment
{ {
public: public:
C4IDList Objects; C4IDList Objects;
public: public:
void Default(); void Default();
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
}; };
class C4Scenario class C4Scenario
{ {
public: public:
C4Scenario(); C4Scenario();
public: public:
C4SHead Head; C4SHead Head;
C4SDefinitions Definitions; C4SDefinitions Definitions;
C4SGame Game; C4SGame Game;
C4SPlrStart PlrStart[C4S_MaxPlayer]; C4SPlrStart PlrStart[C4S_MaxPlayer];
C4SLandscape Landscape; C4SLandscape Landscape;
C4SAnimals Animals; C4SAnimals Animals;
C4SWeather Weather; C4SWeather Weather;
C4SEnvironment Environment; C4SEnvironment Environment;
public: public:
void SetExactLandscape(); void SetExactLandscape();
void Clear(); void Clear();
void Default(); void Default();
bool Load(C4Group &hGroup, bool fLoadSection=false); bool Load(C4Group &hGroup, bool fLoadSection=false);
bool Save(C4Group &hGroup, bool fSaveSection=false); bool Save(C4Group &hGroup, bool fSaveSection=false);
void CompileFunc(StdCompiler *pComp, bool fSection); void CompileFunc(StdCompiler *pComp, bool fSection);
int32_t GetMinPlayer(); // will try to determine the minimum player count for this scenario int32_t GetMinPlayer(); // will try to determine the minimum player count for this scenario
protected: protected:
bool Compile(const char *szSource, bool fLoadSection=false); bool Compile(const char *szSource, bool fLoadSection=false);
bool Decompile(char **ppOutput, int32_t *ipSize, bool fSaveSection=false); bool Decompile(char **ppOutput, int32_t *ipSize, bool fSaveSection=false);
}; };
class C4ScenarioSection; class C4ScenarioSection;

View File

@ -60,21 +60,21 @@ static bool SurfaceEnsureSize(C4Surface **ppSfc, int iMinWdt, int iMinHgt)
} }
void C4Sky::SetFadePalette(int32_t *ipColors) void C4Sky::SetFadePalette(int32_t *ipColors)
{ {
// If colors all zero, use game palette default blue // If colors all zero, use game palette default blue
if (ipColors[0]+ipColors[1]+ipColors[2]+ipColors[3]+ipColors[4]+ipColors[5]==0) if (ipColors[0]+ipColors[1]+ipColors[2]+ipColors[3]+ipColors[4]+ipColors[5]==0)
{ {
BYTE *pClr=::GraphicsResource.GamePalette+3*CSkyDef1; BYTE *pClr=::GraphicsResource.GamePalette+3*CSkyDef1;
FadeClr1=C4RGB(pClr[0], pClr[1], pClr[2]); FadeClr1=C4RGB(pClr[0], pClr[1], pClr[2]);
FadeClr2=C4RGB(pClr[3*19+0], pClr[3*19+1], pClr[3*19+2]); FadeClr2=C4RGB(pClr[3*19+0], pClr[3*19+1], pClr[3*19+2]);
} }
else else
{ {
// set colors // set colors
FadeClr1=C4RGB(ipColors[0], ipColors[1], ipColors[2]); FadeClr1=C4RGB(ipColors[0], ipColors[1], ipColors[2]);
FadeClr2=C4RGB(ipColors[3], ipColors[4], ipColors[5]); FadeClr2=C4RGB(ipColors[3], ipColors[4], ipColors[5]);
} }
} }
bool C4Sky::Init(bool fSavegame) bool C4Sky::Init(bool fSavegame)
{ {
@ -165,8 +165,8 @@ bool C4Sky::Init(bool fSavegame)
} }
// Success // Success
return true; return true;
} }
void C4Sky::Default() void C4Sky::Default()
{ {
@ -261,7 +261,7 @@ bool C4Sky::SetModulation(DWORD dwWithClr, DWORD dwBackClr)
} }
void C4Sky::CompileFunc(StdCompiler *pComp) void C4Sky::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(mkCastIntAdapt(x), "X", Fix0)); pComp->Value(mkNamingAdapt(mkCastIntAdapt(x), "X", Fix0));
pComp->Value(mkNamingAdapt(mkCastIntAdapt(y), "Y", Fix0)); pComp->Value(mkNamingAdapt(mkCastIntAdapt(y), "Y", Fix0));
pComp->Value(mkNamingAdapt(mkCastIntAdapt(xdir),"XDir", Fix0)); pComp->Value(mkNamingAdapt(mkCastIntAdapt(xdir),"XDir", Fix0));
@ -272,4 +272,4 @@ void C4Sky::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(ParallaxMode, "ParMode", C4SkyPM_Fixed)); pComp->Value(mkNamingAdapt(ParallaxMode, "ParMode", C4SkyPM_Fixed));
pComp->Value(mkNamingAdapt(BackClr, "BackClr", 0)); pComp->Value(mkNamingAdapt(BackClr, "BackClr", 0));
pComp->Value(mkNamingAdapt(BackClrEnabled, "BackClrEnabled", false)); pComp->Value(mkNamingAdapt(BackClrEnabled, "BackClrEnabled", false));
} }

View File

@ -34,11 +34,11 @@ void C4SolidMask::Put(bool fCauseInstability, C4TargetRect *pClipRect, bool fRes
// If not put, put mask to background, // If not put, put mask to background,
// storing background pixels in cSolidMask. // storing background pixels in cSolidMask.
// No mask // No mask
if (!pSolidMask || !pSolidMaskMatBuff) { iAttachingObjectsCount = 0; return; } if (!pSolidMask || !pSolidMaskMatBuff) { iAttachingObjectsCount = 0; return; }
// Contained // Contained
if (pForObject->Contained) { iAttachingObjectsCount = 0; return; } if (pForObject->Contained) { iAttachingObjectsCount = 0; return; }
// Mask is put // Mask is put
if (fCauseInstability) CheckConsistency(); if (fCauseInstability) CheckConsistency();
bool RegularPut; bool RegularPut;
@ -57,11 +57,11 @@ void C4SolidMask::Put(bool fCauseInstability, C4TargetRect *pClipRect, bool fRes
if (!pClipRect->ClipBy(MaskPutRect)) return; if (!pClipRect->ClipBy(MaskPutRect)) return;
RegularPut = false; RegularPut = false;
} }
// Lock mask surface // Lock mask surface
int iPitch = pForObject->SolidMask.Wdt; int iPitch = pForObject->SolidMask.Wdt;
int xcnt,ycnt,iTx,iTy; int xcnt,ycnt,iTx,iTy;
// Put mask pixels // Put mask pixels
BYTE byPixel; BYTE byPixel;
// not rotated? // not rotated?
if (!MaskPutRotation) if (!MaskPutRotation)
{ {
@ -234,7 +234,7 @@ void C4SolidMask::Remove(bool fCauseInstability, bool fBackupAttachment)
// If put, restore background pixels from buffer // If put, restore background pixels from buffer
// Not put // Not put
if (!MaskPut || !pSolidMask || !pSolidMaskMatBuff) return; if (!MaskPut || !pSolidMask || !pSolidMaskMatBuff) return;
CheckConsistency(); CheckConsistency();

View File

@ -36,16 +36,16 @@
#include <C4Log.h> #include <C4Log.h>
C4Texture::C4Texture() C4Texture::C4Texture()
{ {
Name[0]=0; Name[0]=0;
Surface32=NULL; Surface32=NULL;
Next=NULL; Next=NULL;
} }
C4Texture::~C4Texture() C4Texture::~C4Texture()
{ {
delete Surface32; delete Surface32;
} }
C4TexMapEntry::C4TexMapEntry() C4TexMapEntry::C4TexMapEntry()
: iMaterialIndex(MNone), pMaterial(NULL) : iMaterialIndex(MNone), pMaterial(NULL)
@ -98,17 +98,17 @@ bool C4TexMapEntry::Init()
} }
C4TextureMap::C4TextureMap() C4TextureMap::C4TextureMap()
{ {
Default(); Default();
} }
C4TextureMap::~C4TextureMap() C4TextureMap::~C4TextureMap()
{ {
Clear(); Clear();
} }
bool C4TextureMap::AddEntry(BYTE byIndex, const char *szMaterial, const char *szTexture) bool C4TextureMap::AddEntry(BYTE byIndex, const char *szMaterial, const char *szTexture)
{ {
// Security // Security
if(byIndex <= 0 || byIndex >= C4M_MaxTexIndex) if(byIndex <= 0 || byIndex >= C4M_MaxTexIndex)
return false; return false;
@ -125,36 +125,36 @@ bool C4TextureMap::AddEntry(BYTE byIndex, const char *szMaterial, const char *sz
// Landscape must be notified (new valid pixel clr) // Landscape must be notified (new valid pixel clr)
::Landscape.HandleTexMapUpdate(); ::Landscape.HandleTexMapUpdate();
} }
return true; return true;
} }
bool C4TextureMap::AddTexture(const char *szTexture, CSurface * sfcSurface) bool C4TextureMap::AddTexture(const char *szTexture, CSurface * sfcSurface)
{ {
C4Texture *pTexture; C4Texture *pTexture;
if (!(pTexture=new C4Texture)) return false; if (!(pTexture=new C4Texture)) return false;
SCopy(szTexture,pTexture->Name,C4M_MaxName); SCopy(szTexture,pTexture->Name,C4M_MaxName);
pTexture->Surface32=sfcSurface; pTexture->Surface32=sfcSurface;
pTexture->Next=FirstTexture; pTexture->Next=FirstTexture;
FirstTexture=pTexture; FirstTexture=pTexture;
return true; return true;
} }
void C4TextureMap::Clear() void C4TextureMap::Clear()
{ {
for(int32_t i = 1; i < C4M_MaxTexIndex; i++) for(int32_t i = 1; i < C4M_MaxTexIndex; i++)
Entry[i].Clear(); Entry[i].Clear();
C4Texture *ctex,*next2; C4Texture *ctex,*next2;
for (ctex=FirstTexture; ctex; ctex=next2) for (ctex=FirstTexture; ctex; ctex=next2)
{ {
next2=ctex->Next; next2=ctex->Next;
delete ctex; delete ctex;
} }
FirstTexture=NULL; FirstTexture=NULL;
fInitialized = false; fInitialized = false;
} }
bool C4TextureMap::LoadFlags(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures) bool C4TextureMap::LoadFlags(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures)
{ {
// Load the file // Load the file
StdStrBuf TexMap; StdStrBuf TexMap;
if(!hGroup.LoadEntryString(szEntryName, TexMap)) if(!hGroup.LoadEntryString(szEntryName, TexMap))
@ -175,20 +175,20 @@ bool C4TextureMap::LoadFlags(C4Group &hGroup, const char *szEntryName, bool *pOv
} }
// Done // Done
return true; return true;
} }
int32_t C4TextureMap::LoadMap(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures) int32_t C4TextureMap::LoadMap(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures)
{ {
char *bpMap; char *bpMap;
char szLine[100+1]; char szLine[100+1];
int32_t cnt, iIndex, iTextures = 0; int32_t cnt, iIndex, iTextures = 0;
// Load text file into memory // Load text file into memory
if (!hGroup.LoadEntry(szEntryName,&bpMap,NULL,1)) return 0; if (!hGroup.LoadEntry(szEntryName,&bpMap,NULL,1)) return 0;
// Scan text buffer lines // Scan text buffer lines
for (cnt=0; SCopySegment(bpMap,cnt,szLine,0x0A,100); cnt++) for (cnt=0; SCopySegment(bpMap,cnt,szLine,0x0A,100); cnt++)
if ( (szLine[0]!='#') && (SCharCount('=',szLine)==1) ) if ( (szLine[0]!='#') && (SCharCount('=',szLine)==1) )
{ {
SReplaceChar(szLine,0x0D,0x00); SReplaceChar(szLine,0x0D,0x00);
if (Inside<int32_t>( iIndex = strtol(szLine,NULL,10), 0, C4M_MaxTexIndex-1 )) if (Inside<int32_t>( iIndex = strtol(szLine,NULL,10), 0, C4M_MaxTexIndex-1 ))
{ {
const char *szMapping = szLine+SCharPos('=',szLine)+1; const char *szMapping = szLine+SCharPos('=',szLine)+1;
@ -197,17 +197,17 @@ int32_t C4TextureMap::LoadMap(C4Group &hGroup, const char *szEntryName, bool *pO
if (AddEntry(iIndex, Material.getData(), Texture.getData())) if (AddEntry(iIndex, Material.getData(), Texture.getData()))
iTextures++; iTextures++;
} }
} }
else else
{ {
if (SEqual2(szLine, "OverloadMaterials")) { fOverloadMaterials = true; if(pOverloadMaterials) *pOverloadMaterials = true; } if (SEqual2(szLine, "OverloadMaterials")) { fOverloadMaterials = true; if(pOverloadMaterials) *pOverloadMaterials = true; }
if (SEqual2(szLine, "OverloadTextures")) { fOverloadTextures = true; if(pOverloadTextures) *pOverloadTextures = true; } if (SEqual2(szLine, "OverloadTextures")) { fOverloadTextures = true; if(pOverloadTextures) *pOverloadTextures = true; }
} }
// Delete buffer, return entry count // Delete buffer, return entry count
delete [] bpMap; delete [] bpMap;
fEntriesAdded=false; fEntriesAdded=false;
return iTextures; return iTextures;
} }
int32_t C4TextureMap::Init() int32_t C4TextureMap::Init()
{ {
@ -298,31 +298,31 @@ void C4TextureMap::MoveIndex(BYTE byOldIndex, BYTE byNewIndex)
} }
int32_t C4TextureMap::GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist, const char *szErrorIfFailed) int32_t C4TextureMap::GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist, const char *szErrorIfFailed)
{ {
BYTE byIndex; BYTE byIndex;
// Find existing // Find existing
for (byIndex = 1; byIndex < C4M_MaxTexIndex; byIndex++) for (byIndex = 1; byIndex < C4M_MaxTexIndex; byIndex++)
if (!Entry[byIndex].isNull()) if (!Entry[byIndex].isNull())
if (SEqualNoCase(Entry[byIndex].GetMaterialName(), szMaterial)) if (SEqualNoCase(Entry[byIndex].GetMaterialName(), szMaterial))
if (!szTexture || SEqualNoCase(Entry[byIndex].GetTextureName(), szTexture)) if (!szTexture || SEqualNoCase(Entry[byIndex].GetTextureName(), szTexture))
return byIndex; return byIndex;
// Add new entry // Add new entry
if (fAddIfNotExist) if (fAddIfNotExist)
for (byIndex=1; byIndex<C4M_MaxTexIndex; byIndex++) for (byIndex=1; byIndex<C4M_MaxTexIndex; byIndex++)
if (Entry[byIndex].isNull()) if (Entry[byIndex].isNull())
{ {
if (AddEntry(byIndex, szMaterial, szTexture)) if (AddEntry(byIndex, szMaterial, szTexture))
{ {
fEntriesAdded=true; fEntriesAdded=true;
return byIndex; return byIndex;
} }
if (szErrorIfFailed) DebugLogF("Error getting MatTex %s-%s for %s from TextureMap: Init failed.", szMaterial, szTexture, szErrorIfFailed); if (szErrorIfFailed) DebugLogF("Error getting MatTex %s-%s for %s from TextureMap: Init failed.", szMaterial, szTexture, szErrorIfFailed);
return 0; return 0;
} }
// Else, fail // Else, fail
if (szErrorIfFailed) DebugLogF("Error getting MatTex %s-%s for %s from TextureMap: %s.", szMaterial, szTexture, szErrorIfFailed, fAddIfNotExist ? "Map is full!" : "Entry not found."); if (szErrorIfFailed) DebugLogF("Error getting MatTex %s-%s for %s from TextureMap: %s.", szMaterial, szTexture, szErrorIfFailed, fAddIfNotExist ? "Map is full!" : "Entry not found.");
return 0; return 0;
} }
int32_t C4TextureMap::GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture, bool fAddIfNotExist, const char *szErrorIfFailed) int32_t C4TextureMap::GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture, bool fAddIfNotExist, const char *szErrorIfFailed)
{ {
@ -350,28 +350,28 @@ int32_t C4TextureMap::GetIndexMatTex(const char *szMaterialTexture, const char *
} }
C4Texture * C4TextureMap::GetTexture(const char *szTexture) C4Texture * C4TextureMap::GetTexture(const char *szTexture)
{ {
C4Texture *pTexture; C4Texture *pTexture;
for (pTexture=FirstTexture; pTexture; pTexture=pTexture->Next) for (pTexture=FirstTexture; pTexture; pTexture=pTexture->Next)
if (SEqualNoCase(pTexture->Name,szTexture)) if (SEqualNoCase(pTexture->Name,szTexture))
return pTexture; return pTexture;
return NULL; return NULL;
} }
bool C4TextureMap::CheckTexture(const char *szTexture) bool C4TextureMap::CheckTexture(const char *szTexture)
{ {
C4Texture *pTexture; C4Texture *pTexture;
for (pTexture=FirstTexture; pTexture; pTexture=pTexture->Next) for (pTexture=FirstTexture; pTexture; pTexture=pTexture->Next)
if (SEqualNoCase(pTexture->Name,szTexture)) if (SEqualNoCase(pTexture->Name,szTexture))
return true; return true;
return false; return false;
} }
const char* C4TextureMap::GetTexture(int32_t iIndex) const char* C4TextureMap::GetTexture(int32_t iIndex)
{ {
C4Texture *pTexture; C4Texture *pTexture;
int32_t cindex; int32_t cindex;
for (pTexture=FirstTexture,cindex=0; pTexture; pTexture=pTexture->Next,cindex++) for (pTexture=FirstTexture,cindex=0; pTexture; pTexture=pTexture->Next,cindex++)
if (cindex==iIndex) if (cindex==iIndex)
return pTexture->Name; return pTexture->Name;
return NULL; return NULL;
@ -379,7 +379,7 @@ const char* C4TextureMap::GetTexture(int32_t iIndex)
void C4TextureMap::Default() void C4TextureMap::Default()
{ {
FirstTexture=NULL; FirstTexture=NULL;
fEntriesAdded=false; fEntriesAdded=false;
fOverloadMaterials=false; fOverloadMaterials=false;
fOverloadTextures=false; fOverloadTextures=false;
@ -396,7 +396,7 @@ void C4TextureMap::StoreMapPalette(BYTE *bypPalette, C4MaterialMap &rMaterial)
bypPalette[2]=252; bypPalette[2]=252;
// Material colors by texture map entries // Material colors by texture map entries
bool fSet[256]; bool fSet[256];
ZeroMem(&fSet, sizeof (fSet)); ZeroMem(&fSet, sizeof (fSet));
int32_t i; int32_t i;
for(i = 0; i < C4M_MaxTexIndex; i++) for(i = 0; i < C4M_MaxTexIndex; i++)
{ {
@ -410,24 +410,24 @@ void C4TextureMap::StoreMapPalette(BYTE *bypPalette, C4MaterialMap &rMaterial)
bypPalette[3*(i+IFT)+2]=dwPix | 0x0F; // IFT arbitrarily gets more blue bypPalette[3*(i+IFT)+2]=dwPix | 0x0F; // IFT arbitrarily gets more blue
fSet[i] = fSet[i + IFT] = true; fSet[i] = fSet[i + IFT] = true;
} }
// Crosscheck colors, change equal palette entries // Crosscheck colors, change equal palette entries
for(i = 0; i < 256; i++) if(fSet[i]) for(i = 0; i < 256; i++) if(fSet[i])
for(;;) for(;;)
{ {
// search equal entry // search equal entry
int32_t j = 0; int32_t j = 0;
for(; j < i; j++) if(fSet[j]) for(; j < i; j++) if(fSet[j])
if(bypPalette[3*i+0] == bypPalette[3*j+0] && if(bypPalette[3*i+0] == bypPalette[3*j+0] &&
bypPalette[3*i+1] == bypPalette[3*j+1] && bypPalette[3*i+1] == bypPalette[3*j+1] &&
bypPalette[3*i+2] == bypPalette[3*j+2]) bypPalette[3*i+2] == bypPalette[3*j+2])
break; break;
// not found? ok then // not found? ok then
if(j >= i) break; if(j >= i) break;
// change randomly // change randomly
if(rand() < RAND_MAX / 2) bypPalette[3*i+0] += 3; else bypPalette[3*i+0] -= 3; if(rand() < RAND_MAX / 2) bypPalette[3*i+0] += 3; else bypPalette[3*i+0] -= 3;
if(rand() < RAND_MAX / 2) bypPalette[3*i+1] += 3; else bypPalette[3*i+1] -= 3; if(rand() < RAND_MAX / 2) bypPalette[3*i+1] += 3; else bypPalette[3*i+1] -= 3;
if(rand() < RAND_MAX / 2) bypPalette[3*i+2] += 3; else bypPalette[3*i+2] -= 3; if(rand() < RAND_MAX / 2) bypPalette[3*i+2] += 3; else bypPalette[3*i+2] -= 3;
} }
} }
C4TextureMap TextureMap; C4TextureMap TextureMap;

View File

@ -28,24 +28,24 @@
#include <C4Material.h> #include <C4Material.h>
class C4Texture class C4Texture
{ {
friend class C4TextureMap; friend class C4TextureMap;
public: public:
C4Texture(); C4Texture();
~C4Texture(); ~C4Texture();
CSurface * Surface32; CSurface * Surface32;
protected: protected:
char Name[C4M_MaxName+1]; char Name[C4M_MaxName+1];
C4Texture *Next; C4Texture *Next;
}; };
class C4TexMapEntry class C4TexMapEntry
{ {
friend class C4TextureMap; friend class C4TextureMap;
public: public:
C4TexMapEntry(); C4TexMapEntry();
private: private:
StdCopyStrBuf Material, Texture; StdCopyStrBuf Material, Texture;
int32_t iMaterialIndex; int32_t iMaterialIndex;
C4Material *pMaterial; C4Material *pMaterial;
CPattern MatPattern; CPattern MatPattern;
@ -59,43 +59,43 @@ class C4TexMapEntry
void Clear(); void Clear();
bool Create(const char *szMaterial, const char *szTexture); bool Create(const char *szMaterial, const char *szTexture);
bool Init(); bool Init();
}; };
class C4TextureMap class C4TextureMap
{ {
public: public:
C4TextureMap(); C4TextureMap();
~C4TextureMap(); ~C4TextureMap();
protected: protected:
C4TexMapEntry Entry[C4M_MaxTexIndex]; C4TexMapEntry Entry[C4M_MaxTexIndex];
C4Texture *FirstTexture; C4Texture *FirstTexture;
bool fOverloadMaterials; bool fOverloadMaterials;
bool fOverloadTextures; bool fOverloadTextures;
bool fInitialized; // Set after Init() - newly added entries initialized automatically bool fInitialized; // Set after Init() - newly added entries initialized automatically
public: public:
bool fEntriesAdded; bool fEntriesAdded;
public: public:
const C4TexMapEntry *GetEntry(int32_t iIndex) const { return Inside<int32_t>(iIndex, 0, C4M_MaxTexIndex-1) ? &Entry[iIndex] : NULL; } const C4TexMapEntry *GetEntry(int32_t iIndex) const { return Inside<int32_t>(iIndex, 0, C4M_MaxTexIndex-1) ? &Entry[iIndex] : NULL; }
void RemoveEntry(int32_t iIndex) { if (Inside<int32_t>(iIndex, 1, C4M_MaxTexIndex-1)) Entry[iIndex].Clear(); } void RemoveEntry(int32_t iIndex) { if (Inside<int32_t>(iIndex, 1, C4M_MaxTexIndex-1)) Entry[iIndex].Clear(); }
void Default(); void Default();
void Clear(); void Clear();
void StoreMapPalette(BYTE *bypPalette, C4MaterialMap &rMaterials); void StoreMapPalette(BYTE *bypPalette, C4MaterialMap &rMaterials);
static bool LoadFlags(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures); static bool LoadFlags(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures);
int32_t LoadMap(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures); int32_t LoadMap(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures);
int32_t Init(); int32_t Init();
bool SaveMap(C4Group &hGroup, const char *szEntryName); bool SaveMap(C4Group &hGroup, const char *szEntryName);
int32_t LoadTextures(C4Group &hGroup, C4Group* OverloadFile=0); int32_t LoadTextures(C4Group &hGroup, C4Group* OverloadFile=0);
bool HasTextures(C4Group &hGroup); bool HasTextures(C4Group &hGroup);
const char *GetTexture(int32_t iIndex); const char *GetTexture(int32_t iIndex);
void MoveIndex(BYTE byOldIndex, BYTE byNewIndex); // change index of texture void MoveIndex(BYTE byOldIndex, BYTE byNewIndex); // change index of texture
int32_t GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist=true, const char *szErrorIfFailed=NULL); int32_t GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist=true, const char *szErrorIfFailed=NULL);
int32_t GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture = NULL, bool fAddIfNotExist=true, const char *szErrorIfFailed=NULL); int32_t GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture = NULL, bool fAddIfNotExist=true, const char *szErrorIfFailed=NULL);
C4Texture * GetTexture(const char *szTexture); C4Texture * GetTexture(const char *szTexture);
bool CheckTexture(const char *szTexture); // return whether texture exists bool CheckTexture(const char *szTexture); // return whether texture exists
bool AddEntry(BYTE byIndex, const char *szMaterial, const char *szTexture); bool AddEntry(BYTE byIndex, const char *szMaterial, const char *szTexture);
protected: protected:
bool AddTexture(const char *szTexture, CSurface * sfcSurface); bool AddTexture(const char *szTexture, CSurface * sfcSurface);
}; };
extern C4TextureMap TextureMap; extern C4TextureMap TextureMap;

View File

@ -30,9 +30,9 @@
#include <C4Game.h> #include <C4Game.h>
C4Weather::C4Weather() C4Weather::C4Weather()
{ {
Default(); Default();
} }
C4Weather::~C4Weather() C4Weather::~C4Weather()
{ {
@ -40,67 +40,67 @@ C4Weather::~C4Weather()
} }
void C4Weather::Init(bool fScenario) void C4Weather::Init(bool fScenario)
{ {
if(fScenario) if(fScenario)
{ {
// Season // Season
Season=Game.C4S.Weather.StartSeason.Evaluate(); Season=Game.C4S.Weather.StartSeason.Evaluate();
YearSpeed=Game.C4S.Weather.YearSpeed.Evaluate(); YearSpeed=Game.C4S.Weather.YearSpeed.Evaluate();
// Temperature // Temperature
Climate=100-Game.C4S.Weather.Climate.Evaluate()-50; Climate=100-Game.C4S.Weather.Climate.Evaluate()-50;
Temperature=Climate; Temperature=Climate;
// Wind // Wind
Wind=TargetWind=Game.C4S.Weather.Wind.Evaluate(); Wind=TargetWind=Game.C4S.Weather.Wind.Evaluate();
// Precipitation // Precipitation
if (!Game.C4S.Head.NoInitialize) if (!Game.C4S.Head.NoInitialize)
if (Game.C4S.Weather.Rain.Evaluate()) if (Game.C4S.Weather.Rain.Evaluate())
for (int32_t iClouds = Min(GBackWdt/500,5); iClouds>0; iClouds--) for (int32_t iClouds = Min(GBackWdt/500,5); iClouds>0; iClouds--)
{ {
volatile int iWidth = GBackWdt/15+Random(320); volatile int iWidth = GBackWdt/15+Random(320);
volatile int iX = Random(GBackWdt); volatile int iX = Random(GBackWdt);
LaunchCloud(iX,-1,iWidth, LaunchCloud(iX,-1,iWidth,
Game.C4S.Weather.Rain.Evaluate(), Game.C4S.Weather.Rain.Evaluate(),
Game.C4S.Weather.Precipitation); Game.C4S.Weather.Precipitation);
} }
// gamma? // gamma?
NoGamma=Game.C4S.Weather.NoGamma; NoGamma=Game.C4S.Weather.NoGamma;
} }
// set gamma // set gamma
SetSeasonGamma(); SetSeasonGamma();
} }
void C4Weather::Execute() void C4Weather::Execute()
{ {
// Season // Season
if (!::Game.iTick35) if (!::Game.iTick35)
{
SeasonDelay+=YearSpeed;
if (SeasonDelay>=200)
{
SeasonDelay=0;
Season++;
if (Season>Game.C4S.Weather.StartSeason.Max)
Season=Game.C4S.Weather.StartSeason.Min;
SetSeasonGamma();
}
}
// Temperature
if (!::Game.iTick35)
{ {
int32_t iTemperature=Climate-(int32_t)(TemperatureRange*cos(6.28*(float)Season/100.0)); SeasonDelay+=YearSpeed;
if (SeasonDelay>=200)
{
SeasonDelay=0;
Season++;
if (Season>Game.C4S.Weather.StartSeason.Max)
Season=Game.C4S.Weather.StartSeason.Min;
SetSeasonGamma();
}
}
// Temperature
if (!::Game.iTick35)
{
int32_t iTemperature=Climate-(int32_t)(TemperatureRange*cos(6.28*(float)Season/100.0));
if (Temperature<iTemperature) Temperature++; if (Temperature<iTemperature) Temperature++;
else if (Temperature>iTemperature) Temperature--; else if (Temperature>iTemperature) Temperature--;
} }
// Wind // Wind
if (!::Game.iTick1000) if (!::Game.iTick1000)
TargetWind=Game.C4S.Weather.Wind.Evaluate(); TargetWind=Game.C4S.Weather.Wind.Evaluate();
if (!::Game.iTick10) if (!::Game.iTick10)
Wind=BoundBy<int32_t>(Wind+Sign(TargetWind-Wind), Wind=BoundBy<int32_t>(Wind+Sign(TargetWind-Wind),
Game.C4S.Weather.Wind.Min, Game.C4S.Weather.Wind.Min,
Game.C4S.Weather.Wind.Max); Game.C4S.Weather.Wind.Max);
if (!::Game.iTick10) if (!::Game.iTick10)
SoundLevel("Wind",NULL,Max(Abs(Wind)-30,0)*2); SoundLevel("Wind",NULL,Max(Abs(Wind)-30,0)*2);
} }
void C4Weather::Clear() void C4Weather::Clear()
{ {
@ -120,10 +120,10 @@ int32_t C4Weather::GetTemperature()
void C4Weather::Default() void C4Weather::Default()
{ {
Season=0; YearSpeed=0; SeasonDelay=0; Season=0; YearSpeed=0; SeasonDelay=0;
Wind=TargetWind=0; Wind=TargetWind=0;
Temperature=Climate=0; Temperature=Climate=0;
TemperatureRange=30; TemperatureRange=30;
NoGamma=true; NoGamma=true;
} }
@ -211,7 +211,7 @@ void C4Weather::SetSeasonGamma()
} }
void C4Weather::CompileFunc(StdCompiler *pComp) void C4Weather::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(Season, "Season", 0)); pComp->Value(mkNamingAdapt(Season, "Season", 0));
pComp->Value(mkNamingAdapt(YearSpeed, "YearSpeed", 0)); pComp->Value(mkNamingAdapt(YearSpeed, "YearSpeed", 0));
pComp->Value(mkNamingAdapt(SeasonDelay, "SeasonDelay", 0)); pComp->Value(mkNamingAdapt(SeasonDelay, "SeasonDelay", 0));
@ -229,6 +229,6 @@ void C4Weather::CompileFunc(StdCompiler *pComp)
dwGammaDefaults[i*3+2] = 0xffffff; dwGammaDefaults[i*3+2] = 0xffffff;
} }
pComp->Value(mkNamingAdapt(mkArrayAdaptM(::GraphicsSystem.dwGamma), "Gamma", dwGammaDefaults)); pComp->Value(mkNamingAdapt(mkArrayAdaptM(::GraphicsSystem.dwGamma), "Gamma", dwGammaDefaults));
} }
C4Weather Weather; C4Weather Weather;

View File

@ -24,23 +24,23 @@
#include <C4Landscape.h> #include <C4Landscape.h>
class C4Weather class C4Weather
{ {
public: public:
C4Weather(); C4Weather();
~C4Weather(); ~C4Weather();
public: public:
int32_t Season,YearSpeed,SeasonDelay; int32_t Season,YearSpeed,SeasonDelay;
int32_t Wind,TargetWind; int32_t Wind,TargetWind;
int32_t Temperature,TemperatureRange,Climate; int32_t Temperature,TemperatureRange,Climate;
int32_t NoGamma; int32_t NoGamma;
public: public:
void Default(); void Default();
void Clear(); void Clear();
void Execute(); void Execute();
void SetClimate(int32_t iClimate); void SetClimate(int32_t iClimate);
void SetSeason(int32_t iSeason); void SetSeason(int32_t iSeason);
void SetTemperature(int32_t iTemperature); void SetTemperature(int32_t iTemperature);
void Init(bool fScenario); void Init(bool fScenario);
void SetWind(int32_t iWind); void SetWind(int32_t iWind);
int32_t GetWind(int32_t x, int32_t y); int32_t GetWind(int32_t x, int32_t y);
int32_t GetTemperature(); int32_t GetTemperature();
@ -48,13 +48,13 @@ class C4Weather
int32_t GetClimate(); int32_t GetClimate();
bool LaunchCloud(int32_t iX, int32_t iY, int32_t iWidth, int32_t iStrength, const char *szPrecipitation); bool LaunchCloud(int32_t iX, int32_t iY, int32_t iWidth, int32_t iStrength, const char *szPrecipitation);
void SetSeasonGamma(); // set gamma adjustment for season void SetSeasonGamma(); // set gamma adjustment for season
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
}; };
extern C4Weather Weather; extern C4Weather Weather;
inline int32_t GBackWind(int32_t x, int32_t y) inline int32_t GBackWind(int32_t x, int32_t y)
{ {
return GBackIFT(x, y) ? 0: ::Weather.Wind; return GBackIFT(x, y) ? 0: ::Weather.Wind;
} }
#endif #endif

View File

@ -23,29 +23,29 @@
#include <C4Object.h> #include <C4Object.h>
C4Action::C4Action() C4Action::C4Action()
{ {
Default(); Default();
} }
C4Action::~C4Action() C4Action::~C4Action()
{ {
} }
void C4Action::Default() void C4Action::Default()
{ {
//pActionDef = 0; //pActionDef = 0;
Dir=DIR_None; Dir=DIR_None;
DrawDir=Dir; DrawDir=Dir;
ComDir=COMD_None; ComDir=COMD_None;
Time=0; Time=0;
Data=0; Data=0;
Target=Target2=NULL; Target=Target2=NULL;
Phase=PhaseDelay=0; Phase=PhaseDelay=0;
Facet.Default(); Facet.Default();
FacetX=FacetY=0; FacetX=FacetY=0;
t_attach=CNAT_None; t_attach=CNAT_None;
Animation = NULL; Animation = NULL;
} }
void C4Action::CompileFunc(StdCompiler *pComp) void C4Action::CompileFunc(StdCompiler *pComp)

File diff suppressed because it is too large Load Diff

View File

@ -62,13 +62,13 @@ const int32_t C4CMD_First = C4CMD_Follow,
C4CMD_Last = C4CMD_Take2; // carlo C4CMD_Last = C4CMD_Take2; // carlo
const int32_t C4CMD_Mode_SilentSub = 0, // subcommand; failure will cause base to fail (no message in case of failure) const int32_t C4CMD_Mode_SilentSub = 0, // subcommand; failure will cause base to fail (no message in case of failure)
C4CMD_Mode_Base = 1, // regular base command C4CMD_Mode_Base = 1, // regular base command
C4CMD_Mode_SilentBase = 2, // silent base command (no message in case of failure) C4CMD_Mode_SilentBase = 2, // silent base command (no message in case of failure)
C4CMD_Mode_Sub = 3; // subcommand; failure will cause base to fail C4CMD_Mode_Sub = 3; // subcommand; failure will cause base to fail
// MoveTo and Enter command options: Include push target // MoveTo and Enter command options: Include push target
const int32_t C4CMD_MoveTo_NoPosAdjust = 1, const int32_t C4CMD_MoveTo_NoPosAdjust = 1,
C4CMD_MoveTo_PushTarget = 2; C4CMD_MoveTo_PushTarget = 2;
const int32_t C4CMD_Enter_PushTarget = 2; const int32_t C4CMD_Enter_PushTarget = 2;
@ -77,25 +77,25 @@ const char* CommandNameID(int32_t iCommand);
int32_t CommandByName(const char *szCommand); int32_t CommandByName(const char *szCommand);
class C4Command class C4Command
{ {
public: public:
C4Command(); C4Command();
~C4Command(); ~C4Command();
public: public:
C4Object *cObj; C4Object *cObj;
int32_t Command; int32_t Command;
C4Value Tx; C4Value Tx;
int32_t Ty; int32_t Ty;
C4Object *Target,*Target2; C4Object *Target,*Target2;
C4Value Data; C4Value Data;
int32_t UpdateInterval; int32_t UpdateInterval;
int32_t Evaluated,PathChecked,Finished; int32_t Evaluated,PathChecked,Finished;
int32_t Failures,Retries,Permit; int32_t Failures,Retries,Permit;
C4String *Text; C4String *Text;
C4Command *Next; C4Command *Next;
int32_t iExec; // 0 = not executing, 1 = executing, 2 = executing, command should delete himself on finish int32_t iExec; // 0 = not executing, 1 = executing, 2 = executing, command should delete himself on finish
int32_t BaseMode; // 0: subcommand/unmarked base (if failing, base will fail, too); 1: base command; 2: silent base command int32_t BaseMode; // 0: subcommand/unmarked base (if failing, base will fail, too); 1: base command; 2: silent base command
public: public:
void Set(int32_t iCommand, C4Object *pObj, C4Object *pTarget, C4Value iTx, int32_t iTy, C4Object *pTarget2, C4Value iData, int32_t iUpdateInterval, bool fEvaluated, int32_t iRetries, C4String *szText, int32_t iBaseMode); void Set(int32_t iCommand, C4Object *pObj, C4Object *pTarget, C4Value iTx, int32_t iTy, C4Object *pTarget2, C4Value iData, int32_t iUpdateInterval, bool fEvaluated, int32_t iRetries, C4String *szText, int32_t iBaseMode);
void Clear(); void Clear();
void Execute(); void Execute();
@ -103,8 +103,8 @@ class C4Command
void Default(); void Default();
void EnumeratePointers(); void EnumeratePointers();
void DenumeratePointers(); void DenumeratePointers();
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
protected: protected:
void Call(); void Call();
void Home(); void Home();
void Retry(); void Retry();
@ -117,33 +117,33 @@ class C4Command
void Transfer(); void Transfer();
void Construct(); void Construct();
void Finish(bool fSuccess=false, const char *szFailMessage=0); void Finish(bool fSuccess=false, const char *szFailMessage=0);
void Follow(); void Follow();
void MoveTo(); void MoveTo();
void Enter(); void Enter();
void Exit(); void Exit();
void Grab(); void Grab();
void UnGrab(); void UnGrab();
void Throw(); void Throw();
void Chop(); void Chop();
void Build(); void Build();
void Jump(); void Jump();
void Wait(); void Wait();
void Take(); void Take();
void Take2(); void Take2();
bool GetTryEnter(); // at object pos during get-command: Try entering it bool GetTryEnter(); // at object pos during get-command: Try entering it
void Get(); void Get();
void Put(); void Put();
void Drop(); void Drop();
void Dig(); void Dig();
void Activate(); void Activate();
void PushTo(); void PushTo();
void Context(); void Context();
int32_t CallFailed(); int32_t CallFailed();
bool JumpControl(); bool JumpControl();
bool FlightControl(); bool FlightControl();
bool InitEvaluation(); bool InitEvaluation();
int32_t GetExpGain(); // get control counts gained by this command; 1EXP=5 ControlCounts int32_t GetExpGain(); // get control counts gained by this command; 1EXP=5 ControlCounts
bool CheckMinimumCon (C4Object *pObj); bool CheckMinimumCon (C4Object *pObj);
}; };
#endif #endif

View File

@ -68,19 +68,19 @@ const char *ProcedureName[C4D_MaxDFA]={ "WALK",
//--------------------------------- C4DefCore ---------------------------------------------- //--------------------------------- C4DefCore ----------------------------------------------
void C4Def::DefaultDefCore() void C4Def::DefaultDefCore()
{ {
rC4XVer[0]=rC4XVer[1]=rC4XVer[2]=rC4XVer[3]=0; rC4XVer[0]=rC4XVer[1]=rC4XVer[2]=rC4XVer[3]=0;
RequireDef.Clear(); RequireDef.Clear();
Physical.Default(); Physical.Default();
Shape.Default(); Shape.Default();
Entrance.Default(); Entrance.Default();
Collection.Default(); Collection.Default();
PictureRect.Default(); PictureRect.Default();
SolidMask.Default(); SolidMask.Default();
TopFace.Default(); TopFace.Default();
Component.Default(); Component.Default();
BurnTurnTo=C4ID::None; BurnTurnTo=C4ID::None;
BuildTurnTo=C4ID::None; BuildTurnTo=C4ID::None;
STimerCall[0]=0; STimerCall[0]=0;
Timer=35; Timer=35;
GrowthType=0; GrowthType=0;
@ -409,8 +409,8 @@ C4Def::C4Def()
void C4Def::Default() void C4Def::Default()
{ {
DefaultDefCore(); DefaultDefCore();
Next=NULL; Next=NULL;
Temporary=false; Temporary=false;
Maker[0]=0; Maker[0]=0;
Filename[0]=0; Filename[0]=0;
Creation=0; Creation=0;
@ -427,7 +427,7 @@ void C4Def::Default()
PortraitCount = 0; PortraitCount = 0;
Portraits = NULL; Portraits = NULL;
pFairCrewPhysical = NULL; pFairCrewPhysical = NULL;
} }
C4Def::~C4Def() C4Def::~C4Def()
{ {
@ -435,7 +435,7 @@ C4Def::~C4Def()
} }
void C4Def::Clear() void C4Def::Clear()
{ {
Graphics.Clear(); Graphics.Clear();
@ -455,10 +455,10 @@ void C4Def::Clear()
} }
bool C4Def::Load(C4Group &hGroup, bool C4Def::Load(C4Group &hGroup,
DWORD dwLoadWhat, DWORD dwLoadWhat,
const char *szLanguage, const char *szLanguage,
C4SoundSystem *pSoundSystem) C4SoundSystem *pSoundSystem)
{ {
bool fSuccess=true; bool fSuccess=true;
bool AddFileMonitoring = false; bool AddFileMonitoring = false;
@ -493,7 +493,7 @@ bool C4Def::Load(C4Group &hGroup,
} }
// Read DefCore // Read DefCore
if (fSuccess) fSuccess=LoadDefCore(hGroup); if (fSuccess) fSuccess=LoadDefCore(hGroup);
// skip def: don't even read sounds! // skip def: don't even read sounds!
@ -526,8 +526,8 @@ bool C4Def::Load(C4Group &hGroup,
return false; return false;
} }
// Read script // Read script
if (dwLoadWhat & C4D_Load_Script) if (dwLoadWhat & C4D_Load_Script)
{ {
// reg script to engine // reg script to engine
Script.Reg2List(&::ScriptEngine, &::ScriptEngine); Script.Reg2List(&::ScriptEngine, &::ScriptEngine);
@ -608,8 +608,8 @@ bool C4Def::Load(C4Group &hGroup,
} }
// Read desc // Read desc
if (dwLoadWhat & C4D_Load_Desc) if (dwLoadWhat & C4D_Load_Desc)
{ {
Desc.LoadEx("Desc", hGroup, C4CFN_DefDesc, szLanguage); Desc.LoadEx("Desc", hGroup, C4CFN_DefDesc, szLanguage);
Desc.TrimSpaces(); Desc.TrimSpaces();
@ -621,7 +621,7 @@ bool C4Def::Load(C4Group &hGroup,
if (pSoundSystem) if (pSoundSystem)
pSoundSystem->LoadEffects(hGroup); pSoundSystem->LoadEffects(hGroup);
// Bitmap post-load settings // Bitmap post-load settings
if (Graphics.GetBitmap()) if (Graphics.GetBitmap())
{ {
// check SolidMask // check SolidMask
@ -751,11 +751,11 @@ C4PhysicalInfo *C4Def::GetFairCrewPhysicals()
} }
void C4Def::ClearFairCrewPhysicals() void C4Def::ClearFairCrewPhysicals()
{ {
// invalidate physicals so the next call to GetFairCrewPhysicals will // invalidate physicals so the next call to GetFairCrewPhysicals will
// reacreate them // reacreate them
delete pFairCrewPhysical; pFairCrewPhysical = NULL; delete pFairCrewPhysical; pFairCrewPhysical = NULL;
} }
void C4Def::Synchronize() void C4Def::Synchronize()
{ {
@ -768,24 +768,24 @@ void C4Def::Synchronize()
//--------------------------------- C4DefList ---------------------------------------------- //--------------------------------- C4DefList ----------------------------------------------
C4DefList::C4DefList() C4DefList::C4DefList()
{ {
Default(); Default();
} }
C4DefList::~C4DefList() C4DefList::~C4DefList()
{ {
Clear(); Clear();
} }
int32_t C4DefList::Load(C4Group &hGroup, DWORD dwLoadWhat, int32_t C4DefList::Load(C4Group &hGroup, DWORD dwLoadWhat,
const char *szLanguage, const char *szLanguage,
C4SoundSystem *pSoundSystem, C4SoundSystem *pSoundSystem,
bool fOverload, bool fOverload,
bool fSearchMessage, int32_t iMinProgress, int32_t iMaxProgress, bool fLoadSysGroups) bool fSearchMessage, int32_t iMinProgress, int32_t iMaxProgress, bool fLoadSysGroups)
{ {
int32_t iResult=0; int32_t iResult=0;
C4Def *nDef; C4Def *nDef;
char szEntryname[_MAX_FNAME+1]; char szEntryname[_MAX_FNAME+1];
C4Group hChild; C4Group hChild;
bool fPrimaryDef=false; bool fPrimaryDef=false;
bool fThisSearchMessage=false; bool fThisSearchMessage=false;
@ -852,8 +852,8 @@ int32_t C4DefList::Load(C4Group &hGroup, DWORD dwLoadWhat,
// progress (could go down one level of recursion...) // progress (could go down one level of recursion...)
if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress)); if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress));
return iResult; return iResult;
} }
int32_t C4DefList::LoadFolderLocal( const char *szPath, int32_t C4DefList::LoadFolderLocal( const char *szPath,
DWORD dwLoadWhat, const char *szLanguage, DWORD dwLoadWhat, const char *szLanguage,
@ -887,11 +887,11 @@ int32_t C4DefList::LoadFolderLocal( const char *szPath,
extern bool C4EngineLoadProcess(const char *szMessage, int32_t iProcess); extern bool C4EngineLoadProcess(const char *szMessage, int32_t iProcess);
int32_t C4DefList::Load(const char *szSearch, int32_t C4DefList::Load(const char *szSearch,
DWORD dwLoadWhat, const char *szLanguage, DWORD dwLoadWhat, const char *szLanguage,
C4SoundSystem *pSoundSystem, C4SoundSystem *pSoundSystem,
bool fOverload, int32_t iMinProgress, int32_t iMaxProgress) bool fOverload, int32_t iMinProgress, int32_t iMaxProgress)
{ {
int32_t iResult=0; int32_t iResult=0;
// Empty // Empty
if (!szSearch[0]) return iResult; if (!szSearch[0]) return iResult;
@ -956,14 +956,14 @@ int32_t C4DefList::Load(const char *szSearch,
// progress (could go down one level of recursion...) // progress (could go down one level of recursion...)
if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress)); if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress));
return iResult; return iResult;
} }
bool C4DefList::Add(C4Def *pDef, bool fOverload) bool C4DefList::Add(C4Def *pDef, bool fOverload)
{ {
if (!pDef) return false; if (!pDef) return false;
// Check old def to overload // Check old def to overload
C4Def *pLastDef = ID2Def(pDef->id); C4Def *pLastDef = ID2Def(pDef->id);
if (pLastDef && !fOverload) return false; if (pLastDef && !fOverload) return false;
@ -979,42 +979,42 @@ bool C4DefList::Add(C4Def *pDef, bool fOverload)
} }
} }
// Remove old def // Remove old def
Remove(pDef->id); Remove(pDef->id);
// Add new def // Add new def
pDef->Next=FirstDef; pDef->Next=FirstDef;
FirstDef=pDef; FirstDef=pDef;
return true; return true;
} }
bool C4DefList::Remove(C4ID id) bool C4DefList::Remove(C4ID id)
{ {
C4Def *cdef,*prev; C4Def *cdef,*prev;
for (cdef=FirstDef,prev=NULL; cdef; prev=cdef,cdef=cdef->Next) for (cdef=FirstDef,prev=NULL; cdef; prev=cdef,cdef=cdef->Next)
if (cdef->id==id) if (cdef->id==id)
{ {
if (prev) prev->Next=cdef->Next; if (prev) prev->Next=cdef->Next;
else FirstDef=cdef->Next; else FirstDef=cdef->Next;
delete cdef; delete cdef;
return true; return true;
} }
return false; return false;
} }
void C4DefList::Remove(C4Def *def) void C4DefList::Remove(C4Def *def)
{ {
C4Def *cdef,*prev; C4Def *cdef,*prev;
for (cdef=FirstDef,prev=NULL; cdef; prev=cdef,cdef=cdef->Next) for (cdef=FirstDef,prev=NULL; cdef; prev=cdef,cdef=cdef->Next)
if (cdef==def) if (cdef==def)
{ {
if (prev) prev->Next=cdef->Next; if (prev) prev->Next=cdef->Next;
else FirstDef=cdef->Next; else FirstDef=cdef->Next;
delete cdef; delete cdef;
return; return;
} }
} }
void C4DefList::Clear() void C4DefList::Clear()
{ {
@ -1050,92 +1050,92 @@ C4Def* C4DefList::ID2Def(C4ID id)
} }
int32_t C4DefList::GetIndex(C4ID id) int32_t C4DefList::GetIndex(C4ID id)
{ {
C4Def *cdef; C4Def *cdef;
int32_t cindex; int32_t cindex;
for (cdef=FirstDef,cindex=0; cdef; cdef=cdef->Next,cindex++) for (cdef=FirstDef,cindex=0; cdef; cdef=cdef->Next,cindex++)
if (cdef->id==id) return cindex; if (cdef->id==id) return cindex;
return -1; return -1;
} }
int32_t C4DefList::GetDefCount(DWORD dwCategory) int32_t C4DefList::GetDefCount(DWORD dwCategory)
{ {
C4Def *cdef; int32_t ccount=0; C4Def *cdef; int32_t ccount=0;
for (cdef=FirstDef; cdef; cdef=cdef->Next) for (cdef=FirstDef; cdef; cdef=cdef->Next)
if (cdef->Category & dwCategory) if (cdef->Category & dwCategory)
ccount++; ccount++;
return ccount; return ccount;
} }
C4Def* C4DefList::GetDef(int32_t iIndex, DWORD dwCategory) C4Def* C4DefList::GetDef(int32_t iIndex, DWORD dwCategory)
{ {
C4Def *pDef; int32_t iCurrentIndex; C4Def *pDef; int32_t iCurrentIndex;
if (iIndex<0) return NULL; if (iIndex<0) return NULL;
for (pDef=FirstDef,iCurrentIndex=-1; pDef; pDef=pDef->Next) for (pDef=FirstDef,iCurrentIndex=-1; pDef; pDef=pDef->Next)
if (pDef->Category & dwCategory) if (pDef->Category & dwCategory)
{ {
iCurrentIndex++; iCurrentIndex++;
if (iCurrentIndex==iIndex) return pDef; if (iCurrentIndex==iIndex) return pDef;
} }
return NULL; return NULL;
} }
C4Def *C4DefList::GetByPath(const char *szPath) C4Def *C4DefList::GetByPath(const char *szPath)
{ {
// search defs // search defs
const char *szDefPath; const char *szDefPath;
for(C4Def *pDef = FirstDef; pDef; pDef = pDef->Next) for(C4Def *pDef = FirstDef; pDef; pDef = pDef->Next)
if((szDefPath = Config.AtRelativePath(pDef->Filename))) if((szDefPath = Config.AtRelativePath(pDef->Filename)))
if(SEqual2NoCase(szPath, szDefPath)) if(SEqual2NoCase(szPath, szDefPath))
{ {
// the definition itself? // the definition itself?
if(!szPath[SLen(szDefPath)]) if(!szPath[SLen(szDefPath)])
return pDef; return pDef;
// or a component? // or a component?
else if(szPath[SLen(szDefPath)] == '\\') else if(szPath[SLen(szDefPath)] == '\\')
if(!strchr(szPath + SLen(szDefPath) + 1, '\\')) if(!strchr(szPath + SLen(szDefPath) + 1, '\\'))
return pDef; return pDef;
} }
// not found // not found
return NULL; return NULL;
} }
int32_t C4DefList::RemoveTemporary() int32_t C4DefList::RemoveTemporary()
{ {
C4Def *cdef,*prev,*next; C4Def *cdef,*prev,*next;
int32_t removed=0; int32_t removed=0;
for (cdef=FirstDef,prev=NULL; cdef; cdef=next) for (cdef=FirstDef,prev=NULL; cdef; cdef=next)
{ {
next=cdef->Next; next=cdef->Next;
if (cdef->Temporary) if (cdef->Temporary)
{ {
if (prev) prev->Next=next; if (prev) prev->Next=next;
else FirstDef=next; else FirstDef=next;
delete cdef; delete cdef;
removed++; removed++;
} }
else else
prev=cdef; prev=cdef;
} }
// rebuild quick access table // rebuild quick access table
BuildTable(); BuildTable();
return removed; return removed;
} }
int32_t C4DefList::CheckEngineVersion(int32_t ver1, int32_t ver2, int32_t ver3, int32_t ver4) int32_t C4DefList::CheckEngineVersion(int32_t ver1, int32_t ver2, int32_t ver3, int32_t ver4)
{ {
int32_t rcount=0; int32_t rcount=0;
C4Def *cdef,*prev,*next; C4Def *cdef,*prev,*next;
for (cdef=FirstDef,prev=NULL; cdef; cdef=next) for (cdef=FirstDef,prev=NULL; cdef; cdef=next)
{ {
next=cdef->Next; next=cdef->Next;
if (CompareVersion(cdef->rC4XVer[0],cdef->rC4XVer[1],cdef->rC4XVer[2],cdef->rC4XVer[3],ver1,ver2,ver3,ver4) > 0) if (CompareVersion(cdef->rC4XVer[0],cdef->rC4XVer[1],cdef->rC4XVer[2],cdef->rC4XVer[3],ver1,ver2,ver3,ver4) > 0)
{ {
if (prev) prev->Next=cdef->Next; if (prev) prev->Next=cdef->Next;
else FirstDef=cdef->Next; else FirstDef=cdef->Next;
delete cdef; delete cdef;
rcount++; rcount++;
} }
else prev=cdef; else prev=cdef;
} }
return rcount; return rcount;
@ -1144,7 +1144,7 @@ int32_t C4DefList::CheckEngineVersion(int32_t ver1, int32_t ver2, int32_t ver3,
int32_t C4DefList::CheckRequireDef() int32_t C4DefList::CheckRequireDef()
{ {
int32_t rcount=0, rcount2; int32_t rcount=0, rcount2;
C4Def *cdef,*prev,*next; C4Def *cdef,*prev,*next;
do do
{ {
rcount2 = rcount; rcount2 = rcount;

View File

@ -139,47 +139,47 @@ const DWORD C4D_Load_None = 0,
#define C4D_Blit_ModAdd 2 #define C4D_Blit_ModAdd 2
class C4Def: public C4PropList class C4Def: public C4PropList
{ {
public: public:
C4ID id; C4ID id;
int32_t rC4XVer[4]; int32_t rC4XVer[4];
C4IDList RequireDef; C4IDList RequireDef;
C4PhysicalInfo Physical; C4PhysicalInfo Physical;
C4Shape Shape; C4Shape Shape;
C4Rect Entrance; C4Rect Entrance;
C4Rect Collection; C4Rect Collection;
C4Rect PictureRect; C4Rect PictureRect;
C4TargetRect SolidMask; C4TargetRect SolidMask;
C4TargetRect TopFace; C4TargetRect TopFace;
C4IDList Component; C4IDList Component;
C4ID BurnTurnTo; C4ID BurnTurnTo;
C4ID BuildTurnTo; C4ID BuildTurnTo;
int32_t GrowthType; int32_t GrowthType;
int32_t CrewMember; int32_t CrewMember;
int32_t NativeCrew; int32_t NativeCrew;
int32_t Mass; int32_t Mass;
int32_t Value; int32_t Value;
int32_t Exclusive; int32_t Exclusive;
int32_t Category; int32_t Category;
int32_t Growth; int32_t Growth;
int32_t Rebuyable; int32_t Rebuyable;
int32_t ContactIncinerate; // 0 off 1 high - 5 low int32_t ContactIncinerate; // 0 off 1 high - 5 low
int32_t BlastIncinerate; // 0 off 1 - x if > damage int32_t BlastIncinerate; // 0 off 1 - x if > damage
int32_t Constructable; int32_t Constructable;
int32_t Grab; // 0 not 1 push 2 grab only int32_t Grab; // 0 not 1 push 2 grab only
int32_t Carryable; int32_t Carryable;
int32_t Rotateable; int32_t Rotateable;
int32_t Chopable; int32_t Chopable;
int32_t Float; int32_t Float;
int32_t ColorByOwner; int32_t ColorByOwner;
int32_t NoHorizontalMove; int32_t NoHorizontalMove;
int32_t BorderBound; int32_t BorderBound;
int32_t LiftTop; int32_t LiftTop;
int32_t GrabPutGet; int32_t GrabPutGet;
int32_t ContainBlast; int32_t ContainBlast;
int32_t UprightAttach; int32_t UprightAttach;
int32_t ContactFunctionCalls; int32_t ContactFunctionCalls;
int32_t MaxUserSelect; int32_t MaxUserSelect;
int32_t Line; int32_t Line;
int32_t LineConnect; int32_t LineConnect;
int32_t LineIntersect; int32_t LineIntersect;
@ -201,7 +201,7 @@ class C4Def: public C4PropList
int32_t Timer; int32_t Timer;
int32_t NoComponentMass; int32_t NoComponentMass;
int32_t NoStabilize; int32_t NoStabilize;
char STimerCall[C4AUL_MAX_Identifier]; char STimerCall[C4AUL_MAX_Identifier];
int32_t ClosedContainer; // if set, contained objects are not damaged by lava/acid etc. 1: Contained objects can't view out; 2: They can int32_t ClosedContainer; // if set, contained objects are not damaged by lava/acid etc. 1: Contained objects can't view out; 2: They can
int32_t SilentCommands; // if set, no command failure messages are printed int32_t SilentCommands; // if set, no command failure messages are printed
int32_t NoBurnDamage; // if set, the object won't take damage when burning int32_t NoBurnDamage; // if set, the object won't take damage when burning
@ -221,7 +221,7 @@ class C4Def: public C4PropList
int32_t AllowPictureStack; // allow stacking of multiple items in menus even if some attributes do not match. APS_*-values int32_t AllowPictureStack; // allow stacking of multiple items in menus even if some attributes do not match. APS_*-values
public: public:
void DefaultDefCore(); void DefaultDefCore();
bool LoadDefCore(C4Group &hGroup); bool LoadDefCore(C4Group &hGroup);
bool Save(C4Group &hGroup); bool Save(C4Group &hGroup);
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
protected: protected:
@ -230,11 +230,11 @@ class C4Def: public C4PropList
// Here begins the C4Def // Here begins the C4Def
friend class C4DefList; friend class C4DefList;
public: public:
C4Def(); C4Def();
~C4Def(); ~C4Def();
public: public:
char Maker[C4MaxName+1]; char Maker[C4MaxName+1];
char Filename[_MAX_FNAME+1]; char Filename[_MAX_FNAME+1];
int32_t Creation; int32_t Creation;
@ -264,25 +264,25 @@ class C4Def: public C4PropList
C4Facet MainFace; C4Facet MainFace;
protected: protected:
C4Def *Next; C4Def *Next;
bool Temporary; bool Temporary;
public: public:
void Clear(); void Clear();
void Default(); void Default();
bool Load(C4Group &hGroup, bool Load(C4Group &hGroup,
DWORD dwLoadWhat, const char *szLanguage, DWORD dwLoadWhat, const char *szLanguage,
class C4SoundSystem *pSoundSystem = NULL); class C4SoundSystem *pSoundSystem = NULL);
void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=NULL, int32_t iPhaseX=0, int32_t iPhaseY=0); void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=NULL, int32_t iPhaseX=0, int32_t iPhaseY=0);
inline C4Facet &GetMainFace(C4DefGraphics *pGraphics, DWORD dwClr=0) { MainFace.Surface=pGraphics->GetBitmap(dwClr); return MainFace; } inline C4Facet &GetMainFace(C4DefGraphics *pGraphics, DWORD dwClr=0) { MainFace.Surface=pGraphics->GetBitmap(dwClr); return MainFace; }
int32_t GetValue(C4Object *pInBase, int32_t iBuyPlayer); // get value of def; calling script functions if defined int32_t GetValue(C4Object *pInBase, int32_t iBuyPlayer); // get value of def; calling script functions if defined
C4PhysicalInfo *GetFairCrewPhysicals(); // get fair crew physicals at current fair crew strength C4PhysicalInfo *GetFairCrewPhysicals(); // get fair crew physicals at current fair crew strength
void ClearFairCrewPhysicals(); // remove cached fair crew physicals, will be created fresh on demand void ClearFairCrewPhysicals(); // remove cached fair crew physicals, will be created fresh on demand
void Synchronize(); void Synchronize();
const char *GetDesc() { return Desc.GetData(); } const char *GetDesc() { return Desc.GetData(); }
virtual C4Def* GetDef() { return this; } virtual C4Def* GetDef() { return this; }
protected: protected:
bool LoadPortraits(C4Group &hGroup); bool LoadPortraits(C4Group &hGroup);
bool LoadActMap(C4Group &hGroup); bool LoadActMap(C4Group &hGroup);
void CrossMapActMap(); void CrossMapActMap();
@ -299,34 +299,34 @@ class C4Def: public C4PropList
C4PropList *GetActionByName(const char *actname); C4PropList *GetActionByName(const char *actname);
C4PropList *GetActionByName(C4String *actname); C4PropList *GetActionByName(C4String *actname);
}; };
class C4DefList class C4DefList
: public CStdFont::CustomImages : public CStdFont::CustomImages
{ {
public: public:
C4DefList(); C4DefList();
virtual ~C4DefList(); virtual ~C4DefList();
public: public:
bool LoadFailure; bool LoadFailure;
typedef std::map<C4ID, C4Def*> Table; typedef std::map<C4ID, C4Def*> Table;
Table table; Table table;
protected: protected:
C4Def *FirstDef; C4Def *FirstDef;
public: public:
void Default(); void Default();
void Clear(); void Clear();
int32_t Load(C4Group &hGroup, int32_t Load(C4Group &hGroup,
DWORD dwLoadWhat, const char *szLanguage, DWORD dwLoadWhat, const char *szLanguage,
C4SoundSystem *pSoundSystem = NULL, C4SoundSystem *pSoundSystem = NULL,
bool fOverload = false, bool fOverload = false,
bool fSearchMessage = false, int32_t iMinProgress=0, int32_t iMaxProgress=0, bool fLoadSysGroups = true); bool fSearchMessage = false, int32_t iMinProgress=0, int32_t iMaxProgress=0, bool fLoadSysGroups = true);
int32_t Load(const char *szSearch, int32_t Load(const char *szSearch,
DWORD dwLoadWhat, const char *szLanguage, DWORD dwLoadWhat, const char *szLanguage,
C4SoundSystem *pSoundSystem = NULL, C4SoundSystem *pSoundSystem = NULL,
bool fOverload = false, int32_t iMinProgress=0, int32_t iMaxProgress=0); bool fOverload = false, int32_t iMinProgress=0, int32_t iMaxProgress=0);
int32_t LoadFolderLocal(const char *szPath, int32_t LoadFolderLocal(const char *szPath,
DWORD dwLoadWhat, const char *szLanguage, DWORD dwLoadWhat, const char *szLanguage,
C4SoundSystem *pSoundSystem = NULL, C4SoundSystem *pSoundSystem = NULL,
bool fOverload = false, char *szStoreName=NULL, int32_t iMinProgress=0, int32_t iMaxProgress=0); bool fOverload = false, char *szStoreName=NULL, int32_t iMinProgress=0, int32_t iMaxProgress=0);
int32_t LoadForScenario(const char *szScenario, int32_t LoadForScenario(const char *szScenario,
@ -334,19 +334,19 @@ class C4DefList
DWORD dwLoadWhat, const char *szLanguage, DWORD dwLoadWhat, const char *szLanguage,
C4SoundSystem *pSoundSystem = NULL, C4SoundSystem *pSoundSystem = NULL,
bool fOverload = false, int32_t iMinProgress=0, int32_t iMaxProgress=0); bool fOverload = false, int32_t iMinProgress=0, int32_t iMaxProgress=0);
C4Def *ID2Def(C4ID id); C4Def *ID2Def(C4ID id);
C4Def *GetDef(int32_t Index, DWORD dwCategory = C4D_All); C4Def *GetDef(int32_t Index, DWORD dwCategory = C4D_All);
C4Def *GetByPath(const char *szPath); C4Def *GetByPath(const char *szPath);
int32_t GetDefCount(DWORD dwCategory = C4D_All); int32_t GetDefCount(DWORD dwCategory = C4D_All);
int32_t GetIndex(C4ID id); int32_t GetIndex(C4ID id);
int32_t RemoveTemporary(); int32_t RemoveTemporary();
int32_t CheckEngineVersion(int32_t ver1, int32_t ver2, int32_t ver3, int32_t ver4); int32_t CheckEngineVersion(int32_t ver1, int32_t ver2, int32_t ver3, int32_t ver4);
int32_t CheckRequireDef(); int32_t CheckRequireDef();
void Draw(C4ID id, C4Facet &cgo, bool fSelected, int32_t iColor); void Draw(C4ID id, C4Facet &cgo, bool fSelected, int32_t iColor);
void Remove(C4Def *def); void Remove(C4Def *def);
bool Remove(C4ID id); bool Remove(C4ID id);
bool Reload(C4Def *pDef, DWORD dwLoadWhat, const char *szLanguage, C4SoundSystem *pSoundSystem = NULL); bool Reload(C4Def *pDef, DWORD dwLoadWhat, const char *szLanguage, C4SoundSystem *pSoundSystem = NULL);
bool Add(C4Def *ndef, bool fOverload); bool Add(C4Def *ndef, bool fOverload);
void BuildTable(); void BuildTable();
void ResetIncludeDependencies(); // resets all pointers into foreign definitions caused by include chains void ResetIncludeDependencies(); // resets all pointers into foreign definitions caused by include chains
void CallEveryDefinition(); void CallEveryDefinition();
@ -354,7 +354,7 @@ class C4DefList
// callback from font renderer: get ID image // callback from font renderer: get ID image
virtual bool GetFontImage(const char *szImageTag, CFacet &rOutImgFacet); virtual bool GetFontImage(const char *szImageTag, CFacet &rOutImgFacet);
}; };
extern C4DefList Definitions; extern C4DefList Definitions;

View File

@ -453,8 +453,8 @@ C4ObjectList &C4GameObjects::ObjectsInt()
void C4GameObjects::RemoveSolidMasks() void C4GameObjects::RemoveSolidMasks()
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
if (cLnk->Obj->pSolidMaskData) if (cLnk->Obj->pSolidMaskData)
cLnk->Obj->pSolidMaskData->Remove(false, false); cLnk->Obj->pSolidMaskData->Remove(false, false);
@ -462,8 +462,8 @@ void C4GameObjects::RemoveSolidMasks()
void C4GameObjects::PutSolidMasks() void C4GameObjects::PutSolidMasks()
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
cLnk->Obj->UpdateSolidMask(false); cLnk->Obj->UpdateSolidMask(false);
} }
@ -478,13 +478,13 @@ void C4GameObjects::DeleteObjects(bool fDeleteInactive)
} }
void C4GameObjects::Clear(bool fClearInactive) void C4GameObjects::Clear(bool fClearInactive)
{ {
DeleteObjects(fClearInactive); DeleteObjects(fClearInactive);
if(fClearInactive) if(fClearInactive)
InactiveObjects.Clear(); InactiveObjects.Clear();
ResortProc = NULL; ResortProc = NULL;
LastUsedMarker = 0; LastUsedMarker = 0;
} }
/* C4ObjResort */ /* C4ObjResort */
@ -696,26 +696,26 @@ int C4GameObjects::Load(C4Group &hGroup, bool fKeepInactive)
Clear(!fKeepInactive); Clear(!fKeepInactive);
// Load data component // Load data component
StdStrBuf Source; StdStrBuf Source;
if (!hGroup.LoadEntryString(C4CFN_ScenarioObjects, Source)) if (!hGroup.LoadEntryString(C4CFN_ScenarioObjects, Source))
return 0; return 0;
// Compile // Compile
StdStrBuf Name = hGroup.GetFullName() + DirSep C4CFN_ScenarioObjects; StdStrBuf Name = hGroup.GetFullName() + DirSep C4CFN_ScenarioObjects;
if(!CompileFromBuf_LogWarn<StdCompilerINIRead>( if(!CompileFromBuf_LogWarn<StdCompilerINIRead>(
mkParAdapt(*this, false), mkParAdapt(*this, false),
Source, Source,
Name.getData())) Name.getData()))
return 0; return 0;
// Process objects // Process objects
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
C4Object *pObj; C4Object *pObj;
bool fObjectNumberCollision = false; bool fObjectNumberCollision = false;
int32_t iMaxObjectNumber = 0; int32_t iMaxObjectNumber = 0;
for(cLnk = Last; cLnk; cLnk = cLnk->Prev) for(cLnk = Last; cLnk; cLnk = cLnk->Prev)
{ {
C4Object *pObj = cLnk->Obj; C4Object *pObj = cLnk->Obj;
// check object number collision with inactive list // check object number collision with inactive list
if (fKeepInactive) if (fKeepInactive)
{ {
@ -733,7 +733,7 @@ int C4GameObjects::Load(C4Group &hGroup, bool fKeepInactive)
// Unterminate end // Unterminate end
} }
// Denumerate pointers // Denumerate pointers
// if object numbers collideded, numbers will be adjusted afterwards // if object numbers collideded, numbers will be adjusted afterwards
// so fake inactive object list empty meanwhile // so fake inactive object list empty meanwhile
C4ObjectLink *pInFirst = NULL; C4ObjectLink *pInFirst = NULL;
@ -794,7 +794,7 @@ int C4GameObjects::Load(C4Group &hGroup, bool fKeepInactive)
} }
} }
// sort out inactive objects // sort out inactive objects
C4ObjectLink *cLnkNext; C4ObjectLink *cLnkNext;
for (cLnk=First; cLnk; cLnk=cLnkNext) for (cLnk=First; cLnk; cLnk=cLnkNext)
{ {
cLnkNext = cLnk->Next; cLnkNext = cLnk->Next;
@ -827,7 +827,7 @@ int C4GameObjects::Load(C4Group &hGroup, bool fKeepInactive)
//Sectors.Dump(); //Sectors.Dump();
// misc updates // misc updates
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if ((pObj=cLnk->Obj)->Status) if ((pObj=cLnk->Obj)->Status)
{ {
// add to plrview // add to plrview
@ -861,28 +861,28 @@ bool C4GameObjects::Save(const char *szFilename, bool fSaveGame, bool fSaveInact
InactiveObjects.Enumerate(); InactiveObjects.Enumerate();
// Decompile objects to buffer // Decompile objects to buffer
StdStrBuf Buffer; StdStrBuf Buffer;
bool fSuccess = DecompileToBuf_Log<StdCompilerINIWrite>(mkParAdapt(*this, !fSaveGame), &Buffer, szFilename); bool fSuccess = DecompileToBuf_Log<StdCompilerINIWrite>(mkParAdapt(*this, !fSaveGame), &Buffer, szFilename);
// Decompile inactives // Decompile inactives
if(fSaveInactive) if(fSaveInactive)
{ {
StdStrBuf InactiveBuffer; StdStrBuf InactiveBuffer;
fSuccess &= DecompileToBuf_Log<StdCompilerINIWrite>(mkParAdapt(InactiveObjects, false, !fSaveGame), &InactiveBuffer, szFilename); fSuccess &= DecompileToBuf_Log<StdCompilerINIWrite>(mkParAdapt(InactiveObjects, false, !fSaveGame), &InactiveBuffer, szFilename);
Buffer.Append("\r\n"); Buffer.Append("\r\n");
Buffer.Append(InactiveBuffer); Buffer.Append(InactiveBuffer);
} }
// Denumerate // Denumerate
InactiveObjects.Denumerate(); InactiveObjects.Denumerate();
Denumerate(); Denumerate();
// Error? // Error?
if(!fSuccess) if(!fSuccess)
return false; return false;
// Write // Write
return Buffer.SaveToFile(szFilename); return Buffer.SaveToFile(szFilename);
} }
void C4GameObjects::UpdateScriptPointers() void C4GameObjects::UpdateScriptPointers()
@ -1017,14 +1017,14 @@ void C4GameObjects::FixObjectOrder()
void C4GameObjects::ResortUnsorted() void C4GameObjects::ResortUnsorted()
{ {
C4ObjectLink *clnk=First; C4Object *cObj; C4ObjectLink *clnk=First; C4Object *cObj;
while (clnk && (cObj=clnk->Obj)) while (clnk && (cObj=clnk->Obj))
{ {
clnk=clnk->Next; clnk=clnk->Next;
if (cObj->Unsorted) if (cObj->Unsorted)
{ {
// readd to main object list // readd to main object list
Remove(cObj); Remove(cObj);
cObj->Unsorted=false; cObj->Unsorted=false;
if (!Add(cObj)) if (!Add(cObj))
{ {
@ -1032,9 +1032,9 @@ void C4GameObjects::ResortUnsorted()
Game.ClearPointers(cObj); Game.ClearPointers(cObj);
delete cObj; delete cObj;
} }
} }
} }
} }
void C4GameObjects::ExecuteResorts() void C4GameObjects::ExecuteResorts()
{ {

View File

@ -53,9 +53,9 @@ void C4IDListChunk::Clear()
} }
C4IDList::C4IDList() : C4IDListChunk() C4IDList::C4IDList() : C4IDListChunk()
{ {
Default(); Default();
} }
C4IDList::C4IDList(const C4IDList &rCopy): C4IDListChunk() C4IDList::C4IDList(const C4IDList &rCopy): C4IDListChunk()
{ {
@ -95,48 +95,48 @@ void C4IDList::Clear()
} }
bool C4IDList::IsClear() const bool C4IDList::IsClear() const
{ {
return !Count; return !Count;
} }
C4ID C4IDList::GetID(size_t index, int32_t *ipCount) const C4ID C4IDList::GetID(size_t index, int32_t *ipCount) const
{ {
// outside list? // outside list?
if (!Inside<int32_t>(index,0,Count-1)) return C4ID::None; if (!Inside<int32_t>(index,0,Count-1)) return C4ID::None;
// get chunk to query // get chunk to query
const C4IDListChunk *pQueryChunk=this; const C4IDListChunk *pQueryChunk=this;
while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; } while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; }
// query it // query it
if (ipCount) *ipCount=pQueryChunk->Count[index]; if (ipCount) *ipCount=pQueryChunk->Count[index];
return pQueryChunk->id[index]; return pQueryChunk->id[index];
} }
int32_t C4IDList::GetCount(size_t index) const int32_t C4IDList::GetCount(size_t index) const
{ {
// outside list? // outside list?
if (!Inside<int32_t>(index,0,Count-1)) return 0; if (!Inside<int32_t>(index,0,Count-1)) return 0;
// get chunk to query // get chunk to query
const C4IDListChunk *pQueryChunk=this; const C4IDListChunk *pQueryChunk=this;
while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; } while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; }
// query it // query it
return pQueryChunk->Count[index]; return pQueryChunk->Count[index];
} }
bool C4IDList::SetCount(size_t index, int32_t iCount) bool C4IDList::SetCount(size_t index, int32_t iCount)
{ {
// outside list? // outside list?
if (!Inside<int32_t>(index,0,Count-1)) return false; if (!Inside<int32_t>(index,0,Count-1)) return false;
// get chunk to set in // get chunk to set in
C4IDListChunk *pQueryChunk=this; C4IDListChunk *pQueryChunk=this;
while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; } while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; }
// set it // set it
pQueryChunk->Count[index]=iCount; pQueryChunk->Count[index]=iCount;
// success // success
return true; return true;
} }
int32_t C4IDList::GetIDCount(C4ID c_id, int32_t iZeroDefVal) const int32_t C4IDList::GetIDCount(C4ID c_id, int32_t iZeroDefVal) const
{ {
// find id // find id
const C4IDListChunk *pQueryChunk=this; const C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0; size_t cnt=Count,cntl=0;
@ -154,11 +154,11 @@ int32_t C4IDList::GetIDCount(C4ID c_id, int32_t iZeroDefVal) const
} }
} }
// none found // none found
return 0; return 0;
} }
bool C4IDList::SetIDCount(C4ID c_id, int32_t iCount, bool fAddNewID) bool C4IDList::SetIDCount(C4ID c_id, int32_t iCount, bool fAddNewID)
{ {
// find id // find id
C4IDListChunk *pQueryChunk=this; C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0; size_t cnt=Count,cntl=0;
@ -194,13 +194,13 @@ bool C4IDList::SetIDCount(C4ID c_id, int32_t iCount, bool fAddNewID)
return true; return true;
} }
// failure // failure
return false; return false;
} }
int32_t C4IDList::GetNumberOfIDs() const int32_t C4IDList::GetNumberOfIDs() const
{ {
return Count; return Count;
} }
int32_t C4IDList::GetIndex(C4ID c_id) const int32_t C4IDList::GetIndex(C4ID c_id) const
{ {
@ -221,7 +221,7 @@ int32_t C4IDList::GetIndex(C4ID c_id) const
} }
bool C4IDList::IncreaseIDCount(C4ID c_id, bool fAddNewID, int32_t IncreaseBy, bool fRemoveEmpty) bool C4IDList::IncreaseIDCount(C4ID c_id, bool fAddNewID, int32_t IncreaseBy, bool fRemoveEmpty)
{ {
// find id in list // find id in list
C4IDListChunk *pQueryChunk=this; C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0; size_t cnt=Count,cntl=0;
@ -264,64 +264,64 @@ bool C4IDList::IncreaseIDCount(C4ID c_id, bool fAddNewID, int32_t IncreaseBy, bo
// Access by category-sorted index // Access by category-sorted index
C4ID C4IDList::GetID(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t *ipCount) const C4ID C4IDList::GetID(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t *ipCount) const
{ {
int32_t cindex=-1; int32_t cindex=-1;
C4Def *cDef; C4Def *cDef;
if (ipCount) *ipCount=0; if (ipCount) *ipCount=0;
// find id // find id
const C4IDListChunk *pQueryChunk=this; const C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0; size_t cnt=Count,cntl=0;
while (cnt--) while (cnt--)
{ {
if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) ) if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
{ {
cindex++; cindex++;
if (cindex==index) { if (ipCount) *ipCount=pQueryChunk->Count[cntl]; return pQueryChunk->id[cntl]; } if (cindex==index) { if (ipCount) *ipCount=pQueryChunk->Count[cntl]; return pQueryChunk->id[cntl]; }
} }
if (++cntl==C4IDListChunkSize) if (++cntl==C4IDListChunkSize)
{ {
pQueryChunk=pQueryChunk->pNext; pQueryChunk=pQueryChunk->pNext;
cntl=0; cntl=0;
} }
} }
return C4ID::None; return C4ID::None;
} }
int32_t C4IDList::GetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index) const int32_t C4IDList::GetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index) const
{ {
int32_t cindex=-1; int32_t cindex=-1;
C4Def *cDef; C4Def *cDef;
const C4IDListChunk *pQueryChunk=this; const C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0; size_t cnt=Count,cntl=0;
while (cnt--) while (cnt--)
{ {
if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) ) if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
{ {
cindex++; cindex++;
if (cindex==index) return pQueryChunk->Count[cntl]; if (cindex==index) return pQueryChunk->Count[cntl];
} }
if (++cntl==C4IDListChunkSize) if (++cntl==C4IDListChunkSize)
{ {
pQueryChunk=pQueryChunk->pNext; pQueryChunk=pQueryChunk->pNext;
cntl=0; cntl=0;
} }
} }
return 0; return 0;
} }
bool C4IDList::SetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t iCount) bool C4IDList::SetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t iCount)
{ {
int32_t cindex=-1; int32_t cindex=-1;
C4Def *cDef; C4Def *cDef;
C4IDListChunk *pQueryChunk=this; C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0; size_t cnt=Count,cntl=0;
while (cnt--) while (cnt--)
{ {
if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) ) if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
{ {
cindex++; cindex++;
if (cindex==index) { pQueryChunk->Count[cntl]=iCount; return true; } if (cindex==index) { pQueryChunk->Count[cntl]=iCount; return true; }
} }
if (++cntl==C4IDListChunkSize) if (++cntl==C4IDListChunkSize)
{ {
pQueryChunk=pQueryChunk->pNext; pQueryChunk=pQueryChunk->pNext;
@ -329,26 +329,26 @@ bool C4IDList::SetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index, int
} }
} }
return false; return false;
} }
int32_t C4IDList::GetNumberOfIDs(C4DefList &rDefs, int32_t dwCategory) const int32_t C4IDList::GetNumberOfIDs(C4DefList &rDefs, int32_t dwCategory) const
{ {
int32_t idnum=0; int32_t idnum=0;
C4Def *cDef; C4Def *cDef;
const C4IDListChunk *pQueryChunk=this; const C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0; size_t cnt=Count,cntl=0;
while (cnt--) while (cnt--)
{ {
if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) ) if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
idnum++; idnum++;
if (++cntl==C4IDListChunkSize) if (++cntl==C4IDListChunkSize)
{ {
pQueryChunk=pQueryChunk->pNext; pQueryChunk=pQueryChunk->pNext;
cntl=0; cntl=0;
} }
} }
return idnum; return idnum;
} }
// IDList merge // IDList merge
bool C4IDList::Add(C4IDList &rList) bool C4IDList::Add(C4IDList &rList)
@ -370,13 +370,13 @@ bool C4IDList::Add(C4IDList &rList)
// Removes all empty id gaps from the list. // Removes all empty id gaps from the list.
bool C4IDList::Consolidate() bool C4IDList::Consolidate()
{ {
// however, there ain't be any of those crappy gaps! // however, there ain't be any of those crappy gaps!
return false; return false;
} }
bool C4IDList::ConsolidateValids(C4DefList &rDefs, int32_t dwCategory) bool C4IDList::ConsolidateValids(C4DefList &rDefs, int32_t dwCategory)
{ {
bool fIDsRemoved=false; bool fIDsRemoved=false;
C4IDListChunk *pQueryChunk=this; C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0; size_t cnt=Count,cntl=0;
@ -400,7 +400,7 @@ bool C4IDList::ConsolidateValids(C4DefList &rDefs, int32_t dwCategory)
} }
} }
return fIDsRemoved; return fIDsRemoved;
} }
void C4IDList::SortByCategory(C4DefList &rDefs) void C4IDList::SortByCategory(C4DefList &rDefs)
{ {
@ -443,7 +443,7 @@ void C4IDList::SortByValue(C4DefList &rDefs)
void C4IDList::Load(C4DefList &rDefs, int32_t dwCategory) void C4IDList::Load(C4DefList &rDefs, int32_t dwCategory)
{ {
// (deprecated, use StdCompiler instead) // (deprecated, use StdCompiler instead)
C4Def *cdef; size_t cntl=0,cnt=0; C4Def *cdef; size_t cntl=0,cnt=0;
// clear list // clear list
Clear(); Clear();
@ -484,9 +484,9 @@ void C4IDList::Draw(C4Facet &cgo, int32_t iSelection,
{ {
cgo2 = cgo.TruncateSection(iAlign); cgo2 = cgo.TruncateSection(iAlign);
rDefs.Draw(c_id,cgo2,(firstid+cnt==iSelection),0); rDefs.Draw(c_id,cgo2,(firstid+cnt==iSelection),0);
sprintf(buf,"%dx",idcount); sprintf(buf,"%dx",idcount);
if (fCounts) Application.DDraw->TextOut(buf, ::GraphicsResource.FontRegular, 1.0, cgo2.Surface,cgo2.X+cgo2.Wdt-1, cgo2.Y + cgo2.Hgt - 1 - ::GraphicsResource.FontRegular.iLineHgt,CStdDDraw::DEFAULT_MESSAGE_COLOR,ARight); if (fCounts) Application.DDraw->TextOut(buf, ::GraphicsResource.FontRegular, 1.0, cgo2.Surface,cgo2.X+cgo2.Wdt-1, cgo2.Y + cgo2.Hgt - 1 - ::GraphicsResource.FontRegular.iLineHgt,CStdDDraw::DEFAULT_MESSAGE_COLOR,ARight);
} }
} }
@ -592,64 +592,64 @@ bool C4IDList::operator==(const C4IDList& rhs) const
} }
void C4IDList::CompileFunc(StdCompiler *pComp, bool fValues) void C4IDList::CompileFunc(StdCompiler *pComp, bool fValues)
{ {
// Get compiler characteristics // Get compiler characteristics
bool fCompiler = pComp->isCompiler(); bool fCompiler = pComp->isCompiler();
bool fNaming = pComp->hasNaming(); bool fNaming = pComp->hasNaming();
// Compiling: Clear existing data first // Compiling: Clear existing data first
if(fCompiler) Clear(); if(fCompiler) Clear();
// Start // Start
C4IDListChunk *pChunk = this; C4IDListChunk *pChunk = this;
size_t iNr = 0, iCNr = 0; size_t iNr = 0, iCNr = 0;
// Without naming: Compile Count // Without naming: Compile Count
int32_t iCount = Count; int32_t iCount = Count;
if(!fNaming) pComp->Value(iCount); if(!fNaming) pComp->Value(iCount);
Count = iCount; Count = iCount;
// Read // Read
for(;;) for(;;)
{ {
// Prepare compiling of single mapping // Prepare compiling of single mapping
if(!fCompiler) if(!fCompiler)
{ {
// End of list? // End of list?
if(iNr >= Count) break; if(iNr >= Count) break;
// End of chunk? // End of chunk?
if(iCNr >= C4IDListChunkSize) if(iCNr >= C4IDListChunkSize)
{ {
pChunk = pChunk->pNext; pChunk = pChunk->pNext;
iCNr = 0; iCNr = 0;
} }
} }
else else
{ {
// End of list? // End of list?
if(!fNaming) if(iNr >= Count) break; if(!fNaming) if(iNr >= Count) break;
// End of chunk? // End of chunk?
if(iCNr >= C4IDListChunkSize) if(iCNr >= C4IDListChunkSize)
{ {
pChunk = pChunk->pNext = new C4IDListChunk(); pChunk = pChunk->pNext = new C4IDListChunk();
iCNr = 0; iCNr = 0;
} }
} }
// Seperator (';') // Seperator (';')
if(iNr > 0) if(!pComp->Seperator(StdCompiler::SEP_SEP2)) break; if(iNr > 0) if(!pComp->Seperator(StdCompiler::SEP_SEP2)) break;
// ID // ID
pComp->Value(mkDefaultAdapt(pChunk->id[iCNr], C4ID::None)); pComp->Value(mkDefaultAdapt(pChunk->id[iCNr], C4ID::None));
// ID not valid? Note that C4ID::None is invalid. // ID not valid? Note that C4ID::None is invalid.
if(pChunk->id[iCNr] == C4ID::None) break; if(pChunk->id[iCNr] == C4ID::None) break;
// Value: Skip this part if requested // Value: Skip this part if requested
if(fValues) if(fValues)
{ {
// Seperator ('=') // Seperator ('=')
if(pComp->Seperator(StdCompiler::SEP_SET)) if(pComp->Seperator(StdCompiler::SEP_SET))
// Count // Count
pComp->Value(mkDefaultAdapt(pChunk->Count[iCNr], 0)); pComp->Value(mkDefaultAdapt(pChunk->Count[iCNr], 0));
} }
else if(fCompiler) else if(fCompiler)
pChunk->Count[iCNr] = 0; pChunk->Count[iCNr] = 0;
// Goto next entry // Goto next entry
iNr++; iCNr++; iNr++; iCNr++;
// Save back count // Save back count
if(fCompiler && fNaming) Count = iNr; if(fCompiler && fNaming) Count = iNr;
} }
} }

View File

@ -35,7 +35,7 @@ const size_t C4IDListChunkSize = 5; // size of id-chunks
class C4IDListChunk class C4IDListChunk
{ {
public: public:
C4ID id[C4IDListChunkSize]; C4ID id[C4IDListChunkSize];
int32_t Count[C4IDListChunkSize]; int32_t Count[C4IDListChunkSize];
@ -50,9 +50,9 @@ class C4IDListChunk
}; };
class C4IDList : protected C4IDListChunk class C4IDList : protected C4IDListChunk
{ {
public: public:
C4IDList(); C4IDList();
C4IDList(const C4IDList &rCopy); // copy ctor C4IDList(const C4IDList &rCopy); // copy ctor
C4IDList &operator = (const C4IDList &rCopy); // assignment C4IDList &operator = (const C4IDList &rCopy); // assignment
~C4IDList(); ~C4IDList();
@ -61,37 +61,37 @@ class C4IDList : protected C4IDListChunk
ALLOW_TEMP_TO_REF(C4IDList) ALLOW_TEMP_TO_REF(C4IDList)
protected: protected:
size_t Count; // number of IDs in this list size_t Count; // number of IDs in this list
public: public:
// General // General
void Default(); void Default();
void Clear(); void Clear();
bool IsClear() const; bool IsClear() const;
// Access by direct index // Access by direct index
C4ID GetID(size_t index, int32_t *ipCount=NULL) const; C4ID GetID(size_t index, int32_t *ipCount=NULL) const;
int32_t GetCount(size_t index) const; int32_t GetCount(size_t index) const;
bool SetCount(size_t index, int32_t iCount); bool SetCount(size_t index, int32_t iCount);
// Access by ID // Access by ID
int32_t GetIDCount(C4ID c_id, int32_t iZeroDefVal=0) const; int32_t GetIDCount(C4ID c_id, int32_t iZeroDefVal=0) const;
bool SetIDCount(C4ID c_id, int32_t iCount, bool fAddNewID=false); bool SetIDCount(C4ID c_id, int32_t iCount, bool fAddNewID=false);
bool IncreaseIDCount(C4ID c_id, bool fAddNewID=true, int32_t IncreaseBy=1, bool fRemoveEmpty=false); bool IncreaseIDCount(C4ID c_id, bool fAddNewID=true, int32_t IncreaseBy=1, bool fRemoveEmpty=false);
bool DecreaseIDCount(C4ID c_id, bool fRemoveEmptyID=true) bool DecreaseIDCount(C4ID c_id, bool fRemoveEmptyID=true)
{ return IncreaseIDCount(c_id, false, -1, fRemoveEmptyID); } { return IncreaseIDCount(c_id, false, -1, fRemoveEmptyID); }
int32_t GetNumberOfIDs() const; int32_t GetNumberOfIDs() const;
int32_t GetIndex(C4ID c_id) const; int32_t GetIndex(C4ID c_id) const;
// Access by category-sorted index // Access by category-sorted index
C4ID GetID(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t *ipCount=NULL) const; C4ID GetID(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t *ipCount=NULL) const;
int32_t GetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index) const; int32_t GetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index) const;
bool SetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t iCount); bool SetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t iCount);
int32_t GetNumberOfIDs(C4DefList &rDefs, int32_t dwCategory) const; int32_t GetNumberOfIDs(C4DefList &rDefs, int32_t dwCategory) const;
// IDList merge // IDList merge
bool Add(C4IDList &rList); bool Add(C4IDList &rList);
// Aux // Aux
bool Consolidate(); bool Consolidate();
bool ConsolidateValids(C4DefList &rDefs, int32_t dwCategory = 0); bool ConsolidateValids(C4DefList &rDefs, int32_t dwCategory = 0);
bool ConsolidateCounts(); bool ConsolidateCounts();
void SortByCategory(C4DefList &rDefs); void SortByCategory(C4DefList &rDefs);
void SortByValue(C4DefList &rDefs); void SortByValue(C4DefList &rDefs);
void Load(C4DefList &rDefs, int32_t dwCategory); void Load(C4DefList &rDefs, int32_t dwCategory);
// Item operation // Item operation
bool DeleteItem(size_t iIndex); bool DeleteItem(size_t iIndex);
bool SwapItems(size_t iIndex1, size_t iIndex2); bool SwapItems(size_t iIndex1, size_t iIndex2);
@ -99,8 +99,8 @@ class C4IDList : protected C4IDListChunk
void Draw(C4Facet &cgo, int32_t iSelection, void Draw(C4Facet &cgo, int32_t iSelection,
C4DefList &rDefs, DWORD dwCategory, C4DefList &rDefs, DWORD dwCategory,
bool fCounts=true, int32_t iAlign=0) const; bool fCounts=true, int32_t iAlign=0) const;
// Compiling // Compiling
void CompileFunc(StdCompiler *pComp, bool fValues = true); void CompileFunc(StdCompiler *pComp, bool fValues = true);
}; };
#endif #endif

View File

@ -37,10 +37,10 @@
//------------------------------- Player Info ---------------------------------------- //------------------------------- Player Info ----------------------------------------
C4PlayerInfoCore::C4PlayerInfoCore() C4PlayerInfoCore::C4PlayerInfoCore()
{ {
ZeroMem(this,sizeof(C4PlayerInfoCore)); ZeroMem(this,sizeof(C4PlayerInfoCore));
Default(); Default();
} }
void C4PlayerInfoCore::Default(C4RankSystem *pRanks) void C4PlayerInfoCore::Default(C4RankSystem *pRanks)
{ {
@ -74,7 +74,7 @@ DWORD C4PlayerInfoCore::GetPrefColorValue(int32_t iPrefColor)
} }
bool C4PlayerInfoCore::Load(C4Group &hGroup) bool C4PlayerInfoCore::Load(C4Group &hGroup)
{ {
// New version // New version
StdStrBuf Source; StdStrBuf Source;
if (hGroup.LoadEntryString(C4CFN_PlayerInfoCore,Source)) if (hGroup.LoadEntryString(C4CFN_PlayerInfoCore,Source))
@ -99,11 +99,11 @@ bool C4PlayerInfoCore::Load(C4Group &hGroup)
} }
// Old version no longer supported - sorry // Old version no longer supported - sorry
return false; return false;
} }
bool C4PlayerInfoCore::Save(C4Group &hGroup) bool C4PlayerInfoCore::Save(C4Group &hGroup)
{ {
StdStrBuf Source, Name = hGroup.GetFullName(); Name.Append(DirSep C4CFN_PlayerInfoCore); StdStrBuf Source, Name = hGroup.GetFullName(); Name.Append(DirSep C4CFN_PlayerInfoCore);
if(!DecompileToBuf_Log<StdCompilerINIWrite>(*this, &Source, Name.getData())) if(!DecompileToBuf_Log<StdCompilerINIWrite>(*this, &Source, Name.getData()))
return false; return false;
@ -349,14 +349,14 @@ void C4PhysicalChange::CompileFunc(StdCompiler *pComp)
//------------------------------- Object Info ---------------------------------------- //------------------------------- Object Info ----------------------------------------
C4ObjectInfoCore::C4ObjectInfoCore() C4ObjectInfoCore::C4ObjectInfoCore()
{ {
Default(); Default();
} }
void C4ObjectInfoCore::Default(C4ID n_id, void C4ObjectInfoCore::Default(C4ID n_id,
C4DefList *pDefs, C4DefList *pDefs,
const char *cpNames) const char *cpNames)
{ {
// Def // Def
C4Def *pDef=NULL; C4Def *pDef=NULL;
@ -364,8 +364,8 @@ void C4ObjectInfoCore::Default(C4ID n_id,
// Defaults // Defaults
id=n_id; id=n_id;
Participation=1; Participation=1;
Rank=0; Rank=0;
Experience=0; Experience=0;
Rounds=0; Rounds=0;
DeathCount=0; DeathCount=0;

View File

@ -31,31 +31,31 @@ const int32_t C4MaxPhysical = 100000,
C4MaxDeathMsg = 75; C4MaxDeathMsg = 75;
class C4PhysicalInfo class C4PhysicalInfo
{ {
public: public:
C4PhysicalInfo(); C4PhysicalInfo();
typedef int32_t C4PhysicalInfo::* Offset; typedef int32_t C4PhysicalInfo::* Offset;
public: public:
int32_t Energy; int32_t Energy;
int32_t Breath; int32_t Breath;
int32_t Walk; int32_t Walk;
int32_t Jump; int32_t Jump;
int32_t Scale; int32_t Scale;
int32_t Hangle; int32_t Hangle;
int32_t Dig; int32_t Dig;
int32_t Swim; int32_t Swim;
int32_t Throw; int32_t Throw;
int32_t Push; int32_t Push;
int32_t Fight; int32_t Fight;
int32_t Magic; int32_t Magic;
int32_t CanScale; int32_t CanScale;
int32_t CanHangle; int32_t CanHangle;
int32_t CanDig; int32_t CanDig;
int32_t CanConstruct; int32_t CanConstruct;
int32_t CanChop; int32_t CanChop;
int32_t CanSwimDig; int32_t CanSwimDig;
int32_t CanFly; int32_t CanFly;
int32_t CorrosionResist; int32_t CorrosionResist;
int32_t BreatheWater; int32_t BreatheWater;
@ -78,7 +78,7 @@ class C4PhysicalInfo
static void TrainValue(int32_t *piVal, int32_t iTrainBy, int32_t iMaxTrain); static void TrainValue(int32_t *piVal, int32_t iTrainBy, int32_t iMaxTrain);
public: public:
void Train(Offset mpiOffset, int32_t iTrainBy, int32_t iMaxTrain); void Train(Offset mpiOffset, int32_t iTrainBy, int32_t iMaxTrain);
}; };
class C4PhysicalChange class C4PhysicalChange
{ {
@ -125,33 +125,33 @@ class C4TempPhysicalInfo : public C4PhysicalInfo
}; };
class C4ObjectInfoCore class C4ObjectInfoCore
{ {
public: public:
C4ObjectInfoCore(); C4ObjectInfoCore();
public: public:
C4ID id; C4ID id;
char Name[C4MaxName+1]; char Name[C4MaxName+1];
int32_t Participation; int32_t Participation;
int32_t Rank; int32_t Rank;
StdStrBuf sRankName; StdStrBuf sRankName;
StdStrBuf sNextRankName; StdStrBuf sNextRankName;
int32_t NextRankExp; // EXP_NoPromotion for no more promotion; 0 if standard rank system is used int32_t NextRankExp; // EXP_NoPromotion for no more promotion; 0 if standard rank system is used
int32_t Experience,Rounds; int32_t Experience,Rounds;
int32_t DeathCount; int32_t DeathCount;
char TypeName[C4MaxName+1+1]; char TypeName[C4MaxName+1+1];
int32_t Birthday,TotalPlayingTime; int32_t Birthday,TotalPlayingTime;
int32_t Age; int32_t Age;
char DeathMessage[C4MaxDeathMsg+1]; char DeathMessage[C4MaxDeathMsg+1];
char PortraitFile[C4MaxName+2+4+1]; // used portrait char PortraitFile[C4MaxName+2+4+1]; // used portrait
C4PhysicalInfo Physical; C4PhysicalInfo Physical;
C4ValueMapData ExtraData; C4ValueMapData ExtraData;
bool NoSave; // set for _XYZ-CrewMembers bool NoSave; // set for _XYZ-CrewMembers
public: public:
bool Save(C4Group &hGroup, class C4DefList *pDefs); bool Save(C4Group &hGroup, class C4DefList *pDefs);
bool Load(C4Group &hGroup); bool Load(C4Group &hGroup);
void Default(C4ID n_id=C4ID::None, class C4DefList *pDefs=NULL, const char *cpNames=NULL); void Default(C4ID n_id=C4ID::None, class C4DefList *pDefs=NULL, const char *cpNames=NULL);
//bool LoadNext(C4Group &hGroup); Old c4o support disabled... //bool LoadNext(C4Group &hGroup); Old c4o support disabled...
//bool Add(C4Group &hGroup); //bool Add(C4Group &hGroup);
void Promote(int32_t iRank, C4RankSystem &rRanks, bool fForceRankName); void Promote(int32_t iRank, C4RankSystem &rRanks, bool fForceRankName);
bool GetNextRankInfo(C4RankSystem &rDefaultRanks, int32_t *piNextRankExp, StdStrBuf *psNextRankName); bool GetNextRankInfo(C4RankSystem &rDefaultRanks, int32_t *piNextRankExp, StdStrBuf *psNextRankName);
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
@ -160,24 +160,24 @@ class C4ObjectInfoCore
bool Decompile(char **ppOutput, size_t *ipSize); bool Decompile(char **ppOutput, size_t *ipSize);
void UpdateCustomRanks(C4DefList *pDefs); // sets NextRankName and NextRankExp void UpdateCustomRanks(C4DefList *pDefs); // sets NextRankName and NextRankExp
}; };
class C4RoundResult class C4RoundResult
{ {
public: public:
C4RoundResult(); C4RoundResult();
public: public:
StdCopyStrBuf Title; StdCopyStrBuf Title;
uint32_t Date; uint32_t Date;
int32_t Duration; int32_t Duration;
int32_t Won; int32_t Won;
int32_t Score,FinalScore,TotalScore; int32_t Score,FinalScore,TotalScore;
int32_t Bonus; int32_t Bonus;
int32_t Level; int32_t Level;
public: public:
void Default(); void Default();
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
}; };
class C4PlayerInfoCore class C4PlayerInfoCore
{ {

View File

@ -49,74 +49,74 @@ const FIXED HitSpeed4=itofix(8); // Flat
/* Some helper functions */ /* Some helper functions */
void RedirectForce(FIXED &from, FIXED &to, int32_t tdir) void RedirectForce(FIXED &from, FIXED &to, int32_t tdir)
{ {
FIXED fred; FIXED fred;
fred=Min(Abs(from), FRedirect); fred=Min(Abs(from), FRedirect);
from-=fred*Sign(from); from-=fred*Sign(from);
to+=fred*tdir; to+=fred*tdir;
} }
void ApplyFriction(FIXED &tval, int32_t percent) void ApplyFriction(FIXED &tval, int32_t percent)
{ {
FIXED ffric=FFriction*percent/100; FIXED ffric=FFriction*percent/100;
if (tval>+ffric) { tval-=ffric; return; } if (tval>+ffric) { tval-=ffric; return; }
if (tval<-ffric) { tval+=ffric; return; } if (tval<-ffric) { tval+=ffric; return; }
tval=0; tval=0;
} }
// Compares all Shape.VtxContactCNAT[] CNAT flags to search flag. // Compares all Shape.VtxContactCNAT[] CNAT flags to search flag.
// Returns true if CNAT match has been found. // Returns true if CNAT match has been found.
bool ContactVtxCNAT(C4Object *cobj, BYTE cnat_dir) bool ContactVtxCNAT(C4Object *cobj, BYTE cnat_dir)
{ {
int32_t cnt; int32_t cnt;
bool fcontact=false; bool fcontact=false;
for (cnt=0; cnt<cobj->Shape.VtxNum; cnt++) for (cnt=0; cnt<cobj->Shape.VtxNum; cnt++)
if (cobj->Shape.VtxContactCNAT[cnt] & cnat_dir) if (cobj->Shape.VtxContactCNAT[cnt] & cnat_dir)
fcontact=true; fcontact=true;
return fcontact; return fcontact;
} }
// Finds first vertex with contact flag set. // Finds first vertex with contact flag set.
// Returns -1/0/+1 for relation on vertex to object center. // Returns -1/0/+1 for relation on vertex to object center.
int32_t ContactVtxWeight(C4Object *cobj) int32_t ContactVtxWeight(C4Object *cobj)
{ {
int32_t cnt; int32_t cnt;
for (cnt=0; cnt<cobj->Shape.VtxNum; cnt++) for (cnt=0; cnt<cobj->Shape.VtxNum; cnt++)
if (cobj->Shape.VtxContactCNAT[cnt]) if (cobj->Shape.VtxContactCNAT[cnt])
{ {
if (cobj->Shape.VtxX[cnt]<0) return -1; if (cobj->Shape.VtxX[cnt]<0) return -1;
if (cobj->Shape.VtxX[cnt]>0) return +1; if (cobj->Shape.VtxX[cnt]>0) return +1;
} }
return 0; return 0;
} }
// ContactVtxFriction: Returns 0-100 friction value of first // ContactVtxFriction: Returns 0-100 friction value of first
// contacted vertex; // contacted vertex;
int32_t ContactVtxFriction(C4Object *cobj) int32_t ContactVtxFriction(C4Object *cobj)
{ {
int32_t cnt; int32_t cnt;
for (cnt=0; cnt<cobj->Shape.VtxNum; cnt++) for (cnt=0; cnt<cobj->Shape.VtxNum; cnt++)
if (cobj->Shape.VtxContactCNAT[cnt]) if (cobj->Shape.VtxContactCNAT[cnt])
return cobj->Shape.VtxFriction[cnt]; return cobj->Shape.VtxFriction[cnt];
return 0; return 0;
} }
const char *CNATName(int32_t cnat) const char *CNATName(int32_t cnat)
{ {
switch (cnat) switch (cnat)
{ {
case CNAT_None: return "None"; case CNAT_None: return "None";
case CNAT_Left: return "Left"; case CNAT_Left: return "Left";
case CNAT_Right: return "Right"; case CNAT_Right: return "Right";
case CNAT_Top: return "Top"; case CNAT_Top: return "Top";
case CNAT_Bottom: return "Bottom"; case CNAT_Bottom: return "Bottom";
case CNAT_Center: return "Center"; case CNAT_Center: return "Center";
} }
return "Undefined"; return "Undefined";
} }
bool C4Object::Contact(int32_t iCNAT) bool C4Object::Contact(int32_t iCNAT)
{ {
@ -124,14 +124,14 @@ bool C4Object::Contact(int32_t iCNAT)
{ {
return !! Call(FormatString(PSF_Contact, CNATName(iCNAT)).getData()); return !! Call(FormatString(PSF_Contact, CNATName(iCNAT)).getData());
} }
return false; return false;
} }
void C4Object::DoMotion(int32_t mx, int32_t my) void C4Object::DoMotion(int32_t mx, int32_t my)
{ {
if (pSolidMaskData) pSolidMaskData->Remove(true, true); if (pSolidMaskData) pSolidMaskData->Remove(true, true);
fix_x += mx; fix_y += my; fix_x += mx; fix_y += my;
} }
static inline int32_t ForceLimits(FIXED &rVal, int32_t iLow, int32_t iHi) static inline int32_t ForceLimits(FIXED &rVal, int32_t iLow, int32_t iHi)
{ {
@ -167,10 +167,10 @@ int32_t C4Object::ContactCheck(int32_t iAtX, int32_t iAtY)
// Store shape contact values in object t_contact // Store shape contact values in object t_contact
t_contact=Shape.ContactCNAT; t_contact=Shape.ContactCNAT;
// Contact script call for the first contacted cnat // Contact script call for the first contacted cnat
if (Shape.ContactCNAT) if (Shape.ContactCNAT)
for (int32_t ccnat=0; ccnat<4; ccnat++) // Left, right, top bottom for (int32_t ccnat=0; ccnat<4; ccnat++) // Left, right, top bottom
if (Shape.ContactCNAT & (1<<ccnat)) if (Shape.ContactCNAT & (1<<ccnat))
if (Contact(1<<ccnat)) if (Contact(1<<ccnat))
break; // Will stop on first positive return contact call! break; // Will stop on first positive return contact call!
@ -193,7 +193,7 @@ void C4Object::SideBounds(FIXED &ctcox)
} }
} }
// landscape bounds // landscape bounds
if (Def->BorderBound & C4D_Border_Sides) if (Def->BorderBound & C4D_Border_Sides)
TargetBounds(ctcox,0-Shape.GetX(),GBackWdt+Shape.GetX(),CNAT_Left,CNAT_Right); TargetBounds(ctcox,0-Shape.GetX(),GBackWdt+Shape.GetX(),CNAT_Left,CNAT_Right);
} }
@ -212,9 +212,9 @@ void C4Object::VerticalBounds(FIXED &ctcoy)
} }
} }
// landscape bounds // landscape bounds
if (Def->BorderBound & C4D_Border_Top) if (Def->BorderBound & C4D_Border_Top)
TargetBounds(ctcoy,0-Shape.GetY(),+1000000,CNAT_Top,CNAT_Bottom); TargetBounds(ctcoy,0-Shape.GetY(),+1000000,CNAT_Top,CNAT_Bottom);
if (Def->BorderBound & C4D_Border_Bottom) if (Def->BorderBound & C4D_Border_Bottom)
TargetBounds(ctcoy,-1000000,GBackHgt+Shape.GetY(),CNAT_Top,CNAT_Bottom); TargetBounds(ctcoy,-1000000,GBackHgt+Shape.GetY(),CNAT_Top,CNAT_Bottom);
} }
@ -465,32 +465,32 @@ void C4Object::DoMovement()
} }
void C4Object::Stabilize() void C4Object::Stabilize()
{ {
// def allows stabilization? // def allows stabilization?
if (Def->NoStabilize) return; if (Def->NoStabilize) return;
// normalize angle // normalize angle
int32_t nr = r; while(nr < -180) nr+=360; while(nr > 180) nr-=360; int32_t nr = r; while(nr < -180) nr+=360; while(nr > 180) nr-=360;
if (nr!=0) if (nr!=0)
if (Inside<int32_t>(nr,-StableRange,+StableRange)) if (Inside<int32_t>(nr,-StableRange,+StableRange))
{ {
// Save step undos // Save step undos
int32_t lcobjr=r; int32_t lcobjr=r;
C4Shape lshape=Shape; C4Shape lshape=Shape;
// Try rotation // Try rotation
r=0; r=0;
UpdateShape(); UpdateShape();
if (ContactCheck(GetX(),GetY())) if (ContactCheck(GetX(),GetY()))
{ // Undo rotation { // Undo rotation
Shape=lshape; Shape=lshape;
r=lcobjr; r=lcobjr;
} }
else else
{ // Stabilization okay { // Stabilization okay
fix_r=itofix(r); fix_r=itofix(r);
UpdateFace(true); UpdateFace(true);
} }
} }
} }
void C4Object::CopyMotion(C4Object *from) void C4Object::CopyMotion(C4Object *from)
{ {
@ -523,48 +523,48 @@ void C4Object::MovePosition(int32_t dx, int32_t dy)
bool C4Object::ExecMovement() // Every Tick1 by Execute bool C4Object::ExecMovement() // Every Tick1 by Execute
{ {
// Containment check // Containment check
if (Contained) if (Contained)
{ {
CopyMotion(Contained); CopyMotion(Contained);
return true; return true;
} }
// General mobility check // General mobility check
if (Category & C4D_StaticBack) return false; if (Category & C4D_StaticBack) return false;
// Movement execution // Movement execution
if (Mobile) // Object is moving if (Mobile) // Object is moving
{ {
// Move object // Move object
DoMovement(); DoMovement();
// Demobilization check // Demobilization check
if ((xdir==0) && (ydir==0) && (rdir==0)) Mobile=0; if ((xdir==0) && (ydir==0) && (rdir==0)) Mobile=0;
// Check for stabilization // Check for stabilization
if (rdir==0) Stabilize(); if (rdir==0) Stabilize();
} }
else // Object is static else // Object is static
{ {
// Check for stabilization // Check for stabilization
Stabilize(); Stabilize();
// Check for mobilization // Check for mobilization
if (!::Game.iTick10) if (!::Game.iTick10)
{ {
// Gravity mobilization // Gravity mobilization
xdir=ydir=rdir=0; xdir=ydir=rdir=0;
fix_r=itofix(r); fix_r=itofix(r);
Mobile=1; Mobile=1;
} }
} }
// Enforce zero rotation // Enforce zero rotation
if (!Def->Rotateable) r=0; if (!Def->Rotateable) r=0;
// Out of bounds check // Out of bounds check
if ((!Inside<int32_t>(GetX(),0,GBackWdt) && !(Def->BorderBound & C4D_Border_Sides)) || (GetY()>GBackHgt && !(Def->BorderBound & C4D_Border_Bottom))) if ((!Inside<int32_t>(GetX(),0,GBackWdt) && !(Def->BorderBound & C4D_Border_Sides)) || (GetY()>GBackHgt && !(Def->BorderBound & C4D_Border_Bottom)))
{ {
C4PropList* pActionDef = GetAction(); C4PropList* pActionDef = GetAction();
// Never remove attached objects: If they are truly outside landscape, their target will be removed, // Never remove attached objects: If they are truly outside landscape, their target will be removed,
@ -589,35 +589,35 @@ bool C4Object::ExecMovement() // Every Tick1 by Execute
} }
} }
} }
return true; return true;
} }
bool SimFlight(FIXED &x, FIXED &y, FIXED &xdir, FIXED &ydir, int32_t iDensityMin, int32_t iDensityMax, int32_t iIter) bool SimFlight(FIXED &x, FIXED &y, FIXED &xdir, FIXED &ydir, int32_t iDensityMin, int32_t iDensityMax, int32_t iIter)
{ {
bool fBreak = false; bool fBreak = false;
int32_t ctcox,ctcoy,cx,cy; int32_t ctcox,ctcoy,cx,cy;
cx = fixtoi(x); cy = fixtoi(y); cx = fixtoi(x); cy = fixtoi(y);
do do
{ {
if(!iIter--) return false; if(!iIter--) return false;
// Set target position by momentum // Set target position by momentum
x+=xdir; y+=ydir; x+=xdir; y+=ydir;
// Movement to target // Movement to target
ctcox=fixtoi(x); ctcoy=fixtoi(y); ctcox=fixtoi(x); ctcoy=fixtoi(y);
// Bounds // Bounds
if (!Inside<int32_t>(ctcox,0,GBackWdt) || (ctcoy>=GBackHgt)) return false; if (!Inside<int32_t>(ctcox,0,GBackWdt) || (ctcoy>=GBackHgt)) return false;
// Move to target // Move to target
do do
{ {
// Set next step target // Set next step target
cx+=Sign(ctcox-cx); cy+=Sign(ctcoy-cy); cx+=Sign(ctcox-cx); cy+=Sign(ctcoy-cy);
// Contact check // Contact check
if(Inside(GBackDensity(cx,cy), iDensityMin, iDensityMax)) if(Inside(GBackDensity(cx,cy), iDensityMin, iDensityMax))
{ fBreak = true; break; } { fBreak = true; break; }
} }
while ((cx!=ctcox) || (cy!=ctcoy)); while ((cx!=ctcox) || (cy!=ctcoy));
// Adjust GravAccel once per frame // Adjust GravAccel once per frame
ydir+=GravAccel; ydir+=GravAccel;
} }
while(!fBreak); while(!fBreak);
// write position back // write position back
@ -627,7 +627,7 @@ bool SimFlight(FIXED &x, FIXED &y, FIXED &xdir, FIXED &ydir, int32_t iDensityMin
} }
bool SimFlightHitsLiquid(FIXED fcx, FIXED fcy, FIXED xdir, FIXED ydir) bool SimFlightHitsLiquid(FIXED fcx, FIXED fcy, FIXED xdir, FIXED ydir)
{ {
// Start in water? // Start in water?
if(DensityLiquid(GBackDensity(fixtoi(fcx), fixtoi(fcy)))) if(DensityLiquid(GBackDensity(fixtoi(fcx), fixtoi(fcy))))
if(!SimFlight(fcx, fcy, xdir, ydir, 0, C4M_Liquid - 1, 10)) if(!SimFlight(fcx, fcy, xdir, ydir, 0, C4M_Liquid - 1, 10))
@ -637,5 +637,5 @@ bool SimFlightHitsLiquid(FIXED fcx, FIXED fcy, FIXED xdir, FIXED ydir)
return false; return false;
// liquid & deep enough? // liquid & deep enough?
return GBackLiquid(fixtoi(fcx), fixtoi(fcy)) && GBackLiquid(fixtoi(fcx), fixtoi(fcy) + 9); return GBackLiquid(fixtoi(fcx), fixtoi(fcy)) && GBackLiquid(fixtoi(fcx), fixtoi(fcy) + 9);
} }

File diff suppressed because it is too large Load Diff

View File

@ -91,25 +91,25 @@ class C4Action
~C4Action(); ~C4Action();
public: public:
//C4PropList * pActionDef; //C4PropList * pActionDef;
int32_t Dir; int32_t Dir;
int32_t DrawDir; // NoSave // - needs to be calculated for old-style objects.txt anyway int32_t DrawDir; // NoSave // - needs to be calculated for old-style objects.txt anyway
int32_t ComDir; int32_t ComDir;
int32_t Time; int32_t Time;
int32_t Data; int32_t Data;
int32_t Phase,PhaseDelay; int32_t Phase,PhaseDelay;
int32_t t_attach; // SyncClearance-NoSave // int32_t t_attach; // SyncClearance-NoSave //
C4Object *Target,*Target2; C4Object *Target,*Target2;
C4Facet Facet; // NoSave // C4Facet Facet; // NoSave //
int32_t FacetX,FacetY; // NoSave // int32_t FacetX,FacetY; // NoSave //
StdMeshInstance::AnimationNode* Animation; // NoSave // StdMeshInstance::AnimationNode* Animation; // NoSave //
public: public:
void Default(); void Default();
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
// BRIDGE procedure: data mask // BRIDGE procedure: data mask
void SetBridgeData(int32_t iBridgeTime, bool fMoveClonk, bool fWall, int32_t iBridgeMaterial); void SetBridgeData(int32_t iBridgeTime, bool fMoveClonk, bool fWall, int32_t iBridgeMaterial);
void GetBridgeData(int32_t &riBridgeTime, bool &rfMoveClonk, bool &rfWall, int32_t &riBridgeMaterial); void GetBridgeData(int32_t &riBridgeTime, bool &rfMoveClonk, bool &rfWall, int32_t &riBridgeMaterial);
}; };
class C4Object: public C4PropListNumbered class C4Object: public C4PropListNumbered
{ {
@ -420,6 +420,6 @@ class C4Object: public C4PropListNumbered
// overloaded from C4PropList // overloaded from C4PropList
virtual C4Object * GetObject() { return this; } virtual C4Object * GetObject() { return this; }
}; };
#endif #endif

View File

@ -44,153 +44,153 @@ bool SimFlightHitsLiquid(FIXED fcx, FIXED fcy, FIXED xdir, FIXED ydir);
bool CreateConstructionSite(int32_t ctx, int32_t bty, C4ID strid, int32_t owner, C4Object *pByObj); bool CreateConstructionSite(int32_t ctx, int32_t bty, C4ID strid, int32_t owner, C4Object *pByObj);
bool ObjectActionWalk(C4Object *cObj) bool ObjectActionWalk(C4Object *cObj)
{ {
if (!cObj->SetActionByName("Walk")) return false; if (!cObj->SetActionByName("Walk")) return false;
cObj->xdir=cObj->ydir=0; cObj->xdir=cObj->ydir=0;
return true; return true;
} }
bool ObjectActionStand(C4Object *cObj) bool ObjectActionStand(C4Object *cObj)
{ {
cObj->Action.ComDir=COMD_Stop; cObj->Action.ComDir=COMD_Stop;
if (!ObjectActionWalk(cObj)) return false; if (!ObjectActionWalk(cObj)) return false;
return true; return true;
} }
bool ObjectActionJump(C4Object *cObj, FIXED xdir, FIXED ydir, bool fByCom) bool ObjectActionJump(C4Object *cObj, FIXED xdir, FIXED ydir, bool fByCom)
{ {
// scripted jump? // scripted jump?
assert(cObj); assert(cObj);
C4AulParSet pars(C4VInt(fixtoi(xdir, 100)), C4VInt(fixtoi(ydir, 100)), C4VBool(fByCom)); C4AulParSet pars(C4VInt(fixtoi(xdir, 100)), C4VInt(fixtoi(ydir, 100)), C4VBool(fByCom));
if (!!cObj->Call(PSF_OnActionJump, &pars)) return true; if (!!cObj->Call(PSF_OnActionJump, &pars)) return true;
// hardcoded jump by action // hardcoded jump by action
if (!cObj->SetActionByName("Jump")) return false; if (!cObj->SetActionByName("Jump")) return false;
cObj->xdir=xdir; cObj->ydir=ydir; cObj->xdir=xdir; cObj->ydir=ydir;
cObj->Mobile=1; cObj->Mobile=1;
// unstick from ground, because jump command may be issued in an Action-callback, // unstick from ground, because jump command may be issued in an Action-callback,
// where attach-values have already been determined for that frame // where attach-values have already been determined for that frame
cObj->Action.t_attach&=~CNAT_Bottom; cObj->Action.t_attach&=~CNAT_Bottom;
return true; return true;
} }
bool ObjectActionDive(C4Object *cObj, FIXED xdir, FIXED ydir) bool ObjectActionDive(C4Object *cObj, FIXED xdir, FIXED ydir)
{ {
if (!cObj->SetActionByName("Dive")) return false; if (!cObj->SetActionByName("Dive")) return false;
cObj->xdir=xdir; cObj->ydir=ydir; cObj->xdir=xdir; cObj->ydir=ydir;
cObj->Mobile=1; cObj->Mobile=1;
// unstick from ground, because jump command may be issued in an Action-callback, // unstick from ground, because jump command may be issued in an Action-callback,
// where attach-values have already been determined for that frame // where attach-values have already been determined for that frame
cObj->Action.t_attach&=~CNAT_Bottom; cObj->Action.t_attach&=~CNAT_Bottom;
return true; return true;
} }
bool ObjectActionTumble(C4Object *cObj, int32_t dir, FIXED xdir, FIXED ydir) bool ObjectActionTumble(C4Object *cObj, int32_t dir, FIXED xdir, FIXED ydir)
{ {
if (!cObj->SetActionByName("Tumble")) return false; if (!cObj->SetActionByName("Tumble")) return false;
cObj->SetDir(dir); cObj->SetDir(dir);
cObj->xdir=xdir; cObj->ydir=ydir; cObj->xdir=xdir; cObj->ydir=ydir;
return true; return true;
} }
bool ObjectActionGetPunched(C4Object *cObj, FIXED xdir, FIXED ydir) bool ObjectActionGetPunched(C4Object *cObj, FIXED xdir, FIXED ydir)
{ {
if (!cObj->SetActionByName("GetPunched")) return false; if (!cObj->SetActionByName("GetPunched")) return false;
cObj->xdir=xdir; cObj->ydir=ydir; cObj->xdir=xdir; cObj->ydir=ydir;
return true; return true;
} }
bool ObjectActionKneel(C4Object *cObj) bool ObjectActionKneel(C4Object *cObj)
{ {
if (!cObj->SetActionByName("KneelDown")) return false; if (!cObj->SetActionByName("KneelDown")) return false;
cObj->xdir=cObj->ydir=0; cObj->xdir=cObj->ydir=0;
return true; return true;
} }
bool ObjectActionFlat(C4Object *cObj, int32_t dir) bool ObjectActionFlat(C4Object *cObj, int32_t dir)
{ {
if (!cObj->SetActionByName("FlatUp")) return false; if (!cObj->SetActionByName("FlatUp")) return false;
cObj->xdir=cObj->ydir=0; cObj->xdir=cObj->ydir=0;
cObj->SetDir(dir); cObj->SetDir(dir);
return true; return true;
} }
bool ObjectActionScale(C4Object *cObj, int32_t dir) bool ObjectActionScale(C4Object *cObj, int32_t dir)
{ {
if (!cObj->SetActionByName("Scale")) return false; if (!cObj->SetActionByName("Scale")) return false;
cObj->xdir=cObj->ydir=0; cObj->xdir=cObj->ydir=0;
cObj->SetDir(dir); cObj->SetDir(dir);
return true; return true;
} }
bool ObjectActionHangle(C4Object *cObj, int32_t dir) bool ObjectActionHangle(C4Object *cObj, int32_t dir)
{ {
if (!cObj->SetActionByName("Hangle")) return false; if (!cObj->SetActionByName("Hangle")) return false;
cObj->xdir=cObj->ydir=0; cObj->xdir=cObj->ydir=0;
cObj->SetDir(dir); cObj->SetDir(dir);
return true; return true;
} }
bool ObjectActionThrow(C4Object *cObj, C4Object *pThing) bool ObjectActionThrow(C4Object *cObj, C4Object *pThing)
{ {
// No object specified, first from contents // No object specified, first from contents
if (!pThing) pThing = cObj->Contents.GetObject(); if (!pThing) pThing = cObj->Contents.GetObject();
// Nothing to throw // Nothing to throw
if (!pThing) return false; if (!pThing) return false;
// Force and direction // Force and direction
FIXED pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw); FIXED pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
int32_t iDir=1; if (cObj->Action.Dir==DIR_Left) iDir=-1; int32_t iDir=1; if (cObj->Action.Dir==DIR_Left) iDir=-1;
// Set action // Set action
if (!cObj->SetActionByName("Throw")) return false; if (!cObj->SetActionByName("Throw")) return false;
// Exit object // Exit object
pThing->Exit(cObj->GetX(), pThing->Exit(cObj->GetX(),
cObj->GetY()+cObj->Shape.y-1, cObj->GetY()+cObj->Shape.y-1,
Random(360), Random(360),
pthrow*iDir+cObj->xdir,-pthrow+cObj->ydir,pthrow*iDir); pthrow*iDir+cObj->xdir,-pthrow+cObj->ydir,pthrow*iDir);
// Success // Success
return true; return true;
} }
bool ObjectActionDig(C4Object *cObj) bool ObjectActionDig(C4Object *cObj)
{ {
if (!cObj->SetActionByName("Dig")) return false; if (!cObj->SetActionByName("Dig")) return false;
cObj->Action.Data=0; // Material Dig2Object request cObj->Action.Data=0; // Material Dig2Object request
return true; return true;
} }
bool ObjectActionBuild(C4Object *cObj, C4Object *target) bool ObjectActionBuild(C4Object *cObj, C4Object *target)
{ {
return cObj->SetActionByName("Build",target); return cObj->SetActionByName("Build",target);
} }
bool ObjectActionPush(C4Object *cObj, C4Object *target) bool ObjectActionPush(C4Object *cObj, C4Object *target)
{ {
return cObj->SetActionByName("Push",target); return cObj->SetActionByName("Push",target);
} }
bool ObjectActionFight(C4Object *cObj, C4Object *target) bool ObjectActionFight(C4Object *cObj, C4Object *target)
{ {
return cObj->SetActionByName("Fight",target); return cObj->SetActionByName("Fight",target);
} }
bool ObjectActionChop(C4Object *cObj, C4Object *target) bool ObjectActionChop(C4Object *cObj, C4Object *target)
{ {
return cObj->SetActionByName("Chop",target); return cObj->SetActionByName("Chop",target);
} }
bool CornerScaleOkay(C4Object *cObj, int32_t iRangeX, int32_t iRangeY) bool CornerScaleOkay(C4Object *cObj, int32_t iRangeX, int32_t iRangeY)
{ {
int32_t ctx,cty; int32_t ctx,cty;
cty=cObj->GetY()-iRangeY; cty=cObj->GetY()-iRangeY;
if (cObj->Action.Dir==DIR_Left) ctx=cObj->GetX()-iRangeX; if (cObj->Action.Dir==DIR_Left) ctx=cObj->GetX()-iRangeX;
else ctx=cObj->GetX()+iRangeX; else ctx=cObj->GetX()+iRangeX;
cObj->ContactCheck(ctx,cty); // (resets VtxContact & t_contact) cObj->ContactCheck(ctx,cty); // (resets VtxContact & t_contact)
if (!(cObj->t_contact & CNAT_Top)) if (!(cObj->t_contact & CNAT_Top))
if (!(cObj->t_contact & CNAT_Left)) if (!(cObj->t_contact & CNAT_Left))
if (!(cObj->t_contact & CNAT_Right)) if (!(cObj->t_contact & CNAT_Right))
if (!(cObj->t_contact & CNAT_Bottom)) if (!(cObj->t_contact & CNAT_Bottom))
return true; return true;
return false; return false;
} }
bool CheckCornerScale(C4Object *cObj, int32_t &iRangeX, int32_t &iRangeY) bool CheckCornerScale(C4Object *cObj, int32_t &iRangeX, int32_t &iRangeY)
{ {
@ -202,7 +202,7 @@ bool CheckCornerScale(C4Object *cObj, int32_t &iRangeX, int32_t &iRangeY)
} }
bool ObjectActionCornerScale(C4Object *cObj) bool ObjectActionCornerScale(C4Object *cObj)
{ {
int32_t iRangeX,iRangeY; int32_t iRangeX,iRangeY;
// Scaling: check range max to min // Scaling: check range max to min
if (cObj->GetProcedure()==DFA_SCALE) if (cObj->GetProcedure()==DFA_SCALE)
@ -229,10 +229,10 @@ bool ObjectActionCornerScale(C4Object *cObj)
} }
bool ObjectComMovement(C4Object *cObj, int32_t comdir) bool ObjectComMovement(C4Object *cObj, int32_t comdir)
{ {
cObj->Action.ComDir=comdir; cObj->Action.ComDir=comdir;
PlayerObjectCommand(cObj->Owner,C4CMD_Follow,cObj); PlayerObjectCommand(cObj->Owner,C4CMD_Follow,cObj);
// direkt turnaround if standing still // direkt turnaround if standing still
if (!cObj->xdir && (cObj->GetProcedure() == DFA_WALK || cObj->GetProcedure() == DFA_HANGLE)) if (!cObj->xdir && (cObj->GetProcedure() == DFA_WALK || cObj->GetProcedure() == DFA_HANGLE))
switch (comdir) switch (comdir)
@ -244,8 +244,8 @@ bool ObjectComMovement(C4Object *cObj, int32_t comdir)
cObj->SetDir(DIR_Right); cObj->SetDir(DIR_Right);
break; break;
} }
return true; return true;
} }
bool ObjectComTurn(C4Object *cObj) bool ObjectComTurn(C4Object *cObj)
{ {
@ -259,12 +259,12 @@ bool ObjectComTurn(C4Object *cObj)
} }
bool ObjectComStop(C4Object *cObj) bool ObjectComStop(C4Object *cObj)
{ {
// Cease current action // Cease current action
cObj->SetActionByName("Idle"); cObj->SetActionByName("Idle");
// Action walk if possible // Action walk if possible
return ObjectActionStand(cObj); return ObjectActionStand(cObj);
} }
bool ObjectComGrab(C4Object *cObj, C4Object *pTarget) bool ObjectComGrab(C4Object *cObj, C4Object *pTarget)
{ {
@ -297,7 +297,7 @@ bool ObjectComUnGrab(C4Object *cObj)
} }
bool ObjectComJump(C4Object *cObj) // by ObjectComUp, ExecCMDFMoveTo, FnJump bool ObjectComJump(C4Object *cObj) // by ObjectComUp, ExecCMDFMoveTo, FnJump
{ {
// Only if walking // Only if walking
if (cObj->GetProcedure()!=DFA_WALK) return false; if (cObj->GetProcedure()!=DFA_WALK) return false;
// Calculate direction & forces // Calculate direction & forces
@ -322,61 +322,61 @@ bool ObjectComJump(C4Object *cObj) // by ObjectComUp, ExecCMDFMoveTo, FnJump
if (SimFlightHitsLiquid(x,y,TXDir,-iPhysicalJump)) if (SimFlightHitsLiquid(x,y,TXDir,-iPhysicalJump))
if (ObjectActionDive(cObj,TXDir,-iPhysicalJump)) if (ObjectActionDive(cObj,TXDir,-iPhysicalJump))
return true; return true;
// Regular jump // Regular jump
return ObjectActionJump(cObj,TXDir,-iPhysicalJump,true); return ObjectActionJump(cObj,TXDir,-iPhysicalJump,true);
} }
bool ObjectComLetGo(C4Object *cObj, int32_t xdirf) bool ObjectComLetGo(C4Object *cObj, int32_t xdirf)
{ // by ACTSCALE, ACTHANGLE or ExecCMDFMoveTo { // by ACTSCALE, ACTHANGLE or ExecCMDFMoveTo
return ObjectActionJump(cObj,itofix(xdirf),Fix0,true); return ObjectActionJump(cObj,itofix(xdirf),Fix0,true);
} }
bool ObjectComEnter(C4Object *cObj) // by pusher bool ObjectComEnter(C4Object *cObj) // by pusher
{ {
if (!cObj) return false; if (!cObj) return false;
// NoPushEnter // NoPushEnter
if (cObj->Def->NoPushEnter) return false; if (cObj->Def->NoPushEnter) return false;
// Check object entrance, try command enter // Check object entrance, try command enter
C4Object *pTarget; C4Object *pTarget;
DWORD ocf=OCF_Entrance; DWORD ocf=OCF_Entrance;
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj))) if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
if (ocf & OCF_Entrance) if (ocf & OCF_Entrance)
{ cObj->SetCommand(C4CMD_Enter,pTarget); return true; } { cObj->SetCommand(C4CMD_Enter,pTarget); return true; }
return false; return false;
} }
bool ObjectComUp(C4Object *cObj) // by DFA_WALK or DFA_SWIM bool ObjectComUp(C4Object *cObj) // by DFA_WALK or DFA_SWIM
{ {
if (!cObj) return false; if (!cObj) return false;
// Check object entrance, try command enter // Check object entrance, try command enter
C4Object *pTarget; C4Object *pTarget;
DWORD ocf=OCF_Entrance; DWORD ocf=OCF_Entrance;
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj))) if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
if (ocf & OCF_Entrance) if (ocf & OCF_Entrance)
return PlayerObjectCommand(cObj->Owner,C4CMD_Enter,pTarget); return PlayerObjectCommand(cObj->Owner,C4CMD_Enter,pTarget);
// Try jump // Try jump
if (cObj->GetProcedure()==DFA_WALK) if (cObj->GetProcedure()==DFA_WALK)
return PlayerObjectCommand(cObj->Owner,C4CMD_Jump); return PlayerObjectCommand(cObj->Owner,C4CMD_Jump);
return false; return false;
} }
bool ObjectComDig(C4Object *cObj) // by DFA_WALK bool ObjectComDig(C4Object *cObj) // by DFA_WALK
{ {
C4PhysicalInfo *phys=cObj->GetPhysical(); C4PhysicalInfo *phys=cObj->GetPhysical();
if (!phys->CanDig || !ObjectActionDig(cObj)) if (!phys->CanDig || !ObjectActionDig(cObj))
{ {
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NODIG"),cObj->GetName()).getData(),cObj); GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NODIG"),cObj->GetName()).getData(),cObj);
return false; return false;
} }
return true; return true;
} }
C4Object *CreateLine(C4ID idType, int32_t iOwner, C4Object *pFrom, C4Object *pTo) C4Object *CreateLine(C4ID idType, int32_t iOwner, C4Object *pFrom, C4Object *pTo)
{ {
@ -398,10 +398,10 @@ bool ObjectComLineConstruction(C4Object *cObj)
C4Object *linekit,*tstruct,*cline; C4Object *linekit,*tstruct,*cline;
DWORD ocf; DWORD ocf;
ObjectActionStand(cObj); ObjectActionStand(cObj);
// Check physical // Check physical
if (!cObj->GetPhysical()->CanConstruct) if (!cObj->GetPhysical()->CanConstruct)
{ {
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOLINECONSTRUCT"),cObj->GetName()).getData(),cObj); return false; GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOLINECONSTRUCT"),cObj->GetName()).getData(),cObj); return false;
} }
@ -411,7 +411,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
// Check for linekit // Check for linekit
if (!(linekit=cObj->Contents.Find(C4ID::Linekit))) if (!(linekit=cObj->Contents.Find(C4ID::Linekit)))
{ {
// Check line pickup // Check line pickup
ocf=OCF_LineConstruct; ocf=OCF_LineConstruct;
tstruct=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj); tstruct=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj);
if (!tstruct || !(ocf & OCF_LineConstruct)) return false; if (!tstruct || !(ocf & OCF_LineConstruct)) return false;
@ -424,7 +424,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NODOUBLEKIT"),cline->GetName()).getData(),cObj); return false; GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NODOUBLEKIT"),cline->GetName()).getData(),cObj); return false;
} }
// Create new linekit // Create new linekit
if (!(linekit=Game.CreateObject(C4ID::Linekit,cObj,cline->Owner))) return false; if (!(linekit=Game.CreateObject(C4ID::Linekit,cObj,cline->Owner))) return false;
// Enter linekit into clonk // Enter linekit into clonk
bool fRejectCollect; bool fRejectCollect;
if (!linekit->Enter(cObj, true, true, &fRejectCollect)) if (!linekit->Enter(cObj, true, true, &fRejectCollect))
@ -546,10 +546,10 @@ bool ObjectComLineConstruction(C4Object *cObj)
} }
void ObjectComDigDouble(C4Object *cObj) // "Activation" by DFA_WALK, DFA_DIG, DFA_SWIM void ObjectComDigDouble(C4Object *cObj) // "Activation" by DFA_WALK, DFA_DIG, DFA_SWIM
{ {
C4Object *pTarget; C4Object *pTarget;
DWORD ocf; DWORD ocf;
C4PhysicalInfo *phys=cObj->GetPhysical(); C4PhysicalInfo *phys=cObj->GetPhysical();
// Contents activation (first contents object only) // Contents activation (first contents object only)
if (cObj->Contents.GetObject()) if (cObj->Contents.GetObject())
@ -557,15 +557,15 @@ void ObjectComDigDouble(C4Object *cObj) // "Activation" by DFA_WALK, DFA_DIG, DF
return; return;
// Linekit: Line construction (move to linekit script...) // Linekit: Line construction (move to linekit script...)
if (cObj->Contents.GetObject() && (cObj->Contents.GetObject()->id==C4ID::Linekit)) if (cObj->Contents.GetObject() && (cObj->Contents.GetObject()->id==C4ID::Linekit))
{ {
ObjectComLineConstruction(cObj); ObjectComLineConstruction(cObj);
return; return;
} }
// Chop // Chop
ocf=OCF_Chop; ocf=OCF_Chop;
if (phys->CanChop) if (phys->CanChop)
if (cObj->GetProcedure()!=DFA_SWIM) if (cObj->GetProcedure()!=DFA_SWIM)
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj))) if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
if (ocf & OCF_Chop) if (ocf & OCF_Chop)
@ -575,64 +575,64 @@ void ObjectComDigDouble(C4Object *cObj) // "Activation" by DFA_WALK, DFA_DIG, DF
} }
// Line construction pick up // Line construction pick up
ocf=OCF_LineConstruct; ocf=OCF_LineConstruct;
if (phys->CanConstruct) if (phys->CanConstruct)
if (!cObj->Contents.GetObject()) if (!cObj->Contents.GetObject())
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj))) if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
if (ocf & OCF_LineConstruct) if (ocf & OCF_LineConstruct)
if (ObjectComLineConstruction(cObj)) if (ObjectComLineConstruction(cObj))
return; return;
// Own activation call // Own activation call
if (!! cObj->Call(PSF_Activate, &C4AulParSet(C4VObj(cObj)))) return; if (!! cObj->Call(PSF_Activate, &C4AulParSet(C4VObj(cObj)))) return;
} }
bool ObjectComDownDouble(C4Object *cObj) // by DFA_WALK bool ObjectComDownDouble(C4Object *cObj) // by DFA_WALK
{ {
C4Object *pTarget; C4Object *pTarget;
DWORD ocf= OCF_Construct | OCF_Grab; DWORD ocf= OCF_Construct | OCF_Grab;
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj))) if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
{ {
if (ocf & OCF_Construct) if (ocf & OCF_Construct)
{ PlayerObjectCommand(cObj->Owner,C4CMD_Build,pTarget); return true; } { PlayerObjectCommand(cObj->Owner,C4CMD_Build,pTarget); return true; }
if (ocf & OCF_Grab) if (ocf & OCF_Grab)
{ PlayerObjectCommand(cObj->Owner,C4CMD_Grab,pTarget); return true; } { PlayerObjectCommand(cObj->Owner,C4CMD_Grab,pTarget); return true; }
} }
return false; return false;
} }
bool ObjectComPut(C4Object *cObj, C4Object *pTarget, C4Object *pThing) bool ObjectComPut(C4Object *cObj, C4Object *pTarget, C4Object *pThing)
{ {
// No object specified, first from contents // No object specified, first from contents
if (!pThing) pThing = cObj->Contents.GetObject(); if (!pThing) pThing = cObj->Contents.GetObject();
// Nothing to put // Nothing to put
if (!pThing) return false; if (!pThing) return false;
// No target // No target
if (!pTarget) return false; if (!pTarget) return false;
// Grabbing: check C4D_Grab_Put // Grabbing: check C4D_Grab_Put
if (pTarget!=cObj->Contained) if (pTarget!=cObj->Contained)
if (!(pTarget->Def->GrabPutGet & C4D_Grab_Put)) if (!(pTarget->Def->GrabPutGet & C4D_Grab_Put))
{ {
// Was meant to be a drop anyway - probably obsolete as controls are being revised // Was meant to be a drop anyway - probably obsolete as controls are being revised
//if (ValidPlr(cObj->Owner)) //if (ValidPlr(cObj->Owner))
// if (Game.Players.Get(cObj->Owner)->LastComDownDouble) // if (Game.Players.Get(cObj->Owner)->LastComDownDouble)
// return ObjectComDrop(cObj, pThing); // return ObjectComDrop(cObj, pThing);
// No grab put: fail // No grab put: fail
return false; return false;
} }
// Target no fullcon // Target no fullcon
if (!(pTarget->OCF & OCF_FullCon)) return false; if (!(pTarget->OCF & OCF_FullCon)) return false;
// Transfer thing // Transfer thing
bool fRejectCollect; bool fRejectCollect;
if (!pThing->Enter(pTarget, true, true, &fRejectCollect)) return false; if (!pThing->Enter(pTarget, true, true, &fRejectCollect)) return false;
// Put call to object script // Put call to object script
cObj->Call(PSF_Put); cObj->Call(PSF_Put);
// Target collection call // Target collection call
pTarget->Call(PSF_Collection,&C4AulParSet(C4VObj(pThing), C4VBool(true))); pTarget->Call(PSF_Collection,&C4AulParSet(C4VObj(pThing), C4VBool(true)));
// Success // Success
return true; return true;
} }
bool ObjectComThrow(C4Object *cObj, C4Object *pThing) bool ObjectComThrow(C4Object *cObj, C4Object *pThing)
{ {
@ -650,8 +650,8 @@ bool ObjectComThrow(C4Object *cObj, C4Object *pThing)
} }
bool ObjectComDrop(C4Object *cObj, C4Object *pThing) bool ObjectComDrop(C4Object *cObj, C4Object *pThing)
{ {
// No object specified, first from contents // No object specified, first from contents
if (!pThing) pThing = cObj->Contents.GetObject(); if (!pThing) pThing = cObj->Contents.GetObject();
// Nothing to throw // Nothing to throw
if (!pThing) return false; if (!pThing) return false;
@ -659,8 +659,8 @@ bool ObjectComDrop(C4Object *cObj, C4Object *pThing)
// When dropping diagonally, drop from edge of shape // When dropping diagonally, drop from edge of shape
// When doing a diagonal forward drop during flight, exit a bit closer to the Clonk to allow planned tumbling // When doing a diagonal forward drop during flight, exit a bit closer to the Clonk to allow planned tumbling
// Except when hangling, so you can mine effectively form the ceiling, and when swimming because you cannot tumble then // Except when hangling, so you can mine effectively form the ceiling, and when swimming because you cannot tumble then
FIXED pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw); FIXED pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
int32_t tdir=0; int right=0; int32_t tdir=0; int right=0;
bool isHanglingOrSwimming = false; bool isHanglingOrSwimming = false;
int32_t iProc = DFA_NONE; int32_t iProc = DFA_NONE;
C4PropList* pActionDef = cObj->GetAction(); C4PropList* pActionDef = cObj->GetAction();
@ -683,54 +683,54 @@ bool ObjectComDrop(C4Object *cObj, C4Object *pThing)
// Update OCF // Update OCF
cObj->SetOCF(); cObj->SetOCF();
// Ungrab // Ungrab
ObjectComUnGrab(cObj); ObjectComUnGrab(cObj);
// Done // Done
return true; return true;
} }
bool ObjectComChop(C4Object *cObj, C4Object *pTarget) bool ObjectComChop(C4Object *cObj, C4Object *pTarget)
{ {
if (!pTarget) return false; if (!pTarget) return false;
if (!cObj->GetPhysical()->CanChop) if (!cObj->GetPhysical()->CanChop)
{ {
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOCHOP"),cObj->GetName()).getData(),cObj); GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOCHOP"),cObj->GetName()).getData(),cObj);
return false; return false;
} }
if (cObj->GetProcedure()!=DFA_WALK) return false; if (cObj->GetProcedure()!=DFA_WALK) return false;
return ObjectActionChop(cObj,pTarget); return ObjectActionChop(cObj,pTarget);
} }
bool ObjectComBuild(C4Object *cObj, C4Object *pTarget) bool ObjectComBuild(C4Object *cObj, C4Object *pTarget)
{ {
if (!pTarget) return false; if (!pTarget) return false;
// Needs to be idle or walking // Needs to be idle or walking
if (cObj->GetAction()) if (cObj->GetAction())
if (cObj->GetProcedure()!=DFA_WALK) if (cObj->GetProcedure()!=DFA_WALK)
return false; return false;
return ObjectActionBuild(cObj,pTarget); return ObjectActionBuild(cObj,pTarget);
} }
bool ObjectComPutTake(C4Object *cObj, C4Object *pTarget, C4Object *pThing) // by C4CMD_Throw bool ObjectComPutTake(C4Object *cObj, C4Object *pTarget, C4Object *pThing) // by C4CMD_Throw
{ // by C4CMD_Drop { // by C4CMD_Drop
// Valid checks // Valid checks
if (!pTarget) return false; if (!pTarget) return false;
// No object specified, first from contents // No object specified, first from contents
if (!pThing) pThing = cObj->Contents.GetObject(); if (!pThing) pThing = cObj->Contents.GetObject();
// Has thing, put to target // Has thing, put to target
if (pThing) if (pThing)
return ObjectComPut(cObj,pTarget,pThing); return ObjectComPut(cObj,pTarget,pThing);
// If target is own container, activate activation menu // If target is own container, activate activation menu
if (pTarget==cObj->Contained) if (pTarget==cObj->Contained)
return ObjectComTake(cObj); // carlo return ObjectComTake(cObj); // carlo
// Assuming target is grabbed, check for grab get // Assuming target is grabbed, check for grab get
if (pTarget->Def->GrabPutGet & C4D_Grab_Get) if (pTarget->Def->GrabPutGet & C4D_Grab_Get)
{ {
// Activate get menu // Activate get menu
return cObj->ActivateMenu(C4MN_Get,0,0,0,pTarget); return cObj->ActivateMenu(C4MN_Get,0,0,0,pTarget);
} }
// Failure // Failure
return false; return false;
} }
// carlo // carlo
bool ObjectComTake(C4Object *cObj) // by C4CMD_Take bool ObjectComTake(C4Object *cObj) // by C4CMD_Take
@ -745,8 +745,8 @@ bool ObjectComTake2(C4Object *cObj) // by C4CMD_Take2
} }
bool ObjectComPunch(C4Object *cObj, C4Object *pTarget, int32_t punch) bool ObjectComPunch(C4Object *cObj, C4Object *pTarget, int32_t punch)
{ {
if (!cObj || !pTarget) return false; if (!cObj || !pTarget) return false;
if (!punch) if (!punch)
if (pTarget->GetPhysical()->Fight) if (pTarget->GetPhysical()->Fight)
punch=BoundBy<int32_t>(5*cObj->GetPhysical()->Fight/pTarget->GetPhysical()->Fight,0,10); punch=BoundBy<int32_t>(5*cObj->GetPhysical()->Fight/pTarget->GetPhysical()->Fight,0,10);
@ -754,32 +754,32 @@ bool ObjectComPunch(C4Object *cObj, C4Object *pTarget, int32_t punch)
bool fBlowStopped = !!pTarget->Call(PSF_QueryCatchBlow,&C4AulParSet(C4VObj(cObj))); bool fBlowStopped = !!pTarget->Call(PSF_QueryCatchBlow,&C4AulParSet(C4VObj(cObj)));
if (fBlowStopped && punch>1) punch=punch/2; // half damage for caught blow, so shield+armor help in fistfight and vs monsters if (fBlowStopped && punch>1) punch=punch/2; // half damage for caught blow, so shield+armor help in fistfight and vs monsters
pTarget->DoEnergy(-punch, false, C4FxCall_EngGetPunched, cObj->Controller); pTarget->DoEnergy(-punch, false, C4FxCall_EngGetPunched, cObj->Controller);
int32_t tdir=+1; if (cObj->Action.Dir==DIR_Left) tdir=-1; int32_t tdir=+1; if (cObj->Action.Dir==DIR_Left) tdir=-1;
pTarget->Action.ComDir=COMD_Stop; pTarget->Action.ComDir=COMD_Stop;
// No tumbles when blow was caught // No tumbles when blow was caught
if (fBlowStopped) return false; if (fBlowStopped) return false;
// Hard punch // Hard punch
if (punch>=10) if (punch>=10)
if (ObjectActionTumble(pTarget,pTarget->Action.Dir,FIXED100(150)*tdir,itofix(-2))) if (ObjectActionTumble(pTarget,pTarget->Action.Dir,FIXED100(150)*tdir,itofix(-2)))
{ pTarget->Call(PSF_CatchBlow,&C4AulParSet(C4VInt(punch), { pTarget->Call(PSF_CatchBlow,&C4AulParSet(C4VInt(punch),
C4VObj(cObj))); C4VObj(cObj)));
return true; } return true; }
// Regular punch // Regular punch
if (ObjectActionGetPunched(pTarget,FIXED100(250)*tdir,Fix0)) if (ObjectActionGetPunched(pTarget,FIXED100(250)*tdir,Fix0))
{ pTarget->Call(PSF_CatchBlow,&C4AulParSet(C4VInt(punch), { pTarget->Call(PSF_CatchBlow,&C4AulParSet(C4VInt(punch),
C4VObj(cObj))); C4VObj(cObj)));
return true; } return true; }
return false; return false;
} }
bool ObjectComCancelAttach(C4Object *cObj) bool ObjectComCancelAttach(C4Object *cObj)
{ {
if (cObj->GetProcedure()==DFA_ATTACH) if (cObj->GetProcedure()==DFA_ATTACH)
return cObj->SetAction(0); return cObj->SetAction(0);
return false; return false;
} }
void ObjectComStopDig(C4Object *cObj) void ObjectComStopDig(C4Object *cObj)
{ {
@ -808,66 +808,66 @@ int32_t ComOrder(int32_t iIndex)
} }
const char *ComName(int32_t iCom) const char *ComName(int32_t iCom)
{ {
switch (iCom) switch (iCom)
{ {
case COM_Up: return "Up"; case COM_Up: return "Up";
case COM_Up_S: return "UpSingle"; case COM_Up_S: return "UpSingle";
case COM_Up_D: return "UpDouble"; case COM_Up_D: return "UpDouble";
case COM_Up_R: return "UpReleased"; case COM_Up_R: return "UpReleased";
case COM_Down: return "Down"; case COM_Down: return "Down";
case COM_Down_S: return "DownSingle"; case COM_Down_S: return "DownSingle";
case COM_Down_D: return "DownDouble"; case COM_Down_D: return "DownDouble";
case COM_Down_R: return "DownReleased"; case COM_Down_R: return "DownReleased";
case COM_Left: return "Left"; case COM_Left: return "Left";
case COM_Left_S: return "LeftSingle"; case COM_Left_S: return "LeftSingle";
case COM_Left_D: return "LeftDouble"; case COM_Left_D: return "LeftDouble";
case COM_Left_R: return "LeftReleased"; case COM_Left_R: return "LeftReleased";
case COM_Right: return "Right"; case COM_Right: return "Right";
case COM_Right_S: return "RightSingle"; case COM_Right_S: return "RightSingle";
case COM_Right_D: return "RightDouble"; case COM_Right_D: return "RightDouble";
case COM_Right_R: return "RightReleased"; case COM_Right_R: return "RightReleased";
case COM_Dig: return "Dig"; case COM_Dig: return "Dig";
case COM_Dig_S: return "DigSingle"; case COM_Dig_S: return "DigSingle";
case COM_Dig_D: return "DigDouble"; case COM_Dig_D: return "DigDouble";
case COM_Dig_R: return "DigReleased"; case COM_Dig_R: return "DigReleased";
case COM_Throw: return "Throw"; case COM_Throw: return "Throw";
case COM_Throw_S: return "ThrowSingle"; case COM_Throw_S: return "ThrowSingle";
case COM_Throw_D: return "ThrowDouble"; case COM_Throw_D: return "ThrowDouble";
case COM_Throw_R: return "ThrowReleased"; case COM_Throw_R: return "ThrowReleased";
case COM_Special: return "Special"; case COM_Special: return "Special";
case COM_Special_S: return "SpecialSingle"; case COM_Special_S: return "SpecialSingle";
case COM_Special_D: return "SpecialDouble"; case COM_Special_D: return "SpecialDouble";
case COM_Special_R: return "SpecialReleased"; case COM_Special_R: return "SpecialReleased";
case COM_Special2: return "Special2"; case COM_Special2: return "Special2";
case COM_Special2_S: return "Special2Single"; case COM_Special2_S: return "Special2Single";
case COM_Special2_D: return "Special2Double"; case COM_Special2_D: return "Special2Double";
case COM_Special2_R: return "Special2Released"; case COM_Special2_R: return "Special2Released";
case COM_WheelUp: return "WheelUp"; case COM_WheelUp: return "WheelUp";
case COM_WheelDown: return "WheelDown"; case COM_WheelDown: return "WheelDown";
} }
return "Undefined"; return "Undefined";
} }
int32_t Com2Control(int32_t iCom) int32_t Com2Control(int32_t iCom)
{ {
iCom = iCom & ~(COM_Double | COM_Single); iCom = iCom & ~(COM_Double | COM_Single);
switch (iCom) switch (iCom)
{ {
case COM_CursorLeft: return CON_CursorLeft; case COM_CursorLeft: return CON_CursorLeft;
case COM_CursorToggle: return CON_CursorToggle; case COM_CursorToggle: return CON_CursorToggle;
case COM_CursorRight: return CON_CursorRight; case COM_CursorRight: return CON_CursorRight;
case COM_Throw: return CON_Throw; case COM_Throw: return CON_Throw;
case COM_Up: return CON_Up; case COM_Up: return CON_Up;
case COM_Dig: return CON_Dig; case COM_Dig: return CON_Dig;
case COM_Left: return CON_Left; case COM_Left: return CON_Left;
case COM_Down: return CON_Down; case COM_Down: return CON_Down;
case COM_Right: return CON_Right; case COM_Right: return CON_Right;
case COM_Special: return CON_Special; case COM_Special: return CON_Special;
case COM_Special2: return CON_Special2; case COM_Special2: return CON_Special2;
} }
return CON_Menu; return CON_Menu;
} }
int32_t Control2Com(int32_t iControl, bool fUp) int32_t Control2Com(int32_t iControl, bool fUp)
{ {

View File

@ -58,7 +58,7 @@ void C4ObjectInfo::Default()
HasDied=false; HasDied=false;
ControlCount=0; ControlCount=0;
Filename[0]=0; Filename[0]=0;
Next=NULL; Next=NULL;
pDef = NULL; pDef = NULL;
Portrait.Default(); Portrait.Default();
pNewPortrait = NULL; pNewPortrait = NULL;
@ -289,7 +289,7 @@ bool C4ObjectInfo::Save(C4Group &hGroup, bool fStoreTiny, C4DefList *pDefs)
void C4ObjectInfo::Evaluate() void C4ObjectInfo::Evaluate()
{ {
Retire(); Retire();
if (WasInAction) Rounds++; if (WasInAction) Rounds++;
} }
void C4ObjectInfo::Clear() void C4ObjectInfo::Clear()
@ -304,8 +304,8 @@ void C4ObjectInfo::Recruit()
{ {
// already recruited? // already recruited?
if (InAction) return; if (InAction) return;
WasInAction=true; WasInAction=true;
InAction=true; InAction=true;
InActionTime=Game.Time; InActionTime=Game.Time;
// rank name overload by def? // rank name overload by def?
C4Def *pDef=::Definitions.ID2Def(id); C4Def *pDef=::Definitions.ID2Def(id);

View File

@ -28,13 +28,13 @@
#include <C4FacetEx.h> #include <C4FacetEx.h>
class C4ObjectInfo: public C4ObjectInfoCore class C4ObjectInfo: public C4ObjectInfoCore
{ {
public: public:
C4ObjectInfo(); C4ObjectInfo();
~C4ObjectInfo(); ~C4ObjectInfo();
public: public:
bool WasInAction; bool WasInAction;
bool InAction; bool InAction;
int32_t InActionTime; int32_t InActionTime;
bool HasDied; bool HasDied;
int32_t ControlCount; int32_t ControlCount;
@ -43,8 +43,8 @@ class C4ObjectInfo: public C4ObjectInfoCore
C4Portrait *pNewPortrait; // new permanent portrait link (usually to def graphics) C4Portrait *pNewPortrait; // new permanent portrait link (usually to def graphics)
C4Portrait *pCustomPortrait; // if assigned, the Clonk has a custom portrait to be set via SetPortrait("custom") C4Portrait *pCustomPortrait; // if assigned, the Clonk has a custom portrait to be set via SetPortrait("custom")
char Filename[_MAX_PATH+1]; char Filename[_MAX_PATH+1];
C4ObjectInfo *Next; C4ObjectInfo *Next;
public: public:
void Default(); void Default();
void Clear(); void Clear();
void Evaluate(); void Evaluate();
@ -58,6 +58,6 @@ class C4ObjectInfo: public C4ObjectInfoCore
bool SetPortrait(const char *szPortraitName, C4Def *pSourceDef, bool fAssignPermanently, bool fCopyFile); bool SetPortrait(const char *szPortraitName, C4Def *pSourceDef, bool fAssignPermanently, bool fCopyFile);
bool SetPortrait(C4PortraitGraphics *pNewPortraitGfx, bool fAssignPermanently, bool fCopyFile); bool SetPortrait(C4PortraitGraphics *pNewPortraitGfx, bool fAssignPermanently, bool fCopyFile);
bool ClearPortrait(bool fPermanently); bool ClearPortrait(bool fPermanently);
}; };
#endif #endif

View File

@ -60,22 +60,22 @@ void C4ObjectInfoList::Clear()
int32_t C4ObjectInfoList::Load(C4Group &hGroup, bool fLoadPortraits) int32_t C4ObjectInfoList::Load(C4Group &hGroup, bool fLoadPortraits)
{ {
C4ObjectInfo *ninf; C4ObjectInfo *ninf;
int32_t infn=0; int32_t infn=0;
char entryname[256+1]; char entryname[256+1];
// Search all c4i files // Search all c4i files
hGroup.ResetSearch(); hGroup.ResetSearch();
while (hGroup.FindNextEntry(C4CFN_ObjectInfoFiles,entryname)) while (hGroup.FindNextEntry(C4CFN_ObjectInfoFiles,entryname))
if ((ninf=new C4ObjectInfo)) if ((ninf=new C4ObjectInfo))
{ {
if (ninf->Load(hGroup,entryname,fLoadPortraits)) { Add(ninf); infn++; } if (ninf->Load(hGroup,entryname,fLoadPortraits)) { Add(ninf); infn++; }
else delete ninf; else delete ninf;
} }
// Search all c4o files // Search all c4o files
/*hGroup.ResetSearch(); /*hGroup.ResetSearch();
while (hGroup.FindNextEntry("*.c4o",entryname)) while (hGroup.FindNextEntry("*.c4o",entryname))
if (ninf=new C4ObjectInfo) if (ninf=new C4ObjectInfo)
if (ninf->Load(hGroup,entryname)) { Add(ninf); infn++; } if (ninf->Load(hGroup,entryname)) { Add(ninf); infn++; }
else delete ninf;*/ else delete ninf;*/
@ -89,7 +89,7 @@ int32_t C4ObjectInfoList::Load(C4Group &hGroup, bool fLoadPortraits)
Load(ItemGroup, fLoadPortraits); Load(ItemGroup, fLoadPortraits);
} }
return infn; return infn;
} }
bool C4ObjectInfoList::Add(C4ObjectInfo *pInfo) bool C4ObjectInfoList::Add(C4ObjectInfo *pInfo)
@ -103,28 +103,28 @@ bool C4ObjectInfoList::Add(C4ObjectInfo *pInfo)
void C4ObjectInfoList::MakeValidName(char *sName) void C4ObjectInfoList::MakeValidName(char *sName)
{ {
char tstr[_MAX_PATH]; char tstr[_MAX_PATH];
int32_t iname,namelen=SLen(sName); int32_t iname,namelen=SLen(sName);
for (iname=2; NameExists(sName); iname++) for (iname=2; NameExists(sName); iname++)
{ {
sprintf(tstr," %d",iname); sprintf(tstr," %d",iname);
SCopy(tstr,sName+Min<int32_t>(namelen,C4MaxName-SLen(tstr))); SCopy(tstr,sName+Min<int32_t>(namelen,C4MaxName-SLen(tstr)));
} }
} }
bool C4ObjectInfoList::NameExists(const char *szName) bool C4ObjectInfoList::NameExists(const char *szName)
{ {
C4ObjectInfo *cinf; C4ObjectInfo *cinf;
for (cinf=First; cinf; cinf=cinf->Next) for (cinf=First; cinf; cinf=cinf->Next)
if (SEqualNoCase(szName,cinf->Name)) if (SEqualNoCase(szName,cinf->Name))
return true; return true;
return false; return false;
} }
C4ObjectInfo* C4ObjectInfoList::GetIdle(C4ID c_id, C4DefList &rDefs) C4ObjectInfo* C4ObjectInfoList::GetIdle(C4ID c_id, C4DefList &rDefs)
{ {
C4Def *pDef; C4Def *pDef;
C4ObjectInfo *pInfo; C4ObjectInfo *pInfo;
C4ObjectInfo *pHiExp=NULL; C4ObjectInfo *pHiExp=NULL;
// Search list // Search list
for (pInfo=First; pInfo; pInfo=pInfo->Next) for (pInfo=First; pInfo; pInfo=pInfo->Next)
@ -143,20 +143,20 @@ C4ObjectInfo* C4ObjectInfoList::GetIdle(C4ID c_id, C4DefList &rDefs)
// Found // Found
if (pHiExp) if (pHiExp)
{ {
pHiExp->Recruit(); pHiExp->Recruit();
return pHiExp; return pHiExp;
} }
return NULL; return NULL;
} }
C4ObjectInfo* C4ObjectInfoList::New(C4ID n_id, C4DefList *pDefs) C4ObjectInfo* C4ObjectInfoList::New(C4ID n_id, C4DefList *pDefs)
{ {
C4ObjectInfo *pInfo; C4ObjectInfo *pInfo;
// Create new info object // Create new info object
if (!(pInfo = new C4ObjectInfo)) return NULL; if (!(pInfo = new C4ObjectInfo)) return NULL;
// Default type clonk if none specified // Default type clonk if none specified
if (n_id == C4ID::None) n_id = C4ID::Clonk; if (n_id == C4ID::None) n_id = C4ID::Clonk;
// Check type valid and def available // Check type valid and def available
C4Def *pDef = NULL; C4Def *pDef = NULL;
@ -167,7 +167,7 @@ C4ObjectInfo* C4ObjectInfoList::New(C4ID n_id, C4DefList *pDefs)
const char *cpNames = Game.Names.GetData(); const char *cpNames = Game.Names.GetData();
if (pDef->pClonkNames) cpNames = pDef->pClonkNames->GetData(); if (pDef->pClonkNames) cpNames = pDef->pClonkNames->GetData();
// Default by type // Default by type
((C4ObjectInfoCore*)pInfo)->Default(n_id, pDefs, cpNames); ((C4ObjectInfoCore*)pInfo)->Default(n_id, pDefs, cpNames);
// Set birthday // Set birthday
pInfo->Birthday=time(NULL); pInfo->Birthday=time(NULL);
// Make valid names // Make valid names
@ -175,16 +175,16 @@ C4ObjectInfo* C4ObjectInfoList::New(C4ID n_id, C4DefList *pDefs)
// Add new portrait (permanently w/o copying file) // Add new portrait (permanently w/o copying file)
if (Config.Graphics.AddNewCrewPortraits) if (Config.Graphics.AddNewCrewPortraits)
pInfo->SetRandomPortrait(C4ID::None, true, false); pInfo->SetRandomPortrait(C4ID::None, true, false);
// Add // Add
Add(pInfo); Add(pInfo);
++iNumCreated; ++iNumCreated;
return pInfo; return pInfo;
} }
void C4ObjectInfoList::Evaluate() void C4ObjectInfoList::Evaluate()
{ {
C4ObjectInfo *cinf; C4ObjectInfo *cinf;
for (cinf=First; cinf; cinf=cinf->Next) for (cinf=First; cinf; cinf=cinf->Next)
cinf->Evaluate(); cinf->Evaluate();
} }
@ -192,7 +192,7 @@ bool C4ObjectInfoList::Save(C4Group &hGroup, bool fSavegame, bool fStoreTiny, C4
{ {
// Save in opposite order (for identical crew order on load) // Save in opposite order (for identical crew order on load)
C4ObjectInfo *pInfo; C4ObjectInfo *pInfo;
for (pInfo = GetLast(); pInfo; pInfo = GetPrevious(pInfo)) for (pInfo = GetLast(); pInfo; pInfo = GetPrevious(pInfo))
{ {
// don't safe TemporaryCrew in regular player files // don't safe TemporaryCrew in regular player files
if (!fSavegame) if (!fSavegame)
@ -209,9 +209,9 @@ bool C4ObjectInfoList::Save(C4Group &hGroup, bool fSavegame, bool fStoreTiny, C4
C4ObjectInfo* C4ObjectInfoList::GetIdle(const char *szByName) C4ObjectInfo* C4ObjectInfoList::GetIdle(const char *szByName)
{ {
C4ObjectInfo *pInfo; C4ObjectInfo *pInfo;
// Find matching name, participating, alive and not in action // Find matching name, participating, alive and not in action
for (pInfo=First; pInfo; pInfo=pInfo->Next) for (pInfo=First; pInfo; pInfo=pInfo->Next)
if (SEqualNoCase(pInfo->Name,szByName)) if (SEqualNoCase(pInfo->Name,szByName))
if (pInfo->Participation) if (!pInfo->InAction) if (pInfo->Participation) if (!pInfo->InAction)
if (!pInfo->HasDied) if (!pInfo->HasDied)
@ -224,8 +224,8 @@ C4ObjectInfo* C4ObjectInfoList::GetIdle(const char *szByName)
void C4ObjectInfoList::DetachFromObjects() void C4ObjectInfoList::DetachFromObjects()
{ {
C4ObjectInfo *cinf; C4ObjectInfo *cinf;
for (cinf=First; cinf; cinf=cinf->Next) for (cinf=First; cinf; cinf=cinf->Next)
::Objects.ClearInfo(cinf); ::Objects.ClearInfo(cinf);
} }
@ -253,7 +253,7 @@ bool C4ObjectInfoList::IsElement(C4ObjectInfo *pInfo)
void C4ObjectInfoList::Strip(C4DefList &rDefs) void C4ObjectInfoList::Strip(C4DefList &rDefs)
{ {
C4ObjectInfo *pInfo, *pPrev; C4ObjectInfo *pInfo, *pPrev;
// Search list // Search list
for (pInfo=First, pPrev=NULL; pInfo; ) for (pInfo=First, pPrev=NULL; pInfo; )
{ {

View File

@ -33,29 +33,29 @@
#include <C4GameObjects.h> #include <C4GameObjects.h>
C4ObjectList::C4ObjectList(): FirstIter(0) C4ObjectList::C4ObjectList(): FirstIter(0)
{ {
Default(); Default();
} }
C4ObjectList::C4ObjectList(const C4ObjectList &List): FirstIter(0) C4ObjectList::C4ObjectList(const C4ObjectList &List): FirstIter(0)
{ {
Default(); Default();
Copy(List); Copy(List);
} }
C4ObjectList::~C4ObjectList() C4ObjectList::~C4ObjectList()
{ {
Clear(); Clear();
} }
void C4ObjectList::Clear() void C4ObjectList::Clear()
{ {
C4ObjectLink *cLnk,*nextLnk; C4ObjectLink *cLnk,*nextLnk;
for (cLnk=First; cLnk; cLnk=nextLnk) for (cLnk=First; cLnk; cLnk=nextLnk)
{ nextLnk=cLnk->Next; delete cLnk; } { nextLnk=cLnk->Next; delete cLnk; }
First=Last=NULL; First=Last=NULL;
if (pEnumerated) delete pEnumerated; pEnumerated=NULL; if (pEnumerated) delete pEnumerated; pEnumerated=NULL;
} }
const int MaxTempListID = 500; const int MaxTempListID = 500;
C4ID TempListID[MaxTempListID]; C4ID TempListID[MaxTempListID];
@ -68,7 +68,7 @@ C4ID C4ObjectList::GetListID(int32_t dwCategory, int Index)
// Create a temporary list of all id's and counts // Create a temporary list of all id's and counts
for (clid=0; clid<MaxTempListID; clid++) TempListID[clid]=C4ID::None; for (clid=0; clid<MaxTempListID; clid++) TempListID[clid]=C4ID::None;
for (clnk=First; clnk && clnk->Obj; clnk=clnk->Next) for (clnk=First; clnk && clnk->Obj; clnk=clnk->Next)
if (clnk->Obj->Status) if (clnk->Obj->Status)
if ((dwCategory==C4D_All) || ( (cdef=C4Id2Def(clnk->Obj->Def->id)) && (cdef->Category & dwCategory) )) if ((dwCategory==C4D_All) || ( (cdef=C4Id2Def(clnk->Obj->Def->id)) && (cdef->Category & dwCategory) ))
for (clid=0; clid<MaxTempListID; clid++) for (clid=0; clid<MaxTempListID; clid++)
@ -93,7 +93,7 @@ int C4ObjectList::ListIDCount(int32_t dwCategory)
// Create a temporary list of all id's and counts // Create a temporary list of all id's and counts
for (clid=0; clid<MaxTempListID; clid++) TempListID[clid]=C4ID::None; for (clid=0; clid<MaxTempListID; clid++) TempListID[clid]=C4ID::None;
for (clnk=First; clnk && clnk->Obj; clnk=clnk->Next) for (clnk=First; clnk && clnk->Obj; clnk=clnk->Next)
if (clnk->Obj->Status) if (clnk->Obj->Status)
if ((dwCategory==C4D_All) || ( (cdef=C4Id2Def(clnk->Obj->Def->id)) && (cdef->Category & dwCategory) )) if ((dwCategory==C4D_All) || ( (cdef=C4Id2Def(clnk->Obj->Def->id)) && (cdef->Category & dwCategory) ))
for (clid=0; clid<MaxTempListID; clid++) for (clid=0; clid<MaxTempListID; clid++)
@ -105,7 +105,7 @@ int C4ObjectList::ListIDCount(int32_t dwCategory)
} }
// Count different id's // Count different id's
for (clid=0; clid<MaxTempListID; clid++) for (clid=0; clid<MaxTempListID; clid++)
if (TempListID[clid]==C4ID::None) if (TempListID[clid]==C4ID::None)
return clid; return clid;
@ -115,9 +115,9 @@ int C4ObjectList::ListIDCount(int32_t dwCategory)
bool C4ObjectList::Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted) bool C4ObjectList::Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted)
{ {
C4ObjectLink *nLnk; C4ObjectLink *nLnk;
if (!nObj || !nObj->Def || !nObj->Status) return false; if (!nObj || !nObj->Def || !nObj->Status) return false;
#ifdef _DEBUG #ifdef _DEBUG
if (eSort==stMain) if (eSort==stMain)
@ -134,10 +134,10 @@ bool C4ObjectList::Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted)
// no self-sort // no self-sort
assert(pLstSorted != this); assert(pLstSorted != this);
// Allocate new link // Allocate new link
if (!(nLnk=new C4ObjectLink)) return false; if (!(nLnk=new C4ObjectLink)) return false;
// Set link // Set link
nLnk->Obj=nObj; nLnk->Obj=nObj;
// Search insert position (default: end of list) // Search insert position (default: end of list)
C4ObjectLink *cLnk = NULL, *cPrev = Last; C4ObjectLink *cLnk = NULL, *cPrev = Last;
@ -242,11 +242,11 @@ bool C4ObjectList::Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted)
} }
#endif #endif
// Add mass // Add mass
Mass+=nObj->Mass; Mass+=nObj->Mass;
return true; return true;
} }
bool C4ObjectList::Remove(C4Object *pObj) bool C4ObjectList::Remove(C4Object *pObj)
{ {
@ -280,76 +280,76 @@ bool C4ObjectList::Remove(C4Object *pObj)
} }
C4Object* C4ObjectList::Find(C4ID id, int owner, DWORD dwOCF) C4Object* C4ObjectList::Find(C4ID id, int owner, DWORD dwOCF)
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
// Find link and object // Find link and object
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
if (cLnk->Obj->Def->id==id) if (cLnk->Obj->Def->id==id)
if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner)) if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner))
if (dwOCF & cLnk->Obj->OCF) if (dwOCF & cLnk->Obj->OCF)
return cLnk->Obj; return cLnk->Obj;
return NULL; return NULL;
} }
C4Object* C4ObjectList::FindOther(C4ID id, int owner) C4Object* C4ObjectList::FindOther(C4ID id, int owner)
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
// Find link and object // Find link and object
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
if (cLnk->Obj->Def->id!=id) if (cLnk->Obj->Def->id!=id)
if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner)) if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner))
return cLnk->Obj; return cLnk->Obj;
return NULL; return NULL;
} }
C4Object* C4ObjectList::GetObject(int Index) C4Object* C4ObjectList::GetObject(int Index)
{ {
int cIdx; int cIdx;
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
// Find link and object // Find link and object
for (cLnk=First,cIdx=0; cLnk; cLnk=cLnk->Next) for (cLnk=First,cIdx=0; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
{ {
if (cIdx==Index) return cLnk->Obj; if (cIdx==Index) return cLnk->Obj;
cIdx++; cIdx++;
} }
return NULL; return NULL;
} }
C4ObjectLink* C4ObjectList::GetLink(C4Object *pObj) C4ObjectLink* C4ObjectList::GetLink(C4Object *pObj)
{ {
if (!pObj) return NULL; if (!pObj) return NULL;
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj==pObj) if (cLnk->Obj==pObj)
return cLnk; return cLnk;
return NULL; return NULL;
} }
int C4ObjectList::ObjectCount(C4ID id, int32_t dwCategory) const int C4ObjectList::ObjectCount(C4ID id, int32_t dwCategory) const
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
int iCount=0; int iCount=0;
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
if ( (id==C4ID::None) || (cLnk->Obj->Def->id==id) ) if ( (id==C4ID::None) || (cLnk->Obj->Def->id==id) )
if ( (dwCategory==C4D_All) || (cLnk->Obj->Category & dwCategory) ) if ( (dwCategory==C4D_All) || (cLnk->Obj->Category & dwCategory) )
iCount++; iCount++;
return iCount; return iCount;
} }
int C4ObjectList::MassCount() int C4ObjectList::MassCount()
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
int iMass=0; int iMass=0;
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
iMass+=cLnk->Obj->Mass; iMass+=cLnk->Obj->Mass;
Mass=iMass; Mass=iMass;
return iMass; return iMass;
} }
void C4ObjectList::DrawIDList(C4Facet &cgo, int iSelection, void C4ObjectList::DrawIDList(C4Facet &cgo, int iSelection,
C4DefList &rDefs, int32_t dwCategory, C4DefList &rDefs, int32_t dwCategory,
@ -360,7 +360,7 @@ void C4ObjectList::DrawIDList(C4Facet &cgo, int iSelection,
/*int iSections = cgo.GetSectionCount(); /*int iSections = cgo.GetSectionCount();
int iItems = ListIDCount(dwCategory);*/ int iItems = ListIDCount(dwCategory);*/
//int iFirstItem = BoundBy(iSelection-iSections/2,0,Max(iItems-iSections,0)); //int iFirstItem = BoundBy(iSelection-iSections/2,0,Max(iItems-iSections,0));
int32_t cSec = 0; int32_t cSec = 0;
int32_t iCount; int32_t iCount;
C4Facet cgo2; C4Facet cgo2;
C4Object *pFirstObj; C4Object *pFirstObj;
@ -383,8 +383,8 @@ void C4ObjectList::DrawIDList(C4Facet &cgo, int iSelection,
cSec++; cSec++;
} }
// Draw by list sorted ids // Draw by list sorted ids
/* for (cPos=0; c_id=GetListID(dwCategory,cPos); cPos++) /* for (cPos=0; c_id=GetListID(dwCategory,cPos); cPos++)
if (Inside(cPos,iFirstItem,iFirstItem+iSections-1)) if (Inside(cPos,iFirstItem,iFirstItem+iSections-1))
{ {
// First object of this type // First object of this type
pFirstObj = Find(c_id); pFirstObj = Find(c_id);
@ -401,8 +401,8 @@ void C4ObjectList::DrawIDList(C4Facet &cgo, int iSelection,
// Region // Region
if (pRegions) pRegions->Add(cgo2.X,cgo2.Y,cgo2.Wdt,cgo2.Hgt,pFirstObj->GetName(),iRegionCom,pFirstObj,COM_None,COM_None,pFirstObj->id); if (pRegions) pRegions->Add(cgo2.X,cgo2.Y,cgo2.Wdt,cgo2.Hgt,pFirstObj->GetName(),iRegionCom,pFirstObj,COM_None,COM_None,pFirstObj->id);
// Next section // Next section
cSec++; cSec++;
} */ } */
} }
int C4ObjectList::ClearPointers(C4Object *pObj) int C4ObjectList::ClearPointers(C4Object *pObj)
@ -411,62 +411,62 @@ int C4ObjectList::ClearPointers(C4Object *pObj)
// Clear all primary list pointers // Clear all primary list pointers
while (Remove(pObj)) rval++; while (Remove(pObj)) rval++;
// Clear all sub pointers // Clear all sub pointers
C4Object *cobj; C4ObjectLink *clnk; C4Object *cobj; C4ObjectLink *clnk;
for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next) for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
cobj->ClearPointers(pObj); cobj->ClearPointers(pObj);
return rval; return rval;
} }
void C4ObjectList::DrawAll(C4TargetFacet &cgo, int iPlayer) void C4ObjectList::DrawAll(C4TargetFacet &cgo, int iPlayer)
{ {
C4ObjectLink *clnk; C4ObjectLink *clnk;
// Draw objects (base) // Draw objects (base)
for (clnk=Last; clnk; clnk=clnk->Prev) for (clnk=Last; clnk; clnk=clnk->Prev)
clnk->Obj->Draw(cgo, iPlayer); clnk->Obj->Draw(cgo, iPlayer);
// Draw objects (top face) // Draw objects (top face)
for (clnk=Last; clnk; clnk=clnk->Prev) for (clnk=Last; clnk; clnk=clnk->Prev)
clnk->Obj->DrawTopFace(cgo, iPlayer); clnk->Obj->DrawTopFace(cgo, iPlayer);
} }
void C4ObjectList::DrawIfCategory(C4TargetFacet &cgo, int iPlayer, uint32_t dwCat, bool fInvert) void C4ObjectList::DrawIfCategory(C4TargetFacet &cgo, int iPlayer, uint32_t dwCat, bool fInvert)
{ {
C4ObjectLink *clnk; C4ObjectLink *clnk;
// Draw objects (base) // Draw objects (base)
for (clnk=Last; clnk; clnk=clnk->Prev) for (clnk=Last; clnk; clnk=clnk->Prev)
if (!(clnk->Obj->Category & dwCat) == fInvert) if (!(clnk->Obj->Category & dwCat) == fInvert)
clnk->Obj->Draw(cgo, iPlayer); clnk->Obj->Draw(cgo, iPlayer);
// Draw objects (top face) // Draw objects (top face)
for (clnk=Last; clnk; clnk=clnk->Prev) for (clnk=Last; clnk; clnk=clnk->Prev)
if (!(clnk->Obj->Category & dwCat) == fInvert) if (!(clnk->Obj->Category & dwCat) == fInvert)
clnk->Obj->DrawTopFace(cgo, iPlayer); clnk->Obj->DrawTopFace(cgo, iPlayer);
} }
void C4ObjectList::Draw(C4TargetFacet &cgo, int iPlayer) void C4ObjectList::Draw(C4TargetFacet &cgo, int iPlayer)
{ {
C4ObjectLink *clnk; C4ObjectLink *clnk;
// Draw objects (base) // Draw objects (base)
for (clnk=Last; clnk; clnk=clnk->Prev) for (clnk=Last; clnk; clnk=clnk->Prev)
if (!(clnk->Obj->Category & C4D_BackgroundOrForeground)) if (!(clnk->Obj->Category & C4D_BackgroundOrForeground))
clnk->Obj->Draw(cgo, iPlayer); clnk->Obj->Draw(cgo, iPlayer);
// Draw objects (top face) // Draw objects (top face)
for (clnk=Last; clnk; clnk=clnk->Prev) for (clnk=Last; clnk; clnk=clnk->Prev)
if (!(clnk->Obj->Category & C4D_BackgroundOrForeground)) if (!(clnk->Obj->Category & C4D_BackgroundOrForeground))
clnk->Obj->DrawTopFace(cgo, iPlayer); clnk->Obj->DrawTopFace(cgo, iPlayer);
} }
void C4ObjectList::Enumerate() void C4ObjectList::Enumerate()
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
// Enumerate object pointers // Enumerate object pointers
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
cLnk->Obj->EnumeratePointers(); cLnk->Obj->EnumeratePointers();
} }
bool C4ObjectList::IsContained(C4Object *pObj) bool C4ObjectList::IsContained(C4Object *pObj)
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj==pObj) if (cLnk->Obj==pObj)
return true; return true;
return false; return false;
@ -492,8 +492,8 @@ bool C4ObjectList::Write(char *szTarget)
{ {
char ostr[25]; char ostr[25];
szTarget[0]=0; szTarget[0]=0;
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=First; cLnk && cLnk->Obj; cLnk=cLnk->Next) for (cLnk=First; cLnk && cLnk->Obj; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
{ {
sprintf(ostr,"%d;",cLnk->Obj->Number); sprintf(ostr,"%d;",cLnk->Obj->Number);
@ -504,16 +504,16 @@ bool C4ObjectList::Write(char *szTarget)
void C4ObjectList::Denumerate() void C4ObjectList::Denumerate()
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
cLnk->Obj->DenumeratePointers(); cLnk->Obj->DenumeratePointers();
} }
void C4ObjectList::CompileFunc(StdCompiler *pComp, bool fSaveRefs, bool fSkipPlayerObjects) void C4ObjectList::CompileFunc(StdCompiler *pComp, bool fSaveRefs, bool fSkipPlayerObjects)
{ {
if(fSaveRefs) if(fSaveRefs)
{ {
// this mode not supported // this mode not supported
assert(!fSkipPlayerObjects); assert(!fSkipPlayerObjects);
// (Re)create list // (Re)create list
@ -529,35 +529,35 @@ void C4ObjectList::CompileFunc(StdCompiler *pComp, bool fSaveRefs, bool fSkipPla
if(!pComp->isCompiler()) if(!pComp->isCompiler())
{ delete pEnumerated; pEnumerated = NULL; } { delete pEnumerated; pEnumerated = NULL; }
// Compiling: Nothing to do - list will e denumerated later // Compiling: Nothing to do - list will e denumerated later
} }
else else
{ {
if(pComp->isDecompiler()) if(pComp->isDecompiler())
{ {
// skipping player objects would screw object counting in non-naming compilers // skipping player objects would screw object counting in non-naming compilers
assert(!fSkipPlayerObjects || pComp->hasNaming()); assert(!fSkipPlayerObjects || pComp->hasNaming());
// Put object count // Put object count
int32_t iObjCnt = ObjectCount(); int32_t iObjCnt = ObjectCount();
pComp->Value(mkNamingCountAdapt(iObjCnt, "Object")); pComp->Value(mkNamingCountAdapt(iObjCnt, "Object"));
// Decompile all objects in reverse order // Decompile all objects in reverse order
for(C4ObjectLink *pPos = Last; pPos; pPos = pPos->Prev) for(C4ObjectLink *pPos = Last; pPos; pPos = pPos->Prev)
if(pPos->Obj->Status) if(pPos->Obj->Status)
if (!fSkipPlayerObjects || !pPos->Obj->IsUserPlayerObject()) if (!fSkipPlayerObjects || !pPos->Obj->IsUserPlayerObject())
pComp->Value(mkNamingAdapt(*pPos->Obj, "Object")); pComp->Value(mkNamingAdapt(*pPos->Obj, "Object"));
} }
else else
{ {
// this mode not supported // this mode not supported
assert(!fSkipPlayerObjects); assert(!fSkipPlayerObjects);
// Remove previous data // Remove previous data
Clear(); Clear();
// Get "Object" section count // Get "Object" section count
int32_t iObjCnt; int32_t iObjCnt;
pComp->Value(mkNamingCountAdapt(iObjCnt, "Object")); pComp->Value(mkNamingCountAdapt(iObjCnt, "Object"));
// Load objects, add them to the list. // Load objects, add them to the list.
for(int i = 0; i < iObjCnt; i++) for(int i = 0; i < iObjCnt; i++)
{ {
C4Object *pObj = NULL; C4Object *pObj = NULL;
try try
{ {
pComp->Value(mkNamingAdapt(mkPtrAdaptNoNull(pObj), "Object")); pComp->Value(mkNamingAdapt(mkPtrAdaptNoNull(pObj), "Object"));
@ -572,9 +572,9 @@ void C4ObjectList::CompileFunc(StdCompiler *pComp, bool fSaveRefs, bool fSkipPla
LogF("ERROR: Object loading(%s): %s", pExc->Pos.getData(), pExc->Msg.getData()); LogF("ERROR: Object loading(%s): %s", pExc->Pos.getData(), pExc->Msg.getData());
delete pExc; delete pExc;
} }
} }
} }
} }
} }
StdStrBuf C4ObjectList::GetNameList(C4DefList &rDefs, DWORD dwCategory) StdStrBuf C4ObjectList::GetNameList(C4DefList &rDefs, DWORD dwCategory)
@ -583,7 +583,7 @@ StdStrBuf C4ObjectList::GetNameList(C4DefList &rDefs, DWORD dwCategory)
C4ID c_id; C4ID c_id;
C4Def *cdef; C4Def *cdef;
StdStrBuf Buf; StdStrBuf Buf;
for (cpos=0; (c_id=GetListID(dwCategory,cpos)); cpos++) for (cpos=0; (c_id=GetListID(dwCategory,cpos)); cpos++)
if ((cdef=rDefs.ID2Def(c_id))) if ((cdef=rDefs.ID2Def(c_id)))
{ {
idcount=ObjectCount(c_id); idcount=ObjectCount(c_id);
@ -595,8 +595,8 @@ StdStrBuf C4ObjectList::GetNameList(C4DefList &rDefs, DWORD dwCategory)
bool C4ObjectList::ValidateOwners() bool C4ObjectList::ValidateOwners()
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
cLnk->Obj->ValidateOwner(); cLnk->Obj->ValidateOwner();
return true; return true;
@ -607,8 +607,8 @@ bool C4ObjectList::AssignInfo()
// the list seems to be traced backwards here, to ensure crew objects are added in correct order // the list seems to be traced backwards here, to ensure crew objects are added in correct order
// (or semi-correct, because this will work only if the crew order matches the main object list order) // (or semi-correct, because this will work only if the crew order matches the main object list order)
// this is obsolete now, because the crew list is stored in the savegame // this is obsolete now, because the crew list is stored in the savegame
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=Last; cLnk; cLnk=cLnk->Prev) for (cLnk=Last; cLnk; cLnk=cLnk->Prev)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
cLnk->Obj->AssignInfo(); cLnk->Obj->AssignInfo();
return true; return true;
@ -616,8 +616,8 @@ bool C4ObjectList::AssignInfo()
void C4ObjectList::ClearInfo(C4ObjectInfo *pInfo) void C4ObjectList::ClearInfo(C4ObjectInfo *pInfo)
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
cLnk->Obj->ClearInfo(pInfo); cLnk->Obj->ClearInfo(pInfo);
} }
@ -629,8 +629,8 @@ void C4ObjectList::DrawList(C4Facet &cgo, int iSelection, DWORD dwCategory)
int iFirstVisible = BoundBy(iSelection-iSections/2,0,Max(iObjects-iSections,0)); int iFirstVisible = BoundBy(iSelection-iSections/2,0,Max(iObjects-iSections,0));
C4Facet cgo2; C4Facet cgo2;
int iObj=0,iSec=0; int iObj=0,iSec=0;
C4ObjectLink *cLnk; C4Object *cObj; C4ObjectLink *cLnk; C4Object *cObj;
for (cLnk=First; cLnk && (cObj=cLnk->Obj); cLnk=cLnk->Next) for (cLnk=First; cLnk && (cObj=cLnk->Obj); cLnk=cLnk->Next)
if (cObj->Status && (cObj->Category && dwCategory)) if (cObj->Status && (cObj->Category && dwCategory))
{ {
if (Inside(iObj,iFirstVisible,iFirstVisible+iSections-1)) if (Inside(iObj,iFirstVisible,iFirstVisible+iSections-1))
@ -644,7 +644,7 @@ void C4ObjectList::DrawList(C4Facet &cgo, int iSelection, DWORD dwCategory)
void C4ObjectList::Sort() void C4ObjectList::Sort()
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
bool fSorted; bool fSorted;
// Sort by id // Sort by id
do do
@ -725,45 +725,45 @@ void C4NotifyingObjectList::RemoveLink(C4ObjectLink *pLnk)
void C4ObjectList::UpdateGraphics(bool fGraphicsChanged) void C4ObjectList::UpdateGraphics(bool fGraphicsChanged)
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
cLnk->Obj->UpdateGraphics(fGraphicsChanged); cLnk->Obj->UpdateGraphics(fGraphicsChanged);
} }
void C4ObjectList::UpdateFaces(bool bUpdateShapes) void C4ObjectList::UpdateFaces(bool bUpdateShapes)
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=First; cLnk; cLnk=cLnk->Next) for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status) if (cLnk->Obj->Status)
cLnk->Obj->UpdateFace(bUpdateShapes); cLnk->Obj->UpdateFace(bUpdateShapes);
} }
void C4ObjectList::DrawSelectMark(C4TargetFacet &cgo, float Zoom) void C4ObjectList::DrawSelectMark(C4TargetFacet &cgo, float Zoom)
{ {
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=Last; cLnk; cLnk=cLnk->Prev) for (cLnk=Last; cLnk; cLnk=cLnk->Prev)
cLnk->Obj->DrawSelectMark(cgo, Zoom); cLnk->Obj->DrawSelectMark(cgo, Zoom);
} }
void C4ObjectList::CloseMenus() void C4ObjectList::CloseMenus()
{ {
C4Object *cobj; C4ObjectLink *clnk; C4Object *cobj; C4ObjectLink *clnk;
for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next) for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
cobj->CloseMenu(true); cobj->CloseMenu(true);
} }
void C4ObjectList::Copy(const C4ObjectList &rList) void C4ObjectList::Copy(const C4ObjectList &rList)
{ {
Clear(); Default(); Clear(); Default();
C4ObjectLink *cLnk; C4ObjectLink *cLnk;
for (cLnk=rList.First; cLnk; cLnk=cLnk->Next) Add(cLnk->Obj, C4ObjectList::stNone); for (cLnk=rList.First; cLnk; cLnk=cLnk->Next) Add(cLnk->Obj, C4ObjectList::stNone);
} }
void C4ObjectList::Default() void C4ObjectList::Default()
{ {
First=Last=NULL; First=Last=NULL;
Mass=0; Mass=0;
pEnumerated=NULL; pEnumerated=NULL;
} }

View File

@ -116,7 +116,7 @@ void C4ObjectMenu::ClearPointers(C4Object *pObj)
C4Object* C4ObjectMenu::GetParentObject() C4Object* C4ObjectMenu::GetParentObject()
{ {
C4Object *cObj; C4ObjectLink *cLnk; C4Object *cObj; C4ObjectLink *cLnk;
for (cLnk=::Objects.First; cLnk && (cObj=cLnk->Obj); cLnk=cLnk->Next) for (cLnk=::Objects.First; cLnk && (cObj=cLnk->Obj); cLnk=cLnk->Next)
if ( cObj->Menu == this ) if ( cObj->Menu == this )
return cObj; return cObj;

View File

@ -55,7 +55,7 @@ void C4Shape::Clear()
} }
void C4Shape::Rotate(int32_t iAngle, bool bUpdateVertices) void C4Shape::Rotate(int32_t iAngle, bool bUpdateVertices)
{ {
#ifdef DEBUGREC #ifdef DEBUGREC
C4RCRotVtx rc; C4RCRotVtx rc;
rc.x=x; rc.y=y; rc.wdt=Wdt; rc.hgt=Hgt; rc.r=iAngle; rc.x=x; rc.y=y; rc.wdt=Wdt; rc.hgt=Hgt; rc.r=iAngle;
@ -64,11 +64,11 @@ void C4Shape::Rotate(int32_t iAngle, bool bUpdateVertices)
{ rc.VtxX[i]=VtxX[i]; rc.VtxY[i]=VtxY[i]; } { rc.VtxX[i]=VtxX[i]; rc.VtxY[i]=VtxY[i]; }
AddDbgRec(RCT_RotVtx1, &rc, sizeof(rc)); AddDbgRec(RCT_RotVtx1, &rc, sizeof(rc));
#endif #endif
int32_t cnt,nvtx,nvty,rdia; int32_t cnt,nvtx,nvty,rdia;
//int32_t *vtx=VtxX; //int32_t *vtx=VtxX;
//int32_t *vty=VtxY; //int32_t *vty=VtxY;
FIXED mtx[4]; FIXED mtx[4];
FIXED fAngle = itofix(iAngle); FIXED fAngle = itofix(iAngle);
if (bUpdateVertices) if (bUpdateVertices)
@ -104,89 +104,89 @@ void C4Shape::Rotate(int32_t iAngle, bool bUpdateVertices)
} }
// Enlarge Rect // Enlarge Rect
rdia= (int32_t) sqrt(double(x*x+y*y)) + 2; rdia= (int32_t) sqrt(double(x*x+y*y)) + 2;
x=-rdia; x=-rdia;
y=-rdia; y=-rdia;
Wdt=2*rdia; Wdt=2*rdia;
Hgt=2*rdia; Hgt=2*rdia;
#ifdef DEBUGREC #ifdef DEBUGREC
rc.x=x; rc.y=y; rc.wdt=Wdt; rc.hgt=Hgt; rc.x=x; rc.y=y; rc.wdt=Wdt; rc.hgt=Hgt;
for (i=0; i<4; ++i) for (i=0; i<4; ++i)
{ rc.VtxX[i]=VtxX[i]; rc.VtxY[i]=VtxY[i]; } { rc.VtxX[i]=VtxX[i]; rc.VtxY[i]=VtxY[i]; }
AddDbgRec(RCT_RotVtx2, &rc, sizeof(rc)); AddDbgRec(RCT_RotVtx2, &rc, sizeof(rc));
#endif #endif
} }
void C4Shape::Stretch(int32_t iCon, bool bUpdateVertices) void C4Shape::Stretch(int32_t iCon, bool bUpdateVertices)
{ {
int32_t cnt; int32_t cnt;
x=x*iCon/FullCon; x=x*iCon/FullCon;
y=y*iCon/FullCon; y=y*iCon/FullCon;
Wdt=Wdt*iCon/FullCon; Wdt=Wdt*iCon/FullCon;
Hgt=Hgt*iCon/FullCon; Hgt=Hgt*iCon/FullCon;
FireTop=FireTop*iCon/FullCon; FireTop=FireTop*iCon/FullCon;
if (bUpdateVertices) if (bUpdateVertices)
for (cnt=0; cnt<VtxNum; cnt++) for (cnt=0; cnt<VtxNum; cnt++)
{ {
VtxX[cnt]=VtxX[cnt]*iCon/FullCon; VtxX[cnt]=VtxX[cnt]*iCon/FullCon;
VtxY[cnt]=VtxY[cnt]*iCon/FullCon; VtxY[cnt]=VtxY[cnt]*iCon/FullCon;
} }
} }
void C4Shape::Jolt(int32_t iCon, bool bUpdateVertices) void C4Shape::Jolt(int32_t iCon, bool bUpdateVertices)
{ {
int32_t cnt; int32_t cnt;
y=y*iCon/FullCon; y=y*iCon/FullCon;
Hgt=Hgt*iCon/FullCon; Hgt=Hgt*iCon/FullCon;
FireTop=FireTop*iCon/FullCon; FireTop=FireTop*iCon/FullCon;
if (bUpdateVertices) if (bUpdateVertices)
for (cnt=0; cnt<VtxNum; cnt++) for (cnt=0; cnt<VtxNum; cnt++)
VtxY[cnt]=VtxY[cnt]*iCon/FullCon; VtxY[cnt]=VtxY[cnt]*iCon/FullCon;
} }
void C4Shape::GetVertexOutline(C4Rect &rRect) void C4Shape::GetVertexOutline(C4Rect &rRect)
{ {
int32_t cnt; int32_t cnt;
rRect.x=rRect.y=rRect.Wdt=rRect.Hgt=0; rRect.x=rRect.y=rRect.Wdt=rRect.Hgt=0;
for (cnt=0; cnt<VtxNum; cnt++) for (cnt=0; cnt<VtxNum; cnt++)
{ {
// Extend left // Extend left
if (VtxX[cnt]<rRect.x) if (VtxX[cnt]<rRect.x)
{ {
rRect.Wdt+=rRect.x-VtxX[cnt]; rRect.Wdt+=rRect.x-VtxX[cnt];
rRect.x=VtxX[cnt]; rRect.x=VtxX[cnt];
} }
// Extend right // Extend right
else if (VtxX[cnt]>rRect.x+rRect.Wdt) else if (VtxX[cnt]>rRect.x+rRect.Wdt)
{ rRect.Wdt=VtxX[cnt]-rRect.x; } { rRect.Wdt=VtxX[cnt]-rRect.x; }
// Extend up // Extend up
if (VtxY[cnt]<rRect.y) if (VtxY[cnt]<rRect.y)
{ {
rRect.Hgt+=rRect.y-VtxY[cnt]; rRect.Hgt+=rRect.y-VtxY[cnt];
rRect.y=VtxY[cnt]; rRect.y=VtxY[cnt];
} }
// Extend down // Extend down
else if (VtxY[cnt]>rRect.y+rRect.Hgt) else if (VtxY[cnt]>rRect.y+rRect.Hgt)
{ rRect.Hgt=VtxY[cnt]-rRect.y; } { rRect.Hgt=VtxY[cnt]-rRect.y; }
} }
rRect.Hgt+=rRect.y-y; rRect.Hgt+=rRect.y-y;
rRect.y=y; rRect.y=y;
} }
bool C4Shape::Attach(int32_t &cx, int32_t &cy, BYTE cnat_pos) bool C4Shape::Attach(int32_t &cx, int32_t &cy, BYTE cnat_pos)
{ {
// Adjust given position to one pixel before contact // Adjust given position to one pixel before contact
// at vertices matching CNAT request. // at vertices matching CNAT request.
bool fAttached=false; bool fAttached=false;
int32_t vtx,xcnt,ycnt,xcrng,ycrng,xcd,ycd; int32_t vtx,xcnt,ycnt,xcrng,ycrng,xcd,ycd;
BYTE cpix; BYTE cpix;
// reset attached material // reset attached material
@ -244,8 +244,8 @@ bool C4Shape::Attach(int32_t &cx, int32_t &cy, BYTE cnat_pos)
} }
} }
return fAttached; return fAttached;
} }
bool C4Shape::LineConnect(int32_t tx, int32_t ty, int32_t cvtx, int32_t ld, int32_t oldx, int32_t oldy) bool C4Shape::LineConnect(int32_t tx, int32_t ty, int32_t cvtx, int32_t ld, int32_t oldx, int32_t oldy)
@ -335,14 +335,14 @@ bool C4Shape::CheckContact(int32_t cx, int32_t cy)
// Return true on any contact. // Return true on any contact.
for (int32_t cvtx=0; cvtx<VtxNum; cvtx++) for (int32_t cvtx=0; cvtx<VtxNum; cvtx++)
if (!(VtxCNAT[cvtx] & CNAT_NoCollision)) if (!(VtxCNAT[cvtx] & CNAT_NoCollision))
if (GBackDensity(cx+VtxX[cvtx],cy+VtxY[cvtx]) >= ContactDensity) if (GBackDensity(cx+VtxX[cvtx],cy+VtxY[cvtx]) >= ContactDensity)
return true; return true;
return false; return false;
} }
bool C4Shape::ContactCheck(int32_t cx, int32_t cy) bool C4Shape::ContactCheck(int32_t cx, int32_t cy)
{ {
@ -352,10 +352,10 @@ bool C4Shape::ContactCheck(int32_t cx, int32_t cy)
// Return true on any contact. // Return true on any contact.
ContactCNAT=CNAT_None; ContactCNAT=CNAT_None;
ContactCount=0; ContactCount=0;
for (int32_t cvtx=0; cvtx<VtxNum; cvtx++) for (int32_t cvtx=0; cvtx<VtxNum; cvtx++)
// Ignore vertex if collision has been flagged out // Ignore vertex if collision has been flagged out
if (!(VtxCNAT[cvtx] & CNAT_NoCollision)) if (!(VtxCNAT[cvtx] & CNAT_NoCollision))
@ -383,8 +383,8 @@ bool C4Shape::ContactCheck(int32_t cx, int32_t cy)
} }
return !!ContactCount; return !!ContactCount;
} }
int32_t C4Shape::GetVertexX(int32_t iVertex) int32_t C4Shape::GetVertexX(int32_t iVertex)
{ {

View File

@ -41,27 +41,27 @@ class C4DensityProvider
extern C4DensityProvider DefaultDensityProvider; extern C4DensityProvider DefaultDensityProvider;
class C4Shape: public C4Rect class C4Shape: public C4Rect
{ {
public: public:
C4Shape(); C4Shape();
public: public:
// remember to adjust C4Shape::CopyFrom and CreateOwnOriginalCopy when adding members here! // remember to adjust C4Shape::CopyFrom and CreateOwnOriginalCopy when adding members here!
int32_t FireTop; int32_t FireTop;
int32_t VtxNum; int32_t VtxNum;
int32_t VtxX[C4D_MaxVertex]; int32_t VtxX[C4D_MaxVertex];
int32_t VtxY[C4D_MaxVertex]; int32_t VtxY[C4D_MaxVertex];
int32_t VtxCNAT[C4D_MaxVertex]; int32_t VtxCNAT[C4D_MaxVertex];
int32_t VtxFriction[C4D_MaxVertex]; int32_t VtxFriction[C4D_MaxVertex];
int32_t ContactDensity; int32_t ContactDensity;
int32_t ContactCNAT; int32_t ContactCNAT;
int32_t ContactCount; int32_t ContactCount;
int32_t AttachMat; int32_t AttachMat;
int32_t VtxContactCNAT[C4D_MaxVertex]; int32_t VtxContactCNAT[C4D_MaxVertex];
int32_t VtxContactMat[C4D_MaxVertex]; int32_t VtxContactMat[C4D_MaxVertex];
int32_t iAttachX, iAttachY, iAttachVtx; int32_t iAttachX, iAttachY, iAttachVtx;
public: public:
void Default(); void Default();
void Clear(); void Clear();
void Rotate(int32_t iAngle, bool bUpdateVertices); void Rotate(int32_t iAngle, bool bUpdateVertices);
void Stretch(int32_t iCon, bool bUpdateVertices); void Stretch(int32_t iCon, bool bUpdateVertices);
void Jolt(int32_t iCon, bool bUpdateVertices); void Jolt(int32_t iCon, bool bUpdateVertices);
@ -82,6 +82,6 @@ class C4Shape: public C4Rect
int32_t GetVertexContact(int32_t iVtx, DWORD dwCheckMask, int32_t tx, int32_t ty, const C4DensityProvider &rDensityProvider = DefaultDensityProvider); // get CNAT-mask for given vertex - does not check range for iVtx! int32_t GetVertexContact(int32_t iVtx, DWORD dwCheckMask, int32_t tx, int32_t ty, const C4DensityProvider &rDensityProvider = DefaultDensityProvider); // get CNAT-mask for given vertex - does not check range for iVtx!
void CreateOwnOriginalCopy(C4Shape &rFrom); // create copy of all vertex members in back area of own buffers void CreateOwnOriginalCopy(C4Shape &rFrom); // create copy of all vertex members in back area of own buffers
void CompileFunc(StdCompiler *pComp, bool fRuntime); void CompileFunc(StdCompiler *pComp, bool fRuntime);
}; };
#endif // INC_C4Shape #endif // INC_C4Shape

File diff suppressed because it is too large Load Diff

View File

@ -110,32 +110,32 @@ bool C4PlayerList::HostilityDeclared(int iPlayer1, int iPlayer2) const
} }
bool C4PlayerList::PositionTaken(int iPosition) const bool C4PlayerList::PositionTaken(int iPosition) const
{ {
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (pPlr->Position==iPosition) if (pPlr->Position==iPosition)
return true; return true;
return false; return false;
} }
bool C4PlayerList::ColorTaken(int iColor) const bool C4PlayerList::ColorTaken(int iColor) const
{ {
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (pPlr->Color==iColor) if (pPlr->Color==iColor)
return true; return true;
return false; return false;
} }
int C4PlayerList::CheckColorDw(DWORD dwColor, C4Player *pExclude) int C4PlayerList::CheckColorDw(DWORD dwColor, C4Player *pExclude)
{ {
// maximum difference // maximum difference
int iDiff=255+255+255; int iDiff=255+255+255;
// check all player's color difference // check all player's color difference
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) if (pPlr != pExclude) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) if (pPlr != pExclude)
{ {
// get color // get color
DWORD dwClr2=pPlr->ColorDw; DWORD dwClr2=pPlr->ColorDw;
// assign difference, if less than smallest difference found // assign difference, if less than smallest difference found
iDiff=Min(iDiff, iDiff=Min(iDiff,
Abs(GetRValue(dwColor) - GetRValue(dwClr2)) Abs(GetRValue(dwColor) - GetRValue(dwClr2))
+ Abs(GetGValue(dwColor) - GetGValue(dwClr2)) + Abs(GetGValue(dwColor) - GetGValue(dwClr2))
+ Abs(GetBValue(dwColor) - GetBValue(dwClr2))); + Abs(GetBValue(dwColor) - GetBValue(dwClr2)));
@ -146,7 +146,7 @@ int C4PlayerList::CheckColorDw(DWORD dwColor, C4Player *pExclude)
C4Player* C4PlayerList::Get(int iNumber) const C4Player* C4PlayerList::Get(int iNumber) const
{ {
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (pPlr->Number==iNumber) if (pPlr->Number==iNumber)
return pPlr; return pPlr;
return NULL; return NULL;
@ -155,7 +155,7 @@ C4Player* C4PlayerList::Get(int iNumber) const
int C4PlayerList::GetIndex(C4Player *tPlr) const int C4PlayerList::GetIndex(C4Player *tPlr) const
{ {
int cindex=0; int cindex=0;
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next, cindex++) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next, cindex++)
if (pPlr==tPlr) if (pPlr==tPlr)
return cindex; return cindex;
return -1; return -1;
@ -163,7 +163,7 @@ int C4PlayerList::GetIndex(C4Player *tPlr) const
C4Player* C4PlayerList::GetByIndex(int iIndex) const C4Player* C4PlayerList::GetByIndex(int iIndex) const
{ {
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (!iIndex--) if (!iIndex--)
return pPlr; return pPlr;
return NULL; return NULL;
@ -171,7 +171,7 @@ C4Player* C4PlayerList::GetByIndex(int iIndex) const
C4Player* C4PlayerList::GetByIndex(int iIndex, C4PlayerType eType) const C4Player* C4PlayerList::GetByIndex(int iIndex, C4PlayerType eType) const
{ {
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (pPlr->GetType() == eType) if (pPlr->GetType() == eType)
if (!iIndex--) if (!iIndex--)
return pPlr; return pPlr;
@ -180,7 +180,7 @@ C4Player* C4PlayerList::GetByIndex(int iIndex, C4PlayerType eType) const
C4Player *C4PlayerList::GetByInfoID(int iInfoID) const C4Player *C4PlayerList::GetByInfoID(int iInfoID) const
{ {
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (pPlr->ID == iInfoID) return pPlr; if (pPlr->ID == iInfoID) return pPlr;
return NULL; return NULL;
} }
@ -188,7 +188,7 @@ C4Player *C4PlayerList::GetByInfoID(int iInfoID) const
int C4PlayerList::GetCount() const int C4PlayerList::GetCount() const
{ {
int iCount = 0; int iCount = 0;
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
iCount++; iCount++;
return iCount; return iCount;
} }
@ -196,7 +196,7 @@ int C4PlayerList::GetCount() const
int C4PlayerList::GetCount(C4PlayerType eType) const int C4PlayerList::GetCount(C4PlayerType eType) const
{ {
int iCount = 0; int iCount = 0;
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (pPlr->GetType() == eType) if (pPlr->GetType() == eType)
iCount++; iCount++;
return iCount; return iCount;
@ -249,11 +249,11 @@ bool C4PlayerList::Remove(C4Player *pPlr, bool fDisconnect, bool fNoCalls)
{ {
C4PlayerInfo *pInfo = Game.PlayerInfos.GetPlayerInfoByID(pPlr->ID); C4PlayerInfo *pInfo = Game.PlayerInfos.GetPlayerInfoByID(pPlr->ID);
if (pInfo) if (pInfo)
{ {
pInfo->SetRemoved(); pInfo->SetRemoved();
if(fDisconnect) if(fDisconnect)
pInfo->SetDisconnected(); pInfo->SetDisconnected();
} }
// if player wasn't evaluated, store round results anyway // if player wasn't evaluated, store round results anyway
if (!pPlr->Evaluated) Game.RoundResults.EvaluatePlayer(pPlr); if (!pPlr->Evaluated) Game.RoundResults.EvaluatePlayer(pPlr);
} }
@ -454,7 +454,7 @@ int C4PlayerList::AverageValueGain() const
C4Player* C4PlayerList::GetByName(const char *szName, int iExcluding) const C4Player* C4PlayerList::GetByName(const char *szName, int iExcluding) const
{ {
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (SEqual(pPlr->GetName(),szName)) if (SEqual(pPlr->GetName(),szName))
if (pPlr->Number!=iExcluding) if (pPlr->Number!=iExcluding)
return pPlr; return pPlr;
@ -485,7 +485,7 @@ bool C4PlayerList::FileInUse(const char *szFilename) const
C4Player* C4PlayerList::GetLocalByIndex(int iIndex) const C4Player* C4PlayerList::GetLocalByIndex(int iIndex) const
{ {
int cindex=0; int cindex=0;
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (pPlr->LocalControl) if (pPlr->LocalControl)
{ {
if (cindex==iIndex) return pPlr; if (cindex==iIndex) return pPlr;
@ -552,7 +552,7 @@ bool C4PlayerList::CtrlRemoveAtClient(const char *szName, bool fDisconnect)
C4Player* C4PlayerList::GetAtClient(int iClient, int iIndex) const C4Player* C4PlayerList::GetAtClient(int iClient, int iIndex) const
{ {
int cindex=0; int cindex=0;
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (pPlr->AtClient == iClient) if (pPlr->AtClient == iClient)
{ {
if (cindex==iIndex) return pPlr; if (cindex==iIndex) return pPlr;
@ -564,7 +564,7 @@ C4Player* C4PlayerList::GetAtClient(int iClient, int iIndex) const
C4Player* C4PlayerList::GetAtClient(const char *szName, int iIndex) const C4Player* C4PlayerList::GetAtClient(const char *szName, int iIndex) const
{ {
int cindex=0; int cindex=0;
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (SEqualNoCase(pPlr->AtClientName,szName)) if (SEqualNoCase(pPlr->AtClientName,szName))
{ {
if (cindex==iIndex) return pPlr; if (cindex==iIndex) return pPlr;
@ -590,7 +590,7 @@ bool C4PlayerList::RemoveAtRemoteClient(bool fDisconnect, bool fNoCalls)
C4Player* C4PlayerList::GetAtRemoteClient(int iIndex) const C4Player* C4PlayerList::GetAtRemoteClient(int iIndex) const
{ {
int cindex=0; int cindex=0;
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (pPlr->AtClient != ::Control.ClientID()) if (pPlr->AtClient != ::Control.ClientID())
{ {
if (cindex==iIndex) return pPlr; if (cindex==iIndex) return pPlr;
@ -620,29 +620,29 @@ bool C4PlayerList::RemoveLocal(bool fDisconnect, bool fNoCalls)
void C4PlayerList::EnumeratePointers() void C4PlayerList::EnumeratePointers()
{ {
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
pPlr->EnumeratePointers(); pPlr->EnumeratePointers();
} }
void C4PlayerList::DenumeratePointers() void C4PlayerList::DenumeratePointers()
{ {
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
pPlr->DenumeratePointers(); pPlr->DenumeratePointers();
} }
bool C4PlayerList::MouseControlTaken() const bool C4PlayerList::MouseControlTaken() const
{ {
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (pPlr->MouseControl) if (pPlr->MouseControl)
if (pPlr->LocalControl) if (pPlr->LocalControl)
return true; return true;
return false; return false;
} }
int C4PlayerList::GetCountNotEliminated() const int C4PlayerList::GetCountNotEliminated() const
{ {
int iCount = 0; int iCount = 0;
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
if (!pPlr->Eliminated) if (!pPlr->Eliminated)
iCount++; iCount++;
return iCount; return iCount;
@ -654,7 +654,7 @@ bool C4PlayerList::SynchronizeLocalFiles()
Log(LoadResStr("IDS_PRC_SYNCPLRS")); Log(LoadResStr("IDS_PRC_SYNCPLRS"));
bool fSuccess = true; bool fSuccess = true;
// check all players // check all players
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
// eliminated players will be saved soon, anyway // eliminated players will be saved soon, anyway
if (!pPlr->Eliminated) if (!pPlr->Eliminated)
if (!pPlr->LocalSync()) fSuccess = false; if (!pPlr->LocalSync()) fSuccess = false;

View File

@ -33,14 +33,14 @@
#include <StdRegistry.h> #include <StdRegistry.h>
C4RankSystem::C4RankSystem() C4RankSystem::C4RankSystem()
{ {
Default(); Default();
} }
int C4RankSystem::Init(const char *szRegister, int C4RankSystem::Init(const char *szRegister,
const char *szDefRanks, const char *szDefRanks,
int iRankBase) int iRankBase)
{ {
// Init // Init
SCopy(szRegister,Register,256); SCopy(szRegister,Register,256);
@ -94,7 +94,7 @@ int C4RankSystem::Init(const char *szRegister,
} }
return iRankNum; return iRankNum;
#endif #endif
} }
bool C4RankSystem::Load(C4Group &hGroup, const char *szFilenames, int DefRankBase, const char *szLanguage) bool C4RankSystem::Load(C4Group &hGroup, const char *szFilenames, int DefRankBase, const char *szLanguage)
{ {
@ -187,8 +187,8 @@ bool C4RankSystem::Load(C4Group &hGroup, const char *szFilenames, int DefRankBas
} }
StdStrBuf C4RankSystem::GetRankName(int iRank, bool fReturnLastIfOver) StdStrBuf C4RankSystem::GetRankName(int iRank, bool fReturnLastIfOver)
{ {
if (iRank<0) return StdStrBuf(); if (iRank<0) return StdStrBuf();
// if a new-style ranklist is loaded, seek there // if a new-style ranklist is loaded, seek there
if (pszRankNames) if (pszRankNames)
{ {
@ -227,14 +227,14 @@ StdStrBuf C4RankSystem::GetRankName(int iRank, bool fReturnLastIfOver)
--iRank; --iRank;
} }
#endif #endif
return StdStrBuf(); return StdStrBuf();
} }
int C4RankSystem::Experience(int iRank) int C4RankSystem::Experience(int iRank)
{ {
if (iRank<0) return 0; if (iRank<0) return 0;
return (int) ( pow (double(iRank), 1.5) * RankBase ); return (int) ( pow (double(iRank), 1.5) * RankBase );
} }
int C4RankSystem::RankByExperience(int iExp) int C4RankSystem::RankByExperience(int iExp)
{ {

View File

@ -29,14 +29,14 @@ class C4Facet;
class C4FacetSurface; class C4FacetSurface;
class C4RankSystem class C4RankSystem
{ {
public: public:
C4RankSystem(); C4RankSystem();
~C4RankSystem() { Clear(); } ~C4RankSystem() { Clear(); }
enum { EXP_NoPromotion = -1 }; // experience value for NextRankExp: No more promotion possible enum { EXP_NoPromotion = -1 }; // experience value for NextRankExp: No more promotion possible
protected: protected:
char Register[256+1]; char Register[256+1];
char RankName[C4MaxName+1]; char RankName[C4MaxName+1];
int RankBase; int RankBase;
@ -45,20 +45,20 @@ class C4RankSystem
int iRankNum; // number of ranks for loaded rank-names int iRankNum; // number of ranks for loaded rank-names
char **pszRankExtensions; // rank extensions (e.g. "%s First class") for even more ranks! char **pszRankExtensions; // rank extensions (e.g. "%s First class") for even more ranks!
int iRankExtNum; // number of rank extensions int iRankExtNum; // number of rank extensions
public: public:
void Default(); void Default();
void Clear(); void Clear();
int Init(const char *szRegister, const char *szDefRanks, int iRankBase); int Init(const char *szRegister, const char *szDefRanks, int iRankBase);
bool Load(C4Group &hGroup, const char *szFilenames, int DefRankBase, const char *szLanguage); // init based on nk file in group bool Load(C4Group &hGroup, const char *szFilenames, int DefRankBase, const char *szLanguage); // init based on nk file in group
int Experience(int iRank); int Experience(int iRank);
int RankByExperience(int iExp); // get rank by experience int RankByExperience(int iExp); // get rank by experience
StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver); StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver);
bool Check(int iRank, const char *szDefRankName); bool Check(int iRank, const char *szDefRankName);
int32_t GetExtendedRankNum() const { return iRankExtNum; } int32_t GetExtendedRankNum() const { return iRankExtNum; }
int32_t GetBaseRankNum() const { return iRankNum; } int32_t GetBaseRankNum() const { return iRankNum; }
//void Reset(const char *szDefRanks); //void Reset(const char *szDefRanks);
static bool DrawRankSymbol(C4FacetSurface *fctSymbol, int32_t iRank, C4Facet *pfctRankSymbols, int32_t iRankSymbolCount, bool fOwnSurface, int32_t iXOff=0, C4Facet *cgoDrawDirect=NULL); // create facet from rank symbol for definition - use custom rank facets if present static bool DrawRankSymbol(C4FacetSurface *fctSymbol, int32_t iRank, C4Facet *pfctRankSymbols, int32_t iRankSymbolCount, bool fOwnSurface, int32_t iXOff=0, C4Facet *cgoDrawDirect=NULL); // create facet from rank symbol for definition - use custom rank facets if present
}; };
extern C4RankSystem DefaultRanks; extern C4RankSystem DefaultRanks;

View File

@ -568,16 +568,16 @@ int32_t FnFxFireStart(C4AulContext *ctx, C4Object *pObj, int32_t iNumber, int32_
// In extinguishing material // In extinguishing material
bool fFireCaused=true; bool fFireCaused=true;
int32_t iMat; int32_t iMat;
if (MatValid(iMat=GBackMat(pObj->GetX(),pObj->GetY()))) if (MatValid(iMat=GBackMat(pObj->GetX(),pObj->GetY())))
if (::MaterialMap.Map[iMat].Extinguisher) if (::MaterialMap.Map[iMat].Extinguisher)
{ {
// blasts should changedef in water, too! // blasts should changedef in water, too!
if (fBlasted) if (pObj->Def->BurnTurnTo!=C4ID::None) pObj->ChangeDef(pObj->Def->BurnTurnTo); if (fBlasted) if (pObj->Def->BurnTurnTo!=C4ID::None) pObj->ChangeDef(pObj->Def->BurnTurnTo);
// no fire caused // no fire caused
fFireCaused = false; fFireCaused = false;
} }
// BurnTurnTo // BurnTurnTo
if (fFireCaused) if (pObj->Def->BurnTurnTo!=C4ID::None) pObj->ChangeDef(pObj->Def->BurnTurnTo); if (fFireCaused) if (pObj->Def->BurnTurnTo!=C4ID::None) pObj->ChangeDef(pObj->Def->BurnTurnTo);
// eject contents // eject contents
C4Object *cobj; C4Object *cobj;
if (!pObj->Def->IncompleteActivity && !pObj->Def->NoBurnDecay) if (!pObj->Def->IncompleteActivity && !pObj->Def->NoBurnDecay)
@ -610,8 +610,8 @@ int32_t FnFxFireStart(C4AulContext *ctx, C4Object *pObj, int32_t iNumber, int32_
if (dwCat & (C4D_Living | C4D_StaticBack)) // Tiere, Bäume if (dwCat & (C4D_Living | C4D_StaticBack)) // Tiere, Bäume
iFireMode = C4Fx_FireMode_LivingVeg; iFireMode = C4Fx_FireMode_LivingVeg;
else if (dwCat & (C4D_Structure | C4D_Vehicle)) // Gebäude und Fahrzeuge sind unten meist kantig else if (dwCat & (C4D_Structure | C4D_Vehicle)) // Gebäude und Fahrzeuge sind unten meist kantig
iFireMode = C4Fx_FireMode_StructVeh; iFireMode = C4Fx_FireMode_StructVeh;
else else
iFireMode = C4Fx_FireMode_Object; iFireMode = C4Fx_FireMode_Object;
} }
else if (!Inside<int32_t>(iFireMode, 1, C4Fx_FireMode_Last)) else if (!Inside<int32_t>(iFireMode, 1, C4Fx_FireMode_Last))
@ -631,7 +631,7 @@ int32_t FnFxFireStart(C4AulContext *ctx, C4Object *pObj, int32_t iNumber, int32_
// Engine script call // Engine script call
pObj->Call(PSF_Incineration,&C4AulParSet(C4VInt(iCausedBy))); pObj->Call(PSF_Incineration,&C4AulParSet(C4VInt(iCausedBy)));
// Done, success // Done, success
return C4Fx_OK; return C4Fx_OK;
} }
int32_t FnFxFireTimer(C4AulContext *ctx, C4Object *pObj, int32_t iNumber, int32_t iTime) int32_t FnFxFireTimer(C4AulContext *ctx, C4Object *pObj, int32_t iNumber, int32_t iTime)
@ -686,9 +686,9 @@ int32_t FnFxFireTimer(C4AulContext *ctx, C4Object *pObj, int32_t iNumber, int32_
// get remainign size (%) // get remainign size (%)
iCon=iWdtCon=Max<int32_t>((100*pObj->GetCon())/FullCon, 1); iCon=iWdtCon=Max<int32_t>((100*pObj->GetCon())/FullCon, 1);
if(!pObj->Def->GrowthType) if(!pObj->Def->GrowthType)
// fixed width for not-stretched-objects // fixed width for not-stretched-objects
if(iWdtCon<100) iWdtCon=100; if(iWdtCon<100) iWdtCon=100;
// regard non-center object offsets // regard non-center object offsets
iX += pObj->Shape.x + pObj->Shape.Wdt/2; iX += pObj->Shape.x + pObj->Shape.Wdt/2;
@ -707,10 +707,10 @@ int32_t FnFxFireTimer(C4AulContext *ctx, C4Object *pObj, int32_t iNumber, int32_
} }
// Adjust particle number by con // Adjust particle number by con
iCount = Max(2, iCount*iWdtCon/100); iCount = Max(2, iCount*iWdtCon/100);
// calc base for particle size parameter // calc base for particle size parameter
iA=(int32_t) (sqrt(sqrt(double(iWidth * iHeight))*(iCon+20)/120)*iRelParticleSize); iA=(int32_t) (sqrt(sqrt(double(iWidth * iHeight))*(iCon+20)/120)*iRelParticleSize);
// create a double set of particles; first quarter normal (Fire); remaining three quarters additive (Fire2) // create a double set of particles; first quarter normal (Fire); remaining three quarters additive (Fire2)
for(int32_t i=0; i<iCount*2; ++i) for(int32_t i=0; i<iCount*2; ++i)
@ -790,7 +790,7 @@ C4String *FnFxFireInfo(C4AulContext *ctx, C4Object *pObj, int32_t iNumber)
// Some other, internal effects ------------------------------------------------------------- // Some other, internal effects -------------------------------------------------------------
void Splash(int32_t tx, int32_t ty, int32_t amt, C4Object *pByObj) void Splash(int32_t tx, int32_t ty, int32_t amt, C4Object *pByObj)
{ {
// Splash only if there is free space above // Splash only if there is free space above
if (GBackSemiSolid(tx, ty - 15)) return; if (GBackSemiSolid(tx, ty - 15)) return;
// get back mat // get back mat
@ -812,12 +812,12 @@ void Splash(int32_t tx, int32_t ty, int32_t amt, C4Object *pByObj)
FIXED100(-Random(200))); FIXED100(-Random(200)));
} }
} }
// Splash sound // Splash sound
if (amt>=20) if (amt>=20)
StartSoundEffect("Splash2",false,100,pByObj); StartSoundEffect("Splash2",false,100,pByObj);
else else
if (amt>1) StartSoundEffect("Splash1",false,100,pByObj); if (amt>1) StartSoundEffect("Splash1",false,100,pByObj);
} }
int32_t GetSmokeLevel() int32_t GetSmokeLevel()
{ {
@ -826,7 +826,7 @@ int32_t GetSmokeLevel()
} }
void BubbleOut(int32_t tx, int32_t ty) void BubbleOut(int32_t tx, int32_t ty)
{ {
// No bubbles from nowhere // No bubbles from nowhere
if (!GBackSemiSolid(tx,ty)) return; if (!GBackSemiSolid(tx,ty)) return;
// User-defined smoke level // User-defined smoke level
@ -835,10 +835,10 @@ void BubbleOut(int32_t tx, int32_t ty)
if (::Objects.ObjectCount(C4ID("FXU1")) >= SmokeLevel) return; if (::Objects.ObjectCount(C4ID("FXU1")) >= SmokeLevel) return;
// Create bubble // Create bubble
Game.CreateObject(C4ID("FXU1"),NULL,NO_OWNER,tx,ty); Game.CreateObject(C4ID("FXU1"),NULL,NO_OWNER,tx,ty);
} }
void Smoke(int32_t tx, int32_t ty, int32_t level, DWORD dwClr) void Smoke(int32_t tx, int32_t ty, int32_t level, DWORD dwClr)
{ {
if (::Particles.pSmoke) if (::Particles.pSmoke)
{ {
::Particles.Create(::Particles.pSmoke, float(tx), float(ty)-level/2, 0.0f, 0.0f, float(level), dwClr); ::Particles.Create(::Particles.pSmoke, float(tx), float(ty)-level/2, 0.0f, 0.0f, float(level), dwClr);
@ -853,22 +853,22 @@ void Smoke(int32_t tx, int32_t ty, int32_t level, DWORD dwClr)
C4Object *pObj; C4Object *pObj;
if ((pObj = Game.CreateObjectConstruction(C4Id2Def(C4ID("FXS1")),NULL,NO_OWNER,tx,ty,FullCon*level/32))) if ((pObj = Game.CreateObjectConstruction(C4Id2Def(C4ID("FXS1")),NULL,NO_OWNER,tx,ty,FullCon*level/32)))
pObj->Call(PSF_Activate); pObj->Call(PSF_Activate);
} }
void Explosion(int32_t tx, int32_t ty, int32_t level, C4Object *inobj, int32_t iCausedBy, C4Object *pByObj, C4ID idEffect, const char *szEffect) void Explosion(int32_t tx, int32_t ty, int32_t level, C4Object *inobj, int32_t iCausedBy, C4Object *pByObj, C4ID idEffect, const char *szEffect)
{ {
int32_t grade=BoundBy((level/10)-1,1,3); int32_t grade=BoundBy((level/10)-1,1,3);
// Sound // Sound
StdStrBuf sound = FormatString("Blast%c", '0'+grade); StdStrBuf sound = FormatString("Blast%c", '0'+grade);
StartSoundEffect(sound.getData(),false,100,pByObj); StartSoundEffect(sound.getData(),false,100,pByObj);
// Check blast containment // Check blast containment
C4Object *container=inobj; C4Object *container=inobj;
while (container && !container->Def->ContainBlast) container=container->Contained; while (container && !container->Def->ContainBlast) container=container->Contained;
// Uncontained blast effects // Uncontained blast effects
if (!container) if (!container)
{ {
// Incinerate landscape // Incinerate landscape
if (!::Landscape.Incinerate(tx,ty)) if (!::Landscape.Incinerate(tx,ty))
if (!::Landscape.Incinerate(tx,ty-10)) if (!::Landscape.Incinerate(tx,ty-10))
if (!::Landscape.Incinerate(tx-5,ty-5)) if (!::Landscape.Incinerate(tx-5,ty-5))
::Landscape.Incinerate(tx+5,ty-5); ::Landscape.Incinerate(tx+5,ty-5);
@ -892,14 +892,14 @@ void Explosion(int32_t tx, int32_t ty, int32_t level, C4Object *inobj, int32_t i
else else
if ((pBlast = Game.CreateObjectConstruction(C4Id2Def(idEffect ? idEffect : C4ID("FXB1")),pByObj,iCausedBy,tx,ty+level,FullCon*level/20))) if ((pBlast = Game.CreateObjectConstruction(C4Id2Def(idEffect ? idEffect : C4ID("FXB1")),pByObj,iCausedBy,tx,ty+level,FullCon*level/20)))
pBlast->Call(PSF_Activate); pBlast->Call(PSF_Activate);
} }
// Blast objects // Blast objects
Game.BlastObjects(tx,ty,level,inobj,iCausedBy,pByObj); Game.BlastObjects(tx,ty,level,inobj,iCausedBy,pByObj);
if (container!=inobj) Game.BlastObjects(tx,ty,level,container,iCausedBy,pByObj); if (container!=inobj) Game.BlastObjects(tx,ty,level,container,iCausedBy,pByObj);
if (!container) if (!container)
{ {
// Blast free landscape. After blasting objects so newly mined materials don't get flinged // Blast free landscape. After blasting objects so newly mined materials don't get flinged
::Landscape.BlastFree(tx,ty,level,grade, iCausedBy); ::Landscape.BlastFree(tx,ty,level,grade, iCausedBy);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -52,15 +52,15 @@ struct C4ScriptConstDef
// * the second (C4V2) takes an array of 10 parameters // * the second (C4V2) takes an array of 10 parameters
// only one may be set. // only one may be set.
struct C4ScriptFnDef struct C4ScriptFnDef
{ {
const char* Identifier; // the name of the func in the script const char* Identifier; // the name of the func in the script
bool Public; bool Public;
C4V_Type RetType; // type returned. ignored when C4V C4V_Type RetType; // type returned. ignored when C4V
C4V_Type ParType[10];// type of the parameters. error when wrong parameter type. C4V_Type ParType[10];// type of the parameters. error when wrong parameter type.
C4Value (*FunctionC4V)(C4AulContext *cthr, C4Value*, C4Value*, C4Value*, C4Value*, C4Value*, C4Value (*FunctionC4V)(C4AulContext *cthr, C4Value*, C4Value*, C4Value*, C4Value*, C4Value*,
C4Value*, C4Value*, C4Value*, C4Value*, C4Value*); C4Value*, C4Value*, C4Value*, C4Value*, C4Value*);
C4Value (*FunctionC4V2)(struct C4AulContext *, C4Value *); C4Value (*FunctionC4V2)(struct C4AulContext *, C4Value *);
}; };
extern C4ScriptConstDef C4ScriptConstMap[]; extern C4ScriptConstDef C4ScriptConstMap[];
extern C4ScriptFnDef C4ScriptFnMap[]; extern C4ScriptFnDef C4ScriptFnMap[];

View File

@ -388,13 +388,13 @@ C4ChatControl::C4ChatControl(C4Network2IRCClient *pnIRCClient) : C4GUI::Window()
pEdtLoginChannel->SetText(Config.IRC.Channel, false); pEdtLoginChannel->SetText(Config.IRC.Channel, false);
// initial sheets // initial sheets
ClearChatSheets(); ClearChatSheets();
// set IRC event callback // set IRC event callback
Application.InteractiveThread.SetCallback(Ev_IRC_Message, this); Application.InteractiveThread.SetCallback(Ev_IRC_Message, this);
} }
C4ChatControl::~C4ChatControl() C4ChatControl::~C4ChatControl()
{ {
Application.InteractiveThread.ClearCallback(Ev_IRC_Message, this); Application.InteractiveThread.ClearCallback(Ev_IRC_Message, this);
delete pTitleChangeBC; delete pTitleChangeBC;
} }
@ -540,16 +540,16 @@ void C4ChatControl::OnConnectBtn(C4GUI::Control *btn)
sWarnMsg.Format(LoadResStr("IDS_MSG_YOUAREABOUTTOCONNECTTOAPU"), sServer.getData()); sWarnMsg.Format(LoadResStr("IDS_MSG_YOUAREABOUTTOCONNECTTOAPU"), sServer.getData());
if (!GetScreen()->ShowMessageModal(sWarnMsg.getData(), LoadResStr("IDS_MSG_CHATDISCLAIMER"), C4GUI::MessageDialog::btnOKAbort, C4GUI::Ico_Notify, &Config.Startup.HideMsgIRCDangerous)) if (!GetScreen()->ShowMessageModal(sWarnMsg.getData(), LoadResStr("IDS_MSG_CHATDISCLAIMER"), C4GUI::MessageDialog::btnOKAbort, C4GUI::Ico_Notify, &Config.Startup.HideMsgIRCDangerous))
return; return;
// set up IRC callback // set up IRC callback
pIRCClient->SetNotify(&Application.InteractiveThread); pIRCClient->SetNotify(&Application.InteractiveThread);
// initiate connection // initiate connection
if (!pIRCClient->Connect(sServer.getData(), sNick.getData(), sRealName.getData(), sPass.getData(), sChannel.getData())) if (!pIRCClient->Connect(sServer.getData(), sNick.getData(), sRealName.getData(), sPass.getData(), sChannel.getData()))
{ {
GetScreen()->ShowErrorMessage(FormatString(LoadResStr("IDS_ERR_IRCCONNECTIONFAILED"), pIRCClient->GetError()).getData()); GetScreen()->ShowErrorMessage(FormatString(LoadResStr("IDS_ERR_IRCCONNECTIONFAILED"), pIRCClient->GetError()).getData());
return; return;
} }
// enable client execution // enable client execution
Application.InteractiveThread.AddProc(pIRCClient); Application.InteractiveThread.AddProc(pIRCClient);
// reset chat sheets (close queries, etc.) // reset chat sheets (close queries, etc.)
ClearChatSheets(); ClearChatSheets();
// connection message // connection message
@ -619,8 +619,8 @@ void C4ChatControl::Update()
--i; --i;
} }
} }
// retrieve messages: All messages in initial update; only unread in subsequent calls // retrieve messages: All messages in initial update; only unread in subsequent calls
C4Network2IRCMessage *pMsg; C4Network2IRCMessage *pMsg;
if (fInitialMessagesReceived) if (fInitialMessagesReceived)
{ {
pMsg = pIRCClient->getUnreadMessageLog(); pMsg = pIRCClient->getUnreadMessageLog();
@ -668,7 +668,7 @@ void C4ChatControl::Update()
pChatSheet = GetServerSheet(); pChatSheet = GetServerSheet();
} }
else if (sUser == pIRCClient->getUserName()) else if (sUser == pIRCClient->getUserName())
{ {
// private message by myself // private message by myself
// message to a service into service window; otherwise (new) query // message to a service into service window; otherwise (new) query
if (IsServiceName(pMsg->getTarget())) if (IsServiceName(pMsg->getTarget()))
@ -681,8 +681,8 @@ void C4ChatControl::Update()
pChatSheet = OpenQuery(pMsg->getTarget(), true, NULL); pChatSheet = OpenQuery(pMsg->getTarget(), true, NULL);
if (pChatSheet) pChatSheet->SetChatTitle(pMsg->getTarget()); if (pChatSheet) pChatSheet->SetChatTitle(pMsg->getTarget());
} }
} }
else else
{ {
// private message // private message
pChatSheet = OpenQuery(sUser.getData(), false, sIdent.getData()); pChatSheet = OpenQuery(sUser.getData(), false, sIdent.getData());
@ -706,9 +706,9 @@ void C4ChatControl::Update()
case MSG_Notice: case MSG_Notice:
if (sUser.getLength()) if (sUser.getLength())
if (sUser != pIRCClient->getUserName()) if (sUser != pIRCClient->getUserName())
sMsg.Format("-%s- %s", sUser.getData(), pMsg->getData()); sMsg.Format("-%s- %s", sUser.getData(), pMsg->getData());
else else
sMsg.Format("-> -%s- %s", pMsg->getTarget(), pMsg->getData()); sMsg.Format("-> -%s- %s", pMsg->getTarget(), pMsg->getData());
else else
sMsg.Format("* %s", pMsg->getData()); sMsg.Format("* %s", pMsg->getData());
@ -905,8 +905,8 @@ bool C4ChatControl::ProcessInput(const char *szInput, ChatSheet *pChatSheet)
{ {
if (C4InVal::ValidateString(sParam, C4InVal::VAL_IRCName)) if (C4InVal::ValidateString(sParam, C4InVal::VAL_IRCName))
pChatSheet->DoError(FormatString(LoadResStr("IDS_ERR_INVALIDNICKNAME2"), sCommand.getData()).getData()); pChatSheet->DoError(FormatString(LoadResStr("IDS_ERR_INVALIDNICKNAME2"), sCommand.getData()).getData());
else else
fIRCSuccess = pIRCClient->ChangeNick(sParam.getData()); fIRCSuccess = pIRCClient->ChangeNick(sParam.getData());
} }
else else
{ {
@ -926,9 +926,9 @@ bool C4ChatControl::ProcessInput(const char *szInput, ChatSheet *pChatSheet)
else else
{ {
szMsgTarget = pChatSheet->GetTitle(); szMsgTarget = pChatSheet->GetTitle();
if (*szInput == '/') // action if (*szInput == '/') // action
fIRCSuccess = pIRCClient->Action(szMsgTarget, szInput+4); fIRCSuccess = pIRCClient->Action(szMsgTarget, szInput+4);
else else
fIRCSuccess = pIRCClient->Message(szMsgTarget, szInput); fIRCSuccess = pIRCClient->Message(szMsgTarget, szInput);
} }
} }
@ -1016,7 +1016,7 @@ bool C4ChatDlg::IsChatActive()
// not if chat is disabled // not if chat is disabled
if (!IsChatEnabled()) return false; if (!IsChatEnabled()) return false;
// check whether IRC is connected // check whether IRC is connected
return Application.IRCClient.IsActive(); return Application.IRCClient.IsActive();
} }
bool C4ChatDlg::IsChatEnabled() bool C4ChatDlg::IsChatEnabled()

View File

@ -117,7 +117,7 @@ class C4ChatControl : public C4GUI::Window, private C4InteractiveThread::Callbac
StdStrBuf sTitle; StdStrBuf sTitle;
C4GUI::BaseInputCallback *pTitleChangeBC; C4GUI::BaseInputCallback *pTitleChangeBC;
C4Network2IRCClient *pIRCClient; C4Network2IRCClient *pIRCClient;
bool fInitialMessagesReceived; // set after initial update call, which fetches all messages. Subsequent calls fetch only unread messages bool fInitialMessagesReceived; // set after initial update call, which fetches all messages. Subsequent calls fetch only unread messages
public: public:
@ -131,7 +131,7 @@ class C4ChatControl : public C4GUI::Window, private C4InteractiveThread::Callbac
public: public:
virtual class C4GUI::Control *GetDefaultControl(); virtual class C4GUI::Control *GetDefaultControl();
C4Network2IRCClient *getIRCClient() { return pIRCClient; } C4Network2IRCClient *getIRCClient() { return pIRCClient; }
void SetTitleChangeCB(C4GUI::BaseInputCallback *pNewCB); void SetTitleChangeCB(C4GUI::BaseInputCallback *pNewCB);
virtual void OnShown(); // callback when shown virtual void OnShown(); // callback when shown
@ -153,8 +153,8 @@ class C4ChatControl : public C4GUI::Window, private C4InteractiveThread::Callbac
ChatSheet *GetServerSheet(); ChatSheet *GetServerSheet();
void ClearChatSheets(); void ClearChatSheets();
// IRC event hook // IRC event hook
virtual void OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData) { if(pEventData == pIRCClient) Update(); } virtual void OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData) { if(pEventData == pIRCClient) Update(); }
}; };

View File

@ -89,7 +89,7 @@ void C4DownloadDlg::SetStatus(const char *szNewText, int32_t iProgressPercent)
} }
void C4DownloadDlg::OnIdle() void C4DownloadDlg::OnIdle()
{ {
// continue query process // continue query process
if (!HTTPClient.Execute()) if (!HTTPClient.Execute())
{ {
@ -138,7 +138,7 @@ void C4DownloadDlg::OnIdle()
} }
void C4DownloadDlg::UserClose(bool fOK) void C4DownloadDlg::UserClose(bool fOK)
{ {
// user cancelled // user cancelled
HTTPClient.Cancel(LoadResStr("IDS_ERR_USERCANCEL")); HTTPClient.Cancel(LoadResStr("IDS_ERR_USERCANCEL"));
} }

View File

@ -26,7 +26,7 @@
// dialog to download a file // dialog to download a file
class C4DownloadDlg : public C4GUI::Dialog class C4DownloadDlg : public C4GUI::Dialog
{ {
private: private:
C4Network2HTTPClient HTTPClient; C4Network2HTTPClient HTTPClient;

View File

@ -30,31 +30,31 @@
//================= C4FolderHead ==================== //================= C4FolderHead ====================
void C4FolderHead::Default() void C4FolderHead::Default()
{ {
Index = 0; Index = 0;
Sort[0] = 0; Sort[0] = 0;
} }
void C4FolderHead::CompileFunc(StdCompiler *pComp) void C4FolderHead::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(Index, "Index", 0)); pComp->Value(mkNamingAdapt(Index, "Index", 0));
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Sort), "Sort", "")); pComp->Value(mkNamingAdapt(mkStringAdaptMA(Sort), "Sort", ""));
} }
//=================== C4Folder ====================== //=================== C4Folder ======================
C4Folder::C4Folder() C4Folder::C4Folder()
{ {
Default(); Default();
} }
void C4Folder::Default() void C4Folder::Default()
{ {
Head.Default(); Head.Default();
} }
bool C4Folder::Load(C4Group &hGroup) bool C4Folder::Load(C4Group &hGroup)
{ {
char *pSource; char *pSource;
// Load // Load
if (!hGroup.LoadEntry(C4CFN_FolderCore, &pSource, NULL, 1)) return false; if (!hGroup.LoadEntry(C4CFN_FolderCore, &pSource, NULL, 1)) return false;
@ -63,7 +63,7 @@ bool C4Folder::Load(C4Group &hGroup)
delete [] pSource; delete [] pSource;
// Success // Success
return true; return true;
} }
/*bool C4Folder::Save(C4Group &hGroup) /*bool C4Folder::Save(C4Group &hGroup)
{ {
@ -76,13 +76,13 @@ bool C4Folder::Load(C4Group &hGroup)
}*/ }*/
void C4Folder::CompileFunc(StdCompiler *pComp) void C4Folder::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(Head, "Head")); pComp->Value(mkNamingAdapt(Head, "Head"));
} }
bool C4Folder::Compile(const char *szSource) bool C4Folder::Compile(const char *szSource)
{ {
Default(); Default();
return CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, StdStrBuf(szSource), C4CFN_FolderCore); return CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, StdStrBuf(szSource), C4CFN_FolderCore);
} }

View File

@ -27,30 +27,30 @@ class C4Group;
const int C4MaxFolderSort = 4096; const int C4MaxFolderSort = 4096;
class C4FolderHead class C4FolderHead
{ {
public: public:
int32_t Index; // Folder index in scenario selection dialog int32_t Index; // Folder index in scenario selection dialog
char Sort[C4MaxFolderSort + 1]; // Folder-defined group sort list (to be used for folder maps) char Sort[C4MaxFolderSort + 1]; // Folder-defined group sort list (to be used for folder maps)
public: public:
void Default(); void Default();
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
}; };
class C4Folder class C4Folder
{ {
public: public:
C4Folder(); C4Folder();
public: public:
C4FolderHead Head; C4FolderHead Head;
public: public:
void Default(); void Default();
//void Clear(); //void Clear();
bool Load(C4Group &hGroup); bool Load(C4Group &hGroup);
//bool Save(C4Group &hGroup); //bool Save(C4Group &hGroup);
void CompileFunc(StdCompiler *pComp); void CompileFunc(StdCompiler *pComp);
protected: protected:
bool Compile(const char *szSource); bool Compile(const char *szSource);
//bool Decompile(char **ppOutput, int32_t *ipSize); //bool Decompile(char **ppOutput, int32_t *ipSize);
}; };
#endif // INC_C4Folder #endif // INC_C4Folder

View File

@ -41,7 +41,7 @@ C4AbortGameDialog::C4AbortGameDialog()
MessageDialog::btnYesNo, MessageDialog::btnYesNo,
true, true,
C4GUI::Ico_Exit), C4GUI::Ico_Exit),
fGameHalted(false) fGameHalted(false)
{ {
is_shown = true; // assume dlg will be shown, soon is_shown = true; // assume dlg will be shown, soon
} }

View File

@ -43,7 +43,7 @@ namespace C4GameLobby {
void C4PacketCountdown::CompileFunc(StdCompiler *pComp) void C4PacketCountdown::CompileFunc(StdCompiler *pComp)
{ {
pComp->Value(mkNamingAdapt(iCountdown, "Countdown", 0)); pComp->Value(mkNamingAdapt(iCountdown, "Countdown", 0));
} }
StdStrBuf C4PacketCountdown::GetCountdownMsg(bool fInitialMsg) const StdStrBuf C4PacketCountdown::GetCountdownMsg(bool fInitialMsg) const
@ -64,7 +64,7 @@ ScenDesc::ScenDesc(const C4Rect &rcBounds, bool fActive) : C4GUI::Window(), fDes
C4GUI::ComponentAligner caMain(GetClientRect(), 0,0, true); C4GUI::ComponentAligner caMain(GetClientRect(), 0,0, true);
//AddElement(pTitle = new C4GUI::Label("", caMain.GetFromTop(rTitleFont.GetLineHeight()), ALeft, C4GUI_CaptionFontClr, &rTitleFont, true)); //AddElement(pTitle = new C4GUI::Label("", caMain.GetFromTop(rTitleFont.GetLineHeight()), ALeft, C4GUI_CaptionFontClr, &rTitleFont, true));
AddElement(pDescBox = new C4GUI::TextWindow(caMain.GetAll(), 0, 0, 0, 100, 4096, "", true)); AddElement(pDescBox = new C4GUI::TextWindow(caMain.GetAll(), 0, 0, 0, 100, 4096, "", true));
pDescBox->SetDecoration(false, false, NULL, true); pDescBox->SetDecoration(false, false, NULL, true);
//pDescBox->SetToolTip(LoadResStr("IDS_MSG_SCENARIODESC")); annoying when scrolling through desc... //pDescBox->SetToolTip(LoadResStr("IDS_MSG_SCENARIODESC")); annoying when scrolling through desc...
// initial update to set current data // initial update to set current data
if (fActive) Activate(); if (fActive) Activate();
@ -109,7 +109,7 @@ void ScenDesc::Update()
else else
{ {
pDescBox->AddTextLine(FormatString(LoadResStr("IDS_MSG_SCENARIODESC_LOADING"), (int) pRes->getPresentPercent()).getData(), pDescBox->AddTextLine(FormatString(LoadResStr("IDS_MSG_SCENARIODESC_LOADING"), (int) pRes->getPresentPercent()).getData(),
&rTextFont, C4GUI_MessageFontClr, false, true); &rTextFont, C4GUI_MessageFontClr, false, true);
} }
pDescBox->UpdateHeight(); pDescBox->UpdateHeight();
} }
@ -724,11 +724,11 @@ C4GUI::ContextMenu *MainDlg::OnRightTabContext(C4GUI::Element *pLabel, int32_t i
pMenu->AddItem(pPlayerSheet->GetTitle(), pPlayerSheet->GetToolTip(), C4GUI::Ico_Player, pMenu->AddItem(pPlayerSheet->GetTitle(), pPlayerSheet->GetToolTip(), C4GUI::Ico_Player,
new C4GUI::CBMenuHandler<MainDlg>(this, &MainDlg::OnCtxTabPlayers)); new C4GUI::CBMenuHandler<MainDlg>(this, &MainDlg::OnCtxTabPlayers));
if (Game.Teams.IsMultiTeams()) if (Game.Teams.IsMultiTeams())
{ {
StdCopyStrBuf strShowTeamsDesc(LoadResStr("IDS_MSG_SHOWTEAMS_DESC")); StdCopyStrBuf strShowTeamsDesc(LoadResStr("IDS_MSG_SHOWTEAMS_DESC"));
pMenu->AddItem(LoadResStr("IDS_MSG_SHOWTEAMS"), strShowTeamsDesc.getData(), C4GUI::Ico_Team, pMenu->AddItem(LoadResStr("IDS_MSG_SHOWTEAMS"), strShowTeamsDesc.getData(), C4GUI::Ico_Team,
new C4GUI::CBMenuHandler<MainDlg>(this, &MainDlg::OnCtxTabTeams)); new C4GUI::CBMenuHandler<MainDlg>(this, &MainDlg::OnCtxTabTeams));
} }
pMenu->AddItem(pResSheet->GetTitle(), pResSheet->GetToolTip(), C4GUI::Ico_Resource, pMenu->AddItem(pResSheet->GetTitle(), pResSheet->GetToolTip(), C4GUI::Ico_Resource,
new C4GUI::CBMenuHandler<MainDlg>(this, &MainDlg::OnCtxTabRes)); new C4GUI::CBMenuHandler<MainDlg>(this, &MainDlg::OnCtxTabRes));
pMenu->AddItem(pOptionsSheet->GetTitle(), pOptionsSheet->GetToolTip(), C4GUI::Ico_Options, pMenu->AddItem(pOptionsSheet->GetTitle(), pOptionsSheet->GetToolTip(), C4GUI::Ico_Options,

Some files were not shown because too many files have changed in this diff Show More