Mercurial > might-and-magic-trilogy
diff Spells.cpp @ 0:8b8875f5b359
Initial commit
author | Nomad |
---|---|
date | Fri, 05 Oct 2012 16:07:14 +0200 |
parents | |
children | 8be5293b6b33 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Spells.cpp Fri Oct 05 16:07:14 2012 +0200 @@ -0,0 +1,313 @@ +#include <stdlib.h> + +#include "Spells.h" +#include "Overlays.h" +#include "Allocator.h" +#include "LOD.h" +#include "stru123.h" + +#include "mm7_data.h" + + + + + +struct SpellStats *pSpellStats; + + +stru324_spell stru_4E3ACC[102]; +SpellData pSpellDatas[95]; + + + + + + +//----- (0042EB31) -------------------------------------------------------- +bool SpellBuff::NotExpired() +{ + bool result; // eax@1 + + result = 0; + if ( (signed __int64)this->uExpireTime > 0 ) + result = 1; + return result; +} + + +//----- (00458585) -------------------------------------------------------- +void SpellBuff::Reset() +{ + SpellBuff *v1; // esi@1 + unsigned __int16 v2; // ax@1 + + v1 = this; + v2 = this->uOverlayID; + this->uSkill = 0; + this->uPower = 0; + this->uExpireTime = 0i64; + this->uCaster = 0; + this->uFlags = 0; + if ( v2 ) + { + ((OtherOverlay *)&stru_5E4C90.field_4B[20 * v2 + 105])->Reset(); + pOtherOverlayList->field_3EC = 1; + v1->uOverlayID = 0; + } +} + +//----- (004585CA) -------------------------------------------------------- +signed int SpellBuff::_4585CA(__int64 a2) +{ + signed int result; // eax@3 + + if ( this->uExpireTime && (signed __int64)this->uExpireTime < a2 ) + { + this->uExpireTime = 0i64; + this->uPower = 0; + this->uSkill = 0; + this->uOverlayID = 0; + result = 1; + } + else + { + result = 0; + } + return result; +} + +//----- (004584E0) -------------------------------------------------------- +signed int SpellBuff::Apply(unsigned __int64 uExpireTime, unsigned __int16 uSkillLevel, unsigned __int16 uPower, int a5, unsigned __int8 a6) +{ + SpellBuff *v6; // esi@1 + signed int result; // eax@3 + int v8; // eax@4 + + v6 = this; + if ( this->uExpireTime && (signed __int64)uExpireTime < (signed __int64)this->uExpireTime ) + { + result = 0; + } + else + { + this->uSkill = uSkillLevel; + this->uPower = uPower; + LOWORD(v8) = this->uOverlayID; + this->uExpireTime = uExpireTime; + if ( (short)v8 ) + { + v8 = (unsigned __int16)v8; + if ( (unsigned __int16)v8 != a5 ) + { + ((OtherOverlay *)&stru_5E4C90.field_4B[20 * v8 + 105])->Reset(); + pOtherOverlayList->field_3EC = 1; + v6->uOverlayID = 0; + } + } + v6->uOverlayID = a5; + v6->uCaster = a6; + result = 1; + } + return result; +} + +//----- (0045384A) -------------------------------------------------------- +void SpellStats::Initialize() +{ + SpellStats *v1; // esi@1 + const char *v2; // ebp@3 + char *v3; // edi@3 + signed int v4; // ebx@4 + char *v5; // esi@4 + char v6; // cl@5 + int v7; // eax@5 + size_t v8; // ebp@40 + int v9; // eax@41 + int v10; // eax@42 + int v11; // eax@43 + char *v12; // [sp+10h] [bp-10h]@3 + signed int v13; // [sp+14h] [bp-Ch]@4 + signed int v14; // [sp+18h] [bp-8h]@3 + int v15; // [sp+1Ch] [bp-4h]@9 + + v1 = this; + if ( pSpellsTXT_Raw ) + pAllocator->FreeChunk(pSpellsTXT_Raw); + pSpellsTXT_Raw = 0; + v2 = "\r"; + pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0); + strtok(pSpellsTXT_Raw, "\r"); + strtok(0, "\r"); + v14 = 1; + v12 = (char *)&pSpellDatas[1].field_10; + v3 = (char *)&v1->pInfos[1].uSchool; + do + { + v4 = 0; + v5 = strtok(0, v2) + 1; + v13 = 0; + do + { + v6 = *v5; + v7 = 0; + while ( v6 != 9 && v6 ) + { + ++v7; + v6 = v5[v7]; + } + v15 = (int)&v5[v7]; + if ( !v5[v7] ) + v13 = 1; + v5[v7] = 0; + if ( v7 ) + { + switch ( v4 ) + { + case 2: + *((char **)v3 - 7) = RemoveQuotes(v5); + break; + case 3: + *v3 = 4; + if ( _strcmpi("fire", v5) ) + { + if ( _strcmpi("air", v5) ) + { + if ( _strcmpi("water", v5) ) + { + if ( _strcmpi("earth", v5) ) + { + if ( _strcmpi("spirit", v5) ) + { + if ( _strcmpi("mind", v5) ) + { + if ( _strcmpi("body", v5) ) + { + if ( _strcmpi("light", v5) ) + { + if ( _strcmpi("dark", v5) ) + { + if ( !_strcmpi("magic", v5) ) + *v3 = 5; + } + else + { + *v3 = 10; + } + } + else + { + *v3 = 9; + } + } + else + { + *v3 = 8; + } + } + else + { + *v3 = 7; + } + } + else + { + *v3 = 6; + } + } + else + { + *v3 = 3; + } + } + else + { + *v3 = 2; + } + } + else + { + *v3 = 1; + } + } + else + { + *v3 = 0; + } + break; + case 4: + *((char **)v3 - 6) = RemoveQuotes(v5); + break; + case 5: + *((char **)v3 - 5) = RemoveQuotes(v5); + break; + case 6: + *((char **)v3 - 4) = RemoveQuotes(v5); + break; + case 7: + *((char **)v3 - 3) = RemoveQuotes(v5); + break; + case 8: + *((char **)v3 - 2) = RemoveQuotes(v5); + break; + case 9: + *((char **)v3 - 1) = RemoveQuotes(v5); + break; + case 10: + v4 = 0; + v8 = strlen(v5); + if ( (signed int)v8 > 0 ) + { + do + { + v9 = tolower((unsigned __int8)v5[v4]) - 99; + if ( v9 ) + { + v10 = v9 - 2; + if ( v10 ) + { + v11 = v10 - 8; + if ( v11 ) + { + if ( v11 == 11 ) + *v12 |= 8u; + } + else + { + *v12 |= 1u; + } + } + else + { + *v12 |= 2u; + } + } + else + { + *v12 |= 4u; + } + ++v4; + } + while ( v4 < (signed int)v8 ); + } + v2 = "\r"; + break; + default: + break; + } + } + else + { + v13 = 1; + } + ++v4; + v5 = (char *)(v15 + 1); + } + while ( v4 - 1 <= 10 && !v13 ); + if ( !(v14 % 11) ) + strtok(0, v2); + v12 += 20; + ++v14; + v3 += 36; + } + while ( (signed int)v12 <= (signed int)&pSpellDatas[90].field_12 ); +} \ No newline at end of file