|
1 registered members (EW_bytes),
15,961
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
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
OP
Serious User
|
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.
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
Expert
|
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
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
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: Aku_Aku]
#329278
06/18/10 23:48
06/18/10 23:48
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
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
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
OP
Serious User
|
OP
Serious User
Joined: Sep 2009
Posts: 1,035
Budapest
|
In my test i used this method:
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
Expert
|
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
OP
Serious User
|
OP
Serious User
Joined: Sep 2009
Posts: 1,035
Budapest
|
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
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Heres a complete stand-alone script to prove my point...
#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
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|