delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/02/16:10:41

X-Originating-Host: 155.45.54.60
Organization: http://www.remarq.com: The World's Usenet/Discussions Start Here
Subject: Bizzare problem in program using DJGPP/Allegro
Lines: 74
From: Litmus Dragon <litmusdragonNOliSPAM AT mailcity DOT com DOT invalid>
Newsgroups: comp.os.msdos.djgpp
Message-ID: <14a024ed.437a99bd@usw-ex0105-037.remarq.com>
Bytes: 3317
X-Wren-Trace: ePbT+/rjpO6luuvq/qPk+/bk4fz90rvh+vb6/Ov7obX2/famreOtrK+5p6e24LU=
Date: Wed, 02 Feb 2000 11:55:06 -0800
NNTP-Posting-Host: 10.0.2.37
X-Complaints-To: wrenabuse AT remarq DOT com
X-Trace: WReNphoon2 949520964 10.0.2.37 (Wed, 02 Feb 2000 11:49:24 PST)
NNTP-Posting-Date: Wed, 02 Feb 2000 11:49:24 PST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I am having an incredibly illogical problem within a C program
I've written.  This is a rather large program which is actually
two seperate programs, a playgame.exe and an editgame.exe.
Playgame.exe is an tile based RPG engine, and editgame.exe is a
program for editing the game that you play with playgame.exe.

Here's the problem I'm having.  A function called "loadmain()"
is called near the beginning of both programs.  This function
loads all of the game variables from a file called "game.dat".
This is a compressed data file using allegro's data compression
format.

Here's the problem.  There's a array of integers defined in
editgame.exe which determines which types of items are passable,
and which block travel.  The variable is called itmammo[500]
(because for weapons it is used for ammo, for objects on the
maps it is used as a flag for passable/impassable).

If itmammo[x]==0, the item blocks travel, if not, you can walk
over it.

In playgame.exe, I first noticed the problem when I realized
that wether or not you set an object as passable, you could walk
over it.  I went through a series of steps and was able to
determinet that itmammo was ALWAYS zero for every item in
playgame.exe, although in editgame.exe, loadmain() returned the
correct value for this array.

The loadmain() function is the same in both programs.  Both
programs use the same set of variables.

Finally, in an effort to understand exactly where this was going
wrong, I added a printf calls to loadmain() which are called at
various points in reading the data file.  These calls print the
value of itmammo at various points in reading the data file.
When playgame.exe calls loadmain() and reads the first itmammo
[x], the printf value returns the correct value.  Once it is
done reading the entire itmammo array from the file, it still is
return the correct values (for every variable in the array).
However if I did a printf of one of the itmammo[x] variables at
the end of the loadmain() function (right after I call
pack_fclose(packf)) and it returns 0!  No matter which of the
variabels in the array I point it to.

The editor has none of these problems.  Loadmain() works
perfectly, itmammo has it's correct value for all items at all
times.

I realize that the source code would help, but loadmain() itself
is 350 lines long.  And without the source for the entire
program it would probably be a useless post anyways.

What an illogical, confusing problem!  It's the same loadmain()
routine.  It's the same set of variables with the "de_var.h"
file defining them in both programs.  What in the world could be
causing this?

Can you sense my distress?  :)  I've been working on this
project for months and I hate to see it blocked by something
that just dosn't make any sense.

Any thoughts?  :)  Is this enough info?

BTW: I am using the latest DJGPP and the latest WIP version of
Allegro for DJGPP.

btw: don't reply via the email address in the header of this
message as remarq "spam shields" it and your message wont reach
me.  email me here: litmusdragon AT mailcity DOT com or just reply to
the thread


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019