Skip to content

Commit 2d388d4

Browse files
committed
Fix Generals Scripts: add missing ParseActionDataChunkJSON declaration, fix TheKindOf usage, remove duplicate function, wrap JSON parser registrations
1 parent 960662a commit 2d388d4

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

Generals/Code/GameEngine/Include/GameLogic/Scripts.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,13 @@ class ScriptAction : public MemoryPoolObject // This is the action class.
596596
static void WriteActionDataChunkJSON(JSONChunkOutput &chunkWriter, ScriptAction *pAct);
597597
#endif
598598
static Bool ParseActionDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
599+
#ifdef RTS_HAS_JSON_CHUNK
600+
static Bool ParseActionDataChunkJSON(JSONChunkInput &file, JSONChunkInfo *info, void *userData);
601+
#endif
599602
static void WriteActionFalseDataChunk(DataChunkOutput &chunkWriter, ScriptAction *pAct);
600603
#ifdef RTS_HAS_JSON_CHUNK
601604
static void WriteActionFalseDataChunkJSON(JSONChunkOutput &chunkWriter, ScriptAction *pAct);
602-
static Bool ParseActionFalseDataChunkJSON(DataChunkInput &file, DataChunkInfo *info, void *userData);
605+
static Bool ParseActionFalseDataChunkJSON(JSONChunkInput &file, JSONChunkInfo *info, void *userData);
603606
#endif
604607
static Bool ParseActionFalseDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
605608

Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,9 +1395,11 @@ Script *Script::ParseScriptJSON(JSONChunkInput &file, unsigned short version)
13951395
if (version>=K_SCRIPT_DATA_VERSION_2) {
13961396
pScript->m_delayEvaluationSeconds = file.readInt();
13971397
}
1398+
#ifdef RTS_HAS_JSON_CHUNK
13981399
file.registerParser( "OrCondition", "Script", OrCondition::ParseOrConditionDataChunkJSON );
13991400
file.registerParser( "ScriptAction", "Script", ScriptAction::ParseActionDataChunkJSON );
14001401
file.registerParser( "ScriptActionFalse", "Script", ScriptAction::ParseActionFalseDataChunkJSON );
1402+
#endif
14011403
if (! file.parse(pScript) )
14021404
{
14031405
return NULL;
@@ -2488,7 +2490,7 @@ Parameter *Parameter::ReadParameterJSON(JSONChunkInput &file)
24882490
if (pParm->getParameterType() == KIND_OF_PARAM)
24892491
{
24902492
Bool found = false;
2491-
const char* const* kindofNames = TheKindOf->getKindOfNames();
2493+
const char* const* kindofNames = KindOfMaskType::getBitNames();
24922494
Int i;
24932495
for( i = 0; kindofNames[i]; ++i )
24942496
{
@@ -2524,7 +2526,7 @@ Parameter *Parameter::ReadParameterJSON(JSONChunkInput &file)
25242526
}
25252527
else
25262528
{
2527-
const char* const* kindofNames = TheKindOf->getKindOfNames();
2529+
const char* const* kindofNames = KindOfMaskType::getBitNames();
25282530
pParm->m_string = kindofNames[pParm->m_int];
25292531
}
25302532

@@ -2921,33 +2923,6 @@ Bool ScriptAction::ParseActionFalseDataChunkJSON(JSONChunkInput &file, JSONChunk
29212923
}
29222924
#endif
29232925

2924-
#ifdef RTS_HAS_JSON_CHUNK
2925-
Bool ScriptAction::ParseActionFalseDataChunkJSON(JSONChunkInput &file, JSONChunkInfo *info, void *userData)
2926-
{
2927-
Script *pScript = (Script *)userData;
2928-
2929-
ScriptAction *pScriptAction = newInstance(ScriptAction);
2930-
2931-
pScriptAction->m_actionType = (enum ScriptActionType)file.readInt();
2932-
pScriptAction->m_numParms =file.readInt();
2933-
Int i;
2934-
for (i=0; i<pScriptAction->m_numParms; i++) {
2935-
pScriptAction->m_parms[i] = Parameter::ReadParameterJSON(file);
2936-
}
2937-
ScriptAction *pLast = pScript->getFalseAction();
2938-
while (pLast && pLast->getNext()) {
2939-
pLast = pLast->getNext();
2940-
}
2941-
if (pLast) {
2942-
pLast->setNextAction(pScriptAction);
2943-
} else {
2944-
pScript->setFalseAction(pScriptAction);
2945-
}
2946-
DEBUG_ASSERTCRASH(file.atEndOfChunk(), ("Unexpected data left over."));
2947-
return true;
2948-
}
2949-
#endif
2950-
29512926
// NOTE: Changing these or adding to TheObjectFlagsNames requires changes to
29522927
// ScriptActions::changeObjectPanelFlagForSingleObject
29532928
// THEY SHOULD STAY IN SYNC.

0 commit comments

Comments
 (0)