Game Development Community

TGB 1.7.3beta1 Bug - Can't load resources

by Rene Damm · in Torque Game Builder · 05/08/2008 (10:37 am) · 32 replies

Adding resources to a project via "Project -> Resources..." has no effect on project. Resources get added to list, but after exiting the dialog, disappear and no resources are added to the Create tab.

Looking at the log reveals the following:

Unable to open file 'C:/Users/Ren[EACUTE here] Damm/AppData/Roaming/GarageGames/TorqueGameBuilder/RSSCache.cs for writing.
Compiling C:/Program Files/Torque/TorqueGameBuilder-1.7.3/tgb/resources/fishArt/resourceDatabase.cs...
Resource with name  found but invalid resource object contained inside resource!
Compiling C:/Program Files/Torque/TorqueGameBuilder-1.7.3/tgb/resources/fishArt/resourceDatabase.cs...
Resource with name  found but invalid resource object contained inside resource!
Compiling C:/Program Files/Torque/TorqueGameBuilder-1.7.3/tgb/resources/fishArt/resourceDatabase.cs...
Resource with name  found but invalid resource object contained inside resource!
Compiling C:/Program Files/Torque/TorqueGameBuilder-1.7.3/tgb/resources/MoleArt/resourceDatabase.cs...
Resource with name  found but invalid resource object contained inside resource!
Compiling C:/Program Files/Torque/TorqueGameBuilder-1.7.3/tgb/resources/fishArt/resourceDatabase.cs...
Resource with name  found but invalid resource object contained inside resource!
Compiling C:/Program Files/Torque/TorqueGameBuilder-1.7.3/tgb/resources/MoleArt/resourceDatabase.cs...
Resource with name  found but invalid resource object contained inside resource!

OS is Vista.

Hoping to find the time to give this a more thorough look.

PS: Hope this hasn't been reported before. Rather new here. Searching turned up nothing.

-----
Edited: Forum software truncated post after eacute character.

-----
Edit: Patched 1.7.4 binaries available here.
Page«First 1 2 Next»
#21
03/29/2009 (11:52 am)
hi Rene,
thanks for this great resource! we are only a few days away from launching And Yet It Moves, and just found out about this unicode mess in TGB...

i patched everything with your diff files, and currently i found only one problem:
when calling StringTableEntry osGetTemporaryDirectory() TGB crashes, debugger tells me this:
Run-Time Check Failure #2 - Stack around the variable 'buf' was corrupted.

it seems that something wants to write into buf, but writes into a wrong adress. when buf's scope ends at the end of the function, this error occurs.

do you know what could cause this? it would really help us alot if we could fix this, cause i dont know which exotic characters users around the world have in their path to windows temp directory

thanks alot!

peter
#22
03/29/2009 (12:26 pm)
Seems the temp path is exceeding the fixed buffer in size. There's also a bug with the backslash removal.

The following replacement of osGetTemporaryDirectory() should do the trick. It's quick-n-dirty but should work, though I didn't test it properly as crap VS botched my working copy of TGB. Please post if it works or not.

StringTableEntry osGetTemporaryDirectory()
{
   TCHAR buf[ 1024 ];
   DWORD len = GetTempPath( sizeof( buf ) / sizeof( buf[ 0 ] ), buf );

   TCHAR* buffer = buf;
   TempAlloc< TCHAR > temp;
   if( len > sizeof( buf ) - 1 )
   {
      temp = TempAlloc< TCHAR >( len + 1 );
      buffer = temp.ptr;
      GetTempPath( len + 1, buffer );
   }

   // Remove the trailing slash
   buffer[len-1] = 0;

#ifdef UNICODE
   TempAlloc< char > utf8( len * 2 + 1 );
   convertUTF16toUTF8( buffer, utf8.ptr, utf8.size );
   char* dir = utf8.ptr;
#else
   char* dir = buf;
#endif

   forwardslash(dir);
   return StringTable->insert(dir);
}

This requires adding a default contructor to TempAlloc:

TempAlloc()
      : ptr( 0 ), size( 0 ) {}

//EDIT: typos galore
#23
03/29/2009 (12:31 pm)
hi,

i tried to replace this line:

TCHAR buf[ 1024 ];

with:

TempAlloc< TCHAR > buf( 1024 );

and now everything seems to work. does this have any sideeffects?

regards,
peter

[EDIT]: just saw you already posted a solution, what i described above was replacing the first line in
StringTableEntry osGetTemporaryDirectory()
of your original fix.
i will try your solution too and post the results.
#24
03/29/2009 (12:39 pm)

Did you replace it in my code above or in the original? In the code above, it will work, though for odd reasons. In the original code it won't.

Just noticed, though, that the problem causing stack corruption wasn't insufficent buffer size at all, but rather some stupid mistake:

TCHAR buf[ 1024 ];
DWORD len = GetTempPath( sizeof( buf ), buf );

That's bogus as sizeof(buf) is the size in bytes not elements. Have fixed this in the code above. That should finally do it.
#25
03/29/2009 (1:08 pm)
both of the following works, but i will of course stick to your last suggestion :)

1) i did the replacement of
TCHAR buf[ 1024 ];
vs.
TempAlloc< TCHAR > buf( 1024 );
in your original fix. and it worked.
2) i replaced
DWORD len = GetTempPath( sizeof( buf ), buf );
with
DWORD len = GetTempPath( sizeof( buf ) / sizeof( buf[ 0 ] ), buf );

and it works too.

so thanks alot again for this quick help! if you want a copy of and yet it moves i would happy to send you one. just send me an email...

greets,
peter
#26
03/29/2009 (1:15 pm)

Yep, last version also fixes two other problems with the code.

Glad it works and email will come :) The game looks really great.
#27
04/23/2009 (11:49 am)
Hi!
I've just spotted the problem with saving profile/highscores etc. to %appdata% with non-latin charactes - or to be more precise it's problem that happened to localized version of my game (Fix-it-up: Kate's Adventure) and was found by one of QAs.

I've tried to use patches you've send - but doing it manually (what's that diff format??) failed.

It seems that it's ok with most of changed files but not with platformWin32/platformWin32.h - Rene - could you please send me whole file with changes to this email (contact@world-loom.com)?

Thanks in advance!
Adam
#28
04/23/2009 (11:54 am)
Sure, no problem. Email on its way.

//Edit: Hmm, actually, don't know if I'd be violating the license by distributing files so I'll just post the thing here.

//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

#ifndef _PLATFORMWIN32_H_
#define _PLATFORMWIN32_H_

// Sanity check for UNICODE
#ifdef TORQUE_UNICODE
#  ifndef UNICODE
#     error "ERROR: You must have UNICODE defined in your preprocessor settings (ie, /DUNICODE) if you have TORQUE_UNICODE enabled in torqueConfig.h!"
#  endif
#endif

// define this so that we can use WM_MOUSEWHEEL messages...
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif

#include <windows.h>
#ifndef _PLATFORM_H_
#include "platform/platform.h"
#endif

#if defined(TORQUE_COMPILER_CODEWARRIOR)
#  include <ansi_prefix.win32.h>
#  include <stdio.h>
#  include <string.h>
#else
#  include <stdio.h>
#  include <string.h>
#endif

#if defined(TORQUE_COMPILER_VISUALC) || defined(TORQUE_COMPILER_GCC2)
#define vsnprintf _vsnprintf
#define stricmp _stricmp
#define strnicmp _strnicmp
#define strupr _strupr
#define strlwr _strlwr
#endif

#define NOMINMAX

struct Win32PlatState
{
   FILE *log_fp;
   HINSTANCE hinstOpenGL;
   HINSTANCE hinstGLU;
   HINSTANCE hinstOpenAL;
   HWND appWindow;
   HDC appDC;
   HINSTANCE appInstance;
   HGLRC hGLRC;
   DWORD processId;
   bool renderThreadBlocked;
   S32 nMessagesPerFrame; // The max number of messages to dispatch per frame
   HMENU appMenu; //*** DAW: The menu bar for the window
#ifdef UNICODE
   HIMC imeHandle;
#endif

   S32 desktopBitsPixel;
   S32 desktopWidth;
   S32 desktopHeight;
   S32 desktopClientWidth;
   S32 desktopClientHeight;
   U32 currentTime;
   
   // minimum time per frame
   U32 sleepTicks;
   // are we in the background?
   bool backgrounded;

   Win32PlatState();
};

extern Win32PlatState winState;

extern bool GL_Init( const char *dllname_gl, const char *dllname_glu );
extern bool GL_EXT_Init();
extern void GL_Shutdown();

extern HWND CreateOpenGLWindow( U32 width, U32 height, bool fullScreen, bool allowSizing = true );
extern HWND CreateCurtain( U32 width, U32 height );
extern void CreatePixelFormat( PIXELFORMATDESCRIPTOR *pPFD, S32 colorBits, S32 depthBits, S32 stencilBits, bool stereo );
extern S32  ChooseBestPixelFormat( HDC hDC, PIXELFORMATDESCRIPTOR *pPFD );
extern void setModifierKeys( S32 modKeys );

#define WGLD3D_FUNCTION(fn_type, fn_name, fn_args, fn_value) extern fn_type (__stdcall *dwgl##fn_name)fn_args;
#define WGL_FUNCTION(fn_type, fn_name, fn_args, fn_value) extern fn_type (__stdcall *d##fn_name)fn_args;
#include "platformWin32/GLWinFunc.h"
#undef WGL_FUNCTION
#undef WGLD3D_FUNCTION

#define WGLEXT_FUNCTION(fn_type, fn_name, fn_args, fn_value) extern fn_type (__stdcall *d##fn_name)fn_args;
#include "platformWin32/GLWinExtFunc.h"
#undef WGLEXT_FUNCTION

//-------------------------------------- Helper Functions

template< typename T >
inline void forwardslashT( T *str )
{
   while(*str)
   {
      if(*str == '\')
         *str = '/';
      str++;
   }
}

inline void forwardslash( char* str )
{
   forwardslashT< char >( str );
}
inline void forwardslash( WCHAR* str )
{
   forwardslashT< WCHAR >( str );
}

template< typename T >
inline void backslashT( T *str )
{
   while(*str)
   {
      if(*str == '/')
         *str = '\';
      str++;
   }
}

inline void backslash( char* str )
{
   backslashT< char >( str );
}
inline void backslash( WCHAR* str )
{
   backslashT< WCHAR >( str );
}

#endif //_PLATFORMWIN32_H_
#29
04/23/2009 (12:08 pm)
Hmmm, I'm not sure how I've wrote those above. My problem is not related with quite easy platformwin32.h but with huge winFileio.cc - which even would not fit into these tiny boxes for code.

As far as I know sending patched file would not violate license as both of us have TGB pro. But if you think it could be a problem - a patch between 1.7.4 and your version would be enough - I can also try to go with what you've send already if it's any kind of automated patch system.

By the way - better would be my personal e-mail (a.r.janiec@world-loom.com) as the other guy using (contact@) is out and has annoying vacation message ;-)

One more thing >'\'< from code above does not work in VC++ as it's interpreted as echoed ' - does it problem with forum code or I missed something?

Thanks in advance,
Adam
#30
04/23/2009 (12:13 pm)

The missing backslashes are from the board software swallowing stuff. Maybe it has also messed with the diffs.

Know what, I'll just pack up the files diff'ed in this thread and send them your way. Probably should be okay.
#31
05/27/2009 (9:42 am)
Updated Win32 binaries for those without a Pro license:

TGB_Unicode_Binaries.7z

//EDIT: this is for TGB 1.7.4
#32
01/19/2010 (3:17 pm)
As found by Virtual Prophecy's Curt Weber, my implementation of ExecuteThread::ExecuteThread contains a bug that will cause a NULL dereference when 'args' and/or 'directory' is not supplied to shellExecute.

Here is the correct code:

ExecuteThread::ExecuteThread(const char *executable, const char *args /* = NULL */, const char *directory /* = NULL */) : Thread(0, NULL, false)
{
   SHELLEXECUTEINFO shl;
   dMemset(&shl, 0, sizeof(shl));

   shl.cbSize = sizeof(shl);
   shl.fMask = SEE_MASK_NOCLOSEPROCESS;
   
   char exeBuf[1024];
   Platform::makeFullPathName(executable, exeBuf, sizeof(exeBuf));
   
   TempAlloc< TCHAR > dirBuf( ( directory ? dStrlen( directory ) : 0 ) + 1 );
   dirBuf[ dirBuf.size - 1 ] = 0;

#ifdef UNICODE
   WCHAR exe[ 1024 ];
   convertUTF8toUTF16( exeBuf, exe, sizeof( exe ) / sizeof( exe[ 0 ] ) );

   TempAlloc< WCHAR > argsBuf( ( args ? dStrlen( args ) : 0 ) + 1 );
   argsBuf[ argsBuf.size - 1 ] = 0;

   if( args )
      convertUTF8toUTF16( args, argsBuf, argsBuf.size );
   if( directory )
      convertUTF8toUTF16( directory, dirBuf, dirBuf.size );
#else
   char* exe = exeBuf;
   char* argsBuf = args;
   if( directory )
      dStrpcy( dirBuf, directory );
#endif

   backslash( exe );
   backslash( dirBuf );
   
   shl.lpVerb = TEXT( "open" );
   shl.lpFile = exe;
   shl.lpParameters = argsBuf;
   shl.lpDirectory = dirBuf;

   shl.nShow = SW_SHOWNORMAL;

   if(ShellExecuteEx(&shl) && shl.hProcess)
   {
      mProcess = shl.hProcess;
      start();
   }
}
Page«First 1 2 Next»