Mercurial > mm7
changeset 1826:bdac32c645c5
Changing arrays in class Player to std::array
author | Grumpy7 |
---|---|
date | Wed, 09 Oct 2013 09:08:15 +0200 |
parents | 23deb6b09c8c |
children | 0c75c3e7e436 |
files | Events.cpp Game.cpp Items.cpp Party.cpp Player.cpp Player.h UI/UiGame.cpp mm7_2.cpp mm7_4.cpp mm7_6.cpp |
diffstat | 10 files changed, 42 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/Events.cpp Wed Oct 09 08:39:49 2013 +0200 +++ b/Events.cpp Wed Oct 09 09:08:15 2013 +0200 @@ -953,7 +953,7 @@ v4 = v124; break; } - v67 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix; + v67 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix.data(); for ( v65 = 0; v65 < 126; ++v65 ) { if ( (int)&pPlayers[uActiveCharacter]->pInventoryItemList[v67] == pValue ) @@ -980,7 +980,7 @@ } for (int i = 1; i < 5; i++) { - v72 = (int)pPlayers[i]->pInventoryMatrix; + v72 = (int)pPlayers[i]->pInventoryMatrix.data(); for ( int v71 = 0; v71 < 126; ++v71 ) { if ( (int)&pPlayers[i]->pInventoryItemList[v72] == pValue )
--- a/Game.cpp Wed Oct 09 08:39:49 2013 +0200 +++ b/Game.cpp Wed Oct 09 09:08:15 2013 +0200 @@ -473,8 +473,8 @@ //do for(int i=0; i<4; ++i) { - memset(pParty->pPlayers[i].pConditions, 0, 0xA0u);//(pConditions, 0, 160) - memset(pParty->pPlayers[i].pPlayerBuffs, 0, 0x180u);//(pPlayerBuffs[0], 0, 384) + memset(pParty->pPlayers[i].pConditions.data(), 0, 0xA0u);//(pConditions, 0, 160) + memset(pParty->pPlayers[i].pPlayerBuffs.data(), 0, 0x180u);//(pPlayerBuffs[0], 0, 384) //*pHealth = 1; pParty->pPlayers[i].sHealth=1; //pHealth += 1743; //6CF
--- a/Items.cpp Wed Oct 09 08:39:49 2013 +0200 +++ b/Items.cpp Wed Oct 09 09:08:15 2013 +0200 @@ -2215,11 +2215,11 @@ itemId = ITEM_ARTIFACT_LEAGUE_BOOTS; NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, 40); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_WATER, 0, &Player::skillWater); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_WATER, 0, &Player::skillWater); itemId = ITEM_ARTIFACT_RULERS_RING; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_MIND, 0, &Player::skillMind); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_DARK, 0, &Player::skillDark); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_MIND, 0, &Player::skillMind); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_DARK, 0, &Player::skillDark); itemId = ITEM_RELIC_MASH; NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 150); @@ -2228,7 +2228,7 @@ NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, -40); itemId = ITEM_RELIC_ETHRICS_STAFF; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_DARK, 0, &Player::skillDark); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_DARK, 0, &Player::skillDark); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_MEDITATION, 15); itemId = ITEM_RELIC_HARECS_LEATHER; @@ -2251,7 +2251,7 @@ NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_AC_BONUS, -15); itemId = ITEM_RELIC_GLORY_SHIELD; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0, &Player::skillSpirit); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0, &Player::skillSpirit); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_SHIELD, 5); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_MIND, -10); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_BODY, -10); @@ -2261,7 +2261,7 @@ NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_EARTH, -30); itemId = ITEM_RELIC_TALEDONS_HELM; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_LIGHT, 0, &Player::skillLight); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_LIGHT, 0, &Player::skillLight); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 15); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 15); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_LUCK, -40); @@ -2271,7 +2271,7 @@ NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ENDURANCE, -50); itemId = ITEM_RELIC_PHYNAXIAN_CROWN; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_FIRE, 0, &Player::skillFire); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_FIRE, 0, &Player::skillFire); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_WATER, +50); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 30); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_AC_BONUS, -20); @@ -2296,12 +2296,12 @@ NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_AC_BONUS, -25); itemId = ITEM_RELIC_JUSTICE; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_MIND, 0, &Player::skillMind); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_BODY, 0, &Player::skillBody); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_MIND, 0, &Player::skillMind); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_BODY, 0, &Player::skillBody); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, -40); itemId = ITEM_RELIC_MEKORIGS_HAMMER; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0, &Player::skillSpirit); + NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0, &Player::skillSpirit); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 75); NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, -50);
--- a/Party.cpp Wed Oct 09 08:39:49 2013 +0200 +++ b/Party.cpp Wed Oct 09 09:08:15 2013 +0200 @@ -254,7 +254,7 @@ while ( v2 <= &pParty->pPlayers[3] ) { v3 = 0; - v4 = v2->pInventoryItemList; + v4 = v2->pInventoryItemList.data(); do { if ( v4->uItemID == uItemID ) @@ -564,7 +564,7 @@ //v10 = uSkillIdx - 35 < 0; } //while (uSkillIdx < 36); - pItems = pCharacter->pInventoryItemList; + pItems = pCharacter->pInventoryItemList.data(); //v13 = 138; for (int i = 0; i < 138; i++) { @@ -905,7 +905,7 @@ v6 = 4; do { - v3 = v2->pPlayerBuffs; + v3 = v2->pPlayerBuffs.data(); v7 = 24; do { @@ -1100,7 +1100,7 @@ if ( pPlayer->classType == PLAYER_CLASS_LICH ) { have_vessels_soul = false; - v7 = pPlayer->pInventoryItemList;//[0].field_1A; + v7 = pPlayer->pInventoryItemList.data();//[0].field_1A; for ( uint i = 138; i; --i ) { if ( v7->uItemID == 601 && (unsigned __int8)v7->uHolderPlayer == pPlayerID + 1 )
--- a/Player.cpp Wed Oct 09 08:39:49 2013 +0200 +++ b/Player.cpp Wed Oct 09 09:08:15 2013 +0200 @@ -1240,7 +1240,7 @@ Player::Player() { memset(&pEquipment, 0, sizeof(PlayerEquipment)); - memset(pInventoryMatrix, 0, 126 * sizeof(int)); + memset(pInventoryMatrix.data(), 0, 126 * sizeof(int)); for (uint i = 0; i < 126; ++i) pInventoryItemList[i].Reset(); for (uint i = 0; i < 12; ++i) @@ -1260,7 +1260,7 @@ pName[0] = 0; uCurrentFace = 0; uVoiceID = 0; - memset(pConditions, 0, 20 * sizeof(__int64)); + memset(pConditions.data(), 0, 20 * sizeof(__int64)); field_BB = 0; @@ -1308,7 +1308,7 @@ _mana_related = 0; uQuickSpell = 0; - memset(pInstalledBeacons, 0, 5 * sizeof(LloydBeacon)); + memset(pInstalledBeacons.data(), 0, 5 * sizeof(LloydBeacon)); _some_attack_bonus = 0; field_1A91 = 0; @@ -3964,7 +3964,7 @@ uLevel = 1; uExperience = 251 + rand() % 100; uBirthYear = 1147 - rand() % 6; - memset(pActiveSkills, 0, sizeof(pActiveSkills)); + memset(pActiveSkills.data(), 0, sizeof(pActiveSkills)); memset(_achieved_awards_bits, 0, 64); memset(&spellbook, 0, sizeof(PlayerSpells)); @@ -7977,4 +7977,5 @@ else if ( this == pPlayers[4] ) uPlayerIdx = 3; Error("Unexpected player pointer"); + return uPlayerIdx; } \ No newline at end of file
--- a/Player.h Wed Oct 09 08:39:49 2013 +0200 +++ b/Player.h Wed Oct 09 09:08:15 2013 +0200 @@ -327,7 +327,7 @@ #pragma pack(push, 1) struct PlayerSpellbookChapter { - char bIsSpellAvailable[11]; + std::array<char, 11> bIsSpellAvailable; }; #pragma pack(pop) @@ -351,12 +351,12 @@ }; struct { - PlayerSpellbookChapter pChapters[9]; + std::array<PlayerSpellbookChapter, 9> pChapters; char _pad_1; }; struct { - char bHaveSpell[99]; + std::array<char, 99> bHaveSpell; char _pad_1; }; }; @@ -382,14 +382,14 @@ unsigned int uGlove; unsigned int uBoot; unsigned int uAmulet; - unsigned int uRings[6]; + std::array<unsigned int, 6> uRings; //unsigned int field_2C; //unsigned int field_30; //unsigned int field_34; //unsigned int field_38; //unsigned int field_3C; }; - unsigned int pIndices[16]; + std::array<unsigned int, 16> pIndices; }; }; #pragma pack(pop) @@ -670,7 +670,7 @@ ItemGen* GetItem(unsigned int PlayerEquipment::* itemPos); int GetPlayerIndex(); - __int64 pConditions[20]; + std::array<__int64, 20> pConditions; unsigned __int64 uExperience; char pName[16]; PLAYER_SEX uSex; @@ -747,7 +747,7 @@ unsigned __int16 skillAlchemy; unsigned __int16 skillLearning; }; - unsigned __int16 pActiveSkills[37]; + std::array<unsigned __int16, 37> pActiveSkills; }; unsigned char _achieved_awards_bits[64]; PlayerSpells spellbook; @@ -763,13 +763,13 @@ { struct { - ItemGen pInventoryItemList[126]; - ItemGen pEquippedItems[12]; + std::array<ItemGen, 126> pInventoryItemList; + std::array<ItemGen, 12> pEquippedItems; }; - ItemGen pOwnItems[138]; + std::array<ItemGen, 138> pOwnItems; }; - int pInventoryMatrix[126]; + std::array<int, 126> pInventoryMatrix; __int16 sResFireBase; __int16 sResAirBase; __int16 sResWaterBase; @@ -792,7 +792,7 @@ __int16 sResBodyBonus; __int16 sResLightBonus; __int16 sResDarkBonus; - SpellBuff pPlayerBuffs[24]; + std::array<SpellBuff, 24> pPlayerBuffs; unsigned int uVoiceID; int uPrevVoiceID; int uPrevFace; @@ -830,7 +830,7 @@ __int16 field_1AA2; int _expression21_animtime; int _expression21_frameset; - LloydBeacon pInstalledBeacons[5]; + std::array<LloydBeacon, 5> pInstalledBeacons; char uNumDivineInterventionCastsThisDay; char uNumArmageddonCasts; char uNumFireSpikeCasts;
--- a/UI/UiGame.cpp Wed Oct 09 08:39:49 2013 +0200 +++ b/UI/UiGame.cpp Wed Oct 09 09:08:15 2013 +0200 @@ -819,7 +819,7 @@ uFramesetIDa = 0; for (uint i = 0; i < 24; ++i) { - auto buff = player->pPlayerBuffs + i; + auto buff = player->pPlayerBuffs.data() + i; if (buff->uExpireTime > 0) { v36 = uFramesetIDa++ * pFontComic->uFontHeight + 134;
--- a/mm7_2.cpp Wed Oct 09 08:39:49 2013 +0200 +++ b/mm7_2.cpp Wed Oct 09 09:08:15 2013 +0200 @@ -101,7 +101,7 @@ auto v5 = LODWORD(player->pConditions[19]);//*((int *)v4 - 32); auto v6 = HIDWORD(player->pConditions[19]);//*((int *)v4 - 31); - memset(player->pConditions, 0, 0xA0u); + memset(player->pConditions.data(), 0, 0xA0u); __debugbreak(); *(int *)&player->pActiveSkills[8] = v5;
--- a/mm7_4.cpp Wed Oct 09 08:39:49 2013 +0200 +++ b/mm7_4.cpp Wed Oct 09 09:08:15 2013 +0200 @@ -794,7 +794,7 @@ if ( v48 ) { v31 = 0; - v32 = (char *)v21->pInventoryItemList; + v32 = (char *)v21->pInventoryItemList.data(); while ( *(int *)v32 != 601 || (unsigned __int8)v32[26] != v49 + 1 ) { ++v31; @@ -2907,7 +2907,7 @@ v6 = pParty->pPlayers;//[0].pInventoryItems[0].field_1A; do { - v7 = v6->pInventoryItemList; + v7 = v6->pInventoryItemList.data(); v8 = 138; do {
--- a/mm7_6.cpp Wed Oct 09 08:39:49 2013 +0200 +++ b/mm7_6.cpp Wed Oct 09 09:08:15 2013 +0200 @@ -437,7 +437,7 @@ { v7 = pParty->pPlayers;//[0].pPlayerBuffs; v8 = 0; - v9 = v7->pPlayerBuffs; + v9 = v7->pPlayerBuffs.data(); while ( v9->uExpireTime <= 0i64 ) { ++v8; @@ -448,7 +448,7 @@ if ( v7 <= &pParty->pPlayers[3] ) { v8 = 0; - v9 = v7->pPlayerBuffs; + v9 = v7->pPlayerBuffs.data(); } else return 0;