Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Akow, degenerate_762), 1,430 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 4
Page 5 of 6 1 2 3 4 5 6
Re: GSVector [Re: pegamode] #261512
04/18/09 07:22
04/18/09 07:22
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
That would be very nice smile
You can just add new function, so your new version would compatible with old one.

Anyway, if vector works good for you, can you show, how to incriment pointer on vector's position?


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: GSVector [Re: VeT] #261869
04/20/09 19:46
04/20/09 19:46
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Sorry, I didn't find the time for the new version yet (but it will come).

But, I can show you how I would increment a counter variable:

Code:
        var test = createGSVector();
	
	insertIntoGSVector(test, 0);
	insertIntoGSVector(test, 1);
	insertIntoGSVector(test, 2);
	insertIntoGSVector(test, 3);
	insertIntoGSVector(test, 4);
	
	int i = 0;
	
	diag("\ngetFromGSVector:");
	diag(str_for_num(NULL,getFromGSVector(test,(int*)i)));
	i++;
	diag("\ngetFromGSVector:");
	diag(str_for_num(NULL,getFromGSVector(test,(int*)i)));
	i++;
	diag("\ngetFromGSVector:");
	diag(str_for_num(NULL,getFromGSVector(test,(int*)i)));
	i++;
	diag("\ngetFromGSVector:");
	diag(str_for_num(NULL,getFromGSVector(test,(int*)i)));
	i++;
	diag("\ngetFromGSVector:");
	diag(str_for_num(NULL,getFromGSVector(test,(int*)i)));


Regards,
Pegamode.

Re: GSVector [Re: pegamode] #261871
04/20/09 19:59
04/20/09 19:59
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
Ahh... really ^^
Thank you, looking like this may work, tomorrow i'd check it smile


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: GSVector [Re: VeT] #261983
04/21/09 13:07
04/21/09 13:07
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
i'm gonna crazy...

Code:
for(num=0; num<sizeOfGSVector(vPlayers); num++) {			
		tempChar = (CHARACTER*)(getFromGSVector(vPlayers,(int*)num));
		
		diag("\n[!!!] CHARACTER:");
		diag_var(" n: %6.3f",num);
		diag_var(" s: %6.3f",tempChar.s);
		diag_var(" i: %6.3f",tempChar.i);
		diag_var(" j: %6.3f",tempChar.j);		
	}


return
[!!!] CHARACTER: n: 0.000 s: 1.000 i: 5.000 j: 5.000
[!!!] CHARACTER: n: 1.000 s: 1.000 i: 5.000 j: 5.000

but the second string must be n: 1.000 s: 1.000 i: 4.000 j: 2.000


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: GSVector [Re: VeT] #261989
04/21/09 13:30
04/21/09 13:30
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
It's hard to comment your code as you just posted the get-part, but not where the values are set.

It would be more helpful if you could post a code that could be run standalone.

Regards,
Pegamode.

Re: GSVector [Re: VeT] #261992
04/21/09 13:45
04/21/09 13:45
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
looking like it works smile
While filling array, you may use

correct
Code:
vPlayers = createGSVector();
	
	var i;
	for (i=0; i<players_number; i++)
	{
		CHARACTER* tempChar = (CHARACTER*)malloc(sizeof(CHARACTER));
		
		tempChar.s = file_var_read(fhandle);
		tempChar.i = file_var_read(fhandle);
		tempChar.j = file_var_read(fhandle);
		
		tempChar.step_max = file_var_read(fhandle);
		tempChar.step_left = file_var_read(fhandle);
		
		insertIntoGSVector(vPlayers,tempChar);
	}


but not
wrong
Code:
vPlayers = createGSVector();
	
	var i;
CHARACTER* tempChar = (CHARACTER*)malloc(sizeof(CHARACTER));
	for (i=0; i<players_number; i++)
	{		
		tempChar.s = file_var_read(fhandle);
		tempChar.i = file_var_read(fhandle);
		tempChar.j = file_var_read(fhandle);
		
		tempChar.step_max = file_var_read(fhandle);
		tempChar.step_left = file_var_read(fhandle);
		
		insertIntoGSVector(vPlayers,tempChar);
	}



1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: GSVector [Re: pegamode] #261993
04/21/09 13:47
04/21/09 13:47
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi VeT,

my current guess is that your mistake is not when reading from the vector, but when creating your struct objects.

Some posts before you posted the following code:

Code:
players_number = file_var_read(fhandle);

vPlayers = createGSVector();
CHARACTER* tempChar = (CHARACTER*)malloc(sizeof(CHARACTER));
	
var i;
for (i=0; i<players_number; i++)
{
	tempChar.s = file_var_read(fhandle);
	tempChar.i = file_var_read(fhandle);
	tempChar.j = file_var_read(fhandle);
		
	tempChar.step_max = file_var_read(fhandle);
	tempChar.step_left = file_var_read(fhandle);
		
	insertIntoGSVector(vPlayers,tempChar);
}


You can't do it that way, because you have to create an object for each player.
So you have to move the malloc into the loop ... this way:

Code:
players_number = file_var_read(fhandle);

vPlayers = createGSVector();
	
var i;
for (i=0; i<players_number; i++)
{
        CHARACTER* tempChar = (CHARACTER*)malloc(sizeof(CHARACTER));
	tempChar.s = file_var_read(fhandle);
	tempChar.i = file_var_read(fhandle);
	tempChar.j = file_var_read(fhandle);
		
	tempChar.step_max = file_var_read(fhandle);
	tempChar.step_left = file_var_read(fhandle);
		
	insertIntoGSVector(vPlayers,tempChar);
}


Regards,
Pegamode

Re: GSVector [Re: VeT] #261994
04/21/09 13:47
04/21/09 13:47
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
//It would be more helpful if you could post a code that could be run standalone.

Yes, i just made in this way
Thanks, now i update project, hope this is the last problem smile


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: GSVector [Re: VeT] #261995
04/21/09 13:48
04/21/09 13:48
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
laugh laugh laugh Thats it smile


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: GSVector [Re: pegamode] #261996
04/21/09 13:49
04/21/09 13:49
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Ok ... it seems like we wrote our posts sametime.

So, I was right with my guess.

It's quite sure that you have to create an object for each player.

Page 5 of 6 1 2 3 4 5 6

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