]>
jfr.im git - irc/gameservirc.git/blob - gameserv/boolean.cpp
7 #if defined(HAVE_CRYPT_H)
11 #elif defined(HAVE_UNISTD_H)
18 bool is_playing(char *u
); // True if the given nickname in the clients list is playing.
19 bool is_playing(aClient
*user
);
21 bool is_fighting(char *u
); // True if the given nick in the clients list is fighting anything.
22 bool is_fighting(aClient
*user
);
24 bool player_fight(char *u
); // True if the player is fighting another player.
25 bool player_fight(aClient
*user
);
27 bool master_fight(char *u
); // True if the player is fighting their master.
28 bool master_fight(aClient
*user
);
30 bool dragon_fight(char *u
); // True if the player is fighting the dragon.
31 bool dragon_fight(aClient
*user
);
33 bool alphaNumeric(const char *str
); // Returns true if all of the characters in str are alphanumeric non-special chars
34 /********** GameServ Booleans **********/
37 bool is_playing(char *u
)
40 if (!(user
= find(u
)))
43 return is_playing(user
);
46 bool is_playing(aClient
*user
)
52 else if (!user
->stats
)
56 else if (!FL_is_playing(user
))
60 else if (user
->stats
->getClient() != user
)
68 bool is_fighting(char *u
)
72 if (!(user
= find(u
)))
75 return is_fighting(user
);
78 bool is_fighting(aClient
*user
)
80 if (!is_playing(user
))
83 return player_fight(user
) || master_fight(user
) ||
84 user
->stats
->getMonster() != NULL
;
87 bool player_fight(char *u
)
91 if (!(user
= find(u
)))
94 return player_fight(user
);
97 bool player_fight(aClient
*user
)
99 if (!is_playing(user
))
101 else if (is_playing(user
->stats
->getBattle()))
109 bool master_fight(char *u
)
113 if (!(user
= find(u
)))
116 return master_fight(user
);
119 bool master_fight(aClient
*user
)
121 if (!is_playing(user
))
124 return user
->stats
->getMaster() != NULL
;
127 bool dragon_fight(char *u
)
130 if (!(user
= find(u
)))
133 return dragon_fight(user
);
136 bool dragon_fight(aClient
*user
)
138 if (!is_playing(user
))
141 return (isDragonFight(user
->stats
));
144 bool alphaNumeric(const char *str
)
146 int len
= strlen(str
);
147 for (int x
= 0; x
< len
; x
++)
149 if (!((int(str
[x
]) >= 65 && int(str
[x
]) <= 90) || (int(str
[x
]) >= 97 && int(str
[x
]) <= 122) || (int(str
[x
]) >= 48 && int(str
[x
]) <= 57) || int(str
[x
]) == 95))
155 bool passcmp(const char *encrypted
, char *plaintext
)
158 char *plaintext2
, *plainToencrypt
;
161 plaintext2
= new char[strlen(encrypted
) + strlen(plaintext
)]; // Extra
162 strcpy(plaintext2
, plaintext
);
164 salt
[0] = encrypted
[0];
165 salt
[1] = encrypted
[1];
168 plainToencrypt
= crypt(plaintext2
, salt
);
170 same
= (strcmp((const char *)encrypted
, plainToencrypt
) == 0 ? true : false);
177 bool check_password(char *name
, char *plaintext
)
181 if (!(p
= findplayer(name
)))
185 return passcmp(p
->getPassword().c_str(), plaintext
);
189 bool timedOut(Player
*p
)
193 else if (p
->lastcommand
== 0)
197 if ((time(NULL
) - p
->lastcommand
) >= maxidletime
)