forked from Mirrors/openclonk
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.
parent
b8d2f39fbd
commit
b4e37b070b
|
@ -83,7 +83,7 @@ bool C4Application::DoInit()
|
|||
assert(AppState == C4AS_None);
|
||||
// Config overwrite by parameter
|
||||
StdStrBuf sConfigFilename;
|
||||
char szParameter[_MAX_PATH+1];
|
||||
char szParameter[_MAX_PATH+1];
|
||||
for (int32_t iPar=0; SGetParameter(GetCommandLine(), iPar, szParameter, _MAX_PATH); iPar++)
|
||||
if (SEqual2NoCase(szParameter, "/config:"))
|
||||
sConfigFilename.Copy(szParameter + 8);
|
||||
|
@ -499,19 +499,19 @@ void C4Application::Activate()
|
|||
// 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
|
||||
// not in the foreground itself), we are using an ugly OS hack.
|
||||
DWORD nForeThread = GetWindowThreadProcessId(GetForegroundWindow(), 0);
|
||||
DWORD nAppThread = GetCurrentThreadId();
|
||||
DWORD nForeThread = GetWindowThreadProcessId(GetForegroundWindow(), 0);
|
||||
DWORD nAppThread = GetCurrentThreadId();
|
||||
if (nForeThread != nAppThread)
|
||||
{
|
||||
AttachThreadInput(nForeThread, nAppThread, true);
|
||||
BringWindowToTop(FullScreen.hWindow);
|
||||
ShowWindow(FullScreen.hWindow, SW_SHOW);
|
||||
AttachThreadInput(nForeThread, nAppThread, false);
|
||||
AttachThreadInput(nForeThread, nAppThread, true);
|
||||
BringWindowToTop(FullScreen.hWindow);
|
||||
ShowWindow(FullScreen.hWindow, SW_SHOW);
|
||||
AttachThreadInput(nForeThread, nAppThread, false);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
BringWindowToTop(FullScreen.hWindow);
|
||||
ShowWindow(FullScreen.hWindow, SW_SHOW);
|
||||
BringWindowToTop(FullScreen.hWindow);
|
||||
ShowWindow(FullScreen.hWindow, SW_SHOW);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ void C4FullScreen::HandleMessage (XEvent &e)
|
|||
::GraphicsSystem.MouseMove(C4MC_Button_RightUp, e.xbutton.x, e.xbutton.y, e.xbutton.state, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MotionNotify:
|
||||
|
@ -257,75 +257,75 @@ void C4FullScreen::HandleMessage (XEvent &e)
|
|||
|
||||
namespace
|
||||
{
|
||||
void sdlToC4MCBtn(const SDL_MouseButtonEvent &e,
|
||||
int32_t& button, DWORD& flags)
|
||||
{
|
||||
static int lastLeftClick = 0, lastRightClick = 0;
|
||||
void sdlToC4MCBtn(const SDL_MouseButtonEvent &e,
|
||||
int32_t& button, DWORD& flags)
|
||||
{
|
||||
static int lastLeftClick = 0, lastRightClick = 0;
|
||||
static int lastX = 0, lastY = 0;
|
||||
static const int clickDist = 2;
|
||||
|
||||
button = C4MC_Button_None;
|
||||
flags = 0;
|
||||
button = C4MC_Button_None;
|
||||
flags = 0;
|
||||
|
||||
switch (e.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
if (e.state == SDL_PRESSED)
|
||||
if (timeGetTime() - lastLeftClick < 400 && abs(lastX-e.x) <= clickDist && abs(lastY-e.y) <= clickDist)
|
||||
{
|
||||
lastLeftClick = 0;
|
||||
button = C4MC_Button_LeftDouble;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastLeftClick = timeGetTime();
|
||||
button = C4MC_Button_LeftDown;
|
||||
}
|
||||
else
|
||||
button = C4MC_Button_LeftUp;
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
if (e.state == SDL_PRESSED)
|
||||
if (timeGetTime() - lastRightClick < 400)
|
||||
{
|
||||
lastRightClick = 0;
|
||||
button = C4MC_Button_RightDouble;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastRightClick = timeGetTime();
|
||||
button = C4MC_Button_RightDown;
|
||||
}
|
||||
else
|
||||
button = C4MC_Button_RightUp;
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
if (e.state == SDL_PRESSED)
|
||||
button = C4MC_Button_MiddleDown;
|
||||
else
|
||||
button = C4MC_Button_MiddleUp;
|
||||
break;
|
||||
case SDL_BUTTON_WHEELUP:
|
||||
button = C4MC_Button_Wheel;
|
||||
flags = (+32) << 16;
|
||||
break;
|
||||
case SDL_BUTTON_WHEELDOWN:
|
||||
button = C4MC_Button_Wheel;
|
||||
flags = (-32) << 16;
|
||||
break;
|
||||
}
|
||||
lastX = e.x;
|
||||
lastY = e.y;
|
||||
}
|
||||
switch (e.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
if (e.state == SDL_PRESSED)
|
||||
if (timeGetTime() - lastLeftClick < 400 && abs(lastX-e.x) <= clickDist && abs(lastY-e.y) <= clickDist)
|
||||
{
|
||||
lastLeftClick = 0;
|
||||
button = C4MC_Button_LeftDouble;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastLeftClick = timeGetTime();
|
||||
button = C4MC_Button_LeftDown;
|
||||
}
|
||||
else
|
||||
button = C4MC_Button_LeftUp;
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
if (e.state == SDL_PRESSED)
|
||||
if (timeGetTime() - lastRightClick < 400)
|
||||
{
|
||||
lastRightClick = 0;
|
||||
button = C4MC_Button_RightDouble;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastRightClick = timeGetTime();
|
||||
button = C4MC_Button_RightDown;
|
||||
}
|
||||
else
|
||||
button = C4MC_Button_RightUp;
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
if (e.state == SDL_PRESSED)
|
||||
button = C4MC_Button_MiddleDown;
|
||||
else
|
||||
button = C4MC_Button_MiddleUp;
|
||||
break;
|
||||
case SDL_BUTTON_WHEELUP:
|
||||
button = C4MC_Button_Wheel;
|
||||
flags = (+32) << 16;
|
||||
break;
|
||||
case SDL_BUTTON_WHEELDOWN:
|
||||
button = C4MC_Button_Wheel;
|
||||
flags = (-32) << 16;
|
||||
break;
|
||||
}
|
||||
lastX = e.x;
|
||||
lastY = e.y;
|
||||
}
|
||||
|
||||
bool isSpecialKey(unsigned unicode)
|
||||
{
|
||||
if (unicode >= 0xe00)
|
||||
return true;
|
||||
if (unicode < 32 || unicode == 127)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
bool isSpecialKey(unsigned unicode)
|
||||
{
|
||||
if (unicode >= 0xe00)
|
||||
return true;
|
||||
if (unicode < 32 || unicode == 127)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#include "StdGL.h"
|
||||
|
@ -336,18 +336,18 @@ void C4FullScreen::HandleMessage (SDL_Event &e)
|
|||
{
|
||||
case SDL_KEYDOWN:
|
||||
{
|
||||
#ifdef USE_GL
|
||||
if (e.key.keysym.sym == SDLK_f && (e.key.keysym.mod & (KMOD_LMETA | KMOD_RMETA)))
|
||||
{
|
||||
Config.Graphics.Windowed = !Config.Graphics.Windowed;
|
||||
if (pGL) pGL->fFullscreen = !Config.Graphics.Windowed;
|
||||
#ifdef USE_GL
|
||||
if (e.key.keysym.sym == SDLK_f && (e.key.keysym.mod & (KMOD_LMETA | KMOD_RMETA)))
|
||||
{
|
||||
Config.Graphics.Windowed = !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);
|
||||
lpDDraw->InvalidateDeviceObjects();
|
||||
lpDDraw->RestoreDeviceObjects();
|
||||
lpDDraw->InvalidateDeviceObjects();
|
||||
lpDDraw->RestoreDeviceObjects();
|
||||
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Only forward real characters to UI. (Nothing outside of "private use" range.)
|
||||
// This works without iconv for some reason. Yay!
|
||||
|
@ -417,7 +417,7 @@ void C4FullScreen::Execute()
|
|||
{
|
||||
// Execute menu
|
||||
if (pMenu) pMenu->Execute();
|
||||
// Draw
|
||||
// Draw
|
||||
::GraphicsSystem.Execute();
|
||||
}
|
||||
|
||||
|
|
750
src/C4Game.cpp
750
src/C4Game.cpp
File diff suppressed because it is too large
Load Diff
46
src/C4Game.h
46
src/C4Game.h
|
@ -169,7 +169,7 @@ class C4Game
|
|||
bool Init();
|
||||
bool PreInit();
|
||||
void ParseCommandLine(const char *szCmdLine);
|
||||
bool Execute();
|
||||
bool Execute();
|
||||
class C4Player *JoinPlayer(const char *szFilename, int32_t iAtClient, const char *szAtClientName, C4PlayerInfo *pInfo);
|
||||
bool DoGameOver();
|
||||
bool CanQuickSave();
|
||||
|
@ -197,18 +197,18 @@ class C4Game
|
|||
bool ReloadDef(C4ID id);
|
||||
bool ReloadParticle(const char *szName);
|
||||
// Object functions
|
||||
void ClearPointers(C4PropList *cobj);
|
||||
C4Object *CreateObject(C4PropList * type, C4Object *pCreator, int32_t owner=NO_OWNER,
|
||||
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);
|
||||
void ClearPointers(C4PropList *cobj);
|
||||
C4Object *CreateObject(C4PropList * type, C4Object *pCreator, int32_t owner=NO_OWNER,
|
||||
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);
|
||||
C4Object *CreateObject(C4ID type, C4Object *pCreator, int32_t owner=NO_OWNER,
|
||||
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);
|
||||
C4Object *CreateObjectConstruction(C4PropList * type,
|
||||
C4Object *CreateObjectConstruction(C4PropList * type,
|
||||
C4Object *pCreator,
|
||||
int32_t owner,
|
||||
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,
|
||||
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);
|
||||
|
@ -228,7 +228,7 @@ class C4Game
|
|||
float iX, float iY,
|
||||
DWORD category,
|
||||
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,
|
||||
DWORD ocf=OCF_All,
|
||||
const char *szAction=NULL, C4Object *pActionTarget=NULL,
|
||||
|
@ -262,9 +262,9 @@ class C4Game
|
|||
void InitValueOverloads();
|
||||
void InitEnvironment();
|
||||
void UpdateRules();
|
||||
void CloseScenario();
|
||||
void DeleteObjects(bool fDeleteInactive);
|
||||
void ExecObjects();
|
||||
void CloseScenario();
|
||||
void DeleteObjects(bool fDeleteInactive);
|
||||
void ExecObjects();
|
||||
void Ticks();
|
||||
const char *FoldersWithLocalsDefs(const char *szPath);
|
||||
bool CheckObjectEnumeration();
|
||||
|
@ -287,9 +287,9 @@ class C4Game
|
|||
bool LinkScriptEngine();
|
||||
bool InitPlayers();
|
||||
bool InitRecord();
|
||||
bool OpenScenario();
|
||||
bool InitDefs();
|
||||
bool InitMaterialTexture();
|
||||
bool OpenScenario();
|
||||
bool InitDefs();
|
||||
bool InitMaterialTexture();
|
||||
bool GameOverCheck();
|
||||
bool PlaceInEarth(C4ID id);
|
||||
bool Compile(const char *szSource);
|
||||
|
@ -302,14 +302,14 @@ class C4Game
|
|||
bool StoreParticipantPlayers();
|
||||
bool RecreatePlayerFiles();
|
||||
|
||||
// Object function internals
|
||||
C4Object *NewObject( C4PropList *ndef, C4Object *pCreator,
|
||||
int32_t owner, C4ObjectInfo *info,
|
||||
int32_t tx, int32_t ty, int32_t tr,
|
||||
FIXED xdir, FIXED ydir, FIXED rdir,
|
||||
int32_t con, int32_t iController);
|
||||
void ClearObjectPtrs(C4Object *tptr);
|
||||
void ObjectRemovalCheck();
|
||||
// Object function internals
|
||||
C4Object *NewObject( C4PropList *ndef, C4Object *pCreator,
|
||||
int32_t owner, C4ObjectInfo *info,
|
||||
int32_t tx, int32_t ty, int32_t tr,
|
||||
FIXED xdir, FIXED ydir, FIXED rdir,
|
||||
int32_t con, int32_t iController);
|
||||
void ClearObjectPtrs(C4Object *tptr);
|
||||
void ObjectRemovalCheck();
|
||||
|
||||
bool ToggleDebugMode(); // dbg modeon/off if allowed
|
||||
bool ActivateMenu(const char *szCommand); // exec given menu command for first local player
|
||||
|
@ -317,7 +317,7 @@ class C4Game
|
|||
public:
|
||||
bool ToggleChart(); // chart dlg on/off
|
||||
void SetMusicLevel(int32_t iToLvl); // change game music volume; multiplied by config volume for real volume
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
const int32_t C4RULE_StructuresNeedEnergy = 1,
|
||||
|
|
|
@ -804,12 +804,12 @@ int32_t C4GraphicsSystem::GetAudibility(int32_t iX, int32_t iY, int32_t *iPan, i
|
|||
// Accumulate audibility by viewports
|
||||
int32_t iAudible=0; *iPan = 0;
|
||||
for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
|
||||
{
|
||||
{
|
||||
iAudible = Max( iAudible,
|
||||
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 = BoundBy<int32_t>(*iPan, -100, 100);
|
||||
*iPan += (iX-(cvp->ViewX+cvp->ViewWdt/2)) / 5;
|
||||
}
|
||||
*iPan = BoundBy<int32_t>(*iPan, -100, 100);
|
||||
return iAudible;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@
|
|||
|
||||
// Build Options
|
||||
#ifdef _DEBUG
|
||||
#define C4BUILDDEBUG " dbg"
|
||||
#define C4BUILDDEBUG " dbg"
|
||||
#else
|
||||
#define C4BUILDDEBUG
|
||||
#define C4BUILDDEBUG
|
||||
#endif
|
||||
|
||||
#define C4BUILDOPT C4BUILDDEBUG
|
||||
|
|
|
@ -59,9 +59,9 @@ int GenerateDump(EXCEPTION_POINTERS* pExceptionPointers)
|
|||
|
||||
// Write dump
|
||||
MINIDUMP_EXCEPTION_INFORMATION ExpParam;
|
||||
ExpParam.ThreadId = GetCurrentThreadId();
|
||||
ExpParam.ExceptionPointers = pExceptionPointers;
|
||||
ExpParam.ClientPointers = true;
|
||||
ExpParam.ThreadId = GetCurrentThreadId();
|
||||
ExpParam.ExceptionPointers = pExceptionPointers;
|
||||
ExpParam.ClientPointers = true;
|
||||
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),
|
||||
file, MiniDumpNormal, &ExpParam, NULL, NULL);
|
||||
|
||||
|
@ -76,12 +76,12 @@ int GenerateDump(EXCEPTION_POINTERS* pExceptionPointers)
|
|||
|
||||
int WINAPI WinMain (HINSTANCE hInst,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpszCmdParam,
|
||||
LPSTR lpszCmdParam,
|
||||
int nCmdShow)
|
||||
{
|
||||
#if defined(_DEBUG) && defined(_MSC_VER)
|
||||
// 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
|
||||
|
||||
#ifdef GENERATE_MINI_DUMP
|
||||
|
|
|
@ -201,8 +201,8 @@ bool C4ComponentHost::Load(const char *szName,
|
|||
}
|
||||
// Truncate any additional segments from stored filename
|
||||
SReplaceChar(Filename, '|', 0);
|
||||
// skip full path (unknown)
|
||||
FilePath[0] = 0;
|
||||
// skip full path (unknown)
|
||||
FilePath[0] = 0;
|
||||
// Not loaded
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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_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"\
|
||||
"|*.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"\
|
||||
"|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_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"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -61,7 +61,7 @@ extern int iC4GroupRewindFilePtrNoWarn;
|
|||
const int C4GroupFileVer1=1, C4GroupFileVer2=2;
|
||||
|
||||
const int C4GroupMaxMaker = 30,
|
||||
C4GroupMaxPassword = 30,
|
||||
C4GroupMaxPassword = 30,
|
||||
C4GroupMaxError = 100;
|
||||
|
||||
const int32_t C4GroupSwapThreshold = 10 * 1024 * 1024;
|
||||
|
@ -95,38 +95,38 @@ extern time_t C4Group_AssumeTimeOffset;
|
|||
#pragma pack (push, 1)
|
||||
|
||||
class C4GroupHeader
|
||||
{
|
||||
{
|
||||
public:
|
||||
C4GroupHeader();
|
||||
public:
|
||||
char id[24+4];
|
||||
int Ver1,Ver2;
|
||||
int Entries;
|
||||
char Maker[C4GroupMaxMaker+2];
|
||||
char Password[C4GroupMaxPassword+2];
|
||||
public:
|
||||
char id[24+4];
|
||||
int Ver1,Ver2;
|
||||
int Entries;
|
||||
char Maker[C4GroupMaxMaker+2];
|
||||
char Password[C4GroupMaxPassword+2];
|
||||
int Creation,Original;
|
||||
BYTE fbuf[92];
|
||||
public:
|
||||
void Init();
|
||||
};
|
||||
BYTE fbuf[92];
|
||||
public:
|
||||
void Init();
|
||||
};
|
||||
|
||||
const char C4GECS_None = 0,
|
||||
C4GECS_Old = 1,
|
||||
C4GECS_New = 2;
|
||||
|
||||
class C4GroupEntryCore
|
||||
{
|
||||
{
|
||||
public:
|
||||
C4GroupEntryCore();
|
||||
public:
|
||||
char FileName[260];
|
||||
int32_t Packed,ChildGroup;
|
||||
int32_t Size, __Unused, Offset;
|
||||
uint32_t Time;
|
||||
public:
|
||||
char FileName[260];
|
||||
int32_t Packed,ChildGroup;
|
||||
int32_t Size, __Unused, Offset;
|
||||
uint32_t Time;
|
||||
char HasCRC; unsigned int CRC;
|
||||
char Executable;
|
||||
BYTE fbuf[26];
|
||||
};
|
||||
BYTE fbuf[26];
|
||||
};
|
||||
|
||||
#pragma pack (pop)
|
||||
|
||||
|
@ -140,9 +140,9 @@ class C4GroupEntry: public C4GroupEntryCore
|
|||
public:
|
||||
C4GroupEntry();
|
||||
~C4GroupEntry();
|
||||
public:
|
||||
char DiskPath[_MAX_PATH + 1];
|
||||
int Status;
|
||||
public:
|
||||
char DiskPath[_MAX_PATH + 1];
|
||||
int Status;
|
||||
bool DeleteOnDisk;
|
||||
bool HoldBuffer;
|
||||
bool BufferIsStdbuf;
|
||||
|
@ -154,106 +154,106 @@ class C4GroupEntry: public C4GroupEntryCore
|
|||
};
|
||||
|
||||
const int GRPF_Inactive=0,
|
||||
GRPF_File=1,
|
||||
GRPF_Folder=2;
|
||||
GRPF_File=1,
|
||||
GRPF_Folder=2;
|
||||
|
||||
class C4Group: public CStdStream
|
||||
{
|
||||
public:
|
||||
C4Group();
|
||||
~C4Group();
|
||||
{
|
||||
public:
|
||||
C4Group();
|
||||
~C4Group();
|
||||
|
||||
protected:
|
||||
int Status;
|
||||
char FileName[_MAX_PATH+1];
|
||||
// Parent status
|
||||
C4Group *Mother;
|
||||
bool ExclusiveChild;
|
||||
// File & Folder
|
||||
C4GroupEntry *SearchPtr;
|
||||
CStdFile StdFile;
|
||||
protected:
|
||||
int Status;
|
||||
char FileName[_MAX_PATH+1];
|
||||
// Parent status
|
||||
C4Group *Mother;
|
||||
bool ExclusiveChild;
|
||||
// File & Folder
|
||||
C4GroupEntry *SearchPtr;
|
||||
CStdFile StdFile;
|
||||
size_t iCurrFileSize; // size of last accessed file
|
||||
// File only
|
||||
int FilePtr;
|
||||
int MotherOffset;
|
||||
int EntryOffset;
|
||||
bool Modified;
|
||||
C4GroupHeader Head;
|
||||
C4GroupEntry *FirstEntry;
|
||||
// Folder only
|
||||
//struct _finddata_t Fdt;
|
||||
//long hFdt;
|
||||
// File only
|
||||
int FilePtr;
|
||||
int MotherOffset;
|
||||
int EntryOffset;
|
||||
bool Modified;
|
||||
C4GroupHeader Head;
|
||||
C4GroupEntry *FirstEntry;
|
||||
// Folder only
|
||||
//struct _finddata_t Fdt;
|
||||
//long hFdt;
|
||||
DirectoryIterator FolderSearch;
|
||||
C4GroupEntry FolderSearchEntry;
|
||||
C4GroupEntry LastFolderSearchEntry;
|
||||
C4GroupEntry FolderSearchEntry;
|
||||
C4GroupEntry LastFolderSearchEntry;
|
||||
|
||||
bool StdOutput;
|
||||
bool StdOutput;
|
||||
bool (*fnProcessCallback)(const char *, int);
|
||||
char ErrorString[C4GroupMaxError+1];
|
||||
char ErrorString[C4GroupMaxError+1];
|
||||
bool MadeOriginal;
|
||||
|
||||
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 Close();
|
||||
bool Open(const char *szGroupName, bool fCreate=false);
|
||||
bool Close();
|
||||
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 OpenMother();
|
||||
bool Add(const char *szFiles);
|
||||
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 *szFiles);
|
||||
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, 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 *szEntryname, C4Group &hSource);
|
||||
bool Merge(const char *szFolders);
|
||||
bool Move(const char *szFiles);
|
||||
bool Move(const char *szFile, const char *szAddAs);
|
||||
bool Extract(const char *szFiles, const char *szExtractTo=NULL, const char *szExclude=NULL);
|
||||
bool ExtractEntry(const char *szFilename, const char *szExtractTo=NULL);
|
||||
bool Delete(const char *szFiles, bool fRecursive = false);
|
||||
bool DeleteEntry(const char *szFilename, bool fRecycle=false);
|
||||
bool Rename(const char *szFile, const char *szNewName);
|
||||
bool Sort(const char *szSortList);
|
||||
bool Merge(const char *szFolders);
|
||||
bool Move(const char *szFiles);
|
||||
bool Move(const char *szFile, const char *szAddAs);
|
||||
bool Extract(const char *szFiles, const char *szExtractTo=NULL, const char *szExclude=NULL);
|
||||
bool ExtractEntry(const char *szFilename, const char *szExtractTo=NULL);
|
||||
bool Delete(const char *szFiles, bool fRecursive = false);
|
||||
bool DeleteEntry(const char *szFilename, bool fRecycle=false);
|
||||
bool Rename(const char *szFile, const char *szNewName);
|
||||
bool Sort(const char *szSortList);
|
||||
bool SortByList(const char **ppSortList, const char *szFilename=NULL);
|
||||
bool View(const char *szFiles);
|
||||
bool View(const char *szFiles);
|
||||
bool GetOriginal();
|
||||
bool AccessEntry(const char *szWildCard,
|
||||
size_t *iSize=NULL, char *sFileName=NULL,
|
||||
bool AccessEntry(const char *szWildCard,
|
||||
size_t *iSize=NULL, char *sFileName=NULL,
|
||||
bool *fChild=NULL, bool NeedsToBeAGroup = false);
|
||||
bool AccessNextEntry(const char *szWildCard,
|
||||
size_t *iSize=NULL, char *sFileName=NULL,
|
||||
bool AccessNextEntry(const char *szWildCard,
|
||||
size_t *iSize=NULL, char *sFileName=NULL,
|
||||
bool *fChild=NULL);
|
||||
bool LoadEntry(const char *szEntryName, char **lpbpBuf,
|
||||
size_t *ipSize=NULL, int iAppendZeros=0);
|
||||
bool LoadEntry(const char *szEntryName, StdBuf &Buf);
|
||||
bool LoadEntryString(const char *szEntryName, StdStrBuf &Buf);
|
||||
bool FindEntry(const char *szWildCard,
|
||||
char *sFileName=NULL,
|
||||
bool LoadEntry(const char *szEntryName, char **lpbpBuf,
|
||||
size_t *ipSize=NULL, int iAppendZeros=0);
|
||||
bool LoadEntry(const char *szEntryName, StdBuf &Buf);
|
||||
bool LoadEntryString(const char *szEntryName, StdStrBuf &Buf);
|
||||
bool FindEntry(const char *szWildCard,
|
||||
char *sFileName=NULL,
|
||||
size_t *iSize=NULL,
|
||||
bool *fChild=NULL);
|
||||
bool FindNextEntry(const char *szWildCard,
|
||||
char *sFileName=NULL,
|
||||
bool FindNextEntry(const char *szWildCard,
|
||||
char *sFileName=NULL,
|
||||
size_t *iSize=NULL,
|
||||
bool *fChild=NULL,
|
||||
bool fStartAtFilename=false);
|
||||
bool Read(void *pBuffer, size_t iSize);
|
||||
bool Read(void *pBuffer, size_t iSize);
|
||||
bool Advance(int iOffset);
|
||||
void SetMaker(const char *szMaker);
|
||||
void SetPassword(const char *szPassword);
|
||||
void SetStdOutput(bool fStatus);
|
||||
void SetProcessCallback(bool (*fnCallback)(const char *, int));
|
||||
void MakeOriginal(bool fOriginal);
|
||||
void ResetSearch();
|
||||
const char *GetError();
|
||||
const char *GetMaker();
|
||||
const char *GetPassword();
|
||||
const char *GetName();
|
||||
void ResetSearch();
|
||||
const char *GetError();
|
||||
const char *GetMaker();
|
||||
const char *GetPassword();
|
||||
const char *GetName();
|
||||
StdStrBuf GetFullName() const;
|
||||
int EntryCount(const char *szWildCard=NULL);
|
||||
int EntrySize(const char *szWildCard=NULL);
|
||||
int EntryCount(const char *szWildCard=NULL);
|
||||
int EntrySize(const char *szWildCard=NULL);
|
||||
int AccessedEntrySize() { return iCurrFileSize; } // retrieve size of last accessed entry
|
||||
int EntryTime(const char *szFilename);
|
||||
unsigned int EntryCRC32(const char *szWildCard=NULL);
|
||||
|
@ -269,39 +269,39 @@ class C4Group: public CStdStream
|
|||
void PrintInternals(const char *szIndent=NULL);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void Init();
|
||||
void Default();
|
||||
void Clear();
|
||||
protected:
|
||||
void Init();
|
||||
void Default();
|
||||
void Clear();
|
||||
void ProcessOut(const char *szMessage, int iProcess=0);
|
||||
bool EnsureChildFilePtr(C4Group *pChild);
|
||||
bool CloseExclusiveMother();
|
||||
bool Error(const char *szStatus);
|
||||
bool OpenReal(const char *szGroupName);
|
||||
bool OpenRealGrpFile();
|
||||
bool SetFilePtr(int iOffset);
|
||||
bool RewindFilePtr();
|
||||
bool AdvanceFilePtr(int iOffset, C4Group *pByChild=NULL);
|
||||
bool AddEntry(int status,
|
||||
bool Error(const char *szStatus);
|
||||
bool OpenReal(const char *szGroupName);
|
||||
bool OpenRealGrpFile();
|
||||
bool SetFilePtr(int iOffset);
|
||||
bool RewindFilePtr();
|
||||
bool AdvanceFilePtr(int iOffset, C4Group *pByChild=NULL);
|
||||
bool AddEntry(int status,
|
||||
bool childgroup,
|
||||
const char *fname,
|
||||
const char *fname,
|
||||
long size,
|
||||
time_t time,
|
||||
char cCRC,
|
||||
unsigned int iCRC,
|
||||
const char *entryname = NULL,
|
||||
BYTE *membuf = NULL,
|
||||
const char *entryname = NULL,
|
||||
BYTE *membuf = NULL,
|
||||
bool fDeleteOnDisk = false,
|
||||
bool fHoldBuffer = false,
|
||||
bool fExecutable = false,
|
||||
bool fBufferIsStdbuf = 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 AppendEntry2StdFile(C4GroupEntry *centry, CStdFile &stdfile);
|
||||
C4GroupEntry *GetEntry(const char *szName);
|
||||
C4GroupEntry *SearchNextEntry(const char *szName);
|
||||
C4GroupEntry *GetNextFolderEntry();
|
||||
bool AddEntryOnDisk(const char *szFilename, const char *szAddAs=NULL, bool fMove=false);
|
||||
bool SetFilePtr2Entry(const char *szName, C4Group *pByChild=NULL, bool NeedsToBeAGroup = false);
|
||||
bool AppendEntry2StdFile(C4GroupEntry *centry, CStdFile &stdfile);
|
||||
C4GroupEntry *GetEntry(const char *szName);
|
||||
C4GroupEntry *SearchNextEntry(const char *szName);
|
||||
C4GroupEntry *GetNextFolderEntry();
|
||||
bool CalcCRC32(C4GroupEntry *pEntry);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -48,16 +48,16 @@ class C4LanguageInfo
|
|||
|
||||
class C4Language
|
||||
{
|
||||
public:
|
||||
C4Language();
|
||||
~C4Language();
|
||||
protected:
|
||||
public:
|
||||
C4Language();
|
||||
~C4Language();
|
||||
protected:
|
||||
C4Group PackDirectory;
|
||||
C4GroupSet Packs;
|
||||
C4GroupSet PackGroups;
|
||||
C4LanguageInfo* Infos;
|
||||
char PackGroupLocation[_MAX_FNAME + 1];
|
||||
public:
|
||||
public:
|
||||
bool CloseGroup(const char *strPath);
|
||||
void ClearLanguage();
|
||||
// Initialization
|
||||
|
|
|
@ -198,17 +198,17 @@ public:
|
|||
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);
|
||||
if(pCore) pCore->Time = iEntryTime;
|
||||
}
|
||||
if(pCore) pCore->Time = iEntryTime;
|
||||
}
|
||||
|
||||
void SetNoSort(const char *szEntry)
|
||||
{
|
||||
void SetNoSort(const char *szEntry)
|
||||
{
|
||||
C4GroupEntry *pEntry = GetEntry(szEntry);
|
||||
if(pEntry) pEntry->NoSort = true;
|
||||
}
|
||||
if(pEntry) pEntry->NoSort = true;
|
||||
}
|
||||
|
||||
// close without header update
|
||||
bool Close(bool fHeaderUpdate)
|
||||
|
@ -350,7 +350,7 @@ bool C4UpdatePackage::Execute(C4Group *pGroup)
|
|||
uint32_t iCRC32;
|
||||
if(!C4Group_GetFileCRC(TargetGrp.GetFullName().getData(), &iCRC32))
|
||||
return false;
|
||||
int i = 0;
|
||||
int i = 0;
|
||||
for(; i < UpGrpCnt; i++)
|
||||
if(iCRC32 == GrpChks1[i])
|
||||
break;
|
||||
|
@ -463,7 +463,7 @@ int C4UpdatePackage::Check(C4Group *pGroup)
|
|||
// so there's nothing to do
|
||||
return C4UPD_CHK_ALREADY_UPDATED;
|
||||
// check if it's one of our registered sources
|
||||
int i = 0;
|
||||
int i = 0;
|
||||
for(; i < UpGrpCnt; i++)
|
||||
if(iCRC32 == GrpChks1[i])
|
||||
break;
|
||||
|
@ -521,7 +521,7 @@ bool C4UpdatePackage::DoUpdate(C4Group *pGrpFrom, C4GroupEx *pGrpTo, const char
|
|||
#ifdef _MSC_VER
|
||||
OutputDebugString(strMsg);
|
||||
#elif _DEBUG
|
||||
puts(strMsg);
|
||||
puts(strMsg);
|
||||
#endif
|
||||
if(!C4Group_CopyEntry(pGrpFrom, pGrpTo, strFileName))
|
||||
return false;
|
||||
|
@ -546,33 +546,33 @@ bool C4UpdatePackage::DoGrpUpdate(C4Group *pUpdateData, C4GroupEx *pGrpTo)
|
|||
{
|
||||
bool fGotIt = false;
|
||||
for(int i = 0; (fGotIt = SCopySegment(pData, i, strItemName2, '|', _MAX_FNAME)); i++)
|
||||
{
|
||||
// remove seperator
|
||||
char *pSep = strchr(strItemName2, '=');
|
||||
if(pSep) *pSep = '\0';
|
||||
// in list?
|
||||
{
|
||||
// remove seperator
|
||||
char *pSep = strchr(strItemName2, '=');
|
||||
if(pSep) *pSep = '\0';
|
||||
// in list?
|
||||
if(SEqual(strItemName, strItemName2))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!fGotIt)
|
||||
pGrpTo->DeleteEntry(strItemName);
|
||||
}
|
||||
// set entry times, set sort list
|
||||
char strSortList[32767] = "";
|
||||
// set entry times, set sort list
|
||||
char strSortList[32767] = "";
|
||||
for(int i = 0; SCopySegment(pData, i, strItemName, '|', _MAX_FNAME); i++)
|
||||
{
|
||||
// get time (if given)
|
||||
char *pTime = strchr(strItemName, '=');
|
||||
if(pTime) *pTime++ = '\0';
|
||||
// set
|
||||
if(pTime) pGrpTo->SetEntryTime(strItemName, atoi(pTime));
|
||||
{
|
||||
// get time (if given)
|
||||
char *pTime = strchr(strItemName, '=');
|
||||
if(pTime) *pTime++ = '\0';
|
||||
// set
|
||||
if(pTime) pGrpTo->SetEntryTime(strItemName, atoi(pTime));
|
||||
// update EntryCRC32. This will make updates to old groups invalid
|
||||
// however, it's needed so updates will update the EntryCRC of *unchanged* files correctly
|
||||
pGrpTo->EntryCRC32(strItemName);
|
||||
// copy to sort list
|
||||
SAppend(strItemName, strSortList);
|
||||
SAppendChar('|', strSortList);
|
||||
}
|
||||
// copy to sort list
|
||||
SAppend(strItemName, strSortList);
|
||||
SAppendChar('|', strSortList);
|
||||
}
|
||||
// sort by list
|
||||
pGrpTo->Sort(strSortList);
|
||||
delete[] pData;
|
||||
|
@ -673,7 +673,7 @@ bool C4UpdatePackage::MakeUpdate(const char *strFile1, const char *strFile2, con
|
|||
// 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; }
|
||||
// already supported by this update?
|
||||
int i = 0;
|
||||
int i = 0;
|
||||
for(; i < UpGrpCnt; i++)
|
||||
if(GrpChks1[UpGrpCnt] == GrpChks1[i])
|
||||
break;
|
||||
|
@ -729,7 +729,7 @@ bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bo
|
|||
{
|
||||
// add to entry list
|
||||
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
|
||||
if(!*fModified)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ class C4UpdatePackageCore
|
|||
public:
|
||||
C4UpdatePackageCore(); // ctor
|
||||
public:
|
||||
int32_t RequireVersion[4];
|
||||
int32_t RequireVersion[4];
|
||||
char Name[C4MaxName+1];
|
||||
char DestPath[_MAX_PATH+1];
|
||||
int32_t GrpUpdate;
|
||||
|
|
|
@ -34,20 +34,20 @@
|
|||
#include <assert.h>
|
||||
|
||||
CStdFile::CStdFile()
|
||||
{
|
||||
Status=false;
|
||||
hFile=NULL;
|
||||
hgzFile=NULL;
|
||||
{
|
||||
Status=false;
|
||||
hFile=NULL;
|
||||
hgzFile=NULL;
|
||||
pMemory=NULL;
|
||||
ClearBuffer();
|
||||
ModeWrite=false;
|
||||
ClearBuffer();
|
||||
ModeWrite=false;
|
||||
Name[0]=0;
|
||||
}
|
||||
}
|
||||
|
||||
CStdFile::~CStdFile()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
{
|
||||
SCopy(szFilename,Name,_MAX_PATH);
|
||||
// Set modes
|
||||
ModeWrite=false;
|
||||
ModeWrite=false;
|
||||
// Open standard file
|
||||
if (fCompressed)
|
||||
{ if (!(hgzFile=gzopen(Name,"rb"))) return false; }
|
||||
else
|
||||
{ if (!(hFile=fopen(Name,"rb"))) return false; }
|
||||
// Reset buffer
|
||||
ClearBuffer();
|
||||
ClearBuffer();
|
||||
// Set status
|
||||
Status=true;
|
||||
return true;
|
||||
}
|
||||
Status=true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStdFile::Append(const char *szFilename)
|
||||
{
|
||||
{
|
||||
SCopy(szFilename,Name,_MAX_PATH);
|
||||
// Set modes
|
||||
ModeWrite=true;
|
||||
ModeWrite=true;
|
||||
// Open standard file
|
||||
if (!(hFile=fopen(Name,"ab"))) return false;
|
||||
// Reset buffer
|
||||
ClearBuffer();
|
||||
ClearBuffer();
|
||||
// Set status
|
||||
Status=true;
|
||||
return true;
|
||||
}
|
||||
Status=true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStdFile::Close(StdBuf **ppMemory)
|
||||
{
|
||||
bool rval=true;
|
||||
Status=false;
|
||||
{
|
||||
bool rval=true;
|
||||
Status=false;
|
||||
Name[0]=0;
|
||||
// Save buffer if in write mode
|
||||
if (ModeWrite && BufferLoad) if (!SaveBuffer()) rval=false;
|
||||
// Close file(s)
|
||||
if (hgzFile) if (gzclose(hgzFile)!=Z_OK) rval=false;
|
||||
// Save buffer if in write mode
|
||||
if (ModeWrite && BufferLoad) if (!SaveBuffer()) rval=false;
|
||||
// Close file(s)
|
||||
if (hgzFile) if (gzclose(hgzFile)!=Z_OK) rval=false;
|
||||
if (hFile) if (fclose(hFile)!=0) rval=false;
|
||||
if (pMemory)
|
||||
{
|
||||
|
@ -144,11 +144,11 @@ bool CStdFile::Close(StdBuf **ppMemory)
|
|||
MemoryPtr=0;
|
||||
hgzFile=NULL; hFile=NULL;
|
||||
return !!rval;
|
||||
}
|
||||
}
|
||||
|
||||
bool CStdFile::Default()
|
||||
{
|
||||
Status=false;
|
||||
Status=false;
|
||||
Name[0]=0;
|
||||
hgzFile=NULL;
|
||||
hFile=NULL;
|
||||
|
@ -184,51 +184,51 @@ bool CStdFile::Read(void *pBuffer, size_t iSize, size_t *ipFSize)
|
|||
}
|
||||
|
||||
int CStdFile::LoadBuffer()
|
||||
{
|
||||
{
|
||||
if (hFile) BufferLoad = fread(Buffer,1,CStdFileBufSize,hFile);
|
||||
if (hgzFile) BufferLoad = gzread(hgzFile, Buffer,CStdFileBufSize);
|
||||
BufferPtr=0;
|
||||
return BufferLoad;
|
||||
}
|
||||
if (hgzFile) BufferLoad = gzread(hgzFile, Buffer,CStdFileBufSize);
|
||||
BufferPtr=0;
|
||||
return BufferLoad;
|
||||
}
|
||||
|
||||
bool CStdFile::SaveBuffer()
|
||||
{
|
||||
int saved = 0;
|
||||
{
|
||||
int saved = 0;
|
||||
if (hFile) saved=fwrite(Buffer,1,BufferLoad,hFile);
|
||||
if (hgzFile) saved=gzwrite(hgzFile,Buffer,BufferLoad);
|
||||
if (pMemory) { pMemory->Append(Buffer, BufferLoad); saved = BufferLoad; }
|
||||
if (saved!=BufferLoad) return false;
|
||||
BufferLoad=0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void CStdFile::ClearBuffer()
|
||||
{
|
||||
BufferLoad=BufferPtr=0;
|
||||
}
|
||||
{
|
||||
BufferLoad=BufferPtr=0;
|
||||
}
|
||||
|
||||
bool CStdFile::Write(const void *pBuffer, int iSize)
|
||||
{
|
||||
int transfer;
|
||||
if (!pBuffer) return false;
|
||||
if (!ModeWrite) return false;
|
||||
BYTE *bypBuffer= (BYTE*) pBuffer;
|
||||
while (iSize>0)
|
||||
{
|
||||
// Space in buffer: Transfer as much as possible
|
||||
if (BufferLoad<CStdFileBufSize)
|
||||
{
|
||||
transfer=Min(CStdFileBufSize-BufferLoad,iSize);
|
||||
memcpy(Buffer+BufferLoad,bypBuffer,transfer);
|
||||
BufferLoad+=transfer;
|
||||
bypBuffer+=transfer;
|
||||
iSize-=transfer;
|
||||
}
|
||||
// Buffer full: Save
|
||||
else if (!SaveBuffer()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
{
|
||||
int transfer;
|
||||
if (!pBuffer) return false;
|
||||
if (!ModeWrite) return false;
|
||||
BYTE *bypBuffer= (BYTE*) pBuffer;
|
||||
while (iSize>0)
|
||||
{
|
||||
// Space in buffer: Transfer as much as possible
|
||||
if (BufferLoad<CStdFileBufSize)
|
||||
{
|
||||
transfer=Min(CStdFileBufSize-BufferLoad,iSize);
|
||||
memcpy(Buffer+BufferLoad,bypBuffer,transfer);
|
||||
BufferLoad+=transfer;
|
||||
bypBuffer+=transfer;
|
||||
iSize-=transfer;
|
||||
}
|
||||
// Buffer full: Save
|
||||
else if (!SaveBuffer()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStdFile::WriteString(const char *szStr)
|
||||
{
|
||||
|
@ -241,9 +241,9 @@ bool CStdFile::WriteString(const char *szStr)
|
|||
}
|
||||
|
||||
bool CStdFile::Rewind()
|
||||
{
|
||||
if (ModeWrite) return false;
|
||||
ClearBuffer();
|
||||
{
|
||||
if (ModeWrite) return false;
|
||||
ClearBuffer();
|
||||
if (hFile) rewind(hFile);
|
||||
if (hgzFile)
|
||||
{
|
||||
|
@ -251,7 +251,7 @@ bool CStdFile::Rewind()
|
|||
if (!(hgzFile=gzopen(Name,"rb"))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CStdFile::Advance(int iOffset)
|
||||
{
|
||||
|
|
|
@ -84,10 +84,10 @@ int dbg_printf(const char *strMessage, ...)
|
|||
bool ProcessGroup(const char *szFilename)
|
||||
{
|
||||
|
||||
C4Group hGroup;
|
||||
int iArg;
|
||||
C4Group hGroup;
|
||||
int iArg;
|
||||
bool fDeleteGroup = false;
|
||||
hGroup.SetStdOutput(true);
|
||||
hGroup.SetStdOutput(true);
|
||||
|
||||
int argc = globalArgC;
|
||||
char **argv = globalArgV;
|
||||
|
@ -97,146 +97,146 @@ bool ProcessGroup(const char *szFilename)
|
|||
printf("Group: %s\n",szFilename);
|
||||
|
||||
// Open group file
|
||||
if (hGroup.Open(szFilename, true))
|
||||
{
|
||||
// No commands: display contents
|
||||
if (iFirstCommand<0)
|
||||
if (hGroup.Open(szFilename, true))
|
||||
{
|
||||
// No commands: display contents
|
||||
if (iFirstCommand<0)
|
||||
{
|
||||
hGroup.View("*");
|
||||
}
|
||||
|
||||
// Process commands
|
||||
// Process commands
|
||||
else
|
||||
for (iArg=iFirstCommand; iArg<argc; iArg++)
|
||||
{
|
||||
for (iArg=iFirstCommand; iArg<argc; iArg++)
|
||||
{
|
||||
// This argument is a command
|
||||
if (argv[iArg][0]=='-')
|
||||
{
|
||||
if (argv[iArg][0]=='-')
|
||||
{
|
||||
// Handle commands
|
||||
switch (argv[iArg][1])
|
||||
{
|
||||
switch (argv[iArg][1])
|
||||
{
|
||||
// Add
|
||||
case 'a':
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
printf("Missing argument for add command\n");
|
||||
else
|
||||
{
|
||||
if ((argv[iArg][2]=='s') || (argv[iArg][2] && (argv[iArg][3]=='s')) )
|
||||
{
|
||||
if ((iArg+2>=argc) || (argv[iArg+2][0]=='-'))
|
||||
printf("Missing argument for add as command\n");
|
||||
else
|
||||
{ hGroup.Add(argv[iArg+1],argv[iArg+2]); iArg+=2; }
|
||||
}
|
||||
else
|
||||
case 'a':
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
printf("Missing argument for add command\n");
|
||||
else
|
||||
{
|
||||
if ((argv[iArg][2]=='s') || (argv[iArg][2] && (argv[iArg][3]=='s')) )
|
||||
{
|
||||
if ((iArg+2>=argc) || (argv[iArg+2][0]=='-'))
|
||||
printf("Missing argument for add as command\n");
|
||||
else
|
||||
{ hGroup.Add(argv[iArg+1],argv[iArg+2]); iArg+=2; }
|
||||
}
|
||||
else
|
||||
#ifdef _WIN32
|
||||
{ hGroup.Add(argv[iArg+1]); iArg++; }
|
||||
{ hGroup.Add(argv[iArg+1]); iArg++; }
|
||||
#else
|
||||
{ hGroup.Add(argv[iArg+1], argv[iArg+1]); iArg++; }
|
||||
{ hGroup.Add(argv[iArg+1], argv[iArg+1]); iArg++; }
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
// Move
|
||||
case 'm':
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
printf("Missing argument for move command\n");
|
||||
else
|
||||
case 'm':
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
printf("Missing argument for move command\n");
|
||||
else
|
||||
#ifdef _WIN32
|
||||
{ hGroup.Move(argv[iArg+1]); iArg++; }
|
||||
#else
|
||||
{ hGroup.Move(argv[iArg+1], argv[iArg+1]); iArg++; }
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
// Extract
|
||||
case 'e':
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
printf("Missing argument for extract command\n");
|
||||
else
|
||||
{
|
||||
if ((argv[iArg][2]=='t') || (argv[iArg][2] && (argv[iArg][3]=='s')) )
|
||||
{
|
||||
if ((iArg+2>=argc) || (argv[iArg+2][0]=='-'))
|
||||
printf("Missing argument for extract as command\n");
|
||||
else
|
||||
{ hGroup.Extract(argv[iArg+1],argv[iArg+2]); iArg+=2; }
|
||||
}
|
||||
else
|
||||
{ hGroup.Extract(argv[iArg+1]); iArg++; }
|
||||
}
|
||||
break;
|
||||
case 'e':
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
printf("Missing argument for extract command\n");
|
||||
else
|
||||
{
|
||||
if ((argv[iArg][2]=='t') || (argv[iArg][2] && (argv[iArg][3]=='s')) )
|
||||
{
|
||||
if ((iArg+2>=argc) || (argv[iArg+2][0]=='-'))
|
||||
printf("Missing argument for extract as command\n");
|
||||
else
|
||||
{ hGroup.Extract(argv[iArg+1],argv[iArg+2]); iArg+=2; }
|
||||
}
|
||||
else
|
||||
{ hGroup.Extract(argv[iArg+1]); iArg++; }
|
||||
}
|
||||
break;
|
||||
// Delete
|
||||
case 'd':
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
printf("Missing argument for delete command\n");
|
||||
else
|
||||
{ hGroup.Delete(argv[iArg+1], fRecursive); iArg++; }
|
||||
break;
|
||||
case 'd':
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
printf("Missing argument for delete command\n");
|
||||
else
|
||||
{ hGroup.Delete(argv[iArg+1], fRecursive); iArg++; }
|
||||
break;
|
||||
// Sort
|
||||
case 's':
|
||||
case 's':
|
||||
// First sort parameter overrides default Clonk sort list
|
||||
C4Group_SetSortList(NULL);
|
||||
// Missing argument
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
printf("Missing argument for sort command\n");
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
printf("Missing argument for sort command\n");
|
||||
// Sort, advance to next argument
|
||||
else
|
||||
{ hGroup.Sort(argv[iArg+1]); iArg++; }
|
||||
break;
|
||||
else
|
||||
{ hGroup.Sort(argv[iArg+1]); iArg++; }
|
||||
break;
|
||||
// Rename
|
||||
case 'r':
|
||||
if ((iArg+2>=argc) || (argv[iArg+1][0]=='-') || (argv[iArg+2][0]=='-'))
|
||||
printf("Missing argument(s) for rename command\n");
|
||||
else
|
||||
{ hGroup.Rename(argv[iArg+1],argv[iArg+2]); iArg+=2; }
|
||||
break;
|
||||
case 'r':
|
||||
if ((iArg+2>=argc) || (argv[iArg+1][0]=='-') || (argv[iArg+2][0]=='-'))
|
||||
printf("Missing argument(s) for rename command\n");
|
||||
else
|
||||
{ hGroup.Rename(argv[iArg+1],argv[iArg+2]); iArg+=2; }
|
||||
break;
|
||||
// View
|
||||
case 'v':
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
{ hGroup.View("*"); }
|
||||
else
|
||||
{ hGroup.View(argv[iArg+1]); iArg++; }
|
||||
break;
|
||||
case 'v':
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
{ hGroup.View("*"); }
|
||||
else
|
||||
{ hGroup.View(argv[iArg+1]); iArg++; }
|
||||
break;
|
||||
// Make original
|
||||
case 'o':
|
||||
hGroup.MakeOriginal(true);
|
||||
break;
|
||||
case 'o':
|
||||
hGroup.MakeOriginal(true);
|
||||
break;
|
||||
// Pack
|
||||
case 'p':
|
||||
case 'p':
|
||||
printf("Packing...\n");
|
||||
// Close
|
||||
// Close
|
||||
if (!hGroup.Close()) printf("Closing failed: %s\n",hGroup.GetError());
|
||||
// Pack
|
||||
else if (!C4Group_PackDirectory(szFilename)) printf("Pack failed\n");
|
||||
// Reopen
|
||||
else if (!hGroup.Open(szFilename)) printf("Reopen failed: %s\n",hGroup.GetError());
|
||||
break;
|
||||
break;
|
||||
// Unpack
|
||||
case 'u':
|
||||
case 'u':
|
||||
printf("Unpacking...\n");
|
||||
// Close
|
||||
// Close
|
||||
if (!hGroup.Close()) printf("Closing failed: %s\n",hGroup.GetError());
|
||||
// Unpack
|
||||
else if (!C4Group_UnpackDirectory(szFilename)) printf("Unpack failed\n");
|
||||
// Reopen
|
||||
else if (!hGroup.Open(szFilename)) printf("Reopen failed: %s\n",hGroup.GetError());
|
||||
break;
|
||||
break;
|
||||
// Unpack
|
||||
case 'x':
|
||||
case 'x':
|
||||
printf("Exploding...\n");
|
||||
// Close
|
||||
// Close
|
||||
if (!hGroup.Close()) printf("Closing failed: %s\n",hGroup.GetError());
|
||||
// Explode
|
||||
else if (!C4Group_ExplodeDirectory(szFilename)) printf("Unpack failed\n");
|
||||
// Reopen
|
||||
else if (!hGroup.Open(szFilename)) printf("Reopen failed: %s\n",hGroup.GetError());
|
||||
break;
|
||||
break;
|
||||
// Print maker
|
||||
case 'k':
|
||||
case 'k':
|
||||
printf("%s\n",hGroup.GetMaker());
|
||||
break;
|
||||
break;
|
||||
// Generate update
|
||||
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");
|
||||
else
|
||||
{
|
||||
|
@ -261,11 +261,11 @@ bool ProcessGroup(const char *szFilename)
|
|||
break;
|
||||
// Optimize update generation target
|
||||
case 'z':
|
||||
if ((iArg + 1 >= argc) || (argv[iArg+1][0] == '-'))
|
||||
if ((iArg + 1 >= argc) || (argv[iArg+1][0] == '-'))
|
||||
printf("Missing parameter for optimization\n");
|
||||
else
|
||||
{
|
||||
printf("Optimizing %s...\n", argv[iArg+1]);
|
||||
printf("Optimizing %s...\n", argv[iArg+1]);
|
||||
if(!C4UpdatePackage::Optimize(&hGroup, argv[iArg+1]))
|
||||
printf("Optimization failed.\n");
|
||||
iArg++;
|
||||
|
@ -278,11 +278,11 @@ bool ProcessGroup(const char *szFilename)
|
|||
break;
|
||||
#endif
|
||||
// Wait
|
||||
case 'w':
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
printf("Missing argument for wait command\n");
|
||||
else
|
||||
{
|
||||
case 'w':
|
||||
if ((iArg+1>=argc) || (argv[iArg+1][0]=='-'))
|
||||
printf("Missing argument for wait command\n");
|
||||
else
|
||||
{
|
||||
int iMilliseconds = 0;
|
||||
sscanf(argv[iArg+1], "%d", &iMilliseconds);
|
||||
// Wait for specified time
|
||||
|
@ -303,28 +303,28 @@ bool ProcessGroup(const char *szFilename)
|
|||
printf("\n");
|
||||
}
|
||||
iArg++;
|
||||
}
|
||||
break;
|
||||
// Undefined
|
||||
default:
|
||||
printf("Unknown command: %s\n",argv[iArg]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Invalid parameter %s\n",argv[iArg]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Undefined
|
||||
default:
|
||||
printf("Unknown command: %s\n",argv[iArg]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Invalid parameter %s\n",argv[iArg]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Error: output status
|
||||
if (!SEqual(hGroup.GetError(),"No Error"))
|
||||
printf("Status: %s\n",hGroup.GetError());
|
||||
|
||||
// Close group file
|
||||
if (!hGroup.Close())
|
||||
printf("Closing: %s\n",hGroup.GetError());
|
||||
// Close group file
|
||||
if (!hGroup.Close())
|
||||
printf("Closing: %s\n",hGroup.GetError());
|
||||
|
||||
// Delete group file if desired (i.e. after apply update)
|
||||
if (fDeleteGroup)
|
||||
|
@ -333,13 +333,13 @@ bool ProcessGroup(const char *szFilename)
|
|||
EraseItem(szFilename);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Couldn't open group
|
||||
else
|
||||
{
|
||||
printf("Status: %s\n",hGroup.GetError());
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Status: %s\n",hGroup.GetError());
|
||||
}
|
||||
|
||||
// Done
|
||||
return true;
|
||||
|
@ -405,7 +405,7 @@ int UnregisterShellExtensions()
|
|||
|
||||
bool Log(const char *msg)
|
||||
{
|
||||
if (!fQuiet)
|
||||
if (!fQuiet)
|
||||
printf("%s\n", msg);
|
||||
return 1;
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ void StdCompilerWarnCallback(void *pData, const char *szPosition, const char *sz
|
|||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
{
|
||||
|
||||
// Scan options (scan including first parameter - this means the group filename cannot start with a '/'...)
|
||||
for (int i = 1; i < argc; i++)
|
||||
|
@ -506,18 +506,18 @@ int main(int argc, char *argv[])
|
|||
printf("Error removing shell extensions.\n");
|
||||
|
||||
// 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
|
||||
if (SCharCount('*',argv[1]))
|
||||
ForEachFile(argv[1], &ProcessGroup);
|
||||
// Only one file
|
||||
else
|
||||
ProcessGroup(argv[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// Too few parameters: output help (if we didn't register stuff)
|
||||
else
|
||||
else
|
||||
if (!fRegisterShell && !fUnregisterShell)
|
||||
{
|
||||
printf("\n");
|
||||
|
@ -568,6 +568,6 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
// Done
|
||||
return iResult;
|
||||
return iResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,13 +57,13 @@ char strExecuteAtEnd[_MAX_PATH + 1] = "";
|
|||
int iResult = 0;
|
||||
|
||||
bool EraseItemSafe(const char *szFilename) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Log(const char *msg) {
|
||||
if (!fQuiet)
|
||||
printf("%s\n", msg);
|
||||
return 1;
|
||||
if (!fQuiet)
|
||||
printf("%s\n", msg);
|
||||
return 1;
|
||||
}
|
||||
#define IMPLEMENT_LOGF(func) \
|
||||
bool func(const char *msg, ...) { \
|
||||
|
@ -79,443 +79,443 @@ IMPLEMENT_LOGF(LogSilentF)
|
|||
|
||||
bool ProcessGroup(const char *FilenamePar) {
|
||||
|
||||
C4Group hGroup;
|
||||
hGroup.SetStdOutput(!fQuiet);
|
||||
C4Group hGroup;
|
||||
hGroup.SetStdOutput(!fQuiet);
|
||||
bool fDeleteGroup = false;
|
||||
|
||||
int argc = globalArgC;
|
||||
char **argv = globalArgV;
|
||||
int argc = globalArgC;
|
||||
char **argv = globalArgV;
|
||||
|
||||
// Strip trailing slash
|
||||
char * szFilename = strdup(FilenamePar);
|
||||
size_t len = strlen(szFilename);
|
||||
if (szFilename[len-1] == DirectorySeparator) szFilename[len-1] = 0;
|
||||
// Current filename
|
||||
LogF("Group: %s", szFilename);
|
||||
// Strip trailing slash
|
||||
char * szFilename = strdup(FilenamePar);
|
||||
size_t len = strlen(szFilename);
|
||||
if (szFilename[len-1] == DirectorySeparator) szFilename[len-1] = 0;
|
||||
// Current filename
|
||||
LogF("Group: %s", szFilename);
|
||||
|
||||
// Open group file
|
||||
if (hGroup.Open(szFilename, true)) {
|
||||
// No commands: display contents
|
||||
if (iFirstCommand >= argc) {
|
||||
hGroup.SetStdOutput(true);
|
||||
// Open group file
|
||||
if (hGroup.Open(szFilename, true)) {
|
||||
// No commands: display contents
|
||||
if (iFirstCommand >= argc) {
|
||||
hGroup.SetStdOutput(true);
|
||||
hGroup.View("*");
|
||||
hGroup.SetStdOutput(!fQuiet);
|
||||
}
|
||||
// Process commands
|
||||
else {
|
||||
for (int iArg = iFirstCommand; iArg < argc; ++iArg) {
|
||||
// This argument is a command
|
||||
if (argv[iArg][0] == '-') {
|
||||
hGroup.SetStdOutput(!fQuiet);
|
||||
}
|
||||
// Process commands
|
||||
else {
|
||||
for (int iArg = iFirstCommand; iArg < argc; ++iArg) {
|
||||
// This argument is a command
|
||||
if (argv[iArg][0] == '-') {
|
||||
// Handle commands
|
||||
switch (argv[iArg][1]) {
|
||||
// Add
|
||||
case 'a':
|
||||
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-'))
|
||||
fprintf(stderr, "Missing argument for add command\n");
|
||||
else {
|
||||
if ((argv[iArg][2] == 's') || (argv[iArg][2] && (argv[iArg][3] == 's'))) {
|
||||
if ((iArg + 2 >= argc) || (argv[iArg + 2][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument for add as command\n");
|
||||
} else {
|
||||
hGroup.Add(argv[iArg + 1], argv[iArg + 2]);
|
||||
iArg += 2;
|
||||
}
|
||||
} else {
|
||||
while (iArg + 1 < argc && argv[iArg + 1][0] != '-') {
|
||||
++iArg;
|
||||
switch (argv[iArg][1]) {
|
||||
// Add
|
||||
case 'a':
|
||||
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-'))
|
||||
fprintf(stderr, "Missing argument for add command\n");
|
||||
else {
|
||||
if ((argv[iArg][2] == 's') || (argv[iArg][2] && (argv[iArg][3] == 's'))) {
|
||||
if ((iArg + 2 >= argc) || (argv[iArg + 2][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument for add as command\n");
|
||||
} else {
|
||||
hGroup.Add(argv[iArg + 1], argv[iArg + 2]);
|
||||
iArg += 2;
|
||||
}
|
||||
} else {
|
||||
while (iArg + 1 < argc && argv[iArg + 1][0] != '-') {
|
||||
++iArg;
|
||||
#ifdef _WIN32
|
||||
// manually expand wildcards
|
||||
hGroup.Add(argv[iArg]);
|
||||
// manually expand wildcards
|
||||
hGroup.Add(argv[iArg]);
|
||||
#else
|
||||
hGroup.Add(argv[iArg], GetFilename(argv[iArg]));
|
||||
hGroup.Add(argv[iArg], GetFilename(argv[iArg]));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Move
|
||||
case 'm':
|
||||
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument for move command\n");
|
||||
} else {
|
||||
while (iArg + 1 < argc && argv[iArg + 1][0] != '-') {
|
||||
++iArg;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Move
|
||||
case 'm':
|
||||
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument for move command\n");
|
||||
} else {
|
||||
while (iArg + 1 < argc && argv[iArg + 1][0] != '-') {
|
||||
++iArg;
|
||||
#ifdef _WIN32
|
||||
// manually expand wildcards
|
||||
hGroup.Move(argv[iArg]);
|
||||
// manually expand wildcards
|
||||
hGroup.Move(argv[iArg]);
|
||||
#else
|
||||
hGroup.Move(argv[iArg], argv[iArg]);
|
||||
hGroup.Move(argv[iArg], argv[iArg]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Extract
|
||||
case 'e':
|
||||
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument for extract command\n");
|
||||
} else {
|
||||
if ((argv[iArg][2] == 't') || (argv[iArg][2] && (argv[iArg][3] == 's'))) {
|
||||
if ((iArg + 2 >= argc) || (argv[iArg + 2][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument for extract as command\n");
|
||||
} else {
|
||||
hGroup.Extract(argv[iArg + 1], argv[iArg + 2]);
|
||||
iArg += 2;
|
||||
}
|
||||
} else {
|
||||
hGroup.Extract(argv[iArg + 1]);
|
||||
iArg++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Delete
|
||||
case 'd':
|
||||
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument for delete command\n");
|
||||
} else {
|
||||
hGroup.Delete(argv[iArg + 1], fRecursive);
|
||||
iArg++;
|
||||
}
|
||||
break;
|
||||
// Sort
|
||||
case 's':
|
||||
// First sort parameter overrides default Clonk sort list
|
||||
C4Group_SetSortList(NULL);
|
||||
// Missing argument
|
||||
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument for sort command\n");
|
||||
}
|
||||
// Sort, advance to next argument
|
||||
else {
|
||||
hGroup.Sort(argv[iArg + 1]);
|
||||
iArg++;
|
||||
}
|
||||
break;
|
||||
// Rename
|
||||
case 'r':
|
||||
if ((iArg + 2 >= argc) || (argv[iArg + 1][0] == '-')
|
||||
|| (argv[iArg + 2][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument(s) for rename command\n");
|
||||
} else {
|
||||
hGroup.Rename(argv[iArg + 1], argv[iArg + 2]);
|
||||
iArg += 2;
|
||||
}
|
||||
break;
|
||||
// View
|
||||
case 'l':
|
||||
hGroup.SetStdOutput(true);
|
||||
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
|
||||
hGroup.View("*");
|
||||
} else {
|
||||
hGroup.View(argv[iArg + 1]);
|
||||
iArg++;
|
||||
}
|
||||
hGroup.SetStdOutput(!fQuiet);
|
||||
break;
|
||||
// Make original
|
||||
case 'o':
|
||||
hGroup.MakeOriginal(true);
|
||||
break;
|
||||
// Pack
|
||||
case 'p':
|
||||
Log("Packing...");
|
||||
// Close
|
||||
if (!hGroup.Close()) {
|
||||
fprintf(stderr, "Closing failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
// Pack
|
||||
else if (!C4Group_PackDirectory(szFilename)) {
|
||||
fprintf(stderr, "Pack failed\n");
|
||||
}
|
||||
// Reopen
|
||||
else if (!hGroup.Open(szFilename)) {
|
||||
fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
break;
|
||||
// Unpack
|
||||
case 'u':
|
||||
LogF("Unpacking...");
|
||||
// Close
|
||||
if (!hGroup.Close()) {
|
||||
fprintf(stderr, "Closing failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
// Pack
|
||||
else if (!C4Group_UnpackDirectory(szFilename)) {
|
||||
fprintf(stderr, "Unpack failed\n");
|
||||
}
|
||||
// Reopen
|
||||
else if (!hGroup.Open(szFilename)) {
|
||||
fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
break;
|
||||
// Unpack
|
||||
case 'x':
|
||||
Log("Exploding...");
|
||||
// Close
|
||||
if (!hGroup.Close()) {
|
||||
fprintf(stderr, "Closing failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
// Pack
|
||||
else if (!C4Group_ExplodeDirectory(szFilename)) {
|
||||
fprintf(stderr, "Unpack failed\n");
|
||||
}
|
||||
// Reopen
|
||||
else if (!hGroup.Open(szFilename)) {
|
||||
fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
break;
|
||||
// Print maker
|
||||
case 'k':
|
||||
printf("%s\n", hGroup.GetMaker());
|
||||
break;
|
||||
// Generate update
|
||||
case 'g':
|
||||
if ((iArg + 3 >= argc) || (argv[iArg + 1][0] == '-')
|
||||
|| (argv[iArg + 2][0] == '-')
|
||||
|| (argv[iArg + 3][0] == '-')) {
|
||||
fprintf(stderr, "Update generation failed: too few arguments\n");
|
||||
} else {
|
||||
C4UpdatePackage Upd;
|
||||
// Close
|
||||
if (!hGroup.Close()) {
|
||||
fprintf(stderr, "Closing failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
// generate
|
||||
else if (!Upd.MakeUpdate(argv[iArg + 1], argv[iArg + 2], szFilename, argv[iArg + 3])) {
|
||||
fprintf(stderr, "Update generation failed.\n");
|
||||
}
|
||||
// Reopen
|
||||
else if (!hGroup.Open(szFilename)) {
|
||||
fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
iArg += 3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Extract
|
||||
case 'e':
|
||||
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument for extract command\n");
|
||||
} else {
|
||||
if ((argv[iArg][2] == 't') || (argv[iArg][2] && (argv[iArg][3] == 's'))) {
|
||||
if ((iArg + 2 >= argc) || (argv[iArg + 2][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument for extract as command\n");
|
||||
} else {
|
||||
hGroup.Extract(argv[iArg + 1], argv[iArg + 2]);
|
||||
iArg += 2;
|
||||
}
|
||||
} else {
|
||||
hGroup.Extract(argv[iArg + 1]);
|
||||
iArg++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Delete
|
||||
case 'd':
|
||||
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument for delete command\n");
|
||||
} else {
|
||||
hGroup.Delete(argv[iArg + 1], fRecursive);
|
||||
iArg++;
|
||||
}
|
||||
break;
|
||||
// Sort
|
||||
case 's':
|
||||
// First sort parameter overrides default Clonk sort list
|
||||
C4Group_SetSortList(NULL);
|
||||
// Missing argument
|
||||
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument for sort command\n");
|
||||
}
|
||||
// Sort, advance to next argument
|
||||
else {
|
||||
hGroup.Sort(argv[iArg + 1]);
|
||||
iArg++;
|
||||
}
|
||||
break;
|
||||
// Rename
|
||||
case 'r':
|
||||
if ((iArg + 2 >= argc) || (argv[iArg + 1][0] == '-')
|
||||
|| (argv[iArg + 2][0] == '-')) {
|
||||
fprintf(stderr, "Missing argument(s) for rename command\n");
|
||||
} else {
|
||||
hGroup.Rename(argv[iArg + 1], argv[iArg + 2]);
|
||||
iArg += 2;
|
||||
}
|
||||
break;
|
||||
// View
|
||||
case 'l':
|
||||
hGroup.SetStdOutput(true);
|
||||
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-')) {
|
||||
hGroup.View("*");
|
||||
} else {
|
||||
hGroup.View(argv[iArg + 1]);
|
||||
iArg++;
|
||||
}
|
||||
hGroup.SetStdOutput(!fQuiet);
|
||||
break;
|
||||
// Make original
|
||||
case 'o':
|
||||
hGroup.MakeOriginal(true);
|
||||
break;
|
||||
// Pack
|
||||
case 'p':
|
||||
Log("Packing...");
|
||||
// Close
|
||||
if (!hGroup.Close()) {
|
||||
fprintf(stderr, "Closing failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
// Pack
|
||||
else if (!C4Group_PackDirectory(szFilename)) {
|
||||
fprintf(stderr, "Pack failed\n");
|
||||
}
|
||||
// Reopen
|
||||
else if (!hGroup.Open(szFilename)) {
|
||||
fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
break;
|
||||
// Unpack
|
||||
case 'u':
|
||||
LogF("Unpacking...");
|
||||
// Close
|
||||
if (!hGroup.Close()) {
|
||||
fprintf(stderr, "Closing failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
// Pack
|
||||
else if (!C4Group_UnpackDirectory(szFilename)) {
|
||||
fprintf(stderr, "Unpack failed\n");
|
||||
}
|
||||
// Reopen
|
||||
else if (!hGroup.Open(szFilename)) {
|
||||
fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
break;
|
||||
// Unpack
|
||||
case 'x':
|
||||
Log("Exploding...");
|
||||
// Close
|
||||
if (!hGroup.Close()) {
|
||||
fprintf(stderr, "Closing failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
// Pack
|
||||
else if (!C4Group_ExplodeDirectory(szFilename)) {
|
||||
fprintf(stderr, "Unpack failed\n");
|
||||
}
|
||||
// Reopen
|
||||
else if (!hGroup.Open(szFilename)) {
|
||||
fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
break;
|
||||
// Print maker
|
||||
case 'k':
|
||||
printf("%s\n", hGroup.GetMaker());
|
||||
break;
|
||||
// Generate update
|
||||
case 'g':
|
||||
if ((iArg + 3 >= argc) || (argv[iArg + 1][0] == '-')
|
||||
|| (argv[iArg + 2][0] == '-')
|
||||
|| (argv[iArg + 3][0] == '-')) {
|
||||
fprintf(stderr, "Update generation failed: too few arguments\n");
|
||||
} else {
|
||||
C4UpdatePackage Upd;
|
||||
// Close
|
||||
if (!hGroup.Close()) {
|
||||
fprintf(stderr, "Closing failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
// generate
|
||||
else if (!Upd.MakeUpdate(argv[iArg + 1], argv[iArg + 2], szFilename, argv[iArg + 3])) {
|
||||
fprintf(stderr, "Update generation failed.\n");
|
||||
}
|
||||
// Reopen
|
||||
else if (!hGroup.Open(szFilename)) {
|
||||
fprintf(stderr, "Reopen failed: %s\n", hGroup.GetError());
|
||||
}
|
||||
iArg += 3;
|
||||
}
|
||||
break;
|
||||
|
||||
// Apply an update
|
||||
case 'y':
|
||||
Log("Applying update...");
|
||||
if (C4Group_ApplyUpdate(hGroup))
|
||||
// Apply an update
|
||||
case 'y':
|
||||
Log("Applying update...");
|
||||
if (C4Group_ApplyUpdate(hGroup))
|
||||
{ if (argv[iArg][2]=='d') fDeleteGroup = true; }
|
||||
else
|
||||
fprintf(stderr,"Update failed.\n");
|
||||
break;
|
||||
fprintf(stderr,"Update failed.\n");
|
||||
break;
|
||||
#ifdef _DEBUG
|
||||
case 'z':
|
||||
hGroup.PrintInternals();
|
||||
break;
|
||||
case 'z':
|
||||
hGroup.PrintInternals();
|
||||
break;
|
||||
#endif
|
||||
// Undefined
|
||||
default:
|
||||
fprintf(stderr, "Unknown command: %s\n", argv[iArg]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Invalid parameter %s\n", argv[iArg]);
|
||||
}
|
||||
// Undefined
|
||||
default:
|
||||
fprintf(stderr, "Unknown command: %s\n", argv[iArg]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Invalid parameter %s\n", argv[iArg]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// Error: output status
|
||||
if (!SEqual(hGroup.GetError(), "No Error")) {
|
||||
fprintf(stderr, "Status: %s\n", hGroup.GetError());
|
||||
}
|
||||
// Close group file
|
||||
if (!hGroup.Close()) {
|
||||
fprintf(stderr, "Closing: %s\n", hGroup.GetError());
|
||||
}
|
||||
}
|
||||
}
|
||||
// Error: output status
|
||||
if (!SEqual(hGroup.GetError(), "No Error")) {
|
||||
fprintf(stderr, "Status: %s\n", hGroup.GetError());
|
||||
}
|
||||
// Close group file
|
||||
if (!hGroup.Close()) {
|
||||
fprintf(stderr, "Closing: %s\n", hGroup.GetError());
|
||||
}
|
||||
// Delete group file if desired (i.e. after apply update)
|
||||
if (fDeleteGroup) {
|
||||
LogF("Deleting %s...\n", GetFilename(szFilename));
|
||||
EraseItem(szFilename);
|
||||
}
|
||||
}
|
||||
// Couldn't open group
|
||||
else {
|
||||
fprintf(stderr, "Status: %s\n", hGroup.GetError());
|
||||
}
|
||||
free(szFilename);
|
||||
// Done
|
||||
return true;
|
||||
}
|
||||
// Couldn't open group
|
||||
else {
|
||||
fprintf(stderr, "Status: %s\n", hGroup.GetError());
|
||||
}
|
||||
free(szFilename);
|
||||
// Done
|
||||
return true;
|
||||
}
|
||||
|
||||
int RegisterShellExtensions() {
|
||||
#ifdef _WIN32
|
||||
char strModule[2048];
|
||||
char strCommand[2048];
|
||||
char strClass[128];
|
||||
int i;
|
||||
GetModuleFileName(NULL, strModule, 2048);
|
||||
// Groups
|
||||
const char *strClasses =
|
||||
"Clonk4.Definition;Clonk4.Folder;Clonk4.Group;Clonk4.Player;Clonk4.Scenario;Clonk4.Update;Clonk4.Weblink";
|
||||
for (i = 0; SCopySegment(strClasses, i, strClass); i++) {
|
||||
// Unpack
|
||||
sprintf(strCommand, "\"%s\" \"%%1\" \"-u\"", strModule);
|
||||
if (!SetRegShell(strClass, "MakeFolder", "C4Group Unpack", strCommand))
|
||||
return 0;
|
||||
// Explode
|
||||
sprintf(strCommand, "\"%s\" \"%%1\" \"-x\"", strModule);
|
||||
if (!SetRegShell(strClass, "ExplodeFolder", "C4Group Explode", strCommand))
|
||||
return 0;
|
||||
}
|
||||
// Directories
|
||||
const char *strClasses2 = "Directory";
|
||||
for (i = 0; SCopySegment(strClasses2, i, strClass); i++) {
|
||||
// Pack
|
||||
sprintf(strCommand, "\"%s\" \"%%1\" \"-p\"", strModule);
|
||||
if (!SetRegShell(strClass, "MakeGroupFile", "C4Group Pack", strCommand))
|
||||
return 0;
|
||||
}
|
||||
// Done
|
||||
char strModule[2048];
|
||||
char strCommand[2048];
|
||||
char strClass[128];
|
||||
int i;
|
||||
GetModuleFileName(NULL, strModule, 2048);
|
||||
// Groups
|
||||
const char *strClasses =
|
||||
"Clonk4.Definition;Clonk4.Folder;Clonk4.Group;Clonk4.Player;Clonk4.Scenario;Clonk4.Update;Clonk4.Weblink";
|
||||
for (i = 0; SCopySegment(strClasses, i, strClass); i++) {
|
||||
// Unpack
|
||||
sprintf(strCommand, "\"%s\" \"%%1\" \"-u\"", strModule);
|
||||
if (!SetRegShell(strClass, "MakeFolder", "C4Group Unpack", strCommand))
|
||||
return 0;
|
||||
// Explode
|
||||
sprintf(strCommand, "\"%s\" \"%%1\" \"-x\"", strModule);
|
||||
if (!SetRegShell(strClass, "ExplodeFolder", "C4Group Explode", strCommand))
|
||||
return 0;
|
||||
}
|
||||
// Directories
|
||||
const char *strClasses2 = "Directory";
|
||||
for (i = 0; SCopySegment(strClasses2, i, strClass); i++) {
|
||||
// Pack
|
||||
sprintf(strCommand, "\"%s\" \"%%1\" \"-p\"", strModule);
|
||||
if (!SetRegShell(strClass, "MakeGroupFile", "C4Group Pack", strCommand))
|
||||
return 0;
|
||||
}
|
||||
// Done
|
||||
#endif
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int UnregisterShellExtensions() {
|
||||
#ifdef _WIN32
|
||||
char strModule[2048];
|
||||
char strClass[128];
|
||||
int i;
|
||||
GetModuleFileName(NULL, strModule, 2048);
|
||||
// Groups
|
||||
const char *strClasses =
|
||||
"Clonk4.Definition;Clonk4.Folder;Clonk4.Group;Clonk4.Player;Clonk4.Scenario;Clonk4.Update;Clonk4.Weblink";
|
||||
for (i = 0; SCopySegment(strClasses, i, strClass); i++) {
|
||||
// Unpack
|
||||
if (!RemoveRegShell(strClass, "MakeFolder"))
|
||||
return 0;
|
||||
// Explode
|
||||
if (!RemoveRegShell(strClass, "ExplodeFolder"))
|
||||
return 0;
|
||||
}
|
||||
// Directories
|
||||
const char *strClasses2 = "Directory";
|
||||
for (i = 0; SCopySegment(strClasses2, i, strClass); i++) {
|
||||
// Pack
|
||||
if (!RemoveRegShell(strClass, "MakeGroupFile"))
|
||||
return 0;
|
||||
}
|
||||
// Done
|
||||
char strModule[2048];
|
||||
char strClass[128];
|
||||
int i;
|
||||
GetModuleFileName(NULL, strModule, 2048);
|
||||
// Groups
|
||||
const char *strClasses =
|
||||
"Clonk4.Definition;Clonk4.Folder;Clonk4.Group;Clonk4.Player;Clonk4.Scenario;Clonk4.Update;Clonk4.Weblink";
|
||||
for (i = 0; SCopySegment(strClasses, i, strClass); i++) {
|
||||
// Unpack
|
||||
if (!RemoveRegShell(strClass, "MakeFolder"))
|
||||
return 0;
|
||||
// Explode
|
||||
if (!RemoveRegShell(strClass, "ExplodeFolder"))
|
||||
return 0;
|
||||
}
|
||||
// Directories
|
||||
const char *strClasses2 = "Directory";
|
||||
for (i = 0; SCopySegment(strClasses2, i, strClass); i++) {
|
||||
// Pack
|
||||
if (!RemoveRegShell(strClass, "MakeGroupFile"))
|
||||
return 0;
|
||||
}
|
||||
// Done
|
||||
#endif
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
#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);
|
||||
#endif
|
||||
// Scan options
|
||||
int iFirstGroup = 0;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
// Option encountered
|
||||
if (argv[i][0] == '-') {
|
||||
switch (argv[i][1]) {
|
||||
// Quiet mode
|
||||
case 'v':
|
||||
fQuiet = false;
|
||||
break;
|
||||
// Silent mode
|
||||
//case 's': fSilent=true; break;
|
||||
// Recursive mode
|
||||
case 'r':
|
||||
fRecursive = true;
|
||||
break;
|
||||
// Register shell
|
||||
case 'i':
|
||||
fRegisterShell = true;
|
||||
break;
|
||||
// Unregister shell
|
||||
case 'u':
|
||||
fUnregisterShell = true;
|
||||
break;
|
||||
// Scan options
|
||||
int iFirstGroup = 0;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
// Option encountered
|
||||
if (argv[i][0] == '-') {
|
||||
switch (argv[i][1]) {
|
||||
// Quiet mode
|
||||
case 'v':
|
||||
fQuiet = false;
|
||||
break;
|
||||
// Silent mode
|
||||
//case 's': fSilent=true; break;
|
||||
// Recursive mode
|
||||
case 'r':
|
||||
fRecursive = true;
|
||||
break;
|
||||
// Register shell
|
||||
case 'i':
|
||||
fRegisterShell = true;
|
||||
break;
|
||||
// Unregister shell
|
||||
case 'u':
|
||||
fUnregisterShell = true;
|
||||
break;
|
||||
// Execute at end
|
||||
case 'x': SCopy(argv[i] + 3, strExecuteAtEnd, _MAX_PATH); break;
|
||||
// Unknown
|
||||
default:
|
||||
fprintf(stderr, "Unknown option %s\n", argv[i]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// filename encountered: no more options expected
|
||||
iFirstGroup = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
iFirstCommand = iFirstGroup;
|
||||
while (iFirstCommand < argc && argv[iFirstCommand][0] != '-')
|
||||
++iFirstCommand;
|
||||
// Unknown
|
||||
default:
|
||||
fprintf(stderr, "Unknown option %s\n", argv[i]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// filename encountered: no more options expected
|
||||
iFirstGroup = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
iFirstCommand = iFirstGroup;
|
||||
while (iFirstCommand < argc && argv[iFirstCommand][0] != '-')
|
||||
++iFirstCommand;
|
||||
|
||||
// Program info
|
||||
LogF("RedWolf Design C4Group %s", C4VERSION);
|
||||
// Program info
|
||||
LogF("RedWolf Design C4Group %s", C4VERSION);
|
||||
|
||||
// Registration check
|
||||
// Registration check
|
||||
/* Config.Init();
|
||||
Config.Load(false);*/
|
||||
Config.Load(false);*/
|
||||
|
||||
// Init C4Group
|
||||
// Init C4Group
|
||||
/* C4Group_SetMaker(Config.General.Name);
|
||||
C4Group_SetTempPath(Config.General.TempPath);*/
|
||||
C4Group_SetSortList(C4CFN_FLS);
|
||||
C4Group_SetTempPath(Config.General.TempPath);*/
|
||||
C4Group_SetSortList(C4CFN_FLS);
|
||||
|
||||
// Store command line parameters
|
||||
globalArgC = argc;
|
||||
globalArgV = argv;
|
||||
// Store command line parameters
|
||||
globalArgC = argc;
|
||||
globalArgV = argv;
|
||||
|
||||
// Register shell
|
||||
if (fRegisterShell) {
|
||||
if (RegisterShellExtensions())
|
||||
printf("Shell extensions registered.\n");
|
||||
else
|
||||
printf("Error registering shell extensions.\n");
|
||||
}
|
||||
// Unregister shell
|
||||
if (fUnregisterShell) {
|
||||
if (UnregisterShellExtensions())
|
||||
printf("Shell extensions removed.\n");
|
||||
else
|
||||
printf("Error removing shell extensions.\n");
|
||||
}
|
||||
// Register shell
|
||||
if (fRegisterShell) {
|
||||
if (RegisterShellExtensions())
|
||||
printf("Shell extensions registered.\n");
|
||||
else
|
||||
printf("Error registering shell extensions.\n");
|
||||
}
|
||||
// Unregister shell
|
||||
if (fUnregisterShell) {
|
||||
if (UnregisterShellExtensions())
|
||||
printf("Shell extensions removed.\n");
|
||||
else
|
||||
printf("Error removing shell extensions.\n");
|
||||
}
|
||||
|
||||
// At least one parameter (filename, not option or command): process file(s)
|
||||
if (iFirstGroup) {
|
||||
// At least one parameter (filename, not option or command): process file(s)
|
||||
if (iFirstGroup) {
|
||||
#ifdef _WIN32
|
||||
// Wildcard in filename: use file search
|
||||
if (SCharCount('*', argv[1]))
|
||||
ForEachFile(argv[1], &ProcessGroup);
|
||||
// Only one file
|
||||
else
|
||||
ProcessGroup(argv[1]);
|
||||
// Wildcard in filename: use file search
|
||||
if (SCharCount('*', argv[1]))
|
||||
ForEachFile(argv[1], &ProcessGroup);
|
||||
// Only one file
|
||||
else
|
||||
ProcessGroup(argv[1]);
|
||||
#else
|
||||
for (int i = iFirstGroup; i < argc && argv[i][0] != '-'; ++i)
|
||||
ProcessGroup(argv[i]);
|
||||
for (int i = iFirstGroup; i < argc && argv[i][0] != '-'; ++i)
|
||||
ProcessGroup(argv[i]);
|
||||
#endif
|
||||
}
|
||||
// Too few parameters: output help (if we didn't register stuff)
|
||||
else if (!fRegisterShell && !fUnregisterShell) {
|
||||
printf("\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(" -l List -d Delete -r Rename -s Sort\n");
|
||||
printf(" -p Pack -u Unpack -x Explode\n");
|
||||
printf(" -k Print maker\n");
|
||||
printf(" -g [source] [target] [title] Make update\n");
|
||||
printf(" -y Apply update\n");
|
||||
printf("\n");
|
||||
printf("Options: -v Verbose -r Recursive\n");
|
||||
printf(" -i Register shell -u Unregister shell\n");
|
||||
printf(" -x:<command> Execute shell command when done\n");
|
||||
printf("\n");
|
||||
printf("Examples: c4group pack.c4g -a myfile.dat -l \"*.dat\"\n");
|
||||
printf(" c4group pack.c4g -as myfile.dat myfile.bin\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 -s \"*.bin|*.dat\"\n");
|
||||
printf(" c4group pack.c4g -x\n");
|
||||
printf(" c4group pack.c4g -k\n");
|
||||
printf(" c4group update.c4u -g ver1.c4f ver2.c4f New_Version\n");
|
||||
printf(" c4group -i\n");
|
||||
}
|
||||
}
|
||||
// Too few parameters: output help (if we didn't register stuff)
|
||||
else if (!fRegisterShell && !fUnregisterShell) {
|
||||
printf("\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(" -l List -d Delete -r Rename -s Sort\n");
|
||||
printf(" -p Pack -u Unpack -x Explode\n");
|
||||
printf(" -k Print maker\n");
|
||||
printf(" -g [source] [target] [title] Make update\n");
|
||||
printf(" -y Apply update\n");
|
||||
printf("\n");
|
||||
printf("Options: -v Verbose -r Recursive\n");
|
||||
printf(" -i Register shell -u Unregister shell\n");
|
||||
printf(" -x:<command> Execute shell command when done\n");
|
||||
printf("\n");
|
||||
printf("Examples: c4group pack.c4g -a myfile.dat -l \"*.dat\"\n");
|
||||
printf(" c4group pack.c4g -as myfile.dat myfile.bin\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 -s \"*.bin|*.dat\"\n");
|
||||
printf(" c4group pack.c4g -x\n");
|
||||
printf(" c4group pack.c4g -k\n");
|
||||
printf(" c4group update.c4u -g ver1.c4f ver2.c4f New_Version\n");
|
||||
printf(" c4group -i\n");
|
||||
}
|
||||
|
||||
// Execute when done
|
||||
if (strExecuteAtEnd[0])
|
||||
|
@ -547,7 +547,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
// Done
|
||||
return iResult;
|
||||
// Done
|
||||
return iResult;
|
||||
|
||||
}
|
||||
|
|
|
@ -577,9 +577,9 @@ void C4ConfigGeneral::DeterminePaths(bool forceWorkingDirectory)
|
|||
else
|
||||
SCopy("/tmp/", TempPath);
|
||||
#else
|
||||
// Mac: Just use the working directory as ExePath.
|
||||
// Mac: Just use the working directory as ExePath.
|
||||
SCopy(GetWorkingDirectory(), ExePath);
|
||||
AppendBackslash(ExePath);
|
||||
AppendBackslash(ExePath);
|
||||
SCopy("/tmp/", TempPath);
|
||||
#endif
|
||||
// Force working directory to exe path if desired
|
||||
|
@ -673,35 +673,35 @@ void C4ConfigGeneral::AddAdditionalDataPath(const char *szPath)
|
|||
char AtPathFilename[_MAX_PATH+1];
|
||||
|
||||
const char* C4Config::AtExePath(const char *szFilename)
|
||||
{
|
||||
{
|
||||
SCopy(General.ExePath,AtPathFilename,_MAX_PATH);
|
||||
SAppend(szFilename,AtPathFilename,_MAX_PATH);
|
||||
return AtPathFilename;
|
||||
}
|
||||
|
||||
const char* C4Config::AtUserDataPath(const char *szFilename)
|
||||
{
|
||||
{
|
||||
SCopy(General.UserDataPath, AtPathFilename, _MAX_PATH);
|
||||
SAppend(szFilename, AtPathFilename, _MAX_PATH);
|
||||
return AtPathFilename;
|
||||
}
|
||||
|
||||
const char* C4Config::AtSystemDataPath(const char *szFilename)
|
||||
{
|
||||
{
|
||||
SCopy(General.SystemDataPath, AtPathFilename, _MAX_PATH);
|
||||
SAppend(szFilename, AtPathFilename, _MAX_PATH);
|
||||
return AtPathFilename;
|
||||
}
|
||||
|
||||
const char* C4Config::AtTempPath(const char *szFilename)
|
||||
{
|
||||
{
|
||||
SCopy(General.TempPath,AtPathFilename,_MAX_PATH);
|
||||
SAppend(szFilename,AtPathFilename,_MAX_PATH);
|
||||
return AtPathFilename;
|
||||
}
|
||||
|
||||
const char* C4Config::AtNetworkPath(const char *szFilename)
|
||||
{
|
||||
{
|
||||
SCopy(General.UserDataPath,AtPathFilename,_MAX_PATH);
|
||||
SAppend(Network.WorkPath,AtPathFilename,_MAX_PATH);
|
||||
SAppend(szFilename,AtPathFilename,_MAX_PATH);
|
||||
|
|
|
@ -145,7 +145,7 @@ class C4ConfigGraphics
|
|||
class C4ConfigSound
|
||||
{
|
||||
public:
|
||||
int32_t RXSound;
|
||||
int32_t RXSound;
|
||||
int32_t RXMusic;
|
||||
int32_t FEMusic;
|
||||
int32_t FESamples;
|
||||
|
@ -165,7 +165,7 @@ class C4ConfigNetwork
|
|||
int32_t NoRuntimeJoin;
|
||||
int32_t NoReferenceRequest;
|
||||
int32_t MaxResSearchRecursion;
|
||||
char WorkPath[CFG_MaxString+1];
|
||||
char WorkPath[CFG_MaxString+1];
|
||||
ValidatedStdCopyStrBuf<C4InVal::VAL_Comment> Comment;
|
||||
int32_t MasterServerSignUp;
|
||||
int32_t MasterServerActive;
|
||||
|
@ -233,18 +233,18 @@ class C4ConfigExplorer
|
|||
public:
|
||||
int32_t Mode;
|
||||
int32_t Run;
|
||||
char Definitions[CFG_MaxString+1];
|
||||
char Definitions[CFG_MaxString+1];
|
||||
char Engines[CFG_MaxString+1];
|
||||
char EditorBitmap[CFG_MaxString+1];
|
||||
char EditorPNG[CFG_MaxString+1];
|
||||
char EditorMusic[CFG_MaxString+1];
|
||||
char EditorRichText[CFG_MaxString+1];
|
||||
char EditorScript[CFG_MaxString+1];
|
||||
char EditorText[CFG_MaxString+1];
|
||||
char EditorSound[CFG_MaxString+1];
|
||||
char EditorZip[CFG_MaxString+1];
|
||||
char EditorDefinition[CFG_MaxString+1];
|
||||
char EditorHtml[CFG_MaxString+1];
|
||||
char EditorBitmap[CFG_MaxString+1];
|
||||
char EditorPNG[CFG_MaxString+1];
|
||||
char EditorMusic[CFG_MaxString+1];
|
||||
char EditorRichText[CFG_MaxString+1];
|
||||
char EditorScript[CFG_MaxString+1];
|
||||
char EditorText[CFG_MaxString+1];
|
||||
char EditorSound[CFG_MaxString+1];
|
||||
char EditorZip[CFG_MaxString+1];
|
||||
char EditorDefinition[CFG_MaxString+1];
|
||||
char EditorHtml[CFG_MaxString+1];
|
||||
char CommandLine[CFG_MaxString+1];
|
||||
int32_t EditorUseShell;
|
||||
int32_t Kindersicherung;
|
||||
|
@ -275,7 +275,7 @@ class C4ConfigControls
|
|||
public:
|
||||
int32_t GamepadGuiControl;
|
||||
int32_t MouseAScroll; // auto scroll strength
|
||||
int32_t Keyboard[C4MaxKeyboardSet][C4MaxKey];
|
||||
int32_t Keyboard[C4MaxKeyboardSet][C4MaxKey];
|
||||
void CompileFunc(StdCompiler *pComp, bool fKeysOnly=false);
|
||||
void ResetKeys(); // reset all keys to default
|
||||
};
|
||||
|
|
|
@ -63,7 +63,7 @@ EVP_PKEY* loadPublicKey(const char *memKey, bool deBase64 = false, bool deXOR =
|
|||
unsigned int keyDataLen;
|
||||
memset(keyData, 0, maxKeyDataLen + 1);
|
||||
|
||||
// De-base64 certificate
|
||||
// De-base64 certificate
|
||||
if (deBase64)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
// De-XOR certificate
|
||||
// De-XOR certificate
|
||||
if (deXOR)
|
||||
{
|
||||
int xorStrLen = strlen(strXOR);
|
||||
|
@ -102,7 +102,7 @@ EVP_PKEY* loadPublicKey(const char *memKey, bool deBase64 = false, bool deXOR =
|
|||
|
||||
void clearPublicKey(EVP_PKEY* pubKey)
|
||||
{
|
||||
EVP_PKEY_free(pubKey);
|
||||
EVP_PKEY_free(pubKey);
|
||||
}
|
||||
|
||||
// Verifies the specified block of data using the public key provided.
|
||||
|
@ -268,7 +268,7 @@ C4ConfigShareware::~C4ConfigShareware()
|
|||
|
||||
void C4ConfigShareware::Default()
|
||||
{
|
||||
ZeroMem(this, sizeof (C4ConfigShareware));
|
||||
ZeroMem(this, sizeof (C4ConfigShareware));
|
||||
C4Config::Default();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
const size_t C4MaxTitle = 512;
|
||||
const int
|
||||
C4MaxDefString = 100,
|
||||
C4MaxDefString = 100,
|
||||
C4MaxMessage = 256,
|
||||
|
||||
C4ViewDelay = 100,
|
||||
|
@ -56,7 +56,7 @@ const int
|
|||
#define C4GRI_USER 8
|
||||
|
||||
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
|
||||
|
||||
const int C4S_MaxPlayer = 4;
|
||||
|
@ -74,10 +74,10 @@ const int C4P_MaxPosition = 4;
|
|||
|
||||
const int C4P_Control_None = -1,
|
||||
C4P_Control_Keyboard1 = 0,
|
||||
C4P_Control_Keyboard2 = 1,
|
||||
C4P_Control_Keyboard3 = 2,
|
||||
C4P_Control_Keyboard4 = 3,
|
||||
C4P_Control_GamePad1 = 4,
|
||||
C4P_Control_Keyboard2 = 1,
|
||||
C4P_Control_Keyboard3 = 2,
|
||||
C4P_Control_Keyboard4 = 3,
|
||||
C4P_Control_GamePad1 = 4,
|
||||
C4P_Control_GamePad2 = 5,
|
||||
C4P_Control_GamePad3 = 6,
|
||||
C4P_Control_GamePad4 = 7,
|
||||
|
@ -96,22 +96,22 @@ const int C4XRV_Completed = 0,
|
|||
const uint32_t OCF_None=0,
|
||||
OCF_All=~OCF_None,
|
||||
OCF_Normal=1,
|
||||
OCF_Construct=1<<1,
|
||||
OCF_Construct=1<<1,
|
||||
OCF_Grab=1<<2,
|
||||
OCF_Carryable=1<<3,
|
||||
OCF_OnFire=1<<4,
|
||||
OCF_OnFire=1<<4,
|
||||
OCF_HitSpeed1=1<<5,
|
||||
OCF_FullCon=1<<6,
|
||||
OCF_Inflammable=1<<7,
|
||||
OCF_Inflammable=1<<7,
|
||||
OCF_Chop=1<<8,
|
||||
OCF_Rotate=1<<9,
|
||||
OCF_Exclusive=1<<10,
|
||||
OCF_Exclusive=1<<10,
|
||||
OCF_Entrance=1<<11,
|
||||
OCF_HitSpeed2=1<<12,
|
||||
OCF_HitSpeed2=1<<12,
|
||||
OCF_HitSpeed3=1<<13,
|
||||
OCF_Collection=1<<14,
|
||||
OCF_Collection=1<<14,
|
||||
OCF_Living=1<<15,
|
||||
OCF_HitSpeed4=1<<16,
|
||||
OCF_HitSpeed4=1<<16,
|
||||
OCF_FightReady=1<<17,
|
||||
OCF_LineConstruct=1<<18,
|
||||
OCF_Prey=1<<19,
|
||||
|
@ -134,7 +134,7 @@ const BYTE // Directional
|
|||
CNAT_None = 0,
|
||||
CNAT_Left = 1,
|
||||
CNAT_Right = 2,
|
||||
CNAT_Top = 4,
|
||||
CNAT_Top = 4,
|
||||
CNAT_Bottom = 8,
|
||||
CNAT_Center = 16,
|
||||
// Additional flags
|
||||
|
@ -163,16 +163,16 @@ const int CON_CursorLeft = 0,
|
|||
//=================================== Control Commands ======================================================
|
||||
|
||||
const BYTE COM_Single = 64,
|
||||
COM_Double = 128;
|
||||
COM_Double = 128;
|
||||
|
||||
const BYTE COM_None = 0;
|
||||
|
||||
const BYTE COM_Left = 1,
|
||||
COM_Right = 2,
|
||||
COM_Up = 3,
|
||||
COM_Down = 4,
|
||||
COM_Throw = 5,
|
||||
COM_Dig = 6,
|
||||
COM_Right = 2,
|
||||
COM_Up = 3,
|
||||
COM_Down = 4,
|
||||
COM_Throw = 5,
|
||||
COM_Dig = 6,
|
||||
|
||||
COM_Special = 7,
|
||||
COM_Special2 = 8,
|
||||
|
@ -182,60 +182,60 @@ const BYTE COM_Left = 1,
|
|||
COM_WheelUp = 10,
|
||||
COM_WheelDown= 11,
|
||||
|
||||
COM_Left_R = COM_Left + 16,
|
||||
COM_Right_R = COM_Right + 16,
|
||||
COM_Up_R = COM_Up + 16,
|
||||
COM_Down_R = COM_Down + 16,
|
||||
COM_Throw_R = COM_Throw + 16,
|
||||
COM_Dig_R = COM_Dig + 16,
|
||||
COM_Special_R = COM_Special + 16,
|
||||
COM_Special2_R = COM_Special2 + 16,
|
||||
COM_ReleaseFirst = COM_Left_R,
|
||||
COM_ReleaseLast = COM_Special2_R,
|
||||
COM_Left_R = COM_Left + 16,
|
||||
COM_Right_R = COM_Right + 16,
|
||||
COM_Up_R = COM_Up + 16,
|
||||
COM_Down_R = COM_Down + 16,
|
||||
COM_Throw_R = COM_Throw + 16,
|
||||
COM_Dig_R = COM_Dig + 16,
|
||||
COM_Special_R = COM_Special + 16,
|
||||
COM_Special2_R = COM_Special2 + 16,
|
||||
COM_ReleaseFirst = COM_Left_R,
|
||||
COM_ReleaseLast = COM_Special2_R,
|
||||
|
||||
COM_Left_S = COM_Left | COM_Single,
|
||||
COM_Right_S = COM_Right | COM_Single,
|
||||
COM_Up_S = COM_Up | COM_Single,
|
||||
COM_Down_S = COM_Down | COM_Single,
|
||||
COM_Right_S = COM_Right | COM_Single,
|
||||
COM_Up_S = COM_Up | COM_Single,
|
||||
COM_Down_S = COM_Down | COM_Single,
|
||||
COM_Throw_S = COM_Throw | COM_Single,
|
||||
COM_Dig_S = COM_Dig | COM_Single,
|
||||
COM_Special_S = COM_Special | COM_Single,
|
||||
COM_Special2_S = COM_Special2 | COM_Single,
|
||||
COM_Dig_S = COM_Dig | COM_Single,
|
||||
COM_Special_S = COM_Special | COM_Single,
|
||||
COM_Special2_S = COM_Special2 | COM_Single,
|
||||
|
||||
COM_Left_D = COM_Left | COM_Double,
|
||||
COM_Right_D = COM_Right | 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_Dig_D = COM_Dig | COM_Double,
|
||||
COM_Special_D = COM_Special | COM_Double,
|
||||
COM_Special2_D = COM_Special2 | COM_Double;
|
||||
COM_Special_D = COM_Special | COM_Double,
|
||||
COM_Special2_D = COM_Special2 | COM_Double;
|
||||
|
||||
const BYTE COM_CursorLeft = 30,
|
||||
COM_CursorRight = 31,
|
||||
COM_CursorToggle = 32;
|
||||
COM_CursorRight = 31,
|
||||
COM_CursorToggle = 32;
|
||||
|
||||
const BYTE COM_CursorToggle_D = COM_CursorToggle | COM_Double;
|
||||
|
||||
const BYTE COM_Help = 35,
|
||||
COM_PlayerMenu = 36,
|
||||
COM_Chat = 37;
|
||||
COM_Chat = 37;
|
||||
|
||||
const BYTE COM_MenuEnter = 38,
|
||||
COM_MenuEnterAll = 39,
|
||||
COM_MenuClose = 40,
|
||||
COM_MenuShowText = 42,
|
||||
COM_MenuLeft = 52,
|
||||
COM_MenuRight = 53,
|
||||
COM_MenuUp = 54,
|
||||
COM_MenuDown = 55,
|
||||
COM_MenuSelect = 60,
|
||||
COM_MenuEnterAll = 39,
|
||||
COM_MenuClose = 40,
|
||||
COM_MenuShowText = 42,
|
||||
COM_MenuLeft = 52,
|
||||
COM_MenuRight = 53,
|
||||
COM_MenuUp = 54,
|
||||
COM_MenuDown = 55,
|
||||
COM_MenuSelect = 60,
|
||||
|
||||
COM_MenuFirst = COM_MenuEnter,
|
||||
COM_MenuLast = COM_MenuSelect,
|
||||
COM_MenuFirst = COM_MenuEnter,
|
||||
COM_MenuLast = COM_MenuSelect,
|
||||
|
||||
COM_MenuNavigation1 = COM_MenuShowText,
|
||||
COM_MenuNavigation2 = COM_MenuSelect;
|
||||
COM_MenuNavigation1 = COM_MenuShowText,
|
||||
COM_MenuNavigation2 = COM_MenuSelect;
|
||||
|
||||
//=================================== SendCommand ========================================
|
||||
const int32_t C4P_Command_None = 0,
|
||||
|
@ -247,7 +247,7 @@ const int32_t C4P_Command_None = 0,
|
|||
//=================================== Owners ==============================================
|
||||
|
||||
const int NO_OWNER = -1,
|
||||
ANY_OWNER = -2,
|
||||
ANY_OWNER = -2,
|
||||
BY_OWNER = 10000,
|
||||
BY_HOSTILE_OWNER = 20000;
|
||||
|
||||
|
@ -255,9 +255,9 @@ const int NO_OWNER = -1,
|
|||
|
||||
enum C4LeagueDisconnectReason
|
||||
{
|
||||
C4LDR_Unknown,
|
||||
C4LDR_ConnectionFailed,
|
||||
C4LDR_Desync
|
||||
C4LDR_Unknown,
|
||||
C4LDR_ConnectionFailed,
|
||||
C4LDR_Desync
|
||||
};
|
||||
|
||||
//=================================== Player (included by C4PlayerInfo and C4Player)
|
||||
|
@ -265,7 +265,7 @@ enum C4LeagueDisconnectReason
|
|||
enum C4PlayerType
|
||||
{
|
||||
C4PT_None=0,
|
||||
C4PT_User=1, // Normal player
|
||||
C4PT_User=1, // Normal player
|
||||
C4PT_Script=2 // AI players, etc.
|
||||
};
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ C4ControlPacket::~C4ControlPacket()
|
|||
|
||||
bool C4ControlPacket::LocalControl() const
|
||||
{
|
||||
return iByClient == ::Control.ClientID();
|
||||
return iByClient == ::Control.ClientID();
|
||||
}
|
||||
|
||||
void C4ControlPacket::SetByClient(int32_t inByClient)
|
||||
|
@ -92,9 +92,9 @@ void C4Control::Clear()
|
|||
|
||||
bool C4Control::PreExecute() const
|
||||
{
|
||||
bool fReady = true;
|
||||
for(C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
|
||||
{
|
||||
bool fReady = true;
|
||||
for(C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
|
||||
{
|
||||
// recheck packet type: Must be control
|
||||
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());
|
||||
}
|
||||
}
|
||||
return fReady;
|
||||
}
|
||||
return fReady;
|
||||
}
|
||||
|
||||
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
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void C4Control::PreRec(C4Record *pRecord) const
|
||||
{
|
||||
for(C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
|
||||
{
|
||||
C4ControlPacket *pCtrlPkt = static_cast<C4ControlPacket *>(pPkt->getPkt());
|
||||
if(pCtrlPkt)
|
||||
pCtrlPkt->PreRec(pRecord);
|
||||
}
|
||||
for(C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
|
||||
{
|
||||
C4ControlPacket *pCtrlPkt = static_cast<C4ControlPacket *>(pPkt->getPkt());
|
||||
if(pCtrlPkt)
|
||||
pCtrlPkt->PreRec(pRecord);
|
||||
}
|
||||
}
|
||||
|
||||
void C4Control::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(Pkts);
|
||||
pComp->Value(Pkts);
|
||||
}
|
||||
|
||||
// *** C4ControlSet
|
||||
|
@ -184,14 +184,14 @@ void C4ControlSet::Execute() const
|
|||
case C4CVT_MaxPlayer:
|
||||
// host only
|
||||
if(iByClient != C4ClientIDHost) break;
|
||||
// not in league
|
||||
if (Game.Parameters.isLeague())
|
||||
{
|
||||
Log("/set maxplayer disabled in league!");
|
||||
C4GUI::GUISound("Error");
|
||||
break;
|
||||
}
|
||||
// set it
|
||||
// not in league
|
||||
if (Game.Parameters.isLeague())
|
||||
{
|
||||
Log("/set maxplayer disabled in league!");
|
||||
C4GUI::GUISound("Error");
|
||||
break;
|
||||
}
|
||||
// set it
|
||||
Game.Parameters.MaxPlayers = iData;
|
||||
LogF("MaxPlayer = %d", (int)Game.Parameters.MaxPlayers);
|
||||
break;
|
||||
|
@ -210,7 +210,7 @@ void C4ControlSet::Execute() const
|
|||
Game.Teams.SetTeamColors(!!iData);
|
||||
break;
|
||||
|
||||
case C4CVT_FairCrew:
|
||||
case C4CVT_FairCrew:
|
||||
// host only
|
||||
if(!HostControl()) break;
|
||||
// deny setting if it's fixed by scenario
|
||||
|
@ -219,17 +219,17 @@ void C4ControlSet::Execute() const
|
|||
if (::Control.isCtrlHost()) Log(LoadResStr("IDS_MSG_NOMODIFYFAIRCREW"));
|
||||
break;
|
||||
}
|
||||
// set new value
|
||||
if(iData < 0)
|
||||
{
|
||||
Game.Parameters.UseFairCrew = false;
|
||||
Game.Parameters.FairCrewStrength = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Game.Parameters.UseFairCrew = true;
|
||||
Game.Parameters.FairCrewStrength = iData;
|
||||
}
|
||||
// set new value
|
||||
if(iData < 0)
|
||||
{
|
||||
Game.Parameters.UseFairCrew = false;
|
||||
Game.Parameters.FairCrewStrength = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Game.Parameters.UseFairCrew = true;
|
||||
Game.Parameters.FairCrewStrength = iData;
|
||||
}
|
||||
// runtime updates for runtime fairness adjustments
|
||||
if (Game.IsRunning)
|
||||
{
|
||||
|
@ -254,15 +254,15 @@ void C4ControlSet::Execute() const
|
|||
// this setting is part of the reference
|
||||
if (::Network.isEnabled() && ::Network.isHost())
|
||||
::Network.InvalidateReference();
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void C4ControlSet::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(mkIntAdapt(eValType), "Type", C4CVT_None));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iData), "Data", 0));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
pComp->Value(mkNamingAdapt(mkIntAdapt(eValType), "Type", C4CVT_None));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iData), "Data", 0));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
}
|
||||
|
||||
// *** C4ControlScript
|
||||
|
@ -311,10 +311,10 @@ void C4ControlScript::Execute() const
|
|||
|
||||
void C4ControlScript::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(iTargetObj, "TargetObj", -1));
|
||||
pComp->Value(mkNamingAdapt(fInternal, "Internal", false));
|
||||
pComp->Value(mkNamingAdapt(Script, "Script", ""));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
pComp->Value(mkNamingAdapt(iTargetObj, "TargetObj", -1));
|
||||
pComp->Value(mkNamingAdapt(fInternal, "Internal", false));
|
||||
pComp->Value(mkNamingAdapt(Script, "Script", ""));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
}
|
||||
|
||||
// *** C4ControlPlayerSelect
|
||||
|
@ -365,15 +365,15 @@ void C4ControlPlayerSelect::Execute() const
|
|||
|
||||
void C4ControlPlayerSelect::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(iPlr, "Player", -1));
|
||||
pComp->Value(mkNamingAdapt(fIsAlt, "IsAlt", false));
|
||||
pComp->Value(mkNamingAdapt(iObjCnt, "ObjCnt", 0));
|
||||
// Compile array
|
||||
if(pComp->isCompiler())
|
||||
pComp->Value(mkNamingAdapt(iPlr, "Player", -1));
|
||||
pComp->Value(mkNamingAdapt(fIsAlt, "IsAlt", false));
|
||||
pComp->Value(mkNamingAdapt(iObjCnt, "ObjCnt", 0));
|
||||
// Compile array
|
||||
if(pComp->isCompiler())
|
||||
{ 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)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iPlr), "Player", -1));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iCmd), "Cmd", 0));
|
||||
pComp->Value(mkNamingAdapt(iX, "X", 0));
|
||||
pComp->Value(mkNamingAdapt(iY, "Y", 0));
|
||||
pComp->Value(mkNamingAdapt(iTarget, "Target", 0));
|
||||
pComp->Value(mkNamingAdapt(iTarget2, "Target2", 0));
|
||||
pComp->Value(mkNamingAdapt(iData, "Data", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iAddMode), "AddMode", 0));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iPlr), "Player", -1));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iCmd), "Cmd", 0));
|
||||
pComp->Value(mkNamingAdapt(iX, "X", 0));
|
||||
pComp->Value(mkNamingAdapt(iY, "Y", 0));
|
||||
pComp->Value(mkNamingAdapt(iTarget, "Target", 0));
|
||||
pComp->Value(mkNamingAdapt(iTarget2, "Target2", 0));
|
||||
pComp->Value(mkNamingAdapt(iData, "Data", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iAddMode), "AddMode", 0));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
}
|
||||
|
||||
// *** C4ControlSyncCheck
|
||||
|
@ -464,7 +464,7 @@ void C4ControlSyncCheck::Set()
|
|||
{
|
||||
extern int32_t FRndPtr3;
|
||||
Frame = Game.FrameCounter;
|
||||
ControlTick = ::Control.ControlTick;
|
||||
ControlTick = ::Control.ControlTick;
|
||||
Random3 = FRndPtr3;
|
||||
RandomCount = ::RandomCount;
|
||||
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());
|
||||
StartSoundEffect("SyncError");
|
||||
#ifdef _DEBUG
|
||||
// Debug safe
|
||||
// Debug safe
|
||||
C4GameSaveNetwork SaveGame(false);
|
||||
SaveGame.Save(Config.AtExePath("Desync.c4s"));
|
||||
#endif
|
||||
|
@ -538,17 +538,17 @@ void C4ControlSyncCheck::Execute() const
|
|||
|
||||
void C4ControlSyncCheck::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(Frame), "Frame", -1));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(ControlTick), "ControlTick", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(Random3), "Random3", 0));
|
||||
pComp->Value(mkNamingAdapt(RandomCount, "RandomCount", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(AllCrewPosX), "AllCrewPosX", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(PXSCount), "PXSCount", 0));
|
||||
pComp->Value(mkNamingAdapt(MassMoverIndex, "MassMoverIndex", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(ObjectCount), "ObjectCount", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(ObjectEnumerationIndex), "ObjectEnumerationIndex", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(SectShapeSum), "SectShapeSum", 0));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(Frame), "Frame", -1));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(ControlTick), "ControlTick", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(Random3), "Random3", 0));
|
||||
pComp->Value(mkNamingAdapt(RandomCount, "RandomCount", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(AllCrewPosX), "AllCrewPosX", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(PXSCount), "PXSCount", 0));
|
||||
pComp->Value(mkNamingAdapt(MassMoverIndex, "MassMoverIndex", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(ObjectCount), "ObjectCount", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(ObjectEnumerationIndex), "ObjectEnumerationIndex", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(SectShapeSum), "SectShapeSum", 0));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
}
|
||||
|
||||
// *** C4ControlSynchronize
|
||||
|
@ -556,14 +556,14 @@ void C4ControlSyncCheck::CompileFunc(StdCompiler *pComp)
|
|||
void C4ControlSynchronize::Execute() const
|
||||
{
|
||||
Game.Synchronize(fSavePlrFiles);
|
||||
if(fSyncClearance) Game.SyncClearance();
|
||||
if(fSyncClearance) Game.SyncClearance();
|
||||
}
|
||||
|
||||
void C4ControlSynchronize::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(fSavePlrFiles, "SavePlrs", false));
|
||||
pComp->Value(mkNamingAdapt(fSyncClearance, "SyncClear", false));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
pComp->Value(mkNamingAdapt(fSavePlrFiles, "SavePlrs", false));
|
||||
pComp->Value(mkNamingAdapt(fSyncClearance, "SyncClear", false));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
}
|
||||
|
||||
// *** C4ControlClientJoin
|
||||
|
@ -608,7 +608,7 @@ void C4ControlClientUpdate::Execute() const
|
|||
// nothing to do?
|
||||
if(pClient->isActivated() == !!iData) break;
|
||||
// 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
|
||||
pClient->SetActivated(!!iData);
|
||||
// local?
|
||||
|
@ -619,7 +619,7 @@ void C4ControlClientUpdate::Execute() const
|
|||
// nothing to do?
|
||||
if(pClient->isObserver()) break;
|
||||
// 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)
|
||||
pClient->SetObserver();
|
||||
// local?
|
||||
|
@ -670,7 +670,7 @@ void C4ControlClientRemove::Execute() const
|
|||
// remove client
|
||||
if(!Game.Clients.Remove(pClient)) return;
|
||||
// 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
|
||||
::Players.RemoveAtClient(iID, true);
|
||||
// remove all resources
|
||||
|
@ -762,8 +762,8 @@ void C4ControlJoinPlayer::Execute() const
|
|||
// Local player: Just join from local file
|
||||
Game.JoinPlayer(szFilename, iAtClient, pClient->getName(), pInfo);
|
||||
}
|
||||
else if(!fByRes)
|
||||
{
|
||||
else if(!fByRes)
|
||||
{
|
||||
if (PlrData.getSize())
|
||||
{
|
||||
// create temp file
|
||||
|
@ -788,7 +788,7 @@ void C4ControlJoinPlayer::Execute() const
|
|||
assert(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(::Control.isNetwork())
|
||||
{
|
||||
// Find ressource
|
||||
|
@ -811,12 +811,12 @@ void C4ControlJoinPlayer::Strip()
|
|||
{
|
||||
// By resource? Can't touch player file, then.
|
||||
if(fByRes) return;
|
||||
// create temp file
|
||||
// create temp file
|
||||
StdStrBuf PlayerFilename; PlayerFilename = GetFilename(Filename.getData());
|
||||
PlayerFilename = Config.AtTempPath(PlayerFilename.getData());
|
||||
PlayerFilename = Config.AtTempPath(PlayerFilename.getData());
|
||||
// Copy to it
|
||||
if(PlrData.SaveToFile(PlayerFilename.getData()))
|
||||
{
|
||||
if(PlrData.SaveToFile(PlayerFilename.getData()))
|
||||
{
|
||||
// open as group
|
||||
C4Group Grp;
|
||||
if(!Grp.Open(PlayerFilename.getData()))
|
||||
|
@ -836,29 +836,29 @@ void C4ControlJoinPlayer::Strip()
|
|||
PlrData = NewPlrData;
|
||||
// Done
|
||||
EraseFile(PlayerFilename.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool C4ControlJoinPlayer::PreExecute() const
|
||||
{
|
||||
// all data included in control packet?
|
||||
if(!fByRes) return true;
|
||||
// all data included in control packet?
|
||||
if(!fByRes) return true;
|
||||
// client lost?
|
||||
if(!Game.Clients.getClientByID(iAtClient)) return true;
|
||||
// network only
|
||||
// network only
|
||||
if(!::Control.isNetwork()) return true;
|
||||
// search ressource
|
||||
// search ressource
|
||||
C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(ResCore.getID());
|
||||
// doesn't exist? start loading
|
||||
if(!pRes) { pRes = ::Network.ResList.AddByCore(ResCore, true); }
|
||||
if(!pRes) return true;
|
||||
// is loading or removed?
|
||||
// is loading or removed?
|
||||
return !pRes->isLoading();
|
||||
}
|
||||
|
||||
void C4ControlJoinPlayer::PreRec(C4Record *pRecord)
|
||||
{
|
||||
if(!pRecord) return;
|
||||
if(!pRecord) return;
|
||||
if (fByRes)
|
||||
{
|
||||
// get local file by id
|
||||
|
@ -882,22 +882,22 @@ void C4ControlJoinPlayer::PreRec(C4Record *pRecord)
|
|||
|
||||
void C4ControlJoinPlayer::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(mkNetFilenameAdapt(Filename), "Filename", ""));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iAtClient), "AtClient", -1));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(idInfo), "InfoID", -1));
|
||||
pComp->Value(mkNamingAdapt(fByRes, "ByRes", false));
|
||||
if(fByRes)
|
||||
pComp->Value(mkNamingAdapt(ResCore, "ResCore"));
|
||||
else
|
||||
pComp->Value(mkNamingAdapt(PlrData, "PlrData"));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
pComp->Value(mkNamingAdapt(mkNetFilenameAdapt(Filename), "Filename", ""));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iAtClient), "AtClient", -1));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(idInfo), "InfoID", -1));
|
||||
pComp->Value(mkNamingAdapt(fByRes, "ByRes", false));
|
||||
if(fByRes)
|
||||
pComp->Value(mkNamingAdapt(ResCore, "ResCore"));
|
||||
else
|
||||
pComp->Value(mkNamingAdapt(PlrData, "PlrData"));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
}
|
||||
|
||||
// *** C4ControlEMMoveObject
|
||||
|
||||
C4ControlEMMoveObject::C4ControlEMMoveObject(C4ControlEMObjectAction eAction, int32_t tx, int32_t ty, C4Object *pTargetObj,
|
||||
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)
|
||||
{
|
||||
|
||||
|
@ -953,26 +953,26 @@ void C4ControlEMMoveObject::Execute() const
|
|||
}
|
||||
// update status
|
||||
if (fLocalCall)
|
||||
{
|
||||
{
|
||||
Console.EditCursor.SetHold(true);
|
||||
Console.PropertyDlg.Update(Console.EditCursor.GetSelection());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EMMO_Script:
|
||||
{
|
||||
if(!pObjects) return;
|
||||
// execute script ...
|
||||
C4ControlScript ScriptCtrl(Script.getData(), C4ControlScript::SCOPE_Global, false);
|
||||
ScriptCtrl.SetByClient(iByClient);
|
||||
// ... for each object in selection
|
||||
// execute script ...
|
||||
C4ControlScript ScriptCtrl(Script.getData(), C4ControlScript::SCOPE_Global, false);
|
||||
ScriptCtrl.SetByClient(iByClient);
|
||||
// ... for each object in selection
|
||||
for (int i=0; i<iObjectNum; ++i)
|
||||
{
|
||||
ScriptCtrl.SetTargetObj(pObjects[i]);
|
||||
ScriptCtrl.Execute();
|
||||
}
|
||||
{
|
||||
ScriptCtrl.SetTargetObj(pObjects[i]);
|
||||
ScriptCtrl.Execute();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
case EMMO_Remove:
|
||||
{
|
||||
if(!pObjects) return;
|
||||
|
@ -982,7 +982,7 @@ void C4ControlEMMoveObject::Execute() const
|
|||
if ((pObj = ::Objects.SafeObjectPointer(pObjects[i])))
|
||||
pObj->AssignRemoval();
|
||||
}
|
||||
break; // Here was fallthrough. Seemed wrong. ck.
|
||||
break; // Here was fallthrough. Seemed wrong. ck.
|
||||
case EMMO_Exit:
|
||||
{
|
||||
if(!pObjects) return;
|
||||
|
@ -992,12 +992,12 @@ void C4ControlEMMoveObject::Execute() const
|
|||
if ((pObj = ::Objects.SafeObjectPointer(pObjects[i])))
|
||||
pObj->Exit(pObj->GetX(), pObj->GetY(), pObj->r);
|
||||
}
|
||||
break; // Same. ck.
|
||||
}
|
||||
break; // Same. ck.
|
||||
}
|
||||
// update property dlg & status bar
|
||||
if(fLocalCall)
|
||||
Console.EditCursor.OnSelectionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void C4ControlEMMoveObject::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
|
@ -1006,11 +1006,11 @@ void C4ControlEMMoveObject::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt(ty, "ty", 0));
|
||||
pComp->Value(mkNamingAdapt(iTargetObj, "TargetObj", -1));
|
||||
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));
|
||||
if(eAction == EMMO_Script)
|
||||
pComp->Value(mkNamingAdapt(Script, "Script", ""));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
if(eAction == EMMO_Script)
|
||||
pComp->Value(mkNamingAdapt(Script, "Script", ""));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
}
|
||||
|
||||
// *** C4ControlEMDrawTool
|
||||
|
@ -1098,7 +1098,7 @@ void C4ControlMessage::Execute() const
|
|||
C4GameLobby::MainDlg *pLobby = ::Network.GetLobby();
|
||||
StdStrBuf str;
|
||||
switch(eType)
|
||||
{
|
||||
{
|
||||
case C4CMT_Normal:
|
||||
case C4CMT_Me:
|
||||
// log it
|
||||
|
@ -1190,23 +1190,23 @@ void C4ControlMessage::Execute() const
|
|||
Application.NotifyUserIfInactive();
|
||||
break;
|
||||
|
||||
case C4CMT_System:
|
||||
// sender must be host
|
||||
if(!HostControl()) break;
|
||||
// show
|
||||
LogF("Network: %s", szMessage);
|
||||
break;
|
||||
case C4CMT_System:
|
||||
// sender must be host
|
||||
if(!HostControl()) break;
|
||||
// show
|
||||
LogF("Network: %s", szMessage);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void C4ControlMessage::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(mkIntAdaptT<uint8_t>(eType), "Type", C4CMT_Normal));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iPlayer), "Player", -1));
|
||||
pComp->Value(mkNamingAdapt(mkIntAdaptT<uint8_t>(eType), "Type", C4CMT_Normal));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iPlayer), "Player", -1));
|
||||
if(eType == C4CMT_Private)
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iToPlayer), "ToPlayer", -1));
|
||||
pComp->Value(mkNamingAdapt(Message, "Message", ""));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iToPlayer), "ToPlayer", -1));
|
||||
pComp->Value(mkNamingAdapt(Message, "Message", ""));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
}
|
||||
|
||||
|
@ -1234,8 +1234,8 @@ void C4ControlPlayerInfo::Execute() const
|
|||
|
||||
void C4ControlPlayerInfo::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(PlrInfo);
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
pComp->Value(PlrInfo);
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
}
|
||||
|
||||
// *** C4ControlRemovePlr
|
||||
|
@ -1250,8 +1250,8 @@ void C4ControlRemovePlr::Execute() const
|
|||
|
||||
void C4ControlRemovePlr::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iPlr), "Plr", -1));
|
||||
pComp->Value(mkNamingAdapt(fDisconnected, "Disconnected", false));
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(iPlr), "Plr", -1));
|
||||
pComp->Value(mkNamingAdapt(fDisconnected, "Disconnected", false));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
}
|
||||
|
||||
|
@ -1264,7 +1264,7 @@ void C4ControlDebugRec::Execute() const
|
|||
|
||||
void C4ControlDebugRec::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(Data);
|
||||
pComp->Value(Data);
|
||||
}
|
||||
|
||||
// *** C4ControlVote
|
||||
|
@ -1397,9 +1397,9 @@ void C4ControlVote::Execute() const
|
|||
|
||||
void C4ControlVote::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(mkIntAdaptT<uint8_t>(eType), "Type", VT_None));
|
||||
pComp->Value(mkNamingAdapt(fApprove, "Approve", true));
|
||||
pComp->Value(mkNamingAdapt(iData, "Data", 0));
|
||||
pComp->Value(mkNamingAdapt(mkIntAdaptT<uint8_t>(eType), "Type", VT_None));
|
||||
pComp->Value(mkNamingAdapt(fApprove, "Approve", true));
|
||||
pComp->Value(mkNamingAdapt(iData, "Data", 0));
|
||||
C4ControlPacket::CompileFunc(pComp);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,13 +46,13 @@ protected:
|
|||
public:
|
||||
int32_t getByClient() const { return iByClient; }
|
||||
bool LocalControl() const;
|
||||
bool HostControl() const { return iByClient == C4ClientIDHost; }
|
||||
bool HostControl() const { return iByClient == C4ClientIDHost; }
|
||||
|
||||
void SetByClient(int32_t iByClient);
|
||||
|
||||
virtual bool PreExecute() const { return true; }
|
||||
virtual void Execute() const = 0;
|
||||
virtual void PreRec(C4Record *pRecord) { }
|
||||
virtual void PreRec(C4Record *pRecord) { }
|
||||
|
||||
// allowed in lobby (without dynamic loaded)?
|
||||
virtual bool Lobby() const { return false; }
|
||||
|
@ -73,11 +73,11 @@ public:
|
|||
~C4Control();
|
||||
|
||||
protected:
|
||||
C4PacketList Pkts;
|
||||
C4PacketList Pkts;
|
||||
|
||||
public:
|
||||
|
||||
void Clear();
|
||||
void Clear();
|
||||
|
||||
// packet list wrappers
|
||||
C4IDPacket *firstPkt() const { return Pkts.firstPkt(); }
|
||||
|
@ -86,9 +86,9 @@ public:
|
|||
void AddHead(C4PacketType eType, C4ControlPacket *pCtrl) { Pkts.AddHead(eType, pCtrl); }
|
||||
void Add(C4PacketType eType, C4ControlPacket *pCtrl) { Pkts.Add(eType, pCtrl); }
|
||||
|
||||
void Take(C4Control &Ctrl) { Pkts.Take(Ctrl.Pkts); }
|
||||
void Append(const C4Control &Ctrl) { Pkts.Append(Ctrl.Pkts); }
|
||||
void Copy(const C4Control &Ctrl) { Clear(); Pkts.Append(Ctrl.Pkts); }
|
||||
void Take(C4Control &Ctrl) { Pkts.Take(Ctrl.Pkts); }
|
||||
void Append(const C4Control &Ctrl) { Pkts.Append(Ctrl.Pkts); }
|
||||
void Copy(const C4Control &Ctrl) { Clear(); Pkts.Append(Ctrl.Pkts); }
|
||||
void Remove(C4IDPacket *pPkt) { Pkts.Remove(pPkt); }
|
||||
void Delete(C4IDPacket *pPkt) { Pkts.Delete(pPkt); }
|
||||
|
||||
|
@ -104,21 +104,21 @@ public:
|
|||
|
||||
enum C4CtrlValueType
|
||||
{
|
||||
C4CVT_None = -1,
|
||||
C4CVT_None = -1,
|
||||
C4CVT_ControlRate = 0,
|
||||
C4CVT_AllowDebug = 1,
|
||||
C4CVT_MaxPlayer = 2,
|
||||
C4CVT_TeamDistribution = 3,
|
||||
C4CVT_TeamColors = 4,
|
||||
C4CVT_FairCrew = 5
|
||||
C4CVT_FairCrew = 5
|
||||
};
|
||||
|
||||
class C4ControlSet : public C4ControlPacket // sync, lobby
|
||||
{
|
||||
public:
|
||||
C4ControlSet()
|
||||
: eValType(C4CVT_None), iData(0)
|
||||
{ }
|
||||
C4ControlSet()
|
||||
: eValType(C4CVT_None), iData(0)
|
||||
{ }
|
||||
C4ControlSet(C4CtrlValueType eValType, int32_t iData)
|
||||
: eValType(eValType), iData(iData)
|
||||
{ }
|
||||
|
@ -137,9 +137,9 @@ class C4ControlScript : public C4ControlPacket // sync
|
|||
public:
|
||||
enum { SCOPE_Console=-2, SCOPE_Global=-1 }; // special scopes to be passed as target objects
|
||||
|
||||
C4ControlScript()
|
||||
: iTargetObj(-1), fInternal(true)
|
||||
{ }
|
||||
C4ControlScript()
|
||||
: iTargetObj(-1), fInternal(true)
|
||||
{ }
|
||||
C4ControlScript(const char *szScript, int32_t iTargetObj = SCOPE_Global, bool fInternal = true)
|
||||
: iTargetObj(iTargetObj), fInternal(fInternal), Script(szScript, true)
|
||||
{ }
|
||||
|
@ -155,8 +155,8 @@ public:
|
|||
class C4ControlPlayerSelect : public C4ControlPacket // sync
|
||||
{
|
||||
public:
|
||||
C4ControlPlayerSelect()
|
||||
: iPlr(-1), fIsAlt(false), iObjCnt(0), pObjNrs(NULL) { }
|
||||
C4ControlPlayerSelect()
|
||||
: iPlr(-1), fIsAlt(false), iObjCnt(0), pObjNrs(NULL) { }
|
||||
C4ControlPlayerSelect(int32_t iPlr, const C4ObjectList &Objs, bool fIsAlt);
|
||||
~C4ControlPlayerSelect() { delete[] pObjNrs; }
|
||||
protected:
|
||||
|
@ -204,8 +204,8 @@ public:
|
|||
class C4ControlPlayerCommand : public C4ControlPacket // sync
|
||||
{
|
||||
public:
|
||||
C4ControlPlayerCommand()
|
||||
: iPlr(-1), iCmd(-1) { }
|
||||
C4ControlPlayerCommand()
|
||||
: iPlr(-1), iCmd(-1) { }
|
||||
C4ControlPlayerCommand(int32_t iPlr, int32_t iCmd, int32_t iX, int32_t iY,
|
||||
C4Object *pTarget, C4Object *pTarget2, int32_t iData, int32_t iAddMode);
|
||||
protected:
|
||||
|
@ -232,7 +232,7 @@ protected:
|
|||
public:
|
||||
void Set();
|
||||
int32_t getFrame() const { return Frame; }
|
||||
virtual bool Sync() const { return false; }
|
||||
virtual bool Sync() const { return false; }
|
||||
DECLARE_C4CONTROL_VIRTUALS
|
||||
protected:
|
||||
static int32_t GetAllCrewPosX();
|
||||
|
@ -258,8 +258,8 @@ public:
|
|||
public:
|
||||
C4ClientCore Core;
|
||||
public:
|
||||
virtual bool Sync() const { return false; }
|
||||
virtual bool Lobby() const { return true; }
|
||||
virtual bool Sync() const { return false; }
|
||||
virtual bool Lobby() const { return true; }
|
||||
DECLARE_C4CONTROL_VIRTUALS
|
||||
};
|
||||
|
||||
|
@ -280,8 +280,8 @@ public:
|
|||
C4ControlClientUpdType eType;
|
||||
int32_t iData;
|
||||
public:
|
||||
virtual bool Sync() const { return false; }
|
||||
virtual bool Lobby() const { return true; }
|
||||
virtual bool Sync() const { return false; }
|
||||
virtual bool Lobby() const { return true; }
|
||||
DECLARE_C4CONTROL_VIRTUALS
|
||||
};
|
||||
|
||||
|
@ -294,8 +294,8 @@ public:
|
|||
int32_t iID;
|
||||
StdCopyStrBuf strReason;
|
||||
public:
|
||||
virtual bool Sync() const { return false; }
|
||||
virtual bool Lobby() const { return true; }
|
||||
virtual bool Sync() const { return false; }
|
||||
virtual bool Lobby() const { return true; }
|
||||
DECLARE_C4CONTROL_VIRTUALS
|
||||
};
|
||||
|
||||
|
@ -303,29 +303,29 @@ public:
|
|||
class C4ControlPlayerInfo : public C4ControlPacket // not sync, lobby
|
||||
{
|
||||
public:
|
||||
C4ControlPlayerInfo()
|
||||
{ }
|
||||
C4ControlPlayerInfo(const C4ClientPlayerInfos &PlrInfo)
|
||||
: PlrInfo(PlrInfo)
|
||||
{ }
|
||||
C4ControlPlayerInfo()
|
||||
{ }
|
||||
C4ControlPlayerInfo(const C4ClientPlayerInfos &PlrInfo)
|
||||
: PlrInfo(PlrInfo)
|
||||
{ }
|
||||
protected:
|
||||
C4ClientPlayerInfos PlrInfo;
|
||||
C4ClientPlayerInfos PlrInfo;
|
||||
public:
|
||||
const C4ClientPlayerInfos &GetInfo() const { return PlrInfo; }
|
||||
virtual bool Sync() const { return false; }
|
||||
virtual bool Lobby() const { return true; }
|
||||
DECLARE_C4CONTROL_VIRTUALS
|
||||
virtual bool Sync() const { return false; }
|
||||
virtual bool Lobby() const { return true; }
|
||||
DECLARE_C4CONTROL_VIRTUALS
|
||||
};
|
||||
|
||||
struct C4ControlJoinPlayer : public C4ControlPacket // sync
|
||||
{
|
||||
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);
|
||||
protected:
|
||||
StdStrBuf Filename;
|
||||
int32_t iAtClient;
|
||||
int32_t iAtClient;
|
||||
int32_t idInfo;
|
||||
bool fByRes;
|
||||
StdBuf PlrData; // for fByRes == false
|
||||
|
@ -350,7 +350,7 @@ enum C4ControlEMObjectAction
|
|||
class C4ControlEMMoveObject : public C4ControlPacket // sync
|
||||
{
|
||||
public:
|
||||
C4ControlEMMoveObject() : pObjects(NULL) { }
|
||||
C4ControlEMMoveObject() : pObjects(NULL) { }
|
||||
C4ControlEMMoveObject(C4ControlEMObjectAction eAction, int32_t tx, int32_t ty, C4Object *pTargetObj,
|
||||
int32_t iObjectNum = 0, int32_t *pObjects = NULL, const char *szScript = NULL);
|
||||
~C4ControlEMMoveObject();
|
||||
|
@ -360,7 +360,7 @@ protected:
|
|||
int32_t iTargetObj; // enumerated ptr to target object
|
||||
int32_t iObjectNum; // number of objects moved
|
||||
int32_t *pObjects; // pointer on array of objects moved
|
||||
StdStrBuf Script; // script to execute
|
||||
StdStrBuf Script; // script to execute
|
||||
public:
|
||||
DECLARE_C4CONTROL_VIRTUALS
|
||||
};
|
||||
|
@ -377,7 +377,7 @@ enum C4ControlEMDrawAction
|
|||
class C4ControlEMDrawTool : public C4ControlPacket // sync
|
||||
{
|
||||
public:
|
||||
C4ControlEMDrawTool() { }
|
||||
C4ControlEMDrawTool() { }
|
||||
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,
|
||||
bool fIFT=true, const char *szMaterial=NULL, const char *szTexture=NULL);
|
||||
|
@ -407,8 +407,8 @@ enum C4ControlMessageType
|
|||
class C4ControlMessage : public C4ControlPacket // not sync, lobby
|
||||
{
|
||||
public:
|
||||
C4ControlMessage()
|
||||
: eType(C4CMT_Normal), iPlayer(-1) { }
|
||||
C4ControlMessage()
|
||||
: eType(C4CMT_Normal), iPlayer(-1) { }
|
||||
C4ControlMessage(C4ControlMessageType eType, const char *szMessage, int32_t iPlayer = -1, int32_t iToPlayer = -1)
|
||||
: eType(eType), iPlayer(iPlayer), iToPlayer(iToPlayer), Message(szMessage, true)
|
||||
{ }
|
||||
|
@ -417,16 +417,16 @@ protected:
|
|||
int32_t iPlayer, iToPlayer;
|
||||
StdStrBuf Message;
|
||||
public:
|
||||
virtual bool Sync() const { return false; }
|
||||
virtual bool Lobby() const { return true; }
|
||||
virtual bool Sync() const { return false; }
|
||||
virtual bool Lobby() const { return true; }
|
||||
DECLARE_C4CONTROL_VIRTUALS
|
||||
};
|
||||
|
||||
class C4ControlRemovePlr : public C4ControlPacket // sync
|
||||
{
|
||||
public:
|
||||
C4ControlRemovePlr()
|
||||
: iPlr(-1) { }
|
||||
C4ControlRemovePlr()
|
||||
: iPlr(-1) { }
|
||||
C4ControlRemovePlr(int32_t iPlr, bool fDisconnected)
|
||||
: iPlr(iPlr), fDisconnected(fDisconnected) { }
|
||||
protected:
|
||||
|
@ -439,10 +439,10 @@ public:
|
|||
class C4ControlDebugRec : public C4ControlPacket // sync
|
||||
{
|
||||
public:
|
||||
C4ControlDebugRec()
|
||||
{ }
|
||||
C4ControlDebugRec(StdBuf &Data)
|
||||
: Data(Data) { }
|
||||
C4ControlDebugRec()
|
||||
{ }
|
||||
C4ControlDebugRec(StdBuf &Data)
|
||||
: Data(Data) { }
|
||||
protected:
|
||||
StdBuf Data;
|
||||
public:
|
||||
|
@ -452,7 +452,7 @@ public:
|
|||
enum C4ControlVoteType
|
||||
{
|
||||
VT_None = -1,
|
||||
VT_Cancel,
|
||||
VT_Cancel,
|
||||
VT_Kick,
|
||||
VT_Pause
|
||||
};
|
||||
|
@ -477,7 +477,7 @@ public:
|
|||
StdStrBuf getDesc() const;
|
||||
StdStrBuf getDescWarning() const;
|
||||
|
||||
virtual bool Sync() const { return false; }
|
||||
virtual bool Sync() const { return false; }
|
||||
|
||||
DECLARE_C4CONTROL_VIRTUALS
|
||||
};
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
C4GameControl::C4GameControl()
|
||||
: Network(this)
|
||||
{
|
||||
Default();
|
||||
Default();
|
||||
}
|
||||
|
||||
C4GameControl::~C4GameControl()
|
||||
|
@ -121,7 +121,7 @@ void C4GameControl::ChangeToLocal()
|
|||
// (otherwise, clients start game when host disconnected!)
|
||||
if (!C4GameOverDlg::IsShown()) Game.HaltCount = 0;
|
||||
|
||||
// set status
|
||||
// set status
|
||||
eMode = CM_Local; fHost = true;
|
||||
ControlRate = 1;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ void C4GameControl::OnGameSynchronizing()
|
|||
|
||||
bool C4GameControl::StartRecord(bool fInitial, bool fStreaming)
|
||||
{
|
||||
assert(fInitComplete);
|
||||
assert(fInitComplete);
|
||||
// already recording?
|
||||
if(pRecord) StopRecord();
|
||||
// start
|
||||
|
@ -170,7 +170,7 @@ void C4GameControl::StopRecord(StdStrBuf *pRecordName, BYTE *pRecordSHA1)
|
|||
if(pRecord)
|
||||
{
|
||||
::Network.FinishStreaming();
|
||||
pRecord->Stop(pRecordName, pRecordSHA1);
|
||||
pRecord->Stop(pRecordName, pRecordSHA1);
|
||||
// just delete
|
||||
delete pRecord; pRecord = NULL;
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ void C4GameControl::StopRecord(StdStrBuf *pRecordName, BYTE *pRecordSHA1)
|
|||
void C4GameControl::RequestRuntimeRecord()
|
||||
{
|
||||
if (!IsRuntimeRecordPossible()) return; // cannot record
|
||||
fRecordNeeded = true;
|
||||
fRecordNeeded = true;
|
||||
// request through a synchronize-call
|
||||
// currnetly do not request, but start record with next gamesync, so network runtime join can be debugged
|
||||
#ifndef DEBUGREC
|
||||
|
@ -209,30 +209,30 @@ void C4GameControl::Clear()
|
|||
{
|
||||
StopRecord();
|
||||
ChangeToLocal();
|
||||
Default();
|
||||
Default();
|
||||
}
|
||||
|
||||
void C4GameControl::Default()
|
||||
{
|
||||
Input.Clear();
|
||||
Network.Clear();
|
||||
Network.Clear();
|
||||
eMode = CM_None;
|
||||
fHost = fPreInit = fInitComplete = false;
|
||||
iClientID = C4ClientIDUnknown;
|
||||
pRecord = NULL;
|
||||
pPlayback = NULL;
|
||||
SyncChecks.Clear();
|
||||
SyncChecks.Clear();
|
||||
ControlRate = BoundBy<int>(Config.Network.ControlRate, 1, C4MaxControlRate);
|
||||
ControlTick = 0;
|
||||
SyncRate = C4SyncCheckRate;
|
||||
DoSync = false;
|
||||
ControlTick = 0;
|
||||
SyncRate = C4SyncCheckRate;
|
||||
DoSync = false;
|
||||
fRecordNeeded = false;
|
||||
pExecutingControl = NULL;
|
||||
}
|
||||
|
||||
bool C4GameControl::Prepare()
|
||||
{
|
||||
assert(fInitComplete);
|
||||
assert(fInitComplete);
|
||||
|
||||
// Prepare control, return true if everything is ready for GameGo.
|
||||
bool is_input_prepared = false;
|
||||
|
@ -279,7 +279,7 @@ void C4GameControl::Execute()
|
|||
{
|
||||
// Execute all available control
|
||||
|
||||
assert(fInitComplete);
|
||||
assert(fInitComplete);
|
||||
|
||||
// control tick? replay must always be executed.
|
||||
if(!isReplay() && Game.FrameCounter % ControlRate)
|
||||
|
@ -329,7 +329,7 @@ void C4GameControl::Execute()
|
|||
|
||||
void C4GameControl::Ticks()
|
||||
{
|
||||
assert(fInitComplete);
|
||||
assert(fInitComplete);
|
||||
|
||||
if(!(Game.FrameCounter % ControlRate))
|
||||
ControlTick++;
|
||||
|
@ -349,12 +349,12 @@ void C4GameControl::Ticks()
|
|||
|
||||
bool C4GameControl::CtrlTickReached(int32_t iTick)
|
||||
{
|
||||
// 1. control tick reached?
|
||||
if(ControlTick < iTick) return false;
|
||||
// 1. control tick reached?
|
||||
if(ControlTick < iTick) return false;
|
||||
// 2. control tick?
|
||||
if(Game.FrameCounter % ControlRate) return false;
|
||||
// ok then
|
||||
return true;
|
||||
// ok then
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t C4GameControl::getCtrlTick(int32_t iFrame) const
|
||||
|
@ -388,7 +388,7 @@ void C4GameControl::DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4Con
|
|||
{
|
||||
assert(fPreInit);
|
||||
|
||||
// check if the control can be executed
|
||||
// check if the control can be executed
|
||||
if(eDelivery == CDT_Direct || eDelivery == CDT_Private)
|
||||
assert(!pPkt->Sync());
|
||||
if(!fInitComplete)
|
||||
|
@ -398,8 +398,8 @@ void C4GameControl::DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4Con
|
|||
if(eDelivery == CDT_Decide)
|
||||
eDelivery = DecideControlDelivery();
|
||||
|
||||
// queue?
|
||||
if(eDelivery == CDT_Queue)
|
||||
// queue?
|
||||
if(eDelivery == CDT_Queue)
|
||||
{
|
||||
// add, will be executed/sent later
|
||||
Input.Add(eCtrlType, pPkt);
|
||||
|
@ -447,9 +447,9 @@ C4ControlDeliveryType C4GameControl::DecideControlDelivery()
|
|||
|
||||
void C4GameControl::DoSyncCheck()
|
||||
{
|
||||
// only once
|
||||
if(!DoSync) return;
|
||||
DoSync = false;
|
||||
// only once
|
||||
if(!DoSync) return;
|
||||
DoSync = false;
|
||||
// create sync check
|
||||
C4ControlSyncCheck *pSyncCheck = new C4ControlSyncCheck();
|
||||
pSyncCheck->Set();
|
||||
|
@ -477,14 +477,14 @@ void C4GameControl::DoSyncCheck()
|
|||
|
||||
void C4GameControl::ExecControl(const C4Control &rCtrl)
|
||||
{
|
||||
// nothing to do?
|
||||
if(!rCtrl.firstPkt()) return;
|
||||
// execute it
|
||||
if(!rCtrl.PreExecute()) Log("Control: PreExecute failed for sync control!");
|
||||
rCtrl.Execute();
|
||||
// record
|
||||
if(pRecord)
|
||||
pRecord->Rec(rCtrl, Game.FrameCounter);
|
||||
// nothing to do?
|
||||
if(!rCtrl.firstPkt()) return;
|
||||
// execute it
|
||||
if(!rCtrl.PreExecute()) Log("Control: PreExecute failed for sync control!");
|
||||
rCtrl.Execute();
|
||||
// record
|
||||
if(pRecord)
|
||||
pRecord->Rec(rCtrl, Game.FrameCounter);
|
||||
}
|
||||
|
||||
void C4GameControl::ExecControlPacket(C4PacketType eCtrlType, C4ControlPacket *pPkt)
|
||||
|
|
|
@ -35,12 +35,12 @@ enum C4ControlMode
|
|||
|
||||
enum C4ControlDeliveryType
|
||||
{
|
||||
CDT_Queue = 0, // Send in control queue (sync)
|
||||
CDT_Sync = 1, // Send, delay execution until net is sync (sync)
|
||||
CDT_Direct = 2, // Send directly to all clients (not sync)
|
||||
CDT_Private = 3, // Send only to some clients (not sync, obviously)
|
||||
CDT_Queue = 0, // Send in control queue (sync)
|
||||
CDT_Sync = 1, // Send, delay execution until net is sync (sync)
|
||||
CDT_Direct = 2, // Send directly to all clients (not sync)
|
||||
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:
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
|
||||
protected:
|
||||
C4ControlMode eMode;
|
||||
bool fPreInit, fInitComplete;
|
||||
bool fPreInit, fInitComplete;
|
||||
bool fHost; // (set for local, too)
|
||||
bool fActivated;
|
||||
bool fRecordNeeded;
|
||||
|
@ -83,7 +83,7 @@ protected:
|
|||
|
||||
C4Control SyncChecks;
|
||||
|
||||
C4GameControlClient *pClients;
|
||||
C4GameControlClient *pClients;
|
||||
|
||||
C4Control *pExecutingControl; // Control that is in the process of being executed - needed by non-initial records
|
||||
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
|
||||
public:
|
||||
|
||||
// configuration
|
||||
// configuration
|
||||
bool isLocal() const { return eMode == CM_Local; }
|
||||
bool isNetwork() const { return eMode == CM_Network; }
|
||||
bool isReplay() const { return eMode == CM_Replay; }
|
||||
|
@ -107,11 +107,11 @@ public:
|
|||
|
||||
bool NoInput() const { return isReplay(); }
|
||||
|
||||
// client list
|
||||
C4GameControlClient *getClient(int32_t iID);
|
||||
C4GameControlClient *getClient(const char *szName);
|
||||
// client list
|
||||
C4GameControlClient *getClient(int32_t iID);
|
||||
C4GameControlClient *getClient(const char *szName);
|
||||
|
||||
// initialization
|
||||
// initialization
|
||||
bool InitLocal(C4Client *pLocal);
|
||||
bool InitNetwork(C4Client *pLocal);
|
||||
bool InitReplay(C4Group &rGroup);
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
void Clear();
|
||||
void Default();
|
||||
|
||||
// records
|
||||
// records
|
||||
bool StartRecord(bool fInitial, bool fStreaming);
|
||||
void StopRecord(StdStrBuf *pRecordName = NULL, BYTE *pRecordSHA1 = NULL);
|
||||
void RequestRuntimeRecord();
|
||||
|
@ -134,7 +134,7 @@ public:
|
|||
void Ticks();
|
||||
|
||||
// public helpers
|
||||
bool CtrlTickReached(int32_t iTick);
|
||||
bool CtrlTickReached(int32_t iTick);
|
||||
int32_t getCtrlTick(int32_t iFrame) const;
|
||||
int32_t getNextControlTick() const;
|
||||
|
||||
|
@ -146,13 +146,13 @@ public:
|
|||
// activation
|
||||
void SetActivated(bool fActivated);
|
||||
|
||||
// input
|
||||
void DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4ControlDeliveryType eDelivery);
|
||||
void DbgRec(C4RecordChunkType eType, const uint8_t *pData=NULL, size_t iSize=0); // record debug stuff
|
||||
// input
|
||||
void DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4ControlDeliveryType eDelivery);
|
||||
void DbgRec(C4RecordChunkType eType, const uint8_t *pData=NULL, size_t iSize=0); // record debug stuff
|
||||
C4ControlDeliveryType DecideControlDelivery();
|
||||
|
||||
// sync check
|
||||
void DoSyncCheck();
|
||||
// sync check
|
||||
void DoSyncCheck();
|
||||
|
||||
// execute and record control (by self or C4GameControlNetwork)
|
||||
void ExecControl(const C4Control &rCtrl);
|
||||
|
|
|
@ -278,14 +278,14 @@ bool C4GameResList::InitNetwork(C4Network2ResList *pNetResList)
|
|||
|
||||
void C4GameResList::CalcHashes()
|
||||
{
|
||||
for (int32_t i = 0; i < iResCount; i++)
|
||||
for (int32_t i = 0; i < iResCount; i++)
|
||||
pResList[i]->CalcHash();
|
||||
}
|
||||
|
||||
bool C4GameResList::RetrieveFiles()
|
||||
{
|
||||
// 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();
|
||||
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(Clients);
|
||||
pComp->Value(Clients);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ bool C4GameSave::SaveCore()
|
|||
rC4S = Game.C4S;
|
||||
// Always mark current engine version
|
||||
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:
|
||||
// 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!
|
||||
|
@ -460,8 +460,8 @@ bool C4GameSave::Save(C4Group &hToGroup, bool fKeepGroup)
|
|||
pSaveGroup->Delete(C4CFN_Titles);
|
||||
pSaveGroup->Delete(C4CFN_Info);
|
||||
}
|
||||
// Always save Game.txt; even for saved scenarios, because global effects need to be saved
|
||||
if(!Game.SaveData(*pSaveGroup, false, fInitial, IsExact()))
|
||||
// Always save Game.txt; even for saved scenarios, because global effects need to be saved
|
||||
if(!Game.SaveData(*pSaveGroup, false, fInitial, IsExact()))
|
||||
{ Log(LoadResStr("IDS_ERR_SAVE_RUNTIMEDATA")); return false; }
|
||||
// save additional runtime data
|
||||
if (GetSaveRuntimeData()) if (!SaveRuntimeData()) return false;
|
||||
|
|
|
@ -66,7 +66,7 @@ class C4GameSave
|
|||
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 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 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
|
||||
|
@ -122,7 +122,7 @@ class C4GameSaveScenario : public C4GameSave
|
|||
bool fForceExactLandscape;
|
||||
bool 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 GetForceExactLandscape() { return C4GameSave::GetForceExactLandscape() || fForceExactLandscape; }
|
||||
virtual bool GetSaveScriptPlayers() { return true; } // script players are also saved; but user players aren't!
|
||||
|
|
|
@ -42,7 +42,7 @@ void C4PlayerInfo::Clear()
|
|||
// del temp file
|
||||
DeleteTempFile();
|
||||
// clear fields
|
||||
sName.Clear(); szFilename.Clear();
|
||||
sName.Clear(); szFilename.Clear();
|
||||
pRes = NULL;
|
||||
ResCore.Clear();
|
||||
// default fields
|
||||
|
@ -66,7 +66,7 @@ void C4PlayerInfo::DeleteTempFile()
|
|||
EraseItem(szFilename.getData());
|
||||
// reset flag and filename to prevent double deletion
|
||||
dwFlags &= ~PIF_TempFile;
|
||||
szFilename.Clear();
|
||||
szFilename.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,13 +179,13 @@ bool C4PlayerInfo::HasTeamWon() const
|
|||
}
|
||||
|
||||
void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
// Names
|
||||
pComp->Value(mkNamingAdapt(sName, "Name", ""));
|
||||
{
|
||||
// Names
|
||||
pComp->Value(mkNamingAdapt(sName, "Name", ""));
|
||||
pComp->Value(mkNamingAdapt(sForcedName, "ForcedName", ""));
|
||||
pComp->Value(mkNamingAdapt(szFilename, "Filename", ""));
|
||||
pComp->Value(mkNamingAdapt(szFilename, "Filename", ""));
|
||||
|
||||
// Flags
|
||||
// Flags
|
||||
const StdBitfieldEntry<uint16_t> Entries[] =
|
||||
{
|
||||
{ "Joined", PIF_Joined },
|
||||
|
@ -202,9 +202,9 @@ void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
|
|||
{ "Invisible", PIF_Invisible},
|
||||
{ NULL, 0 },
|
||||
};
|
||||
uint16_t dwSyncFlags = dwFlags & PIF_SyncFlags; // do not store local flags!
|
||||
pComp->Value(mkNamingAdapt(mkBitfieldAdapt(dwSyncFlags, Entries), "Flags", 0u));
|
||||
if(pComp->isCompiler()) dwFlags = dwSyncFlags;
|
||||
uint16_t dwSyncFlags = dwFlags & PIF_SyncFlags; // do not store local flags!
|
||||
pComp->Value(mkNamingAdapt(mkBitfieldAdapt(dwSyncFlags, Entries), "Flags", 0u));
|
||||
if(pComp->isCompiler()) dwFlags = dwSyncFlags;
|
||||
pComp->Value(mkNamingAdapt(iID, "ID", 0));
|
||||
|
||||
// type
|
||||
|
@ -224,7 +224,7 @@ void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
|
|||
}
|
||||
|
||||
// load colors
|
||||
pComp->Value(mkNamingAdapt(dwColor, "Color", 0u));
|
||||
pComp->Value(mkNamingAdapt(dwColor, "Color", 0u));
|
||||
pComp->Value(mkNamingAdapt(dwOriginalColor, "OriginalColor", dwColor));
|
||||
// load savegame ID
|
||||
pComp->Value(mkNamingAdapt(mkIntPackAdapt(idSavegamePlayer), "SavgamePlayer", 0));
|
||||
|
@ -234,18 +234,18 @@ void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt(szAuthID, "AUID", ""));
|
||||
|
||||
// InGame info
|
||||
if(dwFlags & PIF_Joined)
|
||||
{
|
||||
if(dwFlags & PIF_Joined)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(iInGameNumber, "GameNumber", -1));
|
||||
pComp->Value(mkNamingAdapt(iInGameJoinFrame, "GameJoinFrame", -1));
|
||||
}
|
||||
else
|
||||
iInGameNumber = iInGameJoinFrame = -1;
|
||||
}
|
||||
else
|
||||
iInGameNumber = iInGameJoinFrame = -1;
|
||||
|
||||
if(dwFlags & PIF_Removed)
|
||||
if(dwFlags & PIF_Removed)
|
||||
pComp->Value(mkNamingAdapt(iInGamePartFrame, "GamePartFrame", -1));
|
||||
else
|
||||
iInGamePartFrame = -1;
|
||||
else
|
||||
iInGamePartFrame = -1;
|
||||
|
||||
// script player extra data
|
||||
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(iLeagueRank), "LeagueRank", 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", ""));
|
||||
|
||||
// file resource
|
||||
if (dwFlags & PIF_HasRes)
|
||||
{
|
||||
// ResCore
|
||||
// ResCore
|
||||
if (pComp->isDecompiler() && pRes)
|
||||
{
|
||||
// ensure ResCore is up-to-date
|
||||
|
@ -270,11 +270,11 @@ void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt(ResCore, "ResCore"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void C4PlayerInfo::SetFilename(const char *szToFilename)
|
||||
{
|
||||
szFilename = szToFilename;
|
||||
szFilename = szToFilename;
|
||||
}
|
||||
|
||||
void C4PlayerInfo::SetToScenarioFilename(const char *szScenFilename)
|
||||
|
@ -630,10 +630,10 @@ int32_t C4ClientPlayerInfos::GetJoinedPlayerCount() const
|
|||
}
|
||||
|
||||
void C4ClientPlayerInfos::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
bool fCompiler = pComp->isCompiler();
|
||||
if(fCompiler) Clear();
|
||||
pComp->Value(mkNamingAdapt(iClientID, "ID", C4ClientIDUnknown));
|
||||
{
|
||||
bool fCompiler = pComp->isCompiler();
|
||||
if(fCompiler) Clear();
|
||||
pComp->Value(mkNamingAdapt(iClientID, "ID", C4ClientIDUnknown));
|
||||
|
||||
// Flags
|
||||
StdBitfieldEntry<uint32_t> Entries[] =
|
||||
|
@ -645,22 +645,22 @@ void C4ClientPlayerInfos::CompileFunc(StdCompiler *pComp)
|
|||
|
||||
{ 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"));
|
||||
if(iPlayerCount < 0 || iPlayerCount > C4MaxPlayer)
|
||||
pComp->Value(mkNamingCountAdapt<int32_t>(iPlayerCount, "Player"));
|
||||
if(iPlayerCount < 0 || iPlayerCount > C4MaxPlayer)
|
||||
{ pComp->excCorrupt("player count out of range"); return; }
|
||||
// Grow list, if necessary
|
||||
if(fCompiler && iPlayerCount > iPlayerCapacity)
|
||||
{
|
||||
GrowList(iPlayerCount - iPlayerCapacity);
|
||||
ZeroMem(ppPlayers, sizeof(*ppPlayers) * iPlayerCount);
|
||||
}
|
||||
// Compile
|
||||
pComp->Value(mkNamingAdapt(mkArrayAdaptMap(ppPlayers, iPlayerCount, mkPtrAdaptNoNull<C4PlayerInfo>), "Player"));
|
||||
// Force specialization
|
||||
mkPtrAdaptNoNull<C4PlayerInfo>(*ppPlayers);
|
||||
}
|
||||
// Grow list, if necessary
|
||||
if(fCompiler && iPlayerCount > iPlayerCapacity)
|
||||
{
|
||||
GrowList(iPlayerCount - iPlayerCapacity);
|
||||
ZeroMem(ppPlayers, sizeof(*ppPlayers) * iPlayerCount);
|
||||
}
|
||||
// Compile
|
||||
pComp->Value(mkNamingAdapt(mkArrayAdaptMap(ppPlayers, iPlayerCount, mkPtrAdaptNoNull<C4PlayerInfo>), "Player"));
|
||||
// Force specialization
|
||||
mkPtrAdaptNoNull<C4PlayerInfo>(*ppPlayers);
|
||||
}
|
||||
|
||||
void C4ClientPlayerInfos::LoadResources()
|
||||
{
|
||||
|
@ -770,7 +770,7 @@ bool C4PlayerInfoList::DoLocalNonNetworkPlayerInfoUpdate(C4ClientPlayerInfos *pU
|
|||
UpdatePlayerAttributes(pUpdate, true);
|
||||
// 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
|
||||
::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
|
||||
return true;
|
||||
}
|
||||
|
@ -1215,11 +1215,11 @@ bool C4PlayerInfoList::Load(C4Group &hGroup, const char *szFromFile, C4LangStrin
|
|||
return true;
|
||||
// replace strings
|
||||
if (pLang) pLang->ReplaceStrings(Buf);
|
||||
// (try to) compile
|
||||
if(!CompileFromBuf_LogWarn<StdCompilerINIRead>(
|
||||
mkNamingAdapt(*this, "PlayerInfoList"),
|
||||
Buf, szFromFile))
|
||||
return false;
|
||||
// (try to) compile
|
||||
if(!CompileFromBuf_LogWarn<StdCompilerINIRead>(
|
||||
mkNamingAdapt(*this, "PlayerInfoList"),
|
||||
Buf, szFromFile))
|
||||
return false;
|
||||
// done, success
|
||||
return true;
|
||||
}
|
||||
|
@ -1231,16 +1231,16 @@ bool C4PlayerInfoList::Save(C4Group &hGroup, const char *szToFile)
|
|||
// anything to save?
|
||||
if (!iClientCount) return true;
|
||||
// save it
|
||||
try
|
||||
{
|
||||
// decompile
|
||||
StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(
|
||||
mkNamingAdapt(*this, "PlayerInfoList"));
|
||||
try
|
||||
{
|
||||
// decompile
|
||||
StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(
|
||||
mkNamingAdapt(*this, "PlayerInfoList"));
|
||||
// save buffer to group
|
||||
hGroup.Add(szToFile, Buf, false, true);
|
||||
}
|
||||
catch(StdCompiler::Exception *)
|
||||
{ return false; }
|
||||
}
|
||||
catch(StdCompiler::Exception *)
|
||||
{ return false; }
|
||||
// done, success
|
||||
return true;
|
||||
}
|
||||
|
@ -1613,7 +1613,7 @@ bool C4PlayerInfoList::RecreatePlayers()
|
|||
{
|
||||
const char *szName = pInfo->GetName();
|
||||
if (!::Network.RetrieveRes(pJoinRes->getCore(), C4NetResRetrieveTimeout,
|
||||
FormatString(LoadResStr("IDS_NET_RES_PLRFILE"), szName).getData()))
|
||||
FormatString(LoadResStr("IDS_NET_RES_PLRFILE"), szName).getData()))
|
||||
szFilename=NULL;
|
||||
}
|
||||
// file present?
|
||||
|
@ -1757,49 +1757,49 @@ bool C4PlayerInfoList::SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fS
|
|||
}
|
||||
|
||||
void C4PlayerInfoList::ResetLeagueProjectedGain(bool fSetUpdated)
|
||||
{
|
||||
{
|
||||
C4ClientPlayerInfos *pClient; int iClient=0;
|
||||
while ((pClient = GetIndexedInfo(iClient++)))
|
||||
{
|
||||
C4PlayerInfo *pInfo; int iInfo = 0;
|
||||
while ((pInfo = pClient->GetPlayerInfo(iInfo++)))
|
||||
if (pInfo->IsLeagueProjectedGainValid())
|
||||
{
|
||||
pInfo->ResetLeagueProjectedGain();
|
||||
if (fSetUpdated)
|
||||
pClient->SetUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pInfo->IsLeagueProjectedGainValid())
|
||||
{
|
||||
pInfo->ResetLeagueProjectedGain();
|
||||
if (fSetUpdated)
|
||||
pClient->SetUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void C4PlayerInfoList::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
bool fCompiler = pComp->isCompiler();
|
||||
if(fCompiler) Clear();
|
||||
if(fCompiler) Clear();
|
||||
// skip compiling if there is nothing to compile (cosmentics)
|
||||
if(!fCompiler && pComp->hasNaming() && iLastPlayerID == 0 && iClientCount == 0)
|
||||
return;
|
||||
// header
|
||||
pComp->Value(mkNamingAdapt(iLastPlayerID, "LastPlayerID", 0));
|
||||
// client count
|
||||
int32_t iTemp = iClientCount;
|
||||
pComp->Value(mkNamingCountAdapt<int32_t>(iTemp, "Client"));
|
||||
if(iTemp < 0 || iTemp > C4MaxClient)
|
||||
pComp->Value(mkNamingAdapt(iLastPlayerID, "LastPlayerID", 0));
|
||||
// client count
|
||||
int32_t iTemp = iClientCount;
|
||||
pComp->Value(mkNamingCountAdapt<int32_t>(iTemp, "Client"));
|
||||
if(iTemp < 0 || iTemp > C4MaxClient)
|
||||
{ pComp->excCorrupt("client count out of range"); return; }
|
||||
// grow list
|
||||
if(fCompiler)
|
||||
{
|
||||
if(iTemp > iClientCapacity) GrowList(iTemp - iClientCapacity);
|
||||
iClientCount = iTemp;
|
||||
ZeroMem(ppClients, sizeof(*ppClients) * iClientCount);
|
||||
}
|
||||
// grow list
|
||||
if(fCompiler)
|
||||
{
|
||||
if(iTemp > iClientCapacity) GrowList(iTemp - iClientCapacity);
|
||||
iClientCount = iTemp;
|
||||
ZeroMem(ppClients, sizeof(*ppClients) * iClientCount);
|
||||
}
|
||||
// client packets
|
||||
pComp->Value(
|
||||
mkNamingAdapt(
|
||||
mkArrayAdaptMap(ppClients, iClientCount, mkPtrAdaptNoNull<C4ClientPlayerInfos>),
|
||||
"Client"));
|
||||
// force compiler to specialize
|
||||
mkPtrAdaptNoNull<C4ClientPlayerInfos>(*ppClients);
|
||||
pComp->Value(
|
||||
mkNamingAdapt(
|
||||
mkArrayAdaptMap(ppClients, iClientCount, mkPtrAdaptNoNull<C4ClientPlayerInfos>),
|
||||
"Client"));
|
||||
// force compiler to specialize
|
||||
mkPtrAdaptNoNull<C4ClientPlayerInfos>(*ppClients);
|
||||
}
|
||||
|
||||
int32_t C4PlayerInfoList::GetStartupCount()
|
||||
|
@ -1839,12 +1839,12 @@ void C4PlayerInfoList::FixIDCounter()
|
|||
/* -- Player info packets -- */
|
||||
|
||||
void C4PacketPlayerInfoUpdRequest::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(Info);
|
||||
}
|
||||
{
|
||||
pComp->Value(Info);
|
||||
}
|
||||
|
||||
void C4PacketPlayerInfo::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(fIsRecreationInfo, "Recreation", false));
|
||||
pComp->Value(mkNamingAdapt(Info, "Info"));
|
||||
}
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(fIsRecreationInfo, "Recreation", false));
|
||||
pComp->Value(mkNamingAdapt(Info, "Info"));
|
||||
}
|
||||
|
|
|
@ -55,9 +55,9 @@ class C4PlayerInfo
|
|||
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_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_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_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_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_NoScenarioInit = 1<<12, // do not call ScenariInit for this player
|
||||
PIF_NoEliminationCheck = 1<<13, // do not eliminate player if crew is empty
|
||||
|
@ -141,8 +141,8 @@ class C4PlayerInfo
|
|||
{ dwFlags |= PIF_VotedOut; }
|
||||
void SetLeagueProjectedGain(int32_t iProjectedGain)
|
||||
{ assert(iProjectedGain>=0); iLeagueProjectedGain = iProjectedGain; }
|
||||
void ResetLeagueProjectedGain()
|
||||
{ iLeagueProjectedGain = -1; }
|
||||
void ResetLeagueProjectedGain()
|
||||
{ iLeagueProjectedGain = -1; }
|
||||
void SetForcedName(const char *szNewName)
|
||||
{ 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 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
|
||||
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 GetID() const { return iID; } // get unique ID, if assigned
|
||||
|
@ -193,8 +193,8 @@ class C4PlayerInfo
|
|||
|
||||
DWORD GetFlags() { return dwFlags; } // for dbg print only
|
||||
|
||||
void SetDisconnected() { dwFlags |= PIF_Disconnected; }
|
||||
void SetWinner() { dwFlags |= PIF_Won; }
|
||||
void SetDisconnected() { dwFlags |= PIF_Disconnected; }
|
||||
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
|
||||
};
|
||||
|
@ -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 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
|
||||
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
|
||||
void LoadResources();
|
||||
|
|
|
@ -151,7 +151,7 @@ bool C4Record::Start(bool fInitial)
|
|||
Index++;
|
||||
|
||||
// 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
|
||||
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)
|
||||
{
|
||||
{
|
||||
// safety
|
||||
if (!fRecording) return false;
|
||||
if (!fRecording) return false;
|
||||
if (!DirectoryExists(sFilename.getData())) return false;
|
||||
|
||||
// streaming finished
|
||||
|
@ -220,35 +220,35 @@ bool C4Record::Stop(StdStrBuf *pRecordName, BYTE *pRecordSHA1)
|
|||
if(!C4Group_GetFileSHA1(sFilename.getData(), pRecordSHA1))
|
||||
return false;
|
||||
|
||||
// ok
|
||||
// ok
|
||||
fRecording = false;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool C4Record::Rec(const C4Control &Ctrl, int iFrame)
|
||||
{
|
||||
if(!fRecording) return false;
|
||||
{
|
||||
if(!fRecording) return false;
|
||||
// don't record empty control
|
||||
if(!Ctrl.firstPkt()) return true;
|
||||
// create copy
|
||||
C4Control Cpy; Cpy.Copy(Ctrl);
|
||||
// prepare it for record
|
||||
Cpy.PreRec(this);
|
||||
// record it
|
||||
return Rec(iFrame, DecompileToBuf<StdCompilerBinWrite>(Cpy), RCT_Ctrl);
|
||||
}
|
||||
// create copy
|
||||
C4Control Cpy; Cpy.Copy(Ctrl);
|
||||
// prepare it for record
|
||||
Cpy.PreRec(this);
|
||||
// record it
|
||||
return Rec(iFrame, DecompileToBuf<StdCompilerBinWrite>(Cpy), RCT_Ctrl);
|
||||
}
|
||||
|
||||
bool C4Record::Rec(C4PacketType eCtrlType, C4ControlPacket *pCtrl, int iFrame)
|
||||
{
|
||||
if(!fRecording) return false;
|
||||
// create copy
|
||||
C4IDPacket Pkt = C4IDPacket(eCtrlType, pCtrl, false); if(!Pkt.getPkt()) return false;
|
||||
C4ControlPacket *pCtrlCpy = static_cast<C4ControlPacket *>(Pkt.getPkt());
|
||||
// prepare for recording
|
||||
pCtrlCpy->PreRec(this);
|
||||
// record it
|
||||
return Rec(iFrame, DecompileToBuf<StdCompilerBinWrite>(Pkt), RCT_CtrlPkt);
|
||||
}
|
||||
{
|
||||
if(!fRecording) return false;
|
||||
// create copy
|
||||
C4IDPacket Pkt = C4IDPacket(eCtrlType, pCtrl, false); if(!Pkt.getPkt()) return false;
|
||||
C4ControlPacket *pCtrlCpy = static_cast<C4ControlPacket *>(Pkt.getPkt());
|
||||
// prepare for recording
|
||||
pCtrlCpy->PreRec(this);
|
||||
// record it
|
||||
return Rec(iFrame, DecompileToBuf<StdCompilerBinWrite>(Pkt), RCT_CtrlPkt);
|
||||
}
|
||||
|
||||
bool C4Record::Rec(int iFrame, const StdBuf &sBuf, C4RecordChunkType eType)
|
||||
{
|
||||
|
@ -399,7 +399,7 @@ C4Playback::~C4Playback()
|
|||
}
|
||||
|
||||
bool C4Playback::Open(C4Group &rGrp)
|
||||
{
|
||||
{
|
||||
// clean up
|
||||
Clear();
|
||||
fLoadSequential = !rGrp.IsPacked();
|
||||
|
@ -513,7 +513,7 @@ bool C4Playback::Open(C4Group &rGrp)
|
|||
#endif
|
||||
// ok
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool C4Playback::ReadBinary(const StdBuf &Buf)
|
||||
{
|
||||
|
@ -784,7 +784,7 @@ void C4Playback::Strip()
|
|||
}
|
||||
break;
|
||||
default:
|
||||
// TODO
|
||||
// TODO
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -817,7 +817,7 @@ void C4Playback::Strip()
|
|||
if (fStripMessages) fStripThis=true;
|
||||
break;
|
||||
default:
|
||||
// TODO
|
||||
// TODO
|
||||
break;
|
||||
}
|
||||
if (fStripThis)
|
||||
|
@ -847,13 +847,13 @@ void C4Playback::Strip()
|
|||
|
||||
bool C4Playback::ExecuteControl(C4Control *pCtrl, int iFrame)
|
||||
{
|
||||
// still playbacking?
|
||||
// still playbacking?
|
||||
if (currChunk == chunks.end()) return false;
|
||||
if (Finished) { Finish(); return false; }
|
||||
#ifdef DEBUGREC
|
||||
if(DebugRec.firstPkt())
|
||||
DebugRecError("Debug rec overflow!");
|
||||
DebugRec.Clear();
|
||||
if(DebugRec.firstPkt())
|
||||
DebugRecError("Debug rec overflow!");
|
||||
DebugRec.Clear();
|
||||
#endif
|
||||
// return all control until this frame
|
||||
while(currChunk != chunks.end() && currChunk->Frame <= iFrame)
|
||||
|
@ -862,9 +862,9 @@ bool C4Playback::ExecuteControl(C4Control *pCtrl, int iFrame)
|
|||
{
|
||||
case RCT_Ctrl:
|
||||
pCtrl->Append(*currChunk->pCtrl);
|
||||
break;
|
||||
break;
|
||||
|
||||
case RCT_CtrlPkt:
|
||||
case RCT_CtrlPkt:
|
||||
{
|
||||
C4IDPacket Packet(*currChunk->pPkt);
|
||||
pCtrl->Add(Packet.getPktType(), static_cast<C4ControlPacket *>(Packet.getPkt()));
|
||||
|
@ -878,7 +878,7 @@ bool C4Playback::ExecuteControl(C4Control *pCtrl, int iFrame)
|
|||
break;
|
||||
|
||||
#ifdef DEBUGREC
|
||||
default: // expect it to be debug rec
|
||||
default: // expect it to be debug rec
|
||||
// append to debug rec buffer
|
||||
if (currChunk->pDbg)
|
||||
{
|
||||
|
@ -886,20 +886,20 @@ bool C4Playback::ExecuteControl(C4Control *pCtrl, int iFrame)
|
|||
// the debugrec buffer is now responsible for deleting the packet
|
||||
currChunk->pDbg = NULL;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
#endif
|
||||
|
||||
}
|
||||
// next chunk
|
||||
NextChunk();
|
||||
}
|
||||
// Debug log
|
||||
// Debug log
|
||||
#ifdef DEBUGREC
|
||||
//sprintf(OSTR, "-- Frame %d:", Game.FrameCounter); Log(OSTR);
|
||||
//char Indent[256+1]; strcpy(Indent, "");
|
||||
//pCtrl->deb_print(Indent);
|
||||
#endif
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void C4Playback::Finish()
|
||||
|
@ -1127,7 +1127,7 @@ bool C4Playback::StreamToRecord(const char *szStream, StdStrBuf *pRecordFile)
|
|||
{
|
||||
|
||||
// Initialize stream
|
||||
z_stream strm;
|
||||
z_stream strm;
|
||||
ZeroMem(&strm, sizeof strm);
|
||||
strm.next_in = getMBufPtr<BYTE>(CompressedData);
|
||||
strm.avail_in = CompressedData.getSize();
|
||||
|
|
|
@ -270,11 +270,11 @@ class C4Record // demo recording
|
|||
const StdBuf &GetStreamingBuf() const { return StreamingData; }
|
||||
|
||||
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(C4PacketType eCtrlType, C4ControlPacket *pCtrl, int iFrame); // record control packet
|
||||
bool Rec(int iFrame, const StdBuf &sBuf, C4RecordChunkType eType);
|
||||
bool Rec(const C4Control &Ctrl, int iFrame); // record control
|
||||
bool Rec(C4PacketType eCtrlType, C4ControlPacket *pCtrl, int iFrame); // record control packet
|
||||
bool Rec(int iFrame, const StdBuf &sBuf, C4RecordChunkType eType);
|
||||
|
||||
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
|
||||
void Finish(); // end playback
|
||||
#ifdef DEBUGREC
|
||||
C4PacketList DebugRec;
|
||||
C4PacketList DebugRec;
|
||||
#endif
|
||||
public:
|
||||
C4Playback(); // constructor; init playback
|
||||
|
@ -319,7 +319,7 @@ class C4Playback // demo playback
|
|||
void Clear();
|
||||
#ifdef 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
|
||||
static bool StreamToRecord(const char *szStream, StdStrBuf *pRecord);
|
||||
};
|
||||
|
|
|
@ -42,12 +42,12 @@ void C4RoundResultsPlayer::CompileFunc(StdCompiler *pComp)
|
|||
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(iLeagueRankSymbolNew, "RankSymbol", 0)); // name used in league reply!
|
||||
StdEnumEntry<LeagueStatus> LeagueStatusEntries[] =
|
||||
{
|
||||
{ "", RRPLS_Unknown },
|
||||
{ "Lost", RRPLS_Lost },
|
||||
{ "Won", RRPLS_Won },
|
||||
};
|
||||
StdEnumEntry<LeagueStatus> LeagueStatusEntries[] =
|
||||
{
|
||||
{ "", RRPLS_Unknown },
|
||||
{ "Lost", RRPLS_Lost },
|
||||
{ "Won", RRPLS_Won },
|
||||
};
|
||||
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)
|
||||
{
|
||||
bool fCompiler = pComp->isCompiler();
|
||||
if(fCompiler) Clear();
|
||||
if(fCompiler) Clear();
|
||||
int32_t iTemp = iPlayerCount;
|
||||
pComp->Value(mkNamingCountAdapt<int32_t>(iTemp, "Player"));
|
||||
if(iTemp < 0 || iTemp > C4MaxPlayer)
|
||||
pComp->Value(mkNamingCountAdapt<int32_t>(iTemp, "Player"));
|
||||
if(iTemp < 0 || iTemp > C4MaxPlayer)
|
||||
{ pComp->excCorrupt("player count out of range"); return; }
|
||||
// Grow list, if necessary
|
||||
if(fCompiler && iTemp > iPlayerCapacity)
|
||||
{
|
||||
GrowList(iTemp - iPlayerCapacity);
|
||||
// Grow list, if necessary
|
||||
if(fCompiler && iTemp > iPlayerCapacity)
|
||||
{
|
||||
GrowList(iTemp - iPlayerCapacity);
|
||||
iPlayerCount = iTemp;
|
||||
ZeroMem(ppPlayers, sizeof(*ppPlayers) * iPlayerCount);
|
||||
}
|
||||
// Compile
|
||||
pComp->Value(mkNamingAdapt(mkArrayAdaptMap(ppPlayers, iPlayerCount, mkPtrAdaptNoNull<C4RoundResultsPlayer>), "Player"));
|
||||
// Force specialization
|
||||
mkPtrAdaptNoNull<C4RoundResultsPlayer>(*ppPlayers);
|
||||
ZeroMem(ppPlayers, sizeof(*ppPlayers) * iPlayerCount);
|
||||
}
|
||||
// Compile
|
||||
pComp->Value(mkNamingAdapt(mkArrayAdaptMap(ppPlayers, iPlayerCount, mkPtrAdaptNoNull<C4RoundResultsPlayer>), "Player"));
|
||||
// Force specialization
|
||||
mkPtrAdaptNoNull<C4RoundResultsPlayer>(*ppPlayers);
|
||||
}
|
||||
|
||||
C4RoundResultsPlayer *C4RoundResultsPlayers::GetByIndex(int32_t idx) const
|
||||
|
@ -256,22 +256,22 @@ void C4RoundResults::Init()
|
|||
|
||||
void C4RoundResults::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
bool fCompiler = pComp->isCompiler();
|
||||
if(fCompiler) Clear();
|
||||
pComp->Value(mkNamingAdapt(Goals, "Goals", C4IDList()));
|
||||
bool fCompiler = pComp->isCompiler();
|
||||
if(fCompiler) Clear();
|
||||
pComp->Value(mkNamingAdapt(Goals, "Goals", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(iPlayingTime, "PlayingTime", 0u));
|
||||
pComp->Value(mkNamingAdapt(fHideSettlementScore, "HideSettlementScore", Game.C4S.Game.IsMelee()));
|
||||
pComp->Value(mkNamingAdapt(sCustomEvaluationStrings, "CustomEvaluationStrings", StdCopyStrBuf()));
|
||||
pComp->Value(mkNamingAdapt(iLeaguePerformance, "LeaguePerformance", 0));
|
||||
pComp->Value(mkNamingAdapt(Players, "PlayerInfos", C4RoundResultsPlayers()));
|
||||
pComp->Value(mkNamingAdapt(sNetResult, "NetResult", StdCopyStrBuf()));
|
||||
StdEnumEntry<NetResult> NetResultEntries[] =
|
||||
{
|
||||
{ "", NR_None },
|
||||
{ "LeagueOK", NR_LeagueOK },
|
||||
{ "LeagueError", NR_LeagueError},
|
||||
StdEnumEntry<NetResult> NetResultEntries[] =
|
||||
{
|
||||
{ "", NR_None },
|
||||
{ "LeagueOK", NR_LeagueOK },
|
||||
{ "LeagueError", NR_LeagueError},
|
||||
{ "NetError", NR_NetError },
|
||||
};
|
||||
};
|
||||
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
|
||||
hGroup.DeleteEntry(szFilename);
|
||||
// decompile
|
||||
try
|
||||
{
|
||||
StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*this, "RoundResults"));
|
||||
try
|
||||
{
|
||||
StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*this, "RoundResults"));
|
||||
// save it, if not empty
|
||||
if (Buf.getLength())
|
||||
if (!hGroup.Add(szFilename, Buf, false, true))
|
||||
return false;
|
||||
}
|
||||
catch(StdCompiler::Exception *)
|
||||
{ return false; }
|
||||
}
|
||||
catch(StdCompiler::Exception *)
|
||||
{ return false; }
|
||||
// done, success
|
||||
return true;
|
||||
}
|
||||
|
@ -415,9 +415,9 @@ bool C4RoundResults::Save(C4Group &hGroup, const char *szFilename)
|
|||
// *** C4PacketLeagueRoundResults
|
||||
|
||||
void C4PacketLeagueRoundResults::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(fSuccess, "Success", false));
|
||||
pComp->Value(mkNamingAdapt(sResultsString, "ResultString", StdCopyStrBuf()));
|
||||
pComp->Value(Players);
|
||||
}
|
||||
pComp->Value(Players);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,12 +131,12 @@ int32_t C4Team::GetFirstUnjoinedPlayerID() const
|
|||
void C4Team::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
if (pComp->isCompiler()) Clear();
|
||||
pComp->Value(mkNamingAdapt(iID, "id", 0));
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Name), "Name", ""));
|
||||
pComp->Value(mkNamingAdapt(iID, "id", 0));
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Name), "Name", ""));
|
||||
pComp->Value(mkNamingAdapt(iPlrStartIndex, "PlrStartIndex", 0));
|
||||
pComp->Value(mkNamingAdapt(iPlayerCount, "PlayerCount", 0));
|
||||
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(iPlayerCount, "PlayerCount", 0));
|
||||
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(dwClr, "Color", 0u));
|
||||
pComp->Value(mkNamingAdapt(sIconSpec, "IconSpec", StdCopyStrBuf()));
|
||||
pComp->Value(mkNamingAdapt(iMaxPlayer, "MaxPlayer", 0));
|
||||
|
@ -542,12 +542,12 @@ bool C4TeamList::IsJoin2TeamAllowed(int32_t idTeam)
|
|||
void C4TeamList::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
// if (pComp->isCompiler()) Clear(); - do not clear, because this would corrupt the fCustom-flag
|
||||
pComp->Value(mkNamingAdapt(fActive, "Active", true));
|
||||
pComp->Value(mkNamingAdapt(fCustom, "Custom", true));
|
||||
pComp->Value(mkNamingAdapt(fAllowHostilityChange, "AllowHostilityChange", false));
|
||||
pComp->Value(mkNamingAdapt(fActive, "Active", true));
|
||||
pComp->Value(mkNamingAdapt(fCustom, "Custom", true));
|
||||
pComp->Value(mkNamingAdapt(fAllowHostilityChange, "AllowHostilityChange", false));
|
||||
pComp->Value(mkNamingAdapt(fAllowTeamSwitch, "AllowTeamSwitch", false));
|
||||
pComp->Value(mkNamingAdapt(fAutoGenerateTeams, "AutoGenerateTeams", false));
|
||||
pComp->Value(mkNamingAdapt(iLastTeamID, "LastTeamID", 0));
|
||||
pComp->Value(mkNamingAdapt(iLastTeamID, "LastTeamID", 0));
|
||||
|
||||
StdEnumEntry<TeamDist> TeamDistEntries[] =
|
||||
{
|
||||
|
@ -563,9 +563,9 @@ void C4TeamList::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt(sScriptPlayerNames, "ScriptPlayerNames", StdStrBuf()));
|
||||
|
||||
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];
|
||||
delete [] ppList;
|
||||
|
@ -646,14 +646,14 @@ bool C4TeamList::Save(C4Group &hGroup)
|
|||
// remove previous entry from group
|
||||
hGroup.DeleteEntry(C4CFN_Teams);
|
||||
// decompile
|
||||
try
|
||||
{
|
||||
StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*this, "Teams"));
|
||||
try
|
||||
{
|
||||
StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*this, "Teams"));
|
||||
// save it
|
||||
hGroup.Add(C4CFN_Teams, Buf, false, true);
|
||||
}
|
||||
catch(StdCompiler::Exception *)
|
||||
{ return false; }
|
||||
}
|
||||
catch(StdCompiler::Exception *)
|
||||
{ return false; }
|
||||
// done, success
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -102,8 +102,8 @@ namespace {
|
|||
#endif
|
||||
|
||||
#define FILE_SELECT_FILTER_FOR_C4S "Clonk 4 Scenario\0" \
|
||||
"*.c4s;*.c4f;Scenario.txt\0" \
|
||||
"\0"
|
||||
"*.c4s;*.c4f;Scenario.txt\0" \
|
||||
"\0"
|
||||
|
||||
C4Console::C4Console()
|
||||
{
|
||||
|
@ -161,30 +161,30 @@ INT_PTR CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPara
|
|||
{
|
||||
switch (Msg)
|
||||
{
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
case WM_ACTIVATEAPP:
|
||||
Application.Active = wParam != 0;
|
||||
return true;
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
case WM_DESTROY:
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
case WM_ACTIVATEAPP:
|
||||
Application.Active = wParam != 0;
|
||||
return true;
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
case WM_DESTROY:
|
||||
StoreWindowPosition(hDlg, "Main", Config.GetSubkeyPath("Console"), false);
|
||||
Application.Quit();
|
||||
return true;
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
case WM_CLOSE:
|
||||
Console.Close();
|
||||
return true;
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
case MM_MCINOTIFY:
|
||||
if (wParam == MCI_NOTIFY_SUCCESSFUL)
|
||||
Application.MusicSystem.NotifySuccess();
|
||||
return true;
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
case WM_INITDIALOG:
|
||||
SendMessage(hDlg,DM_SETDEFID,(WPARAM)IDOK,(LPARAM)0);
|
||||
SendMessage(hDlg,DM_SETDEFID,(WPARAM)IDOK,(LPARAM)0);
|
||||
Console.UpdateMenuText(GetMenu(hDlg));
|
||||
return true;
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
return true;
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
case WM_COMMAND:
|
||||
// Evaluate command
|
||||
switch (LOWORD(wParam))
|
||||
|
@ -269,25 +269,25 @@ INT_PTR CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPara
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
case WM_USER_LOG:
|
||||
if (SEqual2((const char *)lParam, "IDS_"))
|
||||
Log(LoadResStr((const char *)lParam));
|
||||
else
|
||||
Log((const char *)lParam);
|
||||
return false;
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
case WM_COPYDATA:
|
||||
COPYDATASTRUCT* pcds = reinterpret_cast<COPYDATASTRUCT *>(lParam);
|
||||
if(pcds->dwData == WM_USER_RELOADFILE)
|
||||
{
|
||||
// get path, ensure proper termination
|
||||
const char *szPath = reinterpret_cast<const char *>(pcds->lpData);
|
||||
if(szPath[pcds->cbData - 1]) break;
|
||||
// reload
|
||||
Game.ReloadFile(szPath);
|
||||
}
|
||||
return false;
|
||||
COPYDATASTRUCT* pcds = reinterpret_cast<COPYDATASTRUCT *>(lParam);
|
||||
if(pcds->dwData == WM_USER_RELOADFILE)
|
||||
{
|
||||
// get path, ensure proper termination
|
||||
const char *szPath = reinterpret_cast<const char *>(pcds->lpData);
|
||||
if(szPath[pcds->cbData - 1]) break;
|
||||
// reload
|
||||
Game.ReloadFile(szPath);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1331,7 +1331,7 @@ void C4Console::EditScript()
|
|||
{
|
||||
if (::Network.isEnabled()) return;
|
||||
Game.Script.Open();
|
||||
::ScriptEngine.ReLink(&::Definitions);
|
||||
::ScriptEngine.ReLink(&::Definitions);
|
||||
}
|
||||
|
||||
void C4Console::EditInfo()
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
#endif
|
||||
|
||||
const int C4CNS_ModePlay = 0,
|
||||
C4CNS_ModeEdit = 1,
|
||||
C4CNS_ModeDraw = 2;
|
||||
C4CNS_ModeEdit = 1,
|
||||
C4CNS_ModeDraw = 2;
|
||||
|
||||
#define IDM_NET_CLIENT1 10000
|
||||
#define IDM_NET_CLIENT2 10100
|
||||
|
|
|
@ -64,23 +64,23 @@ C4EditCursor::~C4EditCursor()
|
|||
|
||||
void C4EditCursor::Execute()
|
||||
{
|
||||
// alt check
|
||||
bool fAltIsDown = Application.IsAltDown();
|
||||
if (fAltIsDown != fAltWasDown)
|
||||
// alt check
|
||||
bool fAltIsDown = Application.IsAltDown();
|
||||
if (fAltIsDown != fAltWasDown)
|
||||
{
|
||||
if ((fAltWasDown = fAltIsDown))
|
||||
AltDown();
|
||||
else
|
||||
AltUp();
|
||||
}
|
||||
// drawing
|
||||
// drawing
|
||||
switch (Mode)
|
||||
{
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
case C4CNS_ModeEdit:
|
||||
// Hold selection
|
||||
if (Hold)
|
||||
EMMoveObject(EMMO_Move, 0, 0, NULL, &Selection);
|
||||
EMMoveObject(EMMO_Move, 0, 0, NULL, &Selection);
|
||||
break;
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
case C4CNS_ModeDraw:
|
||||
|
@ -398,8 +398,8 @@ bool C4EditCursor::OpenPropTools()
|
|||
|
||||
bool C4EditCursor::Duplicate()
|
||||
{
|
||||
EMMoveObject(EMMO_Duplicate, 0, 0, NULL, &Selection);
|
||||
return true;
|
||||
EMMoveObject(EMMO_Duplicate, 0, 0, NULL, &Selection);
|
||||
return true;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
EMMoveObject(EMMO_Move, iXOff, iYOff, NULL, &Selection);
|
||||
EMMoveObject(EMMO_Move, iXOff, iYOff, NULL, &Selection);
|
||||
}
|
||||
|
||||
void C4EditCursor::FrameSelection()
|
||||
{
|
||||
Selection.Clear();
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
for (clnk=::Objects.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
if (cobj->Status) if (cobj->OCF & OCF_NotContained)
|
||||
{
|
||||
|
@ -494,13 +494,13 @@ void C4EditCursor::FrameSelection()
|
|||
|
||||
bool C4EditCursor::In(const char *szText)
|
||||
{
|
||||
EMMoveObject(EMMO_Script, 0, 0, NULL, &Selection, szText);
|
||||
EMMoveObject(EMMO_Script, 0, 0, NULL, &Selection, szText);
|
||||
return true;
|
||||
}
|
||||
|
||||
void C4EditCursor::Default()
|
||||
{
|
||||
fAltWasDown=false;
|
||||
fAltWasDown=false;
|
||||
Mode=C4CNS_ModePlay;
|
||||
X=Y=X2=Y2=0;
|
||||
Target=DropTarget=NULL;
|
||||
|
@ -587,7 +587,7 @@ void C4EditCursor::ApplyToolBrush()
|
|||
{
|
||||
if (!EditingOK()) return;
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -595,7 +595,7 @@ void C4EditCursor::ApplyToolLine()
|
|||
{
|
||||
if (!EditingOK()) return;
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -603,7 +603,7 @@ void C4EditCursor::ApplyToolRect()
|
|||
{
|
||||
if (!EditingOK()) return;
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -611,7 +611,7 @@ void C4EditCursor::ApplyToolFill()
|
|||
{
|
||||
if (!EditingOK()) return;
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -668,12 +668,12 @@ void C4EditCursor::GrabContents()
|
|||
Hold=true;
|
||||
|
||||
// Exit all objects
|
||||
EMMoveObject(EMMO_Exit, 0, 0, NULL, &Selection);
|
||||
EMMoveObject(EMMO_Exit, 0, 0, NULL, &Selection);
|
||||
}
|
||||
|
||||
void C4EditCursor::UpdateDropTarget(WORD wKeyFlags)
|
||||
{
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
|
||||
DropTarget=NULL;
|
||||
|
||||
|
@ -692,7 +692,7 @@ void C4EditCursor::UpdateDropTarget(WORD wKeyFlags)
|
|||
void C4EditCursor::PutContents()
|
||||
{
|
||||
if (!DropTarget) return;
|
||||
EMMoveObject(EMMO_Enter, 0, 0, DropTarget, &Selection);
|
||||
EMMoveObject(EMMO_Enter, 0, 0, DropTarget, &Selection);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// construct object list
|
||||
int32_t iObjCnt = 0; int32_t *pObjIDs = NULL;
|
||||
if(pObjs && (iObjCnt = pObjs->ObjectCount()))
|
||||
{
|
||||
pObjIDs = new int32_t [iObjCnt];
|
||||
// fill
|
||||
int32_t i = 0;
|
||||
for(C4ObjectLink *pLnk = pObjs->First; pLnk; pLnk = pLnk->Next, i++)
|
||||
if(pLnk->Obj && pLnk->Obj->Status)
|
||||
pObjIDs[i] = pLnk->Obj->Number;
|
||||
}
|
||||
{
|
||||
// construct object list
|
||||
int32_t iObjCnt = 0; int32_t *pObjIDs = NULL;
|
||||
if(pObjs && (iObjCnt = pObjs->ObjectCount()))
|
||||
{
|
||||
pObjIDs = new int32_t [iObjCnt];
|
||||
// fill
|
||||
int32_t i = 0;
|
||||
for(C4ObjectLink *pLnk = pObjs->First; pLnk; pLnk = pLnk->Next, i++)
|
||||
if(pLnk->Obj && pLnk->Obj->Status)
|
||||
pObjIDs[i] = pLnk->Obj->Number;
|
||||
}
|
||||
|
||||
// execute control
|
||||
EMControl(CID_EMMoveObj, new C4ControlEMMoveObject(eAction, tx, ty, pTargetObj, iObjCnt, pObjIDs, szScript));
|
||||
// execute control
|
||||
EMControl(CID_EMMoveObj, new C4ControlEMMoveObject(eAction, tx, ty, pTargetObj, iObjCnt, pObjIDs, szScript));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void C4EditCursor::EMControl(C4PacketType eCtrlType, C4ControlPacket *pCtrl)
|
||||
{
|
||||
::Control.DoInput(eCtrlType, pCtrl, CDT_Decide);
|
||||
}
|
||||
{
|
||||
::Control.DoInput(eCtrlType, pCtrl, CDT_Decide);
|
||||
}
|
||||
|
||||
#ifdef WITH_DEVELOPER_MODE
|
||||
// GTK+ callbacks
|
||||
void C4EditCursor::OnDelete(GtkWidget* widget, gpointer data)
|
||||
{
|
||||
static_cast<C4EditCursor*>(data)->Delete();
|
||||
static_cast<C4EditCursor*>(data)->Delete();
|
||||
}
|
||||
|
||||
void C4EditCursor::OnDuplicate(GtkWidget* widget, gpointer data)
|
||||
{
|
||||
static_cast<C4EditCursor*>(data)->Duplicate();
|
||||
static_cast<C4EditCursor*>(data)->Duplicate();
|
||||
}
|
||||
|
||||
void C4EditCursor::OnGrabContents(GtkWidget* widget, gpointer data)
|
||||
{
|
||||
static_cast<C4EditCursor*>(data)->GrabContents();
|
||||
static_cast<C4EditCursor*>(data)->GrabContents();
|
||||
}
|
||||
|
||||
void C4EditCursor::OnProperties(GtkWidget* widget, gpointer data)
|
||||
{
|
||||
static_cast<C4EditCursor*>(data)->OpenPropTools();
|
||||
static_cast<C4EditCursor*>(data)->OpenPropTools();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool C4EditCursor::AltDown()
|
||||
{
|
||||
// alt only has an effect in draw mode (picker)
|
||||
if (Mode == C4CNS_ModeDraw)
|
||||
{
|
||||
Console.ToolsDlg.SetAlternateTool();
|
||||
}
|
||||
// key not processed - allow further usages of Alt
|
||||
return false;
|
||||
}
|
||||
{
|
||||
// alt only has an effect in draw mode (picker)
|
||||
if (Mode == C4CNS_ModeDraw)
|
||||
{
|
||||
Console.ToolsDlg.SetAlternateTool();
|
||||
}
|
||||
// key not processed - allow further usages of Alt
|
||||
return false;
|
||||
}
|
||||
|
||||
bool C4EditCursor::AltUp()
|
||||
{
|
||||
if (Mode == C4CNS_ModeDraw)
|
||||
{
|
||||
Console.ToolsDlg.ResetAlternateTool();
|
||||
}
|
||||
// key not processed - allow further usages of Alt
|
||||
return false;
|
||||
}
|
||||
{
|
||||
if (Mode == C4CNS_ModeDraw)
|
||||
{
|
||||
Console.ToolsDlg.ResetAlternateTool();
|
||||
}
|
||||
// key not processed - allow further usages of Alt
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class C4EditCursor
|
|||
C4EditCursor();
|
||||
~C4EditCursor();
|
||||
protected:
|
||||
bool fAltWasDown;
|
||||
bool fAltWasDown;
|
||||
bool fSelectionChanged;
|
||||
int32_t Mode;
|
||||
int32_t X,Y,X2,Y2;
|
||||
|
@ -79,8 +79,8 @@ class C4EditCursor
|
|||
C4ObjectList &GetSelection() { return Selection; }
|
||||
void SetHold(bool fToState) { Hold = fToState; }
|
||||
void OnSelectionChanged();
|
||||
bool AltDown();
|
||||
bool AltUp();
|
||||
bool AltDown();
|
||||
bool AltUp();
|
||||
protected:
|
||||
bool UpdateStatusBar();
|
||||
void ApplyToolPicker();
|
||||
|
@ -96,8 +96,8 @@ class C4EditCursor
|
|||
void DrawSelectMark(C4Facet &cgo, FLOAT_RECT r);
|
||||
void FrameSelection();
|
||||
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 EMControl(enum C4PacketType eCtrlType, class C4ControlPacket *pCtrl);
|
||||
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);
|
||||
|
||||
#ifdef WITH_DEVELOPER_MODE
|
||||
static void OnDelete(GtkWidget* widget, gpointer data);
|
||||
|
|
|
@ -253,7 +253,7 @@ c4_list_iter_children (GtkTreeModel * tree_model, GtkTreeIter * iter, GtkTreeIte
|
|||
// Return true if 'parent' has children.
|
||||
static gboolean
|
||||
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 (C4_IS_LIST (tree_model), false);
|
||||
|
|
|
@ -64,7 +64,7 @@ BOOL CALLBACK PropertyDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|||
break;
|
||||
//------------------------------------------------------------------------------------------------
|
||||
case WM_INITDIALOG:
|
||||
SendMessage(hDlg,DM_SETDEFID,(WPARAM)IDOK,(LPARAM)0);
|
||||
SendMessage(hDlg,DM_SETDEFID,(WPARAM)IDOK,(LPARAM)0);
|
||||
return true;
|
||||
//------------------------------------------------------------------------------------------------
|
||||
case WM_COMMAND:
|
||||
|
@ -86,7 +86,7 @@ BOOL CALLBACK PropertyDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
}
|
||||
return false;
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ bool C4PropertyDlg::Update(C4ObjectList &rSelection)
|
|||
|
||||
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)
|
||||
return true;
|
||||
return false;
|
||||
|
|
|
@ -457,7 +457,7 @@ void C4ToolsDlg::Clear()
|
|||
bool C4ToolsDlg::SetTool(int32_t iTool, bool fTemp)
|
||||
{
|
||||
Tool=iTool;
|
||||
if (!fTemp) SelectedTool = Tool;
|
||||
if (!fTemp) SelectedTool = Tool;
|
||||
UpdateToolCtrls();
|
||||
UpdatePreview();
|
||||
return true;
|
||||
|
@ -680,7 +680,7 @@ void C4ToolsDlg::UpdatePreview()
|
|||
// Material-Texture
|
||||
else
|
||||
{
|
||||
bCol=Mat2PixColDefault(::MaterialMap.Get(Material));
|
||||
bCol=Mat2PixColDefault(::MaterialMap.Get(Material));
|
||||
// Get/Create TexMap entry
|
||||
BYTE iTex = ::TextureMap.GetIndex(Material, Texture, true);
|
||||
if (iTex)
|
||||
|
@ -755,11 +755,11 @@ void C4ToolsDlg::InitGradeCtrl()
|
|||
#ifdef _WIN32
|
||||
if (!hDialog) return;
|
||||
HWND hwndTrack = GetDlgItem(hDialog,IDC_SLIDERGRADE);
|
||||
SendMessage(hwndTrack,TBM_SETPAGESIZE,0,(LPARAM)5);
|
||||
SendMessage(hwndTrack,TBM_SETLINESIZE,0,(LPARAM)1);
|
||||
SendMessage(hwndTrack,TBM_SETRANGE,(WPARAM)false,
|
||||
(LPARAM) MAKELONG(C4TLS_GradeMin,C4TLS_GradeMax));
|
||||
SendMessage(hwndTrack,TBM_SETPOS,(WPARAM)true,(LPARAM)C4TLS_GradeMax-Grade);
|
||||
SendMessage(hwndTrack,TBM_SETPAGESIZE,0,(LPARAM)5);
|
||||
SendMessage(hwndTrack,TBM_SETLINESIZE,0,(LPARAM)1);
|
||||
SendMessage(hwndTrack,TBM_SETRANGE,(WPARAM)false,
|
||||
(LPARAM) MAKELONG(C4TLS_GradeMin,C4TLS_GradeMax));
|
||||
SendMessage(hwndTrack,TBM_SETPOS,(WPARAM)true,(LPARAM)C4TLS_GradeMax-Grade);
|
||||
UpdateWindow(hwndTrack);
|
||||
#else
|
||||
#ifdef WITH_DEVELOPER_MODE
|
||||
|
@ -1034,16 +1034,16 @@ bool C4ToolsDlg::SelectMaterial(const char *szMaterial)
|
|||
}
|
||||
|
||||
void C4ToolsDlg::SetAlternateTool()
|
||||
{
|
||||
// alternate tool is the picker in any mode
|
||||
SetTool(C4TLS_Picker, true);
|
||||
}
|
||||
{
|
||||
// alternate tool is the picker in any mode
|
||||
SetTool(C4TLS_Picker, true);
|
||||
}
|
||||
|
||||
void C4ToolsDlg::ResetAlternateTool()
|
||||
{
|
||||
// reset tool to selected tool in case alternate tool was set
|
||||
SetTool(SelectedTool, true);
|
||||
}
|
||||
{
|
||||
// reset tool to selected tool in case alternate tool was set
|
||||
SetTool(SelectedTool, true);
|
||||
}
|
||||
|
||||
#ifdef WITH_DEVELOPER_MODE
|
||||
// GTK+ callbacks
|
||||
|
|
|
@ -150,8 +150,8 @@ class C4ToolsDlg
|
|||
bool ToggleIFT() { return !!SetIFT(!ModeIFT); }
|
||||
bool SelectTexture(const char *szTexture);
|
||||
bool SelectMaterial(const char *szMaterial);
|
||||
void SetAlternateTool();
|
||||
void ResetAlternateTool();
|
||||
void SetAlternateTool();
|
||||
void ResetAlternateTool();
|
||||
protected:
|
||||
void AssertValidTexture();
|
||||
void LoadBitmaps();
|
||||
|
|
|
@ -54,13 +54,13 @@ struct C4GameVersion
|
|||
|
||||
// helper
|
||||
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(iVer2 > iRVer2) return 1; if(iVer2 < iRVer2) return -1;
|
||||
if(iVer3 > iRVer3) return 1; if(iVer3 < iRVer3) return -1;
|
||||
if(iVer4 > iRVer4) return 1; if(iVer4 < iRVer4) return -1;
|
||||
return 0;
|
||||
if(iVer1 > iRVer1) return 1; if(iVer1 < iRVer1) return -1;
|
||||
if(iVer2 > iRVer2) return 1; if(iVer2 < iRVer2) return -1;
|
||||
if(iVer3 > iRVer3) return 1; if(iVer3 < iRVer3) return -1;
|
||||
if(iVer4 > iRVer4) return 1; if(iVer4 < iRVer4) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // C4GAMEVERSION_H
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,8 +31,8 @@
|
|||
#include <C4Material.h>
|
||||
|
||||
const uint8_t GBM = 128,
|
||||
GBM_ColNum = 64,
|
||||
IFT = 0x80,
|
||||
GBM_ColNum = 64,
|
||||
IFT = 0x80,
|
||||
IFTOld = GBM_ColNum;
|
||||
|
||||
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 C4LSC_Undefined = 0,
|
||||
C4LSC_Dynamic = 1,
|
||||
C4LSC_Dynamic = 1,
|
||||
C4LSC_Static = 2,
|
||||
C4LSC_Exact = 3;
|
||||
|
||||
|
@ -51,29 +51,29 @@ class C4Object;
|
|||
class C4PropList;
|
||||
|
||||
class C4Landscape
|
||||
{
|
||||
public:
|
||||
C4Landscape();
|
||||
{
|
||||
public:
|
||||
C4Landscape();
|
||||
~C4Landscape();
|
||||
public:
|
||||
public:
|
||||
int32_t Mode;
|
||||
int32_t Width,Height;
|
||||
int32_t MapWidth,MapHeight,MapZoom;
|
||||
CSurface8 * Map;
|
||||
DWORD MatCount[C4MaxMaterial]; // NoSave //
|
||||
DWORD EffectiveMatCount[C4MaxMaterial]; // NoSave //
|
||||
DWORD MatCount[C4MaxMaterial]; // NoSave //
|
||||
DWORD EffectiveMatCount[C4MaxMaterial]; // NoSave //
|
||||
uint8_t *BridgeMatConversion[C4MaxMaterial]; // NoSave //
|
||||
int32_t BlastMatCount[C4MaxMaterial]; // SyncClearance-NoSave //
|
||||
bool NoScan; // ExecuteScan() disabled
|
||||
int32_t ScanX,ScanSpeed; // SyncClearance-NoSave //
|
||||
int32_t ScanX,ScanSpeed; // SyncClearance-NoSave //
|
||||
int32_t LeftOpen,RightOpen,TopOpen,BottomOpen;
|
||||
FIXED Gravity;
|
||||
uint32_t Modulation; // landscape blit modulation; 0 means normal
|
||||
int32_t MapSeed; // random seed for MapToLandscape
|
||||
C4Sky Sky;
|
||||
C4Sky Sky;
|
||||
C4MapCreatorS2 *pMapCreator; // map creator for script-generated maps
|
||||
bool fMapChanged;
|
||||
BYTE *pInitial; // Initial landscape after creation - used for diff
|
||||
BYTE *pInitial; // Initial landscape after creation - used for diff
|
||||
protected:
|
||||
CSurface * Surface32;
|
||||
CSurface8 * Surface8;
|
||||
|
@ -84,15 +84,15 @@ class C4Landscape
|
|||
public:
|
||||
void Default();
|
||||
void Clear(bool fClearMapCreator=true, bool fClearSky=true);
|
||||
void Execute();
|
||||
void Execute();
|
||||
void Synchronize();
|
||||
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 ClearRectDensity(int32_t iTx, int32_t iTy, int32_t iWdt, int32_t iHgt, int32_t iOfDensity);
|
||||
void ClearMatCount();
|
||||
void ClearBlastMatCount();
|
||||
void ScanSideOpen();
|
||||
void ScanSideOpen();
|
||||
void CheckInstabilityRange(int32_t tx, int32_t ty);
|
||||
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);
|
||||
|
@ -107,7 +107,7 @@ class C4Landscape
|
|||
bool Save(C4Group &hGroup);
|
||||
bool SaveDiff(C4Group &hGroup, bool fSyncSave);
|
||||
bool SaveMap(C4Group &hGroup);
|
||||
bool SaveInitial();
|
||||
bool SaveInitial();
|
||||
bool SaveTextures(C4Group &hGroup);
|
||||
bool Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bool &rfLoaded, bool fSavegame);
|
||||
bool MapToLandscape();
|
||||
|
@ -192,7 +192,7 @@ class C4Landscape
|
|||
inline int32_t GetPixMat(BYTE byPix) { return Pix2Mat[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.
|
||||
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 ShakeFreePix(int32_t tx, int32_t ty);
|
||||
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 HandleTexMapUpdate();
|
||||
void UpdatePixMaps();
|
||||
bool DoRelights();
|
||||
void RemoveUnusedTexMapEntries();
|
||||
protected:
|
||||
void ExecuteScan();
|
||||
bool DoRelights();
|
||||
void RemoveUnusedTexMapEntries();
|
||||
protected:
|
||||
void ExecuteScan();
|
||||
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
|
||||
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);
|
||||
DWORD GetClrByTex(int32_t iX, int32_t iY);
|
||||
bool Mat2Pal(); // assign material colors to landscape palette
|
||||
void DigFreeSinglePix(int32_t x, int32_t y, int32_t dx, int32_t dy)
|
||||
{
|
||||
if(GetDensity(x, y) > GetDensity(x + dx, y + dy))
|
||||
DigFreePix(x, y);
|
||||
}
|
||||
void DigFreeSinglePix(int32_t x, int32_t y, int32_t dx, int32_t dy)
|
||||
{
|
||||
if(GetDensity(x, y) > GetDensity(x + dx, y + dy))
|
||||
DigFreePix(x, y);
|
||||
}
|
||||
void UpdatePixCnt(const class C4Rect &Rect, bool fCheck = false);
|
||||
void UpdateMatCnt(C4Rect Rect, bool fPlus);
|
||||
void PrepareChange(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);
|
||||
public:
|
||||
void CompileFunc(StdCompiler *pComp); // without landscape bitmaps and sky
|
||||
public:
|
||||
void CompileFunc(StdCompiler *pComp); // without landscape bitmaps and sky
|
||||
bool DebugSave(const char *szFilename);
|
||||
};
|
||||
};
|
||||
|
||||
extern C4Landscape Landscape;
|
||||
|
||||
|
@ -277,31 +277,31 @@ int32_t PixCol2Mat(BYTE pixc);
|
|||
#define _SBackPixIfMask ::Landscape._SetPixIfMask
|
||||
|
||||
inline bool DensitySolid(int32_t dens)
|
||||
{
|
||||
return (dens>=C4M_Solid);
|
||||
}
|
||||
{
|
||||
return (dens>=C4M_Solid);
|
||||
}
|
||||
|
||||
inline bool DensitySemiSolid(int32_t dens)
|
||||
{
|
||||
return (dens>=C4M_SemiSolid);
|
||||
}
|
||||
{
|
||||
return (dens>=C4M_SemiSolid);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
{
|
||||
return pixc & IFT;
|
||||
}
|
||||
}
|
||||
|
||||
// always use OldGfx-version (used for convert)
|
||||
inline BYTE PixColIFTOld(BYTE pixc)
|
||||
{
|
||||
if (pixc>=GBM+IFTOld) return IFTOld;
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
if (pixc>=GBM+IFTOld) return IFTOld;
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return PixColIFT(GBackPix(x,y));
|
||||
}
|
||||
{
|
||||
return PixColIFT(GBackPix(x,y));
|
||||
}
|
||||
|
||||
inline int32_t GBackMat(int32_t x, int32_t y)
|
||||
{
|
||||
{
|
||||
return ::Landscape.GetMat(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
inline int32_t GBackDensity(int32_t x, int32_t y)
|
||||
{
|
||||
{
|
||||
return ::Landscape.GetDensity(x, 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)
|
||||
{
|
||||
return DensitySemiSolid(GBackDensity(x,y));
|
||||
}
|
||||
{
|
||||
return DensitySemiSolid(GBackDensity(x,y));
|
||||
}
|
||||
|
||||
inline bool GBackLiquid(int32_t x, int32_t y)
|
||||
{
|
||||
return DensityLiquid(GBackDensity(x,y));
|
||||
}
|
||||
{
|
||||
return DensityLiquid(GBackDensity(x,y));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -31,128 +31,128 @@
|
|||
#include <Bitmap256.h>
|
||||
|
||||
C4MapCreator::C4MapCreator()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void C4MapCreator::Reset()
|
||||
{
|
||||
MapIFT=128;
|
||||
MapBuf=NULL;
|
||||
Exclusive=-1;
|
||||
}
|
||||
{
|
||||
MapIFT=128;
|
||||
MapBuf=NULL;
|
||||
Exclusive=-1;
|
||||
}
|
||||
|
||||
void C4MapCreator::SetPix(int32_t x, int32_t y, BYTE col)
|
||||
{
|
||||
// Safety
|
||||
if (!Inside<int32_t>(x,0,MapWdt-1) || !Inside<int32_t>(y,0,MapHgt-1)) return;
|
||||
// Exclusive
|
||||
if (Exclusive>-1) if (GetPix(x,y)!=Exclusive) return;
|
||||
// Set pix
|
||||
MapBuf->SetPix(x,y,col);
|
||||
}
|
||||
{
|
||||
// Safety
|
||||
if (!Inside<int32_t>(x,0,MapWdt-1) || !Inside<int32_t>(y,0,MapHgt-1)) return;
|
||||
// Exclusive
|
||||
if (Exclusive>-1) if (GetPix(x,y)!=Exclusive) return;
|
||||
// Set pix
|
||||
MapBuf->SetPix(x,y,col);
|
||||
}
|
||||
|
||||
void C4MapCreator::SetSpot(int32_t x, int32_t y, int32_t rad, BYTE col)
|
||||
{
|
||||
int32_t ycnt,xcnt,lwdt,dpy;
|
||||
for (ycnt=-rad; ycnt<=rad; ycnt++)
|
||||
{
|
||||
lwdt= (int32_t) sqrt(double(rad*rad-ycnt*ycnt)); dpy=y+ycnt;
|
||||
for (xcnt=-lwdt; xcnt<lwdt+(lwdt==0); xcnt++)
|
||||
SetPix(x+xcnt,dpy,col);
|
||||
}
|
||||
}
|
||||
{
|
||||
int32_t ycnt,xcnt,lwdt,dpy;
|
||||
for (ycnt=-rad; ycnt<=rad; ycnt++)
|
||||
{
|
||||
lwdt= (int32_t) sqrt(double(rad*rad-ycnt*ycnt)); dpy=y+ycnt;
|
||||
for (xcnt=-lwdt; xcnt<lwdt+(lwdt==0); xcnt++)
|
||||
SetPix(x+xcnt,dpy,col);
|
||||
}
|
||||
}
|
||||
|
||||
void C4MapCreator::DrawLayer(int32_t x, int32_t y, int32_t size, BYTE col)
|
||||
{
|
||||
int32_t cnt,cnt2;
|
||||
for (cnt=0; cnt<size; cnt++)
|
||||
{
|
||||
x+=Random(9)-4; y+=Random(3)-1;
|
||||
for (cnt2=Random(3); cnt2<5; cnt2++)
|
||||
{ SetPix(x+cnt2,y,col); SetPix(x+cnt2+1,y+1,col); }
|
||||
}
|
||||
}
|
||||
{
|
||||
int32_t cnt,cnt2;
|
||||
for (cnt=0; cnt<size; cnt++)
|
||||
{
|
||||
x+=Random(9)-4; y+=Random(3)-1;
|
||||
for (cnt2=Random(3); cnt2<5; cnt2++)
|
||||
{ SetPix(x+cnt2,y,col); SetPix(x+cnt2+1,y+1,col); }
|
||||
}
|
||||
}
|
||||
|
||||
BYTE C4MapCreator::GetPix(int32_t x, int32_t y)
|
||||
{
|
||||
// Safety
|
||||
if (!Inside<int32_t>(x,0,MapWdt-1) || !Inside<int32_t>(y,0,MapHgt-1)) return 0;
|
||||
// Get pix
|
||||
return MapBuf->GetPix(x,y);
|
||||
}
|
||||
{
|
||||
// Safety
|
||||
if (!Inside<int32_t>(x,0,MapWdt-1) || !Inside<int32_t>(y,0,MapHgt-1)) return 0;
|
||||
// Get pix
|
||||
return MapBuf->GetPix(x,y);
|
||||
}
|
||||
|
||||
void C4MapCreator::Create(CSurface8 *sfcMap,
|
||||
C4SLandscape &rLScape, C4TextureMap &rTexMap,
|
||||
bool fLayers, int32_t iPlayerNum)
|
||||
{
|
||||
double fullperiod= 20.0 * pi;
|
||||
BYTE ccol;
|
||||
int32_t cx,cy;
|
||||
{
|
||||
double fullperiod= 20.0 * pi;
|
||||
BYTE ccol;
|
||||
int32_t cx,cy;
|
||||
|
||||
// Safeties
|
||||
if (!sfcMap) return;
|
||||
iPlayerNum=BoundBy<int32_t>(iPlayerNum,1,C4S_MaxPlayer);
|
||||
// Safeties
|
||||
if (!sfcMap) return;
|
||||
iPlayerNum=BoundBy<int32_t>(iPlayerNum,1,C4S_MaxPlayer);
|
||||
|
||||
// Set creator variables
|
||||
MapBuf = sfcMap;
|
||||
MapWdt = MapBuf->Wdt; MapHgt = MapBuf->Hgt;
|
||||
// Set creator variables
|
||||
MapBuf = sfcMap;
|
||||
MapWdt = MapBuf->Wdt; MapHgt = MapBuf->Hgt;
|
||||
|
||||
// Reset map (0 is sky)
|
||||
MapBuf->ClearBox8Only(0,0,MapBuf->Wdt, MapBuf->Hgt);
|
||||
// Reset map (0 is sky)
|
||||
MapBuf->ClearBox8Only(0,0,MapBuf->Wdt, MapBuf->Hgt);
|
||||
|
||||
// Surface
|
||||
ccol=rTexMap.GetIndexMatTex(rLScape.Material)+MapIFT;
|
||||
float amplitude= (float) rLScape.Amplitude.Evaluate();
|
||||
float phase= (float) rLScape.Phase.Evaluate();
|
||||
float period= (float) rLScape.Period.Evaluate();
|
||||
if (rLScape.MapPlayerExtend) period *= Min(iPlayerNum, C4S_MaxMapPlayerExtend);
|
||||
float natural= (float) rLScape.Random.Evaluate();
|
||||
int32_t level0= Min(MapWdt,MapHgt)/2;
|
||||
int32_t maxrange= level0*3/4;
|
||||
double cy_curve,cy_natural; // -1.0 - +1.0 !
|
||||
// Surface
|
||||
ccol=rTexMap.GetIndexMatTex(rLScape.Material)+MapIFT;
|
||||
float amplitude= (float) rLScape.Amplitude.Evaluate();
|
||||
float phase= (float) rLScape.Phase.Evaluate();
|
||||
float period= (float) rLScape.Period.Evaluate();
|
||||
if (rLScape.MapPlayerExtend) period *= Min(iPlayerNum, C4S_MaxMapPlayerExtend);
|
||||
float natural= (float) rLScape.Random.Evaluate();
|
||||
int32_t level0= Min(MapWdt,MapHgt)/2;
|
||||
int32_t maxrange= level0*3/4;
|
||||
double cy_curve,cy_natural; // -1.0 - +1.0 !
|
||||
|
||||
double rnd_cy,rnd_tend; // -1.0 - +1.0 !
|
||||
rnd_cy= (double) (Random(2000+1)-1000)/1000.0;
|
||||
rnd_tend= (double) (Random(200+1)-100)/20000.0;
|
||||
double rnd_cy,rnd_tend; // -1.0 - +1.0 !
|
||||
rnd_cy= (double) (Random(2000+1)-1000)/1000.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_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_cy<-0.5) rnd_tend+=0.01;
|
||||
if (rnd_cy>+0.5) rnd_tend-=0.01;
|
||||
rnd_cy+=rnd_tend;
|
||||
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_cy<-0.5) rnd_tend+=0.01;
|
||||
if (rnd_cy>+0.5) rnd_tend-=0.01;
|
||||
|
||||
cy_natural=rnd_cy*natural/100.0;
|
||||
cy_curve=sin(fullperiod*period/100.0*(float)cx/(float)MapWdt
|
||||
+2.0*pi*phase/100.0) * amplitude/100.0;
|
||||
cy_natural=rnd_cy*natural/100.0;
|
||||
cy_curve=sin(fullperiod*period/100.0*(float)cx/(float)MapWdt
|
||||
+2.0*pi*phase/100.0) * amplitude/100.0;
|
||||
|
||||
cy=level0+BoundBy((int32_t)((float)maxrange*(cy_curve+cy_natural)),
|
||||
-maxrange,+maxrange);
|
||||
cy=level0+BoundBy((int32_t)((float)maxrange*(cy_curve+cy_natural)),
|
||||
-maxrange,+maxrange);
|
||||
|
||||
|
||||
SetPix(cx,cy,ccol);
|
||||
}
|
||||
SetPix(cx,cy,ccol);
|
||||
}
|
||||
|
||||
// Raise bottom to surface
|
||||
for (cx=0; cx<MapWdt; cx++)
|
||||
for (cy=MapHgt-1; (cy>=0) && !GetPix(cx,cy); cy--)
|
||||
SetPix(cx,cy,ccol);
|
||||
// Raise liquid level
|
||||
Exclusive=0;
|
||||
ccol=rTexMap.GetIndexMatTex(rLScape.Liquid);
|
||||
int32_t wtr_level=rLScape.LiquidLevel.Evaluate();
|
||||
for (cx=0; cx<MapWdt; cx++)
|
||||
for (cy=MapHgt*(100-wtr_level)/100; cy<MapHgt; cy++)
|
||||
SetPix(cx,cy,ccol);
|
||||
Exclusive=-1;
|
||||
// Raise bottom to surface
|
||||
for (cx=0; cx<MapWdt; cx++)
|
||||
for (cy=MapHgt-1; (cy>=0) && !GetPix(cx,cy); cy--)
|
||||
SetPix(cx,cy,ccol);
|
||||
// Raise liquid level
|
||||
Exclusive=0;
|
||||
ccol=rTexMap.GetIndexMatTex(rLScape.Liquid);
|
||||
int32_t wtr_level=rLScape.LiquidLevel.Evaluate();
|
||||
for (cx=0; cx<MapWdt; cx++)
|
||||
for (cy=MapHgt*(100-wtr_level)/100; cy<MapHgt; cy++)
|
||||
SetPix(cx,cy,ccol);
|
||||
Exclusive=-1;
|
||||
|
||||
// Layers
|
||||
if (fLayers)
|
||||
{
|
||||
if (fLayers)
|
||||
{
|
||||
|
||||
// Base material
|
||||
Exclusive=rTexMap.GetIndexMatTex(rLScape.Material)+MapIFT;
|
||||
|
@ -180,9 +180,9 @@ void C4MapCreator::Create(CSurface8 *sfcMap,
|
|||
|
||||
Exclusive=-1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*bool C4MapCreator::Load(
|
||||
BYTE **pbypBuffer,
|
||||
|
|
|
@ -28,29 +28,29 @@ class CSurface8;
|
|||
class C4TextureMap;
|
||||
|
||||
class C4MapCreator
|
||||
{
|
||||
public:
|
||||
C4MapCreator();
|
||||
protected:
|
||||
int32_t MapIFT;
|
||||
CSurface8 *MapBuf;
|
||||
int32_t MapWdt,MapHgt;
|
||||
int32_t Exclusive;
|
||||
public:
|
||||
void Create(CSurface8 *sfcMap,
|
||||
C4SLandscape &rLScape, C4TextureMap &rTexMap,
|
||||
bool fLayers=false, int32_t iPlayerNum=1);
|
||||
{
|
||||
public:
|
||||
C4MapCreator();
|
||||
protected:
|
||||
int32_t MapIFT;
|
||||
CSurface8 *MapBuf;
|
||||
int32_t MapWdt,MapHgt;
|
||||
int32_t Exclusive;
|
||||
public:
|
||||
void Create(CSurface8 *sfcMap,
|
||||
C4SLandscape &rLScape, C4TextureMap &rTexMap,
|
||||
bool fLayers=false, int32_t iPlayerNum=1);
|
||||
bool Load(BYTE **pbypBuffer,
|
||||
int32_t &rBufWdt, int32_t &rMapWdt, int32_t &rMapHgt,
|
||||
C4Group &hGroup, const char *szEntryName,
|
||||
C4TextureMap &rTexMap);
|
||||
protected:
|
||||
void Reset();
|
||||
void SetPix(int32_t x, int32_t y, 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);
|
||||
protected:
|
||||
void Reset();
|
||||
void SetPix(int32_t x, int32_t y, 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 ValidateTextureIndices(C4TextureMap &rTexMap);
|
||||
BYTE GetPix(int32_t x, int32_t y);
|
||||
};
|
||||
BYTE GetPix(int32_t x, int32_t y);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -385,7 +385,7 @@ bool C4MCOverlay::SetField(C4MCParser *pParser, const char *szField, const char
|
|||
*((C4MCCallbackArray **) pTarget) = new C4MCCallbackArray(pSFunc, MapCreator);
|
||||
}
|
||||
default:
|
||||
// TODO
|
||||
// TODO
|
||||
break;
|
||||
}
|
||||
// done
|
||||
|
@ -818,9 +818,9 @@ CSurface8 * C4MapCreatorS2::Render(const char *szMapName)
|
|||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -1480,7 +1480,7 @@ bool AlgoChecker(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 iYC=(iY/10+s+(iX/80))%(z*2)-z;
|
||||
int32_t id=Abs(iXC*iYC); // ((iSeed^iX^iY)%z)
|
||||
|
|
|
@ -42,19 +42,19 @@
|
|||
// hardly ever exceeding 1000. October 1997
|
||||
|
||||
C4MassMoverSet::C4MassMoverSet()
|
||||
{
|
||||
{
|
||||
Default();
|
||||
}
|
||||
}
|
||||
|
||||
C4MassMoverSet::~C4MassMoverSet()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void C4MassMoverSet::Clear()
|
||||
{
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void C4MassMoverSet::Execute()
|
||||
{
|
||||
|
@ -69,75 +69,75 @@ void C4MassMoverSet::Execute()
|
|||
if (cmm->Mat!=MNone)
|
||||
{ Count++; cmm->Execute(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool C4MassMoverSet::Create(int32_t x, int32_t y, bool fExecute)
|
||||
{
|
||||
{
|
||||
if(Count == C4MassMoverChunk) return false;
|
||||
#ifdef DEBUGREC
|
||||
C4RCMassMover rc;
|
||||
rc.x=x; rc.y=y;
|
||||
AddDbgRec(RCT_MMC, &rc, sizeof(rc));
|
||||
#endif
|
||||
int32_t cptr=CreatePtr;
|
||||
do
|
||||
{
|
||||
cptr++;
|
||||
if (cptr>=C4MassMoverChunk) cptr=0;
|
||||
if (Set[cptr].Mat==MNone)
|
||||
{
|
||||
if (!Set[cptr].Init(x,y)) return false;
|
||||
CreatePtr=cptr;
|
||||
int32_t cptr=CreatePtr;
|
||||
do
|
||||
{
|
||||
cptr++;
|
||||
if (cptr>=C4MassMoverChunk) cptr=0;
|
||||
if (Set[cptr].Mat==MNone)
|
||||
{
|
||||
if (!Set[cptr].Init(x,y)) return false;
|
||||
CreatePtr=cptr;
|
||||
if (fExecute) Set[cptr].Execute();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
while (cptr!=CreatePtr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (cptr!=CreatePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
void C4MassMoverSet::Draw()
|
||||
{
|
||||
/*int32_t cnt;
|
||||
for (cnt=0; cnt<C4MassMoverChunk; cnt++)
|
||||
if (Set[cnt].Mat!=MNone)*/
|
||||
}
|
||||
{
|
||||
/*int32_t cnt;
|
||||
for (cnt=0; cnt<C4MassMoverChunk; cnt++)
|
||||
if (Set[cnt].Mat!=MNone)*/
|
||||
}
|
||||
|
||||
bool C4MassMover::Init(int32_t tx, int32_t ty)
|
||||
{
|
||||
// Out of bounds check
|
||||
if (!Inside<int32_t>(tx,0,GBackWdt-1) || !Inside<int32_t>(ty,0,GBackHgt-1))
|
||||
return false;
|
||||
// Check mat
|
||||
Mat=GBackMat(tx,ty);
|
||||
x=tx; y=ty;
|
||||
{
|
||||
// Out of bounds check
|
||||
if (!Inside<int32_t>(tx,0,GBackWdt-1) || !Inside<int32_t>(ty,0,GBackHgt-1))
|
||||
return false;
|
||||
// Check mat
|
||||
Mat=GBackMat(tx,ty);
|
||||
x=tx; y=ty;
|
||||
::MassMover.Count++;
|
||||
return (Mat!=MNone);
|
||||
}
|
||||
return (Mat!=MNone);
|
||||
}
|
||||
|
||||
void C4MassMover::Cease()
|
||||
{
|
||||
{
|
||||
#ifdef DEBUGREC
|
||||
C4RCMassMover rc;
|
||||
rc.x=x; rc.y=y;
|
||||
AddDbgRec(RCT_MMD, &rc, sizeof(rc));
|
||||
#endif
|
||||
::MassMover.Count--;
|
||||
Mat=MNone;
|
||||
}
|
||||
Mat=MNone;
|
||||
}
|
||||
|
||||
bool C4MassMover::Execute()
|
||||
{
|
||||
int32_t tx,ty;
|
||||
{
|
||||
int32_t tx,ty;
|
||||
|
||||
// Lost target material
|
||||
if (GBackMat(x,y)!=Mat) { Cease(); return false; }
|
||||
// Lost target material
|
||||
if (GBackMat(x,y)!=Mat) { Cease(); return false; }
|
||||
|
||||
// Check for transfer target space
|
||||
// Check for transfer target space
|
||||
C4Material *pMat = ::MaterialMap.Map+Mat;
|
||||
tx=x; ty=y;
|
||||
if (!::Landscape.FindMatPath(tx,ty,+1,pMat->Density,pMat->MaxSlide))
|
||||
{
|
||||
tx=x; ty=y;
|
||||
if (!::Landscape.FindMatPath(tx,ty,+1,pMat->Density,pMat->MaxSlide))
|
||||
{
|
||||
// Contact material reaction check: corrosion/evaporation/inflammation/etc.
|
||||
if (Corrosion(+0,+1) || Corrosion(-1,+0) || Corrosion(+1,+0))
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ bool C4MassMover::Execute()
|
|||
if (Game.C4S.Game.Realism.LandscapeInsertThrust)
|
||||
omat = GBackMat(tx, ty);
|
||||
|
||||
// Transfer mass
|
||||
// Transfer mass
|
||||
if(Random(10))
|
||||
SBackPix(tx,ty,Mat2PixColDefault(::Landscape.ExtractMaterial(x,y))+GBackIFT(tx,ty));
|
||||
else
|
||||
|
@ -173,11 +173,11 @@ bool C4MassMover::Execute()
|
|||
if(Game.C4S.Game.Realism.LandscapeInsertThrust && MatValid(omat) && ::MaterialMap.Map[omat].Density > 0)
|
||||
::Landscape.InsertMaterial(omat, tx, ty + 1);
|
||||
|
||||
// Create new mover at target
|
||||
::MassMover.Create(tx,ty,!Rnd3());
|
||||
// Create new mover at target
|
||||
::MassMover.Create(tx,ty,!Rnd3());
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
int32_t cnt;
|
||||
for (cnt=0; cnt<C4MassMoverChunk; cnt++) Set[cnt].Mat=MNone;
|
||||
Count=0;
|
||||
CreatePtr=0;
|
||||
int32_t cnt;
|
||||
for (cnt=0; cnt<C4MassMoverChunk; cnt++) Set[cnt].Mat=MNone;
|
||||
Count=0;
|
||||
CreatePtr=0;
|
||||
}
|
||||
|
||||
bool C4MassMoverSet::Save(C4Group &hGroup)
|
||||
|
@ -263,7 +263,7 @@ void C4MassMoverSet::Consolidate()
|
|||
if (iSpot==iPtr) iSpot=-1;
|
||||
}
|
||||
}
|
||||
// Reset create ptr
|
||||
// Reset create ptr
|
||||
CreatePtr=0;
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ void C4MassMoverSet::Copy(C4MassMoverSet &rSet)
|
|||
Clear();
|
||||
Count=rSet.Count;
|
||||
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;
|
||||
|
|
|
@ -28,40 +28,40 @@ class C4Group;
|
|||
class C4MassMoverSet;
|
||||
|
||||
class C4MassMover
|
||||
{
|
||||
friend class C4MassMoverSet;
|
||||
protected:
|
||||
int32_t Mat,x,y;
|
||||
protected:
|
||||
void Cease();
|
||||
bool Execute();
|
||||
bool Init(int32_t tx, int32_t ty);
|
||||
{
|
||||
friend class C4MassMoverSet;
|
||||
protected:
|
||||
int32_t Mat,x,y;
|
||||
protected:
|
||||
void Cease();
|
||||
bool Execute();
|
||||
bool Init(int32_t tx, int32_t ty);
|
||||
bool Corrosion(int32_t dx, int32_t dy);
|
||||
};
|
||||
};
|
||||
|
||||
class C4MassMoverSet
|
||||
{
|
||||
public:
|
||||
C4MassMoverSet();
|
||||
~C4MassMoverSet();
|
||||
public:
|
||||
int32_t Count;
|
||||
int32_t CreatePtr;
|
||||
protected:
|
||||
C4MassMover Set[C4MassMoverChunk];
|
||||
public:
|
||||
{
|
||||
public:
|
||||
C4MassMoverSet();
|
||||
~C4MassMoverSet();
|
||||
public:
|
||||
int32_t Count;
|
||||
int32_t CreatePtr;
|
||||
protected:
|
||||
C4MassMover Set[C4MassMoverChunk];
|
||||
public:
|
||||
void Copy(C4MassMoverSet &rSet);
|
||||
void Synchronize();
|
||||
void Default();
|
||||
void Clear();
|
||||
void Draw();
|
||||
void Execute();
|
||||
bool Create(int32_t x, int32_t y, bool fExecute=false);
|
||||
void Clear();
|
||||
void Draw();
|
||||
void Execute();
|
||||
bool Create(int32_t x, int32_t y, bool fExecute=false);
|
||||
bool Load(C4Group &hGroup);
|
||||
bool Save(C4Group &hGroup);
|
||||
protected:
|
||||
protected:
|
||||
void Consolidate();
|
||||
};
|
||||
};
|
||||
|
||||
extern C4MassMoverSet MassMover;
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ void C4MaterialCore::Clear()
|
|||
ColorAnimation = 0;
|
||||
TempConvStrength = 0;
|
||||
MinHeightCount = 0;
|
||||
SplashRate=10;
|
||||
SplashRate=10;
|
||||
}
|
||||
|
||||
void C4MaterialCore::Default()
|
||||
|
@ -154,7 +154,7 @@ bool C4MaterialCore::Load(C4Group &hGroup,
|
|||
if (!hGroup.LoadEntryString(szEntryName,Source))
|
||||
return false;
|
||||
StdStrBuf Name = hGroup.GetFullName() + DirSep + szEntryName;
|
||||
if(!CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, Source, Name.getData()))
|
||||
if(!CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, Source, Name.getData()))
|
||||
return false;
|
||||
// adjust placement, if not specified
|
||||
if (!Placement)
|
||||
|
@ -218,7 +218,7 @@ void C4MaterialCore::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt(BelowTempConvertDir, "BelowTempConvertDir",0 ));
|
||||
pComp->Value(mkNamingAdapt(mkParAdapt(sBelowTempConvertTo, StdCompiler::RCT_IdtfAllowEmpty),"BelowTempConvertTo", "" ));
|
||||
pComp->Value(mkNamingAdapt(MinHeightCount, "MinHeightCount", 0 ));
|
||||
pComp->Value(mkNamingAdapt(SplashRate, "SplashRate", 10 ));
|
||||
pComp->Value(mkNamingAdapt(SplashRate, "SplashRate", 10 ));
|
||||
pComp->NameEnd();
|
||||
// material reactions
|
||||
pComp->Value(mkNamingAdapt(
|
||||
|
@ -230,12 +230,12 @@ void C4MaterialCore::CompileFunc(StdCompiler *pComp)
|
|||
// -------------------------------------- C4Material
|
||||
|
||||
C4Material::C4Material()
|
||||
{
|
||||
BlastShiftTo=0;
|
||||
InMatConvertTo=MNone;
|
||||
BelowTempConvertTo=0;
|
||||
AboveTempConvertTo=0;
|
||||
}
|
||||
{
|
||||
BlastShiftTo=0;
|
||||
InMatConvertTo=MNone;
|
||||
BelowTempConvertTo=0;
|
||||
AboveTempConvertTo=0;
|
||||
}
|
||||
|
||||
void C4Material::UpdateScriptPointers()
|
||||
{
|
||||
|
@ -248,35 +248,35 @@ void C4Material::UpdateScriptPointers()
|
|||
|
||||
|
||||
C4MaterialMap::C4MaterialMap() : DefReactConvert(&mrfConvert), DefReactPoof(&mrfPoof), DefReactCorrode(&mrfCorrode), DefReactIncinerate(&mrfIncinerate), DefReactInsert(&mrfInsert)
|
||||
{
|
||||
{
|
||||
Default();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
C4MaterialMap::~C4MaterialMap()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void C4MaterialMap::Clear()
|
||||
{
|
||||
if (Map) delete [] Map; Map=NULL;
|
||||
{
|
||||
if (Map) delete [] Map; Map=NULL;
|
||||
delete [] ppReactionMap; ppReactionMap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t C4MaterialMap::Load(C4Group &hGroup)
|
||||
{
|
||||
{
|
||||
char entryname[256+1];
|
||||
|
||||
// Determine number of materials in files
|
||||
int32_t mat_num=hGroup.EntryCount(C4CFN_MaterialFiles);
|
||||
// Determine number of materials in files
|
||||
int32_t mat_num=hGroup.EntryCount(C4CFN_MaterialFiles);
|
||||
|
||||
// Allocate new map
|
||||
// Allocate new map
|
||||
C4Material *pNewMap = new C4Material [mat_num + Num];
|
||||
if(!pNewMap) return 0;
|
||||
|
||||
// Load material cores to map
|
||||
hGroup.ResetSearch(); int32_t cnt=0;
|
||||
// Load material cores to map
|
||||
hGroup.ResetSearch(); int32_t cnt=0;
|
||||
while (hGroup.FindNextEntry(C4CFN_MaterialFiles,entryname))
|
||||
{
|
||||
// Load mat
|
||||
|
@ -298,8 +298,8 @@ int32_t C4MaterialMap::Load(C4Group &hGroup)
|
|||
// set material number
|
||||
Num+=cnt;
|
||||
|
||||
return cnt;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
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 cnt;
|
||||
for (cnt=0; cnt<Num; cnt++)
|
||||
if (SEqualNoCase(szMaterial,Map[cnt].Name))
|
||||
return cnt;
|
||||
return MNone;
|
||||
}
|
||||
{
|
||||
int32_t cnt;
|
||||
for (cnt=0; cnt<Num; cnt++)
|
||||
if (SEqualNoCase(szMaterial,Map[cnt].Name))
|
||||
return cnt;
|
||||
return MNone;
|
||||
}
|
||||
|
||||
|
||||
bool C4MaterialMap::CrossMapMaterials() // Called after load
|
||||
|
@ -465,16 +465,16 @@ bool C4MaterialMap::CrossMapMaterials() // Called after load
|
|||
}
|
||||
}
|
||||
// second loop (DefaultMatTex is needed by GetIndexMatTex)
|
||||
for (cnt=0; cnt<Num; cnt++)
|
||||
{
|
||||
if (Map[cnt].sBlastShiftTo.getLength())
|
||||
for (cnt=0; cnt<Num; cnt++)
|
||||
{
|
||||
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());
|
||||
if (Map[cnt].sInMatConvertTo.getLength())
|
||||
Map[cnt].InMatConvertTo=Get(Map[cnt].sInMatConvertTo.getData());
|
||||
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());
|
||||
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());
|
||||
if (Map[cnt].sInMatConvertTo.getLength())
|
||||
Map[cnt].InMatConvertTo=Get(Map[cnt].sInMatConvertTo.getData());
|
||||
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());
|
||||
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());
|
||||
}
|
||||
#if 0
|
||||
int32_t i=0;
|
||||
|
@ -511,7 +511,7 @@ bool C4MaterialMap::SaveEnumeration(C4Group &hGroup)
|
|||
char *mapbuf = new char [1000];
|
||||
mapbuf[0]=0;
|
||||
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(LineFeed,mapbuf);
|
||||
|
@ -575,8 +575,8 @@ bool C4MaterialMap::SortEnumeration(int32_t iMat, const char *szMatName)
|
|||
|
||||
void C4MaterialMap::Default()
|
||||
{
|
||||
Num=0;
|
||||
Map=NULL;
|
||||
Num=0;
|
||||
Map=NULL;
|
||||
ppReactionMap=NULL;
|
||||
}
|
||||
|
||||
|
@ -871,7 +871,7 @@ int32_t PixCol2MatOld(BYTE pixc)
|
|||
}
|
||||
|
||||
int32_t PixCol2MatOld2(BYTE pixc)
|
||||
{
|
||||
{
|
||||
int32_t iMat = ((int32_t) (pixc&0x7f)) -1;
|
||||
// if above MVehic, don't forget additional vehicle-colors
|
||||
if (iMat<=MVehic) return iMat;
|
||||
|
@ -880,6 +880,6 @@ int32_t PixCol2MatOld2(BYTE pixc)
|
|||
// above: range check
|
||||
iMat-=2; if (iMat >= ::MaterialMap.Num) return MNone;
|
||||
return iMat;
|
||||
}
|
||||
}
|
||||
|
||||
C4MaterialMap MaterialMap;
|
||||
|
|
|
@ -74,87 +74,87 @@ struct C4MaterialReaction
|
|||
};
|
||||
|
||||
class C4MaterialCore
|
||||
{
|
||||
{
|
||||
public:
|
||||
C4MaterialCore();
|
||||
~C4MaterialCore() { Clear(); }
|
||||
|
||||
public:
|
||||
std::vector<C4MaterialReaction> CustomReactionList;
|
||||
public:
|
||||
char Name[C4M_MaxName+1];
|
||||
int32_t MapChunkType;
|
||||
int32_t Density;
|
||||
int32_t Friction;
|
||||
int32_t DigFree;
|
||||
int32_t BlastFree;
|
||||
C4ID Dig2Object;
|
||||
int32_t Dig2ObjectRatio;
|
||||
int32_t Dig2ObjectOnRequestOnly;
|
||||
C4ID Blast2Object;
|
||||
int32_t Blast2ObjectRatio;
|
||||
int32_t Blast2PXSRatio;
|
||||
int32_t Instable;
|
||||
int32_t MaxAirSpeed;
|
||||
int32_t MaxSlide;
|
||||
int32_t WindDrift;
|
||||
int32_t Inflammable;
|
||||
int32_t Incindiary;
|
||||
int32_t Extinguisher;
|
||||
public:
|
||||
char Name[C4M_MaxName+1];
|
||||
int32_t MapChunkType;
|
||||
int32_t Density;
|
||||
int32_t Friction;
|
||||
int32_t DigFree;
|
||||
int32_t BlastFree;
|
||||
C4ID Dig2Object;
|
||||
int32_t Dig2ObjectRatio;
|
||||
int32_t Dig2ObjectOnRequestOnly;
|
||||
C4ID Blast2Object;
|
||||
int32_t Blast2ObjectRatio;
|
||||
int32_t Blast2PXSRatio;
|
||||
int32_t Instable;
|
||||
int32_t MaxAirSpeed;
|
||||
int32_t MaxSlide;
|
||||
int32_t WindDrift;
|
||||
int32_t Inflammable;
|
||||
int32_t Incindiary;
|
||||
int32_t Extinguisher;
|
||||
int32_t Corrosive;
|
||||
int32_t Corrode;
|
||||
int32_t Soil;
|
||||
int32_t Soil;
|
||||
int32_t Placement; // placement order for landscape shading
|
||||
StdCopyStrBuf sTextureOverlay; // overlayed texture for this material
|
||||
int32_t OverlayType; // defines the way in which the overlay texture is applied
|
||||
StdCopyStrBuf sPXSGfx; // newgfx: picture used for loose pxs
|
||||
C4TargetRect PXSGfxRt; // newgfx: facet rect of pixture used for loose pixels
|
||||
int32_t PXSGfxSize;
|
||||
StdCopyStrBuf sBlastShiftTo;
|
||||
StdCopyStrBuf sInMatConvert;
|
||||
StdCopyStrBuf sInMatConvertTo;
|
||||
StdCopyStrBuf sBlastShiftTo;
|
||||
StdCopyStrBuf sInMatConvert;
|
||||
StdCopyStrBuf sInMatConvertTo;
|
||||
int32_t InMatConvertDepth; // material converts only if it finds the same material above
|
||||
int32_t BelowTempConvert;
|
||||
int32_t BelowTempConvertDir;
|
||||
StdCopyStrBuf sBelowTempConvertTo;
|
||||
int32_t AboveTempConvert;
|
||||
int32_t AboveTempConvertDir;
|
||||
StdCopyStrBuf sAboveTempConvertTo;
|
||||
int32_t BelowTempConvert;
|
||||
int32_t BelowTempConvertDir;
|
||||
StdCopyStrBuf sBelowTempConvertTo;
|
||||
int32_t AboveTempConvert;
|
||||
int32_t AboveTempConvertDir;
|
||||
StdCopyStrBuf sAboveTempConvertTo;
|
||||
int32_t ColorAnimation;
|
||||
int32_t TempConvStrength;
|
||||
int32_t MinHeightCount; // minimum material thickness in order for it to be counted
|
||||
int32_t SplashRate;
|
||||
int32_t SplashRate;
|
||||
public:
|
||||
void Clear();
|
||||
void Default();
|
||||
bool Load(C4Group &hGroup, const char *szEntryName);
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
};
|
||||
|
||||
class C4Material: public C4MaterialCore
|
||||
{
|
||||
public:
|
||||
C4Material();
|
||||
public:
|
||||
{
|
||||
public:
|
||||
C4Material();
|
||||
public:
|
||||
// Cross-mapped material values
|
||||
int32_t BlastShiftTo; // MatTex
|
||||
int32_t InMatConvertTo; // Mat
|
||||
int32_t BelowTempConvertTo; // MatTex
|
||||
int32_t AboveTempConvertTo; // MatTex
|
||||
int32_t BlastShiftTo; // MatTex
|
||||
int32_t InMatConvertTo; // Mat
|
||||
int32_t BelowTempConvertTo; // MatTex
|
||||
int32_t AboveTempConvertTo; // MatTex
|
||||
int32_t DefaultMatTex; // texture used for single pixel values
|
||||
C4Facet PXSFace; // loose pixel facet
|
||||
|
||||
void UpdateScriptPointers(); // set all material script pointers
|
||||
};
|
||||
};
|
||||
|
||||
class C4MaterialMap
|
||||
{
|
||||
public:
|
||||
C4MaterialMap();
|
||||
~C4MaterialMap();
|
||||
public:
|
||||
int32_t Num;
|
||||
C4Material *Map;
|
||||
{
|
||||
public:
|
||||
C4MaterialMap();
|
||||
~C4MaterialMap();
|
||||
public:
|
||||
int32_t Num;
|
||||
C4Material *Map;
|
||||
C4MaterialReaction **ppReactionMap;
|
||||
|
||||
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);
|
||||
// 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);
|
||||
public:
|
||||
public:
|
||||
void Default();
|
||||
void Clear();
|
||||
int32_t Load(C4Group &hGroup);
|
||||
void Clear();
|
||||
int32_t Load(C4Group &hGroup);
|
||||
bool HasMaterials(C4Group &hGroup) const;
|
||||
int32_t Get(const char *szMaterial);
|
||||
bool SaveEnumeration(C4Group &hGroup);
|
||||
int32_t Get(const char *szMaterial);
|
||||
bool SaveEnumeration(C4Group &hGroup);
|
||||
bool LoadEnumeration(C4Group &hGroup);
|
||||
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));
|
||||
|
@ -181,24 +181,24 @@ class C4MaterialMap
|
|||
C4MaterialReaction *GetReaction(int32_t iPXSMat, int32_t iLandscapeMat);
|
||||
void UpdateScriptPointers(); // set all material script pointers
|
||||
bool CrossMapMaterials();
|
||||
protected:
|
||||
protected:
|
||||
void SetMatReaction(int32_t iPXSMat, int32_t iLSMat, C4MaterialReaction *pReact);
|
||||
bool SortEnumeration(int32_t iMat, const char *szMatName);
|
||||
};
|
||||
};
|
||||
|
||||
extern C4MaterialMap MaterialMap;
|
||||
|
||||
const int32_t C4M_Flat = 0,
|
||||
C4M_TopFlat = 1,
|
||||
C4M_Smooth = 2,
|
||||
C4M_Rough = 3,
|
||||
C4M_TopFlat = 1,
|
||||
C4M_Smooth = 2,
|
||||
C4M_Rough = 3,
|
||||
|
||||
// Material Density Levels
|
||||
// Material Density Levels
|
||||
|
||||
C4M_Vehicle = 100,
|
||||
C4M_Solid = 50,
|
||||
C4M_SemiSolid = 25,
|
||||
C4M_Liquid = 25,
|
||||
C4M_Solid = 50,
|
||||
C4M_SemiSolid = 25,
|
||||
C4M_Liquid = 25,
|
||||
C4M_Background= 0;
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -217,9 +217,9 @@ inline bool MatVehicle(int32_t iMat)
|
|||
}
|
||||
|
||||
inline BYTE MatTex2PixCol(int32_t tex)
|
||||
{
|
||||
{
|
||||
return BYTE(tex);
|
||||
}
|
||||
}
|
||||
|
||||
inline BYTE Mat2PixColDefault(int32_t mat)
|
||||
{
|
||||
|
@ -227,22 +227,22 @@ inline BYTE Mat2PixColDefault(int32_t mat)
|
|||
}
|
||||
|
||||
inline int32_t MatDensity(int32_t mat)
|
||||
{
|
||||
if (!MatValid(mat)) return 0;
|
||||
return ::MaterialMap.Map[mat].Density;
|
||||
}
|
||||
{
|
||||
if (!MatValid(mat)) return 0;
|
||||
return ::MaterialMap.Map[mat].Density;
|
||||
}
|
||||
|
||||
inline int32_t MatPlacement(int32_t mat)
|
||||
{
|
||||
if (!MatValid(mat)) return 0;
|
||||
return ::MaterialMap.Map[mat].Placement;
|
||||
}
|
||||
{
|
||||
if (!MatValid(mat)) return 0;
|
||||
return ::MaterialMap.Map[mat].Placement;
|
||||
}
|
||||
|
||||
inline int32_t MatDigFree(int32_t mat)
|
||||
{
|
||||
if (!MatValid(mat)) return 1;
|
||||
return ::MaterialMap.Map[mat].DigFree;
|
||||
}
|
||||
{
|
||||
if (!MatValid(mat)) return 1;
|
||||
return ::MaterialMap.Map[mat].DigFree;
|
||||
}
|
||||
|
||||
int32_t PixCol2MatOld(BYTE pixc);
|
||||
int32_t PixCol2MatOld2(BYTE pixc);
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
static const FIXED WindDrift_Factor = itofix(1, 800);
|
||||
|
||||
void C4PXS::Execute()
|
||||
{
|
||||
{
|
||||
#ifdef DEBUGREC_PXS
|
||||
{
|
||||
C4RCExecPXS rc;
|
||||
|
@ -132,19 +132,19 @@ void C4PXS::Execute()
|
|||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void C4PXS::Deactivate()
|
||||
{
|
||||
{
|
||||
#ifdef DEBUGREC_PXS
|
||||
C4RCExecPXS rc;
|
||||
rc.x=x; rc.y=y; rc.iMat=Mat;
|
||||
rc.pos = 2;
|
||||
AddDbgRec(RCT_ExecPXS, &rc, sizeof(rc));
|
||||
#endif
|
||||
Mat=MNone;
|
||||
Mat=MNone;
|
||||
::PXS.Delete(this);
|
||||
}
|
||||
}
|
||||
|
||||
C4PXSSystem::C4PXSSystem()
|
||||
{
|
||||
|
@ -177,19 +177,19 @@ void C4PXSSystem::Clear()
|
|||
}
|
||||
|
||||
C4PXS* C4PXSSystem::New()
|
||||
{
|
||||
unsigned int cnt,cnt2;
|
||||
C4PXS *pxp;
|
||||
// Check chunks for available space
|
||||
for (cnt=0; cnt<PXSMaxChunk; cnt++)
|
||||
{
|
||||
// Create new chunk if necessary
|
||||
if (!Chunk[cnt])
|
||||
{
|
||||
if (!(Chunk[cnt]=new C4PXS[PXSChunkSize])) return NULL;
|
||||
{
|
||||
unsigned int cnt,cnt2;
|
||||
C4PXS *pxp;
|
||||
// Check chunks for available space
|
||||
for (cnt=0; cnt<PXSMaxChunk; cnt++)
|
||||
{
|
||||
// Create new chunk if necessary
|
||||
if (!Chunk[cnt])
|
||||
{
|
||||
if (!(Chunk[cnt]=new C4PXS[PXSChunkSize])) return NULL;
|
||||
iChunkPXS[cnt] = 0;
|
||||
}
|
||||
// Check this chunk for space
|
||||
}
|
||||
// Check this chunk for space
|
||||
if(iChunkPXS[cnt] < PXSChunkSize)
|
||||
for (cnt2=0,pxp=Chunk[cnt]; cnt2<PXSChunkSize; cnt2++,pxp++)
|
||||
if (pxp->Mat==MNone)
|
||||
|
@ -198,20 +198,20 @@ C4PXS* C4PXSSystem::New()
|
|||
iChunkPXS[cnt]++;
|
||||
return pxp;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool C4PXSSystem::Create(int32_t mat, FIXED ix, FIXED iy, FIXED ixdir, FIXED iydir)
|
||||
{
|
||||
C4PXS *pxp;
|
||||
if (!MatValid(mat)) return false;
|
||||
if (!(pxp=New())) return false;
|
||||
pxp->Mat=mat;
|
||||
pxp->x=ix; pxp->y=iy;
|
||||
pxp->xdir=ixdir; pxp->ydir=iydir;
|
||||
return true;
|
||||
}
|
||||
{
|
||||
C4PXS *pxp;
|
||||
if (!MatValid(mat)) return false;
|
||||
if (!(pxp=New())) return false;
|
||||
pxp->Mat=mat;
|
||||
pxp->x=ix; pxp->y=iy;
|
||||
pxp->xdir=ixdir; pxp->ydir=iydir;
|
||||
return true;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
int32_t cnt;
|
||||
for (cnt=0; cnt<num; cnt++)
|
||||
Create(mat,
|
||||
itofix(tx),itofix(ty),
|
||||
itofix(Random(level+1)-level/2)/10,
|
||||
itofix(Random(level+1)-level)/10);
|
||||
}
|
||||
{
|
||||
int32_t cnt;
|
||||
for (cnt=0; cnt<num; cnt++)
|
||||
Create(mat,
|
||||
itofix(tx),itofix(ty),
|
||||
itofix(Random(level+1)-level/2)/10,
|
||||
itofix(Random(level+1)-level)/10);
|
||||
}
|
||||
|
||||
bool C4PXSSystem::Save(C4Group &hGroup)
|
||||
{
|
||||
|
|
|
@ -25,16 +25,16 @@
|
|||
#include <C4Material.h>
|
||||
|
||||
class C4PXS
|
||||
{
|
||||
{
|
||||
C4PXS(): Mat(MNone), x(Fix0), y(Fix0), xdir(Fix0), ydir(Fix0) {}
|
||||
friend class C4PXSSystem;
|
||||
protected:
|
||||
int32_t Mat;
|
||||
FIXED x,y,xdir,ydir;
|
||||
protected:
|
||||
void Execute();
|
||||
void Deactivate();
|
||||
};
|
||||
protected:
|
||||
int32_t Mat;
|
||||
FIXED x,y,xdir,ydir;
|
||||
protected:
|
||||
void Execute();
|
||||
void Deactivate();
|
||||
};
|
||||
|
||||
const size_t PXSChunkSize=500,PXSMaxChunk=20;
|
||||
|
||||
|
|
|
@ -415,7 +415,7 @@ C4Particle *C4ParticleSystem::Create(C4ParticleDef *pOfDef,
|
|||
float x, float y,
|
||||
float xdir, float ydir,
|
||||
float a, int32_t b, C4ParticleList *pPxList,
|
||||
C4Object *pObj)
|
||||
C4Object *pObj)
|
||||
{
|
||||
// safety
|
||||
if (!pOfDef) return NULL;
|
||||
|
@ -437,10 +437,10 @@ C4Particle *C4ParticleSystem::Create(C4ParticleDef *pOfDef,
|
|||
pPrt->xdir=xdir; pPrt->ydir=ydir;
|
||||
pPrt->a=a; pPrt->b=b;
|
||||
pPrt->pDef = pOfDef;
|
||||
if(pPrt->pDef->Attach && pObj != NULL) {
|
||||
pPrt->x -= pObj->GetX();
|
||||
pPrt->y -= pObj->GetY();
|
||||
}
|
||||
if(pPrt->pDef->Attach && pObj != NULL) {
|
||||
pPrt->x -= pObj->GetX();
|
||||
pPrt->y -= pObj->GetY();
|
||||
}
|
||||
// call initialization
|
||||
if (!pOfDef->InitProc(pPrt,pObj))
|
||||
// failed :(
|
||||
|
@ -651,16 +651,16 @@ bool fxStdInit(C4Particle *pPrt, C4Object *pTarget)
|
|||
bool fxStdExec(C4Particle *pPrt, C4Object *pTarget)
|
||||
{
|
||||
|
||||
float dx = pPrt->x, dy = pPrt->y;
|
||||
float dxdir = pPrt->xdir, dydir = pPrt->ydir;
|
||||
// rel. position & movement
|
||||
if(pPrt->pDef->Attach && pTarget != NULL)
|
||||
{
|
||||
dx += pTarget->GetX();
|
||||
dy += pTarget->GetY();
|
||||
dxdir += fixtof(pTarget->xdir);
|
||||
dydir += fixtof(pTarget->ydir);
|
||||
}
|
||||
float dx = pPrt->x, dy = pPrt->y;
|
||||
float dxdir = pPrt->xdir, dydir = pPrt->ydir;
|
||||
// rel. position & movement
|
||||
if(pPrt->pDef->Attach && pTarget != NULL)
|
||||
{
|
||||
dx += pTarget->GetX();
|
||||
dy += pTarget->GetY();
|
||||
dxdir += fixtof(pTarget->xdir);
|
||||
dydir += fixtof(pTarget->ydir);
|
||||
}
|
||||
|
||||
// move
|
||||
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 ty=cgo.TargetY*pDef->Parallaxity[1]/100;
|
||||
|
||||
float dx = pPrt->x, dy = pPrt->y;
|
||||
float dxdir = pPrt->xdir, dydir = pPrt->ydir;
|
||||
// relative position & movement
|
||||
if(pPrt->pDef->Attach && pTarget != NULL)
|
||||
{
|
||||
dx += pTarget->GetX();
|
||||
dy += pTarget->GetY();
|
||||
dxdir += fixtof(pTarget->xdir);
|
||||
dydir += fixtof(pTarget->ydir);
|
||||
}
|
||||
float dx = pPrt->x, dy = pPrt->y;
|
||||
float dxdir = pPrt->xdir, dydir = pPrt->ydir;
|
||||
// relative position & movement
|
||||
if(pPrt->pDef->Attach && pTarget != NULL)
|
||||
{
|
||||
dx += pTarget->GetX();
|
||||
dy += pTarget->GetY();
|
||||
dxdir += fixtof(pTarget->xdir);
|
||||
dydir += fixtof(pTarget->ydir);
|
||||
}
|
||||
|
||||
// check if it's in screen range
|
||||
if (!Inside(dx, tx-pPrt->a, tx+cgo.Wdt+pPrt->a)) return;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
/* Notes
|
||||
|
||||
09-30-99
|
||||
09-30-99
|
||||
I have had the concept for this code for more than two years now.
|
||||
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)
|
||||
{
|
||||
int32_t d,dx,dy,aincr,bincr,xincr,yincr,x,y;
|
||||
int32_t d,dx,dy,aincr,bincr,xincr,yincr,x,y;
|
||||
// Y based
|
||||
if (Abs(iToX-rX)<Abs(iToY-rY))
|
||||
{
|
||||
xincr=(iToX>rX) ? +1 : -1; yincr=(iToY>rY) ? +1 : -1;
|
||||
dy=Abs(iToY-rY); dx=Abs(iToX-rX);
|
||||
if (Abs(iToX-rX)<Abs(iToY-rY))
|
||||
{
|
||||
xincr=(iToX>rX) ? +1 : -1; yincr=(iToY>rY) ? +1 : -1;
|
||||
dy=Abs(iToY-rY); dx=Abs(iToX-rX);
|
||||
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
|
||||
if (PointFree(x,y)) { rY=y; rX=x; } else return false;
|
||||
// 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)))
|
||||
return false;
|
||||
// Advance
|
||||
if (d>=0) { x+=xincr; d+=aincr; } else d+=bincr;
|
||||
}
|
||||
}
|
||||
if (d>=0) { x+=xincr; d+=aincr; } else d+=bincr;
|
||||
}
|
||||
}
|
||||
// X based
|
||||
else
|
||||
{
|
||||
yincr=(iToY>rY) ? +1 : -1; xincr=(iToX>rX) ? +1 : -1;
|
||||
else
|
||||
{
|
||||
yincr=(iToY>rY) ? +1 : -1; xincr=(iToX>rX) ? +1 : -1;
|
||||
dx=Abs(iToX-rX); dy=Abs(iToY-rY);
|
||||
d=2*dy-dx; aincr=2*(dy-dx); bincr=2*dy; x=rX; y=rY;
|
||||
for (x=rX; x!=iToX; x+=xincr)
|
||||
{
|
||||
{
|
||||
// Check point free
|
||||
if (PointFree(x,y)) { rY=y; rX=x; } else return false;
|
||||
// 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)))
|
||||
return false;
|
||||
// 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)
|
||||
{
|
||||
int32_t d,dx,dy,aincr,bincr,xincr,yincr,x,y;
|
||||
int32_t d,dx,dy,aincr,bincr,xincr,yincr,x,y;
|
||||
// Y based
|
||||
if (Abs(iToX-rX)<Abs(iToY-rY))
|
||||
{
|
||||
xincr=(iToX>rX) ? +1 : -1;
|
||||
if (Abs(iToX-rX)<Abs(iToY-rY))
|
||||
{
|
||||
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;
|
||||
for (y=rY; y!=iToY; y+=yincr)
|
||||
{
|
||||
for (y=rY; y!=iToY; y+=yincr)
|
||||
{
|
||||
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
|
||||
else
|
||||
{
|
||||
yincr=(iToY>rY) ? +1 : -1;
|
||||
xincr=(iToX>rX) ? +1 : -1;
|
||||
else
|
||||
{
|
||||
yincr=(iToY>rY) ? +1 : -1;
|
||||
xincr=(iToX>rX) ? +1 : -1;
|
||||
dx=Abs(iToX-rX); dy=Abs(iToY-rY);
|
||||
d=2*dy-dx; aincr=2*(dy-dx); bincr=2*dy; x=rX; y=rY;
|
||||
for (x=rX; x!=iToX; x+=xincr)
|
||||
{
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
|
|
|
@ -33,19 +33,19 @@
|
|||
//==================================== C4SVal ==============================================
|
||||
|
||||
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)
|
||||
{
|
||||
Std=std; Rnd=rnd; Min=min; Max=max;
|
||||
}
|
||||
{
|
||||
Std=std; Rnd=rnd; Min=min; Max=max;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
@ -53,39 +53,39 @@ void C4SVal::Default()
|
|||
}
|
||||
|
||||
void C4SVal::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkDefaultAdapt(Std, 0));
|
||||
if (!pComp->Seperator()) return;
|
||||
pComp->Value(mkDefaultAdapt(Rnd, 0));
|
||||
if (!pComp->Seperator()) return;
|
||||
pComp->Value(mkDefaultAdapt(Min, 0));
|
||||
if (!pComp->Seperator()) return;
|
||||
pComp->Value(mkDefaultAdapt(Max, 100));
|
||||
}
|
||||
{
|
||||
pComp->Value(mkDefaultAdapt(Std, 0));
|
||||
if (!pComp->Seperator()) return;
|
||||
pComp->Value(mkDefaultAdapt(Rnd, 0));
|
||||
if (!pComp->Seperator()) return;
|
||||
pComp->Value(mkDefaultAdapt(Min, 0));
|
||||
if (!pComp->Seperator()) return;
|
||||
pComp->Value(mkDefaultAdapt(Max, 100));
|
||||
}
|
||||
|
||||
//================================ C4Scenario ==========================================
|
||||
|
||||
C4Scenario::C4Scenario()
|
||||
{
|
||||
Default();
|
||||
}
|
||||
{
|
||||
Default();
|
||||
}
|
||||
|
||||
void C4Scenario::Default()
|
||||
{
|
||||
int32_t cnt;
|
||||
Head.Default();
|
||||
{
|
||||
int32_t cnt;
|
||||
Head.Default();
|
||||
Definitions.Default();
|
||||
Game.Default();
|
||||
for (cnt=0; cnt<C4S_MaxPlayer; cnt++) PlrStart[cnt].Default();
|
||||
Landscape.Default();
|
||||
Animals.Default();
|
||||
Weather.Default();
|
||||
Game.Realism.Default();
|
||||
Game.Default();
|
||||
for (cnt=0; cnt<C4S_MaxPlayer; cnt++) PlrStart[cnt].Default();
|
||||
Landscape.Default();
|
||||
Animals.Default();
|
||||
Weather.Default();
|
||||
Game.Realism.Default();
|
||||
Environment.Default();
|
||||
}
|
||||
}
|
||||
|
||||
bool C4Scenario::Load(C4Group &hGroup, bool fLoadSection)
|
||||
{
|
||||
{
|
||||
char *pSource;
|
||||
// Load
|
||||
if (!hGroup.LoadEntry(C4CFN_ScenarioCore,&pSource,NULL,1)) return false;
|
||||
|
@ -94,7 +94,7 @@ bool C4Scenario::Load(C4Group &hGroup, bool fLoadSection)
|
|||
delete [] pSource;
|
||||
// Success
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(mkParAdapt(Head, fSection), "Head"));
|
||||
if (!fSection) pComp->Value(mkNamingAdapt(Definitions, "Definitions"));
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(mkParAdapt(Head, fSection), "Head"));
|
||||
if (!fSection) pComp->Value(mkNamingAdapt(Definitions, "Definitions"));
|
||||
pComp->Value(mkNamingAdapt(mkParAdapt(Game, fSection), "Game"));
|
||||
for(int32_t i = 0; i < C4S_MaxPlayer; i++)
|
||||
pComp->Value(mkNamingAdapt(PlrStart[i], FormatString("Player%d", i+1).getData()));
|
||||
pComp->Value(mkNamingAdapt(Landscape, "Landscape"));
|
||||
pComp->Value(mkNamingAdapt(Animals, "Animals"));
|
||||
pComp->Value(mkNamingAdapt(Weather, "Weather"));
|
||||
pComp->Value(mkNamingAdapt(Environment, "Environment"));
|
||||
}
|
||||
for(int32_t i = 0; i < C4S_MaxPlayer; i++)
|
||||
pComp->Value(mkNamingAdapt(PlrStart[i], FormatString("Player%d", i+1).getData()));
|
||||
pComp->Value(mkNamingAdapt(Landscape, "Landscape"));
|
||||
pComp->Value(mkNamingAdapt(Animals, "Animals"));
|
||||
pComp->Value(mkNamingAdapt(Weather, "Weather"));
|
||||
pComp->Value(mkNamingAdapt(Environment, "Environment"));
|
||||
}
|
||||
|
||||
int32_t C4Scenario::GetMinPlayer()
|
||||
{
|
||||
|
@ -132,7 +132,7 @@ int32_t C4Scenario::GetMinPlayer()
|
|||
}
|
||||
|
||||
void C4SDefinitions::Default()
|
||||
{
|
||||
{
|
||||
LocalOnly=AllowUserChange=false;
|
||||
ZeroMem(Definition,sizeof (Definition));
|
||||
SkipDefs.Default();
|
||||
|
@ -141,7 +141,7 @@ void C4SDefinitions::Default()
|
|||
const int32_t C4S_MaxPlayerDefault = 12;
|
||||
|
||||
void C4SHead::Default()
|
||||
{
|
||||
{
|
||||
Origin.Clear();
|
||||
Icon=18;
|
||||
*Title = *Loader = *Font = *Engine = *MissionAccess = '\0';
|
||||
|
@ -153,10 +153,10 @@ void C4SHead::Default()
|
|||
MaxPlayer=MaxPlayerLeague=C4S_MaxPlayerDefault;
|
||||
MinPlayer=0; // auto-determine by mode
|
||||
SCopy("Default Title",Title,C4MaxTitle);
|
||||
}
|
||||
}
|
||||
|
||||
void C4SHead::CompileFunc(StdCompiler *pComp, bool fSection)
|
||||
{
|
||||
{
|
||||
if (!fSection)
|
||||
{
|
||||
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
|
||||
if (pComp->isCompiler()) Origin.ReplaceChar(AltDirectorySeparator, DirectorySeparator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void C4SGame::Default()
|
||||
{
|
||||
{
|
||||
Goals.Clear();
|
||||
Rules.Clear();
|
||||
FoWColor=0;
|
||||
}
|
||||
}
|
||||
|
||||
void C4SGame::CompileFunc(StdCompiler *pComp, bool fSection)
|
||||
{
|
||||
{
|
||||
if (!fSection)
|
||||
{
|
||||
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.LandscapeInsertThrust), "LandscapeInsertThrust",true));
|
||||
|
||||
pComp->Value(mkNamingAdapt(Goals, "Goals", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(Rules, "Rules", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(FoWColor, "FoWColor", 0u));
|
||||
}
|
||||
pComp->Value(mkNamingAdapt(Goals, "Goals", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(Rules, "Rules", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(FoWColor, "FoWColor", 0u));
|
||||
}
|
||||
|
||||
void C4SPlrStart::Default()
|
||||
{
|
||||
{
|
||||
NativeCrew=C4ID::None;
|
||||
Crew.Set(1,0,1,10);
|
||||
Wealth.Set(0,0,0,250);
|
||||
Position[0]=Position[1]=-1;
|
||||
Crew.Set(1,0,1,10);
|
||||
Wealth.Set(0,0,0,250);
|
||||
Position[0]=Position[1]=-1;
|
||||
EnforcePosition=0;
|
||||
ReadyCrew.Default();
|
||||
ReadyBase.Default();
|
||||
ReadyVehic.Default();
|
||||
ReadyMaterial.Default();
|
||||
BuildKnowledge.Default();
|
||||
HomeBaseMaterial.Default();
|
||||
HomeBaseProduction.Default();
|
||||
ReadyBase.Default();
|
||||
ReadyVehic.Default();
|
||||
ReadyMaterial.Default();
|
||||
BuildKnowledge.Default();
|
||||
HomeBaseMaterial.Default();
|
||||
HomeBaseProduction.Default();
|
||||
Magic.Default();
|
||||
}
|
||||
}
|
||||
|
||||
bool C4SPlrStart::EquipmentEqual(C4SPlrStart &rhs)
|
||||
{
|
||||
|
@ -248,44 +248,44 @@ bool C4SPlrStart::operator==(const C4SPlrStart& rhs)
|
|||
}
|
||||
|
||||
void C4SPlrStart::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(NativeCrew, "StandardCrew", C4ID::None));
|
||||
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(mkArrayAdaptDM(Position,-1), "Position" ));
|
||||
pComp->Value(mkNamingAdapt(EnforcePosition, "EnforcePosition", 0));
|
||||
pComp->Value(mkNamingAdapt(ReadyCrew, "Crew", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(ReadyBase, "Buildings", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(ReadyVehic, "Vehicles", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(ReadyMaterial, "Material", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(BuildKnowledge, "Knowledge", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(HomeBaseMaterial, "HomeBaseMaterial", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(HomeBaseProduction, "HomeBaseProduction", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(Magic, "Magic", C4IDList()));
|
||||
}
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(NativeCrew, "StandardCrew", C4ID::None));
|
||||
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(mkArrayAdaptDM(Position,-1), "Position" ));
|
||||
pComp->Value(mkNamingAdapt(EnforcePosition, "EnforcePosition", 0));
|
||||
pComp->Value(mkNamingAdapt(ReadyCrew, "Crew", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(ReadyBase, "Buildings", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(ReadyVehic, "Vehicles", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(ReadyMaterial, "Material", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(BuildKnowledge, "Knowledge", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(HomeBaseMaterial, "HomeBaseMaterial", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(HomeBaseProduction, "HomeBaseProduction", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(Magic, "Magic", C4IDList()));
|
||||
}
|
||||
|
||||
void C4SLandscape::Default()
|
||||
{
|
||||
BottomOpen=0; TopOpen=1;
|
||||
LeftOpen=0; RightOpen=0;
|
||||
AutoScanSideOpen=1;
|
||||
SkyDef[0]=0;
|
||||
{
|
||||
BottomOpen=0; TopOpen=1;
|
||||
LeftOpen=0; RightOpen=0;
|
||||
AutoScanSideOpen=1;
|
||||
SkyDef[0]=0;
|
||||
NoSky=0;
|
||||
for (int32_t cnt=0; cnt<6; cnt++) SkyDefFade[cnt]=0;
|
||||
VegLevel.Set(50,30,0,100);
|
||||
Vegetation.Default();
|
||||
InEarthLevel.Set(50,0,0,100);
|
||||
InEarth.Default();
|
||||
MapWdt.Set(100,0,64,250);
|
||||
MapHgt.Set(50,0,40,250);
|
||||
MapZoom.Set(10,0,5,15);
|
||||
Amplitude.Set(0,0);
|
||||
Phase.Set(50);
|
||||
Period.Set(15);
|
||||
Random.Set(0);
|
||||
LiquidLevel.Default();
|
||||
MapPlayerExtend=0;
|
||||
Layers.Clear();
|
||||
for (int32_t cnt=0; cnt<6; cnt++) SkyDefFade[cnt]=0;
|
||||
VegLevel.Set(50,30,0,100);
|
||||
Vegetation.Default();
|
||||
InEarthLevel.Set(50,0,0,100);
|
||||
InEarth.Default();
|
||||
MapWdt.Set(100,0,64,250);
|
||||
MapHgt.Set(50,0,40,250);
|
||||
MapZoom.Set(10,0,5,15);
|
||||
Amplitude.Set(0,0);
|
||||
Phase.Set(50);
|
||||
Period.Set(15);
|
||||
Random.Set(0);
|
||||
LiquidLevel.Default();
|
||||
MapPlayerExtend=0;
|
||||
Layers.Clear();
|
||||
SCopy("Earth",Material,C4M_MaxName);
|
||||
SCopy("Water",Liquid,C4M_MaxName);
|
||||
ExactLandscape=0;
|
||||
|
@ -307,109 +307,109 @@ void C4SLandscape::GetMapSize(int32_t &rWdt, int32_t &rHgt, int32_t iPlayerNum)
|
|||
}
|
||||
|
||||
void C4SLandscape::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(ExactLandscape, "ExactLandscape", false));
|
||||
pComp->Value(mkNamingAdapt(Vegetation, "Vegetation", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(VegLevel, "VegetationLevel", C4SVal(50,30,0,100), true));
|
||||
pComp->Value(mkNamingAdapt(InEarth, "InEarth", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(InEarthLevel, "InEarthLevel", C4SVal(50,0,0,100), true));
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(SkyDef), "Sky", ""));
|
||||
pComp->Value(mkNamingAdapt(mkArrayAdaptDM(SkyDefFade,0),"SkyFade" ));
|
||||
pComp->Value(mkNamingAdapt(NoSky, "NoSky", false));
|
||||
pComp->Value(mkNamingAdapt(BottomOpen, "BottomOpen", false));
|
||||
pComp->Value(mkNamingAdapt(TopOpen, "TopOpen", true));
|
||||
pComp->Value(mkNamingAdapt(LeftOpen, "LeftOpen", 0));
|
||||
pComp->Value(mkNamingAdapt(RightOpen, "RightOpen", 0));
|
||||
pComp->Value(mkNamingAdapt(AutoScanSideOpen, "AutoScanSideOpen", 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(ExactLandscape, "ExactLandscape", false));
|
||||
pComp->Value(mkNamingAdapt(Vegetation, "Vegetation", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(VegLevel, "VegetationLevel", C4SVal(50,30,0,100), true));
|
||||
pComp->Value(mkNamingAdapt(InEarth, "InEarth", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(InEarthLevel, "InEarthLevel", C4SVal(50,0,0,100), true));
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(SkyDef), "Sky", ""));
|
||||
pComp->Value(mkNamingAdapt(mkArrayAdaptDM(SkyDefFade,0),"SkyFade" ));
|
||||
pComp->Value(mkNamingAdapt(NoSky, "NoSky", false));
|
||||
pComp->Value(mkNamingAdapt(BottomOpen, "BottomOpen", false));
|
||||
pComp->Value(mkNamingAdapt(TopOpen, "TopOpen", true));
|
||||
pComp->Value(mkNamingAdapt(LeftOpen, "LeftOpen", 0));
|
||||
pComp->Value(mkNamingAdapt(RightOpen, "RightOpen", 0));
|
||||
pComp->Value(mkNamingAdapt(AutoScanSideOpen, "AutoScanSideOpen", 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(MapZoom, "MapZoom", C4SVal(10,0,5,15), true));
|
||||
pComp->Value(mkNamingAdapt(Amplitude, "Amplitude", C4SVal(0)));
|
||||
pComp->Value(mkNamingAdapt(Phase, "Phase", C4SVal(50)));
|
||||
pComp->Value(mkNamingAdapt(Period, "Period", C4SVal(15)));
|
||||
pComp->Value(mkNamingAdapt(Random, "Random", C4SVal(0)));
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Material),"Material", "Earth"));
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Liquid), "Liquid", "Water"));
|
||||
pComp->Value(mkNamingAdapt(LiquidLevel, "LiquidLevel", C4SVal()));
|
||||
pComp->Value(mkNamingAdapt(MapPlayerExtend, "MapPlayerExtend", 0));
|
||||
pComp->Value(mkNamingAdapt(Layers, "Layers", C4NameList()));
|
||||
pComp->Value(mkNamingAdapt(Gravity, "Gravity", C4SVal(100,0,10,200), true));
|
||||
pComp->Value(mkNamingAdapt(NoScan, "NoScan", false));
|
||||
pComp->Value(mkNamingAdapt(KeepMapCreator, "KeepMapCreator", false));
|
||||
pComp->Value(mkNamingAdapt(SkyScrollMode, "SkyScrollMode", 0));
|
||||
pComp->Value(mkNamingAdapt(NewStyleLandscape, "NewStyleLandscape", false));
|
||||
pComp->Value(mkNamingAdapt(Amplitude, "Amplitude", C4SVal(0)));
|
||||
pComp->Value(mkNamingAdapt(Phase, "Phase", C4SVal(50)));
|
||||
pComp->Value(mkNamingAdapt(Period, "Period", C4SVal(15)));
|
||||
pComp->Value(mkNamingAdapt(Random, "Random", C4SVal(0)));
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Material),"Material", "Earth"));
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Liquid), "Liquid", "Water"));
|
||||
pComp->Value(mkNamingAdapt(LiquidLevel, "LiquidLevel", C4SVal()));
|
||||
pComp->Value(mkNamingAdapt(MapPlayerExtend, "MapPlayerExtend", 0));
|
||||
pComp->Value(mkNamingAdapt(Layers, "Layers", C4NameList()));
|
||||
pComp->Value(mkNamingAdapt(Gravity, "Gravity", C4SVal(100,0,10,200), true));
|
||||
pComp->Value(mkNamingAdapt(NoScan, "NoScan", false));
|
||||
pComp->Value(mkNamingAdapt(KeepMapCreator, "KeepMapCreator", false));
|
||||
pComp->Value(mkNamingAdapt(SkyScrollMode, "SkyScrollMode", 0));
|
||||
pComp->Value(mkNamingAdapt(NewStyleLandscape, "NewStyleLandscape", false));
|
||||
pComp->Value(mkNamingAdapt(FoWRes, "FoWRes", static_cast<int32_t>(CClrModAddMap::DefResolutionX)));
|
||||
}
|
||||
}
|
||||
|
||||
void C4SWeather::Default()
|
||||
{
|
||||
Climate.Set(50,10);
|
||||
StartSeason.Set(50,50);
|
||||
YearSpeed.Set(50);
|
||||
Rain.Default(); Wind.Set(0,70,-100,+100);
|
||||
{
|
||||
Climate.Set(50,10);
|
||||
StartSeason.Set(50,50);
|
||||
YearSpeed.Set(50);
|
||||
Rain.Default(); Wind.Set(0,70,-100,+100);
|
||||
SCopy("Water",Precipitation,C4M_MaxName);
|
||||
NoGamma=1;
|
||||
}
|
||||
}
|
||||
|
||||
void C4SWeather::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(Climate, "Climate", C4SVal(50,10), true));
|
||||
pComp->Value(mkNamingAdapt(StartSeason, "StartSeason", C4SVal(50,50), true));
|
||||
pComp->Value(mkNamingAdapt(YearSpeed, "YearSpeed", C4SVal(50)));
|
||||
pComp->Value(mkNamingAdapt(Rain, "Rain", C4SVal()));
|
||||
pComp->Value(mkNamingAdapt(Wind, "Wind", C4SVal(0,70,-100,+100), true));
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Precipitation),"Precipitation", "Water"));
|
||||
pComp->Value(mkNamingAdapt(NoGamma, "NoGamma", true));
|
||||
}
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(Climate, "Climate", C4SVal(50,10), true));
|
||||
pComp->Value(mkNamingAdapt(StartSeason, "StartSeason", C4SVal(50,50), true));
|
||||
pComp->Value(mkNamingAdapt(YearSpeed, "YearSpeed", C4SVal(50)));
|
||||
pComp->Value(mkNamingAdapt(Rain, "Rain", C4SVal()));
|
||||
pComp->Value(mkNamingAdapt(Wind, "Wind", C4SVal(0,70,-100,+100), true));
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Precipitation),"Precipitation", "Water"));
|
||||
pComp->Value(mkNamingAdapt(NoGamma, "NoGamma", true));
|
||||
}
|
||||
|
||||
void C4SAnimals::Default()
|
||||
{
|
||||
FreeLife.Clear();
|
||||
EarthNest.Clear();
|
||||
}
|
||||
{
|
||||
FreeLife.Clear();
|
||||
EarthNest.Clear();
|
||||
}
|
||||
|
||||
void C4SAnimals::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(FreeLife, "Animal", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(EarthNest, "Nest", C4IDList()));
|
||||
}
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(FreeLife, "Animal", C4IDList()));
|
||||
pComp->Value(mkNamingAdapt(EarthNest, "Nest", C4IDList()));
|
||||
}
|
||||
|
||||
void C4SEnvironment::Default()
|
||||
{
|
||||
Objects.Clear();
|
||||
}
|
||||
{
|
||||
Objects.Clear();
|
||||
}
|
||||
|
||||
void C4SEnvironment::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(Objects, "Objects", C4IDList()));
|
||||
}
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(Objects, "Objects", C4IDList()));
|
||||
}
|
||||
|
||||
void C4SRealism::Default()
|
||||
{
|
||||
{
|
||||
LandscapePushPull=0;
|
||||
LandscapeInsertThrust=0;
|
||||
ValueOverloads.Default();
|
||||
}
|
||||
}
|
||||
|
||||
bool C4Scenario::Compile(const char *szSource, bool fLoadSection)
|
||||
{
|
||||
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)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Decompile
|
||||
StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkParAdapt(*this, fSaveSection));
|
||||
// Return
|
||||
*ppOutput = Buf.GrabPointer();
|
||||
*ipSize = Buf.getSize();
|
||||
}
|
||||
catch(StdCompiler::Exception *)
|
||||
{ return false; }
|
||||
return true;
|
||||
try
|
||||
{
|
||||
// Decompile
|
||||
StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkParAdapt(*this, fSaveSection));
|
||||
// Return
|
||||
*ppOutput = Buf.GrabPointer();
|
||||
*ipSize = Buf.getSize();
|
||||
}
|
||||
catch(StdCompiler::Exception *)
|
||||
{ return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
void C4Scenario::Clear()
|
||||
|
@ -522,13 +522,13 @@ bool C4SDefinitions::AssertModules(const char *szPath, char *sMissing)
|
|||
}
|
||||
|
||||
void C4SDefinitions::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(LocalOnly, "LocalOnly", false));
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(LocalOnly, "LocalOnly", false));
|
||||
pComp->Value(mkNamingAdapt(AllowUserChange, "AllowUserChange", false));
|
||||
for(int32_t i = 0; i < C4S_MaxDefinitions; i++)
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Definition[i]), FormatString("Definition%i", i+1).getData(), ""));
|
||||
pComp->Value(mkNamingAdapt(SkipDefs, "SkipDefs", C4IDList()));
|
||||
}
|
||||
for(int32_t i = 0; i < C4S_MaxDefinitions; i++)
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Definition[i]), FormatString("Definition%i", i+1).getData(), ""));
|
||||
pComp->Value(mkNamingAdapt(SkipDefs, "SkipDefs", C4IDList()));
|
||||
}
|
||||
|
||||
bool C4SGame::IsMelee()
|
||||
{
|
||||
|
|
|
@ -29,22 +29,22 @@
|
|||
class C4Group;
|
||||
|
||||
class C4SVal
|
||||
{
|
||||
public:
|
||||
C4SVal(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100);
|
||||
public:
|
||||
int32_t Std,Rnd,Min,Max;
|
||||
public:
|
||||
{
|
||||
public:
|
||||
C4SVal(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100);
|
||||
public:
|
||||
int32_t Std,Rnd,Min,Max;
|
||||
public:
|
||||
void Default();
|
||||
void Set(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100);
|
||||
int32_t Evaluate();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
void Set(int32_t std=0, int32_t rnd=0, int32_t min=0, int32_t max=100);
|
||||
int32_t Evaluate();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
public:
|
||||
inline bool operator==(const C4SVal &rhs) const
|
||||
{
|
||||
return rhs.Std == Std && rhs.Rnd == Rnd && rhs.Min == Min && rhs.Max == Max;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#define C4SGFXMODE_NEWGFX 1
|
||||
#define C4SGFXMODE_OLDGFX 2
|
||||
|
@ -71,12 +71,12 @@ enum C4SFilmMode
|
|||
};
|
||||
|
||||
class C4SHead
|
||||
{
|
||||
public:
|
||||
{
|
||||
public:
|
||||
int32_t C4XVer[4];
|
||||
char Title[C4MaxTitle+1];
|
||||
char Loader[C4MaxTitle+1];
|
||||
char Font[C4MaxTitle+1]; // scenario specific font; may be 0
|
||||
char Title[C4MaxTitle+1];
|
||||
char Loader[C4MaxTitle+1];
|
||||
char Font[C4MaxTitle+1]; // scenario specific font; may be 0
|
||||
int32_t Difficulty;
|
||||
int32_t Icon;
|
||||
int32_t NoInitialize;
|
||||
|
@ -93,10 +93,10 @@ class C4SHead
|
|||
int32_t ForcedFairCrew; // 0: free; 1: force FairCrew; 2: force normal Crew (C4SForceFairCrew)
|
||||
int32_t FairCrewStrength;
|
||||
StdCopyStrBuf Origin; // original oath and filename to scenario (for records and savegames)
|
||||
public:
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp, bool fSection);
|
||||
};
|
||||
public:
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp, bool fSection);
|
||||
};
|
||||
|
||||
|
||||
const int32_t C4S_MaxDefinitions = 10;
|
||||
|
@ -108,30 +108,30 @@ class C4SDefinitions
|
|||
int32_t AllowUserChange;
|
||||
char Definition[C4S_MaxDefinitions][_MAX_PATH+1];
|
||||
C4IDList SkipDefs;
|
||||
public:
|
||||
public:
|
||||
void SetModules(const char *szList, const char *szRelativeToPath=NULL, const char *szRelativeToPath2=NULL);
|
||||
bool GetModules(StdStrBuf *psOutModules) const;
|
||||
bool AssertModules(const char *szPath=NULL, char *sMissing=NULL);
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
|
||||
|
||||
class C4SRealism
|
||||
{
|
||||
public:
|
||||
{
|
||||
public:
|
||||
C4IDList ValueOverloads;
|
||||
int32_t LandscapePushPull; // Use new experimental push-pull-algorithms
|
||||
int32_t LandscapeInsertThrust; // Inserted material may thrust material of lower density aside
|
||||
|
||||
public:
|
||||
void Default();
|
||||
};
|
||||
public:
|
||||
void Default();
|
||||
};
|
||||
|
||||
|
||||
class C4SGame
|
||||
{
|
||||
public:
|
||||
{
|
||||
public:
|
||||
C4IDList Goals;
|
||||
C4IDList Rules;
|
||||
|
||||
|
@ -139,10 +139,10 @@ class C4SGame
|
|||
|
||||
C4SRealism Realism;
|
||||
|
||||
public:
|
||||
public:
|
||||
bool IsMelee();
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp, bool fSection);
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp, bool fSection);
|
||||
};
|
||||
|
||||
// Maximum map player extend factor
|
||||
|
@ -150,120 +150,120 @@ class C4SGame
|
|||
const int32_t C4S_MaxMapPlayerExtend = 4;
|
||||
|
||||
class C4SPlrStart
|
||||
{
|
||||
public:
|
||||
{
|
||||
public:
|
||||
C4ID NativeCrew; // Obsolete
|
||||
C4SVal Crew; // Obsolete
|
||||
C4SVal Wealth;
|
||||
int32_t Position[2];
|
||||
C4SVal Crew; // Obsolete
|
||||
C4SVal Wealth;
|
||||
int32_t Position[2];
|
||||
int32_t EnforcePosition;
|
||||
C4IDList ReadyCrew;
|
||||
C4IDList ReadyBase;
|
||||
C4IDList ReadyVehic;
|
||||
C4IDList ReadyMaterial;
|
||||
C4IDList BuildKnowledge;
|
||||
C4IDList HomeBaseMaterial;
|
||||
C4IDList HomeBaseProduction;
|
||||
C4IDList ReadyBase;
|
||||
C4IDList ReadyVehic;
|
||||
C4IDList ReadyMaterial;
|
||||
C4IDList BuildKnowledge;
|
||||
C4IDList HomeBaseMaterial;
|
||||
C4IDList HomeBaseProduction;
|
||||
C4IDList Magic;
|
||||
public:
|
||||
void Default();
|
||||
public:
|
||||
void Default();
|
||||
bool EquipmentEqual(C4SPlrStart &rhs);
|
||||
bool operator==(const C4SPlrStart& rhs);
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
|
||||
|
||||
class C4SLandscape
|
||||
{
|
||||
public:
|
||||
{
|
||||
public:
|
||||
int32_t ExactLandscape;
|
||||
C4SVal VegLevel;
|
||||
C4IDList Vegetation;
|
||||
C4SVal InEarthLevel;
|
||||
C4IDList InEarth;
|
||||
int32_t BottomOpen,TopOpen;
|
||||
int32_t LeftOpen,RightOpen;
|
||||
int32_t AutoScanSideOpen;
|
||||
char SkyDef[C4MaxDefString+1];
|
||||
int32_t SkyDefFade[6];
|
||||
C4SVal VegLevel;
|
||||
C4IDList Vegetation;
|
||||
C4SVal InEarthLevel;
|
||||
C4IDList InEarth;
|
||||
int32_t BottomOpen,TopOpen;
|
||||
int32_t LeftOpen,RightOpen;
|
||||
int32_t AutoScanSideOpen;
|
||||
char SkyDef[C4MaxDefString+1];
|
||||
int32_t SkyDefFade[6];
|
||||
int32_t NoSky;
|
||||
int32_t NoScan;
|
||||
C4SVal Gravity;
|
||||
// Dynamic map
|
||||
C4SVal MapWdt,MapHgt,MapZoom;
|
||||
C4SVal Amplitude,Phase,Period,Random;
|
||||
C4SVal LiquidLevel;
|
||||
int32_t MapPlayerExtend;
|
||||
C4NameList Layers;
|
||||
// Dynamic map
|
||||
C4SVal MapWdt,MapHgt,MapZoom;
|
||||
C4SVal Amplitude,Phase,Period,Random;
|
||||
C4SVal LiquidLevel;
|
||||
int32_t MapPlayerExtend;
|
||||
C4NameList Layers;
|
||||
char Material[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 SkyScrollMode; // sky scrolling mode for newgfx
|
||||
int32_t NewStyleLandscape; // if set to 2, the landscape uses up to 125 mat/texture pairs
|
||||
int32_t FoWRes; // chunk size of FoGOfWar
|
||||
public:
|
||||
void Default();
|
||||
public:
|
||||
void Default();
|
||||
void GetMapSize(int32_t &rWdt, int32_t &rHgt, int32_t iPlayerNum);
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
|
||||
class C4SWeather
|
||||
{
|
||||
public:
|
||||
C4SVal Climate;
|
||||
C4SVal StartSeason,YearSpeed;
|
||||
C4SVal Rain,Wind;
|
||||
{
|
||||
public:
|
||||
C4SVal Climate;
|
||||
C4SVal StartSeason,YearSpeed;
|
||||
C4SVal Rain,Wind;
|
||||
char Precipitation[C4M_MaxName+1];
|
||||
int32_t NoGamma;
|
||||
public:
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
public:
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
|
||||
class C4SAnimals
|
||||
{
|
||||
public:
|
||||
C4IDList FreeLife;
|
||||
{
|
||||
public:
|
||||
C4IDList FreeLife;
|
||||
C4IDList EarthNest;
|
||||
public:
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
public:
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
|
||||
class C4SEnvironment
|
||||
{
|
||||
public:
|
||||
C4IDList Objects;
|
||||
public:
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
{
|
||||
public:
|
||||
C4IDList Objects;
|
||||
public:
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
|
||||
class C4Scenario
|
||||
{
|
||||
public:
|
||||
C4Scenario();
|
||||
public:
|
||||
C4SHead Head;
|
||||
{
|
||||
public:
|
||||
C4Scenario();
|
||||
public:
|
||||
C4SHead Head;
|
||||
C4SDefinitions Definitions;
|
||||
C4SGame Game;
|
||||
C4SPlrStart PlrStart[C4S_MaxPlayer];
|
||||
C4SLandscape Landscape;
|
||||
C4SAnimals Animals;
|
||||
C4SWeather Weather;
|
||||
C4SGame Game;
|
||||
C4SPlrStart PlrStart[C4S_MaxPlayer];
|
||||
C4SLandscape Landscape;
|
||||
C4SAnimals Animals;
|
||||
C4SWeather Weather;
|
||||
C4SEnvironment Environment;
|
||||
public:
|
||||
public:
|
||||
void SetExactLandscape();
|
||||
void Clear();
|
||||
void Default();
|
||||
bool Load(C4Group &hGroup, bool fLoadSection=false);
|
||||
void Default();
|
||||
bool Load(C4Group &hGroup, bool fLoadSection=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
|
||||
protected:
|
||||
bool Compile(const char *szSource, bool fLoadSection=false);
|
||||
bool Decompile(char **ppOutput, int32_t *ipSize, bool fSaveSection=false);
|
||||
};
|
||||
};
|
||||
|
||||
class C4ScenarioSection;
|
||||
|
||||
|
|
|
@ -60,21 +60,21 @@ static bool SurfaceEnsureSize(C4Surface **ppSfc, int iMinWdt, int iMinHgt)
|
|||
}
|
||||
|
||||
void C4Sky::SetFadePalette(int32_t *ipColors)
|
||||
{
|
||||
// If colors all zero, use game palette default blue
|
||||
if (ipColors[0]+ipColors[1]+ipColors[2]+ipColors[3]+ipColors[4]+ipColors[5]==0)
|
||||
{
|
||||
{
|
||||
// If colors all zero, use game palette default blue
|
||||
if (ipColors[0]+ipColors[1]+ipColors[2]+ipColors[3]+ipColors[4]+ipColors[5]==0)
|
||||
{
|
||||
BYTE *pClr=::GraphicsResource.GamePalette+3*CSkyDef1;
|
||||
FadeClr1=C4RGB(pClr[0], pClr[1], pClr[2]);
|
||||
FadeClr2=C4RGB(pClr[3*19+0], pClr[3*19+1], pClr[3*19+2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// set colors
|
||||
FadeClr1=C4RGB(ipColors[0], ipColors[1], ipColors[2]);
|
||||
FadeClr2=C4RGB(ipColors[3], ipColors[4], ipColors[5]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool C4Sky::Init(bool fSavegame)
|
||||
{
|
||||
|
@ -165,8 +165,8 @@ bool C4Sky::Init(bool fSavegame)
|
|||
}
|
||||
|
||||
// Success
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void C4Sky::Default()
|
||||
{
|
||||
|
@ -261,7 +261,7 @@ bool C4Sky::SetModulation(DWORD dwWithClr, DWORD dwBackClr)
|
|||
}
|
||||
|
||||
void C4Sky::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(mkCastIntAdapt(x), "X", Fix0));
|
||||
pComp->Value(mkNamingAdapt(mkCastIntAdapt(y), "Y", 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(BackClr, "BackClr", 0));
|
||||
pComp->Value(mkNamingAdapt(BackClrEnabled, "BackClrEnabled", false));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,11 +34,11 @@ void C4SolidMask::Put(bool fCauseInstability, C4TargetRect *pClipRect, bool fRes
|
|||
// If not put, put mask to background,
|
||||
// storing background pixels in cSolidMask.
|
||||
|
||||
// No mask
|
||||
if (!pSolidMask || !pSolidMaskMatBuff) { iAttachingObjectsCount = 0; return; }
|
||||
// Contained
|
||||
if (pForObject->Contained) { iAttachingObjectsCount = 0; return; }
|
||||
// Mask is put
|
||||
// No mask
|
||||
if (!pSolidMask || !pSolidMaskMatBuff) { iAttachingObjectsCount = 0; return; }
|
||||
// Contained
|
||||
if (pForObject->Contained) { iAttachingObjectsCount = 0; return; }
|
||||
// Mask is put
|
||||
if (fCauseInstability) CheckConsistency();
|
||||
|
||||
bool RegularPut;
|
||||
|
@ -57,11 +57,11 @@ void C4SolidMask::Put(bool fCauseInstability, C4TargetRect *pClipRect, bool fRes
|
|||
if (!pClipRect->ClipBy(MaskPutRect)) return;
|
||||
RegularPut = false;
|
||||
}
|
||||
// Lock mask surface
|
||||
int iPitch = pForObject->SolidMask.Wdt;
|
||||
// Lock mask surface
|
||||
int iPitch = pForObject->SolidMask.Wdt;
|
||||
int xcnt,ycnt,iTx,iTy;
|
||||
// Put mask pixels
|
||||
BYTE byPixel;
|
||||
BYTE byPixel;
|
||||
// not rotated?
|
||||
if (!MaskPutRotation)
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ void C4SolidMask::Remove(bool fCauseInstability, bool fBackupAttachment)
|
|||
// If put, restore background pixels from buffer
|
||||
|
||||
// Not put
|
||||
if (!MaskPut || !pSolidMask || !pSolidMaskMatBuff) return;
|
||||
if (!MaskPut || !pSolidMask || !pSolidMaskMatBuff) return;
|
||||
|
||||
CheckConsistency();
|
||||
|
||||
|
|
|
@ -36,16 +36,16 @@
|
|||
#include <C4Log.h>
|
||||
|
||||
C4Texture::C4Texture()
|
||||
{
|
||||
Name[0]=0;
|
||||
Surface32=NULL;
|
||||
Next=NULL;
|
||||
}
|
||||
{
|
||||
Name[0]=0;
|
||||
Surface32=NULL;
|
||||
Next=NULL;
|
||||
}
|
||||
|
||||
C4Texture::~C4Texture()
|
||||
{
|
||||
delete Surface32;
|
||||
}
|
||||
{
|
||||
delete Surface32;
|
||||
}
|
||||
|
||||
C4TexMapEntry::C4TexMapEntry()
|
||||
: iMaterialIndex(MNone), pMaterial(NULL)
|
||||
|
@ -98,17 +98,17 @@ bool C4TexMapEntry::Init()
|
|||
}
|
||||
|
||||
C4TextureMap::C4TextureMap()
|
||||
{
|
||||
{
|
||||
Default();
|
||||
}
|
||||
}
|
||||
|
||||
C4TextureMap::~C4TextureMap()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
bool C4TextureMap::AddEntry(BYTE byIndex, const char *szMaterial, const char *szTexture)
|
||||
{
|
||||
{
|
||||
// Security
|
||||
if(byIndex <= 0 || byIndex >= C4M_MaxTexIndex)
|
||||
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.HandleTexMapUpdate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool C4TextureMap::AddTexture(const char *szTexture, CSurface * sfcSurface)
|
||||
{
|
||||
C4Texture *pTexture;
|
||||
if (!(pTexture=new C4Texture)) return false;
|
||||
SCopy(szTexture,pTexture->Name,C4M_MaxName);
|
||||
pTexture->Surface32=sfcSurface;
|
||||
pTexture->Next=FirstTexture;
|
||||
FirstTexture=pTexture;
|
||||
return true;
|
||||
}
|
||||
{
|
||||
C4Texture *pTexture;
|
||||
if (!(pTexture=new C4Texture)) return false;
|
||||
SCopy(szTexture,pTexture->Name,C4M_MaxName);
|
||||
pTexture->Surface32=sfcSurface;
|
||||
pTexture->Next=FirstTexture;
|
||||
FirstTexture=pTexture;
|
||||
return true;
|
||||
}
|
||||
|
||||
void C4TextureMap::Clear()
|
||||
{
|
||||
{
|
||||
for(int32_t i = 1; i < C4M_MaxTexIndex; i++)
|
||||
Entry[i].Clear();
|
||||
C4Texture *ctex,*next2;
|
||||
for (ctex=FirstTexture; ctex; ctex=next2)
|
||||
{
|
||||
C4Texture *ctex,*next2;
|
||||
for (ctex=FirstTexture; ctex; ctex=next2)
|
||||
{
|
||||
next2=ctex->Next;
|
||||
delete ctex;
|
||||
}
|
||||
FirstTexture=NULL;
|
||||
FirstTexture=NULL;
|
||||
fInitialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool C4TextureMap::LoadFlags(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures)
|
||||
{
|
||||
{
|
||||
// Load the file
|
||||
StdStrBuf TexMap;
|
||||
if(!hGroup.LoadEntryString(szEntryName, TexMap))
|
||||
|
@ -175,20 +175,20 @@ bool C4TextureMap::LoadFlags(C4Group &hGroup, const char *szEntryName, bool *pOv
|
|||
}
|
||||
// Done
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t C4TextureMap::LoadMap(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures)
|
||||
{
|
||||
char *bpMap;
|
||||
char szLine[100+1];
|
||||
int32_t cnt, iIndex, iTextures = 0;
|
||||
// Load text file into memory
|
||||
if (!hGroup.LoadEntry(szEntryName,&bpMap,NULL,1)) return 0;
|
||||
// Scan text buffer lines
|
||||
for (cnt=0; SCopySegment(bpMap,cnt,szLine,0x0A,100); cnt++)
|
||||
if ( (szLine[0]!='#') && (SCharCount('=',szLine)==1) )
|
||||
{
|
||||
SReplaceChar(szLine,0x0D,0x00);
|
||||
{
|
||||
char *bpMap;
|
||||
char szLine[100+1];
|
||||
int32_t cnt, iIndex, iTextures = 0;
|
||||
// Load text file into memory
|
||||
if (!hGroup.LoadEntry(szEntryName,&bpMap,NULL,1)) return 0;
|
||||
// Scan text buffer lines
|
||||
for (cnt=0; SCopySegment(bpMap,cnt,szLine,0x0A,100); cnt++)
|
||||
if ( (szLine[0]!='#') && (SCharCount('=',szLine)==1) )
|
||||
{
|
||||
SReplaceChar(szLine,0x0D,0x00);
|
||||
if (Inside<int32_t>( iIndex = strtol(szLine,NULL,10), 0, C4M_MaxTexIndex-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()))
|
||||
iTextures++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SEqual2(szLine, "OverloadMaterials")) { fOverloadMaterials = true; if(pOverloadMaterials) *pOverloadMaterials = true; }
|
||||
if (SEqual2(szLine, "OverloadTextures")) { fOverloadTextures = true; if(pOverloadTextures) *pOverloadTextures = true; }
|
||||
}
|
||||
// Delete buffer, return entry count
|
||||
delete [] bpMap;
|
||||
// Delete buffer, return entry count
|
||||
delete [] bpMap;
|
||||
fEntriesAdded=false;
|
||||
return iTextures;
|
||||
}
|
||||
return iTextures;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
BYTE byIndex;
|
||||
// Find existing
|
||||
{
|
||||
BYTE byIndex;
|
||||
// Find existing
|
||||
for (byIndex = 1; byIndex < C4M_MaxTexIndex; byIndex++)
|
||||
if (!Entry[byIndex].isNull())
|
||||
if (SEqualNoCase(Entry[byIndex].GetMaterialName(), szMaterial))
|
||||
if (!szTexture || SEqualNoCase(Entry[byIndex].GetTextureName(), szTexture))
|
||||
return byIndex;
|
||||
// Add new entry
|
||||
if (fAddIfNotExist)
|
||||
for (byIndex=1; byIndex<C4M_MaxTexIndex; byIndex++)
|
||||
if (Entry[byIndex].isNull())
|
||||
{
|
||||
if (AddEntry(byIndex, szMaterial, szTexture))
|
||||
// Add new entry
|
||||
if (fAddIfNotExist)
|
||||
for (byIndex=1; byIndex<C4M_MaxTexIndex; byIndex++)
|
||||
if (Entry[byIndex].isNull())
|
||||
{
|
||||
if (AddEntry(byIndex, szMaterial, szTexture))
|
||||
{
|
||||
fEntriesAdded=true;
|
||||
return byIndex;
|
||||
}
|
||||
if (szErrorIfFailed) DebugLogF("Error getting MatTex %s-%s for %s from TextureMap: Init failed.", szMaterial, szTexture, szErrorIfFailed);
|
||||
return 0;
|
||||
}
|
||||
// Else, fail
|
||||
return 0;
|
||||
}
|
||||
// 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.");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 *pTexture;
|
||||
for (pTexture=FirstTexture; pTexture; pTexture=pTexture->Next)
|
||||
if (SEqualNoCase(pTexture->Name,szTexture))
|
||||
return pTexture;
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
C4Texture *pTexture;
|
||||
for (pTexture=FirstTexture; pTexture; pTexture=pTexture->Next)
|
||||
if (SEqualNoCase(pTexture->Name,szTexture))
|
||||
return pTexture;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool C4TextureMap::CheckTexture(const char *szTexture)
|
||||
{
|
||||
C4Texture *pTexture;
|
||||
for (pTexture=FirstTexture; pTexture; pTexture=pTexture->Next)
|
||||
if (SEqualNoCase(pTexture->Name,szTexture))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
{
|
||||
C4Texture *pTexture;
|
||||
for (pTexture=FirstTexture; pTexture; pTexture=pTexture->Next)
|
||||
if (SEqualNoCase(pTexture->Name,szTexture))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* C4TextureMap::GetTexture(int32_t iIndex)
|
||||
{
|
||||
C4Texture *pTexture;
|
||||
C4Texture *pTexture;
|
||||
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)
|
||||
return pTexture->Name;
|
||||
return NULL;
|
||||
|
@ -379,7 +379,7 @@ const char* C4TextureMap::GetTexture(int32_t iIndex)
|
|||
|
||||
void C4TextureMap::Default()
|
||||
{
|
||||
FirstTexture=NULL;
|
||||
FirstTexture=NULL;
|
||||
fEntriesAdded=false;
|
||||
fOverloadMaterials=false;
|
||||
fOverloadTextures=false;
|
||||
|
@ -396,7 +396,7 @@ void C4TextureMap::StoreMapPalette(BYTE *bypPalette, C4MaterialMap &rMaterial)
|
|||
bypPalette[2]=252;
|
||||
// Material colors by texture map entries
|
||||
bool fSet[256];
|
||||
ZeroMem(&fSet, sizeof (fSet));
|
||||
ZeroMem(&fSet, sizeof (fSet));
|
||||
int32_t 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
|
||||
fSet[i] = fSet[i + IFT] = true;
|
||||
}
|
||||
// Crosscheck colors, change equal palette entries
|
||||
for(i = 0; i < 256; i++) if(fSet[i])
|
||||
for(;;)
|
||||
{
|
||||
// search equal entry
|
||||
// Crosscheck colors, change equal palette entries
|
||||
for(i = 0; i < 256; i++) if(fSet[i])
|
||||
for(;;)
|
||||
{
|
||||
// search equal entry
|
||||
int32_t j = 0;
|
||||
for(; j < i; j++) if(fSet[j])
|
||||
if(bypPalette[3*i+0] == bypPalette[3*j+0] &&
|
||||
bypPalette[3*i+1] == bypPalette[3*j+1] &&
|
||||
bypPalette[3*i+2] == bypPalette[3*j+2])
|
||||
break;
|
||||
// not found? ok then
|
||||
if(j >= i) break;
|
||||
// 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+1] += 3; else bypPalette[3*i+1] -= 3;
|
||||
if(rand() < RAND_MAX / 2) bypPalette[3*i+2] += 3; else bypPalette[3*i+2] -= 3;
|
||||
}
|
||||
for(; j < i; j++) if(fSet[j])
|
||||
if(bypPalette[3*i+0] == bypPalette[3*j+0] &&
|
||||
bypPalette[3*i+1] == bypPalette[3*j+1] &&
|
||||
bypPalette[3*i+2] == bypPalette[3*j+2])
|
||||
break;
|
||||
// not found? ok then
|
||||
if(j >= i) break;
|
||||
// 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+1] += 3; else bypPalette[3*i+1] -= 3;
|
||||
if(rand() < RAND_MAX / 2) bypPalette[3*i+2] += 3; else bypPalette[3*i+2] -= 3;
|
||||
}
|
||||
}
|
||||
|
||||
C4TextureMap TextureMap;
|
||||
|
|
|
@ -28,24 +28,24 @@
|
|||
#include <C4Material.h>
|
||||
|
||||
class C4Texture
|
||||
{
|
||||
friend class C4TextureMap;
|
||||
public:
|
||||
C4Texture();
|
||||
~C4Texture();
|
||||
CSurface * Surface32;
|
||||
protected:
|
||||
char Name[C4M_MaxName+1];
|
||||
C4Texture *Next;
|
||||
};
|
||||
{
|
||||
friend class C4TextureMap;
|
||||
public:
|
||||
C4Texture();
|
||||
~C4Texture();
|
||||
CSurface * Surface32;
|
||||
protected:
|
||||
char Name[C4M_MaxName+1];
|
||||
C4Texture *Next;
|
||||
};
|
||||
|
||||
class C4TexMapEntry
|
||||
{
|
||||
friend class C4TextureMap;
|
||||
{
|
||||
friend class C4TextureMap;
|
||||
public:
|
||||
C4TexMapEntry();
|
||||
private:
|
||||
StdCopyStrBuf Material, Texture;
|
||||
private:
|
||||
StdCopyStrBuf Material, Texture;
|
||||
int32_t iMaterialIndex;
|
||||
C4Material *pMaterial;
|
||||
CPattern MatPattern;
|
||||
|
@ -59,43 +59,43 @@ class C4TexMapEntry
|
|||
void Clear();
|
||||
bool Create(const char *szMaterial, const char *szTexture);
|
||||
bool Init();
|
||||
};
|
||||
};
|
||||
|
||||
class C4TextureMap
|
||||
{
|
||||
public:
|
||||
C4TextureMap();
|
||||
~C4TextureMap();
|
||||
protected:
|
||||
C4TexMapEntry Entry[C4M_MaxTexIndex];
|
||||
C4Texture *FirstTexture;
|
||||
{
|
||||
public:
|
||||
C4TextureMap();
|
||||
~C4TextureMap();
|
||||
protected:
|
||||
C4TexMapEntry Entry[C4M_MaxTexIndex];
|
||||
C4Texture *FirstTexture;
|
||||
bool fOverloadMaterials;
|
||||
bool fOverloadTextures;
|
||||
bool fInitialized; // Set after Init() - newly added entries initialized automatically
|
||||
public:
|
||||
bool fEntriesAdded;
|
||||
public:
|
||||
public:
|
||||
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 Clear();
|
||||
void Clear();
|
||||
void StoreMapPalette(BYTE *bypPalette, C4MaterialMap &rMaterials);
|
||||
static bool LoadFlags(C4Group &hGroup, const char *szEntryName, bool *pOverloadMaterials, bool *pOverloadTextures);
|
||||
int32_t LoadMap(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 Init();
|
||||
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);
|
||||
const char *GetTexture(int32_t iIndex);
|
||||
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 GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture = NULL, bool fAddIfNotExist=true, const char *szErrorIfFailed=NULL);
|
||||
C4Texture * GetTexture(const char *szTexture);
|
||||
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);
|
||||
C4Texture * GetTexture(const char *szTexture);
|
||||
bool CheckTexture(const char *szTexture); // return whether texture exists
|
||||
bool AddEntry(BYTE byIndex, const char *szMaterial, const char *szTexture);
|
||||
protected:
|
||||
bool AddTexture(const char *szTexture, CSurface * sfcSurface);
|
||||
};
|
||||
protected:
|
||||
bool AddTexture(const char *szTexture, CSurface * sfcSurface);
|
||||
};
|
||||
|
||||
extern C4TextureMap TextureMap;
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
#include <C4Game.h>
|
||||
|
||||
C4Weather::C4Weather()
|
||||
{
|
||||
{
|
||||
Default();
|
||||
}
|
||||
}
|
||||
|
||||
C4Weather::~C4Weather()
|
||||
{
|
||||
|
@ -40,67 +40,67 @@ C4Weather::~C4Weather()
|
|||
}
|
||||
|
||||
void C4Weather::Init(bool fScenario)
|
||||
{
|
||||
if(fScenario)
|
||||
{
|
||||
// Season
|
||||
Season=Game.C4S.Weather.StartSeason.Evaluate();
|
||||
YearSpeed=Game.C4S.Weather.YearSpeed.Evaluate();
|
||||
// Temperature
|
||||
Climate=100-Game.C4S.Weather.Climate.Evaluate()-50;
|
||||
Temperature=Climate;
|
||||
// Wind
|
||||
Wind=TargetWind=Game.C4S.Weather.Wind.Evaluate();
|
||||
// Precipitation
|
||||
{
|
||||
if(fScenario)
|
||||
{
|
||||
// Season
|
||||
Season=Game.C4S.Weather.StartSeason.Evaluate();
|
||||
YearSpeed=Game.C4S.Weather.YearSpeed.Evaluate();
|
||||
// Temperature
|
||||
Climate=100-Game.C4S.Weather.Climate.Evaluate()-50;
|
||||
Temperature=Climate;
|
||||
// Wind
|
||||
Wind=TargetWind=Game.C4S.Weather.Wind.Evaluate();
|
||||
// Precipitation
|
||||
if (!Game.C4S.Head.NoInitialize)
|
||||
if (Game.C4S.Weather.Rain.Evaluate())
|
||||
for (int32_t iClouds = Min(GBackWdt/500,5); iClouds>0; iClouds--)
|
||||
{
|
||||
volatile int iWidth = GBackWdt/15+Random(320);
|
||||
volatile int iX = Random(GBackWdt);
|
||||
{
|
||||
volatile int iWidth = GBackWdt/15+Random(320);
|
||||
volatile int iX = Random(GBackWdt);
|
||||
LaunchCloud(iX,-1,iWidth,
|
||||
Game.C4S.Weather.Rain.Evaluate(),
|
||||
Game.C4S.Weather.Precipitation);
|
||||
}
|
||||
}
|
||||
// gamma?
|
||||
NoGamma=Game.C4S.Weather.NoGamma;
|
||||
}
|
||||
}
|
||||
// set gamma
|
||||
SetSeasonGamma();
|
||||
}
|
||||
}
|
||||
|
||||
void C4Weather::Execute()
|
||||
{
|
||||
// Season
|
||||
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)
|
||||
{
|
||||
// Season
|
||||
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++;
|
||||
else if (Temperature>iTemperature) Temperature--;
|
||||
}
|
||||
// Wind
|
||||
if (!::Game.iTick1000)
|
||||
TargetWind=Game.C4S.Weather.Wind.Evaluate();
|
||||
if (!::Game.iTick10)
|
||||
Wind=BoundBy<int32_t>(Wind+Sign(TargetWind-Wind),
|
||||
Game.C4S.Weather.Wind.Min,
|
||||
Game.C4S.Weather.Wind.Max);
|
||||
if (!::Game.iTick10)
|
||||
SoundLevel("Wind",NULL,Max(Abs(Wind)-30,0)*2);
|
||||
}
|
||||
// Wind
|
||||
if (!::Game.iTick1000)
|
||||
TargetWind=Game.C4S.Weather.Wind.Evaluate();
|
||||
if (!::Game.iTick10)
|
||||
Wind=BoundBy<int32_t>(Wind+Sign(TargetWind-Wind),
|
||||
Game.C4S.Weather.Wind.Min,
|
||||
Game.C4S.Weather.Wind.Max);
|
||||
if (!::Game.iTick10)
|
||||
SoundLevel("Wind",NULL,Max(Abs(Wind)-30,0)*2);
|
||||
}
|
||||
|
||||
void C4Weather::Clear()
|
||||
{
|
||||
|
@ -120,10 +120,10 @@ int32_t C4Weather::GetTemperature()
|
|||
|
||||
void C4Weather::Default()
|
||||
{
|
||||
Season=0; YearSpeed=0; SeasonDelay=0;
|
||||
Wind=TargetWind=0;
|
||||
Temperature=Climate=0;
|
||||
TemperatureRange=30;
|
||||
Season=0; YearSpeed=0; SeasonDelay=0;
|
||||
Wind=TargetWind=0;
|
||||
Temperature=Climate=0;
|
||||
TemperatureRange=30;
|
||||
NoGamma=true;
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ void C4Weather::SetSeasonGamma()
|
|||
}
|
||||
|
||||
void C4Weather::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(Season, "Season", 0));
|
||||
pComp->Value(mkNamingAdapt(YearSpeed, "YearSpeed", 0));
|
||||
pComp->Value(mkNamingAdapt(SeasonDelay, "SeasonDelay", 0));
|
||||
|
@ -229,6 +229,6 @@ void C4Weather::CompileFunc(StdCompiler *pComp)
|
|||
dwGammaDefaults[i*3+2] = 0xffffff;
|
||||
}
|
||||
pComp->Value(mkNamingAdapt(mkArrayAdaptM(::GraphicsSystem.dwGamma), "Gamma", dwGammaDefaults));
|
||||
}
|
||||
}
|
||||
|
||||
C4Weather Weather;
|
||||
|
|
|
@ -24,23 +24,23 @@
|
|||
|
||||
#include <C4Landscape.h>
|
||||
class C4Weather
|
||||
{
|
||||
public:
|
||||
C4Weather();
|
||||
{
|
||||
public:
|
||||
C4Weather();
|
||||
~C4Weather();
|
||||
public:
|
||||
int32_t Season,YearSpeed,SeasonDelay;
|
||||
int32_t Wind,TargetWind;
|
||||
int32_t Temperature,TemperatureRange,Climate;
|
||||
public:
|
||||
int32_t Season,YearSpeed,SeasonDelay;
|
||||
int32_t Wind,TargetWind;
|
||||
int32_t Temperature,TemperatureRange,Climate;
|
||||
int32_t NoGamma;
|
||||
public:
|
||||
public:
|
||||
void Default();
|
||||
void Clear();
|
||||
void Execute();
|
||||
void Execute();
|
||||
void SetClimate(int32_t iClimate);
|
||||
void SetSeason(int32_t iSeason);
|
||||
void SetTemperature(int32_t iTemperature);
|
||||
void Init(bool fScenario);
|
||||
void Init(bool fScenario);
|
||||
void SetWind(int32_t iWind);
|
||||
int32_t GetWind(int32_t x, int32_t y);
|
||||
int32_t GetTemperature();
|
||||
|
@ -48,13 +48,13 @@ class C4Weather
|
|||
int32_t GetClimate();
|
||||
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 CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
extern C4Weather Weather;
|
||||
|
||||
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
|
||||
|
|
|
@ -23,29 +23,29 @@
|
|||
#include <C4Object.h>
|
||||
|
||||
C4Action::C4Action()
|
||||
{
|
||||
{
|
||||
Default();
|
||||
}
|
||||
}
|
||||
|
||||
C4Action::~C4Action()
|
||||
{
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void C4Action::Default()
|
||||
{
|
||||
//pActionDef = 0;
|
||||
Dir=DIR_None;
|
||||
Dir=DIR_None;
|
||||
DrawDir=Dir;
|
||||
ComDir=COMD_None;
|
||||
Time=0;
|
||||
Data=0;
|
||||
Target=Target2=NULL;
|
||||
Phase=PhaseDelay=0;
|
||||
ComDir=COMD_None;
|
||||
Time=0;
|
||||
Data=0;
|
||||
Target=Target2=NULL;
|
||||
Phase=PhaseDelay=0;
|
||||
Facet.Default();
|
||||
FacetX=FacetY=0;
|
||||
t_attach=CNAT_None;
|
||||
Animation = NULL;
|
||||
FacetX=FacetY=0;
|
||||
t_attach=CNAT_None;
|
||||
Animation = NULL;
|
||||
}
|
||||
|
||||
void C4Action::CompileFunc(StdCompiler *pComp)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -62,13 +62,13 @@ const int32_t C4CMD_First = C4CMD_Follow,
|
|||
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)
|
||||
C4CMD_Mode_Base = 1, // regular base command
|
||||
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_Base = 1, // regular base command
|
||||
C4CMD_Mode_SilentBase = 2, // silent base command (no message in case of failure)
|
||||
C4CMD_Mode_Sub = 3; // subcommand; failure will cause base to fail
|
||||
|
||||
// MoveTo and Enter command options: Include push target
|
||||
const int32_t C4CMD_MoveTo_NoPosAdjust = 1,
|
||||
C4CMD_MoveTo_PushTarget = 2;
|
||||
C4CMD_MoveTo_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);
|
||||
|
||||
class C4Command
|
||||
{
|
||||
public:
|
||||
C4Command();
|
||||
~C4Command();
|
||||
public:
|
||||
{
|
||||
public:
|
||||
C4Command();
|
||||
~C4Command();
|
||||
public:
|
||||
C4Object *cObj;
|
||||
int32_t Command;
|
||||
int32_t Command;
|
||||
C4Value Tx;
|
||||
int32_t Ty;
|
||||
C4Object *Target,*Target2;
|
||||
C4Object *Target,*Target2;
|
||||
C4Value Data;
|
||||
int32_t UpdateInterval;
|
||||
int32_t Evaluated,PathChecked,Finished;
|
||||
int32_t UpdateInterval;
|
||||
int32_t Evaluated,PathChecked,Finished;
|
||||
int32_t Failures,Retries,Permit;
|
||||
C4String *Text;
|
||||
C4Command *Next;
|
||||
C4Command *Next;
|
||||
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
|
||||
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 Clear();
|
||||
void Execute();
|
||||
|
@ -103,8 +103,8 @@ class C4Command
|
|||
void Default();
|
||||
void EnumeratePointers();
|
||||
void DenumeratePointers();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
protected:
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
protected:
|
||||
void Call();
|
||||
void Home();
|
||||
void Retry();
|
||||
|
@ -117,33 +117,33 @@ class C4Command
|
|||
void Transfer();
|
||||
void Construct();
|
||||
void Finish(bool fSuccess=false, const char *szFailMessage=0);
|
||||
void Follow();
|
||||
void MoveTo();
|
||||
void Enter();
|
||||
void Exit();
|
||||
void Grab();
|
||||
void UnGrab();
|
||||
void Throw();
|
||||
void Chop();
|
||||
void Build();
|
||||
void Jump();
|
||||
void Wait();
|
||||
void Follow();
|
||||
void MoveTo();
|
||||
void Enter();
|
||||
void Exit();
|
||||
void Grab();
|
||||
void UnGrab();
|
||||
void Throw();
|
||||
void Chop();
|
||||
void Build();
|
||||
void Jump();
|
||||
void Wait();
|
||||
void Take();
|
||||
void Take2();
|
||||
bool GetTryEnter(); // at object pos during get-command: Try entering it
|
||||
void Get();
|
||||
void Put();
|
||||
void Drop();
|
||||
void Dig();
|
||||
void Activate();
|
||||
void PushTo();
|
||||
void Context();
|
||||
void Get();
|
||||
void Put();
|
||||
void Drop();
|
||||
void Dig();
|
||||
void Activate();
|
||||
void PushTo();
|
||||
void Context();
|
||||
int32_t CallFailed();
|
||||
bool JumpControl();
|
||||
bool FlightControl();
|
||||
bool InitEvaluation();
|
||||
int32_t GetExpGain(); // get control counts gained by this command; 1EXP=5 ControlCounts
|
||||
bool CheckMinimumCon (C4Object *pObj);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -68,19 +68,19 @@ const char *ProcedureName[C4D_MaxDFA]={ "WALK",
|
|||
//--------------------------------- C4DefCore ----------------------------------------------
|
||||
|
||||
void C4Def::DefaultDefCore()
|
||||
{
|
||||
{
|
||||
rC4XVer[0]=rC4XVer[1]=rC4XVer[2]=rC4XVer[3]=0;
|
||||
RequireDef.Clear();
|
||||
Physical.Default();
|
||||
Shape.Default();
|
||||
Entrance.Default();
|
||||
Collection.Default();
|
||||
PictureRect.Default();
|
||||
SolidMask.Default();
|
||||
TopFace.Default();
|
||||
Component.Default();
|
||||
BurnTurnTo=C4ID::None;
|
||||
BuildTurnTo=C4ID::None;
|
||||
Shape.Default();
|
||||
Entrance.Default();
|
||||
Collection.Default();
|
||||
PictureRect.Default();
|
||||
SolidMask.Default();
|
||||
TopFace.Default();
|
||||
Component.Default();
|
||||
BurnTurnTo=C4ID::None;
|
||||
BuildTurnTo=C4ID::None;
|
||||
STimerCall[0]=0;
|
||||
Timer=35;
|
||||
GrowthType=0;
|
||||
|
@ -409,8 +409,8 @@ C4Def::C4Def()
|
|||
void C4Def::Default()
|
||||
{
|
||||
DefaultDefCore();
|
||||
Next=NULL;
|
||||
Temporary=false;
|
||||
Next=NULL;
|
||||
Temporary=false;
|
||||
Maker[0]=0;
|
||||
Filename[0]=0;
|
||||
Creation=0;
|
||||
|
@ -427,7 +427,7 @@ void C4Def::Default()
|
|||
PortraitCount = 0;
|
||||
Portraits = NULL;
|
||||
pFairCrewPhysical = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
C4Def::~C4Def()
|
||||
{
|
||||
|
@ -435,7 +435,7 @@ C4Def::~C4Def()
|
|||
}
|
||||
|
||||
void C4Def::Clear()
|
||||
{
|
||||
{
|
||||
|
||||
Graphics.Clear();
|
||||
|
||||
|
@ -455,10 +455,10 @@ void C4Def::Clear()
|
|||
}
|
||||
|
||||
bool C4Def::Load(C4Group &hGroup,
|
||||
DWORD dwLoadWhat,
|
||||
DWORD dwLoadWhat,
|
||||
const char *szLanguage,
|
||||
C4SoundSystem *pSoundSystem)
|
||||
{
|
||||
{
|
||||
bool fSuccess=true;
|
||||
|
||||
bool AddFileMonitoring = false;
|
||||
|
@ -493,7 +493,7 @@ bool C4Def::Load(C4Group &hGroup,
|
|||
}
|
||||
|
||||
|
||||
// Read DefCore
|
||||
// Read DefCore
|
||||
if (fSuccess) fSuccess=LoadDefCore(hGroup);
|
||||
|
||||
// skip def: don't even read sounds!
|
||||
|
@ -526,8 +526,8 @@ bool C4Def::Load(C4Group &hGroup,
|
|||
return false;
|
||||
}
|
||||
|
||||
// Read script
|
||||
if (dwLoadWhat & C4D_Load_Script)
|
||||
// Read script
|
||||
if (dwLoadWhat & C4D_Load_Script)
|
||||
{
|
||||
// reg script to engine
|
||||
Script.Reg2List(&::ScriptEngine, &::ScriptEngine);
|
||||
|
@ -608,8 +608,8 @@ bool C4Def::Load(C4Group &hGroup,
|
|||
}
|
||||
|
||||
|
||||
// Read desc
|
||||
if (dwLoadWhat & C4D_Load_Desc)
|
||||
// Read desc
|
||||
if (dwLoadWhat & C4D_Load_Desc)
|
||||
{
|
||||
Desc.LoadEx("Desc", hGroup, C4CFN_DefDesc, szLanguage);
|
||||
Desc.TrimSpaces();
|
||||
|
@ -621,7 +621,7 @@ bool C4Def::Load(C4Group &hGroup,
|
|||
if (pSoundSystem)
|
||||
pSoundSystem->LoadEffects(hGroup);
|
||||
|
||||
// Bitmap post-load settings
|
||||
// Bitmap post-load settings
|
||||
if (Graphics.GetBitmap())
|
||||
{
|
||||
// check SolidMask
|
||||
|
@ -751,11 +751,11 @@ C4PhysicalInfo *C4Def::GetFairCrewPhysicals()
|
|||
}
|
||||
|
||||
void C4Def::ClearFairCrewPhysicals()
|
||||
{
|
||||
// invalidate physicals so the next call to GetFairCrewPhysicals will
|
||||
// reacreate them
|
||||
delete pFairCrewPhysical; pFairCrewPhysical = NULL;
|
||||
}
|
||||
{
|
||||
// invalidate physicals so the next call to GetFairCrewPhysicals will
|
||||
// reacreate them
|
||||
delete pFairCrewPhysical; pFairCrewPhysical = NULL;
|
||||
}
|
||||
|
||||
void C4Def::Synchronize()
|
||||
{
|
||||
|
@ -768,24 +768,24 @@ void C4Def::Synchronize()
|
|||
//--------------------------------- C4DefList ----------------------------------------------
|
||||
|
||||
C4DefList::C4DefList()
|
||||
{
|
||||
{
|
||||
Default();
|
||||
}
|
||||
}
|
||||
|
||||
C4DefList::~C4DefList()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
int32_t C4DefList::Load(C4Group &hGroup, DWORD dwLoadWhat,
|
||||
const char *szLanguage,
|
||||
C4SoundSystem *pSoundSystem,
|
||||
bool fOverload,
|
||||
bool fSearchMessage, int32_t iMinProgress, int32_t iMaxProgress, bool fLoadSysGroups)
|
||||
{
|
||||
{
|
||||
int32_t iResult=0;
|
||||
C4Def *nDef;
|
||||
char szEntryname[_MAX_FNAME+1];
|
||||
C4Def *nDef;
|
||||
char szEntryname[_MAX_FNAME+1];
|
||||
C4Group hChild;
|
||||
bool fPrimaryDef=false;
|
||||
bool fThisSearchMessage=false;
|
||||
|
@ -852,8 +852,8 @@ int32_t C4DefList::Load(C4Group &hGroup, DWORD dwLoadWhat,
|
|||
// progress (could go down one level of recursion...)
|
||||
if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress));
|
||||
|
||||
return iResult;
|
||||
}
|
||||
return iResult;
|
||||
}
|
||||
|
||||
int32_t C4DefList::LoadFolderLocal( const char *szPath,
|
||||
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);
|
||||
|
||||
int32_t C4DefList::Load(const char *szSearch,
|
||||
DWORD dwLoadWhat, const char *szLanguage,
|
||||
DWORD dwLoadWhat, const char *szLanguage,
|
||||
C4SoundSystem *pSoundSystem,
|
||||
bool fOverload, int32_t iMinProgress, int32_t iMaxProgress)
|
||||
{
|
||||
int32_t iResult=0;
|
||||
{
|
||||
int32_t iResult=0;
|
||||
|
||||
// Empty
|
||||
if (!szSearch[0]) return iResult;
|
||||
|
@ -956,14 +956,14 @@ int32_t C4DefList::Load(const char *szSearch,
|
|||
// progress (could go down one level of recursion...)
|
||||
if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress));
|
||||
|
||||
return iResult;
|
||||
}
|
||||
return iResult;
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
// Add new def
|
||||
pDef->Next=FirstDef;
|
||||
FirstDef=pDef;
|
||||
pDef->Next=FirstDef;
|
||||
FirstDef=pDef;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool C4DefList::Remove(C4ID id)
|
||||
{
|
||||
C4Def *cdef,*prev;
|
||||
for (cdef=FirstDef,prev=NULL; cdef; prev=cdef,cdef=cdef->Next)
|
||||
if (cdef->id==id)
|
||||
{
|
||||
if (prev) prev->Next=cdef->Next;
|
||||
else FirstDef=cdef->Next;
|
||||
delete cdef;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
{
|
||||
C4Def *cdef,*prev;
|
||||
for (cdef=FirstDef,prev=NULL; cdef; prev=cdef,cdef=cdef->Next)
|
||||
if (cdef->id==id)
|
||||
{
|
||||
if (prev) prev->Next=cdef->Next;
|
||||
else FirstDef=cdef->Next;
|
||||
delete cdef;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void C4DefList::Remove(C4Def *def)
|
||||
{
|
||||
C4Def *cdef,*prev;
|
||||
for (cdef=FirstDef,prev=NULL; cdef; prev=cdef,cdef=cdef->Next)
|
||||
if (cdef==def)
|
||||
{
|
||||
if (prev) prev->Next=cdef->Next;
|
||||
else FirstDef=cdef->Next;
|
||||
delete cdef;
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
C4Def *cdef,*prev;
|
||||
for (cdef=FirstDef,prev=NULL; cdef; prev=cdef,cdef=cdef->Next)
|
||||
if (cdef==def)
|
||||
{
|
||||
if (prev) prev->Next=cdef->Next;
|
||||
else FirstDef=cdef->Next;
|
||||
delete cdef;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void C4DefList::Clear()
|
||||
{
|
||||
|
@ -1050,92 +1050,92 @@ C4Def* C4DefList::ID2Def(C4ID id)
|
|||
}
|
||||
|
||||
int32_t C4DefList::GetIndex(C4ID id)
|
||||
{
|
||||
C4Def *cdef;
|
||||
int32_t cindex;
|
||||
for (cdef=FirstDef,cindex=0; cdef; cdef=cdef->Next,cindex++)
|
||||
if (cdef->id==id) return cindex;
|
||||
return -1;
|
||||
}
|
||||
{
|
||||
C4Def *cdef;
|
||||
int32_t cindex;
|
||||
for (cdef=FirstDef,cindex=0; cdef; cdef=cdef->Next,cindex++)
|
||||
if (cdef->id==id) return cindex;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t C4DefList::GetDefCount(DWORD dwCategory)
|
||||
{
|
||||
C4Def *cdef; int32_t ccount=0;
|
||||
for (cdef=FirstDef; cdef; cdef=cdef->Next)
|
||||
if (cdef->Category & dwCategory)
|
||||
ccount++;
|
||||
return ccount;
|
||||
C4Def *cdef; int32_t ccount=0;
|
||||
for (cdef=FirstDef; cdef; cdef=cdef->Next)
|
||||
if (cdef->Category & dwCategory)
|
||||
ccount++;
|
||||
return ccount;
|
||||
}
|
||||
|
||||
C4Def* C4DefList::GetDef(int32_t iIndex, DWORD dwCategory)
|
||||
{
|
||||
C4Def *pDef; int32_t iCurrentIndex;
|
||||
if (iIndex<0) return NULL;
|
||||
for (pDef=FirstDef,iCurrentIndex=-1; pDef; pDef=pDef->Next)
|
||||
if (pDef->Category & dwCategory)
|
||||
{
|
||||
iCurrentIndex++;
|
||||
if (iCurrentIndex==iIndex) return pDef;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
C4Def *pDef; int32_t iCurrentIndex;
|
||||
if (iIndex<0) return NULL;
|
||||
for (pDef=FirstDef,iCurrentIndex=-1; pDef; pDef=pDef->Next)
|
||||
if (pDef->Category & dwCategory)
|
||||
{
|
||||
iCurrentIndex++;
|
||||
if (iCurrentIndex==iIndex) return pDef;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
C4Def *C4DefList::GetByPath(const char *szPath)
|
||||
{
|
||||
// search defs
|
||||
const char *szDefPath;
|
||||
for(C4Def *pDef = FirstDef; pDef; pDef = pDef->Next)
|
||||
if((szDefPath = Config.AtRelativePath(pDef->Filename)))
|
||||
if(SEqual2NoCase(szPath, szDefPath))
|
||||
{
|
||||
// the definition itself?
|
||||
if(!szPath[SLen(szDefPath)])
|
||||
return pDef;
|
||||
// or a component?
|
||||
else if(szPath[SLen(szDefPath)] == '\\')
|
||||
if(!strchr(szPath + SLen(szDefPath) + 1, '\\'))
|
||||
return pDef;
|
||||
}
|
||||
// not found
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
// search defs
|
||||
const char *szDefPath;
|
||||
for(C4Def *pDef = FirstDef; pDef; pDef = pDef->Next)
|
||||
if((szDefPath = Config.AtRelativePath(pDef->Filename)))
|
||||
if(SEqual2NoCase(szPath, szDefPath))
|
||||
{
|
||||
// the definition itself?
|
||||
if(!szPath[SLen(szDefPath)])
|
||||
return pDef;
|
||||
// or a component?
|
||||
else if(szPath[SLen(szDefPath)] == '\\')
|
||||
if(!strchr(szPath + SLen(szDefPath) + 1, '\\'))
|
||||
return pDef;
|
||||
}
|
||||
// not found
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t C4DefList::RemoveTemporary()
|
||||
{
|
||||
C4Def *cdef,*prev,*next;
|
||||
int32_t removed=0;
|
||||
for (cdef=FirstDef,prev=NULL; cdef; cdef=next)
|
||||
{
|
||||
next=cdef->Next;
|
||||
if (cdef->Temporary)
|
||||
{
|
||||
if (prev) prev->Next=next;
|
||||
else FirstDef=next;
|
||||
delete cdef;
|
||||
removed++;
|
||||
}
|
||||
else
|
||||
prev=cdef;
|
||||
}
|
||||
{
|
||||
C4Def *cdef,*prev,*next;
|
||||
int32_t removed=0;
|
||||
for (cdef=FirstDef,prev=NULL; cdef; cdef=next)
|
||||
{
|
||||
next=cdef->Next;
|
||||
if (cdef->Temporary)
|
||||
{
|
||||
if (prev) prev->Next=next;
|
||||
else FirstDef=next;
|
||||
delete cdef;
|
||||
removed++;
|
||||
}
|
||||
else
|
||||
prev=cdef;
|
||||
}
|
||||
// rebuild quick access table
|
||||
BuildTable();
|
||||
return removed;
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
int32_t C4DefList::CheckEngineVersion(int32_t ver1, int32_t ver2, int32_t ver3, int32_t ver4)
|
||||
{
|
||||
int32_t rcount=0;
|
||||
C4Def *cdef,*prev,*next;
|
||||
for (cdef=FirstDef,prev=NULL; cdef; cdef=next)
|
||||
C4Def *cdef,*prev,*next;
|
||||
for (cdef=FirstDef,prev=NULL; cdef; 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 (prev) prev->Next=cdef->Next;
|
||||
else FirstDef=cdef->Next;
|
||||
delete cdef;
|
||||
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;
|
||||
else FirstDef=cdef->Next;
|
||||
delete cdef;
|
||||
rcount++;
|
||||
}
|
||||
}
|
||||
else prev=cdef;
|
||||
}
|
||||
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 rcount=0, rcount2;
|
||||
C4Def *cdef,*prev,*next;
|
||||
C4Def *cdef,*prev,*next;
|
||||
do
|
||||
{
|
||||
rcount2 = rcount;
|
||||
|
|
|
@ -139,47 +139,47 @@ const DWORD C4D_Load_None = 0,
|
|||
#define C4D_Blit_ModAdd 2
|
||||
|
||||
class C4Def: public C4PropList
|
||||
{
|
||||
public:
|
||||
C4ID id;
|
||||
{
|
||||
public:
|
||||
C4ID id;
|
||||
int32_t rC4XVer[4];
|
||||
C4IDList RequireDef;
|
||||
C4PhysicalInfo Physical;
|
||||
C4Shape Shape;
|
||||
C4Rect Entrance;
|
||||
C4Rect Collection;
|
||||
C4Rect PictureRect;
|
||||
C4TargetRect SolidMask;
|
||||
C4TargetRect TopFace;
|
||||
C4IDList Component;
|
||||
C4ID BurnTurnTo;
|
||||
C4ID BuildTurnTo;
|
||||
int32_t GrowthType;
|
||||
int32_t CrewMember;
|
||||
C4Shape Shape;
|
||||
C4Rect Entrance;
|
||||
C4Rect Collection;
|
||||
C4Rect PictureRect;
|
||||
C4TargetRect SolidMask;
|
||||
C4TargetRect TopFace;
|
||||
C4IDList Component;
|
||||
C4ID BurnTurnTo;
|
||||
C4ID BuildTurnTo;
|
||||
int32_t GrowthType;
|
||||
int32_t CrewMember;
|
||||
int32_t NativeCrew;
|
||||
int32_t Mass;
|
||||
int32_t Value;
|
||||
int32_t Exclusive;
|
||||
int32_t Category;
|
||||
int32_t Growth;
|
||||
int32_t Rebuyable;
|
||||
int32_t ContactIncinerate; // 0 off 1 high - 5 low
|
||||
int32_t BlastIncinerate; // 0 off 1 - x if > damage
|
||||
int32_t Constructable;
|
||||
int32_t Grab; // 0 not 1 push 2 grab only
|
||||
int32_t Carryable;
|
||||
int32_t Rotateable;
|
||||
int32_t Chopable;
|
||||
int32_t Float;
|
||||
int32_t ColorByOwner;
|
||||
int32_t NoHorizontalMove;
|
||||
int32_t BorderBound;
|
||||
int32_t LiftTop;
|
||||
int32_t GrabPutGet;
|
||||
int32_t ContainBlast;
|
||||
int32_t UprightAttach;
|
||||
int32_t ContactFunctionCalls;
|
||||
int32_t MaxUserSelect;
|
||||
int32_t Mass;
|
||||
int32_t Value;
|
||||
int32_t Exclusive;
|
||||
int32_t Category;
|
||||
int32_t Growth;
|
||||
int32_t Rebuyable;
|
||||
int32_t ContactIncinerate; // 0 off 1 high - 5 low
|
||||
int32_t BlastIncinerate; // 0 off 1 - x if > damage
|
||||
int32_t Constructable;
|
||||
int32_t Grab; // 0 not 1 push 2 grab only
|
||||
int32_t Carryable;
|
||||
int32_t Rotateable;
|
||||
int32_t Chopable;
|
||||
int32_t Float;
|
||||
int32_t ColorByOwner;
|
||||
int32_t NoHorizontalMove;
|
||||
int32_t BorderBound;
|
||||
int32_t LiftTop;
|
||||
int32_t GrabPutGet;
|
||||
int32_t ContainBlast;
|
||||
int32_t UprightAttach;
|
||||
int32_t ContactFunctionCalls;
|
||||
int32_t MaxUserSelect;
|
||||
int32_t Line;
|
||||
int32_t LineConnect;
|
||||
int32_t LineIntersect;
|
||||
|
@ -201,7 +201,7 @@ class C4Def: public C4PropList
|
|||
int32_t Timer;
|
||||
int32_t NoComponentMass;
|
||||
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 SilentCommands; // if set, no command failure messages are printed
|
||||
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
|
||||
public:
|
||||
void DefaultDefCore();
|
||||
bool LoadDefCore(C4Group &hGroup);
|
||||
bool LoadDefCore(C4Group &hGroup);
|
||||
bool Save(C4Group &hGroup);
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
protected:
|
||||
|
@ -230,11 +230,11 @@ class C4Def: public C4PropList
|
|||
|
||||
|
||||
// Here begins the C4Def
|
||||
friend class C4DefList;
|
||||
public:
|
||||
C4Def();
|
||||
~C4Def();
|
||||
public:
|
||||
friend class C4DefList;
|
||||
public:
|
||||
C4Def();
|
||||
~C4Def();
|
||||
public:
|
||||
char Maker[C4MaxName+1];
|
||||
char Filename[_MAX_FNAME+1];
|
||||
int32_t Creation;
|
||||
|
@ -264,25 +264,25 @@ class C4Def: public C4PropList
|
|||
|
||||
C4Facet MainFace;
|
||||
|
||||
protected:
|
||||
C4Def *Next;
|
||||
bool Temporary;
|
||||
protected:
|
||||
C4Def *Next;
|
||||
bool Temporary;
|
||||
public:
|
||||
void Clear();
|
||||
void Default();
|
||||
bool Load(C4Group &hGroup,
|
||||
DWORD dwLoadWhat, const char *szLanguage,
|
||||
bool Load(C4Group &hGroup,
|
||||
DWORD dwLoadWhat, const char *szLanguage,
|
||||
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);
|
||||
|
||||
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
|
||||
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();
|
||||
const char *GetDesc() { return Desc.GetData(); }
|
||||
virtual C4Def* GetDef() { return this; }
|
||||
protected:
|
||||
protected:
|
||||
bool LoadPortraits(C4Group &hGroup);
|
||||
bool LoadActMap(C4Group &hGroup);
|
||||
void CrossMapActMap();
|
||||
|
@ -299,34 +299,34 @@ class C4Def: public C4PropList
|
|||
|
||||
C4PropList *GetActionByName(const char *actname);
|
||||
C4PropList *GetActionByName(C4String *actname);
|
||||
};
|
||||
};
|
||||
|
||||
class C4DefList
|
||||
: public CStdFont::CustomImages
|
||||
{
|
||||
public:
|
||||
C4DefList();
|
||||
virtual ~C4DefList();
|
||||
{
|
||||
public:
|
||||
C4DefList();
|
||||
virtual ~C4DefList();
|
||||
public:
|
||||
bool LoadFailure;
|
||||
typedef std::map<C4ID, C4Def*> Table;
|
||||
Table table;
|
||||
protected:
|
||||
C4Def *FirstDef;
|
||||
public:
|
||||
protected:
|
||||
C4Def *FirstDef;
|
||||
public:
|
||||
void Default();
|
||||
void Clear();
|
||||
int32_t Load(C4Group &hGroup,
|
||||
DWORD dwLoadWhat, const char *szLanguage,
|
||||
void Clear();
|
||||
int32_t Load(C4Group &hGroup,
|
||||
DWORD dwLoadWhat, const char *szLanguage,
|
||||
C4SoundSystem *pSoundSystem = NULL,
|
||||
bool fOverload = false,
|
||||
bool fSearchMessage = false, int32_t iMinProgress=0, int32_t iMaxProgress=0, bool fLoadSysGroups = true);
|
||||
int32_t Load(const char *szSearch,
|
||||
DWORD dwLoadWhat, const char *szLanguage,
|
||||
int32_t Load(const char *szSearch,
|
||||
DWORD dwLoadWhat, const char *szLanguage,
|
||||
C4SoundSystem *pSoundSystem = NULL,
|
||||
bool fOverload = false, int32_t iMinProgress=0, int32_t iMaxProgress=0);
|
||||
int32_t LoadFolderLocal(const char *szPath,
|
||||
DWORD dwLoadWhat, const char *szLanguage,
|
||||
int32_t LoadFolderLocal(const char *szPath,
|
||||
DWORD dwLoadWhat, const char *szLanguage,
|
||||
C4SoundSystem *pSoundSystem = NULL,
|
||||
bool fOverload = false, char *szStoreName=NULL, int32_t iMinProgress=0, int32_t iMaxProgress=0);
|
||||
int32_t LoadForScenario(const char *szScenario,
|
||||
|
@ -334,19 +334,19 @@ class C4DefList
|
|||
DWORD dwLoadWhat, const char *szLanguage,
|
||||
C4SoundSystem *pSoundSystem = NULL,
|
||||
bool fOverload = false, int32_t iMinProgress=0, int32_t iMaxProgress=0);
|
||||
C4Def *ID2Def(C4ID id);
|
||||
C4Def *GetDef(int32_t Index, DWORD dwCategory = C4D_All);
|
||||
C4Def *GetByPath(const char *szPath);
|
||||
C4Def *ID2Def(C4ID id);
|
||||
C4Def *GetDef(int32_t Index, DWORD dwCategory = C4D_All);
|
||||
C4Def *GetByPath(const char *szPath);
|
||||
int32_t GetDefCount(DWORD dwCategory = C4D_All);
|
||||
int32_t GetIndex(C4ID id);
|
||||
int32_t RemoveTemporary();
|
||||
int32_t GetIndex(C4ID id);
|
||||
int32_t RemoveTemporary();
|
||||
int32_t CheckEngineVersion(int32_t ver1, int32_t ver2, int32_t ver3, int32_t ver4);
|
||||
int32_t CheckRequireDef();
|
||||
void Draw(C4ID id, C4Facet &cgo, bool fSelected, int32_t iColor);
|
||||
void Remove(C4Def *def);
|
||||
bool Remove(C4ID id);
|
||||
void Remove(C4Def *def);
|
||||
bool Remove(C4ID id);
|
||||
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 ResetIncludeDependencies(); // resets all pointers into foreign definitions caused by include chains
|
||||
void CallEveryDefinition();
|
||||
|
@ -354,7 +354,7 @@ class C4DefList
|
|||
|
||||
// callback from font renderer: get ID image
|
||||
virtual bool GetFontImage(const char *szImageTag, CFacet &rOutImgFacet);
|
||||
};
|
||||
};
|
||||
|
||||
extern C4DefList Definitions;
|
||||
|
||||
|
|
|
@ -453,8 +453,8 @@ C4ObjectList &C4GameObjects::ObjectsInt()
|
|||
|
||||
void C4GameObjects::RemoveSolidMasks()
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
if (cLnk->Obj->pSolidMaskData)
|
||||
cLnk->Obj->pSolidMaskData->Remove(false, false);
|
||||
|
@ -462,8 +462,8 @@ void C4GameObjects::RemoveSolidMasks()
|
|||
|
||||
void C4GameObjects::PutSolidMasks()
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
cLnk->Obj->UpdateSolidMask(false);
|
||||
}
|
||||
|
@ -478,13 +478,13 @@ void C4GameObjects::DeleteObjects(bool fDeleteInactive)
|
|||
}
|
||||
|
||||
void C4GameObjects::Clear(bool fClearInactive)
|
||||
{
|
||||
DeleteObjects(fClearInactive);
|
||||
if(fClearInactive)
|
||||
InactiveObjects.Clear();
|
||||
ResortProc = NULL;
|
||||
{
|
||||
DeleteObjects(fClearInactive);
|
||||
if(fClearInactive)
|
||||
InactiveObjects.Clear();
|
||||
ResortProc = NULL;
|
||||
LastUsedMarker = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* C4ObjResort */
|
||||
|
||||
|
@ -696,26 +696,26 @@ int C4GameObjects::Load(C4Group &hGroup, bool fKeepInactive)
|
|||
Clear(!fKeepInactive);
|
||||
|
||||
// Load data component
|
||||
StdStrBuf Source;
|
||||
StdStrBuf Source;
|
||||
if (!hGroup.LoadEntryString(C4CFN_ScenarioObjects, Source))
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
// Compile
|
||||
// Compile
|
||||
StdStrBuf Name = hGroup.GetFullName() + DirSep C4CFN_ScenarioObjects;
|
||||
if(!CompileFromBuf_LogWarn<StdCompilerINIRead>(
|
||||
mkParAdapt(*this, false),
|
||||
Source,
|
||||
Name.getData()))
|
||||
return 0;
|
||||
if(!CompileFromBuf_LogWarn<StdCompilerINIRead>(
|
||||
mkParAdapt(*this, false),
|
||||
Source,
|
||||
Name.getData()))
|
||||
return 0;
|
||||
|
||||
// Process objects
|
||||
C4ObjectLink *cLnk;
|
||||
C4Object *pObj;
|
||||
bool fObjectNumberCollision = false;
|
||||
int32_t iMaxObjectNumber = 0;
|
||||
for(cLnk = Last; cLnk; cLnk = cLnk->Prev)
|
||||
{
|
||||
C4Object *pObj = cLnk->Obj;
|
||||
C4ObjectLink *cLnk;
|
||||
C4Object *pObj;
|
||||
bool fObjectNumberCollision = false;
|
||||
int32_t iMaxObjectNumber = 0;
|
||||
for(cLnk = Last; cLnk; cLnk = cLnk->Prev)
|
||||
{
|
||||
C4Object *pObj = cLnk->Obj;
|
||||
// check object number collision with inactive list
|
||||
if (fKeepInactive)
|
||||
{
|
||||
|
@ -733,7 +733,7 @@ int C4GameObjects::Load(C4Group &hGroup, bool fKeepInactive)
|
|||
// Unterminate end
|
||||
}
|
||||
|
||||
// Denumerate pointers
|
||||
// Denumerate pointers
|
||||
// if object numbers collideded, numbers will be adjusted afterwards
|
||||
// so fake inactive object list empty meanwhile
|
||||
C4ObjectLink *pInFirst = NULL;
|
||||
|
@ -794,7 +794,7 @@ int C4GameObjects::Load(C4Group &hGroup, bool fKeepInactive)
|
|||
}
|
||||
}
|
||||
// sort out inactive objects
|
||||
C4ObjectLink *cLnkNext;
|
||||
C4ObjectLink *cLnkNext;
|
||||
for (cLnk=First; cLnk; cLnk=cLnkNext)
|
||||
{
|
||||
cLnkNext = cLnk->Next;
|
||||
|
@ -827,7 +827,7 @@ int C4GameObjects::Load(C4Group &hGroup, bool fKeepInactive)
|
|||
//Sectors.Dump();
|
||||
|
||||
// misc updates
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if ((pObj=cLnk->Obj)->Status)
|
||||
{
|
||||
// add to plrview
|
||||
|
@ -861,28 +861,28 @@ bool C4GameObjects::Save(const char *szFilename, bool fSaveGame, bool fSaveInact
|
|||
InactiveObjects.Enumerate();
|
||||
|
||||
// Decompile objects to buffer
|
||||
StdStrBuf Buffer;
|
||||
bool fSuccess = DecompileToBuf_Log<StdCompilerINIWrite>(mkParAdapt(*this, !fSaveGame), &Buffer, szFilename);
|
||||
StdStrBuf Buffer;
|
||||
bool fSuccess = DecompileToBuf_Log<StdCompilerINIWrite>(mkParAdapt(*this, !fSaveGame), &Buffer, szFilename);
|
||||
|
||||
// Decompile inactives
|
||||
if(fSaveInactive)
|
||||
{
|
||||
StdStrBuf InactiveBuffer;
|
||||
fSuccess &= DecompileToBuf_Log<StdCompilerINIWrite>(mkParAdapt(InactiveObjects, false, !fSaveGame), &InactiveBuffer, szFilename);
|
||||
Buffer.Append("\r\n");
|
||||
Buffer.Append(InactiveBuffer);
|
||||
}
|
||||
// Decompile inactives
|
||||
if(fSaveInactive)
|
||||
{
|
||||
StdStrBuf InactiveBuffer;
|
||||
fSuccess &= DecompileToBuf_Log<StdCompilerINIWrite>(mkParAdapt(InactiveObjects, false, !fSaveGame), &InactiveBuffer, szFilename);
|
||||
Buffer.Append("\r\n");
|
||||
Buffer.Append(InactiveBuffer);
|
||||
}
|
||||
|
||||
// Denumerate
|
||||
// Denumerate
|
||||
InactiveObjects.Denumerate();
|
||||
Denumerate();
|
||||
|
||||
// Error?
|
||||
if(!fSuccess)
|
||||
return false;
|
||||
// Error?
|
||||
if(!fSuccess)
|
||||
return false;
|
||||
|
||||
// Write
|
||||
return Buffer.SaveToFile(szFilename);
|
||||
// Write
|
||||
return Buffer.SaveToFile(szFilename);
|
||||
}
|
||||
|
||||
void C4GameObjects::UpdateScriptPointers()
|
||||
|
@ -1017,14 +1017,14 @@ void C4GameObjects::FixObjectOrder()
|
|||
|
||||
void C4GameObjects::ResortUnsorted()
|
||||
{
|
||||
C4ObjectLink *clnk=First; C4Object *cObj;
|
||||
while (clnk && (cObj=clnk->Obj))
|
||||
{
|
||||
clnk=clnk->Next;
|
||||
if (cObj->Unsorted)
|
||||
{
|
||||
C4ObjectLink *clnk=First; C4Object *cObj;
|
||||
while (clnk && (cObj=clnk->Obj))
|
||||
{
|
||||
clnk=clnk->Next;
|
||||
if (cObj->Unsorted)
|
||||
{
|
||||
// readd to main object list
|
||||
Remove(cObj);
|
||||
Remove(cObj);
|
||||
cObj->Unsorted=false;
|
||||
if (!Add(cObj))
|
||||
{
|
||||
|
@ -1032,9 +1032,9 @@ void C4GameObjects::ResortUnsorted()
|
|||
Game.ClearPointers(cObj);
|
||||
delete cObj;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void C4GameObjects::ExecuteResorts()
|
||||
{
|
||||
|
|
|
@ -53,9 +53,9 @@ void C4IDListChunk::Clear()
|
|||
}
|
||||
|
||||
C4IDList::C4IDList() : C4IDListChunk()
|
||||
{
|
||||
Default();
|
||||
}
|
||||
{
|
||||
Default();
|
||||
}
|
||||
|
||||
C4IDList::C4IDList(const C4IDList &rCopy): C4IDListChunk()
|
||||
{
|
||||
|
@ -95,48 +95,48 @@ void C4IDList::Clear()
|
|||
}
|
||||
|
||||
bool C4IDList::IsClear() const
|
||||
{
|
||||
{
|
||||
return !Count;
|
||||
}
|
||||
}
|
||||
|
||||
C4ID C4IDList::GetID(size_t index, int32_t *ipCount) const
|
||||
{
|
||||
{
|
||||
// outside list?
|
||||
if (!Inside<int32_t>(index,0,Count-1)) return C4ID::None;
|
||||
// get chunk to query
|
||||
const C4IDListChunk *pQueryChunk=this;
|
||||
while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; }
|
||||
// query it
|
||||
if (ipCount) *ipCount=pQueryChunk->Count[index];
|
||||
return pQueryChunk->id[index];
|
||||
}
|
||||
if (ipCount) *ipCount=pQueryChunk->Count[index];
|
||||
return pQueryChunk->id[index];
|
||||
}
|
||||
|
||||
int32_t C4IDList::GetCount(size_t index) const
|
||||
{
|
||||
{
|
||||
// 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
|
||||
const C4IDListChunk *pQueryChunk=this;
|
||||
while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; }
|
||||
// query it
|
||||
return pQueryChunk->Count[index];
|
||||
}
|
||||
return pQueryChunk->Count[index];
|
||||
}
|
||||
|
||||
bool C4IDList::SetCount(size_t index, int32_t iCount)
|
||||
{
|
||||
{
|
||||
// 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
|
||||
C4IDListChunk *pQueryChunk=this;
|
||||
while (index>=C4IDListChunkSize) { pQueryChunk=pQueryChunk->pNext; index-=C4IDListChunkSize; }
|
||||
// set it
|
||||
pQueryChunk->Count[index]=iCount;
|
||||
pQueryChunk->Count[index]=iCount;
|
||||
// success
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t C4IDList::GetIDCount(C4ID c_id, int32_t iZeroDefVal) const
|
||||
{
|
||||
{
|
||||
// find id
|
||||
const C4IDListChunk *pQueryChunk=this;
|
||||
size_t cnt=Count,cntl=0;
|
||||
|
@ -154,11 +154,11 @@ int32_t C4IDList::GetIDCount(C4ID c_id, int32_t iZeroDefVal) const
|
|||
}
|
||||
}
|
||||
// none found
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool C4IDList::SetIDCount(C4ID c_id, int32_t iCount, bool fAddNewID)
|
||||
{
|
||||
{
|
||||
// find id
|
||||
C4IDListChunk *pQueryChunk=this;
|
||||
size_t cnt=Count,cntl=0;
|
||||
|
@ -194,13 +194,13 @@ bool C4IDList::SetIDCount(C4ID c_id, int32_t iCount, bool fAddNewID)
|
|||
return true;
|
||||
}
|
||||
// failure
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t C4IDList::GetNumberOfIDs() const
|
||||
{
|
||||
{
|
||||
return Count;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
{
|
||||
// find id in list
|
||||
C4IDListChunk *pQueryChunk=this;
|
||||
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
|
||||
C4ID C4IDList::GetID(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t *ipCount) const
|
||||
{
|
||||
int32_t cindex=-1;
|
||||
C4Def *cDef;
|
||||
if (ipCount) *ipCount=0;
|
||||
{
|
||||
int32_t cindex=-1;
|
||||
C4Def *cDef;
|
||||
if (ipCount) *ipCount=0;
|
||||
// find id
|
||||
const C4IDListChunk *pQueryChunk=this;
|
||||
size_t cnt=Count,cntl=0;
|
||||
while (cnt--)
|
||||
{
|
||||
if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
|
||||
{
|
||||
cindex++;
|
||||
if (cindex==index) { if (ipCount) *ipCount=pQueryChunk->Count[cntl]; return pQueryChunk->id[cntl]; }
|
||||
}
|
||||
{
|
||||
cindex++;
|
||||
if (cindex==index) { if (ipCount) *ipCount=pQueryChunk->Count[cntl]; return pQueryChunk->id[cntl]; }
|
||||
}
|
||||
if (++cntl==C4IDListChunkSize)
|
||||
{
|
||||
pQueryChunk=pQueryChunk->pNext;
|
||||
cntl=0;
|
||||
}
|
||||
}
|
||||
return C4ID::None;
|
||||
}
|
||||
return C4ID::None;
|
||||
}
|
||||
|
||||
int32_t C4IDList::GetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index) const
|
||||
{
|
||||
int32_t cindex=-1;
|
||||
C4Def *cDef;
|
||||
{
|
||||
int32_t cindex=-1;
|
||||
C4Def *cDef;
|
||||
const C4IDListChunk *pQueryChunk=this;
|
||||
size_t cnt=Count,cntl=0;
|
||||
while (cnt--)
|
||||
{
|
||||
if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
|
||||
{
|
||||
cindex++;
|
||||
if (cindex==index) return pQueryChunk->Count[cntl];
|
||||
}
|
||||
{
|
||||
cindex++;
|
||||
if (cindex==index) return pQueryChunk->Count[cntl];
|
||||
}
|
||||
if (++cntl==C4IDListChunkSize)
|
||||
{
|
||||
pQueryChunk=pQueryChunk->pNext;
|
||||
cntl=0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool C4IDList::SetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t iCount)
|
||||
{
|
||||
int32_t cindex=-1;
|
||||
C4Def *cDef;
|
||||
{
|
||||
int32_t cindex=-1;
|
||||
C4Def *cDef;
|
||||
C4IDListChunk *pQueryChunk=this;
|
||||
size_t cnt=Count,cntl=0;
|
||||
while (cnt--)
|
||||
{
|
||||
if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
|
||||
{
|
||||
cindex++;
|
||||
if (cindex==index) { pQueryChunk->Count[cntl]=iCount; return true; }
|
||||
}
|
||||
{
|
||||
cindex++;
|
||||
if (cindex==index) { pQueryChunk->Count[cntl]=iCount; return true; }
|
||||
}
|
||||
if (++cntl==C4IDListChunkSize)
|
||||
{
|
||||
pQueryChunk=pQueryChunk->pNext;
|
||||
|
@ -329,26 +329,26 @@ bool C4IDList::SetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index, int
|
|||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t C4IDList::GetNumberOfIDs(C4DefList &rDefs, int32_t dwCategory) const
|
||||
{
|
||||
int32_t idnum=0;
|
||||
C4Def *cDef;
|
||||
{
|
||||
int32_t idnum=0;
|
||||
C4Def *cDef;
|
||||
const C4IDListChunk *pQueryChunk=this;
|
||||
size_t cnt=Count,cntl=0;
|
||||
while (cnt--)
|
||||
{
|
||||
if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
|
||||
idnum++;
|
||||
idnum++;
|
||||
if (++cntl==C4IDListChunkSize)
|
||||
{
|
||||
pQueryChunk=pQueryChunk->pNext;
|
||||
cntl=0;
|
||||
}
|
||||
}
|
||||
return idnum;
|
||||
}
|
||||
return idnum;
|
||||
}
|
||||
// IDList merge
|
||||
|
||||
bool C4IDList::Add(C4IDList &rList)
|
||||
|
@ -370,13 +370,13 @@ bool C4IDList::Add(C4IDList &rList)
|
|||
// Removes all empty id gaps from the list.
|
||||
|
||||
bool C4IDList::Consolidate()
|
||||
{
|
||||
{
|
||||
// however, there ain't be any of those crappy gaps!
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool C4IDList::ConsolidateValids(C4DefList &rDefs, int32_t dwCategory)
|
||||
{
|
||||
{
|
||||
bool fIDsRemoved=false;
|
||||
C4IDListChunk *pQueryChunk=this;
|
||||
size_t cnt=Count,cntl=0;
|
||||
|
@ -400,7 +400,7 @@ bool C4IDList::ConsolidateValids(C4DefList &rDefs, int32_t dwCategory)
|
|||
}
|
||||
}
|
||||
return fIDsRemoved;
|
||||
}
|
||||
}
|
||||
|
||||
void C4IDList::SortByCategory(C4DefList &rDefs)
|
||||
{
|
||||
|
@ -443,7 +443,7 @@ void C4IDList::SortByValue(C4DefList &rDefs)
|
|||
|
||||
void C4IDList::Load(C4DefList &rDefs, int32_t dwCategory)
|
||||
{
|
||||
// (deprecated, use StdCompiler instead)
|
||||
// (deprecated, use StdCompiler instead)
|
||||
C4Def *cdef; size_t cntl=0,cnt=0;
|
||||
// clear list
|
||||
Clear();
|
||||
|
@ -484,9 +484,9 @@ void C4IDList::Draw(C4Facet &cgo, int32_t iSelection,
|
|||
{
|
||||
cgo2 = cgo.TruncateSection(iAlign);
|
||||
rDefs.Draw(c_id,cgo2,(firstid+cnt==iSelection),0);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -592,64 +592,64 @@ bool C4IDList::operator==(const C4IDList& rhs) const
|
|||
}
|
||||
|
||||
void C4IDList::CompileFunc(StdCompiler *pComp, bool fValues)
|
||||
{
|
||||
// Get compiler characteristics
|
||||
bool fCompiler = pComp->isCompiler();
|
||||
bool fNaming = pComp->hasNaming();
|
||||
// Compiling: Clear existing data first
|
||||
if(fCompiler) Clear();
|
||||
// Start
|
||||
C4IDListChunk *pChunk = this;
|
||||
size_t iNr = 0, iCNr = 0;
|
||||
// Without naming: Compile Count
|
||||
{
|
||||
// Get compiler characteristics
|
||||
bool fCompiler = pComp->isCompiler();
|
||||
bool fNaming = pComp->hasNaming();
|
||||
// Compiling: Clear existing data first
|
||||
if(fCompiler) Clear();
|
||||
// Start
|
||||
C4IDListChunk *pChunk = this;
|
||||
size_t iNr = 0, iCNr = 0;
|
||||
// Without naming: Compile Count
|
||||
int32_t iCount = Count;
|
||||
if(!fNaming) pComp->Value(iCount);
|
||||
if(!fNaming) pComp->Value(iCount);
|
||||
Count = iCount;
|
||||
// Read
|
||||
for(;;)
|
||||
{
|
||||
// Prepare compiling of single mapping
|
||||
if(!fCompiler)
|
||||
{
|
||||
// End of list?
|
||||
if(iNr >= Count) break;
|
||||
// End of chunk?
|
||||
if(iCNr >= C4IDListChunkSize)
|
||||
{
|
||||
pChunk = pChunk->pNext;
|
||||
iCNr = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// End of list?
|
||||
if(!fNaming) if(iNr >= Count) break;
|
||||
// End of chunk?
|
||||
if(iCNr >= C4IDListChunkSize)
|
||||
{
|
||||
pChunk = pChunk->pNext = new C4IDListChunk();
|
||||
iCNr = 0;
|
||||
}
|
||||
}
|
||||
// Seperator (';')
|
||||
if(iNr > 0) if(!pComp->Seperator(StdCompiler::SEP_SEP2)) break;
|
||||
// ID
|
||||
pComp->Value(mkDefaultAdapt(pChunk->id[iCNr], C4ID::None));
|
||||
// ID not valid? Note that C4ID::None is invalid.
|
||||
// Read
|
||||
for(;;)
|
||||
{
|
||||
// Prepare compiling of single mapping
|
||||
if(!fCompiler)
|
||||
{
|
||||
// End of list?
|
||||
if(iNr >= Count) break;
|
||||
// End of chunk?
|
||||
if(iCNr >= C4IDListChunkSize)
|
||||
{
|
||||
pChunk = pChunk->pNext;
|
||||
iCNr = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// End of list?
|
||||
if(!fNaming) if(iNr >= Count) break;
|
||||
// End of chunk?
|
||||
if(iCNr >= C4IDListChunkSize)
|
||||
{
|
||||
pChunk = pChunk->pNext = new C4IDListChunk();
|
||||
iCNr = 0;
|
||||
}
|
||||
}
|
||||
// Seperator (';')
|
||||
if(iNr > 0) if(!pComp->Seperator(StdCompiler::SEP_SEP2)) break;
|
||||
// ID
|
||||
pComp->Value(mkDefaultAdapt(pChunk->id[iCNr], C4ID::None));
|
||||
// ID not valid? Note that C4ID::None is invalid.
|
||||
if(pChunk->id[iCNr] == C4ID::None) break;
|
||||
// Value: Skip this part if requested
|
||||
if(fValues)
|
||||
{
|
||||
// Seperator ('=')
|
||||
if(pComp->Seperator(StdCompiler::SEP_SET))
|
||||
// Value: Skip this part if requested
|
||||
if(fValues)
|
||||
{
|
||||
// Seperator ('=')
|
||||
if(pComp->Seperator(StdCompiler::SEP_SET))
|
||||
// Count
|
||||
pComp->Value(mkDefaultAdapt(pChunk->Count[iCNr], 0));
|
||||
}
|
||||
else if(fCompiler)
|
||||
pChunk->Count[iCNr] = 0;
|
||||
// Goto next entry
|
||||
iNr++; iCNr++;
|
||||
// Save back count
|
||||
if(fCompiler && fNaming) Count = iNr;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(fCompiler)
|
||||
pChunk->Count[iCNr] = 0;
|
||||
// Goto next entry
|
||||
iNr++; iCNr++;
|
||||
// Save back count
|
||||
if(fCompiler && fNaming) Count = iNr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ const size_t C4IDListChunkSize = 5; // size of id-chunks
|
|||
|
||||
class C4IDListChunk
|
||||
{
|
||||
public:
|
||||
public:
|
||||
C4ID id[C4IDListChunkSize];
|
||||
int32_t Count[C4IDListChunkSize];
|
||||
|
||||
|
@ -50,9 +50,9 @@ class C4IDListChunk
|
|||
};
|
||||
|
||||
class C4IDList : protected C4IDListChunk
|
||||
{
|
||||
public:
|
||||
C4IDList();
|
||||
{
|
||||
public:
|
||||
C4IDList();
|
||||
C4IDList(const C4IDList &rCopy); // copy ctor
|
||||
C4IDList &operator = (const C4IDList &rCopy); // assignment
|
||||
~C4IDList();
|
||||
|
@ -61,37 +61,37 @@ class C4IDList : protected C4IDListChunk
|
|||
ALLOW_TEMP_TO_REF(C4IDList)
|
||||
protected:
|
||||
size_t Count; // number of IDs in this list
|
||||
public:
|
||||
public:
|
||||
// General
|
||||
void Default();
|
||||
void Clear();
|
||||
void Clear();
|
||||
bool IsClear() const;
|
||||
// Access by direct index
|
||||
C4ID GetID(size_t index, int32_t *ipCount=NULL) const;
|
||||
int32_t GetCount(size_t index) const;
|
||||
bool SetCount(size_t index, int32_t iCount);
|
||||
// Access by ID
|
||||
int32_t GetIDCount(C4ID c_id, int32_t iZeroDefVal=0) const;
|
||||
// Access by direct index
|
||||
C4ID GetID(size_t index, int32_t *ipCount=NULL) const;
|
||||
int32_t GetCount(size_t index) const;
|
||||
bool SetCount(size_t index, int32_t iCount);
|
||||
// Access by ID
|
||||
int32_t GetIDCount(C4ID c_id, int32_t iZeroDefVal=0) const;
|
||||
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 DecreaseIDCount(C4ID c_id, bool fRemoveEmptyID=true)
|
||||
bool IncreaseIDCount(C4ID c_id, bool fAddNewID=true, int32_t IncreaseBy=1, bool fRemoveEmpty=false);
|
||||
bool DecreaseIDCount(C4ID c_id, bool fRemoveEmptyID=true)
|
||||
{ return IncreaseIDCount(c_id, false, -1, fRemoveEmptyID); }
|
||||
int32_t GetNumberOfIDs() const;
|
||||
int32_t GetNumberOfIDs() const;
|
||||
int32_t GetIndex(C4ID c_id) const;
|
||||
// Access by category-sorted index
|
||||
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;
|
||||
bool SetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t iCount);
|
||||
int32_t GetNumberOfIDs(C4DefList &rDefs, int32_t dwCategory) const;
|
||||
// Access by category-sorted index
|
||||
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;
|
||||
bool SetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t iCount);
|
||||
int32_t GetNumberOfIDs(C4DefList &rDefs, int32_t dwCategory) const;
|
||||
// IDList merge
|
||||
bool Add(C4IDList &rList);
|
||||
// Aux
|
||||
bool Consolidate();
|
||||
bool ConsolidateValids(C4DefList &rDefs, int32_t dwCategory = 0);
|
||||
// Aux
|
||||
bool Consolidate();
|
||||
bool ConsolidateValids(C4DefList &rDefs, int32_t dwCategory = 0);
|
||||
bool ConsolidateCounts();
|
||||
void SortByCategory(C4DefList &rDefs);
|
||||
void SortByValue(C4DefList &rDefs);
|
||||
void Load(C4DefList &rDefs, int32_t dwCategory);
|
||||
void Load(C4DefList &rDefs, int32_t dwCategory);
|
||||
// Item operation
|
||||
bool DeleteItem(size_t iIndex);
|
||||
bool SwapItems(size_t iIndex1, size_t iIndex2);
|
||||
|
@ -99,8 +99,8 @@ class C4IDList : protected C4IDListChunk
|
|||
void Draw(C4Facet &cgo, int32_t iSelection,
|
||||
C4DefList &rDefs, DWORD dwCategory,
|
||||
bool fCounts=true, int32_t iAlign=0) const;
|
||||
// Compiling
|
||||
void CompileFunc(StdCompiler *pComp, bool fValues = true);
|
||||
};
|
||||
// Compiling
|
||||
void CompileFunc(StdCompiler *pComp, bool fValues = true);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -37,10 +37,10 @@
|
|||
//------------------------------- Player Info ----------------------------------------
|
||||
|
||||
C4PlayerInfoCore::C4PlayerInfoCore()
|
||||
{
|
||||
ZeroMem(this,sizeof(C4PlayerInfoCore));
|
||||
{
|
||||
ZeroMem(this,sizeof(C4PlayerInfoCore));
|
||||
Default();
|
||||
}
|
||||
}
|
||||
|
||||
void C4PlayerInfoCore::Default(C4RankSystem *pRanks)
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ DWORD C4PlayerInfoCore::GetPrefColorValue(int32_t iPrefColor)
|
|||
}
|
||||
|
||||
bool C4PlayerInfoCore::Load(C4Group &hGroup)
|
||||
{
|
||||
{
|
||||
// New version
|
||||
StdStrBuf Source;
|
||||
if (hGroup.LoadEntryString(C4CFN_PlayerInfoCore,Source))
|
||||
|
@ -99,11 +99,11 @@ bool C4PlayerInfoCore::Load(C4Group &hGroup)
|
|||
}
|
||||
|
||||
// Old version no longer supported - sorry
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool C4PlayerInfoCore::Save(C4Group &hGroup)
|
||||
{
|
||||
{
|
||||
StdStrBuf Source, Name = hGroup.GetFullName(); Name.Append(DirSep C4CFN_PlayerInfoCore);
|
||||
if(!DecompileToBuf_Log<StdCompilerINIWrite>(*this, &Source, Name.getData()))
|
||||
return false;
|
||||
|
@ -349,14 +349,14 @@ void C4PhysicalChange::CompileFunc(StdCompiler *pComp)
|
|||
//------------------------------- Object Info ----------------------------------------
|
||||
|
||||
C4ObjectInfoCore::C4ObjectInfoCore()
|
||||
{
|
||||
{
|
||||
Default();
|
||||
}
|
||||
}
|
||||
|
||||
void C4ObjectInfoCore::Default(C4ID n_id,
|
||||
C4DefList *pDefs,
|
||||
const char *cpNames)
|
||||
{
|
||||
{
|
||||
|
||||
// Def
|
||||
C4Def *pDef=NULL;
|
||||
|
@ -364,8 +364,8 @@ void C4ObjectInfoCore::Default(C4ID n_id,
|
|||
|
||||
// Defaults
|
||||
id=n_id;
|
||||
Participation=1;
|
||||
Rank=0;
|
||||
Participation=1;
|
||||
Rank=0;
|
||||
Experience=0;
|
||||
Rounds=0;
|
||||
DeathCount=0;
|
||||
|
|
|
@ -31,31 +31,31 @@ const int32_t C4MaxPhysical = 100000,
|
|||
C4MaxDeathMsg = 75;
|
||||
|
||||
class C4PhysicalInfo
|
||||
{
|
||||
public:
|
||||
{
|
||||
public:
|
||||
C4PhysicalInfo();
|
||||
|
||||
typedef int32_t C4PhysicalInfo::* Offset;
|
||||
|
||||
public:
|
||||
int32_t Energy;
|
||||
public:
|
||||
int32_t Energy;
|
||||
int32_t Breath;
|
||||
int32_t Walk;
|
||||
int32_t Walk;
|
||||
int32_t Jump;
|
||||
int32_t Scale;
|
||||
int32_t Hangle;
|
||||
int32_t Dig;
|
||||
int32_t Swim;
|
||||
int32_t Throw;
|
||||
int32_t Throw;
|
||||
int32_t Push;
|
||||
int32_t Fight;
|
||||
int32_t Magic;
|
||||
int32_t CanScale;
|
||||
int32_t CanScale;
|
||||
int32_t CanHangle;
|
||||
int32_t CanDig;
|
||||
int32_t CanDig;
|
||||
int32_t CanConstruct;
|
||||
int32_t CanChop;
|
||||
int32_t CanSwimDig;
|
||||
int32_t CanSwimDig;
|
||||
int32_t CanFly;
|
||||
int32_t CorrosionResist;
|
||||
int32_t BreatheWater;
|
||||
|
@ -78,7 +78,7 @@ class C4PhysicalInfo
|
|||
static void TrainValue(int32_t *piVal, int32_t iTrainBy, int32_t iMaxTrain);
|
||||
public:
|
||||
void Train(Offset mpiOffset, int32_t iTrainBy, int32_t iMaxTrain);
|
||||
};
|
||||
};
|
||||
|
||||
class C4PhysicalChange
|
||||
{
|
||||
|
@ -125,33 +125,33 @@ class C4TempPhysicalInfo : public C4PhysicalInfo
|
|||
};
|
||||
|
||||
class C4ObjectInfoCore
|
||||
{
|
||||
public:
|
||||
C4ObjectInfoCore();
|
||||
public:
|
||||
C4ID id;
|
||||
char Name[C4MaxName+1];
|
||||
int32_t Participation;
|
||||
int32_t Rank;
|
||||
{
|
||||
public:
|
||||
C4ObjectInfoCore();
|
||||
public:
|
||||
C4ID id;
|
||||
char Name[C4MaxName+1];
|
||||
int32_t Participation;
|
||||
int32_t Rank;
|
||||
StdStrBuf sRankName;
|
||||
StdStrBuf sNextRankName;
|
||||
int32_t NextRankExp; // EXP_NoPromotion for no more promotion; 0 if standard rank system is used
|
||||
int32_t Experience,Rounds;
|
||||
int32_t DeathCount;
|
||||
int32_t Experience,Rounds;
|
||||
int32_t DeathCount;
|
||||
char TypeName[C4MaxName+1+1];
|
||||
int32_t Birthday,TotalPlayingTime;
|
||||
int32_t Age;
|
||||
char DeathMessage[C4MaxDeathMsg+1];
|
||||
char PortraitFile[C4MaxName+2+4+1]; // used portrait
|
||||
C4PhysicalInfo Physical;
|
||||
C4PhysicalInfo Physical;
|
||||
C4ValueMapData ExtraData;
|
||||
bool NoSave; // set for _XYZ-CrewMembers
|
||||
public:
|
||||
public:
|
||||
bool Save(C4Group &hGroup, class C4DefList *pDefs);
|
||||
bool Load(C4Group &hGroup);
|
||||
void Default(C4ID n_id=C4ID::None, class C4DefList *pDefs=NULL, const char *cpNames=NULL);
|
||||
//bool LoadNext(C4Group &hGroup); Old c4o support disabled...
|
||||
//bool Add(C4Group &hGroup);
|
||||
void Default(C4ID n_id=C4ID::None, class C4DefList *pDefs=NULL, const char *cpNames=NULL);
|
||||
//bool LoadNext(C4Group &hGroup); Old c4o support disabled...
|
||||
//bool Add(C4Group &hGroup);
|
||||
void Promote(int32_t iRank, C4RankSystem &rRanks, bool fForceRankName);
|
||||
bool GetNextRankInfo(C4RankSystem &rDefaultRanks, int32_t *piNextRankExp, StdStrBuf *psNextRankName);
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
|
@ -160,24 +160,24 @@ class C4ObjectInfoCore
|
|||
bool Decompile(char **ppOutput, size_t *ipSize);
|
||||
|
||||
void UpdateCustomRanks(C4DefList *pDefs); // sets NextRankName and NextRankExp
|
||||
};
|
||||
};
|
||||
|
||||
class C4RoundResult
|
||||
{
|
||||
{
|
||||
public:
|
||||
C4RoundResult();
|
||||
public:
|
||||
StdCopyStrBuf Title;
|
||||
uint32_t Date;
|
||||
int32_t Duration;
|
||||
int32_t Won;
|
||||
int32_t Score,FinalScore,TotalScore;
|
||||
public:
|
||||
StdCopyStrBuf Title;
|
||||
uint32_t Date;
|
||||
int32_t Duration;
|
||||
int32_t Won;
|
||||
int32_t Score,FinalScore,TotalScore;
|
||||
int32_t Bonus;
|
||||
int32_t Level;
|
||||
public:
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
};
|
||||
|
||||
class C4PlayerInfoCore
|
||||
{
|
||||
|
|
|
@ -49,74 +49,74 @@ const FIXED HitSpeed4=itofix(8); // Flat
|
|||
/* Some helper functions */
|
||||
|
||||
void RedirectForce(FIXED &from, FIXED &to, int32_t tdir)
|
||||
{
|
||||
FIXED fred;
|
||||
fred=Min(Abs(from), FRedirect);
|
||||
from-=fred*Sign(from);
|
||||
to+=fred*tdir;
|
||||
}
|
||||
{
|
||||
FIXED fred;
|
||||
fred=Min(Abs(from), FRedirect);
|
||||
from-=fred*Sign(from);
|
||||
to+=fred*tdir;
|
||||
}
|
||||
|
||||
void ApplyFriction(FIXED &tval, int32_t percent)
|
||||
{
|
||||
FIXED ffric=FFriction*percent/100;
|
||||
if (tval>+ffric) { tval-=ffric; return; }
|
||||
if (tval<-ffric) { tval+=ffric; return; }
|
||||
tval=0;
|
||||
}
|
||||
{
|
||||
FIXED ffric=FFriction*percent/100;
|
||||
if (tval>+ffric) { tval-=ffric; return; }
|
||||
if (tval<-ffric) { tval+=ffric; return; }
|
||||
tval=0;
|
||||
}
|
||||
|
||||
// Compares all Shape.VtxContactCNAT[] CNAT flags to search flag.
|
||||
// Returns true if CNAT match has been found.
|
||||
|
||||
bool ContactVtxCNAT(C4Object *cobj, BYTE cnat_dir)
|
||||
{
|
||||
int32_t cnt;
|
||||
bool fcontact=false;
|
||||
for (cnt=0; cnt<cobj->Shape.VtxNum; cnt++)
|
||||
if (cobj->Shape.VtxContactCNAT[cnt] & cnat_dir)
|
||||
fcontact=true;
|
||||
return fcontact;
|
||||
}
|
||||
{
|
||||
int32_t cnt;
|
||||
bool fcontact=false;
|
||||
for (cnt=0; cnt<cobj->Shape.VtxNum; cnt++)
|
||||
if (cobj->Shape.VtxContactCNAT[cnt] & cnat_dir)
|
||||
fcontact=true;
|
||||
return fcontact;
|
||||
}
|
||||
|
||||
// Finds first vertex with contact flag set.
|
||||
// Returns -1/0/+1 for relation on vertex to object center.
|
||||
|
||||
int32_t ContactVtxWeight(C4Object *cobj)
|
||||
{
|
||||
int32_t cnt;
|
||||
for (cnt=0; cnt<cobj->Shape.VtxNum; cnt++)
|
||||
if (cobj->Shape.VtxContactCNAT[cnt])
|
||||
{
|
||||
if (cobj->Shape.VtxX[cnt]<0) return -1;
|
||||
if (cobj->Shape.VtxX[cnt]>0) return +1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
int32_t cnt;
|
||||
for (cnt=0; cnt<cobj->Shape.VtxNum; cnt++)
|
||||
if (cobj->Shape.VtxContactCNAT[cnt])
|
||||
{
|
||||
if (cobj->Shape.VtxX[cnt]<0) return -1;
|
||||
if (cobj->Shape.VtxX[cnt]>0) return +1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ContactVtxFriction: Returns 0-100 friction value of first
|
||||
// contacted vertex;
|
||||
|
||||
int32_t ContactVtxFriction(C4Object *cobj)
|
||||
{
|
||||
int32_t cnt;
|
||||
for (cnt=0; cnt<cobj->Shape.VtxNum; cnt++)
|
||||
if (cobj->Shape.VtxContactCNAT[cnt])
|
||||
return cobj->Shape.VtxFriction[cnt];
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
int32_t cnt;
|
||||
for (cnt=0; cnt<cobj->Shape.VtxNum; cnt++)
|
||||
if (cobj->Shape.VtxContactCNAT[cnt])
|
||||
return cobj->Shape.VtxFriction[cnt];
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *CNATName(int32_t cnat)
|
||||
{
|
||||
switch (cnat)
|
||||
{
|
||||
case CNAT_None: return "None";
|
||||
case CNAT_Left: return "Left";
|
||||
case CNAT_Right: return "Right";
|
||||
case CNAT_Top: return "Top";
|
||||
case CNAT_Bottom: return "Bottom";
|
||||
case CNAT_Center: return "Center";
|
||||
}
|
||||
return "Undefined";
|
||||
}
|
||||
{
|
||||
switch (cnat)
|
||||
{
|
||||
case CNAT_None: return "None";
|
||||
case CNAT_Left: return "Left";
|
||||
case CNAT_Right: return "Right";
|
||||
case CNAT_Top: return "Top";
|
||||
case CNAT_Bottom: return "Bottom";
|
||||
case CNAT_Center: return "Center";
|
||||
}
|
||||
return "Undefined";
|
||||
}
|
||||
|
||||
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 false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void C4Object::DoMotion(int32_t mx, int32_t my)
|
||||
{
|
||||
if (pSolidMaskData) pSolidMaskData->Remove(true, true);
|
||||
fix_x += mx; fix_y += my;
|
||||
}
|
||||
{
|
||||
if (pSolidMaskData) pSolidMaskData->Remove(true, true);
|
||||
fix_x += mx; fix_y += my;
|
||||
}
|
||||
|
||||
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
|
||||
t_contact=Shape.ContactCNAT;
|
||||
|
||||
// Contact script call for the first contacted cnat
|
||||
if (Shape.ContactCNAT)
|
||||
for (int32_t ccnat=0; ccnat<4; ccnat++) // Left, right, top bottom
|
||||
if (Shape.ContactCNAT & (1<<ccnat))
|
||||
// Contact script call for the first contacted cnat
|
||||
if (Shape.ContactCNAT)
|
||||
for (int32_t ccnat=0; ccnat<4; ccnat++) // Left, right, top bottom
|
||||
if (Shape.ContactCNAT & (1<<ccnat))
|
||||
if (Contact(1<<ccnat))
|
||||
break; // Will stop on first positive return contact call!
|
||||
|
||||
|
@ -193,7 +193,7 @@ void C4Object::SideBounds(FIXED &ctcox)
|
|||
}
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -212,9 +212,9 @@ void C4Object::VerticalBounds(FIXED &ctcoy)
|
|||
}
|
||||
}
|
||||
// landscape bounds
|
||||
if (Def->BorderBound & C4D_Border_Top)
|
||||
if (Def->BorderBound & C4D_Border_Top)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -465,32 +465,32 @@ void C4Object::DoMovement()
|
|||
}
|
||||
|
||||
void C4Object::Stabilize()
|
||||
{
|
||||
{
|
||||
// def allows stabilization?
|
||||
if (Def->NoStabilize) return;
|
||||
// normalize angle
|
||||
int32_t nr = r; while(nr < -180) nr+=360; while(nr > 180) nr-=360;
|
||||
if (nr!=0)
|
||||
if (Inside<int32_t>(nr,-StableRange,+StableRange))
|
||||
{
|
||||
// Save step undos
|
||||
int32_t lcobjr=r;
|
||||
C4Shape lshape=Shape;
|
||||
// Try rotation
|
||||
r=0;
|
||||
UpdateShape();
|
||||
if (ContactCheck(GetX(),GetY()))
|
||||
{ // Undo rotation
|
||||
Shape=lshape;
|
||||
r=lcobjr;
|
||||
}
|
||||
else
|
||||
{ // Stabilization okay
|
||||
fix_r=itofix(r);
|
||||
UpdateFace(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Inside<int32_t>(nr,-StableRange,+StableRange))
|
||||
{
|
||||
// Save step undos
|
||||
int32_t lcobjr=r;
|
||||
C4Shape lshape=Shape;
|
||||
// Try rotation
|
||||
r=0;
|
||||
UpdateShape();
|
||||
if (ContactCheck(GetX(),GetY()))
|
||||
{ // Undo rotation
|
||||
Shape=lshape;
|
||||
r=lcobjr;
|
||||
}
|
||||
else
|
||||
{ // Stabilization okay
|
||||
fix_r=itofix(r);
|
||||
UpdateFace(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
{
|
||||
|
||||
// Containment check
|
||||
if (Contained)
|
||||
{
|
||||
CopyMotion(Contained);
|
||||
// Containment check
|
||||
if (Contained)
|
||||
{
|
||||
CopyMotion(Contained);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// General mobility check
|
||||
if (Category & C4D_StaticBack) return false;
|
||||
// General mobility check
|
||||
if (Category & C4D_StaticBack) return false;
|
||||
|
||||
// Movement execution
|
||||
if (Mobile) // Object is moving
|
||||
{
|
||||
// Move object
|
||||
DoMovement();
|
||||
// Demobilization check
|
||||
if ((xdir==0) && (ydir==0) && (rdir==0)) Mobile=0;
|
||||
// Check for stabilization
|
||||
if (rdir==0) Stabilize();
|
||||
}
|
||||
else // Object is static
|
||||
{
|
||||
// Check for stabilization
|
||||
Stabilize();
|
||||
// Check for mobilization
|
||||
if (!::Game.iTick10)
|
||||
{
|
||||
// Gravity mobilization
|
||||
xdir=ydir=rdir=0;
|
||||
fix_r=itofix(r);
|
||||
Mobile=1;
|
||||
}
|
||||
}
|
||||
// Movement execution
|
||||
if (Mobile) // Object is moving
|
||||
{
|
||||
// Move object
|
||||
DoMovement();
|
||||
// Demobilization check
|
||||
if ((xdir==0) && (ydir==0) && (rdir==0)) Mobile=0;
|
||||
// Check for stabilization
|
||||
if (rdir==0) Stabilize();
|
||||
}
|
||||
else // Object is static
|
||||
{
|
||||
// Check for stabilization
|
||||
Stabilize();
|
||||
// Check for mobilization
|
||||
if (!::Game.iTick10)
|
||||
{
|
||||
// Gravity mobilization
|
||||
xdir=ydir=rdir=0;
|
||||
fix_r=itofix(r);
|
||||
Mobile=1;
|
||||
}
|
||||
}
|
||||
|
||||
// Enforce zero rotation
|
||||
if (!Def->Rotateable) r=0;
|
||||
// Enforce zero rotation
|
||||
if (!Def->Rotateable) r=0;
|
||||
|
||||
// Out of bounds check
|
||||
if ((!Inside<int32_t>(GetX(),0,GBackWdt) && !(Def->BorderBound & C4D_Border_Sides)) || (GetY()>GBackHgt && !(Def->BorderBound & C4D_Border_Bottom)))
|
||||
// Out of bounds check
|
||||
if ((!Inside<int32_t>(GetX(),0,GBackWdt) && !(Def->BorderBound & C4D_Border_Sides)) || (GetY()>GBackHgt && !(Def->BorderBound & C4D_Border_Bottom)))
|
||||
{
|
||||
C4PropList* pActionDef = GetAction();
|
||||
// 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 fBreak = false;
|
||||
bool fBreak = false;
|
||||
int32_t ctcox,ctcoy,cx,cy;
|
||||
cx = fixtoi(x); cy = fixtoi(y);
|
||||
do
|
||||
do
|
||||
{
|
||||
if(!iIter--) return false;
|
||||
// Set target position by momentum
|
||||
x+=xdir; y+=ydir;
|
||||
// Movement to target
|
||||
ctcox=fixtoi(x); ctcoy=fixtoi(y);
|
||||
// Bounds
|
||||
if (!Inside<int32_t>(ctcox,0,GBackWdt) || (ctcoy>=GBackHgt)) return false;
|
||||
// Move to target
|
||||
do
|
||||
{
|
||||
// Set next step target
|
||||
cx+=Sign(ctcox-cx); cy+=Sign(ctcoy-cy);
|
||||
// Contact check
|
||||
if(Inside(GBackDensity(cx,cy), iDensityMin, iDensityMax))
|
||||
// Set target position by momentum
|
||||
x+=xdir; y+=ydir;
|
||||
// Movement to target
|
||||
ctcox=fixtoi(x); ctcoy=fixtoi(y);
|
||||
// Bounds
|
||||
if (!Inside<int32_t>(ctcox,0,GBackWdt) || (ctcoy>=GBackHgt)) return false;
|
||||
// Move to target
|
||||
do
|
||||
{
|
||||
// Set next step target
|
||||
cx+=Sign(ctcox-cx); cy+=Sign(ctcoy-cy);
|
||||
// Contact check
|
||||
if(Inside(GBackDensity(cx,cy), iDensityMin, iDensityMax))
|
||||
{ fBreak = true; break; }
|
||||
}
|
||||
while ((cx!=ctcox) || (cy!=ctcoy));
|
||||
// Adjust GravAccel once per frame
|
||||
ydir+=GravAccel;
|
||||
}
|
||||
while ((cx!=ctcox) || (cy!=ctcoy));
|
||||
// Adjust GravAccel once per frame
|
||||
ydir+=GravAccel;
|
||||
}
|
||||
while(!fBreak);
|
||||
// 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)
|
||||
{
|
||||
{
|
||||
// Start in water?
|
||||
if(DensityLiquid(GBackDensity(fixtoi(fcx), fixtoi(fcy))))
|
||||
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;
|
||||
// liquid & deep enough?
|
||||
return GBackLiquid(fixtoi(fcx), fixtoi(fcy)) && GBackLiquid(fixtoi(fcx), fixtoi(fcy) + 9);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -91,25 +91,25 @@ class C4Action
|
|||
~C4Action();
|
||||
public:
|
||||
//C4PropList * pActionDef;
|
||||
int32_t Dir;
|
||||
int32_t Dir;
|
||||
int32_t DrawDir; // NoSave // - needs to be calculated for old-style objects.txt anyway
|
||||
int32_t ComDir;
|
||||
int32_t Time;
|
||||
int32_t Data;
|
||||
int32_t Phase,PhaseDelay;
|
||||
int32_t t_attach; // SyncClearance-NoSave //
|
||||
C4Object *Target,*Target2;
|
||||
C4Facet Facet; // NoSave //
|
||||
int32_t FacetX,FacetY; // NoSave //
|
||||
StdMeshInstance::AnimationNode* Animation; // NoSave //
|
||||
public:
|
||||
int32_t ComDir;
|
||||
int32_t Time;
|
||||
int32_t Data;
|
||||
int32_t Phase,PhaseDelay;
|
||||
int32_t t_attach; // SyncClearance-NoSave //
|
||||
C4Object *Target,*Target2;
|
||||
C4Facet Facet; // NoSave //
|
||||
int32_t FacetX,FacetY; // NoSave //
|
||||
StdMeshInstance::AnimationNode* Animation; // NoSave //
|
||||
public:
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
|
||||
// BRIDGE procedure: data mask
|
||||
void SetBridgeData(int32_t iBridgeTime, bool fMoveClonk, bool fWall, int32_t iBridgeMaterial);
|
||||
void GetBridgeData(int32_t &riBridgeTime, bool &rfMoveClonk, bool &rfWall, int32_t &riBridgeMaterial);
|
||||
};
|
||||
};
|
||||
|
||||
class C4Object: public C4PropListNumbered
|
||||
{
|
||||
|
@ -420,6 +420,6 @@ class C4Object: public C4PropListNumbered
|
|||
|
||||
// overloaded from C4PropList
|
||||
virtual C4Object * GetObject() { return this; }
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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 ObjectActionWalk(C4Object *cObj)
|
||||
{
|
||||
if (!cObj->SetActionByName("Walk")) return false;
|
||||
cObj->xdir=cObj->ydir=0;
|
||||
return true;
|
||||
}
|
||||
{
|
||||
if (!cObj->SetActionByName("Walk")) return false;
|
||||
cObj->xdir=cObj->ydir=0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionStand(C4Object *cObj)
|
||||
{
|
||||
cObj->Action.ComDir=COMD_Stop;
|
||||
if (!ObjectActionWalk(cObj)) return false;
|
||||
return true;
|
||||
}
|
||||
{
|
||||
cObj->Action.ComDir=COMD_Stop;
|
||||
if (!ObjectActionWalk(cObj)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionJump(C4Object *cObj, FIXED xdir, FIXED ydir, bool fByCom)
|
||||
{
|
||||
{
|
||||
// scripted jump?
|
||||
assert(cObj);
|
||||
C4AulParSet pars(C4VInt(fixtoi(xdir, 100)), C4VInt(fixtoi(ydir, 100)), C4VBool(fByCom));
|
||||
if (!!cObj->Call(PSF_OnActionJump, &pars)) return true;
|
||||
// hardcoded jump by action
|
||||
if (!cObj->SetActionByName("Jump")) return false;
|
||||
cObj->xdir=xdir; cObj->ydir=ydir;
|
||||
cObj->Mobile=1;
|
||||
if (!cObj->SetActionByName("Jump")) return false;
|
||||
cObj->xdir=xdir; cObj->ydir=ydir;
|
||||
cObj->Mobile=1;
|
||||
// unstick from ground, because jump command may be issued in an Action-callback,
|
||||
// where attach-values have already been determined for that frame
|
||||
cObj->Action.t_attach&=~CNAT_Bottom;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionDive(C4Object *cObj, FIXED xdir, FIXED ydir)
|
||||
{
|
||||
if (!cObj->SetActionByName("Dive")) return false;
|
||||
cObj->xdir=xdir; cObj->ydir=ydir;
|
||||
cObj->Mobile=1;
|
||||
{
|
||||
if (!cObj->SetActionByName("Dive")) return false;
|
||||
cObj->xdir=xdir; cObj->ydir=ydir;
|
||||
cObj->Mobile=1;
|
||||
// unstick from ground, because jump command may be issued in an Action-callback,
|
||||
// where attach-values have already been determined for that frame
|
||||
cObj->Action.t_attach&=~CNAT_Bottom;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionTumble(C4Object *cObj, int32_t dir, FIXED xdir, FIXED ydir)
|
||||
{
|
||||
if (!cObj->SetActionByName("Tumble")) return false;
|
||||
cObj->SetDir(dir);
|
||||
cObj->xdir=xdir; cObj->ydir=ydir;
|
||||
return true;
|
||||
}
|
||||
{
|
||||
if (!cObj->SetActionByName("Tumble")) return false;
|
||||
cObj->SetDir(dir);
|
||||
cObj->xdir=xdir; cObj->ydir=ydir;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionGetPunched(C4Object *cObj, FIXED xdir, FIXED ydir)
|
||||
{
|
||||
if (!cObj->SetActionByName("GetPunched")) return false;
|
||||
cObj->xdir=xdir; cObj->ydir=ydir;
|
||||
return true;
|
||||
}
|
||||
{
|
||||
if (!cObj->SetActionByName("GetPunched")) return false;
|
||||
cObj->xdir=xdir; cObj->ydir=ydir;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionKneel(C4Object *cObj)
|
||||
{
|
||||
if (!cObj->SetActionByName("KneelDown")) return false;
|
||||
cObj->xdir=cObj->ydir=0;
|
||||
return true;
|
||||
}
|
||||
{
|
||||
if (!cObj->SetActionByName("KneelDown")) return false;
|
||||
cObj->xdir=cObj->ydir=0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionFlat(C4Object *cObj, int32_t dir)
|
||||
{
|
||||
if (!cObj->SetActionByName("FlatUp")) return false;
|
||||
cObj->xdir=cObj->ydir=0;
|
||||
cObj->SetDir(dir);
|
||||
return true;
|
||||
}
|
||||
{
|
||||
if (!cObj->SetActionByName("FlatUp")) return false;
|
||||
cObj->xdir=cObj->ydir=0;
|
||||
cObj->SetDir(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionScale(C4Object *cObj, int32_t dir)
|
||||
{
|
||||
if (!cObj->SetActionByName("Scale")) return false;
|
||||
cObj->xdir=cObj->ydir=0;
|
||||
cObj->SetDir(dir);
|
||||
return true;
|
||||
}
|
||||
{
|
||||
if (!cObj->SetActionByName("Scale")) return false;
|
||||
cObj->xdir=cObj->ydir=0;
|
||||
cObj->SetDir(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionHangle(C4Object *cObj, int32_t dir)
|
||||
{
|
||||
if (!cObj->SetActionByName("Hangle")) return false;
|
||||
cObj->xdir=cObj->ydir=0;
|
||||
cObj->SetDir(dir);
|
||||
return true;
|
||||
}
|
||||
{
|
||||
if (!cObj->SetActionByName("Hangle")) return false;
|
||||
cObj->xdir=cObj->ydir=0;
|
||||
cObj->SetDir(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionThrow(C4Object *cObj, C4Object *pThing)
|
||||
{
|
||||
// No object specified, first from contents
|
||||
{
|
||||
// No object specified, first from contents
|
||||
if (!pThing) pThing = cObj->Contents.GetObject();
|
||||
// Nothing to throw
|
||||
if (!pThing) return false;
|
||||
// Force and direction
|
||||
FIXED pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
|
||||
int32_t iDir=1; if (cObj->Action.Dir==DIR_Left) iDir=-1;
|
||||
FIXED pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
|
||||
int32_t iDir=1; if (cObj->Action.Dir==DIR_Left) iDir=-1;
|
||||
// Set action
|
||||
if (!cObj->SetActionByName("Throw")) return false;
|
||||
if (!cObj->SetActionByName("Throw")) return false;
|
||||
// Exit object
|
||||
pThing->Exit(cObj->GetX(),
|
||||
cObj->GetY()+cObj->Shape.y-1,
|
||||
Random(360),
|
||||
pthrow*iDir+cObj->xdir,-pthrow+cObj->ydir,pthrow*iDir);
|
||||
cObj->GetY()+cObj->Shape.y-1,
|
||||
Random(360),
|
||||
pthrow*iDir+cObj->xdir,-pthrow+cObj->ydir,pthrow*iDir);
|
||||
// Success
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionDig(C4Object *cObj)
|
||||
{
|
||||
if (!cObj->SetActionByName("Dig")) return false;
|
||||
cObj->Action.Data=0; // Material Dig2Object request
|
||||
return true;
|
||||
}
|
||||
{
|
||||
if (!cObj->SetActionByName("Dig")) return false;
|
||||
cObj->Action.Data=0; // Material Dig2Object request
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectActionBuild(C4Object *cObj, C4Object *target)
|
||||
{
|
||||
return cObj->SetActionByName("Build",target);
|
||||
}
|
||||
{
|
||||
return cObj->SetActionByName("Build",target);
|
||||
}
|
||||
|
||||
bool ObjectActionPush(C4Object *cObj, C4Object *target)
|
||||
{
|
||||
return cObj->SetActionByName("Push",target);
|
||||
}
|
||||
{
|
||||
return cObj->SetActionByName("Push",target);
|
||||
}
|
||||
|
||||
bool ObjectActionFight(C4Object *cObj, C4Object *target)
|
||||
{
|
||||
return cObj->SetActionByName("Fight",target);
|
||||
}
|
||||
{
|
||||
return cObj->SetActionByName("Fight",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)
|
||||
{
|
||||
int32_t ctx,cty;
|
||||
cty=cObj->GetY()-iRangeY;
|
||||
if (cObj->Action.Dir==DIR_Left) ctx=cObj->GetX()-iRangeX;
|
||||
else ctx=cObj->GetX()+iRangeX;
|
||||
cObj->ContactCheck(ctx,cty); // (resets VtxContact & t_contact)
|
||||
if (!(cObj->t_contact & CNAT_Top))
|
||||
if (!(cObj->t_contact & CNAT_Left))
|
||||
if (!(cObj->t_contact & CNAT_Right))
|
||||
{
|
||||
int32_t ctx,cty;
|
||||
cty=cObj->GetY()-iRangeY;
|
||||
if (cObj->Action.Dir==DIR_Left) ctx=cObj->GetX()-iRangeX;
|
||||
else ctx=cObj->GetX()+iRangeX;
|
||||
cObj->ContactCheck(ctx,cty); // (resets VtxContact & t_contact)
|
||||
if (!(cObj->t_contact & CNAT_Top))
|
||||
if (!(cObj->t_contact & CNAT_Left))
|
||||
if (!(cObj->t_contact & CNAT_Right))
|
||||
if (!(cObj->t_contact & CNAT_Bottom))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
{
|
||||
int32_t iRangeX,iRangeY;
|
||||
// Scaling: check range max to min
|
||||
if (cObj->GetProcedure()==DFA_SCALE)
|
||||
|
@ -229,10 +229,10 @@ bool ObjectActionCornerScale(C4Object *cObj)
|
|||
}
|
||||
|
||||
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
|
||||
if (!cObj->xdir && (cObj->GetProcedure() == DFA_WALK || cObj->GetProcedure() == DFA_HANGLE))
|
||||
switch (comdir)
|
||||
|
@ -244,8 +244,8 @@ bool ObjectComMovement(C4Object *cObj, int32_t comdir)
|
|||
cObj->SetDir(DIR_Right);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectComTurn(C4Object *cObj)
|
||||
{
|
||||
|
@ -259,12 +259,12 @@ bool ObjectComTurn(C4Object *cObj)
|
|||
}
|
||||
|
||||
bool ObjectComStop(C4Object *cObj)
|
||||
{
|
||||
// Cease current action
|
||||
cObj->SetActionByName("Idle");
|
||||
// Action walk if possible
|
||||
return ObjectActionStand(cObj);
|
||||
}
|
||||
{
|
||||
// Cease current action
|
||||
cObj->SetActionByName("Idle");
|
||||
// Action walk if possible
|
||||
return ObjectActionStand(cObj);
|
||||
}
|
||||
|
||||
bool ObjectComGrab(C4Object *cObj, C4Object *pTarget)
|
||||
{
|
||||
|
@ -297,7 +297,7 @@ bool ObjectComUnGrab(C4Object *cObj)
|
|||
}
|
||||
|
||||
bool ObjectComJump(C4Object *cObj) // by ObjectComUp, ExecCMDFMoveTo, FnJump
|
||||
{
|
||||
{
|
||||
// Only if walking
|
||||
if (cObj->GetProcedure()!=DFA_WALK) return false;
|
||||
// Calculate direction & forces
|
||||
|
@ -322,61 +322,61 @@ bool ObjectComJump(C4Object *cObj) // by ObjectComUp, ExecCMDFMoveTo, FnJump
|
|||
if (SimFlightHitsLiquid(x,y,TXDir,-iPhysicalJump))
|
||||
if (ObjectActionDive(cObj,TXDir,-iPhysicalJump))
|
||||
return true;
|
||||
// Regular jump
|
||||
return ObjectActionJump(cObj,TXDir,-iPhysicalJump,true);
|
||||
}
|
||||
// Regular jump
|
||||
return ObjectActionJump(cObj,TXDir,-iPhysicalJump,true);
|
||||
}
|
||||
|
||||
bool ObjectComLetGo(C4Object *cObj, int32_t xdirf)
|
||||
{ // by ACTSCALE, ACTHANGLE or ExecCMDFMoveTo
|
||||
return ObjectActionJump(cObj,itofix(xdirf),Fix0,true);
|
||||
}
|
||||
{ // by ACTSCALE, ACTHANGLE or ExecCMDFMoveTo
|
||||
return ObjectActionJump(cObj,itofix(xdirf),Fix0,true);
|
||||
}
|
||||
|
||||
bool ObjectComEnter(C4Object *cObj) // by pusher
|
||||
{
|
||||
if (!cObj) return false;
|
||||
{
|
||||
if (!cObj) return false;
|
||||
|
||||
// NoPushEnter
|
||||
if (cObj->Def->NoPushEnter) return false;
|
||||
|
||||
// Check object entrance, try command enter
|
||||
C4Object *pTarget;
|
||||
DWORD ocf=OCF_Entrance;
|
||||
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
|
||||
if (ocf & OCF_Entrance)
|
||||
{ cObj->SetCommand(C4CMD_Enter,pTarget); return true; }
|
||||
// Check object entrance, try command enter
|
||||
C4Object *pTarget;
|
||||
DWORD ocf=OCF_Entrance;
|
||||
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
|
||||
if (ocf & OCF_Entrance)
|
||||
{ cObj->SetCommand(C4CMD_Enter,pTarget); return true; }
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool ObjectComUp(C4Object *cObj) // by DFA_WALK or DFA_SWIM
|
||||
{
|
||||
if (!cObj) return false;
|
||||
{
|
||||
if (!cObj) return false;
|
||||
|
||||
// Check object entrance, try command enter
|
||||
C4Object *pTarget;
|
||||
DWORD ocf=OCF_Entrance;
|
||||
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
|
||||
if (ocf & OCF_Entrance)
|
||||
return PlayerObjectCommand(cObj->Owner,C4CMD_Enter,pTarget);
|
||||
// Check object entrance, try command enter
|
||||
C4Object *pTarget;
|
||||
DWORD ocf=OCF_Entrance;
|
||||
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
|
||||
if (ocf & OCF_Entrance)
|
||||
return PlayerObjectCommand(cObj->Owner,C4CMD_Enter,pTarget);
|
||||
|
||||
// Try jump
|
||||
// Try jump
|
||||
if (cObj->GetProcedure()==DFA_WALK)
|
||||
return PlayerObjectCommand(cObj->Owner,C4CMD_Jump);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ObjectComDig(C4Object *cObj) // by DFA_WALK
|
||||
{
|
||||
C4PhysicalInfo *phys=cObj->GetPhysical();
|
||||
if (!phys->CanDig || !ObjectActionDig(cObj))
|
||||
{
|
||||
{
|
||||
C4PhysicalInfo *phys=cObj->GetPhysical();
|
||||
if (!phys->CanDig || !ObjectActionDig(cObj))
|
||||
{
|
||||
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NODIG"),cObj->GetName()).getData(),cObj);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
C4Object *CreateLine(C4ID idType, int32_t iOwner, C4Object *pFrom, C4Object *pTo)
|
||||
{
|
||||
|
@ -398,10 +398,10 @@ bool ObjectComLineConstruction(C4Object *cObj)
|
|||
C4Object *linekit,*tstruct,*cline;
|
||||
DWORD ocf;
|
||||
|
||||
ObjectActionStand(cObj);
|
||||
ObjectActionStand(cObj);
|
||||
|
||||
// Check physical
|
||||
if (!cObj->GetPhysical()->CanConstruct)
|
||||
// Check physical
|
||||
if (!cObj->GetPhysical()->CanConstruct)
|
||||
{
|
||||
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOLINECONSTRUCT"),cObj->GetName()).getData(),cObj); return false;
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
|
|||
// Check for linekit
|
||||
if (!(linekit=cObj->Contents.Find(C4ID::Linekit)))
|
||||
{
|
||||
// Check line pickup
|
||||
// Check line pickup
|
||||
ocf=OCF_LineConstruct;
|
||||
tstruct=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj);
|
||||
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;
|
||||
}
|
||||
// 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
|
||||
bool 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
|
||||
{
|
||||
{
|
||||
C4Object *pTarget;
|
||||
DWORD ocf;
|
||||
C4PhysicalInfo *phys=cObj->GetPhysical();
|
||||
DWORD ocf;
|
||||
C4PhysicalInfo *phys=cObj->GetPhysical();
|
||||
|
||||
// Contents activation (first contents object only)
|
||||
if (cObj->Contents.GetObject())
|
||||
|
@ -557,15 +557,15 @@ void ObjectComDigDouble(C4Object *cObj) // "Activation" by DFA_WALK, DFA_DIG, DF
|
|||
return;
|
||||
|
||||
// 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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Chop
|
||||
ocf=OCF_Chop;
|
||||
if (phys->CanChop)
|
||||
ocf=OCF_Chop;
|
||||
if (phys->CanChop)
|
||||
if (cObj->GetProcedure()!=DFA_SWIM)
|
||||
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
|
||||
if (ocf & OCF_Chop)
|
||||
|
@ -575,64 +575,64 @@ void ObjectComDigDouble(C4Object *cObj) // "Activation" by DFA_WALK, DFA_DIG, DF
|
|||
}
|
||||
|
||||
// Line construction pick up
|
||||
ocf=OCF_LineConstruct;
|
||||
if (phys->CanConstruct)
|
||||
ocf=OCF_LineConstruct;
|
||||
if (phys->CanConstruct)
|
||||
if (!cObj->Contents.GetObject())
|
||||
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
|
||||
if (ocf & OCF_LineConstruct)
|
||||
if (ObjectComLineConstruction(cObj))
|
||||
return;
|
||||
|
||||
// Own activation call
|
||||
if (!! cObj->Call(PSF_Activate, &C4AulParSet(C4VObj(cObj)))) return;
|
||||
// Own activation call
|
||||
if (!! cObj->Call(PSF_Activate, &C4AulParSet(C4VObj(cObj)))) return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool ObjectComDownDouble(C4Object *cObj) // by DFA_WALK
|
||||
{
|
||||
C4Object *pTarget;
|
||||
DWORD ocf= OCF_Construct | OCF_Grab;
|
||||
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
|
||||
{
|
||||
if (ocf & OCF_Construct)
|
||||
{ PlayerObjectCommand(cObj->Owner,C4CMD_Build,pTarget); return true; }
|
||||
if (ocf & OCF_Grab)
|
||||
{ PlayerObjectCommand(cObj->Owner,C4CMD_Grab,pTarget); return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
{
|
||||
C4Object *pTarget;
|
||||
DWORD ocf= OCF_Construct | OCF_Grab;
|
||||
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
|
||||
{
|
||||
if (ocf & OCF_Construct)
|
||||
{ PlayerObjectCommand(cObj->Owner,C4CMD_Build,pTarget); return true; }
|
||||
if (ocf & OCF_Grab)
|
||||
{ PlayerObjectCommand(cObj->Owner,C4CMD_Grab,pTarget); return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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();
|
||||
// Nothing to put
|
||||
if (!pThing) return false;
|
||||
// No target
|
||||
if (!pTarget) return false;
|
||||
// Grabbing: check C4D_Grab_Put
|
||||
if (pTarget!=cObj->Contained)
|
||||
if (!(pTarget->Def->GrabPutGet & C4D_Grab_Put))
|
||||
{
|
||||
// Was meant to be a drop anyway - probably obsolete as controls are being revised
|
||||
//if (ValidPlr(cObj->Owner))
|
||||
// if (Game.Players.Get(cObj->Owner)->LastComDownDouble)
|
||||
// return ObjectComDrop(cObj, pThing);
|
||||
// No grab put: fail
|
||||
return false;
|
||||
}
|
||||
// Target no fullcon
|
||||
if (!(pTarget->OCF & OCF_FullCon)) return false;
|
||||
// Transfer thing
|
||||
if (!pTarget) return false;
|
||||
// Grabbing: check C4D_Grab_Put
|
||||
if (pTarget!=cObj->Contained)
|
||||
if (!(pTarget->Def->GrabPutGet & C4D_Grab_Put))
|
||||
{
|
||||
// Was meant to be a drop anyway - probably obsolete as controls are being revised
|
||||
//if (ValidPlr(cObj->Owner))
|
||||
// if (Game.Players.Get(cObj->Owner)->LastComDownDouble)
|
||||
// return ObjectComDrop(cObj, pThing);
|
||||
// No grab put: fail
|
||||
return false;
|
||||
}
|
||||
// Target no fullcon
|
||||
if (!(pTarget->OCF & OCF_FullCon)) return false;
|
||||
// Transfer thing
|
||||
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
|
||||
cObj->Call(PSF_Put);
|
||||
cObj->Call(PSF_Put);
|
||||
// Target collection call
|
||||
pTarget->Call(PSF_Collection,&C4AulParSet(C4VObj(pThing), C4VBool(true)));
|
||||
pTarget->Call(PSF_Collection,&C4AulParSet(C4VObj(pThing), C4VBool(true)));
|
||||
// Success
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectComThrow(C4Object *cObj, C4Object *pThing)
|
||||
{
|
||||
|
@ -650,8 +650,8 @@ bool ObjectComThrow(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();
|
||||
// Nothing to throw
|
||||
if (!pThing) return false;
|
||||
|
@ -659,8 +659,8 @@ bool ObjectComDrop(C4Object *cObj, C4Object *pThing)
|
|||
// 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
|
||||
// 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);
|
||||
int32_t tdir=0; int right=0;
|
||||
FIXED pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
|
||||
int32_t tdir=0; int right=0;
|
||||
bool isHanglingOrSwimming = false;
|
||||
int32_t iProc = DFA_NONE;
|
||||
C4PropList* pActionDef = cObj->GetAction();
|
||||
|
@ -683,54 +683,54 @@ bool ObjectComDrop(C4Object *cObj, C4Object *pThing)
|
|||
// Update OCF
|
||||
cObj->SetOCF();
|
||||
// Ungrab
|
||||
ObjectComUnGrab(cObj);
|
||||
ObjectComUnGrab(cObj);
|
||||
// Done
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ObjectComChop(C4Object *cObj, C4Object *pTarget)
|
||||
{
|
||||
if (!pTarget) return false;
|
||||
if (!cObj->GetPhysical()->CanChop)
|
||||
{
|
||||
if (!pTarget) return false;
|
||||
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;
|
||||
}
|
||||
if (cObj->GetProcedure()!=DFA_WALK) return false;
|
||||
return ObjectActionChop(cObj,pTarget);
|
||||
}
|
||||
if (cObj->GetProcedure()!=DFA_WALK) return false;
|
||||
return ObjectActionChop(cObj,pTarget);
|
||||
}
|
||||
|
||||
bool ObjectComBuild(C4Object *cObj, C4Object *pTarget)
|
||||
{
|
||||
if (!pTarget) return false;
|
||||
// Needs to be idle or walking
|
||||
if (cObj->GetAction())
|
||||
if (cObj->GetProcedure()!=DFA_WALK)
|
||||
return false;
|
||||
return ObjectActionBuild(cObj,pTarget);
|
||||
}
|
||||
{
|
||||
if (!pTarget) return false;
|
||||
// Needs to be idle or walking
|
||||
if (cObj->GetAction())
|
||||
if (cObj->GetProcedure()!=DFA_WALK)
|
||||
return false;
|
||||
return ObjectActionBuild(cObj,pTarget);
|
||||
}
|
||||
|
||||
bool ObjectComPutTake(C4Object *cObj, C4Object *pTarget, C4Object *pThing) // by C4CMD_Throw
|
||||
{ // by C4CMD_Drop
|
||||
// Valid checks
|
||||
if (!pTarget) return false;
|
||||
// No object specified, first from contents
|
||||
{ // by C4CMD_Drop
|
||||
// Valid checks
|
||||
if (!pTarget) return false;
|
||||
// No object specified, first from contents
|
||||
if (!pThing) pThing = cObj->Contents.GetObject();
|
||||
// Has thing, put to target
|
||||
if (pThing)
|
||||
return ObjectComPut(cObj,pTarget,pThing);
|
||||
// If target is own container, activate activation menu
|
||||
if (pTarget==cObj->Contained)
|
||||
// Has thing, put to target
|
||||
if (pThing)
|
||||
return ObjectComPut(cObj,pTarget,pThing);
|
||||
// If target is own container, activate activation menu
|
||||
if (pTarget==cObj->Contained)
|
||||
return ObjectComTake(cObj); // carlo
|
||||
// Assuming target is grabbed, check for grab get
|
||||
if (pTarget->Def->GrabPutGet & C4D_Grab_Get)
|
||||
{
|
||||
// Activate get menu
|
||||
return cObj->ActivateMenu(C4MN_Get,0,0,0,pTarget);
|
||||
}
|
||||
// Failure
|
||||
return false;
|
||||
}
|
||||
// Assuming target is grabbed, check for grab get
|
||||
if (pTarget->Def->GrabPutGet & C4D_Grab_Get)
|
||||
{
|
||||
// Activate get menu
|
||||
return cObj->ActivateMenu(C4MN_Get,0,0,0,pTarget);
|
||||
}
|
||||
// Failure
|
||||
return false;
|
||||
}
|
||||
|
||||
// carlo
|
||||
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)
|
||||
{
|
||||
if (!cObj || !pTarget) return false;
|
||||
{
|
||||
if (!cObj || !pTarget) return false;
|
||||
if (!punch)
|
||||
if (pTarget->GetPhysical()->Fight)
|
||||
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)));
|
||||
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);
|
||||
int32_t tdir=+1; if (cObj->Action.Dir==DIR_Left) tdir=-1;
|
||||
pTarget->Action.ComDir=COMD_Stop;
|
||||
int32_t tdir=+1; if (cObj->Action.Dir==DIR_Left) tdir=-1;
|
||||
pTarget->Action.ComDir=COMD_Stop;
|
||||
// No tumbles when blow was caught
|
||||
if (fBlowStopped) return false;
|
||||
// Hard punch
|
||||
if (punch>=10)
|
||||
if (ObjectActionTumble(pTarget,pTarget->Action.Dir,FIXED100(150)*tdir,itofix(-2)))
|
||||
// Hard punch
|
||||
if (punch>=10)
|
||||
if (ObjectActionTumble(pTarget,pTarget->Action.Dir,FIXED100(150)*tdir,itofix(-2)))
|
||||
{ pTarget->Call(PSF_CatchBlow,&C4AulParSet(C4VInt(punch),
|
||||
C4VObj(cObj)));
|
||||
return true; }
|
||||
|
||||
// Regular punch
|
||||
if (ObjectActionGetPunched(pTarget,FIXED100(250)*tdir,Fix0))
|
||||
// Regular punch
|
||||
if (ObjectActionGetPunched(pTarget,FIXED100(250)*tdir,Fix0))
|
||||
{ pTarget->Call(PSF_CatchBlow,&C4AulParSet(C4VInt(punch),
|
||||
C4VObj(cObj)));
|
||||
return true; }
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ObjectComCancelAttach(C4Object *cObj)
|
||||
{
|
||||
if (cObj->GetProcedure()==DFA_ATTACH)
|
||||
return cObj->SetAction(0);
|
||||
return false;
|
||||
}
|
||||
{
|
||||
if (cObj->GetProcedure()==DFA_ATTACH)
|
||||
return cObj->SetAction(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
void ObjectComStopDig(C4Object *cObj)
|
||||
{
|
||||
|
@ -808,66 +808,66 @@ int32_t ComOrder(int32_t iIndex)
|
|||
}
|
||||
|
||||
const char *ComName(int32_t iCom)
|
||||
{
|
||||
switch (iCom)
|
||||
{
|
||||
case COM_Up: return "Up";
|
||||
case COM_Up_S: return "UpSingle";
|
||||
case COM_Up_D: return "UpDouble";
|
||||
case COM_Up_R: return "UpReleased";
|
||||
case COM_Down: return "Down";
|
||||
case COM_Down_S: return "DownSingle";
|
||||
case COM_Down_D: return "DownDouble";
|
||||
case COM_Down_R: return "DownReleased";
|
||||
case COM_Left: return "Left";
|
||||
case COM_Left_S: return "LeftSingle";
|
||||
case COM_Left_D: return "LeftDouble";
|
||||
case COM_Left_R: return "LeftReleased";
|
||||
case COM_Right: return "Right";
|
||||
case COM_Right_S: return "RightSingle";
|
||||
case COM_Right_D: return "RightDouble";
|
||||
case COM_Right_R: return "RightReleased";
|
||||
case COM_Dig: return "Dig";
|
||||
case COM_Dig_S: return "DigSingle";
|
||||
case COM_Dig_D: return "DigDouble";
|
||||
case COM_Dig_R: return "DigReleased";
|
||||
case COM_Throw: return "Throw";
|
||||
case COM_Throw_S: return "ThrowSingle";
|
||||
case COM_Throw_D: return "ThrowDouble";
|
||||
case COM_Throw_R: return "ThrowReleased";
|
||||
case COM_Special: return "Special";
|
||||
case COM_Special_S: return "SpecialSingle";
|
||||
case COM_Special_D: return "SpecialDouble";
|
||||
case COM_Special_R: return "SpecialReleased";
|
||||
case COM_Special2: return "Special2";
|
||||
case COM_Special2_S: return "Special2Single";
|
||||
case COM_Special2_D: return "Special2Double";
|
||||
case COM_Special2_R: return "Special2Released";
|
||||
case COM_WheelUp: return "WheelUp";
|
||||
case COM_WheelDown: return "WheelDown";
|
||||
}
|
||||
return "Undefined";
|
||||
}
|
||||
{
|
||||
switch (iCom)
|
||||
{
|
||||
case COM_Up: return "Up";
|
||||
case COM_Up_S: return "UpSingle";
|
||||
case COM_Up_D: return "UpDouble";
|
||||
case COM_Up_R: return "UpReleased";
|
||||
case COM_Down: return "Down";
|
||||
case COM_Down_S: return "DownSingle";
|
||||
case COM_Down_D: return "DownDouble";
|
||||
case COM_Down_R: return "DownReleased";
|
||||
case COM_Left: return "Left";
|
||||
case COM_Left_S: return "LeftSingle";
|
||||
case COM_Left_D: return "LeftDouble";
|
||||
case COM_Left_R: return "LeftReleased";
|
||||
case COM_Right: return "Right";
|
||||
case COM_Right_S: return "RightSingle";
|
||||
case COM_Right_D: return "RightDouble";
|
||||
case COM_Right_R: return "RightReleased";
|
||||
case COM_Dig: return "Dig";
|
||||
case COM_Dig_S: return "DigSingle";
|
||||
case COM_Dig_D: return "DigDouble";
|
||||
case COM_Dig_R: return "DigReleased";
|
||||
case COM_Throw: return "Throw";
|
||||
case COM_Throw_S: return "ThrowSingle";
|
||||
case COM_Throw_D: return "ThrowDouble";
|
||||
case COM_Throw_R: return "ThrowReleased";
|
||||
case COM_Special: return "Special";
|
||||
case COM_Special_S: return "SpecialSingle";
|
||||
case COM_Special_D: return "SpecialDouble";
|
||||
case COM_Special_R: return "SpecialReleased";
|
||||
case COM_Special2: return "Special2";
|
||||
case COM_Special2_S: return "Special2Single";
|
||||
case COM_Special2_D: return "Special2Double";
|
||||
case COM_Special2_R: return "Special2Released";
|
||||
case COM_WheelUp: return "WheelUp";
|
||||
case COM_WheelDown: return "WheelDown";
|
||||
}
|
||||
return "Undefined";
|
||||
}
|
||||
|
||||
int32_t Com2Control(int32_t iCom)
|
||||
{
|
||||
{
|
||||
iCom = iCom & ~(COM_Double | COM_Single);
|
||||
switch (iCom)
|
||||
{
|
||||
case COM_CursorLeft: return CON_CursorLeft;
|
||||
case COM_CursorToggle: return CON_CursorToggle;
|
||||
case COM_CursorRight: return CON_CursorRight;
|
||||
case COM_Throw: return CON_Throw;
|
||||
case COM_Up: return CON_Up;
|
||||
case COM_Dig: return CON_Dig;
|
||||
case COM_Left: return CON_Left;
|
||||
case COM_Down: return CON_Down;
|
||||
case COM_Right: return CON_Right;
|
||||
case COM_Special: return CON_Special;
|
||||
case COM_Special2: return CON_Special2;
|
||||
}
|
||||
switch (iCom)
|
||||
{
|
||||
case COM_CursorLeft: return CON_CursorLeft;
|
||||
case COM_CursorToggle: return CON_CursorToggle;
|
||||
case COM_CursorRight: return CON_CursorRight;
|
||||
case COM_Throw: return CON_Throw;
|
||||
case COM_Up: return CON_Up;
|
||||
case COM_Dig: return CON_Dig;
|
||||
case COM_Left: return CON_Left;
|
||||
case COM_Down: return CON_Down;
|
||||
case COM_Right: return CON_Right;
|
||||
case COM_Special: return CON_Special;
|
||||
case COM_Special2: return CON_Special2;
|
||||
}
|
||||
return CON_Menu;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t Control2Com(int32_t iControl, bool fUp)
|
||||
{
|
||||
|
|
|
@ -58,7 +58,7 @@ void C4ObjectInfo::Default()
|
|||
HasDied=false;
|
||||
ControlCount=0;
|
||||
Filename[0]=0;
|
||||
Next=NULL;
|
||||
Next=NULL;
|
||||
pDef = NULL;
|
||||
Portrait.Default();
|
||||
pNewPortrait = NULL;
|
||||
|
@ -289,7 +289,7 @@ bool C4ObjectInfo::Save(C4Group &hGroup, bool fStoreTiny, C4DefList *pDefs)
|
|||
void C4ObjectInfo::Evaluate()
|
||||
{
|
||||
Retire();
|
||||
if (WasInAction) Rounds++;
|
||||
if (WasInAction) Rounds++;
|
||||
}
|
||||
|
||||
void C4ObjectInfo::Clear()
|
||||
|
@ -304,8 +304,8 @@ void C4ObjectInfo::Recruit()
|
|||
{
|
||||
// already recruited?
|
||||
if (InAction) return;
|
||||
WasInAction=true;
|
||||
InAction=true;
|
||||
WasInAction=true;
|
||||
InAction=true;
|
||||
InActionTime=Game.Time;
|
||||
// rank name overload by def?
|
||||
C4Def *pDef=::Definitions.ID2Def(id);
|
||||
|
|
|
@ -28,13 +28,13 @@
|
|||
#include <C4FacetEx.h>
|
||||
|
||||
class C4ObjectInfo: public C4ObjectInfoCore
|
||||
{
|
||||
public:
|
||||
{
|
||||
public:
|
||||
C4ObjectInfo();
|
||||
~C4ObjectInfo();
|
||||
public:
|
||||
bool WasInAction;
|
||||
bool InAction;
|
||||
public:
|
||||
bool WasInAction;
|
||||
bool InAction;
|
||||
int32_t InActionTime;
|
||||
bool HasDied;
|
||||
int32_t ControlCount;
|
||||
|
@ -43,8 +43,8 @@ class C4ObjectInfo: public C4ObjectInfoCore
|
|||
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")
|
||||
char Filename[_MAX_PATH+1];
|
||||
C4ObjectInfo *Next;
|
||||
public:
|
||||
C4ObjectInfo *Next;
|
||||
public:
|
||||
void Default();
|
||||
void Clear();
|
||||
void Evaluate();
|
||||
|
@ -58,6 +58,6 @@ class C4ObjectInfo: public C4ObjectInfoCore
|
|||
bool SetPortrait(const char *szPortraitName, C4Def *pSourceDef, bool fAssignPermanently, bool fCopyFile);
|
||||
bool SetPortrait(C4PortraitGraphics *pNewPortraitGfx, bool fAssignPermanently, bool fCopyFile);
|
||||
bool ClearPortrait(bool fPermanently);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -60,22 +60,22 @@ void C4ObjectInfoList::Clear()
|
|||
|
||||
int32_t C4ObjectInfoList::Load(C4Group &hGroup, bool fLoadPortraits)
|
||||
{
|
||||
C4ObjectInfo *ninf;
|
||||
int32_t infn=0;
|
||||
char entryname[256+1];
|
||||
C4ObjectInfo *ninf;
|
||||
int32_t infn=0;
|
||||
char entryname[256+1];
|
||||
|
||||
// Search all c4i files
|
||||
// Search all c4i files
|
||||
hGroup.ResetSearch();
|
||||
while (hGroup.FindNextEntry(C4CFN_ObjectInfoFiles,entryname))
|
||||
while (hGroup.FindNextEntry(C4CFN_ObjectInfoFiles,entryname))
|
||||
if ((ninf=new C4ObjectInfo))
|
||||
{
|
||||
if (ninf->Load(hGroup,entryname,fLoadPortraits)) { Add(ninf); infn++; }
|
||||
else delete ninf;
|
||||
}
|
||||
|
||||
// Search all c4o files
|
||||
// Search all c4o files
|
||||
/*hGroup.ResetSearch();
|
||||
while (hGroup.FindNextEntry("*.c4o",entryname))
|
||||
while (hGroup.FindNextEntry("*.c4o",entryname))
|
||||
if (ninf=new C4ObjectInfo)
|
||||
if (ninf->Load(hGroup,entryname)) { Add(ninf); infn++; }
|
||||
else delete ninf;*/
|
||||
|
@ -89,7 +89,7 @@ int32_t C4ObjectInfoList::Load(C4Group &hGroup, bool fLoadPortraits)
|
|||
Load(ItemGroup, fLoadPortraits);
|
||||
}
|
||||
|
||||
return infn;
|
||||
return infn;
|
||||
}
|
||||
|
||||
bool C4ObjectInfoList::Add(C4ObjectInfo *pInfo)
|
||||
|
@ -103,28 +103,28 @@ bool C4ObjectInfoList::Add(C4ObjectInfo *pInfo)
|
|||
void C4ObjectInfoList::MakeValidName(char *sName)
|
||||
{
|
||||
char tstr[_MAX_PATH];
|
||||
int32_t iname,namelen=SLen(sName);
|
||||
for (iname=2; NameExists(sName); iname++)
|
||||
{
|
||||
sprintf(tstr," %d",iname);
|
||||
SCopy(tstr,sName+Min<int32_t>(namelen,C4MaxName-SLen(tstr)));
|
||||
}
|
||||
int32_t iname,namelen=SLen(sName);
|
||||
for (iname=2; NameExists(sName); iname++)
|
||||
{
|
||||
sprintf(tstr," %d",iname);
|
||||
SCopy(tstr,sName+Min<int32_t>(namelen,C4MaxName-SLen(tstr)));
|
||||
}
|
||||
}
|
||||
|
||||
bool C4ObjectInfoList::NameExists(const char *szName)
|
||||
{
|
||||
C4ObjectInfo *cinf;
|
||||
for (cinf=First; cinf; cinf=cinf->Next)
|
||||
if (SEqualNoCase(szName,cinf->Name))
|
||||
return true;
|
||||
return false;
|
||||
C4ObjectInfo *cinf;
|
||||
for (cinf=First; cinf; cinf=cinf->Next)
|
||||
if (SEqualNoCase(szName,cinf->Name))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
C4ObjectInfo* C4ObjectInfoList::GetIdle(C4ID c_id, C4DefList &rDefs)
|
||||
{
|
||||
C4Def *pDef;
|
||||
C4ObjectInfo *pInfo;
|
||||
C4ObjectInfo *pHiExp=NULL;
|
||||
C4ObjectInfo *pInfo;
|
||||
C4ObjectInfo *pHiExp=NULL;
|
||||
|
||||
// Search list
|
||||
for (pInfo=First; pInfo; pInfo=pInfo->Next)
|
||||
|
@ -143,20 +143,20 @@ C4ObjectInfo* C4ObjectInfoList::GetIdle(C4ID c_id, C4DefList &rDefs)
|
|||
|
||||
// Found
|
||||
if (pHiExp)
|
||||
{
|
||||
{
|
||||
pHiExp->Recruit();
|
||||
return pHiExp;
|
||||
}
|
||||
return pHiExp;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
C4ObjectInfo* C4ObjectInfoList::New(C4ID n_id, C4DefList *pDefs)
|
||||
{
|
||||
C4ObjectInfo *pInfo;
|
||||
C4ObjectInfo *pInfo;
|
||||
// Create new info object
|
||||
if (!(pInfo = new C4ObjectInfo)) return NULL;
|
||||
// Default type clonk if none specified
|
||||
if (!(pInfo = new C4ObjectInfo)) return NULL;
|
||||
// Default type clonk if none specified
|
||||
if (n_id == C4ID::None) n_id = C4ID::Clonk;
|
||||
// Check type valid and def available
|
||||
C4Def *pDef = NULL;
|
||||
|
@ -167,7 +167,7 @@ C4ObjectInfo* C4ObjectInfoList::New(C4ID n_id, C4DefList *pDefs)
|
|||
const char *cpNames = Game.Names.GetData();
|
||||
if (pDef->pClonkNames) cpNames = pDef->pClonkNames->GetData();
|
||||
// Default by type
|
||||
((C4ObjectInfoCore*)pInfo)->Default(n_id, pDefs, cpNames);
|
||||
((C4ObjectInfoCore*)pInfo)->Default(n_id, pDefs, cpNames);
|
||||
// Set birthday
|
||||
pInfo->Birthday=time(NULL);
|
||||
// Make valid names
|
||||
|
@ -175,16 +175,16 @@ C4ObjectInfo* C4ObjectInfoList::New(C4ID n_id, C4DefList *pDefs)
|
|||
// Add new portrait (permanently w/o copying file)
|
||||
if (Config.Graphics.AddNewCrewPortraits)
|
||||
pInfo->SetRandomPortrait(C4ID::None, true, false);
|
||||
// Add
|
||||
// Add
|
||||
Add(pInfo);
|
||||
++iNumCreated;
|
||||
return pInfo;
|
||||
return pInfo;
|
||||
}
|
||||
|
||||
void C4ObjectInfoList::Evaluate()
|
||||
{
|
||||
C4ObjectInfo *cinf;
|
||||
for (cinf=First; cinf; cinf=cinf->Next)
|
||||
for (cinf=First; cinf; cinf=cinf->Next)
|
||||
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)
|
||||
C4ObjectInfo *pInfo;
|
||||
for (pInfo = GetLast(); pInfo; pInfo = GetPrevious(pInfo))
|
||||
for (pInfo = GetLast(); pInfo; pInfo = GetPrevious(pInfo))
|
||||
{
|
||||
// don't safe TemporaryCrew in regular player files
|
||||
if (!fSavegame)
|
||||
|
@ -209,9 +209,9 @@ bool C4ObjectInfoList::Save(C4Group &hGroup, bool fSavegame, bool fStoreTiny, C4
|
|||
|
||||
C4ObjectInfo* C4ObjectInfoList::GetIdle(const char *szByName)
|
||||
{
|
||||
C4ObjectInfo *pInfo;
|
||||
C4ObjectInfo *pInfo;
|
||||
// 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 (pInfo->Participation) if (!pInfo->InAction)
|
||||
if (!pInfo->HasDied)
|
||||
|
@ -224,8 +224,8 @@ C4ObjectInfo* C4ObjectInfoList::GetIdle(const char *szByName)
|
|||
|
||||
void C4ObjectInfoList::DetachFromObjects()
|
||||
{
|
||||
C4ObjectInfo *cinf;
|
||||
for (cinf=First; cinf; cinf=cinf->Next)
|
||||
C4ObjectInfo *cinf;
|
||||
for (cinf=First; cinf; cinf=cinf->Next)
|
||||
::Objects.ClearInfo(cinf);
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ bool C4ObjectInfoList::IsElement(C4ObjectInfo *pInfo)
|
|||
|
||||
void C4ObjectInfoList::Strip(C4DefList &rDefs)
|
||||
{
|
||||
C4ObjectInfo *pInfo, *pPrev;
|
||||
C4ObjectInfo *pInfo, *pPrev;
|
||||
// Search list
|
||||
for (pInfo=First, pPrev=NULL; pInfo; )
|
||||
{
|
||||
|
|
|
@ -33,29 +33,29 @@
|
|||
#include <C4GameObjects.h>
|
||||
|
||||
C4ObjectList::C4ObjectList(): FirstIter(0)
|
||||
{
|
||||
{
|
||||
Default();
|
||||
}
|
||||
}
|
||||
|
||||
C4ObjectList::C4ObjectList(const C4ObjectList &List): FirstIter(0)
|
||||
{
|
||||
Default();
|
||||
Default();
|
||||
Copy(List);
|
||||
}
|
||||
|
||||
C4ObjectList::~C4ObjectList()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void C4ObjectList::Clear()
|
||||
{
|
||||
C4ObjectLink *cLnk,*nextLnk;
|
||||
for (cLnk=First; cLnk; cLnk=nextLnk)
|
||||
{ nextLnk=cLnk->Next; delete cLnk; }
|
||||
First=Last=NULL;
|
||||
{
|
||||
C4ObjectLink *cLnk,*nextLnk;
|
||||
for (cLnk=First; cLnk; cLnk=nextLnk)
|
||||
{ nextLnk=cLnk->Next; delete cLnk; }
|
||||
First=Last=NULL;
|
||||
if (pEnumerated) delete pEnumerated; pEnumerated=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const int MaxTempListID = 500;
|
||||
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
|
||||
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 ((dwCategory==C4D_All) || ( (cdef=C4Id2Def(clnk->Obj->Def->id)) && (cdef->Category & dwCategory) ))
|
||||
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
|
||||
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 ((dwCategory==C4D_All) || ( (cdef=C4Id2Def(clnk->Obj->Def->id)) && (cdef->Category & dwCategory) ))
|
||||
for (clid=0; clid<MaxTempListID; clid++)
|
||||
|
@ -105,7 +105,7 @@ int C4ObjectList::ListIDCount(int32_t dwCategory)
|
|||
}
|
||||
|
||||
// Count different id's
|
||||
for (clid=0; clid<MaxTempListID; clid++)
|
||||
for (clid=0; clid<MaxTempListID; clid++)
|
||||
if (TempListID[clid]==C4ID::None)
|
||||
return clid;
|
||||
|
||||
|
@ -115,9 +115,9 @@ int C4ObjectList::ListIDCount(int32_t dwCategory)
|
|||
|
||||
|
||||
bool C4ObjectList::Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted)
|
||||
{
|
||||
C4ObjectLink *nLnk;
|
||||
if (!nObj || !nObj->Def || !nObj->Status) return false;
|
||||
{
|
||||
C4ObjectLink *nLnk;
|
||||
if (!nObj || !nObj->Def || !nObj->Status) return false;
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (eSort==stMain)
|
||||
|
@ -134,10 +134,10 @@ bool C4ObjectList::Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted)
|
|||
// no self-sort
|
||||
assert(pLstSorted != this);
|
||||
|
||||
// Allocate new link
|
||||
if (!(nLnk=new C4ObjectLink)) return false;
|
||||
// Set link
|
||||
nLnk->Obj=nObj;
|
||||
// Allocate new link
|
||||
if (!(nLnk=new C4ObjectLink)) return false;
|
||||
// Set link
|
||||
nLnk->Obj=nObj;
|
||||
|
||||
// Search insert position (default: end of list)
|
||||
C4ObjectLink *cLnk = NULL, *cPrev = Last;
|
||||
|
@ -242,11 +242,11 @@ bool C4ObjectList::Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted)
|
|||
}
|
||||
#endif
|
||||
|
||||
// Add mass
|
||||
Mass+=nObj->Mass;
|
||||
// Add mass
|
||||
Mass+=nObj->Mass;
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool C4ObjectList::Remove(C4Object *pObj)
|
||||
{
|
||||
|
@ -280,76 +280,76 @@ bool C4ObjectList::Remove(C4Object *pObj)
|
|||
}
|
||||
|
||||
C4Object* C4ObjectList::Find(C4ID id, int owner, DWORD dwOCF)
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
// Find link and object
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
if (cLnk->Obj->Def->id==id)
|
||||
if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner))
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
// Find link and object
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
if (cLnk->Obj->Def->id==id)
|
||||
if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner))
|
||||
if (dwOCF & cLnk->Obj->OCF)
|
||||
return cLnk->Obj;
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
C4Object* C4ObjectList::FindOther(C4ID id, int owner)
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
// Find link and object
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
if (cLnk->Obj->Def->id!=id)
|
||||
if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner))
|
||||
return cLnk->Obj;
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
// Find link and object
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
if (cLnk->Obj->Def->id!=id)
|
||||
if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner))
|
||||
return cLnk->Obj;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
C4Object* C4ObjectList::GetObject(int Index)
|
||||
{
|
||||
int cIdx;
|
||||
C4ObjectLink *cLnk;
|
||||
// Find link and object
|
||||
for (cLnk=First,cIdx=0; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
{
|
||||
if (cIdx==Index) return cLnk->Obj;
|
||||
cIdx++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int cIdx;
|
||||
C4ObjectLink *cLnk;
|
||||
// Find link and object
|
||||
for (cLnk=First,cIdx=0; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
{
|
||||
if (cIdx==Index) return cLnk->Obj;
|
||||
cIdx++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
C4ObjectLink* C4ObjectList::GetLink(C4Object *pObj)
|
||||
{
|
||||
{
|
||||
if (!pObj) return NULL;
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj==pObj)
|
||||
return cLnk;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int C4ObjectList::ObjectCount(C4ID id, int32_t dwCategory) const
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
int iCount=0;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
if ( (id==C4ID::None) || (cLnk->Obj->Def->id==id) )
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
int iCount=0;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
if ( (id==C4ID::None) || (cLnk->Obj->Def->id==id) )
|
||||
if ( (dwCategory==C4D_All) || (cLnk->Obj->Category & dwCategory) )
|
||||
iCount++;
|
||||
return iCount;
|
||||
}
|
||||
return iCount;
|
||||
}
|
||||
|
||||
int C4ObjectList::MassCount()
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
int iMass=0;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
iMass+=cLnk->Obj->Mass;
|
||||
Mass=iMass;
|
||||
return iMass;
|
||||
}
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
int iMass=0;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
iMass+=cLnk->Obj->Mass;
|
||||
Mass=iMass;
|
||||
return iMass;
|
||||
}
|
||||
|
||||
void C4ObjectList::DrawIDList(C4Facet &cgo, int iSelection,
|
||||
C4DefList &rDefs, int32_t dwCategory,
|
||||
|
@ -360,7 +360,7 @@ void C4ObjectList::DrawIDList(C4Facet &cgo, int iSelection,
|
|||
/*int iSections = cgo.GetSectionCount();
|
||||
int iItems = ListIDCount(dwCategory);*/
|
||||
//int iFirstItem = BoundBy(iSelection-iSections/2,0,Max(iItems-iSections,0));
|
||||
int32_t cSec = 0;
|
||||
int32_t cSec = 0;
|
||||
int32_t iCount;
|
||||
C4Facet cgo2;
|
||||
C4Object *pFirstObj;
|
||||
|
@ -383,8 +383,8 @@ void C4ObjectList::DrawIDList(C4Facet &cgo, int iSelection,
|
|||
cSec++;
|
||||
}
|
||||
// Draw by list sorted ids
|
||||
/* for (cPos=0; c_id=GetListID(dwCategory,cPos); cPos++)
|
||||
if (Inside(cPos,iFirstItem,iFirstItem+iSections-1))
|
||||
/* for (cPos=0; c_id=GetListID(dwCategory,cPos); cPos++)
|
||||
if (Inside(cPos,iFirstItem,iFirstItem+iSections-1))
|
||||
{
|
||||
// First object of this type
|
||||
pFirstObj = Find(c_id);
|
||||
|
@ -401,8 +401,8 @@ void C4ObjectList::DrawIDList(C4Facet &cgo, int iSelection,
|
|||
// Region
|
||||
if (pRegions) pRegions->Add(cgo2.X,cgo2.Y,cgo2.Wdt,cgo2.Hgt,pFirstObj->GetName(),iRegionCom,pFirstObj,COM_None,COM_None,pFirstObj->id);
|
||||
// Next section
|
||||
cSec++;
|
||||
} */
|
||||
cSec++;
|
||||
} */
|
||||
}
|
||||
|
||||
int C4ObjectList::ClearPointers(C4Object *pObj)
|
||||
|
@ -411,62 +411,62 @@ int C4ObjectList::ClearPointers(C4Object *pObj)
|
|||
// Clear all primary list pointers
|
||||
while (Remove(pObj)) rval++;
|
||||
// Clear all sub pointers
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
cobj->ClearPointers(pObj);
|
||||
return rval;
|
||||
}
|
||||
|
||||
void C4ObjectList::DrawAll(C4TargetFacet &cgo, int iPlayer)
|
||||
{
|
||||
C4ObjectLink *clnk;
|
||||
// Draw objects (base)
|
||||
for (clnk=Last; clnk; clnk=clnk->Prev)
|
||||
C4ObjectLink *clnk;
|
||||
// Draw objects (base)
|
||||
for (clnk=Last; clnk; clnk=clnk->Prev)
|
||||
clnk->Obj->Draw(cgo, iPlayer);
|
||||
// Draw objects (top face)
|
||||
for (clnk=Last; clnk; clnk=clnk->Prev)
|
||||
// Draw objects (top face)
|
||||
for (clnk=Last; clnk; clnk=clnk->Prev)
|
||||
clnk->Obj->DrawTopFace(cgo, iPlayer);
|
||||
}
|
||||
|
||||
void C4ObjectList::DrawIfCategory(C4TargetFacet &cgo, int iPlayer, uint32_t dwCat, bool fInvert)
|
||||
{
|
||||
C4ObjectLink *clnk;
|
||||
// Draw objects (base)
|
||||
for (clnk=Last; clnk; clnk=clnk->Prev)
|
||||
C4ObjectLink *clnk;
|
||||
// Draw objects (base)
|
||||
for (clnk=Last; clnk; clnk=clnk->Prev)
|
||||
if (!(clnk->Obj->Category & dwCat) == fInvert)
|
||||
clnk->Obj->Draw(cgo, iPlayer);
|
||||
// Draw objects (top face)
|
||||
for (clnk=Last; clnk; clnk=clnk->Prev)
|
||||
// Draw objects (top face)
|
||||
for (clnk=Last; clnk; clnk=clnk->Prev)
|
||||
if (!(clnk->Obj->Category & dwCat) == fInvert)
|
||||
clnk->Obj->DrawTopFace(cgo, iPlayer);
|
||||
}
|
||||
|
||||
void C4ObjectList::Draw(C4TargetFacet &cgo, int iPlayer)
|
||||
{
|
||||
C4ObjectLink *clnk;
|
||||
// Draw objects (base)
|
||||
for (clnk=Last; clnk; clnk=clnk->Prev)
|
||||
C4ObjectLink *clnk;
|
||||
// Draw objects (base)
|
||||
for (clnk=Last; clnk; clnk=clnk->Prev)
|
||||
if (!(clnk->Obj->Category & C4D_BackgroundOrForeground))
|
||||
clnk->Obj->Draw(cgo, iPlayer);
|
||||
// Draw objects (top face)
|
||||
for (clnk=Last; clnk; clnk=clnk->Prev)
|
||||
// Draw objects (top face)
|
||||
for (clnk=Last; clnk; clnk=clnk->Prev)
|
||||
if (!(clnk->Obj->Category & C4D_BackgroundOrForeground))
|
||||
clnk->Obj->DrawTopFace(cgo, iPlayer);
|
||||
}
|
||||
|
||||
void C4ObjectList::Enumerate()
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
C4ObjectLink *cLnk;
|
||||
// Enumerate object pointers
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
cLnk->Obj->EnumeratePointers();
|
||||
}
|
||||
|
||||
bool C4ObjectList::IsContained(C4Object *pObj)
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj==pObj)
|
||||
return true;
|
||||
return false;
|
||||
|
@ -492,8 +492,8 @@ bool C4ObjectList::Write(char *szTarget)
|
|||
{
|
||||
char ostr[25];
|
||||
szTarget[0]=0;
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk && cLnk->Obj; cLnk=cLnk->Next)
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk && cLnk->Obj; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
{
|
||||
sprintf(ostr,"%d;",cLnk->Obj->Number);
|
||||
|
@ -504,16 +504,16 @@ bool C4ObjectList::Write(char *szTarget)
|
|||
|
||||
void C4ObjectList::Denumerate()
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
cLnk->Obj->DenumeratePointers();
|
||||
}
|
||||
|
||||
void C4ObjectList::CompileFunc(StdCompiler *pComp, bool fSaveRefs, bool fSkipPlayerObjects)
|
||||
{
|
||||
if(fSaveRefs)
|
||||
{
|
||||
if(fSaveRefs)
|
||||
{
|
||||
// this mode not supported
|
||||
assert(!fSkipPlayerObjects);
|
||||
// (Re)create list
|
||||
|
@ -529,35 +529,35 @@ void C4ObjectList::CompileFunc(StdCompiler *pComp, bool fSaveRefs, bool fSkipPla
|
|||
if(!pComp->isCompiler())
|
||||
{ delete pEnumerated; pEnumerated = NULL; }
|
||||
// Compiling: Nothing to do - list will e denumerated later
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pComp->isDecompiler())
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pComp->isDecompiler())
|
||||
{
|
||||
// skipping player objects would screw object counting in non-naming compilers
|
||||
assert(!fSkipPlayerObjects || pComp->hasNaming());
|
||||
// Put object count
|
||||
int32_t iObjCnt = ObjectCount();
|
||||
pComp->Value(mkNamingCountAdapt(iObjCnt, "Object"));
|
||||
// Decompile all objects in reverse order
|
||||
// Put object count
|
||||
int32_t iObjCnt = ObjectCount();
|
||||
pComp->Value(mkNamingCountAdapt(iObjCnt, "Object"));
|
||||
// Decompile all objects in reverse order
|
||||
for(C4ObjectLink *pPos = Last; pPos; pPos = pPos->Prev)
|
||||
if(pPos->Obj->Status)
|
||||
if (!fSkipPlayerObjects || !pPos->Obj->IsUserPlayerObject())
|
||||
pComp->Value(mkNamingAdapt(*pPos->Obj, "Object"));
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
// this mode not supported
|
||||
assert(!fSkipPlayerObjects);
|
||||
// Remove previous data
|
||||
Clear();
|
||||
// Get "Object" section count
|
||||
int32_t iObjCnt;
|
||||
pComp->Value(mkNamingCountAdapt(iObjCnt, "Object"));
|
||||
// Load objects, add them to the list.
|
||||
for(int i = 0; i < iObjCnt; i++)
|
||||
{
|
||||
C4Object *pObj = NULL;
|
||||
// Remove previous data
|
||||
Clear();
|
||||
// Get "Object" section count
|
||||
int32_t iObjCnt;
|
||||
pComp->Value(mkNamingCountAdapt(iObjCnt, "Object"));
|
||||
// Load objects, add them to the list.
|
||||
for(int i = 0; i < iObjCnt; i++)
|
||||
{
|
||||
C4Object *pObj = NULL;
|
||||
try
|
||||
{
|
||||
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());
|
||||
delete pExc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StdStrBuf C4ObjectList::GetNameList(C4DefList &rDefs, DWORD dwCategory)
|
||||
|
@ -583,7 +583,7 @@ StdStrBuf C4ObjectList::GetNameList(C4DefList &rDefs, DWORD dwCategory)
|
|||
C4ID c_id;
|
||||
C4Def *cdef;
|
||||
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)))
|
||||
{
|
||||
idcount=ObjectCount(c_id);
|
||||
|
@ -595,8 +595,8 @@ StdStrBuf C4ObjectList::GetNameList(C4DefList &rDefs, DWORD dwCategory)
|
|||
|
||||
bool C4ObjectList::ValidateOwners()
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
cLnk->Obj->ValidateOwner();
|
||||
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
|
||||
// (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
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=Last; cLnk; cLnk=cLnk->Prev)
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=Last; cLnk; cLnk=cLnk->Prev)
|
||||
if (cLnk->Obj->Status)
|
||||
cLnk->Obj->AssignInfo();
|
||||
return true;
|
||||
|
@ -616,8 +616,8 @@ bool C4ObjectList::AssignInfo()
|
|||
|
||||
void C4ObjectList::ClearInfo(C4ObjectInfo *pInfo)
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
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));
|
||||
C4Facet cgo2;
|
||||
int iObj=0,iSec=0;
|
||||
C4ObjectLink *cLnk; C4Object *cObj;
|
||||
for (cLnk=First; cLnk && (cObj=cLnk->Obj); cLnk=cLnk->Next)
|
||||
C4ObjectLink *cLnk; C4Object *cObj;
|
||||
for (cLnk=First; cLnk && (cObj=cLnk->Obj); cLnk=cLnk->Next)
|
||||
if (cObj->Status && (cObj->Category && dwCategory))
|
||||
{
|
||||
if (Inside(iObj,iFirstVisible,iFirstVisible+iSections-1))
|
||||
|
@ -644,7 +644,7 @@ void C4ObjectList::DrawList(C4Facet &cgo, int iSelection, DWORD dwCategory)
|
|||
|
||||
void C4ObjectList::Sort()
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
C4ObjectLink *cLnk;
|
||||
bool fSorted;
|
||||
// Sort by id
|
||||
do
|
||||
|
@ -725,45 +725,45 @@ void C4NotifyingObjectList::RemoveLink(C4ObjectLink *pLnk)
|
|||
|
||||
void C4ObjectList::UpdateGraphics(bool fGraphicsChanged)
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
cLnk->Obj->UpdateGraphics(fGraphicsChanged);
|
||||
}
|
||||
|
||||
void C4ObjectList::UpdateFaces(bool bUpdateShapes)
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=First; cLnk; cLnk=cLnk->Next)
|
||||
if (cLnk->Obj->Status)
|
||||
cLnk->Obj->UpdateFace(bUpdateShapes);
|
||||
}
|
||||
|
||||
void C4ObjectList::DrawSelectMark(C4TargetFacet &cgo, float Zoom)
|
||||
{
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=Last; cLnk; cLnk=cLnk->Prev)
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=Last; cLnk; cLnk=cLnk->Prev)
|
||||
cLnk->Obj->DrawSelectMark(cgo, Zoom);
|
||||
}
|
||||
|
||||
void C4ObjectList::CloseMenus()
|
||||
{
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
cobj->CloseMenu(true);
|
||||
C4Object *cobj; C4ObjectLink *clnk;
|
||||
for (clnk=First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
|
||||
cobj->CloseMenu(true);
|
||||
}
|
||||
|
||||
void C4ObjectList::Copy(const C4ObjectList &rList)
|
||||
{
|
||||
Clear(); Default();
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=rList.First; cLnk; cLnk=cLnk->Next) Add(cLnk->Obj, C4ObjectList::stNone);
|
||||
C4ObjectLink *cLnk;
|
||||
for (cLnk=rList.First; cLnk; cLnk=cLnk->Next) Add(cLnk->Obj, C4ObjectList::stNone);
|
||||
}
|
||||
|
||||
void C4ObjectList::Default()
|
||||
{
|
||||
First=Last=NULL;
|
||||
Mass=0;
|
||||
First=Last=NULL;
|
||||
Mass=0;
|
||||
pEnumerated=NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ void C4ObjectMenu::ClearPointers(C4Object *pObj)
|
|||
|
||||
C4Object* C4ObjectMenu::GetParentObject()
|
||||
{
|
||||
C4Object *cObj; C4ObjectLink *cLnk;
|
||||
C4Object *cObj; C4ObjectLink *cLnk;
|
||||
for (cLnk=::Objects.First; cLnk && (cObj=cLnk->Obj); cLnk=cLnk->Next)
|
||||
if ( cObj->Menu == this )
|
||||
return cObj;
|
||||
|
|
|
@ -55,7 +55,7 @@ void C4Shape::Clear()
|
|||
}
|
||||
|
||||
void C4Shape::Rotate(int32_t iAngle, bool bUpdateVertices)
|
||||
{
|
||||
{
|
||||
#ifdef DEBUGREC
|
||||
C4RCRotVtx rc;
|
||||
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]; }
|
||||
AddDbgRec(RCT_RotVtx1, &rc, sizeof(rc));
|
||||
#endif
|
||||
int32_t cnt,nvtx,nvty,rdia;
|
||||
int32_t cnt,nvtx,nvty,rdia;
|
||||
|
||||
//int32_t *vtx=VtxX;
|
||||
//int32_t *vty=VtxY;
|
||||
FIXED mtx[4];
|
||||
FIXED mtx[4];
|
||||
FIXED fAngle = itofix(iAngle);
|
||||
|
||||
if (bUpdateVertices)
|
||||
|
@ -104,89 +104,89 @@ void C4Shape::Rotate(int32_t iAngle, bool bUpdateVertices)
|
|||
|
||||
}
|
||||
|
||||
// Enlarge Rect
|
||||
rdia= (int32_t) sqrt(double(x*x+y*y)) + 2;
|
||||
x=-rdia;
|
||||
y=-rdia;
|
||||
Wdt=2*rdia;
|
||||
Hgt=2*rdia;
|
||||
// Enlarge Rect
|
||||
rdia= (int32_t) sqrt(double(x*x+y*y)) + 2;
|
||||
x=-rdia;
|
||||
y=-rdia;
|
||||
Wdt=2*rdia;
|
||||
Hgt=2*rdia;
|
||||
#ifdef DEBUGREC
|
||||
rc.x=x; rc.y=y; rc.wdt=Wdt; rc.hgt=Hgt;
|
||||
for (i=0; i<4; ++i)
|
||||
{ rc.VtxX[i]=VtxX[i]; rc.VtxY[i]=VtxY[i]; }
|
||||
AddDbgRec(RCT_RotVtx2, &rc, sizeof(rc));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void C4Shape::Stretch(int32_t iCon, bool bUpdateVertices)
|
||||
{
|
||||
int32_t cnt;
|
||||
x=x*iCon/FullCon;
|
||||
y=y*iCon/FullCon;
|
||||
Wdt=Wdt*iCon/FullCon;
|
||||
Hgt=Hgt*iCon/FullCon;
|
||||
FireTop=FireTop*iCon/FullCon;
|
||||
{
|
||||
int32_t cnt;
|
||||
x=x*iCon/FullCon;
|
||||
y=y*iCon/FullCon;
|
||||
Wdt=Wdt*iCon/FullCon;
|
||||
Hgt=Hgt*iCon/FullCon;
|
||||
FireTop=FireTop*iCon/FullCon;
|
||||
if (bUpdateVertices)
|
||||
for (cnt=0; cnt<VtxNum; cnt++)
|
||||
{
|
||||
VtxX[cnt]=VtxX[cnt]*iCon/FullCon;
|
||||
VtxY[cnt]=VtxY[cnt]*iCon/FullCon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void C4Shape::Jolt(int32_t iCon, bool bUpdateVertices)
|
||||
{
|
||||
int32_t cnt;
|
||||
y=y*iCon/FullCon;
|
||||
Hgt=Hgt*iCon/FullCon;
|
||||
FireTop=FireTop*iCon/FullCon;
|
||||
{
|
||||
int32_t cnt;
|
||||
y=y*iCon/FullCon;
|
||||
Hgt=Hgt*iCon/FullCon;
|
||||
FireTop=FireTop*iCon/FullCon;
|
||||
if (bUpdateVertices)
|
||||
for (cnt=0; cnt<VtxNum; cnt++)
|
||||
VtxY[cnt]=VtxY[cnt]*iCon/FullCon;
|
||||
}
|
||||
}
|
||||
|
||||
void C4Shape::GetVertexOutline(C4Rect &rRect)
|
||||
{
|
||||
int32_t cnt;
|
||||
rRect.x=rRect.y=rRect.Wdt=rRect.Hgt=0;
|
||||
for (cnt=0; cnt<VtxNum; cnt++)
|
||||
{
|
||||
{
|
||||
int32_t cnt;
|
||||
rRect.x=rRect.y=rRect.Wdt=rRect.Hgt=0;
|
||||
for (cnt=0; cnt<VtxNum; cnt++)
|
||||
{
|
||||
// Extend left
|
||||
if (VtxX[cnt]<rRect.x)
|
||||
{
|
||||
rRect.Wdt+=rRect.x-VtxX[cnt];
|
||||
rRect.x=VtxX[cnt];
|
||||
}
|
||||
if (VtxX[cnt]<rRect.x)
|
||||
{
|
||||
rRect.Wdt+=rRect.x-VtxX[cnt];
|
||||
rRect.x=VtxX[cnt];
|
||||
}
|
||||
// Extend right
|
||||
else if (VtxX[cnt]>rRect.x+rRect.Wdt)
|
||||
{ rRect.Wdt=VtxX[cnt]-rRect.x; }
|
||||
else if (VtxX[cnt]>rRect.x+rRect.Wdt)
|
||||
{ rRect.Wdt=VtxX[cnt]-rRect.x; }
|
||||
|
||||
// Extend up
|
||||
if (VtxY[cnt]<rRect.y)
|
||||
{
|
||||
rRect.Hgt+=rRect.y-VtxY[cnt];
|
||||
rRect.y=VtxY[cnt];
|
||||
}
|
||||
if (VtxY[cnt]<rRect.y)
|
||||
{
|
||||
rRect.Hgt+=rRect.y-VtxY[cnt];
|
||||
rRect.y=VtxY[cnt];
|
||||
}
|
||||
// Extend down
|
||||
else if (VtxY[cnt]>rRect.y+rRect.Hgt)
|
||||
{ rRect.Hgt=VtxY[cnt]-rRect.y; }
|
||||
}
|
||||
else if (VtxY[cnt]>rRect.y+rRect.Hgt)
|
||||
{ rRect.Hgt=VtxY[cnt]-rRect.y; }
|
||||
}
|
||||
|
||||
rRect.Hgt+=rRect.y-y;
|
||||
rRect.y=y;
|
||||
rRect.Hgt+=rRect.y-y;
|
||||
rRect.y=y;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool C4Shape::Attach(int32_t &cx, int32_t &cy, BYTE cnat_pos)
|
||||
{
|
||||
{
|
||||
// Adjust given position to one pixel before contact
|
||||
// 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;
|
||||
|
||||
// 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)
|
||||
|
@ -335,14 +335,14 @@ bool C4Shape::CheckContact(int32_t cx, int32_t cy)
|
|||
// 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 (GBackDensity(cx+VtxX[cvtx],cy+VtxY[cvtx]) >= ContactDensity)
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
|
||||
ContactCNAT=CNAT_None;
|
||||
ContactCNAT=CNAT_None;
|
||||
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
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -41,27 +41,27 @@ class C4DensityProvider
|
|||
extern C4DensityProvider DefaultDensityProvider;
|
||||
|
||||
class C4Shape: public C4Rect
|
||||
{
|
||||
public:
|
||||
{
|
||||
public:
|
||||
C4Shape();
|
||||
public:
|
||||
public:
|
||||
// remember to adjust C4Shape::CopyFrom and CreateOwnOriginalCopy when adding members here!
|
||||
int32_t FireTop;
|
||||
int32_t VtxNum;
|
||||
int32_t VtxX[C4D_MaxVertex];
|
||||
int32_t VtxY[C4D_MaxVertex];
|
||||
int32_t VtxCNAT[C4D_MaxVertex];
|
||||
int32_t VtxFriction[C4D_MaxVertex];
|
||||
int32_t FireTop;
|
||||
int32_t VtxNum;
|
||||
int32_t VtxX[C4D_MaxVertex];
|
||||
int32_t VtxY[C4D_MaxVertex];
|
||||
int32_t VtxCNAT[C4D_MaxVertex];
|
||||
int32_t VtxFriction[C4D_MaxVertex];
|
||||
int32_t ContactDensity;
|
||||
int32_t ContactCNAT;
|
||||
int32_t ContactCount;
|
||||
int32_t AttachMat;
|
||||
int32_t VtxContactCNAT[C4D_MaxVertex];
|
||||
int32_t VtxContactMat[C4D_MaxVertex];
|
||||
int32_t VtxContactCNAT[C4D_MaxVertex];
|
||||
int32_t VtxContactMat[C4D_MaxVertex];
|
||||
int32_t iAttachX, iAttachY, iAttachVtx;
|
||||
public:
|
||||
public:
|
||||
void Default();
|
||||
void Clear();
|
||||
void Clear();
|
||||
void Rotate(int32_t iAngle, bool bUpdateVertices);
|
||||
void Stretch(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!
|
||||
void CreateOwnOriginalCopy(C4Shape &rFrom); // create copy of all vertex members in back area of own buffers
|
||||
void CompileFunc(StdCompiler *pComp, bool fRuntime);
|
||||
};
|
||||
};
|
||||
|
||||
#endif // INC_C4Shape
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -110,32 +110,32 @@ bool C4PlayerList::HostilityDeclared(int iPlayer1, int iPlayer2) const
|
|||
}
|
||||
|
||||
bool C4PlayerList::PositionTaken(int iPosition) const
|
||||
{
|
||||
{
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
if (pPlr->Position==iPosition)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (pPlr->Position==iPosition)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool C4PlayerList::ColorTaken(int iColor) const
|
||||
{
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
if (pPlr->Color==iColor)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
{
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
if (pPlr->Color==iColor)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int C4PlayerList::CheckColorDw(DWORD dwColor, C4Player *pExclude)
|
||||
{
|
||||
// maximum difference
|
||||
int iDiff=255+255+255;
|
||||
// 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
|
||||
DWORD dwClr2=pPlr->ColorDw;
|
||||
// assign difference, if less than smallest difference found
|
||||
iDiff=Min(iDiff,
|
||||
iDiff=Min(iDiff,
|
||||
Abs(GetRValue(dwColor) - GetRValue(dwClr2))
|
||||
+ Abs(GetGValue(dwColor) - GetGValue(dwClr2))
|
||||
+ Abs(GetBValue(dwColor) - GetBValue(dwClr2)));
|
||||
|
@ -146,7 +146,7 @@ int C4PlayerList::CheckColorDw(DWORD dwColor, C4Player *pExclude)
|
|||
|
||||
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)
|
||||
return pPlr;
|
||||
return NULL;
|
||||
|
@ -155,7 +155,7 @@ C4Player* C4PlayerList::Get(int iNumber) const
|
|||
int C4PlayerList::GetIndex(C4Player *tPlr) const
|
||||
{
|
||||
int cindex=0;
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next, cindex++)
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next, cindex++)
|
||||
if (pPlr==tPlr)
|
||||
return cindex;
|
||||
return -1;
|
||||
|
@ -163,7 +163,7 @@ int C4PlayerList::GetIndex(C4Player *tPlr) 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--)
|
||||
return pPlr;
|
||||
return NULL;
|
||||
|
@ -171,7 +171,7 @@ C4Player* C4PlayerList::GetByIndex(int iIndex) 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 (!iIndex--)
|
||||
return pPlr;
|
||||
|
@ -180,7 +180,7 @@ C4Player* C4PlayerList::GetByIndex(int iIndex, C4PlayerType eType) 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;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ C4Player *C4PlayerList::GetByInfoID(int iInfoID) const
|
|||
int C4PlayerList::GetCount() const
|
||||
{
|
||||
int iCount = 0;
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
iCount++;
|
||||
return iCount;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ int C4PlayerList::GetCount() const
|
|||
int C4PlayerList::GetCount(C4PlayerType eType) const
|
||||
{
|
||||
int iCount = 0;
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
if (pPlr->GetType() == eType)
|
||||
iCount++;
|
||||
return iCount;
|
||||
|
@ -249,11 +249,11 @@ bool C4PlayerList::Remove(C4Player *pPlr, bool fDisconnect, bool fNoCalls)
|
|||
{
|
||||
C4PlayerInfo *pInfo = Game.PlayerInfos.GetPlayerInfoByID(pPlr->ID);
|
||||
if (pInfo)
|
||||
{
|
||||
pInfo->SetRemoved();
|
||||
if(fDisconnect)
|
||||
pInfo->SetDisconnected();
|
||||
}
|
||||
{
|
||||
pInfo->SetRemoved();
|
||||
if(fDisconnect)
|
||||
pInfo->SetDisconnected();
|
||||
}
|
||||
// if player wasn't evaluated, store round results anyway
|
||||
if (!pPlr->Evaluated) Game.RoundResults.EvaluatePlayer(pPlr);
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ int C4PlayerList::AverageValueGain() 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 (pPlr->Number!=iExcluding)
|
||||
return pPlr;
|
||||
|
@ -485,7 +485,7 @@ bool C4PlayerList::FileInUse(const char *szFilename) const
|
|||
C4Player* C4PlayerList::GetLocalByIndex(int iIndex) const
|
||||
{
|
||||
int cindex=0;
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
if (pPlr->LocalControl)
|
||||
{
|
||||
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
|
||||
{
|
||||
int cindex=0;
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
if (pPlr->AtClient == iClient)
|
||||
{
|
||||
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
|
||||
{
|
||||
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 (cindex==iIndex) return pPlr;
|
||||
|
@ -590,7 +590,7 @@ bool C4PlayerList::RemoveAtRemoteClient(bool fDisconnect, bool fNoCalls)
|
|||
C4Player* C4PlayerList::GetAtRemoteClient(int iIndex) const
|
||||
{
|
||||
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 (cindex==iIndex) return pPlr;
|
||||
|
@ -620,29 +620,29 @@ bool C4PlayerList::RemoveLocal(bool fDisconnect, bool fNoCalls)
|
|||
|
||||
void C4PlayerList::EnumeratePointers()
|
||||
{
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
pPlr->EnumeratePointers();
|
||||
}
|
||||
|
||||
void C4PlayerList::DenumeratePointers()
|
||||
{
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
pPlr->DenumeratePointers();
|
||||
}
|
||||
|
||||
bool C4PlayerList::MouseControlTaken() const
|
||||
{
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
if (pPlr->MouseControl)
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
if (pPlr->MouseControl)
|
||||
if (pPlr->LocalControl)
|
||||
return true;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
int C4PlayerList::GetCountNotEliminated() const
|
||||
{
|
||||
int iCount = 0;
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next)
|
||||
if (!pPlr->Eliminated)
|
||||
iCount++;
|
||||
return iCount;
|
||||
|
@ -654,7 +654,7 @@ bool C4PlayerList::SynchronizeLocalFiles()
|
|||
Log(LoadResStr("IDS_PRC_SYNCPLRS"));
|
||||
bool fSuccess = true;
|
||||
// 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
|
||||
if (!pPlr->Eliminated)
|
||||
if (!pPlr->LocalSync()) fSuccess = false;
|
||||
|
|
|
@ -33,14 +33,14 @@
|
|||
#include <StdRegistry.h>
|
||||
|
||||
C4RankSystem::C4RankSystem()
|
||||
{
|
||||
{
|
||||
Default();
|
||||
}
|
||||
}
|
||||
|
||||
int C4RankSystem::Init(const char *szRegister,
|
||||
const char *szDefRanks,
|
||||
int iRankBase)
|
||||
{
|
||||
{
|
||||
|
||||
// Init
|
||||
SCopy(szRegister,Register,256);
|
||||
|
@ -94,7 +94,7 @@ int C4RankSystem::Init(const char *szRegister,
|
|||
}
|
||||
return iRankNum;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (iRank<0) return StdStrBuf();
|
||||
{
|
||||
if (iRank<0) return StdStrBuf();
|
||||
// if a new-style ranklist is loaded, seek there
|
||||
if (pszRankNames)
|
||||
{
|
||||
|
@ -227,14 +227,14 @@ StdStrBuf C4RankSystem::GetRankName(int iRank, bool fReturnLastIfOver)
|
|||
--iRank;
|
||||
}
|
||||
#endif
|
||||
return StdStrBuf();
|
||||
return StdStrBuf();
|
||||
}
|
||||
|
||||
int C4RankSystem::Experience(int iRank)
|
||||
{
|
||||
if (iRank<0) return 0;
|
||||
return (int) ( pow (double(iRank), 1.5) * RankBase );
|
||||
}
|
||||
{
|
||||
if (iRank<0) return 0;
|
||||
return (int) ( pow (double(iRank), 1.5) * RankBase );
|
||||
}
|
||||
|
||||
int C4RankSystem::RankByExperience(int iExp)
|
||||
{
|
||||
|
|
|
@ -29,14 +29,14 @@ class C4Facet;
|
|||
class C4FacetSurface;
|
||||
|
||||
class C4RankSystem
|
||||
{
|
||||
public:
|
||||
C4RankSystem();
|
||||
{
|
||||
public:
|
||||
C4RankSystem();
|
||||
~C4RankSystem() { Clear(); }
|
||||
|
||||
enum { EXP_NoPromotion = -1 }; // experience value for NextRankExp: No more promotion possible
|
||||
|
||||
protected:
|
||||
protected:
|
||||
char Register[256+1];
|
||||
char RankName[C4MaxName+1];
|
||||
int RankBase;
|
||||
|
@ -45,20 +45,20 @@ class C4RankSystem
|
|||
int iRankNum; // number of ranks for loaded rank-names
|
||||
char **pszRankExtensions; // rank extensions (e.g. "%s First class") for even more ranks!
|
||||
int iRankExtNum; // number of rank extensions
|
||||
public:
|
||||
public:
|
||||
void Default();
|
||||
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
|
||||
int Experience(int iRank);
|
||||
int Experience(int iRank);
|
||||
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);
|
||||
int32_t GetExtendedRankNum() const { return iRankExtNum; }
|
||||
int32_t GetBaseRankNum() const { return iRankNum; }
|
||||
//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
|
||||
};
|
||||
};
|
||||
|
||||
extern C4RankSystem DefaultRanks;
|
||||
|
||||
|
|
|
@ -568,16 +568,16 @@ int32_t FnFxFireStart(C4AulContext *ctx, C4Object *pObj, int32_t iNumber, int32_
|
|||
// In extinguishing material
|
||||
bool fFireCaused=true;
|
||||
int32_t iMat;
|
||||
if (MatValid(iMat=GBackMat(pObj->GetX(),pObj->GetY())))
|
||||
if (::MaterialMap.Map[iMat].Extinguisher)
|
||||
if (MatValid(iMat=GBackMat(pObj->GetX(),pObj->GetY())))
|
||||
if (::MaterialMap.Map[iMat].Extinguisher)
|
||||
{
|
||||
// blasts should changedef in water, too!
|
||||
if (fBlasted) if (pObj->Def->BurnTurnTo!=C4ID::None) pObj->ChangeDef(pObj->Def->BurnTurnTo);
|
||||
// no fire caused
|
||||
fFireCaused = false;
|
||||
}
|
||||
// BurnTurnTo
|
||||
if (fFireCaused) if (pObj->Def->BurnTurnTo!=C4ID::None) pObj->ChangeDef(pObj->Def->BurnTurnTo);
|
||||
// BurnTurnTo
|
||||
if (fFireCaused) if (pObj->Def->BurnTurnTo!=C4ID::None) pObj->ChangeDef(pObj->Def->BurnTurnTo);
|
||||
// eject contents
|
||||
C4Object *cobj;
|
||||
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
|
||||
iFireMode = C4Fx_FireMode_LivingVeg;
|
||||
else if (dwCat & (C4D_Structure | C4D_Vehicle)) // Gebäude und Fahrzeuge sind unten meist kantig
|
||||
iFireMode = C4Fx_FireMode_StructVeh;
|
||||
else
|
||||
iFireMode = C4Fx_FireMode_StructVeh;
|
||||
else
|
||||
iFireMode = C4Fx_FireMode_Object;
|
||||
}
|
||||
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
|
||||
pObj->Call(PSF_Incineration,&C4AulParSet(C4VInt(iCausedBy)));
|
||||
// Done, success
|
||||
return C4Fx_OK;
|
||||
return C4Fx_OK;
|
||||
}
|
||||
|
||||
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 (%)
|
||||
iCon=iWdtCon=Max<int32_t>((100*pObj->GetCon())/FullCon, 1);
|
||||
if(!pObj->Def->GrowthType)
|
||||
if(!pObj->Def->GrowthType)
|
||||
// fixed width for not-stretched-objects
|
||||
if(iWdtCon<100) iWdtCon=100;
|
||||
if(iWdtCon<100) iWdtCon=100;
|
||||
|
||||
// regard non-center object offsets
|
||||
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
|
||||
iCount = Max(2, iCount*iWdtCon/100);
|
||||
iCount = Max(2, iCount*iWdtCon/100);
|
||||
|
||||
// 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)
|
||||
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 -------------------------------------------------------------
|
||||
|
||||
void Splash(int32_t tx, int32_t ty, int32_t amt, C4Object *pByObj)
|
||||
{
|
||||
{
|
||||
// Splash only if there is free space above
|
||||
if (GBackSemiSolid(tx, ty - 15)) return;
|
||||
// get back mat
|
||||
|
@ -812,12 +812,12 @@ void Splash(int32_t tx, int32_t ty, int32_t amt, C4Object *pByObj)
|
|||
FIXED100(-Random(200)));
|
||||
}
|
||||
}
|
||||
// Splash sound
|
||||
if (amt>=20)
|
||||
// Splash sound
|
||||
if (amt>=20)
|
||||
StartSoundEffect("Splash2",false,100,pByObj);
|
||||
else
|
||||
else
|
||||
if (amt>1) StartSoundEffect("Splash1",false,100,pByObj);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t GetSmokeLevel()
|
||||
{
|
||||
|
@ -826,7 +826,7 @@ int32_t GetSmokeLevel()
|
|||
}
|
||||
|
||||
void BubbleOut(int32_t tx, int32_t ty)
|
||||
{
|
||||
{
|
||||
// No bubbles from nowhere
|
||||
if (!GBackSemiSolid(tx,ty)) return;
|
||||
// User-defined smoke level
|
||||
|
@ -835,10 +835,10 @@ void BubbleOut(int32_t tx, int32_t ty)
|
|||
if (::Objects.ObjectCount(C4ID("FXU1")) >= SmokeLevel) return;
|
||||
// Create bubble
|
||||
Game.CreateObject(C4ID("FXU1"),NULL,NO_OWNER,tx,ty);
|
||||
}
|
||||
}
|
||||
|
||||
void Smoke(int32_t tx, int32_t ty, int32_t level, DWORD dwClr)
|
||||
{
|
||||
{
|
||||
if (::Particles.pSmoke)
|
||||
{
|
||||
::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;
|
||||
if ((pObj = Game.CreateObjectConstruction(C4Id2Def(C4ID("FXS1")),NULL,NO_OWNER,tx,ty,FullCon*level/32)))
|
||||
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)
|
||||
{
|
||||
int32_t grade=BoundBy((level/10)-1,1,3);
|
||||
// Sound
|
||||
StdStrBuf sound = FormatString("Blast%c", '0'+grade);
|
||||
StartSoundEffect(sound.getData(),false,100,pByObj);
|
||||
{
|
||||
int32_t grade=BoundBy((level/10)-1,1,3);
|
||||
// Sound
|
||||
StdStrBuf sound = FormatString("Blast%c", '0'+grade);
|
||||
StartSoundEffect(sound.getData(),false,100,pByObj);
|
||||
// Check blast containment
|
||||
C4Object *container=inobj;
|
||||
while (container && !container->Def->ContainBlast) container=container->Contained;
|
||||
// Uncontained blast effects
|
||||
if (!container)
|
||||
{
|
||||
C4Object *container=inobj;
|
||||
while (container && !container->Def->ContainBlast) container=container->Contained;
|
||||
// Uncontained blast effects
|
||||
if (!container)
|
||||
{
|
||||
// Incinerate landscape
|
||||
if (!::Landscape.Incinerate(tx,ty))
|
||||
if (!::Landscape.Incinerate(tx,ty))
|
||||
if (!::Landscape.Incinerate(tx,ty-10))
|
||||
if (!::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
|
||||
if ((pBlast = Game.CreateObjectConstruction(C4Id2Def(idEffect ? idEffect : C4ID("FXB1")),pByObj,iCausedBy,tx,ty+level,FullCon*level/20)))
|
||||
pBlast->Call(PSF_Activate);
|
||||
}
|
||||
// Blast objects
|
||||
Game.BlastObjects(tx,ty,level,inobj,iCausedBy,pByObj);
|
||||
if (container!=inobj) Game.BlastObjects(tx,ty,level,container,iCausedBy,pByObj);
|
||||
}
|
||||
// Blast objects
|
||||
Game.BlastObjects(tx,ty,level,inobj,iCausedBy,pByObj);
|
||||
if (container!=inobj) Game.BlastObjects(tx,ty,level,container,iCausedBy,pByObj);
|
||||
if (!container)
|
||||
{
|
||||
// Blast free landscape. After blasting objects so newly mined materials don't get flinged
|
||||
::Landscape.BlastFree(tx,ty,level,grade, iCausedBy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -52,15 +52,15 @@ struct C4ScriptConstDef
|
|||
// * the second (C4V2) takes an array of 10 parameters
|
||||
// only one may be set.
|
||||
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;
|
||||
C4V_Type RetType; // type returned. ignored when C4V
|
||||
C4V_Type ParType[10];// type of the parameters. error when wrong parameter type.
|
||||
C4Value (*FunctionC4V)(C4AulContext *cthr, C4Value*, C4Value*, C4Value*, C4Value*, C4Value*,
|
||||
C4Value*, C4Value*, C4Value*, C4Value*, C4Value*);
|
||||
C4Value (*FunctionC4V2)(struct C4AulContext *, C4Value *);
|
||||
};
|
||||
};
|
||||
|
||||
extern C4ScriptConstDef C4ScriptConstMap[];
|
||||
extern C4ScriptFnDef C4ScriptFnMap[];
|
||||
|
|
|
@ -388,13 +388,13 @@ C4ChatControl::C4ChatControl(C4Network2IRCClient *pnIRCClient) : C4GUI::Window()
|
|||
pEdtLoginChannel->SetText(Config.IRC.Channel, false);
|
||||
// initial sheets
|
||||
ClearChatSheets();
|
||||
// set IRC event callback
|
||||
Application.InteractiveThread.SetCallback(Ev_IRC_Message, this);
|
||||
// set IRC event callback
|
||||
Application.InteractiveThread.SetCallback(Ev_IRC_Message, this);
|
||||
}
|
||||
|
||||
C4ChatControl::~C4ChatControl()
|
||||
{
|
||||
Application.InteractiveThread.ClearCallback(Ev_IRC_Message, this);
|
||||
Application.InteractiveThread.ClearCallback(Ev_IRC_Message, this);
|
||||
delete pTitleChangeBC;
|
||||
}
|
||||
|
||||
|
@ -540,16 +540,16 @@ void C4ChatControl::OnConnectBtn(C4GUI::Control *btn)
|
|||
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))
|
||||
return;
|
||||
// set up IRC callback
|
||||
pIRCClient->SetNotify(&Application.InteractiveThread);
|
||||
// set up IRC callback
|
||||
pIRCClient->SetNotify(&Application.InteractiveThread);
|
||||
// initiate connection
|
||||
if (!pIRCClient->Connect(sServer.getData(), sNick.getData(), sRealName.getData(), sPass.getData(), sChannel.getData()))
|
||||
{
|
||||
GetScreen()->ShowErrorMessage(FormatString(LoadResStr("IDS_ERR_IRCCONNECTIONFAILED"), pIRCClient->GetError()).getData());
|
||||
return;
|
||||
}
|
||||
// enable client execution
|
||||
Application.InteractiveThread.AddProc(pIRCClient);
|
||||
// enable client execution
|
||||
Application.InteractiveThread.AddProc(pIRCClient);
|
||||
// reset chat sheets (close queries, etc.)
|
||||
ClearChatSheets();
|
||||
// connection message
|
||||
|
@ -619,8 +619,8 @@ void C4ChatControl::Update()
|
|||
--i;
|
||||
}
|
||||
}
|
||||
// retrieve messages: All messages in initial update; only unread in subsequent calls
|
||||
C4Network2IRCMessage *pMsg;
|
||||
// retrieve messages: All messages in initial update; only unread in subsequent calls
|
||||
C4Network2IRCMessage *pMsg;
|
||||
if (fInitialMessagesReceived)
|
||||
{
|
||||
pMsg = pIRCClient->getUnreadMessageLog();
|
||||
|
@ -668,7 +668,7 @@ void C4ChatControl::Update()
|
|||
pChatSheet = GetServerSheet();
|
||||
}
|
||||
else if (sUser == pIRCClient->getUserName())
|
||||
{
|
||||
{
|
||||
// private message by myself
|
||||
// message to a service into service window; otherwise (new) query
|
||||
if (IsServiceName(pMsg->getTarget()))
|
||||
|
@ -681,8 +681,8 @@ void C4ChatControl::Update()
|
|||
pChatSheet = OpenQuery(pMsg->getTarget(), true, NULL);
|
||||
if (pChatSheet) pChatSheet->SetChatTitle(pMsg->getTarget());
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
// private message
|
||||
pChatSheet = OpenQuery(sUser.getData(), false, sIdent.getData());
|
||||
|
@ -706,9 +706,9 @@ void C4ChatControl::Update()
|
|||
|
||||
case MSG_Notice:
|
||||
if (sUser.getLength())
|
||||
if (sUser != pIRCClient->getUserName())
|
||||
if (sUser != pIRCClient->getUserName())
|
||||
sMsg.Format("-%s- %s", sUser.getData(), pMsg->getData());
|
||||
else
|
||||
else
|
||||
sMsg.Format("-> -%s- %s", pMsg->getTarget(), pMsg->getData());
|
||||
else
|
||||
sMsg.Format("* %s", pMsg->getData());
|
||||
|
@ -905,8 +905,8 @@ bool C4ChatControl::ProcessInput(const char *szInput, ChatSheet *pChatSheet)
|
|||
{
|
||||
if (C4InVal::ValidateString(sParam, C4InVal::VAL_IRCName))
|
||||
pChatSheet->DoError(FormatString(LoadResStr("IDS_ERR_INVALIDNICKNAME2"), sCommand.getData()).getData());
|
||||
else
|
||||
fIRCSuccess = pIRCClient->ChangeNick(sParam.getData());
|
||||
else
|
||||
fIRCSuccess = pIRCClient->ChangeNick(sParam.getData());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -926,9 +926,9 @@ bool C4ChatControl::ProcessInput(const char *szInput, ChatSheet *pChatSheet)
|
|||
else
|
||||
{
|
||||
szMsgTarget = pChatSheet->GetTitle();
|
||||
if (*szInput == '/') // action
|
||||
if (*szInput == '/') // action
|
||||
fIRCSuccess = pIRCClient->Action(szMsgTarget, szInput+4);
|
||||
else
|
||||
else
|
||||
fIRCSuccess = pIRCClient->Message(szMsgTarget, szInput);
|
||||
}
|
||||
}
|
||||
|
@ -1016,7 +1016,7 @@ bool C4ChatDlg::IsChatActive()
|
|||
// not if chat is disabled
|
||||
if (!IsChatEnabled()) return false;
|
||||
// check whether IRC is connected
|
||||
return Application.IRCClient.IsActive();
|
||||
return Application.IRCClient.IsActive();
|
||||
}
|
||||
|
||||
bool C4ChatDlg::IsChatEnabled()
|
||||
|
|
|
@ -117,7 +117,7 @@ class C4ChatControl : public C4GUI::Window, private C4InteractiveThread::Callbac
|
|||
StdStrBuf sTitle;
|
||||
C4GUI::BaseInputCallback *pTitleChangeBC;
|
||||
|
||||
C4Network2IRCClient *pIRCClient;
|
||||
C4Network2IRCClient *pIRCClient;
|
||||
bool fInitialMessagesReceived; // set after initial update call, which fetches all messages. Subsequent calls fetch only unread messages
|
||||
|
||||
public:
|
||||
|
@ -131,7 +131,7 @@ class C4ChatControl : public C4GUI::Window, private C4InteractiveThread::Callbac
|
|||
|
||||
public:
|
||||
virtual class C4GUI::Control *GetDefaultControl();
|
||||
C4Network2IRCClient *getIRCClient() { return pIRCClient; }
|
||||
C4Network2IRCClient *getIRCClient() { return pIRCClient; }
|
||||
|
||||
void SetTitleChangeCB(C4GUI::BaseInputCallback *pNewCB);
|
||||
virtual void OnShown(); // callback when shown
|
||||
|
@ -153,8 +153,8 @@ class C4ChatControl : public C4GUI::Window, private C4InteractiveThread::Callbac
|
|||
ChatSheet *GetServerSheet();
|
||||
void ClearChatSheets();
|
||||
|
||||
// IRC event hook
|
||||
virtual void OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData) { if(pEventData == pIRCClient) Update(); }
|
||||
// IRC event hook
|
||||
virtual void OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData) { if(pEventData == pIRCClient) Update(); }
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ void C4DownloadDlg::SetStatus(const char *szNewText, int32_t iProgressPercent)
|
|||
}
|
||||
|
||||
void C4DownloadDlg::OnIdle()
|
||||
{
|
||||
{
|
||||
// continue query process
|
||||
if (!HTTPClient.Execute())
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ void C4DownloadDlg::OnIdle()
|
|||
}
|
||||
|
||||
void C4DownloadDlg::UserClose(bool fOK)
|
||||
{
|
||||
{
|
||||
// user cancelled
|
||||
HTTPClient.Cancel(LoadResStr("IDS_ERR_USERCANCEL"));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
// dialog to download a file
|
||||
class C4DownloadDlg : public C4GUI::Dialog
|
||||
{
|
||||
{
|
||||
private:
|
||||
C4Network2HTTPClient HTTPClient;
|
||||
|
||||
|
|
|
@ -30,31 +30,31 @@
|
|||
//================= C4FolderHead ====================
|
||||
|
||||
void C4FolderHead::Default()
|
||||
{
|
||||
{
|
||||
Index = 0;
|
||||
Sort[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void C4FolderHead::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(Index, "Index", 0));
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Sort), "Sort", ""));
|
||||
}
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(Index, "Index", 0));
|
||||
pComp->Value(mkNamingAdapt(mkStringAdaptMA(Sort), "Sort", ""));
|
||||
}
|
||||
|
||||
//=================== C4Folder ======================
|
||||
|
||||
C4Folder::C4Folder()
|
||||
{
|
||||
Default();
|
||||
}
|
||||
{
|
||||
Default();
|
||||
}
|
||||
|
||||
void C4Folder::Default()
|
||||
{
|
||||
{
|
||||
Head.Default();
|
||||
}
|
||||
}
|
||||
|
||||
bool C4Folder::Load(C4Group &hGroup)
|
||||
{
|
||||
{
|
||||
char *pSource;
|
||||
// Load
|
||||
if (!hGroup.LoadEntry(C4CFN_FolderCore, &pSource, NULL, 1)) return false;
|
||||
|
@ -63,7 +63,7 @@ bool C4Folder::Load(C4Group &hGroup)
|
|||
delete [] pSource;
|
||||
// Success
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*bool C4Folder::Save(C4Group &hGroup)
|
||||
{
|
||||
|
@ -76,13 +76,13 @@ bool C4Folder::Load(C4Group &hGroup)
|
|||
}*/
|
||||
|
||||
void C4Folder::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(Head, "Head"));
|
||||
}
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(Head, "Head"));
|
||||
}
|
||||
|
||||
bool C4Folder::Compile(const char *szSource)
|
||||
{
|
||||
Default();
|
||||
return CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, StdStrBuf(szSource), C4CFN_FolderCore);
|
||||
return CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, StdStrBuf(szSource), C4CFN_FolderCore);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,30 +27,30 @@ class C4Group;
|
|||
const int C4MaxFolderSort = 4096;
|
||||
|
||||
class C4FolderHead
|
||||
{
|
||||
public:
|
||||
{
|
||||
public:
|
||||
int32_t Index; // Folder index in scenario selection dialog
|
||||
char Sort[C4MaxFolderSort + 1]; // Folder-defined group sort list (to be used for folder maps)
|
||||
public:
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
char Sort[C4MaxFolderSort + 1]; // Folder-defined group sort list (to be used for folder maps)
|
||||
public:
|
||||
void Default();
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
};
|
||||
|
||||
class C4Folder
|
||||
{
|
||||
public:
|
||||
{
|
||||
public:
|
||||
C4Folder();
|
||||
public:
|
||||
C4FolderHead Head;
|
||||
public:
|
||||
void Default();
|
||||
public:
|
||||
void Default();
|
||||
//void Clear();
|
||||
bool Load(C4Group &hGroup);
|
||||
bool Load(C4Group &hGroup);
|
||||
//bool Save(C4Group &hGroup);
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
protected:
|
||||
bool Compile(const char *szSource);
|
||||
//bool Decompile(char **ppOutput, int32_t *ipSize);
|
||||
};
|
||||
};
|
||||
|
||||
#endif // INC_C4Folder
|
||||
|
|
|
@ -41,7 +41,7 @@ C4AbortGameDialog::C4AbortGameDialog()
|
|||
MessageDialog::btnYesNo,
|
||||
true,
|
||||
C4GUI::Ico_Exit),
|
||||
fGameHalted(false)
|
||||
fGameHalted(false)
|
||||
{
|
||||
is_shown = true; // assume dlg will be shown, soon
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace C4GameLobby {
|
|||
|
||||
void C4PacketCountdown::CompileFunc(StdCompiler *pComp)
|
||||
{
|
||||
pComp->Value(mkNamingAdapt(iCountdown, "Countdown", 0));
|
||||
pComp->Value(mkNamingAdapt(iCountdown, "Countdown", 0));
|
||||
}
|
||||
|
||||
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);
|
||||
//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));
|
||||
pDescBox->SetDecoration(false, false, NULL, true);
|
||||
pDescBox->SetDecoration(false, false, NULL, true);
|
||||
//pDescBox->SetToolTip(LoadResStr("IDS_MSG_SCENARIODESC")); annoying when scrolling through desc...
|
||||
// initial update to set current data
|
||||
if (fActive) Activate();
|
||||
|
@ -109,7 +109,7 @@ void ScenDesc::Update()
|
|||
else
|
||||
{
|
||||
pDescBox->AddTextLine(FormatString(LoadResStr("IDS_MSG_SCENARIODESC_LOADING"), (int) pRes->getPresentPercent()).getData(),
|
||||
&rTextFont, C4GUI_MessageFontClr, false, true);
|
||||
&rTextFont, C4GUI_MessageFontClr, false, true);
|
||||
}
|
||||
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,
|
||||
new C4GUI::CBMenuHandler<MainDlg>(this, &MainDlg::OnCtxTabPlayers));
|
||||
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,
|
||||
new C4GUI::CBMenuHandler<MainDlg>(this, &MainDlg::OnCtxTabTeams));
|
||||
}
|
||||
}
|
||||
pMenu->AddItem(pResSheet->GetTitle(), pResSheet->GetToolTip(), C4GUI::Ico_Resource,
|
||||
new C4GUI::CBMenuHandler<MainDlg>(this, &MainDlg::OnCtxTabRes));
|
||||
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
Loading…
Reference in New Issue