Mercurial > mm7
changeset 1202:0dbf6c4dd029
arrays to std::arrays phase 1
author | Grumpy7 |
---|---|
date | Sat, 08 Jun 2013 21:33:22 +0200 |
parents | 44f37efc159c |
children | 1eed3e0ab666 |
files | Actor.cpp Actor.h Arcomage.cpp Arcomage.h AudioPlayer.cpp AudioPlayer.h Autonotes.h Awards.h CastSpellInfo.h Chest.cpp Chest.h Events.cpp Events.h Events2D.h GUIButton.cpp GUIWindow.cpp GUIWindow.h IconFrameTable.h Indoor.cpp Indoor.h Indoor_stuff.h Items.cpp Items.h MM7.h Outdoor.cpp Party.cpp Render.cpp SaveLoad.cpp SpriteObject.cpp UICharacter.cpp UiGame.cpp VectorTypes.h mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_6.cpp mm7_data.cpp mm7_data.h |
diffstat | 39 files changed, 156 insertions(+), 176 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/Actor.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -40,7 +40,7 @@ -Actor pActors[500]; +std::array<Actor, 500> pActors; int uNumActors; stru319 stru_50C198; // idb @@ -1362,13 +1362,13 @@ int v5; // ST1C_4@8 int v6; // eax@8 - auto victim = pActors + uActorID; + auto victim = &pActors[uActorID]; if ( a2 == 1 ) BYTE2(victim->uAttributes) |= 8u; for (uint i = 0; i < uNumActors; ++i) { - auto actor = pActors + i; + auto actor = &pActors[i]; if (!actor->CanAct() || i == uActorID) continue; @@ -1935,7 +1935,7 @@ void Actor::AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, AIDirection *a4) { assert(uActorID < uNumActors); - auto actor = pActors + uActorID; + auto actor = &pActors[uActorID]; AIDirection a3; if (!a4) @@ -2352,7 +2352,7 @@ result = pPlayer->CanAct(); if ( result ) { - pCastSpellInfo->_427D48(v1); + pCastSpellInfo.data()->_427D48(v1); v4 = 0; v5 = pMapStats->GetMapInfo(pCurrentMapName); if ( v5 ) @@ -2972,7 +2972,7 @@ unsigned int v9; // eax@3 assert(uActorID < uNumActors); - auto actor = pActors + uActorID; + auto actor = &pActors[uActorID]; AIDirection a3; // [sp+Ch] [bp-5Ch]@2 if (!a4) @@ -3476,11 +3476,11 @@ //v24 = v3->uLastCharacterIDToHit; //v26 = 0; assert(uActorID < uNumActors); - auto _this = pActors + uActorID; + auto _this = &pActors[uActorID]; for (uint i = 0; i < uNumActors; ++i) { - auto actor = pActors + i; + auto actor = &pActors[i]; //v7 = pActors; //do //{
--- a/Actor.h Sat Jun 08 19:34:33 2013 +0200 +++ b/Actor.h Sat Jun 08 21:33:22 2013 +0200 @@ -275,5 +275,5 @@ //extern Actor pMonsterInfoUI_Doll; -extern Actor pActors[500]; +extern std::array<Actor, 500> pActors; extern int uNumActors; \ No newline at end of file
--- a/Arcomage.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/Arcomage.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -109,7 +109,7 @@ ArcomageGame *pArcomageGame = new ArcomageGame; ArcomageCard pCards[87]; -ArcomagePlayer am_Players[2]; +std::array<ArcomagePlayer, 2> am_Players; Acromage_st1 struct_st1[10];
--- a/Arcomage.h Sat Jun 08 19:34:33 2013 +0200 +++ b/Arcomage.h Sat Jun 08 21:33:22 2013 +0200 @@ -198,7 +198,7 @@ extern ArcomageGame *pArcomageGame; -extern ArcomagePlayer am_Players[2]; +extern std::array<ArcomagePlayer, 2> am_Players; #pragma pack(push, 1)
--- a/AudioPlayer.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/AudioPlayer.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -36,13 +36,13 @@ int uFindSound_BinSearch_ResultID; // weak int uLastLoadedSoundID; // weak int sLastTrackLengthMS; -Sound pSounds[3000]; +std::array<Sound, 3000> pSounds; AudioPlayer *pAudioPlayer; SoundList *pSoundList; -stru339_spell_sound stru_A750F8[4]; -stru339_spell_sound stru_AA1058[4]; +std::array<stru339_spell_sound, 4> stru_A750F8; +std::array<stru339_spell_sound, 4> stru_AA1058; @@ -51,7 +51,7 @@ unsigned __int8 uMusicVolimeMultiplier = 4; int bWalkSound; // idb -float pSoundVolumeLevels[10] = +std::array<float, 10> pSoundVolumeLevels = { 0.0000000f, 0.1099999f, 0.2199999f, 0.3300000f, 0.4399999f, 0.5500000f, 0.6600000f, 0.7699999f, 0.8799999f, 0.9900000f @@ -1681,7 +1681,7 @@ case OBJECT_Actor: { assert(source_id < uNumActors); - auto actor = pActors + source_id; + auto actor = &pActors[source_id]; source_x = actor->vPosition.x; source_y = actor->vPosition.y;
--- a/AudioPlayer.h Sat Jun 08 19:34:33 2013 +0200 +++ b/AudioPlayer.h Sat Jun 08 21:33:22 2013 +0200 @@ -303,7 +303,7 @@ extern int uFindSound_BinSearch_ResultID; // weak extern int uLastLoadedSoundID; // weak extern int sLastTrackLengthMS; -extern Sound pSounds[3000]; +extern std::array<Sound, 3000> pSounds; extern AudioPlayer *pAudioPlayer; extern SoundList *pSoundList; @@ -312,7 +312,7 @@ extern unsigned __int8 uMusicVolimeMultiplier; extern int bWalkSound; // idb -extern float pSoundVolumeLevels[10]; // idb +extern std::array<float, 10> pSoundVolumeLevels; // idb @@ -335,5 +335,5 @@ int pSoundsOffsets[2]; }; #pragma pack(pop) -extern stru339_spell_sound stru_A750F8[4]; -extern stru339_spell_sound stru_AA1058[4]; +extern std::array<stru339_spell_sound, 4> stru_A750F8; +extern std::array<stru339_spell_sound, 4> stru_AA1058;
--- a/Autonotes.h Sat Jun 08 19:34:33 2013 +0200 +++ b/Autonotes.h Sat Jun 08 21:33:22 2013 +0200 @@ -1,5 +1,5 @@ #pragma once - +#include <array> @@ -22,4 +22,4 @@ AUTONOTE_TYPE eType; }; #pragma pack(pop) -extern Autonote pAutonoteTxt[195]; // weak +extern std::array<Autonote, 195> pAutonoteTxt; // weak
--- a/Awards.h Sat Jun 08 19:34:33 2013 +0200 +++ b/Awards.h Sat Jun 08 21:33:22 2013 +0200 @@ -1,5 +1,5 @@ #pragma once - +#include <array> /* 353 */ #pragma pack(push, 1) @@ -9,7 +9,7 @@ unsigned int uPriority; }; #pragma pack(pop) -extern Award pAwards[105]; +extern std::array<Award, 105> pAwards; @@ -122,6 +122,6 @@ , Award_ArcomageLoses = 104 }; -extern AwardType achieved_awards[1000]; +extern std::array<AwardType, 1000> achieved_awards; extern int num_achieved_awards; extern int num_achieved_awards_2; \ No newline at end of file
--- a/CastSpellInfo.h Sat Jun 08 19:34:33 2013 +0200 +++ b/CastSpellInfo.h Sat Jun 08 21:33:22 2013 +0200 @@ -1,5 +1,5 @@ #pragma once - +#include <array> /* 271 */ @@ -34,5 +34,5 @@ #pragma pack(pop) -extern CastSpellInfo pCastSpellInfo[10]; +extern std::array<CastSpellInfo, 10> pCastSpellInfo; extern CastSpellInfo stru_50CDB4; // idb
--- a/Chest.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/Chest.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -31,7 +31,7 @@ size_t uNumChests; // idb struct ChestList *pChestList; -Chest pChests[20]; +std::array<Chest, 20> pChests; const int pChestPixelOffsetX[8] = {42, 18, 18, 42, 42, 42, 18, 42};
--- a/Chest.h Sat Jun 08 19:34:33 2013 +0200 +++ b/Chest.h Sat Jun 08 21:33:22 2013 +0200 @@ -73,4 +73,4 @@ extern size_t uNumChests; // idb extern struct ChestList *pChestList; -extern Chest pChests[20]; \ No newline at end of file +extern std::array<Chest, 20> pChests; \ No newline at end of file
--- a/Events.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/Events.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -34,29 +34,29 @@ -EventIndex pSomeOtherEVT_Events[4400]; +std::array<EventIndex, 4400> pSomeOtherEVT_Events; signed int uSomeOtherEVT_NumEvents; char *pSomeOtherEVT; -EventIndex pSomeEVT_Events[4400]; +std::array<EventIndex, 4400> pSomeEVT_Events; signed int uSomeEVT_NumEvents; char *pSomeEVT; unsigned int uGlobalEVT_NumEvents; unsigned int uGlobalEVT_Size; -char pGlobalEVT[46080]; -EventIndex pGlobalEVT_Index[4400]; +std::array<char, 46080> pGlobalEVT; +std::array<EventIndex, 4400> pGlobalEVT_Index; -unsigned int pLevelStrOffsets[500]; +std::array<unsigned int, 500> pLevelStrOffsets; unsigned int uLevelStrNumStrings; unsigned int uLevelStrFileSize; signed int uLevelEVT_NumEvents; unsigned int uLevelEVT_Size; -char pLevelStr[9216]; -char pLevelEVT[9216]; -EventIndex pLevelEVT_Index[4400]; +std::array<char, 9216> pLevelStr; +std::array<char, 9216> pLevelEVT; +std::array<EventIndex, 4400> pLevelEVT_Index; -_2devent p2DEvents[525]; // weak +std::array<_2devent, 525> p2DEvents; // weak @@ -102,12 +102,12 @@ unsigned int offset_in; raw_event_header *current_hdr; uGlobalEVT_NumEvents = 0; - uGlobalEVT_Size = LoadEventsToBuffer("global.evt", pGlobalEVT, 46080); + uGlobalEVT_Size = LoadEventsToBuffer("global.evt", pGlobalEVT.data(), 46080); if ( !uGlobalEVT_Size ) return; - memset(pGlobalEVT_Index, 0x80, sizeof(pGlobalEVT_Index));//52800 + memset(pGlobalEVT_Index.data(), 0x80, sizeof(pGlobalEVT_Index));//52800 events_count = uGlobalEVT_NumEvents; - current_hdr=(raw_event_header *)pGlobalEVT; + current_hdr=(raw_event_header *)pGlobalEVT.data(); offset_in=0; for (events_count = 0, offset_in = 0; offset_in < uGlobalEVT_Size; ++events_count) { @@ -143,12 +143,12 @@ return; memset(array_5B5928_timers, 0, 3200); - memset(pLevelEVT_Index, 80, sizeof(EventIndex)*4400); + memset(pLevelEVT_Index.data(), 80, sizeof(EventIndex)*4400); uLevelEVT_NumEvents = 0; dword_5B65C8_timers_count = 0; - current_hdr=(raw_event_header *)pLevelEVT; + current_hdr=(raw_event_header *)pLevelEVT.data(); offset_in=0; for (events_count = 0, offset_in = 0; offset_in < uLevelEVT_Size; ++events_count) { @@ -440,14 +440,14 @@ if ( activeLevelDecoration ) { uSomeEVT_NumEvents = uGlobalEVT_NumEvents; - pSomeEVT = pGlobalEVT; - memcpy(pSomeEVT_Events, pGlobalEVT_Index, sizeof(EventIndex)*4400); //4400 evts + pSomeEVT = pGlobalEVT.data(); + memcpy(pSomeEVT_Events.data(), pGlobalEVT_Index.data(), sizeof(EventIndex)*4400); //4400 evts } else { uSomeEVT_NumEvents = uLevelEVT_NumEvents; - pSomeEVT = pLevelEVT; - memcpy(pSomeEVT_Events, pLevelEVT_Index, sizeof(EventIndex)*4400); + pSomeEVT = pLevelEVT.data(); + memcpy(pSomeEVT_Events.data(), pLevelEVT_Index.data(), sizeof(EventIndex)*4400); } v4 = 0; @@ -749,7 +749,7 @@ __debugbreak(); if ( (signed int)uNumActors > 0 ) { - v41 = pActors;//[0].uGroup; + v41 = pActors.data();//[0].uGroup; do { if ( v41->uGroup == v38 ) @@ -772,7 +772,7 @@ __debugbreak(); if ( (signed int)uNumActors > 0 ) { - v45 = pActors;//[0].uAlly; + v45 = pActors.data();//[0].uAlly; do { if ( v45->uGroup == v42 )
--- a/Events.h Sat Jun 08 19:34:33 2013 +0200 +++ b/Events.h Sat Jun 08 21:33:22 2013 +0200 @@ -303,26 +303,26 @@ #define EVT_STRING(x) (unsigned char*)&x #define EVT_BYTE(x) (unsigned char)x -extern EventIndex pSomeOtherEVT_Events[4400]; +extern std::array<EventIndex, 4400> pSomeOtherEVT_Events; extern signed int uSomeOtherEVT_NumEvents; extern char *pSomeOtherEVT; -extern EventIndex pSomeEVT_Events[4400]; +extern std::array<EventIndex, 4400> pSomeEVT_Events; extern signed int uSomeEVT_NumEvents; extern char *pSomeEVT; extern unsigned int uGlobalEVT_NumEvents; extern unsigned int uGlobalEVT_Size; -extern char pGlobalEVT[46080]; -extern EventIndex pGlobalEVT_Index[4400]; +extern std::array<char, 46080> pGlobalEVT; +extern std::array<EventIndex, 4400> pGlobalEVT_Index; -extern unsigned int pLevelStrOffsets[500]; +extern std::array<unsigned int, 500> pLevelStrOffsets; extern unsigned int uLevelStrNumStrings; extern unsigned int uLevelStrFileSize; extern signed int uLevelEVT_NumEvents; extern unsigned int uLevelEVT_Size; -extern char pLevelStr[9216]; -extern char pLevelEVT[9216]; -extern EventIndex pLevelEVT_Index[4400]; +extern std::array<char, 9216> pLevelStr; +extern std::array<char, 9216> pLevelEVT; +extern std::array<EventIndex, 4400> pLevelEVT_Index; unsigned int LoadEventsToBuffer(const char *pContainerName, char *pBuffer, unsigned int uBufferSize);
--- a/Events2D.h Sat Jun 08 19:34:33 2013 +0200 +++ b/Events2D.h Sat Jun 08 21:33:22 2013 +0200 @@ -64,4 +64,4 @@ #pragma pack(pop) -extern _2devent p2DEvents[525]; // weak \ No newline at end of file +extern std::array<_2devent, 525> p2DEvents; // weak \ No newline at end of file
--- a/GUIButton.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/GUIButton.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -100,10 +100,10 @@ struct GUIButton *pBtnLoadSlot; -GUIButton *pCreationUI_BtnPressRight2[4]; -GUIButton *pCreationUI_BtnPressLeft2[4]; -GUIButton *pCreationUI_BtnPressLeft[4]; -GUIButton *pCreationUI_BtnPressRight[4]; +std::array<GUIButton*, 4> pCreationUI_BtnPressRight2; +std::array<GUIButton*, 4> pCreationUI_BtnPressLeft2; +std::array<GUIButton*, 4> pCreationUI_BtnPressLeft; +std::array<GUIButton*, 4> pCreationUI_BtnPressRight;
--- a/GUIWindow.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/GUIWindow.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -34,7 +34,7 @@ int pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[1]; // idb struct GUIWindow *pWindow_MainMenu; -struct GUIWindow pWindowList[20]; +std::array<struct GUIWindow, 20> pWindowList; struct GUIMessageQueue *pMessageQueue_50CBD0 = new GUIMessageQueue; struct GUIMessageQueue *pMessageQueue_50C9E8 = new GUIMessageQueue; @@ -558,7 +558,7 @@ 1, 0, UIMSG_ClickBooksBtn, 0xAu, 0, pGlobalTXT_LocalizationStrings[193],// "Scroll Down" pTex_tab_an_7b__zoot_on, 0); num_achieved_awards = 0; - memset(achieved_awards, 0, 4000); + memset(achieved_awards.data(), 0, 4000); for ( i = dword_506528; i < 512; ++i ) { v14 = (char *)pQuestTable[i-1];//(&dword_722F10)[4 * i];
--- a/GUIWindow.h Sat Jun 08 19:34:33 2013 +0200 +++ b/GUIWindow.h Sat Jun 08 21:33:22 2013 +0200 @@ -1,6 +1,6 @@ #pragma once #include "Player.h" - +#include <array> @@ -458,7 +458,7 @@ extern int pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[]; // idb extern struct GUIWindow *pWindow_MainMenu; -extern struct GUIWindow pWindowList[20]; +extern std::array<struct GUIWindow, 20> pWindowList; @@ -715,10 +715,10 @@ extern struct GUIButton *pBtnLoadSlot; -extern GUIButton *pCreationUI_BtnPressRight2[4]; -extern GUIButton *pCreationUI_BtnPressLeft2[4]; -extern GUIButton *pCreationUI_BtnPressLeft[4]; -extern GUIButton *pCreationUI_BtnPressRight[4]; +extern std::array<GUIButton*, 4> pCreationUI_BtnPressRight2; +extern std::array<GUIButton*, 4> pCreationUI_BtnPressLeft2; +extern std::array<GUIButton*, 4> pCreationUI_BtnPressLeft; +extern std::array<GUIButton*, 4> pCreationUI_BtnPressRight; extern int uTextureID_GameUI_CharSelectionFrame; // 50C98C @@ -730,7 +730,7 @@ extern unsigned int ui_character_bonus_text_color_neg; extern unsigned int ui_character_skill_upgradeable_color; extern unsigned int ui_character_skill_default_color; -extern unsigned int ui_character_award_color[6]; +extern std::array<unsigned int, 6> ui_character_award_color; extern unsigned int ui_game_minimap_outline_color; extern unsigned int ui_game_minimap_actor_friendly_color; extern unsigned int ui_game_minimap_actor_hostile_color; @@ -738,7 +738,7 @@ extern unsigned int ui_game_minimap_decoration_color_1; extern unsigned int ui_game_minimap_projectile_color; extern unsigned int ui_game_minimap_treasure_color; -extern unsigned int ui_game_character_record_playerbuff_colors[24]; +extern std::array<unsigned int, 24> ui_game_character_record_playerbuff_colors; extern unsigned int ui_gamemenu_video_gamma_title_color; extern unsigned int ui_gamemenu_keys_action_name_color; extern unsigned int ui_gamemenu_keys_key_selection_blink_color_1;
--- a/IconFrameTable.h Sat Jun 08 19:34:33 2013 +0200 +++ b/IconFrameTable.h Sat Jun 08 21:33:22 2013 +0200 @@ -1,5 +1,5 @@ #pragma once - +#include <array> @@ -76,4 +76,4 @@ extern struct UIAnimation *pUIAnum_Torchlight; extern struct UIAnimation *pUIAnim_WizardEye; -extern struct UIAnimation *pUIAnims[4]; +extern std::array<struct UIAnimation *, 4> pUIAnims;
--- a/Indoor.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/Indoor.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -51,7 +51,7 @@ struct DecorationList *pDecorationList; -LevelDecoration pLevelDecorations[3000]; +std::array<LevelDecoration, 3000> pLevelDecorations; size_t uNumLevelDecorations; LevelDecoration* activeLevelDecoration; @@ -63,7 +63,7 @@ BspRenderer_stru2 stru_F8A590; BspRenderer *pBspRenderer = new BspRenderer; // idb stru141 stru_721530; -stru352 stru_F83B80[480]; +std::array<stru352, 480> stru_F83B80; @@ -2684,7 +2684,7 @@ pGameLoadingUI_ProgressBar->Progress(); memcpy(&uNumLevelDecorations, pData, 4); - memcpy(pLevelDecorations, pData + 4, uNumLevelDecorations * sizeof(LevelDecoration)); + memcpy(pLevelDecorations.data(), pData + 4, uNumLevelDecorations * sizeof(LevelDecoration)); pData += 4 + uNumLevelDecorations * sizeof(LevelDecoration); for (uint i = 0; i < uNumLevelDecorations; ++i) @@ -2879,7 +2879,7 @@ pGameLoadingUI_ProgressBar->Progress(); memcpy(&uNumActors, pData, 4); - memcpy(pActors, pData + 4, uNumActors * sizeof(Actor)); + memcpy(pActors.data(), pData + 4, uNumActors * sizeof(Actor)); pData += 4 + uNumActors * sizeof(Actor); pGameLoadingUI_ProgressBar->Progress(); @@ -2912,7 +2912,7 @@ pGameLoadingUI_ProgressBar->Progress(); memcpy(&uNumChests, pData, 4); - memcpy(pChests, pData + 4, uNumChests * sizeof(Chest)); + memcpy(pChests.data(), pData + 4, uNumChests * sizeof(Chest)); pData += 4 + uNumChests * sizeof(Chest); pGameLoadingUI_ProgressBar->Progress(); @@ -4484,7 +4484,7 @@ for (uint i = 0; i < uNumLevelDecorations; ++i) { - auto pDecortaion = pLevelDecorations + i; + auto pDecortaion = &pLevelDecorations[i]; pDecorationList->InitializeDecorationSprite(pDecortaion->uDecorationDescID); @@ -4563,7 +4563,7 @@ for (uint i = 0; i < uNumActors; ++i) //if ( (signed int)uNumActors > (signed int)v13 ) { - Actor *pActor = pActors + i; + Actor *pActor = &pActors[i]; //v26 = (char *)&pActors[0].uAttributes; //do //{
--- a/Indoor.h Sat Jun 08 19:34:33 2013 +0200 +++ b/Indoor.h Sat Jun 08 21:33:22 2013 +0200 @@ -39,7 +39,7 @@ __int16 field_1E; }; #pragma pack(pop) -extern LevelDecoration pLevelDecorations[3000]; +extern std::array<LevelDecoration, 3000> pLevelDecorations; extern size_t uNumLevelDecorations; extern LevelDecoration* activeLevelDecoration;
--- a/Indoor_stuff.h Sat Jun 08 19:34:33 2013 +0200 +++ b/Indoor_stuff.h Sat Jun 08 21:33:22 2013 +0200 @@ -423,4 +423,4 @@ int field_34; }; #pragma pack(pop) -extern stru352 stru_F83B80[480]; \ No newline at end of file +extern std::array<stru352, 480> stru_F83B80; \ No newline at end of file
--- a/Items.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/Items.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -28,7 +28,7 @@ }; -const char uItemsAmountPerShopType[5]={ 0, 6, 8, 12, 12}; +std::array<const char, 5> uItemsAmountPerShopType={ 0, 6, 8, 12, 12}; const ITEM_VARIATION shopWeap_variation_ord[15] ={ { 0, { 0, 0, 0, 0 }},
--- a/Items.h Sat Jun 08 19:34:33 2013 +0200 +++ b/Items.h Sat Jun 08 21:33:22 2013 +0200 @@ -1,4 +1,5 @@ #pragma once +#include <array> enum DAMAGE_TYPE:unsigned int { @@ -329,7 +330,7 @@ void GenerateSpecialShopItems(); void GenerateItemsInChest(); -extern const char uItemsAmountPerShopType[]; // weak +extern std::array<const char, 5> uItemsAmountPerShopType; // weak extern ItemGen *ptr_50C9A4; extern struct ItemsTable *pItemsTable;
--- a/MM7.h Sat Jun 08 19:34:33 2013 +0200 +++ b/MM7.h Sat Jun 08 21:33:22 2013 +0200 @@ -88,7 +88,7 @@ __int16 height; }; #pragma pack(pop) -extern stat_coord stat_string_coord[26]; +extern std::array<stat_coord, 26> stat_string_coord; /* 376 */ #pragma pack(push, 1)
--- a/Outdoor.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/Outdoor.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -1993,7 +1993,7 @@ assert(sizeof(LevelDecoration) == 32); //pFilename = (char *)(32 * uNumLevelDecorations); - memcpy(pLevelDecorations, pSrc + 4, uNumLevelDecorations * sizeof(LevelDecoration)); + memcpy(pLevelDecorations.data(), pSrc + 4, uNumLevelDecorations * sizeof(LevelDecoration)); pSrc += 4 + sizeof(LevelDecoration) * uNumLevelDecorations; pGameLoadingUI_ProgressBar->Progress(); @@ -2294,7 +2294,7 @@ assert(sizeof(Actor) == 836); //pFilename = (char *)(836 * uNumActors); - memcpy(pActors, pSrc + 4, uNumActors * sizeof(Actor)); + memcpy(pActors.data(), pSrc + 4, uNumActors * sizeof(Actor)); pSrc += 4 + uNumActors * sizeof(Actor); //v92 = (char *)v91 + (int)pFilename; pGameLoadingUI_ProgressBar->Progress(); @@ -2322,7 +2322,7 @@ assert(sizeof(Chest) == 5324); //pFilename = (char *)(5324 * uNumChests); - memcpy(pChests, pSrc + 4 , uNumChests * sizeof(Chest)); + memcpy(pChests.data(), pSrc + 4 , uNumChests * sizeof(Chest)); pSrc += 4 + uNumChests * sizeof(Chest); //v96 = (char *)v95 + (int)pFilename; pGameLoadingUI_ProgressBar->Progress(); @@ -2708,7 +2708,7 @@ for (uint i = 0; i < uNumLevelDecorations; ++i) { - auto decor = pLevelDecorations + i; + auto decor = &pLevelDecorations[i]; pDecorationList->InitializeDecorationSprite(decor->uDecorationDescID); v4 = pDecorationList->pDecorations[decor->uDecorationDescID].uSoundID; @@ -2943,7 +2943,7 @@ //v1 = pActors;//[0].vPosition.z; //do //{ - auto actor = pActors + i; + auto actor = &pActors[i]; //v2 = actor->uAIState; actor->uAttributes &= 0xFFFFFFF7u;
--- a/Party.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/Party.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -849,7 +849,7 @@ v4 = 0; if ( (signed int)uNumActors > 0 ) { - v0 = pActors;//[0].pMonsterInfo.uMovementType; + v0 = pActors.data();//[0].pMonsterInfo.uMovementType; do { if ( v0->Actor::CanAct() && v0->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long && v0->pMonsterInfo.uMovementType != 5 )
--- a/Render.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/Render.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -3500,7 +3500,7 @@ //do for (int i = 0; i < uNumLevelDecorations; ++i) { - auto decor = pLevelDecorations + i; + auto decor = &pLevelDecorations[i]; auto v0 = (char *)&pLevelDecorations[i].vPosition.y; if ( (!(decor->field_2 & 0x40) || decor->_47A825()) && !(decor->field_2 & 0x20) )
--- a/SaveLoad.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/SaveLoad.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -419,7 +419,7 @@ } memcpy(data_write_pos, &uNumActors, 4); data_write_pos += 4; - memcpy(data_write_pos, pActors, 836 * uNumActors); + memcpy(data_write_pos, pActors.data(), 836 * uNumActors); data_write_pos += 836 * uNumActors; memcpy(data_write_pos, &uNumSpriteObjects, 4); data_write_pos += 4; @@ -427,7 +427,7 @@ data_write_pos += 112 * uNumSpriteObjects; memcpy(data_write_pos, &uNumChests, 4); data_write_pos += 4; - memcpy(data_write_pos, pChests, sizeof(Chest)*uNumChests);//5324 * + memcpy(data_write_pos, pChests.data(), sizeof(Chest)*uNumChests);//5324 * data_write_pos += sizeof(Chest)* uNumChests; memcpy(data_write_pos, pIndoor->pDoors, 0x3E80); data_write_pos += 16000; @@ -468,7 +468,7 @@ } memcpy(data_write_pos, &uNumActors, 4); data_write_pos += 4; - memcpy(data_write_pos, pActors, 836 * uNumActors); + memcpy(data_write_pos, pActors.data(), 836 * uNumActors); data_write_pos += 836 * uNumActors; memcpy(data_write_pos, &uNumSpriteObjects, 4); data_write_pos += 4; @@ -476,7 +476,7 @@ data_write_pos += 112 * uNumSpriteObjects; memcpy(data_write_pos, &uNumChests, 4); data_write_pos += 4; - memcpy(data_write_pos, pChests, sizeof(Chest)* uNumChests); + memcpy(data_write_pos, pChests.data(), sizeof(Chest)* uNumChests); data_write_pos += sizeof(Chest)* uNumChests; memcpy(data_write_pos, &stru_5E4C90, 0xC8); data_write_pos += 200;
--- a/SpriteObject.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/SpriteObject.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -430,7 +430,7 @@ v56 = 0; if ( (signed int)uNumActors > 0 ) { - v60 = pActors; + v60 = pActors.data(); v20 = &pActors[v19]; do { @@ -716,7 +716,7 @@ { if ( (signed int)uNumActors > v8 ) { - v39b = pActors;//[0].word_000086_some_monster_id; + v39b = pActors.data();//[0].word_000086_some_monster_id; do { //v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1; @@ -737,7 +737,7 @@ { if ( (signed int)uNumActors > v8 ) { - v39b = pActors;//[0].word_000086_some_monster_id; + v39b = pActors.data();//[0].word_000086_some_monster_id; do { _46DF1A_collide_against_actor(v42++, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius);
--- a/UICharacter.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/UICharacter.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -41,7 +41,7 @@ unsigned int ui_character_bonus_text_color_neg; unsigned int ui_character_skill_upgradeable_color; unsigned int ui_character_skill_default_color; -unsigned int ui_character_award_color[6]; +std::array<unsigned int, 6> ui_character_award_color; unsigned int ui_game_minimap_outline_color; unsigned int ui_game_minimap_actor_friendly_color; @@ -50,7 +50,7 @@ unsigned int ui_game_minimap_decoration_color_1; unsigned int ui_game_minimap_projectile_color; unsigned int ui_game_minimap_treasure_color; -unsigned int ui_game_character_record_playerbuff_colors[24]; +std::array<unsigned int, 24> ui_game_character_record_playerbuff_colors; unsigned int ui_gamemenu_video_gamma_title_color; unsigned int ui_gamemenu_keys_action_name_color; @@ -2508,28 +2508,6 @@ pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0); } -//Award sort stuff. Should be removed after changing the award container to something other than array -template<class Cont> -typename Cont::iterator begin(Cont& c){ - return c.begin(); -} - -template<class Cont> -typename Cont::iterator end(Cont& c){ - return c.end(); -} - -// overloads for C style arrays -template<class T, std::size_t N> -T* begin(T (&arr)[N]){ - return &arr[0]; -} - -template<class T, std::size_t N> -T* end(T (&arr)[N]){ - return arr + N; -} - bool awardSort (int i,int j) { if (pAwards[i].uPriority == 0) //none { @@ -2566,7 +2544,7 @@ { auto pPlayer = pPlayers[uActiveCharacter]; - memset(achieved_awards, 0, 4000); + memset(achieved_awards.data(), 0, 4000); num_achieved_awards = 0; memset(pTmpBuf2, 0, 0x7D0u); @@ -2587,7 +2565,7 @@ //sort awards index if (num_achieved_awards_2 > 0) { - std::stable_sort(begin(achieved_awards), end(achieved_awards), awardSort); + std::stable_sort(achieved_awards.begin(), achieved_awards.end(), awardSort); } }
--- a/UiGame.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/UiGame.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -2694,7 +2694,7 @@ uZf = 0; if ( (signed int)uNumActors > 0 ) { - flagsc = pActors;//[0].uAIState; + flagsc = pActors.data();//[0].uAIState; do { v39 = flagsc->uAIState;
--- a/VectorTypes.h Sat Jun 08 19:34:33 2013 +0200 +++ b/VectorTypes.h Sat Jun 08 21:33:22 2013 +0200 @@ -1,5 +1,5 @@ #pragma once - +#include <array> typedef unsigned __int32 uint;
--- a/mm7_2.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/mm7_2.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -388,7 +388,7 @@ v0 = 0; if ( (signed int)uNumActors > 0 ) { - v1 = pActors;//[0].uAIState; + v1 = pActors.data();//[0].uAIState; v7 = uNumActors; do { @@ -2728,7 +2728,7 @@ v20 = uNumActors; if ( (signed int)uNumActors > 0 ) { - v4 = pActors;//[0].uAIState; + v4 = pActors.data();//[0].uAIState; while ( v4->uAIState != Removed ) { ++v3; @@ -3059,7 +3059,7 @@ v2 = 0; if ( (signed int)uNumActors <= 0 ) goto LABEL_8; - v3 = pActors; + v3 = pActors.data(); while ( 1 ) { v22 = v3->pMonsterInfo.uID - 1; @@ -3306,7 +3306,7 @@ uint decorEventIdx = 0; for (uint i = 0; i < uNumLevelDecorations; ++i) { - auto decor = pLevelDecorations + i; + auto decor = &pLevelDecorations[i]; if (!decor->field_16_event_id) { @@ -5270,7 +5270,7 @@ for (uint i = 0; i < uNumActors; ++i) //if ( (signed int)uNumActors > 0 ) { - auto pActor = pActors + i; + auto pActor = &pActors[i]; //v2 = (char *)&pActors[0].uNPC_ID; //do //{ @@ -5322,7 +5322,7 @@ for (uint i = 0; i < uNumActors; ++i) { - auto pActor = pActors + i; + auto pActor = &pActors[i]; //v7 = (char *)&pActors[0].pMonsterInfo; //do //{ @@ -5421,7 +5421,7 @@ result = 0; if ( (signed int)uNumLevelDecorations > 0 ) { - v4 = pLevelDecorations; + v4 = pLevelDecorations.data(); do { if ( v4->uDecorationDescID == v2 ) @@ -6800,7 +6800,7 @@ pEventTimer->Pause(); pMiscTimer->Pause(); pParty->uFlags = 2; - pCastSpellInfo->_427D48(1); + pCastSpellInfo.data()->_427D48(1); ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); DoPrepareWorld(0, (v1 == 0) + 1); pMiscTimer->Resume(); @@ -9610,7 +9610,7 @@ v19 = 0; if ( (signed int)uNumActors > 0 ) { - v4 = pActors;//[0].uAIState; + v4 = pActors.data();//[0].uAIState; do { v5 = abs(v4->vPosition.x - pParty->vPosition.x); @@ -9961,7 +9961,7 @@ v1 = this; if ( (signed int)uNumActors > 0 ) { - v2 = pActors;//[0].vPosition.y; + v2 = pActors.data();//[0].vPosition.y; do { if ( v2->CanAct() )
--- a/mm7_3.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/mm7_3.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -11849,7 +11849,7 @@ if (sizeof(pLevelStrOffsets) != 2000) Log::Warning(L"pLevelStrOffsets: deserialization warning"); - memset(pLevelStrOffsets, 0, 2000); + memset(pLevelStrOffsets.data(), 0, 2000); max_string_length = 0; string_num = 1; @@ -11937,7 +11937,7 @@ { auto pEvent = pLevelEVT_Index[i]; - auto _evt = (_evt_raw *)(pLevelEVT + pEvent.uEventOffsetInEVT); + auto _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]); if (_evt->_e_type == EVENT_PlaySound) { @@ -12067,10 +12067,10 @@ char pContainerName[120]; // [sp+8h] [bp-98h]@1 sprintf(pContainerName, "%s.evt", pLevelName); - uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT, 0x2400u); + uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT.data(), 0x2400u); sprintf(pContainerName, "%s.str", pLevelName); - uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr, 0x2400u); + uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr.data(), 0x2400u); if (uLevelStrFileSize) LoadLevel_InitializeLevelStr(); } @@ -12424,9 +12424,9 @@ if ( !npc_event_id ) return 0; evt_seq_num = entry_line; - pSomeOtherEVT = pGlobalEVT; + pSomeOtherEVT = pGlobalEVT.data(); uSomeOtherEVT_NumEvents = uGlobalEVT_NumEvents; - memcpy(pSomeOtherEVT_Events, pGlobalEVT_Index, sizeof(EventIndex)*4400); + memcpy(pSomeOtherEVT_Events.data(), pGlobalEVT_Index.data(), sizeof(EventIndex)*4400); npc_activity = 1; ready_to_exit = false; if ( uSomeOtherEVT_NumEvents <= 0 ) @@ -12785,7 +12785,7 @@ { if ( (signed int)uNumActors > Standing ) { - v6 = pActors;//[0].uAttributes; + v6 = pActors.data();//[0].uAttributes; do { if ( v6->uGroup == v4 ) @@ -12808,7 +12808,7 @@ v7 = uNumActors; if ( (signed int)uNumActors > Standing ) { - v8 = pActors;//[0].uAIState; + v8 = pActors.data();//[0].uAIState; do { if ( v8->uGroup == v4 ) @@ -13731,7 +13731,7 @@ v5 = 0; if ( (signed int)uNumLevelDecorations > 0 ) { - v6 = pLevelDecorations; + v6 = pLevelDecorations.data(); while ( v6->uDecorationDescID != (signed __int16)v4 ) { ++v5; @@ -14051,7 +14051,7 @@ ai_arrays_size = 0; for (uint i = 0; i < uNumActors; ++i) { - auto actor = pActors + i; + auto actor = &pActors[i]; actor->uAttributes &= 0xFFFFFBFF; if (!actor->CanAct()) @@ -14227,7 +14227,7 @@ v43 = 0; if ( (signed int)uNumActors > 0 ) { - v0 = pActors;//[0].uAttributes; + v0 = pActors.data();//[0].uAttributes; do { BYTE1(v0->uAttributes) &= 0xFBu; @@ -14344,7 +14344,7 @@ ai_arrays_size = v19; if ( (signed int)uNumActors > 0 ) { - v24 = pActors;//[0].uAttributes; + v24 = pActors.data();//[0].uAttributes; do { if ( v24->CanAct() && v24->uSectorID == v37 )
--- a/mm7_4.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/mm7_4.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -131,7 +131,7 @@ v37 = 0; if ( (signed int)uNumActors > 0 ) { - v9 = pActors;//[0].vPosition.y; + v9 = pActors.data();//[0].vPosition.y; do { v10 = abs(v33 - v9->vPosition.x); @@ -8565,7 +8565,7 @@ if ( (signed int)uNumActors > 0 ) { //v3 = pActors;//[0].pActorBuffs; - v16 = pActors;//[0].pActorBuffs; + v16 = pActors.data();//[0].pActorBuffs; v3 = v16->pActorBuffs; do { @@ -8744,7 +8744,7 @@ for (uint i = 0; i < uNumActors; ++i) { - auto p = pActors + i; + auto p = &pActors[i]; if (p->uAIState == Removed || p->uAIState == Disabled)
--- a/mm7_5.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/mm7_5.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -1685,7 +1685,7 @@ { pParty->field_6E4 = 0; pParty->field_6E0 = 0; - pCastSpellInfo->_427D48(1); + pCastSpellInfo.data()->_427D48(1); DialogueEnding(); pEventTimer->Pause(); pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_Box); @@ -3252,7 +3252,7 @@ } } } - pCastSpellInfo->_427E01_cast_spell(); + pCastSpellInfo.data()->_427E01_cast_spell(); } //----- (004356FF) -------------------------------------------------------- @@ -4270,7 +4270,7 @@ uActorID = 0; if ( (signed int)uNumActors > 0 ) { - v28 = pActors;//[0].vPosition.z; + v28 = pActors.data();//[0].vPosition.z; do { if ( v28->CanAct() ) @@ -8798,7 +8798,7 @@ Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // ai_near_actors_targets_pid[i] for AI_Stand seems always 0; original code behaviour is identical for (uint i = 0; i < uNumActors; ++i) { - auto actor = pActors + i; + auto actor = &pActors[i]; if (actor->CanAct() || actor->uAIState == Disabled) { @@ -8881,7 +8881,7 @@ v8 = v2; if ( (signed int)uNumActors > 0 ) { - v5 = pActors; + v5 = pActors.data(); do { v6 = v5->uAttributes; @@ -8918,7 +8918,7 @@ v9 = 0; if ( (signed int)uNumActors > 0 ) { - v4 = pActors;//[0].pMonsterInfo.uID; + v4 = pActors.data();//[0].pMonsterInfo.uID; do { v5 = v4->uAttributes; // actor::attributes @@ -8958,7 +8958,7 @@ v9 = 0; if ( (signed int)uNumActors > 0 ) { - v4 = pActors;//[0].uGroup; + v4 = pActors.data();//[0].uGroup; do { v5 = v4->uAttributes;
--- a/mm7_6.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/mm7_6.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -2236,7 +2236,7 @@ if (a5 & 0x3CA) { - assert(sizeof(pCastSpellInfo) / sizeof(*pCastSpellInfo) == 10); + assert(sizeof(pCastSpellInfo) / sizeof(*pCastSpellInfo.data()) == 10); for (uint i = 0; i < 10; ++i) if (pCastSpellInfo[i].field_8 & 0x3CA) { @@ -2245,10 +2245,10 @@ } } - assert(sizeof(pCastSpellInfo) / sizeof(*pCastSpellInfo) == 10); + assert(sizeof(pCastSpellInfo) / sizeof(*pCastSpellInfo.data()) == 10); for (uint i = 0; i < 10; ++i) { - auto spell = pCastSpellInfo + i; + auto spell = &pCastSpellInfo[i]; if (!spell->spellnum) continue; @@ -2264,7 +2264,7 @@ } } - int result = pCastSpellInfo->PushCastSpellInfo(a1, uPlayerID, a4, a5, a6); + int result = pCastSpellInfo.data()->PushCastSpellInfo(a1, uPlayerID, a4, a5, a6); if ( result != -1 ) { if ( a5 & 2 ) @@ -5689,7 +5689,7 @@ signed int _v733 = 0; if ( (signed int)uNumActors > 0 ) { - v518 = pActors;//[0].uAIState; + v518 = pActors.data();//[0].uAIState; auto _v726 = uNumActors; do { @@ -6655,7 +6655,7 @@ if (!player->CanAct()) return; - pCastSpellInfo->_427D48(uActiveCharacter); + pCastSpellInfo.data()->_427D48(uActiveCharacter); //v3 = 0; if (pParty->Invisible()) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); @@ -7034,7 +7034,7 @@ } else { - v1 = pActors; + v1 = pActors.data(); while ( 1 ) { v2 = abs(v1->vInitialPosition.x - pParty->vPosition.x); @@ -7652,7 +7652,7 @@ v24 = pPlayers[uActiveCharacter]->GetAttackRecoveryTime(false); if ( !pParty->bTurnBasedModeOn ) pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333)); - pCastSpellInfo->_427D48(uActiveCharacter); + pCastSpellInfo.data()->_427D48(uActiveCharacter); pTurnEngine->_40471C(); } }
--- a/mm7_data.cpp Sat Jun 08 19:34:33 2013 +0200 +++ b/mm7_data.cpp Sat Jun 08 21:33:22 2013 +0200 @@ -37,7 +37,7 @@ struct stru262_TurnBased *pTurnEngine = new stru262_TurnBased; #include "CastSpellInfo.h" -CastSpellInfo pCastSpellInfo[10]; +std::array<CastSpellInfo, 10> pCastSpellInfo; CastSpellInfo stru_50CDB4; // idb #include "Viewport.h" @@ -53,11 +53,11 @@ stru298 stru_50FE08; // weak #include "Autonotes.h" -Autonote pAutonoteTxt[195]; // weak +std::array<Autonote, 195> pAutonoteTxt; // weak #include "Awards.h" -Award pAwards[105]; -AwardType achieved_awards[1000]; +std::array<Award, 105> pAwards; +std::array<AwardType, 1000> achieved_awards; int num_achieved_awards; int num_achieved_awards_2; @@ -259,7 +259,7 @@ struct UIAnimation *pUIAnum_Torchlight = &_uianim._pUIAnum_Torchlight; struct UIAnimation *pUIAnim_WizardEye = &_uianim._pUIAnim_WizardEye; -struct UIAnimation *pUIAnims[4] = +std::array<struct UIAnimation *, 4> pUIAnims = { &_uianim._pUIAnim_Food, &_uianim._pUIAnim_Gold, @@ -275,8 +275,8 @@ #include "MM7.h" -stat_coord stat_string_coord[26] = //4E2940 -{ +std::array<stat_coord, 26> stat_string_coord = //4E2940 +{{ {0x1A, 0x39, 0xDC, 0x12}, {0x1A, 0x4A, 0xDC, 0x12}, {0x1A, 0x5B, 0xDC, 0x12}, @@ -303,6 +303,7 @@ {0x111, 0x116, 0xBA, 0x12}, {0x111, 0x129, 0xBA, 0x12}, {0x13E, 0x12, 0x89, 0x12}, +} };