Skip to content

Commit

Permalink
Compatibility fixes for NetBSD and Solaris
Browse files Browse the repository at this point in the history
- Fixed some warnings in NetBSD (5.x and 6.x) and Solaris (11)

Signed-off-by: Haru <haru@dotalux.com>
  • Loading branch information
MishimaHaruna committed Jan 23, 2014
1 parent 22b7f90 commit e68d860
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/common/cbasetypes.h
Expand Up @@ -42,6 +42,11 @@
#define __DARWIN__
#endif

// Necessary for __NetBSD_Version__ (defined as VVRR00PP00) on NetBSD
#ifdef __NETBSD__
#include <sys/param.h>
#endif // __NETBSD__

// 64bit OS
#if defined(_M_IA64) || defined(_M_X64) || defined(_WIN64) || defined(_LP64) || defined(_ILP64) || defined(__LP64__) || defined(__ppc64__)
#define __64BIT__
Expand Down
4 changes: 4 additions & 0 deletions src/map/clif.c
Expand Up @@ -12959,14 +12959,18 @@ bool clif_validate_emblem(const uint8 *emblem, unsigned long emblem_len) {
BITMAP_WIDTH = 24,
BITMAP_HEIGHT = 24,
};
#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
#pragma pack(push, 1)
#endif // not NetBSD < 6 / Solaris
struct s_bitmaptripple {
//uint8 b;
//uint8 g;
//uint8 r;
unsigned int rgb:24;
} __attribute__((packed));
#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
#pragma pack(pop)
#endif // not NetBSD < 6 / Solaris
uint8 buf[1800]; // no well-formed emblem bitmap is larger than 1782 (24 bit) / 1654 (8 bit) bytes
unsigned long buf_len = sizeof(buf);
int header = 0, bitmap = 0, offbits = 0, palettesize = 0, i = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/map/npc.c
Expand Up @@ -2432,7 +2432,7 @@ int npc_parseview(const char* w4, const char* start, const char* buffer, const c

// Extract view ID / constant
while (w4[i] != '\0') {
if (isspace(w4[i]) || w4[i] == '/' || w4[i] == ',')
if (ISSPACE(w4[i]) || w4[i] == '/' || w4[i] == ',')
break;

i++;
Expand Down Expand Up @@ -2464,7 +2464,7 @@ bool npc_viewisid(const char * viewid)
{
// Loop through view, looking for non-numeric character.
while (*viewid) {
if (isdigit(*viewid++) == 0) return false;
if (ISDIGIT(*viewid++) == 0) return false;
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/map/packets_struct.h
Expand Up @@ -205,7 +205,9 @@ enum packet_headers {
npcmarketopenType = 0x9d5,
};

#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
#pragma pack(push, 1)
#endif // not NetBSD < 6 / Solaris

/**
* structs for data
Expand Down Expand Up @@ -939,6 +941,8 @@ struct packet_npc_market_open {
} list[1000];/* TODO: whats the actual max of this? */
} __attribute__((packed));

#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
#pragma pack(pop)
#endif // not NetBSD < 6 / Solaris

#endif /* _PACKETS_STRUCT_H_ */

0 comments on commit e68d860

Please sign in to comment.