Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, The_Judge, Grant), 898 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
crash in a simple function... #151594
09/02/07 04:46
09/02/07 04:46
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
...that takes PANEL* as a parameter:

Code:

void drag_win(PANEL* _pan_)
{
while(mouse_left== 1)
{
_pan_.pos_x= mouse_cursor.x - 128;
_pan_.pos_y= mouse_cursor.y - 8;
wait(1);
}
}

... calling it in the button function:

PANEL* quitter=
{
pos_x= 384;
pos_y= 256;
bmap= "exit_prompt.pcx";
red= 128;
green= 128;
blue= 128;
alpha= 100;
button(0,0,"dragger.pcx","dragger.pcx","dragger.pcx",drag_win,NULL,NULL);
button(32,88,"yess_on.pcx","yess_off.pcx","yess_ovr.pcx",exit_,NULL,NULL);
button(104,88,"no_on.pcx","no_off.pcx","no_ovr.pcx",quitter_switch,NULL,NULL);
button(240,0,"x_on.pcx","x_off.pcx","x_ovr.pcx",quitter_switch,NULL,NULL);
flags= LIGHT | TRANSLUCENT | OVERLAY;
}



When I click on the bar, though, it says "Crash in drag_win".

Can anyone figure out why?

I put the function below the PANEL* declaration, just so you know, and so that the function can take that as a parameter. According to the manual:

Quote:


Several buttons may share the same function. The number of the button is passed as the first parameter to the function (1 = first button), the panel pointer is passed as the second parameter.





I'm only using one button for dragging the window around, why isn't it passing the PANEL* "quitter" to the function?!


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: crash in a simple function... [Re: MrCode] #151595
09/02/07 05:15
09/02/07 05:15
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
ARGH!! Another problem!!

Now the FPS drops to about 20 at runtime after removing the function!

I did a diag(); on all the functions that can possibly be running at the time, and none of them are constantly being called!!

Here's the complete Code:

#include <acknex.h>
#include <default.c>

STRING* type_string= "#100000";

BMAP* cur= "bcursor.pcx";
int button_num= 0,dummy= 0;

FONT* font1= "Times New Roman#17";
FONT* font2= "Arial#17";
FONT* font3= "Terminal#12";
FONT* font4= "Small Fonts#20";

TEXT* user_text=
{
pos_y= 32;
red= 0;
green= 0;
blue= 0;
string= type_string;
font= font1;
flags= VISIBLE;
}

PANEL* gui=
{
bmap= "gui.pcx";
red= 128;
blue= 128;
green= 128;
alpha= 100;
button(10,0,"file_on.pcx","file_off.pcx","file_ovr.pcx",menu,NULL,NULL);
button(42,0,"edit_on.pcx","edit_off.pcx","edit_ovr.pcx",menu,NULL,NULL);
button(74,0,"options_on.pcx","options_off.pcx","options_ovr.pcx",menu,NULL,NULL);
button(106,0,"help_on.pcx","help_off.pcx","help_ovr.pcx",menu,NULL,NULL);
button(1008,0,"x_on.pcx","x_off.pcx","x_ovr.pcx",quitter_switch,NULL,NULL);
flags= VISIBLE | LIGHT | TRANSLUCENT | OVERLAY;
}

PANEL* gui_dropdown1=
{
pos_x= 10;
pos_y= 16;
bmap= "gui_dropdown.pcx";
red= 128;
green= 128;
blue= 128;
alpha= 100;
button(0,0,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,16,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,32,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,48,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,64,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,80,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,96,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,112,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
flags= LIGHT | TRANSLUCENT;
}

PANEL* gui_dropdown2=
{
pos_x= 42;
pos_y= 16;
bmap= "gui_dropdown.pcx";
red= 128;
green= 128;
blue= 128;
alpha= 100;
button(0,0,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,16,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,32,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,48,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,64,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,80,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,96,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,112,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
flags= LIGHT | TRANSLUCENT;
}

PANEL* gui_dropdown3=
{
pos_x= 74;
pos_y= 16;
bmap= "gui_dropdown.pcx";
red= 128;
green= 128;
blue= 128;
alpha= 100;
button(0,0,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,16,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,32,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,48,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,64,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,80,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,96,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,112,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
flags= LIGHT | TRANSLUCENT;
}

PANEL* gui_dropdown4=
{
pos_x= 106;
pos_y= 16;
bmap= "gui_dropdown.pcx";
red= 128;
green= 128;
blue= 128;
alpha= 100;
button(0,0,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,16,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,32,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,48,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,64,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,80,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,96,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
button(0,112,"selector_on.tga",NULL,"selector_ovr.tga",NULL,NULL,NULL);
flags= LIGHT | TRANSLUCENT;
}

PANEL* quitter=
{
pos_x= 384;
pos_y= 256;
bmap= "exit_prompt.pcx";
red= 128;
green= 128;
blue= 128;
alpha= 100;
button(0,0,"dragger.pcx","dragger.pcx","dragger.pcx",NULL,NULL,NULL);
button(32,88,"yess_on.pcx","yess_off.pcx","yess_ovr.pcx",exit_,NULL,NULL);
button(104,88,"no_on.pcx","no_off.pcx","no_ovr.pcx",quitter_switch,NULL,NULL);
button(240,0,"x_on.pcx","x_off.pcx","x_ovr.pcx",quitter_switch,NULL,NULL);
flags= LIGHT | TRANSLUCENT | OVERLAY;
}

void input()
{
diag("\n!input(() has been called!");
inkey(type_string);
}

void scroll_menu(PANEL* _pan)
{
diag("\n!scroll_menu(PANEL* _pan) has been called!");
dummy^= 1;
if(dummy== 1)
{
for(_pan.scale_y= 0.1,_pan.flags|= VISIBLE; _pan.scale_y < 0.9; _pan.scale_y+= 0.1 * time_step) wait(1);
}
else
{
for(_pan.scale_y; _pan.scale_y > 0.1; _pan.scale_y-= 0.1 * time_step) wait(1);
_pan.flags&= ~VISIBLE;
}
}

void menu(button_number)
{
diag("\n!menu(button_number) has been called!");
switch(button_number)
{
case 1:
scroll_menu(gui_dropdown1);
case 2:
scroll_menu(gui_dropdown2);
case 3:
scroll_menu(gui_dropdown3);
case 4:
scroll_menu(gui_dropdown4);
}
}

void quitter_switch()
{
diag("\n!quitter_switch() has been called!");
quitter.flags^= VISIBLE;
}

void exit_()
{
diag("\n!exit_() has been called!");
sys_exit(NULL);
}

void main()
{
diag("\n!main() has been called!");
video_mode= 8;
video_screen= 1;
vec_set(screen_color,vector(255,255,255));
mouse_map= cur;
input();
mouse_mode= 1;
while(1)
{
mouse_pos.x= mouse_cursor.x;
mouse_pos.y= mouse_cursor.y;
wait(1);
}
}




Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: crash in a simple function... [Re: MrCode] #151596
09/02/07 11:00
09/02/07 11:00
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Quote:

void drag_win(PANEL* _pan_)



try this:
Code:
 void drag_win(var _var_,PANEL* _pan_)  


I hope that will help you

Re: crash in a simple function... [Re: Lukas] #151597
09/02/07 13:28
09/02/07 13:28
Joined: Oct 2006
Posts: 873
S
Shadow969 Offline
User
Shadow969  Offline
User
S

Joined: Oct 2006
Posts: 873
i'm not sure, but i think your mistake is here

Code:
switch(button_number)
{
case 1:
scroll_menu(gui_dropdown1);
case 2:
scroll_menu(gui_dropdown2);
case 3:
scroll_menu(gui_dropdown3);
case 4:
scroll_menu(gui_dropdown4);
}


after each case you have to add break; like this

Code:
case 1:
scroll_menu(gui_dropdown1);
break;



Re: crash in a simple function... [Re: Shadow969] #151598
09/02/07 13:39
09/02/07 13:39
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline
Serious User
D3D  Offline
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
And while not explicidly needed its common to add a default case to the bottom.


smile
Re: crash in a simple function... [Re: Shadow969] #151599
09/02/07 20:38
09/02/07 20:38
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
I just tried it (the breaks), but I still only get about 40 FPS. It's all panels, and pretty small bmaps, so I don't think rendering's the problem.

EDIT: tried removing default.c from the picture; no good.

I don't understand! It was working at a full 75 FPS before! Why the sudden FPS drop?!

It's not a system-wide thing, because everything else runs just fine.

Last edited by MrCode; 09/02/07 20:42.

Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: crash in a simple function... [Re: MrCode] #151600
09/03/07 16:41
09/03/07 16:41
Joined: Mar 2007
Posts: 75
Hamburg, Ger
Altimeter Offline
Junior Member
Altimeter  Offline
Junior Member

Joined: Mar 2007
Posts: 75
Hamburg, Ger
for debugging try to replace the sophisticated scroll_menu(gui_dropdown1)function by somewhat really simple, that is indicated on your screen.
Like
int debug_value = 0;
...
switch(button_number)
{
case 1:
debug_value = 1; break;
case 2:
debug_value = 2; break;
...

And than look, if you still have frame rate problems.

Re: crash in a simple function... [Re: Altimeter] #151601
09/03/07 22:37
09/03/07 22:37
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
But the framerate drop doesn't occur only when I'm scrolling the menus, it happens on initial startup.

And the menus are using for loops, so they're only running for as long as they're moving.

I think it may have something to do with my inkey function, because I don't think it's being called (but according to my acklog.txt it is)..

EDIT: Yes, it is my inkey();. it's preventing anything after it from being called until I exit out of it. What can I do about this problem?

Here's my void main():

Code:

void main()
{
diag("\n!main() has been called!");
video_mode= 8;
video_screen= 1;
wait(3);
vec_set(screen_color,vector(255,255,255));
mouse_map= cur;
mouse_mode= 1;
inkey(type_string);
while(1)
{
mouse_pos.x= mouse_cursor.x;
mouse_pos.y= mouse_cursor.y;
wait(1);
}
}



But the inkey blocks the mouse loop from running. But I can't put it after the mouse loop, because then it will never be called.



Last edited by MrCode; 09/03/07 22:46.
Re: crash in a simple function... [Re: MrCode] #151602
09/04/07 04:57
09/04/07 04:57
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
And I can't type anything.

Anyone?

Re: crash in a simple function... [Re: MrCode] #151603
09/04/07 23:29
09/04/07 23:29
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

Just a little note
My frame rate drops when WED and SED are open at the same time.
And I run the game with WED.

Ottawa

Page 1 of 2 1 2

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