Mercurial > mm7
diff UiGame.cpp @ 1205:8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
author | Grumpy7 |
---|---|
date | Sun, 09 Jun 2013 00:30:48 +0200 |
parents | 0dbf6c4dd029 |
children | 96a81634669e |
line wrap: on
line diff
--- a/UiGame.cpp Sat Jun 08 21:47:29 2013 +0200 +++ b/UiGame.cpp Sun Jun 09 00:30:48 2013 +0200 @@ -294,8 +294,8 @@ a1.uFrameWidth = 400; a1.uFrameZ = a1.uFrameX + 399; a1.DrawMessageBox(0); - sprintfex(pTmpBuf2, "NPC%03d", v6->uPortraitID); - v8 = pIcons_LOD->LoadTexture(pTmpBuf2, TEXTURE_16BIT_PALETTE); + sprintfex(pTmpBuf2.data(), "NPC%03d", v6->uPortraitID); + v8 = pIcons_LOD->LoadTexture(pTmpBuf2.data(), TEXTURE_16BIT_PALETTE); pRenderer->DrawTextureIndexed( a1.uFrameX + 22, a1.uFrameY + 36, @@ -304,14 +304,14 @@ if ( v9 ) { v10 = v6->pName; - v11 = pTmpBuf; - sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v10, aNPCProfessionNames[v9]); + v11 = pTmpBuf.data(); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], v10, aNPCProfessionNames[v9]); } else { v12 = v6->pName; - v11 = pTmpBuf; - strcpy(pTmpBuf, v12); + v11 = pTmpBuf.data(); + strcpy(pTmpBuf.data(), v12); } v13 = TargetColor(0xFFu, 0xFFu, 0x9Bu); a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u); @@ -498,13 +498,13 @@ if (pNPC->uProfession) { - assert(pNPC->uProfession < sizeof(aNPCProfessionNames) / sizeof(*aNPCProfessionNames)); // sometimes buffer overflows; errors emerge both here and in dialogue text - sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], pNPC->pName, aNPCProfessionNames[pNPC->uProfession]);//^Pi[%s] %s + assert(pNPC->uProfession < sizeof(aNPCProfessionNames) / sizeof(*aNPCProfessionNames.data())); // sometimes buffer overflows; errors emerge both here and in dialogue text + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], pNPC->pName, aNPCProfessionNames[pNPC->uProfession]);//^Pi[%s] %s } else - strcpy(pTmpBuf, pNPC->pName); + strcpy(pTmpBuf.data(), pNPC->pName); - v51.DrawTitleText(pFontArrus, 483, 112, v2, pTmpBuf, 3); + v51.DrawTitleText(pFontArrus, 483, 112, v2, pTmpBuf.data(), 3); pParty->GetPartyFame(); pInString = nullptr; @@ -537,8 +537,8 @@ break; case DIALOGUE_ARENA_REWARD: - sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[576], gold_transaction_amount);// "Congratulations on your win: here's your stuff: %u gold." - pInString = pTmpBuf; + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[576], gold_transaction_amount);// "Congratulations on your win: here's your stuff: %u gold." + pInString = pTmpBuf.data(); break; case DIALOGUE_ARENA_ALREADY_WON: @@ -798,20 +798,20 @@ pFont = pFontArrus; if ( current_npc_text && !byte_5B0938[0] ) - strcpy(byte_5B0938, current_npc_text); + strcpy(byte_5B0938.data(), current_npc_text); v5.uFrameWidth = game_viewport_width; v5.uFrameZ = 452; - v1 = pFontArrus->CalcTextHeight(byte_5B0938, &v5, 12, 0) + 7; + v1 = pFontArrus->CalcTextHeight(byte_5B0938.data(), &v5, 12, 0) + 7; if ( 352 - v1 < 8 ) { pFont = pFontCreate; - v1 = pFontCreate->CalcTextHeight(byte_5B0938, &v5, 12, 0) + 7; + v1 = pFontCreate->CalcTextHeight(byte_5B0938.data(), &v5, 12, 0) + 7; } pRenderer->_4A6A68(8, 352 - v1, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - v1); pRenderer->DrawTextureIndexed(8, 347 - v1, pTexture_591428); - v2 = FitTextInAWindow(byte_5B0938, pFont, &v5, 0xCu, 0); + v2 = FitTextInAWindow(byte_5B0938.data(), pFont, &v5, 0xCu, 0); pGUIWindow2->DrawText(pFont, 12, 354 - v1, 0, v2, 0, 0, 0); pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar); if ( pGUIWindow2->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS) @@ -819,7 +819,7 @@ if ( pGUIWindow2->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) { pGUIWindow2->receives_keyboard_input_2 = WINDOW_INPUT_NONE; - strcpy(GameUI_Footer_TimedString, (const char *)pKeyActionMap->pPressedKeysBuffer); + strcpy(GameUI_Footer_TimedString.data(), (const char *)pKeyActionMap->pPressedKeysBuffer); LABEL_16: sub_4452BB(); return; @@ -828,7 +828,7 @@ return; pGUIWindow2->receives_keyboard_input_2 = WINDOW_INPUT_NONE; LABEL_15: - memset(GameUI_Footer_TimedString, 0, 0xC8u); + memset(GameUI_Footer_TimedString.data(), 0, 0xC8u); goto LABEL_16; } if ( pGUIWindow2->ptr_1C == (void *)26 ) @@ -892,7 +892,7 @@ if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor || (*(float *)&v23 = 0.0, (signed int)v1 <= 0) ) { LABEL_14: - v17 = pMapStats->GetMapInfo(pCurrentMapName); + v17 = pMapStats->GetMapInfo(pCurrentMapName.data()); if ( v17 == v2 ) result = "No Maze Info for this maze on file!"; else @@ -1022,38 +1022,38 @@ pRenderer->DrawTextureTransparent(window->uFrameX + 24, window->uFrameY + 24, v13); - sprintfex(pTmpBuf, "\f%05d", ui_character_header_text_color); - sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], player->pName, pClassNames[player->classType]); // "%s the %s" - strcat(pTmpBuf, pTmpBuf2); - strcat(pTmpBuf, "\f00000\n"); + sprintfex(pTmpBuf.data(), "\f%05d", ui_character_header_text_color); + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[429], player->pName, pClassNames[player->classType]); // "%s the %s" + strcat(pTmpBuf.data(), pTmpBuf2.data()); + strcat(pTmpBuf.data(), "\f00000\n"); v20 = UI_GetHealthManaStringColor(player->sHealth, player->GetMaxHealth()); - sprintf(pTmpBuf2, "%s : \f%05u%d\f00000 / %d\n", + sprintf(pTmpBuf2.data(), "%s : \f%05u%d\f00000 / %d\n", pGlobalTXT_LocalizationStrings[108], // "Hit Points" v20, player->sHealth, player->GetMaxHealth()); - strcat(pTmpBuf, pTmpBuf2); + strcat(pTmpBuf.data(), pTmpBuf2.data()); v24 = UI_GetHealthManaStringColor(player->sMana, player->GetMaxMana()); - sprintf(pTmpBuf2, "%s : \f%05u%d\f00000 / %d\n", + sprintf(pTmpBuf2.data(), "%s : \f%05u%d\f00000 / %d\n", pGlobalTXT_LocalizationStrings[212], // "Spell Points" v24, player->sMana, player->GetMaxMana()); - strcat(pTmpBuf, pTmpBuf2); + strcat(pTmpBuf.data(), pTmpBuf2.data()); v25 = player->GetMajorConditionIdx(); - sprintf(pTmpBuf2, "%s: \f%05d%s\f00000\n", + sprintf(pTmpBuf2.data(), "%s: \f%05d%s\f00000\n", pGlobalTXT_LocalizationStrings[47], // "Condition GetConditionDrawColor(v25), aCharacterConditionNames[v25]); - strcat(pTmpBuf, pTmpBuf2); + strcat(pTmpBuf.data(), pTmpBuf2.data()); v28 = player->uQuickSpell; if ( v28 ) v29 = pSpellStats->pInfos[v28].pShortName; else v29 = pGlobalTXT_LocalizationStrings[153]; - sprintfex(pTmpBuf2, "%s: %s", pGlobalTXT_LocalizationStrings[172], v29); // "Quick Spell" - strcat(pTmpBuf, pTmpBuf2); + sprintfex(pTmpBuf2.data(), "%s: %s", pGlobalTXT_LocalizationStrings[172], v29); // "Quick Spell" + strcat(pTmpBuf.data(), pTmpBuf2.data()); - window->DrawText(pFontArrus, 120, 22, 0, pTmpBuf, 0, 0, 0); + window->DrawText(pFontArrus, 120, 22, 0, pTmpBuf.data(), 0, 0, 0); uFramesetIDa = 0; for (uint i = 0; i < 24; ++i) @@ -1072,8 +1072,8 @@ v39 = ""; if ( uFramesetIDa == 0 ) v39 = pGlobalTXT_LocalizationStrings[153]; // "None" - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[450], v39); // "Active Spells: %s" - window->DrawText(pFontArrus, 14, 114, 0, pTmpBuf, 0, 0, 0); + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[450], v39); // "Active Spells: %s" + window->DrawText(pFontArrus, 14, 114, 0, pTmpBuf.data(), 0, 0, 0); } @@ -1148,12 +1148,12 @@ pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 94 * v43 + 89, 0x12u, ui_character_header_text_color, player->pName, 84, 0); if ( v43 == 0 ) pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, 0x2Fu, 0, pGlobalTXT_LocalizationStrings[131], 60, 0); //Уров. - sprintf(pTmpBuf, "%lu", player->GetActualLevel()); + sprintf(pTmpBuf.data(), "%lu", player->GetActualLevel()); if ( player->GetActualLevel() <= player->GetBaseLevel()) v5 = player->GetExperienceDisplayColor(); else v5 = ui_character_bonus_text_color; - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, 0x2Fu, v5, pTmpBuf, 84, 0); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, 0x2Fu, v5, pTmpBuf.data(), 84, 0); v6 = v45 + 47; if ( v43 == 0 ) pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v45 + 47, 0, pGlobalTXT_LocalizationStrings[41], 60, 0);//Класс @@ -1161,26 +1161,26 @@ v7 = v45 + v6; if ( v43 == 0 ) pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v7, 0, pGlobalTXT_LocalizationStrings[107], 60, 0);//Здор. - sprintf(pTmpBuf, "%d", player->sHealth); + sprintf(pTmpBuf.data(), "%d", player->sHealth); v9 = UI_GetHealthManaStringColor(player->sHealth, player->GetMaxHealth()); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v7, v9, pTmpBuf, 84, 0); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v7, v9, pTmpBuf.data(), 84, 0); v10 = v45 + v7; if ( v43 == 0 ) pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v10, 0, pGlobalTXT_LocalizationStrings[209], 60, 0);//Мана - sprintf(pTmpBuf, "%d", player->sMana); + sprintf(pTmpBuf.data(), "%d", player->sMana); v12 = UI_GetHealthManaStringColor(player->sMana, player->GetMaxMana()); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v10, v12, pTmpBuf, 84, 0); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v10, v12, pTmpBuf.data(), 84, 0); v13 = v45 + v10; if ( v43 == 0 ) pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v13, 0, pGlobalTXT_LocalizationStrings[0], 60, 0);//Класс брони - sprintf(pTmpBuf, "%d", player->GetActualAC()); + sprintf(pTmpBuf.data(), "%d", player->GetActualAC()); v18 = UI_GetHealthManaStringColor(player->GetActualAC(), player->GetBaseAC()); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v13, v18, pTmpBuf, 84, 0); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v13, v18, pTmpBuf.data(), 84, 0); v19 = v45 + v13; if ( !v43 ) pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v19, 0, pGlobalTXT_LocalizationStrings[18], 60, 0);//Атака - sprintf(pTmpBuf, "%+d", player->GetActualAttack(0)); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v19, 0, pTmpBuf, 84, 0); + sprintf(pTmpBuf.data(), "%+d", player->GetActualAttack(0)); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v19, 0, pTmpBuf.data(), 84, 0); v21 = v45 + v19; if ( !v43 ) pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v21, 0, pGlobalTXT_LocalizationStrings[66], 60, 0);//Повр. @@ -1189,8 +1189,8 @@ v23 = v45 + v21; if ( !v43 ) pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v23, 0, pGlobalTXT_LocalizationStrings[203], 60, 0);// Стрелять - sprintf(pTmpBuf, "%+d", player->GetRangedAttack()); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v23, 0, pTmpBuf, 84, 0); + sprintf(pTmpBuf.data(), "%+d", player->GetRangedAttack()); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v23, 0, pTmpBuf.data(), 84, 0); v25 = v45 + v23; if ( !v43 ) pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v25, 0, pGlobalTXT_LocalizationStrings[66], 60, 0);//Повр. @@ -1210,13 +1210,13 @@ --v30; } while ( v30 ); - sprintf(pTmpBuf, "%lu", v28); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v27, 0, pTmpBuf, 84, 0); + sprintf(pTmpBuf.data(), "%lu", v28); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v27, 0, pTmpBuf.data(), 84, 0); v31 = v45 + v27; if ( !v43 ) pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v31, 0, pGlobalTXT_LocalizationStrings[168], 60, 0);//Очки - sprintf(pTmpBuf, "%lu", player->uSkillPoints); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v31, player->uSkillPoints ? ui_character_bonus_text_color : ui_character_default_text_color, pTmpBuf, 84, 0); + sprintf(pTmpBuf.data(), "%lu", player->uSkillPoints); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v31, player->uSkillPoints ? ui_character_bonus_text_color : ui_character_default_text_color, pTmpBuf.data(), 84, 0); v32 = v45 + v31; v48 = player->GetMajorConditionIdx(); if ( !v43 ) @@ -1247,11 +1247,11 @@ else v39 = ui_character_bonus_text_color; - sprintf(pTmpBuf, "%s: \f%05d%s\f00000", pGlobalTXT_LocalizationStrings[180], v39, GetReputationString(v38));//Reputation - pGUIWindow_CurrentMenu->DrawText(pFontArrus, 22, 323, 0, pTmpBuf, 0, 0, 0); + sprintf(pTmpBuf.data(), "%s: \f%05d%s\f00000", pGlobalTXT_LocalizationStrings[180], v39, GetReputationString(v38));//Reputation + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 22, 323, 0, pTmpBuf.data(), 0, 0, 0); - sprintf(pTmpBuf, "\r261%s: %d", pGlobalTXT_LocalizationStrings[84], pParty->GetPartyFame());// Fame Слава - pGUIWindow_CurrentMenu->DrawText(pFontArrus, 0, 323, 0, pTmpBuf, 0, 0, 0); + sprintf(pTmpBuf.data(), "\r261%s: %d", pGlobalTXT_LocalizationStrings[84], pParty->GetPartyFame());// Fame Слава + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 0, 323, 0, pTmpBuf.data(), 0, 0, 0); } @@ -1290,10 +1290,10 @@ if ( uGameState != GAME_STATE_FINAL_WINDOW ) { v2 = sub_44100D() != 0 ? 381 : 322; - sprintf(pTmpBuf, "\r087%lu", pParty->uNumFoodRations); - pPrimaryWindow->DrawText(pFontSmallnum, 0, v2, uGameUIFontMain, pTmpBuf, 0, 0, uGameUIFontShadow); - sprintf(pTmpBuf, "\r028%lu", pParty->uNumGold); - pPrimaryWindow->DrawText(pFontSmallnum, 0, v2, uGameUIFontMain, pTmpBuf, 0, 0, uGameUIFontShadow); + sprintf(pTmpBuf.data(), "\r087%lu", pParty->uNumFoodRations); + pPrimaryWindow->DrawText(pFontSmallnum, 0, v2, uGameUIFontMain, pTmpBuf.data(), 0, 0, uGameUIFontShadow); + sprintf(pTmpBuf.data(), "\r028%lu", pParty->uNumGold); + pPrimaryWindow->DrawText(pFontSmallnum, 0, v2, uGameUIFontMain, pTmpBuf.data(), 0, 0, uGameUIFontShadow); } } @@ -1392,12 +1392,12 @@ pRenderer->DrawTextureRGB(0, 352, pTexture_StatusBar); if (GameUI_Footer_TimeLeft) - v1 = GameUI_Footer_TimedString; + v1 = GameUI_Footer_TimedString.data(); else { if (!pFooterString[0]) return; - v1 = pFooterString; + v1 = pFooterString.data(); } v5 = pFontLucida->AlignText_Center(450, v1); @@ -1416,18 +1416,18 @@ { if ( GameUI_Footer_TimeLeft ) { - for ( i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString); + for ( i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); i > 450; - i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString) ) - byte_5C3427[strlen(GameUI_Footer_TimedString)] = 0; + i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) ) + byte_5C3427[strlen(GameUI_Footer_TimedString.data())] = 0; } else { - strcpy(pFooterString, v1); - for ( j = pFontLucida->GetLineWidth(pFooterString); + strcpy(pFooterString.data(), v1); + for ( j = pFontLucida->GetLineWidth(pFooterString.data()); j > 450; - j = pFontLucida->GetLineWidth(pFooterString) ) - GameUI_Footer_TimedString[strlen(pFooterString) + 199] = 0; + j = pFontLucida->GetLineWidth(pFooterString.data()) ) + GameUI_Footer_TimedString[strlen(pFooterString.data()) + 199] = 0; } } } @@ -1453,28 +1453,28 @@ pRenderer->DrawTextureRGB(0, 352u, pTexture_StatusBar); if ( GameUI_Footer_TimeLeft ) { - v1 = GameUI_Footer_TimedString; - v2 = pFontLucida->GetLineWidth(GameUI_Footer_TimedString); + v1 = GameUI_Footer_TimedString.data(); + v2 = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); v3 = 450; while ( v2 > 450 ) { - v4 = strlen(GameUI_Footer_TimedString); + v4 = strlen(GameUI_Footer_TimedString.data()); v5 = pFontLucida; byte_5C3427[v4] = 0; - v2 = pFontLucida->GetLineWidth(GameUI_Footer_TimedString); + v2 = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); } } else { - v1 = pFooterString; - v6 = pFontLucida->GetLineWidth(pFooterString); + v1 = pFooterString.data(); + v6 = pFontLucida->GetLineWidth(pFooterString.data()); v3 = 450; while ( v6 > 450 ) { - v7 = strlen(pFooterString); + v7 = strlen(pFooterString.data()); v8 = pFontLucida; GameUI_Footer_TimedString[v7 + 199] = 0; - v6 = pFontLucida->GetLineWidth(pFooterString); + v6 = pFontLucida->GetLineWidth(pFooterString.data()); } } v9 = *v1 == 0; @@ -1618,8 +1618,8 @@ return; } v31 = pSpriteObjects[v30].stru_24.GetDisplayName(); - v28 = pTmpBuf; - sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[470], v31);// "Get %s" + v28 = pTmpBuf.data(); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[470], v31);// "Get %s" } else { @@ -1803,13 +1803,13 @@ return; } pActor = &pActors[v19]; - v28 = pTmpBuf; + v28 = pTmpBuf.data(); v29 = pActor->dword_000334_unique_name; if ( v29 ) v40 = pMonsterStats->pPlaceStrings[v29]; else v40 = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].pName; - strncpy(pTmpBuf, v40, 0x7D0u); + strncpy(pTmpBuf.data(), v40, 0x7D0u); } v26 = v28; //LABEL_87: