Skip to content

Commit

Permalink
Added spell_ext.mes and spell_enums_ext.mes instead of directly overr…
Browse files Browse the repository at this point in the history
…iding spell.mes and spell_enum.mes
  • Loading branch information
DudeMcDude committed Jun 3, 2016
1 parent b48ab55 commit d510212
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
3 changes: 2 additions & 1 deletion TemplePlus/gamesystems/legacysystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,15 @@ const std::string &FeatSystem::GetName() const {

SpellSystem::SpellSystem(const GameSystemConf &config) {
auto startup = temple::GetPointer<int(const GameSystemConf*)>(0x1007b740);
mesFuncs.Open("tprules\\spell_enums_ext.mes", &spellSys.spellEnumsExt);
if (!startup(&config)) {
throw TempleException("Unable to initialize game system Spell");
}
spellSys.Init(config);
}
SpellSystem::~SpellSystem() {
auto shutdown = temple::GetPointer<void()>(0x100791d0);
mesFuncs.Close(spellSys.spellEnumsExt);
mesFuncs.Close(spellSys.spellMesExt);
shutdown();

}
Expand Down
22 changes: 17 additions & 5 deletions TemplePlus/spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ class SpellFuncReplacements : public TempleFix {
replaceFunction<const char*(__cdecl)(uint32_t)>(0x10077970, [](uint32_t spellEnum){
return spellSys.GetSpellEnumTAG(spellEnum);
});
// GetSpellMesline
replaceFunction<const char*(__cdecl)(uint32_t)>(0x1007AD80, [](uint32_t spellEnum) {
return spellSys.GetSpellMesline(spellEnum);
});



// SpellPacketSetCasterLevel
replaceFunction<void(__cdecl)(SpellPacketBody*)>(0x10079B70, [](SpellPacketBody* spellPkt){
Expand Down Expand Up @@ -398,6 +404,11 @@ SpellMapTransferInfo::SpellMapTransferInfo()

}

void LegacySpellSystem::Init(const GameSystemConf& conf){
mesFuncs.Open("tprules\\spell_enums_ext.mes", &spellSys.spellEnumsExt);
mesFuncs.Open("mes\\spell_ext.mes", &spellMesExt);
}

uint32_t LegacySpellSystem::spellRegistryCopy(uint32_t spellEnum, SpellEntry* spellEntry)
{
return spellEntryRegistry.copy(spellEnum, spellEntry);
Expand All @@ -418,10 +429,11 @@ int LegacySpellSystem::ParseSpellSpecString(SpellStoreData* spell, char* spellSt
return addresses.ParseSpellSpecString(spell, spellString);
}

const char* LegacySpellSystem::GetSpellMesline(uint32_t lineNumber) const
{
MesLine mesLine;
mesLine.key = lineNumber;
const char* LegacySpellSystem::GetSpellMesline(uint32_t lineNumber) const{

MesLine mesLine(lineNumber);
if (mesFuncs.GetLine(spellMesExt, &mesLine))
return mesLine.value;
mesFuncs.GetLine_Safe(*spellMes, &mesLine);
return mesLine.value;
}
Expand Down Expand Up @@ -725,7 +737,7 @@ SpellMapTransferInfo LegacySpellSystem::SaveSpellForTeleport(const SpellPacket&

auto spellEnum = data.spellPktBody.spellEnum;
Expects(spellEnum > 0 && spellEnum < 10000); // keeping a margin for now because co8 has messed with this a bit
if (spellEnum > SPELL_ENUM_MAX) {
if (spellEnum > SPELL_ENUM_MAX_EXPANDED) {
logger->warn("Spell enum beyond expected range encountered: {}", spellEnum);
}

Expand Down
5 changes: 5 additions & 0 deletions TemplePlus/spell.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#include "tig\tig_mes.h"
#include "spell_structs.h"
#include "tio/tio.h"

//#include "ui/ui_picker.h"

struct GameSystemConf;
class TioOutputStream;
struct PickerArgs;

Expand Down Expand Up @@ -152,8 +154,10 @@ struct LegacySpellSystem : temple::AddressTable
MesHandle * spellEnumMesHandle;
MesHandle spellEnumsExt;
MesHandle * spellMes;
MesHandle spellMesExt;
MesHandle * spellsRadialMenuOptionsMes;
std::vector<SpellMapTransferInfo> spellMapTransInfo;
void Init(const GameSystemConf& conf);

uint32_t spellRegistryCopy(uint32_t spellEnum, SpellEntry* spellEntry);
uint32_t ConfigSpellTargetting(PickerArgs* pickerArgs, SpellPacketBody* spellPacketBody);
Expand All @@ -162,6 +166,7 @@ struct LegacySpellSystem : temple::AddressTable

const char* GetSpellMesline(uint32_t line) const;
bool CheckAbilityScoreReqForSpell(objHndl handle, uint32_t spellEnum, int statBeingRaised) const;

static const char* GetSpellEnumTAG(uint32_t spellEnum);
const char* GetSpellName(uint32_t spellEnum) const;

Expand Down
Binary file modified tpdata/co8fixes.dat
Binary file not shown.
Binary file modified tpdata/tpgamefiles.dat
Binary file not shown.
5 changes: 5 additions & 0 deletions tpdata/tprules/spell_enums_ext.mes
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
{3000}{class_ability_bardic_suggestion}

{8000}{Bardic Suggestion}

{20735}{TAG_HEZROU_STENCH}
{23000}{}//class_ability_bardic_suggestion

0 comments on commit d510212

Please sign in to comment.