Change to AvHFont::Load to use COM_LoadFile

git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@171 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
puzl 2005-06-08 21:37:23 +00:00
parent 8732dc6b75
commit e7d89f8cbf
2 changed files with 12 additions and 10 deletions

View file

@ -24,7 +24,6 @@ const char* getModDirectory(void)
if(!theIsComputed) if(!theIsComputed)
{ {
strcpy(theModDirectory, "ns305");
#ifdef AVH_SERVER #ifdef AVH_SERVER
GET_GAME_DIR(theModDirectory); GET_GAME_DIR(theModDirectory);
#else #else

View file

@ -4,6 +4,10 @@
#include "cl_dll/cl_util.h" #include "cl_dll/cl_util.h"
#include "cl_dll/wrect.h"
#include "cl_dll/cl_dll.h"
#include "dlls/extdll.h"
// Number of characters per row in the font sprite. // Number of characters per row in the font sprite.
const int kNumCharsPerRow = 16; const int kNumCharsPerRow = 16;
@ -22,14 +26,13 @@ bool AvHFont::Load(const char* inFileName)
theSpriteFileName += ".spr"; theSpriteFileName += ".spr";
std::string theWidthFileName; std::string theWidthFileName;
theWidthFileName = getModDirectory(); theWidthFileName = inFileName;
theWidthFileName += "/";
theWidthFileName += inFileName;
theWidthFileName += ".dat"; theWidthFileName += ".dat";
FILE* file = fopen(theWidthFileName.c_str(), "rb"); int length=0;
char *fontFileContents = (char *)gEngfuncs.COM_LoadFile( (char *)theWidthFileName.c_str(), 5, &length);
if (file != NULL) if ( fontFileContents && length )
{ {
struct LABC struct LABC
@ -39,17 +42,17 @@ bool AvHFont::Load(const char* inFileName)
long c; long c;
}; };
LABC labc[256]; LABC *labc=(LABC *)fontFileContents;
fread(labc, sizeof(LABC), 256, file); // fread(labc, sizeof(LABC), 256, file);
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256 && i < (length/sizeof(LABC)) ; ++i)
{ {
mCharWidth[i].a = labc[i].a; mCharWidth[i].a = labc[i].a;
mCharWidth[i].b = labc[i].b; mCharWidth[i].b = labc[i].b;
mCharWidth[i].c = labc[i].c; mCharWidth[i].c = labc[i].c;
} }
fclose(file); gEngfuncs.COM_FreeFile(fontFileContents);
} }
else else
{ {