shithub: sce

Download patch

ref: b3280e12afd42fe9ae744805c72cfe3858a746cd
parent: a274d4d1fafc06576c039ab16551c80491749851
author: qwx <qwx@sciops.net>
date: Tue Nov 23 18:05:53 EST 2021

sim: actually initialize resources, draw team resources on hud

--- a/dat.h
+++ b/dat.h
@@ -251,7 +251,7 @@
 	int sz;
 	int firstempty;
 };
-extern Team teams[Nteam], *curteam;
+extern Team teams[Nteam];
 extern int nteam;
 
 extern int lport;
--- a/drw.c
+++ b/drw.c
@@ -105,10 +105,14 @@
 static void
 drawhud(void)
 {
-	char s[256];
+	int i;
+	char s[256], *s´;
+	Point p;
 	Mobj *mo;
+	Team *t;
 
-	draw(screen, Rpt(p0, screen->r.max), display->black, nil, ZP);
+	p = p0;
+	draw(screen, Rpt(p, screen->r.max), display->black, nil, ZP);
 	mo = selected[0];
 	if(mo == nil)
 		return;
@@ -116,11 +120,18 @@
 		snprint(s, sizeof s, "%s %d", mo->o->name, mo->amount);
 	else
 		snprint(s, sizeof s, "%s %d/%d", mo->o->name, mo->hp, mo->o->hp);
-	string(screen, p0, display->white, ZP, font, s);
+	string(screen, p, display->white, ZP, font, s);
+	p.y += font->height;
 	if((mo->o->f & Fresource) == 0){
 		snprint(s, sizeof s, "%s", mo->state < OSend ? statename[mo->state] : "");
-		string(screen, addpt(p0, Pt(0,font->height)), display->white, ZP, font, s);
+		string(screen, p, display->white, ZP, font, s);
 	}
+	p.y += font->height;
+	t = teams + mo->team;
+	s´ = seprint(s, s+sizeof s, "team %d: ", mo->team);
+	for(i=0; i<nelem(t->r); i++)
+		s´ = seprint(s´, s+sizeof s, "[%s] %d ", resources[i].name, t->r[i]);
+	string(screen, p, display->white, ZP, font, s);
 }
 
 static int
--- a/sim.c
+++ b/sim.c
@@ -4,9 +4,8 @@
 #include "dat.h"
 #include "fns.h"
 
-Team teams[Nteam], *curteam;
+Team teams[Nteam];
 int nteam;
-int initres[Nresource], foodcap;
 
 char *statename[OSend] = {
 	[OSidle] "idle",
@@ -162,10 +161,12 @@
 void
 initsim(void)
 {
+	int i;
 	Team *t;
 
 	if(nteam < 2)
 		sysfatal("initgame: the only winning move is not to play");
 	for(t=teams; t<=teams+nteam; t++)
-		memcpy(t->r, initres, sizeof initres);
+		for(i=0; i<nelem(t->r); i++)
+			t->r[i] = resources[i].init;
 }