about summary refs log tree commit diff
path: root/src/engine/client
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-01 14:36:36 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-01 14:36:36 +0000
commit0747c2dff9289db6204b82501d03447f3ec6cc99 (patch)
treeecca83ee860dfa5293f4dba9233820579a4bf4ac /src/engine/client
parent622dbc6f3e5a5f398af8c6ef98d057a200c813a0 (diff)
downloadzcatch-0747c2dff9289db6204b82501d03447f3ec6cc99.tar.gz
zcatch-0747c2dff9289db6204b82501d03447f3ec6cc99.zip
fixed remote console. some gui tweaks aswell.
Diffstat (limited to 'src/engine/client')
-rw-r--r--src/engine/client/ec_client.c47
1 files changed, 41 insertions, 6 deletions
diff --git a/src/engine/client/ec_client.c b/src/engine/client/ec_client.c
index 0ddcf7d9..56c817a6 100644
--- a/src/engine/client/ec_client.c
+++ b/src/engine/client/ec_client.c
@@ -58,6 +58,7 @@ static int snapcrcerrors = 0;
 
 static int ack_game_tick = -1;
 static int current_recv_tick = 0;
+static int rcon_authed = 0;
 
 /* pinging */
 static int64 ping_start_time = 0;
@@ -323,10 +324,23 @@ static void client_send_ready()
 	client_send_msg();
 }
 
+int client_rcon_authed()
+{
+	return rcon_authed;
+}
+
+void client_rcon_auth(const char *name, const char *password)
+{
+	msg_pack_start_system(NETMSG_RCON_AUTH, MSGFLAG_VITAL);
+	msg_pack_string(name, 32);
+	msg_pack_string(password, 32);
+	msg_pack_end();
+	client_send_msg();
+}
+
 void client_rcon(const char *cmd)
 {
-	msg_pack_start_system(NETMSG_CMD, MSGFLAG_VITAL);
-	msg_pack_string(config.rcon_password, 32);
+	msg_pack_start_system(NETMSG_RCON_CMD, MSGFLAG_VITAL);
 	msg_pack_string(cmd, 256);
 	msg_pack_end();
 	client_send_msg();
@@ -470,17 +484,18 @@ void client_connect(const char *server_address_str)
 	if(net_host_lookup(buf, port, &server_address) != 0)
 		dbg_msg("client", "could not find the address of %s, connecting to localhost", buf);
 	
+	rcon_authed = 0;
 	netclient_connect(net, &server_address);
 	client_set_state(CLIENTSTATE_CONNECTING);
 	
 	graph_init(&intra_graph, 0.0f, 1.0f);
 	graph_init(&input_late_graph, 0.0f, 1.0f);
 	graph_init(&predict_graph, 0.0f, 200.0f);
-	
 }
 
 void client_disconnect_with_reason(const char *reason)
 {
+	rcon_authed = 0;
 	netclient_disconnect(net, reason);
 	client_set_state(CLIENTSTATE_OFFLINE);
 	map_unload();
@@ -722,7 +737,7 @@ static void client_process_packet(NETPACKET *packet)
 		if(sys)
 		{
 			/* system message */
-			if(msg == NETMSG_MAP)
+			if(msg == NETMSG_MAP_CHANGE)
 			{
 				const char *map = msg_unpack_string();
 				int map_crc = msg_unpack_int();
@@ -830,6 +845,21 @@ static void client_process_packet(NETPACKET *packet)
 				msg_pack_end();
 				client_send_msg();
 			}
+			else if(msg == NETMSG_RCON_AUTH_STATUS)
+			{
+				int result = msg_unpack_int();
+				if(msg_unpack_error() == 0)
+					rcon_authed = result;
+			}
+			else if(msg == NETMSG_RCON_LINE)
+			{
+				const char *line = msg_unpack_string();
+				if(msg_unpack_error() == 0)
+				{
+					/*dbg_msg("remote", "%s", line);*/
+					modc_rcon_line(line);
+				}
+			}
 			else if(msg == NETMSG_PING_REPLY)
 				dbg_msg("client/network", "latency %.2f", (time_get() - ping_start_time)*1000 / (float)time_freq());
 			else if(msg == NETMSG_SNAP || msg == NETMSG_SNAPSINGLE || msg == NETMSG_SNAPEMPTY)
@@ -1451,7 +1481,12 @@ int main(int argc, char **argv)
 	/* run the client*/
 	client_run();
 	
-	/* write down the config and quit */	
-	engine_writeconfig();
+	/* write down the config and quit */
+	if(engine_config_write_start() == 0)
+	{
+		config_save();
+		engine_config_write_stop();
+	}
+	
 	return 0;
 }