Changed from using old C style numeric limits to the new C++ style ones.
Removed old min/max macros and use the std:: <algorithm> template functions.
This commit is contained in:
parent
aa4d3d0d10
commit
f8d1bc4536
6 changed files with 12 additions and 18 deletions
pvpgn/src
|
@ -55,7 +55,7 @@ typedef struct
|
|||
#define D2LADDER_STD_OVERALL 0x09
|
||||
#define D2LADDER_EXP_HC_OVERALL 0x13
|
||||
#define D2LADDER_EXP_STD_OVERALL 0x1B
|
||||
#define D2CHAR_CLASS_MAX 0x04
|
||||
#define D2CHAR_EXP_CLASS_MAX 0x06
|
||||
const unsigned D2CHAR_CLASS_MAX = 0x04;
|
||||
const unsigned D2CHAR_EXP_CLASS_MAX = 0x06;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <climits>
|
||||
#include <ctime>
|
||||
#include <cassert>
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "setup.h"
|
||||
#include "d2charfile.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <cstdio>
|
||||
|
@ -766,7 +767,7 @@ extern int file_read(char const * filename, void * data, unsigned int * size)
|
|||
|
||||
std::fseek(fp,0,SEEK_END); /* FIXME: check return value */
|
||||
n=std::ftell(fp);
|
||||
n=min(*size,n);
|
||||
n=std::min(*size,n);
|
||||
std::rewind(fp); /* FIXME: check return value */
|
||||
|
||||
if (std::fread(data,1,n,fp)!=n) {
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
#include "setup.h"
|
||||
#include "d2gs.h"
|
||||
|
||||
#include <limits>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <climits>
|
||||
#include <cstring>
|
||||
|
||||
#include "compat/psock.h"
|
||||
|
@ -364,14 +364,14 @@ extern unsigned int d2gs_calc_checksum(t_connection * c)
|
|||
len=std::strlen(realmname);
|
||||
for (i=0; i<len ; i++) {
|
||||
ch = (unsigned int)(unsigned char) realmname[i];
|
||||
checksum ^= ROTL(sessionnum,i, sizeof(unsigned int) * CHAR_BIT);
|
||||
checksum ^= ROTL(port , ch, sizeof(unsigned int) * CHAR_BIT);
|
||||
checksum ^= ROTL(sessionnum,i, (std::numeric_limits<unsigned int>::digits));
|
||||
checksum ^= ROTL(port , ch, (std::numeric_limits<unsigned int>::digits));
|
||||
}
|
||||
len=std::strlen(password);
|
||||
for (i=0; i<len ; i++) {
|
||||
ch = (unsigned int)(unsigned char) password[i];
|
||||
checksum ^= ROTL(sessionnum,i, sizeof(unsigned int) * CHAR_BIT);
|
||||
checksum ^= ROTL(port , ch, sizeof(unsigned int) * CHAR_BIT);
|
||||
checksum ^= ROTL(sessionnum,i, (std::numeric_limits<unsigned int>::digits));
|
||||
checksum ^= ROTL(port , ch, (std::numeric_limits<unsigned int>::digits));
|
||||
}
|
||||
checksum ^= addr;
|
||||
return checksum;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "setup.h"
|
||||
#include "d2ladder.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cerrno>
|
||||
|
@ -180,9 +181,9 @@ static int d2ladder_append_ladder(unsigned int type, t_d2ladderfile_ladderinfo *
|
|||
}
|
||||
if (charstatus_get_expansion(status)) {
|
||||
ladderstatus |= LADDERSTATUS_FLAG_EXPANSION;
|
||||
ladderstatus |= min(chclass,D2CHAR_EXP_CLASS_MAX);
|
||||
ladderstatus |= std::min<unsigned>(chclass,D2CHAR_EXP_CLASS_MAX);
|
||||
} else {
|
||||
ladderstatus |= min(chclass,D2CHAR_CLASS_MAX);
|
||||
ladderstatus |= std::min<unsigned>(chclass,D2CHAR_CLASS_MAX);
|
||||
}
|
||||
ladderinfo=ladder_data[type].info+ladder_data[type].curr_len;
|
||||
bn_int_set(&ladderinfo->explow, bn_int_get(info->experience));
|
||||
|
|
|
@ -18,13 +18,6 @@
|
|||
#ifndef INCLUDED_D2CS_SETUP_H
|
||||
#define INCLUDED_D2CS_SETUP_H
|
||||
|
||||
#ifndef min
|
||||
# define min(a,b) (((a)>(b))?(b):(a))
|
||||
#endif
|
||||
#ifndef max
|
||||
# define max(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
#define tf(a) ((a)?1:0)
|
||||
|
||||
#define strcmp_charname strcasecmp
|
||||
|
|
Loading…
Add table
Reference in a new issue