diff --git a/client.c b/client.c index 471fec5..932ff94 100644 --- a/client.c +++ b/client.c @@ -429,12 +429,26 @@ pMessage sendMessage(pMessage message,char* binary_name,void* binary,int count,c return result; } -char irc_server[256] = ""; -char irc_channel[256] = ""; #define HASE_MAX_IRC_PORT 8 int irc_port[HASE_MAX_IRC_PORT] = {6667,6667,6667,6667,6667,6667,6667,6667}; int irc_port_count = 1; +void update_irc_ports() +{ + char* content = gop_irc_ports(); + for (irc_port_count = 0; irc_port_count < HASE_MAX_IRC_PORT; irc_port_count++) + { + irc_port[irc_port_count] = strtol (content, &content, 10); + if (content[0] != ',') + { + irc_port_count++; + break; + } + else + content++; + } +} + int server_info() { pMessage result = sendMessage(NULL,NULL,NULL,0,"",gop_server()); @@ -446,28 +460,6 @@ int server_info() if (strcmp(mom->name,"gzip") == 0 && strcmp(mom->content,"yes") == 0) hase_gzip = 1; else - if (strcmp(mom->name,"irc_server") == 0) - sprintf(irc_server,"%s",mom->content); - else - if (strcmp(mom->name,"irc_channel") == 0) - sprintf(irc_channel,"%s",mom->content); - else - if (strcmp(mom->name,"irc_port") == 0) - { - char* content = mom->content; - for (irc_port_count = 0; irc_port_count < HASE_MAX_IRC_PORT; irc_port_count++) - { - irc_port[irc_port_count] = strtol (content, &content, 10); - if (content[0] != ',') - { - irc_port_count++; - break; - } - else - content++; - } - } - else if (strcmp(mom->name,"version") == 0) { int version = atoi(mom->content); @@ -1278,16 +1270,17 @@ void start_irc_client(char* name) else buffer[i] = name[i]; buffer[i] = 0; + update_irc_ports(); int port_try; for (port_try = 0; port_try < irc_port_count; port_try++) { - printf("%s %i %s\n",buffer,irc_port[port_try],irc_server); + printf("%s %i %s\n",buffer,irc_port[port_try],gop_irc_server()); char buffer2[128]; sprintf(buffer2,SP_DEVICE_STRING); for (i = 0; buffer2[i]; i++) if (buffer2[i] == ' ') buffer2[i] = '_'; - if (server = spNetIRCConnectServer(irc_server,irc_port[port_try],buffer,buffer2,name,"*")) + if (server = spNetIRCConnectServer(gop_irc_server(),irc_port[port_try],buffer,buffer2,name,"*")) break; else printf("Port %i failed, trying next if available\n",irc_port[port_try]); @@ -1300,7 +1293,7 @@ void try_to_join() { if (channel == NULL && server && spNetIRCServerReady(server)) { - channel = spNetIRCJoinChannel(server,irc_channel); + channel = spNetIRCJoinChannel(server,gop_irc_channel()); channel->show_users = 1; } if (server) diff --git a/hase.php b/hase.php index 12b04d4..88266de 100644 --- a/hase.php +++ b/hase.php @@ -1,25 +1,6 @@ value)); if (strcmp(entry->key,"update_server") == 0) sop_update_server(atoi(entry->value)); + if (strcmp(entry->key,"irc") == 0) + sop_irc_server(entry->value); + if (strcmp(entry->key,"channel") == 0) + sop_irc_channel(entry->value); + if (strcmp(entry->key,"ports") == 0) + sop_irc_ports(entry->value); entry = entry->next; } spNetC4AProfilePointer profile; @@ -322,6 +361,9 @@ void save_options() spConfigSetInt(conf,"first_game",op_first_game); spConfigSetInt(conf,"sprite",op_sprite); spConfigSetInt(conf,"update_server",op_update_server); + sprintf(spConfigGetString(conf,"irc",""),"%s",op_irc_server); + sprintf(spConfigGetString(conf,"channel",""),"%s",op_irc_channel); + sprintf(spConfigGetString(conf,"ports",""),"%s",op_irc_ports); spConfigWrite(conf); spConfigFree(conf); } diff --git a/options.h b/options.h index f9a47a5..89f39f1 100644 --- a/options.h +++ b/options.h @@ -20,6 +20,9 @@ int gop_global_chat(); int gop_first_game(); int gop_sprite(); int gop_update_server(); +char* gop_irc_server(); +char* gop_irc_channel(); +char* gop_irc_ports(); void sop_zoom(int v); void sop_circle(int v); @@ -36,6 +39,9 @@ void sop_global_chat(int v); void sop_first_game(int g); void sop_sprite(int v); void sop_update_server(int v); +void sop_irc_server(char* irc); +void sop_irc_channel(char* channel); +void sop_irc_ports(char* ports); Uint32* gop_game_options_ptr(); int* gop_game_hares_ptr();