using std::endl;
char *PACKAGE = "GameServ";
-char *VERSION = "1.1.9";
+char *VERSION = "1.2.0 +devel";
int sock;
int day;
-List<aClient> clients;
+List<aClient> clients[U_TABLE_SIZE];
void save_day();
void load_day();
if ((tempPtr = find((source + 1))))
{
char *nick;
+ unsigned long oldhv, newhv;
nick = strtok(NULL, " ");
+ oldhv = HASH((unsigned char *) tempPtr->getNick(),
+ U_TABLE_SIZE);
+ newhv = HASH((unsigned char *) nick, U_TABLE_SIZE);
tempPtr->setNick(nick);
+ clients[oldhv].remove(tempPtr);
+ clients[newhv].insertAtBack(tempPtr);
}
}
else
#else
notice(s_GameServ, nick, welcomemsg, nick);
#endif
-
- clients.insertAtBack(newuser);
+ unsigned long hv = HASH((unsigned char *) nick, U_TABLE_SIZE);
+ clients[hv].insertAtBack(newuser);
delete newuser;
}
#if defined(P10)
if (z == ':')
source++;
+ unsigned long hv = HASH((unsigned char *) source, U_TABLE_SIZE);
if ((quitter = find(source)))
- clients.remove(quitter);
+ clients[hv].remove(quitter);
if ((quitter = findIRCplayer(source)))
{
+ if (player_fight(quitter))
+ {
+ // Stop the fight on the other client
+ aClient *otherplayer = quitter->stats->battle;
+ otherplayer->stats->battle = NULL;
+ notice(s_GameServ, otherplayer->getNick(), "%s "\
+ "has quit IRC. The fight stops here.",
+ quitter->stats->name);
+ }
+ quitter->stats->battle = NULL;
+ quitter->stats->fight = NULL;
+ quitter->stats->master = NULL;
+
quitter->setNick("!NULL!");
+ #ifdef P10
+ quitter->setRealNick("!NULL!");
+ #endif
quitter->stats->user = NULL; // Unidentify them
}
else if (stricmp(dest, c_Forest) == 0)
forest(source, rest);
#endif
+ #if defined(P10)
+ } else if (stricmp(cmd, "J") == 0) {
+ #else
} else if (stricmp(cmd, "JOIN") == 0) {
+ #endif
char *channel;
+ aClient *joiner;
channel = strtok(NULL, " ");
- if (stricmp(channel, c_Forest) == 0 && is_playing(source + 1))
- raw(":%S MODE %s +v %s", c_Forest, (source + 1));
+
+ char z = source[0];
+
+ if (z == ':')
+ source++;
+
+ joiner = find(source);
+
+ if (stricmp(channel, c_Forest) == 0 && is_playing(joiner))
+ {
+ #ifdef DEBUGMODE
+ log("Player %s (IRC: %s) joined %s",
+ joiner->stats->name,
+ #ifdef P10
+ joiner->getRealNick(),
+ #else
+ joiner->getNick(),
+ #endif
+ c_Forest);
+ #endif
+ raw(":%S MODE %s +v %s", c_Forest, (source));
+ }
+
+ if (z == ':')
+ source--;
#if defined(BAHAMUT)
} else if (stricmp(cmd, "SJOIN") == 0) {
aClient *findbyrealnick(char *realnick)
{
ListNode <aClient> *newPtr;
- newPtr = clients.First();
+ unsigned long hv = HASH((unsigned char *) realnick, U_TABLE_SIZE);
+ newPtr = clients[hv].First();
aClient *client = NULL;
aClient *findbynick(char *nick)
{
ListNode <aClient> *newPtr;
- newPtr = clients.First();
+ unsigned long hv = HASH((unsigned char *) nick, U_TABLE_SIZE);
+ newPtr = clients[hv].First();
aClient *client = NULL;
ListNode <aClient> *newPtr;
aClient *p = NULL;
- for (newPtr = players.First(); newPtr; newPtr = newPtr->Next())
+ unsigned long hv = HASH((unsigned char *) nick, U_TABLE_SIZE);
+ for (newPtr = players[hv].First(); newPtr; newPtr = newPtr->Next())
{
p = newPtr->getData();
#ifdef P10
{
ListNode <aClient> *newPtr;
Player *p = NULL;
-
- for (newPtr = players.First(); newPtr; newPtr = newPtr->Next())
+ unsigned long hv = HASH((unsigned char *) name, U_TABLE_SIZE);
+ for (newPtr = players[hv].First(); newPtr; newPtr = newPtr->Next())
{
p = newPtr->getData()->stats;
if (stricmp(p->name, name) == 0)
aClient *findbynick(const char *nick)
{
ListNode <aClient> *newPtr;
- newPtr = clients.First();
+ unsigned long hv = HASH((unsigned char *) nick, U_TABLE_SIZE);
+ newPtr = clients[hv].First();
aClient *client = NULL;