[mw-devel] MW3 r1295 - trunk/src
welshbyte at sucs.org
welshbyte at sucs.org
Sun Nov 18 19:50:22 GMT 2012
Author: welshbyte
Date: 2012-11-18 19:50:22 +0000 (Sun, 18 Nov 2012)
New Revision: 1295
Modified:
trunk/src/init.c
trunk/src/special.c
trunk/src/special.h
Log:
Fix a logic fart in init.c and revert show_specials back to how it was before I broke it (my implementation didn't handle the gaps in the bitfield).
Modified: trunk/src/init.c
===================================================================
--- trunk/src/init.c 2012-11-18 17:27:24 UTC (rev 1294)
+++ trunk/src/init.c 2012-11-18 19:50:22 UTC (rev 1295)
@@ -426,7 +426,7 @@
goto out;
}
/* try to load the personal copy*/
- if (!ReadInitFile(pw->pw_dir, name)) {
+ if (ReadInitFile(pw->pw_dir, name)) {
fprintf(stderr, _("Failed to read init file %s/%s\n"), pw->pw_dir, name);
goto out;
}
Modified: trunk/src/special.c
===================================================================
--- trunk/src/special.c 2012-11-18 17:27:24 UTC (rev 1294)
+++ trunk/src/special.c 2012-11-18 19:50:22 UTC (rev 1295)
@@ -7,25 +7,6 @@
#include <string.h>
#include "special.h"
-static const char special_chars[MWSPCL_SIZE] = {
- [MWSPCL_COVENTRY] = 'C',
- [MWSPCL_SUPER] = 'S',
- [MWSPCL_WIZCHAT] = 'W',
- [MWSPCL_WIZCHATOFF] = 'n',
- [MWSPCL_TIMEOUT] = 'T',
- [MWSPCL_TIMESTAMP] = 't',
- [MWSPCL_POSTINFO] = 'P',
- [7] /* Unused */ = '\0',
- [MWSPCL_COLOUROFF] = 'c',
- [MWSPCL_CHGINFO] = 'G',
- [10] /* unused */ = '\0',
- [MWSPCL_QUIET] = 'Q',
- [MWSPCL_TCUNAMES] = 'U',
- [MWSPCL_DEVEL] = 'D',
- [MWSPCL_FIXEDCONTACT] = 'o',
- [MWSPCL_NOWRAP] = 'L'
-};
-
/* short = 16 bits */
unsigned short set_special(const char *string, unsigned short st)
{
@@ -61,14 +42,24 @@
else return(p);
}
-void show_special(unsigned short st, char *tmp, int flag)
+void show_special(unsigned short stat, char *tmp, int flag)
{
- int i;
- for (i = 0; i < MWSPCL_SIZE; i++)
- if (st&(1<<i))
- tmp[i] = special_chars[i];
- else if (flag)
- tmp[i]='-';
+ int i=0;
+
+ if (stat&(1<<0)) tmp[i++]='C'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<1)) tmp[i++]='S'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<2)) tmp[i++]='W'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<3)) tmp[i++]='n'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<4)) tmp[i++]='T'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<5)) tmp[i++]='t'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<6)) tmp[i++]='P'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<8)) tmp[i++]='c'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<9)) tmp[i++]='G'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<11)) tmp[i++]='Q'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<12)) tmp[i++]='U'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<13)) tmp[i++]='D'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<14)) tmp[i++]='o'; else if (flag) tmp[i++]='-';
+ if (stat&(1<<15)) tmp[i++]='L'; else if (flag) tmp[i++]='-';
+
tmp[i]=0;
}
-
Modified: trunk/src/special.h
===================================================================
--- trunk/src/special.h 2012-11-18 17:27:24 UTC (rev 1294)
+++ trunk/src/special.h 2012-11-18 19:50:22 UTC (rev 1295)
@@ -27,11 +27,11 @@
MWSPCL_TIMEOUT,
MWSPCL_TIMESTAMP,
MWSPCL_POSTINFO,
- /* 7 unused */
- MWSPCL_COLOUROFF = 8,
+ MWSPCL_UNUSED_7,
+ MWSPCL_COLOUROFF,
MWSPCL_CHGINFO,
- /* 10 unused */
- MWSPCL_QUIET = 11,
+ MWSPCL_UNUSED_10,
+ MWSPCL_QUIET,
MWSPCL_TCUNAMES,
MWSPCL_DEVEL,
MWSPCL_FIXEDCONTACT,
@@ -54,5 +54,5 @@
#define s_devel(stat) (stat & (1<<MWSPCL_DEVEL))
#define s_fixedcontact(stat) (stat & (1<<MWSPCL_FIXEDCONTACT))
#define s_nolinewrap(stat) (stat & (1<<MWSPCL_NOWRAP))
-
+
#endif /* SPECIAL_H */
More information about the mw-devel
mailing list