foxygit / doom Log in
commit 95482c25b1e0ec85c90a9150c6c1da4a6aff1046
Author:     James Haley <haleyjd@hotmail.com>
AuthorDate: Thu Sep 9 02:08:43 2010 +0000
Commit:     James Haley <haleyjd@hotmail.com>
CommitDate: Thu Sep 9 02:08:43 2010 +0000

    Changed mobj_t::allegiance to mobj_t::miscdata due to the fact it has
    two completely different uses. Finished P_DialogDoChoice; dialog is now
    virtually 100% functional (just needs finished inventory to really do
    much beyond initial dialogs or getting "no" messages from everybody).

    Subversion-branch: /branches/strife-branch
    Subversion-revision: 2048
---
 src/strife/p_dialog.c | 56 ++++++++++++++++++++++++++++++++-------------------
 src/strife/p_dialog.h |  2 ++
 src/strife/p_enemy.c  |  6 +++---
 src/strife/p_mobj.h   |  6 ++++--
 4 files changed, 44 insertions(+), 26 deletions(-)

diff --git a/src/strife/p_dialog.c b/src/strife/p_dialog.c
index db535143..ce52ee05 100644
--- a/src/strife/p_dialog.c
+++ b/src/strife/p_dialog.c
@@ -31,6 +31,7 @@
 #include "z_zone.h"
 #include "w_wad.h"
 #include "deh_str.h"
+#include "d_main.h"
 #include "d_player.h"
 #include "doomstat.h"
 #include "m_random.h"
@@ -67,6 +68,10 @@
 // are subtitled on screen or not. Defaults to off.
 boolean dialogshowtext = false;

+// The global mission objective buffer. This gets written to and read from file,
+// and is set by dialogs and line actions.
+char mission_objective[OBJECTIVE_LEN];
+
 //
 // Static Globals
 //
@@ -784,19 +789,21 @@ static void P_DialogDrawer(void)
 //
 void P_DialogDoChoice(int choice)
 {
-#if 0
-    int i = 0;
+    int i = 0, nextdialog = 0;
     boolean candochoice = true;
-    char *message;
+    char *message = NULL;
+    mapdlgchoice_t *currentchoice;

     if(choice == -1)
         choice = dialogmenu.numitems - 1;

+    currentchoice = &(currentdialog->choices[choice]);
+
     // I_StartVoice(0); -- verify (should stop previous voice I believe)
     do
     {
-        if(P_PlayerHasItem(dialogplayer, currentdialog->choices[choice].needitems[i]) <
-            currentdialog->choices[choice].needamounts[i])
+        if(P_PlayerHasItem(dialogplayer, currentchoice->needitems[i]) <
+                                         currentchoice->needamounts[i])
         {
             candochoice = false; // nope, missing something
         }
@@ -808,11 +815,11 @@ void P_DialogDoChoice(int choice)
     {
         int item;

-        message = currentdialog->choices[choice].textok;
+        message = currentchoice->textok;
         if(dialogtalkerstates->yes)
             P_SetMobjState(dialogtalker, dialogtalkerstates->yes);

-        item = currentdialog->choices[choice].giveitem;
+        item = currentchoice->giveitem;
         if(item < 0 ||
            P_GiveItemToPlayer(dialogplayer,
                               states[mobjinfo[item].spawnstate].sprite,
@@ -823,8 +830,8 @@ void P_DialogDoChoice(int choice)
             do
             {
                 P_TakeDialogItem(dialogplayer,
-                    currentdialog->choices[choice].needitems[count],
-                    currentdialog->choices[choice].needamounts[count]);
+                                 currentchoice->needitems[count],
+                                 currentchoice->needamounts[count]);
                 ++count;
             }
             while(count < 3);
@@ -832,32 +839,41 @@ void P_DialogDoChoice(int choice)
         else
             message = "You seem to have enough!";

-        // TODO: more....
+        // store next dialog into the talking actor
+        nextdialog = currentchoice->next;
+        if(nextdialog != 0)
+            dialogtalker->miscdata = (byte)(abs(nextdialog));
     }
     else
     {
         // not successful
-        message = currentdialog->choices[choice].textno;
+        message = currentchoice->textno;
         if(dialogtalkerstates->no)
             P_SetMobjState(dialogtalker, dialogtalkerstates->no);
     }

     if(choice != dialogmenu.numitems - 1)
     {
-        // TODO: ...
+        int objective;
+        char *objlump;
+
+        if((objective = currentchoice->objective))
+        {
+            sprintf(mission_objective, "log%i", objective);
+            objlump = W_CacheLumpName(mission_objective, PU_CACHE);
+            strncpy(mission_objective, objlump, 300);
+        }
+        dialogplayer->message = message;
     }

     dialogtalker->angle = dialogtalkerangle;
     dialogplayer->st_update = true;
     M_ClearMenus();
-    /*
-    if(v15 >= 0 || gameaction == ga_victory) // Macil hack
+
+    if(nextdialog >= 0 || gameaction == ga_victory) // Macil hack
         menuindialog = false;
     else
-    */
         P_DialogStart(dialogplayer);
-    // TODO: ...
-#endif
 }

 //
@@ -916,10 +932,8 @@ void P_DialogStart(player_t *player)
     // set pointer to player talking
     dialogplayer = player;

-    // haleyjd: This seems to be an artifact of early development where they
-    // meant to make all this work in multiplayer. By doing this, a thing
-    // could have given different initial dialogs to each player.
-    jumptoconv = linetarget->allegiance;
+    // haleyjd 09/08/10: get any stored dialog state from this object
+    jumptoconv = linetarget->miscdata;

     // check item requirements
     while(1)
diff --git a/src/strife/p_dialog.h b/src/strife/p_dialog.h
index ad0f6abf..da67e932 100644
--- a/src/strife/p_dialog.h
+++ b/src/strife/p_dialog.h
@@ -31,6 +31,8 @@
 #ifndef P_DIALOG_H__
 #define P_DIALOG_H__

+#define OBJECTIVE_LEN       300
+
 #define MDLG_CHOICELEN      32
 #define MDLG_MSGLEN         80
 #define MDLG_NAMELEN        16
diff --git a/src/strife/p_enemy.c b/src/strife/p_enemy.c
index 615930ba..c7c793d0 100644
--- a/src/strife/p_enemy.c
+++ b/src/strife/p_enemy.c
@@ -722,7 +722,7 @@ P_LookForPlayers
     sector_t*   sector;
     angle_t     an;
     fixed_t     dist;
-    mobj_t  *   master = players[actor->allegiance].mo;
+    mobj_t  *   master = players[actor->miscdata].mo;

     // haleyjd 09/05/10: handle Allies
     if(actor->flags & MF_ALLY)
@@ -734,7 +734,7 @@ P_LookForPlayers
             // allegiance. Other allies do it unconditionally.
             if(master && master->target &&
                (master->target->type != MT_REBEL1 ||
-                master->target->allegiance != actor->allegiance))
+                master->target->miscdata != actor->miscdata))
             {
                 actor->target = master->target;
             }
@@ -747,7 +747,7 @@ P_LookForPlayers
                 // friendly Rebel or the allied player.
                 if(!linetarget ||
                     actor->target->type == MT_REBEL1 &&
-                    actor->target->allegiance == actor->allegiance ||
+                    actor->target->miscdata == actor->miscdata ||
                     actor->target == master)
                 {
                     actor->target = NULL;
diff --git a/src/strife/p_mobj.h b/src/strife/p_mobj.h
index 09013395..b7865ff0 100644
--- a/src/strife/p_mobj.h
+++ b/src/strife/p_mobj.h
@@ -325,8 +325,10 @@ typedef struct mobj_s
     // Thing being chased/attacked for tracers.
     struct mobj_s*      tracer;

-    // [STRIFE] haleyjd 09/05/10: allegiance, for friends and teleport beacons
-    byte                allegiance;
+    // [STRIFE] haleyjd 09/05/10:
+    // * In multiplayer this stores allegiance, for friends and teleport beacons
+    // * In single-player this tracks dialog state.
+    byte                miscdata;

 } mobj_t;