Clean up redundant copy&paste code. Patch by Gerard Krol with
some stylistic and extra changes by me. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1158 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
d434901a21
commit
daaac4b5e3
|
@ -55,8 +55,6 @@ extern SDWORD aSinTable[];
|
|||
|
||||
//*************************************************************************
|
||||
|
||||
#define pie_SETUP_ROTATE_PROJECT
|
||||
|
||||
#define pie_ROTATE_PROJECT(x, y, z, sx, sy) pie_RotateProject(x, y, z, &(sx), &(sy))
|
||||
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ static BOOL eventSaveContext(char *pBuffer, UDWORD *pSize)
|
|||
}
|
||||
|
||||
// load the context information for the script system
|
||||
static BOOL eventLoadContext(SDWORD version, char *pBuffer, UDWORD *pSize)
|
||||
static BOOL eventLoadContext(SDWORD version, char *pBuffer, UDWORD *pSize, BOOL bHashed)
|
||||
{
|
||||
UDWORD size, valSize;
|
||||
SDWORD numVars, i, numContext, context;
|
||||
|
@ -202,6 +202,7 @@ static BOOL eventLoadContext(SDWORD version, char *pBuffer, UDWORD *pSize)
|
|||
SCR_VAL_LOAD loadFunc;
|
||||
char *pPos;
|
||||
char *pScriptID;
|
||||
UDWORD hashedName;
|
||||
SCRIPT_CODE *psCode;
|
||||
CONTEXT_RELEASE release;
|
||||
INTERP_VAL *psVal, data;
|
||||
|
@ -218,16 +219,21 @@ static BOOL eventLoadContext(SDWORD version, char *pBuffer, UDWORD *pSize)
|
|||
// go through the contexts
|
||||
for(context=0; context < numContext; context += 1)
|
||||
{
|
||||
// get the script code
|
||||
pScriptID = (char *)pPos;
|
||||
psCode = (SCRIPT_CODE*)resGetData("SCRIPT", pScriptID);
|
||||
pPos += strlen(pScriptID) + 1;
|
||||
|
||||
if(bHashed) {
|
||||
endian_udword((UDWORD*)pPos);
|
||||
hashedName = *((UDWORD*)pPos);
|
||||
psCode = (SCRIPT_CODE*)resGetDataFromHash("SCRIPT", hashedName);
|
||||
pPos += sizeof(UDWORD);
|
||||
} else {
|
||||
// get the script code
|
||||
pScriptID = (char *)pPos;
|
||||
psCode = (SCRIPT_CODE*)resGetData("SCRIPT", pScriptID);
|
||||
pPos += strlen(pScriptID) + 1;
|
||||
}
|
||||
// check the number of variables
|
||||
numVars = psCode->numGlobals + psCode->arraySize;
|
||||
|
||||
endian_sword((SWORD*)pPos);
|
||||
|
||||
numVars = psCode->numGlobals + psCode->arraySize;
|
||||
|
||||
if (numVars != *((SWORD*)pPos))
|
||||
{
|
||||
debug( LOG_ERROR, "eventLoadContext: number of context variables does not match the script code" );
|
||||
|
@ -248,7 +254,11 @@ static BOOL eventLoadContext(SDWORD version, char *pBuffer, UDWORD *pSize)
|
|||
// bit of a hack this - note the id of the context to link it to the triggers
|
||||
psContList->id = (SWORD)context;
|
||||
|
||||
size += strlen(pScriptID) + 1 + sizeof(SWORD) + sizeof(UBYTE);
|
||||
if(bHashed) {
|
||||
size += sizeof(UDWORD) + sizeof(SWORD) + sizeof(UBYTE);
|
||||
} else {
|
||||
size += strlen(pScriptID) + 1 + sizeof(SWORD) + sizeof(UBYTE);
|
||||
}
|
||||
|
||||
// set the context variables
|
||||
for(i=0; i < numVars; i+= 1)
|
||||
|
@ -358,178 +368,6 @@ static BOOL eventLoadContext(SDWORD version, char *pBuffer, UDWORD *pSize)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
// load the context information for the script system
|
||||
static BOOL eventLoadContextHashed(SDWORD version, char *pBuffer, UDWORD *pSize)
|
||||
{
|
||||
UDWORD size, valSize;
|
||||
SDWORD numVars, i, numContext, context;
|
||||
SWORD savedNumVars;
|
||||
SCRIPT_CONTEXT *psCCont;
|
||||
INTERP_TYPE type;
|
||||
SCR_VAL_LOAD loadFunc;
|
||||
char *pPos;
|
||||
//not hashed char *pScriptID;
|
||||
UDWORD hashedName;
|
||||
SCRIPT_CODE *psCode;
|
||||
CONTEXT_RELEASE release;
|
||||
INTERP_VAL *psVal, data;
|
||||
|
||||
size = 0;
|
||||
pPos = pBuffer;
|
||||
|
||||
// get the number of contexts in the save file
|
||||
endian_sword((SWORD *)pPos);
|
||||
numContext = *((SWORD *)pPos);
|
||||
pPos += sizeof(SWORD);
|
||||
size += sizeof(SWORD);
|
||||
|
||||
// go through the contexts
|
||||
for(context=0; context < numContext; context += 1)
|
||||
{
|
||||
// get the script code
|
||||
//notHashed pScriptID = (char *)pPos;
|
||||
//notHashed psCode = resGetData("SCRIPT", pScriptID);
|
||||
//notHashed pPos += strlen(pScriptID) + 1;
|
||||
endian_udword((UDWORD*)pPos);
|
||||
hashedName = *((UDWORD*)pPos);
|
||||
pPos += sizeof(UDWORD);
|
||||
psCode = (SCRIPT_CODE*)resGetDataFromHash("SCRIPT", hashedName);
|
||||
|
||||
|
||||
// check the number of variables
|
||||
numVars = psCode->numGlobals + psCode->arraySize;
|
||||
endian_sword((SWORD*)pPos);
|
||||
savedNumVars = *((SWORD*)pPos);
|
||||
if (numVars != savedNumVars)
|
||||
{
|
||||
debug( LOG_ERROR, "eventLoadContext: number of context variables does not match the script code" );
|
||||
abort();
|
||||
return FALSE;
|
||||
}
|
||||
pPos += sizeof(SWORD);
|
||||
|
||||
release = (CONTEXT_RELEASE)*pPos;
|
||||
pPos += sizeof(UBYTE);
|
||||
|
||||
// create the context
|
||||
if (!eventNewContext(psCode, release, &psCCont))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// bit of a hack this - note the id of the context to link it to the triggers
|
||||
psContList->id = (SWORD)context;
|
||||
|
||||
size += sizeof(UDWORD) + sizeof(SWORD) + sizeof(UBYTE);
|
||||
|
||||
// set the context variables
|
||||
for(i=0; i < numVars; i+= 1)
|
||||
{
|
||||
// get the variable type
|
||||
endian_sword((SWORD*)pPos);
|
||||
type = (INTERP_TYPE) *((SWORD*)pPos);
|
||||
pPos += sizeof(SWORD);
|
||||
size += sizeof(SWORD);
|
||||
|
||||
// get the variable value
|
||||
if (type < VAL_USERTYPESTART)
|
||||
{
|
||||
data.type = type;
|
||||
|
||||
endian_udword((UDWORD*)pPos);
|
||||
|
||||
switch (type) {
|
||||
case VAL_BOOL:
|
||||
data.v.bval = *((BOOL*)pPos);
|
||||
pPos += sizeof(BOOL);
|
||||
size += sizeof(BOOL);
|
||||
break;
|
||||
case VAL_FLOAT:
|
||||
data.v.fval = *((float*)pPos);
|
||||
pPos += sizeof(float);
|
||||
size += sizeof(float);
|
||||
break;
|
||||
case VAL_INT:
|
||||
case VAL_TRIGGER:
|
||||
case VAL_EVENT:
|
||||
case VAL_VOID:
|
||||
case VAL_OPCODE:
|
||||
case VAL_PKOPCODE:
|
||||
data.v.ival = *((UDWORD *)pPos);
|
||||
pPos += sizeof(UDWORD);
|
||||
size += sizeof(UDWORD);
|
||||
break;
|
||||
case VAL_STRING:
|
||||
/* FIXME: this would never work! */
|
||||
data.v.sval = pPos;
|
||||
pPos += sizeof(char*);
|
||||
size += sizeof(char*);
|
||||
break;
|
||||
case VAL_OBJ_GETSET:
|
||||
/* FIXME: saving pointer on disk! */
|
||||
data.v.pObjGetSet = *((SCRIPT_VARFUNC*)pPos);
|
||||
pPos += sizeof(SCRIPT_VARFUNC);
|
||||
size += sizeof(SCRIPT_VARFUNC);
|
||||
break;
|
||||
case VAL_FUNC_EXTERN:
|
||||
/* TODO: saving pointer on disk! */
|
||||
data.v.pFuncExtern = *((SCRIPT_FUNC*)pPos);
|
||||
pPos += sizeof(SCRIPT_FUNC);
|
||||
size += sizeof(SCRIPT_FUNC);
|
||||
break;
|
||||
default:
|
||||
ASSERT( FALSE, "eventLoadContext: invalid internal type" );
|
||||
}
|
||||
|
||||
// set the value in the context
|
||||
if (!eventSetContextVar(psCCont, (UDWORD)i, &data))
|
||||
{
|
||||
debug( LOG_ERROR, "eventLoadContext: couldn't set variable value" );
|
||||
abort();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// user defined type
|
||||
loadFunc = asScrTypeTab[type - VAL_USERTYPESTART].loadFunc;
|
||||
|
||||
ASSERT( loadFunc != NULL,
|
||||
"eventLoadContext: no load function for type %d\n", type );
|
||||
|
||||
endian_uword((UWORD*)pPos);
|
||||
valSize = *((UWORD *)pPos);
|
||||
|
||||
pPos += sizeof(UWORD);
|
||||
size += sizeof(UWORD);
|
||||
|
||||
// get the value pointer so that the loadFunc can write directly
|
||||
// into the variables data space.
|
||||
if (!eventGetContextVal(psCCont, (UDWORD)i, &psVal))
|
||||
{
|
||||
debug( LOG_ERROR, "eventLoadContext: couldn't find variable in context" );
|
||||
abort();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!loadFunc(version, psVal, pPos, valSize))
|
||||
{
|
||||
debug( LOG_ERROR, "eventLoadContext: couldn't get variable value" );
|
||||
abort();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pPos += valSize;
|
||||
size += valSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*pSize = size;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// return the index of a context
|
||||
static BOOL eventGetContextIndex(SCRIPT_CONTEXT *psContext, SDWORD *pIndex)
|
||||
{
|
||||
|
@ -812,19 +650,9 @@ BOOL eventLoadState(char *pBuffer, UDWORD fileSize, BOOL bHashed)
|
|||
|
||||
|
||||
// load the event contexts
|
||||
if (bHashed)
|
||||
if (!eventLoadContext(version, pPos, &size, bHashed))
|
||||
{
|
||||
if (!eventLoadContextHashed(version, pPos, &size))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!eventLoadContext(version, pPos, &size))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pPos += size;
|
||||
|
|
|
@ -295,7 +295,7 @@ extern BOOL bucketRenderCurrentList(void)
|
|||
#endif
|
||||
break;
|
||||
case RENDER_TILE:
|
||||
drawTerrainTile(((TILE_BUCKET*)thisTag->pObject)->i,((TILE_BUCKET*)thisTag->pObject)->j);
|
||||
drawTerrainTile(((TILE_BUCKET*)thisTag->pObject)->i,((TILE_BUCKET*)thisTag->pObject)->j, FALSE);
|
||||
break;
|
||||
|
||||
case RENDER_WATERTILE:
|
||||
|
|
79
src/design.c
79
src/design.c
|
@ -2107,7 +2107,7 @@ static BOOL _intSetSystemForm(COMP_BASE_STATS *psStats)
|
|||
intSetSystemStats(psStats);
|
||||
|
||||
/* Lock the form down if necessary */
|
||||
if (desCompMode == IDES_SYSTEM)
|
||||
if ( desCompMode == IDES_SYSTEM )
|
||||
{
|
||||
widgSetButtonState(psWScreen, IDDES_SYSTEMFORM, WBUT_LOCK);
|
||||
}
|
||||
|
@ -3608,6 +3608,25 @@ static void intSetDesignPower(DROID_TEMPLATE *psTemplate)
|
|||
widgSetBarSize(psWScreen, IDDES_POWERBAR, calcTemplatePower(psTemplate));
|
||||
}
|
||||
|
||||
// work out current system component
|
||||
static UDWORD getSystemType(DROID_TEMPLATE* template)
|
||||
{
|
||||
if (template->asParts[COMP_ECM]) {
|
||||
return COMP_ECM;
|
||||
} else if (template->asParts[COMP_SENSOR]) {
|
||||
return COMP_SENSOR;
|
||||
} else if (template->asParts[COMP_CONSTRUCT]) {
|
||||
return COMP_CONSTRUCT;
|
||||
} else if (template->asParts[COMP_REPAIRUNIT]) {
|
||||
return COMP_REPAIRUNIT;
|
||||
} else if (template->asWeaps[0]) {
|
||||
return COMP_WEAPON;
|
||||
} else {
|
||||
// compare it with the current weapon
|
||||
return COMP_WEAPON;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the shadow bar graphs for the template power points - psStats is new hilited stats*/
|
||||
static void intSetTemplatePowerShadowStats(COMP_BASE_STATS *psStats)
|
||||
{
|
||||
|
@ -3629,34 +3648,9 @@ static void intSetTemplatePowerShadowStats(COMP_BASE_STATS *psStats)
|
|||
/*if type = BODY or PROPULSION can do a straight comparison but if the new stat is
|
||||
a 'system' stat then need to find out which 'system' is currently in place so the
|
||||
comparison is meaningful*/
|
||||
if (desCompMode == IDES_SYSTEM)
|
||||
if (desCompMode == IDES_SYSTEM)
|
||||
{
|
||||
//work out current system component
|
||||
if (sCurrDesign.asParts[COMP_ECM])
|
||||
{
|
||||
type = COMP_ECM;
|
||||
}
|
||||
else if (sCurrDesign.asParts[COMP_SENSOR])
|
||||
{
|
||||
type = COMP_SENSOR;
|
||||
}
|
||||
else if (sCurrDesign.asParts[COMP_CONSTRUCT])
|
||||
{
|
||||
type = COMP_CONSTRUCT;
|
||||
}
|
||||
else if (sCurrDesign.asParts[COMP_REPAIRUNIT])
|
||||
{
|
||||
type = COMP_REPAIRUNIT;
|
||||
}
|
||||
else if (sCurrDesign.asWeaps[0])
|
||||
{
|
||||
type = COMP_WEAPON;
|
||||
}
|
||||
else
|
||||
{
|
||||
// compare it with the current weapon
|
||||
type = COMP_WEAPON;
|
||||
}
|
||||
type = getSystemType(&sCurrDesign);
|
||||
}
|
||||
|
||||
switch (type)
|
||||
|
@ -3741,34 +3735,9 @@ static void intSetTemplateBodyShadowStats(COMP_BASE_STATS *psStats)
|
|||
/*if type = BODY or PROPULSION can do a straight comparison but if the new stat is
|
||||
a 'system' stat then need to find out which 'system' is currently in place so the
|
||||
comparison is meaningful*/
|
||||
if (desCompMode == IDES_SYSTEM)
|
||||
if ( desCompMode == IDES_SYSTEM )
|
||||
{
|
||||
//work out current system component
|
||||
if (sCurrDesign.asParts[COMP_ECM])
|
||||
{
|
||||
type = COMP_ECM;
|
||||
}
|
||||
else if (sCurrDesign.asParts[COMP_SENSOR])
|
||||
{
|
||||
type = COMP_SENSOR;
|
||||
}
|
||||
else if (sCurrDesign.asParts[COMP_CONSTRUCT])
|
||||
{
|
||||
type = COMP_CONSTRUCT;
|
||||
}
|
||||
else if (sCurrDesign.asParts[COMP_REPAIRUNIT])
|
||||
{
|
||||
type = COMP_REPAIRUNIT;
|
||||
}
|
||||
else if (sCurrDesign.asWeaps[0])
|
||||
{
|
||||
type = COMP_WEAPON;
|
||||
}
|
||||
else
|
||||
{
|
||||
// compare it with the current weapon
|
||||
type = COMP_WEAPON;
|
||||
}
|
||||
type = getSystemType( &sCurrDesign );
|
||||
}
|
||||
|
||||
switch (type)
|
||||
|
|
844
src/display3d.c
844
src/display3d.c
File diff suppressed because it is too large
Load Diff
|
@ -48,7 +48,7 @@ extern void renderDroid ( DROID *psDroid );
|
|||
extern void renderStructure ( STRUCTURE *psStructure );
|
||||
extern void renderFeature ( FEATURE *psFeature );
|
||||
extern void renderProximityMsg ( PROXIMITY_DISPLAY *psProxDisp);
|
||||
extern void drawTerrainTile ( UDWORD i, UDWORD j ); //fast version - optimised
|
||||
extern void drawTerrainTile ( UDWORD i, UDWORD j, BOOL onWaterEdge ); //fast version - optimised
|
||||
void drawTerrainWaterTile(UDWORD i, UDWORD j);
|
||||
extern void drawTexturedTile ( UDWORD i, UDWORD j );
|
||||
extern void renderProjectile ( PROJ_OBJECT *psCurr);
|
||||
|
|
305
src/game.c
305
src/game.c
|
@ -3297,89 +3297,9 @@ BOOL gameLoad(char *pFileData, UDWORD filesize)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
// Get campaign number stuff is not needed in this form on the PSX (thank you very much)
|
||||
static BOOL getCampaignV(char *pFileData, UDWORD filesize, UDWORD version)
|
||||
{
|
||||
SAVE_GAME *psSaveGame;
|
||||
UDWORD sizeOfSaveGame = 0;
|
||||
UDWORD campaign;
|
||||
int i, j;
|
||||
|
||||
debug(LOG_WZ, "getCampaignV: version=%d", version);
|
||||
|
||||
psSaveGame = (SAVE_GAME *) pFileData;
|
||||
|
||||
|
||||
//size is now variable so only check old save games
|
||||
if (version < VERSION_14)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (version <= VERSION_16)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V16);
|
||||
}
|
||||
else if (version <= VERSION_17)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V17);
|
||||
}
|
||||
else if (version <= VERSION_18)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V18);
|
||||
}
|
||||
else if (version <= VERSION_19)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V19);
|
||||
}
|
||||
else if (version <= VERSION_21)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V20);
|
||||
}
|
||||
else if (version <= VERSION_23)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V22);
|
||||
}
|
||||
else if (version <= VERSION_26)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V24);
|
||||
}
|
||||
else if (version <= VERSION_28)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V27);
|
||||
}
|
||||
else if (version <= VERSION_29)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V29);
|
||||
}
|
||||
else if (version <= VERSION_30)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V30);
|
||||
}
|
||||
else if (version <= VERSION_32)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V31);
|
||||
}
|
||||
else if (version <= VERSION_33)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V33);
|
||||
}
|
||||
else if (version <= CURRENT_VERSION_NUM)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME);
|
||||
}
|
||||
|
||||
if ((sizeOfSaveGame + GAME_HEADER_SIZE) > filesize)
|
||||
{
|
||||
debug( LOG_ERROR, "getCampaign: unexpected end of file (expected %d, have %d)" ,
|
||||
(sizeOfSaveGame + GAME_HEADER_SIZE) , filesize);
|
||||
abort();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Fix endianness of a savegame
|
||||
static void endian_SaveGameV(SAVE_GAME* psSaveGame, UDWORD version) {
|
||||
UDWORD i,j;
|
||||
/* SAVE_GAME is GAME_SAVE_V33 */
|
||||
/* GAME_SAVE_V33 includes GAME_SAVE_V31 */
|
||||
if(version >= VERSION_33) {
|
||||
|
@ -3514,6 +3434,88 @@ static BOOL getCampaignV(char *pFileData, UDWORD filesize, UDWORD version)
|
|||
endian_udword(&psSaveGame->ScrollMaxX);
|
||||
endian_udword(&psSaveGame->ScrollMaxY);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
// Get campaign number stuff is not needed in this form on the PSX (thank you very much)
|
||||
static BOOL getCampaignV(char *pFileData, UDWORD filesize, UDWORD version)
|
||||
{
|
||||
SAVE_GAME *psSaveGame;
|
||||
UDWORD sizeOfSaveGame = 0;
|
||||
UDWORD campaign;
|
||||
|
||||
debug(LOG_WZ, "getCampaignV: version=%d", version);
|
||||
|
||||
psSaveGame = (SAVE_GAME *) pFileData;
|
||||
|
||||
|
||||
//size is now variable so only check old save games
|
||||
if (version < VERSION_14)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (version <= VERSION_16)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V16);
|
||||
}
|
||||
else if (version <= VERSION_17)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V17);
|
||||
}
|
||||
else if (version <= VERSION_18)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V18);
|
||||
}
|
||||
else if (version <= VERSION_19)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V19);
|
||||
}
|
||||
else if (version <= VERSION_21)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V20);
|
||||
}
|
||||
else if (version <= VERSION_23)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V22);
|
||||
}
|
||||
else if (version <= VERSION_26)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V24);
|
||||
}
|
||||
else if (version <= VERSION_28)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V27);
|
||||
}
|
||||
else if (version <= VERSION_29)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V29);
|
||||
}
|
||||
else if (version <= VERSION_30)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V30);
|
||||
}
|
||||
else if (version <= VERSION_32)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V31);
|
||||
}
|
||||
else if (version <= VERSION_33)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME_V33);
|
||||
}
|
||||
else if (version <= CURRENT_VERSION_NUM)
|
||||
{
|
||||
sizeOfSaveGame = sizeof(SAVE_GAME);
|
||||
}
|
||||
|
||||
if ((sizeOfSaveGame + GAME_HEADER_SIZE) > filesize)
|
||||
{
|
||||
debug( LOG_ERROR, "getCampaign: unexpected end of file (expected %d, have %d)" ,
|
||||
(sizeOfSaveGame + GAME_HEADER_SIZE) , filesize);
|
||||
abort();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
endian_SaveGameV(psSaveGame, version);
|
||||
|
||||
// savedGameTime = psSaveGame->gameTime;
|
||||
|
||||
|
@ -3783,142 +3785,7 @@ BOOL gameLoadV(char *pFileData, UDWORD filesize, UDWORD version)
|
|||
abort();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* SAVE_GAME is GAME_SAVE_V33 */
|
||||
/* GAME_SAVE_V33 includes GAME_SAVE_V31 */
|
||||
if(version >= VERSION_33) {
|
||||
endian_udword(&psSaveGame->sGame.power);
|
||||
endian_uword(&psSaveGame->sGame.bytesPerSec);
|
||||
for(i = 0; i < MaxGames; i++) {
|
||||
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwSize);
|
||||
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwFlags);
|
||||
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwMaxPlayers);
|
||||
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwCurrentPlayers);
|
||||
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwUser1);
|
||||
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwUser2);
|
||||
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwUser3);
|
||||
endian_sdword(&psSaveGame->sNetPlay.games[i].desc.dwUser4);
|
||||
}
|
||||
for(i = 0; i < MaxNumberOfPlayers; i++)
|
||||
endian_sdword(&psSaveGame->sNetPlay.players[i].dpid);
|
||||
endian_udword(&psSaveGame->sNetPlay.playercount);
|
||||
endian_sdword(&psSaveGame->sNetPlay.dpidPlayer);
|
||||
for(i = 0; i < 4; i++)
|
||||
endian_udword(&psSaveGame->sNetPlay.cryptKey[i]);
|
||||
endian_udword(&psSaveGame->savePlayer);
|
||||
for(i = 0; i < MAX_PLAYERS; i++)
|
||||
endian_sdword(&psSaveGame->sPlayer2dpid[i]);
|
||||
}
|
||||
/* GAME_SAVE_V31 includes GAME_SAVE_V30 */
|
||||
if(version >= VERSION_31) {
|
||||
endian_sdword(&psSaveGame->missionCheatTime);
|
||||
}
|
||||
/* GAME_SAVE_V30 includes GAME_SAVE_V29 */
|
||||
if(version >= VERSION_30) {
|
||||
endian_sdword(&psSaveGame->scrGameLevel);
|
||||
}
|
||||
/* GAME_SAVE_V29 includes GAME_SAVE_V27 */
|
||||
if(version >= VERSION_29) {
|
||||
endian_uword(&psSaveGame->missionScrollMinX);
|
||||
endian_uword(&psSaveGame->missionScrollMinY);
|
||||
endian_uword(&psSaveGame->missionScrollMaxX);
|
||||
endian_uword(&psSaveGame->missionScrollMaxY);
|
||||
}
|
||||
/* GAME_SAVE_V27 includes GAME_SAVE_V24 */
|
||||
if(version >= VERSION_27) {
|
||||
for(i = 0; i < MAX_PLAYERS; i++)
|
||||
for(j = 0; j < MAX_RECYCLED_DROIDS; j++)
|
||||
endian_uword(&psSaveGame->awDroidExperience[i][j]);
|
||||
}
|
||||
/* GAME_SAVE_V24 includes GAME_SAVE_V22 */
|
||||
if(version >= VERSION_24) {
|
||||
endian_udword(&psSaveGame->reinforceTime);
|
||||
}
|
||||
/* GAME_SAVE_V22 includes GAME_SAVE_V20 */
|
||||
if(version >= VERSION_22) {
|
||||
for(i = 0; i < MAX_PLAYERS; i++) {
|
||||
endian_sdword(&psSaveGame->asRunData[i].sPos.x);
|
||||
endian_sdword(&psSaveGame->asRunData[i].sPos.y);
|
||||
}
|
||||
}
|
||||
/* GAME_SAVE_V20 includes GAME_SAVE_V19 */
|
||||
if(version >= VERSION_20) {
|
||||
for(i = 0; i < MAX_PLAYERS; i++) {
|
||||
endian_sdword(&psSaveGame->asVTOLReturnPos[i].x);
|
||||
endian_sdword(&psSaveGame->asVTOLReturnPos[i].y);
|
||||
}
|
||||
}
|
||||
/* GAME_SAVE_V19 includes GAME_SAVE_V18 */
|
||||
if(version >= VERSION_19) {
|
||||
}
|
||||
/* GAME_SAVE_V18 includes GAME_SAVE_V17 */
|
||||
if(version >= VERSION_18) {
|
||||
endian_udword(&psSaveGame->oldestVersion);
|
||||
endian_udword(&psSaveGame->validityKey);
|
||||
}
|
||||
/* GAME_SAVE_V17 includes GAME_SAVE_V16 */
|
||||
if(version >= VERSION_17) {
|
||||
endian_udword(&psSaveGame->objId);
|
||||
}
|
||||
/* GAME_SAVE_V16 includes GAME_SAVE_V15 */
|
||||
if(version >= VERSION_16) {
|
||||
}
|
||||
/* GAME_SAVE_V15 includes GAME_SAVE_V14 */
|
||||
if(version >= VERSION_15) {
|
||||
endian_udword(&psSaveGame->RubbleTile);
|
||||
endian_udword(&psSaveGame->WaterTile);
|
||||
endian_udword(&psSaveGame->fogColour);
|
||||
endian_udword(&psSaveGame->fogState);
|
||||
}
|
||||
/* GAME_SAVE_V14 includes GAME_SAVE_V12 */
|
||||
if(version >= VERSION_14) {
|
||||
endian_sdword(&psSaveGame->missionOffTime);
|
||||
endian_sdword(&psSaveGame->missionETA);
|
||||
endian_uword(&psSaveGame->missionHomeLZ_X);
|
||||
endian_uword(&psSaveGame->missionHomeLZ_Y);
|
||||
endian_sdword(&psSaveGame->missionPlayerX);
|
||||
endian_sdword(&psSaveGame->missionPlayerY);
|
||||
for(i = 0; i < MAX_PLAYERS; i++) {
|
||||
endian_uword(&psSaveGame->iTranspEntryTileX[i]);
|
||||
endian_uword(&psSaveGame->iTranspEntryTileY[i]);
|
||||
endian_uword(&psSaveGame->iTranspExitTileX[i]);
|
||||
endian_uword(&psSaveGame->iTranspExitTileY[i]);
|
||||
endian_udword(&psSaveGame->aDefaultSensor[i]);
|
||||
endian_udword(&psSaveGame->aDefaultECM[i]);
|
||||
endian_udword(&psSaveGame->aDefaultRepair[i]);
|
||||
}
|
||||
}
|
||||
/* GAME_SAVE_V12 includes GAME_SAVE_V11 */
|
||||
if(version >= VERSION_12) {
|
||||
endian_udword(&psSaveGame->missionTime);
|
||||
endian_udword(&psSaveGame->saveKey);
|
||||
}
|
||||
/* GAME_SAVE_V11 includes GAME_SAVE_V10 */
|
||||
if(version >= VERSION_11) {
|
||||
endian_sdword(&psSaveGame->currentPlayerPos.p.x);
|
||||
endian_sdword(&psSaveGame->currentPlayerPos.p.y);
|
||||
endian_sdword(&psSaveGame->currentPlayerPos.p.z);
|
||||
endian_sdword(&psSaveGame->currentPlayerPos.r.x);
|
||||
endian_sdword(&psSaveGame->currentPlayerPos.r.y);
|
||||
endian_sdword(&psSaveGame->currentPlayerPos.r.z);
|
||||
}
|
||||
/* GAME_SAVE_V10 includes GAME_SAVE_V7 */
|
||||
if(version >= VERSION_10) {
|
||||
for(i = 0; i < MAX_PLAYERS; i++) {
|
||||
endian_udword(&psSaveGame->power[i].currentPower);
|
||||
endian_udword(&psSaveGame->power[i].extractedPower);
|
||||
}
|
||||
}
|
||||
/* GAME_SAVE_V7 */
|
||||
if(version >= VERSION_7) {
|
||||
endian_udword(&psSaveGame->gameTime);
|
||||
endian_udword(&psSaveGame->GameType);
|
||||
endian_sdword(&psSaveGame->ScrollMinX);
|
||||
endian_sdword(&psSaveGame->ScrollMinY);
|
||||
endian_udword(&psSaveGame->ScrollMaxX);
|
||||
endian_udword(&psSaveGame->ScrollMaxY);
|
||||
}
|
||||
|
||||
endian_SaveGameV(psSaveGame, version);
|
||||
|
||||
savedGameTime = psSaveGame->gameTime;
|
||||
|
||||
|
|
|
@ -500,35 +500,7 @@ char *getPlayerName(UDWORD player)
|
|||
if(strcmp(NetPlay.players[i].name,"") == 0)
|
||||
{
|
||||
// make up a name for this player.
|
||||
switch(getPlayerColour(player))
|
||||
{
|
||||
case 0:
|
||||
strcpy(tempString,strresGetString(psStringRes, STR_FE_GREEN));
|
||||
break;
|
||||
case 1:
|
||||
strcpy(tempString,strresGetString(psStringRes, STR_FE_ORANGE));
|
||||
break;
|
||||
case 2:
|
||||
strcpy(tempString,strresGetString(psStringRes, STR_FE_GREY));
|
||||
break;
|
||||
case 3:
|
||||
strcpy(tempString,strresGetString(psStringRes, STR_FE_BLACK));
|
||||
break;
|
||||
case 4:
|
||||
strcpy(tempString,strresGetString(psStringRes, STR_FE_RED));
|
||||
break;
|
||||
case 5:
|
||||
strcpy(tempString,strresGetString(psStringRes, STR_FE_BLUE));
|
||||
break;
|
||||
case 6:
|
||||
strcpy(tempString,strresGetString(psStringRes, STR_FE_PINK));
|
||||
break;
|
||||
case 7:
|
||||
strcpy(tempString,strresGetString(psStringRes, STR_FE_CYAN));
|
||||
break;
|
||||
}
|
||||
// sprintf(tempString,"%d",player);
|
||||
return tempString;
|
||||
return getPlayerColourName(player);
|
||||
}
|
||||
|
||||
return (char*)&NetPlay.players[i].name;
|
||||
|
|
273
src/scriptai.c
273
src/scriptai.c
|
@ -1803,9 +1803,9 @@ BOOL scrSkDifficultyModifier(void)
|
|||
}
|
||||
|
||||
// ********************************************************************************************
|
||||
// return a good place to build a defence, given a starting point
|
||||
|
||||
BOOL scrSkDefenseLocation(void)
|
||||
// not a direct script function but a helper for scrSkDefenseLocation and scrSkDefenseLocationB
|
||||
static BOOL defenseLocation(BOOL variantB)
|
||||
{
|
||||
SDWORD *pX,*pY,statIndex,statIndex2;
|
||||
UDWORD x,y,gX,gY,dist,player,nearestSoFar,count;
|
||||
|
@ -1814,6 +1814,9 @@ BOOL scrSkDefenseLocation(void)
|
|||
BASE_STATS *psStats,*psWStats;
|
||||
UDWORD x1,x2,x3,x4,y1,y2,y3,y4;
|
||||
BOOL noWater;
|
||||
UDWORD minCount;
|
||||
UDWORD offset;
|
||||
|
||||
|
||||
if (!stackPopParams(6,
|
||||
VAL_REF|VAL_INT, &pX,
|
||||
|
@ -1823,12 +1826,13 @@ BOOL scrSkDefenseLocation(void)
|
|||
ST_DROID, &psDroid,
|
||||
VAL_INT, &player) )
|
||||
{
|
||||
debug(LOG_ERROR,"defenseLocation: failed to pop");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (player >= MAX_PLAYERS)
|
||||
{
|
||||
ASSERT( FALSE, "scrSkDefenseLocation:player number is too high" );
|
||||
ASSERT( FALSE, "defenseLocation:player number is too high" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1858,6 +1862,11 @@ BOOL scrSkDefenseLocation(void)
|
|||
// does it have >1 tile unoccupied.
|
||||
if(psGate->x1 == psGate->x2)
|
||||
{// vert
|
||||
//skip gates that are too short
|
||||
if(variantB && (psGate->y2 - psGate->y1) <= 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
gX = psGate->x1;
|
||||
for(gY=psGate->y1;gY <= psGate->y2; gY++)
|
||||
{
|
||||
|
@ -1873,6 +1882,11 @@ BOOL scrSkDefenseLocation(void)
|
|||
}
|
||||
else
|
||||
{// horiz
|
||||
//skip gates that are too short
|
||||
if(variantB && (psGate->x2 - psGate->x1) <= 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
gY = psGate->y1;
|
||||
for(gX=psGate->x1;gX <= psGate->x2; gX++)
|
||||
{
|
||||
|
@ -1886,224 +1900,12 @@ BOOL scrSkDefenseLocation(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
if(count > 1 && noWater)
|
||||
{ // ok it's free. Is it the nearest one yet?
|
||||
/* Get gateway midpoint */
|
||||
gX = (psGate->x1 + psGate->x2)/2;
|
||||
gY = (psGate->y1 + psGate->y2)/2;
|
||||
/* Estimate the distance to it */
|
||||
dist = dirtySqrt(x,y,gX,gY);
|
||||
/* Is it best we've found? */
|
||||
if(dist<nearestSoFar && dist<30)
|
||||
{
|
||||
/* Yes, then keep a record of it */
|
||||
nearestSoFar = dist;
|
||||
psChosenGate = psGate;
|
||||
}
|
||||
if(variantB) {
|
||||
minCount = 2;
|
||||
} else {
|
||||
minCount = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(!psChosenGate) // we have a gateway.
|
||||
{
|
||||
goto failed;
|
||||
}
|
||||
|
||||
// find an unnocupied tile on that gateway.
|
||||
if(psChosenGate->x1 == psChosenGate->x2)
|
||||
{// vert
|
||||
gX = psChosenGate->x1;
|
||||
for(gY=psChosenGate->y1;gY <= psChosenGate->y2; gY++)
|
||||
{
|
||||
if(! TILE_OCCUPIED(mapTile(gX,gY) ))
|
||||
{
|
||||
y = gY;
|
||||
x = gX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{// horiz
|
||||
gY = psChosenGate->y1;
|
||||
for(gX=psChosenGate->x1;gX <= psChosenGate->x2; gX++)
|
||||
{
|
||||
if(! TILE_OCCUPIED(mapTile(gX,gY) ))
|
||||
{
|
||||
y = gY;
|
||||
x = gX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// back to world coords and store result.
|
||||
*pX = (x << TILE_SHIFT) + (TILE_UNITS/2); // return centre of tile.
|
||||
*pY = (y << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
|
||||
scrFunctionResult.v.bval = TRUE;
|
||||
if (!stackPushResult(VAL_BOOL,&scrFunctionResult)) // success
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// order the droid to build two walls, one either side of the gateway.
|
||||
// or one in the case of a 2 size gateway.
|
||||
|
||||
x = (psChosenGate->x1 + psChosenGate->x2)/2;
|
||||
y = (psChosenGate->y1 + psChosenGate->y2)/2;
|
||||
|
||||
x1 = (psChosenGate->x1 << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
y1 = (psChosenGate->y1 << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
|
||||
if(psChosenGate->x1 == psChosenGate->x2)
|
||||
{
|
||||
x2 = x1;
|
||||
y2 = ((y-1) << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
x3 = x1;
|
||||
y3 = ((y+1) << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
}
|
||||
else
|
||||
{
|
||||
x2 = ((x-1) << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
y2 = y1;
|
||||
x3 = ((x+1) << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
y3 = y1;
|
||||
|
||||
}
|
||||
x4 = (psChosenGate->x2 << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
y4 = (psChosenGate->y2 << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
|
||||
|
||||
// first section.
|
||||
if(x1 == x2 && y1 == y2)
|
||||
{
|
||||
orderDroidStatsLoc(psDroid, DORDER_BUILD, psWStats, x1, y1);
|
||||
}
|
||||
else
|
||||
{
|
||||
orderDroidStatsTwoLoc(psDroid, DORDER_LINEBUILD, psWStats, x1, y1,x2,y2);
|
||||
}
|
||||
|
||||
// second section
|
||||
if(x3 == x4 && y3 == y4)
|
||||
{
|
||||
orderDroidStatsLocAdd(psDroid, DORDER_BUILD, psWStats, x3, y3);
|
||||
}
|
||||
else
|
||||
{
|
||||
orderDroidStatsTwoLocAdd(psDroid, DORDER_LINEBUILD, psWStats, x3, y3,x4,y4);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
failed:
|
||||
scrFunctionResult.v.bval = FALSE;
|
||||
if (!stackPushResult(VAL_BOOL,&scrFunctionResult)) // failed!
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// return a good place to build a defence with a min number of clear tiles
|
||||
BOOL scrSkDefenseLocationB(void)
|
||||
{
|
||||
SDWORD *pX,*pY,statIndex,statIndex2;
|
||||
UDWORD x,y,gX,gY,dist,player,nearestSoFar,count;
|
||||
GATEWAY *psGate,*psChosenGate;
|
||||
DROID *psDroid;
|
||||
BASE_STATS *psStats,*psWStats;
|
||||
UDWORD x1,x2,x3,x4,y1,y2,y3,y4;
|
||||
BOOL noWater;
|
||||
|
||||
if (!stackPopParams(6,
|
||||
VAL_REF|VAL_INT, &pX,
|
||||
VAL_REF|VAL_INT, &pY,
|
||||
ST_STRUCTURESTAT, &statIndex,
|
||||
ST_STRUCTURESTAT, &statIndex2,
|
||||
ST_DROID, &psDroid,
|
||||
VAL_INT, &player) )
|
||||
{
|
||||
debug(LOG_ERROR,"scrSkDefenseLocationB: failed to pop");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (player >= MAX_PLAYERS)
|
||||
{
|
||||
ASSERT( FALSE, "scrSkDefenseLocationB:player number is too high" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
psStats = (BASE_STATS *)(asStructureStats + statIndex);
|
||||
psWStats = (BASE_STATS *)(asStructureStats + statIndex2);
|
||||
|
||||
// check for wacky coords.
|
||||
if( *pX < 0
|
||||
|| *pX > (SDWORD)(mapWidth<<TILE_SHIFT)
|
||||
|| *pY < 0
|
||||
|| *pY > (SDWORD)(mapHeight<<TILE_SHIFT)
|
||||
)
|
||||
{
|
||||
goto failed;
|
||||
}
|
||||
|
||||
x = *pX >> TILE_SHIFT; // change to tile coords.
|
||||
y = *pY >> TILE_SHIFT;
|
||||
|
||||
// go down the gateways, find the nearest gateway with >1 empty tiles
|
||||
nearestSoFar = UDWORD_MAX;
|
||||
psChosenGate = NULL;
|
||||
for(psGate= psGateways; psGate; psGate= psGate->psNext)
|
||||
{
|
||||
count = 0;
|
||||
noWater = TRUE;
|
||||
// does it have >1 tile unoccupied.
|
||||
if(psGate->x1 == psGate->x2)
|
||||
{// vert
|
||||
|
||||
//skip gates that are too short
|
||||
if((psGate->y2 - psGate->y1) <= 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
gX = psGate->x1;
|
||||
for(gY=psGate->y1;gY <= psGate->y2; gY++)
|
||||
{
|
||||
if(! TILE_OCCUPIED(mapTile(gX,gY) ))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
if(TERRAIN_TYPE(mapTile(gX,gY)) == TER_WATER)
|
||||
{
|
||||
noWater = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{// horiz
|
||||
|
||||
//skip gates that are too short
|
||||
if((psGate->x2 - psGate->x1) <= 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
gY = psGate->y1;
|
||||
for(gX=psGate->x1;gX <= psGate->x2; gX++)
|
||||
{
|
||||
if(! TILE_OCCUPIED(mapTile(gX,gY) ))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
if(TERRAIN_TYPE(mapTile(gX,gY)) == TER_WATER)
|
||||
{
|
||||
noWater = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count > 2 && noWater) //<NEW> min 2 tiles
|
||||
if(count > minCount && noWater) //<NEW> min 2 tiles
|
||||
{
|
||||
// ok it's free. Is it the nearest one yet?
|
||||
/* Get gateway midpoint */
|
||||
|
@ -2176,18 +1978,23 @@ BOOL scrSkDefenseLocationB(void)
|
|||
x1 = (psChosenGate->x1 << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
y1 = (psChosenGate->y1 << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
|
||||
if(variantB) {
|
||||
offset = 2;
|
||||
} else {
|
||||
offset = 1;
|
||||
}
|
||||
if(psChosenGate->x1 == psChosenGate->x2) //vert
|
||||
{
|
||||
x2 = x1; //vert: end x pos of the first section = start x pos
|
||||
y2 = ((y-1) << TILE_SHIFT) + (TILE_UNITS/2); //start y loc of the first sec
|
||||
x3 = x1;
|
||||
y3 = ((y+2) << TILE_SHIFT) + (TILE_UNITS/2); //<NEW> //start y loc of the second sec
|
||||
y3 = ((y+offset) << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
}
|
||||
else //hor
|
||||
{
|
||||
x2 = ((x-1) << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
y2 = y1;
|
||||
x3 = ((x+2) << TILE_SHIFT) + (TILE_UNITS/2); //<NEW>
|
||||
x3 = ((x+offset) << TILE_SHIFT) + (TILE_UNITS/2);
|
||||
y3 = y1;
|
||||
|
||||
}
|
||||
|
@ -2198,27 +2005,26 @@ BOOL scrSkDefenseLocationB(void)
|
|||
//some temp checks
|
||||
if(x2 < x1)
|
||||
{
|
||||
debug(LOG_ERROR,"scrSkDefenseLocationB: x2 < x1");
|
||||
debug(LOG_ERROR,"defenseLocation: x2 < x1");
|
||||
return FALSE;
|
||||
}
|
||||
if(x3 > x4)
|
||||
{
|
||||
debug(LOG_ERROR,"scrSkDefenseLocationB: x2 < x1");
|
||||
debug(LOG_ERROR,"defenseLocation: x2 < x1");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(y2 < y1)
|
||||
{
|
||||
debug(LOG_ERROR,"scrSkDefenseLocationB: y2 < y1");
|
||||
debug(LOG_ERROR,"defenseLocation: y2 < y1");
|
||||
return FALSE;
|
||||
}
|
||||
if(y3 > y4)
|
||||
{
|
||||
debug(LOG_ERROR,"scrSkDefenseLocationB: y3 > y4");
|
||||
debug(LOG_ERROR,"defenseLocation: y3 > y4");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// first section.
|
||||
if(x1 == x2 && y1 == y2) //first sec is 1 tile only: ((2 tile gate) or (3 tile gate and first sec))
|
||||
{
|
||||
|
@ -2251,6 +2057,19 @@ failed:
|
|||
}
|
||||
|
||||
|
||||
// return a good place to build a defence, given a starting point
|
||||
BOOL scrSkDefenseLocation(void)
|
||||
{
|
||||
return defenseLocation(FALSE);
|
||||
}
|
||||
|
||||
// return a good place to build a defence with a min number of clear tiles
|
||||
BOOL scrSkDefenseLocationB(void)
|
||||
{
|
||||
return defenseLocation(TRUE);
|
||||
}
|
||||
|
||||
|
||||
BOOL scrSkFireLassat(void)
|
||||
{
|
||||
SDWORD player;
|
||||
|
|
Loading…
Reference in New Issue