Gamestudio Links
Zorro Links
Newest Posts
make a complaint
by EW_bytes. 11/26/26 23:00
FXCM => AVA Trade Plugin???
by Martin_HH. 11/25/26 21:59
No connection to MT4
by Martin_HH. 11/23/26 06:38
MinMax function on History t6 file
by LucasJoshua. 11/21/26 14:28
What are you working on?
by rayp. 11/20/26 18:10
contractUpdate() is filtering if >2 rows
by mistery. 11/09/26 12:06
New Zorro version 3.15
by jcl. 11/09/26 09:24
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (EW_bytes), 15,961 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EvanTJ, rht, MaliceTheMaker, Haitao_Ren, JimSimons
19250 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 4 of 4 1 2 3 4
Re: Perfect copy of an entity [Re: EvilSOB] #328441
06/13/10 10:16
06/13/10 10:16
Joined: Sep 2009
Posts: 1,035
Budapest
Aku_Aku Offline OP
Serious User
Aku_Aku  Offline OP
Serious User

Joined: Sep 2009
Posts: 1,035
Budapest
I assume in my 32 bit environment the A7 will work with 32 bit pointers.
Unfortunately the football World Cup matches are in the tv now this days, so i don't have too much time to test. smile

Last edited by Aku_Aku; 06/13/10 10:16.
Re: Perfect copy of an entity [Re: Aku_Aku] #328442
06/13/10 10:18
06/13/10 10:18
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
A7 is 32bit, regardless of OS (at this time, and the forseeable future).

A8 may be a different story.

But Sylar is trying to make my code overly future-proof.
("overly" IMHO anyways)




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Perfect copy of an entity [Re: EvilSOB] #328474
06/13/10 13:45
06/13/10 13:45
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Originally Posted By: EvilSOB
But Sylar is trying to make my code overly future-proof.

You always should be future proof. As I said, your aren't developing for now but for a date in the future. And after the release, you will need to maintain your game. There is no reason to not work for the future.

For example the version from Heelx would work fine under any kind of bit depth, without any changes.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Perfect copy of an entity [Re: EvilSOB] #329212
06/18/10 13:45
06/18/10 13:45
Joined: Sep 2009
Posts: 1,035
Budapest
Aku_Aku Offline OP
Serious User
Aku_Aku  Offline OP
Serious User

Joined: Sep 2009
Posts: 1,035
Budapest
Hi!

I tested and tried the proposed solution.
On the one hand it makes perhaps a perfect copy. That is good and i give credit for it.
On the other hand i had to recognise, i must not use perfect copy. The reason is that, i use strings attached to the entity as skills.
The perfect copy copies all the pointers from the predecessor to the successor, and they all are same.
I have to admit, i don't need a perfect copy.
I need the perfection for only the model, but i need new, own skills for the new entity.
I want to fill the new entity's skills with new strings but i need the old entity's skill stay intact.

Re: Perfect copy of an entity [Re: Aku_Aku] #329278
06/18/10 23:48
06/18/10 23:48
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Then you need to 'copy' EACH skill that uses a string, something like this.
Skills just storing numbers are fine as is...
eg
Code:
ENTITY* ent_duplicate(ENTITY* source_ent)
{
	ENTITY* target_ent = ent_create(source_ent.type, 0, (void*)source_ent.skill99);
	memcpy(&target_ent.x, &source_ent.x, sizeof(ENTITY)-(sizeof(C_LINK)+sizeof(var)));
	//	ent_clone(target_ent);	//if required
	//duplicate strings-in-skills
	target_ent.skill10 = str_create(_chr(target_ent.skill10));
	target_ent.skill11 = str_create(_chr(target_ent.skill11));
	target_ent.skill15 = str_create(_chr(target_ent.skill15));
	target_ent.skill45 = str_create(_chr(target_ent.skill45));
	//etc
	return(target_ent);
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Perfect copy of an entity [Re: EvilSOB] #329339
06/19/10 06:49
06/19/10 06:49
Joined: Sep 2009
Posts: 1,035
Budapest
Aku_Aku Offline OP
Serious User
Aku_Aku  Offline OP
Serious User

Joined: Sep 2009
Posts: 1,035
Budapest
In my test i used this method:
Code:
target_ent.skill10 = str_create("");
str_cpy((STRING*)target_ent.skill10,(STRING*)source_ent.skill10);


That gave an empty string in both entities.
I assume the reason is the first assign with the "" value.
I guess when want to change the target string, the source will be changed paralell with that.
I stopped this study, and i do the process simply with create the new entity and manually copy everything.

Last edited by Aku_Aku; 06/19/10 06:50.
Re: Perfect copy of an entity [Re: Aku_Aku] #329343
06/19/10 08:54
06/19/10 08:54
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
No, that makes no sense. There must be a bug elsewhere clearing the source entity string.

target_ent.skill10 = str_create(""); will have NO affect on source_ent.skill10
There is no ambiguity in this. It is certain, I am 110% certain.
Whatever was in skill10 is replaced with a pointer to the new string,
it doesnt change the old string at all...
And so cant afect source_ent.skill10 in any way...

Are you sure there is not a typo somewhere?


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Perfect copy of an entity [Re: EvilSOB] #329347
06/19/10 10:35
06/19/10 10:35
Joined: Sep 2009
Posts: 1,035
Budapest
Aku_Aku Offline OP
Serious User
Aku_Aku  Offline OP
Serious User

Joined: Sep 2009
Posts: 1,035
Budapest
Code:
target_ent.skill10 = str_create("");  will have NO affect on source_ent.skill10


I tested, and it cleared the predecessors string.
Please try it.

Re: Perfect copy of an entity [Re: Aku_Aku] #329356
06/19/10 11:20
06/19/10 11:20
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Heres a complete stand-alone script to prove my point...

Click to reveal..
Code:
#include <litec.h>
#include <default.c>


ENTITY* ent_duplicate(ENTITY* source_ent)
{
	ENTITY* target_ent = ent_create(source_ent.type, 0, (void*)source_ent.skill99);
	memcpy(&target_ent.x, &source_ent.x, sizeof(ENTITY)-(sizeof(C_LINK)+sizeof(var)));
	//	ent_clone(target_ent);	//if required
	return(target_ent);
}


action rotater()
{
	my.skill99 = (void*)rotater;
	while(1)
	{
		my.pan += time_step * 5;
		wait(1);
	}
}



function main()
{
	wait(5);	level_load(NULL);		wait(5);		camera.x = -130;
	//

	me = ent_create(CUBE_MDL, vector(0,50,0), rotater);
	me.skill10 = str_create("testing");
	wait(2);
	printf("source.skill10 = \'%s\'",	_chr((STRING*)my.skill10));
	

	wait(-2);
	you = ent_duplicate(me);		you.y = -50;
	wait(2);
	printf("cloned.skill10 = \'%s\'",	_chr((STRING*)you.skill10));


	
	wait(-2);
	you.skill10 = str_create("something new");
	printf("cloned.skill10 reset to = \'%s\'",	_chr((STRING*)you.skill10));


	wait(2);
	printf("source.skill10 still = \'%s\'",	_chr((STRING*)me.skill10));


}


If this doesnt work for you, then what A7 version are you using?
We may have found a bug... (Im using Commercial 7.85.4)


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 4 of 4 1 2 3 4

Gamestudio download | 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