Example #1
0
const char *icec_command(const char *from, const char *arg) {
    char cmd[IMC_NAME_LENGTH];
    char chan[IMC_NAME_LENGTH];
    char data[IMC_DATA_LENGTH];
    const char *p;
    imc_packet out;
    ice_channel *c;
    p = imc_getarg(arg, cmd, IMC_NAME_LENGTH);
    p = imc_getarg(p, chan, IMC_NAME_LENGTH);
    strcpy(data, p);
    if(!cmd[0] || !chan[0]) {
        return "Syntax: icommand <command> <node:channel> [<data..>]";
    }
    p = strchr(chan, ':');
    if(!p) {
        c = icec_findlchannel(chan);
        if(c) {
            strcpy(chan, c->name);
        }
    }
    sprintf(out.to, "ICE@%s", ice_mudof(chan));
    strcpy(out.type, "ice-cmd");
    strcpy(out.from, from);
    imc_initdata(&out.data);
    imc_addkey(&out.data, "channel", chan);
    imc_addkey(&out.data, "command", cmd);
    imc_addkey(&out.data, "data", data);
    imc_send(&out);
    imc_freedata(&out.data);
    return "Command sent.";
}
Example #2
0
/* check for icec channels, return TRUE to stop command processing, FALSE otherwise */
bool icec_command_hook(CHAR_DATA *ch, const char *command, const char *argument)
{
  ice_channel *c;
  char arg[MAX_STRING_LENGTH];
  const char *word2;
  int emote=0;
  
  if (IS_NPC(ch))
    return FALSE;
  
#ifdef CIRCLE
  skip_spaces(&argument);
#endif
  
  c=icec_findlchannel(command);
  if (!c || !c->local)
    return FALSE;

  if (c->local->level > get_trust(ch))
    return FALSE;

  if (!imc_hasname(ch->pcdata->ice_listen, c->local->name))
    return FALSE;
  
  if (!ice_audible(c, imc_makename(ch->name, imc_name)))
  {
    send_to_char("You cannot use that channel.\n\r", ch);
    return TRUE;
  }

  word2=imc_getarg(argument, arg, MAX_STRING_LENGTH);

  if (!arg[0])
  {
    send_to_char("Use ichan to toggle the channel - or provide some text.\n\r", ch);
    return TRUE;
  }

  if (!str_cmp(arg, ",") ||
      !str_cmp(arg, "emote"))
  {
    emote=1;
    argument=word2;
  }
  
  icec_sendmessage(c, ch->name, color_mtoi(argument), emote);
  return TRUE;
}
Example #3
0
void icec_save_channels(void)
{
  ice_channel *c;
  FILE *fp;
  char name[MAX_STRING_LENGTH];

  strcpy(name, imc_prefix);
  strcat(name, "icec");

  fp=fopen(name, "w");
  if (!fp)
  {
    imc_logerror("Can't write to %s", name);
    return;
  }
  
  for (c=saved_channel_list; c; c=c->next)
  {
    /* update */
    ice_channel *current=icec_findlchannel(c->local->name);
    if (current)
    {
      imc_strfree(c->name);
      imc_strfree(c->local->format1);
      imc_strfree(c->local->format2);

      c->name=imc_strdup(current->name);
      c->local->format1=imc_strdup(current->local->format1);
      c->local->format2=imc_strdup(current->local->format2);
      c->local->level=current->local->level;
    }

    /* save */
    fprintf(fp,
	    "%s %s %d\n"
	    "%s\n"
	    "%s\n",
	    c->name, c->local->name, c->local->level,
	    c->local->format1,
	    c->local->format2);
  }

  fclose(fp);
}