Skip to content

Commit

Permalink
fixed freeze on dungeon heart destroy
Browse files Browse the repository at this point in the history
removed DDrawCompat ddraw.dll file from bundle
  • Loading branch information
DiaLight committed Nov 17, 2024
1 parent c1e2599 commit aa15339
Show file tree
Hide file tree
Showing 11 changed files with 326 additions and 131 deletions.
245 changes: 147 additions & 98 deletions mapping/DKII_EXE_v170.sgmap

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mapping/ida/sgmap_ida.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def is_windows_type(tname):
starts_with = [
'tag', 'std', 'D3D', 'DXGI', 'IDX', 'IDirect', 'enum ',
'in_addr', 'midihdr_tag',
'MLD', 'ID3D', 'DI', 'DD', 'MM', 'MCI', 'EXC', 'HMIDIOUT',
'ID3D', 'DI', 'DD', 'MM', 'MCI', 'EXC', 'HMIDIOUT',
'_RTL', '_ACT', '_TEB', '_PEB', '_EXC', '_ASS', '_FLS', '_D3D',
'_CONTEXT', '_s_', '_SCOPE', '_EH3', '_OSVER', '_MEM',
'_SYS', '_TIME', '_STAR', '_SEC', '_WIN', '_RTTI', '_DDSUR',
Expand Down
8 changes: 1 addition & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,12 @@ Now run `DKII-Flame-1.7.0-*.exe` to play. It is possible to rename the .exe file

Note: It is possible to find newer test builds on [github actions](https://github.com/DiaLight/Flame/actions)

Note 2: The `Data` directory and `ddraw.dll` file are not required for this to work, but are recommended.
Note 2: The `Data` directory are not required for this to work, but are recommended.

## Files explained

The `Data` folder in the zip file contains patches for some campaign maps taken from the link https://keeperklan.com/downloads.php?do=file&id=141. These fix creatures like Dark Angels not spawning in some campaign maps.

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`

# For Software Developers

## How it is done
Expand Down
1 change: 0 additions & 1 deletion resources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ configure_file(
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 ".")
Binary file removed resources/DDrawCompat/ddraw.dll
Binary file not shown.
1 change: 0 additions & 1 deletion resources/DDrawCompat/download-url.txt

This file was deleted.

7 changes: 0 additions & 7 deletions resources/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@ 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`
19 changes: 3 additions & 16 deletions src/dk2/CDefaultPlayerInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,21 +427,8 @@ BOOL dk2::CDefaultPlayerInterface::checkAllowToDrop(CThing *thingInHand, int a4_
int dk2::CPlayer::dropThingFromHand(Vec3i *a2_pos, uint16_t *a3_pDirection) {
if (this->thingsInHand_count == 0) return 0;
Vec3i *v5_pos = a2_pos;
CThing *v6_thing;
if (drop_thing_from_hand_fix::enabled) {
uint16_t v5_tagId = thingsInHand[this->thingsInHand_count - 1];
v6_thing = (CThing *) sceneObjects[v5_tagId];
BOOL allowToDrop = checkPlayerAllowToDrop(
g_pWorld, this->f0_tagId, v6_thing,
a2_pos->x >> 12, a2_pos->y >> 12);
if (!allowToDrop) {
// printf("cancel drop\n");
return 0;
}
} else {
uint16_t v5_tagId = thingsInHand[this->thingsInHand_count - 1];
v6_thing = (CThing *) sceneObjects[v5_tagId];
}
uint16_t v5_tagId = thingsInHand[this->thingsInHand_count - 1];
CThing *v6_thing = (CThing *) sceneObjects[v5_tagId];
this->thingsInHand_count--;
v6_thing->fun_4B5560(v5_pos);
int MapWhoType = v6_thing->getMapWhoType_except2();
Expand Down Expand Up @@ -474,7 +461,7 @@ int dk2::CPlayer::dropThingFromHand(Vec3i *a2_pos, uint16_t *a3_pDirection) {
object->v_f24(v14_mapelem->_playerIdFFF & 0xFFF);
}
object->fun_49EF60(1);
int f10_underHandTagId = LOWORD(this->inst__playerAction.data3);
int f10_underHandTagId = LOWORD(this->inst__playerAction.evData3);
if (!sceneObjectsPresent[(unsigned __int16) f10_underHandTagId]) {
if (object->typeId != 0 && object->typeId <= 3u) {
uint16_t direction = 0;
Expand Down
34 changes: 34 additions & 0 deletions src/dk2/entities/CPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,37 @@ void dk2::CPlayer::resetCreaturesState() {
}
}
}

namespace dk2 {
bool checkPlayerAllowToDrop(CWorld *world, uint16_t playerTagId, CThing *thingInHand, int a4_x, int a5_y);
}

int dk2::CPlayer::act4_dropThingFromHand() {
uint16_t v1_dropTag = this->inst__playerAction.evData3;
unsigned int v2_direction = HIWORD(this->inst__playerAction.evData3) & 0x7FF; // v19_direction << 16
Vec3i dropPos;
memset(&dropPos, 0, sizeof(dropPos));
if ( v1_dropTag && sceneObjectsPresent[v1_dropTag] ) {
dropPos = ((CThing *) sceneObjects[v1_dropTag])->f16_pos;
} else {
dropPos.x = this->inst__playerAction.evData1; // a3_underHand->f10_x_if12
dropPos.y = this->inst__playerAction.evData2; // a3_underHand->f14_y_if12
}
dropPos.z = 0x2000;

if (drop_thing_from_hand_fix::enabled) {
uint16_t v5_tagId = thingsInHand[this->thingsInHand_count - 1];
CThing *v6_thing = (CThing *) sceneObjects[v5_tagId];
BOOL allowToDrop = checkPlayerAllowToDrop(
g_pWorld, this->f0_tagId, v6_thing,
dropPos.x >> 12, dropPos.y >> 12);
if (!allowToDrop) {
// printf("cancel drop\n");
return 0;
}
}

uint16_t v5_direction = v2_direction;
this->dropThingFromHand(&dropPos, &v5_direction);
return 1;
}
139 changes: 139 additions & 0 deletions src/dk2/entities/object_type.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
//
// Created by DiaLight on 17.11.2024.
//

#ifndef FLAME_OBJECT_TYPE_H
#define FLAME_OBJECT_TYPE_H

// 1: Gold
// 2: Gold
// 3: Gold
// 4: ResearchBook (Spell Books use treated parchment to contain their volatile words.)
// 5: AlarmTrapCrate (A loose Crate containing an Alarm Trap, ready to install on a Blueprint.)
// 6: ...
// 7: ...
// 8: TortureWheel
// 9: Chicken (Drop one on a hungry minion to feed it.)
// 10: CallToArms
// 11: Rat (Filthy plague-carrying vermin, and the sign of a fine Prison.)
// 12: ...
// 13: ...
// 14: ...
// 15: ...
// 16: ...
// 17: ...
// 18: ...
// 19: ...
// 20: ...
// 21: ...
// 22: ...
// 23: ...
// 24: ...
// 25: ...
// 26: ...
// 27: ...
// 28: PortalGem (Portal Gem: the object of your quest.)
// 29: TrainingTarget
// 31: TombStone
// 32: TombStone
// 33: TombStone
// 34: TombStone
// 35: Coop
// 36: BoulderTrapCrate
// 37: FearTrapCrate
// 38: FireburstTrapCrate
// 39: FreezeTrapCrate
// 40: GasTrapCrate
// 41: Lightning TrapCrate
// 42: CentryTrapCrate
// 43: SpikeTrapCrate
// 44: TriggerTrapCrate
// 45: ...
// 46: ...
// 47: Egg (It's just an egg. Nothing to get excited about.)
// 48: ...
// 49: ...
// 50: ...
// 51: ...
// 52: WoodenDoorCrate
// 53: SteelDoorCrate
// 54: BracedDoorCrate
// 55: MagicDoorCrate
// 56: BarricadeCrate
// 57: SecretDoorCrate
// 58: LibraryBook (Ancient wisdom to aid research and improve beard quality.)
// 59: ...
// 60: ...
// 61: ...
// 62: ...
// 63: ...
// 64: BookCase
// 65: ...
// 66: ...
// 67: ...
// 68: ...
// 69: ...
// 70: GuardPost
// 71: ...
// 72: ...
// 73: ...
// 74: BoulderTrap
// 75-91: ...
// 92: GuardPostCrate (A loose Crate containing a Guard Post, ready to install on a Blueprint.)
// 93: ...
// 94: ...
// 95: Pay-outLever
// 96: ...
// 97: ...
// 98: Destructor
// 99: ...
// 100: ...
// 101: ManaVault
// 102: ...
// 103: ThreatBurn
// 104: ...
// 105: ...
// 106: ...
// 107: ...
// 108: ClaimedManaVault
// 109: ...
// 110: FECandleStick
// 111: TempleCandleStick
// 112: ...
// 113: ...
// 114: HeroGate2By2
// 115: ...
// 116: PrisonBolt
// 117: IncreaseLevel
// 118: RevealMap
// 119: MakeSafe
// 120: WeakenWalls
// 121: IncreaseGold
// 122: Mana Boost
// 123: Stun Imps
// 124: Receive Imps
// 125: Make Happy
// 126: Make Unhappy
// 127: Kill Creatures
// 128: Heal All
// 129: Locate Hidden Land (Allows you to reach a secret level on completion of this one)
// 130: HeroLevelSelector
// 131: ...
// 132: ...
// 133: ...
// 134: ...
// 135: ...
// 136: ...
// 137: ...
// 138: ...
// 139: ...
// 140: ...
// 141: ...
// 142: ...
// 143: ...
// 144: ...
// 145: ...



#endif //FLAME_OBJECT_TYPE_H
1 change: 1 addition & 0 deletions src/replace_globals.map
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
00506B70 int getManufactureRequired(uint16_t); // --- /* auto */
004C3200 int creatureDidWorkshopWork(int, CCreature *); /* auto */
004E8D30 void resetCreaturesState(); // ------------- /* auto */
004C0EE0 int act4_dropThingFromHand(); // ----------- /* auto */

004C5C30 int fun_4C5C30_buildRoom(int, int, int, int, int, int, int); /* auto */
004C5DB0 int destroyRoom(int, int, int); // --------- /* auto */
Expand Down

0 comments on commit aa15339

Please sign in to comment.