]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/client/Main.qc
Added a clientside QuakeC base by Dresk and myself. Included an example of a networke...
[divverent/nexuiz.git] / data / qcsrc / client / Main.qc
1 // --------------------------------------------------------------------------\r
2 // BEGIN REQUIRED CSQC FUNCTIONS\r
3 \r
4 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)\r
5 // Useful for precaching things\r
6 void CSQC_Init(void)\r
7 {\r
8 }\r
9 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)\r
10 void CSQC_Shutdown(void)\r
11 {\r
12 }\r
13 // CSQC_ConsoleCommand : Used to parse commands in the console that have been registered with the "registercmd" function\r
14 // Return value should be 1 if CSQC handled the command, otherwise return 0 to have the engine handle it.\r
15 float CSQC_ConsoleCommand(string strMessage)\r
16 {\r
17         local float nReturn;\r
18         local string s;\r
19         local vector v;\r
20                 nReturn = FALSE;\r
21                 \r
22         // Tokenize String\r
23         tokenize(strMessage);\r
24         \r
25         // Acquire Command\r
26         local string strCmd;\r
27                 strCmd = argv(0);\r
28 \r
29         /*\r
30         if (strCmd == "+forward")\r
31         {\r
32                 // blah\r
33                 nReturn = TRUE;\r
34         }\r
35         */\r
36         return nReturn;\r
37 }\r
38 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.\r
39 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.\r
40 // All keys are in ascii.\r
41 // bInputType = 0 is key pressed, 1 is key released, 2 is mouse input.\r
42 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.\r
43 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.\r
44 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)\r
45 {\r
46         local float bSkipKey;\r
47                 bSkipKey = false;\r
48         return bSkipKey;\r
49 }\r
50 \r
51 // END REQUIRED CSQC FUNCTIONS\r
52 // --------------------------------------------------------------------------\r
53 \r
54 // --------------------------------------------------------------------------\r
55 // BEGIN OPTIONAL CSQC FUNCTIONS\r
56 \r
57 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.\r
58 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.\r
59 void(float bIsNewEntity) CSQC_Ent_Update =\r
60 {\r
61         self.enttype = ReadByte();\r
62         /*\r
63         if (self.enttype == ENT_CLIENT)\r
64         {\r
65                 setmodelindex(self, ReadShort());\r
66                 self.origin_x = ReadCoord();\r
67                 self.origin_y = ReadCoord();\r
68                 self.origin_z = ReadCoord();\r
69                 self.angles_x = ReadCoord();\r
70                 self.angles_y = ReadCoord();\r
71                 self.angles_z = ReadCoord();\r
72                 self.sv_entnum = ReadShort();\r
73                 setorigin(self, self.origin); // relink\r
74                 if (bIsNewEntity)\r
75                 {\r
76                         setsize(self, '0 0 0', '0 0 0');\r
77                         self.drawmask = MASK_NORMAL;\r
78                         self.think = Client_Think;\r
79                         self.nextthink = time;\r
80                 }\r
81         }\r
82         else\r
83                 error("unknown entity type in CSQC_Ent_Update\n");\r
84         */\r
85 };\r
86 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed.  Essentially call remove(self) as well.\r
87 void CSQC_Ent_Remove()\r
88 {\r
89         remove(self);\r
90 }\r
91 // CSQC_Parse_StuffCmd : Provides the stuffcmd string in the first parameter that the server provided.  To execute standard behavior, simply execute localcmd with the string.\r
92 void CSQC_Parse_StuffCmd(string strMessage)\r
93 {       \r
94         localcmd(strMessage);\r
95 }\r
96 // CSQC_Parse_Print : Provides the print string in the first parameter that the server provided.  To execute standard behavior, simply execute print with the string.\r
97 void CSQC_Parse_Print(string strMessage)\r
98 {\r
99         print(strMessage);\r
100 }\r
101 // CSQC_Parse_CenterPrint : Provides the centerprint string in the first parameter that the server provided.  To execute standard behavior, simply execute cprint with the string.\r
102 void CSQC_Parse_CenterPrint(string strMessage)\r
103 {\r
104         cprint(strMessage);\r
105 }\r
106 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.\r
107 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.\r
108 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.\r
109 float CSQC_Parse_TempEntity()\r
110 {\r
111         local float bHandled;\r
112                 bHandled  = true;\r
113         // Acquire TE ID\r
114         local float nTEID;\r
115                 nTEID = ReadByte();\r
116                 \r
117         switch(nTEID)\r
118         {\r
119                 //case TE_GUNSHOT:\r
120                 //      Do something cool with TE_GUNSHOT!\r
121                 //      break;\r
122                 default:\r
123                         // No special logic for this temporary entity; return 0 so the engine can handle it\r
124                         bHandled = false;\r
125                         break;\r
126         }\r
127                 \r
128         return bHandled;\r
129 }