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_content_length(wsi, standalone_html_len, &p, end) ) {
122 if ( lws_finalize_http_header(wsi, &p, end) ) {
126 rval = lws_write(wsi, start, p - start, LWS_WRITE_HTTP_HEADERS);
128 if (rval != (p - start)) {
134 lws_callback_on_writable(wsi);
140 case LWS_CALLBACK_HTTP_BODY_COMPLETION: {
141 lws_return_http_status(wsi, HTTP_STATUS_OK, NULL);
147 case LWS_CALLBACK_HTTP_FILE_COMPLETION: {
153 case LWS_CALLBACK_HTTP_WRITEABLE: {
154 while ( !lws_send_pipe_choked(wsi) && (sent < standalone_html_len) ) {
155 size = standalone_html_len - sent;
157 int pwa = lws_get_peer_write_allowance(wsi);
160 lws_callback_on_writable(wsi);
165 if ( (pwa != -1) && (pwa < size) ) {
169 memcpy(p, standalone_html + sent, size);
171 rval = lws_write(wsi, p, size, LWS_WRITE_HTTP);
178 // while still active, extent timeout
179 lws_set_timeout(wsi, PENDING_TIMEOUT_HTTP_CONTENT, 5);
195 if (lws_http_transaction_completed(wsi)) {
203 static int callback_standalone(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len)
205 #define MAX_BUF_SIZE 1024
206 unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + MAX_BUF_SIZE + LWS_SEND_BUFFER_POST_PADDING];
207 unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
212 case LWS_CALLBACK_ESTABLISHED: {
215 if ( timestamp_elapsed(startup_reset_stamp) ) {
216 std_reset_standalone_gui();
222 case LWS_CALLBACK_CLOSED: {
228 case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: {
236 case LWS_CALLBACK_SERVER_WRITEABLE: {
237 while ( !Standalone_send_buf.empty() ) {
238 size = SDL_strlcpy((char *)p, Standalone_send_buf.front().c_str(), MAX_BUF_SIZE);
240 rval = lws_write(wsi, p, size, LWS_WRITE_TEXT);
243 lwsl_err("ERROR sending buffer!\n");
244 lws_close_reason(wsi, LWS_CLOSE_STATUS_UNEXPECTED_CONDITION, (unsigned char *)"write error", 11);
249 Standalone_send_buf.pop_front();
251 if ( lws_send_pipe_choked(wsi) ) {
252 lws_callback_on_writable(wsi);
261 case LWS_CALLBACK_RECEIVE: {
262 if (in != NULL && len > 0) {
263 const char *msg = (const char *)in;
266 if ( !SDL_strcmp(msg, "shutdown") ) {
267 gameseq_post_event(GS_EVENT_QUIT_GAME);
268 lws_close_reason(wsi, LWS_CLOSE_STATUS_GOINGAWAY, (unsigned char *)"shutdown", 8);
273 if ( !SDL_strcmp(msg, "reset") ) {
274 multi_quit_game(PROMPT_NONE);
275 std_reset_standalone_gui();
283 if ( !SDL_strncmp(msg+2, "name ", 5) ) {
284 SDL_strlcpy(Netgame.name, msg+7, SDL_arraysize(Netgame.name));
285 SDL_strlcpy(Multi_options_g.std_pname, Netgame.name, SDL_arraysize(Multi_options_g.std_pname));
286 } else if ( !SDL_strncmp(msg+2, "pass ", 5) ) {
287 SDL_strlcpy(Multi_options_g.std_passwd, msg+7, SDL_arraysize(Multi_options_g.std_passwd));
288 } else if ( !SDL_strncmp(msg+2, "kick ", 5) ) {
291 for (int i = 0; i < MAX_PLAYERS; i++) {
292 if ( MULTI_CONNECTED(Net_players[i]) ) {
293 psnet_addr_to_string(ip_string, SDL_arraysize(ip_string), &Net_players[i].p_info.addr);
295 if ( !SDL_strcmp(msg+7, ip_string) ) {
296 multi_kick_player(i, 0);
306 else if (mtype == 'M') {
308 if ( !SDL_strncmp(msg+2, "fps ", 4) ) {
309 int fps = SDL_atoi(msg+6);
311 Multi_options_g.std_framecap = fps;
316 else if (mtype == 'P') {
318 if ( !SDL_strncmp(msg+2, "info ", 5) ) {
321 for (i = 0; i < MAX_PLAYERS; i++) {
322 net_player *np = &Net_players[i];
324 if ( MULTI_CONNECTED((*np)) && (Net_player != np) ) {
325 if ( !SDL_strcmp(msg+7, np->player->callsign) ) {
326 Standalone_state.active_player = msg+7;
327 std_pinfo_display_player_info(np);
334 if (i == MAX_PLAYERS) {
335 Standalone_state.active_player.clear();
341 else if (mtype == 'G') {
343 if ( !SDL_strncmp(msg+2, "smsg ", 5) ) {
346 SDL_strlcpy(txt, msg+7, SDL_arraysize(txt));
348 if (SDL_strlen(txt) > 0) {
349 send_game_chat_packet(Net_player, txt, MULTI_MSG_ALL, NULL);
351 std_add_chat_text(txt, MY_NET_PLAYER_NUM, 1);
353 } else if ( !SDL_strcmp(msg+2, "mrefresh") ) {
354 if (MULTI_IS_TRACKER_GAME) {
355 cf_delete(MULTI_VALID_MISSION_FILE, CF_TYPE_DATA);
357 multi_update_valid_missions();
374 static struct lws_protocols stand_protocols[] = {
396 static void std_lws_logger(int level, const char *line)
398 if (level & (LLL_WARN|LLL_ERR)) {
399 mprintf(("STD: %s", line));
400 } else if (level & LLL_NOTICE) {
401 nprintf(("lws", "STD: %s", line));
407 static void std_add_ws_message(const char *id, const char *val)
411 // if no client, and startup stamp elapsed, then don't add more messages
412 if ( (active_wsi == NULL) && timestamp_elapsed(startup_reset_stamp) ) {
422 Standalone_send_buf.push_back(msg);
425 void std_deinit_standalone()
428 lws_cancel_service(stand_context);
429 lws_context_destroy(stand_context);
430 stand_context = NULL;
434 void std_init_standalone()
436 struct lws_context_creation_info info;
444 // basic security measure for admin interface
445 // "1" bind to loopback iface only *default*
446 // "0" bind to any/all
447 // any other value should be ip or iface name to bind
448 // (invalid values will trigger error)
450 const char *stand_iface = os_config_read_string("Network", "RestrictStandAdmin", "1");
452 if ( !SDL_strcmp(stand_iface, "1") ) {
453 info.iface = "127.0.0.1";
454 } else if ( !SDL_strcmp(stand_iface, "0") ) {
457 info.iface = stand_iface;
460 info.port = Multi_options_g.port;
462 info.protocols = stand_protocols;
467 lws_set_log_level(LLL_ERR|LLL_WARN|LLL_NOTICE, std_lws_logger);
469 stand_context = lws_create_context(&info);
471 if (stand_context == NULL) {
472 Error(LOCATION, "Unable to initialize standalone server!");
475 atexit(std_deinit_standalone);
477 // turn off all sound and music
478 Cmdline_freespace_no_sound = 1;
479 Cmdline_freespace_no_music = 1;
482 SDL_snprintf(title, SDL_arraysize(title), "%s %d.%02d.%02d", XSTR("FreeSpace Standalone", 935), FS_VERSION_MAJOR, FS_VERSION_MINOR, FS_VERSION_BUILD);
483 Standalone_state.title = title;
485 // connections > 5 sec after startup should get gui reset
486 startup_reset_stamp = timestamp(5000);
488 std_reset_standalone_gui();
490 std_multi_update_netgame_info_controls();
493 static void std_update_ping_all()
495 std::string ping_upd;
498 for (int i = 0, idx = 0; i < MAX_PLAYERS; i++) {
499 net_player *np = &Net_players[i];
501 if ( MULTI_CONNECTED((*np)) && (Net_player != np) ) {
502 if (np->s_info.ping.ping_avg > -1) {
503 if (np->s_info.ping.ping_avg >= 1000) {
504 SDL_snprintf(ping_str, SDL_arraysize(ping_str), "%s", XSTR("> 1 sec", 914));
506 SDL_snprintf(ping_str, SDL_arraysize(ping_str), "%d%s", np->s_info.ping.ping_avg, XSTR(" ms", 915));
512 // append separator if not first
514 ping_upd.append(",");
517 ping_upd.append(ping_str);
521 if ( !ping_upd.empty() ) {
522 std_add_ws_message("S:ping ", ping_upd.c_str());
526 static void std_update_connections()
528 std::string conn_str;
531 conn_str.reserve(1024);
533 for (int i = 0, idx = 0; i < MAX_PLAYERS; i++) {
534 net_player *np = &Net_players[i];
536 if ( MULTI_CONNECTED((*np)) && (Net_player != np) ) {
537 // append seperator if not first
539 conn_str.append(";");
542 conn_str.append(np->player->callsign);
543 conn_str.append(",");
545 psnet_addr_to_string(ip_address, SDL_arraysize(ip_address), &np->p_info.addr);
546 conn_str.append(ip_address);
550 SDL_assert(conn_str.length() < 1024);
552 if ( !conn_str.empty() ) {
553 std_add_ws_message("S:conn ", conn_str.c_str());
557 void std_do_gui_frame()
559 // maybe update selected player stats
560 if ( ((Standalone_stats_stamp == -1) || timestamp_elapsed(Standalone_stats_stamp)) && !Standalone_state.active_player.empty() ) {
561 Standalone_stats_stamp = timestamp(STD_STATS_UPDATE_TIME);
563 for (int i = 0; i < MAX_PLAYERS; i++) {
564 net_player *np = &Net_players[i];
566 if ( MULTI_CONNECTED((*np)) && (Net_player != np) ) {
567 if ( !SDL_strcmp(Standalone_state.active_player.c_str(), np->player->callsign) ) {
568 std_pinfo_display_player_info(np);
576 // maybe update netgame info
577 if ( (Standalone_ng_stamp == -1) || timestamp_elapsed(Standalone_ng_stamp) ) {
578 Standalone_ng_stamp = timestamp(STD_NG_UPDATE_TIME);
580 std_multi_update_netgame_info_controls();
583 // update connection ping times
584 if ( ((Standalone_ping_stamp == -1) || timestamp_elapsed(Standalone_ping_stamp)) ) {
585 Standalone_ping_stamp = timestamp(STD_PING_UPDATE_TIME);
587 std_update_ping_all();
590 if ( !Standalone_send_buf.empty() ) {
591 lws_callback_on_writable_all_protocol(stand_context, &stand_protocols[1]);
594 lws_service(stand_context, 0);
597 void std_debug_set_standalone_state_string(const char *str)
599 Standalone_state.debug_txt = str;
601 std_add_ws_message("D:", str);
604 void std_connect_set_gamename(const char *name)
607 // if a permanent name exists, use that instead of the default
608 if ( SDL_strlen(Multi_options_g.std_pname) ) {
609 SDL_strlcpy(Netgame.name, Multi_options_g.std_pname, SDL_arraysize(Netgame.name));
611 SDL_strlcpy(Netgame.name, XSTR("Standalone Server", 916), SDL_arraysize(Netgame.name));
614 SDL_strlcpy(Netgame.name, name, SDL_arraysize(Netgame.name));
617 std_add_ws_message("S:name ", Netgame.name);
620 int std_connect_set_connect_count()
624 for (int i = 0; i < MAX_PLAYERS; i++) {
625 if (MULTI_CONNECTED(Net_players[i]) && (Net_player != &Net_players[i]) ) {
633 void std_add_player(net_player *p)
635 std_update_connections();
637 // clear active player, client should reset if needed
638 Standalone_state.active_player.clear();
640 // check to see if this guy is the host
641 std_connect_set_host_connect_status();
644 int std_remove_player(net_player *p)
648 std_update_connections();
650 // clear active player, client should reset if needed
651 Standalone_state.active_player.clear();
653 // update the host connect count
654 std_connect_set_host_connect_status();
656 // update the currently connected players
657 count = std_connect_set_connect_count();
660 multi_quit_game(PROMPT_NONE);
667 void std_update_player_ping(net_player *p)
671 void std_pinfo_display_player_info(net_player *p)
679 pinfo.append(Ship_info[p->p_info.ship_class].name);
683 if (p->s_info.ping.ping_avg > 1000) {
684 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%s", XSTR("> 1 sec", 914));
686 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d%s", p->s_info.ping.ping_avg, XSTR(" ms", 915));
689 pinfo.append(sml_ping);
692 scoring_struct *ptr = &p->player->stats;
695 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->p_shots_fired);
696 pinfo.append(sml_ping);
698 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->p_shots_hit);
699 pinfo.append(sml_ping);
701 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->p_bonehead_hits);
702 pinfo.append(sml_ping);
704 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);
705 pinfo.append(sml_ping);
707 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);
708 pinfo.append(sml_ping);
710 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->s_shots_fired);
711 pinfo.append(sml_ping);
713 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->s_shots_hit);
714 pinfo.append(sml_ping);
716 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->s_bonehead_hits);
717 pinfo.append(sml_ping);
719 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);
720 pinfo.append(sml_ping);
722 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);
723 pinfo.append(sml_ping);
725 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->assists);
726 pinfo.append(sml_ping);
727 pinfo.append(";"); // <- end of block
730 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->mp_shots_fired);
731 pinfo.append(sml_ping);
733 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->mp_shots_hit);
734 pinfo.append(sml_ping);
736 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->mp_bonehead_hits);
737 pinfo.append(sml_ping);
739 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);
740 pinfo.append(sml_ping);
742 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);
743 pinfo.append(sml_ping);
745 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->ms_shots_fired);
746 pinfo.append(sml_ping);
748 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->ms_shots_hit);
749 pinfo.append(sml_ping);
751 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->ms_bonehead_hits);
752 pinfo.append(sml_ping);
754 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);
755 pinfo.append(sml_ping);
757 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);
758 pinfo.append(sml_ping);
760 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->m_assists);
761 pinfo.append(sml_ping);
763 std_add_ws_message("P:info ", pinfo.c_str());
766 void std_add_chat_text(const char *text, int player_index, int add_id)
771 if ( (player_index < 0) || (player_index >= MAX_PLAYERS) ) {
775 // format the chat text nicely
777 if ( MULTI_STANDALONE(Net_players[player_index]) ) {
778 SDL_snprintf(id, SDL_arraysize(id), XSTR("<SERVER> %s", 924), "");
780 SDL_snprintf(id, SDL_arraysize(id), "%s: ", Net_players[player_index].player->callsign);
789 std_add_ws_message("G:mesg ", msg.c_str());
792 void std_reset_timestamps()
794 // reset the stats update stamp
795 Standalone_stats_stamp = timestamp(STD_STATS_UPDATE_TIME);
797 // reset the netgame controls update timestamp
798 Standalone_ng_stamp = timestamp(STD_NG_UPDATE_TIME);
800 // reset the ping update stamp
801 Standalone_ping_stamp = timestamp(STD_PING_UPDATE_TIME);
803 // reset fps update stamp
804 Standalone_fps_stamp = timestamp(STD_FPS_UPDATE_TIME);
807 void std_add_ban(const char *name)
809 if ( (name == NULL) || !SDL_strlen(name) ) {
813 if (Standalone_ban_list.size() >= STANDALONE_MAX_BAN) {
817 Standalone_ban_list.push_back(name);
820 int std_player_is_banned(const char *name)
822 if ( Standalone_ban_list.empty() ) {
826 for (size_t i = 0; i < Standalone_ban_list.size(); i++) {
827 if ( !SDL_strcasecmp(name, Standalone_ban_list[i].c_str()) ) {
835 int std_is_host_passwd()
837 return (SDL_strlen(Multi_options_g.std_passwd) > 0) ? 1 : 0;
840 void std_multi_set_standalone_mission_name(const char *mission_name)
842 std_add_ws_message("M:name ", mission_name);
845 void std_multi_set_standalone_missiontime(float mission_time)
849 fix m_time = fl2f(mission_time);
851 // format the time string and set the text
852 game_format_time(m_time, timestr, SDL_arraysize(timestr));
853 SDL_snprintf(txt, SDL_arraysize(txt), "%s : %.1f", timestr, mission_time);
855 std_add_ws_message("M:time ", txt);
858 void std_multi_update_netgame_info_controls()
862 SDL_snprintf(nginfo, SDL_arraysize(nginfo), "%d,%d,%d,%d", Netgame.max_players, Netgame.options.max_observers, Netgame.security, Netgame.respawn);
864 std_add_ws_message("M:info ", nginfo);
867 void std_set_standalone_fps(float fps)
869 if ( (Standalone_fps_stamp == -1) || timestamp_elapsed(Standalone_fps_stamp) ) {
870 Standalone_fps_stamp = timestamp(STD_FPS_UPDATE_TIME);
874 SDL_snprintf(rfps, SDL_arraysize(rfps), "%.1f", fps);
876 std_add_ws_message("M:rfps ", rfps);
880 void std_multi_setup_goal_tree()
882 std::string mission_goals;
884 std::string secondary;
888 for (int i = 0; i < Num_goals; i++) {
889 switch (Mission_goals[i].satisfied) {
895 case GOAL_COMPLETE: {
900 case GOAL_INCOMPLETE:
907 switch (Mission_goals[i].type & GOAL_TYPE_MASK) {
909 primary.append(status);
910 primary.append(Mission_goals[i].name);
916 case SECONDARY_GOAL: {
917 secondary.append(status);
918 secondary.append(Mission_goals[i].name);
919 secondary.append(",");
925 bonus.append(status);
926 bonus.append(Mission_goals[i].name);
937 if ( primary.empty() ) {
938 mission_goals.append("i none");
940 mission_goals.append(primary.substr(0, primary.size()-1));
943 mission_goals.append(";");
945 if ( secondary.empty() ) {
946 mission_goals.append("i none");
948 mission_goals.append(secondary.substr(0, secondary.size()-1));
951 mission_goals.append(";");
953 if ( bonus.empty() ) {
954 mission_goals.append("i none");
956 mission_goals.append(bonus.substr(0, bonus.size()-1));
959 std_add_ws_message("M:goal ", mission_goals.c_str());
962 void std_multi_add_goals()
964 std_multi_setup_goal_tree();
967 void std_multi_update_goals()
969 std_multi_setup_goal_tree();
972 void std_reset_standalone_gui()
974 Standalone_send_buf.clear();
976 std_add_ws_message("reset", NULL);
978 std_add_ws_message("T:", Standalone_state.title.c_str());
979 std_add_ws_message("D:", Standalone_state.debug_txt.c_str());
981 std_add_ws_message("S:name ", Netgame.name);
982 std_add_ws_message("S:pass ", Multi_options_g.std_passwd);
984 std_update_connections();
985 std_set_standalone_fps(0.0f);
986 std_multi_set_standalone_missiontime(0.0f);
987 std_multi_update_netgame_info_controls();
989 Standalone_fps_stamp = -1;
990 Standalone_ng_stamp = -1;
991 Standalone_ping_stamp = -1;
992 Standalone_stats_stamp = -1;
994 Standalone_state.active_player.clear();
998 void std_create_gen_dialog(const char *title)
1000 Standalone_state.popup_title = title;
1002 Standalone_state.popup_field1 = "";
1003 Standalone_state.popup_field2 = "";
1006 void std_destroy_gen_dialog()
1008 std_add_ws_message("popup ", NULL);
1011 void std_gen_set_text(const char *str, int field_num)
1013 std::string popup_str;
1015 switch (field_num) {
1017 Standalone_state.popup_title = str;
1021 Standalone_state.popup_field1 = str;
1025 Standalone_state.popup_field2 = str;
1032 popup_str.append(Standalone_state.popup_title);
1033 popup_str.append(";");
1034 popup_str.append(Standalone_state.popup_field1);
1035 popup_str.append(";");
1036 popup_str.append(Standalone_state.popup_field2);
1038 std_add_ws_message("popup ", popup_str.c_str());
1040 // force ws write since do_frame() may not happen until popup is done
1041 lws_callback_on_writable_all_protocol(stand_context, &stand_protocols[1]);
1042 lws_service(stand_context, 0);
1045 void std_tracker_notify_login_fail()
1050 void std_tracker_login()
1052 if ( !Multi_options_g.pxo ) {
1056 multi_fs_tracker_init();
1058 if ( !multi_fs_tracker_inited() ) {
1059 std_tracker_notify_login_fail();
1063 multi_fs_tracker_login_freespace();
1066 void std_connect_set_host_connect_status()