# HG changeset patch # User Nomad # Date 1364062971 -7200 # Node ID a464d28566a6e8e43156cd01177cdbc79585cc1f # Parent a84db04439a4db9d0e65edc0c9f2e075515b7429 days_played_without_rest diff -r a84db04439a4 -r a464d28566a6 Events.cpp --- a/Events.cpp Sat Mar 23 19:47:18 2013 +0200 +++ b/Events.cpp Sat Mar 23 20:22:51 2013 +0200 @@ -440,11 +440,11 @@ break; } if ( !_strcmpi(v16, "pcout01") ) // moving to harmondale from emerald isle - { + { Rest(0x2760u); pParty->RestAndHeal(); - pParty->field_764 = 0; - } + pParty->days_played_without_rest = 0; + } if ( !v15 || v128 == 3 ) { pCurrentScreen = v128; diff -r a84db04439a4 -r a464d28566a6 Game.cpp --- a/Game.cpp Sat Mar 23 19:47:18 2013 +0200 +++ b/Game.cpp Sat Mar 23 20:22:51 2013 +0200 @@ -395,7 +395,7 @@ ++pPlayer; } while ( (signed int)pPlayer < (signed int)pParty->pHirelings ); - pParty->field_764 = 0; + pParty->days_played_without_rest = 0; pParty->uTimePlayed += 0x276000ui64; LOWORD(pParty->uFlags) &= ~0x204; pParty->SetGold(0); diff -r a84db04439a4 -r a464d28566a6 Party.cpp --- a/Party.cpp Sat Mar 23 19:47:18 2013 +0200 +++ b/Party.cpp Sat Mar 23 20:22:51 2013 +0200 @@ -1023,16 +1023,11 @@ v2->Zero(); if ( v2->pConditions[14] || v2->pConditions[15] || v2->pConditions[16] ) goto LABEL_33; - LODWORD(v2->pConditions[13]) = 0; - HIDWORD(v2->pConditions[13]) = 0; - LODWORD(v2->pConditions[4]) = 0; - HIDWORD(v2->pConditions[4]) = 0; - LODWORD(v2->pConditions[2]) = 0; - HIDWORD(v2->pConditions[2]) = 0; - LODWORD(v2->pConditions[3]) = 0; - HIDWORD(v2->pConditions[3]) = 0; - LODWORD(v2->pConditions[1]) = 0; - HIDWORD(v2->pConditions[1]) = 0; + v2->pConditions[13] = 0; + v2->pConditions[4] = 0; + v2->pConditions[2] = 0; + v2->pConditions[3] = 0; + v2->pConditions[1] = 0; v2->uTimeToRecovery = 0; v2->sHealth = v2->GetMaxHealth(); v5 = v2->GetMaxMana(); @@ -1094,5 +1089,5 @@ ++v15; } while ( v15 < 4 ); - pParty->field_764 = 0; + pParty->days_played_without_rest = 0; } \ No newline at end of file diff -r a84db04439a4 -r a464d28566a6 Party.h --- a/Party.h Sat Mar 23 19:47:18 2013 +0200 +++ b/Party.h Sat Mar 23 20:22:51 2013 +0200 @@ -152,7 +152,7 @@ uCurrentTimeSecond = 0; field_6FC = 0; - field_764 = 0; + days_played_without_rest = 0; vPosition.y = 0; vPosition.z = 0; @@ -262,7 +262,7 @@ int field_74C; __int16 field_750[5]; __int16 field_75A[5]; - char field_764; // num hours resting or some sort of. + unsigned char days_played_without_rest; unsigned __int8 _quest_bits[64]; unsigned __int8 pArcomageWins[16]; char field_7B5_in_arena_quest; diff -r a84db04439a4 -r a464d28566a6 Player.cpp --- a/Player.cpp Sat Mar 23 19:47:18 2013 +0200 +++ b/Player.cpp Sat Mar 23 20:22:51 2013 +0200 @@ -6792,7 +6792,6 @@ void Player::Zero() { Player *v1; // esi@1 - void *result; // eax@1 v1 = this; this->sLevelModifier = 0; @@ -6813,7 +6812,7 @@ this->field_E8 = 0; this->field_E4 = 0; this->field_E0 = 0; - result = memset(&this->sResFireBonus, 0, 0x16u); + memset(&this->sResFireBonus, 0, 0x16u); v1->field_1A97 = 0; v1->_ranged_dmg_bonus = 0; v1->field_1A95 = 0; diff -r a84db04439a4 -r a464d28566a6 Player.h --- a/Player.h Sat Mar 23 19:47:18 2013 +0200 +++ b/Player.h Sat Mar 23 20:22:51 2013 +0200 @@ -574,6 +574,7 @@ inline bool Eradicated() {return pConditions[Condition::Condition_Eradicated] != 0;} inline bool Zombie() {return pConditions[Condition::Condition_Zombie] != 0;} inline bool Cursed() {return pConditions[Condition::Condition_Cursed] != 0;} + inline bool Pertified() {return pConditions[Condition::Condition_Pertified] != 0;} diff -r a84db04439a4 -r a464d28566a6 mm7_4.cpp --- a/mm7_4.cpp Sat Mar 23 19:47:18 2013 +0200 +++ b/mm7_4.cpp Sat Mar 23 20:22:51 2013 +0200 @@ -2421,7 +2421,7 @@ //char *v6; // ecx@5 //Player *v7; // esi@8 //char *v8; // ecx@12 - Player *pPlayer; // esi@15 + //Player *pPlayer; // esi@15 //void *v10; // esi@25 unsigned int v11; // ecx@27 signed int v12; // edi@29 @@ -2467,23 +2467,23 @@ signed int v52; // ecx@130 int v53; // eax@131 Player *v54; // eax@141 - unsigned int v55; // [sp-8h] [bp-38h]@18 + //unsigned int v55; // [sp-8h] [bp-38h]@18 unsigned int v56; // [sp-8h] [bp-38h]@55 - int v57; // [sp-4h] [bp-34h]@18 + //int v57; // [sp-4h] [bp-34h]@18 int v58; // [sp-4h] [bp-34h]@33 int v59; // [sp-4h] [bp-34h]@55 unsigned int v60; // [sp+10h] [bp-20h]@1 unsigned int v61; // [sp+14h] [bp-1Ch]@1 Player **v62; // [sp+14h] [bp-1Ch]@50 - unsigned int a2; // [sp+18h] [bp-18h]@1 + //unsigned int a2; // [sp+18h] [bp-18h]@1 signed int a2a; // [sp+18h] [bp-18h]@47 signed int v65; // [sp+1Ch] [bp-14h]@47 - a2 = pParty->uCurrentHour; + //a2 = pParty->uCurrentHour; v61 = pParty->uDaysPlayed; v60 = pEventTimer->uTimeElapsed; - pParty->uTimePlayed += (signed int)pEventTimer->uTimeElapsed; - v0 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60; + pParty->uTimePlayed += pEventTimer->uTimeElapsed; + v0 = (signed __int64)(pParty->uTimePlayed * 0.234375) / 60; v1 = v0; v0 /= 60i64; v2 = v0; @@ -2496,7 +2496,7 @@ pParty->uDaysPlayed = (unsigned int)v3 % 28; pParty->uCurrentMonth = v4 % 12; pParty->uCurrentYear = v4 / 0xC + game_starting_year; - if ( pParty->uCurrentHour >= 3 && ((signed int)a2 < 3 || (unsigned int)v3 % 28 > v61) ) + if ( pParty->uCurrentHour >= 3 && (pParty->uCurrentHour < 3 || pParty->uDaysPlayed > v61) ) // new day dawns { pParty->pHirelings[0].bHasUsedTheAbility = false; pParty->pHirelings[1].bHasUsedTheAbility = false; @@ -2504,56 +2504,41 @@ for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i) pNPCStats->pNewNPCData[i].bHasUsedTheAbility = false; - ++pParty->field_764; - if ( pParty->field_764 > 1u ) + ++pParty->days_played_without_rest; + if (pParty->days_played_without_rest > 1) { for (uint i = 0; i < 4; ++i) - pParty->pPlayers[i].SetCondition(1, 0); - - if ( pParty->uNumFoodRations ) - { - Party::TakeFood(1u); - } + pParty->pPlayers[i].SetCondition(Player::Condition_Weak, 0); + + if (pParty->uNumFoodRations) + Party::TakeFood(1); else - { for (uint i = 0; i < 4; ++i) - pParty->pPlayers[i].sHealth = pParty->pPlayers[i].sHealth / ((unsigned __int8)pParty->field_764 + 1) + 1; - } - if ( pParty->field_764 > 3u ) - { - pPlayer = pParty->pPlayers; - do + pParty->pPlayers[i].sHealth = pParty->pPlayers[i].sHealth / (pParty->days_played_without_rest + 1) + 1; + + if (pParty->days_played_without_rest > 3) + for (uint i = 0; i < 4; ++i) { - pPlayer->Zero(); - if ( !(pPlayer->pConditions[15] | pPlayer->pConditions[16] | pPlayer->pConditions[14]) ) + auto player = pParty->pPlayers + i; + + player->Zero(); + + if (!player->Pertified() && !player->Eradicated() && !player->Dead()) { - if ( rand() % 100 < 5 * (unsigned __int8)pParty->field_764 ) - { - v57 = 0; - v55 = 14; -LABEL_21: - pPlayer->SetCondition(v55, v57); - goto LABEL_22; - } - if ( rand() % 100 < 10 * (unsigned __int8)pParty->field_764 ) - { - v57 = 0; - v55 = 5; - goto LABEL_21; - } + if (rand() % 100 < 5 * pParty->days_played_without_rest ) + player->SetCondition(Player::Condition_Dead, 0); + if (rand() % 100 < 10 * pParty->days_played_without_rest ) + player->SetCondition(Player::Condition_Insane, 0); } -LABEL_22: - ++pPlayer; } - while ( (signed int)pPlayer < (signed int)pParty->pHirelings ); - } - } - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) + } + if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) pOutdoor->SetFog(); for (uint i = 0; i < 4; ++i) pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0; } + v11 = LODWORD(pParty->uTimePlayed); if ( pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed ) { diff -r a84db04439a4 -r a464d28566a6 mm7_5.cpp --- a/mm7_5.cpp Sat Mar 23 19:47:18 2013 +0200 +++ b/mm7_5.cpp Sat Mar 23 20:22:51 2013 +0200 @@ -1694,7 +1694,7 @@ ++pPlayer7; } while ( (signed int)pPlayer7 < (signed int)pParty->pHirelings ); - ++pParty->field_764; + ++pParty->days_played_without_rest; } Party::TakeFood((unsigned int)pNPCData4); } @@ -1707,7 +1707,7 @@ ++pPlayer8; } while ( (signed int)pPlayer8 < (signed int)pParty->pHirelings ); - ++pParty->field_764; + ++pParty->days_played_without_rest; } pPaletteManager->ResetNonLocked(); pSpriteFrameTable->ResetSomeSpriteFlags(); @@ -2568,11 +2568,11 @@ //goto LABEL_615; dword_506F14 = 2; pParty->RestAndHeal(); - pParty->field_764 = 0; - pParty->pPlayers[3].pConditions[2] = pParty->uTimePlayed; - pParty->pPlayers[2].pConditions[2] = pParty->uTimePlayed; - pParty->pPlayers[1].pConditions[2] = pParty->uTimePlayed; - pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed; + pParty->days_played_without_rest = 0; + pParty->pPlayers[3].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; + pParty->pPlayers[2].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; + pParty->pPlayers[1].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; + pParty->pPlayers[0].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; continue; case UIMSG_68: if ( pMessageQueue_50CBD0->uNumMessages ) @@ -2715,11 +2715,11 @@ //LABEL_615: dword_506F14 = 2; pParty->RestAndHeal(); - pParty->field_764 = 0; - pParty->pPlayers[3].pConditions[2] = pParty->uTimePlayed; - pParty->pPlayers[2].pConditions[2] = pParty->uTimePlayed; - pParty->pPlayers[1].pConditions[2] = pParty->uTimePlayed; - pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed; + pParty->days_played_without_rest = 0; + pParty->pPlayers[3].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; + pParty->pPlayers[2].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; + pParty->pPlayers[1].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; + pParty->pPlayers[0].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; } continue; case UIMSG_AlreadyResting: