Removed reuses of 'battle_counter' global var
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2386 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -76,7 +76,7 @@ OpenJournal (void)
|
|||||||
DWORD start_seed;
|
DWORD start_seed;
|
||||||
|
|
||||||
#if CREATE_JOURNAL
|
#if CREATE_JOURNAL
|
||||||
if (battle_counter)
|
if (create_journal)
|
||||||
{
|
{
|
||||||
if (journal_fh = copen (journal_buf, MEMORY_STREAM, STREAM_WRITE))
|
if (journal_fh = copen (journal_buf, MEMORY_STREAM, STREAM_WRITE))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ BuildBattle (COUNT which_player)
|
|||||||
HSTARSHIP hBuiltShip;
|
HSTARSHIP hBuiltShip;
|
||||||
STARSHIPPTR BuiltShipPtr;
|
STARSHIPPTR BuiltShipPtr;
|
||||||
|
|
||||||
battle_counter = 0;
|
EncounterRace = -1;
|
||||||
|
|
||||||
if (GetHeadLink (&GLOBAL (npc_built_ship_q)) == 0)
|
if (GetHeadLink (&GLOBAL (npc_built_ship_q)) == 0)
|
||||||
{
|
{
|
||||||
SET_GAME_STATE (BATTLE_SEGUE, 0);
|
SET_GAME_STATE (BATTLE_SEGUE, 0);
|
||||||
@@ -467,9 +468,8 @@ UninitEncounter (void)
|
|||||||
hStarShip = GetHeadLink (&GLOBAL (npc_built_ship_q));
|
hStarShip = GetHeadLink (&GLOBAL (npc_built_ship_q));
|
||||||
FragPtr = (SHIP_FRAGMENTPTR)LockStarShip (&GLOBAL (npc_built_ship_q),
|
FragPtr = (SHIP_FRAGMENTPTR)LockStarShip (&GLOBAL (npc_built_ship_q),
|
||||||
hStarShip);
|
hStarShip);
|
||||||
battle_counter = GET_RACE_ID (FragPtr) + 1;
|
EncounterRace = GET_RACE_ID (FragPtr);
|
||||||
if (GetStarShipFromIndex (&GLOBAL (avail_race_q),
|
if (GetStarShipFromIndex (&GLOBAL (avail_race_q), EncounterRace) == 0)
|
||||||
(COUNT)(battle_counter - 1)) == 0)
|
|
||||||
{
|
{
|
||||||
VictoryState = -1;
|
VictoryState = -1;
|
||||||
InitSISContexts ();
|
InitSISContexts ();
|
||||||
@@ -580,7 +580,7 @@ UninitEncounter (void)
|
|||||||
DrawFilledRectangle (&r);
|
DrawFilledRectangle (&r);
|
||||||
|
|
||||||
/* collect bounty ResUnits */
|
/* collect bounty ResUnits */
|
||||||
j = race_bounty[battle_counter - 1] >> 3;
|
j = race_bounty[EncounterRace] >> 3;
|
||||||
RecycleAmount += j;
|
RecycleAmount += j;
|
||||||
sprintf (buf, "%u", RecycleAmount);
|
sprintf (buf, "%u", RecycleAmount);
|
||||||
t.baseline.x = r.corner.x + r.extent.width - 1;
|
t.baseline.x = r.corner.x + r.extent.width - 1;
|
||||||
@@ -689,7 +689,7 @@ UninitEncounter (void)
|
|||||||
DrawStatusMessage (NULL_PTR);
|
DrawStatusMessage (NULL_PTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ships_killed && (battle_counter - 1) == THRADDASH_SHIP
|
if (ships_killed && EncounterRace == THRADDASH_SHIP
|
||||||
&& !GET_GAME_STATE (THRADD_MANNER))
|
&& !GET_GAME_STATE (THRADD_MANNER))
|
||||||
{
|
{
|
||||||
if ((ships_killed += GET_GAME_STATE (THRADDASH_BODY_COUNT)) >
|
if ((ships_killed += GET_GAME_STATE (THRADDASH_BODY_COUNT)) >
|
||||||
|
|||||||
@@ -176,5 +176,8 @@ extern void GenerateSupox (BYTE control);
|
|||||||
extern void GenerateRainbow (BYTE control);
|
extern void GenerateRainbow (BYTE control);
|
||||||
extern void GenerateIlwrath (BYTE control);
|
extern void GenerateIlwrath (BYTE control);
|
||||||
|
|
||||||
|
extern SIZE EncounterRace;
|
||||||
|
extern BYTE EncounterGroup;
|
||||||
|
|
||||||
#endif /* _ENCOUNT_H */
|
#endif /* _ENCOUNT_H */
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "globdata.h"
|
#include "globdata.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "races.h"
|
#include "races.h"
|
||||||
|
#include "encount.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -545,7 +546,7 @@ ip_group_collision (PELEMENT ElementPtr0, PPOINT pPt0, PELEMENT
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
battle_counter = (SIZE)GET_GROUP_ID (StarShipPtr);
|
EncounterGroup = GET_GROUP_ID (StarShipPtr);
|
||||||
|
|
||||||
if (GET_RACE_ID (StarShipPtr) == URQUAN_PROBE_SHIP)
|
if (GET_RACE_ID (StarShipPtr) == URQUAN_PROBE_SHIP)
|
||||||
{
|
{
|
||||||
@@ -826,10 +827,10 @@ DoMissions (void)
|
|||||||
|
|
||||||
spawn_flag_ship ();
|
spawn_flag_ship ();
|
||||||
|
|
||||||
if (battle_counter)
|
if (EncounterRace >= 0)
|
||||||
{
|
{
|
||||||
NotifyOthers ((COUNT)(battle_counter - 1), 0);
|
NotifyOthers (EncounterRace, 0);
|
||||||
battle_counter = 0;
|
EncounterRace = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (hStarShip = GetHeadLink (&GLOBAL (npc_built_ship_q));
|
for (hStarShip = GetHeadLink (&GLOBAL (npc_built_ship_q));
|
||||||
|
|||||||
@@ -354,7 +354,9 @@ LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc)
|
|||||||
cclose (fh);
|
cclose (fh);
|
||||||
res_CloseResFile (in_fp);
|
res_CloseResFile (in_fp);
|
||||||
|
|
||||||
battle_counter = 0;
|
EncounterGroup = 0;
|
||||||
|
EncounterRace = -1;
|
||||||
|
|
||||||
ReinitQueue (&race_q[0]);
|
ReinitQueue (&race_q[0]);
|
||||||
ReinitQueue (&race_q[1]);
|
ReinitQueue (&race_q[1]);
|
||||||
CurStarDescPtr = FindStar (NULL_PTR, &SD.star_pt, 0, 0);
|
CurStarDescPtr = FindStar (NULL_PTR, &SD.star_pt, 0, 0);
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ DeviceFailed (BYTE which_device)
|
|||||||
{
|
{
|
||||||
SET_GAME_STATE (CHMMR_EMERGING, 1);
|
SET_GAME_STATE (CHMMR_EMERGING, 1);
|
||||||
|
|
||||||
battle_counter = 0;
|
EncounterGroup = 0;
|
||||||
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
|
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
|
||||||
|
|
||||||
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
|
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
|
||||||
@@ -267,7 +267,7 @@ DeviceFailed (BYTE which_device)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
battle_counter = 0;
|
EncounterGroup = 0;
|
||||||
if (GetHeadLink (&GLOBAL (npc_built_ship_q)))
|
if (GetHeadLink (&GLOBAL (npc_built_ship_q)))
|
||||||
{
|
{
|
||||||
SET_GAME_STATE (SHIP_TO_COMPEL, 1);
|
SET_GAME_STATE (SHIP_TO_COMPEL, 1);
|
||||||
@@ -329,7 +329,7 @@ DeviceFailed (BYTE which_device)
|
|||||||
NextActivity |= CHECK_LOAD; /* fake a load game */
|
NextActivity |= CHECK_LOAD; /* fake a load game */
|
||||||
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
|
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
|
||||||
|
|
||||||
battle_counter = 0;
|
EncounterGroup = 0;
|
||||||
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
|
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
|
||||||
ReinitQueue (&GLOBAL (npc_built_ship_q));
|
ReinitQueue (&GLOBAL (npc_built_ship_q));
|
||||||
|
|
||||||
@@ -366,7 +366,7 @@ DeviceFailed (BYTE which_device)
|
|||||||
NextActivity |= CHECK_LOAD; /* fake a load game */
|
NextActivity |= CHECK_LOAD; /* fake a load game */
|
||||||
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
|
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
|
||||||
|
|
||||||
battle_counter = 0;
|
EncounterGroup = 0;
|
||||||
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
|
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
|
||||||
ReinitQueue (&GLOBAL (npc_built_ship_q));
|
ReinitQueue (&GLOBAL (npc_built_ship_q));
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,8 @@ GenerateSamatra (BYTE control)
|
|||||||
break;
|
break;
|
||||||
case REINIT_NPCS:
|
case REINIT_NPCS:
|
||||||
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
|
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
|
||||||
battle_counter = 0;
|
EncounterGroup = 0;
|
||||||
|
EncounterRace = -1; // Do not want guards to chase the player
|
||||||
{
|
{
|
||||||
BOOLEAN GuardEngaged;
|
BOOLEAN GuardEngaged;
|
||||||
HSTARSHIP hStarShip, hNextShip;
|
HSTARSHIP hStarShip, hNextShip;
|
||||||
@@ -290,7 +291,8 @@ GenerateSamatra (BYTE control)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
battle_counter = 0;
|
EncounterGroup = 0;
|
||||||
|
EncounterRace = -1;
|
||||||
GLOBAL (CurrentActivity) = IN_LAST_BATTLE | START_ENCOUNTER;
|
GLOBAL (CurrentActivity) = IN_LAST_BATTLE | START_ENCOUNTER;
|
||||||
if (GET_GAME_STATE (YEHAT_CIVIL_WAR)
|
if (GET_GAME_STATE (YEHAT_CIVIL_WAR)
|
||||||
&& ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING)
|
&& ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "races.h"
|
#include "races.h"
|
||||||
#include "resinst.h"
|
#include "resinst.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
#include "encount.h"
|
||||||
#include "planets/genall.h"
|
#include "planets/genall.h"
|
||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
|
||||||
@@ -189,7 +190,7 @@ generate_orbital (void)
|
|||||||
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
|
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
|
||||||
ReinitQueue (&GLOBAL (npc_built_ship_q));
|
ReinitQueue (&GLOBAL (npc_built_ship_q));
|
||||||
|
|
||||||
battle_counter = 0;
|
EncounterGroup = 0;
|
||||||
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
|
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
|
||||||
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, (BYTE)~0);
|
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, (BYTE)~0);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -767,7 +767,7 @@ PickPlanetSide (PMENU_STATE pMS)
|
|||||||
NextActivity |= CHECK_LOAD; /* fake a load game */
|
NextActivity |= CHECK_LOAD; /* fake a load game */
|
||||||
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
|
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
|
||||||
|
|
||||||
battle_counter = 0;
|
EncounterGroup = 0;
|
||||||
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
|
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
|
||||||
ReinitQueue (&GLOBAL (npc_built_ship_q));
|
ReinitQueue (&GLOBAL (npc_built_ship_q));
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ COLORMAP OrbitalCMap;
|
|||||||
COLORMAP SunCMap;
|
COLORMAP SunCMap;
|
||||||
MUSIC_REF SpaceMusic;
|
MUSIC_REF SpaceMusic;
|
||||||
|
|
||||||
|
SIZE EncounterRace;
|
||||||
|
BYTE EncounterGroup;
|
||||||
|
// last encountered group info
|
||||||
|
|
||||||
#define DRAW_STARS (1 << 0)
|
#define DRAW_STARS (1 << 0)
|
||||||
#define DRAW_PLANETS (1 << 1)
|
#define DRAW_PLANETS (1 << 1)
|
||||||
#define DRAW_ORBITS (1 << 2)
|
#define DRAW_ORBITS (1 << 2)
|
||||||
@@ -1453,7 +1457,8 @@ InitSolarSys (void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
battle_counter = 0;
|
EncounterRace = -1;
|
||||||
|
EncounterGroup = 0;
|
||||||
GLOBAL (BattleGroupRef) = 0;
|
GLOBAL (BattleGroupRef) = 0;
|
||||||
ReinitQueue (&GLOBAL (npc_built_ship_q));
|
ReinitQueue (&GLOBAL (npc_built_ship_q));
|
||||||
(*pSolarSysState->GenFunc) (INIT_NPCS);
|
(*pSolarSysState->GenFunc) (INIT_NPCS);
|
||||||
@@ -1532,9 +1537,9 @@ UninitSolarSys (void)
|
|||||||
|
|
||||||
SET_GAME_STATE (USED_BROADCASTER, 0);
|
SET_GAME_STATE (USED_BROADCASTER, 0);
|
||||||
}
|
}
|
||||||
else if ((GLOBAL (CurrentActivity) & START_ENCOUNTER) && battle_counter)
|
else if ((GLOBAL (CurrentActivity) & START_ENCOUNTER) && EncounterGroup)
|
||||||
{
|
{
|
||||||
GetGroupInfo (GLOBAL (BattleGroupRef), (BYTE)battle_counter);
|
GetGroupInfo (GLOBAL (BattleGroupRef), EncounterGroup);
|
||||||
if (HIWORD (GLOBAL (ShipStamp.frame)) == 0)
|
if (HIWORD (GLOBAL (ShipStamp.frame)) == 0)
|
||||||
{
|
{
|
||||||
BYTE i;
|
BYTE i;
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ while (--ac > 0)
|
|||||||
#endif //DEBUG_PSYTRON
|
#endif //DEBUG_PSYTRON
|
||||||
#if CREATE_JOURNAL
|
#if CREATE_JOURNAL
|
||||||
case 'j':
|
case 'j':
|
||||||
++battle_counter;
|
++create_journal;
|
||||||
break;
|
break;
|
||||||
#endif //CREATE_JOURNAL
|
#endif //CREATE_JOURNAL
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user