Live data from Hacker News

Source code for Quake 2 rerelease

github.com

181–190 of 232 posts

Re: Source code for Quake 2 rerelease

#181

Earlier quoted context omitted.

I wish I could find a use for that, it is a funny idea. Unfortunately in a world where all of you stuff is in terminals, having one special drop down one is less useful.

Never use sudo again! make the drop down be always at your root shell.

sv_cheats 1

Re: Source code for Quake 2 rerelease

#182

Quake II was my first experience writing C. The code is clear, coherent, and straightforward. I’m not going to say it’s the best source code I’ve ever read, but it set a high bar. I’ve read source code to games since then, and I’ve seen all sorts of weird stuff… I’ve seen functions with nesting levels that go past the right side of the screen, I’ve seen functions a mile long that do a million things, you know. It was…

Talking about clear and coherent, does anyone know if there is a deeper reason for using `break' and `continue' instead of pure structured programming? The snippet i = ent->client->chase_target - g_edicts; do { i++; if (i > maxclients->value) i = 1; e = g_edicts + i; if (!e->inuse) continue; if (!e->client->resp.spectator) break; } while (e != ent->client->chase_target); for instance, from the function ChaseNext in t…

Pretty sure your line 3 and the original lines 3-5 are not equivalent. Check it with `i` entering the loop with value `maxclients->value`.

The best reason not to re-write for style reasons is you break it.

Re: Source code for Quake 2 rerelease

#183
post #81

Earlier quoted context omitted.

Descent had mouselook? Now I feel stupid. Or maybe I just didn’t have a mouse when I used to play it with friends, can’t remember.

Descent was closer to DOOM tech, not fully 3d but kind of a 2.5d . Quake was one of first true 3d games

What was 2.5d about it? I mean the rooms needed to be convex IIRC and it had sort of a teleport thing going on, but it was basically all 3d, right?

Re: Source code for Quake 2 rerelease

#184
post #179

Earlier quoted context omitted.

Talking about clear and coherent, does anyone know if there is a deeper reason for using `break' and `continue' instead of pure structured programming? The snippet i = ent->client->chase_target - g_edicts; do { i++; if (i > maxclients->value) i = 1; e = g_edicts + i; if (!e->inuse) continue; if (!e->client->resp.spectator) break; } while (e != ent->client->chase_target); for instance, from the function ChaseNext in t…

Using % vs comparison and reset was probably more efficient with the compilers of the time; might still be. Also I doubt everyone would agree that the one exit condition is more clear. For example, if I know that if e->inuse is 0 it will continue with the next round. Arguably it's more difficult to understand that from the single combined expression—because it isn't so: if !e->inuse but e == ent->client->chase_target…

> if !e->inuse but e == ent->client->chase_target, the original will loop but yours will exit.

No, the continue statement will jump to the test part also for `do' loops:

"The continue statement is related to break, but less often used; it causes the next iteration of the enclosing for, while, or do loop to begin. In the while and do, this means that the test part is executed immediately"

-- "The C programming language (Second Edition)"

Re: Source code for Quake 2 rerelease

#185
post #55

Earlier quoted context omitted.

It was absolutely revolutionary in its time, it’s difficult to think of any current day parallels because the industry has matured so much. For instance, Quake was the first FPS where the maps were truly 3D and could have one piece of floor on top of another. It would be considered insane for a game to not have that now. Quake(World) was the first truly massive online gaming FPS. Quake II was the first game I ever ow…

> For instance, Quake was the first FPS where the maps were truly 3D and could have one piece of floor on top of another Bethesda's Terminator: Future Shock predated Quake by a year and also had truly 3D maps - which were often more expansive than Quake's (also you could drive vehicles, fly a helicopter or something like that IIRC, enter various places to find loot - though the loot variety was limited to basically a…

1: It was ID, not Betsheda.

2: Doom's impact was more huge than Quake. The MOD community still releases PWADs today. Doom basically boosted LAN multiplayer matches.

Re: Source code for Quake 2 rerelease

#186
post #182

Earlier quoted context omitted.

Talking about clear and coherent, does anyone know if there is a deeper reason for using `break' and `continue' instead of pure structured programming? The snippet i = ent->client->chase_target - g_edicts; do { i++; if (i > maxclients->value) i = 1; e = g_edicts + i; if (!e->inuse) continue; if (!e->client->resp.spectator) break; } while (e != ent->client->chase_target); for instance, from the function ChaseNext in t…

Pretty sure your line 3 and the original lines 3-5 are not equivalent. Check it with `i` entering the loop with value `maxclients->value`. The best reason not to re-write for style reasons is you break it.

Thanks, now corrected.

Re: Source code for Quake 2 rerelease

#187
post #182

Earlier quoted context omitted.

Pretty sure your line 3 and the original lines 3-5 are not equivalent. Check it with `i` entering the loop with value `maxclients->value`. The best reason not to re-write for style reasons is you break it.

Thanks, now corrected.

If `i` can enter with value greater than `maxclients->value` (why not), it's still wrong.

Re: Source code for Quake 2 rerelease

#188

Earlier quoted context omitted.

I never scrutinized the id software source, but man have I seen some horrifying game source. The bar is extremely low. What's surprised me is that successful, fun to play, and stable enough games have been shipped with such absolute unmitigated disasters behind the curtain. It makes me question sometimes all the effort(and time) I put into preventing the chaos, when such carelessly bodged together garbage can be perf…

That garbage code brought about the speed run culture, highlighted by charity events like Awesome Games Done Quick. The speed runner and their crew on stage will explain the latest level skips, wall clipping to avoid tedious areas, enemy weaknesses and exploits, and frame perfect input strings needed to accomplish those. And some will perform speed runs blindfolded with only the audio cues to work with.

That hardly has to do with code quality, but instead that some edge-case "features" were not anticipated by the game designers, programmers and QA team, but "discovered" later by speedrunners.

Re: Source code for Quake 2 rerelease

#189

Earlier quoted context omitted.

Talking about clear and coherent, does anyone know if there is a deeper reason for using `break' and `continue' instead of pure structured programming? The snippet i = ent->client->chase_target - g_edicts; do { i++; if (i > maxclients->value) i = 1; e = g_edicts + i; if (!e->inuse) continue; if (!e->client->resp.spectator) break; } while (e != ent->client->chase_target); for instance, from the function ChaseNext in t…

I think it's debateable which is clearer. Your while condition requires some mental parsing of the booleans whereas the original can be analysed one at a time. I'd say I prefer the original.

One nice property with (pure) structured programming is that the statement

  do {
     ...
  } while (p);
guarantees that p is false after the loop and this makes it easier to reason about the program. With breaks, however, the loop could be "lying" so to speak.

Re: Source code for Quake 2 rerelease

#190

Quake II was my first experience writing C. The code is clear, coherent, and straightforward. I’m not going to say it’s the best source code I’ve ever read, but it set a high bar. I’ve read source code to games since then, and I’ve seen all sorts of weird stuff… I’ve seen functions with nesting levels that go past the right side of the screen, I’ve seen functions a mile long that do a million things, you know. It was…

Talking about clear and coherent, does anyone know if there is a deeper reason for using `break' and `continue' instead of pure structured programming? The snippet i = ent->client->chase_target - g_edicts; do { i++; if (i > maxclients->value) i = 1; e = g_edicts + i; if (!e->inuse) continue; if (!e->client->resp.spectator) break; } while (e != ent->client->chase_target); for instance, from the function ChaseNext in t…

Break, continue, return (and arguably even C's goto before variables could be declared in the middle of a scope block) are all entirely normal tools in the structured programming toolbox. How those are used is just personal taste.
Post reply on HN