Skip to content

Commit

Permalink
Add missing checks into duel.c
Browse files Browse the repository at this point in the history
  • Loading branch information
4144 committed Sep 15, 2015
1 parent 21442a8 commit 22d7f4f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/map/duel.c
Expand Up @@ -10,6 +10,7 @@
#include "map/clif.h"
#include "map/pc.h"
#include "common/cbasetypes.h"
#include "common/nullpo.h"

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -44,12 +45,15 @@ int duel_checktime(struct map_session_data* sd) {

return !(diff >= 0 && diff < battle_config.duel_time_interval);
}

static int duel_showinfo_sub(struct map_session_data* sd, va_list va)
{
struct map_session_data *ssd = va_arg(va, struct map_session_data*);
int *p = va_arg(va, int*);
char output[256];

nullpo_retr(1, sd);
nullpo_retr(1, ssd);
if (sd->duel_group != ssd->duel_group) return 0;

sprintf(output, " %d. %s", ++(*p), sd->status.name);
Expand Down Expand Up @@ -81,6 +85,8 @@ int duel_create(struct map_session_data* sd, const unsigned int maxpl) {
int i=1;
char output[256];

nullpo_ret(sd);

while(i < MAX_DUEL && duel->list[i].members_count > 0) i++;
if(i == MAX_DUEL) return 0;

Expand All @@ -101,6 +107,8 @@ int duel_create(struct map_session_data* sd, const unsigned int maxpl) {
void duel_invite(const unsigned int did, struct map_session_data* sd, struct map_session_data* target_sd) {
char output[256];

nullpo_retv(sd);
nullpo_retv(target_sd);
// " -- Player %s invites %s to duel --"
sprintf(output, msg_sd(sd,373), sd->status.name, target_sd->status.name);
clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
Expand All @@ -116,6 +124,7 @@ void duel_invite(const unsigned int did, struct map_session_data* sd, struct map
static int duel_leave_sub(struct map_session_data* sd, va_list va)
{
int did = va_arg(va, int);
nullpo_ret(sd);
if (sd->duel_invite == did)
sd->duel_invite = 0;
return 0;
Expand All @@ -124,6 +133,7 @@ static int duel_leave_sub(struct map_session_data* sd, va_list va)
void duel_leave(const unsigned int did, struct map_session_data* sd) {
char output[256];

nullpo_retv(sd);
// " <- Player %s has left duel --"
sprintf(output, msg_sd(sd,375), sd->status.name);
clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
Expand All @@ -144,6 +154,7 @@ void duel_leave(const unsigned int did, struct map_session_data* sd) {
void duel_accept(const unsigned int did, struct map_session_data* sd) {
char output[256];

nullpo_retv(sd);
duel->list[did].members_count++;
sd->duel_group = sd->duel_invite;
duel->list[did].invites_count--;
Expand All @@ -160,6 +171,7 @@ void duel_accept(const unsigned int did, struct map_session_data* sd) {
void duel_reject(const unsigned int did, struct map_session_data* sd) {
char output[256];

nullpo_retv(sd);
// " -- Player %s has rejected duel --"
sprintf(output, msg_sd(sd,377), sd->status.name);
clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
Expand Down

0 comments on commit 22d7f4f

Please sign in to comment.