Renamed heads/ddraw2 to TalkingHeads/Graphics.

Added necessary defines to prepare TalkingHeads backporting.
Some code edits to AI.cpp, MainMenu.cpp, movies.cpp.
This commit is contained in:
NovaRain
2019-04-22 23:03:03 +08:00
parent 2e2d3f7946
commit cbe31e845c
13 changed files with 145 additions and 90 deletions
+45 -45
View File
@@ -16,30 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <hash_map>
#include "main.h"
#include "AI.h"
#include "FalloutEngine.h"
#include "SafeWrite.h"
#include <hash_map>
typedef stdext::hash_map<DWORD, DWORD> :: const_iterator iter;
static stdext::hash_map<DWORD,DWORD> targets;
static stdext::hash_map<DWORD,DWORD> sources;
DWORD _stdcall AIGetLastAttacker(DWORD target) {
iter itr=sources.find(target);
if(itr==sources.end()) return 0;
else return itr->second;
}
DWORD _stdcall AIGetLastTarget(DWORD source) {
iter itr=targets.find(source);
if(itr==targets.end()) return 0;
else return itr->second;
}
static void __fastcall CombatAttackHook(DWORD source, DWORD target) {
sources[target] = source;
targets[source] = target;
@@ -59,61 +48,72 @@ static void __declspec(naked) combat_attack_hook() {
}
}
static DWORD CombatDisabled;
static char CombatBlockedMessage[128];
static void _stdcall CombatBlocked() {
DisplayConsoleMessage(CombatBlockedMessage);
static DWORD combatDisabled;
void _stdcall AIBlockCombat(DWORD i) {
combatDisabled = i ? 1 : 0;
}
static const DWORD BlockCombatHook1Ret1=0x45F6B4;
static const DWORD BlockCombatHook1Ret2=0x45F6D7;
static char combatBlockedMessage[128];
static void _stdcall CombatBlocked() {
DisplayConsoleMessage(combatBlockedMessage);
}
static const DWORD BlockCombatHook1Ret1 = 0x45F6B4;
static const DWORD BlockCombatHook1Ret2 = 0x45F6D7;
static void __declspec(naked) BlockCombatHook1() {
__asm {
mov eax, CombatDisabled;
mov eax, combatDisabled;
test eax, eax;
jz end;
jz end;
call CombatBlocked;
jmp BlockCombatHook1Ret2;
jmp BlockCombatHook1Ret2;
end:
mov eax, 0x14;
jmp BlockCombatHook1Ret1;
mov eax, 0x14;
jmp BlockCombatHook1Ret1;
}
}
static void __declspec(naked) BlockCombatHook2() {
__asm {
mov eax, dword ptr ds:[_intfaceEnabled];
mov eax, dword ptr ds:[_intfaceEnabled];
test eax, eax;
jz end;
mov eax, CombatDisabled;
jz end;
mov eax, combatDisabled;
test eax, eax;
jz succeed;
pushad;
jz succeed;
push ecx;
push edx;
call CombatBlocked;
popad;
xor eax, eax;
jmp end;
pop edx;
pop ecx;
xor eax, eax;
retn;
succeed:
inc eax;
inc eax;
end:
retn;
}
}
void _stdcall AIBlockCombat(DWORD i) {
if(i) CombatDisabled=1;
else CombatDisabled=0;
}
void AIInit() {
//HookCall(0x42AE1D, ai_attack_hook);
//HookCall(0x42AE5C, ai_attack_hook);
HookCall(0x426A95, combat_attack_hook);
HookCall(0x42A796, combat_attack_hook);
MakeJump(0x45F6AF, BlockCombatHook1);
HookCall(0x4432A6, BlockCombatHook2);
GetPrivateProfileString("sfall", "BlockedCombat", "You cannot enter combat at this time.", CombatBlockedMessage, 128, translationIni);
HookCall(0x426A95, combat_attack_hook); // combat_attack_this_
HookCall(0x42A796, combat_attack_hook); // ai_attack_
MakeJump(0x45F6AF, BlockCombatHook1); // intface_use_item_
HookCall(0x4432A6, BlockCombatHook2); // game_handle_input_
GetPrivateProfileString("sfall", "BlockedCombat", "You cannot enter combat at this time.", combatBlockedMessage, 128, translationIni);
}
DWORD _stdcall AIGetLastAttacker(DWORD target) {
iter itr = sources.find(target);
return (itr != sources.end()) ? itr->second: 0;
}
DWORD _stdcall AIGetLastTarget(DWORD source) {
iter itr = targets.find(source);
return (itr != targets.end()) ? itr->second : 0;
}
void _stdcall AICombatStart() {
+15 -5
View File
@@ -27,7 +27,7 @@ long* ptr_pc_traits = reinterpret_cast<long*>(_pc_trait); // 2
DWORD* ptr_aiInfoList = reinterpret_cast<DWORD*>(_aiInfoList);
DWORD* ptr_ambient_light = reinterpret_cast<DWORD*>(_ambient_light);
DWORD* ptr_art = reinterpret_cast<DWORD*>(_art);
Art* ptr_art = reinterpret_cast<Art*>(_art);
DWORD* ptr_art_name = reinterpret_cast<DWORD*>(_art_name);
DWORD* ptr_art_vault_guy_num = reinterpret_cast<DWORD*>(_art_vault_guy_num);
DWORD* ptr_art_vault_person_nums = reinterpret_cast<DWORD*>(_art_vault_person_nums);
@@ -60,13 +60,14 @@ DWORD* ptr_Educated = reinterpret_cast<DWORD*>(_Educated);
DWORD* ptr_elevation = reinterpret_cast<DWORD*>(_elevation);
DWORD* ptr_Experience_ = reinterpret_cast<DWORD*>(_Experience_);
DWORD* ptr_fallout_game_time = reinterpret_cast<DWORD*>(_fallout_game_time);
DWORD* ptr_fidgetFID = reinterpret_cast<DWORD*>(_fidgetFID);
DWORD* ptr_flptr = reinterpret_cast<DWORD*>(_flptr);
DWORD* ptr_folder_card_desc = reinterpret_cast<DWORD*>(_folder_card_desc);
DWORD* ptr_folder_card_fid = reinterpret_cast<DWORD*>(_folder_card_fid);
DWORD* ptr_folder_card_title = reinterpret_cast<DWORD*>(_folder_card_title);
DWORD* ptr_folder_card_title2 = reinterpret_cast<DWORD*>(_folder_card_title2);
DWORD* ptr_frame_time = reinterpret_cast<DWORD*>(_frame_time);
char* ptr_free_perk = reinterpret_cast<char*>(_free_perk);
char* ptr_free_perk = reinterpret_cast<char*>(_free_perk);
DWORD* ptr_game_global_vars = reinterpret_cast<DWORD*>(_game_global_vars);
DWORD* ptr_game_user_wants_to_quit = reinterpret_cast<DWORD*>(_game_user_wants_to_quit);
DWORD* ptr_gcsd = reinterpret_cast<DWORD*>(_gcsd);
@@ -105,6 +106,7 @@ DWORD* ptr_last_button_winID = reinterpret_cast<DWORD*>(_last_button_wi
DWORD* ptr_last_level = reinterpret_cast<DWORD*>(_last_level);
DWORD* ptr_Level_ = reinterpret_cast<DWORD*>(_Level_);
DWORD* ptr_Lifegiver = reinterpret_cast<DWORD*>(_Lifegiver);
DWORD* ptr_lipsFID = reinterpret_cast<DWORD*>(_lipsFID);
DWORD* ptr_list_com = reinterpret_cast<DWORD*>(_list_com);
DWORD* ptr_list_total = reinterpret_cast<DWORD*>(_list_total);
DWORD* ptr_loadingGame = reinterpret_cast<DWORD*>(_loadingGame);
@@ -151,10 +153,10 @@ DWORD* ptr_patches = reinterpret_cast<DWORD*>(_patches);
DWORD* ptr_paths = reinterpret_cast<DWORD*>(_paths);
DWORD* ptr_pc_crit_succ_eff = reinterpret_cast<DWORD*>(_pc_crit_succ_eff);
DWORD* ptr_pc_kill_counts = reinterpret_cast<DWORD*>(_pc_kill_counts);
char* ptr_pc_name = reinterpret_cast<char*>(_pc_name);
char* ptr_pc_name = reinterpret_cast<char*>(_pc_name);
DWORD* ptr_pc_proto = reinterpret_cast<DWORD*>(_pc_proto);
DWORD* ptr_perk_data = reinterpret_cast<DWORD*>(_perk_data);
int** ptr_perkLevelDataList = reinterpret_cast<int**>(_perkLevelDataList);
int** ptr_perkLevelDataList = reinterpret_cast<int**>(_perkLevelDataList);
DWORD* ptr_pip_win = reinterpret_cast<DWORD*>(_pip_win);
DWORD* ptr_pipboy_message_file = reinterpret_cast<DWORD*>(_pipboy_message_file);
DWORD* ptr_pipmesg = reinterpret_cast<DWORD*>(_pipmesg);
@@ -169,7 +171,7 @@ DWORD* ptr_read_callback = reinterpret_cast<DWORD*>(_read_callback)
DWORD* ptr_RedColor = reinterpret_cast<DWORD*>(_RedColor);
DWORD* ptr_retvals = reinterpret_cast<DWORD*>(_retvals);
DWORD* ptr_rotation = reinterpret_cast<DWORD*>(_rotation);
DWORD* ptr_scr_size = reinterpret_cast<DWORD*>(_scr_size);
BoundRect* ptr_scr_size = reinterpret_cast<BoundRect*>(_scr_size);
DWORD* ptr_scriptListInfo = reinterpret_cast<DWORD*>(_scriptListInfo);
DWORD* ptr_skill_data = reinterpret_cast<DWORD*>(_skill_data);
DWORD* ptr_slot_cursor = reinterpret_cast<DWORD*>(_slot_cursor);
@@ -990,6 +992,14 @@ long __stdcall NewObjId() {
__asm call new_obj_id_;
}
FrmSubframeData* __fastcall FramePtr(FrmFrameData* frm, long frame, long direction) {
__asm {
mov ebx, direction;
mov eax, ecx;
call frame_ptr_;
}
}
// for the backported AmmoCostHook from 4.x
long __stdcall ItemWAnimWeap(TGameObj* item, DWORD hitMode) {
__asm {
+12 -2
View File
@@ -39,6 +39,7 @@
#define _background_volume 0x518E88
#define _bboxslot 0x5970E0
#define _bckgnd 0x5707A4
#define _bk_disabled 0x6AC780
#define _black_palette 0x663FD0
#define _bottom_line 0x664524
#define _btable 0x59E944
@@ -65,6 +66,7 @@
#define _cursor_line 0x664514
#define _dialog_target 0x518848
#define _dialog_target_is_party 0x51884C
#define _dialogue_head 0x518850
#define _dialogue_state 0x518714
#define _dialogue_switch_mode 0x518718
#define _displayMapList 0x41B560
@@ -74,6 +76,8 @@
#define _elevation 0x631D2C
#define _Experience_ 0x6681B4
#define _fallout_game_time 0x51C720
#define _fidgetFID 0x5186F4
#define _fidgetFp 0x5186FC
#define _flptr 0x614808
#define _folder_card_desc 0x5705CC
#define _folder_card_fid 0x5705B0
@@ -123,6 +127,8 @@
#define _last_level 0x5707B4
#define _Level_ 0x6681B0
#define _Lifegiver 0x570854
#define _lips_draw_head 0x519248
#define _lipsFID 0x518704
#define _list_com 0x56D394
#define _list_total 0x56D37C
#define _loadingGame 0x5194C4
@@ -260,7 +266,7 @@ extern long* ptr_pc_traits; // 2 of them
extern DWORD* ptr_aiInfoList;
extern DWORD* ptr_ambient_light;
extern DWORD* ptr_art;
extern Art* ptr_art;
extern DWORD* ptr_art_name;
extern DWORD* ptr_art_vault_guy_num;
extern DWORD* ptr_art_vault_person_nums;
@@ -293,6 +299,7 @@ extern DWORD* ptr_Educated;
extern DWORD* ptr_elevation;
extern DWORD* ptr_Experience_;
extern DWORD* ptr_fallout_game_time;
extern DWORD* ptr_fidgetFID;
extern DWORD* ptr_flptr;
extern DWORD* ptr_folder_card_desc;
extern DWORD* ptr_folder_card_fid;
@@ -338,6 +345,7 @@ extern DWORD* ptr_last_button_winID;
extern DWORD* ptr_last_level;
extern DWORD* ptr_Level_;
extern DWORD* ptr_Lifegiver;
extern DWORD* ptr_lipsFID;
extern DWORD* ptr_list_com;
extern DWORD* ptr_list_total;
extern DWORD* ptr_loadingGame;
@@ -403,7 +411,7 @@ extern DWORD* ptr_RedColor;
extern DWORD* ptr_retvals;
extern DWORD* ptr_rotation;
extern DWORD* ptr_sad;
extern DWORD* ptr_scr_size;
extern BoundRect* ptr_scr_size;
extern DWORD* ptr_scriptListInfo;
extern DWORD* ptr_skill_data;
extern DWORD* ptr_slot_cursor;
@@ -1010,6 +1018,8 @@ long __stdcall QueueFindFirst(TGameObj* object, long qType);
long __stdcall NewObjId();
FrmSubframeData* __fastcall FramePtr(FrmFrameData* frm, long frame, long direction);
// for the backported AmmoCostHook from 4.x
long __stdcall ItemWAnimWeap(TGameObj* item, DWORD hitMode);
long __stdcall ItemWComputeAmmoCost(TGameObj* item, DWORD* rounds);
+24 -1
View File
@@ -167,8 +167,28 @@ struct TProgram
};
#pragma pack(pop)
#pragma pack(push, 1)
struct Art {
long flags;
char path[16];
char* names;
long d18;
long total;
};
#pragma pack(pop)
// Bounding rectangle, used by tile_refresh_rect and related functions
#pragma pack(push, 1)
struct BoundRect {
long x;
long y;
long offx;
long offy;
};
#pragma pack(pop)
// structures for holding frms loaded with fallout2 functions
#pragma pack(push, 2)
#pragma pack(push, 1)
typedef class FrmSubframeData {
public:
WORD width;
@@ -176,8 +196,11 @@ public:
DWORD size;
WORD x;
WORD y;
BYTE data[1]; // begin frame data
} FrmSubframeData;
#pragma pack(pop)
#pragma pack(push, 2)
typedef class FrmFrameData {
public:
DWORD version; // version num
+1 -1
View File
@@ -38,9 +38,9 @@
#include "FalloutEngine.h"
#include "Graphics.h"
#include "heads.h"
#include "input.h"
#include "LoadGameHook.h"
#include "TalkingHeads.h"
#include "Version.h"
typedef HRESULT (_stdcall *DDrawCreateProc)(void*, IDirectDraw**, void*);
+1
View File
@@ -42,6 +42,7 @@
#include "skills.h"
#include "sound.h"
#include "SuperSave.h"
#include "TalkingHeads.h"
#include "version.h"
#define MAX_GLOBAL_SIZE (MaxGlobalVars * 12 + 4)
+31 -20
View File
@@ -41,50 +41,61 @@ static void __declspec(naked) MainMenuTextYHook() {
}
}
static const DWORD MainMenuTextRet = 0x4817B0;
#ifdef NDEBUG
static const char* VerString1 = "SFALL " VERSION_STRING;
#else
static const char* VerString1 = "SFALL " VERSION_STRING " Debug Build";
#endif
static DWORD OverrideColour;
static void __declspec(naked) FontColour() {
__asm {
cmp OverrideColour, 0;
je skip;
je skip;
mov eax, OverrideColour;
retn;
skip:
movzx eax, byte ptr ds:[0x6A8B33];
or eax, 0x6000000;
or eax, 0x6000000;
retn;
}
}
static const DWORD MainMenuTextRet = 0x4817B0;
static void __declspec(naked) MainMenuTextHook() {
__asm {
mov edi, [esp];
sub edi, 12; //shift yposition up by 12
mov [esp], edi;
mov ebp, ecx;
push eax;
mov esi, eax; // winptr
mov ebp, ecx; // keep xpos
mov edi, [esp]; // ypos
mov eax, edi;
sub eax, 12; // shift y position up by 12
mov [esp], eax;
call FontColour;
mov [esp+8], eax;
pop eax;
mov [esp + 4], eax; // colour
mov eax, esi;
mov esi, edx; // keep fallout buff
call win_print_;
// sfall print
mov eax, esi;
call ds:[_text_width];
add ebp, eax; // xpos shift (right align)
call FontColour;
push eax;//colour
mov edx, VerString1;//msg
xor ebx, ebx;//font
mov ecx, ebp;
dec ecx; //xpos
add edi, 12;
push edi; //ypos
mov eax, dword ptr ds:[_main_window];//winptr
push eax; // colour
mov edx, VerString1; // msg
mov eax, edx;
call ds:[_text_width];
mov ecx, ebp; // xpos
sub ecx, eax; // left shift position
push edi; // ypos
xor ebx, ebx; // font
mov eax, dword ptr ds:[_main_window]; // winptr
call win_print_;
jmp MainMenuTextRet;
jmp MainMenuTextRet;
}
}
void MainMenuInit() {
int offset;
if (offset = GetPrivateProfileIntA("Misc", "MainMenuCreditsOffsetX", 0, ini)) {
SafeWrite32(0x481753, 15 + offset);
}
+3 -3
View File
@@ -284,7 +284,7 @@
<ClInclude Include="FalloutStructs.h" />
<ClInclude Include="FileSystem.h" />
<ClInclude Include="Graphics.h" />
<ClInclude Include="heads.h" />
<ClInclude Include="TalkingHeads.h" />
<ClInclude Include="HeroAppearance.h" />
<ClInclude Include="HookScripts.h" />
<ClInclude Include="input.h" />
@@ -342,14 +342,14 @@
<ClCompile Include="Credits.cpp" />
<ClCompile Include="Criticals.cpp" />
<ClCompile Include="ddraw.cpp" />
<ClCompile Include="ddraw2.cpp" />
<ClCompile Include="Graphics.cpp" />
<ClCompile Include="DebugEditor.cpp" />
<ClCompile Include="dinput.cpp" />
<ClCompile Include="Elevators.cpp" />
<ClCompile Include="Explosions.cpp" />
<ClCompile Include="FalloutEngine.cpp" />
<ClCompile Include="FileSystem.cpp" />
<ClCompile Include="heads.cpp" />
<ClCompile Include="TalkingHeads.cpp" />
<ClCompile Include="HeroAppearance.cpp" />
<ClCompile Include="HookScripts.cpp" />
<ClCompile Include="Inventory.cpp" />
+9 -9
View File
@@ -106,9 +106,6 @@
<ClInclude Include="AnimationsAtOnceLimit.h">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="heads.h">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="main.h">
<Filter>Headers</Filter>
</ClInclude>
@@ -196,6 +193,9 @@
<ClInclude Include="DamageMod.h">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="TalkingHeads.h">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="Cpp11_emu.h">
<Filter>Headers</Filter>
</ClInclude>
@@ -219,9 +219,6 @@
<ClCompile Include="ddraw.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="ddraw2.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="DebugEditor.cpp">
<Filter>Source</Filter>
</ClCompile>
@@ -295,9 +292,6 @@
<ClCompile Include="AnimationsAtOnceLimit.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="heads.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="skills.cpp">
<Filter>Source</Filter>
</ClCompile>
@@ -337,6 +331,12 @@
<ClCompile Include="DamageMod.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="Graphics.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="TalkingHeads.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source</Filter>
</ClCompile>
+1
View File
@@ -59,6 +59,7 @@
#include "SpeedPatch.h"
#include "stats.h"
#include "SuperSave.h"
#include "TalkingHeads.h"
#include "Tiles.h"
#include "version.h"
+3 -4
View File
@@ -19,6 +19,7 @@
#include "main.h"
#include <vector> // should be above DX SDK includes to avoid warning 4995
#include <d3d9.h>
#include <dshow.h>
#include <Vmr9.h>
@@ -354,6 +355,7 @@ static std::vector<sDSSound*> loopingSounds;
DWORD playID = 0;
DWORD loopID = 0;
static HWND soundwindow = 0;
static void* musicLoopPtr = nullptr;
//static char playingMusicFile[256];
@@ -543,8 +545,6 @@ static bool __cdecl SoundFileLoad(DWORD called, const char* path) {
wchar_t buf[256];
mbstowcs_s(0, buf, path, 256);
//CleanupSounds();
bool found = false;
int len = wcslen(buf) - 3;
for (int i = 0; i < 3; i++) {
@@ -796,8 +796,7 @@ void MoviesInit() {
CreateSndWnd();
}
DWORD days;
days = SimplePatch<DWORD>(0x4A36EC, "Misc", "MovieTimer_artimer4", 360, 0);
DWORD days = SimplePatch<DWORD>(0x4A36EC, "Misc", "MovieTimer_artimer4", 360, 0);
days = SimplePatch<DWORD>(0x4A3747, "Misc", "MovieTimer_artimer3", 270, 0, days);
days = SimplePatch<DWORD>(0x4A376A, "Misc", "MovieTimer_artimer2", 180, 0, days);
Artimer1DaysCheckTimer = GetPrivateProfileIntA("Misc", "MovieTimer_artimer1", 90, ini);