+// QuakeWorld commands
+
+char emodel_name[] =
+ { 'e' ^ 0xff, 'm' ^ 0xff, 'o' ^ 0xff, 'd' ^ 0xff, 'e' ^ 0xff, 'l' ^ 0xff, 0 };
+char pmodel_name[] =
+ { 'p' ^ 0xff, 'm' ^ 0xff, 'o' ^ 0xff, 'd' ^ 0xff, 'e' ^ 0xff, 'l' ^ 0xff, 0 };
+char prespawn_name[] =
+ { 'p'^0xff, 'r'^0xff, 'e'^0xff, 's'^0xff, 'p'^0xff, 'a'^0xff, 'w'^0xff, 'n'^0xff,
+ ' '^0xff, '%'^0xff, 'i'^0xff, ' '^0xff, '0'^0xff, ' '^0xff, '%'^0xff, 'i'^0xff, 0 };
+char modellist_name[] =
+ { 'm'^0xff, 'o'^0xff, 'd'^0xff, 'e'^0xff, 'l'^0xff, 'l'^0xff, 'i'^0xff, 's'^0xff, 't'^0xff,
+ ' '^0xff, '%'^0xff, 'i'^0xff, ' '^0xff, '%'^0xff, 'i'^0xff, 0 };
+char soundlist_name[] =
+ { 's'^0xff, 'o'^0xff, 'u'^0xff, 'n'^0xff, 'd'^0xff, 'l'^0xff, 'i'^0xff, 's'^0xff, 't'^0xff,
+ ' '^0xff, '%'^0xff, 'i'^0xff, ' '^0xff, '%'^0xff, 'i'^0xff, 0 };
+
+/*
+=====================
+Host_Rcon_f
+
+ Send the rest of the command line over as
+ an unconnected command.
+=====================
+*/
+void Host_Rcon_f (void) // credit: taken from QuakeWorld
+{
+ lhnetaddress_t to;
+ lhnetsocket_t *mysocket;
+
+ if (!rcon_password.string)
+ {
+ Con_Printf ("You must set rcon_password before issuing an rcon command.\n");
+ return;
+ }
+
+ if (cls.netcon)
+ to = cls.netcon->peeraddress;
+ else
+ {
+ if (!rcon_address.integer || !rcon_address.string[0])
+ {
+ Con_Printf ("You must either be connected, or set the rcon_address cvar to issue rcon commands\n");
+ return;
+ }
+ LHNETADDRESS_FromString(&to, rcon_address.string, sv_netport.integer);
+ }
+ mysocket = NetConn_ChooseClientSocketForAddress(&to);
+ if (mysocket)
+ {
+ // simply put together the rcon packet and send it
+ NetConn_WriteString(mysocket, va("\377\377\377\377rcon %s %s", rcon_password.string, Cmd_Args()), &to);
+ }
+}
+
+/*
+====================
+Host_Packet_f
+
+packet <destination> <contents>
+
+Contents allows \n escape character
+====================
+*/
+void Host_Packet_f (void) // credit: taken from QuakeWorld
+{
+ char send[2048];
+ int i, l;
+ const char *in;
+ char *out;
+ lhnetaddress_t address;
+ lhnetsocket_t *mysocket;
+
+ if (Cmd_Argc() != 3)
+ {
+ Con_Printf ("packet <destination> <contents>\n");
+ return;
+ }
+
+ if (!LHNETADDRESS_FromString (&address, Cmd_Argv(1), sv_netport.integer))
+ {
+ Con_Printf ("Bad address\n");
+ return;
+ }
+
+ in = Cmd_Argv(2);
+ out = send+4;
+ send[0] = send[1] = send[2] = send[3] = 0xff;
+
+ l = strlen (in);
+ for (i=0 ; i<l ; i++)
+ {
+ if (out >= send + sizeof(send) - 1)
+ break;
+ if (in[i] == '\\' && in[i+1] == 'n')
+ {
+ *out++ = '\n';
+ i++;
+ }
+ else
+ *out++ = in[i];
+ }
+ *out = 0;
+
+ mysocket = NetConn_ChooseClientSocketForAddress(&address);
+ if (mysocket)
+ NetConn_WriteString(mysocket, send, &address);
+}
+
+//=============================================================================
+