- OTM_TextureClient::MergeUpdate: force reload does now switch the correct texture (previously it lead to a crash)
- OTM_TextureClient::MergeUpdate: volume and cube textures are now loaded (if they were not loaded before)
- OTM_TextureServer: if textures were added more than once, they could not be deleted correctly
- OTM_Sender::SendTextures: if texture were loaded, but get unloaded due to a rearranging of the list, they are now marked correctly as unloaded

Improvements:
- OTM keeps in mind the actual window position
- added a MORE_TEXTURES flag for the pipe comunication: if more data is written to the pipe, than the size of the buffer, the Mainloop of the OTM_TextureServer will wait for the rest of the date before it prepare an update for the OTM_TextureClient.
- added the last missing texture formats of D3DFORMAT (except two formats)
This commit is contained in:
code@koerner-de.net
2011-11-08 14:00:53 +00:00
parent 7e1a8a72b4
commit fab93611c1
14 changed files with 246 additions and 74 deletions
+123 -44
View File
@@ -154,6 +154,8 @@ int OTM_TextureClient::RemoveTexture( OTM_IDirect3DTexture9* pTexture) // is cal
{
FileToMod[ref].NumberOfTextures--;
for (int j=i; j<FileToMod[ref].NumberOfTextures; j++) FileToMod[ref].Textures[j] = FileToMod[ref].Textures[j+1];
FileToMod[ref].Textures[FileToMod[ref].NumberOfTextures] = NULL;
break;
}
}
}
@@ -179,6 +181,8 @@ int OTM_TextureClient::RemoveTexture( OTM_IDirect3DVolumeTexture9* pTexture) //
{
FileToMod[ref].NumberOfTextures--;
for (int j=i; j<FileToMod[ref].NumberOfTextures; j++) FileToMod[ref].Textures[j] = FileToMod[ref].Textures[j+1];
FileToMod[ref].Textures[FileToMod[ref].NumberOfTextures] = NULL;
break;
}
}
}
@@ -204,6 +208,8 @@ int OTM_TextureClient::RemoveTexture( OTM_IDirect3DCubeTexture9* pTexture) // is
{
FileToMod[ref].NumberOfTextures--;
for (int j=i; j<FileToMod[ref].NumberOfTextures; j++) FileToMod[ref].Textures[j] = FileToMod[ref].Textures[j+1];
FileToMod[ref].Textures[FileToMod[ref].NumberOfTextures] = NULL;
break;
}
}
}
@@ -358,8 +364,11 @@ int OTM_TextureClient::MergeUpdate(void)
}
else if (FileToMod[pos_old].Hash < Update[pos_new].Hash) // this fake texture is not in the update
{
for (int i=0; i<FileToMod[pos_old].NumberOfTextures; i++) FileToMod[pos_old].Textures[i]->Release(); // we release the fake textures
for (int i=FileToMod[pos_old].NumberOfTextures-1; i>=0; i--) FileToMod[pos_old].Textures[i]->Release(); // we release the fake textures
if (FileToMod[pos_old].Textures!=NULL) delete [] FileToMod[pos_old].Textures; // we delete the memory
FileToMod[pos_old].NumberOfTextures = 0;
FileToMod[pos_old].Textures = NULL;
pos_old++; // we increase only the old counter by one
}
else // the hash value is the same, thus this texture is in the array FileToMod as well as in the array Update
@@ -380,13 +389,14 @@ int OTM_TextureClient::MergeUpdate(void)
{
OTM_IDirect3DTexture9 *pTexture = (OTM_IDirect3DTexture9*) FileToMod[pos_old].Textures[i];//
OTM_IDirect3DTexture9 *pRefTexture = pTexture->CrossRef_D3Dtex;
FileToMod[pos_old].Textures[i]->Release();
FileToMod[pos_old].Textures[i] = NULL;
pTexture->Release();
i--; //after the Release of the old fake texture FileToMod[pos_old].Textures[i] is overwritten by entries with index greater than i
OTM_IDirect3DTexture9 *fake_Texture;
if (int ret = LoadTexture( & (Update[pos_new]), &fake_Texture)) return (ret);
if (SwitchTextures( fake_Texture, pTexture))
if (SwitchTextures( fake_Texture, pRefTexture))
{
Message("MergeUpdate(): textures not switched %#lX\n", pTexture->Hash);
Message("MergeUpdate(): textures not switched %#lX\n", pRefTexture->Hash);
fake_Texture->Release();
}
else
@@ -400,13 +410,14 @@ int OTM_TextureClient::MergeUpdate(void)
{
OTM_IDirect3DVolumeTexture9 *pTexture = (OTM_IDirect3DVolumeTexture9*) FileToMod[pos_old].Textures[i];//
OTM_IDirect3DVolumeTexture9 *pRefTexture = pTexture->CrossRef_D3Dtex;
FileToMod[pos_old].Textures[i]->Release();
FileToMod[pos_old].Textures[i] = NULL;
pTexture->Release();
i--; //after the Release of the old fake texture FileToMod[pos_old].Textures[i] is overwritten by entries with index greater than i
OTM_IDirect3DVolumeTexture9 *fake_Texture;
if (int ret = LoadTexture( & (Update[pos_new]), &fake_Texture)) return (ret);
if (SwitchTextures( fake_Texture, pTexture))
if (SwitchTextures( fake_Texture, pRefTexture))
{
Message("MergeUpdate(): textures not switched %#lX\n", pTexture->Hash);
Message("MergeUpdate(): textures not switched %#lX\n", pRefTexture->Hash);
fake_Texture->Release();
}
else
@@ -420,13 +431,14 @@ int OTM_TextureClient::MergeUpdate(void)
{
OTM_IDirect3DCubeTexture9 *pTexture = (OTM_IDirect3DCubeTexture9*) FileToMod[pos_old].Textures[i];//
OTM_IDirect3DCubeTexture9 *pRefTexture = pTexture->CrossRef_D3Dtex;
FileToMod[pos_old].Textures[i]->Release();
FileToMod[pos_old].Textures[i] = NULL;
pTexture->Release();
i--; //after the Release of the old fake texture FileToMod[pos_old].Textures[i] is overwritten by entries with index greater than i
OTM_IDirect3DCubeTexture9 *fake_Texture;
if (int ret = LoadTexture( & (Update[pos_new]), &fake_Texture)) return (ret);
if (SwitchTextures( fake_Texture, pTexture))
if (SwitchTextures( fake_Texture, pRefTexture))
{
Message("MergeUpdate(): textures not switched %#lX\n", pTexture->Hash);
Message("MergeUpdate(): textures not switched %#lX\n", pRefTexture->Hash);
fake_Texture->Release();
}
else
@@ -445,6 +457,7 @@ int OTM_TextureClient::MergeUpdate(void)
{
Update[pos_new].NumberOfTextures = FileToMod[pos_old].NumberOfTextures;
Update[pos_new].Textures = FileToMod[pos_old].Textures;
FileToMod[pos_old].NumberOfTextures = 0;
FileToMod[pos_old].Textures = NULL;
}
// we increase both counters by one
@@ -455,8 +468,10 @@ int OTM_TextureClient::MergeUpdate(void)
while (pos_old<NumberToMod) //this fake textures are not in the Update
{
for (int i=0; i<FileToMod[pos_old].NumberOfTextures; i++) FileToMod[pos_old].Textures[i]->Release(); // we release the fake textures
for (int i=FileToMod[pos_old].NumberOfTextures-1; i>=0; i--) FileToMod[pos_old].Textures[i]->Release(); // we release the fake textures
//for (int i=0; i<FileToMod[pos_old].NumberOfTextures; i++) FileToMod[pos_old].Textures[i]->Release(); // we release the fake textures
if (FileToMod[pos_old].Textures!=NULL) delete [] FileToMod[pos_old].Textures; // we delete the memory
FileToMod[pos_old].Textures = NULL;
pos_old++;
}
while (pos_new<NumberOfUpdate) //this fake textures are newly added
@@ -473,7 +488,7 @@ int OTM_TextureClient::MergeUpdate(void)
* Note: to_lookup[num_to_lookup++] = pos_new++; is in ascending order,
* thus Update[to_lookup[pos]].Hash is also sorted ascending!
*/
/*
OTM_IDirect3DTexture9 *single_texture = ((OTM_IDirect3DDevice9*)D3D9Device)->GetSingleTexture();
if (num_to_lookup>0)
{
@@ -497,7 +512,6 @@ int OTM_TextureClient::MergeUpdate(void)
// Note: contradicting to normal C-code here the interval includes the index "begin" and "end"!
while (begin+1<end) // as long as the interval is longer than two
{
//old_pos=pos;
if (hash > Update[to_lookup[pos]].Hash) // the new interval is the right half of the actual interval
{
begin = pos+1; // the new interval does not contain the index "pos"
@@ -540,14 +554,50 @@ int OTM_TextureClient::MergeUpdate(void)
}
}
}
*/
if (FileToMod!=NULL)
{
//for (int i=0; i<NumberToMod; i++) if (FileToMod[i].Textures!=NULL) delete [] FileToMod[i].Textures;
delete [] FileToMod;
}
if (to_lookup != NULL) delete [] to_lookup;
if (FileToMod!=NULL) delete [] FileToMod;
FileToMod = Update;
NumberToMod = NumberOfUpdate;
NumberOfUpdate = -1;
Update = NULL;
if (num_to_lookup>0)
{
OTM_IDirect3DTexture9 *single_texture = ((OTM_IDirect3DDevice9*)D3D9Device)->GetSingleTexture();
int num = OriginalTextures.GetNumber();
for (int i=0; i<num; i++) if (OriginalTextures[i]->CrossRef_D3Dtex==NULL || OriginalTextures[i]->CrossRef_D3Dtex==single_texture)
{
UnswitchTextures(OriginalTextures[i]); //this we can do always, so we unswitch the single texture
LookUpToMod( OriginalTextures[i], num_to_lookup, to_lookup);
}
OTM_IDirect3DVolumeTexture9 *single_volume_texture = ((OTM_IDirect3DDevice9*)D3D9Device)->GetSingleVolumeTexture();
num = OriginalVolumeTextures.GetNumber();
for (int i=0; i<num; i++) if (OriginalVolumeTextures[i]->CrossRef_D3Dtex==NULL || OriginalVolumeTextures[i]->CrossRef_D3Dtex==single_volume_texture)
{
UnswitchTextures(OriginalVolumeTextures[i]); //this we can do always, so we unswitch the single texture
LookUpToMod( OriginalVolumeTextures[i], num_to_lookup, to_lookup);
}
OTM_IDirect3DCubeTexture9 *single_cube_texture = ((OTM_IDirect3DDevice9*)D3D9Device)->GetSingleCubeTexture();
num = OriginalCubeTextures.GetNumber();
for (int i=0; i<num; i++) if (OriginalCubeTextures[i]->CrossRef_D3Dtex==NULL || OriginalCubeTextures[i]->CrossRef_D3Dtex==single_cube_texture)
{
UnswitchTextures(OriginalCubeTextures[i]); //this we can do always, so we unswitch the single texture
LookUpToMod( OriginalCubeTextures[i], num_to_lookup, to_lookup);
}
}
if (to_lookup != NULL) delete [] to_lookup;
return (UnlockMutex());
}
@@ -570,42 +620,71 @@ int OTM_TextureClient::UnlockMutex(void)
int OTM_TextureClient::LookUpToMod( MyTypeHash hash)
int OTM_TextureClient::LookUpToMod( MyTypeHash hash, int num_index_list, int *index_list)
{
if(NumberToMod>0)
{
if (hash<FileToMod[0].Hash || hash>FileToMod[NumberToMod-1].Hash) return (-1);
int pos = NumberToMod/2;
int begin = 0;
int end = NumberToMod-1;
// We look in the middle of the interval and each step we halve the interval,
// unless we find the texture or the size of the interval is less than 3.
// Note: contradicting to normal C-code here the interval includes the index "begin" and "end"!
while (begin+1<end) // as long as the interval is longer than two
if (index_list==NULL || num_index_list==0)
{
if (hash > FileToMod[pos].Hash) // the new interval is the right half of the actual interval
if (hash<FileToMod[0].Hash || hash>FileToMod[NumberToMod-1].Hash) return (-1);
int pos = NumberToMod/2;
int begin = 0;
int end = NumberToMod-1;
// We look in the middle of the interval and each step we halve the interval,
// unless we find the texture or the size of the interval is less than 3.
// Note: contradicting to normal C-code here the interval includes the index "begin" and "end"!
while (begin+1<end) // as long as the interval is longer than two
{
begin = pos+1; // the new interval does not contain the index "pos"
pos = (begin + end)/2; // set "pos" somewhere inside the new intervall
if (hash > FileToMod[pos].Hash) // the new interval is the right half of the actual interval
{
begin = pos+1; // the new interval does not contain the index "pos"
pos = (begin + end)/2; // set "pos" somewhere inside the new intervall
}
else if (hash < FileToMod[pos].Hash) // the new interval is the left half of the actual interval
{
end = pos-1; // the new interval does not contain the index "pos"
pos = (begin + end)/2; // set "pos" somewhere inside the new intervall
}
else {return (pos); break;} // we hit the correct hash
}
else if (hash < FileToMod[pos].Hash) // the new interval is the left half of the actual interval
{
end = pos-1; // the new interval does not contain the index "pos"
pos = (begin + end)/2; // set "pos" somewhere inside the new intervall
}
else {return (pos); break;} // we hit the correct hash
for ( pos=begin; pos<=end; pos++) if (FileToMod[pos].Hash==hash) return (pos);
}
else
{
if (hash<FileToMod[index_list[0]].Hash || hash>FileToMod[index_list[num_index_list-1]].Hash) return (-1);
int pos = num_index_list/2;
int begin = 0;
int end = num_index_list-1;
// We look in the middle of the interval and each step we halve the interval,
// unless we find the texture or the size of the interval is less than 3.
// Note: contradicting to normal C-code here the interval includes the index "begin" and "end"!
while (begin+1<end) // as long as the interval is longer than two
{
if (hash > FileToMod[index_list[pos]].Hash) // the new interval is the right half of the actual interval
{
begin = pos+1; // the new interval does not contain the index "pos"
pos = (begin + end)/2; // set "pos" somewhere inside the new intervall
}
else if (hash < FileToMod[index_list[pos]].Hash) // the new interval is the left half of the actual interval
{
end = pos-1; // the new interval does not contain the index "pos"
pos = (begin + end)/2; // set "pos" somewhere inside the new intervall
}
else {return (index_list[pos]); break;} // we hit the correct hash
}
for ( pos=begin; pos<=end; pos++) if (FileToMod[index_list[pos]].Hash==hash) return (index_list[pos]);
}
for (int i=begin; i<=end; i++) if (FileToMod[i].Hash==hash) return (i);
}
return (-1);
}
int OTM_TextureClient::LookUpToMod( OTM_IDirect3DTexture9* pTexture) // should only be called for original textures
int OTM_TextureClient::LookUpToMod( OTM_IDirect3DTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures
{
Message("OTM_TextureClient::LookUpToMod( %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this);
if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched
int index = LookUpToMod( pTexture->Hash);
int index = LookUpToMod( pTexture->Hash, num_index_list, index_list);
if (index>=0)
{
OTM_IDirect3DTexture9 *fake_Texture;
@@ -630,11 +709,11 @@ int OTM_TextureClient::LookUpToMod( OTM_IDirect3DTexture9* pTexture) // should o
return (RETURN_OK);
}
int OTM_TextureClient::LookUpToMod( OTM_IDirect3DVolumeTexture9* pTexture) // should only be called for original textures
int OTM_TextureClient::LookUpToMod( OTM_IDirect3DVolumeTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures
{
Message("OTM_TextureClient::LookUpToMod( Volume %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this);
if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched
int index = LookUpToMod( pTexture->Hash);
int index = LookUpToMod( pTexture->Hash, num_index_list, index_list);
if (index>=0)
{
OTM_IDirect3DVolumeTexture9 *fake_Texture;
@@ -659,11 +738,11 @@ int OTM_TextureClient::LookUpToMod( OTM_IDirect3DVolumeTexture9* pTexture) // sh
return (RETURN_OK);
}
int OTM_TextureClient::LookUpToMod( OTM_IDirect3DCubeTexture9* pTexture) // should only be called for original textures
int OTM_TextureClient::LookUpToMod( OTM_IDirect3DCubeTexture9* pTexture, int num_index_list, int *index_list) // should only be called for original textures
{
Message("OTM_TextureClient::LookUpToMod( Cube %lu): hash: %#lX, %lu\n", pTexture, pTexture->Hash, this);
if (pTexture->CrossRef_D3Dtex!=NULL) return (RETURN_OK); // bug, this texture is already switched
int index = LookUpToMod( pTexture->Hash);
int index = LookUpToMod( pTexture->Hash, num_index_list, index_list);
if (index>=0)
{
OTM_IDirect3DCubeTexture9 *fake_Texture;
+4 -4
View File
@@ -71,9 +71,9 @@ public:
int AddUpdate(TextureFileStruct* update, int number); //called from the Server, client object must delete update array
int MergeUpdate(void); //called from OTM_IDirect3DDevice9::BeginScene()
int LookUpToMod( OTM_IDirect3DTexture9* pTexture); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
int LookUpToMod( OTM_IDirect3DVolumeTexture9* pTexture); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
int LookUpToMod( OTM_IDirect3DCubeTexture9* pTexture); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
int LookUpToMod( OTM_IDirect3DTexture9* pTexture, int num_index_list=0, int *index_list=NULL); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
int LookUpToMod( OTM_IDirect3DVolumeTexture9* pTexture, int num_index_list=0, int *index_list=NULL); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
int LookUpToMod( OTM_IDirect3DCubeTexture9* pTexture, int num_index_list=0, int *index_list=NULL); // called at the end AddTexture(...) and from Device->UpdateTexture(...)
OTM_TextureHandler<OTM_IDirect3DTexture9> OriginalTextures; // stores the pointer to the OTM_IDirect3DTexture9 objects created by the game
OTM_TextureHandler<OTM_IDirect3DVolumeTexture9> OriginalVolumeTextures; // stores the pointer to the OTM_IDirect3DVolumeTexture9 objects created by the game
@@ -105,7 +105,7 @@ private:
TextureFileStruct* FileToMod; // array which stores the file in memory and the hash of each texture to be modded
int LookUpToMod( MyTypeHash hash); // called from LookUpToMod(...);
int LookUpToMod( MyTypeHash hash, int num_index_list, int *index_list); // called from LookUpToMod(...);
int LoadTexture( TextureFileStruct* file_in_memory, OTM_IDirect3DTexture9 **ppTexture); // called if a target texture is found
int LoadTexture( TextureFileStruct* file_in_memory, OTM_IDirect3DVolumeTexture9 **ppTexture); // called if a target texture is found
int LoadTexture( TextureFileStruct* file_in_memory, OTM_IDirect3DCubeTexture9 **ppTexture); // called if a target texture is found
+42 -1
View File
@@ -10,7 +10,10 @@
unsigned int GetCRC32( char *pcDatabuf, unsigned int ulDatalen);
/*
case D3DFMT_MULTI2_ARGB8:
case D3DFMT_VERTEXDATA:
*/
inline int GetBitsFromFormat(D3DFORMAT format)
{
switch(format) //switch trough the formats to calculate the size of the raw data
@@ -28,13 +31,17 @@ inline int GetBitsFromFormat(D3DFORMAT format)
case D3DFMT_L8: // 8-bit luminance only.
case D3DFMT_A4L4: // 8-bit using 4 bits each for alpha and luminance.
case D3DFMT_FORCE_DWORD:
case D3DFMT_S8_LOCKABLE: // A lockable 8-bit stencil buffer.
{
return (8);
break;
}
case D3DFMT_D16_LOCKABLE: //16-bit z-buffer bit depth.
case D3DFMT_D15S1: // 16-bit z-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel.
case D3DFMT_L6V5U5: // 16-bit bump-map format with luminance using 6 bits for luminance, and 5 bits each for v and u.
case D3DFMT_V8U8: // 16-bit bump-map format using 8 bits each for u and v data.
case D3DFMT_CxV8U8: // 16-bit normal compression format. The texture sampler computes the C channel from: C = sqrt(1 - U2 - V2).
case D3DFMT_R5G6B5: // 16-bit RGB pixel format with 5 bits for red, 6 bits for green, and 5 bits for blue.
case D3DFMT_X1R5G5B5: // 16-bit pixel format where 5 bits are reserved for each color.
case D3DFMT_A1R5G5B5: // 16-bit pixel format where 5 bits are reserved for each color and 1 bit is reserved for alpha.
@@ -42,7 +49,14 @@ inline int GetBitsFromFormat(D3DFORMAT format)
case D3DFMT_A8R3G3B2: // 16-bit ARGB texture format using 8 bits for alpha, 3 bits each for red and green, and 2 bits for blue.
case D3DFMT_X4R4G4B4: // 16-bit RGB pixel format using 4 bits for each color.
case D3DFMT_L16: // 16-bit luminance only.
case D3DFMT_R16F: // 16-bit float format using 16 bits for the red channel.
case D3DFMT_A8L8: // 16-bit using 8 bits each for alpha and luminance.
case D3DFMT_D16: // 16-bit z-buffer bit depth.
case D3DFMT_INDEX16: // 16-bit index buffer bit depth.
case D3DFMT_G8R8_G8B8: // ??
case D3DFMT_R8G8_B8G8: // ??
case D3DFMT_UYVY: // ??
case D3DFMT_YUY2: // ??
{
return (16);
break;
@@ -66,7 +80,20 @@ inline int GetBitsFromFormat(D3DFORMAT format)
case D3DFMT_A8B8G8R8: // 32-bit ARGB pixel format with alpha, using 8 bits per channel.
case D3DFMT_X8B8G8R8: // 32-bit RGB pixel format, where 8 bits are reserved for each color.
case D3DFMT_G16R16: // 32-bit pixel format using 16 bits each for green and red.
case D3DFMT_G16R16F: // 32-bit float format using 16 bits for the red channel and 16 bits for the green channel.
case D3DFMT_A2R10G10B10: // 32-bit pixel format using 10 bits each for red, green, and blue, and 2 bits for alpha.
case D3DFMT_D32: // 32-bit z-buffer bit depth.
case D3DFMT_D24S8: // 32-bit z-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel.
case D3DFMT_D24X8: //32-bit z-buffer bit depth using 24 bits for the depth channel.
case D3DFMT_D24X4S4: // 32-bit z-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel.
case D3DFMT_D32F_LOCKABLE: // A lockable format where the depth value is represented as a standard IEEE floating-point number.
case D3DFMT_D24FS8: // A non-lockable format that contains 24 bits of depth (in a 24-bit floating point format - 20e4) and 8 bits of stencil.
case D3DFMT_D32_LOCKABLE: // A lockable 32-bit depth buffer.
case D3DFMT_INDEX32: // 32-bit index buffer bit depth.
//case : //
//case : //
//case : //
//case : //
{
return (32);
break;
@@ -75,6 +102,7 @@ inline int GetBitsFromFormat(D3DFORMAT format)
case D3DFMT_G32R32F: // 64-bit float format using 32 bits for the red channel and 32 bits for the green channel.
case D3DFMT_Q16W16V16U16: // 64-bit bump-map format using 16 bits for each component.
case D3DFMT_A16B16G16R16: // 64-bit pixel format using 16 bits for each component.
case D3DFMT_A16B16G16R16F: // 64-bit float format using 16 bits for the each channel (alpha, blue, green, red).
{
return (64);
break;
@@ -85,6 +113,19 @@ inline int GetBitsFromFormat(D3DFORMAT format)
return (128);
break;
}
case D3DFMT_DXT2:
case D3DFMT_DXT3:
case D3DFMT_DXT4:
case D3DFMT_DXT5:
{
return (8);
break;
}
case D3DFMT_DXT1:
{
return (4);
break;
}
default: //compressed formats
{
return (4);
+12 -6
View File
@@ -211,12 +211,12 @@ int OTM_TextureServer::AddFile( char* buffer, unsigned int size, MyTypeHash has
temp->Size = size;
temp->NumberOfTextures = 0;
temp->Reference = -1;
temp->Textures = NULL;
temp->Hash = hash;
if (new_file) temp->ForceReload = false; // no need to force a load of the texture
else temp->ForceReload = force;
//if (new_file) temp->ForceReload = false; // no need to force a load of the texture
//else
temp->ForceReload = force;
Message("End AddFile(%#lX)\n", hash);
if (new_file) return (CurrentMod.Add(temp)); // new files must be added to the list of the CurrentMod
@@ -297,7 +297,6 @@ int OTM_TextureServer::AddFile(wchar_t* file_name, MyTypeHash hash, bool force)
temp->Size = size;
temp->NumberOfTextures = 0;
temp->Reference = -1;
temp->Textures = NULL;
temp->Hash = hash;
@@ -567,6 +566,8 @@ int OTM_TextureServer::MainLoop(void) // run as a separated thread
unsigned long num;
Message("MainLoop: started\n");
bool update_textures = false;
bool more_textures = false;
while (1)
{
Message("MainLoop: run\n");
@@ -581,7 +582,7 @@ int OTM_TextureServer::MainLoop(void) // run as a separated thread
{
unsigned int pos = 0;
MsgStruct *commands;
bool update_textures = false;
more_textures = false;
while (pos <= num - sizeof(MsgStruct))
{
commands = (MsgStruct*) &buffer[pos];
@@ -590,6 +591,11 @@ int OTM_TextureServer::MainLoop(void) // run as a separated thread
switch (commands->Control)
{
case CONTROL_MORE_TEXTURES:
{
more_textures=true;
break;
}
case CONTROL_FORCE_RELOAD_TEXTURE: force=true;
case CONTROL_ADD_TEXTURE:
{
@@ -678,7 +684,7 @@ int OTM_TextureServer::MainLoop(void) // run as a separated thread
}
pos += sizeof(MsgStruct) + size;
}
if (update_textures) PropagateUpdate();
if (!more_textures && update_textures) {PropagateUpdate(); update_textures=false;}
}
else
{
+2 -1
View File
@@ -79,7 +79,7 @@ bool MyApp::OnInit(void)
wxMessageBox( Language->Error_AlreadyRunning, "ERROR", wxOK|wxICON_ERROR);
return false;
}
OTM_Frame *frame = new OTM_Frame( OTM_VERSION, wxDefaultPosition, wxSize(set.XSize,set.YSize));
OTM_Frame *frame = new OTM_Frame( OTM_VERSION, wxPoint(set.XPos,set.YPos), wxSize(set.XSize,set.YSize));
SetTopWindow( frame );
return true;
@@ -209,6 +209,7 @@ OTM_Frame::~OTM_Frame(void)
OTM_Settings set;
set.Language = Language->GetCurrentLanguage();
GetSize( &set.XSize, &set.YSize);
GetPosition( &set.XPos, &set.YPos);
set.Save();
}
+1 -1
View File
@@ -322,7 +322,7 @@ int OTM_Language::LoadDefault(void)
Author = "Author: ";
Error_FileNotSupported = "This file type is not supported:\n";
Error_DLLNotFound = "Could not load the dll.\nThe dll injection won't work.\nThis might happen if D3DX9_43.dll is not installed on your system.\nPlease install the newest DirectX End-User Runtime Web Installer.";
Error_DLLNotFound = "Could not load the dll.\nThe dll injection won't work.\nThis might happen if D3DX9_43.dll (32bit) is not installed on your system.\nPlease install the newest DirectX End-User Runtime Web Installer.";
Error_FktNotFound = "Could not load function out of dll.\nThe dll injection won't work.";
Error_AlreadyRunning = "An other instance of OpenTexMod is already running.";
+37 -11
View File
@@ -110,7 +110,11 @@ int OTM_Sender::Send( const OTM_GameInfo &game, const OTM_GameInfo &game_old, bo
for (int i=0; i<num; i++)
{
OTM_File file( files[i]);
file.GetComment(comment);
if (file.GetComment(comment))
{
LastError << file.LastError;
file.LastError.Empty();
}
tex[i].Comment = comment;
tex[i].Add = checked[i];
@@ -153,17 +157,16 @@ int OTM_Sender::Send( const OTM_GameInfo &game, const OTM_GameInfo &game_old, bo
int pos = 0;
bool *hit=NULL;
if (GetMemory( hit, OldTexturesNum, false)) {LastError << Language->Error_Memory; return -1;}
for (int i=0; i<num && i<OldTexturesNum; i++)
for (pos=0; pos<num && pos<OldTexturesNum; pos++)
{
if (OldTextures[i].File == files[i])
if (OldTextures[pos].File == files[pos])
{
tex[i].InheriteMemory(OldTextures[i]);
tex[i].Force = false;
hit[i] = true;
tex[pos].InheriteMemory(OldTextures[pos]);
tex[pos].Force = false;
hit[pos] = true;
}
else
{
pos = i;
break;
}
}
@@ -187,13 +190,21 @@ int OTM_Sender::Send( const OTM_GameInfo &game, const OTM_GameInfo &game_old, bo
if (tex[i].Len==0 || (tex[i].Add && !tex[i].Loaded) )
{
OTM_File file( files[i]);
file.GetComment(comment);
if (file.GetComment(comment))
{
LastError << file.LastError;
file.LastError.Empty();
}
tex[i].Comment = comment;
tex[i].Add = checked[i];
tex[i].Force = true;
tex[i].File = files[i];
file.GetContent( tex[i], tex[i].Add);
if (file.GetContent( tex[i], checked[i]))
{
LastError << file.LastError;
file.LastError.Empty();
}
}
}
@@ -218,6 +229,7 @@ int OTM_Sender::Send( const OTM_GameInfo &game, const OTM_GameInfo &game_old, bo
}
}
SendTextures( num+append, tex);
if (hit!=NULL) delete [] hit;
}
if (checked!=NULL) delete [] checked;
@@ -272,7 +284,7 @@ int OTM_Sender::SendTextures(unsigned int num, AddTextureClass *tex)
{
if (tex[i].Force || !tex[i].Add || !tex[i].WasAdded[j])
// if force==true we must update
// tex[i].Add!=true we can always remove, cause removing does take time in the render thread
// tex[i].Add!=true we can always remove, cause removing does cost time in the render thread
// if tex[i].Add==true and WasAdded[j]!=true this texture was not loaded but should be loaded, so maybe we can load it now
{
bool hit = false; //we send only if this has was not send before
@@ -285,8 +297,11 @@ int OTM_Sender::SendTextures(unsigned int num, AddTextureClass *tex)
continue;
}
if (tex[i].Size[j]+sizeof(MsgStruct)+pos>BIG_BUFSIZE)
if (tex[i].Size[j]+2*sizeof(MsgStruct)+pos>BIG_BUFSIZE) //the buffer is full
{
msg = (MsgStruct*) &Buffer[pos];
msg->Control = CONTROL_MORE_TEXTURES; // we will send more textures
pos+=sizeof(MsgStruct);
if (int ret = SendToGame( Buffer, pos)) return ret;
pos = 0;
}
@@ -315,6 +330,17 @@ int OTM_Sender::SendTextures(unsigned int num, AddTextureClass *tex)
tex[i].WasAdded[j] = false;
}
}
else if (tex[i].Add && tex[i].WasAdded[j]) // this texture could be removed, due to a rearranging of the list
{
bool hit = false; //we send only if this has was not send before
unsigned long temp_hash = tex[i].Hash[j];
for (unsigned int ii=0u; ii<i && !hit; ii++) for (unsigned int jj=0u; jj<tex[ii].Num && !hit; jj++) if (temp_hash==tex[ii].Hash[jj]) hit=true;
for (unsigned int jj=0u; jj<j && !hit; jj++) if (temp_hash==tex[i].Hash[jj]) hit=true;
if (hit)
{
tex[i].WasAdded[j]=false; // due to rearranging this texture is replaced by an other texture
}
}
}
if (pos) if (int ret = SendToGame( Buffer, pos)) return ret;
+21 -4
View File
@@ -23,9 +23,11 @@ along with OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
OTM_Settings::OTM_Settings(void)
{
XSize=600;
YSize=400;
Language="English";
XSize = 600;
YSize = 400;
XPos = -1;
YPos = -1;
Language = "English";
}
#define SETTINGS_FILE "OTM_Settings.txt"
@@ -81,6 +83,16 @@ int OTM_Settings::Load(void)
long y;
if (value.ToLong( &y)) YSize=y;
}
else if (command == "x_pos")
{
long x;
if (value.ToLong( &x)) XPos=x;
}
else if (command == "y_pos")
{
long y;
if (value.ToLong( &y)) YPos=y;
}
}
return 0;
@@ -103,10 +115,15 @@ int OTM_Settings::Save(void)
content.Printf("y_size:%d\n", YSize);
file.Write( content.wc_str(), content.Len()*2);
content.Printf("x_pos:%d\n", XPos);
file.Write( content.wc_str(), content.Len()*2);
content.Printf("y_pos:%d\n", YPos);
file.Write( content.wc_str(), content.Len()*2);
file.Close();
return 0;
}
+1
View File
@@ -30,6 +30,7 @@ public:
int XSize, YSize;
int XPos, YPos;
wxString Language;
int Load(void);
+1 -1
View File
@@ -11,7 +11,7 @@ Warnung: Du verwendest diese Programm auf eigene Gefahr hin!
http://code.google.com/p/texmod/downloads/list
OpenTexMod verwendet die D3DX9_43.dll. Wegen den EULA kann diese dll nicht mit OpenTexMod
OpenTexMod verwendet die D3DX9_43.dll (32bit). Wegen den EULA kann diese dll nicht mit OpenTexMod
mit geliefert werden. Wenn diese dll auf deinem System nicht installiert ist, wird dich OpenTexMod
darauf hinweisen.
+1 -1
View File
@@ -8,7 +8,7 @@ WARNING: You use this program at your own risk!
Download it by your self and don't use versions, send to you by team or guild members!
http://code.google.com/p/texmod/downloads/list
OpenTexMod uses the D3DX9_43.dll. Due to the EULA this dll cannot be delivered together with OpenTexMod .
OpenTexMod uses the D3DX9_43.dll (32bit). Due to the EULA this dll cannot be delivered together with OpenTexMod .
If D3DX9_43.dll is not installed on your system, OpenTexMod will give you a hint at program start.
Binary file not shown.
Binary file not shown.
+1
View File
@@ -51,6 +51,7 @@ typedef struct
#define CONTROL_REMOVE_TEXTURE 3
#define CONTROL_FORCE_RELOAD_TEXTURE_DATA 4
#define CONTROL_ADD_TEXTURE_DATA 5
#define CONTROL_MORE_TEXTURES 6
#define CONTROL_SAVE_ALL 10