Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 10/25/26 03:42
Chat Room for Zorro Programmers
by Haitao_Ren. 10/25/26 03:14
Trading Journey
by Haitao_Ren. 10/25/26 03:14
Algorithmic trading course with Zorro
by Haitao_Ren. 10/25/26 03:12
Zorro tutorial ideas?
by Haitao_Ren. 10/25/26 02:47
Zorro plugin for Hyperliquid.xyz
by mayarik. 10/24/26 09:14
Tradestation missing in table of contents
by AndrewAMD. 10/23/26 14:35
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (3run, TipmyPip, opm), 7,722 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Haitao_Ren, JimSimons, julienp, julienper, KelleyAbbey
19247 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Question(s) regarding c_trace [Re: Kartoffel] #412981
12/05/12 19:35
12/05/12 19:35
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
On a second thought: better always use c_ignore right before tracing. This will prevent hard to find errors and won't do no harm performance wise.


Always learn from history, to be sure you make the same mistakes again...
Re: Question(s) regarding c_trace [Re: Uhrwerk] #413001
12/06/12 07:28
12/06/12 07:28
Joined: Jul 2000
Posts: 28,142
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,142
Frankfurt
You can replace your c_trace calls with a specific c_trace function like "c_trace2" that includes the c_ignore call.

Re: Question(s) regarding c_trace [Re: jcl] #413017
12/06/12 14:38
12/06/12 14:38
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
okay I didn't test it, yet but this should work:
Code:
var c_trace_ent(ENTITY* trace_ent, VECTOR* from, VECTOR* to, long flags, CONTACT * _hit)
{
	var _group = trace_ent.group; // set a backup value
	
	trace_ent.group = 1;
	c_ignore(0);
	
	var _dist = c_trace(from, to, flags);
	
	if(_hit) _hit = hit; // pass hit information (if _hit exists)
	
	trace_ent.group = _group;
	
	return _dist; // return trace distance
}


Last edited by Kartoffel; 12/06/12 14:41.

POTATO-MAN saves the day! - Random
Re: Question(s) regarding c_trace [Re: Kartoffel] #413035
12/06/12 18:11
12/06/12 18:11
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You don't test if the group you are using is different from the group the entity had in the first place.
Code:
if(_hit) _hit = hit;

This won't do anything useful as _hit is lost when the method returns.
Code:
c_ignore(0);

Does not do what you intended to do I guess because it causes no group at all to be ignored.


Always learn from history, to be sure you make the same mistakes again...
Re: Question(s) regarding c_trace [Re: Uhrwerk] #413045
12/06/12 21:19
12/06/12 21:19
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Ok, so everytime I create an entity I set it's group to 1.

...and then for the tracing:
trace_ent.group = 2;
c_ignore(1, 0);

Quote:
This won't do anything useful as _hit is lost when the method returns.
what exactly do you mean with this? Why won't it work?

I've tested it like this:
Code:
var test_fnc(var * var_ptr)
{
	*var_ptr = 25;
	return *var_ptr * 2;
}

[...]

	var var_a = 0;
	var var_b = test_fnc(var_a);

after this var_a is 25 and var_b is 50.

EDIT: got it, should be *_hit = hit;

Last edited by Kartoffel; 12/06/12 21:43.

POTATO-MAN saves the day! - Random
Re: Question(s) regarding c_trace [Re: Kartoffel] #413046
12/06/12 21:28
12/06/12 21:28
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Yeah, that part should work this way.

Now you just have to spot the difference between the code in test_fnc and "if(_hit) _hit = hit;" ... tongue


Always learn from history, to be sure you make the same mistakes again...
Re: Question(s) regarding c_trace [Re: Uhrwerk] #413055
12/07/12 08:16
12/07/12 08:16
Joined: Jul 2000
Posts: 28,142
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,142
Frankfurt
In fact it's if(_hit) memcpy(_hit,hit,sizeof(CONTACT));

As to my knowledge the = operator does not copy structs in lite-C, you need memcpy for this.

Re: Question(s) regarding c_trace [Re: jcl] #413071
12/07/12 12:51
12/07/12 12:51
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Ok, good to know. Thanks!


POTATO-MAN saves the day! - Random
Page 2 of 2 1 2

Moderated by  old_bill, Tobias 

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