bugfixes to make things compile on linux

This commit is contained in:
Enno Rehling 2005-05-06 23:25:08 +00:00
parent 2e9e7f1e23
commit 8656d93555
6 changed files with 67 additions and 57 deletions

View File

@ -302,7 +302,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
dh = 0;
if (u->faction == f || telepath_see) {
for (sk = 0; sk != MAXSKILLS; sk++) {
bufp += spskill(bufp, f->locale, u, sk, &dh, 1);
bufp += spskill(bufp, sizeof(buf)-(bufp-buf), f->locale, u, sk, &dh, 1);
}
}
@ -597,59 +597,59 @@ bufunit_ugroupleader(const faction * f, const unit * u, int indent, int mode)
#endif
size_t
spskill(char * buffer, const struct locale * lang, const struct unit * u, skill_t sk, int *dh, int days)
spskill(char * buffer, size_t siz, const struct locale * lang, const struct unit * u, skill_t sk, int *dh, int days)
{
char * pbuf = buffer;
int i, effsk;
char * bufp = buffer;
int i, effsk;
if (!u->number) return 0;
if (!u->number) return 0;
if (!has_skill(u, sk)) return 0;
if (!has_skill(u, sk)) return 0;
bufp += strlcpy(bufp, ", ", siz);
pbuf += strlcpy(pbuf, ", ", sizeof(buf));
if (!*dh) {
pbuf += strlcpy(pbuf, LOC(lang, "nr_skills"), sizeof(buf)-(bufp-buf));
pbuf += strlcpy(pbuf, ": ", sizeof(buf)-(bufp-buf));
*dh = 1;
}
pbuf += strlcpy(pbuf, skillname(sk, lang), sizeof(buf)-(bufp-buf));
strcpy(pbuf++, " ");
if (sk == SK_MAGIC){
if (find_magetype(u) != M_GRAU){
pbuf += strlcpy(pbuf, LOC(lang, mkname("school", magietypen[find_magetype(u)])), sizeof(buf)-(bufp-buf));
strcpy(pbuf++, " ");
}
}
if (sk == SK_STEALTH) {
i = u_geteffstealth(u);
if(i>=0) {
pbuf += sprintf(pbuf, "%d/", i);
}
}
effsk = effskill(u, sk);
pbuf += sprintf(pbuf, "%d", effsk);
if(u->faction->options & Pow(O_SHOWSKCHANGE)) {
skill *skill = get_skill(u, sk);
int oldeff = 0;
int diff;
if (skill->old > 0) {
oldeff = skill->old + get_modifier(u, sk, skill->old, u->region, false);
}
oldeff = max(0, oldeff);
diff = effsk - oldeff;
if(diff != 0) {
pbuf += sprintf(pbuf, " (%s%d)", (diff>0)?"+":"", diff);
}
}
return pbuf-buffer;
if (!*dh) {
bufp += strlcpy(bufp, LOC(lang, "nr_skills"), siz-(bufp-buffer));
bufp += strlcpy(bufp, ": ", sizeof(buf)-(bufp-buf));
*dh = 1;
}
bufp += strlcpy(bufp, skillname(sk, lang), siz-(bufp-buffer));
strcpy(bufp++, " ");
if (sk == SK_MAGIC){
if (find_magetype(u) != M_GRAU){
bufp += strlcpy(bufp, LOC(lang, mkname("school", magietypen[find_magetype(u)])), siz-(bufp-buffer));
strcpy(bufp++, " ");
}
}
if (sk == SK_STEALTH) {
i = u_geteffstealth(u);
if(i>=0) {
bufp += sprintf(bufp, "%d/", i);
}
}
effsk = effskill(u, sk);
bufp += sprintf(bufp, "%d", effsk);
if(u->faction->options & Pow(O_SHOWSKCHANGE)) {
skill *skill = get_skill(u, sk);
int oldeff = 0;
int diff;
if (skill->old > 0) {
oldeff = skill->old + get_modifier(u, sk, skill->old, u->region, false);
}
oldeff = max(0, oldeff);
diff = effsk - oldeff;
if(diff != 0) {
bufp += sprintf(bufp, " (%s%d)", (diff>0)?"+":"", diff);
}
}
return bufp-buffer;
}
void

View File

@ -43,7 +43,7 @@ extern int read_datenames(const char *filename);
void sparagraph(struct strlist ** SP, const char *s, int indent, char mark);
void lparagraph(struct strlist ** SP, char *s, int indent, char mark);
const char *hp_status(const struct unit * u);
extern size_t spskill(char * pbuf, const struct locale * lang, const struct unit * u, skill_t sk, int *dh, int days); /* mapper */
extern size_t spskill(char * pbuf, size_t siz, const struct locale * lang, const struct unit * u, skill_t sk, int *dh, int days); /* mapper */
extern void spunit(struct strlist ** SP, const struct faction * f, const struct unit * u, int indent, int mode);
extern int reports(void);

View File

@ -12,7 +12,6 @@ SOURCES =
#<dl>malloc.c
attrib.c
base36.c
bsdstring.c
command.c
crmessage.c
cvector.c
@ -38,4 +37,8 @@ SOURCES =
xml.c
;
if $(NO_INLINE) {
SOURCES += bsdstring.c ;
}
Library util : $(SOURCES) ;

View File

@ -1,7 +1,6 @@
#include <config.h>
#include "bsdstring.h"
#include <string.h>
#include "bsdstring.h"
#if !defined(HAVE_STRLCPY)
INLINE_FUNCTION size_t

View File

@ -46,6 +46,11 @@ extern "C" {
# include <mpatrol.h>
#endif
#if defined __GNUC__
# define HAVE_INLINE
# define INLINE_FUNCTION __inline
#endif
#ifdef DMALLOC
# ifndef MALLOCDBG
# define MALLOCDBG 1
@ -148,8 +153,8 @@ typedef struct stat stat_type;
# define R_OK 4
# define HAVE__MKDIR_WITHOUT_PERMISSION
#define HAVE_INLINE
#define INLINE_FUNCTION __inline
# define HAVE_INLINE
# define INLINE_FUNCTION __inline
# define snprintf _snprintf
# define HAVE_SNPRINTF
@ -245,6 +250,9 @@ extern char * strdup(const char *s);
}
#endif
#ifndef INLINE_FUNCTION
# define INLINE_FUNCTION
#endif
/* this function must be implemented in a .o file */
extern char * strnzcpy(char * dst, const char *src, size_t len);
#endif

View File

@ -896,7 +896,7 @@ mapper_spunit(dbllist ** SP, unit * u, int indent)
dh = 0;
for (sk = 0; sk != MAXSKILLS; sk++)
spskill(buf, find_locale("de"), u, sk, &dh, 1);
spskill(buf, sizeof(buf), find_locale("de"), u, sk, &dh, 1);
dh = 0;
for (itm = u->items;itm;itm=itm->next) {