remove pointless int to string to int conversion sequences
This commit is contained in:
parent
3bffc33674
commit
0933499e42
3 changed files with 13 additions and 17 deletions
4
events.c
4
events.c
|
@ -146,11 +146,11 @@ int PlayCardsWarGame (const CmdParams *cmdparams)
|
|||
if (!ircstrcasecmp (cmdparams->source->name,wplayernick[currentplayer]) && currentwargamestatus == WS_GAME_PLAYING) {
|
||||
if (warinprogress == 1) {
|
||||
if (cmdparams->ac == 3) {
|
||||
playwarcards(cmdparams->av[0], cmdparams->av[1], cmdparams->av[2]);
|
||||
playwarcards(atoi(cmdparams->av[0]), atoi(cmdparams->av[1]), atoi(cmdparams->av[2]));
|
||||
}
|
||||
} else {
|
||||
if (cmdparams->ac == 1) {
|
||||
playcard(cmdparams->av[0]);
|
||||
playcard(atoi(cmdparams->av[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
22
play.c
22
play.c
|
@ -269,7 +269,6 @@ static void askplaycard(void)
|
|||
{
|
||||
int trn;
|
||||
int wspa[5];
|
||||
char wspas[5][3];
|
||||
int nwp = (currentwarplayercount + 1);
|
||||
if (wplayercardstotal[currentplayer] == 0) {
|
||||
removewar(wplayernick[currentplayer]);
|
||||
|
@ -310,17 +309,14 @@ static void askplaycard(void)
|
|||
if ((wspa[4] == wspa[2]) || (wspa[4] == wspa[3])) {
|
||||
wspa[4]++;
|
||||
}
|
||||
for (wpln = 2; wpln < 5; wpln++) {
|
||||
ircsnprintf(wspas[wpln], 3, "%d", wspa[wpln]); }
|
||||
playwarcards(wspas[2], wspas[3], wspas[4]);
|
||||
playwarcards(wspa[2], wspa[3], wspa[4]);
|
||||
} else {
|
||||
irc_chanprivmsg (ws_bot, warroom, "\0037%s\0039 you hold\00311 %d\0039 cards, and are currently at \0034WAR\0039 which three would you like to play ?", wplayernick[currentplayer], wplayercardstotal[currentplayer]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!ircstrcasecmp (wplayernick[currentplayer], ws_bot->name)) {
|
||||
ircsnprintf(wspas[0], 3, "%d", ((rand() % wplayercardstotal[currentplayer]) + 1));
|
||||
playcard(wspas[0]);
|
||||
playcard(((rand() % wplayercardstotal[currentplayer]) + 1));
|
||||
} else {
|
||||
irc_chanprivmsg (ws_bot, warroom, "\0037%s\0039 you currently hold\00311 %d\0039 cards, which would you like to play ?", wplayernick[currentplayer], wplayercardstotal[currentplayer]);
|
||||
}
|
||||
|
@ -330,11 +326,12 @@ static void askplaycard(void)
|
|||
/*
|
||||
* Player War Play Card
|
||||
*/
|
||||
void playwarcards(const char *cnps1, const char *cnps2, const char *cnps3) {
|
||||
void playwarcards(int cnp1, int cnp2, int cnp3)
|
||||
{
|
||||
int cnp[3];
|
||||
cnp[0] = atoi(cnps1);
|
||||
cnp[1] = atoi(cnps2);
|
||||
cnp[2] = atoi(cnps3);
|
||||
cnp[0] = cnp1;
|
||||
cnp[1] = cnp2;
|
||||
cnp[2] = cnp3;
|
||||
for (wpln = 0; wpln < 3; wpln++) {
|
||||
if ((cnp[wpln] < 1) || (cnp[wpln] > wplayercardstotal[currentplayer])) {
|
||||
return;
|
||||
|
@ -401,9 +398,8 @@ void playwarcards(const char *cnps1, const char *cnps2, const char *cnps3) {
|
|||
/*
|
||||
* Player Plays Card
|
||||
*/
|
||||
void playcard(const char *cnps) {
|
||||
int cnp;
|
||||
cnp = atoi(cnps);
|
||||
void playcard(int cnp)
|
||||
{
|
||||
if ((cnp > 0) && (cnp < (wplayercardstotal[currentplayer] + 1))){
|
||||
if (wplayercardsinhand[currentplayer][(cnp - 1)] < 13) {
|
||||
strlcpy (csuitcolour, "\0034", 10);
|
||||
|
|
|
@ -69,5 +69,5 @@ void stopwar(void);
|
|||
void startcountdowntimer(char *nic);
|
||||
void joinwar(char *nic);
|
||||
void removewar(char *nic);
|
||||
void playwarcards(const char *cnps1, const char *cnps2, const char *cnps3);
|
||||
void playcard(const char *cnps);
|
||||
void playwarcards(int cnp1, int cnp2, int cnp3);
|
||||
void playcard(int cnp);
|
||||
|
|
Reference in a new issue