Bugs, Tweaks, Fixes for Windows
From LagoonWiki
Work in progress, just personal notes
Notes on Bullet 4 (updsrc.tcl - Gyarados):
Received an error: 'couldn't execute "python": no such file or directory' I was using Python 2.4.3, it was able to run in cygwin alright I updated my cygwin libs, Python 2.5 was installed, tclsh84 updsrc.tcl works correctly now
Deprecation warnings galore, defines don't do the trick (they should - TODO: figure out why):
Added /D_CRT_SECURE_NO_WARNINGS to each project properties under 'Command Line'
Errors about missing inttypes.h: seems MS defines the types themselves, changed code to:
#ifndef _MSC_VER #include <inttypes.h> #endif
MSVC doesn't support snprintf(), it uses _snprintf(). TODO: Make sure that the null-terminator difference between MS and Unix funcs work correctly. Changed ntexturearray.h:
snprintf(buf, N_MAXPATH, "%s", pixel_name);
to:
#ifndef _MSC_VER
snprintf(buf, N_MAXPATH, "%s", pixel_name);
#else
_snprintf(buf, N_MAXPATH, "%s", pixel_name);
#endif
Added tcl.h include path to nnebula, enkiduo projects. I selected the location I had downloaded it to+/generic/. The cygwin one didn't work, big surprise.
Changed nnebula Project Settings: Linke->General->Additional Library Directores to:
Debug,..\..\bin\win32d,..\..\lib\win
Added Python include directory to enkiduo project.
Replaced a bunch of 'and', 'or', 'not' with the _real_ c++ syntax, stupid gcc.
MSVC cannot figure out which operator[] to use with EndStateMachine, defined in nfsm.h, edited nfsm.h to:
n_printf("failed to find state : %i %s\n", state, ((nArray<uint>&)stateNames).operator[]((uint)state));\
Changed Line 29 of nside.h and Line 33 of nside_main.cc, MSVC complaining about 'static const int VOID', probably because it thinks VOID is a type.
defineEnum( RELATIONSHIPS, RVOID ); playerRelationship.DefaultI( RVOID );
Added tnl path to enkiduo project settings include path.
A lot more changes to 'and', 'or', 'not' with the _real_ c++ syntax
Since MSVC doesn't contain a round() in math.h, I grabbed one from a site:
double round( double x)
// Copyright (C) 2001 Tor M. Aamodt, University of Toronto
// Permisssion to use for all purposes commercial and otherwise granted.
// THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY, OR ANY CONDITION OR
// OTHER TERM OF ANY KIND INCLUDING, WITHOUT LIMITATION, ANY WARRANTY
// OF MERCHANTABILITY, SATISFACTORY QUALITY, OR FITNESS FOR A PARTICULAR
// PURPOSE.
{
if( x > 0 ) {
__int64 xint = (__int64) (x+0.5);
if( xint % 2 ) {
// then we might have an even number...
double diff = x - (double)xint;
if( diff == -0.5 )
return double(xint-1);
}
return double(xint);
} else {
__int64 xint = (__int64) (x-0.5);
if( xint % 2 ) {
// then we might have an even number...
double diff = x - (double)xint;
if( diff == 0.5 )
return double(xint+1);
}
return double(xint);
}
}
In nimradial.h: RELATIVE and ABSOLUTE in enum TOS were already defined:
// MH: Fixed the TOS compilation error #ifdef _MSC_VER #undef RELATIVE #undef ABSOLUTE #endif
The _MSC_VER check can probably be removed safely.
Added __WIN32__ ifdefs to nsocket_main.cc, nsock_cmds.cc, nsoundemitter_main.cc.
Changed nfsm_main.cc line 50 to:
// MH: Changed due to MSVC ambigiuty on operator[]
n_printf("warning nFSM(%s) is in state %s and has been told to change state to both [%s|%s] simulatenously\n", this->fn, ((nArray<int>&)this->stateNames).operator []((int)currState.localState), ((nArray<int>&)this->stateNames).operator []((int)nextState.localState), ((nArray<int>&)this->stateNames).operator []((int)localState));
Complained couldn't find tnl.lib, added correct path to project enkiduo.
Complained couldn't find tomcrypt.lib, changed input lib in project settings to libtomcrypt.lib.
Building ODE: In config.h comment defines that you don't have, ie alloc.h, stdint.h, etc - there's about a dozen.
Change to #define dCopySign(a,b) ((dReal)copysign(a,b))
Make sure you select debuglib to build under, compile it. Copy from ode/lib/debuglib/ode.lib to externalPackages/lib
ndirect3d8 project:
Microsoft no longer develops dx8sdks, had to use the latest with 9 and 10 included. d3d8.h is included, however they removed d3dx8.h which defines some formats and a few functions. I moved most of the code to 9, had to remove some shader calls to get it to compile, will go back and fix as it will be an issue when running.
Received lnk2005 errors on nkernel's nroot, already defined in nai_cmds.obj:
Moved defined inline functions from nroot.h to nroot_main.cc Leave Chris' const char* str function in nroot.h
Got further on linking, MSVCRTD and LIBCMT functions conflicting (already defined):
Enkiduo Project Settings->Linker->Input->Ignore Specific Library: LIBCMT
Unresolved symbols:
Comment out the glLineWidth calls in nDisplayer::Display(...) for now
Add ws2_32.lib to the linker library input in Enkiduo project
Commented out (after we fix socket/sound stuff, add it back in) in pkg_enkiduo.cc:
//ks->AddModule("nsoundemitter",n_init_nsoundemitter,n_fini_nsoundemitter,n_new_nsoundemitter);
//ks->AddModule("nsocket",n_init_nsocket,n_fini_nsocket,n_new_nsocket);
//ks->AddModule("nopenalserver",n_init_nopenalserver,n_fini_nopenalserver,n_new_nopenalserver);
Change in nglserver.h:
#include <GL/gl.h> #include <GL/glu.h>
to:
#undef fn #include <GL/gl.h> #include <GL/glu.h>
Enkiduo project links correctly. Onto project go: Add tcl.h and python.h include pathes, as well as python2x.lib path.
Go project links correctly. Onto nopengl: Add devil.lib path to linker settings.
nopengl project links correctly.
A lot of linker errors on the controller project, it appears some .obj files are conflicting with other projects' object files:
Ah ha! http://permalink.gmane.org/gmane.comp.graphics.nebuladevice.cvs/7237 "Each nRoot derived class should be defined in a separate module in the build file (.bld). For example, lets say you have two classes, one named MyApp and the other MyAppState and both of them are derived from nRoot. Then, you should define two separate modules for the classes in the build file."
Changed avatar\bin\makesln.tcl to reflect some of our paths:
set release_libpath "..\\..\\bin\\win32,..\\..\\lib\\win,C:\\Python25\\libs,C:\\tcl\\Release_VC8" set debug_libpath "..\\..\\bin\\win32d,..\\..\\lib\\win,C:\\Python25\\libs,C:\\tcl\\Release_VC8" set incpath "..\\inc,C:\\tcl\\generic,C:\\Python25\\include"
Linker errors still exist (TODO: Fixme so that it properly imports this stuff from enkiduo.lib):
Copy the filter "folders" into controller: n2dpolygon, nallocatorastar, naspect, nastar, ncollideserver, nim, nprofserver, nthing, nvar Copy the filter "folders" into group: naspect, ncollideserver, nthing, nvar
Everything now links and builds correctly. Below this are fixes to get it actually working:
Comment out the TCL stuff in main.cc in project go.
When running python reports os.getenv('NEBULADIR') is a NoneType, fix environment variable:
Right click My Computer->Properties->Advanced->Environment Variables->User variables for %username%->New: Variable = NEBULADIR Value = %your_avatar_directory_path%
ImportError: No module named common.defs. Add to go.py:
##MH: Windows changes #sys.path.append(nebuladir + '/code/scripts/') sys.path.append(nebuladir + '\\code\\scripts') ##--
Locks up with an "Incomptible cygwin .dll" Error. http://www.delorie.com/howto/cygwin/mno-cygwin-howto.html explains this.
Removed cygwin, on my system it had somehow dug it's claws into my command prompt.
Complains of tcl84.dll
Copy tcl84.dll to /bin/win32d
Compains "Could not load dll 'nopengl'":
Stupid Windows, download DevIL.dll and ILU.dll from http://openil.sourceforge.net/download.php Place into /bin/win32d
"Could not load dll 'nlxinputserver'": nlxinputserver is for linux, we use ndi8inputserver on superior windows:
Open code/scripts/common/servers.py and add:
#new('nlxinputserver', 'input')
new('ndi8server', 'input')
"Could not load dll 'nopenalserver'": Kill the audio for now:
Open code/scripts/common/servers.py and add:
#new('ndsoundserver2', 'audio')
#call('audio.setcameravelcoef', 0)
"Could no load dll 'nfsmlink'": Who knows
Temp fix: open nfsm_main.cc, comment:
//nFSMLink* link = (nFSMLink*) kernelServer->New("nfsmlink", "link", "nvisnode");
TCL Error in goReduced: Comment the call out in go.py
After loading group package, segfaults - appears that the kernelServer in nthing_main.cc::Initialize() is null -- WHY?
Moved group stuff into Enkiduo project, updated pkg_enkiduo.cc to support the group stuff.
It runs! Moved controller and group stuff into enkiduo project, updated the pkg_enkiduo.cc file for the controller and group stuff.
Changed nopenalserver.h and nsoundemitter_main.cc to work in Windows
wxPython is having some trouble running, errors in scripts:
--------------------------------------------------------------------------------
Exception thrown in module: fileManager
--------------------------------------------------------------------------------
Traceback (most recent call last):
File "C:/Documents and Settings/mharmer/Desktop/avatar//code/scripts/common/go.py", line 77, in <module>
FileManager.runDefaultXMLParsers()
File "C:\Documents and Settings\mharmer\Desktop\avatar\code\scripts\common\FileManager.py", line 81, in runDefaultXMLParsers
call('/sys/servers/audio.loadwav', name, file)
AttributeError: Unknown command, object 'audio', command 'loadwav'
--------------------------------------------------------------------------------
option pathfind not found
MapManager.load(openwater,naval\maps\openwater.xml)
MapManager.createMapNode(common\heightmaps\flat.bmp,0.000000->-500.000000)
MapManager.adjustCamera pos:[10000.0, 500.0, 10000.0] rot:[0.0, 0.86599999999999999, 0.5, 0.0]
MissionManager.load(empty,cove\missions\empty.xml)
option pathfind not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:/Documents and Settings/mharmer/Desktop/avatar//code/scripts/common/go.py", line 111, in <module>
from common import compass #nice on screen compass
File "C:\Documents and Settings\mharmer\Desktop\avatar\code\scripts\common\compass.py", line 7, in <module>
genShader('simple')
File "C:\Documents and Settings\mharmer\Desktop\avatar/code/scripts/common/defs.py", line 73, in genShader
set('/lib/shaders/%s.clone' % shadername, 'shader' )
Exception: Unable to acquire current object.
Fix: Open compass.py, change:
genShader('simple') to genShader('standard')
genShader('simplealpha') to genShader('alpha')
Got a little further, new error:
-------------------------------------------------------------------------------- Exception thrown in module: loadingGui -------------------------------------------------------------------------------- Traceback (most recent call last): File "C:/Documents and Settings/mharmer/Desktop/avatar//code/scripts/common/go.py", line 150, in <module> frame = GUIManager.MainFrame(None, -1) File "C:\Documents and Settings\mharmer\Desktop\avatar\code\scripts\common\GUIManager.py", line 63, in __init__ catPanel = catGUI.CATPanel(self, size=size) File "C:\Documents and Settings\mharmer\Desktop\avatar\code\scripts\ui\cat\catGUI.py", line 54, in __init__ catPanel = catAuthoringPanel.CatAuthoringPanel(self, size=size) File "C:\Documents and Settings\mharmer\Desktop\avatar\code\scripts\ui\cat\catAuthoringPanel.py", line 58, in __init__ self.entityPanel = catEntityPanel.EntityPanel(self, size=eSize) File "C:\Documents and Settings\mharmer\Desktop\avatar\code\scripts\ui\cat\catEntityPanel.py", line 68, in __init__ wx.Panel.__init__(self, parent, -1, size=size, style = wx.RAISED_BORDER | wx.DOUBLE_BORDER) File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_windows.py", line 68, in __init__ _windows_.Panel_swiginit(self,_windows_.new_Panel(*args, **kwargs)) wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed at ..\..\src\msw\window.cpp(1376) in wxWindow::MSWGetStyle(): unknown border style --------------------------------------------------------------------------------
Removed wx.DOUBLE_BORDER in various UI/CAT files
Cat loads, yay.
Nebula Assertion, debugging in MSVC: Call stack:
nkernel.dll!n_barf(const char * exp=0x100581d4, const char * file=0x10057d08, int line=603) Line 71 + 0x8 bytes C++ nkernel.dll!nKernelServer::PushCwd(nRoot * o=0x00000000) Line 603 + 0x1e bytes C++ enkiduo.dll!nTextDisplayer::Attach(nSceneGraph2 * sceneGraph=0x05001da4) Line 65 + 0x36 bytes C++ nnebula.dll!nVisNode::Attach(nSceneGraph2 * sceneGraph=0x05001da4) Line 246 + 0x13 bytes C++
Appears it fails on ::PushCwd on a null pointer.
Added a null pointer check to return in nTextDisplayer::Attach
Another assertion:
> msvcr80d.dll!operator delete(void * pUserData=0x059f4fcc) Line 52 + 0x51 bytes C++ enkiduo.dll!TNL::NetConnection::handleNotify(unsigned int sequence=63262179, bool recvd=true) Line 637 + 0x6 bytes C++ enkiduo.dll!TNL::NetConnection::readPacketHeader(TNL::BitStream * pstream=0x03c553d4) Line 455 C++ enkiduo.dll!TNL::NetConnection::readRawPacket(TNL::BitStream * bstream=0x03c555d6) Line 247 + 0xf bytes C++ enkiduo.dll!TNL::NetConnection::sendPacket(TNL::BitStream * stream=0x0534b1f0) Line 721 + 0xc bytes C++
A temp fix is to comment out "delete node" in netConnection.cc in tnl - MH: TODO: FIX THIS
Another assertion:
put a return at the top of nSoundEmitter::Tick(..)
Alright, going back and fixing up the nfsmlink stuff: Spent 2 hours on this one: Add N_PUBLIC to nlinknode.h (so it will export the class properly into the .lib):
class N_PUBLIC nLinkNode : public nVisNode {
Different linker errors now, all dealing with nLinkNode::ks(): For whatever reason, attempting to use N_PUBLIC (ie, __declspec(dllexport)) doesn't work on static variables. Placed the following into nfsmlink_main.cc:
nClass *nLinkNode::local_cl = NULL; nKernelServer *nLinkNode::ks = NULL;
Added the following to nFSMLink::Initialize():
nLinkNode::ks = kernelServer;
Uncommenting the following in nfsm_main.cc will allow the rmenu and minimap to be rendered:
link->SetFSM( this ); if(this->visNode.isvalid()) ((nFSMLink*)this->visNode.get())->SetFSM( this ); this->visNode = link;
Undid the following step: TCL Error in goReduced: Comment the call out in go.py
Lights and fonts work now.
Changed/added to nincludes.h before the #define tok:
#ifdef __WIN32__ #define strtok_r(a,b,c) strtok_s(a,b,c) #endif
VShipComm->Connect event doesn't work: Juan's fix:
GUIManager.py:
# Create cove comms for Lagoon
try:
import comms
self.coveClient = comms.getGUI(self, (0, 0))
except:
printExcept('No cove communications')
ID_CONNECT = 5050
menu = wx.Menu()
menu.Append (ID_CONNECT, '&Connect', 'Connect to Cove');
self.coveMenu = menu
menubar.Append (menu, 'VShipComm')
wx.EVT_MENU (self, ID_CONNECT, self.connect)
def connect(self, event):
self.coveClient.connect(event)
coveclient.py:
def initializeMenuItems(self, parent, size):
return
__init__.py:
def getGUI(frame, size): coveclient.coveClient.initializeMenuItems(frame, size) return coveclient.coveClient #return coveclient.CoveClient(frame, size)
Reworking the project and committing stuff...
ninfluencemap_main.cc::init not found
Uncomment the ifdefs on windows in narrayops.h - why are they there?
Reworking the nwaver and nbob linker errors...
Replace N_DLLCLASS with N_PUBLIC in nMeshMixer.h
Added following to nwaver_main.cc:
nKernelServer *nMeshMixer::kernelServer;
Reworking sound stuff... Wrap class nOpenALServer stuff in #ifdef's, put in nDSoundServer2 for WIN32
nDSoundServer2 doesn't appear to have been worked on for lagoon, trying openal...
http://www.openal.org/downloads.html
In nsoundemitter_main.cc:
#ifndef __WIN32__
n_assert( offsetPos.x != NAN && offsetPos.y != NAN && offsetPos.z != NAN );
#else
n_assert( _isnan(offsetPos.x) && _isnan(offsetPos.y) && _isnan(offsetPos.z) );
#endif
Compains can't load enkiduo.dll - copy OpenAL32.dll and alut.dll into the directory.
Release Build Project Properties -> Set Inline Function Expansion to: Default
Load Plan Fix: Open GUIManager.py: onLoadPlan and onSavePlan: replace:
reg = re.compile(r'([^\\/]+)\.xml')
add after file = dlg.getStringSelection():
file = file.replace("\\", "/")
OpenAL fix:
Find a card that actually works, Check. Explicitly assign size = 32 (24 on some computers) in nOpenALServer::InitBuffers(int size) before it's used. This deals with error 0x0000a003, figure out what causes 0x0000a001 on the other systems after calling alGenSources().
Complete File List: Add the following to bin/win32
go.exe alut.dll DevIL.dll ILU.dll OpenAL32.dll python25.dll tcl84.dll
msvcm80.dll (Copy from C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700) msvcp80.dll (Copy from C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700) msvcr80.dll (Copy from C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700) Microsoft.VC80.CRT.manifest (Copy and rename from C:\Windows\WinSxS\Manifests\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700.manifest) same with DebugCRT
enkiduo.dll .toc ncollide.dll .toc ndinput8.dll .toc ndsound.dll .toc nkernel.dll .toc nmap.dll .toc nnebula.dll .toc nopcode.dll .toc nopengl.dll .toc nparticle.dll .toc npython.dll .toc opcode.dll
And the following folders:
avatar/code avatar/data
And the following files:
bin/nsh.tcl
Folder layout:
Avatar bin win32 code data
Todo:
Get the python libs sorted
NSI Install Script:
!include LogicLib.nsh
!include Library.nsh
!include MUI.nsh
; Create a temp file with our revision
!system avatarVersion.exe
!include svnrev.txt
;--------------------------------
; General
Var PythonDirectory
Name "Lagoon (Avatar - r${SVNRevision})"
OutFile "lagoon_w32_x86-avatar.exe"
InstallDir $PROGRAMFILES\Lagoon
DirText "This will install Lagoon on your computer. Choose a directory"
;--------------------------------
; Interface Configuration
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "unr.bmp"
!define MUI_ABORTWARNING
;--------------------------------
; Pages
!insertmacro MUI_PAGE_LICENSE "License.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
; Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
; Installer Sections
Section "Python/wxPython" SecPython
; Check for Python
Call IsPythonInstalled
${If} $PythonDirectory != "0"
MessageBox MB_OK "Python2.5 is already installed."
${Else}
MessageBox MB_YESNO "Python2.5 is not installed. Would you like to install it now?" IDYES installPython IDNO skipinstallPython
installPython:
SetOutPath $INSTDIR\tmp
File python-2.5.1.msi
ExecWait '"msiexec" /i "$INSTDIR\tmp\python-2.5.1.msi"'
Delete "$INSTDIR\tmp\python-2.5.1.msi"
;Grab our PythonDir
Call IsPythonInstalled
skipinstallPython:
${EndIf}
; Check for wxPython
DetailPrint "Python Directory: $PythonDirectory"
${If} $PythonDirectory != "0" ; Check if we have Python installed first
${If} ${FileExists} "$PythonDirectory\Lib\site-packages\wx-2.8-msw-unicode\wxPython\__init__.py"
MessageBox MB_OK "wxPython is already installed."
${Else}
MessageBox MB_YESNO "wxPtyon is not installed. Would you like to install it now?" IDYES installWxPython IDNO skipinstallWxPython
installWxPython:
SetOutPath $INSTDIR\tmp
File wxPython2.8-win32-unicode-2.8.4.0-py25.exe
ExecWait '"$INSTDIR\tmp\wxPython2.8-win32-unicode-2.8.4.0-py25.exe"'
Delete "$INSTDIR\tmp\wxPython2.8-win32-unicode-2.8.4.0-py25.exe"
skipinstallWxPython:
${EndIf}
${EndIf}
RMDir "$INSTDIR\tmp"
SectionEnd
Section "Lagoon" SecLagoon
; Place our binaries
SetOutPath $INSTDIR\bin\win32
File /r /x *.exp /x *.lib /x *.svn /x *.cvsignore /x Makefile ..\bin\win32\*
File .\tcl84.dll
SetOutPath $INSTDIR\bin
File ..\bin\nsh.tcl
File ..\bin\keyframeed.tcl
SetOutPath $INSTDIR\data
File /r /x *.svn* /x *.cvsignore /x Makefile ..\data\*
SetOutPath $INSTDIR\doc
File /r /x *.svn* /x *.cvsignore /x Makefile ..\doc\*
SetOutPath $INSTDIR\code\scripts
File /r /x *.svn* /x *.cvsignore /x Makefile ..\code\scripts\*
SetOutPath $INSTDIR
File ..\readme.html
CreateShortCut $INSTDIR\go.lnk $INSTDIR\bin\win32\go.exe
WriteUninstaller $INSTDIR\uninstaller.exe
SectionEnd ; end the section
;--------------------------------
; Descriptions
LangString DESC_SecPython ${LANG_English} "This will install Python and wxPython to your machine."
LangString DESC_SecLagoon ${LANG_English} "This will install Lagoon to your machine."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecLagoon} $(DESC_SecLagoon)
!insertmacro MUI_DESCRIPTION_TEXT ${SecPython} $(DESC_SecPython)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
; Unistaller Section
Section "Uninstall"
RMDir /r "$INSTDIR"
SectionEnd
;--------------------------------
; Helper Functions
Function IsPythonInstalled
Push $R0
ClearErrors
ReadRegStr $R0 HKLM "SOFTWARE\Python\PythonCore\2.5\InstallPath" ""
IfErrors lbl_na
StrCpy $PythonDirectory $R0
Goto lbl_end
lbl_na:
ReadRegStr $R0 HKCU "SOFTWARE\Python\PythonCore\2.5\InstallPath" ""
IfErrors lbl_na2
StrCpy $PythonDirectory $R0
Goto lbl_end
lbl_na2:
StrCpy $PythonDirectory 0
lbl_end:
FunctionEnd
; These three taken from NSIS wiki
Function un.RMDirUP
!define RMDirUP '!insertmacro RMDirUPCall'
!macro RMDirUPCall _PATH
push '${_PATH}'
Call un.RMDirUP
!macroend
; $0 - current folder
ClearErrors
Exch $0
;DetailPrint "ASDF - $0\.."
RMDir "$0\.."
IfErrors Skip
${RMDirUP} "$0\.."
Skip:
Pop $0
FunctionEnd
avatarVersion.nsi:
Var SVNRevision
OutFile "avatarVersion.exe"
Function .onInit
Push 4
Push "$EXEDIR\..\.svn\entries"
Call ReadFileLine
Call Trim
Pop $SVNRevision
FileOpen $R0 "$EXEDIR\svnrev.txt" w
FileWrite $R0 '!define SVNRevision "$SVNRevision"'
FileClose $R0
Abort
FunctionEnd
; These two functions taken from NSIS Wiki
Function ReadFileLine
Exch $0 ;file
Exch
Exch $1 ;line number
Push $2
Push $3
FileOpen $2 $0 r
StrCpy $3 0
Loop:
IntOp $3 $3 + 1
ClearErrors
FileRead $2 $0
IfErrors +2
StrCmp $3 $1 0 loop
FileClose $2
Pop $3
Pop $2
Pop $1
Exch $0
FunctionEnd
Function Trim
Exch $R1 ; Original string
Push $R2
Loop:
StrCpy $R2 "$R1" 1
StrCmp "$R2" " " TrimLeft
StrCmp "$R2" "$\r" TrimLeft
StrCmp "$R2" "$\n" TrimLeft
StrCmp "$R2" "$\t" TrimLeft
GoTo Loop2
TrimLeft:
StrCpy $R1 "$R1" "" 1
Goto Loop
Loop2:
StrCpy $R2 "$R1" 1 -1
StrCmp "$R2" " " TrimRight
StrCmp "$R2" "$\r" TrimRight
StrCmp "$R2" "$\n" TrimRight
StrCmp "$R2" "$\t" TrimRight
GoTo Done
TrimRight:
StrCpy $R1 "$R1" -1
Goto Loop2
Done:
Pop $R2
Exch $R1
FunctionEnd
Section
SectionEnd
Updated go.py:
# MH: Fixed up code for cross platform
# basedir replaces old NEBULADIR environment variable on Windows
if os.name == 'nt':
basedir = os.path.dirname(sys.executable).rpartition('\\win32')[0].rpartition('\\bin')[0]
os.chdir(os.path.abspath(basedir + '\\data'))
sys.path.append(os.path.abspath(basedir + '\\code\\scripts'))
else:
basedir = os.getenv('NEBULADIR')
os.chdir(os.path.abspath(basedir + '/data'))
sys.path.append(os.path.abspath(basedir + '/code/scripts'))
Fixing memory leaks:
Error in Debug when using networks (TNL): average isn't initialized:
template<class TYPE>
inline TYPE calculateAverage(nArray<TYPE> arr)
Comment out in nallocator_main.cc (tries to initialize average as a vector with pointer 0)
//info.centroid = calculateAverage( info.positions );
Errors:
Select Unit, do a Tack command, dies on:
current = current->parent;
In nprofserver_main.cc
'UnregisterClass' failed with error 0x00000584 (class still has open windows.) Occurs because the window wxPython creates doesn't get closed: http://twistedmatrix.com/pipermail/twisted-python/2003-June/004352.html
Added the following to release.py, it cleans up the Control window a bit better, but Debug still reports an open window.
frame.Destroy()
Added to app.py (class App(wx.App)): Removes the creation of stdout window and prints to the console instead.
def __init__(self):
wx.App.__init__(self, 0)
Packing executables: Placed UPX into installer directory, added the following to the project Post-Build script:
..\..\installer\upx.exe $(OutDir)\$(TargetFileName)
Testing pysco performance...
npython.pak: OS independent change:
Replace:
exec rm output
With:
file delete output
Figure out where to place tcl84.dll, so the entire ActiveStateTCL isn't required to run.
Gyarados (here because wiki doesn't like the tcl stuff on that page)
Big one, after fixes you may get:
C++/C library header files with _DEBUG defined and some with _DEBUG not defined.
Fix in enkiduo/neventserver/neventserver_main.cc:
//#include "tnl.h"
What is this? allocCache.h
#include "google/dense_hash_map"
Had to add sparsemap, from code.google to inc/google
Note: For linux, this directory cannot exist (it pulls it from somewhere else)
niment_main.cc will give a runtime error, using variable x and y without being defined. Strange as it should be defined before hitting the comparison, the compiler must be doing some rearranging here under the hood (even in debug).
int x = minX, y = minY;
for ( x = minX && x > 0; x < maxX && x < res; x++ ) {
for( y = minY && y > 0; y < maxY && y < res; y++ ) {
Yea, don't really need to redefine it, but it doesn't hurt.
Have to generate the .n3d files (aren't under source control), add wfclean, wfflatten and wftriang to the solution and build projects. Pass .obj files through (example):
wfclean < scout.obj | wftriang | wfflatten > scout.n3d
Todo: Make a bat file to do batch file processing.
FoW segfault fix in nfow_main.cc:
nEnt* e = enemy_units->Get(i);
if(! e->get_is_misc()
&& e->HasVar("can_hideInFOW")
&& e->GetVarI("can_hideInFOW"))
{
vector3 pos = e->GetVarV("pos");
// check for outofbounds
int iIndex = MapVectorToBin(pos);
if(iIndex <= visible_map_area.Size())
e->set_visible(visible_map_area[iIndex].visible);
} else {
e->set_visible(true);
}
Heap Corruption, breaks at the location already screwed up by a pointer so it's consistently random. Get "Debugging Tools for Windows" from microsoft's site.
- Run gflags.exe
- Image Tab
- Image name = "go.exe", press Tab
- Enable the following:
- Enable heap tail checking
- Enable heap free checking
- Enable heap parameter checking
- Enable heap validation on call
- Disable heap coalesce on free
Rerun the debug in MSVC IDE, should break on:
N_EXPORT void
nNode::Remove(void)
{
//printf("Remove:%p Pv:%p Nx:%p\n", this, this->pred, this->succ);
///move any head / tail links to me
if ( this->linked ) {
if ( this->nNodeList->head == this ) {
this->nNodeList->head = this->succ;
}
if ( this->nNodeList->tail == this ) {
this->nNodeList->tail = this->pred;
}
}
///move links from my pred / succ
if( this->pred )
this->pred->succ = this->succ;
if( this->succ )
this->succ->pred = this->pred;
///remove my own links
this->pred = 0;
this->succ = 0;
this->linked = false;
this->nNodeList = 0;
}
At either:
this->pred->succ = this->succ;
or:
this->succ->pred = this->pred;
Indicating the list of pointers is becoming mixed up somehow.
Stacktrace:
nkernel.dll!nNode::Remove() Line 154 + 0xc bytes C++
nkernel.dll!nRoot::RemObjectRef(nRef<nRoot> * r=0x41f43080) Line 34 C++
enkiduo.dll!nRef<n3DNode>::~nRef<n3DNode>() Line 164 C++
enkiduo.dll!nBeamTurret::BulletInfo::~BulletInfo() + 0x2b bytes C++
enkiduo.dll!`eh vector destructor iterator'(void * ptr=0x41f43080, unsigned int size=120, int count=31, void (void *)* pDtor=0x078da103) + 0x65 bytes C++
enkiduo.dll!nBeamTurret::BulletInfo::`vector deleting destructor'() + 0x42 bytes C++
enkiduo.dll!nArray<nBeamTurret::BulletInfo>::GrowTo(int newAllocSize=96) Line 326 + 0x2e bytes C++
enkiduo.dll!nArray<nBeamTurret::BulletInfo>::CheckIndex(int index=64) Line 484 C++
enkiduo.dll!nArray<nBeamTurret::BulletInfo>::Push() Line 540 C++
enkiduo.dll!nBeamTurret::Tick(float time=596.27051, float dtime=0.0099999998) Line 144 + 0xe bytes C++
enkiduo.dll!nTriggerServer::TickQueue(int name=0, float dtime=0.0099999998) Line 167 + 0x4e bytes C++
enkiduo.dll!nTriggerServer::TickThings(nThing * things=0x0901cbf8) Line 127 + 0x21 bytes C++
enkiduo.dll!nTriggerServer::TriggerThings(float time=1213.1299) Line 91 + 0x27 bytes C++
enkiduo.dll!nGameServer::MainLoop() Line 217 + 0x33 bytes C++
enkiduo.dll!nGameServer::Start() Line 150 + 0x12 bytes C++
go.exe!_main() + 0x41f bytes
go.exe!__tmainCRTStartup() Line 597 + 0x19 bytes C
go.exe!mainCRTStartup() Line 414 C
And the other location of heap corruption, stacktrace:
enkiduo.dll!nVar::CheckType(VarType varType=VARTYPE_REF) Line 176 + 0x3 bytes C++
enkiduo.dll!nVar::RemoveChildVar(var * childVar=0x3a9286ec) Line 87 C++
enkiduo.dll!var::~var() Line 54 + 0x6a bytes C++
enkiduo.dll!nHardPointAttach::~nHardPointAttach() Line 64 + 0x48 bytes C++
enkiduo.dll!nHardPointAttach::`scalar deleting destructor'() + 0x2b bytes C++
nkernel.dll!nRoot::Release() Line 138 + 0x34 bytes C++
enkiduo.dll!nBeamTurret::BlockDeath(bool urgent=false) Line 97 + 0x34 bytes C++
enkiduo.dll!nEnt::CheckDeath() Line 620 + 0x14 bytes C++
enkiduo.dll!nEnt::Die() Line 576 + 0x12 bytes C++
enkiduo.dll!nTurret::Tick(float time=669.73218, float dtime=0.0099999998) Line 110 + 0x1d bytes C++
enkiduo.dll!nBeamTurret::Tick(float time=669.73218, float dtime=0.0099999998) Line 111 C++
enkiduo.dll!nTriggerServer::TickQueue(int name=0, float dtime=0.0099999998) Line 167 + 0x4e bytes C++
enkiduo.dll!nTriggerServer::TickThings(nThing * things=0x0901cbf8) Line 127 + 0x21 bytes C++
enkiduo.dll!nTriggerServer::TriggerThings(float time=1264.2361) Line 91 + 0x27 bytes C++
enkiduo.dll!nGameServer::MainLoop() Line 217 + 0x33 bytes C++
enkiduo.dll!nGameServer::Start() Line 150 + 0x12 bytes C++
go.exe!main(int argc=3, char * * argv=0x01d78fb8) Line 110 + 0x18 bytes C++
go.exe!__tmainCRTStartup() Line 597 + 0x19 bytes C
go.exe!mainCRTStartup() Line 414 C
Large problem and very hard to track down, only able to break at the correct spot with page heap turned on. What's happening is unclear, for no apparent reason the vis member in bulletInfo struct is in an internal list whose pointers eventually get mangled. The work around higher up is to explicitly call the correct constructor for bullets (nArray of bulletInfo) in nbeamturret_main.cc with a larger initialSize so when the rogue array does decide to grow from 64 to 96 it will not be copying and then deleting the old array, which in turn eventually calls the destructor to vis, which attempts to remove a certain element improperly from the list.
Change in nbeamturret_main.cc:
nBeamTurret::nBeamTurret():
muzzleFlash(0),
bullets(128, 0)
{
}
Error: check type differs on /lib/ents/fishingboat/bars/constructionCost_oil : is VOID should be FLOAT
Delete:
- /data/lagoon/ents/deprecated/*.xml
Fix the water error, gyarados/code/scripts/common/MapManager.py:
'''
genMesh('waveplane')
call('mesh.setreadonly', True)
call('.beginsources', 1)
call('.setsource', 0, 'mesh', 'time')
call('.endsources')
call('.setnormalize', True)
call('.setupdatecoord', True)
call('.setupdatenorm', False)
call('.setupdatecolor', False)
call('.setupdateuv0', True)
call('.setupdateuv1', True)
call('.setupdateuv2', True)
call('.setupdateuv3', True)
'''
Getting Release to work is weird: Download AppVerifier from MSDN site. Enable Basic Checks for go.exe Run once, let it crash Disable basic checks for go.exe Run again and it works always
TODO list:
- OpenAl errors and no audio
- Networking
Asserts on Line 170 in ntnlent.cc:
n_assert(varOffsetCounter < vars.Size());
OpenAL error stuff: Looks like the source nArray is being filled with the same ALuint values when InitBuffers is called, that is why AL_INVALID_NAME is being thrown. alGenSources needs to be looked at, generates AL_INVALID_VALUE.
Quick fix:
void nOpenALServer::InitBuffers( int size ) {
size = 64;
buffer.Reallocate( size,0 );
alGenBuffers( size, buffer.Begin() );
source.Reallocate( size,8 );
int i = 0;
while (!alGetError()) {
source.Insert(i, 0);
alGenSources(1, &source[i++]);
}
n_printf("alGenSources failed at %u\n", i);
CheckError();
}
void nOpenALServer::LoadWav( const char* name, const char* filename ) {
void* data;
log("nOpenALServer::LoadWav(%s,%s)", name, filename );
Sound& s = sounds.Push();
s.name = name;
s.filename = filename;
s.buffer = buffer.Push();
s.source = source.Pop();
Won't go over dwMaxHw3DAllBuffers (DirectX Caps Viewer), my card was 64. Some entities will not speak. Attempting to clean up the initBuffers a bit.
Actual fix, it re-inits over old already created sources and sets them to 0 when they shouldn't be.
void nOpenALServer::InitBuffers( int size ) {
size = 64;
ALuint sourceID;
buffer.Reallocate( size,0 );
alGenBuffers( size, buffer.Begin() );
if (!source.Size()) {
source.Reallocate( size,8 );
for (int i = 0; i < size-1; i++) {
alGenSources(1, &sourceID);
source.Insert(i, sourceID);
}
CheckError();
} else {
n_printf("Hack workaround in effect, not initing source sound\n");
}
}
void nOpenALServer::LoadWav( const char* name, const char* filename ) {
void* data;
log("nOpenALServer::LoadWav(%s,%s)", name, filename );
Sound& s = sounds.Push();
s.name = name;
s.filename = filename;
s.buffer = buffer.Push();
if( source.Size() )
s.source = source.Pop();
else
s.source = 0;
log("s.buffer:%i s.source:%i", s.buffer, s.source );
//setup that source
ALboolean al_bool;
n_printf("OpenAl Debug: s.source=%i\n", s.source);
alutLoadWAVFile((ALbyte*) filename, &s.format, &data, &s.size, &s.freq, &al_bool ); // alutLoadWAVFile((ALbyte*) filename, &s.format, &data, &s.size, &s.freq, &al_bool );
//n_printf("format:%i data:%p size:%i freq:%i al_bool:%i\n", s.format, data, s.size, s.freq, al_bool );
alBufferData( s.buffer, s.format, data, s.size, s.freq );
alutUnloadWAV( s.format, data, s.size, s.freq );
CheckError();
alSourcei( s.source, AL_BUFFER, s.buffer );
alSourcef( s.source, AL_PITCH, 1.0 );
alSourcef( s.source, AL_GAIN, 0.1 );
alSourcefv( s.source, AL_POSITION, defaultSourceVel );
alSourcefv( s.source, AL_VELOCITY, defaultSourceVel );
alSourcei( s.source, AL_LOOPING, AL_FALSE );
//alSourcef( s.source, AL_ROLLOFF_FACTOR, .1f );
CheckError();
}
DevIL fails to build on 64bit linux (yet avatar version works, and svn export and moving it in gyarados doesn't...), anyways error stuff located here: http://bbs.archlinux.org/viewtopic.php?id=35361#p272561
Apply the patches and it works.
Temp fix for it not finding Python.h: Open code/pythondir.mak and append it to the includes (/usr/include/python2.4 for 64bit fedora machine)
64bit issues: devil not running ./configure to create it's own Makefile, error in Makefile.lagoon trying to run it. Manually doing ./configure creates it, after making it fails on permission denied trying to install ilIL.so.1.0.0 in /usr/local/lib/libIL.so.1.0.0
Final NSIS script:
!include LogicLib.nsh
!include Library.nsh
!include MUI.nsh
;--------------------------------
; Get the svn revision
!system gyaradosVersion.exe
!include svnrev.txt
;--------------------------------
; User-defines: Update these as necessary
!define Name_Lagoon "Lagoon (Gyarados rev${SVNRevision})"
!define File_Lagoon "lagoon_w32_x86-gyarados.exe"
!define File_wxPython "wxPython2.8-win32-unicode-2.8.6.0-py25.exe"
!define File_Python "python-2.5.1.msi"
;--------------------------------
; General
Var PythonDirectory
Name "${Name_Lagoon}"
OutFile "${File_Lagoon}"
InstallDir $PROGRAMFILES\Lagoon\Gyarados
DirText "This will install Lagoon on your computer. Choose a directory"
;--------------------------------
; Interface Configuration
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "unr.bmp"
!define MUI_ABORTWARNING
;--------------------------------
; Pages
!insertmacro MUI_PAGE_LICENSE "License.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
; Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
; Installer Sections
Section "Python/wxPython" SecPython
; Check for Python
Call IsPythonInstalled
${If} $PythonDirectory != "0"
MessageBox MB_OK "Python2.5 is already installed."
${Else}
MessageBox MB_YESNO "Python2.5 is not installed. Would you like to install it now?" IDYES installPython IDNO skipinstallPython
installPython:
SetOutPath $INSTDIR\tmp
File ${File_Python}
ExecWait '"msiexec" /i "$INSTDIR\tmp\${File_Python}"'
Delete "$INSTDIR\tmp\${File_Python}"
;Grab our PythonDir
Call IsPythonInstalled
skipinstallPython:
${EndIf}
; Check for wxPython
DetailPrint "Python Directory: $PythonDirectory"
${If} $PythonDirectory != "0" ; Check if we have Python installed first
${If} ${FileExists} "$PythonDirectory\Lib\site-packages\wx-2.8-msw-unicode\wxPython\__init__.py"
MessageBox MB_OK "wxPython is already installed."
${Else}
MessageBox MB_YESNO "wxPtyon is not installed. Would you like to install it now?" IDYES installWxPython IDNO skipinstallWxPython
installWxPython:
SetOutPath $INSTDIR\tmp
File ${File_wxPython}
ExecWait '"$INSTDIR\tmp\${File_wxPython}"'
Delete "$INSTDIR\tmp\${File_wxPython}"
skipinstallWxPython:
${EndIf}
${EndIf}
RMDir "$INSTDIR\tmp"
SectionEnd
Section "Lagoon" SecLagoon
; Place our binaries
SetOutPath $INSTDIR\bin\win32
File /r /x *.exp /x *.lib /x *.svn /x *.cvsignore /x Makefile ..\bin\win32\*
File .\tcl84.dll
SetOutPath $INSTDIR\bin
File ..\bin\nsh.tcl
File ..\bin\keyframeed.tcl
SetOutPath $INSTDIR\data
File /r /x mutiny.wav /x *.obj.* /x test /x slides /x tekdemos /x *.obj /x *.svn* /x *.cvsignore /x Makefile ..\data\*
SetOutPath $INSTDIR\doc
File /r /x *.svn* /x *.cvsignore /x Makefile ..\doc\*
SetOutPath $INSTDIR\code\scripts
File /r /x *.svn* /x *.cvsignore /x Makefile ..\code\scripts\*
SetOutPath $INSTDIR
File ..\readme.html
CreateShortCut $INSTDIR\go.lnk $INSTDIR\bin\win32\go.exe
WriteUninstaller $INSTDIR\uninstaller.exe
SectionEnd ; end the section
;--------------------------------
; Descriptions
LangString DESC_SecPython ${LANG_English} "This will install Python and wxPython to your machine."
LangString DESC_SecLagoon ${LANG_English} "This will install Lagoon to your machine."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecLagoon} $(DESC_SecLagoon)
!insertmacro MUI_DESCRIPTION_TEXT ${SecPython} $(DESC_SecPython)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
; Unistaller Section
Section "Uninstall"
RMDir /r "$INSTDIR"
SectionEnd
;--------------------------------
; Helper Functions
Function IsPythonInstalled
Push $R0
ClearErrors
ReadRegStr $R0 HKLM "SOFTWARE\Python\PythonCore\2.5\InstallPath" ""
IfErrors lbl_na
StrCpy $PythonDirectory $R0
Goto lbl_end
lbl_na:
ReadRegStr $R0 HKCU "SOFTWARE\Python\PythonCore\2.5\InstallPath" ""
IfErrors lbl_na2
StrCpy $PythonDirectory $R0
Goto lbl_end
lbl_na2:
StrCpy $PythonDirectory 0
lbl_end:
FunctionEnd
; Taken from NSIS wiki
Function un.RMDirUP
!define RMDirUP '!insertmacro RMDirUPCall'
!macro RMDirUPCall _PATH
push '${_PATH}'
Call un.RMDirUP
!macroend
; $0 - current folder
ClearErrors
Exch $0
;DetailPrint "ASDF - $0\.."
RMDir "$0\.."
IfErrors Skip
${RMDirUP} "$0\.."
Skip:
Pop $0
FunctionEnd
Gyarados SVN Cleanup to Windows/Linux Stuff:
npython.pak: remove "exec rm output" replace with "file delete output"
