[mw-devel] MW3 r1355 - in trunk/src: . client server

welshbyte at sucs.org welshbyte at sucs.org
Sat Nov 2 01:10:49 GMT 2013


Author: welshbyte
Date: 2013-11-02 01:10:49 +0000 (Sat, 02 Nov 2013)
New Revision: 1355

Modified:
   trunk/src/client/talker.c
   trunk/src/ipc.c
   trunk/src/ipc.h
   trunk/src/server/servsock.c
Log:
Use the IPC_ enums instead of FOURCC() - seems a waste not to.


Modified: trunk/src/client/talker.c
===================================================================
--- trunk/src/client/talker.c	2013-11-01 23:32:07 UTC (rev 1354)
+++ trunk/src/client/talker.c	2013-11-02 01:10:49 UTC (rev 1355)
@@ -253,7 +253,7 @@
 
 void t_uptime(CommandList *cm, int argc, const const char **argv, char *args)
 {
-	ipc_message_t * msg = ipcmsg_create(FOURCC("UPTM"), getpid());
+	ipc_message_t * msg = ipcmsg_create(IPC_UPTIME, getpid());
 	ipcmsg_transmit(msg);
 }
 

Modified: trunk/src/ipc.c
===================================================================
--- trunk/src/ipc.c	2013-11-01 23:32:07 UTC (rev 1354)
+++ trunk/src/ipc.c	2013-11-02 01:10:49 UTC (rev 1355)
@@ -63,7 +63,7 @@
 	ipcsock->state = IPCSTATE_CONNECTED;
 
 	pid_t mypid = getpid();
-	ipc_message_t * msg = ipcmsg_create(FOURCC("HELO"), mypid);
+	ipc_message_t * msg = ipcmsg_create(IPC_HELLO, mypid);
 	ipcmsg_append(msg, &userposn, sizeof(userposn));
 	const char *nonce = get_nonce();
 	ipcmsg_append(msg, nonce, strlen(nonce));

Modified: trunk/src/ipc.h
===================================================================
--- trunk/src/ipc.h	2013-11-01 23:32:07 UTC (rev 1354)
+++ trunk/src/ipc.h	2013-11-02 01:10:49 UTC (rev 1355)
@@ -6,7 +6,6 @@
 #include "user.h"
 #include "socket.h"
 
-#define FOURCC(a) *(uint32_t *)&a
 #define FCC(ch4) ((((uint32_t)(ch4) & 0xFF) << 24) |     \
 		  (((uint32_t)(ch4) & 0xFF00) << 8) |    \
 		  (((uint32_t)(ch4) & 0xFF0000) >> 8) |  \
@@ -44,6 +43,7 @@
 	IPC_PROTLEVEL	= 24,
 	IPC_PROTPOWER	= 25,
 	IPC_DOING	= 26,
+	IPC_HELLO	= FCC('HELO'),
 	IPC_UPTIME	= FCC('UPTM'),
 	IPC_SAYTOROOM	= FCC('SAYR'),
 	IPC_SAYTOUSER	= FCC('SAYU'),

Modified: trunk/src/server/servsock.c
===================================================================
--- trunk/src/server/servsock.c	2013-11-01 23:32:07 UTC (rev 1354)
+++ trunk/src/server/servsock.c	2013-11-02 01:10:49 UTC (rev 1355)
@@ -239,7 +239,7 @@
 	vasprintf(&text, format, va);
 	va_end(va);
 
-	ipc_message_t * msg = ipcmsg_create(FOURCC("TERR"), 0);
+	ipc_message_t * msg = ipcmsg_create(IPC_TALKERROR, 0);
 	ipcmsg_destination(msg, conn->addr);
 
 	char type[5];
@@ -259,7 +259,7 @@
 	ipcmsg_summary("PROCESS", msg);
 
 	/* client just told us who they are */
-	if (msg->head.type == FOURCC("HELO")) {
+	if (msg->head.type == IPC_HELLO) {
 		int wfd;
 		memcpy(&conn->addr, &msg->head.src, sizeof(conn->addr));
 		if (msg->bodylen < 4) {
@@ -288,12 +288,12 @@
 	if (conn->state != IPCSTATE_VALID) return;
 
 	/* ask the server how long it has been up */
-	if (msg->head.type == FOURCC("UPTM")) {
+	if (msg->head.type == IPC_UPTIME) {
 		time_t now = time(0);
 
 		ipcmsg_destroy(msg);
 
-		msg = ipcmsg_create(FOURCC("UPTM"), 0);
+		msg = ipcmsg_create(IPC_UPTIME, 0);
 		ipcmsg_destination(msg, conn->addr);
 
 		json_t * j = json_init(NULL);
@@ -309,7 +309,7 @@
 	}
 
 	/* send message to everyone in the room */
-	if (msg->head.type == FOURCC("SAYR")) {
+	if (msg->head.type == IPC_SAYTOROOM) {
 		/* eventually this should be a server maintained list */
 		int who_fd = who_open(O_RDONLY);
 		int users_fd = userdb_open(O_RDONLY);
@@ -351,7 +351,7 @@
 	}
 
 	/* message is for a specific username */
-	if (msg->head.type == FOURCC("SAYU")) {
+	if (msg->head.type == IPC_SAYTOUSER) {
 		/* eventually this should be a server maintained list */
 		int who_fd = who_open(O_RDONLY);
 		int users_fd = userdb_open(O_RDONLY);
@@ -387,7 +387,7 @@
 	}
 
 	/* send message to everyone (unless this room is soundproof) */
-	if (msg->head.type == FOURCC("WALL")) {
+	if (msg->head.type == IPC_SAYTOALL) {
 		/* eventually this should be a server maintained list */
 		int who_fd = who_open(O_RDONLY);
 		int users_fd = userdb_open(O_RDONLY);




More information about the mw-devel mailing list