On Sat, 26 Jan 2019 22:25:11 -0700
"Theo de Raadt" <[email protected]> wrote:

> -fsigned-char is really the wrong solution.  Every time.
> 
> The right solution is to go into the code, and fix it there.
> 
> C is complex enough as it is, without solving the architectural
> problems with variation "flags".

When I read code, I almost never check the compiler flags.  My
-fsigned-char would become a problem when someone else reads the code
but doesn't see that I added -fsigned-char to the flags.

I now attach crawl-char-4.diff, which tries to fix OpenBSD's port of
games/dungeon-crawl 4.0.0b26 without adding -fsigned-char.  I add many
small patches to change `char` to another type.  Most of these change
`char` to `signed char`, but a few change `char` to `unsigned char` or
`int`.  To make these patches, I searched most C++ files for `char`,
and guessed whether the value might be negative.  After I added the
patches, the game seemed to work, until I tried to 'Z'ap a spell
after loading a save.  I fixed the spell list by changing a few more
`char` to `signed char` around unmarshallByte() in tags.cc.

The diff has other changes:

 - Makefile: bump REVISION, remove obsolete lines.

 - patch-source_files_cc: fix wrong strncpy(), don't write 1 byte
   after the end of the array.  I didn't edit the other calls to
   strncat() or strncpy().  Those calls look bad because they might
   not terminate the string.

 - patch-source_tags_cc: edit marshallFloat and unmarshallFloat
   to help platforms where sizeof(long) > 4.  Adapted from stone-soup.

 - DESCR: mention stone-soup instead of 4.1
   (http://crawl.chaosforge.org/Dungeon_Crawl_4.1_Alpha).

I only tested this diff with ports-gcc 8.2.0p0 in OpenBSD/macppc
(powerpc), where dungeon-crawl had problems because a plain `char`
is unsigned on this platform.  (I also tried an earlier version of
this diff with ports-clang from llvm-7.0.1p1, but the default
compiler is ports-gcc.)  I have only tried a few characters, who never
survived beyond the first few floors of the dungeon.  There may still
be problems in other parts of the game, or with different characters.

I know that games/stone-soup (a newer variant of this game) is out of
date, but I have not tried to update it.  (OpenBSD has stone-soup
0.18.1, last version is 0.23.)  Both dungeon-crawl and stone-soup have
no port maintainer.

-- 
George Koehler <[email protected]>
Index: Makefile
===================================================================
RCS file: /cvs/ports/games/dungeon-crawl/Makefile,v
retrieving revision 1.12
diff -u -p -r1.12 Makefile
--- Makefile    25 Nov 2018 21:06:38 -0000      1.12
+++ Makefile    20 Feb 2019 18:15:02 -0000
@@ -9,11 +9,7 @@ DISTNAME=      dc400b26-src
 EXTRACT_SUFX=  .tbz2
 V=             4.0.0b26
 PKGNAME=       dungeon-crawl-$V
-REVISION =     4
-
-BUILD_DEPENDS+=        archivers/bzip2
-
-EXTRACT_CASES+=        *.tbz2) ${BZIP2} -dc ${FULLDISTDIR}/$$archive | ${TAR} 
xf -;;
+REVISION =     5
 
 
 WRKSRC=        ${WRKDIST}/source
@@ -36,11 +32,7 @@ DOCDIR=${PREFIX}/share/doc/dungeon-crawl
 
 do-install:
        ${INSTALL_PROGRAM} ${WRKBUILD}/crawl ${PREFIX}/bin/dungeon-crawl-$V
-       chgrp games ${PREFIX}/bin/dungeon-crawl-$V
-       chmod g+s ${PREFIX}/bin/dungeon-crawl-$V
        ${INSTALL_DATA_DIR} ${PREFIX}/lib/dungeon-crawl-$V
-       chgrp games ${PREFIX}/lib/dungeon-crawl-$V
-       chmod g+w ${PREFIX}/lib/dungeon-crawl-$V
        ${INSTALL_MAN} ${WRKDIST}/docs/crawl.6 
${PREFIX}/man/man6/dungeon-crawl-$V.6
        ${INSTALL_DATA_DIR} ${DOCDIR}
        ${INSTALL_DATA} ${WRKDIST}/licence.txt ${DOCDIR}
Index: patches/patch-source_acr_cc
===================================================================
RCS file: patches/patch-source_acr_cc
diff -N patches/patch-source_acr_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_acr_cc 20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,68 @@
+$OpenBSD$
+
+Index: source/acr.cc
+--- source/acr.cc.orig
++++ source/acr.cc
+@@ -183,12 +183,12 @@ extern unsigned char your_sign;
+ extern unsigned char your_colour;
+ 
+ // Functions in main module
+-static void close_door(char move_x, char move_y);
++static void close_door(signed char move_x, signed char move_y);
+ static void do_berserk_no_combat_penalty(void);
+ static bool initialise(void);
+ static void input(void);
+-static void move_player(char move_x, char move_y);
+-static void open_door(char move_x, char move_y);
++static void move_player(signed char move_x, signed char move_y);
++static void open_door(signed char move_x, signed char move_y);
+ 
+ /*
+    It all starts here. Some initialisations are run first, then straight to
+@@ -762,7 +762,7 @@ static void handle_wizard_command( void )
+ 
+ // This function creates "equivalence classes" so that undiscovered
+ // traps and secret doors aren't running stopping points.
+-static char base_grid_type( char grid )
++static unsigned char base_grid_type( unsigned char grid )
+ {
+     // Don't stop for undiscovered traps:
+     if (grid == DNGN_UNDISCOVERED_TRAP)
+@@ -846,8 +846,8 @@ static void input(void)
+ 
+     bool its_quiet;             //jmf: for silence messages
+     FixedVector < int, 2 > plox;
+-    char move_x = 0;
+-    char move_y = 0;
++    signed char move_x = 0;
++    signed char move_y = 0;
+ 
+     int keyin = 0;
+ 
+@@ -2431,7 +2431,7 @@ static void input(void)
+    move_y are non-zero,  the pair carries a specific direction for the door
+    to be opened (eg if you type ctrl - dir).
+  */
+-static void open_door(char move_x, char move_y)
++static void open_door(signed char move_x, signed char move_y)
+ {
+     struct dist door_move;
+     int dx, dy;             // door x, door y
+@@ -2512,7 +2512,7 @@ static void open_door(char move_x, char move_y)
+ /*
+    Similar to open_door. Can you spot the difference?
+  */
+-static void close_door(char door_x, char door_y)
++static void close_door(signed char door_x, signed char door_y)
+ {
+     struct dist door_move;
+     int dx, dy;             // door x, door y
+@@ -2762,7 +2762,7 @@ static void do_berserk_no_combat_penalty(void)
+ 
+ // Called when the player moves by walking/running. Also calls
+ // attack function and trap function etc when necessary.
+-static void move_player(char move_x, char move_y)
++static void move_player(signed char move_x, signed char move_y)
+ {
+     bool attacking = false;
+     bool moving = true;         // used to prevent eventual movement (swap)
Index: patches/patch-source_beam_cc
===================================================================
RCS file: patches/patch-source_beam_cc
diff -N patches/patch-source_beam_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_beam_cc        20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/beam.cc
+--- source/beam.cc.orig
++++ source/beam.cc
+@@ -2839,7 +2839,7 @@ static void affect_place_explosion_clouds(struct bolt 
+ 
+ static void affect_items(struct bolt &beam, int x, int y)
+ {
+-    char objs_vulnerable = -1;
++    signed char objs_vulnerable = -1;
+ 
+     switch (beam.flavour)
+     {
Index: patches/patch-source_describe_cc
===================================================================
RCS file: /cvs/ports/games/dungeon-crawl/patches/patch-source_describe_cc,v
retrieving revision 1.1
diff -u -p -r1.1 patch-source_describe_cc
--- patches/patch-source_describe_cc    25 Nov 2018 21:06:38 -0000      1.1
+++ patches/patch-source_describe_cc    20 Feb 2019 18:15:02 -0000
@@ -11,3 +11,12 @@ Index: source/describe.cc
  #include <string>
  
  #ifdef DOS
+@@ -161,7 +162,7 @@ static void randart_descpr( std::string &description, 
+ {
+     unsigned int old_length = description.length();
+ 
+-    FixedVector< char, RA_PROPERTIES > proprt;
++    FixedVector< signed char, RA_PROPERTIES > proprt;
+     randart_wpn_properties( item, proprt );
+ 
+     if (proprt[ RAP_AC ])
Index: patches/patch-source_direct_cc
===================================================================
RCS file: patches/patch-source_direct_cc
diff -N patches/patch-source_direct_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_direct_cc      20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,40 @@
+$OpenBSD$
+
+Index: source/direct.cc
+--- source/direct.cc.orig
++++ source/direct.cc
+@@ -44,15 +44,15 @@
+ 
+ // x and y offsets in the following order:
+ // SW, S, SE, W, E, NW, N, NE
+-static const char xcomp[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
+-static const char ycomp[9] = { 1, 1, 1, 0, 0, 0, -1, -1, -1 };
++static const signed char xcomp[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
++static const signed char ycomp[9] = { 1, 1, 1, 0, 0, 0, -1, -1, -1 };
+ static const char dirchars[19] = { "b1j2n3h4.5l6y7k8u9" };
+ static const char DOSidiocy[10] = { "OPQKSMGHI" };
+ static const char *aim_prompt = "Aim (move cursor or -/+/=, change mode with 
CTRL-F, select with . or >)";
+ 
+ static void describe_cell(int mx, int my);
+ static char mons_find( unsigned char xps, unsigned char yps, 
+-                       FixedVector<char, 2> &mfp, char direction, 
++                       FixedVector<char, 2> &mfp, signed char direction, 
+                        int mode = TARG_ANY );
+ 
+ //---------------------------------------------------------------
+@@ -520,12 +520,12 @@ void look_around(struct dist &moves, bool justLooking,
+ //
+ //---------------------------------------------------------------
+ static char mons_find( unsigned char xps, unsigned char yps,
+-                       FixedVector<char, 2> &mfp, char direction, int mode )
++                       FixedVector<char, 2> &mfp, signed char direction, int 
mode )
+ {
+     unsigned char temp_xps = xps;
+     unsigned char temp_yps = yps;
+-    char x_change = 0;
+-    char y_change = 0;
++    signed char x_change = 0;
++    signed char y_change = 0;
+ 
+     int i, j;
+ 
Index: patches/patch-source_dungeon_cc
===================================================================
RCS file: patches/patch-source_dungeon_cc
diff -N patches/patch-source_dungeon_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_dungeon_cc     20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,34 @@
+$OpenBSD$
+
+Index: source/dungeon.cc
+--- source/dungeon.cc.orig
++++ source/dungeon.cc
+@@ -3555,7 +3555,7 @@ static int builder_by_type(int level_number, char leve
+ 
+     if (level_type == LEVEL_PANDEMONIUM)
+     {
+-        char which_demon = -1;
++        signed char which_demon = -1;
+         // Could do spotty_level, but that doesn't always put all paired
+         // stairs reachable from each other which isn't a problem in normal
+         // dungeon but could be in Pandemonium
+@@ -7286,8 +7286,8 @@ static void labyrinth_level(int level_number)
+     int keep_lx2 = 0, keep_ly2 = 0;
+     char start_point_x = 10;
+     char start_point_y = 10;
+-    char going_x = 1;
+-    char going_y = (coinflip() ? 0 : 1);
++    signed char going_x = 1;
++    signed char going_y = (coinflip() ? 0 : 1);
+     bool do_2 = false;
+     int clear_space = 1;
+     unsigned char traps_put2 = 0;
+@@ -7731,7 +7731,7 @@ static bool treasure_area(int level_number, unsigned c
+ static void diamond_rooms(int level_number)
+ {
+     char numb_diam = 1 + random2(10);
+-    char type_floor = DNGN_DEEP_WATER;
++    unsigned char type_floor = DNGN_DEEP_WATER;
+     int runthru = 0;
+     int i, oblique_max;
+ 
Index: patches/patch-source_effects_cc
===================================================================
RCS file: /cvs/ports/games/dungeon-crawl/patches/patch-source_effects_cc,v
retrieving revision 1.1
diff -u -p -r1.1 patch-source_effects_cc
--- patches/patch-source_effects_cc     1 May 2017 21:00:15 -0000       1.1
+++ patches/patch-source_effects_cc     20 Feb 2019 18:15:02 -0000
@@ -1,4 +1,10 @@
 $OpenBSD: patch-source_effects_cc,v 1.1 2017/05/01 21:00:15 espie Exp $
+
+Add missing header.
+
+Fix when char is unsigned.
+newValue might or might not fit in a signed char.
+
 Index: source/effects.cc
 --- source/effects.cc.orig
 +++ source/effects.cc
@@ -10,3 +16,12 @@ Index: source/effects.cc
  
  #include "externs.h"
  
+@@ -134,7 +135,7 @@ bool lose_stat(unsigned char which_stat, unsigned char
+     bool statLowered = false;   // must initialize to false {dlb}
+     char *ptr_stat = 0;         // NULL {dlb}
+     char *ptr_redraw = 0;       // NULL {dlb}
+-    char newValue = 0;          // holds new value, for comparison to old 
{dlb}
++    int newValue = 0;           // holds new value, for comparison to old 
{dlb}
+ 
+     // begin outputing message: {dlb}
+     strcpy(info, "You feel ");
Index: patches/patch-source_externs_h
===================================================================
RCS file: patches/patch-source_externs_h
diff -N patches/patch-source_externs_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_externs_h      20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,36 @@
+$OpenBSD$
+
+Index: source/externs.h
+--- source/externs.h.orig
++++ source/externs.h
+@@ -133,8 +133,8 @@ struct bolt
+ struct run_check_dir
+ {
+     unsigned char       grid;
+-    char                dx;
+-    char                dy;
++    signed char         dx;
++    signed char         dy;
+ };
+ 
+ 
+@@ -173,8 +173,8 @@ struct player
+ 
+   unsigned char species;
+ 
+-  char run_x;
+-  char run_y;
++  signed char run_x;
++  signed char run_y;
+   FixedVector< run_check_dir, 3 > run_check; // array of grids to check
+   char running;
+ 
+@@ -194,7 +194,7 @@ struct player
+   int y_pos;
+ 
+   int hunger;
+-  FixedVector<char, NUM_EQUIP> equip;
++  FixedVector<signed char, NUM_EQUIP> equip;
+ 
+   int hp;
+   int hp_max;
Index: patches/patch-source_fight_cc
===================================================================
RCS file: patches/patch-source_fight_cc
diff -N patches/patch-source_fight_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_fight_cc       20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/fight.cc
+--- source/fight.cc.orig
++++ source/fight.cc
+@@ -153,7 +153,7 @@ void you_attack(int monster_attacked, bool unarmed_att
+     char st_prn[ 20 ];
+ #endif
+ 
+-    FixedVector< char, RA_PROPERTIES > art_proprt;
++    FixedVector< signed char, RA_PROPERTIES > art_proprt;
+ 
+     if (ur_armed && you.inv[weapon].base_type == OBJ_WEAPONS
+                  && is_random_artefact( you.inv[weapon] ))
Index: patches/patch-source_files_cc
===================================================================
RCS file: /cvs/ports/games/dungeon-crawl/patches/patch-source_files_cc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-source_files_cc
--- patches/patch-source_files_cc       22 Oct 2005 15:20:28 -0000      1.1.1.1
+++ patches/patch-source_files_cc       20 Feb 2019 18:15:02 -0000
@@ -1,7 +1,35 @@
 $OpenBSD: patch-source_files_cc,v 1.1.1.1 2005/10/22 15:20:28 espie Exp $
---- source/files.cc.orig       Sat Oct 22 16:03:22 2005
-+++ source/files.cc    Sat Oct 22 16:04:16 2005
-@@ -925,8 +925,13 @@ void save_game(bool leave_game)
+
+Fix wrong strncpy(): don't write to finalprefix[kFileNameLen],
+which is 1 byte after the end of the array!
+
+Fix when char is unsigned.
+
+Use SAVE_DIR_PATH when not using SAVE_PACKAGE_CMD.
+
+Index: source/files.cc
+--- source/files.cc.orig
++++ source/files.cc
+@@ -216,8 +216,7 @@ void make_filename( char *buf, const char *prefix, int
+     strcpy(buf, SAVE_DIR_PATH);
+ #endif
+ 
+-    strncpy(finalprefix, prefix, kFileNameLen);
+-    finalprefix[kFileNameLen] = '\0';
++    strlcpy(finalprefix, prefix, kFileNameLen);
+ 
+     strcat(buf, finalprefix);
+ 
+@@ -244,7 +243,7 @@ static void write_tagged_file( FILE *dataFile, char ma
+     struct tagHeader th;
+ 
+     // find all relevant tags
+-    char tags[NUM_TAGS];
++    signed char tags[NUM_TAGS];
+     tag_set_expected(tags, fileType);
+ 
+     // write version
+@@ -925,8 +924,13 @@ void save_game(bool leave_game)
                "%s.sav", name_buff );
  
  #else
@@ -15,3 +43,12 @@ $OpenBSD: patch-source_files_cc,v 1.1.1.
      strcat(charFile, ".sav");
  
  #ifdef DOS
+@@ -1200,7 +1204,7 @@ static void restore_tagged_file( FILE *restoreFile, in
+ {
+     int i;
+ 
+-    char tags[NUM_TAGS];
++    signed char tags[NUM_TAGS];
+     tag_set_expected(tags, fileType);
+ 
+     while(1)
Index: patches/patch-source_it_use2_cc
===================================================================
RCS file: patches/patch-source_it_use2_cc
diff -N patches/patch-source_it_use2_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_it_use2_cc     20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/it_use2.cc
+--- source/it_use2.cc.orig
++++ source/it_use2.cc
+@@ -504,7 +504,7 @@ void unuse_randart(unsigned char unw)
+ {
+     ASSERT( is_random_artefact( you.inv[unw] ) );
+ 
+-    FixedVector< char, RA_PROPERTIES > proprt;
++    FixedVector< signed char, RA_PROPERTIES > proprt;
+     randart_wpn_properties( you.inv[unw], proprt );
+ 
+     if (proprt[RAP_AC])
Index: patches/patch-source_item_use_cc
===================================================================
RCS file: patches/patch-source_item_use_cc
diff -N patches/patch-source_item_use_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_item_use_cc    20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,40 @@
+$OpenBSD$
+
+Fix when char is unsigned.
+lnchClass can be -1 or an unsigned char from base_type.
+
+Index: source/item_use.cc
+--- source/item_use.cc.orig
++++ source/item_use.cc
+@@ -1113,10 +1113,10 @@ void shoot_thing(void)
+ static void throw_it(struct bolt &pbolt, int throw_2)
+ {
+     struct dist thr;
+-    char shoot_skill = 0;
++    unsigned char shoot_skill = 0;
+ 
+-    char wepClass, wepType;     // ammo class and type
+-    char lnchClass, lnchType;   // launcher class and type
++    int wepClass, wepType;      // ammo class and type
++    int lnchClass, lnchType;    // launcher class and type
+ 
+     int baseHit = 0, baseDam = 0;       // from thrown or ammo
+     int ammoHitBonus = 0, ammoDamBonus = 0;     // from thrown or ammo
+@@ -2154,7 +2154,7 @@ void zap_wand(void)
+     // blargh! blech! this is just begging to be a problem ...
+     // not to mention work-around after work-around as wands are
+     // added, removed, or altered {dlb}:
+-    char type_zapped = you.inv[item_slot].sub_type;
++    unsigned char type_zapped = you.inv[item_slot].sub_type;
+ 
+     if (type_zapped == WAND_ENSLAVEMENT)
+         type_zapped = ZAP_ENSLAVEMENT;
+@@ -3088,7 +3088,7 @@ void use_randart(unsigned char item_wield_2)
+ {
+     ASSERT( is_random_artefact( you.inv[ item_wield_2 ] ) );
+ 
+-    FixedVector< char, RA_PROPERTIES >  proprt;
++    FixedVector< signed char, RA_PROPERTIES >  proprt;
+     randart_wpn_properties( you.inv[item_wield_2], proprt );
+ 
+     if (proprt[RAP_AC])
Index: patches/patch-source_mon-util_h
===================================================================
RCS file: patches/patch-source_mon-util_h
diff -N patches/patch-source_mon-util_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_mon-util_h     20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/mon-util.h
+--- source/mon-util.h.orig
++++ source/mon-util.h
+@@ -144,7 +144,7 @@ struct monsterentry
+     // 0=no zombie, 1=small zombie (z) 107, 2=_BIG_ zombie (Z) 108
+     char zombie_size PACKED;
+   // 0-12: see above, -1=random one of (0-7)
+-    char shouts PACKED;
++    signed char shouts PACKED;
+   // AI things?
+     char intel PACKED;          // 0=none, 1=worst...4=best
+ 
Index: patches/patch-source_monplace_cc
===================================================================
RCS file: /cvs/ports/games/dungeon-crawl/patches/patch-source_monplace_cc,v
retrieving revision 1.1
diff -u -p -r1.1 patch-source_monplace_cc
--- patches/patch-source_monplace_cc    25 Nov 2018 21:06:38 -0000      1.1
+++ patches/patch-source_monplace_cc    20 Feb 2019 18:15:02 -0000
@@ -12,3 +12,27 @@ Index: source/monplace.cc
  #include "AppHdr.h"
  #include "monplace.h"
  
+@@ -346,7 +348,7 @@ static int place_monster_aux( int mon_type, char behav
+                               bool first_band_member )
+ {
+     int id, i;
+-    char grid_wanted;
++    unsigned char grid_wanted;
+     int fx=0, fy=0;     // final x,y
+ 
+     // gotta be able to pick an ID
+@@ -1180,10 +1182,10 @@ bool empty_surrounds(int emx, int emy, unsigned char s
+     int good_count = 0;
+     int count_x, count_y;
+ 
+-    char minx = -2;
+-    char maxx = 2;
+-    char miny = -2;
+-    char maxy = 2;
++    signed char minx = -2;
++    signed char maxx = 2;
++    signed char miny = -2;
++    signed char maxy = 2;
+ 
+     for (count_x = minx; count_x <= maxx; count_x++)
+     {
Index: patches/patch-source_monstuff_cc
===================================================================
RCS file: patches/patch-source_monstuff_cc
diff -N patches/patch-source_monstuff_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_monstuff_cc    20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/monstuff.cc
+--- source/monstuff.cc.orig
++++ source/monstuff.cc
+@@ -58,7 +58,7 @@ static void monster_move(struct monsters *monster);
+ static bool plant_spit(struct monsters *monster, struct bolt &pbolt);
+ static int map_wand_to_mspell(int wand_type);
+ 
+-char mmov_x, mmov_y;
++signed char mmov_x, mmov_y;
+ 
+ static int compass_x[8] = { -1, 0, 1, 1, 1, 0, -1, -1 };
+ static int compass_y[8] = { -1, -1, -1, 0, 1, 1, 1, 0 };
Index: patches/patch-source_mstuff2_cc
===================================================================
RCS file: patches/patch-source_mstuff2_cc
diff -N patches/patch-source_mstuff2_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_mstuff2_cc     20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/mstuff2.cc
+--- source/mstuff2.cc.orig
++++ source/mstuff2.cc
+@@ -705,7 +705,7 @@ void monster_teleport(struct monsters *monster, bool i
+     // pick the monster up
+     mgrd[monster->x][monster->y] = NON_MONSTER;
+ 
+-    char ogrid = monster_habitat(monster->type);
++    unsigned char ogrid = monster_habitat(monster->type);
+ 
+     int newx, newy;
+     while(true)
Index: patches/patch-source_ouch_cc
===================================================================
RCS file: patches/patch-source_ouch_cc
diff -N patches/patch-source_ouch_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_ouch_cc        20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/ouch.cc
+--- source/ouch.cc.orig
++++ source/ouch.cc
+@@ -256,7 +256,7 @@ void splash_with_acid( char acid_strength )
+ 
+ void weapon_acid( char acid_strength )
+ {
+-    char hand_thing = you.equip[EQ_WEAPON];
++    signed char hand_thing = you.equip[EQ_WEAPON];
+ 
+     if (hand_thing == -1)
+         hand_thing = you.equip[EQ_GLOVES];
Index: patches/patch-source_overmap_cc
===================================================================
RCS file: patches/patch-source_overmap_cc
diff -N patches/patch-source_overmap_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_overmap_cc     20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/overmap.cc
+--- source/overmap.cc.orig
++++ source/overmap.cc
+@@ -48,7 +48,7 @@ enum
+ //   # == which god for remaining numbers.
+ 
+ FixedArray<unsigned char, MAX_LEVELS, MAX_BRANCHES> altars_present;
+-FixedVector<char, MAX_BRANCHES> stair_level;
++FixedVector<signed char, MAX_BRANCHES> stair_level;
+ FixedArray<unsigned char, MAX_LEVELS, MAX_BRANCHES> feature;
+ 
+ int map_lines = 0; //mv: number of lines already printed on "over-map" screen
Index: patches/patch-source_player_cc
===================================================================
RCS file: patches/patch-source_player_cc
diff -N patches/patch-source_player_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_player_cc      20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/player.cc
+--- source/player.cc.orig
++++ source/player.cc
+@@ -3121,7 +3121,7 @@ int scan_randarts(char which_property)
+     return (retval);
+ }                               // end scan_randarts()
+ 
+-void modify_stat(unsigned char which_stat, char amount, bool suppress_msg)
++void modify_stat(unsigned char which_stat, signed char amount, bool 
suppress_msg)
+ {
+     char *ptr_stat = NULL;
+     char *ptr_stat_max = NULL;
Index: patches/patch-source_player_h
===================================================================
RCS file: patches/patch-source_player_h
diff -N patches/patch-source_player_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_player_h       20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/player.h
+--- source/player.h.orig
++++ source/player.h
+@@ -311,7 +311,7 @@ void gain_exp(unsigned int exp_gained);
+  * called from: acr - it_use2 - item_use - mutation - transfor - player -
+  *              misc - stuff
+  * *********************************************************************** */
+-void modify_stat(unsigned char which_stat, char amount, bool suppress_msg);
++void modify_stat(unsigned char which_stat, signed char amount, bool 
suppress_msg);
+ 
+ 
+ // last updated 19may2000 {dlb}
Index: patches/patch-source_randart_cc
===================================================================
RCS file: /cvs/ports/games/dungeon-crawl/patches/patch-source_randart_cc,v
retrieving revision 1.1
diff -u -p -r1.1 patch-source_randart_cc
--- patches/patch-source_randart_cc     1 May 2017 21:00:15 -0000       1.1
+++ patches/patch-source_randart_cc     20 Feb 2019 18:15:02 -0000
@@ -10,3 +10,21 @@ Index: source/randart.cc
  
  #include "externs.h"
  #include "itemname.h"
+@@ -747,7 +748,7 @@ static long calc_seed( const item_def &item )
+ }
+ 
+ void randart_wpn_properties( const item_def &item, 
+-                             FixedVector< char, RA_PROPERTIES > &proprt )
++                             FixedVector< signed char, RA_PROPERTIES > 
&proprt )
+ {
+     ASSERT( is_random_artefact( item ) ); 
+ 
+@@ -1211,7 +1212,7 @@ finished_curses:
+ 
+ int randart_wpn_property( const item_def &item, char prop )
+ {
+-    FixedVector< char, RA_PROPERTIES > proprt;
++    FixedVector< signed char, RA_PROPERTIES > proprt;
+ 
+     randart_wpn_properties( item, proprt );
+ 
Index: patches/patch-source_randart_h
===================================================================
RCS file: patches/patch-source_randart_h
diff -N patches/patch-source_randart_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_randart_h      20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/randart.h
+--- source/randart.h.orig
++++ source/randart.h
+@@ -71,7 +71,7 @@ int find_okay_unrandart(unsigned char aclass, unsigned
+  * called from: describe - fight - it_use2 - item_use - player
+  * *********************************************************************** */
+ void randart_wpn_properties( const item_def &item, 
+-                             FixedVector< char, RA_PROPERTIES > &proprt );
++                             FixedVector< signed char, RA_PROPERTIES > 
&proprt );
+ 
+ int randart_wpn_property( const item_def &item, char prop );
+ 
Index: patches/patch-source_shopping_cc
===================================================================
RCS file: patches/patch-source_shopping_cc
diff -N patches/patch-source_shopping_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_shopping_cc    20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/shopping.cc
+--- source/shopping.cc.orig
++++ source/shopping.cc
+@@ -371,7 +371,7 @@ int randart_value( const item_def &item )
+     ASSERT( is_random_artefact( item ) );
+ 
+     int ret = 10;
+-    FixedVector< char, RA_PROPERTIES >  prop;
++    FixedVector< signed char, RA_PROPERTIES >  prop;
+ 
+     randart_wpn_properties( item, prop );
+ 
Index: patches/patch-source_spells1_cc
===================================================================
RCS file: patches/patch-source_spells1_cc
diff -N patches/patch-source_spells1_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_spells1_cc     20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,32 @@
+$OpenBSD$
+
+Index: source/spells1.cc
+--- source/spells1.cc.orig
++++ source/spells1.cc
+@@ -377,7 +377,7 @@ void big_cloud(char clouds, char cl_x, char cl_y, int 
+     apply_area_cloud(make_a_normal_cloud, cl_x, cl_y, pow, size, clouds);
+ }                               // end big_cloud()
+ 
+-static char healing_spell( int healed )
++static signed char healing_spell( int healed )
+ {
+     int mgr = 0;
+     struct monsters *monster = 0;       // NULL {dlb}
+@@ -446,7 +446,7 @@ char cast_greatest_healing( int pow )
+ }                               // end cast_greatest_healing()
+ #endif 
+ 
+-char cast_healing( int pow )
++signed char cast_healing( int pow )
+ {
+     if (pow > 50)
+         pow = 50;
+@@ -1036,7 +1036,7 @@ void manage_fire_shield(void)
+     if (!you.fire_shield)
+         return;
+ 
+-    char stx = 0, sty = 0;
++    signed char stx = 0, sty = 0;
+ 
+     for (stx = -1; stx < 2; stx++)
+     {
Index: patches/patch-source_spells1_h
===================================================================
RCS file: patches/patch-source_spells1_h
diff -N patches/patch-source_spells1_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_spells1_h      20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/spells1.h
+--- source/spells1.h.orig
++++ source/spells1.h
+@@ -50,7 +50,7 @@ char cast_lesser_healing(void);
+ /* ***********************************************************************
+  * called from: ability - spell
+  * *********************************************************************** */
+-char cast_healing(int power);
++signed char cast_healing(int power);
+ 
+ // last updated 24may2000 {dlb}
+ /* ***********************************************************************
Index: patches/patch-source_spells2_cc
===================================================================
RCS file: patches/patch-source_spells2_cc
diff -N patches/patch-source_spells2_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_spells2_cc     20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,50 @@
+$OpenBSD$
+
+Fix when char is unsigned.  Change summ_success to int because it
+holds the int return from create_monster().
+
+Index: source/spells2.cc
+--- source/spells2.cc.orig
++++ source/spells2.cc
+@@ -148,15 +148,15 @@ int corpse_rot(int power)
+ {
+     UNUSED( power );
+ 
+-    char adx = 0;
+-    char ady = 0;
++    signed char adx = 0;
++    signed char ady = 0;
+ 
+-    char minx = you.x_pos - 6;
+-    char maxx = you.x_pos + 7;
+-    char miny = you.y_pos - 6;
+-    char maxy = you.y_pos + 6;
+-    char xinc = 1;
+-    char yinc = 1;
++    signed char minx = you.x_pos - 6;
++    signed char maxx = you.x_pos + 7;
++    signed char miny = you.y_pos - 6;
++    signed char maxy = you.y_pos + 6;
++    signed char xinc = 1;
++    signed char yinc = 1;
+ 
+     if (coinflip())
+     {
+@@ -992,7 +992,7 @@ int vampiric_drain(int pow)
+ }                               // end vampiric_drain()
+ 
+ // Note: this function is currently only used for Freeze. -- bwr
+-char burn_freeze(int pow, char flavour)
++signed char burn_freeze(int pow, char flavour)
+ {
+     int mgr = NON_MONSTER;
+     struct monsters *monster = 0;       // NULL {dlb}
+@@ -1087,7 +1087,7 @@ int summon_elemental(int pow, unsigned char restricted
+                      unsigned char unfriendly)
+ {
+     int type_summoned = MONS_PROGRAM_BUG;       // error trapping {dlb}
+-    char summ_success = 0;
++    int summ_success = 0;
+     struct dist smove;
+ 
+     int dir_x;
Index: patches/patch-source_spells2_h
===================================================================
RCS file: patches/patch-source_spells2_h
diff -N patches/patch-source_spells2_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_spells2_h      20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/spells2.h
+--- source/spells2.h.orig
++++ source/spells2.h
+@@ -37,7 +37,7 @@ int animate_dead(int power, int corps_beh, int corps_h
+ /* ***********************************************************************
+  * called from: spell
+  * *********************************************************************** */
+-char burn_freeze(int pow, char b_f);
++signed char burn_freeze(int pow, char b_f);
+ 
+ 
+ // last updated 24may2000 {dlb}
Index: patches/patch-source_spells3_cc
===================================================================
RCS file: patches/patch-source_spells3_cc
diff -N patches/patch-source_spells3_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_spells3_cc     20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/spells3.cc
+--- source/spells3.cc.orig
++++ source/spells3.cc
+@@ -972,7 +972,7 @@ bool recall(char type_recalled)
+ 
+ void portal(void)
+ {
+-    char dir_sign = 0;
++    signed char dir_sign = 0;
+     unsigned char keyi;
+     int target_level = 0;
+     int old_level = you.your_level;
Index: patches/patch-source_spl-util_cc
===================================================================
RCS file: patches/patch-source_spl-util_cc
diff -N patches/patch-source_spl-util_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_spl-util_cc    20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+Index: source/spl-util.cc
+--- source/spl-util.cc.orig
++++ source/spl-util.cc
+@@ -663,8 +663,8 @@ void apply_area_cloud( int (*func) (int, int, int, int
+     }
+ }                               // end apply_area_cloud()
+ 
+-char spell_direction( struct dist &spelld, struct bolt &pbolt, 
+-                      int restrict, int mode )
++signed char spell_direction( struct dist &spelld, struct bolt &pbolt, 
++                             int restrict, int mode )
+ {
+     if (restrict == DIR_TARGET)
+         mpr( "Choose a target (+/- for next/prev monster)", MSGCH_PROMPT );
Index: patches/patch-source_spl-util_h
===================================================================
RCS file: patches/patch-source_spl-util_h
diff -N patches/patch-source_spl-util_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_spl-util_h     20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: source/spl-util.h
+--- source/spl-util.h.orig
++++ source/spl-util.h
+@@ -74,7 +74,7 @@ int apply_one_neighbouring_square(int (*func) (int, in
+ int apply_area_within_radius(int (*func) (int, int, int, int),
+                               int x, int y, int pow, int radius, int ctype);
+ 
+-char spell_direction( struct dist &spelld, struct bolt &pbolt,
++signed char spell_direction( struct dist &spelld, struct bolt &pbolt,
+                               int restrict = DIR_NONE, int mode = TARG_ENEMY 
);
+ 
+ void apply_area_cloud(int (*func) (int, int, int, int), int x, int y,
Index: patches/patch-source_tags_cc
===================================================================
RCS file: /cvs/ports/games/dungeon-crawl/patches/patch-source_tags_cc,v
retrieving revision 1.1
diff -u -p -r1.1 patch-source_tags_cc
--- patches/patch-source_tags_cc        1 May 2017 21:00:15 -0000       1.1
+++ patches/patch-source_tags_cc        20 Feb 2019 18:15:02 -0000
@@ -1,4 +1,16 @@
 $OpenBSD: patch-source_tags_cc,v 1.1 2017/05/01 21:00:15 espie Exp $
+
+Add missing header.
+
+Fix when char is unsigned.  The byte from unmarshallByte must be
+signed, because it might be -1 and the code may promote it to int.
+(stone-soup uses int8_t in unmarshallByte.)
+
+Edit marshallFloat and unmarshallFloat to help platforms where
+sizeof(long) > 4.  Adapted from stone-soup
+https://github.com/crawl/crawl/blob/1d0f57c/crawl-ref/source/tags.cc
+before the license change https://github.com/crawl/crawl/commit/07a1981
+
 Index: source/tags.cc
 --- source/tags.cc.orig
 +++ source/tags.cc
@@ -10,3 +22,73 @@ Index: source/tags.cc
  
  #ifdef LINUX
  #include <sys/types.h>
+@@ -95,7 +96,7 @@ static char *tagBuffer = NULL;
+ 
+ // These three are defined in overmap.cc
+ extern FixedArray < unsigned char, MAX_LEVELS, MAX_BRANCHES > altars_present;
+-extern FixedVector < char, MAX_BRANCHES > stair_level;
++extern FixedVector < signed char, MAX_BRANCHES > stair_level;
+ extern FixedArray < unsigned char, MAX_LEVELS, MAX_BRANCHES > feature;
+ 
+ extern unsigned char your_sign; /* these two are defined in view.cc */
+@@ -138,15 +139,15 @@ int read2(FILE * file, char *buffer, unsigned int coun
+     return fread(buffer, 1, count, file);
+ }
+ 
+-void marshallByte(struct tagHeader &th, char data)
++void marshallByte(struct tagHeader &th, signed char data)
+ {
+     tagBuffer[th.offset] = data;
+     th.offset += 1;
+ }
+ 
+-char unmarshallByte(struct tagHeader &th)
++signed char unmarshallByte(struct tagHeader &th)
+ {
+-    char data = tagBuffer[th.offset];
++    signed char data = tagBuffer[th.offset];
+     th.offset += 1;
+     return data;
+ }
+@@ -206,19 +207,27 @@ long unmarshallLong(struct tagHeader &th)
+     return data;
+ }
+ 
++union float_marshall_kludge
++{
++    // assuming sizeof(float) == 4 && sizeof(int) == 4
++    float f_num;
++    int   l_num;
++};
++
+ // single precision float -- marshall in network order.
+ void marshallFloat(struct tagHeader &th, float data)
+ {
+-    long intBits = *((long *)(&data));
+-    marshallLong(th, intBits);
++    float_marshall_kludge k;
++    k.f_num = data;
++    marshallLong(th, k.l_num);
+ }
+ 
+ // single precision float -- unmarshall in network order.
+ float unmarshallFloat(struct tagHeader &th)
+ {
+-    long intBits = unmarshallLong(th);
+-
+-    return *((float *)(&intBits));
++    float_marshall_kludge k;
++    k.l_num = unmarshallLong(th);
++    return k.f_num;
+ }
+ 
+ // string -- marshall length & string data
+@@ -500,7 +509,7 @@ void tag_missing(int tag, char minorVersion)
+ }
+ 
+ // utility
+-void tag_set_expected(char tags[], int fileType)
++void tag_set_expected(signed char tags[], int fileType)
+ {
+     int i;
+ 
Index: patches/patch-source_tags_h
===================================================================
RCS file: patches/patch-source_tags_h
diff -N patches/patch-source_tags_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_tags_h 20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,32 @@
+$OpenBSD$
+
+Index: source/tags.h
+--- source/tags.h.orig
++++ source/tags.h
+@@ -32,7 +32,7 @@ int read2(FILE * file, char *buffer, unsigned int coun
+ /* ***********************************************************************
+  * called from: files tags
+  * *********************************************************************** */
+-void marshallByte(struct tagHeader &th, char data);
++void marshallByte(struct tagHeader &th, signed char data);
+ void marshallShort(struct tagHeader &th, short data);
+ void marshallLong(struct tagHeader &th, long data);
+ void marshallFloat(struct tagHeader &th, float data);
+@@ -43,7 +43,7 @@ void marshallString(struct tagHeader &th, char *data, 
+ /* ***********************************************************************
+  * called from: tags files
+  * *********************************************************************** */
+-char unmarshallByte(struct tagHeader &th);
++signed char unmarshallByte(struct tagHeader &th);
+ short unmarshallShort(struct tagHeader &th);
+ long unmarshallLong(struct tagHeader &th);
+ float unmarshallFloat(struct tagHeader &th);
+@@ -78,7 +78,7 @@ void tag_write(struct tagHeader &th, FILE *saveFile);
+ /* ***********************************************************************
+  * called from: files
+  * *********************************************************************** */
+-void tag_set_expected(char tags[], int fileType);
++void tag_set_expected(signed char tags[], int fileType);
+ 
+ 
+ // last updated 22jan2001 {gdl}
Index: patches/patch-source_view_cc
===================================================================
RCS file: patches/patch-source_view_cc
diff -N patches/patch-source_view_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-source_view_cc        20 Feb 2019 18:15:02 -0000
@@ -0,0 +1,25 @@
+$OpenBSD$
+
+Index: source/view.cc
+--- source/view.cc.orig
++++ source/view.cc
+@@ -1115,7 +1115,7 @@ bool check_awaken(int mons_aw)
+ 
+ void item()
+ {
+-    char count_x, count_y;
++    signed char count_x, count_y;
+ 
+     for (count_y = (you.y_pos - 8); (count_y < you.y_pos + 9); count_y++)
+     {
+@@ -1749,8 +1749,8 @@ void show_map( FixedVector<int, 2> &spec_place )
+ 
+     int bufcount2 = 0;
+ 
+-    char move_x = 0;
+-    char move_y = 0;
++    signed char move_x = 0;
++    signed char move_y = 0;
+     char getty = 0;
+ 
+ #ifdef DOS_TERM
Index: pkg/DESCR
===================================================================
RCS file: /cvs/ports/games/dungeon-crawl/pkg/DESCR,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 DESCR
--- pkg/DESCR   22 Oct 2005 15:20:28 -0000      1.1.1.1
+++ pkg/DESCR   20 Feb 2019 18:15:02 -0000
@@ -2,11 +2,9 @@ Linley's dungeon-crawl is a dungeon slas
 It's very similar to nethack, to the extent that 
 most of the keys are the same, but it is a much harder game.
 
-Development has been somewhat sporadic, there might be a 4.1 version
-at some point.
-
 It's a text terminal-only game, but you can get colors, provided your
 TERM defines them.
 
 This package can coexist with later versions of dungeon-crawl, to allow
-players to finish their game.
+players to finish their game.  The later Dungeon Crawl Stone Soup is in
+the stone-soup package.

Reply via email to