From 48ba7961eb001a98d3e55748345acfed67aa33f2 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 27 Jan 2016 15:22:22 -0600 Subject: [PATCH] possibly controversial commit: remove all windows sources, keeping only the windows cmake so that we can generate an sln to edit the code --- .../application/Miff/src/win32/BISON.HAI | 334 ---- .../Miff/src/win32/InputFileHandler.cpp | 135 -- .../Miff/src/win32/InputFileHandler.h | 71 - .../Miff/src/win32/OutputFileHandler.cpp | 163 -- .../Miff/src/win32/OutputFileHandler.h | 80 - .../application/Miff/src/win32/bison.simple | 698 ------- .../application/Miff/src/win32/mIFF.dox | 62 - .../application/Miff/src/win32/miff.cpp | 953 ---------- .../application/Miff/src/win32/parser.lex | 517 ------ .../application/Miff/src/win32/parser.yac | 1004 ---------- .../Base/win32/Archive.h | 42 - .../Base/win32/Platform.cpp | 31 - .../Base/win32/Platform.h | 98 - .../AuctionTransferGameAPI/Base/win32/Types.h | 42 - .../src/win32/FirstCentralServer.cpp | 5 - .../CentralServer/src/win32/WinMain.cpp | 84 - .../ChatServer/src/win32/WinMain.cpp | 42 - .../CommoditiesServer/src/win32/WinMain.cpp | 70 - .../src/win32/FirstConnectionServer.cpp | 1 - .../ConnectionServer/src/win32/WinMain.cpp | 58 - .../src/win32/LoggingServerApiWrapper.cpp | 16 - .../LogServer/src/win32/WinMain.cpp | 55 - .../src/win32/FirstLoginServer.cpp | 1 - .../LoginServer/src/win32/WinMain.cpp | 46 - .../MetricsServer/src/win32/WinMain.cpp | 91 - .../src/win32/FirstPlanetServer.cpp | 8 - .../PlanetServer/src/win32/WinMain.cpp | 67 - .../ServerConsole/src/win32/main.cpp | 59 - .../TaskManager/src/win32/ConsoleInput.cpp | 22 - .../src/win32/EnvironmentVariable.cpp | 33 - .../TaskManager/src/win32/ProcessSpawner.cpp | 153 -- .../src/win32/TaskManagerSysInfo.cpp | 147 -- .../TaskManager/src/win32/WinMain.cpp | 50 - .../TransferServer/src/win32/WinMain.cpp | 60 - .../src/win32/FirstServerDatabase.cpp | 9 - .../serverGame/src/win32/FirstServerGame.cpp | 10 - .../src/win32/FirstServerKeyShare.cpp | 8 - .../src/win32/FirstServerMetrics.cpp | 9 - .../src/win32/FirstServerNetworkMessages.cpp | 3 - .../src/win32/FirstServerPathfinding.cpp | 8 - .../src/win32/FirstServerScript.cpp | 2 - .../src/win32/FirstServerUtility.cpp | 2 - .../src/win32/FirstTemplateCompiler.cpp | 1 - .../src/win32/FirstTemplateCompiler.h | 8 - .../win32/FirstTemplateDefinitionCompiler.cpp | 1 - .../win32/FirstTemplateDefinitionCompiler.h | 8 - .../src/win32/FirstSharedCollision.cpp | 8 - .../src/win32/FirstSharedCommandParser.cpp | 8 - .../src/win32/FirstSharedCompression.cpp | 8 - .../win32/FirstSharedDatabaseInterface.cpp | 9 - .../src/win32/SQLC_Defs.h | 19 - .../sharedDebug/src/win32/DebugHelp.cpp | 670 ------- .../library/sharedDebug/src/win32/DebugHelp.h | 35 - .../sharedDebug/src/win32/DebugMonitor.cpp | 321 ---- .../sharedDebug/src/win32/DebugMonitor.h | 48 - .../src/win32/FirstSharedDebug.cpp | 8 - .../src/win32/PerformanceTimer.cpp | 105 -- .../sharedDebug/src/win32/PerformanceTimer.h | 49 - .../sharedDebug/src/win32/ProfilerTimer.cpp | 90 - .../sharedDebug/src/win32/ProfilerTimer.h | 29 - .../library/sharedDebug/src/win32/VTune.cpp | 142 -- .../library/sharedDebug/src/win32/VTune.h | 65 - .../sharedFile/src/win32/FirstSharedFile.cpp | 8 - .../library/sharedFile/src/win32/OsFile.cpp | 195 -- .../library/sharedFile/src/win32/OsFile.h | 48 - .../sharedFoundation/src/win32/ByteOrder.cpp | 58 - .../sharedFoundation/src/win32/ByteOrder.h | 22 - .../src/win32/ConfigSharedFoundation.cpp | 324 ---- .../src/win32/ConfigSharedFoundation.h | 74 - .../src/win32/FirstPlatform.h | 82 - .../src/win32/FirstSharedFoundation.cpp | 8 - .../src/win32/FloatingPointUnit.cpp | 257 --- .../src/win32/FloatingPointUnit.h | 104 -- .../library/sharedFoundation/src/win32/Os.cpp | 1633 ----------------- .../library/sharedFoundation/src/win32/Os.h | 152 -- .../src/win32/PerThreadData.cpp | 465 ----- .../src/win32/PerThreadData.h | 57 - .../src/win32/PlatformGlue.cpp | 124 -- .../sharedFoundation/src/win32/PlatformGlue.h | 32 - .../src/win32/ProcessSpawner.cpp | 310 ---- .../src/win32/ProcessSpawner.h | 43 - .../src/win32/RegistryKey.cpp | 918 --------- .../sharedFoundation/src/win32/RegistryKey.h | 270 --- .../src/win32/SetupSharedFoundation.cpp | 410 ----- .../src/win32/SetupSharedFoundation.h | 99 - .../src/win32/WindowsWrapper.h | 51 - .../src/win32/FoundationTypesWin32.h | 33 - .../src/win32/FirstSharedFractal.cpp | 8 - .../sharedGame/src/win32/FirstSharedGame.cpp | 9 - .../src/win32/FirstSharedImage.cpp | 8 - .../src/win32/FirstSharedIoWin.cpp | 8 - .../sharedLog/src/win32/StderrLogger.cpp | 35 - .../sharedMath/src/win32/FirstSharedMath.cpp | 8 - .../library/sharedMath/src/win32/SseMath.cpp | 430 ----- .../library/sharedMath/src/win32/SseMath.h | 58 - .../src/win32/OsMemory.cpp | 56 - .../sharedMemoryManager/src/win32/OsMemory.h | 29 - .../src/win32/OsNewDel.cpp | 211 --- .../sharedMemoryManager/src/win32/OsNewDel.h | 52 - .../src/win32/FirstSharedMessageDispatch.cpp | 8 - .../sharedNetwork/src/win32/Address.cpp | 410 ----- .../src/win32/FirstSharedNetwork.cpp | 9 - .../src/win32/NetworkGetHostName.cpp | 67 - .../sharedNetwork/src/win32/OverlappedTcp.cpp | 85 - .../sharedNetwork/src/win32/OverlappedTcp.h | 47 - .../library/sharedNetwork/src/win32/Sock.cpp | 366 ---- .../library/sharedNetwork/src/win32/Sock.h | 129 -- .../sharedNetwork/src/win32/TcpClient.cpp | 631 ------- .../sharedNetwork/src/win32/TcpClient.h | 87 - .../sharedNetwork/src/win32/TcpServer.cpp | 194 -- .../sharedNetwork/src/win32/TcpServer.h | 50 - .../sharedNetwork/src/win32/UdpSock.cpp | 108 -- .../src/win32/FirstSharedNetworkMessages.cpp | 8 - .../src/win32/FirstSharedObject.cpp | 8 - .../src/win32/FirstSharedPathfinding.cpp | 8 - .../src/win32/FirstSharedRandom.cpp | 8 - .../src/win32/FirstSharedRegex.cpp | 9 - .../sharedRegex/src/win32/RegexServices.cpp | 57 - .../sharedRegex/src/win32/RegexServices.h | 25 - .../src/win32/FirstSharedSkillSystem.cpp | 8 - .../src/win32/ConditionVariable.cpp | 50 - .../src/win32/ConditionVariable.h | 42 - .../src/win32/FirstSharedSynchronization.cpp | 8 - .../sharedSynchronization/src/win32/Gate.cpp | 60 - .../sharedSynchronization/src/win32/Gate.h | 39 - .../src/win32/InterlockedInteger.h | 52 - .../src/win32/InterlockedVoidPointer.h | 45 - .../sharedSynchronization/src/win32/Mutex.cpp | 53 - .../sharedSynchronization/src/win32/Mutex.h | 41 - .../src/win32/RecursiveMutex.cpp | 53 - .../src/win32/RecursiveMutex.h | 41 - .../src/win32/Semaphore.cpp | 37 - .../src/win32/Semaphore.h | 28 - .../src/win32/FirstSharedTemplate.cpp | 1 - .../win32/FirstSharedTemplateDefinition.cpp | 1 - .../src/win32/FirstSharedTerrain.cpp | 8 - .../src/win32/FirstSharedThread.cpp | 8 - .../library/sharedThread/src/win32/Thread.cpp | 179 -- .../library/sharedThread/src/win32/Thread.h | 94 - .../src/win32/FirstSharedUtility.cpp | 8 - .../src/win32/core/FirstSharedXml.cpp | 11 - .../platform/utils/Base/win32/Archive.h | 42 - .../utils/Base/win32/BlockAllocator.cpp | 112 -- .../platform/utils/Base/win32/Event.cpp | 44 - .../library/platform/utils/Base/win32/Event.h | 92 - .../platform/utils/Base/win32/File.cpp | 19 - .../library/platform/utils/Base/win32/File.h | 22 - .../platform/utils/Base/win32/Logger.cpp | 385 ---- .../platform/utils/Base/win32/Mutex.cpp | 40 - .../library/platform/utils/Base/win32/Mutex.h | 73 - .../platform/utils/Base/win32/Platform.cpp | 31 - .../platform/utils/Base/win32/Platform.h | 98 - .../platform/utils/Base/win32/Thread.cpp | 279 --- .../platform/utils/Base/win32/Thread.h | 144 -- .../library/platform/utils/Base/win32/Types.h | 42 - .../CSAssist/utils/Base/win32/Archive.h | 42 - .../utils/Base/win32/BlockAllocator.cpp | 112 -- .../CSAssist/utils/Base/win32/Event.cpp | 44 - .../CSAssist/utils/Base/win32/Event.h | 92 - .../CSAssist/utils/Base/win32/File.cpp | 19 - .../CSAssist/utils/Base/win32/File.h | 22 - .../CSAssist/utils/Base/win32/Mutex.cpp | 40 - .../CSAssist/utils/Base/win32/Mutex.h | 73 - .../CSAssist/utils/Base/win32/Platform.cpp | 31 - .../CSAssist/utils/Base/win32/Platform.h | 98 - .../CSAssist/utils/Base/win32/Thread.cpp | 279 --- .../CSAssist/utils/Base/win32/Thread.h | 144 -- .../CSAssist/utils/Base/win32/Types.h | 42 - .../CTServiceGameAPI/Base/win32/Archive.h | 42 - .../CTServiceGameAPI/Base/win32/Platform.cpp | 31 - .../CTServiceGameAPI/Base/win32/Platform.h | 98 - .../CTServiceGameAPI/Base/win32/Types.h | 42 - .../ChatAPI/utils/Base/win32/Archive.h | 42 - .../utils/Base/win32/BlockAllocator.cpp | 112 -- .../ChatAPI/utils/Base/win32/Event.cpp | 44 - .../ChatAPI/utils/Base/win32/Event.h | 92 - .../ChatAPI/utils/Base/win32/File.cpp | 22 - .../ChatAPI/utils/Base/win32/File.h | 26 - .../ChatAPI/utils/Base/win32/Mutex.cpp | 40 - .../ChatAPI/utils/Base/win32/Mutex.h | 73 - .../ChatAPI/utils/Base/win32/Platform.cpp | 31 - .../ChatAPI/utils/Base/win32/Platform.h | 98 - .../ChatAPI/utils/Base/win32/Thread.cpp | 315 ---- .../ChatAPI/utils/Base/win32/Thread.h | 152 -- .../ChatAPI/utils/Base/win32/Types.h | 42 - .../archive/src/win32/ArchiveMutex.cpp | 35 - .../library/archive/src/win32/ArchiveMutex.h | 27 - .../archive/src/win32/FirstArchive.cpp | 16 - .../library/crypto/src/win32/FirstCrypto.cpp | 1 - .../src/win32/FirstFileInterface.cpp | 1 - .../src/win32/FirstLocalization.cpp | 8 - .../src/win32/FirstLocalizationArchive.cpp | 10 - .../unicode/src/win32/FirstUnicode.cpp | 8 - .../src/win32/FirstUnicodeArchive.cpp | 12 - .../src/win32/FirstSwgDatabaseServer.cpp | 1 - .../SwgDatabaseServer/src/win32/WinMain.cpp | 87 - .../src/win32/FirstSwgGameServer.cpp | 1 - .../SwgGameServer/src/win32/WinMain.cpp | 553 ------ .../win32/FirstSwgServerNetworkMessages.cpp | 9 - .../win32/FirstSwgSharedNetworkMessages.cpp | 9 - .../src/win32/FirstSwgSharedUtility.cpp | 11 - 201 files changed, 21403 deletions(-) delete mode 100644 engine/client/application/Miff/src/win32/BISON.HAI delete mode 100755 engine/client/application/Miff/src/win32/InputFileHandler.cpp delete mode 100755 engine/client/application/Miff/src/win32/InputFileHandler.h delete mode 100755 engine/client/application/Miff/src/win32/OutputFileHandler.cpp delete mode 100755 engine/client/application/Miff/src/win32/OutputFileHandler.h delete mode 100644 engine/client/application/Miff/src/win32/bison.simple delete mode 100644 engine/client/application/Miff/src/win32/mIFF.dox delete mode 100755 engine/client/application/Miff/src/win32/miff.cpp delete mode 100644 engine/client/application/Miff/src/win32/parser.lex delete mode 100644 engine/client/application/Miff/src/win32/parser.yac delete mode 100755 engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Archive.h delete mode 100755 engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Platform.cpp delete mode 100755 engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Platform.h delete mode 100755 engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Types.h delete mode 100755 engine/server/application/CentralServer/src/win32/FirstCentralServer.cpp delete mode 100755 engine/server/application/CentralServer/src/win32/WinMain.cpp delete mode 100755 engine/server/application/ChatServer/src/win32/WinMain.cpp delete mode 100755 engine/server/application/CommoditiesServer/src/win32/WinMain.cpp delete mode 100755 engine/server/application/ConnectionServer/src/win32/FirstConnectionServer.cpp delete mode 100755 engine/server/application/ConnectionServer/src/win32/WinMain.cpp delete mode 100755 engine/server/application/LogServer/src/win32/LoggingServerApiWrapper.cpp delete mode 100755 engine/server/application/LogServer/src/win32/WinMain.cpp delete mode 100755 engine/server/application/LoginServer/src/win32/FirstLoginServer.cpp delete mode 100755 engine/server/application/LoginServer/src/win32/WinMain.cpp delete mode 100755 engine/server/application/MetricsServer/src/win32/WinMain.cpp delete mode 100755 engine/server/application/PlanetServer/src/win32/FirstPlanetServer.cpp delete mode 100755 engine/server/application/PlanetServer/src/win32/WinMain.cpp delete mode 100755 engine/server/application/ServerConsole/src/win32/main.cpp delete mode 100755 engine/server/application/TaskManager/src/win32/ConsoleInput.cpp delete mode 100755 engine/server/application/TaskManager/src/win32/EnvironmentVariable.cpp delete mode 100755 engine/server/application/TaskManager/src/win32/ProcessSpawner.cpp delete mode 100755 engine/server/application/TaskManager/src/win32/TaskManagerSysInfo.cpp delete mode 100755 engine/server/application/TaskManager/src/win32/WinMain.cpp delete mode 100755 engine/server/application/TransferServer/src/win32/WinMain.cpp delete mode 100755 engine/server/library/serverDatabase/src/win32/FirstServerDatabase.cpp delete mode 100755 engine/server/library/serverGame/src/win32/FirstServerGame.cpp delete mode 100755 engine/server/library/serverKeyShare/src/win32/FirstServerKeyShare.cpp delete mode 100755 engine/server/library/serverMetrics/src/win32/FirstServerMetrics.cpp delete mode 100755 engine/server/library/serverNetworkMessages/src/win32/FirstServerNetworkMessages.cpp delete mode 100755 engine/server/library/serverPathfinding/src/win32/FirstServerPathfinding.cpp delete mode 100755 engine/server/library/serverScript/src/win32/FirstServerScript.cpp delete mode 100755 engine/server/library/serverUtility/src/win32/FirstServerUtility.cpp delete mode 100755 engine/shared/application/TemplateCompiler/src/win32/FirstTemplateCompiler.cpp delete mode 100755 engine/shared/application/TemplateCompiler/src/win32/FirstTemplateCompiler.h delete mode 100755 engine/shared/application/TemplateDefinitionCompiler/src/win32/FirstTemplateDefinitionCompiler.cpp delete mode 100755 engine/shared/application/TemplateDefinitionCompiler/src/win32/FirstTemplateDefinitionCompiler.h delete mode 100755 engine/shared/library/sharedCollision/src/win32/FirstSharedCollision.cpp delete mode 100755 engine/shared/library/sharedCommandParser/src/win32/FirstSharedCommandParser.cpp delete mode 100755 engine/shared/library/sharedCompression/src/win32/FirstSharedCompression.cpp delete mode 100755 engine/shared/library/sharedDatabaseInterface/src/win32/FirstSharedDatabaseInterface.cpp delete mode 100755 engine/shared/library/sharedDatabaseInterface/src/win32/SQLC_Defs.h delete mode 100755 engine/shared/library/sharedDebug/src/win32/DebugHelp.cpp delete mode 100755 engine/shared/library/sharedDebug/src/win32/DebugHelp.h delete mode 100755 engine/shared/library/sharedDebug/src/win32/DebugMonitor.cpp delete mode 100755 engine/shared/library/sharedDebug/src/win32/DebugMonitor.h delete mode 100755 engine/shared/library/sharedDebug/src/win32/FirstSharedDebug.cpp delete mode 100755 engine/shared/library/sharedDebug/src/win32/PerformanceTimer.cpp delete mode 100755 engine/shared/library/sharedDebug/src/win32/PerformanceTimer.h delete mode 100755 engine/shared/library/sharedDebug/src/win32/ProfilerTimer.cpp delete mode 100755 engine/shared/library/sharedDebug/src/win32/ProfilerTimer.h delete mode 100755 engine/shared/library/sharedDebug/src/win32/VTune.cpp delete mode 100755 engine/shared/library/sharedDebug/src/win32/VTune.h delete mode 100755 engine/shared/library/sharedFile/src/win32/FirstSharedFile.cpp delete mode 100755 engine/shared/library/sharedFile/src/win32/OsFile.cpp delete mode 100755 engine/shared/library/sharedFile/src/win32/OsFile.h delete mode 100755 engine/shared/library/sharedFoundation/src/win32/ByteOrder.cpp delete mode 100755 engine/shared/library/sharedFoundation/src/win32/ByteOrder.h delete mode 100755 engine/shared/library/sharedFoundation/src/win32/ConfigSharedFoundation.cpp delete mode 100755 engine/shared/library/sharedFoundation/src/win32/ConfigSharedFoundation.h delete mode 100755 engine/shared/library/sharedFoundation/src/win32/FirstPlatform.h delete mode 100755 engine/shared/library/sharedFoundation/src/win32/FirstSharedFoundation.cpp delete mode 100755 engine/shared/library/sharedFoundation/src/win32/FloatingPointUnit.cpp delete mode 100755 engine/shared/library/sharedFoundation/src/win32/FloatingPointUnit.h delete mode 100755 engine/shared/library/sharedFoundation/src/win32/Os.cpp delete mode 100755 engine/shared/library/sharedFoundation/src/win32/Os.h delete mode 100755 engine/shared/library/sharedFoundation/src/win32/PerThreadData.cpp delete mode 100755 engine/shared/library/sharedFoundation/src/win32/PerThreadData.h delete mode 100755 engine/shared/library/sharedFoundation/src/win32/PlatformGlue.cpp delete mode 100755 engine/shared/library/sharedFoundation/src/win32/PlatformGlue.h delete mode 100755 engine/shared/library/sharedFoundation/src/win32/ProcessSpawner.cpp delete mode 100755 engine/shared/library/sharedFoundation/src/win32/ProcessSpawner.h delete mode 100755 engine/shared/library/sharedFoundation/src/win32/RegistryKey.cpp delete mode 100755 engine/shared/library/sharedFoundation/src/win32/RegistryKey.h delete mode 100755 engine/shared/library/sharedFoundation/src/win32/SetupSharedFoundation.cpp delete mode 100755 engine/shared/library/sharedFoundation/src/win32/SetupSharedFoundation.h delete mode 100755 engine/shared/library/sharedFoundation/src/win32/WindowsWrapper.h delete mode 100755 engine/shared/library/sharedFoundationTypes/src/win32/FoundationTypesWin32.h delete mode 100755 engine/shared/library/sharedFractal/src/win32/FirstSharedFractal.cpp delete mode 100755 engine/shared/library/sharedGame/src/win32/FirstSharedGame.cpp delete mode 100755 engine/shared/library/sharedImage/src/win32/FirstSharedImage.cpp delete mode 100755 engine/shared/library/sharedIoWin/src/win32/FirstSharedIoWin.cpp delete mode 100755 engine/shared/library/sharedLog/src/win32/StderrLogger.cpp delete mode 100755 engine/shared/library/sharedMath/src/win32/FirstSharedMath.cpp delete mode 100755 engine/shared/library/sharedMath/src/win32/SseMath.cpp delete mode 100755 engine/shared/library/sharedMath/src/win32/SseMath.h delete mode 100755 engine/shared/library/sharedMemoryManager/src/win32/OsMemory.cpp delete mode 100755 engine/shared/library/sharedMemoryManager/src/win32/OsMemory.h delete mode 100755 engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.cpp delete mode 100755 engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.h delete mode 100755 engine/shared/library/sharedMessageDispatch/src/win32/FirstSharedMessageDispatch.cpp delete mode 100755 engine/shared/library/sharedNetwork/src/win32/Address.cpp delete mode 100755 engine/shared/library/sharedNetwork/src/win32/FirstSharedNetwork.cpp delete mode 100755 engine/shared/library/sharedNetwork/src/win32/NetworkGetHostName.cpp delete mode 100755 engine/shared/library/sharedNetwork/src/win32/OverlappedTcp.cpp delete mode 100755 engine/shared/library/sharedNetwork/src/win32/OverlappedTcp.h delete mode 100755 engine/shared/library/sharedNetwork/src/win32/Sock.cpp delete mode 100755 engine/shared/library/sharedNetwork/src/win32/Sock.h delete mode 100755 engine/shared/library/sharedNetwork/src/win32/TcpClient.cpp delete mode 100755 engine/shared/library/sharedNetwork/src/win32/TcpClient.h delete mode 100755 engine/shared/library/sharedNetwork/src/win32/TcpServer.cpp delete mode 100755 engine/shared/library/sharedNetwork/src/win32/TcpServer.h delete mode 100755 engine/shared/library/sharedNetwork/src/win32/UdpSock.cpp delete mode 100755 engine/shared/library/sharedNetworkMessages/src/win32/FirstSharedNetworkMessages.cpp delete mode 100755 engine/shared/library/sharedObject/src/win32/FirstSharedObject.cpp delete mode 100755 engine/shared/library/sharedPathfinding/src/win32/FirstSharedPathfinding.cpp delete mode 100755 engine/shared/library/sharedRandom/src/win32/FirstSharedRandom.cpp delete mode 100755 engine/shared/library/sharedRegex/src/win32/FirstSharedRegex.cpp delete mode 100755 engine/shared/library/sharedRegex/src/win32/RegexServices.cpp delete mode 100755 engine/shared/library/sharedRegex/src/win32/RegexServices.h delete mode 100755 engine/shared/library/sharedSkillSystem/src/win32/FirstSharedSkillSystem.cpp delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/ConditionVariable.cpp delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/ConditionVariable.h delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/FirstSharedSynchronization.cpp delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/Gate.cpp delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/Gate.h delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/InterlockedInteger.h delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/InterlockedVoidPointer.h delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/Mutex.cpp delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/Mutex.h delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/RecursiveMutex.cpp delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/RecursiveMutex.h delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/Semaphore.cpp delete mode 100755 engine/shared/library/sharedSynchronization/src/win32/Semaphore.h delete mode 100755 engine/shared/library/sharedTemplate/src/win32/FirstSharedTemplate.cpp delete mode 100755 engine/shared/library/sharedTemplateDefinition/src/win32/FirstSharedTemplateDefinition.cpp delete mode 100755 engine/shared/library/sharedTerrain/src/win32/FirstSharedTerrain.cpp delete mode 100755 engine/shared/library/sharedThread/src/win32/FirstSharedThread.cpp delete mode 100755 engine/shared/library/sharedThread/src/win32/Thread.cpp delete mode 100755 engine/shared/library/sharedThread/src/win32/Thread.h delete mode 100755 engine/shared/library/sharedUtility/src/win32/FirstSharedUtility.cpp delete mode 100755 engine/shared/library/sharedXml/src/win32/core/FirstSharedXml.cpp delete mode 100755 external/3rd/library/platform/utils/Base/win32/Archive.h delete mode 100755 external/3rd/library/platform/utils/Base/win32/BlockAllocator.cpp delete mode 100755 external/3rd/library/platform/utils/Base/win32/Event.cpp delete mode 100755 external/3rd/library/platform/utils/Base/win32/Event.h delete mode 100755 external/3rd/library/platform/utils/Base/win32/File.cpp delete mode 100755 external/3rd/library/platform/utils/Base/win32/File.h delete mode 100755 external/3rd/library/platform/utils/Base/win32/Logger.cpp delete mode 100755 external/3rd/library/platform/utils/Base/win32/Mutex.cpp delete mode 100755 external/3rd/library/platform/utils/Base/win32/Mutex.h delete mode 100755 external/3rd/library/platform/utils/Base/win32/Platform.cpp delete mode 100755 external/3rd/library/platform/utils/Base/win32/Platform.h delete mode 100755 external/3rd/library/platform/utils/Base/win32/Thread.cpp delete mode 100755 external/3rd/library/platform/utils/Base/win32/Thread.h delete mode 100755 external/3rd/library/platform/utils/Base/win32/Types.h delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Archive.h delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/BlockAllocator.cpp delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Event.cpp delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Event.h delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/File.cpp delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/File.h delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Mutex.cpp delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Mutex.h delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Platform.cpp delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Platform.h delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Thread.cpp delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Thread.h delete mode 100755 external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Types.h delete mode 100755 external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Archive.h delete mode 100755 external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Platform.cpp delete mode 100755 external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Platform.h delete mode 100755 external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Types.h delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Archive.h delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/BlockAllocator.cpp delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Event.cpp delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Event.h delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/File.cpp delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/File.h delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Mutex.cpp delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Mutex.h delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Platform.cpp delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Platform.h delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Thread.cpp delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Thread.h delete mode 100755 external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Types.h delete mode 100755 external/ours/library/archive/src/win32/ArchiveMutex.cpp delete mode 100755 external/ours/library/archive/src/win32/ArchiveMutex.h delete mode 100755 external/ours/library/archive/src/win32/FirstArchive.cpp delete mode 100755 external/ours/library/crypto/src/win32/FirstCrypto.cpp delete mode 100755 external/ours/library/fileInterface/src/win32/FirstFileInterface.cpp delete mode 100755 external/ours/library/localization/src/win32/FirstLocalization.cpp delete mode 100755 external/ours/library/localizationArchive/src/win32/FirstLocalizationArchive.cpp delete mode 100755 external/ours/library/unicode/src/win32/FirstUnicode.cpp delete mode 100755 external/ours/library/unicodeArchive/src/win32/FirstUnicodeArchive.cpp delete mode 100755 game/server/application/SwgDatabaseServer/src/win32/FirstSwgDatabaseServer.cpp delete mode 100755 game/server/application/SwgDatabaseServer/src/win32/WinMain.cpp delete mode 100755 game/server/application/SwgGameServer/src/win32/FirstSwgGameServer.cpp delete mode 100755 game/server/application/SwgGameServer/src/win32/WinMain.cpp delete mode 100755 game/server/library/swgServerNetworkMessages/src/win32/FirstSwgServerNetworkMessages.cpp delete mode 100755 game/shared/library/swgSharedNetworkMessages/src/win32/FirstSwgSharedNetworkMessages.cpp delete mode 100755 game/shared/library/swgSharedUtility/src/win32/FirstSwgSharedUtility.cpp diff --git a/engine/client/application/Miff/src/win32/BISON.HAI b/engine/client/application/Miff/src/win32/BISON.HAI deleted file mode 100644 index 999b5559..00000000 --- a/engine/client/application/Miff/src/win32/BISON.HAI +++ /dev/null @@ -1,334 +0,0 @@ - -extern int timeclock; - - -int yyerror; /* Yyerror and yycost are set by guards. */ -int yycost; /* If yyerror is set to a nonzero value by a */ - /* guard, the reduction with which the guard */ - /* is associated is not performed, and the */ - /* error recovery mechanism is invoked. */ - /* Yycost indicates the cost of performing */ - /* the reduction given the attributes of the */ - /* symbols. */ - - -/* YYMAXDEPTH indicates the size of the parser's state and value */ -/* stacks. */ - -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 500 -#endif - -/* YYMAXRULES must be at least as large as the number of rules that */ -/* could be placed in the rule queue. That number could be determined */ -/* from the grammar and the size of the stack, but, as yet, it is not. */ - -#ifndef YYMAXRULES -#define YYMAXRULES 100 -#endif - -#ifndef YYMAXBACKUP -#define YYMAXBACKUP 100 -#endif - - -short yyss[YYMAXDEPTH]; /* the state stack */ -YYSTYPE yyvs[YYMAXDEPTH]; /* the semantic value stack */ -YYLTYPE yyls[YYMAXDEPTH]; /* the location stack */ -short yyrq[YYMAXRULES]; /* the rule queue */ -int yychar; /* the lookahead symbol */ - -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ - -YYSTYPE yytval; /* the semantic value for the state */ - /* at the top of the state stack. */ - -YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ - -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ - -YYLTYPE yytloc; /* location data for the state at the */ - /* top of the state stack */ - - -int yynunlexed; -short yyunchar[YYMAXBACKUP]; -YYSTYPE yyunval[YYMAXBACKUP]; -YYLTYPE yyunloc[YYMAXBACKUP]; - -short *yygssp; /* a pointer to the top of the state */ - /* stack; only set during error */ - /* recovery. */ - -YYSTYPE *yygvsp; /* a pointer to the top of the value */ - /* stack; only set during error */ - /* recovery. */ - -YYLTYPE *yyglsp; /* a pointer to the top of the */ - /* location stack; only set during */ - /* error recovery. */ - - -/* Yyget is an interface between the parser and the lexical analyzer. */ -/* It is costly to provide such an interface, but it avoids requiring */ -/* the lexical analyzer to be able to back up the scan. */ - -yyget() -{ - if (yynunlexed > 0) - { - yynunlexed--; - yychar = yyunchar[yynunlexed]; - yylval = yyunval[yynunlexed]; - yylloc = yyunloc[yynunlexed]; - } - else if (yychar <= 0) - yychar = 0; - else - { - yychar = yylex(); - if (yychar < 0) - yychar = 0; - else yychar = YYTRANSLATE(yychar); - } -} - - - -yyunlex(chr, val, loc) -int chr; -YYSTYPE val; -YYLTYPE loc; -{ - yyunchar[yynunlexed] = chr; - yyunval[yynunlexed] = val; - yyunloc[yynunlexed] = loc; - yynunlexed++; -} - - - -yyrestore(first, last) -register short *first; -register short *last; -{ - register short *ssp; - register short *rp; - register int symbol; - register int state; - register int tvalsaved; - - ssp = yygssp; - yyunlex(yychar, yylval, yylloc); - - tvalsaved = 0; - while (first != last) - { - symbol = yystos[*ssp]; - if (symbol < YYNTBASE) - { - yyunlex(symbol, yytval, yytloc); - tvalsaved = 1; - ssp--; - } - - ssp--; - - if (first == yyrq) - first = yyrq + YYMAXRULES; - - first--; - - for (rp = yyrhs + yyprhs[*first]; symbol = *rp; rp++) - { - if (symbol < YYNTBASE) - state = yytable[yypact[*ssp] + symbol]; - else - { - state = yypgoto[symbol - YYNTBASE] + *ssp; - - if (state >= 0 && state <= YYLAST && yycheck[state] == *ssp) - state = yytable[state]; - else - state = yydefgoto[symbol - YYNTBASE]; - } - - *++ssp = state; - } - } - - if ( ! tvalsaved && ssp > yyss) - { - yyunlex(yystos[*ssp], yytval, yytloc); - ssp--; - } - - yygssp = ssp; -} - - - -int -yyparse() -{ - register int yystate; - register int yyn; - register short *yyssp; - register short *yyrq0; - register short *yyptr; - register YYSTYPE *yyvsp; - - int yylen; - YYLTYPE *yylsp; - short *yyrq1; - short *yyrq2; - - yystate = 0; - yyssp = yyss - 1; - yyvsp = yyvs - 1; - yylsp = yyls - 1; - yyrq0 = yyrq; - yyrq1 = yyrq0; - yyrq2 = yyrq0; - - yychar = yylex(); - if (yychar < 0) - yychar = 0; - else yychar = YYTRANSLATE(yychar); - -yynewstate: - - if (yyssp >= yyss + YYMAXDEPTH - 1) - { - yyabort("Parser Stack Overflow"); - YYABORT; - } - - *++yyssp = yystate; - -yyresume: - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; - - yyn += yychar; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar) - goto yydefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - yystate = yyn; - - yyptr = yyrq2; - while (yyptr != yyrq1) - { - yyn = *yyptr++; - yylen = yyr2[yyn]; - yyvsp -= yylen; - yylsp -= yylen; - - yyguard(yyn, yyvsp, yylsp); - if (yyerror) - goto yysemerr; - - yyaction(yyn, yyvsp, yylsp); - *++yyvsp = yyval; - - yylsp++; - if (yylen == 0) - { - yylsp->timestamp = timeclock; - yylsp->first_line = yytloc.first_line; - yylsp->first_column = yytloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } - - if (yyptr == yyrq + YYMAXRULES) - yyptr = yyrq; - } - - if (yystate == YYFINAL) - YYACCEPT; - - yyrq2 = yyptr; - yyrq1 = yyrq0; - - *++yyvsp = yytval; - *++yylsp = yytloc; - yytval = yylval; - yytloc = yylloc; - yyget(); - - goto yynewstate; - -yydefault: - - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - -yyreduce: - - *yyrq0++ = yyn; - - if (yyrq0 == yyrq + YYMAXRULES) - yyrq0 = yyrq; - - if (yyrq0 == yyrq2) - { - yyabort("Parser Rule Queue Overflow"); - YYABORT; - } - - yyssp -= yyr2[yyn]; - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - -yysemerr: - *--yyptr = yyn; - yyrq2 = yyptr; - yyvsp += yyr2[yyn]; - -yyerrlab: - - yygssp = yyssp; - yygvsp = yyvsp; - yyglsp = yylsp; - yyrestore(yyrq0, yyrq2); - yyrecover(); - yystate = *yygssp; - yyssp = yygssp; - yyvsp = yygvsp; - yyrq0 = yyrq; - yyrq1 = yyrq0; - yyrq2 = yyrq0; - goto yyresume; -} - -$ diff --git a/engine/client/application/Miff/src/win32/InputFileHandler.cpp b/engine/client/application/Miff/src/win32/InputFileHandler.cpp deleted file mode 100755 index 96c5ecde..00000000 --- a/engine/client/application/Miff/src/win32/InputFileHandler.cpp +++ /dev/null @@ -1,135 +0,0 @@ -//=========================================================================== -// -// FILENAME: InputFileHandler.cpp [C:\Projects\new\tools\src\miff\src\] -// COPYRIGHT: (C) 1999 BY Bootprint Entertainment -// -// DESCRIPTION: file handler for input files (standard flat text files) -// AUTHOR: Hideki Ikeda -// DATE: 1/13/99 4:53:31 PM -// -// HISTORY: 1/13/99 [HAI] - File created -// : -// -// FUNCTION: InputFileHandler() constructor -// : ~InputFileHandler() destructor -// : -// -//=========================================================================== - -//========================================================== include files == -#include "sharedFoundation/FirstSharedFoundation.h" -#include "InputFileHandler.h" - -#include "sharedFile/TreeFile.h" -//#include "sharedFile/Iff.h" - -//================================================= static vars assignment == - - - -//--------------------------------------------------------------------------- -// Constructor -// -// Remarks: -// -// -// See Also: -// -// -// Revisions and History: -// 1/13/99 [HAI] - created -// -InputFileHandler::InputFileHandler(const char *infilename) -{ - TreeFile::addSearchAbsolute(0); // search current working directory - - file = TreeFile::open(infilename, AbstractFile::PriorityData, true); - -} - - -//--------------------------------------------------------------------------- -// Destructor -// -// Remarks: -// -// -// See Also: -// -// -// Revisions and History: -// 1/13/99 [HAI] - created -// -InputFileHandler::~InputFileHandler(void) -{ - delete file; -} - - -//--------------------------------------------------------------------------- -// reads a file stream into specified buffer of the size passed -// -// Return Value: -// actual size read (signed int) -// -// Remarks: -// -// -// See Also: -// Treefile::read() -// -// Revisions and History: -// 1/13/99 [HAI] - created -// -const int InputFileHandler::read( - void *sourceBuffer, // pointer to the buffer - int bufferSize // number of BYTES to be read - ) -{ - int retVal = -1; // assume fileHandle is NOT valid - - if (file) - retVal = file->read(sourceBuffer, bufferSize); - - return(retVal); -} - -//--------------------------------------------------------------------------- -// Deletes a file -// -// Return Value: -// whatever DeleteFile() returns -// if fileHandle != -1, it assumes that the fileHandle passed belonged to -// this filename, and therefore, it will attempt to close the file and -// set it to 0. -// -// Remarks: -// calls DeleteFile() found in windows.h -// InputFileHandler does NOT have any way to validate that the handle -// passed belongs to the filename that it wants to be deleted. So use -// it with caution -// -// See Also: -// windows.h -// -// Revisions and History: -// 1/13/99 [HAI] - created -// -int InputFileHandler::deleteFile( - const char *filename, - bool deleteHandleFlag - ) -{ - if (deleteHandleFlag && file) - { - delete file; - file = NULL; - } - return(DeleteFile(filename)); -} - - -//=========================================================================== -//============================================================ End-of-file == -//=========================================================================== - diff --git a/engine/client/application/Miff/src/win32/InputFileHandler.h b/engine/client/application/Miff/src/win32/InputFileHandler.h deleted file mode 100755 index 9e4734fe..00000000 --- a/engine/client/application/Miff/src/win32/InputFileHandler.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef __INPUTFILEHANDLER_H__ -#define __INPUTFILEHANDLER_H__ - -//=========================================================================== -// -// FILENAME: InputFileHandler.h [C:\Projects\new\tools\src\miff\src\] -// COPYRIGHT: (C) 1999 BY Bootprint Entertainment -// -// DESCRIPTION: file handler for input files (flat text files) -// AUTHOR: Hideki Ikeda -// DATE: 1/13/99 4:55:15 PM -// -// HISTORY: 1/13/99 [HAI] - File created -// : -// -//=========================================================================== - -//============================================================== #includes == - -//========================================================= class typedefs == - -//====================================================== class definitions == - -class AbstractFile; - -class InputFileHandler -{ -//------------------------------ -//--- public var & functions --- -//------------------------------ -public: // functions - InputFileHandler(const char *infilename); - ~InputFileHandler(void); - - const int read(void *sourceBuffer, int bufferSize); - int deleteFile(const char * filename, bool deleteHandleFlag = false); - -public: // vars - - - //------------------------------- - //--- member vars declaration --- - //------------------------------- -protected: // vars - AbstractFile *file; - -private: // vars - - //----------------------------------- - //--- member function declaration --- - //----------------------------------- -protected: // functions - -private: // functions - void close(void); // close the input file called by destructor - -}; - -//=========================================================================== -//========================================================= inline methods == -//=========================================================================== - - -//=========================================================================== -//============================================================ End-of-file == -//=========================================================================== -#else - #ifdef DEBUG - #pragma message("InputFileHandler.h included more then once!") - #endif -#endif // ifndef __H__ diff --git a/engine/client/application/Miff/src/win32/OutputFileHandler.cpp b/engine/client/application/Miff/src/win32/OutputFileHandler.cpp deleted file mode 100755 index 08987cec..00000000 --- a/engine/client/application/Miff/src/win32/OutputFileHandler.cpp +++ /dev/null @@ -1,163 +0,0 @@ -//=========================================================================== -// -// FILENAME: OutputFileHandler.cpp -// COPYRIGHT: (C) 1999 BY Bootprint Entertainment -// -// DESCRIPTION: file handler for Output file (IFF file) -// AUTHOR: Hideki Ikeda -// DATE: 1/13/99 4:52:42 PM -// -//=========================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "OutputFileHandler.h" - -#include "sharedFile/Iff.h" - -//=========================================================================== -// Constructor - -OutputFileHandler::OutputFileHandler(const char *filename) -{ - outputIFF = new Iff(MAXIFFDATASIZE); - outFilename = NULL; - - setCurrentFilename(filename); -} - -void OutputFileHandler::setCurrentFilename(const char *filename) -{ - delete [] outFilename; - - outFilename = new char[strlen(filename)+1]; - strcpy(outFilename, filename); -} - -//--------------------------------------------------------------------------- -// Destructor - -OutputFileHandler::~OutputFileHandler(void) -{ - if (outputIFF && outFilename) - { - delete outputIFF; - delete [] outFilename; - } - - outputIFF = NULL; -} - - -//--------------------------------------------------------------------------- -// begins a new FORM in the IFF -// -// Return Value: -// bool - true == success -// -// See Also: -// Iff::insertForm() - -void OutputFileHandler::insertForm( - const char *tag - ) -{ - Tag formTag = convertStrToTag(tag); - outputIFF->insertForm(formTag); -} - -//--------------------------------------------------------------------------- -// begins a new CHUNK in the IFF -// -// See Also: -// Iff::insertChunk() - -void OutputFileHandler::insertChunk( - const char *tag - ) -{ - Tag chunkTag = convertStrToTag(tag); - outputIFF->insertChunk(chunkTag); -} - - -//--------------------------------------------------------------------------- -// converts string (4 bytes) form into Tag format -// -// Return Value: -// Tag -// -// Remarks: -// currently, this code is machine dependant code (non portable) and it assumes little endian -// -// See Also: -// Tag - -Tag OutputFileHandler::convertStrToTag( - const char *str - ) -{ - // prepare for hack-o-rama. It is byte order dependant, thus not portable ^_^ - Tag retVal = str[3] + (str[2] * 0x100) + (str[1] * 0x10000) + (str[0] * 0x1000000); - - return(retVal); -} - - -//--------------------------------------------------------------------------- -// adds new chunk data into the current chunk it is in -// -// See Also: -// Iff::insertChunkData() -// - -void OutputFileHandler::insertChunkData( - void *data, - int length - ) -{ - outputIFF->insertChunkData(data, length); -} - -//--------------------------------------------------------------------------- -// exits current FORM section we are in -// -// See Also: -// Iff::exitForm() - -void OutputFileHandler::exitForm(void) -{ - outputIFF->exitForm(); -} - -//--------------------------------------------------------------------------- -// exits current CHUNK we are in -// -// See Also: -// Iff::exitChunk() - -void OutputFileHandler::exitChunk(void) -{ - outputIFF->exitChunk(); -} - - -//--------------------------------------------------------------------------- -// Calls Iff:write() -// -// Return Value: -// -// True if the Iff was successfully written, otherwise false -// -// See Also: -// Iff::write() - -bool OutputFileHandler::writeBuffer(void) -{ - if (outputIFF && outFilename) - return outputIFF->write(outFilename, true); - - return false; -} - -//=========================================================================== - diff --git a/engine/client/application/Miff/src/win32/OutputFileHandler.h b/engine/client/application/Miff/src/win32/OutputFileHandler.h deleted file mode 100755 index 5f4eaf58..00000000 --- a/engine/client/application/Miff/src/win32/OutputFileHandler.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef __OUTPUTFILEHANDLER_H__ -#define __OUTPUTFILEHANDLER_H__ - -//=========================================================================== -// -// FILENAME: OutputFileHandler.h [C:\Projects\new\tools\src\miff\src\] -// COPYRIGHT: (C) 1999 BY Bootprint Entertainment -// -// DESCRIPTION: file handler for output files (IFF file format) -// AUTHOR: Hideki Ikeda -// DATE: 1/13/99 4:55:56 PM -// -// HISTORY: 1/13/99 [HAI] - File created -// : -// -//=========================================================================== - -//============================================================== #includes == - -//========================================================= class typedefs == -#include "sharedFile/Iff.h" - -//====================================================== class definitions == -class OutputFileHandler -{ -//------------------------------ -//--- public var & functions --- -//------------------------------ -public: // functions - OutputFileHandler(const char *filename); - ~OutputFileHandler(void); - bool writeBuffer(void); - - void insertForm(const char *tagName); - void insertChunk(const char *tagName); - void insertChunkData(void *data, int length); - void exitForm(void); - void exitChunk(void); - - void setCurrentFilename(const char *fname); - -public: // vars - - - //------------------------------- - //--- member vars declaration --- - //------------------------------- -protected: // vars - Iff * outputIFF; - char *outFilename; - -enum{ - MAXIFFDATASIZE = 8192 // allocate 8K of memory for a starter - }; - -private: // vars - - //----------------------------------- - //--- member function declaration --- - //----------------------------------- -protected: // functions - -private: // functions - Tag convertStrToTag(const char *str); - -}; - -//=========================================================================== -//========================================================= inline methods == -//=========================================================================== - - -//=========================================================================== -//============================================================ End-of-file == -//=========================================================================== -#else - #ifdef DEBUG - #pragma message("OutputFileHandler.h included more then once!") - #endif -#endif // ifndef __H__ diff --git a/engine/client/application/Miff/src/win32/bison.simple b/engine/client/application/Miff/src/win32/bison.simple deleted file mode 100644 index 5f8f386e..00000000 --- a/engine/client/application/Miff/src/win32/bison.simple +++ /dev/null @@ -1,698 +0,0 @@ -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "bison.simple" - -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -#define MSDOS 1 - -#ifndef alloca -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) -#include -#else /* not sparc */ -#if defined (MSDOS) && !defined (__TURBOC__) -#include -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -#include - #pragma alloca -#else /* not MSDOS, __TURBOC__, or _AIX */ -#ifdef __hpux -#ifdef __cplusplus -extern "C" { -void *alloca (unsigned int); -}; -#else /* not __cplusplus */ -void *alloca (); -#endif /* not __cplusplus */ -#endif /* __hpux */ -#endif /* not _AIX */ -#endif /* not MSDOS, or __TURBOC__ */ -#endif /* not sparc. */ -#endif /* not GNU C. */ -#endif /* alloca not defined. */ - -#ifdef MSDOS -#define alloca(n) malloc(n) -#endif - -/* This is the parser code that is written into each bison parser - when the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -/* Note: there must be only one dollar sign in this file. - It is replaced by the list of actions, each action - as one case of the switch. */ - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 -#define YYACCEPT return(0) -#define YYABORT return(1) -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. - This remains here temporarily to ease the - transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab -#define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(token, value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { yychar = (token), yylval = (value); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -#ifndef YYPURE -#define YYLEX yylex() -#endif - -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval, &yylloc) -#endif -#else /* not YYLSP_NEEDED */ -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval) -#endif -#endif /* not YYLSP_NEEDED */ -#endif - -/* If nonreentrant, generate the variables here */ - -#ifndef YYPURE - -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ - -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ -#endif - -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ - -#if YYDEBUG != 0 -int yydebug = 1; /* nonzero means print parse trace */ -/* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ -#endif - -/* YYINITDEPTH indicates the initial size of the parser's stacks */ - -#ifndef YYINITDEPTH -#define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ - -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 -#endif - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -int yyparse (void); -#endif - -#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#else /* not GNU C or C++ */ -#ifndef __cplusplus - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (to, from, count) - char *to; - char *from; - int count; -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#else /* __cplusplus */ - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (char *to, char *from, int count) -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#endif -#endif - -#line 196 "bison.simple" - -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -#ifdef __cplusplus -#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* not __cplusplus */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -#endif /* not __cplusplus */ -#else /* not YYPARSE_PARAM */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* not YYPARSE_PARAM */ - -int -yyparse(YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - register int yystate; - register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1 = 0; /* lookahead token as an internal (translated) token number */ - - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ - - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ - -#ifdef YYLSP_NEEDED - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - -#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -#define YYPOPSTACK (yyvsp--, yyssp--) -#endif - - int yystacksize = YYINITDEPTH; - -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif - - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ - - int yylen; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss - 1; - yyvsp = yyvs; -#ifdef YYLSP_NEEDED - yylsp = yyls; -#endif - -/* Push a new state, which is found in yystate . */ -/* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. */ -yynewstate: - - *++yyssp = yystate; - - if (yyssp >= yyss + yystacksize - 1) - { - /* Give user a chance to reallocate the stack */ - /* Use copies of these so that the &'s don't force the real ones into memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; -#ifdef YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif - - /* Get the current used size of the three stacks, in elements. */ - int size = yyssp - yyss + 1; - -#ifdef yyoverflow - /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ -#ifdef YYLSP_NEEDED - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); -#else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); -#endif - - yyss = yyss1; yyvs = yyvs1; -#ifdef YYLSP_NEEDED - yyls = yyls1; -#endif -#else /* no yyoverflow */ - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - return 2; - } - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; - yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); - yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); -#ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); -#endif -#endif /* no yyoverflow */ - - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif - - goto yybackup; - yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif - } - else - { - yychar1 = YYTRANSLATE(yychar); - -#if YYDEBUG != 0 - if (yydebug) - { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ -#ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -#endif - fprintf (stderr, ")\n"); - } -#endif - } - - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; - - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); -#endif - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; - - yystate = yyn; - goto yynewstate; - -/* Do the default action for the current state. */ -yydefault: - - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - -/* Do a reduction. yyn is the number of a rule to reduce with. */ -yyreduce: - yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ - -#if YYDEBUG != 0 - if (yydebug) - { - int i; - - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - -$ /* the action file gets copied in in place of this dollarsign */ -#line 498 "bison.simple" - - yyvsp -= yylen; - yyssp -= yylen; -#ifdef YYLSP_NEEDED - yylsp -= yylen; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; - -#ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } -#endif - - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - -yyerrlab: /* here on detecting error */ - - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ - { - ++yynerrs; - -#ifdef YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (yyn > YYFLAG && yyn < YYLAST) - { - int size = 0; - char *msg; - int x, count; - - count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *) malloc(size + 15); - if (msg != 0) - { - strcpy(msg, "parse error"); - - if (count < 5) - { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; - } - } - yyerror(msg); - free(msg); - } - else - yyerror ("parse error; also virtual memory exceeded"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror("parse error"); - } - - goto yyerrlab1; -yyerrlab1: /* here on error raised explicitly by an action */ - - if (yyerrstatus == 3) - { - /* if just tried and failed to reuse lookahead token after an error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); -#endif - - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token - after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - -yyerrdefault: /* current state does not do anything special for the error token. */ - -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; -#endif - -yyerrpop: /* pop the current state because it cannot handle the error token */ - - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; -#ifdef YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - -yyerrhandle: - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - - if (yyn == YYFINAL) - YYACCEPT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - yystate = yyn; - goto yynewstate; -} diff --git a/engine/client/application/Miff/src/win32/mIFF.dox b/engine/client/application/Miff/src/win32/mIFF.dox deleted file mode 100644 index 4c46d600..00000000 --- a/engine/client/application/Miff/src/win32/mIFF.dox +++ /dev/null @@ -1,62 +0,0 @@ -// NOTE: this makes it more convinient for me to make the help screen fancier... -// blah... not that anybody cares... - -printf("\ -Usage:\n\ - mIFF {-%c |--%s=}\n\ - [{-%c |--%s=} | {-%c|--%s}]\n\ - [{-%c|--%s}] [{-%c|--%s}] [{-%c|--%s}]\n\n", - SNAME_INPUT_FILE, LNAME_INPUT_FILE, - SNAME_OUTPUT_FILE, LNAME_OUTPUT_FILE, - SNAME_PRAGMA_TARGET, LNAME_PRAGMA_TARGET, - SNAME_CCCP, LNAME_CCCP, - SNAME_VERBOSE, LNAME_VERBOSE, - SNAME_DEBUG, LNAME_DEBUG); -printf("\ - mIFF {-%c|--%s}\n\n", SNAME_HELP, LNAME_HELP); - -printf("\ -Parameters:\n\ - -%c ,--%s=\n\ - [required] specifies the input path for IFF source file.\n", SNAME_INPUT_FILE, LNAME_INPUT_FILE); -printf("\ - -%c ,--%s=\n\ - [optional] specifies the pathname for the generated \n\ - IFF data file. Note that if neither this nor the following \n\ - option are specified, a default output filename of the source\n\ - file's base name with extension \".iff\" will be used.\n", SNAME_OUTPUT_FILE, LNAME_OUTPUT_FILE); -printf("\ - -%c,--%s\n\ - [optional] specifies the generated output filename should be \n\ - taken from the #pragma options within the source file. \n\ - Allowable #pragma options are: \n\ - #pragma drive \":\"\n\ - #pragma directory \"\"\n\ - #pragma filename \"\"\n\ - #pragma extension \"\"\n", SNAME_PRAGMA_TARGET, LNAME_PRAGMA_TARGET); -printf("\ - -%c,--%s\n\ - [optional] use CCCP rather than CPP.\n", SNAME_CCCP, LNAME_CCCP); -printf("\ - -%c,--%s\n\ - [optional] display more information during execution.\n", SNAME_VERBOSE, LNAME_VERBOSE); -printf("\ - -%c,--%s\n\ - [optional] enable debug mode (save intermediate files).\n", SNAME_DEBUG, LNAME_DEBUG); -printf("\ - -%c,--%s\n\ - [very optional] this help screen.\n", SNAME_HELP, LNAME_HELP); -printf("\ -Examples:\n\ - mIFF -%c foo.bar\n\ - this will generate an iff file foo.iff (default if no parm specified)\n\ - in the current working directory. Even if foo.bar contains #pragma, \n\ - it will create foo.iff because -%c was not specified.\n", SNAME_INPUT_FILE, SNAME_PRAGMA_TARGET); -printf("\ - mIFF -%c \"C:\\my project\\myData\\foo.iff\" --%s=foo.bar\n\ - notice that if you have space in your dirname, use \" to encapsulate \n\ - it.\n", SNAME_OUTPUT_FILE, LNAME_INPUT_FILE); -printf("\ - mIFF -%c foo.bar --%s\n\ - will generate output file specified by #pragma statements \n\ - within file foo.bar.\n", SNAME_INPUT_FILE, LNAME_PRAGMA_TARGET); diff --git a/engine/client/application/Miff/src/win32/miff.cpp b/engine/client/application/Miff/src/win32/miff.cpp deleted file mode 100755 index 43fca051..00000000 --- a/engine/client/application/Miff/src/win32/miff.cpp +++ /dev/null @@ -1,953 +0,0 @@ -//=========================================================================== -// -// FILENAME: mIFF.cpp [C:\Projects\new\tools\src\miff\src\] -// COPYRIGHT: (C) 1999 BY Bootprint Entertainment -// -// DESCRIPTION: make IFF (Console version) -// AUTHOR: Hideki Ikeda -// DATE: 1/07/99 12:57:20 PM -// -// HISTORY: 1/07/99 [HAI] - File created -// : 1/07/99 [HAI] - v1.0 introductory version -// : 1/12/99 [HAI] - v1.1 switched from DOS to Engine library -// : - first attempt was to setup the main entry -// : point via ConsoleEntryPoint() via callback -// : 1/29/99 [HAI] - changed the parameter in MIFFMessage to allow -// : output even in non-verbose mode (for error -// : message purpose. -// : 05/07/99 [HAI]- added MIFFallocString() and MIFFfreeString() -// : to work with memory manager. they are allocated -// : in the lexical analyzer for IDENTIFIERS and STR_LIT -// : deleted after parser parses the rule. -// -// FUNCTION: main() -// : evaluateArgs() -// : help() -// : handleError() -// : preprocessSource() -// : MIFFMessage() -// : callbackFunction() -// -//=========================================================================== - -//========================================================== include files == -#include "sharedFoundation/FirstSharedFoundation.h" - -#include "sharedCompression/SetupSharedCompression.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFile/TreeFile.h" -#include "sharedFoundation/CommandLine.h" -#include "sharedFoundation/Crc.h" -#include "sharedFoundation/Os.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedMemoryManager/MemoryManager.h" -#include "sharedThread/SetupSharedThread.h" - -#include "InputFileHandler.h" -#include "OutputFileHandler.h" - -#include // for memset() -#include // FILE stuff -#include // for getcwd() -#include // for tolower() -#include // for system() - -//================================================= static vars assignment == -const int entryPointVersion = 1; // constantly check DataEntryPoint.h to see if this value has changed - -OutputFileHandler *outfileHandler = NULL; -const int bufferSize = 16 * 1024 * 1024; -const int maxStringSize = 256; -const char version[] = "1.3 September 18, 2000"; - -// vars set by pragmas or via command line -char drive[8]; // should be no more then 2 char "C:" -char directory[maxStringSize]; -char filename[maxStringSize]; -char extension[8]; // we'll truncate if the extension is more then 8 chars... -char inFileName[512]; - -// switches to be sent to mIFF Compiler -char sourceBuffer[bufferSize]; -char outFileName[512]; // x2 to combine filename, dir, and ext -bool usePragma = false; -bool useCCCP = false; -bool verboseMode = false; // default to non-verbose mode -bool debugMode = false; // set this on and the preprocessed source file (mIFF.$$$) won't be deleted - -static bool runningUnderNT; - -enum errorType { - ERR_FILENOTFOUND = -1, - ERR_ARGSTOOFEW = -2, - ERR_BUFFERTOOSMALL = -3, - ERR_UNKNOWNDIR = -4, - ERR_PREPROCESS = -5, - ERR_MULTIPLEINFILE = -6, - ERR_PARSER = -7, - ERR_ENGINE = -8, - - ERR_HELPREQUEST = -9, - ERR_OPTIONS = -10, - - ERR_WRITEERROR = -11, - - ERR_NONE = 0 - }; -char err_msg[256]; -errorType errorFlag = ERR_NONE; // assume no error (default) - - -// long and short name definitions for command line options - -static const char * const LNAME_HELP = "help"; -static const char * const LNAME_INPUT_FILE = "inputfile"; -static const char * const LNAME_OUTPUT_FILE = "outputfile"; -static const char * const LNAME_PRAGMA_TARGET = "pragmatarget"; -static const char * const LNAME_CCCP = "cccp"; -static const char * const LNAME_VERBOSE = "verbose"; -static const char * const LNAME_DEBUG = "debug"; - -static const char SNAME_HELP = 'h'; -static const char SNAME_INPUT_FILE = 'i'; -static const char SNAME_OUTPUT_FILE = 'o'; -static const char SNAME_PRAGMA_TARGET = 'p'; -static const char SNAME_CCCP = 'c'; -static const char SNAME_VERBOSE = 'v'; -static const char SNAME_DEBUG = 'd'; - -// following is the command line option spec tree needed for command line processing -static CommandLine::OptionSpec optionSpecArray[] = -{ - OP_BEGIN_SWITCH(OP_NODE_REQUIRED), - - // help - OP_SINGLE_SWITCH_NODE(SNAME_HELP, LNAME_HELP, OP_ARG_NONE, OP_MULTIPLE_DENIED), - - // real options - OP_BEGIN_SWITCH_NODE(OP_MULTIPLE_DENIED), - OP_BEGIN_LIST(), - // input filename required - OP_SINGLE_LIST_NODE(SNAME_INPUT_FILE, LNAME_INPUT_FILE, OP_ARG_REQUIRED, OP_MULTIPLE_DENIED, OP_NODE_REQUIRED), - - // optional, mutually exclusive output file specification options - // if none specified, generate derive output filename from input filename - OP_BEGIN_LIST_NODE(OP_MULTIPLE_DENIED, OP_NODE_OPTIONAL), - OP_BEGIN_SWITCH(OP_NODE_OPTIONAL), - // specify output filename on command line - OP_SINGLE_SWITCH_NODE(SNAME_OUTPUT_FILE, LNAME_OUTPUT_FILE, OP_ARG_REQUIRED, OP_MULTIPLE_DENIED), - - // use pragma target for output filename - OP_SINGLE_SWITCH_NODE(SNAME_PRAGMA_TARGET, LNAME_PRAGMA_TARGET, OP_ARG_NONE, OP_MULTIPLE_DENIED), - OP_END_SWITCH(), - OP_END_LIST_NODE(), - - // if specified, use cccp instead of cpp - OP_SINGLE_LIST_NODE(SNAME_CCCP, LNAME_CCCP, OP_ARG_NONE, OP_MULTIPLE_DENIED, OP_NODE_OPTIONAL), - - // if specified, be verbose - OP_SINGLE_LIST_NODE(SNAME_VERBOSE, LNAME_VERBOSE, OP_ARG_NONE, OP_MULTIPLE_DENIED, OP_NODE_OPTIONAL), - - // if specified, enter debug info - OP_SINGLE_LIST_NODE(SNAME_DEBUG, LNAME_DEBUG, OP_ARG_NONE, OP_MULTIPLE_DENIED, OP_NODE_OPTIONAL), - OP_END_LIST(), - OP_END_SWITCH_NODE(), - - OP_END_SWITCH() -}; -static const int optionSpecCount = sizeof(optionSpecArray) / sizeof(optionSpecArray[0]); - -//================================================= function prototypes == -int main(int argc, char *argv[]); -static errorType evaluateArgs(void); -static void help(void); -static void handleError(errorType error); -static int preprocessSource(char *sourceName); -static void callbackFunction(void); -static errorType loadInputToBuffer(void *destAddr, int maxBufferSize); - -// functions called by parser.yac and parser.lex -extern "C" void MIFFMessage(char *msg, int forceOut); -extern "C" void MIFFSetError(void); -extern "C" void MIFFSetIFFName(const char *newFileName); -extern "C" void MIFFinsertForm(const char *formName); -extern "C" void MIFFinsertChunk(const char *chunkName); -extern "C" void MIFFinsertChunkData(void * buffer, unsigned bufferSize); -extern "C" int MIFFloadRawData(char *fname, void * buffer, unsigned maxBufferSize); -extern "C" void MIFFexitChunk(void); -extern "C" void MIFFexitForm(void); -extern "C" unsigned long MIFFgetLabelHash(char *inputStream); - -// external functions found in parser.lex file -extern "C" void MIFFCompile(char *inputStream, char *inputFname); -extern "C" void MIFFCompileInit(char *inputStream, char *inputFname); - -//--------------------------------------------------------------------------- -// main entry point from console call -// -// Return Value: -// errorType - see enumeration; 0 if no errors -// -// Remarks: -// -// -// See Also: -// -// -// Revisions and History: -// 1/07/99 [HAI] - created -// -int main( int argc, // number of args in commandline - char * argv[] // list of pointers to strings - ) -{ - memset(sourceBuffer, 0, bufferSize); - - SetupSharedThread::install(); - SetupSharedDebug::install(4096); - - SetupSharedFoundation::Data SetupSharedFoundationData (SetupSharedFoundation::Data::D_console); - SetupSharedFoundationData.useWindowHandle = false; - SetupSharedFoundationData.argc = argc; - SetupSharedFoundationData.argv = argv; - SetupSharedFoundationData.demoMode = false; - SetupSharedFoundation::install (SetupSharedFoundationData); - - SetupSharedCompression::install(); - - SetupSharedFile::install(false); - - TreeFile::addSearchAbsolute(0); - TreeFile::addSearchPath (".", 0); - - SetupSharedFoundation::callbackWithExceptionHandling(callbackFunction); - SetupSharedFoundation::remove(); - - SetupSharedThread::remove(); - return static_cast (errorFlag); -} - -//--------------------------------------------------------------------------- -// callback function for Engine's console entry point -// -// Return Value: -// none -// -// Remarks: -// this is like a substitute of main() -// -// See Also: -// -// -// Revisions and History: -// 1/12/99 [HAI] - created -// -static void callbackFunction(void) -{ - outfileHandler = NULL; - -#ifdef WIN32 - - // check if we're running under NT - OSVERSIONINFO osInfo; - Zero(osInfo); - - osInfo.dwOSVersionInfoSize = sizeof(osInfo); - const BOOL getVersionResult = GetVersionEx(&osInfo); - if (getVersionResult) - runningUnderNT = (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); - if (runningUnderNT) - DEBUG_REPORT_LOG(true, ("MIFF: running under Windows NT platform\n")); - else - DEBUG_REPORT_LOG(true, ("MIFF: running under non-NT Windows platform\n")); - -#endif - - errorFlag = evaluateArgs(); - if (ERR_NONE == errorFlag) - { - outfileHandler = new OutputFileHandler(outFileName); - MIFFCompile(sourceBuffer, inFileName); - } - else - handleError(errorFlag); - - if (outfileHandler) - { - // only write output IF there was no error - if (ERR_NONE == errorFlag) - { - if (!outfileHandler->writeBuffer()) - { - fprintf(stderr, "MIFF: failed to write output file \"%s\"\n", outFileName); - errorFlag = ERR_WRITEERROR; - } - } - delete outfileHandler; - } -} - -//--------------------------------------------------------------------------- -// Evaluates the command line and sets up the environment variables required for mIFF to function -// -// Return Value: -// errorType -// -// Remarks: -// argc's and argv's are substituted with CommandLine::functions() -// -// See Also: -// -// -// Revisions and History: -// 1/07/99 [HAI] - created -// -static errorType evaluateArgs(void) -{ - errorType retVal = ERR_NONE; - - // parse the commandline - const CommandLine::MatchCode mc = CommandLine::parseOptions(optionSpecArray, optionSpecCount); - if (mc != CommandLine::MC_MATCH) - { - // -TF- add call to retrieve command line error buffer for display (as soon as it is written!) - printf("WARNING: usage error detected, printing help.\n"); - help(); - return ERR_OPTIONS; - } - else if (CommandLine::getOccurrenceCount(SNAME_HELP)) - { - // user specified help - help(); - retVal = ERR_HELPREQUEST; - return(retVal); - } - - // at this point, we can assume a valid combination of options has been specified on the commandline - - - // setup input filename - strcpy(inFileName, CommandLine::getOptionString(SNAME_INPUT_FILE)); - - - // handle output filename spec - if (CommandLine::getOccurrenceCount(SNAME_OUTPUT_FILE)) - { - strcpy(outFileName, CommandLine::getOptionString(SNAME_OUTPUT_FILE)); - } - else if (CommandLine::getOccurrenceCount(SNAME_PRAGMA_TARGET)) - { - // use pragma target within iff source for output filename - usePragma = true; - } - else - { - // no output option specified on commandline, derive from input filename - char *terminator; - - // start with input file pathname - strcpy(outFileName, inFileName); - - // try to terminate at rightmost '.' - terminator = strrchr(outFileName, '.'); - if (terminator) - *terminator = 0; - - // append the default iff extension - strcat(outFileName, ".iff"); - } - - - // handle options (get them out of the way, as we use them later) - useCCCP = (CommandLine::getOccurrenceCount(SNAME_CCCP) != 0); - verboseMode = (CommandLine::getOccurrenceCount(SNAME_VERBOSE) != 0); - debugMode = (CommandLine::getOccurrenceCount(SNAME_DEBUG) != 0); - - - // preprocess the input file - if (0 == preprocessSource(inFileName)) - { - if (verboseMode) - { - sprintf(err_msg,"Now compiling %s...\n", inFileName); - MIFFMessage(err_msg, 0); - } - if (ERR_NONE == retVal) - retVal = loadInputToBuffer(sourceBuffer, bufferSize); - } - else - { - // preprocessSource returned an error... - retVal = ERR_PREPROCESS; - } - if (retVal != ERR_NONE) - return retVal; - - return retVal; - -#if 0 - - errorType retVal = ERR_NONE; // assume no error has been found - bool outPathUsed = false; // flag to monitor if -o flag was used, if so, we can ignore -d, -p, -e, -f - bool inFileEntered = false; - int argc = CommandLine::getPlainCount(); - - // get default values from DOS - char currentDir[maxStringSize]; - if (NULL == getcwd(currentDir, maxStringSize)) // get current working directory - { - retVal = ERR_UNKNOWNDIR; - return(retVal); - } - drive[0] = currentDir[0]; // drive letter - drive[1] = 0; // and null terminate it - strcpy(extension, "IFF"); // default to uppercase .IFF - strcpy(directory, ¤tDir[2]); // get everything after the Drive: including the first backslash - filename[0] = 0; - - // see specs.txt for requests - // scan for any argv's that has '-' in the argv[n][0]'s character - for (int index = 0; index < argc; index++) // note: if using argv[] rather then CommandLine::getPlainString() then start with 1 rather then 0 - { - if ('-' == CommandLine::getPlainString(index)[0]) - { - // we've found a parameter switch - switch (tolower(CommandLine::getPlainString(index)[1])) // assume non case sensitive switches - { - case 'i': // install via #pragma - { - usePragma = true; - break; - } - - case 'c': // use CCCP instead of CPP - useCCCP = true; - break; - - case 'v': // don't show any debug message - verboseMode = true; - break; - - case '$': - debugMode = true; - break; - - case 'o': // target output file name and path (complete path) - { - index++; // next param - outPathUsed = true; - strcpy(outFileName, CommandLine::getPlainString(index)); - break; - - } - - case 'd': // target drive letter (-p must be present) - { - if (!outPathUsed) - { - index++; // next param - strcpy(drive, CommandLine::getPlainString(index)); - } - else - index++; // skip the drive letter arg that SHOULD follow the -d option - break; - } - - case 'p': // target pathname - { - if (!outPathUsed) - { - index++; // next param - strcpy(directory, CommandLine::getPlainString(index)); - } - else - index++; // skip the pathname arg that follows the -p option - break; - } - - case 'f': // target filename - { - if (!outPathUsed) - { - index++; // next param - strcpy(filename, CommandLine::getPlainString(index)); - } - else - index++; // skip the filename arg that follows the -f - break; - } - - case 'e': // target extension - { - if (!outPathUsed) - { - index++; // next param - strcpy(extension, CommandLine::getPlainString(index)); - } - else - index++; // skip the extension arg that follows the -e - break; - } - - case 'h': // help! - case '?': - { - help(); - index = argc; // force to exit - retVal = ERR_HELPREQUEST; - return(retVal); // special case, ONLY time I call return() in the middle of the function (because I check for argc < 2 at the end of the code) - break; - } - - default: - { - sprintf(err_msg, "\nUnknown parameter %s, use -h to seek help...\n", CommandLine::getPlainString(index)); - MIFFMessage(err_msg, 1); - index = argc; // force to exit - break; - } - } - } - else - { - // we found an arg that doesn't start with '-' so let's assume it's a filename - if (!inFileEntered) - { - strcpy(inFileName, CommandLine::getPlainString(index)); - inFileEntered = true; - } - else - { - retVal = ERR_MULTIPLEINFILE; - index = argc; - } - - // now construct the DEFAULT filename for this file by scanning backwards to front and only extracting the filename (no extension, no path) - if (ERR_NONE == retVal) - { - char sourceName[maxStringSize]; - strcpy(sourceName, inFileName); // make a duplicate for us to play with - for (int strIndex = strlen(sourceName); strIndex > 0; strIndex--) - { - if ('.' == sourceName[strIndex]) - sourceName[strIndex] = 0; // put a stopper here... we are assuming that '.' indicates extension! I'm going to assume that the person is just testing me if s/he decides to use filename like "foo.bar.psych" which will truncate to "foo" - if ('\\' == sourceName[strIndex]) - break; // get out, for we've reached the path name... - } - - // ok, by here, strIndex should point to either beginning of the string, or where the first '\' was found scanning backwards - strcpy(filename, &sourceName[strIndex]); // ta-da-! - } - } - } - - if (inFileEntered) - { - if (0 == preprocessSource(inFileName)) - { - if (verboseMode) - { - // using err_msg as my temp buffer... - sprintf(err_msg,"Now compiling %s\n", inFileName); - MIFFMessage(err_msg, 0); - } - - if (ERR_NONE == retVal) - retVal = loadInputToBuffer(sourceBuffer, bufferSize); - } - else // preprocessSource returned an error... - { - retVal = ERR_PREPROCESS; - } - } - else // inFileEntered == false - { - MIFFMessage("Missing input filename in command line!", 1); - } - - // construct a outFileName[] based on drive[], directory[], filename[], and extension[] - if (!outPathUsed && (ERR_NONE == retVal)) - { - if (inFileName[0]) // make sure the user has entered a input filename - sprintf(outFileName,"%s:%s\\%s.%s", drive, directory, filename, extension); - } - - if (argc < 1) - retVal = ERR_ARGSTOOFEW; // we can do this because we know -h was not entered... - - return(retVal); - -#endif - -} - - -//--------------------------------------------------------------------------- -// reads the tmeporary files spit out by CCCP and stuffs the plain text into source buffer -// -// Return Value: -// errorType -// -// Remarks: -// -// -// See Also: -// -// -// Revisions and History: -// 1/14/99 [HAI] - created -// -static errorType loadInputToBuffer( - void * dest, // destination address of where you want the date to be read - int maxBufferSize // maximum destination data pool size - ) -{ - errorType retVal = ERR_NONE; - InputFileHandler *inFileHandler = new InputFileHandler("mIFF.$$$"); - - int sizeRead = inFileHandler->read(dest, maxBufferSize); - if (sizeRead >= maxBufferSize) - { - retVal = ERR_BUFFERTOOSMALL; - } - else - { - reinterpret_cast(dest)[sizeRead] = 0; // so stupid... but if you don't zero-terminate at exact spot, YYInput may chokes because of extra grammer that may exist... - } - if (!debugMode) - inFileHandler->deleteFile("mIFF.$$$", true); // no need for temp file now... - - // we've successfully read the file, now close it... - delete inFileHandler; - - return(retVal); -} - -//--------------------------------------------------------------------------- -// help function called by main upon -h switch -// -// Return Value: -// none -// -// Remarks: -// #include's mIFF.dox -// make sure to update the version when modified. -// Notice that help() does NOT go thru MIFFMessage() because we want it to -// print out whether it's verbose mode or not... -// -// See Also: -// mIFF.dox -// -// Revisions and History: -// 1/07/99 [HAI] - created -// -static void help(void) -{ - printf("\nmIFF v%s (DOS version) - Bootprint Ent. (c) 1999\n", version); - printf("Hideki Ikeda\n"); -#include "mIFF.dox" -} - - -//--------------------------------------------------------------------------- -// upon exit from main(), if error has been found, it calls here to inform the user of the type of errors it has encounted. -// -// Return Value: -// none -// -// Remarks: -// use -q switch to suppress error messages - but in shell, return value can be used to determine the handling -// -// See Also: -// -// -// Revisions and History: -// 1/07/99 [HAI] - created -// -static void handleError(errorType error) -{ - if (ERR_NONE == error) - return; - - switch (error) - { - case ERR_NONE: - break; - - case ERR_FILENOTFOUND: - MIFFMessage("ERROR: INPUT File not found!\n", 1); - break; - - case ERR_ARGSTOOFEW: - MIFFMessage("ERROR: Not enough arguments. Use -h for help.\n", 1); - break; - - case ERR_BUFFERTOOSMALL: - MIFFMessage("ERROR: Internally allocated buffer for reading\nsource code is too small, increase buffer and re-compile\n", 1); - break; - - case ERR_UNKNOWNDIR: - MIFFMessage("ERROR: Directory unknown...\n", 1); - break; - - case ERR_PREPROCESS: - MIFFMessage("ERROR: Possible problems running the GNU C Preprocessor.\n", 1); - break; - - case ERR_MULTIPLEINFILE: - MIFFMessage("ERROR: There can only be ONE inputfile name.\nPerhaps you've forgotten the -o option flag\n", 1); - break; - - case ERR_ENGINE: - MIFFMessage("ERROR: Engine returned a non-zero value...\n", 1); - break; - - case ERR_PARSER: - MIFFMessage("ERROR: Parser error\n", 1); - break; - - case ERR_HELPREQUEST: - break; - - case ERR_OPTIONS: - MIFFMessage("ERROR: Failed to handle command line options\n", 1); - break; - - default: - MIFFMessage("ERROR: Unknown error, you suck!\n", 1); - break; - } -} - - -///////////////////////////////////////////////////////////////////////////// -// gotta write all these externs because you can't call C++ class based non-static -// functions from C... So we will use here as the bridge between the two -// languages - - -//--------------------------------------------------------------------------- -// Message output handler called by ALL external "C" functions -// -// Return Value: -// none -// -// Remarks: -// all the messages that are displayed are channeled thru this function. Note the -q quiet mode suppresses all messages. -// this is an extern "C" function -// -// See Also: -// yyerror() -// -// Revisions and History: -// 1/07/99 [] - created -// -extern "C" void MIFFMessage(char *message, // null terminated string to be displayed - int forceOutput) // if non-zero, it will print out even in quiet mode (for ERRORs) -{ - if (forceOutput) - fprintf(stdout, "%s\n", message); - else if (verboseMode) - fprintf(stdout, "%s\n", message); - OutputDebugString(message); - OutputDebugString("\n"); -} - -// Only call this via parser!!! -extern "C" void MIFFSetError(void) -{ - errorFlag = ERR_PARSER; -} - -//--------------------------------------------------------------------------- -// validation of the filename passed are legal. -// -// Return Value: -// bool usePragma - whether #pragma is ignored or not -// -// Remarks: -// if -i switch is used then #pragma's are expected -// this is an extern "C" function -// -// See Also: -// -// -// Revisions and History: -// 1/07/99 [ ] - created -// -extern "C" int validateTargetFilename( char *targetFileName, // pointer to where we can store the string filename - unsigned maxTargetBufSize // size of the filename string buffer - ) -{ - if (strlen(outFileName) > maxTargetBufSize) - MIFFMessage("Internal error, increase string buffer size in parser.yac and recompile!", 1); - - strcpy(targetFileName, outFileName); - - return(usePragma); -} - - -//--------------------------------------------------------------------------- -// function calls CCCP or CPP via shell to preprocess the source code for #include's and #define's via C-Compatible Compiler Preprocessor -// -// Return Value: -// shell return value (4DOS is very generous on returning different values, while DOS just returns 0 all the time) -// -// Remarks: -// use -c switch to use CCCP rather then CPP in your search path -// -// See Also: -// -// -// Revisions and History: -// 1/07/99 [ ] - created -// -static int preprocessSource(char *sourceName) -{ - char shellCommand[512]; - int retVal = 0; - - memset(shellCommand, 0, sizeof(shellCommand)); - -// if (!runningUnderNT) - { - - if (verboseMode) - MIFFMessage("Preprocessing... via CCCP", 0); - - // CCCP parameters: - // -nostdinc -nostdinc++ - do NOT search for standard include directory; without this, your - // puter would be just twiddling its thumb because CCCP can't find it... - // -pedantic - issue warnings (use pedantic-errors if you want it as errors) - // required by the ANSI C standard in certain cases such as comments that - // follow the #else/#endif - // -dD - output #defines (for the purpose of error msg I parse) - // -H - display the name of the header/included files (verbose mode) - // -P - originally, I had this... so it won't show the # line_num "filename" ??? - if (!useCCCP && verboseMode) - { - sprintf(shellCommand, "cpp.exe -nostdinc -nostdinc++ -x c++ -pedantic -Wall -dD -H %s mIFF.$$$", sourceName); - } - else if (!useCCCP && !verboseMode) - { - sprintf(shellCommand, "cpp.exe -nostdinc -nostdinc++ -x c++ -pedantic -Wall -dD %s mIFF.$$$", sourceName); - } - else if (useCCCP && verboseMode) - { - sprintf(shellCommand, "cccp.exe -nostdinc -nostdinc++ -x c++ -pedantic -Wall -dD -H %s mIFF.$$$", sourceName); - } - else - sprintf(shellCommand, "cccp.exe -nostdinc -nostdinc++ -x c++ -pedantic -Wall -dD %s mIFF.$$$", sourceName); - } -// else - { - // running under NT. Use the MSVC cl since it deals with long filenames on fat16/fat32 partitions correctly - // and ccp and cccp don't -// sprintf(shellCommand, "cl /nologo /W4 /EP %s > mIFF.$$$", sourceName); - } - - retVal = system(shellCommand); - if (2 == retVal) // actually, I think 4DOS reports 2 for cannot find file, but DOS returns a 0... - { - REPORT_LOG(true, ("failed to execute following shell command (%d):\n", retVal)); - REPORT_LOG(true, (" %s\n", shellCommand)); - MIFFMessage("\n\nERROR: Cannot find preprocessor (either CCCP.EXE, CPP.EXE or CL.EXE (under NT) in the search path...\n", 1); - MIFFMessage("Please make sure the preprocessor is in your search path!\n", 1); - } - return(retVal); -} - -extern "C" void MIFFSetIFFName(const char *newFileName) -{ - if (ERR_NONE != errorFlag) - return; - - if (outfileHandler) - outfileHandler->setCurrentFilename(newFileName); -} - -extern "C" void MIFFinsertForm(const char *formName) -{ - if (ERR_NONE != errorFlag) - return; - - if (outfileHandler) - outfileHandler->insertForm(formName); -} - -extern "C" void MIFFinsertChunk(const char *chunkName) -{ - if (ERR_NONE != errorFlag) - return; - - if (outfileHandler) - outfileHandler->insertChunk(chunkName); -} - -extern "C" void MIFFinsertChunkData(void * buffer, unsigned bufferSize) -{ - if (ERR_NONE != errorFlag) - return; - - if (outfileHandler) - outfileHandler->insertChunkData(buffer, bufferSize); -} - -extern "C" int MIFFloadRawData(char *fname, void * buffer, unsigned maxBufferSize) -{ - int sizeRead = -1; - - if (ERR_NONE != errorFlag) - return(sizeRead); // should be -1 - - InputFileHandler * inFileName = new InputFileHandler(fname); - - sizeRead = inFileName->read(buffer, maxBufferSize); - if (static_cast(sizeRead) >= maxBufferSize) - { - handleError(ERR_BUFFERTOOSMALL); - sizeRead = -1; - } - delete inFileName; - - return(sizeRead); -} - -extern "C" void MIFFexitChunk(void) -{ - if (ERR_NONE != errorFlag) - return; - - if (outfileHandler) - outfileHandler->exitChunk(); -} -extern "C" void MIFFexitForm(void) -{ - if (ERR_NONE != errorFlag) - return; - - if (outfileHandler) - outfileHandler->exitForm(); -} - -extern "C" char * MIFFallocString(int sizeOfString) -{ - return(new char[sizeOfString]); -} - -extern "C" void MIFFfreeString(char * pointer) -{ - delete [] pointer; -} - -extern "C" unsigned long MIFFgetLabelHash(char * inputStream) -{ - return (unsigned long)Crc::calculate(inputStream); -} - -//=========================================================================== -//============================================================ End-of-file == -//=========================================================================== - diff --git a/engine/client/application/Miff/src/win32/parser.lex b/engine/client/application/Miff/src/win32/parser.lex deleted file mode 100644 index 3989ec88..00000000 --- a/engine/client/application/Miff/src/win32/parser.lex +++ /dev/null @@ -1,517 +0,0 @@ -%option full - -%{ -/*-----------------------------------------------------------------------------** -** FILE: parser.lex ** -** (c) 1998 - Bootprint GTInteractive ** -** ** -** DESCRIPTION: lexical analyzer for mIFF ** -** ** -** AUTHOR: Hideki Ikeda ** -** ** -** HISTORY: ** -** ** -** Notes: companion to parser.yac ** -**-----------------------------------------------------------------------------*/ -/* Disable compiler warnings (we want warning level 4) for anything that flex spits out */ -#pragma warning (disable: 4127) /* conditional expression is constant - ie. while(1) */ -#pragma warning (disable: 4131) /* usage of old-style declarator */ -#pragma warning (disable: 4098) /* void function returning a vlue - this is because yyterminate() is defined as return() */ -#pragma warning (disable: 4505) /* unreferenced local function has been removed (to be direct: yyunput()) */ - -/* include files */ -#include "parser.h" /* NOTE: make sure this matches what Bison/yacc spits out */ - -#include -#include - -/*--------------------------------** -** exteranl prototype declaration ** -**--------------------------------*/ -void MIFFMessage(char *message, int forceOutput); -void MIFFSetError(void); -char * MIFFallocString(int sizeOfString); -void MIFFfreeString(char * pointer); - -int yyparse(); - -/* prototype declaration */ -int MIFFYYInput(char *buf,int max_size); -void initParser(void); -void count(void); -void yyerror(char *err); -void open_brace(void); -void close_brace(void); -int count_brace(void); - -void printString(char *str); - -/* global vars that has to be pre-declared because it's referenced by the lexical analyzer */ -int initialCompile = 0; -int globalErrorFlag = 0; -char inFileName[512]; /* keep track of source file name for error message */ - -#undef YY_INPUT -#define YY_INPUT(buf,result,max_size) (result = MIFFYYInput(buf,max_size)) - -#define SPACE_COUNT_FOR_TAB (8) - -%} - -DIGIT [0-9] -HEXDIGIT [0-9a-fA-F] -LETTER [A-z_] -FLOATSYM (f|F|l|L) -INTSYM (u|U|l|L)* -EXP (e|E)(\+|-)? - -%% -"//"[^\n]*\n { - /* don't do count(); */ - } - -"#define"[^\n]*\n { - /* don't you love regular expression? [^\n]* everything but \n, and then end with \n */ - /* don't do count(); just like comments */ - /* return(DEFINE); <-- note: #define's are ignored in parser for they are handled via preprocessors CCCP */ - } - -\"([^\"]|(\\\"))*\" { - /* start with " then ( [^\"] | (\\\") )* which means either anything but " OR \" of multiple encounter, and then close with " */ - /* case for "string" literals */ - char *s; // allocate space for string and pass the string pointer rather then yytext - - count(); - s = MIFFallocString(strlen(yytext) + 1); - strcpy(s, yytext+1); /* strip off the double quotes */ - s[strlen(yytext+1)-1] = 0; /* strip off the ending double quotes */ - yylval.stype = s; - return(STR_LIT); - } - -"form" | -"FORM" { - count(); - return(FORM); - } - -"chunk" | -"CHUNK" { - count(); - return(CHUNK); - } - -"int32" { - count(); - return(INT32); - } -"int16" { - count(); - return(INT16); - } -"int8" { - count(); - return(INT8); - } -"uint32" { - count(); - return(UINT32); - } -"uint16" { - count(); - return(UINT16); - } -"uint8" { - count(); - return(UINT8); - } -"float" { - count(); - return(FLOAT); - } -"double" { - count(); - return(DOUBLE); - } -"string" | -"cstring" | -"CString" { - count(); - return(STRING); - } -"wstring" | -"WString" { - count(); - return(WSTRING); - } -"labelhash" { - count(); - return(LABELHASH); - } - -"sin" { - count(); - return(SIN); - } -"cos" { - count(); - return(COS); - } -"tan" { - count(); - return(TAN); - } -"asin" { - count(); - return(ASIN); - } -"acos" { - count(); - return(ACOS); - } -"atan" { - count(); - return(ATAN); - } - -"enum" { - count(); - return(ENUMSTRUCT); - } - -"includeIFF" | -"includeiff" { - count(); - return(INCLUDEIFF); - } -"include" { - count(); - return(INCLUDEBIN); - } -"#include" { - count(); - return(INCLUDESOURCE); - } -"#pragma" { - count(); - return(PRAGMA); - } -"drive" { - count(); - return(PRAGMA_DRIVE); - } -"directory" { - count(); - return(PRAGMA_DIR); - } -"filename" { - count(); - return(PRAGMA_FNAME); - } -"extension" { - count(); - return(PRAGMA_EXT); - } - -{LETTER}({LETTER}|{DIGIT})* { - /* label identifiers */ - char *s; // allocate space for string and pass the string pointer rather then yytext - - count(); - s = MIFFallocString(strlen(yytext) + 1); - strcpy(s, yytext); - yylval.stype = s; - return(IDENTIFIER); - } - -{DIGIT}*"."{DIGIT}+{FLOATSYM}? { - /* handle numericals (floats) */ - /* - * {DIGIT}*"."{DIGIT}+{FLOATSYM}? means zero or more digits . one or more digit and with/without f at the end - */ - count(); - /* make sure to store it to dtype, and use strtod to convert to double */ - yylval.dtype = strtod((char *) yytext, (char **) 0); - return(FLOAT_LIT); - } - -0[xX]{HEXDIGIT}+{INTSYM}? | -0{DIGIT}+{INTSYM}? | -{DIGIT}+{INTSYM}? { - /* handle numericals ( hex, ints) */ - /* - * 0[xX]{HEXDIGIT}+{INTSYM}? means start with 0, then X one or more digit and you can put int symbol if you want - * 0{DIGIT}+{INTSYM}? means start with 0, one ore more digit and w/or w/o int symbol - * {DIGIT}+{INTSYM}? means one or more digit and w/or w/o int symbol - */ - count(); - /* make sure to store it to ltype (long), and use strtod to convert to unsigned long */ - yylval.ltype = strtoul((char *) yytext, (char **) 0, 0); - return(LIT); - } - -'(\\.|[^\\'])+' { - /* handle 'x' - single character */ - count(); - yylval.chtype = yytext[1]; - return(CHAR_LIT); - } - -"#" { - /* #'s are used for informing the parser which file and line number it is processing (debug purpose) */ - count(); - return(POUND); - } - -">>" { - count(); - return(SHIFTRIGHT); - } -"<<" { - count(); - return(SHIFTLEFT); - } -"^^" { - count(); - return(RAISEDPOWER); - } - -"[" | -"]" | -"^" | -";" | -"," | -":" | -"=" | -"(" | -")" | -"." | -"&" | -"!" | -"~" | -"-" | -"+" | -"*" | -"/" | -"%" | -"<" | -">" | -"|" | -"?" { - /* valid operators */ - count(); - yylval.stype = yytext; - return(* yylval.stype); - } - -"{" { - count(); - open_brace(); - yylval.stype = yytext; - return(* yylval.stype); - } -"}" { - count(); - close_brace(); - yylval.stype = yytext; - return(* yylval.stype); - } - -[ \t\n\r]+ { - /* white spaces and newlines are ignored */ - count(); - } - -<> { - /* do a count on bracket matching... */ - if (0 == count_brace()) - { - if (!initialCompile && !globalErrorFlag) - MIFFMessage("mIFF successfully compiled!\n", 0); - } - - yyterminate(); /* tell yyparse() it's time to quit! DO NOT comment or delete this line! */ - } - -. { - /* anything that's not a rule from above goes here */ - count(); - yyerror((char *) yytext); - } -%% - -/*--------------------** -** C supporting codes ** -**--------------------*/ - -/*------------------** -** static variables ** -**------------------*/ -static char *MIFFInputStream; -int column = 0; -int line_num = 1; -int line_num2 = 1; -char error_line_buffer[256]; -long brace_counter = 0; - - -/*---------------------------------------------------------------------** -** Initialize all the static variables before all calls to MIFFCompile ** -**---------------------------------------------------------------------*/ -void initParser(void) -{ - line_num = 1; - column = 0; - - brace_counter = 0; - error_line_buffer[0] = 0; - - globalErrorFlag = 0; - - memset(inFileName, 0, 512); /* make sure to change this size if the char array gets bigger... */ -} - -/*-------------------------------------------------** -** generate a dialog box to MFC to report an error ** -**-------------------------------------------------*/ -void yyerror(char *err) /* called by yyparse() */ -{ - char myString[256]; - - if (!initialCompile) - { - /* spit it out in MSDev error format */ - sprintf(myString, "\n%s(%d) : yyERROR : %s\n>>%s<<", inFileName, line_num, err, error_line_buffer); - MIFFMessage(myString, 1); - globalErrorFlag = 1; - MIFFSetError(); /* set global error flag for shell as well */ - yyterminate(); - } - -} - -/*-------------------------** -** our version of YY_INPUT ** -**-------------------------*/ -int MIFFYYInput(char *buf,int max_size) -{ - int len = strlen(MIFFInputStream); - int n = max_size < len ? max_size : len; - if (n > 0) - { - memcpy(buf,MIFFInputStream,n); - MIFFInputStream += n; - } - return(n); -} - -/*------------------------------------------------------------** -** line and column counter for error searching during compile ** -**------------------------------------------------------------*/ -void count() -{ - int i; - static char *elb = error_line_buffer; - for (i = 0; yytext[i] != '\0'; i++) - { - if (yytext[i] == '\n') - { - column = 0; - line_num++; - elb = error_line_buffer; - } - else - { - *elb++ = yytext[i]; - if (yytext[i] == '\t') - column += SPACE_COUNT_FOR_TAB - (column & (SPACE_COUNT_FOR_TAB - 1)); - else - column++; - } - *elb = 0; - } -} - -/*--------------------------------------------------------------** -** sets up current line number and filename the error came from ** -**--------------------------------------------------------------*/ -void setCurrentLineNumber(int lineNum, char * fileName, int mysteryNum) -{ - line_num = lineNum; - strcpy(inFileName, fileName); - line_num2 = mysteryNum; -} - -/*----------------------------------------------** -** MIFFCompile called by CMIFFView::OnCompile() ** -**----------------------------------------------*/ -void MIFFCompile(char *inputStream, char *inputFileName) -{ - MIFFInputStream = inputStream; - yyrestart(0); - initParser(); - initialCompile = 0; - strcpy(inFileName, inputFileName); - yyparse(); -} - -void MIFFCompileInit(char *inputStream, char *inputFileName) -{ - MIFFInputStream = inputStream; - yyrestart(0); - initParser(); - initialCompile = 1; - strcpy(inFileName, inputFileName); - yyparse(); -} - -/*---------------------------------------** -** matching of open/close brace checking ** -**---------------------------------------*/ -void open_brace(void) -{ - brace_counter++; -} - -void close_brace(void) -{ - brace_counter--; -} - -/* - * what: count_brace(): - * return: 0 == all braces matched - */ -int count_brace(void) -{ - if (0 == brace_counter) /* things are fine... */ - return(0); - - /* if this is called, we should have 0 brace counter if not, we have a mis-match*/ - if (brace_counter > 0) - { - /* a mismatch */ - yyerror("There are more OPEN brackets then closed"); - } - else if (brace_counter < 0) - { - yyerror("There are more CLOSED brackets then open"); - } - - return(-1); -} - -/*-----------------------------------------------------------------------** -** FLEX.SLK requires this prototype function so I'm forced to do this... ** -**-----------------------------------------------------------------------*/ -int yywrap() -{ - return(1); -} - -void printString(char *str) -{ - char ts[256]; - sprintf(ts, "%s - %s", str, yytext); - MIFFMessage(ts, 0); -} diff --git a/engine/client/application/Miff/src/win32/parser.yac b/engine/client/application/Miff/src/win32/parser.yac deleted file mode 100644 index 1bfec252..00000000 --- a/engine/client/application/Miff/src/win32/parser.yac +++ /dev/null @@ -1,1004 +0,0 @@ -%expect 1 -%{ -/*-----------------------------------------------------------------------------** -** FILE: parser.yac ** -** (c) 1998 - Bootprint GTInteractive ** -** ** -** DESCRIPTION: parser for mIFF ** -** ** -** AUTHOR: Hideki Ikeda ** -** HISTORY: ** -** ** -** Notes: companion to parser.lex ** -**-----------------------------------------------------------------------------*/ - -/*---------------** -** C declaration ** -**---------------*/ -#pragma warning (disable: 4005) /* macro redefinition - bision.simple redefines alloca() */ -#pragma warning (disable: 4127) /* conditional expression is constant - in bison.simple */ -#pragma warning (disable: 4131) /* uses old-style declarator - mostly in bison.simple */ -#pragma warning (disable: 4244) /* possible loss of data due to conversion from one type to another - bision.simple */ -#pragma warning (disable: 4701) /* local variable ('yyval' in first case) may be used without having been initialed */ -// #pragma warning (disable: 6311) /* compiler malloc.h: see previous definition of alloca() */ - -/* include files */ -#include /* for pow() and stuff */ -#include -#include /* for toupper() */ -#include /* for wide character (16bit) strings */ - -#include -#include - -/*----------------------------------------------------------------** -** debug options, turn these on to TEST ONLY! don't leave these ** -** switch on, it's annoying as hell in console mode! ** -** NOTE: if you turn YYERROR_VERBOSE on, you MUST have YYDEBUG! ** -** IMHO, it's better off using primitive printf() method to debug ** -**----------------------------------------------------------------*/ -#define YYERROR_VERBOSE 1 -#define YYDEBUG 1 - -#undef YYERROR_VERBOSE -#undef YYDEBUG - -/* external prototype declaration */ -extern void MIFFMessage(char *message); /* found in mIFF.CPP */ -extern char * MIFFallocString(int sizeOfString); -extern void MIFFfreeString(char * pointer); -extern int validateTargetFilename(char *fname, int fnameSize); /* found mIFF.CPP */ -extern void yyerror(char *); -extern int yylex(void); -extern void setCurrentLineNumber(int lineNum, char * fileName, int mysteryNum); -extern void MIFFSetIFFName(const char *newFileName); -extern void MIFFinsertForm(const char *formName); -extern void MIFFinsertChunk(const char *chunkName); -extern void MIFFinsertChunkData(void * buffer, unsigned bufferSize); -extern int MIFFloadRawData(char *fname, void * buffer, unsigned maxBufferSize); -extern void MIFFexitChunk(void); -extern void MIFFexitForm(void); -extern unsigned long MIFFgetLabelHash(char *inputStream); - -/* local prototype declaration */ -void initGlobalVars(void); -void checkArgs(void); -void checkPragmas(void); - -void includeBinary(char *fname); - -void write32(long i32); -void write16(short i16); -void write8(char i8); -void writeU32(unsigned long ui32); -void writeU16(unsigned short ui16); -void writeU8(unsigned char u8); -void writeDouble(double d); -void writeFloat(float f); -void writeString(char *s); -void writeString16(char *s); -void writeLabelHash(char *s); -void writeTag(char *tag); -void writeSize(unsigned long size); -void writeData(void *dataPtr, unsigned dataSize); - -void initSymTable(void); -long searchEnumSymbolTable(char *symString); -long getEnumValue(long index); -void addEnumSymbol(char *symString, long value); -void parseESCstring(char *str, char *targetBuffer, int sizeOfTarget); - -/*----------------------------------------------** -** Global vars used by all functions and parser ** -**----------------------------------------------*/ -char err_msg[256]; -int errorFlag; - -/*-----------------------------------------------------------------------------** -** NOTE: this symbol table is ONLY used to construct symbols for enum table!!! ** -**-----------------------------------------------------------------------------*/ -#define MAX_SYMBOLS (1024) /* total number of symbols it can grow to... */ -#define MAX_SYMCHARS (128) /* I label thee insane if you have more the 128 char for your variable! */ -struct structEnumSymTableType -{ - char symbol[MAX_SYMCHARS]; - long value; -}; - -struct structEnumSymTableType symbolEnumTable[MAX_SYMBOLS]; -unsigned currSymIndex = 0; -long lastValue = -1; -char id[MAX_SYMCHARS]; - -/* vars set by pragmas */ -#define MAX_BUFFER_SIZE (16 * 1024 * 1024) -#define MAX_STRING_SIZE (512) -char drive[8]; -char directory[MAX_STRING_SIZE/2]; -char filename[MAX_STRING_SIZE/2]; -char extension[8]; -char outFileName[MAX_STRING_SIZE]; -int usePragmas; - -/*------------------------------------------------------------------------** -** The IRONY of these so-called temp-data's that are GLOBAL is ** -** that they aren't temp if functions called within are also using it ** -** This really gives me the creeps and goosbumps! DOWN with GLOBAL VARS! ** -**------------------------------------------------------------------------*/ -int iTemp, jTemp; -char byteTemp; -short wordTemp; -char tempStr[MAX_STRING_SIZE]; - -%} - -/*--------------------** -** Bison declarations ** -**--------------------*/ -%union { - long ltype; - double dtype; - char *stype; - char chtype; - - int tokentype; -} - -/*------------------------------------------------** -** define tokens defined in lex file ** -** NOTE: all LITERALs are treated as signed long ** -** all FLOAT_LITERALs are treated as double ** -**------------------------------------------------*/ -%token CHAR_LIT -%token STR_LIT -%token IDENTIFIER -%token LIT -%token FLOAT_LIT - -/* all command tokens are type */ -%token INT32 -%token INT16 -%token INT8 -%token UINT32 -%token UINT16 -%token UINT8 -%token FLOAT -%token DOUBLE -%token STRING -%token WSTRING -%token LABELHASH - -%token FORM -%token CHUNK -%token PRAGMA -%token PRAGMA_DRIVE PRAGMA_DIR PRAGMA_FNAME PRAGMA_EXT -%token ENUMSTRUCT -%token INCLUDESOURCE -%token INCLUDEBIN -%token INCLUDEIFF -%token SIN -%token COS -%token TAN -%token ACOS -%token ASIN -%token ATAN -%token POUND -%token SHIFTRIGHT -%token SHIFTLEFT -%token RAISEDPOWER - -%% - -/*------------------------------------------------------------------------** -** Begin Grammar rules ** -** ** -** Note: if possible, always try to use left recurrsion rather then right ** -** to save stack depth... ** -**------------------------------------------------------------------------*/ -mIFFSource: - { - /* initialize some global varibles before we start */ - initGlobalVars(); - checkArgs(); - } - preprocessor - { - /* take care of any mIFF related preprocessors that we might encounter */ - checkPragmas(); - } - body - ; - -/*----------------------** -** Preprocessor handler ** -**----------------------*/ -preprocessor: { /* we don't really have to have preprocessor */} - | preprocessor pragma - | preprocessor debugInfo /* we have to have debugInfo or else pragma gets confused when it finds a # line */ - ; - -pragma: PRAGMA PRAGMA_DRIVE STR_LIT { - if (usePragmas) - { - strcpy(drive, $3); - if (strlen(drive) > 2) - { - sprintf(err_msg, "Drive [%s] is not a valid drive [must be in C: format]", drive); - yyerror(err_msg); - } - drive[1] = ':'; - drive[2] = 0; - } - MIFFfreeString($3); - } - | PRAGMA PRAGMA_DIR STR_LIT { - if (usePragmas) - { - strcpy(directory, $3); - if (directory[strlen(directory)] != '\\') - directory[strlen(directory)] = '\\'; - directory[strlen(directory) + 1] = 0; - } - MIFFfreeString($3); - } - | PRAGMA PRAGMA_FNAME STR_LIT { - if (usePragmas) - strcpy(filename, $3); - MIFFfreeString($3); - } - | PRAGMA PRAGMA_EXT STR_LIT { - if (usePragmas) - strcpy(extension, $3); - MIFFfreeString($3); - } - | PRAGMA IDENTIFIER STR_LIT { - sprintf(err_msg, "Unknown PRAGMA identifier [%s]", $2); - yyerror(err_msg); - MIFFfreeString($2); - MIFFfreeString($3); - } - ; - -/*-------------------------------------------------------** -** This is the #line pragmas in a format of: ** -** # lineNum "FileName" mysteryNumber ** -** We call setCurrentLineNumber so when an error occurs, ** -** it will be sync'd to correct filename and linenumber ** -**-------------------------------------------------------*/ -debugInfo: POUND LIT STR_LIT { setCurrentLineNumber($2, $3, 0); MIFFfreeString($3);} - | POUND LIT STR_LIT LIT { setCurrentLineNumber($2, $3, $4); MIFFfreeString($3);} - ; - -/*-----------------------** -** The main body section ** -**-----------------------*/ -body: /* body can be empty */ - | body form formbody - | body chunk chunkbody - | body enumSection - | body includesource { /* do nothing... should not exist if went thru the preprocessor */ } - | body includeIFF - | body debugInfo - ; - -/*------------------------** -** Enumeration definition ** -**------------------------*/ -enumSection: ENUMSTRUCT enumDeclare '{' enumBody '}' enumType ';' { /* enumSection */ } - ; - -enumDeclare: { /* could have no declaration */ lastValue = -1; } - | IDENTIFIER { /* enumDeclare: ID */ lastValue = -1; MIFFfreeString($1);} - ; - -enumBody: { /* enumBody: can be empty list */ } - | enumAssign { /* enumAssign */ } - | enumBody ',' enumAssign { /* enumAssign, enumBody */ } - ; - -enumAssign: IDENTIFIER '=' exprL { - addEnumSymbol($1, $3); - MIFFfreeString($1); - } - | IDENTIFIER { /* in this case, inc 1 from last count */ - addEnumSymbol($1, ++lastValue); - MIFFfreeString($1); - } - ; - -enumType: /* type declaration can be empty */ - | enumList - ; - -enumList: IDENTIFIER { /* enumList: just ID */ MIFFfreeString($1);} - | enumList ',' IDENTIFIER { /* enumList: ID, enumList */ MIFFfreeString($3);} - ; - -/*----------------------------** -** different types of include ** -**----------------------------*/ -includesource: INCLUDESOURCE STR_LIT { /* do nothing... because CCCP/preprocessor takes care of this*/ MIFFfreeString($2);} - ; - -includebin: INCLUDEBIN STR_LIT { includeBinary($2); MIFFfreeString($2);} - ; - -includeIFF: INCLUDEIFF STR_LIT { includeBinary($2); MIFFfreeString($2);} - ; - -/*------------------** -** the FORM section ** -**------------------*/ -form: FORM STR_LIT { - /* first make sure we have 4 char for FORM name */ - if (strlen($2) > 4) - { - sprintf(err_msg, "FORM name %s greater then 4 char", $2); - yyerror(err_msg); - } - else if (!errorFlag) - { - /* pack the string with ' ' (spaces) if less then 4 chars */ - strcpy(tempStr, $2); - if (strlen(tempStr) < 4) - { - /* pack the string */ - for (iTemp = strlen(tempStr);iTemp < 4; iTemp++) - { - tempStr[iTemp] = ' '; /* pack it with space */ - } - } - - /* let's make sure we don't have a smart ass who wants to do form "FORM" */ - if ((toupper(tempStr[0]) == 'F') && - (toupper(tempStr[1]) == 'O') && - (toupper(tempStr[2]) == 'R') && - (toupper(tempStr[3]) == 'M')) - { - yyerror("FORM name CANNOT BE 'FORM'... nice try bozo!"); - } - - /* FORM */ - MIFFinsertForm(tempStr); - } - MIFFfreeString($2); - } - ; - -formbody: '{' formelements '}' { if (!errorFlag) MIFFexitForm(); }; - -formelements: body { /* recursion of multiple depth in form is allowed */ } - | INCLUDEBIN STR_LIT { - yyerror("Found attempt to include binary file inside FORM\nBinary file inclusion ONLY allowed inside a CHUNK!\nError"); - MIFFfreeString($2); - } - ; - -/*-------------------** -** the CHUNK section ** -**-------------------*/ -chunk: CHUNK STR_LIT { - /* first make sure we have 4 char for CHUNK name */ - if (strlen($2) > 4) - { - sprintf(err_msg, "CHUNK name %s greater then 4 char", $2); - yyerror(err_msg); - } - else if (!errorFlag) - { - /* pack the string with ' ' (spaces) if less then 4 chars */ - strcpy(tempStr, $2); - if (strlen(tempStr) < 4) - { - /* pack the string */ - for (iTemp = strlen(tempStr);iTemp < 4; iTemp++) - { - tempStr[iTemp] = ' '; /* pack it with space */ - } - } - - /* let's make sure we don't have a smart ass who wants to do chunk "FORM" */ - if ((toupper(tempStr[0]) == 'F') && - (toupper(tempStr[1]) == 'O') && - (toupper(tempStr[2]) == 'R') && - (toupper(tempStr[3]) == 'M')) - { - yyerror("CHUNK name CANNOT BE 'FORM'... nice try bozo!"); - } - - MIFFinsertChunk(tempStr); - } - MIFFfreeString($2); - } - ; - -chunkbody: '{' chunkelements '}' { if (!errorFlag) MIFFexitChunk(); }; - -chunkelements: /* can be empty */ - | chunkelements memalloc - | chunkelements includebin - | chunkelements debugInfo - | chunkelements includeIFF { yyerror("Found attempt to include IFF (binary) file inside CHUNK\nIFF inclusion ONLY allowed outside a CHUNK!\nError"); } - ; - -memalloc: INT32 l32AllocExpr { } - | INT16 l16AllocExpr { } - | INT8 l8AllocExpr { } - | UINT32 lU32AllocExpr { } - | UINT16 lU16AllocExpr { } - | UINT8 lU8AllocExpr { } - | FLOAT fAllocExpr { } - | DOUBLE dAllocExpr { } - | LABELHASH STR_LIT { - writeLabelHash($2); - } - | STRING STR_LIT { writeString($2); - /* now, add a NULL termination for this string */ - byteTemp = 0; write8(byteTemp); - MIFFfreeString($2); - } - | WSTRING STR_LIT { writeString16($2); - /* now, add a NULL termination for this string */ - wordTemp = 0; write16(wordTemp); - MIFFfreeString($2); - } - ; - -l32AllocExpr: exprL { write32($1); } - | l32AllocExpr ',' exprL { write32($3); } - ; - -l16AllocExpr: exprL { write16((short) $1); } - | l16AllocExpr ',' exprL { write16((short) $3); } - ; - -l8AllocExpr: exprL { write8((char) $1); } - | l8AllocExpr ',' exprL { write8((char) $3); } - ; - -lU32AllocExpr: exprL { writeU32($1); } - | lU32AllocExpr ',' exprL { writeU32($3); } - ; - -lU16AllocExpr: exprL { writeU16((unsigned short) $1); } - | lU16AllocExpr ',' exprL { writeU16((unsigned short) $3); } - ; - -lU8AllocExpr: exprL { writeU8((unsigned char) $1); } - | lU8AllocExpr ',' exprL { writeU8((unsigned char) $3); } - ; - -fAllocExpr: exprD { writeFloat((float) $1); } - | fAllocExpr ',' exprD { writeFloat((float) $3); } - ; - -dAllocExpr: exprD { writeDouble($1); } - | dAllocExpr ',' exprD { writeDouble($3); } - ; - - -/*-------------------------** -** expression for integers ** -**-------------------------*/ -exprL: exprL '+' factorL { $$ = $1 + $3; } - | exprL '-' factorL { $$ = $1 - $3; } - | exprL SHIFTLEFT factorL { $$ = $1 << $3; } - | exprL SHIFTRIGHT factorL { $$ = $1 >> $3; } - | exprL '&' factorL { $$ = $1 & $3; } - | exprL '|' factorL { $$ = $1 | $3; } - | exprL '^' factorL { $$ = $1 ^ $3; } - | factorL { $$ = ($1); } - ; - -factorL: factorL '*' termL { $$ = $1 * $3; } - | factorL '/' termL { $$ = $1 / $3; } - | factorL '%' termL { $$ = $1 % $3; } - | termL { $$ = ($1); } - ; - -termL: LIT { $$ = $1; } - | '~' termL { $$ = ~$2; } /* bitwise NOT */ - | '-' termL { $$ = -$2; } /* Unary minus */ - | '+' termL { $$ = $2; } /* Unary plus */ - | '(' exprL ')' { $$ = ($2); } - | IDENTIFIER { /* assume it's enum symbol */ - $$ = (signed long) getEnumValue(searchEnumSymbolTable($1)); - MIFFfreeString($1); - } - ; - -/*-----------------------** -** expression for floats ** -**-----------------------*/ -exprD: exprD '+' factorD { $$ = $1 + $3; } - | exprD '-' factorD { $$ = $1 - $3; } - | exprD RAISEDPOWER factorD { $$ = pow($1, $3);} /* exponentiation */ - | factorD { $$ = ($1); } - ; - -factorD: factorD '*' termD { $$ = $1 * $3; } - | factorD '/' termD { $$ = $1 / $3; } - | termD { $$ = ($1); } - ; - -termD: FLOAT_LIT { $$ = $1; } - | LIT { $$ = (double) $1; } /* we should be able to handle values that are integer and treat it as float */ - | '-' termD { $$ = -$2; } /* Unary minus */ - | '+' termD { $$ = $2; } /* Unary plus */ - | '(' exprD ')' { $$ = ($2); } - | SIN '(' exprD ')' { $$ = sin( $3 ); } - | COS '(' exprD ')' { $$ = cos( $3 ); } - | TAN '(' exprD ')' { $$ = tan( $3 ); } - | ACOS '(' exprD ')' { $$ = acos( $3 ); } - | ASIN '(' exprD ')' { $$ = asin( $3 ); } - | ATAN '(' exprD ')' { $$ = atan( $3 ); } - | IDENTIFIER { /* assume it's enum symbol */ - $$ = (signed long) getEnumValue(searchEnumSymbolTable($1)); - MIFFfreeString($1); - } - ; - -%% - -/*-------------------------------------------** -** and now... the supporting C functions... ** -**-------------------------------------------*/ -void initGlobalVars(void) -{ - /* assign defaults */ - drive[0] = 0; - directory[0] = 0; - filename[0] = 0; - extension[0] = 0; - err_msg[0] = 0; - usePragmas = 1; /* default to #pragmas enabled because as a stand-alone .YAC, we have no knowledge of outFileName */ - - errorFlag = 0; - - initSymTable(); -} - -void checkPragmas(void) -{ - int indexOriginal, indexDest; - char _tempStr[512]; - - if (usePragmas) - { - /* check after pre processor if output target is still NULL */ - if (!drive[0] && !errorFlag) - { - yyerror("Drive pragma not defined"); - errorFlag = 1; - } - if (!directory[0] && !errorFlag) - { - yyerror("Directory pragma not defined"); - errorFlag = 1; - } - if (!filename[0] && !errorFlag) - { - yyerror("Filename pragma not defined"); - errorFlag = 1; - } - if (!extension[0] && !errorFlag) - { - yyerror("Extension pragma not defined"); - errorFlag = 1; - } - - if (!errorFlag) - { - /* create an output file */ - strcpy(_tempStr, directory); /* copy directory to _tempStr because we'll be messing with directory */ - for (indexOriginal = 0, indexDest = 0; indexOriginal < (int) strlen(_tempStr); indexOriginal++) - { - /* search for double-slashes and convert it to single slash */ - if ((_tempStr[indexOriginal] == '\\') && (_tempStr[indexOriginal+1] == '\\')) - { - directory[indexDest] = '\\'; - indexOriginal++; - } - else - directory[indexDest] = _tempStr[indexOriginal]; /* copy current position of _tempStr to directory */ - indexDest++; - directory[indexDest] = 0; /* force NULL termination */ - } - sprintf(outFileName, "%s%s%s%s", drive, directory, filename, extension); - } - } /* if usePragmas */ - - MIFFSetIFFName(outFileName); /* tell mIFF we want to use this filename instead of whatever it has! */ -} - -/*--------------------------------------------------------------------------------------** -** This function is called early in the process to find out if usePragma flag was set ** -** in the command line or not. If it was, mIFF already has the outfile and will stuff ** -** it into the outFileName data pool. Even if mIFF had an idea of what the output file ** -** name is, if usePragma flag returned said it is true, then #pragas in the mIFF source ** -** is used instead and overrides whatever file name it has returned. ** -** see usePragmas() for more details. ** -**--------------------------------------------------------------------------------------*/ -void checkArgs(void) -{ - /* request an external function (found in either mIFF.CPP or mIFFView.CPP) to see if pragmas and filename was set... */ - usePragmas = validateTargetFilename(outFileName, sizeof(outFileName)); -} - -/*----------------------------** -** Write to FILE functions... ** -**----------------------------*/ -void write32(long i32) -{ - MIFFinsertChunkData(&i32, sizeof(long)); -} - -void write16(short i16) -{ - MIFFinsertChunkData(&i16, sizeof(short)); -} - -void write8(char i8) -{ - MIFFinsertChunkData(&i8, sizeof(char)); -} - -void writeU32(unsigned long ui32) -{ - MIFFinsertChunkData(&ui32, sizeof(long)); -} - -void writeU16(unsigned short ui16) -{ - MIFFinsertChunkData(&ui16, sizeof(short)); -} - -void writeU8(unsigned char ui8) -{ - MIFFinsertChunkData(&ui8, sizeof(char)); -} - -void writeDouble(double d) -{ - MIFFinsertChunkData(&d, sizeof(double)); -} - -void writeFloat(float f) -{ - MIFFinsertChunkData(&f, sizeof(float)); -} - -void writeString(char *s) -{ - char tempS[MAX_STRING_SIZE]; - parseESCstring(s, tempS, MAX_STRING_SIZE); - - MIFFinsertChunkData(tempS, strlen(tempS)); -} - -void writeString16(char *s) -{ - char tempS[MAX_STRING_SIZE]; - int charCount = 0; - wchar_t wtempStr[512]; /* just to be on the safe side, allocating huge array... */ - - parseESCstring(s, tempS, MAX_STRING_SIZE); - - /* make sure string length is less then the allocated wchar size */ - if ((strlen(tempS) * sizeof(wchar_t)) > (512* sizeof(wchar_t))) - yyerror("wstring: 16bit string too long to handle in buffer!\n"); - else - { - /* call MultiByteString to WideCharString function */ - charCount = mbstowcs(wtempStr, tempS, strlen(tempS)); - writeData(wtempStr, charCount * sizeof(wchar_t)); - } -} - -void writeLabelHash(char *s) -{ - writeU32(MIFFgetLabelHash(s)); -} - -/* search from escape string such as \n and convert it to actual byte */ -void parseESCstring(char *str, char *targetBuffer, int sizeOfTarget) -{ - char *sPtr = str; - int strIndex = 0; - char numString[32]; /* hopefully, never go over 3 char i.e. \x0FF */ - int numIndex = 0; - int tempNum = 0; - int exitParser = 0; - int loopFlag = 0; - - /* memory hog but cute way to convert ascii hex to number */ - int hexTable[256]; - memset(hexTable, 0xFF, 256); - hexTable['0'] = 0x00; - hexTable['1'] = 0x01; - hexTable['2'] = 0x02; - hexTable['3'] = 0x03; - hexTable['4'] = 0x04; - hexTable['5'] = 0x05; - hexTable['6'] = 0x06; - hexTable['7'] = 0x07; - hexTable['8'] = 0x08; - hexTable['9'] = 0x09; - hexTable['A'] = 0x0A; hexTable['a'] = 0x0A; - hexTable['B'] = 0x0B; hexTable['b'] = 0x0B; - hexTable['C'] = 0x0C; hexTable['c'] = 0x0C; - hexTable['D'] = 0x0D; hexTable['d'] = 0x0D; - hexTable['E'] = 0x0E; hexTable['e'] = 0x0E; - hexTable['F'] = 0x0F; hexTable['f'] = 0x0F; - - memset(targetBuffer, 0, sizeOfTarget); - while ((*sPtr) && !exitParser) /* assume we can go until NULL termination */ - { - /* check for escape sequences */ - if (*sPtr == '\\') - { - sPtr++; /* check out next character */ - switch (tolower(*sPtr)) - { - case 'a': /* BELL */ - { - targetBuffer[strIndex++] = '\a'; - break; - } - - case 'b': /* BACKSPACE */ - { - targetBuffer[strIndex++] = '\b'; - break; - } - - case 'f': /* FORMFEED */ - { - targetBuffer[strIndex++] = '\a'; - break; - } - - case 'n': /* NEWLINE */ - { - targetBuffer[strIndex++] = '\n'; - break; - } - - case 'r': /* CARRIAGE RETURN */ - { - targetBuffer[strIndex++] = '\r'; - break; - } - - case 't': /* TAB */ - { - targetBuffer[strIndex++] = '\t'; - break; - } - - case 'v': /* VERTICAL TAB */ - { - targetBuffer[strIndex++] = '\v'; - break; - } - - case '\'': /* SINGLE QUOTE */ - { - targetBuffer[strIndex++] = '\''; - break; - } - - case '\"': /* DOUBLE QUOTE */ - { - targetBuffer[strIndex++] = '\"'; - break; - } - - case '\\': /* BACKSLASH */ - { - targetBuffer[strIndex++] = '\\'; - break; - } - - case '?': /* LITERAL QUESTION MARK */ - { - targetBuffer[strIndex++] = '\?'; - break; - } - - case '0': /* ASCII octal */ - case '1': /* ASCII octal */ - case '2': /* ASCII octal */ - case '3': /* ASCII octal */ - case '4': /* ASCII octal */ - case '5': /* ASCII octal */ - case '6': /* ASCII octal */ - case '7': /* ASCII octal */ - { - /* read until non-digit encountered - if octal value is greater then \377 (400 or more) it is bigger the 255! */ - numIndex = 0; - - while ((*sPtr >= '0') && (*sPtr <= '7') && (*sPtr)) - { - numString[numIndex++] = *sPtr; - sPtr++; - if (numIndex > 3) - { - sprintf(err_msg, "Escape sequence Octal numbers greater then\noctal o400 (256 decimal)! [more then 3 digits]", *sPtr); - yyerror(err_msg); - exitParser = 1; - } - } - - /* now we should have string of octal number in numString */ - if (!exitParser) - { - if (numIndex == 3) - tempNum = (hexTable[numString[0]] * 64) + (hexTable[numString[1]] * 8) + hexTable[numString[2]]; - else if (numIndex == 2) - tempNum = (hexTable[numString[0]] * 8) + hexTable[numString[1]]; - else - tempNum = hexTable[numString[0]]; - - if (tempNum > 255) - { - sprintf(err_msg, "Escape sequence Octal numbers greater then\noctal o400 (256 decimal)!", tempNum); - yyerror(err_msg); - exitParser = 1; - } - - if (!exitParser) - targetBuffer[strIndex++] = tempNum; - } - break; - } - - case 'x': /* ASCII hex */ - { - /* we have to make sure the hex value is less then 256! */ - numIndex = 0; - loopFlag = 1; - sPtr++; /* skip the 'x' */ - - while ((0xFF != hexTable[*sPtr]) && (*sPtr)) - { - numString[numIndex++] = *sPtr; - sPtr++; - if (numIndex > 3) - { - sprintf(err_msg, "Escape sequence HEX numbers greater then 0x100\n(256 decimal)! [more then 3 digits]", *sPtr); - yyerror(err_msg); - exitParser = 1; - } - } - - if (!exitParser) - { - if (numIndex == 3) - tempNum = (hexTable[numString[0]] * 0x100) + (hexTable[numString[1]] * 0x10) + hexTable[numString[2]]; - else if (numIndex == 2) - tempNum = (hexTable[numString[0]] * 0x10) + hexTable[numString[1]]; - else - tempNum = hexTable[numString[0]]; - } - - if (tempNum > 255) - { - sprintf(err_msg, "Escape sequence HEX numbers greater then 0x100\n(256 decimal)!", *sPtr); - yyerror(err_msg); - exitParser = 1; - } - - if (!exitParser) - targetBuffer[strIndex++] = tempNum; - - break; - } - - case '8': - case '9': - { - /* they tried to do octal mode, but 8 and 9 is not in the definition of octal */ - yyerror("Attempted to enter escape sequence with non-octal value"); - exitParser = 1; - break; - } - - default: - sprintf(err_msg, "Unknown ESCape sequence \\%c found in string.\n", *sPtr); - yyerror(err_msg); - exitParser = 1; - break; - } - } - else - targetBuffer[strIndex++] = *sPtr; - sPtr++; - } -} - - -void writeData(void *dataPtr, unsigned dataSize) -{ - MIFFinsertChunkData(dataPtr, dataSize); -} - - -/* NOTE: includeBinary modifies fsize for the caller to access for adjusting the chunk size */ -void includeBinary(char *fname) -{ - char buffer[MAX_BUFFER_SIZE+1]; - int fsize = 0; - - fsize = MIFFloadRawData(fname, buffer, MAX_BUFFER_SIZE); - MIFFinsertChunkData(buffer, fsize); -} - -/*--------------------------------------------------------------------------------** -** Following functions below are all used for constructing, adding, and searching ** -** the symbol table created by enum keyword. It is at this moment, set in a way ** -** that if two identical symbols are added to the list, it will use the first ** -** symbol added to the list and ignores the rest (because of forward search) ** -**--------------------------------------------------------------------------------*/ -void initSymTable(void) -{ - memset(symbolEnumTable, 0, sizeof(struct structEnumSymTableType) * MAX_SYMBOLS); - currSymIndex = 0; - lastValue = -1; -} - -/* Searches thru the symbol table and returns the index */ -long searchEnumSymbolTable(char *symString) -{ - long index = 0; - int found = 0; - while ((0 != symbolEnumTable[index].symbol[0]) && !found) - { - - if (0 == strcmp(symbolEnumTable[index].symbol, symString)) - { - found = 1; - break; - } - else - index++; - } - - if (!found) - { - index = -1; - sprintf(err_msg, "Undefined symbol %s", symString); - yyerror(err_msg); - } - - return(index); -} - -long getEnumValue(long index) -{ - if (index >= 0) - return(symbolEnumTable[index].value); - return(-1); -} - -void addEnumSymbol(char *symString, long value) -{ - if (MAX_SYMCHARS < strlen(symString)) - { - /* somebody insane decided to use variable longer then max size! */ - sprintf(err_msg, "%s is longer then %d characters! [value: %d]", symString, MAX_SYMCHARS, value); - yyerror(err_msg); - } - else - { - strcpy(symbolEnumTable[currSymIndex].symbol, symString); - symbolEnumTable[currSymIndex].value = value; - lastValue = value; - currSymIndex++; - if (MAX_SYMBOLS < currSymIndex) - { - sprintf(err_msg, "Symbol table reached maximum size of %d", MAX_SYMBOLS); - yyerror(err_msg); - } - } -} diff --git a/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Archive.h b/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Archive.h deleted file mode 100755 index 30ddce43..00000000 --- a/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Archive.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef BASE_WIN32_ARCHIVE_H -#define BASE_WIN32_ARCHIVE_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - -#ifdef PACK_BIG_ENDIAN - - inline double byteSwap(double value) { byteReverse64(&value); return value; } - inline float byteSwap(float value) { byteReverse32(&value); return value; } - inline uint64 byteSwap(uint64 value) { byteReverse64(&value); return value; } - inline int64 byteSwap(int64 value) { byteReverse64(&value); return value; } - inline uint32 byteSwap(uint32 value) { byteReverse32(&value); return value; } - inline int32 byteSwap(int32 value) { byteReverse32(&value); return value; } - inline uint16 byteSwap(uint16 value) { byteReverse16(&value); return value; } - inline int16 byteSwap(int16 value) { byteReverse16(&value); return value; } - -#else - - inline double byteSwap(double value) { return value; } - inline float byteSwap(float value) { return value; } - inline uint64 byteSwap(uint64 value) { return value; } - inline int64 byteSwap(int64 value) { return value; } - inline uint32 byteSwap(uint32 value) { return value; } - inline int32 byteSwap(int32 value) { return value; } - inline uint16 byteSwap(uint16 value) { return value; } - inline int16 byteSwap(int16 value) { return value; } - -#endif - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif diff --git a/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Platform.cpp b/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Platform.cpp deleted file mode 100755 index 3b52563e..00000000 --- a/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Platform.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//////////////////////////////////////// -// Platform.cpp -// -// Purpose: -// 1. Implementation of the global functionality declaired in Platform.h. -// -// Revisions: -// 07/10/2001 Created -// - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - - CTimer::CTimer() : - mTimer(0) - { - } - - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif diff --git a/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Platform.h b/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Platform.h deleted file mode 100755 index aaee37b7..00000000 --- a/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Platform.h +++ /dev/null @@ -1,98 +0,0 @@ -//////////////////////////////////////// -// Platform.h -// -// Purpose: -// 1. Include relevent system headers that are platform specific. -// 2. Declair global platform specific functionality. -// 3. Include primative type definitions -// -// Global Functions: -// getTimer() : Return the current high resolution clock count. -// getTimerFrequency() : Return the frequency of the high resolution clock. -// sleep() : Voluntarily relinquish timeslice of the calling thread for a -// specified number of milliseconds. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_PLATFORM_H -#define BASE_WIN32_PLATFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include "Types.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - uint64 getTimer(void); - uint64 getTimerFrequency(void); - - inline uint64 getTimer(void) - { - uint64 result; - if (!QueryPerformanceCounter(reinterpret_cast(&result))) - result = 0; - return result; - } - - inline uint64 getTimerFrequency(void) - { - uint64 result; - if (!QueryPerformanceFrequency(reinterpret_cast(&result))) - result = 0; - return result; - } - - inline void sleep(uint32 ms) - { - Sleep(ms); - } - - - class CTimer - { - public: - CTimer(); - - void Set(uint32 seconds); - void Signal(); - bool Expired(); - - private: - uint32 mTimer; - }; - - inline void CTimer::Set(uint32 interval) - { - mTimer = (uint32)time(0) + interval; - } - - inline void CTimer::Signal() - { - mTimer = 0; - } - - inline bool CTimer::Expired() - { - return (mTimer <= (uint32)time(0)); - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif BASE_WIN32_PLATFORM_H \ No newline at end of file diff --git a/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Types.h b/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Types.h deleted file mode 100755 index 0c64cb2c..00000000 --- a/engine/server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/win32/Types.h +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////// -// Types.h -// -// Purpose: -// 1. Define integer types that are unambiguous with respect to size -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_TYPES_H -#define BASE_WIN32_TYPES_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - -#define INT32_MAX 0x7FFFFFFF -#define INT32_MIN 0x80000000 -#define UINT32_MAX 0xFFFFFFFF - -typedef signed char int8; -typedef unsigned char uint8; -typedef short int16; -typedef unsigned short uint16; - -typedef int int32; -typedef unsigned uint32; -typedef __int64 int64; -typedef unsigned __int64 uint64; - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // BASE_WIN32_TYPES_H - diff --git a/engine/server/application/CentralServer/src/win32/FirstCentralServer.cpp b/engine/server/application/CentralServer/src/win32/FirstCentralServer.cpp deleted file mode 100755 index 509e7da9..00000000 --- a/engine/server/application/CentralServer/src/win32/FirstCentralServer.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// CentralServerPrecompiledHeader.cpp -// copyright 2001 Verant Interactive -// Author: Justin Randall - -#include "FirstCentralServer.h" diff --git a/engine/server/application/CentralServer/src/win32/WinMain.cpp b/engine/server/application/CentralServer/src/win32/WinMain.cpp deleted file mode 100755 index 110a36e5..00000000 --- a/engine/server/application/CentralServer/src/win32/WinMain.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "FirstCentralServer.h" -#include "ConfigCentralServer.h" -#include "CentralServer.h" - -#include "sharedCompression/SetupSharedCompression.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "sharedRandom/SetupSharedRandom.h" -#include "sharedThread/SetupSharedThread.h" - -#include -#include - -//_____________________________________________________________________ -/* -int WINAPI WinMain( - HINSTANCE hInstance, // handle to current instance - HINSTANCE hPrevInstance, // handle to previous instance - LPSTR lpCmdLine, // pointer to command line - int nCmdShow // show state of window - ) - */ -int main(int argc, char ** argv) -{ //lint !e1065 //WinMain conflicts with clib - int i = 0; - -// UNREF(hPrevInstance); -// UNREF(nCmdShow); - - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - //-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - - // command line hack - std::string cmdLine; - for(i = 1; i < argc; ++i) - { - cmdLine += argv[i]; - if(i + 1 < argc) - { - cmdLine += " "; - } - } -// setupFoundationData.hInstance = hInstance; - setupFoundationData.commandLine = cmdLine.c_str(); - setupFoundationData.createWindow = false; - setupFoundationData.clockUsesSleep = true; - - SetupSharedFoundation::install (setupFoundationData); - - SetupSharedCompression::install(); - - SetupSharedFile::install(false); - - SetupSharedNetworkMessages::install(); - - ConfigCentralServer::install(); - - cmdLine.clear(); - // now, the real command line - for(i = 0; i < argc; ++i) - { - cmdLine += argv[i]; - if(i + 1 < argc) - { - cmdLine += " "; - } - } - - CentralServer::getInstance().setCommandLine(cmdLine); - - //-- run game - SetupSharedFoundation::callbackWithExceptionHandling(CentralServer::run); - - SetupSharedFoundation::remove(); - - return 0; -} - -//_____________________________________________________________________ diff --git a/engine/server/application/ChatServer/src/win32/WinMain.cpp b/engine/server/application/ChatServer/src/win32/WinMain.cpp deleted file mode 100755 index 8d0ac8fc..00000000 --- a/engine/server/application/ChatServer/src/win32/WinMain.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "FirstChatServer.h" -#include "ConfigChatServer.h" -#include "ChatServer.h" -#include "sharedCompression/SetupSharedCompression.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "sharedThread/SetupSharedThread.h" - -#include -#include - -int main( int argc, char ** argv ) -{ - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - //-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - - //setupFoundationData.hInstance = hInstance; - setupFoundationData.argc = argc; - setupFoundationData.argv = argv; - setupFoundationData.createWindow = false; - setupFoundationData.clockUsesSleep = true; - - SetupSharedFoundation::install (setupFoundationData); - - SetupSharedCompression::install(); - - SetupSharedNetworkMessages::install(); - - //-- setup game server - ConfigChatServer::install (); - - //-- run game - SetupSharedFoundation::callbackWithExceptionHandling(ChatServer::run); - - SetupSharedFoundation::remove(); - - return 0; -} diff --git a/engine/server/application/CommoditiesServer/src/win32/WinMain.cpp b/engine/server/application/CommoditiesServer/src/win32/WinMain.cpp deleted file mode 100755 index 5051cfa4..00000000 --- a/engine/server/application/CommoditiesServer/src/win32/WinMain.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "FirstCommodityServer.h" - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedCompression/SetupSharedCompression.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/TreeFile.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFoundation/ConfigFile.h" -#include "sharedFoundation/ExitChain.h" -#include "sharedFoundation/Os.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedGame/CommoditiesAdvancedSearchAttribute.h" -#include "sharedGame/ConfigSharedGame.h" -#include "sharedNetwork/SetupSharedNetwork.h" -#include "sharedNetwork/NetworkHandler.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "sharedThread/SetupSharedThread.h" -#include "sharedUtility/DataTableManager.h" -#include "CommodityServer.h" -#include "ConfigCommodityServer.h" -#include "LocalizationManager.h" -#include "UnicodeUtils.h" - -int main(int argc, char ** argv) -{ - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - //-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - - setupFoundationData.argc = argc; - setupFoundationData.argv = argv; - setupFoundationData.createWindow = false; - setupFoundationData.clockUsesSleep = true; - SetupSharedFoundation::install (setupFoundationData); - - ConfigSharedGame::install(); - SetupSharedCompression::install(); - SetupSharedFile::install(false); - SetupSharedNetworkMessages::install(); - - SetupSharedNetwork::SetupData networkSetupData; - SetupSharedNetwork::getDefaultServerSetupData(networkSetupData); - SetupSharedNetwork::install(networkSetupData); - NetworkHandler::install(); - - ConfigCommodityServer::install(); - - const bool displayBadStringIds = ConfigSharedGame::getDisplayBadStringIds (); - const bool debugStringIds = ConfigSharedGame::getDebugStringIds (); - Unicode::NarrowString defaultLocale(ConfigSharedGame::getDefaultLocale ()); - Unicode::UnicodeNarrowStringVector localeVector; - localeVector.push_back(defaultLocale); - - LocalizationManager::install (new TreeFile::TreeFileFactory, localeVector, debugStringIds, NULL, displayBadStringIds); - ExitChain::add(LocalizationManager::remove, "LocalizationManager::remove"); - - DataTableManager::install(); - CommoditiesAdvancedSearchAttribute::install(); - - //-- run server - SetupSharedFoundation::callbackWithExceptionHandling(CommodityServer::run); - - SetupSharedFoundation::remove(); - - return 0; -} - -//----------------------------------------------------------------------- diff --git a/engine/server/application/ConnectionServer/src/win32/FirstConnectionServer.cpp b/engine/server/application/ConnectionServer/src/win32/FirstConnectionServer.cpp deleted file mode 100755 index 137cad41..00000000 --- a/engine/server/application/ConnectionServer/src/win32/FirstConnectionServer.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "FirstConnectionServer.h" diff --git a/engine/server/application/ConnectionServer/src/win32/WinMain.cpp b/engine/server/application/ConnectionServer/src/win32/WinMain.cpp deleted file mode 100755 index 236a8ebf..00000000 --- a/engine/server/application/ConnectionServer/src/win32/WinMain.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "FirstConnectionServer.h" -#include "ConfigConnectionServer.h" -#include "ConnectionServer.h" - -#include "sharedCompression/SetupSharedCompression.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFoundation/PerThreadData.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "sharedRandom/SetupSharedRandom.h" -#include "sharedThread/SetupSharedThread.h" - -#include - -int main(int argc, char ** argv) -{ - // command line hack - std::string cmdLine; - for(int i = 1; i < argc; ++i) - { - cmdLine += argv[i]; - if(i + 1 < argc) - { - cmdLine += " "; - } - } - - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - -//-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - -// setupFoundationData.hInstance = hInstance; - setupFoundationData.commandLine = cmdLine.c_str(); - setupFoundationData.createWindow = false; - setupFoundationData.clockUsesSleep = true; - - SetupSharedFoundation::install (setupFoundationData); - SetupSharedFile::install(false); - SetupSharedCompression::install(); - - SetupSharedNetworkMessages::install(); - SetupSharedRandom::install(int(time(NULL))); - - //-- setup game server - ConfigConnectionServer::install (); - - ConnectionServer::install(); - //-- run game - SetupSharedFoundation::callbackWithExceptionHandling(ConnectionServer::run); - ConnectionServer::remove(); - ConfigConnectionServer::remove(); - SetupSharedFoundation::remove(); - PerThreadData::threadRemove(); - return 0; -} diff --git a/engine/server/application/LogServer/src/win32/LoggingServerApiWrapper.cpp b/engine/server/application/LogServer/src/win32/LoggingServerApiWrapper.cpp deleted file mode 100755 index 78b377f5..00000000 --- a/engine/server/application/LogServer/src/win32/LoggingServerApiWrapper.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// LoggingServerApiWrapper.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -// This is a wrapper cpp to workaround PCH and RSP's. While a DSP -// may exclude a single file from using precompiled headers, the -// dsp builder has no way (I know of) to honor this behavior. -//----------------------------------------------------------------------- - -#include "FirstLogServer.h" -//#include "LoggingServerApi.cpp" - -//----------------------------------------------------------------------- - -//----------------------------------------------------------------------- - diff --git a/engine/server/application/LogServer/src/win32/WinMain.cpp b/engine/server/application/LogServer/src/win32/WinMain.cpp deleted file mode 100755 index 21d829c4..00000000 --- a/engine/server/application/LogServer/src/win32/WinMain.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// ====================================================================== -// -// WinMain.cpp -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#include "FirstLogServer.h" -#include "sharedFoundation/FirstSharedFoundation.h" -#include "LogServer.h" - -#include "sharedCompression/SetupSharedCompression.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "sharedThread/SetupSharedThread.h" - -// ====================================================================== - -int main(int argc, char **argv) -{ - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - //-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - - setupFoundationData.argc = argc; - setupFoundationData.argv = argv; - setupFoundationData.createWindow = false; - setupFoundationData.clockUsesSleep = true; - - SetupSharedFoundation::install(setupFoundationData); - - SetupSharedCompression::install(); - - SetupSharedFile::install(false); - SetupSharedNetworkMessages::install(); - - //-- setup server - LogServer::install(); - - //-- run server - SetupSharedFoundation::callbackWithExceptionHandling(LogServer::run); - - LogServer::remove(); - SetupSharedFoundation::remove(); - SetupSharedThread::remove(); - - return 0; -} - -// ====================================================================== diff --git a/engine/server/application/LoginServer/src/win32/FirstLoginServer.cpp b/engine/server/application/LoginServer/src/win32/FirstLoginServer.cpp deleted file mode 100755 index 199562bb..00000000 --- a/engine/server/application/LoginServer/src/win32/FirstLoginServer.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "FirstLoginServer.h" diff --git a/engine/server/application/LoginServer/src/win32/WinMain.cpp b/engine/server/application/LoginServer/src/win32/WinMain.cpp deleted file mode 100755 index f5c7056c..00000000 --- a/engine/server/application/LoginServer/src/win32/WinMain.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "FirstLoginServer.h" -#include "ConfigLoginServer.h" -#include "LoginServer.h" - -#include "sharedCompression/SetupSharedCompression.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "sharedRandom/SetupSharedRandom.h" -#include "sharedThread/SetupSharedThread.h" - -#include - -int main(int argc, char **argv) -{ - - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - //-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - - setupFoundationData.argc = argc; - setupFoundationData.argv = argv; - setupFoundationData.createWindow = false; - - SetupSharedFoundation::install (setupFoundationData); - SetupSharedNetworkMessages::install(); - - SetupSharedCompression::install(); - - SetupSharedFile::install(false); - - SetupSharedRandom::install(time(NULL)); - - //-- setup game server - ConfigLoginServer::install (); - - //-- run game - SetupSharedFoundation::callbackWithExceptionHandling(LoginServer::run); - - SetupSharedFoundation::remove(); - - return 0; -} diff --git a/engine/server/application/MetricsServer/src/win32/WinMain.cpp b/engine/server/application/MetricsServer/src/win32/WinMain.cpp deleted file mode 100755 index 5955efba..00000000 --- a/engine/server/application/MetricsServer/src/win32/WinMain.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "sharedFoundation/FirstSharedFoundation.h" - -#include "ConfigMetricsServer.h" -#include "MetricsServer.h" - -#include "sharedCompression/SetupSharedCompression.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFoundation/Os.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedNetwork/NetworkHandler.h" -#include "sharedNetwork/SetupSharedNetwork.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "sharedRandom/SetupSharedRandom.h" -#include "sharedThread/SetupSharedThread.h" - -#include - -// ====================================================================== - -int main(int argc, char ** argv) -{ - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - //-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - - // command line hack - std::string cmdLine; - for(int i = 1; i < argc; ++i) - { - cmdLine += argv[i]; - if(i + 1 < argc) - { - cmdLine += " "; - } - } - - setupFoundationData.commandLine = cmdLine.c_str(); - setupFoundationData.createWindow = false; - setupFoundationData.clockUsesSleep = true; - - SetupSharedFoundation::install (setupFoundationData); - - { - //SetupSharedObject::Data data; - //SetupSharedObject::setupDefaultGameData(data); - //SetupSharedObject::install(data); - } - SetupSharedCompression::install(); - SetupSharedFile::install(true, 32); - - SetupSharedNetwork::SetupData networkSetupData; - SetupSharedNetwork::getDefaultServerSetupData(networkSetupData); - SetupSharedNetwork::install(networkSetupData); - - SetupSharedRandom::install(static_cast(time(NULL))); //lint !e1924 !e64 // NULL is a C-Style cast? - - //Os::setProgramName("MetricsServer"); - //setup the server - ConfigMetricsServer::install(); - - //set command line - cmdLine = setupFoundationData.commandLine; - size_t firstArg = cmdLine.find(" ", 0); - size_t lastSlash = 0; - size_t nextSlash = 0; - while(nextSlash < firstArg) - { - nextSlash = cmdLine.find("/", lastSlash); - if(nextSlash == cmdLine.npos || nextSlash >= firstArg) //lint !e1705 static class members may be accessed by the scoping operator (huh?) - break; - lastSlash = nextSlash + 1; - } - cmdLine = cmdLine.substr(lastSlash); - MetricsServer::setCommandLine(cmdLine); - - - //-- run game - NetworkHandler::install(); - MetricsServer::install(); - MetricsServer::run(); - MetricsServer::remove(); - NetworkHandler::remove(); - SetupSharedFoundation::remove(); - - return 0; -} - - diff --git a/engine/server/application/PlanetServer/src/win32/FirstPlanetServer.cpp b/engine/server/application/PlanetServer/src/win32/FirstPlanetServer.cpp deleted file mode 100755 index 97e05471..00000000 --- a/engine/server/application/PlanetServer/src/win32/FirstPlanetServer.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstPlanetServer.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "FirstPlanetServer.h" diff --git a/engine/server/application/PlanetServer/src/win32/WinMain.cpp b/engine/server/application/PlanetServer/src/win32/WinMain.cpp deleted file mode 100755 index f153fee1..00000000 --- a/engine/server/application/PlanetServer/src/win32/WinMain.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "FirstPlanetServer.h" -#include "ConfigPlanetServer.h" -#include "PlanetServer.h" - -#include "sharedCompression/SetupSharedCompression.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFoundation/Os.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedLog/SetupSharedLog.h" -#include "sharedNetwork/SetupSharedNetwork.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "sharedRandom/SetupSharedRandom.h" -#include "sharedThread/SetupSharedThread.h" -#include "sharedUtility/SetupSharedUtility.h" - -#include - -//_____________________________________________________________________ -int main(int argc, char ** argv) -{ - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - //-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - - setupFoundationData.argc = argc; - setupFoundationData.argv = argv; - setupFoundationData.createWindow = false; - setupFoundationData.clockUsesSleep = true; - - SetupSharedFoundation::install (setupFoundationData); - - SetupSharedCompression::install(); - SetupSharedFile::install(false); - - SetupSharedNetwork::SetupData networkSetupData; - SetupSharedNetwork::getDefaultServerSetupData(networkSetupData); - SetupSharedNetwork::install(networkSetupData); - - SetupSharedNetworkMessages::install(); - - SetupSharedRandom::install(int(time(NULL))); - - SetupSharedUtility::Data sharedUtilityData; - SetupSharedUtility::setupGameData (sharedUtilityData); - SetupSharedUtility::install (sharedUtilityData); - - //-- setup server - ConfigPlanetServer::install (); - - char tmp[92]; - sprintf(tmp, "PlanetServer:%d", Os::getProcessId()); - SetupSharedLog::install(tmp); - - //-- run server - SetupSharedFoundation::callbackWithExceptionHandling(PlanetServer::run); - - SetupSharedLog::remove(); - SetupSharedFoundation::remove(); - SetupSharedThread::remove(); - - return 0; -} - -//_____________________________________________________________________ diff --git a/engine/server/application/ServerConsole/src/win32/main.cpp b/engine/server/application/ServerConsole/src/win32/main.cpp deleted file mode 100755 index 3de57087..00000000 --- a/engine/server/application/ServerConsole/src/win32/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// main.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -//----------------------------------------------------------------------- - -#include "FirstServerConsole.h" - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedCompression/SetupSharedCompression.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFoundation/ConfigFile.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedNetwork/SetupSharedNetwork.h" -#include "sharedNetwork/NetworkHandler.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "sharedThread/SetupSharedThread.h" -#include "ServerConsole.h" -#include "ConfigServerConsole.h" - -//----------------------------------------------------------------------- - -int main(int argc, char ** argv) -{ - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - //-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - - setupFoundationData.argc = argc; - setupFoundationData.argv = argv; - setupFoundationData.clockUsesSleep = true; - setupFoundationData.createWindow = false; - SetupSharedFoundation::install (setupFoundationData); - - SetupSharedCompression::install(); - SetupSharedNetworkMessages::install(); - - SetupSharedNetwork::SetupData networkSetupData; - SetupSharedNetwork::getDefaultClientSetupData(networkSetupData); - SetupSharedNetwork::install(networkSetupData); - NetworkHandler::install(); - - ConfigServerConsole::install(); - - //-- run server - SetupSharedFoundation::callbackWithExceptionHandling(ServerConsole::run); - - NetworkHandler::remove(); - SetupSharedFoundation::remove(); - SetupSharedThread::remove(); - - return 0; -} - -//----------------------------------------------------------------------- - diff --git a/engine/server/application/TaskManager/src/win32/ConsoleInput.cpp b/engine/server/application/TaskManager/src/win32/ConsoleInput.cpp deleted file mode 100755 index dfd6c431..00000000 --- a/engine/server/application/TaskManager/src/win32/ConsoleInput.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// ConsoleInput.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -//----------------------------------------------------------------------- - -#include "FirstTaskManager.h" -#include "Console.h" -#include - -//----------------------------------------------------------------------- - -const char Console::getNextChar() -{ - char result = 0; - if(_kbhit()) - result = static_cast(_getche()); - return result; -} - -//----------------------------------------------------------------------- - diff --git a/engine/server/application/TaskManager/src/win32/EnvironmentVariable.cpp b/engine/server/application/TaskManager/src/win32/EnvironmentVariable.cpp deleted file mode 100755 index 017b221e..00000000 --- a/engine/server/application/TaskManager/src/win32/EnvironmentVariable.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "FirstTaskManager.h" - -namespace EnvironmentVariable -{ - bool addToEnvironmentVariable(const char* key, const char* value) - { - bool retval = false; - char oldValue[256]; - DWORD tmp = GetEnvironmentVariable(key, oldValue, sizeof(oldValue)); - if (tmp != 0) - { - std::string s(oldValue); - s += ";"; - s += value; - - //Bad things happen if the first character happens to be ; (ie from an empty environment string) - const char* newValue = s.c_str(); - if (newValue[0] == ';') - ++newValue; - - retval = (SetEnvironmentVariable(key, newValue) != 0); - } - else - { - retval = (SetEnvironmentVariable(key, value) != 0); - } - return retval; - } - bool setEnvironmentVariable(const char* key, const char* value) - { - return (SetEnvironmentVariable(key, value) != 0); - } -}; diff --git a/engine/server/application/TaskManager/src/win32/ProcessSpawner.cpp b/engine/server/application/TaskManager/src/win32/ProcessSpawner.cpp deleted file mode 100755 index b544a301..00000000 --- a/engine/server/application/TaskManager/src/win32/ProcessSpawner.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "FirstTaskManager.h" -#include "sharedFoundation/FirstSharedFoundation.h" -#include "ProcessSpawner.h" -#include -#include -#include "TaskManager.h" - -#include - -uint32 ProcessSpawner::prefix; -std::map procById; - -//----------------------------------------------------------------------- - -bool tokenize (const std::string & str, std::vector & result) -{ - size_t end_pos = 0; - size_t start_pos = 0; - - result.clear (); - - for (;;) - { - if (end_pos >= str.size ()) - break; - - start_pos = str.find_first_not_of (' ', end_pos); - - if (start_pos == str.npos) - break; - - //---------------------------------------------------------------------- - - if (str [start_pos] == '\"') - { - if (++start_pos >= str.size ()) - break; - end_pos = str.find_first_of ('\"', start_pos); - } - else - end_pos = str.find_first_of (' ', start_pos); - - //---------------------------------------------------------------------- - - if (start_pos == end_pos) - break; - - if (end_pos == str.npos) - { - result.push_back (str.substr (start_pos)); - break; - } - else - result.push_back (str.substr (start_pos, end_pos - start_pos)); - - ++start_pos; - } - - return true; -} - -uint32 ProcessSpawner::execute(const std::string & processName, const std::vector & parameters) -{ - STARTUPINFO si; - PROCESS_INFORMATION pi; - char cmd[1024] = {"\0"}; - std::string cmdLine; - - cmdLine = processName.c_str(); - cmdLine += " "; - std::vector::const_iterator i; - for(i = parameters.begin(); i != parameters.end(); ++i) - { - cmdLine += (*i).c_str(); - cmdLine += " "; - } - - _snprintf(cmd, 1024, "%s.exe", processName.c_str()); -// _snprintf(cmd, 1024, "%s", processName.c_str()); - memset(&si, 0, sizeof(si)); - memset(&pi, 0, sizeof(pi)); - - si.cb = sizeof(si); - - const int result = CreateProcess(cmd, const_cast(cmdLine.c_str()), NULL, NULL, false, 0, 0, 0, &si, &pi); - UNREF (result); - -#ifdef _DEBUG - if (!result) - { - DWORD iErr = GetLastError(); - char * errStr = strerror(iErr); - DEBUG_REPORT_LOG(true, ("ProcessSpawner: %s - %s\n", cmd, errStr)); - } -#endif - - procById.insert(std::pair(pi.dwProcessId, pi.hProcess)); - return pi.dwProcessId; -} - -//----------------------------------------------------------------------- - -uint32 ProcessSpawner::execute(const std::string & cmd) -{ - std::vector args; - size_t firstArg = cmd.find_first_of(" "); - std::string processName; - if(firstArg < cmd.size()) - { - std::string a = cmd.substr(firstArg + 1); - tokenize(a, args); - processName = cmd.substr(0, firstArg); - } - else - { - processName = cmd; - } - return execute(processName, args); -} - -//----------------------------------------------------------------------- - -bool ProcessSpawner::isProcessActive(uint32 pid) -{ - bool result = false; - std::map::const_iterator f = procById.find(pid); - if(f != procById.end()) - { - DWORD exitCode; - GetExitCodeProcess((*f).second, &exitCode); - result = (exitCode == STILL_ACTIVE); - } - return result; -} - -//----------------------------------------------------------------------- - -void ProcessSpawner::kill(uint32 pid) -{ - HANDLE p = OpenProcess(PROCESS_TERMINATE, false, (DWORD)pid); - if(p) - TerminateProcess(p, 0); -} - -//----------------------------------------------------------------------- - -void ProcessSpawner::forceCore(const unsigned long pid) -{ - ProcessSpawner::kill(pid); -} - -//----------------------------------------------------------------------- - diff --git a/engine/server/application/TaskManager/src/win32/TaskManagerSysInfo.cpp b/engine/server/application/TaskManager/src/win32/TaskManagerSysInfo.cpp deleted file mode 100755 index feadf4f6..00000000 --- a/engine/server/application/TaskManager/src/win32/TaskManagerSysInfo.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// TaskManagerSysInfo.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -//----------------------------------------------------------------------- - -#include "FirstTaskManager.h" -#include "TaskManagerSysInfo.h" -#pragma warning ( disable : 4201) -#include -#include -//----------------------------------------------------------------------- - -TaskManagerSysInfo::TaskManagerSysInfo() : -averageScore() -{ - update(); -} - -//----------------------------------------------------------------------- - -TaskManagerSysInfo::TaskManagerSysInfo(const TaskManagerSysInfo &) -{ - -} - -//----------------------------------------------------------------------- - -TaskManagerSysInfo::~TaskManagerSysInfo() -{ -} - -//----------------------------------------------------------------------- - -TaskManagerSysInfo & TaskManagerSysInfo::operator = (const TaskManagerSysInfo & rhs) -{ - if(this != &rhs) - { - // make assignments if right hand side is not this instance - } - return *this; -} - -//----------------------------------------------------------------------- - -const float TaskManagerSysInfo::getScore() const -{ - std::list::const_iterator i; - float avg = 0.0f; - for(i = averageScore.begin(); i != averageScore.end(); ++i) - { - avg += (*i); - } - avg = avg / averageScore.size(); - return avg; -} - -//----------------------------------------------------------------------- - -void TaskManagerSysInfo::update() -{ - static int64 activeTime[2] = {0}; - static int64 currentTime[2] = {0}; - - float currentScore = 0.0f; - activeTime[0] = activeTime[1]; - currentTime[0] = currentTime[1]; - activeTime[1] = 0; - - HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0); - double procAvg = 0.0f; - - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - - currentScore = static_cast(static_cast(memStat.dwMemoryLoad) * 0.005f); - if(hProcessSnap != INVALID_HANDLE_VALUE) - { - PROCESSENTRY32 pe32 = {0}; - pe32.dwSize = sizeof(PROCESSENTRY32); - if (Process32First(hProcessSnap, &pe32)) - { - do - { - HANDLE proc = OpenProcess(PROCESS_QUERY_INFORMATION, false, pe32.th32ProcessID); - // some stuf with the enumerated processes - FILETIME createTime = {0}; - FILETIME exitTime = {0}; - FILETIME kernelTime = {0}; - FILETIME userTime = {0}; - GetProcessTimes(proc, &createTime, &exitTime, &kernelTime, &userTime); - int64 totals; - - // SDK docs say: - // It is not recommended that you add and subtract values - // from the FILETIME structure to obtain relative times. Instead, you should - // Copy the resulting FILETIME structure to a ULARGE_INTEGER structure. - // Use normal 64-bit arithmetic on the ULARGE_INTEGER value. - int64 c; - int64 e; - int64 k; - int64 u; - memcpy(&c, &createTime, sizeof(int64)); - memcpy(&e, &exitTime, sizeof(int64)); - memcpy(&k, &kernelTime, sizeof(int64)); - memcpy(&u, &userTime, sizeof(int64)); - - totals = k + u; - - FILETIME fst; - SYSTEMTIME st; - GetSystemTime(&st); - SystemTimeToFileTime(&st, &fst); - - int64 runTime; - memcpy(&runTime, &fst, sizeof(int64)); - runTime = runTime - c; - - if(c || e || k || u) - { - activeTime[1] += k + e; - } - - } - while (Process32Next(hProcessSnap, &pe32)); - } - } - - FILETIME fst; - SYSTEMTIME st; - GetSystemTime(&st); - SystemTimeToFileTime(&st, &fst); - memcpy(¤tTime[1], &fst, sizeof(int64)); - int64 timeSlice = currentTime[1] - currentTime[0]; - int64 activeSlice = activeTime[1] - activeTime[0]; - procAvg = static_cast(static_cast(activeSlice) / timeSlice); - //REPORT_LOG(true, ("%f\n", procAvg)); - currentScore = currentScore + static_cast(procAvg * 0.5); - - averageScore.insert(averageScore.end(), currentScore); - - if(averageScore.size() > 100) - averageScore.erase(averageScore.begin()); -} - -//----------------------------------------------------------------------- - diff --git a/engine/server/application/TaskManager/src/win32/WinMain.cpp b/engine/server/application/TaskManager/src/win32/WinMain.cpp deleted file mode 100755 index 14a6ab39..00000000 --- a/engine/server/application/TaskManager/src/win32/WinMain.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "FirstTaskManager.h" - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedCompression/SetupSharedCompression.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFoundation/ConfigFile.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "sharedRandom/SetupSharedRandom.h" -#include "sharedThread/SetupSharedThread.h" -#include "TaskManager.h" -#include "ConfigTaskManager.h" - -//===================================================================== - -int main(int argc, char **argv) -{ - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - //-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - - setupFoundationData.argc = argc; - setupFoundationData.argv = argv; - setupFoundationData.createWindow = false; - setupFoundationData.clockUsesSleep = true; - SetupSharedFoundation::install (setupFoundationData); - - SetupSharedCompression::install(); - SetupSharedFile::install(false); - SetupSharedNetworkMessages::install(); - SetupSharedRandom::install(static_cast(time(NULL))); //lint !e1924 !e64 // NULL is a C-Style cast? - - ConfigTaskManager::install(); - - TaskManager::install(); - - //-- run server - SetupSharedFoundation::callbackWithExceptionHandling(TaskManager::run); - - TaskManager::remove(); - SetupSharedFoundation::remove(); - SetupSharedThread::remove(); - - return 0; -} - -//===================================================================== diff --git a/engine/server/application/TransferServer/src/win32/WinMain.cpp b/engine/server/application/TransferServer/src/win32/WinMain.cpp deleted file mode 100755 index b1533f7c..00000000 --- a/engine/server/application/TransferServer/src/win32/WinMain.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// main.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -//----------------------------------------------------------------------- - -#include "FirstTransferServer.h" - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedCompression/SetupSharedCompression.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFoundation/Os.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedNetwork/SetupSharedNetwork.h" -#include "sharedNetwork/NetworkHandler.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "sharedThread/SetupSharedThread.h" -#include "TransferServer.h" -#include "ConfigTransferServer.h" - -//----------------------------------------------------------------------- - -int main(int argc, char ** argv) -{ - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - //-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - - setupFoundationData.argc = argc; - setupFoundationData.argv = argv; - setupFoundationData.createWindow = true; - SetupSharedFoundation::install (setupFoundationData); - - SetupSharedCompression::install(); - SetupSharedFile::install(false); - SetupSharedNetworkMessages::install(); - - SetupSharedNetwork::SetupData networkSetupData; - SetupSharedNetwork::getDefaultServerSetupData(networkSetupData); - SetupSharedNetwork::install(networkSetupData); - NetworkHandler::install(); - - //Os::setProgramName("TransferServer"); - ConfigTransferServer::install(); - - //-- run server - SetupSharedFoundation::callbackWithExceptionHandling(TransferServer::run); - - NetworkHandler::remove(); - SetupSharedFoundation::remove(); - SetupSharedThread::remove(); - - return 0; -} - -//----------------------------------------------------------------------- - diff --git a/engine/server/library/serverDatabase/src/win32/FirstServerDatabase.cpp b/engine/server/library/serverDatabase/src/win32/FirstServerDatabase.cpp deleted file mode 100755 index 944e604d..00000000 --- a/engine/server/library/serverDatabase/src/win32/FirstServerDatabase.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// ====================================================================== -// -// FirstServerDatabase.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "serverDatabase/FirstServerDatabase.h" - diff --git a/engine/server/library/serverGame/src/win32/FirstServerGame.cpp b/engine/server/library/serverGame/src/win32/FirstServerGame.cpp deleted file mode 100755 index c10e7d27..00000000 --- a/engine/server/library/serverGame/src/win32/FirstServerGame.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// ====================================================================== -// -// FirstServerGame.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "serverGame/FirstServerGame.h" - -// ====================================================================== diff --git a/engine/server/library/serverKeyShare/src/win32/FirstServerKeyShare.cpp b/engine/server/library/serverKeyShare/src/win32/FirstServerKeyShare.cpp deleted file mode 100755 index 541cbe71..00000000 --- a/engine/server/library/serverKeyShare/src/win32/FirstServerKeyShare.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstServerKeyShare.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "serverKeyShare/FirstServerKeyShare.h" diff --git a/engine/server/library/serverMetrics/src/win32/FirstServerMetrics.cpp b/engine/server/library/serverMetrics/src/win32/FirstServerMetrics.cpp deleted file mode 100755 index 5133f174..00000000 --- a/engine/server/library/serverMetrics/src/win32/FirstServerMetrics.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// FirstServerMetrics.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -//----------------------------------------------------------------------- - -#include "serverMetrics/FirstServerMetrics.h" - -//----------------------------------------------------------------------- diff --git a/engine/server/library/serverNetworkMessages/src/win32/FirstServerNetworkMessages.cpp b/engine/server/library/serverNetworkMessages/src/win32/FirstServerNetworkMessages.cpp deleted file mode 100755 index 16562107..00000000 --- a/engine/server/library/serverNetworkMessages/src/win32/FirstServerNetworkMessages.cpp +++ /dev/null @@ -1,3 +0,0 @@ - - -#include "serverNetworkMessages/FirstServerNetworkMessages.h" diff --git a/engine/server/library/serverPathfinding/src/win32/FirstServerPathfinding.cpp b/engine/server/library/serverPathfinding/src/win32/FirstServerPathfinding.cpp deleted file mode 100755 index ac6ecea0..00000000 --- a/engine/server/library/serverPathfinding/src/win32/FirstServerPathfinding.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstServerPathfinding.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "serverPathfinding/FirstServerPathfinding.h" diff --git a/engine/server/library/serverScript/src/win32/FirstServerScript.cpp b/engine/server/library/serverScript/src/win32/FirstServerScript.cpp deleted file mode 100755 index 46a6979d..00000000 --- a/engine/server/library/serverScript/src/win32/FirstServerScript.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "serverScript/FirstServerScript.h" \ No newline at end of file diff --git a/engine/server/library/serverUtility/src/win32/FirstServerUtility.cpp b/engine/server/library/serverUtility/src/win32/FirstServerUtility.cpp deleted file mode 100755 index 73488cc4..00000000 --- a/engine/server/library/serverUtility/src/win32/FirstServerUtility.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "serverUtility/FirstServerUtility.h" \ No newline at end of file diff --git a/engine/shared/application/TemplateCompiler/src/win32/FirstTemplateCompiler.cpp b/engine/shared/application/TemplateCompiler/src/win32/FirstTemplateCompiler.cpp deleted file mode 100755 index ef9c16dc..00000000 --- a/engine/shared/application/TemplateCompiler/src/win32/FirstTemplateCompiler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "FirstTemplateCompiler.h" diff --git a/engine/shared/application/TemplateCompiler/src/win32/FirstTemplateCompiler.h b/engine/shared/application/TemplateCompiler/src/win32/FirstTemplateCompiler.h deleted file mode 100755 index 355e5538..00000000 --- a/engine/shared/application/TemplateCompiler/src/win32/FirstTemplateCompiler.h +++ /dev/null @@ -1,8 +0,0 @@ -#include "sharedFoundationTypes/FoundationTypes.h" -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedFoundation/FirstSharedFoundation.h" -#include -#include -#include -#include -#include \ No newline at end of file diff --git a/engine/shared/application/TemplateDefinitionCompiler/src/win32/FirstTemplateDefinitionCompiler.cpp b/engine/shared/application/TemplateDefinitionCompiler/src/win32/FirstTemplateDefinitionCompiler.cpp deleted file mode 100755 index 1444700b..00000000 --- a/engine/shared/application/TemplateDefinitionCompiler/src/win32/FirstTemplateDefinitionCompiler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "FirstTemplateDefinitionCompiler.h" \ No newline at end of file diff --git a/engine/shared/application/TemplateDefinitionCompiler/src/win32/FirstTemplateDefinitionCompiler.h b/engine/shared/application/TemplateDefinitionCompiler/src/win32/FirstTemplateDefinitionCompiler.h deleted file mode 100755 index 355e5538..00000000 --- a/engine/shared/application/TemplateDefinitionCompiler/src/win32/FirstTemplateDefinitionCompiler.h +++ /dev/null @@ -1,8 +0,0 @@ -#include "sharedFoundationTypes/FoundationTypes.h" -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedFoundation/FirstSharedFoundation.h" -#include -#include -#include -#include -#include \ No newline at end of file diff --git a/engine/shared/library/sharedCollision/src/win32/FirstSharedCollision.cpp b/engine/shared/library/sharedCollision/src/win32/FirstSharedCollision.cpp deleted file mode 100755 index 175da0d0..00000000 --- a/engine/shared/library/sharedCollision/src/win32/FirstSharedCollision.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstSharedCollision.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedCollision/FirstSharedCollision.h" diff --git a/engine/shared/library/sharedCommandParser/src/win32/FirstSharedCommandParser.cpp b/engine/shared/library/sharedCommandParser/src/win32/FirstSharedCommandParser.cpp deleted file mode 100755 index e07abaf5..00000000 --- a/engine/shared/library/sharedCommandParser/src/win32/FirstSharedCommandParser.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstCommandParser.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedCommandParser/FirstSharedCommandParser.h" diff --git a/engine/shared/library/sharedCompression/src/win32/FirstSharedCompression.cpp b/engine/shared/library/sharedCompression/src/win32/FirstSharedCompression.cpp deleted file mode 100755 index 4c24e040..00000000 --- a/engine/shared/library/sharedCompression/src/win32/FirstSharedCompression.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstCompression.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedCompression/FirstSharedCompression.h" diff --git a/engine/shared/library/sharedDatabaseInterface/src/win32/FirstSharedDatabaseInterface.cpp b/engine/shared/library/sharedDatabaseInterface/src/win32/FirstSharedDatabaseInterface.cpp deleted file mode 100755 index 46137c3b..00000000 --- a/engine/shared/library/sharedDatabaseInterface/src/win32/FirstSharedDatabaseInterface.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// ====================================================================== -// -// FirstServerDatabaseInterface.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedDatabaseInterface/FirstSharedDatabaseInterface.h" - diff --git a/engine/shared/library/sharedDatabaseInterface/src/win32/SQLC_Defs.h b/engine/shared/library/sharedDatabaseInterface/src/win32/SQLC_Defs.h deleted file mode 100755 index 6722c280..00000000 --- a/engine/shared/library/sharedDatabaseInterface/src/win32/SQLC_Defs.h +++ /dev/null @@ -1,19 +0,0 @@ -/* SQLC_Defs.h - * - * This file includes common definitions needed by the other SQLClasses header files. - * (Don't include this file directly -- files that require it will include it.) - * - * Note that this file is specific to each OS, because what header files are - * needed varies in each OS. In particular, Unix versions don't want windows.h. - * - * ODBC versions: includes definitions of ODBC datatypes needed by the various - * SQLClasses - */ - -#ifndef _SQLC_DEFS_H -#define _SQLC_DEFS_H - -#include -#include - -#endif \ No newline at end of file diff --git a/engine/shared/library/sharedDebug/src/win32/DebugHelp.cpp b/engine/shared/library/sharedDebug/src/win32/DebugHelp.cpp deleted file mode 100755 index b80a6a45..00000000 --- a/engine/shared/library/sharedDebug/src/win32/DebugHelp.cpp +++ /dev/null @@ -1,670 +0,0 @@ -// ====================================================================== -// -// DebugHelp.cpp -// copyright 2000 Verant Interactive -// -// ====================================================================== - -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedDebug/DebugHelp.h" - -#include "sharedFoundation/WindowsWrapper.h" - -#include -#include -#include - -// ====================================================================== - - -// ====================================================================== -// This was done to keep the header file from having to include or - -namespace DebugHelpNamespace -{ - static HINSTANCE library; - static HANDLE process; - - struct CallbackData - { - const char *name; - bool loaded; - }; - - typedef DWORD (__stdcall *SymSetOptionsFP)(IN DWORD SymOptions); - typedef BOOL (__stdcall *SymInitializeFP)(IN HANDLE hProcess, IN PSTR UserSearchPath, IN BOOL fInvadeProcess); - typedef BOOL (__stdcall *SymCleanupFP)(IN HANDLE hProcess); - - typedef BOOL (__stdcall *StackWalk64FP)(DWORD MachineType, HANDLE hProcess, HANDLE hThread, LPSTACKFRAME64 StackFrame, PVOID ContextRecord, PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress); - typedef BOOL (__stdcall *SymGetModuleInfo64FP)(IN HANDLE hProcess, IN DWORD64 dwAddr, OUT PIMAGEHLP_MODULE64 ModuleInfo); - typedef DWORD64 (__stdcall *SymLoadModule64FP)(IN HANDLE hProcess, IN HANDLE hFile, IN PSTR ImageName, IN PSTR ModuleName, IN DWORD64 BaseOfDll, IN DWORD SizeOfDll); - typedef BOOL (__stdcall *SymGetSymFromAddr64FP)(IN HANDLE hProcess, IN DWORD64 dwAddr, OUT PDWORD64 pdwDisplacement, OUT PIMAGEHLP_SYMBOL64 Symbol); - typedef BOOL (__stdcall *SymGetLineFromAddr64FP)(IN HANDLE hProcess, IN DWORD64 dwAddr, OUT PDWORD pdwDisplacement, OUT PIMAGEHLP_LINE64 Line); - typedef PVOID (__stdcall *SymFunctionTableAccess64FP)(HANDLE hProcess, DWORD64 AddrBase); - typedef DWORD64 (__stdcall *SymGetModuleBase64FP)(IN HANDLE hProcess, IN DWORD64 dwAddr); - typedef BOOL (__stdcall *SymEnumerateModules64FP)(HANDLE hProcess, PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, PVOID UserContext); - typedef BOOL (__stdcall *EnumerateLoadedModules64FP)(IN HANDLE hProcess, IN PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback, IN PVOID UserContext); - typedef BOOL (__stdcall *MiniDumpWriteDumpFP)(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, MINIDUMP_TYPE DumpType, PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, PMINIDUMP_CALLBACK_INFORMATION CallbackParam); - - static SymSetOptionsFP symSetOptions; - static SymInitializeFP symInitialize; - static SymCleanupFP symCleanup; - static StackWalk64FP stackWalk64; - static SymGetModuleInfo64FP symGetModuleInfo64; - static SymLoadModule64FP symLoadModule64; - static SymGetSymFromAddr64FP symGetSymFromAddr64; - static SymGetLineFromAddr64FP symGetLineFromAddr64; - static SymFunctionTableAccess64FP symFunctionTableAccess64; - static SymGetModuleBase64FP symGetModuleBase64; - static SymEnumerateModules64FP symEnumerateModules64; - static EnumerateLoadedModules64FP enumerateLoadedModules64; - static MiniDumpWriteDumpFP miniDumpWriteDump; - static CRITICAL_SECTION criticalSection; - - // ---------------------------------------------------------------------- - - //BOOL CALLBACK loadSymbolsForDllCallback(PTSTR ModuleName, DWORD64 ModuleBase, ULONG ModuleSize, PVOID UserContext); - - // ---------------------------------------------------------------------- - - - typedef unsigned long int ub4; /* unsigned 4-byte quantities */ - typedef unsigned char ub1; /* unsigned 1-byte quantities */ - - #define hashsize(n) ((ub4)1<<(n)) - #define hashmask(n) (hashsize(n)-1) - - /* - -------------------------------------------------------------------- - mix -- mix 3 32-bit values reversibly. - For every delta with one or two bits set, and the deltas of all three - high bits or all three low bits, whether the original value of a,b,c - is almost all zero or is uniformly distributed, - * If mix() is run forward or backward, at least 32 bits in a,b,c - have at least 1/4 probability of changing. - * If mix() is run forward, every bit of c will change between 1/3 and - 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) - mix() was built out of 36 single-cycle latency instructions in a - structure that could supported 2x parallelism, like so: - a -= b; - a -= c; x = (c>>13); - b -= c; a ^= x; - b -= a; x = (a<<8); - c -= a; b ^= x; - c -= b; x = (b>>13); - ... - Unfortunately, superscalar Pentiums and Sparcs can't take advantage - of that parallelism. They've also turned some of those single-cycle - latency instructions into multi-cycle latency instructions. Still, - this is the fastest good hash I could find. There were about 2^^68 - to choose from. I only looked at a billion or so. - -------------------------------------------------------------------- - */ - #define mix(a,b,c) \ - { \ - a -= b; a -= c; a ^= (c>>13); \ - b -= c; b -= a; b ^= (a<<8); \ - c -= a; c -= b; c ^= (b>>13); \ - a -= b; a -= c; a ^= (c>>12); \ - b -= c; b -= a; b ^= (a<<16); \ - c -= a; c -= b; c ^= (b>>5); \ - a -= b; a -= c; a ^= (c>>3); \ - b -= c; b -= a; b ^= (a<<10); \ - c -= a; c -= b; c ^= (b>>15); \ - } - - /* - -------------------------------------------------------------------- - hash() -- hash a variable-length key into a 32-bit value - k : the key (the unaligned variable-length array of bytes) - len : the length of the key, counting by bytes - initval : can be any 4-byte value - Returns a 32-bit value. Every bit of the key affects every bit of - the return value. Every 1-bit and 2-bit delta achieves avalanche. - About 6*len+35 instructions. - - The best hash table sizes are powers of 2. There is no need to do - mod a prime (mod is sooo slow!). If you need less than 32 bits, - use a bitmask. For example, if you need only 10 bits, do - h = (h & hashmask(10)); - In which case, the hash table should have hashsize(10) elements. - - If you are hashing n strings (ub1 **)k, do it like this: - for (i=0, h=0; i= 12) - { - a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24)); - b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24)); - c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24)); - mix(a,b,c); - k += 12; len -= 12; - } - - /*------------------------------------- handle the last 11 bytes */ - c += length; - switch(len) /* all the case statements fall through */ - { - case 11: c+=((ub4)k[10]<<24); - case 10: c+=((ub4)k[9]<<16); - case 9 : c+=((ub4)k[8]<<8); - /* the first byte of c is reserved for the length */ - case 8 : b+=((ub4)k[7]<<24); - case 7 : b+=((ub4)k[6]<<16); - case 6 : b+=((ub4)k[5]<<8); - case 5 : b+=k[4]; - case 4 : a+=((ub4)k[3]<<24); - case 3 : a+=((ub4)k[2]<<16); - case 2 : a+=((ub4)k[1]<<8); - case 1 : a+=k[0]; - /* case 0: nothing left to add */ - } - mix(a,b,c); - /*-------------------------------------------- report the result */ - return c; - } -#endif - - // version optimized for 4 byte input. - static ub4 hash_DWORD(const DWORD in, const ub4 initval) - { - ub1 *const k = (ub1 *)∈ - ub4 a, b, c, len; - - /* Set up the internal state */ - len = 4; - a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */ - c = initval; /* the previous hash value */ - - /*------------------------------------- handle the last 11 bytes */ - c += 4; - a+=((ub4)k[3]<<24); - a+=((ub4)k[2]<<16); - a+=((ub4)k[1]<<8); - a+=k[0]; - - mix(a,b,c); - - /*-------------------------------------------- report the result */ - return c; - } - - - // ---------------------------------------------------------------------- - - struct BaseAddressLookup - { - DWORD64 keyAddress; // key - DWORD64 baseAddress; // value - }; - - static BaseAddressLookup * s_baseAddressCache; - static inline unsigned _baseAddressCachePageBits() { return 8; } - static inline unsigned _baseAddressCacheBits() { return _baseAddressCachePageBits() + 12; } - static inline unsigned _baseAddressCacheSize() { return 1 << (_baseAddressCacheBits()); } - static inline unsigned _baseAddressCacheElements() { return _baseAddressCacheSize() / sizeof(*s_baseAddressCache); } - static inline unsigned _baseAddressCacheMask() { return _baseAddressCacheElements() - 1; } - - static int s_baseAddressCacheMisses; - static int s_baseAddressCacheHits; - - static int s_baseAddressElements; - static int s_baseAddressUsed; - - /* - static void _baseAddressCacheAnalyze() - { - s_baseAddressElements=0; - s_baseAddressUsed=0; - - unsigned i; - const unsigned count = _baseAddressCacheElements(); - for (i=0;ibaseAddress) - { - s_baseAddressUsed++; - } - } - } - */ - - static DWORD64 _baseAddressLookup(DWORD64 addr) - { - BaseAddressLookup *lookup; - - unsigned long bits = _baseAddressCacheBits(); - - DWORD *addr32 = (DWORD *)&addr; - unsigned long hash32 = hash_DWORD(addr32[0], addr32[1]); - unsigned long hash = (hash32>>(32-bits)) ^ hash32; - - unsigned long mask = _baseAddressCacheMask(); - - unsigned long index = hash & mask; - lookup = s_baseAddressCache + index; - if (lookup->keyAddress==addr) - { - s_baseAddressCacheHits++; - //DEBUG_FATAL(symGetModuleBase64(process, addr) != lookup->baseAddress, ("Cache failure.\n")); - return lookup->baseAddress; - } - else - { - s_baseAddressCacheMisses++; - - DWORD64 baseAddress = symGetModuleBase64(process, addr); - - lookup->keyAddress=addr; - lookup->baseAddress=baseAddress; - - return baseAddress; - } - } - - static DWORD64 __stdcall getModuleBase(HANDLE hProcess, DWORD64 dwAddr) - { - UNREF(hProcess); - DEBUG_FATAL(hProcess!=process, ("Wrong process handle for module base lookup.\n")); - return _baseAddressLookup(dwAddr); - } - - // ---------------------------------------------------------------------- - struct FunctionTableLookup - { - DWORD64 keyAddress; // key - PVOID functionTable; // value - }; - - static FunctionTableLookup * s_functionTableCache; - static inline unsigned _functionTableCachePageBits() { return 4; } - static inline unsigned _functionTableCacheBits() { return _functionTableCachePageBits() + 12; } - static inline unsigned _functionTableCacheSize() { return 1 << (_functionTableCacheBits()); } - static inline unsigned _functionTableCacheElements() { return _functionTableCacheSize() / sizeof(*s_functionTableCache); } - static inline unsigned _functionTableCacheMask() { return _functionTableCacheElements() - 1; } - - static int s_functionTableCacheMisses; - static int s_functionTableCacheHits; - - - static PVOID _functionTableLookup(DWORD64 addr) - { - FunctionTableLookup *lookup; - - unsigned long bits = _functionTableCacheBits(); - - DWORD *addr32 = (DWORD *)&addr; - unsigned long hash32 = hash_DWORD(addr32[0], addr32[1]); - unsigned long hash = (hash32>>(32-bits)) ^ hash32; - - unsigned long mask = _functionTableCacheMask(); - - unsigned long index = hash & mask; - lookup = s_functionTableCache + index; - if (lookup->keyAddress==addr) - { - s_functionTableCacheHits++; - //DEBUG_FATAL(symFunctionTableAccess64(process, addr) != lookup->functionTable, ("Cache failure.\n")); - return lookup->functionTable; - } - else - { - s_functionTableCacheMisses++; - PVOID functionTable = symFunctionTableAccess64(process, addr); - lookup->keyAddress=addr; - lookup->functionTable=functionTable; - - return functionTable; - } - } - - static PVOID __stdcall functionTableAccess(HANDLE hProcess, DWORD64 dwAddr) - { - UNREF(hProcess); - DEBUG_FATAL(hProcess!=process, ("Wrong process handle for module base lookup.\n")); - return _functionTableLookup(DWORD(dwAddr)); - } - - // ---------------------------------------------------------------------- -} -using namespace DebugHelpNamespace; - -// ---------------------------------------------------------------------- - -BOOL CALLBACK loadSymbolsForDllCallback(PSTR ModuleName, DWORD64 ModuleBase, ULONG ModuleSize, PVOID UserContext) -{ - if (!library) - return false; - - CallbackData *callbackData = reinterpret_cast(UserContext); - - // see if this is the right file module and if we can load its symbol information - if (_stricmp(ModuleName, callbackData->name) == 0 && symLoadModule64(process, NULL, ModuleName, 0, ModuleBase, ModuleSize) != 0) - { - callbackData->loaded = true; - return FALSE; - } - - return TRUE; -} - -// ====================================================================== - -void DebugHelp::install() -{ - DEBUG_FATAL(library, ("DebugHelp already installed")); - - library = LoadLibrary("dbghelp_6.3.17.0.dll"); - if (library) - { - process = GetCurrentProcess(); - -#define GPA(a, b) a = reinterpret_cast(GetProcAddress(library, #b)); DEBUG_FATAL(!a, ("GetProcAddress failed for " #b)) - GPA(symSetOptions, SymSetOptions); - GPA(symInitialize, SymInitialize); - GPA(symCleanup, SymCleanup); - GPA(stackWalk64, StackWalk64); - GPA(symGetModuleInfo64, SymGetModuleInfo64); - GPA(symLoadModule64, SymLoadModule64); - GPA(symGetSymFromAddr64, SymGetSymFromAddr64); - GPA(symGetLineFromAddr64, SymGetLineFromAddr64); - GPA(symFunctionTableAccess64, SymFunctionTableAccess64); - GPA(symGetModuleBase64, SymGetModuleBase64); - GPA(symEnumerateModules64, SymEnumerateModules64); - GPA(enumerateLoadedModules64, EnumerateLoadedModules64); - GPA(miniDumpWriteDump, MiniDumpWriteDump); -#undef GPA - - IGNORE_RETURN(symSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME | SYMOPT_LOAD_LINES)); - - // get the path to the executable - char executableDirectory[MAX_PATH * 2]; - const DWORD result = GetModuleFileName(NULL, executableDirectory, sizeof(executableDirectory)); - FATAL(result == 0, ("GetModuleFileName failed")); - char * const slash = strrchr(executableDirectory, '\\'); - DEBUG_FATAL(!slash, ("Executable path does not contain a slash")); - *slash = '\0'; - - const BOOL result1 = symInitialize(process, executableDirectory, TRUE); - UNREF(result1); - DEBUG_FATAL(!result1, ("SymInitialize failed")); - - // ----------------------------------------------------------------------- - - s_baseAddressCache = (BaseAddressLookup *)VirtualAlloc(0, _baseAddressCacheSize(), MEM_COMMIT, PAGE_READWRITE); - - s_functionTableCache = (FunctionTableLookup *)VirtualAlloc(0, _functionTableCacheSize(), MEM_COMMIT, PAGE_READWRITE); - - // ----------------------------------------------------------------------- - } - - // Initialize the critical section one time only. - InitializeCriticalSection(&criticalSection); -} - -// ---------------------------------------------------------------------- - -void DebugHelp::remove() -{ - if (s_baseAddressCache) - { - VirtualFree(s_baseAddressCache, 0, MEM_RELEASE); - s_baseAddressCache=0; - } - - if (s_functionTableCache) - { - VirtualFree(s_functionTableCache, 0, MEM_RELEASE); - s_functionTableCache=0; - } - - if (library) - { - IGNORE_RETURN(symCleanup(process)); - IGNORE_RETURN(FreeLibrary(library)); - library = NULL; - process = NULL; - symSetOptions = NULL; - symInitialize = NULL; - symCleanup = NULL; - stackWalk64 = NULL; - symGetModuleInfo64 = NULL; - symLoadModule64 = NULL; - symGetSymFromAddr64 = NULL; - symGetLineFromAddr64 = NULL; - symFunctionTableAccess64 = NULL; - symGetModuleBase64 = NULL; - symEnumerateModules64 = NULL; - enumerateLoadedModules64 = NULL; - } - - // Release resources used by the critical section object. - DeleteCriticalSection(&criticalSection); -} - -// ---------------------------------------------------------------------- - -bool DebugHelp::loadSymbolsForDll(const char *name) -{ - if (!library) - return false; - - CallbackData callbackData = { name, false }; - enumerateLoadedModules64(process, (PENUMLOADED_MODULES_CALLBACK64)loadSymbolsForDllCallback, reinterpret_cast(&callbackData)); - return callbackData.loaded; -} - -// ---------------------------------------------------------------------- -#pragma warning (disable: 4740 4748) -void DebugHelp::getCallStack(uint32 *callStack, int sizeOfCallStack) -{ - { - for (int i = 0; i < sizeOfCallStack; ++i) - callStack[i] = 0; - } - - if (!library) - return; - - CONTEXT context; - Zero(context); - context.ContextFlags = CONTEXT_FULL; - - // GetThreadContext returns invalid data when called from within the same thread - //if (!GetThreadContext(GetCurrentThread(), &context)) - // return; - - EnterCriticalSection(&criticalSection); - __asm - { - call GetEIP - GetEIP: - pop eax - mov context.Eip, eax - mov context.Esp, esp - mov context.Ebp, ebp - } - LeaveCriticalSection(&criticalSection); - - STACKFRAME64 stackFrame; - Zero(stackFrame); - stackFrame.AddrPC.Mode = AddrModeFlat; - stackFrame.AddrPC.Offset = context.Eip; - stackFrame.AddrStack.Offset = context.Esp; - stackFrame.AddrStack.Mode = AddrModeFlat; - stackFrame.AddrFrame.Offset = context.Ebp; - stackFrame.AddrFrame.Mode = AddrModeFlat; - - for (int i = 0; i < sizeOfCallStack; ++i, ++callStack) - { - if (stackWalk64(IMAGE_FILE_MACHINE_I386, process, process, &stackFrame, &context, NULL, functionTableAccess, getModuleBase, NULL)) - { - const DWORD64 Offset = stackFrame.AddrPC.Offset; - *callStack = DWORD(Offset); - } - } -} - -// ---------------------------------------------------------------------- - -void DebugHelp::reportCallStack(int const maxStackDepth) -{ - // look up the call stack information - int const callStackOffset = 2; - int const callStackSize = callStackOffset + maxStackDepth; - uint32 * callStack = static_cast(_alloca((callStackOffset + maxStackDepth) * sizeof(uint32))); - getCallStack(callStack, callStackOffset + maxStackDepth); - - // look up the caller's file and line - if (callStack[callStackOffset]) - { - char lib[4 * 1024] = { '\0' }; - char file[4 * 1024] = { '\0' }; - int line = 0; - for (int i = callStackOffset; i < callStackSize; ++i) - { - if (callStack[i]) - { - if (lookupAddress(callStack[i], lib, file, sizeof(file), line)) - REPORT_LOG(true, ("\t%s(%d) : caller %d\n", file, line, i-callStackOffset)); - else - REPORT_LOG(true, ("\tunknown(0x%08X) : caller %d\n", static_cast(callStack[i]), i-callStackOffset)); - } - } - } -} - -// ---------------------------------------------------------------------- - -bool DebugHelp::lookupAddress(uint32 address, char *libName, char *fileName, int fileNameLength, int &line) -{ - UNREF(libName); - - if (!library) - return false; - - // make sure the image is loaded - IMAGEHLP_MODULE64 imageHelpModule; - Zero(imageHelpModule); - imageHelpModule.SizeOfStruct = sizeof(imageHelpModule); - if (!symGetModuleInfo64(process, address, &imageHelpModule)) - return false; - - // look up the symbol - const int MaxNameLength = 256; - char buffer[sizeof(IMAGEHLP_SYMBOL64) + MaxNameLength]; - memset(buffer, 0, sizeof(buffer)); - IMAGEHLP_SYMBOL64 *imageHelpSymbol = reinterpret_cast(buffer); - imageHelpSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64); - imageHelpSymbol->Address = address; - imageHelpSymbol->MaxNameLength = MaxNameLength; - { - DWORD64 displacement = 0; - if (!symGetSymFromAddr64(process, address, &displacement, imageHelpSymbol)) - { - return false; - } - } - - // look up the source file name and line number - IMAGEHLP_LINE64 imageHelpLine; - Zero(imageHelpLine); - imageHelpLine.SizeOfStruct = sizeof(imageHelpLine); - { - DWORD displacement = 0; - if (!symGetLineFromAddr64(process, address, &displacement, &imageHelpLine)) - { - return false; - } - } - - // return the results - strncpy(fileName, imageHelpLine.FileName, static_cast(fileNameLength)); - line = static_cast(imageHelpLine.LineNumber); - return true; -} - -// ---------------------------------------------------------------------- - -bool DebugHelp::writeMiniDump(char const *miniDumpFileName, PEXCEPTION_POINTERS exceptionPointers) -{ - if (!miniDumpWriteDump) - return false; - - char buffer[256]; - if (!miniDumpFileName) - { - // get the program name - char programName[512]; - DWORD result = GetModuleFileName(NULL, programName, sizeof(programName)); - if (result == 0) - return false; - - // get the file name without the path - const char *shortProgramName = strrchr(programName, '\\'); - if (shortProgramName) - ++shortProgramName; - else - shortProgramName = programName; - - // lop off the extension - char *dot = const_cast(strchr(shortProgramName, '.')); - if (dot) - *dot = '\0'; - - // create a reasonable minidump filename - snprintf(buffer, sizeof(buffer), "%s_%d.mdmp", shortProgramName, static_cast(GetCurrentProcessId())); - miniDumpFileName = buffer; - } - - // create the file - HANDLE const file = CreateFile(miniDumpFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL); - if (file == INVALID_HANDLE_VALUE) - return false; - - // create the exception information - MINIDUMP_EXCEPTION_INFORMATION exceptionInformationData; - MINIDUMP_EXCEPTION_INFORMATION *exceptionInformation = 0; - if (exceptionPointers) - { - exceptionInformationData.ThreadId = GetCurrentThreadId(); - exceptionInformationData.ExceptionPointers = exceptionPointers; - exceptionInformationData.ClientPointers = true; - exceptionInformation = &exceptionInformationData; - } - - // @todo make the minidump style modifiable - BOOL const result = miniDumpWriteDump(process, GetCurrentProcessId(), file, MiniDumpNormal, exceptionInformation, NULL, NULL); - - // close the file - CloseHandle(file); - - return result ? true : false; -} - -// ====================================================================== diff --git a/engine/shared/library/sharedDebug/src/win32/DebugHelp.h b/engine/shared/library/sharedDebug/src/win32/DebugHelp.h deleted file mode 100755 index ead64d75..00000000 --- a/engine/shared/library/sharedDebug/src/win32/DebugHelp.h +++ /dev/null @@ -1,35 +0,0 @@ -// ====================================================================== -// -// DebugHelp.h -// copyright 2000 Verant Interactive -// -// ====================================================================== - -#ifndef DEBUG_HELP_H -#define DEBUG_HELP_H - -// ====================================================================== - -typedef unsigned long uint32; - -// ====================================================================== - -class DebugHelp -{ -public: - - static void install(); - static void remove(); - - static bool loadSymbolsForDll(const char *name); - - static void getCallStack(uint32 *callStack, int sizeOfCallStack); - static void reportCallStack(int const maxStackDepth = 4); - static bool lookupAddress(uint32 address, char *libName, char *fileName, int fileNameLength, int &line); - - static bool writeMiniDump(char const *miniDumpFileName=0, PEXCEPTION_POINTERS exceptionPointers=0); -}; - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedDebug/src/win32/DebugMonitor.cpp b/engine/shared/library/sharedDebug/src/win32/DebugMonitor.cpp deleted file mode 100755 index ebc7b249..00000000 --- a/engine/shared/library/sharedDebug/src/win32/DebugMonitor.cpp +++ /dev/null @@ -1,321 +0,0 @@ -// ====================================================================== -// -// DebugMonitor.cpp -// copyright 1998 Bootprint Entertainment -// copyright 2001-2004 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedDebug/DebugMonitor.h" - -#if PRODUCTION == 0 - -#include "sharedDebug/DebugFlags.h" -#include "sharedFoundation/ConfigFile.h" - -// ====================================================================== - -namespace DebugMonitorNamespace -{ - typedef void (*ChangedWindowCallback)(int x, int y, int width, int height); - - typedef bool (*InstallFunction)(int x, int y, int width, int height); - typedef void (*RemoveFunction)(); - typedef void (*ShowFunction)(); - typedef void (*HideFunction)(); - typedef void (*SetChangedWindowCallback)(ChangedWindowCallback); - typedef void (*SetBehindWindowFunction)(HWND window); - typedef void (*ClearScreenFunction)(); - typedef void (*ClearToCursorFunction)(); - typedef void (*GotoXYFunction)(int x, int y); - typedef void (*PrintFunction)(const char *string); - - void changedWindowCallback(int x, int y, int width, int height); - - HINSTANCE dll; - HKEY registryKey = HKEY_CLASSES_ROOT; - RemoveFunction removeFunction; - ShowFunction showFunction; - HideFunction hideFunction; - SetBehindWindowFunction setBehindWindowFunction; - ClearScreenFunction clearScreenFunction; - ClearToCursorFunction clearToCursorFunction; - GotoXYFunction gotoXYFunction; - PrintFunction printFunction; - - bool noClear; - - int GetRegistryValue(char const * name, int defaultValue) - { - int value; - DWORD type = 0; - DWORD size = sizeof(DWORD); - LONG result = RegQueryValueEx(registryKey, name, NULL, &type, reinterpret_cast(&value), &size); - if ((result != ERROR_SUCCESS || type != REG_DWORD) && (size != sizeof(int))) - value = defaultValue; - return value; - } - - void SetRegistryValue(char const * name, int value) - { - RegSetValueEx(registryKey, name, NULL, REG_DWORD, reinterpret_cast(&value), sizeof(int)); - } -} -using namespace DebugMonitorNamespace; - -// ====================================================================== -// Install the debug monitor subsystem -// -// Remarks: -// -// This routine will first attempt to install the selected debug monitor. - -void DebugMonitor::install() -{ - dll = LoadLibrary("debugWindow.dll"); - if (dll) - { - InstallFunction installFunction = reinterpret_cast(GetProcAddress(dll, "install")); - - RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Sony Online Entertainment\\DebugWindow", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, ®istryKey, NULL); - - int const x = ConfigFile::getKeyInt("SharedDebug", "debugWindowX", GetRegistryValue("x", 0)); - int const y = ConfigFile::getKeyInt("SharedDebug", "debugWindowY", GetRegistryValue("y", 0)); - int const width = ConfigFile::getKeyInt("SharedDebug", "debugWindowWidth", GetRegistryValue("width", 80)); - int const height = ConfigFile::getKeyInt("SharedDebug", "debugWindowHeight", GetRegistryValue("height", 50)); - - if (installFunction && installFunction(x, y, width, height)) - { - showFunction = reinterpret_cast(GetProcAddress(dll, "showWindow")); - hideFunction = reinterpret_cast(GetProcAddress(dll, "hideWindow")); - removeFunction = reinterpret_cast(GetProcAddress(dll, "remove")); - setBehindWindowFunction = reinterpret_cast(GetProcAddress(dll, "setBehindWindow")); - clearScreenFunction = reinterpret_cast(GetProcAddress(dll, "clearScreen")); - clearToCursorFunction = reinterpret_cast(GetProcAddress(dll, "clearToCursor")); - gotoXYFunction = reinterpret_cast(GetProcAddress(dll, "gotoXY")); - printFunction = reinterpret_cast(GetProcAddress(dll, "print")); - - SetChangedWindowCallback setChangedWindowCallback = reinterpret_cast(GetProcAddress(dll, "setChangedWindowCallback")); - if (setChangedWindowCallback) - (*setChangedWindowCallback)(changedWindowCallback); - - DebugFlags::registerFlag(noClear, "SharedDebug", "noDebugMonitorClear"); - - if (ConfigFile::getKeyBool("SharedDebug", "debugWindow", false)) - show(); - } - else - { - installFunction = NULL; - const BOOL result = FreeLibrary(dll); - dll = NULL; - UNREF(result); - DEBUG_FATAL(!result, ("FreeLibrary failed")); - } - } -} - -// ---------------------------------------------------------------------- -/** - * Remove the debug monitor subsystem. - */ - -void DebugMonitor::remove() -{ - if (removeFunction) - removeFunction(); - - removeFunction = NULL; - setBehindWindowFunction = NULL; - clearScreenFunction = NULL; - clearToCursorFunction = NULL; - gotoXYFunction = NULL; - printFunction = NULL; - - if (dll) - { - const BOOL result = FreeLibrary(dll); - UNREF(result); - DEBUG_FATAL(!result, ("FreeLibrary failed")); - dll = NULL; - - if (registryKey != HKEY_CLASSES_ROOT) - { - RegCloseKey(registryKey); - registryKey = HKEY_CLASSES_ROOT; - } - } -} - -// ---------------------------------------------------------------------- - -void DebugMonitorNamespace::changedWindowCallback(int const x, int const y, int const width, int const height) -{ - SetRegistryValue("x", x); - SetRegistryValue("y", y); - SetRegistryValue("width", width); - SetRegistryValue("height", height); -} - -// ---------------------------------------------------------------------- - -void DebugMonitor::show() -{ - if (showFunction) - (*showFunction)(); -} - -// ---------------------------------------------------------------------- - -void DebugMonitor::hide() -{ - if (hideFunction) - (*hideFunction)(); -} - -// ---------------------------------------------------------------------- -/** - * Set the debug window's z-order. - */ - -void DebugMonitor::setBehindWindow(HWND window) -{ - if (setBehindWindowFunction) - setBehindWindowFunction(window); -} - -// ---------------------------------------------------------------------- -/** - * Clear the debug monitor and home the cursor. - * - * If the mono monitor is not installed, this routine does nothing. - * - * This routine will clear the contents of the debug monitor, reset the screen - * offset to 0, and move the cursor to the upper left corner of the screen. - * - * @see DebugMonitor::home(), DebugMonitor::clearToCursor() - */ - -void DebugMonitor::clearScreen() -{ - if (noClear) - return; - - if (clearScreenFunction) - clearScreenFunction(); -} - -// ---------------------------------------------------------------------- -/** - * Clear the debug monitor to the current cursor position and home the cursor. - * - * If the debug monitor is not installed, this routine does nothing. - * - * This routine will clear the contents of the debug monitor only up to the - * cursor position. If the cursor is not very far down on the screen, - * this routine may be significantly more efficient clearing the screen. - * - * It will also move the cursor to the upper left corner of the screen. - * - * @see DebugMonitor::clearScreen(), DebugMonitor::home() - */ - -void DebugMonitor::clearToCursor() -{ - if (clearToCursorFunction) - clearToCursorFunction(); - else - clearScreen(); -} - -// ====================================================================== -// Move the cursor to the upper left hand corner of the mono monitor screen -// -// Remarks: -// -// If the debug monitor is not installed, this routine does nothing. -// -// All printing happens at the cursor position. -// -// This routine is identical to calling gotoXY(0,0); -// -// See Also: -// -// DebugMonitor::gotoXY() - -void DebugMonitor::home() -{ - gotoXY(0,0); -} - -// ---------------------------------------------------------------------- -/** - * Position the cursor on the debug monitor screen. - * - * If the debug monitor is not installed, this routine does nothing. - * - * All printing happens at the cursor position. - * - * @param x New X position for the cursor - * @param y New Y position for the cursor - */ - -void DebugMonitor::gotoXY(int x, int y) -{ - if (gotoXYFunction) - gotoXYFunction(x, y); -} - -// ---------------------------------------------------------------------- -/** - * Display a string on the debug monitor. - * - * If the debug monitor is not installed, this routine does nothing. - * - * Printing occurs from the cursor position. - * - * Newline characters '\n' will cause the cursor position to advance to the - * beginning of the next line. If the cursor is already on the last line of - * the screen, the screen will scroll up one line and the cursor will move to - * the beginning of the last line. - * - * The backspace character '\b' will cause the cursor to move one character - * backwards. If at the beginning of the line, the cursor will move to the - * end of the previous line. If already on the first line of the screen, the - * cursor position and screen contents will be unchanged. - * - * All other characters are placed directly into the text frame buffer. - * After each character, the cursor will be logically advanced one - * character forward. If the cursor was on the last column, it will advance - * to the next line. If the cursor was already on the last line, the screen - * will be scrolled up one line and the cursor will move to the beginning of - * the last line. - * - * @param string String to display on the debug monitor - */ - -void DebugMonitor::print(const char *string) -{ - if (printFunction) - printFunction(string); -} - -// ---------------------------------------------------------------------- -/** - * Ensure all changes to the DebugMonitor have taken effect by the time - * this function returns. - * - * Note: some platforms may do nothing here. The Win32 platform does not - * require flushing. The Linux platform does. Call it assuming - * that it is needed. It will be a no-op when not required. - */ - -void DebugMonitor::flushOutput() -{ - // Win32 debug monitors don't need to do anything here. -} - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedDebug/src/win32/DebugMonitor.h b/engine/shared/library/sharedDebug/src/win32/DebugMonitor.h deleted file mode 100755 index c992ed11..00000000 --- a/engine/shared/library/sharedDebug/src/win32/DebugMonitor.h +++ /dev/null @@ -1,48 +0,0 @@ -// ====================================================================== -// -// DebugMonitor.h -// -// Portions copyright 1998 Bootprint Entertainment -// Portions copyright 2002-2004 Sony Online Entertainment -// All Rights Reserved. -// -// ====================================================================== - -#ifndef INCLUDED_DebugMonitor_H -#define INCLUDED_DebugMonitor_H - -// ====================================================================== - -#include "sharedFoundation/Production.h" - -// ====================================================================== - -#if PRODUCTION == 0 - -class DebugMonitor -{ -public: - - static void install(); - static void remove(); - - static void setBehindWindow(HWND window); - - static void show(); - static void hide(); - - static void clearScreen(); - static void clearToCursor(); - - static void home(); - static void gotoXY(int x, int y); - static void print(const char *string); - - static void flushOutput(); -}; - -#endif - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedDebug/src/win32/FirstSharedDebug.cpp b/engine/shared/library/sharedDebug/src/win32/FirstSharedDebug.cpp deleted file mode 100755 index ee53a32e..00000000 --- a/engine/shared/library/sharedDebug/src/win32/FirstSharedDebug.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstDebug.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "shareddebug/FirstSharedDebug.h" diff --git a/engine/shared/library/sharedDebug/src/win32/PerformanceTimer.cpp b/engine/shared/library/sharedDebug/src/win32/PerformanceTimer.cpp deleted file mode 100755 index be770b7f..00000000 --- a/engine/shared/library/sharedDebug/src/win32/PerformanceTimer.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// -// PerformanceTimer.cpp -// Copyright 2000-2004 Sony Online Entertainment -// - -//------------------------------------------------------------------- - -#include "shareddebug/FirstSharedDebug.h" -#include "shareddebug/PerformanceTimer.h" - -//------------------------------------------------------------------- - -#include - -//------------------------------------------------------------------- - -__int64 PerformanceTimer::ms_frequency; - -//------------------------------------------------------------------- - -void PerformanceTimer::install() -{ - BOOL result = QueryPerformanceFrequency(reinterpret_cast(&ms_frequency)); - FATAL(!result, ("PerformanceTimer::install QPF failed")); -} - -//------------------------------------------------------------------- - -PerformanceTimer::PerformanceTimer() : - m_startTime (0), - m_stopTime (0) -{ - DEBUG_FATAL (ms_frequency == 0.f, ("PerformanceTimer not installed")); -} - -//------------------------------------------------------------------- - -PerformanceTimer::~PerformanceTimer() -{ -} - -//------------------------------------------------------------------- - -void PerformanceTimer::start() -{ - //-- get the current time - BOOL result = QueryPerformanceCounter(reinterpret_cast(&m_startTime)); - DEBUG_FATAL(!result, ("PerformanceTimer::start QPC failed")); - UNREF (result); -} - -//------------------------------------------------------------------- - -void PerformanceTimer::resume() -{ - __int64 delta = m_stopTime - m_startTime; - start(); - m_startTime -= delta; -} - -//------------------------------------------------------------------- - -void PerformanceTimer::stop () -{ - //-- get the current time - BOOL result = QueryPerformanceCounter(reinterpret_cast(&m_stopTime)); - DEBUG_FATAL(!result, ("PerformanceTimer::stop QPC failed")); - UNREF (result); -} - -//------------------------------------------------------------------- - -float PerformanceTimer::getElapsedTime() const -{ - return static_cast (m_stopTime - m_startTime) / static_cast (ms_frequency); -} - -// ---------------------------------------------------------------------- - -float PerformanceTimer::getSplitTime() const -{ - __int64 currentTime; - BOOL result = QueryPerformanceCounter(reinterpret_cast(¤tTime)); - UNREF(result); - DEBUG_FATAL(!result, ("PerformanceTimer::getSplitTime QPC failed")); - - return static_cast (currentTime - m_startTime) / static_cast (ms_frequency); -} - -//------------------------------------------------------------------- - -void PerformanceTimer::logElapsedTime(const char* string) const -{ - UNREF (string); - -#ifdef _DEBUG - static char buffer [1000]; - sprintf (buffer, "%s : %1.5f seconds\n", string ? string : "null", getElapsedTime()); - DEBUG_REPORT_LOG_PRINT (true, ("%s", buffer)); - DEBUG_OUTPUT_CHANNEL("Foundation\\PerformanceTimer", ("%s", buffer)); -#endif -} - -//------------------------------------------------------------------- - diff --git a/engine/shared/library/sharedDebug/src/win32/PerformanceTimer.h b/engine/shared/library/sharedDebug/src/win32/PerformanceTimer.h deleted file mode 100755 index 0fda7c1a..00000000 --- a/engine/shared/library/sharedDebug/src/win32/PerformanceTimer.h +++ /dev/null @@ -1,49 +0,0 @@ -// -// PerformanceTimer.h -// Copyright 2000-2004 Sony Online Entertainment -// - -//------------------------------------------------------------------- - -#ifndef INCLUDED_PerformanceTimer_H -#define INCLUDED_PerformanceTimer_H - -//------------------------------------------------------------------- - -class PerformanceTimer -{ -public: - - static void install(); - -public: - - DLLEXPORT PerformanceTimer(); - DLLEXPORT ~PerformanceTimer(); - - void DLLEXPORT start(); - void DLLEXPORT resume(); - void DLLEXPORT stop(); - - float DLLEXPORT getElapsedTime() const; - float getSplitTime() const; // Get the time since the timer was started without stopping the timer. - void logElapsedTime(const char* string) const; - -private: - - PerformanceTimer(PerformanceTimer const &); - PerformanceTimer & operator=(PerformanceTimer const &); - -private: - - static __int64 ms_frequency; - -private: - - __int64 m_startTime; - __int64 m_stopTime; -}; - -//------------------------------------------------------------------- - -#endif \ No newline at end of file diff --git a/engine/shared/library/sharedDebug/src/win32/ProfilerTimer.cpp b/engine/shared/library/sharedDebug/src/win32/ProfilerTimer.cpp deleted file mode 100755 index 774765a6..00000000 --- a/engine/shared/library/sharedDebug/src/win32/ProfilerTimer.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// ====================================================================== -// -// ProfilerTimer.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "shareddebug/FirstSharedDebug.h" -#include "shareddebug/ProfilerTimer.h" - -#include "shareddebug/DebugFlags.h" -#include "sharedFoundation/WindowsWrapper.h" - -// ====================================================================== - -namespace ProfilerTimerNamespace -{ - ProfilerTimer::Type ms_qpcFrequency; - float ms_floatQpcFrequency; - __int64 ms_rdtsc; - __int64 ms_qpc; - bool ms_useRdtsc; - -} -using namespace ProfilerTimerNamespace; - -// ====================================================================== - -static __int64 __declspec(naked) __stdcall readTimeStampCounter() -{ - __asm - { - rdtsc; - ret; - } -} - -// ====================================================================== - -void ProfilerTimer::install() -{ - IGNORE_RETURN(QueryPerformanceCounter(reinterpret_cast(&ms_qpc))); - ms_rdtsc = readTimeStampCounter(); - - IGNORE_RETURN(QueryPerformanceFrequency(reinterpret_cast(&ms_qpcFrequency))); - ms_floatQpcFrequency = static_cast(ms_qpcFrequency); - - DebugFlags::registerFlag(ms_useRdtsc, "SharedDebug/Profiler", "useRdtsc"); -} - -// ---------------------------------------------------------------------- - -void ProfilerTimer::getTime(Type &time) -{ - if (ms_useRdtsc) - time = readTimeStampCounter(); - else - IGNORE_RETURN(QueryPerformanceCounter(reinterpret_cast(&time))); -} - -// ---------------------------------------------------------------------- - -void ProfilerTimer::getCalibratedTime(Type &time, Type &frequency) -{ - if (ms_useRdtsc) - { - __int64 qpc; - IGNORE_RETURN(QueryPerformanceCounter(reinterpret_cast(&qpc))); - __int64 rdtsc = readTimeStampCounter(); - - float const t = static_cast(qpc - ms_qpc) / ms_floatQpcFrequency; - frequency = static_cast<__int64>(static_cast(rdtsc - ms_rdtsc) / t); - - time = rdtsc; - ms_qpc = qpc; - ms_rdtsc = time; - } - else - { - IGNORE_RETURN(QueryPerformanceCounter(reinterpret_cast(&time))); - frequency = ms_qpcFrequency; - } -} - -void ProfilerTimer::getFrequency(Type &frequency) -{ - frequency = ms_qpcFrequency; -} - -// ====================================================================== diff --git a/engine/shared/library/sharedDebug/src/win32/ProfilerTimer.h b/engine/shared/library/sharedDebug/src/win32/ProfilerTimer.h deleted file mode 100755 index fe1b8f9a..00000000 --- a/engine/shared/library/sharedDebug/src/win32/ProfilerTimer.h +++ /dev/null @@ -1,29 +0,0 @@ -// ====================================================================== -// -// ProfilerTimer.h -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_ProfilerTimer_H -#define INCLUDED_ProfilerTimer_H - -// ====================================================================== - -class ProfilerTimer -{ -public: - - typedef __int64 Type; - -public: - - static void install(); - static void getTime(Type &time); - static void getCalibratedTime(Type &time, Type &frequency); - static void getFrequency(Type &frequency); -}; - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedDebug/src/win32/VTune.cpp b/engine/shared/library/sharedDebug/src/win32/VTune.cpp deleted file mode 100755 index 6b876fff..00000000 --- a/engine/shared/library/sharedDebug/src/win32/VTune.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// ====================================================================== -// -// VTune.cpp -// Copyright 2000-01, Sony Online Entertainment Inc. -// All Rights Reserved. -// -// ====================================================================== - -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedDebug/VTune.h" - -#if PRODUCTION == 0 - -#include "sharedDebug/DebugFlags.h" - -#include - -// ====================================================================== - -HMODULE VTune::ms_module; -VTune::PauseFunction VTune::ms_pauseFunction; -VTune::ResumeFunction VTune::ms_resumeFunction; -VTune::State VTune::ms_state; -bool VTune::ms_resumeNextFrame; -bool VTune::ms_pauseNextFrame; -bool VTune::ms_debugReport; - -// ====================================================================== - -void VTune::install() -{ - DEBUG_FATAL(ms_module, ("vtune already installed")); - - ms_module = LoadLibrary("VTuneAPI"); - if (!ms_module) - return; - - ms_pauseFunction = reinterpret_cast(GetProcAddress(ms_module, "VTPause")); - ms_resumeFunction = reinterpret_cast(GetProcAddress(ms_module, "VTResume")); - ms_state = S_default; - -#if PRODUCTION == 0 - DebugFlags::registerFlag(ms_debugReport, "SharedDebug", "vtuneState", debugReport); -#endif -} - -// ---------------------------------------------------------------------- - -void VTune::remove() -{ - if (ms_module) - { - FreeLibrary(ms_module); - ms_pauseFunction = 0; - ms_resumeFunction = 0; - } -} - -// ---------------------------------------------------------------------- - -void VTune::debugReport() -{ - switch (ms_state) - { - case S_default: - REPORT_PRINT(true, ("Vtune state unknown\n")); - break; - - case S_sampling: - REPORT_PRINT(true, ("Vtune is sampling\n")); - break; - - case S_paused: - REPORT_PRINT(true, ("Vtune is NOT sampling\n")); - break; - - default: - DEBUG_FATAL(true, ("bad case")); - - } -} - -// ---------------------------------------------------------------------- - -void VTune::resume() -{ - if (ms_module && ms_resumeFunction) - { - MessageBeep(MB_OK); - (*ms_resumeFunction)(); - ms_state = S_sampling; - } -} - -// ---------------------------------------------------------------------- - -void VTune::pause() -{ - if (ms_module && ms_pauseFunction) - { - (*ms_pauseFunction)(); - MessageBeep(MB_ICONEXCLAMATION); - ms_state = S_paused; - } -} - -// ---------------------------------------------------------------------- - -void VTune::pauseNextFrame() -{ - ms_pauseNextFrame = true; - ms_resumeNextFrame = false; -} - -// ---------------------------------------------------------------------- - -void VTune::resumeNextFrame() -{ - ms_pauseNextFrame = false; - ms_resumeNextFrame = true; -} - -// ---------------------------------------------------------------------- - -void VTune::beginFrame() -{ - if (ms_pauseNextFrame) - { - pause(); - ms_pauseNextFrame = false; - } - - if (ms_resumeNextFrame) - { - resume(); - ms_resumeNextFrame = false; - } -} - -// ====================================================================== - -#endif // PRODUCTION == 0 diff --git a/engine/shared/library/sharedDebug/src/win32/VTune.h b/engine/shared/library/sharedDebug/src/win32/VTune.h deleted file mode 100755 index 31125646..00000000 --- a/engine/shared/library/sharedDebug/src/win32/VTune.h +++ /dev/null @@ -1,65 +0,0 @@ -// ====================================================================== -// -// VTune.h -// Copyright 2000-01, Sony Online Entertainment Inc. -// All Rights Reserved. -// -// ====================================================================== - -#ifndef INCLUDED_VTune_H -#define INCLUDED_VTune_H - -// ====================================================================== - -#include "sharedFoundation/Production.h" - -// ====================================================================== - -#if PRODUCTION == 0 - -class VTune -{ -public: - - static void install(); - - static void resume(); - static void pause(); - - static void resumeNextFrame(); - static void pauseNextFrame(); - static void beginFrame(); - -private: - - static void remove(); - static void debugReport(); - -private: - - enum State - { - S_default, - S_sampling, - S_paused - }; - - typedef void (__cdecl *PauseFunction)(void); - typedef void (__cdecl *ResumeFunction)(void); - -private: - - static HMODULE ms_module; - static PauseFunction ms_pauseFunction; - static ResumeFunction ms_resumeFunction; - static State ms_state; - static bool ms_resumeNextFrame; - static bool ms_pauseNextFrame; - static bool ms_debugReport; -}; - -#endif // PRODUCTION == 0 - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFile/src/win32/FirstSharedFile.cpp b/engine/shared/library/sharedFile/src/win32/FirstSharedFile.cpp deleted file mode 100755 index 038a7931..00000000 --- a/engine/shared/library/sharedFile/src/win32/FirstSharedFile.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstFile.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFile/FirstSharedFile.h" diff --git a/engine/shared/library/sharedFile/src/win32/OsFile.cpp b/engine/shared/library/sharedFile/src/win32/OsFile.cpp deleted file mode 100755 index 64acc1a7..00000000 --- a/engine/shared/library/sharedFile/src/win32/OsFile.cpp +++ /dev/null @@ -1,195 +0,0 @@ -// ====================================================================== -// -// OsFile.cpp -// Copyright 2002, Sony Online Entertainment Inc. -// All Rights Reserved. -// -// ====================================================================== - -#include "sharedFile/FirstSharedFile.h" -#include "sharedFile/OsFile.h" - -#ifdef _DEBUG -#include "sharedDebug/PerformanceTimer.h" -#endif - -namespace OsFileNamespace -{ - float ms_time; -} -using namespace OsFileNamespace; - -// ====================================================================== - -void OsFile::install() -{ - -} - -// ---------------------------------------------------------------------- - -float OsFile::getSpentTime() -{ - float const result = ms_time; - ms_time = 0.0f; - return result; -} - -// ---------------------------------------------------------------------- - -bool OsFile::exists(const char *fileName) -{ - NOT_NULL(fileName); - DWORD attributes = GetFileAttributes(fileName); - -#if _MSC_VER < 1300 - const DWORD INVALID_FILE_ATTRIBUTES = 0xffffffff; -#endif - return (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY) == 0); -} - -// ---------------------------------------------------------------------- - -int OsFile::getFileSize(const char *fileName) -{ - NOT_NULL(fileName); - -#ifdef _DEBUG - PerformanceTimer t; - t.start(); -#endif - - HANDLE handle = CreateFile(fileName, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (handle == INVALID_HANDLE_VALUE) - return -1; - - int const size = GetFileSize(handle, NULL); - CloseHandle(handle); - -#ifdef _DEBUG - t.stop(); - ms_time += t.getElapsedTime(); -#endif - return size; -} - -// ---------------------------------------------------------------------- - -OsFile *OsFile::open(const char *fileName, bool randomAccess) -{ -#ifdef _DEBUG - PerformanceTimer t; - t.start(); -#endif - - // attempt to open the file - HANDLE handle = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | (randomAccess ? FILE_FLAG_RANDOM_ACCESS : 0), NULL); - - // check to make sure the file opened sucessfully - if (handle == INVALID_HANDLE_VALUE) - return NULL; - -#ifdef _DEBUG - t.stop(); - ms_time += t.getElapsedTime(); -#endif - - return new OsFile(handle); -} - -// ---------------------------------------------------------------------- - -OsFile::OsFile(HANDLE handle) -: m_handle(handle), - m_offset(0) -{ -} - -// ---------------------------------------------------------------------- - -OsFile::~OsFile() -{ -#ifdef _DEBUG - PerformanceTimer t; - t.start(); -#endif - - CloseHandle(m_handle); - -#ifdef _DEBUG - t.stop(); - ms_time+= t.getElapsedTime(); -#endif -} - -// ---------------------------------------------------------------------- - -int OsFile::length() const -{ - return GetFileSize(m_handle, NULL); -} - -// ---------------------------------------------------------------------- - -void OsFile::seek(int newFilePosition) -{ -#ifdef _DEBUG - PerformanceTimer t; - t.start(); -#endif - - if (m_offset != newFilePosition) - { - const DWORD result = SetFilePointer(m_handle, newFilePosition, NULL, FILE_BEGIN); - DEBUG_FATAL(static_cast(result) != newFilePosition, ("SetFilePointer failed")); - UNREF(result); - m_offset = newFilePosition; - } - -#ifdef _DEBUG - t.stop(); - ms_time += t.getElapsedTime(); -#endif -} - -// ---------------------------------------------------------------------- - -int OsFile::read(void *destinationBuffer, int numberOfBytes) -{ -#ifdef _DEBUG - PerformanceTimer t; - t.start(); -#endif - - DWORD amountReadDword; - BOOL result = ReadFile(m_handle, destinationBuffer, static_cast(numberOfBytes), &amountReadDword, NULL); - -// miles crasher hack -#if 0 - FATAL(!result, ("FileStreamerThread::processRead ReadFile failed to read '%d' bytes with error '%d'", static_cast(numberOfBytes), GetLastError())); -#else - if(!result) - { - if(GetLastError() == 998) // access violation - buffer coming from miles hosed - { - WARNING(true,("FileStreamerThread::processRead ReadFile failed to read '%d' bytes with error '%d'", static_cast(numberOfBytes), GetLastError())); - return 0; - } - else - { - FATAL(true, ("FileStreamerThread::processRead ReadFile failed to read '%d' bytes with error '%d'", static_cast(numberOfBytes), GetLastError())); - } - } -#endif -// end miles crasher hack - -#ifdef _DEBUG - t.stop(); - ms_time += t.getElapsedTime(); -#endif - - m_offset += static_cast(amountReadDword); - return static_cast(amountReadDword); -} - -// ====================================================================== diff --git a/engine/shared/library/sharedFile/src/win32/OsFile.h b/engine/shared/library/sharedFile/src/win32/OsFile.h deleted file mode 100755 index 1f3e6ba9..00000000 --- a/engine/shared/library/sharedFile/src/win32/OsFile.h +++ /dev/null @@ -1,48 +0,0 @@ -// ====================================================================== -// -// OsFile.h -// Copyright 2002, Sony Online Entertainment Inc. -// All Rights Reserved. -// -// ====================================================================== - -#ifndef INCLUDED_OsFile_H -#define INCLUDED_OsFile_H - -// ====================================================================== - -class OsFile -{ -public: - - static void install(); - - static float getSpentTime(); - - static bool exists(const char *fileName); - static int getFileSize(const char *fileName); - static OsFile *open(const char *fileName, bool randomAccess=false); - -public: - - ~OsFile(); - - int length() const; - int tell() const; - void seek(int newFilePosition); - int read(void *destinationBuffer, int numberOfBytes); - -private: - - OsFile(HANDLE handle); - OsFile(const char *fileName); - -private: - - HANDLE m_handle; - int m_offset; -}; - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFoundation/src/win32/ByteOrder.cpp b/engine/shared/library/sharedFoundation/src/win32/ByteOrder.cpp deleted file mode 100755 index 12add8e5..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/ByteOrder.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// ====================================================================== -// -// ByteOrder.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/ByteOrder.h" - -// ====================================================================== - -// I'm using the arguments, but the compiler can't tell that -#pragma warning(disable: 4100) - -__declspec(naked) ulong ntohl(ulong netLong) -{ - _asm - { - mov eax, [esp+4] - bswap eax - ret - } -} //lint !e533 !e715 // function should return a value, argument not referenced - -__declspec(naked) ulong htonl(ulong hostLong) -{ - _asm - { - mov eax, [esp+4] - bswap eax - ret - } -} //lint !e533 !e715 // function should return a value, argument not referenced - -__declspec(naked) ushort ntohs(ushort netShort) -{ - _asm - { - mov eax, [esp+4] - bswap eax - shr eax, 16 - ret - } -} //lint !e533 !e715 // function should return a value, argument not referenced - -__declspec(naked) ushort htons(ushort hostShort) -{ - _asm - { - mov eax, [esp+4] - bswap eax - shr eax, 16 - ret - } -} //lint !e533 !e715 // function should return a value, argument not referenced - -// ====================================================================== diff --git a/engine/shared/library/sharedFoundation/src/win32/ByteOrder.h b/engine/shared/library/sharedFoundation/src/win32/ByteOrder.h deleted file mode 100755 index 4e478703..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/ByteOrder.h +++ /dev/null @@ -1,22 +0,0 @@ -// ====================================================================== -// -// ByteOrder.h -// copyright 1998 Bootprint Entertainment -// copyright 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef BYTE_ORDER_H -#define BYTE_ORDER_H - -// ====================================================================== - -ulong __cdecl ntohl(ulong netLong); -ushort __cdecl ntohs(ushort netShort); - -ulong __cdecl htonl(ulong hostLong); -ushort __cdecl htons(ushort hostShort); - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFoundation/src/win32/ConfigSharedFoundation.cpp b/engine/shared/library/sharedFoundation/src/win32/ConfigSharedFoundation.cpp deleted file mode 100755 index 9498c256..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/ConfigSharedFoundation.cpp +++ /dev/null @@ -1,324 +0,0 @@ -// ====================================================================== -// -// ConfigSharedFoundation.cpp -// copyright 1998 Bootprint Entertainment -// copyright 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/ConfigSharedFoundation.h" - -#include "sharedFoundation/ConfigFile.h" -#include "sharedFoundation/Production.h" - -// ====================================================================== - -#define KEY_INT(a,b) (ms_ ## a = ConfigFile::getKeyInt("SharedFoundation", #a, b)) -#define KEY_BOOL(a,b) (ms_ ## a = ConfigFile::getKeyBool("SharedFoundation", #a, b)) -#define KEY_FLOAT(a,b) (ms_ ## a = ConfigFile::getKeyFloat("SharedFoundation", #a, b)) -#define KEY_STRING(a,b) (ms_ ## a = ConfigFile::getKeyString("SharedFoundation", #a, b)) - -// ====================================================================== - -const int c_defaultFatalCallStackDepth = 32; -const int c_defaultWarningCallStackDepth = PRODUCTION ? -1 : 8; - -// ====================================================================== - -namespace ConfigSharedFoundationNamespace -{ - bool ms_noExceptionHandling; - - bool ms_fpuExceptionPrecision; - bool ms_fpuExceptionUnderflow; - bool ms_fpuExceptionOverflow; - bool ms_fpuExceptionZeroDivide; - bool ms_fpuExceptionDenormal; - bool ms_fpuExceptionInvalid; - - bool ms_demoMode; - - real ms_frameRateLimit; - real ms_minFrameRate; - - bool ms_useRemoteDebug; - int ms_defaultRemoteDebugPort; - - bool ms_profilerExpandAllBranches; - - bool ms_memoryManagerReportAllocations; - bool ms_memoryManagerReportOnOutOfMemory; - - bool ms_useMemoryBlockManager; - bool ms_memoryBlockManagerDebugDumpOnRemove; - - int ms_fatalCallStackDepth; - int ms_warningCallStackDepth; - bool ms_lookUpCallStackNames; - - int ms_processPriority; - - bool ms_verboseHardwareLogging; - bool ms_verboseWarnings; - - bool ms_causeAccessViolation; - - float ms_debugReportLongFrameTime; -} - -using namespace ConfigSharedFoundationNamespace; - -// ====================================================================== -// Determine the Platform-specific configuration information -// -// Remarks: -// -// This routine inspects the ConfigFile class to set some variables for rapid access -// by the rest of the engine. - -void ConfigSharedFoundation::install (const Defaults &defaults) -{ - KEY_BOOL(noExceptionHandling, false); - - KEY_BOOL(fpuExceptionPrecision, false); - KEY_BOOL(fpuExceptionUnderflow, false); - KEY_BOOL(fpuExceptionOverflow, false); - KEY_BOOL(fpuExceptionZeroDivide, false); - KEY_BOOL(fpuExceptionDenormal, false); - KEY_BOOL(fpuExceptionInvalid, false); - - KEY_BOOL(demoMode, defaults.demoMode); - -#if defined (WIN32) && PRODUCTION == 1 - // In production builds, force our frame rate limit to be the application defined limit - ms_frameRateLimit = defaults.frameRateLimit; -#else - KEY_FLOAT(frameRateLimit, defaults.frameRateLimit); -#endif - - KEY_FLOAT(minFrameRate, 1.0f); - - KEY_BOOL(useRemoteDebug, false); - KEY_INT(defaultRemoteDebugPort, 4445); - - KEY_BOOL(profilerExpandAllBranches, false); - KEY_BOOL(memoryManagerReportAllocations, true); - KEY_BOOL(memoryManagerReportOnOutOfMemory, true); - KEY_BOOL(useMemoryBlockManager, true); - KEY_BOOL(memoryBlockManagerDebugDumpOnRemove, false); - - KEY_INT(fatalCallStackDepth, c_defaultFatalCallStackDepth); - KEY_INT(warningCallStackDepth, PRODUCTION ? -1 : c_defaultWarningCallStackDepth); - KEY_BOOL(lookUpCallStackNames, true); - - KEY_INT(processPriority, 0); - - KEY_BOOL(verboseHardwareLogging, false); - KEY_BOOL(verboseWarnings, defaults.verboseWarnings); - - KEY_BOOL(causeAccessViolation, false); - - KEY_FLOAT(debugReportLongFrameTime, 0.25f); -} - -// ---------------------------------------------------------------------- -/** - * Return whether to run with exception handling enabled. - * - * @return True to run without exception handling - */ - -bool ConfigSharedFoundation::getNoExceptionHandling() -{ - return ms_noExceptionHandling; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getFpuExceptionPrecision() -{ - return ms_fpuExceptionPrecision; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getFpuExceptionUnderflow() -{ - return ms_fpuExceptionUnderflow; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getFpuExceptionOverflow() -{ - return ms_fpuExceptionOverflow; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getFpuExceptionZeroDivide() -{ - return ms_fpuExceptionZeroDivide; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getFpuExceptionDenormal() -{ - return ms_fpuExceptionDenormal; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getFpuExceptionInvalid() -{ - return ms_fpuExceptionInvalid; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getDemoMode() -{ - return ms_demoMode; -} - -// ---------------------------------------------------------------------- -/** - * Return the frame rate limit value for the game. - * - * @return The initial frame rate limiter value - */ - -real ConfigSharedFoundation::getFrameRateLimit() -{ - return ms_frameRateLimit; -} - -// ---------------------------------------------------------------------- -/** - * Return the minimum frame rate value for the game. Frames that take longer - * will log a warning and be hard set to the given value. - * - * @return The initial min frame rate value - */ - -real ConfigSharedFoundation::getMinFrameRate() -{ - return ms_minFrameRate; -} - -// ---------------------------------------------------------------------- - -int ConfigSharedFoundation::getDefaultRemoteDebugPort() -{ - return ms_defaultRemoteDebugPort; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getUseRemoteDebug() -{ - return ms_useRemoteDebug; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getProfilerExpandAllBranches() -{ - return ms_profilerExpandAllBranches; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getMemoryManagerReportAllocations() -{ - return ms_memoryManagerReportAllocations; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getMemoryManagerReportOnOutOfMemory() -{ - return ms_memoryManagerReportOnOutOfMemory; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getUseMemoryBlockManager() -{ - return ms_useMemoryBlockManager; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getMemoryBlockManagerDebugDumpOnRemove () -{ - return ms_memoryBlockManagerDebugDumpOnRemove; -} - -// ---------------------------------------------------------------------- - -int ConfigSharedFoundation::getFatalCallStackDepth() -{ - return ms_fatalCallStackDepth; -} - -// ---------------------------------------------------------------------- - -int ConfigSharedFoundation::getWarningCallStackDepth() -{ - return ms_warningCallStackDepth; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getLookUpCallStackNames() -{ - return ms_lookUpCallStackNames; -} - -// ---------------------------------------------------------------------- - -int ConfigSharedFoundation::getProcessPriority() -{ - return ms_processPriority; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getVerboseHardwareLogging() -{ - return ms_verboseHardwareLogging; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getVerboseWarnings() -{ - return ms_verboseWarnings; -} - -// ---------------------------------------------------------------------- - -void ConfigSharedFoundation::setVerboseWarnings(bool const verboseWarnings) -{ - ms_verboseWarnings = verboseWarnings; -} - -// ---------------------------------------------------------------------- - -bool ConfigSharedFoundation::getCauseAccessViolation() -{ - return ms_causeAccessViolation; -} - - -// ---------------------------------------------------------------------- - -float ConfigSharedFoundation::getDebugReportLongFrameTime() -{ - return ms_debugReportLongFrameTime; -} - -// ====================================================================== diff --git a/engine/shared/library/sharedFoundation/src/win32/ConfigSharedFoundation.h b/engine/shared/library/sharedFoundation/src/win32/ConfigSharedFoundation.h deleted file mode 100755 index 6efa3840..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/ConfigSharedFoundation.h +++ /dev/null @@ -1,74 +0,0 @@ -// ====================================================================== -// -// ConfigSharedFoundation.h -// copyright 1998 Bootprint Entertainment -// copyright 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_ConfigSharedFoundation_H -#define INCLUDED_ConfigSharedFoundation_H - -// ====================================================================== - -class ConfigSharedFoundation -{ -public: - - struct Defaults - { - int screenHeight; - int screenWidth; - bool windowed; - real frameRateLimit; - bool demoMode; - bool verboseWarnings; - }; - -public: - - static void install(const Defaults &defaults); - - static bool getNoExceptionHandling(); - - static bool getFpuExceptionPrecision(); - static bool getFpuExceptionUnderflow(); - static bool getFpuExceptionOverflow(); - static bool getFpuExceptionZeroDivide(); - static bool getFpuExceptionDenormal(); - static bool getFpuExceptionInvalid(); - - static bool getDemoMode(); - - static real getFrameRateLimit(); - static real getMinFrameRate(); - - static bool getUseRemoteDebug(); - static int getDefaultRemoteDebugPort(); - - static bool getProfilerExpandAllBranches(); - - static bool getMemoryManagerReportAllocations(); - static bool getMemoryManagerReportOnOutOfMemory(); - - static bool getUseMemoryBlockManager(); - static bool getMemoryBlockManagerDebugDumpOnRemove(); - - static int getFatalCallStackDepth(); - static int getWarningCallStackDepth(); - static bool getLookUpCallStackNames(); - - static int getProcessPriority(); - - static DLLEXPORT bool getVerboseHardwareLogging(); - static bool getVerboseWarnings(); - static void setVerboseWarnings(bool verboseWarnings); - - static bool getCauseAccessViolation(); - - static float getDebugReportLongFrameTime(); -}; - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFoundation/src/win32/FirstPlatform.h b/engine/shared/library/sharedFoundation/src/win32/FirstPlatform.h deleted file mode 100755 index 5a4d021a..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/FirstPlatform.h +++ /dev/null @@ -1,82 +0,0 @@ -// ====================================================================== -// -// FirstPlatform.h -// copyright 1998 Bootprint Entertainment -// copyright 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_FirstPlatform_H -#define INCLUDED_FirstPlatform_H - - -#ifdef WIN32 -#include -#include -#endif - -// ====================================================================== - -// C4127 conditional expression is constant -// C4291 no matching operator delete found; memory will not be freed if initialization throws an exception -// C4503 decorated name length exceeded, name was truncated -// C4514 unreferenced inline function has been removed -// C4702 unreachable code -// C4710 inline function not expanded -// C4786 identifier was truncated to 'number' characters in the debug - -#pragma warning(disable: 4127 4291 4503 4514 4702 4710 4786) - -// ====================================================================== -// If we haven't defined this yet, then we're not compiling a DLL - -#ifndef COMPILE_DLL -#define COMPILE_DLL 0 -#endif - -#if COMPILE_DLL -#define DLLEXPORT __declspec(dllimport) -#else -#define DLLEXPORT __declspec(dllexport) -#endif - -// ====================================================================== - -template -inline int ComGetReferenceCount(T *t) -{ - t->AddRef(); - return t->Release(); -} - -// ====================================================================== -// forward declare some windows stuff to avoid having to include here - -struct HCURSOR__; -struct HICON__; -struct HINSTANCE__; -struct HWND__; - -typedef void *HANDLE; -typedef HICON__ *HCURSOR; -typedef HICON__ *HICON; -typedef HINSTANCE__ *HINSTANCE; -typedef HWND__ *HWND; - -// @todo codereorg still working on this -#include "sharedFoundation/WindowsWrapper.h" - -// ====================================================================== -// convienent fatal macros that check windows HRESULT codes - -#define FATAL_HR(a,b) FATAL(FAILED(b), (a, HRESULT_CODE(b))) -#define DEBUG_FATAL_HR(a,b) DEBUG_FATAL(FAILED(b), (a, HRESULT_CODE(b))) - -// ====================================================================== -// include anything we need to replace missing functionality that other platforms provide - -#include "sharedFoundation/PlatformGlue.h" - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFoundation/src/win32/FirstSharedFoundation.cpp b/engine/shared/library/sharedFoundation/src/win32/FirstSharedFoundation.cpp deleted file mode 100755 index 1cfb9020..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/FirstSharedFoundation.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstFoundation.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" diff --git a/engine/shared/library/sharedFoundation/src/win32/FloatingPointUnit.cpp b/engine/shared/library/sharedFoundation/src/win32/FloatingPointUnit.cpp deleted file mode 100755 index f303e0eb..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/FloatingPointUnit.cpp +++ /dev/null @@ -1,257 +0,0 @@ -// ====================================================================== -// -// FloatingPointUnit.cpp -// copyright 1999 Bootprint Entertainment -// copyright 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/FloatingPointUnit.h" - -#include "sharedFoundation/ConfigSharedFoundation.h" - -// ====================================================================== - -int FloatingPointUnit::updateNumber; -ushort FloatingPointUnit::status; -FloatingPointUnit::Precision FloatingPointUnit::precision; -FloatingPointUnit::Rounding FloatingPointUnit::rounding; -bool FloatingPointUnit::exceptionEnabled[E_max]; - -// ====================================================================== - -const WORD PRECISION_MASK = BINARY4(0000,0011,0000,0000); -const WORD PRECISION_24 = BINARY4(0000,0000,0000,0000); -const WORD PRECISION_53 = BINARY4(0000,0010,0000,0000); -const WORD PRECISION_64 = BINARY4(0000,0011,0000,0000); - -const WORD ROUND_MASK = BINARY4(0000,1100,0000,0000); -const WORD ROUND_NEAREST = BINARY4(0000,0000,0000,0000); -const WORD ROUND_CHOP = BINARY4(0000,1100,0000,0000); -const WORD ROUND_DOWN = BINARY4(0000,0100,0000,0000); -const WORD ROUND_UP = BINARY4(0000,1000,0000,0000); - -const WORD EXCEPTION_PRECISION = BINARY4(0000,0000,0010,0000); -const WORD EXCEPTION_UNDERFLOW = BINARY4(0000,0000,0001,0000); -const WORD EXCEPTION_OVERFLOW = BINARY4(0000,0000,0000,1000); -const WORD EXCEPTION_ZERO_DIVIDE = BINARY4(0000,0000,0000,0100); -const WORD EXCEPTION_DENORMAL = BINARY4(0000,0000,0000,0010); -const WORD EXCEPTION_INVALID = BINARY4(0000,0000,0000,0001); -const WORD EXCEPTION_ALL = BINARY4(0000,0000,0011,1111); - -// ====================================================================== - -void FloatingPointUnit::install(void) -{ - precision = P_24; - rounding = R_roundToNearestOrEven; - memset(exceptionEnabled, 0, sizeof(exceptionEnabled)); - - // preserve all other bits - status = getControlWord(); - status &= ~(PRECISION_MASK | ROUND_MASK | EXCEPTION_ALL); - - // set to single precision, rounding, and all exceptions masked - status |= PRECISION_24 | ROUND_NEAREST | EXCEPTION_ALL; - - // check the config platform flags to see if we should enable some exceptions - if (ConfigSharedFoundation::getFpuExceptionPrecision()) - { - exceptionEnabled[E_precision] = true; - status &= ~EXCEPTION_PRECISION; - } - - if (ConfigSharedFoundation::getFpuExceptionUnderflow()) - { - exceptionEnabled[E_underflow] = true; - status &= ~EXCEPTION_UNDERFLOW; - } - - if (ConfigSharedFoundation::getFpuExceptionOverflow()) - { - exceptionEnabled[E_overflow] = true; - status &= ~EXCEPTION_OVERFLOW; - } - - if (ConfigSharedFoundation::getFpuExceptionZeroDivide()) - { - exceptionEnabled[E_zeroDivide] = true; - status &= ~EXCEPTION_ZERO_DIVIDE; - } - - if (ConfigSharedFoundation::getFpuExceptionDenormal()) - { - exceptionEnabled[E_denormal] = true; - status &= ~EXCEPTION_DENORMAL; - } - - if (ConfigSharedFoundation::getFpuExceptionInvalid()) - { - exceptionEnabled[E_invalid] = true; - status &= ~EXCEPTION_INVALID; - } - - setControlWord(status); -} - -// ---------------------------------------------------------------------- - -void FloatingPointUnit::update(void) -{ - WORD currentStatus = getControlWord(); - - if (currentStatus != status) - { -// DEBUG_REPORT_LOG_PRINT(true, ("FPU: update=%d, in mode=%04x, should be in mode=%04x\n", updateNumber, static_cast(currentStatus), static_cast(status))); - setControlWord(status); - } - - ++updateNumber; -} - -// ---------------------------------------------------------------------- - -WORD FloatingPointUnit::getControlWord(void) -{ - WORD controlWord = 0; - - __asm fnstcw controlWord; - return controlWord; -} - -// ---------------------------------------------------------------------- - -void FloatingPointUnit::setControlWord(WORD controlWord) -{ - UNREF(controlWord); - __asm fldcw controlWord; -} - -// ---------------------------------------------------------------------- - -void FloatingPointUnit::setPrecision(Precision newPrecision) -{ - WORD bits = 0; - - switch (precision) - { - case P_24: - bits = PRECISION_24; - break; - - case P_53: - bits = PRECISION_53; - break; - - case P_64: - bits = PRECISION_64; - break; - - case P_max: - default: - DEBUG_FATAL(true, ("bad case")); - } - - // record the current state - precision = newPrecision; - - // set the proper bit pattern - status &= ~PRECISION_MASK; - status |= bits; - - // slam it into the FPU - setControlWord(status); -} - -// ---------------------------------------------------------------------- - -void FloatingPointUnit::setRounding(Rounding newRounding) -{ - WORD bits = 0; - - switch (newRounding) - { - case R_roundToNearestOrEven: - bits = ROUND_NEAREST; - break; - - case R_chop: - bits = ROUND_CHOP; - break; - - case R_roundDown: - bits = ROUND_DOWN; - break; - - case R_roundUp: - bits = ROUND_UP; - break; - - case R_max: - default: - DEBUG_FATAL(true, ("bad case")); - } - - // record the current state - rounding = newRounding; - - // set the proper bit pattern - status &= ~ROUND_MASK; - status |= bits; - - // slam it into the FPU - setControlWord(status); -} - -// ---------------------------------------------------------------------- - -void FloatingPointUnit::setExceptionEnabled(Exception exception, bool enabled) -{ - WORD bits = 0; - - switch (exception) - { - case E_precision: - bits = EXCEPTION_PRECISION; - break; - - case E_underflow: - bits = EXCEPTION_UNDERFLOW; - break; - - case E_overflow: - bits = EXCEPTION_OVERFLOW; - break; - - case E_zeroDivide: - bits = EXCEPTION_ZERO_DIVIDE; - break; - - case E_denormal: - bits = EXCEPTION_DENORMAL; - break; - - case E_invalid: - bits = EXCEPTION_INVALID; - break; - - case E_max: - default: - DEBUG_FATAL(true, ("bad case")); - } - - // record the current state - exceptionEnabled[exception] = enabled; - - // twiddle the bit appropriately. these bits masks, so set the bit to disable the exception, clear the bit to enable it. - if (enabled) - status &= ~bits; - else - status |= bits; - - // slam it into the FPU - setControlWord(status); -} - -// ====================================================================== diff --git a/engine/shared/library/sharedFoundation/src/win32/FloatingPointUnit.h b/engine/shared/library/sharedFoundation/src/win32/FloatingPointUnit.h deleted file mode 100755 index 9cda070d..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/FloatingPointUnit.h +++ /dev/null @@ -1,104 +0,0 @@ -// ====================================================================== -// -// FloatingPointUnit.h -// jeff grills -// -// copyright 1999 Bootprint Entertainment -// -// ====================================================================== - -#ifndef FLOATING_POINT_UNIT_H -#define FLOATING_POINT_UNIT_H - -// ====================================================================== - -class FloatingPointUnit -{ -public: - - typedef unsigned short WORD; - - enum Precision - { - P_24, - P_53, - P_64, - - P_max - }; - - enum Rounding - { - R_roundToNearestOrEven, - R_chop, - R_roundDown, - R_roundUp, - - R_max - }; - - enum Exception - { - E_precision, - E_underflow, - E_overflow, - E_zeroDivide, - E_denormal, - E_invalid, - - E_max - }; - -private: - - static int updateNumber; - static WORD status; - static Precision precision; - static Rounding rounding; - static bool exceptionEnabled[E_max]; - -public: - - static WORD getControlWord(void); - static void setControlWord(WORD controlWord); - -public: - - static void install(void); - - static void update(void); - - static void setPrecision(Precision newPrecision); - static void setRounding(Rounding newRounding); - static void setExceptionEnabled(Exception exception, bool enabled); - - static Precision getPrecision(void); - static Rounding getRounding(void); - static bool getExceptionEnabled(Exception exception); -}; - -// ====================================================================== - -inline FloatingPointUnit::Precision FloatingPointUnit::getPrecision(void) -{ - return precision; -} - -// ---------------------------------------------------------------------- - -inline FloatingPointUnit::Rounding FloatingPointUnit::getRounding(void) -{ - return rounding; -} - -// ---------------------------------------------------------------------- - -inline bool FloatingPointUnit::getExceptionEnabled(Exception theException) -{ - DEBUG_FATAL(static_cast(theException) < 0 || static_cast(theException) >= static_cast(E_max), ("exception out of range")); //lint !e568 // non-negative quantity is never less than 0 - return exceptionEnabled[theException]; -} - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFoundation/src/win32/Os.cpp b/engine/shared/library/sharedFoundation/src/win32/Os.cpp deleted file mode 100755 index 9c828361..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/Os.cpp +++ /dev/null @@ -1,1633 +0,0 @@ -// ====================================================================== -// -// Os.cpp -// -// Portions copyright 1998 Bootprint Entertainment -// Portions copyright 2000-2002 Sony Online Entertainment -// All Rights Reserved -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/Os.h" - -#include "sharedDebug/DebugFlags.h" -#include "sharedDebug/DebugKey.h" -#include "sharedDebug/DebugMonitor.h" -#include "sharedDebug/Profiler.h" -#include "sharedFoundation/Clock.h" -#include "sharedFoundation/ConfigFile.h" -#include "sharedFoundation/ConfigSharedFoundation.h" -#include "sharedFoundation/CrashReportInformation.h" -#include "sharedFoundation/ExitChain.h" -#include "sharedFoundation/FloatingPointUnit.h" -#include "sharedFoundation/Production.h" -#include "sharedFoundation/StringCompare.h" -#include "sharedFoundation/WindowsWrapper.h" -#include "shellapi.h" - -#include -#include -#include -#include - -// ====================================================================== - -namespace OsNamespace -{ - void applyWindowChanges(); - void updateMousePosition(int x, int y); - - const int PROGRAM_NAME_SIZE = 512; - - bool ms_installed; - bool ms_processMessagePump = true; - -#if PRODUCTION == 0 - bool ms_validateGuardPatterns; - bool ms_validateFreePatterns; - bool ms_allowPopupDebugMenu; -#endif - - int ms_numberOfUpdates; - HWND ms_window; - HCURSOR ms_cursorArrow; - bool ms_engineOwnsWindow; - bool ms_wasFocusLost; - bool ms_gameOver; - bool ms_shouldReturnFromAbort; - bool ms_wantPopupDebugMenu; - bool ms_threadDied; - bool ms_mouseMoveInClient; - bool ms_clickToMove; - char ms_programName[PROGRAM_NAME_SIZE]; - char *ms_shortProgramName; - char ms_programStartupDirectory[MAX_PATH]; - Os::ThreadId ms_mainThreadId; - Os::IsGdiVisibleHookFunction ms_isGdiVisibleHookFunction; - Os::LostFocusHookFunction ms_lostFocusHookFunction; - Os::AcquiredFocusHookFunction ms_acquiredFocusHookFunction; - Os::AcquiredFocusHookFunction ms_acquiredFocusHookFunction2; - Os::QueueCharacterHookFunction ms_queueCharacterHookFunction; - Os::SetSystemMouseCursorPositionHookFunction ms_setSystemMouseCursorPositionHookFunction; - Os::SetSystemMouseCursorPositionHookFunction ms_setSystemMouseCursorPositionHookFunction2; - Os::GetHardwareMouseCursorEnabled ms_getHardwareMouseCursorEnabled; - Os::GetOtherAdapterRectsHookFunction ms_getOtherAdapterRectsHookFunction; - Os::WindowPositionChangedHookFunction ms_windowPositionChangedHookFunction; - Os::DisplayModeChangedHookFunction ms_displayModeChangedHookFunction; - Os::InputLanguageChangedHookFunction ms_inputLanguageChangedHookFunction; - Os::IMEHookFunction ms_IMEHookFunction; - Os::QueueKeyDownHookFunction ms_queueKeyDownHookFunction; - - int ms_processorCount; - int ms_debugKeyIndex; - int ms_SystemMouseCursorPositionX; - int ms_SystemMouseCursorPositionY; - - std::vector ms_otherAdapterRects; - - char ms_keyboardLayout[KL_NAMELENGTH]; - - bool ms_focused; - - int const ms_hotKeyId = 0xBEEF; - - extern "C" WINBASEAPI BOOL WINAPI IsDebuggerPresent(VOID); -}; - -using namespace OsNamespace; - - -static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - -// ====================================================================== -/** - * Install the Os subsystem for games - * - * This routine is supported for all platforms, although different platforms may - * require different arguments to this routine. - * - * This routine registers the window class and creates the window for the application. - * - * This routine will add Os::remove to the ExitChain. - * - * @param instance Handle to the instance for this application - * @param windowName Name for the window title bar - * @paran normalIcon Normal icon for the game - * @param smallIcon Small icon for the task bar - * @see Os::remove() - */ - -void Os::install(HINSTANCE instance, const char *windowName, HICON normalIcon, HICON smallIcon) -{ - installCommon(); - - // setup the window class - WNDCLASSEX wclass; - Zero(wclass); - wclass.cbSize = sizeof(wclass); - wclass.style = CS_BYTEALIGNCLIENT; - wclass.lpfnWndProc = WindowProc; - wclass.hInstance = instance; - wclass.hIcon = normalIcon; - wclass.hCursor = NULL; - wclass.hbrBackground = reinterpret_cast(GetStockObject(BLACK_BRUSH)); - wclass.lpszClassName = windowName; - wclass.hIconSm = smallIcon; - - // register the window class - ATOM atom = RegisterClassEx(&wclass); - FATAL(atom == 0, ("RegisterClassEx failed")); - - // create the window - ms_window = CreateWindow( - windowName, // pointer to registered class name - windowName, // pointer to window name - WS_POPUP, // window style - 0, // horizontal position of window - 0, // vertical position of window - 640, // window width - 480, // window height - NULL, // handle to parent or owner window - NULL, // handle to menu or child-window identifier - instance, // handle to application instance - NULL); // pointer to window-creation data - FATAL(!ms_window, ("CreateWindow failed")); - ms_engineOwnsWindow = true; - - // load the arrow cursor - ms_cursorArrow = LoadCursor(NULL, IDC_ARROW); - FATAL(ms_cursorArrow == NULL, ("LoadCursor failed")); -} - -// ---------------------------------------------------------------------- -/** - * Install the Os subsystem for non-games. - * - * This routine is supported for all platforms, although different platforms may - * require different arguments to this routine.F - * - * This routine will add Os::remove to the ExitChain. - * - * @see Os::remove() - */ - -void Os::install(HWND newWindow, bool newProcessMessagePump) -{ - installCommon(); - ms_window = newWindow; - ms_processMessagePump = newProcessMessagePump; -} - -// ---------------------------------------------------------------------- -/** - * Install the Os subsystem for non-games. - * - * This routine is supported for all platforms, although different platforms may - * require different arguments to this routine. - * - * This routine will add Os::remove to the ExitChain. - * - * @see Os::remove() - */ - -void Os::install() -{ - installCommon(); -} - -// ---------------------------------------------------------------------- -/** - * This routine will remove the Os subsystem. - * - * This routine should not be called directly. It will be called from the ExitChain. - * - * @see Os::install() - */ - -void Os::remove() -{ - DEBUG_FATAL(!ms_installed, ("not installed")); - ms_installed = false; -} - -// ---------------------------------------------------------------------- - -void Os::installCommon() -{ - DEBUG_FATAL(ms_installed, ("already installed")); - - ExitChain::add(Os::remove, "Os::remove", 0, true); - - // get startup folder. - GetCurrentDirectory(sizeof(ms_programStartupDirectory), ms_programStartupDirectory); - - ms_numberOfUpdates = 0; - ms_mainThreadId = GetCurrentThreadId(); - setThreadName(ms_mainThreadId, "Main"); - -#if PRODUCTION == 0 - ms_allowPopupDebugMenu = ConfigFile::getKeyBool("SharedFoundation", "allowPopupDebugMenu", false); -#endif - - // get the name of the executable - DWORD result = GetModuleFileName(NULL, ms_programName, sizeof(ms_programName)); - FATAL(result == 0, ("GetModuleFileName failed")); - - // get the file name without the path - ms_shortProgramName = strrchr(ms_programName, '\\'); - if (ms_shortProgramName) - ++ms_shortProgramName; - else - ms_shortProgramName = ms_programName; - - // switch into single-precision floating point mode - FloatingPointUnit::install(); - - // get the amount of memory - MEMORYSTATUS memoryStatus; - GlobalMemoryStatus(&memoryStatus); - CrashReportInformation::addStaticText("Ram: %dmb\n", memoryStatus.dwTotalPhys / (1024 * 1024)); - - // log the os information - { - OSVERSIONINFO versionInfo; - Zero(versionInfo); - versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&versionInfo); - CrashReportInformation::addStaticText("Os1: %d.%d.%d\n", versionInfo.dwMajorVersion, versionInfo.dwMinorVersion, versionInfo.dwBuildNumber); - - char const * os = "Unknown"; - if (versionInfo.dwMajorVersion == 4 && versionInfo.dwMinorVersion == 10) - os = "Windows 98"; - else - if (versionInfo.dwMajorVersion == 4 && versionInfo.dwMinorVersion == 90) - os = "Windows Me"; - else - if (versionInfo.dwMajorVersion == 5 && versionInfo.dwMinorVersion == 0) - os = "Windows 2000"; - else - if (versionInfo.dwMajorVersion == 5 && versionInfo.dwMinorVersion == 1) - os = "Windows XP"; - else - if (versionInfo.dwMajorVersion == 5 && versionInfo.dwMinorVersion == 2) - os = "Windows Server 2003"; - else - if (versionInfo.dwMajorVersion == 6 && versionInfo.dwMinorVersion == 0) - os = "Windows Vista"; - - - - CrashReportInformation::addStaticText("Os2: %s %s\n", os, versionInfo.szCSDVersion); - } - - // get the number of processors - SYSTEM_INFO si; - GetSystemInfo(&si); - ms_processorCount = static_cast(si.dwNumberOfProcessors); - REPORT_LOG (ConfigSharedFoundation::getVerboseHardwareLogging(), ("Processor Count: %i\n", ms_processorCount)); - CrashReportInformation::addStaticText("NumProc: %d\n", ms_processorCount); - - { - HKEY key; - LONG result = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, KEY_EXECUTE, &key); - - if (result == ERROR_SUCCESS) - { - DWORD data; - DWORD type = REG_DWORD; - DWORD size = sizeof (data); - result = RegQueryValueEx (key, "~MHz", NULL, &type, reinterpret_cast (&data), &size); - if ((result == ERROR_SUCCESS) && (size > 0)) - REPORT_LOG (ConfigSharedFoundation::getVerboseHardwareLogging(), ("Processor Speed: %i MHz\n", data)); - - RegCloseKey (key); - } - } - - if (!GetKeyboardLayoutName(ms_keyboardLayout)) - ms_keyboardLayout[0] = '\0'; - - ms_installed = true; - -#if PRODUCTION == 0 - DebugFlags::registerFlag(ms_validateGuardPatterns, "SharedFoundation", "validateGuardPatterns"); - DebugFlags::registerFlag(ms_validateFreePatterns, "SharedFoundation", "validateFreePatterns"); -#endif - - switch (ConfigSharedFoundation::getProcessPriority()) - { - case -1: - setProcessPriority(P_low); - break; - - case 0: - setProcessPriority(P_normal); - break; - - case 1: - setProcessPriority(P_high); - break; - - default: - DEBUG_WARNING(true, ("invalid process priority, %d should be betweein [-1..1]", ConfigSharedFoundation::getProcessPriority())); - break; - } -} - -// ====================================================================== -// Return the window handle -// -// Return value: -// -// Handle to the window for this application -// -// Remarks: -// -// This routine is only supported on the Win* platforms, and should not be used by the -// game or the engine if portability is required. - -HWND Os::getWindow() -{ - return ms_window; -} - -// ---------------------------------------------------------------------- - -bool Os::engineOwnsWindow() -{ - return ms_engineOwnsWindow; -} - -// ---------------------------------------------------------------------- -/** - * Return the full name of the running executable. - * - * The program name will include the path as well. - * - * @return The full name of the running executable - * @see Os::getShortProgramName() - */ - -const char *Os::getProgramName() -{ - return ms_programName; -} - -// ---------------------------------------------------------------------- -/** - * Return the short name of the running executable. - * - * The program name will not include the path, but will just be the file name. - * - * @return The short name of the running executable - * @see Os::getProgramName() - */ - -const char *Os::getShortProgramName() -{ - return ms_shortProgramName; -} - -// ---------------------------------------------------------------------- -/** - * Return the current working directory when the program was started. - * - */ - -const char *Os::getProgramStartupDirectory() -{ - return ms_programStartupDirectory; -} - -// ---------------------------------------------------------------------- -/** - * Cause Os::abort() to return instead of abort the process. - * - * This routine should not be called directly by users. - * - * This routine is provided so that structured exception handling can catch - * an exception, call Fatal to run the ExitChain, and rethrow the exception - * so that the debugger will catch it. - */ - -void Os::returnFromAbort() -{ - ms_shouldReturnFromAbort = true; -} - -// ---------------------------------------------------------------------- -/** - * Check if the Os knows the game needs to shut down. - * - * The Os can decide that the game need to end for a number of reasons, - * including closing the application or shutting the machine down. - * - * @return True if the game should quit, otherwise false - */ - -bool Os::isGameOver() -{ - return ms_gameOver; -} - -// ---------------------------------------------------------------------- -/** - * Return the number of updates that the have occurred. - * - * @return This value is updated during the Os::update() routine. - */ - -int Os::getNumberOfUpdates() -{ - return ms_numberOfUpdates; -} - -// ---------------------------------------------------------------------- -/** - * Indicate whether or not the application was paused. - * - * @return True if the application was in the background (paused), otherwise false - */ - -bool Os::wasFocusLost() -{ - return ms_wasFocusLost; -} - -// ---------------------------------------------------------------------- -/** - * Return a flag indicating whether we are running a multiprocessor machine or not. - * - * @return True if the machine has more than one processor, false if not. - */ - -bool Os::isMultiprocessor() -{ - return ms_processorCount > 1; -} - -// ---------------------------------------------------------------------- -/** - * Return the number of processors. - * - * @return The number of processors in the machine. - */ - -int Os::getProcessorCount() -{ - return ms_processorCount; -} - -// ---------------------------------------------------------------------- - -bool Os::isMainThread() -{ - // if the Os class hasn't been installed, then assume we are the main thread. - // otherwise, check to see if our thread id is the main thread id - return !ms_installed || (GetCurrentThreadId() == ms_mainThreadId); -} - -// ---------------------------------------------------------------------- -/** - * Terminate the application because of an error condition. - * - * This routine is supported for all platforms. - * - * This routine should not be called directly. The engine and game should use the - * FATAL macro to terminate the application because of an error. - * - * Calling Os::returnFromAbort() will cause the routine to do nothing but return - * immediately. - * - * @see Os::returnFromAbort(), FATAL() - */ - -void Os::abort() -{ - if (!isMainThread()) - { - ms_threadDied = true; - ExitThread(1); - } - - if (!ms_shouldReturnFromAbort) - { - // let the C runtime deal with the abnormal termination - ::abort(); - } -} - -// ---------------------------------------------------------------------- - -void Os::setLostFocusHookFunction(LostFocusHookFunction lostFocusHookFunction) -{ - ms_lostFocusHookFunction = lostFocusHookFunction; -} - -// ---------------------------------------------------------------------- - -void Os::setIsGdiVisibleHookFunction(IsGdiVisibleHookFunction isGdiVisibleHookFunction) -{ - ms_isGdiVisibleHookFunction = isGdiVisibleHookFunction; -} - -// ---------------------------------------------------------------------- - -void Os::setQueueCharacterHookFunction(QueueCharacterHookFunction queueCharacterHookFunction) -{ - ms_queueCharacterHookFunction = queueCharacterHookFunction; -} - -// ---------------------------------------------------------------------- - -void Os::setSetSystemMouseCursorPositionHookFunction(SetSystemMouseCursorPositionHookFunction setSystemMouseCursorPositionHookFunction) -{ - ms_setSystemMouseCursorPositionHookFunction = setSystemMouseCursorPositionHookFunction; -} - -// ---------------------------------------------------------------------- - -void Os::setSetSystemMouseCursorPositionHookFunction2(SetSystemMouseCursorPositionHookFunction setSystemMouseCursorPositionHookFunction) -{ - ms_setSystemMouseCursorPositionHookFunction2 = setSystemMouseCursorPositionHookFunction; -} - -// ---------------------------------------------------------------------- - -void Os::setAcquiredFocusHookFunction(AcquiredFocusHookFunction acquiredFocusHookFunction) -{ - ms_acquiredFocusHookFunction = acquiredFocusHookFunction; -} - -// ---------------------------------------------------------------------- - -void Os::setAcquiredFocusHookFunction2(AcquiredFocusHookFunction acquiredFocusHookFunction) -{ - ms_acquiredFocusHookFunction2 = acquiredFocusHookFunction; -} - -// ---------------------------------------------------------------------- - -void Os::setGetHardwareMouseCursorEnabled(GetHardwareMouseCursorEnabled getHardwareMouseCursorEnabled) -{ - ms_getHardwareMouseCursorEnabled = getHardwareMouseCursorEnabled; -} - -// ---------------------------------------------------------------------- - -void Os::setGetOtherAdapterRectsHookFunction(GetOtherAdapterRectsHookFunction getOtherAdapterRectsHookFunction) -{ - ms_getOtherAdapterRectsHookFunction = getOtherAdapterRectsHookFunction; -} - -// ---------------------------------------------------------------------- - -void Os::setWindowPositionChangedHookFunction(WindowPositionChangedHookFunction windowPositionChangedHookFunction) -{ - ms_windowPositionChangedHookFunction = windowPositionChangedHookFunction; -} - -//----------------------------------------------------------------- - -void Os::setDisplayModeChangedHookFunction(DisplayModeChangedHookFunction displayModeChangedHookFunction) -{ - ms_displayModeChangedHookFunction = displayModeChangedHookFunction; -} - -//----------------------------------------------------------------- - -void Os::setInputLanguageChangedHookFunction(InputLanguageChangedHookFunction inputLanguageChangedHookFunction) -{ - ms_inputLanguageChangedHookFunction = inputLanguageChangedHookFunction; -} - -//----------------------------------------------------------------- -// rls - In IME mode, the F5 key can cause the IME pad window to open up. -// This causes the Japanese player to essentially lock-up because of -// context issues. There is probably a better way to handle this, but be -// warned: the SWG input system may not work properly. -void Os::setIMEHookFunction(IMEHookFunction imeHookFunction) -{ - if (ms_IMEHookFunction) - { - UnregisterHotKey(ms_window, ms_hotKeyId); - } - - ms_IMEHookFunction = imeHookFunction; - - // do not install the hotkey fix if the debugger is present. - if (ms_IMEHookFunction && !OsNamespace::IsDebuggerPresent()) - { - RegisterHotKey(ms_window, ms_hotKeyId, 0, VK_F5); - } -} - -//----------------------------------------------------------------- - -void Os::setQueueKeyDownHookFunction(QueueKeyDownHookFunction queueKeyDownHookFunction) -{ - ms_queueKeyDownHookFunction = queueKeyDownHookFunction; -} - -//----------------------------------------------------------------- -/** -* Create the specified directory and all of it's parents. -* @param directory the path to a directory -* @return always true currently -*/ - -bool Os::createDirectories (const char *directory) -{ - //-- construct list of subdirectories all the way down to root - std::stack directoryStack; - - std::string currentDirectory = directory; - - static const char path_seps [] = { '\\', '/', 0 }; - - // build the stack - while (!currentDirectory.empty()) - { - // remove trailing backslash - if (currentDirectory[currentDirectory.size()-1] == '\\' || currentDirectory[currentDirectory.size()-1] == '/') - IGNORE_RETURN(currentDirectory.erase(currentDirectory.size()-1)); - - if (currentDirectory[currentDirectory.size()-1] == ':') - { - // we've hit something like c: - break; - } - - if (!currentDirectory.empty()) - directoryStack.push(currentDirectory); - - // now strip off current directory - const size_t previousDirIndex = currentDirectory.find_last_of (path_seps); - if (static_cast(previousDirIndex) == currentDirectory.npos) - break; - else - IGNORE_RETURN(currentDirectory.erase(previousDirIndex)); - } - - //-- build all directories specified by the initial directory - while (!directoryStack.empty()) - { - // get the directory - currentDirectory = directoryStack.top(); - directoryStack.pop(); - - // try to create it (don't pass any security attributes) - IGNORE_RETURN (CreateDirectory(currentDirectory.c_str(), NULL)); - } - - return true; -} - -// ---------------------------------------------------------------------- -/** - * Write out a file. - * - * The file name and where the file is written is system-dependent. - * - * @param fileName Name of the file to write - * @param data Data buffer to write to the file - */ - -bool Os::writeFile(const char *fileName, const void *data, int length) // Length of the data bufferto write -{ - BOOL result; - HANDLE handle; - DWORD written; - - // open the file for writing - handle = CreateFile(fileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - - // check if it was opened - if (handle == INVALID_HANDLE_VALUE) - { - WARNING (true, ("Os::writeFile unable to create file [%s] for writing.", fileName)); - return false; - } - - // attempt to write the data - result = WriteFile(handle, data, static_cast(length), &written, NULL); - - // make sure the data was written okay - if (!result || written != static_cast(length)) - { - WARNING (true, ("Os::writeFile error writing file [%s]. Wrote %d, attempted to write %d.", fileName, written, length)); - static_cast(CloseHandle(handle)); - return false; - } - - // close the file - result = CloseHandle(handle); - - // make sure the close was sucessful - if (!result) - { - WARNING (true, ("Os::writeFile error closing file [%s].", fileName)); - return false; - } - - return true; -} - -// ---------------------------------------------------------------------- -/** - * Check to see if any child threads have Fataled. - * - * This routine will - */ - -void Os::checkChildThreads() -{ - FATAL(ms_threadDied, ("child thread died")); -} - -// ---------------------------------------------------------------------- -/** - * Change the priority of this process. - * - */ - -void Os::setProcessPriority(Priority priority) -{ - switch (priority) - { - case P_low: - SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS); - break; - - case P_normal: - SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); - break; - - case P_high: - SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); - break; - - default: - DEBUG_FATAL(true, ("Invalid priority")); - break; - } -} - -// ---------------------------------------------------------------------- -/** - * Update the Os subsystem. - * - * This routine is supported for all platforms. - * - * For the Win* platforms, this routine will process the windows message pump. - */ - -bool Os::update() -{ - MSG msg; - int result; - - FloatingPointUnit::update(); - - ms_wasFocusLost = false; - ++ms_numberOfUpdates; - -#if PRODUCTION == 0 - - if (ms_validateGuardPatterns || ms_validateFreePatterns) - { - PROFILER_AUTO_BLOCK_DEFINE ("validate heap"); - MemoryManager::verify(ms_validateGuardPatterns, ms_validateFreePatterns); - } - -#endif - - if (ms_processMessagePump) - { - do - { - checkChildThreads(); - - // while there are messages in the queue - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) - { - result = GetMessage(&msg, NULL, 0, 0); - - if (result < 0) - { - // error, ignore GetMessage - } - else - // get the message - if (result > 0) - { - static_cast(TranslateMessage(&msg)); - static_cast(DispatchMessage(&msg)); - } - else - { - // WM_QUIT handled here - ms_gameOver = true; - return false; - } - } - - // may need to reprocess the message queue now - } while (handleDebugMenu()); - } - - Clock::update(); - - return true; -} - -// ---------------------------------------------------------------------- -/** - * Formats a message error using GetLastError() and FormatMessge(). - * - * The buffer returned from this function is dynamically allocated to prevent - * issues with this routine being called from multiple threads. The caller - * must delete the buffer when it is done. - * - * @return A dynamically allocated buffer containing the error message - */ - -char *Os::getLastError() -{ - char buffer[2048]; - - const DWORD result = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, sizeof(buffer), NULL); - - if (result == 0) - return NULL; - - return DuplicateString(buffer); -} - -// ---------------------------------------------------------------------- - -bool Os::handleDebugMenu() -{ -#if PRODUCTION == 0 - - // pop up the menu if it is wanted and GDI is actually visible - if (ms_wantPopupDebugMenu && ms_isGdiVisibleHookFunction && ms_isGdiVisibleHookFunction()) - { - ms_focused = false; - // unaquire all the dinput devices - if (ms_lostFocusHookFunction) - ms_lostFocusHookFunction(); - - BOOL b; - POINT p; - - // get the upper left corner of the client space in screen coordinates - p.x = 0; - p.y = 0; - b = ClientToScreen(ms_window, &p); - DEBUG_FATAL(!b, ("ClientToScreen failed")); - - typedef std::map Map; - Map map; - - // create the menu - HMENU menu = CreatePopupMenu(); - const char *lastSection.clear(); - HMENU lastSubmenu = NULL; - int index = 1; - DebugFlags::FlagVector::const_iterator end = DebugFlags::ms_flagsSortedByName.end(); - for (DebugFlags::FlagVector::const_iterator i = DebugFlags::ms_flagsSortedByName.begin(); i != end; ++i, ++index) - { - const DebugFlags::Flag &flag = *i; - - // check if we are starting a new section - if (strcmp(lastSection, flag.section) != 0) - { - lastSection = flag.section; - - char buffer[512]; - strcpy(buffer, lastSection); - char *start = buffer; - char *slash = NULL; - lastSubmenu = menu; - while ((slash = strchr(start, '/')) != NULL) - { - *slash = '\0'; - - Map::iterator entry = map.find(buffer); - if (entry == map.end()) - { - const int numberOfItems = GetMenuItemCount(lastSubmenu); - int insertLocation = 0; - for (insertLocation = 0; insertLocation < numberOfItems && GetSubMenu(lastSubmenu, insertLocation); ++insertLocation) - ; - - HMENU newMenu = CreatePopupMenu(); - static_cast(InsertMenu(lastSubmenu, insertLocation, MF_BYPOSITION | MF_POPUP, reinterpret_cast(newMenu), start)); - lastSubmenu = newMenu; - map.insert(Map::value_type(DuplicateString(buffer), lastSubmenu)); - } - else - lastSubmenu = entry->second; - - *slash = '/'; - start = slash + 1; - } - - const int numberOfItems = GetMenuItemCount(lastSubmenu); - int insertLocation = 0; - for (insertLocation = 0; insertLocation < numberOfItems && GetSubMenu(lastSubmenu, insertLocation); ++insertLocation) - ; - - HMENU newMenu = CreatePopupMenu(); - static_cast(InsertMenu(lastSubmenu, insertLocation, MF_BYPOSITION | MF_POPUP, reinterpret_cast(newMenu), start)); - lastSubmenu = newMenu; - map.insert(Map::value_type(DuplicateString(buffer), lastSubmenu)); - } - - // add the current flag to the current menu - static_cast(AppendMenu(lastSubmenu, MF_ENABLED | MF_STRING | (*flag.variable ? MF_CHECKED : MF_UNCHECKED), index, flag.name)); - } - - { - ms_debugKeyIndex = index; - - Map::iterator entry = map.find("SharedDebug"); - DEBUG_FATAL(entry == map.end(), ("Could not find SharedDebug section")); - - HMENU newMenu = CreatePopupMenu(); - static_cast(AppendMenu(entry->second, MF_POPUP, reinterpret_cast(newMenu), "DebugKey")); - lastSubmenu = newMenu; - - DebugKey::FlagVector::const_iterator end = DebugKey::ms_flags.end(); - for (DebugKey::FlagVector::const_iterator i = DebugKey::ms_flags.begin(); i != end; ++i, ++index) - { - // add the current flag to the current menu - const DebugKey::Flag &flag = *i; - static_cast(AppendMenu(lastSubmenu, MF_ENABLED | MF_STRING | (*flag.variable ? MF_CHECKED : MF_UNCHECKED), index, flag.name)); - } - } - - // free the map memory - while (!map.empty()) - { - Map::iterator i = map.begin(); - char *value = i->first; - map.erase(i); - delete [] value; - } - - // pop up the menu at the top corner of the client space - index = TrackPopupMenuEx(menu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_NONOTIFY | TPM_RETURNCMD | TPM_RIGHTBUTTON, p.x, p.y, ms_window, NULL); - if (index) - { - if (index < ms_debugKeyIndex) - { - bool &value = *DebugFlags::ms_flagsSortedByName[index-1].variable; - value = !value; - } - else - { -#if PRODUCTION == 0 - DebugKey::setCurrentFlag(DebugKey::ms_flags[index - ms_debugKeyIndex].variable); -#endif - } - } - - DestroyMenu(menu); - - // don't want the menu anymore - ms_wantPopupDebugMenu = false; - ms_wasFocusLost = true; - ms_focused = true; - if (ms_acquiredFocusHookFunction2) - ms_acquiredFocusHookFunction2(); - - return true; - } - -#endif - - return false; -} - -// ---------------------------------------------------------------------- - -void Os::enablePopupDebugMenu() -{ -#if PRODUCTION == 0 - ms_allowPopupDebugMenu = true; -#endif -} - -// ---------------------------------------------------------------------- -/** - * Request that the popup debug menu be displayed. - * - * The popup debug menu will only be displayed if the proper config file - * switch has been set. - */ - -void Os::requestPopupDebugMenu() -{ -#if PRODUCTION == 0 - ms_wantPopupDebugMenu = ms_allowPopupDebugMenu; -#endif -} - -bool Os::isNumPadValue(unsigned char asciiChar) -{ - return (asciiChar >= '0' && asciiChar <= '9') || - (asciiChar == '/') || - (asciiChar == '*') || - (asciiChar == '-') || - (asciiChar == '+') || - (asciiChar == '.'); -} - - -// ---------------------------------------------------------------------- -/** - * Check to see if this is a NumPad keypress to be consumed. Enter is the only one not consumed. - */ -bool Os::isNumPadChar(unsigned char asciiChar) -{ - BYTE keyboardstate[256]; - GetKeyboardState( keyboardstate ); - - if (isNumPadValue(asciiChar)) - { - return ( (keyboardstate[VK_NUMPAD1] > 1) || - (keyboardstate[VK_NUMPAD2] > 1) || - (keyboardstate[VK_NUMPAD3] > 1) || - (keyboardstate[VK_NUMPAD4] > 1) || - (keyboardstate[VK_NUMPAD5] > 1) || - (keyboardstate[VK_NUMPAD6] > 1) || - (keyboardstate[VK_NUMPAD7] > 1) || - (keyboardstate[VK_NUMPAD8] > 1) || - (keyboardstate[VK_NUMPAD9] > 1) || - (keyboardstate[VK_NUMPAD0] > 1) || - (keyboardstate[VK_DIVIDE] > 1) || - (keyboardstate[VK_ADD] > 1) || - (keyboardstate[VK_SUBTRACT] > 1) || - (keyboardstate[VK_MULTIPLY] > 1) || - (keyboardstate[VK_DECIMAL] > 1)); - } - return false; -} - -// ---------------------------------------------------------------------- -/** - * Handle window messages. - * - * This routine will process window messages that are passed into the application from - * Windows, likely though the Os::update() routine, but may be from other locations as well. - * - * @param hwnd Handle of window - * @param uMsg Message identifier - * @param wParam First message parameter - * @param lParam Second message parameter - * @see Os::update() - */ - -LRESULT CALLBACK Os::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ -#if 0 - DEBUG_REPORT_LOG_PRINT(true, ("%08d %08x %08x %08x\n", ms_numberOfUpdates, uMsg, wParam, lParam)); -#endif - - if (ms_IMEHookFunction) - { - // Let the IME Manager see and possibly consume message - if (ms_IMEHookFunction(hwnd, uMsg, wParam, lParam) == 0) - { - return 0; - } - } - - switch (uMsg) - { - case WM_ERASEBKGND: - // won't let windows erase the background - return 0; - - case WM_IME_CHAR: - if (ms_queueCharacterHookFunction) - { - const char ansiChars [2] = - { - static_cast(HIBYTE( wParam )), //lint !e1924 // c-style case msvc bug - static_cast(LOBYTE( wParam )) //lint !e1924 // c-style case msvc bug - }; - - wchar_t u; - if (MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, reinterpret_cast(ansiChars), 2, &u, 1)) - ms_queueCharacterHookFunction(0, static_cast(u)); - } - return 0; - - case WM_HOTKEY: - { - if (ms_queueKeyDownHookFunction) - { - ms_queueKeyDownHookFunction(0, MapVirtualKey(HIWORD(lParam), 0)); - } - return 0; - } - case WM_CHAR: - // handle typed string characters - if (ms_queueCharacterHookFunction) - { - //-- the extended bit is bit 24 - const int extended = (lParam & (1 << 24)) != 0; - - if (!extended) - { - int keyCode = (lParam << 8) >> 24; // key code is in bits 16-23 - // cp* == ASCII until 0x80, for which you then need to call the following to get the Unicode value - // from the cp* value. WM_CHAR always returns the values from the windows codepage (cp) used. For US/Europe - // it is cp1252 and for Japan it is cp932. - if (wParam >= 0x80) - { - char cpChar[2]; - wchar_t unicodeChar[2]; - - cpChar[0] = static_cast(wParam); - cpChar[1] = '\0'; - - int result = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, cpChar, sizeof(cpChar), unicodeChar, sizeof(unicodeChar)); - - - if (result > 0) - { - ms_queueCharacterHookFunction(keyCode, static_cast(unicodeChar[0])); - } - } - else - { - ms_queueCharacterHookFunction(keyCode, static_cast(wParam)); - } - } - } - return 0; - - case WM_INPUTLANGCHANGE: - { - if (ms_inputLanguageChangedHookFunction) - { - ms_inputLanguageChangedHookFunction(); - } - } - return 0; - - case WM_DESTROY: - // if the main window gets destroyed, it's time to quit - PostQuitMessage(0); - return 0; - - case WM_SYSCOMMAND: - switch (wParam & 0xFFF0) - { - // hack hack hack hack hack - // don't let alt-f4 close the window, but allow clicking on the close X button to close the window - case SC_CLOSE: - if (GetKeyState(VK_F4) && (GetKeyState(VK_MENU) || GetKeyState(VK_RMENU))) - return 0; - break; - - // don't let the monitor get turned off - case SC_MONITORPOWER: - return 0; - - // don't allow the screen saver to come on - case SC_SCREENSAVE: - return 0; - - // don't allow alt-space to open up the window menu - case SC_KEYMENU: - return 0; - - case SC_MOVE: - ClipCursor(NULL); - ms_focused = false; - if (ms_lostFocusHookFunction) - ms_lostFocusHookFunction(); - ms_wasFocusLost = true; - break; - default: - break; - } - break; - - case WM_ENTERSIZEMOVE: - if (ms_getOtherAdapterRectsHookFunction) - { - ms_otherAdapterRects.clear(); - (*ms_getOtherAdapterRectsHookFunction)(ms_otherAdapterRects); - } - break; - - case WM_EXITSIZEMOVE: - ms_focused = true; - if (ms_acquiredFocusHookFunction) - ms_acquiredFocusHookFunction(); - if (ms_acquiredFocusHookFunction2) - ms_acquiredFocusHookFunction2(); - ms_wasFocusLost = true; - if (ms_windowPositionChangedHookFunction) - (*ms_windowPositionChangedHookFunction)(); -#if PRODUCTION == 0 - DebugMonitor::setBehindWindow(ms_window); -#endif - break; - - case WM_MOUSEACTIVATE: - if (hwnd == ms_window) - { - if (LOWORD(lParam) == HTCAPTION) - ms_clickToMove = true; - else if (LOWORD(lParam) == HTCLIENT) - { - ms_focused = true; - if (ms_acquiredFocusHookFunction) - ms_acquiredFocusHookFunction(); - if (ms_acquiredFocusHookFunction2) - ms_acquiredFocusHookFunction2(); - } - } - - break; - - case WM_MOUSEMOVE: - if (ms_focused && hwnd == ms_window) - { - ms_mouseMoveInClient = true; - updateMousePosition(LOWORD(lParam), HIWORD(lParam)); - } - break; - - case WM_NCMOUSEMOVE: - ms_mouseMoveInClient = false; - break; - - case WM_SETCURSOR: - if (!ms_mouseMoveInClient || hwnd != ms_window) - SetCursor(ms_cursorArrow); - else - if (!ms_getHardwareMouseCursorEnabled || !ms_getHardwareMouseCursorEnabled()) - SetCursor(NULL); - break; - - case WM_NCACTIVATE: -#if PRODUCTION == 0 - // hack to handle coming back from the debugger cleanly - if (wParam) - { - //allow game-specific systems a chance to respond to focus changes - DebugMonitor::setBehindWindow(ms_window); - if (ms_lostFocusHookFunction) - ms_lostFocusHookFunction(); - if (ms_acquiredFocusHookFunction) - ms_acquiredFocusHookFunction(); - if (ms_acquiredFocusHookFunction2) - ms_acquiredFocusHookFunction2(); - ms_wasFocusLost = true; - ms_focused = true; - } -#endif - break; - - case WM_ACTIVATE: - if (hwnd == ms_window) - { - if (wParam != WA_INACTIVE) - { - if (ms_clickToMove) - ms_clickToMove = false; - ms_mouseMoveInClient = true; - ms_focused = true; - ms_wasFocusLost = true; - - if (ms_acquiredFocusHookFunction) - ms_acquiredFocusHookFunction(); - if (ms_acquiredFocusHookFunction2) - ms_acquiredFocusHookFunction2(); - } - else - { - ClipCursor(NULL); - ms_focused = false; - if (ms_lostFocusHookFunction) - ms_lostFocusHookFunction(); - } - } - break; - - case WM_ACTIVATEAPP: - if (wParam == FALSE) - { - ClipCursor(NULL); - ms_focused = false; - if (ms_lostFocusHookFunction) - ms_lostFocusHookFunction(); - } - break; - - case WM_DISPLAYCHANGE: - if (ms_displayModeChangedHookFunction) - ms_displayModeChangedHookFunction(); - break; - - default: - break; - } - - return DefWindowProc(hwnd, uMsg, wParam, lParam); -} - -// ---------------------------------------------------------------------- - -void OsNamespace::updateMousePosition(int x, int y) -{ - if (ms_setSystemMouseCursorPositionHookFunction) - ms_setSystemMouseCursorPositionHookFunction(x, y); - - if (ms_setSystemMouseCursorPositionHookFunction2) - ms_setSystemMouseCursorPositionHookFunction2(x, y); -} - -// ---------------------------------------------------------------------- -/** - * Get an identifier indicating which thread called this function. - */ - -Os::ThreadId Os::getThreadId() -{ - return GetCurrentThreadId(); -} - -// ---------------------------------------------------------------------- -/** - * Get the actual system time, in seconds since the epoch. - * - * Do not use this for most game systems, since it does not take into account - * clock sku, game loop times, etc. - */ -time_t Os::getRealSystemTime() -{ - return time(0); -} - -// ---------------------------------------------------------------------- -/** - * Convert a time in seconds since the epoch to GMT. - * - */ - -void Os::convertTimeToGMT(const time_t &convertTime, tm &zulu) -{ - zulu=*gmtime(&convertTime); // gmtime uses a single static tm structure. Yuck! -} - -// ---------------------------------------------------------------------- -/** - * Convert a tm structure to the time in seconds since the epoch. - * - */ - -time_t Os::convertGMTToTime(const tm &zulu) -{ - return mktime(const_cast(&zulu)); -} - -// ---------------------------------------------------------------------- -/** - * Cause the current thread to suspend for a period of time. Zero delay indicates - * to yield the current time slice. - */ - -void Os::sleep(int ms) -{ - ::Sleep(static_cast(ms)); -} - -// ---------------------------------------------------------------------- -/** - * Assign the given thread a reasonable name (only works for MSDev 6.0 debugger) - * Max 9 characters - * - */ - -void Os::setThreadName(ThreadId threadID, const char* threadName) -{ - //used to give threads reasonable names in the MSDev debugger, - //see http://www.vcdj.com/upload/free/features/vcdj/2001/03mar01/et0103/et0103.asp for more info - struct ThreadNameInfo - { - DWORD dwType; - LPCSTR szName; - DWORD dwThreadID; - DWORD dwFlags; - }; - - ThreadNameInfo info; - info.dwType = 0x1000; //must be this value - info.szName = threadName; - info.dwThreadID = threadID; - info.dwFlags = 0; //unused, reserved for future use - - __try - { - // use the magic exception number MS picked for this purpose - RaiseException(0x406D1388, 0, sizeof(info) / sizeof(DWORD), reinterpret_cast(&info)); - } - __except (EXCEPTION_CONTINUE_EXECUTION) - { - } -} - -// ---------------------------------------------------------------------- -/** - * Given a base directory and a full file pathname, find the relative path - * needed to get from the source directory to the target. - * - * This command is case sensitive. It does not care whether baseDirectory contains - * a trailing backslash or not. - * - * @param baseDirectory the base directory from which a relative path will be constructed. - * @param targetPathname the full pathname for the file for which we want to generate a relative path - * @param relativePath the string into which the constructed relative path will be returned - */ - -void Os::buildRelativePath(const char *baseDirectory, const char *targetPathname, std::string &relativePath) -{ - NOT_NULL(baseDirectory); - DEBUG_FATAL(!targetPathname || !*targetPathname, ("bad targetPathname, must be non-zero length")); - - const char directorySeparator = '\\'; - const char *const backupDirectoryString = "..\\"; - - std::string workingBaseDirectory(baseDirectory); - - //-- ensure base directory ends in directory separator - if (workingBaseDirectory[workingBaseDirectory.length()-1] != directorySeparator) - workingBaseDirectory += directorySeparator; - - //-- grab the target directory - std::string workingTargetDirectory; - - const char *endOfDirectory = strrchr(targetPathname, static_cast(directorySeparator)); - if (endOfDirectory) - IGNORE_RETURN(workingTargetDirectory.append(targetPathname, static_cast(endOfDirectory - targetPathname + 1))); - - //-- find count of character of match between directory strings - const size_t workingBaseDirectoryLength = workingBaseDirectory.length(); - const size_t workingTargetDirectoryLength = workingTargetDirectory.length(); - - size_t searchIndex = 0; - while ((searchIndex < workingBaseDirectoryLength) && (searchIndex < workingTargetDirectoryLength) && (workingBaseDirectory[searchIndex] == workingTargetDirectory[searchIndex])) - ++searchIndex; - - size_t matchCount = searchIndex; - - //-- if we match into the middle of a directory, back up until the previous directory - if ((matchCount > 0) && (workingBaseDirectory[matchCount - 1] != directorySeparator)) - { - do - { - --matchCount; - } while ((matchCount > 0) && (workingBaseDirectory[matchCount - 1] != directorySeparator)); - } - - //-- if we have no match between directories, the best path is the full path. - if (matchCount < 1) - { - relativePath = targetPathname; - return; - } - - //-- for each directory in base directory not matched, insert a "backup directory" string - relativePath.clear(); - { - for (size_t i = matchCount; i < workingBaseDirectoryLength; ++i) - if (workingBaseDirectory[i] == directorySeparator) - IGNORE_RETURN(relativePath.append(backupDirectoryString)); - } - - //-- for each directory in the target directory not matched, append to result. - // this works out to copying from the match point forward in the target path. - IGNORE_RETURN(relativePath.append(targetPathname + matchCount)); -} - -// ---------------------------------------------------------------------- -/** - * Convert a relative path to an absolute path. - */ -bool Os::getAbsolutePath(const char *relativePath, char *absolutePath, int absolutePathBufferSize) -{ - if (_fullpath(absolutePath, relativePath, static_cast(absolutePathBufferSize)) == NULL) - return false; - - // convert the slashes to be forwards - for (char *convert = absolutePath; *convert; ++convert) - if (*convert == '\\') - *convert = '/'; - - return true; -} - -// ---------------------------------------------------------------------- -/** - * Copy text to the system clipboard. - * - * This routine can be used if the application wants to make some data easily available for pasting (like crash call stacks). - */ - -bool Os::copyTextToClipboard(const char *text) -{ - if (!OpenClipboard(ms_window)) - return false; - - if (!EmptyClipboard()) - return false; - - // need to convert to cr/lf sequences. yuck. - int length = 1; - for (const char *t2 = text; *t2; ++t2, ++length) - { - if (*t2 == '\n') - ++length; - } - - HANDLE memoryHandle = GlobalAlloc(GMEM_MOVEABLE, length); - if (memoryHandle == NULL) - { - CloseClipboard(); - return FALSE; - } - - // lock the handle and copy the text to the buffer. - char *destination = reinterpret_cast(GlobalLock(memoryHandle)); - while (*text) - { - if (*text == '\n') - *(destination++) = '\r'; - *destination++ = *text++; - } - - if (GlobalUnlock(memoryHandle) != 0 || GetLastError() != NO_ERROR) - { - IGNORE_RETURN(GlobalFree(memoryHandle)); - return false; - } - - if (!SetClipboardData(CF_TEXT, memoryHandle)) - return false; - - if (!CloseClipboard()) - return false; - - return true; -} - -// ---------------------------------------------------------------------- - -bool Os::getUserName(char *buffer, int &bufferSize) -{ - NOT_NULL(buffer); - DWORD windowsBufferSize = static_cast(bufferSize); - buffer[0] = '\0'; - bool result = GetUserName(buffer, &windowsBufferSize) == TRUE; - return result; -} - -//----------------------------------------------------------------------- - -Os::OsPID_t Os::getProcessId() -{ - return static_cast(GetCurrentProcessId()); -} - -//---------------------------------------------------------------------- - -bool Os::isFocused() -{ - return ms_focused; -} - -//---------------------------------------------------------------------- - -bool Os::launchBrowser(std::string const & website) -{ - std::string URL("http://"); - if (strncmp(URL.c_str(), website.c_str(),7)!=0) - URL+=website; - else - URL=website; - int result = reinterpret_cast(ShellExecute(NULL, "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL)); - return (result > 32); -} - - -// ====================================================================== diff --git a/engine/shared/library/sharedFoundation/src/win32/Os.h b/engine/shared/library/sharedFoundation/src/win32/Os.h deleted file mode 100755 index afb3be40..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/Os.h +++ /dev/null @@ -1,152 +0,0 @@ -// ====================================================================== -// -// Os.h -// -// Portions copyright 1998 Bootprint Entertainment -// Portions copyright 2000-2002 Sony Online Entertainment -// All Rights Reserved -// -// ====================================================================== - -#ifndef INCLUDED_Os_H -#define INCLUDED_Os_H - -// ====================================================================== - -#include - -// ====================================================================== - -class Os -{ -public: - - typedef bool (*IsGdiVisibleHookFunction)(); - typedef void (*LostFocusHookFunction)(); - typedef void (*AcquiredFocusHookFunction)(); - typedef void (*QueueCharacterHookFunction)(int keyboard, int character); - typedef void (*SetSystemMouseCursorPositionHookFunction)(int x, int y); - typedef bool (*GetHardwareMouseCursorEnabled)(); - typedef void (*GetOtherAdapterRectsHookFunction)(stdvector::fwd &); - typedef void (*WindowPositionChangedHookFunction)(); - typedef void (*DisplayModeChangedHookFunction)(); - typedef void (*InputLanguageChangedHookFunction)(); - typedef int (*IMEHookFunction)(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - typedef void (*QueueKeyDownHookFunction)(int keyboard, int character); - - typedef uint ThreadId; - typedef DWORD OsPID_t; - - enum Priority - { - P_high, - P_normal, - P_low - }; - - enum - { - MAX_PATH_LENGTH = 512 - }; - -public: - - static void install(HINSTANCE newInstance, const char *windowName, HICON normalIcon, HICON smallIcon); - static void install(HWND newWindow, bool processMessagePump); - static void install(); - - static bool isGameOver(); - static DLLEXPORT bool isMainThread(); - static bool wasFocusLost(); - static void checkChildThreads(); - - static void setProcessPriority(Priority priority); - - static bool update(); - - static void returnFromAbort(); - static void abort(); - - static void enablePopupDebugMenu(); - static void requestPopupDebugMenu(); - - static bool createDirectories (const char *dirname); - - static bool writeFile(const char *fileName, const void *data, int length); - - static HWND getWindow(); - static bool engineOwnsWindow(); - - static int getNumberOfUpdates(); - - static char *getLastError(); - - static const char *getProgramName(); - static const char *getShortProgramName(); - static const char *getProgramStartupDirectory(); - - static void setIsGdiVisibleHookFunction(IsGdiVisibleHookFunction newGlIsGdiVisible); - static void setLostFocusHookFunction(LostFocusHookFunction lostFocusHookFunction); - static void setQueueCharacterHookFunction(QueueCharacterHookFunction queueCharacterHookFunction); - static void setSetSystemMouseCursorPositionHookFunction(SetSystemMouseCursorPositionHookFunction setSystemMouseCursorPositionHookFunction); - static void setSetSystemMouseCursorPositionHookFunction2(SetSystemMouseCursorPositionHookFunction setSystemMouseCursorPositionHookFunction); - static void setAcquiredFocusHookFunction(AcquiredFocusHookFunction acquiredFocusHookFunction); - static void setAcquiredFocusHookFunction2(AcquiredFocusHookFunction acquiredFocusHookFunction); - static void setGetHardwareMouseCursorEnabled(GetHardwareMouseCursorEnabled getHardwareMouseCursorEnabled); - static void setGetOtherAdapterRectsHookFunction(GetOtherAdapterRectsHookFunction getOtherAdapterRectsHookFunction); - static void setWindowPositionChangedHookFunction(WindowPositionChangedHookFunction windowPositionChangedHookFunction); - static void setDisplayModeChangedHookFunction(DisplayModeChangedHookFunction displayModeChangedHookFunction); - static void setInputLanguageChangedHookFunction(InputLanguageChangedHookFunction inputLanguageChangedHookFunction); - static void setIMEHookFunction(IMEHookFunction imeHookFunction); - static void setQueueKeyDownHookFunction(QueueKeyDownHookFunction queueKeyDownHookFunction); - - static DLLEXPORT ThreadId getThreadId(); - static void setThreadName(ThreadId threadID, const char* name); - - static void sleep(int ms); - - static time_t getRealSystemTime(); - static void convertTimeToGMT(const time_t &time, tm &zulu); - static time_t convertGMTToTime(const tm &zulu); - - static bool isMultiprocessor(); - static int getProcessorCount(); - - static void buildRelativePath(const char *baseDirectory, const char *targetPathname, std::string &relativePath); - static bool getAbsolutePath(const char *relativePath, char *absolutePath, int absolutePathBufferSize); - - static bool copyTextToClipboard(const char *text); - - static bool getUserName(char *buffer, int &bufferSize); - - static OsPID_t getProcessId(); - - static bool isFocused(); - - static bool launchBrowser(std::string const & website); - static bool isNumPadValue(unsigned char asciiChar); - static bool isNumPadChar(unsigned char asciiChar); - -private: - - Os(); - Os(const Os &); - Os &operator =(const Os &); - -private: - - static void remove(); - static void installCommon(); - - static LRESULT CALLBACK Os::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - -private: - -private: - - static bool handleDebugMenu(); -}; - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFoundation/src/win32/PerThreadData.cpp b/engine/shared/library/sharedFoundation/src/win32/PerThreadData.cpp deleted file mode 100755 index 7b2d0b58..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/PerThreadData.cpp +++ /dev/null @@ -1,465 +0,0 @@ -// ====================================================================== -// -// PerThreadData.cpp -// -// Portions copyright 1998 Bootprint Entertainment -// Portions Copyright 2002 Sony Online Entertainment -// All Rights Reserved -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/PerThreadData.h" - -#include "sharedSynchronization/RecursiveMutex.h" -#include "sharedSynchronization/Gate.h" - -#include "sharedFoundation/Os.h" - -#include -#include - -// ====================================================================== - -// ====================================================================== -namespace PerThreadDataNamespace -{ - struct Data - { - bool exitChainRunning; - bool exitChainFataling; - ExitChain::Entry *exitChainFirstEntry; - - int debugPrintFlags; - - Gate *fileStreamerReadGate; - - HANDLE watchHandle; - }; - - typedef std::vector DataAllocations; - - // ------------------------------------------------------ - - static char buffer1[sizeof(RecursiveMutex)]; - static char buffer2[sizeof(DataAllocations)]; - - static const DWORD BadSlot = 0xffffffff; - - static DWORD slot = BadSlot; - static RecursiveMutex *criticalSection; - static DataAllocations *dataAllocations; - - // ------------------------------------------------------ - - static void _threadRemove(Data *data); - static void _removeFromList(Data *data); - static void _watchThreads(); - - /*---------------------------------------------------------------------- - * Get access to the per-thread-data. - * - * This routine will verify the per-thread-data subsystem has been installed and the - * threadInstall() function has been called for the current thread. - * - * @return A pointer to the per-thread-data. - */ - inline static Data *_getData(bool allowReturnNull=false) - { - UNREF(allowReturnNull); - - if (slot == BadSlot) - { - DEBUG_FATAL(true && !allowReturnNull, ("not installed")); - return NULL; - } - - Data * const data = reinterpret_cast(TlsGetValue(slot)); - DEBUG_FATAL(!data && !allowReturnNull, ("not installed for this thread")); - return data; - } - - // ------------------------------------------------------ - - inline static void _closeData(Data *data) - { - if (data->fileStreamerReadGate) - { - delete data->fileStreamerReadGate; - data->fileStreamerReadGate=0; - } - if (data->watchHandle) - { - CloseHandle(data->watchHandle); - data->watchHandle=0; - } - } - - // ------------------------------------------------------ - - inline static void _freeData(Data *data) - { - delete data; - } - - // ------------------------------------------------------ -} -using namespace PerThreadDataNamespace; - -// ====================================================================== - -// ====================================================================== -// Install the per-thread-data subsystem -// -// Remarks: -// -// This routine will install the per-thread-data subsystem that is required for several -// other subsystems in the engine. It should be called from the primary thread before -// any other threads have been created. It will also call threadInstall() for the -// primary thread. -// -// See Also: -// -// PerThreadData::remove() - -void PerThreadData::install() -{ - slot = TlsAlloc(); - FATAL(slot == BadSlot, ("TlsAlloc failed")); - - criticalSection = new(buffer1) RecursiveMutex; - dataAllocations = new(buffer2) DataAllocations; - dataAllocations->reserve(8); - threadInstall(); -} - -// ---------------------------------------------------------------------- -/** - * Remove the per-thread-subsystem. - * - * This routine should be called by the primary thread after all other threads have - * terminated, and no other uses of per-thread-data will occur. - * - * @see PerThreadData::install() - */ -void PerThreadData::remove() -{ - criticalSection->enter(); - { - // remove this thread. - threadRemove(); - - // clean up after any threads which didn't clean up after themselves (like the miles sound system) - const DataAllocations::iterator iEnd = dataAllocations->end(); - for (DataAllocations::iterator i = dataAllocations->begin(); i != iEnd; ++i) - { - _closeData(*i); - _freeData(*i); - } - - dataAllocations->clear(); - } - criticalSection->leave(); - - criticalSection->~RecursiveMutex(); - dataAllocations->~vector(); - - memset(buffer1, 0, sizeof(buffer1)); - memset(buffer2, 0, sizeof(buffer2)); - - const BOOL result = TlsFree(slot); - FATAL(!result, ("TlsFree failed")); -} - -// ---------------------------------------------------------------------- -/** - * Create the per-thread-data for a new thread. - * - * This routine should be called in a thread before the first usage of per-thread-data. - * - * If the client is calling this function on a thread that existed before the engine was - * installed, the client should set isNewThread to false. Setting isNewThread to false - * prevents the function from validating that the thread's TLS is NULL. For threads existing - * before the engine is installed, the TLS data for the thread is undefined. - * - * @param isNewThread [IN] true if the thread was created after the engine was installed, false otherwise - * @see PerThreadData::threadRemove() - */ - -void PerThreadData::threadInstall(bool isNewThread) -{ - UNREF(isNewThread); - - DEBUG_FATAL(slot == BadSlot, ("not installed")); - - // only check for already-set data if this is supposed to be a new thread - DEBUG_FATAL(isNewThread && TlsGetValue(slot), ("already installed for this thread")); - - // create the data - Data * const data = new Data; - - // initialize the data - memset(data, 0, sizeof(*data)); - - //create the event for file streaming reads - data->fileStreamerReadGate = new Gate(false); - - // set the data into the thread slot - const BOOL result = TlsSetValue(slot, data); - UNREF(result); - DEBUG_FATAL(!result, ("TlsSetValue failed")); - - criticalSection->enter(); - { - _watchThreads(); - - dataAllocations->push_back(data); - - // This is most likely a thread created by a 3rd party library such as Miles or Bink. - // Add a watch handle to it so we can clean it up. - if (!isNewThread) - { - const HANDLE processHandle = GetCurrentProcess(); - DuplicateHandle(processHandle, GetCurrentThread(), processHandle, &data->watchHandle, 0, FALSE, DUPLICATE_SAME_ACCESS); - } - } - criticalSection->leave(); -} - -// ---------------------------------------------------------------------- - -void PerThreadDataNamespace::_removeFromList(Data *data) -{ - const DataAllocations::iterator iEnd = dataAllocations->end(); - const DataAllocations::iterator i = std::find(dataAllocations->begin(), iEnd, data); - if (i!=iEnd) - { - dataAllocations->erase(i); - } -} - -// ---------------------------------------------------------------------- -// Synchronization is left up to the user -// Unless this is called during shutdown, the critical section -// needs to be entered. -void PerThreadDataNamespace::_watchThreads() -{ - DataAllocations::iterator tiDest = dataAllocations->begin(); - DataAllocations::iterator tiSrc = tiDest; - DataAllocations::iterator tiEnd = dataAllocations->end(); - - while (tiSrc!=tiEnd) - { - Data *const data = *tiSrc; - const HANDLE h = data->watchHandle; - - if (h!=0 && WaitForSingleObject(h, 0)==WAIT_OBJECT_0) - { - _closeData(data); - _freeData(data); - } - else - { - *tiDest++=data; - } - ++tiSrc; - } - - if (tiSrc!=tiDest) - { - const int newSize = tiDest - dataAllocations->begin(); - dataAllocations->resize(newSize); - } -} - -// ---------------------------------------------------------------------- - -void PerThreadDataNamespace::_threadRemove(Data *data) -{ - //close the event used for file streaming reads - _closeData(data); - - _removeFromList(data); - - // free the memory - _freeData(data); -} - -// ---------------------------------------------------------------------- -/** - * Destroy the per-thread-data for a terminating thread. - * - * This routine should be called in a thread after the last usage of per-thread-data. - * - * @see PerThreadData::threadInstall() - */ - -void PerThreadData::threadRemove() -{ - DEBUG_FATAL(slot == BadSlot, ("not installed")); - DEBUG_FATAL(!TlsGetValue(slot), ("thread not installed")); - - // find our thread record and free the memory - criticalSection->enter(); - - _threadRemove(_getData()); - - // wipe the data in the thread slot - const BOOL result = TlsSetValue(slot, NULL); - UNREF(result); - DEBUG_FATAL(!result, ("TlsSetValue failed")); - - criticalSection->leave(); -} - -// ====================================================================== - -// ====================================================================== -// Determine if the per-thread-data is available for this thread -// -// Return value: -// -// True if the per-thread-data is installed correctly, false otherwise -// -// Remarks: -// -// This routine is not intended for general use; it should only be used by the ExitChain class. -// -// -TRF- looks like Win98 does not zero out a new TLS slot for -// threads existing at the time of slot creation. Thus, if you build a -// plugin that only initializes the engine the first time it is -// used, and other threads already exist in the app, those threads -// will contain bogus non-null data in the TLS slot. If the plugin really -// wants to do lazy initialization of the engine, it will need -// to handle calling PerThreadData::threadInstall() for all existing threads -// (except the thread that initialized the engine, which already -// has its PerThreadData::threadInstall() called). - -bool PerThreadData::isThreadInstalled() -{ - return (_getData(true) != NULL); -} - -// ---------------------------------------------------------------------- -/** - * Get the exit chain running flag value. - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * - * @return True if the exit chain is running, false otherwise. - * @see ExitChain::isRunning() - */ - -bool PerThreadData::getExitChainRunning() -{ - return _getData()->exitChainRunning; -} - -// ---------------------------------------------------------------------- -/** - * Set the exit chain running flag value. - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * - * @param newValue New value for the exit chain running flag - */ - -void PerThreadData::setExitChainRunning(bool newValue) -{ - _getData()->exitChainRunning = newValue; -} - -// ---------------------------------------------------------------------- -/** - * Get the exit chain fataling flag value. - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * - * @return True if the exit chain is fataling, false otherwise. - * @see ExitChain::isFataling() - */ - -bool PerThreadData::getExitChainFataling() -{ - return _getData()->exitChainFataling; -} - -// ---------------------------------------------------------------------- -/** - * Set the exit chain fataling flag value. - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * - * @param newValue New value for the exit chain fataling flag - */ - -void PerThreadData::setExitChainFataling(bool newValue) -{ - _getData()->exitChainFataling = newValue; -} - -// ---------------------------------------------------------------------- -/** - * Get the first entry for the exit chain. - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * This routine may return NULL. - * - * @return Pointer to the first entry on the exit chain - * @see ExitChain::isFataling() - */ - -ExitChain::Entry *PerThreadData::getExitChainFirstEntry() -{ - return _getData()->exitChainFirstEntry; -} - -// ---------------------------------------------------------------------- -/** - * Set the exit chain fataling flag value. - * - * This routine is not intended for general use; it should only be used by the ExitChain class. - * The parameter to this routine may be NULL. - * - * @param newValue New value for the exit chain first entry - */ - -void PerThreadData::setExitChainFirstEntry(ExitChain::Entry *newValue) -{ - _getData()->exitChainFirstEntry = newValue; -} - -// ---------------------------------------------------------------------- -/** - * Get the debug print flags. - * - * This routine is not intended for general use; it should only be used by the DebugPrint functions. - * - * @return Current value of the debug print flags - */ - -int PerThreadData::getDebugPrintFlags() -{ - return _getData()->debugPrintFlags; -} - -// ---------------------------------------------------------------------- -/** - * Set the debug print flags value. - * - * This routine is not intended for general use; it should only be used by the DebugPrint functions. - */ - -void PerThreadData::setDebugPrintFlags(int newValue) -{ - _getData()->debugPrintFlags = newValue; -} - -// ---------------------------------------------------------------------- - -Gate *PerThreadData::getFileStreamerReadGate() -{ - return _getData()->fileStreamerReadGate; -} - -// ====================================================================== diff --git a/engine/shared/library/sharedFoundation/src/win32/PerThreadData.h b/engine/shared/library/sharedFoundation/src/win32/PerThreadData.h deleted file mode 100755 index e45a4170..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/PerThreadData.h +++ /dev/null @@ -1,57 +0,0 @@ -// ====================================================================== -// -// PerThreadData.h -// -// Portions copyright 1998 Bootprint Entertainment -// Portions Copyright 2002 Sony Online Entertainment -// All Rights Reserved -// -// ====================================================================== - -#ifndef INCLUDED_PerThreadData_H -#define INCLUDED_PerThreadData_H - -// ====================================================================== - -class Gate; - -#include "sharedFoundation/ExitChain.h" - -// ====================================================================== - -// Provide thread local storage functionality. -// -// This class' purpose is to allow each thread to maintain some storage that is local and private to each thread. -// The system must be installed before use. Each thread that may use per-thread-data will also need to call the -// threadInstall() routine after creation and threadRemove() just before termination of the thread. - -class PerThreadData -{ -public: - - static void install(void); - static void remove(void); - - static void threadInstall(bool isNewThread = true); - static void threadRemove(void); - - static bool isThreadInstalled(void); - - static bool getExitChainRunning(void); - static void setExitChainRunning(bool newValue); - - static bool getExitChainFataling(void); - static void setExitChainFataling(bool newValue); - - static ExitChain::Entry *getExitChainFirstEntry(void); - static void setExitChainFirstEntry(ExitChain::Entry *newValue); - - static int getDebugPrintFlags(void); - static void setDebugPrintFlags(int newValue); - - static Gate *getFileStreamerReadGate(void); -}; - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFoundation/src/win32/PlatformGlue.cpp b/engine/shared/library/sharedFoundation/src/win32/PlatformGlue.cpp deleted file mode 100755 index cf562e00..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/PlatformGlue.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// ====================================================================== -// -// PlatformGlue.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/PlatformGlue.h" - -#include -#include - -// ====================================================================== - -namespace -{ - -// ---------------------------------------------------------------------- - -class GmTimeSection -{ -public: - - GmTimeSection() - { - InitializeCriticalSection(&m_section); - } - - ~GmTimeSection() - { - DeleteCriticalSection(&m_section); - } - - void enter() - { - EnterCriticalSection(&m_section); - } - - void leave() - { - LeaveCriticalSection(&m_section); - } - -private: - CRITICAL_SECTION m_section; -}; - -// ---------------------------------------------------------------------- - -static GmTimeSection s_gmTimeSection; - -// ---------------------------------------------------------------------- - -} - -// ====================================================================== -// Tokenizing a string. -// Like strtok, except re-entrant. - -char *strsep(char **string, const char *delim) -{ - char *result = *string; - - // handle no string specified, or the end of the string - if (result == 0) - return 0; - - // skip leading delimiters - result = result + strspn(result, delim); - - // handle trailing delimiters - if (*result == '\0') - return 0; - - // look for the first delimiter - const int len = strcspn(result, delim); - if (result[len] == '\0') - { - // hit the end of the string - *string = 0; - } - else - { - // terminate the string and return the substring - result[len] = '\0'; - *string = result + len + 1; - } - - return result; -} - -// ---------------------------------------------------------------------- - -int snprintf(char *buffer, size_t count, const char *format, ...) -{ - va_list va; - - va_start(va, format); - const int result = _vsnprintf(buffer, count, format, va); - va_end(va); - - return result; -} - -// ---------------------------------------------------------------------- - -struct tm *gmtime_r(const time_t *timep, struct tm *result) -{ - s_gmTimeSection.enter(); - tm *t = gmtime(timep); - *result = *t; - s_gmTimeSection.leave(); - return result; -} - -// ---------------------------------------------------------------------- - -int finite(double value) -{ - return _finite(value); -} - -// ====================================================================== diff --git a/engine/shared/library/sharedFoundation/src/win32/PlatformGlue.h b/engine/shared/library/sharedFoundation/src/win32/PlatformGlue.h deleted file mode 100755 index 7eec7bb5..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/PlatformGlue.h +++ /dev/null @@ -1,32 +0,0 @@ -// ====================================================================== -// -// PlatformGlue.h -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_PlatformGlue_H -#define INCLUDED_PlatformGlue_H - -// ====================================================================== - -#include - -// ====================================================================== - -char * strsep(char **string, const char *delim); -int snprintf(char *buffer, size_t count, const char *format, ...); -struct tm * gmtime_r(const time_t *timep, struct tm *result); -int finite(double value); - -//Format specifier for non-portable printf -#define UINT64_FORMAT_SPECIFIER "%I64u" -#define INT64_FORMAT_SPECIFIER "%I64i" - -//Constant definition macro for 64 bit values -#define UINT64_LITERAL(a) a ## ui64 -#define INT64_LITERAL(a) a ## i64 - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFoundation/src/win32/ProcessSpawner.cpp b/engine/shared/library/sharedFoundation/src/win32/ProcessSpawner.cpp deleted file mode 100755 index 987e9b64..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/ProcessSpawner.cpp +++ /dev/null @@ -1,310 +0,0 @@ -// -// ProcessSpawner.cpp -// -//------------------------------------------------------------------- - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/ProcessSpawner.h" - -#include "sharedFoundation/Os.h" - -#include - -ProcessSpawner::ProcessSpawner() -{ - m_asConsole=false; - hProcess=0; - hOutputRead=0; - hInputWrite=0; - currentLine=currentRead=readBuffer; -} - - -ProcessSpawner::~ProcessSpawner() -{ - if (hProcess) - { - CloseHandle(hProcess); - hProcess=0; - } - if (hOutputRead) - { - CloseHandle(hOutputRead); - hOutputRead=0; - } - if (hInputWrite) - { - CloseHandle(hInputWrite); - hInputWrite=0; - } -} - -bool ProcessSpawner::terminate(unsigned exitCode) -{ - if (!hProcess) - { - return false; - } - return TerminateProcess(hProcess, exitCode)!=0; -} - -bool ProcessSpawner::create(const char *commandLine, const char *startupFolder, bool asConsole) -{ - if (hProcess) - { - return false; - } - - if (!commandLine) - { - return false; - } - - if (!startupFolder) - { - startupFolder=Os::getProgramStartupDirectory(); - } - - m_asConsole=asConsole; - - STARTUPINFO sinfo; - memset(&sinfo, 0, sizeof(sinfo)); - sinfo.cb=sizeof(sinfo); - - HANDLE hOutputWrite=0; - HANDLE hErrorWrite=0; - HANDLE hInputRead=0; - - if (asConsole) - { - SECURITY_ATTRIBUTES sa; - sa.nLength=sizeof(sa); - sa.lpSecurityDescriptor=0; - sa.bInheritHandle=true; - - // ----------------------------------------------------- - - // Create the child output pipe. - HANDLE hOutputReadTmp; - CreatePipe(&hOutputReadTmp,&hOutputWrite,&sa,0); - - // Create a duplicate of the output write handle for the std error - // write handle. This is necessary in case the child application - // closes one of its std output handles. - DuplicateHandle( - GetCurrentProcess(), hOutputWrite, - GetCurrentProcess(),&hErrorWrite, - 0, - TRUE,DUPLICATE_SAME_ACCESS - ); - - - // Create the child input pipe. - HANDLE hInputWriteTmp; - CreatePipe(&hInputRead,&hInputWriteTmp,&sa,0); - - // Create new output read handle and the input write handles. Set - // the Properties to FALSE. Otherwise, the child inherits the - // properties and, as a result, non-closeable handles to the pipes - // are created. - DuplicateHandle( - GetCurrentProcess(), hOutputReadTmp, - GetCurrentProcess(), &hOutputRead, // Address of new handle. - 0, FALSE, // Make it uninheritable. - DUPLICATE_SAME_ACCESS - ); - - DuplicateHandle( - GetCurrentProcess(), hInputWriteTmp, - GetCurrentProcess(), &hInputWrite, // Address of new handle. - 0,FALSE, // Make it uninheritable. - DUPLICATE_SAME_ACCESS - ); - - - // Close inheritable copies of the handles you do not want to be - // inherited. - CloseHandle(hOutputReadTmp); hOutputReadTmp=0; - CloseHandle(hInputWriteTmp); hInputWriteTmp=0; - - sinfo.dwFlags|=(STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW); - sinfo.hStdError=hErrorWrite; - sinfo.hStdInput=hInputRead; - sinfo.hStdOutput=hOutputWrite; - sinfo.wShowWindow = SW_HIDE; - } - - PROCESS_INFORMATION pinfo; - BOOL result = CreateProcess( - 0, - (char *)commandLine, - 0, - 0, - TRUE, - CREATE_NEW_CONSOLE, - 0, - startupFolder, - &sinfo, - &pinfo - ); - - if (asConsole) - { - // Close pipe handles (do not continue to modify the parent). - // You need to make sure that no handles to the write end of the - // output pipe are maintained in this process or else the pipe will - // not close when the child process exits and the ReadFile will hang. - CloseHandle(hOutputWrite); hOutputWrite=0; - CloseHandle(hErrorWrite); hErrorWrite=0; - CloseHandle(hInputRead); hInputRead=0; - } - - if (result) - { - CloseHandle(pinfo.hThread); - hProcess=pinfo.hProcess; - return true; - } - else - { - // Failed to launch turf - hProcess=0; - return false; - } -} - -bool ProcessSpawner::isFinished(unsigned waitTime) -{ - if (!hProcess) - { - return true; - } - - DWORD waitResult = WaitForSingleObject(hProcess, waitTime); - - return waitResult==WAIT_OBJECT_0; -} - -bool ProcessSpawner::getExitCode(unsigned &o_code) -{ - if (!hProcess) - { - return false; - } - - DWORD exitCode; - BOOL result = GetExitCodeProcess(hProcess, &exitCode); - if (result) - { - o_code=exitCode; - return true; - } - else - { - return false; - } -} - -bool ProcessSpawner::_returnExistingLine(char *buffer, const int bufferSize) -{ - const char *const bufferStop = buffer + bufferSize; - char *iter = currentLine; - while (iter!=currentRead) - { - if (buffer==bufferStop) - { - currentLine=iter; - return true; - } - - if (*iter=='\n') - { - *buffer++=0; - _stepIter(iter); - currentLine=iter; - return true; - } - else - { - *buffer++=*iter; - _stepIter(iter); - } - } - - return false; -} - -bool ProcessSpawner::getOutputString(char *buffer, int bufferSize) -{ - if (_returnExistingLine(buffer, bufferSize)) - { - return true; - } - - // ---------------------------------------------- - - if (!hOutputRead) - { - return false; - } - - DWORD dwAvail = 0; - if (!::PeekNamedPipe(hOutputRead, NULL, 0, NULL, &dwAvail, NULL)) - { - // ERROR - return false; - } - - if (!dwAvail) - { - return false; - } - - DWORD dwRead; - - if (currentRead >= currentLine) - { - const unsigned bufferAvailable = sizeof(readBuffer) - (currentRead - readBuffer); - unsigned toRead = dwAvail; - if (toRead > bufferAvailable) - { - toRead=bufferAvailable; - } - - dwRead=0; - if (!::ReadFile(hOutputRead, currentRead, min(bufferAvailable, dwAvail), &dwRead, NULL) || !dwRead) - { - return false; - } - dwAvail-=dwRead; - currentRead+=dwRead; - if (currentRead==readBuffer+sizeof(readBuffer)) - { - currentRead=readBuffer; - } - } - - if (dwAvail>0) - { - const unsigned bufferAvailable = currentLine - currentRead - 1; - if (bufferAvailable) - { - unsigned toRead = dwAvail; - if (toRead > bufferAvailable) - { - toRead=bufferAvailable; - } - - dwRead=0; - if (!::ReadFile(hOutputRead, currentRead, min(bufferAvailable, dwAvail), &dwRead, NULL) || !dwRead) - { - return false; - } - currentRead+=dwRead; - - DEBUG_FATAL(currentRead>=currentLine, ("")); - } - } - - return _returnExistingLine(buffer, bufferSize); -} diff --git a/engine/shared/library/sharedFoundation/src/win32/ProcessSpawner.h b/engine/shared/library/sharedFoundation/src/win32/ProcessSpawner.h deleted file mode 100755 index ed64750f..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/ProcessSpawner.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef INCLUDED_ProcessSpawner_H -#define INCLUDED_ProcessSpawner_H - -class ProcessSpawner -{ -public: - - ProcessSpawner(); - ~ProcessSpawner(); - - bool create(const char *commandLine, const char *startupFolder=0, bool asConsole=true); - - bool terminate(unsigned exitCode=0); - bool isFinished(unsigned waitTime=0); - bool getExitCode(unsigned &o_code); - - bool getOutputString(char *buffer, int bufferSize); - -protected: - - bool _returnExistingLine(char *buffer, int bufferSize); - - void _stepIter(char *&i) - { - if (i==readBuffer+sizeof(readBuffer)-1) - { - i=readBuffer; - } - else - { - i++; - } - } - - HANDLE hProcess; - HANDLE hOutputRead, hInputWrite; - bool m_asConsole; - char *currentLine, *currentRead, readBuffer[4096]; -}; - -#endif - - diff --git a/engine/shared/library/sharedFoundation/src/win32/RegistryKey.cpp b/engine/shared/library/sharedFoundation/src/win32/RegistryKey.cpp deleted file mode 100755 index a29d0db5..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/RegistryKey.cpp +++ /dev/null @@ -1,918 +0,0 @@ -// ====================================================================== -// -// RegistryKey.cpp -// Todd Fiala -// -// copyright 1998 Bootprint Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/RegistryKey.h" - -#include "sharedFoundation/ExitChain.h" -#include "sharedFoundation/ConfigFile.h" - -#if USE_REGISTRY_EXECUTION_STATISTICS -#include -#include -#endif - -// ====================================================================== - -// keyname for config file parameter containing relative registry path -// for the product - -const char * const RegistryKey::PRODUCT_REGISTRY_PATH_KEYNAME = "ProductRegistryPath"; -const char * const RegistryKey::DEFAULT_PRODUCT_REGISTRY_PATH = "Software\\Sony Online Entertainment\\Default"; - -#if USE_REGISTRY_EXECUTION_STATISTICS -const char * const RegistryKey::STATISTICS_KEYNAME = "Statistics"; -const char * const RegistryKey::STAT_EXEC_STARTED_COUNT_VALUENAME = "StartedExecutions"; -const char * const RegistryKey::STAT_EXEC_INCOMPLETE_COUNT_VALUENAME = "IncompleteExecutions"; -const char * const RegistryKey::STAT_TIME_AVERAGE_VALUENAME = "AverageClockTime"; -const char * const RegistryKey::STAT_TIME_MIN_VALUENAME = "MinimumClockTime"; -const char * const RegistryKey::STAT_TIME_MAX_VALUENAME = "MaximumClockTime"; -const char * const RegistryKey::STAT_TIME_START_VALUENAME = "StartClockTime"; - -#endif - -bool RegistryKey::installed; -bool RegistryKey::setProductKeyPathFromConfig; - -RegistryKey *RegistryKey::usersKey; -RegistryKey *RegistryKey::currentUserKey; -RegistryKey *RegistryKey::classRootKey; -RegistryKey *RegistryKey::localMachineKey; -RegistryKey *RegistryKey::productUserKey; -RegistryKey *RegistryKey::productMachineKey; - -// ====================================================================== -// construct a RegistryKey instance -// -// Remarks: -// This function does not create the underlying registry object. It -// solely attaches such a registry object with a RegistryKey class -// instance. - -RegistryKey::RegistryKey( - HKEY newKeyHandle, // [IN] handle of existing registry key - bool newCloseKeyOnDestroy // [IN] true if RegCloseKey() should be called on key at destruction time - ) : - keyHandle(newKeyHandle), - closeKeyOnDestroy(newCloseKeyOnDestroy) -{ - // -qq- don't know which of these indicates an invalid handle, so check for both - DEBUG_FATAL(!newKeyHandle, ("null newKeyHandle arg")); - DEBUG_FATAL(newKeyHandle == INVALID_HANDLE_VALUE, ("newKeyHandle arg is an invalid handle")); -} - -// ---------------------------------------------------------------------- -/** - * destroy a RegistryKey instance. - */ - -RegistryKey::~RegistryKey(void) -{ - DEBUG_FATAL(!keyHandle, ("null keyHandle")); - - if (closeKeyOnDestroy) - { - const LONG result = RegCloseKey(keyHandle); - UNREF(result); - DEBUG_FATAL(result != ERROR_SUCCESS, ("failed to close registry key, error = %ld\n", result)); - } - keyHandle = 0; -} - -// ---------------------------------------------------------------------- -/** - * enumerate all child subkeys of the current key. - * - * @param context [IN] user-specified context variable passed to callback - * @param callback [IN] function to call for each subkey enumerated - * @see EnumerateKeyCallback, enumerateValues() - */ - -void RegistryKey::enumerateSubkeys(void *context, EnumerateKeyCallback callback) const -{ - const size_t MAX_NAME_LENGTH = 256; - - LONG result; - FILETIME lastModifiedFileTime; - char subkeyName[MAX_NAME_LENGTH]; - DWORD subkeyNameLength; - DWORD index; - - DEBUG_FATAL(!callback, ("null callback arg\n")); - - for ( - index = 0, subkeyNameLength = MAX_NAME_LENGTH; - ERROR_SUCCESS == (result = RegEnumKeyEx(keyHandle, index, subkeyName, &subkeyNameLength, 0, 0, 0, &lastModifiedFileTime)); - ++index, subkeyNameLength = MAX_NAME_LENGTH - ) - { - bool continueEnum = callback(context, subkeyName, &lastModifiedFileTime); - if (!continueEnum) break; - } - - // ensure we finished enumeration cleanly - FATAL( - (result != ERROR_SUCCESS) && (result != ERROR_NO_MORE_ITEMS), - ("failed to enumerate registry subkeys, error = %ld\n", result)); -} - -// ---------------------------------------------------------------------- -/** - * open and return a subkey under this RegistryKey instance. - * - * The function will fail if the specified subkey does not exist. - * - * @param subkeyName [IN] registry path for subkey to open, relative to this RegistryKey instance - * @param accessFlags [IN] flags indicating access granted to the returned RegistryKey - * @return This function returns a RegistryKey instance for the specified - * subkey. - */ - -RegistryKey *RegistryKey::openSubkey(const char *subkeyName, uint32 accessFlags) const -{ - REGSAM samDesired = 0; - LONG result; - HKEY newKey = 0; - - DEBUG_FATAL(!keyHandle, ("null keyHandle")); - DEBUG_FATAL(!subkeyName, ("null subkeyName arg")); - DEBUG_FATAL(!strlen(subkeyName), ("zero-length subkeyName arg")); - - // configure security access desired - if (accessFlags & AF_READ) - samDesired |= KEY_READ; - if (accessFlags & AF_WRITE) - samDesired |= KEY_WRITE; - - // open the key - result = RegOpenKeyEx(keyHandle, subkeyName, 0, samDesired, &newKey); - FATAL(result != ERROR_SUCCESS, ("failed to open registry subkey \"%s\", error = %ld\n", subkeyName, result)); - - // Create the RegistryKey object. Assume the key must be closed upon - // destruction. - return new RegistryKey(newKey, true); -} - -// ---------------------------------------------------------------------- -/** - * create and return a subkey under this RegistryKey instance. - * - * The function will succeed even if the specified subkey - * already exists. - * - * @return This function returns a RegistryKey instance for the specified - * subkey. - */ - -RegistryKey *RegistryKey::createSubkey(const char *subkeyName, uint32 accessFlags) const -{ - REGSAM samDesired = 0; - LONG result; - HKEY newKey = 0; - DWORD disposition; - - DEBUG_FATAL(!keyHandle, ("null keyHandle")); - DEBUG_FATAL(!subkeyName, ("null subkeyName arg")); - DEBUG_FATAL(!strlen(subkeyName), ("zero-length subkeyName arg")); - - // configure security access desired - if (accessFlags & AF_READ) - samDesired |= KEY_READ; - if (accessFlags & AF_WRITE) - samDesired |= KEY_WRITE; - - // open the key - result = RegCreateKeyEx( - keyHandle, - subkeyName, - 0, // reserved - const_cast(""), // class - REG_OPTION_NON_VOLATILE, // options - samDesired, - NULL, // security - &newKey, - &disposition); - FATAL(result != ERROR_SUCCESS, ("failed to create registry subkey \"%s\", error = %ld\n", subkeyName, result)); - - // Create the RegistryKey object. Assume the key must be closed upon - // destruction. - return new RegistryKey(newKey, true); -} - -// ---------------------------------------------------------------------- -/** - * delete a subkey relative to this RegistryKey instance. - * - * Under Windows NT, deleting a key that has subkeys is considered an - * error. Therefore, the client should ensure the target key for - * deletion does not have any subkeys. (Under Windows 9X, deletion of - * the target registry key will automatically delete all subkeys - * underneath the target key.) - */ - -void RegistryKey::deleteSubkey(const char *subkeyName) -{ - DEBUG_FATAL(!keyHandle, ("null keyHandle")); - DEBUG_FATAL(!subkeyName, ("null subkeyName arg")); - DEBUG_FATAL(!strlen(subkeyName), ("zero-length subkeyName arg")); - - IGNORE_RETURN(RegDeleteKey(keyHandle, subkeyName)); -} - -// ---------------------------------------------------------------------- -/** - * test for the existence of a subkey under this RegistryKey instance. - * - * @param subkeyName [IN] registry path for subkey to open, relative to this RegistryKey instance - */ - -bool RegistryKey::subKeyExists(const char *subkeyName) -{ - REGSAM samDesired = KEY_READ; - LONG result; - HKEY newKey = 0; - - DEBUG_FATAL(!keyHandle, ("null keyHandle")); - DEBUG_FATAL(!subkeyName, ("null subkeyName arg")); - DEBUG_FATAL(!strlen(subkeyName), ("zero-length subkeyName arg")); - - // open the key - result = RegOpenKeyEx(keyHandle, subkeyName, 0, samDesired, &newKey); - return (result == ERROR_SUCCESS); -} - -// ---------------------------------------------------------------------- -/** - * enumerate all values under the current key. - * - * @param context [IN] user-specified context variable passed to callback - * @param callback [IN] function to call for each value enumerated - * @see EnumerateValueCallback, enumerateSubkeys() - */ - -void RegistryKey::enumerateValues(void *context, EnumerateValueCallback callback) const -{ - const size_t MAX_NAME_LENGTH = 256; - - LONG result; - char valueName[MAX_NAME_LENGTH]; - DWORD valueNameLength; - DWORD index; - DWORD dataSize; - DWORD valueType; - - DEBUG_FATAL(!callback, ("null callback arg\n")); - - for ( - index = 0, valueNameLength = MAX_NAME_LENGTH, dataSize = 0; - ERROR_SUCCESS == (result = RegEnumValue(keyHandle, index, valueName, &valueNameLength, 0, &valueType, 0, &dataSize)); - ++index, valueNameLength = MAX_NAME_LENGTH, dataSize = 0 - ) - { - bool continueEnum = callback(context, valueName, static_cast(dataSize), valueType); - if (!continueEnum) break; - } - - // ensure we finished enumeration cleanly - FATAL( - (result != ERROR_SUCCESS) && (result != ERROR_NO_MORE_ITEMS), - ("failed to enumerate registry values, error = %ld\n", result)); -} - -// ---------------------------------------------------------------------- -/** - * query if a value exists and how many bytes that value occupies. - * - * The client does can pass null for the valueSize and/or valueType - * parameter if that information is not desired. The value returned - * within the valueSize and valueType parameter is only valid - * if the doesExist parameter is set to true upon function return. - * The value of the valueType parameter is one of the Windows-defined - * REG_* constants provided for use with the Win32 Reg* registry - * API. Common values are REG_BINARY (binary data), REG_DWORD - * (unsigned integral type data) and REG_SZ (C-style zero-terminated - * strings). Consult the Win32 documentation for RegGetValueEx() - * for a description of all the type constants. - * - * @param valueName [IN] name of the value to query - * @param doesExist [OUT] true if value exists under this key, false otherwise - * @param valueSize [OUT] number of bytes occupied by value's data - * @param valueType [OUT] type flag for registry value (see REG_* in RegSetValueEx()) - */ - -void RegistryKey::getValueInfo(const char *valueName, bool *doesExist, uint32 *valueSize, DWORD *valueType) const -{ - LONG result; - DWORD dwSize = 0; - - DEBUG_FATAL(!keyHandle, ("null keyHandle")); - DEBUG_FATAL(!valueName, ("null valueName arg")); - DEBUG_FATAL(!doesExist, ("null doesExist arg")); - DEBUG_FATAL(!strlen(valueName), ("zero-length valueName arg")); - - // get information on the value - result = RegQueryValueEx(keyHandle, valueName, 0, valueType, 0, &dwSize); - - // assume a query failure indicates the value was not found - *doesExist = (result == ERROR_SUCCESS); - if (valueSize) - *valueSize = static_cast(dwSize); -} - -// ---------------------------------------------------------------------- -/** - * set the data for this key's value. - * - * The value of the valueType parameter is one of the Windows-defined - * REG_* constants provided for use with the Win32 Reg* registry - * API. Common values are REG_BINARY (binary data), REG_DWORD - * (unsigned integral type data) and REG_SZ (C-style zero-terminated - * strings). Consult the Win32 documentation for RegGetValueEx() - * for a description of all the type constants. - * - * @param valueName [IN] name of value under which data will be stored - * @param dataPtr [IN] pointer to buffer containing value's data - * @param dataSize [IN] # bytes to store - * @param valueType [IN] type field for value (indicates nature of data stored with value) - */ - -void RegistryKey::setValue(const char *valueName, const void *dataPtr, uint32 dataSize, DWORD valueType) -{ - LONG result; - - DEBUG_FATAL(!keyHandle, ("null keyHandle")); - DEBUG_FATAL(!valueName, ("null valueName arg")); - DEBUG_FATAL(!strlen(valueName), ("zero-length valueName arg")); - DEBUG_FATAL(!dataPtr, ("null dataPtr arg")); - - // get information on the value - result = RegSetValueEx(keyHandle, valueName, 0, valueType, static_cast(dataPtr), static_cast(dataSize)); - FATAL(result != ERROR_SUCCESS, ("failed to set registry value \"%s\", error = %ld\n", valueName, result)); -} - -// ---------------------------------------------------------------------- -/** - * retrieve the data for the this key's value. - * - * The valueType and/or the valueDataSize parameter may be set - * to null if the client doesn't need this information. - * The value of the valueType parameter is one of the Windows-defined - * REG_* constants provided for use with the Win32 Reg* registry - * API. Common values are REG_BINARY (binary data), REG_DWORD - * (unsigned integral type data) and REG_SZ (C-style zero-terminated - * strings). Consult the Win32 documentation for RegGetValueEx() - * for a description of all the type constants. - * - * @param valueName [IN] the name of the value to retrieve - * @param dataPtr [OUT] the buffer where the value's data will be stored - * @param maxDataSize [IN] size of the data buffer in bytes - * @param valueDataSize [OUT] number of bytes retrieved from the named value - * @param valueType [OUT] type field for value's data (see REG_* codes in RegSetValueEx) - */ - -void RegistryKey::getValue(const char *valueName, void *dataPtr, uint32 maxDataSize, uint32 *valueDataSize, DWORD *valueType) const -{ - LONG result; - DWORD dwSize = maxDataSize; - - DEBUG_FATAL(!keyHandle, ("null keyHandle")); - DEBUG_FATAL(!valueName, ("null valueName arg")); - DEBUG_FATAL(!strlen(valueName), ("zero-length valueName arg")); - - // get information on the value - result = RegQueryValueEx(keyHandle, valueName, 0, valueType, static_cast(dataPtr), &dwSize); - FATAL(result != ERROR_SUCCESS, ("failed to read registry value \"%s\", error = %ld\n", valueName, result)); - - // assume a query failure indicates the value was not found - if (valueDataSize) - *valueDataSize = static_cast(dwSize); -} - -// ---------------------------------------------------------------------- -/** - * retrieve a string from of this key's values, returning a default string - * if the value doesn't exist. - * - * The defaultValue arg is required, must be non-null. - * - * If the specified value exists but is not of type REG_SZ, the default - * string will be returned. - * - * This routine will DEBUG_FATAL on null args, even if optional is set. - * Optional only controls whether a FATAL occurs if there is an issue - * retrieving the value. - * - * @param valueName [IN] name of the string value to retrieve - * @param defaultValue [IN] string to return if registry key does not contain thev value - * @param dest [OUT] buffer for returned string - * @param destSize [IN] max number of bytes (including terminating null) that can be placed in dest - * @param optional [IN] if set, the function will return false if there is a problem retrieving the value. otherwise, a DEBUG_FATAL will occur - */ - -bool RegistryKey::getStringValue(const char *valueName, const char *defaultValue, char *dest, DWORD destSize, bool optional) -{ - DEBUG_FATAL(!defaultValue, ("null defaultValue arg")); - DEBUG_FATAL(!dest, ("null dest arg")); - - bool doesExist; - DWORD valueType; - DWORD valueSize; - - // clear out string - memset(dest, 0, static_cast(destSize)); - - // get info on the value - getValueInfo (valueName, &doesExist, &valueSize, &valueType); - if (!doesExist || (valueType != REG_SZ)) - strncpy(dest, defaultValue, destSize-1); - else - { - // value exists and is a string, retrieve it - getValue (valueName, dest, destSize, &valueSize); - if (!valueSize) - { - FATAL(!optional, ("failed to get registry data for key %s\n", valueName)); - return false; - } - - // terminate the string - dest [valueSize] = 0; - } - return true; -} - - -// ---------------------------------------------------------------------- -/** - * delete a value from this registry key. - */ - -void RegistryKey::deleteValue(const char *valueName) -{ - LONG result; - - DEBUG_FATAL(!keyHandle, ("null keyHandle")); - DEBUG_FATAL(!valueName, ("null valueName arg")); - DEBUG_FATAL(!strlen(valueName), ("zero-length valueName arg")); - - result = RegDeleteValue(keyHandle, valueName); - FATAL(result != ERROR_SUCCESS, ("failed to delete registry value \"%s\", error = %ld\n", valueName, result)); -} - -#if USE_REGISTRY_EXECUTION_STATISTICS - -// ---------------------------------------------------------------------- -/** - * updates beginning-of-execution statistics using the values under a - * given key. - * - * Call this function at the beginning of execution of the code - * for which statistics are desired. At the end of execution, - * call updateShutdownKey() to finish generating statistics. - * This function should only be called once per execution, - * and should be followed by a call to updateShutdownKey(). - * If the latter is not called, the next call to updateStartupKey() - * will assume the application terminated abnormally before - * proper shutdown could occur. - */ - -void RegistryKey::updateStartupKey(RegistryKey *key) -{ - bool valueExist; - uint32 valueSize; - DWORD valueType; - DWORD execStartedCount = 0; - clock_t startTime = clock(); - - DEBUG_FATAL(!key, ("null key arg\n")); - - // handle improper shutdown of last run - key->getValueInfo(STAT_TIME_START_VALUENAME, &valueExist); - if (valueExist) - { - // appears the product did not run to completion on last run. - // increment the incomplete run counts - - DWORD execIncompleteCount = 0; - - key->getValueInfo(STAT_EXEC_INCOMPLETE_COUNT_VALUENAME, &valueExist); - if (valueExist) - { - key->getValue(STAT_EXEC_INCOMPLETE_COUNT_VALUENAME, &execIncompleteCount, sizeof(DWORD), &valueSize, &valueType); - DEBUG_FATAL((valueType != REG_DWORD) || (valueSize != sizeof(DWORD)), ("%s key not DWORD type as expected\n", STAT_EXEC_INCOMPLETE_COUNT_VALUENAME)); - } - ++execIncompleteCount; - key->setValue(STAT_EXEC_INCOMPLETE_COUNT_VALUENAME, &execIncompleteCount, sizeof(DWORD), REG_DWORD); - } - - // get the start count - key->getValueInfo(STAT_EXEC_STARTED_COUNT_VALUENAME, &valueExist); - if (valueExist) - { - key->getValue(STAT_EXEC_STARTED_COUNT_VALUENAME, &execStartedCount, sizeof(DWORD), &valueSize, &valueType); - DEBUG_FATAL((valueType != REG_DWORD) || (valueSize != sizeof(DWORD)), ("%s key not DWORD type as expected\n", STAT_EXEC_STARTED_COUNT_VALUENAME)); - } - ++execStartedCount; - - // save the data - key->setValue(STAT_EXEC_STARTED_COUNT_VALUENAME, &execStartedCount, sizeof(DWORD), REG_DWORD); - key->setValue(STAT_TIME_START_VALUENAME, &startTime, sizeof(clock_t)); -} - -#endif - - -#if USE_REGISTRY_EXECUTION_STATISTICS - -// ---------------------------------------------------------------------- -/** - * updates end-of-execution statistics using the values under a given key. - * - * This function should only be called after updateStartupKey() - * has been called on the same key. After this call returns, - * this function should not be called again until another - * call to updateStartupKey() is made. - */ - -void RegistryKey::updateShutdownKey(RegistryKey *key) -{ - bool valueExist; - uint32 valueSize; - DWORD valueType; - clock_t minTime; - clock_t maxTime; - clock_t averageTime = 0; - clock_t startTime; - clock_t stopTime = clock(); - clock_t runTime; - DWORD startExecCount; - DWORD incompleteExecCount = 0; - DWORD completeExecCount; - real averageFraction; - - DEBUG_FATAL(!key, ("null key arg\n")); - - // find the number of complete execution runs of the product - key->getValue(STAT_EXEC_STARTED_COUNT_VALUENAME, &startExecCount, sizeof(DWORD), &valueSize, &valueType); - DEBUG_FATAL((valueSize != sizeof(DWORD)) || (valueType != REG_DWORD), ("invalid start count statistic registry value\n")); - - key->getValueInfo(STAT_EXEC_INCOMPLETE_COUNT_VALUENAME, &valueExist); - if (valueExist) - { - key->getValue(STAT_EXEC_INCOMPLETE_COUNT_VALUENAME, &incompleteExecCount, sizeof(DWORD), &valueSize, &valueType); - DEBUG_FATAL((valueType != REG_DWORD) || (valueSize != sizeof(DWORD)), ("%s expected to be DWORD type, was %lu instead\n", STAT_EXEC_INCOMPLETE_COUNT_VALUENAME, valueType)); - } - completeExecCount = startExecCount - incompleteExecCount; - - // retrieve the start time - key->getValue(STAT_TIME_START_VALUENAME, &startTime, sizeof(clock_t), &valueSize, &valueType); - DEBUG_FATAL((valueSize != sizeof(clock_t)) || (valueType != REG_BINARY), ("invalid start time statistic registry value\n")); - - // -qq- we don't handle clock wraparound - runTime = stopTime - startTime; - minTime = runTime; - maxTime = runTime; - - // calculate average time - key->getValueInfo(STAT_TIME_AVERAGE_VALUENAME, &valueExist); - if (valueExist) - { - key->getValue(STAT_TIME_AVERAGE_VALUENAME, &averageTime, sizeof(clock_t), &valueSize, &valueType); - DEBUG_FATAL((valueSize != sizeof(clock_t)) || (valueType != REG_BINARY), ("invalid average exec time statistic registry value\n")); - } - averageFraction = CONST_REAL(1.0 / completeExecCount); - averageTime = static_cast(( CONST_REAL(averageTime) * (completeExecCount-1) + runTime) * averageFraction); - if (averageTime < 1) - averageTime = 1; - - // check min exec time - key->getValueInfo(STAT_TIME_MIN_VALUENAME, &valueExist); - if (valueExist) - { - clock_t testValue; - key->getValue(STAT_TIME_MIN_VALUENAME, &testValue, sizeof(clock_t), &valueSize, &valueType); - DEBUG_FATAL((valueSize != sizeof(clock_t)) || (valueType != REG_BINARY), ("invalid min exec time statistic registry value\n")); - if (testValue < minTime) - minTime = testValue; - } - - // check for max exec time - key->getValueInfo(STAT_TIME_MAX_VALUENAME, &valueExist); - if (valueExist) - { - clock_t testValue; - key->getValue(STAT_TIME_MAX_VALUENAME, &testValue, sizeof(clock_t), &valueSize, &valueType); - DEBUG_FATAL((valueSize != sizeof(clock_t)) || (valueType != REG_BINARY), ("invalid max exec time statistic registry value\n")); - if (testValue > maxTime) - maxTime = testValue; - } - - // save the data - key->setValue(STAT_TIME_AVERAGE_VALUENAME, &averageTime, sizeof(clock_t)); - key->setValue(STAT_TIME_MIN_VALUENAME, &minTime, sizeof(clock_t)); - key->setValue(STAT_TIME_MAX_VALUENAME, &maxTime, sizeof(clock_t)); - - // delete the start time value - key->deleteValue(STAT_TIME_START_VALUENAME); -} - -#endif - - -#if USE_REGISTRY_EXECUTION_STATISTICS - -// ---------------------------------------------------------------------- -/** - * An EnumValueCallback that prints each value name, type and size - * - * @param valueName name of value - * @param valueSize size of value in bytes - * @param valueTye type of value - */ - -bool RegistryKey::enumValueInfoPrint( - void*, // unused user context - const char *valueName, - uint32 valueSize, - DWORD valueType - ) -{ - char *valueTypeStr; - char buffer[64]; - - switch (valueType) - { - case REG_BINARY: - valueTypeStr = "REG_BINARY"; - break; - case REG_DWORD: - valueTypeStr = "REG_DWORD [little endian]"; - break; - case REG_DWORD_BIG_ENDIAN: - valueTypeStr = "REG_DWORD_BIG_ENDIAN"; - break; - case REG_EXPAND_SZ: - valueTypeStr = "REG_EXPAND_SZ"; - break; - case REG_NONE: - valueTypeStr = "REG_NONE"; - break; - case REG_SZ: - valueTypeStr = "REG_SZ"; - break; - default: - valueTypeStr = buffer; - sprintf(buffer, "", valueType); - break; - } - - DEBUG_PRINT_LOG(true, (" Key: \"%s\", %s, %u bytes\n", valueName, valueTypeStr, valueSize)); - - // continue enumerating - return true; -} - -#endif - - -#if USE_REGISTRY_EXECUTION_STATISTICS - -// ---------------------------------------------------------------------- -/** - * Update per-startup registry values. - * - * This routine is used primarily to test registry read/write - * functionality; however, it does provide statistics related - * to game usage. These include the following statistics on - * a per-game and per-machine basis: - * # times product was executed - * average real-time duration of execution - * minimum execution time - * maximum execution time - * # times product failed to execute to completion - * (i.e. updateRegistryShutdown() never executed---hard crash, stop debugging) - */ - -void RegistryKey::updateStartupStatistics(void) -{ - DEBUG_FATAL(!productUserKey, ("null productUserKey\n")); - DEBUG_FATAL(!productMachineKey, ("null productMachineKey\n")); - - // create required keys - RegistryKey *userStatKey = productUserKey->createSubkey(STATISTICS_KEYNAME); - RegistryKey *machineStatKey = productMachineKey->createSubkey(STATISTICS_KEYNAME); - - FATAL(!userStatKey, ("failed to create user statistics key")); - FATAL(!machineStatKey, ("failed to create machine statistics key")); - - // handle machine stat key - -#if 1 - // print existing machine stat keys - DEBUG_PRINT_LOG(true, ("BEGIN machine stat key enumeration:\n")); - machineStatKey->enumerateValues(0, enumValueInfoPrint); - DEBUG_PRINT_LOG(true, ("END machine stat key enumeration:\n")); -#endif - - updateStartupKey(machineStatKey); - - - // handle user stat key - -#if 1 - // print existing user stat keys - DEBUG_PRINT_LOG(true, ("BEGIN user stat key enumeration:\n")); - userStatKey->enumerateValues(0, enumValueInfoPrint); - DEBUG_PRINT_LOG(true, ("END user stat key enumeration:\n")); -#endif - - updateStartupKey(userStatKey); - - // cleanup - delete machineStatKey; - delete userStatKey; -} - -#endif - - -#if USE_REGISTRY_EXECUTION_STATISTICS - -// ---------------------------------------------------------------------- -/** - * Update per-shutdown registry values. - * - * @see updateRegistryStartup() - */ - -void RegistryKey::updateShutdownStatistics(void) -{ - DEBUG_FATAL(!productUserKey, ("null productUserKey\n")); - DEBUG_FATAL(!productMachineKey, ("null productMachineKey\n")); - - // create required keys - RegistryKey *userStatKey = productUserKey->createSubkey(STATISTICS_KEYNAME); - RegistryKey *machineStatKey = productMachineKey->createSubkey(STATISTICS_KEYNAME); - - FATAL(!userStatKey, ("failed to create user statistics key")); - FATAL(!machineStatKey, ("failed to create machine statistics key")); - - // handle machine stat key - updateShutdownKey(machineStatKey); - - // handle user stat key - updateShutdownKey(userStatKey); - - // cleanup - delete machineStatKey; - delete userStatKey; -} - -#endif - -// ---------------------------------------------------------------------- -/** - * install the RegistryKey class. - * - * After installation, the following predefined keys are available: - * - * usersKey: HKEY_USERS - * currentUserKey: HKEY_CURRENT_USER - * classRootKey: HKEY_CLASSES_ROOT - * localMachineKey: HKEY_LOCAL_MACHINE - * productUserKey: HKEY_CURENT_USER\ - * productMachineKey: HKEY_LOCAL_MACHINE\ - * - * The client is free to create any other keys required. - * - * The product relative registry path is determined by the first of the - * following methods that succeed: - * 1. If the config file key "ProductRegistryPath" is set, that value is - * used for the relative path. If the product relative path is set - * in this manner, the client's attempt to change the product relative - * path via the setProductKey() function will silently fail. - * 2. If the productKeyRelativePath parameter is a non-null positive length - * string, that value is used as the product keys' relative path. - * 3. The default value DEFAULT_PRODUCT_REGISTRY_PATH ("Software\\Bootprint\\Default") - * is used. - * - * RegistryKey::remove() is added to the exit chain. - * - * Do not delete any of the predefined registry keys. - * - * @param productKeyRelativePath [IN] relative registry path for the product keys - * @see setProductKeyPath() - */ - -void RegistryKey::install(const char *productKeyRelativePath) -{ - UNREF(productKeyRelativePath); - char *useRegistryPath = 0; - - DEBUG_FATAL(installed, ("attempted to install RegistryKey when already installed\n")); - installed = true; - - // add to exit chain - ExitChain::add(remove, "RegistryKey::remove", 0, true); - - // if no passed in value, use the default - setProductKeyPathFromConfig = false; - useRegistryPath = DuplicateString(DEFAULT_PRODUCT_REGISTRY_PATH); - - // create the Windows-defined RegistryKeys (these keys don't get closed at object destruction time) - usersKey = new RegistryKey(HKEY_USERS, false); //lint !e1924 // Note -- C-style cast - currentUserKey = new RegistryKey(HKEY_CURRENT_USER, false); //lint !e1924 // Note -- C-style cast - classRootKey = new RegistryKey(HKEY_CLASSES_ROOT, false); //lint !e1924 // Note -- C-style cast - localMachineKey = new RegistryKey(HKEY_LOCAL_MACHINE, false); //lint !e1924 // Note -- C-style cast - - // check for errors --- unnecessary if new cannot return NULL - FATAL( - !usersKey || !currentUserKey || !classRootKey || !localMachineKey, - ("failed to create standard RegistryKey objects")); - - // create/open the product user key - productUserKey = currentUserKey->createSubkey(useRegistryPath, AF_READ | AF_WRITE); - - // create/open the product machine key - productMachineKey = localMachineKey->createSubkey(useRegistryPath, AF_READ); - - delete [] useRegistryPath; - -#if USE_REGISTRY_EXECUTION_STATISTICS - updateStartupStatistics(); -#endif -} - -// ---------------------------------------------------------------------- -/** - * release all resources and state associated with the RegistryKey system. - * - * It is invalid to call any RegistryKey functions other than install() - * after calling remove(). - */ - -void RegistryKey::remove(void) -{ -#if USE_REGISTRY_EXECUTION_STATISTICS - updateShutdownStatistics(); -#endif - - DEBUG_FATAL(!installed, ("attempted to remove RegistryKey when not installed\n")); - installed = false; - - delete productMachineKey; - delete productUserKey; - delete localMachineKey; - delete classRootKey; - delete currentUserKey; - delete usersKey; - - productMachineKey = 0; - productUserKey = 0; - localMachineKey = 0; - classRootKey = 0; - currentUserKey = 0; - usersKey = 0; - -} - -// ---------------------------------------------------------------------- -/** - * reset the path to the product's machine and user keys. - * - * This routine will redefine the following keys: - * productUserKey: HKEY_CURENT_USER\ - * productMachineKey: HKEY_LOCAL_MACHINE\ - * - * If the product key relative paths were specified in the config - * file, this routine will essentially do nothing --- the client - * is not able to ovveride the config file settings. - */ - -void RegistryKey::setProductKeyPath(const char *productKeyRelativePath) -{ - DEBUG_FATAL( - !productKeyRelativePath || !productKeyRelativePath[0], - ("invalid productKeyRelativePath arg\n")); - - // don't allow client to overwrite if path set by config file - if (setProductKeyPathFromConfig) - { - DEBUG_REPORT_LOG_PRINT(true, ("attempted to set product registry key path to '%s' but config file setting will override\n", productKeyRelativePath)); - return; - } - - delete productUserKey; - delete productMachineKey; - - productUserKey = currentUserKey->createSubkey(productKeyRelativePath, AF_READ | AF_WRITE); - productMachineKey = localMachineKey->createSubkey(productKeyRelativePath, AF_READ | AF_WRITE); -} - -// ====================================================================== diff --git a/engine/shared/library/sharedFoundation/src/win32/RegistryKey.h b/engine/shared/library/sharedFoundation/src/win32/RegistryKey.h deleted file mode 100755 index 9c885194..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/RegistryKey.h +++ /dev/null @@ -1,270 +0,0 @@ -#ifndef REGISTRY_KEY_H -#define REGISTRY_KEY_H - -// ====================================================================== -// -// RegistryKey.h -// Todd Fiala -// -// copyright 1998 Bootprint Entertainment -// -// ====================================================================== - -// provide read and write access to the Windows Registry -// -// Remarks: -// -// Each RegistryKey can create or open a subkey relative to that -// key. This process produces another RegistryKey. RegistryKeys -// provide a mechanism to enumerate all the child subkeys and values -// associated with the key. In addition, clients may query for -// the presence, type and size of a specific value, get a specific -// value's data, and set a named value's data and type. -// -// The RegistryKey class provides the client with six RegistryKey -// objects as starting points into the registry. See documentation -// for install() for more info on these starting points. -// -// The client must install() the RegistryKey class before using it. - -class RegistryKey -{ -public: - // ---------------------------------------------------------------------- - // flags used to indicate what type of access (e.g. read, write) should - // be granted when creating or opening a key. - // - // See Also: - // - // createSubkey(), openSubkey() - - enum // AccessFlags - { - AF_READ = BINARY1(0001), // query values, enumerate subkeys - AF_WRITE = BINARY1(0010) // set values, create subkeys - }; - - // ---------------------------------------------------------------------- - // callback prototype for subkey enumeration - // - // Return Value: - // - // A return value of true indicates the enumeration of subkeys should - // continue. A return value of false stops further enumeration of - // subkeys. - // - // Remarks: - // - // The context parameter is specified in the call to - // enumerateSubkeys(). One use for this could be to pass a class - // instance, with the callack defined as a static member function. - // The function can then cast the context to a pointer to class - // instance, allowing the static function to access per-instance - // data explicitly in place of an assumed this pointer. - // - // See Also: - // - // enumerateSubkeys() - - typedef bool (*EnumerateKeyCallback)( - void *context, // [IN] user-specified context variable - const char *keyName, // [IN] name of the key being enumerated - const FILETIME *lastWriteTime // [IN] last time this key was modified - ); - - // ---------------------------------------------------------------------- - // callback prototype for value enumeration - // - // Return Value: - // - // A return value of true indicates the enumeration of values should - // continue. A return value of false stops further enumeration of - // values . - // - // Remarks: - // - // The context parameter is specified in the call to - // enumerateValues(). One use for this could be to pass a class - // instance, with the callack defined as a static member function. - // The function can then cast the context to a pointer to class - // instance, allowing the static function to access per-instance - // data explicitly in place of an assumed this pointer. - // - // See Also: - // - // enumerateValues() - - typedef bool (*EnumerateValueCallback)( - void *context, // [IN] user-specified context variable - const char *valueName, // [IN] name of the value being enumerated - uint32 valueSize, // [IN] number of bytes occupied by this value's data - DWORD valueType // [IN] type of value (one of REG_* as in RegSetValueEx documentation) - ); - -private: - static const char * const PRODUCT_REGISTRY_PATH_KEYNAME; - static const char * const DEFAULT_PRODUCT_REGISTRY_PATH; - -#if USE_REGISTRY_EXECUTION_STATISTICS - static const char * const STATISTICS_KEYNAME; - static const char * const STAT_EXEC_STARTED_COUNT_VALUENAME; - static const char * const STAT_EXEC_INCOMPLETE_COUNT_VALUENAME; - static const char * const STAT_TIME_AVERAGE_VALUENAME; - static const char * const STAT_TIME_MIN_VALUENAME; - static const char * const STAT_TIME_MAX_VALUENAME; - static const char * const STAT_TIME_START_VALUENAME; -#endif - - static bool installed; - static bool setProductKeyPathFromConfig; - - // private instance member variables - HKEY keyHandle; - bool closeKeyOnDestroy; - -private: - // public member variables - static RegistryKey *usersKey; - static RegistryKey *currentUserKey; - static RegistryKey *classRootKey; - static RegistryKey *localMachineKey; - static RegistryKey *productUserKey; - static RegistryKey *productMachineKey; - -private: - // private member functions - static void remove(void); - RegistryKey(HKEY newKeyHandle, bool newCloseKeyOnDestroy); - -#if USE_REGISTRY_EXECUTION_STATISTICS - static void updateStartupKey(RegistryKey *key); - static void updateShutdownKey(RegistryKey *key); - static bool enumValueInfoPrint(void *context, const char *valueName, uint32 valueSize, DWORD valueType); - - static void updateStartupStatistics(void); - static void updateShutdownStatistics(void); -#endif - -private: - // disable: default constructor, copy constructor, assignment operator - // NOTE: last two can be implemented, but must be specially handled - RegistryKey(void); - RegistryKey(const RegistryKey&); - RegistryKey &operator =(const RegistryKey&); - -public: - // public member functions - - static void install(const char *productKeyRelativePath = 0); - static void setProductKeyPath(const char *productKeyRelativePath); - - // pre-defined RegistryKey retrieval - static RegistryKey *getUsersKey(void); - static RegistryKey *getCurrentUserKey(void); - static RegistryKey *getClassRootKey(void); - static RegistryKey *getLocalMachineKey(void); - static RegistryKey *getProductUserKey(void); - static RegistryKey *getProductMachineKey(void); - - ~RegistryKey(void); - - // subkey interface - void enumerateSubkeys(void *context, EnumerateKeyCallback callback) const; - RegistryKey *openSubkey(const char *subkeyName, uint32 accessFlags = AF_READ) const; - RegistryKey *createSubkey(const char *subkeyName, uint32 accessFlags = AF_READ | AF_WRITE) const; - void deleteSubkey(const char *subkeyName); - bool subKeyExists(const char *subkeyName); - - // value interface - void enumerateValues(void *context, EnumerateValueCallback callback) const; - void setValue(const char *valueName, const void *dataPtr, uint32 dataSize, DWORD valueType = REG_BINARY); - void deleteValue(const char *valueName); - - void getValueInfo(const char *valueName, bool *doesExist, uint32 *valueSize = 0, DWORD *valueType = 0) const; - void getValue(const char *valueName, void *dataPtr, uint32 maxDataSize, uint32 *valueDataSize, DWORD *valueType = 0) const; - bool getStringValue(const char *valueName, const char *defaultValue, char *dest, DWORD destSize, bool optional = false); - -}; - -// ====================================================================== -// retrieve a key to the HKEY_USERS registry key with read access - -inline RegistryKey *RegistryKey::getUsersKey(void) -{ - DEBUG_FATAL(!installed, ("Attempted to use RegistryKey when not installed\n")); - return usersKey; -} - -// ---------------------------------------------------------------------- -/** - * retrieve a key to the HKEY_CURRENT_USER registry key with read/write - * access. - */ - -inline RegistryKey *RegistryKey::getCurrentUserKey(void) -{ - DEBUG_FATAL(!installed, ("Attempted to use RegistryKey when not installed\n")); - return currentUserKey; -} - -// ---------------------------------------------------------------------- -/** - * retrieve a key to the HKEY_CLASSES_ROOT registry key with read/write - * access. - */ - -inline RegistryKey *RegistryKey::getClassRootKey(void) -{ - DEBUG_FATAL(!installed, ("Attempted to use RegistryKey when not installed\n")); - return classRootKey; -} - -// ---------------------------------------------------------------------- -/** - * retrieve a key to the HKEY_LOCAL_MACHINE registry key with read/write - * access. - */ - -inline RegistryKey *RegistryKey::getLocalMachineKey(void) -{ - DEBUG_FATAL(!installed, ("Attempted to use RegistryKey when not installed\n")); - return localMachineKey; -} - -// ---------------------------------------------------------------------- -/** - * retrieve a key to the product's user key with read/write access. - * - * The product user key is the root key for storing user-specific - * product-related information. install() describes where this - * information exists in the registry. - * - * @see install(), getProductMachineKey() - */ - -inline RegistryKey *RegistryKey::getProductUserKey(void) -{ - DEBUG_FATAL(!installed, ("Attempted to use RegistryKey when not installed\n")); - return productUserKey; -} - -// ---------------------------------------------------------------------- -/** - * retrieve a key to the product's machine key with read/write access. - * - * The product machine key is the root key for storing machine-specific - * product-related information. install() describes where this - * information exists in the registry. - * - * @see install(), getProductUserKey() - */ - -inline RegistryKey *RegistryKey::getProductMachineKey(void) -{ - DEBUG_FATAL(!installed, ("Attempted to use RegistryKey when not installed\n")); - return productMachineKey; -} - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFoundation/src/win32/SetupSharedFoundation.cpp b/engine/shared/library/sharedFoundation/src/win32/SetupSharedFoundation.cpp deleted file mode 100755 index 98889b52..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/SetupSharedFoundation.cpp +++ /dev/null @@ -1,410 +0,0 @@ -// ====================================================================== -// -// SetupSharedFoundation.cpp -// copyright 1998 Bootprint Entertainment -// copyright 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedFoundation/SetupSharedFoundation.h" - -#include "sharedDebug/DebugMonitor.h" -#include "sharedDebug/InstallTimer.h" -#include "sharedDebug/Profiler.h" - -#include "sharedFoundation/ApplicationVersion.h" -#include "sharedFoundation/Clock.h" -#include "sharedFoundation/CommandLine.h" -#include "sharedFoundation/ConfigFile.h" -#include "sharedFoundation/ConfigSharedFoundation.h" -#include "sharedFoundation/CrashReportInformation.h" -#include "sharedFoundation/CrcLowerString.h" -#include "sharedFoundation/ExitChain.h" -#include "sharedFoundation/Os.h" -#include "sharedFoundation/Production.h" -#include "sharedFoundation/RegistryKey.h" -#include "sharedFoundation/StaticCallbackEntry.h" -#include "sharedFoundation/MemoryBlockManager.h" -#include "sharedFoundation/Watcher.h" -#include "sharedLog/TailFileLogObserver.h" - -#include -#include - -// ====================================================================== - -namespace FatalNamespace -{ - extern char ms_buffer[32 * 1024]; -} - -namespace SetupSharedFoundationNamespace -{ - LONG __stdcall MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS exceptionPointers); - - bool ms_writeMiniDumps; -} - -using namespace SetupSharedFoundationNamespace; - -// ====================================================================== - -LONG __stdcall SetupSharedFoundationNamespace::MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS exceptionPointers) -{ - // make the routine somewhat safe from re-entrance - static bool entered = false; - if (entered) - return EXCEPTION_CONTINUE_SEARCH; - entered = true; - - // log some important information - static char buffer[128]; - sprintf(buffer, "Exception %08x(%d)=code %08x=addr\n", exceptionPointers->ExceptionRecord->ExceptionCode, exceptionPointers->ExceptionRecord->ExceptionCode, exceptionPointers->ExceptionRecord->ExceptionAddress); - OutputDebugString(buffer); - - // write the minidump if we're in here for the first time - static bool ms_alreadyWroteMiniDump = false; - if (ms_writeMiniDumps && !ms_alreadyWroteMiniDump) - { - ms_alreadyWroteMiniDump = true; - - uint64 timestamp; - time_t now; - tm t; - - IGNORE_RETURN(time(&now)); - IGNORE_RETURN(gmtime_r(&now, &t)); - timestamp = t.tm_year+1900; //lint !e732 !e737 !e776 - timestamp *= 100; - timestamp += t.tm_mon+1; //lint !e737 !e776 - timestamp *= 100; - timestamp += static_cast(t.tm_mday); - timestamp *= 100; - timestamp += static_cast(t.tm_hour); - timestamp *= 100; - timestamp += static_cast(t.tm_min); - timestamp *= 100; - timestamp += static_cast(t.tm_sec); - - static char fileName[512]; - - sprintf(fileName, "%s-%s-%I64d.txt", Os::getShortProgramName(), ApplicationVersion::getInternalVersion(), timestamp); - HANDLE const file = CreateFile(fileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL); - if (file != INVALID_HANDLE_VALUE) - { - char text1[] = "automated crash dump from "; - DWORD bytesWritten; - WriteFile(file, text1, strlen(text1), &bytesWritten, NULL); - - char const * text2 = Os::getShortProgramName(); - WriteFile(file, text2, strlen(text2), &bytesWritten, NULL); - - char text3[] = " "; - WriteFile(file, text3, strlen(text3), &bytesWritten, NULL); - - char const * text4 = ApplicationVersion::getInternalVersion(); - WriteFile(file, text4, strlen(text4), &bytesWritten, NULL); - - char text5[] = "\n\n\n"; - WriteFile(file, text5, strlen(text5), &bytesWritten, NULL); - - if (exceptionPointers->ExceptionRecord->ExceptionCode == 0x80000003) - { - // write out the fatal buffer - char const * text6 = FatalNamespace::ms_buffer; - WriteFile(file, text6, strlen(text6), &bytesWritten, NULL); - } - else - { - char const * text6 = buffer; - WriteFile(file, text6, strlen(text6), &bytesWritten, NULL); - } - - char text7[] = "\n\n"; - WriteFile(file, text7, strlen(text7), &bytesWritten, NULL); - - char const * text8 = ""; - for (int i = 0; text8; ++i) - { - text8 = CrashReportInformation::getEntry(i); - if (text8) - { - int const text8Length = strlen(text8); - if (text8Length) - WriteFile(file, text8, text8Length, &bytesWritten, NULL); - } - } - - CloseHandle(file); - } - - sprintf(fileName, "%s-%s-%I64d.mdmp", Os::getShortProgramName(), ApplicationVersion::getInternalVersion(), timestamp); - OutputDebugString("Generating minidump "); - OutputDebugString(fileName); - OutputDebugString("\n"); - DebugHelp::writeMiniDump(fileName, exceptionPointers); - - sprintf(fileName, "%s-%s-%I64d.log", Os::getShortProgramName(), ApplicationVersion::getInternalVersion(), timestamp); - TailFileLogObserver::flushAllTailFileLogObservers(fileName); - } - - // tell the Os not to abort so we can rethrow the exception - Os::returnFromAbort(); - - // Let the ExitChain do its job - Fatal("ExceptionHandler invoked"); - - // rethrow the exception so that the debugger can catch it - entered = false; - return EXCEPTION_CONTINUE_SEARCH; //lint !e527 // Unreachable -} - -// ---------------------------------------------------------------------- - -static void setFatalVersionString() -{ - char buffer[256]; - sprintf(buffer, "%s: %s\n", Os::getShortProgramName(), ApplicationVersion::getInternalVersion()); - FatalSetVersionString(buffer); -} - -// ====================================================================== -// Install the engine -// -// Remarks: -// -// The settings in the Data structure will determine which subsystems -// get initialized. - -void SetupSharedFoundation::install(const Data &data) -{ - InstallTimer const installTimer("SetupSharedFoundation::install"); - - DEBUG_REPORT_LOG(true, ("SetupSharedFoundation::install: version %s\n", ApplicationVersion::getInternalVersion())); - - ms_writeMiniDumps = data.writeMiniDumps; - SetUnhandledExceptionFilter(MyUnhandledExceptionFilter); - - // and get the command line stuff in quick so we can make decisions based on the command line settings - CommandLine::install(); - - // feed CommandLine with appropriate strings - if (data.commandLine) - CommandLine::absorbString(data.commandLine); - if (data.argc) - CommandLine::absorbStrings(const_cast(data.argv+1), data.argc-1); - - // load the config file - ConfigFile::install(); - if (data.configFile) - IGNORE_RETURN(ConfigFile::loadFile(data.configFile)); - - // get the post command-line text for the ConfigFile (key-value pairs) - const char *configString = CommandLine::getPostCommandLineString(); - if (configString) - { - IGNORE_RETURN(ConfigFile::loadFromCommandLine(configString)); - } - - // @todo codereorg should this be here? - MemoryManager::registerDebugFlags(); -#if PRODUCTION == 0 - Profiler::registerDebugFlags(); -#endif - FatalInstall(); - - // @todo move these, it's part of sharedDebug. However, sharedDebug is installed before sharedFoundation, but these need the ConfigFile. ugh. -#if PRODUCTION == 0 - DebugMonitor::install(); -#endif - SetWarningStrictFatal(ConfigFile::getKeyBool("SharedDebug", "strict", false)); - - { - ConfigSharedFoundation::Defaults defaults; - defaults.frameRateLimit = data.frameRateLimit; - defaults.demoMode = data.demoMode; - defaults.verboseWarnings = data.verboseWarnings; - ConfigSharedFoundation::install(defaults); - - if (ConfigSharedFoundation::getCauseAccessViolation()) - static_cast(0)[0] = 0; - } - - // @todo codereorg should this be here? -#ifdef _DEBUG - MemoryManager::setReportAllocations (ConfigSharedFoundation::getMemoryManagerReportAllocations ()); -#endif - - MemoryBlockManager::install (ConfigSharedFoundation::getMemoryBlockManagerDebugDumpOnRemove ()); - - ExitChain::install(); - Report::install(); - Clock::install(data.clockUsesSleep, data.clockUsesRecalibrationThread); - CrashReportInformation::install(); - RegistryKey::install(data.productRegistryKey); - - PersistentCrcString::install(); - CrcLowerString::install(); - - WatchedByList::install(); - - if (data.createWindow) - { - DEBUG_FATAL(data.useWindowHandle, ("exactly one of createWindow and useWindowHandle must be true")); - Os::install(data.hInstance, data.windowName, data.windowNormalIcon, data.windowSmallIcon); - } - else - { - if (data.useWindowHandle) - Os::install(data.windowHandle, data.processMessagePump); - else - Os::install(); - } - - StaticCallbackEntry::install(); - - setFatalVersionString(); -} - -// ---------------------------------------------------------------------- -// Call a function with appropriate exception handling -// -// Remarks: -// -// If exception handling has been disabled in the config file, this routine -// will call the callback without exception handling. - -void SetupSharedFoundation::callbackWithExceptionHandling( - void (*callback)(void) // Routine to call with exception handling - ) -{ - callback(); -} - -// ---------------------------------------------------------------------- -// Uninstall the engine -// -// Remarks: -// -// This routine will properly uninstall the engine componenets that were -// installed by SetupSharedFoundation::install(). - -void SetupSharedFoundation::remove(void) -{ - ExitChain::quit(); - - if (!ConfigSharedFoundation::getDemoMode() && GetNumberOfWarnings()) - REPORT(true, Report::RF_print | Report::RF_log | Report::RF_dialog, ("%d warnings logged", GetNumberOfWarnings())); -} - -// ====================================================================== - -SetupSharedFoundation::Data::Data(Defaults defaults) -{ - Zero(*this); - - switch (defaults) - { - case D_console: setupConsoleDefaults(); break; - case D_game: setupGameDefaults(); break; - case D_mfc: setupMfcDefaults(); break; - default: DEBUG_FATAL(true, ("invalid enum value")); - } -} - -// ---------------------------------------------------------------------- - -void SetupSharedFoundation::Data::setupGameDefaults() -{ - createWindow = true; - windowName = NULL; - windowNormalIcon = NULL; - windowSmallIcon = NULL; - hInstance = NULL; - useWindowHandle = false; - processMessagePump = true; - windowHandle = NULL; - clockUsesSleep = false; - clockUsesRecalibrationThread = true; - writeMiniDumps = false; - - commandLine = NULL; - argc = 0; - argv = NULL; - - configFile = NULL; - - productRegistryKey = NULL; - - frameRateLimit = CONST_REAL(0); - - lostFocusCallback = NULL; - - demoMode = false; - verboseWarnings = false; -} - -// ---------------------------------------------------------------------- - -void SetupSharedFoundation::Data::setupConsoleDefaults() -{ - createWindow = false; - windowName = NULL; - windowNormalIcon = NULL; - windowSmallIcon = NULL; - hInstance = NULL; - useWindowHandle = false; - processMessagePump = true; - windowHandle = NULL; - clockUsesSleep = false; - clockUsesRecalibrationThread = false; - writeMiniDumps = false; - - commandLine = NULL; - argc = NULL; - argv = NULL; - - configFile = NULL; - - productRegistryKey = NULL; - - frameRateLimit = CONST_REAL(0); - - lostFocusCallback = NULL; - - demoMode = false; - verboseWarnings = false; -} - -// ---------------------------------------------------------------------- - -void SetupSharedFoundation::Data::setupMfcDefaults() -{ - createWindow = false; - windowName = NULL; - windowNormalIcon = NULL; - windowSmallIcon = NULL; - hInstance = NULL; - useWindowHandle = false; - processMessagePump = true; - windowHandle = NULL; - clockUsesSleep = false; - clockUsesRecalibrationThread = false; - writeMiniDumps = false; - - commandLine = NULL; - argc = 0; - argv = NULL; - - configFile = NULL; - - productRegistryKey = NULL; - - frameRateLimit = CONST_REAL(0); - - demoMode = false; - verboseWarnings = false; -} - -// ====================================================================== diff --git a/engine/shared/library/sharedFoundation/src/win32/SetupSharedFoundation.h b/engine/shared/library/sharedFoundation/src/win32/SetupSharedFoundation.h deleted file mode 100755 index b0675d8f..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/SetupSharedFoundation.h +++ /dev/null @@ -1,99 +0,0 @@ -// ====================================================================== -// -// SetupSharedFoundation.h -// copyright 1998 Bootprint Entertainment -// copyright 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_SetupSharedFoundation_H -#define INCLUDED_SetupSharedFoundation_H - -// ====================================================================== - -class SetupSharedFoundation -{ -public: - - struct Data - { - typedef void (*LostFocusCallbackFuction)(); - - // window creation stuff - bool createWindow; - const char *windowName; - HICON windowNormalIcon; - HICON windowSmallIcon; - HINSTANCE hInstance; - - // window use stuff - bool useWindowHandle; - bool processMessagePump; - HWND windowHandle; - - bool writeMiniDumps; - - bool clockUsesSleep; - bool clockUsesRecalibrationThread; - - // pointer to command line - const char *commandLine; - int argc; - char **argv; - - // name of the config file to lead - const char *configFile; - - // registry stuff - const char *productRegistryKey; - - real frameRateLimit; - - - bool demoMode; - - bool verboseWarnings; - - LostFocusCallbackFuction lostFocusCallback; - - public: - - enum Defaults - { - D_console, - D_game, - D_mfc - }; - - Data(Defaults defaults); - - private: - - Data(); - - void setupGameDefaults(); - void setupConsoleDefaults(); - void setupMfcDefaults(); - }; - -public: - - typedef void (*MainFunction)(); - -public: - - static void install(const Data &data); - static void remove(void); - - static void callbackWithExceptionHandling(MainFunction mainFunction); - -private: - - SetupSharedFoundation(); - SetupSharedFoundation(const SetupSharedFoundation &); - SetupSharedFoundation &operator =(const SetupSharedFoundation &); -}; - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFoundation/src/win32/WindowsWrapper.h b/engine/shared/library/sharedFoundation/src/win32/WindowsWrapper.h deleted file mode 100755 index 88b64ed5..00000000 --- a/engine/shared/library/sharedFoundation/src/win32/WindowsWrapper.h +++ /dev/null @@ -1,51 +0,0 @@ -// ====================================================================== -// -// WindowsWrapper.h -// copyright (c) 1998 Bootprint Entertainment -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_WindowsWrapper_H -#define INCLUDED_WindowsWrapper_H - -// ====================================================================== - -// C4201 nonstandard extension used : nameless struct/union -#pragma warning(disable: 4201) - -// make windows.h more strict in the types of handles -#ifndef STRICT -#define STRICT 1 -#endif - -// trim down the amount of stuff windows.h includes -#define NOGDICAPMASKS -#define NOVIRTUALKEYCODE -#define NOKEYSTATES -#define NORASTEROPS -#define NOATOM -#define NOCOLOR -#define NODRAWTEXT -#define NOMEMMGR -#define NOMETAFILE -#define NOMINMAX -#define NOOPENFILE -#define NOSERVICE -#define NOSOUND -#define NOCOMM -#define NOHELP -#define NOPROFILER -#define NODEFERWINDOWPOS -#define NOMCX -#define WIN32_LEAN_AND_MEAN - -#include -#include - -// reenable warnings disables for windows.h -#pragma warning(default: 4201) - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFoundationTypes/src/win32/FoundationTypesWin32.h b/engine/shared/library/sharedFoundationTypes/src/win32/FoundationTypesWin32.h deleted file mode 100755 index 622039d8..00000000 --- a/engine/shared/library/sharedFoundationTypes/src/win32/FoundationTypesWin32.h +++ /dev/null @@ -1,33 +0,0 @@ -// PRIVATE. Do not export this header file outside the package. - -// ====================================================================== -// -// FoundationTypesWin32.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_FoundationTypesWin32_H -#define INCLUDED_FoundationTypesWin32_H - -// ====================================================================== -// specify what platform we're running on. - -#define PLATFORM_WIN32 - -// ====================================================================== -// basic types that we assume to be around - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned long uint32; -typedef unsigned __int64 uint64; -typedef signed char int8; -typedef signed short int16; -typedef signed long int32; -typedef signed __int64 int64; -typedef int FILE_HANDLE; - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedFractal/src/win32/FirstSharedFractal.cpp b/engine/shared/library/sharedFractal/src/win32/FirstSharedFractal.cpp deleted file mode 100755 index 20d5ff2f..00000000 --- a/engine/shared/library/sharedFractal/src/win32/FirstSharedFractal.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstFractal.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedFractal/FirstSharedFractal.h" diff --git a/engine/shared/library/sharedGame/src/win32/FirstSharedGame.cpp b/engine/shared/library/sharedGame/src/win32/FirstSharedGame.cpp deleted file mode 100755 index b95c88bf..00000000 --- a/engine/shared/library/sharedGame/src/win32/FirstSharedGame.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// ====================================================================== -// -// FirstSharedGame.cpp -// Copyright 2002-2003 Sony Online Entertainment, Inc. -// All Rights Reserved. -// -// ====================================================================== - -#include "sharedGame/FirstSharedGame.h" diff --git a/engine/shared/library/sharedImage/src/win32/FirstSharedImage.cpp b/engine/shared/library/sharedImage/src/win32/FirstSharedImage.cpp deleted file mode 100755 index c57c713f..00000000 --- a/engine/shared/library/sharedImage/src/win32/FirstSharedImage.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstImage.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedImage/FirstSharedImage.h" diff --git a/engine/shared/library/sharedIoWin/src/win32/FirstSharedIoWin.cpp b/engine/shared/library/sharedIoWin/src/win32/FirstSharedIoWin.cpp deleted file mode 100755 index 52f7b83b..00000000 --- a/engine/shared/library/sharedIoWin/src/win32/FirstSharedIoWin.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstIoWin.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedIoWin/FirstSharedIoWin.h" diff --git a/engine/shared/library/sharedLog/src/win32/StderrLogger.cpp b/engine/shared/library/sharedLog/src/win32/StderrLogger.cpp deleted file mode 100755 index c7efe43d..00000000 --- a/engine/shared/library/sharedLog/src/win32/StderrLogger.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// ====================================================================== -// -// StderrLogger.cpp -// -// Copyright 2003 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedLog/FirstSharedLog.h" -#include "sharedLog/StderrLogger.h" - -// ====================================================================== - -// Unimplemented for win32 - -// ====================================================================== - -void StderrLogger::install() -{ -} - -// ---------------------------------------------------------------------- - -void StderrLogger::remove() -{ -} - -// ---------------------------------------------------------------------- - -void StderrLogger::update() -{ -} - -// ====================================================================== - diff --git a/engine/shared/library/sharedMath/src/win32/FirstSharedMath.cpp b/engine/shared/library/sharedMath/src/win32/FirstSharedMath.cpp deleted file mode 100755 index 5f04bd2a..00000000 --- a/engine/shared/library/sharedMath/src/win32/FirstSharedMath.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstMath.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedMath/FirstSharedMath.h" diff --git a/engine/shared/library/sharedMath/src/win32/SseMath.cpp b/engine/shared/library/sharedMath/src/win32/SseMath.cpp deleted file mode 100755 index 11624aab..00000000 --- a/engine/shared/library/sharedMath/src/win32/SseMath.cpp +++ /dev/null @@ -1,430 +0,0 @@ -// ====================================================================== -// -// SseMath.cpp -// Copyright 2002 Sony Online Entertainment, Inc. -// All Rights Reserved. -// -// ====================================================================== - -#include "sharedMath/FirstSharedMath.h" -#include "sharedMath/SseMath.h" - -#include "sharedMath/Transform.h" -#include "sharedMath/Vector.h" - -// ====================================================================== - -#define SSE_ALIGN __declspec(align(16)) -#define SSE_VARIABLE_COUNT 5 - -// ====================================================================== - -namespace -{ - SSE_ALIGN float sseVariable[SSE_VARIABLE_COUNT][4]; -} - -// ====================================================================== -/** - * Retrieve whether the hardware can do SSE math. - * - * @return true if SSE math processing is available; false otherwise. - */ - -bool SseMath::canDoSseMath() -{ -#if 0 - return false; -#else - //-- First check the CPUID instruction. If it raises an exception, - // the CPUID instruction doesn't exist and SSE math support is not available. - bool cpuHasSse = false; - bool cpuHasSaveRestore = false; - - uint32 featureBits; - -#if 0 - bool osSupportsSaveRestore = false; - bool osSimdExceptionSupport = false; - bool x87EmulationDisabled = false; - - uint32 controlRegister4; - uint32 controlRegister0; -#endif - - try - { - __asm { - //-- Get features bits. - mov eax, 1 - cpuid - - mov featureBits, edx - -#if 0 - //-- Get control registers. - mov ecx, CR4 - mov controlRegister4, ecx - - mov ecx, CR0 - mov controlRegister0, ecx -#endif - } - - cpuHasSse = ((featureBits & 0x02000000) != 0); //lint !e530 // featureBits not initialized - yes it is, in the asm - cpuHasSaveRestore = ((featureBits & 0x01000000) != 0); - -#if 0 - osSupportsSaveRestore = ((controlRegister4 & 0x00000200) != 0); - osSimdExceptionSupport = ((controlRegister4 & 0x00000400) != 0); - x87EmulationDisabled = ((controlRegister0 & 0x00000004) == 0); -#endif - } - catch (...) - { //lint !e1775 // catch block does not catch any declared exceptions - } - -#if 1 - return cpuHasSse && cpuHasSaveRestore; -#else - return cpuHasSse && cpuHasSaveRestore && osSupportsSaveRestore && osSimdExceptionSupport && x87EmulationDisabled; -#endif -#endif -} - -// ---------------------------------------------------------------------- - -Vector SseMath::rotateTranslateScale_l2p(const Transform &transform, const Vector &vector, float scale) -{ - // NOTE: technically, my xmm register data contents comments are listing items in reverse order from how INTEL docs list them, left most val is really least significant value. - - __asm { - //-- Keep track of ebx. Client is crashing if I trash this. - push ebx - - //-- Load up matrix. - mov ebx, transform - - movaps xmm0, [ebx + 0] // xmm0 = a1 a2 a3 a4 - movaps xmm1, [ebx + 16] // xmm1 = b1 b2 b3 b4 - movaps xmm2, [ebx + 32] // xmm2 = c1 c2 c3 c4 - } - - //-- Prepare source vector. - sseVariable[0][0] = vector.x; - sseVariable[0][1] = vector.y; - sseVariable[0][2] = vector.z; - sseVariable[0][3] = 1.0f; - - __asm { - //-- Load up the source vector. - mov ebx, offset sseVariable - - movaps xmm3, [ebx] // xmm3 = sx sy sz 1 - - //-- Copy source to workspaces. - movaps xmm4, xmm3 // xmm4 = sx sy sz 1 - movaps xmm5, xmm3 // xmm5 = sx sy sz 1 - } - - //-- Prepare the scale vector. - __asm { - movss xmm6, scale // xmm6 = scale ? ? ? - shufps xmm6, xmm6, 0x00 // xmm6 = scale scale - movlhps xmm6, xmm6 // xmm6 = scale scale scale scale - - //-- Do the transform multiplies. - mulps xmm3, xmm0 // xmm3 = a1*sx a2*sy a3*sz a4 - mulps xmm4, xmm1 // xmm4 = b1*sx b2*sy b3*sz b4 - mulps xmm5, xmm2 // xmm5 = c1*sx c2*sy c3*sz c4 - - //-- Do the scale multiplies. - mulps xmm3, xmm6 // xmm3 = a1*sx*scale a2*sy*scale a3*sz*scale a4*scale - mulps xmm4, xmm6 // xmm4 = b1*sx*scale b2*sy*scale b3*sz*scale b4*scale - mulps xmm5, xmm6 // xmm5 = c1*sx*scale c2*sy*scale c3*sz*scale c4*scale - - //-- Save out data. - movaps [ebx + 32], xmm3 - movaps [ebx + 48], xmm4 - movaps [ebx + 64], xmm5 - - //-- Restore EBX - pop ebx - } - - // @todo consider twizzling/detwizzling to be able to perform add in sse. - return Vector( - sseVariable[2][0] + sseVariable[2][1] + sseVariable[2][2] + sseVariable[2][3], - sseVariable[3][0] + sseVariable[3][1] + sseVariable[3][2] + sseVariable[3][3], - sseVariable[4][0] + sseVariable[4][1] + sseVariable[4][2] + sseVariable[4][3]); -} //lint !e715 // scale/transform not referenced - it's in the asm - -// ---------------------------------------------------------------------- - -Vector SseMath::rotateScale_l2p(const Transform &transform, const Vector &vector, float scale) -{ -#if 0 - // @todo do the real thing. - return transform.rotate_l2p(vector) * scale; -#else - - // NOTE: technically, my xmm register data contents comments are listing items in reverse order from how INTEL docs list them, left most val is really least significant value. - - __asm { - //-- Keep track of ebx. Client is crashing if I trash this. - push ebx - - //-- Load up matrix. - mov ebx, transform - - movaps xmm0, [ebx + 0] // xmm0 = a1 a2 a3 a4 - movaps xmm1, [ebx + 16] // xmm1 = b1 b2 b3 b4 - movaps xmm2, [ebx + 32] // xmm2 = c1 c2 c3 c4 - } - - //-- Prepare source vector. - sseVariable[0][0] = vector.x; - sseVariable[0][1] = vector.y; - sseVariable[0][2] = vector.z; - sseVariable[0][3] = 0.0f; - - __asm { - //-- Load up the source vector. - mov ebx, offset sseVariable - - movaps xmm3, [ebx] // xmm3 = sx sy sz 1 - - //-- Copy source to workspaces. - movaps xmm4, xmm3 // xmm4 = sx sy sz 1 - movaps xmm5, xmm3 // xmm5 = sx sy sz 1 - } - - //-- Prepare the scale vector. - __asm { - movss xmm6, scale // xmm6 = scale ? ? ? - shufps xmm6, xmm6, 0x00 // xmm6 = scale scale - movlhps xmm6, xmm6 // xmm6 = scale scale scale scale - - //-- Do the transform multiplies. - mulps xmm3, xmm0 // xmm3 = a1*sx a2*sy a3*sz 0 - mulps xmm4, xmm1 // xmm4 = b1*sx b2*sy b3*sz 0 - mulps xmm5, xmm2 // xmm5 = c1*sx c2*sy c3*sz 0 - - //-- Do the scale multiplies. - mulps xmm3, xmm6 // xmm3 = a1*sx*scale a2*sy*scale a3*sz*scale 0 - mulps xmm4, xmm6 // xmm4 = b1*sx*scale b2*sy*scale b3*sz*scale 0 - mulps xmm5, xmm6 // xmm5 = c1*sx*scale c2*sy*scale c3*sz*scale 0 - - //-- Save out data. - movaps [ebx + 32], xmm3 - movaps [ebx + 48], xmm4 - movaps [ebx + 64], xmm5 - - //-- Restore EBX - pop ebx - } - - // @todo consider twizzling/detwizzling to be able to perform add in sse. - return Vector( - sseVariable[2][0] + sseVariable[2][1] + sseVariable[2][2], - sseVariable[3][0] + sseVariable[3][1] + sseVariable[3][2], - sseVariable[4][0] + sseVariable[4][1] + sseVariable[4][2]); - -#endif -} //lint !e715 // scale/transform not referenced - it's in the asm - -// ---------------------------------------------------------------------- - -void SseMath::skinPositionNormal_l2p(const Transform &transform, const Vector &sourcePosition, const Vector &sourceNormal, float scale, Vector &destPosition, Vector &destNormal) -{ - // NOTE: technically, my xmm register data contents comments are listing items in reverse order from how INTEL docs list them, left most val is really least significant value. - - __asm { - //-- Keep track of ebx. Client is crashing if I trash this. - push ebx - - //-- Load up matrix. - mov ebx, transform - - movaps xmm0, [ebx + 0] // xmm0 = a1 a2 a3 a4 - movaps xmm1, [ebx + 16] // xmm1 = b1 b2 b3 b4 - movaps xmm2, [ebx + 32] // xmm2 = c1 c2 c3 c4 - } - - //-- Prepare source position. - sseVariable[0][0] = sourcePosition.x; - sseVariable[0][1] = sourcePosition.y; - sseVariable[0][2] = sourcePosition.z; - sseVariable[0][3] = 1.0f; - - __asm { - //-- Load up the source vector. - mov ebx, offset sseVariable - - movaps xmm3, [ebx] // xmm3 = sx sy sz 1 - - //-- Copy source to workspaces. - movaps xmm4, xmm3 // xmm4 = sx sy sz 1 - movaps xmm5, xmm3 // xmm5 = sx sy sz 1 - - //-- Prepare the scale vector. - movss xmm6, scale // xmm6 = scale ? ? ? - shufps xmm6, xmm6, 0x00 // xmm6 = scale scale - movlhps xmm6, xmm6 // xmm6 = scale scale scale scale - - //-- Do the transform multiplies. - mulps xmm3, xmm0 // xmm3 = a1*sx a2*sy a3*sz a4 - mulps xmm4, xmm1 // xmm4 = b1*sx b2*sy b3*sz b4 - mulps xmm5, xmm2 // xmm5 = c1*sx c2*sy c3*sz c4 - - //-- Do the scale multiplies. - mulps xmm3, xmm6 // xmm3 = a1*sx*scale a2*sy*scale a3*sz*scale a4*scale - mulps xmm4, xmm6 // xmm4 = b1*sx*scale b2*sy*scale b3*sz*scale b4*scale - mulps xmm5, xmm6 // xmm5 = c1*sx*scale c2*sy*scale c3*sz*scale c4*scale - - //-- Save out data. - movaps [ebx + 32], xmm3 - movaps [ebx + 48], xmm4 - movaps [ebx + 64], xmm5 - } - - destPosition.x = sseVariable[2][0] + sseVariable[2][1] + sseVariable[2][2] + sseVariable[2][3]; - destPosition.y = sseVariable[3][0] + sseVariable[3][1] + sseVariable[3][2] + sseVariable[3][3]; - destPosition.z = sseVariable[4][0] + sseVariable[4][1] + sseVariable[4][2] + sseVariable[4][3]; - - //-- Prepare source normal. - sseVariable[0][0] = sourceNormal.x; - sseVariable[0][1] = sourceNormal.y; - sseVariable[0][2] = sourceNormal.z; - sseVariable[0][3] = 1.0f; - - __asm { - //-- Load up the source vector. - movaps xmm3, [ebx] // xmm3 = sx sy sz 1 - - //-- Copy source to workspaces. - movaps xmm4, xmm3 // xmm4 = sx sy sz 1 - movaps xmm5, xmm3 // xmm5 = sx sy sz 1 - - //-- Do the transform multiplies. - mulps xmm3, xmm0 // xmm3 = a1*sx a2*sy a3*sz a4 - mulps xmm4, xmm1 // xmm4 = b1*sx b2*sy b3*sz b4 - mulps xmm5, xmm2 // xmm5 = c1*sx c2*sy c3*sz c4 - - //-- Do the scale multiplies. - mulps xmm3, xmm6 // xmm3 = a1*sx*scale a2*sy*scale a3*sz*scale a4*scale - mulps xmm4, xmm6 // xmm4 = b1*sx*scale b2*sy*scale b3*sz*scale b4*scale - mulps xmm5, xmm6 // xmm5 = c1*sx*scale c2*sy*scale c3*sz*scale c4*scale - - //-- Save out data. - movaps [ebx + 32], xmm3 - movaps [ebx + 48], xmm4 - movaps [ebx + 64], xmm5 - - //-- Restore EBX - pop ebx - } - - destNormal.x = sseVariable[2][0] + sseVariable[2][1] + sseVariable[2][2]; - destNormal.y = sseVariable[3][0] + sseVariable[3][1] + sseVariable[3][2]; - destNormal.z = sseVariable[4][0] + sseVariable[4][1] + sseVariable[4][2]; -} //lint !e715 // scale/transform not referenced - it's in the asm - -// ---------------------------------------------------------------------- - -void SseMath::skinPositionNormalAdd_l2p(const Transform &transform, const Vector &sourcePosition, const Vector &sourceNormal, float scale, Vector &destPosition, Vector &destNormal) -{ - // NOTE: technically, my xmm register data contents comments are listing items in reverse order from how INTEL docs list them, left most val is really least significant value. - - __asm { - //-- Keep track of ebx. Client is crashing if I trash this. - push ebx - - //-- Load up matrix. - mov ebx, transform - - movaps xmm0, [ebx + 0] // xmm0 = a1 a2 a3 a4 - movaps xmm1, [ebx + 16] // xmm1 = b1 b2 b3 b4 - movaps xmm2, [ebx + 32] // xmm2 = c1 c2 c3 c4 - } - - //-- Prepare source position. - sseVariable[0][0] = sourcePosition.x; - sseVariable[0][1] = sourcePosition.y; - sseVariable[0][2] = sourcePosition.z; - sseVariable[0][3] = 1.0f; - - __asm { - //-- Load up the source vector. - mov ebx, offset sseVariable - - movaps xmm3, [ebx] // xmm3 = sx sy sz 1 - - //-- Copy source to workspaces. - movaps xmm4, xmm3 // xmm4 = sx sy sz 1 - movaps xmm5, xmm3 // xmm5 = sx sy sz 1 - - //-- Prepare the scale vector. - movss xmm6, scale // xmm6 = scale ? ? ? - shufps xmm6, xmm6, 0x00 // xmm6 = scale scale - movlhps xmm6, xmm6 // xmm6 = scale scale scale scale - - //-- Do the transform multiplies. - mulps xmm3, xmm0 // xmm3 = a1*sx a2*sy a3*sz a4 - mulps xmm4, xmm1 // xmm4 = b1*sx b2*sy b3*sz b4 - mulps xmm5, xmm2 // xmm5 = c1*sx c2*sy c3*sz c4 - - //-- Do the scale multiplies. - mulps xmm3, xmm6 // xmm3 = a1*sx*scale a2*sy*scale a3*sz*scale a4*scale - mulps xmm4, xmm6 // xmm4 = b1*sx*scale b2*sy*scale b3*sz*scale b4*scale - mulps xmm5, xmm6 // xmm5 = c1*sx*scale c2*sy*scale c3*sz*scale c4*scale - - //-- Save out data. - movaps [ebx + 32], xmm3 - movaps [ebx + 48], xmm4 - movaps [ebx + 64], xmm5 - } - - destPosition.x += sseVariable[2][0] + sseVariable[2][1] + sseVariable[2][2] + sseVariable[2][3]; - destPosition.y += sseVariable[3][0] + sseVariable[3][1] + sseVariable[3][2] + sseVariable[3][3]; - destPosition.z += sseVariable[4][0] + sseVariable[4][1] + sseVariable[4][2] + sseVariable[4][3]; - - //-- Prepare source normal. - sseVariable[0][0] = sourceNormal.x; - sseVariable[0][1] = sourceNormal.y; - sseVariable[0][2] = sourceNormal.z; - sseVariable[0][3] = 1.0f; - - __asm { - //-- Load up the source vector. - movaps xmm3, [ebx] // xmm3 = sx sy sz 1 - - //-- Copy source to workspaces. - movaps xmm4, xmm3 // xmm4 = sx sy sz 1 - movaps xmm5, xmm3 // xmm5 = sx sy sz 1 - - //-- Do the transform multiplies. - mulps xmm3, xmm0 // xmm3 = a1*sx a2*sy a3*sz a4 - mulps xmm4, xmm1 // xmm4 = b1*sx b2*sy b3*sz b4 - mulps xmm5, xmm2 // xmm5 = c1*sx c2*sy c3*sz c4 - - //-- Do the scale multiplies. - mulps xmm3, xmm6 // xmm3 = a1*sx*scale a2*sy*scale a3*sz*scale a4*scale - mulps xmm4, xmm6 // xmm4 = b1*sx*scale b2*sy*scale b3*sz*scale b4*scale - mulps xmm5, xmm6 // xmm5 = c1*sx*scale c2*sy*scale c3*sz*scale c4*scale - - //-- Save out data. - movaps [ebx + 32], xmm3 - movaps [ebx + 48], xmm4 - movaps [ebx + 64], xmm5 - - //-- Restore EBX - pop ebx - } - - destNormal.x += sseVariable[2][0] + sseVariable[2][1] + sseVariable[2][2]; - destNormal.y += sseVariable[3][0] + sseVariable[3][1] + sseVariable[3][2]; - destNormal.z += sseVariable[4][0] + sseVariable[4][1] + sseVariable[4][2]; -} //lint !e715 // scale/transform not referenced - it's in the asm - -// ====================================================================== diff --git a/engine/shared/library/sharedMath/src/win32/SseMath.h b/engine/shared/library/sharedMath/src/win32/SseMath.h deleted file mode 100755 index fcbeaef2..00000000 --- a/engine/shared/library/sharedMath/src/win32/SseMath.h +++ /dev/null @@ -1,58 +0,0 @@ -// ====================================================================== -// -// SseMath.h -// Copyright 2002 Sony Online Entertainment, Inc. -// All Rights Reserved. -// -// ====================================================================== - -#ifndef INCLUDED_SseMath_H -#define INCLUDED_SseMath_H - -// ====================================================================== - -class Transform; -class Vector; - -// ====================================================================== -#define MXCSR_FLUSH_TO_ZERO (1<<15) -#define MXCSR_PRECISION_MASK (1<<12) -#define MXCSR_UNDERFLOW_MASK (1<<11) -#define MXCSR_OVERFLOW_MASK (1<<10) -#define MXCSR_DIVIDE_BY_ZERO_MASK (1<< 9) -#define MXCSR_DENORMAL_MASK (1<< 8) - -class SseMath -{ -public: - - static bool canDoSseMath(); - - static Vector rotateTranslateScale_l2p(const Transform &transform, const Vector &vector, float scale); - static Vector rotateScale_l2p(const Transform &transform, const Vector &vector, float scale); - - static void skinPositionNormal_l2p(const Transform &transform, const Vector &position, const Vector &normal, float scale, Vector &destPosition, Vector &destNormal); - static void skinPositionNormalAdd_l2p(const Transform &transform, const Vector &position, const Vector &normal, float scale, Vector &destPosition, Vector &destNormal); - static void prefetch(void const * const sourceData, size_t const objectSize); -}; - -// ---------------------------------------------------------------------- - -inline void SseMath::prefetch(void const * const sourceData, size_t const objectSize) -{ -#if defined(_MSC_VER) - _asm - { - mov esi, sourceData - prefetchnta objectSize[esi] - } -#else - // rls - add linux version here. - UNREF(sourceData); - UNREF(objectSize); -#endif -} - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedMemoryManager/src/win32/OsMemory.cpp b/engine/shared/library/sharedMemoryManager/src/win32/OsMemory.cpp deleted file mode 100755 index a6ad6331..00000000 --- a/engine/shared/library/sharedMemoryManager/src/win32/OsMemory.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// ====================================================================== -// -// OsMemory.cpp -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedMemoryManager/FirstSharedMemoryManager.h" -#include "sharedMemoryManager/OsMemory.h" - -// ====================================================================== - -void OsMemory::install() -{ -} - -// ---------------------------------------------------------------------- - -void OsMemory::remove() -{ -} - -// ---------------------------------------------------------------------- - -void *OsMemory::reserve(size_t bytes) -{ - return VirtualAlloc(0, bytes, MEM_RESERVE, PAGE_READWRITE); -} - -// ---------------------------------------------------------------------- - -void *OsMemory::commit(void *addr, size_t bytes) -{ - return VirtualAlloc(addr, bytes, MEM_COMMIT, PAGE_READWRITE); -} - -// ---------------------------------------------------------------------- - -bool OsMemory::free(void *addr, size_t bytes) -{ - UNREF(bytes); - return VirtualFree(addr, 0, MEM_RELEASE) ? true : false; -} - -// ---------------------------------------------------------------------- - -bool OsMemory::protect(void *addr, size_t bytes, bool allowAccess) -{ - DWORD old; - BOOL result = VirtualProtect(addr, bytes, allowAccess ? PAGE_READWRITE : PAGE_NOACCESS, &old); - return result ? true : false; -} - -// ====================================================================== - diff --git a/engine/shared/library/sharedMemoryManager/src/win32/OsMemory.h b/engine/shared/library/sharedMemoryManager/src/win32/OsMemory.h deleted file mode 100755 index 07ff6918..00000000 --- a/engine/shared/library/sharedMemoryManager/src/win32/OsMemory.h +++ /dev/null @@ -1,29 +0,0 @@ -// ====================================================================== -// -// OsMemory.h -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_OsMemory_H -#define INCLUDED_OsMemory_H - -// ====================================================================== - -class OsMemory -{ -public: - static void install(); - static void remove(); - - static void * reserve(size_t bytes); - static void * commit(void *addr, size_t bytes); - static bool free(void *addr, size_t bytes); - static bool protect(void *addr, size_t bytes, bool allowAccess); -}; - -// ====================================================================== - -#endif INCLUDED_OsMemory_H - diff --git a/engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.cpp b/engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.cpp deleted file mode 100755 index c6569707..00000000 --- a/engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// ====================================================================== -// -// OsNewDel.cpp -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedMemoryManager/FirstSharedMemoryManager.h" -#include "sharedMemoryManager/OsNewDel.h" - -// ====================================================================== - -// this is here because MSVC won't call MemoryManager::allocate() from asm directly -static void * __cdecl localAllocate(size_t size, uint32 owner, bool array, bool leakTest) -{ - return MemoryManager::allocate(size, owner, array, leakTest); -} - -// ---------------------------------------------------------------------- - -// We are using the arguments (except for file and line), but MSVC can't tell that. -#pragma warning(disable: 4100) - -// ---------------------------------------------------------------------- - -__declspec(naked) void *operator new(size_t size, MemoryManagerNotALeak) -{ - _asm - { - // setup local call stack - push ebp - mov ebp, esp - - // MemoryManager::alloc(size, [return address], false, false) - push 0 - push 0 - mov eax, dword ptr [ebp+4] - push eax - mov eax, dword ptr [ebp+8] - push eax - call localAllocate - add esp, 12 - - mov esp, ebp - pop ebp - ret - } -} - -// ---------------------------------------------------------------------- - -__declspec(naked) void *operator new(size_t size) -{ - _asm - { - // setup local call stack - push ebp - mov ebp, esp - - // MemoryManager::alloc(size, [return address], false, true) - push 1 - push 0 - mov eax, dword ptr [ebp+4] - push eax - mov eax, dword ptr [ebp+8] - push eax - call localAllocate - add esp, 12 - - mov esp, ebp - pop ebp - ret - } -} - -// ---------------------------------------------------------------------- - -__declspec(naked) void *operator new[](size_t size) -{ - _asm - { - // setup local call stack - push ebp - mov ebp, esp - - // MemoryManager::alloc(size, [return address], true, true) - push 1 - push 1 - mov eax, dword ptr [ebp+4] - push eax - mov eax, dword ptr [ebp+8] - push eax - call localAllocate - add esp, 12 - - mov esp, ebp - pop ebp - ret - } -} - -// ---------------------------------------------------------------------- - -__declspec(naked) void *operator new(size_t size, const char *file, int line) -{ - _asm - { - // setup local call stack - push ebp - mov ebp, esp - - // MemoryManager::alloc(size, [return address], false, true) - push 1 - push 0 - mov eax, dword ptr [ebp+4] - push eax - mov eax, dword ptr [ebp+8] - push eax - call localAllocate - add esp, 12 - - mov esp, ebp - pop ebp - ret - } -} - -// ---------------------------------------------------------------------- - -__declspec(naked) void *operator new[](size_t size, const char *file, int line) -{ - _asm - { - // setup local call stack - push ebp - mov ebp, esp - - // MemoryManager::alloc(size, [return address], true, true) - push 1 - push 1 - mov eax, dword ptr [ebp+4] - push eax - mov eax, dword ptr [ebp+8] - push eax - call localAllocate - add esp, 12 - - mov esp, ebp - pop ebp - ret - } -} - -// ---------------------------------------------------------------------- - -#pragma warning(default: 4100) - -// ---------------------------------------------------------------------- - -void operator delete(void *pointer) -{ - if (pointer) - MemoryManager::free(pointer, false); -} - -// ---------------------------------------------------------------------- - -void operator delete[](void *pointer) -{ - if (pointer) - MemoryManager::free(pointer, true); -} - -// ---------------------------------------------------------------------- - -void operator delete(void *pointer, const char *file, int line) -{ - UNREF(file); - UNREF(line); - - if (pointer) - MemoryManager::free(pointer, false); -} - -// ---------------------------------------------------------------------- - -void operator delete[](void *pointer, const char *file, int line) -{ - UNREF(file); - UNREF(line); - - if (pointer) - MemoryManager::free(pointer, true); -} - -// ====================================================================== -// WARNING!!!!!!! -// -// The init_seg pragma command is used to create certain static objects first, before other static objects are created. -// However, multiple static variables that use the same init_seg category(i.e. compiler) are not guaranteed to destroy in any -// particular order. It is completely random based on how all the linking of static objects occurs. Since this command is being -// used on our memory manager(to overwrite new/delete) - NO OTHER STATIC SHOULD EVER USE INIT_SEG(COMPILER)!!!! This static object -// *MUST* be the final static object that is destroyed. -// -#pragma warning(disable: 4074) -#pragma init_seg(compiler) // ^-Read warning above.-^ -static MemoryManager memoryManager; - -// ====================================================================== - diff --git a/engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.h b/engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.h deleted file mode 100755 index 477a6674..00000000 --- a/engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.h +++ /dev/null @@ -1,52 +0,0 @@ -// ====================================================================== -// -// OsNewDel.h -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_OsNewDel_H -#define INCLUDED_OsNewDel_H - -// ====================================================================== - -enum MemoryManagerNotALeak -{ - MM_notALeak -}; - -void * __cdecl operator new(size_t size, MemoryManagerNotALeak); -void * __cdecl operator new(size_t size); -void * __cdecl operator new[](size_t size); -void * __cdecl operator new(size_t size, char const *file, int line); -void * __cdecl operator new[](size_t size, char const *file, int line); -void * __cdecl operator new(size_t size, void *placement); - -void operator delete(void *pointer); -void operator delete[](void *pointer); -void operator delete(void *pointer, char const *file, int line); -void operator delete[](void *pointer, char const *file, int line); -void operator delete(void *pointer, void *placement); - -#ifndef __PLACEMENT_NEW_INLINE -#define __PLACEMENT_NEW_INLINE - -inline void *operator new(size_t size, void *placement) -{ - static_cast(size); - return placement; -} - -inline void operator delete(void *pointer, void *placement) -{ - static_cast(pointer); - static_cast(placement); -} - -#endif // __PLACEMENT_NEW_INLINE - -// ====================================================================== - -#endif INCLUDED_OsNewDel_H - diff --git a/engine/shared/library/sharedMessageDispatch/src/win32/FirstSharedMessageDispatch.cpp b/engine/shared/library/sharedMessageDispatch/src/win32/FirstSharedMessageDispatch.cpp deleted file mode 100755 index c2403b0f..00000000 --- a/engine/shared/library/sharedMessageDispatch/src/win32/FirstSharedMessageDispatch.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstMessageDispatch.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedMessageDispatch/FirstSharedMessageDispatch.h" diff --git a/engine/shared/library/sharedNetwork/src/win32/Address.cpp b/engine/shared/library/sharedNetwork/src/win32/Address.cpp deleted file mode 100755 index 0d4b0b2a..00000000 --- a/engine/shared/library/sharedNetwork/src/win32/Address.cpp +++ /dev/null @@ -1,410 +0,0 @@ -// Address.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. - -//--------------------------------------------------------------------- - -#include "sharedNetwork/FirstSharedNetwork.h" -#include "sharedNetwork/Address.h" - -#include -#include - -//--------------------------------------------------------------------- -/** - @brief Construct an empty address (INADDR_ANY) - - @author Justin Randall -*/ -Address::Address() : -addr4(new struct sockaddr_in), -hostAddress("0.0.0.0") -{ - memset(addr4, 0, sizeof(struct sockaddr_in)); - addr4->sin_family = AF_INET; -} - -//--------------------------------------------------------------------- -/** - @brief construct an address from a human readable dotted-decimal - host address and port - - Care should be taken when using this constructor. It could potentially - invoke gethostbyname() and block while the resolver returns a - valid ip address. - - @author Justin Randall - - @todo Add a static resolver cache to Address to reduce potential - calls to gethostbyname() -*/ -Address::Address(const std::string & newHostAddress, const unsigned short newHostPort) : -addr4(new struct sockaddr_in), -hostAddress(newHostAddress) -{ - HOSTENT * h; - unsigned long u; - - memset(addr4, 0, sizeof(struct sockaddr_in)); - addr4->sin_port = htons(newHostPort); - addr4->sin_family = AF_INET; - // was an address supplied? - if(hostAddress.size() > 0) - { - // Is the first byte a number? (IP names begin with an alpha) - if(!isdigit(hostAddress[0])) - { - // The first byte is a letter, resolve it - if( (h = gethostbyname(hostAddress.c_str())) != 0) - { - int i = 0; - while (h->h_addr_list[i] != 0) { - memcpy(&addr4->sin_addr, h->h_addr_list[i++], sizeof(addr4->sin_addr)); - //addr4->sin_addr = *(u_long *) h->h_addr_list[i++]; - //printf("\tIP Address #%d: %s\n", i, inet_ntoa(addr)); - } - //memcpy(&addr4->sin_addr, h->h_addr_list[0], sizeof(addr4->sin_addr)); - } - else - { - // boom! grab the entry from the h_addr member instead! - if( (h = gethostbyname(hostAddress.c_str())) != 0) - { - memcpy(&addr4->sin_addr, h->h_addr, sizeof(addr4->sin_addr)); - } - else - { - // no resolution, INADDR_ANY - // could be that the network needs a kick in the ass - memset(&addr4->sin_addr, 0, sizeof(addr4->sin_addr)); - } - } - - // extract IP bytes from ipv4add4 - const unsigned char * ip; - char name[17] = {"\0"}; - - ip = reinterpret_cast(&addr4->sin_addr); - _snprintf(name, 17, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); //lint !e534 - hostAddress = name; - } - else - { - // A dotted decimal ip number string was supplied. Convert for sin_addr - u = inet_addr(hostAddress.c_str()); - memcpy(&addr4->sin_addr, &u, sizeof(addr4->sin_addr)); - } - } - else - { - // nothing was supplied, assign INADDR_ANY - addr4->sin_addr.s_addr = INADDR_ANY; - } - convertFromSockAddr(*addr4); -} - -//--------------------------------------------------------------------- -/** - @brief Address copy constructor - - @author Justin Randall -*/ -Address::Address(const Address & source) : -addr4(new struct sockaddr_in), -hostAddress(source.hostAddress) -{ - *addr4 = *source.addr4; -} - -//--------------------------------------------------------------------- -/** - @brief Constructs an address from a BSD sockaddr structure - - @author Justin Randall -*/ -Address::Address(const struct sockaddr_in & ipv4addr) : -addr4(new struct sockaddr_in), -hostAddress() -{ - convertFromSockAddr(ipv4addr); -} - -//--------------------------------------------------------------------- -/** - @brief Destroy an address - - @author Justin Randall -*/ -Address::~Address() -{ - delete addr4; -} - -//--------------------------------------------------------------------- -/** - @brief Aassign an address to anothe address -*/ -Address & Address::operator = (const Address & rhs) -{ - if(this != &rhs) - { - hostAddress = rhs.hostAddress; - *addr4 = *rhs.addr4; - } - return *this; -} - -//--------------------------------------------------------------------- -/** - @brief Assign an address to a BSD sockaddr_in structure - - @author Justin Randall -*/ -Address & Address::operator = (const struct sockaddr_in & rhs) -{ - convertFromSockAddr(rhs); - return *this; -} - -//--------------------------------------------------------------------- - -void Address::convertFromSockAddr(const struct sockaddr_in & source) -{ - // extract IP bytes from ipv4add4 - const unsigned char * ip; - char name[17] = {"\0"}; - - ip = reinterpret_cast(&source.sin_addr); - _snprintf(name, 17, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); //lint !e534 - hostAddress = name; - if(addr4 != &source) - *addr4 = source; -} - -//--------------------------------------------------------------------- -/** - @brief get a human readable host address - - Example: - \code - void foo(struct sockaddr_in & a) - { - Address b(a); - printf("address = %%s\\n", b.getHostAddress().c_str()); - } - \endcode - - @return A human readable host address string - - @author Justin Randall -*/ -const std::string & Address::getHostAddress() const -{ - return hostAddress; -} - -//--------------------------------------------------------------------- -/** - @brief get the port associated with this address - - Example: - \code - void foo(struct sockaddr_in & a) - { - Address b(a); - printf("port = %%i\\n", b.getHostPort()); - } - \endcode - - @return A human readable port in host-byte order associated with - this address. - - @author Justin Randall -*/ -const unsigned short Address::getHostPort() const -{ - return ntohs(addr4->sin_port); -} - -//--------------------------------------------------------------------- -/** - @brief get the BSD sockaddr describing this address - - Example: - \code - void foo(SOCKET s, unsigned char * d, int l, const Address & a) - { - int t = sizeof(struct sockaddr_in); - sendto(s, s, l, 0, reinterpret_cast(&(a.getSockAddr4())), t); - } - \endcode - - @return a BSD sockaddr that describes this IPv4 address - - @author Justin Randall -*/ -const struct sockaddr_in & Address::getSockAddr4() const -{ - return *addr4; -} - -//--------------------------------------------------------------------- -/** - @brief equality operator - - The equality operator compares the ip address, ip port, - and address family to establish equality. - - Example: - \code - Address a("127.0.0.1", 55443); - Address b; - - b = a; - \endcode - - @return True of the right hand side is equal to this address - - @author Justin Randall -*/ -const bool Address::operator == (const Address & rhs) const -{ - return (addr4->sin_addr.s_addr == rhs.addr4->sin_addr.s_addr && - addr4->sin_family == rhs.addr4->sin_family && - addr4->sin_port == rhs.addr4->sin_port); -} - -//--------------------------------------------------------------------- -/** - @brief less-than comparison operator - - The < comparison operator compares the IP number and port. If - the IP numbers are identical, but the left hand side port is - less than the right hand side port, the operator will return - true. - - @return true if the left hand side's IP number is less than - the right hand side IP number. If the numbers are equal, it - will return true if the left hand side IP port is less - than the right hand side port. Otherwise it returns false. - - @author Justin Randall -*/ -const bool Address::operator < (const Address & rhs) const -{ - return(addr4->sin_addr.s_addr < rhs.addr4->sin_addr.s_addr || - addr4->sin_addr.s_addr == rhs.addr4->sin_addr.s_addr && - addr4->sin_port < rhs.addr4->sin_port); -} - -//--------------------------------------------------------------------- -/** - @brief inequality operator - - Leverages the equality operator, so whenever == returns true, - this returns false, and visa versa. - - @return true if the right hand side is not equal to the left - hand side. False if they are equal. - - @see Adress::operator== - - @author Justin Randall -*/ -const bool Address::operator != (const Address & rhs) const -{ - return(! (rhs == *this)); -} - -//--------------------------------------------------------------------- -/** - @brief greater-than comparison operator - - The > comparison operator compares the IP number and port. If - the IP numbers are identical, but the right hand side port is - lesser than the left hand side port, the operator will return - true. - - @return true if the left hand side's IP number is greater than - the right hand side IP number. If the numbers are equal, it - will return true if the left hand side IP port is greater - than the right hand side port. Otherwise it returns false. - - @author Justin Randall -*/ -const bool Address::operator > (const Address & rhs) const -{ - return(addr4->sin_addr.s_addr > rhs.addr4->sin_addr.s_addr || - addr4->sin_addr.s_addr == rhs.addr4->sin_addr.s_addr && - addr4->sin_port > rhs.addr4->sin_port); -} - -//--------------------------------------------------------------------- -/** - @brief a hash_map support routine - - The STL hash_map (present in most STL implementations) requires - a size_t return from a hash function to identify which bucket - a particular value should reside in. On 32 bit or better platforms - the sockaddr_in.sin_addr.s_addr member is small enough to - qualify as a hash-result, provides reasonably unique values - and is reproducable given an address input. - - Example: - \code - typedef std::hash_map AddressMap; - \endcode - - @return the ip number member of a sockaddr_in struct - - @author Justin Randall -*/ -size_t Address::hashFunction() const -{ - return addr4->sin_addr.s_addr; -} - -//--------------------------------------------------------------------- -/** - @brief STL map support routine - - STL maps (including hash_maps) require unique keys, and therefore - need to compare a key for equality with an existing target. - - The functor uses Address::operator = for the comparison. - - Example: - \code - typedef std::unordered_map AddressMap; - \endcode - - @return true if the left hand side and right hand side are equal - using Address::operator = - @see Address::operator= - -*/ -bool Address::EqualFunction::operator () (const Address & lhs, const Address & rhs) const -{ - return lhs == rhs; -} - -//--------------------------------------------------------------------- -/** - @brief STL hash_map support routine - - The HashFunction::operator() invokes Address::hashFunction to - determine an appropriate hash for the address. - - Example: - \code - typedef std::hash_map AddressMap; - \endcode - - @see Address::hashFunction - - @author Justin Randall -*/ -size_t Address::HashFunction::operator () (const Address & a) const -{ - return a.hashFunction(); -} -//--------------------------------------------------------------------- diff --git a/engine/shared/library/sharedNetwork/src/win32/FirstSharedNetwork.cpp b/engine/shared/library/sharedNetwork/src/win32/FirstSharedNetwork.cpp deleted file mode 100755 index abf6e1d6..00000000 --- a/engine/shared/library/sharedNetwork/src/win32/FirstSharedNetwork.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// FirstSharedNetwork.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. - -//----------------------------------------------------------------------- - -#include "sharedNetwork/FirstSharedNetwork.h" - -//----------------------------------------------------------------------- - diff --git a/engine/shared/library/sharedNetwork/src/win32/NetworkGetHostName.cpp b/engine/shared/library/sharedNetwork/src/win32/NetworkGetHostName.cpp deleted file mode 100755 index faebb2b9..00000000 --- a/engine/shared/library/sharedNetwork/src/win32/NetworkGetHostName.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// NetworkGetHostName.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. - -//----------------------------------------------------------------------- - -#include "sharedNetwork/FirstSharedNetwork.h" - -#include "sharedNetwork/Address.h" -#include "sharedNetwork/NetworkHandler.h" - -#include - -//----------------------------------------------------------------------- - -struct HN -{ - HN(); - std::string hostName; -}; - -//----------------------------------------------------------------------- - -HN::HN() -{ - WSADATA wsaData; - int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); - char name[512] = {"\0"}; - if(gethostname(name, sizeof(name)) == 0) - { - Address a(name, 0); - hostName = a.getHostAddress();//name; - } -} - -//----------------------------------------------------------------------- - -const std::string & NetworkHandler::getHostName() -{ - static HN hn; - return hn.hostName; -} - -const std::string & NetworkHandler::getHumanReadableHostName() -{ - char name[512] = {"\0"}; - static std::string nameString; - if(nameString.empty()) - { - if(gethostname(name, sizeof(name)) == 0) - { - name[sizeof(name) - 1] = 0; - //hostName = name; - nameString = name; - } - } - return nameString; -} - -//----------------------------------------------------------------------- - -const std::vector > & NetworkHandler::getInterfaceAddresses() -{ - static std::vector > s; - return s; -} - -//----------------------------------------------------------------------- diff --git a/engine/shared/library/sharedNetwork/src/win32/OverlappedTcp.cpp b/engine/shared/library/sharedNetwork/src/win32/OverlappedTcp.cpp deleted file mode 100755 index c79c5b50..00000000 --- a/engine/shared/library/sharedNetwork/src/win32/OverlappedTcp.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// OverlappedTcp.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -//----------------------------------------------------------------------- - -#include "sharedNetwork/FirstSharedNetwork.h" -#include "OverlappedTcp.h" -#include -#include "TcpClient.h" -#include "TcpServer.h" - -//--------------------------------------------------------------------- - -OverlappedTcp::~OverlappedTcp() -{ - delete[] m_acceptData; - delete[] m_recvBuf.buf; -} - -//--------------------------------------------------------------------- - -struct OverlappedFreeList -{ - ~OverlappedFreeList(); - std::vector allOverlapped; - std::vector freeOverlapped; -}; - -//--------------------------------------------------------------------- - -OverlappedFreeList::~OverlappedFreeList() -{ - std::vector::const_iterator i; - for(i = allOverlapped.begin(); i != allOverlapped.end(); ++i) - { - OverlappedTcp * t = (*i); - delete t; - } -} - -//--------------------------------------------------------------------- - -OverlappedFreeList overlappedFreeList; - -//--------------------------------------------------------------------- - -OverlappedTcp * getFreeOverlapped() -{ - OverlappedTcp * result = NULL; - - if(! overlappedFreeList.freeOverlapped.empty()) - { - result = overlappedFreeList.freeOverlapped.back(); - overlappedFreeList.freeOverlapped.pop_back(); - } - else - { - result = new OverlappedTcp; - result->m_bytes = 0; - memset(&result->m_overlapped, 0, sizeof(OVERLAPPED)); - result->m_recvBuf.buf = new char[1024]; - result->m_recvBuf.len = 1024; - result->m_tcpClient = 0; - result->m_tcpServer = 0; - result->m_acceptData = 0; - overlappedFreeList.allOverlapped.push_back(result); - } - return result; -} - -//--------------------------------------------------------------------- - -void releaseOverlapped(OverlappedTcp * o) -{ - o->m_bytes = 0; - o->m_tcpClient = 0; - o->m_tcpServer = 0; - o->m_acceptData = 0; - memset(&o->m_overlapped, 0, sizeof(OVERLAPPED)); - overlappedFreeList.freeOverlapped.push_back(o); -} - -//----------------------------------------------------------------------- - diff --git a/engine/shared/library/sharedNetwork/src/win32/OverlappedTcp.h b/engine/shared/library/sharedNetwork/src/win32/OverlappedTcp.h deleted file mode 100755 index c852ab60..00000000 --- a/engine/shared/library/sharedNetwork/src/win32/OverlappedTcp.h +++ /dev/null @@ -1,47 +0,0 @@ -// OverlappedTcp.h -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -#ifndef _INCLUDED_OverlappedTcp_H -#define _INCLUDED_OverlappedTcp_H - -//----------------------------------------------------------------------- - -#include - -//----------------------------------------------------------------------- - -class TcpClient; -class TcpServer; - -//----------------------------------------------------------------------- - -struct OverlappedTcp -{ - ~OverlappedTcp(); - OVERLAPPED m_overlapped; - - enum OPERATIONS - { - INVALID, - ACCEPT, - SEND, - RECV - }; - - unsigned char * m_acceptData; // getting peer name during accept - DWORD m_bytes; - enum OPERATIONS m_operation; - const TcpServer * m_tcpServer; - TcpClient * m_tcpClient; // accepted sock when operation is accept - WSABUF m_recvBuf; -}; - -//--------------------------------------------------------------------- - -OverlappedTcp * getFreeOverlapped(); -void releaseOverlapped(OverlappedTcp *); - -//----------------------------------------------------------------------- - -#endif // _INCLUDED_OverlappedTcp_H diff --git a/engine/shared/library/sharedNetwork/src/win32/Sock.cpp b/engine/shared/library/sharedNetwork/src/win32/Sock.cpp deleted file mode 100755 index 663f6af4..00000000 --- a/engine/shared/library/sharedNetwork/src/win32/Sock.cpp +++ /dev/null @@ -1,366 +0,0 @@ -// Sock.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. - -//--------------------------------------------------------------------- - -#include "sharedNetwork/FirstSharedNetwork.h" -#include "sharedNetwork/Sock.h" - -#include - -struct WinsockStartupObject -{ - WinsockStartupObject(); - ~WinsockStartupObject(); -}; - -WinsockStartupObject::WinsockStartupObject() -{ - WSADATA wsaData; - WORD wVersionRequested; - - wVersionRequested = MAKEWORD(2,0); - int err; - err = WSAStartup(wVersionRequested, &wsaData); -} - -WinsockStartupObject::~WinsockStartupObject() -{ - WSACleanup(); -} - -WinsockStartupObject wso; - -//--------------------------------------------------------------------- -/** - @brief construct a Sock - - This constructor sets handle to INVALID_SOCKET, lastError to - Sock::SOCK_NO_ERROR and the bindAddress to the default Address. - - @see Address - - @author Justin Randall -*/ -Sock::Sock() : -handle(INVALID_SOCKET), -lastError(Sock::SOCK_NO_ERROR), -bindAddress() -{ -} - -//--------------------------------------------------------------------- -/** - @brief destroy the Sock object - - checks for a valid socket close. It is an error to close a socket - that will fail a close operation. - - Also resets handle to INVALID_SOCKET - - @author Justin Randall -*/ -Sock::~Sock() -{ - // ensure we don't block, and that pending - // data is sent with a graceful shutdown - int err; - err = closesocket(handle); - if(err == SOCKET_ERROR) - { - OutputDebugString(getLastError().c_str()); - } - handle = INVALID_SOCKET; -} - -//--------------------------------------------------------------------- -/** - @brief Bind the socket to the specified local address -*/ -bool Sock::bind(const Address & newBindAddress) -{ - bool result = false; - - int enable = 1; - setsockopt(handle, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast(&enable), sizeof(enable)); - - bindAddress = newBindAddress; - int namelen = sizeof(struct sockaddr_in); - int err = ::bind(handle, reinterpret_cast(&(bindAddress.getSockAddr4())), namelen); - if(err == 0) - { - result = true; - struct sockaddr_in a; - int r; - r = getsockname(handle, reinterpret_cast(&a), &namelen); - bindAddress = a; - } - else - { - result = false; - OutputDebugString(getLastError().c_str()); - OutputDebugString("\n"); - } - return result; -} - -//--------------------------------------------------------------------- -/** - @brief bind the socket to the first available local address - as provided by the operating system. - - This bind call is useful for client sockets, or server sockets that - can report their new address to a locator service. - - @author Justin Randall -*/ -bool Sock::bind() -{ - bool result = false; - struct sockaddr_in a; - int namelen = sizeof(struct sockaddr_in); - memset(&a, 0, sizeof(struct sockaddr_in)); - a.sin_family = AF_INET; - a.sin_port = 0; - a.sin_addr.s_addr = INADDR_ANY; - int err = ::bind(handle, reinterpret_cast(&a), namelen); - if(err == 0) - { - result = true; - int r; - r = getsockname(handle, reinterpret_cast(&a), &namelen); - bindAddress = a; - } - return result; -} - -//--------------------------------------------------------------------- -/** - @brief determine if a socket is ready to receive - - On Win32, select is invoked. On Linux, the poll() system call is - used to deterine readability of a socket. - - @return true if the socket can read data without blocking. - - @author Justin Randall - - @todo Win32 should be using WSAEventSelect and WSAEnumNetworkEvents - if they outperform select. -*/ -bool Sock::canRecv() const -{ - struct timeval tv; - fd_set r; - - tv.tv_sec = 0; - tv.tv_usec = 0; - FD_ZERO(&r); -#pragma warning (disable : 4127) - FD_SET(handle, &r); //lint !e717 // I have no idea why MS makes this a do { .. } while(0); macro?! Pointless. - return (select(1, &r, 0, 0, &tv) > 0); -} - -//--------------------------------------------------------------------- -/** - @brief determine writeability of the socket - - Win32 systems use select, Linux use poll. - - @return true if the socket can send data without blocking. - @author Justin Randall - - @todo Win32 should be using WSAEventSelect and WSAEnumNetworkEvents - if they outperform select. -*/ -bool Sock::canSend() const -{ - struct timeval tv; - fd_set w; - - tv.tv_sec = 0; - tv.tv_usec = 0; - - FD_ZERO(&w); - FD_SET(handle, &w); //lint !e717 // I have no idea why MS makes this a do { .. } while(0); macro?! Pointless. - - return (select(1, 0, &w, 0, &tv) > 0); -} - -//--------------------------------------------------------------------- -/** - @brief determine the number of bytes pending on the socket - - Uses ioctl (ioctlsocket on win32) to determine the number - of bytes pending. - - @return the number of unread bytes pending on the socket - - @author Justin Randall -*/ -const unsigned int Sock::getInputBytesPending() const -{ - unsigned long int bytes = 0; - int err; - err = ioctlsocket(handle, FIONREAD, &bytes); //lint !e1924 (I don't know WHAT Microsoft is doing here!) - return bytes; -} - -//--------------------------------------------------------------------- -/** - @brief determine the error state of the socket - - This routine also sets the lastError member of the Sock object, which - is used to determine common errors (connection failure, connection - closed, connection reset, etc..) - - @return an STL string that describes the error state of the socket, - - @author Justin Randall -*/ -const std::string Sock::getLastError() const -{ - std::string errString; - int iErr = WSAGetLastError(); - - switch(iErr) - { - case WSAENOPROTOOPT: - errString = "Bad protocol option. An unknown, invalid or unsupported option or level was specified in a getsockopt or setsockopt call."; - break; - case WSAENETDOWN: - errString = "The network subsystem has failed."; - break; - case WSAEFAULT: - errString = "The buf parameter is not completely contained in a valid part of the user address space."; - break; - case WSAENOTCONN: - errString = "The socket is not connected."; - lastError = Sock::CONNECTION_FAILED; - break; - case WSAEINTR: - errString = "The (blocking) call was canceled through WSACancelBlockingCall."; - break; - case WSAEINPROGRESS: - errString = "A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function."; - break; - case WSAENETRESET: - errString = "The connection has been broken due to the keep-alive activity detecting a failure while the operation was in progress."; - break; - case WSAENOTSOCK: - errString = "The descriptor is not a socket."; - break; - case WSAEOPNOTSUPP: - errString = "MSG_OOB was specified, but the socket is not stream-style such as type SOCK_STREAM, out-of-band data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only send operations."; - break; - case WSAESHUTDOWN: - errString = "The socket has been shut down; it is not possible to recv on a socket after shutdown has been invoked with how set to SD_RECEIVE or SD_BOTH."; - break; - case WSAEWOULDBLOCK: - errString = "The socket is marked as nonblocking and the receive operation would block."; - break; - case WSAEMSGSIZE: - errString = "The message was too large to fit into the specified buffer and was truncated."; - break; - case WSAEINVAL: - errString = "The socket has not been bound with bind, or an unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled or (for byte stream sockets only) len was zero or negative."; - break; - case WSAECONNABORTED: - errString = "The virtual circuit was terminated due to a time-out or other failure. The application should close the socket as it is no longer usable."; - lastError = Sock::CONNECTION_RESET; - break; - case WSAETIMEDOUT: - errString = "The connection has been dropped because of a network failure or because the peer system failed to respond."; - break; - case WSAECONNRESET: - errString = "The virtual circuit was reset by the remote side executing a \"hard\" or \"abortive\" close. The application should close the socket as it is no longer usable. On a UDP datagram socket this error would indicate that a previous send operation resulted in an ICMP \"Port Unreachable\" message."; - lastError = Sock::CONNECTION_RESET; - break; - case WSAECONNREFUSED: - errString = "No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host - i.e. one with no server application running. "; - lastError = Sock::CONNECTION_FAILED; - break; - default: - errString = "An unknown socket error has occurred."; - break; - } - - return errString; -} - -//----------------------------------------------------------------------- -/** @brief determine the maximum message size that may be sent on this socket -*/ -const unsigned int Sock::getMaxMessageSendSize() const -{ - /* - int maxMsgSize = 400; - int optlen = sizeof(int); - int result = getsockopt(handle, SOL_SOCKET, SO_MAX_MSG_SIZE, reinterpret_cast(&maxMsgSize), &optlen); - if(result != 0) - { - int errCode = WSAGetLastError(); - switch(errCode) - { - case WSANOTINITIALISED: - OutputDebugString("A successful WSAStartup call must occur before using this function. "); - break; - case WSAENETDOWN: - OutputDebugString("The network subsystem has failed. "); - break; - case WSAEFAULT: - OutputDebugString("One of the optval or the optlen parameters is not a valid part of the user address space, or the optlen parameter is too small. "); - case WSAEINPROGRESS: - OutputDebugString("A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function. "); - break; - case WSAEINVAL: - OutputDebugString("The level parameter is unknown or invalid. "); - break; - case WSAENOPROTOOPT: - OutputDebugString("The option is unknown or unsupported by the indicated protocol family. "); - break; - case WSAENOTSOCK: - OutputDebugString("The descriptor is not a socket. "); - break; - default: - OutputDebugString("An unknown error occurred while processing getsockopt"); - break; - } - } - */ - return 400; -} - -//--------------------------------------------------------------------- -/** - @brief get a BSD sockaddr struct describing the remote address - of a socket - - @param target a BSD sockaddr struct that will receive the peer - address - @param s the socket to query for the peername - - @author Justin Randall -*/ -void Sock::getPeerName(struct sockaddr_in & target, SOCKET s) -{ - int namelen = sizeof(struct sockaddr_in); - int err; - err = getpeername(s, reinterpret_cast(&(target)), &namelen); -} - -//--------------------------------------------------------------------- -/** @brief a support routine to place the socket in non-blocking mode - - @author Justin Randall -*/ -void Sock::setNonBlocking() const -{ - unsigned long int nb = 1; - int err; - err = ioctlsocket(handle, FIONBIO, &nb); //lint !e569 // loss of precision in the FIONBIO macro, beyond my control - if(err == SOCKET_ERROR) - OutputDebugString(getLastError().c_str()); -} - -//--------------------------------------------------------------------- diff --git a/engine/shared/library/sharedNetwork/src/win32/Sock.h b/engine/shared/library/sharedNetwork/src/win32/Sock.h deleted file mode 100755 index d5dbb028..00000000 --- a/engine/shared/library/sharedNetwork/src/win32/Sock.h +++ /dev/null @@ -1,129 +0,0 @@ -// ====================================================================== -// -// Sock.h -// -// Copyright 2003 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_Sock_H -#define INCLUDED_Sock_H - -// ====================================================================== - -#include "sharedNetwork/Address.h" - -// ====================================================================== - -const unsigned int SOCK_ERROR = 0xFFFFFFFF; -typedef unsigned int SOCKET; - -/** - @brief a BSD socket abstraction - - Sock abstracts BSD sockets for platform independant operation. It - also provides common socket operations to simplify socket management. - - @see BroadcastSock - @see TcpSock - @see UdpSock - - @author Justin Randall -*/ -class Sock -{ -public: - /** - @brief failure states for a socket - */ - enum ErrorCodes - { - SOCK_NO_ERROR, - CONNECTION_FAILED, - CONNECTION_CLOSED, - CONNECTION_RESET - }; - - Sock(); - virtual ~Sock() = 0; - bool bind(const Address & bindAddress); - bool bind(); - bool canSend() const; - bool canRecv() const; - const Address & getBindAddress() const; - const SOCKET getHandle() const; - const unsigned int getInputBytesPending() const; - const std::string getLastError() const; - const enum ErrorCodes getLastErrorCode() const; - const unsigned int getMaxMessageSendSize() const; - static void getPeerName(struct sockaddr_in & target, SOCKET s); - -private: - // disabled - Sock(const Sock & source); - Sock & operator= (const Sock & source); - -protected: - void setNonBlocking() const; -protected: - int handle; - - /** - @brief support for setting/getting last error from derived - sock classes - */ - mutable enum ErrorCodes lastError; -private: - Address bindAddress; -}; - -//--------------------------------------------------------------------- -/** - @brief return the local address of the socket - - Until a socket is bound, the bind address may be reported as - 0.0.0.0:0 - - @return a const Address reference describing the local address - of the socket. - - @author Justin Randall -*/ -inline const Address & Sock::getBindAddress() const -{ - return bindAddress; -} - -//--------------------------------------------------------------------- -/** - @brief return the platform specific socket handle - - the handle returned is not portable and should only be used locally - for Sock specific operations. - - @author Justin Randall -*/ -inline const SOCKET Sock::getHandle() const -{ - return handle; -} - -//--------------------------------------------------------------------- -/** - @brief get the last error code on the socket - - @return the last error code on the socket - - @see Sock::ErrorCodes - - @author Justin Randall -*/ -inline const enum Sock::ErrorCodes Sock::getLastErrorCode() const -{ - return lastError; -} - -//--------------------------------------------------------------------- - -#endif // _Sock_H - diff --git a/engine/shared/library/sharedNetwork/src/win32/TcpClient.cpp b/engine/shared/library/sharedNetwork/src/win32/TcpClient.cpp deleted file mode 100755 index 22c9d992..00000000 --- a/engine/shared/library/sharedNetwork/src/win32/TcpClient.cpp +++ /dev/null @@ -1,631 +0,0 @@ -// TcpClient.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -//----------------------------------------------------------------------- - -#include "sharedNetwork/FirstSharedNetwork.h" -#include "Archive/Archive.h" -#include "Archive/ByteStream.h" -#include "sharedFoundation/Clock.h" -#include "sharedNetwork/Address.h" -#include "sharedNetwork/ConfigSharedNetwork.h" -#include "sharedNetwork/Connection.h" -#include "sharedNetwork/Service.h" -#include "OverlappedTcp.h" -#include "TcpClient.h" -#include -#include - -//----------------------------------------------------------------------- - -const unsigned long KEEPALIVE_MS = 1000; - -//----------------------------------------------------------------------- - -namespace TcpClientNamespace -{ - std::set s_pendingConnectionSends; - std::set s_pendingConnectionRemoves; - std::set s_tcpClients; - QOS s_sqos; - QOS s_gqos; -} - -using namespace TcpClientNamespace; - -//----------------------------------------------------------------------- - -TcpClient::TcpClient(HANDLE parentIOCP) : -m_connectEvent(INVALID_HANDLE_VALUE), -m_socket(), -m_tcpServer(0), -m_localIOCP(INVALID_HANDLE_VALUE), -m_pendingSend(), -m_connection(0), -m_refCount(0), -m_connected(false), -m_ownHandle(false), -m_lastSendTime(0), -m_bindPort(0), -m_rawTCP( false ) -{ - static PROTOENT * p = getprotobyname ("tcp"); - if (p) - { - static int entry = p->p_proto; - m_socket = WSASocket (AF_INET, SOCK_STREAM, entry, NULL, 0, WSA_FLAG_OVERLAPPED); - char optval = 1; - setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); - setsockopt(m_socket, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof(optval)); - unsigned long opt = 1; - ioctlsocket(m_socket, FIONBIO, &opt); - - struct sockaddr_in bindAddr; - int addrLen = sizeof(struct sockaddr_in); - if(getsockname(m_socket, reinterpret_cast(&bindAddr), &addrLen) == 0) - { - m_bindPort = ntohs(bindAddr.sin_port); - } - - m_localIOCP = CreateIoCompletionPort (reinterpret_cast (m_socket), parentIOCP, 0, 0); - queueReceive(); - } - s_tcpClients.insert(this); -} - -//----------------------------------------------------------------------- - -TcpClient::TcpClient(const std::string & remoteAddress, const unsigned short remotePort) : -m_connectEvent(INVALID_HANDLE_VALUE), -m_socket(), -m_localIOCP(INVALID_HANDLE_VALUE), -m_connection(0), -m_refCount(0), -m_connected(false), -m_ownHandle(true), -m_lastSendTime(0), -m_rawTCP( false ) -{ - static PROTOENT * p = getprotobyname ("tcp"); - if (p) - { - static int entry = p->p_proto; - m_socket = WSASocket (AF_INET, SOCK_STREAM, entry, NULL, 0, WSA_FLAG_OVERLAPPED); - if (m_socket != INVALID_SOCKET) - { - int nameLen = sizeof (struct sockaddr_in); - static WSABUF emptyBuf; - emptyBuf.buf = 0; - emptyBuf.len = 0; - - Address a(remoteAddress, remotePort); - char optval = 1; - setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); - setsockopt(m_socket, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof(optval)); - unsigned long opt = 1; - ioctlsocket(m_socket, FIONBIO, &opt); - - int result; - result = WSAConnect (m_socket, reinterpret_cast (&a.getSockAddr4 () ), nameLen, 0, &emptyBuf, &s_sqos, &s_gqos); - m_connectEvent = WSACreateEvent (); - WSAEventSelect (m_socket, m_connectEvent, FD_CONNECT); - m_localIOCP = CreateIoCompletionPort (reinterpret_cast (m_socket), 0, 0, 0); - struct sockaddr_in bindAddr; - int addrLen = sizeof(struct sockaddr_in); - if(getsockname(m_socket, reinterpret_cast(&bindAddr), &addrLen) == 0) - { - m_bindPort = ntohs(bindAddr.sin_port); - } - - } - } - s_tcpClients.insert(this); -} - -//----------------------------------------------------------------------- - -TcpClient::~TcpClient() -{ - s_pendingConnectionRemoves.insert(this); - std::set::iterator f = s_tcpClients.find(this); - if(f != s_tcpClients.end()) - s_tcpClients.erase(f); - - closesocket (m_socket); - if(m_ownHandle) - CloseHandle(m_localIOCP); -} - -//----------------------------------------------------------------------- - -void TcpClient::addRef() -{ - m_refCount++; -} - -//----------------------------------------------------------------------- - -unsigned short TcpClient::getBindPort() const -{ - return m_bindPort; -} - -//----------------------------------------------------------------------- - -std::string const &TcpClient::getRemoteAddress() const -{ - // TODO: implement this - static std::string dummy; - return dummy; -} - -//----------------------------------------------------------------------- - -unsigned short TcpClient::getRemotePort() const -{ - // TODO: implement this - return 0; -} - -//----------------------------------------------------------------------- - -void TcpClient::commit(const unsigned char * const buffer, const int bufferLen) -{ - WSABUF wsaBuf; - - // yuck, docs say this is actually going to be const for the send, - // but WSABUF::buf is not const! - wsaBuf.buf = (char *)buffer; - wsaBuf.len = bufferLen; - - OverlappedTcp * op = getFreeOverlapped (); - if (op) - { - op->m_operation = OverlappedTcp::SEND; - op->m_tcpClient = const_cast(this); - int sent; - sent = WSASend (m_socket, &wsaBuf, 1, &op->m_bytes, 0, &op->m_overlapped, NULL); - if(sent == SOCKET_ERROR) - { - int errCode = WSAGetLastError(); - char * err; - if(errCode != WSA_IO_PENDING) - { - switch(errCode) - { - case WSANOTINITIALISED: - err = "A successful WSAStartup must occur before using this function."; - break; - case WSAENETDOWN: - err = "The network subsystem has failed."; - break; - case WSAENOTCONN: - err = "The socket is not connected."; - break; - case WSAEINTR: - err = "The (blocking) call was canceled through WSACancelBlockingCall. \n"; - break; - case WSAEINPROGRESS: - err = "A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function. \n"; - break; - case WSAENETRESET: - err = "The connection has been broken due to \"keep-alive\" activity detecting a failure while the operation was in progress."; - break; - case WSAENOTSOCK: - err = "The descriptor is not a socket."; - break; - case WSAEFAULT: - err = "The lpBuffers parameter is not completely contained in a valid part of the user address space."; - break; - case WSAEOPNOTSUPP: - err = "MSG_OOB was specified, but the socket is not stream-style such as type SOCK_STREAM, out-of-band data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only send operations."; - break; - case WSAESHUTDOWN: - err = "The socket has been shut down; it is not possible to call WSARecv on a socket after shutdown has been invoked with how set to SD_RECEIVE or SD_BOTH. \n"; - break; - case WSAEWOULDBLOCK: - err = "Overlapped sockets: There are too many outstanding overlapped I/O requests. Nonoverlapped sockets: The socket is marked as nonblocking and the receive operation cannot be completed immediately. \n"; - break; - case WSAEMSGSIZE: - err = "The message was too large to fit into the specified buffer and (for unreliable protocols only) any trailing portion of the message that did not fit into the buffer has been discarded."; - break; - case WSAEINVAL: - err = "The socket has not been bound (for example, with bind)."; - break; - case WSAECONNABORTED: - err = "The virtual circuit was terminated due to a time-out or other failure. \n"; - break; - case WSAECONNRESET: - err = "The virtual circuit was reset by the remote side. \n"; - break; - case WSAEDISCON: - err = "Socket s is message oriented and the virtual circuit was gracefully closed by the remote side. \n"; - break; - case WSA_IO_PENDING: - err = "An overlapped operation was successfully initiated and completion will be indicated at a later time. \n"; - break; - case WSA_OPERATION_ABORTED: - err = "The overlapped operation has been canceled due to the closure of the socket. \n"; - break; - default: - err = "An unknown error occured while processing WSARecv()."; - break; - } - onConnectionClosed(); - } - } - } -} - -//----------------------------------------------------------------------- - -void TcpClient::flush() -{ - if(m_connected && m_pendingSend.getSize() > 0) - { - // put it on the wire - commit(m_pendingSend.getBuffer(), m_pendingSend.getSize()); - m_pendingSend.clear (); - } -} - -//----------------------------------------------------------------------- - -void TcpClient::flushPendingWrites() -{ - std::set::iterator f; - std::set::iterator i; - for(i = s_pendingConnectionSends.begin(); i != s_pendingConnectionSends.end(); ++i) - { - if(s_pendingConnectionRemoves.empty()) - { - (*i)->flush(); - } - else - { - f = s_pendingConnectionRemoves.find((*i)); - if(f == s_pendingConnectionRemoves.end()) - (*i)->flush(); - } - } - s_pendingConnectionSends.clear(); -} - -//----------------------------------------------------------------------- - -SOCKET TcpClient::getSocket() const -{ - return m_socket; -} - -//----------------------------------------------------------------------- - -void TcpClient::install() -{ - WORD wVersionRequested = MAKEWORD(2,2); - WSADATA wsaData; - WSAStartup(wVersionRequested, &wsaData); - s_sqos.ProviderSpecific.buf = 0; - s_sqos.ProviderSpecific.len = 0; - - s_sqos.ReceivingFlowspec.DelayVariation = 0; - s_sqos.ReceivingFlowspec.Latency = 0; - s_sqos.ReceivingFlowspec.MaxSduSize = 0; - s_sqos.ReceivingFlowspec.MinimumPolicedSize = 0; - s_sqos.ReceivingFlowspec.PeakBandwidth = 0; - s_sqos.ReceivingFlowspec.ServiceType = 0; - s_sqos.ReceivingFlowspec.TokenBucketSize = 0; - s_sqos.ReceivingFlowspec.TokenRate = 0; - - s_sqos.SendingFlowspec.DelayVariation = 0; - s_sqos.SendingFlowspec.Latency = 0; - s_sqos.SendingFlowspec.MaxSduSize = 0; - s_sqos.SendingFlowspec.MinimumPolicedSize = 0; - s_sqos.SendingFlowspec.PeakBandwidth = 0; - s_sqos.SendingFlowspec.ServiceType = 0; - s_sqos.SendingFlowspec.TokenBucketSize = 0; - s_sqos.SendingFlowspec.TokenRate = 0; - - s_gqos.ProviderSpecific.buf = 0; - s_gqos.ProviderSpecific.len = 0; - - s_gqos.ReceivingFlowspec.DelayVariation = 0; - s_gqos.ReceivingFlowspec.Latency = 0; - s_gqos.ReceivingFlowspec.MaxSduSize = 0; - s_gqos.ReceivingFlowspec.MinimumPolicedSize = 0; - s_gqos.ReceivingFlowspec.PeakBandwidth = 0; - s_gqos.ReceivingFlowspec.ServiceType = 0; - s_gqos.ReceivingFlowspec.TokenBucketSize = 0; - s_gqos.ReceivingFlowspec.TokenRate = 0; - - s_gqos.SendingFlowspec.DelayVariation = 0; - s_gqos.SendingFlowspec.Latency = 0; - s_gqos.SendingFlowspec.MaxSduSize = 0; - s_gqos.SendingFlowspec.MinimumPolicedSize = 0; - s_gqos.SendingFlowspec.PeakBandwidth = 0; - s_gqos.SendingFlowspec.ServiceType = 0; - s_gqos.SendingFlowspec.TokenBucketSize = 0; - s_gqos.SendingFlowspec.TokenRate = 0; -} - -//----------------------------------------------------------------------- - -void TcpClient::onConnectionClosed() -{ - m_connected = false; - if(m_connection) - { - NetworkHandler::onTerminate(m_connection); - } -} - -//----------------------------------------------------------------------- - -void TcpClient::onConnectionOpened() -{ - m_connected = true; - queueReceive(); - flush(); - if(m_connection) - m_connection->onConnectionOpened(); -} - -//----------------------------------------------------------------------- - -void TcpClient::onReceive(const unsigned char * const buffer, const int length) -{ - queueReceive(); - if(m_connection) - { - m_connection->receive(buffer, length); - } -} - -//----------------------------------------------------------------------- - -void TcpClient::queryConnect() -{ - bool result = false; - - WSANETWORKEVENTS w; - if (WSAEnumNetworkEvents (m_socket, m_connectEvent, &w) != SOCKET_ERROR) - { - if (w.lNetworkEvents == FD_CONNECT) - { - if (w.iErrorCode[FD_CONNECT_BIT] == 0) - { - CloseHandle (m_connectEvent); - result = true; - onConnectionOpened(); - } - else - { - onConnectionClosed(); - } - } - } -} - -//----------------------------------------------------------------------- - -void TcpClient::queueReceive() -{ - OverlappedTcp * op = getFreeOverlapped(); - op->m_operation = OverlappedTcp::RECV; - op->m_tcpClient = const_cast(this); - DWORD flags = 0; - int result; - result = WSARecv(m_socket, &op->m_recvBuf, 1, &op->m_bytes, &flags, &op->m_overlapped, NULL); - - if(result == SOCKET_ERROR) - { - int errCode = WSAGetLastError(); - char * err; - if(errCode != WSA_IO_PENDING) - { - switch(errCode) - { - case WSANOTINITIALISED: - err = "A successful WSAStartup must occur before using this function."; - break; - case WSAENETDOWN: - err = "The network subsystem has failed."; - break; - case WSAENOTCONN: - err = "The socket is not connected."; - break; - case WSAEINTR: - err = "The (blocking) call was canceled through WSACancelBlockingCall. \n"; - break; - case WSAEINPROGRESS: - err = "A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function. \n"; - break; - case WSAENETRESET: - err = "The connection has been broken due to \"keep-alive\" activity detecting a failure while the operation was in progress."; - break; - case WSAENOTSOCK: - err = "The descriptor is not a socket."; - break; - case WSAEFAULT: - err = "The lpBuffers parameter is not completely contained in a valid part of the user address space."; - break; - case WSAEOPNOTSUPP: - err = "MSG_OOB was specified, but the socket is not stream-style such as type SOCK_STREAM, out-of-band data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only send operations."; - break; - case WSAESHUTDOWN: - err = "The socket has been shut down; it is not possible to call WSARecv on a socket after shutdown has been invoked with how set to SD_RECEIVE or SD_BOTH. \n"; - break; - case WSAEWOULDBLOCK: - err = "Overlapped sockets: There are too many outstanding overlapped I/O requests. Nonoverlapped sockets: The socket is marked as nonblocking and the receive operation cannot be completed immediately. \n"; - break; - case WSAEMSGSIZE: - err = "The message was too large to fit into the specified buffer and (for unreliable protocols only) any trailing portion of the message that did not fit into the buffer has been discarded."; - break; - case WSAEINVAL: - err = "The socket has not been bound (for example, with bind)."; - break; - case WSAECONNABORTED: - err = "The virtual circuit was terminated due to a time-out or other failure. \n"; - break; - case WSAECONNRESET: - err = "The virtual circuit was reset by the remote side. \n"; - break; - case WSAEDISCON: - err = "Socket s is message oriented and the virtual circuit was gracefully closed by the remote side. \n"; - break; - case WSA_IO_PENDING: - err = "An overlapped operation was successfully initiated and completion will be indicated at a later time. \n"; - break; - case WSA_OPERATION_ABORTED: - err = "The overlapped operation has been canceled due to the closure of the socket. \n"; - break; - default: - err = "An unknown error occured while processing WSARecv()."; - break; - } - } - } -} - -//----------------------------------------------------------------------- - -void TcpClient::send(const unsigned char * const buffer, const int length) -{ - if (length) - { - m_lastSendTime = Clock::getFrameStartTimeMs(); - s_pendingConnectionSends.insert(this); - if( !m_rawTCP ) - Archive::put(m_pendingSend, length); - m_pendingSend.put(buffer, length); - - static int const tcpMinimumFrame = ConfigSharedNetwork::getTcpMinimumFrame(); - if (static_cast(m_pendingSend.getSize()) >= tcpMinimumFrame) - flush(); - } -} - -//----------------------------------------------------------------------- - -void TcpClient::setConnection(Connection * c) -{ - m_connection = c; -} - -//--------------------------------------------------------------------- - -void TcpClient::update() -{ - OVERLAPPED * overlapped = 0; - OverlappedTcp * op = 0; - unsigned long int bytesTransferred = 0; - unsigned long int completionKey = 0; - bool success = false; - - if (m_connected) - { - unsigned long timeNow = Clock::getFrameStartTimeMs(); - if (timeNow-m_lastSendTime > KEEPALIVE_MS) - { - m_lastSendTime = timeNow; - s_pendingConnectionSends.insert(this); - Archive::put(m_pendingSend, 0); - } - } - - if(! m_connected) - queryConnect(); - - //PlatformTcpClient::queryConnects(); - do - { - success = false; - int ok = GetQueuedCompletionStatus( - m_localIOCP, // completion port of interest - &bytesTransferred, // number of bytes sent or received - &completionKey, - &overlapped, - 0 // timeout immediately if there are no completions - ); - if(ok) - { - op = reinterpret_cast(overlapped); - if(op) - { - switch(op->m_operation) - { - case OverlappedTcp::RECV: - { - if(op->m_tcpClient != 0) - { - if(bytesTransferred > 0) - { - op->m_tcpClient->onReceive((const unsigned char * const)op->m_recvBuf.buf, bytesTransferred); - success = true; - } - } - } - - break; - case OverlappedTcp::SEND: - success = true; - break; - default: - break; - } - releaseOverlapped(op); - } - } - } while(success); -} - -//----------------------------------------------------------------------- - -void TcpClient::setRawTCP( bool bNewValue ) -{ - m_rawTCP = bNewValue; -} - -//----------------------------------------------------------------------- - -void TcpClient::release() -{ - m_refCount--; - if(m_refCount < 1) - { - if(m_connected) - onConnectionClosed(); - delete this; - } -} - -//----------------------------------------------------------------------- - -void TcpClient::remove() -{ - std::set::iterator i; - for(i = s_tcpClients.begin(); i != s_tcpClients.end(); ++i) - { - TcpClient * c = (*i); - delete c; - } - s_tcpClients.clear(); - WSACleanup(); -} - -//----------------------------------------------------------------------- - -void TcpClient::checkKeepalive() -{ - unsigned long const timeNow = Clock::getFrameStartTimeMs(); - if (timeNow-m_lastSendTime > KEEPALIVE_MS) - { - m_lastSendTime = timeNow; - s_pendingConnectionSends.insert(this); - Archive::put(m_pendingSend, 0); - } -} - -//----------------------------------------------------------------------- - diff --git a/engine/shared/library/sharedNetwork/src/win32/TcpClient.h b/engine/shared/library/sharedNetwork/src/win32/TcpClient.h deleted file mode 100755 index a83ec780..00000000 --- a/engine/shared/library/sharedNetwork/src/win32/TcpClient.h +++ /dev/null @@ -1,87 +0,0 @@ -// TcpClient.h -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -#ifndef _INCLUDED_TcpClient_H -#define _INCLUDED_TcpClient_H - -//----------------------------------------------------------------------- - -#include -#include "Archive/ByteStream.h" -#include - -//----------------------------------------------------------------------- - -class Connection; - -//----------------------------------------------------------------------- - -class TcpClient -{ -public: - explicit TcpClient(HANDLE parentIOCP); - TcpClient(const std::string & address, const unsigned short port); - ~TcpClient(); - - static void install(); - static void remove(); - void send(const unsigned char * const buffer, const int length); - unsigned short getBindPort() const; - std::string const &getRemoteAddress() const; - unsigned short getRemotePort() const; - void setPendingSendAllocatedSizeLimit(unsigned int limit); - - // only used by clients - void update(); - static void flushPendingWrites(); - -protected: - friend TcpServer; - friend Connection; - - void addRef(); - void commit(const unsigned char * const buffer, const int bufferLen); - SOCKET getSocket() const; - void onConnectionClosed(); - void onConnectionOpened(); - void onReceive(const unsigned char * const recvBuf, const int bytes); - void queryConnect(); - void queueReceive(); - void release(); - void setConnection(Connection *); - - void checkKeepalive(); - void setRawTCP( bool bNewValue ); - - -private: - TcpClient & operator = (const TcpClient & rhs); - TcpClient(const TcpClient & source); - void flush (); - - WSAEVENT m_connectEvent; - SOCKET m_socket; - TcpServer * m_tcpServer; - HANDLE m_localIOCP; - Archive::ByteStream m_pendingSend; - Connection * m_connection; - int m_refCount; - bool m_connected; - bool m_ownHandle; - unsigned long m_lastSendTime; - unsigned short m_bindPort; - - bool m_rawTCP; -}; - -//----------------------------------------------------------------------- - -inline void TcpClient::setPendingSendAllocatedSizeLimit(const unsigned int limit) -{ - m_pendingSend.setAllocatedSizeLimit(limit); -} - -//----------------------------------------------------------------------- - -#endif // _INCLUDED_TcpClient_H diff --git a/engine/shared/library/sharedNetwork/src/win32/TcpServer.cpp b/engine/shared/library/sharedNetwork/src/win32/TcpServer.cpp deleted file mode 100755 index 17a8f5da..00000000 --- a/engine/shared/library/sharedNetwork/src/win32/TcpServer.cpp +++ /dev/null @@ -1,194 +0,0 @@ -// TcpServer.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -//----------------------------------------------------------------------- - -#include "sharedNetwork/FirstSharedNetwork.h" -#include -#include -#include "sharedNetwork/Address.h" -#include "sharedNetwork/Service.h" -#include "OverlappedTcp.h" -#include "TcpClient.h" -#include "TcpServer.h" - -//----------------------------------------------------------------------- - -TcpServer::TcpServer(Service * service, const std::string & bindAddress, const unsigned short bindPort) : -m_handle(), -m_localIOCP(), -m_pendingConnections(), -m_bindAddress(bindAddress), -m_bindPort(bindPort), -m_service(service) -{ - static PROTOENT * p = getprotobyname("tcp"); - if(p) - { - static int entry = p->p_proto; - m_handle = WSASocket(AF_INET, SOCK_STREAM, entry, NULL, 0, WSA_FLAG_OVERLAPPED); - if(m_handle != INVALID_SOCKET) - { - m_localIOCP = CreateIoCompletionPort(reinterpret_cast(m_handle), 0, 0, 0); - Address a(bindAddress, bindPort); - - int result = bind(m_handle, reinterpret_cast(&a.getSockAddr4()), sizeof(struct sockaddr_in)); - if(result == 0) - { - struct sockaddr_in b; - int addrlen = sizeof(struct sockaddr_in); - getsockname(m_handle, (struct sockaddr *)(&b), &addrlen); - m_bindPort = ntohs(b.sin_port); - result = listen(m_handle, 256); - queueAccept(); - } - } - } -} - -//----------------------------------------------------------------------- - -TcpServer::~TcpServer() -{ - closesocket(m_handle); - CloseHandle(m_localIOCP); -} - -//----------------------------------------------------------------------- - -TcpClient * TcpServer::accept() -{ - TcpClient * result = 0; - if(! m_pendingConnections.empty()) - { - result = m_pendingConnections.back(); - m_pendingConnections.pop_back(); - } - return result; -} - -//----------------------------------------------------------------------- - -const unsigned short TcpServer::getBindPort() const -{ - return m_bindPort; -} - -//----------------------------------------------------------------------- - -void TcpServer::onConnectionClosed(TcpClient *) -{ -} - -//----------------------------------------------------------------------- - -void TcpServer::queueAccept() -{ - OverlappedTcp * op = getFreeOverlapped(); - - // this will contain struct sockaddr data with additional - // book keeping when Windows returns an overlapped - // accept operation (nevermind that +16 or * 2, I don't have the MS - // kb article handy, but it's a gross workaround for the documented - // API and what acceptData really expects to have). - op->m_acceptData = new unsigned char[(sizeof( struct sockaddr_in ) + 16 ) * 2]; - op->m_operation = OverlappedTcp::ACCEPT; - op->m_tcpServer = this; - op->m_tcpClient = new TcpClient(m_localIOCP); - AcceptEx( - m_handle, - op->m_tcpClient->getSocket(), - op->m_acceptData, - 0, - sizeof(struct sockaddr_in) + 16, - sizeof(struct sockaddr_in) + 16, - &op->m_bytes, - &op->m_overlapped); -} - -//----------------------------------------------------------------------- - -void TcpServer::update() -{ - OVERLAPPED * overlapped = 0; - OverlappedTcp * op = 0; - unsigned long int bytesTransferred = 0; - unsigned long int completionKey = 0; - bool success = false; - - do - { - success = false; - int ok = GetQueuedCompletionStatus( - m_localIOCP, // completion port of interest - &bytesTransferred, // number of bytes sent or received - &completionKey, - &overlapped, - 0 // timeout immediately if there are no completions - ); - if(ok) - { - op = reinterpret_cast(overlapped); - if(op) - { - switch(op->m_operation) - { - case OverlappedTcp::ACCEPT: - { - if(op->m_tcpServer == this) - { - if(op->m_acceptData != 0) - { - // Extremely lame hack to keep things safe from Winsock stacktrashing - //struct sockaddr_in local; - //struct sockaddr_in remote; - //memcpy(&local, reinterpret_cast(op->m_acceptData + 10), sizeof(struct sockaddr_in)); - //memcpy(&remote, reinterpret_cast(op->m_acceptData + 38), sizeof(struct sockaddr_in)); - delete[] op->m_acceptData; - TcpClient * newClient = op->m_tcpClient; - newClient->addRef(); - newClient->onConnectionOpened(); - m_pendingConnections.push_back(newClient); - success = true; - queueAccept(); - if(m_service) - { - m_service->onConnectionOpened(newClient); - } - newClient->release(); - } - } - } - break; - case OverlappedTcp::RECV: - { - if(op->m_tcpClient != 0) - { - op->m_tcpClient->onReceive((const unsigned char * const)op->m_recvBuf.buf, bytesTransferred); - } - } - success = true; - break; - case OverlappedTcp::SEND: - success = true; - break; - default: - break; - } - releaseOverlapped(op); - } - } - } while(success); -} - -//----------------------------------------------------------------------- - -const std::string & TcpServer::getBindAddress() const -{ - return m_bindAddress; -} - -//--------------------------------------------------------------------- - - diff --git a/engine/shared/library/sharedNetwork/src/win32/TcpServer.h b/engine/shared/library/sharedNetwork/src/win32/TcpServer.h deleted file mode 100755 index 2ae6b934..00000000 --- a/engine/shared/library/sharedNetwork/src/win32/TcpServer.h +++ /dev/null @@ -1,50 +0,0 @@ -// TcpServer.h -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -#ifndef _INCLUDED_TcpServer_H -#define _INCLUDED_TcpServer_H - -//----------------------------------------------------------------------- - -#include -#include -#include - -//----------------------------------------------------------------------- - -class Service; -class TcpClient; - -//----------------------------------------------------------------------- - -class TcpServer -{ -public: - TcpServer(Service * service, const std::string & bindAddress, const unsigned short bindPort); - ~TcpServer(); - - TcpClient * accept (); - const std::string & getBindAddress () const; - const unsigned short getBindPort () const; - void onConnectionClosed (TcpClient *); - void update (); - -private: - TcpServer & operator = (const TcpServer & rhs); - TcpServer(const TcpServer & source); - - void queueAccept (); - -private: - SOCKET m_handle; - HANDLE m_localIOCP; - std::vector m_pendingConnections; - std::string m_bindAddress; - unsigned short m_bindPort; - Service * m_service; -}; - -//----------------------------------------------------------------------- - -#endif // _INCLUDED_TcpServer_H diff --git a/engine/shared/library/sharedNetwork/src/win32/UdpSock.cpp b/engine/shared/library/sharedNetwork/src/win32/UdpSock.cpp deleted file mode 100755 index 05224a37..00000000 --- a/engine/shared/library/sharedNetwork/src/win32/UdpSock.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// UdpSock.cpp -// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved. - -//--------------------------------------------------------------------- - -#include "sharedNetwork/FirstSharedNetwork.h" -#include "sharedNetwork/UdpSock.h" - -#include - -//--------------------------------------------------------------------- -/** - @brief construct a UdpSock object - - Allocates the socket descriptor, sets it to non-blocking mode. - - @author Justin Randall -*/ -UdpSock::UdpSock() : -Sock() -{ - handle = socket(AF_INET, SOCK_DGRAM, 0); - setNonBlocking(); -} - -//--------------------------------------------------------------------- -/** - @brief destroy the UdpSock object - - Doesn't do anything special. - - @author Justin Randall -*/ -UdpSock::~UdpSock() -{ -} - -//--------------------------------------------------------------------- -/** - @brief receive a datagram - - Receives a datagram and populates the outAddr parameter with the - source address of the message. - - Calling Sock::getInputBytesPending can provide a hint before - allocating the user supplied target buffer. - - @param outAddr target Address reference that receives - the message source IP address - @param targetBuffer a user supplied buffer to receive the data. - @param targetBufferSize the size of the user supplied buffer - - @author Justin Randall -*/ -const unsigned int UdpSock::recvFrom(Address & outAddr, void * targetBuffer, const unsigned int bufferSize) const -{ - int fromLen = sizeof(struct sockaddr_in); - struct sockaddr_in addr; - unsigned int result = ::recvfrom(handle, static_cast(targetBuffer), static_cast(bufferSize), 0, reinterpret_cast(&addr), &fromLen); //lint !e732 // MS wants an int, should be unsigned IMO - outAddr = addr; - if(result == SOCK_ERROR) - { - OutputDebugString(getLastError().c_str()); - } - return result; -} - -//--------------------------------------------------------------------- -/** - @brief send a datagram to a remote system - - sendTo sends a datagram to a remote system. - - @param targetAddress System to receive the datagram - @param sourceBuffer A user supplied buffer containint the data - to be sent - @param length The amount of data in the source buffer to - send - - @return The number of bytes sent on success - - @author Justin Randall -*/ -const unsigned int UdpSock::sendTo(const Address & targetAddress, const void * sourceBuffer, const unsigned int length) const -{ - unsigned int bytesSent = 0; - if(canSend()) - { - int toLen = sizeof(struct sockaddr_in); - bytesSent = ::sendto(handle, static_cast(sourceBuffer), static_cast(length), 0, reinterpret_cast(&(targetAddress.getSockAddr4())), toLen); //lint !e732 // MS wants an int, should be unsigned IMO - if(bytesSent != length) - { - OutputDebugString(getLastError().c_str()); - } - } - return bytesSent; -} - -//----------------------------------------------------------------------- - -void UdpSock::enableBroadcast() -{ - char optval = 1; - int err; - err = setsockopt(getHandle(), SOL_SOCKET, SO_BROADCAST, &optval, sizeof(char)); -} - -//--------------------------------------------------------------------- diff --git a/engine/shared/library/sharedNetworkMessages/src/win32/FirstSharedNetworkMessages.cpp b/engine/shared/library/sharedNetworkMessages/src/win32/FirstSharedNetworkMessages.cpp deleted file mode 100755 index a5d2ce4d..00000000 --- a/engine/shared/library/sharedNetworkMessages/src/win32/FirstSharedNetworkMessages.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstNetworkMessages.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedNetworkMessages/FirstSharedNetworkMessages.h" diff --git a/engine/shared/library/sharedObject/src/win32/FirstSharedObject.cpp b/engine/shared/library/sharedObject/src/win32/FirstSharedObject.cpp deleted file mode 100755 index 4221af2e..00000000 --- a/engine/shared/library/sharedObject/src/win32/FirstSharedObject.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstObject.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedObject/FirstSharedObject.h" diff --git a/engine/shared/library/sharedPathfinding/src/win32/FirstSharedPathfinding.cpp b/engine/shared/library/sharedPathfinding/src/win32/FirstSharedPathfinding.cpp deleted file mode 100755 index 9792c261..00000000 --- a/engine/shared/library/sharedPathfinding/src/win32/FirstSharedPathfinding.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstSharedPathfinding.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedPathfinding/FirstSharedPathfinding.h" diff --git a/engine/shared/library/sharedRandom/src/win32/FirstSharedRandom.cpp b/engine/shared/library/sharedRandom/src/win32/FirstSharedRandom.cpp deleted file mode 100755 index 1ce55673..00000000 --- a/engine/shared/library/sharedRandom/src/win32/FirstSharedRandom.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstRandom.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedRandom/FirstSharedRandom.h" diff --git a/engine/shared/library/sharedRegex/src/win32/FirstSharedRegex.cpp b/engine/shared/library/sharedRegex/src/win32/FirstSharedRegex.cpp deleted file mode 100755 index d219edf0..00000000 --- a/engine/shared/library/sharedRegex/src/win32/FirstSharedRegex.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// ====================================================================== -// -// FirstSharedRegex.cpp -// Copyright 2003 Sony Online Entertainment, Inc. -// All Rights Reserved. -// -// ====================================================================== - -#include "sharedRegex/FirstSharedRegex.h" diff --git a/engine/shared/library/sharedRegex/src/win32/RegexServices.cpp b/engine/shared/library/sharedRegex/src/win32/RegexServices.cpp deleted file mode 100755 index c12a1c67..00000000 --- a/engine/shared/library/sharedRegex/src/win32/RegexServices.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// ====================================================================== -// -// RegexServices.cpp -// Copyright 2003 Sony Online Entertainment, Inc. -// All Rights Reserved. -// -// ====================================================================== - -#include "sharedRegex/FirstSharedRegex.h" -#include "sharedRegex/RegexServices.h" - -// ====================================================================== - -static void * __cdecl localAllocate(size_t size, uint32 owner, bool array, bool leakTest) -{ - return MemoryManager::allocate(size, owner, array, leakTest); -} - -static __declspec(naked) void * regexAllocate(size_t) -{ - _asm - { - // setup local call stack - push ebp - mov ebp, esp - - // MemoryManager::alloc(size, [return address], false, true) - push 1 - push 0 - mov eax, dword ptr [ebp+4] - push eax - mov eax, dword ptr [ebp+8] - push eax - call localAllocate - add esp, 12 - - mov esp, ebp - pop ebp - ret - } -} - -// ---------------------------------------------------------------------- - -void *RegexServices::allocateMemory(size_t byteCount) -{ - return regexAllocate(byteCount); -} - -// ---------------------------------------------------------------------- - -void RegexServices::freeMemory(void *pointer) -{ - MemoryManager::free(pointer, false); -} - -// ====================================================================== diff --git a/engine/shared/library/sharedRegex/src/win32/RegexServices.h b/engine/shared/library/sharedRegex/src/win32/RegexServices.h deleted file mode 100755 index 762c80de..00000000 --- a/engine/shared/library/sharedRegex/src/win32/RegexServices.h +++ /dev/null @@ -1,25 +0,0 @@ -// ====================================================================== -// -// RegexServices.h -// Copyright 2003 Sony Online Entertainment, Inc. -// All Rights Reserved. -// -// ====================================================================== - -#ifndef INCLUDED_RegexServices_H -#define INCLUDED_RegexServices_H - -// ====================================================================== - -class RegexServices -{ -public: - - static void *allocateMemory(size_t byteCount); - static void freeMemory(void *pointer); - -}; - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedSkillSystem/src/win32/FirstSharedSkillSystem.cpp b/engine/shared/library/sharedSkillSystem/src/win32/FirstSharedSkillSystem.cpp deleted file mode 100755 index 0b610d18..00000000 --- a/engine/shared/library/sharedSkillSystem/src/win32/FirstSharedSkillSystem.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// FirstSharedSkillSystem.cpp -// Copyright 2000-01, Sony Online Entertainment Inc., all rights reserved. -// Author: Justin Randall - -//----------------------------------------------------------------------- - -#include "sharedSkillSystem/FirstSharedSkillSystem.h" - diff --git a/engine/shared/library/sharedSynchronization/src/win32/ConditionVariable.cpp b/engine/shared/library/sharedSynchronization/src/win32/ConditionVariable.cpp deleted file mode 100755 index bdcb1a5f..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/ConditionVariable.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// ====================================================================== -// -// ConditionVariable.cpp -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedSynchronization/FirstSharedSynchronization.h" -#include "sharedSynchronization/ConditionVariable.h" - -#include "sharedSynchronization/Mutex.h" - -ConditionVariable::ConditionVariable(Mutex &m) -: sem(1), _mutex(m), count(0) -{ -} - -ConditionVariable::~ConditionVariable() -{ -} - -void ConditionVariable::wait() -{ - ++count; - _mutex.leave(); - sem.wait(); - _mutex.enter(); -} - -void ConditionVariable::signal() -{ - if (count) - { - --count; - sem.signal(); - } -} - -void ConditionVariable::broadcast() -{ - if (count) - { - int oldcount = count; - count = 0; - sem.signal(oldcount); - } -} - diff --git a/engine/shared/library/sharedSynchronization/src/win32/ConditionVariable.h b/engine/shared/library/sharedSynchronization/src/win32/ConditionVariable.h deleted file mode 100755 index 07ab3034..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/ConditionVariable.h +++ /dev/null @@ -1,42 +0,0 @@ -// ====================================================================== -// -// ConditionVariable.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_ConditionVariable_h -#define INCLUDED_ConditionVariable_h - -class Mutex; - -#include "sharedSynchronization/Semaphore.h" - -/* Condition variable semantics follow pthreads semantics. You -must have the mutex locked before calling signal or broadcast. -When wait returns, the mutex is locked and you must unlock it. -*/ - -class ConditionVariable -{ -public: - ConditionVariable(Mutex &m); - ~ConditionVariable(); - void wait(); - // You must own the mutex before calling signal. - void signal(); - void broadcast(); - Mutex &mutex() { return _mutex; } -private: - ConditionVariable(const ConditionVariable &o); - ConditionVariable &operator =(const ConditionVariable &o); - - Semaphore sem; - Mutex &_mutex; - int count; -}; - - -#endif \ No newline at end of file diff --git a/engine/shared/library/sharedSynchronization/src/win32/FirstSharedSynchronization.cpp b/engine/shared/library/sharedSynchronization/src/win32/FirstSharedSynchronization.cpp deleted file mode 100755 index 12dd9b70..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/FirstSharedSynchronization.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstSynchronization.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedSynchronization/FirstSharedSynchronization.h" diff --git a/engine/shared/library/sharedSynchronization/src/win32/Gate.cpp b/engine/shared/library/sharedSynchronization/src/win32/Gate.cpp deleted file mode 100755 index 654ab4f6..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/Gate.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// ====================================================================== -// -// Gate.cpp -// -// Copyright 2001-2002 Sony Online Entertainment -// All Rights Reserved. -// -// ====================================================================== - -#include "sharedSynchronization/FirstSharedSynchronization.h" -#include "sharedSynchronization/Gate.h" - -// ====================================================================== - -Gate::Gate(bool open) -{ - handle = CreateEvent(0, true, open, 0); - DEBUG_FATAL(handle == NULL, ("CreateEvent failed")); -} - -// ---------------------------------------------------------------------- - -Gate::~Gate() -{ - CloseHandle(handle); -} - -// ---------------------------------------------------------------------- - -void Gate::wait() -{ - int errors = 0; - for (;;) - { - DWORD result = WaitForSingleObject(handle, INFINITE); - if (result == WAIT_OBJECT_0) - return; - - ++errors; - FATAL(errors >= 3, ("WaitForSingleObject failed multiple times")); - } -} - -// ---------------------------------------------------------------------- - -void Gate::close() -{ - const BOOL result = ResetEvent(handle); - FATAL(result == 0, ("ResetEvent failed")); -} - -// ---------------------------------------------------------------------- - -void Gate::open() -{ - const BOOL result = SetEvent(handle); - FATAL(result == 0, ("SetEvent failed")); -} - -// ====================================================================== diff --git a/engine/shared/library/sharedSynchronization/src/win32/Gate.h b/engine/shared/library/sharedSynchronization/src/win32/Gate.h deleted file mode 100755 index a0d3116e..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/Gate.h +++ /dev/null @@ -1,39 +0,0 @@ -// ====================================================================== -// -// Gate.h -// -// Copyright 2001-2002 Sony Online Entertainment -// All Rights Reseved. -// -// ====================================================================== - -#ifndef INCLUDED_Gate_h -#define INCLUDED_Gate_h - -// ====================================================================== - -class Gate -{ -public: - - Gate(bool initiallyOpen); - ~Gate(); - - void wait(); - - void close(); - void open(); - -private: - - Gate(const Gate &o); - Gate &operator =(const Gate &o); - -private: - - HANDLE handle; -}; - -// ====================================================================== - -#endif \ No newline at end of file diff --git a/engine/shared/library/sharedSynchronization/src/win32/InterlockedInteger.h b/engine/shared/library/sharedSynchronization/src/win32/InterlockedInteger.h deleted file mode 100755 index 0489c3f8..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/InterlockedInteger.h +++ /dev/null @@ -1,52 +0,0 @@ -// ====================================================================== -// -// InterlockedInteger.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_InterlockedInteger_h -#define INCLUDED_InterlockedInteger_h - -// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -class InterlockedInteger -{ -public: - explicit InterlockedInteger(int initialValue=0); - int operator =(int); // returns prior value (exchange) - int operator ++(); // returns new value - int operator --(); // returns new value - operator int() const { return static_cast(value); } -private: - InterlockedInteger(const InterlockedInteger &o); - InterlockedInteger &operator =(const InterlockedInteger &o); - volatile int value; -}; - -inline InterlockedInteger::InterlockedInteger(int i_value) -: value(i_value) -{ -} - -inline int InterlockedInteger::operator =(int i_value) -{ - long * ptr = (long *)&value; - return static_cast(InterlockedExchange(ptr, static_cast(i_value))); -} - -inline int InterlockedInteger::operator ++() -{ - long * ptr = (long *)&value; - return static_cast(InterlockedIncrement(ptr)); -} - -inline int InterlockedInteger::operator --() -{ - long * ptr = (long *)&value; - return static_cast(InterlockedDecrement(ptr)); -} - -#endif \ No newline at end of file diff --git a/engine/shared/library/sharedSynchronization/src/win32/InterlockedVoidPointer.h b/engine/shared/library/sharedSynchronization/src/win32/InterlockedVoidPointer.h deleted file mode 100755 index eff0a63e..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/InterlockedVoidPointer.h +++ /dev/null @@ -1,45 +0,0 @@ -// ====================================================================== -// -// InterlockedVoidPointer.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_InterlockedVoidPointer_h -#define INCLUDED_InterlockedVoidPointer_h - -// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -class InterlockedVoidPointer -{ -public: - explicit InterlockedVoidPointer(void * initialValue=0); - void * compareExchange(void * compare, void * exchange); // compare and exchange if same - operator void * () const { return reinterpret_cast(value); } -private: - InterlockedVoidPointer(const InterlockedVoidPointer &o); - InterlockedVoidPointer &operator =(const InterlockedVoidPointer &o); - void * volatile value; -}; - -template -class InterlockedPointer: public InterlockedVoidPointer -{ -public: - explicit InterlockedPointer(T * initialValue): InterlockedVoidPointer(initialValue) {} - operator T * () const { return static_cast(value); } -}; - -inline InterlockedVoidPointer::InterlockedVoidPointer(void * initialValue) -{ - value = initialValue; -} - -inline void * InterlockedVoidPointer::compareExchange(void * compare, void * exchange) -{ - return (void *)InterlockedCompareExchange((void **)&value, exchange, compare); -} - -#endif \ No newline at end of file diff --git a/engine/shared/library/sharedSynchronization/src/win32/Mutex.cpp b/engine/shared/library/sharedSynchronization/src/win32/Mutex.cpp deleted file mode 100755 index 557412a7..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/Mutex.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// ====================================================================== -// -// Mutex.cpp -// -// Copyright 2001-2002 Sony Online Entertainment -// All Rights Reserved -// -// ====================================================================== - -#include "sharedSynchronization/FirstSharedSynchronization.h" -#include "sharedSynchronization/Mutex.h" - -// ====================================================================== - -void Mutex::install() -{ -} - -// ---------------------------------------------------------------------- - -void Mutex::remove() -{ -} - -// ====================================================================== - -Mutex::Mutex() -{ - InitializeCriticalSection(&m_criticalSection); -} - -// ---------------------------------------------------------------------- - -Mutex::~Mutex() -{ - DeleteCriticalSection(&m_criticalSection); -} - -// ---------------------------------------------------------------------- - -void Mutex::enter() -{ - EnterCriticalSection(&m_criticalSection); -} - -// ---------------------------------------------------------------------- - -void Mutex::leave() -{ - LeaveCriticalSection(&m_criticalSection); -} - -// ====================================================================== diff --git a/engine/shared/library/sharedSynchronization/src/win32/Mutex.h b/engine/shared/library/sharedSynchronization/src/win32/Mutex.h deleted file mode 100755 index 579b52c5..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/Mutex.h +++ /dev/null @@ -1,41 +0,0 @@ -// ====================================================================== -// -// Mutex.h -// Copyright 2001-2002 Sony Online Entertainment -// All Rights Reserved. -// -// ====================================================================== - -#ifndef INCLUDED_Mutex_H -#define INCLUDED_Mutex_H - -// ====================================================================== - -class Mutex -{ -public: - - static void install(); - static void remove(); - -public: - - Mutex(); - ~Mutex(); - - void enter(); - void leave(); - -private: - - Mutex(const Mutex &); - Mutex &operator =(const Mutex &); - -private: - - CRITICAL_SECTION m_criticalSection; -}; - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedSynchronization/src/win32/RecursiveMutex.cpp b/engine/shared/library/sharedSynchronization/src/win32/RecursiveMutex.cpp deleted file mode 100755 index fa39da6b..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/RecursiveMutex.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// ====================================================================== -// -// RecursiveMutex.cpp -// -// Copyright 2001-2002 Sony Online Entertainment -// All Rights Reserved -// -// ====================================================================== - -#include "sharedSynchronization/FirstSharedSynchronization.h" -#include "sharedSynchronization/RecursiveMutex.h" - -// ====================================================================== - -void RecursiveMutex::install() -{ -} - -// ---------------------------------------------------------------------- - -void RecursiveMutex::remove() -{ -} - -// ====================================================================== - -RecursiveMutex::RecursiveMutex() -{ - InitializeCriticalSection(&m_criticalSection); -} - -// ---------------------------------------------------------------------- - -RecursiveMutex::~RecursiveMutex() -{ - DeleteCriticalSection(&m_criticalSection); -} - -// ---------------------------------------------------------------------- - -void RecursiveMutex::enter() -{ - EnterCriticalSection(&m_criticalSection); -} - -// ---------------------------------------------------------------------- - -void RecursiveMutex::leave() -{ - LeaveCriticalSection(&m_criticalSection); -} - -// ====================================================================== diff --git a/engine/shared/library/sharedSynchronization/src/win32/RecursiveMutex.h b/engine/shared/library/sharedSynchronization/src/win32/RecursiveMutex.h deleted file mode 100755 index 6c056a6c..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/RecursiveMutex.h +++ /dev/null @@ -1,41 +0,0 @@ -// ====================================================================== -// -// RecursiveMutex.h -// Copyright 2001-2002 Sony Online Entertainment -// All Rights Reserved. -// -// ====================================================================== - -#ifndef INCLUDED_RecursiveMutex_H -#define INCLUDED_RecursiveMutex_H - -// ====================================================================== - -class RecursiveMutex -{ -public: - - static void install(); - static void remove(); - -public: - - RecursiveMutex(); - ~RecursiveMutex(); - - void enter(); - void leave(); - -private: - - RecursiveMutex(const RecursiveMutex &); - RecursiveMutex &operator =(const RecursiveMutex &); - -private: - - CRITICAL_SECTION m_criticalSection; -}; - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedSynchronization/src/win32/Semaphore.cpp b/engine/shared/library/sharedSynchronization/src/win32/Semaphore.cpp deleted file mode 100755 index 47a385b4..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/Semaphore.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// ====================================================================== -// -// Semaphore.cpp -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedSynchronization/FirstSharedSynchronization.h" -#include "sharedSynchronization/Semaphore.h" - -Semaphore::Semaphore(int count, int initial) -{ - handle = CreateSemaphore(0, initial, count, 0); -} - -Semaphore::~Semaphore() -{ - CloseHandle(handle); -} - -void Semaphore::wait() -{ - WaitForSingleObject(handle, INFINITE); -} - -void Semaphore::wait(unsigned int maxDurationMs) -{ - WaitForSingleObject(handle, maxDurationMs); -} - -void Semaphore::signal(int count) -{ - ReleaseSemaphore(handle, count, 0); -} - diff --git a/engine/shared/library/sharedSynchronization/src/win32/Semaphore.h b/engine/shared/library/sharedSynchronization/src/win32/Semaphore.h deleted file mode 100755 index 744743a4..00000000 --- a/engine/shared/library/sharedSynchronization/src/win32/Semaphore.h +++ /dev/null @@ -1,28 +0,0 @@ -// ====================================================================== -// -// Semaphore.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_Semaphore_h -#define INCLUDED_Semaphore_h - -class Semaphore -{ -public: - Semaphore(int count=0x7FFFFFFF, int initial=0); - ~Semaphore(); - - void wait(); - void wait(unsigned int maxDurationMs); - void signal(int count=1); -private: - Semaphore(const Semaphore &o); - Semaphore &operator =(const Semaphore &o); - HANDLE handle; -}; - -#endif diff --git a/engine/shared/library/sharedTemplate/src/win32/FirstSharedTemplate.cpp b/engine/shared/library/sharedTemplate/src/win32/FirstSharedTemplate.cpp deleted file mode 100755 index 527ba602..00000000 --- a/engine/shared/library/sharedTemplate/src/win32/FirstSharedTemplate.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "sharedTemplate/FirstSharedTemplate.h" diff --git a/engine/shared/library/sharedTemplateDefinition/src/win32/FirstSharedTemplateDefinition.cpp b/engine/shared/library/sharedTemplateDefinition/src/win32/FirstSharedTemplateDefinition.cpp deleted file mode 100755 index b156d0fd..00000000 --- a/engine/shared/library/sharedTemplateDefinition/src/win32/FirstSharedTemplateDefinition.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "sharedTemplateDefinition/FirstSharedTemplateDefinition.h" diff --git a/engine/shared/library/sharedTerrain/src/win32/FirstSharedTerrain.cpp b/engine/shared/library/sharedTerrain/src/win32/FirstSharedTerrain.cpp deleted file mode 100755 index b8b5d9c2..00000000 --- a/engine/shared/library/sharedTerrain/src/win32/FirstSharedTerrain.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstTerrain.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedTerrain/FirstSharedTerrain.h" diff --git a/engine/shared/library/sharedThread/src/win32/FirstSharedThread.cpp b/engine/shared/library/sharedThread/src/win32/FirstSharedThread.cpp deleted file mode 100755 index 44b0e50c..00000000 --- a/engine/shared/library/sharedThread/src/win32/FirstSharedThread.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstThread.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedThread/FirstSharedThread.h" diff --git a/engine/shared/library/sharedThread/src/win32/Thread.cpp b/engine/shared/library/sharedThread/src/win32/Thread.cpp deleted file mode 100755 index 2db63ced..00000000 --- a/engine/shared/library/sharedThread/src/win32/Thread.cpp +++ /dev/null @@ -1,179 +0,0 @@ -// ====================================================================== -// -// Thread.cpp -// Acy Stapp -// -// Copyright6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedThread/FirstSharedThread.h" -#include "sharedThread/Thread.h" - -#include "sharedFoundation/ExitChain.h" -#include "sharedSynchronization/Mutex.h" -#include "sharedSynchronization/RecursiveMutex.h" -#include "sharedFoundation/Os.h" -#include "sharedFoundation/PerThreadData.h" -#include - -#include - -class MainThread: public Thread -{ -public: - MainThread(const std::string &name): Thread(name) {} -protected: - void run() {} -private: - MainThread(const MainThread &o); - MainThread &operator =(const MainThread &o); -}; - -int Thread::implindex; -Thread * Thread::mainThread; - -void Thread::install() -{ - DEBUG_FATAL(mainThread, ("Thread::install: already installed")); - - implindex = TlsAlloc(); - mainThread = new MainThread("Main"); - mainThread->attach(); - - ExitChain::add(remove, "Thread::remove"); - - Mutex::install(); - RecursiveMutex::install(); - -} - -void Thread::remove() -{ - DEBUG_FATAL(!mainThread, ("Thread::remove: not installed")); - DEBUG_FATAL(mainThread->refcount > 1, ("Someone still holds the main thread")); - delete mainThread; // can't kill because it would terminate the app - TlsFree(implindex); - - Mutex::remove(); - RecursiveMutex::remove(); - - mainThread = 0; -} - -Thread::Thread() -: refcount(1), name(new std::string) -{ -} - -Thread::Thread(const std::string &i_name) -: refcount(1), name(new std::string(i_name)) -{ -} - -void Thread::start() -{ - handle = (HANDLE) _beginthreadex(0, 0, threadFunc, this, 0, &id); -} - -void Thread::attach() -{ - id = GetCurrentThreadId(); - HANDLE process = GetCurrentProcess(); - DuplicateHandle(process, GetCurrentThread(), process, &handle, 0, FALSE, DUPLICATE_SAME_ACCESS); - - TlsSetValue(implindex, this); - Os::setThreadName(id, name->c_str()); -} - -Thread::~Thread() -{ - CloseHandle(handle); - delete name; -} - -unsigned int Thread::threadFunc(void * i) -{ - Thread * impl = static_cast(i); - TlsSetValue(implindex, impl); - Os::setThreadName(impl->id, impl->name->c_str()); - PerThreadData::threadInstall(true); - impl->run(); - PerThreadData::threadRemove(); - impl->kill(); - return 0; -} - -void Thread::kill() -{ - void * h = getCurrentThread()->handle; - deref(); - if (this == getCurrentThread()) - { - _endthreadex(1); - } - else - { - TerminateThread(h, 1); - } -} - -void Thread::wait() -{ - WaitForSingleObject(handle, INFINITE); -} - -bool Thread::done() -{ - return WaitForSingleObject(handle, 0) == WAIT_OBJECT_0; // WAIT_TIMEOUT if the thread is still active -} - -void Thread::setName(const std::string &i_name) -{ - *name = i_name; - Os::setThreadName(id, name->c_str()); -} - -void Thread::setPriority(ePriority priority) -{ - static int priorities[] = - { - THREAD_PRIORITY_IDLE, - THREAD_PRIORITY_LOWEST, - THREAD_PRIORITY_NORMAL, - THREAD_PRIORITY_HIGHEST, - THREAD_PRIORITY_TIME_CRITICAL - }; - ::SetThreadPriority(handle, priorities[priority]); -} - -void Thread::suspend() -{ - ::SuspendThread(handle); -} - -void Thread::resume() -{ - ::ResumeThread(handle); -} - -const std::string &Thread::getName() const -{ - return *name; -} - -// Make sure the header-only files compile :) - -#if 0 - -#include "sharedSynchronization/CountingSemaphore.h" -#include "sharedSynchronization/BlockingPointer.h" -#include "sharedSynchronization/BlockingQueue.h" -#include "sharedSynchronization/WriteOnce.h" - -Mutex t; -BlockingQueue bqint(t, 0, 0); -BlockingPointer bpint(t, 0, 0); -WriteOnce woint; - -#endif \ No newline at end of file diff --git a/engine/shared/library/sharedThread/src/win32/Thread.h b/engine/shared/library/sharedThread/src/win32/Thread.h deleted file mode 100755 index 6d59c27d..00000000 --- a/engine/shared/library/sharedThread/src/win32/Thread.h +++ /dev/null @@ -1,94 +0,0 @@ -// ====================================================================== -// -// Thread.h -// Acy Stapp -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_Thread_h -#define INCLUDED_Thread_h - -#include "sharedSynchronization/InterlockedInteger.h" - -template class TypedThreadHandle; - -class Thread -{ - // Visual studio fails to compile this valid code - // template friend TypedThreadHandle; -public: - static void install(); - static void remove(); - - Thread(); - Thread(const std::string &i_name); - - void kill(); - bool done(); - void wait(); - - enum ePriority - { - kIdle = 0, - kLow = 1, - kNormal = 2, - kHigh = 3, - kCritical = 4 - }; - void setPriority(ePriority priority); - void suspend(); - void resume(); - - const std::string &getName() const; - void setName(const std::string &i_name); - - static Thread * getCurrentThread(); - static Thread * getMainThread(); -protected: - virtual ~Thread(); - virtual void run()=0; - - HANDLE handle; - unsigned int id; - InterlockedInteger refcount; -public: // should be private:, see above - Thread(const Thread &o); - Thread &operator =(const Thread &o); - - void start(); - void attach(); // pick up the currently running thread - - void ref(); - void deref(); - - std::string *name; - - static int implindex; - static Thread * mainThread; - static unsigned int __stdcall threadFunc(void * data); -}; - -inline void Thread::ref() -{ - ++refcount; -} - -inline void Thread::deref() -{ - if (--refcount == 0) - delete this; -} - -inline Thread * Thread::getCurrentThread() -{ - return static_cast(TlsGetValue(implindex)); -} - -inline Thread * Thread::getMainThread() -{ - return mainThread; -} - -#endif \ No newline at end of file diff --git a/engine/shared/library/sharedUtility/src/win32/FirstSharedUtility.cpp b/engine/shared/library/sharedUtility/src/win32/FirstSharedUtility.cpp deleted file mode 100755 index fde40d23..00000000 --- a/engine/shared/library/sharedUtility/src/win32/FirstSharedUtility.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstUtility.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedUtility/FirstSharedUtility.h" diff --git a/engine/shared/library/sharedXml/src/win32/core/FirstSharedXml.cpp b/engine/shared/library/sharedXml/src/win32/core/FirstSharedXml.cpp deleted file mode 100755 index 0d9c1ae2..00000000 --- a/engine/shared/library/sharedXml/src/win32/core/FirstSharedXml.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// ====================================================================== -// -// FirstSharedXml.cpp -// Copyright 2004 Sony Online Entertainment, Inc. -// All Rights Reserved. -// -// ====================================================================== - -#include "sharedXml/FirstSharedXml.h" - -// ====================================================================== diff --git a/external/3rd/library/platform/utils/Base/win32/Archive.h b/external/3rd/library/platform/utils/Base/win32/Archive.h deleted file mode 100755 index 30ddce43..00000000 --- a/external/3rd/library/platform/utils/Base/win32/Archive.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef BASE_WIN32_ARCHIVE_H -#define BASE_WIN32_ARCHIVE_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - -#ifdef PACK_BIG_ENDIAN - - inline double byteSwap(double value) { byteReverse64(&value); return value; } - inline float byteSwap(float value) { byteReverse32(&value); return value; } - inline uint64 byteSwap(uint64 value) { byteReverse64(&value); return value; } - inline int64 byteSwap(int64 value) { byteReverse64(&value); return value; } - inline uint32 byteSwap(uint32 value) { byteReverse32(&value); return value; } - inline int32 byteSwap(int32 value) { byteReverse32(&value); return value; } - inline uint16 byteSwap(uint16 value) { byteReverse16(&value); return value; } - inline int16 byteSwap(int16 value) { byteReverse16(&value); return value; } - -#else - - inline double byteSwap(double value) { return value; } - inline float byteSwap(float value) { return value; } - inline uint64 byteSwap(uint64 value) { return value; } - inline int64 byteSwap(int64 value) { return value; } - inline uint32 byteSwap(uint32 value) { return value; } - inline int32 byteSwap(int32 value) { return value; } - inline uint16 byteSwap(uint16 value) { return value; } - inline int16 byteSwap(int16 value) { return value; } - -#endif - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif diff --git a/external/3rd/library/platform/utils/Base/win32/BlockAllocator.cpp b/external/3rd/library/platform/utils/Base/win32/BlockAllocator.cpp deleted file mode 100755 index 029946b4..00000000 --- a/external/3rd/library/platform/utils/Base/win32/BlockAllocator.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "../BlockAllocator.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - BlockAllocator::BlockAllocator() - { - for(unsigned i = 0; i < 31; i++) - { - m_blocks[i] = NULL; - } - } - - BlockAllocator::~BlockAllocator() - { - // free all allocated memory blocks - for(unsigned i = 0; i < 31; i++) - { - while(m_blocks[i] != NULL) - { - uintptr_t *tmp = m_blocks[i]; - m_blocks[i] = (uintptr_t *)*m_blocks[i]; - free(tmp); - } - } - } - -// Allocate a block that is the next power of two greater than the # of bytes passed. -// 33 bytes yields a 64 byte block of memory and so forth. - - void *BlockAllocator::getBlock(unsigned bytes) - { - unsigned accum = 16, bits = 16; - uintptr_t *handle = NULL; - - // Perform a binary search looking for the highest bit. - - while(bits != 0) - { - // If bytes is less than the bit we're testing for, subtract half - // from the bit value and repeat - if(bytes < (unsigned)(1 << accum)) - { - bits /= 2; - accum -= bits; - } - // If bytes is greater than the bit we're testing for, add half - // from the but value and repeat - else if(bytes > (unsigned)(1 << accum)) - { - bits /= 2; - accum += bits; - } - // Got lucky and hit the value dead on - else - { - break; - } - } - // At this point accum contains the most significant bit index, increment - accum++; - if(accum < 2) - { - accum = 2; - } - - // Note that when memory is actually allocated, 8 extra bytes will be allocated.at the front - // The first integer is the address of the next block of memory when the block is in the allocator - // The second integer is the bit length of the block - // Memory is allocated on 4 byte boundaries to sidestep byte alignment problems - - - // Check if the allocator already has a block of that size - if(m_blocks[accum] == 0) - { - // remove the pre allocated block from the linked list - handle = (uintptr_t *)calloc(((1 << accum) / 4) + 2, sizeof(unsigned)); - handle[1] = accum; - handle[0] = 0; - } - else - { - // Allocate a new block - handle = m_blocks[accum]; - m_blocks[accum] = (uintptr_t *)handle[0]; - handle[0] = 0; - } - // return a pointer that skips over the header used for the allocator's purposes - return(handle + 2); - } - - void BlockAllocator::returnBlock(unsigned *handle) - { - // C++ allows for safe deletion of a NULL pointer - if(handle) - { - // Update the allocator linked list, insert this entry at the head - *(handle - 2) = (uintptr_t)m_blocks[*(handle - 1)]; - // Add this entry to the proper linked list node - m_blocks[*(handle - 1)] = (handle - 2); - } - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - diff --git a/external/3rd/library/platform/utils/Base/win32/Event.cpp b/external/3rd/library/platform/utils/Base/win32/Event.cpp deleted file mode 100755 index 12ee8fe7..00000000 --- a/external/3rd/library/platform/utils/Base/win32/Event.cpp +++ /dev/null @@ -1,44 +0,0 @@ -//////////////////////////////////////// -// Event.cpp -// -// Purpose: -// 1. Implementation of the CEvent class. -// -// Revisions: -// 07/10/2001 Created -// - - -#if !defined(_MT) -# pragma message( "Excluding Base::CEvent - requires multi-threaded compile. (_MT)" ) -#else - -#include "Event.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - CEvent::CEvent() - { - mEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); - } - - CEvent::~CEvent() - { - if (mEvent) - CloseHandle(mEvent); - } - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif // #if defined(_MT) - diff --git a/external/3rd/library/platform/utils/Base/win32/Event.h b/external/3rd/library/platform/utils/Base/win32/Event.h deleted file mode 100755 index 5d2bc712..00000000 --- a/external/3rd/library/platform/utils/Base/win32/Event.h +++ /dev/null @@ -1,92 +0,0 @@ -//////////////////////////////////////// -// Event.h -// -// Purpose: -// 1. Declair the CEvent class that encapsulates the functionality of a -// single-locking semaphore. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_EVENT_H -#define BASE_WIN32_EVENT_H - -#if defined(_MT) - - - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CEvent - // - // Purpose: - // Encapsulates the functionality of a singal-locking semaphore. - // This class is valuable for thread syncronization when a thead's - // execution needs to be dependent upon another thread. - // - // Public Methods: - // Signal() : Signals a thread that has called Wait() so that it can - // continue execution. This function returns true if the waiting - // thread was signalled successfully, otherwise false is returned. - // Wait() : Halts the calling thread's execution indefinately until - // a Singal() call is made by an external thread. If the thread is - // successfully signalled, the function returns eWAIT_SIGNAL. If - // timeout period expires without a signal, eWAIT_TIMEOUT is returned. - // If the function fails, eWAIT_ERROR is returned. - // - class CEvent - { - public: - CEvent(); - virtual ~CEvent(); - - bool Signal(); - int32 Wait(uint32 timeout = 0); - - public: - enum { eWAIT_ERROR, eWAIT_SIGNAL, eWAIT_TIMEOUT }; - private: - HANDLE mEvent; - }; - - inline bool CEvent::Signal() - { - if (mEvent) - return SetEvent(mEvent)!=0; - - return false; - } - - inline int32 CEvent::Wait(uint32 timeout) - { - if (!mEvent) - return CEvent::eWAIT_ERROR; - - DWORD result = WaitForSingleObjectEx(mEvent, timeout ? timeout : INFINITE, FALSE); - if (result == WAIT_OBJECT_0) - return CEvent::eWAIT_SIGNAL; - else if (result == WAIT_TIMEOUT) - return CEvent::eWAIT_TIMEOUT; - else - return CEvent::eWAIT_ERROR; - } - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_MT) - - -#endif // BASE_WIN32_EVENT_H diff --git a/external/3rd/library/platform/utils/Base/win32/File.cpp b/external/3rd/library/platform/utils/Base/win32/File.cpp deleted file mode 100755 index e6b6ee23..00000000 --- a/external/3rd/library/platform/utils/Base/win32/File.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// File.cpp: implementation of the CFile class. -// -////////////////////////////////////////////////////////////////////// - -#include "File.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CFile::CFile(const char *) -{ - -} - -CFile::~CFile() -{ - -} diff --git a/external/3rd/library/platform/utils/Base/win32/File.h b/external/3rd/library/platform/utils/Base/win32/File.h deleted file mode 100755 index 7965427a..00000000 --- a/external/3rd/library/platform/utils/Base/win32/File.h +++ /dev/null @@ -1,22 +0,0 @@ -// File.h: interface for the CFile class. -// -////////////////////////////////////////////////////////////////////// - -#ifndef BASE_FILE_H -#define BASE_FILE_H - -#include - -class CFile -{ - public: - CFile(const char *); - virtual ~CFile(); - - bool IsOpen(); - - private: - FILE* mFileHandle; -}; - -#endif // BASE_FILE_H diff --git a/external/3rd/library/platform/utils/Base/win32/Logger.cpp b/external/3rd/library/platform/utils/Base/win32/Logger.cpp deleted file mode 100755 index cf2afcf6..00000000 --- a/external/3rd/library/platform/utils/Base/win32/Logger.cpp +++ /dev/null @@ -1,385 +0,0 @@ -#include "../Logger.h" -#include "Mutex.h" - -using namespace std; - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - -const char file_sep = '\\'; - -Logger::Logger(const char *prefix, int level, unsigned size, bool rollDate) -: m_defaultLevel(level), m_defaultSize(size), m_dirPrefix(prefix), m_rollDate(rollDate) -{ - char buf[1024]; - FILE *logDir = NULL; - - logDir = fopen(m_dirPrefix.c_str(), "r+"); - if(errno == ENOENT) - { - cmkdir(m_dirPrefix.c_str(), 0755); - } - else if(logDir != NULL) - { - fclose(logDir); - } - - tm now; - time_t t = time(NULL); - memcpy(&now, localtime(&t), sizeof(tm)); - memcpy(&m_lastDateTime, &now, sizeof(tm)); - if(m_rollDate) - { - sprintf(buf, "%s%c%2.2d-%2.2d-%2.2d", m_dirPrefix.c_str(), file_sep, (now.tm_mon + 1), now.tm_mday, (now.tm_year % 100)); - } - else - { - sprintf(buf, "%s", m_dirPrefix.c_str()); - } - - logDir = fopen(buf, "r+"); - if(errno == ENOENT) - { - cmkdir(buf, 0755); - } - else if(logDir != NULL) - { - fclose(logDir); - } - m_logPrefix = buf; -} - -Logger::~Logger() -{ - map::iterator iter; - for(iter = m_logTable.begin(); iter != m_logTable.end(); ++iter) - { - log((*iter).first, LOG_FILEONLY, "---=== Log Stopped ===---"); - fflush((*iter).second->file); - fclose((*iter).second->file); - delete((*iter).second); - - } - m_logTable.clear(); -} - -void Logger::flush(unsigned logenum) -{ - map::iterator iter = m_logTable.find(logenum); - - if(iter != m_logTable.end()) - { - LogInfo *info = (*iter).second; - fflush(info->file); - info->used = 0; - } -} - -void Logger::flushAll() -{ - map::iterator iter; - - for(iter = m_logTable.begin(); iter != m_logTable.end(); ++iter) - { - LogInfo *info = (*iter).second; - fflush(info->file); - info->used = 0; - } -} - -void Logger::addLog(const char *id, unsigned logenum, int level, unsigned size) -{ - LogInfo *newLog = new LogInfo; - newLog->filename = m_logPrefix + file_sep + id + ".log"; - newLog->name = id; - newLog->used = 0; - newLog->max = size; - newLog->last = 0; - newLog->level = level; - - m_logTable.insert(pair(logenum, newLog)); - - if(strcmp("stdout", id) == 0) - { - newLog->file = stdout; - } - else if(strcmp("stderr", id) == 0) - { - newLog->file = stderr; - } - else - { - newLog->file = fopen(newLog->filename.c_str(), "a+"); - } - log(logenum, LOG_FILEONLY, "---=== Log Started ===---"); -} - -void Logger::addLog(const char *id, unsigned logenum) -{ - LogInfo *newLog = new LogInfo; - newLog->filename = m_logPrefix + file_sep + id + ".log"; - newLog->name = id; - newLog->used = 0; - newLog->max = m_defaultSize; - newLog->last = 0; - newLog->level = m_defaultLevel; - m_logTable.insert(pair(logenum, newLog)); - - if(strcmp("stdout", id) == 0) - { - newLog->file = stdout; - } - else if(strcmp("stderr", id) == 0) - { - newLog->file = stderr; - } - else - { - newLog->file = fopen(newLog->filename.c_str(), "a+"); - } - log(logenum, LOG_FILEONLY, "---=== Log Started ===---"); - -} - -void Logger::updateLog(unsigned logenum, int level, unsigned size) -{ - map::iterator iter = m_logTable.find(logenum); - - if(iter != m_logTable.end()) - { - (*iter).second->level = level; - (*iter).second->max = size; - } -} - -void Logger::removeLog(unsigned logenum) -{ - map::iterator iter = m_logTable.find(logenum); - - if(iter != m_logTable.end()) - { - log((*iter).first, LOG_FILEONLY, "---=== Log Stopped ===---"); - fflush((*iter).second->file); - fclose((*iter).second->file); - delete((*iter).second); - } -} - -void Logger::logSimple(unsigned logenum, int level, const char *message) -{ - map::iterator iter = m_logTable.find(logenum); - char dateBuffer[256]; - - if(iter == m_logTable.end()) - { - return; - } - time_t t = time(NULL); - LogInfo *info = (*iter).second; - if(level >= info->level) - { - return; - } - if(info->last != t) - { - memcpy(&info->ts, localtime(&t), sizeof(tm)); - info->last = t; - } - - if(m_rollDate && info->ts.tm_mday != m_lastDateTime.tm_mday) - { -#if defined(_MT) - rLock.Lock(); -#endif - if(info->ts.tm_mday != m_lastDateTime.tm_mday) - { - memcpy(&m_lastDateTime, &info->ts, sizeof(tm)); - rollDate(t); - } -#if defined(_MT) - rLock.Unlock(); -#endif - } - if(iter != m_logTable.end()) - { - if(info->max > 0) - { - sprintf(dateBuffer, "[%2.2d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d] " , (info->ts.tm_mon + 1), info->ts.tm_mday, (info->ts.tm_year % 100), info->ts.tm_hour, info->ts.tm_min, info->ts.tm_sec); - info->used += fputs(dateBuffer, info->file); - info->used += fputs(message, info->file); - fputc('\n', info->file); - if(info->used > info->max) - { - fflush(info->file); - info->used = 0; - } - } - else - { - sprintf(dateBuffer, "[%2.2d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d] " , (info->ts.tm_mon + 1), info->ts.tm_mday, (info->ts.tm_year % 100), info->ts.tm_hour, info->ts.tm_min, info->ts.tm_sec); - fputs(dateBuffer, info->file); - fputs(message, info->file); - fputc('\n', info->file); - fflush(info->file); - } - } -} - -void Logger::log(unsigned logenum, int level, const char *message, ...) -{ - char buf[2048]; - char dateBuffer[256]; - va_list varg; - va_start(varg, message); - _vsnprintf(buf, 2047, message, varg); - buf[2047] = 0; - va_end(varg); - - map::iterator iter = m_logTable.find(logenum); - if(iter == m_logTable.end()) - { - return; - } - time_t t = time(NULL); - LogInfo *info = (*iter).second; - - if(level >= info->level) - { - return; - } - - if(level == LOG_FILEONLY && ((info->file == stderr) || (info->file == stdout))) - { - return; - } - if(info->last != t) - { - memcpy(&info->ts, localtime(&t), sizeof(tm)); - info->last = t; - } - if(m_rollDate && info->ts.tm_mday != m_lastDateTime.tm_mday) - { -#if defined(_MT) - rLock.Lock(); -#endif - if(info->ts.tm_mday != m_lastDateTime.tm_mday) - { - memcpy(&m_lastDateTime, &info->ts, sizeof(tm)); - rollDate(t); - } -#if defined(_MT) - rLock.Unlock(); -#endif - } - - if(iter != m_logTable.end()) - { - if(info->max > 0) - { - sprintf(dateBuffer, "[%2.2d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d] " , (info->ts.tm_mon + 1), info->ts.tm_mday, (info->ts.tm_year % 100), info->ts.tm_hour, info->ts.tm_min, info->ts.tm_sec); - info->used += fputs(dateBuffer, info->file); - info->used += fputs(buf, info->file); - fputc('\n', info->file); - if(info->used > info->max) - { - fflush(info->file); - info->used = 0; - } - } - else - { - sprintf(dateBuffer, "[%2.2d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d] " , (info->ts.tm_mon + 1), info->ts.tm_mday, (info->ts.tm_year % 100), info->ts.tm_hour, info->ts.tm_min, info->ts.tm_sec); - info->used += fputs(dateBuffer, info->file); - info->used += fputs(buf, info->file); - fputc('\n', info->file); - fflush(info->file); - } - } -} - -void Logger::rollDate(time_t t) -{ - char buf[80]; - FILE *logDir = NULL; - - logDir = fopen(m_dirPrefix.c_str(), "r+"); - if(errno == ENOENT) - { - cmkdir(m_dirPrefix.c_str(), 0755); - } - else if(logDir != NULL) - { - fclose(logDir); - } - - tm now; - memcpy(&now, localtime(&t), sizeof(tm)); - - sprintf(buf, "%s%c%2.2d-%2.2d-%2.2d", m_dirPrefix.c_str(), file_sep, (now.tm_mon + 1), now.tm_mday, (now.tm_year % 100)); - logDir = fopen(buf, "r+"); - - if(errno == ENOENT) - { - cmkdir(buf, 0755); - } - else if(logDir != NULL) - { - fclose(logDir); - } - m_logPrefix = buf; - - map::iterator iter; - for(iter = m_logTable.begin(); iter != m_logTable.end(); ++iter) - { - (*iter).second->filename = m_logPrefix + file_sep + (*iter).second->name.c_str() + ".log"; - fflush((*iter).second->file); - fclose((*iter).second->file); - (*iter).second->file = fopen((*iter).second->filename.c_str(), "a+"); - memcpy(&((*iter).second->ts), &now, sizeof(tm)); - } -} - -// mkdir function that creates intermediate directories -void Logger::cmkdir(const char *dir, int mode) -{ - char dirbuf[128]; - strncpy(dirbuf, dir, 127); - dirbuf[127] = 0; - char *j = dirbuf, *i = dirbuf; - int handle; - - while(*i) - { - if(*i == file_sep) - { - (*i) = 0; - handle = _open(j, O_EXCL); - - if((handle > 0) || (errno != EISDIR && errno != ENOENT && errno != EACCES)) - { - perror("Logger::cmkdir():"); - abort(); - } - _mkdir(j); - _close(handle); - (*i) = file_sep; - } - else if(*(i + 1) == 0) - { - _mkdir(j); - } - i++; - } -} - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - diff --git a/external/3rd/library/platform/utils/Base/win32/Mutex.cpp b/external/3rd/library/platform/utils/Base/win32/Mutex.cpp deleted file mode 100755 index 482481e8..00000000 --- a/external/3rd/library/platform/utils/Base/win32/Mutex.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////// -// Mutex.cpp -// -// Purpose: -// 1. Implementation of the CMutex class. -// -// Revisions: -// 07/10/2001 Created -// -#if !defined(_MT) -# pragma message( "Excluding Base::CMutex - requires multi-threaded compile. (_MT)" ) -#else - -#include "Mutex.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - -CMutex::CMutex() - { - InitializeCriticalSection(&mCriticalSection); - } - -CMutex::~CMutex() - { - DeleteCriticalSection(&mCriticalSection); - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif // #if defined(_MT) - diff --git a/external/3rd/library/platform/utils/Base/win32/Mutex.h b/external/3rd/library/platform/utils/Base/win32/Mutex.h deleted file mode 100755 index 66e1c08b..00000000 --- a/external/3rd/library/platform/utils/Base/win32/Mutex.h +++ /dev/null @@ -1,73 +0,0 @@ -//////////////////////////////////////// -// Mutex.h -// -// Purpose: -// 1. Declair the CMutex class that encapsulates the functionality of a -// mutually-exclusive device. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_MUTEX_H -#define BASE_WIN32_MUTEX_H - -#if defined (_MT) - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CMutex - // - // Purpose: - // Encapsulates the functionality of a mutually-exclusive device. - // This class is valuable for protecting against race conditions - // within threaded applications. The CMutex class can be used to - // only allow a single thread to run within a specified code - // segment at a time. - // - // Public Methods: - // Lock() : Locks the mutex. If the mutex is already locked, the - // operating system will block the calling thread until another - // thread has unlocked the mutex. - // Unlock() : Unlocks the mutex. - // - class CMutex - { - public: - CMutex(); - ~CMutex(); - - void Lock(); - void Unlock(); - private: - CRITICAL_SECTION mCriticalSection; - }; - - inline void CMutex::Lock() - { - EnterCriticalSection(&mCriticalSection); - } - - inline void CMutex::Unlock() - { - LeaveCriticalSection(&mCriticalSection); - } - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // #if defined(_MT) - -#endif // BASE_WIN32_MUTEX_H \ No newline at end of file diff --git a/external/3rd/library/platform/utils/Base/win32/Platform.cpp b/external/3rd/library/platform/utils/Base/win32/Platform.cpp deleted file mode 100755 index 3b52563e..00000000 --- a/external/3rd/library/platform/utils/Base/win32/Platform.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//////////////////////////////////////// -// Platform.cpp -// -// Purpose: -// 1. Implementation of the global functionality declaired in Platform.h. -// -// Revisions: -// 07/10/2001 Created -// - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - - CTimer::CTimer() : - mTimer(0) - { - } - - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif diff --git a/external/3rd/library/platform/utils/Base/win32/Platform.h b/external/3rd/library/platform/utils/Base/win32/Platform.h deleted file mode 100755 index aaee37b7..00000000 --- a/external/3rd/library/platform/utils/Base/win32/Platform.h +++ /dev/null @@ -1,98 +0,0 @@ -//////////////////////////////////////// -// Platform.h -// -// Purpose: -// 1. Include relevent system headers that are platform specific. -// 2. Declair global platform specific functionality. -// 3. Include primative type definitions -// -// Global Functions: -// getTimer() : Return the current high resolution clock count. -// getTimerFrequency() : Return the frequency of the high resolution clock. -// sleep() : Voluntarily relinquish timeslice of the calling thread for a -// specified number of milliseconds. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_PLATFORM_H -#define BASE_WIN32_PLATFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include "Types.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - uint64 getTimer(void); - uint64 getTimerFrequency(void); - - inline uint64 getTimer(void) - { - uint64 result; - if (!QueryPerformanceCounter(reinterpret_cast(&result))) - result = 0; - return result; - } - - inline uint64 getTimerFrequency(void) - { - uint64 result; - if (!QueryPerformanceFrequency(reinterpret_cast(&result))) - result = 0; - return result; - } - - inline void sleep(uint32 ms) - { - Sleep(ms); - } - - - class CTimer - { - public: - CTimer(); - - void Set(uint32 seconds); - void Signal(); - bool Expired(); - - private: - uint32 mTimer; - }; - - inline void CTimer::Set(uint32 interval) - { - mTimer = (uint32)time(0) + interval; - } - - inline void CTimer::Signal() - { - mTimer = 0; - } - - inline bool CTimer::Expired() - { - return (mTimer <= (uint32)time(0)); - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif BASE_WIN32_PLATFORM_H \ No newline at end of file diff --git a/external/3rd/library/platform/utils/Base/win32/Thread.cpp b/external/3rd/library/platform/utils/Base/win32/Thread.cpp deleted file mode 100755 index 2692e88e..00000000 --- a/external/3rd/library/platform/utils/Base/win32/Thread.cpp +++ /dev/null @@ -1,279 +0,0 @@ -//////////////////////////////////////// -// Thread.cpp -// -// Purpose: -// 1. Implementation of the CThread class. -// -// Revisions: -// 07/10/2001 Created -// - - -#pragma warning ( disable: 4786 ) - - -#if !defined(_MT) -# pragma message( "Excluding Base::CThread - requires multi-threaded compile. (_MT)" ) -#else - -#include -#include -#include "Thread.h" - -using namespace std; - - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - void threadProc(void *threadPtr) - { - CThread &thread = *((CThread*)threadPtr); - thread.mThreadActive = true; - thread.ThreadProc(); - thread.mThreadActive = false; - } - - CThread::CThread() - { - mThreadID = 0; - mThreadActive = false; - mThreadContinue = false; - } - - CThread::~CThread() - { - StopThread(); - } - - void CThread::StartThread() - { - mThreadContinue = true; - mThreadID = _beginthread(threadProc,0,this); - while (!IsThreadActive()) - Base::sleep(1); - } - - int32 CThread::StopThread(int32 timeout) - { - timeout += int(time(0)); - - mThreadContinue = false; - while (mThreadActive && time(0)OnStartup(this); - while (mThreadContinue) - { - mParent->OnIdle(this); - mSemaphore.Wait(mParent->GetTimeOut()*1000); - - if (mFunction) - { - mFunction(mArgument); - mArgument = NULL; - mFunction = NULL; - } - else if (mParent->OnDestory(this)) - mThreadContinue = false; - } - } - - -//////////////////////////////////////////////////////////////////////////////// - - - CThreadPool::CThreadPool(uint32 maxThreads, uint32 minThreads, uint32 timeout) : - mMutex(), - mIdleMember(), - mBusyMember(), - mNullMember(), - mThreadCount(0), - mMaxThreads(maxThreads), - mMinThreads(minThreads), - mTimeOut(timeout) - { - if (mMaxThreads == 0) mMaxThreads = 1; - if (mMinThreads == 0) mMinThreads = 1; - if (mMinThreads > mMaxThreads) mMinThreads = mMaxThreads; - - for (uint32 i=0; i::iterator setIterator; - - //////////////////////////////////////// - // (1) Destory all busy member threads - mMutex.Lock(); - setIterator = mBusyMember.begin(); - while (setIterator != mBusyMember.end()) - (*setIterator++)->Destroy(); - mMutex.Unlock(); - - //////////////////////////////////////// - // (2) Destory all idle member threads - while (mThreadCount) - { - mMutex.Lock(); - setIterator = mIdleMember.begin(); - while (setIterator != mIdleMember.end()) - (*setIterator++)->Destroy(); - mMutex.Unlock(); - - sleep(1); - } - - //////////////////////////////////////// - // (3) Delete the null member threads - mMutex.Lock(); - while (!mNullMember.empty()) - { - delete mNullMember.front(); - mNullMember.pop_front(); - } - mMutex.Unlock(); - } - - bool CThreadPool::Execute(void( __cdecl *function )( void * ), void * arg) - { - mMutex.Lock(); - - //////////////////////////////////////// - // (1) If no idle members, return false to indicate that no threads - // were available. If the thread count is below the max, create - // a new thread. - if (mIdleMember.empty()) - { - if (mThreadCount < mMaxThreads) - new CMember(this); - mMutex.Unlock(); - return false; - } - - //////////////////////////////////////// - // (2) Delete any null member threads. - while (!mNullMember.empty()) - { - delete mNullMember.front(); - mNullMember.pop_front(); - } - - //////////////////////////////////////// - // (3) Move the first idle thread to the busy set and signal the - // thread to execute the specified function. - CMember * member = *(mIdleMember.begin()); - mIdleMember.erase(member); - mBusyMember.insert(member); - member->Execute(function,arg); - - mMutex.Unlock(); - return true; - } - - uint32 CThreadPool::GetTimeOut() - { - return mTimeOut; - } - - void CThreadPool::OnStartup(CMember * member) - { - mMutex.Lock(); - - mThreadCount++; - mIdleMember.insert(member); - - mMutex.Unlock(); - } - - void CThreadPool::OnIdle(CMember * member) - { - mMutex.Lock(); - - mBusyMember.erase(member); - mIdleMember.insert(member); - - mMutex.Unlock(); - } - - bool CThreadPool::OnDestory(CMember * member) - { - set::iterator setIterator; - - mMutex.Lock(); - - bool result = (setIterator = mIdleMember.find(member)) != mIdleMember.end(); - if (result) - { - mNullMember.push_back(member); - mIdleMember.erase(setIterator); - mThreadCount--; - } - - mMutex.Unlock(); - - return result; - } - - -//////////////////////////////////////////////////////////////////////////////// - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif // #if defined(_MT) - diff --git a/external/3rd/library/platform/utils/Base/win32/Thread.h b/external/3rd/library/platform/utils/Base/win32/Thread.h deleted file mode 100755 index a8338917..00000000 --- a/external/3rd/library/platform/utils/Base/win32/Thread.h +++ /dev/null @@ -1,144 +0,0 @@ -//////////////////////////////////////// -// Thread.h -// -// Purpose: -// 1. Declair the CThread class that encapsulates threading functionality. -// This abstract base class in intended to be used to encapsulate -// individual tasks that require threading in derived classes. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_THREAD_H -#define BASE_WIN32_THREAD_H - -#if defined(_MT) - -#pragma warning( disable : 4786) - -#include -#include -#include "Platform.h" -#include "Mutex.h" -#include "Event.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CThread - // - // Purpose: - // Encapsulates threading functionality. Creating classes derived - // from CThread provides an easy way to encapsulate tasks that require - // their own thread. - // - // Public Methods: - // StartThread() : Creates the low-level thread handle and begins executing - // the CThread::ThreadProc() function within the new thread. - // StopThread() : Signals the ThreadProc() function to stop executing using - // the mThreadContinue member variable, and waits for the ThreadProc() - // function to exit. By default, the function will block for a maximum - // of 5 seconds before exiting without the thread halting. - // IsThreadActive() : Returns true if the physical thread is still executing - // within the ThreadProc() function, otherwise it returns false. - // ThreadProc() : Pure-virtual function that will be executed when the StartThread() - // function is called. Derived classes must implement this function. The - // mThreadContinue member variable should be used internal the the ThreadProc() - // function to indicate whether it should continue executing or exit. - // Protected Attributes: - // mThreadContinue : Boolean value indicating to the ThreadProc() function - // whether to continue executing or to exit. If mThreadContinue is true, - // ThreadProc() should continue, otherwise ThreadProc() should exit. It - // left up to the derived class to implement a ThreadProc() function that - // uses the mThreadContinue member. - // - // - class CThread - { - friend void threadProc(void *); - - public: - enum { eSTOP_SUCCESS, eSTOP_TIMEOUT }; - public: - CThread(); - virtual ~CThread(); - - void StartThread(); - int32 StopThread(int32 timeout=5); - bool IsThreadActive() { return mThreadActive; } - - protected: - virtual void ThreadProc() = 0; - - protected: - bool mThreadContinue; - private: - uint32 mThreadID; - bool mThreadActive; - }; - - - class CThreadPool - { - private: - class CMember : public CThread - { - public: - CMember(CThreadPool * parent); - virtual ~CMember(); - - bool Execute(void( __cdecl *function )( void * ), void * arg); - void Destroy(); - - protected: - virtual void ThreadProc(); - - private: - CThreadPool * mParent; - void( __cdecl * mFunction )( void * ); - void * mArgument; - CEvent mSemaphore; - }; - friend class CMember; - - public: - CThreadPool(uint32 maxThreads, uint32 minThreads=1, uint32 timeout=15*60); - ~CThreadPool(); - - bool Execute(void( __cdecl *function )( void * ), void * arg); - - private: - uint32 GetTimeOut(); - void OnStartup(CMember * member); - void OnIdle(CMember * member); - bool OnDestory(CMember * member); - - private: - CMutex mMutex; - std::set mIdleMember; - std::set mBusyMember; - std::list mNullMember; - uint32 mThreadCount; - - uint32 mMaxThreads; - uint32 mMinThreads; - uint32 mTimeOut; - }; - - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // #if defined(_MT) - -#endif // BASE_WIN32_THREAD_H diff --git a/external/3rd/library/platform/utils/Base/win32/Types.h b/external/3rd/library/platform/utils/Base/win32/Types.h deleted file mode 100755 index 0c64cb2c..00000000 --- a/external/3rd/library/platform/utils/Base/win32/Types.h +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////// -// Types.h -// -// Purpose: -// 1. Define integer types that are unambiguous with respect to size -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_TYPES_H -#define BASE_WIN32_TYPES_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - -#define INT32_MAX 0x7FFFFFFF -#define INT32_MIN 0x80000000 -#define UINT32_MAX 0xFFFFFFFF - -typedef signed char int8; -typedef unsigned char uint8; -typedef short int16; -typedef unsigned short uint16; - -typedef int int32; -typedef unsigned uint32; -typedef __int64 int64; -typedef unsigned __int64 uint64; - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // BASE_WIN32_TYPES_H - diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Archive.h b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Archive.h deleted file mode 100755 index 30ddce43..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Archive.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef BASE_WIN32_ARCHIVE_H -#define BASE_WIN32_ARCHIVE_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - -#ifdef PACK_BIG_ENDIAN - - inline double byteSwap(double value) { byteReverse64(&value); return value; } - inline float byteSwap(float value) { byteReverse32(&value); return value; } - inline uint64 byteSwap(uint64 value) { byteReverse64(&value); return value; } - inline int64 byteSwap(int64 value) { byteReverse64(&value); return value; } - inline uint32 byteSwap(uint32 value) { byteReverse32(&value); return value; } - inline int32 byteSwap(int32 value) { byteReverse32(&value); return value; } - inline uint16 byteSwap(uint16 value) { byteReverse16(&value); return value; } - inline int16 byteSwap(int16 value) { byteReverse16(&value); return value; } - -#else - - inline double byteSwap(double value) { return value; } - inline float byteSwap(float value) { return value; } - inline uint64 byteSwap(uint64 value) { return value; } - inline int64 byteSwap(int64 value) { return value; } - inline uint32 byteSwap(uint32 value) { return value; } - inline int32 byteSwap(int32 value) { return value; } - inline uint16 byteSwap(uint16 value) { return value; } - inline int16 byteSwap(int16 value) { return value; } - -#endif - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/BlockAllocator.cpp b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/BlockAllocator.cpp deleted file mode 100755 index 927c5aef..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/BlockAllocator.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "../BlockAllocator.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - BlockAllocator::BlockAllocator() - { - for(unsigned i = 0; i < 31; i++) - { - m_blocks[i] = NULL; - } - } - - BlockAllocator::~BlockAllocator() - { - // free all allocated memory blocks - for(unsigned i = 0; i < 31; i++) - { - while(m_blocks[i] != NULL) - { - uintptr_t *tmp = m_blocks[i]; - m_blocks[i] = (uintptr_t *)*m_blocks[i]; - free(tmp); - } - } - } - -// Allocate a block that is the next power of two greater than the # of bytes passed. -// 33 bytes yields a 64 byte block of memory and so forth. - - void *BlockAllocator::getBlock(unsigned bytes) - { - unsigned accum = 16, bits = 16; - unsigned *handle = NULL; - - // Perform a binary search looking for the highest bit. - - while(bits != 0) - { - // If bytes is less than the bit we're testing for, subtract half - // from the bit value and repeat - if(bytes < (unsigned)(1 << accum)) - { - bits /= 2; - accum -= bits; - } - // If bytes is greater than the bit we're testing for, add half - // from the but value and repeat - else if(bytes > (unsigned)(1 << accum)) - { - bits /= 2; - accum += bits; - } - // Got lucky and hit the value dead on - else - { - break; - } - } - // At this point accum contains the most significant bit index, increment - accum++; - if(accum < 2) - { - accum = 2; - } - - // Note that when memory is actually allocated, 8 extra bytes will be allocated.at the front - // The first integer is the address of the next block of memory when the block is in the allocator - // The second integer is the bit length of the block - // Memory is allocated on 4 byte boundaries to sidestep byte alignment problems - - - // Check if the allocator already has a block of that size - if(m_blocks[accum] == 0) - { - // remove the pre allocated block from the linked list - handle = (uintptr_t *)calloc(((1 << accum) / 4) + 2, sizeof(uintptr_t)); - handle[1] = accum; - handle[0] = 0; - } - else - { - // Allocate a new block - handle = m_blocks[accum]; - m_blocks[accum] = (uintptr_t *)handle[0]; - handle[0] = 0; - } - // return a pointer that skips over the header used for the allocator's purposes - return(handle + 2); - } - - void BlockAllocator::returnBlock(uintptr_t *handle) - { - // C++ allows for safe deletion of a NULL pointer - if(handle) - { - // Update the allocator linked list, insert this entry at the head - *(handle - 2) = (uintptr_t)m_blocks[*(handle - 1)]; - // Add this entry to the proper linked list node - m_blocks[*(handle - 1)] = (handle - 2); - } - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Event.cpp b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Event.cpp deleted file mode 100755 index 12ee8fe7..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Event.cpp +++ /dev/null @@ -1,44 +0,0 @@ -//////////////////////////////////////// -// Event.cpp -// -// Purpose: -// 1. Implementation of the CEvent class. -// -// Revisions: -// 07/10/2001 Created -// - - -#if !defined(_MT) -# pragma message( "Excluding Base::CEvent - requires multi-threaded compile. (_MT)" ) -#else - -#include "Event.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - CEvent::CEvent() - { - mEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); - } - - CEvent::~CEvent() - { - if (mEvent) - CloseHandle(mEvent); - } - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif // #if defined(_MT) - diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Event.h b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Event.h deleted file mode 100755 index 5d2bc712..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Event.h +++ /dev/null @@ -1,92 +0,0 @@ -//////////////////////////////////////// -// Event.h -// -// Purpose: -// 1. Declair the CEvent class that encapsulates the functionality of a -// single-locking semaphore. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_EVENT_H -#define BASE_WIN32_EVENT_H - -#if defined(_MT) - - - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CEvent - // - // Purpose: - // Encapsulates the functionality of a singal-locking semaphore. - // This class is valuable for thread syncronization when a thead's - // execution needs to be dependent upon another thread. - // - // Public Methods: - // Signal() : Signals a thread that has called Wait() so that it can - // continue execution. This function returns true if the waiting - // thread was signalled successfully, otherwise false is returned. - // Wait() : Halts the calling thread's execution indefinately until - // a Singal() call is made by an external thread. If the thread is - // successfully signalled, the function returns eWAIT_SIGNAL. If - // timeout period expires without a signal, eWAIT_TIMEOUT is returned. - // If the function fails, eWAIT_ERROR is returned. - // - class CEvent - { - public: - CEvent(); - virtual ~CEvent(); - - bool Signal(); - int32 Wait(uint32 timeout = 0); - - public: - enum { eWAIT_ERROR, eWAIT_SIGNAL, eWAIT_TIMEOUT }; - private: - HANDLE mEvent; - }; - - inline bool CEvent::Signal() - { - if (mEvent) - return SetEvent(mEvent)!=0; - - return false; - } - - inline int32 CEvent::Wait(uint32 timeout) - { - if (!mEvent) - return CEvent::eWAIT_ERROR; - - DWORD result = WaitForSingleObjectEx(mEvent, timeout ? timeout : INFINITE, FALSE); - if (result == WAIT_OBJECT_0) - return CEvent::eWAIT_SIGNAL; - else if (result == WAIT_TIMEOUT) - return CEvent::eWAIT_TIMEOUT; - else - return CEvent::eWAIT_ERROR; - } - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_MT) - - -#endif // BASE_WIN32_EVENT_H diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/File.cpp b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/File.cpp deleted file mode 100755 index e6b6ee23..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/File.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// File.cpp: implementation of the CFile class. -// -////////////////////////////////////////////////////////////////////// - -#include "File.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CFile::CFile(const char *) -{ - -} - -CFile::~CFile() -{ - -} diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/File.h b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/File.h deleted file mode 100755 index 7965427a..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/File.h +++ /dev/null @@ -1,22 +0,0 @@ -// File.h: interface for the CFile class. -// -////////////////////////////////////////////////////////////////////// - -#ifndef BASE_FILE_H -#define BASE_FILE_H - -#include - -class CFile -{ - public: - CFile(const char *); - virtual ~CFile(); - - bool IsOpen(); - - private: - FILE* mFileHandle; -}; - -#endif // BASE_FILE_H diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Mutex.cpp b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Mutex.cpp deleted file mode 100755 index 482481e8..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Mutex.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////// -// Mutex.cpp -// -// Purpose: -// 1. Implementation of the CMutex class. -// -// Revisions: -// 07/10/2001 Created -// -#if !defined(_MT) -# pragma message( "Excluding Base::CMutex - requires multi-threaded compile. (_MT)" ) -#else - -#include "Mutex.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - -CMutex::CMutex() - { - InitializeCriticalSection(&mCriticalSection); - } - -CMutex::~CMutex() - { - DeleteCriticalSection(&mCriticalSection); - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif // #if defined(_MT) - diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Mutex.h b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Mutex.h deleted file mode 100755 index 66e1c08b..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Mutex.h +++ /dev/null @@ -1,73 +0,0 @@ -//////////////////////////////////////// -// Mutex.h -// -// Purpose: -// 1. Declair the CMutex class that encapsulates the functionality of a -// mutually-exclusive device. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_MUTEX_H -#define BASE_WIN32_MUTEX_H - -#if defined (_MT) - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CMutex - // - // Purpose: - // Encapsulates the functionality of a mutually-exclusive device. - // This class is valuable for protecting against race conditions - // within threaded applications. The CMutex class can be used to - // only allow a single thread to run within a specified code - // segment at a time. - // - // Public Methods: - // Lock() : Locks the mutex. If the mutex is already locked, the - // operating system will block the calling thread until another - // thread has unlocked the mutex. - // Unlock() : Unlocks the mutex. - // - class CMutex - { - public: - CMutex(); - ~CMutex(); - - void Lock(); - void Unlock(); - private: - CRITICAL_SECTION mCriticalSection; - }; - - inline void CMutex::Lock() - { - EnterCriticalSection(&mCriticalSection); - } - - inline void CMutex::Unlock() - { - LeaveCriticalSection(&mCriticalSection); - } - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // #if defined(_MT) - -#endif // BASE_WIN32_MUTEX_H \ No newline at end of file diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Platform.cpp b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Platform.cpp deleted file mode 100755 index 3b52563e..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Platform.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//////////////////////////////////////// -// Platform.cpp -// -// Purpose: -// 1. Implementation of the global functionality declaired in Platform.h. -// -// Revisions: -// 07/10/2001 Created -// - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - - CTimer::CTimer() : - mTimer(0) - { - } - - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Platform.h b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Platform.h deleted file mode 100755 index aaee37b7..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Platform.h +++ /dev/null @@ -1,98 +0,0 @@ -//////////////////////////////////////// -// Platform.h -// -// Purpose: -// 1. Include relevent system headers that are platform specific. -// 2. Declair global platform specific functionality. -// 3. Include primative type definitions -// -// Global Functions: -// getTimer() : Return the current high resolution clock count. -// getTimerFrequency() : Return the frequency of the high resolution clock. -// sleep() : Voluntarily relinquish timeslice of the calling thread for a -// specified number of milliseconds. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_PLATFORM_H -#define BASE_WIN32_PLATFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include "Types.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - uint64 getTimer(void); - uint64 getTimerFrequency(void); - - inline uint64 getTimer(void) - { - uint64 result; - if (!QueryPerformanceCounter(reinterpret_cast(&result))) - result = 0; - return result; - } - - inline uint64 getTimerFrequency(void) - { - uint64 result; - if (!QueryPerformanceFrequency(reinterpret_cast(&result))) - result = 0; - return result; - } - - inline void sleep(uint32 ms) - { - Sleep(ms); - } - - - class CTimer - { - public: - CTimer(); - - void Set(uint32 seconds); - void Signal(); - bool Expired(); - - private: - uint32 mTimer; - }; - - inline void CTimer::Set(uint32 interval) - { - mTimer = (uint32)time(0) + interval; - } - - inline void CTimer::Signal() - { - mTimer = 0; - } - - inline bool CTimer::Expired() - { - return (mTimer <= (uint32)time(0)); - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif BASE_WIN32_PLATFORM_H \ No newline at end of file diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Thread.cpp b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Thread.cpp deleted file mode 100755 index cfb2c177..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Thread.cpp +++ /dev/null @@ -1,279 +0,0 @@ -//////////////////////////////////////// -// Thread.cpp -// -// Purpose: -// 1. Implementation of the CThread class. -// -// Revisions: -// 07/10/2001 Created -// - - -#pragma warning ( disable: 4786 ) - - -#if !defined(_MT) -# pragma message( "Excluding Base::CThread - requires multi-threaded compile. (_MT)" ) -#else - -#include -#include -#include "Thread.h" - -using namespace std; - - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - void threadProc(void *threadPtr) - { - CThread &thread = *((CThread*)threadPtr); - thread.mThreadActive = true; - thread.ThreadProc(); - thread.mThreadActive = false; - } - - CThread::CThread() - { - mThreadID = 0; - mThreadActive = false; - mThreadContinue = false; - } - - CThread::~CThread() - { - StopThread(); - } - - void CThread::StartThread() - { - mThreadContinue = true; - mThreadID = _beginthread(threadProc,0,this); - while (!IsThreadActive()) - Base::sleep(1); - } - - int32 CThread::StopThread(int32 timeout) - { - timeout += time(0); - - mThreadContinue = false; - while (mThreadActive && time(0)OnStartup(this); - while (mThreadContinue) - { - mParent->OnIdle(this); - mSemaphore.Wait(mParent->GetTimeOut()*1000); - - if (mFunction) - { - mFunction(mArgument); - mArgument = NULL; - mFunction = NULL; - } - else if (mParent->OnDestory(this)) - mThreadContinue = false; - } - } - - -//////////////////////////////////////////////////////////////////////////////// - - - CThreadPool::CThreadPool(uint32 maxThreads, uint32 minThreads, uint32 timeout) : - mMutex(), - mIdleMember(), - mBusyMember(), - mNullMember(), - mThreadCount(0), - mMaxThreads(maxThreads), - mMinThreads(minThreads), - mTimeOut(timeout) - { - if (mMaxThreads == 0) mMaxThreads = 1; - if (mMinThreads == 0) mMinThreads = 1; - if (mMinThreads > mMaxThreads) mMinThreads = mMaxThreads; - - for (uint32 i=0; i::iterator setIterator; - - //////////////////////////////////////// - // (1) Destory all busy member threads - mMutex.Lock(); - setIterator = mBusyMember.begin(); - while (setIterator != mBusyMember.end()) - (*setIterator++)->Destroy(); - mMutex.Unlock(); - - //////////////////////////////////////// - // (2) Destory all idle member threads - while (mThreadCount) - { - mMutex.Lock(); - setIterator = mIdleMember.begin(); - while (setIterator != mIdleMember.end()) - (*setIterator++)->Destroy(); - mMutex.Unlock(); - - sleep(1); - } - - //////////////////////////////////////// - // (3) Delete the null member threads - mMutex.Lock(); - while (!mNullMember.empty()) - { - delete mNullMember.front(); - mNullMember.pop_front(); - } - mMutex.Unlock(); - } - - bool CThreadPool::Execute(void( __cdecl *function )( void * ), void * arg) - { - mMutex.Lock(); - - //////////////////////////////////////// - // (1) If no idle members, return false to indicate that no threads - // were available. If the thread count is below the max, create - // a new thread. - if (mIdleMember.empty()) - { - if (mThreadCount < mMaxThreads) - new CMember(this); - mMutex.Unlock(); - return false; - } - - //////////////////////////////////////// - // (2) Delete any null member threads. - while (!mNullMember.empty()) - { - delete mNullMember.front(); - mNullMember.pop_front(); - } - - //////////////////////////////////////// - // (3) Move the first idle thread to the busy set and signal the - // thread to execute the specified function. - CMember * member = *(mIdleMember.begin()); - mIdleMember.erase(member); - mBusyMember.insert(member); - member->Execute(function,arg); - - mMutex.Unlock(); - return true; - } - - uint32 CThreadPool::GetTimeOut() - { - return mTimeOut; - } - - void CThreadPool::OnStartup(CMember * member) - { - mMutex.Lock(); - - mThreadCount++; - mIdleMember.insert(member); - - mMutex.Unlock(); - } - - void CThreadPool::OnIdle(CMember * member) - { - mMutex.Lock(); - - mBusyMember.erase(member); - mIdleMember.insert(member); - - mMutex.Unlock(); - } - - bool CThreadPool::OnDestory(CMember * member) - { - set::iterator setIterator; - - mMutex.Lock(); - - bool result = (setIterator = mIdleMember.find(member)) != mIdleMember.end(); - if (result) - { - mNullMember.push_back(member); - mIdleMember.erase(setIterator); - mThreadCount--; - } - - mMutex.Unlock(); - - return result; - } - - -//////////////////////////////////////////////////////////////////////////////// - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif // #if defined(_MT) - diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Thread.h b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Thread.h deleted file mode 100755 index a8338917..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Thread.h +++ /dev/null @@ -1,144 +0,0 @@ -//////////////////////////////////////// -// Thread.h -// -// Purpose: -// 1. Declair the CThread class that encapsulates threading functionality. -// This abstract base class in intended to be used to encapsulate -// individual tasks that require threading in derived classes. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_THREAD_H -#define BASE_WIN32_THREAD_H - -#if defined(_MT) - -#pragma warning( disable : 4786) - -#include -#include -#include "Platform.h" -#include "Mutex.h" -#include "Event.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CThread - // - // Purpose: - // Encapsulates threading functionality. Creating classes derived - // from CThread provides an easy way to encapsulate tasks that require - // their own thread. - // - // Public Methods: - // StartThread() : Creates the low-level thread handle and begins executing - // the CThread::ThreadProc() function within the new thread. - // StopThread() : Signals the ThreadProc() function to stop executing using - // the mThreadContinue member variable, and waits for the ThreadProc() - // function to exit. By default, the function will block for a maximum - // of 5 seconds before exiting without the thread halting. - // IsThreadActive() : Returns true if the physical thread is still executing - // within the ThreadProc() function, otherwise it returns false. - // ThreadProc() : Pure-virtual function that will be executed when the StartThread() - // function is called. Derived classes must implement this function. The - // mThreadContinue member variable should be used internal the the ThreadProc() - // function to indicate whether it should continue executing or exit. - // Protected Attributes: - // mThreadContinue : Boolean value indicating to the ThreadProc() function - // whether to continue executing or to exit. If mThreadContinue is true, - // ThreadProc() should continue, otherwise ThreadProc() should exit. It - // left up to the derived class to implement a ThreadProc() function that - // uses the mThreadContinue member. - // - // - class CThread - { - friend void threadProc(void *); - - public: - enum { eSTOP_SUCCESS, eSTOP_TIMEOUT }; - public: - CThread(); - virtual ~CThread(); - - void StartThread(); - int32 StopThread(int32 timeout=5); - bool IsThreadActive() { return mThreadActive; } - - protected: - virtual void ThreadProc() = 0; - - protected: - bool mThreadContinue; - private: - uint32 mThreadID; - bool mThreadActive; - }; - - - class CThreadPool - { - private: - class CMember : public CThread - { - public: - CMember(CThreadPool * parent); - virtual ~CMember(); - - bool Execute(void( __cdecl *function )( void * ), void * arg); - void Destroy(); - - protected: - virtual void ThreadProc(); - - private: - CThreadPool * mParent; - void( __cdecl * mFunction )( void * ); - void * mArgument; - CEvent mSemaphore; - }; - friend class CMember; - - public: - CThreadPool(uint32 maxThreads, uint32 minThreads=1, uint32 timeout=15*60); - ~CThreadPool(); - - bool Execute(void( __cdecl *function )( void * ), void * arg); - - private: - uint32 GetTimeOut(); - void OnStartup(CMember * member); - void OnIdle(CMember * member); - bool OnDestory(CMember * member); - - private: - CMutex mMutex; - std::set mIdleMember; - std::set mBusyMember; - std::list mNullMember; - uint32 mThreadCount; - - uint32 mMaxThreads; - uint32 mMinThreads; - uint32 mTimeOut; - }; - - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // #if defined(_MT) - -#endif // BASE_WIN32_THREAD_H diff --git a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Types.h b/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Types.h deleted file mode 100755 index 0c64cb2c..00000000 --- a/external/3rd/library/soePlatform/CSAssist/utils/Base/win32/Types.h +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////// -// Types.h -// -// Purpose: -// 1. Define integer types that are unambiguous with respect to size -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_TYPES_H -#define BASE_WIN32_TYPES_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - -#define INT32_MAX 0x7FFFFFFF -#define INT32_MIN 0x80000000 -#define UINT32_MAX 0xFFFFFFFF - -typedef signed char int8; -typedef unsigned char uint8; -typedef short int16; -typedef unsigned short uint16; - -typedef int int32; -typedef unsigned uint32; -typedef __int64 int64; -typedef unsigned __int64 uint64; - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // BASE_WIN32_TYPES_H - diff --git a/external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Archive.h b/external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Archive.h deleted file mode 100755 index 30ddce43..00000000 --- a/external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Archive.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef BASE_WIN32_ARCHIVE_H -#define BASE_WIN32_ARCHIVE_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - -#ifdef PACK_BIG_ENDIAN - - inline double byteSwap(double value) { byteReverse64(&value); return value; } - inline float byteSwap(float value) { byteReverse32(&value); return value; } - inline uint64 byteSwap(uint64 value) { byteReverse64(&value); return value; } - inline int64 byteSwap(int64 value) { byteReverse64(&value); return value; } - inline uint32 byteSwap(uint32 value) { byteReverse32(&value); return value; } - inline int32 byteSwap(int32 value) { byteReverse32(&value); return value; } - inline uint16 byteSwap(uint16 value) { byteReverse16(&value); return value; } - inline int16 byteSwap(int16 value) { byteReverse16(&value); return value; } - -#else - - inline double byteSwap(double value) { return value; } - inline float byteSwap(float value) { return value; } - inline uint64 byteSwap(uint64 value) { return value; } - inline int64 byteSwap(int64 value) { return value; } - inline uint32 byteSwap(uint32 value) { return value; } - inline int32 byteSwap(int32 value) { return value; } - inline uint16 byteSwap(uint16 value) { return value; } - inline int16 byteSwap(int16 value) { return value; } - -#endif - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif diff --git a/external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Platform.cpp b/external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Platform.cpp deleted file mode 100755 index 3b52563e..00000000 --- a/external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Platform.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//////////////////////////////////////// -// Platform.cpp -// -// Purpose: -// 1. Implementation of the global functionality declaired in Platform.h. -// -// Revisions: -// 07/10/2001 Created -// - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - - CTimer::CTimer() : - mTimer(0) - { - } - - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif diff --git a/external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Platform.h b/external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Platform.h deleted file mode 100755 index aaee37b7..00000000 --- a/external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Platform.h +++ /dev/null @@ -1,98 +0,0 @@ -//////////////////////////////////////// -// Platform.h -// -// Purpose: -// 1. Include relevent system headers that are platform specific. -// 2. Declair global platform specific functionality. -// 3. Include primative type definitions -// -// Global Functions: -// getTimer() : Return the current high resolution clock count. -// getTimerFrequency() : Return the frequency of the high resolution clock. -// sleep() : Voluntarily relinquish timeslice of the calling thread for a -// specified number of milliseconds. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_PLATFORM_H -#define BASE_WIN32_PLATFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include "Types.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - uint64 getTimer(void); - uint64 getTimerFrequency(void); - - inline uint64 getTimer(void) - { - uint64 result; - if (!QueryPerformanceCounter(reinterpret_cast(&result))) - result = 0; - return result; - } - - inline uint64 getTimerFrequency(void) - { - uint64 result; - if (!QueryPerformanceFrequency(reinterpret_cast(&result))) - result = 0; - return result; - } - - inline void sleep(uint32 ms) - { - Sleep(ms); - } - - - class CTimer - { - public: - CTimer(); - - void Set(uint32 seconds); - void Signal(); - bool Expired(); - - private: - uint32 mTimer; - }; - - inline void CTimer::Set(uint32 interval) - { - mTimer = (uint32)time(0) + interval; - } - - inline void CTimer::Signal() - { - mTimer = 0; - } - - inline bool CTimer::Expired() - { - return (mTimer <= (uint32)time(0)); - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif BASE_WIN32_PLATFORM_H \ No newline at end of file diff --git a/external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Types.h b/external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Types.h deleted file mode 100755 index 0c64cb2c..00000000 --- a/external/3rd/library/soePlatform/CTServiceGameAPI/Base/win32/Types.h +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////// -// Types.h -// -// Purpose: -// 1. Define integer types that are unambiguous with respect to size -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_TYPES_H -#define BASE_WIN32_TYPES_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - -#define INT32_MAX 0x7FFFFFFF -#define INT32_MIN 0x80000000 -#define UINT32_MAX 0xFFFFFFFF - -typedef signed char int8; -typedef unsigned char uint8; -typedef short int16; -typedef unsigned short uint16; - -typedef int int32; -typedef unsigned uint32; -typedef __int64 int64; -typedef unsigned __int64 uint64; - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // BASE_WIN32_TYPES_H - diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Archive.h b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Archive.h deleted file mode 100755 index 30ddce43..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Archive.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef BASE_WIN32_ARCHIVE_H -#define BASE_WIN32_ARCHIVE_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - -#ifdef PACK_BIG_ENDIAN - - inline double byteSwap(double value) { byteReverse64(&value); return value; } - inline float byteSwap(float value) { byteReverse32(&value); return value; } - inline uint64 byteSwap(uint64 value) { byteReverse64(&value); return value; } - inline int64 byteSwap(int64 value) { byteReverse64(&value); return value; } - inline uint32 byteSwap(uint32 value) { byteReverse32(&value); return value; } - inline int32 byteSwap(int32 value) { byteReverse32(&value); return value; } - inline uint16 byteSwap(uint16 value) { byteReverse16(&value); return value; } - inline int16 byteSwap(int16 value) { byteReverse16(&value); return value; } - -#else - - inline double byteSwap(double value) { return value; } - inline float byteSwap(float value) { return value; } - inline uint64 byteSwap(uint64 value) { return value; } - inline int64 byteSwap(int64 value) { return value; } - inline uint32 byteSwap(uint32 value) { return value; } - inline int32 byteSwap(int32 value) { return value; } - inline uint16 byteSwap(uint16 value) { return value; } - inline int16 byteSwap(int16 value) { return value; } - -#endif - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/BlockAllocator.cpp b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/BlockAllocator.cpp deleted file mode 100755 index 6762bc2a..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/BlockAllocator.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "../BlockAllocator.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - BlockAllocator::BlockAllocator() - { - for(unsigned i = 0; i < 31; i++) - { - m_blocks[i] = NULL; - } - } - - BlockAllocator::~BlockAllocator() - { - // free all allocated memory blocks - for(unsigned i = 0; i < 31; i++) - { - while(m_blocks[i] != NULL) - { - unsigned *tmp = m_blocks[i]; - m_blocks[i] = (uintptr_t *)*m_blocks[i]; - free(tmp); - } - } - } - -// Allocate a block that is the next power of two greater than the # of bytes passed. -// 33 bytes yields a 64 byte block of memory and so forth. - - void *BlockAllocator::getBlock(unsigned bytes) - { - unsigned accum = 16, bits = 16; - unsigned *handle = NULL; - - // Perform a binary search looking for the highest bit. - - while(bits != 0) - { - // If bytes is less than the bit we're testing for, subtract half - // from the bit value and repeat - if(bytes < (unsigned)(1 << accum)) - { - bits /= 2; - accum -= bits; - } - // If bytes is greater than the bit we're testing for, add half - // from the but value and repeat - else if(bytes > (unsigned)(1 << accum)) - { - bits /= 2; - accum += bits; - } - // Got lucky and hit the value dead on - else - { - break; - } - } - // At this point accum contains the most significant bit index, increment - accum++; - if(accum < 2) - { - accum = 2; - } - - // Note that when memory is actually allocated, 8 extra bytes will be allocated.at the front - // The first integer is the address of the next block of memory when the block is in the allocator - // The second integer is the bit length of the block - // Memory is allocated on 4 byte boundaries to sidestep byte alignment problems - - - // Check if the allocator already has a block of that size - if(m_blocks[accum] == 0) - { - // remove the pre allocated block from the linked list - handle = (unsigned *)calloc(((1 << accum) / 4) + 2, sizeof(unsigned)); - handle[1] = accum; - handle[0] = 0; - } - else - { - // Allocate a new block - handle = m_blocks[accum]; - m_blocks[accum] = (uintptr_t *)handle[0]; - handle[0] = 0; - } - // return a pointer that skips over the header used for the allocator's purposes - return(handle + 2); - } - - void BlockAllocator::returnBlock(uintptr_t *handle) - { - // C++ allows for safe deletion of a NULL pointer - if(handle) - { - // Update the allocator linked list, insert this entry at the head - *(handle - 2) = (uintptr_t)m_blocks[*(handle - 1)]; - // Add this entry to the proper linked list node - m_blocks[*(handle - 1)] = (handle - 2); - } - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Event.cpp b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Event.cpp deleted file mode 100755 index 12ee8fe7..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Event.cpp +++ /dev/null @@ -1,44 +0,0 @@ -//////////////////////////////////////// -// Event.cpp -// -// Purpose: -// 1. Implementation of the CEvent class. -// -// Revisions: -// 07/10/2001 Created -// - - -#if !defined(_MT) -# pragma message( "Excluding Base::CEvent - requires multi-threaded compile. (_MT)" ) -#else - -#include "Event.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - CEvent::CEvent() - { - mEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); - } - - CEvent::~CEvent() - { - if (mEvent) - CloseHandle(mEvent); - } - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif // #if defined(_MT) - diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Event.h b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Event.h deleted file mode 100755 index 5d2bc712..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Event.h +++ /dev/null @@ -1,92 +0,0 @@ -//////////////////////////////////////// -// Event.h -// -// Purpose: -// 1. Declair the CEvent class that encapsulates the functionality of a -// single-locking semaphore. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_EVENT_H -#define BASE_WIN32_EVENT_H - -#if defined(_MT) - - - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CEvent - // - // Purpose: - // Encapsulates the functionality of a singal-locking semaphore. - // This class is valuable for thread syncronization when a thead's - // execution needs to be dependent upon another thread. - // - // Public Methods: - // Signal() : Signals a thread that has called Wait() so that it can - // continue execution. This function returns true if the waiting - // thread was signalled successfully, otherwise false is returned. - // Wait() : Halts the calling thread's execution indefinately until - // a Singal() call is made by an external thread. If the thread is - // successfully signalled, the function returns eWAIT_SIGNAL. If - // timeout period expires without a signal, eWAIT_TIMEOUT is returned. - // If the function fails, eWAIT_ERROR is returned. - // - class CEvent - { - public: - CEvent(); - virtual ~CEvent(); - - bool Signal(); - int32 Wait(uint32 timeout = 0); - - public: - enum { eWAIT_ERROR, eWAIT_SIGNAL, eWAIT_TIMEOUT }; - private: - HANDLE mEvent; - }; - - inline bool CEvent::Signal() - { - if (mEvent) - return SetEvent(mEvent)!=0; - - return false; - } - - inline int32 CEvent::Wait(uint32 timeout) - { - if (!mEvent) - return CEvent::eWAIT_ERROR; - - DWORD result = WaitForSingleObjectEx(mEvent, timeout ? timeout : INFINITE, FALSE); - if (result == WAIT_OBJECT_0) - return CEvent::eWAIT_SIGNAL; - else if (result == WAIT_TIMEOUT) - return CEvent::eWAIT_TIMEOUT; - else - return CEvent::eWAIT_ERROR; - } - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif -#endif // #if defined(_MT) - - -#endif // BASE_WIN32_EVENT_H diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/File.cpp b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/File.cpp deleted file mode 100755 index c888e545..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/File.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// File.cpp: implementation of the CFile class. -// -////////////////////////////////////////////////////////////////////// - -#include "File.h" - -namespace Base -{ - ////////////////////////////////////////////////////////////////////// - // Construction/Destruction - ////////////////////////////////////////////////////////////////////// - - CFile::CFile(const char *) - { - - } - - CFile::~CFile() - { - - } -} diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/File.h b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/File.h deleted file mode 100755 index fb15ccf1..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/File.h +++ /dev/null @@ -1,26 +0,0 @@ -// File.h: interface for the CFile class. -// -////////////////////////////////////////////////////////////////////// - -#ifndef BASE_FILE_H -#define BASE_FILE_H - -#include - -namespace Base -{ - - class CFile - { - public: - CFile(const char *); - virtual ~CFile(); - - bool IsOpen(); - - private: - FILE* mFileHandle; - }; -} - -#endif // BASE_FILE_H diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Mutex.cpp b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Mutex.cpp deleted file mode 100755 index 482481e8..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Mutex.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////// -// Mutex.cpp -// -// Purpose: -// 1. Implementation of the CMutex class. -// -// Revisions: -// 07/10/2001 Created -// -#if !defined(_MT) -# pragma message( "Excluding Base::CMutex - requires multi-threaded compile. (_MT)" ) -#else - -#include "Mutex.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - -CMutex::CMutex() - { - InitializeCriticalSection(&mCriticalSection); - } - -CMutex::~CMutex() - { - DeleteCriticalSection(&mCriticalSection); - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif // #if defined(_MT) - diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Mutex.h b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Mutex.h deleted file mode 100755 index 66e1c08b..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Mutex.h +++ /dev/null @@ -1,73 +0,0 @@ -//////////////////////////////////////// -// Mutex.h -// -// Purpose: -// 1. Declair the CMutex class that encapsulates the functionality of a -// mutually-exclusive device. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_MUTEX_H -#define BASE_WIN32_MUTEX_H - -#if defined (_MT) - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CMutex - // - // Purpose: - // Encapsulates the functionality of a mutually-exclusive device. - // This class is valuable for protecting against race conditions - // within threaded applications. The CMutex class can be used to - // only allow a single thread to run within a specified code - // segment at a time. - // - // Public Methods: - // Lock() : Locks the mutex. If the mutex is already locked, the - // operating system will block the calling thread until another - // thread has unlocked the mutex. - // Unlock() : Unlocks the mutex. - // - class CMutex - { - public: - CMutex(); - ~CMutex(); - - void Lock(); - void Unlock(); - private: - CRITICAL_SECTION mCriticalSection; - }; - - inline void CMutex::Lock() - { - EnterCriticalSection(&mCriticalSection); - } - - inline void CMutex::Unlock() - { - LeaveCriticalSection(&mCriticalSection); - } - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // #if defined(_MT) - -#endif // BASE_WIN32_MUTEX_H \ No newline at end of file diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Platform.cpp b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Platform.cpp deleted file mode 100755 index 3b52563e..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Platform.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//////////////////////////////////////// -// Platform.cpp -// -// Purpose: -// 1. Implementation of the global functionality declaired in Platform.h. -// -// Revisions: -// 07/10/2001 Created -// - -#include "Platform.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - - CTimer::CTimer() : - mTimer(0) - { - } - - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Platform.h b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Platform.h deleted file mode 100755 index aaee37b7..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Platform.h +++ /dev/null @@ -1,98 +0,0 @@ -//////////////////////////////////////// -// Platform.h -// -// Purpose: -// 1. Include relevent system headers that are platform specific. -// 2. Declair global platform specific functionality. -// 3. Include primative type definitions -// -// Global Functions: -// getTimer() : Return the current high resolution clock count. -// getTimerFrequency() : Return the frequency of the high resolution clock. -// sleep() : Voluntarily relinquish timeslice of the calling thread for a -// specified number of milliseconds. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_PLATFORM_H -#define BASE_WIN32_PLATFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include "Types.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - uint64 getTimer(void); - uint64 getTimerFrequency(void); - - inline uint64 getTimer(void) - { - uint64 result; - if (!QueryPerformanceCounter(reinterpret_cast(&result))) - result = 0; - return result; - } - - inline uint64 getTimerFrequency(void) - { - uint64 result; - if (!QueryPerformanceFrequency(reinterpret_cast(&result))) - result = 0; - return result; - } - - inline void sleep(uint32 ms) - { - Sleep(ms); - } - - - class CTimer - { - public: - CTimer(); - - void Set(uint32 seconds); - void Signal(); - bool Expired(); - - private: - uint32 mTimer; - }; - - inline void CTimer::Set(uint32 interval) - { - mTimer = (uint32)time(0) + interval; - } - - inline void CTimer::Signal() - { - mTimer = 0; - } - - inline bool CTimer::Expired() - { - return (mTimer <= (uint32)time(0)); - } -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif BASE_WIN32_PLATFORM_H \ No newline at end of file diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Thread.cpp b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Thread.cpp deleted file mode 100755 index 9dcbb9a9..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Thread.cpp +++ /dev/null @@ -1,315 +0,0 @@ -//////////////////////////////////////// -// Thread.cpp -// -// Purpose: -// 1. Implementation of the CThread class. -// -// Revisions: -// 07/10/2001 Created -// - - -#pragma warning ( disable: 4786 ) - - -#if !defined(_MT) -# pragma message( "Excluding Base::CThread - requires multi-threaded compile. (_MT)" ) -#else - -#include -#include -#include "Thread.h" - -using namespace std; - - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - void threadProc(void *threadPtr) - { - CThread &thread = *((CThread*)threadPtr); - thread.mThreadActive = true; - thread.ThreadProc(); - thread.mThreadActive = false; - } - - CThread::CThread() - { - mThreadID = 0; - mThreadActive = false; - mThreadContinue = false; - } - - CThread::~CThread() - { - StopThread(); - } - - void CThread::StartThread() - { - mThreadContinue = true; - mThreadID = _beginthread(threadProc,0,this); - while (!IsThreadActive()) - Base::sleep(1); - } - - int32 CThread::StopThread(int32 timeout) - { - timeout += time(0); - - mThreadContinue = false; - while (mThreadActive && time(0)OnStartup(this); - while (mThreadContinue) - { - mParent->OnIdle(this); - mSemaphore.Wait(mParent->GetTimeOut()*1000); - - if (mFunction) - { - mFunction(mArgument); - mArgument = NULL; - mFunction = NULL; - } - else if (mParent->OnDestory(this)) - mThreadContinue = false; - } - } - - -//////////////////////////////////////////////////////////////////////////////// - - - CThreadPool::CThreadPool(uint32 maxThreads, uint32 minThreads, uint32 timeout) : - mMutex(), - mIdleMember(), - mBusyMember(), - mNullMember(), - mThreadCount(0), - mMaxThreads(maxThreads), - mMinThreads(minThreads), - mTimeOut(timeout) - { - if (mMaxThreads == 0) mMaxThreads = 1; - if (mMinThreads == 0) mMinThreads = 1; - if (mMinThreads > mMaxThreads) mMinThreads = mMaxThreads; - - for (uint32 i=0; i::iterator setIterator; - - //////////////////////////////////////// - // (1) Destory all busy member threads - mMutex.Lock(); - setIterator = mBusyMember.begin(); - while (setIterator != mBusyMember.end()) - (*setIterator++)->Destroy(); - mMutex.Unlock(); - - //////////////////////////////////////// - // (2) Destory all idle member threads - while (mThreadCount) - { - mMutex.Lock(); - setIterator = mIdleMember.begin(); - while (setIterator != mIdleMember.end()) - (*setIterator++)->Destroy(); - mMutex.Unlock(); - - sleep(1); - } - - //////////////////////////////////////// - // (3) Delete the null member threads - mMutex.Lock(); - while (!mNullMember.empty()) - { - delete mNullMember.front(); - mNullMember.pop_front(); - } - mMutex.Unlock(); - } - - bool CThreadPool::Execute(void( __cdecl *function )( void * ), void * arg, uint32 poolGrowthSize ) - { - mMutex.Lock(); - - //////////////////////////////////////// - // (1) If no idle members, return false to indicate that no threads - // were available. If the thread count is below the max, create - // a new thread. - if (mIdleMember.empty()) - { - if (mThreadCount < mMaxThreads) - { - if (!poolGrowthSize) - poolGrowthSize = mMinThreads; - - if ((mThreadCount + poolGrowthSize) > mMaxThreads) - poolGrowthSize = mMaxThreads - mThreadCount; - - for (uint32 i(0); i < poolGrowthSize; i++) - new CMember(this); - mMutex.Unlock(); - time_t idleTimeout = time(0) + 5; - while(mIdleMember.empty()) - { - if (time(0) >= idleTimeout) - { - return false; - } - Base::sleep(10); - } - mMutex.Lock(); - - } - else - { - mMutex.Unlock(); - return false; - } - } - - //////////////////////////////////////// - // (2) Delete any null member threads. - while (!mNullMember.empty()) - { - delete mNullMember.front(); - mNullMember.pop_front(); - } - - //////////////////////////////////////// - // (3) Move the first idle thread to the busy set and signal the - // thread to execute the specified function. - CMember * member = *(mIdleMember.begin()); - mIdleMember.erase(member); - mBusyMember.insert(member); - member->Execute(function,arg); - - mMutex.Unlock(); - return true; - } - - uint32 CThreadPool::GetTimeOut() - { - return mTimeOut; - } - - void CThreadPool::OnStartup(CMember * member) - { - mMutex.Lock(); - - mThreadCount++; - mIdleMember.insert(member); - - mMutex.Unlock(); - } - - void CThreadPool::OnIdle(CMember * member) - { - mMutex.Lock(); - - mBusyMember.erase(member); - mIdleMember.insert(member); - - mMutex.Unlock(); - } - - bool CThreadPool::OnDestory(CMember * member) - { - set::iterator setIterator; - - mMutex.Lock(); - - bool result = (setIterator = mIdleMember.find(member)) != mIdleMember.end(); - if (result) - { - mNullMember.push_back(member); - mIdleMember.erase(setIterator); - mThreadCount--; - } - - mMutex.Unlock(); - - return result; - } - - SwitchableScopeLock::SwitchableScopeLock(CMutex & mutex, bool isOn) : - mMutex(mutex), - mIsOn(isOn) - { - if(mIsOn) { mMutex.Lock(); } - } - - SwitchableScopeLock::~SwitchableScopeLock() - { - if(mIsOn) { mMutex.Unlock(); } - } - - -//////////////////////////////////////////////////////////////////////////////// - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - - -#endif // #if defined(_MT) - diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Thread.h b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Thread.h deleted file mode 100755 index cbffabb6..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Thread.h +++ /dev/null @@ -1,152 +0,0 @@ -//////////////////////////////////////// -// Thread.h -// -// Purpose: -// 1. Declair the CThread class that encapsulates threading functionality. -// This abstract base class in intended to be used to encapsulate -// individual tasks that require threading in derived classes. -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_THREAD_H -#define BASE_WIN32_THREAD_H - -#if defined(_MT) - -#pragma warning( disable : 4786) - -#include -#include -#include "Platform.h" -#include "Mutex.h" -#include "Event.h" - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - - //////////////////////////////////////// - // Class: - // CThread - // - // Purpose: - // Encapsulates threading functionality. Creating classes derived - // from CThread provides an easy way to encapsulate tasks that require - // their own thread. - // - // Public Methods: - // StartThread() : Creates the low-level thread handle and begins executing - // the CThread::ThreadProc() function within the new thread. - // StopThread() : Signals the ThreadProc() function to stop executing using - // the mThreadContinue member variable, and waits for the ThreadProc() - // function to exit. By default, the function will block for a maximum - // of 5 seconds before exiting without the thread halting. - // IsThreadActive() : Returns true if the physical thread is still executing - // within the ThreadProc() function, otherwise it returns false. - // ThreadProc() : Pure-virtual function that will be executed when the StartThread() - // function is called. Derived classes must implement this function. The - // mThreadContinue member variable should be used internal the the ThreadProc() - // function to indicate whether it should continue executing or exit. - // Protected Attributes: - // mThreadContinue : Boolean value indicating to the ThreadProc() function - // whether to continue executing or to exit. If mThreadContinue is true, - // ThreadProc() should continue, otherwise ThreadProc() should exit. It - // left up to the derived class to implement a ThreadProc() function that - // uses the mThreadContinue member. - // - // - class CThread - { - friend void threadProc(void *); - - public: - enum { eSTOP_SUCCESS, eSTOP_TIMEOUT }; - public: - CThread(); - virtual ~CThread(); - - void StartThread(); - int32 StopThread(int32 timeout=5); - bool IsThreadActive() { return mThreadActive; } - - protected: - virtual void ThreadProc() = 0; - - protected: - bool mThreadContinue; - private: - uint32 mThreadID; - bool mThreadActive; - }; - - - class CThreadPool - { - private: - class CMember : public CThread - { - public: - CMember(CThreadPool * parent); - virtual ~CMember(); - - bool Execute(void( __cdecl *function )( void * ), void * arg); - void Destroy(); - - protected: - virtual void ThreadProc(); - - private: - CThreadPool * mParent; - void( __cdecl * mFunction )( void * ); - void * mArgument; - CEvent mSemaphore; - }; - friend class CMember; - - public: - CThreadPool(uint32 maxThreads, uint32 minThreads=1, uint32 timeout=15*60); - ~CThreadPool(); - - virtual bool Execute(void( __cdecl *function )( void * ), void * arg, uint32 poolGrowthSize = 0); - - private: - uint32 GetTimeOut(); - void OnStartup(CMember * member); - void OnIdle(CMember * member); - bool OnDestory(CMember * member); - - private: - CMutex mMutex; - std::set mIdleMember; - std::set mBusyMember; - std::list mNullMember; - uint32 mThreadCount; - - uint32 mMaxThreads; - uint32 mMinThreads; - uint32 mTimeOut; - }; - - class SwitchableScopeLock - { - public: - SwitchableScopeLock(CMutex & mutex, bool isOn); - ~SwitchableScopeLock(); - private: - CMutex & mMutex; - bool mIsOn; - }; -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // #if defined(_MT) - -#endif // BASE_WIN32_THREAD_H diff --git a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Types.h b/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Types.h deleted file mode 100755 index 0c64cb2c..00000000 --- a/external/3rd/library/soePlatform/ChatAPI/utils/Base/win32/Types.h +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////// -// Types.h -// -// Purpose: -// 1. Define integer types that are unambiguous with respect to size -// -// Revisions: -// 07/10/2001 Created -// - -#ifndef BASE_WIN32_TYPES_H -#define BASE_WIN32_TYPES_H - -#ifdef EXTERNAL_DISTRO -namespace NAMESPACE -{ - -#endif -namespace Base -{ - -#define INT32_MAX 0x7FFFFFFF -#define INT32_MIN 0x80000000 -#define UINT32_MAX 0xFFFFFFFF - -typedef signed char int8; -typedef unsigned char uint8; -typedef short int16; -typedef unsigned short uint16; - -typedef int int32; -typedef unsigned uint32; -typedef __int64 int64; -typedef unsigned __int64 uint64; - -}; -#ifdef EXTERNAL_DISTRO -}; -#endif - -#endif // BASE_WIN32_TYPES_H - diff --git a/external/ours/library/archive/src/win32/ArchiveMutex.cpp b/external/ours/library/archive/src/win32/ArchiveMutex.cpp deleted file mode 100755 index 016c070b..00000000 --- a/external/ours/library/archive/src/win32/ArchiveMutex.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// ====================================================================== -// -// -// Copyright 6/19/2001 Sony Online Entertainment -// -// ====================================================================== - - -#include "FirstArchive.h" -#include "ArchiveMutex.h" - -namespace Archive -{ - -ArchiveMutex::ArchiveMutex() -{ - InitializeCriticalSection(&m_criticalSection); -} - -ArchiveMutex::~ArchiveMutex() -{ - DeleteCriticalSection(&m_criticalSection); -} - -void ArchiveMutex::enter() -{ - EnterCriticalSection(&m_criticalSection); -} - -void ArchiveMutex::leave() -{ - LeaveCriticalSection(&m_criticalSection); -} - -} diff --git a/external/ours/library/archive/src/win32/ArchiveMutex.h b/external/ours/library/archive/src/win32/ArchiveMutex.h deleted file mode 100755 index b453981b..00000000 --- a/external/ours/library/archive/src/win32/ArchiveMutex.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _ArchiveMutex_H -#define _ArchiveMutex_H - -#include - -namespace Archive -{ - - class ArchiveMutex - { - public: - - ArchiveMutex(); - ~ArchiveMutex(); - void enter(); - void leave(); - - private: - ArchiveMutex(const ArchiveMutex &o); - ArchiveMutex &operator =(const ArchiveMutex &o); - - CRITICAL_SECTION m_criticalSection; - - }; -} - -#endif diff --git a/external/ours/library/archive/src/win32/FirstArchive.cpp b/external/ours/library/archive/src/win32/FirstArchive.cpp deleted file mode 100755 index 6e118e67..00000000 --- a/external/ours/library/archive/src/win32/FirstArchive.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// FirstArchive.cpp -// copyright 2001 Verant Interactive -// Author: Justin Randall - -//----------------------------------------------------------------------- - -#include "FirstArchive.h" - -//----------------------------------------------------------------------- - -namespace -{ - void supress_warning_LNK4221() - { - } -} diff --git a/external/ours/library/crypto/src/win32/FirstCrypto.cpp b/external/ours/library/crypto/src/win32/FirstCrypto.cpp deleted file mode 100755 index 8b9ece1b..00000000 --- a/external/ours/library/crypto/src/win32/FirstCrypto.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "FirstCrypto.h" diff --git a/external/ours/library/fileInterface/src/win32/FirstFileInterface.cpp b/external/ours/library/fileInterface/src/win32/FirstFileInterface.cpp deleted file mode 100755 index 33fdbcbc..00000000 --- a/external/ours/library/fileInterface/src/win32/FirstFileInterface.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "fileInterface/FirstFileInterface.h" diff --git a/external/ours/library/localization/src/win32/FirstLocalization.cpp b/external/ours/library/localization/src/win32/FirstLocalization.cpp deleted file mode 100755 index c21d66d0..00000000 --- a/external/ours/library/localization/src/win32/FirstLocalization.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstLocalization.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "FirstLocalization.h" diff --git a/external/ours/library/localizationArchive/src/win32/FirstLocalizationArchive.cpp b/external/ours/library/localizationArchive/src/win32/FirstLocalizationArchive.cpp deleted file mode 100755 index 475bd6c7..00000000 --- a/external/ours/library/localizationArchive/src/win32/FirstLocalizationArchive.cpp +++ /dev/null @@ -1,10 +0,0 @@ -//====================================================================== -// -// FirstLocalizationArchive.cpp -// copyright (c) 2002 Sony Online Entertainment -// -//====================================================================== - -#include "localizationArchive/FirstLocalizationArchive.h" - -//====================================================================== diff --git a/external/ours/library/unicode/src/win32/FirstUnicode.cpp b/external/ours/library/unicode/src/win32/FirstUnicode.cpp deleted file mode 100755 index 176b4e33..00000000 --- a/external/ours/library/unicode/src/win32/FirstUnicode.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstUnicode.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "FirstUnicode.h" diff --git a/external/ours/library/unicodeArchive/src/win32/FirstUnicodeArchive.cpp b/external/ours/library/unicodeArchive/src/win32/FirstUnicodeArchive.cpp deleted file mode 100755 index 4cb0ce59..00000000 --- a/external/ours/library/unicodeArchive/src/win32/FirstUnicodeArchive.cpp +++ /dev/null @@ -1,12 +0,0 @@ -//====================================================================== -// -// FirstUnicodeArchive.cpp -// copyright (c) 2002 Sony Online Entertainment -// -//====================================================================== - -#include "unicodeArchive/FirstUnicodeArchive.h" - -//====================================================================== - -//====================================================================== diff --git a/game/server/application/SwgDatabaseServer/src/win32/FirstSwgDatabaseServer.cpp b/game/server/application/SwgDatabaseServer/src/win32/FirstSwgDatabaseServer.cpp deleted file mode 100755 index d815aeca..00000000 --- a/game/server/application/SwgDatabaseServer/src/win32/FirstSwgDatabaseServer.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "SwgDatabaseServer/FirstSwgDatabaseServer.h" diff --git a/game/server/application/SwgDatabaseServer/src/win32/WinMain.cpp b/game/server/application/SwgDatabaseServer/src/win32/WinMain.cpp deleted file mode 100755 index 6e458a7c..00000000 --- a/game/server/application/SwgDatabaseServer/src/win32/WinMain.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "SwgDatabaseServer/FirstSwgDatabaseServer.h" - -#include "serverDatabase/ConfigServerDatabase.h" -#include "serverDatabase/DatabaseProcess.h" - -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFile/TreeFile.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedLog/LogManager.h" -#include "sharedLog/SetupSharedLog.h" -#include "sharedNetwork/NetworkHandler.h" -#include "sharedNetwork/SetupSharedNetwork.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "sharedObject/SetupSharedObject.h" -#include "sharedRandom/SetupSharedRandom.h" -#include "sharedThread/SetupSharedThread.h" -#include "SwgDatabaseServer/SwgDatabaseServer.h" - -#include - - -//_____________________________________________________________________ -int main(int argc, char ** argv) -{ - // command line hack - std::string cmdLine; - for(int i = 1; i < argc; ++i) - { - cmdLine += argv[i]; - if(i + 1 < argc) - { - cmdLine += " "; - } - } - - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - // -- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - - setupFoundationData.commandLine = cmdLine.c_str(); - setupFoundationData.createWindow = false; - setupFoundationData.clockUsesSleep = true; - - SetupSharedFoundation::install (setupFoundationData); - - SetupSharedFile::install(false); - SetupSharedRandom::install(int(time(NULL))); - { - SetupSharedObject::Data data; - SetupSharedObject::setupDefaultGameData(data); - SetupSharedObject::install(data); - } - - SetupSharedNetwork::SetupData networkSetupData; - SetupSharedNetwork::getDefaultServerSetupData(networkSetupData); - SetupSharedNetwork::install(networkSetupData); - - SetupSharedNetworkMessages::install(); - - SetupSharedLog::install("SwgDatabaseServer"); - - TreeFile::addSearchAbsolute(0); - TreeFile::addSearchPath(".",0); - - //-- setup server - ConfigServerDatabase::install (); - - NetworkHandler::install(); - - SwgDatabaseServer::install(); - - //-- run server - SetupSharedFoundation::callbackWithExceptionHandling(SwgDatabaseServer::runStatic); - - NetworkHandler::remove(); - SetupSharedLog::remove(); - - SetupSharedFoundation::remove(); - SetupSharedThread::remove(); - - return 0; -} - -//_____________________________________________________________________ diff --git a/game/server/application/SwgGameServer/src/win32/FirstSwgGameServer.cpp b/game/server/application/SwgGameServer/src/win32/FirstSwgGameServer.cpp deleted file mode 100755 index 9716e6e8..00000000 --- a/game/server/application/SwgGameServer/src/win32/FirstSwgGameServer.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "FirstSwgGameServer.h" diff --git a/game/server/application/SwgGameServer/src/win32/WinMain.cpp b/game/server/application/SwgGameServer/src/win32/WinMain.cpp deleted file mode 100755 index 5824ddc5..00000000 --- a/game/server/application/SwgGameServer/src/win32/WinMain.cpp +++ /dev/null @@ -1,553 +0,0 @@ -#include "FirstSwgGameServer.h" -#include "serverGame/GameServer.h" - -#include "LocalizationManager.h" -#include "serverGame/SetupServerGame.h" -#include "serverGame/ServerWorld.h" -#include "serverGame/ServerObjectTemplate.h" -#include "ServerObjectLint.h" -#include "serverPathfinding/SetupServerPathfinding.h" -#include "serverScript/SetupScript.h" -#include "serverUtility/SetupServerUtility.h" -#include "sharedDebug/SetupSharedDebug.h" -#include "sharedFile/SetupSharedFile.h" -#include "sharedFile/TreeFile.h" -#include "sharedFoundation/ConfigFile.h" -#include "sharedFoundation/ExitChain.h" -#include "sharedFoundation/FormattedString.h" -#include "sharedFoundation/Os.h" -#include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedGame/SetupSharedGame.h" -#include "sharedGame/SharedObjectTemplate.h" -#include "sharedImage/SetupSharedImage.h" -#include "sharedLog/LogManager.h" -#include "sharedLog/SetupSharedLog.h" -#include "sharedMath/SetupSharedMath.h" -#include "sharedNetwork/NetworkHandler.h" -#include "sharedNetwork/SetupSharedNetwork.h" -#include "sharedObject/SetupSharedObject.h" -#include "sharedObject/ObjectTemplateList.h" -#include "sharedRandom/SetupSharedRandom.h" -#include "sharedRegex/SetupSharedRegex.h" -#include "sharedRemoteDebugServer/SharedRemoteDebugServer.h" -#include "sharedTerrain/SetupSharedTerrain.h" -#include "sharedThread/SetupSharedThread.h" -#include "sharedUtility/SetupSharedUtility.h" -#include "sharedNetworkMessages/SetupSharedNetworkMessages.h" -#include "SwgGameServer/SwgGameServer.h" -#include "SwgGameServer/WorldSnapshotParser.h" -#include "swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h" -#include "swgServerNetworkMessages/SetupSwgServerNetworkMessages.h" - -#include -#include -#include - -#include - -#ifdef _DEBUG -#include "sharedDebug/DataLint.h" -#include "sharedDebug/PerformanceTimer.h" -#include "sharedFoundation/Os.h" -#include "sharedObject/Object.h" -#include "sharedObject/ObjectTemplate.h" - -void runDataLint(char const *responsePath); -void verifyUpdateRanges (const char* filename); -#endif // _DEBUG - -//_____________________________________________________________________ -/* -int WINAPI WinMain( - HINSTANCE hInstance, // handle to current instance - HINSTANCE hPrevInstance, // handle to previous instance - LPSTR lpCmdLine, // pointer to command line - int nCmdShow // show state of window - ) -*/ -int main(int argc, char ** argv) -{ - int i = 0; - -// UNREF(hPrevInstance); -// UNREF(nCmdShow); -//-- setup foundation - SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game); - - // command line hack - std::string cmdLine; - for(i = 1; i < argc; ++i) - { - cmdLine += argv[i]; - if(i + 1 < argc) - { - cmdLine += " "; - } - } -// setupFoundationData.hInstance = hInstance; - setupFoundationData.commandLine = cmdLine.c_str(); - setupFoundationData.createWindow = false; - setupFoundationData.clockUsesSleep = true; - - SetupSharedThread::install(); - SetupSharedDebug::install(1024); - - SetupSharedFoundation::install (setupFoundationData); - - SetupServerUtility::install(); - - SetupSharedRegex::install(); - - SetupSharedFile::install(false); - - SetupSharedNetwork::SetupData networkSetupData; - SetupSharedNetwork::getDefaultServerSetupData(networkSetupData); - SetupSharedNetwork::install(networkSetupData); - - SetupSharedMath::install(); - - SetupSharedUtility::Data setupUtilityData; - SetupSharedUtility::setupGameData (setupUtilityData); - SetupSharedUtility::install (setupUtilityData); - - SetupSharedRandom::install(int(time(NULL))); - { - SetupSharedObject::Data data; - SetupSharedObject::setupDefaultGameData(data); - // we want the SlotIdManager initialized, but we don't need the associated hardpoint names on the server. - SetupSharedObject::addSlotIdManagerData(data, false); - // we want movement table information on this server - SetupSharedObject::addMovementTableData(data); - // we want CustomizationData support on this server. - SetupSharedObject::addCustomizationSupportData(data); - // we want POB ejection point override support. - SetupSharedObject::addPobEjectionTransformData(data); - // objects should not automatically alter their children and contents - data.objectsAlterChildrenAndContents = false; - SetupSharedObject::install(data); - } - - SetupSharedLog::install(FormattedString<92>().sprintf("SwgGameServer:%d", Os::getProcessId())); - - TreeFile::addSearchAbsolute(0); - TreeFile::addSearchPath(".",0); - - SetupSharedNetworkMessages::install(); - SetupSwgServerNetworkMessages::install(); - SetupSwgSharedNetworkMessages::install(); - - SetupSharedImage::Data setupImageData; - SetupSharedImage::setupDefaultData (setupImageData); - SetupSharedImage::install (setupImageData); - - SetupSharedGame::Data setupSharedGameData; - setupSharedGameData.setUseMountValidScaleRangeTable(true); - setupSharedGameData.setUseClientCombatManagerSupport(true); - SetupSharedGame::install (setupSharedGameData); - - SetupSharedTerrain::Data setupSharedTerrainData; - SetupSharedTerrain::setupGameData (setupSharedTerrainData); - SetupSharedTerrain::install (setupSharedTerrainData); - - SetupScript::Data setupScriptData; - SetupScript::setupDefaultGameData(setupScriptData); - SetupScript::install(); - - SetupServerPathfinding::install(); - - //-- setup game server - SetupServerGame::install(); - - SharedRemoteDebugServer::install(); - - //-- setup game server - cmdLine.clear(); - // now, the real command line - for(i = 0; i < argc; ++i) - { - cmdLine += argv[i]; - if(i + 1 < argc) - { - cmdLine += " "; - } - } - - - Archive::ByteStream bs; - UNREF(bs); - - NetworkHandler::install(); - SwgGameServer::install(); - GameServer::getInstance().setCommandLine(cmdLine); - -#ifdef _DEBUG - //-- see if the game server is being run in a mode to parse the database dump to create planetary snapshot files - const char* const createWorldSnapshots = ConfigFile::getKeyString("WorldSnapshot", "createWorldSnapshots", 0); - if (createWorldSnapshots) - { - WorldSnapshotParser::createWorldSnapshots (createWorldSnapshots); - } - else - //-- see if the gameserver is to be run in a mode to scan update ranges - if (ConfigFile::getKeyBool ("SwgGameServer", "verifyUpdateRanges", false)) - { - ServerWorld::install (); - verifyUpdateRanges ("../../exe/win32/serverobjecttemplates.txt"); - ServerWorld::remove (); - } - else - if (!ConfigFile::getKeyBool("SwgGameServer/DataLint", "disable", true)) - { - runDataLint("../../exe/win32/DataLintServer.rsp"); - } - else -#endif // _DEBUG - { - //-- run game - SetupSharedFoundation::callbackWithExceptionHandling(GameServer::run); - } - - NetworkHandler::remove(); - SetupServerGame::remove(); - - SharedRemoteDebugServer::remove(); - SetupSharedLog::remove(); - SetupSharedFoundation::remove(); - SetupSharedThread::remove (); - - return 0; -} - -#ifdef _DEBUG - -void verifyUpdateRanges (const char* const filename) -{ - FILE* const infile = fopen (filename, "rt"); - if (!infile) - { - DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: response file %s could not be opened\n", filename)); - return; - } - - char serverObjectTemplateName [1024]; - while (fscanf (infile, "%s", serverObjectTemplateName) != EOF) - { - //-- does the name contain test? - if (strstr (serverObjectTemplateName, "test") != 0) - { - DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: skipping test object template %s\n", serverObjectTemplateName)); - continue; - } - - if (strstr (serverObjectTemplateName, "e3_") != 0) - { - DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: skipping test object template %s\n", serverObjectTemplateName)); - continue; - } - - //-- get the object template - const ObjectTemplate* const objectTemplate = ObjectTemplateList::fetch (serverObjectTemplateName); - if (!objectTemplate) - { - DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: %s is not a valid object template\n", serverObjectTemplateName)); - continue; - } - - //-- make sure its a server object template - const ServerObjectTemplate* const serverObjectTemplate = dynamic_cast (objectTemplate); - if (!serverObjectTemplate) - { - objectTemplate->releaseReference (); - DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: %s is not a valid server object template\n", serverObjectTemplateName)); - continue; - } - - //-- make sure it has a shared object template - const std::string& sharedObjectTemplateName = serverObjectTemplate->getSharedTemplate (); - if (sharedObjectTemplateName.empty ()) - { - objectTemplate->releaseReference (); - continue; - } - - //-- make sure the shared template exists - const SharedObjectTemplate* const sharedObjectTemplate = safe_cast (ObjectTemplateList::fetch (sharedObjectTemplateName.c_str ())); - if (!sharedObjectTemplate) - { - DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: %s is not a valid shared object template for server object template %s\n", sharedObjectTemplateName.c_str (), serverObjectTemplateName)); - objectTemplate->releaseReference (); - continue; - } - - const float farUpdateRange = serverObjectTemplate->getUpdateRanges (ServerObjectTemplate::UR_far); - DEBUG_REPORT_LOG (true, ("OK:\t%s\t%s\t%1.1f\n", serverObjectTemplateName, sharedObjectTemplateName.c_str (), farUpdateRange)); - objectTemplate->releaseReference (); - } - fclose(infile); -} - -static std::string currentLintedAsset; -static int m_startIndex = 0; -static int m_numberOfFilesToLint = -1; - -//----------------------------------------------------------------------------- -static int ExceptionHandler(LPEXCEPTION_POINTERS exceptionPointers) -{ - UNREF(exceptionPointers); - - static bool entered = false; - - // make the routine safe from re-entrance - - if (entered) - { - return EXCEPTION_CONTINUE_SEARCH; - } - - entered = true; - - // tell the Os not to abort so we can rethrow the exception - - Os::returnFromAbort(); - - // Let the ExitChain do its job - - DataLint::pushAsset(currentLintedAsset.c_str()); - FATAL(true, ("ExceptionHandler invoked - A crash just occured. The asset is bad or it is constructed improperly with DataLint.")); - DataLint::popAsset(); - - // rethrow the exception so that the debugger can catch it - - return EXCEPTION_CONTINUE_SEARCH; //lint !e527 // Unreachable -} - -//----------------------------------------------------------------------------- -static void lintType(char const *filePath, DataLint::AssetType const assetType, bool const skip) -{ - DataLint::setCurrentAssetType(assetType); - - static int assetNumber = 0; - - if (!skip) - { - DEBUG_REPORT_LOG (true, ("%5i Linting file %s... ", assetNumber, filePath)); - - bool failed = false; - - try - { - switch (assetType) - { - case DataLint::AT_objectTemplate: - { - const ObjectTemplate *objectTemplate = ObjectTemplateList::fetch(filePath); - if (objectTemplate) - { - objectTemplate->testValues(); - - // if file has the directory "base" in it's path, don't - // create an object - if (strstr(filePath, "/base/") == NULL) - { - Object* const object = objectTemplate->createObject (); - delete object; - } - - objectTemplate->releaseReference(); - } - else - { - failed = true; - } - } - break; - case DataLint::AT_unSupported: - { - } - break; - - } - - if (failed) - { - DEBUG_REPORT_LOG (true, ("failed\n")); - } - else - { - DEBUG_REPORT_LOG (true, ("ok\n")); - } - } - catch (FatalException const &e) - { - DEBUG_REPORT_LOG (true, ("failed\n")); - - DataLint::logWarning(e.getMessage()); - } - } - - ++assetNumber; -} - -//----------------------------------------------------------------------------- -static void makeMicrosoftHappyAboutObjectUnWinding(char const *filePath, DataLint::AssetType const assetType, bool const skip) -{ - __try - { - lintType(filePath, assetType, skip); - } - __except (ExceptionHandler(GetExceptionInformation())) - { - } -} - -//----------------------------------------------------------------------------- -static void lint(char const *dataTypeString, DataLint::AssetType const assetType) -{ - DataLint::StringPairList stringPairList(DataLint::getList(assetType)); - DataLint::StringPairList::const_iterator dataLintStringListIter = stringPairList.begin(); - - DEBUG_REPORT_LOG_PRINT(1, ("Linting %d %s assets\n", stringPairList.size(), dataTypeString)); - - int currentIndex = 0; - for (; dataLintStringListIter != stringPairList.end(); ++dataLintStringListIter) - { - { - if ((currentIndex % 10) == 0) - { - //-- see if a file exists to abort - - FILE *file = fopen("stoplint.dat", "rt"); - - if (file) - { - fclose(file); - DEBUG_REPORT_LOG_PRINT(1, ("Stopping all DataLint processing for %s.\n", dataTypeString)); - DataLint::logWarning("Forced DataLint stop. Delete \"stoplint.dat\" to DataLint all the assets."); - break; - } - } - } - - char const *filePath = dataLintStringListIter->first.c_str(); - currentLintedAsset = dataLintStringListIter->second.c_str(); - - //DataLint::pushAsset(filePath); - makeMicrosoftHappyAboutObjectUnWinding(filePath, assetType, (currentIndex < m_startIndex)); - //DataLint::popAsset(); - - DataLint::clearAssetStack(); - ++currentIndex; - - if ((m_numberOfFilesToLint != -1) && (currentIndex >= (m_startIndex + m_numberOfFilesToLint))) - { - break; - } - } -} - -//----------------------------------------------------------------------------- -void runDataLint(char const *responsePath) -{ - ServerObjectLint::install(); - ServerWorld::install(); - DataLint::setServerMode(); - - PerformanceTimer performanceTimer; - performanceTimer.start(); - - FILE *fp = fopen(responsePath, "r"); - - if (fp) - { - // Default to start with the first asset - - m_startIndex = ConfigFile::getKeyInt("SwgGameServer/DataLint", "startIndex", 0); - - // Default to lint all assets - - m_numberOfFilesToLint = ConfigFile::getKeyInt("SwgGameServer/DataLint", "numberOfFilesToLint", -1); - - // Verify this is a valid resonse file - - char text[4096]; - fgets(text, sizeof(text), fp); - - if (strstr(text, "Valid DataLint Rsp") == NULL) - { - DEBUG_REPORT_LOG_PRINT(1, ("DataLint: Invalid Rsp file: %s\n", responsePath)); - -#ifdef WIN32 - char text[4096]; - sprintf(text, "Invalid Rsp file specified: %s. Make sure to run DataLintRspBuilder before running DataLint.", responsePath); - MessageBox(NULL, text, "DataLint Error!", MB_OK | MB_ICONERROR); -#endif // WIN32 - } - else - { - DataLint::install(); - - typedef std::vector StringList; - StringList stringList; - stringList.reserve(32768); - - DEBUG_REPORT_LOG_PRINT(1, ("Loading assets to lint from: %s\n", responsePath)); - - while (fgets(text, sizeof(text), fp)) - { - // Remove the newline character - - char *newLineTest = strchr(text, '\n'); - - if (newLineTest) - { - *newLineTest = '\0'; - } - - // Add the files to the master file list - - stringList.push_back(text); - } - - fclose(fp); - - // Add files to data lint - - DEBUG_REPORT_LOG_PRINT(1, ("Adding %d assets to DataLint to be categorized\n", stringList.size())); - - StringList::iterator stringListIter = stringList.begin(); - - for (; stringListIter != stringList.end(); ++stringListIter) - { - DataLint::addFilePath((*stringListIter).c_str()); - } - - if (ConfigFile::getKeyBool("SwgGameServer/DataLint", "objectTemplate", true)) - { - lint("Objects Template", DataLint::AT_objectTemplate); - } - - DataLint::report(); - } - } - else - { - DEBUG_REPORT_LOG_PRINT(1, ("Bad response path specified: %s", responsePath)); - -#ifdef WIN32 - char text[4096]; - sprintf(text, "Bad response file specified: %s. Make sure to run DataLintRspBuilder before running DataLint.", responsePath); - MessageBox(NULL, text, "DataLint Error!", MB_OK | MB_ICONERROR); -#endif // WIN32 - } - - // Dump the time required to data lint - - performanceTimer.stop(); - float const dataLintTime = performanceTimer.getElapsedTime(); - int const seconds = static_cast(dataLintTime) % 60; - int const minutes = (static_cast(dataLintTime) - seconds) / 60; - DEBUG_REPORT_LOG_PRINT(1, ("DateLint took: %dm %ds\n", minutes, seconds)); -} -#endif // _DEBUG - -//_____________________________________________________________________ diff --git a/game/server/library/swgServerNetworkMessages/src/win32/FirstSwgServerNetworkMessages.cpp b/game/server/library/swgServerNetworkMessages/src/win32/FirstSwgServerNetworkMessages.cpp deleted file mode 100755 index ba4d4d4a..00000000 --- a/game/server/library/swgServerNetworkMessages/src/win32/FirstSwgServerNetworkMessages.cpp +++ /dev/null @@ -1,9 +0,0 @@ -//======================================================================== -// -// FirstSwgServerNetworkMessages.cpp -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#include "swgServerNetworkMessages/FirstSwgServerNetworkMessages.h" diff --git a/game/shared/library/swgSharedNetworkMessages/src/win32/FirstSwgSharedNetworkMessages.cpp b/game/shared/library/swgSharedNetworkMessages/src/win32/FirstSwgSharedNetworkMessages.cpp deleted file mode 100755 index c29a3b43..00000000 --- a/game/shared/library/swgSharedNetworkMessages/src/win32/FirstSwgSharedNetworkMessages.cpp +++ /dev/null @@ -1,9 +0,0 @@ -//======================================================================== -// -// FirstSwgSharedNetworkMessages.cpp -// -// copyright 2001 Sony Online Entertainment -// -//======================================================================== - -#include "swgSharedNetworkMessages/FirstSwgSharedNetworkMessages.h" diff --git a/game/shared/library/swgSharedUtility/src/win32/FirstSwgSharedUtility.cpp b/game/shared/library/swgSharedUtility/src/win32/FirstSwgSharedUtility.cpp deleted file mode 100755 index 29d94d84..00000000 --- a/game/shared/library/swgSharedUtility/src/win32/FirstSwgSharedUtility.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// ====================================================================== -// -// FirstSwgSharedUtility.cpp -// Copyright 2002 Sony Online Entertainment, Inc. -// All Rights Reserved. -// -// ====================================================================== - -#include "swgSharedUtility/FirstSwgSharedUtility.h" - -// ======================================================================