Comment: | Convert player into a class |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
5b7b7d2fc5af4d512db195c4fbfb2aff |
User & Date: | js on 2025-03-24 22:14:24 |
Other Links: | manifest | tags |
2025-03-25
| ||
23:03 | Add forgotten files check-in: 489bb6c39a user: js tags: trunk | |
2025-03-24
| ||
22:14 | Convert player into a class check-in: 5b7b7d2fc5 user: js tags: trunk | |
21:11 | Work around conflicting declaration of gamma check-in: 7c3936be15 user: js tags: trunk | |
Modified src/Cube.m from [3b4164e066] to [8c59576626].
1 2 3 4 5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 | - + | // main.cpp: initialisation & main loop #include "cube.h" #import "Command.h" |
︙ | |||
211 212 213 214 215 216 217 218 219 220 221 222 223 224 | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | + + | } OFDate *past = [OFDate date]; int ignore = 5; for (;;) { @autoreleasepool { [OFRunLoop.mainRunLoop runUntilDate:past]; Player *player1 = Player.player1; int millis = SDL_GetTicks() * gamespeed / 100; if (millis - lastmillis > 200) lastmillis = millis - 200; else if (millis - lastmillis < 1) lastmillis = millis - 1; if (millis - lastmillis < minmillis) |
︙ |
Modified src/DynamicEntity.h from [39b63673d9] to [b25cdd250b].
︙ | |||
17 18 19 20 21 22 23 | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | - - - - + | // see input code @property (nonatomic) bool k_left, k_right, k_up, k_down; // used for fake gravity @property (nonatomic) int timeInAir; // bounding box size @property (nonatomic) float radius, eyeHeight, aboveEye; @property (nonatomic) int lastUpdate, lag, ping; |
︙ |
Modified src/DynamicEntity.m from [03f91e70ff] to [7a1598ea36].
1 2 3 4 5 6 7 8 9 10 11 12 | 1 2 3 4 5 6 7 8 9 10 11 12 13 | + | #import "DynamicEntity.h" #include "cube.h" #import "Monster.h" #import "Player.h" struct dynent { OFVector3D origin, velocity; float yaw, pitch, roll; float maxSpeed; bool outsideMap; bool inWater; |
︙ | |||
54 55 56 57 58 59 60 | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | - + | _yaw = 270; _maxSpeed = 22; _radius = 1.1f; _eyeHeight = 3.2f; _aboveEye = 0.7f; _lastUpdate = lastmillis; |
︙ | |||
94 95 96 97 98 99 100 | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | - - - | copy->_timeInAir = _timeInAir; copy->_radius = _radius; copy->_eyeHeight = _eyeHeight; copy->_aboveEye = _aboveEye; copy->_lastUpdate = _lastUpdate; copy->_lag = _lag; copy->_ping = _ping; |
︙ | |||
146 147 148 149 150 151 152 | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | - - + + + + + + + + + + + + + - - - - - - | .timeInAir = _timeInAir, .radius = _radius, .eyeHeight = _eyeHeight, .aboveEye = _aboveEye, .lastUpdate = _lastUpdate, .lag = _lag, .ping = _ping, |
︙ | |||
213 214 215 216 217 218 219 | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | - - + + + + + + + + + + - - - | _timeInAir = d.timeInAir; _radius = d.radius; _eyeHeight = d.eyeHeight; _aboveEye = d.aboveEye; _lastUpdate = d.lastUpdate; _lag = d.lag; _ping = d.ping; |
︙ |
Modified src/Monster.m from [9674185459] to [0a9cae30d2].
1 2 3 4 5 6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | - + | // monster.cpp: implements AI for single player monsters, currently client only #import "Monster.h" #include "cube.h" |
︙ | |||
97 98 99 100 101 102 103 | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | - + | if (state != M_SLEEP) spawnplayer(self); self.trigger = lastmillis + trigger; self.targetYaw = self.yaw = (float)yaw; self.move = move; |
︙ | |||
252 253 254 255 256 257 258 | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | - + | self.yaw -= 360.0f; } // main AI thinking routine, called every frame for every monster - (void)performAction { if (self.enemy.state == CS_DEAD) { |
︙ | |||
413 414 415 416 417 418 419 | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | - + | n:monstertypes[self.monsterType].pain r:200]; if ((self.health -= damage) <= 0) { self.state = CS_DEAD; self.lastAction = lastmillis; numkilled++; |
︙ |
Modified src/clientextras.m from [b510debdf2] to [44fbd161d9].
1 2 3 4 5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | - + | // clientextras.cpp: stuff that didn't fit in client.cpp or clientgame.cpp :) #include "cube.h" #import "Command.h" |
︙ | |||
86 87 88 89 90 91 92 | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | - + - - + + | void renderclients() { [players enumerateObjectsUsingBlock:^(id player, size_t i, bool *stop) { if (player != [OFNull null] && (!demoplayback || i != democlientnum)) renderclient(player, |
︙ | |||
127 128 129 130 131 132 133 | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | - - + + | } #define maxTeams 4 static OFString *teamName[maxTeams]; static int teamScore[maxTeams]; static size_t teamsUsed; |
︙ | |||
151 152 153 154 155 156 157 | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | - - - + + + - - + + - + | void renderscores() { if (!scoreson) return; [scoreLines removeAllObjects]; if (!demoplayback) |
︙ |
Modified src/clientgame.m from [12fef2cf63] to [d1273c7a21].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | + - - - + - - + | // clientgame.cpp: core game related stuff #include "cube.h" #import "Command.h" #import "DynamicEntity.h" #import "Entity.h" #import "Monster.h" #import "OFString+Cube.h" #import "Player.h" int nextmode = 0; // nextmode becomes gamemode after next map load VAR(gamemode, 1, 0, 0); COMMAND(mode, ARG_1INT, ^(int n) { addmsg(1, 2, SV_GAMEMODE, nextmode = n); }) bool intermission = false; |
︙ | |||
78 79 80 81 82 83 84 | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | - + - + + - - - + + + - - - - - + + + + + - - - - - + + + + + - - + + | int alive = 0, dead = 0; OFString *lastteam = nil; bool oneteam = true; for (id player in players) if (player != [OFNull null]) arenacount( player, &alive, &dead, &lastteam, &oneteam); |
︙ | |||
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | + + + | } physicsframe(); checkquad(curtime); if (m_arena) arenarespawn(); moveprojectiles((float)curtime); demoplaybackstep(); Player *player1 = Player.player1; if (!demoplayback) { if (getclientnum() >= 0) // only shoot when connected to server shoot(player1, worldpos); // do this first, so we have most accurate information // when our player moves gets2c(); } otherplayers(); if (!demoplayback) { [Monster thinkAll]; if (player1.state == CS_DEAD) { if (lastmillis - player1.lastAction < 2000) { player1.move = player1.strafe = 0; moveplayer(player1, 10, false); } else if (!m_arena && !m_sp && lastmillis - player1.lastAction > 10000) respawn(); } else if (!intermission) { moveplayer(player1, 20, true); checkitems(); } // do this last, to reduce the effective frame lag c2sinfo(player1); } } lastmillis = millis; } |
︙ | |||
209 210 211 212 213 214 215 | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | - + | } int spawncycle = -1; int fixspawn = 2; // place at random spawn. also used by monsters! void |
︙ | |||
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | + - + - + + + + - - + + - + | d.state = CS_ALIVE; } // movement input code #define dir(name, v, d, s, os) \ COMMAND(name, ARG_DOWN, ^(bool isDown) { \ Player *player1 = Player.player1; \ player1.s = isDown; \ player1.v = isDown ? d : (player1.os ? -(d) : 0); \ player1.lastMove = lastmillis; \ }) dir(backward, move, -1, k_down, k_up); dir(forward, move, 1, k_up, k_down); dir(left, strafe, 1, k_left, k_right); dir(right, strafe, -1, k_right, k_left); COMMAND(attack, ARG_DOWN, ^(bool on) { if (intermission) return; if (editmode) editdrag(on); |
︙ | |||
347 348 349 350 351 352 353 | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | - + - + - + | } void timeupdate(int timeremain) { if (!timeremain) { intermission = true; |
︙ | |||
404 405 406 407 408 409 410 | 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | - - + + | gamemode = 0; conoutf(@"coop sp not supported yet"); } sleepwait = 0; [Monster resetAll]; projreset(); spawncycle = -1; |
︙ |
Modified src/clients.m from [d14310e680] to [b2ad70bf79].
1 2 3 4 5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 | - + | // client.cpp, mostly network related client game code #include "cube.h" #import "Command.h" |
︙ | |||
65 66 67 68 69 70 71 | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | - + - + - - + + | newname(OFString *name) { c2sinit = false; if (name.length > 16) name = [name substringToIndex:16]; |
︙ | |||
145 146 147 148 149 150 151 | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | - + | conoutf(@"disconnected"); clienthost = NULL; connecting = 0; connattempts = 0; disconnecting = 0; clientnum = -1; c2sinit = false; |
︙ | |||
176 177 178 179 180 181 182 | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | - + | disconnect(0, !disconnecting); } static OFString *ctext; void toserver(OFString *text) { |
︙ | |||
277 278 279 280 281 282 283 | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | - + | enet_host_flush(clienthost); } else localclienttoserver((ENetPacket *)packet); } // send update to the server void |
︙ | |||
338 339 340 341 342 343 344 | 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | - - - + + + | ctext = @""; } // tell other clients who I am if (!c2sinit) { packet->flags = ENET_PACKET_FLAG_RELIABLE; c2sinit = true; putint(&p, SV_INITC2S); |
︙ |
Modified src/clients2c.m from [be4039eb8e] to [ffe8228e75].
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | + | // client processing of the incoming network stream #include "cube.h" #import "DynamicEntity.h" #import "Entity.h" #import "Player.h" extern int clientnum; extern bool c2sinit, senditemstoserver; extern OFString *toservermap; extern OFString *clientpassword; void |
︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | + | // update the position of other clients in the game in our world // don't care if he's in the scenery or other players, // just don't overlap with our client void updatepos(DynamicEntity *d) { Player *player1 = Player.player1; const float r = player1.radius + d.radius; const float dx = player1.origin.x - d.origin.x; const float dy = player1.origin.y - d.origin.y; const float dz = player1.origin.z - d.origin.z; const float rz = player1.aboveEye + d.eyeHeight; const float fx = (float)fabs(dx), fy = (float)fabs(dy), fz = (float)fabs(dz); |
︙ | |||
178 179 180 181 182 183 184 185 | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | + - + - + - + - + - - + + | getalias(nextmapalias); // look up map in the cycle changemap(map != nil ? map : getclientmap()); break; } // another client either connected or changed name/team case SV_INITC2S: { Player *d_ = (Player *)d; sgetstr(); |
︙ | |||
227 228 229 230 231 232 233 | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | - + + - + - + - + - + - - + + - + - + - + | } case SV_DAMAGE: { int target = getint(&p); int damage = getint(&p); int ls = getint(&p); if (target == clientnum) { |
︙ | |||
291 292 293 294 295 296 297 | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | - + | OFVector3D v = OFMakeVector3D(ents[i].x, ents[i].y, ents[i].z); playsound(S_ITEMSPAWN, &v); break; } // server acknowledges that I picked up this item case SV_ITEMACC: |
︙ | |||
357 358 359 360 361 362 363 | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | - - + + | case SV_PING: getint(&p); break; case SV_PONG: addmsg(0, 2, SV_CLIENTPING, |
︙ |
Modified src/cube.h from [9e15fb9815] to [40ed8384d1].
1 2 3 4 5 6 7 8 9 10 11 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + - + | // one big bad include file for the whole engine... nasty! #import <ObjFW/ObjFW.h> #include <SDL2/SDL.h> #include "tools.h" #define _MAXDEFSTR 260 @class DynamicEntity; @class Entity; |
︙ | |||
252 253 254 255 256 257 258 | 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | - - | extern "C" { #endif // map data, the mips are sequential 2D arrays in memory extern struct sqr *world, *wmip[]; extern struct header hdr; // current map header extern int sfactor, ssize; // ssize = 2^sfactor extern int cubicsize, mipsize; // cubicsize = ssize^2 |
︙ |
Modified src/editing.m from [696569b661] to [7c6be4eed6].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | + | // editing.cpp: most map editing commands go here, entity editing commands are // in world.cpp #include "cube.h" #import "Command.h" #import "DynamicEntity.h" #import "Monster.h" #import "OFString+Cube.h" #import "Player.h" bool editmode = false; // the current selection, used by almost all editing commands // invariant: all code assumes that these are kept inside MINBORD distance of // the edge of the map |
︙ | |||
54 55 56 57 58 59 60 61 62 63 64 65 66 67 | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | + | static struct sqr rtex; VAR(editing, 0, 0, 1); void toggleedit() { Player *player1 = Player.player1; if (player1.state == CS_DEAD) return; // do not allow dead players to edit to avoid state // confusion if (!editmode && !allowedittoggle()) return; // not in most multiplayer modes if (!(editmode = !editmode)) { settagareas(); // reset triggers to allow quick playtesting |
︙ | |||
153 154 155 156 157 158 159 160 161 162 163 164 165 166 | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | + | ? (s->type == FHF ? s->floor - t->vdelta / 4.0f : (float)s->floor) : (s->type == CHF ? s->ceil + t->vdelta / 4.0f : (float)s->ceil); } void cursorupdate() // called every frame from hud { Player *player1 = Player.player1; flrceil = ((int)(player1.pitch >= 0)) * 2; volatile float x = worldpos.x; // volatile needed to prevent msvc7 optimizer bug? volatile float y = worldpos.y; volatile float z = worldpos.z; |
︙ | |||
622 623 624 625 626 627 628 | 625 626 627 628 629 630 631 632 633 634 635 | - + | loopselxy(s->tag = tag); }) COMMAND(newent, ARG_5STR, ^(OFString *what, OFString *a1, OFString *a2, OFString *a3, OFString *a4) { EDITSEL; |
Modified src/entities.m from [fe7c9a5680] to [e376d54115].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | + | // entities.cpp: map entity related functions (pickup etc.) #include "cube.h" #import "DynamicEntity.h" #import "Entity.h" #import "MapModelInfo.h" #import "Player.h" OFMutableArray<Entity *> *ents; static OFString *entmdlnames[] = { @"shells", @"bullets", @"rockets", |
︙ | |||
124 125 126 127 128 129 130 | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | - + - + | { 150, 150, S_ITEMARMOUR }, { 20000, 30000, S_ITEMPUP }, }; void baseammo(int gun) { |
︙ | |||
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | + + + | case JUMPPAD: { static int lastjumppad = 0; if (lastmillis - lastjumppad < 300) break; lastjumppad = lastmillis; OFVector3D v = OFMakeVector3D((int)(char)ents[n].attr3 / 10.0f, (int)(char)ents[n].attr2 / 10.0f, ents[n].attr1 / 10.0f); Player *player1 = Player.player1; player1.velocity = OFAddVectors3D( OFMakeVector3D(player1.velocity.x, player1.velocity.y, 0), v); playsoundc(S_JUMPPAD); break; } } } void checkitems() { Player *player1 = Player.player1; if (editmode) return; [ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) { if (e.type == NOTUSED) return; |
︙ | |||
327 328 329 330 331 332 333 334 335 336 337 338 339 340 | 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | + + | pickup(i, player1); }]; } void checkquad(int time) { Player *player1 = Player.player1; if (player1.quadMillis && (player1.quadMillis -= time) < 0) { player1.quadMillis = 0; playsoundc(S_PUPOUT); conoutf(@"quad damage is over"); } } |
︙ |
Modified src/menus.m from [d14babe2b3] to [c38d6c5a56].
1 2 3 4 5 6 7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | - + - + | // menus.cpp: ingame menu system (also used for scores and serverlist) #include "cube.h" #import "Menu.h" #import "Command.h" |
︙ |
Modified src/meson.build from [7b26dc3ecb] to [427dbc46b4].
︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | + | 'KeyMapping.m', 'MD2.m', 'MapModelInfo.m', 'Menu.m', 'MenuItem.m', 'Monster.m', 'OFString+Cube.m', 'Player.m', 'Projectile.m', 'ResolverResult.m', 'ResolverThread.m', 'ServerEntity.m', 'ServerInfo.m', 'Variable.m', 'clients.m', |
︙ |
Modified src/physics.m from [5a011dd2ea] to [7410504650].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + | // physics.cpp: no physics books were hurt nor consulted in the construction of // this code. All physics computations and constants were invented on the fly // and simply tweaked until they "felt right", and have no basis in reality. // Collision detection is simplistic but very robust (uses discrete steps at // fixed fps). #include "cube.h" #import "DynamicEntity.h" #import "Entity.h" #import "MapModelInfo.h" #import "Monster.h" #import "Player.h" // collide with player or monster static bool plcollide( DynamicEntity *d, DynamicEntity *o, float *headspace, float *hi, float *lo) { if (o.state != CS_ALIVE) |
︙ | |||
175 176 177 178 179 180 181 | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | - - + + | for (id player in players) { if (player == [OFNull null] || player == d) continue; if (!plcollide(d, player, &headspace, &hi, &lo)) return false; } |
︙ |
Modified src/protos.h from [e6df6c1853] to [056cf22e2e].
︙ | |||
78 79 80 81 82 83 84 | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | - + - + | extern void disconnect(bool onlyclean, bool async); extern void toserver(OFString *text); extern void addmsg(int rel, int num, int type, ...); extern bool multiplayer(); extern bool allowedittoggle(); extern void sendpackettoserv(void *packet); extern void gets2c(); |
︙ | |||
251 252 253 254 255 256 257 | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | - + | // entities extern void initEntities(); extern void renderents(); extern void putitems(unsigned char **p); extern void checkquad(int time); extern void checkitems(); |
Modified src/renderextras.m from [ace19c9caa] to [429e6fcead].
1 2 3 4 5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | - + | // renderextras.cpp: misc gl render code and the HUD #include "cube.h" #import "Command.h" |
︙ | |||
323 324 325 326 327 328 329 330 331 332 333 334 335 336 | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | + + | VAR(hidestats, 0, 0, 1); VARP(crosshairfx, 0, 1, 1); void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater) { Player *player1 = Player.player1; readmatrices(); if (editmode) { if (cursordepth == 1.0f) worldpos = player1.origin; glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); cursorupdate(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); |
︙ |
Modified src/rendergl.m from [27faa2c25f] to [6b51df5263].
1 2 3 4 5 6 7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | - + | // rendergl.cpp: core opengl rendering stuff #define gamma math_gamma #include "cube.h" #import "Command.h" |
︙ | |||
341 342 343 344 345 346 347 348 349 350 351 352 353 354 | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | + + | conoutf(@"sdl: %s", SDL_GetError()); } }) void transplayer() { Player *player1 = Player.player1; glLoadIdentity(); glRotated(player1.roll, 0.0, 0.0, 1.0); glRotated(player1.pitch, -1.0, 0.0, 0.0); glRotated(player1.yaw, 0.0, 1.0, 0.0); glTranslated(-player1.origin.x, |
︙ | |||
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | + + + + | OFString *hudgunnames[] = { @"hudguns/fist", @"hudguns/shotg", @"hudguns/chaing", @"hudguns/rocket", @"hudguns/rifle" }; void drawhudmodel(int start, int end, float speed, int base) { Player *player1 = Player.player1; rendermodel(hudgunnames[player1.gunSelect], start, end, 0, 1.0f, OFMakeVector3D( player1.origin.x, player1.origin.z, player1.origin.y), player1.yaw + 90, player1.pitch, false, 1.0f, speed, 0, base); } void drawhudgun(float fovy, float aspect, int farplane) { Player *player1 = Player.player1; if (!hudgun /*|| !player1.gunSelect*/) return; glEnable(GL_CULL_FACE); glMatrixMode(GL_PROJECTION); glLoadIdentity(); |
︙ | |||
406 407 408 409 410 411 412 413 414 415 416 417 418 419 | 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | + | glDisable(GL_CULL_FACE); } void gl_drawframe(int w, int h, float curfps) { Player *player1 = Player.player1; float hf = hdr.waterlevel - 0.3f; float fovy = (float)fov * h / w; float aspect = w / (float)h; bool underwater = (player1.origin.z < hf); glFogi(GL_FOG_START, (fog + 64) / 8); glFogi(GL_FOG_END, fog); |
︙ |
Modified src/rendermd2.m from [7b42d00ad3] to [c6c4c06ab4].
1 2 3 4 5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | - + | // rendermd2.cpp: loader code adapted from a nehe tutorial #include "cube.h" #import "Command.h" |
︙ | |||
86 87 88 89 90 91 92 | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | - - + + | void rendermodel(OFString *mdl, int frame, int range, int tex, float rad, OFVector3D position, float yaw, float pitch, bool teammate, float scale, float speed, int snap, int basetime) { MD2 *m = loadmodel(mdl); |
︙ |
Modified src/renderparticles.m from [c7ff826e5c] to [7fffcaae48].
1 2 3 4 | 1 2 3 4 5 6 7 8 9 10 11 12 | - + | // renderparticles.cpp #include "cube.h" |
︙ | |||
52 53 54 55 56 57 58 | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | - - + + | up = u; } void render_particles(int time) { if (demoplayback && demotracking) |
︙ |
Modified src/savegamedemo.m from [b93241b086] to [822ad5d4d5].
1 2 3 4 5 6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | - + - + | // loading and saving of savegames & demos, dumps the spawn state of all // mapents, the full state of all dynents (monsters + player) #include "cube.h" #import "Command.h" |
︙ | |||
101 102 103 104 105 106 107 | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | - + | if (!f) { conoutf(@"could not write %@", IRI.string); return; } gzwrite(f, (void *)"CUBESAVE", 8); gzputc(f, islittleendian); gzputi(SAVEGAMEVERSION); |
︙ | |||
215 216 217 218 219 220 221 | 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | - - + + - + - + | restoreserverstate(ents); OFMutableData *data = [OFMutableData dataWithCapacity:DynamicEntity.serializedSize]; [data increaseCountBy:DynamicEntity.serializedSize]; gzread(f, data.mutableItems, data.count); |
︙ | |||
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | + + + | { bdamage = damage; } void incomingdemodata(unsigned char *buf, int len, bool extras) { Player *player1 = Player.player1; if (!demorecording) return; gzputi(lastmillis - starttime); gzputi(len); gzwrite(f, buf, len); gzput(extras); if (extras) { gzput(player1.gunSelect); gzput(player1.lastAttackGun); |
︙ | |||
366 367 368 369 370 371 372 | 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | - + | void startdemo() { democlientnum = gzgeti(); demoplayback = true; starttime = lastmillis; conoutf(@"now playing demo"); |
︙ | |||
417 418 419 420 421 422 423 | 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | - + | stopreset(); return; } unsigned char buf[MAXTRANS]; gzread(f, buf, len); localservertoclient(buf, len); // update game state |
︙ | |||
448 449 450 451 452 453 454 | 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | - + | // FIXME: set more client state here } // insert latest copy of player into history if (extras && (playerhistory.count == 0 || playerhistory.lastObject.lastUpdate != playbacktime)) { |
︙ | |||
471 472 473 474 475 476 477 | 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | - - + + - + - - - + + + - + - + - - + - - - + + + | return; int itime = lastmillis - demodelaymsec; // find 2 positions in history that surround interpolation time point size_t count = playerhistory.count; for (ssize_t i = count - 1; i >= 0; i--) { if (playerhistory[i].lastUpdate < itime) { |
︙ |
Modified src/sound.m from [93eb0a5b3c] to [432ff899cb].
1 2 3 | 1 2 3 4 5 6 7 8 9 10 11 | - + | #include "cube.h" #import "Command.h" |
︙ | |||
109 110 111 112 113 114 115 | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | - + - - + + | static void updatechanvol(int chan, const OFVector3D *loc) { int vol = soundvol, pan = 255 / 2; if (loc) { |
︙ |
Modified src/weapon.m from [d5d4aa755b] to [48ff54c543].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | + | // weapon.cpp: all shooting and effects code #include "cube.h" #import "Command.h" #import "DynamicEntity.h" #import "Monster.h" #import "OFString+Cube.h" #import "Player.h" #import "Projectile.h" static const int MONSTERDAMAGEFACTOR = 4; #define SGRAYS 20 static const float SGSPREAD = 2; static OFVector3D sg[SGRAYS]; |
︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | + + | void selectgun(int a, int b, int c) { if (a < -1 || b < -1 || c < -1 || a >= NUMGUNS || b >= NUMGUNS || c >= NUMGUNS) return; Player *player1 = Player.player1; int s = player1.gunSelect; if (a >= 0 && s != a && player1.ammo[a]) s = a; else if (b >= 0 && s != b && player1.ammo[b]) s = b; else if (c >= 0 && s != c && player1.ammo[c]) s = c; |
︙ | |||
108 109 110 111 112 113 114 | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | + - - + + - | OFString * playerincrosshair() { if (demoplayback) return NULL; OFVector3D o = Player.player1.origin; |
︙ | |||
158 159 160 161 162 163 164 | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | - - + + - - + + + | } } static void hit(int target, int damage, __kindof DynamicEntity *d, DynamicEntity *at) { OFVector3D o = d.origin; |
︙ | |||
215 216 217 218 219 220 221 | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | - + | playsound(S_RLHIT, &v); newsphere(v, RL_RADIUS, 0); dodynlight(vold, v, 0, 0, p.owner); if (!p.local) return; |
︙ | |||
275 276 277 278 279 280 281 | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | - - + + | v = OFMultiplyVector3D(v, time / dtime); v = OFAddVectors3D(v, po); if (p.local) { for (id player in players) if (player != [OFNull null]) projdamage(player, p, v, i, -1, qdam); |
︙ | |||
306 307 308 309 310 311 312 | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | - + | } // create visual effect from a shot void shootv(int gun, OFVector3D from, OFVector3D to, DynamicEntity *d, bool local) { OFVector3D loc = d.origin; |
︙ | |||
434 435 436 437 438 439 440 | 438 439 440 441 442 443 444 445 446 | - + | }]; for (Monster *monster in Monster.monsters) if (monster != d) raydamage(monster, from, to, d, -2); if ([d isKindOfClass:Monster.class]) |
Modified src/world.m from [c2453dcf9a] to [1c22ea0614].
1 2 3 4 5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | - + | // world.cpp: core map management stuff #include "cube.h" #import "Command.h" |
︙ | |||
294 295 296 297 298 299 300 | 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | - + | __block int best; __block float bdist = 99999; [ents enumerateObjectsUsingBlock:^(Entity *e, size_t i, bool *stop) { if (e.type == NOTUSED) return; OFVector3D v = OFMakeVector3D(e.x, e.y, e.z); |
︙ | |||
379 380 381 382 383 384 385 | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | - + | case MAPMODEL: e.attr4 = e.attr3; e.attr3 = e.attr2; case MONSTER: case TELEDEST: e.attr2 = (unsigned char)e.attr1; case PLAYERSTART: |
︙ |
Modified src/worldocull.m from [80938b4118] to [201c3dd9c9].
1 2 3 4 5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | - + + + | // worldocull.cpp: occlusion map and occlusion test #include "cube.h" #import "Command.h" |
︙ |
Modified src/worldrender.m from [ae30288fea] to [60ed27f341].
1 2 3 4 5 6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | - + | // worldrender.cpp: goes through all cubes in top down quad tree fashion, // determines what has to be rendered and how (depending on neighbouring cubes), // then calls functions in rendercubes.cpp #include "cube.h" |
︙ | |||
129 130 131 132 133 134 135 136 137 138 139 140 141 142 | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | + | vxx - lodleft; // these mark the rect inside the current rest that // we want to render using a lower mip level int ly = vyy - lodtop; int rx = vxx + lodright; int ry = vyy + lodbot; float fsize = (float)(1 << mip); Player *player1 = Player.player1; for (int ox = x; ox < xs; ox++) { // first collect occlusion information for this block for (int oy = y; oy < ys; oy++) { SWS(w, ox, oy, sz)->occluded = isoccluded(player1.origin.x, player1.origin.y, (float)(ox << mip), (float)(oy << mip), fsize); } |
︙ |