From 16a576cd5bbcd8f329bdbbdd3c4ff792e562e9d6 Mon Sep 17 00:00:00 2001 From: Dennis Duda Date: Wed, 29 Aug 2018 01:46:18 +0200 Subject: [PATCH] Brought `GetLevelMTypes` very close to binary exact --- Source/engine.cpp | 2 +- Source/engine.h | 2 +- Source/monster.cpp | 22 +++++++++------------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Source/engine.cpp b/Source/engine.cpp index a35471015..2e05b395e 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -1843,7 +1843,7 @@ int __cdecl GetRndSeed() // 52B97C: using guessed type int sglGameSeed; // 52B998: using guessed type int SeedCount; -int __fastcall random(int idx, int v) +int __fastcall random(BYTE idx, int v) { if ( v <= 0 ) return 0; diff --git a/Source/engine.h b/Source/engine.h index 911ab5c3f..869b45cb0 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -45,7 +45,7 @@ void __fastcall DrawLine(int x0, int y0, int x1, int y1, char col); int __fastcall GetDirection(int x1, int y1, int x2, int y2); void __fastcall SetRndSeed(int s); int __cdecl GetRndSeed(); -int __fastcall random(int idx, int v); +int __fastcall random(BYTE idx, int v); void __cdecl engine_cpp_init_2(); void __cdecl mem_init_mutex(); void __cdecl mem_atexit_mutex(); diff --git a/Source/monster.cpp b/Source/monster.cpp index 94eed8176..594febba9 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -433,6 +433,7 @@ int __fastcall AddMonsterType(int type, int placeflag) InitMonsterGFX(i); InitMonsterSND(i); } + Monsters[i].mPlaceFlags |= placeflag; return i; } @@ -447,14 +448,9 @@ void __cdecl GetLevelMTypes() int minl; // min level int maxl; // max level - char mamask = 3; // monster availability mask? - - int nt; // number of types? + char mamask = 3; // monster availability mask - // TODO: local variable QuestMask that was referenced in the psx symbols - // didn't find any obvious use for that. the casing/naming of it hints at - // a PSX only variable - // maybe it was used instead of QuestStatus() on the console + int nt; // number of types AddMonsterType(MT_GOLEM, 2); if ( currlevel == 16 ) @@ -533,14 +529,13 @@ void __cdecl GetLevelMTypes() { for ( i = 0; i < nt; ) { - if ( monsterdata[typelist[i]].mType <= 4000 - monstimgtot ) - { - i++; - } - else + if ( monsterdata[typelist[i]].mType > 4000 - monstimgtot ) { typelist[i] = typelist[--nt]; + continue; } + + i++; } if ( nt != 0 ) @@ -556,8 +551,9 @@ void __cdecl GetLevelMTypes() else { if ( setlvlnum == SL_SKELKING ) + { AddMonsterType(MT_SKING, 4); - return; + } } }