Skip to content

Commit

Permalink
fixed imp dropping through the fog of war
Browse files Browse the repository at this point in the history
  • Loading branch information
DiaLight committed Nov 7, 2024
1 parent 7cacd7f commit c1ce22c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 39 deletions.
71 changes: 39 additions & 32 deletions mapping/DKII_EXE_v170.sgmap
Original file line number Diff line number Diff line change
Expand Up @@ -11427,7 +11427,7 @@ struct: id=instance_0066E3EC,path=dk2,name=CWorld_vtbl,size=920
type: kind=function,declspec=stdcall
ret: kind=ptr
type: kind=void
field: name=loc_509090
field: name=testCoordsInBounds_509090
type: kind=ptr
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True,winapi=BOOL,fname=BOOL
Expand Down Expand Up @@ -11521,10 +11521,12 @@ struct: id=instance_0066E3EC,path=dk2,name=CWorld_vtbl,size=920
arg: kind=int,size=4,signed=True
field: name=sub_509310
type: kind=ptr
type: kind=function,declspec=stdcall
ret: kind=int,size=4,signed=True
arg: kind=int,size=4,signed=True
arg: kind=int,size=4,signed=True
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True,winapi=BOOL,fname=BOOL
arg: kind=ptr
type: kind=struct,id=vtbl_0066E3EC
arg: kind=int,size=4
arg: kind=int,size=4
arg: kind=int,size=4,signed=True
arg: kind=int,size=4,signed=True
field: name=sub_509340
Expand Down Expand Up @@ -11672,15 +11674,15 @@ struct: id=instance_0066E3EC,path=dk2,name=CWorld_vtbl,size=920
arg: kind=ptr
type: kind=void
arg: kind=int,size=4,signed=True
field: name=sub_5095B0
field: name=getFirstMessage_5095B0
type: kind=ptr
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True
arg: kind=ptr
type: kind=struct,id=vtbl_0066E3EC
arg: kind=ptr
type: kind=struct,id=vtbl_0066D99C
field: name=sub_5095D0
field: name=findNextMessageByPlayer_5095D0
type: kind=ptr
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True
Expand Down Expand Up @@ -11789,7 +11791,7 @@ struct: id=instance_0066E3EC,path=dk2,name=CWorld_vtbl,size=920
ret: kind=int,size=1,signed=True,winapi=char
arg: kind=ptr
type: kind=int,size=1
field: name=CWorld::fun_510000
field: name=isCoordReachable_510000
type: kind=ptr
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True
Expand Down Expand Up @@ -14713,7 +14715,7 @@ struct: id=constructor_00491DC0,path=dk2/entities/data,name=MyCreatureDataObj,si
type: kind=int,size=2,signed=True
field: name=field_6CB
type: kind=int,size=2,signed=True
field: name=field_6CD
field: name=f6CD_crTypeStateTexts
type: kind=array,count=10
type: kind=int,size=2
field: name=field_6E1
Expand Down Expand Up @@ -17470,13 +17472,15 @@ struct: id=construct_00508AAC,path=dk2/world,name=MyPlayerMessageQueue,size=28
field: name=f4_world
type: kind=ptr
type: kind=struct,id=vtbl_0066E3EC
field: name=field_8
type: kind=int,size=4,signed=True
field: name=f8_first
type: kind=ptr
type: kind=struct,id=call_new_arr_004C40B6
field: name=fC_messagesPos
type: kind=ptr
type: kind=struct,id=call_new_arr_004C40B6
field: name=field_10
type: kind=int,size=4,signed=True
field: name=f10_messagesEnd
type: kind=ptr
type: kind=struct,id=call_new_arr_004C40B6
field: name=f14_messages
type: kind=ptr
type: kind=struct,id=call_new_arr_004C40B6
Expand Down Expand Up @@ -29104,7 +29108,7 @@ global: va=004508D0,name=fun_4508D0,size=50,member_of=vtbl_0066D3E4
arg: kind=ptr
type: kind=int,size=4,signed=True
arg: kind=int,size=4,signed=True
global: va=00450910,name=sub_450910,size=718
global: va=00450910,name=sub_450910,size=718,member_of=vtbl_0066D3E4
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True,winapi=BOOL,fname=BOOL
arg: kind=ptr
Expand Down Expand Up @@ -33315,7 +33319,7 @@ global: va=00492230,name=destructor,size=230,member_of=constructor_00491DC0
ret: kind=void
arg: kind=ptr
type: kind=struct,id=constructor_00491DC0
global: va=00492320,name=fun_492320,size=8252,member_of=constructor_00491DC0
global: va=00492320,name=loadCreatureType,size=8252,member_of=constructor_00491DC0
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True
arg: kind=ptr
Expand Down Expand Up @@ -37506,13 +37510,14 @@ global: va=004C43B0,name=saveToTbDiscFile,size=189,member_of=construct_00508AAC
arg: kind=ptr
type: kind=ptr
type: kind=struct,id=vtbl_0066F24C
global: va=004C4470,name=fun_4C4470,size=392,member_of=construct_00508AAC
global: va=004C4470,name=loadFromTbDiscFile,size=392,member_of=construct_00508AAC
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True
arg: kind=ptr
type: kind=struct,id=construct_00508AAC
arg: kind=ptr
type: kind=struct,id=constructor_00449470
type: kind=ptr
type: kind=struct,id=vtbl_0066F24C
global: va=004C4600,name=fun_4C4600,size=1214,member_of=construct_00508AAC
type: kind=function,declspec=thiscall
ret: kind=ptr
Expand All @@ -37538,16 +37543,19 @@ global: va=004C4B10,name=dump,size=89,member_of=construct_00508AAC
ret: kind=void
arg: kind=ptr
type: kind=struct,id=construct_00508AAC
global: va=004C4B70,name=sub_4C4B70,size=30
global: va=004C4B70,name=findMessage,size=30,member_of=construct_00508AAC
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True
ret: kind=ptr
type: kind=struct,id=call_new_arr_004C40B6
arg: kind=ptr
type: kind=int,size=4
type: kind=struct,id=construct_00508AAC
arg: kind=int,size=2,signed=True
global: va=004C4B90,name=sub_4C4B90,size=33
global: va=004C4B90,name=static_MyPlayerMessage_findNextByPlayer,size=33
type: kind=function,declspec=stdcall
ret: kind=int,size=4,signed=True
arg: kind=int,size=4,signed=True
ret: kind=ptr
type: kind=struct,id=call_new_arr_004C40B6
arg: kind=ptr
type: kind=struct,id=call_new_arr_004C40B6
global: va=004C4BC0,name=sub_4C4BC0,size=28
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True
Expand Down Expand Up @@ -37584,12 +37592,11 @@ global: va=004C53F0,name=fun_4C53F0,size=314,member_of=construct_00508AAC
arg: kind=int,size=2,signed=True
arg: kind=int,size=4,signed=True
arg: kind=int,size=4,signed=True
global: va=004C5530,name=sub_4C5530,size=192
global: va=004C5530,name=sub_4C5530,size=192,member_of=construct_00508AAC
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True
arg: kind=ptr
type: kind=ptr
type: kind=int,size=4
type: kind=struct,id=construct_00508AAC
arg: kind=int,size=2
arg: kind=int,size=4,signed=True
arg: kind=int,size=4,signed=True
Expand Down Expand Up @@ -42976,7 +42983,7 @@ global: va=00509050,name=fun_509050,size=51,member_of=vtbl_0066E3EC
arg: kind=int,size=4,signed=True
arg: kind=ptr
type: kind=int,size=4,signed=True
global: va=00509090,name=fun_509090,size=41,member_of=vtbl_0066E3EC
global: va=00509090,name=testCoordsInBounds,size=41,member_of=vtbl_0066E3EC
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True,winapi=BOOL,fname=BOOL
arg: kind=ptr
Expand Down Expand Up @@ -43065,7 +43072,7 @@ global: va=00509310,name=fun_509310,size=34,member_of=vtbl_0066E3EC
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True,winapi=BOOL,fname=BOOL
arg: kind=ptr
type: kind=int,size=1,signed=True,winapi=char
type: kind=struct,id=vtbl_0066E3EC
arg: kind=int,size=4
arg: kind=int,size=4
arg: kind=int,size=4,signed=True
Expand Down Expand Up @@ -43209,7 +43216,7 @@ global: va=005095B0,name=fun_5095B0,size=19,member_of=vtbl_0066E3EC
type: kind=function,declspec=thiscall
ret: kind=int,size=4,signed=True
arg: kind=ptr
type: kind=int,size=4
type: kind=struct,id=vtbl_0066E3EC
arg: kind=int,size=2,signed=True
global: va=005095D0,name=CWorld_5095D0,size=19
type: kind=function,declspec=stdcall
Expand Down Expand Up @@ -44066,9 +44073,9 @@ global: va=0050FD70,name=fun_50FD70,size=654,member_of=vtbl_0066E3EC
type: kind=struct,id=vtbl_0066E3EC
arg: kind=ptr,is_const=True
type: kind=int,size=1,signed=True,winapi=char
global: va=00510000,name=fun_510000,size=63,member_of=vtbl_0066E3EC
global: va=00510000,name=isCoordReachable,size=63,member_of=vtbl_0066E3EC
type: kind=function,declspec=thiscall
ret: kind=int,size=4
ret: kind=int,size=4,signed=True
arg: kind=ptr
type: kind=struct,id=vtbl_0066E3EC
arg: kind=int,size=4
Expand Down Expand Up @@ -45435,7 +45442,7 @@ global: va=0051F240,name=CWorld_loadCreature,size=357
type: kind=void
arg: kind=ptr
type: kind=struct,id=vtbl_0066E3EC
global: va=0051F3B0,name=fun_51F3B0,size=2292,member_of=constructor_00491DC0
global: va=0051F3B0,name=copy,size=2292,member_of=constructor_00491DC0
type: kind=function,declspec=thiscall
ret: kind=ptr
type: kind=struct,id=constructor_00491DC0
Expand Down
10 changes: 6 additions & 4 deletions src/dk2/CDefaultPlayerInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ BOOL __cdecl dk2::CDefaultPlayerInterface_onMouseAction(
}

namespace dk2 {
bool scheduleDropNextTick(CDefaultPlayerInterface *self, ObjUnderHand *a3_underHand) {
bool scheduleDropAfterTakingActionComplete(CDefaultPlayerInterface *self, ObjUnderHand *a3_underHand) {
if (!self->thingsInHand_count) return false;
CPI_ThingInHand *thingInHand = nullptr;
for (int i = 0; i < self->thingsInHand_count; ++i) {
Expand All @@ -209,6 +209,9 @@ namespace dk2 {
break;
}
if (thingInHand == nullptr) return false;
if(drop_thing_from_hand_fix::enabled) {
if (!self->pCWorld->v_isCoordReachable_510000(a3_underHand->x, a3_underHand->y)) return true;
}
if (self->checkAllowToDrop((CThing *) sceneObjects[thingInHand->tagId], a3_underHand->x, a3_underHand->y)) {
thingInHand->hasUnderHand = 1;
static_assert(sizeof(ObjUnderHand) == 0x22);
Expand Down Expand Up @@ -359,14 +362,13 @@ void dk2::CDefaultPlayerInterface::handleRightClick(unsigned int a2_isPressed, O
this->ingameCursor.sub_40ABC0(11, 0);
return;
}
if (scheduleDropNextTick(this, a3_underHand)) return;
if (scheduleDropAfterTakingActionComplete(this, a3_underHand)) return;
if (!this->pCWorld->v_hasThingsInHand_5094B0(this->playerTagId)) return;
int thingInHandIdx = this->pCWorld->v_getNumThingsInPlayerHand_5094D0(this->playerTagId) - 1;
uint16_t v36_thingInHandTagId;
if (!this->pCWorld->v_getThingInPlayerHand_5094F0(this->playerTagId, thingInHandIdx, &v36_thingInHandTagId)) return;
if (!this->pCWorld->v_fun_510000(a3_underHand->x, a3_underHand->y)) return;
if (!this->pCWorld->v_isCoordReachable_510000(a3_underHand->x, a3_underHand->y)) return;
CThing *thingInHand = (CThing *) sceneObjects[v36_thingInHandTagId];

if (!this->checkAllowToDrop(thingInHand, a3_underHand->x, a3_underHand->y)) return;
this->pushDropThingFromHandAction(thingInHand, a3_underHand);
}
Expand Down
6 changes: 3 additions & 3 deletions src/dk2/MyComputerPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ namespace dk2 {
else
v41_maxSize = v40_cworld->v_getCMapWidth_508FA0();
int v62_maxSize_x2 = 2 * v41_maxSize;
if (cp->world->v_loc_509090(v33_locX, v73_locY)) {
if (cp->world->v_testCoordsInBounds_509090(v33_locX, v73_locY)) {
CWorld *v42_cworld = cp->world;
MyMapElement *v43_mapElement = &v42_cworld->cmap.mapElements[v33_locX +
v73_locY * v42_cworld->cmap.width];
Expand All @@ -146,7 +146,7 @@ namespace dk2 {
do {
if (f3C_health) {
while (true) {
if (cp->world->v_loc_509090(v44_locX, v73_locY)) {
if (cp->world->v_testCoordsInBounds_509090(v44_locX, v73_locY)) {
CWorld *v48_cworld = cp->world;
MyMapElement *v49_mapElem = &v48_cworld->cmap.mapElements[
v44_locX + v73_locY * v48_cworld->cmap.width];
Expand All @@ -171,7 +171,7 @@ namespace dk2 {
}
} else {
while (true) {
if (cp->world->v_loc_509090(v44_locX, v73_locY)) {
if (cp->world->v_testCoordsInBounds_509090(v44_locX, v73_locY)) {
CWorld *v45_cworld = cp->world;
MyMapElement *v46_mapElem = &v45_cworld->cmap.mapElements[
v44_locX + v73_locY * v45_cworld->cmap.width];
Expand Down
6 changes: 6 additions & 0 deletions src/tools/StackLimits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ ULONG_PTR GetThreadStackLimits(HANDLE hThread, ULONG_PTR &low) {

StackLimits::StackLimits() {}

//// windows 7 has no GetCurrentThreadStackLimits method
//void WINAPI GetCurrentThreadStackLimits(PULONG_PTR LowLimit, PULONG_PTR HighLimit) {
// NT_TIB *teb = (NT_TIB *) NtCurrentTeb();
// *LowLimit = *(PULONG_PTR) ((BYTE *) teb + 0xE0C); // DeallocationStack
// *HighLimit = (ULONG_PTR) teb->StackBase;
//}
void StackLimits::resolve() {
GetCurrentThreadStackLimits(&low, &high);
}
Expand Down

0 comments on commit c1ce22c

Please sign in to comment.