Exemple #1
0
bool remove_member(long id, char *name)
{
	CHAR_DATA *ch = 0;
	KINGDOM_DATA *kingdom;
	char buf[MAX_STRING_LENGTH];
	char *str;

	if(!name || name[0] == '\0' || (kingdom = get_kingdom(id)) == &kingdom_default)
		return FALSE;

	if((ch = get_char_world(char_list, name)) != 0 && !IS_NPC(ch))
	{
		ch->pcdata->kingdom_invite = 0;
		ch->pcdata->kingdom = 0;
		sprintf(buf, "You have left the %s Kingdom.", kingdom->name);
		send_to_char(buf, ch);

		free_string(ch->pcdata->krank);
		ch->pcdata->krank = str_dup("");
	}

	if((str = str_sep(kingdom->members, name)) == 0)
		return FALSE;

	free_string(kingdom->members);
	kingdom->members = str;

	kingdom_message(0, "%s has left the %s Kingdom.", name, kingdom->name);
	write_kingdoms();
	return TRUE;
}
Exemple #2
0
bool remove_trustee(long id, char *name)
{
	KINGDOM_DATA *kingdom;
	char *str;

	if(!name || name[0] == '\0' || (kingdom = get_kingdom(id)) == &kingdom_default)
		return FALSE;

	if((str = str_sep(kingdom->trustees, name)) == 0)
		return FALSE;

	free_string(kingdom->trustees);
	kingdom->trustees = str;

	kingdom_message(0, "%s is no longer a trusted member of the %s Kingdom.", name, kingdom->name);
	write_kingdoms();
	return TRUE;
}
Exemple #3
0
int
set_values(void)
{
 int fd = -1, n = 0, val = -1, f_c = 0;
 char buf[MAX_VALUES_LEN], *bp = NULL, *fp = NULL, *vp = NULL;

 if ( NULL == field ) {
     return (0);
 } else {
     if ( NULL == values ) {
         if ( NULL == value_path ) {
             return (0);
         } else {
             if ( (fd = open(value_path, O_RDONLY)) < 0 ) {
                 ERR("Open initial values file FAIL"); return (-1);
             } else {
                 memset(buf, 0, MAX_VALUES_LEN);
                 if ( (n = read(fd, buf, MAX_VALUES_LEN-1)) < 0 ) {
                     ERR("Read initial values file FAIL."); return (-1);
                 } else if ( 0 <= n ) {
                     buf[n] = '\0'; values = buf;
                 }
                 (void)close(fd);
             }
         }
     }
     bp = &(values[0]);
     while ( NULL != (fp = str_sep(&bp, &field_separator)) ) {
         if ( ++f_c > field_count ) {
             ERR("field_count=%d exceeded by f_c=%d", field_count, f_c);
             return (-1);
         } else if ( assign_value(field[f_c-1], fp) < 0 ) {
             return (-1);
         }
     }
 }
 return (0);
}