|
3 registered members (3run, TipmyPip, opm),
7,722
guests, and 1
spider. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
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
Expert
|
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: jcl]
#413017
12/06/12 14:38
12/06/12 14:38
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
okay I didn't test it, yet but this should work:
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
Expert
|
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. This won't do anything useful as _hit is lost when the method returns. 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
OP
Expert
|
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); 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:
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
Expert
|
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;" ... 
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|