From: MirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Date: Sun, 29 Jan 2012 20:49:59 +0000 (+0200)
Subject: Obtain image name from the character's text file
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1a6c11811652528347da574475b5b76f7329ee4b;p=voretournament%2Fvoretournament.git

Obtain image name from the character's text file
---

diff --git a/data/qcsrc/client/hud.qc b/data/qcsrc/client/hud.qc
index 282b1fa1..976c1ec6 100644
--- a/data/qcsrc/client/hud.qc
+++ b/data/qcsrc/client/hud.qc
@@ -3553,10 +3553,33 @@ void CSQC_race_hud(void)
 
 void Ent_ReadPortrait()
 {
-	string s, n;
-	s = ReadString();
-	n = ReadString();
+	string pl_model, pl_name, img;
+	float pl_skin;
+	pl_model = ReadString();
+	pl_skin = ReadByte();
+	pl_name = ReadString();
+
+	// obtain the image name from the text file
+	float glob, i, fh;
+	string fn;
+
+	glob = search_begin("models/player/*.txt", TRUE, TRUE);
+	if(glob < 0)
+		return;
+	for(i = 0; i < search_getsize(glob); ++i)
+	{
+		fn = search_getfilename(glob, i);
+		fh = fopen(fn, FILE_READ);
+		if(fh < 0)
+			continue;
 
-	dprint(strcat(s, " --------\n"));
-	dprint(strcat(n, " --------\n"));
+		fgets(fh); // skip name
+		img = fgets(fh);
+		if(pl_skin == stof(fgets(fh)))
+		if(pl_model == fgets(fh))
+			dprint(strcat(img, " ----------------\n"));
+
+		fclose(fh);
+	}
+	search_end(glob);
 }
diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc
index bd66439f..2d7de74f 100644
--- a/data/qcsrc/server/miscfunctions.qc
+++ b/data/qcsrc/server/miscfunctions.qc
@@ -2468,11 +2468,8 @@ float portrait_SendEntity(entity to, float sf)
 
 	WriteByte(MSG_ENTITY, ENT_CLIENT_PORTRAIT);
 
-	string s;
-	s = substring(self.model, 0, strlen(self.model) - 4); // remove extension
-	s = strcat(s, "-", ftos(self.skin));
-
-	WriteString(MSG_ENTITY, s);
+	WriteString(MSG_ENTITY, self.model);
+	WriteByte(MSG_ENTITY, self.skin);
 	WriteString(MSG_ENTITY, self.netname);
 
 	return TRUE;