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);
312 Multi_options_g.std_framecap = fps;
317 else if (mtype == 'P') {
319 if ( !SDL_strncmp(msg+2, "info ", 5) ) {
322 for (i = 0; i < MAX_PLAYERS; i++) {
323 net_player *np = &Net_players[i];
325 if ( MULTI_CONNECTED((*np)) && (Net_player != np) ) {
326 if ( !SDL_strcmp(msg+7, np->player->callsign) ) {
327 Standalone_state.active_player = msg+7;
328 std_pinfo_display_player_info(np);
335 if (i == MAX_PLAYERS) {
336 Standalone_state.active_player.clear();
342 else if (mtype == 'G') {
344 if ( !SDL_strncmp(msg+2, "smsg ", 5) ) {
347 SDL_strlcpy(txt, msg+7, SDL_arraysize(txt));
349 if (SDL_strlen(txt) > 0) {
350 send_game_chat_packet(Net_player, txt, MULTI_MSG_ALL, NULL);
352 std_add_chat_text(txt, MY_NET_PLAYER_NUM, 1);
354 } else if ( !SDL_strcmp(msg+2, "mrefresh") ) {
355 if (MULTI_IS_TRACKER_GAME) {
356 cf_delete(MULTI_VALID_MISSION_FILE, CF_TYPE_DATA);
358 multi_update_valid_missions();
375 static struct lws_protocols stand_protocols[] = {
397 static void std_lws_logger(int level, const char *line)
399 if (level & (LLL_WARN|LLL_ERR)) {
400 mprintf(("STD: %s", line));
401 } else if (level & LLL_NOTICE) {
402 nprintf(("lws", "STD: %s", line));
408 static void std_add_ws_message(const char *id, const char *val)
412 // if no client, and startup stamp elapsed, then don't add more messages
413 if ( (active_wsi == NULL) && timestamp_elapsed(startup_reset_stamp) ) {
423 Standalone_send_buf.push_back(msg);
426 void std_deinit_standalone()
429 lws_cancel_service(stand_context);
430 lws_context_destroy(stand_context);
431 stand_context = NULL;
435 void std_init_standalone()
437 struct lws_context_creation_info info;
445 // basic security measure for admin interface
446 // "1" bind to loopback iface only *default*
447 // "0" bind to any/all
448 // any other value should be ip or iface name to bind
449 // (invalid values will trigger error)
451 const char *stand_iface = os_config_read_string("Network", "RestrictStandAdmin", "1");
453 if ( !SDL_strcmp(stand_iface, "1") ) {
454 info.iface = "127.0.0.1";
455 } else if ( !SDL_strcmp(stand_iface, "0") ) {
458 info.iface = stand_iface;
461 info.port = Multi_options_g.port;
463 info.protocols = stand_protocols;
468 lws_set_log_level(LLL_ERR|LLL_WARN|LLL_NOTICE, std_lws_logger);
470 stand_context = lws_create_context(&info);
472 if (stand_context == NULL) {
473 Error(LOCATION, "Unable to initialize standalone server!");
476 atexit(std_deinit_standalone);
478 // turn off all sound and music
479 Cmdline_freespace_no_sound = 1;
480 Cmdline_freespace_no_music = 1;
483 SDL_snprintf(title, SDL_arraysize(title), "%s %d.%02d.%02d", XSTR("FreeSpace Standalone", 935), FS_VERSION_MAJOR, FS_VERSION_MINOR, FS_VERSION_BUILD);
484 Standalone_state.title = title;
486 // connections > 5 sec after startup should get gui reset
487 startup_reset_stamp = timestamp(5000);
489 std_reset_standalone_gui();
491 std_multi_update_netgame_info_controls();
494 static void std_update_ping_all()
496 std::string ping_upd;
499 for (int i = 0, idx = 0; i < MAX_PLAYERS; i++) {
500 net_player *np = &Net_players[i];
502 if ( MULTI_CONNECTED((*np)) && (Net_player != np) ) {
503 if (np->s_info.ping.ping_avg > -1) {
504 if (np->s_info.ping.ping_avg >= 1000) {
505 SDL_snprintf(ping_str, SDL_arraysize(ping_str), "%s", XSTR("> 1 sec", 914));
507 SDL_snprintf(ping_str, SDL_arraysize(ping_str), "%d%s", np->s_info.ping.ping_avg, XSTR(" ms", 915));
513 // append separator if not first
515 ping_upd.append(",");
518 ping_upd.append(ping_str);
522 if ( !ping_upd.empty() ) {
523 std_add_ws_message("S:ping ", ping_upd.c_str());
527 static void std_update_connections()
529 std::string conn_str;
532 conn_str.reserve(1024);
534 for (int i = 0, idx = 0; i < MAX_PLAYERS; i++) {
535 net_player *np = &Net_players[i];
537 if ( MULTI_CONNECTED((*np)) && (Net_player != np) ) {
538 // append seperator if not first
540 conn_str.append(";");
543 conn_str.append(np->player->callsign);
544 conn_str.append(",");
546 psnet_addr_to_string(ip_address, SDL_arraysize(ip_address), &np->p_info.addr);
547 conn_str.append(ip_address);
551 SDL_assert(conn_str.length() < 1024);
553 if ( !conn_str.empty() ) {
554 std_add_ws_message("S:conn ", conn_str.c_str());
558 void std_do_gui_frame()
560 // maybe update selected player stats
561 if ( ((Standalone_stats_stamp == -1) || timestamp_elapsed(Standalone_stats_stamp)) && !Standalone_state.active_player.empty() ) {
562 Standalone_stats_stamp = timestamp(STD_STATS_UPDATE_TIME);
564 for (int i = 0; i < MAX_PLAYERS; i++) {
565 net_player *np = &Net_players[i];
567 if ( MULTI_CONNECTED((*np)) && (Net_player != np) ) {
568 if ( !SDL_strcmp(Standalone_state.active_player.c_str(), np->player->callsign) ) {
569 std_pinfo_display_player_info(np);
577 // maybe update netgame info
578 if ( (Standalone_ng_stamp == -1) || timestamp_elapsed(Standalone_ng_stamp) ) {
579 Standalone_ng_stamp = timestamp(STD_NG_UPDATE_TIME);
581 std_multi_update_netgame_info_controls();
584 // update connection ping times
585 if ( ((Standalone_ping_stamp == -1) || timestamp_elapsed(Standalone_ping_stamp)) ) {
586 Standalone_ping_stamp = timestamp(STD_PING_UPDATE_TIME);
588 std_update_ping_all();
591 if ( !Standalone_send_buf.empty() ) {
592 lws_callback_on_writable_all_protocol(stand_context, &stand_protocols[1]);
595 lws_service(stand_context, 0);
598 void std_debug_set_standalone_state_string(const char *str)
600 Standalone_state.debug_txt = str;
602 std_add_ws_message("D:", str);
605 void std_connect_set_gamename(const char *name)
608 // if a permanent name exists, use that instead of the default
609 if ( SDL_strlen(Multi_options_g.std_pname) ) {
610 SDL_strlcpy(Netgame.name, Multi_options_g.std_pname, SDL_arraysize(Netgame.name));
612 SDL_strlcpy(Netgame.name, XSTR("Standalone Server", 916), SDL_arraysize(Netgame.name));
615 SDL_strlcpy(Netgame.name, name, SDL_arraysize(Netgame.name));
618 std_add_ws_message("S:name ", Netgame.name);
621 int std_connect_set_connect_count()
625 for (int i = 0; i < MAX_PLAYERS; i++) {
626 if (MULTI_CONNECTED(Net_players[i]) && (Net_player != &Net_players[i]) ) {
634 void std_add_player(net_player *p)
636 std_update_connections();
638 // clear active player, client should reset if needed
639 Standalone_state.active_player.clear();
641 // check to see if this guy is the host
642 std_connect_set_host_connect_status();
645 int std_remove_player(net_player *p)
649 std_update_connections();
651 // clear active player, client should reset if needed
652 Standalone_state.active_player.clear();
654 // update the host connect count
655 std_connect_set_host_connect_status();
657 // update the currently connected players
658 count = std_connect_set_connect_count();
661 multi_quit_game(PROMPT_NONE);
668 void std_update_player_ping(net_player *p)
672 void std_pinfo_display_player_info(net_player *p)
680 pinfo.append(Ship_info[p->p_info.ship_class].name);
684 if (p->s_info.ping.ping_avg > 1000) {
685 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%s", XSTR("> 1 sec", 914));
687 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d%s", p->s_info.ping.ping_avg, XSTR(" ms", 915));
690 pinfo.append(sml_ping);
693 scoring_struct *ptr = &p->player->stats;
696 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->p_shots_fired);
697 pinfo.append(sml_ping);
699 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->p_shots_hit);
700 pinfo.append(sml_ping);
702 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->p_bonehead_hits);
703 pinfo.append(sml_ping);
705 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);
706 pinfo.append(sml_ping);
708 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);
709 pinfo.append(sml_ping);
711 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->s_shots_fired);
712 pinfo.append(sml_ping);
714 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->s_shots_hit);
715 pinfo.append(sml_ping);
717 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->s_bonehead_hits);
718 pinfo.append(sml_ping);
720 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);
721 pinfo.append(sml_ping);
723 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);
724 pinfo.append(sml_ping);
726 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->assists);
727 pinfo.append(sml_ping);
728 pinfo.append(";"); // <- end of block
731 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->mp_shots_fired);
732 pinfo.append(sml_ping);
734 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->mp_shots_hit);
735 pinfo.append(sml_ping);
737 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->mp_bonehead_hits);
738 pinfo.append(sml_ping);
740 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);
741 pinfo.append(sml_ping);
743 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);
744 pinfo.append(sml_ping);
746 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->ms_shots_fired);
747 pinfo.append(sml_ping);
749 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->ms_shots_hit);
750 pinfo.append(sml_ping);
752 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->ms_bonehead_hits);
753 pinfo.append(sml_ping);
755 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);
756 pinfo.append(sml_ping);
758 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);
759 pinfo.append(sml_ping);
761 SDL_snprintf(sml_ping, SDL_arraysize(sml_ping), "%d", ptr->m_assists);
762 pinfo.append(sml_ping);
764 std_add_ws_message("P:info ", pinfo.c_str());
767 void std_add_chat_text(const char *text, int player_index, int add_id)
772 if ( (player_index < 0) || (player_index >= MAX_PLAYERS) ) {
776 // format the chat text nicely
778 if ( MULTI_STANDALONE(Net_players[player_index]) ) {
779 SDL_snprintf(id, SDL_arraysize(id), XSTR("<SERVER> %s", 924), "");
781 SDL_snprintf(id, SDL_arraysize(id), "%s: ", Net_players[player_index].player->callsign);
790 std_add_ws_message("G:mesg ", msg.c_str());
793 void std_reset_timestamps()
795 // reset the stats update stamp
796 Standalone_stats_stamp = timestamp(STD_STATS_UPDATE_TIME);
798 // reset the netgame controls update timestamp
799 Standalone_ng_stamp = timestamp(STD_NG_UPDATE_TIME);
801 // reset the ping update stamp
802 Standalone_ping_stamp = timestamp(STD_PING_UPDATE_TIME);
804 // reset fps update stamp
805 Standalone_fps_stamp = timestamp(STD_FPS_UPDATE_TIME);
808 void std_add_ban(const char *name)
810 if ( (name == NULL) || !SDL_strlen(name) ) {
814 if (Standalone_ban_list.size() >= STANDALONE_MAX_BAN) {
818 Standalone_ban_list.push_back(name);
821 int std_player_is_banned(const char *name)
823 if ( Standalone_ban_list.empty() ) {
827 for (size_t i = 0; i < Standalone_ban_list.size(); i++) {
828 if ( !SDL_strcasecmp(name, Standalone_ban_list[i].c_str()) ) {
836 int std_is_host_passwd()
838 return (SDL_strlen(Multi_options_g.std_passwd) > 0) ? 1 : 0;
841 void std_multi_set_standalone_mission_name(const char *mission_name)
843 std_add_ws_message("M:name ", mission_name);
846 void std_multi_set_standalone_missiontime(float mission_time)
850 fix m_time = fl2f(mission_time);
852 // format the time string and set the text
853 game_format_time(m_time, timestr, SDL_arraysize(timestr));
854 SDL_snprintf(txt, SDL_arraysize(txt), "%s : %.1f", timestr, mission_time);
856 std_add_ws_message("M:time ", txt);
859 void std_multi_update_netgame_info_controls()
863 SDL_snprintf(nginfo, SDL_arraysize(nginfo), "%d,%d,%d,%d", Netgame.max_players, Netgame.options.max_observers, Netgame.security, Netgame.respawn);
865 std_add_ws_message("M:info ", nginfo);
868 void std_set_standalone_fps(float fps)
870 if ( (Standalone_fps_stamp == -1) || timestamp_elapsed(Standalone_fps_stamp) ) {
871 Standalone_fps_stamp = timestamp(STD_FPS_UPDATE_TIME);
875 SDL_snprintf(rfps, SDL_arraysize(rfps), "%.1f", fps);
877 std_add_ws_message("M:rfps ", rfps);
881 void std_multi_setup_goal_tree()
883 std::string mission_goals;
885 std::string secondary;
889 for (int i = 0; i < Num_goals; i++) {
890 switch (Mission_goals[i].satisfied) {
896 case GOAL_COMPLETE: {
901 case GOAL_INCOMPLETE:
908 switch (Mission_goals[i].type & GOAL_TYPE_MASK) {
910 primary.append(status);
911 primary.append(Mission_goals[i].name);
917 case SECONDARY_GOAL: {
918 secondary.append(status);
919 secondary.append(Mission_goals[i].name);
920 secondary.append(",");
926 bonus.append(status);
927 bonus.append(Mission_goals[i].name);
938 if ( primary.empty() ) {
939 mission_goals.append("i none");
941 mission_goals.append(primary.substr(0, primary.size()-1));
944 mission_goals.append(";");
946 if ( secondary.empty() ) {
947 mission_goals.append("i none");
949 mission_goals.append(secondary.substr(0, secondary.size()-1));
952 mission_goals.append(";");
954 if ( bonus.empty() ) {
955 mission_goals.append("i none");
957 mission_goals.append(bonus.substr(0, bonus.size()-1));
960 std_add_ws_message("M:goal ", mission_goals.c_str());
963 void std_multi_add_goals()
965 std_multi_setup_goal_tree();
968 void std_multi_update_goals()
970 std_multi_setup_goal_tree();
973 void std_reset_standalone_gui()
975 Standalone_send_buf.clear();
977 std_add_ws_message("reset", NULL);
979 std_add_ws_message("T:", Standalone_state.title.c_str());
980 std_add_ws_message("D:", Standalone_state.debug_txt.c_str());
982 std_add_ws_message("S:name ", Netgame.name);
983 std_add_ws_message("S:pass ", Multi_options_g.std_passwd);
985 std_update_connections();
986 std_set_standalone_fps(0.0f);
987 std_multi_set_standalone_missiontime(0.0f);
988 std_multi_update_netgame_info_controls();
990 Standalone_fps_stamp = -1;
991 Standalone_ng_stamp = -1;
992 Standalone_ping_stamp = -1;
993 Standalone_stats_stamp = -1;
995 Standalone_state.active_player.clear();
999 void std_create_gen_dialog(const char *title)
1001 Standalone_state.popup_title = title;
1003 Standalone_state.popup_field1 = "";
1004 Standalone_state.popup_field2 = "";
1007 void std_destroy_gen_dialog()
1009 std_add_ws_message("popup ", NULL);
1012 void std_gen_set_text(const char *str, int field_num)
1014 std::string popup_str;
1016 switch (field_num) {
1018 Standalone_state.popup_title = str;
1022 Standalone_state.popup_field1 = str;
1026 Standalone_state.popup_field2 = str;
1033 popup_str.append(Standalone_state.popup_title);
1034 popup_str.append(";");
1035 popup_str.append(Standalone_state.popup_field1);
1036 popup_str.append(";");
1037 popup_str.append(Standalone_state.popup_field2);
1039 std_add_ws_message("popup ", popup_str.c_str());
1041 // force ws write since do_frame() may not happen until popup is done
1042 lws_callback_on_writable_all_protocol(stand_context, &stand_protocols[1]);
1043 lws_service(stand_context, 0);
1046 void std_tracker_notify_login_fail()
1051 void std_tracker_login()
1053 if ( !Multi_options_g.pxo ) {
1057 multi_fs_tracker_init();
1059 if ( !multi_fs_tracker_inited() ) {
1060 std_tracker_notify_login_fail();
1064 multi_fs_tracker_login_freespace();
1067 void std_connect_set_host_connect_status()