fix hash table inits, fix shader inits

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2959 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2008-05-14 18:06:58 +00:00
parent 73f580157f
commit a61d819f68
4 changed files with 26 additions and 3 deletions

View file

@ -172,7 +172,11 @@ static galiastexnum_t *D3D_ChooseSkin(galiasinfo_t *inf, char *modelname, int su
skinname = modelname; skinname = modelname;
if (!skincolourmapped.numbuckets) if (!skincolourmapped.numbuckets)
Hash_InitTable(&skincolourmapped, 256, BZ_Malloc(Hash_BytesForBuckets(256))); {
void *buckets = BZ_Malloc(Hash_BytesForBuckets(256));
memset(buckets, 0, Hash_BytesForBuckets(256));
Hash_InitTable(&skincolourmapped, 256, buckets);
}
for (cm = Hash_Get(&skincolourmapped, skinname); cm; cm = Hash_GetNext(&skincolourmapped, skinname, cm)) for (cm = Hash_Get(&skincolourmapped, skinname); cm; cm = Hash_GetNext(&skincolourmapped, skinname, cm))
{ {
@ -211,6 +215,9 @@ static galiastexnum_t *D3D_ChooseSkin(galiasinfo_t *inf, char *modelname, int su
cm->skinnum = e->skinnum; cm->skinnum = e->skinnum;
cm->texnum.fullbright = 0; cm->texnum.fullbright = 0;
cm->texnum.base = 0; cm->texnum.base = 0;
#ifdef Q3SHADERS
cm->texnum.shader = NULL;
#endif
if (!texnums) if (!texnums)
{ //load just the skin (q2) { //load just the skin (q2)

View file

@ -172,7 +172,11 @@ static galiastexnum_t *D3D9_ChooseSkin(galiasinfo_t *inf, char *modelname, int s
skinname = modelname; skinname = modelname;
if (!skincolourmapped.numbuckets) if (!skincolourmapped.numbuckets)
Hash_InitTable(&skincolourmapped, 256, BZ_Malloc(Hash_BytesForBuckets(256))); {
void *buckets = BZ_Malloc(Hash_BytesForBuckets(256));
memset(buckets, 0, Hash_BytesForBuckets(256));
Hash_InitTable(&skincolourmapped, 256, buckets);
}
for (cm = Hash_Get(&skincolourmapped, skinname); cm; cm = Hash_GetNext(&skincolourmapped, skinname, cm)) for (cm = Hash_Get(&skincolourmapped, skinname); cm; cm = Hash_GetNext(&skincolourmapped, skinname, cm))
{ {
@ -211,6 +215,9 @@ static galiastexnum_t *D3D9_ChooseSkin(galiasinfo_t *inf, char *modelname, int s
cm->skinnum = e->skinnum; cm->skinnum = e->skinnum;
cm->texnum.fullbright = 0; cm->texnum.fullbright = 0;
cm->texnum.base = 0; cm->texnum.base = 0;
#ifdef Q3SHADERS
cm->texnum.shader = NULL;
#endif
if (!texnums) if (!texnums)
{ //load just the skin (q2) { //load just the skin (q2)

View file

@ -1064,7 +1064,11 @@ static galiastexnum_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, int sur
} }
if (!skincolourmapped.numbuckets) if (!skincolourmapped.numbuckets)
Hash_InitTable(&skincolourmapped, 256, BZ_Malloc(Hash_BytesForBuckets(256))); {
void *buckets = BZ_Malloc(Hash_BytesForBuckets(256));
memset(buckets, 0, Hash_BytesForBuckets(256));
Hash_InitTable(&skincolourmapped, 256, buckets);
}
for (cm = Hash_Get(&skincolourmapped, skinname); cm; cm = Hash_GetNext(&skincolourmapped, skinname, cm)) for (cm = Hash_Get(&skincolourmapped, skinname); cm; cm = Hash_GetNext(&skincolourmapped, skinname, cm))
{ {
@ -1097,6 +1101,9 @@ static galiastexnum_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, int sur
cm->skinnum = e->skinnum; cm->skinnum = e->skinnum;
cm->texnum.fullbright = 0; cm->texnum.fullbright = 0;
cm->texnum.base = 0; cm->texnum.base = 0;
#ifdef Q3SHADERS
cm->texnum.shader = NULL;
#endif
if (!texnums) if (!texnums)
{ //load just the skin { //load just the skin
@ -2808,3 +2815,4 @@ void GL_GenerateNormals(float *orgs, float *normals, int *indicies, int numtris,
#endif #endif
#endif // defined(RGLQUAKE) || defined(SERVERONLY) #endif // defined(RGLQUAKE) || defined(SERVERONLY)

View file

@ -8,6 +8,7 @@
#endif #endif
#endif #endif
// hash init assumes we get clean memory
void Hash_InitTable(hashtable_t *table, int numbucks, void *mem) void Hash_InitTable(hashtable_t *table, int numbucks, void *mem)
{ {
table->numbuckets = numbucks; table->numbuckets = numbucks;