diff --git a/.gitignore b/.gitignore index f22710a..2f9e1a1 100644 --- a/.gitignore +++ b/.gitignore @@ -90,7 +90,7 @@ venv.bak/ /tools/obj_research/ /libs/dkii_exe/api/ /install/ -/mapping/ida/entry.py +/src/dev/ **/genlib/*.exp **/genlib/*.lib **/genlib/*.def diff --git a/mapping/DKII_EXE_v170.sgmap b/mapping/DKII_EXE_v170.sgmap index 9c50d4e..46581c3 100644 --- a/mapping/DKII_EXE_v170.sgmap +++ b/mapping/DKII_EXE_v170.sgmap @@ -1078,10 +1078,7 @@ struct: id=constructor_00449470,name=CCamera,size=3794 field: name=field_D8E type: kind=int,size=4 field: name=field_D92 - type: kind=int,size=1,signed=True,winapi=char - field: name=gapD93 - type: kind=array,count=3 - type: kind=int,size=1 + type: kind=int,size=4,signed=True field: name=fD96_arrx3 type: kind=struct,id=vec_xyz field: name=gap_DA2 @@ -1977,7 +1974,7 @@ struct: id=vtbl_0066C4A4,name=CDefaultPlayerInterface,size=20273,vtable=instance type: kind=ptr type: kind=struct,id=constructor_00526020 field: name=f8__cpyToF10 - type: kind=int,size=2,signed=True + type: kind=int,size=2 field: name=fA__counter type: kind=int,size=4,signed=True field: name=gap_E @@ -2253,10 +2250,14 @@ struct: id=vtbl_0066C4A4,name=CDefaultPlayerInterface,size=20273,vtable=instance type: kind=struct,id=construct_00402752 field: name=field_1C1F type: kind=int,size=4,signed=True - field: name=gap_1C23 - type: kind=array,count=794 - type: kind=int,size=1 - field: name=field_1F3D + field: name=field_1C23 + type: kind=int,size=4,signed=True + field: name=f1C27_chatHistory + type: kind=array,count=3 + type: kind=struct,id=fill_00409E9D + field: name=f1F39__showChat + type: kind=int,size=4,signed=True + field: name=f1F3D type: kind=int,size=4,signed=True field: name=field_1F41 type: kind=int,size=4,signed=True @@ -6281,14 +6282,10 @@ struct: id=vtbl_0066EC84,name=CNetworkComponent,size=52,vtable=instance_0066EC84 vtable_value: va=00527790 struct: id=instance_0066EC84,name=CNetworkComponent_vtbl,size=24,super=instance_0066C45C struct: id=vtbl_0066D654,path=dk2/entities,name=CObject,size=393,vtable=instance_0066D654,super=vtbl_0066D5BC - field: name=f124_roomNodeX - type: kind=int,size=2 - field: name=f126_roomNodeY - type: kind=int,size=2 - field: name=f128_autoPlacedObjectNodeX - type: kind=int,size=2 - field: name=f12A_autoPlacedObjectNodeY - type: kind=int,size=2 + field: name=f124_roomNode + type: kind=struct,id=pos2us + field: name=f128_autoPlacedObjectNode + type: kind=struct,id=pos2us field: name=f12C_typeId type: kind=int,size=1 field: name=f12D_typeObj @@ -6793,13 +6790,13 @@ struct: id=vtbl_0066D99C,path=dk2/entities,name=CPlayer,size=4389,vtable=instanc type: kind=int,size=2 field: name=f3A_nextIdx type: kind=int,size=2 - field: name=f3C_ownedArea1 + field: name=f3C_ownedArea1__maxX type: kind=int,size=4,signed=True - field: name=f40_ownedArea2_dungeonHeartHealth + field: name=f40_ownedArea2_dungeonHeartHealth__maxY type: kind=int,size=4,signed=True - field: name=f44_ownedArea4 + field: name=f44_ownedArea4__minX type: kind=int,size=4,signed=True - field: name=f48_ownedArea3 + field: name=f48_ownedArea3__minY type: kind=int,size=4,signed=True field: name=f4C_torturedCreatureTypeList type: kind=int,size=2 @@ -7261,22 +7258,14 @@ struct: id=vtbl_0066DB7C,path=dk2/entities,name=CRoom,size=169,vtable=instance_0 type: kind=struct,id=constructor_004EAB70 field: name=f1D_playerId type: kind=int,size=2 - field: name=f1F_roomManagerNodeX - type: kind=int,size=2 - field: name=f21_roomManagerNodeY - type: kind=int,size=2 - field: name=f23_changedAreaRoomListNodeX - type: kind=int,size=2 - field: name=f25_changedAreaRoomListNodeY - type: kind=int,size=2 - field: name=f27_centrePosX - type: kind=int,size=2 - field: name=f29_centrePosY - type: kind=int,size=2 - field: name=f2B_navigationPosX - type: kind=int,size=1 - field: name=f2C_navigationPosY - type: kind=int,size=1 + field: name=f1F_roomManagerNode + type: kind=struct,id=pos2us + field: name=f23_changedAreaRoomListNode + type: kind=struct,id=pos2us + field: name=f27_centrePos + type: kind=struct,id=pos2us + field: name=f2B_navigationPos + type: kind=struct,id=pos2ub field: name=f2D_firstSlab type: kind=struct,id=pos2ub field: name=f2F_lastSlab @@ -11727,13 +11716,13 @@ struct: id=instance_0066E3EC,path=dk2,name=CWorld_vtbl,size=920 arg: kind=ptr type: kind=int,size=2 arg: kind=int,size=4,signed=True - field: name=sub_509560 + field: name=getWaterTerrainTypeId_509560 type: kind=ptr type: kind=function,declspec=thiscall ret: kind=int,size=1,signed=True,winapi=char arg: kind=ptr type: kind=int,size=1 - field: name=sub_509570 + field: name=getLavaTerrainTypeId_509570 type: kind=ptr type: kind=function,declspec=thiscall ret: kind=int,size=1,signed=True,winapi=char @@ -11970,11 +11959,12 @@ struct: id=instance_0066E3EC,path=dk2,name=CWorld_vtbl,size=920 type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True arg: kind=int,size=4,signed=True - field: name=CWorld::fun_511650 + field: name=CWorld_updateLevelScore type: kind=ptr type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True - arg: kind=int,size=4,signed=True + arg: kind=ptr + type: kind=void arg: kind=int,size=4,signed=True field: name=sub_509670 type: kind=ptr @@ -14039,6 +14029,14 @@ struct: id=construct_0062D2BB,path=dk2/text/render,name=MyCharRenderCtx,size=40 field: name=f24_pChrStart type: kind=ptr type: kind=struct,id=pos_xy +struct: id=fill_00409E9D,name=MyChatMessage,size=262 + field: name=field_0 + type: kind=int,size=4,signed=True + field: name=f4_msg + type: kind=array,count=127 + type: kind=int,size=2,signed=True + field: name=field_102 + type: kind=int,size=4,signed=True struct: id=call_new_00555576,name=MyCmdHandler,size=40 field: name=f0_str type: kind=ptr @@ -17564,11 +17562,11 @@ struct: id=constructor_004EBFE0,name=MyRooms,size=28 type: kind=int,size=2 field: name=f10__nextRoomId type: kind=int,size=2 - field: name=f12__counter + field: name=f12_roomsCount type: kind=int,size=4 - field: name=field_16 + field: name=f16__forceSetSceneIdx type: kind=int,size=4,signed=True - field: name=f1A__roomSceneObjId + field: name=f1A__forceRoomSceneIdx type: kind=int,size=2,signed=True struct: id=constructor_0057C420,name=MyScaledSurface,size=49 field: name=f0_idx @@ -18601,8 +18599,10 @@ struct: id=constructor_004F6570,path=dk2/entities/data,name=MyTerrainDataObj,siz field: name=field_51 type: kind=struct,id=constructor_00504D60 field: name=field_6C - type: kind=array,count=24 - type: kind=int,size=1,signed=True,winapi=char + type: kind=struct,id=vec_xyz + field: name=f78_gap + type: kind=array,count=12 + type: kind=int,size=1 field: name=field_84 type: kind=int,size=4,signed=True field: name=field_88 @@ -18620,9 +18620,9 @@ struct: id=constructor_004F6570,path=dk2/entities/data,name=MyTerrainDataObj,siz type: kind=int,size=2,signed=True field: name=field_185 type: kind=int,size=2,signed=True - field: name=field_187 + field: name=f187__extraMana type: kind=int,size=2,signed=True - field: name=field_189 + field: name=f189__deltaManaSpeed type: kind=int,size=2,signed=True field: name=field_18B type: kind=int,size=2,signed=True @@ -18652,10 +18652,10 @@ struct: id=constructor_004F6570,path=dk2/entities/data,name=MyTerrainDataObj,siz type: kind=int,size=1 field: name=field_1A9 type: kind=int,size=2,signed=True - field: name=f1AB_deltaHealth + field: name=f1AB_roomDeltaHealth + type: kind=int,size=2 + field: name=f1AD_roomSizeMultiplier type: kind=int,size=2 - field: name=field_1AD - type: kind=int,size=2,signed=True field: name=field_1AF type: kind=int,size=2,signed=True field: name=field_1B1 @@ -19314,9 +19314,56 @@ struct: id=constructor_0056F850,name=My_sub_56F850,size=152 type: kind=int,size=4,signed=True field: name=field_40 type: kind=int,size=4,signed=True - field: name=field_44 - type: kind=array,count=84 + field: name=field_44_config_start + type: kind=int,size=4,signed=True + field: name=field_48 + type: kind=int,size=4,signed=True + field: name=field_4C + type: kind=int,size=4 + field: name=field_50 + type: kind=int,size=4 + field: name=field_54 + type: kind=int,size=4 + field: name=field_58 + type: kind=int,size=4 + field: name=field_5C + type: kind=int,size=4 + field: name=field_60 + type: kind=int,size=4,signed=True + field: name=field_64 + type: kind=int,size=4 + field: name=field_68 + type: kind=int,size=4 + field: name=field_6C + type: kind=int,size=4 + field: name=field_70 + type: kind=int,size=4 + field: name=field_74 + type: kind=int,size=4 + field: name=field_78_minZoomLevel + type: kind=int,size=4 + field: name=field_7C_maxZoomLevel + type: kind=int,size=4 + field: name=field_80 + type: kind=int,size=4 + field: name=field_84 + type: kind=int,size=4 + field: name=field_88 + type: kind=int,size=4 + field: name=field_8C + type: kind=int,size=4 + field: name=f90_gap + type: kind=array,count=2 type: kind=int,size=1 + field: name=field_92 + type: kind=int,size=2,signed=True + field: name=field_94 + type: kind=int,size=2,signed=True + field: name=f96_gap + type: kind=array,count=1 + type: kind=int,size=1 + field: name=field_97_eos + type: kind=int,size=1,signed=True,winapi=char struct: id=arr_instance_006AC8A0,name=NameCfg,size=48 field: name=idx type: kind=int,size=4,signed=True @@ -20479,7 +20526,7 @@ struct: id=instance_006F2550,name=Obj6F2550,size=1202 field: name=field_40C type: kind=int,size=2,signed=True field: name=field_40E - type: kind=int,size=2,signed=True + type: kind=int,size=2 field: name=field_410 type: kind=int,size=1,signed=True,winapi=char field: name=field_411 @@ -20578,7 +20625,7 @@ struct: id=instance_006F2550,name=Obj6F2550,size=1202 type: kind=int,size=1,signed=True,winapi=char field: name=field_485 type: kind=int,size=4,signed=True - field: name=field_489 + field: name=f489__levelscore type: kind=int,size=4,signed=True field: name=field_48D type: kind=int,size=4,signed=True @@ -22753,10 +22800,12 @@ global: va=00409DA0,name=sub_409DA0,size=138 global: va=00409E30,name=CDefaultPlayerInterface_chatCallback,size=144 type: kind=function,declspec=cdecl ret: kind=int,size=4,signed=True - arg: kind=int,size=4,signed=True + arg: kind=ptr + type: kind=void arg: kind=ptr type: kind=int,size=4 - arg: kind=int,size=4,signed=True + arg: kind=ptr + type: kind=struct,id=vtbl_0066C4A4 global: va=00409EC0,name=fun_409EC0,size=101,member_of=vtbl_0066C4A4 type: kind=function,declspec=thiscall ret: kind=int,size=4,fname=DWORD @@ -27548,7 +27597,7 @@ global: va=00444970,name=sub_444970,size=1433,member_of=vtbl_0066CC94 type: kind=struct,id=first_visited_0043A6D6 global: va=00444F10,name=sub_444F10,size=4642,member_of=vtbl_0066CC94 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_0066CC94 arg: kind=int,size=4,signed=True @@ -28701,14 +28750,14 @@ global: va=0044FB50,name=sub_44FB50,size=234 arg: kind=int,size=4,signed=True arg: kind=int,size=4,signed=True arg: kind=int,size=4,signed=True -global: va=0044FC40,name=fun_44FC40,size=1645,member_of=vtbl_0066D3E4 +global: va=0044FC40,name=tickSlab,size=1645,member_of=vtbl_0066D3E4 type: kind=function,declspec=thiscall ret: kind=int,size=4 arg: kind=ptr type: kind=struct,id=vtbl_0066D3E4 arg: kind=int,size=4,signed=True arg: kind=int,size=4,signed=True - arg: kind=int,size=4,signed=True + arg: kind=int,size=4 arg: kind=int,size=4,signed=True arg: kind=int,size=4 arg: kind=int,size=4,signed=True @@ -29179,8 +29228,7 @@ global: va=004537E0,name=sub_4537E0,size=92,member_of=constructor_00452B30 arg: kind=int,size=1,signed=True,winapi=char arg: kind=ptr type: kind=ptr - type: kind=ptr - type: kind=void + type: kind=struct,id=vtbl_0066E3DC global: va=00453840,name=sub_453840,size=366,member_of=constructor_00452B30 type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True @@ -36203,7 +36251,7 @@ global: va=004BA420,name=moneyRoom_4BA420,size=767,member_of=vtbl_0066D99C arg: kind=int,size=4,signed=True arg: kind=int,size=4,signed=True arg: kind=int,size=4,signed=True -global: va=004BA720,name=sub_4BA720,size=171,member_of=vtbl_0066D99C +global: va=004BA720,name=updateOwnedArea,size=171,member_of=vtbl_0066D99C type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True arg: kind=ptr @@ -36526,10 +36574,11 @@ global: va=004BDFC0,name=sub_4BDFC0,size=167,member_of=vtbl_0066D99C ret: kind=int,size=2,signed=True arg: kind=ptr type: kind=struct,id=vtbl_0066D99C -global: va=004BE070,name=sub_4BE070,size=21 +global: va=004BE070,name=addDungeonArea,size=21,member_of=vtbl_0066D99C type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True - arg: kind=int,size=4,signed=True + arg: kind=ptr + type: kind=struct,id=vtbl_0066D99C arg: kind=int,size=4,signed=True global: va=004BE090,name=posessCreature_4BE090,size=229,member_of=vtbl_0066D99C type: kind=function,declspec=thiscall @@ -38784,7 +38833,7 @@ global: va=004D6CB0,name=Casino_cpp_4D6CB0,size=531 ret: kind=int,size=1 arg: kind=ptr type: kind=struct,id=vtbl_0066D524 -global: va=004D6ED0,name=sub_4D6ED0,size=504 +global: va=004D6ED0,name=Casino_sub_4D6ED0,size=504 type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True arg: kind=ptr @@ -38920,10 +38969,11 @@ global: va=004D8C70,name=sub_4D8C70,size=58,member_of=vtbl_0066DB7C ret: kind=int,size=2 arg: kind=ptr type: kind=struct,id=vtbl_0066DB7C -global: va=004D8CB0,name=sub_4D8CB0,size=423 +global: va=004D8CB0,name=Crypt_sub_4D8CB0,size=423 type: kind=function,declspec=thiscall ret: kind=int,size=1,signed=True,winapi=char - arg: kind=int,size=4,signed=True + arg: kind=ptr + type: kind=struct,id=vtbl_0066DB7C global: va=004D8E60,name=sub_4D8E60,size=1041,member_of=vtbl_0066DB7C type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True @@ -39170,7 +39220,7 @@ global: va=004DD530,name=sub_4DD530,size=132,member_of=vtbl_0066DB7C ret: kind=int,size=1,signed=True,winapi=char arg: kind=ptr type: kind=struct,id=vtbl_0066DB7C -global: va=004DD5C0,name=sub_4DD5C0,size=260 +global: va=004DD5C0,name=Graveyard_sub_4DD5C0,size=260 type: kind=function,declspec=thiscall ret: kind=int,size=4 arg: kind=ptr @@ -39206,7 +39256,7 @@ global: va=004DDD70,name=tickGuardPost,size=271,member_of=vtbl_0066DB7C ret: kind=int,size=4,signed=True arg: kind=ptr type: kind=struct,id=vtbl_0066DB7C -global: va=004DDE80,name=sub_4DDE80,size=417 +global: va=004DDE80,name=GuardPost_sub_4DDE80,size=417 type: kind=function,declspec=thiscall ret: kind=int,size=1,signed=True,winapi=char arg: kind=ptr @@ -39246,7 +39296,7 @@ global: va=004DE220,name=Hatchery_cpp_4DE220,size=817 type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True arg: kind=ptr - type: kind=int,size=1,signed=True,winapi=char + type: kind=struct,id=vtbl_0066DB7C global: va=004DE560,name=sub_4DE560,size=112,member_of=vtbl_0066DB7C type: kind=function,declspec=thiscall ret: kind=int,size=1,signed=True,winapi=char @@ -39645,10 +39695,12 @@ global: va=004E3290,name=sub_4E3290,size=42,member_of=vtbl_0066DB7C type: kind=struct,id=vtbl_0066DB7C arg: kind=ptr type: kind=int,size=4 -global: va=004E32C0,name=sub_4E32C0,size=768 +global: va=004E32C0,name=Prison_sub_4E32C0,size=768 type: kind=function,declspec=thiscall - ret: kind=int,size=4,signed=True - arg: kind=int,size=4,signed=True + ret: kind=ptr + type: kind=struct,id=vtbl_0066D454 + arg: kind=ptr + type: kind=struct,id=vtbl_0066DB7C global: va=004E35C0,name=sub_4E35C0,size=179,member_of=vtbl_0066DB7C type: kind=function,declspec=thiscall ret: kind=int,size=1,signed=True,winapi=char @@ -39676,7 +39728,7 @@ global: va=004E3800,name=init,size=440,member_of=vtbl_0066DB7C type: kind=struct,id=vtbl_0066DB7C arg: kind=int,size=4,signed=True arg: kind=int,size=2 -global: va=004E39C0,name=sub_4E39C0,size=326,member_of=vtbl_0066DB7C +global: va=004E39C0,name=cleanup,size=326,member_of=vtbl_0066DB7C type: kind=function,declspec=thiscall ret: kind=int,size=2,signed=True arg: kind=ptr @@ -39748,16 +39800,17 @@ global: va=004E443C,name=jpt_4E438A,size=36 global: va=004E4460,name=idt_4E4384,size=26 type: kind=array,count=26 type: kind=int,size=1 -global: va=004E4480,name=sub_4E4480,size=91,member_of=vtbl_0066DB7C +global: va=004E4480,name=tickChangeSize,size=91,member_of=vtbl_0066DB7C type: kind=function,declspec=thiscall ret: kind=ptr type: kind=int,size=1,signed=True,winapi=char arg: kind=ptr type: kind=struct,id=vtbl_0066DB7C -global: va=004E44E0,name=sub_4E44E0,size=128 +global: va=004E44E0,name=sub_4E44E0,size=128,member_of=vtbl_0066DB7C type: kind=function,declspec=thiscall ret: kind=int,size=2 - arg: kind=int,size=4,signed=True + arg: kind=ptr + type: kind=struct,id=vtbl_0066DB7C global: va=004E4560,name=jpt_4E451C,size=40 type: kind=array,count=10 type: kind=ptr @@ -39830,8 +39883,7 @@ global: va=004E52F0,name=getPlayer,size=14,member_of=vtbl_0066DB7C type: kind=struct,id=vtbl_0066DB7C global: va=004E5300,name=updateHealth,size=156,member_of=vtbl_0066DB7C type: kind=function,declspec=thiscall - ret: kind=ptr - type: kind=struct,id=constructor_004F6570 + ret: kind=void arg: kind=ptr type: kind=struct,id=vtbl_0066DB7C arg: kind=ptr @@ -39920,11 +39972,10 @@ global: va=004E6220,name=fun_4E6220,size=164,member_of=vtbl_0066DB7C arg: kind=ptr type: kind=struct,id=vtbl_0066DB7C arg: kind=int,size=4,signed=True -global: va=004E62D0,name=fun_4E62D0,size=166,member_of=vtbl_0066DB7C +global: va=004E62D0,name=unlinkObject,size=166,member_of=vtbl_0066DB7C type: kind=function,declspec=thiscall ret: kind=ptr - type: kind=ptr - type: kind=void + type: kind=struct,id=pos2us arg: kind=ptr type: kind=struct,id=vtbl_0066DB7C arg: kind=ptr @@ -39981,7 +40032,7 @@ global: va=004E6A20,name=Room_cpp_4E6A20,size=415 type: kind=struct,id=vtbl_0066DB7C arg: kind=ptr type: kind=int,size=4 -global: va=004E6BC0,name=removeObject,size=64,member_of=vtbl_0066DB7C +global: va=004E6BC0,name=removeObjectsInRoom,size=64,member_of=vtbl_0066DB7C type: kind=function,declspec=thiscall ret: kind=int,size=2 arg: kind=ptr @@ -40287,7 +40338,7 @@ global: va=004EC5A0,name=createRoomAndAttach,size=176,member_of=constructor_004E arg: kind=int,size=2,signed=True arg: kind=ptr type: kind=int,size=2 -global: va=004EC650,name=sub_4EC650__reattach0,size=676,member_of=constructor_004EBFE0 +global: va=004EC650,name=attachToNearRooms,size=676,member_of=constructor_004EBFE0 type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True arg: kind=ptr @@ -40312,7 +40363,7 @@ global: va=004EC900,name=sub_4EC900,size=619 arg: kind=int,size=4,signed=True arg: kind=ptr type: kind=int,size=1 -global: va=004ECB70,name=removeNearRoom,size=388,member_of=constructor_004EBFE0 +global: va=004ECB70,name=joinNearRoom,size=388,member_of=constructor_004EBFE0 type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True arg: kind=ptr @@ -40332,16 +40383,16 @@ global: va=004ECDB0,name=fun_4ECDB0,size=255,member_of=constructor_004EBFE0 type: kind=struct,id=constructor_004EBFE0 arg: kind=int,size=4,signed=True arg: kind=int,size=4,signed=True -global: va=004ECEB0,name=fun_4ECEB0,size=745,member_of=constructor_004EBFE0 +global: va=004ECEB0,name=calcRoomWallAlignmentMap,size=745,member_of=constructor_004EBFE0 type: kind=function,declspec=thiscall - ret: kind=int,size=1,signed=True,winapi=char + ret: kind=int,size=1 arg: kind=ptr type: kind=struct,id=constructor_004EBFE0 arg: kind=ptr type: kind=struct,id=vtbl_0066DB7C arg: kind=int,size=4,signed=True arg: kind=int,size=4,signed=True -global: va=004ED1A0,name=sub_4ED1A0__reattach2,size=378,member_of=constructor_004EBFE0 +global: va=004ED1A0,name=eventAttachAndReset,size=378,member_of=constructor_004EBFE0 type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True arg: kind=ptr @@ -40350,11 +40401,11 @@ global: va=004ED1A0,name=sub_4ED1A0__reattach2,size=378,member_of=constructor_00 arg: kind=int,size=4,signed=True arg: kind=int,size=4,signed=True arg: kind=int,size=2 - arg: kind=int,size=2 + arg: kind=int,size=1 arg: kind=ptr type: kind=int,size=1,signed=True,fname=int8_t arg: kind=int,size=4,signed=True -global: va=004ED320,name=sub_4ED320__reattach1,size=276,member_of=constructor_004EBFE0 +global: va=004ED320,name=attachToNearForceOrCreate,size=276,member_of=constructor_004EBFE0 type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True arg: kind=ptr @@ -40363,7 +40414,7 @@ global: va=004ED320,name=sub_4ED320__reattach1,size=276,member_of=constructor_00 arg: kind=int,size=4,signed=True arg: kind=int,size=4,signed=True arg: kind=int,size=2,signed=True - arg: kind=int,size=2 + arg: kind=int,size=1 arg: kind=ptr type: kind=int,size=1,signed=True,fname=int8_t arg: kind=ptr @@ -40372,7 +40423,7 @@ global: va=004ED320,name=sub_4ED320__reattach1,size=276,member_of=constructor_00 arg: kind=ptr type: kind=ptr type: kind=struct,id=vtbl_0066DB7C -global: va=004ED440,name=sub_4ED440__sailRoom2,size=873,member_of=constructor_004EBFE0 +global: va=004ED440,name=eventRemoveReset,size=873,member_of=constructor_004EBFE0 type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True arg: kind=ptr @@ -40382,7 +40433,7 @@ global: va=004ED440,name=sub_4ED440__sailRoom2,size=873,member_of=constructor_00 arg: kind=int,size=1,signed=True,winapi=char arg: kind=ptr type: kind=int,size=1,signed=True,fname=int8_t -global: va=004ED7B0,name=sub_4ED7B0__sailRoom,size=953,member_of=constructor_004EBFE0 +global: va=004ED7B0,name=removeAndSplit,size=953,member_of=constructor_004EBFE0 type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True arg: kind=ptr @@ -40394,7 +40445,7 @@ global: va=004ED7B0,name=sub_4ED7B0__sailRoom,size=953,member_of=constructor_004 type: kind=int,size=1,signed=True,fname=int8_t arg: kind=ptr type: kind=ptr - type: kind=struct,id=constructor_004EAB70 + type: kind=struct,id=vtbl_0066DB7C global: va=004EDB70,name=calcChecksum,size=60,member_of=constructor_004EBFE0 type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True @@ -40426,7 +40477,8 @@ global: va=004EDFC0,name=RoomManager_cpp_4EDFC0,size=4261,member_of=constructor_ ret: kind=int,size=1,signed=True,winapi=char arg: kind=ptr type: kind=struct,id=constructor_004EBFE0 - arg: kind=int,size=4,signed=True + arg: kind=ptr + type: kind=struct,id=vtbl_0066DB7C global: va=004EF068,name=jpt_4EE006,size=36 type: kind=array,count=9 type: kind=ptr @@ -40487,7 +40539,7 @@ global: va=004EF1F0,name=fun_4EF1F0,size=1004,member_of=constructor_004EBFE0 type: kind=struct,id=constructor_004EBFE0 arg: kind=ptr type: kind=struct,id=vtbl_0066DB7C -global: va=004EF5E0,name=fun_4EF5E0,size=212,member_of=constructor_004EBFE0 +global: va=004EF5E0,name=calcSpecialTileOffset,size=212,member_of=constructor_004EBFE0 type: kind=function,declspec=thiscall ret: kind=int,size=1 arg: kind=ptr @@ -40665,10 +40717,11 @@ global: va=004F1100,name=tickTemple,size=312,member_of=vtbl_0066DB7C ret: kind=int,size=4,signed=True arg: kind=ptr type: kind=struct,id=vtbl_0066DB7C -global: va=004F1240,name=sub_4F1240,size=858 +global: va=004F1240,name=Temple_sub_4F1240,size=858 type: kind=function,declspec=thiscall ret: kind=int,size=1,signed=True,winapi=char - arg: kind=int,size=4,signed=True + arg: kind=ptr + type: kind=struct,id=vtbl_0066DB7C global: va=004F15A0,name=sub_4F15A0,size=45,member_of=vtbl_0066DB7C type: kind=function,declspec=thiscall ret: kind=ptr @@ -40994,7 +41047,7 @@ global: va=004F5630,name=sub_4F5630,size=30 arg: kind=int,size=4,signed=True arg: kind=ptr type: kind=int,size=2 -global: va=004F5650,name=sub_4F5650,size=401 +global: va=004F5650,name=Workshop_sub_4F5650,size=401 type: kind=function,declspec=thiscall ret: kind=int,size=1,signed=True,winapi=char arg: kind=ptr @@ -42809,16 +42862,16 @@ global: va=00509540,name=fun_509540,size=20,member_of=vtbl_0066E3EC arg: kind=ptr type: kind=void arg: kind=int,size=4,signed=True -global: va=00509560,name=fun_509560,size=7,member_of=vtbl_0066E3EC +global: va=00509560,name=getWaterTerrainTypeId,size=7,member_of=vtbl_0066E3EC type: kind=function,declspec=thiscall ret: kind=int,size=1,signed=True,winapi=char arg: kind=ptr - type: kind=int,size=1 -global: va=00509570,name=fun_509570,size=7,member_of=vtbl_0066E3EC + type: kind=struct,id=vtbl_0066E3EC +global: va=00509570,name=getLavaTerrainTypeId,size=7,member_of=vtbl_0066E3EC type: kind=function,declspec=thiscall ret: kind=int,size=1,signed=True,winapi=char arg: kind=ptr - type: kind=int,size=1 + type: kind=struct,id=vtbl_0066E3EC global: va=00509580,name=fun_509580,size=37,member_of=vtbl_0066E3EC type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True @@ -43907,10 +43960,11 @@ global: va=00511640,name=fun_511640,size=7,member_of=vtbl_0066E3EC type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True arg: kind=int,size=4,signed=True -global: va=00511650,name=fun_511650,size=33,member_of=vtbl_0066E3EC +global: va=00511650,name=updateLevelScore,size=33,member_of=vtbl_0066E3EC type: kind=function,declspec=thiscall ret: kind=int,size=4,signed=True - arg: kind=int,size=4,signed=True + arg: kind=ptr + type: kind=struct,id=vtbl_0066E3EC arg: kind=int,size=4,signed=True global: va=00511680,name=clearChecksums,size=219,member_of=vtbl_0066E3EC type: kind=function,declspec=thiscall @@ -79773,6 +79827,9 @@ global: va=006BB210,name=Main_LoadGame_BtnArr,size=640 global: va=006BC350,name=g_deltaLocs,size=32 type: kind=array,count=4 type: kind=struct,id=pos_xy +global: va=006BC370,name=g_aroundDeltaLocs,size=64 + type: kind=array,count=8 + type: kind=struct,id=pos_xy global: va=006BC430,name=g_majorVersion,size=4 type: kind=int,size=4 global: va=006BC434,name=g_minorVersion,size=4 diff --git a/readme.md b/readme.md index 0382e5b..c2d626e 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,5 @@ -Flame is a new approach to modifying compiled code Dungeon Keeper 2 +# Flame +A new approach to modifying the compiled code of Dungeon Keeper 2 Flame recompiles some functions of `DKII.EXE` into a separate `.exe` file. Then it merges this file with the original `.exe` file, replacing the references to @@ -8,26 +9,34 @@ Recompiled functions are supplemented with switchable changes that fix some game [Earlier](https://github.com/DiaLight/Flame/tree/46e5b0c1df93060bd01a83bb6d14d064e9c8c3dc "Full relinking approach"), this project implemented an approach to fully relinking `DKII.EXE`, which contains false positive references that caused new bugs. -The latest build can be taken from the github actions +## How to install +- download `flame.zip` file from github actions https://github.com/DiaLight/Flame/actions +- copy `DKII-Flame-1.7.0-*.exe` from `flame.zip` to game directory (no need rename to DKII-DX.exe or DKII.exe. exe name does not matter) +- (optional, but recommended) copy `Data` directory from `flame.zip` with replacement to the game directory +- (optional, but recommended) copy `ddraw.dll` from `flame.zip` to the game directory +- run `DKII-Flame-1.7.0-*.exe` -How to install: -- copy DKII-Flame-1.7.0-*.exe from github actions to game directory (no need rename to DKII-DX.exe or DKII.exe. exe name does not matter) -- (optional, but recommended) copy ddraw.dll from https://github.com/narzoul/DDrawCompat/releases/tag/v0.5.3 to game directory -- (optional, but recommended) copy dinput.dll from https://github.com/elishacloud/dinputto8/releases/tag/v1.0.54.0 to game directory -- run DKII-Flame-1.7.0-*.exe +The `DKII-Flame-1.7.0-*.map` file in the `flame.zip` file you dont need to copy. +I need it if I suddenly need to debug an old build -Additional ddraw.dll and dinput.dll are fixing some graphical bugs and i think improve general stability. -I prefer not spending time on fixing something that already fixed by other developers. -When report issue please ensure that you are uses these dlls. -The Steam version of the game is installed along with these dlls +The `Date` folder in the `flame.zip` file contains patches for some campaign maps taken from the link https://keeperklan.com/downloads.php?do=file&id=141 -Build requirements: +The `ddraw.dll` in the `flame.zip` file are taken from https://github.com/narzoul/DDrawCompat/releases/tag/v0.5.3 +It fixing some graphical bugs and i think improve general stability. +This dll is especially needed for those who observe graphic artifacts when starting the game +or whose game crashes immediately upon starting any game level +The Steam version of the game is installed along with this `ddraw.dll` + +If you have any bugs in the game, please describe them in the discord channel https://discord.gg/RvrQpCFUZc +When report issue please ensure that you are uses `ddraw.dll` + +## Build requirements - CMake 3.25 or higher https://cmake.org/download/ - Visual Studio 2022 - Dungeon Keeper II v1.70 (GOG/Steam version) - Python 3 https://www.python.org/downloads/windows/ -How to build: +## How to build - `mkdir build && cd build` - `"D:\Program Files\Visual Studio Community\2022\VC\Auxiliary\Build\vcvars32.bat"` - `cmake -DCMAKE_BUILD_TYPE=Release -GNinja -DCMAKE_INSTALL_PREFIX=../install ..` diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 9644f38..ac8a147 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -32,3 +32,7 @@ configure_file( @ONLY) set(DKII_RESOURCES_FILE ${CMAKE_CURRENT_BINARY_DIR}/resources.rc) + +install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/PatchLevels170/ DESTINATION Data/editor/maps) +install(FILES "${CMAKE_CURRENT_LIST_DIR}/DDrawCompat/ddraw.dll" DESTINATION ".") +install(FILES "${CMAKE_CURRENT_LIST_DIR}/readme.txt" DESTINATION ".") diff --git a/resources/DDrawCompat/ddraw.dll b/resources/DDrawCompat/ddraw.dll new file mode 100644 index 0000000..c9325bd Binary files /dev/null and b/resources/DDrawCompat/ddraw.dll differ diff --git a/resources/DDrawCompat/download-url.txt b/resources/DDrawCompat/download-url.txt new file mode 100644 index 0000000..e638990 --- /dev/null +++ b/resources/DDrawCompat/download-url.txt @@ -0,0 +1 @@ +https://github.com/narzoul/DDrawCompat/releases/tag/v0.5.3 diff --git a/resources/PatchLevels170/Level10Variables.kld b/resources/PatchLevels170/Level10Variables.kld new file mode 100644 index 0000000..80b6a7f Binary files /dev/null and b/resources/PatchLevels170/Level10Variables.kld differ diff --git a/resources/PatchLevels170/Level13Variables.kld b/resources/PatchLevels170/Level13Variables.kld new file mode 100644 index 0000000..b315910 Binary files /dev/null and b/resources/PatchLevels170/Level13Variables.kld differ diff --git a/resources/PatchLevels170/Level14Variables.kld b/resources/PatchLevels170/Level14Variables.kld new file mode 100644 index 0000000..4540027 Binary files /dev/null and b/resources/PatchLevels170/Level14Variables.kld differ diff --git a/resources/PatchLevels170/Level15aVariables.kld b/resources/PatchLevels170/Level15aVariables.kld new file mode 100644 index 0000000..0271d91 Binary files /dev/null and b/resources/PatchLevels170/Level15aVariables.kld differ diff --git a/resources/PatchLevels170/Level19Variables.kld b/resources/PatchLevels170/Level19Variables.kld new file mode 100644 index 0000000..60b95f2 Binary files /dev/null and b/resources/PatchLevels170/Level19Variables.kld differ diff --git a/resources/PatchLevels170/Level20Variables.kld b/resources/PatchLevels170/Level20Variables.kld new file mode 100644 index 0000000..902668f Binary files /dev/null and b/resources/PatchLevels170/Level20Variables.kld differ diff --git a/resources/PatchLevels170/Level9Variables.kld b/resources/PatchLevels170/Level9Variables.kld new file mode 100644 index 0000000..37db595 Binary files /dev/null and b/resources/PatchLevels170/Level9Variables.kld differ diff --git a/resources/PatchLevels170/download-url.txt b/resources/PatchLevels170/download-url.txt new file mode 100644 index 0000000..dc33899 --- /dev/null +++ b/resources/PatchLevels170/download-url.txt @@ -0,0 +1 @@ +https://keeperklan.com/downloads.php?do=file&id=141 diff --git a/resources/PatchLevels170/level11AVariables.kld b/resources/PatchLevels170/level11AVariables.kld new file mode 100644 index 0000000..f208f43 Binary files /dev/null and b/resources/PatchLevels170/level11AVariables.kld differ diff --git a/resources/PatchLevels170/level11BVariables.kld b/resources/PatchLevels170/level11BVariables.kld new file mode 100644 index 0000000..5361129 Binary files /dev/null and b/resources/PatchLevels170/level11BVariables.kld differ diff --git a/resources/PatchLevels170/level11CVariables.kld b/resources/PatchLevels170/level11CVariables.kld new file mode 100644 index 0000000..3107be4 Binary files /dev/null and b/resources/PatchLevels170/level11CVariables.kld differ diff --git a/resources/PatchLevels170/level12Variables.kld b/resources/PatchLevels170/level12Variables.kld new file mode 100644 index 0000000..308aecc Binary files /dev/null and b/resources/PatchLevels170/level12Variables.kld differ diff --git a/resources/PatchLevels170/level15bVariables.kld b/resources/PatchLevels170/level15bVariables.kld new file mode 100644 index 0000000..ec9d423 Binary files /dev/null and b/resources/PatchLevels170/level15bVariables.kld differ diff --git a/resources/PatchLevels170/level18Variables.kld b/resources/PatchLevels170/level18Variables.kld new file mode 100644 index 0000000..0922da5 Binary files /dev/null and b/resources/PatchLevels170/level18Variables.kld differ diff --git a/resources/PatchLevels170/level5Variables.kld b/resources/PatchLevels170/level5Variables.kld new file mode 100644 index 0000000..7b31326 Binary files /dev/null and b/resources/PatchLevels170/level5Variables.kld differ diff --git a/resources/PatchLevels170/level7Variables.kld b/resources/PatchLevels170/level7Variables.kld new file mode 100644 index 0000000..421261b Binary files /dev/null and b/resources/PatchLevels170/level7Variables.kld differ diff --git a/resources/readme.txt b/resources/readme.txt new file mode 100644 index 0000000..95cf95a --- /dev/null +++ b/resources/readme.txt @@ -0,0 +1,22 @@ +Flame - partial Dungeon Keeper 2 recompilation with bug fixes +source code: https://github.com/DiaLight/Flame + +How to install: +- copy `DKII-Flame-1.7.0-*.exe` to game directory (no need rename to DKII-DX.exe or DKII.exe. exe name does not matter) +- (optional, but recommended) copy `Data` directory with replacement to the game directory +- (optional, but recommended) copy `ddraw.dll` to the game directory +- run `DKII-Flame-1.7.0-*.exe` + +The `DKII-Flame-1.7.0-*.map` file you dont need to copy. +I need it if I suddenly need to debug an old build + +The `Date` folder contains patches for some campaign maps taken from the link https://keeperklan.com/downloads.php?do=file&id=141 + +The `ddraw.dll` are taken from https://github.com/narzoul/DDrawCompat/releases/tag/v0.5.3 +It fixing some graphical bugs and i think improve general stability. +This dll is especially needed for those who observe graphic artifacts when starting the game + or whose game crashes immediately upon starting any card +The Steam version of the game is installed along with this `ddraw.dll` + +If you have any bugs in the game, please describe them in the discord channel https://discord.gg/RvrQpCFUZc +When report issue please ensure that you are uses `ddraw.dll` diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 57e1215..13a8547 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,6 +15,7 @@ add_executable(${TARGET} dk2/MyComputerPlayer.cpp dk2/CRoom.cpp dk2/CBridge.cpp + dk2/CCamera.cpp dk2/button/button_types.cpp dk2/button/CTextInput.cpp dk2/entities/entities_type.cpp diff --git a/src/dk2/CCamera.cpp b/src/dk2/CCamera.cpp new file mode 100644 index 0000000..d64332c --- /dev/null +++ b/src/dk2/CCamera.cpp @@ -0,0 +1,26 @@ +// +// Created by DiaLight on 10.10.2024. +// +#include "dk2/CCamera.h" +#include "patches/micro_patches.h" + + +void dk2::CCamera::zoomRel_449CA0(int delta) { + if ((this->fD92 & 8) != 0 || this->endTime) return; + int min = this->minZoomLevel; + int max = this->maxZoomLevel - 1; + if(increase_zoom_level::enabled) { + max += 50000; + if(min > 2000) min -= 2000; + } + int newCur = delta + this->curZoomLevel; + this->curZoomLevel = newCur; + if (newCur <= min) + newCur = min; + if (newCur >= max) { + newCur = max; + } else if (newCur <= min) { + newCur = min; + } + this->curZoomLevel = newCur; +} diff --git a/src/dk2/CRoom.cpp b/src/dk2/CRoom.cpp index db19d6c..0905076 100644 --- a/src/dk2/CRoom.cpp +++ b/src/dk2/CRoom.cpp @@ -95,8 +95,8 @@ unsigned int dk2::CMap::attachToRoom( int a3_y, unsigned __int16 a4_roomObjId, __int16 a5_playerId, - int a6, - int a7) { + int a6_bool, + int a7_bool2) { int v8_y = a3_y; MyMapElement *v9_mapElem = &this->mapElements[a2_x + a3_y * this->width]; int v10_flags = g_MyTerrainDataObj_arr[v9_mapElem->arr6DA4A8_idx]->_flags; @@ -116,18 +116,17 @@ unsigned int dk2::CMap::attachToRoom( } v9_mapElem->fun_4559D0(a5_playerId); MyRoomDataObj *v11_roomDataObj = this->world->v_f98_50D0B0_getMyRoomDataObj(typeId); - this->fun_44FC40(a2_x, v8_y, (int) v11_roomDataObj->_terrainType, v9_mapElem->_playerIdFFF & 0xFFF, 0, a7); -// v9_mapElem->roomId = v9_mapElem->roomId ^ ((v9_mapElem->roomId ^ a4_roomObjId) & 0xFFF); + this->tickSlab(a2_x, v8_y, (int) v11_roomDataObj->_terrainType, v9_mapElem->_playerIdFFF & 0xFFF, 0, a7_bool2); v9_mapElem->_roomIdFFF = (v9_mapElem->_roomIdFFF & 0xF000) | (a4_roomObjId & 0xFFF); return this->sub_4522A0(a2_x, v8_y); } -int dk2::MyRooms::sub_4ED1A0__reattach2( +int dk2::MyRooms::eventAttachAndReset( int a2_x, int arg4_y, int a4_roomTypeId, unsigned __int16 a5_playerId, - unsigned __int16 a6_roomObjId, + unsigned __int8 a6_roomNum, int8_t *a7_pNearCountNeg, int a8) { if ((g_MyTerrainDataObj_arr[this->world->getMapElem(a2_x, arg4_y)->arr6DA4A8_idx]->_flags & 0x80) != 0) { @@ -148,39 +147,37 @@ int dk2::MyRooms::sub_4ED1A0__reattach2( } while ((int) p_y < (int) 0x6BC374); // } while ( (int)p_y < (int)&dword_6BC374 ); } - CRoom *v19[4]; - memset(v19, 0, sizeof(v19)); - CRoom *a3 = 0; - int v14 = this->sub_4ED320__reattach1(a2_x, arg4_y, a4_roomTypeId, a5_playerId, a6_roomObjId, a7_pNearCountNeg, &a3, v19); + CRoom *roomArr[4]; + memset(roomArr, 0, sizeof(roomArr)); + CRoom *a3_room = 0; + int v14 = this->attachToNearForceOrCreate(a2_x, arg4_y, a4_roomTypeId, a5_playerId, a6_roomNum, a7_pNearCountNeg, &a3_room, roomArr); if (wooden_bridge_burn_fix::enabled) { if (((BYTE) a4_roomTypeId) == CRoom_typeId_WoodenBridge) { CMap &map = this->world->cmap; map.mapElements[a2_x + arg4_y * map.width].roomSetBurnLevel(0); } } - CRoom *v15 = a3; + CRoom *v15 = a3_room; int arg4_ya = v14; - if (!a3) + if (!a3_room) return arg4_ya; if (a8 != 8) { - a3->orientation = a8; - v15 = a3; + a3_room->orientation = a8; + v15 = a3_room; } - v15->removeObject(); - this->fun_4ECEB0(a3, a2_x, arg4_y); - this->fun_4EF5E0(a3); - this->RoomManager_cpp_4EDFC0((int) a3); - a3->sub_4E4480(); + v15->removeObjectsInRoom(); + this->calcRoomWallAlignmentMap(a3_room, a2_x, arg4_y); + this->calcSpecialTileOffset(a3_room); + this->RoomManager_cpp_4EDFC0(a3_room); + a3_room->tickChangeSize(); if ((BYTE) a4_roomTypeId == 8 || (BYTE) a4_roomTypeId == 17 || (BYTE) a4_roomTypeId == 22) - ((CPlayer *) sceneObjects[(unsigned __int16) a5_playerId])->sub_4BA720(a2_x, arg4_y); + ((CPlayer *) sceneObjects[(unsigned __int16) a5_playerId])->updateOwnedArea(a2_x, arg4_y); return arg4_ya; } -#define MaxRoomCount (96 * 7) // 0x2A0 +#define MaxRoomCount (override_max_room_count::limit * 7) // 0x2A0 int dk2::MyRooms::createRooms(CWorld *a2_world) { - static_assert(0xA9 == sizeof(CRoom)); - static_assert(0x1BBA4u == (sizeof(CRoom) * 0x2A0 + 4)); DWORD *v3 = (DWORD *) __nh_malloc(sizeof(CRoom) * MaxRoomCount + 4, 1); //operator new(0x1BBA4u); CRoom *v4; if (v3) { @@ -209,17 +206,17 @@ int dk2::MyRooms::createRooms(CWorld *a2_world) { for (i = 0; i < MaxRoomCount; ++i) { CRoom *v7 = &this->CRoom_arr_p[i]; unsigned __int16 f0_tagId = v7->f0_tagId; - v7->roomManagerNodeX = 0; - v7->roomManagerNodeY = 0; + v7->roomManagerNode.x = 0; + v7->roomManagerNode.y = 0; CRoom *fA_CRoom_arr_p = this->CRoom_arr_p; fA_CRoom_arr_p[i].playerRoomListNodeX = 0; fA_CRoom_arr_p[i].playerRoomListNodeY = 0; CRoom *v10 = this->CRoom_arr_p; - v10[i].changedAreaRoomListNodeX = 0; - v10[i].changedAreaRoomListNodeY = 0; - ((CRoom *) sceneObjects[f0_tagId])->roomManagerNodeY = this->_nextRoomId; + v10[i].changedAreaRoomListNode.x = 0; + v10[i].changedAreaRoomListNode.y = 0; + ((CRoom *) sceneObjects[f0_tagId])->roomManagerNode.y = this->_nextRoomId; if (this->_nextRoomId) - ((CRoom *) sceneObjects[this->_nextRoomId])->roomManagerNodeX = f0_tagId; + ((CRoom *) sceneObjects[this->_nextRoomId])->roomManagerNode.x = f0_tagId; this->_nextRoomId = f0_tagId; } this->world = a2_world; @@ -233,13 +230,13 @@ int dk2::MyRooms::createRoom( int a2_roomTypeId, unsigned __int16 a3_playerId, unsigned __int16 *a4_pRoomObjId) { - if (this->_counter >= MaxRoomCount) + if (this->roomsCount >= MaxRoomCount) return 0; unsigned __int16 roomObjId; - if (this->f16) { - roomObjId = this->_roomSceneObjId; - this->f16 = 0; - this->_roomSceneObjId = 0; + if (this->_forceSetSceneIdx) { + roomObjId = this->_forceRoomSceneIdx; + this->_forceSetSceneIdx = 0; + this->_forceRoomSceneIdx = 0; } else { roomObjId = this->_nextRoomId; } @@ -247,27 +244,27 @@ int dk2::MyRooms::createRoom( return 0; CRoom *v6 = (CRoom *) sceneObjects[roomObjId]; // unlink X - if (v6->roomManagerNodeX) { - ((CRoom *) sceneObjects[((CRoom *) sceneObjects[roomObjId])->roomManagerNodeX])->roomManagerNodeY = v6->roomManagerNodeY; + if (v6->roomManagerNode.x) { + ((CRoom *) sceneObjects[((CRoom *) sceneObjects[roomObjId])->roomManagerNode.x])->roomManagerNode.y = v6->roomManagerNode.y; } else { - this->_nextRoomId = v6->roomManagerNodeY; + this->_nextRoomId = v6->roomManagerNode.y; } // unlink Y - if (((CRoom *) sceneObjects[roomObjId])->roomManagerNodeY) { - ((CRoom *) sceneObjects[((CRoom *) sceneObjects[roomObjId])->roomManagerNodeY])->roomManagerNodeX = ((CRoom *) sceneObjects[roomObjId])->roomManagerNodeX; + if (((CRoom *) sceneObjects[roomObjId])->roomManagerNode.y) { + ((CRoom *) sceneObjects[((CRoom *) sceneObjects[roomObjId])->roomManagerNode.y])->roomManagerNode.x = ((CRoom *) sceneObjects[roomObjId])->roomManagerNode.x; } CRoom *v7 = (CRoom *) sceneObjects[roomObjId]; - v7->roomManagerNodeX = 0; - v7->roomManagerNodeY = 0; + v7->roomManagerNode.x = 0; + v7->roomManagerNode.y = 0; __int16 f10__nextRoomId = this->_nextRoomId; if (roomObjId == f10__nextRoomId) this->_nextRoomId = f10__nextRoomId - 1; // link to list - ((CRoom *) sceneObjects[roomObjId])->roomManagerNodeY = this->firstRoomId; + ((CRoom *) sceneObjects[roomObjId])->roomManagerNode.y = this->firstRoomId; if (this->firstRoomId) - ((CRoom *) sceneObjects[this->firstRoomId])->roomManagerNodeX = roomObjId; + ((CRoom *) sceneObjects[this->firstRoomId])->roomManagerNode.x = roomObjId; this->firstRoomId = roomObjId; - this->_counter++; + this->roomsCount++; *a4_pRoomObjId = roomObjId; return 1; } @@ -288,18 +285,18 @@ int dk2::CPlayer::fun_4C5C30_buildRoom( if (!g_pCWorld->v_sub_509280(a2_x, a3_y, v11_playerId_and_roomTypeId, a4_roomTypeId)) return 0; } - size_t maxRoomLimit = 96; + uint8_t maxRoomLimit = 96; if (override_max_room_count::enabled) { maxRoomLimit = override_max_room_count::limit; } - int v9_roomNum = maxRoomLimit - this->numberOfRooms; + uint8_t numRoomsLeft = maxRoomLimit - this->numberOfRooms; int8_t roomsCountNeg; - if (!g_pCWorld->rooms.sub_4ED1A0__reattach2( + if (!g_pCWorld->rooms.eventAttachAndReset( a2_x, a3_y, a4_roomTypeId, this->f0_tagId, - v9_roomNum, + numRoomsLeft, &roomsCountNeg, a8_orientation)) return 0; @@ -330,13 +327,6 @@ namespace dk2 { if(visited.contains(x | (y << 8))) return false; return cmap.hasPlayerRoomWithType(x, y, typeId, playerId); } - bool hasNearPlayerRoomWithTypeExcept(int x, int y, char typeId, __int16 playerId, std::set &visited) { - if(hasPlayerRoomWithTypeExcept(x, y - 1, typeId, playerId, visited)) return true; - if(hasPlayerRoomWithTypeExcept(x + 1, y, typeId, playerId, visited)) return true; - if(hasPlayerRoomWithTypeExcept(x, y + 1, typeId, playerId, visited)) return true; - if(hasPlayerRoomWithTypeExcept(x - 1, y, typeId, playerId, visited)) return true; - return false; - } void travelRoom(int x, int y, char typeId, __int16 playerId, std::set &visited) { if(!hasPlayerRoomWithTypeExcept(x, y, typeId, playerId, visited)) return; visited.insert(x | (y << 8)); @@ -345,24 +335,6 @@ namespace dk2 { travelRoom(x, y + 1, typeId, playerId, visited); travelRoom(x - 1, y, typeId, playerId, visited); } - int getNewRoomsCountIfRemove(int x, int y) { - CRoom &room = *g_pCWorld->v_getMapElem(x, y)->getRoom(); - CMap &cmap = g_pCWorld->cmap; - if(!cmap.hasNearPlayerRoomWithType(x, y, room.typeId, room.playerId)) return -1; - - std::set visited; - visited.insert(x | (y << 8)); - Pos2ub pos = room.firstSlab; - size_t splitCount = 0; - while(pos.x || pos.y) { - if(!visited.contains(pos.x | (pos.y << 8))) { - travelRoom(pos.x, pos.y, room.typeId, room.playerId, visited); - splitCount++; - } - pos = cmap.mapElements[pos.x + pos.y * cmap.width].nextSlab; - } - return splitCount - 1; - } } int dk2::CPlayer::destroyRoom(int a2_x, int a3_y, int a4_bool) { @@ -372,25 +344,39 @@ int dk2::CPlayer::destroyRoom(int a2_x, int a3_y, int a4_bool) { MyMapElement *v7_mapElem = g_pCWorld->v_getMapElem(a2_x, v6_y); CRoom *room = v7_mapElem->getRoom(); int salePrice = (unsigned __int16) room->pRoomDataObj->_getSalePrice(); - size_t maxRoomLimit = 96; + uint8_t maxRoomLimit = 96; if (override_max_room_count::enabled) { maxRoomLimit = override_max_room_count::limit; } - int v9_roomNum = maxRoomLimit - this->numberOfRooms; + uint8_t numRoomsLeft = maxRoomLimit - this->numberOfRooms; - if(override_max_room_count::enabled && override_max_room_count::predictLimit) { - // trying predict limit reach on room destroy - if(v9_roomNum <= 4) { - int splitCount = getNewRoomsCountIfRemove(a2_x, a3_y); - if(v9_roomNum < splitCount) return false; + uint8_t roomTypeId = room->typeId; // remember now as room obj will be released + int8_t deltaRooms; + if(numRoomsLeft < 4) { // remove whole room + std::set visited; + travelRoom(a2_x, a3_y, room->typeId, room->playerId, visited); + deltaRooms = 0; + { + int8_t localDeltaRooms = 0; + if (!g_pCWorld->rooms.eventRemoveReset(a2_x, a3_y, 4, &localDeltaRooms)) return 0; + deltaRooms += localDeltaRooms; + visited.erase(a2_x | (a3_y << 8)); + } + if(deltaRooms > numRoomsLeft && !visited.empty()) { + salePrice *= visited.size(); + for(auto pos : visited) { + uint8_t x = pos; + uint8_t y = pos >> 8; + int8_t localDeltaRooms = 0; + if (!g_pCWorld->rooms.eventRemoveReset(x, y, 4, &localDeltaRooms)) return 0; + deltaRooms += localDeltaRooms; + } } + } else { + if (!g_pCWorld->rooms.eventRemoveReset(a2_x, v6_y, numRoomsLeft, &deltaRooms)) return 0; } - uint8_t roomTypeId = room->typeId; // room obj will be released - int8_t roomsCountNeg; - if (!g_pCWorld->rooms.sub_4ED440__sailRoom2(a2_x, v6_y, v9_roomNum, &roomsCountNeg)) - return 0; - this->numberOfRooms += roomsCountNeg; + this->numberOfRooms += deltaRooms; MyRoomDataObj *v9_roomDataObj = g_pCWorld->v_f98_50D0B0_getMyRoomDataObj(roomTypeId); MyTerrainDataObj *v10_terrainDataObj = g_pCWorld->v_f70_508DD0_getTerrainDataObj(v9_roomDataObj->_terrainType); Vec3i v15_vec; diff --git a/src/main.cpp b/src/main.cpp index 29dbe76..d5ca0f4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -265,9 +265,6 @@ int main(int argc, const char **argv) { exit(-1); } } - if(hasCmdOption(argv, argv + argc, "-experimental_predict_limit")) { - override_max_room_count::predictLimit = true; - } if(!hasCmdOption(argv, argv + argc, "-console")) { ::ShowWindow(::GetConsoleWindow(), SW_HIDE); } diff --git a/src/patches/dev/bridge_burn.txt b/src/patches/dev/bridge_burn.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/patches/dev/state_arays.txt b/src/patches/dev/state_arays.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/patches/dev/zoom_path.txt b/src/patches/dev/zoom_path.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/patches/micro_patches.cpp b/src/patches/micro_patches.cpp index 008684c..55f65f4 100644 --- a/src/patches/micro_patches.cpp +++ b/src/patches/micro_patches.cpp @@ -26,10 +26,10 @@ bool print_game_start_errors::enabled = true; bool creatures_setup_lair_fix::enabled = true; bool wooden_bridge_burn_fix::enabled = true; bool max_host_port_number_fix::enabled = true; +bool increase_zoom_level::enabled = true; bool override_max_room_count::enabled = true; -bool override_max_room_count::predictLimit = false; -size_t override_max_room_count::limit = 96; +uint8_t override_max_room_count::limit = 255; // default is 96 void use_wasd_by_default_patch::useAlternativeName(LPCSTR &lpValueName) { if(!use_wasd_by_default_patch::enabled) return; @@ -82,15 +82,28 @@ void fix_close_window::window_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lP } } +namespace { + bool appIsActive = false; +} bool hide_mouse_cursor_in_window::window_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { switch(Msg) { case WM_SETCURSOR: { - if (LOWORD(lParam) == HTCLIENT) { - SetCursor(NULL); - return true; + if(appIsActive) { + if (LOWORD(lParam) == HTCLIENT) { + SetCursor(NULL); + return true; + } } break; } + case WM_ACTIVATEAPP: + if (wParam) { // activated + SetCursor(NULL); + appIsActive = true; + } else { // deactivated + appIsActive = false; + } + break; } return false; } diff --git a/src/patches/micro_patches.h b/src/patches/micro_patches.h index e518922..668005a 100644 --- a/src/patches/micro_patches.h +++ b/src/patches/micro_patches.h @@ -60,10 +60,13 @@ namespace max_host_port_number_fix { extern bool enabled; } +namespace increase_zoom_level { + extern bool enabled; +} + namespace override_max_room_count { extern bool enabled; - extern bool predictLimit; - extern size_t limit; + extern uint8_t limit; } namespace use_wasd_by_default_patch { diff --git a/src/patches/replace_mouse_dinput_to_user32.cpp b/src/patches/replace_mouse_dinput_to_user32.cpp index bcc8154..df74b6d 100644 --- a/src/patches/replace_mouse_dinput_to_user32.cpp +++ b/src/patches/replace_mouse_dinput_to_user32.cpp @@ -70,10 +70,7 @@ void click_mouse(DWORD dik_scancode, DWORD flags) { namespace { DWORD controlFlags = 0; dk2::Pos2i clientSize; - POINT lastPos = {0, 0}; - - RECT safeArea; - POINT clientResetPos; + bool appIsActive = false; } void handle_fpv_mouse_move(HWND hWnd, POINT pos) { @@ -81,6 +78,7 @@ void handle_fpv_mouse_move(HWND hWnd, POINT pos) { RECT clientRect; GetClientRect(hWnd, &clientRect); + RECT safeArea; safeArea = clientRect; safeArea.left += (clientRect.right - clientRect.left) / 3; safeArea.top += (clientRect.bottom - clientRect.top) / 3; @@ -88,34 +86,25 @@ void handle_fpv_mouse_move(HWND hWnd, POINT pos) { safeArea.bottom -= (clientRect.bottom - clientRect.top) / 3; // update reset pos + POINT clientResetPos; clientResetPos.x = (clientRect.left + clientRect.right) / 2; clientResetPos.y = (clientRect.top + clientRect.bottom) / 2; + POINT lastPos = clientResetPos; float sensitivity = dk2::MyResources_instance.playerCfg.mouseSensitivity / 10.0; if(pos.x != lastPos.x) { - dk2::MyInputManagerCb_instance.f60_mouse->f24_flX_delta = (float) (pos.x - lastPos.x) * sensitivity; + float delta = (float) (pos.x - lastPos.x) / (float) clientSize.x * 640; + dk2::MyInputManagerCb_instance.f60_mouse->f24_flX_delta = delta * sensitivity; lastPos.x = pos.x; } if(pos.y != lastPos.y) { - dk2::MyInputManagerCb_instance.f60_mouse->f28_flY_delta = (float) (pos.y - lastPos.y) * sensitivity; + float delta = (float) (pos.y - lastPos.y) / (float) clientSize.y * 480; + dk2::MyInputManagerCb_instance.f60_mouse->f28_flY_delta = delta * sensitivity; lastPos.y = pos.y; } - - if(!PtInRect(&safeArea, pos)) { - lastPos = clientResetPos; - POINT screenResetPos = clientResetPos; - ClientToScreen(hWnd, &screenResetPos); - SetCursorPos(screenResetPos.x, screenResetPos.y); -// printf("move to center cur=%d,%d client=%d,%d,%d,%d reset=%d,%d safe=%d,%d,%d,%d screen=%d,%d\n", -// pos.x, pos.y, -// clientRect.left, clientRect.top, -// clientRect.right, clientRect.bottom, -// clientResetPos.x, clientResetPos.y, -// safeArea.left, safeArea.top, -// safeArea.right, safeArea.bottom, -// screenResetPos.x, screenResetPos.y -// ); - } + POINT screenResetPos = clientResetPos; + ClientToScreen(hWnd, &screenResetPos); + SetCursorPos(screenResetPos.x, screenResetPos.y); } void replace_mouse_dinput_to_user32::handle_mouse_move(HWND hWnd, POINT pos) { @@ -145,14 +134,29 @@ void replace_mouse_dinput_to_user32::emulate_dinput_from_user32(HWND hWnd, UINT if(!enabled) return; switch (Msg) { case WM_SIZE: { - clientSize = {LOWORD(lParam), HIWORD(lParam)}; + RECT clientRect; + GetClientRect(hWnd, &clientRect); + clientSize = {clientRect.right - clientRect.left, clientRect.bottom - clientRect.top}; +// clientSize = {LOWORD(lParam), HIWORD(lParam)}; break; } case WM_MOUSEMOVE: { - POINT mousePos = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; - handle_mouse_move(hWnd, mousePos); + if(appIsActive) { + POINT mousePos; + GetCursorPos(&mousePos); + ScreenToClient(hWnd, &mousePos); +// POINT mousePos = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; + handle_mouse_move(hWnd, mousePos); + } break; } + case WM_ACTIVATEAPP: + if (wParam) { // activated + appIsActive = true; + } else { // deactivated + appIsActive = false; + } + break; case WM_LBUTTONDOWN: click_mouse(DIK_DK2_LEFTMOUSE, DK2_IsPressed | controlFlags); break; diff --git a/src/replace_globals.map b/src/replace_globals.map index 18d9c50..e14f0d0 100644 --- a/src/replace_globals.map +++ b/src/replace_globals.map @@ -97,4 +97,6 @@ 005622B0 uint32_t settings_readBytesCount(const CHAR *); /* auto */ 005626C0 int *settings_readValue(int *, LPCSTR, uint32_t *); /* auto */ +# CCamera.h +00449CA0 void zoomRel_449CA0(int); // --------------- /* auto */ diff --git a/tools/devhelper/dev_mouse_dinput_to_user32.cpp b/tools/devhelper/dev_mouse_dinput_to_user32.cpp index 671ef21..2382a35 100644 --- a/tools/devhelper/dev_mouse_dinput_to_user32.cpp +++ b/tools/devhelper/dev_mouse_dinput_to_user32.cpp @@ -214,7 +214,7 @@ namespace { POINT clientResetPos; } -void handle_fpv_mouse_move(HWND hWnd, POINT pos) { +void dev_handle_fpv_mouse_move(HWND hWnd, POINT pos) { // update safe area RECT clientRect; GetClientRect(hWnd, &clientRect); @@ -280,7 +280,7 @@ void dev_mouse_dinput_to_user32::handle_mouse_move(HWND hWnd, POINT pos) { // if(dk2::CPlayer *pl = (dk2::CPlayer *) dk2::sceneObjects[dk2::g_pWorld->v_getMEPlayerTagId()]) { // if(pl->creaturePossessed != 0 && !dk2::CDefaultPlayerInterface_instance.inMenu) { // // keep mouse in the center of window -// handle_fpv_mouse_move(hWnd, pos); +// dev_handle_fpv_mouse_move(hWnd, pos); // } // } }