Forum

"Right" Way To Play CD Track

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

"Right" Way To Play CD Track

Postby Baker » Tue Jan 12, 2010 7:11 pm

Spirit said that Quoth has in the mod the ability to send to the client the "cd play xxx" command to play "cd music" [although I'm thinking MP3 or OGG, personally].

I think that's a great idea, but I'm looking for the "right" way to do it.

With DarkPlaces is there a proper way to tell the client via QuakeC to play a "cd track" or music?

The reason that the "cd play xxx" command is the wrong way in my opinion is that direct cd functionality shouldn't even accessible via a mod.

Although I think it would be hilarious for a server admin to have a mod repeatedly send "cd eject" and "cd close" to a troublesome player (LOL :D) and have his/her cd player open and close.

Basically, some commands like "cd <anything>" should be offlimits to the server and the client should ignore such commands. (ProQuake 4, for example, won't act upon a server "unbindall" keys and do that; historically jerk admins would do that people they didn't like and abuse the "profile" command which would crash a client -- referred to as "superkick" in the NQ community -- something of which LordHavoc shared to fix for a couple of years back).
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby mh » Tue Jan 12, 2010 7:22 pm

I'd assume that it does it by "stuffcmd", which is quite evil and I'd totally agree with most of what you said here (where I disagree is that I think "cd play/stop/pause" should be allowed as mods could use it to dramatic effect). I'd even go so far as saying that some cvars should be off-limits ("vid_mode", anyone?) and unless it's explicitly marked as a server cvar there should be some means of interception, and clients should be allowed the option of rejecting or accepting the change.

I'd like to see extended QC builtins to replace most of the current uses of "stuffcmd" in fact, so that mods could do these things in a safer manner and without needing to resort to brute force.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby leileilol » Tue Jan 12, 2010 7:55 pm

Quake does it by a SVC builtin actually
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Postby Baker » Tue Jan 12, 2010 8:12 pm

Ah!

Well, looks like a good case for "cd tracks" to be numbered then [since this is supported in base Q1], instead of actual music titles.

Code: Select all
      case svc_cdtrack:
         cl.cdtrack = MSG_ReadByte ();
         cl.looptrack = MSG_ReadByte ();
         if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
            CDAudio_Play ((byte)cls.forcetrack, true);
         else
            CDAudio_Play ((byte)cl.cdtrack, true);
         break;


Whatever that mysterious "looptrack" is for the 2nd byte, I'm not seeing that being used in the engine anywhere.

TextPad 5 search of q1/qw source: wrote:Searching for: looptrack
WinQuake\cl_parse.c(65): "svc_cdtrack", // [byte] track [byte] looptrack
WinQuake\cl_parse.c(930): cl.looptrack = MSG_ReadByte ();
WinQuake\client.h(224): int cdtrack, looptrack; // cd audio
WinQuake\protocol.h(128): #define svc_cdtrack 32 // [byte] track [byte] looptrack
Found 4 occurrence(s) in 3 file(s)

Searching for: cdtrack
QW\client\cl_demo.c(457): MSG_WriteByte (&buf, svc_cdtrack);
QW\client\cl_parse.c(63): "svc_cdtrack",
QW\client\cl_parse.c(1277): case svc_cdtrack:
QW\client\cl_parse.c(1278): cl.cdtrack = MSG_ReadByte ();
QW\client\cl_parse.c(1279): CDAudio_Play ((byte)cl.cdtrack, true);
QW\client\client.h(285): int cdtrack; // cd audio
QW\client\protocol.h(102): #define svc_cdtrack 32 // [byte] track
QW\progs\client.qc(194): WriteByte (MSG_ALL, SVC_CDTRACK);
QW\progs\defs.qc(341): float SVC_CDTRACK = 32;
QW\server\sv_user.c(111): MSG_WriteByte (&host_client->netchan.message, svc_cdtrack);
WinQuake\cl_parse.c(65): "svc_cdtrack", // [byte] track [byte] looptrack
WinQuake\cl_parse.c(928): case svc_cdtrack:
WinQuake\cl_parse.c(929): cl.cdtrack = MSG_ReadByte ();
WinQuake\cl_parse.c(934): CDAudio_Play ((byte)cl.cdtrack, true);
WinQuake\client.h(224): int cdtrack, looptrack; // cd audio
WinQuake\protocol.h(128): #define svc_cdtrack 32 // [byte] track [byte] looptrack
WinQuake\sv_main.c(220): MSG_WriteByte (&client->message, svc_cdtrack);
Found 17 occurrence(s) in 11 file(s)
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby Spirit » Tue Jan 12, 2010 9:17 pm

Check out the Darkplaces source for the CD stuff, it is beautiful.
Quoth has *_command entities that allow you to send commands and cvar changes (I think).
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
Spirit
 
Posts: 1031
Joined: Sat Nov 20, 2004 9:00 pm

Postby mh » Tue Jan 12, 2010 9:39 pm

From the looks of it cl.looptrack should indicate whether or not the track is to repeat forever, but yeah, I don't see cl.looptrack being used anywhere either (not even in the DOS code).

I'd guess that either the CDAudio_Play calls for svc_cdtrack should use cl.looptrack instead of true as a param and you've just discovered a bug, or else this was a feature of the game (perhaps playing monster or other sounds from CD instead of from PAK files) that got abandoned during development but was left in the protocol.

v.sounds even goes into both byte fields from the server side so it looks like the latter.

That's something interesting for mods to play around with potentially, or otherwise an unused 8 bits during server spawning that engine developers can have a party with.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Baker » Tue Jan 12, 2010 9:45 pm

mh wrote:That's something interesting for mods to play around with potentially, or otherwise an unused 8 bits during server spawning that engine developers can have a party with.


*Snort* :shock: Haha.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby mh » Tue Jan 12, 2010 9:47 pm

Baker wrote:
mh wrote:That's something interesting for mods to play around with potentially, or otherwise an unused 8 bits during server spawning that engine developers can have a party with.


*Snort* :shock: Haha.

A special prize goes to the first person who puts porn in there. :twisted:
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby metlslime » Tue Jan 12, 2010 11:07 pm

mh wrote:A special prize goes to the first person who puts porn in there. :twisted:


That would be difficult. At least with 16 bits you could put a Unicode penis symbol or something.
metlslime
 
Posts: 316
Joined: Tue Feb 05, 2008 11:03 pm

Postby Baker » Tue Jun 29, 2010 1:19 pm

mh wrote:That's something interesting for mods to play around with potentially, or otherwise an unused 8 bits during server spawning that engine developers can have a party with.


I think I may have found a good use for this extra byte. :D
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby mankrip » Tue Jun 29, 2010 2:47 pm

An obvious use for non-looping tracks is for intermission/ending audio.
mh wrote:From the looks of it cl.looptrack should indicate whether or not the track is to repeat forever, but yeah, I don't see cl.looptrack being used anywhere either (not even in the DOS code).

I can't check this at the moment, but I guess this is what I used in the "Loop" option here:
Image
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Postby Spike » Tue Jun 29, 2010 6:10 pm

looptrack isn't a true/false, its a second track to play (and loop) after the first has ended.
it was removed in quakeworld.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby Ranger366 » Tue Jun 29, 2010 7:22 pm

at my old pc, when i entered cd_eject my whole PC began to open/close it O_O
the CD player. such an LOL feature.

Anyways, the thread reminds me of one city map, truly Quake City map, in Quake (lol!) if there is one known, i would really love to know this.
User avatar
Ranger366
 
Posts: 203
Joined: Thu Mar 18, 2010 5:51 pm

Postby Spike » Tue Jun 29, 2010 9:54 pm

Back in the day I ripped out the important parts of quake's cd code and just made a prog that constantly ejected and then injected in a loop.

Killed the entire machine, well, everything but the cd tray.

Yay windows! :P

Incidentilly, does Quake still lock up briefly when using a different thread to start cd tracks?... I wonder.

But yeah, anyway, there's a faketracks extension in DP, that works either via the cd command or via the svc. faketracks are generally better than cds, as faketracks do not generally require seeking/spinning up cds.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest