Merge branch 'master' of https://github.com/rheit/zdoom into z_osx_clean

This commit is contained in:
alexey.lysiuk 2014-08-16 13:28:55 +03:00
commit cbe6cf2d41
12 changed files with 76 additions and 31 deletions

View file

@ -5,6 +5,7 @@
#include "doomtype.h" #include "doomtype.h"
#include "doomdef.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -62,4 +63,25 @@ struct FFileList
void ScanDirectory(TArray<FFileList> &list, const char *dirpath); void ScanDirectory(TArray<FFileList> &list, const char *dirpath);
//==========================================================================
//
// Functions to compensate for a tic being a bit short.
// Since ZDoom uses a milliseconds timer for game timing
// 35 tics are actually only 0.98 seconds.
// For real time display this needs to be adjusted
//
//==========================================================================
inline int AdjustTics(int tics)
{
return (tics * 98) / 100;
}
inline int Tics2Seconds(int tics)
{
return (tics * 98) / (100 * TICRATE);
}
#endif #endif

View file

@ -25,6 +25,11 @@ void ABasicArmor::Serialize (FArchive &arc)
{ {
Super::Serialize (arc); Super::Serialize (arc);
arc << SavePercent << BonusCount << MaxAbsorb << MaxFullAbsorb << AbsorbCount << ArmorType; arc << SavePercent << BonusCount << MaxAbsorb << MaxFullAbsorb << AbsorbCount << ArmorType;
if (SaveVersion >= 4511)
{
arc << ActualSaveAmount;
}
} }
//=========================================================================== //===========================================================================
@ -69,6 +74,7 @@ AInventory *ABasicArmor::CreateCopy (AActor *other)
copy->Icon = Icon; copy->Icon = Icon;
copy->BonusCount = BonusCount; copy->BonusCount = BonusCount;
copy->ArmorType = ArmorType; copy->ArmorType = ArmorType;
copy->ActualSaveAmount = ActualSaveAmount;
GoAwayAndDie (); GoAwayAndDie ();
return copy; return copy;
} }
@ -268,6 +274,7 @@ bool ABasicArmorPickup::Use (bool pickup)
armor->MaxAbsorb = MaxAbsorb; armor->MaxAbsorb = MaxAbsorb;
armor->MaxFullAbsorb = MaxFullAbsorb; armor->MaxFullAbsorb = MaxFullAbsorb;
armor->ArmorType = this->GetClass()->TypeName; armor->ArmorType = this->GetClass()->TypeName;
armor->ActualSaveAmount = SaveAmount;
return true; return true;
} }
@ -360,6 +367,7 @@ bool ABasicArmorBonus::Use (bool pickup)
armor->MaxAbsorb = MaxAbsorb; armor->MaxAbsorb = MaxAbsorb;
armor->ArmorType = this->GetClass()->TypeName; armor->ArmorType = this->GetClass()->TypeName;
armor->MaxFullAbsorb = MaxFullAbsorb; armor->MaxFullAbsorb = MaxFullAbsorb;
armor->ActualSaveAmount = MaxSaveAmount;
} }
armor->Amount = MIN(armor->Amount + saveAmount, MaxSaveAmount + armor->BonusCount); armor->Amount = MIN(armor->Amount + saveAmount, MaxSaveAmount + armor->BonusCount);

View file

@ -423,6 +423,7 @@ public:
int MaxFullAbsorb; int MaxFullAbsorb;
int BonusCount; int BonusCount;
FNameNoInit ArmorType; FNameNoInit ArmorType;
int ActualSaveAmount;
}; };
// BasicArmorPickup replaces the armor you have. // BasicArmorPickup replaces the armor you have.

View file

@ -886,8 +886,11 @@ class CommandDrawString : public SBarInfoCommand
} }
break; break;
case TIME: case TIME:
str.Format("%02d:%02d:%02d", (level.time/TICRATE)/3600, ((level.time/TICRATE)%3600)/60, (level.time/TICRATE)%60); {
int sec = Tics2Seconds(level.time);
str.Format("%02d:%02d:%02d", sec / 3600, (sec % 3600) / 60, sec % 60);
break; break;
}
case LOGTEXT: case LOGTEXT:
str = statusBar->CPlayer->LogText; str = statusBar->CPlayer->LogText;
break; break;

View file

@ -867,7 +867,7 @@ static void DrawTime()
: (hud_showtime < 6 : (hud_showtime < 6
? level.time ? level.time
: level.totaltime); : level.totaltime);
const int timeSeconds = timeTicks / TICRATE; const int timeSeconds = Tics2Seconds(timeTicks);
hours = timeSeconds / 3600; hours = timeSeconds / 3600;
minutes = (timeSeconds % 3600) / 60; minutes = (timeSeconds % 3600) / 60;
@ -994,7 +994,7 @@ void DrawHUD()
if (am_showtotaltime) if (am_showtotaltime)
{ {
seconds = level.totaltime / TICRATE; seconds = Tics2Seconds(level.totaltime);
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
DrawHudText(SmallFont, hudcolor_ttim, printstr, hudwidth-length, bottom, FRACUNIT); DrawHudText(SmallFont, hudcolor_ttim, printstr, hudwidth-length, bottom, FRACUNIT);
bottom -= fonth; bottom -= fonth;
@ -1004,14 +1004,14 @@ void DrawHUD()
{ {
if (level.clusterflags&CLUSTER_HUB) if (level.clusterflags&CLUSTER_HUB)
{ {
seconds = level.time /TICRATE; seconds = Tics2Seconds(level.time);
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
DrawHudText(SmallFont, hudcolor_time, printstr, hudwidth-length, bottom, FRACUNIT); DrawHudText(SmallFont, hudcolor_time, printstr, hudwidth-length, bottom, FRACUNIT);
bottom -= fonth; bottom -= fonth;
} }
// Single level time for hubs // Single level time for hubs
seconds= level.maptime /TICRATE; seconds= Tics2Seconds(level.maptime);
mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
DrawHudText(SmallFont, hudcolor_ltim, printstr, hudwidth-length, bottom, FRACUNIT); DrawHudText(SmallFont, hudcolor_ltim, printstr, hudwidth-length, bottom, FRACUNIT);
} }

View file

@ -1306,8 +1306,8 @@ void DBaseStatusBar::Draw (EHudState state)
} }
else if (automapactive) else if (automapactive)
{ {
int y, time = level.time / TICRATE, height; int y, time = Tics2Seconds(level.time), height;
int totaltime = level.totaltime / TICRATE; int totaltime = Tics2Seconds(level.totaltime);
EColorRange highlight = (gameinfo.gametype & GAME_DoomChex) ? EColorRange highlight = (gameinfo.gametype & GAME_DoomChex) ?
CR_UNTRANSLATED : CR_YELLOW; CR_UNTRANSLATED : CR_YELLOW;

View file

@ -586,29 +586,33 @@ private:
screen->DrawTexture (Images[back], left, top, DTA_CleanNoMove, true, DTA_Alpha, FRACUNIT*3/4, TAG_DONE); screen->DrawTexture (Images[back], left, top, DTA_CleanNoMove, true, DTA_Alpha, FRACUNIT*3/4, TAG_DONE);
screen->DrawTexture (Images[bars], left, top, DTA_CleanNoMove, true, TAG_DONE); screen->DrawTexture (Images[bars], left, top, DTA_CleanNoMove, true, TAG_DONE);
switch (CurrentPop) switch (CurrentPop)
{ {
case POP_Log: case POP_Log:
{
int seconds = Tics2Seconds(level.time);
// Draw the latest log message. // Draw the latest log message.
mysnprintf (buff, countof(buff), "%02d:%02d:%02d", mysnprintf(buff, countof(buff), "%02d:%02d:%02d",
(level.time/TICRATE)/3600, seconds / 3600,
((level.time/TICRATE)%3600)/60, (seconds % 3600) / 60,
(level.time/TICRATE)%60); (seconds) % 60);
screen->DrawText (SmallFont2, CR_UNTRANSLATED, left+210*xscale, top+8*yscale, buff, screen->DrawText(SmallFont2, CR_UNTRANSLATED, left + 210 * xscale, top + 8 * yscale, buff,
DTA_CleanNoMove, true, TAG_DONE); DTA_CleanNoMove, true, TAG_DONE);
if (CPlayer->LogText != NULL) if (CPlayer->LogText != NULL)
{ {
FBrokenLines *lines = V_BreakLines (SmallFont2, 272, CPlayer->LogText); FBrokenLines *lines = V_BreakLines(SmallFont2, 272, CPlayer->LogText);
for (i = 0; lines[i].Width >= 0; ++i) for (i = 0; lines[i].Width >= 0; ++i)
{ {
screen->DrawText (SmallFont2, CR_UNTRANSLATED, left+24*xscale, top+(18+i*12)*yscale, screen->DrawText(SmallFont2, CR_UNTRANSLATED, left + 24 * xscale, top + (18 + i * 12)*yscale,
lines[i].Text, DTA_CleanNoMove, true, TAG_DONE); lines[i].Text, DTA_CleanNoMove, true, TAG_DONE);
} }
V_FreeBrokenLines (lines); V_FreeBrokenLines(lines);
} }
break; break;
}
case POP_Keys: case POP_Keys:
// List the keys the player has. // List the keys the player has.

View file

@ -128,6 +128,7 @@ enum
ARMORINFO_SAVEPERCENT, ARMORINFO_SAVEPERCENT,
ARMORINFO_MAXABSORB, ARMORINFO_MAXABSORB,
ARMORINFO_MAXFULLABSORB, ARMORINFO_MAXFULLABSORB,
ARMORINFO_ACTUALSAVEAMOUNT,
}; };
struct CallReturn struct CallReturn
@ -4858,6 +4859,9 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args, const
case ARMORINFO_MAXFULLABSORB: case ARMORINFO_MAXFULLABSORB:
return equippedarmor->MaxFullAbsorb; return equippedarmor->MaxFullAbsorb;
case ARMORINFO_ACTUALSAVEAMOUNT:
return equippedarmor->ActualSaveAmount;
default: default:
return 0; return 0;
} }

View file

@ -434,8 +434,8 @@ static int R_PointOnSideSlow (fixed_t x, fixed_t y, node_t *node)
// add on a 386/486, but it certainly isn't on anything newer than that. // add on a 386/486, but it certainly isn't on anything newer than that.
fixed_t dx; fixed_t dx;
fixed_t dy; fixed_t dy;
fixed_t left; double left;
fixed_t right; double right;
if (!node->dx) if (!node->dx)
{ {
@ -466,8 +466,9 @@ static int R_PointOnSideSlow (fixed_t x, fixed_t y, node_t *node)
return 0; return 0;
} }
left = FixedMul ( node->dy>>FRACBITS , dx ); // we must use doubles here because the fixed point code will produce errors due to loss of precision for extremely short linedefs.
right = FixedMul ( dy , node->dx>>FRACBITS ); left = (double)node->dy * (double)dx;
right = (double)dy * (double)node->dx;
if (right < left) if (right < left)
{ {

View file

@ -420,7 +420,7 @@ static void StoreLevelStats()
LevelData[i].killcount = level.killed_monsters; LevelData[i].killcount = level.killed_monsters;
LevelData[i].totalsecrets = level.total_secrets; LevelData[i].totalsecrets = level.total_secrets;
LevelData[i].secretcount = level.found_secrets; LevelData[i].secretcount = level.found_secrets;
LevelData[i].leveltime = level.maptime; LevelData[i].leveltime = AdjustTics(level.maptime);
// Check for living monsters. On some maps it can happen // Check for living monsters. On some maps it can happen
// that the counter misses some. // that the counter misses some.
@ -490,7 +490,7 @@ void STAT_ChangeLevel(const char *newl)
} }
infostring.Format("%4d/%4d, %3d/%3d, %2d", statvals[0], statvals[1], statvals[2], statvals[3], validlevels); infostring.Format("%4d/%4d, %3d/%3d, %2d", statvals[0], statvals[1], statvals[2], statvals[3], validlevels);
FSessionStatistics *es = StatisticsEntry(sl, infostring, level.totaltime); FSessionStatistics *es = StatisticsEntry(sl, infostring, AdjustTics(level.totaltime));
for(unsigned i = 0; i < LevelData.Size(); i++) for(unsigned i = 0; i < LevelData.Size(); i++)
{ {

View file

@ -76,7 +76,7 @@ const char *GetVersionString();
// Use 4500 as the base git save version, since it's higher than the // Use 4500 as the base git save version, since it's higher than the
// SVN revision ever got. // SVN revision ever got.
#define SAVEVER 4510 #define SAVEVER 4511
#define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY2(x) #x
#define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x)

View file

@ -1460,7 +1460,7 @@ void WI_drawDeathmatchStats ()
// Draw game time // Draw game time
y += height + CleanYfac; y += height + CleanYfac;
int seconds = plrs[me].stime / TICRATE; int seconds = Tics2Seconds(plrs[me].stime);
int hours = seconds / 3600; int hours = seconds / 3600;
int minutes = (seconds % 3600) / 60; int minutes = (seconds % 3600) / 60;
seconds = seconds % 60; seconds = seconds % 60;
@ -1817,9 +1817,9 @@ void WI_updateStats ()
cnt_kills[0] = plrs[me].skills; cnt_kills[0] = plrs[me].skills;
cnt_items[0] = plrs[me].sitems; cnt_items[0] = plrs[me].sitems;
cnt_secret[0] = plrs[me].ssecret; cnt_secret[0] = plrs[me].ssecret;
cnt_time = plrs[me].stime / TICRATE; cnt_time = Tics2Seconds(plrs[me].stime);
cnt_par = wbs->partime / TICRATE; cnt_par = wbs->partime / TICRATE;
cnt_total_time = wbs->totaltime / TICRATE; cnt_total_time = Tics2Seconds(wbs->totaltime);
} }
if (sp_state == 2) if (sp_state == 2)
@ -1882,19 +1882,21 @@ void WI_updateStats ()
cnt_total_time += 3; cnt_total_time += 3;
} }
if (!gameinfo.intermissioncounter || cnt_time >= plrs[me].stime / TICRATE) int sec = Tics2Seconds(plrs[me].stime);
cnt_time = plrs[me].stime / TICRATE; if (!gameinfo.intermissioncounter || cnt_time >= sec)
cnt_time = sec;
if (!gameinfo.intermissioncounter || cnt_total_time >= wbs->totaltime / TICRATE) int tsec = Tics2Seconds(wbs->totaltime);
cnt_total_time = wbs->totaltime / TICRATE; if (!gameinfo.intermissioncounter || cnt_total_time >= tsec)
cnt_total_time = tsec;
if (!gameinfo.intermissioncounter || cnt_par >= wbs->partime / TICRATE) if (!gameinfo.intermissioncounter || cnt_par >= wbs->partime / TICRATE)
{ {
cnt_par = wbs->partime / TICRATE; cnt_par = wbs->partime / TICRATE;
if (cnt_time >= plrs[me].stime / TICRATE) if (cnt_time >= sec)
{ {
cnt_total_time = wbs->totaltime / TICRATE; cnt_total_time = tsec;
S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE); S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE);
sp_state++; sp_state++;
} }