コード例 #1
0
int hash_map(int actor_node, char *text) {

    /** public function - see header */

    int socket=clients.client[actor_node].socket;
    char map_name[80]="";
    int map_id;

    if(sscanf(text, "%*s *s")==-1){

        //if no tail specified in command, default to current map
        map_id=clients.client[actor_node].map_id;
    }
    else if(sscanf(text, "%*s %[^\n]", map_name)==1){

        map_id=get_map_id(map_name);

        if(map_id==-1){

            send_text(socket, CHAT_SERVER, "%cMap does not exist", c_red3+127);
            return 0;
        }
    }
    else {

        send_text(socket, CHAT_SERVER, "%cyou need to use the format #MAP [map_name] or #MAP", c_red3+127);
        return 0;
    }

    get_map_details(actor_node, map_id);
    get_map_developer_details(actor_node, map_id);

    return 0;
}
コード例 #2
0
ファイル: lockmap.c プロジェクト: AlfredArouna/illumos-gate
int
hash(char *s)
{
	unsigned int n = 0;
	int i;
	char *map_name = s;

	for (i = 1; *s; i += 10, s++) {
		n += i * (*s);
	}
	n %= MAXHASH;

	if (yptol_mode & yptol_newlock) {
		return (get_map_id(map_name, n));
	} else {
		return (n);
	}
}