ref: 99d14fa43f2ee64ebf542ab5b7e87e77939c0cdb
parent: 35ef4f5f660d802a0cf766c44b192426e0c8e492
author: Konstantinn Bonnet <qu7uux@gmail.com>
date: Mon Feb 23 19:10:44 EST 2015
use %r properly in printing functions remove Sys_Warn(); shit must have been fixed when printf(2) -> print(2) although shit was shat when print(2) was used in the first place when everything else used printf(2).
--- a/README
+++ b/README
@@ -13,8 +13,8 @@
- high resolutions work up to 4096x4096 (arbitrary limit in r_shared.h)
. by default, quake uses a 8MB heap, which will be insufficient for higher
resolutions → crash/exit with "Hunk_Alloc: failed on ..."
- -> use -mem param, e.g.
- % qk1 -mem 24
+ → use [-mem MB], e.g.:
+ ; quake -mem 24
. resolutions under around 328x160 don't work, possibly because
menu text isn't scaled down, or something
- mouse is grabbed using m_windowed cvar
@@ -28,7 +28,7 @@
----------------------------------
-nosound
-nostdout
- -mem %d
+ -mem MB
(-noudp)
@@ -38,11 +38,8 @@
- pr_strings: assumed 32bit pointer arithmetic: use PR_GetStr() instead of
dealing with it directly; may be ass
- global cppdefotomy, removing code seen as useless for plan9
- - Sys_Warn added again for print(2) stuff in *_9.c that uses %r, kind of stupid
- since Con_Printf was often used there, and it outputs to both fd=1 and console,
- so needs fixing
- vid_9.c: shitty, can probably improve performance a bit without screwing code
- - *printf -> *print was stupid
+ - *printf -> *print was (mostly) stupid
- removed some of the command line parameters
. -winsize, -width, -height: just set the window dimensions with rio/rc
@@ -54,6 +51,8 @@
- new game while already ingame -> front falls off
. most of the time: exits with R_RenderView: called without enough stack
. sometimes: goes batshit on the console (->press y again and quit normally, etc.)
+ - leave running for a couple of hours -> sound dies and eventually, invalid
+ write/reads -> crash
- compile with BAN_TEST -> net_dgrm build fails
- sprites/particles not scaled correctly on high resolutions
- m_windowed 1: can still look around in frozen world when paused
@@ -60,16 +59,13 @@
- m_windowed 1: mouse can still escape, causing glitchy mouse look
- net_9p.c
- cd_9.c,net_udp.c,net_dgrm.c: actuallyport
- - snd_9.c, vid_9.c: lousy
- manpages
- ungrab mouse when entering console or menus a la games/doom (IN_Grabm())
- cleanse *_9.c from linux legacy
- linking errors with -T cflag
- fix potential fp exceptions in code rather than ignoring them?
- - sys_9.c: proper P9 use (style)
- g '/\* FIXME'
- port quakeworld and utilities +/- merge common code and mkmany
- - Sys_Error printing %r systematically is stupid
legal
--- a/cd_9.c
+++ b/cd_9.c
@@ -254,8 +254,7 @@
}
if((cdfd = open(cd_dev, OREAD)) == -1){
- Sys_Warn("CDAudio_Init %s", cd_dev);
- Con_Printf("CDAudio_Init %s: failed to initialize\n", cd_dev);
+ Con_Printf("CDAudio_Init failed: %r\n");
cdfd = -1;
return -1;
}
--- a/in_9.c
+++ b/in_9.c
@@ -202,7 +202,7 @@
nerr = 0;
for(;;){
if((n = read(fd, buf, sizeof buf)) != 1+4*12){
- Sys_Warn("mproc:read: bad count %d not 49", n);
+ Con_Printf("mproc:read: bad count %d not 49: %r\n", n);
if(n < 0 || ++nerr > 10)
break;
continue;
@@ -241,7 +241,7 @@
return;
if(mouseactive = on){
if((fd = open("/dev/cursor", ORDWR|OCEXEC)) < 0){
- Sys_Warn("IN_Grabm:open");
+ Con_Printf("IN_Grabm:open: %r\n");
return;
}
write(fd, nocurs, sizeof(nocurs));
--- a/net_udp.c
+++ b/net_udp.c
@@ -284,7 +284,7 @@
int haddr;
haddr = ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr);
- sprintf(buffer, "%d.%d.%d.%d:%d", (haddr >> 24) & 0xff, (haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff, ntohs(((struct sockaddr_in *)addr)->sin_port));
+ sprint(buffer, "%d.%d.%d.%d:%d", (haddr >> 24) & 0xff, (haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff, ntohs(((struct sockaddr_in *)addr)->sin_port));
return buffer;
*/
return nil;
--- a/pr_edict.c
+++ b/pr_edict.c
@@ -381,7 +381,7 @@
val = (void *)&pr_globals[ofs];
def = ED_GlobalAtOfs(ofs);
if (!def)
- sprint (line,"%d(???)", ofs); /* FIXME */
+ sprint (line,"%d(???)", ofs);
else
{
s = PR_ValueString (def->type, val);
@@ -404,7 +404,7 @@
def = ED_GlobalAtOfs(ofs);
if (!def)
- sprint (line,"%d(???)", ofs); /* FIXME */
+ sprint (line,"%d(???)", ofs);
else
sprint (line,"%d(%s)", ofs, PR_Str(def->s_name));
--- a/quakedef.h
+++ b/quakedef.h
@@ -223,7 +223,6 @@
extern quakeparms_t host_parms;
extern cvar_t sys_ticrate;
-extern cvar_t sys_nostdout;
extern cvar_t developer;
extern qboolean host_initialized; // true if into command execution
@@ -230,9 +229,9 @@
extern double host_frametime;
extern byte *host_basepal;
extern byte *host_colormap;
-extern int host_framecount; // incremented every frame, never reset
-extern double realtime; // not bounded in any way, changed at
- // start of every frame, never reset
+extern int host_framecount; // incremented every frame, never reset
+extern double realtime; // not bounded in any way, changed at
+ // start of every frame, never reset
void Host_ClearMemory (void);
void Host_ServerFrame (void);
--- a/snd_9.c
+++ b/snd_9.c
@@ -20,11 +20,11 @@
for(;;){
if(recv(schan, nil) < 0){
- Sys_Warn("sproc:recv");
+ Con_Printf("sproc:recv %r\n");
break;
}
if((n = write(audio_fd, shm->buffer, shm->samplebits/8 * shm->samples)) < 0){
- Sys_Warn("SNDDMA_Submit:write");
+ Con_Printf("sproc:write: %r\n");
break;
}
wpos += n;
@@ -39,8 +39,7 @@
snd_inited = 0;
if((audio_fd = open("/dev/audio", OWRITE)) < 0){
- Sys_Warn("SNDDMA_Init:open");
- Con_Printf("Could not open /dev/audio\n");
+ Con_Printf("Could not open /dev/audio: %r\n");
return 0;
}
@@ -60,25 +59,21 @@
shm->channels = 2;
if(COM_CheckParm("-sndmono") != 0)
shm->channels = 1;
- //else if(COM_CheckParm("-sndstereo") != 0)
- // shm->channels = 2;
//shm->samples = info.fragstotal * info.fragsize / (shm->samplebits/8);
shm->samples = 1024;
shm->submission_chunk = 1;
- if((shm->buffer = mallocz(shm->samplebits/8 * shm->samples, 1)) == nil){
- Sys_Warn("SNDDMA_Init:malloc");
- close(audio_fd);
- return 0;
- }
+ if((shm->buffer = mallocz(shm->samplebits/8 * shm->samples, 1)) == nil)
+ Sys_Error("SNDDMA_Init:malloc: %r\n");
shm->samplepos = 0;
+ snd_inited = 1;
schan = chancreate(sizeof(int), Nbuf);
if((stid = proccreate(sproc, nil, mainstacksize)) < 0){
- Sys_Warn("proccreate sproc");
- return 0;
+ stid = -1;
+ SNDDMA_Shutdown();
+ Sys_Error("SNDDMA_Init:proccreate: %r\n");
}
- snd_inited = 1;
return 1;
}
@@ -108,7 +103,7 @@
void SNDDMA_Submit(void)
{
if(nbsend(schan, nil) < 0){
- Sys_Warn("SNDDMA_Submit:send");
+ Con_Printf("SNDDMA_Submit:send: %r\n");
SNDDMA_Shutdown();
}
}
--- a/sys.h
+++ b/sys.h
@@ -16,7 +16,6 @@
//
// system IO
//
-void Sys_Warn (char *msg, ...);
void Sys_Error (char *error, ...);
void Sys_Printf (char *fmt, ...);
void Sys_Quit (void);
--- a/sys_9.c
+++ b/sys_9.c
@@ -5,7 +5,6 @@
#include "quakedef.h"
qboolean isDedicated;
-int nostdout = 0;
mainstacksize = 512*1024; /* FIXME */
char end1[] =
" QUAKE: The Doomed Dimension by id Software\n"
@@ -53,6 +52,7 @@
" Quake is a trademark of Id Software, inc., (c)1996 Id Software, inc.\n"
" All rights reserved. NIN logo is a registered trademark licensed\n"
" to Nothing Interactive, Inc. All rights reserved.\n";
+int nostdout;
void Sys_Printf (char *fmt, ...)
@@ -87,19 +87,6 @@
exits(nil);
}
-void Sys_Warn (char *msg, ...)
-{
- char buf[1024], *out;
- va_list arg;
-
- out = seprint(buf, buf+sizeof(buf), "%s: ", argv0);
- va_start(arg, msg);
- out = vseprint(out, buf+sizeof(buf), msg, arg);
- va_end(arg);
- out = seprint(out, buf+sizeof(buf), ": %r\n");
- write(2, buf, out-buf);
-}
-
void Sys_Error (char *error, ...)
{
char buf[1024], *out;
@@ -108,7 +95,6 @@
va_start(arg, error);
out = vseprint(buf, buf+sizeof(buf), error, arg);
va_end(arg);
- out = seprint(out, buf+sizeof(buf), "\n%s: %r\n", argv0);
write(2, buf, out-buf);
Host_Shutdown();
sysfatal("ending");
@@ -119,7 +105,7 @@
uchar sb[1024];
if(stat(path, sb, sizeof sb) < 0){
- Sys_Warn("Sys_FileTime:stat");
+ Sys_Printf("Sys_FileTime:stat: %r\n");
return -1;
}
return *((int *)(sb+25));
@@ -127,10 +113,10 @@
void Sys_mkdir (char *path)
{
- int d;
+ int d;
if((d = create(path, OREAD, DMDIR|0777)) < 0)
- Sys_Warn("Sys_mkdir:create %s", path);
+ Sys_Printf("Sys_mkdir:create: %r\n");
else
close(d);
}
@@ -137,8 +123,8 @@
vlong Sys_FileOpenRead (char *path, int *handle)
{
- int d;
- uchar bs[1024];
+ int d;
+ uchar bs[1024];
d = open (path, OREAD);
*handle = d;
@@ -145,16 +131,16 @@
if(d < 0)
return -1;
if(fstat(d, bs, sizeof bs) < 0)
- Sys_Error("Sys_FileOpenRead %s failed", path);
+ Sys_Error("Sys_FileOpenRead:fstat: %r\n");
return *((vlong *)(bs+33));
}
int Sys_FileOpenWrite (char *path)
{
- int d;
+ int d;
if((d = open(path, OREAD|OTRUNC)) < 0)
- Sys_Error("Sys_FileOpenWrite %s failed", path);
+ Sys_Error("Sys_FileOpenWrite:open: %r\n");
return d;
}
@@ -235,10 +221,10 @@
parms.membase = malloc(parms.memsize);
if(home = getenv("home")){
- snprintf(basedir, sizeof basedir, "%s/lib/quake", home);
+ snprint(basedir, sizeof basedir, "%s/lib/quake", home);
free(home);
}else
- snprintf(basedir, sizeof basedir, "/sys/lib/quake");
+ snprint(basedir, sizeof basedir, "/sys/lib/quake");
parms.basedir = basedir;
Host_Init(&parms);
--- a/vid_9.c
+++ b/vid_9.c
@@ -228,7 +228,7 @@
srand(getpid());
if(initdraw(nil, nil, "quake") < 0)
- Sys_Error("VID_Init:initdraw");
+ Sys_Error("VID_Init:initdraw: %r\n");
vid.width = Dx(screen->r);
vid.height = Dy(screen->r);
if(screen->chan == CMAP8)
@@ -280,7 +280,7 @@
if(config_notify){ /* skip this frame if window resize */
config_notify = 0;
if(getwindow(display, Refnone) < 0)
- Sys_Error("VID_Update:getwindow");
+ Sys_Error("VID_Update:getwindow: %r\n");
vid.width = Dx(screen->r);
vid.height = Dy(screen->r);
ResetFrameBuffer();