Skip to content

Commit e422ccc

Browse files
committed
CHG: Pause tool unpauses server waiting for clients
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@11693 8aca7d54-2c30-db11-9de9-000461428c89
1 parent a2a2a57 commit e422ccc

File tree

3 files changed

+40
-11
lines changed

3 files changed

+40
-11
lines changed

simutrans/history.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Release of 124.3.1 (r11671 on 5-Apr-2025):
2626
FIX: make sure, the pak path and working path are really different
2727
FIX: single way tile did not force bridge direction
2828
ADD: New simple tool 43 to highlught single ribi ways
29+
CHG: Pause tool unpauses server waiting for clients
2930

3031

3132
Release of 124.3 (r11590 on 10-Jan-2025):

src/simutrans/tool/simtool.cc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
#include "../gui/privatesign_info.h"
5555
#include "../gui/messagebox.h"
5656

57+
#include "../network/network_socket_list.h"
58+
5759
#include "../obj/zeiger.h"
5860
#include "../obj/bruecke.h"
5961
#include "../obj/tunnel.h"
@@ -7217,6 +7219,38 @@ const char *tool_pipette_t::work(player_t *pl, koord3d pos)
72177219
return gr->obj_count()>0 ? "Not allowed to copy object." : NULL;
72187220
}
72197221

7222+
// pause tool also to unpause server games
7223+
char const* tool_pause_t::get_tooltip(player_t const*) const
7224+
{
7225+
if (env_t::networkmode) {
7226+
if (env_t::server) {
7227+
return translator::translate("Pause");
7228+
}
7229+
return translator::translate("deactivated in online mode");
7230+
}
7231+
return translator::translate("Pause");
7232+
7233+
}
7234+
7235+
bool tool_pause_t::init(player_t*)
7236+
{
7237+
if (!env_t::networkmode) {
7238+
welt->set_fast_forward(0);
7239+
welt->set_pause(welt->is_paused() ^ 1);
7240+
}
7241+
else {
7242+
env_t::pause_server_no_clients = !env_t::pause_server_no_clients;
7243+
if (socket_list_t::get_playing_clients() == 0) {
7244+
welt->set_pause(env_t::pause_server_no_clients);
7245+
}
7246+
}
7247+
return false;
7248+
}
7249+
7250+
7251+
7252+
7253+
72207254

72217255
bool tool_show_trees_t::init( player_t* )
72227256
{

src/simutrans/tool/simtool.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -737,17 +737,11 @@ class tool_error_message_t : public tool_t {
737737
class tool_pause_t : public tool_t {
738738
public:
739739
tool_pause_t() : tool_t(TOOL_PAUSE | SIMPLE_TOOL) {}
740-
char const* get_tooltip(player_t const*) const OVERRIDE { return env_t::networkmode ? translator::translate("deactivated in online mode") : translator::translate("Pause"); }
741-
image_id get_icon(player_t*) const OVERRIDE { return env_t::networkmode ? IMG_EMPTY : icon; }
742-
bool is_selected() const OVERRIDE { return welt->is_paused(); }
743-
bool init( player_t * ) OVERRIDE {
744-
if( !env_t::networkmode ) {
745-
welt->set_fast_forward(0);
746-
welt->set_pause( welt->is_paused()^1 );
747-
}
748-
return false;
749-
}
750-
bool exit(player_t *s ) OVERRIDE { return init(s); }
740+
char const* get_tooltip(player_t const*) const OVERRIDE;
741+
image_id get_icon(player_t*) const OVERRIDE { return (env_t::networkmode && !env_t::server) ? IMG_EMPTY : icon; }
742+
bool is_selected() const { return env_t::networkmode ? env_t::pause_server_no_clients : welt->is_paused(); }
743+
bool init(player_t*) OVERRIDE;
744+
bool exit(player_t *s) OVERRIDE { return init(s); }
751745
bool is_init_keeps_game_state() const OVERRIDE { return !env_t::networkmode; }
752746
bool is_work_keeps_game_state() const OVERRIDE { return !env_t::networkmode; }
753747
};

0 commit comments

Comments
 (0)