Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 1,258 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Possible bug? #226029
09/07/08 13:34
09/07/08 13:34
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
I'm working on function witch creates panels at runtime.


Quote:
LEVEL point1; // structure
main ()
...
populate_panels(point1); //pass it to function
...


Quote:
function populate_panels(LEVEL* leveldata)
{

var i;
for (i=0; i<leveldata->overlays; i++) //Lets create as many overlays as needed
{

if(leveldata.visibility[i] == 1) //if visibility 1 then proceed
{

overlay[i] = pan_create("bmap = leveldata.filename[i];pos_x = leveldata.posy[i];pos_y=leveldata.posy[i]; flags=VISIBLE;",2);
}

}

}


leveldata is sturuct witch contains all the info.

I try to debug using this:

Quote:
printf("my_var: %.3f",(int)i);


Struct has 13 panels, and it cycles 13 times, and on every frame I get "i" variable + 1; So, basically, leveldata->overlays successfully gets "13" value from point 1 struct.
But, for sample, if I try this:

Quote:
printf("my_var: %.3f",(int)leveldata->overlays);


I get "0", but not "13";

Why is that so? And, afcourse, all parameters at function pan_create are "0" as well. But, for instance,

Quote:
if(leveldata.visibility[i] == 1)

this part of code is "1", because on every loop cycle I can see debugger passing through this point. So it DO get parameters from point1.

And just do not get what is wrong.

Loops and if..else acts like there are parameter in leveldata, but printf or pan_create do not get them at all.




Last edited by RyuMaster; 09/07/08 14:42.

What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: Possible bug? [Re: RyuMaster] #226035
09/07/08 14:15
09/07/08 14:15
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Code:
function populate_panels(LEVEL* leveldata)
{
	var i;
	for (i=0; i<leveldata->overlays; i++) //Lets create as many overlays as needed
	{
		if(leveldata->visibility[i] == 1) //if visibility 1 then proceed
		{
			//overlay[i] = pan_create("bmap = leveldata.filename[i];pos_x = leveldata.posy[x];pos_y=leveldata.posy[i]; flags=VISIBLE;",2);
			overlay[i] = pan_create("pos_x = 0; flags=VISIBLE;", 2);
			overlay[i]->bmap = leveldata->filename[i];
			overlay[i]->pos_x = leveldata->posx[i];  // i was x (above)
			overlay[i]->pos_y = leveldata->posy[i];
		}
	}
}


Re: Possible bug? [Re: RyuMaster] #226039
09/07/08 14:46
09/07/08 14:46
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
Thanks for reply! But with such approach I get error on this line:

overlay[i]->bmap = leveldata->filename[i];

bmap is not member of a 'function'.

Probably oerlay[i] is not received as correcot pointer?
I var it as var* overlay[maxoverlays]; at the top.
Should it be something like PANEL* overlay[maxoverlays]? (this one causes engine to crash after very start)

Last edited by RyuMaster; 09/07/08 14:48.

What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: Possible bug? [Re: RyuMaster] #226047
09/07/08 15:39
09/07/08 15:39
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
How is your struct currently defined? And do you "zero()" it before use?

Ive put this code together based on this post and your struct one but they dont seem to mesh.
So Ive made some assumptions and done this.
Code:
#define maxoverlays 40

typedef struct { 
   int       overlays; //How many overlays used 
   PANEL*    overlay[maxoverlays];    //Pointer to each Overlay
   int       posx[maxoverlays];       //Its position on the map
   int       posy[maxoverlays];       // "     "      "  "   "
   int       visibility[maxoverlays]; //Overlays visibility setting
   char*     filename[maxoverlays];   //Name of panels BMAP file
   char*     background;              //Name of background BMAP file
} LEVEL;

LEVEL point1; // structure

function populate_panels(LEVEL* leveldata)
{
   var i;
   for (i=0; i<leveldata.overlays; i++) //Lets create as many overlays as needed
   {
      if(leveldata.visibility[i] == 1) //if visibility of this overlay is 1 then proceed 
      {
         STRING* BuildString = str_create("");
         str_cat(BuildString,"bmap = ");   
            str_cat(BuildString,leveldata.filename[i]);   
            str_cat(BuildString,";  ");   
         str_cat_num(BuildString,"pos_x = %.0f;  ",leveldata.posx[i]);   
         str_cat_num(BuildString,"pos_y = %.0f;  ",leveldata.posy[i]);   
         str_cat(BuildString,"flags = VISIBLE;");
         leveldata.overlay[i] = pan_create(_chr(BuildString),2);
      }
   }
}


   ...
   zero(point1);       //first time use zero to clear potential junk data
   point1.overlays=13;
   // assume build/load overlay filenames etc here
   ...
   populate_panels(point1); //pass it to function
   ...

Now, if your struct has changed from what Ive "assumed", let me know what it is and I'll look again.
Theres not enough info in this thead at the moment for me to figure out any more.

PS the weird BuildString thing you'll see before the pan_create is because the
pan_create statement WILL NOT take variables from an array. The resulting panel is
only half populated. I fell in this hole hard recently, and Im still sore.
So the BuildString creates a string containing the DATA from the array variables and builds
the panel based on that.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Possible bug? [Re: RyuMaster] #226055
09/07/08 16:58
09/07/08 16:58
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
WOW! It actually works! I can express how thankfull I am. I think such things should be in the manual, it was impossible for me to guess what was goig on.


What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: Possible bug? [Re: RyuMaster] #242947
12/26/08 18:02
12/26/08 18:02
Joined: Aug 2006
Posts: 155
R
RyuMaster Offline OP
Member
RyuMaster  Offline OP
Member
R

Joined: Aug 2006
Posts: 155
I'm stuck at some point and do not know what to do...
I load and store images in BMAP pointer array.

Quote:
BMAP* overlaybmaps[currentdex] = bmap_create(path);


At some point, I need to pass it to the panel's BuildString.
If I pass simple BMAP*, like this,

Quote:
str_cat(BuildString,"BMAPPOINTERHERE;");


it works.

But if as BMAP pointer array, like

Quote:
str_cat(BuildString,"BMAPPOINTERHERE[5];");


it is not working no matter what.

Is it supposed to be this way? I have tried many combinations, using str_cat_num as well. The worst part - I can not think of any workaround,
I need to use BMAP* array for my blitting function.

Last edited by RyuMaster; 12/26/08 18:04.

What kills me not, that makes me stronger.

***Working on RPG/RTS***
Re: Possible bug? [Re: RyuMaster] #242995
12/26/08 23:09
12/26/08 23:09
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Please check for syntax or spelling errors, Also lite-c is case sensitive.

At a quick glance I noticed str_cat(BuildString,"BMAPPOINTERHERE[5];");
which could be str_cat(BuildString,"BMAPPOINTERHERE[5]");

Also I could be wrong but I think you need to convert BMAPPOINTERHERE[5]
or maybe even try without the ".

Hope this helps.


Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus
Re: Possible bug? [Re: RyuMaster] #243021
12/27/08 08:04
12/27/08 08:04
Joined: Aug 2003
Posts: 902
Van Buren, Ar
Gordon Offline
User
Gordon  Offline
User

Joined: Aug 2003
Posts: 902
Van Buren, Ar
Simple solution to this problem:

Code:
  str_cpy(BuildString, "bmap = NULL;");
  str_cat_num (BuildString, "size_x = %4.0f",bmap_width(overlaybmaps[currentdex]));
  str_cat_num (BuildString, "size_y = %4.0f",bmap_height(overlaybmaps[currentdex]));
 //what ever else you need for the panel here
  MyPan = pan_create(BuildString,42);
  MyPan.bmap = overlaybmaps[currentdex];



Our new web site:Westmarch Studios

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1