tFixed tipoffs with new fighting code - vaccinewars - be a doctor and try to vaccinate the world
git clone git://src.adamsgaard.dk/vaccinewars
Log
Files
Refs
README
LICENSE
---
commit 459965330736864ed274ef1cf4fc7854c6092dd8
parent 54472d27259323996513498982cbdd3742b1e130
Author: Ben Webb 
Date:   Sun, 22 Oct 2000 03:32:11 +0000

Fixed tipoffs with new fighting code


Diffstat:
  M src/message.c                       |       4 +++-
  M src/serverside.c                    |      37 +++++++++++++++++++++++++++++--

2 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/src/message.c b/src/message.c
t@@ -769,6 +769,8 @@ int ProcessMessage(char *Msg,Player *Play,Player **Other,char *AICode,
    gchar *pt,*buf;
    guint ID;
 
+   if (!First || !Play) return;
+
    *AICode=*Code=C_NONE;
    *Other=&Noone;
    pt=Msg;
t@@ -938,7 +940,7 @@ void SendFightReload(Player *To) {
 void SendOldCanFireMessage(Player *To,GString *text) {
    if (To->EventNum==E_FIGHT) {
       To->EventNum=E_FIGHTASK;
-      if (CanRunHere(To) && !HaveAbility(To,A_NEWFIGHT)) {
+      if (CanRunHere(To) && To->Health>0 && !HaveAbility(To,A_NEWFIGHT)) {
          if (text->len>0) g_string_append_c(text,'^');
          if (TotalGunsCarried(To)==0) {
             g_string_prepend(text,"YN^");
diff --git a/src/serverside.c b/src/serverside.c
t@@ -1323,7 +1323,8 @@ void DoReturnFire(Player *Play) {
    if (!Play || !Play->FightArray) return;
 
    if (FightTimeout!=0 || !Play->IsCop) {
-      for (ArrayInd=0;ArrayIndFightArray->len;ArrayInd++) {
+      for (ArrayInd=0;Play->FightArray && ArrayIndFightArray->len;
+           ArrayInd++) {
          Defend=(Player *)g_ptr_array_index(Play->FightArray,ArrayInd);
          if (Defend->IsCop && CanPlayerFire(Defend)) Fire(Defend);
       }
t@@ -1411,7 +1412,9 @@ void Fire(Player *Play) {
       }
    }
    CheckForKilledPlayers(Play);
-   DoReturnFire(Play);
+
+/* Careful, as we might have killed Player "Play" */
+   if (g_slist_find(FirstServer,(gpointer)Play)) DoReturnFire(Play);
 }
 
 gboolean CanPlayerFire(Player *Play) {
t@@ -1441,6 +1444,34 @@ Player *GetNextShooter(Player *Play) {
    return MinPlay;
 }
 
+void ResolveTipoff(Player *Play) {
+   GString *text;
+
+   if (Play->IsCop || !CanRunHere(Play)) return;
+
+   if (g_slist_find(FirstServer,(gpointer)Play->OnBehalfOf)) {
+      g_message(_("%s: tipoff by %s finished OK."),GetPlayerName(Play),
+                GetPlayerName(Play->OnBehalfOf));
+      RemoveListPlayer(&(Play->TipList),Play->OnBehalfOf);
+      text=g_string_new("");
+      if (Play->Health==0) {
+         g_string_sprintf(text,
+           _("Following your tipoff, the cops ambushed %s, who was shot dead!"),
+           GetPlayerName(Play));
+      } else {
+         dpg_string_sprintf(text,
+                _("Following your tipoff, the cops ambushed %s, who escaped "
+                "with %d %tde. "),GetPlayerName(Play),
+                Play->Bitches.Carried,Names.Bitches);
+      }
+      GainBitch(Play->OnBehalfOf);
+      SendPlayerData(Play->OnBehalfOf);
+      SendPrintMessage(NULL,C_NONE,Play->OnBehalfOf,text->str);
+      g_string_free(text,TRUE);
+   }
+   Play->OnBehalfOf=NULL;
+}
+
 void WithdrawFromCombat(Player *Play) {
 /* Cleans up combat after player "Play" has left                    */
    int i,j;
t@@ -1449,6 +1480,7 @@ void WithdrawFromCombat(Player *Play) {
 
    if (!Play->FightArray) return;
 
+   ResolveTipoff(Play);
    FightDone=TRUE;
    for (i=0;iFightArray->len;i++) {
       Attack=(Player *)g_ptr_array_index(Play->FightArray,i);
t@@ -1467,6 +1499,7 @@ void WithdrawFromCombat(Player *Play) {
       for (i=0;iFightArray->len;i++) {
          Defend=(Player *)g_ptr_array_index(Play->FightArray,i);
          Defend->FightArray=NULL;
+         ResolveTipoff(Defend);
          if (Defend->IsCop) {
             FirstServer=RemovePlayer(Defend,FirstServer);
          } else if (Defend->Health==0) {