Skip to content

Commit

Permalink
More debug
Browse files Browse the repository at this point in the history
  • Loading branch information
DMD authored and DMD committed Jan 29, 2018
1 parent cbef90b commit 98e79e5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
50 changes: 45 additions & 5 deletions TemplePlus/maps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "gamesystems/gamesystems.h"
#include "fade.h"
#include "gamesystems/legacymapsystems.h"
#include "infrastructure/tabparser.h"
#include "tig/tig_tabparser.h"

struct MapAddresses : temple::AddressTable {

Expand Down Expand Up @@ -75,12 +77,13 @@ class GameSystemReplacements : TempleFix
return orgField1C(conf);
};

static int JumpPointReset();
static int JumpPointModLoad();
static int JumpPointInit();

void apply() override
{

replaceFunction(0x100BDFE0, JumpPointReset);
replaceFunction(0x100BDFE0, JumpPointModLoad);

orgField1C = replaceFunction(0x1006FC60, field1c); // doesn't seem to get called anywhere, not even when editor mode is enabled. Possibly ripped out code.

Expand Down Expand Up @@ -172,11 +175,11 @@ bool Maps::GetJumpPoint(int id, JumpPoint& jumpPoint, bool withMapName) {
return result;
}

int GameSystemReplacements::JumpPointReset(){
int GameSystemReplacements::JumpPointModLoad(){

auto jmpPntTable = temple::GetPointer<IdxTable<JumpPoint>>(0x10BCAAA4);
auto jmpPntTable = temple::GetPointer<IdxTable<LgcyJumpPoint>>(0x10BCAAA4);

auto makeNewIdxTable = temple::GetRef<void(__cdecl)(IdxTable<JumpPoint>*, int, const char*, int)>(0x101EC620);
auto makeNewIdxTable = temple::GetRef<void(__cdecl)(IdxTable<LgcyJumpPoint>*, int, const char*, int)>(0x101EC620);

makeNewIdxTable(jmpPntTable, 0x18, "jumppoint.c", 117);

Expand All @@ -188,3 +191,40 @@ int GameSystemReplacements::JumpPointReset(){

return res;
}


IdxTableWrapper<LgcyJumpPoint> jmpPointIdxTable(0x10BCAAA4);
int GameSystemReplacements::JumpPointInit(){

for (auto it: jmpPointIdxTable){
auto data = it.data;
free(data->mapName);
}

auto jmpPntTable = temple::GetPointer<IdxTable<LgcyJumpPoint>>(0x10BCAAA4);
/*auto idxTableFree = temple::GetRef<void(__cdecl)(IdxTable<LgcyJumpPoint>*)>(0x101EC690);
auto makeNewIdxTable = temple::GetRef<void(__cdecl)(IdxTable<LgcyJumpPoint>*, int, const char*, int)>(0x101EC620);
*/
jmpPointIdxTable.free();
jmpPointIdxTable.newTable(sizeof LgcyJumpPoint, "jumppoint.c", 97);

TigTabParser tabFile;
auto jmpPtParser = temple::GetRef<TigTabLineParser>(0x100BDE90);
tabFile.Init(jmpPtParser);
tabFile.Open("rules\\jumppoint.tab");
tabFile.Process();

auto &jmpPointMaxId = temple::GetRef<int>(0x10BCAAB8);
jmpPointMaxId = 0;

for (auto it:jmpPointIdxTable){
auto data = it.data;
if (data->id > jmpPointMaxId){
jmpPointMaxId = data->id;
}
}

tabFile.Close();

return 1;
}
8 changes: 8 additions & 0 deletions TemplePlus/maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ struct JumpPoint {
int mapId;
locXY location;
};

struct LgcyJumpPoint {
int id;
char* mapName;
int mapId;
locXY location;
};

struct DayNightXfer
{
ObjectId objId;
Expand Down

0 comments on commit 98e79e5

Please sign in to comment.