Skip to content

Commit

Permalink
move p1xbraten serverbrowser implementation to game::mod
Browse files Browse the repository at this point in the history
  • Loading branch information
sauerbraten committed Mar 17, 2023
1 parent 9c9cf85 commit 5b16dc0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
17 changes: 10 additions & 7 deletions patches/serverbrowser.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ diff --git src/engine/menus.cpp src/engine/menus.cpp
index 8e18447..ab081be 100644
--- src/engine/menus.cpp
+++ src/engine/menus.cpp
@@ -551,12 +551,17 @@ void newgui(char *name, char *contents, char *header, char *init)
@@ -551,12 +551,20 @@ void newgui(char *name, char *contents, char *header, char *init)

menu *guiserversmenu = NULL;

+namespace game { extern int usep1xbratenmenus; }
+namespace mod { namespace serverbrowser { extern const char *showservers(g3d_gui *cgui, uint *header, int pagemin, int pagemax); } }
+namespace game
+{
+ extern int usep1xbratenmenus;
+ namespace mod { extern const char *showservers(g3d_gui *cgui, uint *header, int pagemin, int pagemax); }
+}
+
void guiservers(uint *header, int *pagemin, int *pagemax)
{
Expand All @@ -16,7 +19,7 @@ index 8e18447..ab081be 100644
{
- const char *command = showservers(cgui, header, *pagemin, *pagemax > 0 ? *pagemax : INT_MAX);
+ const char *command = game::usep1xbratenmenus ?
+ mod::serverbrowser::showservers(cgui, header, *pagemin, *pagemax > 0 ? *pagemax : INT_MAX) :
+ game::mod::showservers(cgui, header, *pagemin, *pagemax > 0 ? *pagemax : INT_MAX) :
+ showservers(cgui, header, *pagemin, *pagemax > 0 ? *pagemax : INT_MAX);
if(command)
{
Expand Down Expand Up @@ -183,8 +186,8 @@ index 0000000..e1ad208
+extern void refreshservers();
+extern serverinfo *selectedserver;
+
+namespace mod { namespace serverbrowser {
+
+namespace game { namespace mod
+{
+ static const char * const names[] = { "ping", "players", "slots", "mode", "map", "time", "master", "host", "port", "description" };
+ static const float struts[] = { 0, 0, 0, 12.5f, 14, 0, 0, 14, 0, 24.5f };
+ static const bool right[] = { true, true, true, false, false, false, false, false, true, false };
Expand Down Expand Up @@ -299,7 +302,7 @@ index 0000000..e1ad208
+ break;
+
+ case 6:
+ leftjustified(g->buttonf("%s%s", COL_WHITE, NULL, attr.length()>=5 ? game::mastermodecolor(attr[4], "") : "", attr.length()>=5 ? server::mastermodename(attr[4], "") : ""))
+ leftjustified(g->buttonf("%s%s", COL_WHITE, NULL, attr.length()>=5 ? mastermodecolor(attr[4], "") : "", attr.length()>=5 ? server::mastermodename(attr[4], "") : ""))
+ break;
+
+ case 7:
Expand Down
9 changes: 6 additions & 3 deletions src/engine/menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,16 +551,19 @@ void newgui(char *name, char *contents, char *header, char *init)

menu *guiserversmenu = NULL;

namespace game { extern int usep1xbratenmenus; }
namespace mod { namespace serverbrowser { extern const char *showservers(g3d_gui *cgui, uint *header, int pagemin, int pagemax); } }
namespace game
{
extern int usep1xbratenmenus;
namespace mod { extern const char *showservers(g3d_gui *cgui, uint *header, int pagemin, int pagemax); }
}

void guiservers(uint *header, int *pagemin, int *pagemax)
{
extern const char *showservers(g3d_gui *cgui, uint *header, int pagemin, int pagemax);
if(cgui)
{
const char *command = game::usep1xbratenmenus ?
mod::serverbrowser::showservers(cgui, header, *pagemin, *pagemax > 0 ? *pagemax : INT_MAX) :
game::mod::showservers(cgui, header, *pagemin, *pagemax > 0 ? *pagemax : INT_MAX) :
showservers(cgui, header, *pagemin, *pagemax > 0 ? *pagemax : INT_MAX);
if(command)
{
Expand Down
6 changes: 3 additions & 3 deletions src/p1xbraten/serverbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ extern vector<serverinfo *> servers;
extern void refreshservers();
extern serverinfo *selectedserver;

namespace mod { namespace serverbrowser {

namespace game { namespace mod
{
static const char * const names[] = { "ping", "players", "slots", "mode", "map", "time", "master", "host", "port", "description" };
static const float struts[] = { 0, 0, 0, 12.5f, 14, 0, 0, 14, 0, 24.5f };
static const bool right[] = { true, true, true, false, false, false, false, false, true, false };
Expand Down Expand Up @@ -121,7 +121,7 @@ namespace mod { namespace serverbrowser {
break;

case 6:
leftjustified(g->buttonf("%s%s", COL_WHITE, NULL, attr.length()>=5 ? game::mastermodecolor(attr[4], "") : "", attr.length()>=5 ? server::mastermodename(attr[4], "") : ""))
leftjustified(g->buttonf("%s%s", COL_WHITE, NULL, attr.length()>=5 ? mastermodecolor(attr[4], "") : "", attr.length()>=5 ? server::mastermodename(attr[4], "") : ""))
break;

case 7:
Expand Down

0 comments on commit 5b16dc0

Please sign in to comment.