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