54 : announce_time(0), server_config(0), motd_index(1)
62 WORD server_port = 11100;
85 c->
name =
"Persistent Multiplayer";
89 while (++c_iter && !mission_id) {
94 while (++m_iter && !mission_id) {
141 net_lobby_server =
this;
160 if (net_lobby_server ==
this)
161 net_lobby_server = 0;
167 return net_lobby_server;
178 fopen_s(&f,
"motd.txt",
"r");
183 while (fgets(line, 256, f)) {
184 int n = strlen(line) - 1;
186 while (n >= 0 && isspace(line[n]))
201 for (
int i = 0; i <
motd.
size(); i++) {
204 sprintf_s(buffer,
"id %d user \" \" msg \"%s\"",
210 sprintf_s(buffer,
"id %d user \" \" msg \" \"",
motd_index++);
222 if (mods.
size() < 1)
return;
224 for (
int i = 0; i < mods.
size(); i++) {
227 sprintf_s(buffer,
"id %d user \"Enabled Mods:\" msg \"%d. '%s' ",
247 sprintf_s(buffer,
"id %d user \" \" msg \" \"",
motd_index++);
272 DWORD mission_id = 0;
281 if (!c || c->
name !=
"Persistent Multiplayer") {
284 c->
name =
"Persistent Multiplayer";
292 while (++c_iter && !mission_id) {
297 while (++m_iter && !mission_id) {
329 if (
link && dst && type > 0 && type < 255) {
345 bool dropped =
false;
370 ::Print(
"NetLobbyServer::CheckSessions() Could not find player for '%s'\n", u->
Name().
data());
374 ::Print(
"NetLobbyServer::CheckSessions() Could not find net game for '%s'\n", u->
Name().
data());
380 Print(
"NetLobbyServer: Dropped inactive connection '%s' %s\n",
384 Print(
" User was host - ending net game.\n");
440 if (user && !user->
IsHost()) {
441 ::Print(
"NetLobbyServer::BanUser name '%s' addr %d.%d.%d.%d\n",
515 if (user && msg && *msg) {
519 while (*p && !msg_ok) {
543 sprintf_s(buffer,
"id %d user \"%s\" msg \"%s\"",
544 entry->
GetID(), usr_buf, msg_buf);
571 fopen_s(&f,
"chat.txt",
"w");
575 fprintf(f,
"%08x [%s] %s\n",
630 if (elem->
Count() == 1) {
646 for (
int i = 0; i < elem->
Count(); i++) {
667 for (i = 0; i < units.
size(); i++) {
680 for (i = 0; i < units.
size(); i++) {
758 while (++u_iter && !unit) {
792 const char* type =
"Starshatter";
793 const char* password =
"No";
796 strcpy_s(address,
"0");
803 type =
"Starshatter-LAN";
804 sprintf_s(address,
"%d.%d.%d.%d",
811 type =
"Starshatter";
812 sprintf_s(address,
"0.0.0.0");
840 if (peer && peer->
NetID()) {
842 WORD gameport = 11101;
847 sprintf_s(buffer,
"info \"%s\" version \"%s\" mode %d users %d host %s port %d",
862 if (peer && peer->
NetID()) {
869 sprintf_s(buffer,
"num %d ", mods.
size());
875 response +=
"mod \"";
876 response += info->
Name();
877 response +=
"\" url \"";
878 response += info->
URL();
879 response +=
"\" ver \"";
909 for (
int i = 0; i < params.
size(); i++) {
913 sscanf_s(p->
value,
"%d", &num);
915 if (p->
name ==
"name")
918 else if (p->
name ==
"pass")
921 else if (p->
name ==
"gamepass")
924 else if (p->
name ==
"host")
927 else if (p->
name ==
"sig")
928 signature = p->
value;
930 else if (p->
name ==
"squad")
933 else if (p->
name ==
"version")
936 else if (p->
name ==
"rank")
939 else if (p->
name ==
"time")
942 else if (p->
name ==
"miss")
945 else if (p->
name ==
"kill")
948 else if (p->
name ==
"loss")
956 Print(
"NetLobbyServer - user '%s' tried to login with invalid game version '%s'\n",
965 Print(
"NetLobbyServer - user '%s' tried to login with invalid game password '%s'\n",
977 if (pre_existing->
Pass() == pass &&
996 if (host ==
"true" && !
HasHost())
1030 sprintf_s(buffer,
"id %d user \"SERVER\" msg \"**********\"",
motd_index++);
1033 sprintf_s(buffer,
"id %d user \"SERVER\" msg \"*** Your game configuration does not match the server.\"",
motd_index++);
1037 sprintf_s(buffer,
"id %d user \"SERVER\" msg \"*** Please check that you have the proper mods deployed in\"",
motd_index++);
1039 sprintf_s(buffer,
"id %d user \"SERVER\" msg \"*** the order shown above.\"",
motd_index++);
1044 sprintf_s(buffer,
"id %d user \"SERVER\" msg \"*** Please verify that you have no mods deployed.\"",
motd_index++);
1048 sprintf_s(buffer,
"id %d user \"SERVER\" msg \"*** You will not be permitted to join the game with an invalid\"",
motd_index++);
1051 sprintf_s(buffer,
"id %d user \"SERVER\" msg \"*** configuration. You may reconnect to this server after you\"",
motd_index++);
1054 sprintf_s(buffer,
"id %d user \"SERVER\" msg \"*** have corrected your mod configuration.\"",
motd_index++);
1057 sprintf_s(buffer,
"id %d user \"SERVER\" msg \"**********\"",
motd_index++);
1060 sprintf_s(buffer,
"id %d user \" \" msg \" \"",
motd_index++);
1074 for (
int i = 0; i < params.
size(); i++) {
1078 sscanf_s(p->
value,
"%d", &num);
1080 if (p->
name ==
"msg") {
1081 chat_msg = p->
value;
1113 sprintf_s(buffer,
"id %d user \"%s\" msg \"%s\"",
1114 entry->
GetID(), usr_buf, msg_buf);
1152 if (params.
size() > 0) {
1155 if (p->
name ==
"user") {
1182 sprintf_s(buffer,
"c_id 0x%08x c_name \"%s\" ",
1203 sprintf_s(buffer,
"m_id 0x%08x ", mission_id);
1206 reply +=
"m_name \"";
1213 while (*s && n < 4090) {
1218 else if (*s ==
'\n') {
1223 else if (*s ==
'\t') {
1236 reply +=
"\" m_desc \"";
1263 for (
int i = 0; i < params.
size(); i++) {
1267 sscanf_s(p->
value,
"0x%x", &num);
1269 if (p->
name ==
"m_id") {
1287 FILE* f = ::fopen(
"multi_mission_send.def",
"w");
1289 ::fwrite(reply.
data(), reply.
length(), 1, f);
1326 for (
int i = 0; i < params.
size(); i++) {
1329 if (p->
name ==
"id") {
1330 sscanf_s(p->
value,
"%d", &
id);
1333 else if (p->
name ==
"user") {
1334 user_name = p->
value;
1337 else if (p->
name ==
"lock") {
1338 lock = (p->
value ==
"true") ?
true :
false;