2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on the
12 #include "osregistry.h"
13 #include "multi_options.h"
14 #include "gamesequence.h"
18 #include "stand_server.h"
19 #include "multi_pmsg.h"
20 #include "multi_endgame.h"
21 #include "multimsgs.h"
22 #include "multiutil.h"
23 #include "freespace.h"
24 #include "missiongoals.h"
26 #include "multi_kick.h"
27 #include "multi_fstracker.h"
28 #include "osregistry.h"
29 #include "standalone_html.h"
31 #include <libwebsockets.h>
39 std::string debug_txt;
40 std::string popup_title;
41 std::string popup_field1;
42 std::string popup_field2;
44 std::string active_player;
47 static std_state Standalone_state;
49 static std::list<std::string> Standalone_send_buf;
52 #define STANDALONE_MAX_BAN 50
53 static std::vector<std::string> Standalone_ban_list;
55 #define STD_STATS_UPDATE_TIME 500 // ms between updating player stats
56 #define STD_NG_UPDATE_TIME 1500 // ms between updating netgame information
57 #define STD_PING_UPDATE_TIME 1000 // ms between updating pings
58 #define STD_FPS_UPDATE_TIME 250 // ms between fps updates
60 static int Standalone_stats_stamp = -1;
61 static int Standalone_ng_stamp = -1;
62 static int Standalone_ping_stamp = -1;
63 static int Standalone_fps_stamp = -1;
65 static lws_context *stand_context = NULL;
67 static int startup_reset_stamp;
68 static struct lws *active_wsi = NULL;
71 static int callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len)
73 unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + standalone_html_len + LWS_SEND_BUFFER_POST_PADDING];
74 unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
75 unsigned char *start = p;
76 unsigned char *end = p + standalone_html_len;
77 bool try_reuse = false;
80 static unsigned int sent = 0;
83 case LWS_CALLBACK_HTTP: {
85 lws_return_http_status(wsi, HTTP_STATUS_BAD_REQUEST, NULL);
92 FILE *html = fopen("./standalone.html", "rb");
97 rval = lws_serve_http_file(wsi, "./standalone.html", "text/html", NULL, 0);
99 if ( (rval < 0) || ((rval > 0) && lws_http_transaction_completed(wsi)) ) {
100 // error or can't reuse connection, close the socket
106 if ( lws_add_http_header_status(wsi, 200, &p, end) ) {
110 if ( lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_SERVER, (unsigned char *)"libwebsockets", 13, &p, end) ) {
114 if ( lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_CONTENT_TYPE, (unsigned char *)"text/html", 9, &p, end) ) {
118 if ( lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_CONTENT_ENCODING, (unsigned char *)"gzip", 4, &p, end) ) {
122 if ( lws_add_http_header_content_length(wsi, standalone_html_len, &p, end) ) {
126 if ( lws_finalize_http_header(wsi, &p, end) ) {
130 rval = lws_write(wsi, start, p - start, LWS_WRITE_HTTP_HEADERS);
132 if (rval != (p - start)) {
138 lws_callback_on_writable(wsi);
144 case LWS_CALLBACK_HTTP_BODY_COMPLETION: {
145 lws_return_http_status(wsi, HTTP_STATUS_OK, NULL);
151 case LWS_CALLBACK_HTTP_FILE_COMPLETION: {
157 case LWS_CALLBACK_HTTP_WRITEABLE: {
158 while ( !lws_send_pipe_choked(wsi) && (sent < standalone_html_len) ) {
159 size = standalone_html_len - sent;
161 int pwa = lws_get_peer_write_allowance(wsi);
164 lws_callback_on_writable(wsi);
169 if ( (pwa != -1) && (pwa < size) ) {
173 memcpy(p, standalone_html + sent, size);
175 rval = lws_write(wsi, p, size, LWS_WRITE_HTTP);
182 // while still active, extent timeout
183 lws_set_timeout(wsi, PENDING_TIMEOUT_HTTP_CONTENT, 5);
199 if (lws_http_transaction_completed(wsi)) {
207 static int callback_standalone(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len)
209 #define MAX_BUF_SIZE 1024
210 unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + MAX_BUF_SIZE + LWS_SEND_BUFFER_POST_PADDING];
211 unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
216 case LWS_CALLBACK_ESTABLISHED: {
219 if ( timestamp_elapsed(startup_reset_stamp) ) {
220 std_reset_standalone_gui();
226 case LWS_CALLBACK_CLOSED: {
232 case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: {
240 case LWS_CALLBACK_SERVER_WRITEABLE: {
241 while ( !Standalone_send_buf.empty() ) {
242 size = SDL_strlcpy((char *)p, Standalone_send_buf.front().c_str(), MAX_BUF_SIZE);
244 rval = lws_write(wsi, p, size, LWS_WRITE_TEXT);
247 lwsl_err("ERROR sending buffer!\n");
248 lws_close_reason(wsi, LWS_CLOSE_STATUS_UNEXPECTED_CONDITION, (unsigned char *)"write error", 11);
253 Standalone_send_buf.pop_front();
255 if ( lws_send_pipe_choked(wsi) ) {
256 lws_callback_on_writable(wsi);
265 case LWS_CALLBACK_RECEIVE: {
266 if (in != NULL && len > 0) {
267 const char *msg = (const char *)in;
270 if ( !SDL_strcmp(msg, "shutdown") ) {
271 gameseq_post_event(GS_EVENT_QUIT_GAME);
272 lws_close_reason(wsi, LWS_CLOSE_STATUS_GOINGAWAY, (unsigned char *)"shutdown", 8);
277 if ( !SDL_strcmp(msg, "reset") ) {
278 multi_quit_game(PROMPT_NONE);
279 std_reset_standalone_gui();
287 if ( !SDL_strncmp(msg+2, "name ", 5) ) {
288 SDL_strlcpy(Netgame.name, msg+7, SDL_arraysize(Netgame.name));
289 SDL_strlcpy(Multi_options_g.std_pname, Netgame.name, SDL_arraysize(Multi_options_g.std_pname));
290 } else if ( !SDL_strncmp(msg+2, "pass ", 5) ) {
291 SDL_strlcpy(Multi_options_g.std_passwd, msg+7, SDL_arraysize(Multi_options_g.std_passwd));
292 } else if ( !SDL_strncmp(msg+2, "kick ", 5) ) {
295 for (int i = 0; i < MAX_PLAYERS; i++) {
296 if ( MULTI_CONNECTED(Net_players[i]) ) {
297 psnet_addr_to_string(ip_string, SDL_arraysize(ip_string), &Net_players[i].p_info.addr);
299 if ( !SDL_strcmp(msg+7, ip_string) ) {
300 multi_kick_player(i, 0);
310 else if (mtype == 'M') {
312 if ( !SDL_strncmp(msg+2, "fps ", 4) ) {
313 int fps = SDL_atoi(msg+6);
316 Multi_options_g.std_framecap = fps;
321 else if (mtype == 'P') {
323 if ( !SDL_strncmp(msg+2, "info ", 5) ) {
326 for (i = 0; i < MAX_PLAYERS; i++) {
327 net_player *np = &Net_players[i];
329 if ( MULTI_CONNECTED((*np)) && (Net_player != np) ) {
330 if ( !SDL_strcmp(msg+7, np->player->callsign) ) {
331 Standalone_state.active_player = msg+7;
332 std_pinfo_display_player_info(np);
339 if (i == MAX_PLAYERS) {
340 Standalone_state.active_player.clear();
346 else if (mtype == 'G') {
348 if ( !SDL_strncmp(msg+2, "smsg ", 5) ) {
351 SDL_strlcpy(txt, msg+7, SDL_arraysize(txt));
353 if (SDL_strlen(txt) > 0) {
354 send_game_chat_packet(Net_player, txt, MULTI_MSG_ALL, NULL);
356 std_add_chat_text(txt, MY_NET_PLAYER_NUM, 1);
358 } else if ( !SDL_strcmp(msg+2, "mrefresh") ) {
359 if (MULTI_IS_TRACKER_GAME) {
360 cf_delete(MULTI_VALID_MISSION_FILE, CF_TYPE_DATA);
362 multi_update_valid_missions();
379 static struct lws_protocols stand_protocols[] = {
401 static void std_lws_logger(int level, const char *line)
403 if (level & (LLL_WARN|LLL_ERR)) {
404 mprintf(("STD: %s", line));
405 } else if (level & LLL_NOTICE) {
406 nprintf(("lws", "STD: %s", line));
412 static void std_add_ws_message(const char *id, const char *val)
416 // if no client, and startup stamp elapsed, then don't add more messages
417 if ( (active_wsi == NULL) && timestamp_elapsed(startup_reset_stamp) ) {
427 Standalone_send_buf.push_back(msg);
430 void std_deinit_standalone()
433 lws_cancel_service(stand_context);
434 lws_context_destroy(stand_context);
435 stand_context = NULL;
439 void std_init_standalone()
441 struct lws_context_creation_info info;
449 // basic security measure for admin interface
450 // "1" bind to loopback iface only *default*
451 // "0" bind to any/all
452 // any other value should be ip or iface name to bind
453 // (invalid values will trigger error)
455 const char *stand_iface = os_config_read_string("Network", "RestrictStandAdmin", "1");
457 if ( !SDL_strcmp(stand_iface, "1") ) {
458 info.iface = "127.0.0.1";
459 } else if ( !SDL_strcmp(stand_iface, "0") ) {
462 info.iface = stand_iface;
465 info.port = Multi_options_g.port;
467 info.protocols = stand_protocols;
472 lws_set_log_level(LLL_ERR|LLL_WARN|LLL_NOTICE, std_lws_logger);
474 stand_context = lws_create_context(&info);
476 if (stand_context == NULL) {
477 Error(LOCATION, "Unable to initialize standalone server!");
480 atexit(std_deinit_standalone);
482 // turn off all sound and music
483 Cmdline_freespace_no_sound = 1;
484 Cmdline_freespace_no_music = 1;
487 SDL_snprintf(title, SDL_arraysize(title), "%s %d.%02d.%02d", XSTR("FreeSpace Standalone", 935), FS_VERSION_MAJOR, FS_VERSION_MINOR, FS_VERSION_BUILD);
488 Standalone_state.title = title;
490 // connections > 5 sec after startup should get gui reset
491 startup_reset_stamp = timestamp(5000);
493 std_reset_standalone_gui();
495 std_multi_update_netgame_info_controls();
498 static void std_update_ping_all()
500 std::string ping_upd;
503 for (int i = 0, idx = 0; i < MAX_PLAYERS; i++) {
504 net_player *np = &Net_players[i];
506 if ( MULTI_CONNECTED((*np)) && (Net_player != np) ) {
507 if (np->s_info.ping.ping_avg > -1) {
508 if (np->s_info.ping.ping_avg >= 1000) {
509 SDL_snprintf(ping_str, SDL_arraysize(ping_str), "%s", XSTR("> 1 sec", 914));
511 SDL_snprintf(ping_str, SDL_arraysize(ping_str), "%d%s", np->s_info.ping.ping_avg, XSTR(" ms", 915));
517 // append separator if not first
519 ping_upd.append(",");
522 ping_upd.append(ping_str);
526 if ( !ping_upd.empty() ) {
527 std_add_ws_message("S:ping ", ping_upd.c_str());
531 static void std_update_connections()
533 std::string conn_str;
536 conn_str.reserve(1024);
538 for (int i = 0, idx = 0; i < MAX_PLAYERS; i++) {
539 net_player *np = &Net_players[i];
541 if ( MULTI_CONNECTED((*np)) && (Net_player != np) ) {
542 // append seperator if not first
544 conn_str.append(";");
547 conn_str.append(np->player->callsign);
548 conn_str.append(",");
550 psnet_addr_to_string(ip_address, SDL_arraysize(ip_address), &np->p_info.addr);
551 conn_str.append(ip_address);
555 SDL_assert(conn_str.length() < 1024);
557 if ( !conn_str.empty() ) {
558 std_add_ws_message("S:conn ", conn_str.c_str());
562 void std_do_gui_frame()
564 // maybe update selected player stats
565 if ( ((Standalone_stats_stamp == -1) || timestamp_elapsed(Standalone_stats_stamp)) && !Standalone_state.active_player.empty() ) {
566 Standalone_stats_stamp = timestamp(STD_STATS_UPDATE_TIME);
568 for (int i = 0; i < MAX_PLAYERS; i++) {
569 net_player *np = &Net_players[i];
571 if ( MULTI_CONNECTED((*np)) && (Net_player != np) ) {
572 if ( !SDL_strcmp(Standalone_state.active_player.c_str(), np->player->callsign) ) {
573 std_pinfo_display_player_info(np);
581 // maybe update netgame info
582 if ( (Standalone_ng_stamp == -1) || timestamp_elapsed(Standalone_ng_stamp) ) {
583 Standalone_ng_stamp = timestamp(STD_NG_UPDATE_TIME);
585 std_multi_update_netgame_info_controls();
588 // update connection ping times
589 if ( ((Standalone_ping_stamp == -1) || timestamp_elapsed(Standalone_ping_stamp)) ) {
590 Standalone_ping_stamp = timestamp(STD_PING_UPDATE_TIME);
592 std_update_ping_all();
595 if ( !Standalone_send_buf.empty() ) {
596 lws_callback_on_writable_all_protocol(stand_context, &stand_protocols[1]);
599 lws_service(stand_context, 0);
602 void std_debug_set_standalone_state_string(const char *str)
604 Standalone_state.debug_txt = str;
606 std_add_ws_message("D:", str);
609 void std_connect_set_gamename(const char *name)
612 // if a permanent name exists, use that instead of the default
613 if ( SDL_strlen(Multi_options_g.std_pname) ) {
614 SDL_strlcpy(Netgame.name, Multi_options_g.std_pname, SDL_arraysize(Netgame.name));
616 SDL_strlcpy(Netgame.name, XSTR("Standalone Server", 916), SDL_arraysize(Netgame.name));
619 SDL_strlcpy(Netgame.name, name, SDL_arraysize(Netgame.name));
622 std_add_ws_message("S:name ", Netgame.name);
625 int std_connect_set_connect_count()
629 for (int i = 0; i < MAX_PLAYERS; i++) {
630 if (MULTI_CONNECTED(Net_players[i]) && (Net_player != &Net_players[i]) ) {
638 void std_add_player(net_player *p)
640 std_update_connections();
642 // clear active player, client should reset if needed
643 Standalone_state.active_player.clear();
645 // check to see if this guy is the host
646 std_connect_set_host_connect_status();
649 int std_remove_player(net_player *p)
653 std_update_connections();
655 // clear active player, client should reset if needed
656 Standalone_state.active_player.clear();
658 // update the host connect count
659 std_connect_set_host_connect_status();
661 // update the currently connected players
662 count = std_connect_set_connect_count();
665 multi_quit_game(PROMPT_NONE);
672 void std_update_player_ping(net_player *p)
676 void std_pinfo_display_player_info(net_player *p)
684 pinfo.append(Ship_info[p->p_info.ship_class].name);
688 if (p->s_info.ping.ping_avg > 1000) {
689 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%s", XSTR("> 1 sec", 914));
691 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d%s", p->s_info.ping.ping_avg, XSTR(" ms", 915));
694 pinfo.append(sml_ping);
697 scoring_struct *ptr = &p->player->stats;
700 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->p_shots_fired);
701 pinfo.append(sml_ping);
703 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->p_shots_hit);
704 pinfo.append(sml_ping);
706 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->p_bonehead_hits);
707 pinfo.append(sml_ping);
709 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->p_shots_fired ? (int)(100.0f * ((float)ptr->p_shots_hit / (float)ptr->p_shots_fired)) : 0);
710 pinfo.append(sml_ping);
712 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->p_shots_fired ? (int)(100.0f * ((float)ptr->p_bonehead_hits / (float)ptr->p_shots_fired)) : 0);
713 pinfo.append(sml_ping);
715 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->s_shots_fired);
716 pinfo.append(sml_ping);
718 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->s_shots_hit);
719 pinfo.append(sml_ping);
721 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->s_bonehead_hits);
722 pinfo.append(sml_ping);
724 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->s_shots_fired ? (int)(100.0f * ((float)ptr->s_shots_hit / (float)ptr->s_shots_fired)) : 0);
725 pinfo.append(sml_ping);
727 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->s_shots_fired ? (int)(100.0f * ((float)ptr->s_bonehead_hits / (float)ptr->s_shots_fired)) : 0);
728 pinfo.append(sml_ping);
730 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->assists);
731 pinfo.append(sml_ping);
732 pinfo.append(";"); // <- end of block
735 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->mp_shots_fired);
736 pinfo.append(sml_ping);
738 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->mp_shots_hit);
739 pinfo.append(sml_ping);
741 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->mp_bonehead_hits);
742 pinfo.append(sml_ping);
744 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->mp_shots_fired ? (int)(100.0f * ((float)ptr->mp_shots_hit / (float)ptr->mp_shots_fired)) : 0);
745 pinfo.append(sml_ping);
747 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->mp_shots_fired ? (int)(100.0f * ((float)ptr->mp_bonehead_hits / (float)ptr->mp_shots_fired)) : 0);
748 pinfo.append(sml_ping);
750 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->ms_shots_fired);
751 pinfo.append(sml_ping);
753 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->ms_shots_hit);
754 pinfo.append(sml_ping);
756 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->ms_bonehead_hits);
757 pinfo.append(sml_ping);
759 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->ms_shots_fired ? (int)(100.0f * ((float)ptr->ms_shots_hit / (float)ptr->ms_shots_fired)) : 0);
760 pinfo.append(sml_ping);
762 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->ms_shots_fired ? (int)(100.0f * ((float)ptr->ms_bonehead_hits / (float)ptr->ms_shots_fired)) : 0);
763 pinfo.append(sml_ping);
765 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->m_assists);
766 pinfo.append(sml_ping);
768 std_add_ws_message("P:info ", pinfo.c_str());
771 void std_add_chat_text(const char *text, int player_index, int add_id)
776 if ( (player_index < 0) || (player_index >= MAX_PLAYERS) ) {
780 // format the chat text nicely
782 if ( MULTI_STANDALONE(Net_players[player_index]) ) {
783 SDL_snprintf(id, SDL_arraysize(id), XSTR("<SERVER> %s", 924), "");
785 SDL_snprintf(id, SDL_arraysize(id), "%s: ", Net_players[player_index].player->callsign);
794 std_add_ws_message("G:mesg ", msg.c_str());
797 void std_reset_timestamps()
799 // reset the stats update stamp
800 Standalone_stats_stamp = timestamp(STD_STATS_UPDATE_TIME);
802 // reset the netgame controls update timestamp
803 Standalone_ng_stamp = timestamp(STD_NG_UPDATE_TIME);
805 // reset the ping update stamp
806 Standalone_ping_stamp = timestamp(STD_PING_UPDATE_TIME);
808 // reset fps update stamp
809 Standalone_fps_stamp = timestamp(STD_FPS_UPDATE_TIME);
812 void std_add_ban(const char *name)
814 if ( (name == NULL) || !SDL_strlen(name) ) {
818 if (Standalone_ban_list.size() >= STANDALONE_MAX_BAN) {
822 Standalone_ban_list.push_back(name);
825 int std_player_is_banned(const char *name)
827 if ( Standalone_ban_list.empty() ) {
831 for (size_t i = 0; i < Standalone_ban_list.size(); i++) {
832 if ( !SDL_strcasecmp(name, Standalone_ban_list[i].c_str()) ) {
840 int std_is_host_passwd()
842 return (SDL_strlen(Multi_options_g.std_passwd) > 0) ? 1 : 0;
845 void std_multi_set_standalone_mission_name(const char *mission_name)
847 std_add_ws_message("M:name ", mission_name);
850 void std_multi_set_standalone_missiontime(float mission_time)
854 fix m_time = fl2f(mission_time);
856 // format the time string and set the text
857 game_format_time(m_time, timestr, SDL_arraysize(timestr));
858 SDL_snprintf(txt, SDL_arraysize(txt), "%s : %.1f", timestr, mission_time);
860 std_add_ws_message("M:time ", txt);
863 void std_multi_update_netgame_info_controls()
867 SDL_snprintf(nginfo, SDL_arraysize(nginfo), "%d,%d,%d,%d", Netgame.max_players, Netgame.options.max_observers, Netgame.security, Netgame.respawn);
869 std_add_ws_message("M:info ", nginfo);
872 void std_set_standalone_fps(float fps)
874 if ( (Standalone_fps_stamp == -1) || timestamp_elapsed(Standalone_fps_stamp) ) {
875 Standalone_fps_stamp = timestamp(STD_FPS_UPDATE_TIME);
879 SDL_snprintf(rfps, SDL_arraysize(rfps), "%.1f", fps);
881 std_add_ws_message("M:rfps ", rfps);
885 void std_multi_setup_goal_tree()
887 std::string mission_goals;
889 std::string secondary;
893 for (int i = 0; i < Num_goals; i++) {
894 switch (Mission_goals[i].satisfied) {
900 case GOAL_COMPLETE: {
905 case GOAL_INCOMPLETE:
912 switch (Mission_goals[i].type & GOAL_TYPE_MASK) {
914 primary.append(status);
915 primary.append(Mission_goals[i].name);
921 case SECONDARY_GOAL: {
922 secondary.append(status);
923 secondary.append(Mission_goals[i].name);
924 secondary.append(",");
930 bonus.append(status);
931 bonus.append(Mission_goals[i].name);
942 if ( primary.empty() ) {
943 mission_goals.append("i none");
945 mission_goals.append(primary.substr(0, primary.size()-1));
948 mission_goals.append(";");
950 if ( secondary.empty() ) {
951 mission_goals.append("i none");
953 mission_goals.append(secondary.substr(0, secondary.size()-1));
956 mission_goals.append(";");
958 if ( bonus.empty() ) {
959 mission_goals.append("i none");
961 mission_goals.append(bonus.substr(0, bonus.size()-1));
964 std_add_ws_message("M:goal ", mission_goals.c_str());
967 void std_multi_add_goals()
969 std_multi_setup_goal_tree();
972 void std_multi_update_goals()
974 std_multi_setup_goal_tree();
977 void std_reset_standalone_gui()
979 Standalone_send_buf.clear();
981 std_add_ws_message("reset", NULL);
983 std_add_ws_message("T:", Standalone_state.title.c_str());
984 std_add_ws_message("D:", Standalone_state.debug_txt.c_str());
986 std_add_ws_message("S:name ", Netgame.name);
987 std_add_ws_message("S:pass ", Multi_options_g.std_passwd);
989 std_update_connections();
990 std_set_standalone_fps(0.0f);
991 std_multi_set_standalone_missiontime(0.0f);
992 std_multi_update_netgame_info_controls();
994 Standalone_fps_stamp = -1;
995 Standalone_ng_stamp = -1;
996 Standalone_ping_stamp = -1;
997 Standalone_stats_stamp = -1;
999 Standalone_state.active_player.clear();
1003 void std_create_gen_dialog(const char *title)
1005 Standalone_state.popup_title = title;
1007 Standalone_state.popup_field1 = "";
1008 Standalone_state.popup_field2 = "";
1011 void std_destroy_gen_dialog()
1013 std_add_ws_message("popup ", NULL);
1016 void std_gen_set_text(const char *str, int field_num)
1018 std::string popup_str;
1020 switch (field_num) {
1022 Standalone_state.popup_title = str;
1026 Standalone_state.popup_field1 = str;
1030 Standalone_state.popup_field2 = str;
1037 popup_str.append(Standalone_state.popup_title);
1038 popup_str.append(";");
1039 popup_str.append(Standalone_state.popup_field1);
1040 popup_str.append(";");
1041 popup_str.append(Standalone_state.popup_field2);
1043 std_add_ws_message("popup ", popup_str.c_str());
1045 // force ws write since do_frame() may not happen until popup is done
1046 lws_callback_on_writable_all_protocol(stand_context, &stand_protocols[1]);
1047 lws_service(stand_context, 0);
1050 void std_tracker_notify_login_fail()
1055 void std_tracker_login()
1057 if ( !Multi_options_g.pxo ) {
1061 multi_fs_tracker_init();
1063 if ( !multi_fs_tracker_inited() ) {
1064 std_tracker_notify_login_fail();
1068 multi_fs_tracker_login_freespace();
1071 void std_connect_set_host_connect_status()