logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Res-Man update - overwrite internals

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Wed Apr 18, 2012 0:29    Post subject: Res-Man update - overwrite internals Reply with quote

Could someone with write access consider updating resman for windows.
I have made the following changes to my local version, and it seems to function.

Im not saavi enough with c++ to impliment the hashtable that is in the linux version - to further optimize it.

Basically, this is so we can overwrite internal resources, with the external resources of the same name.


I tested this by loading up a module, placing X3_DM_TOOL10.ncs (modified with a new message)
Into the external sources folder - went in game, used DM Tool 10- and it correctly used the external version, over the internal version.

Also - It seems that the nwnx project builds quite well in visual studio 2010 - after being converted via the conversion wizard.
The only issue it reports is that there is a duplicate linkage/header of CreateThreadEx etc
Renaming the MadCHook.h declaration to have a 2 at the end, solved it.

It seems that Windows uses the same declaration in winbase.h - which is why it throws up errors.
Author of MadCHook used that method name first - then windows copied it.

Code:

#include <io.h>  //  <--  Put this at top


char* CNWNXResMan::DemandRes(CResStruct* cRes, char* resRef, NwnResType resType)
{
   unsigned long size;

   if (!resRef)
      return NULL;

   char resPath[MAXPATH + 16];
   strcpy(resPath, m_sourcePath);
   strcat(resPath, resRef);

   strcat(resPath, NwnGetResTypeExtension(resType));
   
   if (cRes->pResName)
   {
      if (_access(resPath, 0) == -1)
      {
         if (m_LogLevel == logAll)
         Log("o Request for internal resource = %s (type %X)\n", resRef, resType);
         // nothing for us to do
         return NULL;
      }
      Log("o Request for External resource to overwrite internal = %s (type %X)\n", resRef, resType);
   }

   // try to load external resource

   size = LoadResource(resPath);
   if (size == 0)
      return NULL;

   // resource loaded   
   // set resStruct
   cRes->pResData = pScriptBuffer;
   cRes->pResName = saveName;
   cRes->resSize = size;
   cRes->unk2 = 1;
   cRes->unk4 = 4;
   cRes->loaded = 1;
   cRes->loaded2 = 1;
   cRes->resSize2 = size;
   cRes->pResData2 = pScriptBuffer;

   cRes->id1 = 0;
   cRes->id2 = 0;
   cRes->id3 = 0;
   cRes->id4 = 0;

   // Call server function which sets various data pointers
   if (cRes->pClass)
   {
      char* pFunc = cRes->pClass;
      pFunc = (char*)(*(int*)(pFunc+0x10));
      __asm {
         mov ecx, cRes
         call pFunc
      }
   }

   //alternatively:
   //void (__fastcall *pServFunc)(CResStruct* cRes) = (void (__fastcall *)(CResStruct* cRes)) pFunc;
   //pServFunc(cRes);
   
   return cRes->pResData;

}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group