diff Outdoor.cpp @ 783:b27dd658ea77

Taveling by foot fixed.
author Nomad
date Sun, 24 Mar 2013 21:14:28 +0200
parents 67b77b052ef3
children 346f7069676a
line wrap: on
line diff
--- a/Outdoor.cpp	Sun Mar 24 00:33:27 2013 +0200
+++ b/Outdoor.cpp	Sun Mar 24 21:14:28 2013 +0200
@@ -5,7 +5,6 @@
 #include "SpriteObject.h"
 #include "LOD.h"
 #include "Render.h"
-#include "MapInfo.h"
 #include "Allocator.h"
 #include "Weather.h"
 #include "PaletteManager.h"
@@ -31,6 +30,8 @@
 
 
 
+MapStartPoint uLevel_StartingPointType; // weak
+
 OutdoorLocation *pOutdoor = new OutdoorLocation;
 OutdoorCamera *pOutdoorCamera;
 
@@ -337,20 +338,83 @@
   return true;
 }
 
+
+
+char foot_travel_destinations[15][4] =
+{
+// north           south               east              west                    from
+  {MAP_INVALID,    MAP_INVALID,        MAP_INVALID,      MAP_INVALID},        // MAP_EMERALD_ISLE
+  {MAP_PIERPONT,   MAP_BARROW_DOWNS,   MAP_PIERPONT,     MAP_STEADWICK},      // MAP_HARMONDALE
+  {MAP_DEYJA,      MAP_BRAKADA_DESERT, MAP_HARMONDALE,   MAP_TATALIA},        // MAP_STEADWICK
+  {MAP_AVLEE,      MAP_HARMONDALE,     MAP_INVALID,      MAP_DEYJA},          // MAP_PIERPONT
+  {MAP_PIERPONT,   MAP_STEADWICK,      MAP_PIERPONT,     MAP_STEADWICK},      // MAP_DEYJA
+  {MAP_STEADWICK,  MAP_INVALID,        MAP_BARROW_DOWNS, MAP_INVALID},        // MAP_BRAKADA_DESERT
+  {MAP_INVALID,    MAP_INVALID,        MAP_INVALID,      MAP_INVALID},        // MAP_CELESTIA
+  {MAP_INVALID,    MAP_INVALID,        MAP_INVALID,      MAP_INVALID},        // MAP_THE_PIT
+  {MAP_INVALID,    MAP_INVALID,        MAP_INVALID,      MAP_INVALID},        // MAP_EVENMORN_ISLE
+  {MAP_INVALID,    MAP_INVALID,        MAP_INVALID,      MAP_INVALID},        // MAP_MOUNT_NIGHON
+  {MAP_HARMONDALE, MAP_BRAKADA_DESERT, MAP_HARMONDALE,   MAP_BRAKADA_DESERT}, // MAP_BARROW_DOWNS
+  {MAP_INVALID,    MAP_INVALID,        MAP_INVALID,      MAP_INVALID},        // MAP_LAND_OF_GIANTS
+  {MAP_INVALID,    MAP_INVALID,        MAP_STEADWICK,    MAP_INVALID},        // MAP_TATALIA
+  {MAP_INVALID,    MAP_PIERPONT,       MAP_PIERPONT,     MAP_INVALID},        // MAP_AVLEE
+  {MAP_INVALID,    MAP_INVALID,        MAP_INVALID,      MAP_INVALID}         // MAP_SHOALS
+};
+unsigned char foot_travel_times[15][4] =
+{
+// north south east  west    from
+  {0,    0,    0,    0},  // MAP_EMERALD_ISLE
+  {5,    5,    7,    5},  // MAP_HARMONDALE
+  {5,    5,    5,    5},  // MAP_STEADWICK
+  {5,    5,    0,    5},  // MAP_PIERPONT
+  {7,    5,    5,    4},  // MAP_DEYJA
+  {5,    0,    5,    0},  // MAP_BRAKADA_DESERT
+  {0,    0,    0,    0},  // MAP_CELESTIA
+  {0,    0,    0,    0},  // MAP_THE_PIT
+  {0,    0,    0,    0},  // MAP_EVENMORN_ISLE
+  {0,    0,    0,    0},  // MAP_MOUNT_NIGHON
+  {5,    7,    7,    5},  // MAP_BARROW_DOWNS
+  {0,    0,    0,    0},  // MAP_LAND_OF_GIANTS
+  {0,    0,    5,    0},  // MAP_TATALIA
+  {0,    7,    5,    0},  // MAP_AVLEE
+  {0,    0,    0,    0},  // MAP_SHOALS
+};
+
+
+MapStartPoint foot_travel_arrival_points[15][4] =
+{
+// north                south                east                 west                     from
+  {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_EMERALD_ISLE
+  {MapStartPoint_South, MapStartPoint_North, MapStartPoint_South, MapStartPoint_East},  // MAP_HARMONDALE
+  {MapStartPoint_South, MapStartPoint_North, MapStartPoint_West,  MapStartPoint_East},  // MAP_STEADWICK
+  {MapStartPoint_East,  MapStartPoint_North, MapStartPoint_Party, MapStartPoint_East},  // MAP_PIERPONT
+  {MapStartPoint_West,  MapStartPoint_North, MapStartPoint_West,  MapStartPoint_North}, // MAP_DEYJA
+  {MapStartPoint_South, MapStartPoint_Party, MapStartPoint_West,  MapStartPoint_Party}, // MAP_BRAKADA_DESERT
+  {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_CELESTIA
+  {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_THE_PIT
+  {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_EVENMORN_ISLE
+  {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_MOUNT_NIGHON
+  {MapStartPoint_South, MapStartPoint_East,  MapStartPoint_South, MapStartPoint_East},  // MAP_BARROW_DOWNS
+  {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_LAND_OF_GIANTS
+  {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_West,  MapStartPoint_Party}, // MAP_TATALIA
+  {MapStartPoint_Party, MapStartPoint_North, MapStartPoint_North, MapStartPoint_Party}, // MAP_AVLEE
+  {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_SHOALS
+};
+
+
 //----- (0048902E) --------------------------------------------------------
 bool OutdoorLocation::GetTravelDestination(signed int sPartyX, signed int sPartyZ, char *pOut, signed int a5)
 {
   OutdoorLocation *v5; // esi@1
   char *v6; // eax@3
   int v7; // eax@3
-  int v8; // edx@3
+  //int v8; // edx@3
   signed int v9; // esi@7
-  int v10; // esi@23
+  //int v10; // esi@23
   signed int v11; // eax@23
-  int v12; // ST14_4@25
+  //int v12; // ST14_4@25
   signed int v14; // [sp-4h] [bp-84h]@6
   char Str[140]; // [sp+8h] [bp-78h]@3
-  int a5a; // [sp+94h] [bp+14h]@3
+  //int a5a; // [sp+94h] [bp+14h]@3
 
   auto Source = this;
 
@@ -362,8 +426,8 @@
         v6 = strtok(Str, "out"),
         v6[2] = 0,
         v7 = atoi(v6),
-        v8 = v7,
-        a5a = v7,
+        //v8 = v7,
+        //a5a = v7,
         v7 < 1)
     || v7 > 15 )
     return 0;
@@ -390,18 +454,18 @@
 LABEL_14:
   if ( v7 == 14 )
   {
-    if ( v9 == 4 )
+    if ( v9 == 4 ) // to & from Shoals
     {
       if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(0) )
       {
         uDefaultTravelTime_ByFoot = 1;
         strcpy(pOut, "out15.odm");
-        uLevel_StartingPointType = 3;
+        uLevel_StartingPointType = MapStartPoint_East;
 LABEL_18:
         LOWORD(pParty->uFlags) &= 0xFD7Bu;
         return 1;
       }
-      v8 = a5a;
+      //v8 = v7;
     }
   }
   else
@@ -410,21 +474,24 @@
     {
       uDefaultTravelTime_ByFoot = 1;
       strcpy(pOut, "out14.odm");
-      uLevel_StartingPointType = 4;
+      uLevel_StartingPointType = MapStartPoint_West;
       goto LABEL_18;
     }
   }
-  v10 = v9 + 4 * v8;
-  v11 = (unsigned __int8)aTiletableLoadU[v10 + 39];
-  if ( v11 >= 1 && v11 <= 15 )
-  {
-    v12 = (unsigned __int8)aTiletableLoadU[v10 + 39];
-    uDefaultTravelTime_ByFoot = (unsigned __int8)byte_4ECA93[v10];
-    sprintf(pOut, "out%02d.odm", v12);
-    uLevel_StartingPointType = (unsigned __int8)byte_4ECACF[v10];
-    return 1;
-  }
-  return 0;
+  //v10 = v9 + 4 * v7;
+  //v11 = (unsigned __int8)aTiletableLoadU[v10 + 39];
+  v11 = foot_travel_destinations[v7 - 1][v9 - 1];
+  if (v11 == MAP_INVALID)
+    return false;
+
+  assert(v11 <= MAP_SHOALS);
+
+  uDefaultTravelTime_ByFoot = foot_travel_times[v7 - 1][v9 - 1];
+  uLevel_StartingPointType = foot_travel_arrival_points[v7 - 1][v9 - 1];
+  sprintf(pOut, "out%02d.odm", v11);
+  return 1;
+  //}
+  //return 0;
 }
 // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot;
 // 6BE35C: using guessed type int uLevel_StartingPointType;