id
int64
0
877k
file_name
stringlengths
3
109
file_path
stringlengths
13
185
content
stringlengths
31
9.38M
size
int64
31
9.38M
language
stringclasses
1 value
extension
stringclasses
11 values
total_lines
int64
1
340k
avg_line_length
float64
2.18
149k
max_line_length
int64
7
2.22M
alphanum_fraction
float64
0
1
repo_name
stringlengths
6
66
repo_stars
int64
94
47.3k
repo_forks
int64
0
12k
repo_open_issues
int64
0
3.4k
repo_license
stringclasses
11 values
repo_extraction_date
stringclasses
197 values
exact_duplicates_redpajama
bool
2 classes
near_duplicates_redpajama
bool
2 classes
exact_duplicates_githubcode
bool
2 classes
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
2 classes
near_duplicates_githubcode
bool
2 classes
near_duplicates_stackv1
bool
2 classes
near_duplicates_stackv2
bool
1 class
1,542,114
immunecat.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/immunecat.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "immunecat.h" #include "version.h" #include <array> namespace game::ImmuneCategories { // clang-format off static std::array<Categories, 4> categories = {{ // Akella Categories{ (LImmuneCat*)0x8393a8, (LImmuneCat*)0x8393b8, (LImmuneCat*)0x8393c8, }, // Russobit Categories{ (LImmuneCat*)0x8393a8, (LImmuneCat*)0x8393b8, (LImmuneCat*)0x8393c8, }, // Gog Categories{ (LImmuneCat*)0x837358, (LImmuneCat*)0x837368, (LImmuneCat*)0x837378, }, // Scenario Editor Categories{ (LImmuneCat*)0x665b30, (LImmuneCat*)0x665b40, (LImmuneCat*)0x665b50, }, }}; static std::array<const void*, 4> vftables = {{ // Akella (const void*)0x6e9cfc, // Russobit (const void*)0x6e9cfc, // Gog (const void*)0x6e7c9c, // Scenario Editor (const void*)0x5df754, }}; // clang-format on Categories& get() { return categories[static_cast<int>(hooks::gameVersion())]; } const void* vftable() { return vftables[static_cast<int>(hooks::gameVersion())]; } } // namespace game::ImmuneCategories namespace game::LImmuneCatTableApi { // clang-format off static std::array<Api, 4> functions = {{ // Akella Api{ (Api::Constructor)0x584c37, (Api::Init)0x584d87, (Api::ReadCategory)0x584dff, (Api::InitDone)0x584d42, (Api::FindCategoryById)0x5a032c, }, // Russobit Api{ (Api::Constructor)0x584c37, (Api::Init)0x584d87, (Api::ReadCategory)0x584dff, (Api::InitDone)0x584d42, (Api::FindCategoryById)0x5a032c, }, // Gog Api{ (Api::Constructor)0x583dea, (Api::Init)0x583f3a, (Api::ReadCategory)0x583fb2, (Api::InitDone)0x583ef5, (Api::FindCategoryById)0x59f5c2, }, // Scenario Editor Api{ (Api::Constructor)0x53b4aa, (Api::Init)0x53b5fa, (Api::ReadCategory)0x53b672, (Api::InitDone)0x53b5b5, (Api::FindCategoryById)0x5485a1, }, }}; static std::array<const void*, 4> vftables = {{ // Akella (const void*)0x6e9d04, // Russobit (const void*)0x6e9d04, // Gog (const void*)0x6e7ca4, // Scenario Editor (const void*)0x5df75c, }}; // clang-format on Api& get() { return functions[static_cast<int>(hooks::gameVersion())]; } const void* vftable() { return vftables[static_cast<int>(hooks::gameVersion())]; } } // namespace game::LImmuneCatTableApi
3,357
C++
.cpp
125
22.16
72
0.660764
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,115
encparambasehooks.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/encparambasehooks.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2023 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "encparambasehooks.h" #include "battlemsgdata.h" #include "encparambase.h" namespace hooks { void __stdcall encParamBaseAddUnitBattleInfoHooked(game::CEncParamBase* param, const game::CMidgardID* unitId, const game::BattleMsgData* battleMsgData) { using namespace game; const auto& api = CEncParamBaseApi::get(); const auto& battleApi = BattleMsgDataApi::get(); auto data = param->data; if (battleApi.getUnitStatus(battleMsgData, unitId, BattleStatus::BoostDamageLvl1)) { data->statuses |= (int)CEncParamBaseDataStatus::BoostDamageLvl1; } else if (battleApi.getUnitStatus(battleMsgData, unitId, BattleStatus::BoostDamageLvl2)) { data->statuses |= (int)CEncParamBaseDataStatus::BoostDamageLvl2; } else if (battleApi.getUnitStatus(battleMsgData, unitId, BattleStatus::BoostDamageLvl3)) { data->statuses |= (int)CEncParamBaseDataStatus::BoostDamageLvl3; } else if (battleApi.getUnitStatus(battleMsgData, unitId, BattleStatus::BoostDamageLvl4)) { data->statuses |= (int)CEncParamBaseDataStatus::BoostDamageLvl4; } if (battleApi.getUnitStatus(battleMsgData, unitId, BattleStatus::LowerDamageLvl1)) { data->statuses |= (int)CEncParamBaseDataStatus::LowerDamageLvl1; } else if (battleApi.getUnitStatus(battleMsgData, unitId, BattleStatus::LowerDamageLvl2)) { data->statuses |= (int)CEncParamBaseDataStatus::LowerDamageLvl2; } if (battleApi.getUnitStatus(battleMsgData, unitId, BattleStatus::LowerInitiative)) { data->statuses |= (int)CEncParamBaseDataStatus::LowerInitiative; } auto unitInfo = battleApi.getUnitInfoById(battleMsgData, unitId); if (unitInfo != nullptr) { api.setData(param, CEncParamBaseDataKey::AttackSourceImmunityStatuses, unitInfo->attackSourceImmunityStatuses.patched); api.setData(param, CEncParamBaseDataKey::AttackClassImmunityStatuses, unitInfo->attackClassImmunityStatuses); } } } // namespace hooks
2,932
C++
.cpp
56
45.857143
95
0.726195
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,116
batattacktransformother.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/batattacktransformother.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "batattacktransformother.h" #include "version.h" #include <array> namespace game::CBatAttackTransformOtherApi { // clang-format off static std::array<IBatAttackVftable*, 4> vftables = {{ // Akella (IBatAttackVftable*)0x6f545c, // Russobit (IBatAttackVftable*)0x6f545c, // Gog (IBatAttackVftable*)0x6f340c, // Scenario Editor (IBatAttackVftable*)nullptr, }}; // clang-format on IBatAttackVftable* vftable() { return vftables[static_cast<int>(hooks::gameVersion())]; } } // namespace game::CBatAttackTransformOtherApi
1,379
C++
.cpp
39
32.871795
72
0.754307
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,117
menurace.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/menurace.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "menurace.h" #include "version.h" #include <array> namespace game::CMenuRaceApi { // clang-format off static std::array<Api, 3> functions = {{ // Akella Api{ (Api::ScrollButtonCallback)0x4eedcf, (Api::ScrollButtonCallback)0x4eefac, (Api::UpdateButtons)0x4ee5a4, (Api::UpdateRaceDescription)0x4eec47, (Api::GetRaceCategory)0x4ee8ec, (Api::GetRaceBgndImageName)0x4ee976, (Api::GetTransitionAnimationName)0x4eeeb1, (Api::SetRacesToSkip)0x4ee3d1, }, // Russobit Api{ (Api::ScrollButtonCallback)0x4eedcf, (Api::ScrollButtonCallback)0x4eefac, (Api::UpdateButtons)0x4ee5a4, (Api::UpdateRaceDescription)0x4eec47, (Api::GetRaceCategory)0x4ee8ec, (Api::GetRaceBgndImageName)0x4ee976, (Api::GetTransitionAnimationName)0x4eeeb1, (Api::SetRacesToSkip)0x4ee3d1, }, // Gog Api{ (Api::ScrollButtonCallback)0x4ee217, (Api::ScrollButtonCallback)0x4ee3f4, (Api::UpdateButtons)0x4ed9ec, (Api::UpdateRaceDescription)0x4ee08f, (Api::GetRaceCategory)0x4edd34, (Api::GetRaceBgndImageName)0x4eddbe, (Api::GetTransitionAnimationName)0x4ee2f9, (Api::SetRacesToSkip)0x4ed819, } }}; // clang-format on Api& get() { return functions[static_cast<int>(hooks::gameVersion())]; } } // namespace game::CMenuRaceApi
2,238
C++
.cpp
64
30
72
0.709083
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,118
attackutils.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/attackutils.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "attackutils.h" #include "attack.h" #include "attackmodified.h" #include "customattacks.h" #include "custommodifier.h" #include "dynamiccast.h" #include "globaldata.h" #include "globalvariables.h" #include "midgardid.h" #include <array> namespace hooks { game::IAttack* getGlobalAttack(const game::CMidgardID* attackId) { using namespace game; if (*attackId == emptyId) return nullptr; const auto& global = GlobalDataApi::get(); const auto attacks = (*global.getGlobalData())->attacks; return (IAttack*)global.findById(attacks, attackId); } game::CAttackImpl* getAttackImpl(const game::IAttack* attack) { using namespace game; const auto& rtti = RttiApi::rtti(); const auto dynamicCast = RttiApi::get().dynamicCast; auto current = attack; while (current) { auto customModifier = castAttackToCustomModifier(current); if (customModifier) { current = customModifier->getPrevAttack(current); continue; } auto attackImpl = (CAttackImpl*)dynamicCast(current, 0, rtti.IAttackType, rtti.CAttackImplType, 0); if (attackImpl) return attackImpl; auto attackModified = (CAttackModified*)dynamicCast(current, 0, rtti.IAttackType, rtti.CAttackModifiedType, 0); current = attackModified ? attackModified->data->prev : nullptr; } return nullptr; } int getBoostDamage(int level) { using namespace game; const auto& global = GlobalDataApi::get(); const auto vars = *(*global.getGlobalData())->globalVariables; int count = std::size(vars->battleBoostDamage); return (0 < level && level <= count) ? vars->battleBoostDamage[level - 1] : 0; } int getLowerDamage(int level) { using namespace game; const auto& global = GlobalDataApi::get(); const auto vars = *(*global.getGlobalData())->globalVariables; int count = std::size(vars->battleLowerDamage); return (0 < level && level <= count) ? vars->battleLowerDamage[level - 1] : 0; } int getLowerInitiative(int level) { using namespace game; if (level != 1) return 0; const auto& global = GlobalDataApi::get(); const auto vars = *(*global.getGlobalData())->globalVariables; return vars->battleLowerIni; } bool attackHasPower(game::AttackClassId id) { const auto& classes = game::AttackClassCategories::get(); return id == classes.paralyze->id || id == classes.petrify->id || id == classes.damage->id || id == classes.drain->id || id == classes.drainOverflow->id || id == classes.fear->id || id == classes.lowerDamage->id || id == classes.lowerInitiative->id || id == classes.poison->id || id == classes.frostbite->id || id == classes.blister->id || id == classes.bestowWards->id || id == classes.shatter->id || id == classes.revive->id || id == classes.drainLevel->id || id == classes.transformSelf->id || id == classes.transformOther->id; } bool attackHasDamage(game::AttackClassId id) { const auto& classes = game::AttackClassCategories::get(); return id == classes.damage->id || id == classes.drain->id || id == classes.drainOverflow->id || id == classes.poison->id || id == classes.frostbite->id || id == classes.blister->id || id == classes.shatter->id; } bool attackHasHeal(game::AttackClassId id) { const auto& classes = game::AttackClassCategories::get(); return id == classes.heal->id || id == classes.revive->id || id == classes.bestowWards->id; } bool attackHasInfinite(game::AttackClassId id) { const auto& classes = game::AttackClassCategories::get(); return id == classes.paralyze->id || id == classes.petrify->id || id == classes.boostDamage->id || id == classes.lowerDamage->id || id == classes.lowerInitiative->id || id == classes.poison->id || id == classes.frostbite->id || id == classes.blister->id || id == classes.transformOther->id; } bool attackHasCritHit(game::AttackClassId id) { return isNormalDamageAttack(id); } bool attackHasAltAttack(game::AttackClassId id) { const auto& classes = game::AttackClassCategories::get(); return id == classes.transformSelf->id || id == classes.doppelganger->id; } bool attackHasAltAttack(const game::IAttack* attack) { // Using getAttackClass here results in a serious performance loss due to recursive calls inside // of CCustomModifier::attackGetAttackClass in case of nested modifiers const auto altAttackId = attack->vftable->getAltAttackId(attack); return *altAttackId != game::emptyId; } bool attackHasDrain(game::AttackClassId id) { return isNormalDamageAttack(id); } bool isNormalDamageAttack(game::AttackClassId id) { const auto& classes = game::AttackClassCategories::get(); return id == classes.damage->id || id == classes.drain->id || id == classes.drainOverflow->id; } bool isModifiableDamageAttack(game::AttackClassId id) { const auto& classes = game::AttackClassCategories::get(); return id == classes.damage->id || id == classes.drain->id || id == classes.drainOverflow->id || id == classes.shatter->id; } bool isMeleeAttack(const game::IAttack* attack) { auto reach = attack->vftable->getAttackReach(attack); return isMeleeAttack(reach->id); } bool isMeleeAttack(game::AttackReachId id) { using namespace game; const auto& reaches = AttackReachCategories::get(); if (id == reaches.adjacent->id) { return true; } else if (id != reaches.all->id && id != reaches.any->id) { for (auto& custom : getCustomAttacks().reaches) { if (id == custom.reach.id) { return custom.melee; } } } return false; } int getAttackMaxTargets(const game::AttackReachId id) { using namespace game; const auto& reaches = AttackReachCategories::get(); if (id == reaches.all->id) { return 6; } else if (id == reaches.any->id || id == reaches.adjacent->id) { return 1; } else { for (const auto& custom : getCustomAttacks().reaches) { if (id == custom.reach.id) { return custom.maxTargets; } } } return 0; } } // namespace hooks
7,208
C++
.cpp
185
33.627027
100
0.671351
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,119
restrictions.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/restrictions.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "restrictions.h" #include "version.h" #include <array> namespace game { // clang-format off std::array<GameRestrictions, 4> restrictions = {{ // Akella GameRestrictions{ (Restriction<int>*)0x6eb3f8, (Restriction<int>*)0x6ea928, (Restriction<int>*)0x6eb778, (Restriction<int>*)0x6ea954, (Restriction<int>*)0x6ea94c, (Restriction<int>*)0x6ea95c, (Restriction<int>*)0x6ea964, (Restriction<int>*)0x6ea944, (Restriction<int>*)0x6eb768, (Restriction<int>*)0x6eb770, (Restriction<int>*)0x6ea934, (int*)0x6ea930, (std::uint32_t*)0x6eb780, (std::uint8_t*)0x65cefe, (std::uint8_t*)0x626726, (UnitHighLevels*)0x6ea9a8, {0, INT_MAX}, {0, 100}, {-100, 100}, }, // Russobit GameRestrictions{ (Restriction<int>*)0x6eb3f8, (Restriction<int>*)0x6ea928, (Restriction<int>*)0x6eb778, (Restriction<int>*)0x6ea954, (Restriction<int>*)0x6ea94c, (Restriction<int>*)0x6ea95c, (Restriction<int>*)0x6ea964, (Restriction<int>*)0x6ea944, (Restriction<int>*)0x6eb768, (Restriction<int>*)0x6eb770, (Restriction<int>*)0x6ea934, (int*)0x6ea930, (std::uint32_t*)0x6eb780, (std::uint8_t*)0x65cefe, (std::uint8_t*)0x626726, (UnitHighLevels*)0x6ea9a8, {0, INT_MAX}, {0, 100}, {-100, 100}, }, // Gog GameRestrictions{ (Restriction<int>*)0x6e9398, (Restriction<int>*)0x6e88c8, (Restriction<int>*)0x6e9718, (Restriction<int>*)0x6e88f4, (Restriction<int>*)0x6e88ec, (Restriction<int>*)0x6e88fc, (Restriction<int>*)0x6e8904, (Restriction<int>*)0x6e88e4, (Restriction<int>*)0x6e9708, (Restriction<int>*)0x6e9710, (Restriction<int>*)0x6e88d4, (int*)0x6e88d0, (std::uint32_t*)0x6e9720, (std::uint8_t*)0x65b97e, (std::uint8_t*)0x625266, (UnitHighLevels*)0x6e8948, {0, INT_MAX}, {0, 100}, {-100, 100}, }, // Scenario Editor GameRestrictions{ (Restriction<int>*)0x5df134, (Restriction<int>*)0x5de038, (Restriction<int>*)0x5df490, (Restriction<int>*)0x5de064, (Restriction<int>*)0x5de05c, (Restriction<int>*)0x5de06c, (Restriction<int>*)0x5de074, (Restriction<int>*)0x5de054, (Restriction<int>*)0x5df480, (Restriction<int>*)0x5df488, (Restriction<int>*)0x5de044, (int*)0x5de040, (std::uint32_t*)0x5df498, (std::uint8_t*)nullptr, (std::uint8_t*)nullptr, (UnitHighLevels*)0x5de0b8, {0, INT_MAX}, {0, 100}, {-100, 100}, } }}; // clang-format on GameRestrictions& gameRestrictions() { return restrictions[static_cast<int>(hooks::gameVersion())]; } } // namespace game
3,802
C++
.cpp
119
25.218487
72
0.622349
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,120
sitemerchantinterf.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/sitemerchantinterf.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "sitemerchantinterf.h" #include "version.h" #include <array> namespace game::CSiteMerchantInterfApi { // clang-format off static std::array<Api, 3> functions = {{ // Akella Api{ (Api::Constructor)0x4996fd, (Api::CreateButtonFunctor)0x49ac6e }, // Russobit Api{ (Api::Constructor)0x4996fd, (Api::CreateButtonFunctor)0x49ac6e }, // Gog Api{ (Api::Constructor)0x4990e9, (Api::CreateButtonFunctor)0x49a649 } }}; static std::array<Vftable, 4> vftables = {{ // Akella Vftable{ (CMidDataCache2::INotifyVftable*)0x6d7914, (IResetStackExtVftable*)0x6d78f4, (CInterfaceVftable*)0x6d7864, (ITaskManagerHolderVftable*)0x6d7854, (IMidDropManagerVftable*)0x6d7814, }, // Russobit Vftable{ (CMidDataCache2::INotifyVftable*)0x6d7914, (IResetStackExtVftable*)0x6d78f4, (CInterfaceVftable*)0x6d7864, (ITaskManagerHolderVftable*)0x6d7854, (IMidDropManagerVftable*)0x6d7814, }, // Gog Vftable{ (CMidDataCache2::INotifyVftable*)0x6d58b4, (IResetStackExtVftable*)0x6d5894, (CInterfaceVftable*)0x6d5804, (ITaskManagerHolderVftable*)0x6d57f4, (IMidDropManagerVftable*)0x6d57b4, }, // Scenario Editor Vftable{}, }}; // clang-format on Api& get() { return functions[static_cast<int>(hooks::gameVersion())]; } Vftable& vftable() { return vftables[static_cast<int>(hooks::gameVersion())]; } } // namespace game::CSiteMerchantInterfApi
2,391
C++
.cpp
78
26.064103
72
0.701648
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,121
effectresult.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/effectresult.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "effectresult.h" #include "version.h" #include <array> namespace game::IEffectResultApi { // clang-format off static std::array<Api, 3> functions = {{ // Akella Api{ (Api::Create)0x4427c2, }, // Russobit Api{ (Api::Create)0x4427c2, }, // Gog Api{ (Api::Create)0x442427, }, }}; // clang-format on Api& get() { return functions[static_cast<int>(hooks::gameVersion())]; } } // namespace game::IEffectResultApi
1,297
C++
.cpp
43
27.162791
72
0.71257
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,122
imagepointlist.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/imagepointlist.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "imagepointlist.h" #include "version.h" #include <array> namespace game::ImagePointListApi { // clang-format off static std::array<Api, 4> functions = {{ // Akella Api{ (Api::Add)0x5b7129, (Api::AddText)0x5cb088, (Api::AddImageWithText)0x5cae49, }, // Russobit Api{ (Api::Add)0x5b7129, (Api::AddText)0x5cb088, (Api::AddImageWithText)0x5cae49, }, // Gog Api{ (Api::Add)0x494dcb, (Api::AddText)0x5c9fa4, (Api::AddImageWithText)0x5c9d65, }, // Scenario Editor Api{ (Api::Add)0, (Api::AddText)0x4d2468, (Api::AddImageWithText)0x4d2288, }, }}; // clang-format on Api& get() { return functions[static_cast<int>(hooks::gameVersion())]; } } // namespace game::ImagePointListApi
1,644
C++
.cpp
55
25.8
72
0.6875
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,123
menunewskirmishhotseat.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/menunewskirmishhotseat.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2023 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "menunewskirmishhotseat.h" #include "version.h" #include <array> namespace game::CMenuNewSkirmishHotseatApi { // clang-format off static std::array<Api, 3> functions = {{ // Akella Api{ (Api::Constructor)0x4ea808, }, // Russobit Api{ (Api::Constructor)0x4ea808, }, // Gog Api{ (Api::Constructor)0x4e9c9e, }, }}; // clang-format on Api& get() { return functions[static_cast<int>(hooks::gameVersion())]; } } // namespace game::CMenuNewSkirmishHotseatApi
1,342
C++
.cpp
43
28.209302
72
0.722566
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,124
unittypedescriptor.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/unittypedescriptor.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "unittypedescriptor.h" #include "version.h" #include <array> namespace game::CUnitTypeDescriptorApi { // clang-format off static std::array<Api, 4> functions = {{ // Akella Api{ (Api::GetUnitImpl)0x57f2ac, (Api::GetAttack)0x57f2c4, (Api::GetAltAttack)0x57f312, }, // Russobit Api{ (Api::GetUnitImpl)0x57f2ac, (Api::GetAttack)0x57f2c4, (Api::GetAltAttack)0x57f312, }, // Gog Api{ (Api::GetUnitImpl)0x57e964, (Api::GetAttack)0x57e97c, (Api::GetAltAttack)0x57e9ca, }, // Scenario Editor Api{ (Api::GetUnitImpl)0x4d070f, (Api::GetAttack)0x4d0727, (Api::GetAltAttack)0x4d0775, }, }}; static std::array<IEncUnitDescriptorVftable*, 4> vftables = {{ // Akella (IEncUnitDescriptorVftable*)0x6e90ec, // Russobit (IEncUnitDescriptorVftable*)0x6e90ec, // Gog (IEncUnitDescriptorVftable*)0x6e708c, // Scenario Editor (IEncUnitDescriptorVftable*)0x5d853c, }}; // clang-format on Api& get() { return functions[static_cast<int>(hooks::gameVersion())]; } const IEncUnitDescriptorVftable* vftable() { return vftables[static_cast<int>(hooks::gameVersion())]; } } // namespace game::CUnitTypeDescriptorApi
2,099
C++
.cpp
69
26.405797
72
0.704894
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,125
mideveffecthooks.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/mideveffecthooks.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "mideveffecthooks.h" #include "d2string.h" #include "eventeffectcathooks.h" #include "game.h" #include "originalfunctions.h" #include <string> namespace hooks { game::CMidEvEffect* __stdcall createEventEffectFromCategoryHooked( const game::CMidgardID* eventId, const game::LEventEffectCategory* category) { const auto& effects = customEventEffects(); const auto id = category->id; return getOriginalFunctions().createEventEffectFromCategory(eventId, category); } void __stdcall eventEffectGetInfoStringHooked(game::String* info, const game::IMidgardObjectMap* objectMap, const game::CMidEvEffect* eventEffect) { const auto& effects = customEventEffects(); const auto id = eventEffect->category.id; getOriginalFunctions().eventEffectGetInfoString(info, objectMap, eventEffect); } void __stdcall eventEffectGetDescriptionHooked(game::String* description, const game::LEventEffectCategory* category) { using namespace game; const auto& effects = customEventEffects(); const auto id = category->id; const CMidgardID* descriptionId{nullptr}; if (descriptionId) { auto text = gameFunctions().getInterfaceText(descriptionId); StringApi::get().initFromStringN(description, text, std::strlen(text)); return; } getOriginalFunctions().eventEffectGetDescription(description, category); } void __stdcall eventEffectGetBriefHooked(game::String* brief, const game::LEventEffectCategory* category) { using namespace game; const auto& effects = customEventEffects(); const auto id = category->id; const CMidgardID* briefId{nullptr}; if (briefId) { auto text = gameFunctions().getInterfaceText(briefId); StringApi::get().initFromStringN(brief, text, std::strlen(text)); return; } getOriginalFunctions().eventEffectGetBrief(brief, category); } } // namespace hooks
2,900
C++
.cpp
70
35.428571
90
0.710629
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,126
idvector.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/idvector.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "idvector.h" #include "version.h" #include <array> namespace game::IdVectorApi { // clang-format off static std::array<Api, 4> functions = {{ // Akella Api{ (Api::Destructor)0x410dc1, (Api::PushBack)0x4118f0, (Api::Reserve)0x41683d, (Api::Copy)0x46c081, }, // Russobit Api{ (Api::Destructor)0x410dc1, (Api::PushBack)0x4118f0, (Api::Reserve)0x41683d, (Api::Copy)0x46c081, }, // Gog Api{ (Api::Destructor)0x41099f, (Api::PushBack)0x4114ce, (Api::Reserve)0x416517, (Api::Copy)0x46ba06, }, // Scenario Editor Api{ (Api::Destructor)0x414ed1, (Api::PushBack)0x4151ff, (Api::Reserve)0x4152eb, (Api::Copy)0x415269, } }}; // clang-format on Api& get() { return functions[static_cast<int>(hooks::gameVersion())]; } } // namespace game::IdVectorApi
1,744
C++
.cpp
59
25.135593
72
0.675
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,127
menubase.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/menubase.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "menubase.h" #include "version.h" #include <array> namespace game::CMenuBaseApi { // clang-format off static std::array<Api, 3> functions = {{ // Akella Api{ (Api::Constructor)0x4db5ea, (Api::Destructor)0x4db6f7, (Api::CreateMenu)0x4db76a, (Api::GetDialogInterface)0x40306a, (Api::ButtonCallback)0x4dcf9e, (Api::CreateButtonFunctor)0x4ea842, (Api::CreateListBoxDisplayFunctor)0x4e563f, (Api::CreateListBoxDisplayTextFunctor)0x4ea88e, (Api::ListBoxCallback)0x4e9cb3, (Api::CreateListBoxFunctor)0x4ea8da, (Api::CreateSpinButtonFunctor)0x4e5867, (Api::CreatePictureFunctor)0x492cb0, }, // Russobit Api{ (Api::Constructor)0x4db5ea, (Api::Destructor)0x4db6f7, (Api::CreateMenu)0x4db76a, (Api::GetDialogInterface)0x40306a, (Api::ButtonCallback)0x4dcf9e, (Api::CreateButtonFunctor)0x4ea842, (Api::CreateListBoxDisplayFunctor)0x4e563f, (Api::CreateListBoxDisplayTextFunctor)0x4ea88e, (Api::ListBoxCallback)0x4e9cb3, (Api::CreateListBoxFunctor)0x4ea8da, (Api::CreateSpinButtonFunctor)0x4e5867, (Api::CreatePictureFunctor)0x492cb0, }, // Gog Api{ (Api::Constructor)0x4dac4f, (Api::Destructor)0x4dad5c, (Api::CreateMenu)0x4dadcf, (Api::GetDialogInterface)0x402db0, (Api::ButtonCallback)0x4dbeae, (Api::CreateButtonFunctor)0x4e9cdd, (Api::CreateListBoxDisplayFunctor)0x4e4d4c, (Api::CreateListBoxDisplayTextFunctor)0x4e9d29, (Api::ListBoxCallback)0x4e914e, (Api::CreateListBoxFunctor)0x4e9d75, (Api::CreateSpinButtonFunctor)0x4e4f74, (Api::CreatePictureFunctor)0x492766, }, }}; static std::array<CInterfaceVftable*, 3> vftables = {{ // Akella (CInterfaceVftable*)0x6dd294, // Russobit (CInterfaceVftable*)0x6dd294, // Gog (CInterfaceVftable*)0x6db234, }}; // clang-format on Api& get() { return functions[static_cast<int>(hooks::gameVersion())]; } const CInterfaceVftable* vftable() { return vftables[static_cast<int>(hooks::gameVersion())]; } } // namespace game::CMenuBaseApi
3,050
C++
.cpp
88
29.340909
72
0.70423
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,128
batattackdrainlevel.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/batattackdrainlevel.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "batattackdrainlevel.h" #include "version.h" #include <array> namespace game::CBatAttackDrainLevelApi { // clang-format off static std::array<IBatAttackVftable*, 4> vftables = {{ // Akella (IBatAttackVftable*)0x6f5584, // Russobit (IBatAttackVftable*)0x6f5584, // Gog (IBatAttackVftable*)0x6f3534, // Scenario Editor (IBatAttackVftable*)nullptr, }}; // clang-format on IBatAttackVftable* vftable() { return vftables[static_cast<int>(hooks::gameVersion())]; } } // namespace game::CBatAttackDrainLevelApi
1,367
C++
.cpp
39
32.564103
72
0.752079
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,129
menuphasehooks.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/menuphasehooks.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "menuphasehooks.h" #include "log.h" #include "menucustomlobby.h" #include "menuphase.h" #include "menurandomscenariomulti.h" #include "menurandomscenariosingle.h" #include "midgard.h" #include "originalfunctions.h" #include "scenariotemplates.h" #include <fmt/format.h> namespace hooks { game::CMenuPhase* __fastcall menuPhaseCtorHooked(game::CMenuPhase* thisptr, int /*%edx*/, int a2, int a3) { getOriginalFunctions().menuPhaseCtor(thisptr, a2, a3); loadScenarioTemplates(); return thisptr; } void __fastcall menuPhaseDtorHooked(game::CMenuPhase* thisptr, int /*%edx*/, char flags) { freeScenarioTemplates(); getOriginalFunctions().menuPhaseDtor(thisptr, flags); } void __fastcall menuPhaseSetTransitionHooked(game::CMenuPhase* thisptr, int /*%edx*/, int transition) { using namespace game; using CreateMenuCallback = CMenuPhaseApi::Api::CreateMenuCallback; CMenuPhaseData* data = thisptr->data; auto transitionPtr = &data->transitionNumber; int current = *transitionPtr; int next = transition; logDebug("transitions.log", fmt::format("Current state {:d}, transition to {:d}", current, next)); auto& midgardApi = CMidgardApi::get(); auto& menuPhase = CMenuPhaseApi::get(); while (true) { switch (current) { default: break; case 12: { logDebug("transitions.log", "current is 12"); auto midgard = midgardApi.instance(); midgardApi.setClientsNetProxy(midgard, thisptr); *transitionPtr = 15; goto label_5; } case 13: { logDebug("transitions.log", "current is 13"); *transitionPtr = next != 0 ? 15 : 27; label_5: next = 0; transitionPtr = &thisptr->data->transitionNumber; current = *transitionPtr; if (*transitionPtr > 36) { return; } continue; } case 20: logDebug("transitions.log", "current is 20"); thisptr->data->transitionNumber = 21; [[fallthrough]]; case 21: // Creates CMenuMain, sets transition to 0 logDebug("transitions.log", "current is 21"); menuPhase.switchToMain(thisptr); break; case 0: // CMenuMain state. // next 0: shows 'TRANS_MAIN2SINGLE' animation, sets transition to 22 // next 1: shows 'TRANS_MAIN2PROTO' animation, sets transition to 23 // next 2: shows 'intro' animation, sets transition to 17 // next 3: shows 'credits' animation, sets transition to 18 logDebug("transitions.log", "current is 0"); menuPhase.transitionFromMain(thisptr, next); break; case 22: // CMenuMain -> CMenuSingle animation state. // Creates CMenuSingle, sets transition to 1 logDebug("transitions.log", "current is 22"); menuPhase.switchToSingle(thisptr); break; case 1: // CMenuSingle state. // next 0: shows 'TRANS_SINGLE2GOD' animation, sets transition to 26 // next 1: shows 'TRANS_SINGLE2LOAD' animation, sets transition to 34 // next 2: shows 'TRANS_SINGLE2NEW' animation, sets transition to 27 // next 3: shows 'TRANS_SINGLE2LOAD' animation, sets transition to 33 // next 4: shows 'TRANS_SINGLE2NEW' animation, sets transition to 29 // next 5: shows 'TRANS_SINGLE2NEW' animation, sets transition to 32 logDebug("transitions.log", "current is 1"); menuPhase.transitionFromSingle(thisptr, next); break; case 2: { // CMenuProtocol state logDebug("transitions.log", "current is 2"); if (next == 2) { // Show new fullscreen animation logDebug("transitions.log", "Try to transition to 35 while playing animation"); menuPhase.showFullScreenAnimation(thisptr, &data->transitionNumber, &data->interfManager, &data->currentMenu, 35, "TRANS_PROTO2MULTI"); } else { menuPhase.transitionFromProto(thisptr, next); } break; } case 35: { // Create custom lobby menu window during fullscreen animation CreateMenuCallback tmp = createCustomLobbyMenu; CreateMenuCallback* callback = &tmp; logDebug("transitions.log", "Try to transition to 36"); menuPhase.doTransition(thisptr, &data->transitionNumber, &data->interfManager, &data->currentMenu, &data->transitionAnimation, 36, nullptr, &callback); } case 36: { // CMenuCustomLobby state logDebug("transitions.log", "current is 36"); break; } case 3: // CMenuHotseat state. // next 0: shows 'TRANS_HOTSEAT2NEW' animation, sets transition to 9 // next 1: shows 'TRANS_HOTSEAT2LOAD' animation, sets transition to 10 logDebug("transitions.log", "current is 3"); menuPhase.transitionFromHotseat(thisptr, next); break; case 26: logDebug("transitions.log", "current is 26"); menuPhase.switchToRaceCampaign(thisptr); break; case 5: logDebug("transitions.log", "current is 5"); menuPhase.transitionGodToLord(thisptr, next); break; case 29: logDebug("transitions.log", "current is 29"); menuPhase.switchToCustomCampaign(thisptr); break; case 8: logDebug("transitions.log", "current is 8"); menuPhase.transitionNewQuestToGod(thisptr, next); break; case 27: logDebug("transitions.log", "current is 27"); menuPhase.switchToNewSkirmish(thisptr); break; case 6: { logDebug("transitions.log", "current is 6"); if (next == 0) { logDebug("transitions.log", "switch to 15 or 28"); menuPhase.switchTo15Or28(thisptr); } else if (next == 1) { menuPhase.showFullScreenAnimation(thisptr, &data->transitionNumber, &data->interfManager, &data->currentMenu, 37, "TRANS_NEWQUEST2RNDSINGLE"); } else if (next == 2) { // CMenuNewSkirmishMulti -> CMenuRandomScenarioMulti menuPhase.showFullScreenAnimation(thisptr, &data->transitionNumber, &data->interfManager, &data->currentMenu, 41, "TRANS_HOST2RNDMULTI"); } else { logError("mssProxyError.log", "Invalid next transition from state 6"); return; } break; } case 41: { // CMenuRandomScenarioMulti animation state logDebug("transitions.log", "current is 41"); // Create random scenario multi menu window during fullscreen animaation CreateMenuCallback tmp = createMenuRandomScenarioMulti; CreateMenuCallback* callback = &tmp; logDebug("transitions.log", "Try to transition to 42"); menuPhase.doTransition(thisptr, &data->transitionNumber, &data->interfManager, &data->currentMenu, &data->transitionAnimation, 42, nullptr, &callback); break; } case 42: { // CMenuRandomScenarioMulti state logDebug("transitions.log", "current is 42, switch to 15"); menuPhase.switchTo15Or28(thisptr); break; } case 37: { // CMenuRandomScenarioSingle animation state logDebug("transitions.log", "current is 37"); // Create random scenario single menu window during fullscreen animation CreateMenuCallback tmp = createMenuRandomScenarioSingle; CreateMenuCallback* callback = &tmp; logDebug("transitions.log", "Try to transition to 38"); menuPhase.doTransition(thisptr, &data->transitionNumber, &data->interfManager, &data->currentMenu, &data->transitionAnimation, 38, nullptr, &callback); break; } case 38: { // CMenuRandomScenarioSingle state logDebug("transitions.log", "current is 38"); menuPhase.showFullScreenAnimation(thisptr, &data->transitionNumber, &data->interfManager, &data->currentMenu, 28, "TRANS_RNDSINGLE2GOD"); break; } case 28: logDebug("transitions.log", "current is 28"); menuPhase.switchToRaceSkirmish(thisptr); break; case 7: logDebug("transitions.log", "current is 7"); menuPhase.transitionGodToLord(thisptr, next); break; case 31: logDebug("transitions.log", "current is 31"); menuPhase.switchToLord(thisptr); break; case 33: // CMenuMulti -> CMenuLoad animation state. // For GameSpy creates CMenuLoadSkirmishGameSpy, sets transition to 15 // If loading scenario, creates CMenuLoadSkirmishMulti, sets transition to 15 // Otherwise, creates CMenuLoad, sets transition to 16 logDebug("transitions.log", "current is 33"); menuPhase.switchToLoadSkirmish(thisptr); break; case 34: logDebug("transitions.log", "current is 34"); menuPhase.switchToLoadCampaign(thisptr); break; case 32: logDebug("transitions.log", "current is 32"); menuPhase.switchToLoadCustomCampaign(thisptr); break; case 17: // Shows 'TRANS_INTRO2MAIN', sets transition to 20 logDebug("transitions.log", "current is 17"); menuPhase.switchIntroToMain(thisptr); break; case 18: logDebug("transitions.log", "current is 18"); menuPhase.transitionToCredits(thisptr, next); break; case 19: logDebug("transitions.log", "current is 19"); menuPhase.switchIntroToMain(thisptr); break; case 23: // CMenuMain -> CMenuProtocol animation state. // Creates CMenuProtocol, sets transition to 2 logDebug("transitions.log", "current is 23"); menuPhase.switchToProtocol(thisptr); break; case 25: // CMenuProtocol -> CMenuMulti animation state. // Creates CMenuMulti, sets transition to 4. logDebug("transitions.log", "current is 25"); menuPhase.switchToMulti(thisptr); break; case 4: // CMenuMulti state. // next 0: shows 'TRANS_MULTI2HOST' animation, sets transition to 27 // next 1: shows 'TRANS_MULTI2JOIN' animation, sets transition to 11 // next 2: shows 'TRANS_MULTI2LOAD' animation, sets transition to 33 logDebug("transitions.log", "current is 4"); menuPhase.transitionFromMulti(thisptr, next); break; case 24: // CMenuProtocol -> CMenuHotseat animation state. // Creates CMenuHotseat, sets transition to 3. logDebug("transitions.log", "current is 24"); menuPhase.switchToHotseat(thisptr); break; case 9: // CMenuHotseat -> CMenuNewSkirmishHotseat animation state. // Creates CMenuNewSkirmishHotseat, sets transition to 30 logDebug("transitions.log", "current is 9"); menuPhase.switchToNewSkirmishHotseat(thisptr); break; case 10: // CMenuHotseat -> CMenuLoadSkirmishHotseat animation state. // Creates CMenuLoadSkirmishHotseat, sets transition to 16 logDebug("transitions.log", "current is 10"); menuPhase.switchToLoadSkirmishHotseat(thisptr); break; case 30: { // CMenuNewSkirmishHotseat state. logDebug("transitions.log", "current is 30"); if (next == 0) { // Shows 'TRANS_NEW2HSLOBBY' animation, sets transition to 14 menuPhase.showFullScreenAnimation(thisptr, &data->transitionNumber, &data->interfManager, &data->currentMenu, 14, "TRANS_NEW2HSLOBBY"); } else if (next == 1) { // Reuse animation when transitioning from CMenuNewSkirmishHotseat // to CMenuRandomScenarioSingle menuPhase.showFullScreenAnimation(thisptr, &data->transitionNumber, &data->interfManager, &data->currentMenu, 39, "TRANS_NEWQUEST2RNDSINGLE"); } else { logError("mssProxyError.log", "Invalid next transition from state 30"); return; } break; } case 39: { // CMenuNewSkirmishHotseat -> CMenuRandomScenarioSingle animation state. // Create random scenario single menu window during fullscreen animation. // Reuse CMenuRandomScenarioSingle for hotseat games CreateMenuCallback tmp = createMenuRandomScenarioSingle; CreateMenuCallback* callback = &tmp; logDebug("transitions.log", "current is 39, try to transition to 40"); menuPhase.doTransition(thisptr, &data->transitionNumber, &data->interfManager, &data->currentMenu, &data->transitionAnimation, 40, nullptr, &callback); break; } case 40: { // CMenuRandomScenarioSingle state for hotseat game mode. // Creates CMenuHotseatLobby, sets transition to 14 logDebug("transitions.log", "current is 40"); menuPhase.showFullScreenAnimation(thisptr, &data->transitionNumber, &data->interfManager, &data->currentMenu, 14, "TRANS_RND2HSLOBBY"); break; } case 14: // CMenuNewSkirmishHotseat -> CMenuHotseatLobby animation state. // Creates CMenuHotseatLobby, sets transition to 16 logDebug("transitions.log", "current is 14"); menuPhase.switchToHotseatLobby(thisptr); break; case 11: logDebug("transitions.log", "current is 11"); menuPhase.switchToSession(thisptr); break; case 15: logDebug("transitions.log", "current is 15"); menuPhase.switchToLobbyHostJoin(thisptr); break; case 16: // Creates CMidClient, deletes CMenuPhase logDebug("transitions.log", "current is 16"); menuPhase.switchToWait(thisptr); break; } break; } } } // namespace hooks
16,797
C++
.cpp
372
31.744624
95
0.569495
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,130
netmsgcallbacks.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/netmsgcallbacks.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "netmsgcallbacks.h" #include "version.h" #include <array> namespace game::NetMsgApi { // clang-format off static std::array<Api, 3> functions = {{ // Akella Api{ (Api::AllocateEntryData)0x4eaca5, (Api::FreeEntryData)0x40fb9d, (Api::AddEntry)0x55baa9, }, // Russobit Api{ (Api::AllocateEntryData)0x4eaca5, (Api::FreeEntryData)0x40fb9d, (Api::AddEntry)0x55baa9, }, // Gog Api{ (Api::AllocateEntryData)0x4ea157, (Api::FreeEntryData)0x40f75b, (Api::AddEntry)0x55b1b8, }, }}; // clang-format on Api& get() { return functions[static_cast<int>(hooks::gameVersion())]; } } // namespace game::NetMsgApi
1,532
C++
.cpp
49
27.530612
72
0.70433
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,131
utils.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/utils.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "utils.h" #include "game.h" #include "interfmanager.h" #include "log.h" #include "mempool.h" #include "midgardmsgbox.h" #include "midgardobjectmap.h" #include "midmsgboxbuttonhandlerstd.h" #include "midscenvariables.h" #include "smartptr.h" #include "uimanager.h" #include <Windows.h> #include <fmt/format.h> #include <fstream> #include <random> #include <wincrypt.h> namespace hooks { std::string trimSpaces(const std::string& str) { const auto begin = str.find_first_not_of(" "); if (begin == std::string::npos) { return ""; } const auto end = str.find_last_not_of(" "); return str.substr(begin, end - begin + 1); } const std::filesystem::path& gameFolder() { static std::filesystem::path folder{}; if (folder.empty()) { folder = exePath(); folder.remove_filename(); } return folder; } const std::filesystem::path& globalsFolder() { static const std::filesystem::path folder{gameFolder() / "Globals"}; return folder; } const std::filesystem::path& scriptsFolder() { static const std::filesystem::path folder{gameFolder() / "Scripts"}; return folder; } const std::filesystem::path& modifiersFolder() { static const std::filesystem::path folder{gameFolder() / "Scripts" / "Modifiers"}; return folder; } const std::filesystem::path& templatesFolder() { static const std::filesystem::path folder{gameFolder() / "Templates"}; return folder; } const std::filesystem::path& exportsFolder() { static const std::filesystem::path folder{gameFolder() / "Exports"}; return folder; } const std::filesystem::path& exePath() { static std::filesystem::path exe{}; if (exe.empty()) { HMODULE module = GetModuleHandle(NULL); std::string moduleName(MAX_PATH, '\0'); GetModuleFileName(module, &moduleName[0], MAX_PATH - 1); exe = std::filesystem::path(moduleName); } return exe; } std::string idToString(const game::CMidgardID* id, bool lowercase) { char idString[11] = {0}; game::CMidgardIDApi::get().toString(id, idString); if (lowercase) { for (auto& c : idString) { c = (char)std::tolower((unsigned char)c); } } return {idString}; } std::string getInterfaceText(const char* textIdString) { using namespace game; if (textIdString == nullptr || strlen(textIdString) == 0) return ""; CMidgardID textId{}; CMidgardIDApi::get().fromString(&textId, textIdString); return {gameFunctions().getInterfaceText(&textId)}; } std::string getInterfaceText(const char* textIdString, const char* def) { using namespace game; if (textIdString == nullptr || strlen(textIdString) == 0) { return def; } CMidgardID textId{}; CMidgardIDApi::get().fromString(&textId, textIdString); return {gameFunctions().getInterfaceText(&textId)}; } const char* getGlobalText(const game::CMidgardID& textId) { using namespace game; const auto& globalApi = GlobalDataApi::get(); const auto texts = (*globalApi.getGlobalData())->texts; return globalApi.findTextById(texts, &textId); } const char* getGlobalText(const std::string& textIdString) { using namespace game; CMidgardID textId{}; CMidgardIDApi::get().fromString(&textId, textIdString.c_str()); if (textId == invalidId) return ""; return getGlobalText(textId); } bool replace(std::string& str, const std::string& keyword, const std::string& replacement) { const auto pos = str.find(keyword); if (pos == std::string::npos) { return false; } str.replace(pos, keyword.length(), replacement); return true; } int getRandomNumber(int min, int max) { static std::random_device dev; static std::mt19937 rng{dev()}; std::uniform_int_distribution<int> disribution(min, max); return disribution(rng); } std::string readFile(const std::filesystem::path& file) { // Do not resize resulting string to match file size because ifstream replaces \r\n with \n. // Otherwise the string is padded with 0 chars and its size() returns incorrect value. // Resulting string_view causes failures in Lua functions without explicit call to c_str. // Either use binary mode to get exact contents or use iterator approach. // While iterators are slower than binary read, Lua transforms \r\n to \n by itself anyway. std::ifstream stream(file); return std::string(std::istreambuf_iterator<char>(stream), std::istreambuf_iterator<char>()); } bool readUserSelectedFile(std::string& contents, const char* filter, const char* directory) { OPENFILENAME ofn; ZeroMemory(&ofn, sizeof(ofn)); char file[MAX_PATH]; ZeroMemory(file, sizeof(file)); ofn.lStructSize = sizeof(ofn); ofn.lpstrFile = file; ofn.lpstrFile[0] = 0; ofn.nMaxFile = sizeof(file); ofn.lpstrFilter = filter; ofn.nFilterIndex = 1; ofn.lpstrInitialDir = directory; ofn.lpstrFileTitle = NULL; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; ofn.hwndOwner = FindWindowEx(nullptr, nullptr, "MQ_UIManager", nullptr); if (!GetOpenFileName(&ofn)) { return false; } contents = readFile(std::filesystem::path{file}); return true; } void showInterface(game::CInterface* interf) { using namespace game; InterfManagerImplPtr ptr; CInterfManagerImplApi::get().get(&ptr); ptr.data->CInterfManagerImpl::CInterfManager::vftable->showInterface(ptr.data, interf); SmartPointerApi::get().createOrFree((SmartPointer*)&ptr, nullptr); } void hideInterface(game::CInterface* interf) { using namespace game; InterfManagerImplPtr ptr; CInterfManagerImplApi::get().get(&ptr); ptr.data->CInterfManagerImpl::CInterfManager::vftable->hideInterface(ptr.data, interf); SmartPointerApi::get().createOrFree((SmartPointer*)&ptr, nullptr); } void showMessageBox(const std::string& message, game::CMidMsgBoxButtonHandler* buttonHandler, bool showCancel) { using namespace game; auto memAlloc = Memory::get().allocate; if (!buttonHandler) { buttonHandler = (CMidMsgBoxButtonHandlerStd*)memAlloc(sizeof(CMidMsgBoxButtonHandlerStd)); buttonHandler->vftable = CMidMsgBoxButtonHandlerStdApi::vftable(); } CMidgardMsgBox* msgBox = (CMidgardMsgBox*)memAlloc(sizeof(CMidgardMsgBox)); CMidgardMsgBoxApi::get().constructor(msgBox, message.c_str(), showCancel, buttonHandler, nullptr, nullptr); showInterface(msgBox); } void showErrorMessageBox(const std::string& message) { logError("mssProxyError.log", message); MessageBox(NULL, message.c_str(), "mss32.dll proxy", MB_OK); } void createTimerEvent(game::UiEvent* timerEvent, void* userData, void* callback, std::uint32_t timeoutMs) { using namespace game; const auto freeFunctor = SmartPointerApi::get().createOrFreeNoDtor; const auto& uiManagerApi = CUIManagerApi::get(); using TimerCallback = CUIManagerApi::Api::TimerEventCallback; TimerCallback timerCallback{}; timerCallback.callback = (TimerCallback::Callback)callback; SmartPointer functor; uiManagerApi.createTimerEventFunctor(&functor, 0, userData, &timerCallback); UIManagerPtr uiManager; uiManagerApi.get(&uiManager); uiManagerApi.createTimerEvent(uiManager.data, timerEvent, &functor, timeoutMs); freeFunctor(&functor, nullptr); SmartPointerApi::get().createOrFree((SmartPointer*)&uiManager, nullptr); } std::uint32_t createMessageEvent(game::UiEvent* messageEvent, void* userData, void* callback, const char* messageName) { using namespace game; const auto freeFunctor = SmartPointerApi::get().createOrFreeNoDtor; const auto& uiManagerApi = CUIManagerApi::get(); using MessageCallback = CUIManagerApi::Api::MessageEventCallback; MessageCallback messageCallback = (MessageCallback)callback; SmartPointer functor; uiManagerApi.createMessageEventFunctor(&functor, 0, userData, &messageCallback); UIManagerPtr uiManager; uiManagerApi.get(&uiManager); std::uint32_t messageId = uiManagerApi.registerMessage(uiManager.data, messageName); uiManagerApi.createMessageEvent(uiManager.data, messageEvent, &functor, messageId); freeFunctor(&functor, nullptr); SmartPointerApi::get().createOrFree((SmartPointer*)&uiManager, nullptr); return messageId; } bool computeHash(const std::filesystem::path& folder, std::string& hash) { struct HashGuard { HashGuard() = default; ~HashGuard() { CryptDestroyHash(hash); CryptReleaseContext(provider, 0); } HCRYPTPROV provider{}; HCRYPTHASH hash{}; }; std::vector<std::filesystem::path> filenames; for (const auto& entry : std::filesystem::directory_iterator(folder)) { filenames.push_back(entry.path()); } std::sort(filenames.begin(), filenames.end()); HashGuard guard; if (!CryptAcquireContext(&guard.provider, nullptr, nullptr, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { logError("mssProxyError.log", fmt::format("Could not acquire context, reason {:d}", GetLastError())); return false; } if (!CryptCreateHash(guard.provider, CALG_MD5, 0, 0, &guard.hash)) { logError("mssProxyError.log", fmt::format("Could not create hash, reason {:d}", GetLastError())); return false; } for (const auto& file : filenames) { std::ifstream stream{file, std::ios_base::binary}; if (!stream) { logError("mssProxyError.log", fmt::format("Could not open file '{:s}'", file.filename().string())); return false; } const auto size = static_cast<size_t>(std::filesystem::file_size(file)); std::vector<unsigned char> contents(size); stream.read(reinterpret_cast<char*>(contents.data()), size); stream.close(); if (!CryptHashData(guard.hash, contents.data(), size, 0)) { logError("mssProxyError.log", fmt::format("Compute hash failed, reason {:d}", GetLastError())); return false; } } constexpr size_t md5Length{16}; DWORD length{md5Length}; unsigned char md5Hash[md5Length] = {0}; if (!CryptGetHashParam(guard.hash, HP_HASHVAL, md5Hash, &length, 0)) { logError("mssProxyError.log", fmt::format("Could not get hash value, reason {:d}", GetLastError())); return false; } hash.clear(); static const char hexDigits[] = "0123456789abcdef"; for (DWORD i = 0; i < length; ++i) { hash += hexDigits[md5Hash[i] >> 4]; hash += hexDigits[md5Hash[i] & 0xf]; } return true; } void forEachScenarioObject(game::IMidgardObjectMap* objectMap, game::IdType idType, const std::function<void(const game::IMidScenarioObject*)>& func) { using namespace game; IteratorPtr current{}; objectMap->vftable->begin(objectMap, &current); IteratorPtr end{}; objectMap->vftable->end(objectMap, &end); const auto& getType{CMidgardIDApi::get().getType}; while (!current.data->vftable->end(current.data, end.data)) { const auto* id{current.data->vftable->getObjectId(current.data)}; if (getType(id) == idType) { func(objectMap->vftable->findScenarioObjectById(objectMap, id)); } current.data->vftable->advance(current.data); } const auto& free{SmartPointerApi::get().createOrFree}; free((SmartPointer*)&current, nullptr); free((SmartPointer*)&end, nullptr); } } // namespace hooks
12,787
C++
.cpp
343
31.510204
98
0.680408
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,132
unitviewdummy.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/unitviewdummy.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "unitviewdummy.h" #include "modifierview.h" #include "unitimplview.h" #include <sol/sol.hpp> namespace bindings { UnitViewDummy::UnitViewDummy(const game::CMidgardID& id, const game::IUsUnit* impl, int xp, int hp, int hpMax) : id(id) , impl(impl) , xp(xp) , hp(hp) , hpMax(hpMax) { } void UnitViewDummy::bind(sol::state& lua) { auto unit = lua.new_usertype<UnitViewDummy>("UnitViewDummy"); unit["id"] = sol::property(&UnitViewDummy::getId); unit["xp"] = sol::property(&UnitViewDummy::getXp); unit["hp"] = sol::property(&UnitViewDummy::getHp); unit["hpMax"] = sol::property(&UnitViewDummy::getHpMax); unit["impl"] = sol::property(&UnitViewDummy::getImpl); unit["baseImpl"] = sol::property(&UnitViewDummy::getBaseImpl); unit["leveledImpl"] = sol::property(&UnitViewDummy::getLeveledImpl); // For backward compatibility unit["modifiers"] = sol::property(&UnitViewDummy::getModifiers); unit["type"] = sol::property(&UnitViewDummy::getLeaderCategory); unit["movement"] = sol::property(&UnitViewDummy::getMovement); unit["scout"] = sol::property(&UnitViewDummy::getScout); unit["leadership"] = sol::property(&UnitViewDummy::getLeadership); unit["hasAbility"] = &UnitViewDummy::hasAbility; unit["hasMoveBonus"] = &UnitViewDummy::hasMoveBonus; } game::CMidgardID UnitViewDummy::getIdInternal() const { return id; } const game::IUsUnit* UnitViewDummy::getImplInternal() const { return impl; } int UnitViewDummy::getXpInternal() const { return xp; } int UnitViewDummy::getHpInternal() const { return hp; } int UnitViewDummy::getHpMaxInternal() const { return hpMax; } } // namespace bindings
2,635
C++
.cpp
74
31.256757
72
0.697647
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,133
rodview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/rodview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "rodview.h" #include "gameutils.h" #include "midrod.h" #include "playerview.h" #include <sol/sol.hpp> namespace bindings { RodView::RodView(const game::CMidRod* rod, const game::IMidgardObjectMap* objectMap) : rod{rod} , objectMap{objectMap} { } void RodView::bind(sol::state& lua) { auto rodView = lua.new_usertype<RodView>("RodView"); rodView["id"] = sol::property(&RodView::getId); rodView["position"] = sol::property(&RodView::getPosition); rodView["owner"] = sol::property(&RodView::getOwner); } IdView RodView::getId() const { return IdView{rod->id}; } Point RodView::getPosition() const { return Point{rod->mapElement.position}; } std::optional<PlayerView> RodView::getOwner() const { auto player = hooks::getPlayer(objectMap, &rod->ownerId); if (!player) { return std::nullopt; } return {PlayerView{player, objectMap}}; } } // namespace bindings
1,740
C++
.cpp
52
30.884615
84
0.731388
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,134
scenvariablesview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/scenvariablesview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "scenvariablesview.h" #include "log.h" #include "scenariovariableview.h" #include "utils.h" #include <algorithm> #include <fmt/format.h> #include <sol/sol.hpp> namespace bindings { ScenVariablesView::ScenVariablesView(const game::CMidScenVariables* scenVariables) : scenVariables(scenVariables) { // Game does not have functions for search variables by name, // but accessing them using it is convenient for scripts. // Cache scenario variables for our own fast search by name. // This is safe because variables list is created once // and there are no additions or deletions of them during the game. for (const auto& variable : scenVariables->variables) { variables[variable.second.name] = &variable; } } void ScenVariablesView::bind(sol::state& lua) { auto vars = lua.new_usertype<ScenVariablesView>("ScenarioVariables"); vars["getVariable"] = &ScenVariablesView::getScenarioVariable; } std::optional<ScenarioVariableView> ScenVariablesView::getScenarioVariable( const std::string& name) const { std::string ingameName{name}; // Game stores variable names in uppercase std::transform(ingameName.begin(), ingameName.end(), ingameName.begin(), toupper); const auto it = variables.find(ingameName); if (it == variables.end()) { return std::nullopt; } return ScenarioVariableView{it->second}; } } // namespace bindings
2,234
C++
.cpp
56
36.875
86
0.74977
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,135
idview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/idview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "idview.h" #include <sol/sol.hpp> namespace bindings { IdView::IdView(const char* id) { if (id) { game::CMidgardIDApi::get().fromString(&this->id, id); } else { this->id = game::emptyId; } } IdView::IdView(const std::string& id) { if (!id.empty()) { game::CMidgardIDApi::get().fromString(&this->id, id.c_str()); } else { this->id = game::emptyId; } } IdView::IdView(const game::CMidgardID* id) : id(id ? *id : game::emptyId) { } IdView::IdView(const game::CMidgardID& id) : id(id) { } void IdView::bind(sol::state& lua) { auto id = lua.new_usertype<IdView>( "Id", sol::constructors<IdView(const char*), IdView(const std::string&), IdView(const game::CMidgardID*), IdView(const game::CMidgardID&)>()); id["value"] = sol::property(&IdView::getValue); id["typeIndex"] = sol::property(&IdView::getTypeIndex); id["emptyId"] = IdView::getEmptyId; } int IdView::getValue() const { return id.value; } int IdView::getTypeIndex() const { // Duplicates impl of CMidgardIDApi::GetTypeIndex for better performance return id.value & 0xFFFF; } IdView IdView::getEmptyId() { return IdView{game::emptyId}; } } // namespace bindings
2,085
C++
.cpp
67
27.641791
95
0.686099
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,136
groupview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/groupview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "groupview.h" #include "game.h" #include "idview.h" #include "midunitgroup.h" #include "unitslotview.h" #include "unitview.h" #include <sol/sol.hpp> namespace bindings { GroupView::GroupView(const game::CMidUnitGroup* group, const game::IMidgardObjectMap* objectMap, const game::CMidgardID* groupId) : group{group} , objectMap{objectMap} , groupId{*groupId} { } void GroupView::bind(sol::state& lua) { auto group = lua.new_usertype<GroupView>("GroupView"); group["id"] = sol::property(&GroupView::getId); group["slots"] = sol::property(&GroupView::getSlots); group["units"] = sol::property(&GroupView::getUnits); group["hasUnit"] = sol::overload<>(&GroupView::hasUnit, &GroupView::hasUnitById); } IdView GroupView::getId() const { return IdView{groupId}; } GroupView::GroupSlots GroupView::getSlots() const { const auto& fn = game::gameFunctions(); GroupSlots slots; for (size_t i = 0; i < std::size(group->positions); ++i) { const auto& unitId{group->positions[i]}; if (unitId == game::emptyId) { slots.emplace_back(UnitSlotView(nullptr, i, &groupId)); continue; } // Unit can be null in case where a map is in a state of loading, group object is already // serialized, while some (or all) of its units are not (yet). auto unit = fn.findUnitById(objectMap, &unitId); if (unit) { slots.emplace_back(UnitSlotView(unit, i, &groupId)); } } return slots; } GroupView::GroupUnits GroupView::getUnits() const { const auto& fn = game::gameFunctions(); GroupUnits units; for (const game::CMidgardID* it = group->units.bgn; it != group->units.end; ++it) { auto unit = fn.findUnitById(objectMap, it); if (unit) { units.emplace_back(UnitView(unit)); } } return units; } bool GroupView::hasUnit(const bindings::UnitView& unit) const { auto unitId = unit.getId(); return hasUnitById(unitId); } bool GroupView::hasUnitById(const bindings::IdView& unitId) const { auto& units = group->units; for (const game::CMidgardID* it = units.bgn; it != units.end; ++it) { if (unitId.id == *it) return true; } return false; } } // namespace bindings
3,160
C++
.cpp
91
30.076923
97
0.674967
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,137
playerview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/playerview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "playerview.h" #include "fogview.h" #include "gameutils.h" #include "globaldata.h" #include "lordtype.h" #include "midplayer.h" #include "racetype.h" #include <sol/sol.hpp> namespace bindings { PlayerView::PlayerView(const game::CMidPlayer* player, const game::IMidgardObjectMap* objectMap) : player{player} , objectMap{objectMap} { } void PlayerView::bind(sol::state& lua) { auto view = lua.new_usertype<PlayerView>("PlayerView"); view["id"] = sol::property(&PlayerView::getId); view["race"] = sol::property(&PlayerView::getRaceCategoryId); view["lord"] = sol::property(&PlayerView::getLordCategoryId); view["bank"] = sol::property(&PlayerView::getBank); view["human"] = sol::property(&PlayerView::isHuman); view["alwaysAi"] = sol::property(&PlayerView::isAlwaysAi); view["fog"] = sol::property(&PlayerView::getFog); } IdView PlayerView::getId() const { return player->id; } int PlayerView::getRaceCategoryId() const { const auto raceType = player->raceType; if (!raceType) return game::emptyCategoryId; return (int)raceType->data->raceType.id; } int PlayerView::getLordCategoryId() const { using namespace game; const auto& globalApi = GlobalDataApi::get(); const auto lords = (*globalApi.getGlobalData())->lords; const auto lordType = (TLordType*)globalApi.findById(lords, &player->lordId); if (!lordType) return game::emptyCategoryId; return (int)lordType->data->lordCategory.id; } CurrencyView PlayerView::getBank() const { return {player->bank}; } bool PlayerView::isHuman() const { return player->isHuman; } bool PlayerView::isAlwaysAi() const { return player->alwaysAi; } std::optional<FogView> PlayerView::getFog() const { const auto fog{hooks::getFog(objectMap, player)}; if (!fog) { return std::nullopt; } return FogView{fog}; } } // namespace bindings
2,735
C++
.cpp
84
29.583333
96
0.727031
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,138
point.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/point.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "point.h" #include "mqpoint.h" #include <sol/sol.hpp> namespace bindings { Point::Point() : x(0) , y(0) { } Point::Point(int x, int y) : x(x) , y(y) { } Point::Point(const game::CMqPoint& point) : x(point.x) , y(point.y) { } void Point::bind(sol::state& lua) { auto point = lua.new_usertype<Point>( "Point", sol::constructors<Point(), Point(int, int), Point(const game::CMqPoint&)>()); point["x"] = &Point::x; point["y"] = &Point::y; } } // namespace bindings
1,332
C++
.cpp
42
29.095238
94
0.699922
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,139
scenariovariableview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/scenariovariableview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "scenariovariableview.h" #include "midscenvariables.h" #include <sol/sol.hpp> namespace bindings { ScenarioVariableView::ScenarioVariableView(const game::ScenarioVariable* variable) : variable(variable) { } void ScenarioVariableView::bind(sol::state& lua) { auto var = lua.new_usertype<ScenarioVariableView>("ScenarioVariable"); var["name"] = sol::property(&ScenarioVariableView::getName); var["value"] = sol::property(&ScenarioVariableView::getValue); } std::string ScenarioVariableView::getName() const { return {variable->second.name}; } int ScenarioVariableView::getValue() const { return variable->second.value; } } // namespace bindings
1,495
C++
.cpp
40
35.175
82
0.765884
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,140
locationview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/locationview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "locationview.h" #include "midlocation.h" #include <sol/sol.hpp> namespace bindings { LocationView::LocationView(const game::CMidLocation* location) : location(location) { } void LocationView::bind(sol::state& lua) { auto location = lua.new_usertype<LocationView>("Location"); location["id"] = sol::property(&LocationView::getId); location["position"] = sol::property(&LocationView::getPosition); location["radius"] = sol::property(&LocationView::getRadius); } IdView LocationView::getId() const { return IdView{location->id}; } Point LocationView::getPosition() const { return Point{location->position}; } int LocationView::getRadius() const { // Convert radius from ingame type to actual value return location->radius * 2 + 1; } } // namespace bindings
1,620
C++
.cpp
46
32.891304
72
0.749681
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,141
attackview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/attackview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "attackview.h" #include "attack.h" #include "attackutils.h" #include "customattacks.h" #include "customattackutils.h" #include "modifierutils.h" #include "modifierview.h" #include "unitmodifier.h" #include <sol/sol.hpp> namespace bindings { AttackView::AttackView(const game::IAttack* attack) : attack{attack} { } void AttackView::bind(sol::state& lua) { auto attackView = lua.new_usertype<AttackView>("AttackView"); attackView["id"] = sol::property(&AttackView::getId); attackView["type"] = sol::property(&AttackView::getAttackClass); attackView["source"] = sol::property(&AttackView::getAttackSource); attackView["initiative"] = sol::property(&AttackView::getInitiative); attackView["power"] = sol::property(&AttackView::getPower); attackView["reach"] = sol::property(&AttackView::getReach); attackView["damage"] = sol::property(&AttackView::getDamage); attackView["heal"] = sol::property(&AttackView::getHeal); attackView["infinite"] = sol::property(&AttackView::isInfinite); attackView["crit"] = sol::property(&AttackView::canCrit); attackView["level"] = sol::property(&AttackView::getLevel); attackView["wards"] = sol::property(&AttackView::getWards); attackView["melee"] = sol::property(&AttackView::isMelee); attackView["maxTargets"] = sol::property(&AttackView::maxTargets); attackView["critDamage"] = sol::property(&AttackView::critDamage); attackView["critPower"] = sol::property(&AttackView::critPower); attackView["damageRatio"] = sol::property(&AttackView::damageRatio); attackView["damageRatioPerTarget"] = sol::property(&AttackView::damageRatioPerTarget); attackView["damageSplit"] = sol::property(&AttackView::damageSplit); } IdView AttackView::getId() const { return attack->id; } int AttackView::getAttackClass() const { auto attackClass{attack->vftable->getAttackClass(attack)}; if (!attackClass) { return 0; } return static_cast<int>(attackClass->id); } int AttackView::getAttackSource() const { auto attackSource{attack->vftable->getAttackSource(attack)}; if (!attackSource) { return 0; } return static_cast<int>(attackSource->id); } int AttackView::getInitiative() const { return attack->vftable->getInitiative(attack); } int AttackView::getPower() const { int power{}; attack->vftable->getPower(attack, &power); return power; } int AttackView::getReach() const { auto reach{attack->vftable->getAttackReach(attack)}; if (!reach) { return 0; } return static_cast<int>(reach->id); } int AttackView::getDamage() const { return attack->vftable->getQtyDamage(attack); } int AttackView::getHeal() const { return attack->vftable->getQtyHeal(attack); } bool AttackView::isInfinite() const { return attack->vftable->getInfinite(attack); } bool AttackView::canCrit() const { return attack->vftable->getCritHit(attack); } int AttackView::getLevel() const { return attack->vftable->getLevel(attack); } std::vector<ModifierView> AttackView::getWards() const { std::vector<ModifierView> result; const auto wards = attack->vftable->getWards(attack); for (const game::CMidgardID* modifierId = wards->bgn; modifierId != wards->end; modifierId++) { auto modifier = hooks::getUnitModifier(modifierId); result.push_back(ModifierView{modifier->data->modifier}); } return result; } bool AttackView::isMelee() const { return hooks::isMeleeAttack(attack); } int AttackView::maxTargets() const { auto reach{attack->vftable->getAttackReach(attack)}; return hooks::getAttackMaxTargets(reach->id); } int AttackView::critDamage() const { return hooks::getCustomAttackData(attack).critDamage; } int AttackView::critPower() const { return hooks::getCustomAttackData(attack).critPower; } int AttackView::damageRatio() const { return hooks::getCustomAttackData(attack).damageRatio; } bool AttackView::damageRatioPerTarget() const { return hooks::getCustomAttackData(attack).damageRatioPerTarget; } bool AttackView::damageSplit() const { return hooks::getCustomAttackData(attack).damageSplit; } } // namespace bindings
5,023
C++
.cpp
152
29.993421
99
0.73781
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,142
battlemsgdataview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/battlemsgdataview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "battlemsgdataview.h" #include "battlemsgdata.h" #include "gameutils.h" #include "idview.h" #include "playerview.h" #include "stackview.h" #include <sol/sol.hpp> namespace bindings { BattleMsgDataView::BattleMsgDataView(const game::BattleMsgData* battleMsgData, const game::IMidgardObjectMap* objectMap) : battleMsgData{battleMsgData} , objectMap{objectMap} { } void BattleMsgDataView::bind(sol::state& lua) { auto view = lua.new_usertype<BattleMsgDataView>("BattleView"); view["getUnitStatus"] = &BattleMsgDataView::getUnitStatus; view["currentRound"] = sol::property(&BattleMsgDataView::getCurrentRound); view["autoBattle"] = sol::property(&BattleMsgDataView::getAutoBattle); view["attackerPlayer"] = sol::property(&BattleMsgDataView::getAttackerPlayer); view["defenderPlayer"] = sol::property(&BattleMsgDataView::getDefenderPlayer); view["attacker"] = sol::property(&BattleMsgDataView::getAttacker); view["defender"] = sol::property(&BattleMsgDataView::getDefender); } bool BattleMsgDataView::getUnitStatus(const IdView& unitId, int status) const { using namespace game; return BattleMsgDataApi::get().getUnitStatus(battleMsgData, &unitId.id, (BattleStatus)status); } int BattleMsgDataView::getCurrentRound() const { return battleMsgData->currentRound; } bool BattleMsgDataView::getAutoBattle() const { return game::BattleMsgDataApi::get().isAutoBattle(battleMsgData); } std::optional<PlayerView> BattleMsgDataView::getAttackerPlayer() const { return getPlayer(battleMsgData->attackerPlayerId); } std::optional<PlayerView> BattleMsgDataView::getDefenderPlayer() const { return getPlayer(battleMsgData->defenderPlayerId); } std::optional<StackView> BattleMsgDataView::getAttacker() const { auto stack{hooks::getStack(objectMap, &battleMsgData->attackerGroupId)}; if (!stack) { return std::nullopt; } return StackView{stack, objectMap}; } std::optional<GroupView> BattleMsgDataView::getDefender() const { auto group{hooks::getGroup(objectMap, &battleMsgData->defenderGroupId)}; if (!group) { return std::nullopt; } return GroupView{group, objectMap, &battleMsgData->defenderGroupId}; } std::optional<PlayerView> BattleMsgDataView::getPlayer(const game::CMidgardID& playerId) const { auto player{hooks::getPlayer(objectMap, &playerId)}; if (!player) { return std::nullopt; } return PlayerView{player, objectMap}; } } // namespace bindings
3,351
C++
.cpp
88
34.727273
98
0.755391
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,143
unitviewbase.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/unitviewbase.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "unitviewbase.h" #include "modifierview.h" #include "unitimplview.h" #include <sol/sol.hpp> namespace bindings { std::optional<UnitImplView> UnitViewBase::getImpl() const { return {getImplInternal()}; } std::optional<UnitImplView> UnitViewBase::getBaseImpl() const { return getImpl()->getGlobal(); } std::optional<UnitImplView> UnitViewBase::getLeveledImpl() const { return getImpl()->getGenerated(); } IdView UnitViewBase::getId() const { return IdView{getIdInternal()}; } int UnitViewBase::getXp() const { return getXpInternal(); } int UnitViewBase::getHp() const { return getHpInternal(); } int UnitViewBase::getHpMax() const { return getHpMaxInternal(); } int UnitViewBase::getLeaderCategory() const { return getImpl()->getLeaderCategory(); } int UnitViewBase::getMovement() const { return getImpl()->getMovement(); } int UnitViewBase::getScout() const { return getImpl()->getScout(); } int UnitViewBase::getLeadership() const { return getImpl()->getLeadership(); } bool UnitViewBase::hasAbility(int abilityId) const { return getImpl()->hasAbility(abilityId); } bool UnitViewBase::hasMoveBonus(int groundId) const { return getImpl()->hasMoveBonus(groundId); } std::vector<ModifierView> UnitViewBase::getModifiers() const { return getImpl()->getModifiers(); } } // namespace bindings
2,181
C++
.cpp
80
25.1375
72
0.759117
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,144
itemview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/itemview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "itemview.h" #include "itembaseview.h" #include "itemutils.h" #include "miditem.h" #include <sol/sol.hpp> namespace bindings { ItemView::ItemView(const game::CMidgardID* itemId, const game::IMidgardObjectMap* objectMap) : itemId{*itemId} , objectMap{objectMap} { } void ItemView::bind(sol::state& lua) { auto view = lua.new_usertype<ItemView>("ItemView"); view["id"] = sol::property(&getId); view["base"] = sol::property(&getBase); view["sellValue"] = sol::property(&getSellValue); } IdView ItemView::getId() const { return itemId; } std::optional<ItemBaseView> ItemView::getBase() const { auto item = hooks::getGlobalItemById(objectMap, &itemId); if (!item) return std::nullopt; return ItemBaseView{item}; } CurrencyView ItemView::getSellValue() const { using namespace game; Bank bank{}; CMidItemApi::get().getSellingPrice(&bank, objectMap, &itemId); return CurrencyView{bank}; } } // namespace bindings
1,803
C++
.cpp
54
30.685185
92
0.735903
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,145
unitslotview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/unitslotview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "unitslotview.h" #include "game.h" #include "midunit.h" #include "unitview.h" #include <sol/sol.hpp> namespace bindings { UnitSlotView::UnitSlotView(const game::CMidUnit* unit, int position, const game::CMidgardID* groupId) : unit(unit) , position(position) , groupId(*groupId) { } bool UnitSlotView::operator==(const UnitSlotView& value) const { return position == value.position && groupId == value.groupId; } void UnitSlotView::bind(sol::state& lua) { auto slot = lua.new_usertype<UnitSlotView>("UnitSlot", "distance", &getDistance, sol::meta_function::equal_to, &operator==); slot["unit"] = sol::property(&getUnitView); slot["position"] = sol::property(&getPosition); slot["line"] = sol::property(&getLine); slot["column"] = sol::property(&getColumn); slot["frontline"] = sol::property(&isFrontline); slot["backline"] = sol::property(&isBackline); lua.set_function("distance", &getDistance); } std::optional<UnitView> UnitSlotView::getUnitView() const { if (unit) return {UnitView(unit)}; return std::nullopt; } int UnitSlotView::getPosition() const { return position; } int UnitSlotView::getLine() const { return position % 2; } int UnitSlotView::getColumn() const { return position / 2; } bool UnitSlotView::isFrontline() const { return position % 2 == 0; } bool UnitSlotView::isBackline() const { return position % 2 != 0; } int UnitSlotView::getDistance(const UnitSlotView& to) const { using namespace game; const auto& fn = gameFunctions(); return fn.getUnitPositionDistance(position, to.position, groupId == to.groupId); } game::CMidgardID UnitSlotView::getUnitId() const { using namespace game; return unit ? unit->id : emptyId; } const game::CMidUnit* UnitSlotView::getUnit() const { return unit; } } // namespace bindings
2,784
C++
.cpp
89
27.539326
90
0.702279
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,146
scenarioview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/scenarioview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "scenarioview.h" #include "diplomacyview.h" #include "dynamiccast.h" #include "fortview.h" #include "gameutils.h" #include "idview.h" #include "locationview.h" #include "midgardmapblock.h" #include "midgardobjectmap.h" #include "midgardplan.h" #include "midscenvariables.h" #include "playerview.h" #include "point.h" #include "rodview.h" #include "ruinview.h" #include "scenarioinfo.h" #include "scenvariablesview.h" #include "stackview.h" #include "tileview.h" #include "unitview.h" #include <sol/sol.hpp> namespace bindings { ScenarioView::ScenarioView(const game::IMidgardObjectMap* objectMap) : objectMap(objectMap) { } void ScenarioView::bind(sol::state& lua) { auto scenario = lua.new_usertype<ScenarioView>("Scenario"); scenario["getLocation"] = sol::overload<>(&ScenarioView::getLocation, &ScenarioView::getLocationById); scenario["variables"] = sol::property(&ScenarioView::getScenVariables); scenario["getTile"] = sol::overload<>(&ScenarioView::getTile, &ScenarioView::getTileByPoint); scenario["getStack"] = sol::overload<>(&ScenarioView::getStack, &ScenarioView::getStackById, &ScenarioView::getStackByCoordinates, &ScenarioView::getStackByPoint); scenario["getFort"] = sol::overload<>(&ScenarioView::getFort, &ScenarioView::getFortById, &ScenarioView::getFortByCoordinates, &ScenarioView::getFortByPoint); scenario["getRuin"] = sol::overload<>(&ScenarioView::getRuin, &ScenarioView::getRuinById, &ScenarioView::getRuinByCoordinates, &ScenarioView::getRuinByPoint); scenario["getRod"] = sol::overload<>(&ScenarioView::getRod, &ScenarioView::getRodById, &ScenarioView::getRodByCoordinates, &ScenarioView::getRodByPoint); scenario["getPlayer"] = sol::overload<>(&ScenarioView::getPlayer, &ScenarioView::getPlayerById); scenario["getUnit"] = sol::overload<>(&ScenarioView::getUnit, &ScenarioView::getUnitById); scenario["findStackByUnit"] = sol::overload<>(&ScenarioView::findStackByUnit, &ScenarioView::findStackByUnitId, &ScenarioView::findStackByUnitIdString); scenario["findFortByUnit"] = sol::overload<>(&ScenarioView::findFortByUnit, &ScenarioView::findFortByUnitId, &ScenarioView::findFortByUnitIdString); scenario["findRuinByUnit"] = sol::overload<>(&ScenarioView::findRuinByUnit, &ScenarioView::findRuinByUnitId, &ScenarioView::findRuinByUnitIdString); scenario["day"] = sol::property(&ScenarioView::getCurrentDay); scenario["size"] = sol::property(&ScenarioView::getSize); scenario["diplomacy"] = sol::property(&ScenarioView::getDiplomacy); } std::optional<LocationView> ScenarioView::getLocation(const std::string& id) const { return getLocationById(IdView{id}); } std::optional<LocationView> ScenarioView::getLocationById(const IdView& id) const { using namespace game; if (!objectMap) { return std::nullopt; } auto obj = objectMap->vftable->findScenarioObjectById(objectMap, &id.id); if (!obj) { return std::nullopt; } const auto dynamicCast = RttiApi::get().dynamicCast; const auto& rtti = RttiApi::rtti(); auto* location = (const game::CMidLocation*)dynamicCast(obj, 0, rtti.IMidScenarioObjectType, rtti.CMidLocationType, 0); if (!location) { return std::nullopt; } return LocationView{location}; } std::optional<ScenVariablesView> ScenarioView::getScenVariables() const { if (!objectMap) { return std::nullopt; } auto variables{hooks::getScenarioVariables(objectMap)}; if (!variables) { return std::nullopt; } return ScenVariablesView{variables}; } std::optional<TileView> ScenarioView::getTile(int x, int y) const { using namespace game; if (!objectMap) { return std::nullopt; } auto info = hooks::getScenarioInfo(objectMap); if (!info) { return std::nullopt; } auto block = hooks::getMidgardMapBlock(objectMap, &info->id, info->mapSize, x, y); if (!block) { return std::nullopt; } const auto& blockPos = block->position; if (x < blockPos.x || x >= blockPos.x + 8 || y < blockPos.y || y >= blockPos.y + 4) { // Outside of map block return std::nullopt; } const auto index = x + 8 * (y - blockPos.y) - blockPos.x; if (index < 0 || index >= 32) { return std::nullopt; } return TileView{block->tiles[index]}; } std::optional<TileView> ScenarioView::getTileByPoint(const Point& p) const { return getTile(p.x, p.y); } std::optional<StackView> ScenarioView::getStack(const std::string& id) const { return getStackById(IdView{id}); } std::optional<StackView> ScenarioView::getStackById(const IdView& id) const { if (!objectMap) { return std::nullopt; } auto stack = hooks::getStack(objectMap, &id.id); if (!stack) { return std::nullopt; } return StackView{stack, objectMap}; } std::optional<StackView> ScenarioView::getStackByCoordinates(int x, int y) const { auto stackId = getObjectId(x, y, game::IdType::Stack); if (!stackId) { return std::nullopt; } return getStackById(IdView{stackId}); } std::optional<StackView> ScenarioView::getStackByPoint(const Point& p) const { return getStackByCoordinates(p.x, p.y); } std::optional<StackView> ScenarioView::findStackByUnit(const UnitView& unit) const { auto unitId = unit.getId(); return findStackByUnitId(unitId); } std::optional<StackView> ScenarioView::findStackByUnitId(const IdView& unitId) const { if (!objectMap) { return std::nullopt; } auto stack = hooks::getStackByUnitId(objectMap, &unitId.id); if (!stack) { return std::nullopt; } return {StackView{stack, objectMap}}; } std::optional<StackView> ScenarioView::findStackByUnitIdString(const std::string& unitId) const { return findStackByUnitId(IdView{unitId}); } std::optional<FortView> ScenarioView::getFort(const std::string& id) const { return getFortById(IdView{id}); } std::optional<FortView> ScenarioView::getFortById(const IdView& id) const { using namespace game; if (!objectMap) { return std::nullopt; } if (CMidgardIDApi::get().getType(&id.id) != IdType::Fortification) { return std::nullopt; } auto fort = hooks::getFort(objectMap, &id.id); if (!fort) { return std::nullopt; } return {FortView{fort, objectMap}}; } std::optional<FortView> ScenarioView::getFortByCoordinates(int x, int y) const { auto fortId = getObjectId(x, y, game::IdType::Fortification); if (!fortId) { return std::nullopt; } return getFortById(IdView{fortId}); } std::optional<FortView> ScenarioView::getFortByPoint(const Point& p) const { return getFortByCoordinates(p.x, p.y); } std::optional<FortView> ScenarioView::findFortByUnit(const UnitView& unit) const { auto unitId = unit.getId(); return findFortByUnitId(unitId); } std::optional<FortView> ScenarioView::findFortByUnitId(const IdView& unitId) const { if (!objectMap) { return std::nullopt; } auto fort = hooks::getFortByUnitId(objectMap, &unitId.id); if (!fort) { return std::nullopt; } return {FortView{fort, objectMap}}; } std::optional<FortView> ScenarioView::findFortByUnitIdString(const std::string& unitId) const { return findFortByUnitId(IdView{unitId}); } std::optional<RuinView> ScenarioView::getRuin(const std::string& id) const { return getRuinById(IdView{id}); } std::optional<RuinView> ScenarioView::getRuinById(const IdView& id) const { using namespace game; if (!objectMap) { return std::nullopt; } if (CMidgardIDApi::get().getType(&id.id) != IdType::Ruin) { return std::nullopt; } auto ruin = hooks::getRuin(objectMap, &id.id); if (!ruin) { return std::nullopt; } return {RuinView{ruin, objectMap}}; } std::optional<RuinView> ScenarioView::getRuinByCoordinates(int x, int y) const { auto ruinId = getObjectId(x, y, game::IdType::Ruin); if (!ruinId) { return std::nullopt; } return getRuinById(IdView{ruinId}); } std::optional<RuinView> ScenarioView::getRuinByPoint(const Point& p) const { return getRuinByCoordinates(p.x, p.y); } std::optional<RodView> ScenarioView::getRod(const std::string& id) const { return getRodById(IdView{id}); } std::optional<RodView> ScenarioView::getRodById(const IdView& id) const { using namespace game; if (!objectMap) { return std::nullopt; } if (CMidgardIDApi::get().getType(&id.id) != IdType::Rod) { return std::nullopt; } auto rod = hooks::getRod(objectMap, &id.id); if (!rod) { return std::nullopt; } return {RodView{rod, objectMap}}; } std::optional<RodView> ScenarioView::getRodByCoordinates(int x, int y) const { auto rodId = getObjectId(x, y, game::IdType::Rod); if (!rodId) { return std::nullopt; } return getRodById(IdView{rodId}); } std::optional<RodView> ScenarioView::getRodByPoint(const Point& p) const { return getRodByCoordinates(p.x, p.y); } std::optional<RuinView> ScenarioView::findRuinByUnit(const UnitView& unit) const { auto unitId = unit.getId(); return findRuinByUnitId(unitId); } std::optional<RuinView> ScenarioView::findRuinByUnitId(const IdView& unitId) const { if (!objectMap) { return std::nullopt; } auto ruin = hooks::getRuinByUnitId(objectMap, &unitId.id); if (!ruin) { return std::nullopt; } return {RuinView{ruin, objectMap}}; } std::optional<RuinView> ScenarioView::findRuinByUnitIdString(const std::string& unitId) const { return findRuinByUnitId(IdView{unitId}); } std::optional<PlayerView> ScenarioView::getPlayer(const std::string& id) const { return getPlayerById(IdView{id}); } std::optional<PlayerView> ScenarioView::getPlayerById(const IdView& id) const { using namespace game; if (!objectMap) { return std::nullopt; } if (CMidgardIDApi::get().getType(&id.id) != IdType::Player) { return std::nullopt; } auto player = hooks::getPlayer(objectMap, &id.id); if (!player) { return std::nullopt; } return {PlayerView{player, objectMap}}; } std::optional<UnitView> ScenarioView::getUnit(const std::string& id) const { return getUnitById(IdView{id}); } std::optional<UnitView> ScenarioView::getUnitById(const IdView& id) const { using namespace game; if (!objectMap) { return std::nullopt; } if (CMidgardIDApi::get().getType(&id.id) != IdType::Unit) { return std::nullopt; } auto obj = objectMap->vftable->findScenarioObjectById(objectMap, &id.id); if (!obj) { return std::nullopt; } return {UnitView{(const CMidUnit*)obj}}; } int ScenarioView::getCurrentDay() const { if (!objectMap) { return 0; } auto info = hooks::getScenarioInfo(objectMap); return info ? info->currentTurn : 0; } int ScenarioView::getSize() const { if (!objectMap) { return 0; } auto info = hooks::getScenarioInfo(objectMap); return info ? info->mapSize : 0; } std::optional<DiplomacyView> ScenarioView::getDiplomacy() const { if (!objectMap) { return std::nullopt; } return DiplomacyView{hooks::getDiplomacy(objectMap)}; } const game::CMidgardID* ScenarioView::getObjectId(int x, int y, game::IdType type) const { using namespace game; if (!objectMap) { return nullptr; } auto plan{hooks::getMidgardPlan(objectMap)}; if (!plan) { return nullptr; } const CMqPoint position{x, y}; return CMidgardPlanApi::get().getObjectId(plan, &position, &type); } } // namespace bindings
13,302
C++
.cpp
395
27.873418
100
0.665496
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,147
ruinview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/ruinview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ruinview.h" #include "gameutils.h" #include "itemview.h" #include "midruin.h" #include "playerview.h" #include <sol/sol.hpp> namespace bindings { RuinView::RuinView(const game::CMidRuin* ruin, const game::IMidgardObjectMap* objectMap) : ruin{ruin} , objectMap{objectMap} { } void RuinView::bind(sol::state& lua) { auto ruinView = lua.new_usertype<RuinView>("RuinView"); ruinView["id"] = sol::property(&RuinView::getId); ruinView["position"] = sol::property(&RuinView::getPosition); ruinView["looter"] = sol::property(&RuinView::getLooter); ruinView["group"] = sol::property(&RuinView::getGroup); ruinView["item"] = sol::property(&RuinView::getItem); ruinView["cash"] = sol::property(&RuinView::getCash); } IdView RuinView::getId() const { return IdView{ruin->id}; } Point RuinView::getPosition() const { return Point{ruin->mapElement.position}; } std::optional<PlayerView> RuinView::getLooter() const { auto player = hooks::getPlayer(objectMap, &ruin->looterId); if (!player) { return std::nullopt; } return {PlayerView{player, objectMap}}; } GroupView RuinView::getGroup() const { return GroupView{&ruin->group, objectMap, &ruin->id}; } std::optional<ItemView> RuinView::getItem() const { if (ruin->itemId == game::emptyId) return std::nullopt; return {ItemView{&ruin->itemId, objectMap}}; } CurrencyView RuinView::getCash() const { return CurrencyView{ruin->cash}; } } // namespace bindings
2,321
C++
.cpp
70
30.414286
88
0.726988
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,148
stackview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/stackview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "stackview.h" #include "fortview.h" #include "game.h" #include "gameutils.h" #include "itemview.h" #include "midgardobjectmap.h" #include "midstack.h" #include "midsubrace.h" #include "unitview.h" #include <sol/sol.hpp> namespace bindings { StackView::StackView(const game::CMidStack* stack, const game::IMidgardObjectMap* objectMap) : stack{stack} , objectMap{objectMap} { } void StackView::bind(sol::state& lua) { auto stackView = lua.new_usertype<StackView>("StackView"); stackView["id"] = sol::property(&StackView::getId); stackView["position"] = sol::property(&StackView::getPosition); stackView["owner"] = sol::property(&StackView::getOwner); stackView["inside"] = sol::property(&StackView::getInside); stackView["group"] = sol::property(&StackView::getGroup); stackView["leader"] = sol::property(&StackView::getLeader); stackView["movement"] = sol::property(&StackView::getMovement); stackView["subrace"] = sol::property(&StackView::getSubrace); stackView["invisible"] = sol::property(&StackView::isInvisible); stackView["battlesWon"] = sol::property(&StackView::getBattlesWon); stackView["inventory"] = sol::property(&StackView::getInventoryItems); stackView["getEquippedItem"] = &StackView::getLeaderEquippedItem; } IdView StackView::getId() const { return IdView{stack->id}; } Point StackView::getPosition() const { return Point{stack->position}; } std::optional<PlayerView> StackView::getOwner() const { auto player = hooks::getPlayer(objectMap, &stack->ownerId); if (!player) { return std::nullopt; } return PlayerView{player, objectMap}; } std::optional<FortView> StackView::getInside() const { auto fort = hooks::getFort(objectMap, &stack->insideId); if (!fort) { return std::nullopt; } return {FortView{fort, objectMap}}; } GroupView StackView::getGroup() const { return GroupView{&stack->group, objectMap, &stack->id}; } std::optional<UnitView> StackView::getLeader() const { auto leaderUnit{game::gameFunctions().findUnitById(objectMap, &stack->leaderId)}; if (!leaderUnit) { return std::nullopt; } return UnitView{leaderUnit}; } int StackView::getMovement() const { return stack->movement; } int StackView::getSubrace() const { auto obj{objectMap->vftable->findScenarioObjectById(objectMap, &stack->subraceId)}; auto subrace{static_cast<const game::CMidSubRace*>(obj)}; return subrace ? static_cast<int>(subrace->subraceCategory.id) : game::emptyCategoryId; } bool StackView::isInvisible() const { return stack->invisible; } int StackView::getBattlesWon() const { return stack->nbBattle; } std::vector<ItemView> StackView::getInventoryItems() const { const auto& items = stack->inventory.items; const auto count = items.end - items.bgn; std::vector<ItemView> result; result.reserve(count); for (const game::CMidgardID* it = items.bgn; it != items.end; it++) { result.push_back(ItemView{it, objectMap}); } return result; } std::optional<ItemView> StackView::getLeaderEquippedItem(const game::EquippedItemIdx& idx) const { const auto& items = stack->leaderEquippedItems; const auto count = items.end - items.bgn; if (idx < 0 || idx >= count) return std::nullopt; auto itemId = stack->leaderEquippedItems.bgn[idx]; if (itemId == game::emptyId) return std::nullopt; return {ItemView{&itemId, objectMap}}; } } // namespace bindings
4,337
C++
.cpp
126
31.134921
96
0.722992
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,149
currencyview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/currencyview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "currencyview.h" #include <sol/sol.hpp> namespace bindings { CurrencyView::CurrencyView(const game::Bank& value) : bank(value) { } bool CurrencyView::operator==(const CurrencyView& value) const { return bank == value.bank; } bool CurrencyView::operator<(const CurrencyView& value) const { return bank < value.bank; } bool CurrencyView::operator<=(const CurrencyView& value) const { return bank <= value.bank; } void CurrencyView::bind(sol::state& lua) { auto view = lua.new_usertype<CurrencyView>( "Currency", sol::constructors<CurrencyView(const CurrencyView&)>(), sol::meta_function::equal_to, &operator==, sol::meta_function::less_than, &operator<, sol::meta_function::less_than_or_equal_to, &operator<=); view["infernalMana"] = sol::property(&getInfernalMana, &setInfernalMana); view["lifeMana"] = sol::property(&getLifeMana, &setLifeMana); view["deathMana"] = sol::property(&getDeathMana, &setDeathMana); view["runicMana"] = sol::property(&getRunicMana, &setRunicMana); view["groveMana"] = sol::property(&getGroveMana, &setGroveMana); view["gold"] = sol::property(&getGold, &setGold); } int CurrencyView::getInfernalMana() const { return bank.infernalMana; } void CurrencyView::setInfernalMana(int value) { using namespace game; BankApi::get().set(&bank, CurrencyType::InfernalMana, (int16_t)value); } int CurrencyView::getLifeMana() const { return bank.lifeMana; } void CurrencyView::setLifeMana(int value) { using namespace game; BankApi::get().set(&bank, CurrencyType::LifeMana, (int16_t)value); } int CurrencyView::getDeathMana() const { return bank.deathMana; } void CurrencyView::setDeathMana(int value) { using namespace game; BankApi::get().set(&bank, CurrencyType::DeathMana, (int16_t)value); } int CurrencyView::getRunicMana() const { return bank.runicMana; } void CurrencyView::setRunicMana(int value) { using namespace game; BankApi::get().set(&bank, CurrencyType::RunicMana, (int16_t)value); } int CurrencyView::getGroveMana() const { return bank.groveMana; } void CurrencyView::setGroveMana(int value) { using namespace game; BankApi::get().set(&bank, CurrencyType::GroveMana, (int16_t)value); } int CurrencyView::getGold() const { return bank.gold; } void CurrencyView::setGold(int value) { using namespace game; BankApi::get().set(&bank, CurrencyType::Gold, (int16_t)value); } } // namespace bindings
3,310
C++
.cpp
104
29.067308
93
0.737421
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,150
unitview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/unitview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "game.h" #include "unitview.h" #include "midunit.h" #include "modifierutils.h" #include "modifierview.h" #include "unitimplview.h" #include "unitmodifier.h" #include "unitutils.h" #include "unitviewdummy.h" #include "ussoldier.h" #include "usunitimpl.h" #include <sol/sol.hpp> namespace bindings { UnitView::UnitView(const game::CMidUnit* unit) : unit(unit) , unitImpl(nullptr) { } UnitView::UnitView(const game::CMidUnit* unit, const game::IUsUnit* unitImpl) : unit(unit) , unitImpl(unitImpl) { } void UnitView::bind(sol::state& lua) { auto unit = lua.new_usertype<UnitView>("UnitView"); unit["id"] = sol::property(&UnitView::getId); unit["xp"] = sol::property(&UnitView::getXp); unit["hp"] = sol::property(&UnitView::getHp); unit["hpMax"] = sol::property(&UnitView::getHpMax); unit["impl"] = sol::property(&UnitView::getImpl); unit["baseImpl"] = sol::property(&UnitView::getBaseImpl); unit["leveledImpl"] = sol::property(&UnitView::getLeveledImpl); unit["original"] = sol::property(&UnitView::getOriginal); unit["originalModifiers"] = sol::property(&UnitView::getOriginalModifiers); // For backward compatibility unit["modifiers"] = sol::property(&UnitView::getModifiers); unit["type"] = sol::property(&UnitView::getLeaderCategory); unit["movement"] = sol::property(&UnitView::getMovement); unit["scout"] = sol::property(&UnitView::getScout); unit["leadership"] = sol::property(&UnitView::getLeadership); unit["hasAbility"] = &UnitView::hasAbility; unit["hasMoveBonus"] = &UnitView::hasMoveBonus; } std::optional<UnitViewDummy> UnitView::getOriginal() const { if (!unit->transformed) { return std::nullopt; } return UnitViewDummy{unit->id, hooks::getUnitImpl(&unit->origTypeId), unit->origXp, unit->hpBefore, unit->hpBefMax}; } std::vector<ModifierView> UnitView::getOriginalModifiers() const { std::vector<ModifierView> result; for (auto modifierId : unit->origModifiers) { auto modifier = hooks::getUnitModifier(&modifierId); result.push_back(ModifierView{modifier->data->modifier}); } return result; } game::CMidgardID UnitView::getIdInternal() const { return unit->id; } const game::IUsUnit* UnitView::getImplInternal() const { return unitImpl ? unitImpl : unit->unitImpl; } int UnitView::getXpInternal() const { return unit->currentXp; } int UnitView::getHpInternal() const { return unit->currentHp; } int UnitView::getHpMaxInternal() const { using namespace game; if (unit->transformed && unit->keepHp) return unit->hpBefMax; auto soldier = gameFunctions().castUnitImplToSoldier(getImplInternal()); return soldier->vftable->getHitPoints(soldier); } } // namespace bindings
3,626
C++
.cpp
102
32.186275
87
0.719544
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,151
modifierview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/modifierview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "modifierview.h" #include "ummodifier.h" #include <sol/sol.hpp> namespace bindings { ModifierView::ModifierView(const game::CUmModifier* modifier) : modifier{modifier} { } void ModifierView::bind(sol::state& lua) { auto view = lua.new_usertype<ModifierView>("ModifierView"); view["id"] = sol::property(&getId); } IdView ModifierView::getId() const { return modifier->data->modifierId; } } // namespace bindings
1,255
C++
.cpp
35
33.742857
72
0.75453
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,152
diplomacyview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/diplomacyview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2023 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "diplomacyview.h" #include "diplomacyhooks.h" #include "racecategory.h" #include <sol/sol.hpp> namespace bindings { static const game::LRaceCategory* getRaceById(game::RaceId categoryId) { using namespace game; const auto& races = RaceCategories::get(); if (races.human->id == categoryId) { return races.human; } if (races.dwarf->id == categoryId) { return races.dwarf; } if (races.heretic->id == categoryId) { return races.heretic; } if (races.undead->id == categoryId) { return races.undead; } if (races.neutral->id == categoryId) { return races.neutral; } if (races.elf->id == categoryId) { return races.elf; } return nullptr; } DiplomacyView::DiplomacyView(const game::CMidDiplomacy* diplomacy) : diplomacy{diplomacy} {} void DiplomacyView::bind(sol::state& lua) { // clang-format off lua.new_enum("Relation", "War", RelationType::War, "Neutral", RelationType::Neutral, "Peace", RelationType::Peace ); // clang-format on auto view = lua.new_usertype<DiplomacyView>("DiplomacyView"); view["getCurrentRelation"] = &DiplomacyView::getCurrentRelation; view["getPreviousRelation"] = &DiplomacyView::getPreviousRelation; view["getAlliance"] = &DiplomacyView::getAlliance; view["getAllianceTurn"] = &DiplomacyView::getAllianceTurn; view["getAlwaysAtWar"] = &DiplomacyView::getAlwaysAtWar; view["getAiCouldNotBreakAlliance"] = &DiplomacyView::getAiCouldNotBreakAlliance; view["getRelationType"] = &DiplomacyView::getRelationType; } std::uint32_t DiplomacyView::getCurrentRelation(int race1CategoryId, int race2CategoryId) const { using namespace game; const LRaceCategory* race1 = getRaceById(static_cast<RaceId>(race1CategoryId)); const LRaceCategory* race2 = getRaceById(static_cast<RaceId>(race2CategoryId)); std::uint32_t relation = 0u; hooks::getCurrentRelationHooked(diplomacy, 0, &relation, race1, race2); return relation; } std::uint32_t DiplomacyView::getPreviousRelation(int race1CategoryId, int race2CategoryId) const { using namespace game; const LRaceCategory* race1 = getRaceById(static_cast<RaceId>(race1CategoryId)); const LRaceCategory* race2 = getRaceById(static_cast<RaceId>(race2CategoryId)); std::uint32_t relation = 0u; hooks::getPreviousRelationHooked(diplomacy, 0, &relation, race1, race2); return relation; } bool DiplomacyView::getAlliance(int race1CategoryId, int race2CategoryId) const { using namespace game; const LRaceCategory* race1 = getRaceById(static_cast<RaceId>(race1CategoryId)); const LRaceCategory* race2 = getRaceById(static_cast<RaceId>(race2CategoryId)); return hooks::areAlliesHooked(diplomacy, 0, race1, race2); } std::uint32_t DiplomacyView::getAllianceTurn(int race1CategoryId, int race2CategoryId) const { using namespace game; const LRaceCategory* race1 = getRaceById(static_cast<RaceId>(race1CategoryId)); const LRaceCategory* race2 = getRaceById(static_cast<RaceId>(race2CategoryId)); std::uint32_t turn = 0u; hooks::getAllianceTurnHooked(diplomacy, 0, &turn, race1, race2); return turn; } bool DiplomacyView::getAlwaysAtWar(int race1CategoryId, int race2CategoryId) const { using namespace game; const LRaceCategory* race1 = getRaceById(static_cast<RaceId>(race1CategoryId)); const LRaceCategory* race2 = getRaceById(static_cast<RaceId>(race2CategoryId)); return hooks::areAlwaysAtWarHooked(diplomacy, 0, race1, race2); } bool DiplomacyView::getAiCouldNotBreakAlliance(int race1CategoryId, int race2CategoryId) const { using namespace game; const LRaceCategory* race1 = getRaceById(static_cast<RaceId>(race1CategoryId)); const LRaceCategory* race2 = getRaceById(static_cast<RaceId>(race2CategoryId)); return hooks::aiCouldNotBreakAllianceHooked(diplomacy, 0, race1, race2); } int DiplomacyView::getRelationType(std::uint32_t relations) const { using namespace hooks; if (areRelationsAtWarHooked(&relations)) { return static_cast<int>(RelationType::War); } if (areRelationsNeutralHooked(&relations)) { return static_cast<int>(RelationType::Neutral); } if (areRelationsPeacefulHooked(&relations)) { return static_cast<int>(RelationType::Peace); } // This should never happen // Assume war relations return static_cast<int>(RelationType::War); } }
5,319
C++
.cpp
133
35.819549
96
0.742474
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,153
fogview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/fogview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2023 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "fogview.h" #include "midgardmapfog.h" #include "point.h" #include <sol/sol.hpp> namespace bindings { FogView::FogView(const game::CMidgardMapFog* mapFog) : mapFog(mapFog) { } void FogView::bind(sol::state& lua) { auto view = lua.new_usertype<FogView>("FogView"); view["getFog"] = sol::overload<>(&FogView::getFogByCoordinates, &FogView::getFogByPoint); } IdView FogView::getId() const { return IdView{mapFog->id}; } bool FogView::getFogByCoordinates(int x, int y) const { const game::CMqPoint mapPosition{x, y}; bool fog = false; if (game::CMidgardMapFogApi::get().getFog(mapFog, &fog, &mapPosition)) { return fog; } return false; } bool FogView::getFogByPoint(const Point& p) const { return getFogByCoordinates(p.x, p.y); } } // namespace bindings
1,629
C++
.cpp
49
30.714286
93
0.736306
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,154
dynupgradeview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/dynupgradeview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "dynupgradeview.h" #include "dynupgrade.h" #include <sol/sol.hpp> namespace bindings { DynUpgradeView::DynUpgradeView(const game::CDynUpgrade* upgrade) : upgrade(upgrade) { } void DynUpgradeView::bind(sol::state& lua) { auto impl = lua.new_usertype<DynUpgradeView>("DynUpgrade"); impl["xpNext"] = sol::property(&DynUpgradeView::getXpNext); } int DynUpgradeView::getXpNext() const { return upgrade->xpNext; } } // namespace bindings
1,275
C++
.cpp
35
34.314286
72
0.758509
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,155
fortview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/fortview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "fortview.h" #include "fortification.h" #include "gameutils.h" #include "itemview.h" #include "midgardobjectmap.h" #include "midsubrace.h" #include "stackview.h" #include <sol/sol.hpp> namespace bindings { FortView::FortView(const game::CFortification* fort, const game::IMidgardObjectMap* objectMap) : fort{fort} , objectMap{objectMap} { } void FortView::bind(sol::state& lua) { auto fortView = lua.new_usertype<FortView>("FortView"); fortView["id"] = sol::property(&FortView::getId); fortView["position"] = sol::property(&FortView::getPosition); fortView["owner"] = sol::property(&FortView::getOwner); fortView["group"] = sol::property(&FortView::getGroup); fortView["visitor"] = sol::property(&FortView::getVisitor); fortView["subrace"] = sol::property(&FortView::getSubrace); fortView["inventory"] = sol::property(&FortView::getInventoryItems); fortView["capital"] = sol::property(&FortView::isCapital); fortView["tier"] = sol::property(&FortView::getTier); } IdView FortView::getId() const { return IdView{fort->id}; } Point FortView::getPosition() const { return Point{fort->mapElement.position}; } std::optional<PlayerView> FortView::getOwner() const { auto player = hooks::getPlayer(objectMap, &fort->ownerId); if (!player) { return std::nullopt; } return PlayerView{player, objectMap}; } GroupView FortView::getGroup() const { return GroupView{&fort->group, objectMap, &fort->id}; } std::optional<StackView> FortView::getVisitor() const { auto stack = hooks::getStack(objectMap, &fort->stackId); if (!stack) return std::nullopt; return {StackView{stack, objectMap}}; } int FortView::getSubrace() const { auto obj{objectMap->vftable->findScenarioObjectById(objectMap, &fort->subraceId)}; auto subrace{static_cast<const game::CMidSubRace*>(obj)}; return subrace ? static_cast<int>(subrace->subraceCategory.id) : game::emptyCategoryId; } std::vector<ItemView> FortView::getInventoryItems() const { const auto& items = fort->inventory.items; const auto count = items.end - items.bgn; std::vector<ItemView> result; result.reserve(count); for (const game::CMidgardID* it = items.bgn; it != items.end; it++) { result.push_back(ItemView{it, objectMap}); } return result; } bool FortView::isCapital() const { return getTier() == 6; } int FortView::getTier() const { const auto* vftable{static_cast<const game::CFortificationVftable*>(fort->vftable)}; return vftable->getTier(fort, objectMap); } } // namespace bindings
3,426
C++
.cpp
98
31.897959
94
0.725129
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,156
tileview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/tileview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "tileview.h" #include "midgardmapblock.h" #include <sol/sol.hpp> namespace bindings { TileView::TileView(std::uint32_t tile) : tile(tile) { } void TileView::bind(sol::state& lua) { auto tileView = lua.new_usertype<TileView>("Tile"); tileView["terrain"] = sol::property(&TileView::getTerrain); tileView["ground"] = sol::property(&TileView::getGround); } int TileView::getTerrain() const { return static_cast<int>(game::tileTerrain(tile)); } int TileView::getGround() const { return static_cast<int>(game::tileGround(tile)); } } // namespace bindings
1,401
C++
.cpp
40
32.825
72
0.744461
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,157
itembaseview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/itembaseview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "itembaseview.h" #include "attackutils.h" #include "attackview.h" #include "itembase.h" #include "itemcategory.h" #include "itemutils.h" #include "unitimplview.h" #include "unitutils.h" #include "usunitimpl.h" #include <sol/sol.hpp> namespace bindings { ItemBaseView::ItemBaseView(const game::CItemBase* item) : item{item} { } void ItemBaseView::bind(sol::state& lua) { auto view = lua.new_usertype<ItemBaseView>("ItemBaseView"); view["id"] = sol::property(&getId); view["type"] = sol::property(&getCategory); view["value"] = sol::property(&getValue); view["unitImpl"] = sol::property(&getUnitImpl); view["attack"] = sol::property(&getAttack); } IdView ItemBaseView::getId() const { return item->itemId; } int ItemBaseView::getCategory() const { auto category = item->vftable->getCategory(item); return category ? (int)category->id : game::emptyCategoryId; } CurrencyView ItemBaseView::getValue() const { using namespace game; Bank bank = *item->vftable->getValue(item); return CurrencyView{bank}; } std::optional<UnitImplView> ItemBaseView::getUnitImpl() const { using namespace game; auto unitImplId = item->data->unitId; if (unitImplId == emptyId) return std::nullopt; auto unitImpl = hooks::getUnitImpl(&unitImplId); if (!unitImpl) return std::nullopt; return UnitImplView(unitImpl); } std::optional<AttackView> ItemBaseView::getAttack() const { using namespace game; auto attackId = hooks::getAttackId(item); if (attackId == emptyId) { return std::nullopt; } auto attack = hooks::getGlobalAttack(&attackId); if (!attack) { return std::nullopt; } return AttackView(attack); } } // namespace bindings
2,583
C++
.cpp
81
28.740741
72
0.723541
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,158
unitimplview.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/bindings/unitimplview.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "unitimplview.h" #include "attackclasscat.h" #include "attacksourcecat.h" #include "attackview.h" #include "customattacks.h" #include "dynupgradeview.h" #include "game.h" #include "globaldata.h" #include "groundcat.h" #include "leaderabilitycat.h" #include "leadercategory.h" #include "log.h" #include "midsubrace.h" #include "modifierutils.h" #include "modifierview.h" #include "racecategory.h" #include "racetype.h" #include "ummodifier.h" #include "unitutils.h" #include "usleader.h" #include "ussoldier.h" #include "usstackleader.h" #include "usunitimpl.h" #include <fmt/format.h> #include <sol/sol.hpp> namespace bindings { UnitImplView::UnitImplView(const game::IUsUnit* unitImpl) : impl(unitImpl) { } void UnitImplView::bind(sol::state& lua) { auto impl = lua.new_usertype<UnitImplView>("UnitImpl"); impl["id"] = sol::property(&UnitImplView::getId); impl["level"] = sol::property(&UnitImplView::getLevel); impl["xpNext"] = sol::property(&UnitImplView::getXpNext); impl["xpKilled"] = sol::property(&UnitImplView::getXpKilled); impl["hp"] = sol::property(&UnitImplView::getHitPoint); impl["armor"] = sol::property(&UnitImplView::getArmor); impl["regen"] = sol::property(&UnitImplView::getRegen); impl["race"] = sol::property(&UnitImplView::getRace); impl["subrace"] = sol::property(&UnitImplView::getSubRace); impl["small"] = sol::property(&UnitImplView::isSmall); impl["male"] = sol::property(&UnitImplView::isMale); impl["waterOnly"] = sol::property(&UnitImplView::isWaterOnly); impl["attacksTwice"] = sol::property(&UnitImplView::attacksTwice); impl["type"] = sol::property(&UnitImplView::getUnitCategory); impl["dynUpgLvl"] = sol::property(&UnitImplView::getDynUpgLevel); impl["dynUpg1"] = sol::property(&UnitImplView::getDynUpgrade1); impl["dynUpg2"] = sol::property(&UnitImplView::getDynUpgrade2); impl["attack1"] = sol::property(&UnitImplView::getAttack); impl["attack2"] = sol::property(&UnitImplView::getAttack2); impl["altAttack"] = sol::property(&UnitImplView::getAltAttack); impl["base"] = sol::property(&UnitImplView::getBaseUnit); impl["global"] = sol::property(&UnitImplView::getGlobal); impl["generated"] = sol::property(&UnitImplView::getGenerated); impl["modifiers"] = sol::property(&UnitImplView::getModifiers); impl["hasModifier"] = sol::overload<>(&UnitImplView::hasModifier, &UnitImplView::hasModifierById); impl["leaderType"] = sol::property(&UnitImplView::getLeaderCategory); impl["movement"] = sol::property(&UnitImplView::getMovement); impl["scout"] = sol::property(&UnitImplView::getScout); impl["leadership"] = sol::property(&UnitImplView::getLeadership); impl["hasAbility"] = &UnitImplView::hasAbility; impl["hasMoveBonus"] = &UnitImplView::hasMoveBonus; impl["getImmuneToAttackClass"] = &UnitImplView::getImmuneToAttackClass; impl["getImmuneToAttackSource"] = &UnitImplView::getImmuneToAttackSource; } IdView UnitImplView::getId() const { return IdView{impl->id}; } int UnitImplView::getLevel() const { auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); return soldier ? soldier->vftable->getLevel(soldier) : 0; } int UnitImplView::getXpNext() const { auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); return soldier ? soldier->vftable->getXpNext(soldier) : 0; } int UnitImplView::getDynUpgLevel() const { auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); return soldier ? soldier->vftable->getDynUpgLvl(soldier) : 0; } int UnitImplView::getXpKilled() const { auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); return soldier ? soldier->vftable->getXpKilled(soldier) : 0; } int UnitImplView::getHitPoint() const { auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); return soldier ? soldier->vftable->getHitPoints(soldier) : 0; } int UnitImplView::getArmor() const { int armor; auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); return soldier ? *soldier->vftable->getArmor(soldier, &armor) : 0; } int UnitImplView::getRegen() const { auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); return soldier ? *soldier->vftable->getRegen(soldier) : 0; } int UnitImplView::getRace() const { using namespace game; const auto& globalApi = GlobalDataApi::get(); auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); if (!soldier) return emptyCategoryId; auto raceId = soldier->vftable->getRaceId(soldier); auto races = (*globalApi.getGlobalData())->races; auto race = (TRaceType*)globalApi.findById(races, raceId); if (!race) return emptyCategoryId; return (int)race->data->raceType.id; } int UnitImplView::getSubRace() const { auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); return soldier ? (int)soldier->vftable->getSubrace(soldier)->id : game::emptyCategoryId; } bool UnitImplView::isSmall() const { auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); return soldier ? soldier->vftable->getSizeSmall(soldier) : false; } bool UnitImplView::isMale() const { auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); return soldier ? soldier->vftable->getSexM(soldier) : false; } bool UnitImplView::isWaterOnly() const { auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); return soldier ? soldier->vftable->getWaterOnly(soldier) : false; } bool UnitImplView::attacksTwice() const { auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); return soldier ? soldier->vftable->getAttackTwice(soldier) : false; } int UnitImplView::getUnitCategory() const { using namespace game; auto category{impl->vftable->getCategory(impl)}; if (!category) { return emptyCategoryId; } return static_cast<int>(category->id); } std::optional<UnitImplView> UnitImplView::getBaseUnit() const { using namespace game; auto soldier = hooks::castUnitImplToSoldierWithLogging(impl); if (!soldier) return std::nullopt; auto baseUnitImplId = soldier->vftable->getBaseUnitImplId(soldier); if (*baseUnitImplId == emptyId) return std::nullopt; auto globalUnitImpl = hooks::getUnitImpl(baseUnitImplId); if (!globalUnitImpl) return std::nullopt; return {globalUnitImpl}; } std::optional<UnitImplView> UnitImplView::getGlobal() const { return {hooks::getGlobalUnitImpl(&impl->id)}; } std::optional<UnitImplView> UnitImplView::getGenerated() const { return {hooks::getUnitImpl(&impl->id)}; } std::vector<ModifierView> UnitImplView::getModifiers() const { using namespace game; const auto& rtti = RttiApi::rtti(); const auto dynamicCast = RttiApi::get().dynamicCast; std::vector<ModifierView> result; CUmModifier* modifier = nullptr; for (auto curr = impl; curr; curr = modifier->data->prev) { modifier = (CUmModifier*)dynamicCast(curr, 0, rtti.IUsUnitType, rtti.CUmModifierType, 0); if (!modifier) break; result.push_back(ModifierView{modifier}); } std::reverse(result.begin(), result.end()); return result; } bool UnitImplView::hasModifier(const std::string& id) const { return hasModifierById(IdView{id}); } bool UnitImplView::hasModifierById(const IdView& id) const { return hooks::hasModifier(impl, &id.id); } int UnitImplView::getLeaderCategory() const { using namespace game; auto leader{gameFunctions().castUnitImplToLeader(impl)}; if (!leader) { return emptyCategoryId; } auto category{leader->vftable->getCategory(leader)}; if (!category) { return emptyCategoryId; } return static_cast<int>(category->id); } int UnitImplView::getMovement() const { auto leader{game::gameFunctions().castUnitImplToStackLeader(impl)}; return leader ? leader->vftable->getMovement(leader) : 0; } int UnitImplView::getScout() const { auto leader{game::gameFunctions().castUnitImplToStackLeader(impl)}; return leader ? leader->vftable->getScout(leader) : 0; } int UnitImplView::getLeadership() const { auto leader{game::gameFunctions().castUnitImplToStackLeader(impl)}; return leader ? leader->vftable->getLeadership(leader) : 0; } bool UnitImplView::hasAbility(int abilityId) const { using namespace game; auto leader{gameFunctions().castUnitImplToStackLeader(impl)}; if (!leader) { return false; } auto leaderHasAbility{leader->vftable->hasAbility}; const auto& abilities{LeaderAbilityCategories::get()}; switch (static_cast<LeaderAbilityId>(abilityId)) { case LeaderAbilityId::Incorruptible: return leaderHasAbility(leader, abilities.incorruptible); case LeaderAbilityId::WeaponMaster: return leaderHasAbility(leader, abilities.weaponMaster); case LeaderAbilityId::WandScrollUse: return leaderHasAbility(leader, abilities.wandScrollUse); case LeaderAbilityId::WeaponArmorUse: return leaderHasAbility(leader, abilities.weaponArmorUse); case LeaderAbilityId::BannerUse: return leaderHasAbility(leader, abilities.bannerUse); case LeaderAbilityId::JewelryUse: return leaderHasAbility(leader, abilities.jewelryUse); case LeaderAbilityId::Rod: return leaderHasAbility(leader, abilities.rod); case LeaderAbilityId::OrbUse: return leaderHasAbility(leader, abilities.orbUse); case LeaderAbilityId::TalismanUse: return leaderHasAbility(leader, abilities.talismanUse); case LeaderAbilityId::TravelItemUse: return leaderHasAbility(leader, abilities.travelItemUse); case LeaderAbilityId::CriticalHit: return leaderHasAbility(leader, abilities.criticalHit); } return false; } bool UnitImplView::hasMoveBonus(int groundId) const { using namespace game; auto leader{gameFunctions().castUnitImplToStackLeader(impl)}; if (!leader) { return false; } auto hasBonus{leader->vftable->hasMovementBonus}; const auto& grounds{GroundCategories::get()}; switch (static_cast<GroundId>(groundId)) { case GroundId::Plain: return hasBonus(leader, grounds.plain); case GroundId::Forest: return hasBonus(leader, grounds.forest); case GroundId::Water: return hasBonus(leader, grounds.water); case GroundId::Mountain: return hasBonus(leader, grounds.mountain); } return false; } std::optional<DynUpgradeView> UnitImplView::getDynUpgrade1() const { return getDynUpgrade(1); } std::optional<DynUpgradeView> UnitImplView::getDynUpgrade2() const { return getDynUpgrade(2); } std::optional<AttackView> UnitImplView::getAttack() const { auto soldier{hooks::castUnitImplToSoldierWithLogging(impl)}; if (!soldier) { return std::nullopt; } auto attack{soldier->vftable->getAttackById(soldier)}; if (!attack) { return std::nullopt; } return AttackView{attack}; } std::optional<AttackView> UnitImplView::getAttack2() const { auto soldier{hooks::castUnitImplToSoldierWithLogging(impl)}; if (!soldier) { return std::nullopt; } auto secondaryAttack{soldier->vftable->getSecondAttackById(soldier)}; if (!secondaryAttack) { return std::nullopt; } return AttackView{secondaryAttack}; } std::optional<AttackView> UnitImplView::getAltAttack() const { auto altAttack = hooks::getAltAttack(impl, true); if (!altAttack) { return std::nullopt; } return AttackView{altAttack}; } int UnitImplView::getImmuneToAttackClass(int attackClassId) const { using namespace game; auto soldier{hooks::castUnitImplToSoldierWithLogging(impl)}; if (!soldier) { return emptyCategoryId; } const auto& attackClasses{AttackClassCategories::get()}; auto getImmune{soldier->vftable->getImmuneByAttackClass}; const LImmuneCat* immuneCategory = nullptr; switch (static_cast<AttackClassId>(attackClassId)) { default: return emptyCategoryId; case AttackClassId::Damage: immuneCategory = getImmune(soldier, attackClasses.damage); break; case AttackClassId::Drain: immuneCategory = getImmune(soldier, attackClasses.drain); break; case AttackClassId::Paralyze: immuneCategory = getImmune(soldier, attackClasses.paralyze); break; case AttackClassId::Heal: immuneCategory = getImmune(soldier, attackClasses.heal); break; case AttackClassId::Fear: immuneCategory = getImmune(soldier, attackClasses.fear); break; case AttackClassId::BoostDamage: immuneCategory = getImmune(soldier, attackClasses.boostDamage); break; case AttackClassId::Petrify: immuneCategory = getImmune(soldier, attackClasses.petrify); break; case AttackClassId::LowerDamage: immuneCategory = getImmune(soldier, attackClasses.lowerDamage); break; case AttackClassId::LowerInitiative: immuneCategory = getImmune(soldier, attackClasses.lowerInitiative); break; case AttackClassId::Poison: immuneCategory = getImmune(soldier, attackClasses.poison); break; case AttackClassId::Frostbite: immuneCategory = getImmune(soldier, attackClasses.frostbite); break; case AttackClassId::Revive: immuneCategory = getImmune(soldier, attackClasses.revive); break; case AttackClassId::DrainOverflow: immuneCategory = getImmune(soldier, attackClasses.drainOverflow); break; case AttackClassId::Cure: immuneCategory = getImmune(soldier, attackClasses.cure); break; case AttackClassId::Summon: immuneCategory = getImmune(soldier, attackClasses.summon); break; case AttackClassId::DrainLevel: immuneCategory = getImmune(soldier, attackClasses.drainLevel); break; case AttackClassId::GiveAttack: immuneCategory = getImmune(soldier, attackClasses.giveAttack); break; case AttackClassId::Doppelganger: immuneCategory = getImmune(soldier, attackClasses.doppelganger); break; case AttackClassId::TransformSelf: immuneCategory = getImmune(soldier, attackClasses.transformSelf); break; case AttackClassId::TransformOther: immuneCategory = getImmune(soldier, attackClasses.transformOther); break; case AttackClassId::Blister: immuneCategory = getImmune(soldier, attackClasses.blister); break; case AttackClassId::BestowWards: immuneCategory = getImmune(soldier, attackClasses.bestowWards); break; case AttackClassId::Shatter: immuneCategory = getImmune(soldier, attackClasses.shatter); break; } return immuneCategory ? static_cast<int>(immuneCategory->id) : emptyCategoryId; } int UnitImplView::getImmuneToAttackSource(int attackSourceId) const { using namespace game; auto soldier{hooks::castUnitImplToSoldierWithLogging(impl)}; if (!soldier) { return emptyCategoryId; } const auto& attackSources{AttackSourceCategories::get()}; auto getImmune{soldier->vftable->getImmuneByAttackSource}; const LImmuneCat* immuneCategory = nullptr; const AttackSourceId srcId{static_cast<AttackSourceId>(attackSourceId)}; switch (srcId) { default: { // Check custom attack sources first const auto& customSources = hooks::getCustomAttacks().sources; for (const auto& customSource : customSources) { if (customSource.source.id == srcId) { immuneCategory = getImmune(soldier, &customSource.source); break; } } if (immuneCategory == nullptr) { // Could not find source id even in custom sources return emptyCategoryId; } break; } case AttackSourceId::Weapon: immuneCategory = getImmune(soldier, attackSources.weapon); break; case AttackSourceId::Mind: immuneCategory = getImmune(soldier, attackSources.mind); break; case AttackSourceId::Life: immuneCategory = getImmune(soldier, attackSources.life); break; case AttackSourceId::Death: immuneCategory = getImmune(soldier, attackSources.death); break; case AttackSourceId::Fire: immuneCategory = getImmune(soldier, attackSources.fire); break; case AttackSourceId::Water: immuneCategory = getImmune(soldier, attackSources.water); break; case AttackSourceId::Earth: immuneCategory = getImmune(soldier, attackSources.earth); break; case AttackSourceId::Air: immuneCategory = getImmune(soldier, attackSources.air); break; } return immuneCategory ? static_cast<int>(immuneCategory->id) : emptyCategoryId; } std::optional<DynUpgradeView> UnitImplView::getDynUpgrade(int upgradeNumber) const { auto upgrade = hooks::getDynUpgrade(impl, upgradeNumber); if (!upgrade) { return std::nullopt; } return DynUpgradeView{upgrade}; } } // namespace bindings
18,107
C++
.cpp
491
31.857434
97
0.721946
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,159
dbffile.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/dbf/dbffile.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "dbffile.h" #include <cassert> namespace utils { bool DbfFile::open(const std::filesystem::path& file) { valid = false; std::ifstream stream(file, std::ios_base::binary); if (!stream.is_open()) { return false; } stream.seekg(0, stream.end); const auto fileSize = stream.tellg(); stream.seekg(0, stream.beg); if (fileSize < sizeof(DbfHeader)) { return false; } if (!readHeader(stream)) { return false; } const auto recordsDataLength = recordsTotal() * header.recordLength; if (!readColumns(stream)) { return false; } char endOfFields{}; stream.read(&endOfFields, 1); if (endOfFields != 0xd) { return false; } recordsData.resize(recordsDataLength); // https://en.wikipedia.org/wiki/.dbf#Database_records // Each record begins with a 1-byte "deletion" flag. The byte's value is a space (0x20), if the // record is active, or an asterisk (0x2A), if the record is deleted. char firstChar{}; stream.read(&firstChar, 1); if (firstChar != 0x20 && firstChar != 0x2A) { // Workaround for different file formats from Sdbf/SergDBF where there is an additional // EOF/NUL between header and data blocks stream.read(reinterpret_cast<char*>(&recordsData[0]), recordsDataLength); } else { recordsData[0] = firstChar; stream.read(reinterpret_cast<char*>(&recordsData[1]), recordsDataLength - 1); } valid = true; return true; } CodePage DbfFile::language() const { return header.language; } std::uint32_t DbfFile::columnsTotal() const { return (std::uint32_t)columns.size(); } std::uint32_t DbfFile::recordsTotal() const { return header.recordsTotal; } const DbfColumn* DbfFile::column(std::uint32_t index) const { return index < columns.size() ? &columns[index] : nullptr; } const DbfColumn* DbfFile::column(const std::string& name) const { const auto it = columnIndices.find(name); if (it == columnIndices.end()) { return nullptr; } return column(it->second); } bool DbfFile::record(DbfRecord& result, std::uint32_t index) const { if (index >= recordsTotal()) { return false; } const auto* bgn = &recordsData[index * header.recordLength]; bool deleted = *bgn == 0x2a; result = DbfRecord(this, DbfRecord::RecordData(bgn + 1, header.recordLength), deleted); return true; } bool DbfFile::readHeader(std::ifstream& stream) { DbfHeader tmpHeader; stream.read(reinterpret_cast<char*>(&tmpHeader), sizeof(tmpHeader)); if (tmpHeader.version.parts.version != 0x3) { return false; } if (tmpHeader.headerLength == 0 || tmpHeader.headerLength < sizeof(DbfHeader) + 1) { return false; } if (tmpHeader.recordLength == 0) { return false; } header = tmpHeader; return true; } bool DbfFile::readColumns(std::ifstream& stream) { const auto columnsTotal = (header.headerLength - sizeof(DbfHeader) - 1) / sizeof(DbfColumn); Columns tmpColumns(columnsTotal); ColumnIndexMap tmpIndices; std::uint32_t index{0}; std::uint32_t dataAddress{0}; for (auto& column : tmpColumns) { if (!readColumn(stream, column)) { return false; } column.dataAddress = dataAddress; dataAddress += column.length; tmpIndices[column.name] = index++; } columns.swap(tmpColumns); columnIndices.swap(tmpIndices); return true; } bool DbfFile::readColumn(std::ifstream& stream, DbfColumn& column) { stream.read(reinterpret_cast<char*>(&column), sizeof(DbfColumn)); return true; } } // namespace utils
4,519
C++
.cpp
138
28.253623
99
0.685603
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,160
dbfrecord.cpp
VladimirMakeev_D2ModdingToolset/mss32/src/dbf/dbfrecord.cpp
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "dbfrecord.h" #include "dbffile.h" #include <charconv> namespace utils { DbfRecord::DbfRecord(const DbfFile* dbf, RecordData recordData, bool deleted) : dbf(dbf) , data(recordData) , deleted(deleted) { } bool DbfRecord::value(std::string& result, std::uint32_t columnIndex) const { if (!dbf) { return false; } const auto column = dbf->column(columnIndex); if (!column) { return false; } return value(result, *column); } bool DbfRecord::value(std::string& result, const std::string& columnName) const { if (!dbf) { return false; } const auto column = dbf->column(columnName); if (!column) { return false; } return value(result, *column); } bool DbfRecord::value(std::string& result, const DbfColumn& column) const { if (data.empty()) { return false; } if (column.type != ColumnType::Character) { return false; } const char* bgn = reinterpret_cast<const char*>(&data[column.dataAddress]); result = std::string(bgn, column.length); return true; } bool DbfRecord::value(int& result, std::uint32_t columnIndex) const { if (!dbf) { return false; } const auto column = dbf->column(columnIndex); if (!column) { return false; } return value(result, *column); } bool DbfRecord::value(int& result, const std::string& columnName) const { if (!dbf) { return false; } const auto column = dbf->column(columnName); if (!column) { return false; } return value(result, *column); } bool DbfRecord::value(int& result, const DbfColumn& column) const { if (data.empty()) { return false; } if (column.type != ColumnType::Number) { return false; } const char* first = reinterpret_cast<const char*>(&data[column.dataAddress]); auto length = column.length; // skip spaces at the start of the field to std::from_chars work properly while (*first == ' ' && length) { first++; length--; } if (!length) { return false; } const char* last = first + length; int tmpResult{}; auto [p, ec] = std::from_chars(first, last, tmpResult); if (ec != std::errc()) { return false; } result = tmpResult; return true; } bool DbfRecord::value(bool& result, std::uint32_t columnIndex) const { if (!dbf) { return false; } const auto column = dbf->column(columnIndex); if (!column) { return false; } return value(result, *column); } bool DbfRecord::value(bool& result, const std::string& columnName) const { if (!dbf) { return false; } const auto column = dbf->column(columnName); if (!column) { return false; } return value(result, *column); } bool DbfRecord::value(bool& result, const DbfColumn& column) const { if (data.empty()) { return false; } if (column.type != ColumnType::Logical) { return false; } result = data[column.dataAddress] == 'T'; return true; } bool DbfRecord::isDeleted() const { return deleted; } } // namespace utils
4,007
C++
.cpp
148
22.614865
81
0.654027
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,163
ldo.h
VladimirMakeev_D2ModdingToolset/lua/ldo.h
/* ** $Id: ldo.h $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ #ifndef ldo_h #define ldo_h #include "lobject.h" #include "lstate.h" #include "lzio.h" /* ** Macro to check stack size and grow stack if needed. Parameters ** 'pre'/'pos' allow the macro to preserve a pointer into the ** stack across reallocations, doing the work only when needed. ** It also allows the running of one GC step when the stack is ** reallocated. ** 'condmovestack' is used in heavy tests to force a stack reallocation ** at every check. */ #define luaD_checkstackaux(L,n,pre,pos) \ if (L->stack_last - L->top <= (n)) \ { pre; luaD_growstack(L, n, 1); pos; } \ else { condmovestack(L,pre,pos); } /* In general, 'pre'/'pos' are empty (nothing to save) */ #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) #define savestack(L,p) ((char *)(p) - (char *)L->stack) #define restorestack(L,n) ((StkId)((char *)L->stack + (n))) /* macro to check stack size, preserving 'p' */ #define checkstackGCp(L,n,p) \ luaD_checkstackaux(L, n, \ ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \ luaC_checkGC(L), /* stack grow uses memory */ \ p = restorestack(L, t__)) /* 'pos' part: restore 'p' */ /* macro to check stack size and GC */ #define checkstackGC(L,fsize) \ luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0) /* type of protected functions, to be ran by 'runprotected' */ typedef void (*Pfunc) (lua_State *L, void *ud); LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, const char *mode); LUAI_FUNC void luaD_hook (lua_State *L, int event, int line, int fTransfer, int nTransfer); LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci); LUAI_FUNC void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int n); LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); LUAI_FUNC void luaD_tryfuncTM (lua_State *L, StkId func); LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, ptrdiff_t oldtop, ptrdiff_t ef); LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres); LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror); LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror); LUAI_FUNC void luaD_shrinkstack (lua_State *L); LUAI_FUNC void luaD_inctop (lua_State *L); LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); #endif
2,760
C++
.h
58
43.551724
80
0.6694
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
1,542,164
lfunc.h
VladimirMakeev_D2ModdingToolset/lua/lfunc.h
/* ** $Id: lfunc.h $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ #ifndef lfunc_h #define lfunc_h #include "lobject.h" #define sizeCclosure(n) (cast_int(offsetof(CClosure, upvalue)) + \ cast_int(sizeof(TValue)) * (n)) #define sizeLclosure(n) (cast_int(offsetof(LClosure, upvals)) + \ cast_int(sizeof(TValue *)) * (n)) /* test whether thread is in 'twups' list */ #define isintwups(L) (L->twups != L) /* ** maximum number of upvalues in a closure (both C and Lua). (Value ** must fit in a VM register.) */ #define MAXUPVAL 255 #define upisopen(up) ((up)->v != &(up)->u.value) #define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v)) /* ** maximum number of misses before giving up the cache of closures ** in prototypes */ #define MAXMISS 10 /* ** Special "status" for 'luaF_close' */ /* close upvalues without running their closing methods */ #define NOCLOSINGMETH (-1) /* close upvalues running all closing methods in protected mode */ #define CLOSEPROTECT (-2) LUAI_FUNC Proto *luaF_newproto (lua_State *L); LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nupvals); LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nupvals); LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level); LUAI_FUNC int luaF_close (lua_State *L, StkId level, int status); LUAI_FUNC void luaF_unlinkupval (UpVal *uv); LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, int pc); #endif
1,763
C++
.h
45
35.622222
77
0.693625
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
1,542,166
llimits.h
VladimirMakeev_D2ModdingToolset/lua/llimits.h
/* ** $Id: llimits.h $ ** Limits, basic types, and some other 'installation-dependent' definitions ** See Copyright Notice in lua.h */ #ifndef llimits_h #define llimits_h #include <limits.h> #include <stddef.h> #include "lua.h" /* ** 'lu_mem' and 'l_mem' are unsigned/signed integers big enough to count ** the total memory used by Lua (in bytes). Usually, 'size_t' and ** 'ptrdiff_t' should work, but we use 'long' for 16-bit machines. */ #if defined(LUAI_MEM) /* { external definitions? */ typedef LUAI_UMEM lu_mem; typedef LUAI_MEM l_mem; #elif LUAI_IS32INT /* }{ */ typedef size_t lu_mem; typedef ptrdiff_t l_mem; #else /* 16-bit ints */ /* }{ */ typedef unsigned long lu_mem; typedef long l_mem; #endif /* } */ /* chars used as small naturals (so that 'char' is reserved for characters) */ typedef unsigned char lu_byte; typedef signed char ls_byte; /* maximum value for size_t */ #define MAX_SIZET ((size_t)(~(size_t)0)) /* maximum size visible for Lua (must be representable in a lua_Integer) */ #define MAX_SIZE (sizeof(size_t) < sizeof(lua_Integer) ? MAX_SIZET \ : (size_t)(LUA_MAXINTEGER)) #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)) #define MAX_LMEM ((l_mem)(MAX_LUMEM >> 1)) #define MAX_INT INT_MAX /* maximum value of an int */ /* ** floor of the log2 of the maximum signed value for integral type 't'. ** (That is, maximum 'n' such that '2^n' fits in the given signed type.) */ #define log2maxs(t) (sizeof(t) * 8 - 2) /* ** test whether an unsigned value is a power of 2 (or zero) */ #define ispow2(x) (((x) & ((x) - 1)) == 0) /* number of chars of a literal string without the ending \0 */ #define LL(x) (sizeof(x)/sizeof(char) - 1) /* ** conversion of pointer to unsigned integer: ** this is for hashing only; there is no problem if the integer ** cannot hold the whole pointer value */ #define point2uint(p) ((unsigned int)((size_t)(p) & UINT_MAX)) /* types of 'usual argument conversions' for lua_Number and lua_Integer */ typedef LUAI_UACNUMBER l_uacNumber; typedef LUAI_UACINT l_uacInt; /* ** Internal assertions for in-house debugging */ #if defined LUAI_ASSERT #undef NDEBUG #include <assert.h> #define lua_assert(c) assert(c) #endif #if defined(lua_assert) #define check_exp(c,e) (lua_assert(c), (e)) /* to avoid problems with conditions too long */ #define lua_longassert(c) ((c) ? (void)0 : lua_assert(0)) #else #define lua_assert(c) ((void)0) #define check_exp(c,e) (e) #define lua_longassert(c) ((void)0) #endif /* ** assertion for checking API calls */ #if !defined(luai_apicheck) #define luai_apicheck(l,e) ((void)l, lua_assert(e)) #endif #define api_check(l,e,msg) luai_apicheck(l,(e) && msg) /* macro to avoid warnings about unused variables */ #if !defined(UNUSED) #define UNUSED(x) ((void)(x)) #endif /* type casts (a macro highlights casts in the code) */ #define cast(t, exp) ((t)(exp)) #define cast_void(i) cast(void, (i)) #define cast_voidp(i) cast(void *, (i)) #define cast_num(i) cast(lua_Number, (i)) #define cast_int(i) cast(int, (i)) #define cast_uint(i) cast(unsigned int, (i)) #define cast_byte(i) cast(lu_byte, (i)) #define cast_uchar(i) cast(unsigned char, (i)) #define cast_char(i) cast(char, (i)) #define cast_charp(i) cast(char *, (i)) #define cast_sizet(i) cast(size_t, (i)) /* cast a signed lua_Integer to lua_Unsigned */ #if !defined(l_castS2U) #define l_castS2U(i) ((lua_Unsigned)(i)) #endif /* ** cast a lua_Unsigned to a signed lua_Integer; this cast is ** not strict ISO C, but two-complement architectures should ** work fine. */ #if !defined(l_castU2S) #define l_castU2S(i) ((lua_Integer)(i)) #endif /* ** macros to improve jump prediction (used mainly for error handling) */ #if !defined(likely) #if defined(__GNUC__) #define likely(x) (__builtin_expect(((x) != 0), 1)) #define unlikely(x) (__builtin_expect(((x) != 0), 0)) #else #define likely(x) (x) #define unlikely(x) (x) #endif #endif /* ** non-return type */ #if !defined(l_noret) #if defined(__GNUC__) #define l_noret void __attribute__((noreturn)) #elif defined(_MSC_VER) && _MSC_VER >= 1200 #define l_noret void __declspec(noreturn) #else #define l_noret void #endif #endif /* ** type for virtual-machine instructions; ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) */ #if LUAI_IS32INT typedef unsigned int l_uint32; #else typedef unsigned long l_uint32; #endif typedef l_uint32 Instruction; /* ** Maximum length for short strings, that is, strings that are ** internalized. (Cannot be smaller than reserved words or tags for ** metamethods, as these strings must be internalized; ** #("function") = 8, #("__newindex") = 10.) */ #if !defined(LUAI_MAXSHORTLEN) #define LUAI_MAXSHORTLEN 40 #endif /* ** Initial size for the string table (must be power of 2). ** The Lua core alone registers ~50 strings (reserved words + ** metaevent keys + a few others). Libraries would typically add ** a few dozens more. */ #if !defined(MINSTRTABSIZE) #define MINSTRTABSIZE 128 #endif /* ** Size of cache for strings in the API. 'N' is the number of ** sets (better be a prime) and "M" is the size of each set (M == 1 ** makes a direct cache.) */ #if !defined(STRCACHE_N) #define STRCACHE_N 53 #define STRCACHE_M 2 #endif /* minimum size for string buffer */ #if !defined(LUA_MINBUFFER) #define LUA_MINBUFFER 32 #endif /* ** macros that are executed whenever program enters the Lua core ** ('lua_lock') and leaves the core ('lua_unlock') */ #if !defined(lua_lock) #define lua_lock(L) ((void) 0) #define lua_unlock(L) ((void) 0) #endif /* ** macro executed during Lua functions at points where the ** function can yield. */ #if !defined(luai_threadyield) #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} #endif /* ** these macros allow user-specific actions when a thread is ** created/deleted/resumed/yielded. */ #if !defined(luai_userstateopen) #define luai_userstateopen(L) ((void)L) #endif #if !defined(luai_userstateclose) #define luai_userstateclose(L) ((void)L) #endif #if !defined(luai_userstatethread) #define luai_userstatethread(L,L1) ((void)L) #endif #if !defined(luai_userstatefree) #define luai_userstatefree(L,L1) ((void)L) #endif #if !defined(luai_userstateresume) #define luai_userstateresume(L,n) ((void)L) #endif #if !defined(luai_userstateyield) #define luai_userstateyield(L,n) ((void)L) #endif /* ** The luai_num* macros define the primitive operations over numbers. */ /* floor division (defined as 'floor(a/b)') */ #if !defined(luai_numidiv) #define luai_numidiv(L,a,b) ((void)L, l_floor(luai_numdiv(L,a,b))) #endif /* float division */ #if !defined(luai_numdiv) #define luai_numdiv(L,a,b) ((a)/(b)) #endif /* ** modulo: defined as 'a - floor(a/b)*b'; the direct computation ** using this definition has several problems with rounding errors, ** so it is better to use 'fmod'. 'fmod' gives the result of ** 'a - trunc(a/b)*b', and therefore must be corrected when ** 'trunc(a/b) ~= floor(a/b)'. That happens when the division has a ** non-integer negative result: non-integer result is equivalent to ** a non-zero remainder 'm'; negative result is equivalent to 'a' and ** 'b' with different signs, or 'm' and 'b' with different signs ** (as the result 'm' of 'fmod' has the same sign of 'a'). */ #if !defined(luai_nummod) #define luai_nummod(L,a,b,m) \ { (void)L; (m) = l_mathop(fmod)(a,b); \ if (((m) > 0) ? (b) < 0 : ((m) < 0 && (b) > 0)) (m) += (b); } #endif /* exponentiation */ #if !defined(luai_numpow) #define luai_numpow(L,a,b) ((void)L, l_mathop(pow)(a,b)) #endif /* the others are quite standard operations */ #if !defined(luai_numadd) #define luai_numadd(L,a,b) ((a)+(b)) #define luai_numsub(L,a,b) ((a)-(b)) #define luai_nummul(L,a,b) ((a)*(b)) #define luai_numunm(L,a) (-(a)) #define luai_numeq(a,b) ((a)==(b)) #define luai_numlt(a,b) ((a)<(b)) #define luai_numle(a,b) ((a)<=(b)) #define luai_numgt(a,b) ((a)>(b)) #define luai_numge(a,b) ((a)>=(b)) #define luai_numisnan(a) (!luai_numeq((a), (a))) #endif /* ** macro to control inclusion of some hard tests on stack reallocation */ #if !defined(HARDSTACKTESTS) #define condmovestack(L,pre,pos) ((void)0) #else /* realloc stack keeping its size */ #define condmovestack(L,pre,pos) \ { int sz_ = (L)->stacksize; pre; luaD_reallocstack((L), sz_, 0); pos; } #endif #if !defined(HARDMEMTESTS) #define condchangemem(L,pre,pos) ((void)0) #else #define condchangemem(L,pre,pos) \ { if (G(L)->gcrunning) { pre; luaC_fullgc(L, 0); pos; } } #endif #endif
8,604
C++
.h
271
30.302583
78
0.691524
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
1,542,169
lparser.h
VladimirMakeev_D2ModdingToolset/lua/lparser.h
/* ** $Id: lparser.h $ ** Lua Parser ** See Copyright Notice in lua.h */ #ifndef lparser_h #define lparser_h #include "llimits.h" #include "lobject.h" #include "lzio.h" /* ** Expression and variable descriptor. ** Code generation for variables and expressions can be delayed to allow ** optimizations; An 'expdesc' structure describes a potentially-delayed ** variable/expression. It has a description of its "main" value plus a ** list of conditional jumps that can also produce its value (generated ** by short-circuit operators 'and'/'or'). */ /* kinds of variables/expressions */ typedef enum { VVOID, /* when 'expdesc' describes the last expression a list, this kind means an empty list (so, no expression) */ VNIL, /* constant nil */ VTRUE, /* constant true */ VFALSE, /* constant false */ VK, /* constant in 'k'; info = index of constant in 'k' */ VKFLT, /* floating constant; nval = numerical float value */ VKINT, /* integer constant; ival = numerical integer value */ VKSTR, /* string constant; strval = TString address; (string is fixed by the lexer) */ VNONRELOC, /* expression has its value in a fixed register; info = result register */ VLOCAL, /* local variable; var.sidx = stack index (local register); var.vidx = relative index in 'actvar.arr' */ VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ VCONST, /* compile-time constant; info = absolute index in 'actvar.arr' */ VINDEXED, /* indexed variable; ind.t = table register; ind.idx = key's R index */ VINDEXUP, /* indexed upvalue; ind.t = table upvalue; ind.idx = key's K index */ VINDEXI, /* indexed variable with constant integer; ind.t = table register; ind.idx = key's value */ VINDEXSTR, /* indexed variable with literal string; ind.t = table register; ind.idx = key's K index */ VJMP, /* expression is a test/comparison; info = pc of corresponding jump instruction */ VRELOC, /* expression can put result in any register; info = instruction pc */ VCALL, /* expression is a function call; info = instruction pc */ VVARARG /* vararg expression; info = instruction pc */ } expkind; #define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXSTR) #define vkisindexed(k) (VINDEXED <= (k) && (k) <= VINDEXSTR) typedef struct expdesc { expkind k; union { lua_Integer ival; /* for VKINT */ lua_Number nval; /* for VKFLT */ TString *strval; /* for VKSTR */ int info; /* for generic use */ struct { /* for indexed variables */ short idx; /* index (R or "long" K) */ lu_byte t; /* table (register or upvalue) */ } ind; struct { /* for local variables */ lu_byte sidx; /* index in the stack */ unsigned short vidx; /* compiler index (in 'actvar.arr') */ } var; } u; int t; /* patch list of 'exit when true' */ int f; /* patch list of 'exit when false' */ } expdesc; /* kinds of variables */ #define VDKREG 0 /* regular */ #define RDKCONST 1 /* constant */ #define RDKTOCLOSE 2 /* to-be-closed */ #define RDKCTC 3 /* compile-time constant */ /* description of an active local variable */ typedef union Vardesc { struct { TValuefields; /* constant value (if it is a compile-time constant) */ lu_byte kind; lu_byte sidx; /* index of the variable in the stack */ short pidx; /* index of the variable in the Proto's 'locvars' array */ TString *name; /* variable name */ } vd; TValue k; /* constant value (if any) */ } Vardesc; /* description of pending goto statements and label statements */ typedef struct Labeldesc { TString *name; /* label identifier */ int pc; /* position in code */ int line; /* line where it appeared */ lu_byte nactvar; /* number of active variables in that position */ lu_byte close; /* goto that escapes upvalues */ } Labeldesc; /* list of labels or gotos */ typedef struct Labellist { Labeldesc *arr; /* array */ int n; /* number of entries in use */ int size; /* array size */ } Labellist; /* dynamic structures used by the parser */ typedef struct Dyndata { struct { /* list of all active local variables */ Vardesc *arr; int n; int size; } actvar; Labellist gt; /* list of pending gotos */ Labellist label; /* list of active labels */ } Dyndata; /* control of blocks */ struct BlockCnt; /* defined in lparser.c */ /* state needed to generate code for a given function */ typedef struct FuncState { Proto *f; /* current function header */ struct FuncState *prev; /* enclosing function */ struct LexState *ls; /* lexical state */ struct BlockCnt *bl; /* chain of current blocks */ int pc; /* next position to code (equivalent to 'ncode') */ int lasttarget; /* 'label' of last 'jump label' */ int previousline; /* last line that was saved in 'lineinfo' */ int nk; /* number of elements in 'k' */ int np; /* number of elements in 'p' */ int nabslineinfo; /* number of elements in 'abslineinfo' */ int firstlocal; /* index of first local var (in Dyndata array) */ int firstlabel; /* index of first label (in 'dyd->label->arr') */ short ndebugvars; /* number of elements in 'f->locvars' */ lu_byte nactvar; /* number of active local variables */ lu_byte nups; /* number of upvalues */ lu_byte freereg; /* first free register */ lu_byte iwthabs; /* instructions issued since last absolute line info */ lu_byte needclose; /* function needs to close upvalues when returning */ } FuncState; LUAI_FUNC int luaY_nvarstack (FuncState *fs); LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, Dyndata *dyd, const char *name, int firstchar); #endif
5,910
C++
.h
143
37.006993
80
0.650174
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
1,542,171
lobject.h
VladimirMakeev_D2ModdingToolset/lua/lobject.h
/* ** $Id: lobject.h $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ #ifndef lobject_h #define lobject_h #include <stdarg.h> #include "llimits.h" #include "lua.h" /* ** Extra types for collectable non-values */ #define LUA_TUPVAL LUA_NUMTYPES /* upvalues */ #define LUA_TPROTO (LUA_NUMTYPES+1) /* function prototypes */ /* ** number of all possible types (including LUA_TNONE) */ #define LUA_TOTALTYPES (LUA_TPROTO + 2) /* ** tags for Tagged Values have the following use of bits: ** bits 0-3: actual tag (a LUA_T* constant) ** bits 4-5: variant bits ** bit 6: whether value is collectable */ /* add variant bits to a type */ #define makevariant(t,v) ((t) | ((v) << 4)) /* ** Union of all Lua values */ typedef union Value { struct GCObject *gc; /* collectable objects */ void *p; /* light userdata */ lua_CFunction f; /* light C functions */ lua_Integer i; /* integer numbers */ lua_Number n; /* float numbers */ } Value; /* ** Tagged Values. This is the basic representation of values in Lua: ** an actual value plus a tag with its type. */ #define TValuefields Value value_; lu_byte tt_ typedef struct TValue { TValuefields; } TValue; #define val_(o) ((o)->value_) #define valraw(o) (&val_(o)) /* raw type tag of a TValue */ #define rawtt(o) ((o)->tt_) /* tag with no variants (bits 0-3) */ #define novariant(t) ((t) & 0x0F) /* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */ #define withvariant(t) ((t) & 0x3F) #define ttypetag(o) withvariant(rawtt(o)) /* type of a TValue */ #define ttype(o) (novariant(rawtt(o))) /* Macros to test type */ #define checktag(o,t) (rawtt(o) == (t)) #define checktype(o,t) (ttype(o) == (t)) /* Macros for internal tests */ /* collectable object has the same tag as the original value */ #define righttt(obj) (ttypetag(obj) == gcvalue(obj)->tt) /* ** Any value being manipulated by the program either is non ** collectable, or the collectable object has the right tag ** and it is not dead. The option 'L == NULL' allows other ** macros using this one to be used where L is not available. */ #define checkliveness(L,obj) \ ((void)L, lua_longassert(!iscollectable(obj) || \ (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj)))))) /* Macros to set values */ /* set a value's tag */ #define settt_(o,t) ((o)->tt_=(t)) /* main macro to copy values (from 'obj1' to 'obj2') */ #define setobj(L,obj1,obj2) \ { TValue *io1=(obj1); const TValue *io2=(obj2); \ io1->value_ = io2->value_; settt_(io1, io2->tt_); \ checkliveness(L,io1); lua_assert(!isnonstrictnil(io1)); } /* ** Different types of assignments, according to source and destination. ** (They are mostly equal now, but may be different in the future.) */ /* from stack to stack */ #define setobjs2s(L,o1,o2) setobj(L,s2v(o1),s2v(o2)) /* to stack (not from same stack) */ #define setobj2s(L,o1,o2) setobj(L,s2v(o1),o2) /* from table to same table */ #define setobjt2t setobj /* to new object */ #define setobj2n setobj /* to table */ #define setobj2t setobj /* ** Entries in the Lua stack */ typedef union StackValue { TValue val; } StackValue; /* index to stack elements */ typedef StackValue *StkId; /* convert a 'StackValue' to a 'TValue' */ #define s2v(o) (&(o)->val) /* ** {================================================================== ** Nil ** =================================================================== */ /* Standard nil */ #define LUA_VNIL makevariant(LUA_TNIL, 0) /* Empty slot (which might be different from a slot containing nil) */ #define LUA_VEMPTY makevariant(LUA_TNIL, 1) /* Value returned for a key not found in a table (absent key) */ #define LUA_VABSTKEY makevariant(LUA_TNIL, 2) /* macro to test for (any kind of) nil */ #define ttisnil(v) checktype((v), LUA_TNIL) /* macro to test for a standard nil */ #define ttisstrictnil(o) checktag((o), LUA_VNIL) #define setnilvalue(obj) settt_(obj, LUA_VNIL) #define isabstkey(v) checktag((v), LUA_VABSTKEY) /* ** macro to detect non-standard nils (used only in assertions) */ #define isnonstrictnil(v) (ttisnil(v) && !ttisstrictnil(v)) /* ** By default, entries with any kind of nil are considered empty. ** (In any definition, values associated with absent keys must also ** be accepted as empty.) */ #define isempty(v) ttisnil(v) /* macro defining a value corresponding to an absent key */ #define ABSTKEYCONSTANT {NULL}, LUA_VABSTKEY /* mark an entry as empty */ #define setempty(v) settt_(v, LUA_VEMPTY) /* }================================================================== */ /* ** {================================================================== ** Booleans ** =================================================================== */ #define LUA_VFALSE makevariant(LUA_TBOOLEAN, 0) #define LUA_VTRUE makevariant(LUA_TBOOLEAN, 1) #define ttisboolean(o) checktype((o), LUA_TBOOLEAN) #define ttisfalse(o) checktag((o), LUA_VFALSE) #define ttistrue(o) checktag((o), LUA_VTRUE) #define l_isfalse(o) (ttisfalse(o) || ttisnil(o)) #define setbfvalue(obj) settt_(obj, LUA_VFALSE) #define setbtvalue(obj) settt_(obj, LUA_VTRUE) /* }================================================================== */ /* ** {================================================================== ** Threads ** =================================================================== */ #define LUA_VTHREAD makevariant(LUA_TTHREAD, 0) #define ttisthread(o) checktag((o), ctb(LUA_VTHREAD)) #define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc)) #define setthvalue(L,obj,x) \ { TValue *io = (obj); lua_State *x_ = (x); \ val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTHREAD)); \ checkliveness(L,io); } #define setthvalue2s(L,o,t) setthvalue(L,s2v(o),t) /* }================================================================== */ /* ** {================================================================== ** Collectable Objects ** =================================================================== */ /* ** Common Header for all collectable objects (in macro form, to be ** included in other objects) */ #define CommonHeader struct GCObject *next; lu_byte tt; lu_byte marked /* Common type for all collectable objects */ typedef struct GCObject { CommonHeader; } GCObject; /* Bit mark for collectable types */ #define BIT_ISCOLLECTABLE (1 << 6) #define iscollectable(o) (rawtt(o) & BIT_ISCOLLECTABLE) /* mark a tag as collectable */ #define ctb(t) ((t) | BIT_ISCOLLECTABLE) #define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) #define gcvalueraw(v) ((v).gc) #define setgcovalue(L,obj,x) \ { TValue *io = (obj); GCObject *i_g=(x); \ val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); } /* }================================================================== */ /* ** {================================================================== ** Numbers ** =================================================================== */ /* Variant tags for numbers */ #define LUA_VNUMINT makevariant(LUA_TNUMBER, 0) /* integer numbers */ #define LUA_VNUMFLT makevariant(LUA_TNUMBER, 1) /* float numbers */ #define ttisnumber(o) checktype((o), LUA_TNUMBER) #define ttisfloat(o) checktag((o), LUA_VNUMFLT) #define ttisinteger(o) checktag((o), LUA_VNUMINT) #define nvalue(o) check_exp(ttisnumber(o), \ (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o))) #define fltvalue(o) check_exp(ttisfloat(o), val_(o).n) #define ivalue(o) check_exp(ttisinteger(o), val_(o).i) #define fltvalueraw(v) ((v).n) #define ivalueraw(v) ((v).i) #define setfltvalue(obj,x) \ { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_VNUMFLT); } #define chgfltvalue(obj,x) \ { TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); } #define setivalue(obj,x) \ { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_VNUMINT); } #define chgivalue(obj,x) \ { TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); } /* }================================================================== */ /* ** {================================================================== ** Strings ** =================================================================== */ /* Variant tags for strings */ #define LUA_VSHRSTR makevariant(LUA_TSTRING, 0) /* short strings */ #define LUA_VLNGSTR makevariant(LUA_TSTRING, 1) /* long strings */ #define ttisstring(o) checktype((o), LUA_TSTRING) #define ttisshrstring(o) checktag((o), ctb(LUA_VSHRSTR)) #define ttislngstring(o) checktag((o), ctb(LUA_VLNGSTR)) #define tsvalueraw(v) (gco2ts((v).gc)) #define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc)) #define setsvalue(L,obj,x) \ { TValue *io = (obj); TString *x_ = (x); \ val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \ checkliveness(L,io); } /* set a string to the stack */ #define setsvalue2s(L,o,s) setsvalue(L,s2v(o),s) /* set a string to a new object */ #define setsvalue2n setsvalue /* ** Header for a string value. */ typedef struct TString { CommonHeader; lu_byte extra; /* reserved words for short strings; "has hash" for longs */ lu_byte shrlen; /* length for short strings */ unsigned int hash; union { size_t lnglen; /* length for long strings */ struct TString *hnext; /* linked list for hash table */ } u; char contents[1]; } TString; /* ** Get the actual string (array of bytes) from a 'TString'. */ #define getstr(ts) ((ts)->contents) /* get the actual string (array of bytes) from a Lua value */ #define svalue(o) getstr(tsvalue(o)) /* get string length from 'TString *s' */ #define tsslen(s) ((s)->tt == LUA_VSHRSTR ? (s)->shrlen : (s)->u.lnglen) /* get string length from 'TValue *o' */ #define vslen(o) tsslen(tsvalue(o)) /* }================================================================== */ /* ** {================================================================== ** Userdata ** =================================================================== */ /* ** Light userdata should be a variant of userdata, but for compatibility ** reasons they are also different types. */ #define LUA_VLIGHTUSERDATA makevariant(LUA_TLIGHTUSERDATA, 0) #define LUA_VUSERDATA makevariant(LUA_TUSERDATA, 0) #define ttislightuserdata(o) checktag((o), LUA_VLIGHTUSERDATA) #define ttisfulluserdata(o) checktag((o), ctb(LUA_VUSERDATA)) #define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) #define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc)) #define pvalueraw(v) ((v).p) #define setpvalue(obj,x) \ { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_VLIGHTUSERDATA); } #define setuvalue(L,obj,x) \ { TValue *io = (obj); Udata *x_ = (x); \ val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VUSERDATA)); \ checkliveness(L,io); } /* Ensures that addresses after this type are always fully aligned. */ typedef union UValue { TValue uv; LUAI_MAXALIGN; /* ensures maximum alignment for udata bytes */ } UValue; /* ** Header for userdata with user values; ** memory area follows the end of this structure. */ typedef struct Udata { CommonHeader; unsigned short nuvalue; /* number of user values */ size_t len; /* number of bytes */ struct Table *metatable; GCObject *gclist; UValue uv[1]; /* user values */ } Udata; /* ** Header for userdata with no user values. These userdata do not need ** to be gray during GC, and therefore do not need a 'gclist' field. ** To simplify, the code always use 'Udata' for both kinds of userdata, ** making sure it never accesses 'gclist' on userdata with no user values. ** This structure here is used only to compute the correct size for ** this representation. (The 'bindata' field in its end ensures correct ** alignment for binary data following this header.) */ typedef struct Udata0 { CommonHeader; unsigned short nuvalue; /* number of user values */ size_t len; /* number of bytes */ struct Table *metatable; union {LUAI_MAXALIGN;} bindata; } Udata0; /* compute the offset of the memory area of a userdata */ #define udatamemoffset(nuv) \ ((nuv) == 0 ? offsetof(Udata0, bindata) \ : offsetof(Udata, uv) + (sizeof(UValue) * (nuv))) /* get the address of the memory block inside 'Udata' */ #define getudatamem(u) (cast_charp(u) + udatamemoffset((u)->nuvalue)) /* compute the size of a userdata */ #define sizeudata(nuv,nb) (udatamemoffset(nuv) + (nb)) /* }================================================================== */ /* ** {================================================================== ** Prototypes ** =================================================================== */ #define LUA_VPROTO makevariant(LUA_TPROTO, 0) /* ** Description of an upvalue for function prototypes */ typedef struct Upvaldesc { TString *name; /* upvalue name (for debug information) */ lu_byte instack; /* whether it is in stack (register) */ lu_byte idx; /* index of upvalue (in stack or in outer function's list) */ lu_byte kind; /* kind of corresponding variable */ } Upvaldesc; /* ** Description of a local variable for function prototypes ** (used for debug information) */ typedef struct LocVar { TString *varname; int startpc; /* first point where variable is active */ int endpc; /* first point where variable is dead */ } LocVar; /* ** Associates the absolute line source for a given instruction ('pc'). ** The array 'lineinfo' gives, for each instruction, the difference in ** lines from the previous instruction. When that difference does not ** fit into a byte, Lua saves the absolute line for that instruction. ** (Lua also saves the absolute line periodically, to speed up the ** computation of a line number: we can use binary search in the ** absolute-line array, but we must traverse the 'lineinfo' array ** linearly to compute a line.) */ typedef struct AbsLineInfo { int pc; int line; } AbsLineInfo; /* ** Function Prototypes */ typedef struct Proto { CommonHeader; lu_byte numparams; /* number of fixed (named) parameters */ lu_byte is_vararg; lu_byte maxstacksize; /* number of registers needed by this function */ int sizeupvalues; /* size of 'upvalues' */ int sizek; /* size of 'k' */ int sizecode; int sizelineinfo; int sizep; /* size of 'p' */ int sizelocvars; int sizeabslineinfo; /* size of 'abslineinfo' */ int linedefined; /* debug information */ int lastlinedefined; /* debug information */ TValue *k; /* constants used by the function */ Instruction *code; /* opcodes */ struct Proto **p; /* functions defined inside the function */ Upvaldesc *upvalues; /* upvalue information */ ls_byte *lineinfo; /* information about source lines (debug information) */ AbsLineInfo *abslineinfo; /* idem */ LocVar *locvars; /* information about local variables (debug information) */ TString *source; /* used for debug information */ GCObject *gclist; } Proto; /* }================================================================== */ /* ** {================================================================== ** Closures ** =================================================================== */ #define LUA_VUPVAL makevariant(LUA_TUPVAL, 0) /* Variant tags for functions */ #define LUA_VLCL makevariant(LUA_TFUNCTION, 0) /* Lua closure */ #define LUA_VLCF makevariant(LUA_TFUNCTION, 1) /* light C function */ #define LUA_VCCL makevariant(LUA_TFUNCTION, 2) /* C closure */ #define ttisfunction(o) checktype(o, LUA_TFUNCTION) #define ttisclosure(o) ((rawtt(o) & 0x1F) == LUA_VLCL) #define ttisLclosure(o) checktag((o), ctb(LUA_VLCL)) #define ttislcf(o) checktag((o), LUA_VLCF) #define ttisCclosure(o) checktag((o), ctb(LUA_VCCL)) #define isLfunction(o) ttisLclosure(o) #define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc)) #define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc)) #define fvalue(o) check_exp(ttislcf(o), val_(o).f) #define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc)) #define fvalueraw(v) ((v).f) #define setclLvalue(L,obj,x) \ { TValue *io = (obj); LClosure *x_ = (x); \ val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VLCL)); \ checkliveness(L,io); } #define setclLvalue2s(L,o,cl) setclLvalue(L,s2v(o),cl) #define setfvalue(obj,x) \ { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_VLCF); } #define setclCvalue(L,obj,x) \ { TValue *io = (obj); CClosure *x_ = (x); \ val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VCCL)); \ checkliveness(L,io); } /* ** Upvalues for Lua closures */ typedef struct UpVal { CommonHeader; lu_byte tbc; /* true if it represents a to-be-closed variable */ TValue *v; /* points to stack or to its own value */ union { struct { /* (when open) */ struct UpVal *next; /* linked list */ struct UpVal **previous; } open; TValue value; /* the value (when closed) */ } u; } UpVal; #define ClosureHeader \ CommonHeader; lu_byte nupvalues; GCObject *gclist typedef struct CClosure { ClosureHeader; lua_CFunction f; TValue upvalue[1]; /* list of upvalues */ } CClosure; typedef struct LClosure { ClosureHeader; struct Proto *p; UpVal *upvals[1]; /* list of upvalues */ } LClosure; typedef union Closure { CClosure c; LClosure l; } Closure; #define getproto(o) (clLvalue(o)->p) /* }================================================================== */ /* ** {================================================================== ** Tables ** =================================================================== */ #define LUA_VTABLE makevariant(LUA_TTABLE, 0) #define ttistable(o) checktag((o), ctb(LUA_VTABLE)) #define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc)) #define sethvalue(L,obj,x) \ { TValue *io = (obj); Table *x_ = (x); \ val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTABLE)); \ checkliveness(L,io); } #define sethvalue2s(L,o,h) sethvalue(L,s2v(o),h) /* ** Nodes for Hash tables: A pack of two TValue's (key-value pairs) ** plus a 'next' field to link colliding entries. The distribution ** of the key's fields ('key_tt' and 'key_val') not forming a proper ** 'TValue' allows for a smaller size for 'Node' both in 4-byte ** and 8-byte alignments. */ typedef union Node { struct NodeKey { TValuefields; /* fields for value */ lu_byte key_tt; /* key type */ int next; /* for chaining */ Value key_val; /* key value */ } u; TValue i_val; /* direct access to node's value as a proper 'TValue' */ } Node; /* copy a value into a key */ #define setnodekey(L,node,obj) \ { Node *n_=(node); const TValue *io_=(obj); \ n_->u.key_val = io_->value_; n_->u.key_tt = io_->tt_; \ checkliveness(L,io_); } /* copy a value from a key */ #define getnodekey(L,obj,node) \ { TValue *io_=(obj); const Node *n_=(node); \ io_->value_ = n_->u.key_val; io_->tt_ = n_->u.key_tt; \ checkliveness(L,io_); } /* ** About 'alimit': if 'isrealasize(t)' is true, then 'alimit' is the ** real size of 'array'. Otherwise, the real size of 'array' is the ** smallest power of two not smaller than 'alimit' (or zero iff 'alimit' ** is zero); 'alimit' is then used as a hint for #t. */ #define BITRAS (1 << 7) #define isrealasize(t) (!((t)->flags & BITRAS)) #define setrealasize(t) ((t)->flags &= cast_byte(~BITRAS)) #define setnorealasize(t) ((t)->flags |= BITRAS) typedef struct Table { CommonHeader; lu_byte flags; /* 1<<p means tagmethod(p) is not present */ lu_byte lsizenode; /* log2 of size of 'node' array */ unsigned int alimit; /* "limit" of 'array' array */ TValue *array; /* array part */ Node *node; Node *lastfree; /* any free position is before this position */ struct Table *metatable; GCObject *gclist; } Table; /* ** Macros to manipulate keys inserted in nodes */ #define keytt(node) ((node)->u.key_tt) #define keyval(node) ((node)->u.key_val) #define keyisnil(node) (keytt(node) == LUA_TNIL) #define keyisinteger(node) (keytt(node) == LUA_VNUMINT) #define keyival(node) (keyval(node).i) #define keyisshrstr(node) (keytt(node) == ctb(LUA_VSHRSTR)) #define keystrval(node) (gco2ts(keyval(node).gc)) #define setnilkey(node) (keytt(node) = LUA_TNIL) #define keyiscollectable(n) (keytt(n) & BIT_ISCOLLECTABLE) #define gckey(n) (keyval(n).gc) #define gckeyN(n) (keyiscollectable(n) ? gckey(n) : NULL) /* ** Use a "nil table" to mark dead keys in a table. Those keys serve ** to keep space for removed entries, which may still be part of ** chains. Note that the 'keytt' does not have the BIT_ISCOLLECTABLE ** set, so these values are considered not collectable and are different ** from any valid value. */ #define setdeadkey(n) (keytt(n) = LUA_TTABLE, gckey(n) = NULL) /* }================================================================== */ /* ** 'module' operation for hashing (size is always a power of 2) */ #define lmod(s,size) \ (check_exp((size&(size-1))==0, (cast_int((s) & ((size)-1))))) #define twoto(x) (1<<(x)) #define sizenode(t) (twoto((t)->lsizenode)) /* size of buffer for 'luaO_utf8esc' function */ #define UTF8BUFFSZ 8 LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x); LUAI_FUNC int luaO_ceillog2 (unsigned int x); LUAI_FUNC int luaO_rawarith (lua_State *L, int op, const TValue *p1, const TValue *p2, TValue *res); LUAI_FUNC void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2, StkId res); LUAI_FUNC size_t luaO_str2num (const char *s, TValue *o); LUAI_FUNC int luaO_hexavalue (int c); LUAI_FUNC void luaO_tostring (lua_State *L, TValue *obj); LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp); LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t srclen); #endif
21,906
C++
.h
561
36.823529
79
0.619377
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
1,542,175
lobbycallbacks.h
VladimirMakeev_D2ModdingToolset/mss32/include/lobbycallbacks.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef LOBBYCALLBACKS_H #define LOBBYCALLBACKS_H #ifdef __INTEGRATE_LOBBY2_WITH_ROOMS_PLUGIN #include <RoomsPlugin.h> #endif #include <Lobby2Message.h> namespace hooks { struct CMenuCustomLobby; class LoggingCallbacks : public SLNet::Lobby2Callbacks { public: LoggingCallbacks() = default; ~LoggingCallbacks() override = default; void ExecuteDefaultResult(SLNet::Lobby2Message* msg) override; }; class UiUpdateCallbacks : public SLNet::Lobby2Callbacks { public: UiUpdateCallbacks(CMenuCustomLobby* menuLobby) : menuLobby{menuLobby} { } ~UiUpdateCallbacks() override = default; void MessageResult(SLNet::Client_Login* message) override; void MessageResult(SLNet::Client_Logoff* message) override; private: CMenuCustomLobby* menuLobby; }; class RoomsListCallbacks : public SLNet::RoomsCallback { public: RoomsListCallbacks(CMenuCustomLobby* menuLobby) : menuLobby{menuLobby} { } ~RoomsListCallbacks() override = default; void JoinByFilter_Callback(const SLNet::SystemAddress& senderAddress, SLNet::JoinByFilter_Func* callResult) override; void SearchByFilter_Callback(const SLNet::SystemAddress& senderAddress, SLNet::SearchByFilter_Func* callResult) override; private: CMenuCustomLobby* menuLobby; }; } // namespace hooks #endif // LOBBYCALLBACKS_H
2,219
C++
.h
61
32.508197
82
0.753271
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,176
midclient.h
VladimirMakeev_D2ModdingToolset/mss32/include/midclient.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIDCLIENT_H #define MIDCLIENT_H #include "d2list.h" #include "d2vector.h" #include "midclientcore.h" #include "midcommandqueue2.h" #include "midgardid.h" #include "textmessage.h" #include "uievent.h" namespace game { struct CPhase; struct CMidClientData { CPhase* phase; int unknown2; Vector<TextMessage> messages; List<CMidgardID> list; List<CMidgardID> list2; List<CMidgardID> list3; int unknown7; int unknown8; int unknown9; int unknown10; UiEvent notificationFadeEvent; /**< Restores window notify state. */ /** Flashes game window each second to notify player, for example when battle starts. */ UiEvent notificationShowEvent; }; assert_size(CMidClientData, 136); struct CMidClient : public CMidCommandQueue2::INotifyCQ { CMidClientCore core; CMidClientData* data; }; assert_size(CMidClient, 16); } // namespace game #endif // MIDCLIENT_H
1,734
C++
.h
54
29.5
92
0.756886
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,177
attacksourcelist.h
VladimirMakeev_D2ModdingToolset/mss32/include/attacksourcelist.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef ATTACKSOURCELIST_H #define ATTACKSOURCELIST_H #include "attacksourcecat.h" #include "d2list.h" namespace game { using AttackSourceList = List<LAttackSource>; using AttackSourceListNode = ListNode<LAttackSource>; namespace AttackSourceListApi { struct Api { /** Adds AttackSource to list. */ using Add = int(__thiscall*)(AttackSourceList* list, const LAttackSource* attackSource); Add add; }; Api& get(); } // namespace AttackSourceListApi } // namespace game #endif // ATTACKSOURCELIST_H
1,331
C++
.h
36
34.888889
92
0.768872
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,178
enclayoutruinhooks.h
VladimirMakeev_D2ModdingToolset/mss32/include/enclayoutruinhooks.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef ENCLAYOUTRUINHOOKS_H #define ENCLAYOUTRUINHOOKS_H namespace game { struct CDialogInterf; struct CMidRuin; struct CEncLayoutRuinData; } // namespace game namespace hooks { void __stdcall encLayoutRuinUpdateHooked(const game::CEncLayoutRuinData* data, const game::CMidRuin* ruin, game::CDialogInterf* dialog); } // namespace hooks #endif // ENCLAYOUTRUINHOOKS_H
1,269
C++
.h
31
36.548387
78
0.731331
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,179
mqdisplay2.h
VladimirMakeev_D2ModdingToolset/mss32/include/mqdisplay2.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MQDISPLAY2_H #define MQDISPLAY2_H #include "d2assert.h" namespace game { struct IMqDisplay2Vftable; struct CMqPoint; struct DisplaySettings; struct CMqRect; template <typename T> struct IMqDisplay2T { T* vftable; }; struct IMqDisplay2 : public IMqDisplay2T<IMqDisplay2Vftable> { }; // Virtual table does not contain destructor struct IMqDisplay2Vftable { /** Returns current display settings. */ using GetDisplaySettings = DisplaySettings*(__thiscall*)(IMqDisplay2* thisptr, DisplaySettings* settings); GetDisplaySettings getDisplaySettings; using Method1 = void*(__thiscall*)(IMqDisplay2* thisptr, void* a2); Method1 method1; /** Returns size of screen surface. */ using GetScreenSurfaceSize = CMqPoint*(__thiscall*)(IMqDisplay2* thisptr, CMqPoint* screenSurfaceSize); GetScreenSurfaceSize getScreenSurfaceSize; /** * Assumption: adds scaling start operation to the render queue if rendering is in process. * Otherwise immediately starts scaling in IMqRasterizer. * Does nothing if rasterizer does not support scaling. */ using StartScaling = void(__thiscall*)(IMqDisplay2* thisptr, const CMqRect* area, const CMqPoint* position); StartScaling startScaling; /** * Assumption: adds scaling end operation to the render queue if rendering is in process. * Otherwise immediately ends scaling in IMqRasterizer. * Does nothing if rasterizer does not support scaling. */ using EndScaling = void(__thiscall*)(IMqDisplay2* thisptr); EndScaling endScaling; /** Returns true if scaling operations are supported by current IMqRasterizer. */ using IsScalingSupported = bool(__thiscall*)(const IMqDisplay2* thisptr); IsScalingSupported isScalingSupported; /** Returns true if game is in full screen mode. */ using IsFullscreen = bool(__thiscall*)(const IMqDisplay2* thisptr); IsFullscreen isFullscreen; /** * Swaps screen buffers. * All implementations call IDirectDraw7::FlipToGDISurface. */ using FlipToGDISurface = void(__thiscall*)(IMqDisplay2* thisptr); FlipToGDISurface flipToGDISurface; /** Returns true if specified display settings are supported. */ using IsDisplaySettingsSupported = bool(__thiscall*)(IMqDisplay2* thisptr, const DisplaySettings* settings); IsDisplaySettingsSupported isDisplaySettingsSupported; /** Initializes render surfaces. */ using InitializeSurfaces = bool(__thiscall*)(IMqDisplay2* thisptr, const DisplaySettings* settings); InitializeSurfaces initializeSurfaces; using Method10 = bool(__thiscall*)(const IMqDisplay2* thisptr, int a2); Method10 method10; }; assert_vftable_size(IMqDisplay2Vftable, 11); } // namespace game #endif // MQDISPLAY2_H
3,900
C++
.h
88
37.306818
95
0.697521
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,180
midcampaign.h
VladimirMakeev_D2ModdingToolset/mss32/include/midcampaign.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIDCAMPAIGN_H #define MIDCAMPAIGN_H #include "d2list.h" #include "midgardid.h" #include "midobject.h" #include "racecategory.h" #include "textandid.h" #include <cstddef> namespace game { /** Holds campaign scenario data read from CScen.dbf. */ struct CMidCampaignScenario { CMidgardID scenarioId; char smkBrief[9]; char smkWin[9]; char smkLose[9]; char wavWin[9]; }; assert_size(CMidCampaignScenario, 40); assert_offset(CMidCampaignScenario, smkWin, 13); assert_offset(CMidCampaignScenario, smkLose, 22); assert_offset(CMidCampaignScenario, wavWin, 31); struct CMidCampaignData { LRaceCategory playableRace; char conclusion[9]; List<CMidCampaignScenario> scenarios; TextAndId name; TextAndId description; bool canImport; char padding[3]; }; assert_size(CMidCampaignData, 60); assert_offset(CMidCampaignData, name, 40); /** Holds campaign data read from CCamp.dbf. */ struct CMidCampaign : public IMidObject { CMidCampaignData* data; }; assert_size(CMidCampaign, 12); } // namespace game #endif // MIDCAMPAIGN_H
1,894
C++
.h
60
29.233333
72
0.765222
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,181
functordispatch4.h
VladimirMakeev_D2ModdingToolset/mss32/include/functordispatch4.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef FUNCTORDISPATCH4_H #define FUNCTORDISPATCH4_H namespace game { template <typename T, typename U, typename V, typename W> struct CBFunctorDispatch4Vftable; template <typename T, typename U, typename V, typename W> struct CBFunctorDispatch4 { CBFunctorDispatch4Vftable<T, U, V, W>* vftable; }; template <typename T, typename U, typename V, typename W> struct CBFunctorDispatch4Vftable { /** Calls functor-specific callback function, passing it T, U, V and W as a parameters. */ using RunCallback = void(__thiscall*)(CBFunctorDispatch4<T, U, V, W>* thisptr, T value, U value2, V value3, W value4); RunCallback runCallback; }; } // namespace game #endif // FUNCTORDISPATCH4_H
1,683
C++
.h
41
34.97561
94
0.68685
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,182
faceimgimpl.h
VladimirMakeev_D2ModdingToolset/mss32/include/faceimgimpl.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2023 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef FACEIMGIMPL_H #define FACEIMGIMPL_H #include "faceimg.h" #include "imagedatadescriptor.h" #include "mqtexture.h" #include "smartptr.h" #include "texturehandle.h" namespace game { struct CMqPresentationManager; struct CFaceImgImpl : public CFaceImg::IFaceImg , public IMqTexture { SmartPtr<CMqPresentationManager> presentationManager; TextureHandle textureHandle; ImageDataDescriptor imageDataDescriptor; int unknown68; int percentHp; bool leftSide; bool unknown77; bool unknown78; char padding; }; assert_size(CFaceImgImpl, 80); assert_offset(CFaceImgImpl, imageDataDescriptor, 32); assert_offset(CFaceImgImpl, unknown68, 68); } // namespace game #endif // FACEIMGIMPL_H
1,544
C++
.h
46
31.065217
72
0.774497
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,183
capitaldata.h
VladimirMakeev_D2ModdingToolset/mss32/include/capitaldata.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef CAPITALDATA_H #define CAPITALDATA_H #include "capitalraceset.h" #include "smartptr.h" namespace game { /** Holds capitals information read from Capital.dat. */ struct CapitalData { CapitalDatList heretic; CapitalDatList human; CapitalDatList dwarf; CapitalDatList undead; CapitalDatList elf; CapitalRaceSet races; }; assert_size(CapitalData, 108); using CapitalDataPtr = SmartPtr<CapitalData*>; namespace CapitalDataApi { struct Api { /** Allocates memory for CapitalData structure and initializes races list. */ using Allocate = CapitalData**(__thiscall*)(CapitalData** thisptr); Allocate allocate; /** * Returns capital data using smart pointer. * Creates CapitalData global object on first function call. */ using GetCapitalData = CapitalDataPtr*(__stdcall*)(CapitalDataPtr* capitalData); GetCapitalData getCapitalData; /** * Sets smart pointer data. * Decrements reference counter if data is nullptr; */ using CapitalDataPtrSetData = void(__thiscall*)(CapitalDataPtr* thisptr, CapitalData** data); CapitalDataPtrSetData capitalDataPtrSetData; /** Reads Capital.dat information into CapitalData. */ using Read = void(__stdcall*)(const char* imagesFolderPath, const char* filename); Read read; /** Reads single Capital.dat entry for specified race. */ using ReadEntry = bool(__thiscall*)(CapitalData**** thisptr, const char* configFilePath, const LRaceCategory* race); ReadEntry readEntry; }; Api& get(); } // namespace CapitalDataApi } // namespace game #endif // CAPITALDATA_H
2,511
C++
.h
66
33.606061
97
0.724166
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,184
enclayoutcity.h
VladimirMakeev_D2ModdingToolset/mss32/include/enclayoutcity.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef ENCLAYOUTCITY_H #define ENCLAYOUTCITY_H #include "enclayout.h" #include "midgardid.h" #include "smartptr.h" namespace game { struct CEncLayoutCityData; struct IMidgardObjectMap; struct CFortification; struct CMidUnitGroup; struct IMqImage2; struct CEncLayoutCity : public IEncLayout { CEncLayoutCityData* data; }; assert_size(CEncLayoutCity, 16); // Similar to GroupAdapterUnitData struct CEncLayoutCityGroupData { bool boostApplied[6]; bool lowerApplied[6]; bool potionApplied[6]; bool canLevelUp[6]; bool hasHighLevel[6]; char padding[2]; int highLevel[6]; }; assert_size(CEncLayoutCityGroupData, 56); // Similar to CDDUnitGroupData struct CEncLayoutCityData { const IMidgardObjectMap* objectMap; CMidgardID* playerId; CMidgardID fortificationId; SmartPointer buttonFunctor; IMqImage2* spellBoostIcon; IMqImage2* spellLowerIcon; IMqImage2* potionBoostIcon; IMqImage2* upgrageIcon; IMqImage2* highLevelIcons[3]; CEncLayoutCityGroupData stackGroup; CEncLayoutCityGroupData fortGroup; }; assert_size(CEncLayoutCityData, 160); assert_offset(CEncLayoutCityData, stackGroup.highLevel, 80); assert_offset(CEncLayoutCityData, fortGroup.highLevel, 136); namespace CEncLayoutCityApi { struct Api { using Update = void(__thiscall*)(CEncLayoutCity* thisptr, const IMidgardObjectMap* objectMap, const CFortification* fort, CDialogInterf* dialog); Update update; using UpdateGroupUi = void(__stdcall*)(const IMidgardObjectMap* objectMap, const CMidUnitGroup* group, CDialogInterf* dialog, const char* txtStackNameFormat, const char* imgStackNameFormat, bool isStackGroup); UpdateGroupUi updateGroupUi; }; Api& get(); IEncLayoutVftable* vftable(); } // namespace CEncLayoutCityApi } // namespace game #endif // ENCLAYOUTCITY_H
2,971
C++
.h
85
28.623529
78
0.699093
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,185
version.h
VladimirMakeev_D2ModdingToolset/mss32/include/version.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef VERSION_H #define VERSION_H #include <filesystem> #include <system_error> namespace hooks { enum class GameVersion { Unknown = -1, Akella, Russobit, Gog, ScenarioEditor }; /** Returns determined game version. */ GameVersion gameVersion(); /** Returns true if dll loaded from game executable. */ bool executableIsGame(); /** Returns true if custom lobby is supported. */ bool isLobbySupported(); std::error_code determineGameVersion(const std::filesystem::path& exeFilePath); } // namespace hooks #endif // VERSION_H
1,366
C++
.h
40
31.975
79
0.757599
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,186
waitgenerationinterf.h
VladimirMakeev_D2ModdingToolset/mss32/include/waitgenerationinterf.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2023 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef WAITGENERATIONINTERF_H #define WAITGENERATIONINTERF_H #include "popupdialoginterf.h" namespace hooks { struct CMenuRandomScenario; using OnGenerationCanceled = void (*)(CMenuRandomScenario* thisptr); /** Represents 'DLG_WAIT_GENERATION' from Interf.dlg */ struct WaitGenerationInterf : public game::CPopupDialogInterf { OnGenerationCanceled onCanceled; CMenuRandomScenario* menu; }; WaitGenerationInterf* createWaitGenerationInterf(CMenuRandomScenario* menu, OnGenerationCanceled onCanceled); } // namespace hooks #endif // WAITGENERATIONINTERF_H
1,433
C++
.h
34
38.705882
82
0.764748
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,187
scenarioinfo.h
VladimirMakeev_D2ModdingToolset/mss32/include/scenarioinfo.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef SCENARIOINFO_H #define SCENARIOINFO_H #include "d2list.h" #include "difficultylevel.h" #include "midgardid.h" #include "midscenarioobject.h" #include "racecategory.h" #include <cstddef> namespace game { /** Holds general information about scenario in scenario file and game. */ struct CScenarioInfo : public IMidScenarioObject { char* name; char* description; char* briefing; char* briefLong; char* debunkW; char* debunkL; int currentTurn; char official; char sourceM; char padding[2]; char* creator; int mapSize; int qtyCities; LDifficultyLevel scenarioDifficulty; LDifficultyLevel gameDifficulty; List<LRaceCategory> races; CMidgardID campaignId; int spellMaxTier; int unitMaxTier; int leaderMaxLevel; int cityMaxTier; int suggestedLevel; int mapSeed; }; assert_size(CScenarioInfo, 120); assert_offset(CScenarioInfo, scenarioDifficulty, 52); assert_offset(CScenarioInfo, unitMaxTier, 100); } // namespace game #endif // SCENARIOINFO_H
1,856
C++
.h
59
28.491525
74
0.756425
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,188
registeraccountinterf.h
VladimirMakeev_D2ModdingToolset/mss32/include/registeraccountinterf.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef REGISTERACCOUNTINTERF_H #define REGISTERACCOUNTINTERF_H namespace hooks { void showRegisterAccountDialog(); } // namespace hooks #endif // REGISTERACCOUNTINTERF_H
988
C++
.h
24
39.25
72
0.775808
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,189
mqanimator2.h
VladimirMakeev_D2ModdingToolset/mss32/include/mqanimator2.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MQANIMATOR2_H #define MQANIMATOR2_H #include "d2assert.h" namespace game { struct IMqAnimator2Vftable; struct IMqAnimation; struct IMqAnimator2 { IMqAnimator2Vftable* vftable; }; // Virtual table does not contain destructor struct IMqAnimator2Vftable { using HandleAnimation = bool(__thiscall*)(IMqAnimator2* thisptr, IMqAnimation* animation); HandleAnimation addSlowAnimation; HandleAnimation addFastAnimation; HandleAnimation removeSlowAnimation; HandleAnimation removeFastAnimation; }; assert_vftable_size(IMqAnimator2Vftable, 4); } // namespace game #endif // MQANIMATOR2_H
1,432
C++
.h
40
33.525
94
0.785818
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,190
midmsgboxbuttonhandler.h
VladimirMakeev_D2ModdingToolset/mss32/include/midmsgboxbuttonhandler.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIDMSGBOXBUTTONHANDLER_H #define MIDMSGBOXBUTTONHANDLER_H #include "d2assert.h" namespace game { struct CMidMsgBoxButtonHandlerVftable; struct CMidgardMsgBox; /** Base class for all CMidgardMsgBox button handlers. */ struct CMidMsgBoxButtonHandler { CMidMsgBoxButtonHandlerVftable* vftable; }; assert_size(CMidMsgBoxButtonHandler, 4); struct CMidMsgBoxButtonHandlerVftable { using Destructor = void(__thiscall*)(CMidMsgBoxButtonHandler* thisptr); Destructor destructor; /** * CMidgardMsgBox result handler function. * Called on BTN_YES, BTN_OK and BTN_NO presses. */ using Handler = void(__thiscall*)(CMidMsgBoxButtonHandler* thisptr, CMidgardMsgBox* msgBox, bool okPressed); Handler handler; }; assert_vftable_size(CMidMsgBoxButtonHandlerVftable, 2); } // namespace game #endif // MIDMSGBOXBUTTONHANDLER_H
1,753
C++
.h
46
34
75
0.744104
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,191
multilayerimg.h
VladimirMakeev_D2ModdingToolset/mss32/include/multilayerimg.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MULTILAYERIMG_H #define MULTILAYERIMG_H #include "d2list.h" #include "mqimage2.h" #include "mqpoint.h" #include "smartptr.h" namespace game { struct MultiLayerImgInfo { SmartPtr<IMqImage2> image; int unknown; int unknown2; bool unknown3; bool unknown4; char padding[2]; }; assert_size(MultiLayerImgInfo, 20); struct CMultiLayerImgData { List<MultiLayerImgInfo> images; CMqPoint size; std::uint32_t imagesCount; }; assert_size(CMultiLayerImgData, 28); /** Used to render several images on top of each other. */ struct CMultiLayerImg : public IMqImage2 { CMultiLayerImgData* data; }; assert_size(CMultiLayerImg, 8); namespace CMultiLayerImgApi { struct Api { using Constructor = CMultiLayerImg*(__thiscall*)(CMultiLayerImg* thisptr); Constructor constructor; using AddImage = void(__thiscall*)(CMultiLayerImg* thisptr, const IMqImage2* image, int a3, int a4); AddImage addImage; }; Api& get(); } // namespace CMultiLayerImgApi } // namespace game #endif // MULTILAYERIMG_H
1,980
C++
.h
63
27.15873
78
0.713835
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,192
faceimg.h
VladimirMakeev_D2ModdingToolset/mss32/include/faceimg.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2023 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef FACEIMG_H #define FACEIMG_H #include "mqimage2.h" namespace game { struct IFaceImgVftable; struct CFaceImg { struct IFaceImg : public IMqImage2T<IFaceImgVftable> { }; assert_size(IFaceImg, 4); }; /** Unknown names map to CFaceImgImpl fields. */ struct IFaceImgVftable : public IMqImage2Vftable { /** Probably image index. */ using SetInt = void(__thiscall*)(CFaceImg::IFaceImg* thisptr, int value); SetInt setUnknown68; using GetInt = int(__thiscall*)(CFaceImg::IFaceImg* thisptr); GetInt getUnknown68; SetInt setPercentHp; SetInt setLeftSide; }; assert_vftable_size(IFaceImgVftable, 13); } // namespace game #endif // FACEIMG_H
1,503
C++
.h
43
32.325581
77
0.751209
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,193
mqnetreception.h
VladimirMakeev_D2ModdingToolset/mss32/include/mqnetreception.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MQNETRECEPTION_H #define MQNETRECEPTION_H namespace game { struct IMqNetReceptionVftable; struct IMqNetReception { IMqNetReceptionVftable* vftable; }; struct IMqNetReceptionVftable { using Destructor = void(__thiscall*)(IMqNetReception* thisptr, char flags); Destructor destructor; /** Called to notify server or client about receiving net message. */ using Notify = void(__thiscall*)(IMqNetReception* thisptr); Notify notify; }; } // namespace game #endif // MQNETRECEPTION_H
1,329
C++
.h
36
34.555556
79
0.766537
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,194
midstacktemplate.h
VladimirMakeev_D2ModdingToolset/mss32/include/midstacktemplate.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIDSTACKTEMPLATE_H #define MIDSTACKTEMPLATE_H #include "d2list.h" #include "idvector.h" #include "midgardid.h" #include "midscenarioobject.h" #include "ordercat.h" #include "stringandid.h" #include <cstddef> namespace game { enum class Facing : std::uint8_t { SouthWest, West, NorthWest, North, NorthEast, East, SouthEast, South }; struct StackTemplateListNode { char unknown[8]; }; struct CMidStackTemplate : public IMidScenarioObject { CMidgardID ownerId; CMidgardID subraceId; LOrderCategory orderCategory; CMidgardID orderTargetId; StringAndId name; CMidgardID leaderId; IdVector units; CMidgardID positions[6]; bool useFacing; Facing facing; char padding[2]; List<StackTemplateListNode> modifiers; int aiPriority; }; assert_size(CMidStackTemplate, 112); assert_offset(CMidStackTemplate, orderTargetId, 28); assert_offset(CMidStackTemplate, facing, 89); } // namespace game #endif // MIDSTACKTEMPLATE_H
1,824
C++
.h
64
25.71875
72
0.759566
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,195
midmusic.h
VladimirMakeev_D2ModdingToolset/mss32/include/midmusic.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIDMUSIC_H #define MIDMUSIC_H #include "d2string.h" #include "racecategory.h" #include "smartptr.h" namespace game { struct CLogFile; struct CSoundSystemStream; struct CStreamHolder; struct CMidMusicData { char musicFolder[260]; char customMusicFolder[260]; CLogFile* logFile; CStreamHolder* streamHolder; SmartPtr<CSoundSystemStream> soundSystemStream; int unknown2; int unknown3; LRaceCategory raceCategory; String string; String string2; String string3; String string4; char unknown4[12]; }; assert_size(CMidMusicData, 632); struct CMidMusic { CMidMusicData* data; }; assert_size(CMidMusic, 4); namespace CMidMusicApi { struct Api { /** * Frees memory allocated for strings in CMidMusicData. * Actual meaning unknown. */ using FreeStrings = void(__thiscall*)(CMidMusic* thisptr); FreeStrings freeStrings; /** * Plays specified wav or mp3 file. * @param[in] thisptr pointer to music object. * @param[in] folder string containing path to folder with file. * @param[in] fileName name of file without extension to play. * @param a4 unknown. * @param mp3 if set to true '.mp3' used as file extension, otherwise '.wav'. */ using PlayFile = void(__thiscall*)(CMidMusic* thisptr, const char* folder, const char* fileName, int a4, bool mp3); PlayFile playFile; /** Used to switch between music tracks in battle. */ using PlayBattleTrack = void(__thiscall*)(CMidMusic* thisptr); PlayBattleTrack playBattleTrack; /** Used to switch between music tracks in capital cities. */ using PlayCapitalTrack = void(__thiscall*)(CMidMusic* thisptr, const LRaceCategory* raceCategory); PlayCapitalTrack playCapitalTrack; }; Api& get(); } // namespace CMidMusicApi } // namespace game #endif // MIDMUSIC_H
2,879
C++
.h
84
28.619048
82
0.684305
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,196
diplomacyhooks.h
VladimirMakeev_D2ModdingToolset/mss32/include/diplomacyhooks.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2023 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DIPLOMACYHOOKS_H #define DIPLOMACYHOOKS_H #include <cstdint> namespace game { struct CMidDiplomacy; struct LRaceCategory; } namespace hooks { std::uint32_t* __fastcall getCurrentRelationHooked(const game::CMidDiplomacy* thisptr, int /*%edx*/, std::uint32_t* current, const game::LRaceCategory* race1, const game::LRaceCategory* race2); std::uint32_t* __fastcall getPreviousRelationHooked(const game::CMidDiplomacy* thisptr, int /*%edx*/, std::uint32_t* previous, const game::LRaceCategory* race1, const game::LRaceCategory* race2); bool __fastcall areAlliesHooked(const game::CMidDiplomacy* thisptr, int /*%edx*/, const game::LRaceCategory* race1, const game::LRaceCategory* race2); std::uint32_t* __fastcall getAllianceTurnHooked(const game::CMidDiplomacy* thisptr, int /*%edx*/, std::uint32_t* turn, const game::LRaceCategory* race1, const game::LRaceCategory* race2); bool __fastcall areAlwaysAtWarHooked(const game::CMidDiplomacy* thisptr, int /*%edx*/, const game::LRaceCategory* race1, const game::LRaceCategory* race2); bool __fastcall aiCouldNotBreakAllianceHooked(const game::CMidDiplomacy* thisptr, int /*%edx*/, const game::LRaceCategory* race1, const game::LRaceCategory* race2); bool __stdcall areRelationsAtWarHooked(const std::uint32_t* relation); bool __stdcall areRelationsNeutralHooked(const std::uint32_t* relation); bool __stdcall areRelationsPeacefulHooked(const std::uint32_t* relation); } #endif // DIPLOMACYHOOKS_H
3,221
C++
.h
58
37.655172
87
0.548571
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,197
customattackutils.h
VladimirMakeev_D2ModdingToolset/mss32/include/customattackutils.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef CUSTOMATTACKUTILS_H #define CUSTOMATTACKUTILS_H #include "customattacks.h" #include "idlist.h" #include "targetset.h" #include <filesystem> #include <optional> namespace game { struct CMidgardID; struct IMidgardObjectMap; struct BattleMsgData; struct IAttack; struct IBatAttack; } // namespace game namespace bindings { class ItemView; class UnitSlotView; class BattleMsgDataView; } // namespace bindings namespace hooks { struct CustomAttackData; struct CustomAttackReach; using UnitSlots = std::vector<bindings::UnitSlotView>; void fillCustomAttackSources(const std::filesystem::path& dbfFilePath); void fillCustomAttackReaches(const std::filesystem::path& dbfFilePath); UnitSlots getTargetsToSelectOrAttack(const std::string& scriptFile, const bindings::UnitSlotView& attacker, const bindings::UnitSlotView& selected, const UnitSlots& allies, const UnitSlots& targets, bool targetsAreAllies, const std::optional<bindings::ItemView>& item, const bindings::BattleMsgDataView& battle, bool isMarking); UnitSlots getTargets(const game::IMidgardObjectMap* objectMap, const game::BattleMsgData* battleMsgData, const game::IBatAttack* batAttack, const game::CMidgardID* targetGroupId, const game::CMidgardID* unitId, const game::CMidgardID* selectedUnitId); UnitSlots getAllies(const game::IMidgardObjectMap* objectMap, const game::BattleMsgData* battleMsgData, const game::CMidgardID* unitGroupId, const game::CMidgardID* unitId); void fillTargetsListForCustomAttackReach(const game::IMidgardObjectMap* objectMap, const game::BattleMsgData* battleMsgData, const game::IBatAttack* batAttack, const game::CMidgardID* targetGroupId, const game::CMidgardID* unitGroupId, const game::CMidgardID* unitId, const game::CMidgardID* attackUnitOrItemId, const CustomAttackReach& attackReach, game::TargetSet* value); void getTargetsToAttackForAllAttackReach(const game::IMidgardObjectMap* objectMap, const game::BattleMsgData* battleMsgData, const game::IAttack* attack, const game::IBatAttack* batAttack, const game::CMidgardID* targetGroupId, const game::CMidgardID* targetUnitId, game::IdList* value); UnitSlots getTargetsToMarkOrAttackForCustomAttackReach(const game::IMidgardObjectMap* objectMap, const game::BattleMsgData* battleMsgData, const game::IBatAttack* batAttack, const game::CMidgardID* targetGroupId, const game::CMidgardID* targetUnitId, const game::CMidgardID* unitGroupId, const game::CMidgardID* unitId, const CustomAttackReach& attackReach, bool isMarking); UnitSlots getTargetsToAttackForCustomAttackReach(const game::IMidgardObjectMap* objectMap, const game::BattleMsgData* battleMsgData, const game::IBatAttack* batAttack, const game::CMidgardID* targetGroupId, const game::CMidgardID* targetUnitId, const game::CMidgardID* unitGroupId, const game::CMidgardID* unitId, const CustomAttackReach& attackReach); UnitSlots getTargetsToMarkForCustomAttackReach(const game::IMidgardObjectMap* objectMap, const game::BattleMsgData* battleMsgData, const game::IAttack* attack, const game::CMidgardID* targetGroupId, const game::CMidgardID* targetUnitId, const game::CMidgardID* unitGroupId, const game::CMidgardID* unitId, const game::CMidgardID* attackUnitId, const CustomAttackReach& attackReach); void getTargetsToAttackForCustomAttackReach(const game::IMidgardObjectMap* objectMap, const game::BattleMsgData* battleMsgData, const game::IBatAttack* batAttack, const game::CMidgardID* targetGroupId, const game::CMidgardID* targetUnitId, const game::CMidgardID* unitGroupId, const game::CMidgardID* unitId, const CustomAttackReach& attackReach, game::IdList* value); bool shouldExcludeImmuneTargets(const game::IMidgardObjectMap* objectMap, const game::BattleMsgData* battleMsgData, const game::CMidgardID* unitId); void excludeImmuneTargets(const game::IMidgardObjectMap* objectMap, const game::BattleMsgData* battleMsgData, const game::IAttack* attack, const game::CMidgardID* unitGroupId, const game::CMidgardID* targetGroupId, game::TargetSet* value); void fillCustomAttackTargets(const game::IdList* targets); const CustomAttackDamageRatios& getCustomDamageRatios(const game::IAttack* attack); int applyAttackDamageRatio(int damage, double ratio); std::vector<double> computeAttackDamageRatio(const CustomAttackData& customData, int targetCount); double computeTotalDamageRatio(const game::IAttack* attack, int targetCount); int computeAverageTotalDamage(const game::IAttack* attack, int damage); CustomAttackData getCustomAttackData(const game::IAttack* attack); } // namespace hooks #endif // CUSTOMATTACKUTILS_H
8,114
C++
.h
131
39.671756
98
0.547272
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,198
midplayer.h
VladimirMakeev_D2ModdingToolset/mss32/include/midplayer.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIDPLAYER_H #define MIDPLAYER_H #include "categories.h" #include "currency.h" #include "d2set.h" #include "midgardid.h" #include "midscenarioobject.h" #include "stringandid.h" namespace game { struct TRaceType; /** Holds player related data in scenario file and game. */ struct CMidPlayer : public IMidScenarioObject { StringAndId name; StringAndId description; int face; CMidgardID raceId; CMidgardID lordId; TRaceType* raceType; LAttitudesCategory attitude; int qtyBreaks; CMidgardID fogId; CMidgardID knownSpellsId; CMidgardID buildingsId; int researchTurn; int constructionTurn; Set<CMidgardID> spyData; Bank bank; Bank spellBank; bool isHuman; char padding[3]; CMidgardID capturedById; bool alwaysAi; char padding2[3]; Set<std::uint64_t> exmapData; // Each node contains 8 bytes of data }; assert_size(CMidPlayer, 176); assert_offset(CMidPlayer, bank, 112); assert_offset(CMidPlayer, spellBank, 124); assert_offset(CMidPlayer, isHuman, 136); } // namespace game #endif // MIDPLAYER_H
1,905
C++
.h
60
28.866667
72
0.754491
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,199
mqnetsessenum.h
VladimirMakeev_D2ModdingToolset/mss32/include/mqnetsessenum.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MQNETSESSENUM_H #define MQNETSESSENUM_H #include "d2list.h" namespace game { struct String; struct IMqNetPlayerEnum; struct IMqNetSessEnumVftable; /** * Interface for thin wrappers that are created during session enumeration. * Used to store common session info to show in UI and further connection. */ struct IMqNetSessEnum { IMqNetSessEnumVftable* vftable; }; struct IMqNetSessEnumVftable { using Destructor = void(__thiscall*)(IMqNetSessEnum* thisptr, char flags); Destructor destructor; /** Returns session name. */ using GetName = String*(__thiscall*)(const IMqNetSessEnum* thisptr, String* name); GetName getName; /** Returns current number of players in a session. */ using GetPlayersCount = int(__thiscall*)(const IMqNetSessEnum* thisptr); GetPlayersCount getPlayersCount; /** Returns maximum allowed number of players in a session. */ using GetMaxPlayers = int(__thiscall*)(const IMqNetSessEnum* thisptr); GetMaxPlayers getMaxPlayers; /** Returns true if session protected with a password. */ using IsPasswordRequired = bool(__thiscall*)(const IMqNetSessEnum* thisptr); IsPasswordRequired isPasswordRequired; /** Returns list of players in a session. */ using GetPlayers = void(__thiscall*)(const IMqNetSessEnum* thisptr, List<IMqNetPlayerEnum*>* players); GetPlayers getPlayers; }; assert_vftable_size(IMqNetSessEnumVftable, 6); } // namespace game #endif // MQNETSESSENUM_H
2,335
C++
.h
57
37.385965
86
0.746908
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,200
d2unorderedmap.h
VladimirMakeev_D2ModdingToolset/mss32/include/d2unorderedmap.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2023 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef D2UNORDEREDMAP_H #define D2UNORDEREDMAP_H #include "d2assert.h" #include <cstdint> namespace game { template <typename Key, typename T> struct UnorderedMapBucket { Key key; T value; std::uint32_t partialHash; UnorderedMapBucket<Key, T>* next; }; using AssertBucketSize = UnorderedMapBucket<int, int>; assert_size(AssertBucketSize, 16); /** Implementation of std::unordered_map<Key, T> used in game. */ template <typename Key, typename T, typename Unknown = int> struct UnorderedMap { char unknown; char padding[3]; std::uint32_t elementsCount; UnorderedMapBucket<Key, T>** buckets; std::uint32_t bucketsCount; std::uint32_t reallocationThreshold; int maxLoadFactor; /**< Bit representation of a float value */ char unknown4; char unknown5; char unknown6; char unknown7; Unknown unknown8; int unknown9; void* allocator; }; using AssertUnorderedMapSize = UnorderedMap<int, int>; assert_size(AssertUnorderedMapSize, 40); } // namespace game #endif // D2UNORDEREDMAP_H
1,866
C++
.h
56
30.571429
72
0.75236
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,201
immunecat.h
VladimirMakeev_D2ModdingToolset/mss32/include/immunecat.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef IMMUNECAT_H #define IMMUNECAT_H #include "categories.h" namespace game { struct LImmuneCatTable : CEnumConstantTable<ImmuneId> { }; struct LImmuneCat : public Category<ImmuneId> { }; namespace ImmuneCategories { struct Categories { LImmuneCat* notimmune; LImmuneCat* once; LImmuneCat* always; }; Categories& get(); /** Returns address of LImmuneCat::vftable used in game. */ const void* vftable(); } // namespace ImmuneCategories namespace LImmuneCatTableApi { using Api = CategoryTableApi::Api<LImmuneCatTable, LImmuneCat>; Api& get(); /** Returns address of LImmuneCatTable::vftable used in game. */ const void* vftable(); } // namespace LImmuneCatTableApi } // namespace game #endif // IMMUNECAT_H
1,550
C++
.h
45
32.422222
72
0.768145
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,202
midgardscenariomap.h
VladimirMakeev_D2ModdingToolset/mss32/include/midgardscenariomap.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIDGARDSCENARIOMAP_H #define MIDGARDSCENARIOMAP_H #include "d2set.h" #include "d2unorderedmap.h" #include "midgardobjectmap.h" #include <cstdint> namespace game { struct IMidgardStreamEnv; using ScenarioObjectRecord = UnorderedMapBucket<CMidgardID, SmartPtr<IMidScenarioObject>>; assert_size(ScenarioObjectRecord, 20); /** Stores scenario objects. */ struct CMidgardScenarioMap : public IMidgardObjectMap { CMidgardID scenarioFileId; UnorderedMap<CMidgardID, SmartPtr<IMidScenarioObject>> data; /** Used to keep track of last free CMidgardID type index for each IdType. */ int freeIdTypeIndices[59]; Set<CMidgardID> addedObjects; Set<CMidgardID> changedObjects; Set<CMidgardID> objectsToErase; }; assert_size(CMidgardScenarioMap, 368); struct ScenarioMapDataIterator { bool unknown; char padding[3]; ScenarioObjectRecord** records; ScenarioObjectRecord* foundRecord; int recordsTotal; }; assert_size(ScenarioMapDataIterator, 16); struct CMidgardScenarioMapIter : public IMidgardObjectMap::Iterator { ScenarioMapDataIterator iterator; }; assert_size(CMidgardScenarioMapIter, 20); namespace CMidgardScenarioMapApi { struct Api { using GetIterator = ScenarioMapDataIterator*(__thiscall*)(CMidgardScenarioMap* thisptr, ScenarioMapDataIterator* iterator); /** Returns a raw iterator to the first record. */ GetIterator begin; /** Returns a raw iterator to the record following the last one. */ GetIterator end; /** Advances raw iterator. */ using Advance = void(__thiscall*)(ScenarioMapDataIterator* thisptr); Advance advance; /** Checks objects correctness and updates freeIdTypeIndices. */ using CheckObjects = bool(__thiscall*)(CMidgardScenarioMap* scenarioMap); CheckObjects checkObjects; using Stream = bool(__thiscall*)(CMidgardScenarioMap* scenarioMap, IMidgardStreamEnv* streamEnv); Stream stream; }; Api& get(); IMidgardObjectMapVftable* vftable(); } // namespace CMidgardScenarioMapApi } // namespace game #endif // MIDGARDSCENARIOMAP_H
2,988
C++
.h
78
34.192308
97
0.751645
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,203
unitpositionmap.h
VladimirMakeev_D2ModdingToolset/mss32/include/unitpositionmap.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef UNITPOSITIONMAP_H #define UNITPOSITIONMAP_H #include "d2map.h" #include "unitpositionpair.h" namespace game { using UnitPositionMap = Map<int, bool>; using UnitPositionMapNode = MapNode<int, bool>; using UnitPositionMapIterator = MapIterator<int, bool>; namespace UnitPositionMapApi { struct Api { using Constructor = UnitPositionMap*(__thiscall*)(UnitPositionMap* thisptr); Constructor constructor; using Destructor = void(__thiscall*)(UnitPositionMap* thisptr); Destructor destructor; using CopyConstructor = UnitPositionMap*(__thiscall*)(UnitPositionMap* thisptr, const UnitPositionMap* src); CopyConstructor copyConstructor; using CopyAssignment = UnitPositionMap*(__thiscall*)(UnitPositionMap* thisptr, const UnitPositionMap* src); CopyAssignment copyAssignment; using FindByPosition = UnitPositionPair*(__stdcall*)(UnitPositionPair* value, const UnitPositionMap* map, int position); FindByPosition findByPosition; using HasNegativePosition = bool(__stdcall*)(const UnitPositionMap* thisptr); HasNegativePosition hasNegativePosition; }; Api& get(); } // namespace UnitPositionMapApi } // namespace game #endif // UNITPOSITIONMAP_H
2,249
C++
.h
50
37.8
86
0.698718
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,204
mqrenderer2.h
VladimirMakeev_D2ModdingToolset/mss32/include/mqrenderer2.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MQRENDERER2_H #define MQRENDERER2_H #include "d2assert.h" namespace game { struct IMqRenderer2Vftable; struct CMqPoint; struct CMqRect; struct TextureHandle; /** Statistics are shown in CMqFps window. */ struct RenderStatistics { int unique; int used; int created; int loaded; int texels; int pixels; int memory; int blitCount; }; assert_size(RenderStatistics, 32); struct IMqRenderer2 { IMqRenderer2Vftable* vftable; }; // Virtual table does not contain destructor struct IMqRenderer2Vftable { /** Assumption: returns current batch number. */ using GetBatchNumber = int(__thiscall*)(IMqRenderer2* thisptr); GetBatchNumber getBatchNumber; /** Returns current fps the game is running on. */ using GetFps = float(__thiscall*)(const IMqRenderer2* thisptr); GetFps getFPS; /** * Called before rendering frame. * Clears screen with solid black color. * Sets 'frame rendering' flag. * Called before drawing CMqPresentationManager::IPresentation elements. */ using BeforeRender = void(__thiscall*)(IMqRenderer2* thisptr); BeforeRender beforeRender; /** * Main rendering logic. * Called after drawing all CMqPresentationManager::IPresentation elements. * Processes render queue into batch and calls IMqTexture methods * to draw their contents if dirty. Performs alpha blending. * Swaps front and back buffers, updates fps, animations and render statistics. * Resets 'frame rendering' flag. */ using RenderFrame = int(__thiscall*)(IMqRenderer2* thisptr); RenderFrame renderFrame; /** * Adds texture handle with specified dimensions to render queue * for rendering in the current frame. * For example, called from CMqImage2Surface16::IMqImage2::render (0x670790). * CMqImage2Surface16 adds its texture handle along with points and area, * so render will pack this into a batch and call IMqTexture::draw during batch processing. * Does nothing if 'frame rendering' flag is not set. */ using DrawTexture = void(__thiscall*)(IMqRenderer2* thisptr, TextureHandle* textureHandle, const CMqPoint* start, const CMqPoint* offset, const CMqPoint* size, const CMqRect* area); DrawTexture drawTexture; /** * Adds specified area to render queue list. * Use cases unknown. */ using AddArea = void(__thiscall*)(IMqRenderer2* thisptr, const CMqRect* area); AddArea addArea; /** * Removes first area from render queue list. * Use cases unknown. */ using RemoveArea = void(__thiscall*)(IMqRenderer2* thisptr); RemoveArea removeArea; /** Returns current renderer statistics. */ using GetRenderStats = void(__thiscall*)(const IMqRenderer2* thisptr, RenderStatistics* statistics); GetRenderStats getRenderStats; /** * Clears render statistics, except blitCount. * Called from CMidgardOnKeyPressed when pressing Ctrl+R. */ using ResetRenderStats = void(__thiscall*)(IMqRenderer2* thisptr); ResetRenderStats resetRenderStats; using Method9 = void(__thiscall*)(IMqRenderer2* thisptr, int a2, int a3, int a4); Method9 method9; void* method10; void* method11; using Method12 = void(__thiscall*)(IMqRenderer2* thisptr); Method12 method12; }; assert_vftable_size(IMqRenderer2Vftable, 13); } // namespace game #endif // MQRENDERER2_H
4,501
C++
.h
117
32.324786
95
0.689821
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,205
unitpositionlist.h
VladimirMakeev_D2ModdingToolset/mss32/include/unitpositionlist.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef UNITPOSITIONLIST_H #define UNITPOSITIONLIST_H #include "d2list.h" #include "unitpositionpair.h" namespace game { using UnitPositionList = List<UnitPositionPair>; using UnitPositionListNode = ListNode<UnitPositionPair>; using UnitPositionListIterator = ListIterator<UnitPositionPair>; namespace UnitPositionListApi { struct Api { using Constructor = UnitPositionList*(__thiscall*)(UnitPositionList* thisptr); Constructor constructor; using Destructor = void(__thiscall*)(UnitPositionList* thisptr); Destructor destructor; }; Api& get(); } // namespace UnitPositionListApi } // namespace game #endif // UNITPOSITIONLIST_H
1,468
C++
.h
38
36.473684
82
0.782241
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,206
effectinterfhandler.h
VladimirMakeev_D2ModdingToolset/mss32/include/effectinterfhandler.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef EFFECTINTERFHANDLER_H #define EFFECTINTERFHANDLER_H namespace game::editor { struct CEffectInterfHandlerVftable; struct CEffectInterfHandler { CEffectInterfHandlerVftable* vftable; }; struct CEffectInterfHandlerVftable { using Destructor = void(__thiscall*)(CEffectInterfHandler* thisptr, char flags); Destructor destructor; using RunCallback = void(__thiscall*)(CEffectInterfHandler* thisptr, bool); RunCallback runCallback; }; } // namespace game::editor #endif // EFFECTINTERFHANDLER_H
1,337
C++
.h
35
35.914286
84
0.779753
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,207
batviewer.h
VladimirMakeev_D2ModdingToolset/mss32/include/batviewer.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef BATVIEWER_H #define BATVIEWER_H #include "unitpositionmap.h" namespace game { struct IBatViewer; struct IBatViewerVftable; struct BatViewerTargetData; struct BatViewerTargetDataSet; struct CMidgardID; struct BattleMsgData; struct BattleAttackInfo; enum class BattleAction : int; struct IBatViewer { const IBatViewerVftable* vftable; }; struct IBatViewerVftable { using Destructor = void(__thiscall*)(IBatViewer* thisptr, bool freeMemory); Destructor destructor; /** Called on receiving CCmdBattleChooseActionMsg to show battle actions. */ using Update = void(__thiscall*)(IBatViewer* thisptr, const BattleMsgData* battleMsgData, const CMidgardID* unitId, const Set<BattleAction>* actions, const BatViewerTargetDataSet* targetData); Update update; /** Called on receiving CCmdBattleResultMsg to show results of attack in battle. */ using ShowAttackEffect = void(__thiscall*)(IBatViewer* thisptr, const BattleMsgData* battleMsgData, const BattleAttackInfo** attackInfo, const LAttackClass* attackClass); ShowAttackEffect showAttackEffect; /** Called on receiving CCmdBattleEndMsg to hide battle window. */ using BattleEnd = void(__thiscall*)(IBatViewer* thisptr, const BattleMsgData* battleMsgData, const CMidgardID* a3); BattleEnd battleEnd; }; assert_vftable_size(IBatViewerVftable, 4); struct BatViewerTargetData { CMidgardID targetGroupId; UnitPositionMap targetPositions; }; assert_size(BatViewerTargetData, 32); struct BatViewerTargetDataSet { BatViewerTargetData attack; BatViewerTargetData items[2]; }; assert_size(BatViewerTargetDataSet, 96); } // namespace game #endif // BATVIEWER_H
2,862
C++
.h
72
32.263889
87
0.685539
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,208
lovechat.h
VladimirMakeev_D2ModdingToolset/mss32/include/lovechat.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2023 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef LOVECHAT_H #define LOVECHAT_H #include "d2assert.h" namespace game { struct TextMessage; struct ILoveChatVftable; // Yes, this name was used in original game source code struct ILoveChat { ILoveChatVftable* vftable; }; struct ILoveChatVftable { using Destructor = void(__thiscall*)(ILoveChat* thisptr, char flags); Destructor destructor; using Method1 = void(__thiscall*)(ILoveChat* thisptr, const TextMessage* chatMessage, const char* messageText, bool a4); Method1 method1; }; assert_vftable_size(ILoveChatVftable, 2); } // namespace game #endif // LOVECHAT_H
1,526
C++
.h
42
31.5
73
0.708277
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,209
usracialleader.h
VladimirMakeev_D2ModdingToolset/mss32/include/usracialleader.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef USRACIALLEADER_H #define USRACIALLEADER_H #include "usglobal.h" #include "usleaderimpl.h" #include "ussoldierimpl.h" #include "usstackleaderimpl.h" #include "usunitimpl.h" #include <cstddef> namespace game { /** * Represents leader unit template. * Leader unit in scenario is represented by CMidUnit * which accesses leader template data via CMidUnit::unitImpl pointer. * Leader units can learn abilities, use scrolls, wands, orbs and other items. * They are created and deleted along with the stacks. */ struct TUsRacialLeader : public IUsGlobal , public TUsUnitImpl , public TUsSoldierImpl , public TUsStackLeaderImpl , public TUsLeaderImpl { }; assert_size(TUsRacialLeader, 48); assert_offset(TUsRacialLeader, TUsRacialLeader::IUsGlobal::vftable, 0); assert_offset(TUsRacialLeader, TUsRacialLeader::TUsUnitImpl::vftable, 4); assert_offset(TUsRacialLeader, TUsRacialLeader::TUsSoldierImpl::vftable, 24); assert_offset(TUsRacialLeader, TUsRacialLeader::TUsStackLeaderImpl::vftable, 32); assert_offset(TUsRacialLeader, TUsRacialLeader::TUsLeaderImpl::vftable, 40); } // namespace game #endif // USRACIALLEADER_H
1,965
C++
.h
49
38.081633
81
0.78418
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,210
roomservercreation.h
VladimirMakeev_D2ModdingToolset/mss32/include/roomservercreation.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef ROOMSERVERCREATION_H #define ROOMSERVERCREATION_H namespace game { struct CMenuBase; } namespace hooks { void startRoomAndServerCreation(game::CMenuBase* menu, bool loadScenario); } #endif // ROOMSERVERCREATION_H
1,039
C++
.h
27
36.62963
74
0.77833
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,211
midgardstreamenv.h
VladimirMakeev_D2ModdingToolset/mss32/include/midgardstreamenv.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIDGARDSTREAMENV_H #define MIDGARDSTREAMENV_H #include "d2assert.h" #include "smartptr.h" namespace game { struct IMidgardStreamEnvVftable; struct IMidgardStreamCount; struct IMidgardStream; struct CMidgardID; struct IMidgardStreamEnv { IMidgardStreamEnvVftable* vftable; }; struct IMidgardStreamEnvVftable { using Destructor = void(__thiscall*)(IMidgardStreamEnv* thisptr, char flags); Destructor destructor; using Method1 = int(__thiscall*)(IMidgardStreamEnv* thisptr); Method1 method1; using GetBool = bool(__thiscall*)(const IMidgardStreamEnv* thisptr); GetBool writeMode; GetBool readMode; // See description of CMidServerLogicCoreData::isExpansionContent GetBool isExpansionContent; using GetError = const char*(__thiscall*)(const IMidgardStreamEnv* thisptr); GetError getError; using SetError = void(__thiscall*)(IMidgardStreamEnv* thisptr, const char* errorMessage); SetError setError; using GetStreamCount = IMidgardStreamCount*(__thiscall*)(IMidgardStreamEnv* thisptr); GetStreamCount getStreamCount; using FindStream = IMidgardStream*(__thiscall*)(IMidgardStreamEnv* thisptr, const char* fileName, SmartPointer* ptr); FindStream findStream; using OpenStream = void(__thiscall*)(IMidgardStreamEnv* thisptr, char* fileName, SmartPointer* ptr); OpenStream openStream; using CloseStream = void(__thiscall*)(IMidgardStreamEnv* thisptr, void* a1, void* a2, void* a3); CloseStream closeStream; using StreamObjectGuard = void(__thiscall*)(IMidgardStreamEnv* thisptr, const CMidgardID* objectId); StreamObjectGuard streamBeginObject; StreamObjectGuard streamEndObject; }; assert_vftable_size(IMidgardStreamEnvVftable, 13); } // namespace game #endif // MIDGARDSTREAMENV_H
2,849
C++
.h
66
36.530303
100
0.711079
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,212
ddstackgroup.h
VladimirMakeev_D2ModdingToolset/mss32/include/ddstackgroup.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DDSTACKGROUP_H #define DDSTACKGROUP_H #include "ddunitgroup.h" namespace game { struct ITask; struct CPhaseGame; struct CMidDragDropInterf; struct IResetStackExt; struct CDDStackGroupData { ITask* task; CPhaseGame* phaseGame; int unknown; CMidDragDropInterf* dragDropInterf; IResetStackExt* resetStackExt; IMidgardObjectMap* objectMap; CMidgardID id1; CMidgardID id2; char unknown3[4]; SmartPtr<IMqImage2> defaultCursorImage; SmartPtr<IMqImage2> noDragDropCursorImage; }; assert_size(CDDStackGroupData, 52); struct CDDStackGroup : public CDDUnitGroup { CDDStackGroupData* data; }; assert_size(CDDStackGroup, 20); } // namespace game #endif // DDSTACKGROUP_H
1,536
C++
.h
48
29.4375
72
0.775372
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,213
midobject.h
VladimirMakeev_D2ModdingToolset/mss32/include/midobject.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIDOBJECT_H #define MIDOBJECT_H #include "midgardid.h" namespace game { struct IMidObject; struct IMidObjectVftable { using Destructor = void(__thiscall*)(IMidObject* thisptr, char flags); Destructor destructor; }; template <typename T = IMidObjectVftable> struct IMidObjectT { const T* vftable; CMidgardID id; }; struct IMidObject : public IMidObjectT<> { }; } // namespace game #endif // MIDOBJECT_H
1,247
C++
.h
38
30.710526
74
0.7625
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,214
taskmanager.h
VladimirMakeev_D2ModdingToolset/mss32/include/taskmanager.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef TASKMANAGER_H #define TASKMANAGER_H #include "d2assert.h" namespace game { struct ITaskManagerHolder; struct CTaskManagerData { void* unknown; ITaskManagerHolder* taskManagerHolder; }; assert_size(CTaskManagerData, 8); struct CTaskManager { void* vftable; CTaskManagerData* data; }; assert_size(CTaskManager, 8); } // namespace game #endif // TASKMANAGER_H
1,203
C++
.h
37
30.351351
72
0.769896
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,215
hooks.h
VladimirMakeev_D2ModdingToolset/mss32/include/hooks.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef HOOKS_H #define HOOKS_H #include "attack.h" #include "attacktypepairvector.h" #include "d2string.h" #include "idlist.h" #include "targetset.h" #include <string> #include <utility> #include <vector> namespace game { struct DialogScriptData; struct CMenuNewSkirmishSingle; struct CMidDataCache2; struct GlobalData; struct CDBTable; struct LBuildingCategoryTable; struct CBuildingBranch; struct IUsSoldier; struct IMidgardObjectMap; struct BattleMsgData; struct CBatAttackGiveAttack; struct CBatAttackShatter; struct BattleAttackInfo; struct CMidPlayer; struct CEncLayoutSpell; struct CInterface; struct CEncParamBase; struct CDDCarryOverItems; struct IMidDropManager; struct CListBoxInterf; struct CPhaseGame; struct CMqPoint; struct os_exception; struct CMidUnit; struct CMidUnitGroup; struct CUnitGenerator; struct CMenuPhase; struct NetPlayerInfo; struct LRaceCategory; struct CMidgardScenarioMap; struct IMidgardStreamEnv; struct CMidStreamEnvFile; struct IUsUnit; struct TBuildingType; struct TUsUnitImpl; struct EditBoxData; enum class BuildingBranchNumber : int; enum class CanApplyPotionResult : int; enum class BuildingStatus : int; }; // namespace game namespace hooks { struct HookInfo { void* target; void* hook; void** original; }; using Hooks = std::vector<HookInfo>; /** Returns array of hooks to setup. */ Hooks getHooks(); Hooks getVftableHooks(); void respopupInitHooked(void); void* __fastcall toggleShowBannersInitHooked(void* thisptr, int /*%edx*/); bool __stdcall addPlayerUnitsToHireListHooked(game::CMidDataCache2* dataCache, const game::CMidgardID* playerId, const game::CMidgardID* a3, game::IdList* hireList); /** * Create TBuildingUnitUpgType objects for buildings from heal category. * This allows to assign temples as buildings required to hire units. */ void __stdcall createBuildingTypeHooked(const game::CDBTable* dbTable, void* a2, const game::GlobalData** globalData); game::LBuildingCategoryTable* __fastcall buildingCategoryTableCtorHooked( game::LBuildingCategoryTable* thisptr, int /*%edx*/, const char* globalsFolderPath, void* codeBaseEnvProxy); game::CBuildingBranch* __fastcall buildingBranchCtorHooked( game::CBuildingBranch* thisptr, int /*%edx*/, game::CPhaseGame* phaseGame, game::BuildingBranchNumber* branchNumber); int __stdcall chooseUnitLaneHooked(const game::IUsSoldier* soldier); bool __stdcall isTurnValidHooked(int turn); game::CMidgardID* __stdcall radioButtonIndexToPlayerIdHooked(game::CMidgardID* playerId, game::IMidgardObjectMap* objectMap, int index); bool __fastcall giveAttackCanPerformHooked(game::CBatAttackGiveAttack* thisptr, int /*%edx*/, game::IMidgardObjectMap* objectMap, game::BattleMsgData* battleMsgData, game::CMidgardID* unitId); bool __fastcall shatterCanPerformHooked(game::CBatAttackShatter* thisptr, int /*%edx*/, game::IMidgardObjectMap* objectMap, game::BattleMsgData* battleMsgData, game::CMidgardID* unitId); void __fastcall setUnitShatteredArmorHooked(game::BattleMsgData* thisptr, int /*%edx*/, const game::CMidgardID* unitId, int armor); void __fastcall shatterOnHitHooked(game::CBatAttackShatter* thisptr, int /*%edx*/, game::IMidgardObjectMap* objectMap, game::BattleMsgData* battleMsgData, game::CMidgardID* unitId, game::BattleAttackInfo** attackInfo); bool __fastcall shatterCanMissHooked(game::CBatAttackShatter* thisptr, int /*%edx*/, game::BattleMsgData* battleMsgData, game::CMidgardID* id); bool __stdcall buildLordSpecificBuildingsHooked(game::IMidgardObjectMap* objectMap, const game::NetPlayerInfo* playerInfo, int); game::CEncLayoutSpell* __fastcall encLayoutSpellCtorHooked(game::CEncLayoutSpell* thisptr, int /*%edx*/, game::IMidgardObjectMap* objectMap, game::CInterface* interf, void* a2, game::CMidgardID* spellId, game::CEncParamBase* encParam, const game::CMidgardID* playerId); int __stdcall countStacksOnMapHooked(game::IMidgardObjectMap* objectMap); game::CDDCarryOverItems* __fastcall carryOverItemsCtorHooked(game::CDDCarryOverItems* thisptr, int /*%edx*/, game::IMidDropManager* dropManager, game::CListBoxInterf* listBox, game::CPhaseGame* phaseGame, int carryOverItemsMax); void __fastcall markMapPositionHooked(void* thisptr, int /*%edx*/, game::CMqPoint* position); int __stdcall computeDamageHooked(const game::IMidgardObjectMap* objectMap, const game::BattleMsgData* battleMsgData, const game::IAttack* attack, const game::CMidgardID* attackerUnitId, const game::CMidgardID* targetUnitId, bool computeCriticalHit, int* attackDamage, int* criticalHitDamage); void __stdcall getAttackPowerHooked(int* power, const game::IAttack* attack, const game::IMidgardObjectMap* objectMap, const game::CMidgardID* unitId, const game::BattleMsgData* battleMsgData); bool __stdcall attackShouldMissHooked(const int* power); int __stdcall getUnitHealAttackNumberHooked(const game::IMidgardObjectMap* objectMap, const game::CMidgardID* unitId); int __stdcall getAttackQtyDamageOrHealHooked(const game::IAttack* attack, int damageMax); void __stdcall afterBattleTurnHooked(game::BattleMsgData* battleMsgData, const game::CMidgardID* unitId, const game::CMidgardID* nextUnitId); void __stdcall beforeBattleTurnHooked(game::BattleMsgData* battleMsgData, game::IMidgardObjectMap* objectMap, const game::CMidgardID* unitId); void __stdcall throwExceptionHooked(const game::os_exception* thisptr, const void* throwInfo); int __stdcall computeUnitEffectiveHpForAiHooked(const game::IMidgardObjectMap* objectMap, const game::CMidUnit* unit, const game::BattleMsgData* battleMsgData); void __stdcall applyDynUpgradeToAttackDataHooked(const game::CMidgardID* unitImplId, game::CUnitGenerator* unitGenerator, int unitLevel, game::IdType dynUpgradeType, const game::CMidgardID* altAttackId, game::CAttackData* attackData); void __stdcall getUnitAttacksHooked(const game::IMidgardObjectMap* objectMap, const game::CMidgardID* unitId, game::AttackTypePairVector* value, bool checkAltAttack); bool __stdcall isUnitUseAdditionalAnimationHooked(const game::CMidgardID* unitId); bool __stdcall shouldAddUnitToHireHooked(const game::CMidPlayer* player, game::CPhaseGame* phaseGame, const game::CMidgardID* unitImplId); bool __stdcall enableUnitInHireListUiHooked(const game::CMidPlayer* player, game::CPhaseGame* phaseGame, const game::CMidgardID* unitImplId); void __stdcall getCityPreviewLargeImageNamesHooked(game::List<game::String>* imageNames, const void* cityFF, const game::LRaceCategory* race, int cityTier); void __stdcall getCityIconImageNamesHooked(game::List<game::String>* imageNames, const void* iconsFF, const game::CMidgardID* fortificationId, const game::IMidgardObjectMap* objectMap); bool __fastcall checkMapObjectsHooked(game::CMidgardScenarioMap* scenarioMap, int /*%edx*/); int __stdcall loadScenarioMapHooked(int a1, game::CMidStreamEnvFile* streamEnv, game::CMidgardScenarioMap* scenarioMap); bool __fastcall scenarioMapStreamHooked(game::CMidgardScenarioMap* scenarioMap, int /*%edx*/, game::IMidgardStreamEnv* streamEnv); void __stdcall getStackFortRuinGroupForChangeHooked(game::IMidgardObjectMap* objectMap, const game::CMidgardID* objectId, game::CMidUnitGroup** result); game::CanApplyPotionResult __stdcall canApplyPotionToUnitHooked( const game::IMidgardObjectMap* objectMap, const game::CMidgardID* unitId, const game::CMidgardID* groupId, const game::CMidgardID* itemId); void __stdcall getUnitRequiredBuildingsHooked(const game::IMidgardObjectMap* objectMap, const game::CMidgardID* playerId, const game::IUsUnit* unitImpl, game::Vector<game::TBuildingType*>* result); const game::TUsUnitImpl* __stdcall getUpgradeUnitImplCheckXpHooked( const game::IMidgardObjectMap* objectMap, const game::CMidUnit* unit); bool __stdcall changeUnitXpCheckUpgradeHooked(game::IMidgardObjectMap* objectMap, const game::CMidgardID* playerId, const game::CMidgardID* unitId, int amount); bool __stdcall isUnitTierMaxHooked(const game::IMidgardObjectMap* objectMap, const game::CMidgardID* playerId, const game::CMidgardID* unitId); bool __stdcall isUnitLevelNotMaxHooked(const game::IMidgardObjectMap* objectMap, const game::CMidgardID* playerId, const game::CMidgardID* unitId); bool __stdcall isUnitUpgradePendingHooked(const game::CMidgardID* unitId, const game::IMidgardObjectMap* objectMap); bool __fastcall editBoxIsCharValidHooked(const game::EditBoxData* thisptr, int /*%edx*/, char ch); game::BuildingStatus __stdcall getBuildingStatusHooked(const game::IMidgardObjectMap* objectMap, const game::CMidgardID* playerId, const game::CMidgardID* buildingId, bool ignoreBuildTurnAndCost); } // namespace hooks #endif // HOOKS_H
13,748
C++
.h
244
37.262295
98
0.55934
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,216
textids.h
VladimirMakeev_D2ModdingToolset/mss32/include/textids.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef TEXTIDS_H #define TEXTIDS_H #include <string> namespace hooks { struct TextIds { struct Interf { std::string sellAllValuables; std::string sellAllItems; std::string critHitAttack; std::string critHitDamage; std::string ratedDamage; std::string ratedDamageEqual; std::string ratedDamageSeparator; std::string splitDamage; std::string modifiedValue; std::string modifiedNumber; std::string modifiedNumberTotal; std::string positiveBonusNumber; std::string negativeBonusNumber; std::string modifiersCaption; std::string modifiersEmpty; std::string modifierDescription; std::string nativeModifierDescription; std::string drainDescription; std::string drainEffect; std::string overflowAttack; std::string overflowText; std::string dynamicUpgradeLevel; std::string dynamicUpgradeValues; std::string durationDescription; std::string durationText; std::string instantDurationText; std::string randomDurationText; std::string singleTurnDurationText; std::string wholeBattleDurationText; std::string infiniteAttack; std::string infiniteText; std::string removedAttackWard; } interf; struct Events { struct Conditions { struct OwnResource { std::string tooMany; std::string mutuallyExclusive; } ownResource; struct GameMode { std::string tooMany; std::string single; std::string hotseat; std::string online; } gameMode; struct PlayerType { std::string tooMany; std::string human; std::string ai; } playerType; struct VariableCmp { std::string equal; std::string notEqual; std::string greater; std::string greaterEqual; std::string less; std::string lessEqual; } variableCmp; } conditions; } events; struct Lobby { std::string serverName; std::string serverNotResponding; std::string connectAttemptFailed; std::string serverIsFull; std::string computeHashFailed; std::string requestHashCheckFailed; std::string wrongHash; std::string wrongRoomPassword; } lobby; struct ScenarioGenerator { std::string description; std::string wrongGameData; std::string generationError; std::string limitExceeded; } rsg; }; const TextIds& textIds(); } // namespace hooks #endif // TEXTIDS_H
3,704
C++
.h
114
24.140351
72
0.632653
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,217
nativelandmarkinfo.h
VladimirMakeev_D2ModdingToolset/mss32/include/nativelandmarkinfo.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2023 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef NATIVELANDMARKINFO_H #define NATIVELANDMARKINFO_H #include "landmarkinfo.h" #include "position.h" #include "rsgid.h" namespace hooks { class NativeLandmarkInfo final : public rsg::LandmarkInfo { public: NativeLandmarkInfo(const rsg::CMidgardID& landmarkId, const rsg::Position& size, rsg::LandmarkType type, bool mountain) : landmarkId{landmarkId} , size{size} , landmarkType{type} , mountain{mountain} { } ~NativeLandmarkInfo() override = default; const rsg::CMidgardID& getLandmarkId() const override { return landmarkId; } rsg::LandmarkType getLandmarkType() const override { return landmarkType; } const rsg::Position& getSize() const override { return size; } bool isMountain() const override { return mountain; } private: rsg::CMidgardID landmarkId; rsg::Position size{1, 1}; rsg::LandmarkType landmarkType{rsg::LandmarkType::Misc}; bool mountain{}; }; } // namespace hooks #endif // NATIVELANDMARKINFO_H
1,952
C++
.h
61
27.098361
72
0.698776
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,218
midanim2.h
VladimirMakeev_D2ModdingToolset/mss32/include/midanim2.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIDANIM2_H #define MIDANIM2_H #include "d2assert.h" namespace game { struct IMidAnim2Vftable; struct IMidAnim2 { IMidAnim2Vftable* vftable; }; struct IMidAnim2Vftable { using Destructor = void(__thiscall*)(IMidAnim2* thisptr, char flags); Destructor destructor; using ChangeFrame = void(__thiscall*)(IMidAnim2* thisptr); ChangeFrame changeFrame; ChangeFrame changeFrame2; using Hide = void(__thiscall*)(IMidAnim2* thisptr); Hide hide; using IsOver = bool(__thiscall*)(const IMidAnim2* thisptr); IsOver isOver; using GetSmoothScroll = bool(__thiscall*)(const IMidAnim2* thisptr); GetSmoothScroll getSmoothScroll; }; assert_vftable_size(IMidAnim2Vftable, 6); } // namespace game #endif // MIDANIM2_H
1,579
C++
.h
44
33.113636
73
0.756242
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,219
mideveffecthooks.h
VladimirMakeev_D2ModdingToolset/mss32/include/mideveffecthooks.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIDEVEFFECTHOOKS_H #define MIDEVEFFECTHOOKS_H namespace game { struct CMidgardID; struct CMidEvEffect; struct LEventEffectCategory; struct String; struct IMidgardObjectMap; } // namespace game namespace hooks { game::CMidEvEffect* __stdcall createEventEffectFromCategoryHooked( const game::CMidgardID* eventId, const game::LEventEffectCategory* category); void __stdcall eventEffectGetInfoStringHooked(game::String* info, const game::IMidgardObjectMap* objectMap, const game::CMidEvEffect* eventEffect); void __stdcall eventEffectGetDescriptionHooked(game::String* description, const game::LEventEffectCategory* category); void __stdcall eventEffectGetBriefHooked(game::String* brief, const game::LEventEffectCategory* category); } // namespace hooks #endif // MIDEVEFFECTHOOKS_H
1,797
C++
.h
40
38.575
91
0.716247
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,220
terraintile.h
VladimirMakeev_D2ModdingToolset/mss32/include/terraintile.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2022 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef TERRAINTILE_H #define TERRAINTILE_H #include "isoground2.h" namespace game { struct CTerrainTile : public IIsoGround2 { void*** imageData; }; } // namespace game #endif // TERRAINTILE_H
1,016
C++
.h
28
34.321429
72
0.762729
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,221
attacktypepairvector.h
VladimirMakeev_D2ModdingToolset/mss32/include/attacktypepairvector.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2021 Stanislav Egorov. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef ATTACKTYPEPAIRVECTOR_H #define ATTACKTYPEPAIRVECTOR_H #include "d2pair.h" #include "d2vector.h" namespace game { struct IAttack; enum class AttackType : int { Primary, Secondary, Item, }; using AttackTypePair = Pair<IAttack*, AttackType>; using AttackTypePairVector = Vector<AttackTypePair>; namespace AttackTypePairVectorApi { struct Api { using PushBack = void(__thiscall*)(AttackTypePairVector* thisptr, const AttackTypePair* value); PushBack pushBack; }; Api& get(); } // namespace AttackTypePairVectorApi } // namespace game #endif // ATTACKTYPEPAIRVECTOR_H
1,415
C++
.h
42
31.547619
99
0.772394
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,542,222
d2string.h
VladimirMakeev_D2ModdingToolset/mss32/include/d2string.h
/* * This file is part of the modding toolset for Disciples 2. * (https://github.com/VladimirMakeev/D2ModdingToolset) * Copyright (C) 2020 Vladimir Makeev. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef D2STRING_H #define D2STRING_H #include "d2assert.h" #include <cstdint> namespace game { /** Implementation of std::string used in game. */ struct String { std::uint32_t length; std::uint32_t lengthAllocated; char* string; void* allocator; }; assert_size(String, 16); namespace StringApi { struct Api { /** * Initializes existing String using C-style string. * Allocates memory and copies string data. * @param[in] thisptr pointer to already existing String. * @param[in] string pointer to C-style string to copy. * @returns thisptr. */ using InitFromString = String*(__thiscall*)(String* thisptr, const char* string); InitFromString initFromString; /** * Initializes existing String using C-style string and length. * Allocates memory and copies length characters of string. * @param[in] thisptr pointer to already existing String. * @param[in] string pointer to C-style string to copy. * @param length number of characters to copy. * @returns thisptr. */ using InitFromStringN = String*(__thiscall*)(String* thisptr, const char* string, std::uint32_t length); InitFromStringN initFromStringN; /** Frees memory allocated for thisptr->string. */ using Free = int(__thiscall*)(String* thisptr); Free free; /** * Appends string of specified length. * @param[in] thisptr pointer to existing String to append to. * @param[in] string pointer to C-style string to append. * @param length number of characters to append. * @returns thisptr->string. */ using Append = char*(__thiscall*)(String* thisptr, const char* string, std::uint32_t length); Append append; /** * Appends count number of characters ch to String. * @param[in] thisptr pointer to existing String to append to. * @param ch character to append. * @param count number of times to append. * @returns thisptr->string. */ using AppendChar = char*(__thiscall*)(String* thisptr, char ch, std::uint32_t count); AppendChar appendChar; /** Returns a pointer to a null-terminated character array with data equivalent to those stored * in the string. */ using CStr = const char*(__thiscall*)(const String* thisptr); CStr cStr; }; /** Returns String functions according to determined version of the game. */ Api& get(); } // namespace StringApi } // namespace game #endif // D2STRING_H
3,384
C++
.h
87
33.885057
99
0.689119
VladimirMakeev/D2ModdingToolset
32
13
15
GPL-3.0
9/20/2024, 10:45:25 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false