@@ -2823,6 +2823,107 @@ Bool ScriptAction::ParseActionDataChunk(DataChunkInput &file, DataChunkInfo *inf
28232823 return true ;
28242824}
28252825
2826+ #ifdef RTS_HAS_JSON_CHUNK
2827+ Bool ScriptAction::ParseActionDataChunkJSON (JSONChunkInput &file, JSONChunkInfo *info, void *userData)
2828+ {
2829+ Script *pScript = (Script *)userData;
2830+ ScriptAction *pScriptAction = newInstance (ScriptAction);
2831+
2832+ pScriptAction->m_actionType = (enum ScriptActionType)file.readInt ();
2833+
2834+ #if defined(RTS_DEBUG)
2835+ const ActionTemplate* at = TheScriptEngine->getActionTemplate (pScriptAction->m_actionType );
2836+ if (at && (at->getName ().isEmpty () || (at->getName ().compareNoCase (" (placeholder)" ) == 0 ))) {
2837+ DEBUG_CRASH ((" Invalid Script Action found in script '%s'" , pScript->getName ().str ()));
2838+ }
2839+ #endif
2840+
2841+ pScriptAction->m_numParms =file.readInt ();
2842+ Int i;
2843+ for (i=0 ; i<pScriptAction->m_numParms ; i++)
2844+ {
2845+ pScriptAction->m_parms [i] = Parameter::ReadParameterJSON (file);
2846+ }
2847+
2848+ switch (pScriptAction->getActionType ())
2849+ {
2850+ case SKIRMISH_FIRE_SPECIAL_POWER_AT_MOST_COST:
2851+ if (pScriptAction->m_numParms == 1 )
2852+ {
2853+ pScriptAction->m_numParms = 2 ;
2854+ pScriptAction->m_parms [1 ] = pScriptAction->m_parms [0 ];
2855+ pScriptAction->m_parms [0 ] = newInstance (Parameter)(Parameter::SIDE, 0 );
2856+ pScriptAction->m_parms [0 ]->friend_setString (THIS_PLAYER);
2857+ }
2858+ break ;
2859+ case TEAM_FOLLOW_WAYPOINTS:
2860+ if (pScriptAction->m_numParms == 2 )
2861+ {
2862+ pScriptAction->m_numParms = 3 ;
2863+ pScriptAction->m_parms [2 ] = newInstance (Parameter)(Parameter::BOOLEAN, 1 );
2864+ }
2865+ break ;
2866+ case SKIRMISH_BUILD_BASE_DEFENSE_FRONT:
2867+ if (pScriptAction->m_numParms == 1 )
2868+ {
2869+ Bool flank = pScriptAction->m_parms [0 ]->getInt ()!=0 ;
2870+ deleteInstance (pScriptAction->m_parms [0 ]);
2871+ pScriptAction->m_numParms = 0 ;
2872+ if (flank) pScriptAction->m_actionType = SKIRMISH_BUILD_BASE_DEFENSE_FLANK;
2873+ }
2874+ break ;
2875+ case NAMED_SET_ATTITUDE:
2876+ case TEAM_SET_ATTITUDE:
2877+ if (pScriptAction->m_numParms >= 2 && pScriptAction->m_parms [1 ]->getParameterType () == Parameter::INT)
2878+ {
2879+ pScriptAction->m_parms [1 ] = newInstance (Parameter)(Parameter::AI_MOOD, pScriptAction->m_parms [1 ]->getInt ());
2880+ }
2881+ break ;
2882+ case MAP_REVEAL_AT_WAYPOINT:
2883+ case MAP_SHROUD_AT_WAYPOINT:
2884+ if (pScriptAction->getNumParameters () == 2 )
2885+ {
2886+ pScriptAction->m_numParms = 3 ;
2887+ pScriptAction->m_parms [2 ] = newInstance (Parameter)(Parameter::SIDE);
2888+ }
2889+ break ;
2890+ case MAP_REVEAL_ALL:
2891+ case MAP_REVEAL_ALL_PERM:
2892+ case MAP_REVEAL_ALL_UNDO_PERM:
2893+ case MAP_SHROUD_ALL:
2894+ if (pScriptAction->getNumParameters () == 0 )
2895+ {
2896+ pScriptAction->m_numParms = 1 ;
2897+ pScriptAction->m_parms [0 ] = newInstance (Parameter)(Parameter::SIDE);
2898+ }
2899+ break ;
2900+ case SPEECH_PLAY:
2901+ if (pScriptAction->getNumParameters () == 1 )
2902+ {
2903+ pScriptAction->m_numParms = 2 ;
2904+ pScriptAction->m_parms [1 ] = newInstance (Parameter)(Parameter::BOOLEAN, 1 );
2905+ }
2906+ break ;
2907+ }
2908+
2909+ ScriptAction *pLast = pScript->getAction ();
2910+ while (pLast && pLast->getNext ())
2911+ {
2912+ pLast = pLast->getNext ();
2913+ }
2914+
2915+ if (pLast)
2916+ {
2917+ pLast->setNextAction (pScriptAction);
2918+ }
2919+ else
2920+ {
2921+ pScript->setAction (pScriptAction);
2922+ }
2923+ DEBUG_ASSERTCRASH (file.atEndOfChunk (), (" Unexpected data left over." ));
2924+ return true ;
2925+ }
2926+ #endif
28262927
28272928/* *
28282929* ScriptAction::WriteActionFalseDataChunk - Writes a false Action chunk.
0 commit comments