Moved the code of set_map_time_multi to WorldmapOps.hpp, and NPCAutoLevel to PartyControl.cpp.

Removed validate_test example function from release builds.
This commit is contained in:
NovaRain
2019-02-27 12:27:22 +08:00
parent 730cd212a4
commit 68a345f398
9 changed files with 66 additions and 58 deletions
+18 -5
View File
@@ -31,6 +31,8 @@
#include "HeroAppearance.h"
#include "PartyControl.h"
bool npcAutoLevelEnabled;
static DWORD Mode;
static int IsControllingNPC = 0;
static bool SkipCounterAnim = false;
@@ -131,8 +133,8 @@ static void TakeControlOfNPC(TGameObj* npc) {
CritterPcSetName(CritterName(npc));
// change level
int level = IsPartyMember(npc)
? PartyMemberGetCurrentLevel(npc)
int level = IsPartyMember(npc)
? PartyMemberGetCurrentLevel(npc)
: 0;
*ptr_Level_ = level;
@@ -214,7 +216,7 @@ static int _stdcall CombatWrapperInner(TGameObj* obj) {
// save "real" dude state
SaveRealDudeState();
TakeControlOfNPC(obj);
// Do combat turn
int turnResult = CombatTurn(obj);
@@ -393,9 +395,18 @@ static void __declspec(naked) gdControlUpdateInfo_hook() {
}
}
static void NpcAutoLevelPatch() {
npcAutoLevelEnabled = GetPrivateProfileIntA("Misc", "NPCAutoLevel", 0, ini) != 0;
if (npcAutoLevelEnabled) {
dlog("Applying NPC autolevel patch.", DL_INIT);
SafeWrite8(0x495CFB, 0xEB); // jmps 0x495D28 (skip random check)
dlogr(" Done", DL_INIT);
}
}
void PartyControlInit() {
Mode = GetPrivateProfileIntA("Misc", "ControlCombat", 0, ini);
if (Mode > 2)
if (Mode > 2)
Mode = 0;
if (Mode > 0) {
char pidbuf[512];
@@ -405,7 +416,7 @@ void PartyControlInit() {
char* comma;
while (true) {
comma = strchr(ptr, ',');
if (!comma)
if (!comma)
break;
*comma = 0;
if (strlen(ptr) > 0)
@@ -429,6 +440,8 @@ void PartyControlInit() {
} else
dlogr(" Disabled.", DL_INIT);
NpcAutoLevelPatch();
SkipCounterAnim = (GetPrivateProfileIntA("Misc", "SpeedInterfaceCounterAnims", 0, ini) == 3);
// display party member's current level & AC & addict flag
+4 -1
View File
@@ -15,9 +15,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
extern bool npcAutoLevelEnabled;
void PartyControlInit();
void __stdcall PartyControlReset();
int __stdcall PartyControl_SwitchHandHook(TGameObj* item);
bool IsNpcControlled();
bool IsNpcControlled();
+2
View File
@@ -404,7 +404,9 @@ static const SfallOpcodeMetadata opcodeMetaArray[] = {
{sf_set_outline, "set_outline", {DATATYPE_MASK_VALID_OBJ, DATATYPE_MASK_INT}},
{sf_spatial_radius, "spatial_radius", {DATATYPE_MASK_VALID_OBJ}},
{sf_unjam_lock, "unjam_lock", {DATATYPE_MASK_VALID_OBJ}},
#ifndef NDEBUG
{sf_test, "validate_test", {DATATYPE_MASK_INT, DATATYPE_MASK_INT | DATATYPE_MASK_FLOAT, DATATYPE_MASK_STR, DATATYPE_NONE}},
#endif
//{op_message_str_game, {}}
};
+4 -4
View File
@@ -13,14 +13,14 @@
// rscript - 32-bit register where script pointer will be put (it is used for several related functions)
#define _OP_BEGIN(rscript) __asm \
{ \
__asm pushad \
__asm mov rscript, eax \
__asm pushad \
__asm mov rscript, eax \
}
#define _OP_END __asm \
{ \
__asm popad \
__asm retn \
__asm popad \
__asm retn \
}
/*
+5 -2
View File
@@ -50,9 +50,9 @@ static MetaruleTableType metaruleTable;
// currently executed metarule
static const SfallMetarule* currentMetarule;
static std::string sf_test_stringBuf;
// Example handler. Feel free to add handlers in other files.
#ifndef NDEBUG
static std::string sf_test_stringBuf;
static void sf_test() {
std::ostringstream sstream;
sstream << "sfall_funcX(\"test\"";
@@ -79,6 +79,7 @@ static void sf_test() {
sf_test_stringBuf = sstream.str();
opHandler.setReturn(sf_test_stringBuf.c_str());
}
#endif
// returns current contents of metarule table
static void sf_get_metarule_table() {
@@ -135,7 +136,9 @@ static const SfallMetarule metaruleArray[] = {
{"spatial_radius", sf_spatial_radius, 1, 1},
{"tile_refresh_display", sf_tile_refresh_display, 0, 0},
{"unjam_lock", sf_unjam_lock, 1, 1},
#ifndef NDEBUG
{"validate_test", sf_test, 2, 5},
#endif
};
static void InitMetaruleTable() {
+1 -33
View File
@@ -25,6 +25,7 @@
#include "KillCounter.h"
#include "Knockback.h"
#include "movies.h"
#include "PartyControl.h"
#include "ScriptExtender.h"
/*
@@ -198,36 +199,6 @@ static void __declspec(naked) GameLoaded() {
}
}
void _stdcall SetMapMulti(float d);
static void __declspec(naked) set_map_time_multi() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_FLOAT;
jz paramWasFloat;
cmp dx, VAR_TYPE_INT;
jnz fail;
push eax;
fild dword ptr [esp];
fstp dword ptr [esp];
jmp end;
paramWasFloat:
push eax;
end:
call SetMapMulti;
fail:
pop edx;
pop ecx;
pop ebx;
retn;
}
}
static void __declspec(naked) SetPipBoyAvailable() {
__asm {
push ebx;
@@ -253,8 +224,6 @@ end:
}
}
// Kill counters
static void __declspec(naked) GetKillCounter() {
__asm {
@@ -273,7 +242,6 @@ static void __declspec(naked) GetKillCounter() {
mov edx, ds:[_pc_kill_counts+eax*4];
jmp end;
fail:
xor edx, edx;
end:
mov eax, ecx
+31
View File
@@ -211,6 +211,37 @@ end:
}
}
void _stdcall SetMapMulti(float d);
static void __declspec(naked) set_map_time_multi() {
__asm {
push ebx;
push ecx;
push edx;
mov ecx, eax;
call interpretPopShort_;
mov edx, eax;
mov eax, ecx;
call interpretPopLong_;
cmp dx, VAR_TYPE_FLOAT;
jz paramWasFloat;
cmp dx, VAR_TYPE_INT;
jnz fail;
push eax;
fild dword ptr [esp];
fstp dword ptr [esp];
jmp end;
paramWasFloat:
push eax;
end:
call SetMapMulti;
fail:
pop edx;
pop ecx;
pop ebx;
retn;
}
}
static void sf_set_map_enter_position() {
int tile = opHandler.arg(0).asInt();
int elev = opHandler.arg(1).asInt();
+1 -11
View File
@@ -82,9 +82,6 @@ char dfModelName[65];
static const char* musicOverridePath = "data\\sound\\music\\";
DWORD AddUnarmedStatToGetYear = 0;
bool npcAutoLevelEnabled;
static int* scriptDialog = nullptr;
static DWORD ViewportX;
@@ -1134,13 +1131,6 @@ static void DllMain2() {
DebugEditorInit();
npcAutoLevelEnabled = GetPrivateProfileIntA("Misc", "NPCAutoLevel", 0, ini) != 0;
if (npcAutoLevelEnabled) {
dlog("Applying NPC autolevel patch.", DL_INIT);
SafeWrite8(0x495CFB, 0xEB); // jmps 0x495D28 (skip random check)
dlogr(" Done", DL_INIT);
}
if (GetPrivateProfileIntA("Misc", "SingleCore", 1, ini)) {
dlog("Applying single core patch.", DL_INIT);
HANDLE process = GetCurrentProcess();
@@ -1443,7 +1433,7 @@ static void DllMain2() {
AIInit();
dlogr(" Done", DL_INIT);
dlogr("Initializing AI control.", DL_INIT);
dlogr("Initializing party control.", DL_INIT);
PartyControlInit();
if (GetPrivateProfileIntA("Misc", "ObjCanSeeObj_ShootThru_Fix", 0, ini)) {
-2
View File
@@ -70,8 +70,6 @@ extern DWORD modifiedIni;
extern char dmModelName[65];
extern char dfModelName[65];
extern bool npcAutoLevelEnabled;
DWORD GetAddedYears(bool isCheck = true);
void SetAddedYears(DWORD years);