.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...

Forum Thread
  Posts  
darkplaces extensions - callfunction (Groups : qc : Forum : vault() : darkplaces extensions - callfunction) Locked
Thread Options
numbersix
numbersix quake-c coder++
Jan 13 2016 Anchor

This is an interesting quake-c extension:

void(string s) callfunction = #605;
float(string s) isfunction = #607;

"callfunction" causes the engine to call the function indicated by the passed parameter.
So, why do you need isfunction?

It seems that function better exist:

sv_cmd test
Host_Error: VM_callfunciton: function test not found !
QuakeC crash report for server:
s6766: STORE_F    IMMEDIATE (=* GameCommand - called with: ), GLOBAL4
s6767: CALL1      bprint (=bprint())
s6768: STORE_F    s (=test), GLOBAL4
s6769: CALL1      bprint (=bprint())
s6770: STORE_F    IMMEDIATE (=
), GLOBAL4
s6771: CALL1      bprint (=bprint())
s6772: STORE_F    s (=test), GLOBAL4
s6773: CALL1      callfunction (=callfunction())
frikbot/_code.qc : GameCommand : statement 7
Host_ShutdownServer
Client "_-=*[ Z ]" dropped
CL_Disconnect
CSQC unloaded
Sending clc_disconnect

so:

	if (isfunction(s)) callfunction(s);

This has many possibilities, including remote server admin with "rcon sv_cmd {function}", custom map design, csqc operation, etc.


I have decided to fix that in the engine port.
When a map has an invalid classname no crash happens.

This can be bulletproofed. Fixed.
Now a warning is issued if cvar( sv_prvm_warn ) is non zero.
I'll have a look to see if any other PRVM_ERROR instance can have this fix.

Edited by: numbersix

Feb 11 2016 Anchor

Kool that you are modding the DP eng, I always wanted to get into that. Apparently there is a svn on the homepage where you can collaborate with the rest of the devs and possibly they may include the changes on an autobuild. Apparently there is a new autobuild made every 6 hours.


But on this isfunction built in , I have not tried it, but I thought the checkextension function was suppose do basicly do the same thing?


For example, the sound () built in in older DP engines does not have the capability to pitch the sound like newer versions past a certain build - Im not sure what the build exactly is , it may be Nov 2011. But lets say you join a server thats pitching the sound for when the rocket launches, and the clients connected have older DP engines, they will crash with an illegible server message once the sound is played.

So as a fix I tried this:

qsg_allowed = cvar ("pr_checkextension");
	if (qsg_allowed)
	{
		TQ_RAILTRAIL = checkextension ("TQ_RAILTRAIL");
		 
		 if (checkextension("DP_SND_SOUND7_WIP1") || checkextension("DP_SND_SOUND7_WIP1"))
		 DP_SND7 = 1;
	}



However it does not work, and since server is ssqc, its not known if we are checking against all connected clients or just the engine running as the server.

Basicly the sound function itself as the built in has the same #8 as regular sound (), but with more arguements. Its also got "WIP" prefix which means work in progress, so I suppose its intentionally unfixed for the time being. But this is a good reason why doing the svn thing might be interesting, collaborating and improving with some more experienced engine coders, is much needed for DP.

But anyhow , could this issue be addressed with isfunction?

//DP_SND_SOUND7_WIP1
//DP_SND_SOUND7_WIP2
//idea: divVerent
//darkplaces implementation: divVerent
//builtin definitions:
void(entity e, float chan, string samp, float vol, float atten, float speed, float flags) sound7 = #8;
float SOUNDFLAG_RELIABLE = 1;
//description:
//plays a sound, with some more flags
//extensions to sound():
//- channel may be in the range from -128 to 127; channels -128 to 0 are "auto",
//  i.e. support multiple sounds at once, but cannot be stopped/restarted
//- a value 0 in the speed parameter means no change; otherwise, it is a
//  percentage of playback speed ("pitch shifting"). 100 is normal pitch, 50 is
//  half speed, 200 is double speed, etc. (DP_SND_SOUND7_WIP2)
//- the flag SOUNDFLAG_RELIABLE can be specified, which makes the sound send
//  to MSG_ALL (reliable) instead of MSG_BROADCAST (unreliable, default);
//  similarily, SOUNDFLAG_RELIABLE_TO_ONE sends to MSG_ONE
//- channel 0 is controlled by snd_channel0volume; channel 1 and -1 by
//  snd_channel1volume, etc. (so, a channel shares the cvar with its respective
//  auto-channel); however, the mod MUST define snd_channel8volume and upwards
//  in default.cfg if they are to be used, as the engine does not create them
//  to not litter the cvar list
//- this extension applies to CSQC as well; CSQC_Event_Sound will get speed and
//  flags as extra 7th and 8th argument
//- WIP2 ideas: SOUNDFLAG_RELIABLE_TO_ONE, SOUNDFLAG_NOPHS, SOUNDFLAG_FORCELOOP
//- NOTE: to check for this, ALSO OR a check with DP_SND_SOUND7 to also support
//  the finished extension once done



numbersix
numbersix quake-c coder++
Feb 11 2016 Anchor

I checked callfunction. Turns out I fixed it:

        if(!func)
        {
                if (sv_prvm_warn.integer)
                        VM_Warning("VM_callfunciton: function %s not found !", s);
                else
                        PRVM_ERROR("VM_callfunciton: function %s not found !", s);
        }

If "sv_prvm_warn" is true - it only issues a warning. That also stops another fail.
So I removed the isfunction test and saved the bytes. Also put sv_prvm_warn 1 in the default cfg.

I really need to do an atari 2600 game or something. Maybe c64, I know a lot more about that system.

>checkextension function was suppose do basicly do the same thing?

isfunction checks a text string to see if it corresponds to any qc function. callfunction calls it, but you cant use parms.
I dont know how it would treat a builtin function. Seeing that builtin is declared as a qc function, it should report true.

Server cant tell much about clients outside of the usual network comms.
The best answer is likely to ask (or force) all clients to run the dp you desire.
I'd bet you could put something in csqc to fix this.
Either block the call, wrap it in the old sound - dropping the extra parms, or
disconnect and request they update their client.

Technically I'm not modding dp, but a gpl port.
Getting no response from Lordhavok, I decided a port was a better idea.

Edited by: numbersix

--

\|/
-*- Support free code: Patreon.com
/|\

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.