Skip to content

Commit

Permalink
Merge branch 'stable' into bug/fix-208
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMax committed Aug 8, 2021
2 parents a5a449c + 89a03d5 commit 47221ed
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 80 deletions.
7 changes: 3 additions & 4 deletions client/sdl/i_main.cpp
Expand Up @@ -284,10 +284,9 @@ int main(int argc, char *argv[])
catch (CDoomError &error)
{
if (LOG.is_open())
{
LOG << error.GetMsg() << std::endl;
LOG << std::endl;
}
{
LOG << "=== ERROR: " << error.GetMsg() << " ===\n\n";
}

I_ErrorMessageBox(error.GetMsg().c_str());

Expand Down
2 changes: 1 addition & 1 deletion client/src/cl_cvarlist.cpp
Expand Up @@ -180,7 +180,7 @@ CVAR_RANGE_FUNC_DECL(msgmidcolor, "5", "Color used for centered messages.",
// ------------

// Determines whether to draw the scores on intermission.
CVAR( wi_newintermission, "0", "Draw the scores on intermission",
CVAR( wi_newintermission, "0", "Use Odamex's intermission screen if there are 4 players or less on cooperative gamemodes.",
CVARTYPE_BOOL, CVAR_CLIENTARCHIVE)


Expand Down
89 changes: 74 additions & 15 deletions client/src/wi_stuff.cpp
Expand Up @@ -41,9 +41,11 @@
#include "hu_stuff.h"
#include "v_palette.h"
#include "c_dispatch.h"
#include "v_text.h"
#include "gi.h"

void WI_unloadData(void);
size_t P_NumPlayersInGame();

//
// Data needed to add patches to full screen intermission pics.
Expand Down Expand Up @@ -455,7 +457,32 @@ static int WI_DrawName (const char *str, int x, int y)
return (5*(p->height()-p->topoffset()))/4;
}

static int WI_DrawSmallName(const char* str, int x, int y)
{
int lump;
patch_t* p = NULL;
char charname[9];

while (*str)
{
sprintf(charname, "STCFN%.3d", HU_FONTSTART + (toupper(*str) - 32) - 1);
lump = W_CheckNumForName(charname);
if (lump != -1)
{
p = W_CachePatch(lump);
screen->DrawPatchClean(p, x, y);
x += p->width() - 1;
}
else
{
x += 12;
}
str++;
}

p = W_CachePatch("FONTB39");
return (5 * (p->height() - p->topoffset())) / 4;
}

//Draws "<Levelname> Finished!"
void WI_drawLF (void)
Expand Down Expand Up @@ -1086,6 +1113,7 @@ void WI_updateNetgameStats()
void WI_drawNetgameStats(void)
{
unsigned int x, y;
unsigned int nbPlayers = 0;

patch_t* pPercent = W_ResolvePatchHandle(::percent);
patch_t* pKills = W_ResolvePatchHandle(::kills);
Expand Down Expand Up @@ -1120,8 +1148,12 @@ void WI_drawNetgameStats(void)

for (Players::iterator it = players.begin();it != players.end();++it)
{
// [RH] Quick hack: Only show the first four players.
if (it->id > 4)
// Make sure while demoplaybacking that we're not exceeding the hardlimit of 4 players.
if (demoplayback && it->id > 4)
break;

// Break it anyway if we count more than 4 ACTIVE players in our session.
if (!demoplayback && nbPlayers > 4)
break;

byte i = (it->id) - 1;
Expand All @@ -1131,23 +1163,37 @@ void WI_drawNetgameStats(void)

x = NG_STATSX;
// [RH] Only use one graphic for the face backgrounds
V_ColorMap = translationref_t(translationtables + i * 256, i);
if (demoplayback)
V_ColorMap = translationref_t(translationtables + it->id * 256, it->id);
else
V_ColorMap = translationref_t(translationtables + i * 256, i);

screen->DrawTranslatedPatchClean(pP, x - pP->width(), y);
// classic face background colour
//screen->DrawTranslatedPatchClean (faceclassic[i], x-p->width(), y);

if (i == me)
screen->DrawPatchClean(pStar, x - pP->width(), y);

// Display player names online!
if (!demoplayback)
{
std::string str;
StrFormat(str, "%s", it->userinfo.netname.c_str());
WI_DrawSmallName(str.c_str(), x+10, y+24);
}

x += NG_SPACINGX;

WI_drawPercent (cnt_kills_c[i], x-pwidth, y+10, wbs->maxkills); x += NG_SPACINGX;
WI_drawPercent (cnt_items_c[i], x-pwidth, y+10, wbs->maxitems); x += NG_SPACINGX;
WI_drawPercent (cnt_secret_c[i], x-pwidth, y+10, wbs->maxsecret); x += NG_SPACINGX;

if (dofrags)
WI_drawNum(cnt_frags_c[i], x, y+10, -1);

y += WI_SPACINGY;
y += WI_SPACINGY+4;
nbPlayers++;
}
}

Expand Down Expand Up @@ -1359,12 +1405,19 @@ void WI_Ticker (void)
switch (state)
{
case StatCount:
if (multiplayer && sv_maxplayers > 1)
if (multiplayer)
{
if (sv_gametype == 0 && !wi_newintermission && sv_maxplayers < 5)
WI_updateNetgameStats();
else
WI_updateNoState();
if (demoplayback)
{
WI_updateNetgameStats();
}
else
{
if (sv_gametype == 0 && !wi_newintermission && P_NumPlayersInGame() < 5)
WI_updateNetgameStats();
else
WI_updateNoState();
}
}
else
WI_updateStats();
Expand Down Expand Up @@ -1630,13 +1683,19 @@ void WI_Drawer (void)
switch (state)
{
case StatCount:
if (multiplayer && sv_maxplayers > 1)
if (multiplayer)
{
// TODO: Fix classic coop scoreboard
//if (sv_gametype == 0 && !wi_newintermission && sv_maxplayers < 5)
//WI_drawNetgameStats();
//else
WI_drawDeathmatchStats();
if (demoplayback)
{
WI_drawNetgameStats();
}
else
{
if (sv_gametype == 0 && !wi_newintermission && P_NumPlayersInGame() < 5)
WI_drawNetgameStats();
else
WI_drawDeathmatchStats();
}
}
else
WI_drawStats();
Expand Down
33 changes: 28 additions & 5 deletions common/p_user.cpp
Expand Up @@ -798,9 +798,34 @@ bool P_CanSpy(player_t &viewer, player_t &other, bool demo)
if (demo)
return true;

// A teammate can see their other teammates.
// Spectators see anyone with one slight restriction.
if (P_AreTeammates(viewer, other) || viewer.spectator)
// Is the player a teammate?
bool isTeammate = false;
if (G_IsCoopGame())
{
// You are everyone's teammate in a coop game.
isTeammate = true;
}
else if (G_IsTeamGame())
{
if (viewer.userinfo.team == other.userinfo.team)
{
// You are on the same team.
isTeammate = true;
}
else
{
PlayerResults pr =
PlayerQuery().hasLives().onTeam(viewer.userinfo.team).execute();
if (pr.count == 0)
{
// You are on a different team but your teammates are dead, so
// it doesn't really matter if you spectate them.
isTeammate = true;
}
}
}

if (isTeammate || viewer.spectator)
{
// If a player has no more lives, don't show him.
if (::g_lives && other.lives < 1)
Expand All @@ -813,8 +838,6 @@ bool P_CanSpy(player_t &viewer, player_t &other, bool demo)
if (::sv_gametype == GM_DM && ::g_lives && viewer.lives < 1)
return true;



return false;
}

Expand Down
65 changes: 31 additions & 34 deletions server/src/i_main.cpp
Expand Up @@ -168,27 +168,25 @@ int __cdecl main(int argc, char *argv[])
atterm (DObject::StaticShutdown);

D_DoomMain();
}
catch (CDoomError &error)
{
}
catch (CDoomError& error)
{
if (LOG.is_open())
{
LOG << error.GetMsg() << std::endl;
LOG << std::endl;
}
else
{
MessageBox(NULL, error.GetMsg().c_str(), "Odasrv Error", MB_OK);
}
{
LOG << "=== ERROR: " << error.GetMsg() << " ===\n\n";
}

fprintf(stderr, "=== ERROR: %s ===\n\n", error.GetMsg().c_str());

call_terms();
exit(EXIT_FAILURE);
}
catch (...)
{
call_terms ();
}
catch (...)
{
call_terms();
throw;
}
return 0;
}
return 0;
}
#else

Expand Down Expand Up @@ -285,26 +283,25 @@ int main (int argc, char **argv)
// I set earlier.

D_DoomMain();
}
catch (CDoomError &error)
{
fprintf (stderr, "%s\n", error.GetMsg().c_str());
}
catch (CDoomError& error)
{
if (LOG.is_open())
{
LOG << "=== ERROR: " << error.GetMsg() << " ===\n\n";
}

if (LOG.is_open())
{
LOG << error.GetMsg() << std::endl;
LOG << std::endl;
}
fprintf(stderr, "=== ERROR: %s ===\n\n", error.GetMsg().c_str());

call_terms();
exit(EXIT_FAILURE);
}
catch (...)
{
call_terms ();
call_terms();
exit(EXIT_FAILURE);
}
catch (...)
{
call_terms();
throw;
}
return 0;
}
return 0;
}

#endif
Expand Down
49 changes: 35 additions & 14 deletions server/src/sv_level.cpp
Expand Up @@ -192,29 +192,50 @@ void G_ChangeMap() {
}
else
{
size_t next_index;
if (!Maplist::instance().get_next_index(next_index)) {
// We don't have a maplist, so grab the next 'natural' map lump.
std::string next = G_NextMap();
G_DeferedInitNew((char *)next.c_str());
}
else {
maplist_entry_t maplist_entry;
Maplist::instance().get_map_by_index(next_index, maplist_entry);
maplist_entry_t lobby_entry;
lobby_entry = Maplist::instance().get_lobbymap();

if (!Maplist::instance().lobbyempty())
{
std::string wadstr;
for (size_t i = 0; i < maplist_entry.wads.size(); i++)
for (size_t i = 0; i < lobby_entry.wads.size(); i++)
{
if (i != 0)
{
wadstr += " ";
}
wadstr += C_QuoteString(maplist_entry.wads.at(i));
wadstr += C_QuoteString(lobby_entry.wads.at(i));
}
G_LoadWadString(wadstr, lobby_entry.map);
}
else
{
size_t next_index;
if (!Maplist::instance().get_next_index(next_index))
{
// We don't have a maplist, so grab the next 'natural' map lump.
std::string next = G_NextMap();
G_DeferedInitNew((char*)next.c_str());
}
G_LoadWadString(wadstr, maplist_entry.map);
else
{
maplist_entry_t maplist_entry;
Maplist::instance().get_map_by_index(next_index, maplist_entry);

std::string wadstr;
for (size_t i = 0; i < maplist_entry.wads.size(); i++)
{
if (i != 0)
{
wadstr += " ";
}
wadstr += C_QuoteString(maplist_entry.wads.at(i));
}
G_LoadWadString(wadstr, maplist_entry.map);

// Set the new map as the current map
Maplist::instance().set_index(next_index);
// Set the new map as the current map
Maplist::instance().set_index(next_index);
}
}

// run script at the end of each map
Expand Down

0 comments on commit 47221ed

Please sign in to comment.