t"IsAt" changed from a char to an int to a) improve performance marginally and … | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit b6dd218301c177073743070514e2869a58e39b53 | |
parent 29d5b1410ef359cf013d0f12a8ee96663b291173 | |
Author: Ben Webb <[email protected]> | |
Date: Fri, 1 Mar 2002 11:19:22 +0000 | |
"IsAt" changed from a char to an int to a) improve performance marginally | |
and b) eliminate the oh-so-dodgy int->char casts that cause mega problems | |
when "char" is unsigned (e.g. on PPC systems). | |
Diffstat: | |
M ChangeLog | 1 + | |
M src/AIPlayer.c | 10 +++++----- | |
M src/dopewars.h | 2 +- | |
M src/message.c | 2 +- | |
M src/serverside.c | 20 +++++++++----------- | |
5 files changed, 17 insertions(+), 18 deletions(-) | |
--- | |
diff --git a/ChangeLog b/ChangeLog | |
t@@ -4,6 +4,7 @@ cvs | |
- Icon added for GTK+ client | |
- Bug with withdrawing cash from the bank fixed | |
- URL in GTK+ client "About" box is now clickable | |
+ - Crash bugs when running on PPC systems fixed | |
1.5.3 04-02-2002 | |
- Text-mode server is now non-interactive by default (server admin can | |
diff --git a/src/AIPlayer.c b/src/AIPlayer.c | |
t@@ -351,7 +351,7 @@ int HandleAIMessage(char *Message, Player *AIPlay) | |
break; | |
case C_SUBWAYFLASH: | |
dpg_print(_("Jetting to %tde with %P cash and %P debt\n"), | |
- Location[(int)AIPlay->IsAt].Name, AIPlay->Cash, | |
+ Location[AIPlay->IsAt].Name, AIPlay->Cash, | |
AIPlay->Debt); | |
/* Use bselect rather than sleep, as this is portable to Win32 */ | |
tv.tv_sec = AITurnPause; | |
t@@ -602,7 +602,7 @@ void AIHandleQuestion(char *Data, AICode AI, Player *AIPla… | |
case C_ASKLOAN: | |
if (RealLoanShark == -1) { | |
g_print(_("Loan shark located at %s\n"), | |
- Location[(int)AIPlay->IsAt].Name); | |
+ Location[AIPlay->IsAt].Name); | |
} | |
RealLoanShark = AIPlay->IsAt; | |
AISendAnswer(AIPlay, From, "Y"); | |
t@@ -610,14 +610,14 @@ void AIHandleQuestion(char *Data, AICode AI, Player *AIP… | |
case C_ASKGUNSHOP: | |
if (RealGunShop == -1) { | |
g_print(_("Gun shop located at %s\n"), | |
- Location[(int)AIPlay->IsAt].Name); | |
+ Location[AIPlay->IsAt].Name); | |
} | |
RealGunShop = AIPlay->IsAt; | |
AISendAnswer(AIPlay, From, "Y"); | |
break; | |
case C_ASKPUB: | |
if (RealPub == -1) { | |
- g_print(_("Pub located at %s\n"), Location[(int)AIPlay->IsAt].Name); | |
+ g_print(_("Pub located at %s\n"), Location[AIPlay->IsAt].Name); | |
} | |
RealPub = AIPlay->IsAt; | |
AISendAnswer(AIPlay, From, "Y"); | |
t@@ -632,7 +632,7 @@ void AIHandleQuestion(char *Data, AICode AI, Player *AIPla… | |
break; | |
case C_ASKBANK: | |
if (RealBank == -1) { | |
- g_print(_("Bank located at %s\n"), Location[(int)AIPlay->IsAt].Name); | |
+ g_print(_("Bank located at %s\n"), Location[AIPlay->IsAt].Name); | |
} | |
RealBank = AIPlay->IsAt; | |
AISendAnswer(AIPlay, From, "N"); | |
diff --git a/src/dopewars.h b/src/dopewars.h | |
t@@ -277,7 +277,7 @@ struct PLAYER_T { | |
price_t Cash, Debt, Bank; | |
int Health; | |
int CoatSize; | |
- char IsAt; | |
+ int IsAt; | |
PlayerFlags Flags; | |
gchar *Name; | |
Inventory *Guns, *Drugs, Bitches; | |
diff --git a/src/message.c b/src/message.c | |
t@@ -1317,7 +1317,7 @@ void FormatFightMessage(Player *To, GString *text, Playe… | |
if (!IsCop(Attacker) && brandom(0, 100) < 70 | |
&& Attacker->IsAt >= 0) { | |
g_string_sprintfa(text, _("%s has got away to %s!"), AttackName, | |
- Location[(int)Attacker->IsAt].Name); | |
+ Location[Attacker->IsAt].Name); | |
} else { | |
g_string_sprintfa(text, _("%s has got away!"), AttackName); | |
} | |
diff --git a/src/serverside.c b/src/serverside.c | |
t@@ -472,7 +472,7 @@ void HandleServerMessage(gchar *buf, Player *Play) | |
} else if (i != Play->IsAt && (NumTurns == 0 || Play->Turn < NumTurns) | |
&& Play->EventNum == E_NONE && Play->Health > 0) { | |
dopelog(4, "%s jets to %s", GetPlayerName(Play), Location[i].Name); | |
- Play->IsAt = (char)i; | |
+ Play->IsAt = i; | |
Play->Turn++; | |
Play->Debt = (price_t)((float)Play->Debt * 1.1); | |
Play->Bank = (price_t)((float)Play->Bank * 1.05); | |
t@@ -2285,7 +2285,7 @@ int SendCopOffer(Player *To, OfferForce Force) | |
/* The cops are more likely to attack in locations with higher police | |
* presence ratings */ | |
- i = brandom(0, 80 + Location[(int)To->IsAt].PolicePresence); | |
+ i = brandom(0, 80 + Location[To->IsAt].PolicePresence); | |
if (Force == FORCECOPS) | |
i = 100; | |
t@@ -2545,7 +2545,7 @@ void RunFromCombat(Player *Play, int ToLocation) | |
Play->CopIndex--; | |
} | |
BackupAt = Play->IsAt; | |
- Play->IsAt = (char)ToLocation; | |
+ Play->IsAt = ToLocation; | |
WithdrawFromCombat(Play); | |
Play->IsAt = BackupAt; | |
Play->EventNum = Play->ResyncNum; | |
t@@ -2605,7 +2605,7 @@ static void CheckCopsIntervene(Player *Play) | |
if (!Play->Attacking) | |
return; /* Cops don't attack "innocent victims" ;) */ | |
- if (brandom(0, 100) > Location[(int)Play->IsAt].PolicePresence) { | |
+ if (brandom(0, 100) > Location[Play->IsAt].PolicePresence) { | |
return; /* The cops shouldn't _always_ attack | |
* (unless P.P. == 100) */ | |
} | |
t@@ -2844,10 +2844,8 @@ void WithdrawFromCombat(Player *Play) | |
FirstServer = RemovePlayer(Defend, FirstServer); | |
} else if (Defend->Health == 0) { | |
FinishGame(Defend, _("You're dead! Game over.")); | |
- } else if (CanRunHere(Defend) && | |
- brandom(0, | |
- 100) > | |
- Location[(int)Defend->IsAt].PolicePresence) { | |
+ } else if (CanRunHere(Defend) | |
+ && brandom(0, 100) > Location[Defend->IsAt].PolicePresence) { | |
Defend->EventNum = E_DOCTOR; | |
Defend->DocPrice = prandom(Bitch.MinPrice, Bitch.MaxPrice) * | |
Defend->Health / 500; | |
t@@ -3063,8 +3061,8 @@ static void GenerateDrugsHere(Player *To, enum DealType … | |
NumEvents--; | |
} | |
} | |
- NumRandom = brandom(Location[(int)To->IsAt].MinDrug, | |
- Location[(int)To->IsAt].MaxDrug); | |
+ NumRandom = brandom(Location[To->IsAt].MinDrug, | |
+ Location[To->IsAt].MaxDrug); | |
if (NumRandom > NumDrug) | |
NumRandom = NumDrug; | |
t@@ -3321,7 +3319,7 @@ void BuyObject(Player *From, char *data) | |
if (!Sanitized && (From->Drugs[index].Price == 0 && | |
brandom(0, | |
100) < | |
- Location[(int)From->IsAt].PolicePresence)) { | |
+ Location[From->IsAt].PolicePresence)) { | |
SendPrintMessage(NULL, C_NONE, From, | |
_("The cops spot you dropping drugs!")); | |
CopsAttackPlayer(From); |