[mw-devel] MW3 r1399 - in trunk/src: client server
arthur at sucs.org
arthur at sucs.org
Mon Oct 5 11:23:25 BST 2015
Author: arthur
Date: 2015-10-05 11:23:24 +0100 (Mon, 05 Oct 2015)
New Revision: 1399
Modified:
trunk/src/client/incoming.c
trunk/src/client/talker.c
trunk/src/server/actions.c
trunk/src/server/servsock.c
Log:
finish fixing mrod/zod, and honour onchat status
Modified: trunk/src/client/incoming.c
===================================================================
--- trunk/src/client/incoming.c 2015-10-02 16:32:22 UTC (rev 1398)
+++ trunk/src/client/incoming.c 2015-10-05 10:23:24 UTC (rev 1399)
@@ -650,9 +650,6 @@
asprintf(&excuse, "%s gives the reason \"%s\".", whom, reason);
}
force_text(msg, excuse, whom);
- } else {
- force_text(msg, "They didn't say why...\n", whom);
- printf("\n\nraw: %s\n\n", msg->body);
}
} else {
printf("Unknown message type %4.4s", (char *)&msg->head.type);
Modified: trunk/src/client/talker.c
===================================================================
--- trunk/src/client/talker.c 2015-10-02 16:32:22 UTC (rev 1398)
+++ trunk/src/client/talker.c 2015-10-05 10:23:24 UTC (rev 1399)
@@ -1147,24 +1147,16 @@
void t_zod(CommandList *cm, int argc, const char **argv, char *args)
{
- char buff[MAXTEXTLENGTH];
- snprintf(buff,MAXTEXTLENGTH-1,"z");
- if (args != NULL)
- {
- char *tmp, *qtmp;
- tmp = remove_first_word(args);
- if (tmp!=NULL && !allspace(tmp))
- {
- qtmp = quotetext(tmp);
- strncat(buff, "r", MAXTEXTLENGTH - 2);
- strncat(buff, qtmp, MAXTEXTLENGTH - strlen(buff) - 1);
- free(qtmp);
- }
- else strncat(buff, "-", MAXTEXTLENGTH - 2);
- SAFE_FREE(tmp);
- }
- else strncat(buff, "-", MAXTEXTLENGTH - 2);
- ipc_send_to_username(argv[1], IPC_KICK, buff);
+ AUTOFREE_BUFFER excuse = remove_first_word(args);
+ ipc_message_t * msg = ipcmsg_create(IPC_ACTION, userposn);
+ json_t * j = json_init(NULL);
+ json_addstring(j, "target", argv[1]);
+ json_addstring(j, "type", "zod");
+ if (excuse!=NULL && !allspace(excuse))
+ json_addstring(j, "reason", excuse);
+ ipcmsg_json_encode(msg, j);
+ json_decref(j);
+ ipcmsg_transmit(msg);
}
void t_mrod(CommandList *cm, int argc, const char **argv, char *args)
@@ -1183,46 +1175,32 @@
void t_kick(CommandList *cm, int argc, const char **argv, char *args)
{
- char buff[MAXTEXTLENGTH];
- snprintf(buff,MAXTEXTLENGTH-1,"k");
- if (args != NULL)
- {
- char *tmp, *qtmp;
- tmp = remove_first_word(args);
- if (tmp!=NULL && !allspace(tmp))
- {
- qtmp = quotetext(tmp);
- strncat(buff, "r", MAXTEXTLENGTH - 2);
- strncat(buff, qtmp, MAXTEXTLENGTH - strlen(buff) - 1);
- free(qtmp);
- }
- else strncat(buff, "-", MAXTEXTLENGTH - 2);
- SAFE_FREE(tmp);
- }
- else strncat(buff, "-", MAXTEXTLENGTH - 2);
- ipc_send_to_username(argv[1], IPC_KICK, buff);
+ AUTOFREE_BUFFER excuse = remove_first_word(args);
+ ipc_message_t * msg = ipcmsg_create(IPC_ACTION, userposn);
+ json_t * j = json_init(NULL);
+ json_addstring(j, "target", argv[1]);
+ json_addstring(j, "type", "zod");
+ json_addstring(j, "admin", "yes");
+ if (excuse!=NULL && !allspace(excuse))
+ json_addstring(j, "reason", excuse);
+ ipcmsg_json_encode(msg, j);
+ json_decref(j);
+ ipcmsg_transmit(msg);
}
void t_remove(CommandList *cm, int argc, const char **argv, char *args)
{
- char buff[MAXTEXTLENGTH];
- snprintf(buff,MAXTEXTLENGTH-1,"r");
- if (args != NULL)
- {
- char *tmp, *qtmp;
- tmp = remove_first_word(args);
- if (tmp!=NULL && !allspace(tmp))
- {
- qtmp = quotetext(tmp);
- strncat(buff, "r", MAXTEXTLENGTH - 2);
- strncat(buff, qtmp, MAXTEXTLENGTH - strlen(buff) - 1);
- free(qtmp);
- }
- else strncat(buff, "-", MAXTEXTLENGTH - 2);
- SAFE_FREE(tmp);
- }
- else strncat(buff, "-", MAXTEXTLENGTH - 2);
- ipc_send_to_username(argv[1], IPC_KICK, buff);
+ AUTOFREE_BUFFER excuse = remove_first_word(args);
+ ipc_message_t * msg = ipcmsg_create(IPC_ACTION, userposn);
+ json_t * j = json_init(NULL);
+ json_addstring(j, "target", argv[1]);
+ json_addstring(j, "type", "mrodod");
+ json_addstring(j, "admin", "yes");
+ if (excuse!=NULL && !allspace(excuse))
+ json_addstring(j, "reason", excuse);
+ ipcmsg_json_encode(msg, j);
+ json_decref(j);
+ ipcmsg_transmit(msg);
}
void t_raw(CommandList *cm, int argc, const char **argv, char *args)
Modified: trunk/src/server/actions.c
===================================================================
--- trunk/src/server/actions.c 2015-10-02 16:32:22 UTC (rev 1398)
+++ trunk/src/server/actions.c 2015-10-05 10:23:24 UTC (rev 1399)
@@ -21,6 +21,7 @@
#include <rooms.h>
#include <talker_privs.h>
#include <ipc.h>
+#include <perms.h>
#include "servsock.h"
#include "replay.h"
@@ -39,6 +40,7 @@
const char *command = json_getstring(j, "type");
const char *victim_username = json_getstring(j, "target");
const char *reason = json_getstring(j, "reason");
+ const char *admin = json_getstring(j, "admin");
if (command == NULL || victim_username == NULL) {
send_error(conn, msg, "Invalid server command syntax");
@@ -70,6 +72,11 @@
/* attacker was stronger, success */
if (prot_at >= prot_vi) success = 1;
+ /* an admin can ask to ignore protection modes */
+ if (admin!=NULL && strcasecmp(admin, "yes")==0 && u_god(attacker.status)) {
+ success = 1;
+ }
+
if (strcasecmp(command, "mrod")==0) {
// tell the world
ipc_message_t * event = ipcmsg_create(IPC_EVENT, msg->head.src);
@@ -88,10 +95,8 @@
if (reason != NULL) {
asprintf(&buff,"mr%s", reason);
json_addstring(ej, "reason", reason);
- printf("MROD set reason '%s'\n", reason);
} else {
asprintf(&buff,"m-");
- printf("MROD with no reason\n");
}
ipc_message_t *update = ipcmsg_create(IPC_KICK, msg->head.src);
ipcmsg_destination(update, toid);
Modified: trunk/src/server/servsock.c
===================================================================
--- trunk/src/server/servsock.c 2015-10-02 16:32:22 UTC (rev 1398)
+++ trunk/src/server/servsock.c 2015-10-05 10:23:24 UTC (rev 1399)
@@ -431,6 +431,9 @@
/* have we been told to exclude someone in this room */
if (exclude!=NULL && strcasecmp(exclude, user.name)==0) continue;
+ /* person not on talker, just skip them */
+ if (!cm_flags(user.chatmode, CM_ONCHAT, CM_MODE_ALL)) continue;
+
/* room matches, send them a copy */
if (user.room == msg->head.dst) {
msg_attach_to_pid(msg, who.pid);
@@ -487,6 +490,9 @@
lseek(users_fd, who.posn, SEEK_SET);
if (read(users_fd, &user, sizeof(user)) <= 0) continue;
+ /* person not on talker, just skip them */
+ if (!cm_flags(user.chatmode, CM_ONCHAT, CM_MODE_ALL)) continue;
+
msg_attach_to_pid(msg, who.pid);
printf("Broadcast to %s in %d\n", user.name, user.room);
}
@@ -561,7 +567,7 @@
**/
void msg_apply_gag(struct person * from, ipc_message_t * msg, const char * field)
{
- char * newtext = NULL;
+ AUTOFREE_BUFFER newtext = NULL;
json_t * j = json_init(msg);
const char * text = json_getstring(j, field);
More information about the mw-devel
mailing list