From 9e86b04b23ebe12de3b8f4f72770241ba3e071af Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Mon, 2 Feb 2026 16:57:42 +0100 Subject: [PATCH 1/5] cmake: Set CMAKE_{LIBRARY,RUNTIME}_OUTPUT_DIRECTORY as cache property Further overrides belong in CMakeUserPresets.json --- CMakeLists.txt | 12 ++---------- OniProj/OniCMakeProjs/TEVCProj/CMakeLists.txt | 10 ++-------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 530e6ca..502bbb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,16 +107,8 @@ elseif (APPLE) ) endif () -set(ONI_OUTPUT_DIR "${CMAKE_SOURCE_DIR}/Bin/") -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${ONI_OUTPUT_DIR}") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${ONI_OUTPUT_DIR}") -set(CMAKE_SHARED_LIBRARY_PREFIX "") -foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${ONI_OUTPUT_DIR}) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${ONI_OUTPUT_DIR}) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${ONI_OUTPUT_DIR}) -endforeach () +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Runtime output directory") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Library output directory") if (ONI_BINK_VIDEO) add_subdirectory(OniProj/OniCMakeProjs/BinkProj/) diff --git a/OniProj/OniCMakeProjs/TEVCProj/CMakeLists.txt b/OniProj/OniCMakeProjs/TEVCProj/CMakeLists.txt index d7ff4e3..f453823 100644 --- a/OniProj/OniCMakeProjs/TEVCProj/CMakeLists.txt +++ b/OniProj/OniCMakeProjs/TEVCProj/CMakeLists.txt @@ -45,17 +45,11 @@ if (MSVC) endif () set(TEVCWorkingDirectory "${CMAKE_SOURCE_DIR}/OniProj/OniCMakeProjs/TEVCProj") -set(TEVCProjExecutable "") -if (WIN32) - set(TEVCProjExecutable "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/TEVCProj.exe") -else () - set(TEVCProjExecutable "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/TEVCProj") -endif () -if (EXISTS "${TEVCProjExecutable}") +if (TARGET TEVCProj AND NOT CMAKE_CROSSCOMPILING) message("Found TEVCProj under output directory, attempting to update templatechecksum.c") execute_process( - COMMAND "${TEVCProjExecutable}" + COMMAND TEVCProj WORKING_DIRECTORY "${TEVCWorkingDirectory}") # check if anything was spat out From 685aa473b44a7eed95b1eb38f20ae3e0d4e1bfe8 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Mon, 2 Feb 2026 17:22:51 +0100 Subject: [PATCH 2/5] Always generate templatechecksum.c when running TemplateExtractor --- .../Common/TemplateExtractor/TE_Extract.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c index 880decf..18a0f9d 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c @@ -329,9 +329,6 @@ TErExtract( curSymbol = curSymbol->next; } - // if our total checksum has not changed then we are done - if(totalChecksum == TMgTemplateChecksum) return UUcError_None; - // If we are here then we need to output templatechecksum.c // Write out the dumpfile @@ -374,8 +371,11 @@ TErExtract( } curSymbol = curSymbol->next; } - - BFrFile_Printf(logFile, "* Templates changed"UUmNL); + + if(totalChecksum != TMgTemplateChecksum) + { + BFrFile_Printf(logFile, "* Templates changed"UUmNL); + } curSymbol = TEgSymbolList; while(curSymbol) { @@ -424,11 +424,14 @@ TErExtract( BFrFile_Close(logFile); BFrFileRef_Dispose(logFileRef); + if(totalChecksum != TMgTemplateChecksum) + { + fprintf(stderr, "*** TEMPLATE CHECKSUM CHANGED\n"); + } + TMgTemplateChecksum = totalChecksum; TMgNumTemplateDefinitions = (UUtUns32)totalChecksumFactor; - - fprintf(stderr, "*** TEMPLATE CHECKSUM CHANGED\n"); - + error = BFrFileRef_MakeFromName("templatechecksum.c", &cFileRef); UUmError_ReturnOnError(error); error = BFrFile_Open(cFileRef, "w", &cFile); From 99ca0597ed2a5d93aa10d4f39c239b97392b4a71 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Mon, 2 Feb 2026 17:31:33 +0100 Subject: [PATCH 3/5] Generate templatechecksum.c without trailing whitespace --- .../Common/TemplateExtractor/TE_Extract.c | 10 +- .../ImpConsole/templatechecksum.c | 4818 ++++++++--------- 2 files changed, 2417 insertions(+), 2411 deletions(-) diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c index 18a0f9d..e23376d 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c @@ -248,8 +248,14 @@ TEiExtract_WriteOutSwapCodes( { if(itr % 8 == 0) BFrFile_Printf(inFile, UUmNL"\t"); BFrFile_Printf(inFile, "0x%02x", *p); - - if(itr != inLength - 1) BFrFile_Printf(inFile, ", "); + + if(itr != inLength - 1) + { + BFrFile_Printf(inFile, ","); + if ((itr + 1) % 8 != 0) { + BFrFile_Printf(inFile, " "); + } + } } BFrFile_Printf(inFile, UUmNL); BFrFile_Printf(inFile, "};"UUmNL); diff --git a/OniProj/OniWin32Projs/ImpConsole/templatechecksum.c b/OniProj/OniWin32Projs/ImpConsole/templatechecksum.c index 8b14f47..de1d90f 100644 --- a/OniProj/OniWin32Projs/ImpConsole/templatechecksum.c +++ b/OniProj/OniWin32Projs/ImpConsole/templatechecksum.c @@ -1,2409 +1,2409 @@ -#include "BFW.h" -#include "BFW_TemplateManager.h" -#include "BFW_TM_Private.h" -UUtUns64 TMgTemplateChecksum = 1052091493724257; -UUtUns32 TMgNumTemplateDefinitions = 114; -TMtTemplateDefinition* TMgTemplateDefinitionArray = NULL; -static UUtUns8 gSwapCodes_AISA[74] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x05, 0x20, 0x04, 0x06, 0x03, 0x03, 0x03, 0x03, - 0x09, 0x43, 0x43, 0x4e, 0x4f, 0x05, 0x20, 0x04, - 0x06, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x04, 0x06, 0x09, 0x43, 0x57, 0x4e, 0x4f, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x05, 0x02, 0x04, 0x06, - 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AITR[22] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, - 0x05, 0x40, 0x04, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AIWA[21] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x05, - 0x02, 0x04, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AKAA[13] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ABNA[14] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AKVA[40] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AKBA[17] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, - 0x06 -}; -static UUtUns8 gSwapCodes_AKBP[13] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AKDA[23] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AKEV[101] = -{ - 0x02, 0x02, 0x09, 0x41, 0x54, 0x4e, 0x50, 0x09, - 0x41, 0x45, 0x4c, 0x50, 0x09, 0x41, 0x43, 0x58, - 0x54, 0x09, 0x47, 0x51, 0x47, 0x41, 0x09, 0x52, - 0x51, 0x47, 0x41, 0x09, 0x43, 0x51, 0x47, 0x41, - 0x09, 0x42, 0x44, 0x47, 0x41, 0x09, 0x41, 0x4d, - 0x58, 0x54, 0x09, 0x41, 0x56, 0x4b, 0x41, 0x09, - 0x41, 0x42, 0x4b, 0x41, 0x09, 0x41, 0x58, 0x44, - 0x49, 0x09, 0x41, 0x58, 0x44, 0x49, 0x09, 0x50, - 0x42, 0x4b, 0x41, 0x09, 0x41, 0x4e, 0x42, 0x41, - 0x09, 0x54, 0x4f, 0x4b, 0x41, 0x09, 0x41, 0x41, - 0x4b, 0x41, 0x09, 0x41, 0x44, 0x4b, 0x41, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_AGQC[17] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, - 0x06 -}; -static UUtUns8 gSwapCodes_AGDB[12] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AGQG[24] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x04, 0x02, 0x06, 0x05, 0x04, 0x02, 0x06, - 0x05, 0x04, 0x02, 0x06, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AGQM[7] = -{ - 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x06 -}; -static UUtUns8 gSwapCodes_AGQR[12] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x03, 0x03, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AKOT[28] = -{ - 0x02, 0x02, 0x09, 0x54, 0x49, 0x54, 0x4f, 0x09, - 0x46, 0x4c, 0x54, 0x4f, 0x09, 0x41, 0x4e, 0x54, - 0x51, 0x09, 0x41, 0x58, 0x44, 0x49, 0x09, 0x41, - 0x58, 0x44, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_OTIT[14] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x08, 0x02, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_OTLF[17] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x05, 0x06, 0x02, 0x06, 0x02, 0x02, 0x08, - 0x06 -}; -static UUtUns8 gSwapCodes_QTNA[14] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x04, 0x02, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_BINA[5] = -{ - 0x02, 0x02, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_ENVP[35] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x05, 0x40, 0x04, 0x06, 0x05, 0x30, 0x04, 0x06, - 0x05, 0x0c, 0x02, 0x06, 0x02, 0x02, 0x03, 0x03, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_FXLR[14] = -{ - 0x02, 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, - 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x06 -}; -static UUtUns8 gSwapCodes_3CLA[13] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_EDIA[16] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x02, 0x03, 0x06, 0x03, 0x03, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_M3GM[44] = -{ - 0x02, 0x02, 0x02, 0x09, 0x41, 0x54, 0x4e, 0x50, - 0x09, 0x41, 0x52, 0x43, 0x56, 0x09, 0x41, 0x52, - 0x43, 0x56, 0x09, 0x41, 0x43, 0x58, 0x54, 0x09, - 0x41, 0x58, 0x44, 0x49, 0x09, 0x41, 0x58, 0x44, - 0x49, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x00, - 0x00, 0x00, 0x00, 0x06 -}; -static UUtUns8 gSwapCodes_GMAN[22] = -{ - 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x03, 0x03, - 0x03, 0x05, 0x02, 0x04, 0x06, 0x07, 0x02, 0x09, - 0x4d, 0x47, 0x33, 0x4d, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_M3GA[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_PLEA[14] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_PNTA[23] = -{ - 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x07, 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_QUDA[14] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x04, 0x02, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TXCA[12] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TXMP[30] = -{ - 0x02, 0x02, 0x05, 0x80, 0x04, 0x06, 0x02, 0x03, - 0x03, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x09, - 0x50, 0x4d, 0x58, 0x54, 0x02, 0x02, 0x02, 0x02, - 0x04, 0x05, 0x03, 0x04, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_TXAN[22] = -{ - 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x03, 0x03, - 0x03, 0x05, 0x02, 0x04, 0x06, 0x07, 0x02, 0x09, - 0x50, 0x4d, 0x58, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TXMA[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x09, 0x50, 0x4d, 0x58, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TXMB[20] = -{ - 0x02, 0x02, 0x05, 0x08, 0x04, 0x06, 0x03, 0x03, - 0x02, 0x03, 0x03, 0x07, 0x02, 0x09, 0x50, 0x4d, - 0x58, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TXPC[14] = -{ - 0x02, 0x02, 0x05, 0x08, 0x04, 0x06, 0x02, 0x02, - 0x02, 0x07, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_M3TA[14] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x03, 0x02, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_VCRA[13] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_Impt[15] = -{ - 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x03, 0x04, - 0x06, 0x09, 0x00, 0x00, 0x00, 0x00, 0x06 -}; -static UUtUns8 gSwapCodes_Mtrl[15] = -{ - 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x03, 0x04, - 0x06, 0x09, 0x00, 0x00, 0x00, 0x00, 0x06 -}; -static UUtUns8 gSwapCodes_NMSA[14] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_CONS[33] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x09, 0x41, 0x47, 0x46, 0x4f, 0x09, 0x4d, - 0x47, 0x33, 0x4d, 0x02, 0x05, 0x20, 0x04, 0x06, - 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, - 0x06 -}; -static UUtUns8 gSwapCodes_DOOR[30] = -{ - 0x02, 0x02, 0x05, 0x02, 0x09, 0x41, 0x47, 0x46, - 0x4f, 0x06, 0x09, 0x4e, 0x41, 0x42, 0x4f, 0x02, - 0x02, 0x02, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, - 0x20, 0x04, 0x06, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_OFGA[26] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x09, 0x50, - 0x56, 0x4e, 0x45, 0x07, 0x02, 0x02, 0x09, 0x4d, - 0x47, 0x33, 0x4d, 0x09, 0x53, 0x4c, 0x42, 0x4f, - 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_OBLS[12] = -{ - 0x02, 0x02, 0x02, 0x02, 0x05, 0x03, 0x02, 0x06, - 0x02, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_TRIG[39] = -{ - 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x09, - 0x4d, 0x47, 0x33, 0x4d, 0x09, 0x53, 0x4c, 0x42, - 0x4f, 0x02, 0x09, 0x45, 0x47, 0x52, 0x54, 0x09, - 0x4e, 0x41, 0x42, 0x4f, 0x05, 0x20, 0x04, 0x06, - 0x05, 0x20, 0x04, 0x06, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_TRGE[15] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_TURR[123] = -{ - 0x02, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x04, 0x06, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x05, 0x02, 0x04, 0x06, 0x02, - 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x09, 0x53, 0x4c, - 0x42, 0x4f, 0x02, 0x09, 0x4d, 0x47, 0x33, 0x4d, - 0x02, 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x10, 0x05, - 0x10, 0x04, 0x06, 0x02, 0x03, 0x03, 0x05, 0x0c, - 0x02, 0x06, 0x05, 0x04, 0x04, 0x06, 0x06, 0x02, - 0x05, 0x0c, 0x02, 0x06, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x20, 0x04, - 0x06, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_OBAN[30] = -{ - 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x02, 0x05, - 0x0c, 0x02, 0x06, 0x05, 0x0c, 0x02, 0x06, 0x03, - 0x03, 0x03, 0x07, 0x03, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_OBDC[23] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x03, 0x03, 0x09, 0x4e, 0x41, 0x42, 0x4f, 0x03, - 0x03, 0x02, 0x03, 0x03, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_OBOA[50] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x09, 0x41, 0x47, 0x33, 0x4d, 0x09, 0x4e, 0x41, - 0x42, 0x4f, 0x09, 0x50, 0x56, 0x4e, 0x45, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x05, 0x0c, 0x02, 0x06, - 0x05, 0x40, 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, - 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_CBPI[27] = -{ - 0x02, 0x02, 0x05, 0x13, 0x09, 0x74, 0x70, 0x6d, - 0x49, 0x06, 0x05, 0x13, 0x09, 0x74, 0x70, 0x6d, - 0x49, 0x06, 0x05, 0x13, 0x09, 0x74, 0x70, 0x6d, - 0x49, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_CBPM[11] = -{ - 0x02, 0x02, 0x05, 0x13, 0x09, 0x6c, 0x72, 0x74, - 0x4d, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_ONCC[233] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, - 0x03, 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, - 0x04, 0x04, 0x05, 0x02, 0x04, 0x06, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x03, 0x05, 0x02, 0x04, - 0x06, 0x05, 0x05, 0x02, 0x06, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x04, 0x05, 0x01, 0x04, 0x06, 0x02, 0x05, 0x20, - 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x05, 0x0d, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, - 0x03, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x03, 0x03, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x02, - 0x04, 0x06, 0x05, 0xff, 0x04, 0x06, 0x05, 0x41, - 0x04, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x09, 0x56, 0x43, 0x4e, 0x4f, 0x09, 0x50, 0x43, - 0x4e, 0x4f, 0x09, 0x41, 0x49, 0x4e, 0x4f, 0x04, - 0x04, 0x03, 0x05, 0x10, 0x04, 0x06, 0x05, 0x0f, - 0x05, 0x80, 0x04, 0x06, 0x03, 0x06, 0x05, 0x02, - 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, 0x02, 0x02, - 0x09, 0x53, 0x42, 0x52, 0x54, 0x09, 0x41, 0x4d, - 0x52, 0x54, 0x09, 0x4d, 0x50, 0x42, 0x43, 0x09, - 0x49, 0x50, 0x42, 0x43, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x05, 0x07, 0x02, 0x06, 0x02, - 0x09, 0x43, 0x41, 0x52, 0x54, 0x09, 0x43, 0x53, - 0x52, 0x54, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, - 0x06 -}; -static UUtUns8 gSwapCodes_ONIA[29] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x04, 0x05, - 0x03, 0x04, 0x06, 0x07, 0x02, 0x05, 0x10, 0x04, - 0x06, 0x05, 0x80, 0x04, 0x06, 0x05, 0x10, 0x04, - 0x06, 0x03, 0x03, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONCP[29] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x04, 0x05, - 0x03, 0x04, 0x06, 0x07, 0x02, 0x05, 0x10, 0x04, - 0x06, 0x05, 0x40, 0x04, 0x06, 0x03, 0x05, 0x02, - 0x04, 0x06, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONCV[16] = -{ - 0x02, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x05, - 0x20, 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_CRSA[38] = -{ - 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x02, 0x02, - 0x07, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x02, 0x06, 0x09, 0x43, 0x43, 0x4e, 0x4f, 0x05, - 0x13, 0x05, 0x0c, 0x02, 0x06, 0x06, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_DPge[19] = -{ - 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x03, 0x04, - 0x06, 0x05, 0x0c, 0x02, 0x06, 0x09, 0x47, 0x50, - 0x47, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_FILM[34] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x05, 0x02, 0x09, 0x4d, 0x41, 0x52, - 0x54, 0x06, 0x05, 0x0c, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x01, 0x02, 0x05, 0x04, 0x04, 0x06, - 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONFA[22] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x03, 0x07, - 0x03, 0x05, 0x0c, 0x02, 0x06, 0x02, 0x02, 0x02, - 0x02, 0x03, 0x04, 0x04, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONGS[107] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x05, 0x10, 0x02, 0x06, 0x05, 0x10, 0x02, 0x06, - 0x05, 0xff, 0x04, 0x06, 0x05, 0xff, 0x04, 0x06, - 0x05, 0xff, 0x04, 0x06, 0x05, 0x83, 0x04, 0x06, - 0x05, 0xff, 0x04, 0x06, 0x05, 0xff, 0x04, 0x06, - 0x05, 0xff, 0x04, 0x06, 0x05, 0x83, 0x04, 0x06, - 0x05, 0x0e, 0x02, 0x06, 0x05, 0xff, 0x04, 0x06, - 0x05, 0xff, 0x04, 0x06, 0x05, 0x42, 0x04, 0x06, - 0x05, 0xa0, 0x04, 0x06, 0x05, 0x03, 0x02, 0x06, - 0x05, 0x03, 0x02, 0x06, 0x05, 0x03, 0x02, 0x06, - 0x05, 0x03, 0x02, 0x06, 0x05, 0x03, 0x02, 0x06, - 0x05, 0x03, 0x02, 0x06, 0x02, 0x05, 0x10, 0x05, - 0x20, 0x04, 0x06, 0x03, 0x03, 0x05, 0x20, 0x04, - 0x06, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_HPge[13] = -{ - 0x02, 0x02, 0x05, 0x02, 0x04, 0x06, 0x03, 0x09, - 0x47, 0x50, 0x47, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_IGHH[32] = -{ - 0x02, 0x02, 0x05, 0x1c, 0x04, 0x06, 0x09, 0x50, - 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, - 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x07, 0x02, - 0x05, 0x40, 0x04, 0x06, 0x03, 0x03, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_IGPG[27] = -{ - 0x02, 0x02, 0x09, 0x46, 0x46, 0x53, 0x54, 0x02, - 0x02, 0x03, 0x03, 0x09, 0x00, 0x00, 0x00, 0x00, - 0x09, 0x41, 0x53, 0x47, 0x49, 0x09, 0x41, 0x53, - 0x47, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_IGPA[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x09, 0x47, 0x50, 0x47, 0x49, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_IGSt[20] = -{ - 0x02, 0x02, 0x09, 0x46, 0x46, 0x53, 0x54, 0x02, - 0x02, 0x03, 0x03, 0x05, 0xff, 0x04, 0x06, 0x05, - 0x81, 0x04, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_IGSA[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x09, 0x74, 0x53, 0x47, 0x49, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_IPge[9] = -{ - 0x02, 0x02, 0x02, 0x09, 0x47, 0x50, 0x47, 0x49, - 0x06 -}; -static UUtUns8 gSwapCodes_KeyI[53] = -{ - 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, - 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, - 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, - 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, - 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, - 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, - 0x50, 0x4d, 0x58, 0x54, 0x06 -}; -static UUtUns8 gSwapCodes_ONLV[82] = -{ - 0x02, 0x02, 0x05, 0x40, 0x04, 0x06, 0x09, 0x56, - 0x45, 0x4b, 0x41, 0x09, 0x41, 0x4f, 0x42, 0x4f, - 0x09, 0x41, 0x4d, 0x4e, 0x4f, 0x09, 0x41, 0x46, - 0x4e, 0x4f, 0x09, 0x41, 0x54, 0x4e, 0x4f, 0x09, - 0x4b, 0x53, 0x4e, 0x4f, 0x02, 0x09, 0x41, 0x53, - 0x49, 0x41, 0x09, 0x52, 0x54, 0x49, 0x41, 0x09, - 0x41, 0x53, 0x4e, 0x4f, 0x09, 0x43, 0x44, 0x42, - 0x4f, 0x09, 0x41, 0x4f, 0x4e, 0x4f, 0x09, 0x50, - 0x56, 0x4e, 0x45, 0x02, 0x05, 0x20, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x06, 0x09, 0x41, 0x53, 0x52, - 0x43, 0x06 -}; -static UUtUns8 gSwapCodes_ONLD[9] = -{ - 0x02, 0x02, 0x03, 0x03, 0x05, 0x40, 0x04, 0x06, - 0x06 -}; -static UUtUns8 gSwapCodes_ONMA[20] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x05, 0x40, 0x04, 0x06, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONOA[16] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x09, 0x41, 0x58, 0x44, 0x49, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_OPge[13] = -{ - 0x02, 0x02, 0x05, 0x02, 0x04, 0x06, 0x03, 0x09, - 0x41, 0x50, 0x47, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_ONSK[55] = -{ - 0x02, 0x02, 0x05, 0x06, 0x09, 0x50, 0x4d, 0x58, - 0x54, 0x06, 0x05, 0x08, 0x09, 0x50, 0x4d, 0x58, - 0x54, 0x06, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x05, - 0x05, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x06, 0x02, - 0x02, 0x05, 0x08, 0x02, 0x06, 0x05, 0x08, 0x02, - 0x06, 0x05, 0x08, 0x02, 0x06, 0x05, 0x08, 0x02, - 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_ONSA[11] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x03, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TxtC[8] = -{ - 0x02, 0x02, 0x09, 0x41, 0x50, 0x47, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_ONTA[52] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x02, 0x07, - 0x02, 0x05, 0x08, 0x02, 0x02, 0x02, 0x06, 0x05, - 0x06, 0x05, 0x04, 0x02, 0x06, 0x06, 0x05, 0x06, - 0x02, 0x02, 0x02, 0x06, 0x05, 0x06, 0x02, 0x02, - 0x02, 0x02, 0x06, 0x05, 0x06, 0x03, 0x06, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONVL[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x09, 0x56, 0x43, 0x4e, 0x4f, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_WPge[13] = -{ - 0x02, 0x02, 0x09, 0x43, 0x57, 0x4e, 0x4f, 0x09, - 0x47, 0x50, 0x47, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_OSBD[5] = -{ - 0x02, 0x02, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_PSpc[18] = -{ - 0x02, 0x02, 0x05, 0x09, 0x03, 0x03, 0x06, 0x05, - 0x09, 0x03, 0x03, 0x06, 0x09, 0x00, 0x00, 0x00, - 0x00, 0x06 -}; -static UUtUns8 gSwapCodes_PSpL[16] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_PSUI[223] = -{ - 0x02, 0x02, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, - 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, - 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, - 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, - 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, - 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, - 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, - 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, - 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, - 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, - 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, - 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, - 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, - 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, - 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, - 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, - 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, - 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, - 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, - 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, - 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, - 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, - 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, - 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, - 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, - 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, - 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, - 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x06 -}; -static UUtUns8 gSwapCodes_SNDD[8] = -{ - 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_SUBT[12] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x02, 0x07, - 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_UUEA[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x7e, 0x04, 0x06, 0x03, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TMFA[11] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_IDXA[11] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TStr[7] = -{ - 0x02, 0x02, 0x05, 0x80, 0x04, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_StNA[15] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x09, 0x72, 0x74, 0x53, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TMRA[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x09, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRAS[16] = -{ - 0x02, 0x02, 0x09, 0x4d, 0x41, 0x52, 0x54, 0x02, - 0x02, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x06 -}; -static UUtUns8 gSwapCodes_TRAM[94] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x05, 0x02, 0x09, 0x4d, 0x41, 0x52, 0x54, 0x06, - 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, - 0x05, 0x24, 0x02, 0x06, 0x03, 0x04, 0x04, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x04, - 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x03, - 0x03, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x04, 0x06 -}; -static UUtUns8 gSwapCodes_TRAC[24] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x09, 0x43, - 0x41, 0x52, 0x54, 0x03, 0x07, 0x03, 0x03, 0x03, - 0x02, 0x09, 0x4d, 0x41, 0x52, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRCM[31] = -{ - 0x02, 0x02, 0x02, 0x03, 0x05, 0x02, 0x04, 0x06, - 0x05, 0x40, 0x04, 0x06, 0x02, 0x02, 0x02, 0x09, - 0x41, 0x47, 0x52, 0x54, 0x09, 0x41, 0x54, 0x52, - 0x54, 0x09, 0x41, 0x49, 0x52, 0x54, 0x06 -}; -static UUtUns8 gSwapCodes_TRBS[11] = -{ - 0x02, 0x02, 0x05, 0x05, 0x09, 0x4d, 0x43, 0x52, - 0x54, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_TRMA[15] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x09, 0x50, 0x4d, 0x58, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRFT[11] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRGA[15] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRIA[14] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x04, 0x04, 0x04, 0x04, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRSC[15] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x09, 0x53, 0x41, 0x52, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRTA[13] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TSFT[33] = -{ - 0x02, 0x02, 0x05, 0x06, 0x04, 0x06, 0x03, 0x02, - 0x03, 0x03, 0x03, 0x03, 0x05, 0xff, 0x09, 0x41, - 0x47, 0x53, 0x54, 0x06, 0x05, 0x01, 0x09, 0x41, - 0x47, 0x53, 0x54, 0x06, 0x07, 0x02, 0x02, 0x08, - 0x06 -}; -static UUtUns8 gSwapCodes_TSFF[20] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x09, 0x4c, - 0x46, 0x53, 0x54, 0x07, 0x02, 0x09, 0x54, 0x46, - 0x53, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TSFL[23] = -{ - 0x02, 0x02, 0x05, 0x40, 0x04, 0x06, 0x05, 0x40, - 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, 0x05, 0x40, - 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_TSGA[25] = -{ - 0x02, 0x02, 0x05, 0xff, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x02, 0x02, 0x06, 0x05, 0x01, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x06, - 0x06 -}; -static UUtUns8 gSwapCodes_UVDL[19] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x02, 0x07, - 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, 0x04, - 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_WMCL[16] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_WMDD[50] = -{ - 0x02, 0x02, 0x05, 0xff, 0x04, 0x06, 0x05, 0x01, - 0x04, 0x06, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, - 0x03, 0x03, 0x07, 0x02, 0x05, 0xff, 0x04, 0x06, - 0x05, 0x01, 0x04, 0x06, 0x03, 0x03, 0x02, 0x02, - 0x03, 0x03, 0x03, 0x03, 0x09, 0x46, 0x46, 0x53, - 0x54, 0x02, 0x02, 0x05, 0x02, 0x04, 0x06, 0x03, - 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_WMMB[16] = -{ - 0x02, 0x02, 0x05, 0x12, 0x04, 0x06, 0x03, 0x07, - 0x02, 0x09, 0x5f, 0x4d, 0x4d, 0x57, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_WMM_[21] = -{ - 0x02, 0x02, 0x05, 0x12, 0x04, 0x06, 0x03, 0x05, - 0x40, 0x04, 0x06, 0x07, 0x02, 0x03, 0x03, 0x05, - 0x40, 0x04, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONWC[175] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x02, - 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x02, 0x02, - 0x09, 0x50, 0x4d, 0x58, 0x54, 0x02, 0x02, 0x02, - 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, - 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, - 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x05, 0x20, 0x04, - 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x02, 0x02, 0x05, 0x0c, 0x02, 0x06, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x0c, 0x02, - 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x10, 0x05, - 0x0c, 0x02, 0x06, 0x05, 0x10, 0x04, 0x06, 0x02, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06, 0x05, - 0x20, 0x04, 0x06, 0x02, 0x09, 0x50, 0x4d, 0x58, - 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x05, 0x02, - 0x02, 0x06, 0x02, 0x02, 0x02, 0x02, 0x06 -}; -static TMtTemplateDefinition TMgTemplateDefinitionArray_Mem[114] = -{ - // #0 - { - 180964060137, - 0x41495341, - "AI Character Setup Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x160, - NULL, - 0x4d41474b, - NULL, - }, - // #1 - { - 1763925, - 0x41495452, - "AI script trigger array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x54, - NULL, - 0x4d41474b, - NULL, - }, - // #2 - { - 1081091, - 0x41495741, - "AI Imported Waypoint Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x1c, - NULL, - 0x4d41474b, - NULL, - }, - // #3 - { - 1171063, - 0x414b4141, - "Adjacency Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #4 - { - 1207712, - 0x41424e41, - "bsp tree node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x10, - NULL, - 0x4d41474b, - NULL, - }, - // #5 - { - 14616032, - 0x414b5641, - "BNV Node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x74, - NULL, - 0x4d41474b, - NULL, - }, - // #6 - { - 3811460, - 0x414b4241, - "Side Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x1c, - NULL, - 0x4d41474b, - NULL, - }, - // #7 - { - 848969, - 0x414b4250, - "BSP node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #8 - { - 3036260, - 0x414b4441, - "Door Frame Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x34, - NULL, - 0x4d41474b, - NULL, - }, - // #9 - { - 584922226293, - 0x414b4556, - "Akira Environment", - NULL, - (TMtTemplateFlags)0x4, - 0x80, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #10 - { - 1887121, - 0x41475143, - "Gunk Quad Collision Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x1c, - NULL, - 0x4d41474b, - NULL, - }, - // #11 - { - 470551, - 0x41474442, - "Gunk Quad Debug Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x8, - NULL, - 0x4d41474b, - NULL, - }, - // #12 - { - 1835986, - 0x41475147, - "Gunk Quad General Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x38, - NULL, - 0x4d41474b, - NULL, - }, - // #13 - { - 281254, - 0x4147514d, - "Gunk Quad Material", - NULL, - (TMtTemplateFlags)0x6, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #14 - { - 539195, - 0x41475152, - "Gunk Quad Render Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #15 - { - 76902095368, - 0x414b4f54, - "Oct tree", - NULL, - (TMtTemplateFlags)0x4, - 0x1c, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #16 - { - 676306, - 0x4f544954, - "Oct tree interior node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x20, - NULL, - 0x4d41474b, - NULL, - }, - // #17 - { - 2010123, - 0x4f544c46, - "Oct tree leaf node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x24, - NULL, - 0x4d41474b, - NULL, - }, - // #18 - { - 421580, - 0x51544e41, - "Quad tree node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x10, - NULL, - 0x4d41474b, - NULL, - }, - // #19 - { - 89617, - 0x42494e41, - "Binary Data", - NULL, - (TMtTemplateFlags)0x6, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #20 - { - 6799811, - 0x454e5650, - "Env Particle Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xd0, - NULL, - 0x4d41474b, - NULL, - }, - // #21 - { - 28278257833, - 0x46584c52, - "FX Laser effect", - NULL, - (TMtTemplateFlags)0x4, - 0x14, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #22 - { - 321214, - 0x33434c41, - "RGB Color Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #23 - { - 505591, - 0x45444941, - "Edge Index Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x8, - NULL, - 0x4d41474b, - NULL, - }, - // #24 - { - 170196001846, - 0x4d33474d, - "Geometry", - NULL, - (TMtTemplateFlags)0x4, - 0x2c, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #25 - { - 41447257509, - 0x474d414e, - "Geometry Animation", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #26 - { - 22018728114, - 0x4d334741, - "GeometryArray", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #27 - { - 506936, - 0x504c4541, - "Plane Equation Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x10, - NULL, - 0x4d41474b, - NULL, - }, - // #28 - { - 3630956, - 0x504e5441, - "3D Point Array", - NULL, - (TMtTemplateFlags)0x6, - 0x40, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #29 - { - 220778, - 0x51554441, - "Quad array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x10, - NULL, - 0x4d41474b, - NULL, - }, - // #30 - { - 594970, - 0x54584341, - "Texture Coordinate Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x8, - NULL, - 0x4d41474b, - NULL, - }, - // #31 - { - 36794461023, - 0x54584d50, - "Texture Map", - NULL, - (TMtTemplateFlags)0x4, - 0xb0, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #32 - { - 45282968455, - 0x5458414e, - "Texture Map Animation", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #33 - { - 24056332176, - 0x54584d41, - "Texture map array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #34 - { - 45283174994, - 0x54584d42, - "Texture Map Big", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #35 - { - 763774, - 0x54585043, - "Texture Procedure Data", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #36 - { - 194497, - 0x4d335441, - "Triangle array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #37 - { - 345913, - 0x56435241, - "3D Vector Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #38 - { - 282390, - 0x496d7074, - "Impact", - NULL, - (TMtTemplateFlags)0x4, - 0x14, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #39 - { - 167437, - 0x4d74726c, - "Material", - NULL, - (TMtTemplateFlags)0x4, - 0x14, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #40 - { - 788892, - 0x4e4d5341, - "Network Spawn Point Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x10, - NULL, - 0x4d41474b, - NULL, - }, - // #41 - { - 85270924253, - 0x434f4e53, - "Console", - NULL, - (TMtTemplateFlags)0x4, - 0x90, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #42 - { - 26599423335, - 0x444f4f52, - "Door", - NULL, - (TMtTemplateFlags)0x4, - 0x6c, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #43 - { - 83566969698, - 0x4f464741, - "Object Furn Geom Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #44 - { - 749629, - 0x4f424c53, - "Object LS Data", - NULL, - (TMtTemplateFlags)0x6, - 0x28, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #45 - { - 145438592300, - 0x54524947, - "Trigger", - NULL, - (TMtTemplateFlags)0x4, - 0x74, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #46 - { - 36266490172, - 0x54524745, - "Trigger Emitter", - NULL, - (TMtTemplateFlags)0x4, - 0x28, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #47 - { - 316893824446, - 0x54555252, - "Turret", - NULL, - (TMtTemplateFlags)0x4, - 0x648, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #48 - { - 5114916, - 0x4f42414e, - "Object animation", - NULL, - (TMtTemplateFlags)0x6, - 0x80, - 0x20, - NULL, - 0x4d41474b, - NULL, - }, - // #49 - { - 33246071307, - 0x4f424443, - "Door class array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x18, - NULL, - 0x4d41474b, - NULL, - }, - // #50 - { - 82938791649, - 0x4f424f41, - "Starting Object Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0xf0, - NULL, - 0x4d41474b, - NULL, - }, - // #51 - { - 51740530370, - 0x43425049, - "Character Body Part Impacts", - NULL, - (TMtTemplateFlags)0x4, - 0xec, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #52 - { - 10395858207, - 0x4342504d, - "Character Body Part Material", - NULL, - (TMtTemplateFlags)0x4, - 0x54, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #53 - { - 5109581306351, - 0x4f4e4343, - "Oni Character Class", - NULL, - (TMtTemplateFlags)0x4, - 0xc98, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #54 - { - 2830234, - 0x4f4e4941, - "Oni Character Impact Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xa4, - NULL, - 0x4d41474b, - NULL, - }, - // #55 - { - 3109665, - 0x4f4e4350, - "Oni Character Particle Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x58, - NULL, - 0x4d41474b, - NULL, - }, - // #56 - { - 170485, - 0x4f4e4356, - "Oni Character Variant", - NULL, - (TMtTemplateFlags)0x4, - 0x4c, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #57 - { - 51896374476, - 0x43525341, - "Corpse Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x44c, - NULL, - 0x4d41474b, - NULL, - }, - // #58 - { - 33194403947, - 0x44506765, - "Diary Page", - NULL, - (TMtTemplateFlags)0x4, - 0x44, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #59 - { - 48102073005, - 0x46494c4d, - "Film", - NULL, - (TMtTemplateFlags)0x4, - 0x40, - 0x18, - NULL, - 0x4d41474b, - NULL, - }, - // #60 - { - 1772775, - 0x4f4e4641, - "Imported Flag Node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x44, - NULL, - 0x4d41474b, - NULL, - }, - // #61 - { - 36105142, - 0x4f4e4753, - "Oni Game Settings", - NULL, - (TMtTemplateFlags)0x6, - 0xf44, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #62 - { - 18441269563, - 0x48506765, - "Help Page", - NULL, - (TMtTemplateFlags)0x4, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #63 - { - 38211049694, - 0x49474848, - "IGUI HUD Help", - NULL, - (TMtTemplateFlags)0x4, - 0x40, - 0x44, - NULL, - 0x4d41474b, - NULL, - }, - // #64 - { - 76477335677, - 0x49475047, - "IGUI Page", - NULL, - (TMtTemplateFlags)0x4, - 0x24, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #65 - { - 20900088069, - 0x49475041, - "IGUI Page Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #66 - { - 11318621989, - 0x49475374, - "IGUI String", - NULL, - (TMtTemplateFlags)0x4, - 0x198, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #67 - { - 20900127752, - 0x49475341, - "IGUI String Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #68 - { - 11064797626, - 0x49506765, - "Item Page", - NULL, - (TMtTemplateFlags)0x4, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #69 - { - 275939547053, - 0x4b657949, - "Key Icons", - NULL, - (TMtTemplateFlags)0x4, - 0x30, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #70 - { - 539951247011, - 0x4f4e4c56, - "Oni Game Level", - NULL, - (TMtTemplateFlags)0x4, - 0x304, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #71 - { - 266913, - 0x4f4e4c44, - "Oni Game Level Descriptor", - NULL, - (TMtTemplateFlags)0x6, - 0x4c, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #72 - { - 1197945, - 0x4f4e4d41, - "Imported Marker Node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x58, - NULL, - 0x4d41474b, - NULL, - }, - // #73 - { - 27043257468, - 0x4f4e4f41, - "Object Gunk Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x8, - NULL, - 0x4d41474b, - NULL, - }, - // #74 - { - 18441354235, - 0x4f506765, - "Objective Page", - NULL, - (TMtTemplateFlags)0x4, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #75 - { - 89156620391, - 0x4f4e534b, - "Oni Sky class", - NULL, - (TMtTemplateFlags)0x4, - 0xf4, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #76 - { - 280116, - 0x4f4e5341, - "Imported Spawn Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x2, - NULL, - 0x4d41474b, - NULL, - }, - // #77 - { - 7376505639, - 0x54787443, - "Text Console", - NULL, - (TMtTemplateFlags)0x4, - 0xc, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #78 - { - 10550464, - 0x4f4e5441, - "Trigger Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x1a0, - NULL, - 0x4d41474b, - NULL, - }, - // #79 - { - 22619145610, - 0x4f4e564c, - "Oni Variant List", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #80 - { - 19047942581, - 0x57506765, - "Weapon Page", - NULL, - (TMtTemplateFlags)0x4, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #81 - { - 89660, - 0x4f534244, - "Oni Sound Binary Data", - NULL, - (TMtTemplateFlags)0x6, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #82 - { - 534088, - 0x50537063, - "Part Specification", - NULL, - (TMtTemplateFlags)0x4, - 0x54, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #83 - { - 838661, - 0x5053704c, - "Part Specification List", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x8, - NULL, - 0x4d41474b, - NULL, - }, - // #84 - { - 4180417615611, - 0x50535549, - "Part Specifications UI", - NULL, - (TMtTemplateFlags)0x4, - 0xb8, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #85 - { - 266731, - 0x534e4444, - "Sound Data", - NULL, - (TMtTemplateFlags)0x6, - 0x18, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #86 - { - 289896, - 0x53554254, - "Subtitle Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #87 - { - 716476, - 0x55554541, - "Error Binding Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x80, - NULL, - 0x4d41474b, - NULL, - }, - // #88 - { - 152356, - 0x544d4641, - "Float Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #89 - { - 159887, - 0x49445841, - "Index Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #90 - { - 25760, - 0x54537472, - "String", - NULL, - (TMtTemplateFlags)0x6, - 0x88, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #91 - { - 24050971936, - 0x53744e41, - "String Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #92 - { - 472353, - 0x544d5241, - "Template Reference Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #93 - { - 8491477296, - 0x54524153, - "Totoro Aiming Screen", - NULL, - (TMtTemplateFlags)0x4, - 0x24, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #94 - { - 70837389592, - 0x5452414d, - "Totoro Animation Sequence", - NULL, - (TMtTemplateFlags)0x4, - 0x188, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #95 - { - 65077377839, - 0x54524143, - "Animation Collection", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #96 - { - 152787879246, - 0x5452434d, - "Totoro Quaternion Body", - NULL, - (TMtTemplateFlags)0x4, - 0x68, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #97 - { - 11317428793, - 0x54524253, - "Totoro Body Set", - NULL, - (TMtTemplateFlags)0x4, - 0x1c, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #98 - { - 24056327511, - 0x54524d41, - "Texture Map Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #99 - { - 139695, - 0x54524654, - "Totoro Facing Table", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #100 - { - 22018728184, - 0x54524741, - "Totoro Quaternion Body Geometry Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #101 - { - 705666, - 0x54524941, - "Totoro Quaternion Body Index Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #102 - { - 24049642263, - 0x54525343, - "Screen (aiming) Collection", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #103 - { - 481768, - 0x54525441, - "Totoro Quaternion Body Translation Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #104 - { - 97619402474, - 0x54534654, - "Font", - NULL, - (TMtTemplateFlags)0x4, - 0x420, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #105 - { - 45272025226, - 0x54534646, - "Font Family", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #106 - { - 581161, - 0x5453464c, - "Font Language", - NULL, - (TMtTemplateFlags)0x6, - 0x148, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #107 - { - 2772632, - 0x54534741, - "Glyph Array", - NULL, - (TMtTemplateFlags)0x6, - 0x1408, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #108 - { - 661221, - 0x5556444c, - "UV Data List", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x40, - NULL, - 0x4d41474b, - NULL, - }, - // #109 - { - 643190, - 0x574d434c, - "WM Cursor List", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x8, - NULL, - 0x4d41474b, - NULL, - }, - // #110 - { - 120261047236, - 0x574d4444, - "WM Dialog Data", - NULL, - (TMtTemplateFlags)0x0, - 0x120, - 0x124, - NULL, - 0x4d41474b, - NULL, - }, - // #111 - { - 29293831991, - 0x574d4d42, - "WM Menu Bar", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #112 - { - 793144, - 0x574d4d5f, - "WM Menu", - NULL, - (TMtTemplateFlags)0x6, - 0x60, - 0x44, - NULL, - 0x4d41474b, - NULL, - }, - // #113 - { - 1733621247669, - 0x4f4e5743, - "Oni Weapon Class", - NULL, - (TMtTemplateFlags)0x4, - 0x71c, - 0x0, - NULL, - 0x4d41474b, - NULL, - } -}; -void -TMrTemplate_BuildList( - void) -{ - TMgTemplateDefinitionArray_Mem[0].swapCodes = gSwapCodes_AISA; - TMgTemplateDefinitionArray_Mem[1].swapCodes = gSwapCodes_AITR; - TMgTemplateDefinitionArray_Mem[2].swapCodes = gSwapCodes_AIWA; - TMgTemplateDefinitionArray_Mem[3].swapCodes = gSwapCodes_AKAA; - TMgTemplateDefinitionArray_Mem[4].swapCodes = gSwapCodes_ABNA; - TMgTemplateDefinitionArray_Mem[5].swapCodes = gSwapCodes_AKVA; - TMgTemplateDefinitionArray_Mem[6].swapCodes = gSwapCodes_AKBA; - TMgTemplateDefinitionArray_Mem[7].swapCodes = gSwapCodes_AKBP; - TMgTemplateDefinitionArray_Mem[8].swapCodes = gSwapCodes_AKDA; - TMgTemplateDefinitionArray_Mem[9].swapCodes = gSwapCodes_AKEV; - TMgTemplateDefinitionArray_Mem[10].swapCodes = gSwapCodes_AGQC; - TMgTemplateDefinitionArray_Mem[11].swapCodes = gSwapCodes_AGDB; - TMgTemplateDefinitionArray_Mem[12].swapCodes = gSwapCodes_AGQG; - TMgTemplateDefinitionArray_Mem[13].swapCodes = gSwapCodes_AGQM; - TMgTemplateDefinitionArray_Mem[14].swapCodes = gSwapCodes_AGQR; - TMgTemplateDefinitionArray_Mem[15].swapCodes = gSwapCodes_AKOT; - TMgTemplateDefinitionArray_Mem[16].swapCodes = gSwapCodes_OTIT; - TMgTemplateDefinitionArray_Mem[17].swapCodes = gSwapCodes_OTLF; - TMgTemplateDefinitionArray_Mem[18].swapCodes = gSwapCodes_QTNA; - TMgTemplateDefinitionArray_Mem[19].swapCodes = gSwapCodes_BINA; - TMgTemplateDefinitionArray_Mem[20].swapCodes = gSwapCodes_ENVP; - TMgTemplateDefinitionArray_Mem[21].swapCodes = gSwapCodes_FXLR; - TMgTemplateDefinitionArray_Mem[22].swapCodes = gSwapCodes_3CLA; - TMgTemplateDefinitionArray_Mem[23].swapCodes = gSwapCodes_EDIA; - TMgTemplateDefinitionArray_Mem[24].swapCodes = gSwapCodes_M3GM; - TMgTemplateDefinitionArray_Mem[25].swapCodes = gSwapCodes_GMAN; - TMgTemplateDefinitionArray_Mem[26].swapCodes = gSwapCodes_M3GA; - TMgTemplateDefinitionArray_Mem[27].swapCodes = gSwapCodes_PLEA; - TMgTemplateDefinitionArray_Mem[28].swapCodes = gSwapCodes_PNTA; - TMgTemplateDefinitionArray_Mem[29].swapCodes = gSwapCodes_QUDA; - TMgTemplateDefinitionArray_Mem[30].swapCodes = gSwapCodes_TXCA; - TMgTemplateDefinitionArray_Mem[31].swapCodes = gSwapCodes_TXMP; - TMgTemplateDefinitionArray_Mem[32].swapCodes = gSwapCodes_TXAN; - TMgTemplateDefinitionArray_Mem[33].swapCodes = gSwapCodes_TXMA; - TMgTemplateDefinitionArray_Mem[34].swapCodes = gSwapCodes_TXMB; - TMgTemplateDefinitionArray_Mem[35].swapCodes = gSwapCodes_TXPC; - TMgTemplateDefinitionArray_Mem[36].swapCodes = gSwapCodes_M3TA; - TMgTemplateDefinitionArray_Mem[37].swapCodes = gSwapCodes_VCRA; - TMgTemplateDefinitionArray_Mem[38].swapCodes = gSwapCodes_Impt; - TMgTemplateDefinitionArray_Mem[39].swapCodes = gSwapCodes_Mtrl; - TMgTemplateDefinitionArray_Mem[40].swapCodes = gSwapCodes_NMSA; - TMgTemplateDefinitionArray_Mem[41].swapCodes = gSwapCodes_CONS; - TMgTemplateDefinitionArray_Mem[42].swapCodes = gSwapCodes_DOOR; - TMgTemplateDefinitionArray_Mem[43].swapCodes = gSwapCodes_OFGA; - TMgTemplateDefinitionArray_Mem[44].swapCodes = gSwapCodes_OBLS; - TMgTemplateDefinitionArray_Mem[45].swapCodes = gSwapCodes_TRIG; - TMgTemplateDefinitionArray_Mem[46].swapCodes = gSwapCodes_TRGE; - TMgTemplateDefinitionArray_Mem[47].swapCodes = gSwapCodes_TURR; - TMgTemplateDefinitionArray_Mem[48].swapCodes = gSwapCodes_OBAN; - TMgTemplateDefinitionArray_Mem[49].swapCodes = gSwapCodes_OBDC; - TMgTemplateDefinitionArray_Mem[50].swapCodes = gSwapCodes_OBOA; - TMgTemplateDefinitionArray_Mem[51].swapCodes = gSwapCodes_CBPI; - TMgTemplateDefinitionArray_Mem[52].swapCodes = gSwapCodes_CBPM; - TMgTemplateDefinitionArray_Mem[53].swapCodes = gSwapCodes_ONCC; - TMgTemplateDefinitionArray_Mem[54].swapCodes = gSwapCodes_ONIA; - TMgTemplateDefinitionArray_Mem[55].swapCodes = gSwapCodes_ONCP; - TMgTemplateDefinitionArray_Mem[56].swapCodes = gSwapCodes_ONCV; - TMgTemplateDefinitionArray_Mem[57].swapCodes = gSwapCodes_CRSA; - TMgTemplateDefinitionArray_Mem[58].swapCodes = gSwapCodes_DPge; - TMgTemplateDefinitionArray_Mem[59].swapCodes = gSwapCodes_FILM; - TMgTemplateDefinitionArray_Mem[60].swapCodes = gSwapCodes_ONFA; - TMgTemplateDefinitionArray_Mem[61].swapCodes = gSwapCodes_ONGS; - TMgTemplateDefinitionArray_Mem[62].swapCodes = gSwapCodes_HPge; - TMgTemplateDefinitionArray_Mem[63].swapCodes = gSwapCodes_IGHH; - TMgTemplateDefinitionArray_Mem[64].swapCodes = gSwapCodes_IGPG; - TMgTemplateDefinitionArray_Mem[65].swapCodes = gSwapCodes_IGPA; - TMgTemplateDefinitionArray_Mem[66].swapCodes = gSwapCodes_IGSt; - TMgTemplateDefinitionArray_Mem[67].swapCodes = gSwapCodes_IGSA; - TMgTemplateDefinitionArray_Mem[68].swapCodes = gSwapCodes_IPge; - TMgTemplateDefinitionArray_Mem[69].swapCodes = gSwapCodes_KeyI; - TMgTemplateDefinitionArray_Mem[70].swapCodes = gSwapCodes_ONLV; - TMgTemplateDefinitionArray_Mem[71].swapCodes = gSwapCodes_ONLD; - TMgTemplateDefinitionArray_Mem[72].swapCodes = gSwapCodes_ONMA; - TMgTemplateDefinitionArray_Mem[73].swapCodes = gSwapCodes_ONOA; - TMgTemplateDefinitionArray_Mem[74].swapCodes = gSwapCodes_OPge; - TMgTemplateDefinitionArray_Mem[75].swapCodes = gSwapCodes_ONSK; - TMgTemplateDefinitionArray_Mem[76].swapCodes = gSwapCodes_ONSA; - TMgTemplateDefinitionArray_Mem[77].swapCodes = gSwapCodes_TxtC; - TMgTemplateDefinitionArray_Mem[78].swapCodes = gSwapCodes_ONTA; - TMgTemplateDefinitionArray_Mem[79].swapCodes = gSwapCodes_ONVL; - TMgTemplateDefinitionArray_Mem[80].swapCodes = gSwapCodes_WPge; - TMgTemplateDefinitionArray_Mem[81].swapCodes = gSwapCodes_OSBD; - TMgTemplateDefinitionArray_Mem[82].swapCodes = gSwapCodes_PSpc; - TMgTemplateDefinitionArray_Mem[83].swapCodes = gSwapCodes_PSpL; - TMgTemplateDefinitionArray_Mem[84].swapCodes = gSwapCodes_PSUI; - TMgTemplateDefinitionArray_Mem[85].swapCodes = gSwapCodes_SNDD; - TMgTemplateDefinitionArray_Mem[86].swapCodes = gSwapCodes_SUBT; - TMgTemplateDefinitionArray_Mem[87].swapCodes = gSwapCodes_UUEA; - TMgTemplateDefinitionArray_Mem[88].swapCodes = gSwapCodes_TMFA; - TMgTemplateDefinitionArray_Mem[89].swapCodes = gSwapCodes_IDXA; - TMgTemplateDefinitionArray_Mem[90].swapCodes = gSwapCodes_TStr; - TMgTemplateDefinitionArray_Mem[91].swapCodes = gSwapCodes_StNA; - TMgTemplateDefinitionArray_Mem[92].swapCodes = gSwapCodes_TMRA; - TMgTemplateDefinitionArray_Mem[93].swapCodes = gSwapCodes_TRAS; - TMgTemplateDefinitionArray_Mem[94].swapCodes = gSwapCodes_TRAM; - TMgTemplateDefinitionArray_Mem[95].swapCodes = gSwapCodes_TRAC; - TMgTemplateDefinitionArray_Mem[96].swapCodes = gSwapCodes_TRCM; - TMgTemplateDefinitionArray_Mem[97].swapCodes = gSwapCodes_TRBS; - TMgTemplateDefinitionArray_Mem[98].swapCodes = gSwapCodes_TRMA; - TMgTemplateDefinitionArray_Mem[99].swapCodes = gSwapCodes_TRFT; - TMgTemplateDefinitionArray_Mem[100].swapCodes = gSwapCodes_TRGA; - TMgTemplateDefinitionArray_Mem[101].swapCodes = gSwapCodes_TRIA; - TMgTemplateDefinitionArray_Mem[102].swapCodes = gSwapCodes_TRSC; - TMgTemplateDefinitionArray_Mem[103].swapCodes = gSwapCodes_TRTA; - TMgTemplateDefinitionArray_Mem[104].swapCodes = gSwapCodes_TSFT; - TMgTemplateDefinitionArray_Mem[105].swapCodes = gSwapCodes_TSFF; - TMgTemplateDefinitionArray_Mem[106].swapCodes = gSwapCodes_TSFL; - TMgTemplateDefinitionArray_Mem[107].swapCodes = gSwapCodes_TSGA; - TMgTemplateDefinitionArray_Mem[108].swapCodes = gSwapCodes_UVDL; - TMgTemplateDefinitionArray_Mem[109].swapCodes = gSwapCodes_WMCL; - TMgTemplateDefinitionArray_Mem[110].swapCodes = gSwapCodes_WMDD; - TMgTemplateDefinitionArray_Mem[111].swapCodes = gSwapCodes_WMMB; - TMgTemplateDefinitionArray_Mem[112].swapCodes = gSwapCodes_WMM_; - TMgTemplateDefinitionArray_Mem[113].swapCodes = gSwapCodes_ONWC; - TMgTemplateDefinitionArray = TMgTemplateDefinitionArray_Mem; -} +#include "BFW.h" +#include "BFW_TemplateManager.h" +#include "BFW_TM_Private.h" +UUtUns64 TMgTemplateChecksum = 1052091493724257; +UUtUns32 TMgNumTemplateDefinitions = 114; +TMtTemplateDefinition* TMgTemplateDefinitionArray = NULL; +static UUtUns8 gSwapCodes_AISA[74] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x05, 0x20, 0x04, 0x06, 0x03, 0x03, 0x03, 0x03, + 0x09, 0x43, 0x43, 0x4e, 0x4f, 0x05, 0x20, 0x04, + 0x06, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x04, 0x06, 0x09, 0x43, 0x57, 0x4e, 0x4f, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x05, 0x02, 0x04, 0x06, + 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AITR[22] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, + 0x05, 0x40, 0x04, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AIWA[21] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x05, + 0x02, 0x04, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AKAA[13] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ABNA[14] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AKVA[40] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AKBA[17] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, + 0x06 +}; +static UUtUns8 gSwapCodes_AKBP[13] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AKDA[23] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AKEV[101] = +{ + 0x02, 0x02, 0x09, 0x41, 0x54, 0x4e, 0x50, 0x09, + 0x41, 0x45, 0x4c, 0x50, 0x09, 0x41, 0x43, 0x58, + 0x54, 0x09, 0x47, 0x51, 0x47, 0x41, 0x09, 0x52, + 0x51, 0x47, 0x41, 0x09, 0x43, 0x51, 0x47, 0x41, + 0x09, 0x42, 0x44, 0x47, 0x41, 0x09, 0x41, 0x4d, + 0x58, 0x54, 0x09, 0x41, 0x56, 0x4b, 0x41, 0x09, + 0x41, 0x42, 0x4b, 0x41, 0x09, 0x41, 0x58, 0x44, + 0x49, 0x09, 0x41, 0x58, 0x44, 0x49, 0x09, 0x50, + 0x42, 0x4b, 0x41, 0x09, 0x41, 0x4e, 0x42, 0x41, + 0x09, 0x54, 0x4f, 0x4b, 0x41, 0x09, 0x41, 0x41, + 0x4b, 0x41, 0x09, 0x41, 0x44, 0x4b, 0x41, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_AGQC[17] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, + 0x06 +}; +static UUtUns8 gSwapCodes_AGDB[12] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AGQG[24] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x04, 0x02, 0x06, 0x05, 0x04, 0x02, 0x06, + 0x05, 0x04, 0x02, 0x06, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AGQM[7] = +{ + 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x06 +}; +static UUtUns8 gSwapCodes_AGQR[12] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x03, 0x03, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AKOT[28] = +{ + 0x02, 0x02, 0x09, 0x54, 0x49, 0x54, 0x4f, 0x09, + 0x46, 0x4c, 0x54, 0x4f, 0x09, 0x41, 0x4e, 0x54, + 0x51, 0x09, 0x41, 0x58, 0x44, 0x49, 0x09, 0x41, + 0x58, 0x44, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_OTIT[14] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x08, 0x02, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_OTLF[17] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x05, 0x06, 0x02, 0x06, 0x02, 0x02, 0x08, + 0x06 +}; +static UUtUns8 gSwapCodes_QTNA[14] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x04, 0x02, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_BINA[5] = +{ + 0x02, 0x02, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_ENVP[35] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x05, 0x40, 0x04, 0x06, 0x05, 0x30, 0x04, 0x06, + 0x05, 0x0c, 0x02, 0x06, 0x02, 0x02, 0x03, 0x03, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_FXLR[14] = +{ + 0x02, 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, + 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x06 +}; +static UUtUns8 gSwapCodes_3CLA[13] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_EDIA[16] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x02, 0x03, 0x06, 0x03, 0x03, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_M3GM[44] = +{ + 0x02, 0x02, 0x02, 0x09, 0x41, 0x54, 0x4e, 0x50, + 0x09, 0x41, 0x52, 0x43, 0x56, 0x09, 0x41, 0x52, + 0x43, 0x56, 0x09, 0x41, 0x43, 0x58, 0x54, 0x09, + 0x41, 0x58, 0x44, 0x49, 0x09, 0x41, 0x58, 0x44, + 0x49, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x00, + 0x00, 0x00, 0x00, 0x06 +}; +static UUtUns8 gSwapCodes_GMAN[22] = +{ + 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x03, 0x03, + 0x03, 0x05, 0x02, 0x04, 0x06, 0x07, 0x02, 0x09, + 0x4d, 0x47, 0x33, 0x4d, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_M3GA[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_PLEA[14] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_PNTA[23] = +{ + 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x07, 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_QUDA[14] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x04, 0x02, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TXCA[12] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TXMP[30] = +{ + 0x02, 0x02, 0x05, 0x80, 0x04, 0x06, 0x02, 0x03, + 0x03, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x09, + 0x50, 0x4d, 0x58, 0x54, 0x02, 0x02, 0x02, 0x02, + 0x04, 0x05, 0x03, 0x04, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_TXAN[22] = +{ + 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x03, 0x03, + 0x03, 0x05, 0x02, 0x04, 0x06, 0x07, 0x02, 0x09, + 0x50, 0x4d, 0x58, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TXMA[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x09, 0x50, 0x4d, 0x58, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TXMB[20] = +{ + 0x02, 0x02, 0x05, 0x08, 0x04, 0x06, 0x03, 0x03, + 0x02, 0x03, 0x03, 0x07, 0x02, 0x09, 0x50, 0x4d, + 0x58, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TXPC[14] = +{ + 0x02, 0x02, 0x05, 0x08, 0x04, 0x06, 0x02, 0x02, + 0x02, 0x07, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_M3TA[14] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x03, 0x02, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_VCRA[13] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_Impt[15] = +{ + 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x03, 0x04, + 0x06, 0x09, 0x00, 0x00, 0x00, 0x00, 0x06 +}; +static UUtUns8 gSwapCodes_Mtrl[15] = +{ + 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x03, 0x04, + 0x06, 0x09, 0x00, 0x00, 0x00, 0x00, 0x06 +}; +static UUtUns8 gSwapCodes_NMSA[14] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_CONS[33] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x09, 0x41, 0x47, 0x46, 0x4f, 0x09, 0x4d, + 0x47, 0x33, 0x4d, 0x02, 0x05, 0x20, 0x04, 0x06, + 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, + 0x06 +}; +static UUtUns8 gSwapCodes_DOOR[30] = +{ + 0x02, 0x02, 0x05, 0x02, 0x09, 0x41, 0x47, 0x46, + 0x4f, 0x06, 0x09, 0x4e, 0x41, 0x42, 0x4f, 0x02, + 0x02, 0x02, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, + 0x20, 0x04, 0x06, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_OFGA[26] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x09, 0x50, + 0x56, 0x4e, 0x45, 0x07, 0x02, 0x02, 0x09, 0x4d, + 0x47, 0x33, 0x4d, 0x09, 0x53, 0x4c, 0x42, 0x4f, + 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_OBLS[12] = +{ + 0x02, 0x02, 0x02, 0x02, 0x05, 0x03, 0x02, 0x06, + 0x02, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_TRIG[39] = +{ + 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x09, + 0x4d, 0x47, 0x33, 0x4d, 0x09, 0x53, 0x4c, 0x42, + 0x4f, 0x02, 0x09, 0x45, 0x47, 0x52, 0x54, 0x09, + 0x4e, 0x41, 0x42, 0x4f, 0x05, 0x20, 0x04, 0x06, + 0x05, 0x20, 0x04, 0x06, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_TRGE[15] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_TURR[123] = +{ + 0x02, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x04, 0x06, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x05, 0x02, 0x04, 0x06, 0x02, + 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x09, 0x53, 0x4c, + 0x42, 0x4f, 0x02, 0x09, 0x4d, 0x47, 0x33, 0x4d, + 0x02, 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x10, 0x05, + 0x10, 0x04, 0x06, 0x02, 0x03, 0x03, 0x05, 0x0c, + 0x02, 0x06, 0x05, 0x04, 0x04, 0x06, 0x06, 0x02, + 0x05, 0x0c, 0x02, 0x06, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x20, 0x04, + 0x06, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_OBAN[30] = +{ + 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x02, 0x05, + 0x0c, 0x02, 0x06, 0x05, 0x0c, 0x02, 0x06, 0x03, + 0x03, 0x03, 0x07, 0x03, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_OBDC[23] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x03, 0x03, 0x09, 0x4e, 0x41, 0x42, 0x4f, 0x03, + 0x03, 0x02, 0x03, 0x03, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_OBOA[50] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x09, 0x41, 0x47, 0x33, 0x4d, 0x09, 0x4e, 0x41, + 0x42, 0x4f, 0x09, 0x50, 0x56, 0x4e, 0x45, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x05, 0x0c, 0x02, 0x06, + 0x05, 0x40, 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, + 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_CBPI[27] = +{ + 0x02, 0x02, 0x05, 0x13, 0x09, 0x74, 0x70, 0x6d, + 0x49, 0x06, 0x05, 0x13, 0x09, 0x74, 0x70, 0x6d, + 0x49, 0x06, 0x05, 0x13, 0x09, 0x74, 0x70, 0x6d, + 0x49, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_CBPM[11] = +{ + 0x02, 0x02, 0x05, 0x13, 0x09, 0x6c, 0x72, 0x74, + 0x4d, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_ONCC[233] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, + 0x03, 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, + 0x04, 0x04, 0x05, 0x02, 0x04, 0x06, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x03, 0x05, 0x02, 0x04, + 0x06, 0x05, 0x05, 0x02, 0x06, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x04, 0x05, 0x01, 0x04, 0x06, 0x02, 0x05, 0x20, + 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x05, 0x0d, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, + 0x03, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x03, 0x03, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x02, + 0x04, 0x06, 0x05, 0xff, 0x04, 0x06, 0x05, 0x41, + 0x04, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x09, 0x56, 0x43, 0x4e, 0x4f, 0x09, 0x50, 0x43, + 0x4e, 0x4f, 0x09, 0x41, 0x49, 0x4e, 0x4f, 0x04, + 0x04, 0x03, 0x05, 0x10, 0x04, 0x06, 0x05, 0x0f, + 0x05, 0x80, 0x04, 0x06, 0x03, 0x06, 0x05, 0x02, + 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, 0x02, 0x02, + 0x09, 0x53, 0x42, 0x52, 0x54, 0x09, 0x41, 0x4d, + 0x52, 0x54, 0x09, 0x4d, 0x50, 0x42, 0x43, 0x09, + 0x49, 0x50, 0x42, 0x43, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x05, 0x07, 0x02, 0x06, 0x02, + 0x09, 0x43, 0x41, 0x52, 0x54, 0x09, 0x43, 0x53, + 0x52, 0x54, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, + 0x06 +}; +static UUtUns8 gSwapCodes_ONIA[29] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x04, 0x05, + 0x03, 0x04, 0x06, 0x07, 0x02, 0x05, 0x10, 0x04, + 0x06, 0x05, 0x80, 0x04, 0x06, 0x05, 0x10, 0x04, + 0x06, 0x03, 0x03, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONCP[29] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x04, 0x05, + 0x03, 0x04, 0x06, 0x07, 0x02, 0x05, 0x10, 0x04, + 0x06, 0x05, 0x40, 0x04, 0x06, 0x03, 0x05, 0x02, + 0x04, 0x06, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONCV[16] = +{ + 0x02, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x05, + 0x20, 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_CRSA[38] = +{ + 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x02, 0x02, + 0x07, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x02, 0x06, 0x09, 0x43, 0x43, 0x4e, 0x4f, 0x05, + 0x13, 0x05, 0x0c, 0x02, 0x06, 0x06, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_DPge[19] = +{ + 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x03, 0x04, + 0x06, 0x05, 0x0c, 0x02, 0x06, 0x09, 0x47, 0x50, + 0x47, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_FILM[34] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x05, 0x02, 0x09, 0x4d, 0x41, 0x52, + 0x54, 0x06, 0x05, 0x0c, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x01, 0x02, 0x05, 0x04, 0x04, 0x06, + 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONFA[22] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x03, 0x07, + 0x03, 0x05, 0x0c, 0x02, 0x06, 0x02, 0x02, 0x02, + 0x02, 0x03, 0x04, 0x04, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONGS[107] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x05, 0x10, 0x02, 0x06, 0x05, 0x10, 0x02, 0x06, + 0x05, 0xff, 0x04, 0x06, 0x05, 0xff, 0x04, 0x06, + 0x05, 0xff, 0x04, 0x06, 0x05, 0x83, 0x04, 0x06, + 0x05, 0xff, 0x04, 0x06, 0x05, 0xff, 0x04, 0x06, + 0x05, 0xff, 0x04, 0x06, 0x05, 0x83, 0x04, 0x06, + 0x05, 0x0e, 0x02, 0x06, 0x05, 0xff, 0x04, 0x06, + 0x05, 0xff, 0x04, 0x06, 0x05, 0x42, 0x04, 0x06, + 0x05, 0xa0, 0x04, 0x06, 0x05, 0x03, 0x02, 0x06, + 0x05, 0x03, 0x02, 0x06, 0x05, 0x03, 0x02, 0x06, + 0x05, 0x03, 0x02, 0x06, 0x05, 0x03, 0x02, 0x06, + 0x05, 0x03, 0x02, 0x06, 0x02, 0x05, 0x10, 0x05, + 0x20, 0x04, 0x06, 0x03, 0x03, 0x05, 0x20, 0x04, + 0x06, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_HPge[13] = +{ + 0x02, 0x02, 0x05, 0x02, 0x04, 0x06, 0x03, 0x09, + 0x47, 0x50, 0x47, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_IGHH[32] = +{ + 0x02, 0x02, 0x05, 0x1c, 0x04, 0x06, 0x09, 0x50, + 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, + 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x07, 0x02, + 0x05, 0x40, 0x04, 0x06, 0x03, 0x03, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_IGPG[27] = +{ + 0x02, 0x02, 0x09, 0x46, 0x46, 0x53, 0x54, 0x02, + 0x02, 0x03, 0x03, 0x09, 0x00, 0x00, 0x00, 0x00, + 0x09, 0x41, 0x53, 0x47, 0x49, 0x09, 0x41, 0x53, + 0x47, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_IGPA[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x09, 0x47, 0x50, 0x47, 0x49, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_IGSt[20] = +{ + 0x02, 0x02, 0x09, 0x46, 0x46, 0x53, 0x54, 0x02, + 0x02, 0x03, 0x03, 0x05, 0xff, 0x04, 0x06, 0x05, + 0x81, 0x04, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_IGSA[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x09, 0x74, 0x53, 0x47, 0x49, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_IPge[9] = +{ + 0x02, 0x02, 0x02, 0x09, 0x47, 0x50, 0x47, 0x49, + 0x06 +}; +static UUtUns8 gSwapCodes_KeyI[53] = +{ + 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, + 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, + 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, + 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, + 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, + 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, + 0x50, 0x4d, 0x58, 0x54, 0x06 +}; +static UUtUns8 gSwapCodes_ONLV[82] = +{ + 0x02, 0x02, 0x05, 0x40, 0x04, 0x06, 0x09, 0x56, + 0x45, 0x4b, 0x41, 0x09, 0x41, 0x4f, 0x42, 0x4f, + 0x09, 0x41, 0x4d, 0x4e, 0x4f, 0x09, 0x41, 0x46, + 0x4e, 0x4f, 0x09, 0x41, 0x54, 0x4e, 0x4f, 0x09, + 0x4b, 0x53, 0x4e, 0x4f, 0x02, 0x09, 0x41, 0x53, + 0x49, 0x41, 0x09, 0x52, 0x54, 0x49, 0x41, 0x09, + 0x41, 0x53, 0x4e, 0x4f, 0x09, 0x43, 0x44, 0x42, + 0x4f, 0x09, 0x41, 0x4f, 0x4e, 0x4f, 0x09, 0x50, + 0x56, 0x4e, 0x45, 0x02, 0x05, 0x20, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x06, 0x09, 0x41, 0x53, 0x52, + 0x43, 0x06 +}; +static UUtUns8 gSwapCodes_ONLD[9] = +{ + 0x02, 0x02, 0x03, 0x03, 0x05, 0x40, 0x04, 0x06, + 0x06 +}; +static UUtUns8 gSwapCodes_ONMA[20] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x05, 0x40, 0x04, 0x06, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONOA[16] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x09, 0x41, 0x58, 0x44, 0x49, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_OPge[13] = +{ + 0x02, 0x02, 0x05, 0x02, 0x04, 0x06, 0x03, 0x09, + 0x41, 0x50, 0x47, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_ONSK[55] = +{ + 0x02, 0x02, 0x05, 0x06, 0x09, 0x50, 0x4d, 0x58, + 0x54, 0x06, 0x05, 0x08, 0x09, 0x50, 0x4d, 0x58, + 0x54, 0x06, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x05, + 0x05, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x06, 0x02, + 0x02, 0x05, 0x08, 0x02, 0x06, 0x05, 0x08, 0x02, + 0x06, 0x05, 0x08, 0x02, 0x06, 0x05, 0x08, 0x02, + 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_ONSA[11] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x03, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TxtC[8] = +{ + 0x02, 0x02, 0x09, 0x41, 0x50, 0x47, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_ONTA[52] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x02, 0x07, + 0x02, 0x05, 0x08, 0x02, 0x02, 0x02, 0x06, 0x05, + 0x06, 0x05, 0x04, 0x02, 0x06, 0x06, 0x05, 0x06, + 0x02, 0x02, 0x02, 0x06, 0x05, 0x06, 0x02, 0x02, + 0x02, 0x02, 0x06, 0x05, 0x06, 0x03, 0x06, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONVL[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x09, 0x56, 0x43, 0x4e, 0x4f, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_WPge[13] = +{ + 0x02, 0x02, 0x09, 0x43, 0x57, 0x4e, 0x4f, 0x09, + 0x47, 0x50, 0x47, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_OSBD[5] = +{ + 0x02, 0x02, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_PSpc[18] = +{ + 0x02, 0x02, 0x05, 0x09, 0x03, 0x03, 0x06, 0x05, + 0x09, 0x03, 0x03, 0x06, 0x09, 0x00, 0x00, 0x00, + 0x00, 0x06 +}; +static UUtUns8 gSwapCodes_PSpL[16] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_PSUI[223] = +{ + 0x02, 0x02, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, + 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, + 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, + 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, + 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, + 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, + 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, + 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, + 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, + 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, + 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, + 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, + 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, + 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, + 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, + 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, + 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, + 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, + 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, + 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, + 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, + 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, + 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, + 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, + 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, + 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, + 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, + 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x06 +}; +static UUtUns8 gSwapCodes_SNDD[8] = +{ + 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_SUBT[12] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x02, 0x07, + 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_UUEA[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x7e, 0x04, 0x06, 0x03, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TMFA[11] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_IDXA[11] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TStr[7] = +{ + 0x02, 0x02, 0x05, 0x80, 0x04, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_StNA[15] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x09, 0x72, 0x74, 0x53, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TMRA[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x09, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRAS[16] = +{ + 0x02, 0x02, 0x09, 0x4d, 0x41, 0x52, 0x54, 0x02, + 0x02, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x06 +}; +static UUtUns8 gSwapCodes_TRAM[94] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x05, 0x02, 0x09, 0x4d, 0x41, 0x52, 0x54, 0x06, + 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, + 0x05, 0x24, 0x02, 0x06, 0x03, 0x04, 0x04, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x04, + 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x03, + 0x03, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x06 +}; +static UUtUns8 gSwapCodes_TRAC[24] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x09, 0x43, + 0x41, 0x52, 0x54, 0x03, 0x07, 0x03, 0x03, 0x03, + 0x02, 0x09, 0x4d, 0x41, 0x52, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRCM[31] = +{ + 0x02, 0x02, 0x02, 0x03, 0x05, 0x02, 0x04, 0x06, + 0x05, 0x40, 0x04, 0x06, 0x02, 0x02, 0x02, 0x09, + 0x41, 0x47, 0x52, 0x54, 0x09, 0x41, 0x54, 0x52, + 0x54, 0x09, 0x41, 0x49, 0x52, 0x54, 0x06 +}; +static UUtUns8 gSwapCodes_TRBS[11] = +{ + 0x02, 0x02, 0x05, 0x05, 0x09, 0x4d, 0x43, 0x52, + 0x54, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_TRMA[15] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x09, 0x50, 0x4d, 0x58, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRFT[11] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRGA[15] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRIA[14] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x04, 0x04, 0x04, 0x04, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRSC[15] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x09, 0x53, 0x41, 0x52, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRTA[13] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TSFT[33] = +{ + 0x02, 0x02, 0x05, 0x06, 0x04, 0x06, 0x03, 0x02, + 0x03, 0x03, 0x03, 0x03, 0x05, 0xff, 0x09, 0x41, + 0x47, 0x53, 0x54, 0x06, 0x05, 0x01, 0x09, 0x41, + 0x47, 0x53, 0x54, 0x06, 0x07, 0x02, 0x02, 0x08, + 0x06 +}; +static UUtUns8 gSwapCodes_TSFF[20] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x09, 0x4c, + 0x46, 0x53, 0x54, 0x07, 0x02, 0x09, 0x54, 0x46, + 0x53, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TSFL[23] = +{ + 0x02, 0x02, 0x05, 0x40, 0x04, 0x06, 0x05, 0x40, + 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, 0x05, 0x40, + 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_TSGA[25] = +{ + 0x02, 0x02, 0x05, 0xff, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x02, 0x02, 0x06, 0x05, 0x01, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x06, + 0x06 +}; +static UUtUns8 gSwapCodes_UVDL[19] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x02, 0x07, + 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, 0x04, + 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_WMCL[16] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_WMDD[50] = +{ + 0x02, 0x02, 0x05, 0xff, 0x04, 0x06, 0x05, 0x01, + 0x04, 0x06, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, + 0x03, 0x03, 0x07, 0x02, 0x05, 0xff, 0x04, 0x06, + 0x05, 0x01, 0x04, 0x06, 0x03, 0x03, 0x02, 0x02, + 0x03, 0x03, 0x03, 0x03, 0x09, 0x46, 0x46, 0x53, + 0x54, 0x02, 0x02, 0x05, 0x02, 0x04, 0x06, 0x03, + 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_WMMB[16] = +{ + 0x02, 0x02, 0x05, 0x12, 0x04, 0x06, 0x03, 0x07, + 0x02, 0x09, 0x5f, 0x4d, 0x4d, 0x57, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_WMM_[21] = +{ + 0x02, 0x02, 0x05, 0x12, 0x04, 0x06, 0x03, 0x05, + 0x40, 0x04, 0x06, 0x07, 0x02, 0x03, 0x03, 0x05, + 0x40, 0x04, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONWC[175] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x02, + 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x02, 0x02, + 0x09, 0x50, 0x4d, 0x58, 0x54, 0x02, 0x02, 0x02, + 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, + 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, + 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x05, 0x20, 0x04, + 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x02, 0x02, 0x05, 0x0c, 0x02, 0x06, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x0c, 0x02, + 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x10, 0x05, + 0x0c, 0x02, 0x06, 0x05, 0x10, 0x04, 0x06, 0x02, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06, 0x05, + 0x20, 0x04, 0x06, 0x02, 0x09, 0x50, 0x4d, 0x58, + 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x05, 0x02, + 0x02, 0x06, 0x02, 0x02, 0x02, 0x02, 0x06 +}; +static TMtTemplateDefinition TMgTemplateDefinitionArray_Mem[114] = +{ + // #0 + { + 180964060137, + 0x41495341, + "AI Character Setup Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x160, + NULL, + 0x4d41474b, + NULL, + }, + // #1 + { + 1763925, + 0x41495452, + "AI script trigger array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x54, + NULL, + 0x4d41474b, + NULL, + }, + // #2 + { + 1081091, + 0x41495741, + "AI Imported Waypoint Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x1c, + NULL, + 0x4d41474b, + NULL, + }, + // #3 + { + 1171063, + 0x414b4141, + "Adjacency Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #4 + { + 1207712, + 0x41424e41, + "bsp tree node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x10, + NULL, + 0x4d41474b, + NULL, + }, + // #5 + { + 14616032, + 0x414b5641, + "BNV Node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x74, + NULL, + 0x4d41474b, + NULL, + }, + // #6 + { + 3811460, + 0x414b4241, + "Side Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x1c, + NULL, + 0x4d41474b, + NULL, + }, + // #7 + { + 848969, + 0x414b4250, + "BSP node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #8 + { + 3036260, + 0x414b4441, + "Door Frame Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x34, + NULL, + 0x4d41474b, + NULL, + }, + // #9 + { + 584922226293, + 0x414b4556, + "Akira Environment", + NULL, + (TMtTemplateFlags)0x4, + 0x80, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #10 + { + 1887121, + 0x41475143, + "Gunk Quad Collision Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x1c, + NULL, + 0x4d41474b, + NULL, + }, + // #11 + { + 470551, + 0x41474442, + "Gunk Quad Debug Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x8, + NULL, + 0x4d41474b, + NULL, + }, + // #12 + { + 1835986, + 0x41475147, + "Gunk Quad General Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x38, + NULL, + 0x4d41474b, + NULL, + }, + // #13 + { + 281254, + 0x4147514d, + "Gunk Quad Material", + NULL, + (TMtTemplateFlags)0x6, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #14 + { + 539195, + 0x41475152, + "Gunk Quad Render Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #15 + { + 76902095368, + 0x414b4f54, + "Oct tree", + NULL, + (TMtTemplateFlags)0x4, + 0x1c, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #16 + { + 676306, + 0x4f544954, + "Oct tree interior node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x20, + NULL, + 0x4d41474b, + NULL, + }, + // #17 + { + 2010123, + 0x4f544c46, + "Oct tree leaf node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x24, + NULL, + 0x4d41474b, + NULL, + }, + // #18 + { + 421580, + 0x51544e41, + "Quad tree node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x10, + NULL, + 0x4d41474b, + NULL, + }, + // #19 + { + 89617, + 0x42494e41, + "Binary Data", + NULL, + (TMtTemplateFlags)0x6, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #20 + { + 6799811, + 0x454e5650, + "Env Particle Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xd0, + NULL, + 0x4d41474b, + NULL, + }, + // #21 + { + 28278257833, + 0x46584c52, + "FX Laser effect", + NULL, + (TMtTemplateFlags)0x4, + 0x14, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #22 + { + 321214, + 0x33434c41, + "RGB Color Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #23 + { + 505591, + 0x45444941, + "Edge Index Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x8, + NULL, + 0x4d41474b, + NULL, + }, + // #24 + { + 170196001846, + 0x4d33474d, + "Geometry", + NULL, + (TMtTemplateFlags)0x4, + 0x2c, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #25 + { + 41447257509, + 0x474d414e, + "Geometry Animation", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #26 + { + 22018728114, + 0x4d334741, + "GeometryArray", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #27 + { + 506936, + 0x504c4541, + "Plane Equation Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x10, + NULL, + 0x4d41474b, + NULL, + }, + // #28 + { + 3630956, + 0x504e5441, + "3D Point Array", + NULL, + (TMtTemplateFlags)0x6, + 0x40, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #29 + { + 220778, + 0x51554441, + "Quad array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x10, + NULL, + 0x4d41474b, + NULL, + }, + // #30 + { + 594970, + 0x54584341, + "Texture Coordinate Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x8, + NULL, + 0x4d41474b, + NULL, + }, + // #31 + { + 36794461023, + 0x54584d50, + "Texture Map", + NULL, + (TMtTemplateFlags)0x4, + 0xb0, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #32 + { + 45282968455, + 0x5458414e, + "Texture Map Animation", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #33 + { + 24056332176, + 0x54584d41, + "Texture map array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #34 + { + 45283174994, + 0x54584d42, + "Texture Map Big", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #35 + { + 763774, + 0x54585043, + "Texture Procedure Data", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #36 + { + 194497, + 0x4d335441, + "Triangle array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #37 + { + 345913, + 0x56435241, + "3D Vector Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #38 + { + 282390, + 0x496d7074, + "Impact", + NULL, + (TMtTemplateFlags)0x4, + 0x14, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #39 + { + 167437, + 0x4d74726c, + "Material", + NULL, + (TMtTemplateFlags)0x4, + 0x14, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #40 + { + 788892, + 0x4e4d5341, + "Network Spawn Point Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x10, + NULL, + 0x4d41474b, + NULL, + }, + // #41 + { + 85270924253, + 0x434f4e53, + "Console", + NULL, + (TMtTemplateFlags)0x4, + 0x90, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #42 + { + 26599423335, + 0x444f4f52, + "Door", + NULL, + (TMtTemplateFlags)0x4, + 0x6c, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #43 + { + 83566969698, + 0x4f464741, + "Object Furn Geom Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #44 + { + 749629, + 0x4f424c53, + "Object LS Data", + NULL, + (TMtTemplateFlags)0x6, + 0x28, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #45 + { + 145438592300, + 0x54524947, + "Trigger", + NULL, + (TMtTemplateFlags)0x4, + 0x74, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #46 + { + 36266490172, + 0x54524745, + "Trigger Emitter", + NULL, + (TMtTemplateFlags)0x4, + 0x28, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #47 + { + 316893824446, + 0x54555252, + "Turret", + NULL, + (TMtTemplateFlags)0x4, + 0x648, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #48 + { + 5114916, + 0x4f42414e, + "Object animation", + NULL, + (TMtTemplateFlags)0x6, + 0x80, + 0x20, + NULL, + 0x4d41474b, + NULL, + }, + // #49 + { + 33246071307, + 0x4f424443, + "Door class array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x18, + NULL, + 0x4d41474b, + NULL, + }, + // #50 + { + 82938791649, + 0x4f424f41, + "Starting Object Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0xf0, + NULL, + 0x4d41474b, + NULL, + }, + // #51 + { + 51740530370, + 0x43425049, + "Character Body Part Impacts", + NULL, + (TMtTemplateFlags)0x4, + 0xec, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #52 + { + 10395858207, + 0x4342504d, + "Character Body Part Material", + NULL, + (TMtTemplateFlags)0x4, + 0x54, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #53 + { + 5109581306351, + 0x4f4e4343, + "Oni Character Class", + NULL, + (TMtTemplateFlags)0x4, + 0xc98, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #54 + { + 2830234, + 0x4f4e4941, + "Oni Character Impact Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xa4, + NULL, + 0x4d41474b, + NULL, + }, + // #55 + { + 3109665, + 0x4f4e4350, + "Oni Character Particle Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x58, + NULL, + 0x4d41474b, + NULL, + }, + // #56 + { + 170485, + 0x4f4e4356, + "Oni Character Variant", + NULL, + (TMtTemplateFlags)0x4, + 0x4c, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #57 + { + 51896374476, + 0x43525341, + "Corpse Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x44c, + NULL, + 0x4d41474b, + NULL, + }, + // #58 + { + 33194403947, + 0x44506765, + "Diary Page", + NULL, + (TMtTemplateFlags)0x4, + 0x44, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #59 + { + 48102073005, + 0x46494c4d, + "Film", + NULL, + (TMtTemplateFlags)0x4, + 0x40, + 0x18, + NULL, + 0x4d41474b, + NULL, + }, + // #60 + { + 1772775, + 0x4f4e4641, + "Imported Flag Node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x44, + NULL, + 0x4d41474b, + NULL, + }, + // #61 + { + 36105142, + 0x4f4e4753, + "Oni Game Settings", + NULL, + (TMtTemplateFlags)0x6, + 0xf44, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #62 + { + 18441269563, + 0x48506765, + "Help Page", + NULL, + (TMtTemplateFlags)0x4, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #63 + { + 38211049694, + 0x49474848, + "IGUI HUD Help", + NULL, + (TMtTemplateFlags)0x4, + 0x40, + 0x44, + NULL, + 0x4d41474b, + NULL, + }, + // #64 + { + 76477335677, + 0x49475047, + "IGUI Page", + NULL, + (TMtTemplateFlags)0x4, + 0x24, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #65 + { + 20900088069, + 0x49475041, + "IGUI Page Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #66 + { + 11318621989, + 0x49475374, + "IGUI String", + NULL, + (TMtTemplateFlags)0x4, + 0x198, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #67 + { + 20900127752, + 0x49475341, + "IGUI String Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #68 + { + 11064797626, + 0x49506765, + "Item Page", + NULL, + (TMtTemplateFlags)0x4, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #69 + { + 275939547053, + 0x4b657949, + "Key Icons", + NULL, + (TMtTemplateFlags)0x4, + 0x30, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #70 + { + 539951247011, + 0x4f4e4c56, + "Oni Game Level", + NULL, + (TMtTemplateFlags)0x4, + 0x304, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #71 + { + 266913, + 0x4f4e4c44, + "Oni Game Level Descriptor", + NULL, + (TMtTemplateFlags)0x6, + 0x4c, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #72 + { + 1197945, + 0x4f4e4d41, + "Imported Marker Node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x58, + NULL, + 0x4d41474b, + NULL, + }, + // #73 + { + 27043257468, + 0x4f4e4f41, + "Object Gunk Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x8, + NULL, + 0x4d41474b, + NULL, + }, + // #74 + { + 18441354235, + 0x4f506765, + "Objective Page", + NULL, + (TMtTemplateFlags)0x4, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #75 + { + 89156620391, + 0x4f4e534b, + "Oni Sky class", + NULL, + (TMtTemplateFlags)0x4, + 0xf4, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #76 + { + 280116, + 0x4f4e5341, + "Imported Spawn Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x2, + NULL, + 0x4d41474b, + NULL, + }, + // #77 + { + 7376505639, + 0x54787443, + "Text Console", + NULL, + (TMtTemplateFlags)0x4, + 0xc, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #78 + { + 10550464, + 0x4f4e5441, + "Trigger Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x1a0, + NULL, + 0x4d41474b, + NULL, + }, + // #79 + { + 22619145610, + 0x4f4e564c, + "Oni Variant List", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #80 + { + 19047942581, + 0x57506765, + "Weapon Page", + NULL, + (TMtTemplateFlags)0x4, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #81 + { + 89660, + 0x4f534244, + "Oni Sound Binary Data", + NULL, + (TMtTemplateFlags)0x6, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #82 + { + 534088, + 0x50537063, + "Part Specification", + NULL, + (TMtTemplateFlags)0x4, + 0x54, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #83 + { + 838661, + 0x5053704c, + "Part Specification List", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x8, + NULL, + 0x4d41474b, + NULL, + }, + // #84 + { + 4180417615611, + 0x50535549, + "Part Specifications UI", + NULL, + (TMtTemplateFlags)0x4, + 0xb8, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #85 + { + 266731, + 0x534e4444, + "Sound Data", + NULL, + (TMtTemplateFlags)0x6, + 0x18, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #86 + { + 289896, + 0x53554254, + "Subtitle Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #87 + { + 716476, + 0x55554541, + "Error Binding Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x80, + NULL, + 0x4d41474b, + NULL, + }, + // #88 + { + 152356, + 0x544d4641, + "Float Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #89 + { + 159887, + 0x49445841, + "Index Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #90 + { + 25760, + 0x54537472, + "String", + NULL, + (TMtTemplateFlags)0x6, + 0x88, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #91 + { + 24050971936, + 0x53744e41, + "String Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #92 + { + 472353, + 0x544d5241, + "Template Reference Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #93 + { + 8491477296, + 0x54524153, + "Totoro Aiming Screen", + NULL, + (TMtTemplateFlags)0x4, + 0x24, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #94 + { + 70837389592, + 0x5452414d, + "Totoro Animation Sequence", + NULL, + (TMtTemplateFlags)0x4, + 0x188, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #95 + { + 65077377839, + 0x54524143, + "Animation Collection", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #96 + { + 152787879246, + 0x5452434d, + "Totoro Quaternion Body", + NULL, + (TMtTemplateFlags)0x4, + 0x68, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #97 + { + 11317428793, + 0x54524253, + "Totoro Body Set", + NULL, + (TMtTemplateFlags)0x4, + 0x1c, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #98 + { + 24056327511, + 0x54524d41, + "Texture Map Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #99 + { + 139695, + 0x54524654, + "Totoro Facing Table", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #100 + { + 22018728184, + 0x54524741, + "Totoro Quaternion Body Geometry Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #101 + { + 705666, + 0x54524941, + "Totoro Quaternion Body Index Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #102 + { + 24049642263, + 0x54525343, + "Screen (aiming) Collection", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #103 + { + 481768, + 0x54525441, + "Totoro Quaternion Body Translation Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #104 + { + 97619402474, + 0x54534654, + "Font", + NULL, + (TMtTemplateFlags)0x4, + 0x420, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #105 + { + 45272025226, + 0x54534646, + "Font Family", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #106 + { + 581161, + 0x5453464c, + "Font Language", + NULL, + (TMtTemplateFlags)0x6, + 0x148, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #107 + { + 2772632, + 0x54534741, + "Glyph Array", + NULL, + (TMtTemplateFlags)0x6, + 0x1408, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #108 + { + 661221, + 0x5556444c, + "UV Data List", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x40, + NULL, + 0x4d41474b, + NULL, + }, + // #109 + { + 643190, + 0x574d434c, + "WM Cursor List", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x8, + NULL, + 0x4d41474b, + NULL, + }, + // #110 + { + 120261047236, + 0x574d4444, + "WM Dialog Data", + NULL, + (TMtTemplateFlags)0x0, + 0x120, + 0x124, + NULL, + 0x4d41474b, + NULL, + }, + // #111 + { + 29293831991, + 0x574d4d42, + "WM Menu Bar", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #112 + { + 793144, + 0x574d4d5f, + "WM Menu", + NULL, + (TMtTemplateFlags)0x6, + 0x60, + 0x44, + NULL, + 0x4d41474b, + NULL, + }, + // #113 + { + 1733621247669, + 0x4f4e5743, + "Oni Weapon Class", + NULL, + (TMtTemplateFlags)0x4, + 0x71c, + 0x0, + NULL, + 0x4d41474b, + NULL, + } +}; +void +TMrTemplate_BuildList( + void) +{ + TMgTemplateDefinitionArray_Mem[0].swapCodes = gSwapCodes_AISA; + TMgTemplateDefinitionArray_Mem[1].swapCodes = gSwapCodes_AITR; + TMgTemplateDefinitionArray_Mem[2].swapCodes = gSwapCodes_AIWA; + TMgTemplateDefinitionArray_Mem[3].swapCodes = gSwapCodes_AKAA; + TMgTemplateDefinitionArray_Mem[4].swapCodes = gSwapCodes_ABNA; + TMgTemplateDefinitionArray_Mem[5].swapCodes = gSwapCodes_AKVA; + TMgTemplateDefinitionArray_Mem[6].swapCodes = gSwapCodes_AKBA; + TMgTemplateDefinitionArray_Mem[7].swapCodes = gSwapCodes_AKBP; + TMgTemplateDefinitionArray_Mem[8].swapCodes = gSwapCodes_AKDA; + TMgTemplateDefinitionArray_Mem[9].swapCodes = gSwapCodes_AKEV; + TMgTemplateDefinitionArray_Mem[10].swapCodes = gSwapCodes_AGQC; + TMgTemplateDefinitionArray_Mem[11].swapCodes = gSwapCodes_AGDB; + TMgTemplateDefinitionArray_Mem[12].swapCodes = gSwapCodes_AGQG; + TMgTemplateDefinitionArray_Mem[13].swapCodes = gSwapCodes_AGQM; + TMgTemplateDefinitionArray_Mem[14].swapCodes = gSwapCodes_AGQR; + TMgTemplateDefinitionArray_Mem[15].swapCodes = gSwapCodes_AKOT; + TMgTemplateDefinitionArray_Mem[16].swapCodes = gSwapCodes_OTIT; + TMgTemplateDefinitionArray_Mem[17].swapCodes = gSwapCodes_OTLF; + TMgTemplateDefinitionArray_Mem[18].swapCodes = gSwapCodes_QTNA; + TMgTemplateDefinitionArray_Mem[19].swapCodes = gSwapCodes_BINA; + TMgTemplateDefinitionArray_Mem[20].swapCodes = gSwapCodes_ENVP; + TMgTemplateDefinitionArray_Mem[21].swapCodes = gSwapCodes_FXLR; + TMgTemplateDefinitionArray_Mem[22].swapCodes = gSwapCodes_3CLA; + TMgTemplateDefinitionArray_Mem[23].swapCodes = gSwapCodes_EDIA; + TMgTemplateDefinitionArray_Mem[24].swapCodes = gSwapCodes_M3GM; + TMgTemplateDefinitionArray_Mem[25].swapCodes = gSwapCodes_GMAN; + TMgTemplateDefinitionArray_Mem[26].swapCodes = gSwapCodes_M3GA; + TMgTemplateDefinitionArray_Mem[27].swapCodes = gSwapCodes_PLEA; + TMgTemplateDefinitionArray_Mem[28].swapCodes = gSwapCodes_PNTA; + TMgTemplateDefinitionArray_Mem[29].swapCodes = gSwapCodes_QUDA; + TMgTemplateDefinitionArray_Mem[30].swapCodes = gSwapCodes_TXCA; + TMgTemplateDefinitionArray_Mem[31].swapCodes = gSwapCodes_TXMP; + TMgTemplateDefinitionArray_Mem[32].swapCodes = gSwapCodes_TXAN; + TMgTemplateDefinitionArray_Mem[33].swapCodes = gSwapCodes_TXMA; + TMgTemplateDefinitionArray_Mem[34].swapCodes = gSwapCodes_TXMB; + TMgTemplateDefinitionArray_Mem[35].swapCodes = gSwapCodes_TXPC; + TMgTemplateDefinitionArray_Mem[36].swapCodes = gSwapCodes_M3TA; + TMgTemplateDefinitionArray_Mem[37].swapCodes = gSwapCodes_VCRA; + TMgTemplateDefinitionArray_Mem[38].swapCodes = gSwapCodes_Impt; + TMgTemplateDefinitionArray_Mem[39].swapCodes = gSwapCodes_Mtrl; + TMgTemplateDefinitionArray_Mem[40].swapCodes = gSwapCodes_NMSA; + TMgTemplateDefinitionArray_Mem[41].swapCodes = gSwapCodes_CONS; + TMgTemplateDefinitionArray_Mem[42].swapCodes = gSwapCodes_DOOR; + TMgTemplateDefinitionArray_Mem[43].swapCodes = gSwapCodes_OFGA; + TMgTemplateDefinitionArray_Mem[44].swapCodes = gSwapCodes_OBLS; + TMgTemplateDefinitionArray_Mem[45].swapCodes = gSwapCodes_TRIG; + TMgTemplateDefinitionArray_Mem[46].swapCodes = gSwapCodes_TRGE; + TMgTemplateDefinitionArray_Mem[47].swapCodes = gSwapCodes_TURR; + TMgTemplateDefinitionArray_Mem[48].swapCodes = gSwapCodes_OBAN; + TMgTemplateDefinitionArray_Mem[49].swapCodes = gSwapCodes_OBDC; + TMgTemplateDefinitionArray_Mem[50].swapCodes = gSwapCodes_OBOA; + TMgTemplateDefinitionArray_Mem[51].swapCodes = gSwapCodes_CBPI; + TMgTemplateDefinitionArray_Mem[52].swapCodes = gSwapCodes_CBPM; + TMgTemplateDefinitionArray_Mem[53].swapCodes = gSwapCodes_ONCC; + TMgTemplateDefinitionArray_Mem[54].swapCodes = gSwapCodes_ONIA; + TMgTemplateDefinitionArray_Mem[55].swapCodes = gSwapCodes_ONCP; + TMgTemplateDefinitionArray_Mem[56].swapCodes = gSwapCodes_ONCV; + TMgTemplateDefinitionArray_Mem[57].swapCodes = gSwapCodes_CRSA; + TMgTemplateDefinitionArray_Mem[58].swapCodes = gSwapCodes_DPge; + TMgTemplateDefinitionArray_Mem[59].swapCodes = gSwapCodes_FILM; + TMgTemplateDefinitionArray_Mem[60].swapCodes = gSwapCodes_ONFA; + TMgTemplateDefinitionArray_Mem[61].swapCodes = gSwapCodes_ONGS; + TMgTemplateDefinitionArray_Mem[62].swapCodes = gSwapCodes_HPge; + TMgTemplateDefinitionArray_Mem[63].swapCodes = gSwapCodes_IGHH; + TMgTemplateDefinitionArray_Mem[64].swapCodes = gSwapCodes_IGPG; + TMgTemplateDefinitionArray_Mem[65].swapCodes = gSwapCodes_IGPA; + TMgTemplateDefinitionArray_Mem[66].swapCodes = gSwapCodes_IGSt; + TMgTemplateDefinitionArray_Mem[67].swapCodes = gSwapCodes_IGSA; + TMgTemplateDefinitionArray_Mem[68].swapCodes = gSwapCodes_IPge; + TMgTemplateDefinitionArray_Mem[69].swapCodes = gSwapCodes_KeyI; + TMgTemplateDefinitionArray_Mem[70].swapCodes = gSwapCodes_ONLV; + TMgTemplateDefinitionArray_Mem[71].swapCodes = gSwapCodes_ONLD; + TMgTemplateDefinitionArray_Mem[72].swapCodes = gSwapCodes_ONMA; + TMgTemplateDefinitionArray_Mem[73].swapCodes = gSwapCodes_ONOA; + TMgTemplateDefinitionArray_Mem[74].swapCodes = gSwapCodes_OPge; + TMgTemplateDefinitionArray_Mem[75].swapCodes = gSwapCodes_ONSK; + TMgTemplateDefinitionArray_Mem[76].swapCodes = gSwapCodes_ONSA; + TMgTemplateDefinitionArray_Mem[77].swapCodes = gSwapCodes_TxtC; + TMgTemplateDefinitionArray_Mem[78].swapCodes = gSwapCodes_ONTA; + TMgTemplateDefinitionArray_Mem[79].swapCodes = gSwapCodes_ONVL; + TMgTemplateDefinitionArray_Mem[80].swapCodes = gSwapCodes_WPge; + TMgTemplateDefinitionArray_Mem[81].swapCodes = gSwapCodes_OSBD; + TMgTemplateDefinitionArray_Mem[82].swapCodes = gSwapCodes_PSpc; + TMgTemplateDefinitionArray_Mem[83].swapCodes = gSwapCodes_PSpL; + TMgTemplateDefinitionArray_Mem[84].swapCodes = gSwapCodes_PSUI; + TMgTemplateDefinitionArray_Mem[85].swapCodes = gSwapCodes_SNDD; + TMgTemplateDefinitionArray_Mem[86].swapCodes = gSwapCodes_SUBT; + TMgTemplateDefinitionArray_Mem[87].swapCodes = gSwapCodes_UUEA; + TMgTemplateDefinitionArray_Mem[88].swapCodes = gSwapCodes_TMFA; + TMgTemplateDefinitionArray_Mem[89].swapCodes = gSwapCodes_IDXA; + TMgTemplateDefinitionArray_Mem[90].swapCodes = gSwapCodes_TStr; + TMgTemplateDefinitionArray_Mem[91].swapCodes = gSwapCodes_StNA; + TMgTemplateDefinitionArray_Mem[92].swapCodes = gSwapCodes_TMRA; + TMgTemplateDefinitionArray_Mem[93].swapCodes = gSwapCodes_TRAS; + TMgTemplateDefinitionArray_Mem[94].swapCodes = gSwapCodes_TRAM; + TMgTemplateDefinitionArray_Mem[95].swapCodes = gSwapCodes_TRAC; + TMgTemplateDefinitionArray_Mem[96].swapCodes = gSwapCodes_TRCM; + TMgTemplateDefinitionArray_Mem[97].swapCodes = gSwapCodes_TRBS; + TMgTemplateDefinitionArray_Mem[98].swapCodes = gSwapCodes_TRMA; + TMgTemplateDefinitionArray_Mem[99].swapCodes = gSwapCodes_TRFT; + TMgTemplateDefinitionArray_Mem[100].swapCodes = gSwapCodes_TRGA; + TMgTemplateDefinitionArray_Mem[101].swapCodes = gSwapCodes_TRIA; + TMgTemplateDefinitionArray_Mem[102].swapCodes = gSwapCodes_TRSC; + TMgTemplateDefinitionArray_Mem[103].swapCodes = gSwapCodes_TRTA; + TMgTemplateDefinitionArray_Mem[104].swapCodes = gSwapCodes_TSFT; + TMgTemplateDefinitionArray_Mem[105].swapCodes = gSwapCodes_TSFF; + TMgTemplateDefinitionArray_Mem[106].swapCodes = gSwapCodes_TSFL; + TMgTemplateDefinitionArray_Mem[107].swapCodes = gSwapCodes_TSGA; + TMgTemplateDefinitionArray_Mem[108].swapCodes = gSwapCodes_UVDL; + TMgTemplateDefinitionArray_Mem[109].swapCodes = gSwapCodes_WMCL; + TMgTemplateDefinitionArray_Mem[110].swapCodes = gSwapCodes_WMDD; + TMgTemplateDefinitionArray_Mem[111].swapCodes = gSwapCodes_WMMB; + TMgTemplateDefinitionArray_Mem[112].swapCodes = gSwapCodes_WMM_; + TMgTemplateDefinitionArray_Mem[113].swapCodes = gSwapCodes_ONWC; + TMgTemplateDefinitionArray = TMgTemplateDefinitionArray_Mem; +} From 3a8e7f14327df10c8d0430f95ea2d70cf59a86d8 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Mon, 2 Feb 2026 17:53:20 +0100 Subject: [PATCH 4/5] Use PRI[us]64 to print 64-bit integers on gcc compilers --- BungieFrameWork/BFW_Headers/BFW.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BungieFrameWork/BFW_Headers/BFW.h b/BungieFrameWork/BFW_Headers/BFW.h index 194baa4..d68cc31 100644 --- a/BungieFrameWork/BFW_Headers/BFW.h +++ b/BungieFrameWork/BFW_Headers/BFW.h @@ -317,6 +317,7 @@ extern "C" { */ #if UUmCompiler_GCC + #include #include typedef int8_t UUtInt8; @@ -328,8 +329,8 @@ extern "C" { typedef int64_t UUtInt64; typedef uint64_t UUtUns64; - #define UUmFS_UUtUns64 "%qu" - #define UUmFS_UUtInt64 "%qd" + #define UUmFS_UUtUns64 "%" PRIu64 + #define UUmFS_UUtInt64 "%" PRIs64 #else typedef unsigned long UUtUns32; typedef long UUtInt32; From 2706814a8974007446485efbaacb3f5b0489cbf3 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Mon, 2 Feb 2026 18:13:54 +0100 Subject: [PATCH 5/5] Remove all trailing spaces and ensure trailing newline --- BungieFrameWork/BFW_Headers/BFW.h | 466 +- BungieFrameWork/BFW_Headers/BFW_Akira.h | 160 +- .../BFW_Headers/BFW_AppUtilities.h | 140 +- BungieFrameWork/BFW_Headers/BFW_BinaryData.h | 14 +- BungieFrameWork/BFW_Headers/BFW_Bink.h | 2 +- BungieFrameWork/BFW_Headers/BFW_BitVector.h | 14 +- BungieFrameWork/BFW_Headers/BFW_Collision.h | 32 +- BungieFrameWork/BFW_Headers/BFW_CommandLine.h | 2 +- BungieFrameWork/BFW_Headers/BFW_Console.h | 12 +- .../BFW_Headers/BFW_DebuggerSymbols.h | 54 +- .../BFW_Headers/BFW_DialogManager.h | 34 +- BungieFrameWork/BFW_Headers/BFW_Doors.h | 10 +- BungieFrameWork/BFW_Headers/BFW_Effect.h | 16 +- BungieFrameWork/BFW_Headers/BFW_EnvParticle.h | 12 +- BungieFrameWork/BFW_Headers/BFW_ErrorCodes.h | 16 +- BungieFrameWork/BFW_Headers/BFW_FileFormat.h | 8 +- BungieFrameWork/BFW_Headers/BFW_FileManager.h | 60 +- BungieFrameWork/BFW_Headers/BFW_Group.h | 20 +- BungieFrameWork/BFW_Headers/BFW_Image.h | 72 +- BungieFrameWork/BFW_Headers/BFW_LocalInput.h | 62 +- .../BFW_Headers/BFW_MasterHeader.h | 10 +- BungieFrameWork/BFW_Headers/BFW_Materials.h | 16 +- BungieFrameWork/BFW_Headers/BFW_MathLib.h | 118 +- BungieFrameWork/BFW_Headers/BFW_Motoko.h | 780 +-- .../BFW_Headers/BFW_NetworkManager.h | 36 +- BungieFrameWork/BFW_Headers/BFW_Object.h | 20 +- BungieFrameWork/BFW_Headers/BFW_Particle.h | 2 +- BungieFrameWork/BFW_Headers/BFW_Particle3.h | 24 +- BungieFrameWork/BFW_Headers/BFW_Path.h | 40 +- BungieFrameWork/BFW_Headers/BFW_Physics.h | 30 +- .../BFW_Headers/BFW_Platform_AltiVec.h | 8 +- BungieFrameWork/BFW_Headers/BFW_Ranma.h | 8 +- BungieFrameWork/BFW_Headers/BFW_RedPig.h | 2 +- BungieFrameWork/BFW_Headers/BFW_ScriptLang.h | 58 +- .../BFW_Headers/BFW_SoundSystem2.h | 180 +- .../BFW_Headers/BFW_TemplateManager.h | 106 +- BungieFrameWork/BFW_Headers/BFW_TextSystem.h | 86 +- BungieFrameWork/BFW_Headers/BFW_Timer.h | 12 +- BungieFrameWork/BFW_Headers/BFW_Totoro.h | 46 +- BungieFrameWork/BFW_Headers/BFW_Types.h | 10 +- BungieFrameWork/BFW_Headers/BFW_Util_BSP.h | 18 +- BungieFrameWork/BFW_Headers/BFW_ViewManager.h | 106 +- .../BFW_Source/BFW_Akira/Akira_Private.h | 20 +- .../BFW_Source/BFW_Akira/BFW_Akira.c | 200 +- .../BFW_Akira/BFW_Akira_Collision.c | 642 +-- .../BFW_Source/BFW_Akira/BFW_Akira_Render.c | 708 +-- .../BFW_Akira/BFW_Akira_Render_AltiVec.c | 390 +- .../BFW_Source/BFW_Akira/BFW_Akira_Template.c | 30 +- .../BFW_AppUtilities/BFW_AppUtilities.c | 698 +-- .../BFW_BinaryData/BFW_BinaryData.c | 58 +- .../BFW_BinaryData/BFW_BinaryData_Template.c | 4 +- .../BFW_Source/BFW_Bink/BFW_Bink.c | 2 +- .../BFW_Source/BFW_Bink/BinkHeaders/Rad.h | 88 +- .../BFW_Source/BFW_Collision/BFW_Collision.c | 602 +- .../BFW_CommandLine/BFW_CommandLine.c | 2 +- .../Platform_MacOS/BFW_CL_Platform_MacOS.c | 170 +- .../Platform_MacOS/BFW_CL_Platform_MacOS.h | 2 +- .../Platform_Win32/BFW_CL_Platform_Win32.c | 50 +- .../Platform_Win32/BFW_CL_Platform_Win32.h | 2 +- .../Platform_Win32/BFW_CL_Resource.h | 2 +- .../BFW_Source/BFW_Console/BFW_Console.c | 220 +- .../BFW_Console/BFW_ConsoleVariable.h | 2 +- .../BFW_DebuggerSymbols_MacOS.c | 116 +- .../BFW_DebuggerSymbols_Win32.c | 12 +- .../BFW_DebuggerSymbols/stack_walk_windows.c | 32 +- .../BFW_DialogManager/BFW_DMVM_Templates.c | 10 +- .../BFW_DialogManager/BFW_DialogManager.c | 256 +- .../BFW_DialogManager/BFW_ViewManager.c | 268 +- .../BFW_DialogManager/BFW_ViewUtilities.c | 110 +- .../BFW_DialogManager/BFW_ViewUtilities.h | 8 +- .../DM_Cursor/DM_DialogCursor.c | 48 +- .../DM_Cursor/DM_DialogCursor.h | 30 +- .../BFW_DialogManager/VM_Views/VM_View_Box.c | 6 +- .../BFW_DialogManager/VM_Views/VM_View_Box.h | 6 +- .../VM_Views/VM_View_Button.c | 76 +- .../VM_Views/VM_View_Button.h | 16 +- .../VM_Views/VM_View_CheckBox.c | 38 +- .../VM_Views/VM_View_CheckBox.h | 14 +- .../VM_Views/VM_View_Dialog.c | 40 +- .../VM_Views/VM_View_Dialog.h | 20 +- .../VM_Views/VM_View_EditField.c | 126 +- .../VM_Views/VM_View_EditField.h | 20 +- .../VM_Views/VM_View_ListBox.c | 274 +- .../VM_Views/VM_View_ListBox.h | 14 +- .../VM_Views/VM_View_Picture.c | 12 +- .../VM_Views/VM_View_Picture.h | 8 +- .../VM_Views/VM_View_RadioButton.c | 40 +- .../VM_Views/VM_View_RadioButton.h | 14 +- .../VM_Views/VM_View_RadioGroup.c | 38 +- .../VM_Views/VM_View_RadioGroup.h | 8 +- .../VM_Views/VM_View_Scrollbar.c | 186 +- .../VM_Views/VM_View_Scrollbar.h | 18 +- .../VM_Views/VM_View_Slider.c | 76 +- .../VM_Views/VM_View_Slider.h | 14 +- .../BFW_DialogManager/VM_Views/VM_View_Tab.c | 80 +- .../BFW_DialogManager/VM_Views/VM_View_Tab.h | 16 +- .../VM_Views/VM_View_TabGroup.c | 50 +- .../VM_Views/VM_View_TabGroup.h | 4 +- .../BFW_DialogManager/VM_Views/VM_View_Text.c | 58 +- .../BFW_DialogManager/VM_Views/VM_View_Text.h | 14 +- .../BFW_Source/BFW_Effect/BFW_Effect.c | 8 +- .../BFW_Effect/BFW_Effect_Private.h | 8 +- .../BFW_FileFormat/BFW_FileFormat.c | 34 +- .../BFW_FileFormat/BMP/BFW_FF_BMP.c | 202 +- .../BFW_FileFormat/BMP/BFW_FF_BMP.h | 12 +- .../BFW_FileFormat/BMP/BFW_FF_BMP_Priv.h | 28 +- .../BFW_FileFormat/DDS/BFW_FF_DDS.c | 74 +- .../BFW_FileFormat/DDS/BFW_FF_DDS.h | 12 +- .../BFW_FileFormat/DDS/BFW_FF_DDS_Priv.h | 18 +- .../BFW_FileFormat/PSD/BFW_FF_PSD.c | 308 +- .../BFW_FileFormat/PSD/BFW_FF_PSD.h | 12 +- .../BFW_FileFormat/PSD/BFW_FF_PSD_Priv.h | 28 +- .../BFW_FileManager/BFW_FileManager_Common.c | 228 +- .../Platform_Linux/BFW_FileManager_Linux.c | 212 +- .../Platform_MacOS/BFW_FileManager_MacOS.c | 372 +- .../Platform_MacOS/MoreFiles/DirectoryCopy.c | 82 +- .../Platform_MacOS/MoreFiles/DirectoryCopy.h | 46 +- .../Platform_MacOS/MoreFiles/FSpCompat.c | 100 +- .../Platform_MacOS/MoreFiles/FSpCompat.h | 334 +- .../Platform_MacOS/MoreFiles/FileCopy.c | 60 +- .../Platform_MacOS/MoreFiles/FileCopy.h | 16 +- .../Platform_MacOS/MoreFiles/FullPath.c | 48 +- .../Platform_MacOS/MoreFiles/FullPath.h | 54 +- .../MoreFiles/IterateDirectory.c | 28 +- .../MoreFiles/IterateDirectory.h | 28 +- .../Platform_MacOS/MoreFiles/MoreDesktopMgr.c | 130 +- .../Platform_MacOS/MoreFiles/MoreDesktopMgr.h | 102 +- .../Platform_MacOS/MoreFiles/MoreFiles.c | 12 +- .../Platform_MacOS/MoreFiles/MoreFiles.h | 302 +- .../MoreFiles/MoreFilesExtras.c | 418 +- .../MoreFiles/MoreFilesExtras.h | 608 +-- .../Platform_MacOS/MoreFiles/Optimization.h | 4 +- .../Platform_MacOS/MoreFiles/PascalElim.h | 2 +- .../Platform_MacOS/MoreFiles/Search.c | 204 +- .../Platform_MacOS/MoreFiles/Search.h | 32 +- .../Platform_Win32/BFW_FileManager_Win32.c | 272 +- .../BFW_Source/BFW_Group/BFW_Group.c | 236 +- .../BFW_Source/BFW_Image/BFW_Image.c | 314 +- .../BFW_Source/BFW_Image/BFW_Image_Dither.c | 54 +- .../BFW_Source/BFW_Image/BFW_Image_Draw.c | 50 +- .../BFW_Image/BFW_Image_PixelConversion.c | 420 +- .../BFW_Source/BFW_Image/BFW_Image_Private.h | 12 +- .../BFW_Image/BFW_Image_Scale_Box.c | 1014 ++-- .../BFW_LocalInput/BFW_LI_Platform.h | 4 +- .../BFW_LocalInput/BFW_LI_Translators.c | 28 +- .../BFW_LocalInput/BFW_LocalInput.c | 226 +- .../BFW_LocalInput/BFW_LocalInput_Template.c | 8 +- .../Platform_MacOS/BFW_LI_Platform_MacOS.c | 242 +- .../Platform_SDL/BFW_LI_Platform_SDL.c | 66 +- .../Platform_Win32/BFW_LI_Platform_Win32.c | 122 +- .../Platform_Win32/BFW_LI_Platform_Win32.h | 2 +- .../BFW_Source/BFW_Materials/BFW_Materials.c | 58 +- .../BFW_Source/BFW_MathLib/BFW_MathLib.c | 388 +- .../BFW_MathLib/BFW_MathLib_Matrix.c | 362 +- .../BFW_Source/BFW_MathLib/EulerAngles.c | 88 +- .../BFW_Source/BFW_MathLib/EulerAngles.h | 20 +- .../BFW_Source/BFW_MathLib/bfw_math.c | 54 +- .../BFW_Source/BFW_MathLib/bfw_math.h | 2 +- .../BFW_Source/BFW_MathLib/bfw_math_3dnow.c | 2 +- .../BFW_Source/BFW_MathLib/bfw_math_stdc.c | 22 +- .../3DFX_Glide/MG_DC_CreateVertex.c | 224 +- .../3DFX_Glide/MG_DC_CreateVertex.h | 10 +- .../3DFX_Glide/MG_DC_Method_Bitmap.c | 30 +- .../3DFX_Glide/MG_DC_Method_Bitmap.h | 12 +- .../3DFX_Glide/MG_DC_Method_Frame.h | 10 +- .../3DFX_Glide/MG_DC_Method_LinePoint.c | 22 +- .../3DFX_Glide/MG_DC_Method_LinePoint.h | 16 +- .../DrawEngine/3DFX_Glide/MG_DC_Method_Pent.c | 100 +- .../DrawEngine/3DFX_Glide/MG_DC_Method_Pent.h | 28 +- .../DrawEngine/3DFX_Glide/MG_DC_Method_Quad.c | 110 +- .../DrawEngine/3DFX_Glide/MG_DC_Method_Quad.h | 26 +- .../3DFX_Glide/MG_DC_Method_Query.h | 2 +- .../3DFX_Glide/MG_DC_Method_SmallQuad.h | 20 +- .../3DFX_Glide/MG_DC_Method_State.h | 10 +- .../3DFX_Glide/MG_DC_Method_Triangle.c | 100 +- .../3DFX_Glide/MG_DC_Method_Triangle.h | 54 +- .../DrawEngine/3DFX_Glide/MG_DC_Mode.c | 10 +- .../DrawEngine/3DFX_Glide/MG_DC_Mode.h | 10 +- .../DrawEngine/3DFX_Glide/MG_DC_Private.h | 56 +- .../3DFX_Glide/MG_DrawEngine_Method.c | 188 +- .../3DFX_Glide/MG_DrawEngine_Method.h | 8 +- .../3DFX_Glide/MG_DrawEngine_Method_Ptrs.c | 432 +- .../3DFX_Glide/MG_DrawEngine_Method_Ptrs.h | 10 +- .../3DFX_Glide/MG_DrawEngine_Platform.h | 12 +- .../DrawEngine/3DFX_Glide/MG_Polygon.c | 10 +- .../DrawEngine/3DFX_Glide/MG_Polygon.h | 24 +- .../DrawEngine/3DFX_Glide/lrar_cache.c | 46 +- .../DrawEngine/3DFX_Glide/lrar_cache2.c | 48 +- .../DrawEngine/3DFX_Glide/rasterizer_3dfx.c | 110 +- .../DrawEngine/3DFX_Glide/rasterizer_3dfx.h | 16 +- .../DrawEngine/Direct3D/MD_DC_Method_Bitmap.c | 32 +- .../DrawEngine/Direct3D/MD_DC_Method_Bitmap.h | 10 +- .../DrawEngine/Direct3D/MD_DC_Method_Frame.h | 10 +- .../Direct3D/MD_DC_Method_LinePoint.c | 154 +- .../Direct3D/MD_DC_Method_LinePoint.h | 16 +- .../DrawEngine/Direct3D/MD_DC_Method_Pent.c | 10 +- .../DrawEngine/Direct3D/MD_DC_Method_Pent.h | 16 +- .../DrawEngine/Direct3D/MD_DC_Method_Quad.c | 16 +- .../DrawEngine/Direct3D/MD_DC_Method_Quad.h | 16 +- .../DrawEngine/Direct3D/MD_DC_Method_Query.c | 18 +- .../DrawEngine/Direct3D/MD_DC_Method_Query.h | 2 +- .../Direct3D/MD_DC_Method_SmallQuad.c | 16 +- .../Direct3D/MD_DC_Method_SmallQuad.h | 16 +- .../DrawEngine/Direct3D/MD_DC_Method_State.c | 52 +- .../DrawEngine/Direct3D/MD_DC_Method_State.h | 10 +- .../Direct3D/MD_DC_Method_Triangle.c | 86 +- .../Direct3D/MD_DC_Method_Triangle.h | 16 +- .../DrawEngine/Direct3D/MD_DC_Private.h | 24 +- .../Direct3D/MD_DrawEngine_Method.c | 406 +- .../Direct3D/MD_DrawEngine_Method.h | 8 +- .../Direct3D/MD_DrawEngine_Platform.h | 12 +- .../EmptyEngine/EM_DC_Method_Bitmap.c | 10 +- .../EmptyEngine/EM_DC_Method_Bitmap.h | 12 +- .../EmptyEngine/EM_DC_Method_Frame.h | 10 +- .../EmptyEngine/EM_DC_Method_LinePoint.c | 10 +- .../EmptyEngine/EM_DC_Method_LinePoint.h | 16 +- .../EmptyEngine/EM_DC_Method_Pent.c | 4 +- .../EmptyEngine/EM_DC_Method_Pent.h | 10 +- .../EmptyEngine/EM_DC_Method_Quad.c | 10 +- .../EmptyEngine/EM_DC_Method_Quad.h | 10 +- .../EmptyEngine/EM_DC_Method_Query.h | 2 +- .../EmptyEngine/EM_DC_Method_State.c | 16 +- .../EmptyEngine/EM_DC_Method_State.h | 10 +- .../EmptyEngine/EM_DC_Method_Triangle.c | 10 +- .../EmptyEngine/EM_DC_Method_Triangle.h | 10 +- .../DrawEngine/EmptyEngine/EM_DC_Private.h | 14 +- .../EmptyEngine/EM_DrawEngine_Method.c | 34 +- .../EmptyEngine/EM_DrawEngine_Method.h | 8 +- .../EmptyEngine/EM_DrawEngine_Platform.h | 12 +- .../Engines/DrawEngine/OpenGL/GL_DC_Private.h | 16 +- .../DrawEngine/OpenGL/GL_DrawEngine_Method.c | 118 +- .../DrawEngine/OpenGL/GL_DrawEngine_Method.h | 8 +- .../DrawEngine/OpenGL/GL_Draw_Functions.c | 148 +- .../DrawEngine/OpenGL/GL_Draw_Functions.h | 16 +- .../Engines/DrawEngine/OpenGL/GL_Platform.h | 8 +- .../DrawEngine/OpenGL/GL_Platform_MacOS.c | 22 +- .../DrawEngine/OpenGL/GL_Platform_Windows.c | 44 +- .../DrawEngine/OpenGL/GL_Utility_Functions.c | 16 +- .../DrawEngine/OpenGL/GL_Utility_Functions.h | 10 +- .../Engines/DrawEngine/OpenGL/gl_engine.c | 68 +- .../Engines/DrawEngine/OpenGL/gl_engine.h | 16 +- .../OpenGL/gl_geometry_draw_method.c | 4 +- .../Engines/DrawEngine/OpenGL/gl_macos.c | 192 +- .../Engines/DrawEngine/OpenGL/gl_mswindows.c | 30 +- .../Engines/DrawEngine/OpenGL/gl_sdl.c | 12 +- .../Engines/DrawEngine/OpenGL/gl_utility.c | 156 +- .../Engines/DrawEngine/OpenGL/glext.h | 8 +- .../DrawEngine/RAVE/RV_DC_Method_Bitmap.c | 22 +- .../DrawEngine/RAVE/RV_DC_Method_Bitmap.h | 12 +- .../DrawEngine/RAVE/RV_DC_Method_Frame.h | 10 +- .../DrawEngine/RAVE/RV_DC_Method_LinePoint.c | 10 +- .../DrawEngine/RAVE/RV_DC_Method_LinePoint.h | 16 +- .../DrawEngine/RAVE/RV_DC_Method_Pent.c | 4 +- .../DrawEngine/RAVE/RV_DC_Method_Pent.h | 10 +- .../DrawEngine/RAVE/RV_DC_Method_Quad.c | 10 +- .../DrawEngine/RAVE/RV_DC_Method_Quad.h | 10 +- .../DrawEngine/RAVE/RV_DC_Method_Query.h | 2 +- .../DrawEngine/RAVE/RV_DC_Method_SmallQuad.c | 20 +- .../DrawEngine/RAVE/RV_DC_Method_SmallQuad.h | 18 +- .../DrawEngine/RAVE/RV_DC_Method_State.c | 18 +- .../DrawEngine/RAVE/RV_DC_Method_State.h | 10 +- .../DrawEngine/RAVE/RV_DC_Method_Triangle.c | 10 +- .../DrawEngine/RAVE/RV_DC_Method_Triangle.h | 10 +- .../Engines/DrawEngine/RAVE/RV_DC_Private.h | 20 +- .../DrawEngine/RAVE/RV_DrawEngine_Method.c | 160 +- .../DrawEngine/RAVE/RV_DrawEngine_Method.h | 8 +- .../DrawEngine/RAVE/RV_DrawEngine_Platform.h | 12 +- .../DrawEngine/Software/MS_DC_Method_Bitmap.c | 52 +- .../DrawEngine/Software/MS_DC_Method_Bitmap.h | 12 +- .../DrawEngine/Software/MS_DC_Method_Frame.h | 10 +- .../Software/MS_DC_Method_LinePoint.c | 154 +- .../Software/MS_DC_Method_LinePoint.h | 16 +- .../DrawEngine/Software/MS_DC_Method_Pent.c | 10 +- .../DrawEngine/Software/MS_DC_Method_Pent.h | 16 +- .../DrawEngine/Software/MS_DC_Method_Quad.c | 16 +- .../DrawEngine/Software/MS_DC_Method_Quad.h | 16 +- .../DrawEngine/Software/MS_DC_Method_Query.c | 8 +- .../DrawEngine/Software/MS_DC_Method_Query.h | 4 +- .../Software/MS_DC_Method_SmallQuad.c | 16 +- .../Software/MS_DC_Method_SmallQuad.h | 16 +- .../DrawEngine/Software/MS_DC_Method_State.c | 54 +- .../DrawEngine/Software/MS_DC_Method_State.h | 10 +- .../Software/MS_DC_Method_Triangle.c | 10 +- .../Software/MS_DC_Method_Triangle.h | 16 +- .../DrawEngine/Software/MS_DC_Private.h | 40 +- .../Software/MS_DrawEngine_Method.c | 166 +- .../Software/MS_DrawEngine_Method.h | 8 +- .../Software/MS_DrawEngine_Platform.h | 12 +- .../Platform_MacOS/MS_DC_Platform_Mac.c | 64 +- .../MS_DrawEngine_Platform_Mac.c | 132 +- .../Platform_MacOS/MS_Mac_CustomProc.c | 240 +- .../Platform_MacOS/MS_Mac_CustomProc.h | 8 +- .../Software/Platform_MacOS/MS_Mac_PPCAsm.c | 78 +- .../Software/Platform_MacOS/MS_Mac_PPCAsm.h | 8 +- .../Platform_Win32/MS_Platform_Win32.c | 142 +- .../EmptyGeomEngine/EM_GC_Method_Camera.c | 10 +- .../EmptyGeomEngine/EM_GC_Method_Camera.h | 10 +- .../EmptyGeomEngine/EM_GC_Method_Env.c | 12 +- .../EmptyGeomEngine/EM_GC_Method_Env.h | 12 +- .../EmptyGeomEngine/EM_GC_Method_Frame.c | 12 +- .../EmptyGeomEngine/EM_GC_Method_Frame.h | 10 +- .../EmptyGeomEngine/EM_GC_Method_Geometry.c | 24 +- .../EmptyGeomEngine/EM_GC_Method_Geometry.h | 18 +- .../EmptyGeomEngine/EM_GC_Method_Light.c | 10 +- .../EmptyGeomEngine/EM_GC_Method_Light.h | 10 +- .../EmptyGeomEngine/EM_GC_Method_Matrix.c | 32 +- .../EmptyGeomEngine/EM_GC_Method_Matrix.h | 26 +- .../EmptyGeomEngine/EM_GC_Method_Pick.c | 10 +- .../EmptyGeomEngine/EM_GC_Method_Pick.h | 10 +- .../EmptyGeomEngine/EM_GC_Method_State.c | 16 +- .../EmptyGeomEngine/EM_GC_Method_State.h | 10 +- .../EmptyGeomEngine/EM_GC_Private.h | 10 +- .../EmptyGeomEngine/EM_GeomEngine_Method.c | 12 +- .../EmptyGeomEngine/EM_GeomEngine_Method.h | 8 +- .../GeomOpenGL/OG_GC_Method_Camera.c | 14 +- .../GeomOpenGL/OG_GC_Method_Camera.h | 10 +- .../GeomEngine/GeomOpenGL/OG_GC_Method_Env.c | 68 +- .../GeomEngine/GeomOpenGL/OG_GC_Method_Env.h | 12 +- .../GeomOpenGL/OG_GC_Method_Frame.c | 12 +- .../GeomOpenGL/OG_GC_Method_Frame.h | 10 +- .../GeomOpenGL/OG_GC_Method_Geometry.c | 70 +- .../GeomOpenGL/OG_GC_Method_Geometry.h | 20 +- .../GeomOpenGL/OG_GC_Method_Light.c | 10 +- .../GeomOpenGL/OG_GC_Method_Light.h | 10 +- .../GeomOpenGL/OG_GC_Method_Matrix.c | 10 +- .../GeomOpenGL/OG_GC_Method_Matrix.h | 26 +- .../GeomEngine/GeomOpenGL/OG_GC_Method_Pick.c | 10 +- .../GeomEngine/GeomOpenGL/OG_GC_Method_Pick.h | 10 +- .../GeomOpenGL/OG_GC_Method_State.c | 16 +- .../GeomOpenGL/OG_GC_Method_State.h | 10 +- .../GeomEngine/GeomOpenGL/OG_GC_Private.h | 18 +- .../GeomOpenGL/OG_GeomEngine_Method.c | 84 +- .../GeomOpenGL/OG_GeomEngine_Method.h | 8 +- .../GeomEngine/Software/MS_GC_Env_Clip.c | 1020 ++-- .../GeomEngine/Software/MS_GC_Env_Clip.h | 10 +- .../Software/MS_GC_Method_AltiVec.c | 62 +- .../Software/MS_GC_Method_AltiVec.h | 8 +- .../GeomEngine/Software/MS_GC_Method_Camera.h | 12 +- .../GeomEngine/Software/MS_GC_Method_Env.c | 108 +- .../GeomEngine/Software/MS_GC_Method_Env.h | 12 +- .../GeomEngine/Software/MS_GC_Method_Frame.c | 18 +- .../GeomEngine/Software/MS_GC_Method_Frame.h | 10 +- .../Software/MS_GC_Method_Geometry.c | 606 +-- .../Software/MS_GC_Method_Geometry.h | 22 +- .../GeomEngine/Software/MS_GC_Method_Light.c | 38 +- .../GeomEngine/Software/MS_GC_Method_Light.h | 10 +- .../GeomEngine/Software/MS_GC_Method_Matrix.c | 76 +- .../GeomEngine/Software/MS_GC_Method_Matrix.h | 26 +- .../GeomEngine/Software/MS_GC_Method_Pick.c | 38 +- .../GeomEngine/Software/MS_GC_Method_Pick.h | 10 +- .../GeomEngine/Software/MS_GC_Method_State.c | 90 +- .../GeomEngine/Software/MS_GC_Method_State.h | 10 +- .../GeomEngine/Software/MS_GC_Private.h | 86 +- .../Software/MS_GeomEngine_Method.c | 188 +- .../Software/MS_GeomEngine_Method.h | 8 +- .../GeomEngine/Software/MS_Geom_Clip.c | 1844 +++---- .../GeomEngine/Software/MS_Geom_Clip.h | 40 +- .../GeomEngine/Software/MS_Geom_Shade.c | 104 +- .../GeomEngine/Software/MS_Geom_Shade.h | 8 +- .../Software/MS_Geom_Shade_AltiVec.c | 172 +- .../Software/MS_Geom_Shade_AltiVec.h | 8 +- .../GeomEngine/Software/MS_Geom_Transform.c | 298 +- .../GeomEngine/Software/MS_Geom_Transform.h | 8 +- .../Software/MS_Geom_Transform_AltiVec.c | 606 +-- .../Software/MS_Geom_Transform_AltiVec.h | 14 +- .../Engines/OGL_Common/OGL_DrawGeom_Common.c | 224 +- .../Engines/OGL_Common/OGL_DrawGeom_Common.h | 26 +- .../OGL_Common/OGL_DrawGeom_Platform.h | 10 +- .../OGL_Common/OGL_DrawGeom_Platform_MacOS.c | 16 +- .../OGL_Common/OGL_DrawGeom_Platform_Win32.c | 10 +- .../AltiVec/Motoko_SIMDCache_AltiVec.c | 14 +- .../AltiVec/Motoko_SIMDCache_AltiVec.h | 8 +- .../BFW_Motoko/Manager/BFW_Motoko_Template.c | 10 +- .../BFW_Motoko/Manager/Motoko_Draw.c | 44 +- .../BFW_Motoko/Manager/Motoko_Geom.c | 152 +- .../BFW_Motoko/Manager/Motoko_Geom_Camera.c | 480 +- .../BFW_Motoko/Manager/Motoko_Geom_Matrix.c | 58 +- .../BFW_Motoko/Manager/Motoko_Manager.c | 168 +- .../BFW_Motoko/Manager/Motoko_Manager.h | 108 +- .../BFW_Motoko/Manager/Motoko_Private.h | 22 +- .../BFW_Motoko/Manager/Motoko_Sort.c | 190 +- .../BFW_Motoko/Manager/Motoko_Sort.h | 14 +- .../BFW_Motoko/Manager/Motoko_State_Draw.c | 92 +- .../BFW_Motoko/Manager/Motoko_State_Geom.c | 64 +- .../BFW_Motoko/Manager/Motoko_Texture.c | 150 +- .../BFW_Motoko/Manager/Motoko_Utility.c | 116 +- .../BFW_Motoko/Manager/Motoko_Verify.c | 18 +- .../BFW_Motoko/Manager/Motoko_Verify.h | 8 +- .../BFW_Motoko/Manager/Win32/DriverManager.c | 306 +- .../BFW_NetworkManager/BFW_NetworkManager.c | 36 +- .../NM_OpenTransport/NM_OpenTransport.c | 160 +- .../NM_OpenTransport/NM_OpenTransport.h | 2 +- .../NM_OpenTransport_Private.h | 4 +- .../BFW_NetworkManager/NM_Queues/NM_Queues.c | 84 +- .../BFW_NetworkManager/NM_Queues/NM_Queues.h | 14 +- .../NM_WinSock/NM_WinSock.c | 138 +- .../NM_WinSock/NM_WinSock.h | 4 +- .../NM_WinSock/NM_WinSock_Private.h | 4 +- .../BFW_Source/BFW_Object/BFW_Doors.c | 56 +- .../BFW_Source/BFW_Object/BFW_Object.c | 108 +- .../BFW_Object/BFW_Object_Templates.h | 32 +- .../BFW_Source/BFW_Object/BFW_Physics.c | 132 +- .../BFW_Source/BFW_Particle/BFW_Decal.c | 28 +- .../BFW_Source/BFW_Particle/BFW_EnvParticle.c | 66 +- .../BFW_Source/BFW_Particle/BFW_Particle3.c | 672 +-- .../BFW_Source/BFW_Path/BFW_Path.c | 152 +- .../BFW_ScriptLang/BFW_ScriptLang.c | 106 +- .../BFW_ScriptLang/BFW_ScriptLang_Context.c | 16 +- .../BFW_ScriptLang/BFW_ScriptLang_Context.h | 10 +- .../BFW_ScriptLang/BFW_ScriptLang_Database.c | 324 +- .../BFW_ScriptLang/BFW_ScriptLang_Database.h | 10 +- .../BFW_ScriptLang/BFW_ScriptLang_Error.c | 52 +- .../BFW_ScriptLang/BFW_ScriptLang_Error.h | 14 +- .../BFW_ScriptLang/BFW_ScriptLang_Eval.c | 76 +- .../BFW_ScriptLang/BFW_ScriptLang_Eval.h | 16 +- .../BFW_ScriptLang/BFW_ScriptLang_Expr.c | 204 +- .../BFW_ScriptLang/BFW_ScriptLang_Expr.h | 34 +- .../BFW_ScriptLang/BFW_ScriptLang_Parse.c | 444 +- .../BFW_ScriptLang/BFW_ScriptLang_Parse.h | 20 +- .../BFW_ScriptLang/BFW_ScriptLang_Private.h | 92 +- .../BFW_ScriptLang/BFW_ScriptLang_Scheduler.c | 162 +- .../BFW_ScriptLang/BFW_ScriptLang_Scheduler.h | 12 +- .../BFW_ScriptLang/BFW_ScriptLang_Token.c | 226 +- .../BFW_ScriptLang/BFW_ScriptLang_Token.h | 10 +- .../BFW_Source/BFW_Shared/BFW_Shared_Camera.h | 16 +- .../BFW_Source/BFW_Shared/BFW_Shared_Clip.c | 32 +- .../BFW_Source/BFW_Shared/BFW_Shared_Clip.h | 24 +- .../BFW_Shared/BFW_Shared_ClipCompPoint_c.h | 178 +- .../BFW_Shared/BFW_Shared_ClipPoly_c.h | 2132 ++++---- .../BFW_Source/BFW_Shared/BFW_Shared_Math.c | 10 +- .../BFW_Source/BFW_Shared/BFW_Shared_Math.h | 42 +- .../BFW_Shared/BFW_Shared_TriRaster.h | 10 +- .../BFW_Shared/BFW_Shared_TriRaster_c.h | 902 +-- .../BFW_SS2_RegisterTemplate.c | 4 +- .../BFW_SoundSystem/BFW_SS_Private.h | 4 +- .../Platform_MacOS/BFW_SS_Platform_MacOS.c | 108 +- .../Platform_MacOS/BFW_SS_Platform_MacOS.h | 2 +- .../BFW_Source/BFW_SoundSystem2/BFW_SS2_IMA.c | 168 +- .../BFW_Source/BFW_SoundSystem2/BFW_SS2_IMA.h | 4 +- .../BFW_SoundSystem2/BFW_SS2_MSADPCM.c | 46 +- .../BFW_SoundSystem2/BFW_SS2_MSADPCM.h | 2 +- .../BFW_SoundSystem2/BFW_SS2_Platform.h | 28 +- .../BFW_SoundSystem2/BFW_SS2_Private.h | 22 +- .../BFW_SS2_RegisterTemplate.c | 4 +- .../BFW_SoundSystem2/BFW_SoundSystem2.c | 1402 ++--- .../Platform_MacOS/BFW_SS2_Platform_MacOS.c | 108 +- .../Platform_MacOS/BFW_SS2_Platform_MacOS.h | 2 +- .../Platform_OpenAL/BFW_SS2_Platform_OpenAL.c | 42 +- .../Platform_Win32/BFW_SS2_Platform_Win32.c | 438 +- .../Platform_Win32/BFW_SS2_Platform_Win32.h | 10 +- .../BFW_TemplateManager/BFW_TM_Common.c | 190 +- .../BFW_TemplateManager/BFW_TM_Construction.c | 1228 ++--- .../BFW_TemplateManager/BFW_TM_Construction.h | 16 +- .../BFW_TemplateManager/BFW_TM_Game.c | 824 +-- .../BFW_TemplateManager/BFW_TM_Private.h | 34 +- .../BFW_TemplateManager/BFW_TemplateManager.c | 2522 ++++----- .../BFW_TextSystem/BFW_TS_Private.h | 4 +- .../BFW_TextSystem/BFW_TextSystem.c | 570 +- .../BFW_TextSystem/BFW_TextSystem_Template.c | 10 +- .../BFW_Source/BFW_Totoro/BFW_Totoro.c | 232 +- .../BFW_Totoro/BFW_Totoro_Private.h | 46 +- .../BFW_Totoro/BFW_Totoro_Template.c | 14 +- .../BFW_Source/BFW_Utility/BFW_BitVector.c | 148 +- .../BFW_Source/BFW_Utility/BFW_Error.c | 94 +- .../BFW_Source/BFW_Utility/BFW_Error.h | 10 +- .../BFW_Source/BFW_Utility/BFW_Memory.c | 850 +-- .../BFW_Source/BFW_Utility/BFW_Memory.h | 10 +- .../BFW_Source/BFW_Utility/BFW_Noise.c | 16 +- .../BFW_Source/BFW_Utility/BFW_Platform.h | 10 +- .../BFW_Source/BFW_Utility/BFW_Preferences.c | 20 +- .../BFW_Source/BFW_Utility/BFW_Preferences.h | 10 +- .../BFW_Source/BFW_Utility/BFW_String.c | 108 +- .../BFW_Source/BFW_Utility/BFW_Timer.c | 18 +- .../BFW_Source/BFW_Utility/BFW_Utility.c | 100 +- .../Platform_MacOS/BFW_Platform_AltiVec.c | 94 +- .../Platform_MacOS/BFW_Platform_MacOS.c | 168 +- .../Platform_SDL/BFW_Platform_SDL.c | 24 +- .../Platform_Win32/BFW_Platform_Win32.c | 112 +- .../BFW_WindowManager/BFW_WindowManager.c | 772 +-- .../BFW_WindowManager_Private.h | 32 +- .../BFW_WindowManager_Public.h | 222 +- .../BFW_WindowManager/WM_Cursor/WM_Cursor.c | 16 +- .../BFW_WindowManager/WM_Cursor/WM_Cursor.h | 14 +- .../BFW_WindowManager/WM_Dialog/WM_Dialog.c | 256 +- .../BFW_WindowManager/WM_Dialog/WM_Dialog.h | 38 +- .../WM_DrawContext/WM_DrawContext.c | 312 +- .../WM_DrawContext/WM_DrawContext.h | 38 +- .../WM_PartSpecification.c | 106 +- .../WM_PartSpecification.h | 72 +- .../WM_Utilities/WM_Utilities.c | 50 +- .../WM_Utilities/WM_Utilities.h | 2 +- .../BFW_WindowManager/WM_Windows/WM_Box.c | 40 +- .../BFW_WindowManager/WM_Windows/WM_Box.h | 6 +- .../BFW_WindowManager/WM_Windows/WM_Button.c | 82 +- .../BFW_WindowManager/WM_Windows/WM_Button.h | 4 +- .../WM_Windows/WM_CheckBox.c | 72 +- .../WM_Windows/WM_CheckBox.h | 8 +- .../WM_Windows/WM_EditField.c | 218 +- .../WM_Windows/WM_EditField.h | 4 +- .../BFW_WindowManager/WM_Windows/WM_ListBox.c | 626 +-- .../BFW_WindowManager/WM_Windows/WM_ListBox.h | 16 +- .../BFW_WindowManager/WM_Windows/WM_Menu.c | 258 +- .../BFW_WindowManager/WM_Windows/WM_Menu.h | 36 +- .../BFW_WindowManager/WM_Windows/WM_MenuBar.c | 222 +- .../BFW_WindowManager/WM_Windows/WM_MenuBar.h | 12 +- .../BFW_WindowManager/WM_Windows/WM_Picture.c | 60 +- .../BFW_WindowManager/WM_Windows/WM_Picture.h | 8 +- .../WM_Windows/WM_PopupMenu.c | 208 +- .../WM_Windows/WM_PopupMenu.h | 16 +- .../WM_Windows/WM_ProgressBar.c | 60 +- .../WM_Windows/WM_ProgressBar.h | 4 +- .../WM_Windows/WM_RadioButton.c | 64 +- .../WM_Windows/WM_RadioButton.h | 6 +- .../WM_Windows/WM_Scrollbar.c | 294 +- .../WM_Windows/WM_Scrollbar.h | 10 +- .../BFW_WindowManager/WM_Windows/WM_Slider.c | 208 +- .../BFW_WindowManager/WM_Windows/WM_Slider.h | 14 +- .../BFW_WindowManager/WM_Windows/WM_Text.c | 38 +- .../BFW_WindowManager/WM_Windows/WM_Text.h | 8 +- .../BFW_WindowManager/WM_Windows/WM_Window.c | 254 +- .../BFW_WindowManager/WM_Windows/WM_Window.h | 2 +- .../BFW_ToolSource/Common/Imp/Imp_AI2.c | 50 +- .../BFW_ToolSource/Common/Imp/Imp_AI2.h | 8 +- .../BFW_ToolSource/Common/Imp/Imp_AI_Script.c | 124 +- .../BFW_ToolSource/Common/Imp/Imp_AI_Script.h | 8 +- .../BFW_ToolSource/Common/Imp/Imp_ANSI.c | 158 +- .../BFW_ToolSource/Common/Imp/Imp_BatchFile.c | 132 +- .../BFW_ToolSource/Common/Imp/Imp_BatchFile.h | 4 +- .../BFW_ToolSource/Common/Imp/Imp_Character.c | 578 +- .../BFW_ToolSource/Common/Imp/Imp_Character.h | 20 +- .../BFW_ToolSource/Common/Imp/Imp_Common.c | 66 +- .../BFW_ToolSource/Common/Imp/Imp_Common.h | 4 +- .../BFW_ToolSource/Common/Imp/Imp_Console.c | 36 +- .../BFW_ToolSource/Common/Imp/Imp_Console.h | 2 +- .../BFW_ToolSource/Common/Imp/Imp_Cursor.c | 84 +- .../Common/Imp/Imp_Descriptor.c | 18 +- .../Common/Imp/Imp_Descriptor.h | 2 +- .../BFW_ToolSource/Common/Imp/Imp_Dialog.c | 186 +- .../BFW_ToolSource/Common/Imp/Imp_Dialog.h | 20 +- .../Common/Imp/Imp_DialogData.c | 188 +- .../Common/Imp/Imp_DialogData.h | 4 +- .../Common/Imp/Imp_DialogList.c | 28 +- .../Common/Imp/Imp_DialogList.h | 2 +- .../BFW_ToolSource/Common/Imp/Imp_Door.c | 28 +- .../BFW_ToolSource/Common/Imp/Imp_Door.h | 2 +- .../BFW_ToolSource/Common/Imp/Imp_Env2.c | 166 +- .../BFW_ToolSource/Common/Imp/Imp_Env2.h | 10 +- .../Common/Imp/Imp_Env2_CreateInst.c | 402 +- .../Common/Imp/Imp_Env2_LightMaps2.c | 114 +- .../Common/Imp/Imp_Env2_OctTree2.c | 438 +- .../Common/Imp/Imp_Env2_Parse.c | 604 +-- .../Common/Imp/Imp_Env2_Private.h | 224 +- .../Common/Imp/Imp_Env2_Process.c | 1024 ++-- .../Common/Imp/Imp_Env2_Process_RastLM.c | 438 +- .../Common/Imp/Imp_EnvParticle.c | 14 +- .../Common/Imp/Imp_EnvParticle.h | 2 +- .../Common/Imp/Imp_Environment.c | 154 +- .../Common/Imp/Imp_Environment.h | 10 +- .../BFW_ToolSource/Common/Imp/Imp_FX.c | 4 +- .../BFW_ToolSource/Common/Imp/Imp_FX.h | 6 +- .../BFW_ToolSource/Common/Imp/Imp_Font.c | 170 +- .../BFW_ToolSource/Common/Imp/Imp_Font.h | 28 +- .../BFW_ToolSource/Common/Imp/Imp_Furniture.c | 96 +- .../BFW_ToolSource/Common/Imp/Imp_Furniture.h | 4 +- .../Common/Imp/Imp_GameSettings.c | 30 +- .../BFW_ToolSource/Common/Imp/Imp_InGameUI.c | 394 +- .../BFW_ToolSource/Common/Imp/Imp_InGameUI.h | 10 +- .../BFW_ToolSource/Common/Imp/Imp_Input.h | 10 +- .../BFW_ToolSource/Common/Imp/Imp_Material.c | 28 +- .../BFW_ToolSource/Common/Imp/Imp_Material.h | 2 +- .../BFW_ToolSource/Common/Imp/Imp_MenuStuff.c | 58 +- .../BFW_ToolSource/Common/Imp/Imp_MenuStuff.h | 2 +- .../BFW_ToolSource/Common/Imp/Imp_Model.c | 452 +- .../BFW_ToolSource/Common/Imp/Imp_Model.h | 14 +- .../Common/Imp/Imp_ParseEnvFile.c | 198 +- .../Common/Imp/Imp_ParseEnvFile.h | 12 +- .../BFW_ToolSource/Common/Imp/Imp_PartSpec.c | 188 +- .../BFW_ToolSource/Common/Imp/Imp_PartSpec.h | 6 +- .../BFW_ToolSource/Common/Imp/Imp_Particle.h | 14 +- .../BFW_ToolSource/Common/Imp/Imp_Path.c | 134 +- .../BFW_ToolSource/Common/Imp/Imp_Path.h | 22 +- .../BFW_ToolSource/Common/Imp/Imp_Sky.c | 2 +- .../BFW_ToolSource/Common/Imp/Imp_Sky.h | 4 +- .../BFW_ToolSource/Common/Imp/Imp_Sound.c | 2 +- .../BFW_ToolSource/Common/Imp/Imp_Sound.h | 2 +- .../BFW_ToolSource/Common/Imp/Imp_Sound2.c | 138 +- .../BFW_ToolSource/Common/Imp/Imp_Sound2.h | 4 +- .../BFW_ToolSource/Common/Imp/Imp_Texture.c | 196 +- .../BFW_ToolSource/Common/Imp/Imp_Texture.h | 14 +- .../Common/Imp/Imp_TextureFlags.c | 58 +- .../Common/Imp/Imp_TextureFlags.h | 6 +- .../Common/Imp/Imp_Texture_Big.c | 140 +- .../BFW_ToolSource/Common/Imp/Imp_Trigger.c | 28 +- .../BFW_ToolSource/Common/Imp/Imp_Trigger.h | 2 +- .../BFW_ToolSource/Common/Imp/Imp_Turret.c | 112 +- .../BFW_ToolSource/Common/Imp/Imp_Turret.h | 2 +- .../Common/Imp/Imp_UnitViewer.c | 34 +- .../Common/Imp/Imp_UnitViewer.h | 2 +- .../BFW_ToolSource/Common/Imp/Imp_View.c | 396 +- .../BFW_ToolSource/Common/Imp/Imp_View.h | 2 +- .../BFW_ToolSource/Common/Imp/Imp_Weapon.c | 50 +- .../BFW_ToolSource/Common/Imp/Imp_Weapon.h | 12 +- .../Common/Imp/libtiff/machdep.h | 16 +- .../Common/Imp/libtiff/prototypes.h | 16 +- .../BFW_ToolSource/Common/Imp/libtiff/t4.h | 16 +- .../Common/Imp/libtiff/tif_aux.c | 16 +- .../Common/Imp/libtiff/tif_ccittrle.c | 16 +- .../Common/Imp/libtiff/tif_close.c | 16 +- .../Common/Imp/libtiff/tif_compat.c | 34 +- .../Common/Imp/libtiff/tif_compress.c | 16 +- .../Common/Imp/libtiff/tif_dir.c | 18 +- .../Common/Imp/libtiff/tif_dirinfo.c | 16 +- .../Common/Imp/libtiff/tif_dirread.c | 24 +- .../Common/Imp/libtiff/tif_dirwrite.c | 16 +- .../Common/Imp/libtiff/tif_dumpmode.c | 16 +- .../Common/Imp/libtiff/tif_error.c | 16 +- .../Common/Imp/libtiff/tif_fax3.c | 18 +- .../Common/Imp/libtiff/tif_fax3.h | 16 +- .../Common/Imp/libtiff/tif_fax4.c | 16 +- .../Common/Imp/libtiff/tif_flush.c | 16 +- .../Common/Imp/libtiff/tif_getimage.c | 26 +- .../Common/Imp/libtiff/tif_jpeg.c | 16 +- .../Common/Imp/libtiff/tif_lzw.c | 26 +- .../Common/Imp/libtiff/tif_machdep.c | 16 +- .../Common/Imp/libtiff/tif_next.c | 16 +- .../Common/Imp/libtiff/tif_open.c | 20 +- .../Common/Imp/libtiff/tif_packbits.c | 16 +- .../Common/Imp/libtiff/tif_print.c | 16 +- .../Common/Imp/libtiff/tif_read.c | 24 +- .../Common/Imp/libtiff/tif_strip.c | 16 +- .../Common/Imp/libtiff/tif_swab.c | 80 +- .../Common/Imp/libtiff/tif_thunder.c | 18 +- .../Common/Imp/libtiff/tif_tile.c | 26 +- .../Common/Imp/libtiff/tif_version.c | 16 +- .../Common/Imp/libtiff/tif_warning.c | 16 +- .../Common/Imp/libtiff/tif_write.c | 18 +- .../BFW_ToolSource/Common/Imp/libtiff/tiff.h | 16 +- .../Common/Imp/libtiff/tiffcompat.h | 18 +- .../Common/Imp/libtiff/tiffio.h | 16 +- .../Common/Imp/libtiff/tiffioP.h | 22 +- .../Common/LSSolutionFileIO/BFW_LSSolution.c | 34 +- .../Common/LSSolutionFileIO/BFW_LSSolution.h | 24 +- .../LPWriter/BFW_LSPreperation.h | 12 +- .../LSSolutionFileIO/LSReader/BFW_LSBuilder.h | 44 +- .../Common/TemplateExtractor/TE_Extract.c | 152 +- .../Common/TemplateExtractor/TE_Extract.h | 12 +- .../Common/TemplateExtractor/TE_Parser.c | 212 +- .../Common/TemplateExtractor/TE_Parser.h | 14 +- .../Common/TemplateExtractor/TE_Private.h | 34 +- .../Common/TemplateExtractor/TE_Symbol.c | 630 +-- .../Common/TemplateExtractor/TE_Symbol.h | 28 +- .../TemplateExtractor/TemplateExtractor.c | 180 +- .../TemplateExtractor/TemplateExtractor.h | 12 +- .../Win32/ModelExporter/EnvFileFormat.h | 34 +- .../Win32/ModelExporter/ExportTools.h | 28 +- .../Win32/ModelExporter/resource.h | 2 +- OniProj/OniCMakeProjs/BinkProj/CMakeLists.txt | 64 +- OniProj/OniGameSource/Oni.c | 246 +- OniProj/OniGameSource/Oni.h | 8 +- OniProj/OniGameSource/Oni_AI/Oni_AI.c | 12 +- OniProj/OniGameSource/Oni_AI/Oni_AI.h | 24 +- OniProj/OniGameSource/Oni_AI/Oni_AI2.c | 144 +- OniProj/OniGameSource/Oni_AI/Oni_AI2.h | 14 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Alarm.c | 12 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Alarm.h | 8 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Alert.c | 10 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Alert.h | 8 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Combat.c | 106 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Combat.h | 12 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Error.c | 28 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Error.h | 8 +- .../OniGameSource/Oni_AI/Oni_AI2_Executor.c | 26 +- .../OniGameSource/Oni_AI/Oni_AI2_Executor.h | 10 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Fight.c | 10 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Fight.h | 8 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Guard.c | 14 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Guard.h | 10 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Idle.c | 8 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Idle.h | 10 +- .../OniGameSource/Oni_AI/Oni_AI2_Knowledge.c | 86 +- .../OniGameSource/Oni_AI/Oni_AI2_Knowledge.h | 10 +- .../OniGameSource/Oni_AI/Oni_AI2_LocalPath.c | 12 +- .../OniGameSource/Oni_AI/Oni_AI2_LocalPath.h | 6 +- .../OniGameSource/Oni_AI/Oni_AI2_Maneuver.c | 42 +- .../OniGameSource/Oni_AI/Oni_AI2_Maneuver.h | 10 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Melee.c | 202 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Melee.h | 8 +- .../Oni_AI/Oni_AI2_MeleeProfile.h | 10 +- .../OniGameSource/Oni_AI/Oni_AI2_Movement.c | 64 +- .../OniGameSource/Oni_AI/Oni_AI2_Movement.h | 10 +- .../Oni_AI/Oni_AI2_MovementState.c | 126 +- .../Oni_AI/Oni_AI2_MovementState.h | 8 +- .../Oni_AI/Oni_AI2_MovementStub.c | 18 +- .../Oni_AI/Oni_AI2_MovementStub.h | 8 +- .../OniGameSource/Oni_AI/Oni_AI2_Neutral.c | 26 +- .../OniGameSource/Oni_AI/Oni_AI2_Neutral.h | 8 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Panic.c | 22 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Panic.h | 8 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Path.c | 40 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Path.h | 8 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Patrol.c | 24 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Patrol.h | 8 +- .../OniGameSource/Oni_AI/Oni_AI2_Pursuit.c | 22 +- .../OniGameSource/Oni_AI/Oni_AI2_Pursuit.h | 8 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Script.c | 142 +- OniProj/OniGameSource/Oni_AI/Oni_AI2_Script.h | 8 +- .../OniGameSource/Oni_AI/Oni_AI2_Targeting.c | 58 +- .../OniGameSource/Oni_AI/Oni_AI2_Targeting.h | 16 +- .../OniGameSource/Oni_AI/Oni_AI2_TeamBattle.c | 8 +- .../OniGameSource/Oni_AI/Oni_AI2_TeamBattle.h | 10 +- OniProj/OniGameSource/Oni_AI/Oni_AI_Action.c | 2 +- OniProj/OniGameSource/Oni_AI/Oni_AI_Action.h | 2 +- .../OniGameSource/Oni_AI/Oni_AI_Activity.c | 2 +- .../OniGameSource/Oni_AI/Oni_AI_Activity.h | 2 +- .../OniGameSource/Oni_AI/Oni_AI_Behaviour.h | 2 +- OniProj/OniGameSource/Oni_AI/Oni_AI_Group.c | 2 +- OniProj/OniGameSource/Oni_AI/Oni_AI_Group.h | 2 +- .../OniGameSource/Oni_AI/Oni_AI_Learning.h | 2 +- OniProj/OniGameSource/Oni_AI/Oni_AI_Profile.c | 2 +- OniProj/OniGameSource/Oni_AI/Oni_AI_Profile.h | 2 +- OniProj/OniGameSource/Oni_AI/Oni_AI_Script.c | 134 +- OniProj/OniGameSource/Oni_AI/Oni_AI_Script.h | 18 +- OniProj/OniGameSource/Oni_AI/Oni_AI_Setup.c | 2 +- OniProj/OniGameSource/Oni_AI/Oni_AI_Setup.h | 24 +- OniProj/OniGameSource/Oni_AI/Oni_AStar.c | 188 +- OniProj/OniGameSource/Oni_AI/Oni_AStar.h | 8 +- OniProj/OniGameSource/Oni_Action.h | 2 +- OniProj/OniGameSource/Oni_Aiming.c | 72 +- OniProj/OniGameSource/Oni_Aiming.h | 18 +- .../Oni_BinaryData/Oni_BinaryData.c | 76 +- .../Oni_BinaryData/Oni_BinaryData.h | 4 +- OniProj/OniGameSource/Oni_Bink.c | 42 +- OniProj/OniGameSource/Oni_Bink.h | 4 +- OniProj/OniGameSource/Oni_Camera.c | 80 +- OniProj/OniGameSource/Oni_Camera.h | 16 +- OniProj/OniGameSource/Oni_Character.c | 1022 ++-- OniProj/OniGameSource/Oni_Character.h | 80 +- .../OniGameSource/Oni_Character_Animation.h | 40 +- OniProj/OniGameSource/Oni_Cinematics.c | 156 +- OniProj/OniGameSource/Oni_Cinematics.h | 10 +- OniProj/OniGameSource/Oni_Combos.c | 2 +- OniProj/OniGameSource/Oni_DataConsole.c | 14 +- OniProj/OniGameSource/Oni_DataConsole.h | 10 +- OniProj/OniGameSource/Oni_Dialogs.c | 418 +- OniProj/OniGameSource/Oni_Dialogs.h | 30 +- OniProj/OniGameSource/Oni_Event.c | 22 +- OniProj/OniGameSource/Oni_Event.h | 2 +- OniProj/OniGameSource/Oni_FX.c | 28 +- OniProj/OniGameSource/Oni_FX.h | 8 +- OniProj/OniGameSource/Oni_Film.c | 34 +- OniProj/OniGameSource/Oni_Film.h | 14 +- OniProj/OniGameSource/Oni_Game.h | 2 +- OniProj/OniGameSource/Oni_GameSettings.c | 10 +- OniProj/OniGameSource/Oni_GameSettings.h | 8 +- OniProj/OniGameSource/Oni_GameState.c | 550 +- OniProj/OniGameSource/Oni_GameState.h | 26 +- OniProj/OniGameSource/Oni_GameStatePrivate.h | 26 +- OniProj/OniGameSource/Oni_ImpactEffect.c | 182 +- OniProj/OniGameSource/Oni_ImpactEffect.h | 12 +- OniProj/OniGameSource/Oni_InGameUI.c | 760 +-- OniProj/OniGameSource/Oni_InGameUI.h | 82 +- OniProj/OniGameSource/Oni_InputBindings.h | 8 +- OniProj/OniGameSource/Oni_KeyBindings.c | 16 +- OniProj/OniGameSource/Oni_KeyBindings.h | 14 +- OniProj/OniGameSource/Oni_Level.c | 248 +- OniProj/OniGameSource/Oni_Level.h | 32 +- OniProj/OniGameSource/Oni_Mechanics.c | 46 +- OniProj/OniGameSource/Oni_Mechanics.h | 2 +- OniProj/OniGameSource/Oni_Motoko.c | 112 +- OniProj/OniGameSource/Oni_Motoko.h | 14 +- .../Oni_Networking/Oni_Net_Private.h | 98 +- .../Oni_Networking/Oni_Net_Support.c | 1222 ++--- .../Oni_Networking/Oni_Net_Support.h | 32 +- .../Oni_Networking/Oni_Networking.c | 506 +- .../Oni_Networking/Oni_Networking.h | 34 +- .../OniGameSource/Oni_Object/OT_PatrolPoint.c | 112 +- OniProj/OniGameSource/Oni_Object/Oni_Object.c | 990 ++-- OniProj/OniGameSource/Oni_Object/Oni_Object.h | 204 +- .../OniGameSource/Oni_Object/Oni_ObjectFile.c | 154 +- .../OniGameSource/Oni_Object/Oni_ObjectFile.h | 18 +- .../Oni_Object/Oni_Object_Private.h | 28 +- .../Oni_Object/Oni_Object_RegisterTemplates.c | 2 +- .../Oni_Object/Oni_Object_Utils.c | 48 +- .../Oni_Object/object_types/OT_Character.c | 140 +- .../Oni_Object/object_types/OT_Combat.c | 54 +- .../Oni_Object/object_types/OT_Console.c | 192 +- .../Oni_Object/object_types/OT_Door.c | 340 +- .../Oni_Object/object_types/OT_Flags.c | 142 +- .../Oni_Object/object_types/OT_Furniture.c | 200 +- .../Oni_Object/object_types/OT_Melee.c | 50 +- .../Oni_Object/object_types/OT_Neutral.c | 44 +- .../Oni_Object/object_types/OT_Particle.c | 98 +- .../Oni_Object/object_types/OT_PowerUps.c | 98 +- .../Oni_Object/object_types/OT_Sound.c | 196 +- .../Oni_Object/object_types/OT_Trigger.c | 176 +- .../object_types/OT_TriggerVolume.c | 42 +- .../Oni_Object/object_types/OT_Turret.c | 284 +- .../Oni_Object/object_types/OT_Weapon.c | 82 +- .../Oni_OutGameUI/Oni_OutGameUI.c | 252 +- .../Oni_OutGameUI/Oni_OutGameUI.h | 8 +- OniProj/OniGameSource/Oni_Particle3.c | 176 +- OniProj/OniGameSource/Oni_Path.c | 206 +- OniProj/OniGameSource/Oni_Path.h | 16 +- OniProj/OniGameSource/Oni_Performance.c | 152 +- OniProj/OniGameSource/Oni_Performance.h | 8 +- OniProj/OniGameSource/Oni_Persistance.c | 22 +- OniProj/OniGameSource/Oni_Persistance.h | 8 +- OniProj/OniGameSource/Oni_Platform.h | 20 +- OniProj/OniGameSource/Oni_Script.c | 34 +- OniProj/OniGameSource/Oni_Script.h | 8 +- OniProj/OniGameSource/Oni_Sky.c | 62 +- OniProj/OniGameSource/Oni_Sky.h | 10 +- OniProj/OniGameSource/Oni_Sound.c | 656 +-- OniProj/OniGameSource/Oni_Sound.h | 58 +- OniProj/OniGameSource/Oni_Sound2.c | 1094 ++-- OniProj/OniGameSource/Oni_Sound2.h | 66 +- OniProj/OniGameSource/Oni_Sound_Animation.c | 426 +- OniProj/OniGameSource/Oni_Sound_Animation.h | 36 +- OniProj/OniGameSource/Oni_Sound_Private.h | 10 +- OniProj/OniGameSource/Oni_Speech.c | 14 +- OniProj/OniGameSource/Oni_Speech.h | 10 +- OniProj/OniGameSource/Oni_Templates.c | 22 +- OniProj/OniGameSource/Oni_Templates.h | 8 +- OniProj/OniGameSource/Oni_Testbed.h | 2 +- OniProj/OniGameSource/Oni_TextureMaterials.c | 130 +- OniProj/OniGameSource/Oni_TextureMaterials.h | 4 +- OniProj/OniGameSource/Oni_UnitViewer.c | 238 +- OniProj/OniGameSource/Oni_UnitViewer.h | 12 +- OniProj/OniGameSource/Oni_Weapon.c | 224 +- OniProj/OniGameSource/Oni_Weapon.h | 28 +- OniProj/OniGameSource/Oni_Windows.c | 556 +- OniProj/OniGameSource/Oni_Windows.h | 52 +- .../OniGameSource/Oni_Windows/Oni_Obj_Tools.c | 956 ++-- .../OniGameSource/Oni_Windows/Oni_Obj_Tools.h | 56 +- .../OniGameSource/Oni_Windows/Oni_Win_AI.c | 36 +- .../OniGameSource/Oni_Windows/Oni_Win_AI.h | 10 +- .../Oni_Windows/Oni_Win_AI_Character.c | 48 +- .../Oni_Windows/Oni_Win_AI_Combat.c | 16 +- .../Oni_Windows/Oni_Win_AI_Combat.h | 10 +- .../Oni_Windows/Oni_Win_AI_Melee.c | 74 +- .../Oni_Windows/Oni_Win_AI_Melee.h | 8 +- .../Oni_Windows/Oni_Win_AI_Neutral.c | 20 +- .../Oni_Windows/Oni_Win_AI_Neutral.h | 8 +- .../Oni_Windows/Oni_Win_AI_Path.c | 66 +- .../Oni_Windows/Oni_Win_ImpactEffects.c | 168 +- .../Oni_Windows/Oni_Win_ImpactEffects.h | 4 +- .../Oni_Windows/Oni_Win_Multiplayer.c | 142 +- .../Oni_Windows/Oni_Win_Particle.c | 642 +-- .../Oni_Windows/Oni_Win_Particle.h | 14 +- .../Oni_Windows/Oni_Win_Settings.c | 28 +- .../OniGameSource/Oni_Windows/Oni_Win_Sound.c | 1472 ++--- .../OniGameSource/Oni_Windows/Oni_Win_Sound.h | 6 +- .../Oni_Windows/Oni_Win_Sound2.c | 2472 ++++----- .../Oni_Windows/Oni_Win_Sound2.h | 24 +- .../Oni_Windows/Oni_Win_TextureMaterials.c | 90 +- .../Oni_Windows/Oni_Win_TextureMaterials.h | 2 +- .../OniGameSource/Oni_Windows/Oni_Win_Tools.c | 1200 ++-- .../OniGameSource/Oni_Windows/Oni_Win_Tools.h | 40 +- OniProj/OniGameSource/Oni_Windows2.c | 48 +- .../Platform_MacOS/Oni_Mac_Keys.h | 8 +- .../Platform_MacOS/Oni_Platform_Mac.c | 170 +- .../Platform_MacOS/Oni_Platform_Mac.h | 22 +- .../Platform_SDL/Oni_Platform_SDL.c | 12 +- .../Platform_SDL/Oni_Platform_SDL.h | 2 +- .../Platform_Win32/Oni_Platform_Win32.c | 62 +- .../Platform_Win32/Oni_Platform_Win32.h | 8 +- .../OniPrefix/ImporterPrefix_MacOSOpt.h | 2 +- .../OniProj/OniPrefix/ImporterPrefix_Win32.h | 6 +- .../OniProj/OniPrefix/OniPrefix_MacOSDbg.h | 16 +- .../OniProj/OniPrefix/OniPrefix_MacOSOpt.h | 10 +- .../OniPrefix/OniPrefix_MacOSProfile.h | 10 +- .../OniProj/OniPrefix/OniPrefix_Win32Dbg.h | 10 +- .../OniProj/OniPrefix/OniPrefix_Win32Opt.h | 10 +- OniProj/OniMWProjects/Oni_Film.h | 14 +- OniProj/OniResources/resource.h | 2 +- .../ImpConsole/templatechecksum.c | 4818 ++++++++--------- .../LSSolutionConverter/LSVCDirectories.txt | 2 +- .../LSSolutionConverter/lsConverter.c | 16 +- 878 files changed, 46576 insertions(+), 46576 deletions(-) diff --git a/BungieFrameWork/BFW_Headers/BFW.h b/BungieFrameWork/BFW_Headers/BFW.h index d68cc31..ac44a1e 100644 --- a/BungieFrameWork/BFW_Headers/BFW.h +++ b/BungieFrameWork/BFW_Headers/BFW.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW.h - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: May 17, 1997 - + PURPOSE: Utilities for platform, processor, memory, error, and assertions - + Copyright 1997, 2000 */ @@ -75,23 +75,23 @@ extern "C" { #define UUmPlatform_Win32 1 #define UUmPlatform_Mac 2 #define UUmPlatform_Linux 3 - + #define UUmProcessor_Pentium 1 #define UUmProcessor_PPC 2 - + #define UUmCompiler_VisC 1 #define UUmCompiler_MWerks 2 #define UUmCompiler_Moto 3 #define UUmCompiler_Watcom 4 #define UUmCompiler_GCC 5 - + #define UUmEndian_Little 0 #define UUmEndian_Big 1 - + #define UUmSIMD_None 0 #define UUmSIMD_AltiVec 1 #define UUmSIMD_Intel 2 - + /* * Try to determine the correct platform, processor, and compiler settings if * they are not given. @@ -107,17 +107,17 @@ extern "C" { #error Unknown platform - please specify and then do a search on UUmPlatform to add the needed cases #endif #endif - + #if !defined(UUmProcessor) #if (defined(__MWERKS__) && defined(__POWERPC__)) || defined(__MRC__) || defined(__MOTO__) || defined(ppc) || defined(__ppc__) || defined(__ppc) #define UUmProcessor UUmProcessor_PPC - + #if defined(__ALTIVEC__) && defined(__VEC__) #define UUmSIMD UUmSIMD_AltiVec #else #define UUmSIMD UUmSIMD_None #endif - + #elif defined(i386) || defined(__i386__) #define UUmProcessor UUmProcessor_Pentium #define UUmSIMD UUmSIMD_None @@ -125,11 +125,11 @@ extern "C" { #elif (defined(__MWERKS__) && defined(__INTEL__)) || defined(_MSC_VER) || defined(__WATCOMC__) #define UUmProcessor UUmProcessor_Pentium #define UUmSIMD UUmSIMD_None - #else + #else #error Unknown processor - please specify and then do a search on UUmProcessor to add the needed cases #endif #endif - + #if !defined(UUmCompiler) #if defined(__MWERKS__) #define UUmCompiler UUmCompiler_MWerks @@ -147,7 +147,7 @@ extern "C" { #error Unknown compiler - please specify and then do a search on UUmCompiler to add the needed cases #endif #endif - + #if !defined(UUmEndian) #if UUmProcessor == UUmProcessor_PPC #define UUmEndian UUmEndian_Big @@ -162,7 +162,7 @@ extern "C" { * Define the processor specific macros * * Things defined in this file - * 1. UUcProcessor_CacheLineSize - A hint at the cache line size. While this is required to be defined it does not + * 1. UUcProcessor_CacheLineSize - A hint at the cache line size. While this is required to be defined it does not * necessarily need to be exactly correct. A correct value would lead to higher performance. * 2. UUrProcessor_ZeroCacheLine - An instruction to zero a cache line. This is a hint to help memory bandwidth */ @@ -187,7 +187,7 @@ extern "C" { // change compiler behavior #if UUmCompiler == UUmCompiler_VisC -#pragma warning( 1 : 4003) // not enough actual parameters for macro +#pragma warning( 1 : 4003) // not enough actual parameters for macro #pragma warning( 1 : 4018) // signed/unsigned mismatch #pragma warning( error : 4013) // undefined; assuming extern returning int #pragma warning( error : 4020) // too many actual parameters @@ -229,7 +229,7 @@ extern "C" { #include #include #elif UUmPlatform == UUmPlatform_Win32 - #if UUmCompiler != UUmCompiler_MWerks + #if UUmCompiler != UUmCompiler_MWerks #include #endif @@ -241,7 +241,7 @@ extern "C" { #if UUmCompiler == UUmCompiler_VisC #define UUcInline __inline -#elif UUmCompiler == UUmCompiler_MWerks +#elif UUmCompiler == UUmCompiler_MWerks #define UUcInline inline #elif UUmCompiler == UUmCompiler_GCC #define UUcInline inline @@ -254,8 +254,8 @@ extern "C" { #define UUcArglist_Call __cdecl #define UUcExternal_Call __cdecl #else - #define UUcArglist_Call - #define UUcExternal_Call + #define UUcArglist_Call + #define UUcExternal_Call #endif /* @@ -266,28 +266,28 @@ extern "C" { * Used to replace the "struct" keyword when defining a new template */ #define tm_template(c1, c2, c3, c4, string) struct - + /* * Used to replace the struct keyword when defining a struct to be used within a template */ #define tm_struct struct - + /* * Used to replace the enum keyword when defining a enum to be used within a template */ #define tm_enum enum - + /* * Used to declare a template field that will be the index to a variable length array. * *** This must immediately preceed a tm_vararray declaration */ #define tm_varindex - + /* * Used to declare a variable length array. *** This must be the last field */ #define tm_vararray - + /* * This is used to pad a template declaration so the data is cache aligned. * "x" is typically the size of the var array index type so that the variable @@ -315,7 +315,7 @@ extern "C" { /* * ============================= Useful typedefs ============================= */ - + #if UUmCompiler_GCC #include #include @@ -343,7 +343,7 @@ extern "C" { typedef long long UUtInt64; typedef unsigned long long UUtUns64; - + #define UUmFS_UUtUns64 "%llu" #define UUmFS_UUtInt64 "%lld" @@ -366,7 +366,7 @@ extern "C" { UUtInt16 left; UUtInt16 top; UUtInt16 right; - UUtInt16 bottom; + UUtInt16 bottom; } UUtRect; /* @@ -429,17 +429,17 @@ extern "C" { #define UUmMakeLong(hi,lo) ((UUtUns32)(((((UUtUns16)(hi)) << 16)) | ((UUtUns16)(lo)))) #define UUmHighWord(l) ((UUtUns16)(((UUtUns32)(l)) >> 16)) #define UUmLowWord(l) ((UUtUns16)(l)) - + #define UUmMakeShort(hi,lo) ((UUtUns16)((((UUtUns8)(hi)) << 8) | ((UUtUns8)(lo)))) #define UUmHighByte(s) ((UUtUns8)(((UUtUns16)(s)) >> 8)) #define UUmLowByte(s) ((UUtUns8)(s)) - - + + #define UUm2CharToUns16(c1, c2) (UUtUns16)(((UUtUns16)(c1) << 8) | (UUtUns16)(c2)) #define UUm4CharToUns32(c1, c2, c3, c4) (UUtUns32)(((UUtUns32)(c1) << 24) | ((UUtUns32)(c2) << 16) | ((UUtUns32)(c3) << 8) | (UUtUns32)(c4)) - // some trig helper macros - + // some trig helper macros + // for theta >= 0 && theta <= 4 pi, changes theta to theta >= 0 && theta <= 2 pi #define UUmTrig_ClipHigh(theta) do { if ((theta) >= M3c2Pi) { (theta) -= M3c2Pi; } } while(0) @@ -480,11 +480,11 @@ extern "C" { #define UUmFloat_CompareLTSloppy(a, b) ((float)((a) - (b)) < -UUcNewfieEpsilon) #define UUmFloat_CompareGESloppy(a, b) ((float)((b) - (a)) < UUcNewfieEpsilon) #define UUmFloat_CompareGTSloppy(a, b) ((float)((b) - (a)) < -UUcNewfieEpsilon) - + #define UUmFloat_Mod(n, mod) ( ((n) < 0) ? ((n) + (mod)) : (((n) > mod) ? ((n) - mod) : (n) ) ) #define UUmChar_Upper(c) (((c) >= 'a' && (c) <= 'z') ? ((c) + ('A' - 'a')) : (c)) - + #define UUmCPPCanSuck(x) #x #define UUmStringize(y) UUmCPPCanSuck(y) @@ -552,7 +552,7 @@ extern "C" { #endif #if defined(DEBUGGING) && DEBUGGING - + #if defined(DEBUG_EXTERNAL) && DEBUG_EXTERNAL #define UUmAssertTrigRange(number) UUmAssert(((number) >= 0) && ((number) <= M3c2Pi)) @@ -561,22 +561,22 @@ extern "C" { #define UUmAssertReadPtr(ptr, size) UUmAssert((0 == (size)) || ((NULL != (ptr)) && (0x55554742 != ((UUtUns32)(ptr))))) #define UUmAssertWritePtr(ptr, size) UUmAssert((0 == (size)) || ((NULL != (ptr)) && (0x55554742 != ((UUtUns32)(ptr))))) - + #elif UUmPlatform == UUmPlatform_Win32 - + #define UUmAssertReadPtr(ptr, size) UUmAssert(!IsBadReadPtr(ptr, size)); #define UUmAssertWritePtr(ptr, size) UUmAssert(!IsBadWritePtr(ptr, size)); - + #elif UUmPlatform == UUmPlatform_Linux - + //FIXME #define UUmAssertReadPtr(ptr, size) #define UUmAssertWritePtr(ptr, size) - + #endif #define UUmAssertAlignedPtr(ptr) UUmAssert((((UUtUns32)(ptr)) & UUcProcessor_CacheLineSize_Mask) == 0) - + #if UUmPlatform == UUmPlatform_Win32 && defined(SHIPPING_VERSION) && (SHIPPING_VERSION != 1) #define UUmAssert(x) if (!(x)) { \ extern void stack_walk(int); \ @@ -595,45 +595,45 @@ extern "C" { #else #define UUmAssertTrigRange(number) UUmAssert(((number) >= 0) && ((number) <= M3c2Pi)) - + #if UUmPlatform == UUmPlatform_Mac - + #define UUmAssertReadPtr(ptr, size) UUmAssert((0 == (size)) || ((NULL != (ptr)) && (0x55554742 != ((UUtUns32) (ptr))) && (0xDDDDDDDD != ((UUtUns32)(ptr))))) #define UUmAssertWritePtr(ptr, size) UUmAssert((0 == (size)) || ((NULL != (ptr)) && (0x55554742 != ((UUtUns32)(ptr))))) - + #elif UUmPlatform == UUmPlatform_Win32 - + #define UUmAssertReadPtr(ptr, size) UUmAssert(!IsBadReadPtr(ptr, size) && (0xDDDDDDDD != ((UUtUns32) ptr))); #define UUmAssertWritePtr(ptr, size) UUmAssert(!IsBadWritePtr(ptr, size) && (0xDDDDDDDD != ((UUtUns32) ptr))); - + #elif UUmPlatform == UUmPlatform_Linux - + //FIXME #define UUmAssertReadPtr(ptr, size) #define UUmAssertWritePtr(ptr, size) - + #endif #define UUmAssertAlignedPtr(ptr) UUmAssert((((UUtUns32)(ptr)) & UUcProcessor_CacheLineSize_Mask) == 0) - + #if UUmPlatform == UUmPlatform_Mac - + #define UUmAssert(x) if (!(x)) {UUrDebuggerMessage("file %s line %d msg %s"UUmNL,__FILE__,__LINE__,#x); UUmEnterDebugger;} - + #else - + #define UUmAssert(x) if (!(x)) do { AUrMessageBox(AUcMBType_OK, "file %s line %d msg %s"UUmNL,__FILE__,__LINE__,#x); UUrDebuggerMessage("file %s line %d msg %s"UUmNL,__FILE__,__LINE__,#x); UUmEnterDebugger; } while(0) - + #endif - + #define UUmAssertOnce(x) do { static int assert_once = 0; if (!assert_once) { if (!(x)) { int assert_result; assert_once = 1; UUrDebuggerMessage("file %s line %d msg %s"UUmNL,__FILE__,__LINE__,#x); assert_result = UUrEnterDebuggerInline(#x); if (assert_result) { UUmEnterDebugger; } } } } while(0) #define UUmDebugStr(x) if (1) { int debug_result = UUrEnterDebuggerInline(x); if (debug_result) UUmEnterDebugger; } #define UUmAssert_Untested() UUmAssert(!"I am not tested, just a warning - remove me if I work") - + #endif - #else + #else #define UUmAssertTrigRange(number) #define UUmAssertReadPtr(ptr, size) @@ -643,8 +643,8 @@ extern "C" { #define UUmAssertOnce(x) #define UUmDebugStr(x) #define UUmAssert_Untested() - - #endif + + #endif /* * ============================= error handling ============================= @@ -654,8 +654,8 @@ extern "C" { #define UUcError_Generic ((UUtError) 0x0001) #define UUcError_OutOfMemory ((UUtError) 0x0002) #define UUcError_DirectDraw ((UUtError) 0x0003) - - + + void UUrError_Report_Internal( const char *inFile, unsigned long inLine, @@ -670,7 +670,7 @@ extern "C" { UUtUns32 value0, UUtUns32 value1, UUtUns32 value2); - + void UUcArglist_Call UUrPrintWarning( const char *format, ...); @@ -775,20 +775,20 @@ extern "C" { UUrError_ReportP_Internal(__FILE__, __LINE__, error, msg, p0, p1, p2); \ UUmAssert(UUcError_None == (error)); \ do {} while (0) - + #if UUmPlatform == UUmPlatform_Win32 char *UUrError_DirectDraw2Str(HRESULT ddReturn); #endif - + /* * Memory utilities * * Important notes * 1. All memory is UUcProcessor_CacheLineSize aligned * 2. All memory is allocated in multiples of UUcProcessor_CacheLineSize blocks - * 3. Do not use the functions with the "_Real" or "_Debug" directly. Use the macros + * 3. Do not use the functions with the "_Real" or "_Debug" directly. Use the macros */ /* @@ -799,7 +799,7 @@ extern "C" { /* * alignment function, increments pointer until aligned - */ + */ void *UUrAlignMemory(void *inMemory); @@ -814,7 +814,7 @@ extern "C" { UUrMemory_Block_NewClear_Real( // This is used to allocate a new block UUtUns32 inSize); - void + void UUrMemory_Block_Delete_Real( // This is used to delete a block void* inMemory); @@ -830,52 +830,52 @@ extern "C" { #define UUcPool_Fixed UUcTrue #define UUcPool_Growable UUcFalse - - UUtMemory_Pool* + + UUtMemory_Pool* UUrMemory_Pool_New_Real( // This is used to create a new memory pool UUtUns32 inChunkSize, // This is the chunk size of the pool UUtBool inFixed); // This is true if only one pool is allocated - void + void UUrMemory_Pool_Delete_Real( // This is used to delete a pool - Use reset below to empty out the pool UUtMemory_Pool *inMemoryPool); - + void * UUrMemory_Pool_Block_New( // This is used to allocate a block within a pool UUtMemory_Pool *inMemoryPool, UUtUns32 inSize); - - void + + void UUrMemory_Pool_Reset( // This is used to reset the pool to be empty UUtMemory_Pool *inMemoryPool); UUtUns32 UUrMemory_Pool_Get_ChunkSize( UUtMemory_Pool *inMemoryPool); - + /* * Heap allocation functions */ typedef struct UUtMemory_Heap UUtMemory_Heap; - - UUtMemory_Heap* + + UUtMemory_Heap* UUrMemory_Heap_New_Real( // This is used to create a new memory heap UUtUns32 inChunkSize, // This is the chunk size of the pool UUtBool inFixed); // This is true if only one pool is allocated - void + void UUrMemory_Heap_Delete_Real( // This is used to delete a heap - Use reset below to empty out the pool UUtMemory_Heap *inMemoryHeap); - + void * UUrMemory_Heap_Block_New_Real( // This is used to allocate a block within a heap UUtMemory_Heap *inMemoryHeap, UUtUns32 inSize); - + void UUrMemory_Heap_Block_Delete_Real( // This is used to allocate a block within a heap UUtMemory_Heap *inMemoryHeap, void* inBlock); - + void UUrMemory_Heap_Reset( UUtMemory_Heap *inMemoryHeap); @@ -885,18 +885,18 @@ extern "C" { */ typedef struct UUtMemory_Array UUtMemory_Array; - UUtMemory_Array* + UUtMemory_Array* UUrMemory_Array_New_Real( // This is used to create a new array UUtUns32 inElementSize, // The size of each element UUtUns32 inAllocChunkSize, // The chunk size of incremental allocations UUtUns32 inNumInitialElemsUsed, // The number of elements initially used UUtUns32 inNumElemsToAlloc); // The number of elements to allocate - void + void UUrMemory_Array_Delete_Real( // This is used to delete a array UUtMemory_Array* inMemoryArray); - - UUtError + + UUtError UUrMemory_Array_MakeRoom( // This is used to make sure that enough elems have been allocated UUtMemory_Array* inMemoryArray, UUtUns32 inNumElems, @@ -905,34 +905,34 @@ extern "C" { void* UUrMemory_Array_GetMemory( // This is used to get the pointer to the linear array memory UUtMemory_Array* inMemoryArray); - + UUtError UUrMemory_Array_GetNewElement( // This is used to get an additional element from the array UUtMemory_Array* inMemoryArray, UUtUns32 *outNewIndex, UUtBool *outMemoryMoved); - + void UUrMemory_Array_DeleteElement( // This always moves memory UUtMemory_Array* inMemoryArray, UUtUns32 inIndex); - + UUtError UUrMemory_Array_InsertElement( // This always moves memory UUtMemory_Array* inMemoryArray, UUtUns32 inIndex, UUtBool *outMemoryMoved); - + UUtUns32 UUrMemory_Array_GetUsedElems( // This is used to return the number of elements in use UUtMemory_Array* inMemoryArray); - + UUtError UUrMemory_Array_SetUsedElems( // This is used to set the number of elements in use UUtMemory_Array* inMemoryArray, UUtUns32 inElemsUsed, UUtBool *outMemoryMoved); - + /* * Parallel array functions - operations effect all member arrays */ @@ -940,26 +940,26 @@ extern "C" { { UUcMemory_ParallelArray_MaxMembers = 5 }; - + typedef struct UUtMemory_ParallelArray UUtMemory_ParallelArray; typedef struct UUtMemory_ParallelArray_Member UUtMemory_ParallelArray_Member; - UUtMemory_ParallelArray* + UUtMemory_ParallelArray* UUrMemory_ParallelArray_New_Real( // This is used to create a new parallel array UUtUns32 inAllocChunkSize, // The chunk size of incremental allocations UUtUns32 inNumInitialElemsUsed, // The number of elements initially used UUtUns32 inNumElemsToAlloc); // The number of elements to allocate - - void + + void UUrMemory_ParallelArray_Delete_Real( // This is used to delete a parallel array UUtMemory_ParallelArray* inParallelArray); - - UUtMemory_ParallelArray_Member* + + UUtMemory_ParallelArray_Member* UUrMemory_ParallelArray_Member_New( // This is used to create a new member array UUtMemory_ParallelArray* inParallelArray, UUtUns32 inElementSize); - - UUtError + + UUtError UUrMemory_ParallelArray_MakeRoom( // This is used to make sure that enough elems have been allocated UUtMemory_ParallelArray* inParallelArray, UUtUns32 inNumElems, @@ -969,23 +969,23 @@ extern "C" { UUrMemory_ParallelArray_DeleteElement( // This is used to delete a element in every member array UUtMemory_ParallelArray* inParallelArray, UUtUns32 inIndex); - + UUtUns32 UUrMemory_ParallelArray_GetNumUsedElems( // This is used to return the number of used elements UUtMemory_ParallelArray* inParallelArray); - + UUtError UUrMemory_ParallelArray_SetUsedElems( // This is used to set the number of elements in use UUtMemory_ParallelArray* inParallelArray, UUtUns32 inElemsUsed, UUtBool *outMemoryMoved); - + UUtError UUrMemory_ParallelArray_AddNewElem( // This adds a new element to every member array - use UUrMemory_ParallelArray_Member_GetNewElement_Real to get the memory UUtMemory_ParallelArray* inParallelArraym, UUtUns32 *outNewIndex, UUtBool *outMemoryMoved); - + void* UUrMemory_ParallelArray_Member_GetMemory( // This is used to get the pointer to the linear array memory UUtMemory_ParallelArray* inParallelArray, @@ -995,25 +995,25 @@ extern "C" { UUrMemory_ParallelArray_Member_GetNewElement( // This is used to get the new element from a member array UUtMemory_ParallelArray* inParallelArray, UUtMemory_ParallelArray_Member* inMemberArray); - + /* * String memory utilities */ typedef struct UUtMemory_String UUtMemory_String; - + UUtMemory_String* UUrMemory_String_New( UUtUns32 inTableSize); - + void UUrMemory_String_Delete( UUtMemory_String* inMemoryString); - + char* UUrMemory_String_GetStr( UUtMemory_String* inMemoryString, const char* inStr); - + UUtUns32 UUrMemory_String_GetSize( UUtMemory_String* inMemoryString); @@ -1021,27 +1021,27 @@ extern "C" { void UUrMemory_String_Reset( UUtMemory_String* inMemoryString); - + #if 0 && defined(DEBUGGING) && DEBUGGING #define DEBUGGING_MEMORY 1 #endif - + #if DEBUGGING_MEMORY - + #define UUmMemoryBlock_Garbage ((unsigned long)'UUGB') #define UUmMemoryBlock_GarbageTest ((void *)'UUGB') /* * Block allocation debug functions */ - void + void UUrMemory_Block_VerifyList( void); - void + void UUrMemory_Block_Verify( void *inMemory); - + void* UUrMemory_Block_New_Debug( char* inFile, @@ -1054,12 +1054,12 @@ extern "C" { long inLine, unsigned long inSize); - void + void UUrMemory_Block_Delete_Debug( char* inFile, long inLine, void* inMemory); - + void* UUrMemory_Block_Realloc_Debug( char *inFile, @@ -1070,44 +1070,44 @@ extern "C" { /* * Memory pool debug functions */ - - UUtMemory_Pool* + + UUtMemory_Pool* UUrMemory_Pool_New_Debug( char* inFile, long inLine, UUtUns32 inChunkSize, UUtBool inFixed); - - void + + void UUrMemory_Pool_Delete_Debug( char* inFile, long inLine, UUtMemory_Pool* inMemoryPool); - + /* * Memory heap debug functions */ - - UUtMemory_Heap* + + UUtMemory_Heap* UUrMemory_Heap_New_Debug( char* inFile, long inLine, UUtUns32 inChunkSize, UUtBool inFixed); - - void + + void UUrMemory_Heap_Delete_Debug( char* inFile, long inLine, UUtMemory_Heap* inMemoryHeap); - + void * UUrMemory_Heap_Block_New_Debug( // This is used to allocate a block within a heap char* inFile, long inLine, UUtMemory_Heap *inMemoryHeap, UUtUns32 inSize); - + void UUrMemory_Heap_Block_Delete_Debug( // This is used to allocate a block within a heap char* inFile, @@ -1118,7 +1118,7 @@ extern "C" { /* * Resizeable array debug functions */ - UUtMemory_Array* + UUtMemory_Array* UUrMemory_Array_New_Debug( char* inFile, long inLine, @@ -1127,29 +1127,29 @@ extern "C" { UUtUns32 inNumInitialElemsUsed, UUtUns32 inNumElemsToAlloc); - void + void UUrMemory_Array_Delete_Debug( char* inFile, long inLine, UUtMemory_Array* inMemoryArray); - + /* * Parallel array debug functions */ - UUtMemory_ParallelArray* + UUtMemory_ParallelArray* UUrMemory_ParallelArray_New_Debug( char* inFile, long inLine, UUtUns32 inAllocChunkSize, UUtUns32 inNumInitialElemsUsed, UUtUns32 inNumElemsToAlloc); - - void + + void UUrMemory_ParallelArray_Delete_Debug( char* inFile, long inLine, UUtMemory_ParallelArray* inParallelArray); - + /* * Functions for tracing mem leaks */ @@ -1158,20 +1158,20 @@ extern "C" { char* inFileName, UUtInt32 inLineNum, const char* inComment); - + void UUrMemory_Leak_StopAndReport_Real( void); - + /* - * + * */ void UUrMemory_Heap_Block_Verify( UUtMemory_Heap* inMemoryHeap, void* inPtr, UUtUns32 inLength); - + UUtBool UUrMemory_SetVerifyEnable( UUtBool inEnable); @@ -1185,22 +1185,22 @@ extern "C" { */ #define UUrMemory_Block_New(size) \ UUrMemory_Block_New_Debug(__FILE__, __LINE__, size) - + #define UUrMemory_Block_NewClear(size) \ UUrMemory_Block_NewClear_Debug(__FILE__, __LINE__, size) - + #define UUrMemory_Block_Delete(ptr) \ UUrMemory_Block_Delete_Debug(__FILE__, __LINE__, ptr) - + #define UUrMemory_Block_Realloc(ptr, size) \ UUrMemory_Block_Realloc_Debug(__FILE__, __LINE__, ptr, size) - + /* * Memory pool macros */ #define UUrMemory_Pool_New(chunkSize, fixed) \ UUrMemory_Pool_New_Debug(__FILE__, __LINE__, chunkSize, fixed) - + #define UUrMemory_Pool_Delete(pool) \ UUrMemory_Pool_Delete_Debug(__FILE__, __LINE__, pool) @@ -1209,101 +1209,101 @@ extern "C" { */ #define UUrMemory_Heap_New(chunkSize, fixed) \ UUrMemory_Heap_New_Debug(__FILE__, __LINE__, chunkSize, fixed) - + #define UUrMemory_Heap_Delete(heap) \ UUrMemory_Heap_Delete_Debug(__FILE__, __LINE__, heap) - + #define UUrMemory_Heap_Block_New(heap, size) \ UUrMemory_Heap_Block_New_Debug(__FILE__, __LINE__, heap, size) - + #define UUrMemory_Heap_Block_Delete(heap, ptr) \ UUrMemory_Heap_Block_Delete_Debug(__FILE__, __LINE__, heap, ptr) - + /* * Resizeable array macros */ #define UUrMemory_Array_New(inElementSize, inAllocChunkSize, inNumInitialElemsUsed, inNumElemsToAlloc) \ UUrMemory_Array_New_Debug(__FILE__, __LINE__, inElementSize, inAllocChunkSize, inNumInitialElemsUsed, inNumElemsToAlloc) - + #define UUrMemory_Array_Delete(inMemoryArray) \ UUrMemory_Array_Delete_Debug(__FILE__, __LINE__, inMemoryArray) - + /* * Parallel array macros */ #define UUrMemory_ParallelArray_New(inAllocChunkSize, inNumInitialElemsUsed, inNumElemsToAlloc) \ UUrMemory_ParallelArray_New_Debug(__FILE__, __LINE__, inAllocChunkSize, inNumInitialElemsUsed, inNumElemsToAlloc) - + #define UUrMemory_ParallelArray_Delete(inParallelArray) \ UUrMemory_ParallelArray_Delete_Debug(__FILE__, __LINE__, inParallelArray) - + /* * Leak macros */ #define UUrMemory_Leak_Start(comm) UUrMemory_Leak_Start_Real(__FILE__, __LINE__, comm) #define UUrMemory_Leak_StopAndReport() UUrMemory_Leak_StopAndReport_Real() - + #define UUrMemory_Leak_ForceGlobal_Begin() UUrMemory_Leak_ForceGlobal_Begin_Real() #define UUrMemory_Leak_ForceGlobal_End() UUrMemory_Leak_ForceGlobal_End_Real() - + void UUrMemory_Leak_ForceGlobal_Begin_Real( void); - + void UUrMemory_Leak_ForceGlobal_End_Real( void); - - #else - + + #else + #define UUrMemory_Heap_Block_Verify(x, y, z) #define UUrMemory_SetVerifyEnable(x) UUcFalse #define UUrMemory_SetVerifyForce(x) - + /* Non debugging macors */ - + /* * Block allocation macros */ #define UUrMemory_Block_VerifyList() - + #define UUrMemory_Block_Verify(inMemory) - + #define UUrMemory_Block_New(size) \ UUrMemory_Block_New_Real(size) - + #define UUrMemory_Block_NewClear(size) \ UUrMemory_Block_NewClear_Real(size) - + #define UUrMemory_Block_Delete(ptr) \ UUrMemory_Block_Delete_Real(ptr) - + #define UUrMemory_Block_Realloc(ptr, size) \ UUrMemory_Block_Realloc_Real(ptr, size) - - + + /* * Memory pool macros */ #define UUrMemory_Pool_New(chunkSize, fixed) \ UUrMemory_Pool_New_Real(chunkSize, fixed) - + #define UUrMemory_Pool_Delete(pool) \ UUrMemory_Pool_Delete_Real(pool) - - + + /* * Memory heap macros */ #define UUrMemory_Heap_New(chunkSize, fixed) \ UUrMemory_Heap_New_Real(chunkSize, fixed) - + #define UUrMemory_Heap_Delete(heap) \ UUrMemory_Heap_Delete_Real(heap) - + #define UUrMemory_Heap_Block_New(heap, size) \ UUrMemory_Heap_Block_New_Real(heap, size) - + #define UUrMemory_Heap_Block_Delete(heap, ptr) \ UUrMemory_Heap_Block_Delete_Real(heap, ptr) @@ -1312,16 +1312,16 @@ extern "C" { */ #define UUrMemory_Array_New(inElementSize, inAllocChunkSize, inNumInitialElemsUsed, inNumElemsToAlloc) \ UUrMemory_Array_New_Real(inElementSize, inAllocChunkSize, inNumInitialElemsUsed, inNumElemsToAlloc) - + #define UUrMemory_Array_Delete(inMemoryArray) \ UUrMemory_Array_Delete_Real(inMemoryArray) - + /* * Parallel array macros */ #define UUrMemory_ParallelArray_New(inAllocChunkSize, inNumInitialElemsUsed, inNumElemsToAlloc) \ UUrMemory_ParallelArray_New_Real(inAllocChunkSize, inNumInitialElemsUsed, inNumElemsToAlloc) - + #define UUrMemory_ParallelArray_Delete(inParallelArray) \ UUrMemory_ParallelArray_Delete_Real(inParallelArray) @@ -1346,7 +1346,7 @@ extern "C" { #if DEBUGGING_MEMORY - void UUrMemory_MoveFast_Debug(const void *inSrc, void *inDst, UUtUns32 inSize); + void UUrMemory_MoveFast_Debug(const void *inSrc, void *inDst, UUtUns32 inSize); void UUrMemory_MoveOverlap_Debug(const void *inSrc, void *inDst, UUtUns32 inSize); void UUrMemory_Clear_Debug(void *inDst, UUtUns32 inNumBytes); void UUrMemory_Set8_Debug(void *inDst, UUtUns8 inFillValue, UUtUns32 inNumBytes); @@ -1355,7 +1355,7 @@ extern "C" { static UUcInline UUtBool UUrMemory_IsEqual(const void *inPtrA, const void *inPtrB, UUtUns32 inLength) { UUtBool result; - + result = 0 == memcmp(inPtrA, inPtrB, inLength); return result; @@ -1429,23 +1429,23 @@ extern "C" { void UUrString_PadNumber(UUtInt32 inNumber, UUtInt32 inDigits, char *outString); char* UUrTag2Str(UUtUns32 inTag); - + #if UUmPlatform == UUmPlatform_Mac - + #define UUmNL "\n" - + #elif UUmPlatform == UUmPlatform_Win32 - + #define UUmNL "\r\n" - + #elif UUmPlatform == UUmPlatform_Linux - + #define UUmNL "\n" - + #else - + #error define me - + #endif /* * ============================ Random Numbers ============================ @@ -1481,10 +1481,10 @@ extern "C" { // Random float, 0->1 // S.S. #define UUmRandomFloat ((float)UUrRandom() / (float)UUcMaxUns16) #define UUmRandomFloat ((float)UUrRandom() * 1.52590219e-5f) - + // Random float, lo->hi #define UUmRandomRangeFloat(lo,hi) (UUmRandomFloat * ((hi)-(lo)) + (lo)) - + /* * Interrupt handling utilities @@ -1511,37 +1511,37 @@ extern "C" { void* inAddr) { UUtUns32 i = *(UUtUns32*)inAddr; - + UUmAssertReadPtr(inAddr, 4); - + *(UUtUns32*)inAddr = ((i & 0xFF000000) >> 24) | ((i & 0x00FF0000) >> 8) | ((i & 0x0000FF00) << 8) | ((i & 0x000000FF) << 24); } - static UUcInline void + static UUcInline void UUrSwap_2Byte( void *inAddr) { UUtUns16 i = *(UUtUns16*)inAddr; - + UUmAssertReadPtr(inAddr, 2); - + *(UUtUns16*)inAddr = ((i & 0xFF00) >> 8) | ((i & 0x00FF) << 8); } - static UUcInline void + static UUcInline void UUrSwap_8Byte( void* inAddr) - { + { UUtUns32* p = (UUtUns32*)inAddr; UUtUns32 v; UUmAssertReadPtr(inAddr, 8); - + v = p[0]; p[0] = p[1]; p[1] = v; - + UUrSwap_4Byte(p); UUrSwap_4Byte(p + 1); } @@ -1549,7 +1549,7 @@ extern "C" { void UUrSwap_2Byte_Array(void *inAddr, UUtUns32 count); void UUrSwap_4Byte_Array(void *inAddr, UUtUns32 count); void UUrSwap_8Byte_Array(void *inAddr, UUtUns32 count); - + #if UUmEndian == UUmEndian_Big #define UUmSwapLittle_2Byte(addr) UUrSwap_2Byte(addr) #define UUmSwapLittle_4Byte(addr) UUrSwap_4Byte(addr) @@ -1579,7 +1579,7 @@ extern "C" { #define UUmSwapBig_4Byte_Array(addr, count) UUrSwap_4Byte_Array(addr, count) #define UUmSwapBig_8Byte_Array(addr, count) UUrSawp_8Byte_Array(addr, count) #else - #pragma error + #pragma error #endif #define UUmSwapNet_2Byte(addr) UUmSwapLittle_2Byte(addr) @@ -1591,20 +1591,20 @@ extern "C" { */ UUtError UUrInitialize( UUtBool inInitializeBasePlatform); - + void UUrTerminate( void); - + /* * Our atexit functions */ typedef void (UUcExternal_Call *UUtAtExitProc)(void); - + UUtError - UUrAtExit_Register( + UUrAtExit_Register( UUtAtExitProc inAtExitProc); - + /* * Performance monitoring utilities */ @@ -1612,48 +1612,48 @@ extern "C" { #if UUmCompiler == UUmCompiler_VisC #define PROFILE 1 #endif - + typedef enum UUtProfileState { UUcProfile_State_Off, UUcProfile_State_On - + } UUtProfileState; - + #if defined(PROFILE) && PROFILE - + UUtError UUrProfile_Initialize( void); - + void UUrProfile_Terminate( void); - + void UUrProfile_State_Set( UUtProfileState inProfileState); - + UUtProfileState UUrProfile_State_Get( void); - + void UUrProfile_Dump( char* inFileName); - + #else - + #define UUrProfile_Initialize() (UUcError_None) #define UUrProfile_Terminate() #define UUrProfile_State_Set(x) #define UUrProfile_State_Get() UUcProfile_State_Off #define UUrProfile_Dump(x) - + #endif /* - * + * */ UUtUns32 UUrStack_GetPCChain( @@ -1703,7 +1703,7 @@ FILE *UUrFOpen( UUtUns32 UUrGetSecsSince1900( void); - + UUtUns32 UUrConvertStrToSecsSince1900( char* inStr); // MMM DD YYYY HH:MM:SS @@ -1712,11 +1712,11 @@ FILE *UUrFOpen( UUrConvertSecsSince1900ToStr( UUtUns32 inSecs, char* inBuffer); // MMM DD YYYY HH:MM:SS - + /* - * ============================ Queue Functions ============================ + * ============================ Queue Functions ============================ * - * note: not suitable for threads, if you must have threads add a + * note: not suitable for threads, if you must have threads add a * thread get, which memcopies or peak(..., 0) copy and get instead * of getting * @@ -1734,16 +1734,16 @@ UUtError UUrQueue_Add(UUtQueue *inQueue, void *inElement); UUtUns16 UUrQueue_CountMembers(UUtQueue *inQueue); UUtUns16 UUrQueue_CountVacant(UUtQueue *inQueue); - + /* - * ============================ Misc Junk ============================ + * ============================ Misc Junk ============================ */ UUtUns32 UUrStringToOSType(char *inString); #define UUmCompileTimeString __DATE__" "__TIME__ #define UUmCompileTimeSince1900 UUrConvertStrToSecsSince1900(UUmCompileTimeString) - + #if UUmPlatform == UUmPlatform_Mac #define UUc1904_To_1900_era_offset ((365UL * 4UL) * 24UL * 60UL * 60UL) @@ -1757,7 +1757,7 @@ UUtUns16 UUrQueue_CountVacant(UUtQueue *inQueue); #include "BFW_ErrorCodes.h" /* - * ============================ String stuff ============================ + * ============================ String stuff ============================ */ UUtBool @@ -1778,7 +1778,7 @@ UUtUns16 UUrQueue_CountVacant(UUtQueue *inQueue); UUrString_MakeLowerCase( char* ioString, UUtUns32 inLength); - + UUtBool UUrString_Substring( const char* inString, @@ -1794,13 +1794,13 @@ UUtUns16 UUrQueue_CountVacant(UUtQueue *inQueue); UUrString_NukeNumSuffix( char* ioString, UUtUns32 inLength); - + void UUrString_Copy( // This copies the terminator as well char* inDst, const char* inSrc, UUtUns32 inDstLength); // length includes the terminator - + // CB: copy at most inCopyLength characters to inDst // this does not include the terminator, which will be copied // only if there is room for it in inDst @@ -1831,18 +1831,18 @@ UUtUns16 UUrQueue_CountVacant(UUtQueue *inQueue); char *ioString, const char *inStrDelimit, char **internal); // private char *, pass in - + void UUrString_PStr2CStr( const unsigned char*const inPStr, char *outCStr, UUtUns32 inBufferSize); - + void UUrString_StripExtension( char* inStr); - - + + /* * Various one way functions */ @@ -1855,12 +1855,12 @@ UUtUns16 UUrQueue_CountVacant(UUtQueue *inQueue); UUtUns8 UUrOneWayFunction_Uns8( UUtUns8 inUns8); - + void UUrOneWayFunction_ConvertString( char* ioString, UUtUns16 inLength); - + UUtBool UUrOneWayFunction_CompareString( char* inNormalString, diff --git a/BungieFrameWork/BFW_Headers/BFW_Akira.h b/BungieFrameWork/BFW_Headers/BFW_Akira.h index 477f8ed..193b387 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Akira.h +++ b/BungieFrameWork/BFW_Headers/BFW_Akira.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_Akira.h - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: July 15, 1998 - + PURPOSE: environment engine - + Copyright 1997-2000 */ @@ -31,7 +31,7 @@ //#define AKcMaxAdjacency 32 /* Maximum number of nodes that can share a partition */ #define AKcSphereCollisionPasses 3 /* Maximum number of supported multiple collisions */ #define AKcSphereCollisionFudge 0.001f // How much extra we push out to avoid repeat collision -#define AKcPointCollisionFudge 0.01f +#define AKcPointCollisionFudge 0.01f #define AKcBNV_OutsideAcceptDistance 5.0f /* so that we never reject a BNV that we are just a fraction outside of */ @@ -81,7 +81,7 @@ planeC = p->c; \ planeD = p->d; \ } while(0); - + // Given that x, y, and z are 0 or 1 compute the index into the node child array //#define AKmOctTreeChildIndex(x, y, z) ((x << 2) | (y << 1) | z) #define AKmOctTree_IsLeafNode(x) ((x) & 0x80000000) @@ -164,7 +164,7 @@ typedef tm_struct AKtAlphaBSPTree_Node UUtUns32 planeEquIndex; UUtUns32 posNodeIndex; UUtUns32 negNodeIndex; - + } AKtAlphaBSPTree_Node; #define AKcTemplate_AlphaBSPTree_NodeArray UUm4CharToUns32('A', 'B', 'N', 'A') @@ -172,16 +172,16 @@ typedef tm_template('A', 'B', 'N', 'A', "bsp tree node Array") AKtAlphaBSPTree_NodeArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numNodes; tm_vararray AKtAlphaBSPTree_Node nodes[1]; - + } AKtAlphaBSPTree_NodeArray; typedef tm_struct AKtQuadTree_Node { UUtUns32 children[4]; - + } AKtQuadTree_Node; #define AKcOctTree_Shift_Dim 27 @@ -205,7 +205,7 @@ typedef tm_struct AKtOctTree_LeafNode // 9 bits - max y position // 9 bits - max z position UUtUns32 bnvIndirectIndex_Encode; // high order 24 bits is the base - low order 8 is the length - + } AKtOctTree_LeafNode; typedef tm_struct AKtOctTree_InteriorNode @@ -219,10 +219,10 @@ typedef tm_template('Q', 'T', 'N', 'A', "Quad tree node Array") AKtQuadTree_NodeArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numNodes; tm_vararray AKtQuadTree_Node nodes[1]; - + } AKtQuadTree_NodeArray; #define AKcTemplate_OctTree_LeafNodeArray UUm4CharToUns32('O', 'T', 'L', 'F') @@ -230,10 +230,10 @@ typedef tm_template('O', 'T', 'L', 'F', "Oct tree leaf node Array") AKtOctTree_LeafNodeArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numNodes; tm_vararray AKtOctTree_LeafNode nodes[1]; - + } AKtOctTree_LeafNodeArray; #define AKcTemplate_OctTree_InteriorNodeArray UUm4CharToUns32('O', 'T', 'I', 'T') @@ -241,10 +241,10 @@ typedef tm_template('O', 'T', 'I', 'T', "Oct tree interior node Array") AKtOctTree_InteriorNodeArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numNodes; tm_vararray AKtOctTree_InteriorNode nodes[1]; - + } AKtOctTree_InteriorNodeArray; #define AKcTemplate_OctTree UUm4CharToUns32('A', 'K', 'O', 'T') @@ -256,7 +256,7 @@ AKtOctTree AKtQuadTree_NodeArray* qtNodeArray; TMtIndexArray* gqIndices; TMtIndexArray* bnvIndices; - + } AKtOctTree; /* @@ -274,10 +274,10 @@ typedef tm_template('A', 'K', 'B', 'P', "BSP node Array") AKtBSPNodeArray { tm_pad pad0[22]; - + tm_varindex UUtUns16 numNodes; tm_vararray AKtBNV_BSPNode nodes[1]; - + } AKtBSPNodeArray; /* @@ -292,7 +292,7 @@ AKtBSPNodeArray AKcGQ_Flag_SAT_Down = (1 << 3), AKcGQ_Flag_Stairs = (1 << 4), AKcGQ_Flag_Jello = (1 << 5), - AKcGQ_Flag_Triangle = (1 << 6), + AKcGQ_Flag_Triangle = (1 << 6), AKcGQ_Flag_Transparent = (1 << 7), AKcGQ_Flag_Draw_Flash = (1 << 8), AKcGQ_Flag_DrawBothSides = (1 << 9), @@ -331,7 +331,7 @@ AKtBSPNodeArray #define AKcGQ_Flag_SoundOcclude_Skip (AKcGQ_Flag_No_Collision | AKcGQ_Flag_No_Object_Collision | AKcGQ_Flag_BrokenGlass | AKcGQ_Flag_SoundTransparent) #define AKcGQ_Flag_2Sided (AKcGQ_Flag_Transparent | AKcGQ_Flag_DrawBothSides | AKcGQ_Flag_Jello) - + #define AKcGQ_Flag_SAT_Mask ( \ AKcGQ_Flag_SAT_Up | \ AKcGQ_Flag_SAT_Down) @@ -340,16 +340,16 @@ AKtBSPNodeArray AKcGQ_Flag_Ghost | \ AKcGQ_Flag_SAT_Mask | \ AKcGQ_Flag_Door) - + #define AKcGQ_Flag_NoTextureMask ( \ AKcGQ_Flag_PathfindingMask) - + #define AKcGQ_Flag_DontLight (AKcGQ_Flag_Invisible | AKcGQ_Flag_NoTextureMask | AKcGQ_Flag_2Sided) #define AKmGetQuadProjection(flags) ((flags & AKcGQ_Flag_Projection_Mask) >> AKcGQ_Flag_Projection_Shift) typedef UUtUns32 AKtGQ_Flags; - + #define AKcTemplate_GQ_Material UUm4CharToUns32('A', 'G', 'Q', 'M') typedef tm_template('A', 'G', 'Q', 'M', "Gunk Quad Material") AKtGQMaterial @@ -367,23 +367,23 @@ AKtBSPNodeArray UUtUns32 flags; // These are the flags UUtUns32 object_tag; // -1 if not an object (furniture, console, turret, door, etc) }; - + tm_struct AKtGQ_Render { UUtUns16 textureMapIndex; UUtUns16 alpha; - + // CB: these are no longer used anywhere (they were never reliable anyway) so I'm nuking them //UUtUns32 adjGQIndices[4]; }; - + typedef tm_struct AKtGQ_Debug { tm_raw(char *) object_name; tm_raw(char *) file_name; } AKtGQ_Debug; - + typedef tm_struct AKtGQ_Collision { // CB: projection only had two significant bits! they are now stored in gqGeneral->flags. @@ -391,7 +391,7 @@ AKtBSPNodeArray UUtUns32 planeEquIndex; // This is the index into the plane equation array // These are used to quickly compute the bbox for this quad - M3tBoundingBox_MinMax bBox; + M3tBoundingBox_MinMax bBox; } AKtGQ_Collision; #define AKcTemplate_GQ_General UUm4CharToUns32('A', 'G', 'Q', 'G') @@ -399,10 +399,10 @@ AKtBSPNodeArray AKtGQGeneralArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numGQs; tm_vararray AKtGQ_General gqGeneral[1]; - + } AKtGQGeneralArray; #define AKcTemplate_GQ_Render UUm4CharToUns32('A', 'G', 'Q', 'R') @@ -410,10 +410,10 @@ AKtBSPNodeArray AKtGQRenderArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numGQs; tm_vararray AKtGQ_Render gqRender[1]; - + } AKtGQRenderArray; #define AKcTemplate_GQ_Collision UUm4CharToUns32('A', 'G', 'Q', 'C') @@ -421,10 +421,10 @@ AKtBSPNodeArray AKtGQCollisionArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numGQs; tm_vararray AKtGQ_Collision gqCollision[1]; - + } AKtGQCollisionArray; #define AKcTemplate_GQ_Debug UUm4CharToUns32('A', 'G', 'D', 'B') @@ -432,10 +432,10 @@ AKtBSPNodeArray AKtGQDebugArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numGQs; tm_vararray AKtGQ_Debug gqDebug[1]; - + } AKtGQDebugArray; /* @@ -451,7 +451,7 @@ AKtBSPNodeArray AKcBNV_Flag_SimplePathfinding = (1 << 4) // gridless pathfinding in this room }; #define AKcBNV_Flag_Stairs (AKcBNV_Flag_Stairs_Standard | AKcBNV_Flag_Stairs_Spiral) - + /* * */ @@ -459,79 +459,79 @@ AKtBSPNodeArray { UUtUns32 adjacentBNVIndex; // Node connection data UUtUns32 adjacentGQIndex; // Absolute gunk quad indices of shared ???s - UUtUns32 adjacencyFlags; + UUtUns32 adjacencyFlags; } AKtAdjacency; - + #define AKcTemplate_AdjacencyArray UUm4CharToUns32('A', 'K', 'A', 'A') typedef tm_template('A', 'K', 'A', 'A', "Adjacency Array") AKtAdjacencyArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numAdjacenies; tm_vararray AKtAdjacency adjacencies[1]; - + } AKtAdjacencyArray; typedef tm_struct AKtBNVNode_Side { UUtUns32 planeEquIndex; - + UUtUns32 adjacencyStartIndex; UUtUns32 adjacencyEndIndex; - + UUtUns32 ghostGQStartIndIndex; UUtUns32 ghostGQEndIndIndex; - + UUtUns32 bnvQuadStartIndIndex; UUtUns32 bnvQuadEndIndIndex; } AKtBNVNode_Side; - + #define AKcTemplate_BNVNodeSideArray UUm4CharToUns32('A', 'K', 'B', 'A') typedef tm_template('A', 'K', 'B', 'A', "Side Array") AKtBNVNodeSideArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numSides; tm_vararray AKtBNVNode_Side sides[1]; - + } AKtBNVNodeSideArray; /* - * + * */ typedef tm_struct AKtBNVNode - { + { UUtUns32 bspRootNode; UUtUns32 index; // Our index in the environment - + UUtUns32 sideStartIndex; // Index into the volume side array UUtUns32 sideEndIndex; // - + UUtUns32 childIndex; UUtUns32 nextIndex; - + UUtUns32 pathnodeIndex; // set at runtime PHtRoomData roomData; // Pathfinding data UUtUns32 flags; M3tPlaneEquation stairPlane; float stairHeight; - + } AKtBNVNode; /* - * + * */ #define AKcTemplate_BNVNodeArray UUm4CharToUns32('A', 'K', 'V', 'A') typedef tm_template('A', 'K', 'V', 'A', "BNV Node Array") AKtBNVNodeArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numNodes; tm_vararray AKtBNVNode nodes[1]; - + } AKtBNVNodeArray; /* @@ -552,20 +552,20 @@ AKtBSPNodeArray AKtDoorFrameArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 door_count; tm_vararray AKtDoorFrame door_frames[1]; - + } AKtDoorFrameArray; /* - * + * */ #define AKcTemplate_Environment UUm4CharToUns32('A', 'K', 'E', 'V') tm_template('A', 'K', 'E', 'V', "Akira Environment") AKtEnvironment - { + { M3tPoint3DArray* pointArray; // List of points used by the nodes of this object M3tPlaneEquationArray* planeArray; // List of planes used by the nodes of this object M3tTextureCoordArray* textureCoordArray; // List of texture coordinates for base and light coords @@ -574,9 +574,9 @@ AKtBSPNodeArray AKtGQRenderArray* gqRenderArray; AKtGQCollisionArray* gqCollisionArray; AKtGQDebugArray* gqDebugArray; // CB: this may be NULL if shipping version - + M3tTextureMapArray* textureMapArray; // Arrays of texture map - + AKtBNVNodeArray* bnvNodeArray; // Array of volume nodes AKtBNVNodeSideArray* bnvSideArray; // List of volume node sides @@ -584,13 +584,13 @@ AKtBSPNodeArray TMtIndexArray* envQuadRemaps; // Script remap IDs of those quads AKtBSPNodeArray* bspNodeArray; // List of BSP Nodes - + AKtAlphaBSPTree_NodeArray* alphaBSPNodeArray; // list of BSP nodes for alpha quads - + AKtOctTree* octTree; - + AKtAdjacencyArray* adjacencyArray; - + AKtDoorFrameArray* door_frames; // Array of doors frames M3tBoundingBox_MinMax bbox; // bounding box for the environment @@ -604,28 +604,28 @@ AKtBSPNodeArray * Collision stuff */ #define AKcMaxNumCollisions 255 // reducing less then 100 is known to break character collision - + typedef struct AKtCollision { UUtUns32 compare_distance; CLtCollisionType collisionType; UUtUns16 contactType; - + M3tPlaneEquation plane; M3tPoint3D collisionPoint; - + UUtUns32 gqIndex; // For face collisions M3tPoint3D bEdgeL,bEdgeR; // For bbox collisions (which edge (Collision) or vertex (Contact) of bbox collided) - + float float_distance; - + } AKtCollision; - + extern AKtCollision AKgCollisionList[AKcMaxNumCollisions]; extern UUtUns16 AKgNumCollisions; extern AKtEnvironment* AKgEnvironment; - + /* * Spatial locality */ @@ -645,7 +645,7 @@ AKrLevel_Begin( void AKrLevel_End( void); - + UUtError AKrInitialize( void); @@ -666,7 +666,7 @@ AKrEnvironment_SetContextDimensions( void AKrEnvironment_FastMode(UUtBool inFast); void AKrEnvironment_GunkChanged(void); - + UUtError AKrEnvironment_StartFrame( AKtEnvironment* inEnvironment, @@ -712,7 +712,7 @@ void AKrEnvironment_DrawIfVisible_Point( M3tGeometry *inGeometry, const M3tMatrix4x3 *inMatrix); - + AKtBNVNode* AKrNodeFromPoint( const M3tPoint3D* inPoint); @@ -747,7 +747,7 @@ UUtBool AKrLineOfSight( M3tPoint3D *inPointA, M3tPoint3D *inPointB); - + UUtUns32 AKrGQToIndex( AKtEnvironment* inEnvironment, @@ -760,7 +760,7 @@ AKrPointInNode( UUtUns32 inNodeIndex, M3tPlaneEquation* outRejectingPlane, float* outRejectionValue); - + UUtBool AKrPointInNodeVertically( const M3tPoint3D* inPoint, diff --git a/BungieFrameWork/BFW_Headers/BFW_AppUtilities.h b/BungieFrameWork/BFW_Headers/BFW_AppUtilities.h index 9d2ca4d..8cd863f 100644 --- a/BungieFrameWork/BFW_Headers/BFW_AppUtilities.h +++ b/BungieFrameWork/BFW_Headers/BFW_AppUtilities.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_AppUtilities.h - + AUTHOR: Brent H. Pease - + CREATED: Feb 27, 1998 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1998 */ @@ -33,7 +33,7 @@ extern "C" (*AUtSharedElemArray_Equal)( void* inElemA, void* inElemB); - + AUtSharedElemArray* AUrSharedElemArray_New( UUtUns32 inElemSize, @@ -75,16 +75,16 @@ extern "C" void* AUrSharedElemArray_GetList( AUtSharedElemArray* inSharedElemArray); - + UUtUns32* AUrSharedElemArray_GetSortedIndexList( AUtSharedElemArray* inSharedElemArray); - + /* * Shared point functions */ typedef struct AUtSharedPointArray AUtSharedPointArray; - + AUtSharedPointArray* AUrSharedPointArray_New( void); @@ -119,25 +119,25 @@ extern "C" UUtUns32 AUrSharedPointArray_GetNum( AUtSharedPointArray* inSharedPointArray); - + void AUrSharedPointArray_Dump( AUtSharedPointArray* inSharedPointArray, FILE* inFile); - + UUtError AUrSharedPointArray_CreateTemplate( AUtSharedPointArray* inSharedPointArray, char* inName, M3tPoint3DArray* *outReference); - + UUtError AUrSharedPointArray_InterpolatePoint( AUtSharedPointArray* inPointArray, - float inA, - float inB, - float inC, - float inD, + float inA, + float inB, + float inC, + float inD, M3tPoint3D* inInVertex, M3tPoint3D* inOutVertex, UUtUns32 *outNewVertexIndex); @@ -149,7 +149,7 @@ extern "C" * This means that d is always positive in the actual list of plane equations */ typedef struct AUtSharedPlaneEquArray AUtSharedPlaneEquArray; - + AUtSharedPlaneEquArray* AUrSharedPlaneEquArray_New( void); @@ -178,7 +178,7 @@ extern "C" UUtUns32 AUrSharedPlaneEquArray_GetNum( AUtSharedPlaneEquArray* inSharedPlaneEquArray); - + void AUrSharedPlaneEquArray_Dump( AUtSharedPlaneEquArray* inSharedPlaneEquArray, @@ -189,7 +189,7 @@ extern "C" AUtSharedPlaneEquArray* inSharedPlaneEquArray, char* inName, M3tPlaneEquationArray* *outReference); - + UUtBool AUrSharedPlaneEquArray_FindPlaneEqu( AUtSharedPlaneEquArray* inSharedPlaneEquArray, @@ -198,12 +198,12 @@ extern "C" float inC, float inD, UUtUns32 *outPlaneEquIndex); - + /* * Shared Quad functions */ typedef struct AUtSharedQuadArray AUtSharedQuadArray; - + AUtSharedQuadArray* AUrSharedQuadArray_New( void); @@ -236,23 +236,23 @@ extern "C" UUtUns32 AUrSharedQuadArray_GetNum( AUtSharedQuadArray* inSharedQuadArray); - + void AUrSharedQuadArray_Dump( AUtSharedQuadArray* inSharedQuadArray, FILE* inFile); - + UUtError AUrSharedQuadArray_CreateTemplate( AUtSharedQuadArray* inSharedQuadArray, char* inName, M3tQuadArray* *outReference); - + /* * Shared Vector functions */ typedef struct AUtSharedVectorArray AUtSharedVectorArray; - + AUtSharedVectorArray* AUrSharedVectorArray_New( void); @@ -285,7 +285,7 @@ extern "C" AUrSharedVectorArray_Dump( AUtSharedVectorArray* inSharedVectorArray, FILE* inFile); - + UUtError AUrSharedVectorArray_CreateTemplate( AUtSharedVectorArray* inSharedVectorArray, @@ -296,7 +296,7 @@ extern "C" * Shared TexCoord functions */ typedef struct AUtSharedTexCoordArray AUtSharedTexCoordArray; - + AUtSharedTexCoordArray* AUrSharedTexCoordArray_New( void); @@ -323,7 +323,7 @@ extern "C" UUtUns32 AUrSharedTexCoordArray_GetNum( AUtSharedTexCoordArray* inSharedTexCoordArray); - + UUtError AUrSharedTexCoordArray_CreateTemplate( AUtSharedTexCoordArray* inSharedTexCoordArray, @@ -334,15 +334,15 @@ extern "C" * Shared edge functions */ #define AUcMaxQuadsPerEdge 12 - + typedef struct AUtSharedEdgeArray AUtSharedEdgeArray; typedef struct AUtEdge { UUtUns32 vIndex0; UUtUns32 vIndex1; - + UUtUns32 quadIndices[AUcMaxQuadsPerEdge]; - + } AUtEdge; AUtSharedEdgeArray* @@ -364,7 +364,7 @@ extern "C" UUtUns32 inEdge1, UUtUns32 inQuadIndex, UUtUns32 *outEdgeIndex); - + UUtError AUrSharedEdgeArray_AddPoly( AUtSharedEdgeArray* inSharedEdgeArray, @@ -372,7 +372,7 @@ extern "C" UUtUns32* inVertices, UUtUns32 inQuadIndex, UUtUns32 *outEdgeIndices); - + AUtEdge* AUrSharedEdgeArray_GetList( AUtSharedEdgeArray* inSharedEdgeArray); @@ -380,12 +380,12 @@ extern "C" UUtUns32 AUrSharedEdgeArray_GetNum( AUtSharedEdgeArray* inSharedEdgeArray); - + UUtUns32 AUrSharedEdge_FindCommonVertex( AUtEdge* inEdgeA, AUtEdge* inEdgeB); - + UUtUns32 AUrSharedEdge_FindOtherVertex( AUtEdge* inEdge, @@ -407,16 +407,16 @@ extern "C" * Shared String functions */ #define AUcMaxStringLength 128 - + typedef struct AUtSharedStringArray AUtSharedStringArray; - + typedef struct AUtSharedString { char string[AUcMaxStringLength]; UUtUns32 data; - + } AUtSharedString; - + AUtSharedStringArray* AUrSharedStringArray_New( void); @@ -464,11 +464,11 @@ extern "C" * Hash table utilities */ typedef struct AUtHashTable AUtHashTable; - + typedef UUtUns32 (*AUtHashTable_Hash)( void* inElement); - + typedef UUtBool (*AUtHashTable_IsEqual)( void* inElement1, @@ -488,25 +488,25 @@ extern "C" UUtUns32 inNumBuckets, AUtHashTable_Hash inHashFunction, AUtHashTable_IsEqual inCompareFunction); - + void AUrHashTable_Delete( AUtHashTable* inHashTable); - + void AUrHashTable_Reset( AUtHashTable* inHashTable); - + void * AUrHashTable_Add( AUtHashTable* inHashTable, void *inNewElement); - + void* AUrHashTable_Find( AUtHashTable* inHashTable, void *inElement); - + /* * Some quad utilities */ @@ -520,20 +520,20 @@ extern "C" float *outMaxY, float *outMinZ, float *outMaxZ); - + // This assumes they already lie on the same plane UUtBool AUrQuad_QuadOverlapsQuad( const M3tPoint3D* inPointList, const M3tQuad* inQuad, const M3tQuad* inQuadOverlapping); - + UUtBool AUrQuad_QuadWithinQuad( const M3tPoint3D* inPointList, const M3tQuad* inQuad, const M3tQuad* inQuadWithin); - + void AUrQuad_ComputeCenter( const M3tPoint3D* inPointList, @@ -541,24 +541,24 @@ extern "C" float *outCenterX, float *outCenterY, float *outCenterZ); - + UUtBool AUrQuad_SharesAnEdge( const M3tQuad* inQuadA, const M3tQuad* inQuadB); - + void AUrQuad_LowestPoints( M3tQuad *inQuad, M3tPoint3D *inPointArray, M3tPoint3D **outPointLowest, M3tPoint3D **outPointNextLowest); - + void AUrQuad_HighestPoints( M3tQuad *inQuad, M3tPoint3D *inPointArray, M3tPoint3D **outPointHighest, M3tPoint3D **outPointNextHighest); - + /* * some text parsing funcs */ @@ -584,7 +584,7 @@ extern "C" float nx, float ny, float nz); - + typedef UUtError (*AUtParseGeometry_AddQuadFunc)( void* inRefCon, @@ -595,7 +595,7 @@ extern "C" float nx, float ny, float nz); - + typedef UUtError (*AUtParseGeometry_AddEnvTriangleFunc)( void* inRefCon, @@ -606,7 +606,7 @@ extern "C" float nx, float ny, float nz); - + typedef UUtError (*AUtParseGeometry_AddEnvQuadFunc)( void* inRefCon, @@ -618,7 +618,7 @@ extern "C" float nx, float ny, float nz); - + UUtError AUrParse_CoreGeometry( BFtTextFile* inTextFile, @@ -652,34 +652,34 @@ extern "C" M3tPoint3D* outPoint); /* - * + * */ typedef struct AUtFlagElement { char* textName; UUtUns32 flagValue; - + } AUtFlagElement; - + const char* AUrFlags_GetTextName( AUtFlagElement *inFlagList, UUtUns32 inFlagValue); - + UUtError AUrFlags_ParseFromGroupArray( AUtFlagElement* inFlagList, // Terminated by a NULL textName GRtElementType inElementType, void* inElement, UUtUns32 *outResult); - + UUtError AUrFlags_ParseFromString( char* inString, // multiple entries are delimited by "|" UUtBool inIsBitField, AUtFlagElement* inFlagList, // Terminated by a NULL textName UUtUns32 *outResult); - + void AUrFlags_PrintFromValue( FILE* inFile, @@ -687,12 +687,12 @@ extern "C" AUtFlagElement* inFlagList, UUtUns32 inValue); /* - * + * */ UUtWindow AUrWindow_New( UUtRect* inRect); - + void AUrWindow_CopyImageInto( UUtWindow inDstWindow, @@ -700,7 +700,7 @@ extern "C" UUtUns16 inSrcHeight, IMtPixelType inSrcPixelType, void* inSrcData); - + void AUrWindow_EORImage( UUtWindow inWindow, @@ -718,11 +718,11 @@ extern "C" UUtWindow inWindow); void AUrBuildArgumentList( - char *inString, - UUtUns32 inMaxCount, - UUtUns32 *outCount, + char *inString, + UUtUns32 inMaxCount, + UUtUns32 *outCount, char **outArguments); - + // dictionary funtions typedef struct AUtDict { @@ -780,7 +780,7 @@ extern "C" * * Takes a string, mapping and ptr to a uns32. * - * If it finds inString in inMapping sets the result to 1 << n where n is + * If it finds inString in inMapping sets the result to 1 << n where n is * the index of the string in inMapping. * * Otherwise returns an error diff --git a/BungieFrameWork/BFW_Headers/BFW_BinaryData.h b/BungieFrameWork/BFW_Headers/BFW_BinaryData.h index 8d80e93..2beea0c 100644 --- a/BungieFrameWork/BFW_Headers/BFW_BinaryData.h +++ b/BungieFrameWork/BFW_Headers/BFW_BinaryData.h @@ -24,21 +24,21 @@ BDtBinaryData { UUtUns32 data_size; tm_separate data_index; - + } BDtBinaryData; typedef struct BDtHeader { BDtClassType class_type; UUtUns32 data_size; - + } BDtHeader; typedef struct BDtData { BDtHeader header; UUtUns8 data[1]; - + } BDtData; // ---------------------------------------------------------------------- @@ -54,7 +54,7 @@ typedef UUtError typedef struct BDtMethods { BDtMethod_Load rLoad; - + } BDtMethods; // ====================================================================== @@ -84,7 +84,7 @@ typedef struct BDtMethods #define BDmSkip4BytesFromBuffer(src) \ 4; do { \ *(UUtUns8**)&(src) += 4; \ - } while(0) + } while(0) #define BDmGet4BytesFromBuffer(src,dst,type,swap_it) \ 4; \ @@ -108,7 +108,7 @@ typedef struct BDtMethods #define BDmSkip2BytesFromBuffer(src) \ 2; do { \ *(UUtUns8**)&(src) += 2; \ - } while(0) + } while(0) #define BDmGet2BytesFromBuffer(src,dst,type,swap_it) \ 2; \ @@ -154,7 +154,7 @@ typedef struct BDtMethods #define BDmGetStringFromBuffer(src,dst,len,swap_it) \ (len); do { \ UUrString_Copy((dst), (char *) (src), (len)); \ - *(UUtUns8**)&(src) += (len); } while(0) + *(UUtUns8**)&(src) += (len); } while(0) #define BDmWriteStringToBuffer(buf,val,len,num_bytes, write_big) \ (len); do { \ diff --git a/BungieFrameWork/BFW_Headers/BFW_Bink.h b/BungieFrameWork/BFW_Headers/BFW_Bink.h index cb15201..bd0d0e6 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Bink.h +++ b/BungieFrameWork/BFW_Headers/BFW_Bink.h @@ -37,4 +37,4 @@ BKrMovie_Play( BKtScale inScale); // ====================================================================== -#endif /* BFW_BINK_H */ \ No newline at end of file +#endif /* BFW_BINK_H */ diff --git a/BungieFrameWork/BFW_Headers/BFW_BitVector.h b/BungieFrameWork/BFW_Headers/BFW_BitVector.h index 7b49fb4..06287d2 100644 --- a/BungieFrameWork/BFW_Headers/BFW_BitVector.h +++ b/BungieFrameWork/BFW_Headers/BFW_BitVector.h @@ -141,30 +141,30 @@ UUrBitVector_TestAndSetBit(UUtUns32 *bitVector, UUtUns32 bit) UUtUns32* elem; UUtUns32 bvBit; UUtBool result; - + UUmAssert(bitVector); - + elem = bitVector + BV_INDEX(bit); bvBit = BV_BIT(bit); - + result = (*elem & bvBit) != 0; *elem |= bvBit; return result; } -static UUcInline UUtBool +static UUcInline UUtBool UUrBitVector_TestAndClearBit(UUtUns32 *bitVector, UUtUns32 bit) { UUtUns32* elem; UUtUns32 bvBit; UUtBool result; - + UUmAssert(bitVector); - + elem = bitVector + BV_INDEX(bit); bvBit = BV_BIT(bit); - + result = (*elem & bvBit) != 0; *elem &= ~bvBit; diff --git a/BungieFrameWork/BFW_Headers/BFW_Collision.h b/BungieFrameWork/BFW_Headers/BFW_Collision.h index a6decbb..609fa06 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Collision.h +++ b/BungieFrameWork/BFW_Headers/BFW_Collision.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_Collision.h - + AUTHOR: Brent H. Pease - + CREATED: May 10, 1998 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1998 */ @@ -25,7 +25,7 @@ typedef tm_enum CLtQuadProjection CLcProjection_XY, CLcProjection_XZ, CLcProjection_YZ - + } CLtQuadProjection; typedef enum CLtCollisionType @@ -41,12 +41,12 @@ UUtBool CLrSphere_Ray( const M3tBoundingSphere *inSphere, float *outT, UUtBool *outIsExit); - + UUtBool CLrQuad_Cylinder( const M3tPoint3D *inPointArray, const M3tQuad *inQuad, const M3tBoundingCylinder *inCylinder); - + UUtBool CLrSphere_Line( const M3tPoint3D* inStart, @@ -64,12 +64,12 @@ CLrBox_Line( const M3tBoundingBox_MinMax* inBox, const M3tPoint3D* inStartPoint, const M3tPoint3D* inEndPoint); - + UUtBool CLrBox_Sphere( M3tBoundingBox_MinMax* inBox, M3tBoundingSphere* inSphere); - + UUtBool CLrQuad_PointInQuad( @@ -84,7 +84,7 @@ CLrLine_Plane( M3tPoint3D *inLineB, M3tPlaneEquation *inPlane, M3tPoint3D *outIntersection); // optional - + UUtBool CLrQuad_Line( CLtQuadProjection inProjection, @@ -113,8 +113,8 @@ CLrQuad_Quad( M3tPoint3D *outIntersectionR, // Ignored if above is null M3tPlaneEquation *outPlaneA, // return the plane of quad A or NULL if you don't care M3tPlaneEquation *outPlaneB); - - + + UUtBool CLrQuad_SphereTrivialReject( CLtQuadProjection inProjection, @@ -141,9 +141,9 @@ CLrQuad_Box( const M3tPlaneEquation* inPlaneArray, UUtUns32 inPlaneEquIndex, const M3tQuad* inQuad, - const M3tBoundingBox_MinMax* inBox); + const M3tBoundingBox_MinMax* inBox); -void +void CLrPlaneEquationFromQuad( const M3tQuad *inQuad, const M3tPoint3D *inPointArray, @@ -158,12 +158,12 @@ UUtBool CLrBox_Point( M3tBoundingBox *inBox, M3tPoint3D *inPoint); - + UUtBool CLrBox_Box( M3tBoundingBox *inBoxA, M3tBoundingBox *inBoxB); - + UUtBool CLrHotdog_Sphere( M3tBoundingHotdog *inDog, M3tBoundingSphere *inSphere); diff --git a/BungieFrameWork/BFW_Headers/BFW_CommandLine.h b/BungieFrameWork/BFW_Headers/BFW_CommandLine.h index 1d566d1..5e0f346 100644 --- a/BungieFrameWork/BFW_Headers/BFW_CommandLine.h +++ b/BungieFrameWork/BFW_Headers/BFW_CommandLine.h @@ -20,4 +20,4 @@ CLrGetCommandLine( char ***outArgV); // ====================================================================== -#endif /* BFW_COMMANDLINE_H */ \ No newline at end of file +#endif /* BFW_COMMANDLINE_H */ diff --git a/BungieFrameWork/BFW_Headers/BFW_Console.h b/BungieFrameWork/BFW_Headers/BFW_Console.h index 632ef0a..f46c09d 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Console.h +++ b/BungieFrameWork/BFW_Headers/BFW_Console.h @@ -38,7 +38,7 @@ typedef enum COtCallbackAction COc_ValueChanged, COc_PrintRange, COc_GetValue - + } COtCallbackAction; // ---------------------------------------------------------------------- @@ -47,7 +47,7 @@ typedef void (*COtVarCallback)( COtCallbackAction inCallbackAction, void* inCallbackData, void* inRefcon); - + typedef void (*COtCommandCallback)( UUtUns32 inArgC, char** inArgV, @@ -101,7 +101,7 @@ COrConsole_Activate( void COrConsole_Deactivate( void); - + void COrConsole_Display_Lines( void); @@ -152,8 +152,8 @@ UUtBool COrCommand_Execute(char *inCommandLine); extern IMtShade COgDefaultTextShade; -extern IMtShade COgDefaultTextShadowShade; - +extern IMtShade COgDefaultTextShadowShade; + #if THE_DAY_IS_MINE void UUcArglist_Call COrConsole_Printf(const char *format, ...); #else @@ -169,7 +169,7 @@ void UUcArglist_Call COrConsole_Printf_Color(COtPriority inPriority, IMtShade in #if defined(DEBUGGING) && DEBUGGING #define COmAssert(x) if (!(x)) do { COrConsole_Printf("%s", #x); } while(0) #else -#define COmAssert(x) +#define COmAssert(x) #endif UUtError diff --git a/BungieFrameWork/BFW_Headers/BFW_DebuggerSymbols.h b/BungieFrameWork/BFW_Headers/BFW_DebuggerSymbols.h index e5877cc..7fb1c2b 100644 --- a/BungieFrameWork/BFW_Headers/BFW_DebuggerSymbols.h +++ b/BungieFrameWork/BFW_Headers/BFW_DebuggerSymbols.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_DebuggerSymbols.h - + AUTHOR: Brent H. Pease - + CREATED: July 12, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -23,9 +23,9 @@ typedef enum DStSourceSymDB_Platform { DScSourceSymDB_Platform_MacOS, DScSourceSymDB_Platform_Win32, - + DScPlatform_Num - + } DStSourceSymDB_Platform; typedef struct DStSourceSymDB_BinOffset2SourceFileMap @@ -34,58 +34,58 @@ typedef struct DStSourceSymDB_BinOffset2SourceFileMap UUtUns32 owningFunctionIndex; UUtUns32 owningSourceFileIndex; UUtUns32 owningScope; - + UUtUns32 binOffsetLow; // resource relative UUtUns32 binOffsetHigh; // resource relative - + UUtUns32 sourceFileLineLow; UUtUns32 sourceFileLineHigh; - + } DStSourceSymDB_BinOffset2SourceFileMap; typedef struct DStSourceSymDB_SourceFile { char* sourceFileLeafName; UUtUns32 modDate; - + UUtUns32 functionIndexLow; UUtUns32 functionIndexHigh; - + } DStSourceSymDB_SourceFile; typedef struct DStSourceSymDB_Scope { UUtUns32 scopingDepth; - + UUtUns32 mappingIndexLow; // indexes into resource mappings UUtUns32 mappingIndexHigh; // indexes into resource mappings - + UUtUns32 parentScopeIndex; UUtUns32 parentFunctionIndex; UUtUns32 parentSourceFileIndex; - + } DStSourceSymDB_Scope; typedef struct DStSourceSymDB_Function { char* functionName; - + UUtUns32 owningResourceIndex; UUtUns32 owningSourceFileIndex; - + UUtUns32 mappingIndexLow; // indexes into resource mappings UUtUns32 mappingIndexHigh; // indexes into resource mappings - + UUtUns32 scopeIndexLow; UUtUns32 scopeIndexHigh; - + } DStSourceSymDB_Function; typedef struct DStSourceSymDB_Resource { UUtUns32 mappingIndexLow; UUtUns32 mappingIndexHigh; - + } DStSourceSymDB_Resource; typedef struct DStSourceSymDB_Header @@ -93,24 +93,24 @@ typedef struct DStSourceSymDB_Header char version[DScSourceSymDB_VersionStrLength]; char* executableLeafName; DStSourceSymDB_Platform platform; - + UUtUns32 rootFunctionIndex; - + UUtUns32 numResources; DStSourceSymDB_Resource* resources; - + UUtUns32 numSourceFiles; DStSourceSymDB_SourceFile* sourceFiles; - + UUtUns32 numFunctions; DStSourceSymDB_Function* functions; - + UUtUns32 numScopes; DStSourceSymDB_Scope* scope; - + UUtUns32 nameLength; char* names; - + UUtUns32 numMappings; DStSourceSymDB_BinOffset2SourceFileMap* mappings; diff --git a/BungieFrameWork/BFW_Headers/BFW_DialogManager.h b/BungieFrameWork/BFW_Headers/BFW_DialogManager.h index 535d72c..5beacae 100644 --- a/BungieFrameWork/BFW_Headers/BFW_DialogManager.h +++ b/BungieFrameWork/BFW_Headers/BFW_DialogManager.h @@ -34,7 +34,7 @@ enum DMcMBFlag_None = 0x00000000, DMcMBFlag_Ok = 0x00000001, DMcMBFlag_OkCancel = 0x00000003 - + }; // Message Box Results @@ -42,7 +42,7 @@ enum { DMcMB_Ok = 100, DMcMB_Cancel = 101 - + }; // ====================================================================== @@ -62,7 +62,7 @@ typedef UUtBool typedef tm_struct DMtDialogRef { tm_templateref dialog_ref; - + } DMtDialogRef; #define DMcTemplate_DialogList UUm4CharToUns32('D', 'M', 'D', 'L') @@ -70,12 +70,12 @@ typedef tm_template('D', 'M', 'D', 'L', "DM Dialog List") DMtDialogList { tm_pad pad0[22]; - + tm_varindex UUtUns16 num_dialogs; tm_vararray DMtDialogRef dialogs[1]; - + } DMtDialogList; - + // ====================================================================== // typedefs // ====================================================================== @@ -83,20 +83,20 @@ void DMrDialog_ActivateTab( DMtDialog *inDialog, UUtUns16 inTabID); - + void DMrDialog_Display( VMtView *inView); - + DMtDialog* DMrDialog_GetParentDialog( VMtView *inView); - + VMtView* DMrDialog_GetViewByID( DMtDialog *inDialog, UUtUns16 inViewID); - + UUtBool DMrDialog_IsActive( VMtView *inView); @@ -107,19 +107,19 @@ DMrDialog_MessageBox( char *inTitle, char *inMessage, UUtUns32 inFlags); - + UUtError DMrDialog_Load( UUtUns16 inDialogID, DMtDialogCallback inDialogCallback, DMtDialog *inParent, DMtDialog **outDialog); - + void DMrDialog_ReleaseMouseFocusView( DMtDialog *inDialog, VMtView *inView); - + UUtError DMrDialog_Run( UUtUns16 inDialogID, @@ -136,16 +136,16 @@ void DMrDialog_SetMouseFocusView( DMtDialog *inDialog, VMtView *inView); - + void DMrDialog_Stop( DMtDialog *inDialog, UUtUns32 inMessage); - + void DMrDialog_Update( DMtDialog *inDialog); - + // ---------------------------------------------------------------------- UUtError DMrInitialize( @@ -161,4 +161,4 @@ DMVMrRegisterTemplates( void); // ====================================================================== -#endif /* BFW_DIALOGMANAGER_H */ \ No newline at end of file +#endif /* BFW_DIALOGMANAGER_H */ diff --git a/BungieFrameWork/BFW_Headers/BFW_Doors.h b/BungieFrameWork/BFW_Headers/BFW_Doors.h index 16d5daf..7dd0fad 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Doors.h +++ b/BungieFrameWork/BFW_Headers/BFW_Doors.h @@ -20,12 +20,12 @@ typedef tm_struct OBtDoorClass { UUtUns16 id; UUtUns16 flags; // OBtDoorClassFlags - + OBtAnimation *openCloseAnim; - + UUtUns16 openKey; // Not used UUtUns16 closeKey; // " - + float activationRadiusSquared; UUtUns16 objectID; // ??? UUtUns16 linkID; @@ -38,10 +38,10 @@ typedef tm_template('O','B','D','C', "Door class array") OBtDoorClassArray { tm_pad pad0[22]; - + tm_varindex UUtUns16 numDoors; tm_vararray OBtDoorClass doors[1]; - + } OBtDoorClassArray; typedef enum OBtDoorActivationState diff --git a/BungieFrameWork/BFW_Headers/BFW_Effect.h b/BungieFrameWork/BFW_Headers/BFW_Effect.h index 33cf5e8..56df389 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Effect.h +++ b/BungieFrameWork/BFW_Headers/BFW_Effect.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_Effect.h - + AUTHOR: Brent Pease - + CREATED: Oct 8, 1999 - + PURPOSE: effects engine - + Copyright 1999 */ @@ -26,7 +26,7 @@ FXcLaserFlag_None = 0, FXcLaserFlag_StopsAtFirstCollision = 1, // otherwise it is fixed length based on geometry FXcLaserFlag_Procedural = 2 - + } FXtLaser_Flags; #define FXcTemplate_Laser UUm4CharToUns32('F', 'X', 'L', 'R') @@ -34,12 +34,12 @@ FXtLaser { FXtLaser_Flags flags; - + M3tTextureMap* texture; M3tGeometry* geometry; - + //AItScript* script; - + } FXtLaser; diff --git a/BungieFrameWork/BFW_Headers/BFW_EnvParticle.h b/BungieFrameWork/BFW_Headers/BFW_EnvParticle.h index 4e2beed..f54eecf 100644 --- a/BungieFrameWork/BFW_Headers/BFW_EnvParticle.h +++ b/BungieFrameWork/BFW_Headers/BFW_EnvParticle.h @@ -5,13 +5,13 @@ /* FILE: BFW_EnvParticle.h - + AUTHOR: Chris Butcher - + CREATED: May 26, 2000 - + PURPOSE: support for environmental particles - + Copyright (c) 2000, Bungie Software */ @@ -83,10 +83,10 @@ typedef tm_template('E','N','V','P',"Env Particle Array") EPtEnvParticleArray { tm_pad pad0[22]; - + tm_varindex UUtUns16 numParticles; tm_vararray EPtEnvParticle particle[1]; - + } EPtEnvParticleArray; // callback function template, for enumerating env particles diff --git a/BungieFrameWork/BFW_Headers/BFW_ErrorCodes.h b/BungieFrameWork/BFW_Headers/BFW_ErrorCodes.h index b4bc7d7..5ffcec1 100644 --- a/BungieFrameWork/BFW_Headers/BFW_ErrorCodes.h +++ b/BungieFrameWork/BFW_Headers/BFW_ErrorCodes.h @@ -2,13 +2,13 @@ /* FILE: BFW_Error.h - + AUTHOR: Michael Evans, Brent H. Pease - + CREATED: July 16, 1998 - + PURPOSE: Error type and error codes - + Copyright 1998 */ @@ -47,7 +47,7 @@ typedef tm_struct UUtErrorBinding { char errorText[126]; UUtUns16 error; - + } UUtErrorBinding; #define TMcTemplate_ErrorBindingArray UUm4CharToUns32('U', 'U', 'E', 'A') @@ -55,10 +55,10 @@ typedef tm_template('U', 'U', 'E', 'A', "Error Binding Array") TMtErrorBindingArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numErrorBindings; tm_vararray UUtErrorBinding errorBindings[1]; - + } TMtErrorBindingArray; -#endif // BFW_ERRORCODES_H \ No newline at end of file +#endif // BFW_ERRORCODES_H diff --git a/BungieFrameWork/BFW_Headers/BFW_FileFormat.h b/BungieFrameWork/BFW_Headers/BFW_FileFormat.h index 7200e52..b4fc5cc 100644 --- a/BungieFrameWork/BFW_Headers/BFW_FileFormat.h +++ b/BungieFrameWork/BFW_Headers/BFW_FileFormat.h @@ -2,13 +2,13 @@ /* FILE: BFW_FileFormat.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1998 - + PURPOSE: Interface to various graphical file formats - + Copyright 1998 */ diff --git a/BungieFrameWork/BFW_Headers/BFW_FileManager.h b/BungieFrameWork/BFW_Headers/BFW_FileManager.h index 0fd4b24..2934245 100644 --- a/BungieFrameWork/BFW_Headers/BFW_FileManager.h +++ b/BungieFrameWork/BFW_Headers/BFW_FileManager.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_FileManager.h - + AUTHOR: Brent H. Pease - + CREATED: June 28, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -27,7 +27,7 @@ extern "C" { * Define some errors */ - + /* * The inMode parameter to BFrFile_Open can be one of the following * "r" - open for reading @@ -61,7 +61,7 @@ typedef struct BFtFileRef { FSSpec fsSpec; char leafName[64]; // This should only be the name of the base file or folder - + } BFtFileRef; #elif UUmPlatform == UUmPlatform_Linux @@ -98,17 +98,17 @@ BFrFile_CompletionFunc_Bool( BFrFileRef_MakeFromFSSpec( const FSSpec* inFSSpec, BFtFileRef* *outFileRef); - + FSSpec* BFrFileRef_GetFSSpec( BFtFileRef *inFileRef); - + #elif UUmPlatform == UUmPlatform_Win32 || UUmPlatform == UUmPlatform_Linux #else #error implement me - + #endif UUtError @@ -123,11 +123,11 @@ BFrFileRef_Search( BFtFileRef * BFrFileRef_MakeUnique( - const char *inPrefix, - const char *inSuffix, - UUtInt32 *ioNumber, + const char *inPrefix, + const char *inSuffix, + UUtInt32 *ioNumber, UUtInt32 inMaxNumber); - + void BFrFileRef_Dispose( BFtFileRef* inFileRef); @@ -149,7 +149,7 @@ UUtError BFrFileRef_GetParentDirectory( BFtFileRef *inFileRef, BFtFileRef **outParentDirectory); - + const char * BFrFileRef_GetSuffixName( const BFtFileRef* inFileRef); @@ -161,12 +161,12 @@ BFrFileRef_IsDirectory( UUtBool BFrFileRef_IsLocked( BFtFileRef* inFileRef); - + UUtBool BFrFileRef_IsEqual( const BFtFileRef *inFileRef1, const BFtFileRef *inFileRef2); - + UUtError BFrFileRef_SetName( BFtFileRef* inFileRef, @@ -193,7 +193,7 @@ BFrFileRef_DuplicateAndReplaceName( const BFtFileRef* inOrigFileRef, const char* inReplaceName, // Could be an absolute path or a relative path BFtFileRef* *outNewFileRef); - + UUtError BFrFileRef_DuplicateAndAppendName( const BFtFileRef* inOrigFileRef, // This had best be a directory... @@ -213,7 +213,7 @@ UUtError BFrFileRef_GetModTime( BFtFileRef* inFileRef, UUtUns32* outSecsSince1900); - + UUtError BFrFile_Create( BFtFileRef* inFileRef); @@ -221,7 +221,7 @@ BFrFile_Create( UUtError BFrFile_Delete( BFtFileRef* inFileRef); - + UUtError BFrFile_Open( BFtFileRef* inFileRef, @@ -242,7 +242,7 @@ BFrFile_Map( void BFrFile_UnMap( BFtFileMapping *inMapping); - + UUtError BFrFile_Flush( BFtFile* inFile); @@ -259,7 +259,7 @@ BFrFile_GetLength( UUtError BFrFile_SetEOF( BFtFile* inFile); - + UUtError BFrFile_SetPos( BFtFile* inFile, @@ -277,7 +277,7 @@ BFrFile_Async_Read( void* inDataPtr, BFtCompletion_Func inCompletionFunc, void* inRefCon); - + UUtError BFrFile_Async_Write( BFtFile* inFile, @@ -330,11 +330,11 @@ BFrFile_WritePos( UUtUns32 inLength, void* inDataPtr); -UUtError -UUcArglist_Call +UUtError +UUcArglist_Call BFrFile_Printf( BFtFile* inFile, - const char *format, + const char *format, ...); UUtError @@ -359,7 +359,7 @@ BFrTextFile_Close( char * BFrTextFile_GetCurStr( BFtTextFile* inTextFile); - + char* BFrTextFile_GetNextStr( BFtTextFile* inTextFile); @@ -394,7 +394,7 @@ BFrTextFile_VerifyNextNWords( char *inMatchString, UUtUns16 inNumWordsToRead, BFtTextFile* inTextFile); - + UUtUns32 BFrTextFile_GetOSType( BFtTextFile* inTextFile); @@ -408,8 +408,8 @@ BFrTextFile_VerifyNextStr( do { \ UUtError macroError = BFrTextFile_VerifyNextStr(inTextFile, inString); \ if (macroError != UUcError_None) { return macroError; } \ -} while(0) - +} while(0) + UUtError BFrFileRef_LoadIntoMemory( BFtFileRef* inFileRef, diff --git a/BungieFrameWork/BFW_Headers/BFW_Group.h b/BungieFrameWork/BFW_Headers/BFW_Group.h index 8ecba77..f329069 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Group.h +++ b/BungieFrameWork/BFW_Headers/BFW_Group.h @@ -2,13 +2,13 @@ /* FILE: BFW_Group.h - + AUTHOR: Brent H. Pease - + CREATED: Dec 17, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -29,10 +29,10 @@ typedef enum GRtElementType GRcElementType_String, GRcElementType_Group, GRcElementType_Array - + } GRtElementType; -UUtError +UUtError GRrGroup_Context_New( GRtGroup_Context **outGroupContext); @@ -52,7 +52,7 @@ GRrGroup_Context_NewFromPartialFile( UUtUns16 inLines, GRtGroup_Context* *outGroupContext, GRtGroup* *outGroup); - + UUtError GRrGroup_Context_NewFromString( const char* inString, @@ -60,7 +60,7 @@ GRrGroup_Context_NewFromString( GRtGroup_Context *inContext, GRtGroup_Context* *outGroupContext, GRtGroup* *outGroup); - + void GRrGroup_Context_Delete( GRtGroup_Context* inGroupContext); @@ -76,7 +76,7 @@ GRrGroup_GetElement( const char* inVarName, GRtElementType *outElementType, void* *outDataPtr); // Either a GRtGroup, GRtElementArray, or char* - + UUtError GRrGroup_GetString( GRtGroup* inGroup, diff --git a/BungieFrameWork/BFW_Headers/BFW_Image.h b/BungieFrameWork/BFW_Headers/BFW_Image.h index 07fd90d..12ae29e 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Image.h +++ b/BungieFrameWork/BFW_Headers/BFW_Image.h @@ -2,19 +2,19 @@ /* FILE: BFW_Image.h - + AUTHOR: Brent H. Pease - + CREATED: Nov 27, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 - + GENERAL IMAGE RULES: 1) the base address for any image starts at the top-left of the image 2) tbd - + */ #ifndef BFW_IMAGE_H #define BFW_IMAGE_H @@ -30,7 +30,7 @@ padded(if needed) to be a multiple of 2bytes. 5) IMcPixelType_I1 must be 2byte aligned and each row must be padded(if needed) to be a multiple of 2bytes - + */ #define IMcShade_None (0x00000000) @@ -81,35 +81,35 @@ IMcPixelType_RGBA_Bytes, // byte packed rgba (gl) IMcPixelType_RGBA5551, // (gl) IMcPixelType_RGBA4444, // (gl) - IMcPixelType_RGB565, // + IMcPixelType_RGB565, // IMcPixelType_ABGR1555, // 1555 IMcNumPixelTypes - + } IMtPixelType; - + typedef enum IMtDitherMode { IMcDitherMode_Off, IMcDitherMode_On - + } IMtDitherMode; - + typedef enum IMtScaleMode { IMcScaleMode_None = 0, IMcScaleMode_Box = 0, IMcScaleMode_High = (1 << 0), IMcScaleMode_IndependantAlpha = (1 << 1) - + } IMtScaleMode; - + /* * rect and point types for images */ - + // This is a struct so that pixel color parameters don't get misused typedef struct IMtPixel { @@ -120,7 +120,7 @@ { UUtInt16 x; UUtInt16 y; - + } IMtPoint2D; typedef enum @@ -130,7 +130,7 @@ } IMtMipMap; /* - * + * */ UUtError IMrInitialize( @@ -143,7 +143,7 @@ const char *IMrPixelTypeToString(IMtPixelType inPixelType); /* - * + * */ void IMrImage_Draw_Line( @@ -154,7 +154,7 @@ IMtPixel inDrawColor, IMtPoint2D *inPoint1, IMtPoint2D *inPoint2); - + void IMrImage_Draw_Rect( UUtUns16 inImageWidth, @@ -165,7 +165,7 @@ UUtRect *inDrawRect); /* - * + * */ UUtError IMrImage_Scale( @@ -177,7 +177,7 @@ UUtUns16 inDstWidth, UUtUns16 inDstHeight, void* outDstData); // caller is responsible for allocating this memory - + UUtError IMrImage_ConvertPixelType( IMtDitherMode inDitherMode, @@ -188,7 +188,7 @@ void* inSrcData, IMtPixelType inDstPixelType, void* outDstData); // caller is responsible for allocating this memory - + void IMrImage_Copy( UUtUns16 inCopyWidth, @@ -218,7 +218,7 @@ UUtRect* inDstRect, IMtPixelType inDstPixelType, void* outDstData); // caller is responsible for allocating this memory - + void IMrImage_GetPixel( UUtUns16 inSrcWidth, @@ -238,7 +238,7 @@ UUtUns16 inDstHeight, const UUtRect* inDstRect, void* outDstData); - + UUtUns16 IMrImage_ComputeRowBytes( IMtPixelType inPixelType, @@ -270,9 +270,9 @@ UUtUns16 inWidth, UUtUns16 inHeight, UUtUns16 inBlockPowerOf2); - + /* - * + * */ IMtPixel @@ -287,7 +287,7 @@ IMtPixel IMrPixel_FromARGB( IMtPixelType inPixelType, - float inA, + float inA, float inR, float inG, float inB); @@ -314,7 +314,7 @@ IMtShade inShade2); /* - * + * */ void IMrPixel_Convert( @@ -322,14 +322,14 @@ IMtPixel inSrcPixel, IMtPixelType inDstPixelType, IMtPixel *outDstPixel); - + UUtUns8 IMrPixel_GetSize( IMtPixelType inPixelType); void IMrPixel_Decompose( - IMtPixel inPixel, + IMtPixel inPixel, IMtPixelType inPixelType, float *outA, float *outR, @@ -339,12 +339,12 @@ UUtBool IMrPixelType_HasAlpha( IMtPixelType inPixelType); - + UUtUns16 IMrPixel_BlendARGB4444( UUtUns16 inSrcPixel, UUtUns16 inDstPixel); - + /* * */ @@ -353,7 +353,7 @@ const UUtRect* inRect1, const UUtRect* inRect2, UUtRect *outRect); - + void IMrRect_Inset( UUtRect *ioRect, @@ -370,7 +370,7 @@ IMrRect_PointIn( const UUtRect* inRect, const IMtPoint2D* inPoint); - + void IMrRect_ComputeClipInfo( const UUtRect* inRect1, @@ -394,5 +394,5 @@ const IMtPoint2D *inPoint1, const IMtPoint2D *inPoint2); - + #endif /* BFW_IMAGE_H */ diff --git a/BungieFrameWork/BFW_Headers/BFW_LocalInput.h b/BungieFrameWork/BFW_Headers/BFW_LocalInput.h index 195083f..42fd223 100644 --- a/BungieFrameWork/BFW_Headers/BFW_LocalInput.h +++ b/BungieFrameWork/BFW_Headers/BFW_LocalInput.h @@ -37,14 +37,14 @@ typedef enum LItInputEventType LIcInputEvent_KeyUp, LIcInputEvent_KeyDown, LIcInputEvent_KeyRepeat - + } LItInputEventType; typedef enum LItMode { LIcMode_Normal, LIcMode_Game - + } LItMode; // ====================================================================== @@ -114,7 +114,7 @@ enum LIc_Bit_Fire1, LIc_Bit_Fire2, LIc_Bit_Fire3, - + LIcNumButtonBits }; @@ -177,7 +177,7 @@ typedef enum LItInputType LIcIT_Axis_Delta, LIcIT_Axis_Symmetric_Pos, LIcIT_Axis_Symmetric_Neg - + } LItInputType; // ====================================================================== @@ -185,7 +185,7 @@ typedef enum LItInputType typedef enum { LIcKeyCode_None = 0x00, - + LIcKeyCode_Escape = 0x1B, LIcKeyCode_F1 = 0x81, LIcKeyCode_F2 = 0x82, @@ -217,7 +217,7 @@ typedef enum LIcKeyCode_Minus = '-', LIcKeyCode_Equals = '=', LIcKeyCode_BackSpace = 0x08, - + LIcKeyCode_Tab = 0x09, LIcKeyCode_Q = 'q', LIcKeyCode_W = 'w', @@ -232,7 +232,7 @@ typedef enum LIcKeyCode_LeftBracket = '[', LIcKeyCode_RightBracket = ']', LIcKeyCode_BackSlash = '\\', - + LIcKeyCode_CapsLock = 0x90, LIcKeyCode_A = 'a', LIcKeyCode_S = 's', @@ -246,7 +246,7 @@ typedef enum LIcKeyCode_Semicolon = ';', LIcKeyCode_Apostrophe = '\'', LIcKeyCode_Return = 0x0D, - + LIcKeyCode_LeftShift = 0x91, LIcKeyCode_Z = 'z', LIcKeyCode_X = 'x', @@ -259,7 +259,7 @@ typedef enum LIcKeyCode_Period = '.', LIcKeyCode_Slash = '/', LIcKeyCode_RightShift = 0x92, - + LIcKeyCode_LeftControl = 0x93, LIcKeyCode_LeftOption = 0x94, LIcKeyCode_LeftAlt = 0x95, @@ -268,23 +268,23 @@ typedef enum LIcKeyCode_RightOption = 0x97, LIcKeyCode_AppMenuKey = 0x98, LIcKeyCode_RightControl = 0x99, - + LIcKeyCode_PrintScreen = LIcKeyCode_F13, LIcKeyCode_ScrollLock = LIcKeyCode_F14, LIcKeyCode_Pause = LIcKeyCode_F15, - + LIcKeyCode_Insert = 0xAA, LIcKeyCode_Home = 0xAB, LIcKeyCode_PageUp = 0xAC, LIcKeyCode_Delete = 0xAD, LIcKeyCode_End = 0xAE, LIcKeyCode_PageDown = 0xAF, - + LIcKeyCode_UpArrow = 0xB0, LIcKeyCode_LeftArrow = 0xB1, LIcKeyCode_DownArrow = 0xB2, LIcKeyCode_RightArrow = 0xB3, - + LIcKeyCode_NumLock = 0xB4, LIcKeyCode_Divide = 0xB5, LIcKeyCode_Multiply = 0xB6, @@ -294,7 +294,7 @@ typedef enum LIcKeyCode_NumPadEnter = 0xBA, LIcKeyCode_NumPadComma = 0xBB, LIcKeyCode_NumPadEquals = 0xBC, - + LIcKeyCode_NumPad0 = 0xBD, LIcKeyCode_NumPad1 = 0xBE, LIcKeyCode_NumPad2 = 0xBF, @@ -305,7 +305,7 @@ typedef enum LIcKeyCode_NumPad7 = 0xC4, LIcKeyCode_NumPad8 = 0xC5, LIcKeyCode_NumPad9 = 0xC6, - + LIcKeyCode_Tilde = '~', LIcKeyCode_Exclamation = '!', LIcKeyCode_At = '@', @@ -327,10 +327,10 @@ typedef enum LIcKeyCode_LessThan = '<', LIcKeyCode_GreaterThan = '>', LIcKeyCode_Question = '?', - + LIcKeyCode_LeftWindowsKey = 0xC7, LIcKeyCode_RightWindowsKey = 0xC9 - + } LItKeyCode; enum @@ -367,7 +367,7 @@ enum LIcKeyState_RCommandDown = 0x0008, /* right control key under Win32 */ LIcKeyState_LAltDown = 0x0010, LIcKeyState_RAltDown = 0x0020, - + LIcKeyState_ShiftDown = (LIcKeyState_LShiftDown | LIcKeyState_RShiftDown), LIcKeyState_CommandDown = (LIcKeyState_LCommandDown | LIcKeyState_RCommandDown), LIcKeyState_AltDown = (LIcKeyState_LAltDown | LIcKeyState_RAltDown) @@ -380,7 +380,7 @@ typedef struct LItAction { LItButtonBits buttonBits; float analogValues[LIcNumAnalogValues]; - + } LItAction; typedef struct LItInputEvent @@ -389,7 +389,7 @@ typedef struct LItInputEvent IMtPoint2D where; UUtInt16 key; UUtUns32 modifiers; - + } LItInputEvent; // ---------------------------------------------------------------------- @@ -408,7 +408,7 @@ typedef struct LItDeviceInput { UUtUns32 input; float analogValue; - + } LItDeviceInput; // actions that the game understands @@ -417,7 +417,7 @@ typedef struct LItActionDescription UUtUns16 inputType; UUtUns16 actionData; // AnalogValue index or LIc_Bit_* char actionName[LIcMaxActionNameLength]; - + } LItActionDescription; // binding of device input to actions @@ -425,7 +425,7 @@ typedef struct LItBinding { UUtUns32 boundInput; LItActionDescription *action; - + } LItBinding; // enumerator function pointer typedef @@ -442,14 +442,14 @@ typedef UUtBool UUtBool LIrTestKey(LItKeyCode inKeyCode); -UUtBool +UUtBool LIrKeyWentDown(LItKeyCode inKeyCode, UUtBool *ioOldKeyDown); void LIrActionBuffer_Add( LItAction *outAction, LItDeviceInput *inDeviceInput); - + void LIrActionBuffer_Get( UUtUns16 *outNumActionsInBuffer, @@ -465,7 +465,7 @@ void LIrBindings_Enumerate( LItEnumBindings inBindingEnumerator, UUtUns32 inUserParam); - + void LIrBinding_Remove( UUtUns32 inBoundInput); @@ -473,7 +473,7 @@ LIrBinding_Remove( void LIrBindings_RemoveAll( void); - + // ---------------------------------------------------------------------- void LIrInputEvent_Add( @@ -481,7 +481,7 @@ LIrInputEvent_Add( IMtPoint2D *inPoint, UUtUns32 inKey, UUtUns32 inModifiers); - + UUtBool LIrInputEvent_Get( LItInputEvent *outInputEvent); @@ -498,13 +498,13 @@ void LIrInputEvent_CheatHook(LItCheatHook inHook); LItMode LIrMode_Get( void); - + void LIrMode_Set( LItMode inMode); void LIrGameIsActive(UUtBool inGameIsActive); - + // ---------------------------------------------------------------------- void LIrTranslate_InputCode( @@ -537,6 +537,6 @@ LIrUpdate( UUtError LIrRegisterTemplates( void); - + // ====================================================================== #endif /* BFW_LOCALINPUT_H */ diff --git a/BungieFrameWork/BFW_Headers/BFW_MasterHeader.h b/BungieFrameWork/BFW_Headers/BFW_MasterHeader.h index 56d1f3c..75da312 100644 --- a/BungieFrameWork/BFW_Headers/BFW_MasterHeader.h +++ b/BungieFrameWork/BFW_Headers/BFW_MasterHeader.h @@ -6,13 +6,13 @@ /* FILE: BFW.h - + AUTHOR: Michael Evans - + CREATED: Oct 13, 1999 - + PURPOSE: Master Include File - + Copyright 1999 */ @@ -62,4 +62,4 @@ #include "gl_code_version.h" -#endif //BFW_MASTERHEADER_H \ No newline at end of file +#endif //BFW_MASTERHEADER_H diff --git a/BungieFrameWork/BFW_Headers/BFW_Materials.h b/BungieFrameWork/BFW_Headers/BFW_Materials.h index b1af2c0..8189009 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Materials.h +++ b/BungieFrameWork/BFW_Headers/BFW_Materials.h @@ -36,7 +36,7 @@ MAtMaterial UUtBool breakable; // valid only at runtime tm_pad pad0[3]; tm_templateref parent; - + } MAtMaterial; #define MAcTemplate_Impact UUm4CharToUns32('I', 'm', 'p', 't') @@ -48,7 +48,7 @@ MAtImpact UUtBool lookup_bymaterial; // valid only at runtime tm_pad pad0[3]; tm_templateref parent; - + } MAtImpact; // ====================================================================== @@ -57,7 +57,7 @@ MAtImpact MAtImpactType MArImpactType_GetByName( const char *inImpactTypeName); - + const char* MArImpactType_GetName( MAtImpactType inImpactType); @@ -78,7 +78,7 @@ MArImpactType_LookupByMaterial( MAtMaterialType MArMaterialType_GetByName( const char *inMaterialTypeName); - + const char* MArMaterialType_GetName( MAtMaterialType inMaterialType); @@ -93,7 +93,7 @@ MArMaterialType_GetParent( // returns UUcTrue iff inDescendant descends from inMaterial UUtBool MArMaterial_IsDescendent( - MAtMaterialType inDescendant, + MAtMaterialType inDescendant, MAtMaterialType inMaterial); UUtBool @@ -104,7 +104,7 @@ MArMaterialType_IsBreakable( UUtUns32 MArImpacts_GetNumTypes( void); - + UUtUns32 MArMaterials_GetNumTypes( void); @@ -112,7 +112,7 @@ MArMaterials_GetNumTypes( UUtError MArMaterials_Initialize( void); - + UUtError MArMaterials_RegisterTemplates( void); @@ -120,7 +120,7 @@ MArMaterials_RegisterTemplates( void MArMaterials_Terminate( void); - + // ---------------------------------------------------------------------- UUtError MArImpacts_PreProcess( diff --git a/BungieFrameWork/BFW_Headers/BFW_MathLib.h b/BungieFrameWork/BFW_Headers/BFW_MathLib.h index 24f3b2a..275c898 100644 --- a/BungieFrameWork/BFW_Headers/BFW_MathLib.h +++ b/BungieFrameWork/BFW_Headers/BFW_MathLib.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_MathLib.h - + AUTHOR: Michael Evans - + CREATED: January 9, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -29,9 +29,9 @@ extern "C" { #define UUcFloat_NormalizedBit 0x00800000 #define UUcFloat_ExponentMask 0x7f800000 // bits 1- 8 [8] #define UUcFloat_SignBit 0x80000000 // bit 0 [1] - + #define UUcDouble_FractionMask ((UUtUns64) 0x000fffffffffffff) // bits 12-63 -#define UUcDouble_NormalizedBit ((UUtUns64) 0x0010000000000000) +#define UUcDouble_NormalizedBit ((UUtUns64) 0x0010000000000000) #define UUcDouble_ExponentMask ((UUtUns64) 0x7ff0000000000000) // bits 1-11 #define UUcDouble_SignBit ((UUtUns64) 0x8000000000000000) // bit 0 @@ -78,12 +78,12 @@ typedef struct MUtEuler void MUrMinMaxBBox_CreateFromSphere( const M3tMatrix4x3 *inMatrix, - const M3tBoundingSphere *inSphere, + const M3tBoundingSphere *inSphere, M3tBoundingBox_MinMax *outBBox); void MUrMinMaxBBox_ExpandBySphere( const M3tMatrix4x3 *inMatrix, - const M3tBoundingSphere *inSphere, + const M3tBoundingSphere *inSphere, M3tBoundingBox_MinMax *ioBBox); void MUrMinMaxBBox_To_Sphere( @@ -92,12 +92,12 @@ void MUrMinMaxBBox_To_Sphere( void MUrCylinder_CreateFromSphere( const M3tMatrix4x3 *inMatrix, - const M3tBoundingSphere *inSphere, + const M3tBoundingSphere *inSphere, M3tBoundingCylinder *outCylinder); void MUrCylinder_ExpandBySphere( const M3tMatrix4x3 *inMatrix, - const M3tBoundingSphere *inSphere, + const M3tBoundingSphere *inSphere, M3tBoundingCylinder *ioCylinder); void MUrInitialize(void); @@ -191,7 +191,7 @@ void MUrPoint2D_Subtract(M3tPoint2D *result, const M3tPoint2D *inPointA, const M UUmAssert((plane).a < ( (value))); \ UUmAssert((plane).b < ( (value))); \ UUmAssert((plane).c < ( (value))); \ - UUmAssert((plane).d < ( (value))); + UUmAssert((plane).d < ( (value))); #define MUmAssertVector(vec, value) \ UUmAssert((vec).x > (-(value))); \ @@ -199,7 +199,7 @@ void MUrPoint2D_Subtract(M3tPoint2D *result, const M3tPoint2D *inPointA, const M UUmAssert((vec).z > (-(value))); \ UUmAssert((vec).x < (value)); \ UUmAssert((vec).y < (value)); \ - UUmAssert((vec).z < (value)); + UUmAssert((vec).z < (value)); #define MUmVector_IsZero(vec) \ ( UUmFloat_CompareEqu((vec).x, 0) && \ @@ -251,7 +251,7 @@ do { (vec).x=(a); \ (vec).y=(b); \ (vec).z=(c); } while (0) -#ifndef USE_FAST_MATH +#ifndef USE_FAST_MATH #define MUmVector_Scale(vec,s) \ do { (vec).x*=(s); \ (vec).y*=(s); \ @@ -313,7 +313,7 @@ UUtBool MUrVector_Normalize_ZeroTest(M3tVector3D *inV); #define MUmVector_IsNormalized(vector) \ (((UUmSQR((vector).x) + UUmSQR((vector).y) + UUmSQR((vector).z)) > .99f) && \ ((UUmSQR((vector).x) + UUmSQR((vector).y) + UUmSQR((vector).z)) < 1.01f)) - + #define MUmPoint_Compare(pointA, pointB) \ (UUmFloat_CompareEqu((pointA).x, (pointB).x) && \ UUmFloat_CompareEqu((pointA).y, (pointB).y) && \ @@ -389,7 +389,7 @@ float MUrPoint_ManhattanDistanceToQuad( M3tPoint3D *inPoint, M3tPoint3D *inPointArray, M3tQuad *inQuad); - + void MUrVector_PlaneFromEdges( M3tPoint3D *inEdge1a, M3tPoint3D *inEdge1b, @@ -402,9 +402,9 @@ MUrTriangle_Area( M3tPoint3D* inPoint0, M3tPoint3D* inPoint1, M3tPoint3D* inPoint2); - + /* - * + * */ void MUrMatrix_From_Point_And_Vectors( @@ -443,11 +443,11 @@ UUtBool MUrPlaneEquation_IsClose( const M3tPlaneEquation *inPlaneEquationB); typedef struct { - M3tVector3D translation; + M3tVector3D translation; M3tQuaternion rotation; - M3tQuaternion stretchRotation; - M3tVector3D stretch; - float sign; + M3tQuaternion stretchRotation; + M3tVector3D stretch; + float sign; } MUtAffineParts; // strips scale and translation @@ -548,13 +548,13 @@ void MUrMatrix_Inverse(const M3tMatrix4x3 *inV, M3tMatrix4x3 *outV); void MUrMatrix_Adjoint(const M3tMatrix4x3 *inV, M3tMatrix4x3 *outV); void MUrMatrix_Identity(M3tMatrix4x3 *ioMatrix); float MUrMatrix_Determinant(const M3tMatrix4x3 *m); -void MUrMatrix_RotateX(M3tMatrix4x3 *matrix, float angle); -void MUrMatrix_RotateY(M3tMatrix4x3 *matrix, float angle); -void MUrMatrix_RotateZ(M3tMatrix4x3 *matrix, float angle); -void MUrMatrix3x3_Rotate(M3tMatrix3x3 *matrix, float inX, float inY, float inZ, float angle); -void MUrMatrix3x3_RotateX(M3tMatrix3x3 *matrix, float angle); -void MUrMatrix3x3_RotateY(M3tMatrix3x3 *matrix, float angle); -void MUrMatrix3x3_RotateZ(M3tMatrix3x3 *matrix, float angle); +void MUrMatrix_RotateX(M3tMatrix4x3 *matrix, float angle); +void MUrMatrix_RotateY(M3tMatrix4x3 *matrix, float angle); +void MUrMatrix_RotateZ(M3tMatrix4x3 *matrix, float angle); +void MUrMatrix3x3_Rotate(M3tMatrix3x3 *matrix, float inX, float inY, float inZ, float angle); +void MUrMatrix3x3_RotateX(M3tMatrix3x3 *matrix, float angle); +void MUrMatrix3x3_RotateY(M3tMatrix3x3 *matrix, float angle); +void MUrMatrix3x3_RotateZ(M3tMatrix3x3 *matrix, float angle); void MUrMatrix_Translate( M3tMatrix4x3 *ioMatrix, const M3tVector3D *inTranslate); @@ -569,16 +569,16 @@ void MUrMatrixVerify(const M3tMatrix4x3 *inMatrix); #endif void MUrMatrix_Multiply( - const M3tMatrix4x3 *inMatrixA, - const M3tMatrix4x3 *inMatrixB, + const M3tMatrix4x3 *inMatrixA, + const M3tMatrix4x3 *inMatrixB, M3tMatrix4x3 *outResult); void MUrMatrix3x3_Multiply( - const M3tMatrix3x3 *inMatrixA, - const M3tMatrix3x3 *inMatrixB, + const M3tMatrix3x3 *inMatrixA, + const M3tMatrix3x3 *inMatrixB, M3tMatrix3x3 *outResult); // transpose a matrix void MUrMatrix3x3_Transpose( - const M3tMatrix3x3 *inMatrix, + const M3tMatrix3x3 *inMatrix, M3tMatrix3x3 *outResult); void MUrMatrix_MultiplyNormal( @@ -593,24 +593,24 @@ void MUrMatrix_MultiplyNormals( M3tVector3D *outNormals); void MUrMatrix_MultiplyPoint( - const M3tPoint3D *inPoint, - const M3tMatrix4x3 *inMatrix, + const M3tPoint3D *inPoint, + const M3tMatrix4x3 *inMatrix, M3tPoint3D *outPoint); void MUrMatrix3x3_MultiplyPoint( - const M3tPoint3D *inPoint, - const M3tMatrix3x3 *inMatrix, + const M3tPoint3D *inPoint, + const M3tMatrix3x3 *inMatrix, M3tPoint3D *outPoint); void MUrMatrix3x3_TransposeMultiplyPoint( - const M3tPoint3D *inPoint, - const M3tMatrix3x3 *inMatrix, + const M3tPoint3D *inPoint, + const M3tMatrix3x3 *inMatrix, M3tPoint3D *outPoint); void MUrMatrix_MultiplyPoints( UUtUns32 inNumPoints, - const M3tMatrix4x3 *inMatrix, - const M3tPoint3D *inPoints, + const M3tMatrix4x3 *inMatrix, + const M3tPoint3D *inPoints, M3tPoint3D *outPoints); void MUrMatrix_DualAlignment( @@ -651,18 +651,18 @@ void MUrMatrixStack_Euler( M3tMatrix4x3 *topOfStack, const MUtEuler *inEuler); -void MUrMatrixStack_RotateX(M3tMatrix4x3 *topOfStack, float angle); -void MUrMatrixStack_RotateY(M3tMatrix4x3 *topOfStack, float angle); -void MUrMatrixStack_RotateZ(M3tMatrix4x3 *topOfStack, float angle); +void MUrMatrixStack_RotateX(M3tMatrix4x3 *topOfStack, float angle); +void MUrMatrixStack_RotateY(M3tMatrix4x3 *topOfStack, float angle); +void MUrMatrixStack_RotateZ(M3tMatrix4x3 *topOfStack, float angle); -/* +/* * euler functions * * see EulerAngles.h or GraphicsGems IV pp 222 * * include EulerAngles.h for constants for EulerFrom - * + * */ MUtEuler Euler_(float ai, float aj, float ah, int order); @@ -728,7 +728,7 @@ void MUrQuat_Exp(M3tQuaternion* q1, M3tQuaternion* q2); UUmFloat_CompareEqu(quatA.y,quatB.y) && \ UUmFloat_CompareEqu(quatA.z,quatB.z) && \ UUmFloat_CompareEqu(quatA.w,quatB.w)) - + void MUrQuat_Inverse(const M3tQuaternion *quat, M3tQuaternion *res); float MUrQuat_Length(M3tQuaternion* q1); void MUrQuat_Lerp(const M3tQuaternion *from, const M3tQuaternion *to, float t, M3tQuaternion *res); @@ -770,7 +770,7 @@ void MUrNormalize(M3tVector3D *ioVector); void MUrPoint3D_Lerp(const M3tPoint3D *inFrom, const M3tPoint3D *inTo, float t, M3tPoint3D *outResult); /* - * + * */ void MUrVector_SetLength(M3tVector3D *ioVector, float inNewMagnitude); @@ -801,9 +801,9 @@ void MUrPoint3D_Lerp(const M3tPoint3D *inFrom, const M3tPoint3D *inTo, float t, const M3tPoint3D* inPoint1, const M3tPoint3D* inPoint2, M3tVector3D *outNormal); - + /* - * + * */ void @@ -851,7 +851,7 @@ void MUrPoint3D_Lerp(const M3tPoint3D *inFrom, const M3tPoint3D *inTo, float t, float inY, float inZ, M3tMatrix4x3 *outMatrix); - + void MUrMatrix_BuildTranslate( float inX, @@ -864,7 +864,7 @@ void MUrPoint3D_Lerp(const M3tPoint3D *inFrom, const M3tPoint3D *inTo, float t, float inScale, M3tMatrix4x3 *outMatrix); - void + void MUrMatrix_BuildScale( M3tPoint3D *inScale, M3tMatrix4x3 *outMatrix); @@ -875,28 +875,28 @@ void MUrPoint3D_Lerp(const M3tPoint3D *inFrom, const M3tPoint3D *inTo, float t, // Matrix3x3 operations void MUrMatrix3x3_MultiplyNormal( - const M3tVector3D *inNormal, - const M3tMatrix3x3 *inMatrix, + const M3tVector3D *inNormal, + const M3tMatrix3x3 *inMatrix, M3tVector3D *outNormal); - + void MUrMatrix3x3_MultiplyNormals( UUtUns32 inNumNormals, const M3tMatrix3x3 *inMatrix, const M3tVector3D *inNormals, M3tVector3D *outNormals); - + void MUrMatrix3x3_ExtractFrom4x3( M3tMatrix3x3 *outMatrix3x3, const M3tMatrix4x3 *inMatrix4x3); - + void MUrMatrix4x3_Multiply3x3( const M3tMatrix4x3* inMatrix4x3, const M3tMatrix3x3* inMatrix3x3, M3tMatrix4x3 *outMatrix4x3); - + void MUrMatrix4x3_BuildFrom3x3( M3tMatrix4x3 *outMatrix4x3, diff --git a/BungieFrameWork/BFW_Headers/BFW_Motoko.h b/BungieFrameWork/BFW_Headers/BFW_Motoko.h index 2b89392..dc2241f 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Motoko.h +++ b/BungieFrameWork/BFW_Headers/BFW_Motoko.h @@ -2,13 +2,13 @@ /* FILE: BFW_Motoko.h - + AUTHOR: Brent H. Pease - + CREATED: April 2, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -18,25 +18,25 @@ for a 3D engine. The real implementation is contained within a shared library. When Motoko is initialized at start-up time all shared libraries that implement the Motoko API are loaded and available for use. - + Coordinate Systems: - + Frustum/View Space Coordinate System: Right Handed x increases to the right y increases upwards z increases out of the screen - + Screen Coordinate System: Right Handed x increases to the right y increases downwards z increases into the screen - - - - + + + + SCREEN ====== - + x -> *--------------------------------> | @@ -87,29 +87,29 @@ extern "C" { #define M3cQuarterPi 0.78539816339744830961566084581988f // S.S. ((float) (0.25f * M3cPi)) #define M3cEpsilon UUcEpsilon #define M3cModelMatrix_MaxDepth 32 - #define M3cMaxObjVertices 2048 // S.S. (2 * 1024) - #define M3cMaxObjTris 4096 // S.S. (4 * 1024) - #define M3cMaxObjQuads 4096 // S.S. (4 * 1024) + #define M3cMaxObjVertices 2048 // S.S. (2 * 1024) + #define M3cMaxObjTris 4096 // S.S. (4 * 1024) + #define M3cMaxObjQuads 4096 // S.S. (4 * 1024) #define M3cDegToRad 0.017453292519943295769236907684886f // S.S. (M3c2Pi / 360.f) #define M3cRadToDeg 57.295779513082320876798154814105f // S.S. (360.f / M3c2Pi) - + #define M3cExtraCoords (60) - + #define M3cMaxDisplayModes (16) #define M3cMaxDisplayDevices (8) #define M3cMaxNumEngines (2) #define M3cMaxNameLen (64) - + #define M3cMaxAlpha ((UUtUns32)255) - + #define M3cBBoxSideBV_PosX 1 // S.S. (1 << 0) #define M3cBBoxSideBV_NegX 2 // S.S. (1 << 1) #define M3cBBoxSideBV_PosY 4 // S.S. (1 << 2) #define M3cBBoxSideBV_NegY 8 // S.S. (1 << 3) #define M3cBBoxSideBV_PosZ 16 // S.S. (1 << 4) #define M3cBBoxSideBV_NegZ 32 // S.S. (1 << 5) - + /* * Motoko is a 16bit RGB(1555 or 565) and 16bit zbuffer engine */ @@ -134,43 +134,43 @@ extern "C" { /* * Predefine a few opaque data structures */ - + typedef struct M3tDrawContext M3tDrawContext; typedef struct M3tDrawContextPrivate M3tDrawContextPrivate; typedef struct M3tGeomContext M3tGeomContext; typedef struct M3tGeomContextPrivate M3tGeomContextPrivate; - + typedef struct M3tGeomCamera M3tGeomCamera; - + #if UUmPlatform == UUmPlatform_Mac - + typedef GDHandle M3tPlatformDevice; - + #elif UUmPlatform == UUmPlatform_Win32 - + typedef LPVOID M3tPlatformDevice; - + #elif UUmPlatform == UUmPlatform_Linux - + // software renderer not yet available on Linux typedef struct {} M3tPlatformDevice; - + #else - + #error implement me - + #endif /* * A 3d point */ - typedef tm_struct M3tPoint3D + typedef tm_struct M3tPoint3D { - float x; - float y; - float z; - + float x; + float y; + float z; + } M3tPoint3D; #if 0 /* @@ -181,8 +181,8 @@ extern "C" { float x; float y; float z; - - } M3tVector3D; + + } M3tVector3D; #endif typedef M3tPoint3D M3tVector3D; @@ -191,21 +191,21 @@ extern "C" { { float x; float z; - + } M3tPoint2D; /* - * + * */ - typedef tm_struct M3tTextureCoord + typedef tm_struct M3tTextureCoord { float u; float v; - + } M3tTextureCoord; /* - * + * */ typedef tm_struct M3tPoint4D { @@ -213,7 +213,7 @@ extern "C" { float y; float z; float w; - + } M3tPoint4D; /* @@ -240,21 +240,21 @@ extern "C" { } M3tRotation; /* - * + * */ typedef tm_struct M3tTri { - UUtUns32 indices[3]; + UUtUns32 indices[3]; } M3tTri; - + typedef tm_struct M3tQuad { - UUtUns32 indices[4]; + UUtUns32 indices[4]; } M3tQuad; - + typedef tm_struct M3tPent { - UUtUns32 indices[5]; + UUtUns32 indices[5]; } M3tPent; /* @@ -266,11 +266,11 @@ extern "C" { float b; float c; float d; - + } M3tPlaneEquation; - + /* - * + * */ typedef tm_struct M3tPointScreen { @@ -278,30 +278,30 @@ extern "C" { float y; float z; float invW; - + } M3tPointScreen; /* Conceptually a M3tMatrix4x3 is viewed as the following: - + -- -- | a b c d | | e f g h | | i j k l | -- -- - + use the following example to access the elements of the matrix - + M3tMatrix4x3* matrix; - + matrix->m[0][0] is a; matrix->m[1][0] is b; matrix->m[2][0] is c; matrix->m[3][0] is d; - + ... - + matrix->m[0][2] is i; matrix->m[1][2] is j; matrix->m[2][2] is k; @@ -341,100 +341,100 @@ extern "C" { M3cBBoxSide_NegZ, M3cBBoxSide_None } M3tBBoxSide; - + // cylinder - // Etymology: Middle French or Latin; Middle French cylindre, from Latin cylindrus, - // from Greek kylindros, from kylindein to roll; perhaps akin to Greek kyklos wheel - + // Etymology: Middle French or Latin; Middle French cylindre, from Latin cylindrus, + // from Greek kylindros, from kylindein to roll; perhaps akin to Greek kyklos wheel + typedef tm_struct M3tBoundingCircle { M3tPoint2D center; float radius; } M3tBoundingCircle; - + typedef tm_struct M3tBoundingCylinder { M3tBoundingCircle circle; float top; float bottom; } M3tBoundingCylinder; - + typedef tm_struct M3tBoundingBox_MinMax { M3tPoint3D minPoint; M3tPoint3D maxPoint; - + } M3tBoundingBox_MinMax; - + #define M3cBoundingBox_Edge_Count 12 typedef tm_struct M3tBoundingBox_Edge { M3tEdge edges[12]; } M3tBoundingBox_Edge; - + typedef tm_struct M3tBoundingBox { M3tPoint3D localPoints[8]; - + } M3tBoundingBox; - - + + #define M3cNumBoundingPoints 8 // Do not change without changing references below #define M3cNumBoundingFaces 6 // Do not change without changing references below - typedef tm_struct M3tBoundingVolume + typedef tm_struct M3tBoundingVolume { M3tPoint3D worldPoints[8]; // Must match M3cNumBoundingPoints above M3tQuad faces[6]; // Must match M3cNumBoundingFaces above M3tVector3D normals[6]; // Must match M3cNumBoundingFaces above - starting normals - + M3tPlaneEquation curPlanes[6]; // Must match M3cNumBoundingFaces above - current plane equs UUtUns16 curProjections[6]; // Must match M3cNumBoundingFaces above - + } M3tBoundingVolume; - - - + + + typedef tm_struct M3tBoundingSphere { M3tPoint3D center; float radius; } M3tBoundingSphere; - - + + // hotdog (path carved by moving sphere) - // Etymology: American, from Latin sweatus caninus, - // from Greek baseballos snackos, from kholesterol to grow wide; perhaps akin to Greek rapidos foodos. + // Etymology: American, from Latin sweatus caninus, + // from Greek baseballos snackos, from kholesterol to grow wide; perhaps akin to Greek rapidos foodos. typedef tm_struct M3tBoundingHotdog { M3tPoint3D start; M3tPoint3D end; float radius; - + } M3tBoundingHotdog; /* - * + * */ typedef tm_struct M3tColorRGB { float r; float g; float b; - + } M3tColorRGB; typedef struct M3tLight_Ambient { M3tColorRGB color; - + } M3tLight_Ambient; typedef struct M3tLight_Directional { M3tVector3D direction; M3tColorRGB color; - + } M3tLight_Directional; typedef struct M3tLight_Point @@ -442,7 +442,7 @@ extern "C" { M3tPoint3D location; float a, b, c; // attenuation = a/(d*d) + b/d + c M3tColorRGB color; - + } M3tLight_Point; typedef struct M3tLight_Cone @@ -453,7 +453,7 @@ extern "C" { float falloffAngle; // no intensity outside this angle float a, b, c; // attenuation = a/(d*d) + b/d + c M3tColorRGB color; - + } M3tLight_Cone; /* @@ -465,11 +465,11 @@ extern "C" { UUtUns16 indices[2]; UUtUns16 triA; UUtUns16 triB; - + } M3tEdgeIndex; - + /* - * + * */ typedef enum M3tGeomStateIntType { @@ -479,61 +479,61 @@ extern "C" { M3cGeomStateIntType_Hint, M3cGeomStateIntType_SubmitMode, M3cGeomStateIntType_Alpha, // range is 0 - 255 - M3cGeomStateIntType_SpriteMode, + M3cGeomStateIntType_SpriteMode, M3cGeomStateIntType_DebugMode, M3cGeomStateIntType_FastMode, M3cGeomStateIntType_NumTypes } M3tGeomStateIntType; - + /* - * + * */ typedef enum M3tGeomState_Fill { M3cGeomState_Fill_Point, M3cGeomState_Fill_Line, M3cGeomState_Fill_Solid - + } M3tGeomState_Fill; /* - * + * */ typedef enum M3tGeomState_Shade { M3cGeomState_Shade_Vertex, M3cGeomState_Shade_Face - + } M3tGeomState_Shade; /* - * + * */ typedef enum M3tGeomState_Appearance { M3cGeomState_Appearance_Gouraud, M3cGeomState_Appearance_Texture - + } M3tGeomState_Appearance; /* - * + * */ typedef enum M3tGeomState_Hint { M3cGeomState_Hint_None, M3cGeomState_Hint_NoClip - + } M3tGeomState_Hint; /* - * + * */ typedef enum M3tGeomState_SubmitMode { M3cGeomState_SubmitMode_Normal, M3cGeomState_SubmitMode_SortAlphaTris - + } M3tGeomState_SubmitMode; /* @@ -563,18 +563,18 @@ extern "C" { } M3tContrailData; /* - * + * */ typedef enum M3tGeomState_DebugMode { M3cGeomState_DebugMode_None = 0, M3cGeomState_DebugMode_UseEnvDbgTexture = (1 << 0), M3cGeomState_DebugMode_DrawGhostGQs = (1 << 1) - + } M3tGeomState_DebugMode; - + /* - * + * */ typedef enum M3tDrawStatePtrType { @@ -586,15 +586,15 @@ extern "C" { M3cDrawStatePtrType_BaseTextureMap, M3cDrawStatePtrType_LightTextureMap, M3cDrawStatePtrType_EnvTextureMap, - + M3cDrawStatePtrType_VertexBitVector, // This list indicates which vertices will actually be used - + M3cDrawStatePtrType_NumTypes - + } M3tDrawStatePtrType; /* - * + * */ typedef enum M3tDrawStateIntType { @@ -606,27 +606,27 @@ extern "C" { M3cDrawStateIntType_ZBias, M3cDrawStateIntType_NumRealVertices, // This is the number of vertices not including extra for clipping M3cDrawStateIntType_ConstantColor, - + M3cDrawStateIntType_SubmitMode, M3cDrawStateIntType_Alpha, // range is 0 to 255 M3cDrawStateIntType_Time, // time in 60ths, used for animated textures M3cDrawStateIntType_TextureInstance, // used to identify a particular instance of a texture (random start) M3cDrawStateIntType_BufferClear, // 1 = buffer clear, 0 = dont buffer clear - M3cDrawStateIntType_DoubleBuffer, // 1 = double buffer, 0 = single buffer + M3cDrawStateIntType_DoubleBuffer, // 1 = double buffer, 0 = single buffer M3cDrawStateIntType_Clipping, // 1 = clipping on, 0 = no clipping M3cDrawStateIntType_Fog, // S.S. 1 = enable fog, 0 = disable fog; initial state is on M3cDrawStateIntType_FrameBufferBlendWithConstantAlpha, // S.S. the name says it all; boolean value - + M3cDrawStateIntType_VertexFormat, M3cDrawStateIntType_ClearColor, - + M3cDrawStateIntType_NumTypes - + } M3tDrawStateIntType; /* - * + * */ typedef struct M3tDrawContext_Counters { @@ -639,11 +639,11 @@ typedef struct M3tDrawContext_Counters UUtUns32 numPentSplits; UUtUns32 numSprites; UUtUns32 numAlphaSortedObjs; - + } M3tDrawContext_Counters; /* - * + * */ typedef enum M3tDrawStateAppearence { @@ -653,97 +653,97 @@ typedef struct M3tDrawContext_Counters M3cDrawState_Appearence_Texture_Unlit, M3cDrawState_Appearence_Num - + } M3tDrawStateAppearence; - + /* - * + * */ typedef enum M3tDrawState_Fill { M3cDrawState_Fill_Point, M3cDrawState_Fill_Line, M3cDrawState_Fill_Solid, - + M3cDrawState_Fill_Num - + } M3tDrawState_Fill; /* - * + * */ typedef enum M3tDrawStateInterpolation { M3cDrawState_Interpolation_None, M3cDrawState_Interpolation_Vertex, - + M3cDrawState_Interpolation_Num - + } M3tDrawStateInterpolation; - + /* - * + * */ typedef enum M3tDrawStateZWrite { M3cDrawState_ZWrite_Off, M3cDrawState_ZWrite_On - + } M3tDrawStateZWrite; /* - * + * */ typedef enum M3tDrawStateZCompare { M3cDrawState_ZCompare_Off, M3cDrawState_ZCompare_On - + } M3tDrawStateZCompare; /* - * + * */ typedef enum M3tDrawStateBufferClear { M3cDrawState_BufferClear_Off, M3cDrawState_BufferClear_On - + } M3tDrawStateBufferClear; - + /* - * + * */ typedef enum M3tDrawStateDoubleBuffer { M3cDrawState_DoubleBuffer_Off, M3cDrawState_DoubleBuffer_On - + } M3tDrawStateDoubleBuffer; /* - * + * */ typedef enum M3tDrawStateSubmitMode { M3cDrawState_SubmitMode_Normal, M3cDrawState_SubmitMode_SortAlphaTris - + } M3tDrawStateSubmitMode; - + /* - * + * */ typedef enum M3tDrawStateVertexFormat { M3cDrawStateVertex_Unified, // a single index specifies both xyz, rgb, and uv M3cDrawStateVertex_Split, - + M3cDrawStateVertex_Num - + } M3tDrawStateVertexFormat; /* - * + * */ typedef enum M3tDrawStateFogDisable // S.S. @@ -754,23 +754,23 @@ typedef struct M3tDrawContext_Counters M3cDrawStateFog_Num } M3tDrawStateFogDisable; - + /* - * + * */ #define M3cTemplate_PlaneEquationArray UUm4CharToUns32('P', 'L', 'E', 'A') typedef tm_template('P', 'L', 'E', 'A', "Plane Equation Array") M3tPlaneEquationArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numPlanes; tm_vararray M3tPlaneEquation planes[1]; - + } M3tPlaneEquationArray; /* - * + * */ #define M3cTextureMap_MaxWidth 256 #define M3cTextureMap_MaxHeight 256 @@ -804,18 +804,18 @@ typedef struct M3tDrawContext_Counters M3tTextureMap { // implied 8 bytes here - + //char pad[28]; - + char debugName[128]; - + UUtUns32 flags; UUtUns16 width; UUtUns16 height; IMtPixelType texelType; tm_templateref animation; M3tTextureMap* envMap; // The environment map that is tied to this texture map - + tm_raw(void *) pixels; // CB: if this is non-NULL then it is either 1) a special texture that is saved as raw data and // not separate data during the importer (there are none of these textures at present) // or 2) a texture that was created at runtime. @@ -828,7 +828,7 @@ typedef struct M3tDrawContext_Counters UUtUns32 opengl_texture_name; UUtBool opengl_dirty; tm_pad pad1[3]; // S.S. I am using these pad bytes internally so don't mess with them without making sure they aren't used - + }; #define M3cTemplate_TextureMapAnimation UUm4CharToUns32('T', 'X', 'A', 'N') @@ -838,10 +838,10 @@ typedef struct M3tDrawContext_Counters tm_pad pad0[12]; UUtUns16 timePerFrame; // in 60th sec - + UUtUns16 randTPF_low; UUtUns16 randTPF_range; - + tm_pad pad1[2]; tm_varindex UUtUns32 numFrames; @@ -858,38 +858,38 @@ typedef struct M3tDrawContext_Counters M3tTextureMap_Big { tm_pad pad0[8]; - + UUtUns16 width; UUtUns16 height; IMtPixelType texelType; - + UUtUns16 num_x; UUtUns16 num_y; tm_varindex UUtUns32 num_textures; tm_vararray M3tTextureMap *textures[1]; - + } M3tTextureMap_Big; - + #define M3cTemplate_TextureMap_Proc UUm4CharToUns32('T', 'X', 'P', 'C') typedef tm_template('T','X','P','C', "Texture Procedure Data") M3tTextureMap_Proc { tm_pad pad0[8]; - + UUtUns32 nextFrameTime; UUtUns32 speed; UUtUns32 curTexture; - + tm_varindex UUtUns32 numTextures; tm_vararray UUtUns32 textureIndices[1]; } M3tTextureMap_Proc; - + /* - * + * */ #define M3cTemplate_Point3DArray UUm4CharToUns32('P', 'N', 'T', 'A') - + typedef tm_template('P', 'N', 'T', 'A', "3D Point Array") M3tPoint3DArray { @@ -897,74 +897,74 @@ typedef struct M3tDrawContext_Counters M3tBoundingBox_MinMax minmax_boundingBox; M3tBoundingSphere boundingSphere; - + tm_varindex UUtUns32 numPoints; tm_vararray M3tPoint3D points[1]; - + } M3tPoint3DArray; - + /* - * + * */ #define M3cTemplate_Vector3DArray UUm4CharToUns32('V', 'C', 'R', 'A') - + typedef tm_template('V', 'C', 'R', 'A', "3D Vector Array") M3tVector3DArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numVectors; tm_vararray M3tVector3D vectors[1]; - + } M3tVector3DArray; - + /* - * + * */ #define M3cTemplate_ColorRGBArray UUm4CharToUns32('3', 'C', 'L', 'A') - + typedef tm_template('3', 'C', 'L', 'A', "RGB Color Array") M3tColorRGBArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numColors; tm_vararray M3tColorRGB colors[1]; - + } M3tColorRGBArray; /* - * + * */ #define M3cTemplate_EdgeIndexArray UUm4CharToUns32('E', 'D', 'I', 'A') - + typedef tm_template('E', 'D', 'I', 'A', "Edge Index Array") M3tEdgeIndexArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numEdges; tm_vararray M3tEdgeIndex edgeIndices[1]; - + } M3tEdgeIndexArray; /* - * + * */ #define M3cTemplate_TextureCoordArray UUm4CharToUns32('T', 'X', 'C', 'A') - + typedef tm_template('T', 'X', 'C', 'A', "Texture Coordinate Array") M3tTextureCoordArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numTextureCoords; tm_vararray M3tTextureCoord textureCoords[1]; // This list must have an extra MScExtraTextureCoords coords for clipping - + } M3tTextureCoordArray; /* - * + * */ typedef tm_enum M3tGeometryFlags { @@ -973,76 +973,76 @@ typedef struct M3tDrawContext_Counters M3cGeometryFlag_ComputeSpecular = 0x02, // Compute specular highlights M3cGeometryFlag_ComputeDiffuse = 0x04, // Compute diffuse component M3cGeometryFlag_HasAmbient = 0x08, // Object has an ambient color - M3cGeometryFlag_SelfIlluminent = 0x10, // Object is self-illuminent (do not shade) + M3cGeometryFlag_SelfIlluminent = 0x10, // Object is self-illuminent (do not shade) M3cGeometryFlag_NoQuads = 0x20 // Object has no quads defined (only points) } M3tGeometryFlags; - + /* - * + * */ #define M3cTemplate_TriArray UUm4CharToUns32('M', '3', 'T', 'A') - + typedef tm_template('M', '3', 'T', 'A', "Triangle array") M3tTriArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numTris; tm_vararray M3tTri tris[1]; - + } M3tTriArray; /* - * + * */ #define M3cTemplate_QuadArray UUm4CharToUns32('Q', 'U', 'D', 'A') - + typedef tm_template('Q', 'U', 'D', 'A', "Quad array") M3tQuadArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numQuads; tm_vararray M3tQuad quads[1]; - + } M3tQuadArray; /* - * + * */ #define M3cTemplate_TextureMapArray UUm4CharToUns32('T', 'X', 'M', 'A') - + typedef tm_template('T', 'X', 'M', 'A', "Texture map array") M3tTextureMapArray { tm_pad pad0[20]; tm_varindex UUtUns32 numMaps; - tm_vararray M3tTextureMap* maps[1]; + tm_vararray M3tTextureMap* maps[1]; } M3tTextureMapArray; - + /* * */ #define M3cTemplate_Geometry UUm4CharToUns32('M', '3', 'G', 'M') - + typedef tm_template('M', '3', 'G', 'M', "Geometry") M3tGeometry { M3tGeometryFlags geometryFlags; - - M3tPoint3DArray* pointArray; - M3tVector3DArray* vertexNormalArray; + + M3tPoint3DArray* pointArray; + M3tVector3DArray* vertexNormalArray; M3tVector3DArray* triNormalArray; M3tTextureCoordArray* texCoordArray; // This list must have an extra MScExtraTextureCoords coords for clipping - + TMtIndexArray* triStripArray; TMtIndexArray* triNormalIndexArray; // This also indicates the number of tris in the object - + M3tTextureMap* baseMap; // This is also the source of the environment map - + tm_templateref animation; - + } M3tGeometry; #define M3cTemplate_GeometryAnimation UUm4CharToUns32('G', 'M', 'A', 'N') @@ -1055,10 +1055,10 @@ typedef struct M3tDrawContext_Counters UUtUns16 randTPF_low; UUtUns16 randTPF_range; tm_pad pad1[2]; - + tm_varindex UUtUns32 numFrames; tm_vararray M3tGeometry* frames[1]; - + } M3tGeometryAnimation; #define M3cTemplate_GeometryArray UUm4CharToUns32('M', '3', 'G', 'A') @@ -1087,14 +1087,14 @@ typedef struct M3tDrawContext_Counters } M3tSpriteArray; /* - * + * */ typedef struct M3tDiffuseRGB { UUtUns32 diffuseRGB; } M3tDiffuseRGB; - + /* * Draw Engine Names */ @@ -1103,12 +1103,12 @@ typedef struct M3tDrawContext_Counters #define M3cDrawEngine_D3D "Direct3D" #define M3cDrawEngine_RAVE "RAVE" #define M3cDrawEngine_OpenGL "OpenGL" - + /* * Geom Engine IDs */ #define M3cGeomEngine_Software "Oni Software" - + /* * Draw Engine cap list structure */ @@ -1119,9 +1119,9 @@ typedef struct M3tDrawContext_Counters M3cDrawEngineFlag_CanHandleOffScreen = (1 << 0), M3cDrawEngineFlag_3DOnly = (1 << 1), M3cDrawEngineFlag_CanSort = (1 << 2) - + } M3tDrawEngineFlags; - + typedef struct M3tDisplayMode { UUtUns16 width; @@ -1129,53 +1129,53 @@ typedef struct M3tDrawContext_Counters UUtUns16 bitDepth; UUtUns16 platformData; } M3tDisplayMode; - + typedef struct M3tDisplayDevice { M3tPlatformDevice platformDevice; - + UUtUns16 numDisplayModes; M3tDisplayMode displayModes[M3cMaxDisplayModes]; - + } M3tDisplayDevice; - + typedef struct M3tDrawEngineCaps { M3tDrawEngineFlags engineFlags; - + char engineName[M3cMaxNameLen]; char engineDriver[M3cMaxNameLen]; - + UUtUns32 engineVersion; - + UUtUns32 numDisplayDevices; M3tDisplayDevice displayDevices[M3cMaxDisplayDevices]; - + void* enginePrivate; - + } M3tDrawEngineCaps; - + /* * Geom engine cap list structure */ typedef enum M3tGeomEngineFlags { M3tGeomEngineFlag_None = 0 - + } M3tGeomEngineFlags; - + typedef struct M3tGeomEngineCaps { M3tGeomEngineFlags engineFlags; - + char engineName[M3cMaxNameLen]; char engineDriver[M3cMaxNameLen]; - + UUtUns32 engineVersion; UUtUns32 compatibleDrawEngineBV; - + } M3tGeomEngineCaps; - + /* * Data structures for creating contexts */ @@ -1183,39 +1183,39 @@ typedef struct M3tDrawContext_Counters { M3cDrawContextType_OffScreen, M3cDrawContextType_OnScreen - + } M3tDrawContextType; - - + + typedef struct M3tDrawContextDescriptorOffScreen { UUtUns16 inWidth; UUtUns16 inHeight; - + void* outBaseAddr; /* This is returned by the engine */ UUtUns32 outRowBytes; /* This is returned by the engine */ - + } M3tDrawContextDescriptorOffScreen; - + typedef struct M3tDrawContextDescriptorOnScreen { UUtAppInstance appInstance; UUtWindow window; // Must live on the active device UUtRect rect; // Must live on the active device - + } M3tDrawContextDescriptorOnScreen; - + typedef struct M3tDrawContextDescriptor { M3tDrawContextType type; - + union { M3tDrawContextDescriptorOffScreen offScreen; M3tDrawContextDescriptorOnScreen onScreen; - + } drawContext; - + } M3tDrawContextDescriptor; /* @@ -1225,51 +1225,51 @@ typedef struct M3tDrawContext_Counters { M3tTri vertexIndices; M3tTri baseUVIndices; - UUtUns32 shades[3]; + UUtUns32 shades[3]; } M3tTriSplit; - + typedef tm_struct M3tQuadSplit { M3tQuad vertexIndices; M3tQuad baseUVIndices; - UUtUns32 shades[4]; + UUtUns32 shades[4]; } M3tQuadSplit; - + typedef struct M3tPentSplit { M3tPent vertexIndices; M3tPent baseUVIndices; - UUtUns32 shades[5]; + UUtUns32 shades[5]; } M3tPentSplit; - - + + /* * Real function prototypes for the draw engine interface */ - + /* * Engine caps and display mode stuff */ UUtError M3rDrawEngine_FindGrayscalePixelType( IMtPixelType *outTextureFormat); - + UUtUns16 M3rDrawEngine_GetNumber( void); - + M3tDrawEngineCaps* M3rDrawEngine_GetCaps( UUtUns16 inDrawEngineIndex); - + UUtUns16 M3rGeomEngine_GetNumber( void); - + M3tGeomEngineCaps* M3rGeomEngine_GetCaps( UUtUns16 inGeomEngineIndex); - + /* * Specify the active engine, display device, and mode */ @@ -1279,41 +1279,41 @@ typedef struct M3tDrawContext_Counters UUtUns16 inDisplayDeviceIndex, // The display to use UUtBool inFullScreen, UUtUns16 inDisplayModeIndex); // Only relevent for full screen mode - + UUtError M3rDrawEngine_GetActiveDeviceRect( UUtRect *outDeviceRect); - + /* * Draw Context functions, use these ONLY if you are using the rasterizer directly */ - - UUtError + + UUtError M3rDrawContext_New( M3tDrawContextDescriptor* inDrawContextDescriptor); - + void M3rDrawContext_Delete( void); - + /* * Draw Context texture stuff */ void M3rDrawContext_ResetTextures( void); - + /* * Real function prototypes for the geom engine interface */ - + /* * Service query functions */ UUtUns16 M3rGeomEngine_GetNumber( void); - + M3tGeomEngineCaps* M3rGeomEngine_GetCaps( UUtUns16 inGeomEngineIndex); @@ -1321,20 +1321,20 @@ typedef struct M3tDrawContext_Counters UUtError M3rGeomEngine_MakeActive( UUtUns16 inGeomEngineIndex); - + /* * Geom Context functions */ - - UUtError + + UUtError M3rGeomContext_New( M3tDrawContextDescriptor* inDrawContextDescriptor); - + struct AKtEnvironment; UUtError M3rGeomContext_SetEnvironment( struct AKtEnvironment* inEnvironment); - + void M3rGeomContext_Delete( void); @@ -1358,19 +1358,19 @@ typedef struct M3tDrawContext_Counters /* * typedefs for draw engine functions */ - + /* * Frame functions - */ - UUtError + */ + UUtError M3rDraw_Frame_Start( UUtUns32 inGameTime); - - UUtError + + UUtError M3rDraw_Frame_End( void); - UUtError + UUtError M3rDraw_Frame_Sync( void); @@ -1382,17 +1382,17 @@ typedef struct M3tDrawContext_Counters void M3rDraw_Texture_EnsureLoaded(M3tTextureMap *texture_map); // GME UUtBool M3rDraw_Texture_Load(M3tTextureMap *texture_map); // S.S. UUtBool M3rDraw_Texture_Unload(M3tTextureMap *texture_map); // S.S. - + /* * Bitmap drawing */ - extern M3tTextureCoord sprite_uv[4]; + extern M3tTextureCoord sprite_uv[4]; void M3rDraw_TriSprite( const M3tPointScreen *inPoints, // points[3] const M3tTextureCoord *inTextureCoords); // UVs[3] - + void M3rDraw_Sprite( const M3tPointScreen *inPoints, // topleft, botright @@ -1414,13 +1414,13 @@ typedef struct M3tDrawContext_Counters UUtInt32 inWidth, UUtInt32 inHeight); - UUtError + UUtError M3rDraw_ScreenCapture( - const UUtRect* inRect, + const UUtRect* inRect, void* outBuffer); - - UUtBool + + UUtBool M3rDraw_PointVisible( const M3tPointScreen *inPoint, float inTolerance); @@ -1431,7 +1431,7 @@ typedef struct M3tDrawContext_Counters M3tPoint2D *inTestOffsets, UUtUns32 inTestOffsetCount ); - UUtBool + UUtBool M3rDraw_SupportPointVisible( void); @@ -1446,52 +1446,52 @@ typedef struct M3tDrawContext_Counters /* * Resolution functions */ - + UUtError M3rDraw_SetResolution(M3tDisplayMode mode); - + /* * Draw engine state */ - + UUtUns16 M3rDraw_GetWidth( void); - + UUtUns16 M3rDraw_GetHeight( void); - + void M3rDraw_State_SetInt( M3tDrawStateIntType inDrawStateType, UUtInt32 inDrawState); - + UUtInt32 M3rDraw_State_GetInt( M3tDrawStateIntType inDrawStateType); - + void M3rDraw_State_SetPtr( M3tDrawStatePtrType inDrawStateType, void* inDrawState); - + void* M3rDraw_State_GetPtr( M3tDrawStatePtrType inDrawStateType); - + UUtError M3rDraw_State_Push( void); - + UUtError M3rDraw_State_Pop( void); - + UUtError M3rDraw_State_Commit( void); - + const M3tDrawContext_Counters* M3rDraw_Counters_Get( void); @@ -1499,30 +1499,30 @@ typedef struct M3tDrawContext_Counters /* * typedefs for geom engine functions */ - + /* * Frame functions - */ - typedef UUtError + */ + typedef UUtError (*M3tGeomContextMethod_Frame_Start)( UUtUns32 inGameTicksElapsed); - - typedef UUtError + + typedef UUtError (*M3tGeomContextMethod_Frame_End)( void); - - UUtError + + UUtError M3rGeom_Frame_Start( UUtUns32 inGameTicksElapsed); - + UUtError M3rGeom_Draw_Environment_Alpha( void); - UUtError + UUtError M3rGeom_Frame_End( void); - + void M3rGeom_Clear_Jello( void); @@ -1536,7 +1536,7 @@ typedef struct M3tDrawContext_Counters UUtUns16 inScreenX, UUtUns16 inScreenY, M3tPoint3D *outWorldZNearPoint); - + /* * Light functions */ @@ -1589,7 +1589,7 @@ typedef struct M3tDrawContext_Counters M3tMatrix3x3* inOrientation, float inXOffset, float inXShorten, - float inXChop); + float inXChop); UUtError M3rSprite_Draw( @@ -1604,7 +1604,7 @@ typedef struct M3tDrawContext_Counters M3tMatrix3x3* inOrientation, float inXOffset, float inXShorten, - float inXChop); + float inXChop); UUtError M3rSimpleSprite_Draw( @@ -1613,7 +1613,7 @@ typedef struct M3tDrawContext_Counters float horizSize, float vertSize, UUtUns32 inShade, - UUtUns16 inAlpha); + UUtUns16 inAlpha); typedef UUtError (*M3tGeomContextMethod_SpriteArray_Draw)( @@ -1635,7 +1635,7 @@ typedef struct M3tDrawContext_Counters float inV0, float inV1, M3tContrailData* inPoint0, - M3tContrailData* inPoint1); + M3tContrailData* inPoint1); UUtError M3rContrail_Draw( @@ -1643,7 +1643,7 @@ typedef struct M3tDrawContext_Counters float inV0, float inV1, M3tContrailData* inPoint0, - M3tContrailData* inPoint1); + M3tContrailData* inPoint1); /* @@ -1656,36 +1656,36 @@ typedef struct M3tDrawContext_Counters typedef UUtError (*M3tGeomContextMethod_Geometry_Draw)( - M3tGeometry* inGeometryObject); - + M3tGeometry* inGeometryObject); + UUtError M3rGeometry_Draw( - M3tGeometry* inGeometryObject); + M3tGeometry* inGeometryObject); - void + void M3rGeometry_MultiplyAndDraw( M3tGeometry *inGeometryObject, const M3tMatrix4x3 *inMatrix); - + /* * Environment rendering */ typedef UUtError (*M3tGeomContextMethod_Env_SetCamera)( M3tGeomCamera* inCamera); // If null use active camera in geom context - + typedef UUtError (*M3tGeomContextMethod_Env_DrawGQList)( UUtUns32 inNumGQs, UUtUns32* inGQIndices, UUtBool inTransparentList); - + UUtError M3rEnv_DrawGQList( UUtUns32 inNumGQs, UUtUns32* inGQIndices); - + /* * polys, points and lines @@ -1695,13 +1695,13 @@ typedef struct M3tDrawContext_Counters UUtUns32 inNumPoints, M3tPoint3D* inPoints, UUtUns32 inShade); - + typedef UUtError (*M3tGeomContextMethod_Geometry_LineDraw)( UUtUns32 inNumPoints, M3tPoint3D* inPoints, UUtUns32 inShade); - + typedef UUtError (*M3tGeomContextMethod_Geometry_PointDraw)( UUtUns32 inNumPoints, @@ -1712,7 +1712,7 @@ typedef struct M3tDrawContext_Counters (*M3tGeomContextMethod_PointVisible)( M3tPoint3D* inPoint, float inTolerance); - + void M3rGeom_Draw_DebugSphere( M3tPoint3D * inPoint, @@ -1729,7 +1729,7 @@ typedef struct M3tDrawContext_Counters M3tPoint3D* inPoint, M3tPoint2D* inTestOffsets, UUtUns32 inTestOffsetCount ); - + float M3rPointVisibleScale( M3tPoint3D* inPoint, @@ -1757,7 +1757,7 @@ typedef struct M3tDrawContext_Counters UUtUns16 inAlpha); UUtError - M3rDecal_Draw( + M3rDecal_Draw( M3tDecalHeader* inDecal, UUtUns16 inAlpha); @@ -1767,58 +1767,58 @@ typedef struct M3tDrawContext_Counters UUtError M3rCamera_New( M3tGeomCamera* *outNewCamera); - + void M3rCamera_Delete( M3tGeomCamera* inCamera); - + void M3rCamera_SetActive( M3tGeomCamera* inCamera); - + UUtError M3rCamera_GetActive( M3tGeomCamera* *outCamera); - - void + + void M3rCamera_SetStaticData( M3tGeomCamera* inCamera, float inFOVy, float inAspect, float inZNear, float inZFar); - - void + + void M3rCamera_SetViewData( M3tGeomCamera* inCamera, M3tPoint3D* inCameraLocation, M3tVector3D* inViewDirection, M3tVector3D* inUpDirection); - void + void M3rCamera_GetStaticData( M3tGeomCamera* inCamera, float *outFOVy, float *outAspect, float *outZNear, float *outZFar); - - void + + void M3rCamera_GetViewData( M3tGeomCamera* inCamera, M3tPoint3D *outCameraLocation, M3tVector3D *outViewDirection, M3tVector3D *outUpDirection); - + void M3rCamera_GetViewData_VxU( M3tGeomCamera* inCamera, M3tVector3D *outViewXUp); - + /* - + outPointList mapping - + index x y z 0 left up near 1 right up near @@ -1828,9 +1828,9 @@ typedef struct M3tDrawContext_Counters 5 right up far 6 left down far 7 right down far - + outPlaneEquList mapping - + index facing 0 perp to zNear plane(toward camera) 1 right side @@ -1838,15 +1838,15 @@ typedef struct M3tDrawContext_Counters 3 bottom side 4 top side 5 perp to zFar plane(away from camera) - + */ - void + void M3rCamera_GetWorldFrustum( M3tGeomCamera* inCamera, M3tPoint3D *outPointList, M3tPlaneEquation *outPlaneEquList); - void + void M3rCamera_DrawWorldFrustum( M3tGeomCamera* inCamera); @@ -1871,8 +1871,8 @@ typedef struct M3tDrawContext_Counters M3tTextureCoord texture_coords[M3cMaxSkyboxVerts]; } M3tSkyboxData; - UUtError - M3rDraw_Skybox( + UUtError + M3rDraw_Skybox( M3tSkyboxData *inSkybox ); UUtError @@ -1884,7 +1884,7 @@ typedef struct M3tDrawContext_Counters M3rDraw_DestroySkybox( M3tSkyboxData *inSkybox ); - typedef UUtError + typedef UUtError (*M3tGeomContextMethod_Skybox_Draw)( M3tSkyboxData *inSkybox ); @@ -1908,31 +1908,31 @@ typedef struct M3tDrawContext_Counters UUtError M3rMatrixStack_Get( M3tMatrix4x3* *outMatrix); - + UUtError M3rMatrixStack_Pop( void); - + void M3rMatrixStack_Identity( void); - - void + + void M3rMatrixStack_Clear( void); - void + void M3rMatrixStack_Rotate( float inRadians, float inX, float inY, float inZ); - + void M3rMatrixStack_UniformScale( float inScale); - - void + + void M3rMatrixStack_Translate( float inX, float inY, @@ -1941,7 +1941,7 @@ typedef struct M3tDrawContext_Counters void M3rMatrixStack_Quaternion( const M3tQuaternion* inQuaternion); - + void M3rMatrixStack_Multiply( const M3tMatrix4x3* inMatrix); @@ -1949,7 +1949,7 @@ typedef struct M3tDrawContext_Counters /* * macros for accessing the function pointers */ - + /* macros for geom engines */ #define M3rMatrixStack_RotateXAxis(radians) \ M3rMatrixStack_Rotate(radians, 1.0f, 0.0f, 0.0f) @@ -1977,22 +1977,22 @@ typedef struct M3tDrawContext_Counters #define M3rLightList_Point(numLights, inLightList) \ (M3gGeomContext)->lightListPoint(numLights, inLightList) - + #define M3rLightList_Cone(numLights, inLightList) \ (M3gGeomContext)->lightListCone(numLights, inLightList) - + #define M3rGeometry_Draw_BoundingBox(rgb55, geometryObject) \ (M3gGeomContext)->geometryBoundingBoxDraw(rgb55, geometryObject) - + #define M3rEnv_SetCamera(inCamera) \ (M3gGeomContext)->envSetCamera(inCamera) - + #define M3rGeometry_PolyDraw(inNumPoints, inPoints, inShade) \ (M3gGeomContext)->geometryPolyDraw(inNumPoints, inPoints, inShade) - + #define M3rGeometry_LineDraw(inNumPoints, inPoints, inShade) \ (M3gGeomContext)->geometryLineDraw(inNumPoints, inPoints, inShade) - + #define M3rGeometry_PointDraw(inNumPoints, inPoints, inShade) \ (M3gGeomContext)->geometryPointDraw(inNumPoints, inPoints, inShade) @@ -2004,22 +2004,22 @@ typedef struct M3tDrawContext_Counters { M3tGeomContextMethod_Frame_Start frameStart; M3tGeomContextMethod_Frame_End frameEnd; - + M3tGeomContextMethod_Pick_ScreenToWorld pickScreenToWorld; M3tGeomContextMethod_LightList_Ambient lightListAmbient; M3tGeomContextMethod_LightList_Directional lightListDirectional; - M3tGeomContextMethod_LightList_Point lightListPoint; + M3tGeomContextMethod_LightList_Point lightListPoint; M3tGeomContextMethod_LightList_Cone lightListCone; - + M3tGeomContextMethod_Geometry_BoundingBox_Draw geometryBoundingBoxDraw; M3tGeomContextMethod_Geometry_PolyDraw geometryPolyDraw; M3tGeomContextMethod_Geometry_LineDraw geometryLineDraw; M3tGeomContextMethod_Geometry_PointDraw geometryPointDraw; - + M3tGeomContextMethod_Env_SetCamera envSetCamera; M3tGeomContextMethod_Env_DrawGQList envDrawGQList; - + M3tGeomContextMethod_Sprite_Draw spriteDraw; M3tGeomContextMethod_Contrail_Draw contrailDraw; M3tGeomContextMethod_Geometry_Draw geometryDraw; @@ -2033,7 +2033,7 @@ typedef struct M3tDrawContext_Counters M3tGeomContextMethod_PointVisible pointVisible; M3tGeomContextMethod_PointVisibleScale pointVisibleScale; - + } M3tGeomContextMethods; @@ -2113,8 +2113,8 @@ M3rTerminate( */ void M3rGeom_Line_Light( - const M3tPoint3D *point1, - const M3tPoint3D *point2, + const M3tPoint3D *point1, + const M3tPoint3D *point2, UUtUns32 shade); void M3rGeom_FaceNormal( @@ -2123,9 +2123,9 @@ void M3rGeom_FaceNormal( const M3tVector3D *inFaceNormals, UUtUns32 inShade); -/* +/* * BBox routines - */ + */ void M3rGeometry_GetBBox( const M3tGeometry *inGeometry, @@ -2136,7 +2136,7 @@ const M3tQuad *M3rBBox_GetSide( M3tBBoxSide inSide); void M3rMinMaxBBox_To_BBox( - const M3tBoundingBox_MinMax *inBoundingBox, + const M3tBoundingBox_MinMax *inBoundingBox, M3tBoundingBox *outBoundingBox); void M3rMinMaxBBox_Draw_Line( @@ -2150,7 +2150,7 @@ void M3rBVolume_Draw_Line( void M3rBBox_Draw_Line( M3tBoundingBox *inBBox, UUtUns32 inShade); - + void M3rBBox_To_EdgeBBox( M3tBoundingBox *inBoundingBox, M3tBoundingBox_Edge *outBoundingBox); @@ -2190,13 +2190,13 @@ void M3rDisplay_Circle(M3tPoint3D *inCenter, float inRadius, UUtUns32 inShade); void M3rBuildCircle( UUtUns32 inNumPoints, float inHeight, - const M3tBoundingCircle *circle, + const M3tBoundingCircle *circle, M3tPoint3D *outPoints); - + void M3rBoundingCylinder_Draw_Line( const M3tBoundingCylinder *inBoundingCylinder, UUtUns32 inShade); - + void M3rDraw_Bitmap( M3tTextureMap *inBitmap, @@ -2204,9 +2204,9 @@ M3rDraw_Bitmap( UUtUns16 inWidth, UUtUns16 inHeight, UUtUns32 inShade, - UUtUns16 inAlpha); + UUtUns16 inAlpha); -void +void M3rDraw_BitmapUV( M3tTextureMap *inBitmap, const M3tTextureCoord *inUV, @@ -2216,14 +2216,14 @@ M3rDraw_BitmapUV( UUtUns32 inShade, UUtUns16 inAlpha); -void +void M3rDraw_BigBitmap( M3tTextureMap_Big *inBigBitmap, const M3tPointScreen *inDestPoint, UUtUns16 inWidth, UUtUns16 inHeight, UUtUns32 inShade, - UUtUns16 inAlpha); + UUtUns16 inAlpha); void M3rDraw_Commit_Alpha( void); @@ -2236,7 +2236,7 @@ typedef enum { M3cTexture_AllocMemory = (1 << 0), M3cTexture_UseTempMem = (1 << 1) - + } M3tTextureAllocMemory; UUtError @@ -2307,7 +2307,7 @@ M3rTextureMap_Big_New( void M3rTextureMap_Big_Unload(M3tTextureMap_Big *inTextureMap); // GME #define M3cFillEntireMap (NULL) - + UUtError M3rTextureMap_BuildMipMap( IMtScaleMode inScaleMode, @@ -2351,7 +2351,7 @@ M3rTextureMap_Big_Fill( MAtMaterialType M3rTextureMap_GetMaterialType( const M3tTextureMap *inTextureMap); - + void M3rTextureMap_SetMaterialType( M3tTextureMap *ioTextureMap, @@ -2364,7 +2364,7 @@ M3rTextureRef_GetSize( UUtUns16 *outHeight); /* - * + * */ void M3rTextureCoord_FindMinMax( @@ -2374,7 +2374,7 @@ M3rTextureRef_GetSize( float *outMinV, float *outMaxU, float *outMaxV); - + UUtError M3rGroup_GetColor( GRtGroup* inGroup, @@ -2394,9 +2394,9 @@ void MSrStackVerify_Debug(void); #define MSmMatrix3x3Verify(m) MSrMatrix3x3Verify(m); #define MSmStackVerify() MSrStackVerify_Debug() #else -#define MSmMatrixVerify(m) UUmBlankFunction +#define MSmMatrixVerify(m) UUmBlankFunction #define MSmMatrix3x3Verify(m) UUmBlankFunction -#define MSmStackVerify() UUmBlankFunction +#define MSmStackVerify() UUmBlankFunction #endif diff --git a/BungieFrameWork/BFW_Headers/BFW_NetworkManager.h b/BungieFrameWork/BFW_Headers/BFW_NetworkManager.h index eddac0e..13872df 100644 --- a/BungieFrameWork/BFW_Headers/BFW_NetworkManager.h +++ b/BungieFrameWork/BFW_Headers/BFW_NetworkManager.h @@ -70,9 +70,9 @@ typedef enum NMtServiceType NMcTCP, NMcNetSprocket, NMcDirectPlay, - + NMcNumServiceTypes - + } NMtServiceType; // ---------------------------------------------------------------------- @@ -80,7 +80,7 @@ typedef enum NMtFlags { NMcFlag_None, NMcFlag_Broadcast - + } NMtFlags; // ---------------------------------------------------------------------- @@ -104,11 +104,11 @@ typedef UUtError UUtUns16 inPortNumber, UUtUns8 *inDataBuffer, UUtUns16 inNumBytes); - + typedef UUtError (*NMtNetContextMethod_CloseProtocol)( NMtNetContext *inNetContext); - + typedef UUtBool (*NMtNetContextMethod_CompareAddresses)( NMtNetContext *inNetContext, @@ -149,12 +149,12 @@ typedef UUtError UUtUns8 *inDataBuffer, UUtUns16 inNumBytes, UUtUns16 inFlags); - + // ====================================================================== typedef struct NMtNetServiceCaps { NMtServiceType type; - + } NMtNetServiceCaps; // ---------------------------------------------------------------------- @@ -181,12 +181,12 @@ struct NMtNetContext UUtUns16 port_number; NMtNetContextPrivate *private_data; NMtNetContextMethods methods; - + UUtUns16 num_incoming_buffers; UUtUns16 num_outgoing_buffers; UUtBool out_of_incoming_buffers; - UUtBool out_of_outgoing_buffers; - + UUtBool out_of_outgoing_buffers; + }; // ---------------------------------------------------------------------- @@ -194,7 +194,7 @@ typedef struct NMtNetServices { NMtNetServiceCaps service; NMtNetContextMethods methods; - + } NMtNetServices; // ---------------------------------------------------------------------- @@ -202,7 +202,7 @@ typedef struct NMtPacketHeader { UUtUns32 packet_flags; UUtUns32 packet_data_size; - + } NMtPacketHeader; #define NMcPacketDataSize (NMcMaxNetPacketSize - sizeof(NMtPacketHeader)) @@ -211,7 +211,7 @@ typedef struct NMtPacket { NMtPacketHeader packet_header; UUtUns8 packet_data[NMcPacketDataSize]; - + } NMtPacket; #define NMcPacketSize sizeof(NMtPacket) @@ -222,7 +222,7 @@ typedef struct NMtUDPData UUtUns32 address_length; UUtUns16 buffer_length; UUtUns8 buffer[NMcPacketSize]; - + } NMtUDPData; // ====================================================================== @@ -231,11 +231,11 @@ typedef struct NMtUDPData char* NMrAddressToString( const NMtNetAddress *inNetAddress); - + UUtError NMrInitialize( void); - + void NMrTerminate( void); @@ -252,10 +252,10 @@ NMrNetContext_New( UUtUns16 inPortNumber, NMtFlags inFlags, NMtNetContext **outNetContext); - + UUtError NMrNetContext_Delete( NMtNetContext **inNetContext); // ====================================================================== -#endif /* BFW_NETWORKMANAGER_H */ \ No newline at end of file +#endif /* BFW_NETWORKMANAGER_H */ diff --git a/BungieFrameWork/BFW_Headers/BFW_Object.h b/BungieFrameWork/BFW_Headers/BFW_Object.h index d4d31f5..896b1d5 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Object.h +++ b/BungieFrameWork/BFW_Headers/BFW_Object.h @@ -2,13 +2,13 @@ /* FILE: BFW_Object.h - + AUTHOR: Quinn Dunki, Michael Evans, Kevin Armstrong - + CREATED: 4/8/98 - + PURPOSE: Interface to the Object engine - + Copyright 1998,2000 */ @@ -59,7 +59,7 @@ enum { }; -struct OBtObject; +struct OBtObject; typedef UUtBool (*OBtAllowPauseCallback)(const struct OBtObject *inObject, const struct PHtPhysicsContext *inCollidingCallback); #define OBcObjectNodeCount 32 @@ -72,9 +72,9 @@ typedef struct OBtObject UUtUns32 geometry_count; M3tGeometry *damagedGeometry; - + EPtEnvParticleArray* particleArray; - + UUtUns16 index; UUtUns16 flags; @@ -82,7 +82,7 @@ typedef struct OBtObject UUtUns16 pad; PHtPhysicsContext *physics; // Data for physics engine - + UUtUns32 num_frames_offscreen; IMtShade flat_lighting_shade; void *owner; @@ -102,10 +102,10 @@ typedef tm_struct OBtObjectList { UUtUns16 maxObjects; UUtUns16 numObjects; - + OBtObject object_list[1]; } OBtObjectList; - + UUtError OBrRegisterTemplates(void); UUtBool OBrUpdate(OBtObject *ioObject, UUtBool *deleteMe, UUtInt16 *redoObject); diff --git a/BungieFrameWork/BFW_Headers/BFW_Particle.h b/BungieFrameWork/BFW_Headers/BFW_Particle.h index 938172c..830052c 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Particle.h +++ b/BungieFrameWork/BFW_Headers/BFW_Particle.h @@ -1 +1 @@ -#error obsolete file \ No newline at end of file +#error obsolete file diff --git a/BungieFrameWork/BFW_Headers/BFW_Particle3.h b/BungieFrameWork/BFW_Headers/BFW_Particle3.h index c896042..3a94538 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Particle3.h +++ b/BungieFrameWork/BFW_Headers/BFW_Particle3.h @@ -5,13 +5,13 @@ /* FILE: BFW_Particle3.h - + AUTHOR: Chris Butcher - + CREATED: Feb 02, 2000 - + PURPOSE: definitions for new particle system (iteration 3) - + Copyright 2000 */ @@ -51,7 +51,7 @@ typedef enum P3tDataType P3cDataType_Enum = (256 << 4), P3cDataType_Sound_Ambient = (1 << 13), P3cDataType_Sound_Impulse = (1 << 14) - + } P3tDataType; // P3tEnumType is used in combination with P3cDataType_Enum to store @@ -862,7 +862,7 @@ enum P3tParticleClassFlags { P3cParticleClassFlag_Appearance_ParallelDirRightVector = (7 << P3cParticleClassFlags_SpriteTypeShift), // bits 5-7 P3cParticleClassFlag_Appearance_Geometry = (1 << 8), - + P3cParticleClassFlag_Physics_CollideEnv = (1 << 9), P3cParticleClassFlag_Physics_CollideChar = (1 << 10), @@ -1056,7 +1056,7 @@ extern P3tAttractorSelectorSpec P3gAttractorSelectorTable[P3cAttractorSelector_M // num_variables P3tVariableInfo // num_actions P3tActionInstance // num_emitters P3tEmitter -// +// // a P3tParticleDefinition defines the characteristics and behaviour of a // single class of particles. at load time, a P3tParticleClass is created // that stores this definition and all of the runtime structures as required. @@ -2348,7 +2348,7 @@ typedef struct P3tEffectData { // decals... // ============================================= -typedef enum P3tDecalFlags +typedef enum P3tDecalFlags { P3cDecalFlag_Static = 0x0001, P3cDecalFlag_Manual = 0x0002, @@ -2357,7 +2357,7 @@ typedef enum P3tDecalFlags P3cDecalFlag_FullBright = 0x0010 } P3tDecalFlags; -typedef struct P3tDecalData +typedef struct P3tDecalData { M3tDecalHeader *decal_header; P3tParticleReference particle; @@ -2677,13 +2677,13 @@ static UUcInline float P3rRandom(void) #define P3mSignedRandom() \ (UUrLocalRandom() * (2.0f / (float)UUcMaxUns16) - 1.0f) - + #else static UUcInline float P3mSignedRandom(void) { static const float multiplier = (2.0f / (float)UUcMaxUns16); - return (((float)UUrLocalRandom() * multiplier) - 1.0f); + return (((float)UUrLocalRandom() * multiplier) - 1.0f); } #endif @@ -2762,7 +2762,7 @@ void P3rNotifySkyVisible(UUtBool inVisible); /* * particle interaction with environment */ - + // damage a quad in the environment UUtBool P3iDamageQuad(AKtEnvironment *inEnvironment, UUtUns32 inGQIndex, float inDamage, M3tPoint3D *inBlastCenter, M3tVector3D *inBlastDir, float inBlastRadius, diff --git a/BungieFrameWork/BFW_Headers/BFW_Path.h b/BungieFrameWork/BFW_Headers/BFW_Path.h index 777f06d..8b013a6 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Path.h +++ b/BungieFrameWork/BFW_Headers/BFW_Path.h @@ -1,8 +1,8 @@ /* BFW_Path.h - + This file contains all pathfinding header stuff - + Author: Quinn Dunki, Michael Evans Copyright (c) 1998 Bungie */ @@ -38,7 +38,7 @@ // constants #define PHcWorldCoord_YOffset 0.5f // added to worldspace coordinates so that if they are tested they are guaranteed // not to lie below the room's origin -#define PHcFlatNormal 0.5f // Y component of normal of "flatest" surface we can walk on +#define PHcFlatNormal 0.5f // Y component of normal of "flatest" surface we can walk on #define PHcSquareSize 4.0f // Default size (in units) of 1 grid square #define PHcMaxGridSize 200 // Maximum size of working grid (each dimension) #define PHcComfortDistance 10.0f @@ -83,12 +83,12 @@ extern const char *PHcDebugEventName[]; typedef tm_struct PHtSquare { UUtUns8 weight; // in units -} PHtSquare; +} PHtSquare; typedef tm_struct PHtDynamicSquare { UUtUns8 obstruction; // index into the node's obstruction table, or 0 for none -} PHtDynamicSquare; +} PHtDynamicSquare; typedef tm_struct PHtDebugInfo { @@ -118,7 +118,7 @@ typedef tm_struct PHtRoomData UUtUns32 compressed_grid_size; float squareSize; // Size (in AutoCad units) of one grid square - + M3tPoint3D origin; // Worldspace origin of the node M3tPoint3D antiOrigin; // Opposite corner of the worldspace origin (forms an axis bounding box) UUtInt16 gox; // Offset origin for the grid. Will always be -IMPcGridBuffer @@ -142,25 +142,25 @@ void PHrWaypointFromGunk(AKtEnvironment *inEnv, AKtGQ_General *inQQGeneral, M3tP typedef void (*PHtRasterizationCallback)(UUtInt16 inX, UUtInt16 inY, UUtUns8 inWeight); void PHrBresenhamAA( - UUtInt16 x1, - UUtInt16 y1, - UUtInt16 x2, + UUtInt16 x1, + UUtInt16 y1, + UUtInt16 x2, UUtInt16 y2, - PHtSquare *grid, - UUtUns32 width, - UUtUns32 height, - PHtSquare *fill, + PHtSquare *grid, + UUtUns32 width, + UUtUns32 height, + PHtSquare *fill, PHtSquare *blend, PHtRasterizationCallback callback); void PHrDynamicBresenham2( - UUtInt16 x1, - UUtInt16 y1, - UUtInt16 x2, - UUtInt16 y2, - PHtDynamicSquare *grid, - UUtUns32 inWidth, - UUtUns32 inHeight, + UUtInt16 x1, + UUtInt16 y1, + UUtInt16 x2, + UUtInt16 y2, + PHtDynamicSquare *grid, + UUtUns32 inWidth, + UUtUns32 inHeight, UUtUns8 inObstruction, UUtBool inOverwrite); diff --git a/BungieFrameWork/BFW_Headers/BFW_Physics.h b/BungieFrameWork/BFW_Headers/BFW_Physics.h index b98222d..9c0de22 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Physics.h +++ b/BungieFrameWork/BFW_Headers/BFW_Physics.h @@ -5,13 +5,13 @@ /* FILE: BFW_Physics.h - + AUTHOR: Quinn Dunki - + CREATED: 4/8/98 - + PURPOSE: Physics engine - + Copyright 1998 */ @@ -55,13 +55,13 @@ enum { PHcUpdateFlag_None = 0x0000, PHcUpdateFlag_Position = 0x0001 - + }; typedef enum PHtColliderType { PHcCollider_Env, - PHcCollider_Phy + PHcCollider_Phy } PHtColliderType; typedef enum PHtPhysicsLevel @@ -101,7 +101,7 @@ typedef struct PHtSphereTree typedef struct PHtCollider { PHtColliderType type; - void *data; // * PHcCollider_Env = gq, PHcCollider_Phy, physics context + void *data; // * PHcCollider_Env = gq, PHcCollider_Phy, physics context M3tPlaneEquation plane; // * Plane of collision (computed by called) M3tPoint3D planePoint; // * Point on plane first touched (computed by called) @@ -133,13 +133,13 @@ typedef void PHtPhysicsContext *ioContext, M3tVector3D *inVelocityThisFrame); -typedef void +typedef void (*PHtCallback_ReceiveForce)( PHtPhysicsContext *ioContext, const PHtPhysicsContext *inPushingContext, const M3tVector3D *inForce); -typedef void +typedef void (*PHtCallback_ApplyForce)( PHtPhysicsContext *ioContext, PHtCollider *inCollider); @@ -225,7 +225,7 @@ struct PHtPhysicsContext PHtSphereTree *sphereTree; M3tBoundingBox axisBox; // Must be a M3tBoundingBox M3tBoundingVolume *worldAlignedBounds; // axisBox * matrix - + // Physical data M3tVector3D velocity; M3tQuaternion rotationalVelocity; @@ -245,7 +245,7 @@ struct PHtPhysicsContext // status info M3tVector3D acceleration; - + // Status info UUtUns32 flags; PHtPhysicsLevel level; @@ -325,7 +325,7 @@ UUtBool PHrCollision_Volume_SphereTree( UUtBool PHrCollision_Volume_Ray( const M3tBoundingVolume *inA, - const M3tPoint3D *inPoint, + const M3tPoint3D *inPoint, const M3tVector3D *inV, M3tPlaneEquation *outPlane, // optional M3tPoint3D *outPoint); // optional @@ -353,7 +353,7 @@ void PHrPhysics_Delete( PHtPhysicsContext *ioPhysics); void PHrPhysics_Accelerate( - PHtPhysicsContext *physics, + PHtPhysicsContext *physics, const M3tVector3D *inAcceleration); UUtBool PHrPhysics_Update_Animation( @@ -371,8 +371,8 @@ PHrPhysics_Colliders_GetFromSphere( M3tVector3D* inVector, UUtUns16 *outNumColliders, PHtCollider *outColliders); - + void PHrPhysics_Pause_Animation(OBtAnimationContext *ioAnimContext); void PHrPhysics_Unpause_Animation(OBtAnimationContext *ioAnimContext); -#endif // #define __BFW_PHYSICS_H__ \ No newline at end of file +#endif // #define __BFW_PHYSICS_H__ diff --git a/BungieFrameWork/BFW_Headers/BFW_Platform_AltiVec.h b/BungieFrameWork/BFW_Headers/BFW_Platform_AltiVec.h index 6d45646..c53fb41 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Platform_AltiVec.h +++ b/BungieFrameWork/BFW_Headers/BFW_Platform_AltiVec.h @@ -1,12 +1,12 @@ /* FILE: BFW_Platform_AltiVec.h - + AUTHOR: Brent H. Pease - + CREATED: Aug 6, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997-1999 */ diff --git a/BungieFrameWork/BFW_Headers/BFW_Ranma.h b/BungieFrameWork/BFW_Headers/BFW_Ranma.h index 8792945..2629d95 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Ranma.h +++ b/BungieFrameWork/BFW_Headers/BFW_Ranma.h @@ -2,13 +2,13 @@ /* FILE: BFW_Ranma.h - + AUTHOR: Michael Evans - + CREATED: Sept 18, 1998 PURPOSE: hierirchical rigid body dynamics engine - + Copyright 1998 */ @@ -17,4 +17,4 @@ #ifndef BFW_RANMA_H #define BFW_RANMA_H -#endif \ No newline at end of file +#endif diff --git a/BungieFrameWork/BFW_Headers/BFW_RedPig.h b/BungieFrameWork/BFW_Headers/BFW_RedPig.h index 2dc01f6..aff3304 100644 --- a/BungieFrameWork/BFW_Headers/BFW_RedPig.h +++ b/BungieFrameWork/BFW_Headers/BFW_RedPig.h @@ -1 +1 @@ -#error "BFW_RedPig is obsolete" \ No newline at end of file +#error "BFW_RedPig is obsolete" diff --git a/BungieFrameWork/BFW_Headers/BFW_ScriptLang.h b/BungieFrameWork/BFW_Headers/BFW_ScriptLang.h index 827de82..3cdf89c 100644 --- a/BungieFrameWork/BFW_Headers/BFW_ScriptLang.h +++ b/BungieFrameWork/BFW_Headers/BFW_ScriptLang.h @@ -1,26 +1,26 @@ #pragma once /* FILE: BFW_ScriptLang.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + This module is designed to let a game designer write simple game logic that - can communicate with the core game engine. - + can communicate with the core game engine. + Features: - + 1) different parts of the core engine can register commands to make them available to the game designers. An example of this is a command to initiate a particle effect or to tell a character to start moving. - + 2) different parts of the engine can register global variables to make them available to the game designers. An example of this is the current game time or the number of civilians killed. - + 3) A simple interpreted language to describe game logic - functions - global/local variables @@ -28,28 +28,28 @@ - if then else statements - iterators - etc - + 4) An event scheduling system. Functions can be scheduled to be called periodically. For an example a function can be scheduled every 60 game ticks to check for mission success or failure conditions. - + 5) Engine can check the value of global vars declared within a script - + 6) scripts can sleep for a specified amount of time - + 7) Game designers can modify the scripts while still in the engine. - + Uses: 1) Code level logic such as keeping track of number of civilians killed. - + 2) Glue different parts of the system together. When particles hit something (either wall or character) then can execute a script that can change some other part of the system. When a trigger volume is hit a script can be executed to issue orders to the AI system. - + 3) Implement multiplayer game logic. Score can be kept track with the script system for an any type of multiplayer game that we come up with. - + Copyright 1999 */ @@ -70,7 +70,7 @@ typedef enum SLtReadWrite { SLcReadWrite_ReadOnly, SLcReadWrite_ReadWrite - + } SLtReadWrite; typedef enum SLtType @@ -81,7 +81,7 @@ typedef enum SLtType SLcType_Bool = 3, SLcType_Void = 4, // used to signal no return value SLcType_Max = 5 - + } SLtType; extern const char *SLcTypeName[]; @@ -101,21 +101,21 @@ typedef union SLtValue UUtUns32 b; #else UUtBool b; -#endif +#endif } SLtValue; typedef struct SLtParameter_Actual { SLtType type; SLtValue val; - + } SLtParameter_Actual; typedef struct SLtParameter_Formal { const char* name; SLtType type; - + } SLtParameter_Formal; typedef struct SLtErrorContext @@ -123,7 +123,7 @@ typedef struct SLtErrorContext const char* funcName; const char* fileName; UUtUns16 line; - + } SLtErrorContext; typedef UUtError @@ -197,7 +197,7 @@ typedef struct SLtRegisterVoidFunctionTable SLtEngineCommand function; } SLtRegisterVoidFunctionTable; -UUtError +UUtError SLrScript_CommandTable_Register_Void(SLtRegisterVoidFunctionTable *inTable); UUtError @@ -279,7 +279,7 @@ UUtError SLrGlobalVariable_Register_String_Table(SLtRegisterStringTable *inTable * These are used by the engine to execute commands in the scripting engine */ -UUtError +UUtError SLrScript_Schedule( const char* inName, UUtUns16 inParameterListLength, @@ -289,7 +289,7 @@ SLrScript_Schedule( UUtUns32 inNumberOfTimes, // if 0 script executes every game tick(not recommended) SLtContext ** ioReferencePtr); // used for getting a reference to track currently-running scripts -UUtError +UUtError SLrScript_ExecuteOnce( const char* inName, UUtUns16 inParameterListLength, @@ -318,7 +318,7 @@ SLrScheduler_ForceDelete( * * These are used to add functions and variables defined in text files */ - + void SLrScript_Database_Reset( void); @@ -329,7 +329,7 @@ SLrScript_Database_Add( const char* inText); /* - * + * */ void diff --git a/BungieFrameWork/BFW_Headers/BFW_SoundSystem2.h b/BungieFrameWork/BFW_Headers/BFW_SoundSystem2.h index 3f65bd7..98e4502 100644 --- a/BungieFrameWork/BFW_Headers/BFW_SoundSystem2.h +++ b/BungieFrameWork/BFW_Headers/BFW_SoundSystem2.h @@ -43,7 +43,7 @@ typedef enum SStPriority2 SScPriority2_Normal, SScPriority2_High, SScPriority2_Highest - + } SStPriority2; // ---------------------------------------------------------------------- @@ -52,7 +52,7 @@ enum { SScWaveFormat_PCM = 0x0001, SScWaveFormat_ADPCM = 0x0002 - + }; // ---------------------------------------------------------------------- @@ -61,9 +61,9 @@ enum SScSoundDataFlag_None = 0x0000, SScSoundDataFlag_Compressed = 0x0001, // this sound is compressed SScSoundDataFlag_Stereo = 0x0002, - + SScSoundDataFlag_DynamicAlloc = 0x8000 /* SStSoundData was dynamically allocated */ - + }; // ---------------------------------------------------------------------- @@ -73,7 +73,7 @@ enum SScAmbientFlag_InterruptOnStop = 0x0001, // playing tracks are interrupted when stopped SScAmbientFlag_PlayOnce = 0x0002, // the base tracks are only played one time SScAmbientFlag_Pan = 0x0004 // the ambient sound can be panned - + }; // ---------------------------------------------------------------------- @@ -82,7 +82,7 @@ typedef enum SStType SScType_Ambient, SScType_Group, SScType_Impulse - + } SStType; // ---------------------------------------------------------------------- @@ -90,7 +90,7 @@ enum { SScGroupFlag_None = 0x0000, SScGroupFlag_PreventRepeats = 0x0001, - + SScGroupFlag_WriteMask = 0x000F }; @@ -107,7 +107,7 @@ SStSubtitle tm_varindex UUtUns32 numSubtitles; tm_vararray UUtUns32 subtitles[1]; - + } SStSubtitle; // ---------------------------------------------------------------------- @@ -119,7 +119,7 @@ typedef tm_struct SStADPCMCOEFSET { UUtInt16 iCoef1; UUtInt16 iCoef2; - + } SStADPCMCOEFSET; typedef tm_struct SStFormat @@ -131,11 +131,11 @@ typedef tm_struct SStFormat UUtUns16 nBlockAlign; UUtUns16 wBitsPerSample; UUtUns16 cbSize; - + UUtUns16 wSamplesPerBlock; UUtUns16 wNumCoef; SStADPCMCOEFSET aCoef[7]; - + } SStFormat; #if UUmPlatform == UUmPlatform_Win32 @@ -149,10 +149,10 @@ typedef struct WAVEFORMAT_EX_ADPCM UUtUns16 nBlockAlign; UUtUns16 wBitsPerSample; UUtUns16 cbSize; - + UUtUns16 wSamplesPerBlock; UUtUns16 wNumCoef; - SStADPCMCOEFSET aCoef[7]; + SStADPCMCOEFSET aCoef[7]; } WAVEFORMAT_EX_ADPCM; extern WAVEFORMAT_EX_ADPCM SSgWaveFormat_Mono; @@ -169,14 +169,14 @@ typedef tm_template('S', 'N', 'D', 'D', "Sound Data") SStSoundData { UUtUns32 flags; - + //SStFormat f; UUtUns16 duration_ticks; UUtUns16 pad; - + UUtUns32 num_bytes; tm_raw(void*) data; - + } SStSoundData; static UUcInline UUtBool SSrSound_IsStereo(SStSoundData *inSoundData) @@ -197,31 +197,31 @@ static UUcInline UUtUns32 SSrSound_GetNumChannels(SStSoundData *inSoundData) typedef struct SStPermutation { UUtUns32 weight; - + float min_volume_percent; // the minimum percent from max volume (ex: 0.0) float max_volume_percent; // the maximum percent from max volume (ex: 1.0) - + float min_pitch_percent; // the minimum percent from normal pitch (ex: 0.7) float max_pitch_percent; // the maximum percent from normal pitch (ex: 1.2) - + SStSoundData *sound_data; char sound_data_name[SScMaxNameLength]; - + } SStPermutation; typedef struct SStGroup { char group_name[SScMaxNameLength]; - + float group_volume; float group_pitch; - + UUtUns16 flags; UUtUns16 flag_data; - + UUtUns32 num_channels; UUtMemory_Array *permutations; - + } SStGroup; // ---------------------------------------------------------------------- @@ -230,55 +230,55 @@ typedef struct SStGroup Ambient Sounds, and Spatial Ambient Sounds. Game State Music and Environmental Ambient Sounds behave exactly the same, they are just used in different ways. - + Ambient Sounds have a detail track and two base tracks. - + The in sound, out sound, and base track 1 must all be mono or must all be stereo. - + The permutation from the detail track will be played at a time between the min and max detail times. - + If a position is provided for the sound, it will be played as a Spatial Ambient Sound. The min and max volume distance will be used to set the maximum volume for all of the tracks. The detail track will be placed at the provided position. - + If no position is provided, only the detail track uses the minimum and maximum volume distance. The detail track will be positioned randomly within the sphere radius. The sphere radius cannot exceed the size of the minimum volume distance. - + Dialog uses base track 1. The in sound, out sound, base track 2 and the detail sound can be used, but only base track 1 is actually used. */ typedef struct SStAmbient { char ambient_name[SScMaxNameLength]; - + SStPriority2 priority; // priority of the group UUtUns32 flags; // flags for how the ambient functions - + float sphere_radius; // radius of sphere at the sound's location. - // Sound are randomly positioned within the sphere. - + // Sound are randomly positioned within the sphere. + float min_detail_time; // minimum amount of time that must pass before a // detail sound is played float max_detail_time; // maximum amount of time that can pass before a // detail sound is played - + float max_volume_distance; // distance at which the maximum volume is heard float min_volume_distance; // distance at which the minimum volume is heard - + UUtUns32 threshold; // maximimum number of this ambient which can be playing at a time float min_occlusion; // minimum occlusion percentage - + SStGroup *detail; // group of sounds to be played as hilites SStGroup *base_track1; // group of sounds to be played in a loop SStGroup *base_track2; // group of sounds to be played in a loop SStGroup *in_sound; // sound played at the beginning of the ambient sound SStGroup *out_sound; // sound played at the end of the ambient sound - + char detail_name[SScMaxNameLength]; char base_track1_name[SScMaxNameLength]; char base_track2_name[SScMaxNameLength]; @@ -286,36 +286,36 @@ typedef struct SStAmbient char out_sound_name[SScMaxNameLength]; const char *subtitle; // subtitle associated with this ambient sound - + } SStAmbient; // ---------------------------------------------------------------------- -// Impulse sounds are meant to be used for sounds that have a distinct +// Impulse sounds are meant to be used for sounds that have a distinct // position in the world. They do not loop. typedef struct SStImpulse { char impulse_name[SScMaxNameLength]; - + SStGroup *impulse_group; // group of impulse sounds char impulse_group_name[SScMaxNameLength]; - + SStPriority2 priority; // priority of the group - + float max_volume_distance; // distance at which the maximum volume is heard float min_volume_distance; // distance at which the minimum volume is heard - + float max_volume_angle; // angle at which the maximum volume is heard float min_volume_angle; // angle at which the minimum volume is heard float min_angle_attenuation; // ammount of attenuation at min_volume_angle - + UUtUns32 alt_threshold; // max number of the SStGroup of this impulse that can be playing at once struct SStImpulse *alt_impulse; // pointer to impulse sound char alt_impulse_name[SScMaxNameLength]; // impulse to play if alt_threshold copies of this impulse are playing - + // this should really live in the impact effects, but it is easier to put it here this late in the project float impact_velocity; // velocity at which an impact plays at full volume float min_occlusion; // minimum occlusion percentage - + } SStImpulse; // ---------------------------------------------------------------------- @@ -364,16 +364,16 @@ extern SStCompressionMode SSgCompressionMode; void SS2rFrame_Start( void); - + void SS2rFrame_End( void); - + // ---------------------------------------------------------------------- void SSrDetails_SetCanPlay( UUtBool inCanPlay); - + UUtError SSrGetSoundDirectory( BFtFileRef **outDirectoryRef); @@ -394,15 +394,15 @@ SS2rEnabled( void SSrLevel_Begin( void); - + void SSrPlayingChannels_Pause( void); - + void SSrPlayingChannels_Resume( void); - + UUtError SS2rRegisterTemplates( void); @@ -410,7 +410,7 @@ SS2rRegisterTemplates( void SSrStopAll( void); - + void UUcExternal_Call SS2rTerminate( void); @@ -426,11 +426,11 @@ SS2rUpdate( float SS2rVolume_Get( void); - + float SS2rVolume_Set( float inVolume); - + void SS2rInstallPointerHandlers( SStImpulsePointerHandler inImpulseHandler, @@ -440,7 +440,7 @@ SS2rInstallPointerHandlers( void SSrShowDebugInfo( void); - + // ---------------------------------------------------------------------- void SSrListener_SetPosition( @@ -451,12 +451,12 @@ SSrListener_SetPosition( UUtBool SSrAmbient_CheckSoundData( const SStAmbient *inAmbient); - + UUtError SSrAmbient_Copy( const SStAmbient *inSource, SStAmbient *ioDest); - + void SSrAmbient_Delete( const char *inAmbientName, @@ -465,11 +465,11 @@ SSrAmbient_Delete( SStAmbient* SSrAmbient_GetByIndex( UUtUns32 inIndex); - + SStAmbient* SSrAmbient_GetByName( const char *inAmbientName); - + UUtUns32 SSrAmbient_GetNumAmbientSounds( void); @@ -477,27 +477,27 @@ SSrAmbient_GetNumAmbientSounds( const char* SSrAmbient_GetSubtitle( SStAmbient *inAmbient); - + void SSrAmbient_Halt( SStPlayID inPlayID); - + UUtError SSrAmbient_New( const char *inAmbientName, SStAmbient **outAmbient); - + void SSrAmbient_SetPitch( SStPlayID inPlayID, float inPitch); - + void SSrAmbient_SetVolume( SStPlayID inPlayID, float inVolume, float inTime); // seconds - + SStPlayID SSrAmbient_Start( const SStAmbient *inAmbient, @@ -512,7 +512,7 @@ SStPlayID SSrAmbient_Start_Simple( const SStAmbient *inAmbient, const float *inVolume); - + void SSrAmbient_Stop( SStPlayID inPlayID); @@ -529,17 +529,17 @@ void SSrAmbient_UpdateGroupName( const char *inOldGroupName, const char *inNewGroupName); - + void SSrAmbient_UpdateGroupPointers( void); - + // ---------------------------------------------------------------------- UUtError SSrImpulse_Copy( const SStImpulse *inSource, SStImpulse *ioDest); - + void SSrImpulse_Delete( const char *inImpulseName, @@ -552,7 +552,7 @@ SSrImpulse_GetByIndex( SStImpulse* SSrImpulse_GetByName( const char *inImpulseName); - + UUtUns32 SSrImpulse_GetNumImpulseSounds( void); @@ -567,7 +567,7 @@ void SSrImpulse_Play_Simple( const char *inImpulseName, const M3tPoint3D *inPosition); - + void SSrImpulse_Play( SStImpulse *inImpulse, @@ -580,16 +580,16 @@ void SSrImpulse_UpdateGroupName( const char *inOldGroupName, const char *inNewGroupName); - + void SSrImpulse_UpdateGroupPointers( void); - + // ---------------------------------------------------------------------- const char* SSrPermutation_GetName( SStPermutation *inPermutation); - + void SSrPermutation_Play( SStPermutation *inPermutation, @@ -601,29 +601,29 @@ SSrPermutation_Play( UUtBool SSrGroup_CheckSoundData( const SStGroup *inGroup); - + UUtError SSrGroup_Copy( const SStGroup *inSource, SStGroup *ioDest); - + void SSrGroup_Delete( const char *inGroupName, UUtUns32 inUpdatePointers); - + SStGroup* SSrGroup_GetByIndex( UUtUns32 inIndex); - + SStGroup* SSrGroup_GetByName( const char *inGroupName); - + UUtUns32 SSrGroup_GetNumChannels( const SStGroup *inGroup); - + UUtUns32 SSrGroup_GetNumPermutations( const SStGroup *inGroup); @@ -631,35 +631,35 @@ SSrGroup_GetNumPermutations( UUtUns32 SSrGroup_GetNumSoundGroups( void); - + UUtError SSrGroup_New( const char *inGroupName, SStGroup **outGroup); - + void SSrGroup_Permutation_Delete( SStGroup *ioGroup, UUtUns32 inPermIndex); - + SStPermutation* SSrGroup_Permutation_Get( SStGroup *inGroup, UUtUns32 inPermIndex); - + UUtError SSrGroup_Permutation_New( SStGroup *ioGroup, SStSoundData *inSoundData, UUtUns32 *outPermutationIndex); - + void SSrGroup_Play( SStGroup *inGroup, SStSoundChannel *inSoundChannel, /* optional */ const char *inDebugSoundType, const char *inDebugSoundName); - + void SSrGroup_UpdateSoundDataPointers( void); @@ -676,11 +676,11 @@ SSrSoundData_GetByName( void SSrSoundData_GetByName_StartCache(void); void SSrSoundData_GetByName_StopCache(void); - + const char* SSrSoundData_GetName( const SStSoundData *inSoundData); - + UUtError SSrSoundData_Load( BFtFileRef *inFileRef, @@ -709,7 +709,7 @@ SSrTextFile_Write( UUtError SSrListBrokenSounds( BFtFile *inFile); - + // ====================================================================== typedef enum UUtFileEndian { diff --git a/BungieFrameWork/BFW_Headers/BFW_TemplateManager.h b/BungieFrameWork/BFW_Headers/BFW_TemplateManager.h index 5f2d640..ab738e0 100644 --- a/BungieFrameWork/BFW_Headers/BFW_TemplateManager.h +++ b/BungieFrameWork/BFW_Headers/BFW_TemplateManager.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_TemplateManager.h - + AUTHOR: Brent H. Pease - + CREATED: June 8, 1997 - + PURPOSE: Manage templates and instance data - + Copyright 1997 */ @@ -29,25 +29,25 @@ extern "C" { #define TMcMaxLevelNum (128) #define TMcTemplateTag_None UUm4CharToUns32('N', 'O', 'N', 'E') - + #define TMcInstanceName_MaxLength (128) - + #define TMcMaxStringLength (128) - + #define TMcSeparateFileOffset_None ((TMtSeparateFileOffset) 0) /* - * + * */ typedef enum TMtAllowFolding { - TMcFolding_Forbid, + TMcFolding_Forbid, TMcFolding_Allow - + } TMtAllowFolding; /* - * + * */ typedef enum TMtTemplateFlags { @@ -56,17 +56,17 @@ extern "C" { TMcTemplateFlag_Leaf = (1 << 1), TMcTemplateFlag_VarArrayIsLeaf = (1 << 2), TMcTemplateFlag_AllowFolding = (1 << 3) - + } TMtTemplateFlags; /* - * + * */ typedef enum TMtDynamicPool_Type { TMcDynamicPool_Type_Temporary = 2, TMcDynamicPool_Type_Permanent = 3 - + } TMtDynamicPool_Type; @@ -80,9 +80,9 @@ extern "C" { TMcTemplateProcMessage_DisposePreProcess, TMcTemplateProcMessage_Update, TMcTemplateProcMessage_PrepareForUse, - + TMcTemplateProcMessage_Dummy = (1 << 31) - + } TMtTemplateProc_Message; /* @@ -94,9 +94,9 @@ extern "C" { TMcInstancePriority_NotNeeded = 1, TMcInstancePriority_NeededSoon = 2, TMcInstancePriority_NeededNow = 3, - + TMcInstancePriority_Num = 4 - + } TMtInstancePriorities; /* @@ -108,7 +108,7 @@ extern "C" { typedef struct TMtCache_MemoryPool TMtCache_MemoryPool; typedef struct TMtPrivateData TMtPrivateData; - + /* * The typedef for a routine that receives runtime template messages @@ -118,11 +118,11 @@ extern "C" { TMtTemplateProc_Message inMessage, void* inInstancePtr, void* inPrivateData); - + typedef UUtError (*TMtTemplateProc_ByteSwap)( void* inInstancePtr); - + /* * Template definition */ @@ -132,16 +132,16 @@ extern "C" { TMtTemplateTag tag; char* name; UUtUns8* swapCodes; - + TMtTemplateFlags flags; - + UUtUns32 size; // This is the size with a var array length of zero UUtUns32 varArrayElemSize; - + TMtTemplateProc_ByteSwap byteSwapProc; - + UUtUns32 magicCookie; - void *timer; + void *timer; } TMtTemplateDefinition; /* @@ -152,30 +152,30 @@ extern "C" { TMtIndexArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numIndices; tm_vararray UUtUns32 indices[1]; - + } TMtIndexArray; - - + + typedef tm_struct TMtTemplateRef { tm_templateref templateRef; - + } TMtTemplateRef; - + #define TMcTemplate_TemplateRefArray UUm4CharToUns32('T', 'M', 'R', 'A') typedef tm_template('T', 'M', 'R', 'A', "Template Reference Array") TMtTemplateRefArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numRefs; tm_vararray TMtTemplateRef templateRefs[1]; } TMtTemplateRefArray; - + #define TMcTemplate_FloatArray UUm4CharToUns32('T', 'M', 'F', 'A') typedef tm_template('T', 'M', 'F', 'A', "Float Array") TMtFloatArray @@ -183,15 +183,15 @@ extern "C" { tm_pad pad0[22]; tm_varindex UUtUns16 numFloats; - tm_vararray float numbers[1]; - + tm_vararray float numbers[1]; + } TMtFloatArray; #define TMcTemplate_String UUm4CharToUns32('T', 'S', 't', 'r') typedef tm_template('T', 'S', 't', 'r', "String") TMtString { - + char string[128]; // must match TMcMaxStringLength above } TMtString; @@ -202,7 +202,7 @@ extern "C" { tm_pad pad0[22]; tm_varindex UUtUns16 numStrings; - tm_vararray TMtString *string[1]; + tm_vararray TMtString *string[1]; } TMtStringArray; /* @@ -241,7 +241,7 @@ extern "C" { UUtError TMrRegisterTemplates( void); - + /* * This is used to add custom byte swapping for the var array field */ @@ -270,7 +270,7 @@ extern "C" { (*TMtCacheProc_Simple_Unload)( void* inInstanceData, void* inDataPtr); - + typedef void (*TMtCacheProc_MemoryPool_Load)( void* inInstanceData, @@ -280,11 +280,11 @@ extern "C" { (*TMtCacheProc_MemoryPool_Unload)( void* inInstanceData, void* inDataPtr); - + typedef UUtUns32 (*TMtCacheProc_MemoryPool_ComputeSize)( void* inInstanceData); - + UUtError TMrTemplate_Cache_MemoryPool_New( TMtTemplateTag inTemplateTag, @@ -292,16 +292,16 @@ extern "C" { TMtCacheProc_MemoryPool_Load inLoadProc, TMtCacheProc_MemoryPool_Unload inUnloadProc, TMtCache_MemoryPool* *outCache); - + void TMrTemplate_Cache_MemoryPool_Delete( TMtCache_MemoryPool* inCache); - + void* TMrTemplate_Cache_MemoryPool_GetDataPtr( TMtCache_MemoryPool* inCache, void* inInstanceDataPtr); - + /* * Allow the allocation of private data associated with instances of common template */ @@ -311,11 +311,11 @@ extern "C" { UUtUns32 inDataSize, TMtTemplateProc_Handler inProcHandler, TMtPrivateData* *outPrivateData); - + void TMrTemplate_PrivateData_Delete( TMtPrivateData* inPrivateData); - + void* TMrTemplate_PrivateData_GetDataPtr( TMtPrivateData* inPrivateData, @@ -325,13 +325,13 @@ extern "C" { * This is used to load a new level */ - typedef enum + typedef enum { TMcPrivateData_Yes, TMcPrivateData_No - + } TMtAllowPrivateData; - + UUtBool TMrLevel_Exists( UUtUns16 inLevelNumber); @@ -339,12 +339,12 @@ extern "C" { void TMrLevel_Unload( UUtUns16 inLevelNumber); - + UUtError TMrLevel_Load( UUtUns16 inLevelNumber, TMtAllowPrivateData inAllowPrivateData); - + /* * Get a pointer to the requested instance * IN @@ -390,7 +390,7 @@ extern "C" { TMrInstance_GetTagCount( TMtTemplateTag inTemplateTag); - + /* * This is used to create a runtime instance */ diff --git a/BungieFrameWork/BFW_Headers/BFW_TextSystem.h b/BungieFrameWork/BFW_Headers/BFW_TextSystem.h index d0cb99b..3572ccb 100644 --- a/BungieFrameWork/BFW_Headers/BFW_TextSystem.h +++ b/BungieFrameWork/BFW_Headers/BFW_TextSystem.h @@ -48,13 +48,13 @@ enum TSc_HLeft = 0x0001, // Horizontal left justified text TSc_HCenter = 0x0002, // Horizontal centered text TSc_HRight = 0x0004, // Horizontal right justified text - + TSc_VTop = 0x0001, // Vertical top justified text TSc_VCenter = 0x0008, // Vertical centered text TSc_VBottom = 0x0010, // Vertical bottom justified text - + TSc_SingleLine = 0x0020 // Text is drawn on a single line - + }; // ---------------------------------------------------------------------- @@ -63,18 +63,18 @@ typedef tm_enum TStFontStyle TScStyle_Plain = 0, // Plain text TScStyle_Bold = 1, // Bold text TScStyle_Italic = 2, // Italic text - + TScStyle_NumStyles = 3, TScStyle_InUse = TScStyle_NumStyles // used in TSrGetFont() to get the font // in use - + } TStFontStyle; // ====================================================================== // typedefs // ====================================================================== typedef struct TStTextContext TStTextContext; -typedef UUtUns16 TStFormat; +typedef UUtUns16 TStFormat; typedef struct TStStringFormat { @@ -86,7 +86,7 @@ typedef struct TStStringFormat IMtShade colors[TScMaxSegments]; UUtRect bounds[TScMaxSegments]; IMtPoint2D destination[TScMaxSegments]; - + } TStStringFormat; // ---------------------------------------------------------------------- @@ -103,7 +103,7 @@ typedef tm_struct TStGlyph // than the width and height UUtUns32 longs_offset; // offset into longs[] array - + UUtUns32 cell; // pointer to cell -- only used at runtime } TStGlyph; @@ -114,9 +114,9 @@ typedef tm_struct TStGlyph typedef tm_template('T', 'S', 'G', 'A', "Glyph Array") TStGlyphArray { - + TStGlyph glyphs[256]; // array of glyphs - + } TStGlyphArray; // ---------------------------------------------------------------------- @@ -126,10 +126,10 @@ typedef tm_template ('T', 'S', 'F', 'T', "Font") TStFont { tm_pad pad[6]; - + UUtUns16 font_size; // size of this font TStFontStyle font_style; // style of this font - + UUtInt16 ascending_height; // character_height == ascending_height + UUtInt16 descending_height; // descending_height @@ -137,10 +137,10 @@ TStFont UUtInt16 leading_width; // amount to inset from left edge of rectangle TStGlyphArray *glyph_arrays[256]; // array of glyph arrays - + tm_varindex UUtUns32 num_longs; // number of UUtUns32s in the longs[1] tm_vararray UUtUns32 longs[1]; // glyph intensity 8 data - + } TStFont; extern TMtPrivateData *TSgTemplate_Font_PrivateData; @@ -151,7 +151,7 @@ extern TMtPrivateData *TSgTemplate_Font_PrivateData; typedef tm_template('T', 'S', 'F', 'L', "Font Language") TStFontLanguage { - + char breaking_1[64]; // Truncation string char breaking_2[64]; // Characters which cannot be allowed to preceed // a truncation @@ -160,7 +160,7 @@ TStFontLanguage char breaking_4[64]; // Characters which cannot end words (plus all // single-byte characters, minus breaking_3) char breaking_5[64]; // Characters which cannot begin words - + } TStFontLanguage; // ---------------------------------------------------------------------- @@ -170,12 +170,12 @@ typedef tm_template ('T', 'S', 'F', 'F', "Font Family") TStFontFamily { tm_pad pad[16]; - + TStFontLanguage *font_language; // language of the family - + tm_varindex UUtUns32 num_fonts; // the number of fonts in the language tm_vararray TStFont *fonts[1]; // the fonts - + } TStFontFamily; // ---------------------------------------------------------------------- @@ -186,7 +186,7 @@ typedef tm_struct TStFontInfo UUtUns32 font_shade; tm_pad pad[2]; UUtUns16 font_size; - + } TStFontInfo; // ====================================================================== @@ -196,19 +196,19 @@ typedef tm_struct TStFontInfo UUtError TSrInitialize( void); - + UUtError TSrRegisterTemplates( void); - + void TSrTerminate( void); - + UUtError TSrTextureCache_Initialize( void); - + // CB: for debugging only void TSrFont_DisplayCacheTexture( @@ -223,11 +223,11 @@ TSrContext_New( TStFormat inFormat, UUtBool inUseFormatting, TStTextContext **outTextContext); - + void TSrContext_Delete( TStTextContext *inTextContext); - + UUtError TSrContext_DrawFormattedText( const TStTextContext *inTextContext, @@ -235,7 +235,7 @@ TSrContext_DrawFormattedText( UUtInt32 inAlpha, const IMtPoint2D *inOffset, const IMtShade *inOverrideColor); - + UUtError TSrContext_DrawString( const TStTextContext *inTextContext, @@ -243,7 +243,7 @@ TSrContext_DrawString( const char *inString, const UUtRect *inBounds, const IMtPoint2D *inDestination); - + UUtError TSrContext_DrawText( const TStTextContext *inTextContext, @@ -251,7 +251,7 @@ TSrContext_DrawText( UUtInt32 inAlpha, const UUtRect *inBounds, const IMtPoint2D *inDestination); - + struct DCtDrawContext; UUtError @@ -262,7 +262,7 @@ TSrContext_DrawText_DC( const IMtPoint2D *inDestination, const struct DCtDrawContext *inDrawContext, UUtRect *outStringRect); - + UUtError TSrContext_FormatString( const TStTextContext *inTextContext, @@ -270,12 +270,12 @@ TSrContext_FormatString( const UUtRect *inBounds, const IMtPoint2D *inDestination, TStStringFormat *outStringFormat); - + TStFont* TSrContext_GetFont( const TStTextContext *inTextContext, TStFontStyle inStyle); - + UUtError TSrContext_GetStringRect( const TStTextContext *inTextContext, @@ -296,12 +296,12 @@ UUtError TSrContext_SetFormat( TStTextContext *inTextContext, TStFormat inFontFormat); - + UUtError TSrContext_SetFontSize( TStTextContext *ioTextContext, UUtUns16 inSize); - + UUtError TSrContext_SetFontStyle( TStTextContext *inTextContext, @@ -318,7 +318,7 @@ TSrString_AppendChar( char *ioString, const UUtUns16 inKey, const UUtUns16 inMaxCharsInString); - + UUtBool TSrString_DeleteChar( char *ioString, @@ -329,7 +329,7 @@ UUtUns16 TSrString_GetCharacterAtIndex( const char *inString, const UUtUns16 inIndex); - + UUtUns16 TSrString_GetLength( const char *inString); @@ -340,7 +340,7 @@ TSrString_InsertChar( UUtUns16 inInsertBefore, const UUtUns16 inChar, const UUtUns16 inMaxCharsInString); - + // ---------------------------------------------------------------------- UUtError TSrFontFamily_Get( @@ -352,29 +352,29 @@ TSrFontFamily_GetFont( TStFontFamily *inFontFamily, UUtUns16 inSize, TStFontStyle inStyle); - + // ---------------------------------------------------------------------- TStFont* TSrFont_Get( const char *inName, UUtUns16 inSize, TStFontStyle inStyle); - + UUtUns16 TSrFont_GetAscendingHeight( TStFont *inFont); - + void TSrFont_GetCharacterSize( TStFont *inFont, UUtUns16 inCharacter, UUtUns16 *outWidth, UUtUns16 *outHeight); - + UUtUns16 TSrFont_GetLeadingHeight( TStFont *inFont); - + UUtUns16 TSrFont_GetLineHeight( TStFont *inFont); @@ -384,4 +384,4 @@ TSrFont_GetDescendingHeight( TStFont *inFont); // ====================================================================== -#endif /* BFW_TEXTSYSTEM_H */ \ No newline at end of file +#endif /* BFW_TEXTSYSTEM_H */ diff --git a/BungieFrameWork/BFW_Headers/BFW_Timer.h b/BungieFrameWork/BFW_Headers/BFW_Timer.h index d4ffdbc..ea52754 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Timer.h +++ b/BungieFrameWork/BFW_Headers/BFW_Timer.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW.h - + AUTHOR: Michael Evans - + CREATED: January 2, 2000 - + PURPOSE: Timing utilities - + Copyright 2000 */ @@ -34,7 +34,7 @@ double UUrMachineTime_High_To_Seconds(UUtInt64 time); /* * stall timer - * + * */ typedef UUtUns32 UUtStallTimer; @@ -124,7 +124,7 @@ void UUrPerformanceTimer_SetPrefix(char *inPrefix); 11. MUrQuat_Lerp 20. MUrMatrix_Multiply -12. SSiPlatform_UpdateSoundBuffer_MSADPCM +12. SSiPlatform_UpdateSoundBuffer_MSADPCM 16. M3iGeom_TraverseBSP diff --git a/BungieFrameWork/BFW_Headers/BFW_Totoro.h b/BungieFrameWork/BFW_Headers/BFW_Totoro.h index dac774d..3c9e8e6 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Totoro.h +++ b/BungieFrameWork/BFW_Headers/BFW_Totoro.h @@ -2,13 +2,13 @@ /* FILE: BFW_Totoro.h - + AUTHOR: Michael Evans - + CREATED: Sept 25, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997, 1998 */ @@ -34,7 +34,7 @@ typedef struct TRtBodyTextures TRtBodyTextures; typedef struct TRtAnimationCollection TRtAnimationCollection; typedef struct TRtAnimationIdentifier TRtAnimationIdentifier; typedef struct TRtScreenCollection TRtScreenCollection; -typedef struct TRtAnimationCollectionPart TRtAnimationCollectionPart; +typedef struct TRtAnimationCollectionPart TRtAnimationCollectionPart; #define TRcAnimState_None ((TRtAnimState) 0) #define TRcAnimState_Anything ((TRtAnimState) 1) @@ -42,7 +42,7 @@ typedef struct TRtAnimationCollectionPart TRtAnimationCollectionPart; #define TRcAnimType_None ((TRtAnimType) 0) #define TRcAnimType_Anything ((TRtAnimType) 1) -enum +enum { TRcAnimFlag_Prepared, TRcAnimFlag_FirstPublic @@ -63,7 +63,7 @@ enum UUtError TRrInitialize( void); - + void TRrTerminate( void); @@ -169,7 +169,7 @@ typedef UUtInt32 TRtBodySelector; typedef tm_template('T', 'R', 'B', 'S', "Totoro Body Set") TRtBodySet { - + TRtBody *body[5]; } TRtBodySet; @@ -182,7 +182,7 @@ typedef tm_template('T', 'R', 'F', 'T', "Totoro Facing Table") TRtFacingTable { tm_pad pad0[22]; - + tm_varindex UUtUns16 tableSize; tm_vararray float facing[1]; } TRtFacingTable; @@ -276,10 +276,10 @@ typedef tm_struct TRtAttack float knockback; UUtUns32 flags; - UUtUns16 damage; - UUtUns16 firstDamageFrame; + UUtUns16 damage; + UUtUns16 firstDamageFrame; - UUtUns16 lastDamageFrame; + UUtUns16 lastDamageFrame; UUtUns16 damageAnimation; UUtUns16 hitStun; @@ -585,7 +585,7 @@ void TRrBody_DrawMagic( type rules 1. must match inType - + state rules 1. must match inState or have a shortcut from inState @@ -598,17 +598,17 @@ void TRrBody_DrawMagic( */ const TRtAnimation *TRrCollection_Lookup( - const TRtAnimationCollection *inCollection, - TRtAnimType inType, - TRtAnimState inState, + const TRtAnimationCollection *inCollection, + TRtAnimType inType, + TRtAnimState inState, TRtAnimVarient inFlags); -void +void TRrCollection_Lookup_Range( - TRtAnimationCollection *inCollection, - TRtAnimType inType, - TRtAnimState inState, - TRtAnimationCollectionPart **outFirst, + TRtAnimationCollection *inCollection, + TRtAnimType inType, + TRtAnimState inState, + TRtAnimationCollectionPart **outFirst, UUtInt32 *outCount); TRtAnimationCollection *TRrCollection_GetRecursive( @@ -685,5 +685,5 @@ TRtFootstepKind TRrGetFootstep(const TRtAnimation *inAnimation, TRtAnimTime inFr void TRrInstallConsoleVariables(void); - + #endif /* BFW_TOTORO_H */ diff --git a/BungieFrameWork/BFW_Headers/BFW_Types.h b/BungieFrameWork/BFW_Headers/BFW_Types.h index b3f0e47..59bb12d 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Types.h +++ b/BungieFrameWork/BFW_Headers/BFW_Types.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW.h - + AUTHOR: Michael Evans - + CREATED: March 30, 2000 - + PURPOSE: Shared BFW types - + Copyright (c) Bungie Software 2000 */ @@ -19,4 +19,4 @@ typedef struct AKtEnvironment AKtEnvironment; typedef struct AKtGQ_General AKtGQ_General; typedef struct AKtGQ_Render AKtGQ_Render; -#endif // BFW_TYPES_H \ No newline at end of file +#endif // BFW_TYPES_H diff --git a/BungieFrameWork/BFW_Headers/BFW_Util_BSP.h b/BungieFrameWork/BFW_Headers/BFW_Util_BSP.h index c351579..4b34846 100644 --- a/BungieFrameWork/BFW_Headers/BFW_Util_BSP.h +++ b/BungieFrameWork/BFW_Headers/BFW_Util_BSP.h @@ -5,8 +5,8 @@ CREATED: April 2, 1998 - PURPOSE: - + PURPOSE: + Copyright 1997 */ @@ -22,7 +22,7 @@ enum { UUcBSP_Negative = 0, UUcBSP_Positive = 1 - + }; typedef tm_struct UUtBSP_Plane_Node @@ -30,9 +30,9 @@ typedef tm_struct UUtBSP_Plane_Node UUtUns16 planeEquIndex; UUtUns16 posNodeIndex; UUtUns16 negNodeIndex; - + UUtUns16 pad; - + } UUtBSP_Plane_Node; #define UUcTemplate_BSP_Plane UUm4CharToUns32('U', 'B', 'P', 'P') @@ -40,10 +40,10 @@ typedef tm_template('U', 'B', 'P', 'P', "BSP plane node array") UUtBSP_Plane_Node_Array { tm_pad(2); - + tm_varindex UUtUns16 numNodes; tm_vararray UUtBSP_Plane_Node nodes[1]; - + } UUtBSP_Plane_NodeArray; /* @@ -86,6 +86,6 @@ UUrBSP_Plane_System_MakeTemplate( UUtBSP_Plane_System* inSystem, char* inName, UUtBSP_Plane_NodeArray* *outTemplate); - -#endif /* BFW_UTIL_BSP_H */ \ No newline at end of file + +#endif /* BFW_UTIL_BSP_H */ diff --git a/BungieFrameWork/BFW_Headers/BFW_ViewManager.h b/BungieFrameWork/BFW_Headers/BFW_ViewManager.h index 8cc82a3..7336d42 100644 --- a/BungieFrameWork/BFW_Headers/BFW_ViewManager.h +++ b/BungieFrameWork/BFW_Headers/BFW_ViewManager.h @@ -40,23 +40,23 @@ typedef enum VMtMessage { // View Manager Messages VMcMessage_None, - + VMcMessage_Create, VMcMessage_Destroy, - + VMcMessage_Command, VMcMessage_Timer, - + VMcMessage_KeyDown, VMcMessage_KeyUp, - + VMcMessage_MouseMove, VMcMessage_MouseLeave, VMcMessage_LMouseDown, VMcMessage_LMouseUp, VMcMessage_LMouseDblClck, - + VMcMessage_MMouseDown, VMcMessage_MMouseUp, VMcMessage_MMouseDblClck, @@ -64,21 +64,21 @@ typedef enum VMtMessage VMcMessage_RMouseDown, VMcMessage_RMouseUp, VMcMessage_RMouseDblClck, - + VMcMessage_SetFocus, - + VMcMessage_Paint, VMcMessage_Update, - + VMcMessage_GetValue, VMcMessage_SetValue, - + VMcMessage_Location, VMcMessage_Size, - + // Dialog Manager Messages DMcMessage_InitDialog, - + // List Box Messages LBcMessage_AddString, LBcMessage_ReplaceString, @@ -91,31 +91,31 @@ typedef enum VMtMessage LBcMessage_Reset, LBcMessage_SetSelection, LBcMessage_SetLineColor, - + // Scroll Bar Messages SBcMessage_HorizontalScroll, SBcMessage_VerticalScroll, - + // Tab Messages TbcMessage_InitTab - + } VMtMessage; enum { VMcNotify_Click = 1, VMcNotify_DoubleClick = 2, - + RBcNotify_Off = 30, // radio button went off RBcNotify_On = 31, // radio button went on - + LBcNotify_SelectionChanged = 40 // List Box Selection Changed }; enum { VMcViewFlag_None = 0x0000, - + VMcViewFlag_Visible = 0x0001, VMcViewFlag_Enabled = 0x0002, VMcViewFlag_Active = 0x0004, @@ -138,16 +138,16 @@ enum enum { VMcCommonFlag_None = 0x0000, - + VMcCommonFlag_Text_HLeft = 0x0100, VMcCommonFlag_Text_HCenter = 0x0200, VMcCommonFlag_Text_HRight = 0x0400, VMcCommonFlag_Text_VCenter = 0x0800, - + VMcCommonFlag_Text_Small = 0x1000, VMcCommonFlag_Text_Bold = 0x2000, VMcCommonFlag_Text_Italic = 0x4000 - + }; enum @@ -185,7 +185,7 @@ typedef struct VMtViewTimer UUtUns16 timer_id; UUtUns32 timer_frequency; // in ticks UUtUns32 next_update; // in ticks - + } VMtViewTimer; // ---------------------------------------------------------------------- @@ -193,7 +193,7 @@ typedef tm_struct VMtViewRef { tm_templateref view_ref; - + } VMtViewRef; #define VMcTemplate_View UUm4CharToUns32('V', 'M', '_', 'V') @@ -202,20 +202,20 @@ VMtView { // implied 8 bytes here //tm_pad pad[32]; - + UUtUns16 id; UUtUns16 type; UUtUns32 flags; - + IMtPoint2D location; UUtInt16 width; UUtInt16 height; - + tm_templateref view_data; - + tm_varindex UUtUns32 num_child_views; tm_vararray VMtViewRef child_views[1]; - + } VMtView; typedef UUtUns32 @@ -231,7 +231,7 @@ typedef struct VMtView_PrivateData VMtViewCallback callback; VMtViewTimer *timers; UUtUns16 layer; - + } VMtView_PrivateData; // ---------------------------------------------------------------------- @@ -244,13 +244,13 @@ VMtTextureGroup VMcMouseOverTextures, VMcMouseOverToClickedTextures, VMcClickedTextures - + } VMtTextureGroup; typedef tm_struct VMtTexture { tm_templateref texture_ref; - + } VMtTexture; #define VMcTemplate_TextureList UUm4CharToUns32('V', 'M', 'T', 'L') @@ -258,10 +258,10 @@ typedef tm_template('V', 'M', 'T', 'L', "VM Texture List") VMtTextureList { tm_pad pad0[22]; - + tm_varindex UUtUns16 num_textures; tm_vararray VMtTexture textures[1]; - + } VMtTextureList; // ---------------------------------------------------------------------- @@ -284,7 +284,7 @@ enum VMcPart_MiddleRow = VMcPart_LeftMiddle | VMcPart_MiddleMiddle | VMcPart_RightMiddle, VMcPart_BottomRow = VMcPart_LeftBottom | VMcPart_MiddleBottom | VMcPart_RightBottom, VMcPart_All = 0xFFFF - + }; enum @@ -302,11 +302,11 @@ enum typedef tm_template('V', 'M', 'P', 'S', "VM Part Specification") VMtPartSpec { - + IMtPoint2D part_matrix_tl[3][3]; // [column][row] IMtPoint2D part_matrix_br[3][3]; // [column][row] tm_templateref texture; - + } VMtPartSpec; typedef struct VMtPartSpec_PrivateData @@ -318,7 +318,7 @@ typedef struct VMtPartSpec_PrivateData M3tTextureCoord mt[4]; M3tTextureCoord mm[4]; M3tTextureCoord mb[4]; - + M3tTextureCoord rt[4]; M3tTextureCoord rm[4]; M3tTextureCoord rb[4]; @@ -342,12 +342,12 @@ void VMrView_Draw( VMtView *inView, M3tPointScreen *inDestination); - + VMtView* VMrView_GetNextFocusableView( VMtView *inView, VMtView *inCurrentFocus); - + VMtView* VMrView_GetParent( VMtView *inView); @@ -355,30 +355,30 @@ VMrView_GetParent( UUtUns32 VMrView_GetValue( VMtView *inView); - + VMtView* VMrView_GetViewUnderPoint( VMtView *inView, IMtPoint2D *inPoint, UUtUns16 inFlags); - + UUtError VMrView_Load( VMtView *inView, VMtView *inParent); - + void VMrView_PointGlobalToView( const VMtView *inView, const IMtPoint2D *inPoint, IMtPoint2D *outPoint); - + UUtError VMrView_ProcHandler( TMtTemplateProc_Message inMessage, void *inInstancePtr, void* inPrivateData); - + UUtUns32 VMrView_SendMessage( VMtView *inView, @@ -390,43 +390,43 @@ void VMrView_SetActive( VMtView *inView, UUtBool inIsActive); - + void VMrView_SetCallback( VMtView *inView, VMtViewCallback inCallback); - + void VMrView_SetEnabled( VMtView *inView, UUtBool inIsEnabled); - + void VMrView_SetFocus( VMtView *inView, UUtBool inIsFocused); - + void VMrView_SetLocation( VMtView *inView, IMtPoint2D *inLocation); - + void VMrView_SetSize( VMtView *inView, UUtUns16 inWidth, UUtUns16 inHeight); - + void VMrView_SetValue( VMtView *inView, UUtUns32 inValue); - + void VMrView_SetVisible( VMtView *inView, UUtBool inIsVisible); - + UUtError VMrView_Timer_Start( VMtView *inView, @@ -450,10 +450,10 @@ VMrView_Unload( UUtError VMrInitialize( void); - + void VMrTerminate( void); // ====================================================================== -#endif /* BFW_VIEWMANAGER_H */ \ No newline at end of file +#endif /* BFW_VIEWMANAGER_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Akira/Akira_Private.h b/BungieFrameWork/BFW_Source/BFW_Akira/Akira_Private.h index 587c1a1..c712f0e 100644 --- a/BungieFrameWork/BFW_Source/BFW_Akira/Akira_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Akira/Akira_Private.h @@ -2,11 +2,11 @@ FILE: BFW_Akira_Private.h AUTHOR: Brent H. Pease, Chris Butcher, Michael Evans - + CREATED: October 23, 1997 - + PURPOSE: environment engine - + Copyright 1997, 2000 */ @@ -47,7 +47,7 @@ extern UUtPerformanceTimer *AKg_IsBoundingBoxMinMaxVisible_Recursive_Timer; typedef struct AKtRay { float u, v; - + } AKtRay; typedef struct AKtFrame @@ -58,20 +58,20 @@ typedef struct AKtFrame typedef struct AKtEnvironment_Private { - + UUtUns32* gqComputedBackFaceBV; UUtUns32* gqBackFaceBV; UUtUns32* gq2VisibilityVector; UUtUns32* ot2LeafNodeVisibility; - + M3tGeomCamera* geomCamera; - + //UUtUns32* alphaGQVisBV; - + UUtUns32 visGQ_Num; UUtUns32* visGQ_List; UUtUns32 sky_visibility; - + } AKtEnvironment_Private; extern UUtBool gEnvironmentCollision; @@ -137,6 +137,6 @@ AKrRayCastCoefficients_Terminate( UUtError AKrCollision_LevelBegin(AKtEnvironment *inEnvironment); void AKrCollision_LevelEnd(void); - + #endif /* BFW_AKIRA_PRIVATE_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira.c b/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira.c index e065e60..9b47821 100644 --- a/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira.c +++ b/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira.c @@ -1,12 +1,12 @@ /* FILE: BFW_Akira.c - + AUTHOR: Brent H. Pease - + CREATED: October 22, 1997 PURPOSE: environment engine - + Copyright 1997 */ @@ -135,12 +135,12 @@ static UUtError AKrEnvironment_TemplateHandler( TMtTemplateProc_Message inMessage, void* inDataPtr, - void* inPrivateData) + void* inPrivateData) { AKtEnvironment_Private* environmentPrivate = (AKtEnvironment_Private*)inPrivateData; AKtEnvironment* environment = (AKtEnvironment*)inDataPtr; UUtUns32 itr; - + UUmAssert(environmentPrivate != NULL); // debugging code to verify @@ -153,7 +153,7 @@ AKrEnvironment_TemplateHandler( UUmAssert(node->leaf == 0 || node->gqStartIndirectIndex <= environment->octTreeGQIndices->numIndices); } #endif - + switch(inMessage) { case TMcTemplateProcMessage_NewPostProcess: @@ -163,7 +163,7 @@ AKrEnvironment_TemplateHandler( environmentPrivate->ot2LeafNodeVisibility = NULL; environmentPrivate->sky_visibility = 0; break; - + case TMcTemplateProcMessage_Update: if(environmentPrivate->gqComputedBackFaceBV != NULL) { UUrBitVector_Dispose(environmentPrivate->gqComputedBackFaceBV); @@ -182,19 +182,19 @@ AKrEnvironment_TemplateHandler( } UUmAssert(!"WHAT!"); - + /* no break */ - + case TMcTemplateProcMessage_LoadPostProcess: - + environmentPrivate->gqComputedBackFaceBV = UUrBitVector_New(environment->gqGeneralArray->numGQs); environmentPrivate->gqBackFaceBV = UUrBitVector_New(environment->gqGeneralArray->numGQs); - - environmentPrivate->gq2VisibilityVector = UUr2BitVector_Allocate(environment->gqGeneralArray->numGQs); + + environmentPrivate->gq2VisibilityVector = UUr2BitVector_Allocate(environment->gqGeneralArray->numGQs); environmentPrivate->ot2LeafNodeVisibility = UUr2BitVector_Allocate(environment->octTree->leafNodeArray->numNodes); - + environmentPrivate->visGQ_List = UUrMemory_Block_NewClear(sizeof(UUtUns32) * AKcMaxVisibleGQs); if(environmentPrivate->gqComputedBackFaceBV == NULL || @@ -208,7 +208,7 @@ AKrEnvironment_TemplateHandler( UUr2BitVector_Clear(environmentPrivate->gq2VisibilityVector, environment->gqGeneralArray->numGQs); UUr2BitVector_Clear(environmentPrivate->ot2LeafNodeVisibility, environment->octTree->leafNodeArray->numNodes); - + // clear sky persist-frames timer environmentPrivate->sky_visibility = 0; @@ -228,7 +228,7 @@ AKrEnvironment_TemplateHandler( } } - if (environment->gqDebugArray != NULL) + if (environment->gqDebugArray != NULL) { AKtGQ_Debug *gqDebug; UUtUns32 offset = (UUtUns32) TMrInstance_GetRawOffset(environment); @@ -245,13 +245,13 @@ AKrEnvironment_TemplateHandler( } AKiPrepareGrids(environment); - + break; - + case TMcTemplateProcMessage_DisposePreProcess: AKiEnvironment_DebugMaps_Dispose((AKtEnvironment *)inDataPtr); - + if(environmentPrivate->gqComputedBackFaceBV != NULL) { UUrBitVector_Dispose(environmentPrivate->gqComputedBackFaceBV); } @@ -272,7 +272,7 @@ AKrEnvironment_TemplateHandler( UUrMemory_Block_Delete(environmentPrivate->visGQ_List); } break; - + default: UUmAssert(!"Illegal message"); } @@ -293,19 +293,19 @@ AKiNodeProcHandler( { case TMcTemplateProcMessage_NewPostProcess: break; - + case TMcTemplateProcMessage_LoadPostProcess: break; - + case TMcTemplateProcMessage_DisposePreProcess: - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); } - + return UUcError_None; } @@ -320,16 +320,16 @@ AKiEnvShow( UUtUns32 newState = AKgEnvShowState; UUtBool add; char* p; - + if(inArgC < 2) { goto printDesc; } - + for(i = 1; i < inArgC; i++) { p = inArgV[i]; - + if(*p == '+') { add = UUcTrue; @@ -342,9 +342,9 @@ AKiEnvShow( { goto printDesc; } - + p++; - + if(strcmp(p, "all") == 0) { if(add) @@ -378,16 +378,16 @@ AKiEnvShow( newState &=~ AKcEnvShow_GQ; } } - else + else { goto printDesc; } } - + AKgEnvShowState = newState; - + return; - + printDesc: COrConsole_Printf("%s [ + | - ] [bnv | prt | psg | all]", inArgV[0]); @@ -404,7 +404,7 @@ AKiEnvShow_Generic_ParseExpr( UUtUns32 start, end; char c; char* bp; - + while(1) { bp = buffer; @@ -415,9 +415,9 @@ AKiEnvShow_Generic_ParseExpr( c = *p++; } *bp = 0; - + sscanf(buffer, "%d", &start); - + if(c == '.') { c = *p++; @@ -432,16 +432,16 @@ AKiEnvShow_Generic_ParseExpr( c = *p++; } *bp = 0; - + sscanf(buffer, "%d", &end); } else { end = start; } - + inFunc(inBitVector, start, end); - + if(c != ',') { break; @@ -461,20 +461,20 @@ AKiEnvShow_Generic( char* p; char c; UUtUns16 i; - + UUtBitVector_BitRangeFunc func; - + if(inArgC <= 1) { goto printDesc; } - + for(i = 1; i < inArgC; i++) { p = inArgV[i]; - + c = *p; - + if(c == '+') { func = UUrBitVector_SetBitRange; @@ -491,9 +491,9 @@ AKiEnvShow_Generic( { goto printDesc; } - + p++; - + if(p[0] == 'a' && p[1] == 'l' && p[2] == 'l') { func(inBitVector, 0, inMaxBits); @@ -503,14 +503,14 @@ AKiEnvShow_Generic( AKiEnvShow_Generic_ParseExpr(inBitVector, inMaxBits, func, p); } } - + return; - + printDesc: COrConsole_Printf("%s [ + | - ] [all | expr; expr -> num | num..num | expr,expr", inArgV[0]); - + } - + static void AKiEnvShow_BNV( UUtUns32 inArgC, @@ -550,9 +550,9 @@ AKiEnvShowFileNames( UUtInt32 i; AKtBNV_Debug* curBNVDebug; //AKtGQ_Debug* curGQDebug; - + showState = 0; - + for(i = 1; i < (UUtInt32)inArgC; i++) { if(strcmp(inArgV[i], "all") == 0) @@ -572,10 +572,10 @@ AKiEnvShowFileNames( goto printDesc; } } - + // Only print out stuff for the displayed objects showState &= AKgEnvShowState; - + if(showState & AKcEnvShow_BNV) { UUmBitVector_ForEachBitSetDo(i, AKgBNVBitVector, (UUtInt32)AKgEnvDebug->bnvNodeArray->numBNVs - 1) @@ -584,7 +584,7 @@ AKiEnvShowFileNames( COrConsole_Printf("BNV[%d]: %s", i, curBNVDebug->fileName); } } - + #if 0 if(showState & AKcEnvShow_GQT) { @@ -595,12 +595,12 @@ AKiEnvShowFileNames( } } #endif - + return; printDesc: COrConsole_Printf("%s [bnv | prt | psg | all]", inArgV[0]); - + } #endif @@ -664,13 +664,13 @@ AKrInitialize( error = AKrRegisterTemplates(); UUmError_ReturnOnError(error); - + /* * Register my template handlers with the TemplateManager */ error = TMrTemplate_PrivateData_New(AKcTemplate_Environment, sizeof(AKtEnvironment_Private), AKrEnvironment_TemplateHandler, &AKgTemplate_PrivateData); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); #if 1 @@ -718,11 +718,11 @@ AKrInitialize( void AKrTerminate( void) -{ +{ if(AKgDebugLeafNodes != NULL) { AUrDict_Dispose(AKgDebugLeafNodes); } - + AKrEnvironment_PrintStats(); AKrEnvironment_Collision_PrintStats(); } @@ -736,18 +736,18 @@ ARiPointInBSP( M3tPlaneEquation* outRejectingPlane, float* outRejectionValue) { - const AKtBNV_BSPNode *curNode; + const AKtBNV_BSPNode *curNode; float a, b, c, d, plane_val; UUtUns32 curNodeIndex; - + curNodeIndex = inRootNode; - + while(1) - { + { curNode = inBSPNodeArray + curNodeIndex; - + AKmPlaneEqu_GetComponents(curNode->planeEquIndex, inPlaneEquArray, a, b, c, d); - + plane_val = inPoint->x * a + inPoint->y * b + inPoint->z * c + d; if(UUmFloat_CompareLE(plane_val, 0.0f)) { if(0xFFFFFFFF == curNode->posNodeIndex) { @@ -785,7 +785,7 @@ AKrPointInNode( { AKtBNVNode* node; node = &inEnvironment->bnvNodeArray->nodes[inNodeIndex]; - + return ARiPointInBSP( inEnvironment->planeArray->planes, inEnvironment->bspNodeArray->nodes, @@ -793,7 +793,7 @@ AKrPointInNode( inViewpoint, outRejectingPlane, outRejectionValue); - + } UUtBool @@ -804,7 +804,7 @@ AKrPointInNodeVertically( { // Returns TRUE if the point is in the vertical space of the node const PHtRoomData *room = &inNode->roomData; - + return (inPoint->y >= room->origin.y && inPoint->y <= room->antiOrigin.y); } @@ -821,7 +821,7 @@ AKrEnvironment_SetContextDimensions( UUtUns16 inWidth, UUtUns16 inHeight) { - + return UUcError_None; } @@ -850,10 +850,10 @@ AKrNodeFromPoint( UUmAssertReadPtr(inPoint, sizeof(*inPoint)); UUmAssertReadPtr(AKgEnvironment, sizeof(*AKgEnvironment)); - UUmAssert(UUcError_None == M3rVerify_Point3D(inPoint)); - + UUmAssert(UUcError_None == M3rVerify_Point3D(inPoint)); + octTreeBNVIndices = AKgEnvironment->octTree->bnvIndices->indices; - + curLeafNodeIndex = AKrFindOctTreeNodeIndex( AKgEnvironment->octTree->interiorNodeArray->nodes, @@ -861,12 +861,12 @@ AKrNodeFromPoint( inPoint->y, inPoint->z, NULL); - + curLeafNode = AKgEnvironment->octTree->leafNodeArray->nodes + AKmOctTree_GetLeafIndex(curLeafNodeIndex); - + bnvIndexStart = (UUtUns16)(curLeafNode->bnvIndirectIndex_Encode >> 8); bnvIndexLength = (UUtUns16)(curLeafNode->bnvIndirectIndex_Encode & 0xFF); - + for(curBNVIndIndex = bnvIndexStart; curBNVIndIndex < bnvIndexStart + bnvIndexLength; curBNVIndIndex++) @@ -874,7 +874,7 @@ AKrNodeFromPoint( UUmAssert(curBNVIndIndex < AKgEnvironment->octTree->bnvIndices->numIndices); curBNVIndex = octTreeBNVIndices[curBNVIndIndex]; - + pointIsInNode = AKrPointInNode(inPoint, AKgEnvironment, curBNVIndex, &reject_plane, &d); @@ -898,18 +898,18 @@ AKrNodeFromPoint( } d += (float)fabs(dy); - + isStairNode = ((bnv->flags & AKcBNV_Flag_Stairs_Standard) != 0); if (isStairNode) { // reject stair nodes if we're outside their vertical extent - stair_rel_y = inPoint->x * bnv->stairPlane.a + inPoint->y * bnv->stairPlane.b + + stair_rel_y = inPoint->x * bnv->stairPlane.a + inPoint->y * bnv->stairPlane.b + inPoint->z * bnv->stairPlane.c + bnv->stairPlane.d; if (UUmFloat_CompareLT(stair_rel_y, 0.0f) || UUmFloat_CompareGT(stair_rel_y, bnv->stairHeight)) { continue; } } - + if (pointIsInNode) { if (closestIsOutside) { // inside nodes override outside ones @@ -952,7 +952,7 @@ AKrNodeFromPoint( v2 =(float)(fabs(bnv->roomData.origin.x - bnv->roomData.antiOrigin.x) * fabs(bnv->roomData.origin.y - bnv->roomData.antiOrigin.y) * fabs(bnv->roomData.origin.z - bnv->roomData.antiOrigin.z)); - + if (v2gqGeneralArray->gqGeneral; } @@ -990,7 +990,7 @@ static void AKrEnvironment_NodeList_Get_Recursive( M3tBoundingBox_MinMax newBox; float curDim; UUtUns32 itr; - + if (g_nlgr_bounding_box->maxPoint.x < inCurBox->minPoint.x || g_nlgr_bounding_box->maxPoint.y < inCurBox->minPoint.y || g_nlgr_bounding_box->maxPoint.z < inCurBox->minPoint.z || @@ -1000,7 +1000,7 @@ static void AKrEnvironment_NodeList_Get_Recursive( { goto exit; } - + if (AKmOctTree_IsLeafNode(inCurNodeIndex)) { if (g_nlgr_count < g_nlgr_max_count) { @@ -1011,9 +1011,9 @@ static void AKrEnvironment_NodeList_Get_Recursive( goto exit; } - + curDim = (inCurBox->maxPoint.x - inCurBox->minPoint.x) * 0.5f; - + for(itr = 0; itr < 8; itr++) { if(itr & 0x1) { @@ -1107,7 +1107,7 @@ UUtBool AKrEnvironment_NodeList_Visible( { UUtUns32 itr; UUtUns32 count = inList[0]; - + for(itr = 0; itr < count; itr++) { UUtUns32 node_index = inList[itr + 1]; @@ -1144,7 +1144,7 @@ AKrEnvironment_IsBoundingBoxMinMaxVisible_Recursive( #if PERFORMANCE_TIMER UUrPerformanceTimer_Enter(AKg_IsBoundingBoxMinMaxVisible_Recursive_Timer); #endif - + //if(!CLrBox_MinMaxBox(inBoundingBox, inCurBox)) // S.S. inlined because this is the only spot it is used and is getting called thousands of times per frame if (inBoundingBox->maxPoint.x < inCurBox->minPoint.x || @@ -1171,7 +1171,7 @@ AKrEnvironment_IsBoundingBoxMinMaxVisible_Recursive( int itr; visible= UUcFalse; - + for (itr= 0; itr<8; itr++) { if(itr & 0x1) @@ -1206,7 +1206,7 @@ AKrEnvironment_IsBoundingBoxMinMaxVisible_Recursive( newBox.minPoint.z= inCurBox->minPoint.z; newBox.maxPoint.z= inCurBox->maxPoint.z - cur_dim; } - + if (AKrEnvironment_IsBoundingBoxMinMaxVisible_Recursive( inInteriorNodeArray, inLeafVisible2BV, @@ -1227,7 +1227,7 @@ AKrEnvironment_IsBoundingBoxMinMaxVisible_Recursive( return visible; } - + UUtBool AKrEnvironment_IsBoundingBoxMinMaxVisible( M3tBoundingBox_MinMax *bounding_box) { @@ -1241,14 +1241,14 @@ UUtBool AKrEnvironment_IsBoundingBoxMinMaxVisible( #if PERFORMANCE_TIMER UUrPerformanceTimer_Enter(AKg_BBox_Visible_Timer); #endif - + box.minPoint.x= -AKcMaxHalfOTDim; box.minPoint.y= -AKcMaxHalfOTDim; box.minPoint.z= -AKcMaxHalfOTDim; box.maxPoint.x= AKcMaxHalfOTDim; box.maxPoint.y= AKcMaxHalfOTDim; box.maxPoint.z= AKcMaxHalfOTDim; - + visible= AKrEnvironment_IsBoundingBoxMinMaxVisible_Recursive( AKgEnvironment->octTree->interiorNodeArray->nodes, environment_private->ot2LeafNodeVisibility, @@ -1275,14 +1275,14 @@ UUtBool AKrEnvironment_IsBoundingBoxMinMaxVisible_WithNodeIndex( #if PERFORMANCE_TIMER UUrPerformanceTimer_Enter(AKg_BBox_Visible_Timer); #endif - + box.minPoint.x= -AKcMaxHalfOTDim; box.minPoint.y= -AKcMaxHalfOTDim; box.minPoint.z= -AKcMaxHalfOTDim; box.maxPoint.x= AKcMaxHalfOTDim; box.maxPoint.y= AKcMaxHalfOTDim; box.maxPoint.z= AKcMaxHalfOTDim; - + visible= AKrEnvironment_IsBoundingBoxMinMaxVisible_Recursive( AKgEnvironment->octTree->interiorNodeArray->nodes, environment_private->ot2LeafNodeVisibility, @@ -1303,7 +1303,7 @@ AKrEnvironment_PointIsVisible( UUtUns32 *leaf_visible_bv = environmentPrivate->ot2LeafNodeVisibility; UUtUns32 node_index; UUtBool is_visible; - + node_index = AKrFindOctTreeNodeIndex(AKgEnvironment->octTree->interiorNodeArray->nodes, inPoint->x, inPoint->y, inPoint->z, NULL); is_visible = UUr2BitVector_Test(leaf_visible_bv, AKmOctTree_GetLeafIndex(node_index)) > 0; @@ -1318,7 +1318,7 @@ AKrEnvironment_IsGeometryVisible( { M3tBoundingBox_MinMax bbox; UUtBool is_visible; - + M3rGeometry_GetBBox(inGeometry, inMatrix, &bbox); is_visible = AKrEnvironment_IsBoundingBoxMinMaxVisible(&bbox); @@ -1349,7 +1349,7 @@ AKrEnvironment_DrawIfVisible( { M3tBoundingBox_MinMax bbox; UUtBool is_visible; - + M3rGeometry_GetBBox(inGeometry, inMatrix, &bbox); is_visible = AKrEnvironment_IsBoundingBoxMinMaxVisible(&bbox); diff --git a/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Collision.c b/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Collision.c index 999c0af..f3f8a45 100644 --- a/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Collision.c +++ b/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Collision.c @@ -1,13 +1,13 @@ /* FILE: BFW_Akira_Collision.c - + AUTHOR: Brent H. Pease - + CREATED: October 12, 1998 PURPOSE: environment engine - + Copyright (c) Bungie Software 1997, 2000 */ @@ -66,10 +66,10 @@ UUtError AKrCollision_LevelBegin(AKtEnvironment *inEnvironment) AKgGQTestedDict = AUrDict_New(AKcMaxNumCheckedGQs, numGQs); UUmError_ReturnOnNull(AKgGQTestedDict); - + AKgLocalNodeTestedDict = AUrDict_New(AKcMaxNumCheckedGQs, numLeafNodes); UUmError_ReturnOnNull(AKgLocalNodeTestedDict); - + return UUcError_None; } @@ -158,7 +158,7 @@ UUtBool AKrLineOfSight( * LOS is blocked, we return the point at which it was blocked * in the collisionPoint field of the first Akira collision. */ - + M3tVector3D sightline; AKtEnvironment *env; OBtObjectList *oblist; @@ -167,19 +167,19 @@ UUtBool AKrLineOfSight( env = ONrGameState_GetEnvironment(); oblist = ONrGameState_GetObjectList(); obcount = oblist->numObjects; - + // Check for environment blockage MUmVector_Subtract(sightline,*inPointB,*inPointA); - if (AKrCollision_Point(env, inPointA, &sightline, AKcGQ_Flag_LOS_CanSee_Skip_AI, 1)) + if (AKrCollision_Point(env, inPointA, &sightline, AKcGQ_Flag_LOS_CanSee_Skip_AI, 1)) { return UUcFalse; } - + // Check for objects for (i=0; iobject_list + i; if (!(curObject->flags & OBcFlags_InUse)) continue; @@ -187,7 +187,7 @@ UUtBool AKrLineOfSight( // checking sight against spheres, which is relatively close sphere = &(curObject->physics->sphereTree[0].sphere); - + // collide against sphere if (CLrSphere_Line(inPointA,inPointB,sphere)) { @@ -196,7 +196,7 @@ UUtBool AKrLineOfSight( return UUcFalse; } } - + return UUcTrue; } @@ -219,7 +219,7 @@ AKrFindOctTreeNodeIndex_Integer( UUtInt32 in_y = MUrFloat_Round_To_Int(inPointY * scale); UUtInt32 in_z = MUrFloat_Round_To_Int(inPointZ * scale); UUtUns32 cur_dim = (UUtUns32) (AKcMaxHalfOTDim * scale * 0.5f); - + UUtInt32 cur_center_x = 0; UUtInt32 cur_center_y = 0; UUtInt32 cur_center_z = 0; @@ -233,7 +233,7 @@ AKrFindOctTreeNodeIndex_Integer( // We want to find which octant the end point lies in curOctant = 0; - + if (in_x > cur_center_x) { cur_center_x += cur_dim; curOctant |= AKcOctTree_SideBV_X; @@ -257,13 +257,13 @@ AKrFindOctTreeNodeIndex_Integer( else { cur_center_z -= cur_dim; } - + // Find the child curNodeIndex = curIntNode->children[curOctant]; // if we are at a leaf node then break if (AKmOctTree_IsLeafNode(curNodeIndex)) break; - + if (++itrs >= AKcMaxTreeDepth) { UUmAssert("OT corrupted"); } @@ -303,7 +303,7 @@ AKrFindOctTreeNodeIndex_Float( float curCenterPointZ = 0; UUtUns32 itrs = 0; UUtUns32 leaf; - + #if MEASURE_CACHE static UUtUns32 nodecache_hit = 0, nodecache_miss = 0; #endif @@ -347,7 +347,7 @@ AKrFindOctTreeNodeIndex_Float( // We want to find which octant the end point lies in curOctant = 0; - + if (inPointX > curCenterPointX) { curOctant |= AKcOctTree_SideBV_X; } @@ -359,7 +359,7 @@ AKrFindOctTreeNodeIndex_Float( if (inPointZ > curCenterPointZ) { curOctant |= AKcOctTree_SideBV_Z; } - + // Find the child curNodeIndex = curIntNode->children[curOctant]; @@ -434,72 +434,72 @@ AKrCollision_Point_SpatialCache( AKtOctTree_LeafNode* leafNodeArray; AKtQuadTree_Node* qtInteriorNodeArray; AKtQuadTree_Node* curQTIntNode; - + UUtUns32 curGQIndIndex; AKtGQ_General* gqGeneralArray; AKtGQ_Collision* gqCollisionArray; - + AKtGQ_Collision* curGQCollision; UUtUns32 xSideFlag; UUtUns32 ySideFlag; UUtUns32 zSideFlag; UUtUns32 sideCrossing; - + UUtUns32 endNodeIndex; UUtUns32 curNodeIndex; AKtOctTree_LeafNode* curOTLeafNode; UUtUns32 curOctant; - + M3tPoint3D endPoint; float startPointX; float startPointY; float startPointZ; - + float endPointX; float endPointY; float endPointZ; - + float vX; float vY; float vZ; - + float invVX; float invVY; float invVZ; - + float xPlane; float yPlane; float zPlane; float d; - + float curCenterPointU; float curCenterPointV; - + float minX; float minY; float minZ; float maxX, maxY, maxZ; - + float curHalfDim; float curFullDim; float t1, t2; - + float curDistance; - - + + UUtUns32 length; - + #if defined(DEBUG_COLLISION2_TRAVERSAL) && DEBUG_COLLISION2_TRAVERSAL M3tBoundingBox_MinMax bBox; M3tPoint3D start, end; UUtBool in; #endif - + UUmAssertReadPtr(inEnvironment, sizeof(AKtEnvironment)); UUmAssertReadPtr(ioPoint, sizeof(M3tPoint3D)); UUmAssertReadPtr(inVector, sizeof(M3tVector3D)); @@ -511,7 +511,7 @@ AKrCollision_Point_SpatialCache( AUrDict_Clear(AKgGQTestedDict); AKgNumCollisions = 0; - + pointArray = inEnvironment->pointArray->points; planeEquArray = inEnvironment->planeArray->planes; interiorNodeArray = inEnvironment->octTree->interiorNodeArray->nodes; @@ -520,11 +520,11 @@ AKrCollision_Point_SpatialCache( gqGeneralArray = inEnvironment->gqGeneralArray->gqGeneral; gqCollisionArray = inEnvironment->gqCollisionArray->gqCollision; octTreeGQIndices = inEnvironment->octTree->gqIndices->indices; - + vX = inVector->x; vY = inVector->y; vZ = inVector->z; - + if (vX != 0.0f) { invVX = 1.0f / vX; } @@ -536,24 +536,24 @@ AKrCollision_Point_SpatialCache( if (vZ != 0.0f) { invVZ = 1.0f / vZ; } - + startPointX = ioPoint->x; startPointY = ioPoint->y; startPointZ = ioPoint->z; - + // Compute the side flags xSideFlag = AKcOctTree_Side_NegX + (vX > 0.0f); ySideFlag = AKcOctTree_Side_NegY + (vY > 0.0f); zSideFlag = AKcOctTree_Side_NegZ + (vZ > 0.0f); - + endPoint.x = endPointX = startPointX + vX; endPoint.y = endPointY = startPointY + vY; endPoint.z = endPointZ = startPointZ + vZ; - + curHalfDim = AKcMaxHalfOTDim; - + curNodeIndex = 0; - + // CB: this could perhaps be more efficient if we never found the end octree node directly but // instead just looked at our t-val along the ray and compared it to 1.0... @@ -566,12 +566,12 @@ AKrCollision_Point_SpatialCache( // Find the start and finish octree nodes curNodeIndex = AKrFindOctTreeNodeIndex(interiorNodeArray, startPointX, startPointY, startPointZ, ioStartCache); endNodeIndex = AKrFindOctTreeNodeIndex(interiorNodeArray, endPointX, endPointY, endPointZ, ioEndCache); - + curHalfDim = AKcMaxHalfOTDim; curOctant = 0xFFFFFFFF; - + // go into the start node - + while(1) { UUtUns32 oct_tree_leaf_index = AKmOctTree_GetLeafIndex(curNodeIndex); @@ -579,39 +579,39 @@ AKrCollision_Point_SpatialCache( UUmAssert(AKmOctTree_IsLeafNode(curNodeIndex)); if (0xFFFFFFFF == curNodeIndex) goto finished; - + UUmAssert(oct_tree_leaf_index < inEnvironment->octTree->leafNodeArray->numNodes); - + curOTLeafNode = leafNodeArray + oct_tree_leaf_index; - + #if defined(DEBUG_COLLISION2_TRAVERSAL) && DEBUG_COLLISION2_TRAVERSAL - + bBox.minPoint.x = curOTLeafNode->sidePlane[AKcOctTree_Side_NegX]; bBox.minPoint.y = curOTLeafNode->sidePlane[AKcOctTree_Side_NegY]; bBox.minPoint.z = curOTLeafNode->sidePlane[AKcOctTree_Side_NegZ]; bBox.maxPoint.x = curOTLeafNode->sidePlane[AKcOctTree_Side_PosX]; bBox.maxPoint.y = curOTLeafNode->sidePlane[AKcOctTree_Side_PosY]; bBox.maxPoint.z = curOTLeafNode->sidePlane[AKcOctTree_Side_PosZ]; - + start.x = startPointX; start.y = startPointY; start.z = startPointZ; end.x = endPointX; end.y = endPointY; end.z = endPointZ; - + in = CLrBox_Line(&bBox, &start, &end); - + UUmAssert(in); #endif - + // Do something with curOTLeafNode here - + if (0 == curOTLeafNode->gqIndirectIndex_Encode ) goto skip; - + AKmOctTree_DecodeGQIndIndices(curOTLeafNode->gqIndirectIndex_Encode, startIndirectIndex, length); - + for(curGQIndIndex = startIndirectIndex; curGQIndIndex < startIndirectIndex + length; curGQIndIndex++) @@ -622,17 +622,17 @@ AKrCollision_Point_SpatialCache( curGQIndex = octTreeGQIndices[curGQIndIndex]; curGQGeneral = gqGeneralArray + curGQIndex; - + UUmAssert(curGQIndex < inEnvironment->gqGeneralArray->numGQs); if (curGQGeneral->flags & inSkipFlags) { continue; } - + if (AUrDict_TestAndAdd(AKgGQTestedDict, curGQIndex)) { continue; } - + curGQCollision = gqCollisionArray + curGQIndex; - + if ( CLrQuad_Line( (CLtQuadProjection)AKmGetQuadProjection(curGQGeneral->flags), @@ -648,13 +648,13 @@ AKrCollision_Point_SpatialCache( AKgNumCollisions = 1; goto finished; } - + curDistance = (float)fabs(intersection.x - startPointX); curDistance += (float)fabs(intersection.y - startPointY); curDistance += (float)fabs(intersection.z - startPointZ); - + if (AKgNumCollisions >= AKcMaxNumCollisions) goto finished; - + AKgTempCollisionList[AKgNumCollisions].float_distance = curDistance; AKgTempCollisionList[AKgNumCollisions].compare_distance = MUrUnsignedSmallFloat_ShiftLeft_To_Uns_Round(curDistance, 8); AKgTempCollisionList[AKgNumCollisions].gqIndex = curGQIndex; @@ -662,14 +662,14 @@ AKrCollision_Point_SpatialCache( AKgNumCollisions++; } } - + skip: - + if ((inNumCollisions != 0) && (AKgNumCollisions >= inNumCollisions)) goto finished; - + // If we are finished then bail if (endNodeIndex == curNodeIndex) goto finished; - + { UUtUns32 dim_Encode; @@ -679,7 +679,7 @@ AKrCollision_Point_SpatialCache( maxY = AKgIntToFloatXYZ[(dim_Encode >> AKcOctTree_Shift_Y) & AKcOctTree_Mask_Y]; maxZ = AKgIntToFloatXYZ[(dim_Encode >> AKcOctTree_Shift_Z) & AKcOctTree_Mask_Z]; } - + minX = maxX - curFullDim; minY = maxY - curFullDim; minZ = maxZ - curFullDim; @@ -689,17 +689,17 @@ AKrCollision_Point_SpatialCache( xPlane = (xSideFlag == AKcOctTree_Side_PosX) ? maxX : minX; yPlane = (ySideFlag == AKcOctTree_Side_PosY) ? maxY : minY; zPlane = (zSideFlag == AKcOctTree_Side_PosZ) ? maxZ : minZ; - + t1 = vY * (xPlane - startPointX); t2 = vX * (yPlane - startPointY); - + if (fabs(t1) > fabs(t2)) { - // We cross the y axis - we can eliminate the x side + // We cross the y axis - we can eliminate the x side // project onto YZ plane - + t1 = vZ * (yPlane - startPointY); t2 = vY * (zPlane - startPointZ); - + if (fabs(t1) > fabs(t2)) { sideCrossing = zSideFlag; } @@ -713,7 +713,7 @@ AKrCollision_Point_SpatialCache( t1 = (vZ) * (xPlane - startPointX); t2 = (vX) * (zPlane - startPointZ); - + if (fabs(t1) > fabs(t2)) { sideCrossing = zSideFlag; } @@ -721,9 +721,9 @@ AKrCollision_Point_SpatialCache( sideCrossing = xSideFlag; } } - + #if defined(DEBUG_COLLISION) && DEBUG_COLLISION - + UUrDebuggerMessage("sideCrossing: %d", sideCrossing); #endif @@ -731,15 +731,15 @@ AKrCollision_Point_SpatialCache( // Lets move to the next node curNodeIndex = curOTLeafNode->adjInfo[sideCrossing]; - + if (!AKmOctTree_IsLeafNode(curNodeIndex)) { float uc, vc; // need to traverse quad tree - + curHalfDim = curFullDim * 0.5f; - + // First compute the intersection point switch(sideCrossing) { @@ -751,7 +751,7 @@ AKrCollision_Point_SpatialCache( uc = startPointY + vY * d; vc = startPointZ + vZ * d; break; - + case AKcOctTree_Side_NegY: case AKcOctTree_Side_PosY: curCenterPointU = minX + curHalfDim; @@ -760,7 +760,7 @@ AKrCollision_Point_SpatialCache( uc = startPointX + vX * d; vc = startPointZ + vZ * d; break; - + case AKcOctTree_Side_NegZ: case AKcOctTree_Side_PosZ: curCenterPointU = minX + curHalfDim; @@ -769,22 +769,22 @@ AKrCollision_Point_SpatialCache( uc = startPointX + vX * d; vc = startPointY + vY * d; break; - + default: UUmAssert(0); } - + // next traverse the tree while(1) { curQTIntNode = qtInteriorNodeArray + curNodeIndex; - + curOctant = 0; if (uc > curCenterPointU) curOctant |= AKcQuadTree_SideBV_U; if (vc > curCenterPointV) curOctant |= AKcQuadTree_SideBV_V; - + curNodeIndex = curQTIntNode->children[curOctant]; - + if (AKmOctTree_IsLeafNode(curNodeIndex)) break; curHalfDim *= 0.5f; curCenterPointU += (curOctant & AKcQuadTree_SideBV_U) ? curHalfDim : -curHalfDim; @@ -801,9 +801,9 @@ AKrCollision_Point_SpatialCache( // sort the collisions if (AKgNumCollisions > 0) { - AKiSortCollisions(inNumCollisions); + AKiSortCollisions(inNumCollisions); } - + return (UUtBool)(AKgNumCollisions > 0); } @@ -830,17 +830,17 @@ AKrCollision_Point( UUtUns32 gCol_Sphere_Func_Num = 0; UUtUns32 gCol_Sphere_Func_Time = 0; - + UUtUns32 gCol_Sphere_FindingLeaf_Time = 0; UUtUns32 gCol_Sphere_FindingGQs_Time = 0; - + UUtUns32 gCol_Sphere_GQChecks = 0; UUtUns32 gCol_Sphere_GQHits = 0; UUtUns32 gCol_Sphere_QuadSphereVector_Time = 0; - + UUtUns32 gCol_Sphere_LeafNodes_Num = 0; UUtUns32 gCol_Sphere_SphereChecks_Num = 0; - + #endif @@ -859,7 +859,7 @@ AKrCollision_Sphere( UUtInt64 funcQuadSphereVectorStart; UUtInt64 curTime; UUtInt64 findGQStart; - + #endif UUtUns32* octTreeGQIndices; @@ -869,46 +869,46 @@ AKrCollision_Sphere( AKtQuadTree_Node* qtInteriorNodeArray; AKtGQ_Collision* gqCollisionArray; AKtGQ_General* gqGeneral; - + AKtOctTree_LeafNode* curLeafNode; AKtQuadTree_Node* curQTIntNode; - + float xi, yi, zi; float xm, ym, zm; float curt, inct; float r, r2; float t, dmin; - + UUtUns32 curNodeIndex; UUtUns32 curLeafIndex; - + UUtUns32 leafTOS; UUtUns32 leafStack[AKcMaxSphereStack]; - + float minX, minY, minZ; float maxX, maxY, maxZ; float curX, curY, curZ; - + UUtUns32 dim_Encode; //float curHalfDim; float curFullDim; - + UUtBool done; - + UUtUns32 itr; - + UUtUns32 curGQIndIndex; - + UUtUns32 startIndirectIndex; UUtUns32 length; UUtUns32 curGQIndex; float curDistance; M3tPoint3D intersection; - + M3tPoint3D endPoint; float vectorLength; - + UUmAssertReadPtr(inEnvironment, sizeof(*inEnvironment)); UUmAssertReadPtr(ioSphere, sizeof(*ioSphere)); UUmAssertReadPtr(inVector, sizeof(*inVector)); @@ -917,14 +917,14 @@ AKrCollision_Sphere( #if PERFORMANCE_TIMER UUrPerformanceTimer_Enter(AKg_Collision_Sphere_Timer); #endif - + #if BRENTS_CHEESY_COL_PROFILE - + gCol_Sphere_Func_Num++; funcStart = UUrMachineTime_High(); - + #endif - + AKgNumCollisions = 0; AUrDict_Clear(AKgNodeTestedDict); @@ -939,47 +939,47 @@ AKrCollision_Sphere( xi = ioSphere->center.x; yi = ioSphere->center.y; zi = ioSphere->center.z; - + xm = inVector->x; ym = inVector->y; zm = inVector->z; - + endPoint.x = xi + xm; endPoint.y = yi + ym; endPoint.z = zi + zm; - + r = ioSphere->radius; - + vectorLength = MUrSqrt(xm * xm + ym * ym + zm * zm); - + if (vectorLength < r * 0.125f) { r += vectorLength * 0.5f; - + xi += xm * 0.5f; yi += ym * 0.5f; zi += zm * 0.5f; - + r2 = r * r; - + // go into the start node - curNodeIndex = AKrFindOctTreeNodeIndex(interiorNodeArray, xi, yi, zi, NULL); - + curNodeIndex = AKrFindOctTreeNodeIndex(interiorNodeArray, xi, yi, zi, NULL); + // now add every adjacent sibling that is within the sphere centered around curXYZ leafTOS = 1; leafStack[0] = curNodeIndex; - + while(leafTOS > 0) { curNodeIndex = leafStack[--leafTOS]; if (curNodeIndex == 0xFFFFFFFF) continue; - + if (!AKmOctTree_IsLeafNode(curNodeIndex)) { curQTIntNode = qtInteriorNodeArray + curNodeIndex; - + for(itr = 0; itr < 4; itr++) { if (leafTOS >= AKcMaxSphereStack) @@ -989,22 +989,22 @@ AKrCollision_Sphere( } leafStack[leafTOS++] = curQTIntNode->children[itr]; } - + continue; } - + curLeafIndex = AKmOctTree_GetLeafIndex(curNodeIndex); - + if (AUrDict_Test(AKgNodeTestedDict, curLeafIndex) == UUcTrue) continue; - + #if BRENTS_CHEESY_COL_PROFILE - + gCol_Sphere_SphereChecks_Num++; - + #endif - + curLeafNode = leafNodeArray + curLeafIndex; - + dim_Encode = curLeafNode->dim_Encode; curFullDim = AKgIntToFloatDim[(dim_Encode >> AKcOctTree_Shift_Dim) & AKcOctTree_Mask_Dim]; maxX = AKgIntToFloatXYZ[(dim_Encode >> AKcOctTree_Shift_X) & AKcOctTree_Mask_X]; @@ -1013,7 +1013,7 @@ AKrCollision_Sphere( minX = maxX - curFullDim; minY = maxY - curFullDim; minZ = maxZ - curFullDim; - + dmin = 0.0f; if (xi < minX) { @@ -1026,7 +1026,7 @@ AKrCollision_Sphere( t *= t; dmin += t; } - + if (yi < minY) { t = yi - minY; t *= t; @@ -1037,7 +1037,7 @@ AKrCollision_Sphere( t *= t; dmin += t; } - + if (zi < minZ) { t = zi - minZ; t *= t; @@ -1048,12 +1048,12 @@ AKrCollision_Sphere( t *= t; dmin += t; } - + // if we are within the sphere then push all adjacent quads that have not been visited onto the stack if (dmin <= r2) { AUrDict_TestAndAdd(AKgNodeTestedDict, curLeafIndex); - + for(itr = 0; itr < 6; itr++) { if (leafTOS >= AKcMaxSphereStack) @@ -1070,41 +1070,41 @@ AKrCollision_Sphere( { inct = r * 1.0f / vectorLength; r2 = r * r; - + curt = 0.0f; done = UUcFalse; - + while(!done) { - + if (curt >= 1.0f) { curt = 1.0f; done = UUcTrue; } - + curX = xi + curt * xm; curY = yi + curt * ym; curZ = zi + curt * zm; - + AUrDict_Clear(AKgLocalNodeTestedDict); - + // go into the start node - curNodeIndex = AKrFindOctTreeNodeIndex(interiorNodeArray, curX, curY, curZ, NULL); - + curNodeIndex = AKrFindOctTreeNodeIndex(interiorNodeArray, curX, curY, curZ, NULL); + // now add every adjacent sibling that is within the sphere centered around curXYZ leafTOS = 1; leafStack[0] = curNodeIndex; - + while(leafTOS > 0) { curNodeIndex = leafStack[--leafTOS]; if (0xFFFFFFFF == curNodeIndex) continue; - + if (!AKmOctTree_IsLeafNode(curNodeIndex)) { curQTIntNode = qtInteriorNodeArray + curNodeIndex; - + for(itr = 0; itr < 4; itr++) { if (leafTOS >= AKcMaxSphereStack) { @@ -1113,22 +1113,22 @@ AKrCollision_Sphere( } leafStack[leafTOS++] = curQTIntNode->children[itr]; } - + continue; } - + curLeafIndex = AKmOctTree_GetLeafIndex(curNodeIndex); - + if (AUrDict_Test(AKgLocalNodeTestedDict, curLeafIndex) == UUcTrue) continue; - + #if BRENTS_CHEESY_COL_PROFILE - + gCol_Sphere_SphereChecks_Num++; - + #endif - + curLeafNode = leafNodeArray + curLeafIndex; - + dim_Encode = curLeafNode->dim_Encode; curFullDim = AKgIntToFloatDim[(dim_Encode >> AKcOctTree_Shift_Dim) & AKcOctTree_Mask_Dim]; maxX = AKgIntToFloatXYZ[(dim_Encode >> AKcOctTree_Shift_X) & AKcOctTree_Mask_X]; @@ -1137,7 +1137,7 @@ AKrCollision_Sphere( minX = maxX - curFullDim; minY = maxY - curFullDim; minZ = maxZ - curFullDim; - + dmin = 0.0f; if (curX < minX) { t = curX - minX; @@ -1149,7 +1149,7 @@ AKrCollision_Sphere( t *= t; dmin += t; } - + if (curY < minY) { t = curY - minY; t *= t; @@ -1160,7 +1160,7 @@ AKrCollision_Sphere( t *= t; dmin += t; } - + if (curZ < minZ) { t = curZ - minZ; t *= t; @@ -1171,13 +1171,13 @@ AKrCollision_Sphere( t *= t; dmin += t; } - + // if we are within the sphere then push all adjacent quads that have not been visited onto the stack if (dmin <= r2) { AUrDict_TestAndAdd(AKgNodeTestedDict, curLeafIndex); AUrDict_TestAndAdd(AKgLocalNodeTestedDict, curLeafIndex); - + for(itr = 0; itr < 6; itr++) { if (leafTOS >= AKcMaxSphereStack) @@ -1189,7 +1189,7 @@ AKrCollision_Sphere( } } } - + curt += inct; } } @@ -1197,32 +1197,32 @@ AKrCollision_Sphere( bail: #if BRENTS_CHEESY_COL_PROFILE - + findGQStart = UUrMachineTime_High(); gCol_Sphere_FindingLeaf_Time += findGQStart - funcStart; #endif - + AUrDict_Clear(AKgGQTestedDict); - + #if BRENTS_CHEESY_COL_PROFILE - + gCol_Sphere_LeafNodes_Num += AKgNodeTestedDict->numPages; - + #endif - + // Now traverse all the intersected leaf nodes for(itr = 0; itr < AKgNodeTestedDict->numPages; itr++) { curLeafIndex = AKgNodeTestedDict->pages[itr]; curLeafNode = leafNodeArray + curLeafIndex; - + //AUrDict_TestAndAdd(AKgDebugLeafNodes, curLeafIndex); - + if (curLeafNode->gqIndirectIndex_Encode == 0) continue; - + AKmOctTree_DecodeGQIndIndices(curLeafNode->gqIndirectIndex_Encode, startIndirectIndex, length); - + for(curGQIndIndex = startIndirectIndex; curGQIndIndex < startIndirectIndex + length; curGQIndIndex++) @@ -1231,18 +1231,18 @@ AKrCollision_Sphere( UUmAssert(curGQIndex < inEnvironment->gqGeneralArray->numGQs); if (gqGeneral[curGQIndex].flags & inSkipFlags) { continue; } - + // check this gq if it is not in our dictionary - + if (!AUrDict_TestAndAdd(AKgGQTestedDict, curGQIndex)) - { + { UUtBool touchedThisGQ; - + #if BRENTS_CHEESY_COL_PROFILE - + gCol_Sphere_GQChecks++; funcQuadSphereVectorStart = UUrMachineTime_High(); - + #endif touchedThisGQ = @@ -1254,29 +1254,29 @@ AKrCollision_Sphere( &intersection); #if BRENTS_CHEESY_COL_PROFILE - + gCol_Sphere_QuadSphereVector_Time += UUrMachineTime_High() - funcQuadSphereVectorStart; - + #endif if (touchedThisGQ) { #if BRENTS_CHEESY_COL_PROFILE - + gCol_Sphere_GQHits++; - + #endif - + //inEnvironment->gqGeneralArray->gqGeneral[curGQIndex].flags |= AKcGQ_Flag_Draw_Flash; - + if (inNumCollisions == 0) { AKgNumCollisions = 1; goto finished; } - + if (AKgNumCollisions >= AKcMaxNumCollisions) goto finished; - + curDistance = MUrPoint_Distance(&intersection,&ioSphere->center); AKgTempCollisionList[AKgNumCollisions].float_distance = curDistance; @@ -1299,25 +1299,25 @@ AKrCollision_Sphere( finished: #if BRENTS_CHEESY_COL_PROFILE - + //ggCol_Sphere_MainWhile_Time += UUrMachineTime_High() - funcWhileLoopStart; - + #endif - + // sort the collisions if (AKgNumCollisions > 0) { - AKiSortCollisions(inNumCollisions); + AKiSortCollisions(inNumCollisions); } - + #if BRENTS_CHEESY_COL_PROFILE - + curTime = UUrMachineTime_High(); - + gCol_Sphere_Func_Time += curTime - funcStart; gCol_Sphere_FindingGQs_Time += curTime - findGQStart; - + #endif - + #if PERFORMANCE_TIMER UUrPerformanceTimer_Exit(AKg_Collision_Sphere_Timer); #endif @@ -1331,28 +1331,28 @@ AKrCollision_Sphere( UUtUns32 gSphereVec_Func_Num = 0; UUtUns32 gSphereVec_Func_Time = 0; - + UUtUns32 gSphereVec_TrivReject_SameSide = 0; UUtUns32 gSphereVec_TrivReject_Box = 0; - + UUtUns32 gSphereVec_Accept_PointInQuad_Start = 0; UUtUns32 gSphereVec_Accept_PointInQuad_End = 0; - + UUtUns32 gSphereVec_Accept_QuadLine = 0; UUtUns32 gSphereVec_Accept_VertexInSphere_Start = 0; UUtUns32 gSphereVec_Accept_VertexInSphere_End = 0; - + UUtUns32 gSphereVec_Accept_DistEdge = 0; - + UUtUns32 gSphereVec_Accept_Edge_Start = 0; UUtUns32 gSphereVec_Accept_Edge_End = 0; UUtUns32 gSphereVec_Accept_Edge_Edge = 0; - + UUtUns32 gSphereVec_Reject_Total = 0; UUtUns32 gSphereVec_Accept_Total = 0; - + #endif UUtBool @@ -1368,21 +1368,21 @@ AKrGQ_SphereVector( UUtInt64 funcStart; #endif - + const AKtGQ_Collision *gqCollision; const AKtGQ_General *gqGeneral; const M3tPoint3D *pointArray; const M3tPlaneEquation *planeArray; const M3tQuad *quad; - + UUtBool result; - + float startDist, endDist; M3tPoint3D Pop; M3tPoint3D endPoint; - + UUtUns32 i; - + float sphere_center_x; float sphere_center_y; float sphere_center_z; @@ -1392,16 +1392,16 @@ AKrGQ_SphereVector( float vector_z; float vector_length_squared; - + float px, py, pz; - + float distSquared; float rSquared; float t; float one_over_vector_length_squared; - + float radius; - + float minX, minY, minZ; float maxX, maxY, maxZ; @@ -1413,9 +1413,9 @@ AKrGQ_SphereVector( UUrPerformanceTimer_Enter(AKg_GQ_SphereVector_Timer); #endif - + //UUtBool wouldHaveBailed = UUcFalse; - + UUmAssertReadPtr(inEnvironment, sizeof(AKtEnvironment)); UUmAssertReadPtr(inVector, sizeof(M3tVector3D)); @@ -1427,23 +1427,23 @@ AKrGQ_SphereVector( #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - + gSphereVec_Func_Num++; funcStart = UUrMachineTime_High(); - + #endif - + #if 0 CLrQuad_Line( - AKmGetQuadProjection(gqGeneral->flags), - pointArray, planeArray, - gqCollision->planeEquIndex, + AKmGetQuadProjection(gqGeneral->flags), + pointArray, planeArray, + gqCollision->planeEquIndex, &gqGeneral->m3Quad.vertexIndices, start_point, end_point, #endif - + sphere_center_x = inSphere->center.x; sphere_center_y = inSphere->center.y; sphere_center_z = inSphere->center.z; @@ -1451,28 +1451,28 @@ AKrGQ_SphereVector( endPoint.x = sphere_center_x + inVector->x; endPoint.y = sphere_center_y + inVector->y; endPoint.z = sphere_center_z + inVector->z; - + radius = inSphere->radius; - + // First check if we are far away from the plane - { + { planeEqu = planeArray + (gqCollision->planeEquIndex & 0x7FFFFFFF); - // check for the start and end point within radius distance of the quad + // check for the start and end point within radius distance of the quad startDist = planeEqu->a * sphere_center_x + planeEqu->b * sphere_center_y + planeEqu->c * sphere_center_z + planeEqu->d; endDist = planeEqu->a * endPoint.x + planeEqu->b * endPoint.y + planeEqu->c * endPoint.z + planeEqu->d; } - + // to intersect we must cross the plane or intersect at the start or end of the line segment if (((startDist > radius) && (endDist > radius)) || ((startDist < -radius) && (endDist < -radius))) { #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - gSphereVec_TrivReject_SameSide++; + gSphereVec_TrivReject_SameSide++; #endif - + result = UUcFalse; goto exit; } - + // check min max box minX = gqCollision->bBox.minPoint.x; maxX = gqCollision->bBox.maxPoint.x; @@ -1480,18 +1480,18 @@ AKrGQ_SphereVector( maxY = gqCollision->bBox.maxPoint.y; minZ = gqCollision->bBox.minPoint.z; maxZ = gqCollision->bBox.maxPoint.z; - + UUmAssert(minX <= maxX); UUmAssert(minY <= maxY); UUmAssert(minZ <= maxZ); - + minX -= radius + 0.001f; maxX += radius + 0.001f; minY -= radius + 0.001f; maxY += radius + 0.001f; minZ -= radius + 0.001f; maxZ += radius + 0.001f; - + if ( (sphere_center_x < minX && endPoint.x < minX) || (sphere_center_x > maxX && endPoint.x > maxX) || @@ -1502,74 +1502,74 @@ AKrGQ_SphereVector( ) { #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - + gSphereVec_TrivReject_Box++; - + #endif - + //wouldHaveBailed = UUcTrue; - + result = UUcFalse; goto exit; } - + if ((float)fabs(startDist) <= radius) { Pop.x = sphere_center_x - startDist * planeEqu->a; Pop.y = sphere_center_y - startDist * planeEqu->b; Pop.z = sphere_center_z - startDist * planeEqu->c; - + if (CLrQuad_PointInQuad((CLtQuadProjection)AKmGetQuadProjection(gqGeneral->flags), pointArray, quad, &Pop)) { if (outIntersection != NULL) { *outIntersection = Pop; } - + #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - + gSphereVec_Accept_PointInQuad_Start++; - + #endif - + //UUmAssert(wouldHaveBailed == UUcFalse); - result = UUcTrue; + result = UUcTrue; goto exit; } } - + if ((float)fabs(endDist) <= radius) { Pop.x = endPoint.x - endDist * planeEqu->a; Pop.y = endPoint.y - endDist * planeEqu->b; Pop.z = endPoint.z - endDist * planeEqu->c; - + if (CLrQuad_PointInQuad((CLtQuadProjection)AKmGetQuadProjection(gqGeneral->flags), pointArray, quad, &Pop)) { if (outIntersection != NULL) { *outIntersection = Pop; } - + #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - + gSphereVec_Accept_PointInQuad_End++; - + #endif //UUmAssert(wouldHaveBailed == UUcFalse); - result = UUcTrue; + result = UUcTrue; goto exit; } } - + // Calculate some useful constants vector_x = inVector->x; vector_y = inVector->y; vector_z = inVector->z; - + vector_length_squared = vector_x * vector_x + vector_y * vector_y + vector_z * vector_z; vector_dot_sphere_center = vector_x * sphere_center_x + vector_y * sphere_center_y + vector_z * sphere_center_z; - + one_over_vector_length_squared = 1.0f / vector_length_squared; - + rSquared = radius * radius; - + // Next check the distance of each vertex to the line of the sphere vector for(i = 0; i < 4; i++) { @@ -1580,40 +1580,40 @@ AKrGQ_SphereVector( Cx = pointC->x; Cy = pointC->y; Cz = pointC->z; - + distSquared = UUmSQR(Cx - sphere_center_x); distSquared += UUmSQR(Cy - sphere_center_y); distSquared += UUmSQR(Cz - sphere_center_z); - - if (distSquared <= rSquared) + + if (distSquared <= rSquared) { #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - + gSphereVec_Accept_VertexInSphere_Start++; - + #endif - + if (outIntersection != NULL) { *outIntersection = *pointC; } //UUmAssert(wouldHaveBailed == UUcFalse); - result = UUcTrue; + result = UUcTrue; goto exit; } - + distSquared = UUmSQR(Cx - endPoint.x); distSquared += UUmSQR(Cy - endPoint.y); distSquared += UUmSQR(Cz - endPoint.z); - - if (distSquared <= rSquared) + + if (distSquared <= rSquared) { #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - + gSphereVec_Accept_VertexInSphere_End++; - + #endif //UUmAssert(wouldHaveBailed == UUcFalse); @@ -1622,28 +1622,28 @@ AKrGQ_SphereVector( *outIntersection = *pointC; } - result = UUcTrue; + result = UUcTrue; goto exit; } - + t = -(vector_dot_sphere_center - vector_x * Cx - vector_y * Cy - vector_z * Cz) * one_over_vector_length_squared; if (t >= 0.0f && t <= 1.0f) { distSquared = UUmSQR(sphere_center_x + vector_x * t - Cx); distSquared += UUmSQR(sphere_center_y + vector_y * t - Cy); distSquared += UUmSQR(sphere_center_z + vector_z * t - Cz); - + if (distSquared <= rSquared) { if (outIntersection != NULL) { *outIntersection = *pointC; } - + #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - + gSphereVec_Accept_DistEdge++; - + #endif //UUmAssert(wouldHaveBailed == UUcFalse); @@ -1652,10 +1652,10 @@ AKrGQ_SphereVector( } } } - + // Next check the distance of the closest point between each quad // edge and the cylinder axis to see if its less then the radius - + for(i = 0; i < 4; i++) { const M3tPoint3D* pointC; @@ -1669,63 +1669,63 @@ AKrGQ_SphereVector( pointC = pointArray + quad->indices[i]; pointD = pointArray + quad->indices[(i + 1) % 4]; - + Cx = pointC->x; Cy = pointC->y; Cz = pointC->z; - + CDx = pointD->x - Cx; CDy = pointD->y - Cy; CDz = pointD->z - Cz; - + one_over_length_of_cd_squared = 1.0f / (CDx * CDx + CDy * CDy + CDz * CDz); CD_dot_C = CDx * Cx + CDy * Cy + CDz * Cz; - + // Check the distance from the startPoint to the edge t = -(CD_dot_C - CDx * sphere_center_x - CDy * sphere_center_y - CDz * sphere_center_z) * one_over_length_of_cd_squared; if (t >= 0.0f && t <= 1.0f) { px = Cx + CDx * t; distSquared = UUmSQR(px - sphere_center_x); - + py = Cy + CDy * t; distSquared += UUmSQR(py - sphere_center_y); - + pz = Cz + CDz * t; distSquared += UUmSQR(pz - sphere_center_z); - + if (distSquared <= rSquared) { if (outIntersection != NULL) { outIntersection->x = px; outIntersection->y = py; outIntersection->z = pz; } - + #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - + gSphereVec_Accept_Edge_Start++; - + #endif - + //UUmAssert(wouldHaveBailed == UUcFalse); - result = UUcTrue; + result = UUcTrue; goto exit; } } - + // Check the distance from the endPoint to the edge t = -(CD_dot_C - CDx * endPoint.x - CDy * endPoint.y - CDz * endPoint.z) * one_over_length_of_cd_squared; if (t >= 0.0f && t <= 1.0f) { px = Cx + CDx * t; distSquared = UUmSQR(px - endPoint.x); - + py = Cy + CDy * t; distSquared += UUmSQR(py - endPoint.y); - + pz = Cz + CDz * t; distSquared += UUmSQR(pz - endPoint.z); - + if (distSquared <= rSquared) { if (outIntersection != NULL) @@ -1734,49 +1734,49 @@ AKrGQ_SphereVector( outIntersection->y = py; outIntersection->z = pz; } - + #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - + gSphereVec_Accept_Edge_End++; - + #endif //UUmAssert(wouldHaveBailed == UUcFalse); - result = UUcTrue; + result = UUcTrue; goto exit; } } - + // This is from mathematica t = -(vector_dot_sphere_center - sphere_center_x * CDx - sphere_center_y * CDy - sphere_center_z * CDz - vector_x * Cx + CDx * Cx - vector_y * Cy + CDy * Cy - vector_z * Cz + CDz * Cz) / (vector_length_squared - 2 * vector_x * CDx + CDx * CDx - 2 * vector_y * CDy + CDy * CDy - 2 * vector_z * CDz + CDz * CDz); - + if (t >= 0.0f && t <= 1.0f) { px = (Cx + CDx * t); py = (Cy + CDy * t); pz = (Cz + CDz * t); - - distSquared = UUmSQR((sphere_center_x + vector_x * t) - px); + + distSquared = UUmSQR((sphere_center_x + vector_x * t) - px); distSquared += UUmSQR((sphere_center_y + vector_y * t) - py); distSquared += UUmSQR((sphere_center_z + vector_z * t) - pz); - + if (distSquared <= rSquared) { if (outIntersection != NULL) { outIntersection->x = px; outIntersection->y = py; outIntersection->z = pz; } - + #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - + gSphereVec_Accept_Edge_Edge++; - + #endif //UUmAssert(wouldHaveBailed == UUcFalse); - result = UUcTrue; + result = UUcTrue; goto exit; } } @@ -1794,13 +1794,13 @@ AKrGQ_SphereVector( outIntersection)) { #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - + gSphereVec_Accept_QuadLine++; - + #endif //UUmAssert(wouldHaveBailed == UUcFalse); - result = UUcTrue; + result = UUcTrue; goto exit; } @@ -1808,22 +1808,22 @@ AKrGQ_SphereVector( result = UUcFalse; exit: - + //if (wouldHaveBailed) UUmAssert(result == UUcFalse); - + #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE - + gSphereVec_Func_Time += UUrMachineTime_High() - funcStart; - + if (result) { gSphereVec_Accept_Total++; } else { gSphereVec_Reject_Total++; } - + #endif - + #if PERFORMANCE_TIMER UUrPerformanceTimer_Exit(AKg_GQ_SphereVector_Timer); #endif @@ -1839,36 +1839,36 @@ AKrEnvironment_Collision_PrintStats( BFtDebugFile* statsFile = NULL; #if BRENTS_CHEESY_COL_PROFILE statsFile = BFrDebugFile_Open("collisionStats.txt"); - + if (statsFile == NULL) return; - + BFrDebugFile_Printf(statsFile, "time per func: %f"UUmNL, (float)gCol_Sphere_Func_Time / (float)gCol_Sphere_Func_Num); BFrDebugFile_Printf(statsFile, "time in findLeafNode per total: %f"UUmNL, (float)gCol_Sphere_FindingLeaf_Time / (float)gCol_Sphere_Func_Time); BFrDebugFile_Printf(statsFile, "time in findGQ per total: %f"UUmNL, (float)gCol_Sphere_FindingGQs_Time / (float)gCol_Sphere_Func_Time); BFrDebugFile_Printf(statsFile, "time in QSV per total: %f"UUmNL, (float)gCol_Sphere_QuadSphereVector_Time / (float)gCol_Sphere_Func_Time); BFrDebugFile_Printf(statsFile, UUmNL); - + BFrDebugFile_Printf(statsFile, "SphereChecks per func: %f"UUmNL, (float)gCol_Sphere_SphereChecks_Num / (float)gCol_Sphere_Func_Num); BFrDebugFile_Printf(statsFile, "LeafNodes per func: %f"UUmNL, (float)gCol_Sphere_LeafNodes_Num / (float)gCol_Sphere_Func_Num); BFrDebugFile_Printf(statsFile, UUmNL); - + BFrDebugFile_Printf(statsFile, "GQs checked per func: %f"UUmNL, (float)gCol_Sphere_GQChecks / (float)gCol_Sphere_Func_Num); BFrDebugFile_Printf(statsFile, "GQs hit per func: %f"UUmNL, (float)gCol_Sphere_GQHits / (float)gCol_Sphere_Func_Num); BFrDebugFile_Printf(statsFile, "GQs hit ration: %f"UUmNL, (float)gCol_Sphere_GQHits / (float)gCol_Sphere_GQChecks); BFrDebugFile_Printf(statsFile, UUmNL); - + BFrDebugFile_Close(statsFile); #endif #if BRENTS_CHEESY_SPHEREVECTOR_PROFILE statsFile = BFrDebugFile_Open("sphereVectorStats.txt"); - + if (statsFile == NULL) return; - + BFrDebugFile_Printf(statsFile, "funcNum\t%d"UUmNL, gSphereVec_Func_Num); BFrDebugFile_Printf(statsFile, "funcTime\t%d"UUmNL, gSphereVec_Func_Time); BFrDebugFile_Printf(statsFile, "time per func\t%f"UUmNL, (float)gSphereVec_Func_Time / (float)gSphereVec_Func_Num); - + BFrDebugFile_Printf(statsFile, "Reject_Total\t%d"UUmNL, gSphereVec_Reject_Total); BFrDebugFile_Printf(statsFile, "Accept_Total\t%d"UUmNL, gSphereVec_Accept_Total); BFrDebugFile_Printf(statsFile, "TrivReject SameSide\t%d"UUmNL, gSphereVec_TrivReject_SameSide); @@ -1882,7 +1882,7 @@ AKrEnvironment_Collision_PrintStats( BFrDebugFile_Printf(statsFile, "Accept_Edge_Start\t%d"UUmNL, gSphereVec_Accept_Edge_Start); BFrDebugFile_Printf(statsFile, "Accept_Edge_End\t%d"UUmNL, gSphereVec_Accept_Edge_End); BFrDebugFile_Printf(statsFile, "Accept_Edge_Edge\t%d"UUmNL, gSphereVec_Accept_Edge_Edge); - + BFrDebugFile_Printf(statsFile, "Reject_Total per func\t%f"UUmNL, (float)gSphereVec_Reject_Total / (float)gSphereVec_Func_Num); BFrDebugFile_Printf(statsFile, "Accept_Total per func\t%f"UUmNL, (float)gSphereVec_Accept_Total / (float)gSphereVec_Func_Num); BFrDebugFile_Printf(statsFile, "TrivReject_SameSide per func\t%f"UUmNL, (float)gSphereVec_TrivReject_SameSide / (float)gSphereVec_Func_Num); @@ -1896,7 +1896,7 @@ AKrEnvironment_Collision_PrintStats( BFrDebugFile_Printf(statsFile, "Accept_Edge_Start per func\t%f"UUmNL, (float)gSphereVec_Accept_Edge_Start / (float)gSphereVec_Func_Num); BFrDebugFile_Printf(statsFile, "Accept_Edge_End per func\t%f"UUmNL, (float)gSphereVec_Accept_Edge_End / (float)gSphereVec_Func_Num); BFrDebugFile_Printf(statsFile, "Accept_Edge_Edge per func\t%f"UUmNL, (float)gSphereVec_Accept_Edge_Edge / (float)gSphereVec_Func_Num); - + BFrDebugFile_Close(statsFile); #endif #endif diff --git a/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Render.c b/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Render.c index c8d0bb6..d90e977 100644 --- a/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Render.c +++ b/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Render.c @@ -1,12 +1,12 @@ /* FILE: BFW_Akira_Render.c - + AUTHOR: Brent H. Pease - + CREATED: October 12, 1998 PURPOSE: environment engine - + Copyright 1997 */ @@ -32,7 +32,7 @@ #include "BFW_Object.h" #include "BFW_Timer.h" - + #include "Akira_Private.h" #include "Oni_GameStatePrivate.h" @@ -136,7 +136,7 @@ AKiBoundingBox_Draw( /* 0 - min, 1 - max - + v X Y Z == ========= 0 0 0 0 @@ -147,7 +147,7 @@ AKiBoundingBox_Draw( 5 1 0 1 6 1 1 0 7 1 1 1 - + Edges ===== 0 -> 1 @@ -168,7 +168,7 @@ AKiBoundingBox_Draw( aligned[0].x = inMinPoint->x; aligned[0].y = inMinPoint->y; aligned[0].z = inMinPoint->z; - + aligned[1].x = inMinPoint->x; aligned[1].y = inMinPoint->y; aligned[1].z = inMaxPoint->z; @@ -176,13 +176,13 @@ AKiBoundingBox_Draw( 2, aligned, inColor); - - + + // 0 -> 2 aligned[0].x = inMinPoint->x; aligned[0].y = inMinPoint->y; aligned[0].z = inMinPoint->z; - + aligned[1].x = inMinPoint->x; aligned[1].y = inMaxPoint->y; aligned[1].z = inMinPoint->z; @@ -190,13 +190,13 @@ AKiBoundingBox_Draw( 2, aligned, inColor); - - + + // 0 -> 4 aligned[0].x = inMinPoint->x; aligned[0].y = inMinPoint->y; aligned[0].z = inMinPoint->z; - + aligned[1].x = inMaxPoint->x; aligned[1].y = inMinPoint->y; aligned[1].z = inMinPoint->z; @@ -204,13 +204,13 @@ AKiBoundingBox_Draw( 2, aligned, inColor); - - + + // 1 -> 3 aligned[0].x = inMinPoint->x; aligned[0].y = inMinPoint->y; aligned[0].z = inMaxPoint->z; - + aligned[1].x = inMinPoint->x; aligned[1].y = inMaxPoint->y; aligned[1].z = inMaxPoint->z; @@ -218,13 +218,13 @@ AKiBoundingBox_Draw( 2, aligned, inColor); - - + + // 1 -> 5 aligned[0].x = inMinPoint->x; aligned[0].y = inMinPoint->y; aligned[0].z = inMaxPoint->z; - + aligned[1].x = inMaxPoint->x; aligned[1].y = inMinPoint->y; aligned[1].z = inMaxPoint->z; @@ -232,12 +232,12 @@ AKiBoundingBox_Draw( 2, aligned, inColor); - + // 2 -> 3 aligned[0].x = inMinPoint->x; aligned[0].y = inMaxPoint->y; aligned[0].z = inMinPoint->z; - + aligned[1].x = inMinPoint->x; aligned[1].y = inMaxPoint->y; aligned[1].z = inMaxPoint->z; @@ -245,13 +245,13 @@ AKiBoundingBox_Draw( 2, aligned, inColor); - - + + // 2 -> 6 aligned[0].x = inMinPoint->x; aligned[0].y = inMaxPoint->y; aligned[0].z = inMinPoint->z; - + aligned[1].x = inMaxPoint->x; aligned[1].y = inMaxPoint->y; aligned[1].z = inMinPoint->z; @@ -259,13 +259,13 @@ AKiBoundingBox_Draw( 2, aligned, inColor); - - + + // 3 -> 7 aligned[0].x = inMinPoint->x; aligned[0].y = inMaxPoint->y; aligned[0].z = inMaxPoint->z; - + aligned[1].x = inMaxPoint->x; aligned[1].y = inMaxPoint->y; aligned[1].z = inMaxPoint->z; @@ -273,13 +273,13 @@ AKiBoundingBox_Draw( 2, aligned, inColor); - - + + // 4 -> 5 aligned[0].x = inMaxPoint->x; aligned[0].y = inMinPoint->y; aligned[0].z = inMinPoint->z; - + aligned[1].x = inMaxPoint->x; aligned[1].y = inMinPoint->y; aligned[1].z = inMaxPoint->z; @@ -287,13 +287,13 @@ AKiBoundingBox_Draw( 2, aligned, inColor); - - + + // 4 -> 6 aligned[0].x = inMaxPoint->x; aligned[0].y = inMinPoint->y; aligned[0].z = inMinPoint->z; - + aligned[1].x = inMaxPoint->x; aligned[1].y = inMaxPoint->y; aligned[1].z = inMinPoint->z; @@ -301,13 +301,13 @@ AKiBoundingBox_Draw( 2, aligned, inColor); - - + + // 5 -> 7 aligned[0].x = inMaxPoint->x; aligned[0].y = inMinPoint->y; aligned[0].z = inMaxPoint->z; - + aligned[1].x = inMaxPoint->x; aligned[1].y = inMaxPoint->y; aligned[1].z = inMaxPoint->z; @@ -315,13 +315,13 @@ AKiBoundingBox_Draw( 2, aligned, inColor); - - + + // 6 -> 7 aligned[0].x = inMaxPoint->x; aligned[0].y = inMaxPoint->y; aligned[0].z = inMinPoint->z; - + aligned[1].x = inMaxPoint->x; aligned[1].y = inMaxPoint->y; aligned[1].z = inMaxPoint->z; @@ -334,29 +334,29 @@ AKiBoundingBox_Draw( #define BRENTS_CHEESY_PROFILE_ONLY_FUNC 0 #define BRENTS_CHEESY_PROFILE 0 - + UUtUns32 funcTime = 0; UUtUns32 funcNum = 0; UUtUns32 funcRayTime = 0; UUtUns32 funcNumRays = 0; - + UUtUns32 funcOctantTime = 0; UUtUns32 funcNumMissOctants = 0; UUtUns32 funcNumHitOctants = 0; UUtUns32 funcNumSkippedOctants = 0; - + UUtUns32 funcMissOctant_QuadTraversalTime = 0; UUtUns32 funcMissOctant_NumQuadTraversals = 0; UUtUns32 funcMissOctant_NumQuadChecks = 0; - + UUtUns32 funcHitOctant_QuadTraversalTime = 0; UUtUns32 funcHitOctant_NumQuadTraversals = 0; UUtUns32 funcHitOctant_NumQuadChecks = 0; - + UUtUns32 funcHitOctant_NumQuadsTillHit = 0; -float AKgIntToFloatDim[9] = +float AKgIntToFloatDim[9] = { AKcMinOTDim, AKcMinOTDim * 2.0f, @@ -371,133 +371,133 @@ float AKgIntToFloatDim[9] = float AKgIntToFloatXYZ[512] = { - -255.000000 * AKcMinOTDim, -254.000000 * AKcMinOTDim, -253.000000 * AKcMinOTDim, -252.000000 * AKcMinOTDim, - -251.000000 * AKcMinOTDim, -250.000000 * AKcMinOTDim, -249.000000 * AKcMinOTDim, -248.000000 * AKcMinOTDim, - -247.000000 * AKcMinOTDim, -246.000000 * AKcMinOTDim, -245.000000 * AKcMinOTDim, -244.000000 * AKcMinOTDim, - -243.000000 * AKcMinOTDim, -242.000000 * AKcMinOTDim, -241.000000 * AKcMinOTDim, -240.000000 * AKcMinOTDim, - -239.000000 * AKcMinOTDim, -238.000000 * AKcMinOTDim, -237.000000 * AKcMinOTDim, -236.000000 * AKcMinOTDim, - -235.000000 * AKcMinOTDim, -234.000000 * AKcMinOTDim, -233.000000 * AKcMinOTDim, -232.000000 * AKcMinOTDim, - -231.000000 * AKcMinOTDim, -230.000000 * AKcMinOTDim, -229.000000 * AKcMinOTDim, -228.000000 * AKcMinOTDim, - -227.000000 * AKcMinOTDim, -226.000000 * AKcMinOTDim, -225.000000 * AKcMinOTDim, -224.000000 * AKcMinOTDim, - -223.000000 * AKcMinOTDim, -222.000000 * AKcMinOTDim, -221.000000 * AKcMinOTDim, -220.000000 * AKcMinOTDim, - -219.000000 * AKcMinOTDim, -218.000000 * AKcMinOTDim, -217.000000 * AKcMinOTDim, -216.000000 * AKcMinOTDim, - -215.000000 * AKcMinOTDim, -214.000000 * AKcMinOTDim, -213.000000 * AKcMinOTDim, -212.000000 * AKcMinOTDim, - -211.000000 * AKcMinOTDim, -210.000000 * AKcMinOTDim, -209.000000 * AKcMinOTDim, -208.000000 * AKcMinOTDim, - -207.000000 * AKcMinOTDim, -206.000000 * AKcMinOTDim, -205.000000 * AKcMinOTDim, -204.000000 * AKcMinOTDim, - -203.000000 * AKcMinOTDim, -202.000000 * AKcMinOTDim, -201.000000 * AKcMinOTDim, -200.000000 * AKcMinOTDim, - -199.000000 * AKcMinOTDim, -198.000000 * AKcMinOTDim, -197.000000 * AKcMinOTDim, -196.000000 * AKcMinOTDim, - -195.000000 * AKcMinOTDim, -194.000000 * AKcMinOTDim, -193.000000 * AKcMinOTDim, -192.000000 * AKcMinOTDim, - -191.000000 * AKcMinOTDim, -190.000000 * AKcMinOTDim, -189.000000 * AKcMinOTDim, -188.000000 * AKcMinOTDim, - -187.000000 * AKcMinOTDim, -186.000000 * AKcMinOTDim, -185.000000 * AKcMinOTDim, -184.000000 * AKcMinOTDim, - -183.000000 * AKcMinOTDim, -182.000000 * AKcMinOTDim, -181.000000 * AKcMinOTDim, -180.000000 * AKcMinOTDim, - -179.000000 * AKcMinOTDim, -178.000000 * AKcMinOTDim, -177.000000 * AKcMinOTDim, -176.000000 * AKcMinOTDim, - -175.000000 * AKcMinOTDim, -174.000000 * AKcMinOTDim, -173.000000 * AKcMinOTDim, -172.000000 * AKcMinOTDim, - -171.000000 * AKcMinOTDim, -170.000000 * AKcMinOTDim, -169.000000 * AKcMinOTDim, -168.000000 * AKcMinOTDim, - -167.000000 * AKcMinOTDim, -166.000000 * AKcMinOTDim, -165.000000 * AKcMinOTDim, -164.000000 * AKcMinOTDim, - -163.000000 * AKcMinOTDim, -162.000000 * AKcMinOTDim, -161.000000 * AKcMinOTDim, -160.000000 * AKcMinOTDim, - -159.000000 * AKcMinOTDim, -158.000000 * AKcMinOTDim, -157.000000 * AKcMinOTDim, -156.000000 * AKcMinOTDim, - -155.000000 * AKcMinOTDim, -154.000000 * AKcMinOTDim, -153.000000 * AKcMinOTDim, -152.000000 * AKcMinOTDim, - -151.000000 * AKcMinOTDim, -150.000000 * AKcMinOTDim, -149.000000 * AKcMinOTDim, -148.000000 * AKcMinOTDim, - -147.000000 * AKcMinOTDim, -146.000000 * AKcMinOTDim, -145.000000 * AKcMinOTDim, -144.000000 * AKcMinOTDim, - -143.000000 * AKcMinOTDim, -142.000000 * AKcMinOTDim, -141.000000 * AKcMinOTDim, -140.000000 * AKcMinOTDim, - -139.000000 * AKcMinOTDim, -138.000000 * AKcMinOTDim, -137.000000 * AKcMinOTDim, -136.000000 * AKcMinOTDim, - -135.000000 * AKcMinOTDim, -134.000000 * AKcMinOTDim, -133.000000 * AKcMinOTDim, -132.000000 * AKcMinOTDim, - -131.000000 * AKcMinOTDim, -130.000000 * AKcMinOTDim, -129.000000 * AKcMinOTDim, -128.000000 * AKcMinOTDim, - -127.000000 * AKcMinOTDim, -126.000000 * AKcMinOTDim, -125.000000 * AKcMinOTDim, -124.000000 * AKcMinOTDim, - -123.000000 * AKcMinOTDim, -122.000000 * AKcMinOTDim, -121.000000 * AKcMinOTDim, -120.000000 * AKcMinOTDim, - -119.000000 * AKcMinOTDim, -118.000000 * AKcMinOTDim, -117.000000 * AKcMinOTDim, -116.000000 * AKcMinOTDim, - -115.000000 * AKcMinOTDim, -114.000000 * AKcMinOTDim, -113.000000 * AKcMinOTDim, -112.000000 * AKcMinOTDim, - -111.000000 * AKcMinOTDim, -110.000000 * AKcMinOTDim, -109.000000 * AKcMinOTDim, -108.000000 * AKcMinOTDim, - -107.000000 * AKcMinOTDim, -106.000000 * AKcMinOTDim, -105.000000 * AKcMinOTDim, -104.000000 * AKcMinOTDim, - -103.000000 * AKcMinOTDim, -102.000000 * AKcMinOTDim, -101.000000 * AKcMinOTDim, -100.000000 * AKcMinOTDim, - -99.000000 * AKcMinOTDim, -98.000000 * AKcMinOTDim, -97.000000 * AKcMinOTDim, -96.000000 * AKcMinOTDim, - -95.000000 * AKcMinOTDim, -94.000000 * AKcMinOTDim, -93.000000 * AKcMinOTDim, -92.000000 * AKcMinOTDim, - -91.000000 * AKcMinOTDim, -90.000000 * AKcMinOTDim, -89.000000 * AKcMinOTDim, -88.000000 * AKcMinOTDim, - -87.000000 * AKcMinOTDim, -86.000000 * AKcMinOTDim, -85.000000 * AKcMinOTDim, -84.000000 * AKcMinOTDim, - -83.000000 * AKcMinOTDim, -82.000000 * AKcMinOTDim, -81.000000 * AKcMinOTDim, -80.000000 * AKcMinOTDim, - -79.000000 * AKcMinOTDim, -78.000000 * AKcMinOTDim, -77.000000 * AKcMinOTDim, -76.000000 * AKcMinOTDim, - -75.000000 * AKcMinOTDim, -74.000000 * AKcMinOTDim, -73.000000 * AKcMinOTDim, -72.000000 * AKcMinOTDim, - -71.000000 * AKcMinOTDim, -70.000000 * AKcMinOTDim, -69.000000 * AKcMinOTDim, -68.000000 * AKcMinOTDim, - -67.000000 * AKcMinOTDim, -66.000000 * AKcMinOTDim, -65.000000 * AKcMinOTDim, -64.000000 * AKcMinOTDim, - -63.000000 * AKcMinOTDim, -62.000000 * AKcMinOTDim, -61.000000 * AKcMinOTDim, -60.000000 * AKcMinOTDim, - -59.000000 * AKcMinOTDim, -58.000000 * AKcMinOTDim, -57.000000 * AKcMinOTDim, -56.000000 * AKcMinOTDim, - -55.000000 * AKcMinOTDim, -54.000000 * AKcMinOTDim, -53.000000 * AKcMinOTDim, -52.000000 * AKcMinOTDim, - -51.000000 * AKcMinOTDim, -50.000000 * AKcMinOTDim, -49.000000 * AKcMinOTDim, -48.000000 * AKcMinOTDim, - -47.000000 * AKcMinOTDim, -46.000000 * AKcMinOTDim, -45.000000 * AKcMinOTDim, -44.000000 * AKcMinOTDim, - -43.000000 * AKcMinOTDim, -42.000000 * AKcMinOTDim, -41.000000 * AKcMinOTDim, -40.000000 * AKcMinOTDim, - -39.000000 * AKcMinOTDim, -38.000000 * AKcMinOTDim, -37.000000 * AKcMinOTDim, -36.000000 * AKcMinOTDim, - -35.000000 * AKcMinOTDim, -34.000000 * AKcMinOTDim, -33.000000 * AKcMinOTDim, -32.000000 * AKcMinOTDim, - -31.000000 * AKcMinOTDim, -30.000000 * AKcMinOTDim, -29.000000 * AKcMinOTDim, -28.000000 * AKcMinOTDim, - -27.000000 * AKcMinOTDim, -26.000000 * AKcMinOTDim, -25.000000 * AKcMinOTDim, -24.000000 * AKcMinOTDim, - -23.000000 * AKcMinOTDim, -22.000000 * AKcMinOTDim, -21.000000 * AKcMinOTDim, -20.000000 * AKcMinOTDim, - -19.000000 * AKcMinOTDim, -18.000000 * AKcMinOTDim, -17.000000 * AKcMinOTDim, -16.000000 * AKcMinOTDim, - -15.000000 * AKcMinOTDim, -14.000000 * AKcMinOTDim, -13.000000 * AKcMinOTDim, -12.000000 * AKcMinOTDim, - -11.000000 * AKcMinOTDim, -10.000000 * AKcMinOTDim, -9.000000 * AKcMinOTDim, -8.000000 * AKcMinOTDim, - -7.000000 * AKcMinOTDim, -6.000000 * AKcMinOTDim, -5.000000 * AKcMinOTDim, -4.000000 * AKcMinOTDim, - -3.000000 * AKcMinOTDim, -2.000000 * AKcMinOTDim, -1.000000 * AKcMinOTDim, 0.000000 * AKcMinOTDim, - 1.000000 * AKcMinOTDim, 2.000000 * AKcMinOTDim, 3.000000 * AKcMinOTDim, 4.000000 * AKcMinOTDim, - 5.000000 * AKcMinOTDim, 6.000000 * AKcMinOTDim, 7.000000 * AKcMinOTDim, 8.000000 * AKcMinOTDim, - 9.000000 * AKcMinOTDim, 10.000000 * AKcMinOTDim, 11.000000 * AKcMinOTDim, 12.000000 * AKcMinOTDim, - 13.000000 * AKcMinOTDim, 14.000000 * AKcMinOTDim, 15.000000 * AKcMinOTDim, 16.000000 * AKcMinOTDim, - 17.000000 * AKcMinOTDim, 18.000000 * AKcMinOTDim, 19.000000 * AKcMinOTDim, 20.000000 * AKcMinOTDim, - 21.000000 * AKcMinOTDim, 22.000000 * AKcMinOTDim, 23.000000 * AKcMinOTDim, 24.000000 * AKcMinOTDim, - 25.000000 * AKcMinOTDim, 26.000000 * AKcMinOTDim, 27.000000 * AKcMinOTDim, 28.000000 * AKcMinOTDim, - 29.000000 * AKcMinOTDim, 30.000000 * AKcMinOTDim, 31.000000 * AKcMinOTDim, 32.000000 * AKcMinOTDim, - 33.000000 * AKcMinOTDim, 34.000000 * AKcMinOTDim, 35.000000 * AKcMinOTDim, 36.000000 * AKcMinOTDim, - 37.000000 * AKcMinOTDim, 38.000000 * AKcMinOTDim, 39.000000 * AKcMinOTDim, 40.000000 * AKcMinOTDim, - 41.000000 * AKcMinOTDim, 42.000000 * AKcMinOTDim, 43.000000 * AKcMinOTDim, 44.000000 * AKcMinOTDim, - 45.000000 * AKcMinOTDim, 46.000000 * AKcMinOTDim, 47.000000 * AKcMinOTDim, 48.000000 * AKcMinOTDim, - 49.000000 * AKcMinOTDim, 50.000000 * AKcMinOTDim, 51.000000 * AKcMinOTDim, 52.000000 * AKcMinOTDim, - 53.000000 * AKcMinOTDim, 54.000000 * AKcMinOTDim, 55.000000 * AKcMinOTDim, 56.000000 * AKcMinOTDim, - 57.000000 * AKcMinOTDim, 58.000000 * AKcMinOTDim, 59.000000 * AKcMinOTDim, 60.000000 * AKcMinOTDim, - 61.000000 * AKcMinOTDim, 62.000000 * AKcMinOTDim, 63.000000 * AKcMinOTDim, 64.000000 * AKcMinOTDim, - 65.000000 * AKcMinOTDim, 66.000000 * AKcMinOTDim, 67.000000 * AKcMinOTDim, 68.000000 * AKcMinOTDim, - 69.000000 * AKcMinOTDim, 70.000000 * AKcMinOTDim, 71.000000 * AKcMinOTDim, 72.000000 * AKcMinOTDim, - 73.000000 * AKcMinOTDim, 74.000000 * AKcMinOTDim, 75.000000 * AKcMinOTDim, 76.000000 * AKcMinOTDim, - 77.000000 * AKcMinOTDim, 78.000000 * AKcMinOTDim, 79.000000 * AKcMinOTDim, 80.000000 * AKcMinOTDim, - 81.000000 * AKcMinOTDim, 82.000000 * AKcMinOTDim, 83.000000 * AKcMinOTDim, 84.000000 * AKcMinOTDim, - 85.000000 * AKcMinOTDim, 86.000000 * AKcMinOTDim, 87.000000 * AKcMinOTDim, 88.000000 * AKcMinOTDim, - 89.000000 * AKcMinOTDim, 90.000000 * AKcMinOTDim, 91.000000 * AKcMinOTDim, 92.000000 * AKcMinOTDim, - 93.000000 * AKcMinOTDim, 94.000000 * AKcMinOTDim, 95.000000 * AKcMinOTDim, 96.000000 * AKcMinOTDim, - 97.000000 * AKcMinOTDim, 98.000000 * AKcMinOTDim, 99.000000 * AKcMinOTDim, 100.000000 * AKcMinOTDim, - 101.000000 * AKcMinOTDim, 102.000000 * AKcMinOTDim, 103.000000 * AKcMinOTDim, 104.000000 * AKcMinOTDim, - 105.000000 * AKcMinOTDim, 106.000000 * AKcMinOTDim, 107.000000 * AKcMinOTDim, 108.000000 * AKcMinOTDim, - 109.000000 * AKcMinOTDim, 110.000000 * AKcMinOTDim, 111.000000 * AKcMinOTDim, 112.000000 * AKcMinOTDim, - 113.000000 * AKcMinOTDim, 114.000000 * AKcMinOTDim, 115.000000 * AKcMinOTDim, 116.000000 * AKcMinOTDim, - 117.000000 * AKcMinOTDim, 118.000000 * AKcMinOTDim, 119.000000 * AKcMinOTDim, 120.000000 * AKcMinOTDim, - 121.000000 * AKcMinOTDim, 122.000000 * AKcMinOTDim, 123.000000 * AKcMinOTDim, 124.000000 * AKcMinOTDim, - 125.000000 * AKcMinOTDim, 126.000000 * AKcMinOTDim, 127.000000 * AKcMinOTDim, 128.000000 * AKcMinOTDim, - 129.000000 * AKcMinOTDim, 130.000000 * AKcMinOTDim, 131.000000 * AKcMinOTDim, 132.000000 * AKcMinOTDim, - 133.000000 * AKcMinOTDim, 134.000000 * AKcMinOTDim, 135.000000 * AKcMinOTDim, 136.000000 * AKcMinOTDim, - 137.000000 * AKcMinOTDim, 138.000000 * AKcMinOTDim, 139.000000 * AKcMinOTDim, 140.000000 * AKcMinOTDim, - 141.000000 * AKcMinOTDim, 142.000000 * AKcMinOTDim, 143.000000 * AKcMinOTDim, 144.000000 * AKcMinOTDim, - 145.000000 * AKcMinOTDim, 146.000000 * AKcMinOTDim, 147.000000 * AKcMinOTDim, 148.000000 * AKcMinOTDim, - 149.000000 * AKcMinOTDim, 150.000000 * AKcMinOTDim, 151.000000 * AKcMinOTDim, 152.000000 * AKcMinOTDim, - 153.000000 * AKcMinOTDim, 154.000000 * AKcMinOTDim, 155.000000 * AKcMinOTDim, 156.000000 * AKcMinOTDim, - 157.000000 * AKcMinOTDim, 158.000000 * AKcMinOTDim, 159.000000 * AKcMinOTDim, 160.000000 * AKcMinOTDim, - 161.000000 * AKcMinOTDim, 162.000000 * AKcMinOTDim, 163.000000 * AKcMinOTDim, 164.000000 * AKcMinOTDim, - 165.000000 * AKcMinOTDim, 166.000000 * AKcMinOTDim, 167.000000 * AKcMinOTDim, 168.000000 * AKcMinOTDim, - 169.000000 * AKcMinOTDim, 170.000000 * AKcMinOTDim, 171.000000 * AKcMinOTDim, 172.000000 * AKcMinOTDim, - 173.000000 * AKcMinOTDim, 174.000000 * AKcMinOTDim, 175.000000 * AKcMinOTDim, 176.000000 * AKcMinOTDim, - 177.000000 * AKcMinOTDim, 178.000000 * AKcMinOTDim, 179.000000 * AKcMinOTDim, 180.000000 * AKcMinOTDim, - 181.000000 * AKcMinOTDim, 182.000000 * AKcMinOTDim, 183.000000 * AKcMinOTDim, 184.000000 * AKcMinOTDim, - 185.000000 * AKcMinOTDim, 186.000000 * AKcMinOTDim, 187.000000 * AKcMinOTDim, 188.000000 * AKcMinOTDim, - 189.000000 * AKcMinOTDim, 190.000000 * AKcMinOTDim, 191.000000 * AKcMinOTDim, 192.000000 * AKcMinOTDim, - 193.000000 * AKcMinOTDim, 194.000000 * AKcMinOTDim, 195.000000 * AKcMinOTDim, 196.000000 * AKcMinOTDim, - 197.000000 * AKcMinOTDim, 198.000000 * AKcMinOTDim, 199.000000 * AKcMinOTDim, 200.000000 * AKcMinOTDim, - 201.000000 * AKcMinOTDim, 202.000000 * AKcMinOTDim, 203.000000 * AKcMinOTDim, 204.000000 * AKcMinOTDim, - 205.000000 * AKcMinOTDim, 206.000000 * AKcMinOTDim, 207.000000 * AKcMinOTDim, 208.000000 * AKcMinOTDim, - 209.000000 * AKcMinOTDim, 210.000000 * AKcMinOTDim, 211.000000 * AKcMinOTDim, 212.000000 * AKcMinOTDim, - 213.000000 * AKcMinOTDim, 214.000000 * AKcMinOTDim, 215.000000 * AKcMinOTDim, 216.000000 * AKcMinOTDim, - 217.000000 * AKcMinOTDim, 218.000000 * AKcMinOTDim, 219.000000 * AKcMinOTDim, 220.000000 * AKcMinOTDim, - 221.000000 * AKcMinOTDim, 222.000000 * AKcMinOTDim, 223.000000 * AKcMinOTDim, 224.000000 * AKcMinOTDim, - 225.000000 * AKcMinOTDim, 226.000000 * AKcMinOTDim, 227.000000 * AKcMinOTDim, 228.000000 * AKcMinOTDim, - 229.000000 * AKcMinOTDim, 230.000000 * AKcMinOTDim, 231.000000 * AKcMinOTDim, 232.000000 * AKcMinOTDim, - 233.000000 * AKcMinOTDim, 234.000000 * AKcMinOTDim, 235.000000 * AKcMinOTDim, 236.000000 * AKcMinOTDim, - 237.000000 * AKcMinOTDim, 238.000000 * AKcMinOTDim, 239.000000 * AKcMinOTDim, 240.000000 * AKcMinOTDim, - 241.000000 * AKcMinOTDim, 242.000000 * AKcMinOTDim, 243.000000 * AKcMinOTDim, 244.000000 * AKcMinOTDim, - 245.000000 * AKcMinOTDim, 246.000000 * AKcMinOTDim, 247.000000 * AKcMinOTDim, 248.000000 * AKcMinOTDim, - 249.000000 * AKcMinOTDim, 250.000000 * AKcMinOTDim, 251.000000 * AKcMinOTDim, 252.000000 * AKcMinOTDim, + -255.000000 * AKcMinOTDim, -254.000000 * AKcMinOTDim, -253.000000 * AKcMinOTDim, -252.000000 * AKcMinOTDim, + -251.000000 * AKcMinOTDim, -250.000000 * AKcMinOTDim, -249.000000 * AKcMinOTDim, -248.000000 * AKcMinOTDim, + -247.000000 * AKcMinOTDim, -246.000000 * AKcMinOTDim, -245.000000 * AKcMinOTDim, -244.000000 * AKcMinOTDim, + -243.000000 * AKcMinOTDim, -242.000000 * AKcMinOTDim, -241.000000 * AKcMinOTDim, -240.000000 * AKcMinOTDim, + -239.000000 * AKcMinOTDim, -238.000000 * AKcMinOTDim, -237.000000 * AKcMinOTDim, -236.000000 * AKcMinOTDim, + -235.000000 * AKcMinOTDim, -234.000000 * AKcMinOTDim, -233.000000 * AKcMinOTDim, -232.000000 * AKcMinOTDim, + -231.000000 * AKcMinOTDim, -230.000000 * AKcMinOTDim, -229.000000 * AKcMinOTDim, -228.000000 * AKcMinOTDim, + -227.000000 * AKcMinOTDim, -226.000000 * AKcMinOTDim, -225.000000 * AKcMinOTDim, -224.000000 * AKcMinOTDim, + -223.000000 * AKcMinOTDim, -222.000000 * AKcMinOTDim, -221.000000 * AKcMinOTDim, -220.000000 * AKcMinOTDim, + -219.000000 * AKcMinOTDim, -218.000000 * AKcMinOTDim, -217.000000 * AKcMinOTDim, -216.000000 * AKcMinOTDim, + -215.000000 * AKcMinOTDim, -214.000000 * AKcMinOTDim, -213.000000 * AKcMinOTDim, -212.000000 * AKcMinOTDim, + -211.000000 * AKcMinOTDim, -210.000000 * AKcMinOTDim, -209.000000 * AKcMinOTDim, -208.000000 * AKcMinOTDim, + -207.000000 * AKcMinOTDim, -206.000000 * AKcMinOTDim, -205.000000 * AKcMinOTDim, -204.000000 * AKcMinOTDim, + -203.000000 * AKcMinOTDim, -202.000000 * AKcMinOTDim, -201.000000 * AKcMinOTDim, -200.000000 * AKcMinOTDim, + -199.000000 * AKcMinOTDim, -198.000000 * AKcMinOTDim, -197.000000 * AKcMinOTDim, -196.000000 * AKcMinOTDim, + -195.000000 * AKcMinOTDim, -194.000000 * AKcMinOTDim, -193.000000 * AKcMinOTDim, -192.000000 * AKcMinOTDim, + -191.000000 * AKcMinOTDim, -190.000000 * AKcMinOTDim, -189.000000 * AKcMinOTDim, -188.000000 * AKcMinOTDim, + -187.000000 * AKcMinOTDim, -186.000000 * AKcMinOTDim, -185.000000 * AKcMinOTDim, -184.000000 * AKcMinOTDim, + -183.000000 * AKcMinOTDim, -182.000000 * AKcMinOTDim, -181.000000 * AKcMinOTDim, -180.000000 * AKcMinOTDim, + -179.000000 * AKcMinOTDim, -178.000000 * AKcMinOTDim, -177.000000 * AKcMinOTDim, -176.000000 * AKcMinOTDim, + -175.000000 * AKcMinOTDim, -174.000000 * AKcMinOTDim, -173.000000 * AKcMinOTDim, -172.000000 * AKcMinOTDim, + -171.000000 * AKcMinOTDim, -170.000000 * AKcMinOTDim, -169.000000 * AKcMinOTDim, -168.000000 * AKcMinOTDim, + -167.000000 * AKcMinOTDim, -166.000000 * AKcMinOTDim, -165.000000 * AKcMinOTDim, -164.000000 * AKcMinOTDim, + -163.000000 * AKcMinOTDim, -162.000000 * AKcMinOTDim, -161.000000 * AKcMinOTDim, -160.000000 * AKcMinOTDim, + -159.000000 * AKcMinOTDim, -158.000000 * AKcMinOTDim, -157.000000 * AKcMinOTDim, -156.000000 * AKcMinOTDim, + -155.000000 * AKcMinOTDim, -154.000000 * AKcMinOTDim, -153.000000 * AKcMinOTDim, -152.000000 * AKcMinOTDim, + -151.000000 * AKcMinOTDim, -150.000000 * AKcMinOTDim, -149.000000 * AKcMinOTDim, -148.000000 * AKcMinOTDim, + -147.000000 * AKcMinOTDim, -146.000000 * AKcMinOTDim, -145.000000 * AKcMinOTDim, -144.000000 * AKcMinOTDim, + -143.000000 * AKcMinOTDim, -142.000000 * AKcMinOTDim, -141.000000 * AKcMinOTDim, -140.000000 * AKcMinOTDim, + -139.000000 * AKcMinOTDim, -138.000000 * AKcMinOTDim, -137.000000 * AKcMinOTDim, -136.000000 * AKcMinOTDim, + -135.000000 * AKcMinOTDim, -134.000000 * AKcMinOTDim, -133.000000 * AKcMinOTDim, -132.000000 * AKcMinOTDim, + -131.000000 * AKcMinOTDim, -130.000000 * AKcMinOTDim, -129.000000 * AKcMinOTDim, -128.000000 * AKcMinOTDim, + -127.000000 * AKcMinOTDim, -126.000000 * AKcMinOTDim, -125.000000 * AKcMinOTDim, -124.000000 * AKcMinOTDim, + -123.000000 * AKcMinOTDim, -122.000000 * AKcMinOTDim, -121.000000 * AKcMinOTDim, -120.000000 * AKcMinOTDim, + -119.000000 * AKcMinOTDim, -118.000000 * AKcMinOTDim, -117.000000 * AKcMinOTDim, -116.000000 * AKcMinOTDim, + -115.000000 * AKcMinOTDim, -114.000000 * AKcMinOTDim, -113.000000 * AKcMinOTDim, -112.000000 * AKcMinOTDim, + -111.000000 * AKcMinOTDim, -110.000000 * AKcMinOTDim, -109.000000 * AKcMinOTDim, -108.000000 * AKcMinOTDim, + -107.000000 * AKcMinOTDim, -106.000000 * AKcMinOTDim, -105.000000 * AKcMinOTDim, -104.000000 * AKcMinOTDim, + -103.000000 * AKcMinOTDim, -102.000000 * AKcMinOTDim, -101.000000 * AKcMinOTDim, -100.000000 * AKcMinOTDim, + -99.000000 * AKcMinOTDim, -98.000000 * AKcMinOTDim, -97.000000 * AKcMinOTDim, -96.000000 * AKcMinOTDim, + -95.000000 * AKcMinOTDim, -94.000000 * AKcMinOTDim, -93.000000 * AKcMinOTDim, -92.000000 * AKcMinOTDim, + -91.000000 * AKcMinOTDim, -90.000000 * AKcMinOTDim, -89.000000 * AKcMinOTDim, -88.000000 * AKcMinOTDim, + -87.000000 * AKcMinOTDim, -86.000000 * AKcMinOTDim, -85.000000 * AKcMinOTDim, -84.000000 * AKcMinOTDim, + -83.000000 * AKcMinOTDim, -82.000000 * AKcMinOTDim, -81.000000 * AKcMinOTDim, -80.000000 * AKcMinOTDim, + -79.000000 * AKcMinOTDim, -78.000000 * AKcMinOTDim, -77.000000 * AKcMinOTDim, -76.000000 * AKcMinOTDim, + -75.000000 * AKcMinOTDim, -74.000000 * AKcMinOTDim, -73.000000 * AKcMinOTDim, -72.000000 * AKcMinOTDim, + -71.000000 * AKcMinOTDim, -70.000000 * AKcMinOTDim, -69.000000 * AKcMinOTDim, -68.000000 * AKcMinOTDim, + -67.000000 * AKcMinOTDim, -66.000000 * AKcMinOTDim, -65.000000 * AKcMinOTDim, -64.000000 * AKcMinOTDim, + -63.000000 * AKcMinOTDim, -62.000000 * AKcMinOTDim, -61.000000 * AKcMinOTDim, -60.000000 * AKcMinOTDim, + -59.000000 * AKcMinOTDim, -58.000000 * AKcMinOTDim, -57.000000 * AKcMinOTDim, -56.000000 * AKcMinOTDim, + -55.000000 * AKcMinOTDim, -54.000000 * AKcMinOTDim, -53.000000 * AKcMinOTDim, -52.000000 * AKcMinOTDim, + -51.000000 * AKcMinOTDim, -50.000000 * AKcMinOTDim, -49.000000 * AKcMinOTDim, -48.000000 * AKcMinOTDim, + -47.000000 * AKcMinOTDim, -46.000000 * AKcMinOTDim, -45.000000 * AKcMinOTDim, -44.000000 * AKcMinOTDim, + -43.000000 * AKcMinOTDim, -42.000000 * AKcMinOTDim, -41.000000 * AKcMinOTDim, -40.000000 * AKcMinOTDim, + -39.000000 * AKcMinOTDim, -38.000000 * AKcMinOTDim, -37.000000 * AKcMinOTDim, -36.000000 * AKcMinOTDim, + -35.000000 * AKcMinOTDim, -34.000000 * AKcMinOTDim, -33.000000 * AKcMinOTDim, -32.000000 * AKcMinOTDim, + -31.000000 * AKcMinOTDim, -30.000000 * AKcMinOTDim, -29.000000 * AKcMinOTDim, -28.000000 * AKcMinOTDim, + -27.000000 * AKcMinOTDim, -26.000000 * AKcMinOTDim, -25.000000 * AKcMinOTDim, -24.000000 * AKcMinOTDim, + -23.000000 * AKcMinOTDim, -22.000000 * AKcMinOTDim, -21.000000 * AKcMinOTDim, -20.000000 * AKcMinOTDim, + -19.000000 * AKcMinOTDim, -18.000000 * AKcMinOTDim, -17.000000 * AKcMinOTDim, -16.000000 * AKcMinOTDim, + -15.000000 * AKcMinOTDim, -14.000000 * AKcMinOTDim, -13.000000 * AKcMinOTDim, -12.000000 * AKcMinOTDim, + -11.000000 * AKcMinOTDim, -10.000000 * AKcMinOTDim, -9.000000 * AKcMinOTDim, -8.000000 * AKcMinOTDim, + -7.000000 * AKcMinOTDim, -6.000000 * AKcMinOTDim, -5.000000 * AKcMinOTDim, -4.000000 * AKcMinOTDim, + -3.000000 * AKcMinOTDim, -2.000000 * AKcMinOTDim, -1.000000 * AKcMinOTDim, 0.000000 * AKcMinOTDim, + 1.000000 * AKcMinOTDim, 2.000000 * AKcMinOTDim, 3.000000 * AKcMinOTDim, 4.000000 * AKcMinOTDim, + 5.000000 * AKcMinOTDim, 6.000000 * AKcMinOTDim, 7.000000 * AKcMinOTDim, 8.000000 * AKcMinOTDim, + 9.000000 * AKcMinOTDim, 10.000000 * AKcMinOTDim, 11.000000 * AKcMinOTDim, 12.000000 * AKcMinOTDim, + 13.000000 * AKcMinOTDim, 14.000000 * AKcMinOTDim, 15.000000 * AKcMinOTDim, 16.000000 * AKcMinOTDim, + 17.000000 * AKcMinOTDim, 18.000000 * AKcMinOTDim, 19.000000 * AKcMinOTDim, 20.000000 * AKcMinOTDim, + 21.000000 * AKcMinOTDim, 22.000000 * AKcMinOTDim, 23.000000 * AKcMinOTDim, 24.000000 * AKcMinOTDim, + 25.000000 * AKcMinOTDim, 26.000000 * AKcMinOTDim, 27.000000 * AKcMinOTDim, 28.000000 * AKcMinOTDim, + 29.000000 * AKcMinOTDim, 30.000000 * AKcMinOTDim, 31.000000 * AKcMinOTDim, 32.000000 * AKcMinOTDim, + 33.000000 * AKcMinOTDim, 34.000000 * AKcMinOTDim, 35.000000 * AKcMinOTDim, 36.000000 * AKcMinOTDim, + 37.000000 * AKcMinOTDim, 38.000000 * AKcMinOTDim, 39.000000 * AKcMinOTDim, 40.000000 * AKcMinOTDim, + 41.000000 * AKcMinOTDim, 42.000000 * AKcMinOTDim, 43.000000 * AKcMinOTDim, 44.000000 * AKcMinOTDim, + 45.000000 * AKcMinOTDim, 46.000000 * AKcMinOTDim, 47.000000 * AKcMinOTDim, 48.000000 * AKcMinOTDim, + 49.000000 * AKcMinOTDim, 50.000000 * AKcMinOTDim, 51.000000 * AKcMinOTDim, 52.000000 * AKcMinOTDim, + 53.000000 * AKcMinOTDim, 54.000000 * AKcMinOTDim, 55.000000 * AKcMinOTDim, 56.000000 * AKcMinOTDim, + 57.000000 * AKcMinOTDim, 58.000000 * AKcMinOTDim, 59.000000 * AKcMinOTDim, 60.000000 * AKcMinOTDim, + 61.000000 * AKcMinOTDim, 62.000000 * AKcMinOTDim, 63.000000 * AKcMinOTDim, 64.000000 * AKcMinOTDim, + 65.000000 * AKcMinOTDim, 66.000000 * AKcMinOTDim, 67.000000 * AKcMinOTDim, 68.000000 * AKcMinOTDim, + 69.000000 * AKcMinOTDim, 70.000000 * AKcMinOTDim, 71.000000 * AKcMinOTDim, 72.000000 * AKcMinOTDim, + 73.000000 * AKcMinOTDim, 74.000000 * AKcMinOTDim, 75.000000 * AKcMinOTDim, 76.000000 * AKcMinOTDim, + 77.000000 * AKcMinOTDim, 78.000000 * AKcMinOTDim, 79.000000 * AKcMinOTDim, 80.000000 * AKcMinOTDim, + 81.000000 * AKcMinOTDim, 82.000000 * AKcMinOTDim, 83.000000 * AKcMinOTDim, 84.000000 * AKcMinOTDim, + 85.000000 * AKcMinOTDim, 86.000000 * AKcMinOTDim, 87.000000 * AKcMinOTDim, 88.000000 * AKcMinOTDim, + 89.000000 * AKcMinOTDim, 90.000000 * AKcMinOTDim, 91.000000 * AKcMinOTDim, 92.000000 * AKcMinOTDim, + 93.000000 * AKcMinOTDim, 94.000000 * AKcMinOTDim, 95.000000 * AKcMinOTDim, 96.000000 * AKcMinOTDim, + 97.000000 * AKcMinOTDim, 98.000000 * AKcMinOTDim, 99.000000 * AKcMinOTDim, 100.000000 * AKcMinOTDim, + 101.000000 * AKcMinOTDim, 102.000000 * AKcMinOTDim, 103.000000 * AKcMinOTDim, 104.000000 * AKcMinOTDim, + 105.000000 * AKcMinOTDim, 106.000000 * AKcMinOTDim, 107.000000 * AKcMinOTDim, 108.000000 * AKcMinOTDim, + 109.000000 * AKcMinOTDim, 110.000000 * AKcMinOTDim, 111.000000 * AKcMinOTDim, 112.000000 * AKcMinOTDim, + 113.000000 * AKcMinOTDim, 114.000000 * AKcMinOTDim, 115.000000 * AKcMinOTDim, 116.000000 * AKcMinOTDim, + 117.000000 * AKcMinOTDim, 118.000000 * AKcMinOTDim, 119.000000 * AKcMinOTDim, 120.000000 * AKcMinOTDim, + 121.000000 * AKcMinOTDim, 122.000000 * AKcMinOTDim, 123.000000 * AKcMinOTDim, 124.000000 * AKcMinOTDim, + 125.000000 * AKcMinOTDim, 126.000000 * AKcMinOTDim, 127.000000 * AKcMinOTDim, 128.000000 * AKcMinOTDim, + 129.000000 * AKcMinOTDim, 130.000000 * AKcMinOTDim, 131.000000 * AKcMinOTDim, 132.000000 * AKcMinOTDim, + 133.000000 * AKcMinOTDim, 134.000000 * AKcMinOTDim, 135.000000 * AKcMinOTDim, 136.000000 * AKcMinOTDim, + 137.000000 * AKcMinOTDim, 138.000000 * AKcMinOTDim, 139.000000 * AKcMinOTDim, 140.000000 * AKcMinOTDim, + 141.000000 * AKcMinOTDim, 142.000000 * AKcMinOTDim, 143.000000 * AKcMinOTDim, 144.000000 * AKcMinOTDim, + 145.000000 * AKcMinOTDim, 146.000000 * AKcMinOTDim, 147.000000 * AKcMinOTDim, 148.000000 * AKcMinOTDim, + 149.000000 * AKcMinOTDim, 150.000000 * AKcMinOTDim, 151.000000 * AKcMinOTDim, 152.000000 * AKcMinOTDim, + 153.000000 * AKcMinOTDim, 154.000000 * AKcMinOTDim, 155.000000 * AKcMinOTDim, 156.000000 * AKcMinOTDim, + 157.000000 * AKcMinOTDim, 158.000000 * AKcMinOTDim, 159.000000 * AKcMinOTDim, 160.000000 * AKcMinOTDim, + 161.000000 * AKcMinOTDim, 162.000000 * AKcMinOTDim, 163.000000 * AKcMinOTDim, 164.000000 * AKcMinOTDim, + 165.000000 * AKcMinOTDim, 166.000000 * AKcMinOTDim, 167.000000 * AKcMinOTDim, 168.000000 * AKcMinOTDim, + 169.000000 * AKcMinOTDim, 170.000000 * AKcMinOTDim, 171.000000 * AKcMinOTDim, 172.000000 * AKcMinOTDim, + 173.000000 * AKcMinOTDim, 174.000000 * AKcMinOTDim, 175.000000 * AKcMinOTDim, 176.000000 * AKcMinOTDim, + 177.000000 * AKcMinOTDim, 178.000000 * AKcMinOTDim, 179.000000 * AKcMinOTDim, 180.000000 * AKcMinOTDim, + 181.000000 * AKcMinOTDim, 182.000000 * AKcMinOTDim, 183.000000 * AKcMinOTDim, 184.000000 * AKcMinOTDim, + 185.000000 * AKcMinOTDim, 186.000000 * AKcMinOTDim, 187.000000 * AKcMinOTDim, 188.000000 * AKcMinOTDim, + 189.000000 * AKcMinOTDim, 190.000000 * AKcMinOTDim, 191.000000 * AKcMinOTDim, 192.000000 * AKcMinOTDim, + 193.000000 * AKcMinOTDim, 194.000000 * AKcMinOTDim, 195.000000 * AKcMinOTDim, 196.000000 * AKcMinOTDim, + 197.000000 * AKcMinOTDim, 198.000000 * AKcMinOTDim, 199.000000 * AKcMinOTDim, 200.000000 * AKcMinOTDim, + 201.000000 * AKcMinOTDim, 202.000000 * AKcMinOTDim, 203.000000 * AKcMinOTDim, 204.000000 * AKcMinOTDim, + 205.000000 * AKcMinOTDim, 206.000000 * AKcMinOTDim, 207.000000 * AKcMinOTDim, 208.000000 * AKcMinOTDim, + 209.000000 * AKcMinOTDim, 210.000000 * AKcMinOTDim, 211.000000 * AKcMinOTDim, 212.000000 * AKcMinOTDim, + 213.000000 * AKcMinOTDim, 214.000000 * AKcMinOTDim, 215.000000 * AKcMinOTDim, 216.000000 * AKcMinOTDim, + 217.000000 * AKcMinOTDim, 218.000000 * AKcMinOTDim, 219.000000 * AKcMinOTDim, 220.000000 * AKcMinOTDim, + 221.000000 * AKcMinOTDim, 222.000000 * AKcMinOTDim, 223.000000 * AKcMinOTDim, 224.000000 * AKcMinOTDim, + 225.000000 * AKcMinOTDim, 226.000000 * AKcMinOTDim, 227.000000 * AKcMinOTDim, 228.000000 * AKcMinOTDim, + 229.000000 * AKcMinOTDim, 230.000000 * AKcMinOTDim, 231.000000 * AKcMinOTDim, 232.000000 * AKcMinOTDim, + 233.000000 * AKcMinOTDim, 234.000000 * AKcMinOTDim, 235.000000 * AKcMinOTDim, 236.000000 * AKcMinOTDim, + 237.000000 * AKcMinOTDim, 238.000000 * AKcMinOTDim, 239.000000 * AKcMinOTDim, 240.000000 * AKcMinOTDim, + 241.000000 * AKcMinOTDim, 242.000000 * AKcMinOTDim, 243.000000 * AKcMinOTDim, 244.000000 * AKcMinOTDim, + 245.000000 * AKcMinOTDim, 246.000000 * AKcMinOTDim, 247.000000 * AKcMinOTDim, 248.000000 * AKcMinOTDim, + 249.000000 * AKcMinOTDim, 250.000000 * AKcMinOTDim, 251.000000 * AKcMinOTDim, 252.000000 * AKcMinOTDim, 253.000000 * AKcMinOTDim, 254.000000 * AKcMinOTDim, 255.000000 * AKcMinOTDim, 256.000000 * AKcMinOTDim }; @@ -514,29 +514,29 @@ AKrRayCastCoefficients_Initialize(UUtUns32 inDivs) if (inDivs > MAX_AKIRA_RAYS) { COrConsole_Printf("allocated too many akira rays"); } - + inDivs = UUmMin(inDivs, MAX_AKIRA_RAYS); { UUtUns16 numTotalRays = 0; AKtRay* curDestRay; - + UUtUns16 itr; UUtUns32 x,y; - + float dimOffset = 1.f / ((float) inDivs); UUtUns32 table[4] = { 0,2,1,3 }; - + AKgFrame.rays = NULL; - + UUmAssert(AKgFrame.rays == NULL); AKgFrame.numRays = inDivs * inDivs; AKgFrame.rays = AKgInternalRayStorage; UUmError_ReturnOnNull(AKgFrame.rays); - + curDestRay = AKgFrame.rays; - + for(x = 0; x < inDivs; x++) { for(y = 0; y < inDivs; y++) @@ -547,16 +547,16 @@ AKrRayCastCoefficients_Initialize(UUtUns32 inDivs) numTotalRays++; } } - + UUmAssert(numTotalRays == inDivs * inDivs); - + for(itr = 0; itr < AKcNumTemperalFrames; itr++) { AKgRayOffset[itr].u_offset = AKgSourceRayOffset[itr].u_offset * dimOffset; AKgRayOffset[itr].v_offset = AKgSourceRayOffset[itr].v_offset * dimOffset; } } - + return UUcError_None; } @@ -568,11 +568,11 @@ AKrRayCastCoefficients_Terminate( if(AKgFrame.rays != NULL) { AKgFrame.rays = NULL; } - + #if 0//UUmSIMD != UUmSIMD_None - + AKrRayCastCoefficients_Terminate_SIMD(); - + #endif } @@ -612,7 +612,7 @@ typedef struct raycast_block_type float vX; float vY; float vZ; - + float invVX; float invVY; float invVZ; @@ -670,7 +670,7 @@ static void traverse_single_ray(raycast_block_type *in_block) UUtBool far_clipped; parametric_start = parametric_end; - + UUmAssert(AKmOctTree_IsLeafNode(cur_node_index)); if(0xFFFFFFFF == cur_node_index) { @@ -678,31 +678,31 @@ static void traverse_single_ray(raycast_block_type *in_block) break; } - + //UUmAssert(oct_tree_leaf_index < inEnvironment->octTree->leafNodeArray->numNodes); - + curOTLeafNode = in_block->leafNodeArray + oct_tree_leaf_index; - + UUr2BitVector_Set(in_block->ot2LeafNodeVisibility, oct_tree_leaf_index); - + // dim_Encode = curOTLeafNode->dim_Encode; - + curFullDim = (float)(1 << ((dim_Encode >> AKcOctTree_Shift_Dim) & AKcOctTree_Mask_Dim)); curFullDim *= AKcMinOTDim; - + maxX = (float)((dim_Encode >> AKcOctTree_Shift_X) & AKcOctTree_Mask_X); maxY = (float)((dim_Encode >> AKcOctTree_Shift_Y) & AKcOctTree_Mask_Y); maxZ = (float)((dim_Encode >> AKcOctTree_Shift_Z) & AKcOctTree_Mask_Z); - + maxX -= 255.0f; maxY -= 255.0f; maxZ -= 255.0f; - + maxX *= AKcMinOTDim; maxY *= AKcMinOTDim; maxZ *= AKcMinOTDim; - + minX = maxX - curFullDim; minY = maxY - curFullDim; minZ = maxZ - curFullDim; @@ -718,18 +718,18 @@ static void traverse_single_ray(raycast_block_type *in_block) // Find out which plane I cross - + // project onto XY plane xPlane = (in_block->xSideFlag == AKcOctTree_Side_PosX) ? maxX : minX; yPlane = (in_block->ySideFlag == AKcOctTree_Side_PosY) ? maxY : minY; zPlane = (in_block->zSideFlag == AKcOctTree_Side_PosZ) ? maxZ : minZ; - + // calculate sideCrossing { float parametric_distance_to_x_plane = in_block->invVX * (xPlane - in_block->startPointX); float parametric_distance_to_y_plane = in_block->invVY * (yPlane - in_block->startPointY); float parametric_distance_to_z_plane = in_block->invVZ * (zPlane - in_block->startPointZ); - + if ((parametric_distance_to_x_plane <= parametric_distance_to_y_plane) && (parametric_distance_to_x_plane <= parametric_distance_to_z_plane)) { sideCrossing = in_block->xSideFlag; @@ -750,50 +750,50 @@ static void traverse_single_ray(raycast_block_type *in_block) if (far_clipped) { parametric_end = 1.f; } - } - + } + #if defined(DEBUG_COLLISION2_TRAVERSAL) && DEBUG_COLLISION2_TRAVERSAL - + bBox.minPoint.x = minX; bBox.minPoint.y = minY; bBox.minPoint.z = minZ; bBox.maxPoint.x = maxX; bBox.maxPoint.y = maxY; bBox.maxPoint.z = maxZ; - + start.x = startPointX; start.y = startPointY; start.z = startPointZ; end.x = endPointX; end.y = endPointY; end.z = endPointZ; - + in = CLrBox_Line(&bBox, &start, &end); - + UUmAssert(in); #endif - + stopChecking = UUcFalse; - + if(curOTLeafNode->gqIndirectIndex_Encode == 0) { #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC - + funcNumSkippedOctants++; - + #endif - + goto skip; } - + AKmOctTree_DecodeGQIndIndices(curOTLeafNode->gqIndirectIndex_Encode, startIndirectIndex, length); - + #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC numQuadChecks = 0; funcQuadTraversalStart = UUrMachineTime_High(); #endif - + for(curGQIndIndex = 0; curGQIndIndex < length; curGQIndIndex++) { const AKtGQ_General* curGQGeneral; @@ -807,19 +807,19 @@ static void traverse_single_ray(raycast_block_type *in_block) UUtUns32 old_uns_32; curGQIndex = in_block->octTreeGQIndices[curGQIndIndex + startIndirectIndex]; - + //UUmAssert(curGQIndex < inEnvironment->gqGeneralArray->numGQs); - + gotPlaneEqu = UUcFalse; cur_gq_bv_offset = BV_INDEX(curGQIndex); cur_gq_bv_bit_mask = BV_BIT(curGQIndex); curGQGeneral = in_block->gqGeneralArray + curGQIndex; curGQCollision = in_block->gqCollisionArray + curGQIndex; - - + + //Mark this gq as visible old_uns_32 = in_block->gqComputedBackFaceBV[cur_gq_bv_offset]; - + if (old_uns_32 & cur_gq_bv_bit_mask) { if (in_block->gqBackFaceBV[cur_gq_bv_offset] & cur_gq_bv_bit_mask) @@ -828,7 +828,7 @@ static void traverse_single_ray(raycast_block_type *in_block) } } - + //Mark this gq as visible //if(UUrBitVector_TestAndSetBit(in_block->gqComputedBackFaceBV, curGQIndex)) //{ @@ -856,12 +856,12 @@ static void traverse_single_ray(raycast_block_type *in_block) curGQCollision->planeEquIndex, in_block->planeEquArray, a, b, c, d); - + curPoint = in_block->pointArray + curGQGeneral->m3Quad.vertexIndices.indices[0]; viewVectorX = in_block->startPointX - curPoint->x; viewVectorY = in_block->startPointY - curPoint->y; viewVectorZ = in_block->startPointZ - curPoint->z; - + if ((viewVectorX * a + viewVectorY * b + viewVectorZ * c) < 0.0f) { in_block->gqBackFaceBV[cur_gq_bv_offset] |= cur_gq_bv_bit_mask; //UUrBitVector_SetBit(in_block->gqBackFaceBV, curGQIndex); @@ -870,33 +870,33 @@ static void traverse_single_ray(raycast_block_type *in_block) } } - UUr2BitVector_Set(in_block->gq2VisibilityVector, curGQIndex); + UUr2BitVector_Set(in_block->gq2VisibilityVector, curGQIndex); if (curGQGeneral->flags & AKcGQ_Flag_Occlude_Skip) continue; - + if(!stopChecking) { #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC - + numQuadChecks++; - + #endif - + if(!gotPlaneEqu) { AKmPlaneEqu_GetComponents(curGQCollision->planeEquIndex, in_block->planeEquArray, a, b, c, d); } - + { float t, num1, denom; denom = a * in_block->vX + b * in_block->vY + c * in_block->vZ; - + if(denom == 0.0f) continue; - + num1 = -(a * in_block->startPointX + b * in_block->startPointY + c * in_block->startPointZ + d); - + t = num1 / denom; - + if (t < parametric_start || t > parametric_end) continue; in_block->testPoint.x = in_block->vX * t + in_block->startPointX; @@ -942,12 +942,12 @@ static void traverse_single_ray(raycast_block_type *in_block) } stopChecking = always_positive | always_negative; - } + } } } - + #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC - + if(stopChecking) { funcHitOctant_QuadTraversalTime += UUrMachineTime_High() - funcQuadTraversalStart; @@ -963,7 +963,7 @@ static void traverse_single_ray(raycast_block_type *in_block) funcNumMissOctants++; } #endif - + skip: #if OCT_TREE_TOOL_SUPPORT @@ -973,14 +973,14 @@ static void traverse_single_ray(raycast_block_type *in_block) { M3tPoint3D minPoint; M3tPoint3D maxPoint; - + minPoint.x = minX + 0.1f; minPoint.y = minY + 0.1f; minPoint.z = minZ + 0.1f; maxPoint.x = maxX - 0.1f; maxPoint.y = maxY - 0.1f; maxPoint.z = maxZ - 0.1f; - + if(/*endNodeIndex == curNodeIndex ||*/ stopChecking) { // CB: hit leaf nodes are red @@ -1009,7 +1009,7 @@ static void traverse_single_ray(raycast_block_type *in_block) // Lets move to the next node cur_node_index = curOTLeafNode->adjInfo[sideCrossing]; - + if(!AKmOctTree_IsLeafNode(cur_node_index)) { float curCenterPointU; @@ -1020,9 +1020,9 @@ static void traverse_single_ray(raycast_block_type *in_block) float vc; // need to traverse quad tree - + curHalfDim = curFullDim * 0.5f; - + // First compute the intersection point switch(sideCrossing) { @@ -1034,7 +1034,7 @@ static void traverse_single_ray(raycast_block_type *in_block) uc = in_block->startPointY + in_block->vY * magic_temp; vc = in_block->startPointZ + in_block->vZ * magic_temp; break; - + case AKcOctTree_Side_NegY: case AKcOctTree_Side_PosY: curCenterPointU = minX + curHalfDim; @@ -1043,7 +1043,7 @@ static void traverse_single_ray(raycast_block_type *in_block) uc = in_block->startPointX + in_block->vX * magic_temp; vc = in_block->startPointZ + in_block->vZ * magic_temp; break; - + case AKcOctTree_Side_NegZ: case AKcOctTree_Side_PosZ: curCenterPointU = minX + curHalfDim; @@ -1052,25 +1052,25 @@ static void traverse_single_ray(raycast_block_type *in_block) uc = in_block->startPointX + in_block->vX * magic_temp; vc = in_block->startPointY + in_block->vY * magic_temp; break; - + default: UUmAssert(0); } - + // next traverse the tree while(1) { - const AKtQuadTree_Node* curQTIntNode; + const AKtQuadTree_Node* curQTIntNode; UUtUns32 curOctant; curQTIntNode = in_block->qtInteriorNodeArray + cur_node_index; - + curOctant = 0; if(uc > curCenterPointU) curOctant |= AKcQuadTree_SideBV_U; if(vc > curCenterPointV) curOctant |= AKcQuadTree_SideBV_V; - + cur_node_index = curQTIntNode->children[curOctant]; - + if(AKmOctTree_IsLeafNode(cur_node_index)) break; curHalfDim *= 0.5f; curCenterPointU += (curOctant & AKcQuadTree_SideBV_U) ? curHalfDim : -curHalfDim; @@ -1095,25 +1095,25 @@ AKiEnvironment_RayCastOctTree( { #if BRENTS_CHEESY_PROFILE UUtUns64 funcStart; - + #if !BRENTS_CHEESY_PROFILE_ONLY_FUNC - + UUtUns64 funcRayStart; UUtUns64 funcOctantStart; UUtUns64 funcQuadTraversalStart; - + UUtUns32 numQuadChecks; - + #endif - + UUtUns64 funcEnd; - + #endif - - + + float uv_far_initial_x, uv_far_initial_y, uv_far_initial_z; float u_far_delta_x, u_far_delta_y, u_far_delta_z; @@ -1121,13 +1121,13 @@ AKiEnvironment_RayCastOctTree( float uv_near_initial_x, uv_near_initial_y, uv_near_initial_z; float u_near_delta_x, u_near_delta_y, u_near_delta_z; float v_near_delta_x, v_near_delta_y, v_near_delta_z; - + UUtUns32 itr, numRays; AKtRay* curRay; - AKtRayOffset *curRayOffset = AKgRayOffset + (gFrameNum % AKcNumTemperalFrames); - + AKtRayOffset *curRayOffset = AKgRayOffset + (gFrameNum % AKcNumTemperalFrames); + AKtEnvironment_Private* environmentPrivate = (AKtEnvironment_Private*)(TMrTemplate_PrivateData_GetDataPtr(AKgTemplate_PrivateData, inEnvironment)); - + raycast_block_type raycast_block; @@ -1136,7 +1136,7 @@ AKiEnvironment_RayCastOctTree( M3tPoint3D start, end; UUtBool in; #endif - + #if BRENTS_CHEESY_PROFILE funcNum++; funcStart = UUrMachineTime_High(); @@ -1147,7 +1147,7 @@ AKiEnvironment_RayCastOctTree( #if PERFORMANCE_TIMER UUrPerformanceTimer_Enter(AKg_RayCastOctTree_Timer); #endif - + raycast_block.pointArray = inEnvironment->pointArray->points; raycast_block.planeEquArray = inEnvironment->planeArray->planes; raycast_block.interiorNodeArray = inEnvironment->octTree->interiorNodeArray->nodes; @@ -1161,9 +1161,9 @@ AKiEnvironment_RayCastOctTree( raycast_block.gqBackFaceBV = environmentPrivate->gqBackFaceBV; raycast_block.gq2VisibilityVector = environmentPrivate->gq2VisibilityVector; - + //UUrMemory_Clear(environmentPrivate->gqVisibilityBV, (inEnvironment->gqArray->numGQs + 3) >> 2); - + UUrBitVector_ClearBitAll( environmentPrivate->gqComputedBackFaceBV, inEnvironment->gqGeneralArray->numGQs); @@ -1183,7 +1183,7 @@ AKiEnvironment_RayCastOctTree( NULL); - raycast_block.startNodeIndex = AKrFindOctTreeNodeIndex(raycast_block.interiorNodeArray, cameraLocation.x, cameraLocation.y, cameraLocation.z, NULL); + raycast_block.startNodeIndex = AKrFindOctTreeNodeIndex(raycast_block.interiorNodeArray, cameraLocation.x, cameraLocation.y, cameraLocation.z, NULL); raycast_block.total_min_x = cameraLocation.x; raycast_block.total_min_y = cameraLocation.y; @@ -1192,7 +1192,7 @@ AKiEnvironment_RayCastOctTree( raycast_block.total_max_x = cameraLocation.x; raycast_block.total_max_y = cameraLocation.y; raycast_block.total_max_z = cameraLocation.z; - } + } // cache the interpolation bases { @@ -1201,104 +1201,104 @@ AKiEnvironment_RayCastOctTree( M3rCamera_GetWorldFrustum( inCamera, - frustumWorldPoints, + frustumWorldPoints, frustumWorldPlanes); uv_far_initial_x = frustumWorldPoints[4].x; uv_far_initial_y = frustumWorldPoints[4].y; uv_far_initial_z = frustumWorldPoints[4].z; - + u_far_delta_x = frustumWorldPoints[5].x - uv_far_initial_x; u_far_delta_y = frustumWorldPoints[5].y - uv_far_initial_y; u_far_delta_z = frustumWorldPoints[5].z - uv_far_initial_z; - + v_far_delta_x = frustumWorldPoints[6].x - uv_far_initial_x; v_far_delta_y = frustumWorldPoints[6].y - uv_far_initial_y; v_far_delta_z = frustumWorldPoints[6].z - uv_far_initial_z; - + uv_near_initial_x = frustumWorldPoints[0].x; uv_near_initial_y = frustumWorldPoints[0].y; uv_near_initial_z = frustumWorldPoints[0].z; - + u_near_delta_x = frustumWorldPoints[1].x - uv_near_initial_x; u_near_delta_y = frustumWorldPoints[1].y - uv_near_initial_y; u_near_delta_z = frustumWorldPoints[1].z - uv_near_initial_z; - + v_near_delta_x = frustumWorldPoints[2].x - uv_near_initial_x; v_near_delta_y = frustumWorldPoints[2].y - uv_near_initial_y; v_near_delta_z = frustumWorldPoints[2].z - uv_near_initial_z; } - + // Begin traversing all the rays numRays = AKgFrame.numRays; curRay = AKgFrame.rays; - + #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC funcNumRays += numRays; funcRayStart = UUrMachineTime_High(); #endif - + for(itr = 0; itr < numRays; itr++, curRay++) { float u, v; u = curRay->u + curRayOffset->u_offset; v = curRay->v + curRayOffset->v_offset; - + raycast_block.endPointX = uv_far_initial_x + u * u_far_delta_x + v * v_far_delta_x; raycast_block.endPointY = uv_far_initial_y + u * u_far_delta_y + v * v_far_delta_y; raycast_block.endPointZ = uv_far_initial_z + u * u_far_delta_z + v * v_far_delta_z; - + raycast_block.startPointX = uv_near_initial_x + u * u_near_delta_x + v * v_near_delta_x; raycast_block.startPointY = uv_near_initial_y + u * u_near_delta_y + v * v_near_delta_y; raycast_block.startPointZ = uv_near_initial_z + u * u_near_delta_z + v * v_near_delta_z; - + //numGQsChecked = 0; #if OCT_TREE_TOOL_SUPPORT raycast_block.testPoint.x = raycast_block.endPointX; raycast_block.testPoint.y = raycast_block.endPointY; raycast_block.testPoint.z = raycast_block.endPointZ; #endif - + raycast_block.vX = raycast_block.endPointX - raycast_block.startPointX; raycast_block.vY = raycast_block.endPointY - raycast_block.startPointY; raycast_block.vZ = raycast_block.endPointZ - raycast_block.startPointZ; - + //UUmAssert(vX != 0.0f); //UUmAssert(vY != 0.0f); //UUmAssert(vZ != 0.0f); - + raycast_block.invVX = 1.0f / raycast_block.vX; raycast_block.invVY = 1.0f / raycast_block.vY; raycast_block.invVZ = 1.0f / raycast_block.vZ; - + // Compute the side flags raycast_block.xSideFlag = AKcOctTree_Side_NegX + (raycast_block.vX > 0.0f); raycast_block.ySideFlag = AKcOctTree_Side_NegY + (raycast_block.vY > 0.0f); raycast_block.zSideFlag = AKcOctTree_Side_NegZ + (raycast_block.vZ > 0.0f); - + #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC funcOctantStart = UUrMachineTime_High(); #endif - + traverse_single_ray(&raycast_block); - + #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC funcOctantTime += UUrMachineTime_High() - funcOctantStart; #endif - + #if OCT_TREE_TOOL_SUPPORT if(AKgDebug_ShowRays) { M3tPoint3D points[2]; UUtUns16 colorLine; - + points[0].x = raycast_block.startPointX + 0.01f; points[0].y = raycast_block.startPointY + 0.01f; points[0].z = raycast_block.startPointZ + 0.01f; - + points[1] = raycast_block.testPoint; - + switch(gFrameNum % AKcNumTemperalFrames) { case 0: @@ -1310,9 +1310,9 @@ AKiEnvironment_RayCastOctTree( case 2: colorLine = 0xff; break; - + } - + M3rGeom_Line_Light( &points[0], &points[1], @@ -1323,22 +1323,22 @@ AKiEnvironment_RayCastOctTree( #if BRENTS_CHEESY_PROFILE funcEnd = UUrMachineTime_High(); - + #if !BRENTS_CHEESY_PROFILE_ONLY_FUNC funcRayTime += funcEnd - funcRayStart; #endif - + funcTime += funcEnd - funcStart; - + #endif - inEnvironment->visible_bbox.minPoint.x = raycast_block.total_min_x; - inEnvironment->visible_bbox.minPoint.y = raycast_block.total_min_y; - inEnvironment->visible_bbox.minPoint.z = raycast_block.total_min_z; + inEnvironment->visible_bbox.minPoint.x = raycast_block.total_min_x; + inEnvironment->visible_bbox.minPoint.y = raycast_block.total_min_y; + inEnvironment->visible_bbox.minPoint.z = raycast_block.total_min_z; - inEnvironment->visible_bbox.maxPoint.x = raycast_block.total_max_x; - inEnvironment->visible_bbox.maxPoint.y = raycast_block.total_max_y; - inEnvironment->visible_bbox.maxPoint.z = raycast_block.total_max_z; + inEnvironment->visible_bbox.maxPoint.x = raycast_block.total_max_x; + inEnvironment->visible_bbox.maxPoint.y = raycast_block.total_max_y; + inEnvironment->visible_bbox.maxPoint.z = raycast_block.total_max_z; #if PERFORMANCE_TIMER UUrPerformanceTimer_Exit(AKg_RayCastOctTree_Timer); @@ -1383,11 +1383,11 @@ AKrEnvironment_StartFrame( UUtError error; AKtEnvironment_Private* environmentPrivate = (AKtEnvironment_Private*)(TMrTemplate_PrivateData_GetDataPtr(AKgTemplate_PrivateData, inEnvironment)); UUtUns32 debugState; - + //return UUcError_None; - + debugState = M3rGeom_State_Get(M3cGeomStateIntType_DebugMode); - + if(AKgDrawGhostGQs) { debugState |= M3cGeomState_DebugMode_DrawGhostGQs; @@ -1396,7 +1396,7 @@ AKrEnvironment_StartFrame( { debugState &= ~M3cGeomState_DebugMode_DrawGhostGQs; } - + if(AKgDebug_DebugMaps) { debugState |= M3cGeomState_DebugMode_UseEnvDbgTexture; @@ -1405,16 +1405,16 @@ AKrEnvironment_StartFrame( { debugState &= ~M3cGeomState_DebugMode_UseEnvDbgTexture; } - + M3rGeom_State_Set(M3cGeomStateIntType_DebugMode, debugState); - + if(AKgNoneTexture == NULL) { TMrInstance_GetDataPtr(M3cTemplate_TextureMap, "NONE", (void **) (&AKgNoneTexture)); } - + error = M3rEnv_SetCamera(inCamera); UUmError_ReturnOnError(error); - + { UUtBool is_equal; UUtBool cast_rays = UUcTrue; @@ -1428,7 +1428,7 @@ AKrEnvironment_StartFrame( M3rCamera_GetViewData(inCamera, &newCameraLocation, &newCameraViewVector, &newCameraUpVector); - is_equal = + is_equal = (MUmVector_GetDistanceSquared(newCameraLocation, oldCameraLocation) < UUmSQR(0.1f)) && (MUmVector_GetDistanceSquared(newCameraViewVector, oldCameraViewVector) < UUmSQR(0.05f)) && (MUmVector_GetDistanceSquared(newCameraUpVector, oldCameraUpVector) < UUmSQR(0.05f)); @@ -1443,7 +1443,7 @@ AKrEnvironment_StartFrame( else { AKgNumEqualFrames = 0; } - + if (cast_rays) { static UUtUns32 slow_aging = 0; UUtBool sky_is_visible; @@ -1465,7 +1465,7 @@ AKrEnvironment_StartFrame( } sky_is_visible = UUcFalse; - + { for(ray_cast_itr = 0; ray_cast_itr < ray_cast_count; ray_cast_itr++) @@ -1479,7 +1479,7 @@ AKrEnvironment_StartFrame( if (sky_is_visible) { environmentPrivate->sky_visibility = AKcNumTemperalFrames; } - + oldCameraLocation = newCameraLocation; oldCameraViewVector = newCameraViewVector; oldCameraUpVector = newCameraUpVector; @@ -1488,7 +1488,7 @@ AKrEnvironment_StartFrame( // COrConsole_Printf("environment is still %d", ONgGameState->gameTime); } } - + if(AKgDebug_ShowOctTree == UUcTrue) { // AKiOctTree_Show(inEnvironment); @@ -1510,28 +1510,28 @@ AKtGQ_Render* AKgGQRenderArray; // // Shortly after I started writing a funky hash table bin sort thing I // discovered something wonderful. We're sorting on texture ID numbers, -// which have a limited range, perfect material for a bin sort. +// which have a limited range, perfect material for a bin sort. // // The algorithm makes multiple passes on the visible GQ array. In the // first pass it counts the number of times each texture is used. // In the second pass it constructs a table of offsets, one offset for -// each texture bin, into what will be the final visible GQ array. +// each texture bin, into what will be the final visible GQ array. // In the third pass it uses those offsets to populate a the final // visible GQ array. // // Disadantages over quicksort: More memory use is needed. // Advantages: We're running about 30 times faster :) // -// Note that this subroutine assumes we're running with vertex lighting -// only. +// Note that this subroutine assumes we're running with vertex lighting +// only. // #define MAX_TEXTURES 0x3780 #define MAX_BINS 0x1000 // -// Note to Bungie, I'm grabbing the memory I need for this from -// psx2_stack_allocate. The memory should probably be declared inside +// Note to Bungie, I'm grabbing the memory I need for this from +// psx2_stack_allocate. The memory should probably be declared inside // AKrEvnvironment_VisibleSort, but I'm trying to keep my stack space under // 8k so I can run the game with the stack on the scratch pad. // @@ -1557,7 +1557,7 @@ static void UUcExternal_Call AKgFreeMemory( UUrMemory_Block_Delete(AKgRemapTable); AKgRemapTable= NULL; } - + return; } @@ -1597,7 +1597,7 @@ static void AKrEnvironment_VisibleSort(UUtUns32 *visibleArray, UUtUns32 numVisib } // Second pass, create a table of offsets. We're going to use these - // to figure out where each GQ goes in the new list. + // to figure out where each GQ goes in the new list. offset=0; @@ -1638,7 +1638,7 @@ AKiEnvironment_ComputeVis( AKtGQ_General* gqGeneralArray; AKtGQ_General* curGQGeneral; - + UUtUns32 numGQs; UUtUns16 curByteIndex; @@ -1653,42 +1653,42 @@ AKiEnvironment_ComputeVis( UUtUns32 debugState; UUtUns32* visibleArray; UUtUns32 exceeded_max_visible_gqs_count = 0; - + numGQs = inEnvironment->gqGeneralArray->numGQs; - + gqGeneralArray = inEnvironment->gqGeneralArray->gqGeneral; AKgGQRenderArray = inEnvironment->gqRenderArray->gqRender; debugState = M3rGeom_State_Get(M3cGeomStateIntType_DebugMode); drawGhostGQs = (UUtBool)((debugState & M3cGeomState_DebugMode_DrawGhostGQs) != 0); - + visibleArray = environmentPrivate->visGQ_List; - + // Traverse the bit vector for(curByteIndex = 0, curByte = (UUtUns8*)environmentPrivate->gq2VisibilityVector, curGQIndex = 0; curByteIndex < (numGQs + 3) >> 2; curByteIndex++, curByte++) { curByteValue = *curByte; - + if(curByteValue == 0) { curGQIndex += 4; continue; } - + for(cur2BitIndex = 0, cur2BitMask = 3; (cur2BitIndex < 4) && (curGQIndex < numGQs); cur2BitIndex++, curGQIndex++, cur2BitMask <<= 2) { curGQGeneral = gqGeneralArray + curGQIndex; - + if (drawGhostGQs && (curGQGeneral->flags & AKcGQ_Flag_NoTextureMask)) goto forceDraw; - + if (!(curByteValue & cur2BitMask)) continue; if (curGQGeneral->flags & AKcGQ_Flag_NoTextureMask) continue; - + forceDraw: #ifdef ROCKSTAR if((curGQGeneral->flags & AKcGQ_Flag_Invisible)&&(curGQGeneral->flags & AKcGQ_Flag_Furniture)) @@ -1720,7 +1720,7 @@ AKiEnvironment_ComputeVis( continue; } #endif - + if (numVisible < AKcMaxVisibleGQs) { visibleArray[numVisible++] = curGQIndex; } @@ -1729,7 +1729,7 @@ AKiEnvironment_ComputeVis( } } } - + AKrEnvironment_VisibleSort(visibleArray, numVisible); environmentPrivate->visGQ_Num = numVisible; @@ -1769,14 +1769,14 @@ void AKrEnvironment_EndFrame_Tool(AKtEnvironment *inEnvironment) float curFullDim; leafNodeArray = inEnvironment->octTree->leafNodeArray->nodes; - + if (AKgDebugLeafNodes != NULL) { for(itr = 0; itr < AKgDebugLeafNodes->numPages; itr++) { curLeafIndex = AKgDebugLeafNodes->pages[itr]; curLeafNode = leafNodeArray + curLeafIndex; - + dim_Encode = curLeafNode->dim_Encode; curFullDim = AKgIntToFloatDim[(dim_Encode >> AKcOctTree_Shift_Dim) & AKcOctTree_Mask_Dim]; maxX = AKgIntToFloatXYZ[(dim_Encode >> AKcOctTree_Shift_X) & AKcOctTree_Mask_X]; @@ -1785,14 +1785,14 @@ void AKrEnvironment_EndFrame_Tool(AKtEnvironment *inEnvironment) minX = maxX - curFullDim; minY = maxY - curFullDim; minZ = maxZ - curFullDim; - + minPoint.x = minX; minPoint.y = minY; minPoint.z = minZ; maxPoint.x = maxX; maxPoint.y = maxY; maxPoint.z = maxZ; - + AKiBoundingBox_Draw( &minPoint, &maxPoint, @@ -1802,16 +1802,16 @@ void AKrEnvironment_EndFrame_Tool(AKtEnvironment *inEnvironment) AUrDict_Clear(AKgDebugLeafNodes); } - + for(itr = 0; itr < AKgNumColDebugEntries; itr++) { M3rGeom_State_Push(); M3rGeom_State_Set(M3cGeomStateIntType_Fill, M3cGeomState_Fill_Line); M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor,IMcShade_White); M3rGeom_State_Set(M3cGeomStateIntType_Appearance, M3cGeomState_Appearance_Gouraud); - + ONrDrawSphere( - NULL, + NULL, AKgDebugEntry_Sphere[itr].radius, &AKgDebugEntry_Sphere[itr].center); M3rGeom_State_Pop(); @@ -1828,15 +1828,15 @@ AKrEnvironment_EndFrame( UUtError error; gFrameNum++; - + M3rGeom_State_Push(); - + M3rGeom_State_Set( M3cGeomStateIntType_Alpha, 0xFF); - + M3rGeom_State_Commit(); - + #if PERFORMANCE_TIMER UUrPerformanceTimer_Enter(AKg_ComputeVis_Timer); #endif @@ -1846,7 +1846,7 @@ AKrEnvironment_EndFrame( #if PERFORMANCE_TIMER UUrPerformanceTimer_Exit(AKg_ComputeVis_Timer); #endif - + error = M3rEnv_DrawGQList(environmentPrivate->visGQ_Num, environmentPrivate->visGQ_List); UUmError_ReturnOnError(error); @@ -1863,37 +1863,37 @@ void AKrEnvironment_PrintStats(void) { #if SUPPORT_DEBUG_FILES BFtDebugFile *statsFile = BFrDebugFile_Open("raycastStats.txt"); - + BFrDebugFile_Printf(statsFile, "time per func: %f"UUmNL, (float)funcTime / (float)funcNum); - + #if !BRENTS_CHEESY_PROFILE_ONLY_FUNC BFrDebugFile_Printf(statsFile, "time per raycast: %f"UUmNL, (float)funcRayTime / (float)funcNumRays); - + BFrDebugFile_Printf(statsFile, "time per total octant: %f"UUmNL, (float)funcOctantTime / (float)(funcNumMissOctants + funcNumHitOctants + funcNumSkippedOctants)); BFrDebugFile_Printf(statsFile, "skipped / total octants: %f"UUmNL, (float)funcNumSkippedOctants / (float)(funcNumMissOctants + funcNumHitOctants + funcNumSkippedOctants)); - + BFrDebugFile_Printf(statsFile, "missed octant:"UUmNL); BFrDebugFile_Printf(statsFile, "\ttarversals per: %f"UUmNL, (float)funcMissOctant_NumQuadTraversals / (float)funcNumMissOctants); BFrDebugFile_Printf(statsFile, "\ttime per quadTraversal: %f"UUmNL, (float)funcMissOctant_QuadTraversalTime / (float)funcMissOctant_NumQuadTraversals); BFrDebugFile_Printf(statsFile, "\tchecks / traversal ratio: %f"UUmNL, (float)funcMissOctant_NumQuadChecks / (float)funcMissOctant_NumQuadTraversals); - + BFrDebugFile_Printf(statsFile, "hit octant:"UUmNL); BFrDebugFile_Printf(statsFile, "\ttarversals per: %f"UUmNL, (float)funcHitOctant_NumQuadTraversals / (float)funcNumHitOctants); BFrDebugFile_Printf(statsFile, "\ttime per quadTraversal: %f"UUmNL, (float)funcHitOctant_QuadTraversalTime / (float)funcHitOctant_NumQuadTraversals); BFrDebugFile_Printf(statsFile, "\tchecks / traversal ratio: %f"UUmNL, (float)funcHitOctant_NumQuadChecks / (float)funcHitOctant_NumQuadTraversals); BFrDebugFile_Printf(statsFile, "\tquads till hit: %f"UUmNL, (float)funcHitOctant_NumQuadsTillHit / (float)funcNumHitOctants); - + BFrDebugFile_Printf(statsFile, "raycasts per func: %f"UUmNL, (float)funcNumRays / (float)funcNum); BFrDebugFile_Printf(statsFile, "total octants per raycast: %f"UUmNL, (float)(funcNumMissOctants + funcNumHitOctants + funcNumSkippedOctants) / (float)funcNumRays); BFrDebugFile_Printf(statsFile, "missed octants per raycast: %f"UUmNL, (float)funcNumMissOctants / (float)funcNumRays); BFrDebugFile_Printf(statsFile, "hit octants per raycast: %f"UUmNL, (float)funcNumHitOctants / (float)funcNumRays); BFrDebugFile_Printf(statsFile, "skipped octants per raycast: %f"UUmNL, (float)funcNumSkippedOctants / (float)funcNumRays); - + BFrDebugFile_Printf(statsFile, "quadChecks per raycast: %f"UUmNL, (float)(funcMissOctant_NumQuadTraversals + funcHitOctant_NumQuadTraversals) / (float)funcNumRays); - + #endif - + BFrDebugFile_Close(statsFile); return; diff --git a/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Render_AltiVec.c b/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Render_AltiVec.c index 77edd2a..243dbb2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Render_AltiVec.c +++ b/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Render_AltiVec.c @@ -1,12 +1,12 @@ /* FILE: BFW_Akira_Render_AltiVec.c - + AUTHOR: Brent H. Pease - + CREATED: October 12, 1998 PURPOSE: environment engine - + Copyright 1997 */ @@ -58,21 +58,21 @@ AKiQuad_PointInQuad( const M3tQuad* inQuad, const vector float inVecPoint) { - + vector float splat_wt, splat_ut, splat_vt; - + vector float u0123; vector float v0123; vector float w0123; vector float last; vector float vI0, vI1, vI2, vI3; - + vector float u1230, v1230; - + const vector float splat_epsilon = (const vector float)(UUcEpsilon, UUcEpsilon, UUcEpsilon, UUcEpsilon); const vector float splat_neg_epsilon = (const vector float)(-UUcEpsilon, -UUcEpsilon, -UUcEpsilon, -UUcEpsilon); const vector float splat_zero = (vector float)((vector unsigned long)(0,0,0,0)); //AVcSplatZero; - + const vector unsigned char perm_XZ = (const vector unsigned char) AVmPerm_Build4Byte( 0, 0, @@ -87,25 +87,25 @@ AKiQuad_PointInQuad( 0, 0); const M3tPoint3D* curPoint; - + vector float diff; vector float vt0, vt1, vt2, vt3; - + if(inProjection == CLcProjection_Unknown) { inProjection = CLrQuad_FindProjection(inPointArray, inQuad); UUmAssert(inProjection != CLcProjection_Unknown); // should be discarded at import time } - + curPoint = inPointArray + inQuad->indices[0]; AVmLoadMisalignedVectorPoint(curPoint, u0123); - + curPoint = inPointArray + inQuad->indices[1]; AVmLoadMisalignedVectorPoint(curPoint, v0123); - + curPoint = inPointArray + inQuad->indices[2]; AVmLoadMisalignedVectorPoint(curPoint, w0123); - + curPoint = inPointArray + inQuad->indices[3]; AVmLoadMisalignedVectorPoint(curPoint, last); @@ -114,19 +114,19 @@ AKiQuad_PointInQuad( splat_ut = vec_splat(inVecPoint, 0); splat_vt = vec_splat(inVecPoint, 1); splat_wt = vec_splat(inVecPoint, 2); - + } else if(inProjection == CLcProjection_XZ) { splat_ut = vec_splat(inVecPoint, 0); splat_vt = vec_splat(inVecPoint, 2); splat_wt = vec_splat(inVecPoint, 1); - + u0123 = vec_perm(u0123, u0123, perm_XZ); v0123 = vec_perm(v0123, v0123, perm_XZ); w0123 = vec_perm(w0123, w0123, perm_XZ); last = vec_perm(last, last, perm_XZ); - + } else { @@ -139,7 +139,7 @@ AKiQuad_PointInQuad( w0123 = vec_perm(w0123, w0123, perm_YZ); last = vec_perm(last, last, perm_YZ); } - + vI0 = vec_mergeh ( u0123, w0123 ); vI1 = vec_mergeh ( v0123, last ); vI2 = vec_mergel ( u0123, w0123 ); @@ -150,13 +150,13 @@ AKiQuad_PointInQuad( w0123 = vec_mergeh ( vI2, vI3 ); diff = vec_sub(splat_wt, w0123); - + //if(vec_all_gt(diff, splat_epsilon)) return UUcFalse; //if(vec_all_lt(diff, splat_neg_epsilon)) return UUcFalse; - + /* If the point is in the quad we have something like this - + *0 /|\ / | \ @@ -171,39 +171,39 @@ AKiQuad_PointInQuad( \|/ *2 either: - + |t0 x t1| <= 0 && |t1 x t2| <= 0 && |t2 x t3| <= 0 && |t3 x t0| <= 0 - + or - + |t0 x t1| >= 0 && |t1 x t2| >= 0 && |t2 x t3| >= 0 && |t3 x t0| >= 0 - + (It depends on the orientation of the vertices) - + if the above conditions are not met the point is outside the quad - + */ - + u1230 = (vector float)vec_sld((vector unsigned char)u0123, (vector unsigned char)u0123, 4); v1230 = (vector float)vec_sld((vector unsigned char)v0123, (vector unsigned char)v0123, 4); - + vt0 = vec_sub(u0123, splat_ut); vt1 = vec_sub(v1230, splat_vt); vt2 = vec_sub(v0123, splat_vt); vt3 = vec_sub(u1230, splat_ut); - + vt2 = vec_madd(vt2, vt3, splat_zero); vt0 = vec_nmsub(vt0, vt1, vt2); - + if(vec_all_gt(vt0, splat_neg_epsilon)) return UUcTrue; if(vec_all_lt(vt0, splat_epsilon)) return UUcTrue; - + return UUcFalse; } #endif @@ -217,20 +217,20 @@ AKiQuad_PointInQuad( extern UUtUns32 funcRayTime; extern UUtUns32 funcNumRays; - + extern UUtUns32 funcOctantTime; extern UUtUns32 funcNumMissOctants; extern UUtUns32 funcNumHitOctants; extern UUtUns32 funcNumSkippedOctants; - + extern UUtUns32 funcMissOctant_QuadTraversalTime; extern UUtUns32 funcMissOctant_NumQuadTraversals; extern UUtUns32 funcMissOctant_NumQuadChecks; - + extern UUtUns32 funcHitOctant_QuadTraversalTime; extern UUtUns32 funcHitOctant_NumQuadTraversals; extern UUtUns32 funcHitOctant_NumQuadChecks; - + extern UUtUns32 funcHitOctant_NumQuadsTillHit; #endif @@ -243,19 +243,19 @@ AKrEnvironment_RayCastOctTree_SIMD( #if 1 #if BRENTS_CHEESY_PROFILE UUtUns64 funcStart; - + #if !BRENTS_CHEESY_PROFILE_ONLY_FUNC - + UUtUns64 funcRayStart; UUtUns64 funcOctantStart; UUtUns64 funcQuadTraversalStart; - + UUtUns32 numQuadChecks; - + #endif - + UUtUns64 funcEnd; - + #endif UUtUns32* octTreeGQIndices; @@ -265,43 +265,43 @@ AKrEnvironment_RayCastOctTree_SIMD( AKtOctTree_LeafNode* leafNodeArray; AKtQuadTree_Node* qtInteriorNodeArray; AKtQuadTree_Node* curQTIntNode; - + UUtUns32 curGQIndIndex; UUtUns32 curGQIndex; - + AKtGQ_General* gqGeneralArray; AKtGQ_Collision* gqCollisionArray; AKtGQ_General* curGQGeneral; AKtGQ_Collision* curGQCollision; UUtUns16 sideCrossing; - + //UUtUns16 endNodeIndex; UUtUns16 curNodeIndex; AKtOctTree_LeafNode* curOTLeafNode; UUtUns16 curOctant; - + #if 0 float curCenterPointU; float curCenterPointV; - + float curHalfDim; float uc, vc; #endif - + M3tPoint3D frustumWorldPoints[8]; M3tPlaneEquation frustumWorldPlanes[6]; M3tPoint3D cameraLocation; - + vector float uv_far_initial_xyz; vector float u_far_delta_xyz; vector float v_far_delta_xyz; vector float uv_near_initial_xyz; vector float u_near_delta_xyz; vector float v_near_delta_xyz; - + vector float invVXYZ; vector float maxXYZ; vector float minXYZ; @@ -310,38 +310,38 @@ AKrEnvironment_RayCastOctTree_SIMD( vector float denom; vector float num1; - + vector float vector_t0, vector_t1, vector_t2; vector unsigned int int_t0; vector float testPointXYZ; - + UUtUns32 itr, numRays; AKtRay* curRay; - + UUtUns16 startNodeIndex; - + UUtBool stopChecking; - + M3tPoint3D* curPoint; UUtUns32 startIndirectIndex; UUtUns8 length; - + UUtBool gotPlaneEqu; - + UUtUns32* gqComputedBackFaceBV; UUtUns32* gqBackFaceBV; - + float curFullDim; - + const vector float splat_onehalf = (const vector float)(0.5f, 0.5f, 0.5f, 0.5f); vector float planeMinusStartXYZ; AKtEnvironment_Private* environmentPrivate = (AKtEnvironment_Private*)(TMrTemplate_PrivateData_GetDataPtr(AKgTemplate_PrivateData, inEnvironment)); - - + + const vector float splat_one = vec_ctf((vector unsigned long)(1,1,1,1), 0); //AVcSplatOne; const vector float splat_zero = (vector float)((vector unsigned long)(0,0,0,0)); //AVcSplatZero; const vector unsigned int splat_int_one = (const vector unsigned int)(1, 1, 1, 1); @@ -373,23 +373,23 @@ AKrEnvironment_RayCastOctTree_SIMD( M3tBoundingBox_MinMax bBox; UUtBool in; #endif - + #if BRENTS_CHEESY_PROFILE funcNum++; funcStart = UUrMachineTime_High(); #endif - + M3rCamera_GetWorldFrustum( inCamera, frustumWorldPoints, frustumWorldPlanes); - + M3rCamera_GetViewData( inCamera, &cameraLocation, NULL, NULL); - + pointArray = inEnvironment->pointArray->points; planeEquArray = (vector float*)inEnvironment->planeArray->planes; interiorNodeArray = inEnvironment->octTree->interiorNodeArray->nodes; @@ -398,12 +398,12 @@ AKrEnvironment_RayCastOctTree_SIMD( gqGeneralArray = inEnvironment->gqGeneralArray->gqGeneral; gqCollisionArray = inEnvironment->gqCollisionArray->gqCollision; octTreeGQIndices = inEnvironment->octTree->gqIndices->indices; - + gqComputedBackFaceBV = environmentPrivate->gqComputedBackFaceBV; gqBackFaceBV = environmentPrivate->gqBackFaceBV; - + //UUrMemory_Clear(environmentPrivate->gqVisibilityBV, (inEnvironment->gqArray->numGQs + 3) >> 2); - + UUrBitVector_ClearBitAll( environmentPrivate->gqComputedBackFaceBV, inEnvironment->gqGeneralArray->numGQs); @@ -417,53 +417,53 @@ AKrEnvironment_RayCastOctTree_SIMD( inEnvironment->octTree->leafNodeArray->numNodes); // go into the start node - startNodeIndex = AKrFindOctTreeNodeIndex(interiorNodeArray, cameraLocation.x, cameraLocation.y, cameraLocation.z); - + startNodeIndex = AKrFindOctTreeNodeIndex(interiorNodeArray, cameraLocation.x, cameraLocation.y, cameraLocation.z); + // cache the interpolation bases *((float*)&uv_far_initial_xyz + 0) = frustumWorldPoints[4].x; *((float*)&uv_far_initial_xyz + 1) = frustumWorldPoints[4].y; *((float*)&uv_far_initial_xyz + 2) = frustumWorldPoints[4].z; *((float*)&uv_far_initial_xyz + 3) = 0.0f; - + *((float*)&u_far_delta_xyz + 0) = frustumWorldPoints[5].x; *((float*)&u_far_delta_xyz + 1) = frustumWorldPoints[5].y; *((float*)&u_far_delta_xyz + 2) = frustumWorldPoints[5].z; *((float*)&u_far_delta_xyz + 3) = 0.0f; - + u_far_delta_xyz = vec_sub(u_far_delta_xyz, uv_far_initial_xyz); - + *((float*)&v_far_delta_xyz + 0) = frustumWorldPoints[6].x; *((float*)&v_far_delta_xyz + 1) = frustumWorldPoints[6].y; *((float*)&v_far_delta_xyz + 2) = frustumWorldPoints[6].z; *((float*)&v_far_delta_xyz + 3) = 0.0f; v_far_delta_xyz = vec_sub(v_far_delta_xyz, uv_far_initial_xyz); - + *((float*)&uv_near_initial_xyz + 0) = frustumWorldPoints[0].x; *((float*)&uv_near_initial_xyz + 1) = frustumWorldPoints[0].y; *((float*)&uv_near_initial_xyz + 2) = frustumWorldPoints[0].z; *((float*)&uv_near_initial_xyz + 3) = 0.0f; - + *((float*)&u_near_delta_xyz + 0) = frustumWorldPoints[1].x; *((float*)&u_near_delta_xyz + 1) = frustumWorldPoints[1].y; *((float*)&u_near_delta_xyz + 2) = frustumWorldPoints[1].z; *((float*)&u_near_delta_xyz + 3) = 0.0f; u_near_delta_xyz = vec_sub(u_near_delta_xyz, uv_near_initial_xyz); - + *((float*)&v_near_delta_xyz + 0) = frustumWorldPoints[2].x; *((float*)&v_near_delta_xyz + 1) = frustumWorldPoints[2].y; *((float*)&v_near_delta_xyz + 2) = frustumWorldPoints[2].z; *((float*)&v_near_delta_xyz + 3) = 0.0f; v_near_delta_xyz = vec_sub(v_near_delta_xyz, uv_near_initial_xyz); - + // Begin traversing all the rays numRays = AKgUniqueFrames[gFrameNum % AKcNumTemperalFrames].numRays; curRay = AKgUniqueFrames[gFrameNum % AKcNumTemperalFrames].rays; - + #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC funcNumRays += numRays; funcRayStart = UUrMachineTime_High(); #endif - + for(itr = 0; itr < numRays; itr++, curRay++) { vector float splat_u, splat_v; @@ -474,9 +474,9 @@ AKrEnvironment_RayCastOctTree_SIMD( vector float splat_curFullDim; vector unsigned int splat_dim_Encode; vector unsigned int sideCrossingXYZ; - + #if defined(UUmAltiVec_Trace) && UUmAltiVec_Trace - + if(itr == 4) { startTrace_alt("rayCastTrace", &pointArray); @@ -486,127 +486,127 @@ AKrEnvironment_RayCastOctTree_SIMD( stopTrace_alt(&pointArray); exit(0); } - + #endif *((float*)&splat_u) = curRay->u; *((float*)&splat_v) = curRay->v; - + splat_u = vec_splat(splat_u, 0); splat_v = vec_splat(splat_v, 0); - + endPointXYZ = vec_madd(splat_u, u_far_delta_xyz, uv_far_initial_xyz); endPointXYZ = vec_madd(splat_v, v_far_delta_xyz, endPointXYZ); - + startPointXYZ = vec_madd(splat_u, u_near_delta_xyz, uv_near_initial_xyz); startPointXYZ = vec_madd(splat_v, v_near_delta_xyz, startPointXYZ); - + *((float*)&startPointXYZ + 3) = 1.0f; - + vXYZ = vec_sub(endPointXYZ, startPointXYZ); - + vector_t0 = vec_re(vXYZ); vector_t1 = vec_nmsub(vector_t0, vXYZ, splat_one); invVXYZ = vec_madd(vector_t0, vector_t1, vector_t0); - + signVXYZ = vec_cmpgt(vXYZ, splat_zero); - + // set up the side crossing for x, y, and z sideCrossingXYZ = vec_and(signVXYZ, splat_int_one); sideCrossingXYZ = vec_add(sideCrossingXYZ, splat_neg_xyz); - + curNodeIndex = startNodeIndex; - + #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC funcOctantStart = UUrMachineTime_High(); #endif - + while(1) { UUmAssert(AKmOctTree_IsLeafNode(curNodeIndex)); if(0xFFFFFFFF == curNodeIndex) break; - + UUmAssert(AKmOctTree_GetLeafIndex(curNodeIndex) < inEnvironment->octTree->leafNodeArray->numNodes); - + curOTLeafNode = leafNodeArray + AKmOctTree_GetLeafIndex(curNodeIndex); - + UUrBitVector_SetBit( environmentPrivate->otLeafNodeVisibility, AKmOctTree_GetLeafIndex(curNodeIndex)); - + // *(UUtUns32*)&splat_dim_Encode = curOTLeafNode->dim_Encode; splat_dim_Encode = vec_splat(splat_dim_Encode, 0); - + curFullDim = (float)(1 << ((curOTLeafNode->dim_Encode >> AKcOctTree_Shift_Dim) & AKcOctTree_Mask_Dim)); curFullDim *= AKcMinOTDim; *(float*)&splat_curFullDim = curFullDim; splat_curFullDim = vec_splat(splat_curFullDim, 0); - + int_t0 = vec_sr(splat_dim_Encode, shift_XYZ); int_t0 = vec_and(int_t0, mask_XYZ); - + maxXYZ = vec_ctf(int_t0, 0); - + maxXYZ = vec_sub(maxXYZ, splat_255); maxXYZ = vec_madd(maxXYZ, splat_minOTDim, splat_zero); minXYZ = vec_sub(maxXYZ, splat_curFullDim); - + *((float*)&minXYZ + 3) = -1e9; *((float*)&maxXYZ + 3) = 1e9; - + #if defined(DEBUG_COLLISION2_TRAVERSAL) && DEBUG_COLLISION2_TRAVERSAL - + bBox.minPoint.x = *((float*)&minXYZ + 0); bBox.minPoint.y = *((float*)&minXYZ + 1); bBox.minPoint.z = *((float*)&minXYZ + 2); bBox.maxPoint.x = *((float*)&maxXYZ + 0); bBox.maxPoint.y = *((float*)&maxXYZ + 1); bBox.maxPoint.z = *((float*)&maxXYZ + 2); - + in = CLrBox_Line(&bBox, (M3tPoint3D*)&startPointXYZ, (M3tPoint3D*)&endPointXYZ); - + UUmAssert(in); #endif - + stopChecking = UUcFalse; - + startIndirectIndex = curOTLeafNode->gqIndirectIndex_Encode; - + if(startIndirectIndex == 0) { #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC - + funcNumSkippedOctants++; - + #endif - + goto skip; } - + length = (UUtUns8)(startIndirectIndex & 0xFF); startIndirectIndex >>= 8; - + #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC numQuadChecks = 0; funcQuadTraversalStart = UUrMachineTime_High(); #endif - + for(curGQIndIndex = 0; curGQIndIndex < length; curGQIndIndex++) { curGQIndex = octTreeGQIndices[curGQIndIndex + startIndirectIndex]; - + UUmAssert(curGQIndex < inEnvironment->gqGeneralArray->numGQs); - + curGQGeneral = gqGeneralArray + curGQIndex; curGQCollision = gqCollisionArray + curGQIndex; - + gotPlaneEqu = UUcFalse; - + //Mark this gq as visible if(UUrBitVector_TestAndSetBit(gqComputedBackFaceBV, curGQIndex)) { @@ -621,9 +621,9 @@ AKrEnvironment_RayCastOctTree_SIMD( if(!(curGQGeneral->flags & AKcGQ_Flag_2Sided)) { vector float curPointXYZ; - + gotPlaneEqu = UUcTrue; - + #if 0 // Remove backfacing stuff AKmPlaneEqu_GetComponents( @@ -631,31 +631,31 @@ AKrEnvironment_RayCastOctTree_SIMD( planeEquArray, a, b, c, d); #endif - + planeEqu = planeEquArray[AKmPlaneEqu_GetIndex(curGQCollision->planeEquIndex)]; if(AKmPlaneEqu_IsNegative(curGQCollision->planeEquIndex)) { vector unsigned long signBit = vec_sl((vector unsigned long)(0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF), (vector unsigned long)(0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF)); planeEqu = (vector float) vec_xor((vector unsigned long) planeEqu, signBit); } - + curPoint = pointArray + curGQGeneral->m3Quad.vertexIndices.indices[0]; - + AVmLoadMisalignedVectorPoint(curPoint, curPointXYZ); viewVectorXYZ = vec_sub(startPointXYZ, curPointXYZ); vector_t0 = vec_madd(viewVectorXYZ, viewVectorXYZ, splat_zero); vector_t1 = vec_splat(vector_t0, 1); vector_t2 = vec_splat(vector_t0, 2); - + vector_t0 = vec_add(vector_t0, vector_t1); vector_t0 = vec_add(vector_t0, vector_t2); - + // compute one over sqrt #if defined(UUmRayCast_AltiVec_Refine) && UUmRayCast_AltiVec_Refine { vector float y0, t0, t1; - + y0 = vec_rsqrte(vector_t0); t0 = vec_madd(y0, y0, splat_zero); t1 = vec_madd(y0, splat_onehalf, splat_zero); @@ -665,18 +665,18 @@ AKrEnvironment_RayCastOctTree_SIMD( #else vector_t0 = vec_rsqrte(vector_t0); #endif - + vector_t0 = vec_splat(vector_t0, 0); - + viewVectorXYZ = vec_madd(viewVectorXYZ, vector_t0, splat_zero); - + viewVectorXYZ = vec_madd(viewVectorXYZ, planeEqu, splat_zero); vector_t0 = vec_splat(viewVectorXYZ, 1); vector_t1 = vec_splat(viewVectorXYZ, 2); viewVectorXYZ = vec_add(viewVectorXYZ, vector_t0); viewVectorXYZ = vec_add(viewVectorXYZ, vector_t1); viewVectorXYZ = vec_splat(viewVectorXYZ, 0); - + if(vec_any_lt(viewVectorXYZ, splat_zero)) { UUrBitVector_SetBit(gqBackFaceBV, curGQIndex); @@ -684,23 +684,23 @@ AKrEnvironment_RayCastOctTree_SIMD( } } } - + { UUtUns8* p = (UUtUns8 *)environmentPrivate->gqVisibilityVector + (curGQIndex >> 2); *p |= 0x3 << ((curGQIndex & 0x3) << 1); } - + if(curGQGeneral->flags & (AKcGQ_Flag_VisIgnore | AKcGQ_Flag_Jello | AKcGQ_Flag_Transparent)) continue; - + if(!stopChecking) { - + #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC - + numQuadChecks++; - + #endif - + if(!gotPlaneEqu) { planeEqu = planeEquArray[AKmPlaneEqu_GetIndex(curGQCollision->planeEquIndex)]; @@ -718,12 +718,12 @@ AKrEnvironment_RayCastOctTree_SIMD( denom = vec_add(denom, vector_t1); denom = vec_splat(denom, 0); - + // compute one over denom vector_t0 = vec_re(denom); vector_t1 = vec_nmsub(vector_t0, denom, splat_one); denom = vec_madd(vector_t0, vector_t1, vector_t0); - + num1 = vec_madd(startPointXYZ, planeEqu, splat_zero); vector_t0 = (vector float)vec_sld((vector unsigned char)num1, (vector unsigned char)num1, 4); num1 = vec_add(vector_t0, num1); @@ -731,15 +731,15 @@ AKrEnvironment_RayCastOctTree_SIMD( num1 = vec_add(vector_t0, num1); num1 = vec_nmsub(num1, denom, splat_zero); - + testPointXYZ = vec_madd(vXYZ, num1, startPointXYZ); if(vec_any_lt(num1, splat_zero)) continue; if(vec_any_gt(num1, splat_one)) continue; - + if(vec_any_lt(testPointXYZ, minXYZ)) continue; if(vec_any_gt(testPointXYZ, maxXYZ)) continue; - + if (AKiQuad_PointInQuad( (CLtQuadProjection)curGQCollision->projection, pointArray, @@ -747,7 +747,7 @@ AKrEnvironment_RayCastOctTree_SIMD( testPointXYZ)) { stopChecking = UUcTrue; - + // swap if(curGQIndIndex != 0) { @@ -761,9 +761,9 @@ AKrEnvironment_RayCastOctTree_SIMD( } } } - + #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC - + if(stopChecking) { funcHitOctant_QuadTraversalTime += UUrMachineTime_High() - funcQuadTraversalStart; @@ -779,21 +779,21 @@ AKrEnvironment_RayCastOctTree_SIMD( funcNumMissOctants++; } #endif - + skip: - + #if 0 { M3tPoint3D minPoint; M3tPoint3D maxPoint; - + minPoint.x = minX + 0.1f; minPoint.y = minY + 0.1f; minPoint.z = minZ + 0.1f; maxPoint.x = maxX - 0.1f; maxPoint.y = maxY - 0.1f; maxPoint.z = maxZ - 0.1f; - + if(/*endNodeIndex == curNodeIndex ||*/ stopChecking) { AKiBoundingBox_Draw( @@ -810,7 +810,7 @@ AKrEnvironment_RayCastOctTree_SIMD( } } #endif - + // If we are finished then bail if(stopChecking) break; @@ -820,47 +820,47 @@ AKrEnvironment_RayCastOctTree_SIMD( vector float secondaryCompare; vector float primaryCompare; vector float splat_d; - + planeXYZ = vec_sel(minXYZ, maxXYZ, signVXYZ); - + planeMinusStartXYZ = vec_sub(planeXYZ, startPointXYZ); - + // next set up the secondary compares, YZ and XZ { - + vector float vTemp; vector float pmsTemp; - + vTemp = vec_perm(vXYZ, vXYZ, vPerm); pmsTemp = vec_perm(planeMinusStartXYZ, planeMinusStartXYZ, pmsPerm); - + secondaryCompare = vec_madd(vTemp, pmsTemp, splat_zero); secondaryCompare = vec_abs(secondaryCompare); - + } - + // Now set up the primary compare { vector float primTemp; - + primTemp = vec_perm(vXYZ, vXYZ, primPerm); - + primaryCompare = vec_madd(primTemp, planeMinusStartXYZ, splat_zero); primaryCompare = vec_abs(primaryCompare); - + } - + splat_d = vec_madd(invVXYZ, planeMinusStartXYZ, splat_zero); - + vector_t0 = vec_splat(primaryCompare, 0); vector_t1 = vec_splat(primaryCompare, 1); - + // make the decisions if(vec_any_gt(vector_t0, vector_t1)) { vector_t0 = vec_splat(secondaryCompare, 0); vector_t1 = vec_splat(secondaryCompare, 1); - + if(vec_any_gt(vector_t0, vector_t1)) { sideCrossing = *((UUtUns32*)&sideCrossingXYZ + 2); @@ -887,10 +887,10 @@ AKrEnvironment_RayCastOctTree_SIMD( splat_d = vec_splat(splat_d, 0); } } - + // Lets move to the next node curNodeIndex = curOTLeafNode->adjInfo[sideCrossing]; - + if(!AKmOctTree_IsLeafNode(curNodeIndex)) { vector float splat_curHalfDim; @@ -898,15 +898,15 @@ AKrEnvironment_RayCastOctTree_SIMD( vector float projCenterXYZ; vector float curCenterPointU, curCenterPointV; vector float uc, vc; - + // need to traverse quad tree - + splat_curHalfDim = vec_madd(splat_curFullDim, splat_onehalf, splat_zero); - + curCenterPointXYZ = vec_add(minXYZ, splat_curHalfDim); - + projCenterXYZ = vec_madd(vXYZ, splat_d, startPointXYZ); - + // First compute the intersection point switch(sideCrossing) { @@ -917,7 +917,7 @@ AKrEnvironment_RayCastOctTree_SIMD( uc = vec_splat(projCenterXYZ, 1); vc = vec_splat(projCenterXYZ, 2); break; - + case AKcOctTree_Side_NegY: case AKcOctTree_Side_PosY: curCenterPointU = vec_splat(curCenterPointXYZ, 0); @@ -925,7 +925,7 @@ AKrEnvironment_RayCastOctTree_SIMD( uc = vec_splat(projCenterXYZ, 0); vc = vec_splat(projCenterXYZ, 2); break; - + case AKcOctTree_Side_NegZ: case AKcOctTree_Side_PosZ: curCenterPointU = vec_splat(curCenterPointXYZ, 0); @@ -933,53 +933,53 @@ AKrEnvironment_RayCastOctTree_SIMD( uc = vec_splat(projCenterXYZ, 0); vc = vec_splat(projCenterXYZ, 1); break; - + default: UUmAssert(0); } - + // next traverse the tree while(1) { curQTIntNode = qtInteriorNodeArray + curNodeIndex; - + curOctant = 0; if(vec_any_gt(uc, curCenterPointU)) curOctant |= AKcQuadTree_SideBV_U; if(vec_any_gt(vc, curCenterPointV)) curOctant |= AKcQuadTree_SideBV_V; - + curNodeIndex = curQTIntNode->children[curOctant]; - + if(AKmOctTree_IsLeafNode(curNodeIndex)) break; - + splat_curHalfDim = vec_madd(splat_curFullDim, splat_onehalf, splat_zero); - + if(curOctant & AKcQuadTree_SideBV_U) curCenterPointU = vec_add(curCenterPointU, splat_curHalfDim); else curCenterPointU = vec_sub(curCenterPointU, splat_curHalfDim); - + if(curOctant & AKcQuadTree_SideBV_V) curCenterPointV = vec_add(curCenterPointV, splat_curHalfDim); else curCenterPointV = vec_sub(curCenterPointV, splat_curHalfDim); } } } } - + #if BRENTS_CHEESY_PROFILE && !BRENTS_CHEESY_PROFILE_ONLY_FUNC funcOctantTime += UUrMachineTime_High() - funcOctantStart; #endif - + if(AKgDebug_ShowRays) { M3tPoint3D points[2]; UUtUns16 colorLine; - + points[0] = *(M3tPoint3D*)&startPointXYZ; - + points[0].x += 0.01f; points[0].y += 0.01f; points[0].z += 0.01f; - + points[1] = *(M3tPoint3D*)&testPointXYZ; - + switch(gFrameNum % AKcNumTemperalFrames) { case 0: @@ -991,25 +991,25 @@ AKrEnvironment_RayCastOctTree_SIMD( case 2: colorLine = 0x1f << 0; break; - + } - + M3rGeom_Line_Light( &points[0], &points[1], 0xFFFF); } } - + #if BRENTS_CHEESY_PROFILE funcEnd = UUrMachineTime_High(); - + #if !BRENTS_CHEESY_PROFILE_ONLY_FUNC funcRayTime += funcEnd - funcRayStart; #endif - + funcTime += funcEnd - funcStart; - + #endif #endif } diff --git a/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Template.c b/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Template.c index a027488..7c40889 100644 --- a/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Template.c +++ b/BungieFrameWork/BFW_Source/BFW_Akira/BFW_Akira_Template.c @@ -1,12 +1,12 @@ /* FILE: BFW_Akira_Template.c - + AUTHOR: Brent H. Pease - + CREATED: October 22, 1997 PURPOSE: environment engine - + Copyright 1997 */ @@ -21,7 +21,7 @@ AKrRegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register(AKcTemplate_OctTree, sizeof(AKtOctTree), TMcFolding_Allow); UUmError_ReturnOnError(error); @@ -36,40 +36,40 @@ AKrRegisterTemplates( error = TMrTemplate_Register(AKcTemplate_BSPNodeArray, sizeof(AKtBSPNodeArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(AKcTemplate_GQ_Material, sizeof(AKtGQMaterial), TMcFolding_Allow); UUmError_ReturnOnError(error); error = TMrTemplate_Register(AKcTemplate_GQ_General, sizeof(AKtGQGeneralArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(AKcTemplate_GQ_Render, sizeof(AKtGQRenderArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(AKcTemplate_GQ_Collision, sizeof(AKtGQCollisionArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(AKcTemplate_GQ_Debug, sizeof(AKtGQDebugArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(AKcTemplate_AdjacencyArray, sizeof(AKtAdjacencyArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(AKcTemplate_BNVNodeSideArray, sizeof(AKtBNVNodeSideArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(AKcTemplate_BNVNodeArray, sizeof(AKtBNVNodeArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(AKcTemplate_AlphaBSPTree_NodeArray, sizeof(AKtAlphaBSPTree_NodeArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(AKcTemplate_DoorFrameArray, sizeof(AKtDoorFrameArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(AKcTemplate_Environment, sizeof(AKtEnvironment), TMcFolding_Allow); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_AppUtilities/BFW_AppUtilities.c b/BungieFrameWork/BFW_Source/BFW_AppUtilities/BFW_AppUtilities.c index bc7f746..1446631 100644 --- a/BungieFrameWork/BFW_Source/BFW_AppUtilities/BFW_AppUtilities.c +++ b/BungieFrameWork/BFW_Source/BFW_AppUtilities/BFW_AppUtilities.c @@ -1,12 +1,12 @@ /* FILE: BFW_AppUtilities.c - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: March 2, 1998 - + PURPOSE: application utilities - + Copyright 1998 */ @@ -59,7 +59,7 @@ struct AUtSharedElemArray UUtUns32 elemSize; AUtSharedElemArray_Equal compareFunc; UUtMemory_ParallelArray* parallelArray; - + UUtMemory_ParallelArray_Member* elemArray; UUtMemory_ParallelArray_Member* remapIndexArray; }; @@ -75,22 +75,22 @@ AUrSharedElemArray_New( AUtSharedElemArray_Equal inCompareFunc) { AUtSharedElemArray* newSharedElemArray; - + newSharedElemArray = UUrMemory_Block_New(sizeof(AUtSharedElemArray)); if(newSharedElemArray == NULL) { return NULL; } - + newSharedElemArray->elemSize = inElemSize; newSharedElemArray->compareFunc = inCompareFunc; - + newSharedElemArray->parallelArray = UUrMemory_ParallelArray_New(1000, 0, 1000); if(newSharedElemArray->parallelArray == NULL) { return NULL; } - + newSharedElemArray->elemArray = UUrMemory_ParallelArray_Member_New( newSharedElemArray->parallelArray, @@ -99,7 +99,7 @@ AUrSharedElemArray_New( { return NULL; } - + newSharedElemArray->remapIndexArray = UUrMemory_ParallelArray_Member_New( newSharedElemArray->parallelArray, @@ -108,7 +108,7 @@ AUrSharedElemArray_New( { return NULL; } - + return newSharedElemArray; } @@ -141,29 +141,29 @@ AUrSharedElemArray_FindElem( UUtUns32* remapArray; UUtUns32 remappedIndex; UUtInt16 compareResult; - + UUmAssertReadPtr(outElemIndex, sizeof(UUtUns32)); - + elemMemory = (char*)UUrMemory_ParallelArray_Member_GetMemory(inSharedElemArray->parallelArray, inSharedElemArray->elemArray); remapArray = (UUtUns32*)UUrMemory_ParallelArray_Member_GetMemory(inSharedElemArray->parallelArray, inSharedElemArray->remapIndexArray); elemSize = inSharedElemArray->elemSize; - + lowIndex = 0; highIndex = (UUtUns32)UUrMemory_ParallelArray_GetNumUsedElems(inSharedElemArray->parallelArray); - + *outElemIndex = 0xFFFFFFFF; - + while(lowIndex < highIndex) { midIndex = (lowIndex + highIndex) >> 1; - + remappedIndex = remapArray[midIndex]; - + targetElem = elemMemory + elemSize * remappedIndex; UUmAssertReadPtr(targetElem, elemSize); - + compareResult = inSharedElemArray->compareFunc(inElem, targetElem); - + if(compareResult == 0) { if(outElemIndex != NULL) *outElemIndex = remappedIndex; @@ -178,9 +178,9 @@ AUrSharedElemArray_FindElem( highIndex = midIndex; } } - + *outElemIndex = lowIndex; - + return UUcFalse; } @@ -198,34 +198,34 @@ AUrSharedElemArray_AddElem( UUtUns32* remapArray; UUtUns32 numElems; UUtUns32 lowIndex; - + elemMemory = (char*)UUrMemory_ParallelArray_Member_GetMemory(inSharedElemArray->parallelArray, inSharedElemArray->elemArray); remapArray = (UUtUns32*)UUrMemory_ParallelArray_Member_GetMemory(inSharedElemArray->parallelArray, inSharedElemArray->remapIndexArray); elemSize = inSharedElemArray->elemSize; - + if(AUrSharedElemArray_FindElem( inSharedElemArray, inElem, outElemIndex) == UUcTrue) return UUcError_None; - + numElems = (UUtUns32)UUrMemory_ParallelArray_GetNumUsedElems(inSharedElemArray->parallelArray); if((UUtUns32)(numElems + 1) < numElems) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Can add more than MaxUns32 number elements"); } - - error = + + error = UUrMemory_ParallelArray_AddNewElem( inSharedElemArray->parallelArray, &newIndex, NULL); UUmError_ReturnOnErrorMsg(error, "could not allocate new elem"); - + elemMemory = (char*)UUrMemory_ParallelArray_Member_GetMemory(inSharedElemArray->parallelArray, inSharedElemArray->elemArray); remapArray = (UUtUns32*)UUrMemory_ParallelArray_Member_GetMemory(inSharedElemArray->parallelArray, inSharedElemArray->remapIndexArray); - + lowIndex = *outElemIndex; - + if(lowIndex != newIndex) { UUrMemory_MoveOverlap( @@ -233,13 +233,13 @@ AUrSharedElemArray_AddElem( remapArray + lowIndex + 1, (newIndex - lowIndex) * sizeof(UUtUns32)); } - + remapArray[lowIndex] = (UUtUns32)newIndex; - + newElem = (char*)elemMemory + newIndex * elemSize; - + UUrMemory_MoveFast(inElem, newElem, elemSize); - + if(outElemIndex != NULL) { *outElemIndex = (UUtUns32)newIndex; @@ -258,9 +258,9 @@ AUiSharedElemArray_Compare( char* arrayBase; UUtInt16 compare_function_result; UUtBool result; - + UUmAssertReadPtr(AUgSharedElem_Array, sizeof(AUtSharedElemArray)); - + arrayBase = AUrSharedElemArray_GetList(AUgSharedElem_Array); compare_function_result = AUgSharedElem_Array->compareFunc( @@ -268,7 +268,7 @@ AUiSharedElemArray_Compare( arrayBase + inB * AUgSharedElem_Array->elemSize); result = compare_function_result > 0; - + return result; } @@ -287,16 +287,16 @@ AUrSharedElemArray_Resort( { sortedIndexList[itr] = itr; } - + AUgSharedElem_Array = inSharedElemArray; - + AUrQSort_32( sortedIndexList, numElems, AUiSharedElemArray_Compare); - + AUgSharedElem_Array = NULL; - + return UUcError_None; } @@ -310,31 +310,31 @@ AUrSharedElemArray_Reorder( UUtUns32 numElems; char* originalList; UUtUns32 itr; - + numElems = AUrSharedElemArray_GetNum(inSharedElemArray); - + tempMemory = UUrMemory_Block_New(inSharedElemArray->elemSize * numElems); UUmError_ReturnOnNull(tempMemory); - + originalList = AUrSharedElemArray_GetList(inSharedElemArray); UUmAssertReadPtr(originalList, sizeof(void*)); - + UUrMemory_MoveFast(originalList, tempMemory, inSharedElemArray->elemSize * numElems); - + for(itr = 0; itr < numElems; itr++) { UUmAssert(inRemapArray[itr] < numElems); - + UUrMemory_MoveFast( tempMemory + itr * inSharedElemArray->elemSize, originalList + inRemapArray[itr] * inSharedElemArray->elemSize, inSharedElemArray->elemSize); } - + UUrMemory_Block_Delete(tempMemory); - + AUrSharedElemArray_Resort(inSharedElemArray); - + return UUcError_None; } @@ -343,11 +343,11 @@ AUrSharedElemArray_GetList( AUtSharedElemArray* inSharedElemArray) { void* result; - + result = UUrMemory_ParallelArray_Member_GetMemory(inSharedElemArray->parallelArray, inSharedElemArray->elemArray); UUmAssert(result != NULL); - + return result; } @@ -395,7 +395,7 @@ AUiSharedPointArray_CompareFunc( { return (inPointA->x > inPointB->x) ? 1 : -1; } - + return 0; } @@ -435,16 +435,16 @@ void AUrSharedPointArray_RoundPoint(M3tPoint3D *ioPoint) ioPoint->x*= one_over_epsilon; ioPoint->y*= one_over_epsilon; ioPoint->z*= one_over_epsilon; - + ioPoint->x = (float) MUrFloat_Round_To_Int(ioPoint->x); ioPoint->y = (float) MUrFloat_Round_To_Int(ioPoint->y); ioPoint->z = (float) MUrFloat_Round_To_Int(ioPoint->z); - + ioPoint->x *= UUcEpsilon; ioPoint->y *= UUcEpsilon; ioPoint->z *= UUcEpsilon; #endif - + #if 0 ioPoint->x = inX; ioPoint->y = inY; @@ -467,9 +467,9 @@ AUrSharedPointArray_AddPoint( point3D.x = inX; point3D.y = inY; point3D.z = inZ; - + AUrSharedPointArray_RoundPoint(&point3D); - + return AUrSharedElemArray_AddElem( (AUtSharedElemArray*)inSharedPointArray, @@ -508,7 +508,7 @@ AUrSharedPointArray_Dump( { UUtUns32 i; M3tPoint3D* curPoint; - + for(i = 0, curPoint = AUrSharedPointArray_GetList(inSharedPointArray); i < AUrSharedPointArray_GetNum(inSharedPointArray); i++, curPoint++) @@ -536,110 +536,110 @@ AUrSharedPointArray_CreateTemplate( sharedPoints = AUrSharedPointArray_GetList(inSharedPointArray); numSharedPoints = AUrSharedPointArray_GetNum(inSharedPointArray); - + if(numSharedPoints > UUcMaxUns32) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Too many points in this array"); } - error = + error = TMrConstruction_Instance_Renew( M3cTemplate_Point3DArray, inName, numSharedPoints + M3cExtraCoords, // Hack - this is needed for Akira outReference); - + if(error != UUcError_None) { UUmError_ReturnOnErrorMsg(error, "Could not create point array"); } - + pointArray = (*outReference)->points; - + for(i = 0; i < numSharedPoints; i++) { pointArray[i] = sharedPoints[i]; } - + (*outReference)->numPoints = numSharedPoints; - + return UUcError_None; } UUtError AUrSharedPointArray_InterpolatePoint( AUtSharedPointArray* inPointArray, - float inA, - float inB, - float inC, - float inD, + float inA, + float inB, + float inC, + float inD, M3tPoint3D* inInVertex, M3tPoint3D* inOutVertex, UUtUns32 *outNewVertexIndex) { /* parametric equation of a line: - + X(t) = Xm * t + Xi Y(t) = Ym * t + Yi Z(t) = Zm * t + Zi - + F(t) = [X(t), Y(t), Z(t)] - + F(0) = inInVertex F(1) = inOutVertex - + Xi = inInVertex->x, Xm = (inOutVertex->x - inInVertex->x) Yi = inInVertex->y, Ym = (inOutVertex->y - inInVertex->y) Zi = inInVertex->z, Zm = (inOutVertex->z - inInVertex->z) - + plane equation: - + a * X + b * Y + c * Z + d = 0 - + substitute: - + a * X(t) + b * Y(t) + c * Z(t) + d = 0 - + a * (Xm * t + Xi) + b * (Ym * t + Yi) + c * (Zm * t + Zi) + d = 0 - + ... - + t = -(a * Xi + b * Yi + c * Zi + d) / (a * Xm + b * Ym + c * Zm) - + plug t back into X(t), Y(t), Z(t) for final result - + */ - + UUtError error; float Xi, Yi, Zi; float Xm, Ym, Zm; float Xn, Yn, Zn; float denom; float t; - + Xi = inInVertex->x; Yi = inInVertex->y; Zi = inInVertex->z; - + Xm = (inOutVertex->x - Xi); Ym = (inOutVertex->y - Yi); Zm = (inOutVertex->z - Zi); - + denom = inA * Xm + inB * Ym + inC * Zm; - + UUmAssert(denom != 0.0f); - + t = -(inA * Xi + inB * Yi + inC * Zi + inD) / denom; - + if(t > 0.0011f) t -= 0.0011f; else t -= t * 0.1f; - + Xn = Xm * t + Xi; Yn = Ym * t + Yi; Zn = Zm * t + Zi; - - error = + + error = AUrSharedPointArray_AddPoint( inPointArray, Xn, @@ -647,7 +647,7 @@ AUrSharedPointArray_InterpolatePoint( Zn, outNewVertexIndex); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -695,7 +695,7 @@ AUiSharedPlaneEquArray_CompareFunc( { return UUmFloat_CompareGT(inPlaneEquA->a, inPlaneEquB->a) ? 1 : -1; } - + return 0; } @@ -737,7 +737,7 @@ AUrSharedPlaneEquArray_AddPlaneEqu( UUtUns32 highBit; M3tPlaneEquation planeEqu; AUtSharedElemArray* sharedElemArray = (AUtSharedElemArray*)inSharedPlaneEquArray; - + if(inD != 0.0f) { if(inD < 0.0f) @@ -746,9 +746,9 @@ AUrSharedPlaneEquArray_AddPlaneEqu( planeEqu.b = -inB; planeEqu.c = -inC; planeEqu.d = -inD; - + highBit = 0x80000000; - + } else { @@ -756,29 +756,29 @@ AUrSharedPlaneEquArray_AddPlaneEqu( planeEqu.b = inB; planeEqu.c = inC; planeEqu.d = inD; - + highBit = 0; } - + error = AUrSharedElemArray_AddElem( (AUtSharedElemArray*)inSharedPlaneEquArray, &planeEqu, &result); UUmError_ReturnOnErrorMsg(error, "could not add new elem"); - + if(outPlaneEquIndex != NULL) { *outPlaneEquIndex = result | highBit; } - + UUmAssert(result < 0x7FFFFFFF); } else { UUtUns32 curPlaneEquIndex; M3tPlaneEquation* curPlaneEqu; - + for(curPlaneEquIndex = 0, curPlaneEqu = (M3tPlaneEquation*)UUrMemory_ParallelArray_Member_GetMemory(sharedElemArray->parallelArray, sharedElemArray->elemArray); curPlaneEquIndex < UUrMemory_ParallelArray_GetNumUsedElems(sharedElemArray->parallelArray); @@ -824,10 +824,10 @@ AUrSharedPlaneEquArray_AddPlaneEqu( { *outPlaneEquIndex = result; } - + UUmAssert(result < 0x7FFFFFFF); } - + return UUcError_None; } @@ -858,7 +858,7 @@ AUrSharedPlaneEquArray_Dump( { UUtUns32 i; M3tPlaneEquation* curPlaneEqu; - + for(i = 0, curPlaneEqu = AUrSharedPlaneEquArray_GetList(inSharedPlaneEquArray); i < AUrSharedPlaneEquArray_GetNum(inSharedPlaneEquArray); i++, curPlaneEqu++) @@ -887,25 +887,25 @@ AUrSharedPlaneEquArray_CreateTemplate( sharedPlaneEqus = AUrSharedPlaneEquArray_GetList(inSharedPlaneEquArray); numSharedPlaneEqus = AUrSharedPlaneEquArray_GetNum(inSharedPlaneEquArray); - error = + error = TMrConstruction_Instance_Renew( M3cTemplate_PlaneEquationArray, inName, numSharedPlaneEqus, outReference); - + if(error != UUcError_None) { UUmError_ReturnOnErrorMsg(error, "Could not create PlaneEqu array"); } - + planeEquArray = (*outReference)->planes; - + for(i = 0; i < numSharedPlaneEqus; i++) { planeEquArray[i] = sharedPlaneEqus[i]; } - + return UUcError_None; } @@ -930,7 +930,7 @@ AUrSharedPlaneEquArray_FindPlaneEqu( planeEqu.b = -inB; planeEqu.c = -inC; planeEqu.d = -inD; - + highBit = 0x80000000; } else @@ -939,10 +939,10 @@ AUrSharedPlaneEquArray_FindPlaneEqu( planeEqu.b = inB; planeEqu.c = inC; planeEqu.d = inD; - + highBit = 0; } - + if(AUrSharedElemArray_FindElem( sharedElemArray, &planeEqu, @@ -954,13 +954,13 @@ AUrSharedPlaneEquArray_FindPlaneEqu( return UUcTrue; } - + if(inD == 0.0f) { planeEqu.a = -inA; planeEqu.b = -inB; planeEqu.c = -inC; - + if(AUrSharedElemArray_FindElem( sharedElemArray, &planeEqu, @@ -973,13 +973,13 @@ AUrSharedPlaneEquArray_FindPlaneEqu( return UUcTrue; } } - + remapArray = (UUtUns32*)UUrMemory_ParallelArray_Member_GetMemory( sharedElemArray->parallelArray, sharedElemArray->remapIndexArray); - + *outPlaneEquIndex = remapArray[*outPlaneEquIndex]; - + return UUcFalse; } @@ -992,77 +992,77 @@ AUiSharedQuadArray_CompareFunc( M3tQuad* inQuadB) { if( - inQuadA->indices[0] == inQuadB->indices[0] && - inQuadA->indices[1] == inQuadB->indices[1] && - inQuadA->indices[2] == inQuadB->indices[2] && + inQuadA->indices[0] == inQuadB->indices[0] && + inQuadA->indices[1] == inQuadB->indices[1] && + inQuadA->indices[2] == inQuadB->indices[2] && inQuadA->indices[3] == inQuadB->indices[3]) { return 0; } if( - inQuadA->indices[0] == inQuadB->indices[1] && - inQuadA->indices[1] == inQuadB->indices[2] && - inQuadA->indices[2] == inQuadB->indices[3] && + inQuadA->indices[0] == inQuadB->indices[1] && + inQuadA->indices[1] == inQuadB->indices[2] && + inQuadA->indices[2] == inQuadB->indices[3] && inQuadA->indices[3] == inQuadB->indices[0]) { return 0; } if( - inQuadA->indices[0] == inQuadB->indices[2] && - inQuadA->indices[1] == inQuadB->indices[3] && - inQuadA->indices[2] == inQuadB->indices[0] && + inQuadA->indices[0] == inQuadB->indices[2] && + inQuadA->indices[1] == inQuadB->indices[3] && + inQuadA->indices[2] == inQuadB->indices[0] && inQuadA->indices[3] == inQuadB->indices[1]) { return 0; } if( - inQuadA->indices[0] == inQuadB->indices[3] && - inQuadA->indices[1] == inQuadB->indices[0] && - inQuadA->indices[2] == inQuadB->indices[1] && + inQuadA->indices[0] == inQuadB->indices[3] && + inQuadA->indices[1] == inQuadB->indices[0] && + inQuadA->indices[2] == inQuadB->indices[1] && inQuadA->indices[3] == inQuadB->indices[2]) { return 0; } if( - inQuadA->indices[0] == inQuadB->indices[3] && - inQuadA->indices[1] == inQuadB->indices[2] && - inQuadA->indices[2] == inQuadB->indices[1] && + inQuadA->indices[0] == inQuadB->indices[3] && + inQuadA->indices[1] == inQuadB->indices[2] && + inQuadA->indices[2] == inQuadB->indices[1] && inQuadA->indices[3] == inQuadB->indices[0]) { return 0; } if( - inQuadA->indices[0] == inQuadB->indices[2] && - inQuadA->indices[1] == inQuadB->indices[1] && - inQuadA->indices[2] == inQuadB->indices[0] && + inQuadA->indices[0] == inQuadB->indices[2] && + inQuadA->indices[1] == inQuadB->indices[1] && + inQuadA->indices[2] == inQuadB->indices[0] && inQuadA->indices[3] == inQuadB->indices[3]) { return 0; } if( - inQuadA->indices[0] == inQuadB->indices[1] && - inQuadA->indices[1] == inQuadB->indices[0] && - inQuadA->indices[2] == inQuadB->indices[3] && + inQuadA->indices[0] == inQuadB->indices[1] && + inQuadA->indices[1] == inQuadB->indices[0] && + inQuadA->indices[2] == inQuadB->indices[3] && inQuadA->indices[3] == inQuadB->indices[2]) { return 0; } if( - inQuadA->indices[0] == inQuadB->indices[0] && - inQuadA->indices[1] == inQuadB->indices[3] && - inQuadA->indices[2] == inQuadB->indices[2] && + inQuadA->indices[0] == inQuadB->indices[0] && + inQuadA->indices[1] == inQuadB->indices[3] && + inQuadA->indices[2] == inQuadB->indices[2] && inQuadA->indices[3] == inQuadB->indices[1]) { return 0; } - + if(inQuadA->indices[0] == inQuadB->indices[0]) { if(inQuadA->indices[1] == inQuadB->indices[1]) @@ -1085,7 +1085,7 @@ AUiSharedQuadArray_CompareFunc( { return inQuadA->indices[0] > inQuadB->indices[0] ? 1 : -1; } - + return 0; } @@ -1123,7 +1123,7 @@ AUrSharedQuadArray_AddQuad( UUtUns32 *outQuadIndex) { M3tQuad quad; - + UUmAssert(inIndex0 < 0x80000000); UUmAssert(inIndex1 < 0x80000000); UUmAssert(inIndex2 < 0x80000000); @@ -1133,7 +1133,7 @@ AUrSharedQuadArray_AddQuad( quad.indices[1] = inIndex1; quad.indices[2] = inIndex2; quad.indices[3] = inIndex3; - + return AUrSharedElemArray_AddElem( (AUtSharedElemArray*)inSharedQuadArray, @@ -1169,7 +1169,7 @@ AUrSharedQuadArray_Dump( { UUtUns32 i; M3tQuad* curQuad; - + for(i = 0, curQuad = AUrSharedQuadArray_GetList(inSharedQuadArray); i < AUrSharedQuadArray_GetNum(inSharedQuadArray); i++, curQuad++) @@ -1194,37 +1194,37 @@ AUrSharedQuadArray_CreateTemplate( UUtUns32 numSharedQuads; M3tQuad* quadArray; UUtUns32 i; - + sharedQuads = AUrSharedQuadArray_GetList(inSharedQuadArray); numSharedQuads = AUrSharedQuadArray_GetNum(inSharedQuadArray); - error = + error = TMrConstruction_Instance_Renew( M3cTemplate_QuadArray, inName, numSharedQuads, outReference); - + if(error != UUcError_None) { UUmError_ReturnOnErrorMsg(error, "Could not create Quad array"); } - + quadArray = (*outReference)->quads; - + for(i = 0; i < numSharedQuads; i++) { UUmAssert(sharedQuads[i].indices[0] < UUcMaxUns32); UUmAssert(sharedQuads[i].indices[1] < UUcMaxUns32); UUmAssert(sharedQuads[i].indices[2] < UUcMaxUns32); UUmAssert(sharedQuads[i].indices[3] < UUcMaxUns32); - + quadArray[i].indices[0] = sharedQuads[i].indices[0]; quadArray[i].indices[1] = sharedQuads[i].indices[1]; quadArray[i].indices[2] = sharedQuads[i].indices[2]; quadArray[i].indices[3] = sharedQuads[i].indices[3]; } - + return UUcError_None; } @@ -1293,11 +1293,11 @@ AUrSharedVectorArray_AddVector( UUtUns32 *outVectorIndex) { M3tVector3D vector3D; - + vector3D.x = inX; vector3D.y = inY; vector3D.z = inZ; - + return AUrSharedElemArray_AddElem( (AUtSharedElemArray*)inSharedVectorArray, @@ -1326,7 +1326,7 @@ AUrSharedVectorArray_Dump( { UUtUns32 i; M3tVector3D* curVector; - + for(i = 0, curVector = AUrSharedVectorArray_GetList(inSharedVectorArray); i < AUrSharedVectorArray_GetNum(inSharedVectorArray); i++, curVector++) @@ -1354,25 +1354,25 @@ AUrSharedVectorArray_CreateTemplate( sharedVectors = AUrSharedVectorArray_GetList(inSharedVectorArray); numSharedVectors = AUrSharedVectorArray_GetNum(inSharedVectorArray); - error = + error = TMrConstruction_Instance_Renew( M3cTemplate_Vector3DArray, inName, numSharedVectors, outReference); - + if(error != UUcError_None) { UUmError_ReturnOnErrorMsg(error, "Could not create Vector array"); } - + vectorArray = (*outReference)->vectors; - + for(i = 0; i < numSharedVectors; i++) { vectorArray[i] = sharedVectors[i]; } - + return UUcError_None; } @@ -1392,14 +1392,14 @@ AUiSharedTexCoordArray_CompareFunc( } else { - return UUmFloat_CompareGT(inTexCoordA->v, inTexCoordB->v) ? 1 : -1; + return UUmFloat_CompareGT(inTexCoordA->v, inTexCoordB->v) ? 1 : -1; } } else { - return UUmFloat_CompareGT(inTexCoordA->u, inTexCoordB->u) ? 1 : -1; + return UUmFloat_CompareGT(inTexCoordA->u, inTexCoordB->u) ? 1 : -1; } - + return 0; } @@ -1435,21 +1435,21 @@ AUrSharedTexCoordArray_AddTexCoord( UUtUns32 *outTexCoordIndex) { M3tTextureCoord texCoord; - + #if 0 inU *= 1.0f / UUcEpsilon; inV *= 1.0f / UUcEpsilon; - + inU = UUmFloat_Round(inU); inV = UUmFloat_Round(inV); inU *= UUcEpsilon; inV *= UUcEpsilon; #endif - + texCoord.u = inU; texCoord.v = inV; - + return AUrSharedElemArray_AddElem( (AUtSharedElemArray*)inSharedTexCoordArray, @@ -1485,33 +1485,33 @@ AUrSharedTexCoordArray_CreateTemplate( sharedTexCoords = AUrSharedTexCoordArray_GetList(inSharedTexCoordArray); numSharedTexCoords = AUrSharedTexCoordArray_GetNum(inSharedTexCoordArray); - + if(numSharedTexCoords > UUcMaxUns32) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Too many texture coords"); } - error = + error = TMrConstruction_Instance_Renew( M3cTemplate_TextureCoordArray, inName, numSharedTexCoords + M3cExtraCoords, outReference); - + if(error != UUcError_None) { UUmError_ReturnOnErrorMsg(error, "Could not create TexCoord array"); } - + texCoordArray = (*outReference)->textureCoords; - + for(i = 0; i < numSharedTexCoords; i++) { texCoordArray[i] = sharedTexCoords[i]; } - + (*outReference)->numTextureCoords = numSharedTexCoords; - + return UUcError_None; } @@ -1531,14 +1531,14 @@ AUiSharedEdgeArray_CompareFunc( } else { - return inEdgeA->vIndex1 > inEdgeB->vIndex1 ? 1 : -1; + return inEdgeA->vIndex1 > inEdgeB->vIndex1 ? 1 : -1; } } else { - return inEdgeA->vIndex0 > inEdgeB->vIndex0 ? 1 : -1; + return inEdgeA->vIndex0 > inEdgeB->vIndex0 ? 1 : -1; } - + return 0; } @@ -1579,7 +1579,7 @@ AUrSharedEdgeArray_AddEdge( UUtUns32 resultIndex; AUtEdge* resultEdge; UUtUns32 i; - + if(inEdge0 < inEdge1) { edge.vIndex0 = inEdge0; @@ -1590,22 +1590,22 @@ AUrSharedEdgeArray_AddEdge( edge.vIndex0 = inEdge1; edge.vIndex1 = inEdge0; } - + for(i = 0; i < AUcMaxQuadsPerEdge; i++) { edge.quadIndices[i] = UUcMaxUns32; } - - error = + + error = AUrSharedElemArray_AddElem( (AUtSharedElemArray*)inSharedEdgeArray, &edge, &resultIndex); UUmError_ReturnOnError(error); - - resultEdge = + + resultEdge = AUrSharedEdgeArray_GetList(inSharedEdgeArray) + resultIndex; - + for(i = 0; i < AUcMaxQuadsPerEdge; i++) { if(resultEdge->quadIndices[i] == UUcMaxUns32) @@ -1614,17 +1614,17 @@ AUrSharedEdgeArray_AddEdge( break; } } - + if(i >= AUcMaxQuadsPerEdge) { UUmError_ReturnOnErrorMsgP(UUcError_Generic, "An edge is shared by more then %d quads, talk to brent", AUcMaxQuadsPerEdge, 0, 0); } - + if(outEdgeIndex != NULL) { *outEdgeIndex = resultIndex; } - + return UUcError_None; } @@ -1640,16 +1640,16 @@ AUrSharedEdgeArray_AddPoly( UUtUns32 curVertexItr; UUtUns32 vIndex0; UUtUns32 vIndex1; - + UUmAssertReadPtr(inVertices, sizeof(UUtUns32) * inNumVertices); UUmAssertWritePtr(outEdgeIndices, sizeof(UUtUns32) * inNumVertices); - + for(curVertexItr = 0; curVertexItr < inNumVertices; curVertexItr++) { vIndex0 = curVertexItr; vIndex1 = (curVertexItr + 1) % inNumVertices; - - error = + + error = AUrSharedEdgeArray_AddEdge( inSharedEdgeArray, inVertices[vIndex0], @@ -1658,7 +1658,7 @@ AUrSharedEdgeArray_AddPoly( &outEdgeIndices[curVertexItr]); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -1696,7 +1696,7 @@ AUrSharedEdge_FindOtherVertex( { if(inEdge->vIndex0 == inVertexIndex) return inEdge->vIndex1; else if(inEdge->vIndex1 == inVertexIndex) return inEdge->vIndex0; - + return UUcMaxUns32; } @@ -1706,12 +1706,12 @@ AUrSharedEdge_GetOtherFaceIndex( UUtUns32 inFaceIndex) { UUtUns32 itr; - + for(itr = 0; itr < AUcMaxQuadsPerEdge; itr++) { if(inEdge->quadIndices[itr] != inFaceIndex) return inEdge->quadIndices[itr]; } - + return UUcMaxUns32; } @@ -1725,16 +1725,16 @@ AUrSharedEdge_Triangle_FindEdge( UUtUns32 itr; AUtEdge* targetEdge; AUtEdge* edgeList; - + edgeList = (AUtEdge*)AUrSharedElemArray_GetList((AUtSharedElemArray*)inSharedEdgeArray); - + for(itr = 0; itr < 3; itr++) { targetEdge = edgeList + inTriEdges->indices[itr]; if((targetEdge->vIndex0 == inIndex0 && targetEdge->vIndex1 == inIndex1) || (targetEdge->vIndex0 == inIndex1 && targetEdge->vIndex1 == inIndex0)) return targetEdge; } - + return NULL; } @@ -1780,17 +1780,17 @@ AUrSharedStringArray_AddString( AUtSharedString newString; UUtUns32 stringIndex; - + if(strlen(inString) > AUcMaxStringLength) { UUmError_ReturnOnErrorMsg(UUcError_None, "String too long"); } - + if(outStringIndex == NULL) outStringIndex = &stringIndex; UUrString_Copy(newString.string, inString, AUcMaxStringLength); newString.data = inData; - + return AUrSharedElemArray_AddElem( (AUtSharedElemArray*)inSharedStringArray, &newString, @@ -1818,14 +1818,14 @@ AUrSharedStringArray_GetIndex( UUtUns32 *outIndex) { AUtSharedString newString; - + if(strlen(inString) > AUcMaxStringLength) { UUmError_ReturnOnErrorMsg(UUcError_None, "String too long"); } - + UUrString_Copy(newString.string, inString, AUcMaxStringLength); - + return AUrSharedElemArray_FindElem( (AUtSharedElemArray*)inSharedStringArray, &newString, @@ -1840,8 +1840,8 @@ AUrSharedStringArray_GetData( { UUtUns32 index; AUtSharedString* desiredString; - - + + if(AUrSharedStringArray_GetIndex( inSharedStringArray, inString, @@ -1849,11 +1849,11 @@ AUrSharedStringArray_GetData( { return UUcFalse; } - + desiredString = AUrSharedStringArray_GetList(inSharedStringArray) + index; - + *outData = desiredString->data; - + return UUcTrue; } @@ -2001,7 +2001,7 @@ AUrHashTable_Reset( { UUmAssert(!"not implemented"); } - + void * AUrHashTable_Add( AUtHashTable* inHashTable, @@ -2027,7 +2027,7 @@ AUrHashTable_Add( return current_data_pointer; } - + void* AUrHashTable_Find( AUtHashTable* inHashTable, @@ -2078,7 +2078,7 @@ AUrQuad_FindMinMax( curX = inPointList[inQuad->indices[i]].x; curY = inPointList[inQuad->indices[i]].y; curZ = inPointList[inQuad->indices[i]].z; - + if(curX < quadMinX) quadMinX = curX; if(curY < quadMinY) quadMinY = curY; if(curZ < quadMinZ) quadMinZ = curZ; @@ -2086,7 +2086,7 @@ AUrQuad_FindMinMax( if(curY > quadMaxY) quadMaxY = curY; if(curZ > quadMaxZ) quadMaxZ = curZ; } - + *outMinX = quadMinX; *outMaxX = quadMaxX; *outMinY = quadMinY; @@ -2104,25 +2104,25 @@ AUrQuad_QuadOverlapsQuad( { float quadMinX, quadMaxX, quadMinY, quadMaxY, quadMinZ, quadMaxZ; float overlapMinX, overlapMaxX, overlapMinY, overlapMaxY, overlapMinZ, overlapMaxZ; - + if(inQuad == inQuadOverlapping) return UUcTrue; - + // XXX - HACK ALERT! - + AUrQuad_FindMinMax( inPointList, - inQuad, + inQuad, &quadMinX, &quadMaxX, &quadMinY, &quadMaxY, &quadMinZ, &quadMaxZ); AUrQuad_FindMinMax( inPointList, - inQuadOverlapping, + inQuadOverlapping, &overlapMinX, &overlapMaxX, &overlapMinY, &overlapMaxY, &overlapMinZ, &overlapMaxZ); - + if( overlapMinX > quadMaxX || overlapMaxX < quadMinX || overlapMinY > quadMaxY || overlapMaxY < quadMinY || @@ -2130,7 +2130,7 @@ AUrQuad_QuadOverlapsQuad( { return UUcFalse; } - + return UUcTrue; } @@ -2142,24 +2142,24 @@ AUrQuad_QuadWithinQuad( { float quadMinX, quadMaxX, quadMinY, quadMaxY, quadMinZ, quadMaxZ; float solidMinX, solidMaxX, solidMinY, solidMaxY, solidMinZ, solidMaxZ; - - + + // XXX - HACK ALERT! eventually do a better quad within quad test - + AUrQuad_FindMinMax( inPointList, - inQuad, + inQuad, &quadMinX, &quadMaxX, &quadMinY, &quadMaxY, &quadMinZ, &quadMaxZ); AUrQuad_FindMinMax( inPointList, - inQuadWithin, + inQuadWithin, &solidMinX, &solidMaxX, &solidMinY, &solidMaxY, &solidMinZ, &solidMaxZ); - + if( UUmFloat_CompareLE(solidMinX, quadMinX) && UUmFloat_CompareGE(solidMaxX, quadMaxX) && UUmFloat_CompareLE(solidMinY, quadMinY) && UUmFloat_CompareGE(solidMaxY, quadMaxY) && @@ -2167,7 +2167,7 @@ AUrQuad_QuadWithinQuad( { return UUcTrue; } - + return UUcFalse; } @@ -2180,14 +2180,14 @@ AUrQuad_ComputeCenter( float *outCenterZ) { float quadMinX, quadMaxX, quadMinY, quadMaxY, quadMinZ, quadMaxZ; - + AUrQuad_FindMinMax( inPointList, - inQuad, + inQuad, &quadMinX, &quadMaxX, &quadMinY, &quadMaxY, &quadMinZ, &quadMaxZ); - + *outCenterX = (quadMinX + quadMaxX) * 0.5f; *outCenterY = (quadMinY + quadMaxY) * 0.5f; *outCenterZ = (quadMinZ + quadMaxZ) * 0.5f; @@ -2206,18 +2206,18 @@ AUrParse_CoreGeometry( UUtUns32 numTris; UUtUns32 numQuads; UUtUns32 i; - + float x, y, z, nx, ny, nz, u, v; UUtUns32 i0, i1, i2, i3; - + error = BFrTextFile_VerifyNextStr(inTextFile, "num points"); UUmError_ReturnOnError(error); - + numPoints = BFrTextFile_GetUUtUns16(inTextFile); - + error = BFrTextFile_VerifyNextStr(inTextFile, "x,y,z,nx,ny,nz,u,v"); UUmError_ReturnOnError(error); - + for(i = 0; i < numPoints; i++) { x = BFrTextFile_GetFloat(inTextFile); @@ -2228,18 +2228,18 @@ AUrParse_CoreGeometry( nz = BFrTextFile_GetFloat(inTextFile); u = BFrTextFile_GetFloat(inTextFile); v = BFrTextFile_GetFloat(inTextFile); - + error = BFrTextFile_VerifyNextStr(inTextFile, ""); UUmError_ReturnOnError(error); - + inAddPointFunc(inRefCon, i, x, y, z, nx, ny, nz, u, v); } - + error = BFrTextFile_VerifyNextStr(inTextFile, "num triangles"); UUmError_ReturnOnError(error); - + numTris = BFrTextFile_GetUUtUns16(inTextFile); - + error = BFrTextFile_VerifyNextStr(inTextFile, "index, index, index, nx, ny, nz"); UUmError_ReturnOnError(error); @@ -2251,19 +2251,19 @@ AUrParse_CoreGeometry( nx = BFrTextFile_GetFloat(inTextFile); ny = BFrTextFile_GetFloat(inTextFile); nz = BFrTextFile_GetFloat(inTextFile); - + error = BFrTextFile_VerifyNextStr(inTextFile, ""); UUmError_ReturnOnError(error); - + error = inAddTriFunc(inRefCon, i0, i1, i2, nx, ny, nz); UUmError_ReturnOnError(error); } - + error = BFrTextFile_VerifyNextStr(inTextFile, "num quads"); UUmError_ReturnOnError(error); - + numQuads = BFrTextFile_GetUUtUns16(inTextFile); - + error = BFrTextFile_VerifyNextStr(inTextFile, "index, index, index, index, nx, ny, nz"); UUmError_ReturnOnError(error); @@ -2276,14 +2276,14 @@ AUrParse_CoreGeometry( nx = BFrTextFile_GetFloat(inTextFile); ny = BFrTextFile_GetFloat(inTextFile); nz = BFrTextFile_GetFloat(inTextFile); - + error = BFrTextFile_VerifyNextStr(inTextFile, ""); UUmError_ReturnOnError(error); - + error = inAddQuadFunc(inRefCon, i0, i1, i2, i3, nx, ny, nz); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -2294,28 +2294,28 @@ AUrParse_EnvGeometry( AUtParseGeometry_AddPointFunc inAddPointFunc, // These can be NULL AUtParseGeometry_AddEnvTriangleFunc inAddTriFunc, AUtParseGeometry_AddEnvQuadFunc inAddQuadFunc, - void* inRefCon) + void* inRefCon) { UUtError error; UUtUns32 numPoints; UUtUns32 numTris; UUtUns32 numQuads; UUtUns32 i; - + float u, v; UUtUns32 i0, i1, i2, i3; char* textureName; M3tPoint3D point; M3tVector3D normal; - + error = BFrTextFile_VerifyNextStr(inTextFile, "num points"); UUmError_ReturnOnError(error); - + numPoints = BFrTextFile_GetUUtUns16(inTextFile); - + error = BFrTextFile_VerifyNextStr(inTextFile, "x,y,z,nx,ny,nz,u,v"); UUmError_ReturnOnError(error); - + for(i = 0; i < numPoints; i++) { point.x = BFrTextFile_GetFloat(inTextFile); @@ -2332,15 +2332,15 @@ AUrParse_EnvGeometry( error = BFrTextFile_VerifyNextStr(inTextFile, ""); UUmError_ReturnOnError(error); - + if (inAddPointFunc) inAddPointFunc(inRefCon, i, point.x, point.y, point.z, normal.x, normal.y, normal.z, u, v); } - + error = BFrTextFile_VerifyNextStr(inTextFile, "num triangles"); UUmError_ReturnOnError(error); - + numTris = BFrTextFile_GetUUtUns16(inTextFile); - + error = BFrTextFile_VerifyNextStr(inTextFile, "index, index, index, nx, ny, nz"); UUmError_ReturnOnError(error); @@ -2355,22 +2355,22 @@ AUrParse_EnvGeometry( textureName = BFrTextFile_GetNextStr(inTextFile); MUrMatrix_MultiplyNormal(&normal, inMatrix, &normal); - + error = BFrTextFile_VerifyNextStr(inTextFile, ""); UUmError_ReturnOnError(error); - + if (inAddTriFunc) { error = inAddTriFunc(inRefCon, textureName, i0, i1, i2, normal.x, normal.y, normal.z); UUmError_ReturnOnError(error); } } - + error = BFrTextFile_VerifyNextStr(inTextFile, "num quads"); UUmError_ReturnOnError(error); - + numQuads = BFrTextFile_GetUUtUns16(inTextFile); - + error = BFrTextFile_VerifyNextStr(inTextFile, "index, index, index, index, nx, ny, nz"); UUmError_ReturnOnError(error); @@ -2386,17 +2386,17 @@ AUrParse_EnvGeometry( textureName = BFrTextFile_GetNextStr(inTextFile); MUrMatrix_MultiplyNormal(&normal, inMatrix, &normal); - + error = BFrTextFile_VerifyNextStr(inTextFile, ""); UUmError_ReturnOnError(error); - + if (inAddQuadFunc) { error = inAddQuadFunc(inRefCon, textureName, i0, i1, i2, i3, normal.x, normal.y, normal.z); UUmError_ReturnOnError(error); } } - + return UUcError_None; } @@ -2406,22 +2406,22 @@ AUrQuad_SharesAnEdge( const M3tQuad* inQuadB) { UUtUns32 i, j; - + UUtUns32 indexA0, indexA1; UUtUns32 indexB0, indexB1; - + for(i = 0; i < 4; i++) { indexA0 = inQuadA->indices[i]; indexA1 = inQuadA->indices[(i + 1) % 4]; - + for(j = 0; j < 4; j++) { if(i == j) continue; - + indexB0 = inQuadB->indices[j]; indexB1 = inQuadB->indices[(j + 1) % 4]; - + if(((indexA0 == indexB0) && (indexA1 == indexB1)) || ((indexA0 == indexB1) && (indexA1 == indexB0))) { @@ -2429,7 +2429,7 @@ AUrQuad_SharesAnEdge( } } } - + return UUcFalse; } @@ -2439,35 +2439,35 @@ void AUrPlane_ClosestPoint( M3tPoint3D* outPoint) { /* - + Pcs = the point at the sphere center dist = distance from Pcs to the plane Pop = orthogonal projection of the center onto the plane J - + Jn = plane normal taken from a, b, c of plane equation Jd = d component of plane equation - + dist = Jn . Pcs + Jd - + Pop = Pcs - dist(Jn) - + */ - + float distance; - + UUmAssertReadPtr(inPlaneEqu, sizeof(M3tPlaneEquation)); UUmAssertReadPtr(inPoint, sizeof(M3tPoint3D)); UUmAssertWritePtr(outPoint, sizeof(M3tPoint3D)); distance = MUrSqrt(UUmSQR(inPlaneEqu->a) + UUmSQR(inPlaneEqu->b) + UUmSQR(inPlaneEqu->c)); UUmAssert((distance >= 0.95f) && (distance <= 1.05f)); - - distance = - (inPlaneEqu->a * inPoint->x) + - (inPlaneEqu->b * inPoint->y) + - (inPlaneEqu->c * inPoint->z) + + + distance = + (inPlaneEqu->a * inPoint->x) + + (inPlaneEqu->b * inPoint->y) + + (inPlaneEqu->c * inPoint->z) + (inPlaneEqu->d); - + outPoint->x = inPoint->x - (distance * inPlaneEqu->a); outPoint->y = inPoint->y - (distance * inPlaneEqu->b); outPoint->z = inPoint->z - (distance * inPlaneEqu->c); @@ -2480,14 +2480,14 @@ float AUrPlane_Distance_Squared( { M3tPoint3D pointOnPlane; float distance_squared; - + UUmAssertReadPtr(inPlaneEqu, sizeof(M3tPlaneEquation)); UUmAssertReadPtr(inPoint, sizeof(M3tPoint3D)); - + AUrPlane_ClosestPoint(inPlaneEqu, inPoint, &pointOnPlane); distance_squared = MUrPoint_Distance_Squared(inPoint, &pointOnPlane); - + if (NULL != outPoint) { *outPoint = pointOnPlane; } @@ -2502,14 +2502,14 @@ float AUrPlane_Distance( { M3tPoint3D pointOnPlane; float distance; - + UUmAssertReadPtr(inPlaneEqu, sizeof(M3tPlaneEquation)); UUmAssertReadPtr(inPoint, sizeof(M3tPoint3D)); - + AUrPlane_ClosestPoint(inPlaneEqu, inPoint, &pointOnPlane); distance = MUrPoint_Distance(inPoint, &pointOnPlane); - + if (NULL != outPoint) { *outPoint = pointOnPlane; } @@ -2530,11 +2530,11 @@ AUtMB_ButtonChoice UUcArglist_Call AUrMessageBox(AUtMB_ButtonType inButtonType, return_value= vsprintf(buffer, format, arglist); va_end(arglist); - switch(inButtonType) + switch(inButtonType) { case AUcMBType_AbortRetryIgnore: type = MB_ABORTRETRYIGNORE; break; case AUcMBType_OK: type = MB_OK; break; - case AUcMBType_OKCancel: type = MB_OKCANCEL; break; + case AUcMBType_OKCancel: type = MB_OKCANCEL; break; case AUcMBType_RetryCancel: type = MB_RETRYCANCEL; break; case AUcMBType_YesNo: type = MB_YESNO; break; case AUcMBType_YesNoCancel: type = MB_YESNOCANCEL; break; @@ -2549,7 +2549,7 @@ AUtMB_ButtonChoice UUcArglist_Call AUrMessageBox(AUtMB_ButtonType inButtonType, { case IDOK: choice = AUcMBChoice_OK; break; case IDCANCEL: choice = AUcMBChoice_Cancel; break; - case IDABORT: choice = AUcMBChoice_Abort; break; + case IDABORT: choice = AUcMBChoice_Abort; break; case IDRETRY: choice = AUcMBChoice_Retry; break; case IDIGNORE: choice = AUcMBChoice_Ignore; break; case IDYES: choice = AUcMBChoice_Yes; break; @@ -2568,20 +2568,20 @@ AUtMB_ButtonChoice UUcArglist_Call AUrMessageBox( va_list arglist; int return_value; AUtMB_ButtonChoice choice; - + extern void mac_hide_cursor(void); extern void mac_show_cursor(void); va_start(arglist, format); return_value= vsprintf(buffer, format, arglist); va_end(arglist); - + c2pstrcpy((StringPtr)buffer, buffer); // this can do in-place copies, so this is OK ParamText((unsigned char*)buffer, NULL, NULL, NULL); - + mac_show_cursor(); - switch(inButtonType) + switch(inButtonType) { case AUcMBType_AbortRetryIgnore: switch (Alert(MAC_ALERT_ABORT_RETRY_IGNORE_RES_ID, NULL)) @@ -2606,7 +2606,7 @@ AUtMB_ButtonChoice UUcArglist_Call AUrMessageBox( case _button_cancel2: choice= AUcMBChoice_Cancel; break; default: UUmAssert(0); } - break; + break; case AUcMBType_RetryCancel: switch (Alert(MAC_ALERT_RETRY_CANCEL, NULL)) { @@ -2629,17 +2629,17 @@ AUtMB_ButtonChoice UUcArglist_Call AUrMessageBox( case _button_yes: choice= AUcMBChoice_Yes; break; case _button_no: choice= AUcMBChoice_No; break; case _button_cancel3: choice= AUcMBChoice_Cancel; break; - default: UUmAssert(0); + default: UUmAssert(0); } break; default: UUmAssert(0); } - + mac_hide_cursor(); return choice; -} +} //TODO: SDL_MessageBox #else AUtMB_ButtonChoice AUrMessageBox(AUtMB_ButtonType inButtonType, const char *format, ...) @@ -2655,7 +2655,7 @@ AUtMB_ButtonChoice AUrMessageBox(AUtMB_ButtonType inButtonType, const char *form fprintf(stderr, "%s"UUmNL, buffer); UUrEnterDebugger("%s", buffer); - + return AUcMBChoice_Yes; // (Just to get rid of a warning) } #endif @@ -2664,7 +2664,7 @@ typedef struct { UUtUns32 pixel; double weight; - + } CONTRIB; typedef struct @@ -2688,7 +2688,7 @@ void AUrBuildArgumentList(char *inString, UUtUns32 inMaxCount, UUtUns32 *outCoun while (1) { while (UUrIsSpace(*stringPtr) || ('\0' == *stringPtr)) { - if ('\0' == *stringPtr) { + if ('\0' == *stringPtr) { return; } @@ -2699,7 +2699,7 @@ void AUrBuildArgumentList(char *inString, UUtUns32 inMaxCount, UUtUns32 *outCoun *outCount += 1; while (!UUrIsSpace(*stringPtr)) { - if ('\0' == *stringPtr) { + if ('\0' == *stringPtr) { return; } @@ -2726,9 +2726,9 @@ AUrFlags_GetTextName( { AUtFlagElement *curFlagElem; const char *textName; - + textName = NULL; - + for (curFlagElem = inFlagList; curFlagElem->textName != NULL; curFlagElem++) @@ -2739,7 +2739,7 @@ AUrFlags_GetTextName( break; } } - + return textName; } @@ -2755,10 +2755,10 @@ AUrFlags_ParseFromGroupArray( char* elemFlagString; AUtFlagElement* curFlagElem; UUtUns32 result = 0; - + UUmAssertReadPtr(inFlagList, sizeof(void*)); UUmAssertReadPtr(inElement, sizeof(void*)); - + if(inElementType == GRcElementType_String) { for(curFlagElem = inFlagList; @@ -2771,7 +2771,7 @@ AUrFlags_ParseFromGroupArray( break; } } - + if(curFlagElem->textName == NULL) { return AUcError_FlagNotFound; @@ -2788,7 +2788,7 @@ AUrFlags_ParseFromGroupArray( curGroupElemIndex, &groupType, &elemFlagString); - + for(curFlagElem = inFlagList; curFlagElem->textName != NULL; curFlagElem++) @@ -2799,7 +2799,7 @@ AUrFlags_ParseFromGroupArray( break; } } - + if(curFlagElem->textName == NULL) { return AUcError_FlagNotFound; @@ -2810,9 +2810,9 @@ AUrFlags_ParseFromGroupArray( { return UUcError_Generic; } - + *outResult = result; - + return UUcError_None; } @@ -2827,14 +2827,14 @@ AUrFlags_ParseFromString( char* curField; UUtUns32 result = 0; AUtFlagElement* curFlagElem; - + *outResult = 0; - + for(;;) { curField = UUrString_Tokenize1(NULL, " ", &parseState); if(curField == NULL) break; - + for(curFlagElem = inFlagList; curFlagElem->textName != NULL; curFlagElem++) @@ -2849,18 +2849,18 @@ AUrFlags_ParseFromString( { return AUcError_FlagNotFound; } - + curField = UUrString_Tokenize1(NULL, " ", &parseState); if(curField == NULL) break; - + if(strcmp(curField, "|")) { return UUcError_Generic; } } - + *outResult = result; - + return UUcError_None; } @@ -2872,13 +2872,13 @@ AUrFlags_PrintFromValue( UUtUns32 inValue) { UUtBool first = UUcTrue; - + if(inValue == 0) { fprintf(inFile, "none"); return; } - + if(inIsBitField) { while(inFlagList->textName != NULL) @@ -2892,7 +2892,7 @@ AUrFlags_PrintFromValue( fprintf(inFile, "%s", inFlagList->textName); first = UUcFalse; } - + inFlagList++; } } @@ -2921,7 +2921,7 @@ UUtWindow AUrWindow_New( Rect window_rect; const RGBColor black_color= {0,0,0}; short vert_offset= GetMBarHeight(); - + window_rect.top= inRect->top + vert_offset; window_rect.left= inRect->left; window_rect.bottom= inRect->bottom + vert_offset; @@ -2934,7 +2934,7 @@ UUtWindow AUrWindow_New( ShowWindow(new_window); SetPort(GetWindowPort(new_window)); } - + return (UUtWindow)new_window; } @@ -2945,7 +2945,7 @@ void AUrWindow_Delete( { DisposeWindow((WindowPtr)inWindow); } - + return; } @@ -3014,13 +3014,13 @@ UUtWindow AUrWindow_New( if (window) { BOOL success; - + ShowWindow(window, SW_SHOW); success= BringWindowToTop(window); UUmAssert(success); } } - + return ((UUtWindow)window); } @@ -3069,7 +3069,7 @@ void AUrWindow_EORImage( UUtWindow AUrWindow_New( UUtRect* inRect) -{ +{ return NULL; } @@ -3147,7 +3147,7 @@ UUtUns8 AUrBits16_Count(UUtUns16 inBits) UUtUns16 mask; UUtUns8 count = 0; - for(itr = 0; itr < 16; itr++) + for(itr = 0; itr < 16; itr++) { mask = 1 << itr; @@ -3165,7 +3165,7 @@ UUtUns8 AUrBits32_Count(UUtUns32 inBits) UUtUns32 mask; UUtUns8 count = 0; - for(itr = 0; itr < 32; itr++) + for(itr = 0; itr < 32; itr++) { mask = 1 << itr; @@ -3183,7 +3183,7 @@ UUtUns8 AUrBits64_Count(UUtUns64 inBits) UUtUns64 mask; UUtUns8 count = 0; - for(itr = 0; itr < 64; itr++) + for(itr = 0; itr < 64; itr++) { mask = 1 << itr; @@ -3314,7 +3314,7 @@ void AUrQuad_LowestPoints( } } - + if (outPointLowest != NULL) { UUmAssert(lowest != NULL); *outPointLowest = lowest; @@ -3361,7 +3361,7 @@ void AUrQuad_HighestPoints( } } - + if (outPointHighest != NULL) { UUmAssert(highest != NULL); *outPointHighest = highest; @@ -3530,7 +3530,7 @@ __declspec( naked ) UUtBool __fastcall AUrDict_TestAndAdd(AUtDict *inDict, UUtUn cmp ecx, eax jge Dict_not_enough_pages // if ecx (numpages) >= eax (maxpages) goto Dict_not_enough_pages - + mov [esi]inDict.pages[ecx*4], edx // inc [esi]inDict.numPages inc ecx @@ -3553,7 +3553,7 @@ UUtBool __fastcall AUrDict_TestAndAdd(AUtDict *inDict, UUtUns32 key) UUtBool inDictionary; UUmAssertWritePtr(inDict, sizeof(*inDict)); - + inDictionary = UUrBitVector_TestAndSetBit(inDict->vector, key); if (!inDictionary) @@ -3577,8 +3577,8 @@ UUtBool AUrDict_TestAndAdd(AUtDict *inDict, UUtUns32 key) UUtBool inDictionary; UUmAssertWritePtr(inDict, sizeof(*inDict)); - - + + inDictionary = UUrBitVector_TestAndSetBit(inDict->vector, key); if (!inDictionary) @@ -3988,7 +3988,7 @@ void AUrQSort_32 ( else return; /* all subarrays done */ } - + static void shortsort_32 ( char *lo, char *hi, @@ -4062,14 +4062,14 @@ UUtError AUrParseNumericalRangeString( char numBuffer[10]; UUtUns32 num, numStart = 0xFFFF; UUtBool inRange = 0; - + numBufferIndex = 0; UUmAssert(ioBitVector); while(1) { c = *inArg++; - + if(isdigit(c)) { numBuffer[numBufferIndex++] = c; @@ -4089,7 +4089,7 @@ UUtError AUrParseNumericalRangeString( { UUrBitVector_SetBit(ioBitVector, num); } - + if(c == 0) return UUcError_None; numBufferIndex = 0; inRange = UUcFalse; @@ -4109,7 +4109,7 @@ UUtError AUrParseNumericalRangeString( goto error; } } - + return UUcError_None; error: diff --git a/BungieFrameWork/BFW_Source/BFW_BinaryData/BFW_BinaryData.c b/BungieFrameWork/BFW_Source/BFW_BinaryData/BFW_BinaryData.c index 4593961..4bb230d 100644 --- a/BungieFrameWork/BFW_Source/BFW_BinaryData/BFW_BinaryData.c +++ b/BungieFrameWork/BFW_Source/BFW_BinaryData/BFW_BinaryData.c @@ -17,7 +17,7 @@ typedef struct BDtClass { BDtClassType class_type; BDtMethods methods; - + } BDtClass; // ====================================================================== @@ -44,7 +44,7 @@ BDiBinaryData_ProcHandler( void *binary_storage; binary_data = (BDtBinaryData*)inInstancePtr; - + switch (inMessage) { case TMcTemplateProcMessage_LoadPostProcess: @@ -77,7 +77,7 @@ BDiBinaryData_ProcHandler( } break; } - + return UUcError_None; } @@ -91,7 +91,7 @@ BDrBinaryData_Write( { UUtError error; BDtHeader header; - + // fill in the header header.class_type = inClassType; header.data_size = inDataSize; @@ -100,19 +100,19 @@ BDrBinaryData_Write( UUrSwap_4Byte(&header.class_type); UUrSwap_4Byte(&header.data_size); #endif - + // start at the beginning of the file error = BFrFile_SetPos(inFile, 0); UUmError_ReturnOnError(error); - + // write the header - error = + error = BFrFile_Write( inFile, sizeof(BDtHeader), &header); UUmError_ReturnOnError(error); - + // write the data error = BFrFile_Write( @@ -120,7 +120,7 @@ BDrBinaryData_Write( inDataSize, inData); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -144,27 +144,27 @@ BDrBinaryLoader( UUtUns32 num_classes; BDtClass *class_list; UUtUns32 i; - + // get a pointer to the data data = (BDtData*)inBuffer; - + #if (UUmEndian == UUmEndian_Big) swap_it = UUcTrue; - + UUrSwap_4Byte(&data->header.class_type); UUrSwap_4Byte(&data->header.data_size); #else swap_it = UUcFalse; #endif - + // do a quick check UUmAssert(inBufferSize == (data->header.data_size + sizeof(BDtHeader))); - + // find the appropriate class handler num_classes = UUrMemory_Array_GetUsedElems(BDgClassArray); class_list = (BDtClass*)UUrMemory_Array_GetMemory(BDgClassArray); if (class_list == NULL) { return UUcError_Generic; } - + for (i = 0; i < num_classes; i++) { if (class_list[i].class_type == data->header.class_type) @@ -177,14 +177,14 @@ BDrBinaryLoader( inLocked, inAllocated); UUmError_ReturnOnError(error); - + break; } } // CB: if we didn't recognise this class type, fire off an assertion UUmAssert(i < num_classes); - + return UUcError_None; } @@ -198,16 +198,16 @@ BDrRegisterClass( BDtClass *class_list; UUtUns32 index; UUtBool mem_moved; - + UUmAssert(BDgClassArray); UUmAssert(inMethods); - + class_list = (BDtClass*)UUrMemory_Array_GetMemory(BDgClassArray); if (class_list) { UUtUns32 num_classes; UUtUns32 i; - + // determine if another class of this type has already been registered num_classes = UUrMemory_Array_GetUsedElems(BDgClassArray); for (i = 0; i < num_classes; i++) @@ -218,19 +218,19 @@ BDrRegisterClass( } } } - + // get a space for the class error = UUrMemory_Array_GetNewElement(BDgClassArray, &index, &mem_moved); UUmError_ReturnOnError(error); - + // get a pointer to the class list, this is necessary because // class_list may have been NULL the first time through class_list = (BDtClass*)UUrMemory_Array_GetMemory(BDgClassArray); - + // add the class class_list[index].class_type = inClassType; class_list[index].methods = *inMethods; - + return UUcError_None; } @@ -245,11 +245,11 @@ BDrInitialize( void) { UUtError error; - + // register the templates error = BDrRegisterTemplates(); UUmError_ReturnOnError(error); - + // install the proc handler error = TMrTemplate_PrivateData_New( @@ -258,7 +258,7 @@ BDrInitialize( BDiBinaryData_ProcHandler, &BDgBinaryData_PrivateData); UUmError_ReturnOnError(error); - + // initialize the memory array BDgClassArray = UUrMemory_Array_New( @@ -267,7 +267,7 @@ BDrInitialize( 0, 0); UUmError_ReturnOnNull(BDgClassArray); - + return UUcError_None; } @@ -277,4 +277,4 @@ BDrTerminate( void) { UUrMemory_Array_Delete(BDgClassArray); -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_BinaryData/BFW_BinaryData_Template.c b/BungieFrameWork/BFW_Source/BFW_BinaryData/BFW_BinaryData_Template.c index 26e5396..2b0f80c 100644 --- a/BungieFrameWork/BFW_Source/BFW_BinaryData/BFW_BinaryData_Template.c +++ b/BungieFrameWork/BFW_Source/BFW_BinaryData/BFW_BinaryData_Template.c @@ -18,9 +18,9 @@ BDrRegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register(BDcTemplate_BinaryData, sizeof(BDtBinaryData), TMcFolding_Allow); UUmError_ReturnOnError(error); return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Bink/BFW_Bink.c b/BungieFrameWork/BFW_Source/BFW_Bink/BFW_Bink.c index e897352..fbd714e 100644 --- a/BungieFrameWork/BFW_Source/BFW_Bink/BFW_Bink.c +++ b/BungieFrameWork/BFW_Source/BFW_Bink/BFW_Bink.c @@ -1076,7 +1076,7 @@ static void BKrRestoreBitDepth( } } } - + #elif defined(UUmPlatform) && (UUmPlatform == UUmPlatform_Mac) #endif diff --git a/BungieFrameWork/BFW_Source/BFW_Bink/BinkHeaders/Rad.h b/BungieFrameWork/BFW_Source/BFW_Bink/BinkHeaders/Rad.h index 42fd029..fa2017a 100644 --- a/BungieFrameWork/BFW_Source/BFW_Bink/BinkHeaders/Rad.h +++ b/BungieFrameWork/BFW_Source/BFW_Bink/BinkHeaders/Rad.h @@ -34,14 +34,14 @@ #define __RADPPC__ #define __RADBIGENDIAN__ #endif - + #if defined(__GNUC__) #define __RADALLOWINLINES__ #define RADINLINE inline #endif #endif - + #if (defined(__MWERKS__) && !defined(__INTEL__)) || defined(__MRC__) || defined(THINK_C) || defined(powerc) || defined(macintosh) || defined(__powerc) #define __RADMAC__ @@ -270,7 +270,7 @@ RADDEFSTART #ifdef __RADMACOSX__ #endif - + #ifdef __RADMAC__ #include @@ -278,7 +278,7 @@ RADDEFSTART #include #include #ifdef __MRC__ - #include "intrinsics.h" + #include "intrinsics.h" #endif void radconv32a(void* p, u32 n); @@ -431,19 +431,19 @@ RADDEFSTART u32 DOSOut(const char* str); #pragma aux DOSOut = "cld" "mov ecx,0xffffffff" "xor eax,eax" "mov edx,edi" "repne scasb" "not ecx" "dec ecx" "mov ebx,1" "mov ah,0x40" "int 0x21" parm [EDI] modify [EAX EBX ECX EDX EDI] value [ecx]; - + void DOSOutNum(const char* str,u32 len); #pragma aux DOSOutNum = "mov ah,0x40" "mov ebx,1" "int 0x21" parm [edx] [ecx] modify [eax ebx]; u32 ErrOut(const char* str); #pragma aux ErrOut = "cld" "mov ecx,0xffffffff" "xor eax,eax" "mov edx,edi" "repne scasb" "not ecx" "dec ecx" "xor ebx,ebx" "mov ah,0x40" "int 0x21" parm [EDI] modify [EAX EBX ECX EDX EDI] value [ecx]; - + void ErrOutNum(const char* str,u32 len); #pragma aux ErrOutNum = "mov ah,0x40" "xor ebx,ebx" "int 0x21" parm [edx] [ecx] modify [eax ebx]; void radmemset16(void* dest,u16 value,u32 size); #pragma aux radmemset16 = "cld" "mov bx,ax" "shl eax,16" "mov ax,bx" "mov bl,cl" "shr ecx,1" "rep stosd" "mov cl,bl" "and cl,1" "rep stosw" parm [EDI] [EAX] [ECX] modify [EAX EDX EBX ECX EDI]; - + void radmemset(void* dest,u8 value,u32 size); #pragma aux radmemset = "cld" "mov ah,al" "mov bx,ax" "shl eax,16" "mov ax,bx" "mov bl,cl" "shr ecx,2" "and bl,3" "rep stosd" "mov cl,bl" "rep stosb" parm [EDI] [AL] [ECX] modify [EAX EDX EBX ECX EDI]; @@ -473,7 +473,7 @@ RADDEFSTART u32 radstrlen(const void* dest); #pragma aux radstrlen = "cld" "mov ecx,0xffffffff" "xor eax,eax" "repne scasb" "not ecx" "dec ecx" parm [EDI] modify [EAX ECX EDI] value [ECX]; - + char* radstrcat(void* dest,const void* source); #pragma aux radstrcat = "cld" "mov ecx,0xffffffff" "mov edx,edi" "xor eax,eax" "repne scasb" "dec edi" "lp:" "lodsb" "stosb" "test al,0xff" "jnz lp" \ parm [EDI] [ESI] modify [EAX ECX EDI ESI] value [EDX]; @@ -508,12 +508,12 @@ RADDEFSTART #pragma aux radstru32 = "cld" "xor ecx,ecx" "xor ebx,ebx" "xor edi,edi" "lodsb" "cmp al,45" "jne skip2" "mov edi,1" "jmp skip" "lp:" "mov eax,10" "mul ecx" "lea ecx,[eax+ebx]" \ "skip:" "lodsb" "skip2:" "cmp al,0x39" "ja dne" "cmp al,0x30" "jb dne" "mov bl,al" "sub bl,0x30" "jmp lp" "dne:" "test edi,1" "jz pos" "neg ecx" "pos:" \ parm [ESI] modify [EAX EBX EDX EDI ESI] value [ecx]; - + u16 GetDS(); #pragma aux GetDS = "mov ax,ds" value [ax]; #ifdef __RADWINEXT__ - + #define _16To32(ptr16) ((void*)(((GetSelectorBase((u16)(((u32)(ptr16))>>16))+((u16)(u32)(ptr16)))-GetSelectorBase(GetDS())))) #endif @@ -522,10 +522,10 @@ RADDEFSTART #define int86 int386 #define int86x int386x #endif - + #define u32regs x #define u16regs w - + #else #define radstrcpy strcpy @@ -580,37 +580,37 @@ RADDEFSTART u8 __inline radinp(u16 p) { __asm { - mov dx,[p] - in al,dx - } + mov dx,[p] + in al,dx + } } void __inline radoutp(u16 p,u8 v) { __asm { - mov dx,[p] + mov dx,[p] mov al,[v] - out dx,al + out dx,al } } - RADPCHAR __inline radstpcpy(char* p1, char* p2) { + RADPCHAR __inline radstpcpy(char* p1, char* p2) { __asm { - mov edx,[p1] + mov edx,[p1] mov ecx,[p2] cld lp: - mov al,[ecx] - inc ecx - mov [edx],al + mov al,[ecx] + inc ecx + mov [edx],al inc edx - cmp al,0 - jne lp - dec edx + cmp al,0 + jne lp + dec edx mov eax,edx - } + } } - - RADPCHAR __inline radstpcpyrs(char* p1, char* p2) { + + RADPCHAR __inline radstpcpyrs(char* p1, char* p2) { __asm { mov edx,[p1] mov ecx,[p2] @@ -620,26 +620,26 @@ RADDEFSTART inc ecx mov [edx],al inc edx - cmp al,0 + cmp al,0 jne lp dec ecx - mov eax,ecx - } + mov eax,ecx + } } void __inline radmemset16(void* dest,u16 value,u32 sizeb) { __asm { mov edi,[dest] - mov ax,[value] + mov ax,[value] mov ecx,[sizeb] - shl eax,16 - cld - mov ax,[value] - mov bl,cl - shr ecx,1 + shl eax,16 + cld + mov ax,[value] + mov bl,cl + shr ecx,1 rep stosd - mov cl,bl - and cl,1 + mov cl,bl + and cl,1 rep stosw } } @@ -695,7 +695,7 @@ RADDEFSTART rdtscavail=(u32)-1; } return rdtscavail; - } + } #endif void __inline RADCycleTimerStartAddr(u32* addr) @@ -807,11 +807,11 @@ RADDEFSTART s32 radabs32(s32 ab); #pragma aux radabs32 = "test dx,dx" "jge skip" "neg dx" "neg ax" "sbb dx,0" "skip:" parm [dx ax] value [dx ax]; - + u32 DOSOut(const char far* dest); #pragma aux DOSOut = "cld" "and edi,0xffff" "mov dx,di" "mov ecx,0xffffffff" "xor eax,eax" 0x67 "repne scasb" "not ecx" "dec ecx" "mov bx,1" "push ds" "push es" "pop ds" "mov ah,0x40" "int 0x21" "pop ds" "movzx eax,cx" "shr ecx,16" \ parm [ES DI] modify [AX BX CX DX DI ES] value [CX AX]; - + void DOSOutNum(const char far* str,u16 len); #pragma aux DOSOutNum = "push ds" "mov ds,cx" "mov cx,bx" "mov ah,0x40" "mov bx,1" "int 0x21" "pop ds" parm [cx dx] [bx] modify [ax bx cx]; @@ -842,11 +842,11 @@ RADDEFSTART u32 radstrlen(const void far* dest); #pragma aux radstrlen = "cld" "and edi,0xffff" "mov ecx,0xffffffff" "xor eax,eax" 0x67 "repne scasb" "not ecx" "dec ecx" "movzx eax,cx" "shr ecx,16" parm [ES DI] modify [AX CX DI ES] value [CX AX]; - + char far* radstrcat(void far* dest,const void far* source); #pragma aux radstrcat = "cld" "and edi,0xffff" "mov ecx,0xffffffff" "and esi,0xffff" "push ds" "mov ds,dx" "mov dx,di" "xor eax,eax" 0x67 "repne scasb" "dec edi" "lp:" "lodsb" "stosb" "test al,0xff" "jnz lp" "pop ds" \ parm [ES DI] [DX SI] modify [AX CX DI SI ES] value [es dx]; - + char far* radstrchr(const void far* dest,char chr); #pragma aux radstrchr = "cld" "lp:" 0x26 "lodsb" "cmp al,dl" "je fnd" "cmp al,0" "jnz lp" "xor ax,ax" "mov es,ax" "mov si,1" "fnd:" "dec si" parm [ES SI] [DL] modify [AX SI ES] value [es si]; diff --git a/BungieFrameWork/BFW_Source/BFW_Collision/BFW_Collision.c b/BungieFrameWork/BFW_Source/BFW_Collision/BFW_Collision.c index 965df60..dd6572e 100644 --- a/BungieFrameWork/BFW_Source/BFW_Collision/BFW_Collision.c +++ b/BungieFrameWork/BFW_Source/BFW_Collision/BFW_Collision.c @@ -1,12 +1,12 @@ /* FILE: BFW_Collision.c - + AUTHOR: Brent H. Pease - + CREATED: May 10, 1998 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1998 */ @@ -57,12 +57,12 @@ void CLrPlaneEquationFromQuad( UUmAssert(normal.y >= -1.0f && normal.y <= 1.0f); UUmAssert(normal.z >= -1.0f && normal.z <= 1.0f); UUmAssert(!AKmNoIntersection(normal)); - + outPlaneEquation->a = normal.x; outPlaneEquation->b = normal.y; outPlaneEquation->c = normal.z; - outPlaneEquation->d = -( outPlaneEquation->a * inPointArray[inQuad->indices[0]].x + - outPlaneEquation->b * inPointArray[inQuad->indices[0]].y + + outPlaneEquation->d = -( outPlaneEquation->a * inPointArray[inQuad->indices[0]].x + + outPlaneEquation->b * inPointArray[inQuad->indices[0]].y + outPlaneEquation->c * inPointArray[inQuad->indices[0]].z); return; @@ -83,9 +83,9 @@ UUtBool CLrSphere_Ray( { float disc, a, b, c, t; M3tVector3D relative_pos; - + UUmAssert(inSphere); - + MUmVector_Subtract(relative_pos, *inRayStart, inSphere->center); a = MUmVector_GetLengthSquared(*inRayDir); b = 2*MUrVector_DotProduct(&relative_pos, inRayDir); @@ -94,7 +94,7 @@ UUtBool CLrSphere_Ray( disc = UUmSQR(b) - 4*a*c; if (disc < 0) return UUcFalse; - + if (c < 0) { // we are inside the sphere, use the greater of the two t-values t = (-b + MUrSqrt(disc)) / (2*a); @@ -127,7 +127,7 @@ CLrSphere_Line( float u; // ****** TRIVIAL REJECT ? ****** - + // step 1: test start distanceSquared = 0; distanceSquared += UUmSQR(inStart->x - inSphere->center.x); @@ -153,7 +153,7 @@ CLrSphere_Line( if ((u > 0) && (u < 1.f)) { M3tPoint3D closestPoint; - + MUrLineSegment_ComputePoint(inStart, inEnd, u, &closestPoint); distanceSquared = 0; @@ -167,7 +167,7 @@ CLrSphere_Line( } return UUcFalse; -} +} UUtBool CLrHotdog_Sphere( M3tBoundingHotdog *inDog, @@ -211,11 +211,11 @@ static UUtBool CLrPoint_In_Cylinder( if ((inPoint->y >= inCylinder->bottom) && (inPoint->y <= inCylinder->top)) { - float distance_squared = - UUmSQR(inPoint->x - inCylinder->circle.center.x) + + float distance_squared = + UUmSQR(inPoint->x - inCylinder->circle.center.x) + UUmSQR(inPoint->z - inCylinder->circle.center.z); - if (distance_squared < UUmSQR(inCylinder->circle.radius)) + if (distance_squared < UUmSQR(inCylinder->circle.radius)) { inside = UUcTrue; } @@ -225,25 +225,25 @@ static UUtBool CLrPoint_In_Cylinder( } static void iCircle_LineSegment_Intersections( - const M3tPoint3D *inP1, - const M3tPoint3D *inP2, - const M3tBoundingCircle *circle, - UUtUns8 *outCount, + const M3tPoint3D *inP1, + const M3tPoint3D *inP2, + const M3tBoundingCircle *circle, + UUtUns8 *outCount, M3tPoint3D *outIntersections) { - // Given a ray defined as: + // Given a ray defined as: // x = x1 + (x2 - x1)*t = x1 + i*t // z = z1 + (z2 - z1)*t = z1 + k*t // - //and a sphere defined as: + //and a sphere defined as: // //(x - l)**2 + (z - n)**2 = r**2 // - //Substituting in gives the quadratic equation: + //Substituting in gives the quadratic equation: // //a*t**2 + b*t + c = 0 // - //where: + //where: // //a = i**2 + j**2 + k**2 //b = 2*i*(x1 - l) + 2*k*(z1 - n) @@ -295,14 +295,14 @@ static void iCircle_LineSegment_Intersections( else { line_min_z = inP2->z; line_max_z = inP1->z; - } + } if (line_min_x > (circle->center.x + r)) { goto exit; } if (line_max_x < (circle->center.x - r)) { - goto exit; + goto exit; } if (line_min_z > (circle->center.z + r)) { @@ -314,7 +314,7 @@ static void iCircle_LineSegment_Intersections( } } - + // quadratic equation values a = UUmSQR(i) + UUmSQR(k); b = 2 * i * (x1 - l) + 2 * k * (z1 - n); @@ -387,13 +387,13 @@ UUtBool CLrQuad_Cylinder( switch(intersection_count) { case 2: - if ((intersections[1].y >= inCylinder->bottom) && + if ((intersections[1].y >= inCylinder->bottom) && (intersections[1].y <= inCylinder->top)) { goto exit; } case 1: - if ((intersections[0].y >= inCylinder->bottom) && + if ((intersections[0].y >= inCylinder->bottom) && (intersections[0].y <= inCylinder->top)) { goto exit; @@ -432,7 +432,7 @@ CLrQuad_Quad( // If you do not request the line of intersection, edges are returned as face collisions. In an edge // case, the line of intersection returned is the edge on B that collided. This may not be what you // expect, but deal with it. It's what's most useful for physics. - + M3tPlaneEquation planeA,planeB; UUtUns32 left,right; UUtUns32 foundL=0xFFFFFFFF; @@ -443,10 +443,10 @@ CLrQuad_Quad( const M3tPoint3D *edgeBL; const M3tPoint3D *edgeBR; UUtBool wantLine,foundLeft,foundRight; - + wantLine = outIntersectionL ? UUcTrue : UUcFalse; foundLeft = foundRight = UUcFalse; - + // Start by finding the planes of the two quads if we don't know them if (!inPlaneArrayA) { @@ -456,7 +456,7 @@ CLrQuad_Quad( { AKmPlaneEqu_GetComponents(inPlaneEquIndexA,(M3tPlaneEquation *)inPlaneArrayA,planeA.a,planeA.b,planeA.c,planeA.d); } - + if (!inPlaneArrayB) { CLrPlaneEquationFromQuad(inQuadB, inPointArrayB, &planeB); @@ -465,7 +465,7 @@ CLrQuad_Quad( { AKmPlaneEqu_GetComponents(inPlaneEquIndexB,(M3tPlaneEquation *)inPlaneArrayB,planeB.a,planeB.b,planeB.c,planeB.d); } - + // Next, check all the edges of A against quad B left = 0; right = 1; @@ -506,7 +506,7 @@ CLrQuad_Quad( left = right; right = (right+1) % 4; } while (right != 1); - + // If we haven't found enough intersections yet, then check edges of B against A if ((wantLine && (!foundLeft || !foundRight)) || (!wantLine && !foundLeft)) @@ -522,7 +522,7 @@ CLrQuad_Quad( if (CLrQuad_Line(inProjectionA,inPointArrayA,&planeA,0,inQuadA,L,R,&inter)) { if (wantLine) - { + { if (!AKmNoIntersection(inter)) { if (!foundLeft) @@ -553,7 +553,7 @@ CLrQuad_Quad( right = (right+1) % 4; } while (right != 1); } - + // Return results if (foundLeft || foundRight) { @@ -568,7 +568,7 @@ CLrQuad_Quad( return CLcCollision_None; } } - + // Calculate point of initial contact /*switch(outEdgeCaseList[v]) { @@ -578,13 +578,13 @@ CLrQuad_Quad( MUmVector_Add(AKgCollisionList[passes].collisionPoint,outPoints[v][0],outPoints[v][1]); MUmVector_Scale(AKgCollisionList[passes].collisionPoint,0.5f); break; - + case CLcCollision_Edge: // Collision is point of contact of integral quad on destination edge AKgCollisionList[passes].collisionPoint = outPoints[v][1]; break; }*/ - + if (outPlaneA) *outPlaneA = planeA; if (outPlaneB) *outPlaneB = planeB; if (foundL == foundR) @@ -614,7 +614,7 @@ CLrQuad_Quad( return CLcCollision_Edge; } } - + return CLcCollision_None; } @@ -642,7 +642,7 @@ CLrQuad_Line( #if PERFORMANCE_TIMER UUrPerformanceTimer_Enter(CLgQuad_Line_Timer); #endif - + // Find the plane of the quad if (!inPlaneArray) { CLrPlaneEquationFromQuad(inQuad, inPointArray, &plane); @@ -650,16 +650,16 @@ CLrQuad_Line( else { AKmPlaneEqu_GetComponents(inPlaneEquIndex,(M3tPlaneEquation *)inPlaneArray,plane.a,plane.b,plane.c,plane.d); } - + // Now check for collision Xi = inStartPoint->x; Yi = inStartPoint->y; Zi = inStartPoint->z; - + Xf = inEndPoint->x; Yf = inEndPoint->y; Zf = inEndPoint->z; - + // if both points are on the plane then the line is on the plane if (UUmFloat_CompareEqu(plane.a * Xi + plane.b * Yi + plane.c * Zi + plane.d, 0.0f) && UUmFloat_CompareEqu(plane.a * Xf + plane.b * Yf + plane.c * Zf + plane.d, 0.0f)) @@ -668,14 +668,14 @@ CLrQuad_Line( float Vi0, Vi1, Vi2, Vi3; float Um0, Um1, Um2, Um3; float Vm0, Vm1, Vm2, Vm3; - + float Uit, Vit; float Umt, Vmt; - + float tt, tn; - + const M3tPoint3D* curPoint; - + // XXX - This code could be speed up a bit if (inProjection == CLcProjection_Unknown) { @@ -685,30 +685,30 @@ CLrQuad_Line( goto no_intersection; } } - + if (CLrQuad_PointInQuad(inProjection, inPointArray, inQuad, inEndPoint)) { intersection = *inEndPoint; goto has_intersection; } - + // now we need to see if the line intersects with the edges of the quad if (CLcProjection_XY == inProjection) { curPoint = inPointArray + inQuad->indices[0]; Ui0 = curPoint->x; Vi0 = curPoint->y; - + curPoint = inPointArray + inQuad->indices[1]; Ui1 = curPoint->x; Vi1 = curPoint->y; Um0 = (Ui1 - Ui0); Vm0 = (Vi1 - Vi0); - + curPoint = inPointArray + inQuad->indices[2]; Ui2 = curPoint->x; Vi2 = curPoint->y; Um1 = (Ui2 - Ui1); Vm1 = (Vi2 - Vi1); - + curPoint = inPointArray + inQuad->indices[3]; Ui3 = curPoint->x; Vi3 = curPoint->y; @@ -717,10 +717,10 @@ CLrQuad_Line( Um3 = (Ui0 - Ui3); Vm3 = (Vi0 - Vi3); - + Uit = Xi; Vit = Yi; - + Umt = (Xf - Xi); Vmt = (Yf - Yi); } @@ -728,19 +728,19 @@ CLrQuad_Line( curPoint = inPointArray + inQuad->indices[0]; Ui0 = curPoint->x; Vi0 = curPoint->z; - + curPoint = inPointArray + inQuad->indices[1]; Ui1 = curPoint->x; Vi1 = curPoint->z; Um0 = (Ui1 - Ui0); Vm0 = (Vi1 - Vi0); - + curPoint = inPointArray + inQuad->indices[2]; Ui2 = curPoint->x; Vi2 = curPoint->z; Um1 = (Ui2 - Ui1); Vm1 = (Vi2 - Vi1); - + curPoint = inPointArray + inQuad->indices[3]; Ui3 = curPoint->x; Vi3 = curPoint->z; @@ -749,10 +749,10 @@ CLrQuad_Line( Um3 = (Ui0 - Ui3); Vm3 = (Vi0 - Vi3); - + Uit = Xi; Vit = Zi; - + Umt = (Xf - Xi); Vmt = (Zf - Zi); } @@ -760,19 +760,19 @@ CLrQuad_Line( curPoint = inPointArray + inQuad->indices[0]; Ui0 = curPoint->y; Vi0 = curPoint->z; - + curPoint = inPointArray + inQuad->indices[1]; Ui1 = curPoint->y; Vi1 = curPoint->z; Um0 = (Ui1 - Ui0); Vm0 = (Vi1 - Vi0); - + curPoint = inPointArray + inQuad->indices[2]; Ui2 = curPoint->y; Vi2 = curPoint->z; Um1 = (Ui2 - Ui1); Vm1 = (Vi2 - Vi1); - + curPoint = inPointArray + inQuad->indices[3]; Ui3 = curPoint->y; Vi3 = curPoint->z; @@ -781,48 +781,48 @@ CLrQuad_Line( Um3 = (Ui0 - Ui3); Vm3 = (Vi0 - Vi3); - + Uit = Yi; Vit = Zi; - + Umt = (Yf - Yi); Vmt = (Zf - Zi); } - + /* Uin + tn * Umn = Uit + tt * Umt Vin + tn * Vmn = Vit + tt * Vmt - + tn = (Uit + tt * Umt - Uin) / Umn tn = (Vit + tt * Vmt - Vin) / Vmn - + (Uit + tt * Umt - Uin) / Umn = (Vit + tt * Vmt - Vin) / Vmn - + (Uit + tt * Umt - Uin) * Vmn = (Vit + tt * Vmt - Vin) * Umn - + Uit * Vmn + tt * Umt * Vmn - Uin * Vmn = Vit * Umn + tt * Vmt * Umn - Vin * Umn - + tt * Umt * Vmn - tt * Vmt * Umn = Vit * Umn - Vin * Umn - Uit * Vmn + Uin * Vmn - + tt * (Umt * Vmn - Vmt * Umn) = Vit * Umn - Vin * Umn - Uit * Vmn + Uin * Vmn - + tt = (Vit * Umn - Vin * Umn - Uit * Vmn + Uin * Vmn) / (Umt * Vmn - Vmt * Umn) */ - + tt = (Vit * Um0 - Vi0 * Um0 - Uit * Vm0 + Ui0 * Vm0) / (Umt * Vm0 - Vmt * Um0); - if (tt >= 0.0f && tt <= 1.0) { + if (tt >= 0.0f && tt <= 1.0) { if (UUmFloat_CompareEqu(Um0, 0.0f)) { tn = (Vit + tt * Vmt - Vi0) / Vm0; } else { tn = (Uit + tt * Umt - Ui0) / Um0; } - + if (tn >= 0.0f && tn <= 1.0f) { goto calc_plane_intersection; } } - + tt = (Vit * Um1 - Vi1 * Um1 - Uit * Vm1 + Ui1 * Vm1) / (Umt * Vm1 - Vmt * Um1); if (tt >= 0.0f && tt <= 1.0) { if (UUmFloat_CompareEqu(Um1, 0.0f)) { @@ -831,12 +831,12 @@ CLrQuad_Line( else { tn = (Uit + tt * Umt - Ui1) / Um1; } - + if (tn >= 0.0f && tn <= 1.0f) { goto calc_plane_intersection; } } - + tt = (Vit * Um2 - Vi2 * Um2 - Uit * Vm2 + Ui2 * Vm2) / (Umt * Vm2 - Vmt * Um2); if (tt >= 0.0f && tt <= 1.0) { if (UUmFloat_CompareEqu(Um2, 0.0f)) { @@ -845,12 +845,12 @@ CLrQuad_Line( else { tn = (Uit + tt * Umt - Ui2) / Um2; } - + if (tn >= 0.0f && tn <= 1.0f) { goto calc_plane_intersection; } } - + tt = (Vit * Um3 - Vi3 * Um3 - Uit * Vm3 + Ui3 * Vm3) / (Umt * Vm3 - Vmt * Um3); if (tt >= 0.0f && tt <= 1.0) { if (UUmFloat_CompareEqu(Um3, 0.0f)) { @@ -859,12 +859,12 @@ CLrQuad_Line( else { tn = (Uit + tt * Umt - Ui3) / Um3; } - + if (tn >= 0.0f && tn <= 1.0f) { goto calc_plane_intersection; } } - + goto no_intersection; calc_plane_intersection: @@ -882,36 +882,36 @@ CLrQuad_Line( Xm = (Xf - Xi); Ym = (Yf - Yi); Zm = (Zf - Zi); - + denom = plane.a * Xm + plane.b * Ym + plane.c * Zm; - + if (UUmFloat_CompareEqu(denom,0.0f)) { goto no_intersection; } - + num1 = -(plane.a * Xi + plane.b * Yi + plane.c * Zi + plane.d); - + if (UUmFloat_CompareGT((float)fabs(num1),(float)fabs(denom)) || ((UUmFloat_CompareLT(denom,0.0f)) && (UUmFloat_CompareGT(num1,0.0f))) || ((UUmFloat_CompareGT(denom,0.0f)) && (UUmFloat_CompareLT(num1,0.0f)))) { goto no_intersection; } - + t = num1 / denom; - + //UUmAssert(UUmFloat_CompareGESloppy(t,0.0f) && UUmFloat_CompareLESloppy(t,1.0f)); - + intersection.x = Xm * t + Xi; intersection.y = Ym * t + Yi; intersection.z = Zm * t + Zi; - + if (CLrQuad_PointInQuad(inProjection, inPointArray, inQuad, &intersection)) { UUmAssert(intersection.x > -10000.0f && intersection.x < 10000.0f); goto has_intersection; } } - + no_intersection: intersected = UUcFalse; @@ -936,29 +936,29 @@ CLrLine_Plane( { float Xm,Ym,Zm,denom,t; M3tPoint3D newPoint; - + Xm = (inLineB->x - inLineA->x); Ym = (inLineB->y - inLineA->y); Zm = (inLineB->z - inLineA->z); - + denom = inPlane->a * Xm +inPlane-> b * Ym + inPlane->c * Zm; - + if (denom == 0.0f) { return UUcFalse; } - + t = -(inPlane->a * inLineA->x + inPlane->b * inLineA->y + inPlane->c * inLineA->z + inPlane->d) / denom; if (t < 0.0f || t > 1.0f) { return UUcFalse; } - + newPoint.x = Xm * t + inLineA->x; newPoint.y = Ym * t + inLineA->y; newPoint.z = Zm * t + inLineA->z; - + if (outIntersection) *outIntersection = newPoint; return UUcTrue; } @@ -1041,22 +1041,22 @@ CLrQuad_Sphere( M3tPoint3D *outCollisionPoint) // optional { /* - XXX - This algorithm is not quite right. We need to test the min distance to + XXX - This algorithm is not quite right. We need to test the min distance to each edge of the quad also - + Pcs = the point at the sphere center dist = distance from Pcs to the plane Pop = orthogonal projection of the center onto the plane J - + Jn = plane normal taken from a, b, c of plane equation Jd = d component of plane equation - + dist = (Jn . Pcs) + Jd - + Pop = Pcs - dist(Jn) - + */ - + float dist; float a, b, c, d; float cX, cY, cZ; @@ -1066,14 +1066,14 @@ CLrQuad_Sphere( float t; UUtUns16 curPointIndex; const M3tPoint3D* curPoint; - + r2 = inSphere->radius; r2 *= r2; - + cX = inSphere->center.x; cY = inSphere->center.y; cZ = inSphere->center.z; - + // Start by finding the plane of the quad if we don't know it if (!inPlaneArray) { @@ -1087,36 +1087,36 @@ CLrQuad_Sphere( a = planeEqu.a; b = planeEqu.b; c = planeEqu.c; - d = planeEqu.d; - + d = planeEqu.d; + // First check if we are far away from the plane - + dist = a * cX + b * cY + c * cZ + d; - + if ((float)fabs(dist) > inSphere->radius) { return UUcFalse; } - + // Now check if we are close to any of the corners for(curPointIndex = 0; curPointIndex < 4; curPointIndex++) { curPoint = inPointArray + inQuad->indices[curPointIndex]; - + d2 = 0.0f; - + t = curPoint->x - cX; t *= t; d2 += t; - + t = curPoint->y - cY; t *= t; d2 += t; - + t = curPoint->z - cZ; t *= t; d2 += t; - + // if the distance^2 is less then the radius^2 then we are penetrating the sphere if (d2 < r2) { @@ -1129,23 +1129,23 @@ CLrQuad_Sphere( return UUcTrue; } } - + Pop.x = cX - dist * a; Pop.y = cY - dist * b; Pop.z = cZ - dist * c; - + if (CLrQuad_PointInQuad(inProjection, inPointArray, inQuad, &Pop)) { if (outCollisionPoint) *outCollisionPoint = Pop; return UUcTrue; } - + // Okay, those all failed. Now comes the expensive part. Check the // minimum distance from the sphere center to each of the quad edges { const M3tPoint3D *startPoint,*endPoint; UUtUns16 st=0,ed=1; - + // Intersect each edge with the sphere do { @@ -1156,12 +1156,12 @@ CLrQuad_Sphere( if (outCollisionPoint) *outCollisionPoint = Pop; return UUcTrue; } - + st++; ed = (ed+1)%4; } while (ed!=1); } - + return UUcFalse; } @@ -1198,12 +1198,12 @@ CLrQuad_FindProjection_Slow( float minX, minY, minZ; float maxX, maxY, maxZ; float dX, dY, dZ; - - + + // Find a legit 2D plane to project quad onto // A legit 2D plane does not collapse any of the points into the same point // or onto a flat line - + for(i = 0; i < 4; i++) { for(j = i+1; j < 4; j++) @@ -1231,7 +1231,7 @@ CLrQuad_FindProjection_Slow( sameY = UUmFloat_CompareEqu(targetPoint0->y, targetPoint1->y); sameZ = UUmFloat_CompareEqu(targetPoint0->z, targetPoint1->z); - if (sameX && sameY && sameZ) + if (sameX && sameY && sameZ) { continue; } @@ -1258,10 +1258,10 @@ CLrQuad_FindProjection_Slow( for(curPointIndex = 0; curPointIndex < 4; curPointIndex++) { curPoint = inPointArray + inQuad->indices[curPointIndex]; - + if (minX > curPoint->x) minX = curPoint->x; if (maxX < curPoint->x) maxX = curPoint->x; - + if (minY > curPoint->y) minY = curPoint->y; if (maxY < curPoint->y) maxY = curPoint->y; @@ -1272,7 +1272,7 @@ CLrQuad_FindProjection_Slow( dX = maxX - minX; dY = maxY - minY; dZ = maxZ - minZ; - + if (UUmFloat_CompareGT(dX, 0.0f) && UUmFloat_CompareGT(dY, 0.0f) && xyPlane) { return CLcProjection_XY; @@ -1303,8 +1303,8 @@ CLrQuad_FindProjection_Fast( float minX1, minY1, minZ1; float maxX1, maxY1, maxZ1; - UUtUns32 index0, index1, index2, index3; - const M3tPoint3D *point0, *point1, *point2, *point3; + UUtUns32 index0, index1, index2, index3; + const M3tPoint3D *point0, *point1, *point2, *point3; float x0,x1,x2,x3; float y0,y1,y2,y3; float z0,z1,z2,z3; @@ -1328,7 +1328,7 @@ CLrQuad_FindProjection_Fast( x2 = point2->x; y2 = point2->y; z2 = point2->z; x3 = point3->x; y3 = point3->y; z3 = point3->z; #else - x0 = point0->x; x1 = point1->x; x2 = point2->x; x3 = point3->x; + x0 = point0->x; x1 = point1->x; x2 = point2->x; x3 = point3->x; y0 = point0->y; y1 = point1->y; y2 = point2->y; y3 = point3->y; z0 = point0->z; z1 = point1->z; z2 = point2->z; z3 = point3->z; #endif @@ -1362,7 +1362,7 @@ CLrQuad_FindProjection_Fast( // noting in the above code might make this faster, legibility // binary or should be slightly faster here - not_xy_plane = global_same_x | global_same_y; + not_xy_plane = global_same_x | global_same_y; not_xz_plane = global_same_x | global_same_z; not_yz_plane = global_same_y | global_same_z; } @@ -1396,7 +1396,7 @@ CLrQuad_FindProjection_Fast( // (2,3) CLr_Quad_FindProject_HandleCaseMacro(x2, y2, z2, x3, y3, z3); - + if (!not_xy_plane) { projection = CLcProjection_XY; @@ -1413,7 +1413,7 @@ CLrQuad_FindProjection_Fast( { projection = CLcProjection_Unknown; } - + return projection; } @@ -1444,11 +1444,11 @@ static UUcInline UUtBool CLrQuad_PointInQuad_Internal( float u0, u1, u2, u3, ut; float v0, v1, v2, v3, vt; float w0, w1, w2, w3, wt; - + const M3tPoint3D* curPoint; - + UUtBool result; - + if (inProjection == CLcProjection_Unknown) { inProjection = CLrQuad_FindProjection(inPointArray, inQuad); @@ -1457,13 +1457,13 @@ static UUcInline UUtBool CLrQuad_PointInQuad_Internal( return UUcFalse; } } - + if (inProjection == CLcProjection_XY) { ut = inPoint->x; vt = inPoint->y; wt = inPoint->z; - + curPoint = inPointArray + inQuad->indices[0]; u0 = curPoint->x; v0 = curPoint->y; @@ -1480,7 +1480,7 @@ static UUcInline UUtBool CLrQuad_PointInQuad_Internal( u3 = curPoint->x; v3 = curPoint->y; w3 = curPoint->z; - + if (UUmFloat_CompareLTSloppy(wt, w0) && UUmFloat_CompareLTSloppy(wt, w1) && UUmFloat_CompareLTSloppy(wt, w2) && @@ -1495,7 +1495,7 @@ static UUcInline UUtBool CLrQuad_PointInQuad_Internal( ut = inPoint->x; vt = inPoint->z; wt = inPoint->y; - + curPoint = inPointArray + inQuad->indices[0]; u0 = curPoint->x; v0 = curPoint->z; @@ -1512,7 +1512,7 @@ static UUcInline UUtBool CLrQuad_PointInQuad_Internal( u3 = curPoint->x; v3 = curPoint->z; w3 = curPoint->y; - + if (UUmFloat_CompareLTSloppy(wt, w0) && UUmFloat_CompareLTSloppy(wt, w1) && UUmFloat_CompareLTSloppy(wt, w2) && @@ -1527,7 +1527,7 @@ static UUcInline UUtBool CLrQuad_PointInQuad_Internal( ut = inPoint->y; vt = inPoint->z; wt = inPoint->x; - + curPoint = inPointArray + inQuad->indices[0]; u0 = curPoint->y; v0 = curPoint->z; @@ -1544,7 +1544,7 @@ static UUcInline UUtBool CLrQuad_PointInQuad_Internal( u3 = curPoint->y; v3 = curPoint->z; w3 = curPoint->x; - + if (UUmFloat_CompareLTSloppy(wt, w0) && UUmFloat_CompareLTSloppy(wt, w1) && UUmFloat_CompareLTSloppy(wt, w2) && @@ -1554,10 +1554,10 @@ static UUcInline UUtBool CLrQuad_PointInQuad_Internal( UUmFloat_CompareGTSloppy(wt, w2) && UUmFloat_CompareGTSloppy(wt, w3)) return UUcFalse; } - + /* If the point is in the quad we have something like this - + *0 /|\ / | \ @@ -1572,47 +1572,47 @@ static UUcInline UUtBool CLrQuad_PointInQuad_Internal( \|/ *2 either: - + |t0 x t1| <= 0 && |t1 x t2| <= 0 && |t2 x t3| <= 0 && |t3 x t0| <= 0 - + or - + |t0 x t1| >= 0 && |t1 x t2| >= 0 && |t2 x t3| >= 0 && |t3 x t0| >= 0 - + (It depends on the orientation of the vertices) - + if the above conditions are not met the point is outside the quad - + */ tr0 = (u0 - ut) * (v1 - vt) - (v0 - vt) * (u1 - ut); tr1 = (u1 - ut) * (v2 - vt) - (v1 - vt) * (u2 - ut); tr2 = (u2 - ut) * (v3 - vt) - (v2 - vt) * (u3 - ut); tr3 = (u3 - ut) * (v0 - vt) - (v3 - vt) * (u0 - ut); - + result = UUmFloat_CompareGE(tr0, 0.0f) && UUmFloat_CompareGE(tr1, 0.0f) && UUmFloat_CompareGE(tr2, 0.0f) && UUmFloat_CompareGE(tr3, 0.0f); - + if (result == UUcTrue) { return UUcTrue; } - + result = UUmFloat_CompareLE(tr0, 0.0f) && UUmFloat_CompareLE(tr1, 0.0f) && UUmFloat_CompareLE(tr2, 0.0f) && UUmFloat_CompareLE(tr3, 0.0f); - + return result; } @@ -1623,7 +1623,7 @@ UUtBool CLrQuad_PointInQuad( const M3tPoint3D* inPoint) { UUtBool result; - + #if PERFORMANCE_TIMER UUrPerformanceTimer_Enter(CLgQuad_PointInQuad_Timer); #endif @@ -1650,12 +1650,12 @@ CLrQuad_Box( M3tPoint3D startPoint; M3tPoint3D endPoint; UUtUns16 curPointIndex; - + // First check if any of the vertices are within the box for(curPointIndex = 0; curPointIndex < 4; curPointIndex++) { curPoint = inPointArray + inQuad->indices[curPointIndex]; - + if (UUmFloat_CompareGE(curPoint->x, inBBox->minPoint.x) && UUmFloat_CompareLE(curPoint->x, inBBox->maxPoint.x) && UUmFloat_CompareGE(curPoint->y, inBBox->minPoint.y) && @@ -1666,7 +1666,7 @@ CLrQuad_Box( return UUcTrue; } } - + if (inProjection == CLcProjection_Unknown) { inProjection = CLrQuad_FindProjection(inPointArray, inQuad); @@ -1675,12 +1675,12 @@ CLrQuad_Box( return UUcFalse; } } - + // Now check for the line intersection of each box edge with the quad - + /* 0 - min, 1 - max - + v X Y Z == ========= 0 0 0 0 @@ -1691,7 +1691,7 @@ CLrQuad_Box( 5 1 0 1 6 1 1 0 7 1 1 1 - + Edges ===== 0 -> 1 @@ -1707,16 +1707,16 @@ CLrQuad_Box( 5 -> 7 6 -> 7 */ - + // 0 -> 1 startPoint.x = inBBox->minPoint.x; startPoint.y = inBBox->minPoint.y; startPoint.z = inBBox->minPoint.z; - + endPoint.x = inBBox->minPoint.x; endPoint.y = inBBox->minPoint.y; endPoint.z = inBBox->maxPoint.z; - + if (CLrQuad_Line( inProjection, inPointArray, @@ -1726,20 +1726,20 @@ CLrQuad_Box( &startPoint, &endPoint, NULL)) - + { return UUcTrue; } - + // 0 -> 2 startPoint.x = inBBox->minPoint.x; startPoint.y = inBBox->minPoint.y; startPoint.z = inBBox->minPoint.z; - + endPoint.x = inBBox->minPoint.x; endPoint.y = inBBox->maxPoint.y; endPoint.z = inBBox->minPoint.z; - + if (CLrQuad_Line( inProjection, inPointArray, @@ -1749,20 +1749,20 @@ CLrQuad_Box( &startPoint, &endPoint, NULL)) - + { return UUcTrue; } - + // 0 -> 4 startPoint.x = inBBox->minPoint.x; startPoint.y = inBBox->minPoint.y; startPoint.z = inBBox->minPoint.z; - + endPoint.x = inBBox->maxPoint.x; endPoint.y = inBBox->minPoint.y; endPoint.z = inBBox->minPoint.z; - + if (CLrQuad_Line( inProjection, inPointArray, @@ -1772,20 +1772,20 @@ CLrQuad_Box( &startPoint, &endPoint, NULL)) - + { return UUcTrue; } - + // 1 -> 3 startPoint.x = inBBox->minPoint.x; startPoint.y = inBBox->minPoint.y; startPoint.z = inBBox->maxPoint.z; - + endPoint.x = inBBox->minPoint.x; endPoint.y = inBBox->maxPoint.y; endPoint.z = inBBox->maxPoint.z; - + if (CLrQuad_Line( inProjection, inPointArray, @@ -1795,20 +1795,20 @@ CLrQuad_Box( &startPoint, &endPoint, NULL)) - + { return UUcTrue; } - + // 1 -> 5 startPoint.x = inBBox->minPoint.x; startPoint.y = inBBox->minPoint.y; startPoint.z = inBBox->maxPoint.z; - + endPoint.x = inBBox->maxPoint.x; endPoint.y = inBBox->minPoint.y; endPoint.z = inBBox->maxPoint.z; - + if (CLrQuad_Line( inProjection, inPointArray, @@ -1818,20 +1818,20 @@ CLrQuad_Box( &startPoint, &endPoint, NULL)) - + { return UUcTrue; } - + // 2 -> 3 startPoint.x = inBBox->minPoint.x; startPoint.y = inBBox->maxPoint.y; startPoint.z = inBBox->minPoint.z; - + endPoint.x = inBBox->minPoint.x; endPoint.y = inBBox->maxPoint.y; endPoint.z = inBBox->maxPoint.z; - + if (CLrQuad_Line( inProjection, inPointArray, @@ -1841,20 +1841,20 @@ CLrQuad_Box( &startPoint, &endPoint, NULL)) - + { return UUcTrue; } - + // 2 -> 6 startPoint.x = inBBox->minPoint.x; startPoint.y = inBBox->maxPoint.y; startPoint.z = inBBox->minPoint.z; - + endPoint.x = inBBox->maxPoint.x; endPoint.y = inBBox->maxPoint.y; endPoint.z = inBBox->minPoint.z; - + if (CLrQuad_Line( inProjection, inPointArray, @@ -1864,20 +1864,20 @@ CLrQuad_Box( &startPoint, &endPoint, NULL)) - + { return UUcTrue; } - + // 3 -> 7 startPoint.x = inBBox->minPoint.x; startPoint.y = inBBox->maxPoint.y; startPoint.z = inBBox->maxPoint.z; - + endPoint.x = inBBox->maxPoint.x; endPoint.y = inBBox->maxPoint.y; endPoint.z = inBBox->maxPoint.z; - + if (CLrQuad_Line( inProjection, inPointArray, @@ -1887,20 +1887,20 @@ CLrQuad_Box( &startPoint, &endPoint, NULL)) - + { return UUcTrue; } - + // 4 -> 5 startPoint.x = inBBox->maxPoint.x; startPoint.y = inBBox->minPoint.y; startPoint.z = inBBox->minPoint.z; - + endPoint.x = inBBox->maxPoint.x; endPoint.y = inBBox->minPoint.y; endPoint.z = inBBox->maxPoint.z; - + if (CLrQuad_Line( inProjection, inPointArray, @@ -1910,20 +1910,20 @@ CLrQuad_Box( &startPoint, &endPoint, NULL)) - + { return UUcTrue; } - + // 4 -> 6 startPoint.x = inBBox->maxPoint.x; startPoint.y = inBBox->minPoint.y; startPoint.z = inBBox->minPoint.z; - + endPoint.x = inBBox->maxPoint.x; endPoint.y = inBBox->maxPoint.y; endPoint.z = inBBox->minPoint.z; - + if (CLrQuad_Line( inProjection, inPointArray, @@ -1933,20 +1933,20 @@ CLrQuad_Box( &startPoint, &endPoint, NULL)) - + { return UUcTrue; } - + // 5 -> 7 startPoint.x = inBBox->maxPoint.x; startPoint.y = inBBox->minPoint.y; startPoint.z = inBBox->maxPoint.z; - + endPoint.x = inBBox->maxPoint.x; endPoint.y = inBBox->maxPoint.y; endPoint.z = inBBox->maxPoint.z; - + if (CLrQuad_Line( inProjection, inPointArray, @@ -1956,20 +1956,20 @@ CLrQuad_Box( &startPoint, &endPoint, NULL)) - + { return UUcTrue; } - + // 6 -> 7 startPoint.x = inBBox->maxPoint.x; startPoint.y = inBBox->maxPoint.y; startPoint.z = inBBox->minPoint.z; - + endPoint.x = inBBox->maxPoint.x; endPoint.y = inBBox->maxPoint.y; endPoint.z = inBBox->maxPoint.z; - + if (CLrQuad_Line( inProjection, inPointArray, @@ -1982,7 +1982,7 @@ CLrQuad_Box( { return UUcTrue; } - + // now we need to loop through each edge of the quad to see if it penetrates the box for(curPointIndex = 0; curPointIndex < 4; curPointIndex++) { @@ -1993,9 +1993,9 @@ CLrQuad_Box( { return UUcTrue; } - + } - + return UUcFalse; } @@ -2013,7 +2013,7 @@ CLrBox_Point( { return UUcTrue; } - + return UUcFalse; } @@ -2024,7 +2024,7 @@ CLrBox_Box( { // Lame intersection, not totally correct. For debugging of same size boxes only. UUtUns16 indexA; - + for (indexA=0; indexA<8; indexA++) { if (CLrBox_Point(inBoxB,&inBoxA->localPoints[indexA])) UUmAssert(0);//return UUcTrue; @@ -2033,10 +2033,10 @@ CLrBox_Box( { if (CLrBox_Point(inBoxA,&inBoxB->localPoints[indexA])) UUmAssert(0);//return UUcTrue; } - + return UUcFalse; } - + static UUtBool CLrBox_Line_Slower( const M3tBoundingBox_MinMax* inBox, @@ -2046,29 +2046,29 @@ CLrBox_Line_Slower( float Xi, Yi, Zi; float Xm, Ym, Zm; float Xmi, Ymi, Zmi; - + float Xf, Yf, Zf; - + float ut, vt; - + float minX, minY, minZ; float maxX, maxY, maxZ; float t; - + //return UUcTrue; - + minX = inBox->minPoint.x; minY = inBox->minPoint.y; minZ = inBox->minPoint.z; - + maxX = inBox->maxPoint.x; maxY = inBox->maxPoint.y; maxZ = inBox->maxPoint.z; - + Xi = inStartPoint->x; Yi = inStartPoint->y; Zi = inStartPoint->z; - + // If either of the points are in the box then duh. if (minX <= Xi && Xi <= maxX && minY <= Yi && Yi <= maxY && @@ -2076,7 +2076,7 @@ CLrBox_Line_Slower( { return UUcTrue; } - + Xf = inEndPoint->x; Yf = inEndPoint->y; Zf = inEndPoint->z; @@ -2087,7 +2087,7 @@ CLrBox_Line_Slower( { return UUcTrue; } - + // Check for trivial reject if (Xi < minX && Xf < minX || Yi < minY && Yf < minY || @@ -2098,14 +2098,14 @@ CLrBox_Line_Slower( { return UUcFalse; } - + Xm = (inEndPoint->x - Xi); Ym = (inEndPoint->y - Yi); Zm = (inEndPoint->z - Zi); /* 0 - min, 1 - max - + v X Y Z == ========= 0 0 0 0 @@ -2116,7 +2116,7 @@ CLrBox_Line_Slower( 5 1 0 1 6 1 1 0 7 1 1 1 - + Y ^ | @@ -2141,7 +2141,7 @@ CLrBox_Line_Slower( | ' | / |' |/ 1*-------------*5 - + quads plane equ ===== ======= 0 1 3 2 -1, 0, 0, 0.x @@ -2151,7 +2151,7 @@ CLrBox_Line_Slower( 0 2 6 4 0, 0, -1, 0.z 1 5 7 3 0, 0, 1, -1.z */ - + if (Xm != 0.0f) { // Quad 0 1 3 2 @@ -2162,7 +2162,7 @@ CLrBox_Line_Slower( { ut = Ym * t + Yi; vt = Zm * t + Zi; - + if (minY <= ut && ut <= maxY && minZ <= vt && vt <= maxZ) { @@ -2171,11 +2171,11 @@ CLrBox_Line_Slower( UUmAssert((minZ - Zi) * Xm <= Zm * (minX - Xi)); UUmAssert(Zm * (minX - Xi) <= (maxZ - Zi) * Xm); - + return UUcTrue; } } - + // Quad 4 6 7 5 // t = -(1 * Xi - maxX) / Xm @@ -2184,7 +2184,7 @@ CLrBox_Line_Slower( { ut = Ym * t + Yi; vt = Zm * t + Zi; - + if (minY <= ut && ut <= maxY && minZ <= vt && vt <= maxZ) { @@ -2198,11 +2198,11 @@ CLrBox_Line_Slower( } } } - + if (Ym != 0.0f) { // Quad 0 4 5 1 - + Ymi = 1.f / Ym; // t = -(-1 * Yi + minY) / -Ym t = (minY - Yi) * Ymi; @@ -2210,7 +2210,7 @@ CLrBox_Line_Slower( { ut = Xm * t + Xi; vt = Zm * t + Zi; - + if (minX <= ut && ut <= maxX && minZ <= vt && vt <= maxZ) { @@ -2230,11 +2230,11 @@ CLrBox_Line_Slower( UUmAssert((minZ - Zi) * Ym >= Zm * (minY - Yi)); UUmAssert(Zm * (minY - Yi) >= (maxZ - Zi) * Ym); } - + return UUcTrue; } } - + // Quad 2 3 7 6 // t = -(1 * Xi - maxX) / Xm @@ -2243,7 +2243,7 @@ CLrBox_Line_Slower( { ut = Xm * t + Xi; vt = Zm * t + Zi; - + if (minX <= ut && ut <= maxX && minZ <= vt && vt <= maxZ) { @@ -2251,11 +2251,11 @@ CLrBox_Line_Slower( } } } - + if (Zm != 0.0f) { // Quad 0 2 6 4 - + Zmi = 1.f / Zm; // t = -(-1 * Zi + minZ) / -Zm t = (minZ - Zi) * Zmi; @@ -2263,14 +2263,14 @@ CLrBox_Line_Slower( { ut = Xm * t + Xi; vt = Ym * t + Yi; - + if (minX <= ut && ut <= maxX && minY <= vt && vt <= maxY) { return UUcTrue; } } - + // Quad 1 5 7 3 // t = -(1 * Zi - maxZ) / Zm @@ -2279,7 +2279,7 @@ CLrBox_Line_Slower( { ut = Xm * t + Xi; vt = Ym * t + Yi; - + if (minX <= ut && ut <= maxX && minY <= vt && vt <= maxY) { @@ -2287,7 +2287,7 @@ CLrBox_Line_Slower( } } } - + return UUcFalse; } @@ -2299,27 +2299,27 @@ CLrBox_Line( { float Xi, Yi, Zi; float Xm, Ym, Zm; - + float Xf, Yf, Zf; - + float minX, minY, minZ; float maxX, maxY, maxZ; float t, t2; - + //return UUcTrue; - + minX = inBox->minPoint.x; minY = inBox->minPoint.y; minZ = inBox->minPoint.z; - + maxX = inBox->maxPoint.x; maxY = inBox->maxPoint.y; maxZ = inBox->maxPoint.z; - + Xi = inStartPoint->x; Yi = inStartPoint->y; Zi = inStartPoint->z; - + // If either of the points are in the box then duh. if (minX <= Xi && Xi <= maxX && minY <= Yi && Yi <= maxY && @@ -2327,7 +2327,7 @@ CLrBox_Line( { return UUcTrue; } - + Xf = inEndPoint->x; Yf = inEndPoint->y; Zf = inEndPoint->z; @@ -2338,7 +2338,7 @@ CLrBox_Line( { return UUcTrue; } - + // Check for trivial reject if (Xi < minX && Xf < minX || Yi < minY && Yf < minY || @@ -2349,23 +2349,23 @@ CLrBox_Line( { return UUcFalse; } - + /* The following crap would take a long time to explain so you will just have to take my word for it that its completely broken and you have no hope of fixing it. */ - + Xm = (Xf - Xi); Ym = (Yf - Yi); Zm = (Zf - Zi); - + minY -= Yi; maxY -= Yi; - + minX -= Xi; maxX -= Xi; - + minZ -= Zi; maxZ -= Zi; @@ -2373,16 +2373,16 @@ CLrBox_Line( { t = Ym * minX; t2 = Zm * minX; - + if (minY * Xm <= t && t <= maxY * Xm && minZ * Xm <= t2 && t2 <= maxZ * Xm) { return UUcTrue; } - + t = Ym * maxX; t2 = Zm * maxX; - + if (minY * Xm <= t && t <= maxY * Xm && minZ * Xm <= t2 && t2 <= maxZ * Xm) { @@ -2393,37 +2393,37 @@ CLrBox_Line( { t = Ym * minX; t2 = Zm * minX; - + if (minY * Xm >= t && t >= maxY * Xm && minZ * Xm >= t2 && t2 >= maxZ * Xm) { return UUcTrue; } - + t = Ym * maxX; t2 = Zm * maxX; - + if (minY * Xm >= t && t >= maxY * Xm && minZ * Xm >= t2 && t2 >= maxZ * Xm) { return UUcTrue; } } - + if (Ym > 0.0f) { t = Xm * minY; t2 = Zm * minY; - + if (minX * Ym <= t && t <= maxX * Ym && minZ * Ym <= t2 && t2 <= maxZ * Ym) { return UUcTrue; } - + t = Xm * maxY; t2 = Zm * maxY; - + if (minX * Ym <= t && t <= maxX * Ym && minZ * Ym <= t2 && t2 <= maxZ * Ym) { @@ -2434,37 +2434,37 @@ CLrBox_Line( { t = Xm * minY; t2 = Zm * minY; - + if (minX * Ym >= t && t >= maxX * Ym && minZ * Ym >= t2 && t2 >= maxZ * Ym) { return UUcTrue; } - + t = Xm * maxY; t2 = Zm * maxY; - + if (minX * Ym >= t && t >= maxX * Ym && minZ * Ym >= t2 && t2 >= maxZ * Ym) { return UUcTrue; } } - + if (Zm > 0.0f) { t = Xm * minZ; t2 = Ym * minZ; - + if (minX * Zm <= t && t <= maxX * Zm && minY * Zm <= t2 && t2 <= maxY * Zm) { return UUcTrue; } - + t = Xm * maxZ; t2 = Ym * maxZ; - + if (minX * Zm <= t && t <= maxX * Zm && minY * Zm <= t2 && t2 <= maxY * Zm) { @@ -2475,23 +2475,23 @@ CLrBox_Line( { t = Xm * minZ; t2 = Ym * minZ; - + if (minX * Zm >= t && t >= maxX * Zm && minY * Zm >= t2 && t2 >= maxY * Zm) { return UUcTrue; } - + t = Xm * maxZ; t2 = Ym * maxZ; - + if (minX * Zm >= t && t >= maxX * Zm && minY * Zm >= t2 && t2 >= maxY * Zm) { return UUcTrue; } } - + return UUcFalse; } @@ -2503,21 +2503,21 @@ CLrBox_Sphere( float r2 = inSphere->radius; float dmin = 0.0f; float t; - + float cX, cY, cZ; float minX, minY, minZ; float maxX, maxY, maxZ; - + r2 *= r2; - + cX = inSphere->center.x; cY = inSphere->center.y; cZ = inSphere->center.z; - + minX = inBox->minPoint.x; minY = inBox->minPoint.y; minZ = inBox->minPoint.z; - + maxX = inBox->maxPoint.x; maxY = inBox->maxPoint.y; maxZ = inBox->maxPoint.z; @@ -2528,9 +2528,9 @@ CLrBox_Sphere( { return UUcTrue; } - + // Don't ask me - I got it from Gems I - + if (cX < minX) { t = cX - minX; @@ -2543,7 +2543,7 @@ CLrBox_Sphere( t *= t; dmin += t; } - + if (cY < minY) { t = cY - minY; @@ -2556,7 +2556,7 @@ CLrBox_Sphere( t *= t; dmin += t; } - + if (cZ < minZ) { t = cZ - minZ; @@ -2569,7 +2569,7 @@ CLrBox_Sphere( t *= t; dmin += t; } - + return (UUtBool)(dmin <= r2); } @@ -2609,7 +2609,7 @@ UUtBool PHrCollision_Volume_Ray( M3tPlaneEquation *outPlane, // optional M3tPoint3D *outPoint) // optional { - /********** + /********** * Intersects a point that moves 'inV' with the given bounding volume */ @@ -2623,7 +2623,7 @@ UUtBool PHrCollision_Volume_Ray( normalV = *inV; d = MUmVector_GetLength(normalV); - + if (d!=0.0f) { MUmVector_Scale(normalV,1.0f/d); } @@ -2665,7 +2665,7 @@ UUtBool PHrCollision_Volume_Ray( *outPlane = *collisionPlane; } - if (outPoint != NULL) { + if (outPoint != NULL) { *outPoint = collisionPoint; } } diff --git a/BungieFrameWork/BFW_Source/BFW_CommandLine/BFW_CommandLine.c b/BungieFrameWork/BFW_Source/BFW_CommandLine/BFW_CommandLine.c index 5ad91a4..deb5486 100644 --- a/BungieFrameWork/BFW_Source/BFW_CommandLine/BFW_CommandLine.c +++ b/BungieFrameWork/BFW_Source/BFW_CommandLine/BFW_CommandLine.c @@ -12,7 +12,7 @@ #include "BFW_CL_Platform_MacOS.h" #elif UUmPlatform == UUmPlatform_Win32 - + #include "BFW_CL_Platform_Win32.h" #endif diff --git a/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_MacOS/BFW_CL_Platform_MacOS.c b/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_MacOS/BFW_CL_Platform_MacOS.c index 039ef0b..5436e87 100644 --- a/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_MacOS/BFW_CL_Platform_MacOS.c +++ b/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_MacOS/BFW_CL_Platform_MacOS.c @@ -278,7 +278,7 @@ static char *key_labels[]= { "numpad 5", "numpad 6", "numpad 7", - "numpad 8", + "numpad 8", "numpad 9", "\\", ";", @@ -336,13 +336,13 @@ static void pstrcopy ( StringPtr p2) { register int len; - + len= *p2++= *p1++; while (--len >= 0) { *p2++= *p1++; } - + return; } @@ -350,37 +350,37 @@ static void init_bindings_from_file( char *filename) { FILE *key_config_file; - + if ((key_config_file= fopen(filename, "r")) != NULL) - { + { for (;;) { char *str, *token, *delimiters= " \t\r\n"; char line[128]; - + str= fgets(line, 127, key_config_file); - + if (str[0] == '\r') { BlockMove(line+1, line, 127); } - + if ((str[0] == '#') || (str[0] == '\n') || (str[0] == '\r')) { continue; } - + if ((str == NULL) || (str[0] == '\0')) { break; // EOF } - + // search for strings of the form "bind oni_key_name to oni_action_name" token= strtok(line, delimiters); if (token && strcmp(token, "bind") == 0) { int i; - + if ((token= strtok(NULL, delimiters)) != NULL) { for (i= 0; i 0) @@ -540,7 +540,7 @@ static void set_action_bindings_from_dialog( action_bindings[action_index].oni_key_name= key_bindings[menu_selection - 1]; } } - + return; } @@ -554,7 +554,7 @@ static Boolean handle_dialog_event( WindowPtr which_window= NULL; short item_hit= 0, item_type= 0; Handle item_handle= NULL; - + if (DialogSelect(event, &which_dialog, &item_hit ) == false) { // no extra work needed , just return @@ -567,7 +567,7 @@ static Boolean handle_dialog_event( // esc should count as hitting the cancel button unsigned char key_code= (event->message & charCodeMask); Boolean eat_key= false; - + if ((key_code == key_return) || (key_code == key_enter)) { item_hit= _save_button; @@ -578,12 +578,12 @@ static Boolean handle_dialog_event( item_hit= _cancel_button; eat_key= true; } - + if (eat_key) { Str255 edit_text= "\p"; Rect item_rect; - + GetDialogItem(dialog, _args_edit_text, &item_type, &item_handle, &item_rect); UUmAssert(item_handle); GetDialogItemText(item_handle, edit_text); @@ -591,7 +591,7 @@ static Boolean handle_dialog_event( SetDialogItemText(item_handle, edit_text); } } - + if (item_hit > 0) { switch (item_hit) @@ -617,10 +617,10 @@ static Boolean handle_dialog_event( Handle item_handle; Rect item_rect; int action_index= item_hit - _forward_menu; - + GetDialogItem(dialog, item_hit, &item_type, &item_handle, &item_rect); menu_selection= GetControlValue((ControlHandle)item_handle); - + action_bindings[action_index].oni_key_name= key_bindings[menu_selection - 1]; sprintf(label, "%s : %s", action_labels[action_index], key_labels[menu_selection - 1]); c2pstrcpy(label, label); @@ -651,7 +651,7 @@ static Boolean handle_dialog_event( } } } - + return done; } @@ -664,7 +664,7 @@ static Boolean handle_dialog_event_osx( WindowPtr which_window= NULL; short item_hit= 0, item_type= 0; Handle item_handle= NULL; - + if (DialogSelect(event, &which_dialog, &item_hit ) == false) { // no extra work needed , just return @@ -677,14 +677,14 @@ static Boolean handle_dialog_event_osx( // esc should count as hitting the cancel button unsigned char key_code= (event->message & charCodeMask); Boolean eat_key= false; - + if ((key_code == key_return) || (key_code == key_enter)) { Str255 edit_text= "\p"; Rect item_rect; - + item_hit= _ok_button_osx; - + GetDialogItem(dialog, _args_edit_text_osx, &item_type, &item_handle, &item_rect); UUmAssert(item_handle); GetDialogItemText(item_handle, edit_text); @@ -696,7 +696,7 @@ static Boolean handle_dialog_event_osx( item_hit= _quit_button_osx; } } - + if (item_hit > 0) { switch (item_hit) @@ -712,7 +712,7 @@ static Boolean handle_dialog_event_osx( } } } - + return done; } @@ -722,32 +722,32 @@ static UUtInt16 CLrPlatform_GetCommandLine_PreOSX( DialogPtr dialog; StringHandle key_config_filename_string= NULL, command_line_string= NULL; UUtInt16 argc= 0; - + command_line_string= GetString(COMMAND_LINE_ARGS_STR_RSRC); - + if ((key_config_filename_string= GetString(KEY_CONFIG_FILENAME_STR_RSRC)) != NULL) { HLock(key_config_filename_string); p2cstrcpy((char *)(*key_config_filename_string), *key_config_filename_string); init_bindings_from_file((char *)(*key_config_filename_string)); } - + dialog= GetNewDialog(OPTIONS_DLOG_RSRC, nil, (WindowPtr)(-1L)); - + if (dialog && key_config_filename_string) { Boolean done= false, save_prefs= false; GrafPtr save_port; - + GetPort(&save_port); - + SetDialogDefaultItem(dialog, _save_button); SetDialogCancelItem(dialog, _cancel_button); SetDialogTracksCursor(dialog, true); - + SetPort(GetWindowPort(dialog)); ShowWindow(GetWindowPort(dialog)); - + // setup menus & labels set_dialog_from_action_bindings(dialog); if (command_line_string) @@ -760,28 +760,28 @@ static UUtInt16 CLrPlatform_GetCommandLine_PreOSX( { set_dialog_item_text(dialog, _args_edit_text, "\p"); } - + while (done == false) { EventRecord event; - + if (GetNextEvent( everyEvent, &event)) { done= handle_dialog_event(dialog, &event, &save_prefs); } } - + if (save_prefs && key_config_filename_string) { save_bindings_to_file((char *)(*key_config_filename_string)); } - + if (key_config_filename_string) { HUnlock(key_config_filename_string); ReleaseResource(key_config_filename_string); } - + // get command line args { Handle item_handle; @@ -789,7 +789,7 @@ static UUtInt16 CLrPlatform_GetCommandLine_PreOSX( Rect item_rect; static char command_line[256]= ""; static char *command_line_args[32]= { "Oni" }; - + GetDialogItem(dialog, _args_edit_text, &item_type, &item_handle, &item_rect); UUmAssert(item_handle); GetDialogItemText(item_handle, (StringPtr)command_line); @@ -807,7 +807,7 @@ static UUtInt16 CLrPlatform_GetCommandLine_PreOSX( ReleaseResource(command_line_string); } p2cstrcpy(command_line, command_line); // an in-place copy - + argc= 1; // "Oni" if (command_line[0] != '\0') { @@ -815,7 +815,7 @@ static UUtInt16 CLrPlatform_GetCommandLine_PreOSX( while (arg && (arg[0] != '\0') && (argc < 31)) { int length= 0; - + while ((arg[length] != '\0') && !isspace(arg[length]) && (length < 63)) { ++length; @@ -833,15 +833,15 @@ static UUtInt16 CLrPlatform_GetCommandLine_PreOSX( } } } - + *argv= command_line_args; } - - + + SetPort(save_port); DisposeDialog(dialog); } - + return argc; } @@ -851,25 +851,25 @@ static UUtInt16 CLrPlatform_GetCommandLine_OSX( DialogPtr dialog; StringHandle command_line_string= NULL; UUtInt16 argc= 0; - + command_line_string= GetString(COMMAND_LINE_ARGS_STR_RSRC); - + dialog= GetNewDialog(OPTIONS_DLOG_RSRC_OSX, nil, (WindowPtr)(-1L)); - + if (dialog) { Boolean done= false; GrafPtr save_port; - + GetPort(&save_port); - + SetDialogDefaultItem(dialog, _ok_button_osx); SetDialogCancelItem(dialog, _quit_button_osx); SetDialogTracksCursor(dialog, true); - + SetPort(GetWindowPort(dialog)); ShowWindow(GetWindowPort(dialog)); - + // setup menus & labels if (command_line_string) { @@ -881,17 +881,17 @@ static UUtInt16 CLrPlatform_GetCommandLine_OSX( { set_dialog_item_text(dialog, _args_edit_text_osx, "\p"); } - + while (done == false) { EventRecord event; - + if (GetNextEvent( everyEvent, &event)) { done= handle_dialog_event_osx(dialog, &event); } } - + // get command line args { Handle item_handle; @@ -899,7 +899,7 @@ static UUtInt16 CLrPlatform_GetCommandLine_OSX( Rect item_rect; static char command_line[256]= ""; static char *command_line_args[32]= { "Oni" }; - + GetDialogItem(dialog, _args_edit_text_osx, &item_type, &item_handle, &item_rect); UUmAssert(item_handle); GetDialogItemText(item_handle, (StringPtr)command_line); @@ -914,18 +914,18 @@ static UUtInt16 CLrPlatform_GetCommandLine_OSX( ReleaseResource(command_line_string); } p2cstrcpy(command_line, command_line); // an in-place copy - + argc= 1; // "Oni" if (command_line[0] != '\0') { char *arg= command_line; - + while (isspace(*arg)) ++arg; - + while (arg && (arg[0] != '\0') && (argc < 31)) { int length= 0; - + while ((arg[length] != '\0') && !isspace(arg[length]) && (length < 63)) { ++length; @@ -943,15 +943,15 @@ static UUtInt16 CLrPlatform_GetCommandLine_OSX( } } } - + *argv= command_line_args; } - - + + SetPort(save_port); DisposeDialog(dialog); } - + return argc; } @@ -961,14 +961,14 @@ UUtInt16 CLrPlatform_GetCommandLine( OSErr err; unsigned long value; UUtInt16 argc= 0; - + // check OS version; the pre-OSX version has key-config items that use special // dialog controls which puke under OSX, hence the 2 versions err= Gestalt(gestaltSystemVersion, &value); if (err == noErr) { unsigned long major_version; - + // value will look like this: 0x00000904 (OS 9.0.4) major_version= (value & 0x0000FF00)>>8; if (major_version >= 10) @@ -980,7 +980,7 @@ UUtInt16 CLrPlatform_GetCommandLine( argc= CLrPlatform_GetCommandLine_PreOSX(argv); } } - + return argc; } diff --git a/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_MacOS/BFW_CL_Platform_MacOS.h b/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_MacOS/BFW_CL_Platform_MacOS.h index d2ff973..ab98361 100644 --- a/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_MacOS/BFW_CL_Platform_MacOS.h +++ b/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_MacOS/BFW_CL_Platform_MacOS.h @@ -17,4 +17,4 @@ CLrPlatform_GetCommandLine( char ***inArgV); // ====================================================================== -#endif /* BFW_CL_PLATFORM_MACOS_H */ \ No newline at end of file +#endif /* BFW_CL_PLATFORM_MACOS_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_Win32/BFW_CL_Platform_Win32.c b/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_Win32/BFW_CL_Platform_Win32.c index eb14f61..cc37500 100644 --- a/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_Win32/BFW_CL_Platform_Win32.c +++ b/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_Win32/BFW_CL_Platform_Win32.c @@ -31,7 +31,7 @@ static char CLgApplicationName[MAX_APPLICATION_NAME]; static UUtInt16 CLiParseArgs( char *inCommandLine); - + static BOOL CALLBACK CLiDialogBoxProc( HWND inHDlg, @@ -57,32 +57,32 @@ CLiDialogBoxProc( RECT dialog_rect; UUtInt16 x, y, width, height; UUtInt16 screen_width, screen_height; - + // get the dialogs dimensions GetWindowRect(inHDlg, &dialog_rect); - + // calculate the width and height of the dialog width = (UUtInt16) (dialog_rect.right - dialog_rect.left); height = (UUtInt16) (dialog_rect.bottom - dialog_rect.top); - + // get the screen width and height screen_width = GetSystemMetrics(SM_CXSCREEN); screen_height = GetSystemMetrics(SM_CYSCREEN); - + // calculate the x and y of the dialog x = (screen_width - width) / 2; y = (screen_height - height) / 2; - + // set the dialogs position in the middle of the screen - // flags: ignore width and height + // flags: ignore width and height SetWindowPos(inHDlg, HWND_TOP, x, y, 0, 0, SWP_NOSIZE | SWP_NOREDRAW); SetWindowText(GetDlgItem(inHDlg, ID_EDIT1), CLgCommandLine); - + return TRUE; } break; - + case WM_COMMAND: switch (LOWORD(inWParam)) { @@ -100,7 +100,7 @@ CLiDialogBoxProc( } break; } - + return FALSE; } @@ -116,26 +116,26 @@ CLiParseArgs( char *p; char *p1; char c; - + n = 1; Quote = 0; p = inCommandLine; p1 = (char*)argStr; - + while ((c = *p++) != 0) { if (c==' ') continue; - + CLgArgV[n++] = p1; - + if (n > MAX_ARGS) { return (n-1); } - + do { - if (c=='\\' && *p++) + if (c=='\\' && *p++) { c = *p++; } @@ -148,7 +148,7 @@ CLiParseArgs( Quote = c; continue; } - + if (c == Quote) { Quote = 0; @@ -208,13 +208,13 @@ CLrPlatform_GetCommandLine( { HRESULT result; UUtInt16 argc; - + // clear CLgCommandLine CLgCommandLine[0] = '\0'; - + // set argc to zero argc = 0; - + makeCommandLine(inArgc, inArgv); if (UUrString_Substring(CLgCommandLine, "-nodialog", CLgMaxCommandLineLength + 1)) { @@ -233,24 +233,24 @@ CLrPlatform_GetCommandLine( if (result == IDOK) { char parse_this[CLgMaxCommandLineLength + CLgMaxCommandLineLength + 1]; - + // clear the array UUrMemory_Clear( parse_this, CLgMaxCommandLineLength + CLgMaxCommandLineLength + 1); - + // copy the command line onto parse this UUrString_Cat(parse_this, CLgCommandLine, CLgMaxCommandLineLength + CLgMaxCommandLineLength + 1); - + // parse the command line argc = CLiParseArgs(parse_this); // copy the app_name to CLgArgV UUrString_Copy(CLgApplicationName, inArgv[0], MAX_APPLICATION_NAME); CLgArgV[0]= CLgApplicationName; - + *outArgV = CLgArgV; } - + return argc; } diff --git a/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_Win32/BFW_CL_Platform_Win32.h b/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_Win32/BFW_CL_Platform_Win32.h index 8b90628..8bc873f 100644 --- a/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_Win32/BFW_CL_Platform_Win32.h +++ b/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_Win32/BFW_CL_Platform_Win32.h @@ -19,4 +19,4 @@ CLrPlatform_GetCommandLine( char ***outArgV); // ====================================================================== -#endif /* BFW_CL_PLATFORM_WIN32_H */ \ No newline at end of file +#endif /* BFW_CL_PLATFORM_WIN32_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_Win32/BFW_CL_Resource.h b/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_Win32/BFW_CL_Resource.h index c0f5865..32a00f9 100644 --- a/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_Win32/BFW_CL_Resource.h +++ b/BungieFrameWork/BFW_Source/BFW_CommandLine/Platform_Win32/BFW_CL_Resource.h @@ -6,7 +6,7 @@ #define ID_EDIT1 1003 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 diff --git a/BungieFrameWork/BFW_Source/BFW_Console/BFW_Console.c b/BungieFrameWork/BFW_Source/BFW_Console/BFW_Console.c index 09e967a..abb0a66 100644 --- a/BungieFrameWork/BFW_Source/BFW_Console/BFW_Console.c +++ b/BungieFrameWork/BFW_Source/BFW_Console/BFW_Console.c @@ -88,7 +88,7 @@ typedef struct COtTextArea UUtUns16 num_text_entries; UUtUns16 max_text_entries; COtTextEntry *text_entries; // an array (num_text_entries long) of COtTextEntry - + } COtTextArea; typedef char COtCommandLine[COcMaxCharsPerLine]; @@ -212,7 +212,7 @@ COrTextArea_DiscardByPriority( static void COrTextArea_Display( COtTextArea *inTextArea); - + static void COrTextArea_Print( COtTextArea *inTextArea, @@ -222,7 +222,7 @@ COrTextArea_Print( const char *inString, const char *inIdentifier, UUtUns32 inFadeTime); - + static UUtBool COrTextArea_FadeByIdentifier( COtTextArea *inTextArea, @@ -290,7 +290,7 @@ COrProcessKeyRepeat( static void COrCommand_Complete( LItInputEvent *input_event); - + static void COrCommand_Copy( char *inCommandLine); @@ -302,7 +302,7 @@ COrCommand_CycleUp( static void COrCommand_CycleDown( void); - + // ====================================================================== // functions // ====================================================================== @@ -317,7 +317,7 @@ COiCommand_Print_Callback( SLtParameter_Actual *ioReturnValue) { UUtUns32 itr; - + for(itr = 0; itr < inParameterListLength; itr++) { switch(inParameterList[itr].type) @@ -325,20 +325,20 @@ COiCommand_Print_Callback( case SLcType_Int32: COrConsole_Printf("%d\n", inParameterList[itr].val.i); break; - + case SLcType_Float: COrConsole_Printf("%f\n", inParameterList[itr].val.f); break; - + case SLcType_String: COrConsole_Printf("%s\n", inParameterList[itr].val.str); break; - + default: UUmAssert(0); } } - + return UUcError_None; } @@ -366,13 +366,13 @@ COrRunConfigFile( BFtFileRef configFileRef; BFtTextFile* configFile; char* curLine; - + error = BFrFileRef_Search(inFilename, &configFileRef); if(error != UUcError_None) { return UUcFalse; } - + if(BFrFileRef_FileExists(&configFileRef) == UUcFalse) { return UUcFalse; @@ -383,7 +383,7 @@ COrRunConfigFile( { return UUcFalse; } - + while(1) { curLine = BFrTextFile_GetNextStr(configFile); @@ -401,9 +401,9 @@ COrRunConfigFile( COrCommand_Execute(curLine); } } - + BFrTextFile_Close(configFile); - + return UUcTrue; } @@ -461,37 +461,37 @@ COrInitialize( UUtError error; error; - + // set gInConsole COgInConsole = UUcFalse; - + // set initial values draw area width and height COgDrawAreaWidth = 0; COgDrawAreaHeight = 0; - + // register the console variables #if CONSOLE_DEBUGGING_COMMANDS - error = SLrGlobalVariable_Register_Int32(COcFadeTime_Name, "The fade time of the console", &COgFadeTimeValue); + error = SLrGlobalVariable_Register_Int32(COcFadeTime_Name, "The fade time of the console", &COgFadeTimeValue); UUmError_ReturnOnErrorMsg(error, "Unable to register console control variable"); SLrGlobalVariable_Register("co_priority", "changes the priority of messages to display on the console", SLcReadWrite_ReadWrite, SLcType_Int32, (SLtValue *) &COgPriority, COiVariableChanged_Priority); - error = SLrGlobalVariable_Register_Bool("co_display", "enables console display", &COgDisplayConsole); + error = SLrGlobalVariable_Register_Bool("co_display", "enables console display", &COgDisplayConsole); UUmError_ReturnOnErrorMsg(error, "Unable to register console control variable"); error = SLrGlobalVariable_Register_Bool("co_message_display", "enables text message display", &COgDisplayMessages); UUmError_ReturnOnErrorMsg(error, "Unable to register console control variable"); - + // register the console commands - error = + error = SLrScript_Command_Register_Void( "console_print", "dumps all arguments", "", COiCommand_Print_Callback); UUmError_ReturnOnErrorMsg(error, "Unable to create a new command."); - + error = SLrScript_Command_Register_Void( "co_toggle_text", @@ -520,7 +520,7 @@ COrTerminate( } COgInConsole = UUcFalse; - + // delete the text areas if (COgCommandLine) { COrTextArea_Delete(COgCommandLine); @@ -569,30 +569,30 @@ COrConfigure( UUtUns16 ui_width, ui_height, line_height; TStFontFamily *font_family; TStFont *default_font; - + // get the font family error = TSrFontFamily_Get( TScFontFamily_Default, &font_family); UUmError_ReturnOnErrorMsg(error, "Unable to get the font family."); - + // get the width and height of the draw area drawAreaWidth = M3rDraw_GetWidth(); drawAreaHeight = M3rDraw_GetHeight(); - + if ((drawAreaWidth <= 0) || (drawAreaHeight <= 0)) { char error_msg[128]= ""; - + sprintf(error_msg, "drawAreaWidth= %d drawAreaHeight= %d", drawAreaWidth, drawAreaHeight); UUmError_ReturnOnErrorMsg(UUcError_Generic, error_msg); } - + // store the draw area width and height COgDrawAreaWidth = drawAreaWidth; COgDrawAreaHeight = drawAreaHeight; - + // set the command line bounds bounds.left = 2; bounds.top = drawAreaHeight - 23; @@ -603,7 +603,7 @@ COrConfigure( error = M3rDrawEngine_FindGrayscalePixelType( &COgTexelType); UUmError_ReturnOnErrorMsg(error, "Unable to find a texel_type"); - + if (COgCommandLine == NULL) { // create the command area error = COrTextArea_New(&COgCommandLine, &bounds, IMrPixel_FromShade(COgTexelType, COcCommandLineColor), @@ -616,10 +616,10 @@ COrConfigure( error = COrTextArea_Resize(COgCommandLine, &bounds, 1); UUmError_ReturnOnErrorMsg(error, "Unable to resize the command line."); } - + // set the command line prefix COrTextArea_SetPrefix(COgCommandLine, "CMD: "); - + // set the console lines bounds COiVariableChanged_Priority(); @@ -641,7 +641,7 @@ COrConfigure( error = COrTextArea_Resize(COgConsoleLines, &COgConsoleBounds, -1); UUmError_ReturnOnErrorMsg(error, "Unable to resize the console area."); } - + // set the message area bounds so that there is room for the in-game UI. // currently the in-game UI is a fixed number of pixels, if this changes then // this calculation should be based on the draw area's size. @@ -663,7 +663,7 @@ COrConfigure( } else { bounds.top = 2; } - + if (COgMessageArea == NULL) { // create the message area @@ -727,11 +727,11 @@ COiCompletion_BuildList( void) { UUtUns32 numNames; - + SLrScript_ConsoleCompletionList_Get(&numNames, &COgCompletionNames); COgNumCompletionNames = (UUtUns16) numNames; - - AUrQSort_32(COgCompletionNames, COgNumCompletionNames, COiCompletiond_BuildList_Compare_Function); + + AUrQSort_32(COgCompletionNames, COgNumCompletionNames, COiCompletiond_BuildList_Compare_Function); } // ---------------------------------------------------------------------- @@ -741,17 +741,17 @@ COiCompletion_FindPartial( { UUtUns16 itr; UUtUns16 len; - + COiCompletion_BuildList(); - + len = strlen(inName); - + for (itr = 0; itr < COgNumCompletionNames; itr++) { if (strncmp(COgCompletionNames[itr], inName, len) == 0) return itr; } - + return 0xFFFF; } @@ -765,26 +765,26 @@ COiGetCurPrefix( commandline = COgCommandLine->text_entries[0].text; len = strlen(commandline); outCompletionBuffer[0] = '\0'; - + if (len == 0) return; - + cp = &commandline[len - 1]; - + while(len > 0) { c = *cp; - + if(c == '"') return; - + if(c == ' ' || c == ',' || c == '(' || c == '=') break; - + len--; cp--; } - + UUrString_Copy(outCompletionBuffer, cp+1, COcMaxCharsPerLine); - + } // ====================================================================== @@ -817,7 +817,7 @@ COrConsole_Deactivate( COgInputModeSwitchTime = COcInputModeSwitchTime; } } - + // ---------------------------------------------------------------------- void COrConsole_TemporaryDisable( @@ -900,7 +900,7 @@ COrConsole_Print( COgConsoleDebugFile = BFrDebugFile_Open("consoleLog.txt"); COgConsoleDebugFile_Checked = UUcTrue; } - + if (COgConsoleDebugFile != NULL) { BFrDebugFile_Printf(COgConsoleDebugFile, "%s"UUmNL, inString); } @@ -928,7 +928,7 @@ COrConsole_PrintIdentified( COgConsoleDebugFile = BFrDebugFile_Open("consoleLog.txt"); COgConsoleDebugFile_Checked = UUcTrue; } - + if (COgConsoleDebugFile != NULL) { BFrDebugFile_Printf(COgConsoleDebugFile, "%s"UUmNL, inString); } @@ -1043,10 +1043,10 @@ COrConsole_Update( UUtUns32 inTicksPassed) { LItInputEvent input_event; - + if (COgInputModeSwitchTime > 0) COgInputModeSwitchTime--; - + // set the input mode if necessary if (COgSetInputMode && (COgInputModeSwitchTime == 0)) { @@ -1080,27 +1080,27 @@ COrConsole_Update( { break; } - + // process the input event switch (input_event.type) { case LIcInputEvent_MouseMove: COrProcessMouseMove(&input_event); break; - + case LIcInputEvent_LMouseDown: COrProcessMouseDown(&input_event); break; - + case LIcInputEvent_LMouseUp: COrProcessMouseUp(&input_event); break; - + case LIcInputEvent_KeyDown: case LIcInputEvent_KeyRepeat: COrProcessKeyDown(&input_event); break; - + default: break; } @@ -1108,20 +1108,20 @@ COrConsole_Update( // update the command line COrTextArea_SetTimer(COgCommandLine, COgFadeTimeValue); - COrTextArea_Update(COgCommandLine, inTicksPassed, UUcTrue); + COrTextArea_Update(COgCommandLine, inTicksPassed, UUcTrue); } if (!COgConsoleTemporaryDisable) { // update the console text COrTextArea_Update(COgConsoleLines, inTicksPassed, UUcFalse); } - + if (!COgMessagesTemporaryDisable) { // update the message and in-game subtitle text COrTextArea_Update(COgMessageArea, inTicksPassed, UUcFalse); COrTextArea_Update(COgInGameSubtitleArea, inTicksPassed, UUcFalse); } - + return UUcError_None; } @@ -1147,7 +1147,7 @@ COrTextArea_New( UUtBool inFadeOverBounds) { COtTextArea *text_area; - + // allocate memory for the text area text_area = UUrMemory_Block_New(sizeof(COtTextArea)); UUmError_ReturnOnNull(text_area); @@ -1184,17 +1184,17 @@ COrTextArea_Delete( COtTextArea *inTextArea) { UUmAssert(inTextArea); - + // delete the text context if (inTextArea->text_context) { TSrContext_Delete(inTextArea->text_context); inTextArea->text_context = 0; } - + // delete the text_entries array UUrMemory_Block_Delete(inTextArea->text_entries); - + // release the memory used by the text area UUrMemory_Block_Delete(inTextArea); } @@ -1291,7 +1291,7 @@ static void COrTextArea_Display(COtTextArea *inTextArea) // determine how much vertical space this text requires, and where it should be placed text_height = (formatted_string.bounds[formatted_string.num_segments - 1].bottom - formatted_string.bounds[0].top) + 2; - + if (inTextArea->bottom_justify) { cur_y -= text_height; overflow = (cur_y < inTextArea->bounds.top); @@ -1326,20 +1326,20 @@ static void COrTextArea_Display(COtTextArea *inTextArea) offset.x = +1; offset.y = +1; TSrContext_DrawFormattedText(inTextArea->text_context, &formatted_string, alpha, &offset, &text_entry->text_shadow); TSrContext_DrawFormattedText(inTextArea->text_context, &formatted_string, alpha, NULL, NULL); - + if((inTextArea->display_completion) && (i == 0) && (COgCurCompletionNameIndex != 0xFFFF)) { UUtRect newBounds; IMtPoint2D newDest; - + // draw the greyed out part TSrContext_SetShade(inTextArea->text_context, IMcShade_Gray50); - + TSrContext_GetStringRect(inTextArea->text_context, text, &newBounds); newDest = dest; newDest.x += newBounds.right + 1; newDest.y += 1; - + COiGetCurPrefix(text); TSrContext_SetShade(inTextArea->text_context, COcTextShadow[COgTextColor]); @@ -1350,7 +1350,7 @@ static void COrTextArea_Display(COtTextArea *inTextArea) alpha, NULL, &newDest); - + newDest.x -= 1; newDest.y -= 1; TSrContext_SetShade(inTextArea->text_context, COcDimShades[COgTextColor]); @@ -1455,13 +1455,13 @@ COrTextArea_Resize( // calculate the width and height of the text area text_width = inTextArea->bounds.right - inTextArea->bounds.left; text_height = inTextArea->bounds.bottom - inTextArea->bounds.top; - + UUmAssert(text_width > 0); UUmAssert(text_height > 0); if (text_width > 512) text_width = 512; - + if (inNumTextEntries == -1) { // calculate how many text lines can be displayed line_height = @@ -1471,7 +1471,7 @@ COrTextArea_Resize( } else { max_text_entries = inNumTextEntries; } - + if (max_text_entries != inTextArea->max_text_entries) { if (inTextArea->text_entries == NULL) { // allocate memory for the text entries and clear it to zero @@ -1484,15 +1484,15 @@ COrTextArea_Resize( if (max_text_entries > inTextArea->max_text_entries) { // clear the new memory - UUrMemory_Clear(&inTextArea->text_entries[inTextArea->max_text_entries], + UUrMemory_Clear(&inTextArea->text_entries[inTextArea->max_text_entries], (max_text_entries - inTextArea->max_text_entries) * sizeof(COtTextEntry)); } } - + inTextArea->max_text_entries = max_text_entries; inTextArea->num_text_entries = UUmMin(inTextArea->num_text_entries, inTextArea->max_text_entries); } - + return UUcError_None; } @@ -1520,7 +1520,7 @@ COrTextArea_SetTimer( UUtUns32 inTimer) { UUtUns16 i; - + if (!inTextArea) return; @@ -1541,7 +1541,7 @@ COrTextArea_Update( UUtBool inDisplayCaret) { UUtUns16 i; - + for (i = 0; i < inTextArea->num_text_entries; i++) { if (inTextArea->text_entries[i].timer > 0) { if (inTextArea->text_entries[i].timer > inTicksPassed) { @@ -1654,21 +1654,21 @@ COrProcessKeyDown( key = (input_event->key & 0x00FF); commandline = COgCommandLine->text_entries[0].text; len = strlen(commandline); - + switch (key) { case LIcKeyCode_RightArrow: if(potentialNextIndex < COgNumCompletionNames) { potentialNextIndex += 1; - + if(strncmp(commandline, COgCompletionNames[potentialNextIndex], len) == 0) { COgCurCompletionNameIndex = potentialNextIndex; } } break; - + case LIcKeyCode_LeftArrow: if(potentialNextIndex > 1 && potentialNextIndex < COgNumCompletionNames) { @@ -1689,7 +1689,7 @@ COrProcessKeyDown( if(COgPerformCompletionOnTab) { COgPerformCompletionOnTab = UUcFalse; - + if(COgCurCompletionNameIndex >= COgNumCompletionNames) { COgCurCompletionNameIndex = UUcMaxUns16; @@ -1724,19 +1724,19 @@ COrProcessKeyDown( COgCurCompletionNameIndex = 0; } } - + UUmAssert(COgCurCompletionNameIndex < COgNumCompletionNames); - + UUrString_Copy(commandline, COgCompletionNames[COgCurCompletionNameIndex], COcMaxVarNameLength); } break; - + case LIcKeyCode_BackSpace: // backspace COgPerformCompletionOnTab = UUcTrue; commandline[len - 1] = '\0'; - + len--; - + if(len == 0) { COgCurCompletionNameIndex = 0xFFFF; @@ -1749,7 +1749,7 @@ COrProcessKeyDown( } } break; - + case LIcKeyCode_Return: // return - complete the current command COrCommand_Execute(commandline); break; @@ -1758,19 +1758,19 @@ COrProcessKeyDown( case LIcKeyCode_Escape: // escape COrConsole_Deactivate(); break; - + case LIcKeyCode_UpArrow: // up arrow COrCommand_CycleUp(); COgCurCompletionNameIndex = UUcMaxUns16; COgPerformCompletionOnTab = UUcFalse; break; - + case LIcKeyCode_DownArrow: // down arrow COrCommand_CycleDown(); COgCurCompletionNameIndex = UUcMaxUns16; COgPerformCompletionOnTab = UUcFalse; break; - + default: COgPerformCompletionOnTab = UUcTrue; if (len < COcCharsPerLine) { @@ -1821,14 +1821,14 @@ COrCommand_Execute( char *inCommandLine) { UUtBool success; - + if(inCommandLine[0] == '+') { if(COrRunConfigFile(inCommandLine + 1) == UUcTrue) { COrCommand_Copy(inCommandLine); } - + success = UUcTrue; } else @@ -1836,7 +1836,7 @@ COrCommand_Execute( // try a hook success = COiConsole_CallHook(inCommandLine); - if (success) + if (success) { // copy command to command list - only valid commands get copied COrCommand_Copy(inCommandLine); @@ -1844,7 +1844,7 @@ COrCommand_Execute( // clear the command line COgCommandLine->text_entries[0].text[0] = '\0'; } - } + } return success; } @@ -1865,11 +1865,11 @@ COrCommand_Copy( UUrString_Copy(COgRememberedCommands[itr-1], COgRememberedCommands[itr], COcMaxCharsPerLine); } } - + UUrString_Copy(COgRememberedCommands[COgRemComNum], inCommandLine, COcMaxCharsPerLine); - + COgRemComPos = COgRemComNum; - + if(COgRemComNum < COcMaxRememberedCommands) COgRemComNum++; } } @@ -1883,9 +1883,9 @@ COrCommand_CycleUp( { // copy the previous command COrTextArea_Print(COgCommandLine, COcPriority_Console, IMcShade_White, IMcShade_Black, COgRememberedCommands[COgRemComPos], NULL, 0); - + if(COgRemComPos > 0) COgRemComPos--; - + } } @@ -1896,7 +1896,7 @@ COrCommand_CycleDown( { if(COgRemComPos >= 0) { - if(COgRemComPos < COgRemComNum) + if(COgRemComPos < COgRemComNum) { COgRemComPos++; @@ -1923,7 +1923,7 @@ void UUcArglist_Call COrConsole_Printf(const char *format, ...) char buffer[2048]; va_list arglist; int return_value; - + va_start(arglist, format); return_value= vsprintf(buffer, format, arglist); va_end(arglist); @@ -1939,7 +1939,7 @@ void UUcArglist_Call COrConsole_Printf_Color(COtPriority inPriority, IMtShade in char buffer[2048]; va_list arglist; int return_value; - + va_start(arglist, format); return_value= vsprintf(buffer, format, arglist); va_end(arglist); @@ -1983,7 +1983,7 @@ static UUtBool COiConsole_CallHook(const char *inCommandLine) { UUtInt32 itr; UUtInt32 count = COgNumHooks; - + if (NULL == inCommandLine) { return UUcFalse; } @@ -1995,7 +1995,7 @@ static UUtBool COiConsole_CallHook(const char *inCommandLine) const char *prefix = COgHooks[itr].prefix; UUtUns32 refCon = COgHooks[itr].refCon; UUtBool handled = UUcFalse; - + if (UUrString_HasPrefix(inCommandLine, prefix)) { handled = COgHooks[itr].hook(prefix, refCon, inCommandLine); } @@ -2081,7 +2081,7 @@ void COrConsole_StatusLine_Display(void) M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_White); M3rDraw_State_SetInt(M3cDrawStateIntType_Alpha, 0x80); - + M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, ONgLetterboxTexture); for(current_line = COgStatusLines; current_line != NULL; current_line = current_line->next) @@ -2133,4 +2133,4 @@ void COrConsole_StatusLine_LevelEnd(void) } return; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Console/BFW_ConsoleVariable.h b/BungieFrameWork/BFW_Source/BFW_Console/BFW_ConsoleVariable.h index 6b71f87..ea3a14a 100644 --- a/BungieFrameWork/BFW_Source/BFW_Console/BFW_ConsoleVariable.h +++ b/BungieFrameWork/BFW_Source/BFW_Console/BFW_ConsoleVariable.h @@ -6,4 +6,4 @@ #error delete me -#endif /* BFW_CONSOLEVARIABLE_H */ \ No newline at end of file +#endif /* BFW_CONSOLEVARIABLE_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/BFW_DebuggerSymbols_MacOS.c b/BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/BFW_DebuggerSymbols_MacOS.c index 0057794..1c068ba 100644 --- a/BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/BFW_DebuggerSymbols_MacOS.c +++ b/BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/BFW_DebuggerSymbols_MacOS.c @@ -1,12 +1,12 @@ /* FILE: BFW_DebuggerSymbols_MacOS.c - + AUTHOR: Brent H. Pease - + CREATED: July 12, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -50,10 +50,10 @@ DSiSymFile_Create( char* xsymMemory; if(DSgHeaderBlock != NULL) return UUcError_None; - + error = BFrFileRef_MakeFromName(UUmDebuggerSymFileName, &xsymFileRef); UUmError_ReturnOnError(error); - + error = BFrFile_Open(xsymFileRef, "r", &xsymFile); UUmError_ReturnOnErrorMsg(error, UUmDebuggerSymFileName); @@ -62,32 +62,32 @@ DSiSymFile_Create( xsymMemory = malloc(xsymFileSize); UUmError_ReturnOnNull(xsymMemory); - + error = BFrFile_Read(xsymFile, xsymFileSize, xsymMemory); UUmError_ReturnOnError(error); - + DSgHeaderBlock = (DISK_SYMBOL_HEADER_BLOCK_v32*)xsymMemory; - + DSgPageSize = DSgHeaderBlock->dshb_page_size; - + DSgFRTE = (FILE_REFERENCE_TABLE_ENTRY_v32*)(xsymMemory + DSgHeaderBlock->dshb_frte.dti_first_page * DSgPageSize); DSgNTE = (NAME_TABLE_ENTRY*)(xsymMemory + DSgHeaderBlock->dshb_nte.dti_first_page * DSgPageSize); DSgRTE = (RESOURCE_TABLE_ENTRY_v32*)(xsymMemory + DSgHeaderBlock->dshb_rte.dti_first_page * DSgPageSize); DSgMTE = (MODULES_TABLE_ENTRY_v33*)(xsymMemory + DSgHeaderBlock->dshb_mte.dti_first_page * DSgPageSize); DSgFITE = (FRTE_INDEX_TABLE_ENTRY_v32*)(xsymMemory + DSgHeaderBlock->dshb_fite.dti_first_page * DSgPageSize); DSgCSNTE = (CONTAINED_STATEMENTS_TABLE_ENTRY_v32*)(xsymMemory + DSgHeaderBlock->dshb_csnte.dti_first_page * DSgPageSize); - + DSgMTE_EntriesPerPage = DSgPageSize / sizeof(MODULES_TABLE_ENTRY_v33); DSgMTE_Offset = DSgPageSize % sizeof(MODULES_TABLE_ENTRY_v33); DSgCSNTE_EntriesPerPage = DSgPageSize / sizeof(CONTAINED_STATEMENTS_TABLE_ENTRY_v32); DSgCSNTE_Offset = DSgPageSize % sizeof(CONTAINED_STATEMENTS_TABLE_ENTRY_v32); DSgFRTE_EntriesPerPage = DSgPageSize / sizeof(FILE_REFERENCE_TABLE_ENTRY_v32); DSgFRTE_Offset = DSgPageSize % sizeof(FILE_REFERENCE_TABLE_ENTRY_v32); - + BFrFile_Close(xsymFile); - + BFrFileRef_Dispose(xsymFileRef); - + return UUcError_None; } @@ -116,24 +116,24 @@ DSiSymTable_MTE_FindFromRTEAndResourceOffset( RESOURCE_TABLE_ENTRY_v32* targetRTE; MODULES_TABLE_ENTRY_v33* curMTE; UUtUns32 curIndex; - + targetRTE = DSgRTE + inRTEIndex; - + for(curIndex = targetRTE->rte_mte_first; curIndex < targetRTE->rte_mte_last; curIndex++) - { + { curMTE = DSmMTE_PointerFromIndex(curIndex); - + UUmAssert(curMTE->mte_rte_index == 1); - - if(inResourceOffset >= curMTE->mte_res_offset && + + if(inResourceOffset >= curMTE->mte_res_offset && inResourceOffset < curMTE->mte_res_offset + curMTE->mte_size) { return curIndex; } } - + return NULL; } @@ -153,28 +153,28 @@ DSiSymTable_CSNTE_FindFromMTEAndResourceOffset( UUtBool foundChange = UUcFalse; UUtUns32 curFilePos = 0; UUtUns32 returnFilePos = 0; - + targetMTE = DSmMTE_PointerFromIndex(inMTEIndex); - + mteRelativeOffset = inResourceOffset - targetMTE->mte_res_offset; - + for(curIndex = targetMTE->mte_csnte_idx_1; curIndex < targetMTE->mte_csnte_idx_2; curIndex++) { curCSNTE = DSmCSNTE_PointerFromIndex(curIndex); - + if(curCSNTE->csnte_file_.change == SOURCE_FILE_CHANGE_v32) { UUmAssert(foundChange == UUcFalse); foundChange = UUcTrue; continue; } - + UUmAssert(curCSNTE->csnte_.mte_index == inMTEIndex); - + curFilePos += curCSNTE->csnte_.file_delta; - + offsetDistance = fabs((UUtInt32)curCSNTE->csnte_.mte_offset - mteRelativeOffset); if(offsetDistance < minOffsetDistance) { @@ -183,9 +183,9 @@ DSiSymTable_CSNTE_FindFromMTEAndResourceOffset( csnteIndex = curIndex; } } - + *outMTERelativeSourcePos = returnFilePos; - + return csnteIndex; } @@ -196,11 +196,11 @@ DSiMTE_GetFunctionName( { MODULES_TABLE_ENTRY_v33* mte; unsigned char* pString; - + mte = DSmMTE_PointerFromIndex(inMTEIndex); - + pString = (unsigned char*)(DSgNTE + mte->mte_nte_index); - + UUrString_PStr2CStr(pString, outFunctionName, DScNameBufferSize); } @@ -212,15 +212,15 @@ DSiMTE_GetFileName( MODULES_TABLE_ENTRY_v33* mte; FILE_REFERENCE_TABLE_ENTRY_v32* frte; unsigned char* pString; - + mte = DSmMTE_PointerFromIndex(inMTEIndex); - + frte = DSmFRTE_PointerFromIndex(mte->mte_imp_fref.fref_frte_index); - + UUmAssert(frte->frte_file_.name_entry == FILE_NAME_INDEX_v32); pString = (unsigned char*)(DSgNTE + frte->frte_file_.nte_index); - + UUrString_PStr2CStr(pString, outFileName, DScNameBufferSize); } @@ -237,25 +237,25 @@ DSiSourceFile_GetLineFromOffset( UUtUns32 curLineNum; char* cp; char c; - + error = BFrFileRef_MakeFromName(inFileName, &fileRef); if(error != UUcError_None) return UUcMaxUns32; - + error = BFrFileRef_LoadIntoMemory(fileRef, &fileSize, &fileMemory); if(error != UUcError_None) return UUcMaxUns32; BFrFileRef_Dispose(fileRef); - + cp = fileMemory; curLineNum = 0; curFilePos = 0; - + for(;;) { if(curFilePos >= fileSize || curFilePos >= inFileOffset) break; c = *cp; - + if(c == '\n') { curLineNum++; @@ -266,13 +266,13 @@ DSiSourceFile_GetLineFromOffset( curLineNum++; if(cp[1] == '\n') cp++; } - + cp++; curFilePos++; } - + UUrMemory_Block_Delete(fileMemory); - + return curLineNum; } @@ -308,47 +308,47 @@ DSrProgramCounter_GetFileAndLine( #if defined(DEBUGGING) && (DEBUGGING) MODULES_TABLE_ENTRY_v33* mte; CONTAINED_STATEMENTS_TABLE_ENTRY_v32* csnte; - + UUtUns32 resourceOffset; extern UUtUns32 __code_start__[]; // generated by the linker UUtUns32 code_start; - + UUtUns32 mteIndex; UUtUns32 csnteIndex; UUtUns32 mteRelativeSourcePos; - + UUtUns32 line; - + if(DSgHeaderBlock == NULL) return UUcError_Generic; - + code_start = (UUtUns32)__code_start__; - + resourceOffset = inProgramCounter - code_start; - + mteIndex = DSiSymTable_MTE_FindFromRTEAndResourceOffset( 1, resourceOffset); - + csnteIndex = DSiSymTable_CSNTE_FindFromMTEAndResourceOffset( mteIndex, resourceOffset, &mteRelativeSourcePos); - + mte = DSmMTE_PointerFromIndex(mteIndex); csnte = DSmCSNTE_PointerFromIndex(csnteIndex); - + DSiMTE_GetFunctionName(mteIndex, outFunctionName); DSiMTE_GetFileName(mteIndex, outFile); line = DSiSourceFile_GetLineFromOffset(outFile, mte->mte_imp_fref.fref_offset + mteRelativeSourcePos); - + *outLine = line; #else strcpy(outFile, ""); *outLine = 0; #endif - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/BFW_DebuggerSymbols_Win32.c b/BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/BFW_DebuggerSymbols_Win32.c index 0f4a24a..4cd4d53 100644 --- a/BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/BFW_DebuggerSymbols_Win32.c +++ b/BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/BFW_DebuggerSymbols_Win32.c @@ -1,12 +1,12 @@ /* FILE: BFW_DebuggerSymbols_Win32.c - + AUTHOR: Brent H. Pease - + CREATED: July 12, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -34,6 +34,6 @@ DSrProgramCounter_GetFileAndLine( char *outFunctionName, UUtUns32 *outLine) { - + return UUcError_Generic; } diff --git a/BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/stack_walk_windows.c b/BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/stack_walk_windows.c index dd5adf0..556fd7a 100644 --- a/BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/stack_walk_windows.c +++ b/BungieFrameWork/BFW_Source/BFW_DebuggerSymbols/stack_walk_windows.c @@ -88,7 +88,7 @@ void stack_walk_initialize( memset(&stack_walk_input, 0, sizeof(stack_walk_input)); UUrStartupMessage("stack crawl generation code enabled"); stack_walk_initalized= TRUE; - + return; } @@ -114,7 +114,7 @@ void stack_walk( { HANDLE sw_thread; DWORD thread_id; - + sw_thread= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)stack_walk_thread_proc, &in, 0, &thread_id); if (sw_thread) @@ -173,7 +173,7 @@ void stack_walk_with_context( { HANDLE sw_thread; DWORD thread_id; - + sw_thread= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)stack_walk_thread_proc, &stack_walk_input, 0, &thread_id); if (sw_thread) @@ -211,7 +211,7 @@ void stack_walk_with_context( int handle_exception( LPEXCEPTION_POINTERS exception_data) -{ +{ int ret= EXCEPTION_CONTINUE_SEARCH; if (exception_data) @@ -261,7 +261,7 @@ static void stack_walk_thread_proc( { DWORD opts= SymGetOptions(); boolean success= FALSE; - + opts|= (SYMOPT_UNDNAME|SYMOPT_DEFERRED_LOADS); SymSetOptions(opts); @@ -301,7 +301,7 @@ static void stack_walk_thread_proc( // Initialize the stack_frame structure for the first call. This is only // necessary for Intel CPUs, and isn't mentioned in the documentation. UUrDebuggerMessage("starting stack trace"); - + memset(&stack_frame, 0, sizeof(stack_frame)); stack_frame.AddrPC.Offset= context.Eip; stack_frame.AddrPC.Mode= AddrModeFlat; @@ -311,7 +311,7 @@ static void stack_walk_thread_proc( stack_frame.AddrFrame.Mode= AddrModeFlat; for (frame_num = 0; frame_num < MAX_FRAMES; ++frame_num) - { + { BYTE symbol_buffer[sizeof(IMAGEHLP_SYMBOL)+MAXIMUM_SYMBOL_NAME_LENGTH]= {0}; PIMAGEHLP_SYMBOL p_symbol= (PIMAGEHLP_SYMBOL)symbol_buffer; IMAGEHLP_MODULE module; @@ -382,7 +382,7 @@ static void stack_walk_thread_proc( DWORD section= 0, offset= 0, sgsfa_error; sgsfa_error= GetLastError(); - + get_logical_address((PVOID)(stack_frame.AddrPC.Offset), module, MAX_PATH, §ion, &offset); sprintf(formatted_address[frame_num], "%08x %s+%04x [SymGetSymFromAddr() returned %ld]", section, module, offset, sgsfa_error); @@ -409,7 +409,7 @@ static void stack_walk_thread_proc( while (i>=stack_walk_input.levels_to_ignore) { unsigned long addr= strtoul(formatted_address[i], NULL, 16); - + UUrDebuggerMessage("%d: %s %s", j, formatted_address[i], (symbol_list ? symbol_name_from_address(addr, symbol_list, num_symbols) : "")); checksum^= addr; @@ -418,7 +418,7 @@ static void stack_walk_thread_proc( } if (symbol_list) free(symbol_list); - + UUrDebuggerMessage("end of stack trace : stack trace checksum= 0x%lX", checksum); } } @@ -443,7 +443,7 @@ static void stack_walk_thread_proc( } static boolean get_logical_address( - void *addr, + void *addr, char *module, long length, long *section, @@ -504,7 +504,7 @@ static SymbolPtr parse_map_file( else { char line[MAX_LINE_LENGTH]= ""; - + // display filename if (fgets(line, MAX_LINE_LENGTH, file_ptr)) { @@ -540,7 +540,7 @@ static SymbolPtr parse_map_file( symbol_list = (SymbolPtr)calloc(MAX_NUMBER_OF_SYMBOLS, sizeof(Symbol)); if (!symbol_list) goto DONE; - + // build the symbol list for (i=0;inum_child_views; i++) { VMtView *child = inDialog->child_views[i].view_ref; - + // do the child's flags match the desired flags if ((child->flags & desired_flags) == desired_flags) { @@ -116,7 +116,7 @@ DMiDialog_FindViewToFocus( } } } - + return found_view; } @@ -130,11 +130,11 @@ DMiDialog_HandleKeyEvent( DMtMessage message; UUtUns32 param1; UUtUns32 param2; - + // set param1 and param2 param1 = (UUtUns32)inInputEvent->key; param2 = 0; - + // set the message switch (inInputEvent->type) { @@ -142,16 +142,16 @@ DMiDialog_HandleKeyEvent( case LIcInputEvent_KeyRepeat: message = VMcMessage_KeyDown; break; - + case LIcInputEvent_KeyUp: message = VMcMessage_KeyUp; break; } - + // send a message to the focused view VMrView_SendMessage(inDialog, message, param1, param2); } - + // ---------------------------------------------------------------------- static void DMiDialog_HandleMouseEvent( @@ -166,12 +166,12 @@ DMiDialog_HandleMouseEvent( DMtMouseEventMap *event_map; UUtUns16 flags; - + message = VMcMessage_None; - + // record the cursor position for the cursor drawing to happen later inPrivateData->cursor_position = inInputEvent->where; - + // set the flags to test the control against for (event_map = DMgMouseEventMap; event_map->view_message != VMcMessage_None; @@ -184,11 +184,11 @@ DMiDialog_HandleMouseEvent( break; } } - + // set param1 and param2 param1 = UUmMakeLong(inInputEvent->where.x, inInputEvent->where.y); - param2 = inInputEvent->modifiers; - + param2 = inInputEvent->modifiers; + // set the view to send mouse messages to if (inPrivateData->mouse_focus_view) { @@ -199,10 +199,10 @@ DMiDialog_HandleMouseEvent( // get the view the mouse is currently over view = VMrView_GetViewUnderPoint(inDialog, &inInputEvent->where, flags); } - + // don't send messages to nothing if (view == NULL) return; - + // check for double clicks if ((message == VMcMessage_LMouseUp) || (message == VMcMessage_MMouseUp) || @@ -210,13 +210,13 @@ DMiDialog_HandleMouseEvent( { UUtUns32 time; float distance; - + time = UUrMachineTime_Sixtieths(); distance = IMrPoint2D_Distance( &inPrivateData->mouse_clicked_point, &inInputEvent->where); - + if ((inPrivateData->mouse_clicked_view == view) && (inPrivateData->mouse_clicked_type == message) && (time < (inPrivateData->mouse_clicked_time + DMcDoubleClickDelta)) && @@ -228,7 +228,7 @@ DMiDialog_HandleMouseEvent( message = VMcMessage_MMouseDblClck; else if (message == VMcMessage_RMouseUp) message = VMcMessage_RMouseDblClck; - + // clear the info inPrivateData->mouse_clicked_view = NULL; inPrivateData->mouse_clicked_time = 0; @@ -243,10 +243,10 @@ DMiDialog_HandleMouseEvent( inPrivateData->mouse_clicked_point = inInputEvent->where; } } - + // send a message to the view VMrView_SendMessage(view, message, param1, param2); - + // send a mouse up message if message is a double clicked message if ((message == VMcMessage_LMouseDblClck) || (message == VMcMessage_MMouseDblClck) || @@ -258,10 +258,10 @@ DMiDialog_HandleMouseEvent( message = VMcMessage_MMouseUp; else if (message == VMcMessage_RMouseDblClck) message = VMcMessage_RMouseUp; - + VMrView_SendMessage(view, message, param1, param2); } - + // send appropriate mouse_leave messages if (inPrivateData->mouse_over_view != view) { @@ -274,7 +274,7 @@ DMiDialog_HandleMouseEvent( 0, 0); } - + // save the new mouse_over_view inPrivateData->mouse_over_view = view; } @@ -292,9 +292,9 @@ DMiDialog_Load( DMtDialogList *dialog_list; UUmAssert(TMrInstance_GetTagCount(DMcTemplate_DialogList) == 1); - + *outDialog = NULL; - + // load the dialog list error = TMrInstance_GetDataPtr( @@ -302,28 +302,28 @@ DMiDialog_Load( "dialoglist", &dialog_list); UUmError_ReturnOnError(error); - + for (i = 0; i < dialog_list->num_dialogs; i++) { DMtDialog *dialog; - + dialog = (DMtDialog*)dialog_list->dialogs[i].dialog_ref; - + if (dialog->id == inDialogID) { error = VMrView_Load(dialog, inParent); UUmError_ReturnOnError(error); - + *outDialog = dialog; break; } } - + if (*outDialog == NULL) return UUcError_Generic; - + return UUcError_None; } - + // ====================================================================== #if 0 #pragma mark - @@ -335,20 +335,20 @@ DMiDialog_MessageBox_Initialize( DMtDialog *inDialog) { VMtView *child; - + if ((ONgMessageBox_Flags == DMcMBFlag_None) || (ONgMessageBox_Flags & DMcMBFlag_Ok) == DMcMBFlag_Ok) { child = DMrDialog_GetViewByID(inDialog, DMcMB_Ok); VMrView_SetVisible(child, UUcTrue); } - + if ((ONgMessageBox_Flags & DMcMBFlag_OkCancel) == DMcMBFlag_OkCancel) { child = DMrDialog_GetViewByID(inDialog, DMcMB_Cancel); VMrView_SetVisible(child, UUcTrue); } - + child = DMrDialog_GetViewByID(inDialog, DMcMB_Title); VMrView_SetValue(child, (UUtUns32)ONgMessageBox_Title); @@ -378,22 +378,22 @@ DMiDialog_MessageBox_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case DMcMessage_InitDialog: DMiDialog_MessageBox_Initialize(inDialog); break; - + case VMcMessage_Command: DMiDialog_MessageBox_HandleCommand( inDialog, (UUtUns16)UUmHighWord(inParam1), (UUtUns16)UUmLowWord(inParam1)); break; - + case VMcMessage_KeyDown: if (inParam1 == LIcKeyCode_Return) { @@ -402,7 +402,7 @@ DMiDialog_MessageBox_Callback( else if (inParam1 == LIcKeyCode_Escape) { VMtView *cancel; - + // if the cancel button is visible, then escape returns // cancel, otherwise it returns ok cancel = DMrDialog_GetViewByID(inDialog, DMcMB_Cancel); @@ -416,12 +416,12 @@ DMiDialog_MessageBox_Callback( } } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -440,14 +440,14 @@ DMrDialog_ActivateTab( DMtDialogData_PrivateData *private_data; VMtView *tab_group; UUtUns16 i; - + UUmAssert(inDialog); - + // get a pointer to the dialog data dialog_data = (DMtDialogData*)inDialog->view_data; private_data = (DMtDialogData_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Dialog_PrivateData, dialog_data); UUmAssert(private_data); - + // find the tab group of the dialog tab_group = NULL; for (i = 0; i < inDialog->num_child_views; i++) @@ -461,7 +461,7 @@ DMrDialog_ActivateTab( } } if (tab_group == NULL) return; - + // enable the desired tab VMrView_TabGroup_ActivateTab(tab_group, inTabID); } @@ -474,7 +474,7 @@ DMrDialog_Display( M3tPointScreen dest; DMtDialogData *dialog_data; DMtDialogData_PrivateData *private_data; - + UUmAssert(inDialog); M3rDraw_State_Push(); @@ -486,15 +486,15 @@ DMrDialog_Display( dest.y = (float)inDialog->location.y; dest.z = DMcDialogLayer; dest.invW = 1 / dest.z; - + // draw the view VMrView_Draw(inDialog, &dest); - + // get a pointer to the dialog data dialog_data = (DMtDialogData*)inDialog->view_data; private_data = (DMtDialogData_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Dialog_PrivateData, dialog_data); UUmAssert(private_data); - + // draw the cursor if (dialog_data->flags & DMcDialogFlag_ShowCursor) { @@ -516,9 +516,9 @@ DMrDialog_GetParentDialog( { DMtDialog *dialog; VMtView *parent; - + UUmAssert(inView); - + // set the dialog dialog = NULL; @@ -532,7 +532,7 @@ DMrDialog_GetParentDialog( dialog = parent; break; } - + // get the parent of the parent parent = VMrView_GetParent(parent); } @@ -548,16 +548,16 @@ DMrDialog_GetViewByID( { VMtView *found_view; UUtUns16 i; - + UUmAssert(inDialog); - + found_view = NULL; - - // go through the child views looking for one with this + + // go through the child views looking for one with this for (i = 0; i < inDialog->num_child_views; i++) { VMtView *child = (VMtView*)inDialog->child_views[i].view_ref; - + if (child->id == inViewID) { found_view = child; @@ -568,7 +568,7 @@ DMrDialog_GetViewByID( } if (found_view) break; } - + return found_view; } @@ -579,14 +579,14 @@ DMrDialog_IsActive( { DMtDialogData *dialog_data; DMtDialogData_PrivateData *private_data; - + UUmAssert(inDialog); // get a pointer to the dialog data dialog_data = (DMtDialogData*)inDialog->view_data; private_data = (DMtDialogData_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Dialog_PrivateData, dialog_data); UUmAssert(private_data); - + return !private_data->quit_dialog; } @@ -600,11 +600,11 @@ DMrDialog_MessageBox( { UUtError error; UUtUns32 message; - + ONgMessageBox_Title = inTitle; ONgMessageBox_Message = inMessage; ONgMessageBox_Flags = inFlags; - + error = DMrDialog_Run( DMcDialog_MessageBox, @@ -612,7 +612,7 @@ DMrDialog_MessageBox( inParent, &message); if (error != UUcError_None) return 0; - + return message; } @@ -635,35 +635,35 @@ DMrDialog_Load( UUtUns16 screen_width; UUtUns16 screen_height; IMtPoint2D loc; - + UUmAssert(outDialog); - + // load the view error = DMiDialog_Load(inDialogID, inParent, &dialog); UUmError_ReturnOnErrorMsg(error, "Unable to load the dialog"); - + // set the location of the dialog M3rManager_GetActiveDrawEngine( &activeDrawEngine, &activeDevice, &activeMode); - + drawEngineCaps = M3rDrawEngine_GetCaps(activeDrawEngine); - + screen_width = drawEngineCaps->displayDevices[activeDevice].displayModes[activeMode].width; screen_height = drawEngineCaps->displayDevices[activeDevice].displayModes[activeMode].height; - + UUmAssert(screen_width > 0); UUmAssert(screen_height > 0); - + loc.x = (screen_width - dialog->width) >> 1; loc.y = (screen_height - dialog->height) >> 1; - + if(loc.x < 0) loc.x = 0; if(loc.y < 0) loc.y = 0; VMrView_SetLocation(dialog, &loc); - + // get the dialog data dialog_data = (DMtDialogData*)dialog->view_data; private_data = (DMtDialogData_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Dialog_PrivateData, dialog_data); @@ -681,31 +681,31 @@ DMrDialog_Load( private_data->mouse_clicked_time = 0; private_data->mouse_clicked_type = VMcMessage_None; private_data->prev_localinput_mode = LIrMode_Get(); - + // set the input to normal LIrMode_Set(LIcMode_Normal); - + // load the cursor if necessary if (dialog_data->flags & DMcDialogFlag_ShowCursor) { LItInputEvent event; - + // load the cursor error = DCrCursor_Load(DCcCursorType_Arrow, &private_data->cursor); UUmError_ReturnOnErrorMsg(error, "Unable to laod the cursor"); - + // set the cursor position LIrInputEvent_GetMouse(&event); private_data->cursor_position = event.where; } - + // tell the dialog to initialize itself if (inDialogCallback) { UUtBool result; - + result = inDialogCallback(dialog, DMcMessage_InitDialog, 0, 0); - + // if the dialog returns UUcTrue, that means it set which // view it wants to be the focus if (result == UUcFalse) @@ -713,10 +713,10 @@ DMrDialog_Load( DMrDialog_SetFocus(dialog, NULL); } } - + // set outDialog *outDialog = dialog; - + return UUcError_None; } @@ -727,26 +727,26 @@ DMrDialog_ReleaseMouseFocusView( VMtView *inView) { DMtDialog *dialog; - + UUmAssert(inView); - + // set dialog if (inDialog) dialog = inDialog; else - dialog = DMrDialog_GetParentDialog(inView); - + dialog = DMrDialog_GetParentDialog(inView); + // clear the mouse focus if (dialog) { DMtDialogData *dialog_data; DMtDialogData_PrivateData *private_data; - + // get a pointer to the dialog data dialog_data = (DMtDialogData*)dialog->view_data; private_data = (DMtDialogData_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Dialog_PrivateData, dialog_data); UUmAssert(private_data); - + private_data->mouse_focus_view = NULL; } } @@ -763,11 +763,11 @@ DMrDialog_Run( DMtDialog *dialog; DMtDialogData *dialog_data; DMtDialogData_PrivateData *private_data; - + UUmAssert(outMessage); *outMessage = 0; - + // load the dialog error = DMrDialog_Load( @@ -776,12 +776,12 @@ DMrDialog_Run( inParent, &dialog); UUmError_ReturnOnErrorMsg(error, "Unable to load the dialog"); - + // get the dialog data dialog_data = (DMtDialogData*)dialog->view_data; private_data = (DMtDialogData_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Dialog_PrivateData, dialog_data); UUmAssert(private_data); - + // event loop while (!private_data->quit_dialog) { @@ -793,10 +793,10 @@ DMrDialog_Run( // update the dialog DMrDialog_Update(dialog); } - + // set the output message *outMessage = private_data->out_message; - + return UUcError_None; } @@ -809,20 +809,20 @@ DMrDialog_SetFocus( DMtDialogData *dialog_data; DMtDialogData_PrivateData *private_data; VMtView *view; - + UUmAssert(inDialog); - + // get the dialog data dialog_data = (DMtDialogData*)inDialog->view_data; private_data = (DMtDialogData_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Dialog_PrivateData, dialog_data); UUmAssert(private_data); - + // find the view to focus if (inView) view = inView; else view = VMrView_GetNextFocusableView(inDialog, private_data->text_focus_view); - + // don't refocus on the same view if (view != private_data->text_focus_view) { @@ -831,13 +831,13 @@ DMrDialog_SetFocus( { VMrView_SetFocus(private_data->text_focus_view, UUcFalse); } - + // set the found view's focus to true if (view) { VMrView_SetFocus(view, UUcTrue); } - + // set the focused view private_data->text_focus_view = view; } @@ -850,26 +850,26 @@ DMrDialog_SetMouseFocusView( VMtView *inView) { DMtDialog *dialog; - + UUmAssert(inView); - + // set dialog if (inDialog) dialog = inDialog; else - dialog = DMrDialog_GetParentDialog(inView); - + dialog = DMrDialog_GetParentDialog(inView); + // set the mouse focus if (dialog) { DMtDialogData *dialog_data; DMtDialogData_PrivateData *private_data; - + // get a pointer to the dialog data dialog_data = (DMtDialogData*)dialog->view_data; private_data = (DMtDialogData_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Dialog_PrivateData, dialog_data); UUmAssert(private_data); - + private_data->mouse_focus_view = inView; } } @@ -882,14 +882,14 @@ DMrDialog_Stop( { DMtDialogData *dialog_data; DMtDialogData_PrivateData *private_data; - + UUmAssert(inDialog); // get the dialog data dialog_data = (DMtDialogData*)inDialog->view_data; private_data = (DMtDialogData_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Dialog_PrivateData, dialog_data); UUmAssert(private_data); - + // set the variables private_data->quit_dialog = UUcTrue; private_data->out_message = inMessage; @@ -904,14 +904,14 @@ DMrDialog_Update( LItInputEvent input_event; DMtDialogData *dialog_data; DMtDialogData_PrivateData *private_data; - + UUmAssert(inDialog); - + // get the dialog data dialog_data = (DMtDialogData*)inDialog->view_data; private_data = (DMtDialogData_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Dialog_PrivateData, dialog_data); UUmAssert(private_data); - + // update the timer VMrView_Timer_Update(inDialog); @@ -919,7 +919,7 @@ DMrDialog_Update( for (i = 0; i < DMcMaxEventsPerUpdate; i++) { UUtBool event_avail; - + // get an event from the input context event_avail = LIrInputEvent_Get( @@ -938,7 +938,7 @@ DMrDialog_Update( case LIcInputEvent_RMouseUp: DMiDialog_HandleMouseEvent(inDialog, private_data, &input_event); break; - + case LIcInputEvent_KeyDown: case LIcInputEvent_KeyRepeat: DMiDialog_HandleKeyEvent(inDialog, private_data, &input_event); @@ -950,20 +950,20 @@ DMrDialog_Update( // no input events are available, exit input event processing break; } - + // if the dialog was closed, then exit the loop if (private_data->quit_dialog) break; } - + // reset the input context on closed dialogs if (private_data->quit_dialog) { VMtView_PrivateData *view_private_data; - + // get a pointer the the view's private data view_private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inDialog); if (view_private_data == NULL) return; - + // clean up if (view_private_data->parent == NULL) { @@ -974,7 +974,7 @@ DMrDialog_Update( { // get the current position of the mouse LIrInputEvent_GetMouse(&input_event); - + // update the parent VMrView_SendMessage( view_private_data->parent, @@ -999,28 +999,28 @@ DMrInitialize( void) { UUtError error; - + // register the templates error = DMVMrRegisterTemplates(); UUmError_ReturnOnError(error); - + // initialize the cursor error = DCrInitialize(); UUmError_ReturnOnError(error); - + // initialize the view manager error = VMrInitialize(); UUmError_ReturnOnError(error); - + // install the private data and/or procs - error = + error = TMrTemplate_PrivateData_New( DMcTemplate_DialogData, sizeof(DMtDialogData_PrivateData), DMrDialogData_ProcHandler, &DMgTemplate_Dialog_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install dialog proc handler"); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/BFW_ViewManager.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/BFW_ViewManager.c index 3ab7fa7..e9c1b25 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/BFW_ViewManager.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/BFW_ViewManager.c @@ -51,18 +51,18 @@ VMiView_Create( UUtUns16 i; UUtBool result; VMtView_PrivateData *private_data; - + // get the private data of the view private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(private_data); - + // set the view's parent private_data->parent = inParent; private_data->layer = inLayer; - + // tell this view that it was created result = (UUtBool)VMrView_SendMessage(inView, VMcMessage_Create, 0, 0); - + // load the child views for (i = 0; i < inView->num_child_views; i++) { @@ -71,7 +71,7 @@ VMiView_Create( inView, inLayer + 1); } - + return result; } @@ -81,13 +81,13 @@ VMiView_Destory( VMtView *inView) { UUtUns16 i; - + VMrView_SendMessage(inView, VMcMessage_Destroy, 0, 0); for (i = 0; i < inView->num_child_views; i++) { VMtView *child = (VMtView*)inView->child_views[i].view_ref; - + VMiView_Destory(child); } } @@ -98,7 +98,7 @@ VMiView_IsGroup( VMtView *inView) { UUtBool is_group; - + is_group = UUcFalse; switch (inView->type) { @@ -108,7 +108,7 @@ VMiView_IsGroup( is_group = UUcTrue; break; } - + return is_group; } @@ -126,31 +126,31 @@ VMiView_GetViewUnderPoint( VMtView *found_view; UUtUns16 deepest_layer; UUtBool view_found; - + UUmAssert(inView); - + // get the data private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(private_data); - + // initalize the data found_view = NULL; deepest_layer = 0; view_found = UUcFalse; - + // initialize the bounds_rect bounds_rect.left = inView->location.x; bounds_rect.top = inView->location.y; bounds_rect.right = bounds_rect.left + inView->width; bounds_rect.bottom = bounds_rect.top + inView->height; - + // check to see if the point is in the bounds of the view if (IMrRect_PointIn(&bounds_rect, inPoint) || VMiView_IsGroup(inView)) { UUtUns16 i; IMtPoint2D new_point; - + // make sure the flags match if (((inView->flags & inFlags) == inFlags) && !VMiView_IsGroup(inView)) @@ -160,12 +160,12 @@ VMiView_GetViewUnderPoint( deepest_layer = private_data->layer; view_found = UUcTrue; } - + // calculate a parent relative point new_point = *inPoint; new_point.x -= inView->location.x; new_point.y -= inView->location.y; - + // search the child views for (i = 0; i < inView->num_child_views; i++) { @@ -173,10 +173,10 @@ VMiView_GetViewUnderPoint( UUtBool result; VMtView *out_view; UUtUns16 out_layer; - + // don't look in views that aren't visible if (!(child->flags & VMcViewFlag_Visible)) continue; - + // is the point in the child view? result = VMiView_GetViewUnderPoint( @@ -199,7 +199,7 @@ VMiView_GetViewUnderPoint( } } } - + // set the outgoing data *outView = found_view; *outLayer = deepest_layer; @@ -221,11 +221,11 @@ VMrView_DefaultCallback( { VMtView_PrivateData *private_data; UUtUns16 i; - + // get a pointer to the private data private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(private_data); - + // handle the message switch (inMessage) { @@ -235,26 +235,26 @@ VMrView_DefaultCallback( // tell the child view to draw destination = (M3tPointScreen*)inParam2; - + // draw the child windows for (i = 0; i < inView->num_child_views; i++) { VMtView *child_view; M3tPointScreen dest; - + // get a pointer to the child view child_view = inView->child_views[i].view_ref; - + dest = *destination; dest.x += (float)child_view->location.x; dest.y += (float)child_view->location.y; - + VMrView_Draw(child_view, &dest); } } break; } - + return 0; } @@ -272,9 +272,9 @@ VMrView_Timer_Start( { VMtView_PrivateData *private_data; VMtViewTimer *timer; - + UUmAssert(inView); - + // get the private data of the view private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(private_data); @@ -288,20 +288,20 @@ VMrView_Timer_Start( return UUcError_Generic; } } - + // create a new timer timer = (VMtViewTimer*)UUrMemory_Block_New(sizeof(VMtViewTimer)); UUmError_ReturnOnNull(timer); - + // initialize the timer timer->next = private_data->timers; timer->timer_id = inTimerID; timer->timer_frequency = inTimerFrequency; timer->next_update = 0; - + // add the timer to the list private_data->timers = timer; - + return UUcError_None; } @@ -314,13 +314,13 @@ VMrView_Timer_Stop( VMtView_PrivateData *private_data; VMtViewTimer *current; VMtViewTimer *previous; - + UUmAssert(inView); // get the private data of the view private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(private_data); - + // find the timer in the list previous = NULL; current = private_data->timers; @@ -329,12 +329,12 @@ VMrView_Timer_Stop( // stop if the timer with inTimerID has been found if (current->timer_id == inTimerID) break; - + // move to the next timer previous = current; current = current->next; } - + // if current == NULL then no matching timer was found if (current) { @@ -343,7 +343,7 @@ VMrView_Timer_Stop( previous->next = current->next; else private_data->timers = current->next; - + UUrMemory_Block_Delete(current); } } @@ -355,21 +355,21 @@ VMrView_Timer_Update( { VMtView_PrivateData *private_data; UUtUns16 i; - + UUmAssert(inView); // get the private data of the view private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(private_data); - + if (private_data->timers) { VMtViewTimer *timer; UUtUns32 time; - + // get the current time time = UUrMachineTime_Sixtieths(); - + // update the timers timer = private_data->timers; while (timer) @@ -378,7 +378,7 @@ VMrView_Timer_Update( { // set the next update timer->next_update = time + timer->timer_frequency; - + // send VMcMessage_Timer to the view VMrView_SendMessage( inView, @@ -386,11 +386,11 @@ VMrView_Timer_Update( time, timer->timer_id); } - + timer = timer->next; } } - + // update the children of this view for (i = 0; i < inView->num_child_views; i++) { @@ -410,7 +410,7 @@ VMrView_Draw( M3tPointScreen *inDestination) { UUmAssert(inView); - + if (inView->flags & VMcViewFlag_Visible) { VMrView_SendMessage( @@ -420,7 +420,7 @@ VMrView_Draw( (UUtUns32)inDestination); } } - + // ---------------------------------------------------------------------- VMtView* VMrView_GetNextFocusableView( @@ -432,7 +432,7 @@ VMrView_GetNextFocusableView( UUtUns16 desired_flags; VMtView *next_focusable_view; VMtView *child; - + // setup the variables current_focus_index = 0; next_focusable_view = NULL; @@ -441,7 +441,7 @@ VMrView_GetNextFocusableView( VMcViewFlag_Enabled | VMcViewFlag_Active | VMcViewFlag_CanFocus; - + // find the current view in the list if (inCurrentFocus) { @@ -450,15 +450,15 @@ VMrView_GetNextFocusableView( if (inCurrentFocus == (VMtView*)inView->child_views[i].view_ref) break; } - + current_focus_index = i; } - + // search the rest of the list for the view for (i = current_focus_index + 1; i < inView->num_child_views; i++) { child = inView->child_views[i].view_ref; - + // check the flags if ((child->flags & desired_flags) == desired_flags) { @@ -467,7 +467,7 @@ VMrView_GetNextFocusableView( break; } } - + // NOTE: if inCurrentFocus == NULL then the whole list has already been searched if ((next_focusable_view == NULL) && (inCurrentFocus != NULL)) { @@ -477,7 +477,7 @@ VMrView_GetNextFocusableView( for (i = 0; i < current_focus_index + 1; i++) { child = inView->child_views[i].view_ref; - + // check the flags if ((child->flags & desired_flags) == desired_flags) { @@ -487,7 +487,7 @@ VMrView_GetNextFocusableView( } } } - + return next_focusable_view; } @@ -497,11 +497,11 @@ VMrView_GetParent( VMtView *inView) { VMtView_PrivateData *private_data; - + // get the data private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(private_data); - + return private_data->parent; } @@ -511,16 +511,16 @@ VMrView_GetValue( VMtView *inView) { UUtUns32 result; - + UUmAssert(inView); - + result = VMrView_SendMessage( inView, VMcMessage_GetValue, 0, 0); - + return result; } @@ -533,9 +533,9 @@ VMrView_GetViewUnderPoint( { VMtView *view; UUtUns16 layer; - + VMiView_GetViewUnderPoint(inView, inPoint, inFlags, &view, &layer); - + return view; } @@ -547,7 +547,7 @@ VMrView_Load( { // load and initialize the views VMiView_Create(inView, inParent, 0); - + return UUcError_None; } @@ -560,16 +560,16 @@ VMrView_PointGlobalToView( { VMtView_PrivateData *private_data; IMtPoint2D new_point; - + // get a pointer to the view's private data private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(private_data); - + // calculate the new point new_point = *inPoint; new_point.x -= inView->location.x; new_point.y -= inView->location.y; - + // save the new_point *outPoint = new_point; @@ -581,7 +581,7 @@ VMrView_PointGlobalToView( private_data->parent, &new_point, outPoint); - } + } } // ---------------------------------------------------------------------- @@ -593,9 +593,9 @@ VMrView_ProcHandler( { VMtView *view; VMtView_PrivateData *private_data; - + UUmAssert(inInstancePtr); - + // get a pointer to the view view = (VMtView*)inInstancePtr; // UUmAssert(view->view_data); @@ -603,7 +603,7 @@ VMrView_ProcHandler( // get a pointer to the view's private data private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, view); UUmAssert(private_data); - + switch(inMessage) { case TMcTemplateProcMessage_NewPostProcess: @@ -613,30 +613,30 @@ VMrView_ProcHandler( private_data->parent = NULL; private_data->timers = NULL; private_data->layer = 0; - + // add dialog views to the view list switch (view->type) { case VMcViewType_Box: private_data->callback = VMrView_Box_Callback; break; - + case VMcViewType_Button: private_data->callback = VMrView_Button_Callback; break; - + case VMcViewType_CheckBox: private_data->callback = VMrView_CheckBox_Callback; break; - + case VMcViewType_Dialog: private_data->callback = VMrView_Dialog_Callback; break; - + case VMcViewType_EditField: private_data->callback = VMrView_EditField_Callback; break; - + case VMcViewType_ListBox: private_data->callback = VMrView_ListBox_Callback; break; @@ -644,56 +644,56 @@ VMrView_ProcHandler( case VMcViewType_Picture: private_data->callback = VMrView_Picture_Callback; break; - + case VMcViewType_RadioButton: private_data->callback = VMrView_RadioButton_Callback; break; - + case VMcViewType_RadioGroup: private_data->callback = VMrView_RadioGroup_Callback; break; - + case VMcViewType_Scrollbar: private_data->callback = VMrView_Scrollbar_Callback; break; - + case VMcViewType_Slider: private_data->callback = VMrView_Slider_Callback; break; - + case VMcViewType_Tab: private_data->callback = VMrView_Tab_Callback; break; - + case VMcViewType_TabGroup: private_data->callback = VMrView_TabGroup_Callback; break; - + case VMcViewType_Text: private_data->callback = VMrView_Text_Callback; break; - + default: UUmAssert(!"Unknown View Type"); break; } break; - + case TMcTemplateProcMessage_DisposePreProcess: while (private_data->timers) { VMrView_Timer_Stop(view, private_data->timers->timer_id); } break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } @@ -706,14 +706,14 @@ VMrView_SendMessage( UUtUns32 inParam2) { VMtView_PrivateData *private_data; - + UUmAssert(inView); // get a pointer to the view's private data private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(private_data); UUmAssert(private_data->callback); - + return private_data->callback(inView, inMessage, inParam1, inParam2); } @@ -724,7 +724,7 @@ VMrView_SetActive( UUtBool inIsActive) { UUmAssert(inView); - + if (inIsActive) inView->flags |= VMcViewFlag_Active; else @@ -738,14 +738,14 @@ VMrView_SetCallback( VMtViewCallback inCallback) { VMtView_PrivateData *private_data; - + UUmAssert(inView); UUmAssert(inCallback); - + // get the private data private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(private_data); - + private_data->callback = inCallback; } @@ -756,7 +756,7 @@ VMrView_SetEnabled( UUtBool inIsEnabled) { UUmAssert(inView); - + if (inIsEnabled) inView->flags |= VMcViewFlag_Enabled; else @@ -770,9 +770,9 @@ VMrView_SetFocus( UUtBool inIsFocused) { UUtUns16 desired_flags; - + UUmAssert(inView); - + desired_flags = VMcViewFlag_Visible | VMcViewFlag_Enabled | @@ -796,9 +796,9 @@ VMrView_SetLocation( IMtPoint2D *inLocation) { UUmAssert(inView); - + inView->location = *inLocation; - + VMrView_SendMessage( inView, VMcMessage_Location, @@ -814,10 +814,10 @@ VMrView_SetSize( UUtUns16 inHeight) { UUmAssert(inView); - + inView->width = inWidth; inView->height = inHeight; - + VMrView_SendMessage( inView, VMcMessage_Size, @@ -832,7 +832,7 @@ VMrView_SetValue( UUtUns32 inValue) { UUmAssert(inView); - + VMrView_SendMessage( inView, VMcMessage_SetValue, @@ -847,7 +847,7 @@ VMrView_SetVisible( UUtBool inIsVisible) { UUmAssert(inView); - + if (inIsVisible) inView->flags |= VMcViewFlag_Visible; else @@ -860,7 +860,7 @@ VMrView_Unload( VMtView *inView) { UUmAssert(inView); - + VMiView_Destory(inView); } @@ -884,30 +884,30 @@ VMiPartSpec_CalcUV( float ru; float tv; float bv; - + texture = (M3tTextureMap*)inPartSpec->texture; - + invTextureWidth = 1.0f / (float)texture->width; invTextureHeight = 1.0f / (float)texture->height; - + lu = (float)inPartSpec->part_matrix_tl[inColumn][inRow].x * invTextureWidth; tv = (float)inPartSpec->part_matrix_tl[inColumn][inRow].y * invTextureHeight; - + bv = (float)inPartSpec->part_matrix_br[inColumn][inRow].y * invTextureHeight; ru = (float)inPartSpec->part_matrix_br[inColumn][inRow].x * invTextureWidth; - + // tl ioUVs[0].u = lu; ioUVs[0].v = tv; - + // tr ioUVs[1].u = ru; ioUVs[1].v = tv; - + // bl ioUVs[2].u = lu; ioUVs[2].v = bv; - + // br ioUVs[3].u = ru; ioUVs[3].v = bv; @@ -922,16 +922,16 @@ VMiPartSpec_ProcHandler( { VMtPartSpec *part_spec; VMtPartSpec_PrivateData *private_data; - + UUmAssert(inInstancePtr); - + // get a pointer to the part spec part_spec = (VMtPartSpec*)inInstancePtr; // get a pointer to the view's private data private_data = (VMtPartSpec_PrivateData*)inPrivateData; UUmAssert(private_data); - + switch(inMessage) { case TMcTemplateProcMessage_NewPostProcess: @@ -949,18 +949,18 @@ VMiPartSpec_ProcHandler( VMiPartSpec_CalcUV(part_spec, private_data->rm, 2, 1); VMiPartSpec_CalcUV(part_spec, private_data->rb, 2, 2); break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } @@ -975,17 +975,17 @@ VMrInitialize( void) { UUtError error; - + // install the private data and/or procs - error = + error = TMrTemplate_PrivateData_New( VMcTemplate_View, sizeof(VMtView_PrivateData), VMrView_ProcHandler, &DMgTemplate_View_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); - - error = + + error = TMrTemplate_PrivateData_New( VMcTemplate_PartSpecification, sizeof(VMtPartSpec_PrivateData), @@ -993,7 +993,7 @@ VMrInitialize( &DMgTemplate_PartSpec_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); - error = + error = TMrTemplate_PrivateData_New( VMcTemplate_View_Button, sizeof(VMtView_Button_PrivateData), @@ -1001,7 +1001,7 @@ VMrInitialize( &DMgTemplate_Button_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); - error = + error = TMrTemplate_PrivateData_New( VMcTemplate_View_CheckBox, sizeof(VMtView_CheckBox_PrivateData), @@ -1009,7 +1009,7 @@ VMrInitialize( &DMgTemplate_CheckBox_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); - error = + error = TMrTemplate_PrivateData_New( VMcTemplate_View_EditField, sizeof(VMtView_EditField_PrivateData), @@ -1017,7 +1017,7 @@ VMrInitialize( &DMgTemplate_EditField_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); - error = + error = TMrTemplate_PrivateData_New( VMcTemplate_View_ListBox, sizeof(VMtView_ListBox_PrivateData), @@ -1025,7 +1025,7 @@ VMrInitialize( &DMgTemplate_ListBox_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); - error = + error = TMrTemplate_PrivateData_New( VMcTemplate_View_RadioButton, sizeof(VMtView_RadioButton_PrivateData), @@ -1033,7 +1033,7 @@ VMrInitialize( &DMgTemplate_RadioButton_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); - error = + error = TMrTemplate_PrivateData_New( VMcTemplate_View_RadioGroup, sizeof(VMtView_RadioGroup_PrivateData), @@ -1041,15 +1041,15 @@ VMrInitialize( &DMgTemplate_RadioGroup_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); - error = + error = TMrTemplate_PrivateData_New( VMcTemplate_View_Tab, sizeof(VMtView_Tab_PrivateData), VMrView_Tab_ProcHandler, &DMgTemplate_Tab_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); - - error = + + error = TMrTemplate_PrivateData_New( VMcTemplate_View_Text, sizeof(VMtView_Text_PrivateData), @@ -1057,7 +1057,7 @@ VMrInitialize( &DMgTemplate_Text_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); - error = + error = TMrTemplate_PrivateData_New( VMcTemplate_View_Slider, sizeof(VMtView_Slider_PrivateData), @@ -1065,7 +1065,7 @@ VMrInitialize( &DMgTemplate_Slider_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); - error = + error = TMrTemplate_PrivateData_New( VMcTemplate_View_Scrollbar, sizeof(VMtView_Scrollbar_PrivateData), diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/BFW_ViewUtilities.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/BFW_ViewUtilities.c index fc9a929..502dbc1 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/BFW_ViewUtilities.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/BFW_ViewUtilities.c @@ -26,7 +26,7 @@ VUrDrawPartSpecification( M3tTextureMap *texture; VMtPartSpec_PrivateData *private_data; M3tPointScreen dest; - + UUtUns16 t_height; UUtUns16 m_height; UUtUns16 b_height; @@ -34,16 +34,16 @@ VUrDrawPartSpecification( UUtUns16 l_width; UUtUns16 m_width; UUtUns16 r_width; - + // get the private data private_data = (VMtPartSpec_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_PartSpec_PrivateData, inPartSpec); UUmAssert(private_data); - + texture = (M3tTextureMap*)inPartSpec->texture; - + // set the shade and alpha shade = IMcShade_White; - + // calculate the heights and widths t_height = UUmABS(inPartSpec->part_matrix_br[0][0].y - inPartSpec->part_matrix_tl[0][0].y); b_height = UUmABS(inPartSpec->part_matrix_br[0][2].y - inPartSpec->part_matrix_tl[0][2].y); @@ -53,7 +53,7 @@ VUrDrawPartSpecification( b_height = b_height * b_height / inHeight; } m_height = (UUtUns16)UUmMax(0, inHeight - (t_height + b_height)); - + l_width = UUmABS(inPartSpec->part_matrix_br[0][0].x - inPartSpec->part_matrix_tl[0][0].x); r_width = UUmABS(inPartSpec->part_matrix_br[2][0].x - inPartSpec->part_matrix_tl[2][0].x); if ((l_width + r_width) > inWidth) @@ -62,13 +62,13 @@ VUrDrawPartSpecification( r_width = r_width * r_width / inWidth; } m_width = (UUtUns16)UUmMax(0, inWidth - (l_width + r_width)); - + if (inFlags == VMcPart_MiddleMiddle) { m_height = inHeight; m_width = inWidth; } - + // draw the left column dest = *inLocation; @@ -109,7 +109,7 @@ VUrDrawPartSpecification( shade, inAlpha); } - + // draw the middle column dest = *inLocation; if (inFlags & VMcPart_LeftColumn) @@ -154,14 +154,14 @@ VUrDrawPartSpecification( shade, inAlpha); } - + // draw the right column dest = *inLocation; if (inFlags & VMcPart_MiddleColumn) { dest.x += l_width + m_width; } - + if (inFlags & VMcPart_RightTop) { M3rDraw_BitmapUV( @@ -214,33 +214,33 @@ VUrDrawTextureRef( UUtUns32 shade; UUtUns16 width; UUtUns16 height; - + UUmAssert(inLocation); - + if (inTextureRef == NULL) return; - + // set the shade and alpha shade = IMcShade_White; // get the template tag of the current background template_tag = TMrInstance_GetTemplateTag(inTextureRef); - + // set the width and height width = inWidth; height = inHeight; - + switch (template_tag) { case M3cTemplate_TextureMap: { M3tTextureMap *texture; - + // get a a pointer to the texture texture = inTextureRef; - + if (inWidth == (UUtUns16)(-1)) width = texture->width; if (inHeight == (UUtUns16)(-1)) height = texture->height; - + // draw background M3rDraw_Bitmap( texture, @@ -251,17 +251,17 @@ VUrDrawTextureRef( inAlpha); } break; - + case M3cTemplate_TextureMap_Big: { M3tTextureMap_Big *texture_big; - + // get a pointer to the texture texture_big = inTextureRef; - + if (inWidth == (UUtUns16)(-1)) width = texture_big->width; if (inHeight == (UUtUns16)(-1)) height = texture_big->height; - + // draw background M3rDraw_BigBitmap( texture_big, @@ -272,7 +272,7 @@ VUrDrawTextureRef( inAlpha); } break; - + default: UUmAssert(!"Unknown texture map template tag."); break; @@ -294,15 +294,15 @@ VUrCreate_Texture( UUtError error; *outTextureRef = NULL; - + // ------------------------------ // create the appropriate texture map // ------------------------------ - if ((inWidth > M3cTextureMap_MaxWidth) || + if ((inWidth > M3cTextureMap_MaxWidth) || (inHeight > M3cTextureMap_MaxHeight)) { M3tTextureMap_Big *texture_big; - + // create a big texture map error = M3rTextureMap_Big_New( @@ -314,13 +314,13 @@ VUrCreate_Texture( "VUrCreate_Texture Big", &texture_big); UUmError_ReturnOnErrorMsg(error, "Unable to create texture map"); - + *outTextureRef = (void*)texture_big; } else { M3tTextureMap *texture; - + // create a texture map error = M3rTextureMap_New( @@ -335,7 +335,7 @@ VUrCreate_Texture( *outTextureRef = (void*)texture; } - + return UUcError_None; } @@ -348,7 +348,7 @@ VUrCreate_StringTexture( UUtRect *outStringBounds) { UUtError error; - + IMtPixel background_color; IMtPixel text_color; @@ -358,7 +358,7 @@ VUrCreate_StringTexture( char *desired_font_family; TStFontStyle desired_font_style; UUtUns16 desired_font_format; - + IMtPoint2D dest; *outStringTexture = NULL; @@ -366,13 +366,13 @@ VUrCreate_StringTexture( outStringBounds->top = 0; outStringBounds->right = 0; outStringBounds->bottom = 0; - + // ------------------------------ // set the colors to draw with // ------------------------------ background_color = IMrPixel_FromShade(VMcControl_PixelType, VMcColor_Background); text_color = IMrPixel_FromShade(VMcControl_PixelType, VMcColor_Text); - + // ------------------------------ // create the text context and draw the string // ------------------------------ @@ -381,23 +381,23 @@ VUrCreate_StringTexture( desired_font_family = TScFontFamily_RomanSmall; else desired_font_family = TScFontFamily_Roman; - + if (inFlags & VMcCommonFlag_Text_Bold) desired_font_style = TScStyle_Bold; else if (inFlags & VMcCommonFlag_Text_Italic) desired_font_style = TScStyle_Italic; else desired_font_style = TScStyle_Plain; - + if (inFlags & VMcCommonFlag_Text_HCenter) desired_font_format = TSc_HCenter; else if (inFlags & VMcCommonFlag_Text_HRight) desired_font_format = TSc_HRight; else desired_font_format = TSc_HLeft; - + desired_font_format |= TSc_VCenter; - + // get the font family error = TMrInstance_GetDataPtr( @@ -405,7 +405,7 @@ VUrCreate_StringTexture( desired_font_family, &font_family); UUmError_ReturnOnErrorMsg(error, "Unable to load font family"); - + // create a new text context error = TSrContext_New( @@ -414,7 +414,7 @@ VUrCreate_StringTexture( desired_font_format, &text_context); UUmError_ReturnOnErrorMsg(error, "Unable to create text context"); - + // set the color of the text error = TSrContext_SetColor(text_context, text_color); UUmError_ReturnOnErrorMsg(error, "Unable to set the text color"); @@ -425,22 +425,22 @@ VUrCreate_StringTexture( // ------------------------------ // create the appropriate texture map // ------------------------------ - + // create the texture error = VUrCreate_Texture(bounds.right, bounds.bottom, outStringTexture); UUmError_ReturnOnErrorMsg(error, "Unable to create texture map"); - + // fill in the texture VUrClearTexture(*outStringTexture, NULL, background_color); - + // ------------------------------ // draw the text on the texture // ------------------------------ - + // set the dest dest.x = 0; dest.y = 0; - + // draw the text into the texture map error = TSrContext_DrawString( @@ -454,9 +454,9 @@ VUrCreate_StringTexture( // dispose of the text context TSrContext_Delete(text_context); text_context = NULL; - + *outStringBounds = bounds; - + return UUcError_None; } @@ -469,14 +469,14 @@ VUrClearTexture( { TMtTemplateTag tag; UUtRect bounds; - + tag = TMrInstance_GetTemplateTag(inTexture); if (tag == M3cTemplate_TextureMap) { M3tTextureMap *texture; - + texture = (M3tTextureMap*)inTexture; - + if (inBounds == NULL) { bounds.left = 0; @@ -488,16 +488,16 @@ VUrClearTexture( { bounds = *inBounds; } - + // fill the texture map with the background color M3rTextureMap_Fill(texture, inColor, &bounds); } else if (tag == M3cTemplate_TextureMap_Big) { M3tTextureMap_Big *texture_big; - + texture_big = (M3tTextureMap_Big*)inTexture; - + if (inBounds == NULL) { bounds.left = 0; @@ -509,9 +509,9 @@ VUrClearTexture( { bounds = *inBounds; } - + // fill the texture map with the background color M3rTextureMap_Big_Fill(texture_big, inColor, &bounds); } } - \ No newline at end of file + diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/BFW_ViewUtilities.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/BFW_ViewUtilities.h index 662b3d6..48851c3 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/BFW_ViewUtilities.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/BFW_ViewUtilities.h @@ -21,7 +21,7 @@ extern TMtPrivateData* DMgTemplate_PartSpec_PrivateData; // ====================================================================== // prototypes -// ====================================================================== +// ====================================================================== void VUrDrawPartSpecification( VMtPartSpec *inPartSpec, @@ -30,7 +30,7 @@ VUrDrawPartSpecification( UUtUns16 inWidth, UUtUns16 inHeight, UUtUns16 inAlpha); - + void VUrDrawTextureRef( void *inTextureRef, @@ -52,7 +52,7 @@ VUrCreate_StringTexture( UUtUns16 inFlags, void **outStringTexture, UUtRect *outStringBounds); - + void VUrClearTexture( void *inTexture, @@ -60,4 +60,4 @@ VUrClearTexture( IMtPixel inColor); // ====================================================================== -#endif /* BFW_VIEWUTILITIES_H */ \ No newline at end of file +#endif /* BFW_VIEWUTILITIES_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/DM_Cursor/DM_DialogCursor.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/DM_Cursor/DM_DialogCursor.c index 260bb15..b0b1a8d 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/DM_Cursor/DM_DialogCursor.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/DM_Cursor/DM_DialogCursor.c @@ -21,13 +21,13 @@ DCrCursor_Animate( UUtUns32 inTime) { DCtCursor_PrivateData *private_data; - + UUmAssert(inCursor); - + // get a pointer to the private data private_data = (DCtCursor_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Cursor_PrivateData, inCursor); if (private_data == NULL) return; - + // make sure it is time to animate if (private_data->next_animation > inTime) return; @@ -37,7 +37,7 @@ DCrCursor_Animate( // go to next cursor in the list private_data->current_cursor++; if (private_data->current_cursor >= inCursor->num_cursors) - private_data->current_cursor = 0; + private_data->current_cursor = 0; } // ---------------------------------------------------------------------- @@ -49,11 +49,11 @@ DCrCursor_Draw( { DCtCursor_PrivateData *private_data; M3tPointScreen destination; - + // get a pointer to the private data private_data = (DCtCursor_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Cursor_PrivateData, inCursor); if (private_data == NULL) return; - + // update the destination destination.x = (float)inDestination->x - DCcCursorCenter_X; destination.y = (float)inDestination->y - DCcCursorCenter_Y; @@ -80,12 +80,12 @@ DCrCursor_Load( DCtCursor *cursor; UUtUns16 i; DCtCursor_PrivateData *private_data; - + UUmAssert(outCursor); - + // clear the outCursor *outCursor = NULL; - + // get a pointer to the cursor type list error = TMrInstance_GetDataPtr( @@ -93,7 +93,7 @@ DCrCursor_Load( "cursor_type_list", &cursor_type_list); UUmError_ReturnOnError(error); - + // find the cursor in the cursor type list for (i = 0; i < cursor_type_list->num_cursor_type_pairs; i++) { @@ -106,20 +106,20 @@ DCrCursor_Load( cursor_type_list->cursor_type_pair[i].cursor_name, &cursor); UUmError_ReturnOnError(error); - + // get a pointer to the private data private_data = (DCtCursor_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Cursor_PrivateData, cursor); if (private_data == NULL) return UUcError_Generic; - + private_data->current_cursor = 0; - + // return the cursor *outCursor = cursor; - + return UUcError_None; } } - + return UUcError_Generic; } @@ -132,10 +132,10 @@ DCrCursor_ProcHandler( { DCtCursor *cursor; DCtCursor_PrivateData *private_data; - + // get a pointer to the dialog data cursor = (DCtCursor*)inInstancePtr; - + // get a pointer to the private data private_data = (DCtCursor_PrivateData*)inPrivateData; if (private_data == NULL) return UUcError_Generic; @@ -148,13 +148,13 @@ DCrCursor_ProcHandler( private_data->current_cursor = 0; private_data->next_animation = 0; break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; @@ -174,16 +174,16 @@ DCrInitialize( void) { UUtError error; - + // install the private data and/or procs for cursors - error = + error = TMrTemplate_PrivateData_New( DCcTemplate_Cursor, sizeof(DCtCursor_PrivateData), DCrCursor_ProcHandler, &DMgTemplate_Cursor_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install dialog proc handler"); - + return UUcError_None; } @@ -192,4 +192,4 @@ void DCrTerminate( void) { -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/DM_Cursor/DM_DialogCursor.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/DM_Cursor/DM_DialogCursor.h index 4c268c5..f044721 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/DM_Cursor/DM_DialogCursor.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/DM_Cursor/DM_DialogCursor.h @@ -28,16 +28,16 @@ typedef UUtUns16 DCtCursorType; enum { DCcCursorType_Arrow = 1, - + DCcNumCursorTypes - + }; // ---------------------------------------------------------------------- typedef tm_struct DCtCursorTexture { tm_templateref texture_ref; - + } DCtCursorTexture; // ---------------------------------------------------------------------- @@ -46,18 +46,18 @@ typedef tm_template('D', 'C', 'C', '_', "DC Cursor List") DCtCursor { tm_pad pad0[20]; - + UUtUns16 animation_rate; - + tm_varindex UUtUns16 num_cursors; tm_vararray DCtCursorTexture cursors[1]; - + } DCtCursor; typedef struct DCtCursor_PrivateData { UUtUns16 current_cursor; - + // time in ticks of next animation UUtUns32 next_animation; @@ -68,7 +68,7 @@ typedef tm_struct DCtCursorTypePair { UUtUns16 cursor_type; char cursor_name[32]; - + } DCtCursorTypePair; // ---------------------------------------------------------------------- @@ -77,10 +77,10 @@ typedef tm_template('C', 'T', 'L', '_', "Cursor Type List") DCtCursorTypeList { tm_pad pad0[22]; - + tm_varindex UUtUns16 num_cursor_type_pairs; tm_vararray DCtCursorTypePair cursor_type_pair[1]; - + } DCtCursorTypeList; @@ -99,26 +99,26 @@ DCrCursor_Draw( DCtCursor *inCursor, IMtPoint2D *inDestination, float inLayer); - + UUtError DCrCursor_Load( DCtCursorType inCursorType, DCtCursor **outCursorList); - + UUtError DCrCursor_ProcHandler( TMtTemplateProc_Message inMessage, void* inInstancePtr, void* inDataPtr); - + // ---------------------------------------------------------------------- UUtError DCrInitialize( void); - + void DCrTerminate( void); // ====================================================================== -#endif /* DM_DIALOGCURSOR_H */ \ No newline at end of file +#endif /* DM_DIALOGCURSOR_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Box.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Box.c index 5cf0334..e984666 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Box.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Box.c @@ -56,10 +56,10 @@ VMrView_Box_Callback( UUtUns32 inParam2) { VMtView_Box *box; - + // get a pointer to the data box = (VMtView_Box*)inView->view_data; - + switch (inMessage) { case VMcMessage_Paint: @@ -70,6 +70,6 @@ VMrView_Box_Callback( (M3tPointScreen*)inParam2); return 0; } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); } diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Box.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Box.h index fac74c4..48a6c1b 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Box.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Box.h @@ -17,9 +17,9 @@ typedef tm_template('V', 'M', 'B', 'X', "VM View Box") VMtView_Box { - + VMtPartSpec *box; - + } VMtView_Box; // ====================================================================== @@ -33,4 +33,4 @@ VMrView_Box_Callback( UUtUns32 inParam2); // ====================================================================== -#endif /* VM_VIEW_BOX_H */ \ No newline at end of file +#endif /* VM_VIEW_BOX_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Button.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Button.c index a38ca3b..70fb51c 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Button.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Button.c @@ -27,12 +27,12 @@ VMiView_Button_Create( UUtError error; UUtInt16 offset_x; UUtInt16 offset_y; - + if ((inPrivateData->texture_ref == NULL) && (TSrString_GetLength(inButton->title) > 0)) { UUtRect string_bounds; - + // create texture_ref error = VUrCreate_StringTexture( @@ -41,12 +41,12 @@ VMiView_Button_Create( &inPrivateData->texture_ref, &string_bounds); UUmError_ReturnOnErrorMsg(error, "Unable to create title texture for the button"); - + // get the string_texture_width and string_texture_height inPrivateData->string_texture_width = string_bounds.right; inPrivateData->string_texture_height = string_bounds.bottom; } - + // calculate offset_x and offset_y offset_x = offset_y = 0; if (inButton->flags & VMcCommonFlag_Text_HRight) @@ -55,7 +55,7 @@ VMiView_Button_Create( offset_x = ((inView->width - inPrivateData->string_texture_width) >> 1); if (inButton->flags & VMcCommonFlag_Text_VCenter) offset_y = ((inView->height - inPrivateData->string_texture_height) >> 1); - + inPrivateData->text_location.x = inButton->text_location_offset.x + offset_x; inPrivateData->text_location.y = inButton->text_location_offset.y + offset_y; @@ -76,16 +76,16 @@ VMiView_Button_Paint( UUtUns16 alpha; VMtPartSpec *partspec; UUtUns8 pressed; - + // set the alpha if (inView->flags & VMcViewFlag_Enabled) alpha = VUcAlpha_Enabled; else alpha = VUcAlpha_Disabled; - + // draw the idle button partspec = NULL; - + pressed = VMcMouseState_MouseDown | VMcMouseState_MouseOver; if (((inPrivateData->mouse_state & pressed) == pressed) && (inButton->pressed)) @@ -103,7 +103,7 @@ VMiView_Button_Paint( { partspec = inButton->idle; } - + if (partspec) { VUrDrawPartSpecification( @@ -114,17 +114,17 @@ VMiView_Button_Paint( inView->height, alpha); } - + // draw the string texture if (inPrivateData->texture_ref) { M3tPointScreen text_dest; - + // set the string destination text_dest = *inDestination; text_dest.x += (float)inPrivateData->text_location.x; text_dest.y += (float)inPrivateData->text_location.y; - + VUrDrawTextureRef( inPrivateData->texture_ref, &text_dest, @@ -150,38 +150,38 @@ VMrView_Button_Callback( VMtView_Button *button; VMtView_Button_PrivateData *private_data; VMtView_PrivateData *view_private_data; - + // get a pointer to the view's private data view_private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(view_private_data); - + // get a pointer to the button data button = (VMtView_Button*)inView->view_data; private_data = (VMtView_Button_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Button_PrivateData, button); UUmAssert(private_data); - + switch (inMessage) { case VMcMessage_Create: VMiView_Button_Create(inView, button, private_data); return 0; - + case VMcMessage_MouseMove: { IMtPoint2D global_point; IMtPoint2D local_point; UUtRect bounds; - + global_point.x = (UUtInt16)UUmHighWord(inParam1); global_point.y = (UUtInt16)UUmLowWord(inParam1); - + VMrView_PointGlobalToView(inView, &global_point, &local_point); - + bounds.left = 0; bounds.top = 0; bounds.right = inView->width; bounds.bottom = inView->height; - + if (IMrRect_PointIn(&bounds, &local_point)) { private_data->mouse_state = VMcMouseState_MouseOver; @@ -190,41 +190,41 @@ VMrView_Button_Callback( { private_data->mouse_state &= ~VMcMouseState_MouseOver; } - + if (inParam2 & LIcMouseState_LButtonDown) private_data->mouse_state |= VMcMouseState_MouseDown; } return 0; - + case VMcMessage_MouseLeave: private_data->mouse_state &= ~VMcMouseState_MouseOver; return 0; - + case VMcMessage_LMouseDown: DMrDialog_SetMouseFocusView(NULL, inView); private_data->mouse_state |= VMcMouseState_MouseDown; return 0; - + case VMcMessage_LMouseUp: { UUtRect bounds_rect; IMtPoint2D global_point; IMtPoint2D view_point; - + DMrDialog_ReleaseMouseFocusView(NULL, inView); - + // initialize the bounds_rect bounds_rect.left = 0; bounds_rect.top = 0; bounds_rect.right = inView->width; bounds_rect.bottom = inView->height; - + // initialize the point global_point.x = (UUtInt16)UUmHighWord(inParam1); global_point.y = (UUtInt16)UUmLowWord(inParam1); - + VMrView_PointGlobalToView(inView, &global_point, &view_point); - + // check to see if the point is in the bounds of the view if (IMrRect_PointIn(&bounds_rect, &view_point)) { @@ -234,11 +234,11 @@ VMrView_Button_Callback( UUmMakeLong(VMcNotify_Click, inView->id), (UUtUns32)inView); } - + private_data->mouse_state &= ~VMcMouseState_MouseDown; } return 0; - + case VMcMessage_Paint: // draw the button VMiView_Button_Paint( @@ -248,7 +248,7 @@ VMrView_Button_Callback( (M3tPointScreen*)inParam2); return 0; } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); } @@ -261,7 +261,7 @@ VMrView_Button_ProcHandler( { VMtView_Button *button; VMtView_Button_PrivateData *private_data; - + // get a pointer to the button data button = (VMtView_Button*)inInstancePtr; private_data = (VMtView_Button_PrivateData*)inPrivateData; @@ -280,17 +280,17 @@ VMrView_Button_ProcHandler( private_data->text_location.y = 0; private_data->next_animation = 0; break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Button.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Button.h index e23f754..3fe6402 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Button.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Button.h @@ -23,35 +23,35 @@ typedef tm_template('V', 'M', '_', 'B', "VM View Button") VMtView_Button { - + // button part specifications VMtPartSpec *idle; VMtPartSpec *mouse_over; VMtPartSpec *pressed; - - IMtPoint2D text_location_offset; // offset from top left corner of button + + IMtPoint2D text_location_offset; // offset from top left corner of button // for the text to be drawn at UUtUns16 flags; UUtUns16 animation_rate; // number of ticks between texture changes char title[32]; - + } VMtView_Button; typedef struct VMtView_Button_PrivateData { UUtUns8 mouse_state; - + // vars for title text tm_templateref texture_ref; UUtInt16 string_texture_width; UUtInt16 string_texture_height; IMtPoint2D text_location; - + // time in ticks of next animation UUtUns32 next_animation; - + } VMtView_Button_PrivateData; extern TMtPrivateData* DMgTemplate_Button_PrivateData; @@ -73,4 +73,4 @@ VMrView_Button_ProcHandler( void* inPrivateData); // ====================================================================== -#endif /* VM_VIEW_BUTTON_H */ \ No newline at end of file +#endif /* VM_VIEW_BUTTON_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_CheckBox.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_CheckBox.c index 2766a22..e6965ac 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_CheckBox.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_CheckBox.c @@ -23,7 +23,7 @@ VMiView_CheckBox_Create( VMtView_CheckBox_PrivateData *inPrivateData) { UUtError error; - + // ------------------------------ // setup the checkbox // ------------------------------ @@ -40,14 +40,14 @@ VMiView_CheckBox_Create( inPrivateData->checkbox_location.x = 4; inPrivateData->checkbox_location.y = 4; } - + // ------------------------------ // create the title_texture_ref // ------------------------------ if (inPrivateData->title_texture_ref == NULL) { UUtRect string_bounds; - + // create the background texture with the outline error = VUrCreate_StringTexture( @@ -56,7 +56,7 @@ VMiView_CheckBox_Create( &inPrivateData->title_texture_ref, &string_bounds); UUmError_ReturnOnErrorMsg(error, "Unable to create the texture"); - + inPrivateData->title_texture_width = string_bounds.right; inPrivateData->title_texture_height = string_bounds.bottom; @@ -118,14 +118,14 @@ VMiView_CheckBox_Paint( inView->height, alpha); } - + // draw the checkbox if (inCheckBox->off && inCheckBox->on) { dest = *inDestination; dest.x += (float)inPrivateData->checkbox_location.x; dest.y += (float)inPrivateData->checkbox_location.y; - + if (inPrivateData->checkbox_state == VMcCheckBox_Off) { VUrDrawPartSpecification( @@ -147,7 +147,7 @@ VMiView_CheckBox_Paint( alpha); } } - + // draw the title texture if (inPrivateData->title_texture_ref) { @@ -180,22 +180,22 @@ VMrView_CheckBox_Callback( { VMtView_CheckBox *checkbox; VMtView_CheckBox_PrivateData *private_data; - + // get pointers to the data checkbox = (VMtView_CheckBox*)inView->view_data; private_data = (VMtView_CheckBox_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_CheckBox_PrivateData, checkbox); UUmAssert(private_data); - + switch (inMessage) { case VMcMessage_Create: VMiView_CheckBox_Create(inView, checkbox, private_data); return 0; - + case VMcMessage_LMouseUp: VMiView_CheckBox_HandleMouseEvent(inView, checkbox, private_data); return 0; - + case VMcMessage_Paint: // draw the button VMiView_CheckBox_Paint( @@ -204,15 +204,15 @@ VMrView_CheckBox_Callback( private_data, (M3tPointScreen*)inParam2); return 0; - + case VMcMessage_GetValue: return (UUtUns32)private_data->checkbox_state; - + case VMcMessage_SetValue: private_data->checkbox_state = (UUtBool)inParam1; return 0; } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); } @@ -225,7 +225,7 @@ VMrView_CheckBox_ProcHandler( { VMtView_CheckBox *checkbox; VMtView_CheckBox_PrivateData *private_data; - + // get pointers to the data checkbox = (VMtView_CheckBox*)inInstancePtr; private_data = (VMtView_CheckBox_PrivateData*)inPrivateData; @@ -241,17 +241,17 @@ VMrView_CheckBox_ProcHandler( private_data->title_texture_width = 0; private_data->title_texture_height = 0; break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_CheckBox.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_CheckBox.h index 1d1ca6c..8d1fe4c 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_CheckBox.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_CheckBox.h @@ -27,17 +27,17 @@ enum typedef tm_template('V', 'M', 'C', 'B', "VM View CheckBox") VMtView_CheckBox { - + UUtUns16 flags; UUtUns16 reserved; IMtPoint2D title_location_offset; - + VMtPartSpec *outline; VMtPartSpec *off; VMtPartSpec *on; - + char title[32]; - + } VMtView_CheckBox; typedef struct VMtView_CheckBox_PrivateData @@ -46,13 +46,13 @@ typedef struct VMtView_CheckBox_PrivateData IMtPoint2D checkbox_location; UUtUns16 checkbox_width; UUtUns16 checkbox_height; - + // vars for title text tm_templateref title_texture_ref; IMtPoint2D title_location; UUtInt16 title_texture_width; UUtInt16 title_texture_height; - + } VMtView_CheckBox_PrivateData; extern TMtPrivateData* DMgTemplate_CheckBox_PrivateData; @@ -74,4 +74,4 @@ VMrView_CheckBox_ProcHandler( void* inPrivateData); // ====================================================================== -#endif /* VM_VIEW_CHECKBOX_H */ \ No newline at end of file +#endif /* VM_VIEW_CHECKBOX_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Dialog.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Dialog.c index f0f958f..90bd8d6 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Dialog.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Dialog.c @@ -25,14 +25,14 @@ VMrView_Dialog_Callback( UUtUns32 result; DMtDialogData *dialog_data; DMtDialogData_PrivateData *private_data; - + // get the dialog data dialog_data = (DMtDialogData*)inView->view_data; private_data = (DMtDialogData_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Dialog_PrivateData, dialog_data); UUmAssert(private_data); - + result = 0; - + switch (inMessage) { case VMcMessage_Create: @@ -46,7 +46,7 @@ VMrView_Dialog_Callback( private_data->mouse_clicked_time = 0; private_data->mouse_clicked_type = VMcMessage_None; return 0; - + case VMcMessage_KeyDown: case VMcMessage_KeyUp: if (private_data->text_focus_view) @@ -58,14 +58,14 @@ VMrView_Dialog_Callback( inParam1, inParam2); } - + if (result == 0) { if (private_data->callback == NULL) break; result = private_data->callback(inView, inMessage, inParam1, inParam2); } return 0; - + case VMcMessage_Destroy: case VMcMessage_Command: case VMcMessage_Timer: @@ -79,21 +79,21 @@ VMrView_Dialog_Callback( if (private_data->callback == NULL) break; result = private_data->callback(inView, inMessage, inParam1, inParam2); return 0; - + case VMcMessage_Paint: { M3tPointScreen destination; UUtUns16 alpha; - + // set the alpha if (inView->flags & VMcViewFlag_Enabled) alpha = VUcAlpha_Enabled; else alpha = VUcAlpha_Disabled; - + // get a pointer to the destination destination = *((M3tPointScreen*)inParam2); - + if (dialog_data->partspec) { VUrDrawPartSpecification( @@ -105,7 +105,7 @@ VMrView_Dialog_Callback( alpha); } else - + // don't draw if there aren't any textures to draw if (dialog_data->b_textures->num_textures > 0) { @@ -119,13 +119,13 @@ VMrView_Dialog_Callback( } } break; // let the defaull callback draw the child views - + case VMcMessage_Update: private_data->cursor_position.x = (UUtInt16)UUmHighWord(inParam1); private_data->cursor_position.y = (UUtInt16)UUmLowWord(inParam1); return 0; } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); } @@ -138,14 +138,14 @@ DMrDialogData_ProcHandler( { DMtDialogData *dialog_data; DMtDialogData_PrivateData *private_data; - + UUmAssert(inInstancePtr); - + // get the dialog data dialog_data = (DMtDialogData*)inInstancePtr; private_data = (DMtDialogData_PrivateData*)inDataPtr; UUmAssert(private_data); - + switch(inMessage) { case TMcTemplateProcMessage_NewPostProcess: @@ -161,17 +161,17 @@ DMrDialogData_ProcHandler( private_data->mouse_clicked_time = 0; private_data->mouse_clicked_type = VMcMessage_None; break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Dialog.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Dialog.h index c87eb2b..0ec5e8f 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Dialog.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Dialog.h @@ -21,38 +21,38 @@ typedef tm_template('D', 'M', 'D', 'D', "VM View Dialog Data") DMtDialogData { - + UUtUns16 flags; UUtUns16 reserved; - + VMtPartSpec *partspec; VMtTextureList *b_textures; // background textures - + } DMtDialogData; typedef struct DMtDialogData_PrivateData { DMtDialogCallback callback; - + UUtBool quit_dialog; UUtUns32 out_message; - + VMtView *text_focus_view; VMtView *mouse_focus_view; VMtView *mouse_over_view; - + DCtCursor *cursor; IMtPoint2D cursor_position; - + // for tracking double clicks VMtView *mouse_clicked_view; UUtUns32 mouse_clicked_time; VMtMessage mouse_clicked_type; IMtPoint2D mouse_clicked_point; - + // local input mode LItMode prev_localinput_mode; - + } DMtDialogData_PrivateData; extern TMtPrivateData* DMgTemplate_Dialog_PrivateData; @@ -74,4 +74,4 @@ DMrDialogData_ProcHandler( void* inPrivateData); // ====================================================================== -#endif /* VM_VIEW_DIALOG_H */ \ No newline at end of file +#endif /* VM_VIEW_DIALOG_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_EditField.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_EditField.c index 4f202e5..808692f 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_EditField.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_EditField.c @@ -29,11 +29,11 @@ VMiView_EditField_UpdateCaret( VMtView_EditField_PrivateData *inPrivateData) { UUtUns32 time; - + if (inPrivateData->has_focus == UUcFalse) return; - + time = UUrMachineTime_Sixtieths(); - + if (inPrivateData->caret_time < time) { // flash the caret if it is time @@ -73,17 +73,17 @@ VMiView_EditField_UpdateTextures( inPrivateData->string, &bounds); if (error != UUcError_None) return; - + inPrivateData->string_width = bounds.right; inPrivateData->string_height = bounds.bottom; - + if ((inView->width > M3cTextureMap_MaxWidth) || (inView->height > M3cTextureMap_MaxHeight)) { // erase the string texture M3rTextureMap_Big_Fill( inPrivateData->string_texture, - inPrivateData->erase_color, + inPrivateData->erase_color, &bounds); } else @@ -91,14 +91,14 @@ VMiView_EditField_UpdateTextures( // erase the string texture M3rTextureMap_Fill( inPrivateData->string_texture, - inPrivateData->erase_color, + inPrivateData->erase_color, &bounds); } - + // set dest dest.x = 0; dest.y = 0; - + // draw the string error = TSrContext_DrawString( @@ -130,20 +130,20 @@ VMiView_EditField_Create( M3tTextureMap_Big *texture_big; M3tTextureMap *texture; - + char temp_string[2]; UUtRect bounds; IMtPoint2D dest; - + UUtInt16 offset_x; UUtInt16 offset_y; - + // ------------------------------ // set the colors to draw with // ------------------------------ text_color = IMrPixel_FromShade(VMcControl_PixelType, VMcColor_Text); inPrivateData->erase_color = IMrPixel_FromShade(VMcControl_PixelType, VMcColor_Background); - + // ------------------------------ // create the text context // ------------------------------ @@ -154,7 +154,7 @@ VMiView_EditField_Create( desired_font_family = TScFontFamily_RomanSmall; else desired_font_family = TScFontFamily_Roman; - + if (inEditField->flags & VMcCommonFlag_Text_Bold) desired_font_style = TScStyle_Bold; else if (inEditField->flags & VMcCommonFlag_Text_Italic) @@ -169,7 +169,7 @@ VMiView_EditField_Create( desired_font_family, &font_family); UUmError_ReturnOnErrorMsg(error, "Unable to load font family"); - + // create a new text context error = TSrContext_New( @@ -193,13 +193,13 @@ VMiView_EditField_Create( inPrivateData->string[0] = 0; } } - + // ------------------------------ // create the string texture // ------------------------------ if (inPrivateData->string_texture == NULL) { - if ((inView->width > M3cTextureMap_MaxWidth) || + if ((inView->width > M3cTextureMap_MaxWidth) || (inView->height > M3cTextureMap_MaxHeight)) { // create a big texture map @@ -213,7 +213,7 @@ VMiView_EditField_Create( "edit field", &texture_big); UUmError_ReturnOnErrorMsg(error, "Unable to create texture map"); - + // clear the texture M3rTextureMap_Big_Fill(texture_big, inPrivateData->erase_color, M3cFillEntireMap); @@ -241,7 +241,7 @@ VMiView_EditField_Create( inPrivateData->string_texture = texture; } } - + // ------------------------------ // create the caret texture // ------------------------------ @@ -256,10 +256,10 @@ VMiView_EditField_Create( temp_string, &bounds); UUmError_ReturnOnErrorMsg(error, "Unable to get caret string rect"); - + inPrivateData->caret_width = bounds.right; inPrivateData->caret_height = bounds.bottom; - + // create the caret texture error = M3rTextureMap_New( @@ -271,14 +271,14 @@ VMiView_EditField_Create( "caret texture", &texture); UUmError_ReturnOnErrorMsg(error, "Unable to create texture map"); - + // clear the texture M3rTextureMap_Fill(texture, inPrivateData->erase_color, M3cFillEntireMap); - + // draw the caret into the texture dest.x = 0; dest.y = 0; - + error = TSrContext_DrawString( inPrivateData->text_context, @@ -287,18 +287,18 @@ VMiView_EditField_Create( &bounds, &dest); UUmError_ReturnOnErrorMsg(error, "Unable to draw string in texture"); - + inPrivateData->caret_texture = texture; } - + // ------------------------------ // calculate the text location // ------------------------------ inPrivateData->string_width = 0; inPrivateData->string_height = TSrFont_GetLineHeight( - TSrContext_GetFont(inPrivateData->text_context, TScStyle_InUse)); - + TSrContext_GetFont(inPrivateData->text_context, TScStyle_InUse)); + // calculate offset_x and offset_y offset_x = offset_y = 0; if (inEditField->flags & VMcCommonFlag_Text_HRight) @@ -307,10 +307,10 @@ VMiView_EditField_Create( offset_x = ((inView->width - inPrivateData->string_width) >> 1); if (inEditField->flags & VMcCommonFlag_Text_VCenter) offset_y = ((inView->height - inPrivateData->string_height) >> 1); - + inPrivateData->text_location.x = inEditField->text_location_offset.x + offset_x; inPrivateData->text_location.y = inEditField->text_location_offset.y + offset_y; - + return UUcError_None; } @@ -330,7 +330,7 @@ VMiView_EditField_Paint( alpha = VUcAlpha_Enabled; else alpha = VUcAlpha_Disabled; - + // draw the outline if (inEditField->outline) { @@ -342,14 +342,14 @@ VMiView_EditField_Paint( inView->height, alpha); } - + // draw the string if (inPrivateData->string_texture) { dest = *inDestination; dest.x += (float)inPrivateData->text_location.x; dest.y += (float)inPrivateData->text_location.y; - + VUrDrawTextureRef( inPrivateData->string_texture, &dest, @@ -357,7 +357,7 @@ VMiView_EditField_Paint( inPrivateData->string_height, alpha); } - + // draw the caret if ((inPrivateData->caret_texture) && (inPrivateData->caret_displayed) && @@ -366,7 +366,7 @@ VMiView_EditField_Paint( dest = *inDestination; dest.x += (float)(inPrivateData->text_location.x + inPrivateData->string_width); dest.y += (float)(inPrivateData->text_location.y); - + VUrDrawTextureRef( inPrivateData->caret_texture, &dest, @@ -385,24 +385,24 @@ VMiVew_EditField_HandleKeyDown( UUtUns16 inKey) { UUtBool handled; - + UUmAssert(inPrivateData->string); UUmAssert(inPrivateData->string_texture); UUmAssert(inPrivateData->text_context); - + // add the key to the string handled = TSrString_AppendChar( inPrivateData->string, inKey, inEditField->max_chars); - + // update the textures VMiView_EditField_UpdateTextures(inView, inEditField, inPrivateData); - + return handled; } - + // ====================================================================== #if 0 #pragma mark - @@ -420,29 +420,29 @@ VMrView_EditField_Callback( VMtView_EditField_PrivateData *private_data; UUtUns32 result; VMtView_PrivateData *view_private_data; - + // get the views data editfield = (VMtView_EditField*)inView->view_data; private_data = (VMtView_EditField_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_EditField_PrivateData, editfield); UUmAssert(private_data); - + // get the view's private data view_private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(view_private_data); - + result = 0; - + switch (inMessage) { case VMcMessage_Create: VMiView_EditField_Create(inView, editfield, private_data); - + private_data->has_focus = UUcFalse; private_data->caret_displayed = UUcFalse; private_data->string[0] = '\0'; return 0; - + case VMcMessage_KeyDown: result = VMiVew_EditField_HandleKeyDown( @@ -462,7 +462,7 @@ VMrView_EditField_Callback( (UUtUns32)inView); } return 0; - + case VMcMessage_SetFocus: if (inParam1) { @@ -474,11 +474,11 @@ VMrView_EditField_Callback( private_data->caret_displayed = UUcFalse; } return 0; - + case VMcMessage_Paint: // update the caret VMiView_EditField_UpdateCaret(inView, editfield, private_data); - + // draw the button VMiView_EditField_Paint( inView, @@ -486,21 +486,21 @@ VMrView_EditField_Callback( private_data, (M3tPointScreen*)inParam2); return 0; - + case VMcMessage_GetValue: return (UUtUns32)private_data->string; - + case VMcMessage_SetValue: { // copy the string UUrString_Copy(private_data->string, (char*)inParam1, editfield->max_chars); - + // update the textures VMiView_EditField_UpdateTextures(inView, editfield, private_data); } return 0; } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); } @@ -513,54 +513,54 @@ VMrView_EditField_ProcHandler( { VMtView_EditField *editfield; VMtView_EditField_PrivateData *private_data; - + // get a pointer to the button data editfield = (VMtView_EditField*)inInstancePtr; private_data = (VMtView_EditField_PrivateData*)inPrivateData; UUmAssert(private_data); - + switch (inMessage) { case TMcTemplateProcMessage_NewPostProcess: case TMcTemplateProcMessage_LoadPostProcess: // initalize the private data private_data->text_context = NULL; - private_data->string = NULL; + private_data->string = NULL; private_data->caret_texture = NULL; private_data->caret_width = 0; private_data->caret_height = 0; private_data->caret_displayed = UUcFalse; private_data->caret_time = 0; - + private_data->string_texture = NULL; private_data->string_width = editfield->text_location_offset.x; private_data->string_height = editfield->text_location_offset.y; - + private_data->has_focus = UUcFalse; break; - + case TMcTemplateProcMessage_DisposePreProcess: if (private_data->text_context) { TSrContext_Delete(private_data->text_context); private_data->text_context = NULL; } - + if (private_data->string) { UUrMemory_Block_Delete(private_data->string); private_data->string = NULL; } break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_EditField.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_EditField.h index 34e6e9a..720724a 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_EditField.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_EditField.h @@ -24,36 +24,36 @@ typedef tm_template('V', 'M', 'E', 'F', "VM View EditField") VMtView_EditField { - + UUtUns16 flags; UUtUns16 max_chars; - + IMtPoint2D text_location_offset; - + VMtPartSpec *outline; - + } VMtView_EditField; typedef struct VMtView_EditField_PrivateData { TStTextContext *text_context; char *string; - + IMtPoint2D text_location; - + tm_templateref caret_texture; UUtInt16 caret_width; UUtInt16 caret_height; UUtBool caret_displayed; UUtUns32 caret_time; - + tm_templateref string_texture; UUtInt16 string_width; UUtInt16 string_height; IMtPixel erase_color; - + UUtBool has_focus; - + } VMtView_EditField_PrivateData; extern TMtPrivateData* DMgTemplate_EditField_PrivateData; @@ -75,4 +75,4 @@ VMrView_EditField_ProcHandler( void* inPrivateData); // ====================================================================== -#endif /* VM_VIEW_EDITFIELD_H */ \ No newline at end of file +#endif /* VM_VIEW_EDITFIELD_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_ListBox.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_ListBox.c index fb2d9b8..b45cbaa 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_ListBox.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_ListBox.c @@ -29,7 +29,7 @@ typedef struct VMtView_ListBox_Entry { IMtPixel color; char string[VMcView_ListBox_MaxCharsPerEntry]; - + } VMtView_ListBox_Entry; // ====================================================================== @@ -58,7 +58,7 @@ VMiView_ListBox_AdjustScrollbar( inPrivateData->num_visible_entries); inPrivateData->scroll_pos = UUmMin(inPrivateData->scroll_pos, inPrivateData->scroll_max); - + // set the scrollbar range and position VMrView_Scrollbar_SetRange(inPrivateData->scrollbar, 0, inPrivateData->scroll_max); VMrView_Scrollbar_SetPosition(inPrivateData->scrollbar, inPrivateData->scroll_pos); @@ -80,7 +80,7 @@ VMiView_ListBox_Create( UUtUns16 i; UUtUns16 width; UUtUns16 height; - + // ------------------------------ // set up the scrollbar view // ------------------------------ @@ -88,31 +88,31 @@ VMiView_ListBox_Create( for (i = 0; i < inView->num_child_views; i++) { VMtView *child = (VMtView*)inView->child_views[i].view_ref; - + if (child->type == VMcViewType_Scrollbar) { inPrivateData->scrollbar = child; break; } } - + if (inPrivateData->scrollbar) { IMtPoint2D new_location; - + // set the location and height of the scrollbar new_location.x = inView->width - inPrivateData->scrollbar->width; new_location.y = 0; VMrView_SetLocation(inPrivateData->scrollbar, &new_location); VMrView_SetSize(inPrivateData->scrollbar, inPrivateData->scrollbar->width, inView->height); } - + // ------------------------------ // set the colors // ------------------------------ inPrivateData->text_background_color = IMrPixel_FromShade(VMcControl_PixelType, VMcColor_Background); inPrivateData->text_color = IMrPixel_FromShade(VMcControl_PixelType, VMcColor_Text); - + // ------------------------------ // create the text texture // ------------------------------ @@ -121,12 +121,12 @@ VMiView_ListBox_Create( // calculate the width, and height width = inView->width - 4; height = inView->height - 4; - + if (inPrivateData->scrollbar) { width -= (inPrivateData->scrollbar->width + 2); } - + // create the texture error = VUrCreate_Texture( @@ -134,12 +134,12 @@ VMiView_ListBox_Create( height, &inPrivateData->text_texture_ref); UUmError_ReturnOnErrorMsg(error, "Unable to create the texture"); - + // save the location, width, and height inPrivateData->text_texture_width = width; inPrivateData->text_texture_height = height; } - + // ------------------------------ // create the text context // ------------------------------ @@ -149,13 +149,13 @@ VMiView_ListBox_Create( char *desired_font_family; TStFontStyle desired_font_style; UUtUns16 desired_font_format; - + // interpret the flags if (inListBox->flags & VMcCommonFlag_Text_Small) desired_font_family = TScFontFamily_RomanSmall; else desired_font_family = TScFontFamily_Roman; - + if (inListBox->flags & VMcCommonFlag_Text_Bold) desired_font_style = TScStyle_Bold; else if (inListBox->flags & VMcCommonFlag_Text_Italic) @@ -177,7 +177,7 @@ VMiView_ListBox_Create( desired_font_family, &font_family); UUmError_ReturnOnErrorMsg(error, "Unable to load font family"); - + // create a new text context error = TSrContext_New( @@ -190,12 +190,12 @@ VMiView_ListBox_Create( // set the color of the text error = TSrContext_SetColor(inPrivateData->text_context, inPrivateData->text_color); UUmError_ReturnOnErrorMsg(error, "Unable to set the text color"); - + // get the height of the text inPrivateData->text_line_height = TSrFont_GetLineHeight(TSrContext_GetFont(inPrivateData->text_context, TScStyle_InUse)); } - + // ------------------------------ // allocate the text array // ------------------------------ @@ -210,16 +210,16 @@ VMiView_ListBox_Create( 0); UUmError_ReturnOnNull(inPrivateData->text_array); } - + // ------------------------------ // setup the scrollbar // ------------------------------ inPrivateData->scroll_pos = 0; inPrivateData->scroll_max = 0; - inPrivateData->num_visible_entries = + inPrivateData->num_visible_entries = (inPrivateData->text_texture_height / inPrivateData->text_line_height); VMiView_ListBox_AdjustScrollbar(inView, inPrivateData); - + // ------------------------------ // initialize the other vars // ------------------------------ @@ -248,24 +248,24 @@ VMiView_ListBox_Paint( M3tPointScreen *inDestination) { UUtUns16 alpha; - + // set the alpha if (inView->flags & VMcViewFlag_Enabled) alpha = VUcAlpha_Enabled; else alpha = VUcAlpha_Disabled; - + // draw the border and background if (inListBox->backborder) { UUtUns16 width; - + width = inView->width; if (inPrivateData->scrollbar) { width -= (inPrivateData->scrollbar->width + 2); } - + VUrDrawPartSpecification( inListBox->backborder, VMcPart_All, @@ -274,16 +274,16 @@ VMiView_ListBox_Paint( inView->height, alpha); } - + // draw the text if (inPrivateData->text_texture_ref) { M3tPointScreen dest; - + dest = *inDestination; dest.x += 2.0f; dest.y += 2.0f; - + VUrDrawTextureRef( inPrivateData->text_texture_ref, &dest, @@ -310,22 +310,22 @@ VMiView_ListBox_Update( VMtView_ListBox_Entry *array_pointer; UUtInt32 i; IMtPoint2D dest; - - // get the + + // get the font = TSrContext_GetFont(inPrivateData->text_context, TScStyle_InUse); line_height = TSrFont_GetLineHeight(font); descending_height = TSrFont_GetDescendingHeight(font); - + // set the bounds to draw in bounds.left = 0; bounds.top = 0; bounds.right = inPrivateData->text_texture_width; bounds.bottom = inPrivateData->text_texture_height; - + // get the array pointer - array_pointer = + array_pointer = (VMtView_ListBox_Entry*)UUrMemory_Array_GetMemory(inPrivateData->text_array); - + // erase the texture if ((inView->width > M3cTextureMap_MaxWidth) || (inView->height > M3cTextureMap_MaxHeight)) @@ -350,17 +350,17 @@ VMiView_ListBox_Update( inPrivateData->num_entries, (inPrivateData->scroll_pos + inPrivateData->num_visible_entries)); - + // draw the lines of text for (i = start_index, draw_line = 1; i < stop_index; i++, draw_line++) { // calculate the destination dest.x = VMcText_X_Offset; dest.y = (draw_line * line_height) - descending_height + VMcText_Y_Offset; - + // set the text color TSrContext_SetColor(inPrivateData->text_context, array_pointer[i].color); - + // draw the string TSrContext_DrawString( inPrivateData->text_context, @@ -375,17 +375,17 @@ VMiView_ListBox_Update( (inPrivateData->current_selection < stop_index)) { UUtRect invert_bounds; - + // calculate the draw_line draw_line = inPrivateData->current_selection - start_index + 1; - + // calculate the invert bounds invert_bounds.left = 0; invert_bounds.top = ((draw_line - 1) * line_height) + VMcText_Y_Offset + 1; invert_bounds.right = invert_bounds.left + inPrivateData->text_texture_width; invert_bounds.bottom = invert_bounds.top + inPrivateData->text_line_height; IMrRect_Inset(&invert_bounds, VMcText_X_Offset, 0); - + // draw the hilight box if ((inView->width > M3cTextureMap_MaxWidth) || (inView->height > M3cTextureMap_MaxHeight)) @@ -402,14 +402,14 @@ VMiView_ListBox_Update( inPrivateData->text_color, &invert_bounds); } - + // calculate the destination dest.x = VMcText_X_Offset; dest.y = (draw_line * line_height) - descending_height + VMcText_Y_Offset; - + // set the text color TSrContext_SetColor(inPrivateData->text_context, inPrivateData->text_background_color); - + // draw the string TSrContext_DrawString( inPrivateData->text_context, @@ -417,11 +417,11 @@ VMiView_ListBox_Update( array_pointer[inPrivateData->current_selection].string, &bounds, &dest); - + // reset the text color TSrContext_SetColor(inPrivateData->text_context, inPrivateData->text_color); } - + // clear the dirty field inPrivateData->text_texture_dirty = UUcFalse; } @@ -441,7 +441,7 @@ VMiView_ListBox_DeleteString( { // check the range if ((inIndex < 0) || (inIndex >= inPrivateData->num_entries)) return UUcFalse; - + // delete the element UUrMemory_Array_DeleteElement(inPrivateData->text_array, inIndex); @@ -450,7 +450,7 @@ VMiView_ListBox_DeleteString( // update the textures at a later time inPrivateData->text_texture_dirty = UUcTrue; - + return UUcTrue; } @@ -463,27 +463,27 @@ VMiView_ListBox_GetText( { UUtInt32 index; VMtView_ListBox_Entry *array_pointer; - + // set the index if (inIndex == -1) index = inPrivateData->current_selection; else index = inIndex; - + // check the bounds on the index if ((index < 0) || (index >= inPrivateData->num_entries)) return UUcFalse; - + // get the array pointer - array_pointer = + array_pointer = (VMtView_ListBox_Entry*)UUrMemory_Array_GetMemory(inPrivateData->text_array); - + // assume that ioString is big enough to hold the contents of the array UUrString_Copy_Length( ioString, array_pointer[index].string, VMcView_ListBox_MaxCharsPerEntry, TSrString_GetLength(array_pointer[index].string) + 1); - + return UUcTrue; } // ---------------------------------------------------------------------- @@ -495,23 +495,23 @@ VMiView_ListBox_GetTextLength( UUtInt32 index; VMtView_ListBox_Entry *array_pointer; UUtUns16 string_length; - + // set the index if (inIndex == -1) index = inPrivateData->current_selection; else index = inIndex; - + // check the bounds on the index if ((index < 0) || (index >= inPrivateData->num_entries)) return 0; - + // get the array pointer - array_pointer = + array_pointer = (VMtView_ListBox_Entry*)UUrMemory_Array_GetMemory(inPrivateData->text_array); - + // assume that ioString is big enough to hold the contents of the array string_length = TSrString_GetLength(array_pointer[index].string); - + return string_length; } @@ -526,14 +526,14 @@ VMiView_ListBox_ReplaceString( { WMtListBox_Item *items; VMtView_ListBox_Entry *array_pointer; - + // CB: check that we are within the bounds of the array if ((inIndex < 0) || (inIndex >= inPrivateData->num_entries)) { return LBcInvalidIndex; } // get the array pointer - array_pointer = + array_pointer = (VMtView_ListBox_Entry*)UUrMemory_Array_GetMemory(inPrivateData->text_array); // copy the string into the entry @@ -541,13 +541,13 @@ VMiView_ListBox_ReplaceString( array_pointer[inIndex].string, inString, VMcView_ListBox_MaxCharsPerEntry); - + // set the default color array_pointer[inIndex].color = inPrivateData->text_color; - + // update the textures at a later time inPrivateData->text_texture_dirty = UUcTrue; - + return (UUtInt32) inIndex; } @@ -564,7 +564,7 @@ VMiView_ListBox_InsertString( UUtBool mem_moved; VMtView_ListBox_Entry *array_pointer; UUtInt32 index; - + // make room in the array if (inIndex != -1) { @@ -575,7 +575,7 @@ VMiView_ListBox_InsertString( inIndex, &mem_moved); if (error != UUcError_None) return LBcInvalidIndex; - + index = inIndex; } else @@ -588,12 +588,12 @@ VMiView_ListBox_InsertString( &mem_moved); if (error != UUcError_None) return LBcInvalidIndex; } - + // update the number of entries inPrivateData->num_entries++; - + // get the array pointer - array_pointer = + array_pointer = (VMtView_ListBox_Entry*)UUrMemory_Array_GetMemory(inPrivateData->text_array); // copy the string into the entry @@ -601,16 +601,16 @@ VMiView_ListBox_InsertString( array_pointer[index].string, inString, VMcView_ListBox_MaxCharsPerEntry); - + // set the default color array_pointer[index].color = inPrivateData->text_color; - + // adjust the scrollbar VMiView_ListBox_AdjustScrollbar(inView, inPrivateData); // update the textures at a later time inPrivateData->text_texture_dirty = UUcTrue; - + return (UUtInt32)index; } @@ -622,7 +622,7 @@ VMiView_ListBox_Reset( VMtView_ListBox_PrivateData *inPrivateData) { UUtUns32 num_elements; - + // clear the array num_elements = UUrMemory_Array_GetUsedElems(inPrivateData->text_array); if (num_elements == 0) @@ -630,22 +630,22 @@ VMiView_ListBox_Reset( inPrivateData->num_entries = 0; return UUcTrue; } - + // delete all the elements in the array while (num_elements--) { UUrMemory_Array_DeleteElement(inPrivateData->text_array, num_elements); } - + // no more entries inPrivateData->num_entries = 0; - + // adjust the scrollbar VMiView_ListBox_AdjustScrollbar(inView, inPrivateData); // update the textures at a later time inPrivateData->text_texture_dirty = UUcTrue; - + return UUcTrue; } @@ -660,7 +660,7 @@ VMiView_ListBox_SetSelection( UUtBool inNotifyParent) { UUtInt32 diff; - + // clear the selection if (inIndex == -1) { @@ -669,27 +669,27 @@ VMiView_ListBox_SetSelection( // update the textures at a later time inPrivateData->text_texture_dirty = UUcTrue; - + return UUcTrue; } - + // check the bounds on the index if ((inIndex < 0) || (inIndex >= inPrivateData->num_entries)) return UUcFalse; - + // set the selection inPrivateData->current_selection = inIndex; - + // update the textures at a later time inPrivateData->text_texture_dirty = UUcTrue; - + // adjust the list to see the newly selected diff = inPrivateData->scroll_pos - (UUtInt32)inPrivateData->current_selection; if (diff > 0) { // current selection is above the scroll pos in the list - if (((UUtInt32)inPrivateData->current_selection - diff) < inPrivateData->scroll_pos) + if (((UUtInt32)inPrivateData->current_selection - diff) < inPrivateData->scroll_pos) { - // the scroll position needs to be changed to make the + // the scroll position needs to be changed to make the // current selection visible inPrivateData->scroll_pos = (UUtInt32)inPrivateData->current_selection; } @@ -705,7 +705,7 @@ VMiView_ListBox_SetSelection( 1; } } - + if (inNotifyParent) { // tell the parent @@ -715,7 +715,7 @@ VMiView_ListBox_SetSelection( UUmMakeLong(LBcNotify_SelectionChanged, inView->id), (UUtUns32)inView); } - + return UUcTrue; } @@ -743,13 +743,13 @@ VMiView_ListBox_SetLineColor( } // get the array pointer - array_pointer = + array_pointer = (VMtView_ListBox_Entry*)UUrMemory_Array_GetMemory(inPrivateData->text_array); - + // set the text color of the line array_pointer[inIndex].color = *inPixel; } - + return UUcTrue; } @@ -769,9 +769,9 @@ VMiView_ListBox_HandleKeyDown( { UUtBool handled; UUtInt32 new_selection; - + handled = UUcTrue; - + switch (inKey) { case LIcKeyCode_UpArrow: @@ -787,7 +787,7 @@ VMiView_ListBox_HandleKeyDown( UUcTrue); } break; - + case LIcKeyCode_DownArrow: new_selection = inPrivateData->current_selection + 1; if (new_selection < (UUtInt32)inPrivateData->num_entries) @@ -799,14 +799,14 @@ VMiView_ListBox_HandleKeyDown( inPrivateData, new_selection, UUcTrue); - } + } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -818,9 +818,9 @@ VMiView_ListBox_HandleLMouseUp( VMtView_ListBox *inListBox, VMtView_ListBox_PrivateData *inPrivateData, IMtPoint2D *inLocalPoint) -{ +{ UUtInt32 selected_entry; - + // the point is in local coordinates so check to see // if it is withing the text display area if ((inLocalPoint->x > inPrivateData->text_texture_width) || @@ -829,12 +829,12 @@ VMiView_ListBox_HandleLMouseUp( // the point is outside the text display area return; } - + // figure out which entry the user clicked on selected_entry = ((inLocalPoint->y - VMcText_Y_Offset) / inPrivateData->text_line_height) + (UUtInt16)UUmMax(0, inPrivateData->scroll_pos); - + // set the selected entry if ((selected_entry < 0) || (selected_entry >= inPrivateData->num_entries)) { @@ -875,41 +875,41 @@ VMiView_ListBox_HandleVerticalScroll( UUtUns32 inParam2) { UUtInt32 scroll_increment; - + // interpret the parameters of the message switch (UUmLowWord(inParam1)) { case SBcNotify_LineUp: scroll_increment = -1; break; - + case SBcNotify_LineDown: scroll_increment = 1; break; - + case SBcNotify_PageUp: scroll_increment = UUmMin( -1, -inPrivateData->text_texture_height / inPrivateData->text_line_height); break; - + case SBcNotify_PageDown: scroll_increment = UUmMax( 1, inPrivateData->text_texture_height / inPrivateData->text_line_height); break; - + case SBcNotify_ThumbPosition: scroll_increment = inParam2 - inPrivateData->scroll_pos; break; - + default: scroll_increment = 0; break; } - + // calculat the increment scroll_increment = UUmMax( @@ -917,7 +917,7 @@ VMiView_ListBox_HandleVerticalScroll( UUmMin( scroll_increment, inPrivateData->scroll_max - inPrivateData->scroll_pos)); - + // adjust the the thumb position and redraw the texture if (scroll_increment != 0) { @@ -947,24 +947,24 @@ VMrView_ListBox_Callback( VMtView_ListBox_PrivateData *private_data; UUtBool result; UUtInt32 index; - + // get the data view_private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(view_private_data); listbox = (VMtView_ListBox*)inView->view_data; private_data = (VMtView_ListBox_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_ListBox_PrivateData, listbox); UUmAssert(private_data); - + switch (inMessage) { case VMcMessage_Create: VMiView_ListBox_Create(inView, listbox, private_data); return 0; - + case VMcMessage_Destroy: VMiView_ListBox_Destroy(inView, listbox, private_data); return 0; - + case VMcMessage_KeyDown: result = VMiView_ListBox_HandleKeyDown( @@ -974,15 +974,15 @@ VMrView_ListBox_Callback( private_data, (UUtUns16)inParam1); return (UUtUns32)result; - + case VMcMessage_LMouseDown: return 0; - + case VMcMessage_LMouseUp: { IMtPoint2D global_mouse_loc; IMtPoint2D local_mouse_loc; - + // get the mouse location in local coordinates global_mouse_loc.x = (UUtInt16)UUmHighWord(inParam1); global_mouse_loc.y = (UUtInt16)UUmLowWord(inParam1); @@ -996,7 +996,7 @@ VMrView_ListBox_Callback( &local_mouse_loc); } return 0; - + case VMcMessage_LMouseDblClck: // tell the parent VMrView_SendMessage( @@ -1005,14 +1005,14 @@ VMrView_ListBox_Callback( UUmMakeLong(VMcNotify_DoubleClick, inView->id), (UUtUns32)inView); return 0; - + case VMcMessage_Paint: // update the texture if it is dirty if (private_data->text_texture_dirty) { VMiView_ListBox_Update(inView, listbox, private_data); } - + // draw the button VMiView_ListBox_Paint( inView, @@ -1020,7 +1020,7 @@ VMrView_ListBox_Callback( private_data, (M3tPointScreen*)inParam2); break; - + case LBcMessage_AddString: index = VMiView_ListBox_InsertString( @@ -1030,7 +1030,7 @@ VMrView_ListBox_Callback( -1, (char*)inParam2); return (UUtUns32)index; - + case LBcMessage_ReplaceString: result = VMiView_ListBox_ReplaceString( @@ -1049,9 +1049,9 @@ VMrView_ListBox_Callback( private_data, (UUtInt32)inParam1); return (UUtUns32)result; - + case LBcMessage_InsertString: - index = + index = VMiView_ListBox_InsertString( inView, listbox, @@ -1059,13 +1059,13 @@ VMrView_ListBox_Callback( (UUtInt32)inParam1, (char*)inParam2); return (UUtUns32)index; - + case LBcMessage_GetNumLines: return (UUtUns32)private_data->num_entries; - + case LBcMessage_GetCurrentSelection: return (UUtUns32)private_data->current_selection; - + case LBcMessage_GetText: result = VMiView_ListBox_GetText( @@ -1073,14 +1073,14 @@ VMrView_ListBox_Callback( (UUtInt32)inParam1, (char*)inParam2); return (UUtUns32)result; - + case LBcMessage_GetTextLength: return (UUtUns32)VMiView_ListBox_GetTextLength(private_data, (UUtInt32)inParam1); - + case LBcMessage_Reset: VMiView_ListBox_Reset(inView, listbox, private_data); return 0; - + case LBcMessage_SetSelection: result = VMiView_ListBox_SetSelection( @@ -1091,7 +1091,7 @@ VMrView_ListBox_Callback( (UUtInt32)inParam1, UUcFalse); return (UUtUns32)result; - + case LBcMessage_SetLineColor: result = VMiView_ListBox_SetLineColor( @@ -1101,7 +1101,7 @@ VMrView_ListBox_Callback( (UUtInt32)inParam1, (IMtPixel*)inParam2); return (UUtUns32)result; - + case SBcMessage_VerticalScroll: VMiView_ListBox_HandleVerticalScroll( inView, @@ -1111,7 +1111,7 @@ VMrView_ListBox_Callback( inParam2); return 0; } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); } @@ -1124,12 +1124,12 @@ VMrView_ListBox_ProcHandler( { VMtView_ListBox *listbox; VMtView_ListBox_PrivateData *private_data; - + // get the data listbox = (VMtView_ListBox*)inInstancePtr; private_data = (VMtView_ListBox_PrivateData*)inPrivateData; UUmAssert(private_data); - + switch (inMessage) { case TMcTemplateProcMessage_NewPostProcess: @@ -1146,14 +1146,14 @@ VMrView_ListBox_ProcHandler( private_data->scroll_pos = 0; private_data->num_visible_entries = 0; break; - + case TMcTemplateProcMessage_DisposePreProcess: if (private_data->text_context) { TSrContext_Delete(private_data->text_context); private_data->text_context = NULL; } - + if (private_data->text_array) { UUrMemory_Array_Delete(private_data->text_array); @@ -1161,15 +1161,15 @@ VMrView_ListBox_ProcHandler( private_data->num_entries = 0; } break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_ListBox.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_ListBox.h index 9dd0334..1ce5783 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_ListBox.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_ListBox.h @@ -23,12 +23,12 @@ typedef tm_template('V', 'M', 'L', 'B', "VM View ListBox") VMtView_ListBox { - + VMtPartSpec *backborder; - + UUtUns16 flags; UUtUns16 reserved; - + } VMtView_ListBox; typedef struct VMtView_ListBox_PrivateData @@ -39,7 +39,7 @@ typedef struct VMtView_ListBox_PrivateData UUtUns16 text_texture_height; IMtPixel text_background_color; UUtBool text_texture_dirty; - + // text data TStTextContext *text_context; UUtMemory_Array *text_array; @@ -50,12 +50,12 @@ typedef struct VMtView_ListBox_PrivateData UUtInt16 num_entries; UUtUns16 num_visible_entries; UUtInt32 current_selection; - + // scrollbar VMtView *scrollbar; UUtInt32 scroll_max; UUtInt32 scroll_pos; - + } VMtView_ListBox_PrivateData; extern TMtPrivateData* DMgTemplate_ListBox_PrivateData; @@ -77,4 +77,4 @@ VMrView_ListBox_ProcHandler( void* inPrivateData); // ====================================================================== -#endif /* VM_VIEW_LISTBOX_H */ \ No newline at end of file +#endif /* VM_VIEW_LISTBOX_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Picture.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Picture.c index 86a46f8..d7ca46f 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Picture.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Picture.c @@ -22,13 +22,13 @@ VMiView_Picture_Paint( M3tPointScreen *inDestination) { UUtUns16 alpha; - + // set the alpha if (inView->flags & VMcViewFlag_Enabled) alpha = VUcAlpha_Enabled; else alpha = VUcAlpha_Disabled; - + if (inPicture->partspec) { VUrDrawPartSpecification( @@ -63,10 +63,10 @@ VMrView_Picture_Callback( UUtUns32 inParam2) { VMtView_Picture *picture; - + // get a pointer to the picture data picture = (VMtView_Picture*)inView->view_data; - + switch (inMessage) { case VMcMessage_Paint: @@ -77,6 +77,6 @@ VMrView_Picture_Callback( (M3tPointScreen*)inParam2); break; } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Picture.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Picture.h index 9e865ed..22b9d8c 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Picture.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Picture.h @@ -17,16 +17,16 @@ typedef tm_template('V', 'M', '_', 'P', "VM View Picture") VMtView_Picture { - + VMtTextureList *b_textures; // background textures VMtPartSpec *partspec; - + } VMtView_Picture; typedef struct VMtView_Picture_PrivateData { UUtUns16 unused; - + } VMtView_Picture_PrivateData; // ====================================================================== @@ -40,4 +40,4 @@ VMrView_Picture_Callback( UUtUns32 inParam2); // ====================================================================== -#endif /* VM_VIEW_PICTURE_H */ \ No newline at end of file +#endif /* VM_VIEW_PICTURE_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioButton.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioButton.c index 4103da8..cf24c85 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioButton.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioButton.c @@ -23,7 +23,7 @@ VMiView_RadioButton_Create( VMtView_RadioButton_PrivateData *inPrivateData) { UUtError error; - + // ------------------------------ // setup the radiobutton // ------------------------------ @@ -38,14 +38,14 @@ VMiView_RadioButton_Create( inRadioButton->off->part_matrix_br[VMcColumn_Left][VMcRow_Top].y - inRadioButton->off->part_matrix_tl[VMcColumn_Left][VMcRow_Top].y; } - + // ------------------------------ // set up the title texture // ------------------------------ if (inPrivateData->title_texture_ref == NULL) { UUtRect bounds; - + // create the title_texture_ref error = VUrCreate_StringTexture( @@ -53,11 +53,11 @@ VMiView_RadioButton_Create( inRadioButton->flags, &inPrivateData->title_texture_ref, &bounds); - + // save the width and height of the title inPrivateData->title_texture_width = bounds.right; inPrivateData->title_texture_height = bounds.bottom; - + // calculate the text location if (inRadioButton->off && inRadioButton->on) { @@ -65,7 +65,7 @@ VMiView_RadioButton_Create( inPrivateData->title_location.x = inPrivateData->radiobutton_width + VMcRadioButton_TextOffset_X; - + // center it relative to the picture inPrivateData->title_location.y = (inPrivateData->radiobutton_height - @@ -136,7 +136,7 @@ VMiView_RadioButton_Paint( dest = *inDestination; dest.x += (float)inPrivateData->title_location.x; dest.y += (float)inPrivateData->title_location.y; - + VUrDrawTextureRef( inPrivateData->title_texture_ref, &dest, @@ -162,21 +162,21 @@ VMrView_RadioButton_Callback( VMtView_RadioButton *radiobutton; VMtView_RadioButton_PrivateData *private_data; VMtView_PrivateData *view_private_data; - + // get pointers to the data radiobutton = (VMtView_RadioButton*)inView->view_data; private_data = (VMtView_RadioButton_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_RadioButton_PrivateData, radiobutton); UUmAssert(private_data); - + view_private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); - + switch (inMessage) { case VMcMessage_Create: VMiView_RadioButton_Create(inView, radiobutton, private_data); return 0; - + case VMcMessage_LMouseUp: VMrView_SendMessage( inView, @@ -184,7 +184,7 @@ VMrView_RadioButton_Callback( !private_data->radiobutton_state, 0); return 0; - + case VMcMessage_Paint: // draw the button VMiView_RadioButton_Paint( @@ -193,7 +193,7 @@ VMrView_RadioButton_Callback( private_data, (M3tPointScreen*)inParam2); return 0; - + case VMcMessage_GetValue: return (UUtUns32)private_data->radiobutton_state; @@ -204,7 +204,7 @@ VMrView_RadioButton_Callback( { private_data->radiobutton_state = VMcRadioButton_On; } - + if (view_private_data->parent != NULL) { if (private_data->radiobutton_state == VMcRadioButton_Off) @@ -226,7 +226,7 @@ VMrView_RadioButton_Callback( } return 0; } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); } @@ -239,7 +239,7 @@ VMrView_RadioButton_ProcHandler( { VMtView_RadioButton *radiobutton; VMtView_RadioButton_PrivateData *private_data; - + // get pointers to the data radiobutton = (VMtView_RadioButton*)inInstancePtr; private_data = (VMtView_RadioButton_PrivateData*)inPrivateData; @@ -255,17 +255,17 @@ VMrView_RadioButton_ProcHandler( private_data->title_texture_width = 0; private_data->title_texture_height = 0; break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioButton.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioButton.h index 0d3cf36..769be4d 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioButton.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioButton.h @@ -32,15 +32,15 @@ enum typedef tm_template('V', 'M', 'R', 'B', "VM View RadioButton") VMtView_RadioButton { - + UUtUns16 flags; UUtUns16 reserved; - + VMtPartSpec *off; VMtPartSpec *on; - + char title[32]; - + } VMtView_RadioButton; typedef struct VMtView_RadioButton_PrivateData @@ -48,13 +48,13 @@ typedef struct VMtView_RadioButton_PrivateData UUtBool radiobutton_state; UUtUns16 radiobutton_width; UUtUns16 radiobutton_height; - + // vars for title text tm_templateref title_texture_ref; UUtInt16 title_texture_width; UUtInt16 title_texture_height; IMtPoint2D title_location; - + } VMtView_RadioButton_PrivateData; extern TMtPrivateData* DMgTemplate_RadioButton_PrivateData; @@ -77,4 +77,4 @@ VMrView_RadioButton_ProcHandler( void* inPrivateData); // ====================================================================== -#endif /* VM_VIEW_RADIOBUTTON_H */ \ No newline at end of file +#endif /* VM_VIEW_RADIOBUTTON_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioGroup.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioGroup.c index 1c6c538..d54f92a 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioGroup.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioGroup.c @@ -30,7 +30,7 @@ VMiView_RadioGroup_Create( { UUtUns16 i; IMtPoint2D dest; - + // ------------------------------ // set the location and state of the child views // ------------------------------ @@ -44,23 +44,23 @@ VMiView_RadioGroup_Create( dest.x = 0; dest.y = 0; } - + for (i = 0; i < inView->num_child_views; i++) { VMtView *child; - + child = (VMtView*)inView->child_views[i].view_ref; - + VMrView_SetValue(child, VMcRadioButton_Off); VMrView_SetLocation(child, &dest); - + dest.y += child->height + 4; } - + // turn the first child in the group on inPrivateData->current_radiobutton = (VMtView*)inView->child_views[0].view_ref; VMrView_SetValue(inPrivateData->current_radiobutton, VMcRadioButton_On); - + return UUcError_None; } @@ -78,7 +78,7 @@ VMiView_RadioGroup_Command( { // turn off the current radio button VMrView_SetValue(inPrivateData->current_radiobutton, VMcRadioButton_Off); - + // set the new current radiobutton inPrivateData->current_radiobutton = inRadioButton; } @@ -93,7 +93,7 @@ VMiView_RadioGroup_Paint( M3tPointScreen *inDestination) { UUtUns16 alpha; - + // set the alpha if (inView->flags & VMcViewFlag_Enabled) alpha = VUcAlpha_Enabled; @@ -128,18 +128,18 @@ VMrView_RadioGroup_Callback( { VMtView_RadioGroup *radiogroup; VMtView_RadioGroup_PrivateData *private_data; - + radiogroup = (VMtView_RadioGroup*)inView->view_data; private_data = (VMtView_RadioGroup_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_RadioGroup_PrivateData, radiogroup); UUmAssert(private_data); - + switch (inMessage) { case VMcMessage_Create: VMiView_RadioGroup_Create(inView, radiogroup, private_data); return 0; - + case VMcMessage_Command: VMiView_RadioGroup_Command( inView, @@ -148,7 +148,7 @@ VMrView_RadioGroup_Callback( (UUtUns16)UUmHighWord(inParam1), (VMtView*)inParam2); return 0; - + case VMcMessage_Paint: // draw the button VMiView_RadioGroup_Paint( @@ -158,7 +158,7 @@ VMrView_RadioGroup_Callback( (M3tPointScreen*)inParam2); break; // break to paint the child views } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); } @@ -171,7 +171,7 @@ VMrView_RadioGroup_ProcHandler( { VMtView_RadioGroup *radiobutton; VMtView_RadioGroup_PrivateData *private_data; - + // get pointers to the data radiobutton = (VMtView_RadioGroup*)inInstancePtr; private_data = (VMtView_RadioGroup_PrivateData*)inPrivateData; @@ -184,17 +184,17 @@ VMrView_RadioGroup_ProcHandler( // initalize the private data private_data->current_radiobutton = NULL; break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioGroup.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioGroup.h index 94e910b..03285c2 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioGroup.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_RadioGroup.h @@ -17,15 +17,15 @@ typedef tm_template('V', 'M', 'R', 'G', "VM View RadioGroup") VMtView_RadioGroup { - + VMtPartSpec *outline; - + } VMtView_RadioGroup; typedef struct VMtView_RadioGroup_PrivateData { VMtView *current_radiobutton; - + } VMtView_RadioGroup_PrivateData; extern TMtPrivateData* DMgTemplate_RadioGroup_PrivateData; @@ -47,4 +47,4 @@ VMrView_RadioGroup_ProcHandler( void* inPrivateData); // ====================================================================== -#endif /* VM_VIEW_RADIOGROUP_H */ \ No newline at end of file +#endif /* VM_VIEW_RADIOGROUP_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Scrollbar.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Scrollbar.c index fb9e04b..582c9fb 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Scrollbar.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Scrollbar.c @@ -30,34 +30,34 @@ VMiView_Scrollbar_SetThumbLocation( float scale; float range; float current_val; - + // calculate the range range = (float)(inPrivateData->max - inPrivateData->min); current_val = (float)(inPrivateData->current_value - inPrivateData->min); - + if (inPrivateData->is_vertical) { float bounds_height; - + // calculate the bounds height bounds_height = (float)(inPrivateData->thumb_move_bounds.bottom - inPrivateData->thumb_move_bounds.top - inPrivateData->thumb_height); - + // calculate the scale scale = bounds_height / range; - + // set the thumb location inPrivateData->thumb_location.x = inPrivateData->thumb_x_track; - inPrivateData->thumb_location.y = + inPrivateData->thumb_location.y = inPrivateData->thumb_move_bounds.top + (UUtUns16)(current_val * scale); - + // set the page up and page down bounds inPrivateData->page_up_bounds = inPrivateData->thumb_move_bounds; inPrivateData->page_up_bounds.bottom = inPrivateData->thumb_location.y; - + inPrivateData->page_dn_bounds = inPrivateData->thumb_move_bounds; inPrivateData->page_dn_bounds.top = inPrivateData->thumb_location.y + @@ -66,26 +66,26 @@ VMiView_Scrollbar_SetThumbLocation( else { float bounds_width; - + // calculate the bounds width bounds_width = (float)(inPrivateData->thumb_move_bounds.right - inPrivateData->thumb_move_bounds.left - inPrivateData->thumb_width); - + // calculate the scale scale = bounds_width / range; - + // set the thumb location - inPrivateData->thumb_location.x = + inPrivateData->thumb_location.x = inPrivateData->thumb_move_bounds.left + (UUtUns16)(current_val * scale); inPrivateData->thumb_location.y = inPrivateData->thumb_y_track; - + // set the page up and page down bounds inPrivateData->page_up_bounds = inPrivateData->thumb_move_bounds; inPrivateData->page_up_bounds.right = inPrivateData->thumb_location.x; - + inPrivateData->page_dn_bounds = inPrivateData->thumb_move_bounds; inPrivateData->page_dn_bounds.left = inPrivateData->thumb_location.x + @@ -102,29 +102,29 @@ VMiView_Scrollbar_GetNewValue( float scale; float range; UUtInt32 new_value; - + // calculate the range range = (float)(inPrivateData->max - inPrivateData->min); - + if (inPrivateData->is_vertical) { float bounds_height; UUtInt32 y_value; - + // calculate the new value - y_value = + y_value = (UUtInt32)(inMouseLocation->y - inPrivateData->thumb_move_bounds.top); - + // calculate the bounds height bounds_height = (float)(inPrivateData->thumb_move_bounds.bottom - inPrivateData->thumb_move_bounds.top - inPrivateData->thumb_height); - + // calculate the scale scale = range / bounds_height; - + // calculate the new value new_value = inPrivateData->min + (UUtInt32)((float)y_value * scale); } @@ -132,25 +132,25 @@ VMiView_Scrollbar_GetNewValue( { float bounds_width; UUtInt32 x_value; - + // calculate the new value - x_value = + x_value = (UUtInt32)(inMouseLocation->x - inPrivateData->thumb_move_bounds.left); - + // calculate the bounds width bounds_width = (float)(inPrivateData->thumb_move_bounds.right - inPrivateData->thumb_move_bounds.left - inPrivateData->thumb_width); - + // calculate the scale scale = range / bounds_width; - + // calculate the new value new_value = inPrivateData->min + (UUtInt32)((float)x_value * scale); } - + // keep new_value within range if (new_value < inPrivateData->min) new_value = inPrivateData->min; @@ -178,32 +178,32 @@ VMiView_Scrollbar_SetBounds( UUtUns16 up_arrow_width; UUtUns16 dn_arrow_height; UUtUns16 dn_arrow_width; - + up_arrow_width = (inScrollbar->vertical_scrollbar->part_matrix_br[VMcColumn_Left][VMcRow_Top].x - inScrollbar->vertical_scrollbar->part_matrix_tl[VMcColumn_Left][VMcRow_Top].x); up_arrow_height = (inScrollbar->vertical_scrollbar->part_matrix_br[VMcColumn_Left][VMcRow_Top].y - inScrollbar->vertical_scrollbar->part_matrix_tl[VMcColumn_Left][VMcRow_Top].y); - + dn_arrow_width = (inScrollbar->vertical_scrollbar->part_matrix_br[VMcColumn_Left][VMcRow_Bottom].x - inScrollbar->vertical_scrollbar->part_matrix_tl[VMcColumn_Left][VMcRow_Bottom].x); dn_arrow_height = (inScrollbar->vertical_scrollbar->part_matrix_br[VMcColumn_Left][VMcRow_Bottom].y - inScrollbar->vertical_scrollbar->part_matrix_tl[VMcColumn_Left][VMcRow_Bottom].y); - + inPrivateData->up_arrow_bounds.left = 0; inPrivateData->up_arrow_bounds.top = 0; inPrivateData->up_arrow_bounds.right = up_arrow_width; inPrivateData->up_arrow_bounds.bottom = up_arrow_height; - + inPrivateData->dn_arrow_bounds.left = inView->width - dn_arrow_width; inPrivateData->dn_arrow_bounds.top = inView->height - dn_arrow_height; inPrivateData->dn_arrow_bounds.right = inView->width; inPrivateData->dn_arrow_bounds.bottom = inView->height; } - + // ------------------------------ // initialize the thumb data // ------------------------------ @@ -212,21 +212,21 @@ VMiView_Scrollbar_SetBounds( inPrivateData->thumb_width = inScrollbar->vertical_thumb->part_matrix_br[VMcColumn_Left][VMcRow_Top].x - inScrollbar->vertical_thumb->part_matrix_tl[VMcColumn_Left][VMcRow_Top].x; - + inPrivateData->thumb_height = inScrollbar->vertical_thumb->part_matrix_br[VMcColumn_Left][VMcRow_Top].y - inScrollbar->vertical_thumb->part_matrix_tl[VMcColumn_Left][VMcRow_Top].y; - + inPrivateData->thumb_move_bounds.left = 0; inPrivateData->thumb_move_bounds.top = inPrivateData->up_arrow_bounds.bottom; inPrivateData->thumb_move_bounds.right = inView->width; inPrivateData->thumb_move_bounds.bottom = inPrivateData->dn_arrow_bounds.top; - + IMrRect_Inset(&inPrivateData->thumb_move_bounds, 1, 1); - + inPrivateData->thumb_x_track = (inView->width - inPrivateData->thumb_width) >> 1; inPrivateData->thumb_y_track = (inView->height - inPrivateData->thumb_height) >> 1; - + VMiView_Scrollbar_SetThumbLocation(inPrivateData); } } @@ -241,32 +241,32 @@ VMiView_Scrollbar_SetBounds( UUtUns16 up_arrow_width; UUtUns16 dn_arrow_height; UUtUns16 dn_arrow_width; - + up_arrow_width = (inScrollbar->horizontal_scrollbar->part_matrix_br[VMcColumn_Left][VMcRow_Top].x - inScrollbar->horizontal_scrollbar->part_matrix_tl[VMcColumn_Left][VMcRow_Top].x); up_arrow_height = (inScrollbar->horizontal_scrollbar->part_matrix_br[VMcColumn_Left][VMcRow_Top].y - inScrollbar->horizontal_scrollbar->part_matrix_tl[VMcColumn_Left][VMcRow_Top].y); - + dn_arrow_width = (inScrollbar->horizontal_scrollbar->part_matrix_br[VMcColumn_Right][VMcRow_Top].x - inScrollbar->horizontal_scrollbar->part_matrix_tl[VMcColumn_Right][VMcRow_Top].x); dn_arrow_height = (inScrollbar->horizontal_scrollbar->part_matrix_br[VMcColumn_Right][VMcRow_Top].y - inScrollbar->horizontal_scrollbar->part_matrix_tl[VMcColumn_Right][VMcRow_Top].y); - + inPrivateData->up_arrow_bounds.left = 0; inPrivateData->up_arrow_bounds.top = 0; inPrivateData->up_arrow_bounds.right = up_arrow_width; inPrivateData->up_arrow_bounds.bottom = up_arrow_height; - + inPrivateData->dn_arrow_bounds.left = inView->width - dn_arrow_width; inPrivateData->dn_arrow_bounds.top = 0; inPrivateData->dn_arrow_bounds.right = inView->width; inPrivateData->dn_arrow_bounds.bottom = dn_arrow_height; } - + // ------------------------------ // initialize the thumb data // ------------------------------ @@ -275,21 +275,21 @@ VMiView_Scrollbar_SetBounds( inPrivateData->thumb_width = inScrollbar->horizontal_thumb->part_matrix_br[VMcColumn_Left][VMcRow_Top].x - inScrollbar->horizontal_thumb->part_matrix_tl[VMcColumn_Left][VMcRow_Top].x; - + inPrivateData->thumb_height = inScrollbar->horizontal_thumb->part_matrix_br[VMcColumn_Left][VMcRow_Top].y - inScrollbar->horizontal_thumb->part_matrix_tl[VMcColumn_Left][VMcRow_Top].y; - + inPrivateData->thumb_move_bounds.left = inPrivateData->up_arrow_bounds.right; inPrivateData->thumb_move_bounds.top = 0; inPrivateData->thumb_move_bounds.right = inPrivateData->dn_arrow_bounds.left; inPrivateData->thumb_move_bounds.bottom = inView->height; - + IMrRect_Inset(&inPrivateData->thumb_move_bounds, 1, 1); - + inPrivateData->thumb_x_track = (inView->width - inPrivateData->thumb_width) >> 1; inPrivateData->thumb_y_track = (inView->height - inPrivateData->thumb_height) >> 1; - + VMiView_Scrollbar_SetThumbLocation(inPrivateData); } } @@ -311,14 +311,14 @@ VMiView_Scrollbar_Create( // initialize the scrollbar private data // ------------------------------ UUrMemory_Clear(inPrivateData, sizeof(VMtView_Scrollbar_PrivateData)); - + inPrivateData->is_vertical = inView->height > inView->width; inPrivateData->min = 0; inPrivateData->max = 100; inPrivateData->current_value = 0; - + VMiView_Scrollbar_SetBounds(inView, inScrollbar, inPrivateData); - + // ------------------------------ // start the timer // ------------------------------ @@ -344,21 +344,21 @@ VMiView_Scrollbar_HandleMouseEvent( UUtBool in_thumb_bounds; UUtRect thumb_bounds; UUtInt32 new_value; - - + + // set the thumb_bounds thumb_bounds.left = inPrivateData->thumb_location.x; thumb_bounds.top = inPrivateData->thumb_location.y; thumb_bounds.right = thumb_bounds.left + inPrivateData->thumb_width; thumb_bounds.bottom = thumb_bounds.top + inPrivateData->thumb_height; - + // determine where the mouse is in_page_up_bounds = IMrRect_PointIn(&inPrivateData->page_up_bounds, inMouseLocation); in_page_dn_bounds = IMrRect_PointIn(&inPrivateData->page_dn_bounds, inMouseLocation); in_up_arrow_bounds = IMrRect_PointIn(&inPrivateData->up_arrow_bounds, inMouseLocation); in_dn_arrow_bounds = IMrRect_PointIn(&inPrivateData->dn_arrow_bounds, inMouseLocation); in_thumb_bounds = IMrRect_PointIn(&thumb_bounds, inMouseLocation); - + switch (inMessage) { case VMcMessage_MouseMove: @@ -369,7 +369,7 @@ VMiView_Scrollbar_HandleMouseEvent( VMiView_Scrollbar_GetNewValue( inPrivateData, inMouseLocation); - + // tell the parent of the thumb move VMrView_SendMessage( inViewPrivateData->parent, @@ -378,7 +378,7 @@ VMiView_Scrollbar_HandleMouseEvent( (UUtInt32)new_value); } break; - + case VMcMessage_LMouseDown: inPrivateData->mouse_state |= VMcMouseState_MouseDown; DMrDialog_SetMouseFocusView(NULL, inView); @@ -427,7 +427,7 @@ VMiView_Scrollbar_HandleMouseEvent( VMiView_Scrollbar_GetNewValue( inPrivateData, inMouseLocation); - + // tell the parent of the thumb move VMrView_SendMessage( inViewPrivateData->parent, @@ -441,7 +441,7 @@ VMiView_Scrollbar_HandleMouseEvent( } } break; - + case VMcMessage_LMouseUp: inPrivateData->mouse_state &= ~VMcMouseState_MouseDown; inPrivateData->mouse_down_in_thumb = UUcFalse; @@ -466,7 +466,7 @@ VMiView_Scrollbar_Paint( alpha = VUcAlpha_Enabled; else alpha = VUcAlpha_Disabled; - + if (inPrivateData->is_vertical) { // draw the scrollbar @@ -480,14 +480,14 @@ VMiView_Scrollbar_Paint( inView->height, alpha); } - + // draw the thumb if (inScrollbar->vertical_thumb) { dest = *inDestination; dest.x += (float)inPrivateData->thumb_location.x; dest.y += (float)inPrivateData->thumb_location.y; - + VUrDrawPartSpecification( inScrollbar->vertical_thumb, VMcPart_LeftTop, @@ -510,14 +510,14 @@ VMiView_Scrollbar_Paint( inView->height, alpha); } - + // draw the thumb if (inScrollbar->horizontal_thumb) { dest = *inDestination; dest.x += (float)inPrivateData->thumb_location.x; dest.y += (float)inPrivateData->thumb_location.y; - + VUrDrawPartSpecification( inScrollbar->horizontal_thumb, VMcPart_LeftTop, @@ -545,10 +545,10 @@ VMrView_Scrollbar_Callback( VMtView_PrivateData *view_private_data; VMtView_Scrollbar *scrollbar; VMtView_Scrollbar_PrivateData *private_data; - + IMtPoint2D global_mouse_loc; IMtPoint2D local_mouse_loc; - + // get the data view_private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(view_private_data); @@ -558,22 +558,22 @@ VMrView_Scrollbar_Callback( private_data = (VMtView_Scrollbar_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Scrollbar_PrivateData, scrollbar); UUmAssert(private_data); - + switch (inMessage) { case VMcMessage_Create: VMiView_Scrollbar_Create(inView, scrollbar, private_data); return 0; - + case VMcMessage_Timer: if ((private_data->mouse_state & VMcMouseState_MouseDown) && (inParam2 == VMcView_Scrollbar_Timer)) { LItInputEvent event; - + LIrInputEvent_GetMouse(&event); VMrView_PointGlobalToView(inView, &event.where, &local_mouse_loc); - + VMiView_Scrollbar_HandleMouseEvent( inView, view_private_data, @@ -583,7 +583,7 @@ VMrView_Scrollbar_Callback( &local_mouse_loc); } return 0; - + case VMcMessage_MouseMove: case VMcMessage_MouseLeave: case VMcMessage_LMouseDown: @@ -593,7 +593,7 @@ VMrView_Scrollbar_Callback( global_mouse_loc.x = (UUtInt16)UUmHighWord(inParam1); global_mouse_loc.y = (UUtInt16)UUmLowWord(inParam1); VMrView_PointGlobalToView(inView, &global_mouse_loc, &local_mouse_loc); - + VMiView_Scrollbar_HandleMouseEvent( inView, view_private_data, @@ -603,7 +603,7 @@ VMrView_Scrollbar_Callback( &local_mouse_loc); } return 0; - + case VMcMessage_Paint: // draw the slider VMiView_Scrollbar_Paint( @@ -612,7 +612,7 @@ VMrView_Scrollbar_Callback( private_data, (M3tPointScreen*)inParam2); return 0; - + case VMcMessage_Size: VMiView_Scrollbar_SetBounds( inView, @@ -620,7 +620,7 @@ VMrView_Scrollbar_Callback( private_data); return 0; } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); } @@ -631,14 +631,14 @@ VMrView_Scrollbar_GetPosition( { VMtView_Scrollbar *scrollbar; VMtView_Scrollbar_PrivateData *private_data; - + if (inView == NULL) return 0; - + // get a pointer to the scrollbar data scrollbar = (VMtView_Scrollbar*)inView->view_data; private_data = (VMtView_Scrollbar_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Scrollbar_PrivateData, scrollbar); UUmAssert(private_data); - + // set the new range values return private_data->current_value; } @@ -652,16 +652,16 @@ VMrView_Scrollbar_GetRange( { VMtView_Scrollbar *scrollbar; VMtView_Scrollbar_PrivateData *private_data; - + *outMin = 0; *outMax = 0; if (inView == NULL) return; - + // get a pointer to the scrollbar data scrollbar = (VMtView_Scrollbar*)inView->view_data; private_data = (VMtView_Scrollbar_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Scrollbar_PrivateData, scrollbar); UUmAssert(private_data); - + *outMin = private_data->min; *outMax = private_data->max; } @@ -675,7 +675,7 @@ VMrView_Scrollbar_ProcHandler( { VMtView_Scrollbar *scrollbar; VMtView_Scrollbar_PrivateData *private_data; - + // get a pointer to the scrollbar data scrollbar = (VMtView_Scrollbar*)inInstancePtr; private_data = (VMtView_Scrollbar_PrivateData*)inPrivateData; @@ -690,18 +690,18 @@ VMrView_Scrollbar_ProcHandler( private_data->max = 100; private_data->current_value = 0; break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } @@ -713,17 +713,17 @@ VMrView_Scrollbar_SetPosition( { VMtView_Scrollbar *scrollbar; VMtView_Scrollbar_PrivateData *private_data; - + if (inView == NULL) return; - + // get a pointer to the scrollbar data scrollbar = (VMtView_Scrollbar*)inView->view_data; private_data = (VMtView_Scrollbar_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Scrollbar_PrivateData, scrollbar); UUmAssert(private_data); - + // set the new range values private_data->current_value = inPosition; - + // make sure the new value is within the range if (private_data->current_value < private_data->min) private_data->current_value = private_data->min; @@ -742,18 +742,18 @@ VMrView_Scrollbar_SetRange( { VMtView_Scrollbar *scrollbar; VMtView_Scrollbar_PrivateData *private_data; - + if (inView == NULL) return; - + // get a pointer to the scrollbar data scrollbar = (VMtView_Scrollbar*)inView->view_data; private_data = (VMtView_Scrollbar_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Scrollbar_PrivateData, scrollbar); UUmAssert(private_data); - + // set the new range values private_data->min = inMin; private_data->max = inMax; private_data->current_value = inMin; - + VMiView_Scrollbar_SetThumbLocation(private_data); } diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Scrollbar.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Scrollbar.h index e1df283..204462f 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Scrollbar.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Scrollbar.h @@ -37,13 +37,13 @@ enum typedef tm_template('V', 'M', 'S', 'B', "VM View Scrollbar") VMtView_Scrollbar { - + VMtPartSpec *vertical_scrollbar; VMtPartSpec *vertical_thumb; - + VMtPartSpec *horizontal_scrollbar; VMtPartSpec *horizontal_thumb; - + } VMtView_Scrollbar; typedef struct VMtView_Scrollbar_PrivateData @@ -51,12 +51,12 @@ typedef struct VMtView_Scrollbar_PrivateData UUtBool is_vertical; UUtUns8 mouse_state; UUtBool mouse_down_in_thumb; - + // scrollbar values UUtInt32 min; UUtInt32 max; UUtInt32 current_value; - + // thumb data UUtRect thumb_move_bounds; IMtPoint2D thumb_location; @@ -64,13 +64,13 @@ typedef struct VMtView_Scrollbar_PrivateData UUtUns16 thumb_height; UUtUns16 thumb_x_track; UUtUns16 thumb_y_track; - + // scrollbar areas UUtRect up_arrow_bounds; UUtRect dn_arrow_bounds; UUtRect page_up_bounds; UUtRect page_dn_bounds; - + } VMtView_Scrollbar_PrivateData; extern TMtPrivateData* DMgTemplate_Scrollbar_PrivateData; @@ -94,7 +94,7 @@ VMrView_Scrollbar_GetRange( VMtView *inView, UUtInt32 *outMin, UUtInt32 *outMax); - + UUtError VMrView_Scrollbar_ProcHandler( TMtTemplateProc_Message inMessage, @@ -113,4 +113,4 @@ VMrView_Scrollbar_SetRange( UUtInt32 inMax); // ====================================================================== -#endif /* VM_VIEW_SCROLLBAR_H */ \ No newline at end of file +#endif /* VM_VIEW_SCROLLBAR_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Slider.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Slider.c index 97b2250..8b60ddb 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Slider.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Slider.c @@ -45,51 +45,51 @@ VMiView_Slider_HandleHorizontalScroll( UUtInt32 min; UUtInt32 max; UUtInt32 current_pos; - + // get the scroll range current_pos = VMrView_Scrollbar_GetPosition(inPrivateData->scrollbar); VMrView_Scrollbar_GetRange(inPrivateData->scrollbar, &min, &max); scroll_range = max - min; - + // interpret the parameters of the message switch (UUmLowWord(inParam1)) { case SBcNotify_LineUp: scroll_increment = -1; break; - + case SBcNotify_LineDown: scroll_increment = 1; break; - + case SBcNotify_PageUp: scroll_increment = UUmMin(-1, -scroll_range / 10); break; - + case SBcNotify_PageDown: scroll_increment = UUmMax(1, scroll_range / 10); break; - + case SBcNotify_ThumbPosition: scroll_increment = inParam2 - current_pos; break; - + default: scroll_increment = 0; break; } - + // adjust the the thumb position and redraw the texture if (scroll_increment != 0) { VMtView_PrivateData *view_private_data; - + view_private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(view_private_data); - + current_pos += scroll_increment; VMrView_Scrollbar_SetPosition(inPrivateData->scrollbar, current_pos); - + // tell the parent about the new slider value VMrView_SendMessage( view_private_data->parent, @@ -112,7 +112,7 @@ VMiView_Slider_Create( VMtView_Slider_PrivateData *inPrivateData) { UUtError error; - + // ------------------------------ // create title texture // ------------------------------ @@ -120,7 +120,7 @@ VMiView_Slider_Create( (TSrString_GetLength(inSlider->title) > 0)) { UUtRect string_bounds; - + error = VUrCreate_StringTexture( inSlider->title, @@ -128,15 +128,15 @@ VMiView_Slider_Create( &inPrivateData->title_texture_ref, &string_bounds); UUmError_ReturnOnErrorMsg(error, "Unable to create title texture for the button"); - + // get the title_texture_width and title_texture_height inPrivateData->title_texture_width = string_bounds.right; inPrivateData->title_texture_height = string_bounds.bottom; - + inPrivateData->title_location.x = 4; inPrivateData->title_location.y = 2; } - + // ------------------------------ // initialize the scrollbar // ------------------------------ @@ -147,7 +147,7 @@ VMiView_Slider_Create( { IMtPoint2D new_location; UUtUns16 new_width; - + if (inSlider->outline) { new_location.x = 4; @@ -160,7 +160,7 @@ VMiView_Slider_Create( new_location.y = inView->height - inPrivateData->scrollbar->height; new_width = inView->width; } - + VMrView_SetLocation(inPrivateData->scrollbar, &new_location); VMrView_SetSize(inPrivateData->scrollbar, new_width, inPrivateData->scrollbar->height); @@ -172,7 +172,7 @@ VMiView_Slider_Create( inPrivateData->scrollbar = NULL; } } - + return UUcError_None; } @@ -192,7 +192,7 @@ VMiView_Slider_Paint( alpha = VUcAlpha_Enabled; else alpha = VUcAlpha_Disabled; - + // draw the outline if (inSlider->outline) { @@ -204,14 +204,14 @@ VMiView_Slider_Paint( inView->height, alpha); } - + // draw the title if (inPrivateData->title_texture_ref) { dest = *inDestination; dest.x += (float)inPrivateData->title_location.x; dest.y += (float)inPrivateData->title_location.y; - + VUrDrawTextureRef( inPrivateData->title_texture_ref, &dest, @@ -236,7 +236,7 @@ VMrView_Slider_Callback( { VMtView_Slider *slider; VMtView_Slider_PrivateData *private_data; - + // get the data slider = (VMtView_Slider*)inView->view_data; private_data = (VMtView_Slider_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Slider_PrivateData, slider); @@ -247,7 +247,7 @@ VMrView_Slider_Callback( case VMcMessage_Create: VMiView_Slider_Create(inView, slider, private_data); return 0; - + case VMcMessage_Paint: // draw the slider VMiView_Slider_Paint( @@ -266,7 +266,7 @@ VMrView_Slider_Callback( inParam2); return 0; } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); } @@ -277,15 +277,15 @@ VMrView_Slider_GetPosition( { VMtView_Slider *slider; VMtView_Slider_PrivateData *private_data; - + UUmAssert(inView); - + // get a pointer to the data slider = (VMtView_Slider*)inView->view_data; private_data = (VMtView_Slider_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Slider_PrivateData, slider); UUmAssert(private_data); UUmAssert(private_data->scrollbar); - + // set the new range values return VMrView_Scrollbar_GetPosition(private_data->scrollbar); } @@ -299,7 +299,7 @@ VMrView_Slider_ProcHandler( { VMtView_Slider *slider; VMtView_Slider_PrivateData *private_data; - + // get a pointer to the button data slider = (VMtView_Slider*)inInstancePtr; private_data = (VMtView_Slider_PrivateData*)inPrivateData; @@ -313,18 +313,18 @@ VMrView_Slider_ProcHandler( private_data->title_texture_ref = NULL; private_data->scrollbar = NULL; break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } @@ -336,9 +336,9 @@ VMrView_Slider_SetPosition( { VMtView_Slider *slider; VMtView_Slider_PrivateData *private_data; - + UUmAssert(inView); - + // get a pointer to the data slider = (VMtView_Slider*)inView->view_data; private_data = (VMtView_Slider_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Slider_PrivateData, slider); @@ -358,15 +358,15 @@ VMrView_Slider_SetRange( { VMtView_Slider *slider; VMtView_Slider_PrivateData *private_data; - + UUmAssert(inView); - + // get a pointer to the data slider = (VMtView_Slider*)inView->view_data; private_data = (VMtView_Slider_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Slider_PrivateData, slider); UUmAssert(private_data); UUmAssert(private_data->scrollbar); - + // set the new range values VMrView_Scrollbar_SetRange(private_data->scrollbar, inMin, inMax); } diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Slider.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Slider.h index 623b360..9933326 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Slider.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Slider.h @@ -28,14 +28,14 @@ enum typedef tm_template('V', 'M', '_', 'S', "VM View Slider") VMtView_Slider { - + UUtUns16 flags; UUtUns16 reserved; - + VMtPartSpec *outline; char title[32]; - + } VMtView_Slider; typedef struct VMtView_Slider_PrivateData @@ -45,7 +45,7 @@ typedef struct VMtView_Slider_PrivateData IMtPoint2D title_location; UUtUns16 title_texture_width; UUtUns16 title_texture_height; - + // scrollbar VMtView *scrollbar; @@ -66,7 +66,7 @@ VMrView_Slider_Callback( UUtInt32 VMrView_Slider_GetPosition( VMtView *inView); - + UUtError VMrView_Slider_ProcHandler( TMtTemplateProc_Message inMessage, @@ -83,6 +83,6 @@ VMrView_Slider_SetRange( VMtView *inView, UUtInt32 inMin, UUtInt32 inMax); - + // ====================================================================== -#endif /* VM_VIEW_SLIDER_H */ \ No newline at end of file +#endif /* VM_VIEW_SLIDER_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Tab.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Tab.c index 2b9afab..8ad8b68 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Tab.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Tab.c @@ -26,7 +26,7 @@ VMiView_Tab_Create( if (inTab->outline) { UUtUns16 tab_button_height; - + // calculate the tab_button height tab_button_height = 0; if (inTab->tab_button) @@ -34,23 +34,23 @@ VMiView_Tab_Create( tab_button_height = inTab->tab_button->part_matrix_br[VMcColumn_Left][VMcRow_Bottom].y - inTab->tab_button->part_matrix_tl[VMcColumn_Left][VMcRow_Top].y; - + // take off a little bit for the overlap tab_button_height -= 2; } - + // set the outline location, width, and height inPrivateData->outline_location.x = 0; inPrivateData->outline_location.y = tab_button_height; - + inPrivateData->outline_width = inView->width; inPrivateData->outline_height = inView->height - tab_button_height; } - + // init the private data inPrivateData->focused_view = NULL; inPrivateData->tab_callback = NULL; - + return UUcError_None; } @@ -64,7 +64,7 @@ VMiView_Tab_Paint( { UUtUns16 alpha; M3tPointScreen dest; - + // set the alpha if (inView->flags & VMcViewFlag_Enabled) alpha = VUcAlpha_Enabled; @@ -76,7 +76,7 @@ VMiView_Tab_Paint( dest = *inDestination; dest.x += (float)inPrivateData->outline_location.x; dest.y += (float)inPrivateData->outline_location.y; - + VUrDrawPartSpecification( inTab->outline, VMcPart_All, @@ -85,13 +85,13 @@ VMiView_Tab_Paint( inPrivateData->outline_height, alpha); } - + if (inTab->tab_button) { dest = *inDestination; dest.x += (float)inPrivateData->tab_button_location.x; dest.y += (float)inPrivateData->tab_button_location.y; - + VUrDrawPartSpecification( inTab->tab_button, VMcPart_All, @@ -110,12 +110,12 @@ VMiView_Tab_SetFocus( UUtBool inIsFocused) { VMtView *view; - + if (inIsFocused) { // get the next focasable view view = VMrView_GetNextFocusableView(inView, inPrivateData->focused_view); - + if (view && (view != inPrivateData->focused_view)) { // turn off focus on the previous view @@ -123,10 +123,10 @@ VMiView_Tab_SetFocus( { VMrView_SetFocus(inPrivateData->focused_view, UUcFalse); } - + // focus on the found view VMrView_SetFocus(view, UUcTrue); - + // save the new view inPrivateData->focused_view = view; } @@ -135,7 +135,7 @@ VMiView_Tab_SetFocus( { // turn off focus on the previous view VMrView_SetFocus(inPrivateData->focused_view, UUcFalse); - + // no views in the tab have the focus when the tab doesn't // have the focus. inPrivateData->focused_view = NULL; @@ -156,14 +156,14 @@ VMrView_Tab_SetFocusOnView( { VMrView_SetFocus(inPrivateData->focused_view, UUcFalse); } - + // focus on inFocusOnVIew VMrView_SetFocus(inFocusOnView, UUcTrue); - + // save the new view inPrivateData->focused_view = inFocusOnView; } -} +} // ====================================================================== #if 0 @@ -179,23 +179,23 @@ VMrView_Tab_SetTabCallback( VMtView_Tab *tab; VMtView_Tab_PrivateData *private_data; UUtBool result; - + UUmAssert(inView); - + // get the private data tab = (VMtView_Tab*)inView->view_data; private_data = (VMtView_Tab_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Tab_PrivateData, tab); UUmAssert(private_data); - + private_data->tab_callback = inTabCallback; - + // call the create functions result = UUcFalse; if (private_data->tab_callback) { result = private_data->tab_callback(inView, TbcMessage_InitTab, 0, 0); } - + return result; } @@ -211,14 +211,14 @@ VMrView_Tab_Callback( VMtView_Tab_PrivateData *private_data; UUtBool result; VMtView_PrivateData *view_private_data; - + result = UUcFalse; - + // get the private data tab = (VMtView_Tab*)inView->view_data; private_data = (VMtView_Tab_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Tab_PrivateData, tab); UUmAssert(private_data); - + view_private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); UUmAssert(view_private_data); @@ -232,24 +232,24 @@ VMrView_Tab_Callback( result = private_data->tab_callback(inView, inMessage, inParam1, inParam2); } } - + switch (inMessage) { case VMcMessage_Create: VMiView_Tab_Create(inView, tab, private_data); return 0; - + case VMcMessage_Command: if (result == UUcFalse) { VMtView *child = (VMtView*)inParam2; - + switch (child->type) { case VMcViewType_EditField: VMrView_Tab_SetFocusOnView(inView, private_data, child); break; - + default: // propogate commands up the hiearchy in this case the // parent should always be a tabgroup @@ -262,7 +262,7 @@ VMrView_Tab_Callback( } } return 0; - + case VMcMessage_KeyDown: if (private_data->focused_view) { @@ -283,7 +283,7 @@ VMrView_Tab_Callback( } } return 0; - + case VMcMessage_Paint: // draw the tab VMiView_Tab_Paint( @@ -292,12 +292,12 @@ VMrView_Tab_Callback( private_data, (M3tPointScreen*)inParam2); break; - + case VMcMessage_SetFocus: VMiView_Tab_SetFocus(inView, private_data, (UUtBool)inParam1); return 0; } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); } @@ -310,12 +310,12 @@ VMrView_Tab_ProcHandler( { VMtView_Tab *tab; VMtView_Tab_PrivateData *private_data; - + // get a pointer to the button data tab = (VMtView_Tab*)inInstancePtr; private_data = (VMtView_Tab_PrivateData*)inPrivateData; UUmAssert(private_data); - + switch (inMessage) { case TMcTemplateProcMessage_NewPostProcess: @@ -324,18 +324,18 @@ VMrView_Tab_ProcHandler( private_data->focused_view = NULL; private_data->tab_callback = NULL; break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Tab.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Tab.h index 684d826..d92cebf 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Tab.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Tab.h @@ -24,23 +24,23 @@ typedef UUtBool typedef tm_template('V', 'M', 'T', 'B', "VM View Tab") VMtView_Tab { - + VMtPartSpec *tab_button; VMtPartSpec *outline; - + } VMtView_Tab; typedef struct VMtView_Tab_PrivateData { VMtView *focused_view; VMtTabCallback tab_callback; - + IMtPoint2D outline_location; UUtUns16 outline_width; UUtUns16 outline_height; - + IMtPoint2D tab_button_location; - + } VMtView_Tab_PrivateData; extern TMtPrivateData* DMgTemplate_Tab_PrivateData; @@ -52,14 +52,14 @@ UUtBool VMrView_Tab_SetTabCallback( VMtView *inView, VMtTabCallback inTabCallback); - + UUtUns32 VMrView_Tab_Callback( VMtView *inView, VMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2); - + UUtError VMrView_Tab_ProcHandler( TMtTemplateProc_Message inMessage, @@ -67,4 +67,4 @@ VMrView_Tab_ProcHandler( void* inPrivateData); // ====================================================================== -#endif /* VM_VIEW_TAB_H */ \ No newline at end of file +#endif /* VM_VIEW_TAB_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_TabGroup.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_TabGroup.c index c7fa230..0fa5347 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_TabGroup.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_TabGroup.c @@ -20,7 +20,7 @@ VMiView_TabGroup_Create( { VMtView_TabGroup_PrivateData *private_data; UUtUns16 i; - + if (inView->view_data == NULL) { // allocate memory for the private data @@ -28,11 +28,11 @@ VMiView_TabGroup_Create( (VMtView_TabGroup_PrivateData*)UUrMemory_Block_New( sizeof(VMtView_TabGroup_PrivateData)); UUmError_ReturnOnNull(private_data); - + // store the private data inView->view_data = private_data; } - + // hide all of the tabs except the first one for (i = 0; i < inView->num_child_views; i++) { @@ -48,7 +48,7 @@ VMiView_TabGroup_Create( VMrView_SetVisible(view, UUcFalse); } } - + return UUcError_None; } @@ -90,15 +90,15 @@ VMrView_TabGroup_ActivateTab( { UUtUns16 i; VMtView_TabGroup_PrivateData *private_data; - + private_data = (VMtView_TabGroup_PrivateData*)inTabGroup->view_data; UUmAssert(private_data); - + // find the tab with inTabID for (i = 0; i < inTabGroup->num_child_views; i++) { VMtView *child = (VMtView*)inTabGroup->child_views[i].view_ref; - + if (child->id == inTabID) { // turn off the current tab @@ -110,37 +110,37 @@ VMrView_TabGroup_ActivateTab( // hide the current tab VMrView_SetVisible(private_data->current_tab, UUcFalse); } - + // don't reshow the tab that was just turned off (this is how the tabs toggle) if (child != private_data->current_tab) { // show the desired tab VMrView_SetVisible(child, UUcTrue); - + // turn on its focus (focus must be done when the tab is visible) VMrView_SetFocus(child, UUcTrue); - + // the child is now the current tab private_data->current_tab = child; } else { // revert to the first tab - private_data->current_tab = + private_data->current_tab = (VMtView*)inTabGroup->child_views[0].view_ref; - + // show the desired tab VMrView_SetVisible(private_data->current_tab, UUcTrue); - + // turn on its focus (focus must be done when the tab is visible) VMrView_SetFocus(private_data->current_tab, UUcTrue); } - + break; } } } - + // ---------------------------------------------------------------------- UUtUns32 VMrView_TabGroup_Callback( @@ -150,31 +150,31 @@ VMrView_TabGroup_Callback( UUtUns32 inParam2) { VMtView_TabGroup_PrivateData *private_data; - + // get the private data private_data = (VMtView_TabGroup_PrivateData*)inView->view_data; if (inMessage != VMcMessage_Create) { UUmAssert(private_data); } - + switch (inMessage) { case VMcMessage_Create: VMiView_TabGroup_Create(inView); return 0; - + case VMcMessage_Destroy: VMiView_TabGroup_Destroy(inView, private_data); return 0; - + case VMcMessage_Command: { VMtView_PrivateData *view_private_data; - + view_private_data = (VMtView_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_View_PrivateData, inView); - + VMrView_SendMessage( view_private_data->parent, inMessage, @@ -182,7 +182,7 @@ VMrView_TabGroup_Callback( inParam2); } return 0; - + case VMcMessage_KeyDown: if (private_data->current_tab) { @@ -200,12 +200,12 @@ VMrView_TabGroup_Callback( VMrView_SetFocus(private_data->current_tab, (UUtBool)inParam1); } return 0; - + case VMcMessage_Paint: // only draw the currently active tab VMiView_TabGroup_Paint(inView, private_data, inParam1, inParam2); return 0; // tabgroups decide which tab to draw and draw it } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_TabGroup.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_TabGroup.h index 8e3b62b..922bc6a 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_TabGroup.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_TabGroup.h @@ -16,7 +16,7 @@ typedef struct VMtView_TabGroup_PrivateData { VMtView *current_tab; - + } VMtView_TabGroup_PrivateData; // ====================================================================== @@ -35,4 +35,4 @@ VMrView_TabGroup_Callback( UUtUns32 inParam2); // ====================================================================== -#endif /* VM_VIEW_TABGROUP_H */ \ No newline at end of file +#endif /* VM_VIEW_TABGROUP_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Text.c b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Text.c index d7a0fa3..a98ff03 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Text.c +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Text.c @@ -26,26 +26,26 @@ VMiView_Text_Update( UUtError error; UUtRect bounds; IMtPoint2D dest; - + // clear the texture VUrClearTexture( inPrivateData->text_texture_ref, NULL, IMrPixel_FromShade(VMcControl_PixelType, IMcShade_None)); - + // set the bounds bounds.left = 0; bounds.top = 0; bounds.right = inView->width; bounds.bottom = inView->height; - + // set the dest dest.x = inText->text_location_offset.x; dest.y = inText->text_location_offset.y + inPrivateData->font_line_height - inPrivateData->font_descending_height; - + // draw the text into the texture map error = TSrContext_DrawString( @@ -55,7 +55,7 @@ VMiView_Text_Update( &bounds, &dest); UUmError_ReturnOnErrorMsg(error, "Unable to draw string in texture"); - + return UUcError_None; } @@ -67,7 +67,7 @@ VMiView_Text_Create( VMtView_Text_PrivateData *inPrivateData) { UUtError error; - + TStFont *font; TStFontFamily *font_family; char *desired_font_family; @@ -87,7 +87,7 @@ VMiView_Text_Create( &inPrivateData->text_texture_ref); UUmError_ReturnOnErrorMsg(error, "Unable to create the background texture"); } - + // ------------------------------ // create the text context // ------------------------------ @@ -98,24 +98,24 @@ VMiView_Text_Create( desired_font_family = TScFontFamily_RomanSmall; else desired_font_family = TScFontFamily_Roman; - + if (inText->flags & VMcCommonFlag_Text_Bold) desired_font_style = TScStyle_Bold; else if (inText->flags & VMcCommonFlag_Text_Italic) desired_font_style = TScStyle_Italic; else desired_font_style = TScStyle_Plain; - + if (inText->flags & VMcCommonFlag_Text_HCenter) desired_font_format = TSc_HCenter; else if (inText->flags & VMcCommonFlag_Text_HRight) desired_font_format = TSc_HRight; else desired_font_format = TSc_HLeft; - + if (inText->flags & VMcCommonFlag_Text_VCenter) desired_font_format |= TSc_VCenter; - + // get the font family error = TMrInstance_GetDataPtr( @@ -123,7 +123,7 @@ VMiView_Text_Create( desired_font_family, &font_family); UUmError_ReturnOnErrorMsg(error, "Unable to load font family"); - + // create a new text context error = TSrContext_New( @@ -132,23 +132,23 @@ VMiView_Text_Create( desired_font_format, &inPrivateData->text_context); UUmError_ReturnOnErrorMsg(error, "Unable to create text context"); - + // set the color of the text white = IMrPixel_FromShade(VMcControl_PixelType, IMcShade_White); error = TSrContext_SetColor(inPrivateData->text_context, white); UUmError_ReturnOnErrorMsg(error, "Unable to set the text color"); - + // get the font heights font = TSrContext_GetFont(inPrivateData->text_context, TScStyle_InUse); inPrivateData->font_line_height = TSrFont_GetLineHeight(font); inPrivateData->font_descending_height = TSrFont_GetDescendingHeight(font); } - + // ------------------------------ // draw the title onto the title_texture_ref // ------------------------------ VMiView_Text_Update(inView, inText, inPrivateData); - + return UUcError_None; } @@ -181,7 +181,7 @@ VMiView_Text_Paint( alpha = VUcAlpha_Enabled; else alpha = VUcAlpha_Disabled; - + if (inText->outline) { VUrDrawPartSpecification( @@ -192,7 +192,7 @@ VMiView_Text_Paint( inView->height, alpha); } - + if (inPrivateData->text_texture_ref) { VUrDrawTextureRef( @@ -219,22 +219,22 @@ VMrView_Text_Callback( { VMtView_Text *text; VMtView_Text_PrivateData *private_data; - + // get a pointer to the data text = (VMtView_Text*)inView->view_data; private_data = (VMtView_Text_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(DMgTemplate_Text_PrivateData, text); UUmAssert(private_data); - + switch (inMessage) { case VMcMessage_Create: VMiView_Text_Create(inView, text, private_data); return 0; - + case VMcMessage_Destroy: VMiView_Text_Destroy(inView, text, private_data); return 0; - + case VMcMessage_Paint: // draw the button VMiView_Text_Paint( @@ -243,13 +243,13 @@ VMrView_Text_Callback( private_data, (M3tPointScreen*)inParam2); return 0; - + case VMcMessage_SetValue: UUrString_Copy(text->string, (char*)inParam1, VMcView_Text_MaxStringLength); VMiView_Text_Update(inView, text, private_data); return 0; } - + return VMrView_DefaultCallback(inView, inMessage, inParam1, inParam2); } @@ -262,7 +262,7 @@ VMrView_Text_ProcHandler( { VMtView_Text *text; VMtView_Text_PrivateData *private_data; - + // get a pointer to the button data text = (VMtView_Text*)inInstancePtr; private_data = (VMtView_Text_PrivateData*)inPrivateData; @@ -278,17 +278,17 @@ VMrView_Text_ProcHandler( private_data->font_line_height = 0; private_data->font_descending_height = 0; break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Text.h b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Text.h index 6ab7eef..040a350 100644 --- a/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Text.h +++ b/BungieFrameWork/BFW_Source/BFW_DialogManager/VM_Views/VM_View_Text.h @@ -22,16 +22,16 @@ typedef tm_template('V', 'M', 'T', 'X', "VM View Text") VMtView_Text { - + UUtUns16 flags; UUtUns16 reserved; - + IMtPoint2D text_location_offset; - + VMtPartSpec *outline; - + char string[128]; - + } VMtView_Text; typedef struct VMtView_Text_PrivateData @@ -40,7 +40,7 @@ typedef struct VMtView_Text_PrivateData TStTextContext *text_context; UUtUns16 font_line_height; UUtUns16 font_descending_height; - + } VMtView_Text_PrivateData; extern TMtPrivateData* DMgTemplate_Text_PrivateData; @@ -62,4 +62,4 @@ VMrView_Text_ProcHandler( void* inPrivateData); // ====================================================================== -#endif /* VM_VIEW_TEXT_H */ \ No newline at end of file +#endif /* VM_VIEW_TEXT_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Effect/BFW_Effect.c b/BungieFrameWork/BFW_Source/BFW_Effect/BFW_Effect.c index 0db9797..be56c10 100644 --- a/BungieFrameWork/BFW_Source/BFW_Effect/BFW_Effect.c +++ b/BungieFrameWork/BFW_Source/BFW_Effect/BFW_Effect.c @@ -1,12 +1,12 @@ /* FILE: BFW_Effects.c - + AUTHOR: Brent Pease - + CREATED: Oct 8, 1999 - + PURPOSE: effects engine - + Copyright 1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Effect/BFW_Effect_Private.h b/BungieFrameWork/BFW_Source/BFW_Effect/BFW_Effect_Private.h index c94ca94..eaced99 100644 --- a/BungieFrameWork/BFW_Source/BFW_Effect/BFW_Effect_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Effect/BFW_Effect_Private.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_Effect_Private.h - + AUTHOR: Brent Pease - + CREATED: Oct 8, 1999 - + PURPOSE: effects engine - + Copyright 1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_FileFormat/BFW_FileFormat.c b/BungieFrameWork/BFW_Source/BFW_FileFormat/BFW_FileFormat.c index 9a69a36..8f14dbb 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileFormat/BFW_FileFormat.c +++ b/BungieFrameWork/BFW_Source/BFW_FileFormat/BFW_FileFormat.c @@ -1,12 +1,12 @@ /* FILE: BFW_FileFormat.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1998 - + PURPOSE: Interface to various graphical file formats - + Copyright 1998 */ @@ -22,7 +22,7 @@ typedef UUtBool (*FFtFunc_IsType)( BFtFileRef* inFileRef); - + typedef UUtError (*FFtFunc_Read)( BFtFileRef* inFileRef, @@ -31,7 +31,7 @@ typedef UUtError UUtUns16 *outHeight, IMtMipMap *outMipMap, void* *outData); - + typedef UUtError (*FFtFunc_Write)( BFtFileRef* inFileRef, @@ -45,7 +45,7 @@ typedef UUtError (*FFtFunc_Peek)( BFtFileRef* inFileRef, FFtFileInfo* outFileInfo); - + typedef struct FFtParser { FFtFormat_2D format; @@ -53,7 +53,7 @@ typedef struct FFtParser FFtFunc_Read read; FFtFunc_Write write; FFtFunc_Peek peek; - + } FFtParser; FFtParser FFgParserTable[] = @@ -63,7 +63,7 @@ FFtParser FFgParserTable[] = {FFcFormat_2D_DDS, FFrType_IsDDS, FFrRead_DDS, FFrWrite_DDS, FFrPeek_DDS}, {FFcFormat_2D_None, NULL, NULL, NULL} }; - + UUtError FFrWrite_2D( BFtFileRef* inFileRef, @@ -75,7 +75,7 @@ FFrWrite_2D( void* inData) { FFtParser* curParser; - + for(curParser = FFgParserTable; curParser->format != FFcFormat_2D_None; curParser++) @@ -91,7 +91,7 @@ FFrWrite_2D( inData); } } - + // Could not find parser return UUcError_Generic; } @@ -127,13 +127,13 @@ FFrRead_2D_Reduce( buffer_size = IMrImage_ComputeSize(inPixelType, info.mipMap, info.width, info.height); reduced_buffer_size = IMrImage_ComputeSize(inPixelType, info.mipMap, info.width >> inReduce, info.height >> inReduce); - out_buffer = UUrMemory_Block_New(reduced_buffer_size); - if (error != UUcError_None) { + out_buffer = UUrMemory_Block_New(reduced_buffer_size); + if (error != UUcError_None) { goto error_exit; } error = FFrRead_2D(inFileRef, inPixelType, &width, &height, &mipMap, &buffer); - if (error != UUcError_None) { + if (error != UUcError_None) { goto error_exit; } @@ -153,7 +153,7 @@ FFrRead_2D_Reduce( else { error = IMrImage_Scale(inScaleMode, width, height, inPixelType, buffer, width >> inReduce, height >> inReduce, out_buffer); - if (error != UUcError_None) { + if (error != UUcError_None) { goto error_exit; } } @@ -192,7 +192,7 @@ FFrRead_2D( void* *outData) // Caller is responsible for freeing this memory { FFtParser* curParser; - + for(curParser = FFgParserTable; curParser->format != FFcFormat_2D_None; curParser++) @@ -220,7 +220,7 @@ FFrPeek_2D( { FFtParser* curParser; UUtError error; - + for(curParser = FFgParserTable; curParser->format != FFcFormat_2D_None; curParser++) diff --git a/BungieFrameWork/BFW_Source/BFW_FileFormat/BMP/BFW_FF_BMP.c b/BungieFrameWork/BFW_Source/BFW_FileFormat/BMP/BFW_FF_BMP.c index 68b1571..a1bda52 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileFormat/BMP/BFW_FF_BMP.c +++ b/BungieFrameWork/BFW_Source/BFW_FileFormat/BMP/BFW_FF_BMP.c @@ -1,12 +1,12 @@ /* FILE: BFW_FF_BMP.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -28,25 +28,25 @@ FFrWrite_BMP( void* inData) { UUtError error; - + BFtFile* file; - + BMPtFileHeader_Raw* fileHeaderRaw; BMPtHeaderOld_Raw* headerRaw; - + UUtUns32 dataSize; UUtUns32 fileSize; - + UUtUns16 x, y; - + UUtUns8* fileMemory; - + UUtUns32 dstRowBytes; UUtUns8* dstBaseAddr; UUtUns32 bitsPerPlane; UUtUns32 bytesPerPlane; - + if ((inPixelType != IMcPixelType_RGB555) && (inPixelType != IMcPixelType_RGB888)) { return UUcError_Generic; @@ -71,41 +71,41 @@ FFrWrite_BMP( bytesPerPlane = bitsPerPlane / 8; dstRowBytes = UUmMakeMultiple(inWidth * bytesPerPlane, 4); - + dataSize = inHeight * dstRowBytes; fileSize = dataSize + sizeof(BMPtFileHeader_Raw) + sizeof(BMPtHeaderOld_Raw); - + fileMemory = UUrMemory_Block_New(fileSize); UUmError_ReturnOnNull(fileMemory); - + fileHeaderRaw = (BMPtFileHeader_Raw*)fileMemory; headerRaw = (BMPtHeaderOld_Raw*)(fileMemory + sizeof(BMPtFileHeader_Raw)); - + fileHeaderRaw->type[0] = ((FFcBMP_Type_BMP >> 8) & 0xFF); fileHeaderRaw->type[1] = ((FFcBMP_Type_BMP >> 0) & 0xFF); *(UUtUns32*)&fileHeaderRaw->size = fileSize; - + *(UUtUns16*)&fileHeaderRaw->xHotSpot = 0; *(UUtUns16*)&fileHeaderRaw->yHotSpot = 0; *(UUtUns32*)&fileHeaderRaw->offsetToBits = sizeof(BMPtFileHeader_Raw) + sizeof(BMPtHeaderOld_Raw); - + UUmSwapLittle_4Byte(&fileHeaderRaw->size); UUmSwapLittle_2Byte(&fileHeaderRaw->xHotSpot); UUmSwapLittle_2Byte(&fileHeaderRaw->yHotSpot); UUmSwapLittle_4Byte(&fileHeaderRaw->offsetToBits); - + *(UUtUns32*)&headerRaw->size = sizeof(BMPtHeaderOld_Raw); *(UUtUns16*)&headerRaw->width = inWidth; *(UUtUns16*)&headerRaw->height = inHeight; *(UUtUns16*)&headerRaw->numBitPlanes = 1; *(UUtUns16*)&headerRaw->numBitsPerPlane = (UUtUns16) bitsPerPlane; - + UUmSwapLittle_4Byte(&headerRaw->size); UUmSwapLittle_2Byte(&headerRaw->width); UUmSwapLittle_2Byte(&headerRaw->height); UUmSwapLittle_2Byte(&headerRaw->numBitPlanes); UUmSwapLittle_2Byte(&headerRaw->numBitsPerPlane); - + dstBaseAddr = fileMemory + sizeof(BMPtFileHeader_Raw) + sizeof(BMPtHeaderOld_Raw); if (IMcPixelType_RGB555 == inPixelType) @@ -117,7 +117,7 @@ FFrWrite_BMP( { curSrc = (UUtUns16*)inData + inWidth * y; curDst = dstBaseAddr + dstRowBytes * (inHeight - y - 1); - + for(x = 0; x < inWidth; x++) { *(UUtUns16*)curDst = *curSrc++; @@ -135,7 +135,7 @@ FFrWrite_BMP( { curSrc = (UUtUns32*)inData + inWidth * y; curDst = dstBaseAddr + dstRowBytes * (inHeight - y - 1); - + for(x = 0; x < inWidth; x++) { *curDst++ = (UUtUns8) ((*curSrc & 0x000000ff) >> 0); @@ -146,22 +146,22 @@ FFrWrite_BMP( } } } - + BFrFile_Delete(inFileRef); - + error = BFrFile_Create(inFileRef); UUmError_ReturnOnError(error); - + error = BFrFile_Open(inFileRef, "w", &file); UUmError_ReturnOnError(error); - + error = BFrFile_Write(file, fileSize, fileMemory); UUmError_ReturnOnError(error); - + BFrFile_Close(file); - + UUrMemory_Block_Delete(fileMemory); - + return UUcError_None; } @@ -170,31 +170,31 @@ FFrType_IsBMP( BFtFileRef* inFileRef) { UUtError error; - + const char* suffix; char type[2]; BFtFile* file; - + suffix = BFrFileRef_GetSuffixName(inFileRef); - + if(suffix == NULL) return UUcFalse; - + if(UUrString_Compare_NoCase(suffix, "bmp")) return UUcFalse; - + error = BFrFile_Open(inFileRef, "r", &file); if(error != UUcError_None) return UUcFalse; - + error = BFrFile_Read(file, 2, &type); if(error != UUcError_None) return UUcFalse; - + BFrFile_Close(file); if(type[0] != ((FFcBMP_Type_BMP >> 8) & 0xFF)) return UUcFalse; if(type[1] != ((FFcBMP_Type_BMP >> 0) & 0xFF)) return UUcFalse; - + return UUcTrue; } - + UUtError FFrRead_BMP( BFtFileRef* inFileRef, @@ -208,19 +208,19 @@ FFrRead_BMP( BFtFile* file; UUtUns32 fileLength; UUtUns8* fileData; - + UUtUns16 width; UUtUns16 height; UUtUns16 rowBytes; UUtUns8* imageData; UUtUns16 x, y; UUtUns8 r, g, b; - + BMPtFileHeader_Raw* fileHeaderRaw; BMPtHeaderOld_Raw* headerOldRaw; BMPtHeaderNew_Raw* headerNewRaw; BMPtHeader header; - + UUtUns8* srcBaseAddr; UUtUns16 srcRowBytes; UUtUns8* curSrc; @@ -228,48 +228,48 @@ FFrRead_BMP( UUtUns16 bitsPerPlane; void *out_data; - + error = BFrFile_Open(inFileRef, "r", &file); UUmError_ReturnOnError(error); - + error = BFrFile_GetLength(file, &fileLength); UUmError_ReturnOnError(error); - + if(fileLength < (sizeof(BMPtFileHeader_Raw) + sizeof(BMPtHeaderOld_Raw))) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Can not process this bmp file"); } - + fileData = UUrMemory_Block_New(fileLength); UUmError_ReturnOnNull(fileData); - + error = BFrFile_Read(file, fileLength, fileData); UUmError_ReturnOnError(error); - + BFrFile_Close(file); file = NULL; - + fileHeaderRaw = (BMPtFileHeader_Raw*)fileData; - + #if UUmEndian == UUmEndian_Big - + UUrSwap_4Byte(&fileHeaderRaw->size); UUrSwap_2Byte(&fileHeaderRaw->xHotSpot); UUrSwap_2Byte(&fileHeaderRaw->yHotSpot); UUrSwap_4Byte(&fileHeaderRaw->offsetToBits); - + #endif - + UUrMemory_Clear(&header, sizeof(BMPtHeader)); - + headerOldRaw = (BMPtHeaderOld_Raw*)(fileData + sizeof(BMPtFileHeader_Raw)); - + #if UUmEndian == UUmEndian_Big - + UUrSwap_4Byte(&headerOldRaw->size); - + #endif - + header.size = *(UUtUns32*)headerOldRaw->size; if(header.size <= 12) @@ -277,14 +277,14 @@ FFrRead_BMP( UUmAssert(header.size == sizeof(BMPtHeaderOld_Raw)); #if UUmEndian == UUmEndian_Big - + UUrSwap_2Byte(&headerOldRaw->width); UUrSwap_2Byte(&headerOldRaw->height); UUrSwap_2Byte(&headerOldRaw->numBitPlanes); UUrSwap_2Byte(&headerOldRaw->numBitsPerPlane); #endif - + header.width = *(UUtUns16*)headerOldRaw->width; header.height = *(UUtUns16*)headerOldRaw->height; header.numBitPlanes = *(UUtUns16*)headerOldRaw->numBitPlanes; @@ -293,9 +293,9 @@ FFrRead_BMP( else { headerNewRaw = (BMPtHeaderNew_Raw*)headerOldRaw; - + #if UUmEndian == UUmEndian_Big - + UUrSwap_4Byte(&headerNewRaw->width); UUrSwap_4Byte(&headerNewRaw->height); UUrSwap_2Byte(&headerNewRaw->numBitPlanes); @@ -329,9 +329,9 @@ FFrRead_BMP( if(header.size <= 60) goto doneSwapping; UUrSwap_4Byte(&headerNewRaw->identifier); doneSwapping: - + #endif - + header.width = *(UUtUns32*)headerNewRaw->width; header.height = *(UUtUns32*)headerNewRaw->height; header.numBitPlanes = *(UUtUns16*)headerNewRaw->numBitPlanes; @@ -366,7 +366,7 @@ FFrRead_BMP( header.identifier = *(UUtUns32*)headerNewRaw->identifier; } next: - + if((fileHeaderRaw->type[0] != ((FFcBMP_Type_BMP >> 8) & 0xFF)) || (fileHeaderRaw->type[1] != ((FFcBMP_Type_BMP >> 0) & 0xFF))) { @@ -379,17 +379,17 @@ FFrRead_BMP( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Can not process this bmp file"); } - + bitsPerPlane = header.numBitsPerPlane; - + if(bitsPerPlane != 16 && bitsPerPlane != 24) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Can not process this bmp file"); } - + UUmAssert(header.width > 0); UUmAssert(header.height > 0); - + width = (UUtUns16)header.width; height = (UUtUns16)header.height; rowBytes = IMrImage_ComputeRowBytes(IMcPixelType_RGB555, width); @@ -398,7 +398,7 @@ FFrRead_BMP( out_data = UUrMemory_Block_New(IMrImage_ComputeSize(inPixelType, IMcNoMipMap, width, height)); UUmError_ReturnOnNull(out_data); - + if(inPixelType != IMcPixelType_RGB555) { @@ -409,18 +409,18 @@ FFrRead_BMP( { imageData = out_data; } - + srcBaseAddr = (UUtUns8*)fileHeaderRaw + *(UUtUns32*)fileHeaderRaw->offsetToBits; - + if(bitsPerPlane == 16) { srcRowBytes = UUmMakeMultiple(width << 1, 4); - + for(y = 0; y < height; y++) { curSrc = srcBaseAddr + srcRowBytes * (height - y - 1); curDst = imageData + rowBytes * y; - + for(x = 0; x < width; x++) { *(UUtUns16*)curDst = *(UUtUns16*)curSrc; @@ -432,28 +432,28 @@ FFrRead_BMP( else { srcRowBytes = UUmMakeMultiple(width * sizeof(BMPtRGB), 4); - + for(y = 0; y < height; y++) { curSrc = srcBaseAddr + srcRowBytes * (height - y - 1); curDst = imageData + rowBytes * y; - + for(x = 0; x < width; x++) { b = *curSrc++; g = *curSrc++; r = *curSrc++; - + r >>= 3; g >>= 3; b >>= 3; - + *(UUtUns16*)curDst = (1 << 15) | (r << 10) | (g << 5) | b; curDst += 2; } } } - + if(inPixelType != IMcPixelType_RGB555) { // convert the image to the desired pixel type @@ -469,21 +469,21 @@ FFrRead_BMP( out_data); UUmError_ReturnOnError(error); } - + // free allocated memory if(inPixelType != IMcPixelType_RGB555) { UUrMemory_Block_Delete(imageData); } - + UUrMemory_Block_Delete(fileData); - + // set the outgoing values *outWidth = width; *outHeight = height; *outMipMap = IMcNoMipMap; *outData = out_data; - + return UUcError_None; } @@ -498,75 +498,75 @@ FFrPeek_BMP( UUtUns8 storage[sizeof(BMPtFileHeader_Raw) + sizeof(BMPtHeaderOld_Raw)]; UUtUns8* fileData = storage; UUtUns16 header_size; - + BMPtHeaderOld_Raw *headerOldRaw; - + // calculate the header size header_size = sizeof(BMPtFileHeader_Raw) + sizeof(BMPtHeaderOld_Raw); // open the file read only error = BFrFile_Open(inFileRef, "r", &file); UUmError_ReturnOnError(error); - + // get the length of the file error = BFrFile_GetLength(file, &fileLength); UUmError_ReturnOnError(error); - + // make sure the file is big enough if (fileLength < header_size) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Can not process this bmp file"); } - + // read the headers of the file error = BFrFile_Read(file, header_size, fileData); UUmError_ReturnOnError(error); - + // close the file BFrFile_Close(file); file = NULL; - + // get a pointer to the header headerOldRaw = (BMPtHeaderOld_Raw*)(fileData + sizeof(BMPtFileHeader_Raw)); #if UUmEndian == UUmEndian_Big - + UUrSwap_4Byte(&headerOldRaw->size); - + #endif - + // process the header as old style or new style depending on it size if ((UUtUns16)(*(UUtUns32*)&headerOldRaw->size) <= 12) { UUmAssert((UUtUns16)(*(UUtUns32*)&headerOldRaw->size) == sizeof(BMPtHeaderOld_Raw)); #if UUmEndian == UUmEndian_Big - + UUrSwap_2Byte(&headerOldRaw->width); UUrSwap_2Byte(&headerOldRaw->height); #endif - + outFileInfo->width = *((UUtUns16*)headerOldRaw->width); outFileInfo->height = *((UUtUns16*)headerOldRaw->height); } else { BMPtHeaderNew_Raw* headerNewRaw; - + headerNewRaw = (BMPtHeaderNew_Raw*)headerOldRaw; - + #if UUmEndian == UUmEndian_Big - + UUrSwap_4Byte(&headerNewRaw->width); UUrSwap_4Byte(&headerNewRaw->height); - + #endif - + outFileInfo->width = (UUtUns16)(*((UUtUns32*)headerNewRaw->width)); outFileInfo->height = (UUtUns16)(*((UUtUns32*)headerNewRaw->height)); } - + outFileInfo->format = FFcFormat_2D_BMP; outFileInfo->mipMap = IMcNoMipMap; outFileInfo->pixelType = IMcPixelType_RGB555; diff --git a/BungieFrameWork/BFW_Source/BFW_FileFormat/BMP/BFW_FF_BMP.h b/BungieFrameWork/BFW_Source/BFW_FileFormat/BMP/BFW_FF_BMP.h index e2b21bd..fb1ba8b 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileFormat/BMP/BFW_FF_BMP.h +++ b/BungieFrameWork/BFW_Source/BFW_FileFormat/BMP/BFW_FF_BMP.h @@ -1,12 +1,12 @@ /* FILE: BFW_FF_BMP.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -25,7 +25,7 @@ FFrWrite_BMP( UUtBool FFrType_IsBMP( BFtFileRef* inFileRef); - + UUtError FFrRead_BMP( BFtFileRef* inFileRef, diff --git a/BungieFrameWork/BFW_Source/BFW_FileFormat/BMP/BFW_FF_BMP_Priv.h b/BungieFrameWork/BFW_Source/BFW_FileFormat/BMP/BFW_FF_BMP_Priv.h index 24c0e15..0ce88c5 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileFormat/BMP/BFW_FF_BMP_Priv.h +++ b/BungieFrameWork/BFW_Source/BFW_FileFormat/BMP/BFW_FF_BMP_Priv.h @@ -1,12 +1,12 @@ /* FILE: BFW_FF_BMP_Priv.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -45,13 +45,13 @@ /* * origin of coordinate space - */ + */ #define FFcBMP_Origin_LOWER_LEFT (0) #define FFcBMP_Origin_LAST (0) /* * halftoning algorithms - */ + */ #define FFcBMP_Halftoning_NONE (0) #define FFcBMP_Halftoning_ERROR_DIFFUSION (1) #define FFcBMP_Halftoning_PANDA (2) @@ -87,7 +87,7 @@ UUtUns8 height[2]; UUtUns8 numBitPlanes[2]; UUtUns8 numBitsPerPlane[2]; - + } BMPtHeaderOld_Raw; typedef struct BMPtHeaderNew_Raw @@ -111,7 +111,7 @@ UUtUns8 halftoningParam2[4]; UUtUns8 colorEncoding[4]; UUtUns8 identifier[4]; - + } BMPtHeaderNew_Raw; typedef struct BMPtHeader @@ -135,7 +135,7 @@ UUtUns32 halftoningParam2; UUtUns32 colorEncoding; UUtUns32 identifier; - + } BMPtHeader; /* @@ -148,7 +148,7 @@ UUtUns8 xHotSpot[2]; UUtUns8 yHotSpot[2]; UUtUns8 offsetToBits[4]; - + } BMPtFileHeader_Raw; /* @@ -162,9 +162,9 @@ UUtUns8 next[2]; UUtUns8 screenWidth[2]; UUtUns8 screenHeight[2]; - + } BMPtArrayHeader_Raw; - + /* * BMPtRGB defines a single color palette entry. */ @@ -173,7 +173,7 @@ UUtUns8 blue; UUtUns8 green; UUtUns8 red; - + } BMPtRGB; #endif /* BFW_FF_PRIV_BMP_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_FileFormat/DDS/BFW_FF_DDS.c b/BungieFrameWork/BFW_Source/BFW_FileFormat/DDS/BFW_FF_DDS.c index 460b56c..7f7bbc6 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileFormat/DDS/BFW_FF_DDS.c +++ b/BungieFrameWork/BFW_Source/BFW_FileFormat/DDS/BFW_FF_DDS.c @@ -1,12 +1,12 @@ /* FILE: BFW_FF_DDS.c - + AUTHOR: Michael Evans - + CREATED: Jan 12, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -49,40 +49,40 @@ FFrType_IsDDS( { UUtBool isDDS = UUcFalse; UUtError error; - + const char* suffix; UUtUns32 type; BFtFile* file; - + suffix = BFrFileRef_GetSuffixName(inFileRef); - - if(suffix == NULL) + + if(suffix == NULL) { goto exit; } - - if(UUrString_Compare_NoCase(suffix, "dds")) + + if(UUrString_Compare_NoCase(suffix, "dds")) { goto exit; } - + error = BFrFile_Open(inFileRef, "r", &file); - if(error != UUcError_None) + if(error != UUcError_None) { goto exit; } - + error = BFrFile_Read(file, 4, &type); - if(error != UUcError_None) + if(error != UUcError_None) { goto exit; } - + UUmSwapBig_4Byte(&type); - + BFrFile_Close(file); - - if(type != FFcDDS_FileSignature) + + if(type != FFcDDS_FileSignature) { goto exit; } @@ -90,10 +90,10 @@ FFrType_IsDDS( // passed all the tests isDDS = UUcTrue; -exit: +exit: return isDDS; } - + UUtError FFrRead_DDS( BFtFileRef* inFileRef, @@ -115,18 +115,18 @@ FFrRead_DDS( // read the file data into memory error = BFrFile_Open(inFileRef, "r", &file); UUmError_ReturnOnError(error); - + error = BFrFile_GetLength(file, &fileLength); UUmError_ReturnOnError(error); - + if (fileLength < sizeof(fileHeader)) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Can not process this DDS file"); } - + error = BFrFile_Read(file, sizeof(fileHeader), &fileHeader); UUmError_ReturnOnError(error); - + FFiSwapDDSHeader(&fileHeader); // compute the image properties @@ -167,10 +167,10 @@ FFrRead_DDS( char *dst_dxt1; // find the last valid mipmap - while((src_width > 1) && (src_height > 1)) { + while((src_width > 1) && (src_height > 1)) { src_dxt1 += IMrImage_ComputeSize(IMcPixelType_DXT1, IMcNoMipMap, src_width, src_height); - - src_width /= 2; + + src_width /= 2; src_height /= 2; } @@ -239,7 +239,7 @@ FFrPeek_DDS( BFtFile* file; UUtUns32 fileLength; FFtDDS_FileHeader_Raw fileHeader; - + retry: //UUmAssert(sizeof(fileHeader) == 0x70); UUmAssertWritePtr(inFileRef, 1); @@ -248,18 +248,18 @@ FFrPeek_DDS( // read the file data into memory error = BFrFile_Open(inFileRef, "r", &file); UUmError_ReturnOnError(error); - + error = BFrFile_GetLength(file, &fileLength); UUmError_ReturnOnError(error); - + if (fileLength < sizeof(fileHeader)) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Can not process this DDS file"); } - + error = BFrFile_Read(file, sizeof(fileHeader), &fileHeader); UUmError_ReturnOnError(error); - + FFiSwapDDSHeader(&fileHeader); BFrFile_Close(file); @@ -267,7 +267,7 @@ FFrPeek_DDS( // verify various bits and pieces if (fileHeader.signature != FFcDDS_FileSignature) UUmError_ReturnOnErrorMsg(UUcError_Generic, "DDS file signature is invalid"); - + switch(fileHeader.format) { case FFcDDS_FormatSignature_DXT1: @@ -275,7 +275,7 @@ FFrPeek_DDS( default: { - AUtMB_ButtonChoice choice = AUrMessageBox(AUcMBType_RetryCancel, "DDS file format is %c%c%c%c expected %c%c%c%c", + AUtMB_ButtonChoice choice = AUrMessageBox(AUcMBType_RetryCancel, "DDS file format is %c%c%c%c expected %c%c%c%c", (fileHeader.format >> 24) & 0xFF, (fileHeader.format >> 16) & 0xFF, (fileHeader.format >> 8) & 0xFF, @@ -293,13 +293,13 @@ FFrPeek_DDS( } } } - + // setup the return outFileInfo->format = FFcFormat_2D_DDS; outFileInfo->width = fileHeader.width; outFileInfo->height = fileHeader.height; outFileInfo->mipMap = (fileHeader.mipMapLevels > 1) ? IMcHasMipMap : IMcNoMipMap; outFileInfo->pixelType = IMcPixelType_DXT1; - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_FileFormat/DDS/BFW_FF_DDS.h b/BungieFrameWork/BFW_Source/BFW_FileFormat/DDS/BFW_FF_DDS.h index 5eaf768..70e5ae1 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileFormat/DDS/BFW_FF_DDS.h +++ b/BungieFrameWork/BFW_Source/BFW_FileFormat/DDS/BFW_FF_DDS.h @@ -1,12 +1,12 @@ /* FILE: BFW_FF_DDS.h - + AUTHOR: Michael Evans - + CREATED: Jan 12, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -25,7 +25,7 @@ FFrWrite_DDS( UUtBool FFrType_IsDDS( BFtFileRef* inFileRef); - + UUtError FFrRead_DDS( BFtFileRef* inFileRef, diff --git a/BungieFrameWork/BFW_Source/BFW_FileFormat/DDS/BFW_FF_DDS_Priv.h b/BungieFrameWork/BFW_Source/BFW_FileFormat/DDS/BFW_FF_DDS_Priv.h index 2bf0d36..00e1c94 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileFormat/DDS/BFW_FF_DDS_Priv.h +++ b/BungieFrameWork/BFW_Source/BFW_FileFormat/DDS/BFW_FF_DDS_Priv.h @@ -1,12 +1,12 @@ /* FILE: BFW_FF_DDS_PRIV_H.h - + AUTHOR: Michael Evans - + CREATED: Jan 11, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -30,10 +30,10 @@ typedef struct FFtDDS_FileHeader_Raw UUtUns16 width; // 16..17 char unknown3[10]; // 18..27 UUtUns8 mipMapLevels; // 28 i.e. 1 means no extra map levels - char unknown4[3]; - char unknown5[0x10]; - char unknown6[0x10]; - char unknown7[0x10]; + char unknown4[3]; + char unknown5[0x10]; + char unknown6[0x10]; + char unknown7[0x10]; char unknown8[4]; UUtUns32 format; // example: DXT1 char unknown9[8]; diff --git a/BungieFrameWork/BFW_Source/BFW_FileFormat/PSD/BFW_FF_PSD.c b/BungieFrameWork/BFW_Source/BFW_FileFormat/PSD/BFW_FF_PSD.c index 682508b..26b5026 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileFormat/PSD/BFW_FF_PSD.c +++ b/BungieFrameWork/BFW_Source/BFW_FileFormat/PSD/BFW_FF_PSD.c @@ -1,12 +1,12 @@ /* FILE: BFW_FF_PSD.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -44,49 +44,49 @@ FFiPSD_Read_Raw( UUtUns32 *curDst; UUtUns16 x; UUtUns16 y; - + curPlane = inData; - + // Copy the red channel for (y = 0; y < inHeight; y++) { curSrc = curPlane + y * inWidth; curDst = outData + y * inWidth; - + for (x = 0; x < inWidth; x++) { *curDst++ = FFmMixRed(*curSrc++, *curDst); } } - + curPlane += inHeight * inWidth; - + // Copy the green channel for (y = 0; y < inHeight; y++) { curSrc = curPlane + y * inWidth; curDst = outData + y * inWidth; - + for (x = 0; x < inWidth; x++) { *curDst++ = FFmMixGreen(*curSrc++, *curDst); } } - + curPlane += inHeight * inWidth; - + // Copy the blue channel for (y = 0; y < inHeight; y++) { curSrc = curPlane + y * inWidth; curDst = outData + y * inWidth; - + for (x = 0; x < inWidth; x++) { *curDst++ = FFmMixBlue(*curSrc++, *curDst); } } - + if (inChannels > 3) { curPlane += inHeight * inWidth * (inChannels - 3); @@ -96,14 +96,14 @@ FFiPSD_Read_Raw( { curSrc = curPlane + y * inWidth; curDst = outData + y * inWidth; - + for (x = 0; x < inWidth; x++) { *curDst++ = FFmMixAlpha(*curSrc++, *curDst); } } } - + return UUcError_None; } @@ -123,52 +123,52 @@ FFiPSD_Read_RLE( UUtInt16 num_bytes_in_row; UUtInt16 counter; UUtUns16 itr; - + curCount = (UUtUns16*)inData; // process red curSrc = (UUtInt8*)(inData + inHeight * inChannels * sizeof(UUtUns16)); curDst = outData; - + for (rows_processed = 0; rows_processed < inHeight; rows_processed++) { // get the number of bytes in the row of data num_bytes_in_row = *curCount++; UUmSwapBig_2Byte(&num_bytes_in_row); - + while (num_bytes_in_row > 0) { // get the number of characters to process counter = *curSrc++; - + num_bytes_in_row--; UUmAssert(num_bytes_in_row >= 0); - + if (counter < 0) { // write the next byte counter times counter = -counter + 1; - + num_bytes_in_row--; UUmAssert(num_bytes_in_row >= 0); - + while (counter--) *curDst++ = FFmMixRed(*curSrc, *curDst); - + curSrc++; } else { // copy the next counter bytes counter++; - + num_bytes_in_row -= counter; UUmAssert(num_bytes_in_row >= 0); - + while (counter--) *curDst++ = FFmMixRed(*curSrc++, *curDst); } - + UUmAssert(curDst <= (outData + inHeight * inWidth)); } } @@ -180,44 +180,44 @@ FFiPSD_Read_RLE( // get the number of bytes in the row of data num_bytes_in_row = *curCount++; UUmSwapBig_2Byte(&num_bytes_in_row); - + while (num_bytes_in_row > 0) { // get the number of characters to process counter = *curSrc++; - + num_bytes_in_row--; UUmAssert(num_bytes_in_row >= 0); - + if (counter < 0) { // write the next byte counter times counter = -counter + 1; - + num_bytes_in_row--; UUmAssert(num_bytes_in_row >= 0); - + while (counter--) *curDst++ = FFmMixGreen(*curSrc, *curDst); - + curSrc++; } else { // copy the next counter bytes counter++; - + num_bytes_in_row -= counter; UUmAssert(num_bytes_in_row >= 0); - + while (counter--) *curDst++ = FFmMixGreen(*curSrc++, *curDst); } - + UUmAssert(curDst <= (outData + inHeight * inWidth)); } } - + // process Blue curDst = outData; for (rows_processed = 0; rows_processed < inHeight; rows_processed++) @@ -225,44 +225,44 @@ FFiPSD_Read_RLE( // get the number of bytes in the row of data num_bytes_in_row = *curCount++; UUmSwapBig_2Byte(&num_bytes_in_row); - + while (num_bytes_in_row > 0) { // get the number of characters to process counter = *curSrc++; - + num_bytes_in_row--; UUmAssert(num_bytes_in_row >= 0); - + if (counter < 0) { // write the next byte counter times counter = -counter + 1; - + num_bytes_in_row--; UUmAssert(num_bytes_in_row >= 0); - + while (counter--) *curDst++ = FFmMixBlue(*curSrc, *curDst); - + curSrc++; } else { // copy the next counter bytes counter++; - + num_bytes_in_row -= counter; UUmAssert(num_bytes_in_row >= 0); - + while (counter--) *curDst++ = FFmMixBlue(*curSrc++, *curDst); } - + UUmAssert(curDst <= (outData + inHeight * inWidth)); } } - + if (inChannels > 3) { // Hack to get one of chris's files working @@ -274,39 +274,39 @@ FFiPSD_Read_RLE( // get the number of bytes in the row of data num_bytes_in_row = *curCount++; UUmSwapBig_2Byte(&num_bytes_in_row); - + while (num_bytes_in_row > 0) { // get the number of characters to process counter = *curSrc++; - + num_bytes_in_row--; UUmAssert(num_bytes_in_row >= 0); - + if (counter < 0) { // write the next byte counter times counter = -counter + 1; - + num_bytes_in_row--; UUmAssert(num_bytes_in_row >= 0); - + curSrc++; } else { // copy the next counter bytes counter++; - + num_bytes_in_row -= counter; UUmAssert(num_bytes_in_row >= 0); } - + UUmAssert(curDst <= (outData + inHeight * inWidth)); } } } - + // process Alpha curDst = outData; for (rows_processed = 0; rows_processed < inHeight; rows_processed++) @@ -314,45 +314,45 @@ FFiPSD_Read_RLE( // get the number of bytes in the row of data num_bytes_in_row = *curCount++; UUmSwapBig_2Byte(&num_bytes_in_row); - + while (num_bytes_in_row > 0) { // get the number of characters to process counter = *curSrc++; - + num_bytes_in_row--; UUmAssert(num_bytes_in_row >= 0); - + if (counter < 0) { // write the next byte counter times counter = -counter + 1; - + num_bytes_in_row--; UUmAssert(num_bytes_in_row >= 0); - + while (counter--) *curDst++ = FFmMixAlpha(*curSrc, *curDst); - + curSrc++; } else { // copy the next counter bytes counter++; - + num_bytes_in_row -= counter; UUmAssert(num_bytes_in_row >= 0); - + while (counter--) *curDst++ = FFmMixAlpha(*curSrc++, *curDst); } - + UUmAssert(curDst <= (outData + inHeight * inWidth)); } } } - + return UUcError_None; } @@ -375,23 +375,23 @@ FFrWrite_PSD( UUtUns32 totalFileByteSize; UUtUns32 imageDataByteSize; UUtUns8* fileData; - + UUtUns16 x, y; UUtUns32* curSrc; UUtUns8* curDst; - + BFtFile* file; - + UUtUns8* curPlane; - + FFtPSD_FileHeader_Raw* fileHeader; FFtPSD_ColorModeData_Raw* colorModeData; FFtPSD_ImageResources_Raw* imageResources; FFtPSD_LayerAndMask_Raw* layerAndMask; FFtPSD_ImageData_Raw* imageData; - + UUtUns16 rowBytes; - + if(inPixelType != IMcPixelType_RGB888) { UUmError_ReturnOnErrorMsg( @@ -403,27 +403,27 @@ FFrWrite_PSD( { return UUcError_Generic; } - + imageDataByteSize = inWidth * inHeight * 3; rowBytes = inWidth << 2; - - totalFileByteSize = - sizeof(FFtPSD_FileHeader_Raw) + - sizeof(FFtPSD_ColorModeData_Raw) + + + totalFileByteSize = + sizeof(FFtPSD_FileHeader_Raw) + + sizeof(FFtPSD_ColorModeData_Raw) + sizeof(FFtPSD_ImageResources_Raw) + - sizeof(FFtPSD_LayerAndMask_Raw) + - sizeof(FFtPSD_ImageData_Raw) + + sizeof(FFtPSD_LayerAndMask_Raw) + + sizeof(FFtPSD_ImageData_Raw) + imageDataByteSize; - + fileData = UUrMemory_Block_New(totalFileByteSize); UUmError_ReturnOnNull(fileData); - + fileHeader = (FFtPSD_FileHeader_Raw*)fileData; colorModeData = (FFtPSD_ColorModeData_Raw*)((char*)fileHeader + sizeof(FFtPSD_FileHeader_Raw)); imageResources = (FFtPSD_ImageResources_Raw*)((char*)colorModeData + sizeof(FFtPSD_ColorModeData_Raw)); layerAndMask = (FFtPSD_LayerAndMask_Raw*)((char*)imageResources + sizeof(FFtPSD_ImageResources_Raw)); imageData = (FFtPSD_ImageData_Raw*)((char*)layerAndMask + sizeof(FFtPSD_LayerAndMask_Raw)); - + *(UUtUns32*)fileHeader->signature = FFcPSD_FileSignature; *(UUtUns16*)fileHeader->version = FFcPSD_FileVersion; fileHeader->reserved[0] = 0; @@ -439,59 +439,59 @@ FFrWrite_PSD( *(UUtUns16*)fileHeader->mode = FFcPSD_ColorMode_RGB; *(UUtUns32*)colorModeData->length = 0; - + *(UUtUns32*)imageResources->length = 0; - + *(UUtUns32*)layerAndMask->length = 0; - + *(UUtUns16*)imageData->compression = FFcPSD_Compression_Raw; - + curPlane = (UUtUns8*)imageData->data; - + // Copy the red channel for(y = 0; y < inHeight; y++) { curSrc = (UUtUns32*)((UUtUns8*)inData + y * rowBytes); curDst = (UUtUns8*)(curPlane + y * inWidth); - + for(x = 0; x < inWidth; x++) { *curDst++ = (UUtUns8)((*curSrc++ >> 16) & 0xFF); } } - + curPlane += inHeight * inWidth; - + // Copy the green channel for(y = 0; y < inHeight; y++) { curSrc = (UUtUns32*)((UUtUns8*)inData + y * rowBytes); curDst = (UUtUns8*)(curPlane + y * inWidth); - + for(x = 0; x < inWidth; x++) { *curDst++ = (UUtUns8)((*curSrc++ >> 8) & 0xFF); } } - + curPlane += inHeight * inWidth; - + // Copy the blue channel for(y = 0; y < inHeight; y++) { curSrc = (UUtUns32*)((UUtUns8*)inData + y * rowBytes); curDst = (UUtUns8*)(curPlane + y * inWidth); - + for(x = 0; x < inWidth; x++) { *curDst++ = (UUtUns8)((*curSrc++ >> 0) & 0xFF); } } - + // Byte swap if needed - + #if UUmEndian == UUmEndian_Little - + UUrSwap_4Byte(&fileHeader->signature); UUrSwap_2Byte(&fileHeader->version); UUrSwap_2Byte(&fileHeader->channels); @@ -499,35 +499,35 @@ FFrWrite_PSD( UUrSwap_4Byte(&fileHeader->columns); UUrSwap_2Byte(&fileHeader->depth); UUrSwap_2Byte(&fileHeader->mode); - + UUrSwap_4Byte(&colorModeData->length); UUrSwap_4Byte(&imageResources->length); UUrSwap_4Byte(&layerAndMask->length); UUrSwap_2Byte(&imageData->compression); #endif - + // Delete any old inFileRef BFrFile_Delete(inFileRef); - + // Create the file ref error = BFrFile_Create(inFileRef); UUmError_ReturnOnError(error); - + // Open the file error = BFrFile_Open(inFileRef, "w", &file); UUmError_ReturnOnError(error); - + // Write the file error = BFrFile_Write(file, totalFileByteSize, fileData); UUmError_ReturnOnError(error); - + // Close the file BFrFile_Close(file); - + // Delete the temp memoruy UUrMemory_Block_Delete(fileData); - + return UUcError_None; } @@ -537,36 +537,36 @@ FFrType_IsPSD( BFtFileRef* inFileRef) { UUtError error; - + const char* suffix; UUtUns32 type; BFtFile* file; - + suffix = BFrFileRef_GetSuffixName(inFileRef); - + if(suffix == NULL) return UUcFalse; - + if(UUrString_Compare_NoCase(suffix, "psd")) return UUcFalse; - + error = BFrFile_Open(inFileRef, "r", &file); if(error != UUcError_None) return UUcFalse; - + error = BFrFile_Read(file, 4, &type); if(error != UUcError_None) return UUcFalse; - + #if UUmEndian == UUmEndian_Little - + UUrSwap_4Byte(&type); - + #endif - + BFrFile_Close(file); - + if(type != FFcPSD_FileSignature) return UUcFalse; - + return UUcTrue; } - + // ---------------------------------------------------------------------- UUtError FFrRead_PSD( @@ -587,7 +587,7 @@ FFrRead_PSD( FFtPSD_ImageResources_Raw* imageResources; FFtPSD_LayerAndMask_Raw* layerAndMask; FFtPSD_ImageData_Raw* imageData; - + UUtUns32 signature; UUtUns16 version; UUtUns16 channels; @@ -599,64 +599,64 @@ FFrRead_PSD( UUtUns16 temp; UUtUns32 *data; UUtUns32 length; - + IMtPixelType src_pixel_type; void *out_data; - + // read the file data into memory error = BFrFile_Open(inFileRef, "r", &file); UUmError_ReturnOnError(error); - + error = BFrFile_GetLength(file, &fileLength); UUmError_ReturnOnError(error); - + if (fileLength == 0) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Can not process this PSD file"); } - + fileData = UUrMemory_Block_New(fileLength); UUmError_ReturnOnNull(fileData); - + error = BFrFile_Read(file, fileLength, fileData); UUmError_ReturnOnError(error); - + BFrFile_Close(file); file = NULL; - + // get pointers to the various parts of the file fileHeader = (FFtPSD_FileHeader_Raw*)fileData; - + signature = *((UUtUns32*)fileHeader->signature); version = *((UUtUns16*)fileHeader->version); UUmSwapBig_4Byte(&signature); UUmSwapBig_2Byte(&version); - + colorModeData = (FFtPSD_ColorModeData_Raw*)((char*)fileHeader + sizeof(FFtPSD_FileHeader_Raw)); - + length = *((UUtUns32*)colorModeData->length); UUmSwapBig_4Byte(&length); imageResources = (FFtPSD_ImageResources_Raw*)((char*)colorModeData + sizeof(FFtPSD_ColorModeData_Raw) + length); - + length = *((UUtUns32*)imageResources->length); UUmSwapBig_4Byte(&length); layerAndMask = (FFtPSD_LayerAndMask_Raw*)((char*)imageResources + sizeof(FFtPSD_ImageResources_Raw) + length); - + length = *((UUtUns32*)layerAndMask->length); UUmSwapBig_4Byte(&length); imageData = (FFtPSD_ImageData_Raw*)((char*)layerAndMask + sizeof(FFtPSD_LayerAndMask_Raw) + length); - + // check the signature if (signature != FFcPSD_FileSignature) { @@ -668,7 +668,7 @@ FFrRead_PSD( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "PSD file version is invalid"); } - + // get info about the file channels = *((UUtUns16*)fileHeader->channels); rows = *((UUtUns32*)fileHeader->rows); @@ -676,7 +676,7 @@ FFrRead_PSD( temp = *((UUtUns16*)fileHeader->depth); depth = (FFtPSD_ChannelBitDepth)temp; temp = *((UUtUns16*)fileHeader->mode); mode = (FFtPSD_ColorMode)temp; temp = *((UUtUns16*)imageData->compression); compression = (FFtPSD_Compression)temp; - + // byte swap if needed UUmSwapBig_2Byte(&channels); UUmSwapBig_4Byte(&rows); @@ -684,19 +684,19 @@ FFrRead_PSD( UUmSwapBig_2Byte(&depth); UUmSwapBig_2Byte(&mode); UUmSwapBig_2Byte(&compression); - + // make sure the channel bit depth is supported if ((depth == FFcPSD_ChannelBitDepth_1) || (depth == FFcPSD_ChannelBitDepth_16)) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "this channel depth is not supported."); } - + // make sure the color mode is supported if (mode != FFcPSD_ColorMode_RGB) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "this color mode is not supported."); } - + // make sure the number of channels is consistent if (channels != 3 && channels != 4) { @@ -704,37 +704,37 @@ FFrRead_PSD( UUcError_Generic, "the number of channels in this psd file is not supported."); } - + // allocate space for the image data = (UUtUns32*)UUrMemory_Block_NewClear(rows * columns * sizeof(UUtUns32)); UUmError_ReturnOnNull(data); - + // read the image data switch (compression) { case FFcPSD_Compression_Raw: error = FFiPSD_Read_Raw(channels, rows, columns, (UUtUns8*)imageData->data, data); break; - + case FFcPSD_Compression_RLE: error = FFiPSD_Read_RLE(channels, rows, columns, (UUtUns8*)imageData->data, data); break; } UUmError_ReturnOnErrorMsg(error, "Error reading image data from PSD file"); - + // set the src_pixel_type if (channels == 3) src_pixel_type = IMcPixelType_RGB888; else src_pixel_type = IMcPixelType_ARGB8888; - + // allocate memory for the new image out_data = UUrMemory_Block_NewClear( rows * IMrImage_ComputeRowBytes(inExpectedPixelType, (UUtUns16)columns)); UUmError_ReturnOnNull(out_data); - + // convert the image to the desired pixel type error = IMrImage_ConvertPixelType( @@ -747,17 +747,17 @@ FFrRead_PSD( inExpectedPixelType, out_data); UUmError_ReturnOnError(error); - + // free the data block UUrMemory_Block_Delete(data); UUrMemory_Block_Delete(fileData); - + // set the outgoing values *outWidth = (UUtUns16)columns; *outHeight = (UUtUns16)rows; *outMipMap = IMcNoMipMap; *outData = out_data; - + return UUcError_None; } @@ -776,18 +776,18 @@ FFrPeek_PSD( // read the file data into memory error = BFrFile_Open(inFileRef, "r", &file); UUmError_ReturnOnError(error); - + error = BFrFile_GetLength(file, &fileLength); UUmError_ReturnOnError(error); - + if (fileLength < sizeof(FFtPSD_FileHeader_Raw)) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Can not process this PSD file"); } - + error = BFrFile_Read(file, sizeof(FFtPSD_FileHeader_Raw), &fileHeader); UUmError_ReturnOnError(error); - + BFrFile_Close(file); file = NULL; @@ -799,7 +799,7 @@ FFrPeek_PSD( UUmSwapBig_4Byte(fileHeader.columns); UUmSwapBig_2Byte(fileHeader.depth); UUmSwapBig_2Byte(fileHeader.mode); - + // check the attributes of the file if (*((UUtUns32*)fileHeader.signature) != FFcPSD_FileSignature) UUmError_ReturnOnErrorMsg(UUcError_Generic, "PSD file signature is invalid"); @@ -809,12 +809,12 @@ FFrPeek_PSD( UUmError_ReturnOnErrorMsg(UUcError_Generic, "PSD file depth is invalid"); if (*((UUtUns16*)fileHeader.mode) != FFcPSD_ColorMode_RGB) UUmError_ReturnOnErrorMsg(UUcError_Generic, "PSD file mode is invalid"); - + outFileInfo->format = FFcFormat_2D_PSD; outFileInfo->width = (UUtUns16)(*((UUtUns32*)fileHeader.columns)); outFileInfo->height = (UUtUns16)(*((UUtUns32*)fileHeader.rows)); outFileInfo->mipMap = IMcNoMipMap; outFileInfo->pixelType = IMcPixelType_ARGB8888; - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_FileFormat/PSD/BFW_FF_PSD.h b/BungieFrameWork/BFW_Source/BFW_FileFormat/PSD/BFW_FF_PSD.h index 4580f18..691f6f5 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileFormat/PSD/BFW_FF_PSD.h +++ b/BungieFrameWork/BFW_Source/BFW_FileFormat/PSD/BFW_FF_PSD.h @@ -1,12 +1,12 @@ /* FILE: BFW_FF_PSD.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -25,7 +25,7 @@ FFrWrite_PSD( UUtBool FFrType_IsPSD( BFtFileRef* inFileRef); - + UUtError FFrRead_PSD( BFtFileRef* inFileRef, diff --git a/BungieFrameWork/BFW_Source/BFW_FileFormat/PSD/BFW_FF_PSD_Priv.h b/BungieFrameWork/BFW_Source/BFW_FileFormat/PSD/BFW_FF_PSD_Priv.h index 8ddec0d..40ce443 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileFormat/PSD/BFW_FF_PSD_Priv.h +++ b/BungieFrameWork/BFW_Source/BFW_FileFormat/PSD/BFW_FF_PSD_Priv.h @@ -1,12 +1,12 @@ /* FILE: BFW_FF_PSD_Priv.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -24,8 +24,8 @@ typedef enum FFtPSD_ChannelBitDepth FFcPSD_ChannelBitDepth_1 = 1, FFcPSD_ChannelBitDepth_8 = 8, FFcPSD_ChannelBitDepth_16 = 16 - - + + } FFtPSD_ChannelBitDepth; typedef enum FFtPSD_ColorMode @@ -38,14 +38,14 @@ typedef enum FFtPSD_ColorMode FFcPSD_ColorMode_Multichannel = 5, FFcPSD_ColorMode_Duotone = 6, FFcPSD_ColorMode_Lab = 7 - + } FFtPSD_ColorMode; typedef enum FFtPSD_Compression { FFcPSD_Compression_Raw = 0, FFcPSD_Compression_RLE = 1 - + } FFtPSD_Compression; @@ -59,21 +59,21 @@ typedef struct FFtPSD_FileHeader_Raw char columns[4]; // Width of the image char depth[2]; // Number of bits per channel - FFtPSD_ChannelBitDepth char mode[2]; // Color mode - FFtPSD_ColorMode - + } FFtPSD_FileHeader_Raw; typedef struct FFtPSD_ColorModeData_Raw { char length[4]; char colorData[0]; - + } FFtPSD_ColorModeData_Raw; typedef struct FFtPSD_ImageResources_Raw { char length[4]; char resources[0]; - + } FFtPSD_ImageResources_Raw; typedef struct FFtPSD_LayerAndMask_Raw @@ -81,14 +81,14 @@ typedef struct FFtPSD_LayerAndMask_Raw char length[4]; char layers[0]; //char globalLayerMask[]; - + } FFtPSD_LayerAndMask_Raw; typedef struct FFtPSD_ImageData_Raw { char compression[2]; // FFtPSD_Compression char data[0]; - + } FFtPSD_ImageData_Raw; diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/BFW_FileManager_Common.c b/BungieFrameWork/BFW_Source/BFW_FileManager/BFW_FileManager_Common.c index dbe996a..a0d0999 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/BFW_FileManager_Common.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/BFW_FileManager_Common.c @@ -1,12 +1,12 @@ /* FILE: BFW_FileManager_Common.c - + AUTHOR: Brent H. Pease - + CREATED: August 14, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -55,31 +55,31 @@ BFrFileRef_LoadIntoMemory( UUmAssert(NULL != inFileRef); UUmAssert(NULL != outFileLength); UUmAssert(NULL != outMemory); - + *outMemory = NULL; *outFileLength = 0; - + error = BFrFile_Open(inFileRef, "r", &file); if (error) { return error; } - + error = BFrFile_GetLength(file, outFileLength); UUmError_ReturnOnError(error); - + newMemory = UUrMemory_Block_New(*outFileLength + 1); if(newMemory == NULL) { UUmError_ReturnOnError(UUcError_OutOfMemory); } - + error = BFrFile_Read(file, *outFileLength, newMemory); UUmError_ReturnOnError(error); - + BFrFile_Close(file); - + newMemory[*outFileLength] = 0; - + *outMemory = newMemory; - + return UUcError_None; } @@ -94,9 +94,9 @@ BFrFileRef_Search( UUtUns16 i; char temp[BFcMaxPathLength]; char temp2[BFcMaxPathLength]; - + UUrString_Copy(temp, inFileName, BFcMaxPathLength); - + for(i = 0; i < BFcMaxSearchDepth; i++) { error = BFrFileRef_Set(outFileRef, temp); @@ -110,27 +110,27 @@ BFrFileRef_Search( sprintf(temp2, "..%c%s", BFcPathSeparator, temp); UUrString_Copy(temp, temp2, BFcMaxPathLength); } - + return BFcError_FileNotFound; } - + void BFrFileRef_SetLeafNameSuffex( BFtFileRef *inFileRef, const char *inNewSuffix) { UUtError error; - + char nameBuffer[BFcMaxPathLength]; const char *origName; char *dotp; - + origName = BFrFileRef_GetLeafName(inFileRef); - + UUrString_Copy(nameBuffer, origName, BFcMaxPathLength); - + if(*inNewSuffix == '.') inNewSuffix++; - + dotp = strrchr(nameBuffer, '.'); if(dotp == NULL) { @@ -144,7 +144,7 @@ BFrFileRef_SetLeafNameSuffex( *dotp++ = *inNewSuffix++; *dotp++ = *inNewSuffix++; } - + error = BFrFileRef_SetName( inFileRef, @@ -160,14 +160,14 @@ BFrFileRef_DuplicateAndReplaceSuffix( { UUtError error; BFtFileRef* newFileRef; - + error = BFrFileRef_Duplicate(inOrigFileRef, &newFileRef); UUmError_ReturnOnError(error); - + BFrFileRef_SetLeafNameSuffex(newFileRef, inNewSuffix); - + *outNewFileRef = newFileRef; - + return UUcError_None; } @@ -177,16 +177,16 @@ BFrFileRef_GetSuffixName( { const char* fileName; char* suffix; - + fileName = BFrFileRef_GetLeafName(inFileRef); - + suffix = strrchr(fileName, '.'); - + if(suffix == NULL) { return NULL; } - + return suffix+1; } @@ -198,18 +198,18 @@ BFrFileRef_DuplicateAndReplaceName( { UUtError error; BFtFileRef* newFileRef; - + error = BFrFileRef_Duplicate(inOrigFileRef, &newFileRef); UUmError_ReturnOnError(error); - + error = BFrFileRef_SetName(newFileRef, inReplaceName); UUmError_ReturnOnError(error); - + *outNewFileRef = newFileRef; - + return UUcError_None; } - + UUtError BFrFileRef_DuplicateAndAppendName( const BFtFileRef* inOrigFileRef, // This had best be a directory... @@ -220,22 +220,22 @@ BFrFileRef_DuplicateAndAppendName( BFtFileRef* newFileRef; const char* leafName; char newName[BFcMaxPathLength]; - + error = BFrFileRef_Duplicate(inOrigFileRef, &newFileRef); UUmError_ReturnOnError(error); - + leafName = BFrFileRef_GetLeafName(inOrigFileRef); - + sprintf(newName, "%s%c%s", leafName, BFcPathSeparator, inAppendName); - + error = BFrFileRef_SetName(newFileRef, newName); UUmError_ReturnOnErrorMsgP(error, "Could not set name %s", (UUtUns32)newName, 0, 0); - + *outNewFileRef = newFileRef; - + return UUcError_None; } - + UUtError BFrFileRef_AppendName( BFtFileRef* inFileRef, // This had best be a directory... @@ -244,14 +244,14 @@ BFrFileRef_AppendName( UUtError error; const char* leafName; char newName[BFcMaxPathLength]; - + leafName = BFrFileRef_GetLeafName(inFileRef); - + sprintf(newName, "%s%c%s", leafName, BFcPathSeparator, inAppendName); - + error = BFrFileRef_SetName(inFileRef, newName); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -266,9 +266,9 @@ BFrTextFile_MapForRead( UUmAssert(NULL != inFileRef); UUmAssert(NULL != outTextFile); - + *outTextFile = NULL; - + newTextFile = UUrMemory_Block_New(sizeof(BFtTextFile)); if(newTextFile == NULL) { @@ -276,7 +276,7 @@ BFrTextFile_MapForRead( } error = BFrFile_Map(inFileRef, 0, &newTextFile->mapping, &newTextFile->fileMemory, &fileLength); - + // failed to load the file into memory free and return if (UUcError_None != error) { @@ -286,12 +286,12 @@ BFrTextFile_MapForRead( newTextFile->curStr = newTextFile->fileMemory; newTextFile->endFile = newTextFile->fileMemory + fileLength; - + *outTextFile = newTextFile; - + return UUcError_None; } - + UUtError BFrTextFile_OpenForRead( BFtFileRef *inFileRef, @@ -303,17 +303,17 @@ BFrTextFile_OpenForRead( UUmAssert(NULL != inFileRef); UUmAssert(NULL != outTextFile); - + *outTextFile = NULL; - + newTextFile = UUrMemory_Block_New(sizeof(BFtTextFile)); if(newTextFile == NULL) { return UUcError_OutOfMemory; } - + error = BFrFileRef_LoadIntoMemory(inFileRef, &fileLength, &newTextFile->fileMemory); - + // failed to load the file into memory free and return if (UUcError_None != error) { @@ -324,9 +324,9 @@ BFrTextFile_OpenForRead( newTextFile->mapping = NULL; newTextFile->curStr = newTextFile->fileMemory; newTextFile->endFile = newTextFile->fileMemory + fileLength; - + *outTextFile = newTextFile; - + return UUcError_None; } @@ -340,27 +340,27 @@ BFrTextFile_MakeFromString( UUmAssert(NULL != inString); UUmAssert(NULL != outTextFile); - + *outTextFile = NULL; - + newTextFile = UUrMemory_Block_New(sizeof(BFtTextFile)); if(newTextFile == NULL) { return UUcError_OutOfMemory; } - + newTextFile->mapping = NULL; newTextFile->fileMemory = UUrMemory_Block_New(strlen(inString) + 1); UUmError_ReturnOnNull(newTextFile->fileMemory); - + strcpy(newTextFile->fileMemory, inString); newTextFile->curStr = newTextFile->fileMemory; - + newTextFile->endFile = newTextFile->fileMemory + strlen(newTextFile->fileMemory); - + *outTextFile = newTextFile; - + return UUcError_None; } @@ -396,18 +396,18 @@ BFrTextFile_GetNextStr( { char *returnStr; char *p; - + UUmAssert(NULL != inTextFile); p = returnStr = inTextFile->curStr; - + if(p >= inTextFile->endFile) { return NULL; } - + while(*p != '\n' && *p != '\r' && *p != '\0' && p < inTextFile->endFile) p++; - + if(*p == '\r') { *p++ = 0; @@ -422,11 +422,11 @@ BFrTextFile_GetNextStr( { // when we are doing this to file-mapped files, we are writing to 1 byte past the // file, which is technically illegal. Fortunately Windows seems to be letting this slide. - *p= 0; + *p= 0; } - + inTextFile->curStr = p; - + return returnStr; } @@ -438,26 +438,26 @@ BFrTextFile_GetNextNWords( char *returnStr; char *p; short n; - + UUmAssert(NULL != inTextFile); p = returnStr = inTextFile->curStr; - + if(p >= inTextFile->endFile) { return NULL; } - + for (n=0; ncurStr = p; - + return returnStr; } @@ -469,13 +469,13 @@ BFrTextFile_VerifyNextNWords( { char *string; UUtBool stringsAreEqual; - + string = BFrTextFile_GetNextNWords(inNumWordsToRead,inTextFile); if (!string) return UUcError_Generic; stringsAreEqual = (0 == strcmp(string,inMatchString)); if (!stringsAreEqual) return UUcError_Generic; - + return UUcError_None; } @@ -491,7 +491,7 @@ BFrTextFile_GetUUtUns32( line = BFrTextFile_GetNextStr(inTextFile); - fieldsScanned = sscanf(line, "%u", &scanned); + fieldsScanned = sscanf(line, "%u", &scanned); UUmAssert(1 == fieldsScanned); @@ -512,7 +512,7 @@ BFrTextFile_GetUUtUns16( line = BFrTextFile_GetNextStr(inTextFile); - fieldsScanned = sscanf(line, "%u", &scanned); + fieldsScanned = sscanf(line, "%u", &scanned); UUmAssert(1 == fieldsScanned); UUmAssert(scanned >= UUcMinUns16); @@ -535,7 +535,7 @@ BFrTextFile_GetUUtInt32( line = BFrTextFile_GetNextStr(inTextFile); - fieldsScanned = sscanf(line, "%d", &scanned); + fieldsScanned = sscanf(line, "%d", &scanned); UUmAssert(1 == fieldsScanned); @@ -557,7 +557,7 @@ BFrTextFile_GetUUtInt16( line = BFrTextFile_GetNextStr(inTextFile); - fieldsScanned = sscanf(line, "%d", &scanned); + fieldsScanned = sscanf(line, "%d", &scanned); UUmAssert(1 == fieldsScanned); UUmAssert(scanned >= UUcMinInt16); @@ -579,7 +579,7 @@ BFrTextFile_GetFloat( line = BFrTextFile_GetNextStr(inTextFile); - fieldsScanned = sscanf(line, "%f", &result); + fieldsScanned = sscanf(line, "%f", &result); UUmAssert(1 == fieldsScanned); @@ -590,7 +590,7 @@ UUtUns32 BFrTextFile_GetOSType(BFtTextFile* inTextFile) { char *line; UUtUns32 result; - + line = BFrTextFile_GetNextStr(inTextFile); UUmAssert(line[0] != 0); UUmAssert(line[1] != 0); @@ -638,7 +638,7 @@ BFrTextFile_VerifyNextStr( (UUtUns32)curLine, 0);*/ } - + return UUcError_None; } @@ -706,7 +706,7 @@ BFrFile_ReadPos( error = BFrFile_SetPos(inFile, inStartPos); - if (UUcError_None == error) { + if (UUcError_None == error) { error = BFrFile_Read(inFile, inLength, inDataPtr); } @@ -725,7 +725,7 @@ BFrFile_WritePos( error = BFrFile_SetPos(inFile, inStartPos); - if (UUcError_None == error) { + if (UUcError_None == error) { error = BFrFile_Write(inFile, inLength, inDataPtr); } @@ -746,7 +746,7 @@ BFrFile_Async_ReadPos( error = BFrFile_SetPos(inFile, inStartPos); - if (UUcError_None == error) { + if (UUcError_None == error) { error = BFrFile_Async_Read(inFile, inLength, inDataPtr, inCompletionFunc, inRefCon); } @@ -766,7 +766,7 @@ BFrFile_Async_WritePos( error = BFrFile_SetPos(inFile, inStartPos); - if (UUcError_None == error) { + if (UUcError_None == error) { error = BFrFile_Async_Write(inFile, inLength, inDataPtr, inCompletionFunc, inRefCon); } @@ -774,11 +774,11 @@ BFrFile_Async_WritePos( } #endif -UUtError -UUcArglist_Call +UUtError +UUcArglist_Call BFrFile_Printf( BFtFile* inFile, - const char *format, + const char *format, ...) { UUtError error; @@ -791,7 +791,7 @@ BFrFile_Printf( va_end(arglist); error = BFrFile_Write(inFile, strlen(msg), msg); - + return error; } @@ -811,7 +811,7 @@ BFrFile_MapClassic( UUmAssert(NULL != inFileRef); UUmAssert(NULL != outSize); UUmAssert(NULL != outPtr); - + *outFile = NULL; *outPtr = NULL; *outSize = 0; @@ -819,12 +819,12 @@ BFrFile_MapClassic( if (!BFrFileRef_FileExists(inFileRef)) { return BFcError_FileNotFound; } - + // to mirror the behavior of windows, try "rw" then "r" error = BFrFile_Open(inFileRef, "rw", &file); if (UUcError_None != error) { error = BFrFile_Open(inFileRef, "r", &file); } if (error) { return error; } - + error = BFrFile_GetLength(file, &size); UUmError_ReturnOnError(error); @@ -842,15 +842,15 @@ BFrFile_MapClassic( { UUmError_ReturnOnError(UUcError_OutOfMemory); } - + error = BFrFile_ReadPos(file, inOffset, size, newMemory); UUmError_ReturnOnError(error); } - + *outFile = file; *outPtr = newMemory; *outSize = size; - + return UUcError_None; } @@ -866,7 +866,7 @@ BFtFile *BFrFile_FOpen(char *inName, char *inMode) } error = BFrFile_Open(&fileRef, inMode, &file); - if (error != UUcError_None) { + if (error != UUcError_None) { goto errorExit; } @@ -917,11 +917,11 @@ BFtFileRef *BFrFileRef_MakeUnique(const char *prefix, const char *suffix, UUtInt UUrString_PadNumber(count, max_digits, number_buffer); sprintf(fileName, "%s%s%s", prefix, number_buffer, suffix); - + error = BFrFileRef_MakeFromName(fileName, &fileRef); - if (error) { - break; + if (error) { + break; } if (!BFrFileRef_FileExists(fileRef)) { @@ -1002,21 +1002,21 @@ static UUtError BFrFileCache_Expand(BFtFileCache *inCache, BFtFileRef *inDirRef, { UUtError error; BFtFileIterator *file_iterator; - + // if we have previously been prepared for use, this invalidates our current state inCache->preparedForUse = UUcFalse; // create a file iterator for the binary directory error = BFrDirectory_FileIterator_New(inDirRef, NULL, NULL, &file_iterator); UUmError_ReturnOnError(error); - + while (1) { BFtFileRef file_ref; - + error = BFrDirectory_FileIterator_Next(file_iterator, &file_ref); if (error != UUcError_None) { break; } - + if (BFrFileRef_IsDirectory(&file_ref)) { if (BFcFileCache_Recursive == inDepth) { error = BFrFileCache_Expand(inCache, &file_ref, inDepth); @@ -1030,14 +1030,14 @@ static UUtError BFrFileCache_Expand(BFtFileCache *inCache, BFtFileRef *inDirRef, inCache->references[inCache->numEntries] = file_ref; inCache->numEntries++; } - + if (error != UUcError_None) { break; } } - + // delete the file iterator BFrDirectory_FileIterator_Delete(file_iterator); file_iterator = NULL; - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_Linux/BFW_FileManager_Linux.c b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_Linux/BFW_FileManager_Linux.c index bdb33bd..8890799 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_Linux/BFW_FileManager_Linux.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_Linux/BFW_FileManager_Linux.c @@ -47,26 +47,26 @@ BFiConvertWin2Unix( { const char* src; char* dst; - + src = inOrigName; dst = outMungedName; - + while(*src != 0) { if(*src == '\\') { *dst++ = '/'; - + src++; } else { *dst++ = *src; - + src++; } } - + *dst = 0; } @@ -82,19 +82,19 @@ BFiCheckFileName( const char *inFileName) { const char *name; - + name = inFileName; - + /* while (*name) { if (name[0] == '/') { char illegal_char[2]; - + illegal_char[0] = name[0]; illegal_char[1] = '\0'; - + UUmError_ReturnOnErrorMsgP( UUcError_Generic, "Illegal character %s in file name.", @@ -102,11 +102,11 @@ BFiCheckFileName( 0, 0); } - + name++; } */ - + return UUcError_None; } @@ -117,10 +117,10 @@ BFrFileRef_Set( { UUtError error; char mungedName[BFcMaxPathLength]; - + UUmAssert(NULL != inFileRef); UUmAssert(NULL != inFileName); - + if(strlen(inFileName) >= BFcMaxPathLength) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Path name too long"); @@ -129,19 +129,19 @@ BFrFileRef_Set( /* Make sure the path name is valid */ error = BFiCheckFileName(inFileName); UUmError_ReturnOnError(error); - + BFiConvertWin2Unix(inFileName, mungedName); - + if(BFiFileRef_PathNameExists(mungedName) == UUcFalse) { return BFcError_FileNotFound; } - + UUrString_Copy(inFileRef->name, inFileName, BFcMaxPathLength); - + { char *leaf_name = BFrPath_To_Name(inFileRef->name); - + if(strlen(leaf_name) >= BFcMaxFileNameLength) { UUmError_ReturnOnErrorMsgP( @@ -150,7 +150,7 @@ BFrFileRef_Set( (UUtUns32)leaf_name, BFcMaxFileNameLength-1, 0); } } - + return UUcError_None; } @@ -158,11 +158,11 @@ void BFrFileRef_Dispose( BFtFileRef *inFileRef) { - + UUmAssert(inFileRef != NULL); - + UUrMemory_Block_Delete(inFileRef); - + } UUtError @@ -171,17 +171,17 @@ BFrFileRef_Duplicate( BFtFileRef **outNewFileRef) { UUtError error; - + UUmAssert(inOrigFileRef != NULL); UUmAssert(outNewFileRef != NULL); - + error = BFrFileRef_MakeFromName( inOrigFileRef->name, outNewFileRef); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -200,7 +200,7 @@ BFrFileRef_GetLeafName( const char * BFrFileRef_GetFullPath( const BFtFileRef* inFileRef) -{ +{ return inFileRef->name; } @@ -216,10 +216,10 @@ BFrFileRef_SetName( UUmAssert(inFileRef != NULL); UUmAssert(inName != NULL); - + error = BFiCheckFileName(inName); UUmError_ReturnOnError(error); - + if (BFrPath_IsAbsolute(inName)) { if(strlen(inName) >= BFcMaxPathLength) @@ -239,7 +239,7 @@ BFrFileRef_SetName( UUrString_Copy(leaf_name, inName, BFcMaxPathLength); } - + { char *leaf_name = BFrPath_To_Name(inFileRef->name); @@ -251,12 +251,12 @@ BFrFileRef_SetName( (UUtUns32)leaf_name, BFcMaxFileNameLength-1, 0); } } - + if(BFiFileRef_PathNameExists(inFileRef->name) == UUcFalse) { return BFcError_FileNotFound; } - + return UUcError_None; } @@ -273,21 +273,21 @@ BFrFile_Create( BFtFileRef *inFileRef) { FILE *file; - + UUmAssert(inFileRef != NULL); UUmAssert(inFileRef->name[0] != '\0'); remove(inFileRef->name); - + file = fopen(inFileRef->name, "wb"); - + if(file == NULL) { return UUcError_Generic; //XXX } - + fclose(file); - + return UUcError_None; } @@ -309,12 +309,12 @@ BFrFile_Open( BFtFile **outFile) { const char *mungedMode; - + UUmAssert(inFileRef != NULL); UUmAssert(inFileRef->name[0] != '\0'); UUmAssert(inMode != NULL); UUmAssert(outFile != NULL); - + if(!strcmp("r", inMode)) { mungedMode = "rb"; @@ -331,14 +331,14 @@ BFrFile_Open( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Illegal file mode"); } - + *outFile = (BFtFile *) fopen(inFileRef->name, mungedMode); if(*outFile == NULL) { return errno == ENOENT ? BFcError_FileNotFound : UUcError_Generic; } - + return UUcError_None; } @@ -358,8 +358,8 @@ BFrFile_Map( BFtFileMapping *mapping; mapping = UUrMemory_Block_New(sizeof(BFtFileMapping)); - if (NULL == mapping) { - error = UUcError_OutOfMemory; + if (NULL == mapping) { + error = UUcError_OutOfMemory; goto fail; } @@ -414,8 +414,8 @@ BFrFile_Map_Default( BFtFileMapping *mappingRef; mappingRef = UUrMemory_Block_New(sizeof(BFtFileMapping)); - if (NULL == mappingRef) { - error = UUcError_OutOfMemory; + if (NULL == mappingRef) { + error = UUcError_OutOfMemory; goto fail; } @@ -463,8 +463,8 @@ BFrFile_Map( mappingRef = UUrMemory_Block_New(sizeof(BFtFileMapping)); if (NULL == mappingRef) - { - error = UUcError_OutOfMemory; + { + error = UUcError_OutOfMemory; goto fail; } @@ -547,7 +547,7 @@ BFrFile_UnMap( } } BFrFile_Close(inMapping->file); - + UUrMemory_Block_Delete(inMapping); } #endif @@ -559,7 +559,7 @@ BFrFile_Flush( UUmAssert(NULL != inFile); fflush((FILE *)inFile); - + return UUcError_None; } @@ -570,7 +570,7 @@ BFrFile_Close( UUmAssert(NULL != inFile); fclose((FILE *)inFile); - + } UUtBool @@ -588,10 +588,10 @@ BFrFileRef_IsEqual( { UUtInt32 result; UUtBool equal; - + result = UUrString_Compare_NoCase(inFileRef1->name, inFileRef2->name); equal = (result == 0); - + return equal; } @@ -601,7 +601,7 @@ BFrFileRef_IsLocked( { return access(inFileRef->name, W_OK) != 0; } - + UUtError BFrFile_GetLength( BFtFile *inFile, @@ -612,9 +612,9 @@ BFrFile_GetLength( if (fd < 0 || fstat(fd, &statbuf) != 0) { UUmError_ReturnOnError(UUcError_Generic); } - + *outLength = statbuf.st_size; - + return UUcError_None; } @@ -627,7 +627,7 @@ BFrFile_GetPos( UUmAssertWritePtr(outPos, sizeof(UUtUns32)); *outPos = ftell((FILE *) inFile); - + return UUcError_None; } @@ -652,7 +652,7 @@ BFrFile_SetPos( return error; } - + UUtError BFrFile_Read( BFtFile *inFile, @@ -688,11 +688,11 @@ BFrFile_Write( UUmAssert(NULL != inFile); UUmAssert((NULL != inData) || (0 == inLength)); - + count = fwrite(inData, 1, inLength, (FILE *)inFile); error = (count == inLength) ? UUcError_None : UUcError_Generic; - + return UUcError_None; } @@ -710,7 +710,7 @@ BFrFileRef_GetModTime( //TODO: duplicated with UUrGetSecsSince1900() static const UUtUns32 secondsBetween1900And1970 = 2208988800; *outSecsSince1900 = statbuf.st_mtime + secondsBetween1900And1970; - + return UUcError_None; } @@ -730,9 +730,9 @@ iCheckFileNameValid( { return UUcFalse; } - + } - + if(inSuffix != NULL) { // Check for suffix match @@ -741,7 +741,7 @@ iCheckFileNameValid( return UUcFalse; } } - + return UUcTrue; } @@ -758,11 +758,11 @@ BFrDirectory_GetFileList( DIR * directory; struct dirent* dirent; char* fileName; - + UUtUns32 curFileIndex; char fullFilePath[1024]; - + AUtSharedStringArray* stringArray; UUtUns32 num; UUtUns32* sortedIndexList; @@ -772,11 +772,11 @@ BFrDirectory_GetFileList( UUtUns32 newIndex; *outNumFiles = 0; - + curFileIndex = 0; - + stringArray = AUrSharedStringArray_New(); - + directory = opendir(inDirectoryRef->name); if(directory == NULL) { @@ -786,32 +786,32 @@ BFrDirectory_GetFileList( } return UUcError_Generic; } - + while((dirent = readdir(directory))) { fileName = dirent->d_name; - + //TODO: symlink are probably fine as well if they resolve to a regular file if(dirent->d_type != DT_REG || iCheckFileNameValid(fileName, inPrefix, inSuffix) == UUcFalse) { continue; } - + if(curFileIndex >= inMaxFiles) { break; } - + // make a new file ref sprintf(fullFilePath, "%s/%s", inDirectoryRef->name, fileName); - error = + error = BFrFileRef_MakeFromName( fullFilePath, &newFileRef); UUmError_ReturnOnErrorMsg(error, "Could not create file ref"); - - error = + + error = AUrSharedStringArray_AddString( stringArray, fileName, @@ -820,29 +820,29 @@ BFrDirectory_GetFileList( UUmError_ReturnOnErrorMsg(error, "Could not add file ref"); curFileIndex++; - + } - + closedir(directory); - + if (errno) { return UUcError_Generic; } - + *outNumFiles = (UUtUns16)curFileIndex; - + num = AUrSharedStringArray_GetNum(stringArray); UUmAssert(curFileIndex == num); - + strings = AUrSharedStringArray_GetList(stringArray); sortedIndexList = AUrSharedStringArray_GetSortedIndexList(stringArray); - + for(itr = 0; itr < num; itr++) { outFileRefArray[itr] = (BFtFileRef*)strings[sortedIndexList[itr]].data; } - + AUrSharedStringArray_Delete(stringArray); return UUcError_None; @@ -853,7 +853,7 @@ struct BFtFileIterator BFtFileRef fileRef; DIR * directory; - + char* prefix; char* suffix; @@ -878,7 +878,7 @@ BFrDirectory_FileIterator_New( { return UUcError_OutOfMemory; } - + newFileIterator->fileRef = *inDirectoryRef; newFileIterator->directory = NULL; newFileIterator->prefix = inPrefix; @@ -887,9 +887,9 @@ BFrDirectory_FileIterator_New( if( inDirectoryRef->name[strlen(inDirectoryRef->name) - 1] != '/' ) { sprintf(newFileIterator->fileRef.name, "%s/", inDirectoryRef->name); } - + *outFileIterator = newFileIterator; - + return UUcError_None; } @@ -900,31 +900,31 @@ BFrDirectory_FileIterator_Next( { struct dirent* dirent; UUtBool stop; - + UUmAssert(inFileIterator->fileRef.name[ strlen( inFileIterator->fileRef.name)-1 ] == '/'); - + if(!inFileIterator->directory) { inFileIterator->directory = opendir(inFileIterator->fileRef.name); - + if(inFileIterator->directory == NULL) { return UUcError_Generic; } - + stop = UUcFalse; } - + while((dirent = readdir(inFileIterator->directory))) { if(dirent->d_type == DT_REG && iCheckFileNameValid(dirent->d_name, inFileIterator->prefix, inFileIterator->suffix)) - { + { sprintf(outFileRef->name, "%s%s", inFileIterator->fileRef.name, dirent->d_name); - + return UUcError_None; } } - + return UUcError_Generic; } @@ -954,20 +954,20 @@ BFrDirectory_DeleteContentsOnly( NULL, &fileIterator); UUmError_ReturnOnError(error); - + while(1) { error = BFrDirectory_FileIterator_Next(fileIterator, &curFileRefToDelete); if(error != UUcError_None) break; - - + + res = stat(curFileRefToDelete.name, &statbuf); if(res != 0) { UUmAssert(UUcFalse); statbuf.st_mode = 0; } - + if(S_ISDIR(statbuf.st_mode)) { BFrDirectory_DeleteDirectoryAndContents(&curFileRefToDelete); @@ -977,7 +977,7 @@ BFrDirectory_DeleteContentsOnly( BFrFile_Delete(&curFileRefToDelete); } } - + BFrDirectory_FileIterator_Delete(fileIterator); return UUcError_None; @@ -1020,7 +1020,7 @@ BFrDirectory_Create( sprintf(buffer, "%s/%s", inDirRef->name, inDirName); success = mkdir(buffer, 0777) == 0; } - + if(success == UUcFalse) return UUcError_Generic; return UUcError_None; @@ -1034,25 +1034,25 @@ BFrFileRef_GetParentDirectory( UUtError error; char path[BFcMaxPathLength]; char *last_dir; - + UUmAssert(inFileRef); UUmAssert(outParentDirectory); - + // initialize *outParentDirectory = NULL; - + UUrString_Copy(path, inFileRef->name, BFcMaxPathLength); - + last_dir = strrchr(path, BFcPathSeparator); if (last_dir == NULL) { return UUcError_Generic; } last_dir[0] = '\0'; - + // create the texture directory file ref error = BFrFileRef_MakeFromName(path, outParentDirectory); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/BFW_FileManager_MacOS.c b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/BFW_FileManager_MacOS.c index c0bd72f..90c0c99 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/BFW_FileManager_MacOS.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/BFW_FileManager_MacOS.c @@ -1,13 +1,13 @@ /* FILE: BFW_FileManager_MacOS.c - + AUTHOR: Brent H. Pease - + CREATED: June 28, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -44,7 +44,7 @@ typedef struct BFtParamBlock UUtBool used; BFtCompletion_Func completionProc; void* refCon; - + } BFtParamBlock; @@ -58,17 +58,17 @@ BFiConvertWin2Mac( const char* src; char* dst; char* colonPtr; - + src = inOrigName; dst = outMungedName; - + colonPtr = strchr(inOrigName, ':'); - + if(colonPtr == NULL && src[0] != '\\') { *dst++ = ':'; } - + while(*src != 0) { if(src[0] == '.' && src[1] == '.' && src[2] == '\\') @@ -79,17 +79,17 @@ BFiConvertWin2Mac( else if(*src == '\\' || src[0] == ':' || src[0] == '/') { *dst++ = ':'; - + src++; } else { *dst++ = *src; - + src++; } } - + *dst = 0; } @@ -98,19 +98,19 @@ BFiCheckFileName( const char *inFileName) { const char *name; - + name = inFileName; - + while (*name) { // if (name[0] == '\/') - This barfs on MrC if (name[0] == '/') { char illegal_char[2]; - + illegal_char[0] = name[0]; illegal_char[1] = '\0'; - + UUmError_ReturnOnErrorMsgP( UUcError_Generic, "Illegal character %s in file name.", @@ -118,10 +118,10 @@ BFiCheckFileName( 0, 0); } - + name++; } - + return UUcError_None; } @@ -134,17 +134,17 @@ BFrFileRef_SetFromFSSpec( UUtUns16 i; Boolean isAlias; Boolean isAliasFolder; - + for(i = 0; i < inFSSpec->name[0]; i++) { outFileRef->leafName[i] = inFSSpec->name[i+1]; } outFileRef->leafName[inFSSpec->name[0]] = 0; outFileRef->fsSpec = *inFSSpec; - + // resolve alias if needed ResolveAliasFile(&outFileRef->fsSpec, true, &isAliasFolder, &isAlias); - + return; } @@ -157,9 +157,9 @@ BFrFileRef_MakeFromFSSpec( // UUtUns16 i; // Boolean isAlias; // Boolean isAliasFolder; - + newFileRef = (BFtFileRef *) UUrMemory_Block_New(sizeof(BFtFileRef)); - + if(newFileRef == NULL) { UUrError_Report( UUcError_OutOfMemory, "Could not allocate new file ref"); @@ -167,9 +167,9 @@ BFrFileRef_MakeFromFSSpec( } BFrFileRef_SetFromFSSpec(inFSSpec, newFileRef); - + *outFileRef = newFileRef; - + return UUcError_None; } @@ -184,10 +184,10 @@ BFrFileRef_Set( char mungedName[BFcMaxPathLength + 30]; const char* slashPtr; UUtUns16 pathLength; - + error = BFiCheckFileName(inFileName); UUmError_ReturnOnError(error); - + pathLength = strlen(inFileName); if(pathLength > BFcMaxPathLength) { @@ -196,7 +196,7 @@ BFrFileRef_Set( "Filename \"%s\" too long, max path length is %d", (UUtUns32)mungedName, BFcMaxPathLength-1, 0); } - + BFiConvertWin2Mac(inFileName, mungedName + 1); slashPtr = strrchr(mungedName + 1, ':'); @@ -204,7 +204,7 @@ BFrFileRef_Set( { slashPtr = inFileName; } - + if(strlen(slashPtr) >= BFcMaxFileNameLength) { UUmError_ReturnOnErrorMsgP( @@ -212,18 +212,18 @@ BFrFileRef_Set( "Filename \"%s\" too long, max leaf name length is %d", (UUtUns32)slashPtr, BFcMaxFileNameLength-1, 0); } - + mungedName[0] = strlen(mungedName + 1); - + osError = FSMakeFSSpec(0, 0, (unsigned char *)mungedName, &fsSpec); - + BFrFileRef_SetFromFSSpec(&fsSpec, inFileRef); if(osError != noErr && osError != fnfErr) { return BFcError_FileNotFound; } - + return UUcError_None; } @@ -232,7 +232,7 @@ BFrFileRef_Dispose( BFtFileRef *inFileRef) { UUmAssert(inFileRef != NULL); - + UUrMemory_Block_Delete(inFileRef); } @@ -243,14 +243,14 @@ BFrFileRef_Duplicate( BFtFileRef **outNewFileRef) { UUtError error; - + error = BFrFileRef_MakeFromFSSpec( &inOrigFileRef->fsSpec, outNewFileRef); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -267,25 +267,25 @@ BFrFileRef_IsDirectory( { OSErr osError; DirInfo dirInfo; - + UUmAssert(inFileRef); - + #if defined(DEBUGGING) && DEBUGGING UUrMemory_Clear(&dirInfo, sizeof(DirInfo)); #endif - + dirInfo.ioCompletion = NULL; dirInfo.ioNamePtr = inFileRef->fsSpec.name; dirInfo.ioVRefNum = inFileRef->fsSpec.vRefNum; dirInfo.ioFDirIndex = 0; dirInfo.ioDrDirID = inFileRef->fsSpec.parID; - + osError = PBGetCatInfo((CInfoPBPtr)&dirInfo, 0); if(osError != noErr) { return UUcFalse; } - + return ((dirInfo.ioFlAttrib & (1 << 4)) != 0); } @@ -295,11 +295,11 @@ BFrFileRef_IsEqual( const BFtFileRef *inFileRef2) { UUtBool equal; - + equal = (inFileRef1->fsSpec.vRefNum == inFileRef2->fsSpec.vRefNum) && (inFileRef1->fsSpec.parID == inFileRef2->fsSpec.parID) && (UUrString_Compare_NoCase(inFileRef1->leafName, inFileRef2->leafName) == 0); - + return equal; } @@ -309,9 +309,9 @@ BFrFileRef_IsLocked( { OSErr osError; HFileInfo fileInfo; - + UUmAssert(inFileRef); - + #if defined(DEBUGGING) && DEBUGGING UUrMemory_Clear(&fileInfo, sizeof(fileInfo)); #endif @@ -321,13 +321,13 @@ BFrFileRef_IsLocked( fileInfo.ioVRefNum = inFileRef->fsSpec.vRefNum; fileInfo.ioFDirIndex = 0; fileInfo.ioDirID = inFileRef->fsSpec.parID; - + osError = PBGetCatInfo((CInfoPBPtr)&fileInfo, 0); if(osError != noErr) { return UUcFalse; } - + return ((fileInfo.ioFlAttrib & (1 << 0)) != 0); } @@ -338,10 +338,10 @@ BFrFileRef_GetParentDirectory( { OSErr osError; FSSpec parent_FSSpec; - + // initialize *outParentDirectory = NULL; - + // get the parent directory osError = FSMakeFSSpec( @@ -353,7 +353,7 @@ BFrFileRef_GetParentDirectory( { return UUcError_Generic; } - + return BFrFileRef_MakeFromFSSpec(&parent_FSSpec, outParentDirectory); } @@ -369,10 +369,10 @@ BFrFileRef_SetName( const char* slashPtr; UUtBool isDirectory = UUcFalse; UUtBool absolute_path = BFrPath_IsAbsolute(inName); - + error = BFiCheckFileName(inName); UUmError_ReturnOnError(error); - + slashPtr = strrchr(inName, '\\'); if(slashPtr == NULL) { @@ -383,7 +383,7 @@ BFrFileRef_SetName( if(*slashPtr == '\\') slashPtr++; if(*slashPtr == 0) isDirectory = UUcTrue; } - + if(strlen(slashPtr) >= BFcMaxFileNameLength) { UUmError_ReturnOnErrorMsgP( @@ -391,9 +391,9 @@ BFrFileRef_SetName( "Filename \"%s\" too long, max length is %d", (UUtUns32)slashPtr, BFcMaxFileNameLength-1, 0); } - + UUmAssert(strlen(inName) < 128); - + BFiConvertWin2Mac(inName, mungedName + 1); mungedName[0] = strlen(mungedName + 1); @@ -403,19 +403,19 @@ BFrFileRef_SetName( absolute_path ? 0 : inFileRef->fsSpec.parID, (unsigned char *)mungedName, &inFileRef->fsSpec); - + if(osError != noErr && osError != fnfErr) { return BFcError_FileNotFound; } - + // Reset the leaf name for(i = 0; i < inFileRef->fsSpec.name[0]; i++) { inFileRef->leafName[i] = inFileRef->fsSpec.name[i+1]; } inFileRef->leafName[inFileRef->fsSpec.name[0]] = 0; - + return UUcError_None; } @@ -424,7 +424,7 @@ BFrFileRef_GetFullPath( const BFtFileRef* inFileRef) { UUmAssert(!"Implement Me"); - + return NULL; } @@ -434,19 +434,19 @@ BFrFileRef_FileExists( { OSErr error; FSSpec fsSpec; - - error = + + error = FSMakeFSSpec( inFileRef->fsSpec.vRefNum, inFileRef->fsSpec.parID, inFileRef->fsSpec.name, &fsSpec); - + if(error != noErr) { return UUcFalse; } - + return UUcTrue; } @@ -457,22 +457,22 @@ BFrFileRef_GetModTime( { OSErr osError; HFileParam fileParamBlock; - + fileParamBlock.ioCompletion = NULL; fileParamBlock.ioNamePtr = inFileRef->fsSpec.name; fileParamBlock.ioVRefNum = inFileRef->fsSpec.vRefNum; fileParamBlock.ioFDirIndex = 0; fileParamBlock.ioDirID = inFileRef->fsSpec.parID; - + osError = PBHGetFInfo((HParmBlkPtr)&fileParamBlock, 0); - + if(osError != noErr) { return BFcError_FileNotFound; } - + *outSecsSince1900 = fileParamBlock.ioFlMdDat + UUc1904_To_1900_era_offset; - + return UUcError_None; } @@ -491,7 +491,7 @@ BFrFile_Create( OSType filetype= 'INST'; char filename[64]= {0}; UUtError error= UUcError_None; - + // make any adjustments necessary to filetype info p2cstrcpy(filename, inFileRef->fsSpec.name); if (strstr(filename, ".bmp") || strstr(filename, ".BMP")) @@ -519,7 +519,7 @@ BFrFile_Create( } error= FSpCreate(&inFileRef->fsSpec, creator, filetype,0); - + return error; } @@ -529,16 +529,16 @@ BFrFile_Delete( { OSErr error; - error = + error = FSpDelete( &inFileRef->fsSpec); - + if(error != noErr) { - + return BFcError_FileNotFound; } - + return UUcError_None; } @@ -552,7 +552,7 @@ BFrFile_Open( short refNum; char permission; UUtBool create = UUcFalse; - + if(!strcmp("r", inMode)) { permission = fsRdPerm; @@ -572,33 +572,33 @@ BFrFile_Open( UUrError_Report(UUcError_Generic, "Illegal file mode"); return UUcError_Generic; } - - error = + + error = FSpOpenDF( &inFileRef->fsSpec, permission, &refNum); - + // if file does not exist attempt to create the file like fopen if ((fnfErr == error) && create) { error = BFrFile_Create(inFileRef); if (error != UUcError_None) return error; - - error = + + error = FSpOpenDF( &inFileRef->fsSpec, permission, &refNum); } - + if(error != noErr) { return BFcError_FileNotFound; } - + *outFile = (BFtFile *)refNum; - + return UUcError_None; } @@ -611,15 +611,15 @@ BFrFile_Flush( paramBlock.ioCompletion = NULL; paramBlock.ioRefNum = (short)inFile; - + osError = PBFlushFileSync((ParmBlkPtr)¶mBlock); - + if(osError != noErr) { UUrError_Report(UUcError_Generic, "could not flush file"); return UUcError_Generic; } - + return UUcError_None; } @@ -630,7 +630,7 @@ BFrFile_Close( OSErr osError; osError = FSClose((short)inFile); - + if(osError != noErr) { UUrError_Report(UUcError_Generic, "could not close file"); @@ -644,11 +644,11 @@ BFrFile_GetLength( { OSErr error; short refNum; - + refNum = (short)inFile; - + error = GetEOF(refNum, (long*)outLength); - + if(error != noErr) { UUrError_Report(UUcError_Generic, "could not get length"); @@ -683,7 +683,7 @@ BFrFile_SetEOF( { OSErr osErr; UUtInt32 filePos; - + // get the current read/write position of the file osErr = GetFPos((short)inFile, &filePos); if (osErr != noErr) { return UUcError_Generic; } @@ -691,7 +691,7 @@ BFrFile_SetEOF( // set the End Of File (EOF) to the current position osErr = SetEOF((short)inFile, filePos); if (osErr != noErr) { return UUcError_Generic; } - + return UUcError_None; } @@ -701,14 +701,14 @@ BFrFile_SetPos( UUtUns32 inPos) { OSErr osErr; - + UUmAssert(inFile != NULL); osErr = SetFPos((short) inFile, fsFromStart, (long) inPos); - + if (eofErr == osErr) { osErr = SetEOF((short) inFile, (long) inPos); - + if (noErr != osErr) { return UUcError_Generic; } @@ -719,7 +719,7 @@ BFrFile_SetPos( if (noErr != osErr) { return UUcError_Generic; } - + return UUcError_None; } @@ -734,30 +734,30 @@ BFrFile_Read( UUtUns32 num_reads; char *buffer; const UUtInt32 max_bytes = (1 << 23); // 1 << 23 = 8,388,608 - + // read the data in a maximum of max_bytes at a time num_reads = (inLength / max_bytes) + 1; buffer = (char*)inData; length = (UUtInt32)inLength; - + while (num_reads--) { UUtInt32 bytes_to_read; - + bytes_to_read = UUmMin(length, max_bytes); - + osError = FSRead((short)inFile, &bytes_to_read, buffer); if(osError != noErr) { // UUrError_Report(UUcError_Generic, "could not read file"); return UUcError_Generic; } - + // prepare for next read length -= bytes_to_read; buffer += bytes_to_read; } - + #if 0 const UUtUns32 max_bytes = (1 << 23); // 1 << 23 = 8388608 if (inLength < max_bytes) @@ -767,20 +767,20 @@ BFrFile_Read( { UUtUns32 num_reads; char *buffer; - + // read the data in a maximum of max_bytes at a time num_reads = (inLength / max_bytes) + 1; buffer = (char*)inData; - + while (num_reads--) { UUtUns32 bytes_to_read; - + // calculate the number of bytes to read length = UUmMin(length, max_bytes); - + length = bytes_to_read; - + // read the data from the file osError = FSRead((short)inFile, &length, buffer); if(osError != noErr) @@ -789,14 +789,14 @@ BFrFile_Read( return UUcError_Generic; } UUmAssert(length == bytes_to_read); - + // prepare for next read length -= bytes_to_read; buffer += bytes_to_read; } } #endif - + return UUcError_None; } @@ -808,15 +808,15 @@ BFrFile_Write( { OSErr osError; UUtInt32 length = inLength; - + osError = FSWrite((short)inFile, &length, inData); - + if(osError != noErr) { UUrError_Report(UUcError_Generic, "could not read file"); return UUcError_Generic; } - + return UUcError_None; } @@ -842,19 +842,19 @@ BFrFile_Async_Read( BFtParamBlock* bfParamBlock; OSErr osError; UUtUns16 itr; - + for(itr = 0, bfParamBlock = BFgParamBlocks; itr < BFcMaxParamBlocks; itr++, bfParamBlock++) { if(bfParamBlock->used == UUcFalse) break; } - + if(itr == BFcMaxParamBlocks) return UUcError_Generic; - + bfParamBlock->completionProc = inCompletionFunc; bfParamBlock->refCon = inRefCon; - + bfParamBlock->paramBlock.ioCompletion = (IOCompletionUPP)BFiFile_Async_CompletionFunc; bfParamBlock->paramBlock.ioVRefNum = 0; bfParamBlock->paramBlock.ioRefNum = (short)inFile; @@ -862,18 +862,18 @@ BFrFile_Async_Read( bfParamBlock->paramBlock.ioReqCount = inLength; bfParamBlock->paramBlock.ioPosMode = fsFromMark; bfParamBlock->paramBlock.ioPosOffset = 0; - + osError = PBReadAsync((ParmBlkPtr)&bfParamBlock); - + if(osError != noErr) { UUrError_Report(UUcError_Generic, "could not read file"); return UUcError_Generic; } return UUcError_None; -#endif +#endif } - + UUtError BFrFile_Async_Write( BFtFile* inFile, @@ -888,19 +888,19 @@ BFrFile_Async_Write( BFtParamBlock* bfParamBlock; OSErr osError; UUtUns16 itr; - + for(itr = 0, bfParamBlock = BFgParamBlocks; itr < BFcMaxParamBlocks; itr++, bfParamBlock++) { if(bfParamBlock->used == UUcFalse) break; } - + if(itr == BFcMaxParamBlocks) return UUcError_Generic; - + bfParamBlock->completionProc = inCompletionFunc; bfParamBlock->refCon = inRefCon; - + bfParamBlock->paramBlock.ioCompletion = (IOCompletionUPP)BFiFile_Async_CompletionFunc; bfParamBlock->paramBlock.ioVRefNum = 0; bfParamBlock->paramBlock.ioRefNum = (short)inFile; @@ -908,15 +908,15 @@ BFrFile_Async_Write( bfParamBlock->paramBlock.ioReqCount = inLength; bfParamBlock->paramBlock.ioPosMode = fsFromMark; bfParamBlock->paramBlock.ioPosOffset = 0; - + osError = PBWriteAsync((ParmBlkPtr)&bfParamBlock); - + if(osError != noErr) { UUrError_Report(UUcError_Generic, "could not read file"); return UUcError_Generic; } - + return UUcError_None; #endif } @@ -929,9 +929,9 @@ BFiCheckCPBValid( { char* targetName; char buffer[512]; - + UUrString_PStr2CStr(cpbPtr->hFileInfo.ioNamePtr, buffer, 512); - + targetName = buffer; if(inPrefix != NULL) @@ -941,9 +941,9 @@ BFiCheckCPBValid( { return UUcFalse; } - + } - + if(inSuffix != NULL) { // Check for suffix match @@ -952,7 +952,7 @@ BFiCheckCPBValid( return UUcFalse; } } - + return UUcTrue; } @@ -961,12 +961,12 @@ typedef struct tContentsData UUtUns16 maxNumFiles; UUtUns16 curFileIndex; //BFtFileRef** fileRefArray; - + AUtSharedStringArray* stringArray; - + char* prefix; char* suffix; - + } tContentsData; static pascal void @@ -983,23 +983,23 @@ BFiDirectory_ContentsIterator( char cstr[128]; UUtUns16 itr; UUtUns32 newIndex; - + *outQuitFlag = false; - + //if(!(cpbPtr->hFileInfo.ioFlAttrib & ioDirMask)) - + if(contentsData->curFileIndex >= contentsData->maxNumFiles) { *outQuitFlag = true; return; } - + if(BFiCheckCPBValid(cpbPtr, contentsData->prefix, contentsData->suffix) == UUcFalse) { return; } - - osErr = + + osErr = FSMakeFSSpec( cpbPtr->hFileInfo.ioVRefNum, cpbPtr->hFileInfo.ioFlParID, @@ -1010,8 +1010,8 @@ BFiDirectory_ContentsIterator( *outQuitFlag = true; return; } - - error = + + error = BFrFileRef_MakeFromFSSpec( &fsSpec, &newFileRef); @@ -1021,14 +1021,14 @@ BFiDirectory_ContentsIterator( *outQuitFlag = true; return; } - + for(itr = 0; itr < *cpbPtr->hFileInfo.ioNamePtr; itr++) { cstr[itr] = cpbPtr->hFileInfo.ioNamePtr[itr+1]; } cstr[itr] = 0; - - error = + + error = AUrSharedStringArray_AddString( contentsData->stringArray, cstr, @@ -1039,7 +1039,7 @@ BFiDirectory_ContentsIterator( *outQuitFlag = true; return; } - + contentsData->curFileIndex++; } @@ -1059,26 +1059,26 @@ BFrDirectory_GetFileList( UUtUns32* sortedIndexList; AUtSharedString* strings; UUtUns16 itr; - + *outNumFiles = 0; stringArray = AUrSharedStringArray_New(); UUmError_ReturnOnNull(stringArray); - + contentsData.maxNumFiles = inMaxFiles; contentsData.curFileIndex = 0; //contentsData.fileRefArray = outFileRefArray; contentsData.prefix = inPrefix; contentsData.suffix = inSuffix; contentsData.stringArray = stringArray; - - osErr = + + osErr = FSpIterateDirectory( &inDirectoryRef->fsSpec, 1, BFiDirectory_ContentsIterator, (void*)&contentsData); - + if (fnfErr == osErr) { goto exit; } @@ -1086,20 +1086,20 @@ BFrDirectory_GetFileList( AUrSharedStringArray_Delete(stringArray); return UUcError_Generic; } - + *outNumFiles = contentsData.curFileIndex; - + num = AUrSharedStringArray_GetNum(stringArray); UUmAssert(contentsData.curFileIndex == num); - + strings = AUrSharedStringArray_GetList(stringArray); sortedIndexList = AUrSharedStringArray_GetSortedIndexList(stringArray); - + for(itr = 0; itr < num; itr++) { outFileRefArray[itr] = (BFtFileRef*)strings[sortedIndexList[itr]].data; } - + exit: AUrSharedStringArray_Delete(stringArray); return UUcError_None; @@ -1109,10 +1109,10 @@ struct BFtFileIterator { CInfoPBRec cPB; /* the parameter block used for PBGetCatInfo calls */ Str63 itemName; /* the name of the current item */ - + UUtUns16 index; UUtInt32 dirID; - + char* prefix; char* suffix; @@ -1130,13 +1130,13 @@ BFrDirectory_FileIterator_New( Boolean isDirectory; UUtInt16 theVRefNum; UUtInt32 theDirID; - + newFileIterator = UUrMemory_Block_New(sizeof(BFtFileIterator)); if(newFileIterator == NULL) { return UUcError_OutOfMemory; } - + /* Get the real directory ID and make sure it is a directory */ osErr = GetDirectoryID( @@ -1149,12 +1149,12 @@ BFrDirectory_FileIterator_New( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "GetDirectoryID return an error"); } - + if(isDirectory == false) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "inDirectoryRef must be a directory"); } - + /* Get the real vRefNum */ osErr = DetermineVRefNum(inDirectoryRef->fsSpec.name, inDirectoryRef->fsSpec.vRefNum, &theVRefNum); if(osErr != noErr) @@ -1169,9 +1169,9 @@ BFrDirectory_FileIterator_New( newFileIterator->index = 1; newFileIterator->prefix = inPrefix; newFileIterator->suffix = inSuffix; - + *outFileIterator = newFileIterator; - + return UUcError_None; } @@ -1183,21 +1183,21 @@ BFrDirectory_FileIterator_Next( OSErr osErr; // UUtError error; FSSpec fsSpec; - + do { inFileIterator->cPB.dirInfo.ioFDirIndex = inFileIterator->index++; inFileIterator->cPB.dirInfo.ioDrDirID = inFileIterator->dirID; - + osErr = PBGetCatInfoSync((CInfoPBPtr)&inFileIterator->cPB); if(osErr != noErr) { return UUcError_Generic; } - + } while(BFiCheckCPBValid(&inFileIterator->cPB, inFileIterator->prefix, inFileIterator->suffix) == UUcFalse); - osErr = + osErr = FSMakeFSSpec( inFileIterator->cPB.hFileInfo.ioVRefNum, inFileIterator->cPB.hFileInfo.ioFlParID, @@ -1207,10 +1207,10 @@ BFrDirectory_FileIterator_Next( { return UUcError_Generic; } - + BFrFileRef_SetFromFSSpec(&fsSpec, outFileRef); - + return UUcError_None; } @@ -1226,18 +1226,18 @@ BFrDirectory_DeleteContentsOnly( BFtFileRef* inDirectoryRef) { OSErr err; - + err = DeleteDirectoryContents( inDirectoryRef->fsSpec.vRefNum, inDirectoryRef->fsSpec.parID, inDirectoryRef->fsSpec.name); - + if(err != noErr) { return UUcError_Generic; } - + return UUcError_None; } @@ -1246,18 +1246,18 @@ BFrDirectory_DeleteDirectoryAndContents( BFtFileRef* inDirectoryRef) { OSErr err; - + err = DeleteDirectory( inDirectoryRef->fsSpec.vRefNum, inDirectoryRef->fsSpec.parID, inDirectoryRef->fsSpec.name); - + if(err != noErr) { return UUcError_Generic; } - + return UUcError_None; } @@ -1269,7 +1269,7 @@ BFrDirectory_Create( OSErr err; char mungedName[BFcMaxPathLength]; UUtInt32 newDirID; - + if(inDirName == NULL) { err = @@ -1282,14 +1282,14 @@ BFrDirectory_Create( else { BFiConvertWin2Mac(inDirName, mungedName + 1); - + if(strlen(mungedName + 1) > 255) { return UUcError_Generic; } - + mungedName[0] = strlen(mungedName + 1); - + err = DirCreate( inParentDirRef->fsSpec.vRefNum, @@ -1297,12 +1297,12 @@ BFrDirectory_Create( (unsigned char *)mungedName, &newDirID); } - + if(err != noErr) { return UUcError_Generic; } - + return UUcError_None; } @@ -1321,8 +1321,8 @@ BFrFile_Map( BFtFileMapping *mapping; mapping = UUrMemory_Block_New(sizeof(BFtFileMapping)); - if (NULL == mapping) { - error = UUcError_OutOfMemory; + if (NULL == mapping) { + error = UUcError_OutOfMemory; goto fail; } diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/DirectoryCopy.c b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/DirectoryCopy.c index 48d24a3..249e09b 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/DirectoryCopy.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/DirectoryCopy.c @@ -90,7 +90,7 @@ struct PreflightGlobals CInfoPBRec myCPB; /* the parameter block used for PBGetCatInfo calls */ unsigned long dstBlksPerAllocBlk; /* the number of 512 byte blocks per allocation block on destination */ - + unsigned long allocBlksNeeded; /* the total number of allocation blocks needed */ unsigned long tempBlocks; /* temporary storage for calculations (save some stack space) */ @@ -119,14 +119,14 @@ static OSErr PreflightDirectoryCopySpace(short srcVRefNum, static void CopyLevel(long sourceDirID, long dstDirID, EnumerateGlobals *theGlobals); - + /*****************************************************************************/ static void GetLevelSize(long currentDirID, PreflightGlobals *theGlobals) { short index = 1; - + do { theGlobals->myCPB.dirInfo.ioFDirIndex = index; @@ -143,7 +143,7 @@ static void GetLevelSize(long currentDirID, if ( (theGlobals->myCPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* we have a directory */ - + GetLevelSize(theGlobals->myCPB.dirInfo.ioDrDirID, theGlobals); /* recurse */ theGlobals->result = noErr; /* clear error return on way back */ } @@ -152,7 +152,7 @@ static void GetLevelSize(long currentDirID, /* We have a file - add its allocation blocks to allocBlksNeeded. */ /* Since space on Mac OS disks is always allocated in allocation blocks, */ /* this takes into account rounding up to the end of an allocation block. */ - + /* get number of 512-byte blocks needed for data fork */ if ( ((unsigned long)theGlobals->myCPB.hFileInfo.ioFlLgLen & 0x000001ff) != 0 ) { @@ -171,7 +171,7 @@ static void GetLevelSize(long currentDirID, { theGlobals->allocBlksNeeded += theGlobals->tempBlocks / theGlobals->dstBlksPerAllocBlk; } - + /* get number of 512-byte blocks needed for resource fork */ if ( ((unsigned long)theGlobals->myCPB.hFileInfo.ioFlRLgLen & 0x000001ff) != 0 ) { @@ -209,26 +209,26 @@ static OSErr PreflightDirectoryCopySpace(short srcVRefNum, OSErr error; unsigned long dstFreeBlocks; PreflightGlobals theGlobals; - + error = XGetVolumeInfoNoName(NULL, dstVRefNum, &pb); if ( error == noErr ) { /* Convert freeBytes to free disk blocks (512-byte blocks) */ dstFreeBlocks = U32SetU(U64ShiftRight(pb.ioVFreeBytes, 9)); - + /* get allocation block size (always multiple of 512) and divide by 512 to get number of 512-byte blocks per allocation block */ theGlobals.dstBlksPerAllocBlk = ((unsigned long)pb.ioVAlBlkSiz >> 9); - + theGlobals.allocBlksNeeded = 0; theGlobals.myCPB.dirInfo.ioNamePtr = theGlobals.itemName; theGlobals.myCPB.dirInfo.ioVRefNum = srcVRefNum; - + theGlobals.copyFilterProc = copyFilterProc; - + GetLevelSize(srcDirID, &theGlobals); - + /* Is there enough room on the destination volume for the source file? */ /* Note: This will work because the largest number of disk blocks supported */ /* on a 2TB volume is 0xffffffff and (allocBlksNeeded * dstBlksPerAllocBlk) */ @@ -248,14 +248,14 @@ static void CopyLevel(long sourceDirID, long currentSrcDirID; long newDirID; short index = 1; - + do - { + { /* Get next source item at the current directory level */ - + theGlobals->myCPB.dirInfo.ioFDirIndex = index; theGlobals->myCPB.dirInfo.ioDrDirID = sourceDirID; - theGlobals->error = PBGetCatInfoSync(&theGlobals->myCPB); + theGlobals->error = PBGetCatInfoSync(&theGlobals->myCPB); if ( theGlobals->error == noErr ) { @@ -268,7 +268,7 @@ static void CopyLevel(long sourceDirID, if ( (theGlobals->myCPB.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* We have a directory */ - + /* Create a new directory at the destination. No errors allowed! */ theGlobals->error = DirCreate(theGlobals->destinationVRefNum, dstDirID, theGlobals->itemName, &newDirID); if ( theGlobals->error == noErr ) @@ -276,20 +276,20 @@ static void CopyLevel(long sourceDirID, /* Save the current source directory ID where we can get it when we come back ** from recursion land. */ currentSrcDirID = theGlobals->myCPB.dirInfo.ioDrDirID; - + /* Dive again (copy the directory level we just found below this one) */ CopyLevel(theGlobals->myCPB.dirInfo.ioDrDirID, newDirID, theGlobals); - + if ( !theGlobals->bailout ) { /* Copy comment from old to new directory. */ /* Ignore the result because we really don't care if it worked or not. */ (void) DTCopyComment(theGlobals->myCPB.dirInfo.ioVRefNum, currentSrcDirID, NULL, theGlobals->destinationVRefNum, newDirID, NULL); - + /* Copy directory attributes (dates, etc.) to newDirID. */ /* No errors allowed */ theGlobals->error = CopyFileMgrAttributes(theGlobals->myCPB.dirInfo.ioVRefNum, currentSrcDirID, NULL, theGlobals->destinationVRefNum, newDirID, NULL, true); - + /* handle any errors from CopyFileMgrAttributes */ if ( theGlobals->error != noErr ) { @@ -323,7 +323,7 @@ static void CopyLevel(long sourceDirID, theGlobals->bailout = true; } } - + if ( !theGlobals->bailout ) { /* clear error return on way back if we aren't bailing out */ @@ -333,7 +333,7 @@ static void CopyLevel(long sourceDirID, else { /* We have a file, so copy it */ - + theGlobals->error = FileCopy(theGlobals->myCPB.hFileInfo.ioVRefNum, theGlobals->myCPB.hFileInfo.ioFlParID, theGlobals->itemName, @@ -344,7 +344,7 @@ static void CopyLevel(long sourceDirID, theGlobals->copyBuffer, theGlobals->bufferSize, false); - + /* handle any errors from FileCopy */ if ( theGlobals->error != noErr ) { @@ -375,7 +375,7 @@ static void CopyLevel(long sourceDirID, if ( theGlobals->error != fnfErr ) { if ( theGlobals->errorHandler != NULL ) - { + { theGlobals->bailout = CallCopyErrProc(theGlobals->errorHandler, theGlobals->error, getNextItemOp, theGlobals->myCPB.dirInfo.ioVRefNum, sourceDirID, NULL, 0, 0, NULL); if ( !theGlobals->bailout ) @@ -416,8 +416,8 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, OSErr error; Boolean ourCopyBuffer = false; Str63 srcDirName, oldDiskName; - Boolean spaceOK; - + Boolean spaceOK; + /* Make sure a copy buffer is allocated. */ if ( copyBufferPtr == NULL ) { @@ -437,7 +437,7 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, } ourCopyBuffer = true; } - + /* Get the real dirID where we're copying from and make sure it is a directory. */ error = GetDirectoryID(srcVRefNum, srcDirID, srcName, &srcDirID, &isDirectory); if ( error != noErr ) @@ -449,7 +449,7 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, error = dirNFErr; goto ErrorExit; } - + /* Special case destination if it is the root parent directory. */ /* Since you can't create the root directory, this is needed if */ /* you want to copy a directory's content to a disk's root directory. */ @@ -473,7 +473,7 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, goto ErrorExit; } } - + /* Get the real vRefNum of both the source and destination */ error = DetermineVRefNum(srcName, srcVRefNum, &srcVRefNum); if ( error != noErr ) @@ -485,7 +485,7 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, { goto ErrorExit; } - + if ( preflight ) { error = PreflightDirectoryCopySpace(srcVRefNum, srcDirID, dstVRefNum, copyFilterProc, &spaceOK); @@ -507,7 +507,7 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, { goto ErrorExit; } - + /* Again, special case destination if the destination is the */ /* root parent directory. This time, we'll rename the disk to */ /* the source directory name. */ @@ -515,7 +515,7 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, { /* Get the current name of the destination disk */ error = GetDirName(dstVRefNum, fsRtDirID, oldDiskName); - if ( error == noErr ) + if ( error == noErr ) { /* use the copyName as srcDirName if supplied */ if ( copyName != NULL ) @@ -525,10 +525,10 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, } /* Shorten the name if it's too long to be the volume name */ TruncPString(srcDirName, srcDirName, 27); - + /* Rename the disk */ error = HRename(dstVRefNum, fsRtParID, oldDiskName, srcDirName); - + /* and copy to the root directory */ dstDirID = fsRtDirID; } @@ -563,9 +563,9 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, goto ErrorExit; } } - + /* dstDirID is now the newly created directory! */ - + /* Set up the globals we need to access from the recursive routine. */ theGlobals.copyBuffer = (Ptr)copyBufferPtr; theGlobals.bufferSize = copyBufferSize; @@ -575,21 +575,21 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, theGlobals.errorHandler = copyErrHandler; theGlobals.bailout = false; theGlobals.copyFilterProc = copyFilterProc; - + /* Here we go into recursion land... */ CopyLevel(srcDirID, dstDirID, &theGlobals); error = theGlobals.error; /* get the result */ - + if ( !theGlobals.bailout ) { /* Copy comment from source to destination directory. */ /* Ignore the result because we really don't care if it worked or not. */ (void) DTCopyComment(srcVRefNum, srcDirID, NULL, dstVRefNum, dstDirID, NULL); - + /* Copy the File Manager attributes */ error = CopyFileMgrAttributes(srcVRefNum, srcDirID, NULL, dstVRefNum, dstDirID, NULL, true); - + /* handle any errors from CopyFileMgrAttributes */ if ( (error != noErr) && (copyErrHandler != NULL) ) { diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/DirectoryCopy.h b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/DirectoryCopy.h index fc57010..5c5e41f 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/DirectoryCopy.h +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/DirectoryCopy.h @@ -74,7 +74,7 @@ typedef pascal Boolean (*CopyErrProcPtr) (OSErr error, dstDirID specifies the directory. __________ - + Also see: FilteredDirectoryCopy, FSpFilteredDirectoryCopy, DirectoryCopy, FSpDirectoryCopy */ @@ -89,11 +89,11 @@ typedef pascal Boolean (*CopyFilterProcPtr) (const CInfoPBRec * const cpbPtr); This is the prototype for the CopyFilterProc function called by FilteredDirectoryCopy and GetLevelSize. If true is returned, the file/folder is included in the copy, otherwise it is excluded. - + pb input: Points to the CInfoPBRec for the item under consideration. __________ - + Also see: FilteredDirectoryCopy, FSpFilteredDirectoryCopy */ @@ -121,10 +121,10 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, copyBufferPtr = NIL, then this routine allocates a buffer in the application heap. If you pass a copy buffer to this routine, make its size a multiple of 512 ($200) bytes for optimum performance. - + The optional copyFilterProc parameter lets a routine you define decide what files or directories are copied to the destination. - + FilteredDirectoryCopy normally creates a new directory *in* the specified destination directory and copies the source directory's content into the new directory. However, if root parent directory @@ -136,7 +136,7 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, This special case is supported by FilteredDirectoryCopy, but not by FSpFilteredDirectoryCopy since with FSpFilteredDirectoryCopy, the dstName parameter can not be NULL. - + srcVRefNum input: Source volume specification. srcDirID input: Source directory ID. srcName input: Source directory name, or nil if @@ -168,7 +168,7 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, copyFilterProc input: A pointer to the filter routine you want called for each item in the source directory, or NULL if you don't want to filter. - + Result Codes noErr 0 No error readErr –19 Driver does not respond to read requests @@ -206,9 +206,9 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, modes afpObjectTypeErr -5025 Source is a directory, directory not found or incomplete pathname - + __________ - + Also see: CopyErrProcPtr, CopyFilterProcPtr, FSpFilteredDirectoryCopy, DirectoryCopy, FSpDirectoryCopy, FileCopy, FSpFileCopy */ @@ -231,10 +231,10 @@ pascal OSErr FSpFilteredDirectoryCopy(const FSSpec *srcSpec, copyBufferPtr = NIL, then this routine allocates a buffer in the application heap. If you pass a copy buffer to this routine, make its size a multiple of 512 ($200) bytes for optimum performance. - + The optional copyFilterProc parameter lets a routine you define decide what files or directories are copied to the destination. - + srcSpec input: An FSSpec record specifying the directory to copy. dstSpec input: An FSSpec record specifying destination directory of the copy. @@ -261,7 +261,7 @@ pascal OSErr FSpFilteredDirectoryCopy(const FSSpec *srcSpec, copyFilterProc input: A pointer to the filter routine you want called for each item in the source directory, or NULL if you don't want to filter. - + Result Codes noErr 0 No error readErr –19 Driver does not respond to read requests @@ -299,9 +299,9 @@ pascal OSErr FSpFilteredDirectoryCopy(const FSSpec *srcSpec, modes afpObjectTypeErr -5025 Source is a directory, directory not found or incomplete pathname - + __________ - + Also see: CopyErrProcPtr, CopyFilterProcPtr, FilteredDirectoryCopy, DirectoryCopy, FSpDirectoryCopy, FileCopy, FSpFileCopy */ @@ -327,7 +327,7 @@ pascal OSErr DirectoryCopy(short srcVRefNum, routine allocates a buffer in the application heap. If you pass a copy buffer to this routine, make its size a multiple of 512 ($200) bytes for optimum performance. - + DirectoryCopy normally creates a new directory *in* the specified destination directory and copies the source directory's content into the new directory. However, if root parent directory (fsRtParID) @@ -338,7 +338,7 @@ pascal OSErr DirectoryCopy(short srcVRefNum, destination volume's root directory. This special case is supported by DirectoryCopy, but not by FSpDirectoryCopy since with FSpDirectoryCopy, the dstName parameter can not be NULL. - + srcVRefNum input: Source volume specification. srcDirID input: Source directory ID. srcName input: Source directory name, or nil if @@ -367,7 +367,7 @@ pascal OSErr DirectoryCopy(short srcVRefNum, error will cause the copy to quit and DirectoryCopy will return the error. Error handling is recommended... - + Result Codes noErr 0 No error readErr –19 Driver does not respond to read requests @@ -405,9 +405,9 @@ pascal OSErr DirectoryCopy(short srcVRefNum, modes afpObjectTypeErr -5025 Source is a directory, directory not found or incomplete pathname - + __________ - + Also see: CopyErrProcPtr, FSpDirectoryCopy, FilteredDirectoryCopy, FSpFilteredDirectoryCopy, FileCopy, FSpFileCopy */ @@ -429,7 +429,7 @@ pascal OSErr FSpDirectoryCopy(const FSSpec *srcSpec, routine allocates a buffer in the application heap. If you pass a copy buffer to this routine, make its size a multiple of 512 ($200) bytes for optimum performance. - + srcSpec input: An FSSpec record specifying the directory to copy. dstSpec input: An FSSpec record specifying destination directory of the copy. @@ -453,7 +453,7 @@ pascal OSErr FSpDirectoryCopy(const FSSpec *srcSpec, error will cause the copy to quit and DirectoryCopy will return the error. Error handling is recommended... - + Result Codes noErr 0 No error readErr –19 Driver does not respond to read requests @@ -491,9 +491,9 @@ pascal OSErr FSpDirectoryCopy(const FSSpec *srcSpec, modes afpObjectTypeErr -5025 Source is a directory, directory not found or incomplete pathname - + __________ - + Also see: CopyErrProcPtr, DirectoryCopy, FilteredDirectoryCopy, FSpFilteredDirectoryCopy, FileCopy, FSpFileCopy */ diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FSpCompat.c b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FSpCompat.c index 1b681af..0226822 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FSpCompat.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FSpCompat.c @@ -90,7 +90,7 @@ static Boolean FSHasFSSpecCalls(void) #else Boolean result = false; #endif - + #if !GENERATENODATA if ( !tested ) { @@ -122,7 +122,7 @@ static Boolean QTHasFSSpecCalls(void) #else Boolean result = false; #endif - + #if !GENERATENODATA if ( !tested ) { @@ -153,7 +153,7 @@ static Boolean HasFSpExchangeFilesCompatibilityFix(void) #else /* !GENERATENODATA */ Boolean result = false; #endif /* !GENERATENODATA */ - + #if !GENERATENODATA if ( !tested ) { @@ -187,7 +187,7 @@ static Boolean HasFSpCreateScriptSupportFix(void) #else Boolean result = false; #endif /* !GENERATENODATA */ - + #if !GENERATENODATA if ( !tested ) { @@ -218,12 +218,12 @@ pascal OSErr FSMakeFSSpecCompat(short vRefNum, FSSpec *spec) { OSErr result; - + #if !__MACOSSEVENORLATER if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() ) { Boolean isDirectory; - + result = GetObjectLocation(vRefNum, dirID, fileName, &(spec->vRefNum), &(spec->parID), spec->name, &isDirectory); @@ -256,7 +256,7 @@ pascal OSErr FSpOpenDFCompat(const FSSpec *spec, { OSErr result; HParamBlockRec pb; - + pb.ioParam.ioVRefNum = spec->vRefNum; pb.fileParam.ioDirID = spec->parID; pb.ioParam.ioNamePtr = (StringPtr) &(spec->name); @@ -285,7 +285,7 @@ pascal OSErr FSpOpenRFCompat(const FSSpec *spec, { OSErr result; HParamBlockRec pb; - + pb.ioParam.ioVRefNum = spec->vRefNum; pb.fileParam.ioDirID = spec->parID; pb.ioParam.ioNamePtr = (StringPtr) &(spec->name); @@ -314,7 +314,7 @@ pascal OSErr FSpCreateCompat(const FSSpec *spec, OSErr result; UniversalFMPB pb; - + if ( #if !__MACOSSEVENORLATER (!FSHasFSSpecCalls() && !QTHasFSSpecCalls()) || @@ -369,7 +369,7 @@ pascal OSErr FSpDirCreateCompat(const FSSpec *spec, { OSErr result; UniversalFMPB pb; - + pb.hPB.fileParam.ioVRefNum = spec->vRefNum; pb.hPB.fileParam.ioDirID = spec->parID; pb.hPB.fileParam.ioNamePtr = (StringPtr) &(spec->name); @@ -391,7 +391,7 @@ pascal OSErr FSpDirCreateCompat(const FSSpec *spec, ((char)scriptTag | (char)0x80) : (smRoman); /* Restore ioDirID field in pb which was changed by PBGetCatInfo */ - pb.ciPB.dirInfo.ioDrDirID = spec->parID; + pb.ciPB.dirInfo.ioDrDirID = spec->parID; result = PBSetCatInfoSync(&(pb.ciPB)); } } @@ -412,7 +412,7 @@ pascal OSErr FSpDeleteCompat(const FSSpec *spec) if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() ) { HParamBlockRec pb; - + pb.ioParam.ioVRefNum = spec->vRefNum; pb.fileParam.ioDirID = spec->parID; pb.ioParam.ioNamePtr = (StringPtr) &(spec->name); @@ -436,7 +436,7 @@ pascal OSErr FSpGetFInfoCompat(const FSSpec *spec, { OSErr result; HParamBlockRec pb; - + pb.fileParam.ioVRefNum = spec->vRefNum; pb.fileParam.ioDirID = spec->parID; pb.fileParam.ioNamePtr = (StringPtr) &(spec->name); @@ -463,7 +463,7 @@ pascal OSErr FSpSetFInfoCompat(const FSSpec *spec, { OSErr result; HParamBlockRec pb; - + pb.fileParam.ioVRefNum = spec->vRefNum; pb.fileParam.ioDirID = spec->parID; pb.fileParam.ioNamePtr = (StringPtr) &(spec->name); @@ -493,7 +493,7 @@ pascal OSErr FSpSetFLockCompat(const FSSpec *spec) if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() ) { HParamBlockRec pb; - + pb.fileParam.ioVRefNum = spec->vRefNum; pb.fileParam.ioDirID = spec->parID; pb.fileParam.ioNamePtr = (StringPtr) &(spec->name); @@ -515,7 +515,7 @@ pascal OSErr FSpRstFLockCompat(const FSSpec *spec) if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() ) { HParamBlockRec pb; - + pb.fileParam.ioVRefNum = spec->vRefNum; pb.fileParam.ioDirID = spec->parID; pb.fileParam.ioNamePtr = (StringPtr) &(spec->name); @@ -538,7 +538,7 @@ pascal OSErr FSpRenameCompat(const FSSpec *spec, if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() ) { HParamBlockRec pb; - + pb.ioParam.ioVRefNum = spec->vRefNum; pb.fileParam.ioDirID = spec->parID; pb.ioParam.ioNamePtr = (StringPtr) &(spec->name); @@ -562,11 +562,11 @@ pascal OSErr FSpCatMoveCompat(const FSSpec *source, if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() ) { CMovePBRec pb; - + /* source and destination volume must be the same */ if ( source->vRefNum != dest->vRefNum ) return ( paramErr ); - + pb.ioNamePtr = (StringPtr) &(source->name); pb.ioVRefNum = source->vRefNum; pb.ioDirID = source->parID; @@ -597,7 +597,7 @@ static OSErr GenerateUniqueName(short volume, long i; CInfoPBRec cinfo; unsigned char hexStr[16]; - + for ( i = 0; i < 16; ++i ) { if ( i < 10 ) @@ -609,14 +609,14 @@ static OSErr GenerateUniqueName(short volume, hexStr[i] = 0x37 + i; } } - + cinfo.hFileInfo.ioVRefNum = volume; cinfo.hFileInfo.ioFDirIndex = 0; cinfo.hFileInfo.ioNamePtr = uniqueName; while ( error != fnfErr ) { - (*startSeed)++; + (*startSeed)++; cinfo.hFileInfo.ioNamePtr[0] = 8; for ( i = 1; i <= 8; i++ ) { @@ -644,7 +644,7 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, const FSSpec *dest) { #if !__MACOSSEVENFIVEORLATER - if ( + if ( #if !__MACOSSEVENORLATER !FSHasFSSpecCalls() || #endif /* !__MACOSSEVENORLATER */ @@ -657,23 +657,23 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, StringPtr unique1Ptr, unique2Ptr, swapola; GetVolParmsInfoBuffer volInfo; long theSeed, temp; - + /* Make sure the source and destination are on the same volume */ if ( source->vRefNum != dest->vRefNum ) { result = diffVolErr; goto errorExit3; } - + /* Try PBExchangeFiles first since it preserves the file ID reference */ pb.fidParam.ioNamePtr = (StringPtr) &(source->name); pb.fidParam.ioVRefNum = source->vRefNum; pb.fidParam.ioDestNamePtr = (StringPtr) &(dest->name); pb.fidParam.ioDestDirID = dest->parID; pb.fidParam.ioSrcDirID = source->parID; - + result = PBExchangeFilesSync(&pb); - + /* Note: The compatibility case won't work for files with *Btree control blocks. */ /* Right now the only *Btree files are created by the system. */ if ( result != noErr ) @@ -682,13 +682,13 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, pb.ioParam.ioBuffer = (Ptr) &volInfo; pb.ioParam.ioReqCount = sizeof(volInfo); result2 = PBHGetVolParmsSync(&pb); - + /* continue if volume has no fileID support (or no GetVolParms support) */ if ( (result2 == noErr) && hasFileIDs(volInfo) ) { goto errorExit3; } - + /* Get the catalog information for each file */ /* and make sure both files are *really* files */ catInfoSource.hFileInfo.ioVRefNum = source->vRefNum; @@ -706,7 +706,7 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, result = notAFileErr; goto errorExit3; } - + catInfoDest.hFileInfo.ioVRefNum = dest->vRefNum; catInfoDest.hFileInfo.ioFDirIndex = 0; catInfoDest.hFileInfo.ioNamePtr = (StringPtr) &(dest->name); @@ -722,24 +722,24 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, result = notAFileErr; goto errorExit3; } - + /* generate 2 filenames that are unique in both directories */ theSeed = 0x64666A6C; /* a fine unlikely filename */ unique1Ptr = (StringPtr)&unique1; unique2Ptr = (StringPtr)&unique2; - + result = GenerateUniqueName(source->vRefNum, &theSeed, source->parID, dest->parID, unique1Ptr); if ( result != noErr ) { goto errorExit3; } - + GenerateUniqueName(source->vRefNum, &theSeed, source->parID, dest->parID, unique2Ptr); if ( result != noErr ) { goto errorExit3; } - + /* rename source to unique1 */ pb.fileParam.ioNamePtr = (StringPtr) &(source->name); pb.ioParam.ioMisc = (Ptr) unique1Ptr; @@ -749,7 +749,7 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, { goto errorExit3; } - + /* rename dest to unique2 */ pb.ioParam.ioMisc = (Ptr) unique2Ptr; pb.ioParam.ioVersNum = 0; @@ -760,7 +760,7 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, { goto errorExit2; /* back out gracefully by renaming unique1 back to source */ } - + /* If files are not in same directory, swap their locations */ if ( source->parID != dest->parID ) { @@ -774,7 +774,7 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, { goto errorExit1; /* back out gracefully by renaming both files to original names */ } - + /* move dest file to source directory */ pb.copyParam.ioNamePtr = unique2Ptr; pb.copyParam.ioNewDirID = source->parID; @@ -791,35 +791,35 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, goto errorExit1; /* back out gracefully by renaming both files to original names */ } } - + /* Make unique1Ptr point to file in source->parID */ /* and unique2Ptr point to file in dest->parID */ /* This lets us fall through to the rename code below */ swapola = unique1Ptr; unique1Ptr = unique2Ptr; unique2Ptr = swapola; - + /* At this point, the files are in their new locations (if they were moved) */ /* Source is named Unique1 (name pointed to by unique2Ptr) and is in dest->parID */ /* Dest is named Unique2 (name pointed to by unique1Ptr) and is in source->parID */ /* Need to swap attributes except mod date and swap names */ - + /* swap the catalog info by re-aiming the CInfoPB's */ catInfoSource.hFileInfo.ioNamePtr = unique1Ptr; catInfoDest.hFileInfo.ioNamePtr = unique2Ptr; - + catInfoSource.hFileInfo.ioDirID = source->parID; catInfoDest.hFileInfo.ioDirID = dest->parID; - + /* Swap the original mod dates with each file */ temp = catInfoSource.hFileInfo.ioFlMdDat; catInfoSource.hFileInfo.ioFlMdDat = catInfoDest.hFileInfo.ioFlMdDat; catInfoDest.hFileInfo.ioFlMdDat = temp; - + /* Here's the swap (ignore errors) */ - (void) PBSetCatInfoSync(&catInfoSource); + (void) PBSetCatInfoSync(&catInfoSource); (void) PBSetCatInfoSync(&catInfoDest); - + /* rename unique2 back to dest */ errorExit1: pb.ioParam.ioMisc = (Ptr) &(dest->name); @@ -827,7 +827,7 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, pb.fileParam.ioNamePtr = unique2Ptr; pb.fileParam.ioDirID = dest->parID; (void) PBHRenameSync(&pb); /* ignore errors */ - + /* rename unique1 back to source */ errorExit2: pb.ioParam.ioMisc = (Ptr) &(source->name); @@ -848,7 +848,7 @@ errorExit3: { /* null statement */ } /*****************************************************************************/ -/* +/* ** Resource Manager FSp calls */ @@ -875,7 +875,7 @@ pascal void FSpCreateResFileCompat(const FSSpec *spec, OSType creator, OSType fileType, ScriptCode scriptTag) -{ +{ #if !__MACOSSEVENFIVEONEORLATER if ( #if !__MACOSSEVENORLATER @@ -885,7 +885,7 @@ pascal void FSpCreateResFileCompat(const FSSpec *spec, { OSErr result; CInfoPBRec pb; - + HCreateResFile(spec->vRefNum, spec->parID, spec->name); if ( ResError() == noErr ) { @@ -907,7 +907,7 @@ pascal void FSpCreateResFileCompat(const FSSpec *spec, /* Set creator/fileType */ pb.hFileInfo.ioFlFndrInfo.fdCreator = creator; pb.hFileInfo.ioFlFndrInfo.fdType = fileType; - + /* Restore ioDirID field in pb which was changed by PBGetCatInfo */ pb.hFileInfo.ioDirID = spec->parID; result = PBSetCatInfoSync(&pb); diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FSpCompat.h b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FSpCompat.h index 6dda57c..c80c772 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FSpCompat.h +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FSpCompat.h @@ -45,19 +45,19 @@ pascal OSErr FSMakeFSSpecCompat(short vRefNum, entry on the disk volume. That is because fileName is parsed to get the name instead of getting the name back from the file system. This works fine with System 6 where FSMakeSpec isn't available. - + vRefNum input: Volume specification. dirID input: Directory ID. fileName input: Pointer to object name, or nil when dirID specifies a directory that's the object. spec output: A file system specification to be filled in by FSMakeFSSpecCompat. - + Result Codes - noErr 0 No error - nsvErr -35 Volume doesn’t exist + noErr 0 No error + nsvErr -35 Volume doesn’t exist fnfErr -43 File or directory does not exist - (FSSpec is still valid) + (FSSpec is still valid) */ /*****************************************************************************/ @@ -72,29 +72,29 @@ pascal OSErr FSpOpenDFCompat(const FSSpec *spec, FSpOpenDFCompat uses PHBOpen because System 6 doesn't support PBHOpenDF. This means FSpOpenDFCompat could accidentally open a driver if the spec->name begins with a period. - + spec input: An FSSpec record specifying the file whose data fork is to be opened. permission input: A constant indicating the desired file access permissions. refNum output: A reference number of an access path to the file's data fork. - + Result Codes - noErr 0 No error - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - tmfoErr -42 Too many files open - fnfErr -43 File not found - opWrErr -49 File already open for writing - permErr -54 Attempt to open locked file for writing + noErr 0 No error + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + tmfoErr -42 Too many files open + fnfErr -43 File not found + opWrErr -49 File already open for writing + permErr -54 Attempt to open locked file for writing dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access to the file - + __________ - + See also: FSpOpenAware */ @@ -106,29 +106,29 @@ pascal OSErr FSpOpenRFCompat(const FSSpec *spec, /* ¶ Open a file's resource fork. The FSpOpenRFCompat function opens the resource fork of the file specified by spec. - + spec input: An FSSpec record specifying the file whose resource fork is to be opened. permission input: A constant indicating the desired file access permissions. refNum output: A reference number of an access path to the file's resource fork. - + Result Codes - noErr 0 No error - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - tmfoErr -42 Too many files open - fnfErr -43 File not found - opWrErr -49 File already open for writing - permErr -54 Attempt to open locked file for writing + noErr 0 No error + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + tmfoErr -42 Too many files open + fnfErr -43 File not found + opWrErr -49 File already open for writing + permErr -54 Attempt to open locked file for writing dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access to the file - + __________ - + See also: FSpOpenRFAware */ @@ -145,27 +145,27 @@ pascal OSErr FSpCreateCompat(const FSSpec *spec, Differences from FSpCreate: FSpCreateCompat correctly sets the fdScript in the file's FXInfo record to scriptTag if the problem isn't fixed in the File Manager code. - + spec input: An FSSpec record specifying the file to create. creator input: The creator of the new file. fileType input The file type of the new file. scriptCode input: The code of the script system in which the file name is to be displayed. - + Result Codes - noErr 0 No error - dirFulErr -33 File directory full - dskFulErr -34 Disk is full - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - fnfErr -43 Directory not found or incomplete pathname - wPrErr -44 Hardware volume lock - vLckdErr -46 Software volume lock - dupFNErr -48 Duplicate filename and version - dirNFErrdirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 A directory exists with that name + noErr 0 No error + dirFulErr -33 File directory full + dskFulErr -34 Disk is full + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + fnfErr -43 Directory not found or incomplete pathname + wPrErr -44 Hardware volume lock + vLckdErr -46 Software volume lock + dupFNErr -48 Duplicate filename and version + dirNFErrdirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 A directory exists with that name */ /*****************************************************************************/ @@ -176,28 +176,28 @@ pascal OSErr FSpDirCreateCompat(const FSSpec *spec, /* ¶ Create a new directory. The FSpDirCreateCompat function creates a new directory and returns the directory ID of the newDirectory. - + spec input: An FSSpec record specifying the directory to create. scriptCode input: The code of the script system in which the directory name is to be displayed. createdDirID output: The directory ID of the directory that was created. - + Result Codes - noErr 0 No error - dirFulErr -33 File directory full - dskFulErr -34 Disk is full - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - fnfErr -43 Directory not found or incomplete pathname - wPrErr -44 Hardware volume lock - vLckdErr -46 Software volume lock - dupFNErr -48 Duplicate filename and version - dirNFErrdirNFErr -120 Directory not found or incomplete pathname - wrgVolTypErr -123 Not an HFS volume - afpAccessDenied -5000 User does not have the correct access + noErr 0 No error + dirFulErr -33 File directory full + dskFulErr -34 Disk is full + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + fnfErr -43 Directory not found or incomplete pathname + wPrErr -44 Hardware volume lock + vLckdErr -46 Software volume lock + dupFNErr -48 Duplicate filename and version + dirNFErrdirNFErr -120 Directory not found or incomplete pathname + wrgVolTypErr -123 Not an HFS volume + afpAccessDenied -5000 User does not have the correct access */ /*****************************************************************************/ @@ -205,23 +205,23 @@ pascal OSErr FSpDirCreateCompat(const FSSpec *spec, pascal OSErr FSpDeleteCompat(const FSSpec *spec); /* ¶ Delete a file or directory. The FSpDeleteCompat function deletes a file or directory. - - spec input: An FSSpec record specifying the file or + + spec input: An FSSpec record specifying the file or directory to delete. - + Result Codes - noErr 0 No error - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - fnfErr -43 File not found - wPrErr -44 Hardware volume lock - fLckdErr -45 File is locked - vLckdErr -46 Software volume lock + noErr 0 No error + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + fnfErr -43 File not found + wPrErr -44 Hardware volume lock + fLckdErr -45 File is locked + vLckdErr -46 Software volume lock fBsyErr -47 File busy, directory not empty, or - working directory control block open - dirNFErrdirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access + working directory control block open + dirNFErrdirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access */ /*****************************************************************************/ @@ -233,20 +233,20 @@ pascal OSErr FSpGetFInfoCompat(const FSSpec *spec, spec input: An FSSpec record specifying the file. fndrInfo output: If the object is a file, then its FInfo. - + Result Codes - noErr 0 No error - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - fnfErr -43 File not found - paramErr -50 No default volume - dirNFErrdirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - + noErr 0 No error + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + fnfErr -43 File not found + paramErr -50 No default volume + dirNFErrdirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + __________ - + Also see: FSpGetDInfo */ @@ -259,22 +259,22 @@ pascal OSErr FSpSetFInfoCompat(const FSSpec *spec, spec input: An FSSpec record specifying the file. fndrInfo input: The FInfo. - + Result Codes - noErr 0 No error - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - fnfErr -43 File not found - wPrErr -44 Hardware volume lock - fLckdErr -45 File is locked - vLckdErr -46 Software volume lock - dirNFErrdirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Object was a directory - + noErr 0 No error + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + fnfErr -43 File not found + wPrErr -44 Hardware volume lock + fLckdErr -45 File is locked + vLckdErr -46 Software volume lock + dirNFErrdirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Object was a directory + __________ - + Also see: FSpSetDInfo */ @@ -285,18 +285,18 @@ pascal OSErr FSpSetFLockCompat(const FSSpec *spec); The FSpSetFLockCompat function locks a file. spec input: An FSSpec record specifying the file. - + Result Codes - noErr 0 No error - nsvErr -35 No such volume - ioErr -36 I/O error - fnfErr -43 File not found - wPrErr -44 Hardware volume lock - vLckdErr -46 Software volume lock - dirNFErrdirNFErr -120 Directory not found or incomplete pathname + noErr 0 No error + nsvErr -35 No such volume + ioErr -36 I/O error + fnfErr -43 File not found + wPrErr -44 Hardware volume lock + vLckdErr -46 Software volume lock + dirNFErrdirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access to - the file - afpObjectTypeErr -5025 Folder locking not supported by volume + the file + afpObjectTypeErr -5025 Folder locking not supported by volume */ /*****************************************************************************/ @@ -306,18 +306,18 @@ pascal OSErr FSpRstFLockCompat(const FSSpec *spec); The FSpRstFLockCompat function unlocks a file. spec input: An FSSpec record specifying the file. - + Result Codes - noErr 0 No error - nsvErr -35 No such volume - ioErr -36 I/O error - fnfErr -43 File not found - wPrErr -44 Hardware volume lock - vLckdErr -46 Software volume lock - dirNFErrdirNFErr -120 Directory not found or incomplete pathname + noErr 0 No error + nsvErr -35 No such volume + ioErr -36 I/O error + fnfErr -43 File not found + wPrErr -44 Hardware volume lock + vLckdErr -46 Software volume lock + dirNFErrdirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access to - the file - afpObjectTypeErr -5025 Folder locking not supported by volume + the file + afpObjectTypeErr -5025 Folder locking not supported by volume */ /*****************************************************************************/ @@ -329,24 +329,24 @@ pascal OSErr FSpRenameCompat(const FSSpec *spec, spec input: An FSSpec record specifying the file. newName input: The new name of the file or directory. - + Result Codes - noErr 0 No error - dirFulErr -33 File directory full - dskFulErr -34 Volume is full - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - fnfErr -43 File not found - wPrErr -44 Hardware volume lock - fLckdErr -45 File is locked - vLckdErr -46 Software volume lock - dupFNErr -48 Duplicate filename and version - paramErr -50 No default volume - fsRnErr -59 Problem during rename - dirNFErrdirNFErr -120 Directory not found or incomplete pathname + noErr 0 No error + dirFulErr -33 File directory full + dskFulErr -34 Volume is full + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + fnfErr -43 File not found + wPrErr -44 Hardware volume lock + fLckdErr -45 File is locked + vLckdErr -46 Software volume lock + dupFNErr -48 Duplicate filename and version + paramErr -50 No default volume + fsRnErr -59 Problem during rename + dirNFErrdirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access to - the file + the file */ /*****************************************************************************/ @@ -361,23 +361,23 @@ pascal OSErr FSpCatMoveCompat(const FSSpec *source, dest input: An FSSpec record specifying the name and location of the directory into which the source file or directory is to be moved. - + Result Codes - noErr 0 No error - nsvErr -35 No such volume - ioErr -36 I/O error + noErr 0 No error + nsvErr -35 No such volume + ioErr -36 I/O error bdNamErr -37 Bad filename or attempt to move into - a file - fnfErr -43 File not found - wPrErr -44 Hardware volume lock - fLckdErr -45 Target directory is locked - vLckdErr -46 Software volume lock - dupFNErr -48 Duplicate filename and version - paramErr -50 No default volume - badMovErr -122 Attempt to move into offspring - wrgVolTypErr -123 Not an HFS volume + a file + fnfErr -43 File not found + wPrErr -44 Hardware volume lock + fLckdErr -45 Target directory is locked + vLckdErr -46 Software volume lock + dupFNErr -48 Duplicate filename and version + paramErr -50 No default volume + badMovErr -122 Attempt to move into offspring + wrgVolTypErr -123 Not an HFS volume afpAccessDenied -5000 User does not have the correct access to - the file + the file */ /*****************************************************************************/ @@ -395,21 +395,21 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, don't support PBExchangeFiles (even though you may get a noErr result). System Update 3.0 and System 7.5 and later have the problems in FSpExchangeFiles corrected. - + Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnfErr -43 File not found - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 Function not supported by volume - volOfflinErr -53 Volume is offline - wrgVolTypErr -123 Not an HFS volume - diffVolErr -1303 Files on different volumes - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Object is a directory, not a file - afpSameObjectErr -5038 Source and destination files are the same + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnfErr -43 File not found + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 Function not supported by volume + volOfflinErr -53 Volume is offline + wrgVolTypErr -123 Not an HFS volume + diffVolErr -1303 Files on different volumes + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Object is a directory, not a file + afpSameObjectErr -5038 Source and destination files are the same */ /*****************************************************************************/ @@ -419,14 +419,14 @@ pascal short FSpOpenResFileCompat(const FSSpec *spec, /* ¶ Open a file's resource file. The FSpOpenResFileCompat function opens the resource file specified by spec. - + spec input: An FSSpec record specifying the file whose resource file is to be opened. permission input: A constant indicating the desired file access permissions. function result output: A resource file reference number, or if there's an error -1. - + Result Codes noErr 0 No error nsvErr –35 No such volume @@ -456,13 +456,13 @@ pascal void FSpCreateResFileCompat(const FSSpec *spec, Differences from FSpCreateResFile: FSpCreateResFileCompat correctly sets the fdScript in the file's FXInfo record to scriptTag if the problem isn't fixed in the File Manager code. - + spec input: An FSSpec record specifying the resource file to create. creator input: The creator of the new file. fileType input The file type of the new file. scriptCode input: The code of the script system in which the file name is to be displayed. - + Result Codes noErr 0 No error dirFulErr –33 Directory full diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FileCopy.c b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FileCopy.c index 08d0325..2528419 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FileCopy.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FileCopy.c @@ -44,7 +44,7 @@ enum dstCopyMode = dmWrDenyRdWr }; -/* The largest (16K) and smallest (.5K) copy buffer to use if the caller doesn't supply +/* The largest (16K) and smallest (.5K) copy buffer to use if the caller doesn't supply ** their own copy buffer. */ enum @@ -132,7 +132,7 @@ static OSErr GetDestinationDirInfo(short vRefNum, *isDirectory = (pb.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0; /* see if access priviledges are make changes, not see folder, and not see files (drop box) */ *isDropBox = userHasDropBoxAccess(pb.dirInfo.ioACUser); - + return ( error ); } @@ -146,7 +146,7 @@ static OSErr CheckForForks(short vRefNum, { HParamBlockRec pb; OSErr error; - + pb.fileParam.ioNamePtr = (StringPtr)name; pb.fileParam.ioVRefNum = vRefNum; pb.fileParam.ioFVersNum = 0; @@ -155,7 +155,7 @@ static OSErr CheckForForks(short vRefNum, error = PBHGetFInfoSync(&pb); *hasDataFork = (pb.fileParam.ioFlLgLen != 0); *hasResourceFork = (pb.fileParam.ioFlRLgLen != 0); - + return ( error ); } @@ -174,17 +174,17 @@ static OSErr PreflightFileCopySpace(short srcVRefNum, unsigned long dstBlksPerAllocBlk; unsigned long srcDataBlks; unsigned long srcResourceBlks; - + error = XGetVolumeInfoNoName(dstVolName, dstVRefNum, &pb.xPB); if ( error == noErr ) { /* get allocation block size (always multiple of 512) and divide by 512 to get number of 512-byte blocks per allocation block */ dstBlksPerAllocBlk = ((unsigned long)pb.xPB.ioVAlBlkSiz >> 9); - + /* Convert freeBytes to free disk blocks (512-byte blocks) */ dstFreeBlocks = U32SetU(U64ShiftRight(pb.xPB.ioVFreeBytes, 9)); - + /* Now, get the size of the file's data resource forks */ pb.hPB.fileParam.ioNamePtr = (StringPtr)srcName; pb.hPB.fileParam.ioVRefNum = srcVRefNum; @@ -206,7 +206,7 @@ static OSErr PreflightFileCopySpace(short srcVRefNum, { srcDataBlks = (unsigned long)pb.hPB.fileParam.ioFlLgLen >> 9; } - + /* now, calculate number of new allocation blocks needed */ if ( srcDataBlks % dstBlksPerAllocBlk ) { @@ -216,7 +216,7 @@ static OSErr PreflightFileCopySpace(short srcVRefNum, { srcDataBlks /= dstBlksPerAllocBlk; } - + /* get number of 512-byte blocks needed for resource fork */ if ( ((unsigned long)pb.hPB.fileParam.ioFlRLgLen & 0x000001ff) != 0 ) { @@ -236,12 +236,12 @@ static OSErr PreflightFileCopySpace(short srcVRefNum, { srcResourceBlks /= dstBlksPerAllocBlk; } - + /* Is there enough room on the destination volume for the source file? */ *spaceOK = ( ((srcDataBlks + srcResourceBlks) * dstBlksPerAllocBlk) <= dstFreeBlocks ); } } - + return ( error ); } @@ -263,21 +263,21 @@ pascal OSErr FileCopy(short srcVRefNum, short srcRefNum = 0, /* 0 when source data and resource fork are closed */ dstDataRefNum = 0, /* 0 when destination data fork is closed */ dstRsrcRefNum = 0; /* 0 when destination resource fork is closed */ - + Str63 dstName; /* The filename of the destination. It might be the ** source filename, it might be a new name... */ - + GetVolParmsInfoBuffer infoBuffer; /* Where PBGetVolParms dumps its info */ long srcServerAdr; /* AppleTalk server address of source (if any) */ - + Boolean dstCreated = false, /* true when destination file has been created */ ourCopyBuffer = false, /* true if we had to allocate the copy buffer */ isDirectory, /* true if destination is really a directory */ isDropBox; /* true if destination is an AppleShare drop box */ - + long tempLong; short tempInt; - + Boolean spaceOK; /* true if there's enough room to copy the file to the destination volume */ Boolean hasDataFork; @@ -292,7 +292,7 @@ pascal OSErr FileCopy(short srcVRefNum, { return ( err ); } - + if ( !spaceOK ) { return ( dskFulErr ); @@ -306,7 +306,7 @@ pascal OSErr FileCopy(short srcVRefNum, { goto ErrorExit; } - + if ( !isDirectory ) { return ( dirNFErr ); @@ -318,7 +318,7 @@ pascal OSErr FileCopy(short srcVRefNum, { goto ErrorExit; } - + /* See if PBHCopyFile can be used. Using PBHCopyFile saves time by letting the file server ** copy the file if the source and destination locations are on the same file server. */ tempLong = sizeof(infoBuffer); @@ -348,7 +348,7 @@ pascal OSErr FileCopy(short srcVRefNum, { return ( err ); } - + /* AppleShare's CopyFile clears the isAlias bit, so I still need to attempt to copy the File's attributes to attempt to get things right. */ if ( copyName != NULL ) /* Did caller supply copy file name? */ @@ -397,9 +397,9 @@ pascal OSErr FileCopy(short srcVRefNum, err = HOpenAware(srcVRefNum, srcDirID, srcName, srcCopyMode, &srcRefNum); if ( err != noErr ) return ( err ); - + /* Once a file is opened, we have to exit via ErrorExit to make sure things are cleaned up */ - + /* See if the copy will be renamed. */ if ( copyName != NULL ) /* Did caller supply copy file name? */ BlockMoveData(copyName, dstName, copyName[0] + 1); /* Yes, use the caller supplied copy file name. */ @@ -426,7 +426,7 @@ pascal OSErr FileCopy(short srcVRefNum, ** Copying a file into an AppleShare dropbox presents some special problems. Here are the ** rules we have to follow to copy a file into a dropbox: ** • File attributes can be changed only when both forks of a file are empty. - ** • DeskTop Manager comments can be added to a file only when both forks of a file + ** • DeskTop Manager comments can be added to a file only when both forks of a file ** are empty. ** • A fork can be opened for write access only when both forks of a file are empty. ** So, with those rules to live with, we'll do those operations now while both forks @@ -471,7 +471,7 @@ pascal OSErr FileCopy(short srcVRefNum, { goto ErrorExit; } - + if ( hasDataFork ) { /* Open the destination data fork. */ @@ -500,7 +500,7 @@ pascal OSErr FileCopy(short srcVRefNum, { goto ErrorExit; } - + /* Close both data forks and clear reference numbers. */ (void) FSClose(srcRefNum); (void) FSClose(dstDataRefNum); @@ -521,14 +521,14 @@ pascal OSErr FileCopy(short srcVRefNum, { goto ErrorExit; } - + /* Copy the resource fork. */ err = CopyFork(srcRefNum, dstRsrcRefNum, copyBufferPtr, copyBufferSize); if ( err != noErr ) { goto ErrorExit; } - + /* Close both resource forks and clear reference numbers. */ (void) FSClose(srcRefNum); (void) FSClose(dstRsrcRefNum); @@ -549,7 +549,7 @@ pascal OSErr FileCopy(short srcVRefNum, /* Hey, we did it! */ return ( noErr ); - + ErrorExit: if ( srcRefNum != 0 ) { @@ -565,14 +565,14 @@ pascal OSErr FileCopy(short srcVRefNum, } if ( dstCreated ) { - (void) HDelete(dstVRefNum, dstDirID, dstName); /* Delete dest file. This may fail if the file + (void) HDelete(dstVRefNum, dstDirID, dstName); /* Delete dest file. This may fail if the file is in a "drop folder" */ } if ( ourCopyBuffer ) /* dispose of any memory we allocated */ { DisposePtr((Ptr)copyBufferPtr); } - + return ( err ); } diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FileCopy.h b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FileCopy.h index ba1b969..f8b3936 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FileCopy.h +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FileCopy.h @@ -59,7 +59,7 @@ pascal OSErr FileCopy(short srcVRefNum, allocates a buffer in the application heap. If you pass a copy buffer to this routine, make its size a multiple of 512 ($200) bytes for optimum performance. - + srcVRefNum input: Source volume specification. srcDirID input: Source directory ID. srcName input: Source file name. @@ -80,7 +80,7 @@ pascal OSErr FileCopy(short srcVRefNum, allocation blocks on the destination volume to hold both the data and resource forks before starting the copy. - + Result Codes noErr 0 No error readErr –19 Driver does not respond to read requests @@ -118,9 +118,9 @@ pascal OSErr FileCopy(short srcVRefNum, modes afpObjectTypeErr -5025 Source is a directory, directory not found or incomplete pathname - + __________ - + Also see: FSpFileCopy, DirectoryCopy, FSpDirectoryCopy */ @@ -148,7 +148,7 @@ pascal OSErr FSpFileCopy(const FSSpec *srcSpec, allocates a buffer in the application heap. If you pass a copy buffer to this routine, make its size a multiple of 512 ($200) bytes for optimum performance. - + srcSpec input: An FSSpec record specifying the source file. dstSpec input: An FSSpec record specifying the destination directory. @@ -165,7 +165,7 @@ pascal OSErr FSpFileCopy(const FSSpec *srcSpec, enough allocation blocks on the destination volume to hold both the data and resource forks before starting the copy. - + Result Codes noErr 0 No error readErr –19 Driver does not respond to read requests @@ -203,9 +203,9 @@ pascal OSErr FSpFileCopy(const FSSpec *srcSpec, modes afpObjectTypeErr -5025 Source is a directory, directory not found or incomplete pathname - + __________ - + Also see: FileCopy, DirectoryCopy, FSpDirectoryCopy */ diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FullPath.c b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FullPath.c index 3ae2a8c..9bf69d3 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FullPath.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FullPath.c @@ -33,11 +33,11 @@ /* IMPORTANT NOTE: - + The use of full pathnames is strongly discouraged. Full pathnames are particularly unreliable as a means of identifying files, directories or volumes within your application, for two primary reasons: - + • The user can change the name of any element in the path at virtually any time. • Volume names on the Macintosh are *not* unique. Multiple @@ -46,18 +46,18 @@ results you expect. If more than one volume has the same name and a full pathname is used, the File Manager currently uses the first mounted volume it finds with a matching name in the volume queue. - + In general, you should use a file’s name, parent directory ID, and volume reference number to identify a file you want to open, delete, or otherwise manipulate. - + If you need to remember the location of a particular file across subsequent system boots, use the Alias Manager to create an alias record describing the file. If the Alias Manager is not available, you can save the file’s name, its parent directory ID, and the name of the volume on which it’s located. Although none of these methods is foolproof, they are much more reliable than using full pathnames to identify files. - + Nonetheless, it is sometimes useful to display a file’s full pathname to the user. For example, a backup utility might display a list of full pathnames of files as it copies them onto the backup medium. Or, a @@ -68,7 +68,7 @@ numbers or directory IDs. (Hint: Use the TruncString function from TextUtils.h with truncMiddle as the truncWhere argument to shorten full pathnames to a displayable length.) - + The following technique for constructing the full pathname of a file is intended for display purposes only. Applications that depend on any particular structure of a full pathname are likely to fail on alternate @@ -85,16 +85,16 @@ pascal OSErr GetFullPath(short vRefNum, { OSErr result; FSSpec spec; - + *fullPathLength = 0; *fullPath = NULL; - + result = FSMakeFSSpecCompat(vRefNum, dirID, name, &spec); if ( (result == noErr) || (result == fnfErr) ) { result = FSpGetFullPath(&spec, fullPathLength, fullPath); } - + return ( result ); } @@ -108,14 +108,14 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec, OSErr realResult; FSSpec tempSpec; CInfoPBRec pb; - + *fullPathLength = 0; *fullPath = NULL; - - + + /* Default to noErr */ realResult = result = noErr; - + /* work around Nav Services "bug" (it returns invalid FSSpecs with empty names) */ if ( spec->name[0] == 0 ) { @@ -126,24 +126,24 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec, /* Make a copy of the input FSSpec that can be modified */ BlockMoveData(spec, &tempSpec, sizeof(FSSpec)); } - + if ( result == noErr ) { if ( tempSpec.parID == fsRtParID ) { /* The object is a volume */ - + /* Add a colon to make it a full pathname */ ++tempSpec.name[0]; tempSpec.name[tempSpec.name[0]] = ':'; - + /* We're done */ result = PtrToHand(&tempSpec.name[1], fullPath, tempSpec.name[0]); } else { /* The object isn't a volume */ - + /* Is the object a file or a directory? */ pb.dirInfo.ioNamePtr = tempSpec.name; pb.dirInfo.ioVRefNum = tempSpec.vRefNum; @@ -160,7 +160,7 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec, ++tempSpec.name[0]; tempSpec.name[tempSpec.name[0]] = ':'; } - + /* Put the object name in first */ result = PtrToHand(&tempSpec.name[1], fullPath, tempSpec.name[0]); if ( result == noErr ) @@ -179,7 +179,7 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec, /* Append colon to directory name */ ++tempSpec.name[0]; tempSpec.name[tempSpec.name[0]] = ':'; - + /* Add directory name to beginning of fullPath */ (void) Munger(*fullPath, 0, NULL, 0, &tempSpec.name[1], tempSpec.name[0]); result = MemError(); @@ -189,7 +189,7 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec, } } } - + if ( result == noErr ) { /* Return the length */ @@ -206,7 +206,7 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec, *fullPath = NULL; *fullPathLength = 0; } - + return ( result ); } @@ -220,7 +220,7 @@ pascal OSErr FSpLocationFromFullPath(short fullPathLength, OSErr result; Boolean wasChanged; Str32 nullString; - + /* Create a minimal alias from the full pathname */ nullString[0] = 0; /* null string to indicate no zone or server name */ result = NewAliasMinimalFromFullPath(fullPathLength, fullPath, nullString, nullString, &alias); @@ -228,7 +228,7 @@ pascal OSErr FSpLocationFromFullPath(short fullPathLength, { /* Let the Alias Manager resolve the alias. */ result = ResolveAlias(NULL, alias, spec, &wasChanged); - + /* work around Alias Mgr sloppy volume matching bug */ if ( spec->vRefNum == 0 ) { @@ -252,7 +252,7 @@ pascal OSErr LocationFromFullPath(short fullPathLength, { OSErr result; FSSpec spec; - + result = FSpLocationFromFullPath(fullPathLength, fullPath, &spec); if ( result == noErr ) { diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FullPath.h b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FullPath.h index 1363b2d..cf1262a 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FullPath.h +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/FullPath.h @@ -33,11 +33,11 @@ extern "C" { /* IMPORTANT NOTE: - + The use of full pathnames is strongly discouraged. Full pathnames are particularly unreliable as a means of identifying files, directories or volumes within your application, for two primary reasons: - + • The user can change the name of any element in the path at virtually any time. • Volume names on the Macintosh are *not* unique. Multiple @@ -46,11 +46,11 @@ extern "C" { results you expect. If more than one volume has the same name and a full pathname is used, the File Manager currently uses the first mounted volume it finds with a matching name in the volume queue. - + In general, you should use a file’s name, parent directory ID, and volume reference number to identify a file you want to open, delete, or otherwise manipulate. - + If you need to remember the location of a particular file across subsequent system boots, use the Alias Manager to create an alias record describing the file. If the Alias Manager is not available, you @@ -58,7 +58,7 @@ extern "C" { volume on which it’s located. Although none of these methods is foolproof, they are much more reliable than using full pathnames to identify files. - + Nonetheless, it is sometimes useful to display a file’s full pathname to the user. For example, a backup utility might display a list of full pathnames of files as it copies them onto the backup medium. Or, a @@ -69,7 +69,7 @@ extern "C" { numbers or directory IDs. (Hint: Use the TruncString function from TextUtils.h with truncMiddle as the truncWhere argument to shorten full pathnames to a displayable length.) - + The following technique for constructing the full pathname of a file is intended for display purposes only. Applications that depend on any particular structure of a full pathname are likely to fail on alternate @@ -89,11 +89,11 @@ pascal OSErr GetFullPath(short vRefNum, fullPath and the length of the full pathname is returned in fullPathLength. Your program is responsible for disposing of the fullPath handle. - + Note that a full pathname can be made to a file/directory that does not yet exist if all directories up to that file/directory exist. In this case, GetFullPath will return a fnfErr. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID @@ -104,9 +104,9 @@ pascal OSErr GetFullPath(short vRefNum, fullPath output: A handle to the newly created full pathname buffer. If the function fails to create a full pathname, it sets fullPath to NULL. - + Result Codes - noErr 0 No error + noErr 0 No error nsvErr -35 No such volume ioErr -36 I/O error bdNamErr -37 Bad filename @@ -117,9 +117,9 @@ pascal OSErr GetFullPath(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: FSpGetFullPath */ @@ -134,11 +134,11 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec, fullPath and the length of the full pathname is returned in fullPathLength. Your program is responsible for disposing of the fullPath handle. - + Note that a full pathname can be made to a file/directory that does not yet exist if all directories up to that file/directory exist. In this case, FSpGetFullPath will return a fnfErr. - + spec input: An FSSpec record specifying the object. fullPathLength output: The number of characters in the full pathname. If the function fails to create a full pathname, @@ -146,9 +146,9 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec, fullPath output: A handle to the newly created full pathname buffer. If the function fails to create a full pathname, it sets fullPath to NULL. - + Result Codes - noErr 0 No error + noErr 0 No error nsvErr -35 No such volume ioErr -36 I/O error bdNamErr -37 Bad filename @@ -159,9 +159,9 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: GetFullPath */ @@ -173,7 +173,7 @@ pascal OSErr FSpLocationFromFullPath(short fullPathLength, /* ¶ Get a FSSpec from a full pathname. The FSpLocationFromFullPath function returns a FSSpec to the object specified by full pathname. This function requires the Alias Manager. - + fullPathLength input: The number of characters in the full pathname of the target. fullPath input: A pointer to a buffer that contains the full @@ -182,7 +182,7 @@ pascal OSErr FSpLocationFromFullPath(short fullPathLength, all of the directory names in the path to the target, and ends with the target name. spec output: An FSSpec record specifying the object. - + Result Codes noErr 0 No error nsvErr -35 The volume is not mounted @@ -190,9 +190,9 @@ pascal OSErr FSpLocationFromFullPath(short fullPathLength, directory found paramErr -50 Parameter error usrCanceledErr -128 The user canceled the operation - + __________ - + See also: LocationFromFullPath */ @@ -207,7 +207,7 @@ pascal OSErr LocationFromFullPath(short fullPathLength, The LocationFromFullPath function returns the volume reference number, parent directory ID and name of the object specified by full pathname. This function requires the Alias Manager. - + fullPathLength input: The number of characters in the full pathname of the target. fullPath input: A pointer to a buffer that contains the full @@ -218,7 +218,7 @@ pascal OSErr LocationFromFullPath(short fullPathLength, vRefNum output: The volume reference number. parID output: The parent directory ID of the specified object. name output: The name of the specified object. - + Result Codes noErr 0 No error nsvErr -35 The volume is not mounted @@ -226,9 +226,9 @@ pascal OSErr LocationFromFullPath(short fullPathLength, directory found paramErr -50 Parameter error usrCanceledErr -128 The user canceled the operation - + __________ - + See also: FSpLocationFromFullPath */ @@ -240,4 +240,4 @@ pascal OSErr LocationFromFullPath(short fullPathLength, #include "OptimizationEnd.h" -#endif /* __FULLPATH__ */ \ No newline at end of file +#endif /* __FULLPATH__ */ diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/IterateDirectory.c b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/IterateDirectory.c index 9564222..e282ab1 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/IterateDirectory.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/IterateDirectory.c @@ -74,23 +74,23 @@ static void IterateDirectoryLevel(long dirID, (theGlobals->currentLevel < theGlobals->maxLevels) ) /* if currentLevel < maxLevels, look at this level */ { short index = 1; - + ++theGlobals->currentLevel; /* go to next level */ - + do { /* Isn't C great... What I'd give for a "WITH theGlobals DO" about now... */ - + /* Get next source item at the current directory level */ - + theGlobals->cPB.dirInfo.ioFDirIndex = index; theGlobals->cPB.dirInfo.ioDrDirID = dirID; - theGlobals->result = PBGetCatInfoSync((CInfoPBPtr)&theGlobals->cPB); - + theGlobals->result = PBGetCatInfoSync((CInfoPBPtr)&theGlobals->cPB); + if ( theGlobals->result == noErr ) { /* Call the IterateFilterProc */ CallIterateFilterProc(theGlobals->iterateFilter, &theGlobals->cPB, &theGlobals->quitFlag, theGlobals->yourDataPtr); - + /* Is it a directory? */ if ( (theGlobals->cPB.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { @@ -102,16 +102,16 @@ static void IterateDirectoryLevel(long dirID, } } } - + ++index; /* prepare to get next item */ } while ( (theGlobals->result == noErr) && (!theGlobals->quitFlag) ); /* time to fall back a level? */ - + if ( (theGlobals->result == fnfErr) || /* fnfErr is OK - it only means we hit the end of this level */ (theGlobals->result == afpAccessDenied) ) /* afpAccessDenied is OK, too - it only means we cannot see inside a directory */ { theGlobals->result = noErr; } - + --theGlobals->currentLevel; /* return to previous level as we leave */ } } @@ -130,7 +130,7 @@ pascal OSErr IterateDirectory(short vRefNum, long theDirID; short theVRefNum; Boolean isDirectory; - + /* Make sure there is a IterateFilter */ if ( iterateFilter != NULL ) { @@ -154,10 +154,10 @@ pascal OSErr IterateDirectory(short vRefNum, theGlobals.maxLevels = maxLevels; theGlobals.currentLevel = 0; /* start at level 0 */ theGlobals.yourDataPtr = yourDataPtr; - + /* Here we go into recursion land... */ IterateDirectoryLevel(theDirID, &theGlobals); - + result = theGlobals.result; /* set the result */ } } @@ -171,7 +171,7 @@ pascal OSErr IterateDirectory(short vRefNum, { result = paramErr; /* iterateFilter was NULL */ } - + return ( result ); } diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/IterateDirectory.h b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/IterateDirectory.h index f40b514..e566af3 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/IterateDirectory.h +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/IterateDirectory.h @@ -39,11 +39,11 @@ typedef pascal void (*IterateFilterProcPtr) (const CInfoPBRec * const cpbPtr, IterateFilterProc gets a pointer to the CInfoPBRec that IterateDirectory used to call PBGetCatInfo. The IterateFilterProc can use the read-only data in the CInfoPBRec for whatever it wants. - + If the IterateFilterProc wants to stop IterateDirectory, it can set quitFlag to true (quitFlag will be passed to the IterateFilterProc false). - + The yourDataPtr parameter can point to whatever data structure you might want to access from within the IterateFilterProc. @@ -55,9 +55,9 @@ typedef pascal void (*IterateFilterProcPtr) (const CInfoPBRec * const cpbPtr, if it wants to stop IterateDirectory. yourDataPtr input: A pointer to whatever data structure you might want to access from within the IterateFilterProc. - + __________ - + Also see: IterateDirectory, FSpIterateDirectory */ @@ -76,13 +76,13 @@ pascal OSErr IterateDirectory(short vRefNum, The IterateDirectory function performs a recursive iteration (scan) of the specified directory and calls your IterateFilterProc function once for each file and directory found. - + The maxLevels parameter lets you control how deep the recursion goes. If maxLevels is 1, IterateDirectory only scans the specified directory; if maxLevels is 2, IterateDirectory scans the specified directory and one subdirectory below the specified directory; etc. Set maxLevels to zero to scan all levels. - + The yourDataPtr parameter can point to whatever data structure you might want to access from within the IterateFilterProc. @@ -97,7 +97,7 @@ pascal OSErr IterateDirectory(short vRefNum, IterateDirectory. yourDataPtr input: A pointer to whatever data structure you might want to access from within the IterateFilterProc. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -109,9 +109,9 @@ pascal OSErr IterateDirectory(short vRefNum, or a file was passed instead of a directory afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: IterateFilterProcPtr, FSpIterateDirectory */ @@ -125,13 +125,13 @@ pascal OSErr FSpIterateDirectory(const FSSpec *spec, The FSpIterateDirectory function performs a recursive iteration (scan) of the specified directory and calls your IterateFilterProc function once for each file and directory found. - + The maxLevels parameter lets you control how deep the recursion goes. If maxLevels is 1, FSpIterateDirectory only scans the specified directory; if maxLevels is 2, FSpIterateDirectory scans the specified directory and one subdirectory below the specified directory; etc. Set maxLevels to zero to scan all levels. - + The yourDataPtr parameter can point to whatever data structure you might want to access from within the IterateFilterProc. @@ -143,7 +143,7 @@ pascal OSErr FSpIterateDirectory(const FSSpec *spec, FSpIterateDirectory. yourDataPtr input: A pointer to whatever data structure you might want to access from within the IterateFilterProc. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -154,9 +154,9 @@ pascal OSErr FSpIterateDirectory(const FSSpec *spec, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: IterateFilterProcPtr, IterateDirectory */ diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreDesktopMgr.c b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreDesktopMgr.c index f78173b..2ec5bdb 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreDesktopMgr.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreDesktopMgr.c @@ -149,11 +149,11 @@ static OSErr GetAPPLFromDesktopFile(ConstStr255Param volName, static OSErr FindBundleGivenCreator(OSType creator, BNDLRecHandle *returnBndl); - + static OSErr FindTypeInBundle(OSType typeToFind, BNDLRecHandle theBndl, BundleTypePtr *returnBundleType); - + static OSErr GetLocalIDFromFREF(BundleTypePtr theBundleType, OSType fileType, short *iconLocalID); @@ -195,7 +195,7 @@ static OSErr GetDesktopFileName(short vRefNum, HParamBlockRec pb; short index; Boolean found; - + pb.fileParam.ioNamePtr = desktopName; pb.fileParam.ioVRefNum = vRefNum; pb.fileParam.ioFVersNum = 0; @@ -216,7 +216,7 @@ static OSErr GetDesktopFileName(short vRefNum, } ++index; } while ( (error == noErr) && !found ); - + return ( error ); } @@ -231,7 +231,7 @@ pascal OSErr DTOpen(ConstStr255Param volName, GetVolParmsInfoBuffer volParmsInfo; long infoSize; DTPBRec pb; - + /* Check for volume Desktop Manager support before calling */ infoSize = sizeof(GetVolParmsInfoBuffer); error = HGetVolParms(volName, vRefNum, &volParmsInfo, &infoSize); @@ -286,7 +286,7 @@ static OSErr GetAPPLFromDesktopFile(ConstStr255Param volName, Boolean foundCreator; Ptr applPtr; long applSize; - + error = DetermineVRefNum(volName, vRefNum, &realVRefNum); if ( error == noErr ) { @@ -302,7 +302,7 @@ static OSErr GetAPPLFromDesktopFile(ConstStr255Param volName, SetResLoad(false); dfRefNum = HOpenResFile(realVRefNum, fsRtDirID, desktopName, fsRdPerm); SetResLoad(true); - + if ( dfRefNum != -1) { /* Get 'APPL' resource ID 0 */ @@ -314,7 +314,7 @@ static OSErr GetAPPLFromDesktopFile(ConstStr255Param volName, { foundCreator = false; applPtr = *applResHandle; - + /* APPL's don't have a count so I have to use the size as the bounds */ while ( (foundCreator == false) && (applPtr < (*applResHandle + applSize)) ) @@ -359,7 +359,7 @@ static OSErr GetAPPLFromDesktopFile(ConstStr255Param volName, { error = afpItemNotFound; /* no APPL mapping available */ } - + /* restore the resource chain and close the Desktop file */ UseResFile(savedResFile); CloseResFile(dfRefNum); @@ -370,7 +370,7 @@ static OSErr GetAPPLFromDesktopFile(ConstStr255Param volName, } } } - + return ( error ); } @@ -393,7 +393,7 @@ pascal OSErr DTXGetAPPL(ConstStr255Param volName, Boolean applFound; FSSpec spec; long actMatchCount; - + /* get the real vRefNum */ error = DetermineVRefNum(volName, vRefNum, &realVRefNum); if ( error == noErr ) @@ -415,10 +415,10 @@ pascal OSErr DTXGetAPPL(ConstStr255Param volName, if ( error == noErr ) { /* got a match - see if it is valid */ - + *applVRefNum = realVRefNum; /* get the vRefNum now */ *applParID = pb.dtPB.ioAPPLParID; /* get the parent ID now */ - + /* pb.hPB.fileParam.ioNamePtr is already set */ pb.hPB.fileParam.ioVRefNum = realVRefNum; pb.hPB.fileParam.ioFVersNum = 0; @@ -451,13 +451,13 @@ pascal OSErr DTXGetAPPL(ConstStr255Param volName, { /* if paramErr, the volume didn't support the Desktop Manager */ /* try the Desktop file */ - + error = GetAPPLFromDesktopFile(volName, vRefNum, creator, applVRefNum, applParID, applName); if ( error == noErr ) { /* got a match - see if it is valid */ - + pb.hPB.fileParam.ioNamePtr = applName; pb.hPB.fileParam.ioVRefNum = *applVRefNum; pb.hPB.fileParam.ioFVersNum = 0; @@ -482,7 +482,7 @@ pascal OSErr DTXGetAPPL(ConstStr255Param volName, { /* Couldn't be found in the Desktop file either, */ /* try searching with CatSearch if requested */ - + error = CreatorTypeFileSearch(NULL, realVRefNum, creator, kAPPLResType, &spec, 1, &actMatchCount, true); if ( (error == noErr) || (error == eofErr) ) @@ -500,7 +500,7 @@ pascal OSErr DTXGetAPPL(ConstStr255Param volName, } } } - + return ( error ); } @@ -525,7 +525,7 @@ pascal OSErr DTGetAPPL(ConstStr255Param volName, long *applParID, Str255 applName) { - /* Call DTXGetAPPL with the "searchCatalog" parameter true */ + /* Call DTXGetAPPL with the "searchCatalog" parameter true */ return ( DTXGetAPPL(volName, vRefNum, creator, true, applVRefNum, applParID, applName) ); } @@ -537,7 +537,7 @@ pascal OSErr FSpDTGetAPPL(ConstStr255Param volName, OSType creator, FSSpec *spec) { - /* Call DTXGetAPPL with the "searchCatalog" parameter true */ + /* Call DTXGetAPPL with the "searchCatalog" parameter true */ return ( DTXGetAPPL(volName, vRefNum, creator, true, &(spec->vRefNum), &(spec->parID), spec->name) ); } @@ -557,19 +557,19 @@ static OSErr FindBundleGivenCreator(OSType creator, short numOfBundles; short index; BNDLRecHandle theBndl; - + error = afpItemNotFound; /* default to not found */ - + /* Search each BNDL resource until we find the one with a matching creator. */ - + numOfBundles = Count1Resources(kBNDLResType); index = 1; *returnBndl = NULL; - + while ( (index <= numOfBundles) && (*returnBndl == NULL) ) { theBndl = (BNDLRecHandle)Get1IndResource(kBNDLResType, index); - + if ( theBndl != NULL ) { if ( (*theBndl)->signature == creator ) @@ -583,11 +583,11 @@ static OSErr FindBundleGivenCreator(OSType creator, error = noErr; } } - } - + } + index ++; } - + return ( error ); } @@ -607,9 +607,9 @@ static OSErr FindTypeInBundle(OSType typeToFind, OSErr error; short index; Ptr ptrIterator; /* use a Ptr so we can do ugly pointer math */ - + error = afpItemNotFound; /* default to not found */ - + ptrIterator = (Ptr)((*theBndl)->typeArray); index = 0; *returnBundleType = NULL; @@ -631,7 +631,7 @@ static OSErr FindTypeInBundle(OSType typeToFind, ++index; } } - + return ( error ); } @@ -653,14 +653,14 @@ static OSErr GetLocalIDFromFREF(BundleTypePtr theBundleType, short index; IDRecPtr idIterator; FREFRecHandle theFref; - + error = afpItemNotFound; /* default to not found */ - + /* For each localID in this type, get the FREF resource looking for fileType */ index = 0; idIterator = &theBundleType->idArray[0]; *iconLocalID = 0; - + while ( (index <= theBundleType->count) && (*iconLocalID == 0) ) { theFref = (FREFRecHandle)Get1Resource(kFREFResType, idIterator->rsrcID); @@ -672,11 +672,11 @@ static OSErr GetLocalIDFromFREF(BundleTypePtr theBundleType, error = noErr; } } - + ++idIterator; ++index; } - + return ( error ); } @@ -697,14 +697,14 @@ static OSErr GetIconRsrcIDFromLocalID(BundleTypePtr theBundleType, OSErr error; short index; IDRecPtr idIterator; - + error = afpItemNotFound; /* default to not found */ - + /* Find the rsrcID of the icon family type, given the localID */ index = 0; idIterator = &theBundleType->idArray[0]; *iconRsrcID = 0; - + while ( (index <= theBundleType->count) && (*iconRsrcID == 0) ) { if ( idIterator->localID == iconLocalID ) @@ -712,11 +712,11 @@ static OSErr GetIconRsrcIDFromLocalID(BundleTypePtr theBundleType, *iconRsrcID = idIterator->rsrcID; error = noErr; } - + idIterator ++; index ++; } - + return ( error ); } @@ -731,7 +731,7 @@ static OSErr GetIconRsrcIDFromLocalID(BundleTypePtr theBundleType, static OSType DTIconToResIcon(short iconType) { OSType resType; - + switch ( iconType ) { case kLargeIcon: @@ -756,7 +756,7 @@ static OSType DTIconToResIcon(short iconType) resType = (OSType)0; break; } - + return ( resType ); } @@ -794,11 +794,11 @@ static OSErr GetIconFromDesktopFile(ConstStr255Param volName, short iconLocalID; short iconRsrcID; OSType iconRsrcType; - Handle returnIconHandle; + Handle returnIconHandle; char bndlState; - + *iconHandle = NULL; - + error = DetermineVRefNum(volName, vRefNum, &realVRefNum); if ( error == noErr ) { @@ -806,7 +806,7 @@ static OSErr GetIconFromDesktopFile(ConstStr255Param volName, if ( error == noErr ) { savedResFile = CurResFile(); - + /* ** Open the 'Desktop' file in the root directory. (because ** opening the resource file could preload unwanted resources, @@ -815,7 +815,7 @@ static OSErr GetIconFromDesktopFile(ConstStr255Param volName, SetResLoad(false); dfRefNum = HOpenResFile(realVRefNum, fsRtDirID, desktopName, fsRdPerm); SetResLoad(true); - + if ( dfRefNum != -1 ) { /* @@ -827,7 +827,7 @@ static OSErr GetIconFromDesktopFile(ConstStr255Param volName, /* Lock the BNDL resource so it won't be purged when other resources are loaded */ bndlState = HGetState((Handle)theBndl); HLock((Handle)theBndl); - + /* Find the 'FREF' BundleType record in the BNDL resource. */ error = FindTypeInBundle(kFREFResType, theBndl, &theBundleType); if ( error == noErr ) @@ -846,7 +846,7 @@ static OSErr GetIconFromDesktopFile(ConstStr255Param volName, { /* Map Desktop Manager icon type to resource type */ iconRsrcType = DTIconToResIcon(iconType); - + if ( iconRsrcType != (OSType)0 ) { /* Load the icon */ @@ -873,7 +873,7 @@ static OSErr GetIconFromDesktopFile(ConstStr255Param volName, } } } - /* Restore the state of the BNDL resource */ + /* Restore the state of the BNDL resource */ HSetState((Handle)theBndl, bndlState); } /* Restore the resource chain and close the Desktop file */ @@ -890,7 +890,7 @@ static OSErr GetIconFromDesktopFile(ConstStr255Param volName, error = afpItemNotFound; /* force an error we should return */ } } - + return ( error ); } @@ -908,13 +908,13 @@ pascal OSErr DTGetIcon(ConstStr255Param volName, short dtRefNum; Boolean newDTDatabase; Size bufferSize; - + *iconHandle = NULL; error = DTOpen(volName, vRefNum, &dtRefNum, &newDTDatabase); if ( error == noErr ) { /* there was a desktop database and it's now open */ - + if ( !newDTDatabase ) /* don't bother to look in a new (empty) database */ { /* get the buffer size for the requested icon type */ @@ -949,7 +949,7 @@ pascal OSErr DTGetIcon(ConstStr255Param volName, if ( *iconHandle != NULL ) { HLock(*iconHandle); - + pb.ioDTRefNum = dtRefNum; pb.ioTagInfo = 0; pb.ioDTBuffer = **iconHandle; @@ -958,9 +958,9 @@ pascal OSErr DTGetIcon(ConstStr255Param volName, pb.ioFileCreator = fileCreator; pb.ioFileType = fileType; error = PBDTGetIconSync(&pb); - + HUnlock(*iconHandle); - + if ( error != noErr ) { DisposeHandle(*iconHandle); /* dispose of the allocated memory */ @@ -985,11 +985,11 @@ pascal OSErr DTGetIcon(ConstStr255Param volName, else { /* There is no desktop database - try the Desktop file */ - + error = GetIconFromDesktopFile(volName, vRefNum, iconType, fileCreator, fileType, iconHandle); } - + return ( error ); } @@ -1076,7 +1076,7 @@ static OSErr GetCommentFromDesktopFile(short vRefNum, short savedResFile; short dfRefNum; StringHandle commentHandle; - + /* Get the comment ID number */ error = GetCommentID(vRefNum, dirID, name, &commentID); if ( error == noErr ) @@ -1098,7 +1098,7 @@ static OSErr GetCommentFromDesktopFile(short vRefNum, SetResLoad(false); dfRefNum = HOpenResFile(realVRefNum, fsRtDirID, desktopName, fsRdPerm); SetResLoad(true); - + if ( dfRefNum != -1) { /* Get the comment resource */ @@ -1118,7 +1118,7 @@ static OSErr GetCommentFromDesktopFile(short vRefNum, { error = afpItemNotFound; /* no comment available */ } - + /* restore the resource chain and close the Desktop file */ UseResFile(savedResFile); CloseResFile(dfRefNum); @@ -1139,7 +1139,7 @@ static OSErr GetCommentFromDesktopFile(short vRefNum, error = afpItemNotFound; /* no comment available */ } } - + return ( error ); } @@ -1158,13 +1158,13 @@ pascal OSErr DTGetComment(short vRefNum, if (comment != NULL) { comment[0] = 0; /* return nothing by default */ - + /* attempt to open the desktop database */ error = DTOpen(name, vRefNum, &dtRefNum, &newDTDatabase); if ( error == noErr ) { /* There was a desktop database and it's now open */ - + if ( !newDTDatabase ) { pb.ioDTRefNum = dtRefNum; @@ -1208,7 +1208,7 @@ pascal OSErr DTGetComment(short vRefNum, { error = paramErr; } - + return (error); } diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreDesktopMgr.h b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreDesktopMgr.h index 9b00c88..a87f244 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreDesktopMgr.h +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreDesktopMgr.h @@ -57,7 +57,7 @@ pascal OSErr DTOpen(ConstStr255Param volName, false if the desktop database was already created, or if it could not be determined if it was already created. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -65,7 +65,7 @@ pascal OSErr DTOpen(ConstStr255Param volName, paramErr -50 Volume doesn't support this function extFSErr -58 External file system error - no file system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - + desktopDamagedErr -1305 The desktop database has become corrupted - the Finder will fix this, but if your application is not running with the Finder, use PBDTReset or PBDTDelete @@ -86,7 +86,7 @@ pascal OSErr DTXGetAPPL(ConstStr255Param volName, the application mapping from the desktop database. If that fails, then it tries to find an application in the Desktop file. If that fails and searchCatalog is true, then it tries to find an application - with the specified creator using the File Manager's CatSearch routine. + with the specified creator using the File Manager's CatSearch routine. volName input: A pointer to the name of a mounted volume or nil. @@ -98,7 +98,7 @@ pascal OSErr DTXGetAPPL(ConstStr255Param volName, application is on. applParID output: The parent directory ID of the application. applName output: The name of the application. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -107,14 +107,14 @@ pascal OSErr DTXGetAPPL(ConstStr255Param volName, rfNumErr -51 Reference number invalid extFSErr -58 External file system error - no file system claimed this call - desktopDamagedErr -1305 The desktop database has become corrupted - + desktopDamagedErr -1305 The desktop database has become corrupted - the Finder will fix this, but if your application is not running with the Finder, use PBDTReset or PBDTDelete afpItemNotFound -5012 Information not found - + __________ - + Also see: FSpDTGetAPPL */ @@ -131,7 +131,7 @@ pascal OSErr FSpDTXGetAPPL(ConstStr255Param volName, the application mapping from the desktop database. If that fails, then it tries to find an application in the Desktop file. If that fails and searchCatalog is true, then it tries to find an application - with the specified creator using the File Manager's CatSearch routine. + with the specified creator using the File Manager's CatSearch routine. volName input: A pointer to the name of a mounted volume or nil. @@ -141,7 +141,7 @@ pascal OSErr FSpDTXGetAPPL(ConstStr255Param volName, if it isn't found in the desktop database. spec output: FSSpec record containing the application name and location. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -150,14 +150,14 @@ pascal OSErr FSpDTXGetAPPL(ConstStr255Param volName, rfNumErr -51 Reference number invalid extFSErr -58 External file system error - no file system claimed this call - desktopDamagedErr -1305 The desktop database has become corrupted - + desktopDamagedErr -1305 The desktop database has become corrupted - the Finder will fix this, but if your application is not running with the Finder, use PBDTReset or PBDTDelete afpItemNotFound -5012 Information not found - + __________ - + Also see: FSpDTGetAPPL */ @@ -175,7 +175,7 @@ pascal OSErr DTGetAPPL(ConstStr255Param volName, the application mapping from the desktop database. If that fails, then it tries to find an application in the Desktop file. If that fails, then it tries to find an application with the specified creator - using the File Manager's CatSearch routine. + using the File Manager's CatSearch routine. volName input: A pointer to the name of a mounted volume or nil. @@ -185,7 +185,7 @@ pascal OSErr DTGetAPPL(ConstStr255Param volName, application is on. applParID output: The parent directory ID of the application. applName output: The name of the application. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -194,14 +194,14 @@ pascal OSErr DTGetAPPL(ConstStr255Param volName, rfNumErr -51 Reference number invalid extFSErr -58 External file system error - no file system claimed this call - desktopDamagedErr -1305 The desktop database has become corrupted - + desktopDamagedErr -1305 The desktop database has become corrupted - the Finder will fix this, but if your application is not running with the Finder, use PBDTReset or PBDTDelete afpItemNotFound -5012 Information not found - + __________ - + Also see: FSpDTGetAPPL */ @@ -217,7 +217,7 @@ pascal OSErr FSpDTGetAPPL(ConstStr255Param volName, the application mapping from the desktop database. If that fails, then it tries to find an application in the Desktop file. If that fails, then it tries to find an application with the specified creator - using the File Manager's CatSearch routine. + using the File Manager's CatSearch routine. volName input: A pointer to the name of a mounted volume or nil. @@ -225,7 +225,7 @@ pascal OSErr FSpDTGetAPPL(ConstStr255Param volName, creator input: The file's creator type. spec output: FSSpec record containing the application name and location. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -234,14 +234,14 @@ pascal OSErr FSpDTGetAPPL(ConstStr255Param volName, rfNumErr -51 Reference number invalid extFSErr -58 External file system error - no file system claimed this call - desktopDamagedErr -1305 The desktop database has become corrupted - + desktopDamagedErr -1305 The desktop database has become corrupted - the Finder will fix this, but if your application is not running with the Finder, use PBDTReset or PBDTDelete afpItemNotFound -5012 Information not found - + __________ - + Also see: DTGetAPPL */ @@ -273,7 +273,7 @@ pascal OSErr DTGetIcon(ConstStr255Param volName, fileCreator input: The icon's creator type. fileType input: The icon's file type. iconHandle output: A Handle containing the newly created icon. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -283,7 +283,7 @@ pascal OSErr DTGetIcon(ConstStr255Param volName, extFSErr -58 External file system error - no file system claimed this call memFullErr -108 iconHandle could not be allocated - desktopDamagedErr -1305 The desktop database has become corrupted - + desktopDamagedErr -1305 The desktop database has become corrupted - the Finder will fix this, but if your application is not running with the Finder, use PBDTReset or PBDTDelete @@ -307,7 +307,7 @@ pascal OSErr DTSetComment(short vRefNum, specifies a directory that's the object. comment input: The comment to add. Comments are limited to 200 characters; longer comments are truncated. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -319,13 +319,13 @@ pascal OSErr DTSetComment(short vRefNum, rfNumErr –51 Reference number invalid extFSErr -58 External file system error - no file system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - + desktopDamagedErr -1305 The desktop database has become corrupted - the Finder will fix this, but if your application is not running with the Finder, use PBDTReset or PBDTDelete - + __________ - + Also see: DTCopyComment, FSpDTCopyComment, FSpDTSetComment, DTGetComment, FSpDTGetComment */ @@ -342,7 +342,7 @@ pascal OSErr FSpDTSetComment(const FSSpec *spec, spec input: An FSSpec record specifying the file or directory. comment input: The comment to add. Comments are limited to 200 characters; longer comments are truncated. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -354,13 +354,13 @@ pascal OSErr FSpDTSetComment(const FSSpec *spec, paramErr -50 Volume doesn't support this function extFSErr -58 External file system error - no file system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - + desktopDamagedErr -1305 The desktop database has become corrupted - the Finder will fix this, but if your application is not running with the Finder, use PBDTReset or PBDTDelete - + __________ - + Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, DTGetComment, FSpDTGetComment */ @@ -381,13 +381,13 @@ pascal OSErr DTGetComment(short vRefNum, Desktop Manager, other file systems (such as Apple Photo Access) return up to 255 characters. Make sure the comment buffer is a Str255 or you'll regret it. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. comment output: A Str255 where the comment is to be returned. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -397,14 +397,14 @@ pascal OSErr DTGetComment(short vRefNum, rfNumErr –51 Reference number invalid extFSErr -58 External file system error - no file system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - + desktopDamagedErr -1305 The desktop database has become corrupted - the Finder will fix this, but if your application is not running with the Finder, use PBDTReset or PBDTDelete afpItemNotFound -5012 Information not found - + __________ - + Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, FSpDTSetComment, FSpDTGetComment */ @@ -423,7 +423,7 @@ pascal OSErr FSpDTGetComment(const FSSpec *spec, Desktop Manager, other file systems (such as Apple Photo Access) return up to 255 characters. Make sure the comment buffer is a Str255 or you'll regret it. - + spec input: An FSSpec record specifying the file or directory. comment output: A Str255 where the comment is to be returned. @@ -436,14 +436,14 @@ pascal OSErr FSpDTGetComment(const FSSpec *spec, rfNumErr –51 Reference number invalid extFSErr -58 External file system error - no file system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - + desktopDamagedErr -1305 The desktop database has become corrupted - the Finder will fix this, but if your application is not running with the Finder, use PBDTReset or PBDTDelete afpItemNotFound -5012 Information not found - + __________ - + Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, FSpDTSetComment, DTGetComment */ @@ -460,7 +460,7 @@ pascal OSErr DTCopyComment(short srcVRefNum, The DTCopyComment function copies the file or folder comment from the source to the destination object. The destination volume must support the Desktop Manager because you only have read access to the Desktop file. - + srcVRefNum input: Source volume specification. srcDirID input: Source directory ID. srcName input: Pointer to source object name, or nil when srcDirID @@ -469,7 +469,7 @@ pascal OSErr DTCopyComment(short srcVRefNum, dstDirID input: Destination directory ID. dstName input: Pointer to destination object name, or nil when dstDirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -482,14 +482,14 @@ pascal OSErr DTCopyComment(short srcVRefNum, paramErr -50 Volume doesn't support this function extFSErr -58 External file system error - no file system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - + desktopDamagedErr -1305 The desktop database has become corrupted - the Finder will fix this, but if your application is not running with the Finder, use PBDTReset or PBDTDelete afpItemNotFound -5012 Information not found - + __________ - + Also see: FSpDTCopyComment, DTSetComment, FSpDTSetComment, DTGetComment, FSpDTGetComment */ @@ -502,10 +502,10 @@ pascal OSErr FSpDTCopyComment(const FSSpec *srcSpec, The FSpDTCopyComment function copies the desktop database comment from the source to the destination object. Both the source and the destination volumes must support the Desktop Manager. - + srcSpec input: An FSSpec record specifying the source object. dstSpec input: An FSSpec record specifying the destination object. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -518,14 +518,14 @@ pascal OSErr FSpDTCopyComment(const FSSpec *srcSpec, paramErr -50 Volume doesn't support this function extFSErr -58 External file system error - no file system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - + desktopDamagedErr -1305 The desktop database has become corrupted - the Finder will fix this, but if your application is not running with the Finder, use PBDTReset or PBDTDelete afpItemNotFound -5012 Information not found - + __________ - + Also see: DTCopyComment, DTSetComment, FSpDTSetComment, DTGetComment, FSpDTGetComment */ diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFiles.c b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFiles.c index 173b824..b4460ba 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFiles.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFiles.c @@ -101,7 +101,7 @@ pascal OSErr ResolveFileIDRef(ConstStr255Param volName, HParamBlockRec pb; OSErr error; Str255 tempStr; - + tempStr[0] = 0; if ( volName != NULL ) { @@ -130,7 +130,7 @@ pascal OSErr FSpResolveFileIDRef(ConstStr255Param volName, FSSpec *spec) { OSErr error; - + error = DetermineVRefNum(volName, vRefNum, &(spec->vRefNum)); if ( error == noErr ) { @@ -239,7 +239,7 @@ pascal OSErr GetForeignPrivs(short vRefNum, pb.foreignPrivParam.ioNamePtr = (StringPtr)name; pb.foreignPrivParam.ioVRefNum = vRefNum; - pb.foreignPrivParam.ioForeignPrivDirID = dirID; + pb.foreignPrivParam.ioForeignPrivDirID = dirID; pb.foreignPrivParam.ioForeignPrivBuffer = (Ptr)foreignPrivBuffer; pb.foreignPrivParam.ioForeignPrivReqCount = *foreignPrivSize; error = PBGetForeignPrivsSync(&pb); @@ -284,7 +284,7 @@ pascal OSErr SetForeignPrivs(short vRefNum, pb.foreignPrivParam.ioNamePtr = (StringPtr)name; pb.foreignPrivParam.ioVRefNum = vRefNum; - pb.foreignPrivParam.ioForeignPrivDirID = dirID; + pb.foreignPrivParam.ioForeignPrivDirID = dirID; pb.foreignPrivParam.ioForeignPrivBuffer = (Ptr)foreignPrivBuffer; pb.foreignPrivParam.ioForeignPrivReqCount = *foreignPrivSize; pb.foreignPrivParam.ioForeignPrivInfo1 = foreignPrivInfo1; @@ -504,7 +504,7 @@ pascal OSErr FSpMoveRename(const FSSpec *srcSpec, ConstStr255Param copyName) { OSErr error; - + /* make sure the FSSpecs refer to the same volume */ if ( srcSpec->vRefNum != dstSpec->vRefNum ) { @@ -512,7 +512,7 @@ pascal OSErr FSpMoveRename(const FSSpec *srcSpec, } else { - error = HMoveRename(srcSpec->vRefNum, srcSpec->parID, srcSpec->name, + error = HMoveRename(srcSpec->vRefNum, srcSpec->parID, srcSpec->name, dstSpec->parID, dstSpec->name, copyName); } return ( error ); diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFiles.h b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFiles.h index 8d17510..f68b7d7 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFiles.h +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFiles.h @@ -51,14 +51,14 @@ pascal OSErr HGetVolParms(ConstStr255Param volName, output: Atributes information. infoSize input: Size of buffer pointed to by volParmsInfo. output: Size of data actually returned. - + Result Codes noErr 0 No error nsvErr -35 Volume not found paramErr -50 Volume doesn't support this function - + __________ - + Also see the macros for checking attribute bits in MoreFilesExtras.h */ @@ -72,11 +72,11 @@ pascal OSErr HCreateMinimum(short vRefNum, the creator and file type of the new file. This function is needed to create a file in an AppleShare "drop box" where the user can make changes, but cannot see folder or files. - + vRefNum input: Volume specification. dirID input: Directory ID. fileName input: The name of the new file. - + Result Codes noErr 0 No error dirFulErr -33 File directory full @@ -91,9 +91,9 @@ pascal OSErr HCreateMinimum(short vRefNum, dirNFErrdirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 A directory exists with that name - + __________ - + Also see: FSpCreateMinimum */ @@ -101,13 +101,13 @@ pascal OSErr HCreateMinimum(short vRefNum, pascal OSErr FSpCreateMinimum(const FSSpec *spec); /* ¶ Create a new file with no creator or file type. - The FSpCreateMinimum function creates a new file without attempting to set + The FSpCreateMinimum function creates a new file without attempting to set the the creator and file type of the new file. This function is needed to create a file in an AppleShare "dropbox" where the user can make - changes, but cannot see folder or files. - + changes, but cannot see folder or files. + spec input: An FSSpec record specifying the file to create. - + Result Codes noErr 0 No error dirFulErr -33 File directory full @@ -122,9 +122,9 @@ pascal OSErr FSpCreateMinimum(const FSSpec *spec); dirNFErrdirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 A directory exists with that name - + __________ - + Also see: HCreateMinimum */ @@ -145,7 +145,7 @@ pascal OSErr ExchangeFiles(short vRefNum, srcName input: Source file name. dstDirID input: Destination directory ID. dstName input: Destination file name. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -162,7 +162,7 @@ pascal OSErr ExchangeFiles(short vRefNum, afpSameObjectErr -5038 Source and destination are the same __________ - + Also see: FSpExchangeFilesCompat */ @@ -176,7 +176,7 @@ pascal OSErr ResolveFileIDRef(ConstStr255Param volName, /* ¶ Retrieve the location of the file with the specified file ID reference. The ResolveFileIDRef function returns the filename and parent directory ID of the file with the specified file ID reference. - + volName input: A pointer to the name of a mounted volume or nil. vRefNum input: Volume specification. @@ -185,7 +185,7 @@ pascal OSErr ResolveFileIDRef(ConstStr255Param volName, name input: Points to a buffer (minimum Str63) where the filename is to be returned or must be nil. output: The filename. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -202,9 +202,9 @@ pascal OSErr ResolveFileIDRef(ConstStr255Param volName, afpObjectTypeErr -5025 Specified file is a directory afpIDNotFound -5034 File ID reference not found afpBadIDErr -5039 File ID reference not found - + __________ - + Also see: FSpResolveFileIDRef, CreateFileIDRef, FSpCreateFileIDRef, DeleteFileIDRef */ @@ -218,7 +218,7 @@ pascal OSErr FSpResolveFileIDRef(ConstStr255Param volName, /* ¶ Retrieve the location of the file with the specified file ID reference. The FSpResolveFileIDRef function fills in an FSSpec with the location of the file with the specified file ID reference. - + volName input: A pointer to the name of a mounted volume or nil. vRefNum input: Volume specification. @@ -226,7 +226,7 @@ pascal OSErr FSpResolveFileIDRef(ConstStr255Param volName, spec input: A pointer to a FSSpec record. output: A file system specification to be filled in by FSpResolveFileIDRef. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -244,9 +244,9 @@ pascal OSErr FSpResolveFileIDRef(ConstStr255Param volName, afpObjectTypeErr -5025 Specified file is a directory afpIDNotFound -5034 File ID reference not found afpBadIDErr -5039 File ID reference not found - + __________ - + Also see: ResolveFileIDRef, CreateFileIDRef, FSpCreateFileIDRef, DeleteFileIDRef */ @@ -267,7 +267,7 @@ pascal OSErr CreateFileIDRef(short vRefNum, fileName input: The name of the file. fileID output: The file ID reference (if result is noErr, fidExists, or afpIDExists). - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -285,9 +285,9 @@ pascal OSErr CreateFileIDRef(short vRefNum, afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Specified file is a directory afpIDExists -5035 File ID reference already exists - + __________ - + Also see: FSpResolveFileIDRef, ResolveFileIDRef, FSpCreateFileIDRef, DeleteFileIDRef */ @@ -304,7 +304,7 @@ pascal OSErr FSpCreateFileIDRef(const FSSpec *spec, spec input: An FSSpec record specifying the file. fileID output: The file ID reference (if result is noErr, fidExists, or afpIDExists). - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -322,9 +322,9 @@ pascal OSErr FSpCreateFileIDRef(const FSSpec *spec, afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Specified file is a directory afpIDExists -5035 File ID reference already exists - + __________ - + Also see: FSpResolveFileIDRef, ResolveFileIDRef, CreateFileIDRef, DeleteFileIDRef */ @@ -341,7 +341,7 @@ pascal OSErr DeleteFileIDRef(ConstStr255Param volName, or nil. vRefNum input: Volume specification. fileID input: The file ID reference. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -358,9 +358,9 @@ pascal OSErr DeleteFileIDRef(ConstStr255Param volName, afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Specified file is a directory afpIDNotFound -5034 File ID reference not found - + __________ - + Also see: FSpResolveFileIDRef, ResolveFileIDRef, CreateFileIDRef, FSpCreateFileIDRef */ @@ -375,7 +375,7 @@ pascal OSErr FlushFile(short refNum); is called. refNum input: The file reference number of an open file. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -399,7 +399,7 @@ pascal OSErr LockRange(short refNum, refNum input: The file reference number of an open file. rangeLength input: The number of bytes in the range. rangeStart input: The starting byte in the range to lock. - + Result Codes noErr 0 No error ioErr -36 I/O error @@ -415,7 +415,7 @@ pascal OSErr LockRange(short refNum, afpRangeOverlap -5021 Part of range is already locked __________ - + Also see: UnlockRange */ @@ -431,7 +431,7 @@ pascal OSErr UnlockRange(short refNum, refNum input: The file reference number of an open file. rangeLength input: The number of bytes in the range. rangeStart input: The starting byte in the range to unlock. - + Result Codes noErr 0 No error ioErr -36 I/O error @@ -445,7 +445,7 @@ pascal OSErr UnlockRange(short refNum, afpRangeNotLocked -5020 Specified range was not locked __________ - + Also see: LockRange */ @@ -464,7 +464,7 @@ pascal OSErr GetForeignPrivs(short vRefNum, The GetForeignPrivs function retrieves the native access-control information for a file or directory stored on a volume managed by a foreign file system. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID @@ -479,16 +479,16 @@ pascal OSErr GetForeignPrivs(short vRefNum, foreignPrivInfo2 output: Information specific to privilege model. foreignPrivInfo3 output: Information specific to privilege model. foreignPrivInfo4 output: Information specific to privilege model. - + Result Codes noErr 0 No error nsvErr -35 Volume not found paramErr -50 Volume is HFS or MFS (that is, it has no foreign privilege model), or foreign volume does not support these calls - + __________ - + Also see: FSpGetForeignPrivs, SetForeignPrivs, FSpSetForeignPrivs */ @@ -505,7 +505,7 @@ pascal OSErr FSpGetForeignPrivs(const FSSpec *spec, The FSpGetForeignPrivs function retrieves the native access-control information for a file or directory stored on a volume managed by a foreign file system. - + spec input: An FSSpec record specifying the object. foreignPrivBuffer input: Pointer to buffer where the privilege information is returned. @@ -517,16 +517,16 @@ pascal OSErr FSpGetForeignPrivs(const FSSpec *spec, foreignPrivInfo2 output: Information specific to privilege model. foreignPrivInfo3 output: Information specific to privilege model. foreignPrivInfo4 output: Information specific to privilege model. - + Result Codes noErr 0 No error nsvErr -35 Volume not found paramErr -50 Volume is HFS or MFS (that is, it has no foreign privilege model), or foreign volume does not support these calls - + __________ - + Also see: GetForeignPrivs, SetForeignPrivs, FSpSetForeignPrivs */ @@ -545,7 +545,7 @@ pascal OSErr SetForeignPrivs(short vRefNum, The SetForeignPrivs function changes the native access-control information for a file or directory stored on a volume managed by a foreign file system. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID @@ -558,16 +558,16 @@ pascal OSErr SetForeignPrivs(short vRefNum, foreignPrivInfo2 input: Information specific to privilege model. foreignPrivInfo3 input: Information specific to privilege model. foreignPrivInfo4 input: Information specific to privilege model. - + Result Codes noErr 0 No error nsvErr -35 Volume not found paramErr -50 Volume is HFS or MFS (that is, it has no foreign privilege model), or foreign volume does not support these calls - + __________ - + Also see: GetForeignPrivs, FSpGetForeignPrivs, FSpSetForeignPrivs */ @@ -584,7 +584,7 @@ pascal OSErr FSpSetForeignPrivs(const FSSpec *spec, The FSpSetForeignPrivs function changes the native access-control information for a file or directory stored on a volume managed by a foreign file system. - + spec input: An FSSpec record specifying the object. foreignPrivBuffer input: Pointer to privilege information buffer. foreignPrivSize input: Size of buffer pointed to by @@ -594,16 +594,16 @@ pascal OSErr FSpSetForeignPrivs(const FSSpec *spec, foreignPrivInfo2 input: Information specific to privilege model. foreignPrivInfo3 input: Information specific to privilege model. foreignPrivInfo4 input: Information specific to privilege model. - + Result Codes noErr 0 No error nsvErr -35 Volume not found paramErr -50 Volume is HFS or MFS (that is, it has no foreign privilege model), or foreign volume does not support these calls - + __________ - + Also see: GetForeignPrivs, FSpGetForeignPrivs, SetForeignPrivs */ @@ -616,7 +616,7 @@ pascal OSErr HGetLogInInfo(ConstStr255Param volName, /* ¶ Get the login method and user name used to log on to a shared volume. The HGetLogInInfo function retrieves the login method and user name used to log on to a particular shared volume. - + volName input: A pointer to the name of a mounted volume or nil. vRefNum input: The volume reference number. @@ -626,14 +626,14 @@ pascal OSErr HGetLogInInfo(ConstStr255Param volName, userName input: Points to a buffer (minimum Str31) where the user name is to be returned or must be nil. output: The user name. - + Result Codes noErr 0 No error nsvErr -35 Specified volume doesn’t exist paramErr -50 Function not supported by volume - + __________ - + Also see: HGetDirAccess, FSpGetDirAccess, HSetDirAccess, FSpSetDirAccess, HMapName, HMapID */ @@ -649,7 +649,7 @@ pascal OSErr HGetDirAccess(short vRefNum, /* ¶ Get a directory's access control information on a shared volume. The HGetDirAccess function retrieves the directory access control information for a directory on a shared volume. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to directory name, or nil if dirID @@ -658,16 +658,16 @@ pascal OSErr HGetDirAccess(short vRefNum, groupID output: The directory's group ID or 0 if no group affiliation. accessRights output: The directory's access rights. - + Result Codes noErr 0 No error fnfErr -43 Directory not found paramErr -50 Function not supported by volume afpAccessDenied -5000 User does not have the correct access to the directory - + __________ - + Also see: HGetLogInInfo, FSpGetDirAccess, HSetDirAccess, FSpSetDirAccess, HMapName, HMapID */ @@ -681,22 +681,22 @@ pascal OSErr FSpGetDirAccess(const FSSpec *spec, /* ¶ Get a directory's access control information on a shared volume. The FSpGetDirAccess function retrieves the directory access control information for a directory on a shared volume. - + spec input: An FSSpec record specifying the directory. ownerID output: The directory's owner ID. groupID output: The directory's group ID or 0 if no group affiliation. accessRights output: The directory's access rights. - + Result Codes noErr 0 No error fnfErr -43 Directory not found paramErr -50 Function not supported by volume afpAccessDenied -5000 User does not have the correct access to the directory - + __________ - + Also see: HGetLogInInfo, HGetDirAccess, HSetDirAccess, FSpSetDirAccess, HMapName, HMapID */ @@ -713,7 +713,7 @@ pascal OSErr HSetDirAccess(short vRefNum, The HSetDirAccess function changes the directory access control information for a directory on a shared volume. You must own a directory to change its access control information. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to directory name, or nil if dirID @@ -722,7 +722,7 @@ pascal OSErr HSetDirAccess(short vRefNum, groupID input: The directory's group ID or 0 if no group affiliation. accessRights input: The directory's access rights. - + Result Codes noErr 0 No error fnfErr -43 Directory not found @@ -731,9 +731,9 @@ pascal OSErr HSetDirAccess(short vRefNum, afpAccessDenied -5000 User does not have the correct access to the directory afpObjectTypeErr -5025 Object is a file, not a directory - + __________ - + Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, FSpSetDirAccess, HMapName, HMapID */ @@ -748,13 +748,13 @@ pascal OSErr FSpSetDirAccess(const FSSpec *spec, The FSpSetDirAccess function changes the directory access control information for a directory on a shared volume. You must own a directory to change its access control information. - + spec input: An FSSpec record specifying the directory. ownerID input: The directory's owner ID. groupID input: The directory's group ID or 0 if no group affiliation. accessRights input: The directory's access rights. - + Result Codes noErr 0 No error fnfErr -43 Directory not found @@ -763,9 +763,9 @@ pascal OSErr FSpSetDirAccess(const FSSpec *spec, afpAccessDenied -5000 User does not have the correct access to the directory afpObjectTypeErr -5025 Object is a file, not a directory - + __________ - + Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess, HMapName, HMapID */ @@ -780,7 +780,7 @@ pascal OSErr HMapID(ConstStr255Param volName, /* ¶ Map a user or group ID to a user or group name. The HMapID function determines the name of a user or group if you know the user or group ID. - + volName input: A pointer to the name of a mounted volume or nil. vRefNum input: Volume specification. @@ -790,14 +790,14 @@ pascal OSErr HMapID(ConstStr255Param volName, name input: Points to a buffer (minimum Str31) where the user or group name is to be returned or must be nil. output: The user or group name. - + Result Codes noErr 0 No error fnfErr -43 Unrecognizable owner or group name paramErr -50 Function not supported by volume - + __________ - + Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess, FSpSetDirAccess, HMapName */ @@ -812,7 +812,7 @@ pascal OSErr HMapName(ConstStr255Param volName, /* ¶ Map a user or group name to a user or group ID. The HMapName function determines the user or group ID if you know the user or group name. - + volName input: A pointer to the name of a mounted volume or nil. vRefNum input: Volume specification. @@ -826,9 +826,9 @@ pascal OSErr HMapName(ConstStr255Param volName, noErr 0 No error fnfErr -43 Unrecognizable owner or group name paramErr -50 Function not supported by volume - + __________ - + Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess, FSpSetDirAccess, HMapID */ @@ -846,7 +846,7 @@ pascal OSErr HCopyFile(short srcVRefNum, The HCopyFile function duplicates a file and optionally to renames it. The source and destination volumes must be on the same file server. This function instructs the server to copy the file. - + srcVRefNum input: Source volume specification. srcDirID input: Source directory ID. srcName input: Source file name. @@ -856,7 +856,7 @@ pascal OSErr HCopyFile(short srcVRefNum, nil when dstDirID specifies a directory. copyName input: Points to the new file name if the file is to be renamed or nil if the file isn't to be renamed. - + Result Codes noErr 0 No error dskFulErr -34 Destination volume is full @@ -876,9 +876,9 @@ pascal OSErr HCopyFile(short srcVRefNum, not be opened with the correct access modes afpObjectTypeErr -5025 Source is a directory - + __________ - + Also see: FSpCopyFile, FileCopy, FSpFileCopy */ @@ -891,13 +891,13 @@ pascal OSErr FSpCopyFile(const FSSpec *srcSpec, The FSpCopyFile function duplicates a file and optionally to renames it. The source and destination volumes must be on the same file server. This function instructs the server to copy the file. - + srcSpec input: An FSSpec record specifying the source file. dstSpec input: An FSSpec record specifying the destination directory. copyName input: Points to the new file name if the file is to be renamed or nil if the file isn't to be renamed. - + Result Codes noErr 0 No error dskFulErr -34 Destination volume is full @@ -917,9 +917,9 @@ pascal OSErr FSpCopyFile(const FSSpec *srcSpec, not be opened with the correct access modes afpObjectTypeErr -5025 Source is a directory - + __________ - + Also see: HCopyFile, FileCopy, FSpFileCopy */ @@ -935,7 +935,7 @@ pascal OSErr HMoveRename(short vRefNum, The HMoveRename function moves a file or directory and optionally renames it. The source and destination locations must be on the same shared volume. - + vRefNum input: Volume specification. srcDirID input: Source directory ID. srcName input: The source object name. @@ -944,7 +944,7 @@ pascal OSErr HMoveRename(short vRefNum, nil when dstDirID specifies a directory. copyName input: Points to the new name if the object is to be renamed or nil if the object isn't to be renamed. - + Result Codes noErr 0 No error fnfErr -43 Source file or directory not found @@ -956,9 +956,9 @@ pascal OSErr HMoveRename(short vRefNum, offspring afpAccessDenied -5000 The user does not have the right to move the file or directory - + __________ - + Also see: FSpMoveRename, HMoveRenameCompat, FSpMoveRenameCompat */ @@ -971,13 +971,13 @@ pascal OSErr FSpMoveRename(const FSSpec *srcSpec, The FSpMoveRename function moves a file or directory and optionally renames it. The source and destination locations must be on the same shared volume. - + srcSpec input: An FSSpec record specifying the source object. dstSpec input: An FSSpec record specifying the destination directory. copyName input: Points to the new name if the object is to be renamed or nil if the object isn't to be renamed. - + Result Codes noErr 0 No error fnfErr -43 Source file or directory not found @@ -989,9 +989,9 @@ pascal OSErr FSpMoveRename(const FSSpec *srcSpec, offspring afpAccessDenied -5000 The user does not have the right to move the file or directory - + __________ - + Also see: HMoveRename, HMoveRenameCompat, FSpMoveRenameCompat */ @@ -1003,13 +1003,13 @@ pascal OSErr GetVolMountInfoSize(ConstStr255Param volName, /* ¶ Get the size of a volume mounting information record. The GetVolMountInfoSize function determines the how much space the program needs to allocate for a volume mounting information record. - + volName input: A pointer to the name of a mounted volume or nil. vRefNum input: Volume specification. size output: The space needed (in bytes) of the volume mounting information record. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -1018,7 +1018,7 @@ pascal OSErr GetVolMountInfoSize(ConstStr255Param volName, system claimed this call. __________ - + Also see: GetVolMountInfo, VolumeMount BuildAFPVolMountInfo, RetrieveAFPVolMountInfo */ @@ -1032,23 +1032,23 @@ pascal OSErr GetVolMountInfo(ConstStr255Param volName, The GetVolMountInfo function retrieves a volume mounting information record containing all the information needed to mount the volume, except for passwords. - + volName input: A pointer to the name of a mounted volume or nil. vRefNum input: Volume specification. volMountInfo output: Points to a volume mounting information record where the mounting information is to be returned. - + Result Codes - noErr 0 No error - nsvErr -35 Volume not found - paramErr -50 Parameter error + noErr 0 No error + nsvErr -35 Volume not found + paramErr -50 Parameter error extFSErr -58 External file system error - no file system claimed this call. __________ - + Also see: GetVolMountInfoSize, VolumeMount, BuildAFPVolMountInfo, RetrieveAFPVolMountInfo */ @@ -1060,10 +1060,10 @@ pascal OSErr VolumeMount(const void *volMountInfo, /* ¶ Mount a volume using a volume mounting information record. The VolumeMount function mounts a volume using a volume mounting information record. - + volMountInfo input: Points to a volume mounting information record. vRefNum output: A volume reference number. - + Result Codes noErr 0 No error notOpenErr -28 AppleTalk is not open @@ -1091,7 +1091,7 @@ pascal OSErr VolumeMount(const void *volMountInfo, on the same machine __________ - + Also see: GetVolMountInfoSize, GetVolMountInfo, BuildAFPVolMountInfo, RetrieveAFPVolMountInfo */ @@ -1109,21 +1109,21 @@ pascal OSErr Share(short vRefNum, dirID input: Directory ID. name input: Pointer to directory name, or nil if dirID specifies the directory. - + Result Codes - noErr 0 No error - tmfoErr -42 Too many share points - fnfErr -43 File not found - dupFNErr -48 Already a share point with this name - paramErr -50 Function not supported by volume - dirNFErrdirNFErr -120 Directory not found - afpAccessDenied -5000 This directory cannot be shared - afpObjectTypeErr -5025 Object was a file, not a directory - afpContainsSharedErr -5033 The directory contains a share point - afpInsideSharedErr -5043 The directory is inside a shared directory + noErr 0 No error + tmfoErr -42 Too many share points + fnfErr -43 File not found + dupFNErr -48 Already a share point with this name + paramErr -50 Function not supported by volume + dirNFErrdirNFErr -120 Directory not found + afpAccessDenied -5000 This directory cannot be shared + afpObjectTypeErr -5025 Object was a file, not a directory + afpContainsSharedErr -5033 The directory contains a share point + afpInsideSharedErr -5043 The directory is inside a shared directory __________ - + Also see: FSpShare, Unshare, FSpUnshare */ @@ -1135,21 +1135,21 @@ pascal OSErr FSpShare(const FSSpec *spec); share point. spec input: An FSSpec record specifying the share point. - + Result Codes - noErr 0 No error - tmfoErr -42 Too many share points - fnfErr -43 File not found - dupFNErr -48 Already a share point with this name - paramErr -50 Function not supported by volume - dirNFErrdirNFErr -120 Directory not found - afpAccessDenied -5000 This directory cannot be shared - afpObjectTypeErr -5025 Object was a file, not a directory - afpContainsSharedErr -5033 The directory contains a share point - afpInsideSharedErr -5043 The directory is inside a shared directory + noErr 0 No error + tmfoErr -42 Too many share points + fnfErr -43 File not found + dupFNErr -48 Already a share point with this name + paramErr -50 Function not supported by volume + dirNFErrdirNFErr -120 Directory not found + afpAccessDenied -5000 This directory cannot be shared + afpObjectTypeErr -5025 Object was a file, not a directory + afpContainsSharedErr -5033 The directory contains a share point + afpInsideSharedErr -5043 The directory is inside a shared directory __________ - + Also see: Share, Unshare, FSpUnshare */ @@ -1165,17 +1165,17 @@ pascal OSErr Unshare(short vRefNum, dirID input: Directory ID. name input: Pointer to directory name, or nil if dirID specifies the directory. - + Result Codes - noErr 0 No error - fnfErr -43 File not found - paramErr -50 Function not supported by volume - dirNFErrdirNFErr -120 Directory not found + noErr 0 No error + fnfErr -43 File not found + paramErr -50 Function not supported by volume + dirNFErrdirNFErr -120 Directory not found afpObjectTypeErr -5025 Object was a file, not a directory; or, - this directory is not a share point + this directory is not a share point __________ - + Also see: Share, FSpShare, FSpUnshare */ @@ -1186,17 +1186,17 @@ pascal OSErr FSpUnshare(const FSSpec *spec); The FSpUnshare function removes a share point. spec input: An FSSpec record specifying the share point. - + Result Codes - noErr 0 No error - fnfErr -43 File not found - paramErr -50 Function not supported by volume - dirNFErrdirNFErr -120 Directory not found + noErr 0 No error + fnfErr -43 File not found + paramErr -50 Function not supported by volume + dirNFErrdirNFErr -120 Directory not found afpObjectTypeErr -5025 Object was a file, not a directory; or, - this directory is not a share point + this directory is not a share point __________ - + Also see: Share, FSpShare, Unshare */ @@ -1218,15 +1218,15 @@ pascal OSErr GetUGEntry(short objType, group whose alphabetically next in the list of entries is returned. output: The user or group ID. - + Result Codes - noErr 0 No error - fnfErr -43 No more users or groups + noErr 0 No error + fnfErr -43 No more users or groups paramErr -50 Function not supported; or, ioObjID is - negative + negative __________ - + Also see: GetUGEntries */ diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFilesExtras.c b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFilesExtras.c index c4f9668..2ebe706 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFilesExtras.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFilesExtras.c @@ -90,7 +90,7 @@ typedef DeleteEnumGlobals *DeleteEnumGlobalsPtr; #if __WANTPASCALELIMINATION #undef pascal #endif // __WANTPASCALELIMINATION - + /* This is exactly like the simple mixed mode glue in InterfaceLib in Mac OS 8.5 and 8.6 */ static pascal OSErr PBXGetVolInfoSyncGlue(XVolumeParamPtr paramBlock) { @@ -103,9 +103,9 @@ typedef DeleteEnumGlobals *DeleteEnumGlobalsPtr; | REGISTER_ROUTINE_PARAMETER(2, kRegisterD1, SIZE_CODE(sizeof(long))) /* trap word */ | REGISTER_ROUTINE_PARAMETER(3, kRegisterA0, SIZE_CODE(sizeof(XVolumeParamPtr))) }; - + static UniversalProcPtr fsDispatchTrapAddress = NULL; - + /* Is this the first time we've been called? */ if ( fsDispatchTrapAddress == NULL ) { @@ -118,7 +118,7 @@ typedef DeleteEnumGlobals *DeleteEnumGlobalsPtr; _FSDispatch, paramBlock) ); } - + /* ** PBXGetVolInfoSync was added to the File Manager in System software 7.5.2. ** However, PBXGetVolInfoSync wasn't added to InterfaceLib until Mac OS 8.5. @@ -129,11 +129,11 @@ typedef DeleteEnumGlobals *DeleteEnumGlobalsPtr; static pascal OSErr CallPBXGetVolInfoSync(XVolumeParamPtr paramBlock) { typedef pascal OSErr (*PBXGetVolInfoProcPtr) (XVolumeParamPtr paramBlock); - + OSErr result; CFragConnectionID connID; static PBXGetVolInfoProcPtr PBXGetVolInfoSyncPtr = NULL; - + //* Is this the first time we've been called? */ if ( PBXGetVolInfoSyncPtr == NULL ) { @@ -154,7 +154,7 @@ typedef DeleteEnumGlobals *DeleteEnumGlobalsPtr; } #if __WANTPASCALELIMINATION - #define pascal + #define pascal #endif // __WANTPASCALELIMINATION #endif // TARGET_API_MAC_CARBON || !TARGET_RT_MAC_CFM @@ -166,7 +166,7 @@ pascal void TruncPString(StringPtr destination, short maxLength) { short charType; - + if ( source != NULL && destination != NULL ) /* don't do anything stupid */ { if ( source[0] > maxLength ) @@ -178,7 +178,7 @@ pascal void TruncPString(StringPtr destination, // Note: CharacterByteType's textOffset parameter is zero-based from the textPtr parameter charType = CharacterByteType((Ptr)&source[1], maxLength - 1, smSystemScript); if ( (charType == smSingleByte) || (charType == smLastByte) ) - break; /* source[maxLength] is now a valid last character */ + break; /* source[maxLength] is now a valid last character */ --maxLength; } } @@ -210,19 +210,19 @@ pascal Ptr GetTempBuffer(long buffReqSize, kSlopMemory = 0x00008000 /* 32K - Amount of free memory to leave when allocating buffers */ }; Ptr tempPtr; - + /* Make request a multiple of 1024 bytes */ buffReqSize = buffReqSize & 0xfffffc00; - + if ( buffReqSize < 0x00000400 ) { /* Request was smaller than 1024 bytes - make it 1024 */ buffReqSize = 0x00000400; } - + /* Attempt to allocate the memory */ tempPtr = NewPtr(buffReqSize); - + /* If request failed, go to backup plan */ if ( (tempPtr == NULL) && (buffReqSize > 0x00000400) ) { @@ -231,22 +231,22 @@ pascal Ptr GetTempBuffer(long buffReqSize, ** leaving some slop for the toolbox if possible */ long freeMemory = (FreeMem() - kSlopMemory) & 0xfffffc00; - + buffReqSize = MaxBlock() & 0xfffffc00; - + if ( buffReqSize > freeMemory ) { buffReqSize = freeMemory; } - + if ( buffReqSize == 0 ) { buffReqSize = 0x00000400; } - + tempPtr = NewPtr(buffReqSize); } - + /* Return bytes allocated */ if ( tempPtr != NULL ) { @@ -256,7 +256,7 @@ pascal Ptr GetTempBuffer(long buffReqSize, { *buffActSize = 0; } - + return ( tempPtr ); } @@ -279,8 +279,8 @@ pascal OSErr GetVolumeInfoNoName(ConstStr255Param pathname, { Str255 tempPathname; OSErr error; - - /* Make sure pb parameter is not NULL */ + + /* Make sure pb parameter is not NULL */ if ( pb != NULL ) { pb->volumeParam.ioVRefNum = vRefNum; @@ -321,8 +321,8 @@ pascal OSErr XGetVolumeInfoNoName(ConstStr255Param pathname, { Str255 tempPathname; OSErr error; - - /* Make sure pb parameter is not NULL */ + + /* Make sure pb parameter is not NULL */ if ( pb != NULL ) { pb->ioVRefNum = vRefNum; @@ -338,11 +338,11 @@ pascal OSErr XGetVolumeInfoNoName(ConstStr255Param pathname, pb->ioNamePtr = (StringPtr)tempPathname; /* use the copy so original isn't trashed */ pb->ioVolIndex = -1; /* use ioNamePtr/ioVRefNum combination */ } - + { #if !TARGET_API_MAC_CARBON long response; - + /* Is PBXGetVolInfo available? */ if ( ( Gestalt(gestaltFSAttr, &response) != noErr ) || ((response & (1L << gestaltFSSupports2TBVols)) == 0) ) { @@ -380,7 +380,7 @@ pascal OSErr GetCatInfoNoName(short vRefNum, { Str31 tempName; OSErr error; - + /* Protection against File Sharing problem */ if ( (name == NULL) || (name[0] == 0) ) { @@ -428,7 +428,7 @@ pascal OSErr HGetVInfo(short volReference, OSErr result; UInt64 freeBytes64; UInt64 totalBytes64; - + // get the best values possible from XGetVInfo result = XGetVInfo(volReference, volName, vRefNum, &freeBytes64, &totalBytes64); if ( result == noErr ) @@ -443,7 +443,7 @@ pascal OSErr HGetVInfo(short volReference, { *freeBytes = U32SetU(freeBytes64); } - + if ( UInt64ToUnsignedWide(totalBytes64).hi != 0 ) { // pin to maximum 512-byte block aligned value @@ -454,7 +454,7 @@ pascal OSErr HGetVInfo(short volReference, *totalBytes = U32SetU(totalBytes64); } } - + return ( result ); } @@ -468,25 +468,25 @@ pascal OSErr XGetVInfo(short volReference, { OSErr result; XVolumeParam pb; - + #if !TARGET_API_MAC_CARBON - + long response; - + #endif // !TARGET_API_MAC_CARBON - + pb.ioVRefNum = volReference; pb.ioNamePtr = volName; pb.ioXVersion = 0; /* this XVolumeParam version (0) */ pb.ioVolIndex = 0; /* use ioVRefNum only, return volume name */ - + #if !TARGET_API_MAC_CARBON /* See if large volume support is available */ if ( ( Gestalt(gestaltFSAttr, &response) == noErr ) && ((response & (1L << gestaltFSSupports2TBVols)) != 0) ) - + #endif // !TARGET_API_MAC_CARBON - + { /* Large volume support is available */ result = CallPBXGetVolInfoSync(&pb); @@ -495,15 +495,15 @@ pascal OSErr XGetVInfo(short volReference, /* The volume name was returned in volName (if not NULL) and */ /* we have the volume's vRefNum and allocation block size */ *vRefNum = pb.ioVRefNum; - + /* return the freeBytes and totalBytes */ *totalBytes = pb.ioVTotalBytes; *freeBytes = pb.ioVFreeBytes; } } - + #if !TARGET_API_MAC_CARBON - + else { /* No large volume support */ @@ -512,11 +512,11 @@ pascal OSErr XGetVInfo(short volReference, if ( result == noErr ) { VCB *theVCB; - + /* The volume name was returned in volName (if not NULL) and */ /* we have the volume's vRefNum */ *vRefNum = pb.ioVRefNum; - + /* System 7.5 (and beyond) pins the number of allocation blocks and */ /* the number of free allocation blocks returned by PBHGetVInfo to */ /* a value so that when multiplied by the allocation block size, */ @@ -527,7 +527,7 @@ pascal OSErr XGetVInfo(short volReference, /* in the volume's VCB so we'll get those values from the VCB. */ /* Note: Carbon doesn't support the VCB queue, so this code cannot be */ /* used (and is conditionalized out) by Carbon applications. */ - + /* Find the volume's VCB */ theVCB = (VCB *)(GetVCBQHdr()->qHead); while ( theVCB != NULL ) @@ -536,10 +536,10 @@ pascal OSErr XGetVInfo(short volReference, { break; } - + theVCB = (VCB *)(theVCB->qLink); /* next VCB */ } - + if ( theVCB != NULL ) { /* Found a VCB we can use. Get the un-pinned number of allocation blocks */ @@ -554,12 +554,12 @@ pascal OSErr XGetVInfo(short volReference, *freeBytes = U64Multiply(U64SetU((unsigned short)pb.ioVFrBlk), U64SetU((unsigned long)pb.ioVAlBlkSiz)); *totalBytes = U64Multiply(U64SetU((unsigned short)pb.ioVNmAlBlks), U64SetU((unsigned long)pb.ioVAlBlkSiz)); } - + } } - + #endif // !TARGET_API_MAC_CARBON - + return ( result ); } @@ -583,7 +583,7 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, error = vLckdErr; /* volume locked by software */ } } - + return ( error ); } @@ -591,7 +591,7 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, // // The following routines call Mac OS routines that are not supported by // Carbon: -// +// // GetDriverName // FindDrive // GetDiskBlocks @@ -607,7 +607,7 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, OSErr result; DCtlHandle theDctl; DRVRHeaderPtr dHeaderPtr; - + theDctl = GetDCtlEntry(driverRefNum); if ( theDctl != NULL ) { @@ -629,7 +629,7 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, driverName[0] = 0; result = badUnitErr; /* bad reference number */ } - + return ( result ); } @@ -642,9 +642,9 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, OSErr result; HParamBlockRec hPB; short driveNumber; - + *driveQElementPtr = NULL; - + /* First, use GetVolumeInfoNoName to determine the volume */ result = GetVolumeInfoNoName(pathname, vRefNum, &hPB); if ( result == noErr ) @@ -679,23 +679,23 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, driveNumber = (short)-hPB.volumeParam.ioVDRefNum; } } - + /* Get pointer to first element in drive queue */ *driveQElementPtr = (DrvQElPtr)(GetDrvQHdr()->qHead); - + /* Search for a matching drive number */ while ( (*driveQElementPtr != NULL) && ((*driveQElementPtr)->dQDrive != driveNumber) ) { *driveQElementPtr = (DrvQElPtr)(*driveQElementPtr)->qLink; } - + if ( *driveQElementPtr == NULL ) { /* This should never happen since every volume must have a drive, but... */ result = nsDrvErr; } } - + return ( result ); } @@ -710,24 +710,24 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, { /* return format list status code */ kFmtLstCode = 6, - + /* reference number of .SONY driver */ kSonyRefNum = 0xfffb, - + /* values returned by DriveStatus in DrvSts.twoSideFmt */ kSingleSided = 0, kDoubleSided = -1, kSingleSidedSize = 800, /* 400K */ kDoubleSidedSize = 1600, /* 800K */ - + /* values in DrvQEl.qType */ kWordDrvSiz = 0, kLongDrvSiz = 1, - + /* more than enough formatListRecords */ kMaxFormatListRecs = 16 }; - + DrvQElPtr driveQElementPtr; unsigned long blocks; ParamBlockRec pb; @@ -737,15 +737,15 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, OSErr result; blocks = 0; - + /* Find the drive queue element for this volume */ result = FindDrive(pathname, vRefNum, &driveQElementPtr); - - /* + + /* ** Make sure this is a real driver (dQRefNum < 0). ** AOCE's Mail Enclosures volume uses 0 for dQRefNum which will cause ** problems if you try to use it as a driver refNum. - */ + */ if ( (result == noErr) && (driveQElementPtr->dQRefNum >= 0) ) { result = paramErr; @@ -754,19 +754,19 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, { /* Attempt to get the drive's format list. */ /* (see the Technical Note "What Your Sony Drives For You") */ - + pb.cntrlParam.ioVRefNum = driveQElementPtr->dQDrive; pb.cntrlParam.ioCRefNum = driveQElementPtr->dQRefNum; pb.cntrlParam.csCode = kFmtLstCode; pb.cntrlParam.csParam[0] = kMaxFormatListRecs; *(long *)&pb.cntrlParam.csParam[1] = (long)&formatListRecords[0]; - + result = PBStatusSync(&pb); - + if ( result == noErr ) { /* The drive supports ReturnFormatList status call. */ - + /* Get the current disk's size. */ for( formatListRecIndex = 0; formatListRecIndex < pb.cntrlParam.csParam[0]; @@ -787,7 +787,7 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, else if ( driveQElementPtr->dQRefNum == (short)kSonyRefNum ) { /* The drive is a non-SuperDrive floppy which only supports 400K and 800K disks */ - + result = DriveStatus(driveQElementPtr->dQDrive, &status); if ( result == noErr ) { @@ -810,7 +810,7 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, { /* The drive is not a floppy and it doesn't support ReturnFormatList */ /* so use the dQDrvSz field(s) */ - + result = noErr; /* reset result */ switch ( driveQElementPtr->qType ) { @@ -828,12 +828,12 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, } } } - + if ( result == noErr ) { *numBlocks = blocks; } - + return ( result ); } @@ -858,7 +858,7 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, /* the volume is online and not ejected */ *volumeOnline = true; *volumeEjected = false; - + /* Get the drive number */ driveNumber = pb.volumeParam.ioVDrvInfo; } @@ -870,7 +870,7 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, /* Is it ejected? */ *volumeEjected = pb.volumeParam.ioVDRefNum > 0; - + if ( *volumeEjected ) { /* If ejected, the drive number is ioVDRefNum */ @@ -882,17 +882,17 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, driveNumber = (short)-pb.volumeParam.ioVDRefNum; } } - + { DrvQElPtr drvQElem; - + /* Find the drive queue element by searching the drive queue */ drvQElem = (DrvQElPtr)(GetDrvQHdr()->qHead); while ( (drvQElem != NULL) && (drvQElem->dQDrive != driveNumber) ) { drvQElem = (DrvQElPtr)drvQElem->qLink; } - + if ( drvQElem != NULL ) { /* @@ -903,25 +903,25 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, */ { Ptr flagBytePtr; - + /* point to byte 1 of the flag bytes */ flagBytePtr = (Ptr)drvQElem; flagBytePtr -= 3; - + /* ** The drive is ejectable if flag byte 1 does not contain ** 0x08 (nonejectable) or 0x48 (nonejectable, but wants eject call). */ - + *driveEjectable = (*flagBytePtr != 0x08) && (*flagBytePtr != 0x48); - + /* ** The driver wants an eject call if flag byte 1 does not contain ** 0x08 (nonejectable). This may seem like a minor point, but some ** disk drivers use the Eject request to flush their caches to disk ** and you wouldn't want to skip that step after unmounting a volume. */ - + *driverWantsEject = (*flagBytePtr != 0x08); } } @@ -933,7 +933,7 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, } } } - + return ( error ); } @@ -955,7 +955,7 @@ pascal OSErr GetVolFileSystemID(ConstStr255Param pathname, { *fileSystemID = pb.volumeParam.ioVFSID; } - + return ( error ); } @@ -977,28 +977,28 @@ pascal OSErr UnmountAndEject(ConstStr255Param pathname, error = GetVolumeInfoNoName(pathname, vRefNum, &pb); if ( error == noErr ) { - + #if !TARGET_API_MAC_CARBON short driveNum; Boolean ejected, wantsEject; DrvQElPtr drvQElem; - + if ( pb.volumeParam.ioVDrvInfo != 0 ) { /* the volume is online and not ejected */ ejected = false; - + /* Get the drive number */ driveNum = pb.volumeParam.ioVDrvInfo; } else { /* the volume is ejected or offline */ - + /* Is it ejected? */ ejected = pb.volumeParam.ioVDRefNum > 0; - + if ( ejected ) { /* If ejected, the drive number is ioVDRefNum */ @@ -1010,14 +1010,14 @@ pascal OSErr UnmountAndEject(ConstStr255Param pathname, driveNum = (short)-pb.volumeParam.ioVDRefNum; } } - + /* find the drive queue element */ drvQElem = (DrvQElPtr)(GetDrvQHdr()->qHead); while ( (drvQElem != NULL) && (drvQElem->dQDrive != driveNum) ) { drvQElem = (DrvQElPtr)drvQElem->qLink; } - + if ( drvQElem != NULL ) { /* does the drive want an eject call */ @@ -1028,7 +1028,7 @@ pascal OSErr UnmountAndEject(ConstStr255Param pathname, /* didn't find the drive!! */ wantsEject = false; } - + #endif // !TARGET_API_MAC_CARBON /* unmount the volume */ @@ -1047,11 +1047,11 @@ pascal OSErr UnmountAndEject(ConstStr255Param pathname, error = PBEject((ParmBlkPtr)&pb); } } - + #endif // !TARGET_API_MAC_CARBON } - + return ( error ); } @@ -1087,7 +1087,7 @@ pascal OSErr OnLine(FSSpecPtr volumes, { error = paramErr; } - + return ( error ); } @@ -1099,7 +1099,7 @@ pascal OSErr SetDefault(short newVRefNum, long *oldDirID) { OSErr error; - + /* Get the current default volume/directory. */ error = HGetVol(NULL, oldVRefNum, oldDirID); if ( error == noErr ) @@ -1107,7 +1107,7 @@ pascal OSErr SetDefault(short newVRefNum, /* Set the new default volume/directory */ error = HSetVol(NULL, newVRefNum, newDirID); } - + return ( error ); } @@ -1117,13 +1117,13 @@ pascal OSErr RestoreDefault(short oldVRefNum, long oldDirID) { OSErr error; - + #if !TARGET_API_MAC_CARBON short defaultVRefNum; long defaultDirID; long defaultProcID; - + /* Determine if the default volume was a wdRefNum. */ error = GetWDInfo(oldVRefNum, &defaultVRefNum, &defaultDirID, &defaultProcID); if ( error == noErr ) @@ -1136,7 +1136,7 @@ pascal OSErr RestoreDefault(short oldVRefNum, } else { - + #endif // !TARGET_API_MAC_CARBON /* oldVRefNum was a real vRefNum - use HSetVol */ @@ -1147,7 +1147,7 @@ pascal OSErr RestoreDefault(short oldVRefNum, } } #endif // !TARGET_API_MAC_CARBON - + return ( error ); } @@ -1160,7 +1160,7 @@ pascal OSErr GetDInfo(short vRefNum, { CInfoPBRec pb; OSErr error; - + error = GetCatInfoNoName(vRefNum, dirID, name, &pb); if ( error == noErr ) { @@ -1175,7 +1175,7 @@ pascal OSErr GetDInfo(short vRefNum, error = dirNFErr; } } - + return ( error ); } @@ -1235,7 +1235,7 @@ pascal OSErr SetDInfo(short vRefNum, error = dirNFErr; } } - + return ( error ); } @@ -1271,7 +1271,7 @@ pascal OSErr GetDirectoryID(short vRefNum, *theDirID = pb.hFileInfo.ioFlParID; } } - + return ( error ); } @@ -1306,7 +1306,7 @@ pascal OSErr GetDirName(short vRefNum, { error = paramErr; } - + return ( error ); } @@ -1319,7 +1319,7 @@ pascal OSErr GetIOACUser(short vRefNum, { CInfoPBRec pb; OSErr error; - + /* Clear ioACUser before calling PBGetCatInfo since some file systems ** don't bother to set or clear this field. If ioACUser isn't set by the ** file system, then you'll get the zero value back (full access) which @@ -1339,7 +1339,7 @@ pascal OSErr GetIOACUser(short vRefNum, *ioACUser = pb.dirInfo.ioACUser; } } - + return ( error ); } @@ -1362,7 +1362,7 @@ pascal OSErr GetParentID(short vRefNum, Str31 tempName; OSErr error; short realVRefNum; - + /* Protection against File Sharing problem */ if ( (name == NULL) || (name[0] == 0) ) { @@ -1395,9 +1395,9 @@ pascal OSErr GetParentID(short vRefNum, if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* Its a directory */ - + /* is there a pathname? */ - if ( pb.hFileInfo.ioNamePtr == name ) + if ( pb.hFileInfo.ioNamePtr == name ) { /* could it contain multiple separators? */ if ( name[0] >= 2 ) @@ -1406,7 +1406,7 @@ pascal OSErr GetParentID(short vRefNum, if ( (name[name[0]] == ':') && (name[name[0] - 1] == ':') ) { /* OK, then do the extra stuff to get the correct parID */ - + /* Get the real vRefNum (this should not fail) */ error = DetermineVRefNum(name, vRefNum, &realVRefNum); if ( error == noErr ) @@ -1425,7 +1425,7 @@ pascal OSErr GetParentID(short vRefNum, } } } - + if ( error == noErr ) { /* if no errors, then pb.hFileInfo.ioFlParID (pb.dirInfo.ioDrParID) */ @@ -1433,7 +1433,7 @@ pascal OSErr GetParentID(short vRefNum, *parID = pb.hFileInfo.ioFlParID; } } - + return ( error ); } @@ -1454,7 +1454,7 @@ pascal OSErr GetFilenameFromPathname(ConstStr255Param pathname, { /* get string length */ index = pathname[0]; - + /* check for empty string */ if ( index != 0 ) { @@ -1476,7 +1476,7 @@ pascal OSErr GetFilenameFromPathname(ConstStr255Param pathname, { --index; } - + /* if we parsed to the beginning of the pathname and the pathname ended */ /* with a colon, then pathname is a full pathname to a volume, not a file */ if ( (index != 0) || (pathname[pathname[0]] != ':') ) @@ -1509,7 +1509,7 @@ pascal OSErr GetFilenameFromPathname(ConstStr255Param pathname, /* NULL pathname isn't a file */ error = notAFileErr; } - + return ( error ); } @@ -1526,12 +1526,12 @@ pascal OSErr GetObjectLocation(short vRefNum, OSErr error; CInfoPBRec pb; Str255 tempPathname; - + /* clear results */ *realVRefNum = 0; *realParID = 0; realName[0] = 0; - + /* ** Get the real vRefNum */ @@ -1542,7 +1542,7 @@ pascal OSErr GetObjectLocation(short vRefNum, ** Determine if the object already exists and if so, ** get the real parent directory ID if it's a file */ - + /* Protection against File Sharing problem */ if ( (pathname == NULL) || (pathname[0] == 0) ) { @@ -1563,7 +1563,7 @@ pascal OSErr GetObjectLocation(short vRefNum, /* ** The file system object is present and we have the file's real parID */ - + /* Is it a directory or a file? */ *isDirectory = (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0; if ( *isDirectory ) @@ -1571,13 +1571,13 @@ pascal OSErr GetObjectLocation(short vRefNum, /* ** It's a directory, get its name and parent dirID, and then we're done */ - + pb.dirInfo.ioNamePtr = realName; pb.dirInfo.ioVRefNum = *realVRefNum; /* pb.dirInfo.ioDrDirID already contains the dirID of the directory object */ pb.dirInfo.ioFDirIndex = -1; /* get information about ioDirID */ error = PBGetCatInfoSync(&pb); - + /* get the parent ID here, because the file system can return the */ /* wrong parent ID from the last call. */ *realParID = pb.dirInfo.ioDrParID; @@ -1588,7 +1588,7 @@ pascal OSErr GetObjectLocation(short vRefNum, ** It's a file - use the parent directory ID from the last call ** to GetCatInfoparse, get the file name, and then we're done */ - *realParID = pb.hFileInfo.ioFlParID; + *realParID = pb.hFileInfo.ioFlParID; error = GetFilenameFromPathname(pathname, realName); } } @@ -1597,12 +1597,12 @@ pascal OSErr GetObjectLocation(short vRefNum, /* ** The file system object is not present - see if its parent is present */ - + /* ** Parse to get the object name from end of pathname */ error = GetFilenameFromPathname(pathname, realName); - + /* if we can't get the object name from the end, we can't continue */ if ( error == noErr ) { @@ -1616,10 +1616,10 @@ pascal OSErr GetObjectLocation(short vRefNum, ** if pathname is ':file' tempPathname becomes ':' ** if pathname is 'file or file:' tempPathname becomes '' */ - + /* get a copy of the pathname */ BlockMoveData(pathname, tempPathname, pathname[0] + 1); - + /* remove the object name */ tempPathname[0] -= realName[0]; /* and the trailing colon (if any) */ @@ -1627,9 +1627,9 @@ pascal OSErr GetObjectLocation(short vRefNum, { --tempPathname[0]; } - + /* OK, now get the parent's directory ID */ - + /* Protection against File Sharing problem */ pb.hFileInfo.ioNamePtr = (StringPtr)tempPathname; if ( tempPathname[0] != 0 ) @@ -1647,7 +1647,7 @@ pascal OSErr GetObjectLocation(short vRefNum, *isDirectory = false; /* we don't know what the object is really going to be */ } - + if ( error != noErr ) { error = dirNFErr; /* couldn't find parent directory */ @@ -1658,7 +1658,7 @@ pascal OSErr GetObjectLocation(short vRefNum, } } } - + return ( error ); } @@ -1679,7 +1679,7 @@ pascal OSErr GetDirItems(short vRefNum, long theDirID; Boolean isDirectory; FSSpec *endItemsArray; - + if ( *itemIndex > 0 ) { /* NOTE: If I could be sure that the caller passed a real vRefNum and real directory */ @@ -1689,7 +1689,7 @@ pascal OSErr GetDirItems(short vRefNum, /* file system keeps for indexed calls. I can't be sure, so for maximum throughput, */ /* pass a big array of FSSpecs so you can get the directory's contents with few calls */ /* to this routine. */ - + /* get the real volume reference number */ error = DetermineVRefNum(name, vRefNum, &pb.hFileInfo.ioVRefNum); if ( error == noErr ) @@ -1713,7 +1713,7 @@ pascal OSErr GetDirItems(short vRefNum, items->parID = pb.hFileInfo.ioFlParID; /* return item's parID */ items->vRefNum = pb.hFileInfo.ioVRefNum; /* return item's vRefNum */ ++*itemIndex; /* prepare to get next item in directory */ - + if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { if ( getDirectories ) @@ -1746,7 +1746,7 @@ pascal OSErr GetDirItems(short vRefNum, /* bad itemIndex */ error = paramErr; } - + return ( error ); } @@ -1756,7 +1756,7 @@ static void DeleteLevel(long dirToDelete, DeleteEnumGlobalsPtr theGlobals) { long savedDir; - + do { /* prepare to delete directory */ @@ -1788,7 +1788,7 @@ static void DeleteLevel(long dirToDelete, } } } while ( theGlobals->error == noErr ); - + if ( theGlobals->error == fnfErr ) { theGlobals->error = noErr; @@ -1817,7 +1817,7 @@ pascal OSErr DeleteDirectoryContents(short vRefNum, { /* Set up the globals we need to access from the recursive routine. */ theGlobals.myPB.ciPB.dirInfo.ioVRefNum = vRefNum; - + /* Here we go into recursion land... */ DeleteLevel(dirID, &theGlobals); error = theGlobals.error; @@ -1828,7 +1828,7 @@ pascal OSErr DeleteDirectoryContents(short vRefNum, error = dirNFErr; } } - + return ( error ); } @@ -1839,7 +1839,7 @@ pascal OSErr DeleteDirectory(short vRefNum, ConstStr255Param name) { OSErr error; - + /* Make sure a directory was specified and then delete its contents */ error = DeleteDirectoryContents(vRefNum, dirID, name); if ( error == noErr ) @@ -1851,7 +1851,7 @@ pascal OSErr DeleteDirectory(short vRefNum, error = HDelete(vRefNum, dirID, name); /* and try again */ } } - + return ( error ); } @@ -1863,7 +1863,7 @@ pascal OSErr CheckObjectLock(short vRefNum, { CInfoPBRec pb; OSErr error; - + error = GetCatInfoNoName(vRefNum, dirID, name, &pb); if ( error == noErr ) { @@ -1873,7 +1873,7 @@ pascal OSErr CheckObjectLock(short vRefNum, error = fLckdErr; } } - + return ( error ); } @@ -1894,7 +1894,7 @@ pascal OSErr GetFileSize(short vRefNum, { HParamBlockRec pb; OSErr error; - + pb.fileParam.ioNamePtr = (StringPtr)fileName; pb.fileParam.ioVRefNum = vRefNum; pb.fileParam.ioFVersNum = 0; @@ -1906,7 +1906,7 @@ pascal OSErr GetFileSize(short vRefNum, *dataSize = pb.fileParam.ioFlLgLen; *rsrcSize = pb.fileParam.ioFlRLgLen; } - + return ( error ); } @@ -1962,7 +1962,7 @@ pascal OSErr BumpDate(short vRefNum, } error = PBSetCatInfoSync(&pb); } - + return ( error ); } @@ -2002,13 +2002,13 @@ pascal OSErr ChangeCreatorType(short vRefNum, { pb.hFileInfo.ioFlFndrInfo.fdCreator = creator; } - + /* If fileType not 0x00000000, change fileType */ if ( fileType != (OSType)0x00000000 ) { pb.hFileInfo.ioFlFndrInfo.fdType = fileType; } - + pb.hFileInfo.ioDirID = dirID; error = PBSetCatInfoSync(&pb); /* now, save the new information back to disk */ @@ -2030,7 +2030,7 @@ pascal OSErr ChangeCreatorType(short vRefNum, error = notAFileErr; } } - + return ( error ); } @@ -2075,7 +2075,7 @@ pascal OSErr ChangeFDFlags(short vRefNum, if ( error == noErr ) { parID = pb.hFileInfo.ioFlParID; /* save parent dirID for BumpDate call */ - + /* set or clear the appropriate bits in the Finder flags */ if ( setBits ) { @@ -2087,7 +2087,7 @@ pascal OSErr ChangeFDFlags(short vRefNum, /* AND out the bits */ pb.hFileInfo.ioFlFndrInfo.fdFlags &= ~flagBits; } - + if ( pb.dirInfo.ioNamePtr == tempName ) { pb.hFileInfo.ioDirID = pb.hFileInfo.ioFlParID; @@ -2096,7 +2096,7 @@ pascal OSErr ChangeFDFlags(short vRefNum, { pb.hFileInfo.ioDirID = dirID; } - + error = PBSetCatInfoSync(&pb); /* now, save the new information back to disk */ if ( (error == noErr) && (parID != fsRtParID) ) /* can't bump fsRtParID */ @@ -2111,7 +2111,7 @@ pascal OSErr ChangeFDFlags(short vRefNum, } } } - + return ( error ); } @@ -2390,12 +2390,12 @@ pascal OSErr HOpenAware(short vRefNum, else if ( (error == noErr) || (error == paramErr) ) /* paramErr is OK, it just means this volume doesn't support GetVolParms */ { /* OpenDeny isn't supported, so try File Manager Open functions */ - + /* If request includes write permission, then see if the volume is */ /* locked by hardware or software. The HFS file system doesn't check */ /* for this when a file is opened - you only find out later when you */ /* try to write and the write fails with a wPrErr or a vLckdErr. */ - + if ( (denyModes & dmWr) != 0 ) { error = CheckVolLock(fileName, vRefNum); @@ -2404,7 +2404,7 @@ pascal OSErr HOpenAware(short vRefNum, { error = noErr; } - + if ( error == noErr ) { /* Set File Manager permissions to closest thing possible */ @@ -2425,7 +2425,7 @@ pascal OSErr HOpenAware(short vRefNum, *refNum = pb.ioParam.ioRefNum; } } - + return ( error ); } @@ -2474,12 +2474,12 @@ pascal OSErr HOpenRFAware(short vRefNum, else if ( (error == noErr) || (error == paramErr) ) /* paramErr is OK, it just means this volume doesn't support GetVolParms */ { /* OpenRFDeny isn't supported, so try File Manager OpenRF function */ - + /* If request includes write permission, then see if the volume is */ /* locked by hardware or software. The HFS file system doesn't check */ /* for this when a file is opened - you only find out later when you */ /* try to write and the write fails with a wPrErr or a vLckdErr. */ - + if ( (denyModes & dmWr) != 0 ) { error = CheckVolLock(fileName, vRefNum); @@ -2488,7 +2488,7 @@ pascal OSErr HOpenRFAware(short vRefNum, { error = noErr; } - + if ( error == noErr ) { /* Set File Manager permissions to closest thing possible */ @@ -2578,7 +2578,7 @@ static Boolean EqualMemory(const void *buffer1, const void *buffer2, unsigned lo --numBytes; } } - + return ( true ); } @@ -2588,7 +2588,7 @@ static Boolean EqualMemory(const void *buffer1, const void *buffer2, unsigned lo ** Read any number of bytes from an open file using read-verify mode. ** The FSReadVerify function reads any number of bytes from an open file ** and verifies them against the data in the buffer pointed to by buffPtr. -** +** ** Because of a bug in the HFS file system, only non-block aligned parts of ** the read are verified against the buffer data and the rest is *copied* ** into the buffer. Thus, you shouldn't verify against your original data; @@ -2627,7 +2627,7 @@ pascal OSErr FSWriteVerify(short refNum, long bytesVerified; Ptr startVerify; OSErr result; - + /* ** Allocate the verify buffer ** Try to get get a large enough buffer to verify in one pass. @@ -2640,7 +2640,7 @@ pascal OSErr FSWriteVerify(short refNum, verifyBuffer = GetTempBuffer(bufferSize, &bufferSize); } if ( verifyBuffer != NULL ) - { + { /* Save the current position */ result = GetFPos(refNum, &position); if ( result == noErr ) @@ -2685,7 +2685,7 @@ pascal OSErr FSWriteVerify(short refNum, ** after the read-verify request completes. */ BlockMoveData(startVerify, verifyBuffer, byteCount); - + /* Read-verify the data back into the verify buffer */ result = FSReadVerify(refNum, &byteCount, verifyBuffer); if ( result == noErr ) @@ -2725,7 +2725,7 @@ pascal OSErr CopyFork(short srcRefNum, if ( (copyBufferPtr == NULL) || (copyBufferSize == 0) ) return ( paramErr ); - + srcPB.ioParam.ioRefNum = srcRefNum; dstPB.ioParam.ioRefNum = dstRefNum; @@ -2826,7 +2826,7 @@ pascal OSErr CopyDirectoryAccess(short srcVRefNum, short dstVRefNum, long dstDirID, ConstStr255Param dstName) -{ +{ OSErr error; GetVolParmsInfoBuffer infoBuffer; /* Where PBGetVolParms dumps its info */ long dstServerAdr; /* AppleTalk server address of destination (if any) */ @@ -2841,7 +2841,7 @@ pascal OSErr CopyDirectoryAccess(short srcVRefNum, if ( hasAccessCntl(infoBuffer) ) { dstServerAdr = infoBuffer.vMServerAdr; - + /* See if source supports directory access control and is on same server */ tempLong = sizeof(infoBuffer); error = HGetVolParms(srcName, srcVRefNum, &infoBuffer, &tempLong); @@ -2871,7 +2871,7 @@ pascal OSErr CopyDirectoryAccess(short srcVRefNum, error = paramErr; } } - + return ( error ); } @@ -2904,7 +2904,7 @@ pascal OSErr HMoveRenameCompat(short vRefNum, long uniqueTempDirID; Str31 uniqueTempDirName; unsigned short uniqueNameoverflow; - + /* Get volume attributes */ infoSize = sizeof(GetVolParmsInfoBuffer); error = HGetVolParms((StringPtr)srcName, vRefNum, &volParmsInfo, &infoSize); @@ -2916,7 +2916,7 @@ pascal OSErr HMoveRenameCompat(short vRefNum, else if ( (error == noErr) || (error == paramErr) ) /* paramErr is OK, it just means this volume doesn't support GetVolParms */ { /* MoveRename isn't supported by this volume, so do it by hand */ - + /* If copyName isn't supplied, we can simply CatMove and return */ if ( copyName == NULL ) { @@ -2925,7 +2925,7 @@ pascal OSErr HMoveRenameCompat(short vRefNum, else { /* Renaming is required, so we have some work to do... */ - + /* Get the object's real name, real parent ID and real vRefNum */ error = GetObjectLocation(vRefNum, srcDirID, (StringPtr)srcName, &realVRefNum, &realParID, realName, &isDirectory); @@ -2939,8 +2939,8 @@ pascal OSErr HMoveRenameCompat(short vRefNum, /* Create a new uniquely named folder in the temporary items folder. */ /* This is done to avoid the case where 'realName' or 'copyName' already */ /* exists in the temporary items folder. */ - - /* Start with current tick count as uniqueTempDirName */ + + /* Start with current tick count as uniqueTempDirName */ NumToString(TickCount(), uniqueTempDirName); uniqueNameoverflow = 0; do @@ -2965,7 +2965,7 @@ pascal OSErr HMoveRenameCompat(short vRefNum, error = CatMove(realVRefNum, realParID, realName, uniqueTempDirID, NULL); if ( error == noErr ) { - /* Rename the object */ + /* Rename the object */ error = HRename(realVRefNum, uniqueTempDirID, realName, copyName); if ( error == noErr ) { @@ -2990,7 +2990,7 @@ pascal OSErr HMoveRenameCompat(short vRefNum, } } } - + return ( error ); } @@ -3023,7 +3023,7 @@ pascal OSErr BuildAFPVolMountInfo(short flags, { MyAFPVolMountInfoPtr infoPtr; OSErr error; - + /* Allocate the AFPXVolMountInfo record */ infoPtr = (MyAFPVolMountInfoPtr)NewPtrClear(sizeof(MyAFPVolMountInfo)); if ( infoPtr != NULL ) @@ -3035,21 +3035,21 @@ pascal OSErr BuildAFPVolMountInfo(short flags, infoPtr->nbpInterval = nbpInterval; infoPtr->nbpCount = nbpCount; infoPtr->uamType = uamType; - + infoPtr->zoneNameOffset = offsetof(MyAFPVolMountInfo, zoneName); infoPtr->serverNameOffset = offsetof(MyAFPVolMountInfo, serverName); infoPtr->volNameOffset = offsetof(MyAFPVolMountInfo, volName); infoPtr->userNameOffset = offsetof(MyAFPVolMountInfo, userName); infoPtr->userPasswordOffset = offsetof(MyAFPVolMountInfo, userPassword); infoPtr->volPasswordOffset = offsetof(MyAFPVolMountInfo, volPassword); - + BlockMoveData(zoneName, infoPtr->zoneName, sizeof(Str32)); BlockMoveData(serverName, infoPtr->serverName, sizeof(Str32)); BlockMoveData(volName, infoPtr->volName, sizeof(Str27)); BlockMoveData(userName, infoPtr->userName, sizeof(Str31)); BlockMoveData(userPassword, infoPtr->userPassword, sizeof(Str8)); BlockMoveData(volPassword, infoPtr->volPassword, sizeof(Str8)); - + *afpInfoPtr = (AFPVolMountInfoPtr)infoPtr; error = noErr; } @@ -3057,7 +3057,7 @@ pascal OSErr BuildAFPVolMountInfo(short flags, { error = memFullErr; } - + return ( error ); } @@ -3073,44 +3073,44 @@ pascal OSErr RetrieveAFPVolMountInfo(AFPVolMountInfoPtr afpInfoPtr, { StringPtr tempPtr; OSErr error; - + /* Retrieve the AFP mounting information from an AFPVolMountInfo record. */ if ( afpInfoPtr->media == AppleShareMediaType ) { *flags = afpInfoPtr->flags; *uamType = afpInfoPtr->uamType; - + if ( afpInfoPtr->zoneNameOffset != 0) { tempPtr = (StringPtr)((long)afpInfoPtr + afpInfoPtr->zoneNameOffset); BlockMoveData(tempPtr, zoneName, tempPtr[0] + 1); } - + if ( afpInfoPtr->serverNameOffset != 0) { tempPtr = (StringPtr)((long)afpInfoPtr + afpInfoPtr->serverNameOffset); BlockMoveData(tempPtr, serverName, tempPtr[0] + 1); } - + if ( afpInfoPtr->volNameOffset != 0) { tempPtr = (StringPtr)((long)afpInfoPtr + afpInfoPtr->volNameOffset); BlockMoveData(tempPtr, volName, tempPtr[0] + 1); } - + if ( afpInfoPtr->userNameOffset != 0) { tempPtr = (StringPtr)((long)afpInfoPtr + afpInfoPtr->userNameOffset); BlockMoveData(tempPtr, userName, tempPtr[0] + 1); } - + error = noErr; } else { error = paramErr; } - + return ( error ); } @@ -3134,10 +3134,10 @@ pascal OSErr BuildAFPXVolMountInfo(short flags, Size infoSize; MyAFPXVolMountInfoPtr infoPtr; OSErr error; - + /* Calculate the size of the AFPXVolMountInfo record */ infoSize = sizeof(MyAFPXVolMountInfo) + alternateAddressLength - 1; - + /* Allocate the AFPXVolMountInfo record */ infoPtr = (MyAFPXVolMountInfoPtr)NewPtrClear(infoSize); if ( infoPtr != NULL ) @@ -3163,8 +3163,8 @@ pascal OSErr BuildAFPXVolMountInfo(short flags, infoPtr->nbpInterval = nbpInterval; infoPtr->nbpCount = nbpCount; infoPtr->uamType = uamType; - - infoPtr->zoneNameOffset = offsetof(MyAFPXVolMountInfo, zoneName); + + infoPtr->zoneNameOffset = offsetof(MyAFPXVolMountInfo, zoneName); infoPtr->serverNameOffset = offsetof(MyAFPXVolMountInfo, serverName); infoPtr->volNameOffset = offsetof(MyAFPXVolMountInfo, volName); infoPtr->userNameOffset = offsetof(MyAFPXVolMountInfo, userName); @@ -3172,7 +3172,7 @@ pascal OSErr BuildAFPXVolMountInfo(short flags, infoPtr->volPasswordOffset = offsetof(MyAFPXVolMountInfo, volPassword); infoPtr->uamNameOffset = offsetof(MyAFPXVolMountInfo, uamName); infoPtr->alternateAddressOffset = offsetof(MyAFPXVolMountInfo, alternateAddress); - + BlockMoveData(zoneName, infoPtr->zoneName, sizeof(Str32)); BlockMoveData(serverName, infoPtr->serverName, sizeof(Str32)); BlockMoveData(volName, infoPtr->volName, sizeof(Str27)); @@ -3181,7 +3181,7 @@ pascal OSErr BuildAFPXVolMountInfo(short flags, BlockMoveData(volPassword, infoPtr->volPassword, sizeof(Str8)); BlockMoveData(uamName, infoPtr->uamName, sizeof(Str32)); BlockMoveData(alternateAddress, infoPtr->alternateAddress, alternateAddressLength); - + *afpXInfoPtr = (AFPXVolMountInfoPtr)infoPtr; error = noErr; } @@ -3189,7 +3189,7 @@ pascal OSErr BuildAFPXVolMountInfo(short flags, { error = memFullErr; } - + return ( error ); } @@ -3212,20 +3212,20 @@ pascal OSErr RetrieveAFPXVolMountInfo(AFPXVolMountInfoPtr afpXInfoPtr, Size alternateAddressDataSize; OSErr error; UInt8 addressCount; - + /* Retrieve the AFP mounting information from an AFPVolMountInfo record. */ if ( afpXInfoPtr->media == AppleShareMediaType ) { /* default to noErr */ error = noErr; - + /* Is this an extended record? */ if ( (afpXInfoPtr->flags & volMountExtendedFlagsMask) != 0 ) { if ( ((afpXInfoPtr->extendedFlags & kAFPExtendedFlagsAlternateAddressMask) != 0) && (afpXInfoPtr->alternateAddressOffset != 0) ) { - + alternateAddressStart = (Ptr)((long)afpXInfoPtr + afpXInfoPtr->alternateAddressOffset); alternateAddressEnd = alternateAddressStart + 1; /* skip over alternate address version byte */ addressCount = *(UInt8*)alternateAddressEnd; /* get the address count */ @@ -3253,7 +3253,7 @@ pascal OSErr RetrieveAFPXVolMountInfo(AFPXVolMountInfoPtr afpXInfoPtr, error = memFullErr; } } - + if ( error == noErr ) /* fill in more output parameters if everything is OK */ { if ( afpXInfoPtr->uamNameOffset != 0 ) @@ -3263,30 +3263,30 @@ pascal OSErr RetrieveAFPXVolMountInfo(AFPXVolMountInfoPtr afpXInfoPtr, } } } - + if ( error == noErr ) /* fill in more output parameters if everything is OK */ { *flags = afpXInfoPtr->flags; *uamType = afpXInfoPtr->uamType; - + if ( afpXInfoPtr->zoneNameOffset != 0 ) { tempPtr = (StringPtr)((long)afpXInfoPtr + afpXInfoPtr->zoneNameOffset); BlockMoveData(tempPtr, zoneName, tempPtr[0] + 1); } - + if ( afpXInfoPtr->serverNameOffset != 0 ) { tempPtr = (StringPtr)((long)afpXInfoPtr + afpXInfoPtr->serverNameOffset); BlockMoveData(tempPtr, serverName, tempPtr[0] + 1); } - + if ( afpXInfoPtr->volNameOffset != 0 ) { tempPtr = (StringPtr)((long)afpXInfoPtr + afpXInfoPtr->volNameOffset); BlockMoveData(tempPtr, volName, tempPtr[0] + 1); } - + if ( afpXInfoPtr->userNameOffset != 0 ) { tempPtr = (StringPtr)((long)afpXInfoPtr + afpXInfoPtr->userNameOffset); @@ -3298,7 +3298,7 @@ pascal OSErr RetrieveAFPXVolMountInfo(AFPXVolMountInfoPtr afpXInfoPtr, { error = paramErr; } - + return ( error ); } @@ -3332,7 +3332,7 @@ pascal OSErr GetUGEntries(short objType, ++*actEntryCount; } } - + return ( error ); } diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFilesExtras.h b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFilesExtras.h index 842d774..be1804d 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFilesExtras.h +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/MoreFilesExtras.h @@ -130,7 +130,7 @@ enum { /* mask for just the access restriction bits */ acUserAccessMask = (kioACUserNoSeeFolderMask + kioACUserNoSeeFilesMask + kioACUserNoMakeChangesMask), - + /* common access privilege settings */ acUserFull = 0x00, /* no access restiction bits on */ acUserNone = acUserAccessMask, /* all access restiction bits on */ @@ -177,7 +177,7 @@ enum dmRdWrDenyWr = (fsRdWrPerm + fsWrDenyPerm), /* Single writer, multiple readers; the writer */ dmRdWrDenyRdWr = (fsRdWrPerm + fsRdDenyPerm + fsWrDenyPerm) /* Exclusive access - equivalent to fsRdWrPerm */ }; - + /*****************************************************************************/ #if PRAGMA_STRUCT_ALIGN @@ -239,15 +239,15 @@ struct MyAFPVolMountInfo short userNameOffset; /* offset from start of record to userName */ short userPasswordOffset; /* offset from start of record to userPassword */ short volPasswordOffset; /* offset from start of record to volPassword */ - Str32 zoneName; /* server's AppleTalk zone name */ + Str32 zoneName; /* server's AppleTalk zone name */ char filler1; /* to word align volPassword */ - Str32 serverName; /* server name */ + Str32 serverName; /* server name */ char filler2; /* to word align volPassword */ - Str27 volName; /* volume name */ + Str27 volName; /* volume name */ Str31 userName; /* user name (zero length Pascal string for guest) */ - Str8 userPassword; /* user password (zero length Pascal string if no user password) */ + Str8 userPassword; /* user password (zero length Pascal string if no user password) */ char filler3; /* to word align volPassword */ - Str8 volPassword; /* volume password (zero length Pascal string if no volume password) */ + Str8 volPassword; /* volume password (zero length Pascal string if no volume password) */ char filler4; /* to end record on word boundry */ }; typedef struct MyAFPVolMountInfo MyAFPVolMountInfo; @@ -270,15 +270,15 @@ struct MyAFPXVolMountInfo short extendedFlags; /* extended flags word */ short uamNameOffset; /* offset to a pascal UAM name string */ short alternateAddressOffset; /* offset to Alternate Addresses in tagged format */ - Str32 zoneName; /* server's AppleTalk zone name */ + Str32 zoneName; /* server's AppleTalk zone name */ char filler1; /* to word align volPassword */ - Str32 serverName; /* server name */ + Str32 serverName; /* server name */ char filler2; /* to word align volPassword */ - Str27 volName; /* volume name */ + Str27 volName; /* volume name */ Str31 userName; /* user name (zero length Pascal string for guest) */ - Str8 userPassword; /* user password (zero length Pascal string if no user password) */ + Str8 userPassword; /* user password (zero length Pascal string if no user password) */ char filler3; /* to word align volPassword */ - Str8 volPassword; /* volume password (zero length Pascal string if no volume password) */ + Str8 volPassword; /* volume password (zero length Pascal string if no volume password) */ char filler4; /* to word align uamNameOffset */ Str32 uamName; /* UAM name */ char filler5; /* to word align alternateAddress */ @@ -301,7 +301,7 @@ pascal void TruncPString(StringPtr destination, the source Pascal string to the destination Pascal string. TruncPString ensures that the truncated string ends on a single-byte character, or on the last byte of a multi-byte character. - + destination output: destination Pascal string. source input: source Pascal string. maxLength output: The maximum allowable length of the destination @@ -316,7 +316,7 @@ pascal Ptr GetTempBuffer(long buffReqSize, The GetTempBuffer function allocates a temporary buffer for file system operations which is at least 1024 bytes (1K) and a multiple of 1024 bytes. - + buffReqSize input: Size you'd like the buffer to be. buffActSize output: Size of buffer allocated. function result output: Pointer to memory allocated or nil if no memory @@ -340,7 +340,7 @@ pascal OSErr GetVolumeInfoNoName(ConstStr255Param pathname, I noticed using this code in several places, so here it is once. This reduces the code size of MoreFiles. - pathName input: Pointer to a full pathname or nil. If you pass in a + pathName input: Pointer to a full pathname or nil. If you pass in a partial pathname, it is ignored. A full pathname to a volume must end with a colon character (:). vRefNum input: Volume specification (volume reference number, working @@ -348,7 +348,7 @@ pascal OSErr GetVolumeInfoNoName(ConstStr255Param pathname, pb input: A pointer to HParamBlockRec. output: The parameter block as filled in by PBHGetVInfoSync except that ioNamePtr will always be NULL. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -368,7 +368,7 @@ pascal OSErr XGetVolumeInfoNoName(ConstStr255Param pathname, the parameter block is always returned as NULL (since it might point to XGetVolumeInfoNoName's local variable tempPathname). - pathName input: Pointer to a full pathname or nil. If you pass in a + pathName input: Pointer to a full pathname or nil. If you pass in a partial pathname, it is ignored. A full pathname to a volume must end with a colon character (:). vRefNum input: Volume specification (volume reference number, working @@ -376,7 +376,7 @@ pascal OSErr XGetVolumeInfoNoName(ConstStr255Param pathname, pb input: A pointer to HParamBlockRec. output: The parameter block as filled in by PBXGetVolInfoSync except that ioNamePtr will always be NULL. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -408,7 +408,7 @@ pascal OSErr GetCatInfoNoName(short vRefNum, output: The parameter block as filled in by PBGetCatInfoSync except that ioNamePtr will always be NULL. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -419,7 +419,7 @@ pascal OSErr GetCatInfoNoName(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + */ /*****************************************************************************/ @@ -439,13 +439,13 @@ pascal OSErr DetermineVRefNum(ConstStr255Param pathname, currently uses the first volume it finds with a matching name in the volume queue. - pathName input: Pointer to a full pathname or nil. If you pass in a + pathName input: Pointer to a full pathname or nil. If you pass in a partial pathname, it is ignored. A full pathname to a volume must end with a colon character (:). vRefNum input: Volume specification (volume reference number, working directory number, drive number, or 0). realVRefNum output: The real volume reference number. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -465,7 +465,7 @@ pascal OSErr HGetVInfo(short volReference, specified volume. You can specify the volume by providing its drive number, volume reference number, or 0 for the default volume. This routine is compatible with volumes up to 4 gigabytes. - + volReference input: The drive number, volume reference number, or 0 for the default volume. volName input: A pointer to a buffer (minimum Str27) where @@ -477,14 +477,14 @@ pascal OSErr HGetVInfo(short volReference, freeBytes is an unsigned long value. totalBytes output: The total number of bytes on the volume. totalBytes is an unsigned long value. - + Result Codes noErr 0 No error nsvErr -35 No such volume paramErr -50 No default volume - + __________ - + Also see: XGetVInfo */ @@ -501,7 +501,7 @@ pascal OSErr XGetVInfo(short volReference, specified volume. You can specify the volume by providing its drive number, volume reference number, or 0 for the default volume. This routine is compatible with volumes up to 2 terabytes. - + volReference input: The drive number, volume reference number, or 0 for the default volume. volName input: A pointer to a buffer (minimum Str27) where @@ -513,14 +513,14 @@ pascal OSErr XGetVInfo(short volReference, freeBytes is an UnsignedWide value. totalBytes output: The total number of bytes on the volume. totalBytes is an UnsignedWide value. - + Result Codes noErr 0 No error nsvErr -35 No such volume paramErr -50 No default volume - + __________ - + Also see: HGetVInfo */ @@ -533,12 +533,12 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, hardware or by software. If CheckVolLock returns noErr, then the volume is not locked. - pathName input: Pointer to a full pathname or nil. If you pass in a + pathName input: Pointer to a full pathname or nil. If you pass in a partial pathname, it is ignored. A full pathname to a volume must end with a colon character (:). vRefNum input: Volume specification (volume reference number, working directory number, drive number, or 0). - + Result Codes noErr 0 No error - volume not locked nsvErr -35 No such volume @@ -551,7 +551,7 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, // // The following routines call Mac OS routines that are not supported by // Carbon: -// +// // GetDriverName // FindDrive // GetDiskBlocks @@ -568,7 +568,7 @@ pascal OSErr GetDriverName(short driverRefNum, driverRefNum input: The driver reference number. driverName output: The driver's name. - + Result Codes noErr 0 No error badUnitErr -21 Bad driver reference number @@ -593,7 +593,7 @@ pascal OSErr FindDrive(ConstStr255Param pathname, driveQElementPtr output: Pointer to a volume's drive queue element in the drive queue. DO NOT change the DrvQEl. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -619,7 +619,7 @@ pascal OSErr GetDiskBlocks(ConstStr255Param pathname, number, working directory number, drive number, or 0). numBlocks output: The number of physical disk blocks on the disk drive. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -651,7 +651,7 @@ pascal OSErr GetVolState(ConstStr255Param pathname, The GetVolState function determines if a volume is online or offline, if an offline volume is ejected, and if the volume's driver is ejectable or wants eject calls. - + pathName input: Pointer to a full pathname or nil. vRefNum input: Volume specification (volume reference number, working directory number, drive number, or 0). @@ -666,7 +666,7 @@ pascal OSErr GetVolState(ConstStr255Param pathname, request after unmount (even if the drive is not ejectable); False if the volume's driver does not need an eject request. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -698,11 +698,11 @@ pascal OSErr GetVolFileSystemID(ConstStr255Param pathname, $4953 Macintosh PC Exchange (MS-DOS) $4A48 Audio CD Access (through Foreign File Access) $4D4B Apple Photo Access (through Foreign File Access) - + See the Technical Note "FL 35 - Determining Which File System Is Active" and the "Guide to the File System Manager" for more information. - + pathName input: Pointer to a full pathname or nil. If you pass in a partial pathname, it is ignored. A full pathname to a volume must contain at least @@ -711,7 +711,7 @@ pascal OSErr GetVolFileSystemID(ConstStr255Param pathname, vRefNum input: Volume specification (volume reference number, working directory number, drive number, or 0). fileSystemID output: The volume's file system ID. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -725,13 +725,13 @@ pascal OSErr UnmountAndEject(ConstStr255Param pathname, /* ¶ Unmount and eject a volume. The UnmountAndEject function unmounts and ejects a volume. The volume is ejected only if it is ejectable and not already ejected. - - pathName input: Pointer to a full pathname or nil. If you pass in a + + pathName input: Pointer to a full pathname or nil. If you pass in a partial pathname, it is ignored. A full pathname to a volume must end with a colon character (:). vRefNum input: Volume specification (volume reference number, working directory number, drive number, or 0). - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -753,7 +753,7 @@ pascal OSErr OnLine(FSSpecPtr volumes, /* ¶ Return the list of volumes currently mounted. The OnLine function returns the list of volumes currently mounted in an array of FSSpec records. - + A noErr result indicates that the volumes array was filled (actVolCount == reqVolCount) and there may be additional volumes mounted. A nsvErr result indicates that the end of the volume list @@ -769,7 +769,7 @@ pascal OSErr OnLine(FSSpecPtr volumes, output: The volume index position to get the next volume. Pass this value the next time you call OnLine to start where you left off. - + Result Codes noErr 0 No error, but there are more volumes to list @@ -793,25 +793,25 @@ pascal OSErr SetDefault(short newVRefNum, designed to be used as a wrapper around Standard I/O routines where the location of the file is implied to be the default volume and directory. In other words, this is how you should use these functions: - + error = SetDefault(newVRefNum, newDirID, &oldVRefNum, &oldDirID); if ( error == noErr ) { // call the Stdio functions like remove, rename, tmpfile, // fopen, freopen, etc. or non-ANSI extensions like // fdopen,fsetfileinfo, -- create, open, unlink, etc. here! - + error = RestoreDefault(oldVRefNum, oldDirID); } - + By using these functions as a wrapper, you won't need to open a working directory (because SetDefault and RestoreDefault use HSetVol) and you won't have to worry about the effects of using HSetVol (documented in Technical Note "FL 11 - PBHSetVol is Dangerous" and in the - Inside Macintosh: Files book in the description of the HSetVol and + Inside Macintosh: Files book in the description of the HSetVol and PBHSetVol functions) because the default volume/directory is restored before giving up control to code that might be affected by HSetVol. - + newVRefNum input: Volume specification (volume reference number, working directory number, drive number, or 0) of the new default volume. @@ -820,7 +820,7 @@ pascal OSErr SetDefault(short newVRefNum, RestoreDefault. oldDirID output: The directory ID to save for use with RestoreDefault. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -828,9 +828,9 @@ pascal OSErr SetDefault(short newVRefNum, fnfErr -43 Directory not found paramErr -50 No default volume afpAccessDenied -5000 User does not have access to the directory - + __________ - + Also see: RestoreDefault */ @@ -840,34 +840,34 @@ pascal OSErr RestoreDefault(short oldVRefNum, long oldDirID); /* ¶ Restore the default volume after making Standard C I/O requests. The RestoreDefault function restores the default volume and directory - to the volume specified by oldVRefNum and the directory specified by + to the volume specified by oldVRefNum and the directory specified by oldDirID. The oldVRefNum and oldDirID parameters were previously obtained from the SetDefault function. These two functions are designed to be used as a wrapper around Standard C I/O routines where the location of the file is implied to be the default volume and directory. In other words, this is how you should use these functions: - + error = SetDefault(newVRefNum, newDirID, &oldVRefNum, &oldDirID); if ( error == noErr ) { // call the Stdio functions like remove, rename, tmpfile, // fopen, freopen, etc. or non-ANSI extensions like // fdopen,fsetfileinfo, -- create, open, unlink, etc. here! - + error = RestoreDefault(oldVRefNum, oldDirID); } - + By using these functions as a wrapper, you won't need to open a working directory (because SetDefault and RestoreDefault use HSetVol) and you won't have to worry about the effects of using HSetVol (documented in Technical Note "FL 11 - PBHSetVol is Dangerous" and in the - Inside Macintosh: Files book in the description of the HSetVol and + Inside Macintosh: Files book in the description of the HSetVol and PBHSetVol functions) because the default volume/directory is restored before giving up control to code that might be affected by HSetVol. - + oldVRefNum input: The volume specification to restore. oldDirID input: The directory ID to restore. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -876,9 +876,9 @@ pascal OSErr RestoreDefault(short oldVRefNum, paramErr -50 No default volume rfNumErr -51 Bad working directory reference number afpAccessDenied -5000 User does not have access to the directory - + __________ - + Also see: SetDefault */ @@ -896,7 +896,7 @@ pascal OSErr GetDInfo(short vRefNum, name input: Pointer to object name, or nil when dirID specifies a directory that's the object. fndrInfo output: If the object is a directory, then its DInfo. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -907,9 +907,9 @@ pascal OSErr GetDInfo(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + Also see: FSpGetDInfo, FSpGetFInfoCompat */ @@ -922,7 +922,7 @@ pascal OSErr FSpGetDInfo(const FSSpec *spec, spec input: An FSSpec record specifying the directory. fndrInfo output: If the object is a directory, then its DInfo. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -933,9 +933,9 @@ pascal OSErr FSpGetDInfo(const FSSpec *spec, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + Also see: FSpGetFInfoCompat, GetDInfo */ @@ -953,7 +953,7 @@ pascal OSErr SetDInfo(short vRefNum, name input: Pointer to object name, or nil when dirID specifies a directory that's the object. fndrInfo input: The DInfo. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -966,9 +966,9 @@ pascal OSErr SetDInfo(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + Also see: FSpSetDInfo, FSpSetFInfoCompat */ @@ -981,7 +981,7 @@ pascal OSErr FSpSetDInfo(const FSSpec *spec, spec input: An FSSpec record specifying the directory. fndrInfo input: The DInfo. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -994,9 +994,9 @@ pascal OSErr FSpSetDInfo(const FSSpec *spec, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + Also see: FSpSetFInfoCompat, SetDInfo */ @@ -1025,7 +1025,7 @@ pascal OSErr GetDirectoryID(short vRefNum, name and a volume name or full pathname is used, the File Manager currently uses the first volume it finds with a matching name in the volume queue. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID @@ -1034,7 +1034,7 @@ pascal OSErr GetDirectoryID(short vRefNum, ID. If the object is a directory, then its ID. isDirectory output: True if object is a directory; false if object is a file. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1063,12 +1063,12 @@ pascal OSErr FSpGetDirectoryID(const FSSpec *spec, directory of the file is returned and isDirectory is false. If spec is to a directory, then that directory's ID number is returned and isDirectory is true. - + spec input: An FSSpec record specifying the directory. theDirID output: The directory ID. isDirectory output: True if object is a directory; false if object is a file. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1094,7 +1094,7 @@ pascal OSErr GetDirName(short vRefNum, dirID input: Directory ID. name output: Points to a Str31 where the directory name is to be returned. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1118,13 +1118,13 @@ pascal OSErr GetIOACUser(short vRefNum, GetIOACUser returns a directory's access restrictions byte. Use the masks and macro defined in MoreFilesExtras to check for specific access priviledges. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. ioACUser output: The access restriction byte - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1145,10 +1145,10 @@ pascal OSErr FSpGetIOACUser(const FSSpec *spec, FSpGetIOACUser returns a directory's access restrictions byte. Use the masks and macro defined in MoreFilesExtras to check for specific access priviledges. - + spec input: An FSSpec record specifying the directory. ioACUser output: The access restriction byte - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1170,13 +1170,13 @@ pascal OSErr GetParentID(short vRefNum, /* ¶ Get the parent directory ID number of the specified object. The GetParentID function gets the parent directory ID number of the specified object. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. parID output: The parent directory ID of the specified object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1199,18 +1199,18 @@ pascal OSErr GetFilenameFromPathname(ConstStr255Param pathname, pathname is nil, the pathname is empty, or the pathname cannot refer to a filename (with a noErr result, the pathname could still refer to a directory). - + pathname input: A full or partial pathname. filename output: The file (or directory) name. - + Result Codes noErr 0 No error notAFileErr -1302 The pathname is nil, the pathname is empty, or the pathname cannot refer to a filename - + __________ - + See also: GetObjectLocation. */ @@ -1231,7 +1231,7 @@ pascal OSErr GetObjectLocation(short vRefNum, returned is valid, but it describes an object that doesn't exist. You can use the location information for another operation, such as creating a file or directory. - + vRefNum input: Volume specification. dirID input: Directory ID. pathname input: Pointer to object name, or nil when dirID specifies @@ -1244,7 +1244,7 @@ pascal OSErr GetObjectLocation(short vRefNum, system is not case sensitive, it shouldn't matter). isDirectory output: True if object is a directory; false if object is a file. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1258,9 +1258,9 @@ pascal OSErr GetObjectLocation(short vRefNum, to a filename afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: FSMakeFSSpecCompat */ @@ -1279,7 +1279,7 @@ pascal OSErr GetDirItems(short vRefNum, The GetDirItems function returns a list of items in the specified directory in an array of FSSpec records. File, subdirectories, or both can be returned in the list. - + A noErr result indicates that the items array was filled (actItemCount == reqItemCount) and there may be additional items left in the directory. A fnfErr result indicates that the end of @@ -1303,7 +1303,7 @@ pascal OSErr GetDirItems(short vRefNum, output: The item index position to get the next item. Pass this value the next time you call GetDirItems to start where you left off. - + Result Codes noErr 0 No error, but there are more items to list @@ -1329,29 +1329,29 @@ pascal OSErr DeleteDirectoryContents(short vRefNum, If a locked file or directory is encountered, it is unlocked and then deleted. If any unexpected errors are encountered, DeleteDirectoryContents quits and returns to the caller. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to directory name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume ioErr -36 I/O error bdNamErr -37 Bad filename fnfErr -43 File not found - wPrErr -44 Hardware volume lock - fLckdErr -45 File is locked - vLckdErr -46 Software volume lock - fBsyErr -47 File busy, directory not empty, or working directory control block open + wPrErr -44 Hardware volume lock + fLckdErr -45 File is locked + vLckdErr -46 Software volume lock + fBsyErr -47 File busy, directory not empty, or working directory control block open paramErr -50 No default volume dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + Also see: DeleteDirectory */ @@ -1367,12 +1367,12 @@ pascal OSErr DeleteDirectory(short vRefNum, deleted. After deleting the directories contents, the directory is deleted. If any unexpected errors are encountered, DeleteDirectory quits and returns to the caller. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to directory name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1382,14 +1382,14 @@ pascal OSErr DeleteDirectory(short vRefNum, wPrErr -44 Hardware volume lock fLckdErr -45 File is locked vLckdErr -46 Software volume lock - fBsyErr -47 File busy, directory not empty, or working directory control block open + fBsyErr -47 File busy, directory not empty, or working directory control block open paramErr -50 No default volume dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + Also see: DeleteDirectoryContents */ @@ -1402,12 +1402,12 @@ pascal OSErr CheckObjectLock(short vRefNum, The CheckObjectLock function determines if a file or directory is locked. If CheckObjectLock returns noErr, then the file or directory is not locked. If CheckObjectLock returns fLckdErr, the it is locked. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1419,9 +1419,9 @@ pascal OSErr CheckObjectLock(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + Also see: FSpCheckObjectLock */ @@ -1432,9 +1432,9 @@ pascal OSErr FSpCheckObjectLock(const FSSpec *spec); The FSpCheckObjectLock function determines if a file or directory is locked. If FSpCheckObjectLock returns noErr, then the file or directory is not locked. - + spec input: An FSSpec record specifying the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1446,9 +1446,9 @@ pascal OSErr FSpCheckObjectLock(const FSSpec *spec); dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + Also see: CheckObjectLock */ @@ -1462,13 +1462,13 @@ pascal OSErr GetFileSize(short vRefNum, /* ¶ Get the logical sizes of a file's forks. The GetFileSize function returns the logical size of a file's data and resource fork. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: The name of the file. dataSize output: The number of bytes in the file's data fork. rsrcSize output: The number of bytes in the file's resource fork. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1479,9 +1479,9 @@ pascal OSErr GetFileSize(short vRefNum, dirNFErrdirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: FSpGetFileSize */ @@ -1493,11 +1493,11 @@ pascal OSErr FSpGetFileSize(const FSSpec *spec, /* ¶ Get the logical sizes of a file's forks. The FSpGetFileSize function returns the logical size of a file's data and resource fork. - + spec input: An FSSpec record specifying the file. dataSize output: The number of bytes in the file's data fork. rsrcSize output: The number of bytes in the file's resource fork. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1508,9 +1508,9 @@ pascal OSErr FSpGetFileSize(const FSSpec *spec, dirNFErrdirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: GetFileSize */ @@ -1524,12 +1524,12 @@ pascal OSErr BumpDate(short vRefNum, directory to the current date/time. If the modification date is already equal to the current date/time, then add one second to the modification date. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1542,9 +1542,9 @@ pascal OSErr BumpDate(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: FSpBumpDate */ @@ -1556,9 +1556,9 @@ pascal OSErr FSpBumpDate(const FSSpec *spec); directory to the current date/time. If the modification date is already equal to the current date/time, then add one second to the modification date. - + spec input: An FSSpec record specifying the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1571,9 +1571,9 @@ pascal OSErr FSpBumpDate(const FSSpec *spec); dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: BumpDate */ @@ -1594,7 +1594,7 @@ pascal OSErr ChangeCreatorType(short vRefNum, the creator type alone. fileType input: The new file type or 0x00000000 to leave the file type alone. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1608,9 +1608,9 @@ pascal OSErr ChangeCreatorType(short vRefNum, notAFileErr -1302 Name was not a file afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: FSpChangeCreatorType */ @@ -1627,7 +1627,7 @@ pascal OSErr FSpChangeCreatorType(const FSSpec *spec, the creator type alone. fileType input: The new file type or 0x00000000 to leave the file type alone. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1641,9 +1641,9 @@ pascal OSErr FSpChangeCreatorType(const FSSpec *spec, notAFileErr -1302 Name was not a file afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: ChangeCreatorType */ @@ -1657,7 +1657,7 @@ pascal OSErr ChangeFDFlags(short vRefNum, /* ¶ Set or clear Finder Flag bits. The ChangeFDFlags function sets or clears Finder Flag bits in the fdFlags field of a file or directory's FInfo record. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies @@ -1669,7 +1669,7 @@ pascal OSErr ChangeFDFlags(short vRefNum, then the same bit in fdFlags is either set or cleared depending on the state of the setBits parameter. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1682,9 +1682,9 @@ pascal OSErr ChangeFDFlags(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: FSpChangeFDFlags */ @@ -1696,7 +1696,7 @@ pascal OSErr FSpChangeFDFlags(const FSSpec *spec, /* ¶ Set or clear Finder Flag bits. The FSpChangeFDFlags function sets or clears Finder Flag bits in the fdFlags field of a file or directory's FInfo record. - + spec input: An FSSpec record specifying the object. setBits input: If true, then set the bits specified in flagBits. If false, then clear the bits specified in flagBits. @@ -1705,7 +1705,7 @@ pascal OSErr FSpChangeFDFlags(const FSSpec *spec, then the same bit in fdFlags is either set or cleared depending on the state of the setBits parameter. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1718,9 +1718,9 @@ pascal OSErr FSpChangeFDFlags(const FSSpec *spec, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: ChangeFDFlags */ @@ -1732,12 +1732,12 @@ pascal OSErr SetIsInvisible(short vRefNum, /* ¶ Set the invisible Finder Flag bit. The SetIsInvisible function sets the invisible bit in the fdFlags word of the specified file or directory's finder information. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1750,9 +1750,9 @@ pascal OSErr SetIsInvisible(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: FSpSetIsInvisible, ClearIsInvisible, FSpClearIsInvisible */ @@ -1762,9 +1762,9 @@ pascal OSErr FSpSetIsInvisible(const FSSpec *spec); /* ¶ Set the invisible Finder Flag bit. The FSpSetIsInvisible function sets the invisible bit in the fdFlags word of the specified file or directory's finder information. - + spec input: An FSSpec record specifying the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1777,9 +1777,9 @@ pascal OSErr FSpSetIsInvisible(const FSSpec *spec); dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: SetIsInvisible, ClearIsInvisible, FSpClearIsInvisible */ @@ -1791,12 +1791,12 @@ pascal OSErr ClearIsInvisible(short vRefNum, /* ¶ Clear the invisible Finder Flag bit. The ClearIsInvisible function clears the invisible bit in the fdFlags word of the specified file or directory's finder information. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1809,9 +1809,9 @@ pascal OSErr ClearIsInvisible(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: SetIsInvisible, FSpSetIsInvisible, FSpClearIsInvisible */ @@ -1821,9 +1821,9 @@ pascal OSErr FSpClearIsInvisible(const FSSpec *spec); /* ¶ Clear the invisible Finder Flag bit. The FSpClearIsInvisible function clears the invisible bit in the fdFlags word of the specified file or directory's finder information. - + spec input: An FSSpec record specifying the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1836,9 +1836,9 @@ pascal OSErr FSpClearIsInvisible(const FSSpec *spec); dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: SetIsInvisible, FSpSetIsInvisible, ClearIsInvisible */ @@ -1850,12 +1850,12 @@ pascal OSErr SetNameLocked(short vRefNum, /* ¶ Set the nameLocked Finder Flag bit. The SetNameLocked function sets the nameLocked bit in the fdFlags word of the specified file or directory's finder information. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1868,9 +1868,9 @@ pascal OSErr SetNameLocked(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: FSpSetNameLocked, ClearNameLocked, FSpClearNameLocked */ @@ -1880,9 +1880,9 @@ pascal OSErr FSpSetNameLocked(const FSSpec *spec); /* ¶ Set the nameLocked Finder Flag bit. The FSpSetNameLocked function sets the nameLocked bit in the fdFlags word of the specified file or directory's finder information. - + spec input: An FSSpec record specifying the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1895,9 +1895,9 @@ pascal OSErr FSpSetNameLocked(const FSSpec *spec); dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: SetNameLocked, ClearNameLocked, FSpClearNameLocked */ @@ -1909,12 +1909,12 @@ pascal OSErr ClearNameLocked(short vRefNum, /* ¶ Clear the nameLocked Finder Flag bit. The ClearNameLocked function clears the nameLocked bit in the fdFlags word of the specified file or directory's finder information. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1927,9 +1927,9 @@ pascal OSErr ClearNameLocked(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: SetNameLocked, FSpSetNameLocked, FSpClearNameLocked */ @@ -1939,9 +1939,9 @@ pascal OSErr FSpClearNameLocked(const FSSpec *spec); /* ¶ Clear the nameLocked Finder Flag bit. The FSpClearNameLocked function clears the nameLocked bit in the fdFlags word of the specified file or directory's finder information. - + spec input: An FSSpec record specifying the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1954,9 +1954,9 @@ pascal OSErr FSpClearNameLocked(const FSSpec *spec); dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: SetNameLocked, FSpSetNameLocked, ClearNameLocked */ @@ -1968,12 +1968,12 @@ pascal OSErr SetIsStationery(short vRefNum, /* ¶ Set the isStationery Finder Flag bit. The SetIsStationery function sets the isStationery bit in the fdFlags word of the specified file or directory's finder information. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -1986,9 +1986,9 @@ pascal OSErr SetIsStationery(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: FSpSetIsStationery, ClearIsStationery, FSpClearIsStationery */ @@ -1998,9 +1998,9 @@ pascal OSErr FSpSetIsStationery(const FSSpec *spec); /* ¶ Set the isStationery Finder Flag bit. The FSpSetIsStationery function sets the isStationery bit in the fdFlags word of the specified file or directory's finder information. - + spec input: An FSSpec record specifying the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2013,9 +2013,9 @@ pascal OSErr FSpSetIsStationery(const FSSpec *spec); dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: SetIsStationery, ClearIsStationery, FSpClearIsStationery */ @@ -2027,12 +2027,12 @@ pascal OSErr ClearIsStationery(short vRefNum, /* ¶ Clear the isStationery Finder Flag bit. The ClearIsStationery function clears the isStationery bit in the fdFlags word of the specified file or directory's finder information. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2045,9 +2045,9 @@ pascal OSErr ClearIsStationery(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: SetIsStationery, FSpSetIsStationery, FSpClearIsStationery */ @@ -2057,9 +2057,9 @@ pascal OSErr FSpClearIsStationery(const FSSpec *spec); /* ¶ Clear the isStationery Finder Flag bit. The FSpClearIsStationery function clears the isStationery bit in the fdFlags word of the specified file or directory's finder information. - + spec input: An FSSpec record specifying the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2072,9 +2072,9 @@ pascal OSErr FSpClearIsStationery(const FSSpec *spec); dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: SetIsStationery, FSpSetIsStationery, ClearIsStationery */ @@ -2086,12 +2086,12 @@ pascal OSErr SetHasCustomIcon(short vRefNum, /* ¶ Set the hasCustomIcon Finder Flag bit. The SetHasCustomIcon function sets the hasCustomIcon bit in the fdFlags word of the specified file or directory's finder information. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2104,9 +2104,9 @@ pascal OSErr SetHasCustomIcon(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: FSpSetHasCustomIcon, ClearHasCustomIcon, FSpClearHasCustomIcon */ @@ -2116,9 +2116,9 @@ pascal OSErr FSpSetHasCustomIcon(const FSSpec *spec); /* ¶ Set the hasCustomIcon Finder Flag bit. The FSpSetHasCustomIcon function sets the hasCustomIcon bit in the fdFlags word of the specified file or directory's finder information. - + spec input: An FSSpec record specifying the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2131,9 +2131,9 @@ pascal OSErr FSpSetHasCustomIcon(const FSSpec *spec); dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: SetHasCustomIcon, ClearHasCustomIcon, FSpClearHasCustomIcon */ @@ -2145,12 +2145,12 @@ pascal OSErr ClearHasCustomIcon(short vRefNum, /* ¶ Clear the hasCustomIcon Finder Flag bit. The ClearHasCustomIcon function clears the hasCustomIcon bit in the fdFlags word of the specified file or directory's finder information. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2163,9 +2163,9 @@ pascal OSErr ClearHasCustomIcon(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: SetHasCustomIcon, FSpSetHasCustomIcon, FSpClearHasCustomIcon */ @@ -2175,9 +2175,9 @@ pascal OSErr FSpClearHasCustomIcon(const FSSpec *spec); /* ¶ Clear the hasCustomIcon Finder Flag bit. The FSpClearHasCustomIcon function clears the hasCustomIcon bit in the fdFlags word of the specified file or directory's finder information. - + spec input: An FSSpec record specifying the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2190,9 +2190,9 @@ pascal OSErr FSpClearHasCustomIcon(const FSSpec *spec); dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: SetHasCustomIcon, FSpSetHasCustomIcon, ClearHasCustomIcon */ @@ -2204,12 +2204,12 @@ pascal OSErr ClearHasBeenInited(short vRefNum, /* ¶ Clear the hasBeenInited Finder Flag bit. The ClearHasBeenInited function clears the hasBeenInited bit in the fdFlags word of the specified file or directory's finder information. - + vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2222,9 +2222,9 @@ pascal OSErr ClearHasBeenInited(short vRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: FSpClearHasBeenInited */ @@ -2234,9 +2234,9 @@ pascal OSErr FSpClearHasBeenInited(const FSSpec *spec); /* ¶ Clear the hasBeenInited Finder Flag bit. The FSpClearHasBeenInited function clears the hasBeenInited bit in the fdFlags word of the specified file or directory's finder information. - + spec input: An FSSpec record specifying the object. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2249,9 +2249,9 @@ pascal OSErr FSpClearHasBeenInited(const FSSpec *spec); dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: ClearHasBeenInited */ @@ -2280,7 +2280,7 @@ pascal OSErr CopyFileMgrAttributes(short srcVRefNum, dstDirID specifies a directory that's the object. copyLockBit input: If true, set the locked state of the destination to match the source. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2293,9 +2293,9 @@ pascal OSErr CopyFileMgrAttributes(short srcVRefNum, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: FSpCopyFileMgrAttributes */ @@ -2314,7 +2314,7 @@ pascal OSErr FSpCopyFileMgrAttributes(const FSSpec *srcSpec, dstSpec input: An FSSpec record specifying the destination object. copyLockBit input: If true, set the locked state of the destination to match the source. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2327,9 +2327,9 @@ pascal OSErr FSpCopyFileMgrAttributes(const FSSpec *srcSpec, dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname - + __________ - + See also: CopyFileMgrAttributes */ @@ -2355,7 +2355,7 @@ pascal OSErr HOpenAware(short vRefNum, fileName input: The name of the file. denyModes input: The deny modes access under which to open the file. refNum output: The file reference number of the opened file. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2369,9 +2369,9 @@ pascal OSErr HOpenAware(short vRefNum, permErr -54 File is already open and cannot be opened using specified deny modes afpAccessDenied -5000 User does not have the correct access to the file afpDenyConflict -5006 Requested access permission not possible - + __________ - + See also: FSpOpenAware, HOpenRFAware, FSpOpenRFAware */ @@ -2393,7 +2393,7 @@ pascal OSErr FSpOpenAware(const FSSpec *spec, spec input: An FSSpec record specifying the file. denyModes input: The deny modes access under which to open the file. refNum output: The file reference number of the opened file. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2407,9 +2407,9 @@ pascal OSErr FSpOpenAware(const FSSpec *spec, permErr -54 File is already open and cannot be opened using specified deny modes afpAccessDenied -5000 User does not have the correct access to the file afpDenyConflict -5006 Requested access permission not possible - + __________ - + See also: HOpenAware, HOpenRFAware, FSpOpenRFAware */ @@ -2434,7 +2434,7 @@ pascal OSErr HOpenRFAware(short vRefNum, fileName input: The name of the file. denyModes input: The deny modes access under which to open the file. refNum output: The file reference number of the opened file. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2448,9 +2448,9 @@ pascal OSErr HOpenRFAware(short vRefNum, permErr -54 File is already open and cannot be opened using specified deny modes afpAccessDenied -5000 User does not have the correct access to the file afpDenyConflict -5006 Requested access permission not possible - + __________ - + See also: HOpenAware, FSpOpenAware, FSpOpenRFAware */ @@ -2471,7 +2471,7 @@ pascal OSErr FSpOpenRFAware(const FSSpec *spec, spec input: An FSSpec record specifying the file. denyModes input: The deny modes access under which to open the file. refNum output: The file reference number of the opened file. - + Result Codes noErr 0 No error nsvErr -35 No such volume @@ -2485,9 +2485,9 @@ pascal OSErr FSpOpenRFAware(const FSSpec *spec, permErr -54 File is already open and cannot be opened using specified deny modes afpAccessDenied -5000 User does not have the correct access to the file afpDenyConflict -5006 Requested access permission not possible - + __________ - + See also: HOpenAware, FSpOpenAware, HOpenRFAware */ @@ -2499,13 +2499,13 @@ pascal OSErr FSReadNoCache(short refNum, /* ¶ Read any number of bytes from an open file requesting no caching. The FSReadNoCache function reads any number of bytes from an open file while asking the file system to bypass its cache mechanism. - + refNum input: The file reference number of an open file. count input: The number of bytes to read. output: The number of bytes actually read. buffPtr input: A pointer to the data buffer into which the bytes are to be read. - + Result Codes noErr 0 No error readErr –19 Driver does not respond to read requests @@ -2522,7 +2522,7 @@ pascal OSErr FSReadNoCache(short refNum, the file __________ - + See also: FSWriteNoCache */ @@ -2534,13 +2534,13 @@ pascal OSErr FSWriteNoCache(short refNum, /* ¶ Write any number of bytes to an open file requesting no caching. The FSReadNoCache function writes any number of bytes to an open file while asking the file system to bypass its cache mechanism. - + refNum input: The file reference number of an open file. count input: The number of bytes to write to the file. output: The number of bytes actually written. buffPtr input: A pointer to the data buffer from which the bytes are to be written. - + Result Codes noErr 0 No error writErr –20 Driver does not respond to write requests @@ -2550,20 +2550,20 @@ pascal OSErr FSWriteNoCache(short refNum, nil handle in unit table abortErr –27 Request aborted by KillIO notOpenErr –28 Driver not open - dskFulErr -34 Disk full + dskFulErr -34 Disk full ioErr –36 Data does not match in read-verify mode fnOpnErr -38 File not open - wPrErr -44 Hardware volume lock - fLckdErr -45 File is locked - vLckdErr -46 Software volume lock + wPrErr -44 Hardware volume lock + fLckdErr -45 File is locked + vLckdErr -46 Software volume lock rfNumErr -51 Bad reference number wrPermErr -61 Read/write permission doesn’t - allow writing + allow writing afpAccessDenied -5000 User does not have the correct access to the file __________ - + See also: FSReadNoCache */ @@ -2575,13 +2575,13 @@ pascal OSErr FSWriteVerify(short refNum, /* ¶ Write any number of bytes to an open file and then verify the data was written. The FSWriteVerify function writes any number of bytes to an open file and then verifies that the data was actually written to the device. - + refNum input: The file reference number of an open file. count input: The number of bytes to write to the file. output: The number of bytes actually written and verified. buffPtr input: A pointer to the data buffer from which the bytes are to be written. - + Result Codes noErr 0 No error readErr –19 Driver does not respond to read requests @@ -2592,19 +2592,19 @@ pascal OSErr FSWriteVerify(short refNum, nil handle in unit table abortErr –27 Request aborted by KillIO notOpenErr –28 Driver not open - dskFulErr -34 Disk full + dskFulErr -34 Disk full ioErr –36 Data does not match in read-verify mode fnOpnErr -38 File not open eofErr -39 Logical end-of-file reached posErr -40 Attempt to position mark before start of file - wPrErr -44 Hardware volume lock - fLckdErr -45 File is locked - vLckdErr -46 Software volume lock + wPrErr -44 Hardware volume lock + fLckdErr -45 File is locked + vLckdErr -46 Software volume lock rfNumErr -51 Bad reference number gfpErr -52 Error during GetFPos wrPermErr -61 Read/write permission doesn’t - allow writing + allow writing memFullErr -108 Not enough room in heap zone to allocate verify buffer afpAccessDenied -5000 User does not have the correct access to @@ -2621,14 +2621,14 @@ pascal OSErr CopyFork(short srcRefNum, The CopyFork function copies all data from the source fork to the destination fork of open file forks and makes sure the destination EOF is equal to the source EOF. - + srcRefNum input: The source file reference number. dstRefNum input: The destination file reference number. copyBufferPtr input: Pointer to buffer to use during copy. The buffer should be at least 512-bytes minimum. The larger the buffer, the faster the copy. copyBufferSize input: The size of the copy buffer. - + Result Codes noErr 0 No error readErr –19 Driver does not respond to read requests @@ -2639,15 +2639,15 @@ pascal OSErr CopyFork(short srcRefNum, nil handle in unit table abortErr –27 Request aborted by KillIO notOpenErr –28 Driver not open - dskFulErr -34 Disk full + dskFulErr -34 Disk full ioErr –36 Data does not match in read-verify mode fnOpnErr -38 File not open - wPrErr -44 Hardware volume lock - fLckdErr -45 File is locked - vLckdErr -46 Software volume lock + wPrErr -44 Hardware volume lock + fLckdErr -45 File is locked + vLckdErr -46 Software volume lock rfNumErr -51 Bad reference number wrPermErr -61 Read/write permission doesn’t - allow writing + allow writing afpAccessDenied -5000 User does not have the correct access to the file */ @@ -2668,16 +2668,16 @@ pascal OSErr GetFileLocation(short refNum, fileName input: Points to a buffer (minimum Str63) where the filename is to be returned or must be nil. output: The filename. - + Result Codes noErr 0 No error nsvErr -35 Specified volume doesn’t exist fnOpnErr -38 File not open rfNumErr -51 Reference number specifies nonexistent access path - + __________ - + See also: FSpGetFileLocation */ @@ -2691,16 +2691,16 @@ pascal OSErr FSpGetFileLocation(short refNum, refNum input: The file reference number of an open file. spec output: FSSpec record containing the file name and location. - + Result Codes noErr 0 No error nsvErr -35 Specified volume doesn’t exist fnOpnErr -38 File not open rfNumErr -51 Reference number specifies nonexistent access path - + __________ - + See also: GetFileLocation */ @@ -2716,7 +2716,7 @@ pascal OSErr CopyDirectoryAccess(short srcVRefNum, The CopyDirectoryAccess function copies the AFP directory access privileges from one directory to another. Both directories must be on the same file server, but not necessarily on the same server volume. - + srcVRefNum input: Source volume specification. srcDirID input: Source directory ID. srcName input: Pointer to source directory name, or nil when @@ -2725,7 +2725,7 @@ pascal OSErr CopyDirectoryAccess(short srcVRefNum, dstDirID input: Destination directory ID. dstName input: Pointer to destination directory name, or nil when dstDirID specifies the directory. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -2735,9 +2735,9 @@ pascal OSErr CopyDirectoryAccess(short srcVRefNum, afpAccessDenied -5000 User does not have the correct access to the directory afpObjectTypeErr -5025 Object is a file, not a directory - + __________ - + See also: FSpCopyDirectoryAccess */ @@ -2752,7 +2752,7 @@ pascal OSErr FSpCopyDirectoryAccess(const FSSpec *srcSpec, srcSpec input: An FSSpec record specifying the source directory. dstSpec input: An FSSpec record specifying the destination directory. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -2762,9 +2762,9 @@ pascal OSErr FSpCopyDirectoryAccess(const FSSpec *srcSpec, afpAccessDenied -5000 User does not have the correct access to the directory afpObjectTypeErr -5025 Object is a file, not a directory - + __________ - + See also: CopyDirectoryAccess */ @@ -2780,7 +2780,7 @@ pascal OSErr HMoveRenameCompat(short vRefNum, The HMoveRenameCompat function moves a file or directory and optionally renames it. The source and destination locations must be on the same volume. This routine works even if the volume doesn't support MoveRename. - + vRefNum input: Volume specification. srcDirID input: Source directory ID. srcName input: The source object name. @@ -2789,7 +2789,7 @@ pascal OSErr HMoveRenameCompat(short vRefNum, nil when dstDirID specifies a directory. copyName input: Points to the new name if the object is to be renamed or nil if the object isn't to be renamed. - + Result Codes noErr 0 No error dirFulErr -33 File directory full @@ -2821,9 +2821,9 @@ pascal OSErr HMoveRenameCompat(short vRefNum, move the file or directory afpObjectTypeErr -5025 Directory not found or incomplete pathname afpSameObjectErr -5038 Source and destination files are the same - + __________ - + See also: FSpMoveRenameCompat */ @@ -2836,13 +2836,13 @@ pascal OSErr FSpMoveRenameCompat(const FSSpec *srcSpec, The FSpMoveRenameCompat function moves a file or directory and optionally renames it. The source and destination locations must be on the same volume. This routine works even if the volume doesn't support MoveRename. - + srcSpec input: An FSSpec record specifying the source object. dstSpec input: An FSSpec record specifying the destination directory. copyName input: Points to the new name if the object is to be renamed or nil if the object isn't to be renamed. - + Result Codes noErr 0 No error dirFulErr -33 File directory full @@ -2874,9 +2874,9 @@ pascal OSErr FSpMoveRenameCompat(const FSSpec *srcSpec, move the file or directory afpObjectTypeErr -5025 Directory not found or incomplete pathname afpSameObjectErr -5038 Source and destination files are the same - + __________ - + See also: HMoveRenameCompat */ @@ -2897,7 +2897,7 @@ pascal OSErr BuildAFPVolMountInfo(short flags, The BuildAFPVolMountInfo function allocates and initializes the fields of an AFPVolMountInfo record before using that record to call the VolumeMount function. - + flags input: The AFP mounting flags. 0 = normal mount; set bit 0 to inhibit greeting messages. nbpInterval input: The interval used for VolumeMount's @@ -2921,13 +2921,13 @@ pascal OSErr BuildAFPVolMountInfo(short flags, memFullErr. Your program is responsible for disposing of this pointer when it is finished with it. - + Result Codes noErr 0 No error memFullErr -108 memory full error - + __________ - + Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount, RetrieveAFPVolMountInfo, BuildAFPXVolMountInfo, RetrieveAFPXVolMountInfo @@ -2946,7 +2946,7 @@ pascal OSErr RetrieveAFPVolMountInfo(AFPVolMountInfoPtr afpInfoPtr, The RetrieveAFPVolMountInfo function retrieves the AFP mounting information returned in an AFPVolMountInfo record by the GetVolMountInfo function. - + afpInfoPtr input: Pointer to AFPVolMountInfo record that contains the AFP mounting information. flags output: The AFP mounting flags. @@ -2956,14 +2956,14 @@ pascal OSErr RetrieveAFPVolMountInfo(AFPVolMountInfoPtr afpInfoPtr, volName output: The AFP volume name. userName output: The user name (zero length Pascal string for guest). - + Result Codes noErr 0 No error paramErr -50 media field in AFP mounting information was not AppleShareMediaType - + __________ - + Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount, BuildAFPVolMountInfo, BuildAFPXVolMountInfo, RetrieveAFPXVolMountInfo @@ -2989,7 +2989,7 @@ pascal OSErr BuildAFPXVolMountInfo(short flags, The BuildAFPXVolMountInfo function allocates and initializes the fields of an AFPXVolMountInfo record before using that record to call the VolumeMount function. - + flags input: The AFP mounting flags. nbpInterval input: The interval used for VolumeMount's NBP Lookup call. 7 is a good choice. @@ -3016,13 +3016,13 @@ pascal OSErr BuildAFPXVolMountInfo(short flags, result is memFullErr. Your program is responsible for disposing of this pointer when it is finished with it. - + Result Codes noErr 0 No error memFullErr -108 memory full error - + __________ - + Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount, BuildAFPVolMountInfo, RetrieveAFPVolMountInfo, RetrieveAFPXVolMountInfo @@ -3044,7 +3044,7 @@ pascal OSErr RetrieveAFPXVolMountInfo(AFPXVolMountInfoPtr afpXInfoPtr, The RetrieveAFPXVolMountInfo function retrieves the AFP mounting information returned in an AFPXVolMountInfo record by the GetVolMountInfo function. - + afpXInfoPtr input: Pointer to AFPXVolMountInfo record that contains the AFP mounting information. flags output: The AFP mounting flags. @@ -3064,15 +3064,15 @@ pascal OSErr RetrieveAFPXVolMountInfo(AFPXVolMountInfoPtr afpXInfoPtr, function result is memFullErr. Your program is responsible for disposing of this pointer when it is finished with it. - + Result Codes noErr 0 No error paramErr -50 media field in AFP mounting information was not AppleShareMediaType memFullErr -108 memory full error - + __________ - + Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount, BuildAFPVolMountInfo, RetrieveAFXVolMountInfo, BuildAFPXVolMountInfo @@ -3099,15 +3099,15 @@ pascal OSErr GetUGEntries(short objType, output: The index position to get the next entry. Pass this value the next time you call GetUGEntries to start where you left off. - + Result Codes - noErr 0 No error - fnfErr -43 No more users or groups + noErr 0 No error + fnfErr -43 No more users or groups paramErr -50 Function not supported; or, ioObjID is - negative + negative __________ - + Also see: GetUGEntry */ diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/Optimization.h b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/Optimization.h index 036450e..acb5214 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/Optimization.h +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/Optimization.h @@ -38,7 +38,7 @@ ** ** 2 -- You may disable Pascal calling conventions in all MoreFiles routines ** except for system callbacks that require Pascal calling conventions. -** This will make 68K C programs both smaller and faster. +** This will make 68K C programs both smaller and faster. ** (PowerPC compilers ignore pascal calling conventions.) ** Just define __WANTPASCALELIMINATION to be 1 to turn this optimization on ** when building MoreFiles for use from C programs (you'll need to keep @@ -80,7 +80,7 @@ #endif #if __WANTPASCALELIMINATION - #define pascal + #define pascal #endif diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/PascalElim.h b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/PascalElim.h index fa6449a..909760b 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/PascalElim.h +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/PascalElim.h @@ -21,5 +21,5 @@ #endif #ifdef __WANTPASCALELIMINATION -#define pascal +#define pascal #endif diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/Search.c b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/Search.c index 8d4dee0..564e60a 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/Search.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/Search.c @@ -148,7 +148,7 @@ static void TimeOutTask(void); #endif #if __WANTPASCALELIMINATION -#define pascal +#define pascal #endif static long GetDirModDate(short vRefNum, @@ -199,7 +199,7 @@ static OSErr CheckStack(unsigned short stackDepth, Size *searchStackSize) { OSErr result; - + if ( (*searchStackSize / sizeof(LevelRec)) == (stackDepth + 1) ) { /* Time to grow stack */ @@ -211,7 +211,7 @@ static OSErr CheckStack(unsigned short stackDepth, { result = noErr; } - + return ( result ); } @@ -231,22 +231,22 @@ static OSErr VerifyUserPB(CSParamPtr userPB, { CInfoPBPtr searchInfo1; CInfoPBPtr searchInfo2; - + searchInfo1 = userPB->ioSearchInfo1; searchInfo2 = userPB->ioSearchInfo2; - + /* ioMatchPtr cannot be NULL */ if ( userPB->ioMatchPtr == NULL ) { goto ParamErrExit; } - + /* ioSearchInfo1 cannot be NULL */ if ( searchInfo1 == NULL ) { goto ParamErrExit; } - + /* If any bits except partialName, fullName, or negate are set, then */ /* ioSearchInfo2 cannot be NULL because information in ioSearchInfo2 is required */ if ( ((userPB->ioSearchBits & ~(fsSBPartialName | fsSBFullName | fsSBNegate)) != 0) && @@ -254,11 +254,11 @@ static OSErr VerifyUserPB(CSParamPtr userPB, { goto ParamErrExit; } - + *includeFiles = false; *includeDirs = false; *includeNames = false; - + if ( (userPB->ioSearchBits & (fsSBPartialName | fsSBFullName)) != 0 ) { /* If any kind of name matching is requested, then ioNamePtr in */ @@ -269,10 +269,10 @@ static OSErr VerifyUserPB(CSParamPtr userPB, { goto ParamErrExit; } - + *includeNames = true; } - + if ( (userPB->ioSearchBits & fsSBFlAttrib) != 0 ) { /* The only attributes you can search on are the directory flag */ @@ -281,7 +281,7 @@ static OSErr VerifyUserPB(CSParamPtr userPB, { goto ParamErrExit; } - + /* interested in the directory bit? */ if ( (searchInfo2->hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { @@ -308,7 +308,7 @@ static OSErr VerifyUserPB(CSParamPtr userPB, *includeDirs = true; *includeFiles = true; } - + /* If directories are included in the search, */ /* then the locked attribute cannot be requested. */ if ( *includeDirs && @@ -317,7 +317,7 @@ static OSErr VerifyUserPB(CSParamPtr userPB, { goto ParamErrExit; } - + /* If files are included in the search, then there cannot be */ /* a search on the number of files. */ if ( *includeFiles && @@ -325,7 +325,7 @@ static OSErr VerifyUserPB(CSParamPtr userPB, { goto ParamErrExit; } - + /* If directories are included in the search, then there cannot */ /* be a search on file lengths. */ if ( *includeDirs && @@ -333,9 +333,9 @@ static OSErr VerifyUserPB(CSParamPtr userPB, { goto ParamErrExit; } - + return ( noErr ); - + ParamErrExit: return ( paramErr ); } @@ -354,28 +354,28 @@ static Boolean IsSubString(ConstStr255Param aStringPtr, short subStrLength; /* length of subString */ Boolean found; /* result of test */ short index; /* current index into string */ - + found = false; strLength = aStringPtr[0]; subStrLength = subStringPtr[0]; - + if ( subStrLength <= strLength) { register short count; /* search counter */ register short strIndex; /* running index into string */ register short subStrIndex; /* running index into subString */ - + /* start looking at first character */ index = 1; - + /* continue looking until remaining string is shorter than substring */ count = strLength - subStrLength + 1; - + do { strIndex = index; /* start string index at index */ subStrIndex = 1; /* start subString index at 1 */ - + while ( !found && (aStringPtr[strIndex] == subStringPtr[subStrIndex]) ) { if ( subStrIndex == subStrLength ) @@ -390,7 +390,7 @@ static Boolean IsSubString(ConstStr255Param aStringPtr, ++strIndex; } } - + if ( !found ) { /* start substring search again at next string character */ @@ -399,7 +399,7 @@ static Boolean IsSubString(ConstStr255Param aStringPtr, } } while ( count != 0 && (!found) ); } - + return ( found ); } @@ -417,21 +417,21 @@ static Boolean CompareMasked(const long *data1, short longsToCompare) { Boolean result = true; - + while ( (longsToCompare != 0) && (result == true) ) { /* (*data1 ^ *data2) = bits that are different, so... */ /* ((*data1 ^ *data2) & *mask) = bits that are different that we're interested in */ - + if ( ((*data1 ^ *data2) & *mask) != 0 ) result = false; - + ++data1; ++data2; ++mask; --longsToCompare; } - + return ( result ); } @@ -453,15 +453,15 @@ static void CheckForMatches(CInfoPBPtr cPB, CInfoPBPtr searchInfo2; Str63 itemName; /* copy of object's name for partial name matching */ Boolean foundMatch; - + foundMatch = false; /* default to no match */ - + searchBits = userPB->ioSearchBits; searchInfo1 = userPB->ioSearchInfo1; searchInfo2 = userPB->ioSearchInfo2; - + /* Into the if statements that go on forever... */ - + if ( (cPB->hFileInfo.ioFlAttrib & kioFlAttribDirMask) == 0 ) { if (!includeFiles) @@ -476,7 +476,7 @@ static void CheckForMatches(CInfoPBPtr cPB, goto Failed; } } - + if ( (searchBits & fsSBPartialName) != 0 ) { if ( (cPB->hFileInfo.ioNamePtr[0] > 0) && @@ -493,7 +493,7 @@ static void CheckForMatches(CInfoPBPtr cPB, { goto Failed; } - + { if ( !IsSubString(itemName, matchName) ) { @@ -506,7 +506,7 @@ static void CheckForMatches(CInfoPBPtr cPB, } } } - + if ( (searchBits & fsSBFullName) != 0 ) { /* Use the same non-international call the File Manager uses */ @@ -520,7 +520,7 @@ static void CheckForMatches(CInfoPBPtr cPB, goto Hit; } } - + if ( (searchBits & fsSBFlParID) != 0 ) { if ( ((unsigned long)(cPB->hFileInfo.ioFlParID) < (unsigned long)(searchInfo1->hFileInfo.ioFlParID)) || @@ -529,7 +529,7 @@ static void CheckForMatches(CInfoPBPtr cPB, goto Failed; } } - + if ( (searchBits & fsSBFlAttrib) != 0 ) { if ( ((cPB->hFileInfo.ioFlAttrib ^ searchInfo1->hFileInfo.ioFlAttrib) & @@ -538,7 +538,7 @@ static void CheckForMatches(CInfoPBPtr cPB, goto Failed; } } - + if ( (searchBits & fsSBDrNmFls) != 0 ) { if ( ((unsigned long)(cPB->dirInfo.ioDrNmFls) < (unsigned long)(searchInfo1->dirInfo.ioDrNmFls)) || @@ -558,7 +558,7 @@ static void CheckForMatches(CInfoPBPtr cPB, goto Failed; } } - + if ( (searchBits & fsSBFlXFndrInfo) != 0 ) /* fsSBFlXFndrInfo is same as fsSBDrFndrInfo */ { if ( !CompareMasked((long *)&(cPB->hFileInfo.ioFlXFndrInfo), @@ -569,7 +569,7 @@ static void CheckForMatches(CInfoPBPtr cPB, goto Failed; } } - + if ( (searchBits & fsSBFlLgLen) != 0 ) { if ( ((unsigned long)(cPB->hFileInfo.ioFlLgLen) < (unsigned long)(searchInfo1->hFileInfo.ioFlLgLen)) || @@ -634,7 +634,7 @@ static void CheckForMatches(CInfoPBPtr cPB, } /* Hey, we passed all of the tests! */ - + Hit: foundMatch = true; @@ -645,7 +645,7 @@ static void CheckForMatches(CInfoPBPtr cPB, { foundMatch = !foundMatch; /* matches are not, not matches are */ } - + if ( foundMatch ) { @@ -659,7 +659,7 @@ static void CheckForMatches(CInfoPBPtr cPB, BlockMoveData(cPB->hFileInfo.ioNamePtr, userPB->ioMatchPtr[userPB->ioActMatchCount].name, cPB->hFileInfo.ioNamePtr[0] + 1); - + /* increment the actual count */ ++(userPB->ioActMatchCount); } @@ -689,7 +689,7 @@ static pascal void TimeOutTask(TMTaskPtr tmTaskPtr) static pascal TMTaskPtr GetTMTaskPtr(void) ONEWORDINLINE(0x2e89); /* MOVE.L A1,(SP) */ - + static void TimeOutTask(void) { ((ExtendedTMTaskPtr)GetTMTaskPtr())->stopSearch = true; @@ -698,7 +698,7 @@ static void TimeOutTask(void) #endif #if __WANTPASCALELIMINATION -#define pascal +#define pascal #endif /*****************************************************************************/ @@ -721,7 +721,7 @@ static long GetDirModDate(short vRefNum, pb.dirInfo.ioVRefNum = vRefNum; pb.dirInfo.ioDrDirID = dirID; pb.dirInfo.ioFDirIndex = -1; /* use ioDrDirID */ - + if ( PBGetCatInfoSync(&pb) == noErr ) { modDate = pb.dirInfo.ioDrMdDat; @@ -730,7 +730,7 @@ static long GetDirModDate(short vRefNum, { modDate = -1; } - + return ( modDate ); } @@ -754,9 +754,9 @@ pascal OSErr IndexedSearch(CSParamPtr pb, Boolean includeDirs; Boolean includeNames; Str63 upperName; - + timerTask.stopSearch = false; /* don't stop yet! */ - + /* If request has a timeout, install a Time Manager task. */ if ( pb->ioSearchTime != 0 ) { @@ -765,7 +765,7 @@ pascal OSErr IndexedSearch(CSParamPtr pb, InsTime((QElemPtr)&(timerTask.theTask)); PrimeTime((QElemPtr)&(timerTask.theTask), pb->ioSearchTime); } - + /* Check the parameter block passed for things that we don't want to assume */ /* are OK later in the code. For example, make sure pointers to data structures */ /* and buffers are not NULL. And while we're in there, see if the request */ @@ -775,7 +775,7 @@ pascal OSErr IndexedSearch(CSParamPtr pb, if ( result == noErr ) { pb->ioActMatchCount = 0; /* no matches yet */ - + if ( includeNames ) { /* The search includes seach by full or partial name. */ @@ -787,33 +787,33 @@ pascal OSErr IndexedSearch(CSParamPtr pb, /* Use the same non-international call the File Manager uses */ UpperString(upperName, true); } - + /* Prevent casting to my type throughout code */ catPosition = (SearchPositionRecPtr)&pb->ioCatPosition; - + /* Create searchStack first time called */ if ( searchStack == NULL ) { searchStack = (LevelRecHandle)NewHandle(kAdditionalLevelRecs * sizeof(LevelRec)); } - + /* Make sure searchStack really exists */ if ( searchStack != NULL ) { searchStackSize = GetHandleSize((Handle)searchStack); - + /* See if the search is a new search or a resumed search. */ if ( catPosition->initialize == 0 ) { /* New search. */ - - /* Get the real vRefNum and fill in catPosition->initialize. */ + + /* Get the real vRefNum and fill in catPosition->initialize. */ result = CheckVol(pb->ioNamePtr, pb->ioVRefNum, &realVRefNum, &catPosition->initialize); if ( result == noErr ) { /* clear searchStack */ catPosition->stackDepth = 0; - + /* use dirID parameter passed and... */ index = -1; /* start with the passed directory itself! */ } @@ -821,8 +821,8 @@ pascal OSErr IndexedSearch(CSParamPtr pb, else { /* We're resuming a search. */ - - /* Get the real vRefNum and make sure catPosition->initialize is valid. */ + + /* Get the real vRefNum and make sure catPosition->initialize is valid. */ result = CheckVol(pb->ioNamePtr, pb->ioVRefNum, &realVRefNum, &tempLong); if ( result == noErr ) { @@ -834,11 +834,11 @@ pascal OSErr IndexedSearch(CSParamPtr pb, { /* Position catPosition->stackDepth to access last saved level */ --(catPosition->stackDepth); - + /* Get the dirID and index for the next item */ dirID = (*searchStack)[catPosition->stackDepth].dirID; index = (*searchStack)[catPosition->stackDepth].index; - + /* Check the dir's mod date against the saved mode date on our "stack" */ modDate = GetDirModDate(realVRefNum, dirID); if ( modDate != (*searchStack)[catPosition->stackDepth].dirModDate ) @@ -859,13 +859,13 @@ pascal OSErr IndexedSearch(CSParamPtr pb, } } } - + if ( result == noErr ) { /* ioNamePtr and ioVRefNum only need to be set up once. */ cPB.hFileInfo.ioNamePtr = itemName; cPB.hFileInfo.ioVRefNum = realVRefNum; - + /* ** Here's the loop that: ** Finds the next item on the volume. @@ -893,14 +893,14 @@ pascal OSErr IndexedSearch(CSParamPtr pb, if ( result == noErr ) { /* We found something */ - + CheckForMatches(&cPB, pb, upperName, includeFiles, includeDirs); - + ++index; if ( (cPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* It's a directory */ - + result = CheckStack(catPosition->stackDepth, searchStack, &searchStackSize); if ( result == noErr ) { @@ -909,10 +909,10 @@ pascal OSErr IndexedSearch(CSParamPtr pb, (*searchStack)[catPosition->stackDepth].dirID = dirID; (*searchStack)[catPosition->stackDepth].index = index; (*searchStack)[catPosition->stackDepth].dirModDate = GetDirModDate(realVRefNum, dirID); - + /* position catPosition->stackDepth for next saved level */ ++(catPosition->stackDepth); - + /* The next item to get is the 1st item in the child directory */ dirID = cPB.dirInfo.ioDrDirID; index = 1; @@ -930,10 +930,10 @@ pascal OSErr IndexedSearch(CSParamPtr pb, { /* position catPosition->stackDepth to access last saved level */ --(catPosition->stackDepth); - + dirID = (*searchStack)[catPosition->stackDepth].dirID; index = (*searchStack)[catPosition->stackDepth].index; - + /* Check the dir's mod date against the saved mode date on our "stack" */ modDate = GetDirModDate(realVRefNum, dirID); if ( modDate != (*searchStack)[catPosition->stackDepth].dirModDate ) @@ -963,9 +963,9 @@ pascal OSErr IndexedSearch(CSParamPtr pb, if ( result == noErr ) { /* We found something */ - + CheckForMatches(&cPB, pb, upperName, includeFiles, includeDirs); - + /* Now, set the index to 1 and then we're ready to look inside */ /* the passed directory. */ index = 1; @@ -974,7 +974,7 @@ pascal OSErr IndexedSearch(CSParamPtr pb, } while ( (!timerTask.stopSearch) && /* timer hasn't fired */ (result == noErr) && /* no unexpected errors */ (pb->ioReqMatchCount > pb->ioActMatchCount) ); /* we haven't found our limit */ - + /* Did we drop out of the loop because of timeout or */ /* ioReqMatchCount was found? */ if ( result == noErr ) @@ -984,13 +984,13 @@ pascal OSErr IndexedSearch(CSParamPtr pb, { /* Either there was a timeout or ioReqMatchCount was reached. */ /* Save the dirID and index for the next time we're called. */ - + (*searchStack)[catPosition->stackDepth].dirID = dirID; (*searchStack)[catPosition->stackDepth].index = index; (*searchStack)[catPosition->stackDepth].dirModDate = GetDirModDate(realVRefNum, dirID); - + /* position catPosition->stackDepth for next saved level */ - + ++(catPosition->stackDepth); } } @@ -1002,14 +1002,14 @@ pascal OSErr IndexedSearch(CSParamPtr pb, result = memFullErr; } } - + if ( pb->ioSearchTime != 0 ) { /* Stop Time Manager task here if it was installed */ RmvTime((QElemPtr)&(timerTask.theTask)); DisposeTimerUPP(timerTask.theTask.tmAddr); } - + return ( result ); } @@ -1026,7 +1026,7 @@ pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock) static Boolean hasFullExtFSDispatching = false; long response; #endif - + result = noErr; #if !__MACOSSEVENORLATER @@ -1042,7 +1042,7 @@ pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock) } } #endif - + /* CatSearch is a per volume attribute, so we have to check each time we're */ /* called to see if it is available on the volume specified. */ supportsCatSearch = false; @@ -1058,7 +1058,7 @@ pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock) supportsCatSearch = hasCatSearch(volParmsInfo); } } - + /* noErr or paramErr is OK here. */ /* paramErr just means that GetVolParms isn't supported by this volume */ if ( (result == noErr) || (result == paramErr) ) @@ -1076,7 +1076,7 @@ pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock) result = IndexedSearch(paramBlock, fsRtDirID); } } - + return ( result ); } @@ -1096,12 +1096,12 @@ pascal OSErr NameFileSearch(ConstStr255Param volName, OSErr error; static CatPositionRec catPosition; static short lastVRefNum = 0; - + /* get the real volume reference number */ error = DetermineVRefNum(volName, vRefNum, &vRefNum); if ( error != noErr ) return ( error ); - + pb.csParam.ioNamePtr = NULL; pb.csParam.ioVRefNum = vRefNum; pb.csParam.ioMatchPtr = matches; @@ -1128,13 +1128,13 @@ pascal OSErr NameFileSearch(ConstStr255Param volName, /* search for fileName */ searchInfo1.hFileInfo.ioNamePtr = (StringPtr)fileName; searchInfo2.hFileInfo.ioNamePtr = NULL; - + /* only match files (not directories) */ searchInfo1.hFileInfo.ioFlAttrib = 0x00; searchInfo2.hFileInfo.ioFlAttrib = kioFlAttribDirMask; error = PBCatSearchSyncCompat((CSParamPtr)&pb); - + if ( (error == noErr) || /* If no errors or the end of catalog was */ (error == eofErr) ) /* found, then the call was successful so */ { @@ -1144,7 +1144,7 @@ pascal OSErr NameFileSearch(ConstStr255Param volName, { *actMatchCount = 0; /* else no matches found */ } - + if ( (error == noErr) || /* If no errors */ (error == catChangedErr) ) /* or there was a change in the catalog */ { @@ -1157,12 +1157,12 @@ pascal OSErr NameFileSearch(ConstStr255Param volName, catPosition.initialize = 0; /* start the next search from beginning of catalog */ } - + if ( pb.csParam.ioOptBuffer != NULL ) { DisposePtr(pb.csParam.ioOptBuffer); } - + return ( error ); } @@ -1182,12 +1182,12 @@ pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, OSErr error; static CatPositionRec catPosition; static short lastVRefNum = 0; - + /* get the real volume reference number */ error = DetermineVRefNum(volName, vRefNum, &vRefNum); if ( error != noErr ) return ( error ); - + pb.csParam.ioNamePtr = NULL; pb.csParam.ioVRefNum = vRefNum; pb.csParam.ioMatchPtr = matches; @@ -1207,11 +1207,11 @@ pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, /* no fileName */ searchInfo1.hFileInfo.ioNamePtr = NULL; searchInfo2.hFileInfo.ioNamePtr = NULL; - + /* only match files (not directories) */ searchInfo1.hFileInfo.ioFlAttrib = 0x00; searchInfo2.hFileInfo.ioFlAttrib = kioFlAttribDirMask; - + /* search for creator; if creator = 0x00000000, ignore creator */ searchInfo1.hFileInfo.ioFlFndrInfo.fdCreator = creator; if ( creator == (OSType)0x00000000 ) @@ -1222,7 +1222,7 @@ pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, { searchInfo2.hFileInfo.ioFlFndrInfo.fdCreator = (OSType)0xffffffff; } - + /* search for fileType; if fileType = 0x00000000, ignore fileType */ searchInfo1.hFileInfo.ioFlFndrInfo.fdType = fileType; if ( fileType == (OSType)0x00000000 ) @@ -1233,20 +1233,20 @@ pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, { searchInfo2.hFileInfo.ioFlFndrInfo.fdType = (OSType)0xffffffff; } - + /* zero all other FInfo fields */ searchInfo1.hFileInfo.ioFlFndrInfo.fdFlags = 0; searchInfo1.hFileInfo.ioFlFndrInfo.fdLocation.v = 0; searchInfo1.hFileInfo.ioFlFndrInfo.fdLocation.h = 0; searchInfo1.hFileInfo.ioFlFndrInfo.fdFldr = 0; - + searchInfo2.hFileInfo.ioFlFndrInfo.fdFlags = 0; searchInfo2.hFileInfo.ioFlFndrInfo.fdLocation.v = 0; searchInfo2.hFileInfo.ioFlFndrInfo.fdLocation.h = 0; searchInfo2.hFileInfo.ioFlFndrInfo.fdFldr = 0; error = PBCatSearchSyncCompat((CSParamPtr)&pb); - + if ( (error == noErr) || /* If no errors or the end of catalog was */ (error == eofErr) ) /* found, then the call was successful so */ { @@ -1256,7 +1256,7 @@ pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, { *actMatchCount = 0; /* else no matches found */ } - + if ( (error == noErr) || /* If no errors */ (error == catChangedErr) ) /* or there was a change in the catalog */ { @@ -1269,12 +1269,12 @@ pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, catPosition.initialize = 0; /* start the next search from beginning of catalog */ } - + if ( pb.csParam.ioOptBuffer != NULL ) { DisposePtr(pb.csParam.ioOptBuffer); } - + return ( error ); } diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/Search.h b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/Search.h index c2a8c70..f94d0e9 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/Search.h +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_MacOS/MoreFiles/Search.h @@ -40,7 +40,7 @@ pascal OSErr IndexedSearch(CSParamPtr pb, specified directory using the same parameters (in pb) as is passed to PBCatSearch. See Inside Macintosh: Files for a description of the parameter block. - + pb input: A CSParamPtr record specifying the volume to search and the search criteria. output: Fields in the parameter block are returned indicating @@ -50,13 +50,13 @@ pascal OSErr IndexedSearch(CSParamPtr pb, off. dirID input: The directory to search. If fsRtDirID is passed, the entire volume is searched. - + Note: If you use a high-level debugger and use ioSearchTime to limit the length of time to run the search, you'll want to step over calls to IndexedSearch because it installs a Time Manager task. Most high-level debuggers don't deal gracefully with interrupt driven code. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -70,9 +70,9 @@ pascal OSErr IndexedSearch(CSParamPtr pb, memFullErr -108 Memory could not be allocated in heap catChangedErr -1304 Catalog has changed and catalog position record may be invalid - + __________ - + See also: PBCatSearch, PBCatSearchSyncCompat */ @@ -84,7 +84,7 @@ pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock); IndexedSearch (if PBCatSearch is not available) to search a volume using a set of search criteria that you specify. It builds a list of all files or directories that meet your specifications. - + pb input: A CSParamPtr record specifying the volume to search and the search criteria. output: Fields in the parameter block are returned indicating @@ -92,13 +92,13 @@ pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock); search ended with noErr, the CatPosition record that lets you resume a search where the last search left off. - + Note: If you use a high-level debugger and use ioSearchTime to limit the length of time to run the search, you'll want to step over calls to PBCatSearchSyncCompat because it calls IndexedSearch which installs a Time Manager task. Most high-level debuggers don't deal gracefully with interrupt driven code. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -114,9 +114,9 @@ pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock); record may be invalid afpCatalogChanged -5037 Catalog has changed and search cannot be resumed - + __________ - + See also: PBCatSearch, IndexedSearch */ @@ -155,7 +155,7 @@ pascal OSErr NameFileSearch(ConstStr255Param volName, that exactly match fileName will be found. If the partial parameter is true, then all file names that contain fileName will be found. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -171,9 +171,9 @@ pascal OSErr NameFileSearch(ConstStr255Param volName, record may be invalid afpCatalogChanged -5037 Catalog has changed and search cannot be resumed - + __________ - + Also see: CreatorTypeFileSearch */ @@ -213,7 +213,7 @@ pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, vRefNum is the same as the last call to CreatorTypeFileSearch, then start searching at the position where the last search left off. - + Result Codes noErr 0 No error nsvErr -35 Volume not found @@ -229,9 +229,9 @@ pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, record may be invalid afpCatalogChanged -5037 Catalog has changed and search cannot be resumed - + __________ - + Also see: NameFileSearch */ diff --git a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_Win32/BFW_FileManager_Win32.c b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_Win32/BFW_FileManager_Win32.c index 6317e5f..db38c58 100644 --- a/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_Win32/BFW_FileManager_Win32.c +++ b/BungieFrameWork/BFW_Source/BFW_FileManager/Platform_Win32/BFW_FileManager_Win32.c @@ -1,13 +1,13 @@ /* FILE: BFW_FileManager_Win32.c - + AUTHOR: Brent H. Pease - + CREATED: June 28, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -18,7 +18,7 @@ #include #include -#include +#include #include //#include @@ -89,7 +89,7 @@ static const char *WindowsErrorToString(DWORD error) case ERROR_GEN_FAILURE: error_msg = "a deviced attached to the system is not functioning"; break; case ERROR_SHARING_VIOLATION: error_msg = "cannot access the file, in use by anther process"; break; case ERROR_LOCK_VIOLATION: error_msg = "another process has locked a portion of the file"; break; - case ERROR_WRONG_DISK: error_msg = "the wrong diskette is in the drive"; break; + case ERROR_WRONG_DISK: error_msg = "the wrong diskette is in the drive"; break; case ERROR_SHARING_BUFFER_EXCEEDED: error_msg = "too many file opened for sharing"; break; case ERROR_HANDLE_EOF: error_msg = "reached the end of file"; break; case ERROR_HANDLE_DISK_FULL: error_msg = "the disk is full"; break; @@ -107,23 +107,23 @@ BFiFileRef_PathNameExists( char buffer[BFcMaxPathLength]; char* bufferLeafName; DWORD attributes; - + UUrString_Copy(buffer, inPath, BFcMaxPathLength); - + bufferLeafName = BFrPath_To_Name(buffer); - + if(bufferLeafName > buffer) { *bufferLeafName = 0; - + attributes = GetFileAttributes(buffer); - + if(attributes == 0xFFFFFFFF) { return UUcFalse; } } - + return UUcTrue; } @@ -133,18 +133,18 @@ BFiCheckFileName( const char *inFileName) { const char *name; - + name = inFileName; - + while (*name) { if (name[0] == '/') { char illegal_char[2]; - + illegal_char[0] = name[0]; illegal_char[1] = '\0'; - + UUmError_ReturnOnErrorMsgP( UUcError_Generic, "Illegal character %s in file name.", @@ -152,10 +152,10 @@ BFiCheckFileName( 0, 0); } - + name++; } - + return UUcError_None; } @@ -165,10 +165,10 @@ BFrFileRef_Set( const char* inFileName) // like make from name but does not create { UUtError error; - + UUmAssert(NULL != inFileRef); UUmAssert(NULL != inFileName); - + if(strlen(inFileName) >= BFcMaxPathLength) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Path name too long"); @@ -177,17 +177,17 @@ BFrFileRef_Set( /* Make sure the path name is valid */ error = BFiCheckFileName(inFileName); UUmError_ReturnOnError(error); - + if(BFiFileRef_PathNameExists(inFileName) == UUcFalse) { return BFcError_FileNotFound; } - + UUrString_Copy(inFileRef->name, inFileName, BFcMaxPathLength); - + { char *leaf_name = BFrPath_To_Name(inFileRef->name); - + if(strlen(leaf_name) >= BFcMaxFileNameLength) { UUmError_ReturnOnErrorMsgP( @@ -196,7 +196,7 @@ BFrFileRef_Set( (UUtUns32)leaf_name, BFcMaxFileNameLength-1, 0); } } - + return UUcError_None; } @@ -204,11 +204,11 @@ void BFrFileRef_Dispose( BFtFileRef *inFileRef) { - + UUmAssert(inFileRef != NULL); - + UUrMemory_Block_Delete(inFileRef); - + } UUtError @@ -217,17 +217,17 @@ BFrFileRef_Duplicate( BFtFileRef **outNewFileRef) { UUtError error; - + UUmAssert(inOrigFileRef != NULL); UUmAssert(outNewFileRef != NULL); - + error = BFrFileRef_MakeFromName( inOrigFileRef->name, outNewFileRef); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -246,7 +246,7 @@ BFrFileRef_GetLeafName( const char * BFrFileRef_GetFullPath( const BFtFileRef* inFileRef) -{ +{ return inFileRef->name; } @@ -262,10 +262,10 @@ BFrFileRef_SetName( UUmAssert(inFileRef != NULL); UUmAssert(inName != NULL); - + error = BFiCheckFileName(inName); UUmError_ReturnOnError(error); - + if (BFrPath_IsAbsolute(inName)) { if(strlen(inName) >= BFcMaxPathLength) @@ -285,7 +285,7 @@ BFrFileRef_SetName( UUrString_Copy(leaf_name, inName, BFcMaxPathLength); } - + { char *leaf_name = BFrPath_To_Name(inFileRef->name); @@ -297,12 +297,12 @@ BFrFileRef_SetName( (UUtUns32)leaf_name, BFcMaxFileNameLength-1, 0); } } - + if(BFiFileRef_PathNameExists(inFileRef->name) == UUcFalse) { return BFcError_FileNotFound; } - + return UUcError_None; } @@ -311,14 +311,14 @@ BFrFileRef_FileExists( BFtFileRef *inFileRef) { DWORD attributes; - + attributes = GetFileAttributes(inFileRef->name); - + if(attributes == 0xFFFFFFFF) { return UUcFalse; } - + return UUcTrue; } @@ -327,21 +327,21 @@ BFrFile_Create( BFtFileRef *inFileRef) { FILE *file; - + UUmAssert(inFileRef != NULL); UUmAssert(inFileRef->name[0] != '\0'); remove(inFileRef->name); - + file = fopen(inFileRef->name, "wb"); - + if(file == NULL) { return UUcError_Generic; //XXX } - + fclose(file); - + return UUcError_None; } @@ -364,12 +364,12 @@ BFrFile_Open( { char *mungedMode; DWORD dwDesiredAccess; - + UUmAssert(inFileRef != NULL); UUmAssert(inFileRef->name[0] != '\0'); UUmAssert(inMode != NULL); UUmAssert(outFile != NULL); - + if(!strcmp("r", inMode)) { mungedMode = "rb"; @@ -389,7 +389,7 @@ BFrFile_Open( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Illegal file mode"); } - + *outFile = (BFtFile *) fopen(inFileRef->name, mungedMode); if(*outFile == NULL) @@ -410,7 +410,7 @@ BFrFile_Open( fileHandle = CreateFile( inFileRef->name, dwDesiredAccess, - FILE_SHARE_READ, + FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, @@ -425,10 +425,10 @@ BFrFile_Open( CloseHandle(fileHandle); } #endif - + return BFcError_FileNotFound; } - + return UUcError_None; } @@ -448,8 +448,8 @@ BFrFile_Map( BFtFileMapping *mapping; mapping = UUrMemory_Block_New(sizeof(BFtFileMapping)); - if (NULL == mapping) { - error = UUcError_OutOfMemory; + if (NULL == mapping) { + error = UUcError_OutOfMemory; goto fail; } @@ -504,8 +504,8 @@ BFrFile_Map_Default( BFtFileMapping *mappingRef; mappingRef = UUrMemory_Block_New(sizeof(BFtFileMapping)); - if (NULL == mappingRef) { - error = UUcError_OutOfMemory; + if (NULL == mappingRef) { + error = UUcError_OutOfMemory; goto fail; } @@ -554,8 +554,8 @@ BFrFile_Map( UUmAssertWritePtr(outPtr, sizeof(*outPtr)); mappingRef = UUrMemory_Block_New(sizeof(BFtFileMapping)); - if (NULL == mappingRef) { - error = UUcError_OutOfMemory; + if (NULL == mappingRef) { + error = UUcError_OutOfMemory; goto fail; } @@ -563,7 +563,7 @@ BFrFile_Map( fileHandle = CreateFile( inFileRef->name, GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ, + FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, @@ -574,7 +574,7 @@ BFrFile_Map( fileHandle = CreateFile( inFileRef->name, GENERIC_READ, - FILE_SHARE_READ, + FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, @@ -594,7 +594,7 @@ BFrFile_Map( error = UUcError_Generic; goto fail; } - + fileMappingHandle = CreateFileMapping( fileHandle, NULL, @@ -603,12 +603,12 @@ BFrFile_Map( 0, NULL); - if ((fileMappingHandle != NULL) && (GetLastError() == ERROR_ALREADY_EXISTS)) - { + if ((fileMappingHandle != NULL) && (GetLastError() == ERROR_ALREADY_EXISTS)) + { error = UUcError_Generic; goto fail; - } - + } + if (NULL == fileMappingHandle) { win32Error = GetLastError(); error_msg = WindowsErrorToString(win32Error); @@ -661,16 +661,16 @@ BFrFile_UnMap( BOOL unmapResult; UUmAssertReadPtr(inMapping, sizeof(*inMapping)); - if (NULL != inMapping->fileMappingHandle) + if (NULL != inMapping->fileMappingHandle) { UUmAssert(NULL == inMapping->classicFile); unmapResult = UnmapViewOfFile(inMapping->ptr); UUmAssert(unmapResult); - + CloseHandle(inMapping->fileMappingHandle); - CloseHandle(inMapping->fileHandle); - + CloseHandle(inMapping->fileHandle); + UUrMemory_Block_Delete(inMapping); } else @@ -696,7 +696,7 @@ BFrFile_Flush( UUmAssert(NULL != inFile); fflush((FILE *)inFile); - + return UUcError_None; } @@ -707,7 +707,7 @@ BFrFile_Close( UUmAssert(NULL != inFile); fclose((FILE *)inFile); - + } UUtBool @@ -715,7 +715,7 @@ BFrFileRef_IsDirectory( BFtFileRef* inFileRef) { DWORD attributes; - + // is this a file reference to a directory // routine returns UUcTrue if file ref is a directory attributes = GetFileAttributes(inFileRef->name); @@ -729,10 +729,10 @@ BFrFileRef_IsEqual( { UUtInt32 result; UUtBool equal; - + result = UUrString_Compare_NoCase(inFileRef1->name, inFileRef2->name); equal = (result == 0); - + return equal; } @@ -741,20 +741,20 @@ BFrFileRef_IsLocked( BFtFileRef* inFileRef) { DWORD attributes; - + // do we have write access to the file? // routine returns UUcTrue if file is locked attributes = GetFileAttributes(inFileRef->name); return ((attributes & FILE_ATTRIBUTE_READONLY) != 0); } - + UUtError BFrFile_GetLength( BFtFile *inFile, UUtUns32 *outLength) { fpos_t currentPos; - + UUmAssert(NULL != inFile); UUmAssert(NULL != outLength); @@ -762,19 +762,19 @@ BFrFile_GetLength( { UUmError_ReturnOnError(UUcError_Generic); } - + if(fseek((FILE *)inFile, 0, SEEK_END) != 0) { UUmError_ReturnOnError(UUcError_Generic); } - + *outLength = ftell((FILE *)inFile); - + if(fsetpos((FILE *)inFile, ¤tPos) != 0) { UUmError_ReturnOnError(UUcError_Generic); } - + return UUcError_None; } @@ -787,7 +787,7 @@ BFrFile_GetPos( UUmAssertWritePtr(outPos, sizeof(UUtUns32)); *outPos = ftell((FILE *) inFile); - + return UUcError_None; } @@ -812,7 +812,7 @@ BFrFile_SetPos( return error; } - + UUtError BFrFile_Read( BFtFile *inFile, @@ -848,11 +848,11 @@ BFrFile_Write( UUmAssert(NULL != inFile); UUmAssert((NULL != inData) || (0 == inLength)); - + count = fwrite(inData, 1, inLength, (FILE *)inFile); error = (count == inLength) ? UUcError_None : UUcError_Generic; - + return UUcError_None; } @@ -876,7 +876,7 @@ BFrFileRef_GetModTime( fileHandle = CreateFile(inFileRef->name, 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0 ,0); - if (INVALID_HANDLE_VALUE == fileHandle) + if (INVALID_HANDLE_VALUE == fileHandle) { DWORD windowsErrorCode = GetLastError(); error_msg = WindowsErrorToString(windowsErrorCode); @@ -887,7 +887,7 @@ BFrFileRef_GetModTime( CloseHandle(fileHandle); - if (!success) + if (!success) { UUmError_ReturnOnError(UUcError_Generic); } @@ -896,7 +896,7 @@ BFrFileRef_GetModTime( FileTimeToSystemTime(&lastWriteTimeLocal, &systemTime); *outSecsSince1900 = UUrSystemToSecsSince1900(systemTime); - + return UUcError_None; } @@ -916,9 +916,9 @@ iCheckFileNameValid( { return UUcFalse; } - + } - + if(inSuffix != NULL) { // Check for suffix match @@ -927,7 +927,7 @@ iCheckFileNameValid( return UUcFalse; } } - + return UUcTrue; } @@ -944,11 +944,11 @@ BFrDirectory_GetFileList( HANDLE fileHandle; WIN32_FIND_DATA curFindData; char* fileName; - + UUtUns32 curFileIndex; char fullFilePath[1024]; - + AUtSharedStringArray* stringArray; UUtUns32 num; UUtUns32* sortedIndexList; @@ -956,46 +956,46 @@ BFrDirectory_GetFileList( UUtUns32 itr; BFtFileRef* newFileRef; UUtUns32 newIndex; - + sprintf(fullFilePath, "%s\\*.*", inDirectoryRef->name); fileHandle = FindFirstFile(fullFilePath, &curFindData); - + *outNumFiles = 0; - + curFileIndex = 0; - + stringArray = AUrSharedStringArray_New(); if(fileHandle == INVALID_HANDLE_VALUE) { return UUcError_None; } - + do { fileName = curFindData.cFileName; - + if(iCheckFileNameValid(fileName, inPrefix, inSuffix) == UUcFalse) { continue; } - + if(curFileIndex >= inMaxFiles) { break; } - + // make a new file ref sprintf(fullFilePath, "%s\\%s", inDirectoryRef->name, fileName); - error = + error = BFrFileRef_MakeFromName( fullFilePath, &newFileRef); UUmError_ReturnOnErrorMsg(error, "Could not create file ref"); - - error = + + error = AUrSharedStringArray_AddString( stringArray, fileName, @@ -1004,24 +1004,24 @@ BFrDirectory_GetFileList( UUmError_ReturnOnErrorMsg(error, "Could not add file ref"); curFileIndex++; - + } while((FindNextFile(fileHandle, &curFindData) == TRUE)); - + FindClose(fileHandle); - + *outNumFiles = (UUtUns16)curFileIndex; - + num = AUrSharedStringArray_GetNum(stringArray); UUmAssert(curFileIndex == num); - + strings = AUrSharedStringArray_GetList(stringArray); sortedIndexList = AUrSharedStringArray_GetSortedIndexList(stringArray); - + for(itr = 0; itr < num; itr++) { outFileRefArray[itr] = (BFtFileRef*)strings[sortedIndexList[itr]].data; } - + AUrSharedStringArray_Delete(stringArray); return UUcError_None; @@ -1033,7 +1033,7 @@ struct BFtFileIterator HANDLE fileHandle; WIN32_FIND_DATA curFindData; - + char* prefix; char* suffix; @@ -1058,7 +1058,7 @@ BFrDirectory_FileIterator_New( { return UUcError_OutOfMemory; } - + newFileIterator->fileRef = *inDirectoryRef; newFileIterator->fileHandle = NULL; newFileIterator->prefix = inPrefix; @@ -1067,9 +1067,9 @@ BFrDirectory_FileIterator_New( if( inDirectoryRef->name[strlen(inDirectoryRef->name) - 1] != '\\' ) { sprintf(newFileIterator->fileRef.name, "%s\\", inDirectoryRef->name); } - + *outFileIterator = newFileIterator; - + return UUcError_None; } @@ -1080,9 +1080,9 @@ BFrDirectory_FileIterator_Next( { WIN32_FIND_DATA curFindData; UUtBool stop; - + UUmAssert(inFileIterator->fileRef.name[ strlen( inFileIterator->fileRef.name)-1 ] == '\\'); - + if(inFileIterator->fileHandle == NULL) { char fullFilePath[1024]; @@ -1090,31 +1090,31 @@ BFrDirectory_FileIterator_Next( sprintf(fullFilePath, "%s*.*", inFileIterator->fileRef.name); inFileIterator->fileHandle = FindFirstFile(fullFilePath, &curFindData); - + if(inFileIterator->fileHandle == INVALID_HANDLE_VALUE) { return UUcError_Generic; } - + stop = UUcFalse; } else { stop = FindNextFile(inFileIterator->fileHandle, &curFindData) == FALSE; } - + while(!stop) { if(iCheckFileNameValid(curFindData.cFileName, inFileIterator->prefix, inFileIterator->suffix)) - { + { sprintf(outFileRef->name, "%s%s", inFileIterator->fileRef.name, curFindData.cFileName); - + return UUcError_None; } stop = FindNextFile(inFileIterator->fileHandle, &curFindData) == FALSE; } - + return UUcError_Generic; } @@ -1143,17 +1143,17 @@ BFrDirectory_DeleteContentsOnly( NULL, &fileIterator); UUmError_ReturnOnError(error); - + while(1) { error = BFrDirectory_FileIterator_Next(fileIterator, &curFileRefToDelete); if(error != UUcError_None) break; - - + + attributes = GetFileAttributes(curFileRefToDelete.name); - + UUmAssert(attributes != 0xFFFFFFFF); - + if(attributes & FILE_ATTRIBUTE_DIRECTORY) { BFrDirectory_DeleteDirectoryAndContents(&curFileRefToDelete); @@ -1163,7 +1163,7 @@ BFrDirectory_DeleteContentsOnly( BFrFile_Delete(&curFileRefToDelete); } } - + BFrDirectory_FileIterator_Delete(fileIterator); return UUcError_None; @@ -1206,7 +1206,7 @@ BFrDirectory_Create( sprintf(buffer, "%s\\%s", inDirRef->name, inDirName); success = CreateDirectory(buffer, NULL); } - + if(success == UUcFalse) return UUcError_Generic; return UUcError_None; @@ -1220,26 +1220,26 @@ BFrFileRef_GetParentDirectory( UUtError error; char path[BFcMaxPathLength]; char *last_dir; - + UUmAssert(inFileRef); UUmAssert(outParentDirectory); - + // initialize *outParentDirectory = NULL; - + UUrString_Copy(path, inFileRef->name, BFcMaxPathLength); - + last_dir = strrchr(path, '\\'); if (last_dir == NULL) { return UUcError_Generic; } last_dir[0] = '\0'; - + // create the texture directory file ref error = BFrFileRef_MakeFromName(path, outParentDirectory); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Group/BFW_Group.c b/BungieFrameWork/BFW_Source/BFW_Group/BFW_Group.c index ee7fd8d..746be36 100644 --- a/BungieFrameWork/BFW_Source/BFW_Group/BFW_Group.c +++ b/BungieFrameWork/BFW_Source/BFW_Group/BFW_Group.c @@ -1,12 +1,12 @@ /* FILE: BFW_Group.c - + AUTHOR: Brent H. Pease - + CREATED: Dec 17, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -23,7 +23,7 @@ typedef enum GRtToken { GReToken_None, - + GReToken_BracketLeft, GReToken_BracketRight, GReToken_CurlyLeft, @@ -32,35 +32,35 @@ typedef enum GRtToken GReToken_String, GReToken_Equal, GReToken_Identifier, - + GReToken_EOF - + } GRtToken; typedef struct GRtElement { GRtElementType type; - + union { char* value; GRtGroup* group; GRtElementArray* array; } u; - + } GRtElement; struct GRtElementArray { UUtUns16 numElements; GRtElement elements[GRcMaxNumArray]; - + }; typedef struct GRtBinding { char* varName; - + GRtElement element; } GRtBinding; @@ -90,7 +90,7 @@ GRiGroup_Create( GRtGroup_Context* inContext, GRtGroup* inPreferenceGroup, BFtTextFile* inTextFile); - + static UUtError GRiGroup_ParseElement( GRtGroup_Context* inContext, @@ -119,16 +119,16 @@ GRiGetNextToken( GRgUngotToken = GReToken_None; return; } - + GRgToken = GReToken_None; - + if(GRgCurLine == NULL || *GRgCurLine == 0) { while(1) { GRgCurLine = BFrTextFile_GetNextStr(inTextFile); GRgLineNum++; - + if(GRgCurLine == NULL || GRgLineNum >= GRgMaxLines) { GRgToken = GReToken_EOF; @@ -161,14 +161,14 @@ GRiGetNextToken( *lexem++ = c; c = *GRgCurLine; if(!(isalpha(c) || c == '_' || isdigit(c))) break; - + GRgCurLine++; } *lexem = 0; - + GRgToken = GReToken_Identifier; return; - + case '{': GRgToken = GReToken_CurlyLeft; return; @@ -176,7 +176,7 @@ GRiGetNextToken( case '}': GRgToken = GReToken_CurlyRight; return; - + case '[': GRgToken = GReToken_BracketLeft; return; @@ -184,20 +184,20 @@ GRiGetNextToken( case ']': GRgToken = GReToken_BracketRight; return; - + case '=': GRgToken = GReToken_Equal; return; - + case ',': GRgToken = GReToken_Comma; return; - + case '#': GRgCurLine = NULL; GRiGetNextToken(inTextFile); return; - + case '"': while(1) { @@ -217,12 +217,12 @@ GRiGetNextToken( c = *GRgCurLine++; UUmAssert(c != 0); } - + GRgCurLine++; } - + *lexem = 0; - + GRgToken = GReToken_String; break; @@ -233,7 +233,7 @@ GRiGetNextToken( GRgToken = GReToken_String; break; } - + while(1) { *lexem++ = c; @@ -243,8 +243,8 @@ GRiGetNextToken( escaped = UUcTrue; c = *(++GRgCurLine); } - - if(c == 0 || + + if(c == 0 || c == '{' || c == '}' || c == '[' || @@ -260,12 +260,12 @@ GRiGetNextToken( GRgCurLine++; } - + *lexem = 0; - + GRgToken = GReToken_String; } - + static GRtElementArray* GRiGroup_ParseArray( @@ -278,27 +278,27 @@ GRiGroup_ParseArray( UUmAssert(NULL != inContext); UUmAssert(NULL != inTextFile); - + newArray = UUrMemory_Pool_Block_New(inContext->memoryPool, sizeof(GRtElementArray)); if(newArray == NULL) { return NULL; } - + newArray->numElements = 0; - + while(1) { GRiGetNextToken(inTextFile); - + if(GRgToken == GReToken_BracketRight) { break; } - + GRiUngetToken(GRgToken); - - error = + + error = GRiGroup_ParseElement( inContext, inPreferenceGroup, @@ -308,10 +308,10 @@ GRiGroup_ParseArray( { return NULL; } - + newArray->numElements++; } - + return newArray; } @@ -329,13 +329,13 @@ GRiGroup_ParseElement( char* value; GRtElementType elementType; UUtUns32 itr; - + UUmAssert(NULL != inContext); UUmAssert(NULL != inTextFile); UUmAssert(NULL != outElement); - + GRiGetNextToken(inTextFile); - + if(GRgToken == GReToken_CurlyLeft) { outElement->type = GRcElementType_Group; @@ -356,30 +356,30 @@ GRiGroup_ParseElement( } else if(GRgToken == GReToken_Identifier) { - + if(NULL == inPreferenceGroup) { UUrError_Report(UUcError_Generic, "No preferences group"); return UUcError_Generic; } - + error = GRrGroup_GetElement(inPreferenceGroup, GRgLexem, &elementType, &value); if(error != UUcError_None || elementType != GRcElementType_String) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Illegal preference variable"); } - + UUrString_Copy(temp, value, 1024); - + p = temp + strlen(temp); - + GRiGetNextToken(inTextFile); - + if(GRgToken != GReToken_String) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "expected a string here"); } - + // Wierd ass crap here for backward compatibility but to remove extra spaces from strings if(!isspace(GRgLexem[0])) { @@ -397,9 +397,9 @@ GRiGroup_ParseElement( } UUrString_Copy(p, GRgLexem, 1024 - strlen(p)); - + outElement->type = GRcElementType_String; - + outElement->u.value = UUrMemory_String_GetStr(inContext->memoryString, temp); } else if(GRgToken == GReToken_String) @@ -419,25 +419,25 @@ GRiGroup_ParseElement( } } } - + UUrString_Copy(temp, GRgLexem, 1024); - + outElement->type = GRcElementType_String; - + outElement->u.value = UUrMemory_String_GetStr(inContext->memoryString, temp); } else { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Illegal token"); } - + GRiGetNextToken(inTextFile); - + if(GRgToken != GReToken_Comma) { GRiUngetToken(GRgToken); } - + return UUcError_None; } @@ -450,48 +450,48 @@ GRiGroup_Create( UUtError error; GRtGroup* newGroup; char c; - + UUmAssert(NULL != inContext); UUmAssert(NULL != inTextFile); - + newGroup = UUrMemory_Pool_Block_New(inContext->memoryPool, sizeof(GRtGroup)); if(newGroup == NULL) { UUrError_Report(UUcError_OutOfMemory, "out of memory"); return NULL; } - + newGroup->numBindings = 0; newGroup->recursive = NULL; - + while(1) { GRiGetNextToken(inTextFile); - + if(GRgToken == GReToken_CurlyRight || GRgToken == GReToken_BracketRight || GRgToken == GReToken_EOF) break; - + if(GRgToken == GReToken_Identifier) { newGroup->bindings[newGroup->numBindings].varName = UUrMemory_String_GetStr(inContext->memoryString, GRgLexem); - + GRiGetNextToken(inTextFile); - + if(GRgToken != GReToken_Equal) { UUrError_Report(UUcError_Generic, "Expecting $name = value"); return NULL; } - + while(1) { c = *GRgCurLine; if(c == 0 || !UUrIsSpace(c)) break; GRgCurLine++; } - + if(*GRgCurLine != 0) { error = @@ -509,7 +509,7 @@ GRiGroup_Create( else { newGroup->bindings[newGroup->numBindings].element.type = GRcElementType_String; - + newGroup->bindings[newGroup->numBindings].element.u.value = UUrMemory_String_GetStr(inContext->memoryString, "\0"); } @@ -517,11 +517,11 @@ GRiGroup_Create( newGroup->numBindings++; } } - + return newGroup; } -UUtError +UUtError GRrGroup_Context_New( GRtGroup_Context **outGroupContext) { @@ -532,16 +532,16 @@ GRrGroup_Context_New( { goto errorExit; } - + newContext->memoryPool = NULL; newContext->memoryString = NULL; - + newContext->memoryPool = UUrMemory_Pool_New(10 * 1024, UUcPool_Growable); if(newContext->memoryPool == NULL) { goto errorExit; } - + newContext->memoryString = UUrMemory_String_New(10 * 1024); if(newContext->memoryString == NULL) { @@ -571,34 +571,34 @@ GRrGroup_Context_NewFromPartialFile( * You specify how many lines from the current file pointer are to * be treated as the group. */ - + UUtError error; GRtGroup_Context* newContext; - + UUmAssert(NULL != inFile); UUmAssert(NULL != outGroupContext); UUmAssert(NULL != outGroup); - + GRgMaxLines = inLines; GRgLineNum = 0; - + *outGroupContext = NULL; *outGroup = NULL; - + if (NULL == inGroupContext) { error = GRrGroup_Context_New(&newContext); UUmError_ReturnOnError(error); } - else + else { newContext = inGroupContext; } - + *outGroup = GRiGroup_Create(newContext, inPreferenceGroup, inFile); - + *outGroupContext = newContext; - + return UUcError_None; } @@ -612,17 +612,17 @@ GRrGroup_Context_NewFromString( { UUtError error; BFtTextFile* textFile; - + GRgMaxLines = UUcMaxInt32; GRgLineNum = 0; - - error = + + error = BFrTextFile_MakeFromString( inString, &textFile); UUmError_ReturnOnError(error); - - error = + + error = GRrGroup_Context_NewFromPartialFile( textFile, inPreferenceGroup, @@ -630,12 +630,12 @@ GRrGroup_Context_NewFromString( UUcMaxUns16, outGroupContext, outGroup); - + BFrTextFile_Close(textFile); - + return error; } - + UUtError GRrGroup_Context_NewFromFileRef( BFtFileRef* inFileRef, @@ -649,17 +649,17 @@ GRrGroup_Context_NewFromFileRef( BFtTextFile* textFile; UUmAssert(NULL != inFileRef); - - if (NULL != outGroupContext) + + if (NULL != outGroupContext) { *outGroupContext = NULL; } - if (NULL != outGroup) + if (NULL != outGroup) { *outGroup = NULL; } - + GRgMaxLines = UUcMaxInt32; GRgLineNum = 0; @@ -668,18 +668,18 @@ GRrGroup_Context_NewFromFileRef( error = GRrGroup_Context_New(&newContext); UUmError_ReturnOnError(error); } - else + else { newContext = inGroupContext; } - + error = BFrTextFile_OpenForRead(inFileRef, &textFile); if (UUcError_None != error) { UUrError_ReportP(error, "failed to open group file %s", (UUtUns32) BFrFileRef_GetLeafName(inFileRef),0,0); } - - if (NULL != outGroup) + + if (NULL != outGroup) { *outGroup = GRiGroup_Create(newContext, inPreferenceGroup, textFile); } @@ -688,9 +688,9 @@ GRrGroup_Context_NewFromFileRef( { *outGroupContext = newContext; } - + BFrTextFile_Close(textFile); - + return UUcError_None; } @@ -704,14 +704,14 @@ GRrGroup_Context_Delete( { UUrMemory_Pool_Delete(inGroupContext->memoryPool); } - + if(inGroupContext->memoryString != NULL) { UUrMemory_String_Delete(inGroupContext->memoryString); } - + UUrMemory_Block_Delete(inGroupContext); - } + } } UUtError @@ -738,18 +738,18 @@ GRrGroup_GetElement( } } - if (inGroup->recursive != NULL) + if (inGroup->recursive != NULL) { return GRrGroup_GetElement( - inGroup->recursive, - inVarName, - outElementType, + inGroup->recursive, + inVarName, + outElementType, outDataPtr); } - + return GRcError_ElementNotFound; } - + UUtError GRrGroup_Array_GetElement( GRtElementArray* inElementArray, @@ -764,10 +764,10 @@ GRrGroup_Array_GetElement( { if (outElementType) *outElementType = inElementArray->elements[inIndex].type; *outDataPtr = inElementArray->elements[inIndex].u.value; - + return UUcError_None; } - + return GRcError_ElementNotFound; } @@ -781,7 +781,7 @@ GRrGroup_Array_GetLength( } - + UUtError GRrGroup_GetString( GRtGroup* inGroup, @@ -1110,7 +1110,7 @@ GRrGroup_GetOSType( error = GRrGroup_GetString(inGroup, inVarName, &string); - if (error) + if (error) { return error; } @@ -1138,8 +1138,8 @@ GRrGroup_GetVarName( UUtUns32 inVarNumber) { const char *varName = NULL; - - if (inVarNumber < inGroup->numBindings) + + if (inVarNumber < inGroup->numBindings) { varName = inGroup->bindings[inVarNumber].varName; } diff --git a/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image.c b/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image.c index 4154c8a..11bdd82 100644 --- a/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image.c +++ b/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image.c @@ -1,12 +1,12 @@ /* FILE: BFW_Image.c - + AUTHOR: Brent H. Pease - + CREATED: Nov 27, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -28,12 +28,12 @@ typedef struct IMtPixelTypeInfo_Lookup UUtUns32 rMask; UUtUns32 gMask; UUtUns32 bMask; - + } IMtPixelTypeInfo_Lookup; // table must be in order const IMtPixelTypeInfo_Lookup -IMgPixelTypeInfoTable[] = +IMgPixelTypeInfoTable[] = { { IMcPixelType_ARGB4444, UUcTrue, 2, 0xf000, 0x0f00, 0x00f0, 0x000f }, { IMcPixelType_RGB555, UUcTrue, 2, 0x0000, 0x7c00, 0x03e0, 0x001f }, @@ -47,8 +47,8 @@ IMgPixelTypeInfoTable[] = { IMcPixelType_DXT1, UUcFalse, 0, 0, 0, 0, 0 }, { IMcPixelType_RGB_Bytes, UUcFalse, 3, 3, 0, 0, 0 }, { IMcPixelType_RGBA_Bytes, UUcFalse, 4, 4, 0, 0, 0 }, - { IMcPixelType_RGBA5551, UUcTrue, 2, 0x0001, 0xf800, 0x07c0, 0x003e }, - { IMcPixelType_RGBA4444, UUcTrue, 2, 0x000f, 0xf000, 0x0f00, 0x00f0 }, + { IMcPixelType_RGBA5551, UUcTrue, 2, 0x0001, 0xf800, 0x07c0, 0x003e }, + { IMcPixelType_RGBA4444, UUcTrue, 2, 0x000f, 0xf000, 0x0f00, 0x00f0 }, { IMcPixelType_RGB565, UUcTrue, 2, 0x0000, 0xf800, 0x07e0, 0x001f }, { IMcPixelType_ABGR1555, UUcTrue, 2, 0x8000, 0x001f, 0x03e0, 0x7c00 } }; @@ -116,7 +116,7 @@ static UUtUns32 IMiComponentToBits(float component, UUtUns32 mask) UUtUns32 shiftedMask = mask >> shift; UUtUns32 result; - if (0 == mask) + if (0 == mask) { return 0; } @@ -134,7 +134,7 @@ static float IMiBitsToComponent(UUtUns32 bits, UUtUns32 mask) UUtUns32 shift = IMiMaskToShift(mask); float result; - if (0 == mask) + if (0 == mask) { return 1.f; } @@ -158,35 +158,35 @@ IMiImage_Scale_High( { case IMcPixelType_ARGB4444: break; - + case IMcPixelType_RGB555: break; - + case IMcPixelType_ARGB1555: break; - + case IMcPixelType_I8: break; - + case IMcPixelType_I1: break; - + case IMcPixelType_A8: break; - + case IMcPixelType_A4I4: break; - + case IMcPixelType_ARGB8888: break; - + case IMcPixelType_RGB888: break; - + default: UUmError_ReturnOnError(UUcError_Generic); } - + return UUcError_None; } @@ -232,7 +232,7 @@ IMrImage_Scale( if(inScaleMode & IMcScaleMode_High) { - return + return IMiImage_Scale_High( inSrcWidth, inSrcHeight, @@ -246,7 +246,7 @@ IMrImage_Scale( { if(inScaleMode & IMcScaleMode_IndependantAlpha) { - return + return IMrImage_Scale_Box_IndependantAlpha( inSrcWidth, inSrcHeight, @@ -258,7 +258,7 @@ IMrImage_Scale( } else { - return + return IMrImage_Scale_Box( inSrcWidth, inSrcHeight, @@ -269,7 +269,7 @@ IMrImage_Scale( outDstData); } } - + return UUcError_None; } @@ -294,17 +294,17 @@ IMrImage_Copy( UUtRect src_bounds; UUtRect src_rect; UUtUns32 src_read; - + UUtUns16 dst_rowbytes; UUtUns16 dst_pixel_size; UUtUns32 dst; UUtRect dst_bounds; UUtRect dst_rect; UUtUns32 dst_write; - + UUtRect temp; UUtUns16 width; - + // clip src_rect to the image temp.left = inSrcLocation->x; temp.top = inSrcLocation->y; @@ -326,25 +326,25 @@ IMrImage_Copy( dst_bounds.right = inDstWidth; dst_bounds.bottom = inDstHeight; IMrRect_Intersect(&temp, &dst_bounds, &dst_rect); - + // get the pixel sizes src_pixel_size = IMrPixel_GetSize(inSrcPixelType); dst_pixel_size = IMrPixel_GetSize(inDstPixelType); - + // calculate the src start src_rowbytes = IMrImage_ComputeRowBytes(inSrcPixelType, inSrcWidth); src = (UUtUns32)inSrcData + (src_rect.left * src_pixel_size) + (src_rect.top * src_rowbytes); - + // calculate the dst start dst_rowbytes = IMrImage_ComputeRowBytes(inDstPixelType, inDstWidth); dst = (UUtUns32)inDstData + (dst_rect.left * dst_pixel_size) + (dst_rect.top * dst_rowbytes); - + // if the pixel types are the same, the pixel doesn't have to // be converted between copy and past if (inSrcPixelType == inDstPixelType) @@ -357,7 +357,7 @@ IMrImage_Copy( width = inCopyWidth; src_read = src; dst_write = dst; - + while (width--) { *((UUtUns8*)dst_write) = *((UUtUns8*)src_read); @@ -368,14 +368,14 @@ IMrImage_Copy( dst += dst_rowbytes; } break; - + case 2: while (inCopyHeight--) { width = inCopyWidth; src_read = src; dst_write = dst; - + while (width--) { *((UUtUns16*)dst_write) = *((UUtUns16*)src_read); @@ -386,14 +386,14 @@ IMrImage_Copy( dst += dst_rowbytes; } break; - + case 4: while (inCopyHeight--) { width = inCopyWidth; src_read = src; dst_write = dst; - + while (width--) { *((UUtUns32*)dst_write) = *((UUtUns32*)src_read); @@ -419,7 +419,7 @@ IMrImage_Copy( width = inCopyWidth; src_read = src; dst_write = dst; - + while (width--) { src_pixel.value = *((UUtUns8*)src_read); @@ -436,14 +436,14 @@ IMrImage_Copy( dst += dst_rowbytes; } break; - + case 2: while (inCopyHeight--) { width = inCopyWidth; src_read = src; dst_write = dst; - + while (width--) { src_pixel.value = *((UUtUns16*)src_read); @@ -460,14 +460,14 @@ IMrImage_Copy( dst += dst_rowbytes; } break; - + case 4: while (inCopyHeight--) { width = inCopyWidth; src_read = src; dst_write = dst; - + while (width--) { src_pixel.value = *((UUtUns32*)src_read); @@ -509,7 +509,7 @@ IMrImage_GeneralManipulation( void* newSrcData; IMtPoint2D srcLocation; IMtPoint2D newSrcLocation; - + UUtUns16 dstWidth; UUtUns16 dstHeight; UUtUns16 unconvertedDstRowBytes; @@ -517,7 +517,7 @@ IMrImage_GeneralManipulation( UUtUns16 convertedDstRowBytes; void* convertedDstData; IMtPoint2D dstLocation; - + newSrcWidth = inSrcRect->right - inSrcRect->left; newSrcHeight = inSrcRect->bottom - inSrcRect->top; newSrcRowBytes = IMrImage_ComputeRowBytes(inSrcPixelType, newSrcWidth); @@ -527,18 +527,18 @@ IMrImage_GeneralManipulation( newSrcLocation.y = 0; newSrcData = UUrMemory_Block_New(newSrcRowBytes * newSrcHeight); - UUmError_ReturnOnNull(newSrcData); - + UUmError_ReturnOnNull(newSrcData); + dstWidth = inDstRect->right - inDstRect->left; dstHeight = inDstRect->bottom - inDstRect->top; unconvertedDstRowBytes = IMrImage_ComputeRowBytes(inSrcPixelType, dstWidth); convertedDstRowBytes = IMrImage_ComputeRowBytes(inDstPixelType, dstWidth); dstLocation.x = inDstRect->left; dstLocation.y = inDstRect->top; - + unconvertedDstData = UUrMemory_Block_New(unconvertedDstRowBytes * dstHeight); - UUmError_ReturnOnNull(unconvertedDstData); - + UUmError_ReturnOnNull(unconvertedDstData); + // Step 1. Copy srcRect out of the source image into its own image IMrImage_Copy( newSrcWidth, @@ -553,7 +553,7 @@ IMrImage_GeneralManipulation( inSrcPixelType, newSrcData, &newSrcLocation); - + // Step 2. Scale new source image into the proper dimensions IMrImage_Scale( IMcScaleMode_Box, @@ -564,12 +564,12 @@ IMrImage_GeneralManipulation( dstWidth, dstHeight, unconvertedDstData); - + // Step 3. Convert to dst pixel type if(inSrcPixelType != inDstPixelType) - { + { convertedDstData = UUrMemory_Block_New(convertedDstRowBytes * dstHeight); - + IMrImage_ConvertPixelType( inDitherMode, dstWidth, @@ -584,7 +584,7 @@ IMrImage_GeneralManipulation( { convertedDstData = unconvertedDstData; } - + // Step 3. Copy scaled image into the dst rect IMrImage_Copy( dstWidth, @@ -599,15 +599,15 @@ IMrImage_GeneralManipulation( inDstPixelType, outDstData, &dstLocation); - + UUrMemory_Block_Delete(newSrcData); UUrMemory_Block_Delete(unconvertedDstData); - + if(convertedDstData != unconvertedDstData) { UUrMemory_Block_Delete(convertedDstData); } - + return UUcError_None; } @@ -623,32 +623,32 @@ IMrImage_GetPixel( IMtPixel *outDstPixel) { IMtPixel temp_pixel; - + UUmAssert((inPixelX >= 0) && (inPixelX < inSrcWidth)); UUmAssert((inPixelY >= 0) && (inPixelY < inSrcHeight)); UUmAssert(inSrcData); UUmAssert(outDstPixel); - + // get the pixel from the the bitmap switch (IMrPixel_GetSize(inSrcPixelType)) { case 1: temp_pixel.value = *((UUtUns8*)(inSrcData) + inPixelX + inPixelY); break; - + case 2: temp_pixel.value = *((UUtUns16*)(inSrcData) + inPixelX + (inPixelY * inSrcWidth)); break; - + case 4: temp_pixel.value = *((UUtUns32*)(inSrcData) + inPixelX + (inPixelY * inSrcWidth)); break; - + default: UUmAssert(!"bad pixel type"); break; } - + // convert the pixel to the desired pixel type IMrPixel_Convert( inSrcPixelType, @@ -683,15 +683,15 @@ IMrImage_Fill( switch(IMrPixel_GetSize(inPixelType)) { case 1: - UUrMemory_Set8(inDstData, (UUtUns8) inPixel.value, numBytes); + UUrMemory_Set8(inDstData, (UUtUns8) inPixel.value, numBytes); break; case 2: - UUrMemory_Set16(inDstData, (UUtUns16) inPixel.value, numBytes); + UUrMemory_Set16(inDstData, (UUtUns16) inPixel.value, numBytes); break; case 4: - UUrMemory_Set32(inDstData, (UUtUns32) inPixel.value, numBytes); + UUrMemory_Set32(inDstData, (UUtUns32) inPixel.value, numBytes); break; default: @@ -701,21 +701,21 @@ IMrImage_Fill( } UUmAssertReadPtr(inDstRect, sizeof(*inDstRect)); - + // set the texture_rect texture_rect.left = 0; texture_rect.top = 0; texture_rect.right = inDstWidth; texture_rect.bottom = inDstHeight; - + // set the clip info IMrRect_ComputeClipInfo(&texture_rect, inDstRect, &dest_x, &dest_y, &width, &height); - + if ((width <= 0) || (height <= 0)) return; texel_size = IMrPixel_GetSize(inPixelType); - + // fill in the bounds area of the texture map with inColor switch (texel_size) { @@ -723,68 +723,68 @@ IMrImage_Fill( { UUtUns16 *dest_16_line_start; UUtUns32 dest_16_row_texels; - + dest_16_row_texels = inDstWidth; dest_16_line_start = (UUtUns16*)inDstData + dest_x + (dest_16_row_texels * dest_y); - + for (i = 0; i < height; i++) { UUrMemory_Set16( - dest_16_line_start, - (UUtUns16) inPixel.value, + dest_16_line_start, + (UUtUns16) inPixel.value, width * texel_size); - + dest_16_line_start += dest_16_row_texels; } } break; - + case 1: { UUtUns8 *dest_8_line_start; UUtUns32 dest_8_row_texels; - + dest_8_row_texels = inDstWidth; dest_8_line_start = (UUtUns8*)inDstData + dest_x + (dest_8_row_texels * dest_y); - + for (i = 0; i < height; i++) { UUrMemory_Set8( - dest_8_line_start, - (UUtUns8) inPixel.value, + dest_8_line_start, + (UUtUns8) inPixel.value, width * texel_size); - + dest_8_line_start += dest_8_row_texels; } } break; - + case 4: { UUtUns32 *dest_32_line_start; UUtUns32 dest_32_row_texels; - + dest_32_row_texels = inDstWidth; dest_32_line_start = (UUtUns32*)inDstData + dest_x + (dest_32_row_texels * dest_y); - + for (i = 0; i < height; i++) { UUrMemory_Set32( - dest_32_line_start, - inPixel.value, + dest_32_line_start, + inPixel.value, width * texel_size); - + dest_32_line_start += dest_32_row_texels; } } break; - + default: UUmAssert(!"Unknown TexelSize"); } @@ -808,7 +808,7 @@ IMrImage_ComputeRowBytes( case 2: UUmAssert(inWidth <= (UUcMaxUns16 / 2)); return inWidth * 2; - + case 1: return (inWidth + 1) & ~1; } @@ -823,8 +823,8 @@ IMrImage_ComputeRowBytes( default: UUmAssert(!"unknown pixel type"); } - } - + } + return 0; } @@ -962,7 +962,7 @@ IMrImage_ComputeSize( UUmAssert(inWidth <= (UUcMaxUns16 / 2)); size = inWidth * inHeight * 2; break; - + case 1: size = ((inWidth + 1) & ~1) * inHeight * 1; break; @@ -986,7 +986,7 @@ IMrImage_ComputeSize( UUmAssert(!"unknown pixel type"); } } - + if (IMcHasMipMap == inHasMipMap) { // S.S. UUtUns16 newWidth = inWidth / 2; @@ -1001,7 +1001,7 @@ IMrImage_ComputeSize( size += IMrImage_ComputeSize(inPixelType, inHasMipMap, newWidth, newHeight); } - + return size; } @@ -1009,7 +1009,7 @@ IMrImage_ComputeSize( IMtPixel IMrPixel_FromARGB( IMtPixelType inPixelType, - float inA, + float inA, float inR, float inG, float inB) @@ -1060,7 +1060,7 @@ IMrShade_FromPixel( { float a,r,g,b; IMtShade shade_a, shade_r, shade_g, shade_b; - IMtShade shade; + IMtShade shade; IMrPixel_Decompose(inPixel, inPixelType, &a, &r, &g, &b); @@ -1082,9 +1082,9 @@ IMrShade_Interpolate_Integer( float inInterp) { IMtShade result; - IMtShade dst_a; - IMtShade dst_r; - IMtShade dst_g; + IMtShade dst_a; + IMtShade dst_r; + IMtShade dst_g; IMtShade dst_b; UUtUns32 to_amount = MUrUnsignedSmallFloat_ShiftLeft_To_Uns_Round(inInterp, 8); UUtUns32 from_amount = 256 - to_amount; @@ -1145,7 +1145,7 @@ IMrShade_Interpolate( #if defined(DEBUGGING) && DEBUGGING { - IMtShade result_float = IMrShade_Interpolate_Float(inShade1, inShade2, inInterp); + IMtShade result_float = IMrShade_Interpolate_Float(inShade1, inShade2, inInterp); UUmAssert(IMrShade_IsEqual(result_integer, result_float)); } #endif @@ -1154,7 +1154,7 @@ IMrShade_Interpolate( } UUtBool IMrShade_IsEqual(IMtShade src, IMtShade dst) -{ +{ UUtInt32 max_delta = 2; UUtInt32 delta = 0; UUtBool is_equal = UUcTrue; @@ -1222,7 +1222,7 @@ IMrPixel_Get( void IMrPixel_Decompose( - IMtPixel inPixel, + IMtPixel inPixel, IMtPixelType inPixelType, float *outA, float *outR, @@ -1277,7 +1277,7 @@ IMrInitialize( static const float one_over_255= 1.f/255.f; UUrStartupMessage("initializing image system..."); - + // initialize alpha blend table for(itr = 0; itr < 0xFF; itr++) { @@ -1287,21 +1287,21 @@ IMrInitialize( dstA = (UUtUns16)(itr & 0xF); test_alpha = IMr4BitAlphaBlendTable(srcA, dstA); - + srcA |= (UUtUns16)(srcA << 4); dstA |= (UUtUns16)(dstA << 4); - + /* S.S. srcA_float = srcA / 255.0f; dstA_float = dstA / 255.0f;*/ srcA_float= srcA * one_over_255; dstA_float= dstA * one_over_255; - + newA_float = 1.0f - (1.0f - dstA_float) * (1.0f - srcA_float); newA = (UUtUns16)(newA_float * 15.0f); UUmAssert(UUmABS(test_alpha - newA) <= 1); } - + // verify the rgb blend table for(itr = 0; itr < 0xFFFF; itr++) { @@ -1315,12 +1315,12 @@ IMrInitialize( if (0 == (srcA+dstA)) { continue; } function_result = IMr4BitRGBBlendTable(srcA, dstA, srcC, dstC); - + srcA |= srcA << 4; dstA |= dstA << 4; srcC |= srcC << 4; dstC |= dstC << 4; - + /* S.S. srcA_float = srcA / 255.0f; dstA_float = dstA / 255.0f; srcC_float = srcC / 255.0f; @@ -1331,7 +1331,7 @@ IMrInitialize( dstC_float = dstC * one_over_255; newC_float = (srcC_float * srcA_float + dstC_float * dstA_float) / (srcA_float + dstA_float); - + newC = (UUtUns16)(newC_float * 15.0f); UUmAssert(UUmABS(function_result == newC) <= 1); } @@ -1348,7 +1348,7 @@ IMrInitialize( IMrShade_Interpolate(shade1, shade2, t); } #endif - + return UUcError_None; } @@ -1369,7 +1369,7 @@ IMrPixel_BlendARGB4444( UUtUns32 srcG, dstG, newG; UUtUns32 srcB, dstB, newB; UUtUns32 result; - + srcA = (inSrcPixel >> 12) & 0xF; dstA = (inDstPixel >> 12) & 0xF; @@ -1378,19 +1378,19 @@ IMrPixel_BlendARGB4444( } newA = IMr4BitAlphaBlendTable(srcA, dstA); - + srcR = (inSrcPixel >> 8) & 0xF; dstR = (inDstPixel >> 8) & 0xF; newR = IMr4BitRGBBlendTable(srcA, dstA, srcR, dstR); - + srcG = (inSrcPixel >> 4) & 0xF; dstG = (inDstPixel >> 4) & 0xF; newG = IMr4BitRGBBlendTable(srcA, dstA, srcG, dstG); - + srcB = (inSrcPixel >> 0) & 0xF; dstB = (inDstPixel >> 0) & 0xF; newB = IMr4BitRGBBlendTable(srcA, dstA, srcB, dstB); - + result = (newA << 12) | (newR << 8) | (newG << 4) | (newB); return (UUtUns16) result; @@ -1405,7 +1405,7 @@ IMrRect_Inset( const UUtInt16 inDeltaY) { UUmAssert(ioRect); - + ioRect->left += inDeltaX; ioRect->top += inDeltaY; ioRect->right -= inDeltaX; @@ -1423,28 +1423,28 @@ IMrRect_Intersect( UUtInt16 right; UUtInt16 top; UUtInt16 bottom; - + UUmAssert(inRect1); UUmAssert(inRect2); UUmAssert(outRect); - + // calculate the left, right, top, and bottom of the out rect left = UUmMin(inRect1->left, inRect2->right); left = UUmMax(left, inRect2->left); - + right = UUmMax(inRect1->right, inRect2->left); right = UUmMin(right, inRect2->right); - + top = UUmMin(inRect1->top, inRect2->bottom); top = UUmMax(top, inRect2->top); - + bottom = UUmMax(inRect1->bottom, inRect2->top); bottom = UUmMin(bottom, inRect2->bottom); - + // if they don't intersect, set the params to zero if (left > right) left = right = 0; if (top > bottom) top = bottom = 0; - + // set the out rect outRect->left = left; outRect->right = right; @@ -1460,10 +1460,10 @@ IMrRect_Offset( const UUtInt16 inOffsetY) { UUmAssert(ioRect); - + ioRect->left = ioRect->left + inOffsetX; ioRect->right = ioRect->right + inOffsetX; - + ioRect->top = ioRect->top + inOffsetY; ioRect->bottom = ioRect->bottom + inOffsetY; } @@ -1481,7 +1481,7 @@ IMrRect_PointIn( { return UUcTrue; } - + return UUcFalse; } @@ -1499,7 +1499,7 @@ IMrRect_ComputeClipInfo( UUtInt16 right; UUtInt16 top; UUtInt16 bottom; - + UUmAssertReadPtr(inRect1, sizeof(*inRect1)); UUmAssertReadPtr(inRect2, sizeof(*inRect2)); UUmAssertWritePtr(outDestX, sizeof(*outDestX)); @@ -1509,19 +1509,19 @@ IMrRect_ComputeClipInfo( left = UUmMin(inRect1->left, inRect2->right); left = UUmMax(left, inRect2->left); - + right = UUmMax(inRect1->right, inRect2->left); right = UUmMin(right, inRect2->right); - + top = UUmMin(inRect1->top, inRect2->bottom); top = UUmMax(top, inRect2->top); - + bottom = UUmMax(inRect1->bottom, inRect2->top); bottom = UUmMin(bottom, inRect2->bottom); - + *outDestX = left; *outDestY = top; - *outWidth = right - left; + *outWidth = right - left; *outHeight = bottom - top; } @@ -1533,16 +1533,16 @@ IMrRect_Union( UUtRect *outRect) { UUtRect temp; - + UUmAssertReadPtr(inRect1, sizeof(*inRect1)); UUmAssertReadPtr(inRect2, sizeof(*inRect2)); UUmAssertWritePtr(outRect, sizeof(*outRect)); - + temp.left = UUmMin(inRect1->left, inRect2->left); temp.top = UUmMin(inRect1->top, inRect2->top); temp.right = UUmMax(inRect1->right, inRect2->right); temp.bottom = UUmMax(inRect1->bottom, inRect2->bottom); - + *outRect = temp; } @@ -1553,11 +1553,11 @@ IMrPoint2D_Distance( const IMtPoint2D *inPoint2) { M3tPoint3D delta; - + delta.x = (float)(inPoint2->x - inPoint1->x); delta.y = (float)(inPoint2->y - inPoint1->y); delta.z = 0.0f; - + return (UUtInt16)MUrPoint_Length(&delta); } @@ -1592,7 +1592,7 @@ AUiImage_GetRow( { return; } - + UUrMemory_MoveFast( (char*)inImage->baseAddr + (inRowIndex * inImage->rowBytes), inRowMem, @@ -1614,7 +1614,7 @@ AUiImage_PutPixel( { return; } - + p = (UUtUns32*)((char*)inImage->baseAddr + (inY * inImage->rowBytes)); p[inX] = (inR << 16) | (inG << 8) | (inB << 0); @@ -1633,9 +1633,9 @@ AUiImage_GetColumn( { return; } - + d = inImage->rowBytes >> 2; - + for(i = inImage->height, p = inImage->baseAddr + inColumnIndex; i-- > 0; p += d) @@ -1657,9 +1657,9 @@ AUrImage_Scale( double width, fscale, weight; /* filter calculation variables */ UUtUns32* raster; /* a row or column of pixels */ double r, g, b; - + CLIST* contrib; /* array of contribution lists */ - + float fWidth = 2.0; /* create intermediate image to hold horizontal zoom */ tmp = AUiImage_New(inDst->width, inSrc->height); @@ -1667,24 +1667,24 @@ AUrImage_Scale( { UUmError_ReturnOnError(UUcError_OutOfMemory); } - + xscale = (double) inDst->width / (double) inSrc->width; yscale = (double) inDst->height / (double) inSrc->height; /* pre-calculate filter contributions for a row */ contrib = (CLIST *)UUrMemory_Block_NewClear(inDst->width * sizeof(CLIST)); - + if(xscale < 1.0) { width = fWidth / xscale; fscale = 1.0 / xscale; - + for(i = 0; i < inDst->width; ++i) { contrib[i].n = 0; contrib[i].p = (CONTRIB *) UUrMemory_Block_NewClear((int) (width * 2 + 1) * sizeof(CONTRIB)); - + center = (double) i / xscale; left = ceil(center - width); right = floor(center + width); @@ -1724,7 +1724,7 @@ AUrImage_Scale( { weight = center - (double) j; weight = Lanczos3_filter(weight); - + if(j < 0) { n = -j; @@ -1737,7 +1737,7 @@ AUrImage_Scale( { n = j; } - + k = contrib[i].n++; contrib[i].p[k].pixel = n; contrib[i].p[k].weight = weight; @@ -1768,7 +1768,7 @@ AUrImage_Scale( (UUtUns32)UUmPin(b, 0.0f, 255.999f)); } } - + UUrMemory_Block_Delete(raster); /* free the memory allocated for horizontal filter weights */ @@ -1875,11 +1875,11 @@ AUrImage_Scale( { UUrMemory_Block_Delete(contrib[i].p); } - + UUrMemory_Block_Delete(contrib); AUiImage_Delete(tmp); - + return UUcError_None; } @@ -1890,10 +1890,10 @@ const char *IMrPixelTypeToString(IMtPixelType inPixelType) typedef struct IMtPixelTypeToStringTable { IMtPixelType type; - const char *string; + const char *string; } IMtPixelTypeToStringTable; - IMtPixelTypeToStringTable table[IMcNumPixelTypes] = + IMtPixelTypeToStringTable table[IMcNumPixelTypes] = { { IMcPixelType_ARGB4444, "argb4444" }, { IMcPixelType_RGB555, "rgb555" }, @@ -1912,14 +1912,14 @@ const char *IMrPixelTypeToString(IMtPixelType inPixelType) { IMcPixelType_RGB565, "rgb565" }, { IMcPixelType_ABGR1555, "abgr1555" }, }; - + const char *pixel_type_string; // verify the table { IMtPixelType itr; - for(itr = 0; itr < IMcNumPixelTypes; itr++) + for(itr = 0; itr < IMcNumPixelTypes; itr++) { UUmAssert(table[itr].type == itr); UUmAssert(table[itr].string != NULL); diff --git a/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Dither.c b/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Dither.c index d95ed4c..d337ae3 100644 --- a/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Dither.c +++ b/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Dither.c @@ -1,12 +1,12 @@ /* FILE: BFW_Image_Dither.c - + AUTHOR: Brent H. Pease - + CREATED: Nov 27, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -30,24 +30,24 @@ IMrImage_Dither_Row_ARGB_to_ARGB1555( UUtUns8 dr, dg, db; UUtUns16* dstPtr; UUtInt16 er, eg, eb; - + for(x = 0, curSrcPixel = inSrcCurRow, dstPtr = outDstRow; x < inWidth; x++, curSrcPixel++, dstPtr++) { // pin the current pixel to [0, 255] a = UUmPin(curSrcPixel->a, 0, UUcMaxUns8); - + if(a != 0xFF) { *dstPtr = 0; continue; } - + r = UUmPin(curSrcPixel->r, 0, UUcMaxUns8); g = UUmPin(curSrcPixel->g, 0, UUcMaxUns8); b = UUmPin(curSrcPixel->b, 0, UUcMaxUns8); - + // quantize the pixel //qr = (UUtUns8)(((UUtUns16)(r >> 3) * (UUtUns16)UUcMaxUns8) / (UUtUns16)31); //qg = (UUtUns8)(((UUtUns16)(g >> 3) * (UUtUns16)UUcMaxUns8) / (UUtUns16)31); @@ -55,17 +55,17 @@ IMrImage_Dither_Row_ARGB_to_ARGB1555( qr = (UUtUns8)((r + 4) & ~0x7); qg = (UUtUns8)((g + 4) & ~0x7); qb = (UUtUns8)((b + 4) & ~0x7); - + dr = qr >> 3; dg = qg >> 3; db = qb >> 3; - + *dstPtr = (1 << 15) | (dr << 10) | (dg << 5) | db; - + er = (UUtInt16)r - (UUtInt16)qr; eg = (UUtInt16)g - (UUtInt16)qg; eb = (UUtInt16)b - (UUtInt16)qb; - + // 7/16ths distributed right if(x < inWidth - 1 && (curSrcPixel + 1)->a == 0xFF) { @@ -76,7 +76,7 @@ IMrImage_Dither_Row_ARGB_to_ARGB1555( (curSrcPixel + 1)->g += ((eg * 7) >> 4); (curSrcPixel + 1)->b += ((eb * 7) >> 4); } - + if(inSrcNextRow) { // 3/16ths below left @@ -89,7 +89,7 @@ IMrImage_Dither_Row_ARGB_to_ARGB1555( inSrcNextRow[x - 1].g += ((eg * 3) >> 4); inSrcNextRow[x - 1].b += ((eb * 3) >> 4); } - + // 5/16ths below if(inSrcNextRow[x].a == 0xFF) { @@ -100,7 +100,7 @@ IMrImage_Dither_Row_ARGB_to_ARGB1555( inSrcNextRow[x].g += ((eg * 5) >> 4); inSrcNextRow[x].b += ((eb * 5) >> 4); } - + // 1/16th below right if(x < inWidth - 1 && inSrcNextRow[x + 1].a == 0xFF) { @@ -139,39 +139,39 @@ IMrImage_Dither_Row_RGB_to_ARGB1555( UUtUns8 dr, dg, db; UUtUns16* dstPtr; UUtInt16 er, eg, eb; - + for(x = 0, curSrcPixel = inSrcCurRow, dstPtr = outDstRow; x < inWidth; x++, curSrcPixel++, dstPtr++) { // pin the current pixel to [0, 255] a = UUmPin(curSrcPixel->a, 0, UUcMaxUns8); - + if(a != 0xFF) { *dstPtr = 0; continue; } - + r = UUmPin(curSrcPixel->r, 0, UUcMaxUns8); g = UUmPin(curSrcPixel->g, 0, UUcMaxUns8); b = UUmPin(curSrcPixel->b, 0, UUcMaxUns8); - + // quantize the pixel qr = (UUtUns8)(((UUtUns16)(r >> 3) * (UUtUns16)UUcMaxUns8) / (UUtUns16)31); qg = (UUtUns8)(((UUtUns16)(g >> 3) * (UUtUns16)UUcMaxUns8) / (UUtUns16)31); qb = (UUtUns8)(((UUtUns16)(b >> 3) * (UUtUns16)UUcMaxUns8) / (UUtUns16)31); - + dr = qr >> 3; dg = qg >> 3; db = qb >> 3; - + *dstPtr = (1 << 15) | (dr << 10) | (dg << 5) | db; - + er = (UUtInt16)r - (UUtInt16)qr; eg = (UUtInt16)g - (UUtInt16)qg; eb = (UUtInt16)b - (UUtInt16)qb; - + // 7/16ths distributed right if(x < inWidth - 1 && (curSrcPixel + 1)->a == 0xFF) { @@ -182,7 +182,7 @@ IMrImage_Dither_Row_RGB_to_ARGB1555( (curSrcPixel + 1)->g += ((eg * 7) >> 4); (curSrcPixel + 1)->b += ((eb * 7) >> 4); } - + if(inSrcNextRow) { // 3/16ths below left @@ -195,7 +195,7 @@ IMrImage_Dither_Row_RGB_to_ARGB1555( inSrcNextRow[x - 1].g += ((eg * 3) >> 4); inSrcNextRow[x - 1].b += ((eb * 3) >> 4); } - + // 5/16ths below if(inSrcNextRow[x].a == 0xFF) { @@ -206,7 +206,7 @@ IMrImage_Dither_Row_RGB_to_ARGB1555( inSrcNextRow[x].g += ((eg * 5) >> 4); inSrcNextRow[x].b += ((eb * 5) >> 4); } - + // 1/16th below right if(x < inWidth - 1 && inSrcNextRow[x + 1].a == 0xFF) { diff --git a/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Draw.c b/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Draw.c index d9ec95b..5c47ca2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Draw.c +++ b/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Draw.c @@ -33,21 +33,21 @@ IMrImage_Draw_Line( UUtInt16 width; UUtInt16 height; UUtUns16 row_bytes; - + UUmAssert(inImageData); UUmAssert(inPoint1); UUmAssert(inPoint2); - + // get the row_bytes row_bytes = IMrImage_ComputeRowBytes(inImagePixelType, inImageWidth); - + // optimize for vertical drawing if (inPoint1->x == inPoint2->x) { // calculate and clip the Ys x1 = x2 = UUmMax(0, inPoint1->x); x1 = x2 = UUmMin(x1, inImageWidth - 1); - + // calculate the Ys if (inPoint1->y <= inPoint2->y) { @@ -61,7 +61,7 @@ IMrImage_Draw_Line( y1 = inPoint2->y; y2 = inPoint1->y; } - + // clip the Ys y1 = UUmMax(0, y1); y2 = UUmMin(y2, inImageHeight - 1); @@ -70,7 +70,7 @@ IMrImage_Draw_Line( // the origin of the image height = y2 - y1; offset = x1 + (y1 * row_bytes); - + switch (inImagePixelType) { // 1 byte @@ -78,32 +78,32 @@ IMrImage_Draw_Line( case IMcPixelType_A8: case IMcPixelType_A4I4: dst_1 = (UUtUns8*)inImageData + offset; - + while (height--) { *dst_1 = (UUtUns8) inDrawColor.value; dst_1 += row_bytes; } break; - + // 2 byte case IMcPixelType_ARGB4444: case IMcPixelType_RGB555: case IMcPixelType_ARGB1555: dst_2 = (UUtUns16*)inImageData + offset; - + while (height--) { *dst_2 = (UUtUns16) inDrawColor.value; dst_2 += row_bytes; } break; - + // 4 byte case IMcPixelType_ARGB8888: case IMcPixelType_RGB888: dst_4 = (UUtUns32*)inImageData + offset; - + while (height--) { *dst_4 = inDrawColor.value; @@ -118,7 +118,7 @@ IMrImage_Draw_Line( // calculate and clip the Ys y1 = y2 = UUmMax(0, inPoint1->y); y1 = y2 = UUmMin(y1, inImageHeight - 1); - + // calculate the Xs if (inPoint1->x <= inPoint2->x) { @@ -132,7 +132,7 @@ IMrImage_Draw_Line( x1 = inPoint2->x; x2 = inPoint1->x; } - + // clip the Xs x1 = UUmMax(0, x1); x2 = UUmMin(x2, inImageWidth - 1); @@ -141,7 +141,7 @@ IMrImage_Draw_Line( // the origin of the image width = x2 - x1; offset = x1 + (y1 * row_bytes); - + switch (inImagePixelType) { // 1 byte @@ -149,30 +149,30 @@ IMrImage_Draw_Line( case IMcPixelType_A8: case IMcPixelType_A4I4: dst_1 = (UUtUns8*)inImageData + offset; - + while (width--) { *dst_1++ = (UUtUns8) inDrawColor.value; } break; - + // 2 byte case IMcPixelType_ARGB4444: case IMcPixelType_RGB555: case IMcPixelType_ARGB1555: dst_2 = (UUtUns16*)inImageData + offset; - + while (width--) { *dst_2++ = (UUtUns16) inDrawColor.value; } break; - + // 4 byte case IMcPixelType_ARGB8888: case IMcPixelType_RGB888: dst_4 = (UUtUns32*)inImageData + offset; - + while (width--) { *dst_4++ = inDrawColor.value; @@ -201,10 +201,10 @@ IMrImage_Draw_Rect( IMtPoint2D point2; IMtPoint2D point3; IMtPoint2D point4; - + UUmAssert(inImageData); UUmAssert(inDrawRect); - + point1.x = inDrawRect->left; point1.y = inDrawRect->top; point2.x = inDrawRect->right; @@ -213,7 +213,7 @@ IMrImage_Draw_Rect( point3.y = inDrawRect->bottom; point4.x = inDrawRect->left; point4.y = inDrawRect->bottom; - + // draw the top of the rect IMrImage_Draw_Line( inImageWidth, @@ -223,7 +223,7 @@ IMrImage_Draw_Rect( inDrawColor, &point1, &point2); - + // draw the right of the rect IMrImage_Draw_Line( inImageWidth, @@ -243,7 +243,7 @@ IMrImage_Draw_Rect( inDrawColor, &point3, &point4); - + // draw the left of the rect IMrImage_Draw_Line( inImageWidth, @@ -253,4 +253,4 @@ IMrImage_Draw_Rect( inDrawColor, &point4, &point1); -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_PixelConversion.c b/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_PixelConversion.c index 9fb3c75..1babcfb 100644 --- a/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_PixelConversion.c +++ b/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_PixelConversion.c @@ -1,12 +1,12 @@ /* FILE: BFW_Image_PixelConversion.c - + AUTHOR: Brent H. Pease - + CREATED: Nov 27, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -45,7 +45,7 @@ static UUtInt16 IMgDitherMatrix[IMcDitherDim][IMcDitherDim] = r = IMmShiftDownAndMask8(pixel, 16); \ g = IMmShiftDownAndMask8(pixel, 8); \ b = IMmShiftDownAndMask8(pixel, 0); \ - + #define IMmRGB888_to_rgb(pixel, r, g, b) \ r = IMmShiftDownAndMask8(pixel, 16); \ g = IMmShiftDownAndMask8(pixel, 8); \ @@ -88,35 +88,35 @@ static UUtInt16 IMgDitherMatrix[IMcDitherDim][IMcDitherDim] = pixel = IMmMask8AndShiftUp(r, 24); \ pixel |= IMmMask8AndShiftUp(g, 16); \ pixel |= IMmMask8AndShiftUp(b, 8); \ - + #define IMmARGB_to_ARGB1555(pixel, a, r, g, b) \ pixel = IMmMask1AndShiftUp(a, 15); \ pixel |= IMmMask5AndShiftUp(r, 10); \ pixel |= IMmMask5AndShiftUp(g, 5); \ pixel |= IMmMask5AndShiftUp(b, 0); \ - + #define IMmRGB_to_RGB555(pixel, r, g, b) \ pixel = IMmMask5AndShiftUp(r, 10); \ pixel |= IMmMask5AndShiftUp(g, 5); \ pixel |= IMmMask5AndShiftUp(b, 0); \ - + #define IMmARGB_to_ARGB4444(pixel, a, r, g, b) \ pixel = IMmMask8AndShiftUp(a, 12); \ pixel |= IMmMask8AndShiftUp(r, 8); \ pixel |= IMmMask8AndShiftUp(g, 4); \ pixel |= IMmMask8AndShiftUp(b, 0); \ - + #define IMmRGB888_to_I8(pixel, r, g, b) \ pixel = (r + g + b) / 3; #define IMmRGB555_to_I8(pixel, r, g, b) \ pixel = (r + g + b) / 3; \ pixel = (pixel << 3) | (pixel & 0x7); - + #define IMmRGB444_to_I8(pixel, r, g, b) \ pixel = (r + g + b) / 3; \ pixel = (pixel << 4) | (pixel & 0xF); - + typedef UUtError (*IMtConvertPixelType_Proc)( IMtDitherMode inDitherMode, @@ -136,7 +136,7 @@ static void iBuild_ConvertPixelType_Table(void); typedef struct { IMtPixelType from; IMtPixelType to; - IMtConvertPixelType_Proc function; + IMtConvertPixelType_Proc function; } IMtConverPixelType_LookupEntry; @@ -153,37 +153,37 @@ IMiConvert_RGB555_to_I8( { UUtUns16 x, y; UUtUns16 r, g, b; - + UUtUns16* srcPtr; UUtUns8* dstPtr; UUtUns16 pixel; - + UUtUns8* dstRowPtr; UUtUns16 dstRowBytes; dstRowBytes = IMrImage_ComputeRowBytes(IMcPixelType_I8, inWidth); - + srcPtr = inSrcData; dstRowPtr = outDstData; - + for(y = 0; y < inHeight; y++) { dstPtr = dstRowPtr; - + for(x = 0; x < inWidth; x++) { pixel = *srcPtr++; - + IMmARGB1555_to_rgb(pixel, r, g, b); - + IMmRGB555_to_I8(pixel, r, g, b); - + *dstPtr++ = (UUtUns8)pixel; } - + dstRowPtr += dstRowBytes; } - + return UUcError_None; } @@ -200,28 +200,28 @@ IMiConvert_ARGB4444_to_RGB555( { UUtUns16 x, y; UUtUns16 a, r, g, b; - + UUtUns16* srcPtr; UUtUns16* dstPtr; UUtUns16 pixel; - + srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = *srcPtr++; - + IMmARGB4444_to_argb(pixel, a, r, g, b); - + if(a == 0xF) { r = (r << 1) | (r & 0x01); g = (g << 1) | (g & 0x01); b = (b << 1) | (b & 0x01); - + IMmARGB_to_ARGB1555(pixel, 0x1, r, g, b); } else @@ -231,7 +231,7 @@ IMiConvert_ARGB4444_to_RGB555( *dstPtr++ = pixel; } } - + return UUcError_None; } @@ -268,7 +268,7 @@ IMiCopy_Row_ARGB8888( { UUtUns16 x; UUtUns32 pixel; - + for(x = 0; x < inWidth; x++) { pixel = *inSrcData++; @@ -288,7 +288,7 @@ IMiCopy_Row_RGB888( { UUtUns16 x; UUtUns32 pixel; - + for(x = 0; x < inWidth; x++) { pixel = *inSrcData++; @@ -313,23 +313,23 @@ IMiConvert_RGB555_to_ARGB4444( { UUtUns16 x, y; UUtInt16 r, g, b; - + UUtUns16* srcPtr; UUtUns16* dstPtr; UUtUns16 pixel; UUtInt16 bias; - + srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = *srcPtr++; - + IMmARGB1555_to_rgb(pixel, r, g, b); - + if(inDitherMode == IMcDitherMode_On) { // S.S. bias = IMgDitherMatrix[x & (IMcDitherDim-1)][y & (IMcDitherDim-1)] / 2; @@ -341,17 +341,17 @@ IMiConvert_RGB555_to_ARGB4444( g = UUmPin(g, 0, 31); b = UUmPin(b, 0, 31); } - + r >>= 1; g >>= 1; b >>= 1; - + IMmARGB_to_ARGB1555(pixel, 0xF, r, g, b); - + *dstPtr++ = pixel; } } - + return UUcError_None; } @@ -366,14 +366,14 @@ IMiConvert_A8_to_RGBA4444( void* outDstData) { UUtUns16 x, y; - + UUtUns8* srcPtr; UUtUns16* dstPtr; UUtUns16 pixel; - + srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) @@ -384,7 +384,7 @@ IMiConvert_A8_to_RGBA4444( *dstPtr++ = pixel | 0xFFF0; } } - + return UUcError_None; } @@ -399,19 +399,19 @@ IMiConvert_A8_to_RGBA_Bytes( void* outDstData) { UUtUns16 x, y; - + UUtUns8* srcPtr; UUtUns8* dstPtr; - + srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { UUtUns8 alpha = *srcPtr; - + dstPtr[0] = 0xff; // r dstPtr[1] = 0xff; // g dstPtr[2] = 0xff; // b @@ -421,7 +421,7 @@ IMiConvert_A8_to_RGBA_Bytes( dstPtr += 4; } } - + return UUcError_None; } @@ -441,15 +441,15 @@ IMiConvert_RGB555_to_ARGB1555( UUtUns32 alphas; // calculate the number of pixels in the image num_pixels = inWidth * inHeight >> 1; - + // copy the data and add an alpha src_data = inSrcData; dst_data = outDstData; alphas = 0x80008000; - + while (num_pixels--) *dst_data++ = *src_data++ | alphas; - + return UUcError_None; } @@ -466,23 +466,23 @@ IMiConvert_ARGB8888_to_ARGB4444( { UUtUns16 x, y; UUtInt16 a, r, g, b; - + UUtUns32* srcPtr; UUtUns16* dstPtr; UUtUns32 pixel; UUtInt16 bias; - + srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = *srcPtr++; - + IMmARGB8888_to_argb(pixel, a, r, g, b); - + if(inDitherMode == IMcDitherMode_On) { bias = IMgDitherMatrix[x & (IMcDitherDim-1)][y & (IMcDitherDim-1)]; @@ -495,18 +495,18 @@ IMiConvert_ARGB8888_to_ARGB4444( g = UUmPin(g, 0, UUcMaxUns8); b = UUmPin(b, 0, UUcMaxUns8); } - + a >>= 4; r >>= 4; g >>= 4; b >>= 4; - + IMmARGB_to_ARGB4444(pixel, a, r, g, b); - + *dstPtr++ = (UUtUns16)pixel; } } - + return UUcError_None; } @@ -522,53 +522,53 @@ IMiConvert_ARGB8888_to_RGB555( { UUtUns16 x, y; UUtInt16 a, r, g, b; - + UUtUns32* srcPtr; UUtUns16* dstPtr; UUtUns32 pixel; UUtInt16 bias; - + srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = *srcPtr++; - + IMmARGB8888_to_argb(pixel, a, r, g, b); - + if(a == 0xFF) { if(inDitherMode == IMcDitherMode_On) { bias = IMgDitherMatrix[x & (IMcDitherDim-1)][y & (IMcDitherDim-1)]; - + r += bias; g += bias; b += bias; - + r = UUmPin(r, 0, UUcMaxUns8); g = UUmPin(g, 0, UUcMaxUns8); b = UUmPin(b, 0, UUcMaxUns8); } - + r >>= 3; g >>= 3; b >>= 3; - + IMmARGB_to_ARGB1555(pixel, 0x1, r, g, b); } else { pixel = 0; } - + *dstPtr++ = (UUtUns16)pixel; } } - + return UUcError_None; } @@ -584,23 +584,23 @@ IMiConvert_ARGB8888_to_ARGB1555( { UUtUns16 x, y; UUtInt16 a, r, g, b; - + UUtUns32* srcPtr; UUtUns16* dstPtr; UUtUns32 pixel; UUtInt16 bias; - + srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = *srcPtr++; - + IMmARGB8888_to_argb(pixel, a, r, g, b); - + if(inDitherMode == IMcDitherMode_On) { bias = IMgDitherMatrix[x & (IMcDitherDim-1)][y & (IMcDitherDim-1)]; @@ -611,18 +611,18 @@ IMiConvert_ARGB8888_to_ARGB1555( g = UUmPin(g, 0, UUcMaxUns8); b = UUmPin(b, 0, UUcMaxUns8); } - + a = a == 0xFF; r >>= 3; g >>= 3; b >>= 3; - + IMmARGB_to_ARGB1555(pixel, a, r, g, b); - + *dstPtr++ = (UUtUns16)pixel; } } - + return UUcError_None; } @@ -639,48 +639,48 @@ IMiConvert_RGB888_to_ARGB4444( { UUtUns16 x, y; UUtInt16 a, r, g, b; - + UUtUns32* srcPtr; UUtUns16* dstPtr; UUtUns32 pixel; UUtInt16 bias; - + srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = *srcPtr++; - + IMmARGB8888_to_rgb(pixel, r, g, b); a = UUcMaxUns8; if(inDitherMode == IMcDitherMode_On) { bias = IMgDitherMatrix[x & (IMcDitherDim-1)][y & (IMcDitherDim-1)]; - + r += bias; g += bias; b += bias; - + r = UUmPin(r, 0, UUcMaxUns8); g = UUmPin(g, 0, UUcMaxUns8); b = UUmPin(b, 0, UUcMaxUns8); } - + a >>= 4; r >>= 4; g >>= 4; b >>= 4; - + IMmARGB_to_ARGB4444(pixel, a, r, g, b); - + *dstPtr++ = (UUtUns16)pixel; } } - + return UUcError_None; } @@ -696,25 +696,25 @@ IMiConvert_RGB888_to_RGB555( { UUtUns16 x, y; UUtInt16 r, g, b; - + UUtUns32* srcPtr; UUtUns16* dstPtr; UUtUns32 pixel; UUtInt16 bias; - + srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = *srcPtr++; - + r = (UUtUns16)((pixel >> 16) & 0xFF); g = (UUtUns16)((pixel >> 8) & 0xFF); b = (UUtUns16)((pixel >> 0) & 0xFF); - + if(inDitherMode == IMcDitherMode_On) { bias = IMgDitherMatrix[x & (IMcDitherDim-1)][y & (IMcDitherDim-1)]; @@ -725,16 +725,16 @@ IMiConvert_RGB888_to_RGB555( g = UUmPin(g, 0, UUcMaxUns8); b = UUmPin(b, 0, UUcMaxUns8); } - + r >>= 3; g >>= 3; b >>= 3; - + *dstPtr++ = (r << 10) | (g << 5) | (b); } } - + return UUcError_None; } @@ -749,34 +749,34 @@ IMiConvert_I8_to_RGB555( void* outDstData) { UUtUns16 x, y; - + UUtUns8* srcPtr; UUtUns16* dstPtr; UUtUns16 pixel; UUtInt16 bias; - + srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = *srcPtr++; - + if(inDitherMode == IMcDitherMode_On) { bias = IMgDitherMatrix[x & (IMcDitherDim-1)][y & (IMcDitherDim-1)]; pixel += bias; pixel = UUmPin(pixel, 0, UUcMaxUns8); } - + pixel >>= 3; - + *dstPtr++ = (pixel << 10) | (pixel << 5) | (pixel); } } - + return UUcError_None; } @@ -791,12 +791,12 @@ IMiConvert_I8_to_RGB_Bytes( void* outDstData) { UUtUns32 count = inWidth * inHeight; - + UUtUns8* endPtr; UUtUns8* srcPtr; UUtUns8* dstPtr; UUtUns8 pixel; - + srcPtr = inSrcData; dstPtr = outDstData; endPtr = srcPtr + count; @@ -804,14 +804,14 @@ IMiConvert_I8_to_RGB_Bytes( while(srcPtr < endPtr) { pixel = *srcPtr++; - + dstPtr[0] = pixel; dstPtr[1] = pixel; dstPtr[2] = pixel; dstPtr += 3; } - + return UUcError_None; } @@ -827,25 +827,25 @@ IMiConvert_RGB888_to_ARGB1555( { UUtUns16 x, y; UUtInt16 r, g, b; - + UUtUns32* srcPtr; UUtUns16* dstPtr; UUtUns32 pixel; UUtInt16 bias; - + srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = *srcPtr++; - + r = (UUtUns16)((pixel >> 16) & 0xFF); g = (UUtUns16)((pixel >> 8) & 0xFF); b = (UUtUns16)((pixel >> 0) & 0xFF); - + if(inDitherMode == IMcDitherMode_On) { bias = IMgDitherMatrix[x & (IMcDitherDim-1)][y & (IMcDitherDim-1)]; @@ -856,15 +856,15 @@ IMiConvert_RGB888_to_ARGB1555( g = UUmPin(g, 0, UUcMaxUns8); b = UUmPin(b, 0, UUcMaxUns8); } - + r >>= 3; g >>= 3; b >>= 3; - + *dstPtr++ = (1 << 15) | (r << 10) | (g << 5) | (b); } } - + return UUcError_None; } @@ -1252,7 +1252,7 @@ static void DecodeDXT1Block_To_RGBBytes( UUrMemory_MoveFast(rgb_colors[IMmShiftDownAndMask2(*inSrc,2)], out0 + 3, 3); UUrMemory_MoveFast(rgb_colors[IMmShiftDownAndMask2(*inSrc,4)], out0 + 6, 3); UUrMemory_MoveFast(rgb_colors[IMmShiftDownAndMask2(*inSrc,6)], out0 + 9, 3); - + UUrMemory_MoveFast(rgb_colors[IMmShiftDownAndMask2(*inSrc,8)], out1 + 0, 3); UUrMemory_MoveFast(rgb_colors[IMmShiftDownAndMask2(*inSrc,10)], out1 + 3, 3); UUrMemory_MoveFast(rgb_colors[IMmShiftDownAndMask2(*inSrc,12)], out1 + 6, 3); @@ -1263,7 +1263,7 @@ static void DecodeDXT1Block_To_RGBBytes( UUrMemory_MoveFast(rgb_colors[IMmShiftDownAndMask2(*inSrc,2)], out2 + 3, 3); UUrMemory_MoveFast(rgb_colors[IMmShiftDownAndMask2(*inSrc,4)], out2 + 6, 3); UUrMemory_MoveFast(rgb_colors[IMmShiftDownAndMask2(*inSrc,6)], out2 + 9, 3); - + UUrMemory_MoveFast(rgb_colors[IMmShiftDownAndMask2(*inSrc,8)], out3 + 0, 3); UUrMemory_MoveFast(rgb_colors[IMmShiftDownAndMask2(*inSrc,10)], out3 + 3, 3); UUrMemory_MoveFast(rgb_colors[IMmShiftDownAndMask2(*inSrc,12)], out3 + 6, 3); @@ -1369,7 +1369,7 @@ static void DecodeDXT1Block_To_RGBABytes( UUrMemory_MoveFast(rgba_colors[IMmShiftDownAndMask2(*inSrc,2)], out0 + 4, 4); UUrMemory_MoveFast(rgba_colors[IMmShiftDownAndMask2(*inSrc,4)], out0 + 8, 4); UUrMemory_MoveFast(rgba_colors[IMmShiftDownAndMask2(*inSrc,6)], out0 + 12, 4); - + UUrMemory_MoveFast(rgba_colors[IMmShiftDownAndMask2(*inSrc,8)], out1 + 0, 4); UUrMemory_MoveFast(rgba_colors[IMmShiftDownAndMask2(*inSrc,10)], out1 + 4, 4); UUrMemory_MoveFast(rgba_colors[IMmShiftDownAndMask2(*inSrc,12)], out1 + 8, 4); @@ -1380,7 +1380,7 @@ static void DecodeDXT1Block_To_RGBABytes( UUrMemory_MoveFast(rgba_colors[IMmShiftDownAndMask2(*inSrc,2)], out2 + 4, 4); UUrMemory_MoveFast(rgba_colors[IMmShiftDownAndMask2(*inSrc,4)], out2 + 8, 4); UUrMemory_MoveFast(rgba_colors[IMmShiftDownAndMask2(*inSrc,6)], out2 + 12, 4); - + UUrMemory_MoveFast(rgba_colors[IMmShiftDownAndMask2(*inSrc,8)], out3 + 0, 4); UUrMemory_MoveFast(rgba_colors[IMmShiftDownAndMask2(*inSrc,10)], out3 + 4, 4); UUrMemory_MoveFast(rgba_colors[IMmShiftDownAndMask2(*inSrc,12)], out3 + 8, 4); @@ -1436,7 +1436,7 @@ static UUtUns16 SelectColor( UUtInt16 rwish = (wish & (UUtUns16)(0x1f << 10)) >> 10; UUtInt16 gwish = (wish & (UUtUns16)(0x1f << 5)) >> 5; UUtInt16 bwish = (wish & (UUtUns16)(0x1f << 0)) >> 0; - + UUtInt16 choice = 0; UUtInt16 delta = UUcMaxInt16; UUtUns8 itr; @@ -1449,8 +1449,8 @@ static UUtUns16 SelectColor( r = (colors[itr] & rmask) >> 11; g = (colors[itr] & gmask) >> 6; b = (colors[itr] & bmask) >> 0; - - curDelta = abs(r - rwish); + + curDelta = abs(r - rwish); curDelta += abs(g - gwish); curDelta += abs(b - bwish); @@ -1528,10 +1528,10 @@ static void EncodeDXT1Block_From_ARGB1555( const UUtUns16 *inRow2, const UUtUns16 *inRow3, UUtUns16 *outDst) -{ +{ UUtUns16 rgb565_1, rgb565_2; UUtUns16 rgb555_1, rgb555_2; - + // find the two best colors rgb555_1 = FindFarColor(inRow0[0], inRow0, inRow1, inRow2, inRow3); rgb555_2 = FindFarColor(rgb555_1, inRow0, inRow1, inRow2, inRow3); @@ -1547,7 +1547,7 @@ static void EncodeDXT1Block_From_ARGB1555( r2 = rgb555_2 & (UUtUns16) (0x1f << 10); g2 = rgb555_2 & (UUtUns16) (0x1f << 5); b2 = rgb555_2 & (UUtUns16) (0x1f << 0); - + rgb565_1 = (r << 1) | (g << 1) | (b << 0); rgb565_2 = (r2 << 1) | (g2 << 1) | (b2 << 0); } @@ -1560,7 +1560,7 @@ static void EncodeDXT1Block_From_ARGB1555( *outDst++ = 0x0000; *outDst++ = 0x0000; } - else + else { UUtUns16 colors[4]; @@ -1638,13 +1638,13 @@ IMiConvert_ARGB1555_to_DXT1( rows[2] = rows[1] + inWidth; rows[3] = rows[2] + inWidth; - for(x = 0; x < blockWidth; x++) + for(x = 0; x < blockWidth; x++) { UUtUns16 src_x, src_y; UUtUns16 dst_x, dst_y; UUtUns16 data[4][4]; - UUrMemory_Set16(data, rows[0][0], sizeof(UUtUns16) * 4 * 4); + UUrMemory_Set16(data, rows[0][0], sizeof(UUtUns16) * 4 * 4); // copy, the clipped part in for(src_y = 0, dst_y = y * 4; dst_y < UUmMin(y * 4 + 4, inHeight); src_y++, dst_y++) @@ -1679,7 +1679,7 @@ IMiConvert_ARGB1555_to_DXT1( rows[2] = rows[1] + inWidth; rows[3] = rows[2] + inWidth; - for(x = 0; x < blockWidth; x++) + for(x = 0; x < blockWidth; x++) { EncodeDXT1Block_From_ARGB1555(rows[0], rows[1], rows[2], rows[3], curOutPtr); @@ -1760,7 +1760,7 @@ IMiConvert_DXT1_to_NByte( rows[2] = ((char *) rows[1]) + (inWidth * dst_size); rows[3] = ((char *) rows[2]) + (inWidth * dst_size); - for(x = 0; x < blockWidth; x++) + for(x = 0; x < blockWidth; x++) { UUtUns16 src_x, src_y; UUtUns16 dst_x, dst_y; @@ -1813,7 +1813,7 @@ IMiConvert_DXT1_to_NByte( row2 = ((char *) row1) + (inWidth * dst_size); row3 = ((char *) row2) + (inWidth * dst_size); - for(x = 0; x < blockWidth; x++) + for(x = 0; x < blockWidth; x++) { block_decode(curInPtr, row0, row1, row2, row3); @@ -1844,7 +1844,7 @@ IMrPixel_Convert( UUtUns8 r; UUtUns8 g; UUtUns8 b; - + switch (inSrcPixelType) { case IMcPixelType_ARGB4444: @@ -1854,14 +1854,14 @@ IMrPixel_Convert( case IMcPixelType_ARGB4444: *outDstPixel = inSrcPixel; break; - + case IMcPixelType_RGB555: r <<= 1; g <<= 1; b <<= 1; IMmRGB_to_RGB555(outDstPixel->value, r, g, b); break; - + case IMcPixelType_ARGB1555: (a > 0) ? (a = 1) : (a = 0); r <<= 1; @@ -1869,14 +1869,14 @@ IMrPixel_Convert( b <<= 1; IMmARGB_to_ARGB1555(outDstPixel->value, a, r, g, b); break; - + case IMcPixelType_I8: case IMcPixelType_I1: case IMcPixelType_A8: case IMcPixelType_A4I4: UUmAssert(!"Unimplemented"); break; - + case IMcPixelType_ARGB8888: a <<= 4; r <<= 4; @@ -1884,7 +1884,7 @@ IMrPixel_Convert( b <<= 4; IMmARGB_to_ARGB8888(outDstPixel->value, a, r, g, b); break; - + case IMcPixelType_RGB888: r <<= 4; g <<= 4; @@ -1893,7 +1893,7 @@ IMrPixel_Convert( break; } break; - + case IMcPixelType_RGB555: IMmRGB555_to_rgb(inSrcPixel.value, r, g, b); switch (inDstPixelType) @@ -1905,22 +1905,22 @@ IMrPixel_Convert( b >>= 1; IMmARGB_to_ARGB4444(outDstPixel->value, a, r, g, b); break; - + case IMcPixelType_RGB555: *outDstPixel = inSrcPixel; break; - + case IMcPixelType_ARGB1555: outDstPixel->value = inSrcPixel.value | 0x8000; break; - + case IMcPixelType_I8: case IMcPixelType_I1: case IMcPixelType_A8: case IMcPixelType_A4I4: UUmAssert(!"Unimplemented"); break; - + case IMcPixelType_ARGB8888: a = 0xFF; r <<= 3; @@ -1928,7 +1928,7 @@ IMrPixel_Convert( b <<= 3; IMmARGB_to_ARGB8888(outDstPixel->value, a, r, g, b); break; - + case IMcPixelType_RGB888: r <<= 3; g <<= 3; @@ -1937,7 +1937,7 @@ IMrPixel_Convert( break; } break; - + case IMcPixelType_ARGB1555: IMmARGB1555_to_argb(inSrcPixel.value, a, r, g, b); switch (inDstPixelType) @@ -1949,22 +1949,22 @@ IMrPixel_Convert( b >>= 1; IMmARGB_to_ARGB4444(outDstPixel->value, a, r, g, b); break; - + case IMcPixelType_RGB555: *outDstPixel = inSrcPixel; break; - + case IMcPixelType_ARGB1555: *outDstPixel = inSrcPixel; break; - + case IMcPixelType_I8: case IMcPixelType_I1: case IMcPixelType_A8: case IMcPixelType_A4I4: UUmAssert(!"Unimplemented"); break; - + case IMcPixelType_ARGB8888: (a == 1) ? (a = 0xFF) : (a = 0); r <<= 3; @@ -1972,7 +1972,7 @@ IMrPixel_Convert( b <<= 3; IMmARGB_to_ARGB8888(outDstPixel->value, a, r, g, b); break; - + case IMcPixelType_RGB888: r <<= 3; g <<= 3; @@ -1981,14 +1981,14 @@ IMrPixel_Convert( break; } break; - + case IMcPixelType_I8: case IMcPixelType_I1: case IMcPixelType_A8: case IMcPixelType_A4I4: UUmAssert(!"Unimplemented"); break; - + case IMcPixelType_ARGB8888: IMmARGB8888_to_argb(inSrcPixel.value, a, r, g, b); switch (inDstPixelType) @@ -2000,14 +2000,14 @@ IMrPixel_Convert( b >>= 4; IMmARGB_to_ARGB4444(outDstPixel->value, a, r, g, b); break; - + case IMcPixelType_RGB555: r >>= 3; g >>= 3; b >>= 3; IMmRGB_to_RGB555(outDstPixel->value, r, g, b); break; - + case IMcPixelType_ARGB1555: (a > 0) ? (a = 1) : (a = 0); r >>= 3; @@ -2015,24 +2015,24 @@ IMrPixel_Convert( b >>= 3; IMmARGB_to_ARGB1555(outDstPixel->value, a, r, g, b); break; - + case IMcPixelType_I8: case IMcPixelType_I1: case IMcPixelType_A8: case IMcPixelType_A4I4: UUmAssert(!"Unimplemented"); break; - + case IMcPixelType_ARGB8888: *outDstPixel = inSrcPixel; break; - + case IMcPixelType_RGB888: *outDstPixel = inSrcPixel; break; } break; - + case IMcPixelType_RGB888: IMmRGB888_to_rgb(inSrcPixel.value, r, g, b); a = 0xFF; @@ -2045,7 +2045,7 @@ IMrPixel_Convert( b >>= 4; IMmARGB_to_ARGB4444(outDstPixel->value, a, r, g, b); break; - + case IMcPixelType_RGB555: a = 0xF; r >>= 3; @@ -2053,7 +2053,7 @@ IMrPixel_Convert( b >>= 3; IMmRGB_to_RGB555(outDstPixel->value, r, g, b); break; - + case IMcPixelType_ARGB1555: a = 1; r >>= 3; @@ -2061,18 +2061,18 @@ IMrPixel_Convert( b >>= 3; IMmARGB_to_ARGB1555(outDstPixel->value, a, r, g, b); break; - + case IMcPixelType_I8: case IMcPixelType_I1: case IMcPixelType_A8: case IMcPixelType_A4I4: UUmAssert(!"Unimplemented"); break; - + case IMcPixelType_ARGB8888: *outDstPixel = inSrcPixel; break; - + case IMcPixelType_RGB888: *outDstPixel = inSrcPixel; break; @@ -2102,8 +2102,8 @@ IMrImage_ConvertPixelType( } conversionProc = IMgConvertPixelType_Table[inDstPixelType][inSrcPixelType]; - - if (NULL != conversionProc) + + if (NULL != conversionProc) { UUtUns16 width = inWidth; UUtUns16 height = inHeight; @@ -2156,18 +2156,18 @@ IMiConvert_ARGB4444_to_ARGB8888( { UUtUns16 x, y; UUtUns32 a, r, g, b; - + UUtUns16* srcPtr; UUtUns32* dstPtr; UUtUns16 srcPixel; UUtUns32 dstPixel; - + UUmAssertReadPtr(inSrcData, 2 * inWidth * inHeight); UUmAssertWritePtr(outDstData, 4 * inWidth * inHeight); srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) @@ -2183,13 +2183,13 @@ IMiConvert_ARGB4444_to_ARGB8888( r = (r << 4) | r; g = (g << 4) | g; b = (b << 4) | b; - + dstPixel = (a << 24) | (r << 16) | (g << 8) | (b << 0); *dstPtr++ = dstPixel; } } - + return UUcError_None; } @@ -2205,36 +2205,36 @@ IMiConvert_RGB555_to_RGB888( { UUtUns16 x, y; UUtUns16 r, g, b; - + UUtUns16* srcPtr; UUtUns32* dstPtr; UUtUns16 pixel; UUtUns32 dstPixel; - + UUmAssertReadPtr(inSrcData, 2 * inWidth * inHeight); UUmAssertWritePtr(outDstData, 4 * inWidth * inHeight); srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = *srcPtr++; - + IMmARGB1555_to_rgb(pixel, r, g, b); - + r = (r << 3) | r; g = (g << 3) | g; b = (b << 3) | b; - + IMmARGB_to_ARGB8888(dstPixel, 0xFF, r, g, b); - + *dstPtr++ = dstPixel; } } - + return UUcError_None; } @@ -2250,27 +2250,27 @@ IMiConvert_RGB555_to_RGB_Bytes( { UUtUns16 x, y; UUtUns8 r, g, b; - + UUtUns16* srcPtr; UUtUns8* dstPtr; UUtUns16 pixel; - + UUmAssertReadPtr(inSrcData, 2 * inWidth * inHeight); UUmAssertWritePtr(outDstData, 4 * inWidth * inHeight); srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = srcPtr[0]; - + r = (UUtUns8) (((pixel & (0x3f << 10)) >> 10) << 3); g = (UUtUns8) (((pixel & (0x3f << 5)) >> 5) << 3); b = (UUtUns8) (((pixel & (0x3f << 0)) >> 0) << 3); - + dstPtr[0] = r; dstPtr[1] = g; dstPtr[2] = b; @@ -2279,7 +2279,7 @@ IMiConvert_RGB555_to_RGB_Bytes( dstPtr += 3; } } - + return UUcError_None; } @@ -2295,27 +2295,27 @@ IMiConvert_RGB555_to_RGBA_Bytes( { UUtUns16 x, y; UUtUns8 r, g, b; - + UUtUns16* srcPtr; UUtUns8* dstPtr; UUtUns16 pixel; - + UUmAssertReadPtr(inSrcData, 2 * inWidth * inHeight); UUmAssertWritePtr(outDstData, 4 * inWidth * inHeight); srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = srcPtr[0]; - + r = (UUtUns8) (((pixel & (0x3f << 10)) >> 10) << 3); g = (UUtUns8) (((pixel & (0x3f << 5)) >> 5) << 3); b = (UUtUns8) (((pixel & (0x3f << 0)) >> 0) << 3); - + dstPtr[0] = r; dstPtr[1] = g; dstPtr[2] = b; @@ -2325,7 +2325,7 @@ IMiConvert_RGB555_to_RGBA_Bytes( dstPtr += 4; } } - + return UUcError_None; } static UUtError @@ -2340,36 +2340,36 @@ IMiConvert_ARGB1555_to_ARGB8888( { UUtUns16 x, y; UUtUns16 r, g, b; - + UUtUns16* srcPtr; UUtUns32* dstPtr; UUtUns16 pixel; UUtUns32 dstPixel; - + UUmAssertReadPtr(inSrcData, 2 * inWidth * inHeight); UUmAssertWritePtr(outDstData, 4 * inWidth * inHeight); srcPtr = inSrcData; dstPtr = outDstData; - + for(y = 0; y < inHeight; y++) { for(x = 0; x < inWidth; x++) { pixel = *srcPtr++; - + IMmARGB1555_to_rgb(pixel, r, g, b); - + r = (r << 3) | r; g = (g << 3) | g; b = (b << 3) | b; - + IMmARGB_to_ARGB8888(dstPixel, 0xFF, r, g, b); - + *dstPtr++ = dstPixel; } } - + return UUcError_None; } @@ -2388,7 +2388,7 @@ IMiConvert_ARGB4444_to_RGBA_Bytes( UUtUns16 *pSrc = inSrcData; UUtUns8 *pDst = outDstData; - for(loop = 0; loop < count; loop++) + for(loop = 0; loop < count; loop++) { UUtUns8 a,r,g,b; @@ -2429,7 +2429,7 @@ IMiConvert_ARGB1555_to_RGBA_Bytes( UUtUns16 *pSrc = inSrcData; UUtUns8 *pDst = outDstData; - for(loop = 0; loop < count; loop++) + for(loop = 0; loop < count; loop++) { UUtUns8 a,r,g,b; @@ -2472,7 +2472,7 @@ IMiConvert_RGB555_to_RGBA_5551( UUtUns16 *pSrc = inSrcData; UUtUns16 *pDst = outDstData; - for(loop = 0; loop < count; loop++) + for(loop = 0; loop < count; loop++) { UUtUns16 block; @@ -2502,7 +2502,7 @@ IMiConvert_ARGB1555_to_RGBA_5551( UUtUns16 *pSrc = inSrcData; UUtUns16 *pDst = outDstData; - for(loop = 0; loop < count; loop++) + for(loop = 0; loop < count; loop++) { UUtUns16 block; @@ -2533,7 +2533,7 @@ IMiConvert_ARGB4444_to_RGBA_4444( UUtUns16 *pSrc = inSrcData; UUtUns16 *pDst = outDstData; - for(loop = 0; loop < count; loop++) + for(loop = 0; loop < count; loop++) { UUtUns16 block; @@ -2563,7 +2563,7 @@ static UUtError IMiConvert_RGB888_to_RGB_Bytes( UUtUns32 *pSrc = inSrcData; UUtUns8 *pDst = outDstData; - for(loop = 0; loop < count; loop++) + for(loop = 0; loop < count; loop++) { UUtUns32 chunk = *pSrc; UUtUns32 r = (chunk >> 16) & 0xFF; @@ -2654,7 +2654,7 @@ static IMtConverPixelType_LookupEntry IMgConvertPixelType_List[] = { IMcPixelType_DXT1, IMcPixelType_RGBA_Bytes,IMiConvert_DXT1_to_NByte}, //{ IMcPixelType_DXT1, IMcPixelType_RGB_Bytes, IMiConvert_DXT1_to_RGB_Bytes}, - + { IMcPixelType_ARGB1555, IMcPixelType_DXT1, IMiConvert_ARGB1555_to_DXT1}, { IMcPixelType_RGB555, IMcPixelType_DXT1, IMiConvert_ARGB1555_to_DXT1}, @@ -2684,7 +2684,7 @@ static void iBuild_ConvertPixelType_Table(void) UUmAssert(curEntry->to < IMcNumPixelTypes); UUmAssert(curEntry->from < IMcNumPixelTypes); UUmAssert(NULL == IMgConvertPixelType_Table[curEntry->to][curEntry->from]); - + IMgConvertPixelType_Table[curEntry->to][curEntry->from] = curEntry->function; } @@ -2696,4 +2696,4 @@ static void iBuild_ConvertPixelType_Table(void) IMgConvertPixelType_Table_Built = UUcTrue; return; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Private.h b/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Private.h index 5520122..7212f65 100644 --- a/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Private.h @@ -1,12 +1,12 @@ /* FILE: BFW_Image_Private.h - + AUTHOR: Brent H. Pease - + CREATED: Nov 27, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ #ifndef BFW_IMAGE_PRIVATE_H @@ -37,7 +37,7 @@ IMrImage_Scale_Box_IndependantAlpha( typedef struct IMtDitherPixel { UUtInt16 a, r, g, b; - + } IMtDitherPixel; void diff --git a/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Scale_Box.c b/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Scale_Box.c index dfe007f..1db3fe4 100644 --- a/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Scale_Box.c +++ b/BungieFrameWork/BFW_Source/BFW_Image/BFW_Image_Scale_Box.c @@ -1,12 +1,12 @@ /* FILE: BFW_Image_Scale_Box.c - + AUTHOR: Brent H. Pease - + CREATED: Nov 27, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -38,41 +38,41 @@ IMiImage_Scale_Box_Down_RGB888_PowerOfTwo( UUtUns32 dstWidth = inSrcWidth >> inShiftAmount; UUtUns32 dstHeight = inSrcHeight >> inShiftAmount; - + UUtUns32* dstRowStartPtr; UUtUns32* srcRowStartPtr; UUtUns32* dstPtr; UUtUns32* srcPtr; - + /* the pixmap needs to be shrunk in x and y */ multiplier = 1 << inShiftAmount; dividing_shift = inShiftAmount * 2; round_number = (1 << dividing_shift) >> 1; half_multiplier = multiplier >> 1; - + /* * We are going to traverse the destination map filtering each * corresponding block in the source map down to a single pixel */ - + dstRowStartPtr = outDstData; for(desty = 0; desty < dstHeight; desty++) { dstPtr = dstRowStartPtr; - + for(destx = 0; destx < dstWidth; destx++) - { + { cumr = cumg = cumb = round_number; // so we round instead of going down //srcRowStartPtr = ((UUtUns32 *) inSrcData) + (desty * multiplier) * inSrcWidth + (destx * multiplier); srcRowStartPtr = ((UUtUns32 *) inSrcData) + (((desty * inSrcWidth) + destx) << inShiftAmount); - + for(srcy = 0; srcy < multiplier; srcy++) { srcPtr = srcRowStartPtr; - + for(srcx = 0; srcx < half_multiplier; srcx++) { UUtUns32 pixel1; @@ -91,10 +91,10 @@ IMiImage_Scale_Box_Down_RGB888_PowerOfTwo( cumg += (pixel2 >> 8) & 0xFF; cumb += (pixel2 >> 0) & 0xFF; } - + srcRowStartPtr += inSrcWidth; } - + cumr = cumr >> dividing_shift; cumg = cumg >> dividing_shift; cumb = cumb >> dividing_shift; @@ -102,10 +102,10 @@ IMiImage_Scale_Box_Down_RGB888_PowerOfTwo( UUmAssert(cumr <= 0xff); UUmAssert(cumg <= 0xff); UUmAssert(cumb <= 0xff); - + *dstPtr++ = (cumr << 16) | (cumg << 8) | cumb; } - + dstRowStartPtr += dstWidth; } } @@ -126,19 +126,19 @@ IMiImage_Scale_Box_Down_RGB888( UUtUns32 numPixels; UUtUns32 sx, sy, ex, ey; UUtUns32 srcLength = sizeof(UUtUns32) * inSrcWidth * inSrcHeight; - + UUtUns32* dstRowStartPtr; UUtUns32* srcRowStartPtr; UUtUns32* dstPtr; UUtUns32* srcPtr; - + /* the pixmap needs to be shrunk in x and y */ { UUtUns32 width_multiplier = inSrcWidth / inDstWidth; UUtUns32 height_multiplier = inSrcHeight / inDstHeight; - if (width_multiplier == height_multiplier) + if (width_multiplier == height_multiplier) { if ((inSrcWidth == (width_multiplier * inDstWidth)) && (inSrcHeight == (height_multiplier * inDstHeight))) { @@ -156,7 +156,7 @@ IMiImage_Scale_Box_Down_RGB888( case 256: shift = 8; break; } - if (shift != 0) + if (shift != 0) { IMiImage_Scale_Box_Down_RGB888_PowerOfTwo(inSrcWidth, inSrcHeight, inSrcData, shift, outDstData); return UUcError_None; @@ -164,32 +164,32 @@ IMiImage_Scale_Box_Down_RGB888( } } } - + /* compute the gradients to 16 bits of fractional precision */ my = (inSrcHeight << 16) / inDstHeight; mx = (inSrcWidth << 16) / inDstWidth; - + /* * We are going to traverse the destination map filtering each * corresponding block in the source map down to a single pixel */ - + dstRowStartPtr = outDstData; for(desty = 0; desty < inDstHeight; desty++) { dstPtr = dstRowStartPtr; - + for(destx = 0; destx < inDstWidth; destx++) { - /* compute the starting x, y and then the ending x, y in the source + /* compute the starting x, y and then the ending x, y in the source pixmap space */ sx = (destx * mx) >> 16; sy = (desty * my) >> 16; - + ex = (destx * mx + mx) >> 16; ey = (desty * my + my) >> 16; - + cumr = cumg = cumb = 0; srcRowStartPtr = (UUtUns32 *) inSrcData + sy * inSrcWidth + sx; @@ -197,12 +197,12 @@ IMiImage_Scale_Box_Down_RGB888( numPixels = (ex - sx) * (ey - sy); UUmAssert(numPixels > 0); - + for(srcy = sy; srcy < ey; srcy++) { UUmAssert((srcy >= 0) && (srcy < inSrcHeight)); srcPtr = srcRowStartPtr; - + for(srcx = sx; srcx < ex; srcx++) { UUmAssert((srcx >=0) && (srcx < inSrcWidth)); @@ -213,20 +213,20 @@ IMiImage_Scale_Box_Down_RGB888( cumg += (pixel >> 8) & 0xFF; cumb += (pixel) & 0xFF; } - + srcRowStartPtr += inSrcWidth; } - + cumr = MUrFloat_Round_To_Int((float) cumr / numPixels); cumg = MUrFloat_Round_To_Int((float) cumg / numPixels); cumb = MUrFloat_Round_To_Int((float) cumb / numPixels); - + *dstPtr++ = (cumr << 16) | (cumg << 8) | cumb; } - + dstRowStartPtr += inDstWidth; } - + return UUcError_None; } @@ -246,39 +246,39 @@ IMiImage_Scale_Box_Down_RGB555( UUtUns32 numPixels; UUtUns32 sx, sy, ex, ey; UUtUns32 srcLength = 2 * inSrcWidth * inSrcHeight; - + UUtUns16* dstRowStartPtr; UUtUns16* srcRowStartPtr; UUtUns16* dstPtr; UUtUns16* srcPtr; - + /* the pixmap needs to be shrunk in x and y */ - + /* compute the gradients to 16 bits of fractional precision */ my = (inSrcHeight << 16) / inDstHeight; mx = (inSrcWidth << 16) / inDstWidth; - + /* * We are going to traverse the destination map filtering each * corresponding block in the source map down to a single pixel */ - + dstRowStartPtr = outDstData; for(desty = 0; desty < inDstHeight; desty++) { dstPtr = dstRowStartPtr; - + for(destx = 0; destx < inDstWidth; destx++) { - /* compute the starting x, y and then the ending x, y in the source + /* compute the starting x, y and then the ending x, y in the source pixmap space */ sx = (destx * mx) >> 16; sy = (desty * my) >> 16; - + ex = (destx * mx + mx) >> 16; ey = (desty * my + my) >> 16; - + cumr = cumg = cumb = 0; srcRowStartPtr = (UUtUns16*)inSrcData + sy * inSrcWidth + sx; @@ -286,12 +286,12 @@ IMiImage_Scale_Box_Down_RGB555( numPixels = (ex - sx) * (ey - sy); UUmAssert(numPixels > 0); - + for(srcy = sy; srcy < ey; srcy++) { UUmAssert((srcy >= 0) && (srcy < inSrcHeight)); srcPtr = srcRowStartPtr; - + for(srcx = sx; srcx < ex; srcx++) { UUmAssert((srcx >=0) && (srcx < inSrcWidth)); @@ -302,20 +302,20 @@ IMiImage_Scale_Box_Down_RGB555( cumg += (pixel >> 5) & 0x1F; cumb += (pixel >> 0) & 0x1F; } - + srcRowStartPtr += inSrcWidth; } - + cumr = MUrUnsignedSmallFloat_To_Uns_Round((float) cumr / numPixels); cumg = MUrUnsignedSmallFloat_To_Uns_Round((float) cumg / numPixels); cumb = MUrUnsignedSmallFloat_To_Uns_Round((float) cumb / numPixels); - + *dstPtr++ = (UUtUns16)((1 << 15) | (cumr << 10) | (cumg << 5) | cumb); } - + dstRowStartPtr += inDstWidth; } - + return UUcError_None; } @@ -335,80 +335,80 @@ IMiImage_Scale_Box_Down_ARGB8888( UUtUns32 a; UUtUns32 numPixels; UUtUns32 sx, sy, ex, ey; - + UUtUns32* dstRowStartPtr; UUtUns32* srcRowStartPtr; UUtUns32* dstPtr; UUtUns32* srcPtr; UUtUns32 inSrcLength = 4 * inSrcWidth * inSrcHeight; - + /* the pixmap needs to be shrunk in x and y */ - + /* compute the gradients to 16 bits of fractional precision */ my = ((inSrcHeight - 1) << 16) / inDstHeight; mx = ((inSrcWidth - 1) << 16) / inDstWidth; - + /* * We are going to traverse the destination map filtering each * corresponding block in the source map down to a single pixel */ - + dstRowStartPtr = outDstData; for(desty = 0; desty < inDstHeight; desty++) { dstPtr = dstRowStartPtr; - + for(destx = 0; destx < inDstWidth; destx++) { - /* compute the starting x, y and then the ending x, y in the source + /* compute the starting x, y and then the ending x, y in the source pixmap space */ sx = (destx * mx) >> 16; sy = (desty * my) >> 16; - + ex = (destx * mx + mx) >> 16; ey = (desty * my + my) >> 16; - + cuma = cumr = cumg = cumb = 0; - + srcRowStartPtr = (UUtUns32*)inSrcData + sy * inSrcWidth + sx; - + numPixels = (ex - sx + 1) * (ey - sy + 1); - + /* Filtering is inclusive so we iterate at least once */ for(srcy = sy; srcy <= ey; srcy++) { UUmAssert((srcy >= 0) && (srcy < inSrcHeight)); srcPtr = srcRowStartPtr; - + for(srcx = sx; srcx <= ex; srcx++) { UUmAssert((srcx >=0) && (srcx < inSrcWidth)); UUmAssertInRange(srcPtr, inSrcData, inSrcLength); pixel = *srcPtr++; - + a = (pixel >> 24) & 0xFF; - + cuma += a; cumr += a * ((pixel >> 16) & 0xFF); cumg += a * ((pixel >> 8) & 0xFF); cumb += a * ((pixel) & 0xFF); } - + srcRowStartPtr += inSrcWidth; } - + if (cuma > 0) { cumr = MUrUnsignedSmallFloat_To_Uns_Round((float) cumr / cuma); cumg = MUrUnsignedSmallFloat_To_Uns_Round((float) cumg / cuma); cumb = MUrUnsignedSmallFloat_To_Uns_Round((float) cumb / cuma); } - + cuma = MUrUnsignedSmallFloat_To_Uns_Round((float) cuma / numPixels); - + UUmAssert(cuma <= 0xff); UUmAssert(cumr <= 0xff); UUmAssert(cumg <= 0xff); @@ -416,10 +416,10 @@ IMiImage_Scale_Box_Down_ARGB8888( *dstPtr++ = (cuma << 24) | (cumr << 16) | (cumg << 8) | cumb; } - + dstRowStartPtr += inDstWidth; } - + return UUcError_None; } @@ -440,55 +440,55 @@ IMiImage_Scale_Box_Down_ARGB1555( UUtUns32 numPixels; UUtUns32 sx, sy, ex, ey; UUtUns32 srcLength = 2 * inSrcWidth * inSrcHeight; - + UUtUns16* dstRowStartPtr; UUtUns16* srcRowStartPtr; UUtUns16* dstPtr; UUtUns16* srcPtr; - + // Not really sure what exactly to do with the alpha at the edges here... - + /* the pixmap needs to be shrunk in x and y */ - + /* compute the gradients to 16 bits of fractional precision */ my = (inSrcHeight << 16) / inDstHeight; mx = (inSrcWidth << 16) / inDstWidth; - + /* * We are going to traverse the destination map filtering each * corresponding block in the source map down to a single pixel */ - + dstRowStartPtr = outDstData; for(desty = 0; desty < inDstHeight; desty++) { dstPtr = dstRowStartPtr; - + for(destx = 0; destx < inDstWidth; destx++) { - /* compute the starting x, y and then the ending x, y in the source + /* compute the starting x, y and then the ending x, y in the source pixmap space */ sx = (destx * mx) >> 16; sy = (desty * my) >> 16; - + ex = (destx * mx + mx) >> 16; ey = (desty * my + my) >> 16; - + cuma = cumr = cumg = cumb = 0; - + srcRowStartPtr = (UUtUns16*)inSrcData + sy * inSrcWidth + sx; - + numPixels = (ex - sx) * (ey - sy); UUmAssert(numPixels > 0); - + /* Filtering is inclusive so we iterate at least once */ for(srcy = sy; srcy < ey; srcy++) { UUmAssert((srcy >= 0) && (srcy < inSrcHeight)); srcPtr = srcRowStartPtr; - + for(srcx = sx; srcx < ex; srcx++) { UUmAssert((srcx >=0) && (srcx < inSrcWidth)); @@ -505,29 +505,29 @@ IMiImage_Scale_Box_Down_ARGB1555( cumb += (pixel) & 0x1F; } } - + srcRowStartPtr += inSrcWidth; } - + if (cuma > 0) { cumr = MUrUnsignedSmallFloat_To_Uns_Round((float) cumr / cuma); cumg = MUrUnsignedSmallFloat_To_Uns_Round((float) cumg / cuma); cumb = MUrUnsignedSmallFloat_To_Uns_Round((float) cumb / cuma); } - - cuma = MUrUnsignedSmallFloat_To_Uns_Round((float) cuma / numPixels); + + cuma = MUrUnsignedSmallFloat_To_Uns_Round((float) cuma / numPixels); UUmAssert(cuma <= 0x1); UUmAssert(cumr <= 0x1f); UUmAssert(cumg <= 0x1f); UUmAssert(cumb <= 0x1f); - + *dstPtr++ = (UUtUns16)((cuma << 15) | (cumr << 10) | (cumg << 5) | cumb); } - + dstRowStartPtr += inDstWidth; } - + return UUcError_None; } @@ -548,55 +548,55 @@ IMiImage_Scale_Box_Down_ARGB4444( UUtUns32 numPixels; UUtUns32 sx, sy, ex, ey; UUtUns32 inSrcLength = 2 * inSrcWidth * inSrcHeight; - + UUtUns16* dstRowStartPtr; UUtUns16* srcRowStartPtr; UUtUns16* dstPtr; UUtUns16* srcPtr; - + // Not really sure what exactly to do with the alpha at the edges here... - + /* the pixmap needs to be shrunk in x and y */ - + /* compute the gradients to 16 bits of fractional precision */ my = (inSrcHeight << 16) / inDstHeight; mx = (inSrcWidth << 16) / inDstWidth; - + /* * We are going to traverse the destination map filtering each * corresponding block in the source map down to a single pixel */ - + dstRowStartPtr = outDstData; for(desty = 0; desty < inDstHeight; desty++) { dstPtr = dstRowStartPtr; - + for(destx = 0; destx < inDstWidth; destx++) { - /* compute the starting x, y and then the ending x, y in the source + /* compute the starting x, y and then the ending x, y in the source pixmap space */ sx = (destx * mx) >> 16; sy = (desty * my) >> 16; - + ex = (destx * mx + mx) >> 16; ey = (desty * my + my) >> 16; - + cuma = cumr = cumg = cumb = 0; - + srcRowStartPtr = (UUtUns16*)inSrcData + sy * inSrcWidth + sx; - + numPixels = (ex - sx) * (ey - sy); UUmAssert(numPixels > 0); - + for(srcy = sy; srcy < ey; srcy++) { UUmAssert((srcy >= 0) && (srcy < inSrcHeight)); srcPtr = srcRowStartPtr; - + for(srcx = sx; srcx < ex; srcx++) { UUmAssert((srcx >=0) && (srcx < inSrcWidth)); @@ -611,17 +611,17 @@ IMiImage_Scale_Box_Down_ARGB4444( cumg += a * ((pixel >> 4) & 0xF); cumb += a * ((pixel) & 0xF); } - + srcRowStartPtr += inSrcWidth; } - + if (cuma > 0) { cumr = MUrUnsignedSmallFloat_To_Uns_Round((float) cumr / cuma); cumg = MUrUnsignedSmallFloat_To_Uns_Round((float) cumg / cuma); cumb = MUrUnsignedSmallFloat_To_Uns_Round((float) cumb / cuma); } - + cuma = MUrUnsignedSmallFloat_To_Uns_Round((float) cuma / numPixels); UUmAssert(cuma <= 0xf); @@ -631,10 +631,10 @@ IMiImage_Scale_Box_Down_ARGB4444( *dstPtr++ = (UUtUns16)((cuma << 12) | (cumr << 8) | (cumg << 4) | cumb); } - + dstRowStartPtr += inDstWidth; } - + return UUcError_None; } @@ -654,77 +654,77 @@ IMiImage_Scale_Box_Down_ARGB8888_IndependantAlpha( UUtUns32 a; UUtUns32 numPixels; UUtUns32 sx, sy, ex, ey; - + UUtUns32* dstRowStartPtr; UUtUns32* srcRowStartPtr; UUtUns32* dstPtr; UUtUns32* srcPtr; UUtUns32 inSrcLength = 4 * inSrcWidth * inSrcHeight; - + /* the pixmap needs to be shrunk in x and y */ - + /* compute the gradients to 16 bits of fractional precision */ my = ((inSrcHeight - 1) << 16) / inDstHeight; mx = ((inSrcWidth - 1) << 16) / inDstWidth; - + /* * We are going to traverse the destination map filtering each * corresponding block in the source map down to a single pixel */ - + dstRowStartPtr = outDstData; for(desty = 0; desty < inDstHeight; desty++) { dstPtr = dstRowStartPtr; - + for(destx = 0; destx < inDstWidth; destx++) { - /* compute the starting x, y and then the ending x, y in the source + /* compute the starting x, y and then the ending x, y in the source pixmap space */ sx = (destx * mx) >> 16; sy = (desty * my) >> 16; - + ex = (destx * mx + mx) >> 16; ey = (desty * my + my) >> 16; - + cuma = cumr = cumg = cumb = 0; - + srcRowStartPtr = (UUtUns32*)inSrcData + sy * inSrcWidth + sx; - + numPixels = (ex - sx + 1) * (ey - sy + 1); - + /* Filtering is inclusive so we iterate at least once */ for(srcy = sy; srcy <= ey; srcy++) { UUmAssert((srcy >= 0) && (srcy < inSrcHeight)); srcPtr = srcRowStartPtr; - + for(srcx = sx; srcx <= ex; srcx++) { UUmAssert((srcx >=0) && (srcx < inSrcWidth)); UUmAssertInRange(srcPtr, inSrcData, inSrcLength); pixel = *srcPtr++; - + a = (pixel >> 24) & 0xFF; - + cuma += a; cumr += ((pixel >> 16) & 0xFF); cumg += ((pixel >> 8) & 0xFF); cumb += ((pixel) & 0xFF); } - + srcRowStartPtr += inSrcWidth; } - + cumr = MUrUnsignedSmallFloat_To_Uns_Round((float) cumr / numPixels); cumg = MUrUnsignedSmallFloat_To_Uns_Round((float) cumg / numPixels); cumb = MUrUnsignedSmallFloat_To_Uns_Round((float) cumb / numPixels); cuma = MUrUnsignedSmallFloat_To_Uns_Round((float) cuma / numPixels); - + UUmAssert(cuma <= 0xff); UUmAssert(cumr <= 0xff); UUmAssert(cumg <= 0xff); @@ -732,10 +732,10 @@ IMiImage_Scale_Box_Down_ARGB8888_IndependantAlpha( *dstPtr++ = (cuma << 24) | (cumr << 16) | (cumg << 8) | cumb; } - + dstRowStartPtr += inDstWidth; } - + return UUcError_None; } @@ -756,55 +756,55 @@ IMiImage_Scale_Box_Down_ARGB1555_IndependantAlpha( UUtUns32 numPixels; UUtUns32 sx, sy, ex, ey; UUtUns32 srcLength = 2 * inSrcWidth * inSrcHeight; - + UUtUns16* dstRowStartPtr; UUtUns16* srcRowStartPtr; UUtUns16* dstPtr; UUtUns16* srcPtr; - + // Not really sure what exactly to do with the alpha at the edges here... - + /* the pixmap needs to be shrunk in x and y */ - + /* compute the gradients to 16 bits of fractional precision */ my = (inSrcHeight << 16) / inDstHeight; mx = (inSrcWidth << 16) / inDstWidth; - + /* * We are going to traverse the destination map filtering each * corresponding block in the source map down to a single pixel */ - + dstRowStartPtr = outDstData; for(desty = 0; desty < inDstHeight; desty++) { dstPtr = dstRowStartPtr; - + for(destx = 0; destx < inDstWidth; destx++) { - /* compute the starting x, y and then the ending x, y in the source + /* compute the starting x, y and then the ending x, y in the source pixmap space */ sx = (destx * mx) >> 16; sy = (desty * my) >> 16; - + ex = (destx * mx + mx) >> 16; ey = (desty * my + my) >> 16; - + cuma = cumr = cumg = cumb = 0; - + srcRowStartPtr = (UUtUns16*)inSrcData + sy * inSrcWidth + sx; - + numPixels = (ex - sx) * (ey - sy); UUmAssert(numPixels > 0); - + /* Filtering is inclusive so we iterate at least once */ for(srcy = sy; srcy < ey; srcy++) { UUmAssert((srcy >= 0) && (srcy < inSrcHeight)); srcPtr = srcRowStartPtr; - + for(srcx = sx; srcx < ex; srcx++) { UUmAssert((srcx >=0) && (srcx < inSrcWidth)); @@ -818,27 +818,27 @@ IMiImage_Scale_Box_Down_ARGB1555_IndependantAlpha( cumg += (pixel >> 5) & 0x1F; cumb += (pixel) & 0x1F; } - + srcRowStartPtr += inSrcWidth; } - + cumr = MUrUnsignedSmallFloat_To_Uns_Round((float) cumr / numPixels); cumg = MUrUnsignedSmallFloat_To_Uns_Round((float) cumg / numPixels); cumb = MUrUnsignedSmallFloat_To_Uns_Round((float) cumb / numPixels); - + cuma = MUrUnsignedSmallFloat_To_Uns_Round((float) cuma / numPixels); UUmAssert(cuma <= 0x1); UUmAssert(cumr <= 0x1f); UUmAssert(cumg <= 0x1f); UUmAssert(cumb <= 0x1f); - + *dstPtr++ = (UUtUns16)((cuma << 15) | (cumr << 10) | (cumg << 5) | cumb); } - + dstRowStartPtr += inDstWidth; } - + return UUcError_None; } @@ -859,55 +859,55 @@ IMiImage_Scale_Box_Down_ARGB4444_IndependantAlpha( UUtUns32 numPixels; UUtUns32 sx, sy, ex, ey; UUtUns32 inSrcLength = 2 * inSrcWidth * inSrcHeight; - + UUtUns16* dstRowStartPtr; UUtUns16* srcRowStartPtr; UUtUns16* dstPtr; UUtUns16* srcPtr; - + // Not really sure what exactly to do with the alpha at the edges here... - + /* the pixmap needs to be shrunk in x and y */ - + /* compute the gradients to 16 bits of fractional precision */ my = (inSrcHeight << 16) / inDstHeight; mx = (inSrcWidth << 16) / inDstWidth; - + /* * We are going to traverse the destination map filtering each * corresponding block in the source map down to a single pixel */ - + dstRowStartPtr = outDstData; for(desty = 0; desty < inDstHeight; desty++) { dstPtr = dstRowStartPtr; - + for(destx = 0; destx < inDstWidth; destx++) { - /* compute the starting x, y and then the ending x, y in the source + /* compute the starting x, y and then the ending x, y in the source pixmap space */ sx = (destx * mx) >> 16; sy = (desty * my) >> 16; - + ex = (destx * mx + mx) >> 16; ey = (desty * my + my) >> 16; - + cuma = cumr = cumg = cumb = 0; - + srcRowStartPtr = (UUtUns16*)inSrcData + sy * inSrcWidth + sx; - + numPixels = (ex - sx) * (ey - sy); UUmAssert(numPixels > 0); - + for(srcy = sy; srcy < ey; srcy++) { UUmAssert((srcy >= 0) && (srcy < inSrcHeight)); srcPtr = srcRowStartPtr; - + for(srcx = sx; srcx < ex; srcx++) { UUmAssert((srcx >=0) && (srcx < inSrcWidth)); @@ -922,14 +922,14 @@ IMiImage_Scale_Box_Down_ARGB4444_IndependantAlpha( cumg += ((pixel >> 4) & 0xF); cumb += ((pixel) & 0xF); } - + srcRowStartPtr += inSrcWidth; } - + cumr = MUrUnsignedSmallFloat_To_Uns_Round((float) cumr / numPixels); cumg = MUrUnsignedSmallFloat_To_Uns_Round((float) cumg / numPixels); cumb = MUrUnsignedSmallFloat_To_Uns_Round((float) cumb / numPixels); - + cuma = MUrUnsignedSmallFloat_To_Uns_Round((float) cuma / numPixels); UUmAssert(cuma <= 0xf); @@ -939,10 +939,10 @@ IMiImage_Scale_Box_Down_ARGB4444_IndependantAlpha( *dstPtr++ = (UUtUns16)((cuma << 12) | (cumr << 8) | (cumg << 4) | cumb); } - + dstRowStartPtr += inDstWidth; } - + return UUcError_None; } @@ -983,38 +983,38 @@ IMiImage_Scale_Box_Up_RGB888( UUtUns32 my, mx; UUtUns32 texel; UUtUns32 sx, sy, ex, ey; - + UUmAssert_Untested(); - + /* compute the gradients to 16 bits of fractional precision */ my = (inDstHeight << 16) / inSrcHeight; mx = (inDstWidth << 16) / inSrcWidth; - + /* We are going to traverse the source map expanding each pixel into a block of pixels in the destination map */ - + for(srcy = 0; srcy < inSrcHeight; srcy++) { for(srcx = 0; srcx < inSrcWidth; srcx++) { - /* compute the starting x, y and then the ending x, y in the destination + /* compute the starting x, y and then the ending x, y in the destination pixmap space */ sx = (srcx * mx) >> 16; sy = (srcy * my) >> 16; - + ex = (srcx * mx + mx) >> 16; ey = (srcy * my + my) >> 16; - + texel = *((UUtUns32*)inSrcData + inSrcWidth * srcy + srcx); rCenter = ((texel >> 16) & 0xFF) << 16; gCenter = ((texel >> 8) & 0xFF) << 16; bCenter = ((texel >> 0) & 0xFF) << 16; - + /* Read in the surrounding pixels */ if(srcy > 0) { texelUp = *((UUtUns32*)inSrcData + inSrcWidth * (srcy-1) + srcx); - + if(srcx > 0) { texelUpLeft = *((UUtUns32*)inSrcData + inSrcWidth * (srcy-1) + (srcx-1)); @@ -1023,7 +1023,7 @@ IMiImage_Scale_Box_Up_RGB888( { texelUpLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelUpRight = *((UUtUns32*)inSrcData + inSrcWidth * (srcy-1) + (srcx+1)); @@ -1046,11 +1046,11 @@ IMiImage_Scale_Box_Up_RGB888( rUpRight = ((texelUpRight >> 16) & 0xFF) << 16; gUpRight = ((texelUpRight >> 8) & 0xFF) << 16; bUpRight = ((texelUpRight >> 0) & 0xFF) << 16; - + if(srcy + 1 < inSrcHeight) { texelDown = *((UUtUns32*)inSrcData + inSrcWidth * (srcy+1) + srcx); - + if(srcx > 0) { texelDownLeft = *((UUtUns32*)inSrcData + inSrcWidth * (srcy+1) + (srcx-1)); @@ -1059,7 +1059,7 @@ IMiImage_Scale_Box_Up_RGB888( { texelDownLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelDownRight = *((UUtUns32*)inSrcData + inSrcWidth * (srcy+1) + (srcx+1)); @@ -1073,7 +1073,7 @@ IMiImage_Scale_Box_Up_RGB888( { texelDownRight = texelDownLeft = texelDown = texel; } - + rDown = ((texelDown >> 16) & 0xFF) << 16; gDown = ((texelDown >> 8) & 0xFF) << 16; bDown = ((texelDown >> 0) & 0xFF) << 16; @@ -1083,7 +1083,7 @@ IMiImage_Scale_Box_Up_RGB888( rDownRight = ((texelDownRight >> 16) & 0xFF) << 16; gDownRight = ((texelDownRight >> 8) & 0xFF) << 16; bDownRight = ((texelDownRight >> 0) & 0xFF) << 16; - + if(srcx > 0) { texelLeft = *((UUtUns32*)inSrcData + inSrcWidth * srcy + (srcx-1)); @@ -1095,7 +1095,7 @@ IMiImage_Scale_Box_Up_RGB888( rLeft = ((texelLeft >> 16) & 0xFF) << 16; gLeft = ((texelLeft >> 8) & 0xFF) << 16; bLeft = ((texelLeft >> 0) & 0xFF) << 16; - + if(srcx + 1 < inSrcWidth) { texelRight = *((UUtUns32*)inSrcData + inSrcWidth * srcy + (srcx+1)); @@ -1104,11 +1104,11 @@ IMiImage_Scale_Box_Up_RGB888( { texelRight = texel; } - + rRight = ((texelRight >> 16) & 0xFF) << 16; gRight = ((texelRight >> 8) & 0xFF) << 16; bRight = ((texelRight >> 0) & 0xFF) << 16; - + rUL = (rCenter + rUp + rLeft + rUpLeft) / 4; gUL = (gCenter + gUp + gLeft + gUpLeft) / 4; bUL = (bCenter + bUp + bLeft + bUpLeft) / 4; @@ -1121,14 +1121,14 @@ IMiImage_Scale_Box_Up_RGB888( rLR = (rCenter + rDown + rRight + rDownRight) / 4; gLR = (gCenter + gDown + gRight + gDownRight) / 4; bLR = (bCenter + bDown + bRight + bDownRight) / 4; - + mrUp = (rUR - rUL) / (ex - sx); mgUp = (gUR - gUL) / (ex - sx); mbUp = (bUR - bUL) / (ex - sx); mrDown = (rLR - rLL) / (ex - sx); mgDown = (gLR - gLL) / (ex - sx); mbDown = (bLR - bLL) / (ex - sx); - + /* loop through each pixel in the dest block */ for(desty = sy; desty < ey; desty++) { @@ -1136,7 +1136,7 @@ IMiImage_Scale_Box_Up_RGB888( { blocky = desty - sy; blockx = destx - sx; - + /* interpolate along both horizontal lines */ rUpInterp = mrUp * blockx + rUL; gUpInterp = mgUp * blockx + gUL; @@ -1144,7 +1144,7 @@ IMiImage_Scale_Box_Up_RGB888( rDownInterp = mrDown * blockx + rLL; gDownInterp = mgDown * blockx + gLL; bDownInterp = mbDown * blockx + bLL; - + /* Now interpolate along the vertical line */ rFinal = (((rDownInterp - rUpInterp) * blocky) / (ey - sy)) + rUpInterp; rFinal >>= 16; @@ -1152,18 +1152,18 @@ IMiImage_Scale_Box_Up_RGB888( gFinal >>= 16; bFinal = (((bDownInterp - bUpInterp) * blocky) / (ey - sy)) + bUpInterp; bFinal >>= 16; - - texel = + + texel = (rFinal << 16) | (gFinal << 8) | (bFinal << 0); - + *((UUtUns32*)outDstData + inDstWidth * desty + destx) = texel; } } } } - + return UUcError_None; } #endif @@ -1205,38 +1205,38 @@ IMiImage_Scale_Box_Up_RGB555( UUtUns32 my, mx; UUtUns32 texel; UUtUns32 sx, sy, ex, ey; - + UUmAssert_Untested(); - + /* compute the gradients to 16 bits of fractional precision */ my = (inDstHeight << 16) / inSrcHeight; mx = (inDstWidth << 16) / inSrcWidth; - + /* We are going to traverse the source map expanding each pixel into a block of pixels in the destination map */ - + for(srcy = 0; srcy < inSrcHeight; srcy++) { for(srcx = 0; srcx < inSrcWidth; srcx++) { - /* compute the starting x, y and then the ending x, y in the destination + /* compute the starting x, y and then the ending x, y in the destination pixmap space */ sx = (srcx * mx) >> 16; sy = (srcy * my) >> 16; - + ex = (srcx * mx + mx) >> 16; ey = (srcy * my + my) >> 16; - + texel = *((UUtUns16*)inSrcData + inSrcWidth * srcy + srcx); rCenter = ((texel >> 10) & 0x1F) << 16; gCenter = ((texel >> 5) & 0x1F) << 16; bCenter = ((texel >> 0) & 0x1F) << 16; - + /* Read in the surrounding pixels */ if(srcy > 0) { texelUp = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + srcx); - + if(srcx > 0) { texelUpLeft = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + (srcx-1)); @@ -1245,7 +1245,7 @@ IMiImage_Scale_Box_Up_RGB555( { texelUpLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelUpRight = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + (srcx+1)); @@ -1268,11 +1268,11 @@ IMiImage_Scale_Box_Up_RGB555( rUpRight = ((texelUpRight >> 10) & 0x1F) << 16; gUpRight = ((texelUpRight >> 5) & 0x1F) << 16; bUpRight = ((texelUpRight >> 0) & 0x1F) << 16; - + if(srcy + 1 < inSrcHeight) { texelDown = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + srcx); - + if(srcx > 0) { texelDownLeft = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + (srcx-1)); @@ -1281,7 +1281,7 @@ IMiImage_Scale_Box_Up_RGB555( { texelDownLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelDownRight = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + (srcx+1)); @@ -1295,7 +1295,7 @@ IMiImage_Scale_Box_Up_RGB555( { texelDownRight = texelDownLeft = texelDown = texel; } - + rDown = ((texelDown >> 10) & 0x1F) << 16; gDown = ((texelDown >> 5) & 0x1F) << 16; bDown = ((texelDown >> 0) & 0x1F) << 16; @@ -1305,7 +1305,7 @@ IMiImage_Scale_Box_Up_RGB555( rDownRight = ((texelDownRight >> 10) & 0x1F) << 16; gDownRight = ((texelDownRight >> 5) & 0x1F) << 16; bDownRight = ((texelDownRight >> 0) & 0x1F) << 16; - + if(srcx > 0) { texelLeft = *((UUtUns16*)inSrcData + inSrcWidth * srcy + (srcx-1)); @@ -1317,7 +1317,7 @@ IMiImage_Scale_Box_Up_RGB555( rLeft = ((texelLeft >> 10) & 0x1F) << 16; gLeft = ((texelLeft >> 5) & 0x1F) << 16; bLeft = ((texelLeft >> 0) & 0x1F) << 16; - + if(srcx + 1 < inSrcWidth) { texelRight = *((UUtUns16*)inSrcData + inSrcWidth * srcy + (srcx+1)); @@ -1326,11 +1326,11 @@ IMiImage_Scale_Box_Up_RGB555( { texelRight = texel; } - + rRight = ((texelRight >> 10) & 0x1F) << 16; gRight = ((texelRight >> 5) & 0x1F) << 16; bRight = ((texelRight >> 0) & 0x1F) << 16; - + rUL = (rCenter + rUp + rLeft + rUpLeft) / 4; gUL = (gCenter + gUp + gLeft + gUpLeft) / 4; bUL = (bCenter + bUp + bLeft + bUpLeft) / 4; @@ -1343,14 +1343,14 @@ IMiImage_Scale_Box_Up_RGB555( rLR = (rCenter + rDown + rRight + rDownRight) / 4; gLR = (gCenter + gDown + gRight + gDownRight) / 4; bLR = (bCenter + bDown + bRight + bDownRight) / 4; - + mrUp = (rUR - rUL) / (ex - sx); mgUp = (gUR - gUL) / (ex - sx); mbUp = (bUR - bUL) / (ex - sx); mrDown = (rLR - rLL) / (ex - sx); mgDown = (gLR - gLL) / (ex - sx); mbDown = (bLR - bLL) / (ex - sx); - + /* loop through each pixel in the dest block */ for(desty = sy; desty < ey; desty++) { @@ -1358,7 +1358,7 @@ IMiImage_Scale_Box_Up_RGB555( { blocky = desty - sy; blockx = destx - sx; - + /* interpolate along both horizontal lines */ rUpInterp = mrUp * blockx + rUL; gUpInterp = mgUp * blockx + gUL; @@ -1366,7 +1366,7 @@ IMiImage_Scale_Box_Up_RGB555( rDownInterp = mrDown * blockx + rLL; gDownInterp = mgDown * blockx + gLL; bDownInterp = mbDown * blockx + bLL; - + /* Now interpolate along the vertical line */ rFinal = (((rDownInterp - rUpInterp) * blocky) / (ey - sy)) + rUpInterp; rFinal >>= 16; @@ -1374,18 +1374,18 @@ IMiImage_Scale_Box_Up_RGB555( gFinal >>= 16; bFinal = (((bDownInterp - bUpInterp) * blocky) / (ey - sy)) + bUpInterp; bFinal >>= 16; - - texel = + + texel = (rFinal << 10) | (gFinal << 5) | (bFinal << 0); - + *((UUtUns16*)outDstData + inDstWidth * desty + destx) = (UUtUns16)texel; } } } } - + return UUcError_None; } #endif @@ -1427,41 +1427,41 @@ IMiImage_Scale_Box_Up_ARGB8888( UUtUns32 my, mx; UUtUns32 texel; UUtUns32 sx, sy, ex, ey; - + UUmAssert_Untested(); - + // Not really sure I am handling alpha entirely correct here... - + /* compute the gradients to 16 bits of fractional precision */ my = (inDstHeight << 16) / inSrcHeight; mx = (inDstWidth << 16) / inSrcWidth; - + /* We are going to traverse the source map expanding each pixel into a block of pixels in the destination map */ - + for(srcy = 0; srcy < inSrcHeight; srcy++) { for(srcx = 0; srcx < inSrcWidth; srcx++) { - /* compute the starting x, y and then the ending x, y in the destination + /* compute the starting x, y and then the ending x, y in the destination pixmap space */ sx = (srcx * mx) >> 16; sy = (srcy * my) >> 16; - + ex = (srcx * mx + mx) >> 16; ey = (srcy * my + my) >> 16; - + texel = *((UUtUns32*)inSrcData + inSrcWidth * srcy + srcx); aCenter = ((texel >> 24) & 0xFF) << 16; rCenter = ((texel >> 16) & 0xFF) << 16; gCenter = ((texel >> 8) & 0xFF) << 16; bCenter = ((texel >> 0) & 0xFF) << 16; - + /* Read in the surrounding pixels */ if(srcy > 0) { texelUp = *((UUtUns32*)inSrcData + inSrcWidth * (srcy-1) + srcx); - + if(srcx > 0) { texelUpLeft = *((UUtUns32*)inSrcData + inSrcWidth * (srcy-1) + (srcx-1)); @@ -1470,7 +1470,7 @@ IMiImage_Scale_Box_Up_ARGB8888( { texelUpLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelUpRight = *((UUtUns32*)inSrcData + inSrcWidth * (srcy-1) + (srcx+1)); @@ -1484,7 +1484,7 @@ IMiImage_Scale_Box_Up_ARGB8888( { texelUpRight = texelUpLeft = texelUp = texel; } - + aUp = ((texelUp >> 24) & 0xFF) << 16; if(aUp > 0) { @@ -1498,7 +1498,7 @@ IMiImage_Scale_Box_Up_ARGB8888( gUp = gCenter; bUp = bCenter; } - + aUpLeft = ((texelUpLeft >> 24) & 0xFF) << 16; if(aUpLeft > 0) { @@ -1512,7 +1512,7 @@ IMiImage_Scale_Box_Up_ARGB8888( gUpLeft = gCenter; bUpLeft = bCenter; } - + aUpRight = ((texelUpRight >> 24) & 0xFF) << 16; if(aUpRight > 0) { @@ -1526,11 +1526,11 @@ IMiImage_Scale_Box_Up_ARGB8888( gUpRight = gCenter; bUpRight = bCenter; } - + if(srcy + 1 < inSrcHeight) { texelDown = *((UUtUns32*)inSrcData + inSrcWidth * (srcy+1) + srcx); - + if(srcx > 0) { texelDownLeft = *((UUtUns32*)inSrcData + inSrcWidth * (srcy+1) + (srcx-1)); @@ -1539,7 +1539,7 @@ IMiImage_Scale_Box_Up_ARGB8888( { texelDownLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelDownRight = *((UUtUns32*)inSrcData + inSrcWidth * (srcy+1) + (srcx+1)); @@ -1553,7 +1553,7 @@ IMiImage_Scale_Box_Up_ARGB8888( { texelDownRight = texelDownLeft = texelDown = texel; } - + aDown = ((texelDown >> 24) & 0xFF) << 16; if(aDown > 0) { @@ -1567,7 +1567,7 @@ IMiImage_Scale_Box_Up_ARGB8888( gDown = gCenter; bDown = bCenter; } - + aDownLeft = ((texelDownLeft >> 24) & 0xFF) << 16; if(aDownLeft > 0) { @@ -1581,7 +1581,7 @@ IMiImage_Scale_Box_Up_ARGB8888( gDownLeft = gCenter; bDownLeft = bCenter; } - + aDownRight = ((texelDownRight >> 24) & 0xFF) << 16; if(aDownRight > 0) { @@ -1595,7 +1595,7 @@ IMiImage_Scale_Box_Up_ARGB8888( gDownRight = gCenter; bDownRight = bCenter; } - + if(srcx > 0) { texelLeft = *((UUtUns32*)inSrcData + inSrcWidth * srcy + (srcx-1)); @@ -1604,7 +1604,7 @@ IMiImage_Scale_Box_Up_ARGB8888( { texelLeft = texel; } - + aLeft = ((texelLeft >> 24) & 0xFF) << 16; if(aLeft > 0) { @@ -1618,7 +1618,7 @@ IMiImage_Scale_Box_Up_ARGB8888( gLeft = gCenter; bLeft = bCenter; } - + if(srcx + 1 < inSrcWidth) { texelRight = *((UUtUns32*)inSrcData + inSrcWidth * srcy + (srcx+1)); @@ -1627,7 +1627,7 @@ IMiImage_Scale_Box_Up_ARGB8888( { texelRight = texel; } - + aRight = ((texelRight >> 24) & 0xFF) << 16; if(aRight > 0) { @@ -1641,37 +1641,37 @@ IMiImage_Scale_Box_Up_ARGB8888( gRight = gCenter; bRight = bCenter; } - + aUL = (aCenter + aUp + aLeft + aUpLeft) / 4; rUL = (rCenter + rUp + rLeft + rUpLeft) / 4; gUL = (gCenter + gUp + gLeft + gUpLeft) / 4; bUL = (bCenter + bUp + bLeft + bUpLeft) / 4; - + aUR = (aCenter + aUp + aRight + aUpRight) / 4; rUR = (rCenter + rUp + rRight + rUpRight) / 4; gUR = (gCenter + gUp + gRight + gUpRight) / 4; bUR = (bCenter + bUp + bRight + bUpRight) / 4; - + aLL = (aCenter + aDown + aLeft + aDownLeft) / 4; rLL = (rCenter + rDown + rLeft + rDownLeft) / 4; gLL = (gCenter + gDown + gLeft + gDownLeft) / 4; bLL = (bCenter + bDown + bLeft + bDownLeft) / 4; - + aLR = (aCenter + aDown + aRight + aDownRight) / 4; rLR = (rCenter + rDown + rRight + rDownRight) / 4; gLR = (gCenter + gDown + gRight + gDownRight) / 4; bLR = (bCenter + bDown + bRight + bDownRight) / 4; - + maUp = (aUR - aUL) / (ex - sx); mrUp = (rUR - rUL) / (ex - sx); mgUp = (gUR - gUL) / (ex - sx); mbUp = (bUR - bUL) / (ex - sx); - + maDown = (aLR - aLL) / (ex - sx); mrDown = (rLR - rLL) / (ex - sx); mgDown = (gLR - gLL) / (ex - sx); mbDown = (bLR - bLL) / (ex - sx); - + /* loop through each pixel in the dest block */ for(desty = sy; desty < ey; desty++) { @@ -1679,18 +1679,18 @@ IMiImage_Scale_Box_Up_ARGB8888( { blocky = desty - sy; blockx = destx - sx; - + /* interpolate along both horizontal lines */ aUpInterp = maUp * blockx + aUL; rUpInterp = mrUp * blockx + rUL; gUpInterp = mgUp * blockx + gUL; bUpInterp = mbUp * blockx + bUL; - + aDownInterp = maDown * blockx + aLL; rDownInterp = mrDown * blockx + rLL; gDownInterp = mgDown * blockx + gLL; bDownInterp = mbDown * blockx + bLL; - + /* Now interpolate along the vertical line */ aFinal = (((aDownInterp - aUpInterp) * blocky) / (ey - sy)) + aUpInterp; aFinal >>= 16; @@ -1700,19 +1700,19 @@ IMiImage_Scale_Box_Up_ARGB8888( gFinal >>= 16; bFinal = (((bDownInterp - bUpInterp) * blocky) / (ey - sy)) + bUpInterp; bFinal >>= 16; - - texel = + + texel = (aFinal << 24) | (rFinal << 16) | (gFinal << 8) | (bFinal << 0); - + *((UUtUns32*)outDstData + inDstWidth * desty + destx) = texel; } } } } - + return UUcError_None; } #endif @@ -1754,41 +1754,41 @@ IMiImage_Scale_Box_Up_ARGB1555( UUtUns32 my, mx; UUtUns32 texel; UUtUns32 sx, sy, ex, ey; - + UUmAssert_Untested(); - + // Not really sure I am handling alpha entirely correct here... - + /* compute the gradients to 16 bits of fractional precision */ my = (inDstHeight << 16) / inSrcHeight; mx = (inDstWidth << 16) / inSrcWidth; - + /* We are going to traverse the source map expanding each pixel into a block of pixels in the destination map */ - + for(srcy = 0; srcy < inSrcHeight; srcy++) { for(srcx = 0; srcx < inSrcWidth; srcx++) { - /* compute the starting x, y and then the ending x, y in the destination + /* compute the starting x, y and then the ending x, y in the destination pixmap space */ sx = (srcx * mx) >> 16; sy = (srcy * my) >> 16; - + ex = (srcx * mx + mx) >> 16; ey = (srcy * my + my) >> 16; - + texel = *((UUtUns16*)inSrcData + inSrcWidth * srcy + srcx); aCenter = ((texel >> 15) & 0x01) << 16; rCenter = ((texel >> 10) & 0x1F) << 16; gCenter = ((texel >> 5) & 0x1F) << 16; bCenter = ((texel >> 0) & 0x1F) << 16; - + /* Read in the surrounding pixels */ if(srcy > 0) { texelUp = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + srcx); - + if(srcx > 0) { texelUpLeft = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + (srcx-1)); @@ -1797,7 +1797,7 @@ IMiImage_Scale_Box_Up_ARGB1555( { texelUpLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelUpRight = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + (srcx+1)); @@ -1811,7 +1811,7 @@ IMiImage_Scale_Box_Up_ARGB1555( { texelUpRight = texelUpLeft = texelUp = texel; } - + aUp = ((texelUp >> 15) & 0x01) << 16; if(aUp > 0) { @@ -1825,7 +1825,7 @@ IMiImage_Scale_Box_Up_ARGB1555( gUp = gCenter; bUp = bCenter; } - + aUpLeft = ((texelUpLeft >> 15) & 0x01) << 16; if(aUpLeft > 0) { @@ -1839,7 +1839,7 @@ IMiImage_Scale_Box_Up_ARGB1555( gUpLeft = gCenter; bUpLeft = bCenter; } - + aUpRight = ((texelUpRight >> 15) & 0x01) << 16; if(aUpRight > 0) { @@ -1853,11 +1853,11 @@ IMiImage_Scale_Box_Up_ARGB1555( gUpRight = gCenter; bUpRight = bCenter; } - + if(srcy + 1 < inSrcHeight) { texelDown = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + srcx); - + if(srcx > 0) { texelDownLeft = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + (srcx-1)); @@ -1866,7 +1866,7 @@ IMiImage_Scale_Box_Up_ARGB1555( { texelDownLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelDownRight = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + (srcx+1)); @@ -1880,7 +1880,7 @@ IMiImage_Scale_Box_Up_ARGB1555( { texelDownRight = texelDownLeft = texelDown = texel; } - + aDown = ((texelDown >> 15) & 0x01) << 16; if(aDown > 0) { @@ -1894,7 +1894,7 @@ IMiImage_Scale_Box_Up_ARGB1555( gDown = gCenter; bDown = bCenter; } - + aDownLeft = ((texelDownLeft >> 15) & 0x01) << 16; if(aDownLeft > 0) { @@ -1908,7 +1908,7 @@ IMiImage_Scale_Box_Up_ARGB1555( gDownLeft = gCenter; bDownLeft = bCenter; } - + aDownRight = ((texelDownRight >> 15) & 0x01) << 16; if(aDownRight > 0) { @@ -1922,7 +1922,7 @@ IMiImage_Scale_Box_Up_ARGB1555( gDownRight = gCenter; bDownRight = bCenter; } - + if(srcx > 0) { texelLeft = *((UUtUns16*)inSrcData + inSrcWidth * srcy + (srcx-1)); @@ -1931,7 +1931,7 @@ IMiImage_Scale_Box_Up_ARGB1555( { texelLeft = texel; } - + aLeft = ((texelLeft >> 15) & 0x01) << 16; if(aLeft > 0) { @@ -1945,7 +1945,7 @@ IMiImage_Scale_Box_Up_ARGB1555( gLeft = gCenter; bLeft = bCenter; } - + if(srcx + 1 < inSrcWidth) { texelRight = *((UUtUns16*)inSrcData + inSrcWidth * srcy + (srcx+1)); @@ -1954,7 +1954,7 @@ IMiImage_Scale_Box_Up_ARGB1555( { texelRight = texel; } - + aRight = ((texelRight >> 15) & 0x01) << 16; if(aRight > 0) { @@ -1968,37 +1968,37 @@ IMiImage_Scale_Box_Up_ARGB1555( gRight = gCenter; bRight = bCenter; } - + aUL = (aCenter + aUp + aLeft + aUpLeft) / 4; rUL = (rCenter + rUp + rLeft + rUpLeft) / 4; gUL = (gCenter + gUp + gLeft + gUpLeft) / 4; bUL = (bCenter + bUp + bLeft + bUpLeft) / 4; - + aUR = (aCenter + aUp + aRight + aUpRight) / 4; rUR = (rCenter + rUp + rRight + rUpRight) / 4; gUR = (gCenter + gUp + gRight + gUpRight) / 4; bUR = (bCenter + bUp + bRight + bUpRight) / 4; - + aLL = (aCenter + aDown + aLeft + aDownLeft) / 4; rLL = (rCenter + rDown + rLeft + rDownLeft) / 4; gLL = (gCenter + gDown + gLeft + gDownLeft) / 4; bLL = (bCenter + bDown + bLeft + bDownLeft) / 4; - + aLR = (aCenter + aDown + aRight + aDownRight) / 4; rLR = (rCenter + rDown + rRight + rDownRight) / 4; gLR = (gCenter + gDown + gRight + gDownRight) / 4; bLR = (bCenter + bDown + bRight + bDownRight) / 4; - + maUp = (aUR - aUL) / (ex - sx); mrUp = (rUR - rUL) / (ex - sx); mgUp = (gUR - gUL) / (ex - sx); mbUp = (bUR - bUL) / (ex - sx); - + maDown = (aLR - aLL) / (ex - sx); mrDown = (rLR - rLL) / (ex - sx); mgDown = (gLR - gLL) / (ex - sx); mbDown = (bLR - bLL) / (ex - sx); - + /* loop through each pixel in the dest block */ for(desty = sy; desty < ey; desty++) { @@ -2006,18 +2006,18 @@ IMiImage_Scale_Box_Up_ARGB1555( { blocky = desty - sy; blockx = destx - sx; - + /* interpolate along both horizontal lines */ aUpInterp = maUp * blockx + aUL; rUpInterp = mrUp * blockx + rUL; gUpInterp = mgUp * blockx + gUL; bUpInterp = mbUp * blockx + bUL; - + aDownInterp = maDown * blockx + aLL; rDownInterp = mrDown * blockx + rLL; gDownInterp = mgDown * blockx + gLL; bDownInterp = mbDown * blockx + bLL; - + /* Now interpolate along the vertical line */ aFinal = (((aDownInterp - aUpInterp) * blocky) / (ey - sy)) + aUpInterp; aFinal >>= 16; @@ -2027,19 +2027,19 @@ IMiImage_Scale_Box_Up_ARGB1555( gFinal >>= 16; bFinal = (((bDownInterp - bUpInterp) * blocky) / (ey - sy)) + bUpInterp; bFinal >>= 16; - - texel = + + texel = (aFinal << 15) | (rFinal << 10) | (gFinal << 5) | (bFinal << 0); - + *((UUtUns16*)outDstData + inDstWidth * desty + destx) = (UUtUns16)texel; } } } } - + return UUcError_None; } #endif @@ -2080,41 +2080,41 @@ IMiImage_Scale_Box_Up_ARGB4444( UUtUns32 my, mx; UUtUns32 texel; UUtUns32 sx, sy, ex, ey; - + //UUmAssert_Untested(); - + // Not really sure I am handling alpha entirely correct here... - + /* compute the gradients to 16 bits of fractional precision */ my = (inDstHeight << 16) / inSrcHeight; mx = (inDstWidth << 16) / inSrcWidth; - + /* We are going to traverse the source map expanding each pixel into a block of pixels in the destination map */ - + for(srcy = 0; srcy < inSrcHeight; srcy++) { for(srcx = 0; srcx < inSrcWidth; srcx++) { - /* compute the starting x, y and then the ending x, y in the destination + /* compute the starting x, y and then the ending x, y in the destination pixmap space */ sx = (srcx * mx) >> 16; sy = (srcy * my) >> 16; - + ex = (srcx * mx + mx) >> 16; ey = (srcy * my + my) >> 16; - + texel = *((UUtUns16*)inSrcData + inSrcWidth * srcy + srcx); aCenter = ((texel >> 12) & 0xF) << 16; rCenter = ((texel >> 8) & 0xF) << 16; gCenter = ((texel >> 4) & 0xF) << 16; bCenter = ((texel >> 0) & 0xF) << 16; - + /* Read in the surrounding pixels */ if(srcy > 0) { texelUp = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + srcx); - + if(srcx > 0) { texelUpLeft = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + (srcx-1)); @@ -2123,7 +2123,7 @@ IMiImage_Scale_Box_Up_ARGB4444( { texelUpLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelUpRight = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + (srcx+1)); @@ -2137,7 +2137,7 @@ IMiImage_Scale_Box_Up_ARGB4444( { texelUpRight = texelUpLeft = texelUp = texel; } - + aUp = ((texelUp >> 12) & 0xF) << 16; if(aUp > 0) { @@ -2151,7 +2151,7 @@ IMiImage_Scale_Box_Up_ARGB4444( gUp = gCenter; bUp = bCenter; } - + aUpLeft = ((texelUpLeft >> 12) & 0xF) << 16; if(aUpLeft > 0) { @@ -2165,7 +2165,7 @@ IMiImage_Scale_Box_Up_ARGB4444( gUpLeft = gCenter; bUpLeft = bCenter; } - + aUpRight = ((texelUpRight >> 12) & 0xFF) << 16; if(aUpRight > 0) { @@ -2179,11 +2179,11 @@ IMiImage_Scale_Box_Up_ARGB4444( gUpRight = gCenter; bUpRight = bCenter; } - + if(srcy + 1 < inSrcHeight) { texelDown = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + srcx); - + if(srcx > 0) { texelDownLeft = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + (srcx-1)); @@ -2192,7 +2192,7 @@ IMiImage_Scale_Box_Up_ARGB4444( { texelDownLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelDownRight = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + (srcx+1)); @@ -2206,7 +2206,7 @@ IMiImage_Scale_Box_Up_ARGB4444( { texelDownRight = texelDownLeft = texelDown = texel; } - + aDown = ((texelDown >> 12) & 0xF) << 16; if(aDown > 0) { @@ -2220,7 +2220,7 @@ IMiImage_Scale_Box_Up_ARGB4444( gDown = gCenter; bDown = bCenter; } - + aDownLeft = ((texelDownLeft >> 12) & 0xF) << 16; if(aDownLeft > 0) { @@ -2234,7 +2234,7 @@ IMiImage_Scale_Box_Up_ARGB4444( gDownLeft = gCenter; bDownLeft = bCenter; } - + aDownRight = ((texelDownRight >> 12) & 0xF) << 16; if(aDownRight > 0) { @@ -2248,7 +2248,7 @@ IMiImage_Scale_Box_Up_ARGB4444( gDownRight = gCenter; bDownRight = bCenter; } - + if(srcx > 0) { texelLeft = *((UUtUns16*)inSrcData + inSrcWidth * srcy + (srcx-1)); @@ -2257,7 +2257,7 @@ IMiImage_Scale_Box_Up_ARGB4444( { texelLeft = texel; } - + aLeft = ((texelLeft >> 12) & 0xF) << 16; if(aLeft > 0) { @@ -2271,7 +2271,7 @@ IMiImage_Scale_Box_Up_ARGB4444( gLeft = gCenter; bLeft = bCenter; } - + if(srcx + 1 < inSrcWidth) { texelRight = *((UUtUns16*)inSrcData + inSrcWidth * srcy + (srcx+1)); @@ -2280,7 +2280,7 @@ IMiImage_Scale_Box_Up_ARGB4444( { texelRight = texel; } - + aRight = ((texelRight >> 12) & 0xF) << 16; if(aRight > 0) { @@ -2294,37 +2294,37 @@ IMiImage_Scale_Box_Up_ARGB4444( gRight = gCenter; bRight = bCenter; } - + aUL = (aCenter + aUp + aLeft + aUpLeft) / 4; rUL = (rCenter + rUp + rLeft + rUpLeft) / 4; gUL = (gCenter + gUp + gLeft + gUpLeft) / 4; bUL = (bCenter + bUp + bLeft + bUpLeft) / 4; - + aUR = (aCenter + aUp + aRight + aUpRight) / 4; rUR = (rCenter + rUp + rRight + rUpRight) / 4; gUR = (gCenter + gUp + gRight + gUpRight) / 4; bUR = (bCenter + bUp + bRight + bUpRight) / 4; - + aLL = (aCenter + aDown + aLeft + aDownLeft) / 4; rLL = (rCenter + rDown + rLeft + rDownLeft) / 4; gLL = (gCenter + gDown + gLeft + gDownLeft) / 4; bLL = (bCenter + bDown + bLeft + bDownLeft) / 4; - + aLR = (aCenter + aDown + aRight + aDownRight) / 4; rLR = (rCenter + rDown + rRight + rDownRight) / 4; gLR = (gCenter + gDown + gRight + gDownRight) / 4; bLR = (bCenter + bDown + bRight + bDownRight) / 4; - + maUp = (aUR - aUL) / (ex - sx); mrUp = (rUR - rUL) / (ex - sx); mgUp = (gUR - gUL) / (ex - sx); mbUp = (bUR - bUL) / (ex - sx); - + maDown = (aLR - aLL) / (ex - sx); mrDown = (rLR - rLL) / (ex - sx); mgDown = (gLR - gLL) / (ex - sx); mbDown = (bLR - bLL) / (ex - sx); - + /* loop through each pixel in the dest block */ for(desty = sy; desty < ey; desty++) { @@ -2332,18 +2332,18 @@ IMiImage_Scale_Box_Up_ARGB4444( { blocky = desty - sy; blockx = destx - sx; - + /* interpolate along both horizontal lines */ aUpInterp = maUp * blockx + aUL; rUpInterp = mrUp * blockx + rUL; gUpInterp = mgUp * blockx + gUL; bUpInterp = mbUp * blockx + bUL; - + aDownInterp = maDown * blockx + aLL; rDownInterp = mrDown * blockx + rLL; gDownInterp = mgDown * blockx + gLL; bDownInterp = mbDown * blockx + bLL; - + /* Now interpolate along the vertical line */ aFinal = (((aDownInterp - aUpInterp) * blocky) / (ey - sy)) + aUpInterp; aFinal >>= 16; @@ -2353,19 +2353,19 @@ IMiImage_Scale_Box_Up_ARGB4444( gFinal >>= 16; bFinal = (((bDownInterp - bUpInterp) * blocky) / (ey - sy)) + bUpInterp; bFinal >>= 16; - - texel = + + texel = (aFinal << 12) | (rFinal << 8) | (gFinal << 4) | (bFinal << 0); - + *((UUtUns16*)outDstData + inDstWidth * desty + destx) = (UUtUns16)texel; } } } } - + return UUcError_None; } @@ -2406,41 +2406,41 @@ IMiImage_Scale_Box_Up_ARGB8888_IndependantAlpha( UUtUns32 my, mx; UUtUns32 texel; UUtUns32 sx, sy, ex, ey; - + UUmAssert_Untested(); - + // Not really sure I am handling alpha entirely correct here... - + /* compute the gradients to 16 bits of fractional precision */ my = (inDstHeight << 16) / inSrcHeight; mx = (inDstWidth << 16) / inSrcWidth; - + /* We are going to traverse the source map expanding each pixel into a block of pixels in the destination map */ - + for(srcy = 0; srcy < inSrcHeight; srcy++) { for(srcx = 0; srcx < inSrcWidth; srcx++) { - /* compute the starting x, y and then the ending x, y in the destination + /* compute the starting x, y and then the ending x, y in the destination pixmap space */ sx = (srcx * mx) >> 16; sy = (srcy * my) >> 16; - + ex = (srcx * mx + mx) >> 16; ey = (srcy * my + my) >> 16; - + texel = *((UUtUns32*)inSrcData + inSrcWidth * srcy + srcx); aCenter = ((texel >> 24) & 0xFF) << 16; rCenter = ((texel >> 16) & 0xFF) << 16; gCenter = ((texel >> 8) & 0xFF) << 16; bCenter = ((texel >> 0) & 0xFF) << 16; - + /* Read in the surrounding pixels */ if(srcy > 0) { texelUp = *((UUtUns32*)inSrcData + inSrcWidth * (srcy-1) + srcx); - + if(srcx > 0) { texelUpLeft = *((UUtUns32*)inSrcData + inSrcWidth * (srcy-1) + (srcx-1)); @@ -2449,7 +2449,7 @@ IMiImage_Scale_Box_Up_ARGB8888_IndependantAlpha( { texelUpLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelUpRight = *((UUtUns32*)inSrcData + inSrcWidth * (srcy-1) + (srcx+1)); @@ -2463,26 +2463,26 @@ IMiImage_Scale_Box_Up_ARGB8888_IndependantAlpha( { texelUpRight = texelUpLeft = texelUp = texel; } - + aUp = ((texelUp >> 24) & 0xFF) << 16; rUp = ((texelUp >> 16) & 0xFF) << 16; gUp = ((texelUp >> 8) & 0xFF) << 16; bUp = ((texelUp >> 0) & 0xFF) << 16; - + aUpLeft = ((texelUpLeft >> 24) & 0xFF) << 16; rUpLeft = ((texelUpLeft >> 16) & 0xFF) << 16; gUpLeft = ((texelUpLeft >> 8) & 0xFF) << 16; bUpLeft = ((texelUpLeft >> 0) & 0xFF) << 16; - + aUpRight = ((texelUpRight >> 24) & 0xFF) << 16; rUpRight = ((texelUpRight >> 16) & 0xFF) << 16; gUpRight = ((texelUpRight >> 8) & 0xFF) << 16; bUpRight = ((texelUpRight >> 0) & 0xFF) << 16; - + if(srcy + 1 < inSrcHeight) { texelDown = *((UUtUns32*)inSrcData + inSrcWidth * (srcy+1) + srcx); - + if(srcx > 0) { texelDownLeft = *((UUtUns32*)inSrcData + inSrcWidth * (srcy+1) + (srcx-1)); @@ -2491,7 +2491,7 @@ IMiImage_Scale_Box_Up_ARGB8888_IndependantAlpha( { texelDownLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelDownRight = *((UUtUns32*)inSrcData + inSrcWidth * (srcy+1) + (srcx+1)); @@ -2505,7 +2505,7 @@ IMiImage_Scale_Box_Up_ARGB8888_IndependantAlpha( { texelDownRight = texelDownLeft = texelDown = texel; } - + aDown = ((texelDown >> 24) & 0xFF) << 16; if(aDown > 0) { @@ -2519,7 +2519,7 @@ IMiImage_Scale_Box_Up_ARGB8888_IndependantAlpha( gDown = gCenter; bDown = bCenter; } - + aDownLeft = ((texelDownLeft >> 24) & 0xFF) << 16; if(aDownLeft > 0) { @@ -2533,7 +2533,7 @@ IMiImage_Scale_Box_Up_ARGB8888_IndependantAlpha( gDownLeft = gCenter; bDownLeft = bCenter; } - + aDownRight = ((texelDownRight >> 24) & 0xFF) << 16; if(aDownRight > 0) { @@ -2547,7 +2547,7 @@ IMiImage_Scale_Box_Up_ARGB8888_IndependantAlpha( gDownRight = gCenter; bDownRight = bCenter; } - + if(srcx > 0) { texelLeft = *((UUtUns32*)inSrcData + inSrcWidth * srcy + (srcx-1)); @@ -2556,12 +2556,12 @@ IMiImage_Scale_Box_Up_ARGB8888_IndependantAlpha( { texelLeft = texel; } - + aLeft = ((texelLeft >> 24) & 0xFF) << 16; rLeft = ((texelLeft >> 16) & 0xFF) << 16; gLeft = ((texelLeft >> 8) & 0xFF) << 16; bLeft = ((texelLeft >> 0) & 0xFF) << 16; - + if(srcx + 1 < inSrcWidth) { texelRight = *((UUtUns32*)inSrcData + inSrcWidth * srcy + (srcx+1)); @@ -2570,42 +2570,42 @@ IMiImage_Scale_Box_Up_ARGB8888_IndependantAlpha( { texelRight = texel; } - + aRight = ((texelRight >> 24) & 0xFF) << 16; rRight = ((texelRight >> 16) & 0xFF) << 16; gRight = ((texelRight >> 8) & 0xFF) << 16; bRight = ((texelRight >> 0) & 0xFF) << 16; - + aUL = (aCenter + aUp + aLeft + aUpLeft) / 4; rUL = (rCenter + rUp + rLeft + rUpLeft) / 4; gUL = (gCenter + gUp + gLeft + gUpLeft) / 4; bUL = (bCenter + bUp + bLeft + bUpLeft) / 4; - + aUR = (aCenter + aUp + aRight + aUpRight) / 4; rUR = (rCenter + rUp + rRight + rUpRight) / 4; gUR = (gCenter + gUp + gRight + gUpRight) / 4; bUR = (bCenter + bUp + bRight + bUpRight) / 4; - + aLL = (aCenter + aDown + aLeft + aDownLeft) / 4; rLL = (rCenter + rDown + rLeft + rDownLeft) / 4; gLL = (gCenter + gDown + gLeft + gDownLeft) / 4; bLL = (bCenter + bDown + bLeft + bDownLeft) / 4; - + aLR = (aCenter + aDown + aRight + aDownRight) / 4; rLR = (rCenter + rDown + rRight + rDownRight) / 4; gLR = (gCenter + gDown + gRight + gDownRight) / 4; bLR = (bCenter + bDown + bRight + bDownRight) / 4; - + maUp = (aUR - aUL) / (ex - sx); mrUp = (rUR - rUL) / (ex - sx); mgUp = (gUR - gUL) / (ex - sx); mbUp = (bUR - bUL) / (ex - sx); - + maDown = (aLR - aLL) / (ex - sx); mrDown = (rLR - rLL) / (ex - sx); mgDown = (gLR - gLL) / (ex - sx); mbDown = (bLR - bLL) / (ex - sx); - + /* loop through each pixel in the dest block */ for(desty = sy; desty < ey; desty++) { @@ -2613,18 +2613,18 @@ IMiImage_Scale_Box_Up_ARGB8888_IndependantAlpha( { blocky = desty - sy; blockx = destx - sx; - + /* interpolate along both horizontal lines */ aUpInterp = maUp * blockx + aUL; rUpInterp = mrUp * blockx + rUL; gUpInterp = mgUp * blockx + gUL; bUpInterp = mbUp * blockx + bUL; - + aDownInterp = maDown * blockx + aLL; rDownInterp = mrDown * blockx + rLL; gDownInterp = mgDown * blockx + gLL; bDownInterp = mbDown * blockx + bLL; - + /* Now interpolate along the vertical line */ aFinal = (((aDownInterp - aUpInterp) * blocky) / (ey - sy)) + aUpInterp; aFinal >>= 16; @@ -2634,19 +2634,19 @@ IMiImage_Scale_Box_Up_ARGB8888_IndependantAlpha( gFinal >>= 16; bFinal = (((bDownInterp - bUpInterp) * blocky) / (ey - sy)) + bUpInterp; bFinal >>= 16; - - texel = + + texel = (aFinal << 24) | (rFinal << 16) | (gFinal << 8) | (bFinal << 0); - + *((UUtUns32*)outDstData + inDstWidth * desty + destx) = texel; } } } } - + return UUcError_None; } #endif @@ -2688,41 +2688,41 @@ IMiImage_Scale_Box_Up_ARGB1555_IndependantAlpha( UUtUns32 my, mx; UUtUns32 texel; UUtUns32 sx, sy, ex, ey; - + UUmAssert_Untested(); - + // Not really sure I am handling alpha entirely correct here... - + /* compute the gradients to 16 bits of fractional precision */ my = (inDstHeight << 16) / inSrcHeight; mx = (inDstWidth << 16) / inSrcWidth; - + /* We are going to traverse the source map expanding each pixel into a block of pixels in the destination map */ - + for(srcy = 0; srcy < inSrcHeight; srcy++) { for(srcx = 0; srcx < inSrcWidth; srcx++) { - /* compute the starting x, y and then the ending x, y in the destination + /* compute the starting x, y and then the ending x, y in the destination pixmap space */ sx = (srcx * mx) >> 16; sy = (srcy * my) >> 16; - + ex = (srcx * mx + mx) >> 16; ey = (srcy * my + my) >> 16; - + texel = *((UUtUns16*)inSrcData + inSrcWidth * srcy + srcx); aCenter = ((texel >> 15) & 0x01) << 16; rCenter = ((texel >> 10) & 0x1F) << 16; gCenter = ((texel >> 5) & 0x1F) << 16; bCenter = ((texel >> 0) & 0x1F) << 16; - + /* Read in the surrounding pixels */ if(srcy > 0) { texelUp = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + srcx); - + if(srcx > 0) { texelUpLeft = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + (srcx-1)); @@ -2731,7 +2731,7 @@ IMiImage_Scale_Box_Up_ARGB1555_IndependantAlpha( { texelUpLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelUpRight = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + (srcx+1)); @@ -2745,26 +2745,26 @@ IMiImage_Scale_Box_Up_ARGB1555_IndependantAlpha( { texelUpRight = texelUpLeft = texelUp = texel; } - + aUp = ((texelUp >> 15) & 0x01) << 16; rUp = ((texelUp >> 10) & 0x1F) << 16; gUp = ((texelUp >> 5) & 0x1F) << 16; bUp = ((texelUp >> 0) & 0x1F) << 16; - + aUpLeft = ((texelUpLeft >> 15) & 0x01) << 16; rUpLeft = ((texelUpLeft >> 10) & 0x1F) << 16; gUpLeft = ((texelUpLeft >> 5) & 0x1F) << 16; bUpLeft = ((texelUpLeft >> 0) & 0x1F) << 16; - + aUpRight = ((texelUpRight >> 15) & 0x01) << 16; rUpRight = ((texelUpRight >> 10) & 0x1F) << 16; gUpRight = ((texelUpRight >> 5) & 0x1F) << 16; bUpRight = ((texelUpRight >> 0) & 0x1F) << 16; - + if(srcy + 1 < inSrcHeight) { texelDown = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + srcx); - + if(srcx > 0) { texelDownLeft = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + (srcx-1)); @@ -2773,7 +2773,7 @@ IMiImage_Scale_Box_Up_ARGB1555_IndependantAlpha( { texelDownLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelDownRight = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + (srcx+1)); @@ -2787,22 +2787,22 @@ IMiImage_Scale_Box_Up_ARGB1555_IndependantAlpha( { texelDownRight = texelDownLeft = texelDown = texel; } - + aDown = ((texelDown >> 15) & 0x01) << 16; rDown = ((texelDown >> 10) & 0x1F) << 16; gDown = ((texelDown >> 5) & 0x1F) << 16; bDown = ((texelDown >> 0) & 0x1F) << 16; - + aDownLeft = ((texelDownLeft >> 15) & 0x01) << 16; rDownLeft = ((texelDownLeft >> 10) & 0x1F) << 16; gDownLeft = ((texelDownLeft >> 5) & 0x1F) << 16; bDownLeft = ((texelDownLeft >> 0) & 0x1F) << 16; - + aDownRight = ((texelDownRight >> 15) & 0x01) << 16; rDownRight = ((texelDownRight >> 10) & 0x1F) << 16; gDownRight = ((texelDownRight >> 5) & 0x1F) << 16; bDownRight = ((texelDownRight >> 0) & 0x1F) << 16; - + if(srcx > 0) { texelLeft = *((UUtUns16*)inSrcData + inSrcWidth * srcy + (srcx-1)); @@ -2811,12 +2811,12 @@ IMiImage_Scale_Box_Up_ARGB1555_IndependantAlpha( { texelLeft = texel; } - + aLeft = ((texelLeft >> 15) & 0x01) << 16; rLeft = ((texelLeft >> 10) & 0x1F) << 16; gLeft = ((texelLeft >> 5) & 0x1F) << 16; bLeft = ((texelLeft >> 0) & 0x1F) << 16; - + if(srcx + 1 < inSrcWidth) { texelRight = *((UUtUns16*)inSrcData + inSrcWidth * srcy + (srcx+1)); @@ -2825,42 +2825,42 @@ IMiImage_Scale_Box_Up_ARGB1555_IndependantAlpha( { texelRight = texel; } - + aRight = ((texelRight >> 15) & 0x01) << 16; rRight = ((texelRight >> 10) & 0x1F) << 16; gRight = ((texelRight >> 5) & 0x1F) << 16; bRight = ((texelRight >> 0) & 0x1F) << 16; - + aUL = (aCenter + aUp + aLeft + aUpLeft) / 4; rUL = (rCenter + rUp + rLeft + rUpLeft) / 4; gUL = (gCenter + gUp + gLeft + gUpLeft) / 4; bUL = (bCenter + bUp + bLeft + bUpLeft) / 4; - + aUR = (aCenter + aUp + aRight + aUpRight) / 4; rUR = (rCenter + rUp + rRight + rUpRight) / 4; gUR = (gCenter + gUp + gRight + gUpRight) / 4; bUR = (bCenter + bUp + bRight + bUpRight) / 4; - + aLL = (aCenter + aDown + aLeft + aDownLeft) / 4; rLL = (rCenter + rDown + rLeft + rDownLeft) / 4; gLL = (gCenter + gDown + gLeft + gDownLeft) / 4; bLL = (bCenter + bDown + bLeft + bDownLeft) / 4; - + aLR = (aCenter + aDown + aRight + aDownRight) / 4; rLR = (rCenter + rDown + rRight + rDownRight) / 4; gLR = (gCenter + gDown + gRight + gDownRight) / 4; bLR = (bCenter + bDown + bRight + bDownRight) / 4; - + maUp = (aUR - aUL) / (ex - sx); mrUp = (rUR - rUL) / (ex - sx); mgUp = (gUR - gUL) / (ex - sx); mbUp = (bUR - bUL) / (ex - sx); - + maDown = (aLR - aLL) / (ex - sx); mrDown = (rLR - rLL) / (ex - sx); mgDown = (gLR - gLL) / (ex - sx); mbDown = (bLR - bLL) / (ex - sx); - + /* loop through each pixel in the dest block */ for(desty = sy; desty < ey; desty++) { @@ -2868,18 +2868,18 @@ IMiImage_Scale_Box_Up_ARGB1555_IndependantAlpha( { blocky = desty - sy; blockx = destx - sx; - + /* interpolate along both horizontal lines */ aUpInterp = maUp * blockx + aUL; rUpInterp = mrUp * blockx + rUL; gUpInterp = mgUp * blockx + gUL; bUpInterp = mbUp * blockx + bUL; - + aDownInterp = maDown * blockx + aLL; rDownInterp = mrDown * blockx + rLL; gDownInterp = mgDown * blockx + gLL; bDownInterp = mbDown * blockx + bLL; - + /* Now interpolate along the vertical line */ aFinal = (((aDownInterp - aUpInterp) * blocky) / (ey - sy)) + aUpInterp; aFinal >>= 16; @@ -2889,19 +2889,19 @@ IMiImage_Scale_Box_Up_ARGB1555_IndependantAlpha( gFinal >>= 16; bFinal = (((bDownInterp - bUpInterp) * blocky) / (ey - sy)) + bUpInterp; bFinal >>= 16; - - texel = + + texel = (aFinal << 15) | (rFinal << 10) | (gFinal << 5) | (bFinal << 0); - + *((UUtUns16*)outDstData + inDstWidth * desty + destx) = (UUtUns16)texel; } } } } - + return UUcError_None; } #endif @@ -2942,41 +2942,41 @@ IMiImage_Scale_Box_Up_ARGB4444_IndependantAlpha( UUtUns32 my, mx; UUtUns32 texel; UUtUns32 sx, sy, ex, ey; - + //UUmAssert_Untested(); - + // Not really sure I am handling alpha entirely correct here... - + /* compute the gradients to 16 bits of fractional precision */ my = (inDstHeight << 16) / inSrcHeight; mx = (inDstWidth << 16) / inSrcWidth; - + /* We are going to traverse the source map expanding each pixel into a block of pixels in the destination map */ - + for(srcy = 0; srcy < inSrcHeight; srcy++) { for(srcx = 0; srcx < inSrcWidth; srcx++) { - /* compute the starting x, y and then the ending x, y in the destination + /* compute the starting x, y and then the ending x, y in the destination pixmap space */ sx = (srcx * mx) >> 16; sy = (srcy * my) >> 16; - + ex = (srcx * mx + mx) >> 16; ey = (srcy * my + my) >> 16; - + texel = *((UUtUns16*)inSrcData + inSrcWidth * srcy + srcx); aCenter = ((texel >> 12) & 0xF) << 16; rCenter = ((texel >> 8) & 0xF) << 16; gCenter = ((texel >> 4) & 0xF) << 16; bCenter = ((texel >> 0) & 0xF) << 16; - + /* Read in the surrounding pixels */ if(srcy > 0) { texelUp = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + srcx); - + if(srcx > 0) { texelUpLeft = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + (srcx-1)); @@ -2985,7 +2985,7 @@ IMiImage_Scale_Box_Up_ARGB4444_IndependantAlpha( { texelUpLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelUpRight = *((UUtUns16*)inSrcData + inSrcWidth * (srcy-1) + (srcx+1)); @@ -2999,26 +2999,26 @@ IMiImage_Scale_Box_Up_ARGB4444_IndependantAlpha( { texelUpRight = texelUpLeft = texelUp = texel; } - + aUp = ((texelUp >> 12) & 0xF) << 16; rUp = ((texelUp >> 8) & 0xF) << 16; gUp = ((texelUp >> 4) & 0xF) << 16; bUp = ((texelUp >> 0) & 0xF) << 16; - + aUpLeft = ((texelUpLeft >> 12) & 0xF) << 16; rUpLeft = ((texelUpLeft >> 8) & 0xF) << 16; gUpLeft = ((texelUpLeft >> 4) & 0xF) << 16; bUpLeft = ((texelUpLeft >> 0) & 0xF) << 16; - + aUpRight = ((texelUpRight >> 12) & 0xFF) << 16; rUpRight = ((texelUpRight >> 8) & 0xFF) << 16; gUpRight = ((texelUpRight >> 4) & 0xFF) << 16; bUpRight = ((texelUpRight >> 0) & 0xFF) << 16; - + if(srcy + 1 < inSrcHeight) { texelDown = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + srcx); - + if(srcx > 0) { texelDownLeft = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + (srcx-1)); @@ -3027,7 +3027,7 @@ IMiImage_Scale_Box_Up_ARGB4444_IndependantAlpha( { texelDownLeft = texel; } - + if(srcx + 1 < inSrcWidth) { texelDownRight = *((UUtUns16*)inSrcData + inSrcWidth * (srcy+1) + (srcx+1)); @@ -3041,22 +3041,22 @@ IMiImage_Scale_Box_Up_ARGB4444_IndependantAlpha( { texelDownRight = texelDownLeft = texelDown = texel; } - + aDown = ((texelDown >> 12) & 0xF) << 16; rDown = ((texelDown >> 8) & 0xF) << 16; gDown = ((texelDown >> 4) & 0xF) << 16; bDown = ((texelDown >> 0) & 0xF) << 16; - + aDownLeft = ((texelDownLeft >> 12) & 0xF) << 16; rDownLeft = ((texelDownLeft >> 8) & 0xF) << 16; gDownLeft = ((texelDownLeft >> 4) & 0xF) << 16; bDownLeft = ((texelDownLeft >> 0) & 0xF) << 16; - + aDownRight = ((texelDownRight >> 12) & 0xF) << 16; rDownRight = ((texelDownRight >> 8) & 0xF) << 16; gDownRight = ((texelDownRight >> 4) & 0xF) << 16; bDownRight = ((texelDownRight >> 0) & 0xF) << 16; - + if(srcx > 0) { texelLeft = *((UUtUns16*)inSrcData + inSrcWidth * srcy + (srcx-1)); @@ -3065,12 +3065,12 @@ IMiImage_Scale_Box_Up_ARGB4444_IndependantAlpha( { texelLeft = texel; } - + aLeft = ((texelLeft >> 12) & 0xF) << 16; rLeft = ((texelLeft >> 8) & 0xF) << 16; gLeft = ((texelLeft >> 4) & 0xF) << 16; bLeft = ((texelLeft >> 0) & 0xF) << 16; - + if(srcx + 1 < inSrcWidth) { texelRight = *((UUtUns16*)inSrcData + inSrcWidth * srcy + (srcx+1)); @@ -3079,42 +3079,42 @@ IMiImage_Scale_Box_Up_ARGB4444_IndependantAlpha( { texelRight = texel; } - + aRight = ((texelRight >> 12) & 0xF) << 16; rRight = ((texelRight >> 8) & 0xF) << 16; gRight = ((texelRight >> 4) & 0xF) << 16; bRight = ((texelRight >> 0) & 0xF) << 16; - + aUL = (aCenter + aUp + aLeft + aUpLeft) / 4; rUL = (rCenter + rUp + rLeft + rUpLeft) / 4; gUL = (gCenter + gUp + gLeft + gUpLeft) / 4; bUL = (bCenter + bUp + bLeft + bUpLeft) / 4; - + aUR = (aCenter + aUp + aRight + aUpRight) / 4; rUR = (rCenter + rUp + rRight + rUpRight) / 4; gUR = (gCenter + gUp + gRight + gUpRight) / 4; bUR = (bCenter + bUp + bRight + bUpRight) / 4; - + aLL = (aCenter + aDown + aLeft + aDownLeft) / 4; rLL = (rCenter + rDown + rLeft + rDownLeft) / 4; gLL = (gCenter + gDown + gLeft + gDownLeft) / 4; bLL = (bCenter + bDown + bLeft + bDownLeft) / 4; - + aLR = (aCenter + aDown + aRight + aDownRight) / 4; rLR = (rCenter + rDown + rRight + rDownRight) / 4; gLR = (gCenter + gDown + gRight + gDownRight) / 4; bLR = (bCenter + bDown + bRight + bDownRight) / 4; - + maUp = (aUR - aUL) / (ex - sx); mrUp = (rUR - rUL) / (ex - sx); mgUp = (gUR - gUL) / (ex - sx); mbUp = (bUR - bUL) / (ex - sx); - + maDown = (aLR - aLL) / (ex - sx); mrDown = (rLR - rLL) / (ex - sx); mgDown = (gLR - gLL) / (ex - sx); mbDown = (bLR - bLL) / (ex - sx); - + /* loop through each pixel in the dest block */ for(desty = sy; desty < ey; desty++) { @@ -3122,18 +3122,18 @@ IMiImage_Scale_Box_Up_ARGB4444_IndependantAlpha( { blocky = desty - sy; blockx = destx - sx; - + /* interpolate along both horizontal lines */ aUpInterp = maUp * blockx + aUL; rUpInterp = mrUp * blockx + rUL; gUpInterp = mgUp * blockx + gUL; bUpInterp = mbUp * blockx + bUL; - + aDownInterp = maDown * blockx + aLL; rDownInterp = mrDown * blockx + rLL; gDownInterp = mgDown * blockx + gLL; bDownInterp = mbDown * blockx + bLL; - + /* Now interpolate along the vertical line */ aFinal = (((aDownInterp - aUpInterp) * blocky) / (ey - sy)) + aUpInterp; aFinal >>= 16; @@ -3143,19 +3143,19 @@ IMiImage_Scale_Box_Up_ARGB4444_IndependantAlpha( gFinal >>= 16; bFinal = (((bDownInterp - bUpInterp) * blocky) / (ey - sy)) + bUpInterp; bFinal >>= 16; - - texel = + + texel = (aFinal << 12) | (rFinal << 8) | (gFinal << 4) | (bFinal << 0); - + *((UUtUns16*)outDstData + inDstWidth * desty + destx) = (UUtUns16)texel; } } } } - + return UUcError_None; } @@ -3182,12 +3182,12 @@ IMrImage_Scale_Box( } UUrMemory_Block_VerifyList(); - + if(inSrcWidth == inDstWidth && inSrcHeight == inDstHeight) { - + if(inSrcData == outDstData) return UUcError_None; - + UUrMemory_MoveFast( inSrcData, outDstData, @@ -3206,7 +3206,7 @@ IMrImage_Scale_Box( inDstWidth, inDstHeight, outDstData); - + case IMcPixelType_RGB555: return IMiImage_Scale_Box_Down_RGB555( @@ -3216,7 +3216,7 @@ IMrImage_Scale_Box( inDstWidth, inDstHeight, outDstData); - + case IMcPixelType_ARGB1555: return IMiImage_Scale_Box_Down_ARGB1555( @@ -3226,19 +3226,19 @@ IMrImage_Scale_Box( inDstWidth, inDstHeight, outDstData); - + case IMcPixelType_I8: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_I1: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_A8: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_A4I4: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_ARGB8888: return IMiImage_Scale_Box_Down_ARGB8888( @@ -3248,7 +3248,7 @@ IMrImage_Scale_Box( inDstWidth, inDstHeight, outDstData); - + case IMcPixelType_RGB888: return IMiImage_Scale_Box_Down_RGB888( @@ -3277,7 +3277,7 @@ IMrImage_Scale_Box( inDstWidth, inDstHeight, outDstData); - + #if INCLUDE_UNTESTED_STUFF case IMcPixelType_RGB555: return @@ -3289,7 +3289,7 @@ IMrImage_Scale_Box( inDstHeight, outDstData); #endif - + #if INCLUDE_UNTESTED_STUFF case IMcPixelType_ARGB1555: return @@ -3301,19 +3301,19 @@ IMrImage_Scale_Box( inDstHeight, outDstData); #endif - + case IMcPixelType_I8: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_I1: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_A8: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_A4I4: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + #if INCLUDE_UNTESTED_STUFF case IMcPixelType_ARGB8888: return @@ -3325,7 +3325,7 @@ IMrImage_Scale_Box( inDstHeight, outDstData); #endif - + #if INCLUDE_UNTESTED_STUFF case IMcPixelType_RGB888: return @@ -3344,16 +3344,16 @@ IMrImage_Scale_Box( else { /* expand source to bigger dimension then scale to destination */ - + void *tempMemory; UUtUns16 tempDimension; - + tempDimension = inSrcWidth > inSrcHeight ? inSrcWidth : inSrcHeight; - + tempMemory = UUrMemory_Block_New( IMrImage_ComputeRowBytes(inSrcPixelType, tempDimension) * tempDimension); UUmError_ReturnOnNull(tempMemory); - + IMrImage_Scale_Box( inSrcWidth, inSrcHeight, @@ -3362,8 +3362,8 @@ IMrImage_Scale_Box( tempDimension, tempDimension, tempMemory); - - + + IMrImage_Scale_Box( tempDimension, tempDimension, @@ -3372,12 +3372,12 @@ IMrImage_Scale_Box( inDstWidth, inDstHeight, outDstData); - + UUrMemory_Block_Delete(tempMemory); } - + UUrMemory_Block_VerifyList(); - + return UUcError_None; } @@ -3392,12 +3392,12 @@ IMrImage_Scale_Box_IndependantAlpha( void* outDstData) { UUrMemory_Block_VerifyList(); - + if(inSrcWidth == inDstWidth && inSrcHeight == inDstHeight) { - + if(inSrcData == outDstData) return UUcError_None; - + UUrMemory_MoveFast( inSrcData, outDstData, @@ -3416,7 +3416,7 @@ IMrImage_Scale_Box_IndependantAlpha( inDstWidth, inDstHeight, outDstData); - + case IMcPixelType_RGB555: return IMiImage_Scale_Box_Down_RGB555( @@ -3426,7 +3426,7 @@ IMrImage_Scale_Box_IndependantAlpha( inDstWidth, inDstHeight, outDstData); - + case IMcPixelType_ARGB1555: return IMiImage_Scale_Box_Down_ARGB1555_IndependantAlpha( @@ -3436,19 +3436,19 @@ IMrImage_Scale_Box_IndependantAlpha( inDstWidth, inDstHeight, outDstData); - + case IMcPixelType_I8: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_I1: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_A8: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_A4I4: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_ARGB8888: return IMiImage_Scale_Box_Down_ARGB8888_IndependantAlpha( @@ -3458,7 +3458,7 @@ IMrImage_Scale_Box_IndependantAlpha( inDstWidth, inDstHeight, outDstData); - + case IMcPixelType_RGB888: return IMiImage_Scale_Box_Down_RGB888( @@ -3485,7 +3485,7 @@ IMrImage_Scale_Box_IndependantAlpha( inDstWidth, inDstHeight, outDstData); - + #if INCLUDE_UNTESTED_STUFF case IMcPixelType_RGB555: return @@ -3497,7 +3497,7 @@ IMrImage_Scale_Box_IndependantAlpha( inDstHeight, outDstData); #endif - + #if INCLUDE_UNTESTED_STUFF case IMcPixelType_ARGB1555: return @@ -3509,19 +3509,19 @@ IMrImage_Scale_Box_IndependantAlpha( inDstHeight, outDstData); #endif - + case IMcPixelType_I8: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_I1: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_A8: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + case IMcPixelType_A4I4: UUmError_ReturnOnErrorMsg(UUcError_Generic, "Not implemented"); - + #if INCLUDE_UNTESTED_STUFF case IMcPixelType_ARGB8888: return @@ -3552,16 +3552,16 @@ IMrImage_Scale_Box_IndependantAlpha( else { /* expand source to bigger dimension then scale to destination */ - + void *tempMemory; UUtUns16 tempDimension; - + tempDimension = inSrcWidth > inSrcHeight ? inSrcWidth : inSrcHeight; - + tempMemory = UUrMemory_Block_New( IMrImage_ComputeRowBytes(inSrcPixelType, tempDimension) * tempDimension); UUmError_ReturnOnNull(tempMemory); - + IMrImage_Scale_Box( inSrcWidth, inSrcHeight, @@ -3570,8 +3570,8 @@ IMrImage_Scale_Box_IndependantAlpha( tempDimension, tempDimension, tempMemory); - - + + IMrImage_Scale_Box( tempDimension, tempDimension, @@ -3580,11 +3580,11 @@ IMrImage_Scale_Box_IndependantAlpha( inDstWidth, inDstHeight, outDstData); - + UUrMemory_Block_Delete(tempMemory); } - + UUrMemory_Block_VerifyList(); - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LI_Platform.h b/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LI_Platform.h index a6344a9..8f3a680 100644 --- a/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LI_Platform.h +++ b/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LI_Platform.h @@ -23,7 +23,7 @@ void LIrPlatform_InputEvent_GetMouse( LItMode inMode, LItInputEvent *outInputEvent); - + // ---------------------------------------------------------------------- void LIrPlatform_Mode_Set( @@ -38,7 +38,7 @@ LIrPlatform_Initialize( void LIrPlatform_PollInputForAction( LItAction *outAction); - + void LIrPlatform_Terminate( void); diff --git a/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LI_Translators.c b/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LI_Translators.c index 6532470..2a1f161 100644 --- a/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LI_Translators.c +++ b/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LI_Translators.c @@ -21,7 +21,7 @@ typedef struct LItInputNames { char name[LIcMaxInputNameLength]; UUtUns32 keyCode; - + } LItInputNames; // ====================================================================== @@ -106,7 +106,7 @@ LItInputNames LIgInputNames[] = { "fkey13", LIcKeyCode_F13 }, { "fkey14", LIcKeyCode_F14 }, { "fkey15", LIcKeyCode_F15 }, - + { "backspace", LIcKeyCode_BackSpace }, { "tab", LIcKeyCode_Tab }, { "capslock", LIcKeyCode_CapsLock }, @@ -133,12 +133,12 @@ LItInputNames LIgInputNames[] = { "delete", LIcKeyCode_Delete }, { "end", LIcKeyCode_End }, { "pagedown", LIcKeyCode_PageDown }, - + { "uparrow", LIcKeyCode_UpArrow }, { "leftarrow", LIcKeyCode_LeftArrow }, { "downarrow", LIcKeyCode_DownArrow }, { "rightarrow", LIcKeyCode_RightArrow }, - + { "numlock", LIcKeyCode_NumLock }, { "divide", LIcKeyCode_Divide }, { "multiply", LIcKeyCode_Multiply }, @@ -166,7 +166,7 @@ LItInputNames LIgInputNames[] = { "leftbracket", LIcKeyCode_LeftBracket }, { "rightbracket", LIcKeyCode_RightBracket }, { "comma", LIcKeyCode_Comma }, - + { "mousebutton1", LIcMouseCode_Button1 }, { "mousebutton2", LIcMouseCode_Button2 }, { "mousebutton3", LIcMouseCode_Button3 }, @@ -174,7 +174,7 @@ LItInputNames LIgInputNames[] = { "mousexaxis", LIcMouseCode_XAxis }, { "mouseyaxis", LIcMouseCode_YAxis }, { "mousezaxis", LIcMouseCode_ZAxis }, - + { "", LIcKeyCode_None } }; @@ -189,10 +189,10 @@ LIrTranslate_InputCode( { LItInputNames *name; UUtBool found; - + // initialize outInputName UUrString_Copy(outInputName, "", LIcMaxInputNameLength); - + // find the input name whose keycode that matches inKeyCode found = UUcFalse; for (name = LIgInputNames; @@ -206,7 +206,7 @@ LIrTranslate_InputCode( break; } } - + if (found == UUcFalse) { // it wasn't a complex name @@ -222,13 +222,13 @@ LIrTranslate_InputName( UUtUns32 name_length; UUtUns32 out_keycode; char *src; - + // init the vars out_keycode = LIcKeyCode_None; // get the length of the string name_length = strlen(inInputName); - + // make the input name all lower case src = inInputName; while (*src) @@ -236,7 +236,7 @@ LIrTranslate_InputName( *src = tolower(*src); src++; } - + if (name_length == 1) { // it is a letter or number or symbol and can easily be @@ -246,7 +246,7 @@ LIrTranslate_InputName( else { LItInputNames *name; - + // go through the input names list and translate // the name into the key for (name = LIgInputNames; @@ -260,6 +260,6 @@ LIrTranslate_InputName( } } } - + return out_keycode; } diff --git a/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LocalInput.c b/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LocalInput.c index f436b80..946921a 100644 --- a/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LocalInput.c +++ b/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LocalInput.c @@ -40,14 +40,14 @@ typedef struct LItEventQueueElement LItEventQueueElement; struct LItEventQueueElement { LItEventQueueElement *next; - LItInputEvent event; + LItInputEvent event; }; typedef struct LItEventQueue { LItEventQueueElement *head; LItEventQueueElement *tail; - + } LItEventQueue; // ====================================================================== @@ -74,12 +74,12 @@ static LItCheatHook LIgCheatHook = NULL; // False is the default value of LIgActionBufferUnavail so that the programmer // doesn't have to remember to initialize it. It is good to initialize it, but // this is safer than having a variable that has to be initialize to True. -static volatile UUtBool LIgActionBufferUnavail; +static volatile UUtBool LIgActionBufferUnavail; #if UUmPlatform == UUmPlatform_Win32 HANDLE gInputMutex= NULL; -#endif +#endif // ====================================================================== // functions @@ -92,16 +92,16 @@ LIrActionBuffer_Enter( #if UUmPlatform == UUmPlatform_Win32 WaitForSingleObject(gInputMutex, INFINITE); #else - + while(LIgActionBufferUnavail) { }; - + LIgActionBufferUnavail=UUcTrue; #endif } - + // ---------------------------------------------------------------------- static void LIrActionBuffer_Leave( @@ -130,7 +130,7 @@ LIiBind( SLtParameter_Actual *ioReturnValue) { LIrBinding_Add(LIrTranslate_InputName(inParameterList[0].val.str), inParameterList[2].val.str); - + return UUcError_None; } @@ -148,7 +148,7 @@ LIiUnbind( return UUcError_None; } - + // ---------------------------------------------------------------------- static UUtError LIiUnbindAll( @@ -160,7 +160,7 @@ LIiUnbindAll( SLtParameter_Actual *ioReturnValue) { LIrBindings_RemoveAll(); - + return UUcError_None; } @@ -175,27 +175,27 @@ LIiEventQueue_Dequeue( LItEventQueue *ioQueue) { LItEventQueueElement *temp; - + // get the head element temp = ioQueue->head; - + // if temp != NULL then there was at least one element in the queue // so set the queue's head to the next element in the queue. If // there is only one element in the queue, next will be NULL, and // the head will be set properly. if (temp == NULL) return NULL; - + ioQueue->head = ioQueue->head->next; - + // if there was only one element in the queue, then set the tail to NULL if (temp == ioQueue->tail) { ioQueue->tail = NULL; } - + // temp no longer points to anything temp->next = NULL; - + // return the element return temp; } @@ -207,7 +207,7 @@ LIiEventQueue_Enqueue( LItEventQueueElement *ioElement) { UUmAssert(ioElement); - + // there is nothing after the element ioElement->next = NULL; @@ -220,7 +220,7 @@ LIiEventQueue_Enqueue( // insert the element at the tail of the queue ioQueue->tail = ioElement; - + // mark the head if there are no elements in the queue if (ioQueue->head == NULL) { @@ -234,28 +234,28 @@ LIiEventQueue_Initialize( void) { UUtUns16 i; - + // initialize the queue LIgEmptyQueue.head = NULL; LIgEmptyQueue.tail = NULL; LIgEventQueue.head = NULL; LIgEventQueue.tail = NULL; - + // add elements to the empty queue for (i = 0; i < LIcMaxQueueElements; i++) { LItEventQueueElement *temp; - + // allocate a new element temp = (LItEventQueueElement*)UUrMemory_Block_New( sizeof(LItEventQueueElement)); UUmError_ReturnOnNull(temp); - + // insert the element into the empty queue LIiEventQueue_Enqueue(&LIgEmptyQueue, temp); } - + return UUcError_None; } @@ -265,7 +265,7 @@ LIiEventQueue_Terminate( void) { LItEventQueueElement *temp; - + // clear the empty queue temp = LIiEventQueue_Dequeue(&LIgEmptyQueue); while (temp) @@ -275,7 +275,7 @@ LIiEventQueue_Terminate( } LIgEmptyQueue.head = NULL; LIgEmptyQueue.tail = NULL; - + // clear the event queue temp = LIiEventQueue_Dequeue(&LIgEventQueue); while (temp) @@ -304,54 +304,54 @@ LIrActionBuffer_Add( { UUtUns16 i; LItBinding *binding; - + #if UUmPlatform != UUmPlatform_Mac - + // The mac does not like hitting asserts at interrupt time when debugging - + UUmAssertReadPtr(inDeviceInput, sizeof(*inDeviceInput)); UUmAssertReadPtr(outAction, sizeof(*outAction)); UUmAssert(inDeviceInput->input != LIcKeyCode_None); - + #endif - + // find the binding assigned to this input for (i = 0; i < LIcMaxBindings; i++) { binding = &LIgBindingArray[i]; if (binding->boundInput == inDeviceInput->input) break; } - + // if no binding was found, exit if (i == LIcMaxBindings) return; - + #if UUmPlatform != UUmPlatform_Mac // set the data in the action UUmAssertReadPtr(binding->action, sizeof(binding->action)); #endif - + switch (binding->action->inputType) { case LIcIT_Button: outAction->buttonBits |= LImMakeBitMask(binding->action->actionData); break; - + case LIcIT_Axis_Asymmetric: outAction->analogValues[binding->action->actionData] += inDeviceInput->analogValue; break; - + case LIcIT_Axis_Symmetric_Pos: outAction->analogValues[binding->action->actionData] += inDeviceInput->analogValue; break; - + case LIcIT_Axis_Symmetric_Neg: outAction->analogValues[binding->action->actionData] -= inDeviceInput->analogValue; break; - + case LIcIT_Axis_Delta: outAction->analogValues[binding->action->actionData] += inDeviceInput->analogValue; @@ -381,17 +381,17 @@ LIrActionBuffer_Get( // take control of the action buffer LIrActionBuffer_Enter(); - + // Get the buffer which will be returned returnBuffer = LIgActiveBuffer; - + // Flip the buffer LIgActiveBuffer = !LIgActiveBuffer; - + *outNumActionsInBuffer = LIgBufferIndex[returnBuffer]; LIgBufferIndex[returnBuffer] = 0; *outActionBuffer = LIgBuffer[returnBuffer]; - + // release the action buffer LIrActionBuffer_Leave(); } @@ -410,19 +410,19 @@ LIiBindings_GetFreeBinding( { UUtUns16 i; LItBinding *binding; - + for (i = 0; i < LIcMaxBindings; i++) { binding = &LIgBindingArray[i]; - + if (binding->boundInput == LIcKeyCode_None) break; } - + if (i == LIcMaxBindings) { binding = NULL; } - + return binding; } @@ -437,16 +437,16 @@ LIrBinding_Add( LItActionDescription *ad; UUtUns16 i; UUtBool found_binding; - + // don't bind to LIcKeyCode_None if (inBoundInput == LIcKeyCode_None) return UUcError_None; - + // init vars that need initing error = UUcError_None; - + // take control of the action buffer LIrActionBuffer_Enter(); - + // ------------------------------ // search for a binding with a matching boundInput // ------------------------------ @@ -460,12 +460,12 @@ LIrBinding_Add( break; } } - + // ------------------------------ // find all the action descriptions and calculate the number of actions // ------------------------------ // convert inActionName to lowercase - + // search for a matching action description for (ad = LIgActionDescriptions; ad->actionName[0] != '\0'; @@ -473,7 +473,7 @@ LIrBinding_Add( { if (UUrString_Compare_NoCase(ad->actionName, inActionName) == 0) break; } - + // if no actions were found, then exit if (ad->actionName[0] == '\0') { @@ -488,7 +488,7 @@ LIrBinding_Add( // don't allow the escape key's binding to change. This // test for LIcKeyCode_Escape has to happen here because // the binding for escape goes through this function and if - // inBoundInput is checked against LIcKeyCode_Escape, the + // inBoundInput is checked against LIcKeyCode_Escape, the // escape key will never get bound. if ((found_binding) && (binding->boundInput != LIcKeyCode_Escape)) { @@ -503,10 +503,10 @@ LIrBinding_Add( error = UUcError_OutOfMemory; goto exit; } - + // set the bound input binding->boundInput = inBoundInput; - + // add the action descriptions to the binding binding->action = ad; } @@ -514,9 +514,9 @@ LIrBinding_Add( exit: // release the action buffer LIrActionBuffer_Leave(); - + //UUrMemory_Block_VerifyList(); - + return error; } @@ -529,18 +529,18 @@ LIrBindings_Enumerate( UUtUns16 i; UUmAssert(inBindingEnumerator); - + for (i = 0; i < LIcMaxBindings; i++) { UUtBool result; LItBinding *binding; - + binding = &LIgBindingArray[i]; if (binding->boundInput == LIcKeyCode_None) { continue; } - + result = inBindingEnumerator( binding->boundInput, @@ -556,14 +556,14 @@ LIiBindings_Initialize( void) { UUtUns16 i; - + // initialize LIgBindingArray for (i = 0; i < LIcMaxBindings; i++) { LIgBindingArray[i].boundInput = LIcKeyCode_None; LIgBindingArray[i].action = NULL; } - + return UUcError_None; } @@ -574,24 +574,24 @@ LIrBinding_Remove( { LItBinding *binding; UUtUns16 i; - + // don't unbind escape if ((inBoundInput == LIcKeyCode_Escape) || (inBoundInput == LIcKeyCode_None)) { return; } - + // take control of the action buffer LIrActionBuffer_Enter(); - + // search for a binding with a matching boundInput for (i = 0; i < LIcMaxBindings; i++) { binding = &LIgBindingArray[i]; if (binding->boundInput == inBoundInput) break; } - + // turn off the binding if (i != LIcMaxBindings) { @@ -609,21 +609,21 @@ LIiBindings_RemoveAll( void) { UUtUns16 i; - + // take control of the action buffer LIrActionBuffer_Enter(); - + // turn off all of the bindings for (i = 0; i < LIcMaxBindings; i++) { LItBinding *binding; - + binding = &LIgBindingArray[i]; - + binding->boundInput = LIcKeyCode_None; binding->action = NULL; } - + // release the action buffer LIrActionBuffer_Leave(); } @@ -635,7 +635,7 @@ LIrBindings_RemoveAll( { // remove all of the bindings LIiBindings_RemoveAll(); - + // put escape back LIrBinding_Add(LIcKeyCode_Escape, "escape"); } @@ -663,14 +663,14 @@ LIrInputEvent_Add( UUtUns32 inModifiers) { LItEventQueueElement *temp; - + // don't add events when in game mode if (LIgMode_Internal == LIcMode_Game) return; - + // get a queue element from the empty queue temp = LIiEventQueue_Dequeue(&LIgEmptyQueue); if (temp == NULL) return; - + // set up outInputEvent temp->event.type = inEventType; if (inPoint) @@ -688,7 +688,7 @@ LIrInputEvent_Add( LIrPlatform_InputEvent_InterpretModifiers( inEventType, inModifiers); - + // add the event to the queue LIiEventQueue_Enqueue(&LIgEventQueue, temp); } @@ -699,17 +699,17 @@ LIrInputEvent_Get( LItInputEvent *outInputEvent) { LItEventQueueElement *temp; - + // update the input system LIrUpdate(); - + // set up outInputEvent outInputEvent->type = LIcInputEvent_None; outInputEvent->where.x = 0; outInputEvent->where.y = 0; outInputEvent->key = 0; outInputEvent->modifiers = 0; - + // try to get an event from the event queue and return the event // if one was available temp = LIiEventQueue_Dequeue(&LIgEventQueue); @@ -721,13 +721,13 @@ LIrInputEvent_Get( if (NULL != LIgCheatHook) { LIgCheatHook(outInputEvent); } - + // put temp into the empty queue LIiEventQueue_Enqueue(&LIgEmptyQueue, temp); - + return UUcTrue; } - + return UUcFalse; } @@ -758,7 +758,7 @@ static void LIrMode_Set_Internal(void) LItMode new_mode; LIgMouse_Invert = ONrPersist_IsInvertMouseOn(); - + if (!LIgGameIsActive) { new_mode = LIcMode_Normal; } @@ -768,13 +768,13 @@ static void LIrMode_Set_Internal(void) // don't switch modes if it isn't necessary if (LIgMode_Internal == new_mode) return; - + // update the platform level LIrPlatform_Mode_Set(new_mode); - + // clear out any old events while (LIrPlatform_Update(new_mode)){}; - + // record the mode change LIgMode_Internal = new_mode; @@ -832,20 +832,20 @@ LIiInterruptHandleProc( { // take control of the action buffers LIrActionBuffer_Enter(); - + // wrap the action buffer if it is full if(LIgBufferIndex[LIgActiveBuffer] >= LIcMaxActionsInBuffer) { LIgBufferIndex[LIgActiveBuffer] = 0; } - + // get an action from the platform LIrPlatform_PollInputForAction( &LIgBuffer[LIgActiveBuffer][LIgBufferIndex[LIgActiveBuffer]]); // advance to the next buffer in the buffer LIgBufferIndex[LIgActiveBuffer]++; - + // release the action buffers LIrActionBuffer_Leave(); } @@ -862,24 +862,24 @@ static void mac_get_input_in_game( { // take control of the action buffers LIrActionBuffer_Enter(); - + // wrap the action buffer if it is full if(LIgBufferIndex[LIgActiveBuffer] >= LIcMaxActionsInBuffer) { LIgBufferIndex[LIgActiveBuffer] = 0; } - + // get an action from the platform LIrPlatform_PollInputForAction( &LIgBuffer[LIgActiveBuffer][LIgBufferIndex[LIgActiveBuffer]]); // advance to the next buffer in the buffer LIgBufferIndex[LIgActiveBuffer]++; - + // release the action buffers LIrActionBuffer_Leave(); } - + return; } #endif @@ -894,22 +894,22 @@ LIiTerminate_AtExit( void) { // this can be called reentrantly under Win32 so make sure that doesn't happen - static UUtBool inside = UUcFalse; - + static UUtBool inside = UUcFalse; + // take control of the action buffer LIrActionBuffer_Enter(); - + if (!inside) { inside = UUcTrue; - + if (LIgInterruptProcRef != NULL) { UUrInterruptProc_Deinstall(LIgInterruptProcRef); LIgInterruptProcRef = NULL; } } - + inside = UUcFalse; // release the action buffer @@ -943,22 +943,22 @@ LIrInitialize( LIgBufferIndex[1] = 0; LIgInterruptProcRef = NULL; LIgActionBufferUnavail = UUcFalse; - + // register an atexit proc UUrAtExit_Register(LIiTerminate_AtExit); - + // initialize the bindings error = LIiBindings_Initialize(); UUmError_ReturnOnError(error); - + // initialize the queues error = LIiEventQueue_Initialize(); UUmError_ReturnOnError(error); - + // initialize the platform specific input stuff error = LIrPlatform_Initialize(inInstance, inWindow); UUmError_ReturnOnError(error); - + // install the interrupt handler #if UUmPlatform != UUmPlatform_Mac // the whole interrupt proc thing does not work on Mac. don't use it. @@ -1070,19 +1070,19 @@ LIrInitializeDeveloperKeys( LIrBinding_Add(LIcKeyCode_L, "record_screen"); LIrBinding_Add(LIcKeyCode_Insert, "addflag"); LIrBinding_Add(LIcKeyCode_Delete, "deleteflag"); - + LIrBinding_Add(LIcKeyCode_Subtract, "man_cam_move_up"); LIrBinding_Add(LIcKeyCode_Add, "man_cam_move_down"); LIrBinding_Add(LIcKeyCode_NumPad1, "man_cam_move_left"); LIrBinding_Add(LIcKeyCode_NumPad3, "man_cam_move_right"); LIrBinding_Add(LIcKeyCode_NumPad8, "man_cam_move_forward"); LIrBinding_Add(LIcKeyCode_NumPad5, "man_cam_move_backward"); - + LIrBinding_Add(LIcKeyCode_NumPad6, "man_cam_pan_left"); LIrBinding_Add(LIcKeyCode_NumPad4, "man_cam_pan_right"); LIrBinding_Add(LIcKeyCode_UpArrow, "man_cam_pan_up"); LIrBinding_Add(LIcKeyCode_DownArrow, "man_cam_pan_down"); - + LIrBinding_Add(LIcKeyCode_Comma, "place_quad"); LIrBinding_Add(LIcKeyCode_Period, "place_quad_mode"); } @@ -1113,19 +1113,19 @@ LIrUnbindDeveloperKeys( LIrBinding_Remove(LIcKeyCode_L); LIrBinding_Remove(LIcKeyCode_Insert); LIrBinding_Remove(LIcKeyCode_Delete); - + LIrBinding_Remove(LIcKeyCode_Subtract); LIrBinding_Remove(LIcKeyCode_Add); LIrBinding_Remove(LIcKeyCode_NumPad1); LIrBinding_Remove(LIcKeyCode_NumPad3); LIrBinding_Remove(LIcKeyCode_NumPad8); LIrBinding_Remove(LIcKeyCode_NumPad5); - + LIrBinding_Remove(LIcKeyCode_NumPad6); LIrBinding_Remove(LIcKeyCode_NumPad4); LIrBinding_Remove(LIcKeyCode_UpArrow); LIrBinding_Remove(LIcKeyCode_DownArrow); - + LIrBinding_Remove(LIcKeyCode_Comma); LIrBinding_Remove(LIcKeyCode_Period); } @@ -1141,13 +1141,13 @@ LIrTerminate( UUrInterruptProc_Deinstall(LIgInterruptProcRef); LIgInterruptProcRef = NULL; } - + // terminate the platform specific input stuff LIrPlatform_Terminate(); - + // terminate the queue LIiEventQueue_Terminate(); - + // terminate the bindings LIiBindings_Terminate(); @@ -1181,7 +1181,7 @@ LIrTestKey(LItKeyCode inKeyCode) return result; } -UUtBool +UUtBool LIrKeyWentDown(LItKeyCode inKeyCode, UUtBool *ioOldKeyDown) { UUtBool key_down = LIrTestKey(inKeyCode); diff --git a/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LocalInput_Template.c b/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LocalInput_Template.c index ba5aa7a..80da0ed 100644 --- a/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LocalInput_Template.c +++ b/BungieFrameWork/BFW_Source/BFW_LocalInput/BFW_LocalInput_Template.c @@ -1,12 +1,12 @@ /* FILE: BFW_LocalInput_Template.c - + AUTHOR: Brent H. Pease - + CREATED: May 31, 1997 - + PURPOSE: input - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_MacOS/BFW_LI_Platform_MacOS.c b/BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_MacOS/BFW_LI_Platform_MacOS.c index 2143cc2..d91bb8c 100644 --- a/BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_MacOS/BFW_LI_Platform_MacOS.c +++ b/BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_MacOS/BFW_LI_Platform_MacOS.c @@ -62,7 +62,7 @@ typedef struct LItKeyCodeHelper { UUtUns8 ascii; UUtUns8 keyCode; - + } LItKeyCodeHelper; typedef struct LItMouse @@ -75,7 +75,7 @@ typedef struct LItMouse ISpElementReference xAxis; ISpElementReference yAxis; ISpElementReference zAxis; - + } LItMouse; // ====================================================================== @@ -94,7 +94,7 @@ struct mac_oni_key { UUtUns8 mac_key; }; -static struct mac_oni_key mac_keyboard_translation_table[]= +static struct mac_oni_key mac_keyboard_translation_table[]= { {LIcKeyCode_Grave, 0x32}, // ~ 0x32 {LIcKeyCode_1, 0x12}, // 1 0x12 @@ -266,29 +266,29 @@ void mac_hide_cursor( void) { extern UUtBool M3gResolutionSwitch; // BFW_Motoko.h - + if (SHIPPING_VERSION) // never hide cursor if running a non-shipping version { extern WindowPtr oni_mac_window; // Oni_Platform_Mac.c Rect window_rect; - + // load the invisible cursor only if running full screen if ((oni_cursor == NULL) && M3gResolutionSwitch) { oni_cursor= GetCursor(CURS_RES_ID); } - + if (oni_cursor) { HLock(oni_cursor); SetCursor(*oni_cursor); } - + if (oni_mac_window && GetWindowPortBounds(oni_mac_window, &window_rect)) { Point offset; - + offset.h= window_rect.left; offset.v= window_rect.top; ShieldCursor(&window_rect, offset); @@ -297,10 +297,10 @@ void mac_hide_cursor( { HideCursor(); } - + mac_cursor_visible= false; } - + return; } @@ -312,7 +312,7 @@ void mac_show_cursor( if (oni_cursor) { Cursor unused= {0}, *arrow; - + if ((arrow= GetQDGlobalsArrow(&unused)) != NULL) { SetCursor(arrow); @@ -325,11 +325,11 @@ void mac_show_cursor( UUrDebuggerMessage("unable to restore the MacOS cursor"); } } - + ShowCursor(); mac_cursor_visible= true; } - + return; } @@ -348,13 +348,13 @@ LIiPlatform_Mouse_Activate( if (using_input_sprocket) { UUtUns32 mindex; - + // activate the devices for (mindex= 0; mindex < LIgMouse_NumMice; mindex++) { OSStatus status; UUtUns32 i; - + if (LIgMouse[mindex].mouse == NULL) continue; for (i= 0; i < LIgMouse[mindex].num_buttons; i++) @@ -364,7 +364,7 @@ LIiPlatform_Mouse_Activate( if (LIgMouse[mindex].xAxis) status= ISpElement_Flush(LIgMouse[mindex].xAxis); if (LIgMouse[mindex].yAxis) status= ISpElement_Flush(LIgMouse[mindex].yAxis); if (LIgMouse[mindex].zAxis) status= ISpElement_Flush(LIgMouse[mindex].zAxis); - + status= ISpDevices_Activate(1, &LIgMouse[mindex].mouse); } } @@ -380,15 +380,15 @@ LIiPlatform_Mouse_Deactivate( if (using_input_sprocket) { UUtUns32 mindex; - + // activate the devices for (mindex= 0; mindex < LIgMouse_NumMice; mindex++) { OSStatus status; UUtUns32 i; - + if (LIgMouse[mindex].mouse == NULL) continue; - + for (i= 0; i < LIgMouse[mindex].num_buttons; i++) { if (LIgMouse[mindex].button[i]) status= ISpElement_Flush(LIgMouse[mindex].button[i]); @@ -396,7 +396,7 @@ LIiPlatform_Mouse_Deactivate( if (LIgMouse[mindex].xAxis) status= ISpElement_Flush(LIgMouse[mindex].xAxis); if (LIgMouse[mindex].yAxis) status= ISpElement_Flush(LIgMouse[mindex].yAxis); if (LIgMouse[mindex].zAxis) status= ISpElement_Flush(LIgMouse[mindex].zAxis); - + status= ISpDevices_Deactivate(1, &LIgMouse[mindex].mouse); } } @@ -416,14 +416,14 @@ LIiPlatform_Mouse_GetData( if (using_input_sprocket) { UUtUns32 mindex; - + for (mindex= 0; mindex < LIgMouse_NumMice; mindex++) { UUtUns32 button_data; UUtUns32 delta_data; LItDeviceInput deviceInput; UUtUns32 i; - + if (LIgMouse[mindex].mouse == NULL) continue; // get the button data @@ -438,29 +438,29 @@ LIiPlatform_Mouse_GetData( // XXX - if LIcMouseCode_ButtonX ever change, this may break deviceInput.input= i + LIcMouseCode_Button1; deviceInput.analogValue= 1.0f; - + LIrActionBuffer_Add(outAction, &deviceInput); } } } - + // get the axis data if (LIgMouse[mindex].xAxis) { delta_data= 0; ISpElement_GetSimpleState(LIgMouse[mindex].xAxis, &delta_data); - + deviceInput.input= LIcMouseCode_XAxis; deviceInput.analogValue= (float)((UUtInt32)delta_data) * LIcFixed_to_Float * 160.0f; - + LIrActionBuffer_Add(outAction, &deviceInput); } - + if (LIgMouse[mindex].yAxis) { delta_data= 0; ISpElement_GetSimpleState(LIgMouse[mindex].yAxis, &delta_data); - + deviceInput.input= LIcMouseCode_YAxis; if (LIgMouse_Invert) { @@ -470,18 +470,18 @@ LIiPlatform_Mouse_GetData( { deviceInput.analogValue= (float)((UUtInt32)delta_data) * LIcFixed_to_Float * -160.0f; } - + LIrActionBuffer_Add(outAction, &deviceInput); } - + if (LIgMouse[mindex].zAxis) { delta_data= 0; ISpElement_GetSimpleState(LIgMouse[mindex].zAxis, &delta_data); - + deviceInput.input = LIcMouseCode_ZAxis; deviceInput.analogValue = (float)((UUtInt32)delta_data) * LIcFixed_to_Float * 160.0f; - + LIrActionBuffer_Add(outAction, &deviceInput); } } @@ -494,19 +494,19 @@ LIiPlatform_Mouse_GetData( GrafPtr old_port; Point current_mouse; static Point old_mouse= {0,0}; - + // set the port GetPort(&old_port); SetPort(GetWindowPort(LIgWindow)); - + GetMouse(¤t_mouse); mouse_dx= current_mouse.h - old_mouse.h; mouse_dy= old_mouse.v - current_mouse.v; // invert Y old_mouse= current_mouse; button_down= Button(); - + SetPort(old_port); - + if (button_down) { device_input.input= LIcMouseCode_Button1; @@ -540,17 +540,17 @@ LIiPlatform_Mouse_Initialize( void) { UUtError error= UUcError_None; - + if (using_input_sprocket) { OSStatus status; UUtUns32 numDevices; ISpDeviceReference devices[LIcNumDevices]; UUtUns32 mindex; - + // Initialize UUrMemory_Clear(LIgMouse, sizeof(LIgMouse)); - + // get a list of the mice attached to the system status = ISpDevices_ExtractByClass( @@ -563,19 +563,19 @@ LIiPlatform_Mouse_Initialize( UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to extract devices"); } if (numDevices == 0) return UUcError_None; - + LIgMouse_NumMice = UUmMin(LIcMouse_MaxMice, numDevices); - + for (mindex = 0; mindex < LIgMouse_NumMice; mindex++) { ISpElementListReference elementListRef; UUtUns32 numElements; ISpElementReference elements[LIcNumElements]; UUtUns32 i; - + // only use the first device LIgMouse[mindex].mouse = devices[mindex]; - + // get a list of the elements in the first device status = ISpDevice_GetElementList( @@ -591,7 +591,7 @@ LIiPlatform_Mouse_Initialize( LIgMouse[mindex].mouse = NULL; return UUcError_None; } - + // extract the elements of the device status = ISpElementList_Extract( @@ -609,12 +609,12 @@ LIiPlatform_Mouse_Initialize( LIgMouse[mindex].mouse = NULL; return UUcError_None; } - + // go through the elements and find uses for them for (i = 0; i < numElements; i++) { ISpElementInfo elementInfo; - + // get info about the element status = ISpElement_GetInfo( @@ -624,7 +624,7 @@ LIiPlatform_Mouse_Initialize( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to extract devices"); } - + // gather the info switch (elementInfo.theKind) { @@ -635,18 +635,18 @@ LIiPlatform_Mouse_Initialize( LIgMouse[mindex].num_buttons++; } break; - + case kISpElementKind_Delta: switch (elementInfo.theLabel) { case kISpElementLabel_Delta_X: LIgMouse[mindex].xAxis = elements[i]; break; - + case kISpElementLabel_Delta_Y: LIgMouse[mindex].yAxis = elements[i]; break; - + case kISpElementLabel_Delta_Z: LIgMouse[mindex].zAxis = elements[i]; break; @@ -656,7 +656,7 @@ LIiPlatform_Mouse_Initialize( } } } - + return error; } @@ -691,20 +691,20 @@ static void LIiPlatform_Keyboard_GetData( { unsigned char keymap[16]; int i; - + GetKeys((unsigned long *)keymap); for (i= 0; i>3] >> (mac_keyboard_translation_table[i].mac_key & 7) ) & 1) { LItDeviceInput device_input; - + device_input.input= mac_keyboard_translation_table[i].oni_key; device_input.analogValue= 1.0f; LIrActionBuffer_Add(action, &device_input); } } - + return; } @@ -736,7 +736,7 @@ LIiPlatform_Devices_Activate( // activate the devices LIiPlatform_Mouse_Activate(); LIiPlatform_Keyboard_Activate(); - + return; } @@ -748,10 +748,10 @@ LIiPlatform_Devices_Deactivate( // deactivate the devices LIiPlatform_Mouse_Deactivate(); LIiPlatform_Keyboard_Deactivate(); - + // flush the events in the MacOS event queue FlushEvents(everyEvent, 0); - + return; } @@ -761,15 +761,15 @@ LIiPlatform_Devices_Initialize( void) { UUtError error; - + // initialize the mouse error= LIiPlatform_Mouse_Initialize(); UUmError_ReturnOnError(error); - + // initialize the keyboard error= LIiPlatform_Keyboard_Initialize(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -784,10 +784,10 @@ LIiPlatform_Devices_GetData( { // get mouse data LIiPlatform_Mouse_GetData(outAction); - + // get the keyboard data LIiPlatform_Keyboard_GetData(outAction); - + return; } @@ -817,7 +817,7 @@ static void mac_handle_menu_choice( menu= HiWord(menu_result); menu_item= LoWord(menu_result); - + switch (menu) { case _mac_shortcuts_menu: @@ -834,9 +834,9 @@ static void mac_handle_menu_choice( default: break; } - + HiliteMenu(0); - + return; } @@ -856,14 +856,14 @@ LIiPlatform_InputEvent_GetEvent( EventRecord event= {0}; GrafPtr old_port; LItInputEvent inputEvent= {0}; - + // don't call WaitNextEvent() unless the mode is LIcMode_Normal if (inMode == LIcMode_Game) return UUcFalse; - + // set the port GetPort(&old_port); SetPort(GetWindowPort(LIgWindow)); - + // get keyboard events and mouse events was_event= WaitNextEvent(everyEvent, &event, 0, NULL); if (was_event) @@ -875,7 +875,7 @@ LIiPlatform_InputEvent_GetEvent( { UUtInt16 part; WindowPtr window; - + part= FindWindow(event.where, &window); switch (part) { @@ -884,23 +884,23 @@ LIiPlatform_InputEvent_GetEvent( mac_handle_menu_choice(MenuSelect(event.where)); break; #endif - + case inSysWindow: /* Carbon -S.S. SystemClick(&event, window); */ was_event= UUcFalse; break; - + case inContent: // put the event in local coordinates GlobalToLocal(&event.where); - + // set the where inputEvent.where.x= event.where.h; inputEvent.where.y= event.where.v; inputEvent.modifiers= event.modifiers; - + // set the type if (inputEvent.modifiers & LIcMacOS_RightMouseButtonKey) { @@ -928,25 +928,25 @@ LIiPlatform_InputEvent_GetEvent( } } break; - + case keyDown: inputEvent.type= LIcInputEvent_KeyDown; inputEvent.key= LIgAsciiToKeyCode[(event.message & charCodeMask)]; inputEvent.modifiers= event.modifiers; - + if (inputEvent.key == LIcKeyCode_F1) { UUtUns32 index= ((event.message & keyCodeMask) - LIcFKeyStart) >> 8; inputEvent.key= LIgFunctionKey[index]; } - #ifdef USE_MAC_MENU + #ifdef USE_MAC_MENU if (event.modifiers & cmdKey) { mac_handle_menu_choice(MenuKey(inputEvent.key)); } #endif break; - + case keyUp: inputEvent.type= LIcInputEvent_KeyUp; inputEvent.key= LIgAsciiToKeyCode[(event.message & charCodeMask)]; @@ -958,7 +958,7 @@ LIiPlatform_InputEvent_GetEvent( inputEvent.key= LIgFunctionKey[index]; } break; - + case autoKey: inputEvent.type= LIcInputEvent_KeyRepeat; inputEvent.key= LIgAsciiToKeyCode[(event.message & charCodeMask)]; @@ -969,27 +969,27 @@ LIiPlatform_InputEvent_GetEvent( UUtUns32 index= ((event.message & keyCodeMask) - LIcFKeyStart) >> 8; inputEvent.key= LIgFunctionKey[index]; } - #ifdef USE_MAC_MENU + #ifdef USE_MAC_MENU if (event.modifiers & cmdKey) { mac_handle_menu_choice(MenuKey(inputEvent.key)); } #endif break; - + case updateEvt: BeginUpdate((WindowPtr)event.message); mac_hide_cursor(); EndUpdate((WindowPtr)event.message); was_event= UUcFalse; break; - + case osEvt: { UUtUns8 osEvtType; - + osEvtType= (event.message & osEvtMessageMask) >> 24; - + if (osEvtType & suspendResumeMessage) { if (event.message & resumeFlag) @@ -1001,7 +1001,7 @@ LIiPlatform_InputEvent_GetEvent( // suspend } } - + if (osEvtType & mouseMovedMessage) { // if the mouse changed position, generate a mouse moved event @@ -1028,28 +1028,28 @@ LIiPlatform_InputEvent_GetEvent( was_event= UUcFalse; break; } - + // set the previous mouse location LIgMouseLocation= inputEvent.where; } else { Point current_mouse_location; - + // get the current mouse position GetMouse(¤t_mouse_location); - + // if the mouse changed position, generate a mouse moved event if ((current_mouse_location.h != LIgMouseLocation.x) || (current_mouse_location.v != LIgMouseLocation.y)) { EventRecord fakeEvent= {0}; - + // get a fake os event /* Carbon GetOSEvent(0, &fakeEvent);*/ //GetNextEvent(0, &fakeEvent); no need for this - + // set the type and location inputEvent.type= LIcInputEvent_MouseMove; inputEvent.where.x= current_mouse_location.h; @@ -1064,7 +1064,7 @@ LIiPlatform_InputEvent_GetEvent( } } event_avail= was_event; - + // add the event to the event queue if (event_avail) { @@ -1074,7 +1074,7 @@ LIiPlatform_InputEvent_GetEvent( inputEvent.key, inputEvent.modifiers); } - + // restore the port SetPort(old_port); @@ -1099,40 +1099,40 @@ LIrPlatform_InputEvent_GetMouse( GrafPtr old_port; Point mouse_position; EventRecord fakeEvent; - + // set the port GetPort(&old_port); SetPort(GetWindowPort(LIgWindow)); - + // get the mouse position GetMouse(&mouse_position); - + // set the input event outInputEvent->where.x= mouse_position.h; outInputEvent->where.y= mouse_position.v; - + // get a fake os event /* Carbon GetOSEvent(0, &fakeEvent);*/ GetNextEvent(0, &fakeEvent); - + // check the shift key if (fakeEvent.modifiers & LIcMacOS_ShiftKey) outInputEvent->modifiers|= LIcMouseState_LShiftDown; - + // check the button state - if (!(fakeEvent.modifiers & btnState)) + if (!(fakeEvent.modifiers & btnState)) { if (fakeEvent.modifiers & LIcMacOS_RightMouseButtonKey) outInputEvent->modifiers|= LIcMouseState_RButtonDown; else outInputEvent->modifiers|= LIcMouseState_LButtonDown; } - + // restore the port SetPort(old_port); } - + return; } @@ -1143,10 +1143,10 @@ LIrPlatform_InputEvent_InterpretModifiers( UUtUns32 inModifiers) { UUtUns32 modifiers; - + // init modifiers= 0; - + switch (inEventType) { case LIcInputEvent_MouseMove: @@ -1159,16 +1159,16 @@ LIrPlatform_InputEvent_InterpretModifiers( // set the modifiers if (inModifiers & LIcMacOS_LShiftKey) modifiers|= LIcMouseState_LShiftDown; - + if (inModifiers & LIcMacOS_RShiftKey) modifiers|= LIcMouseState_RShiftDown; - + if (inModifiers & LIcMacOS_LOptionKey) modifiers|= LIcMouseState_LControlDown; if (inModifiers & LIcMacOS_ROptionKey) modifiers|= LIcMouseState_RControlDown; - + if (!(inModifiers & btnState)) { if (inModifiers & LIcMacOS_RightMouseButtonKey) @@ -1177,7 +1177,7 @@ LIrPlatform_InputEvent_InterpretModifiers( modifiers|= LIcMouseState_LButtonDown; } break; - + case LIcInputEvent_KeyUp: case LIcInputEvent_KeyDown: case LIcInputEvent_KeyRepeat: @@ -1186,19 +1186,19 @@ LIrPlatform_InputEvent_InterpretModifiers( { modifiers|= LIcKeyState_ShiftDown; } - + if (inModifiers & LIcMacOS_CommandKey) { modifiers|= LIcKeyState_CommandDown; } - + if (inModifiers & LIcMacOS_OptionKey) { modifiers|= LIcKeyState_AltDown; } break; } - + return modifiers; } @@ -1220,7 +1220,7 @@ LIrPlatform_Mode_Set( { LIiPlatform_Devices_Deactivate(); } - + return; } @@ -1239,20 +1239,20 @@ LIrPlatform_Initialize( NumVersion ISpVersion= {0}; UUtUns16 i; LItKeyCodeHelper *help; - + // ------------------------------ // initialize the globals // ------------------------------ LIgWindow= inWindow; LIgMouseLocation.x= 0; LIgMouseLocation.y= 0; - + // initialize LIgAsciiToKeyCode for (i = 0; i < 256; i++) { LIgAsciiToKeyCode[i] = i; } - + for (help= LIgKeyCodeHelper; help->ascii != 0x0000; help++) { LIgAsciiToKeyCode[help->ascii] = help->keyCode; @@ -1274,18 +1274,18 @@ LIrPlatform_Initialize( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "This version of InputSprocket is not supported."); } - + // startup ISp if (ISpStartup() != noErr) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to startup InputSprocket."); } } - + // initialize the devices error= LIiPlatform_Devices_Initialize(); UUmError_ReturnOnErrorMsg(error, "Unable to initialize the devices."); - + return UUcError_None; } @@ -1299,17 +1299,17 @@ LIrPlatform_PollInputForAction( LItAction *outAction) { UUtUns16 i; - + // clear the action outAction->buttonBits = 0; for (i= 0; ianalogValues[i] = 0.0f; } - + // get the action data LIiPlatform_Devices_GetData(outAction); - + return; } @@ -1350,7 +1350,7 @@ UUtBool LIrPlatform_TestKey( unsigned char keymap[16]; UUtBool down= UUcFalse; int i; - + GetKeys((unsigned long *)keymap); for (i= 0; isdl_key; } } - + return SDLK_UNKNOWN; } static LItKeyCode sdl_to_oni_keycode(SDL_Keycode key) { int i; - + if (key < 0x80) { // ascii range maps directly return key; } - + for (i = 0; ioni_key; } } - + return LIcKeyCode_None; } @@ -214,10 +214,10 @@ LIiPlatform_Mouse_GetData( LItAction *outAction) { LItDeviceInput deviceInput; - + int x = 0, y = 0, i; Uint32 buttonsstate = SDL_GetRelativeMouseState(&x, &y); - + for (i = 0; i < 4; ++i) { if (buttonsstate & SDL_BUTTON(i + 1)) @@ -227,7 +227,7 @@ LIiPlatform_Mouse_GetData( LIrActionBuffer_Add(outAction, &deviceInput); } } - + deviceInput.input = LIcMouseCode_XAxis; deviceInput.analogValue = (float)x * SDL_MOUSEMOVE_FACTOR; LIrActionBuffer_Add(outAction, &deviceInput); @@ -269,11 +269,11 @@ LIiPlatform_Keyboard_GetData( if (keyState[i]) { LItDeviceInput deviceInput; - + deviceInput.input = sdl_to_oni_keycode(SDL_GetKeyFromScancode(i)); deviceInput.analogValue = 1.0f; - - if (deviceInput.input != LIcKeyCode_None) + + if (deviceInput.input != LIcKeyCode_None) { LIrActionBuffer_Add(outAction, &deviceInput); } @@ -304,7 +304,7 @@ LIiPlatform_Devices_GetData( { LIiPlatform_Mouse_GetData(outAction); } - + // get the keyboard data LIiPlatform_Keyboard_GetData(outAction); } @@ -403,7 +403,7 @@ LIrPlatform_InputEvent_GetMouse( if (inMode == LIcMode_Normal) { int x, y; - + Uint32 buttons = SDL_GetMouseState(&x, &y); outInputEvent->where.x = (UUtInt16)x; outInputEvent->where.y = (UUtInt16)y; @@ -455,7 +455,7 @@ LIrPlatform_Initialize( { //UUmAssert(inInstance); UUmAssert(inWindow); - + // ------------------------------ // initialize the globals // ------------------------------ @@ -478,12 +478,12 @@ LIrPlatform_PollInputForAction( LItAction *outAction) { UUtUns16 i; - + // clear the action outAction->buttonBits = 0; for (i = 0; i < LIcNumAnalogValues; i++) outAction->analogValues[i] = 0.0f; - + // get the action data LIiPlatform_Devices_GetData(outAction); } @@ -509,7 +509,7 @@ LIrPlatform_Update( IMtPoint2D where = {0, 0}; static Uint32 current_mouse_buttons = 0; static Uint32 current_modifiers = 0; - + //FIXME: Mac and Win32 only poll for a single event // however, input is laggy if that is done. while (1) @@ -517,20 +517,20 @@ LIrPlatform_Update( if (!SDL_PollEvent(&event)) { return UUcFalse; } - + switch (event.type) { case SDL_KEYDOWN: case SDL_KEYUP: eventType = (event.key.state == SDL_PRESSED) ? LIcInputEvent_KeyDown : LIcInputEvent_KeyUp; - + current_modifiers |= sdl_to_kmod(event.key.keysym.sym); if (current_modifiers != event.key.keysym.mod) { UUmAssert(UUcFalse); current_modifiers = event.key.keysym.mod; } - + LIrInputEvent_Add( eventType, NULL, @@ -541,13 +541,13 @@ LIrPlatform_Update( case SDL_MOUSEMOTION: where.x = event.motion.x; where.y = event.motion.y; - + if (current_mouse_buttons != event.motion.state) { UUmAssert(UUcFalse); current_mouse_buttons = event.motion.state; } - + LIrInputEvent_Add( LIcInputEvent_MouseMove, &where, @@ -571,10 +571,10 @@ LIrPlatform_Update( default: return UUcTrue; } - + where.x = event.button.x; where.y = event.button.y; - + if (event.button.state == SDL_PRESSED) { current_mouse_buttons |= sdl_to_oni_mouse_modifiers(SDL_BUTTON(event.button.button)); @@ -583,7 +583,7 @@ LIrPlatform_Update( { current_mouse_buttons &= ~sdl_to_oni_mouse_modifiers(SDL_BUTTON(event.button.button)); } - + LIrInputEvent_Add( eventType, &where, @@ -605,7 +605,7 @@ LIrPlatform_Update( break; } } - + return UUcTrue; } @@ -617,7 +617,7 @@ LIrPlatform_TestKey( { (void)inMode; UUtBool keyDown = UUcFalse; - + int numkeys = 0; //TODO: capture in LIrPlatform_Update()? const Uint8 *keyState = SDL_GetKeyboardState(&numkeys); @@ -625,6 +625,6 @@ LIrPlatform_TestKey( if (scancode > 0 && scancode < numkeys) { keyDown = keyState[scancode]; } - + return keyDown; } diff --git a/BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_Win32/BFW_LI_Platform_Win32.c b/BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_Win32/BFW_LI_Platform_Win32.c index f1ea57d..404ef46 100644 --- a/BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_Win32/BFW_LI_Platform_Win32.c +++ b/BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_Win32/BFW_LI_Platform_Win32.c @@ -537,7 +537,7 @@ static UUtUns8 global_keys[256]= {0}; static char* LIiGetDIErrorMsg( HRESULT inError); - + // ====================================================================== // functions // ====================================================================== @@ -547,7 +547,7 @@ LIiPlatform_Acquire( void) { HRESULT result; - + // acquire the mouse if (LIgMouse) { @@ -557,7 +557,7 @@ LIiPlatform_Acquire( UUrError_Report(UUcError_Generic, LIiGetDIErrorMsg(result)); } } - + // acquire the keyboard if (LIgKeyboard) { @@ -575,7 +575,7 @@ LIiPlatform_Unacquire( void) { HRESULT result; - + // unacquire the mouse if (LIgMouse) { @@ -610,7 +610,7 @@ LIiPlatform_Mouse_Callback( { HRESULT result; LPDIRECTINPUTDEVICE temp_device; - + // create the device result = IDirectInput_CreateDevice( @@ -623,7 +623,7 @@ LIiPlatform_Mouse_Callback( UUrError_Report(UUcError_Generic, LIiGetDIErrorMsg(result)); return DIENUM_STOP; } - + // set the data format result = IDirectInputDevice_SetDataFormat(temp_device, &c_dfDIMouse); if (result != DI_OK) @@ -631,7 +631,7 @@ LIiPlatform_Mouse_Callback( UUrError_Report(UUcError_Generic, LIiGetDIErrorMsg(result)); return DIENUM_STOP; } - + // set the cooperative level result = IDirectInputDevice_SetCooperativeLevel( @@ -644,10 +644,10 @@ LIiPlatform_Mouse_Callback( UUrError_Report(UUcError_Generic, LIiGetDIErrorMsg(result)); return DIENUM_STOP; } - + // set the device global LIgMouse = temp_device; - + // no more return DIENUM_STOP; } @@ -673,20 +673,20 @@ LIiPlatform_Mouse_GetData_DirectInput( DIMOUSESTATE *outMouseData) { HRESULT result; - + // get the device state result= IDirectInputDevice_GetDeviceState(LIgMouse, sizeof(DIMOUSESTATE), outMouseData); if (result != DI_OK) { if (result == DIERR_INPUTLOST) - { + { LIiPlatform_Acquire(); result= IDirectInputDevice_GetDeviceState(LIgMouse, sizeof(DIMOUSESTATE), outMouseData); } } CenterCursor(); - + return (result == DI_OK); } @@ -704,15 +704,15 @@ LIiPlatform_Mouse_GetData_Win32( outMouseData->lX = cursor_pos.x - LIgCenter.x; outMouseData->lY = cursor_pos.y - LIgCenter.y; outMouseData->lZ = 0; - + // get the button data outMouseData->rgbButtons[0] = GetAsyncKeyState(MK_LBUTTON) >> 8; outMouseData->rgbButtons[1] = GetAsyncKeyState(MK_RBUTTON) >> 8; outMouseData->rgbButtons[2] = GetAsyncKeyState(MK_MBUTTON) >> 8; outMouseData->rgbButtons[3] = UUcFalse; - + CenterCursor(); - + success = UUcTrue; } else @@ -731,7 +731,7 @@ LIiPlatform_Mouse_GetData( UUtBool got_data; DIMOUSESTATE mouse_data; LItDeviceInput deviceInput; - + // get the mouse data if (LIgUseDirectInput) { @@ -742,7 +742,7 @@ LIiPlatform_Mouse_GetData( got_data = LIiPlatform_Mouse_GetData_Win32(&mouse_data); } if (got_data == UUcFalse) return; - + // interpret the data if (mouse_data.rgbButtons[0] == 0x80) { @@ -750,28 +750,28 @@ LIiPlatform_Mouse_GetData( deviceInput.analogValue = 1.0f; LIrActionBuffer_Add(outAction, &deviceInput); } - + if (mouse_data.rgbButtons[1] == 0x80) { deviceInput.input = LIcMouseCode_Button2; deviceInput.analogValue = 1.0f; LIrActionBuffer_Add(outAction, &deviceInput); } - + if (mouse_data.rgbButtons[2] == 0x80) { deviceInput.input = LIcMouseCode_Button3; deviceInput.analogValue = 1.0f; LIrActionBuffer_Add(outAction, &deviceInput); } - + if (mouse_data.rgbButtons[3] == 0x80) { deviceInput.input = LIcMouseCode_Button4; deviceInput.analogValue = 1.0f; LIrActionBuffer_Add(outAction, &deviceInput); } - + deviceInput.input = LIcMouseCode_XAxis; deviceInput.analogValue = (float)UUmPin((mouse_data.lX << 1), UUcMinInt32, UUcMaxInt32) / 8.0f; @@ -813,7 +813,7 @@ LIiPlatform_Keyboard_Callback( { HRESULT result; LPDIRECTINPUTDEVICE temp_device; - + // create the device result = IDirectInput_CreateDevice( @@ -826,7 +826,7 @@ LIiPlatform_Keyboard_Callback( UUrError_Report(UUcError_Generic, LIiGetDIErrorMsg(result)); return DIENUM_STOP; } - + // set the data format result = IDirectInputDevice_SetDataFormat(temp_device, &c_dfDIKeyboard); if (result != DI_OK) @@ -834,7 +834,7 @@ LIiPlatform_Keyboard_Callback( UUrError_Report(UUcError_Generic, LIiGetDIErrorMsg(result)); return DIENUM_STOP; } - + // set the cooperative level result = IDirectInputDevice_SetCooperativeLevel( @@ -847,10 +847,10 @@ LIiPlatform_Keyboard_Callback( UUrError_Report(UUcError_Generic, LIiGetDIErrorMsg(result)); return DIENUM_STOP; } - + // set the device global LIgKeyboard = temp_device; - + // no more return DIENUM_STOP; } @@ -865,13 +865,13 @@ LIiPlatform_Keyboard_GetData_DirectInput( char *keys) { HRESULT result; - + // set the device state result= IDirectInputDevice_GetDeviceState(LIgKeyboard, 256, keys); if (result != DI_OK) { if (result == DIERR_INPUTLOST) - { + { LIiPlatform_Acquire(); result= IDirectInputDevice_GetDeviceState(LIgKeyboard, 256, keys); } @@ -880,7 +880,7 @@ LIiPlatform_Keyboard_GetData_DirectInput( LIiGetDIErrorMsg(result); } } - + return (result == DI_OK); } @@ -890,14 +890,14 @@ LIiPlatform_Keyboard_GetData_Win32( char *keys) { UUtUns16 i; - + for (i = 0; i < 256; i++) { - if (LIgVKKeyboardTranslation[i] != LIcKeyCode_None) + if (LIgVKKeyboardTranslation[i] != LIcKeyCode_None) { keys[i] = GetAsyncKeyState(i) >> 8; } - else + else { keys[i] = 0; } @@ -915,7 +915,7 @@ LIiPlatform_Keyboard_GetData( char keys[256]; UUtUns16 i; const UUtUns8 *translation; - + // get the data if (LIgUseDirectInput) { @@ -928,18 +928,18 @@ LIiPlatform_Keyboard_GetData( translation = LIgVKKeyboardTranslation; } if (got_data == UUcFalse) return; - + // interpret the data for (i = 0; i < 256; i++) { if (keys[i] & 0x80) { LItDeviceInput deviceInput; - + deviceInput.input = translation[i]; deviceInput.analogValue = 1.0f; - - if (deviceInput.input != LIcKeyCode_None) + + if (deviceInput.input != LIcKeyCode_None) { LIrActionBuffer_Add(outAction, &deviceInput); } @@ -962,7 +962,7 @@ LIiPlatform_Devices_Initialize( void) { HRESULT result; - + // enumerate the mouse result = IDirectInput_EnumDevices( @@ -975,7 +975,7 @@ LIiPlatform_Devices_Initialize( { UUmError_ReturnOnErrorMsg(UUcError_Generic, LIiGetDIErrorMsg(result)); } - + // enumerate the keyboard result = IDirectInput_EnumDevices( @@ -988,7 +988,7 @@ LIiPlatform_Devices_Initialize( { UUmError_ReturnOnErrorMsg(UUcError_Generic, LIiGetDIErrorMsg(result)); } - + return UUcError_None; } @@ -1006,7 +1006,7 @@ LIiPlatform_Devices_GetData( { LIiPlatform_Mouse_GetData(outAction); } - + // get the keyboard data LIiPlatform_Keyboard_GetData(outAction); } @@ -1025,7 +1025,7 @@ LIiPlatform_Devices_Terminate( { IDirectInputDevice_Release(LIgMouse); } - + // release the keyboard if (LIgKeyboard) { @@ -1045,9 +1045,9 @@ LIrPlatform_InputEvent_InterpretModifiers( UUtUns32 inModifiers) { UUtUns32 outModifiers; - + outModifiers = 0; - + switch (inEventType) { case LIcInputEvent_MouseMove: @@ -1066,7 +1066,7 @@ LIrPlatform_InputEvent_InterpretModifiers( if (inModifiers & MK_LBUTTON) outModifiers |= LIcMouseState_LButtonDown; break; - + case LIcInputEvent_KeyUp: case LIcInputEvent_KeyDown: case LIcInputEvent_KeyRepeat: @@ -1078,8 +1078,8 @@ LIrPlatform_InputEvent_InterpretModifiers( outModifiers |= LIcKeyState_AltDown; break; } - - + + return outModifiers; } @@ -1100,7 +1100,7 @@ LIrPlatform_InputEvent_GetMouse( { BOOL status; POINT mouse_position; - + // get the current position of the cursor status = GetCursorPos(&mouse_position); if (status) @@ -1136,7 +1136,7 @@ LIrPlatform_Mode_Set( { RECT window_rect; - + // set the cursor center position based on the rect of the window being used if (GetWindowRect(LIgWindow, &window_rect)) { @@ -1166,10 +1166,10 @@ LIrPlatform_Initialize( UUtError error; HRESULT result; OSVERSIONINFO info; - + UUmAssert(inInstance); UUmAssert(inWindow); - + // ------------------------------ // initialize the globals // ------------------------------ @@ -1179,7 +1179,7 @@ LIrPlatform_Initialize( LIgCenter.y = 0; LIgWindow = inWindow; LIgSetCursorPosThisFrame = UUcFalse; - + // find out which OS the game is running under info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx(&info)) @@ -1209,7 +1209,7 @@ LIrPlatform_Initialize( UUcError_Generic, "DirectInputCreate failed."); } - + // initialize the devices error = LIiPlatform_Devices_Initialize(); UUmError_ReturnOnError(error); @@ -1221,7 +1221,7 @@ LIrPlatform_Initialize( #if THE_DAY_IS_MINE error = SLrGlobalVariable_Register_Bool("li_center_cursor", "Should we center the cursor", &LIgSetCursorPosEver); - UUmError_ReturnOnErrorMsg(error, "Unable to create a new console variable."); + UUmError_ReturnOnErrorMsg(error, "Unable to create a new console variable."); #endif // @@ -1239,7 +1239,7 @@ LIrPlatform_Initialize( LIgDIKeyboardTranslation_Reverse[LIgDIKeyboardTranslation[i]]= (UUtUns8)i; } } - + return UUcError_None; } @@ -1253,12 +1253,12 @@ LIrPlatform_PollInputForAction( LItAction *outAction) { UUtUns16 i; - + // clear the action outAction->buttonBits = 0; for (i = 0; i < LIcNumAnalogValues; i++) outAction->analogValues[i] = 0.0f; - + // get the action data LIiPlatform_Devices_GetData(outAction); } @@ -1274,10 +1274,10 @@ LIrPlatform_Terminate( { // unacquire the devices LIiPlatform_Unacquire(); - + // terminate the devices LIiPlatform_Devices_Terminate(); - + // stop Direct Input if (LIgDirectInput) { @@ -1293,7 +1293,7 @@ LIrPlatform_Update( { BOOL was_event; UUtUns16 itr = LIcPlatform_MaxRetries; - + // check the windows message queue LIcPlatform_MaxRetries times do { @@ -1315,7 +1315,7 @@ LIrPlatform_Update( } } while (--itr); - + return was_event; } diff --git a/BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_Win32/BFW_LI_Platform_Win32.h b/BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_Win32/BFW_LI_Platform_Win32.h index 9b357aa..ea7fd9a 100644 --- a/BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_Win32/BFW_LI_Platform_Win32.h +++ b/BungieFrameWork/BFW_Source/BFW_LocalInput/Platform_Win32/BFW_LI_Platform_Win32.h @@ -10,6 +10,6 @@ UUtUns32 LIrPlatform_Win32_TranslateVirtualKey( UUtUns32 inVirtualKey); - + // ====================================================================== #endif /* BFW_LI_PLATFORM_WIN32 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Materials/BFW_Materials.c b/BungieFrameWork/BFW_Source/BFW_Materials/BFW_Materials.c index fa93e64..794a6d7 100644 --- a/BungieFrameWork/BFW_Source/BFW_Materials/BFW_Materials.c +++ b/BungieFrameWork/BFW_Source/BFW_Materials/BFW_Materials.c @@ -46,12 +46,12 @@ MArImpactType_GetByName( { UUtError error; MAtImpact *impact; - + UUmAssert(inImpactTypeName); - + error = TMrInstance_GetDataPtr(MAcTemplate_Impact, inImpactTypeName, &impact); if (error != UUcError_None) { return MAcInvalidID; } - + return impact->id; } @@ -101,7 +101,7 @@ MArImpactType_GetParent( if (parent == NULL) { return MAcInvalidID; } - + UUmAssertReadPtr(parent, sizeof(MAtImpact)); UUmAssert((parent->id >= 0) && (parent->id < MAgNumImpacts)); @@ -139,12 +139,12 @@ MArMaterialType_GetByName( { UUtError error; MAtMaterial *material; - + UUmAssert(inMaterialTypeName); - + error = TMrInstance_GetDataPtr(MAcTemplate_Material, inMaterialTypeName, &material); if (error != UUcError_None) { return MAcInvalidID; } - + return material->id; } @@ -215,9 +215,9 @@ MAiImpacts_ProcHandler( void *inPrivateData) { MAtImpact *impact; - + impact = (MAtImpact*)inInstancePtr; - + switch (inMessage) { case TMcTemplateProcMessage_LoadPostProcess: @@ -226,7 +226,7 @@ MAiImpacts_ProcHandler( } break; } - + return UUcError_None; } @@ -238,9 +238,9 @@ MAiMaterials_ProcHandler( void *inPrivateData) { MAtMaterial *material; - + material = (MAtMaterial*)inInstancePtr; - + switch (inMessage) { case TMcTemplateProcMessage_LoadPostProcess: @@ -249,7 +249,7 @@ MAiMaterials_ProcHandler( } break; } - + return UUcError_None; } @@ -280,14 +280,14 @@ MArMaterials_Initialize( void) { UUtError error; - + // initialize the globals MAgNumImpacts = 0; MAgImpactArray = NULL; - + MAgNumMaterials = 0; MAgMaterialArray = NULL; - + error = MArMaterials_RegisterTemplates(); UUmError_ReturnOnError(error); @@ -299,7 +299,7 @@ MArMaterials_Initialize( MAiMaterials_ProcHandler, &MAgMaterials_PrivateData); UUmError_ReturnOnError(error); - + error = TMrTemplate_PrivateData_New( MAcTemplate_Impact, @@ -317,13 +317,13 @@ MArMaterials_RegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register(MAcTemplate_Material, sizeof(MAtMaterial), TMcFolding_Forbid); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(MAcTemplate_Impact, sizeof(MAtImpact), TMcFolding_Forbid); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -416,7 +416,7 @@ MArImpacts_PreProcess( for (itr = 0; itr < num_impacts; itr++) { error = TMrInstance_GetDataPtr_ByNumber(MAcTemplate_Impact, itr, &impact); UUmError_ReturnOnError(error); - + impact->id = MAcInvalidID; } @@ -451,7 +451,7 @@ MArImpacts_PreProcess( } } else { UUmAssertReadPtr(parent, sizeof(MAtImpact)); - + if (parent->id == MAcInvalidID) { // we can't add the impact because its parent has not yet been added. continue; @@ -513,7 +513,7 @@ MArImpacts_PreProcess( for (itr = 0; itr < num_impacts; itr++) { error = TMrInstance_GetDataPtr_ByNumber(MAcTemplate_Impact, itr, &impact); UUmError_ReturnOnError(error); - + if (impact->id == MAcInvalidID) { UUrDebuggerMessage(" - %s (parent %s)\n", TMrInstance_GetInstanceName(impact), (impact->parent == NULL) ? "None" : TMrInstance_GetInstanceName(impact->parent)); @@ -532,7 +532,7 @@ MArImpacts_PreProcess( UUmAssert(traverse_id == MAgNumImpacts); UUrMemory_Block_Delete(impact_array); - + return UUcError_None; } @@ -615,7 +615,7 @@ MArMaterials_PreProcess( for (itr = 0; itr < num_materials; itr++) { error = TMrInstance_GetDataPtr_ByNumber(MAcTemplate_Material, itr, &material); UUmError_ReturnOnError(error); - + material->id = MAcInvalidID; } @@ -650,7 +650,7 @@ MArMaterials_PreProcess( } } else { UUmAssertReadPtr(parent, sizeof(MAtMaterial)); - + if (parent->id == MAcInvalidID) { // we can't add the material because its parent has not yet been added. continue; @@ -712,7 +712,7 @@ MArMaterials_PreProcess( for (itr = 0; itr < num_materials; itr++) { error = TMrInstance_GetDataPtr_ByNumber(MAcTemplate_Material, itr, &material); UUmError_ReturnOnError(error); - + if (material->id == MAcInvalidID) { UUrDebuggerMessage(" - %s (parent %s)\n", TMrInstance_GetInstanceName(material), (material->parent == NULL) ? "None" : TMrInstance_GetInstanceName(material->parent)); @@ -732,7 +732,7 @@ MArMaterials_PreProcess( UUmAssert(traverse_id == MAgNumMaterials); UUrMemory_Block_Delete(material_array); - + return UUcError_None; } @@ -749,7 +749,7 @@ UUtBool MArMaterial_IsDescendant(MAtMaterialType inDescendant, MAtMaterialType i for(material_itr = inDescendant; material_itr != MAcInvalidID; material_itr = MArMaterialType_GetParent(material_itr)) { - if (material_itr == inMaterial) { + if (material_itr == inMaterial) { is_descendant = UUcTrue; break; } diff --git a/BungieFrameWork/BFW_Source/BFW_MathLib/BFW_MathLib.c b/BungieFrameWork/BFW_Source/BFW_MathLib/BFW_MathLib.c index 1479832..a2689a4 100644 --- a/BungieFrameWork/BFW_Source/BFW_MathLib/BFW_MathLib.c +++ b/BungieFrameWork/BFW_Source/BFW_MathLib/BFW_MathLib.c @@ -1,12 +1,12 @@ /* FILE: BFW_Math.c - + AUTHOR: Michael Evans - + CREATED: January 9, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -78,10 +78,10 @@ static void MUrRandomMatrix(M3tMatrix4x3 *outMatrix) x = UUmLocalRandomRange(0, 10000) * M3c2Pi * 0.00001f; // S.S. / 10000.f; y = UUmLocalRandomRange(0, 10000) * M3c2Pi * 0.00001f; // S.S. / 10000.f; z = UUmLocalRandomRange(0, 10000) * M3c2Pi * 0.00001f; // S.S. / 10000.f; - - MUrMatrix_RotateX(outMatrix, x); - MUrMatrix_RotateY(outMatrix, y); - MUrMatrix_RotateZ(outMatrix, z); + + MUrMatrix_RotateX(outMatrix, x); + MUrMatrix_RotateY(outMatrix, y); + MUrMatrix_RotateZ(outMatrix, z); return; } @@ -98,7 +98,7 @@ static void MUrRandomVector(M3tVector3D *ioVector) ioVector->x = x; ioVector->y = y; ioVector->z = z; - + return; } @@ -128,7 +128,7 @@ static void MUrTest(void) float x = 0.5f; float y = 1.0f; float z = 1.5f; - + M3tMatrix4x3 matA, matB; MUtEuler eulA, eulB; M3tQuaternion quatA, quatB; @@ -142,9 +142,9 @@ static void MUrTest(void) MUrEulerToMatrix(&eulA, &matA); MUrMatrix_Identity(&matB); - MUrMatrix_RotateX(&matB, x); - MUrMatrix_RotateY(&matB, y); - MUrMatrix_RotateZ(&matB, z); + MUrMatrix_RotateX(&matB, x); + MUrMatrix_RotateY(&matB, y); + MUrMatrix_RotateZ(&matB, z); UUmAssert(MUrMatrix_IsEqual(&matA, &matB)); @@ -188,7 +188,7 @@ static void MUrTest(void) r1 = a; r2 = a; MUrRandomVector(&vec); - + time1 -= UUrMachineTime_High(); // old time1 += UUrMachineTime_High(); @@ -198,7 +198,7 @@ static void MUrTest(void) time2 += UUrMachineTime_High(); - if (!MUrMatrix_IsEqual(&r1, &r2)) { + if (!MUrMatrix_IsEqual(&r1, &r2)) { UUrDebuggerMessage("failure"); } } @@ -260,7 +260,7 @@ void MUrLineSegment_ComputePoint( M3tPoint3D *outPoint) { M3tPoint3D P2MinusP1; - + P2MinusP1.x = inLineP2->x - inLineP1->x; P2MinusP1.y = inLineP2->y - inLineP1->y; P2MinusP1.z = inLineP2->z - inLineP1->z; @@ -280,7 +280,7 @@ void MUrLineSegment_ClosestPointToPoint( { // Returns closest point on line to point float u = MUrLineSegment_ClosestPoint(inLineP1,inLineP2,inPoint); - + if (u<0.0f) *outClosestPoint = *inLineP1; else if (u>1.0f) *outClosestPoint = *inLineP2; else MUrLineSegment_ComputePoint(inLineP1,inLineP2,u,outClosestPoint); @@ -321,7 +321,7 @@ float MUrTan(float f) float MUrATan2(float x, float y) { float atan2_result = (float) atan2(x, y); - + return atan2_result; } @@ -371,30 +371,30 @@ float MUrPoint_ManhattanLength(M3tPoint3D *inPoint) UUtBool MUrPoint_PointOnPlaneSloppy(M3tPoint3D *inPoint, M3tPlaneEquation *inPlane) { // Returns whether the point is roughly in the plane - + if(UUmFloat_CompareEquSloppy( inPlane->a * inPoint->x + - inPlane->b * inPoint->y + + inPlane->b * inPoint->y + inPlane->c * inPoint->z + inPlane->d, 0.0f)) - + return UUcTrue; - + return UUcFalse; } UUtBool MUrPoint_PointBehindPlaneSloppy(M3tPoint3D *inPoint, M3tPlaneEquation *inPlane) { // Returns whether the point is roughly behind the plane - + if(UUmFloat_CompareLTSloppy( inPlane->a * inPoint->x + - inPlane->b * inPoint->y + + inPlane->b * inPoint->y + inPlane->c * inPoint->z + inPlane->d,0.0f)) - + return UUcTrue; - + return UUcFalse; } @@ -402,45 +402,45 @@ UUtBool MUrPoint_PointBehindPlaneSloppy(M3tPoint3D *inPoint, M3tPlaneEquation *i UUtBool MUrPoint_PointOnPlane(M3tPoint3D *inPoint, M3tPlaneEquation *inPlane) { // Returns whether the point is in the plane - + if(UUmFloat_CompareEqu( inPlane->a * inPoint->x + - inPlane->b * inPoint->y + + inPlane->b * inPoint->y + inPlane->c * inPoint->z + inPlane->d, 0.0f)) - + return UUcTrue; - + return UUcFalse; } UUtBool MUrPoint_PointBehindPlane(M3tPoint3D *inPoint, M3tPlaneEquation *inPlane) { // Returns whether the point is behind the plane - + if(UUmFloat_CompareLT( inPlane->a * inPoint->x + - inPlane->b * inPoint->y + + inPlane->b * inPoint->y + inPlane->c * inPoint->z + inPlane->d,0.0f)) - + return UUcTrue; - + return UUcFalse; } UUtBool MUrPoint_PointOnOrBehindPlane(M3tPoint3D *inPoint, M3tPlaneEquation *inPlane) { // Returns whether the point is behind or in the plane - + if(UUmFloat_CompareLE( inPlane->a * inPoint->x + - inPlane->b * inPoint->y + + inPlane->b * inPoint->y + inPlane->c * inPoint->z + inPlane->d, 0.0f)) - + return UUcTrue; - + return UUcFalse; } @@ -448,10 +448,10 @@ void MUrVector_Increment_Unique(M3tVector3D *inDest, M3tVector3D *inSrc, M3tVect { // Increments dest by src if src doesn't already exist in the list // defined by 'inList' and 'inCount'. inSrc is added to that list afterwards. - + UUtUns16 c; M3tVector3D *curV; - + for (c=0; c<*inCount; c++) { curV = &inList[c]; @@ -477,19 +477,19 @@ void MUrVector_ProjectToPlane( { // Projects 'inVector' into the plane float distance; - + UUmAssertReadPtr(inPlaneEqu, sizeof(M3tPlaneEquation)); UUmAssertReadPtr(inVector, sizeof(M3tVector3D)); UUmAssertWritePtr(outVector, sizeof(M3tVector3D)); distance = MUrSqrt(UUmSQR(inPlaneEqu->a) + UUmSQR(inPlaneEqu->b) + UUmSQR(inPlaneEqu->c)); UUmAssert((distance >= 0.95f) && (distance <= 1.05f)); - - distance = - (inPlaneEqu->a * inVector->x) + - (inPlaneEqu->b * inVector->y) + + + distance = + (inPlaneEqu->a * inVector->x) + + (inPlaneEqu->b * inVector->y) + (inPlaneEqu->c * inVector->z); - + outVector->x = inVector->x - (distance * inPlaneEqu->a); outVector->y = inVector->y - (distance * inPlaneEqu->b); outVector->z = inVector->z - (distance * inPlaneEqu->c); @@ -512,14 +512,14 @@ void MUrPoint_RotateAboutAxis( M3tPoint3D *outPoint) { M3tMatrix4x3 matrix; - + MUrMatrix_BuildRotate( inRadians, inVector->x, inVector->y, inVector->z, &matrix); - + MUrMatrix_MultiplyPoint( inPoint, &matrix, @@ -576,8 +576,8 @@ void MUrPoint_RotateYAxis(const M3tPoint3D *inPoint, float inRadians, M3tPoint3D inZ = inPoint->z; radians = M3c2Pi - radians; - if (radians > M3c2Pi) { - radians -= M3c2Pi; + if (radians > M3c2Pi) { + radians -= M3c2Pi; } radians2 = radians + M3cHalfPi; @@ -637,12 +637,12 @@ MUrPoint_Align( M3tPoint3D *outPoint) { M3tMatrix4x3 matrix; - + MUrMatrix_Alignment( inFrom, inTo, &matrix); - + MUrMatrix_MultiplyPoint( outPoint, &matrix, @@ -655,7 +655,7 @@ MUrPoint_Align( void MUrNormalize(M3tVector3D *ioVector) { /* Normalizes 'ioVector' */ - + float oneOverLength; float length; @@ -667,7 +667,7 @@ void MUrNormalize(M3tVector3D *ioVector) { ioVector->x *= 1e20f; ioVector->y *= 1e20f; - ioVector->z *= 1e20f; + ioVector->z *= 1e20f; length = MUmVector_GetLength(*ioVector); } @@ -714,17 +714,17 @@ float MUrPointsXYAngle(float inFromX, float inFromY, float inToX, float inToY) float MUrAngleBetweenVectors(float inAx, float inAy, float inBx, float inBy) { /* Returns angle between A and B in radians */ - + float dot,absA,absB,denom; float result; float dotOverDenom; - + dot = inAx*inBx + inAy*inBy; absA = MUrSqrt(inAx*inAx + inAy*inAy); absB = MUrSqrt(inBx*inBx + inBy*inBy); denom = absA * absB; dotOverDenom = dot / denom; - + UUmAssert((denom > 0) && (denom < 1e9) && (denom > -1e9)); UUmAssert((dot < 1e9) && (dot > -1e9)); UUmAssert(denom != 0); @@ -734,13 +734,13 @@ float MUrAngleBetweenVectors(float inAx, float inAy, float inBx, float inBy) UUmAssert(dotOverDenom < 1.1f); // valid range of acos is 0..1 - dotOverDenom = UUmPin(dotOverDenom, -1.f, 1.f); + dotOverDenom = UUmPin(dotOverDenom, -1.f, 1.f); result = (float) MUrACos(dotOverDenom); UUmAssert(result >= 0); UUmAssert(result <= M3cPi); - + return result; } @@ -765,13 +765,13 @@ UUtBool MUrPoint_Distance_LessOrEqual(const M3tPoint3D *inA, const M3tPoint3D *i float MUrPoint_Distance_Squared(const M3tPoint3D *inA, const M3tPoint3D *inB) { /* Returns the distance between 'A' and 'B' */ - + M3tPoint3D delta; float distanceSquared; UUmAssertReadPtr(inA, sizeof(M3tPoint3D)); UUmAssertReadPtr(inB, sizeof(M3tPoint3D)); - + delta.x = inB->x - inA->x; delta.y = inB->y - inA->y; delta.z = inB->z - inA->z; @@ -784,13 +784,13 @@ float MUrPoint_Distance_Squared(const M3tPoint3D *inA, const M3tPoint3D *inB) float MUrPoint_Distance_SquaredXZ(const M3tPoint3D *inA, const M3tPoint3D *inB) { /* Returns the distance between 'A' and 'B' in the XZ plane */ - + M3tPoint3D delta; float distanceSquared; UUmAssertReadPtr(inA, sizeof(M3tPoint3D)); UUmAssertReadPtr(inB, sizeof(M3tPoint3D)); - + delta.x = inB->x - inA->x; delta.z = inB->z - inA->z; @@ -802,13 +802,13 @@ float MUrPoint_Distance_SquaredXZ(const M3tPoint3D *inA, const M3tPoint3D *inB) float MUrPoint_Distance(const M3tPoint3D *inA, const M3tPoint3D *inB) { /* Returns the distance between 'A' and 'B' */ - + M3tPoint3D delta; float distance; UUmAssertReadPtr(inA, sizeof(M3tPoint3D)); UUmAssertReadPtr(inB, sizeof(M3tPoint3D)); - + delta.x = inB->x - inA->x; delta.y = inB->y - inA->y; delta.z = inB->z - inA->z; @@ -821,13 +821,13 @@ float MUrPoint_Distance(const M3tPoint3D *inA, const M3tPoint3D *inB) float MUrPoint_ManhattanDistance(const M3tPoint3D *inA, const M3tPoint3D *inB) { /* Returns the distance between 'A' and 'B' */ - + M3tPoint3D delta; float distance; UUmAssertReadPtr(inA, sizeof(M3tPoint3D)); UUmAssertReadPtr(inB, sizeof(M3tPoint3D)); - + delta.x = inB->x - inA->x; delta.y = inB->y - inA->y; delta.z = inB->z - inA->z; @@ -840,13 +840,13 @@ float MUrPoint_ManhattanDistance(const M3tPoint3D *inA, const M3tPoint3D *inB) float MUrPoint_ManhattanDistanceXZ(const M3tPoint3D *inA, const M3tPoint3D *inB) { /* Returns the distance between 'A' and 'B' in the XZ plane */ - + M3tPoint3D delta; float distance; UUmAssertReadPtr(inA, sizeof(M3tPoint3D)); UUmAssertReadPtr(inB, sizeof(M3tPoint3D)); - + delta.x = inB->x - inA->x; delta.y = 0; delta.z = inB->z - inA->z; @@ -863,16 +863,16 @@ float MUrPoint_ManhattanDistanceToQuad( { // Returns the average of the manhattan distances from the point to // each vertex of the quad - + float accum = 0.0; UUtUns16 c; - + for (c=0; c<4; c++) { accum += MUrPoint_ManhattanDistance((const M3tPoint3D *)inPoint,(const M3tPoint3D *) (&inPointArray[inQuad->indices[c]])); } - + return accum/4.0f; } @@ -883,16 +883,16 @@ float MUrPoint_DistanceToQuad( { // Returns the average of the manhattan distances from the point to // each vertex of the quad - + float accum = 0.0; UUtUns16 c; - + for (c=0; c<4; c++) { accum += MUrPoint_Distance((const M3tPoint3D *)inPoint,(const M3tPoint3D *) (&inPointArray[inQuad->indices[c]])); } - + return accum/4.0f; } @@ -926,7 +926,7 @@ MUrAngleLess180( { UUmAssert(!"doh!"); } - + return UUcFalse; } @@ -985,7 +985,7 @@ void MUrXYZEulerToQuat(float x, float y, float z, M3tQuaternion *quat) Comments: remember: roll - rotation around X axis pitch - rotation around Y axis yaw - rotation around Z axis - + rotations are performed in the following order: yaw(z) -> pitch(y) -> roll(x) @@ -1003,7 +1003,7 @@ void MUrZYXEulerToQuat(float x, float y, float z, M3tQuaternion *quat) sr = MUrSin(x/2); sp = MUrSin(y/2); sy = MUrSin(z/2); - + cpcy = cp * cy; spsy = sp * sy; @@ -1019,7 +1019,7 @@ void MUrZYXEulerToQuat(float x, float y, float z, M3tQuaternion *quat) Name: MUrQuat_Slerp - Action: Smoothly (spherically, shortest path on a quaternion sphere) + Action: Smoothly (spherically, shortest path on a quaternion sphere) interpolates between two UNIT quaternion positions Params: GLQUAT (first and second quaternion), float (interpolation @@ -1033,7 +1033,7 @@ void MUrZYXEulerToQuat(float x, float y, float z, M3tQuaternion *quat) slerp(p,q,t) = (p*sin((1-t)*omega) + q*sin(t*omega)) / sin(omega) ***********************************************************************EDOC*/ -void MUrQuat_Slerp(const M3tQuaternion * from, const M3tQuaternion * to, float t, +void MUrQuat_Slerp(const M3tQuaternion * from, const M3tQuaternion * to, float t, M3tQuaternion * res) { float to1[4]; @@ -1070,7 +1070,7 @@ void MUrQuat_Slerp(const M3tQuaternion * from, const M3tQuaternion * to, float t // calculate coefficients - if ( (1.0 - cosom) > MUcQuatDelta ) + if ( (1.0 - cosom) > MUcQuatDelta ) { // standard case (slerp) omega = MUrACos(cosom); @@ -1078,8 +1078,8 @@ void MUrQuat_Slerp(const M3tQuaternion * from, const M3tQuaternion * to, float t scale0 = MUrSin((1.f - t) * omega) / sinom; scale1 = MUrSin(t * omega) / sinom; - } else { - // "from" and "to" quaternions are very close + } else { + // "from" and "to" quaternions are very close // ... so we can do a linear interpolation scale0 = 1.f - t; @@ -1182,7 +1182,7 @@ void MUrQuat_Normalize(M3tQuaternion *quat) square = quat->x * quat->x + quat->y * quat->y + quat->z * quat->z + quat->w * quat->w; - + if (square > 0.0) { dist = MUrOneOverSqrt(square); @@ -1220,7 +1220,7 @@ void MUrQuat_Normalize(M3tQuaternion *quat) NOTE2: angle is in RADIANS ***********************************************************************EDOC*/ -void MUrQuat_GetValue(M3tQuaternion *quat, float *x, float *y, +void MUrQuat_GetValue(M3tQuaternion *quat, float *x, float *y, float *z, float *radians) { float len; @@ -1233,7 +1233,7 @@ void MUrQuat_GetValue(M3tQuaternion *quat, float *x, float *y, len = tx * tx + ty * ty + tz * tz; - if (len > MUcQuatDelta) + if (len > MUcQuatDelta) { *x = tx * (1.f / len); *y = ty * (1.f / len); @@ -1276,7 +1276,7 @@ void MUrQuat_SetValue(M3tQuaternion *quat, float x, float y, float z, float angl // normalize temp = x*x + y*y + z*z; - dist = (float)(MUrOneOverSqrt(temp)) * theSin; + dist = (float)(MUrOneOverSqrt(temp)) * theSin; x *= dist; y *= dist; @@ -1359,7 +1359,7 @@ void MUrQuat_SetFromTwoVectors(const M3tVector3D *inFrom, const M3tVector3D *inT MUmVector_Normalize(from); MUmVector_Normalize(to); - + MUrQuat_SetFromAx(from.x, from.y, from.z, to.x, to.y, to.z, outQuat); return; @@ -1369,7 +1369,7 @@ void MUrQuat_SetFromTwoVectors(const M3tVector3D *inFrom, const M3tVector3D *inT Name: MUrQuat_SetFromAx - Action: Constructs quaternion to rotate from one direction vector to + Action: Constructs quaternion to rotate from one direction vector to another Params: fromX, fromY, fromZ - fromVector @@ -1381,7 +1381,7 @@ void MUrQuat_SetFromTwoVectors(const M3tVector3D *inFrom, const M3tVector3D *inT them before calling this function Some parts are heavily optimized so readability is not so great :( ***********************************************************************EDOC*/ -void MUrQuat_SetFromAx(float fromX,float fromY, float fromZ, +void MUrQuat_SetFromAx(float fromX,float fromY, float fromZ, float toX,float toY, float toZ, M3tQuaternion *outQuat) { @@ -1426,7 +1426,7 @@ void MUrQuat_SetFromAx(float fromX,float fromY, float fromZ, tx *= dist; ty *= dist; tz *= dist; - + outQuat->x = tx; outQuat->y = ty; outQuat->z = tz; @@ -1449,7 +1449,7 @@ void MUrQuat_SetFromAx(float fromX,float fromY, float fromZ, // we have to use half-angle formulae (sin^2 t = ( 1 - cos (2t) ) /2) - + ss = MUrSqrt(0.5f * (1.0f - cost)); tx *= ss; @@ -1615,7 +1615,7 @@ void MUrQuat_Div(const M3tQuaternion* q1, const M3tQuaternion* q2, M3tQuaternion q.x = -q.x; q.y = -q.y; q.z = -q.z; - + MUrQuat_Mul(q1, &q, &r); MUrQuat_Mul(&q, &q, &s); @@ -1704,8 +1704,8 @@ void MUrQuat_Sqrt(const M3tQuaternion* q1, M3tQuaternion* res) M3tQuaternion r; length = MUrSqrt (q1->w * q1->w + q1->x * q1->x + q1->y * q1->y); - if (length != 0.0) - length = 1.0f / length; + if (length != 0.0) + length = 1.0f / length; else length = 1.0f; r.x = q1->x * length; @@ -1773,7 +1773,7 @@ float MUrQuat_Length(M3tQuaternion* q1) Returns: nothing - Comments: Source quaternion does NOT have to be normalized + Comments: Source quaternion does NOT have to be normalized ***********************************************************************EDOC*/ void MUrQuat_Negate(M3tQuaternion* q1, M3tQuaternion* q2) @@ -1804,9 +1804,9 @@ void MUrQuat_Exp(M3tQuaternion* q1, M3tQuaternion* q2) float len1, len2; len1 = (float) MUrSqrt (q1->x * q1->x + q1->y * q1->y + q1->z * q1->z); - if (len1 > 0.0) - len2 = (float)sin(len1) / len1; - else + if (len1 > 0.0) + len2 = (float)sin(len1) / len1; + else len2 = 1.0; q2->x = q1->x * len2; @@ -1836,8 +1836,8 @@ void MUrQuat_Log(M3tQuaternion* q1, M3tQuaternion* q2) length = MUrSqrt (q1->x * q1->x + q1->y * q1->y + q1->z * q1->z); //make sure we do not divide by 0 - if (q1->w != 0.0) - length = MUrATan (length / q1->w); + if (q1->w != 0.0) + length = MUrATan (length / q1->w); else length = M3cHalfPi; q2->w = 0.0f; @@ -1884,15 +1884,15 @@ MUrQuatToMatrix( outMatrix->m[2][2] = 1.f - (xx + yy); outMatrix->m[3][0] = 0; - outMatrix->m[3][1] = 0; + outMatrix->m[3][1] = 0; outMatrix->m[3][2] = 0; return; } void MUrMatrix_MultiplyPoint( - const M3tPoint3D *inPoint, - const M3tMatrix4x3 *inMatrix, + const M3tPoint3D *inPoint, + const M3tMatrix4x3 *inMatrix, M3tPoint3D *outPoint) { float iX = inPoint->x; @@ -1907,8 +1907,8 @@ void MUrMatrix_MultiplyPoint( } void MUrMatrix3x3_MultiplyPoint( - const M3tPoint3D *inPoint, - const M3tMatrix3x3 *inMatrix, + const M3tPoint3D *inPoint, + const M3tMatrix3x3 *inMatrix, M3tPoint3D *outPoint) { float iX = inPoint->x; @@ -1923,8 +1923,8 @@ void MUrMatrix3x3_MultiplyPoint( } void MUrMatrix3x3_TransposeMultiplyPoint( - const M3tPoint3D *inPoint, - const M3tMatrix3x3 *inMatrix, + const M3tPoint3D *inPoint, + const M3tMatrix3x3 *inMatrix, M3tPoint3D *outPoint) { float iX = inPoint->x; @@ -1939,13 +1939,13 @@ void MUrMatrix3x3_TransposeMultiplyPoint( } void MUrMatrix_MultiplyNormal( - const M3tVector3D *inNormal, - const M3tMatrix4x3 *inMatrix, + const M3tVector3D *inNormal, + const M3tMatrix4x3 *inMatrix, M3tVector3D *outNormal) { float iX; float iY; - float iZ; + float iZ; UUmAssertReadPtr(inNormal, sizeof(*inNormal)); UUmAssertReadPtr(inMatrix, sizeof(*inMatrix)); @@ -1965,13 +1965,13 @@ void MUrMatrix_MultiplyNormal( } void MUrMatrix3x3_MultiplyNormal( - const M3tVector3D *inNormal, - const M3tMatrix3x3 *inMatrix, + const M3tVector3D *inNormal, + const M3tMatrix3x3 *inMatrix, M3tVector3D *outNormal) { float iX; float iY; - float iZ; + float iZ; UUmAssertReadPtr(inNormal, sizeof(*inNormal)); UUmAssertReadPtr(inMatrix, sizeof(*inMatrix)); @@ -2022,8 +2022,8 @@ void MUrMatrix3x3_MultiplyNormals( void MUrMatrix_MultiplyPoints( UUtUns32 inNumPoints, - const M3tMatrix4x3 *inMatrix, - const M3tPoint3D *inPoints, + const M3tMatrix4x3 *inMatrix, + const M3tPoint3D *inPoints, M3tPoint3D *outPoints) { UUtUns32 itr; @@ -2064,7 +2064,7 @@ MUrVector_DotProduct( UUmAssert(NULL != inVectorA); UUmAssert(NULL != inVectorB); - + result = inVectorA->x * inVectorB->x + inVectorA->y * inVectorB->y + inVectorA->z * inVectorB->z; return result; @@ -2086,7 +2086,7 @@ MUrVector_NormalFromPoints( UUmAssert(NULL != inPoint1); UUmAssert(NULL != inPoint2); UUmAssert(NULL != outNormal); - + vector01.x = inPoint1->x - inPoint0->x; vector01.y = inPoint1->y - inPoint0->y; vector01.z = inPoint1->z - inPoint0->z; @@ -2094,12 +2094,12 @@ MUrVector_NormalFromPoints( vector02.x = inPoint2->x - inPoint0->x; vector02.y = inPoint2->y - inPoint0->y; vector02.z = inPoint2->z - inPoint0->z; - + MUrVector_CrossProduct( &vector01, &vector02, outNormal); - + length = outNormal->x * outNormal->x + outNormal->y * outNormal->y + outNormal->z * outNormal->z; if (length==0.0f) { @@ -2109,7 +2109,7 @@ MUrVector_NormalFromPoints( return; } - + length = MUrOneOverSqrt(length); outNormal->x *= length; // Negatives here account for counterclockwise point ordering @@ -2132,13 +2132,13 @@ void MUrVector_PlaneFromEdges( // of the plane is computed with the SECOND edge. This can be // significant of the two edges are not intersecting. M3tVector3D vecA,vecB,normal; - + // Determine the normal of the plane of the two lines of the collision MUmVector_Subtract(vecA,*inEdge1a,*inEdge1b); MUmVector_Subtract(vecB,*inEdge2b,*inEdge2a); MUrVector_CrossProduct(&vecA,&vecB,&normal); MUrNormalize(&normal); - + // Now extract the plane equation at the point of impact outPlane->a = normal.x; outPlane->b = normal.y; @@ -2153,9 +2153,9 @@ void MUrVector_SetLength(M3tVector3D *ioVector, float inNewMagnitude) * Adjusts 'ioVector' so that its magnitude is 'm', * but leaves its direction unchanged */ - + float oldLength, scaleAmt; - + oldLength = MUrVector_Length(ioVector); scaleAmt = inNewMagnitude / oldLength; MUmVector_Scale(*ioVector, scaleAmt); @@ -2164,8 +2164,8 @@ void MUrVector_SetLength(M3tVector3D *ioVector, float inNewMagnitude) } void MUrVector_PushBack( - M3tVector3D *outPushBack, - const M3tVector3D *inDelta, + M3tVector3D *outPushBack, + const M3tVector3D *inDelta, const M3tVector3D *inNormal) { #if 0 @@ -2180,7 +2180,7 @@ void MUrVector_PushBack( *outPushBack = projection; if (UUmFloat_CompareEquSloppy(inDelta->x,outPushBack->x)) outPushBack->x = inDelta->x; - if (UUmFloat_CompareEquSloppy(inDelta->y,outPushBack->y)) outPushBack->y = inDelta->y; + if (UUmFloat_CompareEquSloppy(inDelta->y,outPushBack->y)) outPushBack->y = inDelta->y; if (UUmFloat_CompareEquSloppy(inDelta->z,outPushBack->z)) outPushBack->z = inDelta->z; /* if ((inDelta->x < 0 && -outPushBack->x < inDelta->x) || @@ -2224,7 +2224,7 @@ void MUrVector_PushBack( pushBackAlignmentSpace.x = inDeltaAlignmentSpace.x; pushBackAlignmentSpace.y = 0; pushBackAlignmentSpace.z = 0; - + //if (pushBackAlignmentSpace.x > -0.01f) pushBackAlignmentSpace.x = -0.01f; MUrMatrix_MultiplyPoints(1, &inverseAlignmentMatrix, &pushBackAlignmentSpace, outPushBack); } @@ -2235,7 +2235,7 @@ void MUrVector_PushBack( } //if (UUmFloat_CompareEquSloppy(inDelta->x,outPushBack->x)) outPushBack->x = inDelta->x; - //if (UUmFloat_CompareEquSloppy(inDelta->y,outPushBack->y)) outPushBack->y = inDelta->y; + //if (UUmFloat_CompareEquSloppy(inDelta->y,outPushBack->y)) outPushBack->y = inDelta->y; //if (UUmFloat_CompareEquSloppy(inDelta->z,outPushBack->z)) outPushBack->z = inDelta->z; #else float pushback_dot; @@ -2259,13 +2259,13 @@ void MUrVector_ProjectVector(M3tVector3D *inA, M3tVector3D *inB, M3tVector3D *ou /****************** * Projects A on to B */ - + float magsquared,dotovermagsq; - + magsquared = MUrVector_Length(inB); magsquared *= magsquared; UUmAssert(magsquared); - + *outV = *inB; dotovermagsq = MUrVector_DotProduct(inA,inB)/magsquared; MUmVector_Scale(*outV,dotovermagsq); @@ -2277,38 +2277,38 @@ MUrTriangle_Area( M3tPoint3D* inPoint1, M3tPoint3D* inPoint2) { - + float length01, temp, height; M3tPoint3D closestPointOn01; - + length01 = inPoint1->x - inPoint0->x; length01 *= length01; - + temp = inPoint1->y - inPoint0->y; length01 += temp * temp; - + temp = inPoint1->z - inPoint0->z; length01 += temp * temp; - + length01 = MUrSqrt(length01); - + MUrLineSegment_ClosestPointToPoint( inPoint0, inPoint1, inPoint2, &closestPointOn01); - + height = closestPointOn01.x - inPoint2->x; height *= height; - + temp = closestPointOn01.y - inPoint2->y; height += temp * temp; - + temp = closestPointOn01.z - inPoint2->z; height += temp * temp; - + height = MUrSqrt(height); - + return length01 * height * 0.5f; } @@ -2327,11 +2327,11 @@ float MUrAngleBetweenVectors3D(const M3tVector3D *inVector1, const M3tVector3D * UUmAssert((dotProduct > -1.1f) && (dotProduct < 1.1f)); // valid range of acos is strictly 0..1 - dotProduct = UUmPin(dotProduct, -1.f, 1.f); + dotProduct = UUmPin(dotProduct, -1.f, 1.f); result = MUrACos(dotProduct); UUmAssertTrigRange(result); - + return result; } @@ -2343,37 +2343,37 @@ float MUrAngleBetweenVectors3D_0To2Pi(const M3tVector3D *inVector1, const M3tVec M3tVector3D alignedV2; M3tVector3D upX; M3tMatrix4x3 alignUpXMatrix; - + UUmAssert(MUmVector_IsNormalized(*inVector1)); UUmAssert(MUmVector_IsNormalized(*inVector2)); - + upX.x = 1.0f; upX.y = 0.0f; upX.z = 0.0f; - + MUrMatrix_Alignment( inVector1, &upX, &alignUpXMatrix); - + MUrMatrix_MultiplyPoint( (const M3tPoint3D*)inVector2, &alignUpXMatrix, (M3tPoint3D*)&alignedV2); - + dotProduct = MUrVector_DotProduct(&upX, &alignedV2); // never should be to far off UUmAssert((dotProduct > -1.1f) && (dotProduct < 1.1f)); // valid range of acos is strictly 0..1 - dotProduct = UUmPin(dotProduct, -1.f, 1.f); + dotProduct = UUmPin(dotProduct, -1.f, 1.f); result = MUrACos(dotProduct); UUmAssertTrigRange(result); - + if(alignedV2.y < 0.0f) result = M3cPi * 2.0f - result; - + return result; } @@ -2381,18 +2381,18 @@ float MUrAngleBetweenVectors3D_0To2Pi(const M3tVector3D *inVector1, const M3tVec float MUrACos(float inFloat) { float result; - + UUmAssert((inFloat >= -1.f) && (inFloat <= 1.f)); - + result = (float) acos(inFloat); - + #if UUmCompiler == UUmCompiler_MWerks result = UUmPin(result, 0, M3cPi); UUmAssert((result >= 0) && (result <= M3cPi)); #else UUmAssert((result >= 0) && (result <= M3cPi)); #endif - + return result; } @@ -2409,13 +2409,13 @@ float MUrASin(float inFloat) void MUrMinMaxBBox_CreateFromSphere( const M3tMatrix4x3 *inMatrix, - const M3tBoundingSphere *inSphere, + const M3tBoundingSphere *inSphere, M3tBoundingBox_MinMax *outBBox) { M3tPoint3D center; UUmAssertWritePtr(outBBox, sizeof(*outBBox)); - + if (NULL == inMatrix) { center = inSphere->center; @@ -2428,7 +2428,7 @@ void MUrMinMaxBBox_CreateFromSphere( outBBox->minPoint.x = center.x - inSphere->radius; outBBox->maxPoint.x = center.x + inSphere->radius; - + outBBox->minPoint.y = center.y - inSphere->radius; outBBox->maxPoint.y = center.y + inSphere->radius; @@ -2441,7 +2441,7 @@ void MUrMinMaxBBox_CreateFromSphere( void MUrMinMaxBBox_ExpandBySphere( const M3tMatrix4x3 *inMatrix, - const M3tBoundingSphere *inSphere, + const M3tBoundingSphere *inSphere, M3tBoundingBox_MinMax *outBBox) { M3tPoint3D center; @@ -2465,7 +2465,7 @@ void MUrMinMaxBBox_ExpandBySphere( outBBox->minPoint.z = UUmMin(center.z - inSphere->radius, outBBox->minPoint.z); outBBox->maxPoint.z = UUmMax(center.z + inSphere->radius, outBBox->maxPoint.z); - + return; } @@ -2482,16 +2482,16 @@ void MUrMinMaxBBox_To_Sphere( outSphere->center.y = inBBox->minPoint.y + (inBBox->maxPoint.y - inBBox->minPoint.y) / 2; outSphere->center.z = inBBox->minPoint.z + (inBBox->maxPoint.z - inBBox->minPoint.z) / 2; - outSphere->radius = (cLargerThanRoot2 * 0.5f /* S.S. / 2.f*/) * - UUmMax3(inBBox->maxPoint.x - inBBox->minPoint.x, - inBBox->maxPoint.y - inBBox->minPoint.y, + outSphere->radius = (cLargerThanRoot2 * 0.5f /* S.S. / 2.f*/) * + UUmMax3(inBBox->maxPoint.x - inBBox->minPoint.x, + inBBox->maxPoint.y - inBBox->minPoint.y, inBBox->maxPoint.z - inBBox->minPoint.z); return; } void MUrCylinder_CreateFromSphere( const M3tMatrix4x3 *inMatrix, - const M3tBoundingSphere *inSphere, + const M3tBoundingSphere *inSphere, M3tBoundingCylinder *outCylinder) { M3tPoint3D center; @@ -2499,7 +2499,7 @@ void MUrCylinder_CreateFromSphere( UUmAssertReadPtr(inMatrix, sizeof(*inMatrix)); UUmAssertReadPtr(inSphere, sizeof(*inSphere)); UUmAssertWritePtr(outCylinder, sizeof(*outCylinder)); - + MUrMatrix_MultiplyPoints(1, inMatrix, &inSphere->center, ¢er); outCylinder->circle.center.x = center.x; @@ -2563,7 +2563,7 @@ static float MUrLineSegment2D_ExpandByPoint(float cur_distance_squared, M3tPoint } else { *l1 = *newPoint; - + return l2_new_distance_squared; } } @@ -2631,7 +2631,7 @@ static void MUrCircle_ExpandByCircle(M3tBoundingCircle *ioCircleA, const M3tBoun void MUrCylinder_ExpandBySphere( const M3tMatrix4x3 *inMatrix, - const M3tBoundingSphere *inSphere, + const M3tBoundingSphere *inSphere, M3tBoundingCylinder *ioCylinder) { M3tPoint3D center; @@ -2640,14 +2640,14 @@ void MUrCylinder_ExpandBySphere( UUmAssertReadPtr(inMatrix, sizeof(*inMatrix)); UUmAssertReadPtr(inSphere, sizeof(*inSphere)); UUmAssertWritePtr(ioCylinder, sizeof(*ioCylinder)); - + MUrMatrix_MultiplyPoints(1, inMatrix, &inSphere->center, ¢er); // step 1 grow top and bottom ioCylinder->top = UUmMax(center.y + inSphere->radius, ioCylinder->top); ioCylinder->bottom = UUmMin(center.y - inSphere->radius, ioCylinder->bottom); - // step 2 grow radius & move center + // step 2 grow radius & move center // draw line segment from center of one 2-d circle to the other // grow segment to hit the edges of each circle. @@ -2675,7 +2675,7 @@ UUtUns8 MUrSolveQuadratic(float a, float b, float c, float *outSolutions) } else { float one_over_two_a = 0.5f / a; - + if (UUmFloat_CompareEqu(discriminant, 0)) { outSolutions[0] = -b * one_over_two_a; @@ -2804,7 +2804,7 @@ UUtBool MUrQuat_IsEqual( equal = MUrQuat_IsEqual_Internal(&inverseA, inQuatB); } - + return equal; } @@ -2840,7 +2840,7 @@ UUtInt32 MUrFloat_Round_To_Int(float inFloatNumber) UUtInt32 integerNumber; // #define MUrFloat_Round_To_Int(x) (((x) < 0.0) ? (float)((UUtInt32)(x - 0.5)) : (float)((UUtInt32)(x + 0.5))) - if (inFloatNumber < 0) + if (inFloatNumber < 0) { integerNumber = inFloatNumber - 0.5f; } @@ -2919,70 +2919,70 @@ MUrPointVector_FlipAboutPlane( float refl_vec_x, refl_vec_y, refl_vec_z; float temp; float t; - + plane_a = inPlane->a; plane_b = inPlane->b; plane_c = inPlane->c; plane_d = inPlane->d; - + vec_x = inVector->x; vec_y = inVector->y; vec_z = inVector->z; - + point_x = inPoint->x; point_y = inPoint->y; point_z = inPoint->z; - + // compute reflection point dist_point_to_plane = plane_a * point_x + plane_b * point_y + plane_c * point_z + plane_d; - + refl_point_x = point_x - dist_point_to_plane * plane_a * 2.0f; refl_point_y = point_y - dist_point_to_plane * plane_b * 2.0f; refl_point_z = point_z - dist_point_to_plane * plane_c * 2.0f; - + // compute intersection point denom = plane_a * vec_x + plane_b * vec_y + plane_c * vec_z; - + if(denom == 0.0f) { *outReflectedPoint = *inPoint; *outReflectedVector = *inVector; return; } - + t = -(plane_a * point_x + plane_b * point_y + plane_c * point_z + plane_d) / denom; - + inter_point_x = vec_x * t + point_x; inter_point_y = vec_y * t + point_y; inter_point_z = vec_z * t + point_z; - + #if 0 // compute reflection vector which is V - N(2(N.V)) temp = 2.0f * denom; refl_vec_x = vec_x - plane_a * temp; refl_vec_y = vec_y - plane_b * temp; refl_vec_z = vec_z - plane_c * temp; - + #else refl_vec_x = inter_point_x - refl_point_x; refl_vec_y = inter_point_y - refl_point_y; refl_vec_z = inter_point_z - refl_point_z; - + temp = MUrOneOverSqrt(refl_vec_x * refl_vec_x + refl_vec_y * refl_vec_y + refl_vec_z * refl_vec_z); - + refl_vec_x *= temp; refl_vec_y *= temp; refl_vec_z *= temp; #endif - + outReflectedPoint->x = refl_point_x; outReflectedPoint->y = refl_point_y; outReflectedPoint->z = refl_point_z; - + outReflectedVector->x = refl_vec_x; outReflectedVector->y = refl_vec_y; outReflectedVector->z = refl_vec_z; - + } /* these used to be inlined */ @@ -3031,7 +3031,7 @@ UUtUns32 MUrUnsignedSmallFloat_To_Uns_Round(float f) UUmAssert((f >= 0) && (f < UUcFloat_NormalizedBit)); f += UUcFloat_NormalizedBit; - + number.float_4byte = f; return number.unsigned_4byte & UUcFloat_FractionMask; @@ -3140,4 +3140,4 @@ void MUrMatrix3x3_FormOrthonormalBasis(M3tVector3D *inX, M3tVector3D *inY, M3tVe outMatrix->m[2][2] = inZ->z; return; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_MathLib/BFW_MathLib_Matrix.c b/BungieFrameWork/BFW_Source/BFW_MathLib/BFW_MathLib_Matrix.c index 61d1a1e..3cad450 100644 --- a/BungieFrameWork/BFW_Source/BFW_MathLib/BFW_MathLib_Matrix.c +++ b/BungieFrameWork/BFW_Source/BFW_MathLib/BFW_MathLib_Matrix.c @@ -1,12 +1,12 @@ /* FILE: BFW_Math.c - + AUTHOR: Michael Evans - + CREATED: January 9, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -20,10 +20,10 @@ #include "EulerAngles.h" #include "Decompose.h" -const M3tMatrix4x3 MUgIdentityMatrix = +const M3tMatrix4x3 MUgIdentityMatrix = { 1, 0, 0, - 0, 1, 0, - 0, 0, 1, + 0, 1, 0, + 0, 0, 1, 0, 0, 0 }; void MUrMatrixToQuat(const M3tMatrix4x3 *inMatrix, M3tQuaternion *outQuat) @@ -39,33 +39,33 @@ void MUrMatrixToQuat(const M3tMatrix4x3 *inMatrix, M3tQuaternion *outQuat) // check the diagonal - if (tr > 0.0) + if (tr > 0.0) { s = MUrSqrt (tr + 1.f); outQuat->w = s * 0.5f; // S.S. / 2.f; - + s = 0.5f / s; outQuat->x = (inMatrix->m[2][1] - inMatrix->m[1][2]) * s; outQuat->y = (inMatrix->m[0][2] - inMatrix->m[2][0]) * s; outQuat->z = (inMatrix->m[1][0] - inMatrix->m[0][1]) * s; - } - else { - + } + else { + // diagonal is negative - + i = 0; if (inMatrix->m[1][1] > inMatrix->m[0][0]) i = 1; if (inMatrix->m[2][2] > inMatrix->m[i][i]) i = 2; - + j = nxt[i]; k = nxt[j]; s = MUrSqrt ((inMatrix->m[i][i] - (inMatrix->m[j][j] + inMatrix->m[k][k])) + 1.f); - + q[i] = s * 0.5f; if (s != 0.0) s = 0.5f / s; @@ -105,17 +105,17 @@ void MUrMatrix_GetCol(const M3tMatrix4x3 *inMatrix, UUtUns8 inCol, M3tPoint3D *o } void MUrMatrix_Multiply( - const M3tMatrix4x3 *inMatrixA, - const M3tMatrix4x3 *inMatrixB, + const M3tMatrix4x3 *inMatrixA, + const M3tMatrix4x3 *inMatrixB, M3tMatrix4x3 *outResult) { float a00, a10, a20, a30; float a01, a11, a21, a31; float a02, a12, a22, a32; - + float b0, b1, b2; float d0, d1, d2; - + a00 = inMatrixA->m[0][0]; a01 = inMatrixA->m[0][1]; a02 = inMatrixA->m[0][2]; @@ -131,68 +131,68 @@ void MUrMatrix_Multiply( a30 = inMatrixA->m[3][0]; a31 = inMatrixA->m[3][1]; a32 = inMatrixA->m[3][2]; - + b0 = inMatrixB->m[0][0]; b1 = inMatrixB->m[0][1]; b2 = inMatrixB->m[0][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2; d1 = a01 * b0 + a11 * b1 + a21 * b2; d2 = a02 * b0 + a12 * b1 + a22 * b2; - + outResult->m[0][0] = d0; outResult->m[0][1] = d1; outResult->m[0][2] = d2; - + b0 = inMatrixB->m[1][0]; b1 = inMatrixB->m[1][1]; b2 = inMatrixB->m[1][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2; d1 = a01 * b0 + a11 * b1 + a21 * b2; d2 = a02 * b0 + a12 * b1 + a22 * b2; - + outResult->m[1][0] = d0; outResult->m[1][1] = d1; outResult->m[1][2] = d2; - + b0 = inMatrixB->m[2][0]; b1 = inMatrixB->m[2][1]; b2 = inMatrixB->m[2][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2; d1 = a01 * b0 + a11 * b1 + a21 * b2; d2 = a02 * b0 + a12 * b1 + a22 * b2; - + outResult->m[2][0] = d0; outResult->m[2][1] = d1; outResult->m[2][2] = d2; - + b0 = inMatrixB->m[3][0]; b1 = inMatrixB->m[3][1]; b2 = inMatrixB->m[3][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2 + a30; d1 = a01 * b0 + a11 * b1 + a21 * b2 + a31; d2 = a02 * b0 + a12 * b1 + a22 * b2 + a32; - + outResult->m[3][0] = d0; outResult->m[3][1] = d1; outResult->m[3][2] = d2; } void MUrMatrix3x3_Multiply( - const M3tMatrix3x3 *inMatrixA, - const M3tMatrix3x3 *inMatrixB, + const M3tMatrix3x3 *inMatrixA, + const M3tMatrix3x3 *inMatrixB, M3tMatrix3x3 *outResult) { float a00, a10, a20; float a01, a11, a21; float a02, a12, a22; - + float b0, b1, b2; float d0, d1, d2; - + a00 = inMatrixA->m[0][0]; a01 = inMatrixA->m[0][1]; a02 = inMatrixA->m[0][2]; @@ -204,46 +204,46 @@ void MUrMatrix3x3_Multiply( a20 = inMatrixA->m[2][0]; a21 = inMatrixA->m[2][1]; a22 = inMatrixA->m[2][2]; - + b0 = inMatrixB->m[0][0]; b1 = inMatrixB->m[0][1]; b2 = inMatrixB->m[0][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2; d1 = a01 * b0 + a11 * b1 + a21 * b2; d2 = a02 * b0 + a12 * b1 + a22 * b2; - + outResult->m[0][0] = d0; outResult->m[0][1] = d1; outResult->m[0][2] = d2; - + b0 = inMatrixB->m[1][0]; b1 = inMatrixB->m[1][1]; b2 = inMatrixB->m[1][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2; d1 = a01 * b0 + a11 * b1 + a21 * b2; d2 = a02 * b0 + a12 * b1 + a22 * b2; - + outResult->m[1][0] = d0; outResult->m[1][1] = d1; outResult->m[1][2] = d2; - + b0 = inMatrixB->m[2][0]; b1 = inMatrixB->m[2][1]; b2 = inMatrixB->m[2][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2; d1 = a01 * b0 + a11 * b1 + a21 * b2; d2 = a02 * b0 + a12 * b1 + a22 * b2; - + outResult->m[2][0] = d0; outResult->m[2][1] = d1; outResult->m[2][2] = d2; } void MUrMatrix3x3_Transpose( - const M3tMatrix3x3 *inMatrix, + const M3tMatrix3x3 *inMatrix, M3tMatrix3x3 *outResult) { outResult->m[0][0] = inMatrix->m[0][0]; @@ -267,15 +267,15 @@ void MUrMatrix3x3_Transpose( result.m[0][0] = inA->m[0][0] * inB->m[0][0] + inA->m[1][0] * inB->m[0][1] + inA->m[2][0] * inB->m[0][2]; result.m[0][1] = inA->m[0][1] * inB->m[0][0] + inA->m[1][1] * inB->m[0][1] + inA->m[2][1] * inB->m[0][2]; result.m[0][2] = inA->m[0][2] * inB->m[0][0] + inA->m[1][2] * inB->m[0][1] + inA->m[2][2] * inB->m[0][2]; - + result.m[1][0] = inA->m[0][0] * inB->m[1][0] + inA->m[1][0] * inB->m[1][1] + inA->m[2][0] * inB->m[1][2]; result.m[1][1] = inA->m[0][1] * inB->m[1][0] + inA->m[1][1] * inB->m[1][1] + inA->m[2][1] * inB->m[1][2]; result.m[1][2] = inA->m[0][2] * inB->m[1][0] + inA->m[1][2] * inB->m[1][1] + inA->m[2][2] * inB->m[1][2]; - + result.m[2][0] = inA->m[0][0] * inB->m[2][0] + inA->m[1][0] * inB->m[2][1] + inA->m[2][0] * inB->m[2][2]; result.m[2][1] = inA->m[0][1] * inB->m[2][0] + inA->m[1][1] * inB->m[2][1] + inA->m[2][1] * inB->m[2][2]; result.m[2][2] = inA->m[0][2] * inB->m[2][0] + inA->m[1][2] * inB->m[2][1] + inA->m[2][2] * inB->m[2][2]; - + result.m[3][0] = inA->m[0][0] * inB->m[3][0] + inA->m[1][0] * inB->m[3][1] + inA->m[2][0] * inB->m[3][2] + inA->m[3][0]; result.m[3][1] = inA->m[0][1] * inB->m[3][0] + inA->m[1][1] * inB->m[3][1] + inA->m[2][1] * inB->m[3][2] + inA->m[3][1]; result.m[3][2] = inA->m[0][2] * inB->m[3][0] + inA->m[1][2] * inB->m[3][1] + inA->m[2][2] * inB->m[3][2] + inA->m[3][2]; @@ -295,22 +295,22 @@ MUrMatrix_BuildRotateX( float s; UUmAssert(NULL != outMatrix); - + c = MUrCos(inRadians); s = MUrSin(inRadians); outMatrix->m[0][0] = 1.f; outMatrix->m[0][1] = 0; outMatrix->m[0][2] = 0; - + outMatrix->m[1][0] = 0; outMatrix->m[1][1] = c; outMatrix->m[1][2] = s; - + outMatrix->m[2][0] = 0; outMatrix->m[2][1] = -s; outMatrix->m[2][2] = c; - + outMatrix->m[3][0] = 0.0f; outMatrix->m[3][1] = 0.0f; outMatrix->m[3][2] = 0.0f; @@ -339,22 +339,22 @@ MUrMatrix_BuildRotateY( float s; UUmAssert(NULL != outMatrix); - + c = MUrCos(inRadians); s = MUrSin(inRadians); outMatrix->m[0][0] = c; outMatrix->m[0][1] = 0; outMatrix->m[0][2] = -s; - + outMatrix->m[1][0] = 0; outMatrix->m[1][1] = 1; outMatrix->m[1][2] = 0; - + outMatrix->m[2][0] = s; outMatrix->m[2][1] = 0; outMatrix->m[2][2] = c; - + outMatrix->m[3][0] = 0.0f; outMatrix->m[3][1] = 0.0f; outMatrix->m[3][2] = 0.0f; @@ -374,22 +374,22 @@ MUrMatrix_BuildRotateZ( float s; UUmAssert(NULL != outMatrix); - + c = MUrCos(inRadians); s = MUrSin(inRadians); outMatrix->m[0][0] = c; outMatrix->m[0][1] = s; outMatrix->m[0][2] = 0; - + outMatrix->m[1][0] = -s; outMatrix->m[1][1] = c; outMatrix->m[1][2] = 0; - + outMatrix->m[2][0] = 0; outMatrix->m[2][1] = 0; outMatrix->m[2][2] = 1; - + outMatrix->m[3][0] = 0.0f; outMatrix->m[3][1] = 0.0f; outMatrix->m[3][2] = 0.0f; @@ -404,18 +404,18 @@ MUrMatrix3x3_BuildRotateX( float s; UUmAssert(NULL != outMatrix); - + c = MUrCos(inRadians); s = MUrSin(inRadians); outMatrix->m[0][0] = 1.f; outMatrix->m[0][1] = 0; outMatrix->m[0][2] = 0; - + outMatrix->m[1][0] = 0; outMatrix->m[1][1] = c; outMatrix->m[1][2] = s; - + outMatrix->m[2][0] = 0; outMatrix->m[2][1] = -s; outMatrix->m[2][2] = c; @@ -434,18 +434,18 @@ MUrMatrix3x3_BuildRotateY( float s; UUmAssert(NULL != outMatrix); - + c = MUrCos(inRadians); s = MUrSin(inRadians); outMatrix->m[0][0] = c; outMatrix->m[0][1] = 0; outMatrix->m[0][2] = -s; - + outMatrix->m[1][0] = 0; outMatrix->m[1][1] = 1; outMatrix->m[1][2] = 0; - + outMatrix->m[2][0] = s; outMatrix->m[2][1] = 0; outMatrix->m[2][2] = c; @@ -465,18 +465,18 @@ MUrMatrix3x3_BuildRotateZ( float s; UUmAssert(NULL != outMatrix); - + c = MUrCos(inRadians); s = MUrSin(inRadians); outMatrix->m[0][0] = c; outMatrix->m[0][1] = s; outMatrix->m[0][2] = 0; - + outMatrix->m[1][0] = -s; outMatrix->m[1][1] = c; outMatrix->m[1][2] = 0; - + outMatrix->m[2][0] = 0; outMatrix->m[2][1] = 0; outMatrix->m[2][2] = 1; @@ -494,18 +494,18 @@ MUrMatrix3x3_BuildRotate( float s; UUmAssert(NULL != outMatrix); - + c = MUrCos(inRadians); s = MUrSin(inRadians); outMatrix->m[0][0] = inX * inX * (1 - c) + c; outMatrix->m[0][1] = inY * inX * (1 - c) + inZ * s; outMatrix->m[0][2] = inX * inZ * (1 - c) - inY * s; - + outMatrix->m[1][0] = inX * inY * (1 - c) - inZ * s; outMatrix->m[1][1] = inY * inY * (1 - c) + c; outMatrix->m[1][2] = inY * inZ * (1 - c) + inX * s; - + outMatrix->m[2][0] = inX * inZ * (1 - c) + inY * s; outMatrix->m[2][1] = inY * inZ * (1 - c) - inX * s; outMatrix->m[2][2] = inZ * inZ * (1 - c) + c; @@ -523,22 +523,22 @@ MUrMatrix_BuildRotate( float s; UUmAssert(NULL != outMatrix); - + c = MUrCos(inRadians); s = MUrSin(inRadians); outMatrix->m[0][0] = inX * inX * (1 - c) + c; outMatrix->m[0][1] = inY * inX * (1 - c) + inZ * s; outMatrix->m[0][2] = inX * inZ * (1 - c) - inY * s; - + outMatrix->m[1][0] = inX * inY * (1 - c) - inZ * s; outMatrix->m[1][1] = inY * inY * (1 - c) + c; outMatrix->m[1][2] = inY * inZ * (1 - c) + inX * s; - + outMatrix->m[2][0] = inX * inZ * (1 - c) + inY * s; outMatrix->m[2][1] = inY * inZ * (1 - c) - inX * s; outMatrix->m[2][2] = inZ * inZ * (1 - c) + c; - + outMatrix->m[3][0] = 0.0f; outMatrix->m[3][1] = 0.0f; outMatrix->m[3][2] = 0.0f; @@ -596,7 +596,7 @@ MUrMatrix_BuildUniformScale( return; } -void +void MUrMatrix_BuildScale( M3tPoint3D *inScale, M3tMatrix4x3 *outMatrix) @@ -650,7 +650,7 @@ void MUrMatrix_Inverse(const M3tMatrix4x3 *inM, M3tMatrix4x3 *outM) MUrMatrix_Adjoint(inM, outM); /* calculate the 4x4 determinant - * if the determinant is zero, + * if the determinant is zero, * then the inverse matrix is not unique. */ @@ -670,9 +670,9 @@ void MUrMatrix_Inverse(const M3tMatrix4x3 *inM, M3tMatrix4x3 *outM) } -/* +/* * MUrMatrix_Adjoint( original_matrix, inverse_matrix ) - * + * * calculate the MUrMatrix_Adjoint of a 4x4 matrix * * Let a denote the minor determinant of matrix A obtained by @@ -696,27 +696,27 @@ void MUrMatrix_Adjoint(const M3tMatrix4x3 *inM, M3tMatrix4x3 *outM) /* assign to individual variable names to aid */ /* selecting correct values */ - a1 = inM->m[0][0]; - b1 = inM->m[0][1]; - c1 = inM->m[0][2]; + a1 = inM->m[0][0]; + b1 = inM->m[0][1]; + c1 = inM->m[0][2]; // d1 = inM->m[0][3]; d1 = 0.f; - a2 = inM->m[1][0]; - b2 = inM->m[1][1]; - c2 = inM->m[1][2]; + a2 = inM->m[1][0]; + b2 = inM->m[1][1]; + c2 = inM->m[1][2]; // d2 = inM->m[1][3]; d2 = 0.f; - a3 = inM->m[2][0]; + a3 = inM->m[2][0]; b3 = inM->m[2][1]; - c3 = inM->m[2][2]; + c3 = inM->m[2][2]; // d3 = inM->m[2][3]; d3 = 0.f; - a4 = inM->m[3][0]; - b4 = inM->m[3][1]; - c4 = inM->m[3][2]; + a4 = inM->m[3][0]; + b4 = inM->m[3][1]; + c4 = inM->m[3][2]; // d4 = inM->m[3][3]; d4 = 1.f; @@ -727,17 +727,17 @@ void MUrMatrix_Adjoint(const M3tMatrix4x3 *inM, M3tMatrix4x3 *outM) outM->m[1][0] = - MUr3x3_Determinant( a2, a3, a4, c2, c3, c4, d2, d3, d4); outM->m[2][0] = MUr3x3_Determinant( a2, a3, a4, b2, b3, b4, d2, d3, d4); outM->m[3][0] = - MUr3x3_Determinant( a2, a3, a4, b2, b3, b4, c2, c3, c4); - + outM->m[0][1] = - MUr3x3_Determinant( b1, b3, b4, c1, c3, c4, d1, d3, d4); outM->m[1][1] = MUr3x3_Determinant( a1, a3, a4, c1, c3, c4, d1, d3, d4); outM->m[2][1] = - MUr3x3_Determinant( a1, a3, a4, b1, b3, b4, d1, d3, d4); outM->m[3][1] = MUr3x3_Determinant( a1, a3, a4, b1, b3, b4, c1, c3, c4); - + outM->m[0][2] = MUr3x3_Determinant( b1, b2, b4, c1, c2, c4, d1, d2, d4); outM->m[1][2] = - MUr3x3_Determinant( a1, a2, a4, c1, c2, c4, d1, d2, d4); outM->m[2][2] = MUr3x3_Determinant( a1, a2, a4, b1, b2, b4, d1, d2, d4); outM->m[3][2] = - MUr3x3_Determinant( a1, a2, a4, b1, b2, b4, c1, c2, c4); - + // outM->m[0][3] = - MUr3x3_Determinant( b1, b2, b3, c1, c2, c3, d1, d2, d3); // outM->m[1][3] = MUr3x3_Determinant( a1, a2, a3, c1, c2, c3, d1, d2, d3); // outM->m[2][3] = - MUr3x3_Determinant( a1, a2, a3, b1, b2, b3, d1, d2, d3); @@ -746,7 +746,7 @@ void MUrMatrix_Adjoint(const M3tMatrix4x3 *inM, M3tMatrix4x3 *outM) /* * float = MUrMatrix_Determinant( matrix ) - * + * * calculate the determinant of a 4x4 matrix. */ float MUrMatrix_Determinant(const M3tMatrix4x3 *inMatrix) @@ -757,27 +757,27 @@ float MUrMatrix_Determinant(const M3tMatrix4x3 *inMatrix) /* assign to individual variable names to aid selecting */ /* correct elements */ - a1 = inMatrix->m[0][0]; - b1 = inMatrix->m[0][1]; - c1 = inMatrix->m[0][2]; + a1 = inMatrix->m[0][0]; + b1 = inMatrix->m[0][1]; + c1 = inMatrix->m[0][2]; // d1 = inMatrix->m[0][3]; d1 = 0.f; - a2 = inMatrix->m[1][0]; - b2 = inMatrix->m[1][1]; - c2 = inMatrix->m[1][2]; + a2 = inMatrix->m[1][0]; + b2 = inMatrix->m[1][1]; + c2 = inMatrix->m[1][2]; //d2 = inMatrix->m[1][3]; d2 = 0.f; - a3 = inMatrix->m[2][0]; - b3 = inMatrix->m[2][1]; - c3 = inMatrix->m[2][2]; + a3 = inMatrix->m[2][0]; + b3 = inMatrix->m[2][1]; + c3 = inMatrix->m[2][2]; //d3 = inMatrix->m[2][3]; d3 = 0.f; - a4 = inMatrix->m[3][0]; - b4 = inMatrix->m[3][1]; - c4 = inMatrix->m[3][2]; + a4 = inMatrix->m[3][0]; + b4 = inMatrix->m[3][1]; + c4 = inMatrix->m[3][2]; //d4 = inMatrix->m[3][3]; d4 = 1.f; @@ -793,7 +793,7 @@ float MUrMatrix_Determinant(const M3tMatrix4x3 *inMatrix) /* * float = MUr3x3_Determinant( a1, a2, a3, b1, b2, b3, c1, c2, c3 ) - * + * * calculate the determinant of a 3x3 matrix * in the form * @@ -814,7 +814,7 @@ float MUr3x3_Determinant(float a1, float a2, float a3, float b1, float b2, float /* * float = MUr2x2_Determinant( float a, float b, float c, float d ) - * + * * calculate the determinant of a 2x2 matrix. */ @@ -891,7 +891,7 @@ void MUrMatrixStack_Translate( float r30 = ioTOS->m[3][0]; float r31 = ioTOS->m[3][1]; float r32 = ioTOS->m[3][2]; - + r30 += r00 * x + r10 * y + r20 * z; r31 += r01 * x + r11 * y + r21 * z; r32 += r02 * x + r12 * y + r22 * z; @@ -944,7 +944,7 @@ void MUrMatrixStack_Quaternion( testEuler = MUrQuatToEuler(&testQuat, MUcEulerOrderXYXs); testQuat = MUrEulerToQuat(&testEuler); MUrXYXsEulerToQuat(testEuler.x, testEuler.y, testEuler.z, &testQuat2); - + UUmAssert(MUrQuat_IsEqual(inQuaternion, &testQuat)); UUmAssert(MUrQuat_IsEqual(&testQuat2, &testQuat)); } @@ -985,15 +985,15 @@ void MUrMatrix_Identity(M3tMatrix4x3 *ioMatrix) ioMatrix->m[0][0] = 1.0f; ioMatrix->m[0][1] = 0.0f; ioMatrix->m[0][2] = 0.0f; - + ioMatrix->m[1][0] = 0.0f; ioMatrix->m[1][1] = 1.0f; ioMatrix->m[1][2] = 0.0f; - + ioMatrix->m[2][0] = 0.0f; ioMatrix->m[2][1] = 0.0f; ioMatrix->m[2][2] = 1.0f; - + ioMatrix->m[3][0] = 0.0f; ioMatrix->m[3][1] = 0.0f; ioMatrix->m[3][2] = 0.0f; @@ -1008,11 +1008,11 @@ void MUrMatrix3x3_Identity(M3tMatrix3x3 *ioMatrix) ioMatrix->m[0][0] = 1.0f; ioMatrix->m[0][1] = 0.0f; ioMatrix->m[0][2] = 0.0f; - + ioMatrix->m[1][0] = 0.0f; ioMatrix->m[1][1] = 1.0f; ioMatrix->m[1][2] = 0.0f; - + ioMatrix->m[2][0] = 0.0f; ioMatrix->m[2][1] = 0.0f; ioMatrix->m[2][2] = 1.0f; @@ -1043,7 +1043,7 @@ void MUrMatrix_Translate( float r30 = ioMatrix->m[3][0]; float r31 = ioMatrix->m[3][1]; float r32 = ioMatrix->m[3][2]; - + r30 += r00 * x + r10 * y + r20 * z; r31 += r01 * x + r11 * y + r21 * z; r32 += r02 * x + r12 * y + r22 * z; @@ -1189,11 +1189,11 @@ void MUrMatrix_DecomposeAffine(const M3tMatrix4x3 *inMatrix, MUtAffineParts *out outParts->translation.x = parts.t.x; outParts->translation.y = parts.t.y; outParts->translation.z = parts.t.z; - + outParts->rotation.x = parts.q.x; outParts->rotation.y = parts.q.y; outParts->rotation.z = parts.q.z; - outParts->rotation.w = -parts.q.w; // shoemake appears to have + outParts->rotation.w = -parts.q.w; // shoemake appears to have outParts->stretchRotation.x = parts.u.x; outParts->stretchRotation.y = parts.u.y; @@ -1212,10 +1212,10 @@ void MUrMatrix_DecomposeAffine(const M3tMatrix4x3 *inMatrix, MUtAffineParts *out void MUrMatrix_To_RotationMatrix(const M3tMatrix4x3 *inMatrix, M3tMatrix4x3 *outMatrix) { MUtAffineParts parts; - + MUrMatrix_DecomposeAffine(inMatrix, &parts); - // rotate + // rotate MUrQuatToMatrix(&parts.rotation, outMatrix); return; @@ -1226,17 +1226,17 @@ void MUrMatrix_StripScale(const M3tMatrix4x3 *inMatrix, M3tMatrix4x3 *outMatrix) MUtAffineParts parts; M3tMatrix4x3 translateTM; M3tMatrix4x3 rotateTM; - + MUrMatrix_DecomposeAffine(inMatrix, &parts); // translate MUrMatrix_BuildTranslate( - parts.translation.x, - parts.translation.y, - parts.translation.z, + parts.translation.x, + parts.translation.y, + parts.translation.z, &translateTM); - // rotate + // rotate MUrQuatToMatrix(&parts.rotation, &rotateTM); // this should just be original matrix @@ -1278,7 +1278,7 @@ void MUrMatrix_To_ScaleMatrix(const M3tMatrix4x3 *inMatrix, M3tMatrix4x3 *outMat M3tMatrix4x3 invRotTM; M3tMatrix4x3 temp; - + MUrMatrix_DecomposeAffine(inMatrix, &parts); MUrQuat_Inverse(&parts.stretchRotation, &invQuat); @@ -1296,12 +1296,12 @@ static UUtBool MUrMatrix_HasNonUniformScale(const M3tMatrix4x3 *inMatrix) { MUtAffineParts parts; UUtBool hasNonUniformScale; - + MUrMatrix_DecomposeAffine(inMatrix, &parts); - hasNonUniformScale = + hasNonUniformScale = (!UUmFloat_CompareEqu(parts.stretch.x, parts.stretch.y)) || - (!UUmFloat_CompareEqu(parts.stretch.x, parts.stretch.z)) || + (!UUmFloat_CompareEqu(parts.stretch.x, parts.stretch.z)) || (!UUmFloat_CompareEqu(parts.stretch.y, parts.stretch.z)); return hasNonUniformScale; @@ -1332,10 +1332,10 @@ MUrMatrix4x3_Multiply3x3( float a00, a10, a20, a30; float a01, a11, a21, a31; float a02, a12, a22, a32; - + float b0, b1, b2; float d0, d1, d2; - + a00 = inMatrix4x3->m[0][0]; a01 = inMatrix4x3->m[0][1]; a02 = inMatrix4x3->m[0][2]; @@ -1351,47 +1351,47 @@ MUrMatrix4x3_Multiply3x3( a30 = inMatrix4x3->m[3][0]; a31 = inMatrix4x3->m[3][1]; a32 = inMatrix4x3->m[3][2]; - + b0 = inMatrix3x3->m[0][0]; b1 = inMatrix3x3->m[0][1]; b2 = inMatrix3x3->m[0][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2; d1 = a01 * b0 + a11 * b1 + a21 * b2; d2 = a02 * b0 + a12 * b1 + a22 * b2; - + outMatrix4x3->m[0][0] = d0; outMatrix4x3->m[0][1] = d1; outMatrix4x3->m[0][2] = d2; - + b0 = inMatrix3x3->m[1][0]; b1 = inMatrix3x3->m[1][1]; b2 = inMatrix3x3->m[1][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2; d1 = a01 * b0 + a11 * b1 + a21 * b2; d2 = a02 * b0 + a12 * b1 + a22 * b2; - + outMatrix4x3->m[1][0] = d0; outMatrix4x3->m[1][1] = d1; outMatrix4x3->m[1][2] = d2; - + b0 = inMatrix3x3->m[2][0]; b1 = inMatrix3x3->m[2][1]; b2 = inMatrix3x3->m[2][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2; d1 = a01 * b0 + a11 * b1 + a21 * b2; d2 = a02 * b0 + a12 * b1 + a22 * b2; - + outMatrix4x3->m[2][0] = d0; outMatrix4x3->m[2][1] = d1; outMatrix4x3->m[2][2] = d2; - + d0 = a30; d1 = a31; d2 = a32; - + outMatrix4x3->m[3][0] = d0; outMatrix4x3->m[3][1] = d1; outMatrix4x3->m[3][2] = d2; @@ -1405,15 +1405,15 @@ MUrMatrix4x3_BuildFrom3x3( outMatrix4x3->m[0][0] = inMatrix3x3->m[0][0]; outMatrix4x3->m[0][1] = inMatrix3x3->m[0][1]; outMatrix4x3->m[0][2] = inMatrix3x3->m[0][2]; - + outMatrix4x3->m[1][0] = inMatrix3x3->m[1][0]; outMatrix4x3->m[1][1] = inMatrix3x3->m[1][1]; outMatrix4x3->m[1][2] = inMatrix3x3->m[1][2]; - + outMatrix4x3->m[2][0] = inMatrix3x3->m[2][0]; outMatrix4x3->m[2][1] = inMatrix3x3->m[2][1]; outMatrix4x3->m[2][2] = inMatrix3x3->m[2][2]; - + outMatrix4x3->m[3][0] = 0.0f; outMatrix4x3->m[3][1] = 0.0f; outMatrix4x3->m[3][2] = 0.0f; @@ -1458,7 +1458,7 @@ void MUrMatrix_DualAlignment( UUmTrig_Clip(angle_delta); MUrMatrix_BuildRotate(angle_delta, dst2->x, dst2->y, dst2->z, &rotate_matrix); - + // ok, we have a 2 stage process, alignment matrix, then rotate matrix MUrMatrix_Multiply(&alignment_matrix1, &rotate_matrix, outMatrix); @@ -1482,10 +1482,10 @@ MUrMath_Matrix4x4Multiply( float a01, a11, a21, a31; float a02, a12, a22, a32; float a03, a13, a23, a33; - + float b0, b1, b2, b3; float d0, d1, d2, d3; - + a00 = inMatrixA->m[0][0]; a01 = inMatrixA->m[0][1]; a02 = inMatrixA->m[0][2]; @@ -1505,62 +1505,62 @@ MUrMath_Matrix4x4Multiply( a31 = inMatrixA->m[3][1]; a32 = inMatrixA->m[3][2]; a33 = inMatrixA->m[3][3]; - + b0 = inMatrixB->m[0][0]; b1 = inMatrixB->m[0][1]; b2 = inMatrixB->m[0][2]; b3 = inMatrixB->m[0][3]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2 + a30 * b3; d1 = a01 * b0 + a11 * b1 + a21 * b2 + a31 * b3; d2 = a02 * b0 + a12 * b1 + a22 * b2 + a32 * b3; d3 = a03 * b0 + a13 * b1 + a23 * b2 + a33 * b3; - + outResult->m[0][0] = d0; outResult->m[0][1] = d1; outResult->m[0][2] = d2; outResult->m[0][3] = d3; - + b0 = inMatrixB->m[1][0]; b1 = inMatrixB->m[1][1]; b2 = inMatrixB->m[1][2]; b3 = inMatrixB->m[1][3]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2 + a30 * b3; d1 = a01 * b0 + a11 * b1 + a21 * b2 + a31 * b3; d2 = a02 * b0 + a12 * b1 + a22 * b2 + a32 * b3; d3 = a03 * b0 + a13 * b1 + a23 * b2 + a33 * b3; - + outResult->m[1][0] = d0; outResult->m[1][1] = d1; outResult->m[1][2] = d2; outResult->m[1][3] = d3; - + b0 = inMatrixB->m[2][0]; b1 = inMatrixB->m[2][1]; b2 = inMatrixB->m[2][2]; b3 = inMatrixB->m[2][3]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2 + a30 * b3; d1 = a01 * b0 + a11 * b1 + a21 * b2 + a31 * b3; d2 = a02 * b0 + a12 * b1 + a22 * b2 + a32 * b3; d3 = a03 * b0 + a13 * b1 + a23 * b2 + a33 * b3; - + outResult->m[2][0] = d0; outResult->m[2][1] = d1; outResult->m[2][2] = d2; outResult->m[2][3] = d3; - + b0 = inMatrixB->m[3][0]; b1 = inMatrixB->m[3][1]; b2 = inMatrixB->m[3][2]; b3 = inMatrixB->m[3][3]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2 + a30 * b3; d1 = a01 * b0 + a11 * b1 + a21 * b2 + a31 * b3; d2 = a02 * b0 + a12 * b1 + a22 * b2 + a32 * b3; d3 = a03 * b0 + a13 * b1 + a23 * b2 + a33 * b3; - + outResult->m[3][0] = d0; outResult->m[3][1] = d1; outResult->m[3][2] = d2; @@ -1577,10 +1577,10 @@ MUrMath_Matrix4x4Multiply4x3( float a01, a11, a21, a31; float a02, a12, a22, a32; float a03, a13, a23, a33; - + float b0, b1, b2; float d0, d1, d2, d3; - + a00 = inMatrixA->m[0][0]; a01 = inMatrixA->m[0][1]; a02 = inMatrixA->m[0][2]; @@ -1600,58 +1600,58 @@ MUrMath_Matrix4x4Multiply4x3( a31 = inMatrixA->m[3][1]; a32 = inMatrixA->m[3][2]; a33 = inMatrixA->m[3][3]; - + b0 = inMatrixB->m[0][0]; b1 = inMatrixB->m[0][1]; b2 = inMatrixB->m[0][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2; d1 = a01 * b0 + a11 * b1 + a21 * b2; d2 = a02 * b0 + a12 * b1 + a22 * b2; d3 = a03 * b0 + a13 * b1 + a23 * b2; - + outResult->m[0][0] = d0; outResult->m[0][1] = d1; outResult->m[0][2] = d2; outResult->m[0][3] = d3; - + b0 = inMatrixB->m[1][0]; b1 = inMatrixB->m[1][1]; b2 = inMatrixB->m[1][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2; d1 = a01 * b0 + a11 * b1 + a21 * b2; d2 = a02 * b0 + a12 * b1 + a22 * b2; d3 = a03 * b0 + a13 * b1 + a23 * b2; - + outResult->m[1][0] = d0; outResult->m[1][1] = d1; outResult->m[1][2] = d2; outResult->m[1][3] = d3; - + b0 = inMatrixB->m[2][0]; b1 = inMatrixB->m[2][1]; b2 = inMatrixB->m[2][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2; d1 = a01 * b0 + a11 * b1 + a21 * b2; d2 = a02 * b0 + a12 * b1 + a22 * b2; d3 = a03 * b0 + a13 * b1 + a23 * b2; - + outResult->m[2][0] = d0; outResult->m[2][1] = d1; outResult->m[2][2] = d2; outResult->m[2][3] = d3; - + b0 = inMatrixB->m[3][0]; b1 = inMatrixB->m[3][1]; b2 = inMatrixB->m[3][2]; - + d0 = a00 * b0 + a10 * b1 + a20 * b2 + a30; d1 = a01 * b0 + a11 * b1 + a21 * b2 + a31; d2 = a02 * b0 + a12 * b1 + a22 * b2 + a32; d3 = a03 * b0 + a13 * b1 + a23 * b2 + a33; - + outResult->m[3][0] = d0; outResult->m[3][1] = d1; outResult->m[3][2] = d2; @@ -1700,12 +1700,12 @@ void MUrMatrix_Lerp(const M3tMatrix4x3 *inFrom, const M3tMatrix4x3 *inTo, float // translate MUrMatrix_BuildTranslate( - lerpParts.translation.x, - lerpParts.translation.y, - lerpParts.translation.z, + lerpParts.translation.x, + lerpParts.translation.y, + lerpParts.translation.z, &translateTM); - // rotate + // rotate MUrQuatToMatrix(&lerpParts.rotation, &rotateTM); // this should just be original matrix @@ -1713,4 +1713,4 @@ void MUrMatrix_Lerp(const M3tMatrix4x3 *inFrom, const M3tMatrix4x3 *inTo, float MUrMatrix_Multiply(&translateTM, &rotateTM, outResult); return; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_MathLib/EulerAngles.c b/BungieFrameWork/BFW_Source/BFW_MathLib/EulerAngles.c index 31c8879..ebfd09f 100644 --- a/BungieFrameWork/BFW_Source/BFW_MathLib/EulerAngles.c +++ b/BungieFrameWork/BFW_Source/BFW_MathLib/EulerAngles.c @@ -32,32 +32,32 @@ M3tQuaternion MUrEulerToQuat(const MUtEuler *inEuler) int i,j,k,h,n,s,f; iEuler_GetOrder(ea.order,i,j,k,h,n,s,f); - if (f==EulFrmR) { - float t = ea.x; - ea.x = ea.z; - ea.z = t; + if (f==EulFrmR) { + float t = ea.x; + ea.x = ea.z; + ea.z = t; } - if (n==EulParOdd) { - ea.y = - ea.y; + if (n==EulParOdd) { + ea.y = - ea.y; UUmTrig_ClipLow(ea.y); } - ti = ea.x * 0.5f; - tj = ea.y * 0.5f; + ti = ea.x * 0.5f; + tj = ea.y * 0.5f; th = ea.z * 0.5f; - ci = MUrCos(ti); - cj = MUrCos(tj); + ci = MUrCos(ti); + cj = MUrCos(tj); ch = MUrCos(th); - si = MUrSin(ti); - sj = MUrSin(tj); + si = MUrSin(ti); + sj = MUrSin(tj); sh = MUrSin(th); - cc = ci*ch; - cs = ci*sh; - sc = si*ch; + cc = ci*ch; + cs = ci*sh; + sc = si*ch; ss = si*sh; if (s==EulRepYes) { @@ -72,12 +72,12 @@ M3tQuaternion MUrEulerToQuat(const MUtEuler *inEuler) qu.w = -(cj*cc + sj*ss); } - if (n==EulParOdd) { + if (n==EulParOdd) { a[j] = -a[j]; } - qu.x = a[0]; - qu.y = a[1]; + qu.x = a[0]; + qu.y = a[1]; qu.z = a[2]; return (qu); @@ -90,21 +90,21 @@ void MUrXYZrEulerToQuat(float inX, float inY, float inZ, M3tQuaternion *outQuat) float si, sj, sh; float cc, cs, sc, ss; - ti = inZ * 0.5f; - tj = M3c2Pi - (inY * 0.5f); + ti = inZ * 0.5f; + tj = M3c2Pi - (inY * 0.5f); th = inX * 0.5f; - ci = MUrCos(ti); - cj = MUrCos(tj); + ci = MUrCos(ti); + cj = MUrCos(tj); ch = MUrCos(th); - si = MUrSin(ti); - sj = MUrSin(tj); + si = MUrSin(ti); + sj = MUrSin(tj); sh = MUrSin(th); - cc = ci*ch; - cs = ci*sh; - sc = si*ch; + cc = ci*ch; + cs = ci*sh; + sc = si*ch; ss = si*sh; outQuat->x = cj*cs - sj*sc; @@ -138,21 +138,21 @@ void MUrXYXsEulerToQuat(float inX, float inY, float inZ, M3tQuaternion *outQuat) float si, sj, sh; float cc, cs, sc, ss; - ti = inX * 0.5f; - tj = inY * 0.5f; + ti = inX * 0.5f; + tj = inY * 0.5f; th = inZ * 0.5f; - ci = MUrCos(ti); - cj = MUrCos(tj); + ci = MUrCos(ti); + cj = MUrCos(tj); ch = MUrCos(th); - si = MUrSin(ti); - sj = MUrSin(tj); + si = MUrSin(ti); + sj = MUrSin(tj); sh = MUrSin(th); - cc = ci * ch; - cs = ci * sh; - sc = si * ch; + cc = ci * ch; + cs = ci * sh; + sc = si * ch; ss = si * sh; outQuat->x = cj * (cs + sc); @@ -198,7 +198,7 @@ void MUrEulerToMatrix(const MUtEuler *inEuler, M3tMatrix4x3 *inMatrix) if (f==EulFrmR) {float t = ea.x; ea.x = ea.z; ea.z = t;} if (n==EulParOdd) { - ea.x = -ea.x; + ea.x = -ea.x; ea.y = -ea.y; ea.z = -ea.z; @@ -216,7 +216,7 @@ void MUrEulerToMatrix(const MUtEuler *inEuler, M3tMatrix4x3 *inMatrix) inMatrix->m[i][i] = cj; inMatrix->m[j][i] = sj*si; inMatrix->m[k][i] = sj*ci; inMatrix->m[i][j] = sj*sh; inMatrix->m[j][j] = -cj*ss+cc; inMatrix->m[k][j] = -cj*cs-sc; inMatrix->m[i][k] = -sj*ch; inMatrix->m[j][k] = cj*sc+cs; inMatrix->m[k][k] = cj*cc-ss; - } + } else { inMatrix->m[i][i] = cj*ch; inMatrix->m[j][i] = sj*sc-cs; inMatrix->m[k][i] = sj*cc+ss; inMatrix->m[i][j] = cj*sh; inMatrix->m[j][j] = sj*ss+cc; inMatrix->m[k][j] = sj*cs-sc; @@ -238,12 +238,12 @@ MUtEuler MUrMatrixToEuler(const M3tMatrix4x3 *inMatrix, int order) if (s==EulRepYes) { float sy = MUrSqrt(UUmSQR(inMatrix->m[j][i]) + UUmSQR(inMatrix->m[k][i])); - if (sy > 16 * EULER_EPSILON) + if (sy > 16 * EULER_EPSILON) { ea.x = MUrATan2(inMatrix->m[j][i], inMatrix->m[k][i]); ea.y = MUrATan2(sy, inMatrix->m[i][i]); ea.z = MUrATan2(inMatrix->m[i][j], -inMatrix->m[i][k]); - } + } else { ea.x = MUrATan2(-inMatrix->m[k][j], inMatrix->m[j][j]); ea.y = MUrATan2(sy, inMatrix->m[i][i]); @@ -257,7 +257,7 @@ MUtEuler MUrMatrixToEuler(const M3tMatrix4x3 *inMatrix, int order) ea.x = MUrATan2(inMatrix->m[j][k], inMatrix->m[k][k]); ea.y = MUrATan2(-inMatrix->m[i][k], cy); ea.z = MUrATan2(inMatrix->m[i][j], inMatrix->m[i][i]); - } + } else { ea.x = MUrATan2(-inMatrix->m[k][j], inMatrix->m[j][j]); ea.y = MUrATan2(-inMatrix->m[i][k], cy); @@ -272,11 +272,11 @@ MUtEuler MUrMatrixToEuler(const M3tMatrix4x3 *inMatrix, int order) } if (f==EulFrmR) { - float t = ea.x; - ea.x = ea.z; + float t = ea.x; + ea.x = ea.z; ea.z = t; } - + UUmTrig_ClipLow(ea.x); UUmTrig_ClipLow(ea.y); UUmTrig_ClipLow(ea.z); diff --git a/BungieFrameWork/BFW_Source/BFW_MathLib/EulerAngles.h b/BungieFrameWork/BFW_Source/BFW_MathLib/EulerAngles.h index 773a66c..41722a7 100644 --- a/BungieFrameWork/BFW_Source/BFW_MathLib/EulerAngles.h +++ b/BungieFrameWork/BFW_Source/BFW_MathLib/EulerAngles.h @@ -7,19 +7,19 @@ #include "BFW_Motoko.h" #include "BFW_MathLib.h" -/*** Order type constants, constructors, extractors -There are 24 possible conventions, designated by: +/*** Order type constants, constructors, extractors +There are 24 possible conventions, designated by: - o EulAxI = axis used initially - o EulPar = parity of axis permutation - o EulRep = repetition of initial axis as last - o EulFrm = frame from which axes are taken + o EulAxI = axis used initially + o EulPar = parity of axis permutation + o EulRep = repetition of initial axis as last + o EulFrm = frame from which axes are taken -Axes I,J,K will be a permutation of X,Y,Z. +Axes I,J,K will be a permutation of X,Y,Z. Axis H will be either I or K, depending on EulRep. -Frame S takes axes from initial static frame. -If ord = (AxI=X, Par=Even, Rep=No, Frm=S), then -{a,b,c,ord} means Rz(c)Ry(b)Rx(a), where Rz(c)v +Frame S takes axes from initial static frame. +If ord = (AxI=X, Par=Even, Rep=No, Frm=S), then +{a,b,c,ord} means Rz(c)Ry(b)Rx(a), where Rz(c)v rotates v around Z by c radians. ****************************************************/ diff --git a/BungieFrameWork/BFW_Source/BFW_MathLib/bfw_math.c b/BungieFrameWork/BFW_Source/BFW_MathLib/bfw_math.c index c149577..16395b2 100644 --- a/BungieFrameWork/BFW_Source/BFW_MathLib/bfw_math.c +++ b/BungieFrameWork/BFW_Source/BFW_MathLib/bfw_math.c @@ -275,7 +275,7 @@ static unsigned int get_feature_flags( xor eax, eax ; CPUID function #0 cpuid ; largest std func/vendor string - mov dword ptr [vendor], ebx ; save + mov dword ptr [vendor], ebx ; save mov dword ptr [vendor+4], edx ; vendor mov dword ptr [vendor+8], ecx ; string test eax, eax ; largest standard function==0? @@ -286,7 +286,7 @@ static unsigned int get_feature_flags( ;; Step 3: Get standard feature flags and signature ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - mov eax, 1 ; CPUID function #1 + mov eax, 1 ; CPUID function #1 cpuid ; get signature/std feature flgs mov [signature], eax ; save processor signature @@ -308,7 +308,7 @@ static unsigned int get_feature_flags( mov ecx, CPUID_STD_MMX ; bit 23 indicates MMX support and ecx, edx ; supports MMX ? CPUID_STD_MMX:0 neg ecx ; supports MMX ? CY : NC - sbb ecx, ecx ; supports MMX ? 0xffffffff:0 + sbb ecx, ecx ; supports MMX ? 0xffffffff:0 and ecx, FEATURE_MMX ; supports MMX ? FEATURE_MMX:0 or [result], ecx ; merge into feature flags @@ -320,7 +320,7 @@ static unsigned int get_feature_flags( sbb ecx, ecx ; supports CMOV ? 0xffffffff:0 and ecx, FEATURE_CMOV ; supports CMOV ? FEATURE_CMOV:0 or [result], ecx ; merge into feature flags - + ;; Check support for P6-style MTRRs mov ecx, CPUID_STD_MTRR ; bit 12 indicates MTRR support @@ -337,7 +337,7 @@ static unsigned int get_feature_flags( and ecx, edx ; supports SSE ? CPUID_STD_SSE:0 neg ecx ; supports SSE ? CY : NC sbb ecx, ecx ; supports SSE ? 0xffffffff:0 - and ecx, (FEATURE_MMXEXT+FEATURE_SSEFP) ; supports SSE ? + and ecx, (FEATURE_MMXEXT+FEATURE_SSEFP) ; supports SSE ? ; FEATURE_MMXEXT+FEATURE_SSEFP:0 or [result], ecx ; merge into feature flags @@ -352,14 +352,14 @@ static unsigned int get_feature_flags( or [result], FEATURE_EXT_FEATURES; does have ext. feature flags ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; Step 6: Get extended feature flags + ;; Step 6: Get extended feature flags ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov eax, 0x80000001 ; CPUID ext. function 0x80000001 cpuid ; EDX = extended feature flags - + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; Step 7: Extract vendor independent features from extended flags + ;; Step 7: Extract vendor independent features from extended flags ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Check for 3DNow! support (vendor independent) @@ -387,7 +387,7 @@ static unsigned int get_feature_flags( ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov ecx, CPUID_EXT_AMD_3DNOWEXT ; bit 30 indicates 3DNow! ext. - and ecx, edx ; 3DNow! ext? + and ecx, edx ; 3DNow! ext? neg ecx ; 3DNow! ext ? CY : NC sbb ecx, ecx ; 3DNow! ext ? 0xffffffff : 0 and ecx, FEATURE_3DNOWEXT ; 3DNow! ext?FEATURE_3DNOWEXT:0 @@ -396,7 +396,7 @@ static unsigned int get_feature_flags( test [result], FEATURE_MMXEXT ; determined SSE MMX support? jnz $has_mmxext ; yes, do not need to check again - ;; Check support for AMDs multimedia instruction set additions + ;; Check support for AMDs multimedia instruction set additions mov ecx, CPUID_EXT_AMD_MMXEXT ; bit 22 indicates MMX extension and ecx, edx ; MMX ext?CPUID_EXT_AMD_MMXEXT:0 @@ -404,15 +404,15 @@ static unsigned int get_feature_flags( sbb ecx, ecx ; MMX ext? 0xffffffff : 0 and ecx, FEATURE_MMXEXT ; MMX ext ? FEATURE_MMXEXT:0 or [result], ecx ; merge into feature flags - + $has_mmxext: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Step 10: Check AMD-specific features not reported by CPUID ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; Check support for AMD-K6 processor-style MTRRs - + ;; Check support for AMD-K6 processor-style MTRRs + mov eax, [signature] ; get processor signature and eax, 0xFFF ; extract family/model/stepping cmp eax, 0x588 ; CPU < AMD-K6-2/CXT ? CY : NC @@ -420,9 +420,9 @@ static unsigned int get_feature_flags( not edx ; CPU < AMD-K6-2/CXT ? 0:0xffffffff cmp eax, 0x600 ; CPU < AMD Athlon ? CY : NC sbb ecx, ecx ; CPU < AMD-K6 ? 0xffffffff:0 - and ecx, edx ; (CPU>=AMD-K6-2/CXT)&& + and ecx, edx ; (CPU>=AMD-K6-2/CXT)&& ; (CPU=AMD-K6-2/CXT)&& + and ecx, FEATURE_K6_MTRR ; (CPU>=AMD-K6-2/CXT)&& ; (CPUv.x + quat->v.x; - y2= quat->v.y + quat->v.y; + y2= quat->v.y + quat->v.y; z2= quat->v.z + quat->v.z; xx= quat->v.x * x2; xy = quat->v.x * y2; xz = quat->v.x * z2; @@ -789,7 +789,7 @@ static void stdc_quat2glMat( // calculate coefficients x2= quat->v.x + quat->v.x; - y2= quat->v.y + quat->v.y; + y2= quat->v.y + quat->v.y; z2= quat->v.z + quat->v.z; xx= quat->v.x * x2; xy = quat->v.x * y2; xz = quat->v.x * z2; @@ -899,13 +899,13 @@ static void stdc_euler2quat2( deg= rot[0] * 0.5f * DEG2RAD; stdc_sincos(deg, cs); qx.v.x= cs[1]; //(float)sin (deg); - qx.v.y= 0.0f; - qx.v.z= 0.0f; + qx.v.y= 0.0f; + qx.v.z= 0.0f; qx.s= cs[0]; //(float)cos (deg); deg= rot[1] * 0.5f * DEG2RAD; stdc_sincos(deg, cs); - qy.v.x= 0.0f; + qy.v.x= 0.0f; qy.v.y= cs[1]; //(float)sin (deg); qy.v.z= 0.0f; qy.s= cs[0]; //(float)cos (deg); @@ -1181,11 +1181,11 @@ static void stdc_inverse_3x3( res[0] = a[4]*a[8] - a[5]*a[7] * det; res[1] = -(a[1]*a[8] - a[7]*a[2]) * det; res[2] = a[1]*a[5] - a[4]*a[2] * det; - + res[3] = -(a[3]*a[8] - a[5]*a[6]) * det; res[4] = a[0]*a[8] - a[6]*a[2] * det; res[5] = -(a[0]*a[5] - a[3]*a[2]) * det; - + res[6] = a[3]*a[7] - a[6]*a[4] * det; res[7] = -(a[0]*a[7] - a[6]*a[1]) * det; res[8] = a[0]*a[4] - a[1]*a[3] * det; @@ -1401,7 +1401,7 @@ static void stdc_glMul_3x3( const float *b) { int i, j; - + for (i = 0; i < 3; i++) { const int idx = i * 3; @@ -1452,17 +1452,17 @@ static void stdc_D3DMul_4x4( r->_12 = a->_11 * b->_12 + a->_12 * b->_22 + a->_13 * b->_32 + a->_14 * b->_42; r->_13 = a->_11 * b->_13 + a->_12 * b->_23 + a->_13 * b->_33 + a->_14 * b->_43; r->_14 = a->_11 * b->_14 + a->_12 * b->_24 + a->_13 * b->_34 + a->_14 * b->_44; - + r->_21 = a->_21 * b->_11 + a->_22 * b->_21 + a->_23 * b->_31 + a->_24 * b->_41; r->_22 = a->_21 * b->_12 + a->_22 * b->_22 + a->_23 * b->_32 + a->_24 * b->_42; r->_23 = a->_21 * b->_13 + a->_22 * b->_23 + a->_23 * b->_33 + a->_24 * b->_43; r->_24 = a->_21 * b->_14 + a->_22 * b->_24 + a->_23 * b->_34 + a->_24 * b->_44; - + r->_31 = a->_31 * b->_11 + a->_32 * b->_21 + a->_33 * b->_31 + a->_34 * b->_41; r->_32 = a->_31 * b->_12 + a->_32 * b->_22 + a->_33 * b->_32 + a->_34 * b->_42; r->_33 = a->_31 * b->_13 + a->_32 * b->_23 + a->_33 * b->_33 + a->_34 * b->_43; r->_34 = a->_31 * b->_14 + a->_32 * b->_24 + a->_33 * b->_34 + a->_34 * b->_44; - + r->_41 = a->_41 * b->_11 + a->_42 * b->_21 + a->_43 * b->_31 + a->_44 * b->_41; r->_42 = a->_41 * b->_12 + a->_42 * b->_22 + a->_43 * b->_32 + a->_44 * b->_42; r->_43 = a->_41 * b->_13 + a->_42 * b->_23 + a->_43 * b->_33 + a->_44 * b->_43; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_CreateVertex.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_CreateVertex.c index d0729d7..9d4983f 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_CreateVertex.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_CreateVertex.c @@ -1,12 +1,12 @@ /* FILE: MG_DC_CreateVertex.c - + AUTHOR: Brent Pease - + CREATED: July 31, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1999 */ @@ -32,21 +32,21 @@ MGrVertexCreate_XYZ( UUtUns16 block8; const UUtUns32* curBVPtr; UUtUns32 curBV; - + UUmAssert(sizeof(GrVertex) == 15 * sizeof(float)); UUmAssert(sizeof(GrVertex) * 8 == UUcProcessor_CacheLineSize * 15); - + numVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; curBVPtr = MGgDrawContextPrivate->statePtr[M3cDrawStatePtrType_VertexBitVector]; - + curMotokoVertex = MGmGetScreenPoints(MGgDrawContextPrivate); - + curGlideVertex = MGgDrawContextPrivate->vertexList; - + block8 = numVertices >> 3; - + curBV = 0xFFFFFFFF; - + for(vertexItr = 0; vertexItr < block8; vertexItr++, curGlideVertex += 8, curMotokoVertex += 8) @@ -54,19 +54,19 @@ MGrVertexCreate_XYZ( if(curBVPtr != NULL) { curBV = curBVPtr[vertexItr >> 2] >> ((vertexItr & 0x3) << 3); - + if(!curBV) continue; } UUrProcessor_ZeroCacheLine((char*)curGlideVertex, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 1, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 2, 0); - + if(curBV & (1 << 0)) { MGmConvertVertex_XYZ(curMotokoVertex + 0, curGlideVertex + 0); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 3, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 4, 0); @@ -74,7 +74,7 @@ MGrVertexCreate_XYZ( { MGmConvertVertex_XYZ(curMotokoVertex + 1, curGlideVertex + 1); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 5, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 6, 0); @@ -82,7 +82,7 @@ MGrVertexCreate_XYZ( { MGmConvertVertex_XYZ(curMotokoVertex + 2, curGlideVertex + 2); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 7, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 8, 0); @@ -90,7 +90,7 @@ MGrVertexCreate_XYZ( { MGmConvertVertex_XYZ(curMotokoVertex + 3, curGlideVertex + 3); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 9, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 10, 0); @@ -98,7 +98,7 @@ MGrVertexCreate_XYZ( { MGmConvertVertex_XYZ(curMotokoVertex + 4, curGlideVertex + 4); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 11, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 12, 0); @@ -106,7 +106,7 @@ MGrVertexCreate_XYZ( { MGmConvertVertex_XYZ(curMotokoVertex + 5, curGlideVertex + 5); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 13, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 14, 0); @@ -114,15 +114,15 @@ MGrVertexCreate_XYZ( { MGmConvertVertex_XYZ(curMotokoVertex + 6, curGlideVertex + 6); } - + if(curBV & (1 << 7)) { MGmConvertVertex_XYZ(curMotokoVertex + 7, curGlideVertex + 7); } } - + // don't forget trailing vertices - + for(vertexItr = block8 * 8; vertexItr < numVertices; vertexItr++, curGlideVertex++, curMotokoVertex++) @@ -130,9 +130,9 @@ MGrVertexCreate_XYZ( if(curBVPtr == NULL || UUrBitVector_TestBit(curBVPtr, vertexItr)) { MGmConvertVertex_XYZ(curMotokoVertex, curGlideVertex); - } + } } - + } void @@ -147,21 +147,21 @@ MGrVertexCreate_XYZ_RGB( const UUtUns32* curBVPtr; UUtUns32 curBV; UUtUns32* curVertexShade = MGmGetVertexShades(MGgDrawContextPrivate); - + UUmAssert(sizeof(GrVertex) == 15 * sizeof(float)); UUmAssert(sizeof(GrVertex) * 8 == UUcProcessor_CacheLineSize * 15); - + numVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; curBVPtr = MGgDrawContextPrivate->statePtr[M3cDrawStatePtrType_VertexBitVector]; - + curMotokoVertex = MGmGetScreenPoints(MGgDrawContextPrivate); - + curGlideVertex = MGgDrawContextPrivate->vertexList; - + block8 = numVertices >> 3; - + curBV = 0xFF; - + for(vertexItr = 0; vertexItr < block8; vertexItr++, curGlideVertex += 8, curMotokoVertex += 8, curVertexShade += 8) @@ -169,20 +169,20 @@ MGrVertexCreate_XYZ_RGB( if(curBVPtr != NULL) { curBV = curBVPtr[vertexItr >> 2] >> ((vertexItr & 0x3) << 3); - + if(!curBV) continue; } UUrProcessor_ZeroCacheLine((char*)curGlideVertex, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 1, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 2, 0); - + if(curBV & (1 << 0)) { MGmConvertVertex_XYZ(curMotokoVertex + 0, curGlideVertex + 0); MGmConvertVertex_RGB(curVertexShade[0], curGlideVertex + 0); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 3, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 4, 0); @@ -191,7 +191,7 @@ MGrVertexCreate_XYZ_RGB( MGmConvertVertex_XYZ(curMotokoVertex + 1, curGlideVertex + 1); MGmConvertVertex_RGB(curVertexShade[1], curGlideVertex + 1); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 5, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 6, 0); @@ -200,7 +200,7 @@ MGrVertexCreate_XYZ_RGB( MGmConvertVertex_XYZ(curMotokoVertex + 2, curGlideVertex + 2); MGmConvertVertex_RGB(curVertexShade[2], curGlideVertex + 2); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 7, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 8, 0); @@ -209,7 +209,7 @@ MGrVertexCreate_XYZ_RGB( MGmConvertVertex_XYZ(curMotokoVertex + 3, curGlideVertex + 3); MGmConvertVertex_RGB(curVertexShade[3], curGlideVertex + 3); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 9, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 10, 0); @@ -218,7 +218,7 @@ MGrVertexCreate_XYZ_RGB( MGmConvertVertex_XYZ(curMotokoVertex + 4, curGlideVertex + 4); MGmConvertVertex_RGB(curVertexShade[4], curGlideVertex + 4); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 11, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 12, 0); @@ -227,7 +227,7 @@ MGrVertexCreate_XYZ_RGB( MGmConvertVertex_XYZ(curMotokoVertex + 5, curGlideVertex + 5); MGmConvertVertex_RGB(curVertexShade[5], curGlideVertex + 5); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 13, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 14, 0); @@ -236,16 +236,16 @@ MGrVertexCreate_XYZ_RGB( MGmConvertVertex_XYZ(curMotokoVertex + 6, curGlideVertex + 6); MGmConvertVertex_RGB(curVertexShade[6], curGlideVertex + 6); } - + if(curBV & (1 << 7)) { MGmConvertVertex_XYZ(curMotokoVertex + 7, curGlideVertex + 7); MGmConvertVertex_RGB(curVertexShade[7], curGlideVertex + 7); } } - + // don't forget trailing vertices - + for(vertexItr = block8 * 8; vertexItr < numVertices; vertexItr++, curGlideVertex++, curMotokoVertex++, curVertexShade++) @@ -254,9 +254,9 @@ MGrVertexCreate_XYZ_RGB( { MGmConvertVertex_XYZ(curMotokoVertex, curGlideVertex); MGmConvertVertex_RGB(curVertexShade[0], curGlideVertex); - } + } } - + } void @@ -273,24 +273,24 @@ MGrVertexCreate_XYZ_BaseUV( MGtTextureMapPrivate* baseMapPrivate = MGmGetBaseMapPrivate(MGgDrawContextPrivate); M3tTextureCoord* curTextureCoord = MGmGetTextureCoords(MGgDrawContextPrivate); float uScale, vScale; - + UUmAssert(sizeof(GrVertex) == 15 * sizeof(float)); UUmAssert(sizeof(GrVertex) * 8 == UUcProcessor_CacheLineSize * 15); - + numVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; curBVPtr = MGgDrawContextPrivate->statePtr[M3cDrawStatePtrType_VertexBitVector]; - + curMotokoVertex = MGmGetScreenPoints(MGgDrawContextPrivate); - + curGlideVertex = MGgDrawContextPrivate->vertexList; - + block8 = numVertices >> 3; - + curBV = 0xFFFFFFFF; - + uScale = baseMapPrivate->u_scale; vScale = baseMapPrivate->v_scale; - + for(vertexItr = 0; vertexItr < block8; vertexItr++, curGlideVertex += 8, curMotokoVertex += 8, curTextureCoord += 8) @@ -298,20 +298,20 @@ MGrVertexCreate_XYZ_BaseUV( if(curBVPtr != NULL) { curBV = curBVPtr[vertexItr >> 2] >> ((vertexItr & 0x3) << 3); - + if(!curBV) continue; } UUrProcessor_ZeroCacheLine((char*)curGlideVertex, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 1, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 2, 0); - + if(curBV & (1 << 0)) { MGmConvertVertex_XYZ(curMotokoVertex + 0, curGlideVertex + 0); MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 0, curGlideVertex + 0); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 3, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 4, 0); @@ -320,7 +320,7 @@ MGrVertexCreate_XYZ_BaseUV( MGmConvertVertex_XYZ(curMotokoVertex + 1, curGlideVertex + 1); MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 1, curGlideVertex + 1); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 5, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 6, 0); @@ -329,7 +329,7 @@ MGrVertexCreate_XYZ_BaseUV( MGmConvertVertex_XYZ(curMotokoVertex + 2, curGlideVertex + 2); MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 2, curGlideVertex + 2); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 7, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 8, 0); @@ -338,7 +338,7 @@ MGrVertexCreate_XYZ_BaseUV( MGmConvertVertex_XYZ(curMotokoVertex + 3, curGlideVertex + 3); MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 3, curGlideVertex + 3); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 9, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 10, 0); @@ -347,7 +347,7 @@ MGrVertexCreate_XYZ_BaseUV( MGmConvertVertex_XYZ(curMotokoVertex + 4, curGlideVertex + 4); MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 4, curGlideVertex + 4); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 11, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 12, 0); @@ -356,7 +356,7 @@ MGrVertexCreate_XYZ_BaseUV( MGmConvertVertex_XYZ(curMotokoVertex + 5, curGlideVertex + 5); MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 5, curGlideVertex + 5); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 13, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 14, 0); @@ -365,14 +365,14 @@ MGrVertexCreate_XYZ_BaseUV( MGmConvertVertex_XYZ(curMotokoVertex + 6, curGlideVertex + 6); MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 6, curGlideVertex + 6); } - + if(curBV & (1 << 7)) { MGmConvertVertex_XYZ(curMotokoVertex + 7, curGlideVertex + 7); MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 7, curGlideVertex + 7); } } - + // don't forget trailing vertices for(vertexItr = block8 * 8; vertexItr < numVertices; @@ -382,7 +382,7 @@ MGrVertexCreate_XYZ_BaseUV( { MGmConvertVertex_XYZ(curMotokoVertex, curGlideVertex); MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord, curGlideVertex); - } + } } } @@ -401,39 +401,39 @@ MGrVertexCreate_XYZ_RGB_BaseUV( M3tTextureCoord* curTextureCoord = MGmGetTextureCoords(MGgDrawContextPrivate); UUtUns32* curVertexShade = MGmGetVertexShades(MGgDrawContextPrivate); float uScale, vScale; - + UUmAssert(sizeof(GrVertex) == 15 * sizeof(float)); UUmAssert(sizeof(GrVertex) * 8 == UUcProcessor_CacheLineSize * 15); - + numVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; curBVPtr = MGgDrawContextPrivate->statePtr[M3cDrawStatePtrType_VertexBitVector]; - + curMotokoVertex = MGmGetScreenPoints(MGgDrawContextPrivate); - + curGlideVertex = MGgDrawContextPrivate->vertexList; - + curBV = 0xFFFFFFFF; - + uScale = baseMapPrivate->u_scale; vScale = baseMapPrivate->v_scale; - + for(vertexItr = 0; vertexItr < numVertices; vertexItr++, curGlideVertex += 1, curMotokoVertex += 1, curTextureCoord += 1, curVertexShade += 1) { if ((curBVPtr != NULL) && (0 == (vertexItr % 8))) { curBV = curBVPtr[vertexItr >> 5] >> (((vertexItr >> 3) & 0x3) << 3); - + if(!curBV) continue; } - + if(curBV & (1 << (vertexItr % 8))) { MGmConvertVertex_XYZ(curMotokoVertex, curGlideVertex); MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord, curGlideVertex ); MGmConvertVertex_RGB(*curVertexShade, curGlideVertex); } - } + } } #else { @@ -448,24 +448,24 @@ MGrVertexCreate_XYZ_RGB_BaseUV( M3tTextureCoord* curTextureCoord = MGmGetTextureCoords(MGgDrawContextPrivate); UUtUns32* curVertexShade = MGmGetVertexShades(MGgDrawContextPrivate); float uScale, vScale; - + UUmAssert(sizeof(GrVertex) == 15 * sizeof(float)); UUmAssert(sizeof(GrVertex) * 8 == UUcProcessor_CacheLineSize * 15); - + numVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; curBVPtr = MGgDrawContextPrivate->statePtr[M3cDrawStatePtrType_VertexBitVector]; - + curMotokoVertex = MGmGetScreenPoints(MGgDrawContextPrivate); - + curGlideVertex = MGgDrawContextPrivate->vertexList; - + block8 = numVertices >> 3; - + curBV = 0xFFFFFFFF; - + uScale = baseMapPrivate->u_scale; vScale = baseMapPrivate->v_scale; - + for(vertexItr = 0; vertexItr < block8; vertexItr++, curGlideVertex += 8, curMotokoVertex += 8, curTextureCoord += 8, curVertexShade += 8) @@ -473,21 +473,21 @@ MGrVertexCreate_XYZ_RGB_BaseUV( if(curBVPtr != NULL) { curBV = curBVPtr[vertexItr >> 2] >> ((vertexItr & 0x3) << 3); - + if(!curBV) continue; } UUrProcessor_ZeroCacheLine((char*)curGlideVertex, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 1, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 2, 0); - + if(curBV & (1 << 0)) { MGmConvertVertex_XYZ(curMotokoVertex + 0, curGlideVertex + 0); MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 0, curGlideVertex + 0); MGmConvertVertex_RGB(curVertexShade[0], curGlideVertex + 0); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 3, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 4, 0); @@ -497,7 +497,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV( MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 1, curGlideVertex + 1); MGmConvertVertex_RGB(curVertexShade[1], curGlideVertex + 1); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 5, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 6, 0); @@ -507,7 +507,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV( MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 2, curGlideVertex + 2); MGmConvertVertex_RGB(curVertexShade[2], curGlideVertex + 2); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 7, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 8, 0); @@ -517,7 +517,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV( MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 3, curGlideVertex + 3); MGmConvertVertex_RGB(curVertexShade[3], curGlideVertex + 3); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 9, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 10, 0); @@ -527,7 +527,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV( MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 4, curGlideVertex + 4); MGmConvertVertex_RGB(curVertexShade[4], curGlideVertex + 4); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 11, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 12, 0); @@ -537,7 +537,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV( MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 5, curGlideVertex + 5); MGmConvertVertex_RGB(curVertexShade[5], curGlideVertex + 5); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 13, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 14, 0); @@ -547,7 +547,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV( MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord + 6, curGlideVertex + 6); MGmConvertVertex_RGB(curVertexShade[6], curGlideVertex + 6); } - + if(curBV & (1 << 7)) { MGmConvertVertex_XYZ(curMotokoVertex + 7, curGlideVertex + 7); @@ -555,7 +555,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV( MGmConvertVertex_RGB(curVertexShade[7], curGlideVertex + 7); } } - + // don't forget trailing vertices for(vertexItr = block8 * 8; vertexItr < numVertices; @@ -566,7 +566,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV( MGmConvertVertex_XYZ(curMotokoVertex, curGlideVertex); MGmConvertVertex_UV(uScale, vScale, 0, curTextureCoord, curGlideVertex); MGmConvertVertex_RGB(curVertexShade[0], curGlideVertex); - } + } } } #endif @@ -589,26 +589,26 @@ MGrVertexCreate_XYZ_RGB_BaseUV_EnvUV( UUtUns32* curVertexShade = MGmGetVertexShades(MGgDrawContextPrivate); float uScaleBase, vScaleBase; float uScaleEnv, vScaleEnv; - + UUmAssert(sizeof(GrVertex) == 15 * sizeof(float)); UUmAssert(sizeof(GrVertex) * 8 == UUcProcessor_CacheLineSize * 15); - + numVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; curBVPtr = MGgDrawContextPrivate->statePtr[M3cDrawStatePtrType_VertexBitVector]; - + curMotokoVertex = MGmGetScreenPoints(MGgDrawContextPrivate); - + curGlideVertex = MGgDrawContextPrivate->vertexList; - + block8 = numVertices >> 3; - + curBV = 0xFFFFFFFF; - + uScaleBase = baseMapPrivate->u_scale; vScaleBase = baseMapPrivate->v_scale; uScaleEnv = envMapPrivate->u_scale; vScaleEnv = envMapPrivate->v_scale; - + for(vertexItr = 0; vertexItr < block8; vertexItr++, curGlideVertex += 8, curMotokoVertex += 8, curTextureCoord += 8, curEnvTextureCoord += 8, curVertexShade += 8) @@ -616,14 +616,14 @@ MGrVertexCreate_XYZ_RGB_BaseUV_EnvUV( if(curBVPtr != NULL) { curBV = curBVPtr[vertexItr >> 2] >> ((vertexItr & 0x3) << 3); - + if(!curBV) continue; } UUrProcessor_ZeroCacheLine((char*)curGlideVertex, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 1, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 2, 0); - + if(curBV & (1 << 0)) { MGmConvertVertex_XYZ(curMotokoVertex + 0, curGlideVertex + 0); @@ -631,7 +631,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV_EnvUV( MGmConvertVertex_UV(uScaleEnv, vScaleEnv, 1, curEnvTextureCoord + 0, curGlideVertex + 0); MGmConvertVertex_RGB(curVertexShade[0], curGlideVertex + 0); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 3, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 4, 0); @@ -642,7 +642,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV_EnvUV( MGmConvertVertex_UV(uScaleEnv, vScaleEnv, 1, curEnvTextureCoord + 1, curGlideVertex + 1); MGmConvertVertex_RGB(curVertexShade[1], curGlideVertex + 1); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 5, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 6, 0); @@ -653,7 +653,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV_EnvUV( MGmConvertVertex_UV(uScaleEnv, vScaleEnv, 1, curEnvTextureCoord + 2, curGlideVertex + 2); MGmConvertVertex_RGB(curVertexShade[2], curGlideVertex + 2); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 7, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 8, 0); @@ -664,7 +664,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV_EnvUV( MGmConvertVertex_UV(uScaleEnv, vScaleEnv, 1, curEnvTextureCoord + 3, curGlideVertex + 3); MGmConvertVertex_RGB(curVertexShade[3], curGlideVertex + 3); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 9, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 10, 0); @@ -675,7 +675,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV_EnvUV( MGmConvertVertex_UV(uScaleEnv, vScaleEnv, 1, curEnvTextureCoord + 4, curGlideVertex + 4); MGmConvertVertex_RGB(curVertexShade[4], curGlideVertex + 4); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 11, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 12, 0); @@ -686,7 +686,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV_EnvUV( MGmConvertVertex_UV(uScaleEnv, vScaleEnv, 1, curEnvTextureCoord + 5, curGlideVertex + 5); MGmConvertVertex_RGB(curVertexShade[5], curGlideVertex + 5); } - + UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 13, 0); UUrProcessor_ZeroCacheLine((char*)curGlideVertex + UUcProcessor_CacheLineSize * 14, 0); @@ -697,7 +697,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV_EnvUV( MGmConvertVertex_UV(uScaleEnv, vScaleEnv, 1, curEnvTextureCoord + 6, curGlideVertex + 6); MGmConvertVertex_RGB(curVertexShade[6], curGlideVertex + 6); } - + if(curBV & (1 << 7)) { MGmConvertVertex_XYZ(curMotokoVertex + 7, curGlideVertex + 7); @@ -706,7 +706,7 @@ MGrVertexCreate_XYZ_RGB_BaseUV_EnvUV( MGmConvertVertex_RGB(curVertexShade[7], curGlideVertex + 7); } } - + // don't forget trailing vertices for(vertexItr = block8 * 8; vertexItr < numVertices; @@ -718,6 +718,6 @@ MGrVertexCreate_XYZ_RGB_BaseUV_EnvUV( MGmConvertVertex_UV(uScaleBase, vScaleBase, 0, curTextureCoord, curGlideVertex); MGmConvertVertex_UV(uScaleEnv, vScaleEnv, 1, curEnvTextureCoord, curGlideVertex); MGmConvertVertex_RGB(curVertexShade[0], curGlideVertex); - } + } } } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_CreateVertex.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_CreateVertex.h index b050251..c905f0b 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_CreateVertex.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_CreateVertex.h @@ -1,12 +1,12 @@ /* FILE: MG_DC_CreateVertex.h - + AUTHOR: Brent Pease - + CREATED: July 31, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Bitmap.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Bitmap.c index f44ab20..26cbaee 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Bitmap.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Bitmap.c @@ -1,12 +1,12 @@ /* FILE: MG_DC_Method_Bitmap.c - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: Nov 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997, 1998 */ @@ -30,7 +30,7 @@ #include "rasterizer_3dfx.h" // this table converts from Motoko alpha to glide vertex alpha -float MGg5BitsTo0_255FloatTable[32] = +float MGg5BitsTo0_255FloatTable[32] = { ( 0.f * (MGc255Float / ((float) MGcMax5Bits))), ( 1.f * (MGc255Float / ((float) MGcMax5Bits))), ( 2.f * (MGc255Float / ((float) MGcMax5Bits))), ( 3.f * (MGc255Float / ((float) MGcMax5Bits))), ( 4.f * (MGc255Float / ((float) MGcMax5Bits))), ( 5.f * (MGc255Float / ((float) MGcMax5Bits))), ( 6.f * (MGc255Float / ((float) MGcMax5Bits))), ( 7.f * (MGc255Float / ((float) MGcMax5Bits))), @@ -76,10 +76,10 @@ MGrDrawContext_Method_TriSprite( float ooz2 = 65535.f / inPoints[2].z; float oow2 = inPoints[2].invW; - GrVertex glide_vertices[3]; - + GrVertex glide_vertices[3]; + UUmAssert(textureMapPrivate != NULL); - + glide_vertices[0].x= x0; glide_vertices[0].y= y0; glide_vertices[0].ooz= ooz0; @@ -102,7 +102,7 @@ MGrDrawContext_Method_TriSprite( glide_vertices[2].tmuvtx[0].tow= textureMapPrivate->v_scale*inTextureCoords[2].v*oow2; grDrawPlanarPolygonVertexList(3, glide_vertices); - + return; } @@ -125,10 +125,10 @@ MGrDrawContext_Method_Sprite( float y1 = SNAP_COORD(inPoints[1].y); float x1 = SNAP_COORD(inPoints[1].x); - GrVertex glide_vertices[4]; - + GrVertex glide_vertices[4]; + UUmAssert(textureMapPrivate != NULL); - + // upper left glide_vertices[1].x= x0; glide_vertices[1].y= y0; @@ -162,7 +162,7 @@ MGrDrawContext_Method_Sprite( glide_vertices[3].tmuvtx[0].tow= textureMapPrivate->v_scale*inTextureCoords[3].v*oow; grDrawPlanarPolygonVertexList(4, glide_vertices); - + return; } @@ -198,7 +198,7 @@ MGrDrawContext_Method_ScreenCapture( return UUcError_None; } -UUtBool +UUtBool MGrDrawContext_Method_PointVisible( const M3tPointScreen *inPoint, float inTolerance) diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Bitmap.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Bitmap.h index c414dbe..3b92f08 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Bitmap.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Bitmap.h @@ -1,12 +1,12 @@ /* FILE: MG_DC_Method_Bitmap.h - + AUTHOR: Brent H. Pease - + CREATED: Nov 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -24,7 +24,7 @@ MGrDrawContext_Method_Sprite( const M3tTextureCoord *inTextureCoords); // tl, tr, bl, br UUtError MGrDrawContext_Method_ScreenCapture( - const UUtRect *inRect, + const UUtRect *inRect, void *outBuffer); UUtBool MGrDrawContext_Method_PointVisible( diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Frame.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Frame.h index 144346a..96b20d9 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Frame.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Frame.h @@ -1,12 +1,12 @@ /* FILE: MG_DC_Method_Frame.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_LinePoint.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_LinePoint.c index 7d6b207..830c52b 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_LinePoint.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_LinePoint.c @@ -4,9 +4,9 @@ AUTHOR: Brent H. Pease CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -30,17 +30,17 @@ MGrPoint( M3tPointScreen* invCoord) { GrVertex glide_vertex; - + MGmConvertVertex_XYZ(invCoord, &glide_vertex); - + glide_vertex.oow *= 1.01f; - + MGrSet_ColorCombine(MGcColorCombine_ConstantColor); MGrSet_AlphaCombine(MGcAlphaCombine_NoAlpha); grDrawPoint(&glide_vertex); } -void +void MGrLine_InterpVertex( UUtUns32 inVIndex0, UUtUns32 inVIndex1) @@ -50,7 +50,7 @@ MGrLine_InterpVertex( inVIndex1); } -void +void MGrLine_InterpNone( UUtUns32 inVIndex0, UUtUns32 inVIndex1) @@ -58,14 +58,14 @@ MGrLine_InterpNone( M3tPointScreen *screenPoints; GrVertex glide_vertices[2]; - + screenPoints = (M3tPointScreen*)MGgDrawContextPrivate->statePtr[ M3cDrawStatePtrType_ScreenPointArray]; - + MGmConvertVertex_XYZ(screenPoints + inVIndex0, glide_vertices + 0); MGmConvertVertex_XYZ(screenPoints + inVIndex1, glide_vertices + 1); - + glide_vertices[0].oow *= 1.01f; glide_vertices[1].oow *= 1.01f; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_LinePoint.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_LinePoint.h index c1b7c71..4a02c45 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_LinePoint.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_LinePoint.h @@ -1,28 +1,28 @@ /* FILE: MG_DC_Method_LinePoint.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MG_DC_METHOD_LINEPOINT_H #define MG_DC_METHOD_LINEPOINT_H -void +void MGrPoint( M3tPointScreen* invCoord); -void +void MGrLine_InterpVertex( UUtUns32 inVIndex0, UUtUns32 inVIndex1); -void +void MGrLine_InterpNone( UUtUns32 inVIndex0, UUtUns32 inVIndex1); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Pent.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Pent.c index 54a1d75..e777bf3 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Pent.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Pent.c @@ -5,8 +5,8 @@ CREATED: Sept 18, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ @@ -25,14 +25,14 @@ #include "rasterizer_3dfx.h" -void +void MGrPent_Point( M3tPent* inPent) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); UUtUns32* vertexShades = MGmGetVertexShades(MGgDrawContextPrivate); GrVertex* vertexList; - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); @@ -63,9 +63,9 @@ MGrPent_Line_InterpNone( M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); UUtUns32* vertexShades = MGmGetVertexShades(MGgDrawContextPrivate); GrVertex* vertexList; - + UUtUns16 vertexItr; - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); @@ -97,26 +97,26 @@ MGrPent_Solid_Gouraud_InterpNone( UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_None); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Gouraud); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); UUtUns16 numRealVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; UUmAssert(numRealVertices < MGcMaxElements); - + MGmSplatVertex_XYZ(inPent->indices[0]); MGmSplatVertex_XYZ(inPent->indices[1]); MGmSplatVertex_XYZ(inPent->indices[2]); MGmSplatVertex_XYZ(inPent->indices[3]); MGmSplatVertex_XYZ(inPent->indices[4]); } - + iList[0] = inPent->indices[0]; iList[1] = inPent->indices[1]; iList[2] = inPent->indices[2]; @@ -136,16 +136,16 @@ MGrPent_Solid_Gouraud_InterpVertex( { GrVertex* vertexList; int iList[5]; - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_Vertex); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Gouraud); vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { UUtUns16 numRealVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; @@ -153,14 +153,14 @@ MGrPent_Solid_Gouraud_InterpVertex( UUtUns32* vertexShades = MGmGetVertexShades(MGgDrawContextPrivate); UUmAssert(numRealVertices < MGcMaxElements); - + MGmSplatVertex_XYZRGB(inPent->indices[0]); MGmSplatVertex_XYZRGB(inPent->indices[1]); MGmSplatVertex_XYZRGB(inPent->indices[2]); MGmSplatVertex_XYZRGB(inPent->indices[3]); MGmSplatVertex_XYZRGB(inPent->indices[4]); } - + iList[0] = inPent->indices[0]; iList[1] = inPent->indices[1]; iList[2] = inPent->indices[2]; @@ -179,16 +179,16 @@ MGrPent_Solid_TextureLit_InterpNone( { GrVertex* vertexList; int iList[5]; - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_None); - + //UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == // M3cDrawState_Appearence_Texture_Lit); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { UUtUns16 numRealVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; @@ -196,20 +196,20 @@ MGrPent_Solid_TextureLit_InterpNone( M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); MGtTextureMapPrivate* baseMapPrivate = MGmGetBaseMapPrivate(MGgDrawContextPrivate); float u_scale, v_scale; - + UUmAssert(numRealVertices < MGcMaxElements); UUmAssertReadPtr(baseMapPrivate, sizeof(*baseMapPrivate)); - + u_scale = baseMapPrivate->u_scale; v_scale = baseMapPrivate->v_scale; - + MGmSplatVertex_XYZUV(inPent->indices[0]); MGmSplatVertex_XYZUV(inPent->indices[1]); MGmSplatVertex_XYZUV(inPent->indices[2]); MGmSplatVertex_XYZUV(inPent->indices[3]); MGmSplatVertex_XYZUV(inPent->indices[4]); } - + iList[0] = inPent->indices[0]; iList[1] = inPent->indices[1]; iList[2] = inPent->indices[2]; @@ -228,16 +228,16 @@ MGrPent_Solid_TextureLit_InterpVertex( { GrVertex* vertexList; int iList[5]; - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_Vertex); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Texture_Lit); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); @@ -249,17 +249,17 @@ MGrPent_Solid_TextureLit_InterpVertex( UUmAssertReadPtr(baseMapPrivate, sizeof(*baseMapPrivate)); UUmAssert(numRealVertices < MGcMaxElements); - + u_scale = baseMapPrivate->u_scale; v_scale = baseMapPrivate->v_scale; - + MGmSplatVertex_XYZUVRGB(inPent->indices[0]); MGmSplatVertex_XYZUVRGB(inPent->indices[1]); MGmSplatVertex_XYZUVRGB(inPent->indices[2]); MGmSplatVertex_XYZUVRGB(inPent->indices[3]); MGmSplatVertex_XYZUVRGB(inPent->indices[4]); } - + MGmAssertVertex_RGB(vertexList + inPent->indices[0]); MGmAssertVertex_RGB(vertexList + inPent->indices[1]); MGmAssertVertex_RGB(vertexList + inPent->indices[2]); @@ -284,16 +284,16 @@ MGrPent_Solid_TextureLit_EnvMap_InterpVertex( { GrVertex* vertexList; int iList[5]; - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_Vertex); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Texture_Lit_EnvMap); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); @@ -308,19 +308,19 @@ MGrPent_Solid_TextureLit_EnvMap_InterpVertex( UUmAssertReadPtr(baseMapPrivate, sizeof(*baseMapPrivate)); UUmAssert(numRealVertices < MGcMaxElements); - + u_scale = baseMapPrivate->u_scale; v_scale = baseMapPrivate->v_scale; u_scale_env = envMapPrivate->u_scale; v_scale_env = envMapPrivate->v_scale; - + MGmSplatVertex_XYZUVRGBEnvMap(inPent->indices[0]); MGmSplatVertex_XYZUVRGBEnvMap(inPent->indices[1]); MGmSplatVertex_XYZUVRGBEnvMap(inPent->indices[2]); MGmSplatVertex_XYZUVRGBEnvMap(inPent->indices[3]); MGmSplatVertex_XYZUVRGBEnvMap(inPent->indices[4]); } - + MGmAssertVertex_RGB(vertexList + inPent->indices[0]); MGmAssertVertex_RGB(vertexList + inPent->indices[1]); MGmAssertVertex_RGB(vertexList + inPent->indices[2]); @@ -371,31 +371,31 @@ MGrPentSplit_Solid_TextureUnlit_LMOff( GrVertex* vertexList; float u_scale, v_scale; int iList[5]; - + UUmAssertReadPtr(baseMapPrivate, sizeof(*baseMapPrivate)); UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_None); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Texture_Unlit); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { UUtUns16 numRealVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); - + UUmAssert(numRealVertices < MGcMaxElements); - + MGmSplatVertex_XYZ(inPent->vertexIndices.indices[0]); MGmSplatVertex_XYZ(inPent->vertexIndices.indices[1]); MGmSplatVertex_XYZ(inPent->vertexIndices.indices[2]); MGmSplatVertex_XYZ(inPent->vertexIndices.indices[3]); MGmSplatVertex_XYZ(inPent->vertexIndices.indices[4]); } - + u_scale = baseMapPrivate->u_scale; v_scale = baseMapPrivate->v_scale; @@ -404,31 +404,31 @@ MGrPentSplit_Solid_TextureUnlit_LMOff( 0, textureCoords + inPent->baseUVIndices.indices[0], vertexList + inPent->vertexIndices.indices[0]); - + MGmConvertVertex_UV( u_scale, v_scale, 0, textureCoords + inPent->baseUVIndices.indices[1], vertexList + inPent->vertexIndices.indices[1]); - + MGmConvertVertex_UV( u_scale, v_scale, 0, textureCoords + inPent->baseUVIndices.indices[2], vertexList + inPent->vertexIndices.indices[2]); - + MGmConvertVertex_UV( u_scale, v_scale, 0, textureCoords + inPent->baseUVIndices.indices[3], vertexList + inPent->vertexIndices.indices[3]); - + MGmConvertVertex_UV( u_scale, v_scale, 0, textureCoords + inPent->baseUVIndices.indices[4], vertexList + inPent->vertexIndices.indices[4]); - + iList[0] = inPent->vertexIndices.indices[0]; iList[1] = inPent->vertexIndices.indices[1]; iList[2] = inPent->vertexIndices.indices[2]; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Pent.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Pent.h index 237361e..ece9ea1 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Pent.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Pent.h @@ -1,12 +1,12 @@ /* FILE: MG_DC_Method_Pent.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -14,7 +14,7 @@ #define MG_DC_METHOD_PENT_H // Pent functions - void + void MGrPent_Point( M3tPent* inPent); @@ -51,25 +51,25 @@ M3tPent* inPent); // Pentsplit functions - + // texture lit - + // interp none - + void MGrPentSplit_Solid_TextureLit_InterpNone_LMOff( M3tPentSplit* inPent); - - + + // interp vertex - + void MGrPentSplit_Solid_TextureLit_InterpVertex_LMOff( M3tPentSplit* inPent); - + // texture unlit - + void MGrPentSplit_Solid_TextureUnlit_LMOff( M3tPentSplit* inPent); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Quad.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Quad.c index 601aef7..47373d2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Quad.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Quad.c @@ -1,12 +1,12 @@ /* FILE: MG_DC_Method_Quad.c - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997, 1998 */ @@ -25,14 +25,14 @@ #include "MG_DC_Method_Quad.h" #include "rasterizer_3dfx.h" -void +void MGrQuad_Point( M3tQuad* inQuad) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); UUtUns32* vertexShades = MGmGetVertexShades(MGgDrawContextPrivate); GrVertex* vertexList; - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); @@ -60,9 +60,9 @@ MGrQuad_Line_InterpNone( M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); UUtUns32* vertexShades = MGmGetVertexShades(MGgDrawContextPrivate); GrVertex* vertexList; - + UUtUns16 vertexItr; - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); @@ -94,25 +94,25 @@ MGrQuad_Solid_Gouraud_InterpNone( UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_None); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Gouraud); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); UUtUns16 numRealVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; UUmAssert(numRealVertices < MGcMaxElements); - + MGmSplatVertex_XYZ(inQuad->indices[0]); MGmSplatVertex_XYZ(inQuad->indices[1]); MGmSplatVertex_XYZ(inQuad->indices[2]); MGmSplatVertex_XYZ(inQuad->indices[3]); } - + iList[0] = inQuad->indices[0]; iList[1] = inQuad->indices[1]; iList[2] = inQuad->indices[2]; @@ -131,16 +131,16 @@ MGrQuad_Solid_Gouraud_InterpVertex( { GrVertex* vertexList; int iList[4]; - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_Vertex); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Gouraud); vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { UUtUns16 numRealVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; @@ -148,13 +148,13 @@ MGrQuad_Solid_Gouraud_InterpVertex( UUtUns32* vertexShades = MGmGetVertexShades(MGgDrawContextPrivate); UUmAssert(numRealVertices < MGcMaxElements); - + MGmSplatVertex_XYZRGB(inQuad->indices[0]); MGmSplatVertex_XYZRGB(inQuad->indices[1]); MGmSplatVertex_XYZRGB(inQuad->indices[2]); MGmSplatVertex_XYZRGB(inQuad->indices[3]); } - + iList[0] = inQuad->indices[0]; iList[1] = inQuad->indices[1]; iList[2] = inQuad->indices[2]; @@ -172,16 +172,16 @@ MGrQuad_Solid_TextureLit_InterpNone( { GrVertex* vertexList; int iList[4]; - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_None); - + //UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == // M3cDrawState_Appearence_Texture_Lit); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { UUtUns16 numRealVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; @@ -189,19 +189,19 @@ MGrQuad_Solid_TextureLit_InterpNone( M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); MGtTextureMapPrivate* baseMapPrivate = MGmGetBaseMapPrivate(MGgDrawContextPrivate); float u_scale, v_scale; - + UUmAssert(numRealVertices < MGcMaxElements); UUmAssertReadPtr(baseMapPrivate, sizeof(*baseMapPrivate)); - + u_scale = baseMapPrivate->u_scale; v_scale = baseMapPrivate->v_scale; - + MGmSplatVertex_XYZUV(inQuad->indices[0]); MGmSplatVertex_XYZUV(inQuad->indices[1]); MGmSplatVertex_XYZUV(inQuad->indices[2]); MGmSplatVertex_XYZUV(inQuad->indices[3]); } - + iList[0] = inQuad->indices[0]; iList[1] = inQuad->indices[1]; iList[2] = inQuad->indices[2]; @@ -219,18 +219,18 @@ MGrQuad_Solid_TextureLit_InterpVertex( { GrVertex* vertexList; int iList[4]; - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_Vertex); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Texture_Lit); - + UUmAssert(globals_3dfx.currentColorCombine == MGcColorCombine_TextureGouraud); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); @@ -242,16 +242,16 @@ MGrQuad_Solid_TextureLit_InterpVertex( UUmAssertReadPtr(baseMapPrivate, sizeof(*baseMapPrivate)); UUmAssert(numRealVertices < MGcMaxElements); - + u_scale = baseMapPrivate->u_scale; v_scale = baseMapPrivate->v_scale; - + MGmSplatVertex_XYZUVRGB(inQuad->indices[0]); MGmSplatVertex_XYZUVRGB(inQuad->indices[1]); MGmSplatVertex_XYZUVRGB(inQuad->indices[2]); MGmSplatVertex_XYZUVRGB(inQuad->indices[3]); } - + MGmAssertVertex_RGB(vertexList + inQuad->indices[0]); MGmAssertVertex_RGB(vertexList + inQuad->indices[1]); MGmAssertVertex_RGB(vertexList + inQuad->indices[2]); @@ -274,18 +274,18 @@ MGrQuad_Solid_TextureLit_EnvMap_InterpVertex( { GrVertex* vertexList; int iList[4]; - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_Vertex); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Texture_Lit_EnvMap); - + UUmAssert(globals_3dfx.currentColorCombine == MGcColorCombine_TextureGouraud); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); @@ -300,18 +300,18 @@ MGrQuad_Solid_TextureLit_EnvMap_InterpVertex( UUmAssertReadPtr(baseMapPrivate, sizeof(*baseMapPrivate)); UUmAssert(numRealVertices < MGcMaxElements); - + u_scale = baseMapPrivate->u_scale; v_scale = baseMapPrivate->v_scale; u_scale_env = envMapPrivate->u_scale; v_scale_env = envMapPrivate->v_scale; - + MGmSplatVertex_XYZUVRGBEnvMap(inQuad->indices[0]); MGmSplatVertex_XYZUVRGBEnvMap(inQuad->indices[1]); MGmSplatVertex_XYZUVRGBEnvMap(inQuad->indices[2]); MGmSplatVertex_XYZUVRGBEnvMap(inQuad->indices[3]); } - + MGmAssertVertex_RGB(vertexList + inQuad->indices[0]); MGmAssertVertex_RGB(vertexList + inQuad->indices[1]); MGmAssertVertex_RGB(vertexList + inQuad->indices[2]); @@ -361,30 +361,30 @@ MGrQuadSplit_Solid_TextureUnlit_LMOff( GrVertex* vertexList; float u_scale, v_scale; int iList[4]; - + UUmAssertReadPtr(baseMapPrivate, sizeof(*baseMapPrivate)); UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_None); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Texture_Unlit); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { UUtUns16 numRealVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); - + UUmAssert(numRealVertices < MGcMaxElements); - + MGmSplatVertex_XYZ(inQuad->vertexIndices.indices[0]); MGmSplatVertex_XYZ(inQuad->vertexIndices.indices[1]); MGmSplatVertex_XYZ(inQuad->vertexIndices.indices[2]); MGmSplatVertex_XYZ(inQuad->vertexIndices.indices[3]); } - + u_scale = baseMapPrivate->u_scale; v_scale = baseMapPrivate->v_scale; @@ -393,25 +393,25 @@ MGrQuadSplit_Solid_TextureUnlit_LMOff( 0, textureCoords + inQuad->baseUVIndices.indices[0], vertexList + inQuad->vertexIndices.indices[0]); - + MGmConvertVertex_UV( u_scale, v_scale, 0, textureCoords + inQuad->baseUVIndices.indices[1], vertexList + inQuad->vertexIndices.indices[1]); - + MGmConvertVertex_UV( u_scale, v_scale, 0, textureCoords + inQuad->baseUVIndices.indices[2], vertexList + inQuad->vertexIndices.indices[2]); - + MGmConvertVertex_UV( u_scale, v_scale, 0, textureCoords + inQuad->baseUVIndices.indices[3], vertexList + inQuad->vertexIndices.indices[3]); - + iList[0] = inQuad->vertexIndices.indices[0]; iList[1] = inQuad->vertexIndices.indices[1]; iList[2] = inQuad->vertexIndices.indices[2]; @@ -421,6 +421,6 @@ MGrQuadSplit_Solid_TextureUnlit_LMOff( 4, iList, vertexList); - + return; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Quad.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Quad.h index a98d580..ef39612 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Quad.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Quad.h @@ -1,12 +1,12 @@ /* FILE: MG_DC_Method_Quad.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -14,7 +14,7 @@ #define MG_DC_METHOD_QUAD_H // Quad functions - void + void MGrQuad_Point( M3tQuad* inQuad); @@ -51,23 +51,23 @@ M3tQuad* inQuad); // Quadsplit functions - + // texture lit - + // interp none - + void MGrQuadSplit_Solid_TextureLit_InterpNone_LMOff( - M3tQuadSplit* inQuad); - + M3tQuadSplit* inQuad); + // interp vertex - + void MGrQuadSplit_Solid_TextureLit_InterpVertex_LMOff( M3tQuadSplit* inQuad); // texture unlit - + void MGrQuadSplit_Solid_TextureUnlit_LMOff( M3tQuadSplit* inQuad); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Query.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Query.h index 40be311..75405f0 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Query.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Query.h @@ -17,4 +17,4 @@ MGrDrawContext_TextureFormatAvailable( IMtPixelType inTexelType); // ====================================================================== -#endif /* MG_DC_METHOD_QUERY_H */ \ No newline at end of file +#endif /* MG_DC_METHOD_QUERY_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_SmallQuad.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_SmallQuad.h index 781be2b..1cf3798 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_SmallQuad.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_SmallQuad.h @@ -1,27 +1,27 @@ /* FILE: MG_DC_Method_SmallQuad.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MG_DC_METHOD_SMALLQUAD_H #define MG_DC_METHOD_SMALLQUAD_H -void +void MGrDrawContext_Method_SmallQuadGouraudInterpolate( UUtUns32 inIndices); -void +void MGrDrawContext_Method_SmallQuadGouraudFlat( UUtUns32 inIndices); -void +void MGrDrawContext_Method_SmallQuadTextureInterpolate( UUtUns32 inIndices); @@ -29,11 +29,11 @@ void MGrDrawContext_Method_SmallQuadTextureFlat( UUtUns32 inIndices); -void +void MGrDrawContext_Method_SmallQuadLineFlat( UUtUns32 inIndices); -void +void MGrDrawContext_Method_SmallQuadLineInterp( UUtUns32 inIndices); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_State.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_State.h index 70358b7..2ab1701 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_State.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_State.h @@ -1,12 +1,12 @@ /* FILE: MG_DC_Method_State.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Triangle.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Triangle.c index 4777037..3158441 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Triangle.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Triangle.c @@ -1,12 +1,12 @@ /* FILE: MG_DC_Method_Triangle.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -28,14 +28,14 @@ #define DYNAHEADER #include "glide.h" -void +void MGrTriangle_Point( M3tTri* inTri) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); UUtUns32* vertexShades = MGmGetVertexShades(MGgDrawContextPrivate); GrVertex* vertexList; - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); @@ -60,9 +60,9 @@ MGrTriangle_Line_InterpNone( M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); UUtUns32* vertexShades = MGmGetVertexShades(MGgDrawContextPrivate); GrVertex* vertexList; - + UUtUns16 vertexItr; - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); @@ -93,24 +93,24 @@ MGrTriangle_Solid_Gouraud_InterpNone( UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_None); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Gouraud); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); UUtUns16 numRealVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; UUmAssert(numRealVertices < MGcMaxElements); - + MGmSplatVertex_XYZ(inTri->indices[0]); MGmSplatVertex_XYZ(inTri->indices[1]); MGmSplatVertex_XYZ(inTri->indices[2]); } - + MGrDrawTriangle( vertexList + inTri->indices[0], vertexList + inTri->indices[1], @@ -122,16 +122,16 @@ MGrTriangle_Solid_Gouraud_InterpVertex( M3tTri* inTri) { GrVertex* vertexList; - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_Vertex); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Gouraud); vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { UUtUns16 numRealVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; @@ -139,12 +139,12 @@ MGrTriangle_Solid_Gouraud_InterpVertex( UUtUns32* vertexShades = MGmGetVertexShades(MGgDrawContextPrivate); UUmAssert(numRealVertices < MGcMaxElements); - + MGmSplatVertex_XYZRGB(inTri->indices[0]); MGmSplatVertex_XYZRGB(inTri->indices[1]); MGmSplatVertex_XYZRGB(inTri->indices[2]); } - + MGrDrawTriangle( vertexList + inTri->indices[0], vertexList + inTri->indices[1], @@ -156,16 +156,16 @@ MGrTriangle_Solid_TextureLit_InterpNone( M3tTri* inTri) { GrVertex* vertexList; - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_None); - + //UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == // M3cDrawState_Appearence_Texture_Lit); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { UUtUns16 numRealVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; @@ -173,18 +173,18 @@ MGrTriangle_Solid_TextureLit_InterpNone( M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); MGtTextureMapPrivate* baseMapPrivate = MGmGetBaseMapPrivate(MGgDrawContextPrivate); float u_scale, v_scale; - + UUmAssert(numRealVertices < MGcMaxElements); UUmAssertReadPtr(baseMapPrivate, sizeof(*baseMapPrivate)); - + u_scale = baseMapPrivate->u_scale; v_scale = baseMapPrivate->v_scale; - + MGmSplatVertex_XYZUV(inTri->indices[0]); MGmSplatVertex_XYZUV(inTri->indices[1]); MGmSplatVertex_XYZUV(inTri->indices[2]); } - + MGrDrawTriangle( vertexList + inTri->indices[0], vertexList + inTri->indices[1], @@ -198,16 +198,16 @@ MGrTriangle_Solid_TextureLit_InterpVertex( M3tTri* inTri) { GrVertex* vertexList; - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_Vertex); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Texture_Lit); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); @@ -219,15 +219,15 @@ MGrTriangle_Solid_TextureLit_InterpVertex( UUmAssertReadPtr(baseMapPrivate, sizeof(*baseMapPrivate)); UUmAssert(numRealVertices < MGcMaxElements); - + u_scale = baseMapPrivate->u_scale; v_scale = baseMapPrivate->v_scale; - + MGmSplatVertex_XYZUVRGB(inTri->indices[0]); MGmSplatVertex_XYZUVRGB(inTri->indices[1]); MGmSplatVertex_XYZUVRGB(inTri->indices[2]); } - + MGmAssertVertex_RGB(vertexList + inTri->indices[0]); MGmAssertVertex_RGB(vertexList + inTri->indices[1]); MGmAssertVertex_RGB(vertexList + inTri->indices[2]); @@ -244,16 +244,16 @@ MGrTriangle_Solid_TextureLit_EnvMap_InterpVertex( M3tTri* inTri) { GrVertex* vertexList; - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_Vertex); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Texture_Lit_EnvMap); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); @@ -268,17 +268,17 @@ MGrTriangle_Solid_TextureLit_EnvMap_InterpVertex( UUmAssertReadPtr(baseMapPrivate, sizeof(*baseMapPrivate)); UUmAssert(numRealVertices < MGcMaxElements); - + u_scale = baseMapPrivate->u_scale; v_scale = baseMapPrivate->v_scale; u_scale_env = envMapPrivate->u_scale; v_scale_env = envMapPrivate->v_scale; - + MGmSplatVertex_XYZUVRGBEnvMap(inTri->indices[0]); MGmSplatVertex_XYZUVRGBEnvMap(inTri->indices[1]); MGmSplatVertex_XYZUVRGBEnvMap(inTri->indices[2]); } - + MGmAssertVertex_RGB(vertexList + inTri->indices[0]); MGmAssertVertex_RGB(vertexList + inTri->indices[1]); MGmAssertVertex_RGB(vertexList + inTri->indices[2]); @@ -328,27 +328,27 @@ MGrTriSplit_Solid_TextureUnlit_LMOff( UUmAssertReadPtr(baseMapPrivate, sizeof(*baseMapPrivate)); UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Interpolation] == M3cDrawState_Interpolation_None); - + UUmAssert(MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_Appearence] == M3cDrawState_Appearence_Texture_Unlit); - + vertexList = MGgDrawContextPrivate->vertexList; UUmAssert(vertexList != NULL); - + if(MGgDrawContextPrivate->clipping) { M3tPointScreen* screenPoints = MGmGetScreenPoints(MGgDrawContextPrivate); UUtUns16 numRealVertices = (UUtUns16)MGgDrawContextPrivate->stateInt[M3cDrawStateIntType_NumRealVertices]; - + UUmAssert(numRealVertices < MGcMaxElements); - + MGmSplatVertex_XYZ(inTri->vertexIndices.indices[0]); MGmSplatVertex_XYZ(inTri->vertexIndices.indices[1]); MGmSplatVertex_XYZ(inTri->vertexIndices.indices[2]); } - - + + u_scale = baseMapPrivate->u_scale; v_scale = baseMapPrivate->v_scale; @@ -357,13 +357,13 @@ MGrTriSplit_Solid_TextureUnlit_LMOff( 0, textureCoords + inTri->baseUVIndices.indices[0], vertexList + inTri->vertexIndices.indices[0]); - + MGmConvertVertex_UV( u_scale, v_scale, 0, textureCoords + inTri->baseUVIndices.indices[1], vertexList + inTri->vertexIndices.indices[1]); - + MGmConvertVertex_UV( u_scale, v_scale, 0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Triangle.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Triangle.h index c402867..ebdc2fb 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Triangle.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Method_Triangle.h @@ -1,12 +1,12 @@ /* FILE: MG_DC_Method_Triangle.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -14,7 +14,7 @@ #define MG_DC_METHOD_TRIANGLE_H // Triangle functions - void + void MGrTriangle_Point( M3tTri* inTri); @@ -51,76 +51,76 @@ M3tTri* inTri); // Trisplit functions - + // texture lit - + // interp none - + void MGrTriSplit_Solid_TextureLit_InterpNone_LMOff( M3tTriSplit* inTri); - + void MGrTriSplit_Solid_TextureLit_InterpNone_LMOn_1TMU( M3tTriSplit* inTri); - + void MGrTriSplit_Solid_TextureLit_InterpNone_LMOn_2TMU( M3tTriSplit* inTri); - + void MGrTriSplit_Solid_TextureLit_InterpNone_LMOnly_1TMU( M3tTriSplit* inTri); - + void MGrTriSplit_Solid_TextureLit_InterpNone_LMOnly_2TMU( M3tTriSplit* inTri); - - + + // interp vertex - + void MGrTriSplit_Solid_TextureLit_InterpVertex_LMOff( M3tTriSplit* inTri); - + void MGrTriSplit_Solid_TextureLit_InterpVertex_LMOn_1TMU( M3tTriSplit* inTri); - + void MGrTriSplit_Solid_TextureLit_InterpVertex_LMOn_2TMU( M3tTriSplit* inTri); - + void MGrTriSplit_Solid_TextureLit_InterpVertex_LMOnly_1TMU( M3tTriSplit* inTri); - + void MGrTriSplit_Solid_TextureLit_InterpVertex_LMOnly_2TMU( M3tTriSplit* inTri); // texture unlit - + void MGrTriSplit_Solid_TextureUnlit_LMOff( M3tTriSplit* inTri); - + void MGrTriSplit_Solid_TextureUnlit_LMOn_1TMU( M3tTriSplit* inTri); - + void MGrTriSplit_Solid_TextureUnlit_LMOn_2TMU( M3tTriSplit* inTri); - + void MGrTriSplit_Solid_TextureUnlit_LMOnly_1TMU( M3tTriSplit* inTri); - + void MGrTriSplit_Solid_TextureUnlit_LMOnly_2TMU( M3tTriSplit* inTri); - - + + #endif /* MG_DC_METHOD_TRIANGLE_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Mode.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Mode.c index 4867f37..61bce63 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Mode.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Mode.c @@ -1,12 +1,12 @@ /* FILE: MG_DC_Mode.c - + AUTHOR: Brent Pease - + CREATED: July 31, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Mode.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Mode.h index 9e5b0bb..0f35869 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Mode.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Mode.h @@ -1,12 +1,12 @@ /* FILE: MG_DC_Mode.h - + AUTHOR: Brent Pease - + CREATED: July 31, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Private.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Private.h index 92b242b..b448ed2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DC_Private.h @@ -1,12 +1,12 @@ /* FILE: MG_DrawContext_Private.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 17, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -33,9 +33,9 @@ typedef enum MGtDrawState_TMU { MGcDrawState_TMU_1, MGcDrawState_TMU_2, - + MGcDrawState_TMU_Num - + } MGtDrawState_TMU; // 3dfx tells you to do this; check manual for details (don't take it out) @@ -77,7 +77,7 @@ extern float MGg5BitsTo0_255FloatTable[32]; (glide_vertex)->y= SNAP_COORD((m_vertex)->y); \ (glide_vertex)->ooz= 65535.f / (m_vertex)->z; \ (glide_vertex)->oow= (m_vertex)->invW; \ - UUmBlankFunction + UUmBlankFunction #else @@ -85,7 +85,7 @@ extern float MGg5BitsTo0_255FloatTable[32]; (glide_vertex)->x= SNAP_COORD((m_vertex)->x); \ (glide_vertex)->y= SNAP_COORD((m_vertex)->y); \ (glide_vertex)->oow= (m_vertex)->invW; \ - UUmBlankFunction + UUmBlankFunction #endif @@ -95,46 +95,46 @@ extern float MGg5BitsTo0_255FloatTable[32]; (glide_vertex)->r = UUmPin((255.f / ((float) 0x1f) * (((m_color) & (0x1f << 10)) >> 10)), 0.f, 255.f); \ (glide_vertex)->g = UUmPin((255.f / ((float) 0x1f) * (((m_color) & (0x1f << 5)) >> 5)), 0.f, 255.f); \ (glide_vertex)->b = UUmPin((255.f / ((float) 0x1f) * (((m_color) & (0x1f << 0)) >> 0)), 0.f, 255.f); \ - UUmBlankFunction + UUmBlankFunction #else #define MGmConvertVertex_RGB(m_color, glide_vertex) \ (glide_vertex)->a = 0.0f; \ (glide_vertex)->r = (float)(((m_color) >> 16) & 0xFF); \ (glide_vertex)->g = (float)(((m_color) >> 8) & 0xFF); \ (glide_vertex)->b = (float)(((m_color) >> 0) & 0xFF); \ - UUmBlankFunction + UUmBlankFunction #endif #define MGmConvertVertex_UV(u_scale, v_scale, glide_tmu, m_texture_coord, glide_vertex) \ (glide_vertex)->tmuvtx[glide_tmu].sow= (u_scale*(m_texture_coord)->u)*(glide_vertex)->oow; \ (glide_vertex)->tmuvtx[glide_tmu].tow= (v_scale*(m_texture_coord)->v)*(glide_vertex)->oow; \ - UUmBlankFunction + UUmBlankFunction #define MGmConvertVertex_UV_LM(u_scale_base, v_scale_base, u_scale_light, v_scale_light, m_base_texture_coord, m_light_texture_coord, glide_vertex) \ MGmConvertVertex_UV(u_scale_base, v_scale_base, 0, m_base_texture_coord, glide_vertex); \ MGmConvertVertex_UV(u_scale_light, v_scale_light, 1, m_light_texture_coord, glide_vertex); \ - - + + #define MGmConvertVertex_XYZUV(m_vertex, u_scale_base, v_scale_base, m_texture_coord, glide_vertex) \ MGmConvertVertex_XYZ(m_vertex, glide_vertex); \ MGmConvertVertex_UV(u_scale_base, v_scale_base, 0, m_texture_coord, glide_vertex); \ - UUmBlankFunction + UUmBlankFunction #define MGmConvertVertex_XYZUVRGB(m_vertex, u_scale_base, v_scale_base, m_texture_coord, m_color, glide_vertex) \ MGmConvertVertex_XYZUV(m_vertex, u_scale_base, v_scale_base, m_texture_coord, glide_vertex); \ MGmConvertVertex_RGB(m_color, glide_vertex); \ - UUmBlankFunction + UUmBlankFunction #define MGmConvertVertex_XYZUVRGBEnvMap(m_vertex, u_scale_base, v_scale_base, m_texture_coord, u_scale_env, v_scale_env, m_env_texture_coord, m_color, glide_vertex) \ MGmConvertVertex_XYZUV(m_vertex, u_scale_base, v_scale_base, m_texture_coord, glide_vertex); \ MGmConvertVertex_UV(u_scale_env, v_scale_env, 1, m_env_texture_coord, glide_vertex); \ MGmConvertVertex_RGB(m_color, glide_vertex); \ - UUmBlankFunction + UUmBlankFunction #define MGmConvertVertex_XYZRGB(m_vertex, m_color, glide_vertex) \ MGmConvertVertex_XYZ(m_vertex, glide_vertex); \ MGmConvertVertex_RGB(m_color, glide_vertex); \ - UUmBlankFunction + UUmBlankFunction #define MGmSplatVertex_XYZ(index) \ if(index >= numRealVertices) \ @@ -144,7 +144,7 @@ extern float MGg5BitsTo0_255FloatTable[32]; vertexList + index); \ } \ UUmBlankFunction - + #define MGmSplatVertex_XYZRGB(index) \ if(index >= numRealVertices) \ { \ @@ -154,7 +154,7 @@ extern float MGg5BitsTo0_255FloatTable[32]; vertexList + index); \ } \ UUmBlankFunction - + #define MGmSplatVertex_XYZUV(index) \ if(index >= numRealVertices) \ { \ @@ -179,7 +179,7 @@ extern float MGg5BitsTo0_255FloatTable[32]; vertexList + index); \ } \ UUmBlankFunction - + #define MGmSplatVertex_XYZUVRGBEnvMap(index) \ if(index >= numRealVertices) \ { \ @@ -195,7 +195,7 @@ extern float MGg5BitsTo0_255FloatTable[32]; vertexList + index); \ } \ UUmBlankFunction - + #define MGmGetScreenPoints(MGgDrawContextPrivate) ((M3tPointScreen*) ((MGgDrawContextPrivate)->statePtr[M3cDrawStatePtrType_ScreenPointArray])) @@ -253,25 +253,25 @@ typedef struct MGtStatePrivate { GrVertex* vertexList; UUtUns32* vertexListBV; - + } MGtStatePrivate; struct MGtDrawContextPrivate { long width; long height; - + M3tDrawContextType contextType; - + GrVertex* vertexList; //UUtUns32* vertexListBV; - + const MGtTextureMapPrivate* curBaseTexture; const UUtInt32* stateInt; const void** statePtr; - + UUtBool clipping; - + //MGtTextureMapPrivate* lastTexture; }; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method.c index a0bc482..b62ef16 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method.c @@ -1,12 +1,12 @@ /* FILE: MG_DrawEngine_Method.c - + AUTHOR: Kevin Armstrong, Michael Evans - + CREATED: January 5, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1998 */ @@ -46,7 +46,7 @@ // since the table needs to grow when M3cNumTextureTypes changes // this array is in order i.e. the left column is 0..6 it is direct looked up -static const MGtTexelTypeInfo MGgTexInfoTable[] = +static const MGtTexelTypeInfo MGgTexInfoTable[] = { { IMcPixelType_ARGB4444, MGcTextureValid, MGcTextureExpansion_No, MGcTextureAlpha_Yes, GR_TEXFMT_ARGB_4444 }, { IMcPixelType_RGB555, MGcTextureValid, MGcTextureExpansion_No, MGcTextureAlpha_No, GR_TEXFMT_ARGB_1555 }, @@ -134,7 +134,7 @@ const MGtTexelTypeInfo *MGrTexelType_GetInfo(IMtPixelType inTexelType) UUmAssert(MGgSizeofPixelInfoTable == IMcNumPixelTypes); UUmAssert(inTexelType <= IMcNumPixelTypes); UUmAssert(inTexelType >= 0); - + texInfo = MGgTexInfoTable + inTexelType; UUmAssert(texInfo->texelType == inTexelType); @@ -158,7 +158,7 @@ MGiTextureMap_BuildPrivate( short glide_level_of_detail_min; short glide_aspect_ratio; UUtUns16 widthNBits, heightNBits; - + UUmAssertReadPtr(inTextureMap, sizeof(*inTextureMap)); UUmAssertWritePtr(outPrivate, sizeof(*outPrivate)); UUmAssert(0 == (inTextureMap->flags & M3cTextureFlags_Offscreen)); @@ -167,10 +167,10 @@ MGiTextureMap_BuildPrivate( UUmAssert((inTextureMap->height >= 1) && (inTextureMap->height <= 256)); widthNBits = heightNBits = 15; - + while(!(inTextureMap->width & (1 << widthNBits))) widthNBits--; while(!(inTextureMap->height & (1 << heightNBits))) heightNBits--; - + UUmAssert(inTextureMap->width == 1 << widthNBits); UUmAssert(inTextureMap->height == 1 << heightNBits); @@ -219,7 +219,7 @@ MGiTextureMap_BuildPrivate( { case GR_ASPECT_8x1: case GR_ASPECT_1x8: - glide_level_of_detail_min = GR_LOD_8; + glide_level_of_detail_min = GR_LOD_8; break; case GR_ASPECT_4x1: @@ -265,7 +265,7 @@ MGiTextureMap_BuildPrivate( outPrivate->flags |= (MGcTextureExpansion_Yes == texelTypeInfo->textureExpansion) ? MGcTextureFlag_Expansion: 0; outPrivate->width = inTextureMap->width; outPrivate->height = inTextureMap->height; - + return; } @@ -319,7 +319,7 @@ static void MGiTextureMap_ClearTMUInfo(MGtTextureMapPrivate *outPrivate) outPrivate->hardware_block_index_tmu1= NONE; outPrivate->hardware_block_index_tmu1_odd = NONE; -#if 0 // these values are valid only for uploaded +#if 0 // these values are valid only for uploaded outPrivate->hardware_block_dirty_tmu0 = UUcTrue; outPrivate->hardware_block_dirty_tmu0_even = UUcTrue; outPrivate->hardware_block_dirty_tmu1 = UUcTrue; @@ -344,13 +344,13 @@ MGrDrawEngine_Method_Texture_Init( // always set this, even if this is an invalid texture (or offscreen for that matter) MGiTextureMap_ClearTMUInfo(inTextureMapPrivate); - + // is this an offscreen texture if (inTextureMap->flags & M3cTextureFlags_Offscreen) return UUcError_None; // build the private data (does not include the TMU data) MGiTextureMap_BuildPrivate(inTextureMap, inTextureMapPrivate); - + return UUcError_None; } @@ -389,7 +389,7 @@ MGrDrawEngine_Method_Texture_Delete( // is this an offscreen texture if (inTextureMap->flags & M3cTextureFlags_Offscreen) return UUcError_None; - + if ((globals_3dfx.texture_memory_cache_tmu0 != NULL) && (inTextureMapPrivate->hardware_block_index_tmu0 != NONE)) { lrar_deallocate(globals_3dfx.texture_memory_cache_tmu0, inTextureMapPrivate->hardware_block_index_tmu0); @@ -399,7 +399,7 @@ MGrDrawEngine_Method_Texture_Delete( { lrar_deallocate(globals_3dfx.texture_memory_cache_tmu1, inTextureMapPrivate->hardware_block_index_tmu1); } - + return UUcError_None; } @@ -412,7 +412,7 @@ MGiDrawEngine_TextureMap_ProcHandler( M3tTextureMap *inTexture = (M3tTextureMap*)inInstancePtr; UUtError error; -{ +{ void MGrDrawContext_VerifyCaches( void); @@ -427,29 +427,29 @@ MGiDrawEngine_TextureMap_ProcHandler( error = MGrDrawEngine_Method_Texture_Init(inTexture, (MGtTextureMapPrivate*)inPrivateData); UUmError_ReturnOnError(error); break; - + case TMcTemplateProcMessage_LoadPostProcess: M3rTextureMap_Prepare(inTexture); error = MGrDrawEngine_Method_Texture_Init(inTexture, (MGtTextureMapPrivate*)inPrivateData); UUmError_ReturnOnError(error); break; - + case TMcTemplateProcMessage_DisposePreProcess: error = MGrDrawEngine_Method_Texture_Delete(inTexture, (MGtTextureMapPrivate*)inPrivateData); UUmError_ReturnOnError(error); break; - + case TMcTemplateProcMessage_Update: error = MGrDrawEngine_Method_Texture_Update(inTexture, (MGtTextureMapPrivate*)inPrivateData); UUmError_ReturnOnError(error); break; - + case TMcTemplateProcMessage_PrepareForUse: break; } - -{ + +{ void MGrDrawContext_VerifyCaches( void); @@ -457,7 +457,7 @@ MGiDrawEngine_TextureMap_ProcHandler( } return UUcError_None; } - + // ---------------------------------------------------------------------- @@ -466,13 +466,13 @@ MGrDrawEngine_Method_ContextPrivateDelete( void) { UUmAssertReadPtr(MGgDrawEngine_TexureMap_PrivateData, sizeof(void*)); - + TMrTemplate_PrivateData_Delete(MGgDrawEngine_TexureMap_PrivateData); MGgDrawEngine_TexureMap_PrivateData = NULL; - + // grsstclose dispose_3dfx(); - + UUrMemory_Block_Delete(MGgDrawContextPrivate); MGgDrawContextPrivate = NULL; } @@ -491,26 +491,26 @@ MGrDrawEngine_Method_ContextPrivateNew( UUtUns16 activeDevice; UUtUns16 activeMode; M3tDrawEngineCaps* drawEngineCaps; - + UUmAssert(MGgDrawContextPrivate == NULL); - + MGgDrawContextPrivate = UUrMemory_Block_New(sizeof(MGtDrawContextPrivate)); - + if(MGgDrawContextPrivate == NULL) { UUrError_Report(UUcError_OutOfMemory, "Could not allocated private draw context"); return UUcError_OutOfMemory; } - + /* * Get the active draw engine info */ - + M3rManager_GetActiveDrawEngine( &activeDrawEngine, &activeDevice, &activeMode); - + drawEngineCaps = M3rDrawEngine_GetCaps(activeDrawEngine); *outAPI = M3cDrawAPI_Glide; @@ -531,23 +531,23 @@ MGrDrawEngine_Method_ContextPrivateNew( MGgDrawContextMethods.screenCapture = MGrDrawContext_Method_ScreenCapture; MGgDrawContextMethods.pointVisible = MGrDrawContext_Method_PointVisible; MGgDrawContextMethods.textureFormatAvailable = MGrDrawContext_TextureFormatAvailable; - + *outDrawContextFuncs = &MGgDrawContextMethods; - + MGgDrawContextPrivate->contextType = inDrawContextDescriptor->type; - + MGgDrawContextPrivate->width= drawEngineCaps[activeDrawEngine].displayDevices[activeDevice].displayModes[activeMode].width; MGgDrawContextPrivate->height= drawEngineCaps[activeDrawEngine].displayDevices[activeDevice].displayModes[activeMode].height; - + initialize_3dfx( MGgMotokoToGlideScreenRes[activeMode]); - + // Init some state MGgDrawContextPrivate->vertexList = NULL; MGgDrawContextPrivate->curBaseTexture = NULL; - + // create the texture private data - error = + error = TMrTemplate_PrivateData_New( M3cTemplate_TextureMap, sizeof(MGtTextureMapPrivate), @@ -555,13 +555,13 @@ MGrDrawEngine_Method_ContextPrivateNew( &MGgDrawEngine_TexureMap_PrivateData); UUmError_ReturnOnError(error); - + return UUcError_None; - + //failure: - + MGrDrawEngine_Method_ContextPrivateDelete(); - + return errorCode; } @@ -577,36 +577,36 @@ MGrDrawEngine_Method_PrivateState_New( void* inState_Private) { MGtStatePrivate* statePrivate = (MGtStatePrivate*)inState_Private; - + statePrivate->vertexList = NULL; statePrivate->vertexListBV = NULL; - + statePrivate->vertexList = UUrMemory_Block_New(MGcMaxElements * sizeof(GrVertex)); UUmError_ReturnOnNull(statePrivate->vertexList); - + statePrivate->vertexListBV = UUrBitVector_New(MGcMaxElements); UUmError_ReturnOnNull(statePrivate->vertexListBV); - + return UUcError_None; } // This lets the engine delete a new private state structure -static void +static void MGrDrawEngine_Method_PrivateState_Delete( void* inState_Private) { MGtStatePrivate* statePrivate = (MGtStatePrivate*)inState_Private; - + if(statePrivate->vertexList != NULL) { UUrMemory_Block_Delete(statePrivate->vertexList); } - + if(statePrivate->vertexListBV != NULL) { UUrBitVector_Dispose(statePrivate->vertexListBV); } - + statePrivate->vertexList = NULL; statePrivate->vertexListBV = NULL; } @@ -626,11 +626,11 @@ MGrDrawEngine_Method_State_Update( UUtUns16 interpolation; UUtUns16 tmuMode; M3tDrawStateVertexFormat vertexMode; - + MGgDrawContextPrivate->vertexList = statePrivate->vertexList; MGgDrawContextPrivate->stateInt = inState_Int; MGgDrawContextPrivate->statePtr = inState_Ptr; - + if(inState_IntFlags & (1 << M3cDrawStateIntType_ZCompare)) { if(inState_Int[M3cDrawStateIntType_ZCompare] == M3cDrawState_ZCompare_On) @@ -646,7 +646,7 @@ MGrDrawEngine_Method_State_Update( grDepthBufferFunction(GR_CMP_ALWAYS); } } - + if(inState_IntFlags & (1 << M3cDrawStateIntType_ZWrite)) { if(inState_Int[M3cDrawStateIntType_ZWrite] == M3cDrawState_ZWrite_On) @@ -658,14 +658,14 @@ MGrDrawEngine_Method_State_Update( MGrSet_ZWrite(MGcZWrite_Off); } } - - if((inState_Int[M3cDrawStateIntType_Appearence] != M3cDrawState_Appearence_Gouraud) && + + if((inState_Int[M3cDrawStateIntType_Appearence] != M3cDrawState_Appearence_Gouraud) && (inState_Int[M3cDrawStateIntType_Fill] == M3cDrawState_Fill_Solid)) { if(inState_PtrFlags & (1 << M3cDrawStatePtrType_BaseTextureMap)) { M3tTextureMap* textureMap = (M3tTextureMap*)inState_Ptr[M3cDrawStatePtrType_BaseTextureMap]; - + if(textureMap != NULL) { MGrSet_TextureMode(textureMap); @@ -680,27 +680,27 @@ MGrDrawEngine_Method_State_Update( { MGgDrawContextPrivate->curBaseTexture = NULL; } - + if(inState_IntFlags & ((1 << M3cDrawStateIntType_ConstantColor) | (1 << M3cDrawStateIntType_Alpha))) { UUtUns32 alpha = inState_Int[M3cDrawStateIntType_Alpha]; - UUtUns32 glideColor; + UUtUns32 glideColor; UUmAssert(alpha <= 0xff); - - glideColor = - (alpha & 0xff) << 24 | + + glideColor = + (alpha & 0xff) << 24 | (inState_Int[M3cDrawStateIntType_ConstantColor] & 0x00ffffff); grConstantColorValue(glideColor); } - + fill = (UUtUns16)inState_Int[M3cDrawStateIntType_Fill]; appearance = (UUtUns16)inState_Int[M3cDrawStateIntType_Appearence]; interpolation = (UUtUns16)inState_Int[M3cDrawStateIntType_Interpolation]; tmuMode = (UUtUns16)globals_3dfx.numTMU - 1; vertexMode = (M3tDrawStateVertexFormat)inState_Int[M3cDrawStateIntType_VertexFormat]; - + if(inState_IntFlags & ( (1 << M3cDrawStateIntType_Appearence) | (1 << M3cDrawStateIntType_Interpolation) | @@ -710,7 +710,7 @@ MGrDrawEngine_Method_State_Update( MGtModeFunction modeFunction; MGgDrawContextMethods.line = MGgLineFuncs[interpolation]; - + if(vertexMode == M3cDrawStateVertex_Unified) { MGgDrawContextMethods.triangle = (M3tDrawContextMethod_Triangle)MGgTriangleFuncs_VertexUnified[fill][appearance][interpolation]; @@ -720,7 +720,7 @@ MGrDrawEngine_Method_State_Update( modeFunction = MGgModeFuncs_VertexUnified[fill][appearance][interpolation]; } else if(vertexMode == M3cDrawStateVertex_Split) - { + { MGgDrawContextMethods.triangle = (M3tDrawContextMethod_Triangle)MGgTriangleFuncs_VertexSplit[fill][appearance][interpolation][tmuMode]; MGgDrawContextMethods.quad = (M3tDrawContextMethod_Quad)MGgQuadFuncs_VertexSplit[fill][appearance][interpolation][tmuMode]; MGgDrawContextMethods.pent = (M3tDrawContextMethod_Pent)MGgPentFuncs_VertexSplit[fill][appearance][interpolation][tmuMode]; @@ -731,22 +731,22 @@ MGrDrawEngine_Method_State_Update( { UUmAssert(!"Illegal vertex mode"); } - + modeFunction(); - + } - + if(interpolation == M3cDrawState_Interpolation_Vertex && appearance == M3cDrawState_Appearence_Texture_Lit) { UUmAssert(globals_3dfx.currentColorCombine == MGcColorCombine_TextureGouraud); } - + if(inState_PtrFlags & (1 << M3cDrawStatePtrType_ScreenPointArray)) { if(inState_Int[M3cDrawStateIntType_NumRealVertices] > 0) { MGtVertexCreateFunction vertexCreateFunction; - + if(inState_Int[M3cDrawStateIntType_VertexFormat] == M3cDrawStateVertex_Unified) { vertexCreateFunction = MGgVertexCreateFuncs_Unified[appearance][interpolation]; @@ -755,13 +755,13 @@ MGrDrawEngine_Method_State_Update( { vertexCreateFunction = MGgVertexCreateFuncs_Split[appearance][interpolation][tmuMode]; } - + vertexCreateFunction(); } } - + MGgDrawContextPrivate->clipping = (UUtBool)inState_Int[M3cDrawStateIntType_Clipping]; - + MGgBufferClear = (UUtBool) inState_Int[M3cDrawStateIntType_BufferClear]; MGgDoubleBuffer = (UUtBool) inState_Int[M3cDrawStateIntType_DoubleBuffer]; @@ -776,10 +776,10 @@ MGrDrawEngine_Initialize( void) { UUtError error; - + UUtUns16 curDisplayModeIndex; UUtUns16 itr; - + // available_3dfx() loads the glide DLL and must be called before // initialize_3dfx(). if (!available_3dfx()) @@ -796,22 +796,22 @@ MGrDrawEngine_Initialize( MGgDrawEngineMethods.contextPrivateNew = MGrDrawEngine_Method_ContextPrivateNew; MGgDrawEngineMethods.contextPrivateDelete = MGrDrawEngine_Method_ContextPrivateDelete; MGgDrawEngineMethods.textureResetAll = MGrDrawEngine_Method_Texture_ResetAll; - + MGgDrawEngineMethods.privateStateSize = sizeof(MGtStatePrivate); MGgDrawEngineMethods.privateStateNew = MGrDrawEngine_Method_PrivateState_New; MGgDrawEngineMethods.privateStateDelete = MGrDrawEngine_Method_PrivateState_Delete; MGgDrawEngineMethods.privateStateUpdate = MGrDrawEngine_Method_State_Update; - + MGgDrawEngineCaps.engineFlags = M3cDrawEngineFlag_3DOnly; - + UUrString_Copy(MGgDrawEngineCaps.engineName, M3cDrawEngine_3DFX_Glide2x, M3cMaxNameLen); MGgDrawEngineCaps.engineDriver[0] = 0; - + MGgDrawEngineCaps.engineVersion = MGcSoftware_Version; - + MGgDrawEngineCaps.numDisplayDevices = 1; MGgDrawEngineCaps.displayDevices[0].numDisplayModes = 0; - + for(itr = 0; MGgPixelFormatTable[itr].glideID != GR_RESOLUTION_NONE && itr < M3cMaxDisplayModes; itr++) @@ -820,15 +820,15 @@ MGrDrawEngine_Initialize( MGgFrameBufferBytes) { curDisplayModeIndex = MGgDrawEngineCaps.displayDevices[0].numDisplayModes++; - MGgDrawEngineCaps.displayDevices[0].displayModes[curDisplayModeIndex].width = + MGgDrawEngineCaps.displayDevices[0].displayModes[curDisplayModeIndex].width = MGgPixelFormatTable[itr].width; - MGgDrawEngineCaps.displayDevices[0].displayModes[curDisplayModeIndex].height = + MGgDrawEngineCaps.displayDevices[0].displayModes[curDisplayModeIndex].height = MGgPixelFormatTable[itr].height; MGgDrawEngineCaps.displayDevices[0].displayModes[curDisplayModeIndex].bitDepth = 16; MGgMotokoToGlideScreenRes[curDisplayModeIndex] = MGgPixelFormatTable[itr].glideID; } } - + error = M3rManager_Register_DrawEngine( &MGgDrawEngineCaps, @@ -856,29 +856,29 @@ MGrDrawContext_Method_Frame_Start( { //MGgDrawContextPrivate->stateFlags = 0xFF; - + if (MGgBufferClear) { erase_backbuffer_3dfx(); } start_rasterizing_3dfx(); - + MGgTextureBytesDownloaded = 0; - + return UUcError_None; } - + // ---------------------------------------------------------------------- UUtError MGrDrawContext_Method_Frame_End( UUtUns32 *outTextureBytesDownloaded) { - + *outTextureBytesDownloaded = MGgTextureBytesDownloaded; stop_rasterizing_3dfx(); display_backbuffer_3dfx(); - + return UUcError_None; } @@ -901,4 +901,4 @@ MGrDrawContext_VerifyCaches( verify_lrar_cache(globals_3dfx.texture_memory_cache_tmu0); verify_lrar_cache(globals_3dfx.texture_memory_cache_tmu1); #endif -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method.h index ddc83c1..0154f56 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method.h @@ -1,12 +1,12 @@ /* FILE: MG_DrawEngine_Method.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method_Ptrs.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method_Ptrs.c index 210a4b4..61f2421 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method_Ptrs.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method_Ptrs.c @@ -1,12 +1,12 @@ /* FILE: MG_DrawEngine_Method_Ptrs.c - + AUTHOR: Brent Pease - + CREATED: July 31, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1999 */ @@ -27,7 +27,7 @@ M3tDrawContextMethod_Line MGgLineFuncs[M3cDrawState_Interpolation_Num] = { // M3cDrawState_Interpolation_None MGrLine_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrLine_InterpVertex }; @@ -43,113 +43,113 @@ MGtDrawTri MGgTriangleFuncs_VertexUnified { // M3cDrawState_Interpolation_None MGrTriangle_Point, - + // M3cDrawState_Interpolation_Vertex MGrTriangle_Point }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrTriangle_Point, - + // M3cDrawState_Interpolation_Vertex MGrTriangle_Point }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrTriangle_Point, - + // M3cDrawState_Interpolation_Vertex MGrTriangle_Point }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None MGrTriangle_Point, - + // M3cDrawState_Interpolation_Vertex MGrTriangle_Point } }, - + // M3cDrawState_Fill_Line { // M3cDrawState_Appearence_Gouraud { // M3cDrawState_Interpolation_None MGrTriangle_Line_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrTriangle_Line_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrTriangle_Line_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrTriangle_Line_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrTriangle_Line_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrTriangle_Line_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None MGrTriangle_Line_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrTriangle_Line_InterpNone } - + }, - + // M3cDrawState_Fill_Solid { // M3cDrawState_Appearence_Gouraud { // M3cDrawState_Interpolation_None MGrTriangle_Solid_Gouraud_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrTriangle_Solid_Gouraud_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrTriangle_Solid_TextureLit_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrTriangle_Solid_TextureLit_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrTriangle_Solid_TextureLit_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrTriangle_Solid_TextureLit_EnvMap_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None MGrTriangle_Solid_TextureUnlit, - + // M3cDrawState_Interpolation_Vertex MGrTriangle_Solid_TextureUnlit } @@ -172,7 +172,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawTriSplit)MGrTriangle_Point, (MGtDrawTriSplit)MGrTriangle_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -180,7 +180,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit (MGtDrawTriSplit)MGrTriangle_Point, (MGtDrawTriSplit)MGrTriangle_Point } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -189,7 +189,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawTriSplit)MGrTriangle_Point, (MGtDrawTriSplit)MGrTriangle_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -197,7 +197,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit (MGtDrawTriSplit)MGrTriangle_Point, (MGtDrawTriSplit)MGrTriangle_Point } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -206,7 +206,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawTriSplit)MGrTriangle_Point, (MGtDrawTriSplit)MGrTriangle_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -214,7 +214,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit (MGtDrawTriSplit)MGrTriangle_Point, (MGtDrawTriSplit)MGrTriangle_Point } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -223,7 +223,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawTriSplit)MGrTriangle_Point, (MGtDrawTriSplit)MGrTriangle_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -231,9 +231,9 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit (MGtDrawTriSplit)MGrTriangle_Point, (MGtDrawTriSplit)MGrTriangle_Point } } - + }, - + // M3cDrawState_Fill_Line { // M3cDrawState_Appearence_Gouraud @@ -244,7 +244,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawTriSplit)MGrTriangle_Line_InterpNone, (MGtDrawTriSplit)MGrTriangle_Line_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -252,7 +252,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit (MGtDrawTriSplit)MGrTriangle_Line_InterpVertex, (MGtDrawTriSplit)MGrTriangle_Line_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -261,7 +261,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawTriSplit)MGrTriangle_Line_InterpNone, (MGtDrawTriSplit)MGrTriangle_Line_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -269,7 +269,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit (MGtDrawTriSplit)MGrTriangle_Line_InterpVertex, (MGtDrawTriSplit)MGrTriangle_Line_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -278,7 +278,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawTriSplit)MGrTriangle_Line_InterpNone, (MGtDrawTriSplit)MGrTriangle_Line_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -286,7 +286,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit (MGtDrawTriSplit)MGrTriangle_Line_InterpVertex, (MGtDrawTriSplit)MGrTriangle_Line_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -295,7 +295,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawTriSplit)MGrTriangle_Line_InterpNone, (MGtDrawTriSplit)MGrTriangle_Line_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -304,7 +304,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit } } }, - + // M3cDrawState_Fill_Solid { // M3cDrawState_Appearence_Gouraud @@ -315,7 +315,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit // 1 TMU 2 TMU (MGtDrawTriSplit)MGrTriangle_Solid_Gouraud_InterpNone, (MGtDrawTriSplit)MGrTriangle_Solid_Gouraud_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -323,7 +323,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit (MGtDrawTriSplit)MGrTriangle_Solid_Gouraud_InterpVertex, (MGtDrawTriSplit)MGrTriangle_Solid_Gouraud_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -332,7 +332,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit // 1TMU // 2 TMU MGrTriSplit_Solid_TextureLit_InterpNone_LMOff, MGrTriSplit_Solid_TextureLit_InterpNone_LMOff }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -340,7 +340,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit MGrTriSplit_Solid_TextureLit_InterpVertex_LMOff, MGrTriSplit_Solid_TextureLit_InterpVertex_LMOff } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -349,7 +349,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit // 1TMU // 2 TMU MGrTriSplit_Solid_TextureLit_InterpNone_LMOff, MGrTriSplit_Solid_TextureLit_InterpNone_LMOff }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -357,7 +357,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit MGrTriSplit_Solid_TextureLit_InterpVertex_LMOff, MGrTriSplit_Solid_TextureLit_InterpVertex_LMOff } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -366,7 +366,7 @@ MGtDrawTriSplit MGgTriangleFuncs_VertexSplit // 1TMU // 2 TMU MGrTriSplit_Solid_TextureUnlit_LMOff, MGrTriSplit_Solid_TextureUnlit_LMOff }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -388,114 +388,114 @@ MGtDrawQuad MGgQuadFuncs_VertexUnified { // M3cDrawState_Interpolation_None MGrQuad_Point, - + // M3cDrawState_Interpolation_Vertex MGrQuad_Point }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrQuad_Point, - + // M3cDrawState_Interpolation_Vertex MGrQuad_Point }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrQuad_Point, - + // M3cDrawState_Interpolation_Vertex MGrQuad_Point }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None MGrQuad_Point, - + // M3cDrawState_Interpolation_Vertex MGrQuad_Point } - + }, - + // M3cDrawState_Fill_Line { // M3cDrawState_Appearence_Gouraud { // M3cDrawState_Interpolation_None MGrQuad_Line_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrQuad_Line_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrQuad_Line_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrQuad_Line_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrQuad_Line_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrQuad_Line_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None MGrQuad_Line_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrQuad_Line_InterpNone } - + }, - + // M3cDrawState_Fill_Solid { // M3cDrawState_Appearence_Gouraud { // M3cDrawState_Interpolation_None MGrQuad_Solid_Gouraud_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrQuad_Solid_Gouraud_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrQuad_Solid_TextureLit_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrQuad_Solid_TextureLit_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrQuad_Solid_TextureLit_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrQuad_Solid_TextureLit_EnvMap_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None MGrQuad_Solid_TextureUnlit, - + // M3cDrawState_Interpolation_Vertex MGrQuad_Solid_TextureUnlit } @@ -519,7 +519,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawQuadSplit)MGrQuad_Point, (MGtDrawQuadSplit)MGrQuad_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -527,7 +527,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit (MGtDrawQuadSplit)MGrQuad_Point, (MGtDrawQuadSplit)MGrQuad_Point } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -536,7 +536,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawQuadSplit)MGrQuad_Point, (MGtDrawQuadSplit)MGrQuad_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -544,7 +544,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit (MGtDrawQuadSplit)MGrQuad_Point, (MGtDrawQuadSplit)MGrQuad_Point } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -553,7 +553,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawQuadSplit)MGrQuad_Point, (MGtDrawQuadSplit)MGrQuad_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -561,7 +561,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit (MGtDrawQuadSplit)MGrQuad_Point, (MGtDrawQuadSplit)MGrQuad_Point } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -570,7 +570,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawQuadSplit)MGrQuad_Point, (MGtDrawQuadSplit)MGrQuad_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -578,9 +578,9 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit (MGtDrawQuadSplit)MGrQuad_Point, (MGtDrawQuadSplit)MGrQuad_Point } } - + }, - + // M3cDrawState_Fill_Line { // M3cDrawState_Appearence_Gouraud @@ -591,7 +591,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawQuadSplit)MGrQuad_Line_InterpNone, (MGtDrawQuadSplit)MGrQuad_Line_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -599,7 +599,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit (MGtDrawQuadSplit)MGrQuad_Line_InterpVertex, (MGtDrawQuadSplit)MGrQuad_Line_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -608,7 +608,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawQuadSplit)MGrQuad_Line_InterpNone, (MGtDrawQuadSplit)MGrQuad_Line_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -616,7 +616,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit (MGtDrawQuadSplit)MGrQuad_Line_InterpVertex, (MGtDrawQuadSplit)MGrQuad_Line_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -625,7 +625,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawQuadSplit)MGrQuad_Line_InterpNone, (MGtDrawQuadSplit)MGrQuad_Line_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -633,7 +633,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit (MGtDrawQuadSplit)MGrQuad_Line_InterpVertex, (MGtDrawQuadSplit)MGrQuad_Line_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -642,7 +642,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawQuadSplit)MGrQuad_Line_InterpNone, (MGtDrawQuadSplit)MGrQuad_Line_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -651,7 +651,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit } } }, - + // M3cDrawState_Fill_Solid { // M3cDrawState_Appearence_Gouraud @@ -662,7 +662,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit // 1 TMU 2 TMU (MGtDrawQuadSplit)MGrQuad_Solid_Gouraud_InterpNone, (MGtDrawQuadSplit)MGrQuad_Solid_Gouraud_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -670,7 +670,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit (MGtDrawQuadSplit)MGrQuad_Solid_Gouraud_InterpVertex, (MGtDrawQuadSplit)MGrQuad_Solid_Gouraud_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -679,7 +679,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit // 1TMU // 2 TMU MGrQuadSplit_Solid_TextureLit_InterpNone_LMOff, MGrQuadSplit_Solid_TextureLit_InterpNone_LMOff }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -687,7 +687,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit MGrQuadSplit_Solid_TextureLit_InterpVertex_LMOff, MGrQuadSplit_Solid_TextureLit_InterpVertex_LMOff } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -696,7 +696,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit // 1TMU // 2 TMU MGrQuadSplit_Solid_TextureLit_InterpNone_LMOff, MGrQuadSplit_Solid_TextureLit_InterpNone_LMOff }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -704,7 +704,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit MGrQuadSplit_Solid_TextureLit_InterpVertex_LMOff, MGrQuadSplit_Solid_TextureLit_InterpVertex_LMOff } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -713,7 +713,7 @@ MGtDrawQuadSplit MGgQuadFuncs_VertexSplit // 1TMU // 2 TMU MGrQuadSplit_Solid_TextureUnlit_LMOff, MGrQuadSplit_Solid_TextureUnlit_LMOff }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -735,114 +735,114 @@ MGtDrawPent MGgPentFuncs_VertexUnified { // M3cDrawState_Interpolation_None MGrPent_Point, - + // M3cDrawState_Interpolation_Vertex MGrPent_Point }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrPent_Point, - + // M3cDrawState_Interpolation_Vertex MGrPent_Point }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrPent_Point, - + // M3cDrawState_Interpolation_Vertex MGrPent_Point }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None MGrPent_Point, - + // M3cDrawState_Interpolation_Vertex MGrPent_Point } - + }, - + // M3cDrawState_Fill_Line { // M3cDrawState_Appearence_Gouraud { // M3cDrawState_Interpolation_None MGrPent_Line_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrPent_Line_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrPent_Line_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrPent_Line_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrPent_Line_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrPent_Line_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None MGrPent_Line_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrPent_Line_InterpNone } - + }, - + // M3cDrawState_Fill_Solid { // M3cDrawState_Appearence_Gouraud { // M3cDrawState_Interpolation_None MGrPent_Solid_Gouraud_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrPent_Solid_Gouraud_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrPent_Solid_TextureLit_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrPent_Solid_TextureLit_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrPent_Solid_TextureLit_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrPent_Solid_TextureLit_EnvMap_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None MGrPent_Solid_TextureUnlit, - + // M3cDrawState_Interpolation_Vertex MGrPent_Solid_TextureUnlit } @@ -866,7 +866,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawPentSplit)MGrPent_Point, (MGtDrawPentSplit)MGrPent_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -874,7 +874,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit (MGtDrawPentSplit)MGrPent_Point, (MGtDrawPentSplit)MGrPent_Point } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -882,7 +882,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit { (MGtDrawPentSplit)MGrPent_Point, (MGtDrawPentSplit)MGrPent_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -890,7 +890,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit (MGtDrawPentSplit)MGrPent_Point, (MGtDrawPentSplit)MGrPent_Point } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -899,7 +899,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawPentSplit)MGrPent_Point, (MGtDrawPentSplit)MGrPent_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -907,7 +907,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit (MGtDrawPentSplit)MGrPent_Point, (MGtDrawPentSplit)MGrPent_Point } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -916,7 +916,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawPentSplit)MGrPent_Point, (MGtDrawPentSplit)MGrPent_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -924,9 +924,9 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit (MGtDrawPentSplit)MGrPent_Point, (MGtDrawPentSplit)MGrPent_Point } } - + }, - + // M3cDrawState_Fill_Line { // M3cDrawState_Appearence_Gouraud @@ -937,7 +937,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawPentSplit)MGrPent_Line_InterpNone, (MGtDrawPentSplit)MGrPent_Line_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -945,7 +945,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit (MGtDrawPentSplit)MGrPent_Line_InterpVertex, (MGtDrawPentSplit)MGrPent_Line_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -954,7 +954,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawPentSplit)MGrPent_Line_InterpNone, (MGtDrawPentSplit)MGrPent_Line_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -962,7 +962,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit (MGtDrawPentSplit)MGrPent_Line_InterpVertex, (MGtDrawPentSplit)MGrPent_Line_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -971,7 +971,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawPentSplit)MGrPent_Line_InterpNone, (MGtDrawPentSplit)MGrPent_Line_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -979,7 +979,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit (MGtDrawPentSplit)MGrPent_Line_InterpVertex, (MGtDrawPentSplit)MGrPent_Line_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -988,7 +988,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit // 1 TMU // 2 TMU (MGtDrawPentSplit)MGrPent_Line_InterpNone, (MGtDrawPentSplit)MGrPent_Line_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -997,7 +997,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit } } }, - + // M3cDrawState_Fill_Solid { // M3cDrawState_Appearence_Gouraud @@ -1008,7 +1008,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit // 1 TMU 2 TMU (MGtDrawPentSplit)MGrPent_Solid_Gouraud_InterpNone, (MGtDrawPentSplit)MGrPent_Solid_Gouraud_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1016,7 +1016,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit (MGtDrawPentSplit)MGrPent_Solid_Gouraud_InterpVertex, (MGtDrawPentSplit)MGrPent_Solid_Gouraud_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -1025,7 +1025,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit // 1TMU // 2 TMU MGrPentSplit_Solid_TextureLit_InterpNone_LMOff, MGrPentSplit_Solid_TextureLit_InterpNone_LMOff }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1033,7 +1033,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit MGrPentSplit_Solid_TextureLit_InterpVertex_LMOff, MGrPentSplit_Solid_TextureLit_InterpVertex_LMOff } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -1042,7 +1042,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit // 1TMU // 2 TMU MGrPentSplit_Solid_TextureLit_InterpNone_LMOff, MGrPentSplit_Solid_TextureLit_InterpNone_LMOff }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1050,7 +1050,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit MGrPentSplit_Solid_TextureLit_InterpVertex_LMOff, MGrPentSplit_Solid_TextureLit_InterpVertex_LMOff } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -1059,7 +1059,7 @@ MGtDrawPentSplit MGgPentFuncs_VertexSplit // 1TMU // 2 TMU MGrPentSplit_Solid_TextureUnlit_LMOff, MGrPentSplit_Solid_TextureUnlit_LMOff }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1081,117 +1081,117 @@ MGtModeFunction MGgModeFuncs_VertexUnified { // M3cDrawState_Interpolation_None MGrMode_Point, - + // M3cDrawState_Interpolation_Vertex MGrMode_Point }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrMode_Point, - + // M3cDrawState_Interpolation_Vertex MGrMode_Point }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrMode_Point, - + // M3cDrawState_Interpolation_Vertex MGrMode_Point }, - + // M3cDrawState_Appearence_TextureUnlit { // M3cDrawState_Interpolation_None MGrMode_Point, - + // M3cDrawState_Interpolation_Vertex MGrMode_Point } }, - + // M3cDrawState_Fill_Line { // M3cDrawState_Appearence_Gouraud { // M3cDrawState_Interpolation_None MGrMode_Line_Gouraud_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrMode_Line_Gouraud_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrMode_Line_Gouraud_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrMode_Line_Gouraud_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrMode_Line_Gouraud_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrMode_Line_Gouraud_InterpVertex }, - + // M3cDrawState_Appearence_TextureUnlit { // M3cDrawState_Interpolation_None MGrMode_Line_Gouraud_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrMode_Line_Gouraud_InterpVertex } }, - - + + // M3cDrawState_Fill_Solid { // M3cDrawState_Appearence_Gouraud { // M3cDrawState_Interpolation_None MGrMode_Solid_Gouraud_InterpNone, - + // M3cDrawState_Interpolation_Vertex MGrMode_Solid_Gouraud_InterpVertex }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrMode_Solid_TextureLit_InterpNone_LMOn_1TMU, - + // M3cDrawState_Interpolation_Vertex MGrMode_Solid_TextureLit_InterpVertex_LMOn_1TMU }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrMode_Solid_TextureLit_InterpNone_LMOn_1TMU, - + // M3cDrawState_Interpolation_Vertex MGrMode_Solid_TextureLit_InterpVertex_LMOn_1TMU }, - + // M3cDrawState_Appearence_TextureUnlit { // M3cDrawState_Interpolation_None MGrMode_Solid_TextureUnlit_InterpNone_LMOn_1TMU, - + // M3cDrawState_Interpolation_Vertex MGrMode_Solid_TextureUnlit_InterpNone_LMOn_1TMU } - } + } }; @@ -1211,7 +1211,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit // 1 TMU // 2 TMU MGrMode_Point, MGrMode_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1219,7 +1219,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit MGrMode_Point, MGrMode_Point } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -1228,7 +1228,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit // 1 TMU // 2 TMU MGrMode_Point, MGrMode_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1236,7 +1236,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit MGrMode_Point, MGrMode_Point } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -1245,7 +1245,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit // 1 TMU // 2 TMU MGrMode_Point, MGrMode_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1253,7 +1253,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit MGrMode_Point, MGrMode_Point } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -1262,7 +1262,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit // 1 TMU // 2 TMU MGrMode_Point, MGrMode_Point }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1270,9 +1270,9 @@ MGtModeFunction MGgModeFuncs_VertexSplit MGrMode_Point, MGrMode_Point } } - + }, - + // M3cDrawState_Fill_Line { // M3cDrawState_Appearence_Gouraud @@ -1283,7 +1283,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit // 1 TMU // 2 TMU MGrMode_Line_Gouraud_InterpNone, MGrMode_Line_Gouraud_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1291,7 +1291,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit MGrMode_Line_Gouraud_InterpVertex, MGrMode_Line_Gouraud_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -1300,7 +1300,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit // 1 TMU // 2 TMU MGrMode_Line_Gouraud_InterpNone, MGrMode_Line_Gouraud_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1308,7 +1308,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit MGrMode_Line_Gouraud_InterpVertex, MGrMode_Line_Gouraud_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -1317,7 +1317,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit // 1 TMU // 2 TMU MGrMode_Line_Gouraud_InterpNone, MGrMode_Line_Gouraud_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1325,7 +1325,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit MGrMode_Line_Gouraud_InterpVertex, MGrMode_Line_Gouraud_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -1333,7 +1333,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit { MGrMode_Line_Gouraud_InterpNone, MGrMode_Line_Gouraud_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1342,7 +1342,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit } } }, - + // M3cDrawState_Fill_Solid { // M3cDrawState_Appearence_Gouraud @@ -1353,7 +1353,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit // 1 TMU 2 TMU MGrMode_Solid_Gouraud_InterpNone, MGrMode_Solid_Gouraud_InterpNone }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1361,7 +1361,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit MGrMode_Solid_Gouraud_InterpVertex, MGrMode_Solid_Gouraud_InterpVertex } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -1370,7 +1370,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit // 1TMU // 2 TMU MGrMode_Solid_TextureLit_InterpNone_LMOff_1TMU, MGrMode_Solid_TextureLit_InterpNone_LMOff_2TMU }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1378,7 +1378,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit MGrMode_Solid_TextureLit_InterpVertex_LMOff_1TMU, MGrMode_Solid_TextureLit_InterpVertex_LMOff_2TMU } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -1387,7 +1387,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit // 1TMU // 2 TMU MGrMode_Solid_TextureLit_InterpNone_LMOff_1TMU, MGrMode_Solid_TextureLit_InterpNone_LMOff_2TMU }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1395,7 +1395,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit MGrMode_Solid_TextureLit_InterpVertex_LMOff_1TMU, MGrMode_Solid_TextureLit_InterpVertex_LMOff_2TMU } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -1404,7 +1404,7 @@ MGtModeFunction MGgModeFuncs_VertexSplit // 1TMU // 2 TMU MGrMode_Solid_TextureUnlit_InterpNone_LMOff_1TMU, MGrMode_Solid_TextureUnlit_InterpNone_LMOff_2TMU }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1417,40 +1417,40 @@ MGtModeFunction MGgModeFuncs_VertexSplit MGtVertexCreateFunction MGgVertexCreateFuncs_Unified [M3cDrawState_Appearence_Num] - [M3cDrawState_Interpolation_Num] = + [M3cDrawState_Interpolation_Num] = { // M3cDrawState_Appearence_Gouraud { // M3cDrawState_Interpolation_None MGrVertexCreate_XYZ, - + // M3cDrawState_Interpolation_Vertex MGrVertexCreate_XYZ_RGB }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None MGrVertexCreate_XYZ_BaseUV, - + // M3cDrawState_Interpolation_Vertex MGrVertexCreate_XYZ_RGB_BaseUV }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None MGrVertexCreate_XYZ_BaseUV, - + // M3cDrawState_Interpolation_Vertex MGrVertexCreate_XYZ_RGB_BaseUV_EnvUV }, - + // M3cDrawState_Appearence_TextureUnlit { // M3cDrawState_Interpolation_None MGrVertexCreate_XYZ_BaseUV, - + // M3cDrawState_Interpolation_Vertex MGrVertexCreate_XYZ_BaseUV } @@ -1469,7 +1469,7 @@ MGtVertexCreateFunction MGgVertexCreateFuncs_Split // 1 TMU // 2 TMU MGrVertexCreate_XYZ, MGrVertexCreate_XYZ }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1477,7 +1477,7 @@ MGtVertexCreateFunction MGgVertexCreateFuncs_Split MGrVertexCreate_XYZ_RGB, MGrVertexCreate_XYZ_RGB } }, - + // M3cDrawState_Appearence_Texture_Lit { // M3cDrawState_Interpolation_None @@ -1486,7 +1486,7 @@ MGtVertexCreateFunction MGgVertexCreateFuncs_Split // 1 TMU // 2 TMU MGrVertexCreate_XYZ, MGrVertexCreate_XYZ }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1494,7 +1494,7 @@ MGtVertexCreateFunction MGgVertexCreateFuncs_Split MGrVertexCreate_XYZ_RGB, MGrVertexCreate_XYZ_RGB } }, - + // M3cDrawState_Appearence_Texture_Lit_EnvMap { // M3cDrawState_Interpolation_None @@ -1503,7 +1503,7 @@ MGtVertexCreateFunction MGgVertexCreateFuncs_Split // 1 TMU // 2 TMU MGrVertexCreate_XYZ, MGrVertexCreate_XYZ }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off @@ -1511,7 +1511,7 @@ MGtVertexCreateFunction MGgVertexCreateFuncs_Split MGrVertexCreate_XYZ_RGB, MGrVertexCreate_XYZ_RGB } }, - + // M3cDrawState_Appearence_Texture_Unlit { // M3cDrawState_Interpolation_None @@ -1520,7 +1520,7 @@ MGtVertexCreateFunction MGgVertexCreateFuncs_Split // 1 TMU // 2 TMU MGrVertexCreate_XYZ, MGrVertexCreate_XYZ }, - + // M3cDrawState_Interpolation_Vertex { // M3cDrawState_LightMapMode_Off diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method_Ptrs.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method_Ptrs.h index 3817d38..c103ffd 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method_Ptrs.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Method_Ptrs.h @@ -1,12 +1,12 @@ /* FILE: MG_DrawEngine_Method_Ptrs.h - + AUTHOR: Brent Pease - + CREATED: July 31, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Platform.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Platform.h index 0314c8c..6edce91 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Platform.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_DrawEngine_Platform.h @@ -1,12 +1,12 @@ /* FILE: MG_DrawEngine_Platform.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -20,5 +20,5 @@ MGrDrawEngine_Platform_SetupDrawContextPrivate( void MGrDrawEngine_Platform_DestroyDrawContextPrivate( void); - + #endif /* MG_DRAWENGINE_PLATFORM_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_Polygon.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_Polygon.c index a222740..027ee27 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_Polygon.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_Polygon.c @@ -1,12 +1,12 @@ /* FILE: MG_Polygon.c - + AUTHOR: Michael Evans - + CREATED: July 5, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_Polygon.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_Polygon.h index 6d2d36e..7a7aba7 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_Polygon.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/MG_Polygon.h @@ -1,12 +1,12 @@ /* FILE: MG_Polygon.h - + AUTHOR: Michael Evans - + CREATED: July 5, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -29,18 +29,18 @@ #include "rasterizer_3dfx.h" void MGrDrawPolygon_VertexList_TextureUnlit( - int nverts, - const GrVertex vlist[], + int nverts, + const GrVertex vlist[], MGtTextureMapPrivate *inTexture); void MGrDrawPolygon_VertexList_TextureInterpolate( - int nverts, - const GrVertex vlist[], + int nverts, + const GrVertex vlist[], MGtTextureMapPrivate *inTexture); void MGrDrawPolygon_VertexList_TextureFlat( - int nverts, - const GrVertex vlist[], + int nverts, + const GrVertex vlist[], MGtTextureMapPrivate *inTexture); void MGrDrawTriangle_TextureInterpolate( @@ -51,4 +51,4 @@ void MGrDrawTriangle_TextureInterpolate( #endif -#endif // MG_POLYGON_H \ No newline at end of file +#endif // MG_POLYGON_H diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/lrar_cache.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/lrar_cache.c index 025b0a5..91ea310 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/lrar_cache.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/lrar_cache.c @@ -18,7 +18,7 @@ enum { LRAR_CACHE_SIGNATURE= 'lrar', LRAR_CACHE_BLOCK_SIGNATURE= 'Rblk', - + MAXIMUM_LRAR_CACHE_NAME_LENGTH= 31 }; @@ -89,7 +89,7 @@ static void lrar_default_purge_block_proc(void *user_data); assert(minimum_addressblocks); free(cache); - + return; } @@ -172,14 +172,14 @@ static void lrar_internal_purge_oldest_block( UUrMemory_Clear(oldest_block, sizeof( lrar_cache_block)); cache->cur_block_count -= 1; - + if (0 == cache->cur_block_count) { // no more blocks cache->last_allocated_block_index = NONE; cache->oldest_block_index = NONE; } - else + else { // bump oldest_block_index mod cache->max_block_count cache->oldest_block_index += 1; @@ -226,12 +226,12 @@ short lrar_allocate( short new_block_index= NONE; UUmAssert(size > 0); - + verify_lrar_cache(cache); // add the size of a block header and 4-byte align it if (size&((1<alignment_bit)-1)) size= (size|((1<alignment_bit)-1))+1; - + if (size>=0 && size<=cache->size) { UUtBool wrapped = UUcFalse; @@ -252,12 +252,12 @@ short lrar_allocate( new_block_index = cache->last_allocated_block_index + 1; if (new_block_index>=cache->max_block_count) new_block_index= 0; } - + while (!done) { unsigned long new_block_address; - // compute the base address of the new block + // compute the base address of the new block if (cache->last_allocated_block_index==NONE) { new_block_address= cache->minimum_address; @@ -297,13 +297,13 @@ short lrar_allocate( new_block_address = cache->minimum_address; } } - else + else { new_block_address = cache->minimum_address; } // if there are any blocks to purge we may need to purge - if (cache->oldest_block_index != NONE) + if (cache->oldest_block_index != NONE) { lrar_cache_block *oldest_block = get_lrar_cache_block(cache, cache->oldest_block_index); @@ -366,7 +366,7 @@ unsigned long lrar_block_address( short block_index) { verify_lrar_cache(cache); - + return get_lrar_cache_block(cache, block_index)->address; } @@ -377,7 +377,7 @@ static void lrar_default_new_block_proc( short block_index) { *(short *)user_data= block_index; - + return; } @@ -387,7 +387,7 @@ static void lrar_default_purge_block_proc( if (NULL != user_data) { *(short *)user_data= NONE; } - + return; } @@ -404,7 +404,7 @@ static lrar_cache_block *get_lrar_cache_block( block= cache->blocks + block_index; verify_lrar_cache_block(cache, block); - + return block; } @@ -422,10 +422,10 @@ static void verify_lrar_cache_block( valid= UUcTrue; } } - + vassert(valid, csprintf(temporary, "lrar cache %s @%p block @%p appears to be corrupt", cache->name, cache, block)); - + return; } @@ -435,7 +435,7 @@ void verify_lrar_cache( short new_block_index= NONE; short itr; UUtBool valid= UUcFalse; - + if (cache->signature==LRAR_CACHE_SIGNATURE && cache->minimum_addressmaximum_address && cache->size>0 && @@ -455,7 +455,7 @@ void verify_lrar_cache( // CB: only check user data if we know what it's being used for if (block->user_data && (cache->new_block == lrar_default_new_block_proc)) { - short user_data; + short user_data; user_data = *((short *) (block->user_data)); UUmAssert(block_index == user_data); @@ -464,7 +464,7 @@ void verify_lrar_cache( vassert(valid, csprintf(temporary, "lrar cache %s @%p appears to be corrupt", cache->name, cache)); - + return; } #endif diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/lrar_cache2.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/lrar_cache2.c index 4274b2f..46d887a 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/lrar_cache2.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/lrar_cache2.c @@ -21,7 +21,7 @@ enum LRAR_CACHE_SIGNATURE= 'lrar', LRAR_CACHE_BLOCK_SIGNATURE= 'Rblk', LRAR_CACHE_DEALLOCATED_BLOCK_SIGNATURE= 'Dblk', - + MAXIMUM_LRAR_CACHE_NAME_LENGTH= 31 }; @@ -99,7 +99,7 @@ struct lrar_cache *lrar_new( assert(minimum_addressname, name, MAXIMUM_LRAR_CACHE_NAME_LENGTH); cache->name[MAXIMUM_LRAR_CACHE_NAME_LENGTH]= 0; @@ -148,11 +148,11 @@ struct lrar_cache *lrar_new( else { UUrMemory_Block_Delete(cache); - + cache= (struct lrar_cache *) NULL; } } - + return cache; } @@ -160,10 +160,10 @@ void lrar_dispose( struct lrar_cache *cache) { verify_lrar_cache(cache); - + UUrMemory_Block_Delete(cache->blocks); UUrMemory_Block_Delete(cache); - + return; } @@ -171,7 +171,7 @@ void lrar_flush( struct lrar_cache *cache) { short block_index; - + verify_lrar_cache(cache); block_index= cache->oldest_block_index; @@ -196,7 +196,7 @@ void lrar_flush( cache->oldest_block_index= NONE; cache->last_allocated_block_index= NONE; - + return; } @@ -212,22 +212,22 @@ short lrar_allocate( // add the size of a block header and 4-byte align it if (size&((1<alignment_bit)-1)) size= (size|((1<alignment_bit)-1))+1; - + if (size>=0 && size<=cache->size) { short oldest_block_index= cache->oldest_block_index; - + boolean done= UUcFalse; new_block_index= cache->last_allocated_block_index==NONE ? 0 : (cache->last_allocated_block_index+1); if (new_block_index>=cache->block_count) new_block_index= 0; - + while (!done) { unsigned long new_block_address; unsigned long adjusted_new_block_address; // to compensate for boundary crossing - // compute the base address of the new block + // compute the base address of the new block if (cache->last_allocated_block_index==NONE) { new_block_address= cache->minimum_address; @@ -265,18 +265,18 @@ short lrar_allocate( if (oldest_block->signature == LRAR_CACHE_BLOCK_SIGNATURE) { lrar_purge_block(cache, oldest_block); } - + oldest_block_index+= 1; if (oldest_block_index>=cache->block_count) oldest_block_index= 0; oldest_block= get_lrar_cache_block(cache, oldest_block_index); - } + } } - + if (adjusted_new_block_address + size > cache->maximum_address) { // this block would fall off the edge of the cache, wrap - + cache->last_allocated_block_index= NONE; } else @@ -355,7 +355,7 @@ static void lrar_default_new_block_proc( short block_index) { *(short *)user_data= block_index; - + return; } @@ -363,7 +363,7 @@ static void lrar_default_purge_block_proc( void *user_data) { *(short *)user_data= NONE; - + return; } @@ -398,7 +398,7 @@ static struct lrar_cache_block *get_lrar_cache_block( block= cache->blocks + block_index; verify_lrar_cache_block(cache, block); - + return block; } @@ -418,10 +418,10 @@ static void verify_lrar_cache_block( } } } - + vassert(valid, csprintf(temporary, "lrar cache %s @%p block @%p appears to be corrupt", cache->name, cache, block)); - + return; } @@ -429,7 +429,7 @@ void verify_lrar_cache( struct lrar_cache *cache) { boolean valid= UUcFalse; - + if (cache->signature==LRAR_CACHE_SIGNATURE && cache->minimum_addressmaximum_address && cache->size>0 && @@ -440,7 +440,7 @@ void verify_lrar_cache( vassert(valid, csprintf(temporary, "lrar cache %s @%p appears to be corrupt", cache->name, cache)); - + return; } #endif diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/rasterizer_3dfx.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/rasterizer_3dfx.c index 2e24f63..5bce1d1 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/rasterizer_3dfx.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/rasterizer_3dfx.c @@ -3,7 +3,7 @@ * RASTERIZER_3DFX.C * */ - + #include "bfw_cseries.h" #include "lrar_cache.h" @@ -97,14 +97,14 @@ void initialize_3dfx( UUrStartupMessage("initializing 3dfx..."); UUmAssert(gGlideAvailable); - + success = grSstQueryHardware(&hwconfig); UUmAssert(success); UUrStartupMessage("3dfx hardware query gave us %d...", success); UUrStartupMessage("selecting 3dfx display device..."); grSstSelect(0); - + globals_3dfx.numTMU = hwconfig.SSTs[0].sstBoard.VoodooConfig.nTexelfx; globals_3dfx.numTMU = UUmMin(globals_3dfx.numTMU, 2); // only handle 2 tmus @@ -118,12 +118,12 @@ void initialize_3dfx( minimum_address = grTexMinAddress(GR_TMU0); maximum_address = grTexMaxAddress(GR_TMU0); - globals_3dfx.texture_memory_cache_tmu0= - lrar_new( "3dfx texture memory cache 0", + globals_3dfx.texture_memory_cache_tmu0= + lrar_new( "3dfx texture memory cache 0", minimum_address, - maximum_address, - MAXIMUM_CACHED_TEXTURES_PER_TMU, - 4, + maximum_address, + MAXIMUM_CACHED_TEXTURES_PER_TMU, + 4, 21, (lrar_new_block_proc) NULL, (lrar_purge_block_proc) NULL); UUmAssert(globals_3dfx.texture_memory_cache_tmu0); @@ -131,12 +131,12 @@ void initialize_3dfx( if (globals_3dfx.numTMU >= 2) { minimum_address = grTexMinAddress(GR_TMU1); maximum_address = grTexMaxAddress(GR_TMU1); - globals_3dfx.texture_memory_cache_tmu1 = - lrar_new( "3dfx texture memory cache 1", + globals_3dfx.texture_memory_cache_tmu1 = + lrar_new( "3dfx texture memory cache 1", minimum_address, - maximum_address, - MAXIMUM_CACHED_TEXTURES_PER_TMU, - 4, + maximum_address, + MAXIMUM_CACHED_TEXTURES_PER_TMU, + 4, 21, (lrar_new_block_proc) NULL, (lrar_purge_block_proc) NULL); UUmAssert(globals_3dfx.texture_memory_cache_tmu1); @@ -154,7 +154,7 @@ void initialize_3dfx( globals_3dfx.clampT_tmu0 = GR_TEXTURECLAMP_WRAP; globals_3dfx.clampS_tmu1 = GR_TEXTURECLAMP_WRAP; globals_3dfx.clampT_tmu1 = GR_TEXTURECLAMP_WRAP; - + grTexClampMode(GR_TMU0, GR_TEXTURECLAMP_WRAP, GR_TEXTURECLAMP_WRAP); grTexMipMapMode(GR_TMU0, GR_MIPMAP_DISABLE, FXFALSE); grTexLodBiasValue(GR_TMU0, 0.5f); // per texture would be ideal (.5 if only 1 texture) @@ -171,7 +171,7 @@ void initialize_3dfx( } grHints( GR_HINT_ALLOW_MIPMAP_DITHER, 1); - + // clear the backbuffer to green, swap it to front #if MGcUseZBuffer grBufferClear(0x007F007F, 0, GR_ZDEPTHVALUE_FARTHEST); @@ -208,12 +208,12 @@ void initialize_3dfx( grRenderBuffer(GR_BUFFER_BACKBUFFER); while (grBufferNumPending()>0) ; - + if(MGgDecompressBuffer != NULL) { UUrMemory_Block_Delete(MGgDecompressBuffer); } - + MGgDecompressBuffer = UUrMemory_Block_New((256 * 256 * 2 * 3) / 2); UUmAssert(NULL != MGgDecompressBuffer); @@ -243,7 +243,7 @@ void dispose_3dfx( { lrar_dispose(globals_3dfx.texture_memory_cache_tmu0); } - + if (globals_3dfx.texture_memory_cache_tmu1 != NULL) { lrar_dispose(globals_3dfx.texture_memory_cache_tmu1); @@ -295,7 +295,7 @@ UUtBool available_3dfx( has_3dfx= UUcTrue; } - else + else { UUrStartupMessage("did not detect 3dfx hardware"); } @@ -321,7 +321,7 @@ UUtBool available_3dfx( } gGlideAvailable = has_3dfx; - + return has_3dfx; } @@ -352,7 +352,7 @@ void erase_backbuffer_3dfx( #endif MGrSet_ZWrite(oldMode); - + return; } @@ -375,14 +375,14 @@ void lock_backbuffer_3dfx( } #endif - return; + return; } void unlock_backbuffer_3dfx( void) { grLfbUnlock(GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER); - + return; } @@ -394,7 +394,7 @@ void display_backbuffer_3dfx( if (MGgGamma != MGgOldGamma) { grGammaCorrectionValue(MGgGamma); } - + if (MGgDoubleBuffer) { grBufferSwap(1); grRenderBuffer(GR_BUFFER_BACKBUFFER); @@ -402,7 +402,7 @@ void display_backbuffer_3dfx( else { grRenderBuffer(GR_BUFFER_FRONTBUFFER); } - + if (MGgBilinear) { grTexFilterMode(GR_TMU0, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR); if (globals_3dfx.numTMU >= 2) { @@ -428,7 +428,7 @@ static void UUcExternal_Call dispose_glide_atexit( void) { grGlideShutdown(); - + return; } @@ -438,7 +438,7 @@ myGRTexDownloadMipMap( GrChipID_t tmu, FxU32 evenOdd, GrTexInfo *info, long size) -{ +{ MGgTextureBytesDownloaded += size; grTexDownloadMipMap(tmu, startAddress, evenOdd, info); @@ -482,9 +482,9 @@ set_current_glide_texture( GrChipID_t inTMU, MGtTextureMapPrivate* inTexture, MGtTextureUploadMode mode) -{ - GrTexInfo** current_texture_ptr; - GrTexInfo* hardware_format; +{ + GrTexInfo** current_texture_ptr; + GrTexInfo* hardware_format; short* hardware_block_index; lrar_cache* lrar_cache; short* current_block_index; @@ -582,7 +582,7 @@ set_current_glide_texture( lrar_cache = globals_3dfx.texture_memory_cache_tmu0; current_texture_ptr = &(globals_3dfx.current_texture_tmu0); break; - + case GR_TMU1: if (MGcTextureUploadMode_Trilinear == mode) { hardware_block_index = &(inTexture->hardware_block_index_tmu1_odd); @@ -664,12 +664,12 @@ set_current_glide_texture( if (GR_TMU0 == inTMU) { globals_3dfx.hardware_address_tmu0 = hardware_address; globals_3dfx.hardware_format_tmu0 = *hardware_format; - globals_3dfx.evenOdd_tmu0 = evenOdd; + globals_3dfx.evenOdd_tmu0 = evenOdd; } else { globals_3dfx.hardware_address_tmu1 = hardware_address; globals_3dfx.hardware_format_tmu1 = *hardware_format; - globals_3dfx.evenOdd_tmu1 = evenOdd; + globals_3dfx.evenOdd_tmu1 = evenOdd; } if (texture_changed) { @@ -693,7 +693,7 @@ set_current_glide_texture( IMrImage_ConvertPixelType( - IMcDitherMode_Off, + IMcDitherMode_Off, inTexture->width, inTexture->height, mipMap, @@ -704,14 +704,14 @@ set_current_glide_texture( } myGRTexDownloadMipMap(inTMU, hardware_address, evenOdd, hardware_format, size); - + thisMap = hardware_format->data; thisMapSize = inTexture->width * inTexture->height * 2; *hardware_block_dirty = UUcFalse; } - if (MGgMipMapping) + if (MGgMipMapping) { grTexSource(inTMU, hardware_address, evenOdd, hardware_format); } @@ -757,7 +757,7 @@ void MGrSet_MipMapMode(GrChipID_t inTMU, MGtMipMapMode inMode) break; case MGcMipMapMode_NoMipmapping: - grTexMipMapMode(inTMU, GR_MIPMAP_DISABLE, FXFALSE); + grTexMipMapMode(inTMU, GR_MIPMAP_DISABLE, FXFALSE); break; case MGcMipMapMode_MipMapping: @@ -781,7 +781,7 @@ void MGrSet_MipMapMode(GrChipID_t inTMU, MGtMipMapMode inMode) } -void MGrSet_AlphaCombine(MGtAlphaCombine inMode) +void MGrSet_AlphaCombine(MGtAlphaCombine inMode) { if (inMode == globals_3dfx.currentAlphaCombine) { return; @@ -889,7 +889,7 @@ void MGrSet_TextureCombine(MGtTextureCombine inMode) if (inMode == globals_3dfx.currentTextureCombine) { return; } - + if (1 == globals_3dfx.numTMU) { return; } @@ -913,7 +913,7 @@ void MGrSet_TextureCombine(MGtTextureCombine inMode) case MGcTextureCombine_Multiply: grHints( GR_HINT_STWHINT, GR_STWHINT_ST_DIFF_TMU1); - grTexCombine(GR_TMU0, GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, + grTexCombine(GR_TMU0, GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE); grTexCombine( GR_TMU1, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, @@ -938,17 +938,17 @@ void MGrSet_TextureCombine(MGtTextureCombine inMode) grTexCombine( GR_TMU1, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE ); break; - + case MGcTextureCombine_EnvMap: grHints( GR_HINT_STWHINT, GR_STWHINT_ST_DIFF_TMU1); - + grTexCombine( GR_TMU0, GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, GR_COMBINE_FACTOR_LOCAL_ALPHA, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE ); grTexCombine( GR_TMU1, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE ); break; - + default: UUmAssert(0); break; @@ -965,11 +965,11 @@ void MGrSet_TextureMode( UUtBool trilinear; UUtBool envmapping; UUtBool blend_additive; - + UUmAssertReadPtr(texturePrivate, sizeof(MGtTextureMapPrivate)); MGgDrawContextPrivate->curBaseTexture = texturePrivate; - + textureAlpha = (texturePrivate->flags & MGcTextureFlag_HasAlpha) ? MGcAlphaCombine_TextureTimesConstantAlpha : @@ -979,14 +979,14 @@ void MGrSet_TextureMode( (2 == globals_3dfx.numTMU) && (texturePrivate->flags & MGcTextureFlag_HasMipMap) && ((MGgFilteringOverrideMode == MGcFilteringOverride_Dont) || - (MGgFilteringOverrideMode == MGcFilteringOverride_Trilinear)); + (MGgFilteringOverrideMode == MGcFilteringOverride_Trilinear)); #endif - + trilinear = 0; - + envmapping = (inTexture->flags & M3cTextureFlags_ReceivesEnvMap) != 0; blend_additive = (inTexture->flags & M3cTextureFlags_Blend_Additive) != 0; - + if(blend_additive) { textureAlpha = MGcAlphaCombine_Additive; @@ -995,9 +995,9 @@ void MGrSet_TextureMode( { textureAlpha = MGcAlphaCombine_ConstantAlpha; } - + MGrSet_AlphaCombine(textureAlpha); - + if (trilinear) { MGrSet_TextureCombine(MGcTextureCombine_Trilinear); @@ -1007,7 +1007,7 @@ void MGrSet_TextureMode( else if(envmapping) { MGtTextureMapPrivate* envMapPrivate = MGmGetEnvMapPrivate(MGgDrawContextPrivate); - + // UUmAssertReadPtr(envMapPrivate, sizeof(*envMapPrivate)); if (envMapPrivate) { @@ -1026,7 +1026,7 @@ void MGrSet_TextureMode( MGrSet_TextureCombine(MGcTextureCombine_None); set_current_glide_texture(GR_TMU0, texturePrivate, MGcTextureUploadMode_Normal); } - + } void @@ -1038,14 +1038,14 @@ MGrDrawPolygon( #if 0//defined(DEBUGGING) && DEBUGGING { int i; - + for(i = 0; i < nverts; i++) { MGmAssertVertexXY(vlist + ilist[i]); } } #endif - + grDrawPolygon(nverts, ilist, vlist); } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/rasterizer_3dfx.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/rasterizer_3dfx.h index 1985b21..b4d62a3 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/rasterizer_3dfx.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/3DFX_Glide/rasterizer_3dfx.h @@ -39,7 +39,7 @@ typedef enum { MGcTextureCombine_Trilinear = 0x40000, MGcTextureCombine_AlphaBlend = 0x80000, MGcTextureCombine_EnvMap = 0x100000 - + } MGtTextureCombine; typedef enum { @@ -60,7 +60,7 @@ typedef enum { MGcZWrite_Invalid = 0x10, MGcZWrite_On = 0x20, MGcZWrite_Off = 0x30 - + } MGtZWriteMode; @@ -118,7 +118,7 @@ struct MGtTextureMapPrivate GrTexInfo hardware_format; // glide texture format // block indicies in the lrar_cache on the card - short hardware_block_index_tmu0; + short hardware_block_index_tmu0; short hardware_block_index_tmu0_even; short hardware_block_index_tmu1; short hardware_block_index_tmu1_odd; @@ -128,16 +128,16 @@ struct MGtTextureMapPrivate long hardware_block_size_tmu1; long hardware_block_size_tmu1_odd; - UUtBool hardware_block_dirty_tmu0; + UUtBool hardware_block_dirty_tmu0; UUtBool hardware_block_dirty_tmu0_even; UUtBool hardware_block_dirty_tmu1; UUtBool hardware_block_dirty_tmu1_odd; - short flags; + short flags; short width, height; }; -typedef struct +typedef struct { GrTexInfo *current_texture_tmu0; GrTexInfo *current_texture_tmu1; @@ -213,10 +213,10 @@ void MGrSet_TextureMode( void MGrDrawPolygon( int nverts, const int ilist[], const GrVertex vlist[] ); -void MGrDrawTriangle(const GrVertex* a, const GrVertex* b, const GrVertex* c); +void MGrDrawTriangle(const GrVertex* a, const GrVertex* b, const GrVertex* c); /* ---------- prototypes/RASTERIZER_3DFX_WINDOWS.C */ UUtBool load_glide_procedures(void); -#endif \ No newline at end of file +#endif diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Bitmap.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Bitmap.c index f1be027..fa0d8d5 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Bitmap.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Bitmap.c @@ -1,12 +1,12 @@ /* FILE: MD_DC_Method_Bitmap.c - + AUTHOR: Brent H. Pease - + CREATED: Nov 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -29,7 +29,7 @@ // funcitons // ====================================================================== // ---------------------------------------------------------------------- -void +void MDrDrawContext_Method_Bitmap( M3tDrawContext *inDrawContext, M3tTextureMap *inBitmap, @@ -46,54 +46,54 @@ MDrDrawContext_Method_Bitmap( M3tTextureCoord vt[4]; float max_u; float max_v; - + // get access to the private context drawContextPrivate = (MDtDrawContextPrivate*)inDrawContext->privateContext; if (drawContextPrivate == NULL) return; - + // get access to the private texturemap data textureMapPrivate = (MDtTextureMapPrivate*)(TMmInstance_GetDynamicData(inBitmap)); vs[0] = vs[1] = vs[2] = vs[3] = 0xFFFF; - + max_u = (float)inWidth / (float)inBitmap->width; max_v = (float)inHeight / (float)inBitmap->height; - + vc[0].x = inDestPoint->x; vc[0].y = inDestPoint->y; vc[0].z = inDestPoint->z; vc[0].invW = inDestPoint->invW; vt[0].u = 0.0; vt[0].v = 0.0; - + vc[1].x = inDestPoint->x + inWidth; vc[1].y = inDestPoint->y; vc[1].z = inDestPoint->z; vc[1].invW = inDestPoint->invW; vt[1].u = max_u; vt[1].v = 0.0; - + vc[2].x = inDestPoint->x + inWidth; vc[2].y = inDestPoint->y + inHeight; vc[2].z = inDestPoint->z; vc[2].invW = inDestPoint->invW; vt[2].u = max_u; vt[2].v = max_v; - + vc[3].x = inDestPoint->x; vc[3].y = inDestPoint->y + inHeight; vc[3].z = inDestPoint->z; vc[3].invW = inDestPoint->invW; vt[3].u = 0.0; vt[3].v = max_v; - + M3rDraw_State_SetPtr(inDrawContext, M3cDrawStatePtrType_ScreenPointArray, vc); M3rDraw_State_SetPtr(inDrawContext, M3cDrawStatePtrType_ScreenShadeArray_DC, vs); M3rDraw_State_SetPtr(inDrawContext, M3cDrawStatePtrType_TextureCoordArray, vt); M3rDraw_State_SetPtr(inDrawContext, M3cDrawStatePtrType_BaseTextureMap, inBitmap); - + MDrDrawContext_Method_QuadTextureFlat(inDrawContext, 0, 1, 2, 3, 0); -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Bitmap.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Bitmap.h index c83ced2..39e694d 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Bitmap.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Bitmap.h @@ -1,12 +1,12 @@ /* FILE: MD_DC_Method_Bitmap.h - + AUTHOR: Brent H. Pease - + CREATED: Nov 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Frame.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Frame.h index 0563728..4946c1a 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Frame.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Frame.h @@ -1,12 +1,12 @@ /* FILE: MD_DC_Method_Frame.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_LinePoint.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_LinePoint.c index 230dcf6..66444c7 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_LinePoint.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_LinePoint.c @@ -4,9 +4,9 @@ AUTHOR: Brent H. Pease CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -33,38 +33,38 @@ MDrDrawContext_Method_Point( UUtUns32 targetZ; UUtUns16 *targetZPtr, *targetRGBPtr; MDtDrawContextPrivate *drawContextPrivate = (MDtDrawContextPrivate *)inDrawContext->privateContext; - + UUmAssert(invCoord->y >= 0.0 && invCoord->y < (float)drawContextPrivate->height); UUmAssert(invCoord->x >= 0.0 && invCoord->x < (float)drawContextPrivate->width); UUmAssert(invCoord->z >= 0.0 && invCoord->z <= 1.0); - + x = (UUtInt32)invCoord->x; y = (UUtInt32)invCoord->y; z = (UUtInt32)invCoord->z * MSmULongScale; - + //y = drawContext->height - y; - + targetZPtr = (UUtUns16 *)((char *)drawContextPrivate->zBufferBaseAddr + - y * drawContextPrivate->zBufferRowBytes + + y * drawContextPrivate->zBufferRowBytes + x * 2); - + targetZ = *targetZPtr << 16; - + if(z < targetZ) { *targetZPtr = (UUtUns16)(z >> 16); - + targetRGBPtr = (UUtUns16 *)((char *)drawContextPrivate->imageBufferBaseAddr + - y * drawContextPrivate->imageBufferRowBytes + + y * drawContextPrivate->imageBufferRowBytes + x * 2); - + *targetRGBPtr = inVShade; - + } #endif } -void +void MDrDrawContext_Method_Line_Interpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -90,10 +90,10 @@ MDrDrawContext_Method_Line_Interpolate( long zRowBytes; float x0, y0, x1, y1; float dx, dy, fabs_dx, fabs_dy; - + M3tPointScreen *vCoordStart, *vCoordEnd; UUtUns16 vShadeStart, vShadeEnd; - + long major, minor; char *rgbAddress; char *zAddress; @@ -105,24 +105,24 @@ MDrDrawContext_Method_Line_Interpolate( float height = (float) drawContextPrivate->height; float width = (float) drawContextPrivate->width; - + M3tPointScreen* screenPoints; M3tPointScreen* vCoord0; M3tPointScreen* vCoord1; - + UUtUns16* vertexShades; UUtUns16 vShade0; UUtUns16 vShade1; - + screenPoints = drawContextPrivate->arrayData[M3cDrawArrayType_ScreenPoint]; vertexShades = (UUtUns16*)drawContextPrivate->arrayData[M3cDrawArrayType_ScreenShade_DC]; - + vCoord0 = screenPoints + inVIndex0; vCoord1 = screenPoints + inVIndex1; - + vShade0 = vertexShades[inVIndex0]; vShade1 = vertexShades[inVIndex1]; - + x0 = vCoord0->x; x1 = vCoord1->x; y0 = vCoord0->y; @@ -134,7 +134,7 @@ MDrDrawContext_Method_Line_Interpolate( * It appears that this functions requires clipped lines, I am adding assertions * */ - + UUmAssert(x0 >= 0.0); UUmAssert(x1 >= 0.0); UUmAssert(y0 >= 0.0); @@ -147,7 +147,7 @@ MDrDrawContext_Method_Line_Interpolate( dx = x1 - x0; dy = y1 - y0; - + rgbPixelBytes = M3cDrawRGBBytesPerPixel; zPixelBytes = M3cDrawZBytesPerPixel; @@ -156,18 +156,18 @@ MDrDrawContext_Method_Line_Interpolate( rgbRowBytes = drawContextPrivate->imageBufferRowBytes; zRowBytes = drawContextPrivate->zBufferRowBytes; - + if (fabs_dx > fabs_dy) { /* * Δx is larger, so the major axis will be X. */ - + rgbMajorIncrement = rgbPixelBytes; zMajorIncrement = zPixelBytes; rgbMinorIncrement = rgbRowBytes; zMinorIncrement = zRowBytes; - + if (dx > 0.0F) { vCoordStart = vCoord0; @@ -197,12 +197,12 @@ MDrDrawContext_Method_Line_Interpolate( /* * Δy is larger, so the major axis will be Y. */ - + rgbMajorIncrement = rgbRowBytes; zMajorIncrement = zRowBytes; rgbMinorIncrement = rgbPixelBytes; zMinorIncrement = zPixelBytes; - + if (dy > 0.0F) { vCoordStart = vCoord0; @@ -227,19 +227,19 @@ MDrDrawContext_Method_Line_Interpolate( } fabsMajorDelta = fabs_dy; } - + /* * Snap major axis endpoints, including a 0.5 pixel subpixel coverage rule. */ - + majorStartSnapped = (UUtInt32)(majorStart + 0.5F); - + /* Avoid Divide by zero error */ if(fabsMajorDelta == 0.0F) { return; } - + invLength = 1.0F / fabsMajorDelta; snapCorrection = (majorStartSnapped + 0.5F) - majorStart; tempEnd = majorEnd - 0.5F; @@ -251,7 +251,7 @@ MDrDrawContext_Method_Line_Interpolate( * reasons -- if we continue, the cast of fTemp to an int will produce * 0, which isn't correct. */ - + return; } majorEndSnapped = (UUtInt32)tempEnd; @@ -261,17 +261,17 @@ MDrDrawContext_Method_Line_Interpolate( * initial value. This isn't really necessary if kQAZFunction_None is set, but testing * for that isn't really worth while. */ - + { const float zScale = (float)MDmULongScale; const float zOffset = (float)MDmULongOffset; - + tempStart = vCoordStart->z * zScale + zOffset; tempEnd = vCoordEnd->z * zScale + zOffset; dTemp = (tempEnd - tempStart) * invLength; z = (UUtUns32)(tempStart + snapCorrection * dTemp); dZ = (long) dTemp; - + } tempStart = vShadeStart->r * charScale; @@ -279,33 +279,33 @@ MDrDrawContext_Method_Line_Interpolate( dTemp = (tempEnd - tempStart) * invLength; rScaled = (UUtInt32)tempStart; dRScaled = (UUtInt32)dTemp; - + tempStart = vShadeStart->g * charScale; tempEnd = vShadeEnd->g * charScale; dTemp = (tempEnd - tempStart) * invLength; gScaled = (UUtInt32)tempStart; dGScaled = (UUtInt32)dTemp; - + tempStart = vShadeStart->b * charScale; tempEnd = vShadeEnd->b * charScale; dTemp = (tempEnd - tempStart) * invLength; bScaled = (UUtInt32)tempStart; dBScaled = (UUtInt32)dTemp; - + /* * Determine the initial minor axis value, the minor axis delta per major axis pixel, * and whether the minor axis will increment or decrement as we move along the major axis. */ - + minorScaled = (UUtInt32)(minorStart * (float)MDmFractOne); dMinorScaled = (UUtInt32)(minorDelta * invLength * (float)MDmFractOne); - + if (minorDelta < 0.0F) { /* * Minor axis decrements, so negate the rgb/zMinorIncrement values. */ - + rgbMinorIncrement = -rgbMinorIncrement; zMinorIncrement = -zMinorIncrement; } @@ -313,10 +313,10 @@ MDrDrawContext_Method_Line_Interpolate( major = majorStartSnapped; minor = minorScaled >> MDmFractBits; minorScaled &= fractMask; - + rgbAddress = (char *)drawContextPrivate->imageBufferBaseAddr + major * rgbMajorIncrement + minor * abs (rgbMinorIncrement); - + zAddress = (char *)drawContextPrivate->zBufferBaseAddr + major * zMajorIncrement + minor * abs (zMinorIncrement); @@ -324,11 +324,11 @@ MDrDrawContext_Method_Line_Interpolate( { zPixel = *((unsigned short *) zAddress); zPixel = zPixel | (zPixel << 16); - + if (z < zPixel) { long rDithered, gDithered, bDithered; - + rDithered = rScaled >> MDmFractBits; gDithered = gScaled >> MDmFractBits; bDithered = bScaled >> MDmFractBits; @@ -340,7 +340,7 @@ MDrDrawContext_Method_Line_Interpolate( | ((gScaled >> (MDmFractBits + 3)) << 5) | (bScaled >> (MDmFractBits + 3))); } - + zAddress += zMajorIncrement; z += dZ; minorScaled += dMinorScaled; @@ -359,7 +359,7 @@ MDrDrawContext_Method_Line_Interpolate( } -void +void MDrDrawContext_Method_Line_Flat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -383,9 +383,9 @@ MDrDrawContext_Method_Line_Flat( long zRowBytes; float x0, y0, x1, y1; float dx, dy, fabs_dx, fabs_dy; - + M3tPointScreen *vCoordStart, *vCoordEnd; - + long major, minor; char *rgbAddress; char *zAddress; @@ -401,9 +401,9 @@ MDrDrawContext_Method_Line_Flat( M3tPointScreen* screenPoints; M3tPointScreen* vCoord0; M3tPointScreen* vCoord1; - + screenPoints = drawContextPrivate->statePtr[M3cDrawStatePtrType_ScreenPoint]; - + vCoord0 = screenPoints + inVIndex0; vCoord1 = screenPoints + inVIndex1; @@ -418,7 +418,7 @@ MDrDrawContext_Method_Line_Flat( * It appears that this functions requires clipped lines, I am adding assertions * */ - + UUmAssert(x0 >= 0.0); UUmAssert(x1 >= 0.0); UUmAssert(y0 >= 0.0); @@ -427,7 +427,7 @@ MDrDrawContext_Method_Line_Flat( UUmAssert(vCoord1->z >= 0.0); UUmAssert(vCoord0->z <= 1.0); UUmAssert(vCoord1->z <= 1.0); - + UUmAssert(x0 < width); UUmAssert(x1 < width); UUmAssert(y0 < height); @@ -441,7 +441,7 @@ MDrDrawContext_Method_Line_Flat( dx = x1 - x0; dy = y1 - y0; - + rgbPixelBytes = M3cDrawRGBBytesPerPixel; zPixelBytes = M3cDrawZBytesPerPixel; @@ -450,18 +450,18 @@ MDrDrawContext_Method_Line_Flat( rgbRowBytes = drawContextPrivate->imageBufferRowBytes; zRowBytes = drawContextPrivate->zBufferRowBytes; - + if (fabs_dx > fabs_dy) { /* * Δx is larger, so the major axis will be X. */ - + rgbMajorIncrement = rgbPixelBytes; zMajorIncrement = zPixelBytes; rgbMinorIncrement = rgbRowBytes; zMinorIncrement = zRowBytes; - + if (dx > 0.0F) { vCoordStart = vCoord0; @@ -487,12 +487,12 @@ MDrDrawContext_Method_Line_Flat( /* * Δy is larger, so the major axis will be Y. */ - + rgbMajorIncrement = rgbRowBytes; zMajorIncrement = zRowBytes; rgbMinorIncrement = rgbPixelBytes; zMinorIncrement = zPixelBytes; - + if (dy > 0.0F) { vCoordStart = vCoord0; @@ -513,19 +513,19 @@ MDrDrawContext_Method_Line_Flat( } fabsMajorDelta = fabs_dy; } - + /* * Snap major axis endpoints, including a 0.5 pixel subpixel coverage rule. */ - + majorStartSnapped = (UUtInt32)(majorStart + 0.5F); - + /* Avoid Divide by zero error */ if(fabsMajorDelta == 0.0F) { return; } - + invLength = 1.0F / fabsMajorDelta; snapCorrection = (majorStartSnapped + 0.5F) - majorStart; tempEnd = majorEnd - 0.5F; @@ -537,7 +537,7 @@ MDrDrawContext_Method_Line_Flat( * reasons -- if we continue, the cast of fTemp to an int will produce * 0, which isn't correct. */ - + return; } majorEndSnapped = (UUtInt32)tempEnd; @@ -547,33 +547,33 @@ MDrDrawContext_Method_Line_Flat( * initial value. This isn't really necessary if kQAZFunction_None is set, but testing * for that isn't really worth while. */ - + { const float zScale = (float)MSmULongScale; const float zOffset = (float)MSmULongOffset; - + tempStart = vCoordStart->z * zScale + zOffset; tempEnd = vCoordEnd->z * zScale + zOffset; dTemp = (tempEnd - tempStart) * invLength; z = (UUtUns32)(tempStart + snapCorrection * dTemp); dZ = (long) dTemp; - + } /* * Determine the initial minor axis value, the minor axis delta per major axis pixel, * and whether the minor axis will increment or decrement as we move along the major axis. */ - + minorScaled = (UUtInt32)(minorStart * (float)MSmFractOne); dMinorScaled = (UUtInt32)(minorDelta * invLength * (float)MSmFractOne); - + if (minorDelta < 0.0F) { /* * Minor axis decrements, so negate the rgb/zMinorIncrement values. */ - + rgbMinorIncrement = -rgbMinorIncrement; zMinorIncrement = -zMinorIncrement; } @@ -581,10 +581,10 @@ MDrDrawContext_Method_Line_Flat( major = majorStartSnapped; minor = minorScaled >> MSmFractBits; minorScaled &= fractMask; - + rgbAddress = (char *)drawContextPrivate->imageBufferBaseAddr + major * rgbMajorIncrement + minor * abs (rgbMinorIncrement); - + zAddress = (char *)drawContextPrivate->zBufferBaseAddr + major * zMajorIncrement + minor * abs (zMinorIncrement); @@ -592,7 +592,7 @@ MDrDrawContext_Method_Line_Flat( { zPixel = *((unsigned short *) zAddress); zPixel = zPixel | (zPixel << 16); - + if (z < zPixel) { @@ -600,7 +600,7 @@ MDrDrawContext_Method_Line_Flat( *((UUtUns16 *) rgbAddress) = inShade; } - + zAddress += zMajorIncrement; z += dZ; minorScaled += dMinorScaled; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_LinePoint.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_LinePoint.h index 2805b5a..e785ed4 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_LinePoint.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_LinePoint.h @@ -1,31 +1,31 @@ /* FILE: MD_DC_Method_LinePoint.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MD_DC_METHOD_LINEPOINT_H #define MD_DC_METHOD_LINEPOINT_H -void +void MDrDrawContext_Method_Point( M3tDrawContext* inDrawContext, M3tPointScreen* invCoord, UUtUns16 inVShade); -void +void MDrDrawContext_Method_Line_Interpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, UUtUns16 inVIndex1); -void +void MDrDrawContext_Method_Line_Flat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Pent.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Pent.c index 51c4511..876ce06 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Pent.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Pent.c @@ -5,8 +5,8 @@ CREATED: Sept 18, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ @@ -20,7 +20,7 @@ #include "MD_DC_Method_Triangle.h" #include "MD_DC_Method_Pent.h" -void +void MDrDrawContext_Method_PentGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -47,7 +47,7 @@ MDrDrawContext_Method_PentGouraudInterpolate( } -void +void MDrDrawContext_Method_PentGouraudFlat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -78,7 +78,7 @@ MDrDrawContext_Method_PentGouraudFlat( } -void +void MDrDrawContext_Method_PentTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Pent.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Pent.h index 9ad981b..0231843 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Pent.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Pent.h @@ -1,19 +1,19 @@ /* FILE: MD_DC_Method_Pent.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MD_DC_METHOD_PENT_H #define MD_DC_METHOD_PENT_H -void +void MDrDrawContext_Method_PentGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -22,7 +22,7 @@ MDrDrawContext_Method_PentGouraudInterpolate( UUtUns16 inVIndex3, UUtUns16 inVIndex4); -void +void MDrDrawContext_Method_PentGouraudFlat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -32,7 +32,7 @@ MDrDrawContext_Method_PentGouraudFlat( UUtUns16 inVIndex4, UUtUns16 inFaceShade); -void +void MDrDrawContext_Method_PentTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Quad.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Quad.c index d7eae4c..c53e435 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Quad.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Quad.c @@ -1,12 +1,12 @@ /* FILE: MD_DC_Method_Quad.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -20,7 +20,7 @@ #include "MD_DC_Method_Triangle.h" #include "MD_DC_Method_Quad.h" -void +void MDrDrawContext_Method_QuadGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -40,7 +40,7 @@ MDrDrawContext_Method_QuadGouraudInterpolate( inVIndex3); } -void +void MDrDrawContext_Method_QuadGouraudFlat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -64,7 +64,7 @@ MDrDrawContext_Method_QuadGouraudFlat( } -void +void MDrDrawContext_Method_QuadTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Quad.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Quad.h index 5babbc6..0c0dcac 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Quad.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Quad.h @@ -1,19 +1,19 @@ /* FILE: MD_DC_Method_Quad.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MD_DC_METHOD_QUAD_H #define MD_DC_METHOD_QUAD_H -void +void MDrDrawContext_Method_QuadGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -21,7 +21,7 @@ MDrDrawContext_Method_QuadGouraudInterpolate( UUtUns16 inVIndex2, UUtUns16 inVIndex3); -void +void MDrDrawContext_Method_QuadGouraudFlat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -30,7 +30,7 @@ MDrDrawContext_Method_QuadGouraudFlat( UUtUns16 inVIndex3, UUtUns16 inFaceShade); -void +void MDrDrawContext_Method_QuadTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Query.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Query.c index 3fe9c9f..53d1375 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Query.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Query.c @@ -19,12 +19,12 @@ MDrDrawContext_TextureFormatAvailable( M3tTexelType inTexelType) { DDPIXELFORMAT ddpf; - + // set up the ddsd UUrMemory_Clear(&ddpf, sizeof(DDPIXELFORMAT)); ddpf.dwSize = sizeof(DDPIXELFORMAT); ddpf.dwFlags = DDPF_RGB; - + switch (inTexelType) { case M3cTextureType_ARGB4444: @@ -35,7 +35,7 @@ MDrDrawContext_TextureFormatAvailable( ddpf.dwBBitMask = 0x0000000F; ddpf.dwRGBAlphaBitMask = 0x0000F000; break; - + case M3cTextureType_RGB555: ddpf.dwRGBBitCount = 16; ddpf.dwRBitMask = 0x00007C00; @@ -43,7 +43,7 @@ MDrDrawContext_TextureFormatAvailable( ddpf.dwBBitMask = 0x0000001F; ddpf.dwRGBAlphaBitMask = 0x00000000; break; - + case M3cTextureType_ARGB1555: ddpf.dwRGBBitCount = 16; ddpf.dwFlags |= DDPF_ALPHAPIXELS; @@ -52,7 +52,7 @@ MDrDrawContext_TextureFormatAvailable( ddpf.dwBBitMask = 0x0000001F; ddpf.dwRGBAlphaBitMask = 0x00008000; break; - + case M3cTextureType_ARGB8888: ddpf.dwRGBBitCount = 32; ddpf.dwFlags |= DDPF_ALPHAPIXELS; @@ -62,12 +62,12 @@ MDrDrawContext_TextureFormatAvailable( ddpf.dwRGBAlphaBitMask = 0xFF000000; break; } - + // search the available texture formats to see if the desired one // is available if (MDrTextureFormatAvailable(&ddpf)) return UUcTrue; - + return UUcFalse; } @@ -78,7 +78,7 @@ MDrDrawContext_GetWidth( { MDtDrawContextPrivate *drawContextPrivate; drawContextPrivate = (MDtDrawContextPrivate *)inDrawContext->privateContext; - + return (UUtUns16)drawContextPrivate->width; } @@ -89,7 +89,7 @@ MDrDrawContext_GetHeight( { MDtDrawContextPrivate *drawContextPrivate; drawContextPrivate = (MDtDrawContextPrivate *)inDrawContext->privateContext; - + return (UUtUns16)drawContextPrivate->height; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Query.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Query.h index 2484475..245cb96 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Query.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Query.h @@ -25,4 +25,4 @@ MDrDrawContext_GetHeight( M3tDrawContext *inDrawContext); // ====================================================================== -#endif /* MD_DC_METHOD_QUERY_H */ \ No newline at end of file +#endif /* MD_DC_METHOD_QUERY_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_SmallQuad.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_SmallQuad.c index 991b0aa..ec90e1e 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_SmallQuad.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_SmallQuad.c @@ -1,12 +1,12 @@ /* FILE: MD_DC_Method_SmallQuad.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -20,7 +20,7 @@ #include "MD_DC_Method_Triangle.h" #include "MD_DC_Method_SmallQuad.h" -void +void MDrDrawContext_Method_SmallQuadGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns32 inIndices) @@ -37,7 +37,7 @@ MDrDrawContext_Method_SmallQuadGouraudInterpolate( (UUtUns16)(inIndices & 0xFF)); } -void +void MDrDrawContext_Method_SmallQuadGouraudFlat( M3tDrawContext* inDrawContext, UUtUns32 inIndices, @@ -57,7 +57,7 @@ MDrDrawContext_Method_SmallQuadGouraudFlat( inFaceShade); } -void +void MDrDrawContext_Method_SmallQuadTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns32 inIndices) diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_SmallQuad.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_SmallQuad.h index 744c6b4..a0ba4d6 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_SmallQuad.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_SmallQuad.h @@ -1,30 +1,30 @@ /* FILE: MD_DC_Method_SmallQuad.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MD_DC_METHOD_SMALLQUAD_H #define MD_DC_METHOD_SMALLQUAD_H -void +void MDrDrawContext_Method_SmallQuadGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns32 inIndices); -void +void MDrDrawContext_Method_SmallQuadGouraudFlat( M3tDrawContext* inDrawContext, UUtUns32 inIndices, UUtUns16 inFaceShade); -void +void MDrDrawContext_Method_SmallQuadTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns32 inIndices); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_State.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_State.c index 64b7bb7..a8ec7fa 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_State.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_State.c @@ -1,12 +1,12 @@ /* FILE: MD_DC_Method_State.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -32,14 +32,14 @@ MDrDrawContext_Method_State_SetInt( { MDtDrawContextPrivate *drawContextPrivate = (MDtDrawContextPrivate *)inDrawContext->privateContext; M3tDrawContextMethod method; - + if(drawContextPrivate->stateInt[inDrawStateType] == inDrawState) { return; } - + drawContextPrivate->stateInt[inDrawStateType] = inDrawState; - + if(inDrawStateType == M3cDrawStateIntType_Appearence) { switch((M3tDrawStateAppearence)inDrawState) @@ -50,50 +50,50 @@ MDrDrawContext_Method_State_SetInt( inDrawContext, M3cDrawContextMethodType_TriInterpolate, method); - + method.triFlat = MDrDrawContext_Method_TriGouraudFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_TriFlat, method); - + method.quadInterpolate = MDrDrawContext_Method_QuadGouraudInterpolate; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_QuadInterpolate, method); - + method.quadFlat = MDrDrawContext_Method_QuadGouraudFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_QuadFlat, method); - + method.smallQuadInterpolate = MDrDrawContext_Method_SmallQuadGouraudInterpolate; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_SmallQuadInterpolate, method); - + method.smallQuadFlat = MDrDrawContext_Method_SmallQuadGouraudFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_SmallQuadFlat, method); - + method.pentInterpolate = MDrDrawContext_Method_PentGouraudInterpolate; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_PentInterpolate, method); - + method.pentFlat = MDrDrawContext_Method_PentGouraudFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_PentFlat, method); break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: method.triInterpolate = MDrDrawContext_Method_TriTextureInterpolate; @@ -101,50 +101,50 @@ MDrDrawContext_Method_State_SetInt( inDrawContext, M3cDrawContextMethodType_TriInterpolate, method); - + method.triFlat = MDrDrawContext_Method_TriTextureFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_TriFlat, method); - + method.quadInterpolate = MDrDrawContext_Method_QuadTextureInterpolate; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_QuadInterpolate, method); - + method.quadFlat = MDrDrawContext_Method_QuadTextureFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_QuadFlat, method); - + method.smallQuadInterpolate = MDrDrawContext_Method_SmallQuadTextureInterpolate; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_SmallQuadInterpolate, method); - + method.smallQuadFlat = MDrDrawContext_Method_SmallQuadTextureFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_SmallQuadFlat, method); - + method.pentInterpolate = MDrDrawContext_Method_PentTextureInterpolate; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_PentInterpolate, method); - + method.pentFlat = MDrDrawContext_Method_PentTextureFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_PentFlat, method); break; - + default: UUmAssert(!"Unkown appearence type"); } @@ -157,7 +157,7 @@ MDrDrawContext_Method_State_GetInt( M3tDrawStateIntType inDrawStateType) { MDtDrawContextPrivate *drawContextPrivate = (MDtDrawContextPrivate *)inDrawContext->privateContext; - + return drawContextPrivate->stateInt[inDrawStateType]; } @@ -178,6 +178,6 @@ MDrDrawContext_Method_State_GetPtr( M3tDrawStatePtrType inDrawStateType) { MDtDrawContextPrivate *drawContextPrivate = (MDtDrawContextPrivate *)inDrawContext->privateContext; - + return drawContextPrivate->statePtr[inDrawStateType]; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_State.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_State.h index 4be296d..e72be29 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_State.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_State.h @@ -1,12 +1,12 @@ /* FILE: MD_DC_Method_State.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Triangle.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Triangle.c index 13303bb..1141638 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Triangle.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Triangle.c @@ -1,12 +1,12 @@ /* FILE: MD_DC_Method_Triangle.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -26,7 +26,7 @@ // funcitons // ====================================================================== // ---------------------------------------------------------------------- -void +void MDrDrawContext_Method_TriGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -37,18 +37,18 @@ MDrDrawContext_Method_TriGouraudInterpolate( MDtDrawContextPrivate *drawContextPrivate; D3DTLVERTEX vertex_list[3]; M3tPointScreen *screenPoints; - + // get access to the private context drawContextPrivate = (MDtDrawContextPrivate*)inDrawContext->privateContext; if (drawContextPrivate == NULL) return; - + // get the list of screen points screenPoints = (M3tPointScreen*)drawContextPrivate->statePtr[ M3cDrawStatePtrType_ScreenPointArray]; - + // set up the vertex_list vertex_list[0].sx = screenPoints[inVIndex0].x; vertex_list[0].sy = screenPoints[inVIndex0].y; @@ -56,23 +56,23 @@ MDrDrawContext_Method_TriGouraudInterpolate( vertex_list[0].rhw = screenPoints[inVIndex0].invW; vertex_list[0].color = RGB_MAKE(255,255,255); vertex_list[0].specular = RGB_MAKE(0,0,0); - + vertex_list[1].sx = screenPoints[inVIndex1].x; vertex_list[1].sy = screenPoints[inVIndex1].y; vertex_list[1].sz = screenPoints[inVIndex1].z; vertex_list[1].rhw = screenPoints[inVIndex1].invW; vertex_list[1].color = RGB_MAKE(255,255,255); vertex_list[1].specular = RGB_MAKE(0,0,0); - + vertex_list[2].sx = screenPoints[inVIndex2].x; vertex_list[2].sy = screenPoints[inVIndex2].y; vertex_list[2].sz = screenPoints[inVIndex2].z; vertex_list[2].rhw = screenPoints[inVIndex2].invW; vertex_list[2].color = RGB_MAKE(255,255,255); vertex_list[2].specular = RGB_MAKE(0,0,0); - + // draw the triangle - d3dResult = + d3dResult = IDirect3DDevice2_DrawPrimitive( drawContextPrivate->d3d_device2, D3DPT_TRIANGLELIST, @@ -83,7 +83,7 @@ MDrDrawContext_Method_TriGouraudInterpolate( } // ---------------------------------------------------------------------- -void +void MDrDrawContext_Method_TriGouraudFlat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -95,18 +95,18 @@ MDrDrawContext_Method_TriGouraudFlat( MDtDrawContextPrivate *drawContextPrivate; D3DTLVERTEX vertex_list[3]; M3tPointScreen *screenPoints; - + // get access to the private context drawContextPrivate = (MDtDrawContextPrivate*)inDrawContext->privateContext; if (drawContextPrivate == NULL) return; - + // get the list of screen points screenPoints = (M3tPointScreen*)drawContextPrivate->statePtr[ M3cDrawStatePtrType_ScreenPointArray]; - + // set up the vertex_list vertex_list[0].sx = screenPoints[inVIndex0].x; vertex_list[0].sy = screenPoints[inVIndex0].y; @@ -114,23 +114,23 @@ MDrDrawContext_Method_TriGouraudFlat( vertex_list[0].rhw = screenPoints[inVIndex0].invW; vertex_list[0].color = RGB_MAKE(255,255,255); vertex_list[0].specular = RGB_MAKE(0,0,0); - + vertex_list[1].sx = screenPoints[inVIndex1].x; vertex_list[1].sy = screenPoints[inVIndex1].y; vertex_list[1].sz = screenPoints[inVIndex1].z; vertex_list[1].rhw = screenPoints[inVIndex1].invW; vertex_list[1].color = RGB_MAKE(255,255,255); vertex_list[1].specular = RGB_MAKE(0,0,0); - + vertex_list[2].sx = screenPoints[inVIndex2].x; vertex_list[2].sy = screenPoints[inVIndex2].y; vertex_list[2].sz = screenPoints[inVIndex2].z; vertex_list[2].rhw = screenPoints[inVIndex2].invW; vertex_list[2].color = RGB_MAKE(255,255,255); vertex_list[2].specular = RGB_MAKE(0,0,0); - + // draw the triangle - d3dResult = + d3dResult = IDirect3DDevice2_DrawPrimitive( drawContextPrivate->d3d_device2, D3DPT_TRIANGLELIST, @@ -141,7 +141,7 @@ MDrDrawContext_Method_TriGouraudFlat( } // ---------------------------------------------------------------------- -void +void MDrDrawContext_Method_TriTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -152,18 +152,18 @@ MDrDrawContext_Method_TriTextureInterpolate( MDtDrawContextPrivate *drawContextPrivate; D3DTLVERTEX vertex_list[3]; M3tPointScreen *screenPoints; - + // get access to the private context drawContextPrivate = (MDtDrawContextPrivate*)inDrawContext->privateContext; if (drawContextPrivate == NULL) return; - + // get the list of screen points screenPoints = (M3tPointScreen*)drawContextPrivate->statePtr[ M3cDrawStatePtrType_ScreenPointArray]; - + // set up the vertex_list vertex_list[0].sx = screenPoints[inVIndex0].x; vertex_list[0].sy = screenPoints[inVIndex0].y; @@ -171,23 +171,23 @@ MDrDrawContext_Method_TriTextureInterpolate( vertex_list[0].rhw = screenPoints[inVIndex0].invW; vertex_list[0].color = RGB_MAKE(255,255,255); vertex_list[0].specular = RGB_MAKE(0,0,0); - + vertex_list[1].sx = screenPoints[inVIndex1].x; vertex_list[1].sy = screenPoints[inVIndex1].y; vertex_list[1].sz = screenPoints[inVIndex1].z; vertex_list[1].rhw = screenPoints[inVIndex1].invW; vertex_list[1].color = RGB_MAKE(255,255,255); vertex_list[1].specular = RGB_MAKE(0,0,0); - + vertex_list[2].sx = screenPoints[inVIndex2].x; vertex_list[2].sy = screenPoints[inVIndex2].y; vertex_list[2].sz = screenPoints[inVIndex2].z; vertex_list[2].rhw = screenPoints[inVIndex2].invW; vertex_list[2].color = RGB_MAKE(255,255,255); vertex_list[2].specular = RGB_MAKE(0,0,0); - + // draw the triangle - d3dResult = + d3dResult = IDirect3DDevice2_DrawPrimitive( drawContextPrivate->d3d_device2, D3DPT_TRIANGLELIST, @@ -214,7 +214,7 @@ MDrDrawContext_Method_TriTextureFlat( UUtUns8 color1, color2, color3; color1 = color2 = color3 = 255; - + // get access to the data drawContextPrivate = (MDtDrawContextPrivate*)inDrawContext->privateContext; @@ -231,7 +231,7 @@ MDrDrawContext_Method_TriTextureFlat( MDrUseTexture( drawContextPrivate, drawContextPrivate->statePtr[M3cDrawStatePtrType_BaseTextureMap]); - + // set up the vertex_list vertex_list[0].sx = screenPoints[inVIndex0].x; vertex_list[0].sy = screenPoints[inVIndex0].y; @@ -241,7 +241,7 @@ MDrDrawContext_Method_TriTextureFlat( vertex_list[0].tv = textureCoords[inVIndex0].v; vertex_list[0].color = RGB_MAKE(color1, color2, color3); vertex_list[0].specular = RGB_MAKE(0,0,0); - + vertex_list[1].sx = screenPoints[inVIndex1].x; vertex_list[1].sy = screenPoints[inVIndex1].y; vertex_list[1].sz = screenPoints[inVIndex1].z; @@ -250,7 +250,7 @@ MDrDrawContext_Method_TriTextureFlat( vertex_list[1].tv = textureCoords[inVIndex1].v; vertex_list[1].color = RGB_MAKE(color1, color2, color3); vertex_list[1].specular = RGB_MAKE(0,0,0); - + vertex_list[2].sx = screenPoints[inVIndex2].x; vertex_list[2].sy = screenPoints[inVIndex2].y; vertex_list[2].sz = screenPoints[inVIndex2].z; @@ -259,9 +259,9 @@ MDrDrawContext_Method_TriTextureFlat( vertex_list[2].tv = textureCoords[inVIndex2].v; vertex_list[2].color = RGB_MAKE(color1, color2, color3); vertex_list[2].specular = RGB_MAKE(0,0,0); - + // draw the triangle - result = + result = IDirect3DDevice2_DrawPrimitive( drawContextPrivate->d3d_device2, D3DPT_TRIANGLELIST, @@ -291,9 +291,9 @@ MDrDrawContext_Method_TriTextureSplit( M3tPointScreen *screenPoints; M3tTextureCoord *textureCoords; UUtUns8 color1, color2, color3; - + color1 = color2 = color3 = 255; - + // get access to the data drawContextPrivate = (MDtDrawContextPrivate*)inDrawContext->privateContext; @@ -310,7 +310,7 @@ MDrDrawContext_Method_TriTextureSplit( MDrUseTexture( drawContextPrivate, drawContextPrivate->statePtr[M3cDrawStatePtrType_BaseTextureMap]); - + // set up the vertex_list vertex_list[0].sx = screenPoints[inVIndex0].x; vertex_list[0].sy = screenPoints[inVIndex0].y; @@ -320,7 +320,7 @@ MDrDrawContext_Method_TriTextureSplit( vertex_list[0].tv = textureCoords[inBaseUVIndex0].v; vertex_list[0].color = RGB_MAKE(color1, color2, color3); vertex_list[0].specular = RGB_MAKE(0,0,0); - + vertex_list[1].sx = screenPoints[inVIndex1].x; vertex_list[1].sy = screenPoints[inVIndex1].y; vertex_list[1].sz = screenPoints[inVIndex1].z; @@ -329,7 +329,7 @@ MDrDrawContext_Method_TriTextureSplit( vertex_list[1].tv = textureCoords[inBaseUVIndex1].v; vertex_list[1].color = RGB_MAKE(color1, color2, color3); vertex_list[1].specular = RGB_MAKE(0,0,0); - + vertex_list[2].sx = screenPoints[inVIndex2].x; vertex_list[2].sy = screenPoints[inVIndex2].y; vertex_list[2].sz = screenPoints[inVIndex2].z; @@ -338,9 +338,9 @@ MDrDrawContext_Method_TriTextureSplit( vertex_list[2].tv = textureCoords[inBaseUVIndex2].v; vertex_list[2].color = RGB_MAKE(color1, color2, color3); vertex_list[2].specular = RGB_MAKE(0,0,0); - + // draw the triangle - result = + result = IDirect3DDevice2_DrawPrimitive( drawContextPrivate->d3d_device2, D3DPT_TRIANGLELIST, @@ -348,4 +348,4 @@ MDrDrawContext_Method_TriTextureSplit( vertex_list, 3, D3DDP_WAIT); -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Triangle.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Triangle.h index 5b18843..ed0ed41 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Triangle.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Method_Triangle.h @@ -1,26 +1,26 @@ /* FILE: MD_DC_Method_Triangle.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MD_DC_METHOD_TRIANGLE_H #define MD_DC_METHOD_TRIANGLE_H -void +void MDrDrawContext_Method_TriGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, UUtUns16 inVIndex1, UUtUns16 inVIndex2); -void +void MDrDrawContext_Method_TriGouraudFlat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -28,7 +28,7 @@ MDrDrawContext_Method_TriGouraudFlat( UUtUns16 inVIndex2, UUtUns16 inFaceShade); -void +void MDrDrawContext_Method_TriTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Private.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Private.h index d12bab4..9344a6c 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DC_Private.h @@ -1,12 +1,12 @@ /* FILE: MD_DrawContext_Private.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 17, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -32,19 +32,19 @@ typedef struct MDtDrawContextPrivate UUtInt32 height; // width of front buffer UUtInt32 bpp; // bits per pixel UUtInt32 zbpp; // bits per pixel of zBuffer - + UUtBool isHardware; // d3d_device is a hardware device - + M3tDrawContextType contextType; M3tDrawContextScreenFlags screenFlags; - + // DirectX data LPDIRECTDRAW dd; // DirectDraw device LPDIRECTDRAW2 dd2; // DirectDraw 2 device LPDIRECT3D2 d3d2; // Direct3D2 LPDIRECT3DDEVICE2 d3d_device2; // Direct3D Device2 LPDIRECT3DVIEWPORT2 d3d_viewport2; // Direct3D Viewport2 - + // Draw data LPDIRECTDRAWSURFACE frontBuffer; // buffer displayed on the screen LPDIRECTDRAWSURFACE backBuffer; // buffer to draw into @@ -52,11 +52,11 @@ typedef struct MDtDrawContextPrivate RECT rect; DWORD top; DWORD left; - + // Array data void* statePtr[M3cDrawStatePtrType_NumTypes]; UUtInt32 stateInt[M3cDrawStateIntType_NumTypes]; - + } MDtDrawContextPrivate; // ---------------------------------------------------------------------- @@ -73,7 +73,7 @@ typedef struct MDtTextureMapPrivate D3DTEXTUREHANDLE texture_handle; LPDIRECTDRAWSURFACE3 memory_surface; LPDIRECTDRAWSURFACE3 device_surface; - + } MDtTextureMapPrivate; // ====================================================================== diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DrawEngine_Method.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DrawEngine_Method.c index b1f05f7..cf88b07 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DrawEngine_Method.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DrawEngine_Method.c @@ -1,12 +1,12 @@ /* FILE: MD_DrawEngine_Method.c - + AUTHOR: Kevin Armstrong - + CREATED: January 5, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1998 */ @@ -52,15 +52,15 @@ typedef struct MDtD3D_device_info { GUID d3d_guid; - + char device_desc[MDcMaxDescChars]; - + D3DDEVICEDESC HAL_desc; D3DDEVICEDESC HEL_desc; - + UUtUns16 num_texture_formats; DDSURFACEDESC texture_format[MDcMaxTextureDesc]; - + } MDtD3D_device_info; typedef struct MDtPlatform @@ -70,7 +70,7 @@ typedef struct MDtPlatform UUtUns16 num_d3d_devices; MDtD3D_device_info d3d_devices[MDcMaxD3DDevices]; - + } MDtPlatform; // ====================================================================== @@ -85,7 +85,7 @@ MDiInitBuffers( MDtDrawContextPrivate *inDrawContextPrivate, M3tDisplayDevice *inDisplayDevice, UUtUns32 inD3DDevice); - + UUtError MDiInitD3D( MDtDrawContextPrivate *inDrawContextPrivate, @@ -99,7 +99,7 @@ MDrDrawContext_Method_Frame_Start( UUtError MDrDrawContext_Method_Frame_End( M3tDrawContext *inDrawContext); - + UUtError MDrDrawContext_Method_Frame_Sync( M3tDrawContext *drawContext); @@ -170,26 +170,26 @@ static UUtError MDrDrawEngine_SetupDrawContextPrivate( // get a pointer to onScreen onScreen = &inDrawContextDescriptor->drawContext.onScreen; - + // ---------------------------------------- // Create the direct draw object // ---------------------------------------- // get a pointer to the draw engine caps list draw_engine_caps_list = M3rDrawEngine_GetCapList(); - + UUmAssert(draw_engine_caps_list); - + // get the index of the active draw engine M3rManager_GetActiveDrawEngine(&activeDrawEngine, &activeDevice, &activeMode); - + // get a pointer to the current draw engine's caps current_draw_engine_caps = &draw_engine_caps_list->drawEngines[activeDrawEngine]; - + // get a pointer to the platform_data - platform_data = + platform_data = (MDtPlatform*)current_draw_engine_caps->displayDevices[activeDevice].platformDevice; - + // create the DirectDraw object if (platform_data->primary) { @@ -211,7 +211,7 @@ static UUtError MDrDrawEngine_SetupDrawContextPrivate( { UUmError_ReturnOnErrorMsg(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); } - + // get the DirectDraw2 object result = IDirectDraw_QueryInterface( @@ -222,11 +222,11 @@ static UUtError MDrDrawEngine_SetupDrawContextPrivate( { UUmError_ReturnOnErrorMsg(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); } - + // ---------------------------------------- // Setup the connection to the window // ---------------------------------------- - + // set the flags for the window if (inFullScreen == UUcTrue) { @@ -236,7 +236,7 @@ static UUtError MDrDrawEngine_SetupDrawContextPrivate( { win_flags = DDSCL_NOWINDOWCHANGES | DDSCL_NORMAL; } - + // set the cooperative level result = IDirectDraw2_SetCooperativeLevel( @@ -247,11 +247,11 @@ static UUtError MDrDrawEngine_SetupDrawContextPrivate( { UUmError_ReturnOnErrorMsg(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); } - + // ---------------------------------------- // create the Direct3D interface // ---------------------------------------- - + // get the d3d2 interface from DirectDraw result = IDirectDraw2_QueryInterface( @@ -266,10 +266,10 @@ static UUtError MDrDrawEngine_SetupDrawContextPrivate( // ---------------------------------------- // setup the buffers and whatnots // ---------------------------------------- - + // get the d3d_device index d3d_device_index = MDiGetD3DDeviceIndex(); - + if (inDrawContextDescriptor->type == M3cDrawContextType_OnScreen) { // XXX - this may need to change to better reflect the activeMode @@ -298,7 +298,7 @@ static UUtError MDrDrawEngine_SetupDrawContextPrivate( ¤t_draw_engine_caps->displayDevices[activeDevice], d3d_device_index); UUmError_ReturnOnErrorMsg(error, "Unable to init the buffers."); - + // Initialize Direct3D error = MDiInitD3D( @@ -315,7 +315,7 @@ static UUtError MDrDrawEngine_SetupDrawContextPrivate( // ---------------------------------------- // Set the display mode // ---------------------------------------- - + result = IDirectDraw2_SetDisplayMode( inDrawContextPrivate->dd2, @@ -325,8 +325,8 @@ static UUtError MDrDrawEngine_SetupDrawContextPrivate( 60, 0); UUmError_ReturnOnErrorMsg(error, "Unable to set the display mode."); - - + + return UUcError_None; } @@ -353,11 +353,11 @@ MDrDrawEngine_Method_ContextPrivateDelete( M3tDrawContextPrivate *inDrawContextPrivate) { MDtDrawContextPrivate *contextPrivate; - + contextPrivate = (MDtDrawContextPrivate *)inDrawContextPrivate; MDrDrawEngine_DestroyDrawContextPrivate(contextPrivate); - + UUrMemory_Block_Delete(inDrawContextPrivate); } @@ -371,7 +371,7 @@ MDrDrawEngine_Method_ContextPrivateNew( { UUtError errorCode; MDtDrawContextPrivate *newDrawContextPrivate; - + *outDrawContextPrivate = NULL; *outAPI = M3cDrawAPI_D3D; @@ -381,13 +381,13 @@ MDrDrawEngine_Method_ContextPrivateNew( { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not allocate private draw context"); } - + // clear the structure UUrMemory_Clear(newDrawContextPrivate, sizeof(MDtDrawContextPrivate)); - + // set the contextType newDrawContextPrivate->contextType = inDrawContextDescriptor->type; - + // set the screenFlags if (inDrawContextDescriptor->type == M3cDrawContextType_OnScreen) { @@ -398,7 +398,7 @@ MDrDrawEngine_Method_ContextPrivateNew( { newDrawContextPrivate->screenFlags = M3cDrawContextScreenFlags_None; } - + // Setup the platform specific data errorCode = MDrDrawEngine_SetupDrawContextPrivate( @@ -409,17 +409,17 @@ MDrDrawEngine_Method_ContextPrivateNew( { goto failure; } - + // return the new draw context *outDrawContextPrivate = (M3tDrawContextPrivate*)newDrawContextPrivate; - + return UUcError_None; - + failure: - + MDrDrawEngine_Method_ContextPrivateDelete( (M3tDrawContextPrivate *)newDrawContextPrivate); - + return errorCode; } @@ -431,220 +431,220 @@ MDrDrawEngine_Method_ContextMetaHandler( M3tDrawContextMethod* inMethod) { MDtDrawContextPrivate *drawContextPrivate; - + // get a pointer shortcut drawContextPrivate = (MDtDrawContextPrivate *)inDrawContext->privateContext; - + switch (inMethodType) { case M3cDrawContextMethodType_Frame_Start: inMethod->frameStart = MDrDrawContext_Method_Frame_Start; break; - + case M3cDrawContextMethodType_Frame_End: inMethod->frameEnd = MDrDrawContext_Method_Frame_End; break; - + case M3cDrawContextMethodType_Frame_Sync: inMethod->frameSync = MDrDrawContext_Method_Frame_Sync; break; - + case M3cDrawContextMethodType_State_SetInt: inMethod->stateSetInt = MDrDrawContext_Method_State_SetInt; break; - + case M3cDrawContextMethodType_State_GetInt: inMethod->stateGetInt = MDrDrawContext_Method_State_GetInt; break; - + case M3cDrawContextMethodType_State_SetPtr: inMethod->stateSetPtr = MDrDrawContext_Method_State_SetPtr; break; - + case M3cDrawContextMethodType_State_GetPtr: inMethod->stateGetPtr = MDrDrawContext_Method_State_GetPtr; break; - + case M3cDrawContextMethodType_TriInterpolate: switch (drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: inMethod->triInterpolate = MDrDrawContext_Method_TriGouraudInterpolate; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: inMethod->triInterpolate = MDrDrawContext_Method_TriTextureInterpolate; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_TriFlat: switch (drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: inMethod->triFlat = MDrDrawContext_Method_TriGouraudFlat; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: inMethod->triFlat = MDrDrawContext_Method_TriTextureFlat; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_TriSplit: inMethod->triSplit = MDrDrawContext_Method_TriTextureSplit; break; - + case M3cDrawContextMethodType_QuadInterpolate: switch (drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: inMethod->quadInterpolate = MDrDrawContext_Method_QuadGouraudInterpolate; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: inMethod->quadInterpolate = MDrDrawContext_Method_QuadTextureInterpolate; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_QuadFlat: switch (drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: inMethod->quadFlat = MDrDrawContext_Method_QuadGouraudFlat; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: inMethod->quadFlat = MDrDrawContext_Method_QuadTextureFlat; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_QuadSplit: inMethod->quadSplit = MDrDrawContext_Method_QuadTextureSplit; break; - + case M3cDrawContextMethodType_SmallQuadInterpolate: switch (drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: inMethod->smallQuadInterpolate = MDrDrawContext_Method_SmallQuadGouraudInterpolate; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: inMethod->smallQuadInterpolate = MDrDrawContext_Method_SmallQuadTextureInterpolate; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_SmallQuadFlat: switch (drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: inMethod->smallQuadFlat = MDrDrawContext_Method_SmallQuadGouraudFlat; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: inMethod->smallQuadFlat = MDrDrawContext_Method_SmallQuadTextureFlat; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_PentInterpolate: switch (drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: inMethod->pentInterpolate = MDrDrawContext_Method_PentGouraudInterpolate; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: inMethod->pentInterpolate = MDrDrawContext_Method_PentTextureInterpolate; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_PentFlat: switch (drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: inMethod->pentFlat = MDrDrawContext_Method_PentGouraudFlat; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: inMethod->pentFlat = MDrDrawContext_Method_PentTextureFlat; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_PentSplit: inMethod->pentSplit = MDrDrawContext_Method_PentTextureSplit; break; - + case M3cDrawContextMethodType_Line_Interpolate: inMethod->lineInterpolate = MDrDrawContext_Method_Line_Interpolate; break; - + case M3cDrawContextMethodType_Line_Flat: inMethod->lineFlat = MDrDrawContext_Method_Line_Flat; break; - + case M3cDrawContextMethodType_Point: inMethod->point = MDrDrawContext_Method_Point; break; - + case M3cDrawContextMethodType_Bitmap: inMethod->bitmap = MDrDrawContext_Method_Bitmap; break; - + case M3cDrawContextMethodType_TextureFormatAvailable: inMethod->textureFormatAvailable = MDrDrawContext_TextureFormatAvailable; break; - + case M3cDrawContextMethodType_GetWidth: inMethod->getWidth = MDrDrawContext_GetWidth; break; - + case M3cDrawContextMethodType_GetHeight: inMethod->getHeight = MDrDrawContext_GetHeight; break; - + default: UUmDebugStr("MDrDrawEngine_Method_ContextMetaHandler: invalid case"); } - + return UUcError_None; } @@ -662,30 +662,30 @@ MDrTextureFormatAvailable( UUtUns16 activeMode; UUtUns32 d3d_device_index; UUtUns32 i; - + // get a pointer to the draw engine caps list draw_engine_caps_list = M3rDrawEngine_GetCapList(); - + UUmAssert(draw_engine_caps_list); - + // get the index of the active draw engine M3rManager_GetActiveDrawEngine(&activeDrawEngine, &activeDevice, &activeMode); - + // get a pointer to the current draw engine's caps current_draw_engine_caps = &draw_engine_caps_list->drawEngines[activeDrawEngine]; - + // get a pointer to the platform_data - platform_data = + platform_data = (MDtPlatform*)current_draw_engine_caps->displayDevices[activeDevice].platformDevice; // get the d3d_device index d3d_device_index = MDiGetD3DDeviceIndex(); - + for (i = 0; i < platform_data->d3d_devices[d3d_device_index].num_texture_formats; i++) { // get a pointer to the pixel format ddpf = &platform_data->d3d_devices[d3d_device_index].texture_format[i].ddpfPixelFormat; - + // check to see that the important parts are the same if ((ddpf->dwFlags & DDPF_RGB) == (inDDPixelFormat->dwFlags & DDPF_RGB)) { @@ -706,7 +706,7 @@ MDrTextureFormatAvailable( } } } - + return UUcFalse; } @@ -721,14 +721,14 @@ MDrDrawEngine_Method_Texture_Init( M3tTextureMap* inTextureMap) { MDtTextureMapPrivate* privateData; - + // get a pointer to the texturemaps private data privateData = (MDtTextureMapPrivate*)M3rManager_Texture_GetEnginePrivate( inTextureMap); - + UUmAssert(privateData != NULL); - + if(inTextureMap->numLongs > 1 && inTextureMap->width > 0 && inTextureMap->height > 0) { // clear the variables @@ -737,7 +737,7 @@ MDrDrawEngine_Method_Texture_Init( privateData->memory_surface = NULL; privateData->device_surface = NULL; } - + return UUcError_None; } @@ -746,7 +746,7 @@ static UUtError MDrDrawEngine_Method_Texture_Load( M3tTextureMap* inTextureMap) { - + return UUcError_None; } @@ -755,7 +755,7 @@ static UUtError MDrDrawEngine_Method_Texture_Unload( M3tTextureMap* inTextureMap) { - + return UUcError_None; } @@ -765,26 +765,26 @@ MDrDrawEngine_Method_Texture_Delete( M3tTextureMap* inTextureMap) { MDtTextureMapPrivate* privateData; - + // get a pointer to the texturemaps private data privateData = (MDtTextureMapPrivate*)M3rManager_Texture_GetEnginePrivate( inTextureMap); - + UUmAssert(privateData != NULL); - + if (privateData->memory_surface) { IDirectDrawSurface3_Release(privateData->memory_surface); privateData->memory_surface = NULL; } - + if (privateData->device_surface) { IDirectDrawSurface3_Release(privateData->device_surface); privateData->device_surface = NULL; } - + return UUcError_None; } @@ -793,7 +793,7 @@ static UUtError MDrDrawEngine_Method_Texture_Update( M3tTextureMap* inTextureMap) { - + return UUcError_None; } @@ -811,7 +811,7 @@ MDrDrawEngine_Initialize( OSVERSIONINFO info; M3tDrawEngineCaps drawEngineCaps; M3tDrawEngineMethods drawEngineMethods; - + // find out which OS the game is running under info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx(&info)) @@ -825,21 +825,21 @@ MDrDrawEngine_Initialize( drawEngineMethods.contextPrivateNew = MDrDrawEngine_Method_ContextPrivateNew; drawEngineMethods.contextPrivateDelete = MDrDrawEngine_Method_ContextPrivateDelete; drawEngineMethods.contextMetaHandler = MDrDrawEngine_Method_ContextMetaHandler; - + drawEngineMethods.textureInit = MDrDrawEngine_Method_Texture_Init; drawEngineMethods.textureLoad = MDrDrawEngine_Method_Texture_Load; drawEngineMethods.textureUnload = MDrDrawEngine_Method_Texture_Unload; drawEngineMethods.textureDelete = MDrDrawEngine_Method_Texture_Delete; drawEngineMethods.textureUpdate = MDrDrawEngine_Method_Texture_Update; - + // Setup engine caps UUrMemory_Clear(&drawEngineCaps, sizeof(M3tDrawEngineCaps)); - + drawEngineCaps.engineFlags = M3cDrawEngineFlag_3DOnly; - + UUrString_Copy(drawEngineCaps.engineName, M3cDrawEngine_D3D, M3cMaxNameLen); drawEngineCaps.engineDriver[0] = 0; - + drawEngineCaps.engineVersion = MDcD3D_Version; // Setup engine caps @@ -849,7 +849,7 @@ MDrDrawEngine_Initialize( UUrError_Report(UUcError_Generic, "Could not setup engine caps"); return; } - + // register the Direct3D draw engine error = M3rManager_Register_DrawEngine( @@ -882,7 +882,7 @@ MDrUseTexture( UUmAssert(inDrawContextPrivate); UUmAssert(inTextureMap); - + textureMapPrivate = (MDtTextureMapPrivate*)(TMmInstance_GetDynamicData(inTextureMap)); @@ -894,7 +894,7 @@ MDrUseTexture( DDSURFACEDESC ddsd; LPDIRECTDRAWSURFACE temp_surface; LPDIRECT3DTEXTURE2 texture; - + // -------------------------------------------------- // setup the surface description UUrMemory_Clear(&ddsd, sizeof(DDSURFACEDESC)); @@ -907,10 +907,10 @@ MDrUseTexture( ddsd.dwWidth = inTextureMap->width; ddsd.dwHeight = inTextureMap->height; ddsd.lPitch = inTextureMap->rowBytes; - + ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; - + switch (inTextureMap->texelType) { case M3cTextureType_ARGB4444: @@ -921,7 +921,7 @@ MDrUseTexture( ddsd.ddpfPixelFormat.dwBBitMask = 0x0000000F; ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0x0000F000; break; - + case M3cTextureType_RGB555: ddsd.ddpfPixelFormat.dwRGBBitCount = 16; ddsd.ddpfPixelFormat.dwRBitMask = 0x00007C00; @@ -929,7 +929,7 @@ MDrUseTexture( ddsd.ddpfPixelFormat.dwBBitMask = 0x0000001F; ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0x00000000; break; - + case M3cTextureType_ARGB1555: ddsd.ddpfPixelFormat.dwRGBBitCount = 16; ddsd.ddpfPixelFormat.dwFlags |= DDPF_ALPHAPIXELS; @@ -938,7 +938,7 @@ MDrUseTexture( ddsd.ddpfPixelFormat.dwBBitMask = 0x0000001F; ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0x00008000; break; - + case M3cTextureType_ARGB8888: ddsd.ddpfPixelFormat.dwRGBBitCount = 32; ddsd.ddpfPixelFormat.dwFlags |= DDPF_ALPHAPIXELS; @@ -947,11 +947,11 @@ MDrUseTexture( ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF; ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000; break; - + default: UUmAssert(!"Unknown texture format."); } - + if (inDrawContextPrivate->isHardware) { ddsd.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY | DDSCAPS_ALLOCONLOAD; @@ -960,7 +960,7 @@ MDrUseTexture( { ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; } - + // create the device surface result = IDirectDraw2_CreateSurface( @@ -973,21 +973,21 @@ MDrUseTexture( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return; } - + // get the DirectDrawSurface3 interface result = IDirectDrawSurface_QueryInterface( temp_surface, &IID_IDirectDrawSurface3, (void**)&textureMapPrivate->device_surface); - + // -------------------------------------------------- // create the memory surface -- this one will actually hold the // data and it does not get lost. if (inDrawContextPrivate->isHardware) { ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_TEXTURE; - + // create the memory surface result = IDirectDraw2_CreateSurface( @@ -1000,7 +1000,7 @@ MDrUseTexture( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return; } - + // get an interface to the DirectDrawSurface3 result = IDirectDrawSurface_QueryInterface( @@ -1020,7 +1020,7 @@ MDrUseTexture( textureMapPrivate->memory_surface = textureMapPrivate->device_surface; IDirectDrawSurface3_AddRef(textureMapPrivate->device_surface); } - + // set the pointer to the data UUrMemory_Clear(&ddsd, sizeof(DDSURFACEDESC)); ddsd.dwSize = sizeof(DDSURFACEDESC); @@ -1036,7 +1036,7 @@ MDrUseTexture( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return; } - + // -------------------------------------------------- // query the surface for a texture interface result = @@ -1049,7 +1049,7 @@ MDrUseTexture( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return; } - + // get a handle to the texture result = IDirect3DTexture2_GetHandle( @@ -1061,10 +1061,10 @@ MDrUseTexture( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return; } - + RELEASE(texture); } - + // -------------------------------------------------- // load the texture result = @@ -1097,10 +1097,10 @@ MDrDrawContext_Method_Frame_Start( HRESULT result = DD_OK; D3DRECT d3d_rect; DDBLTFX dd_blt_fx; - + // get shortcut pointers drawContextPrivate = (MDtDrawContextPrivate*)inDrawContext->privateContext; - + // use the blitter to do a color fill on the backbuffer dd_blt_fx.dwSize = sizeof(DDBLTFX); dd_blt_fx.dwFillColor = RGB_MAKE(0,0,255); @@ -1121,7 +1121,7 @@ MDrDrawContext_Method_Frame_Start( d3d_rect.y1 = drawContextPrivate->rect.top; d3d_rect.x2 = drawContextPrivate->rect.right; d3d_rect.y2 = drawContextPrivate->rect.bottom; - + result = IDirect3DViewport2_Clear( drawContextPrivate->d3d_viewport2, @@ -1149,7 +1149,7 @@ MDrDrawContext_Method_Frame_Start( { UUmError_ReturnOnErrorMsg(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); } - + // turn on z-buffering result = IDirect3DDevice2_SetRenderState( @@ -1160,7 +1160,7 @@ MDrDrawContext_Method_Frame_Start( { UUmError_ReturnOnErrorMsg(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); } - + // turn off culling result = IDirect3DDevice2_SetRenderState( @@ -1171,7 +1171,7 @@ MDrDrawContext_Method_Frame_Start( { UUmError_ReturnOnErrorMsg(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); } - + // turn on perspective correct texture mapping result = IDirect3DDevice2_SetRenderState( @@ -1193,7 +1193,7 @@ MDrDrawContext_Method_Frame_Start( { UUmError_ReturnOnErrorMsg(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); } - + // turn on some ambient light result = IDirect3DDevice2_SetLightState( @@ -1207,10 +1207,10 @@ MDrDrawContext_Method_Frame_Start( states_set = UUcTrue; } - + return UUcError_None; } - + // ---------------------------------------------------------------------- UUtError MDrDrawContext_Method_Frame_End( @@ -1220,10 +1220,10 @@ MDrDrawContext_Method_Frame_End( HRESULT result = DD_OK; drawContextPrivate = (MDtDrawContextPrivate*)inDrawContext->privateContext; - + // end the Direct3D scene result = IDirect3DDevice2_EndScene(drawContextPrivate->d3d_device2); - + // draw the rendered scene to the screen if(drawContextPrivate->screenFlags & M3cDrawContextScreenFlags_DoubleBuffer) { @@ -1235,7 +1235,7 @@ MDrDrawContext_Method_Frame_End( drawContextPrivate->backBuffer, &drawContextPrivate->rect, DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); /* XXX - Eventually get rid of the wait */ - + if(result != DD_OK) { UUrError_Report(UUcError_Generic, M3rPlatform_GetErrorMsg(result)); @@ -1277,13 +1277,13 @@ MDiInitBuffers( // DDSCAPS ddscaps; HRESULT result; UUtUns32 mem_location; - + // setup the direct draw surface description for the front buffer UUrMemory_Clear(&ddsd, sizeof(DDSURFACEDESC)); ddsd.dwSize = sizeof(DDSURFACEDESC); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - + // create the frontBuffer result = IDirectDraw2_CreateSurface( @@ -1296,10 +1296,10 @@ MDiInitBuffers( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + // get a pointer to the platform data platform_data = (MDtPlatform*)inDisplayDevice->platformDevice; - + // get the D3D device description if (MDiIsHardware(&platform_data->d3d_devices[inD3DDevice])) { @@ -1339,7 +1339,7 @@ MDiInitBuffers( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + // create the zbuffer UUrMemory_Clear(&ddsd, sizeof(DDSURFACEDESC)); ddsd.dwSize = sizeof(DDSURFACEDESC); @@ -1348,7 +1348,7 @@ MDiInitBuffers( ddsd.dwWidth = inDrawContextPrivate->width; ddsd.dwHeight = inDrawContextPrivate->height; ddsd.dwZBufferBitDepth = inDrawContextPrivate->zbpp; - + result = IDirectDraw2_CreateSurface( inDrawContextPrivate->dd2, @@ -1360,7 +1360,7 @@ MDiInitBuffers( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + // attach the zBuffer to the rendering surface result = IDirectDrawSurface2_AddAttachedSurface( @@ -1371,7 +1371,7 @@ MDiInitBuffers( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + return UUcError_None; } @@ -1385,10 +1385,10 @@ MDiInitD3D( HRESULT result; D3DVIEWPORT2 viewport_data; MDtPlatform *platform_data; - + // get a pointer to the platform data platform_data = (MDtPlatform*)inDisplayDevice->platformDevice; - + // create the D3D Device result = IDirect3D2_CreateDevice( @@ -1401,7 +1401,7 @@ MDiInitD3D( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + // Create the viewport result = IDirect3D2_CreateViewport( @@ -1413,7 +1413,7 @@ MDiInitD3D( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + // Attach viewport to D3D device result = IDirect3DDevice_AddViewport( @@ -1424,10 +1424,10 @@ MDiInitD3D( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + // configure the viewport UUrMemory_Clear(&viewport_data, sizeof(D3DVIEWPORT2)); - + viewport_data.dwSize = sizeof(D3DVIEWPORT2); viewport_data.dwX = inDrawContextPrivate->left; viewport_data.dwY = inDrawContextPrivate->top; @@ -1439,7 +1439,7 @@ MDiInitD3D( viewport_data.dvClipY = 0.0; viewport_data.dvMinZ = 0.0; viewport_data.dvMaxZ = 1.0; - + result = IDirect3DViewport2_SetViewport2( inDrawContextPrivate->d3d_viewport2, @@ -1449,7 +1449,7 @@ MDiInitD3D( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + // make the device use the viewport result = IDirect3DDevice2_SetCurrentViewport( @@ -1460,7 +1460,7 @@ MDiInitD3D( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + // load the texture formats for the device result = IDirect3DDevice2_EnumTextureFormats( @@ -1484,14 +1484,14 @@ MDiDrawEngine_SetupEngineCaps( HRESULT result; ioDrawEngineCaps->numDisplayDevices = 0; - + // enumerate the direct draw devices result = DirectDrawEnumerate(MDiDD_DriverCallback, ioDrawEngineCaps); if (result != DD_OK) { UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); } - + return UUcError_None; } @@ -1509,33 +1509,33 @@ MDiDD_DriverCallback( LPDIRECT3D2 d3d2; MDtPlatform *platform_data; HRESULT result; - + // if inData is null, something went terribly wrong if (inData == NULL) { return DDENUMRET_OK; } - + // get a pointer to the draw engine caps draw_engine_caps = (M3tDrawEngineCaps*)inData; - + // get an index into the display devices array index = draw_engine_caps->numDisplayDevices; if (index >= M3cMaxDisplayDevices) { return DDENUMRET_CANCEL; } - + // allocate the platform_data platform_data = (MDtPlatform*)UUrMemory_Block_New(sizeof(MDtPlatform)); if (platform_data == NULL) { return DDENUMRET_OK; } - + // clear the memory UUrMemory_Clear(platform_data, sizeof(MDtPlatform)); - + // save guid if (inGuid) { @@ -1546,23 +1546,23 @@ MDiDD_DriverCallback( { platform_data->primary = UUcTrue; } - + // initialize the display device draw_engine_caps->displayDevices[index].platformDevice = (M3tPlatformDevice)platform_data; draw_engine_caps->displayDevices[index].numDisplayModes = 0; - + // create the DirectDraw object result = DirectDrawCreate(inGuid, &dd, NULL); if (result != DD_OK) { UUrMemory_Block_Delete(platform_data); draw_engine_caps->displayDevices[index].platformDevice = NULL; - + UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); goto cleanup; } - + // try to get a Direct3D interface result = IDirectDraw_QueryInterface(dd, &IID_IDirect3D2, &d3d2); if (result != DD_OK) @@ -1584,11 +1584,11 @@ MDiDD_DriverCallback( { UUrMemory_Block_Delete(platform_data); draw_engine_caps->displayDevices[index].platformDevice = NULL; - + UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); goto cleanup; } - + // enumerate the d3d devices result = IDirect3D2_EnumDevices( @@ -1599,7 +1599,7 @@ MDiDD_DriverCallback( { UUrMemory_Block_Delete(platform_data); draw_engine_caps->displayDevices[index].platformDevice = NULL; - + UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); goto cleanup; } @@ -1614,14 +1614,14 @@ MDiDD_DriverCallback( IDirect3D2_Release(d3d2); d3d2 = NULL; } - + if (dd) { IDirectDraw_Release(dd); dd = NULL; } - - return DDENUMRET_OK; + + return DDENUMRET_OK; } // ---------------------------------------------------------------------- @@ -1632,51 +1632,51 @@ MDiDD_ModeCallback( { M3tDisplayDevice *display_device; UUtUns16 index; - + // if inData is NULL, something went terribly wrong if (inData == NULL) { return DDENUMRET_OK; } - + // if the surface description is null something went wrong if (inSurfaceDesc == NULL) { return DDENUMRET_CANCEL; } - + // double check structure size if (inSurfaceDesc->dwSize != sizeof(DDSURFACEDESC)) { return DDENUMRET_CANCEL; } - + // only use surfaces that have 16 bit pixels if (inSurfaceDesc->ddpfPixelFormat.dwRGBBitCount != 16) { return DDENUMRET_OK; } - + // get a pointer to the display device display_device = (M3tDisplayDevice*)inData; - + // get an index into the display modes array index = display_device->numDisplayModes; if (index >= M3cMaxDisplayModes) { return DDENUMRET_CANCEL; } - + // fill in info about the display mode display_device->displayModes[index].width = (UUtUns16)inSurfaceDesc->dwWidth; display_device->displayModes[index].height = (UUtUns16)inSurfaceDesc->dwHeight; display_device->displayModes[index].bitDepth = (UUtUns16)inSurfaceDesc->ddpfPixelFormat.dwRGBBitCount; display_device->displayModes[index].pad = 0; - + // increment the number of display devices display_device->numDisplayModes++; - + return DDENUMRET_OK; } @@ -1693,39 +1693,39 @@ MDiD3D_DeviceCallback( M3tDisplayDevice *display_device; MDtPlatform *platform_data; UUtUns16 index; - + // if inData is NULL, something went terribly wrong if (inData == NULL) { return DDENUMRET_OK; } - + // get a pointer to the display device display_device = (M3tDisplayDevice*)inData; - + // get a pointer to the platform data platform_data = (MDtPlatform*)display_device->platformDevice; if (platform_data == NULL) { return DDENUMRET_OK; } - + // get an index into the d3d device array index = platform_data->num_d3d_devices; if (index >= MDcMaxD3DDevices) { return DDENUMRET_OK; } - + // record the info platform_data->d3d_devices[index].d3d_guid = *inGuid; UUrString_Copy(platform_data->d3d_devices[index].device_desc, inDescription, MDcMaxDescChars); platform_data->d3d_devices[index].HAL_desc = *inHALDesc; platform_data->d3d_devices[index].HEL_desc = *inHELDesc; - + // increment the number of d3d devices platform_data->num_d3d_devices++; - + return DDENUMRET_OK; } @@ -1737,27 +1737,27 @@ MDiD3D_TextureFormatCallback( { MDtD3D_device_info *d3d_device_info; UUtUns16 index; - + // get a pointer to the d3d device info d3d_device_info = (MDtD3D_device_info*)inData; if (d3d_device_info == NULL) { return DDENUMRET_OK; } - + // get an index into the texture format array index = d3d_device_info->num_texture_formats; if (index >= MDcMaxTextureDesc) { return DDENUMRET_OK; } - + // record the info d3d_device_info->texture_format[index] = *inTextureFormat; - + // increment the number of texture formats d3d_device_info->num_texture_formats++; - + return DDENUMRET_OK; } @@ -1806,4 +1806,4 @@ MDiGetD3DDeviceIndex( { // XXX - must find a better mechanism for this return 1; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DrawEngine_Method.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DrawEngine_Method.h index eb68998..232dd24 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DrawEngine_Method.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DrawEngine_Method.h @@ -1,12 +1,12 @@ /* FILE: MD_DrawEngine_Method.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DrawEngine_Platform.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DrawEngine_Platform.h index a85ec4c..8451705 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DrawEngine_Platform.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Direct3D/MD_DrawEngine_Platform.h @@ -1,16 +1,16 @@ /* FILE: MD_DrawEngine_Platform.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MD_DRAWENGINE_PLATFORM_H #define MD_DRAWENGINE_PLATFORM_H - + #endif /* MD_DRAWENGINE_PLATFORM_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Bitmap.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Bitmap.c index f6768a1..23eb5a2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Bitmap.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Bitmap.c @@ -1,12 +1,12 @@ /* FILE: EM_DC_Method_Bitmap.c - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: Nov 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997, 1998 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Bitmap.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Bitmap.h index 3c051b8..e4b5fe1 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Bitmap.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Bitmap.h @@ -1,12 +1,12 @@ /* FILE: EM_DC_Method_Bitmap.h - + AUTHOR: Brent H. Pease - + CREATED: Nov 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -22,7 +22,7 @@ EDrDrawContext_Method_Sprite( UUtError EDrDrawContext_Method_ScreenCapture( - const UUtRect *inRect, + const UUtRect *inRect, void *outBuffer); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Frame.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Frame.h index d002789..f6d287d 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Frame.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Frame.h @@ -1,12 +1,12 @@ /* FILE: EM_DC_Method_Frame.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_LinePoint.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_LinePoint.c index a1ef365..657ed73 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_LinePoint.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_LinePoint.c @@ -4,9 +4,9 @@ AUTHOR: Brent H. Pease CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -27,7 +27,7 @@ EDrDrawContext_Method_Point( } -void +void EDrDrawContext_Method_Line_Interpolate( UUtUns16 inVIndex0, UUtUns16 inVIndex1) @@ -35,7 +35,7 @@ EDrDrawContext_Method_Line_Interpolate( } -void +void EDrDrawContext_Method_Line_Flat( UUtUns16 inVIndex0, UUtUns16 inVIndex1) diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_LinePoint.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_LinePoint.h index 79062d4..8d0d72b 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_LinePoint.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_LinePoint.h @@ -1,28 +1,28 @@ /* FILE: EM_DC_Method_LinePoint.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef EM_DC_METHOD_LINEPOINT_H #define EM_DC_METHOD_LINEPOINT_H -void +void EDrDrawContext_Method_Point( M3tPointScreen* invCoord); -void +void EDrDrawContext_Method_Line_Interpolate( UUtUns16 inVIndex0, UUtUns16 inVIndex1); -void +void EDrDrawContext_Method_Line_Flat( UUtUns16 inVIndex0, UUtUns16 inVIndex1); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Pent.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Pent.c index 1eaef0a..f75c155 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Pent.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Pent.c @@ -5,8 +5,8 @@ CREATED: Sept 18, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Pent.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Pent.h index d8dc650..44edce9 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Pent.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Pent.h @@ -1,12 +1,12 @@ /* FILE: EM_DC_Method_Pent.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Quad.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Quad.c index 97b949f..c3506aa 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Quad.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Quad.c @@ -1,12 +1,12 @@ /* FILE: EM_DC_Method_Quad.c - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997, 1998 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Quad.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Quad.h index 2c7af2b..5c9d0f2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Quad.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Quad.h @@ -1,12 +1,12 @@ /* FILE: EM_DC_Method_Quad.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Query.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Query.h index b9c2c3e..b242d36 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Query.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Query.h @@ -17,4 +17,4 @@ EDrDrawContext_TextureFormatAvailable( IMtPixelType inTexelType); // ====================================================================== -#endif /* EM_DC_METHOD_QUERY_H */ \ No newline at end of file +#endif /* EM_DC_METHOD_QUERY_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_State.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_State.c index bb54e22..07d0dfb 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_State.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_State.c @@ -1,12 +1,12 @@ /* FILE: EM_DC_Method_State.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -38,7 +38,7 @@ UUtInt32 EDrDrawContext_Method_State_GetInt( M3tDrawStateIntType inDrawStateType) { - + return 0; } @@ -54,7 +54,7 @@ void* EDrDrawContext_Method_State_GetPtr( M3tDrawStatePtrType inDrawStateType) { - + return NULL; } @@ -62,7 +62,7 @@ UUtError EDrDrawContext_Method_State_Push( void) { - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_State.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_State.h index 74acb31..004f5c3 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_State.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_State.h @@ -1,12 +1,12 @@ /* FILE: EM_DC_Method_State.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Triangle.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Triangle.c index d47d735..5a3a22a 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Triangle.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Triangle.c @@ -1,12 +1,12 @@ /* FILE: EM_DC_Method_Triangle.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Triangle.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Triangle.h index 210b248..a067966 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Triangle.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Method_Triangle.h @@ -1,12 +1,12 @@ /* FILE: EM_DC_Method_Triangle.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Private.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Private.h index 198842e..7ef5f83 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DC_Private.h @@ -1,12 +1,12 @@ /* FILE: EM_DrawContext_Private.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 17, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -26,9 +26,9 @@ enum typedef struct EDtTextureMapPrivate { - UUtInt16 flags; + UUtInt16 flags; UUtInt16 width, height; - + } EDtTextureMapPrivate; #define MGcStateStack_MaxDepth 3 diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DrawEngine_Method.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DrawEngine_Method.c index a115df0..e9bc51a 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DrawEngine_Method.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DrawEngine_Method.c @@ -1,12 +1,12 @@ /* FILE: EM_DrawEngine_Method.c - + AUTHOR: Kevin Armstrong, Michael Evans - + CREATED: January 5, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1998 */ @@ -76,7 +76,7 @@ EDrDrawEngine_Method_ContextPrivateNew( EMgDrawContextMethods.screenCapture = NULL; EMgDrawContextMethods.pointVisible = NULL; EMgDrawContextMethods.textureFormatAvailable = NULL; - + return UUcError_None; } @@ -103,7 +103,7 @@ static UUtError EDrDrawEngine_Method_Texture_Load( M3tTextureMap* inTextureMap) { - + return UUcError_None; } @@ -119,7 +119,7 @@ EDrDrawEngine_Method_Texture_Delete( M3tTextureMap* inTextureMap) { //EDtTextureMapPrivate *private_texture = (EDtTextureMapPrivate*) (M3rManager_Texture_GetEnginePrivate(inTextureMap)); - + return UUcError_None; } @@ -129,28 +129,28 @@ EDrDrawEngine_Initialize( void) { UUtError error; - + M3tDrawEngineCaps drawEngineCaps; M3tDrawEngineMethods drawEngineMethods; - - + + drawEngineMethods.contextPrivateNew = EDrDrawEngine_Method_ContextPrivateNew; drawEngineMethods.contextPrivateDelete = EDrDrawEngine_Method_ContextPrivateDelete; drawEngineCaps.engineFlags = M3cDrawEngineFlag_3DOnly; - + strncpy(drawEngineCaps.engineName, M3cDrawEngine_RAVE, M3cMaxNameLen); drawEngineCaps.engineDriver[0] = 0; - + drawEngineCaps.engineVersion = EMcSoftware_Version; - + // XXX - Someday make this more real drawEngineCaps.numDisplayDevices = 1; drawEngineCaps.displayDevices[0].numDisplayModes = 1; drawEngineCaps.displayDevices[0].displayModes[0].width = 0; drawEngineCaps.displayDevices[0].displayModes[0].height = 0; drawEngineCaps.displayDevices[0].displayModes[0].bitDepth = 0; - + error = M3rManager_Register_DrawEngine( &drawEngineCaps, @@ -179,13 +179,13 @@ EDrDrawContext_Method_Frame_Start( return UUcError_None; } - + // ---------------------------------------------------------------------- UUtError EDrDrawContext_Method_Frame_End( void) { - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DrawEngine_Method.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DrawEngine_Method.h index acfb895..49fd437 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DrawEngine_Method.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DrawEngine_Method.h @@ -1,12 +1,12 @@ /* FILE: EM_DrawEngine_Method.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DrawEngine_Platform.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DrawEngine_Platform.h index 7e6cb5d..e41fb74 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DrawEngine_Platform.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/EmptyEngine/EM_DrawEngine_Platform.h @@ -1,12 +1,12 @@ /* FILE: EM_DrawEngine_Platform.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -21,5 +21,5 @@ EDrDrawEngine_Platform_SetupDrawContextPrivate( void EDrDrawEngine_Platform_DestroyDrawContextPrivate( EDtDrawContextPrivate* inDrawContextPrivate); - + #endif /* EM_DRAWENGINE_PLATFORM_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_DC_Private.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_DC_Private.h index b6eee25..da4626b 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_DC_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_DC_Private.h @@ -1,12 +1,12 @@ /* FILE: GL_DrawContext_Private.h - + AUTHOR: Michael Evans - + CREATED: August 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -35,12 +35,12 @@ struct GLtDrawContextPrivate UUtInt32 width; UUtInt32 height; UUtInt32 bitDepth; - + M3tDrawContextType contextType; - + GLtVertex* vertexList; UUtUns32 vertexCount; - + M3tTextureMap* curBaseMap; M3tTextureMap* curLightMap; M3tTextureMap* curEnvironmentMap; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_DrawEngine_Method.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_DrawEngine_Method.c index 1944a88..3fa05c7 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_DrawEngine_Method.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_DrawEngine_Method.c @@ -1,12 +1,12 @@ /* FILE: GL_DrawEngine_Method.c - + AUTHOR: Kevin Armstrong, Michael Evans - + CREATED: January 5, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1998 */ @@ -48,11 +48,11 @@ UUtUns32 GLgClearColor = 0x00000000; #if 0 -GL_ALPHA, GL_ALPHA4, GL_ALPHA8, GL_ALPHA12, GL_ALPHA16, GL_LUMINANCE, GL_LUMINANCE4, -GL_LUMINANCE8, GL_LUMINANCE12, GL_LUMINANCE16, GL_LUMINANCE_ALPHA, GL_LUMINANCE4_ALPHA4, -GL_LUMINANCE6_ALPHA2, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE12_ALPHA4, GL_LUMINANCE12_ALPHA12, -GL_LUMINANCE16_ALPHA16, GL_INTENSITY, GL_INTENSITY4, GL_INTENSITY8, GL_INTENSITY12, -GL_INTENSITY16, GL_RGB, GL_R3_G3_B2, GL_RGB4, GL_RGB5, GL_RGB8, GL_RGB10, GL_RGB12, +GL_ALPHA, GL_ALPHA4, GL_ALPHA8, GL_ALPHA12, GL_ALPHA16, GL_LUMINANCE, GL_LUMINANCE4, +GL_LUMINANCE8, GL_LUMINANCE12, GL_LUMINANCE16, GL_LUMINANCE_ALPHA, GL_LUMINANCE4_ALPHA4, +GL_LUMINANCE6_ALPHA2, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE12_ALPHA4, GL_LUMINANCE12_ALPHA12, +GL_LUMINANCE16_ALPHA16, GL_INTENSITY, GL_INTENSITY4, GL_INTENSITY8, GL_INTENSITY12, +GL_INTENSITY16, GL_RGB, GL_R3_G3_B2, GL_RGB4, GL_RGB5, GL_RGB8, GL_RGB10, GL_RGB12, GL_RGB16, GL_RGBA, GL_RGBA2, GL_RGBA4, GL_RGB5_A1, GL_RGBA8, GL_RGB10_A2, GL_RGBA12, or GL_RGBA16. #endif @@ -110,15 +110,15 @@ GLrDrawEngine_Method_ContextPrivateNew( UUtUns16 activeDevice; UUtUns16 activeMode; M3tDrawEngineCaps* drawEngineCaps; - + UUrStartupMessage("creating new opengl context"); - + *outAPI = M3cDrawAPI_OpenGL; GLgDrawContextPrivate = UUrMemory_Block_NewClear(sizeof(*GLgDrawContextPrivate)); UUmError_ReturnOnNull(GLgDrawContextPrivate); - GLgDrawContextPrivate->compiled_vertex_array = UUrMemory_Block_New(sizeof(float) * 3 * GLcMaxVerticies); + GLgDrawContextPrivate->compiled_vertex_array = UUrMemory_Block_New(sizeof(float) * 3 * GLcMaxVerticies); UUmError_ReturnOnNull(GLgDrawContextPrivate->compiled_vertex_array); GLgDrawContextPrivate->constant_r = 1.f; @@ -126,16 +126,16 @@ GLrDrawEngine_Method_ContextPrivateNew( GLgDrawContextPrivate->constant_b = 1.f; GLgDrawContextPrivate->constant_a = 1.f; - + /* * Get the active draw engine info */ - + M3rManager_GetActiveDrawEngine( &activeDrawEngine, &activeDevice, &activeMode); - + drawEngineCaps = M3rDrawEngine_GetCaps(activeDrawEngine); /* @@ -155,15 +155,15 @@ GLrDrawEngine_Method_ContextPrivateNew( GLgDrawContextMethods.screenCapture = GLrDrawContext_Method_ScreenCapture; GLgDrawContextMethods.pointVisible = GLrDrawContext_Method_PointVisible; GLgDrawContextMethods.textureFormatAvailable = OGLrCommon_TextureMap_TextureFormatAvailable; - + *outDrawContextFuncs = &GLgDrawContextMethods; - + GLgDrawContextPrivate->contextType = inDrawContextDescriptor->type; - + GLgDrawContextPrivate->width= drawEngineCaps->displayDevices[activeDevice].displayModes[activeMode].width; GLgDrawContextPrivate->height= drawEngineCaps->displayDevices[activeDevice].displayModes[activeMode].height; GLgDrawContextPrivate->bitDepth= drawEngineCaps->displayDevices[activeDevice].displayModes[activeMode].bitDepth; - + // Init some state GLgDrawContextPrivate->vertexList = NULL; GLgDrawContextPrivate->curBaseMap = NULL; @@ -172,13 +172,13 @@ GLrDrawEngine_Method_ContextPrivateNew( initialize_opengl(); - + return UUcError_None; - + //failure: - + GLrDrawEngine_Method_ContextPrivateDelete(); - + return errorCode; } @@ -193,12 +193,12 @@ static UUtError GLrDrawEngine_Method_PrivateState_New( void* inState_Private) { - + return UUcError_None; } // This lets the engine delete a new private state structure -static void +static void GLrDrawEngine_Method_PrivateState_Delete( void* inState_Private) { @@ -243,7 +243,7 @@ GLrDrawEngine_Method_State_Update( } } } - + if( inState_IntFlags & (1 << M3cDrawStateIntType_ZBias )) { UUtInt32 value = inState_Int[M3cDrawStateIntType_ZBias]; @@ -259,16 +259,16 @@ GLrDrawEngine_Method_State_Update( OGLrCommon_DepthMode_Set(zread, zwrite); } - - if((inState_Int[M3cDrawStateIntType_Appearence] != M3cDrawState_Appearence_Gouraud) && + + if((inState_Int[M3cDrawStateIntType_Appearence] != M3cDrawState_Appearence_Gouraud) && (inState_Int[M3cDrawStateIntType_Fill] == M3cDrawState_Fill_Solid)) { - if(inState_PtrFlags & (1 << M3cDrawStatePtrType_BaseTextureMap)) { + if(inState_PtrFlags & (1 << M3cDrawStatePtrType_BaseTextureMap)) { M3tTextureMap* textureMap = (M3tTextureMap*)inState_Ptr[M3cDrawStatePtrType_BaseTextureMap]; - + GLgDrawContextPrivate->curBaseMap = textureMap; - + if (NULL == textureMap) { OGLrCommon_TextureMap_Select(NULL, GL_TEXTURE0_ARB); @@ -304,7 +304,7 @@ GLrDrawEngine_Method_State_Update( GLgDrawContextPrivate->constant_a = alpha * (1.f / 255.f); } - + if (inState_IntFlags & ((1 << M3cDrawStateIntType_ConstantColor))) { UUtUns32 color = inState_Int[M3cDrawStateIntType_ConstantColor]; @@ -316,7 +316,7 @@ GLrDrawEngine_Method_State_Update( GLgDrawContextPrivate->constant_g = g * (1.f / 255.f); GLgDrawContextPrivate->constant_b = b * (1.f / 255.f); } - + if(inState_IntFlags & ((1 << M3cDrawStateIntType_Alpha) | (1 << M3cDrawStateIntType_ConstantColor))) { glColor4f( @@ -325,14 +325,14 @@ GLrDrawEngine_Method_State_Update( GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); } - + if(inState_IntFlags & ( (1 << M3cDrawStateIntType_Appearence) | (1 << M3cDrawStateIntType_Interpolation) | (1 << M3cDrawStateIntType_Fill))) { } - + switch(inState_Int[M3cDrawStateIntType_Fill]) { case M3cDrawState_Fill_Point: @@ -354,7 +354,7 @@ GLrDrawEngine_Method_State_Update( case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Lit_EnvMap: - case M3cDrawState_Appearence_Texture_Unlit: + case M3cDrawState_Appearence_Texture_Unlit: switch(inState_Int[M3cDrawStateIntType_VertexFormat]) { case M3cDrawStateVertex_Unified: @@ -390,7 +390,7 @@ GLrDrawEngine_Method_State_Update( break; } } - + GLgBufferClear = (UUtBool) inState_Int[M3cDrawStateIntType_BufferClear]; GLgClearColor = inState_Int[M3cDrawStateIntType_ClearColor]; GLgDoubleBuffer = (UUtBool) inState_Int[M3cDrawStateIntType_DoubleBuffer]; @@ -407,7 +407,7 @@ GLrDrawEngine_Initialize( void) { UUtInt32 itr; - M3tDisplayMode displayModeList[16] = + M3tDisplayMode displayModeList[16] = { { 640, 480, 16, 0 }, { 800, 600, 16, 0 }, @@ -430,29 +430,29 @@ GLrDrawEngine_Initialize( UUtError error; - + if(glGetString == NULL) return; GLgDrawEngineMethods.contextPrivateNew = GLrDrawEngine_Method_ContextPrivateNew; GLgDrawEngineMethods.contextPrivateDelete = GLrDrawEngine_Method_ContextPrivateDelete; GLgDrawEngineMethods.textureResetAll = GLrDrawEngine_Method_Texture_ResetAll; - + GLgDrawEngineMethods.privateStateSize = 0; GLgDrawEngineMethods.privateStateNew = GLrDrawEngine_Method_PrivateState_New; GLgDrawEngineMethods.privateStateDelete = GLrDrawEngine_Method_PrivateState_Delete; GLgDrawEngineMethods.privateStateUpdate = GLrDrawEngine_Method_State_Update; - + GLgDrawEngineCaps.engineFlags = M3cDrawEngineFlag_3DOnly; - + UUrString_Copy(GLgDrawEngineCaps.engineName, M3cDrawEngine_OpenGL, M3cMaxNameLen); GLgDrawEngineCaps.engineDriver[0] = 0; - + GLgDrawEngineCaps.engineVersion = 1; - + GLgDrawEngineCaps.numDisplayDevices = 1; - + GLgDrawEngineCaps.displayDevices[0].numDisplayModes = 16; - + for(itr = 0; itr < 16; itr++) { // NOTE: this should be built on the fly at some point GLgDrawEngineCaps.displayDevices[0].displayModes[itr] = displayModeList[itr]; @@ -501,7 +501,7 @@ UUtError initialize_opengl(void) error = OGLrCommon_Initialize_OneTime(); UUmError_ReturnOnError(error); // XXX - At some point inform user that open gl did not have needed extensions - + GLgDrawContextPrivate->num_tmu = 1; if (OGLgCommon.ext_arb_multitexture) { @@ -513,7 +513,7 @@ UUtError initialize_opengl(void) GLgDrawContextPrivate->num_tmu = 1; } - UUrStartupMessage("supports %d texturing units", GLgDrawContextPrivate->num_tmu); + UUrStartupMessage("supports %d texturing units", GLgDrawContextPrivate->num_tmu); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &GLgDrawContextPrivate->max_texture_size); glGetIntegerv(GL_DOUBLEBUFFER, &GLgDrawContextPrivate->has_double_buffer); @@ -521,25 +521,25 @@ UUtError initialize_opengl(void) glDisable(GL_CULL_FACE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - + glClearColor(0.f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - + glPixelStorei(GL_UNPACK_ALIGNMENT,1); glPixelStorei(GL_PACK_ALIGNMENT,1); - - + + /* the depth range is set by the set_frame_parameters code */ - + OGLrCommon_DepthMode_Set(UUcTrue,UUcTrue); - + OGLrCommon_State_Initialize((UUtUns16)GLgDrawContextPrivate->width, (UUtUns16)GLgDrawContextPrivate->height); - + // glFogfv(GL_FOG_COLOR,GLgDrawContextPrivate->fog_color); - - //set_opengl_texture(NULL); + + //set_opengl_texture(NULL); /* check for OpenGL Errors here */ - + return UUcTrue; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_DrawEngine_Method.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_DrawEngine_Method.h index 93fdc01..1378b02 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_DrawEngine_Method.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_DrawEngine_Method.h @@ -1,12 +1,12 @@ /* FILE: GL_DrawEngine_Method.h - + AUTHOR: Michael Evans - + CREATED: August 10, 1999 - + PURPOSE: OpenGL Draw Engine - + Copyright 1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Draw_Functions.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Draw_Functions.c index be35703..e1896fb 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Draw_Functions.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Draw_Functions.c @@ -1,12 +1,12 @@ /* FILE: GL_DC_Method_Frame.h - + AUTHOR: Michael Evans - + CREATED: August 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -27,7 +27,7 @@ extern GLint gl_error; #if 1 #define FLUSH glFlush(); #else -#define FLUSH +#define FLUSH #endif void @@ -44,7 +44,7 @@ GLrDrawContext_Method_TriSprite( GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); #endif - + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -54,7 +54,7 @@ GLrDrawContext_Method_TriSprite( // point[0] glTexCoord2f(inTextureCoords[0].u, inTextureCoords[0].v); glVertex3f(inPoints[0].x, inPoints[0].y, inPoints[0].z); - + // point[1] glTexCoord2f(inTextureCoords[1].u, inTextureCoords[1].v); glVertex3f(inPoints[1].x, inPoints[1].y, inPoints[0].z); @@ -83,7 +83,7 @@ GLrDrawContext_Method_Sprite( z = inPoints[0].z; w = inPoints[0].invW; - + #if 0 glColor4f( GLgDrawContextPrivate->constant_r, @@ -91,7 +91,7 @@ GLrDrawContext_Method_Sprite( GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); #endif - + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -101,7 +101,7 @@ GLrDrawContext_Method_Sprite( // tl glTexCoord2f(inTextureCoords[0].u, inTextureCoords[0].v); glVertex3f(inPoints[0].x, inPoints[0].y, z); - + // tr glTexCoord2f(inTextureCoords[1].u, inTextureCoords[1].v); glVertex3f(inPoints[1].x, inPoints[0].y, z); @@ -133,20 +133,20 @@ GLrDrawContext_Method_SpriteArray( float w; UUtUns32 i; UUtUns32 color; - + color = (UUtUns32)GLgDrawContextPrivate->statePtr[M3cDrawStateIntType_ConstantColor]; OGLrCommon_Camera_Update(OGLcCameraMode_2D); glBegin(GL_QUADS); - + i = 0; for( i = 0; i < inCount; i++ ) { z = inPoints[0].z; w = inPoints[0].invW; - + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -173,7 +173,7 @@ GLrDrawContext_Method_SpriteArray( // tl glTexCoord2f(inTextureCoords[i*4+0].u, inTextureCoords[i*4+0].v); glVertex3f(inPoints[i*2+0].x, inPoints[i*2+0].y, z); - + // tr glTexCoord2f(inTextureCoords[i*4+1].u, inTextureCoords[i*4+1].v); glVertex3f(inPoints[i*2+1].x, inPoints[i*2+0].y, z); @@ -196,7 +196,7 @@ GLrDrawContext_Method_SpriteArray( UUtError GLrDrawContext_Method_ScreenCapture( - const UUtRect *inRect, + const UUtRect *inRect, void *outBuffer) { GLenum glError; @@ -212,7 +212,7 @@ UUtError GLrDrawContext_Method_ScreenCapture( glReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, outBuffer); OGLmAssertSuccess(glError); - + return UUcError_None; } @@ -251,12 +251,12 @@ void GLrLine( #if 0 glColor4f( - GLgDrawContextPrivate->constant_r, - GLgDrawContextPrivate->constant_g, - GLgDrawContextPrivate->constant_b, + GLgDrawContextPrivate->constant_r, + GLgDrawContextPrivate->constant_g, + GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); #endif - + glBegin(GL_LINES); glVertex3f(ourScreenPoints[0]->x, ourScreenPoints[0]->y, ourScreenPoints[0]->z); glVertex3f(ourScreenPoints[1]->x, ourScreenPoints[1]->y, ourScreenPoints[1]->z); @@ -298,7 +298,7 @@ void GLrTriangle(M3tTri *inTri) clipped = UUmMax3(inTri->indices[0], inTri->indices[1], inTri->indices[2]) > GLgDrawContextPrivate->vertexCount; clipped = GLgVertexArray ? clipped : UUcTrue; - + if (clipped) { glBegin(GL_TRIANGLES); glColor4ub(GLmR(ourShades[0]), GLmG(ourShades[0]), GLmB(ourShades[0]), alpha); @@ -329,7 +329,7 @@ void GLrTriangle(M3tTri *inTri) glArrayElement(inTri->indices[2]); glEnd(); } - + FLUSH @@ -363,7 +363,7 @@ void GLrQuad(M3tQuad *inQuad) ourTextureCoords[1] = textureCoords + inQuad->indices[1]; ourTextureCoords[2] = textureCoords + inQuad->indices[2]; ourTextureCoords[3] = textureCoords + inQuad->indices[3]; - + clipped = UUmMax4(inQuad->indices[0], inQuad->indices[1], inQuad->indices[2], inQuad->indices[3]) > GLgDrawContextPrivate->vertexCount; clipped = GLgVertexArray ? clipped : UUcTrue; @@ -443,7 +443,7 @@ void GLrPent(M3tPent *inPent) ourTextureCoords[2] = textureCoords + inPent->indices[2]; ourTextureCoords[3] = textureCoords + inPent->indices[3]; ourTextureCoords[4] = textureCoords + inPent->indices[4]; - + glBegin(GL_POLYGON); glColor4ub(GLmR(ourShades[0]), GLmG(ourShades[0]), GLmB(ourShades[0]), alpha); glTexCoord4f(ourTextureCoords[0]->u * ourScreenPoints[0]->invW, ourTextureCoords[0]->v * ourScreenPoints[0]->invW, 0.f, ourScreenPoints[0]->invW); @@ -508,7 +508,7 @@ void GLrTriangle_Flat(M3tTri *inTri) GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); #endif - + glBegin(GL_TRIANGLES); glTexCoord4f(ourTextureCoords[0]->u * ourScreenPoints[0]->invW, ourTextureCoords[0]->v * ourScreenPoints[0]->invW, 0.f, ourScreenPoints[0]->invW); glVertex3f(ourScreenPoints[0]->x, ourScreenPoints[0]->y, ourScreenPoints[0]->z); @@ -544,7 +544,7 @@ void GLrQuad_Flat(M3tQuad *inQuad) ourTextureCoords[1] = textureCoords + inQuad->indices[1]; ourTextureCoords[2] = textureCoords + inQuad->indices[2]; ourTextureCoords[3] = textureCoords + inQuad->indices[3]; - + #if 0 glColor4f( GLgDrawContextPrivate->constant_r, @@ -552,7 +552,7 @@ void GLrQuad_Flat(M3tQuad *inQuad) GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); #endif - + glBegin(GL_QUADS); glTexCoord4f(ourTextureCoords[0]->u * ourScreenPoints[0]->invW, ourTextureCoords[0]->v * ourScreenPoints[0]->invW, 0.f, ourScreenPoints[0]->invW); glVertex3f(ourScreenPoints[0]->x, ourScreenPoints[0]->y, ourScreenPoints[0]->z); @@ -593,7 +593,7 @@ void GLrPent_Flat(M3tPent *inPent) ourTextureCoords[2] = textureCoords + inPent->indices[2]; ourTextureCoords[3] = textureCoords + inPent->indices[3]; ourTextureCoords[4] = textureCoords + inPent->indices[4]; - + #if 0 glColor4f( GLgDrawContextPrivate->constant_r, @@ -601,7 +601,7 @@ void GLrPent_Flat(M3tPent *inPent) GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); #endif - + glBegin(GL_POLYGON); glTexCoord4f(ourTextureCoords[0]->u * ourScreenPoints[0]->invW, ourTextureCoords[0]->v * ourScreenPoints[0]->invW, 0.f, ourScreenPoints[0]->invW); glVertex3f(ourScreenPoints[0]->x, ourScreenPoints[0]->y, ourScreenPoints[0]->z); @@ -643,7 +643,7 @@ void GLrTriangle_Gourand(M3tTri *inTri) ourShades[0] = vertexShades[inTri->indices[0]]; ourShades[1] = vertexShades[inTri->indices[1]]; ourShades[2] = vertexShades[inTri->indices[2]]; - + glBegin(GL_TRIANGLES); glColor4ub(GLmR(ourShades[0]), GLmG(ourShades[0]), GLmB(ourShades[0]), alpha); glVertex3f(ourScreenPoints[0]->x, ourScreenPoints[0]->y, ourScreenPoints[0]->z); @@ -680,7 +680,7 @@ void GLrQuad_Gourand(M3tQuad *inQuad) ourShades[1] = vertexShades[inQuad->indices[1]]; ourShades[2] = vertexShades[inQuad->indices[2]]; ourShades[3] = vertexShades[inQuad->indices[3]]; - + glBegin(GL_QUADS); glColor4ub(GLmR(ourShades[0]), GLmG(ourShades[0]), GLmB(ourShades[0]), alpha); glVertex3f(ourScreenPoints[0]->x, ourScreenPoints[0]->y, ourScreenPoints[0]->z); @@ -722,7 +722,7 @@ void GLrPent_Gourand(M3tPent *inPent) ourShades[2] = vertexShades[inPent->indices[2]]; ourShades[3] = vertexShades[inPent->indices[3]]; ourShades[4] = vertexShades[inPent->indices[4]]; - + glBegin(GL_POLYGON); glColor4ub(GLmR(ourShades[0]), GLmG(ourShades[0]), GLmB(ourShades[0]), alpha); glVertex3f(ourScreenPoints[0]->x, ourScreenPoints[0]->y, ourScreenPoints[0]->z); @@ -758,18 +758,18 @@ void GLrTriangle_Wireframe(M3tTri *inTri) ourScreenPoints[0] = screenPoints + inTri->indices[0]; ourScreenPoints[1] = screenPoints + inTri->indices[1]; ourScreenPoints[2] = screenPoints + inTri->indices[2]; - + #if 0 glColor4f( - GLgDrawContextPrivate->constant_r, - GLgDrawContextPrivate->constant_g, - GLgDrawContextPrivate->constant_b, + GLgDrawContextPrivate->constant_r, + GLgDrawContextPrivate->constant_g, + GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); #endif - + clipped = UUmMax3(inTri->indices[0], inTri->indices[1], inTri->indices[2]) > GLgDrawContextPrivate->vertexCount; clipped = GLgVertexArray ? clipped : UUcTrue; - + if (clipped) { glBegin(GL_LINE_LOOP); glVertex3f(ourScreenPoints[0]->x, ourScreenPoints[0]->y, ourScreenPoints[0]->z); @@ -784,7 +784,7 @@ void GLrTriangle_Wireframe(M3tTri *inTri) glArrayElement(inTri->indices[2]); glEnd(); } - + FLUSH @@ -805,18 +805,18 @@ void GLrQuad_Wireframe(M3tQuad *inQuad) ourScreenPoints[1] = screenPoints + inQuad->indices[1]; ourScreenPoints[2] = screenPoints + inQuad->indices[2]; ourScreenPoints[3] = screenPoints + inQuad->indices[3]; - + #if 0 glColor4f( - GLgDrawContextPrivate->constant_r, - GLgDrawContextPrivate->constant_g, - GLgDrawContextPrivate->constant_b, + GLgDrawContextPrivate->constant_r, + GLgDrawContextPrivate->constant_g, + GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); #endif - + clipped = UUmMax4(inQuad->indices[0], inQuad->indices[1], inQuad->indices[2], inQuad->indices[3]) > GLgDrawContextPrivate->vertexCount; clipped = GLgVertexArray ? clipped : UUcTrue; - + if (clipped) { glBegin(GL_LINE_LOOP); glVertex3f(ourScreenPoints[0]->x, ourScreenPoints[0]->y, ourScreenPoints[0]->z); @@ -833,7 +833,7 @@ void GLrQuad_Wireframe(M3tQuad *inQuad) glArrayElement(inQuad->indices[3]); glEnd(); } - + FLUSH @@ -854,18 +854,18 @@ void GLrPent_Wireframe(M3tPent *inPent) ourScreenPoints[2] = screenPoints + inPent->indices[2]; ourScreenPoints[3] = screenPoints + inPent->indices[3]; ourScreenPoints[4] = screenPoints + inPent->indices[4]; - + #if 0 glColor4f( - GLgDrawContextPrivate->constant_r, - GLgDrawContextPrivate->constant_g, - GLgDrawContextPrivate->constant_b, + GLgDrawContextPrivate->constant_r, + GLgDrawContextPrivate->constant_g, + GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); #endif - + clipped = UUmMax5(inPent->indices[0], inPent->indices[1], inPent->indices[2], inPent->indices[3], inPent->indices[4]) > GLgDrawContextPrivate->vertexCount; clipped = GLgVertexArray ? clipped : UUcTrue; - + if (clipped) { glBegin(GL_LINE_LOOP); glVertex3f(ourScreenPoints[0]->x, ourScreenPoints[0]->y, ourScreenPoints[0]->z); @@ -884,7 +884,7 @@ void GLrPent_Wireframe(M3tPent *inPent) glArrayElement(inPent->indices[4]); glEnd(); } - + FLUSH @@ -903,15 +903,15 @@ void GLrTriangleSplit_VertexLighting(M3tTriSplit *inTri) UUtUns8 alpha = (UUtUns8) MUrUnsignedSmallFloat_To_Int_Round(GLgDrawContextPrivate->constant_a * 0xff); OGLrCommon_Camera_Update(OGLcCameraMode_2D); - + #if 0 glColor4f( - GLgDrawContextPrivate->constant_r, - GLgDrawContextPrivate->constant_g, - GLgDrawContextPrivate->constant_b, + GLgDrawContextPrivate->constant_r, + GLgDrawContextPrivate->constant_g, + GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); #endif - + ourScreenPoints[0] = screenPoints + inTri->vertexIndices.indices[0]; ourScreenPoints[1] = screenPoints + inTri->vertexIndices.indices[1]; ourScreenPoints[2] = screenPoints + inTri->vertexIndices.indices[2]; @@ -924,7 +924,7 @@ void GLrTriangleSplit_VertexLighting(M3tTriSplit *inTri) clipped = UUmMax3(inTri->vertexIndices.indices[0], inTri->vertexIndices.indices[1], inTri->vertexIndices.indices[2]) > GLgDrawContextPrivate->vertexCount; clipped = GLgVertexArray ? clipped : UUcTrue; - + if (clipped) { glBegin(GL_TRIANGLES); glColor4ub(GLmR(vertexShades[0]), GLmG(vertexShades[0]), GLmB(vertexShades[0]), alpha); @@ -972,15 +972,15 @@ void GLrQuadSplit_VertexLighting(M3tQuadSplit *inQuad) UUtUns8 alpha = (UUtUns8) MUrUnsignedSmallFloat_To_Int_Round(GLgDrawContextPrivate->constant_a * 0xff); OGLrCommon_Camera_Update(OGLcCameraMode_2D); - + #if 0 glColor4f( - GLgDrawContextPrivate->constant_r, - GLgDrawContextPrivate->constant_g, - GLgDrawContextPrivate->constant_b, + GLgDrawContextPrivate->constant_r, + GLgDrawContextPrivate->constant_g, + GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); #endif - + ourScreenPoints[0] = screenPoints + inQuad->vertexIndices.indices[0]; ourScreenPoints[1] = screenPoints + inQuad->vertexIndices.indices[1]; ourScreenPoints[2] = screenPoints + inQuad->vertexIndices.indices[2]; @@ -1051,15 +1051,15 @@ void GLrPentSplit_VertexLighting(M3tPentSplit *inPent) UUtUns8 alpha = (UUtUns8) MUrUnsignedSmallFloat_To_Int_Round(GLgDrawContextPrivate->constant_a * 0xff); OGLrCommon_Camera_Update(OGLcCameraMode_2D); - + #if 0 glColor4f( - GLgDrawContextPrivate->constant_r, - GLgDrawContextPrivate->constant_g, - GLgDrawContextPrivate->constant_b, + GLgDrawContextPrivate->constant_r, + GLgDrawContextPrivate->constant_g, + GLgDrawContextPrivate->constant_b, GLgDrawContextPrivate->constant_a); #endif - + ourScreenPoints[0] = screenPoints + inPent->vertexIndices.indices[0]; ourScreenPoints[1] = screenPoints + inPent->vertexIndices.indices[1]; ourScreenPoints[2] = screenPoints + inPent->vertexIndices.indices[2]; @@ -1157,7 +1157,7 @@ void GLrTriangle_EnvironmentMap_Only(M3tTri *inTri) clipped = UUmMax3(inTri->indices[0], inTri->indices[1], inTri->indices[2]) > GLgDrawContextPrivate->vertexCount; clipped = GLgVertexArray ? clipped : UUcTrue; - + if (clipped) { glBegin(GL_TRIANGLES); glColor4ub(GLmR(ourShades[0]), GLmG(ourShades[0]), GLmB(ourShades[0]), alpha); @@ -1188,7 +1188,7 @@ void GLrTriangle_EnvironmentMap_Only(M3tTri *inTri) glArrayElement(inTri->indices[2]); glEnd(); } - + FLUSH @@ -1222,7 +1222,7 @@ void GLrQuad_EnvironmentMap_Only(M3tQuad *inQuad) ourTextureCoords[1] = textureCoords + inQuad->indices[1]; ourTextureCoords[2] = textureCoords + inQuad->indices[2]; ourTextureCoords[3] = textureCoords + inQuad->indices[3]; - + clipped = UUmMax4(inQuad->indices[0], inQuad->indices[1], inQuad->indices[2], inQuad->indices[3]) > GLgDrawContextPrivate->vertexCount; clipped = GLgVertexArray ? clipped : UUcTrue; @@ -1302,7 +1302,7 @@ void GLrPent_EnvironmentMap_Only(M3tPent *inPent) ourTextureCoords[2] = textureCoords + inPent->indices[2]; ourTextureCoords[3] = textureCoords + inPent->indices[3]; ourTextureCoords[4] = textureCoords + inPent->indices[4]; - + glBegin(GL_POLYGON); glColor4ub(GLmR(ourShades[0]), GLmG(ourShades[0]), GLmB(ourShades[0]), alpha); glTexCoord4f(ourTextureCoords[0]->u * ourScreenPoints[0]->invW, ourTextureCoords[0]->v * ourScreenPoints[0]->invW, 0.f, ourScreenPoints[0]->invW); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Draw_Functions.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Draw_Functions.h index 7b74d59..fa54ad7 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Draw_Functions.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Draw_Functions.h @@ -1,12 +1,12 @@ /* FILE: GL_DC_Method_Frame.h - + AUTHOR: Michael Evans - + CREATED: August 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -20,7 +20,7 @@ void GLrDrawContext_Method_TriSprite( const M3tPointScreen *inPoints, // points[3] const M3tTextureCoord *inTextureCoords); // UVs[3] - + void GLrDrawContext_Method_Sprite( const M3tPointScreen *inPoints, // tl, br @@ -34,7 +34,7 @@ GLrDrawContext_Method_SpriteArray( const UUtUns32 inCount ); UUtError GLrDrawContext_Method_ScreenCapture( - const UUtRect *inRect, + const UUtRect *inRect, void *outBuffer); UUtBool GLrDrawContext_Method_PointVisible( @@ -83,4 +83,4 @@ void GLrTriangle_EnvironmentMap_1TMU(M3tTri *inTri); void GLrQuad_EnvironmentMap_1TMU(M3tQuad *inQuad); void GLrPent_EnvironmentMap_1TMU(M3tPent *inPent); -#endif \ No newline at end of file +#endif diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Platform.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Platform.h index a0a9687..6932ac9 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Platform.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Platform.h @@ -1,12 +1,12 @@ /* FILE: GL_Platform_H - + AUTHOR: Michael Evans - + CREATED: August 10, 1999 - + PURPOSE: OpenGL Draw Engine - + Copyright 1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Platform_MacOS.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Platform_MacOS.c index 9d7fd05..a09a057 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Platform_MacOS.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Platform_MacOS.c @@ -42,19 +42,19 @@ GLrPlatform_Initialize( OSStatus status; DisplayIDType displayID; GDHandle device;*/ - + UUmAssert(ONgPlatformData.gameWindow); - + // get the device that the draw sprocket context is displayed on /* dsp_context = (DSpContextReference)GetWRefCon(ONgPlatformData.gameWindow); if (dsp_context == NULL) return UUcError_Generic; - + status = DSpContext_GetDisplayID(dsp_context, &displayID); if (status != noErr) return UUcError_Generic; - + status = DMGetGDeviceByDisplayID(displayID, &device, UUcFalse); if (status != noErr) return UUcError_Generic; - + // choose a pixel format pixel_format = aglChoosePixelFormat(&device, 1, GLgPixelAttributes_FullScreen); if (pixel_format == NULL) @@ -62,7 +62,7 @@ GLrPlatform_Initialize( pixel_format = aglChoosePixelFormat(&device, 1, GLgPixelAttributes_Window); if (pixel_format == NULL) return UUcError_Generic; }*/ - + // choose a pixel format // pixel_format = aglChoosePixelFormat(NULL, 0, GLgPixelAttributes_FullScreen); // if (pixel_format == NULL) @@ -74,22 +74,22 @@ GLrPlatform_Initialize( if (pixel_format == NULL) { return UUcError_Generic; } } } - + // create an AGL context GLgContext = aglCreateContext(pixel_format, NULL); if (GLgContext == NULL) return UUcError_Generic; - + // attach the window to the context result = aglSetDrawable(GLgContext, ONgPlatformData.gameWindow); if (result == GL_FALSE) return UUcError_Generic; - + // set the current context result = aglSetCurrentContext(GLgContext); if (result == GL_FALSE) return UUcError_Generic; - + // destroy the pixel format aglDestroyPixelFormat(pixel_format); - + /* Find the depth of the main screen */ pixelsize = (*(*GetMainDevice())->gdPMap)->pixelSize; if (32 != pixelsize) exit(1); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Platform_Windows.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Platform_Windows.c index 4621dd9..f8ed10f 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Platform_Windows.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Platform_Windows.c @@ -28,27 +28,27 @@ boolean available_opengl_platform( { static boolean first_time= TRUE; static boolean has_opengl= FALSE; - + if (first_time) { PIXELFORMATDESCRIPTOR pfd; HDC device_context; short pixel_format; - + first_time= FALSE; - + memset(&pfd,0,sizeof(PIXELFORMATDESCRIPTOR)); - + pfd.nSize= sizeof(PIXELFORMATDESCRIPTOR); pfd.nVersion= 1; pfd.dwFlags= PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; - + UUmAssert(ONgPlatformData.gameWindow && (ONgPlatformData.gameWindow != INVALID_HANDLE_VALUE)); device_context= GetDC(ONgPlatformData.gameWindow); UUmAssert(device_context); - + pixel_format= ChoosePixelFormat(device_context,&pfd); - + if ( DescribePixelFormat(device_context,pixel_format,sizeof(PIXELFORMATDESCRIPTOR),&pfd) && (pfd.dwFlags & PFD_DRAW_TO_WINDOW) && @@ -58,10 +58,10 @@ boolean available_opengl_platform( ) { has_opengl= TRUE; } - + ReleaseDC(ONgPlatformData.gameWindow,device_context); } - + return has_opengl; } @@ -71,17 +71,17 @@ static UUtBool fullscreenCandidate(HWND hwnd) { UUtBool status = UUcFalse; DWORD style = GetWindowLong (hwnd, GWL_STYLE); - // Quake II sets (WS_POPUP | WS_VISIBLE | + // Quake II sets (WS_POPUP | WS_VISIBLE | // WS_CLIPSIBLINGS) - // Heretic II sets (WS_POPUP | WS_VISIBLE | - // WS_CLIPSIBLINGS | + // Heretic II sets (WS_POPUP | WS_VISIBLE | + // WS_CLIPSIBLINGS | // WS_SYSMENU) - // TrueSpace4 sets (WS_POPUP | WS_VISIBLE | - // WS_CLIPSIBLINGS | WS_CLIPCHILDREN | + // TrueSpace4 sets (WS_POPUP | WS_VISIBLE | + // WS_CLIPSIBLINGS | WS_CLIPCHILDREN | // WS_BORDER | // WS_SYSMENU | WS_THICKFRAME) - // This function needs to - // return 0 for TrueSpace4, which wants a window and + // This function needs to + // return 0 for TrueSpace4, which wants a window and // return 1 for Quake II and Heretic II, which want fullscreen if ( (style & WS_POPUP) && !(style & (WS_BORDER | WS_THICKFRAME))) @@ -97,7 +97,7 @@ static UUtBool fullscreenCandidate(HWND hwnd) { } static DEVMODE original_display_mode; - + static void GLrSetDisplaySettings(UUtInt32 width, UUtInt32 height, UUtInt32 depth) { BOOL success; @@ -115,7 +115,7 @@ static void GLrSetDisplaySettings(UUtInt32 width, UUtInt32 height, UUtInt32 dept desired_display_mode.dmPelsHeight = height; desired_display_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; desired_display_mode.dmDriverExtra = 0; - + if (M3gResolutionSwitch) { LONG result; @@ -159,7 +159,7 @@ GLrPlatform_Initialize( if (M3gResolutionSwitch) { UUmAssert(fullscreenCandidate(ONgPlatformData.gameWindow)); } - + UUmAssert(ONgPlatformData.gameWindow && (ONgPlatformData.gameWindow != INVALID_HANDLE_VALUE)); gDeviceContext= GetDC(ONgPlatformData.gameWindow); UUmAssert(gDeviceContext); @@ -253,7 +253,7 @@ GLrPlatform_Dispose( UUmAssert(gRenderContext); success = wglDeleteContext(gRenderContext); UUmAssert(success); - + UUmAssert(ONgPlatformData.gameWindow && (ONgPlatformData.gameWindow != INVALID_HANDLE_VALUE)); ReleaseDC(ONgPlatformData.gameWindow,gDeviceContext); @@ -270,8 +270,8 @@ GLrPlatform_Dispose( screen_width, screen_height, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER); - - return; + + return; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Utility_Functions.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Utility_Functions.c index f722144..b7ff95b 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Utility_Functions.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Utility_Functions.c @@ -1,12 +1,12 @@ /* FILE: GL_DC_Method_Frame.h - + AUTHOR: Michael Evans - + CREATED: August 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -58,10 +58,10 @@ GLrDrawContext_Method_Frame_Start( // update fog params OGLrCommon_glFogEnable(); - + return UUcError_None; } - + // ---------------------------------------------------------------------- UUtError GLrDrawContext_Method_Frame_End( @@ -74,7 +74,7 @@ GLrDrawContext_Method_Frame_End( if (GLgDoubleBuffer) { GLrPlatform_DisplayBackBuffer(); } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Utility_Functions.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Utility_Functions.h index fe252c6..8f670cf 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Utility_Functions.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/GL_Utility_Functions.h @@ -1,12 +1,12 @@ /* FILE: GL_DC_Method_Frame.h - + AUTHOR: Michael Evans - + CREATED: August 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_engine.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_engine.c index 706ab8c..d94271f 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_engine.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_engine.c @@ -58,7 +58,7 @@ UUtBool gl_draw_engine_initialize( if ((success= opengl_available())) { UUtError error= UUcError_None; - + //gl->mode= NONE; //gl->vertex_count= 0; //gl->vertex_format_flags= NONE; @@ -67,12 +67,12 @@ UUtBool gl_draw_engine_initialize( gl->draw_engine_methods.contextPrivateNew= gl_context_private_new; gl->draw_engine_methods.contextPrivateDelete= gl_context_private_delete; gl->draw_engine_methods.textureResetAll= gl_texture_reset_all; - + gl->draw_engine_methods.privateStateSize= 0; gl->draw_engine_methods.privateStateNew= gl_private_state_new; gl->draw_engine_methods.privateStateDelete= gl_private_state_delete; gl->draw_engine_methods.privateStateUpdate= gl_private_state_update; - + gl->draw_engine_caps.engineFlags= M3cDrawEngineFlag_3DOnly; UUrString_Copy(gl->draw_engine_caps.engineName, M3cDrawEngine_OpenGL, M3cMaxNameLen); gl->draw_engine_caps.engineDriver[0] = 0; @@ -86,7 +86,7 @@ UUtBool gl_draw_engine_initialize( error= M3rManager_Register_DrawEngine(&gl->draw_engine_caps, &gl->draw_engine_methods); - + if (error != UUcError_None) { UUrError_Report(UUcError_Generic, "Could not setup engine caps"); @@ -139,7 +139,7 @@ static UUtError gl_context_private_new( word active_device; word active_mode; M3tDrawEngineCaps *active_draw_engine_caps; - + UUrStartupMessage("creating new OpenGL context"); *out_api= M3cDrawAPI_OpenGL; @@ -167,10 +167,10 @@ static UUtError gl_context_private_new( gl->draw_context_methods.loadTexture= gl_texture_map_create; gl->draw_context_methods.unloadTexture= gl_texture_map_delete; gl->draw_context_methods.supportSinglePassMultitexture= gl_single_pass_multitexture_capable; - gl->draw_context_methods.supportPointVisible= gl_support_depth_reads; + gl->draw_context_methods.supportPointVisible= gl_support_depth_reads; *out_draw_context_funcs= &gl->draw_context_methods; - + gl->context_type= in_draw_context_descriptor->type; gl->display_mode= active_draw_engine_caps->displayDevices[active_device].displayModes[active_mode]; @@ -197,7 +197,7 @@ static UUtError gl_context_private_new( // force update of the camera gl->camera_mode= _camera_mode_3d; gl_camera_update(_camera_mode_2d); - + // create the texture private array if (gl->texture_private_data == NULL) { @@ -225,7 +225,7 @@ static void gl_context_private_delete( TMrTemplate_PrivateData_Delete(gl->texture_private_data); gl->texture_private_data= NULL; } - + if (gl->loaded_texture_array) { UUrMemory_Block_Delete(gl->loaded_texture_array); @@ -268,9 +268,9 @@ static UUtError gl_change_mode( { UUtError error= UUcError_None; M3tDisplayMode oldMode= gl->display_mode; - + gl->display_mode= mode; - + // this relies on gl_platform_initialize() doing the resolution // switch for us without messing up anything else!! if (gl_platform_initialize() == FALSE) @@ -326,7 +326,7 @@ static UUtError gl_private_state_update( } #endif -#ifdef GL_ENABLE_ALPHA_FADE_CODE +#ifdef GL_ENABLE_ALPHA_FADE_CODE // special frame buffer blend mode (for the invisibility powerup) if (in_state_int_flags & (1<texture0= gl->texture1= NULL; - + // set base texture map - if ((in_state_int[M3cDrawStateIntType_Appearence] != M3cDrawState_Appearence_Gouraud) && + if ((in_state_int[M3cDrawStateIntType_Appearence] != M3cDrawState_Appearence_Gouraud) && (in_state_int[M3cDrawStateIntType_Fill] == M3cDrawState_Fill_Solid) && (in_state_ptr_flags & (1 << M3cDrawStatePtrType_BaseTextureMap))) { @@ -386,7 +386,7 @@ static UUtError gl_private_state_update( constant_color_changed= TRUE; } } - + if (in_state_int_flags & ((1<constant_color.r= (byte)((in_state_int[M3cDrawStateIntType_ConstantColor]&0x00FF0000)>>16); @@ -394,19 +394,19 @@ static UUtError gl_private_state_update( gl->constant_color.b= (byte)(in_state_int[M3cDrawStateIntType_ConstantColor]&0x000000FF); constant_color_changed= TRUE; } - + if (constant_color_changed) { GL_FXN(glColor4ub)(gl->constant_color.r, gl->constant_color.g, gl->constant_color.b, gl->constant_color.a); } - + // what does this mean? /*if (in_state_int_flags & ((1<texture0= (M3tTextureMap*)in_state_ptr[M3cDrawStatePtrType_EnvTextureMap]; gl->texture1= (M3tTextureMap*)in_state_ptr[M3cDrawStatePtrType_BaseTextureMap]; UUmAssert(gl->texture1); - + if (gl_save_geom_draw_mode == NONE) { if (ONrMotoko_GraphicsQuality_SupportReflectionMapping() == FALSE) @@ -487,7 +487,7 @@ static UUtError gl_private_state_update( current_fill_mode= gl_fill_mode; } } - + if ((in_state_int_flags & (1<buffer_clear= (boolean)in_state_int[M3cDrawStateIntType_BufferClear])) { @@ -497,7 +497,7 @@ static UUtError gl_private_state_update( gl->clear_color.b= (float)((in_state_int[M3cDrawStateIntType_ClearColor]&0x000000FF) * ONE_OVER_255); GL_FXN(glClearColor)(gl->clear_color.r, gl->clear_color.g, gl->clear_color.b, gl->clear_color.a); } - + if (in_state_int_flags & (1<double_buffer= (boolean)in_state_int[M3cDrawStateIntType_DoubleBuffer]; @@ -533,7 +533,7 @@ void gl_finish_multipass( { gl->geom_draw_mode= gl_save_geom_draw_mode; gl_save_geom_draw_mode= NONE; - + return; } @@ -634,11 +634,11 @@ static UUtError gl_frame_start( { gl->frame_count= 0; } - + // COrConsole_Printf_Color(2, 0xFF30FF30, 0xFF307030, "texture memory used= %ld bytes", gl->current_texture_memory); - + UUmAssert(gl_GetError() == GL_NO_ERROR); - + return UUcError_None; } @@ -646,13 +646,13 @@ static UUtError gl_frame_end( UUtUns32 *out_texture_bytes_downloaded) { *out_texture_bytes_downloaded = 0; - + if (gl->double_buffer) { gl->gl_display_back_buffer(); } UUmAssert(gl_GetError() == GL_NO_ERROR); - + return UUcError_None; } @@ -677,7 +677,7 @@ static UUtError gl_screen_capture( GL_FXN(glReadPixels)(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, out_buffer); UUmAssert(gl_GetError() == GL_NO_ERROR); - + return UUcError_None; } @@ -688,11 +688,11 @@ static UUtBool gl_point_visible( GLfloat depth_val; GLint x= MUrUnsignedSmallFloat_To_Uns_Round(in_point->x); GLint y= gl->display_mode.height - MUrUnsignedSmallFloat_To_Uns_Round(in_point->y); - + GL_FXN(glReadBuffer)(GL_BACK); GL_FXN(glReadPixels)(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, (void *)&depth_val); UUmAssert(gl_GetError() == GL_NO_ERROR); - + // visible if the point isn't behind the distance stored in the depth buffer return (depth_val > in_point->z); } @@ -841,7 +841,7 @@ static void gl_line( our_screen_points[0]= screen_points + index0; our_screen_points[1]= screen_points + index1; - + GL_FXN(glBegin)(GL_LINES); GL_FXN(glVertex3f)(our_screen_points[0]->x, our_screen_points[0]->y, ZCOORD(our_screen_points[0]->z)); GL_FXN(glVertex3f)(our_screen_points[1]->x, our_screen_points[1]->y, ZCOORD(our_screen_points[1]->z)); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_engine.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_engine.h index 484f48a..a59a9a0 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_engine.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_engine.h @@ -112,15 +112,15 @@ enum { _gl_initial_dfactor= GL_ZERO, MAX_COMPRESSED_TEXTURE_FORMATS= 16, - + // S.S. 11/09/2000 added this for texture management - + MAX_INTERNAL_FRAME_COUNT_VALUE= 0x00FFFFFF, // storing in the 3 pad bytes for a Motoko texture - + KILO= 1024, MEG= KILO * KILO, GIG= KILO * MEG, - + // this regulates how many OpenGL textures we will keep loaded // gl_macos.c contains code which regulates this based on graphics quality setting MAX_DEFAULT_TEXTURE_MEMORY_LIMIT= 1 * GIG, // no limit @@ -558,7 +558,7 @@ struct gl_api { // this is so we can load the apropriate OpenGL DLL on Windows, void (APIENTRY *glViewport)(GLint x, GLint y, GLsizei width, GLsizei height); #if defined(UUmPlatform) && (UUmPlatform == UUmPlatform_Win32) - + // WGL BOOL (WINAPI *wglCopyContext)(HGLRC, HGLRC, UINT); HGLRC (WINAPI *wglCreateContext)(HDC); @@ -614,7 +614,7 @@ struct gl_api { // this is so we can load the apropriate OpenGL DLL on Windows, struct gl_state_global { boolean engine_initialized; - + M3tDrawEngineCaps draw_engine_caps; M3tDrawEngineMethods draw_engine_methods; M3tDrawContextMethods draw_context_methods; @@ -623,7 +623,7 @@ struct gl_state_global { M3tDrawContextType context_type; -/* 09/01/2000 we will never be using vertex arrays for oni +/* 09/01/2000 we will never be using vertex arrays for oni gl_vertex *vertices; gl_color_4ub *vertex_colors; gl_texture_coord *uvs0; @@ -655,7 +655,7 @@ struct gl_state_global { char *renderer; char *version; char *extensions; - + int multitexture; int mipmap_offset; GLint max_nvidia_general_combiners; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_geometry_draw_method.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_geometry_draw_method.c index dfe4545..48bb8f2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_geometry_draw_method.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_geometry_draw_method.c @@ -148,7 +148,7 @@ static void FUNCTION_NAME ( // diffuse color + base texture { GEOM_SPLIT_TYPE *in_geom_split= (GEOM_SPLIT_TYPE *)in_geom; - + gl_set_textures(gl->texture0, NULL, NONE, NONE); // this will flush buffers if needed GL_FXN(glBegin)(GEOMETRY_MODE); for (i=0; istate_ptr[M3cDrawStatePtrType_EnvTextureCoordArray]; - + if (gl->multitexture) { gl_set_textures(gl->texture0, gl->texture1, NONE, NONE); // this will flush buffers if needed diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_macos.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_macos.c index 628b770..11c9493 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_macos.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_macos.c @@ -136,19 +136,19 @@ UUtBool gl_platform_initialize( static short window_width= 0; static short window_height= 0; static short window_depth= 0; - + if (aglChoosePixelFormat == NULL) { AUrMessageBox(AUcMBType_OK, "Oni requires OpenGL to run; please install OpenGL and try again."); exit(0); } - + if (original_display_width == 0) { boolean got_settings; OSErr err= noErr; unsigned long value= 0L; - + // save initial display settings got_settings= gl_get_current_display_setting(&original_display_width, &original_display_height, &original_display_depth); UUrStartupMessage("original display settings= %dx%dx%d : %s", original_display_width, original_display_height, original_display_depth, @@ -159,9 +159,9 @@ UUtBool gl_platform_initialize( UUrStartupMessage("DMGetDisplayMode() returned err= %d", err); } } - + UUmAssert(ONgPlatformData.gameWindow); - + if (gl->context == NULL) { if (gl->display_mode.bitDepth == 32) @@ -172,13 +172,13 @@ UUtBool gl_platform_initialize( { pixel_format= aglChoosePixelFormat(NULL, 0, pixel_attributes_16bit); } - + if (pixel_format == NULL) { AUtMB_ButtonChoice response; UUtUns32 gl_macos_pref; UUtBool option_key_down; - + gl_macos_pref= gl_macos_read_pref(); option_key_down= LIrPlatform_TestKey(LIcKeyCode_LeftOption, 0); if ((gl_macos_pref & _mac_always_search_any_opengl_pref_flag) && (option_key_down == UUcFalse)) @@ -198,7 +198,7 @@ UUtBool gl_platform_initialize( } gl_macos_write_pref(gl_macos_pref); } - + if (response == AUcMBChoice_Yes) { GLint pixel_attributes_any32bit[]= { @@ -217,7 +217,7 @@ UUtBool gl_platform_initialize( 16, AGL_NONE }; - + if (gl->display_mode.bitDepth == 32) { pixel_format= aglChoosePixelFormat(NULL, 0, pixel_attributes_any32bit); @@ -228,7 +228,7 @@ UUtBool gl_platform_initialize( } } } - + if (pixel_format != NULL) { if (M3gResolutionSwitch) @@ -250,7 +250,7 @@ UUtBool gl_platform_initialize( { success= TRUE; } - + if (success) { gl->context= aglCreateContext(pixel_format, NULL); @@ -267,10 +267,10 @@ UUtBool gl_platform_initialize( 8 * MEG, 16 * MEG, 32 * MEG}; - + quality_setting= UUmMin(quality_setting, 4); available_texture_memory= texture_memory_based_on_quality[quality_setting]; - + success= aglSetCurrentContext((AGLContext)gl->context); aglDestroyPixelFormat(pixel_format); window_width= gl->display_mode.width; @@ -298,13 +298,13 @@ UUtBool gl_platform_initialize( { success= TRUE; } - + if (success) { SizeWindow(ONgPlatformData.gameWindow, gl->display_mode.width, gl->display_mode.height, false); window_width= gl->display_mode.width; window_height= gl->display_mode.height; - + if (!aglUpdateContext((AGLContext)gl->context)) { UUrDebuggerMessage("aglUpdateContext() failed after resizing the display"); @@ -316,11 +316,11 @@ UUtBool gl_platform_initialize( // redundant call (also occurs on resolution changing) success= TRUE; } - + if (success) { GLbyte *renderer_string, *vendor_string; - + // punt if we end up in one of Apple's software renderers renderer_string= GL_FXN(glGetString)(GL_RENDERER); vendor_string= GL_FXN(glGetString)(GL_VENDOR); @@ -332,7 +332,7 @@ UUtBool gl_platform_initialize( gl_platform_dispose(); exit(0); } - + // cursor won't stay hidden until we are done messing around with display settings mac_hide_cursor(); } @@ -350,7 +350,7 @@ void gl_platform_dispose( aglDestroyContext((AGLContext)gl->context); gl->context= NULL; } - + // new; since we no longer play bink thru OpenGL we need to grow the window back up to full-screen size // on the chance that the end movie is going to play after we exit this function if (ONgPlatformData.gameWindow && @@ -359,11 +359,11 @@ void gl_platform_dispose( { SizeWindow(ONgPlatformData.gameWindow, original_display_width, original_display_height, false); } - + if (M3gResolutionSwitch) { short width, height, depth; - + // restore previous display settings if we messed with them if (quicktime_screen_state_ptr) { @@ -374,11 +374,11 @@ void gl_platform_dispose( (gl->display_mode.bitDepth != original_display_depth)) { boolean success; - + UUrStartupMessage("resetting display settings to: %dx%dx%d", original_display_width, original_display_height, original_display_depth); success= gl_change_display_setting(original_display_width, original_display_height, original_display_depth); } - + if (gl_get_current_display_setting(&width, &height, &depth)) { UUrStartupMessage("actual exiting display settings= %dx%dx%d", width, height, depth); @@ -390,7 +390,7 @@ void gl_platform_dispose( } } } - + return; } @@ -399,7 +399,7 @@ void gl_display_back_buffer( { UUmAssert(gl->context); aglSwapBuffers((AGLContext)gl->context); - + return; } @@ -408,7 +408,7 @@ void gl_matrox_display_back_buffer( { UUmAssert(gl->context); aglSwapBuffers((AGLContext)gl->context); - + return; } @@ -433,7 +433,7 @@ int gl_enumerate_valid_display_modes( {1600, 1200, 32, 0}, {1920, 1080, 32, 0} /*{1920, 1200, 32, 0}*/}; - + n= sizeof(desired_display_mode_list)/sizeof(desired_display_mode_list[0]); j= 0; for (i= 0; igdPMap))->pixelSize; success= TRUE; } - + return success; } @@ -531,14 +531,14 @@ static boolean gl_test_display_setting( { VideoRequestRec request= {0}; boolean success= FALSE; - + request.screenDevice= GetMainDevice(); request.reqHorizontal= width; request.reqVertical= height; request.reqBitDepth= depth; request.displayMode= nil; // must init to nil request.depthMode= nil; // must init to nil - request.requestFlags= 0; + request.requestFlags= 0; if ((RVRequestVideoSetting(&request) == noErr) && (request.reqHorizontal == request.availHorizontal) && (request.reqVertical == request.availVertical) && @@ -546,7 +546,7 @@ static boolean gl_test_display_setting( { success= TRUE; } - + return success; } @@ -562,7 +562,7 @@ static boolean gl_change_display_setting_use_quicktime( WindowPtr fullscreen_window= NULL; short original_width= width; short original_height= height; - + err= BeginFullScreen(&quicktime_screen_state_ptr, NULL, &width, &height, &fullscreen_window, &black_color, flags); if (err != noErr) { @@ -572,19 +572,19 @@ static boolean gl_change_display_setting_use_quicktime( else { short dx= 0, dy= 0; - + SizeWindow(ONgPlatformData.gameWindow, original_width, original_height, false); BringToFront(ONgPlatformData.gameWindow); - + if ((width > original_width) || (height > original_height)) { dx= (width - original_width)>>1; dy= (height - original_height)>>1; } - + MoveWindow(ONgPlatformData.gameWindow, dx, dy, true); } - + return (err == noErr); } @@ -592,7 +592,7 @@ static boolean gl_restore_display_settings_use_quicktime( void) { OSErr err= noErr; - + if (quicktime_screen_state_ptr) { err= EndFullScreen(quicktime_screen_state_ptr, nil); @@ -605,7 +605,7 @@ static boolean gl_restore_display_settings_use_quicktime( quicktime_screen_state_ptr= NULL; } } - + return (err == noErr); } @@ -617,12 +617,12 @@ static boolean gl_change_display_setting( boolean success= FALSE, osx= FALSE; OSErr err; unsigned long value; - + err= Gestalt(gestaltSystemVersion, &value); if (err == noErr) { unsigned long major_version; - + // value will look like this: 0x00000904 (OS 9.0.4) major_version= (value & 0x0000FF00)>>8; if (major_version >= 10) @@ -630,8 +630,8 @@ static boolean gl_change_display_setting( osx= TRUE; } } - - + + if (osx || quicktime_screen_state_ptr) { success= gl_change_display_setting_use_quicktime(width, height); @@ -642,7 +642,7 @@ static boolean gl_change_display_setting( short current_width; short current_height; short current_bitdepth; - + if (gl_get_current_display_setting(¤t_width, ¤t_height, ¤t_bitdepth)) { request.screenDevice= GetMainDevice(); @@ -651,27 +651,27 @@ static boolean gl_change_display_setting( request.reqBitDepth= depth; request.displayMode= nil; // must init to nil request.depthMode= nil; // must init to nil - request.requestFlags= 0; //1<displayMode && requestRecPtr->depthMode) { - SetDeviceAttribute(requestRecPtr->screenDevice, gdDevType, kColorDev); - + SetDeviceAttribute(requestRecPtr->screenDevice, gdDevType, kColorDev); + err= DMSetDisplayMode(requestRecPtr->screenDevice, // GDevice requestRecPtr->displayMode, // DM1.0 uses this &requestRecPtr->depthMode, // DM1.0 uses this @@ -769,7 +769,7 @@ static OSErr RVSetVideoRequest( display_state_handle); if (noErr == err) { - + } else if (kDMDriverNotDisplayMgrAwareErr == err) { @@ -784,7 +784,7 @@ static OSErr RVSetVideoRequest( { UUrDebuggerMessage("bad display change request", err); } - + return err; } @@ -834,7 +834,7 @@ static OSErr RVRequestVideoSetting( { short iCount = 0; // just a counter of GDevices we have seen DMDisplayModeListIteratorUPP myModeIteratorProc = nil; // for DM2.0 searches - Boolean suppliedGDevice; + Boolean suppliedGDevice; DisplayIDType theDisplayID; // for DM2.0 searches DMListIndexType theDisplayModeCount; // for DM2.0 searches DMListType theDisplayModeList; // for DM2.0 searches @@ -852,10 +852,10 @@ static OSErr RVRequestVideoSetting( walkDevice = DMGetFirstScreenDevice (dmOnlyActiveDisplays); // for everybody suppliedGDevice = false; } - + //myModeIteratorProc = (DMDisplayModeListIteratorUPP)NewDMDisplayModeListIteratorProc(ModeListIterator); // for DM2.0 searches myModeIteratorProc = (DMDisplayModeListIteratorUPP)(ModeListIterator); // for DM2.0 searches - + // Note that we are hosed if somebody changes the gdevice list behind our backs while we are iterating.... // ...now do the loop if we can start if( walkDevice && myModeIteratorProc) do // start the search @@ -885,7 +885,7 @@ static OSErr RVRequestVideoSetting( } while ( !suppliedGDevice && nil != (walkDevice = DMGetNextScreenDevice ( walkDevice, dmOnlyActiveDisplays )) ); // go until no more gdevices if( myModeIteratorProc ) DisposeDMNotificationUPP(myModeIteratorProc); - + return (noErr); // we were able to get the look for a match } @@ -895,10 +895,10 @@ static pascal void ModeListIterator(void *userData, DMListIndexType, DMDisplayMo short iCount; ListIteratorDataRec *myIterateData = (ListIteratorDataRec*) userData; DepthInfo *myDepthInfo; - + // set user data in a round about way myIterateData->displayModeTimingInfo = *displaymodeInfo->displayModeTimingInfo; - + // now get the DMDepthInfo info into memory we own depthCount = displaymodeInfo->displayModeDepthBlockInfo->depthBlockCount; myDepthInfo = (DepthInfo*)NewPtrClear(depthCount * sizeof(DepthInfo)); @@ -910,9 +910,9 @@ static pascal void ModeListIterator(void *userData, DMListIndexType, DMDisplayMo // and fill out all the entries if (depthCount) for (iCount=0; iCount < depthCount; iCount++) { - myDepthInfo[iCount].depthSwitchInfo = + myDepthInfo[iCount].depthSwitchInfo = *displaymodeInfo->displayModeDepthBlockInfo->depthVPBlock[iCount].depthSwitchInfo; - myDepthInfo[iCount].depthVPBlock = + myDepthInfo[iCount].depthVPBlock = *displaymodeInfo->displayModeDepthBlockInfo->depthVPBlock[iCount].depthVPBlock; } } @@ -932,12 +932,12 @@ static void GetRequestTheDM2Way(VideoRequestRecPtr requestRecPtr, for (jCount=0; jCountrequestFlags & 1<availBitDepth = searchData.depthBlocks[kCount].depthVPBlock.vpPixelSize; requestRecPtr->availHorizontal = searchData.depthBlocks[kCount].depthVPBlock.vpBounds.right; requestRecPtr->availVertical = searchData.depthBlocks[kCount].depthVPBlock.vpBounds.bottom; - + // now set the important info for DM to set the display requestRecPtr->depthMode = searchData.depthBlocks[kCount].depthSwitchInfo.csMode; requestRecPtr->displayMode = searchData.depthBlocks[kCount].depthSwitchInfo.csData; @@ -960,12 +960,12 @@ static void GetRequestTheDM2Way(VideoRequestRecPtr requestRecPtr, if (searchData.displayModeTimingInfo.csTimingFlags & 1<availFlags = 0; // mode safe else requestRecPtr->availFlags = 1<= requestRecPtr->reqHorizontal && vertical >= requestRecPtr->reqVertical) - || - !(requestRecPtr->requestFlags & 1<requestFlags & 1<reqBitDepth || - !(requestRecPtr->requestFlags & 1<reqBitDepth || + !(requestRecPtr->requestFlags & 1<reqHorizontal && + ( (horizontal == requestRecPtr->reqHorizontal && vertical == requestRecPtr->reqVertical && bitDepth == requestRecPtr->reqBitDepth) || - !(requestRecPtr->requestFlags & 1<requestFlags & 1<requestFlags & 1<requestFlags & 1<availBitDepth != requestRecPtr->reqBitDepth ) && @@ -1022,18 +1022,18 @@ static Boolean FindBestMatch( bitDepth <= requestRecPtr->reqBitDepth ) || - !(requestRecPtr->requestFlags & 1<requestFlags & 1<availBitDepth < requestRecPtr->reqBitDepth && - bitDepth > requestRecPtr->availBitDepth + bitDepth > requestRecPtr->availBitDepth ) && - ( (horizontal == requestRecPtr->reqHorizontal && + ( (horizontal == requestRecPtr->reqHorizontal && vertical == requestRecPtr->reqVertical && bitDepth == requestRecPtr->reqBitDepth) || - !(requestRecPtr->requestFlags & 1<requestFlags & 1<= requestRecPtr->reqHorizontal && vertical >= requestRecPtr->reqVertical) || @@ -1061,12 +1061,12 @@ static Boolean FindBestMatch( // (depth is less/equal or kShallowDepth not set) and // ([h or v not equal] or [avail depth less reqested and new greater avail] or depth equal avail) and // (request match or kAbsoluteRequest not set) - if ( ( requestRecPtr->availBitDepth == bitDepth || + if ( ( requestRecPtr->availBitDepth == bitDepth || !(requestRecPtr->requestFlags & 1<reqBitDepth || - !(requestRecPtr->requestFlags & 1<reqBitDepth || + !(requestRecPtr->requestFlags & 1<availHorizontal != horizontal || @@ -1078,11 +1078,11 @@ static Boolean FindBestMatch( (bitDepth == requestRecPtr->reqBitDepth) ) && - ( (horizontal == requestRecPtr->reqHorizontal && + ( (horizontal == requestRecPtr->reqHorizontal && vertical == requestRecPtr->reqVertical && bitDepth == requestRecPtr->reqBitDepth) || - !(requestRecPtr->requestFlags & 1<requestFlags & 1<cColorBits= 16; + pfd->cColorBits= 16; pfd->cDepthBits= 16; break; case 32: @@ -267,25 +267,25 @@ boolean gl_create_render_context( void) { boolean success= FALSE; - + if (gl && gl->device_context) { PIXELFORMATDESCRIPTOR pfd; short pixel_format; - + make_pixel_format_descriptor(&pfd, gl->display_mode.bitDepth); pixel_format= GDI_FXN(ChoosePixelFormat)(gl->device_context, &pfd); - + if (pixel_format) { success= (UUtBool)GDI_FXN(SetPixelFormat)(gl->device_context, pixel_format, &pfd); - + if (success) { /* Matrox cards decided to stop running with this line uncommented. They used to work.. but now they don't. And now, a Windows Haiku for your reading pleasure... - + Yesterday it worked. Today it is not working. Windows is like that. @@ -480,7 +480,7 @@ void gl_platform_dispose( UUmAssert(gl->render_context); success= WGL_FXN(wglDeleteContext)(gl->render_context); UUmAssert(success); - + UUmAssert(ONgPlatformData.gameWindow && (ONgPlatformData.gameWindow != INVALID_HANDLE_VALUE)); ReleaseDC(ONgPlatformData.gameWindow, gl->device_context); @@ -497,7 +497,7 @@ void gl_platform_dispose( gl_unload_opengl_dll(); #endif - return; + return; } @@ -598,9 +598,9 @@ static char *gl_find_opengl_dll_from_registry( { HKEY registry_key= NULL; long ret; - + ret= RegOpenKeyEx(HKEY_LOCAL_MACHINE, registry_subkey[i], 0, KEY_READ, ®istry_key); - + if (ret == ERROR_SUCCESS) { long length= 256, type= REG_SZ; @@ -610,7 +610,7 @@ static char *gl_find_opengl_dll_from_registry( while ((names[j] != NULL) && !success) { int ret2= RegQueryValueEx(registry_key, names[j], NULL, (unsigned long*)&type, (unsigned char*)dll_filename, (unsigned long*)&length); - + if (ret2 == ERROR_SUCCESS) { success= TRUE; // found it @@ -1162,7 +1162,7 @@ boolean gl_load_opengl_dll( // 3Dfx gamma extensions (optional) LOAD_GL_FUNCTION(wglSetDeviceGammaRamp3DFX); LOAD_GL_FUNCTION(wglGetDeviceGammaRamp3DFX); - + n= sizeof(struct gl_api)/sizeof(void *); for (i=0; icColorBits= 16; + pfd->cColorBits= 16; pfd->cDepthBits= 16; break; case 32: @@ -145,7 +145,7 @@ boolean gl_create_render_context( { /* boolean success= FALSE; - + success= gl_pixel_format_is_accelerated(&pfd); if (success) { @@ -292,10 +292,10 @@ void gl_platform_dispose( UUmAssert(gl->context); SDL_GL_DeleteContext(gl->context); - + UUmAssert(ONgPlatformData.gameWindow); - return; + return; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_utility.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_utility.c index b37411a..8e0063e 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_utility.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/gl_utility.c @@ -92,7 +92,7 @@ static struct gl_texel_type_info gl_texel_type_info_table[] = { {IMcPixelType_A8, _gl_pixel_download_classic, GL_ALPHA, GL_ALPHA8 }, #endif {IMcPixelType_A8, _gl_pixel_download_packed, GL_UNSIGNED_SHORT_4_4_4_4, GL_RGBA4}, - + {IMcPixelType_A4I4, _gl_pixel_download_generic, 0, GL_LUMINANCE4_ALPHA4}, {IMcPixelType_ARGB8888, _gl_pixel_download_generic, 0, GL_RGBA}, {IMcPixelType_RGB888, _gl_pixel_download_generic, 0, GL_RGB}, @@ -139,7 +139,7 @@ boolean initialize_opengl( { boolean success= TRUE; UUtError error= _error_none; - + UUrStartupMessage("OpenGL platform initialization"); success= gl_platform_initialize(); @@ -294,7 +294,7 @@ boolean initialize_opengl( gl->fog_end= ONI_FOG_END; #ifdef ENABLE_GL_FOG - + GL_FXN(glFogi)(GL_FOG_MODE, GL_LINEAR); GL_FXN(glFogfv)(GL_FOG_COLOR, (float *)&gl->fog_color); #ifdef Z_SCALE @@ -322,7 +322,7 @@ boolean initialize_opengl( #endif #ifdef DISABLE_FOG_ON_3DFX - + if (strstr(gl->renderer, "3Dfx") || strstr(gl->renderer, "3dfx")) { // 3Dfx cards on Mac handle fog correctly (also, vendor string reported as "3dfx" instead of "3Dfx" but we don't want to rely on that) @@ -345,16 +345,16 @@ boolean initialize_opengl( } #endif - + #if defined(UUmPlatform) && (UUmPlatform == UUmPlatform_Mac) // glReadPixels() has proven to be prohibitively slow on current generation ATI // and 3Dfx hardware (ie, the Mac video card market) gl->depth_buffer_reads_disabled= TRUE; #endif - + GL_FXN(glClearColor)(gl->clear_color.r, gl->clear_color.g, gl->clear_color.b, gl->clear_color.a); GL_FXN(glClear)(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - + gl_depth_mode_set(TRUE, TRUE); GL_FXN(glViewport)(0, 0, gl->display_mode.width, gl->display_mode.height); @@ -368,7 +368,7 @@ boolean initialize_opengl( boolean gl_query_extension( char *extension) -{ +{ UUmAssert(gl->extensions); UUmAssert(extension && extension[0] != '\0'); @@ -391,9 +391,9 @@ static void *load_gl_extension_routine( #else #error "unknown platform" #endif - + UUmAssert(gl_GetError() == GL_NO_ERROR); - + return extension_routine; } @@ -423,7 +423,7 @@ void gl_reset_fog_parameters( #endif #endif - + UUmAssert(gl_GetError() == GL_NO_ERROR); return; @@ -547,7 +547,7 @@ void gl_fog_update( gl->fog_end_changing= FALSE; } - } + } else if (delta < 0) { // we are ramping down the fog_end @@ -579,10 +579,10 @@ void gl_camera_update( //M3tManager_GeomCamera *active_camera; UUmAssert(0); // uncharted territory ahead ... -/* +/* M3rCamera_GetActive((M3tGeomCamera**)&active_camera); M3rManager_Camera_UpdateMatrices(active_camera); - + if (gl->camera_mode != _camera_mode_3d) { gl->camera_mode= camera_mode; @@ -604,7 +604,7 @@ void gl_camera_update( active_camera->upVector.y, ZCOORD(active_camera->upVector.z)); } - + if (gl->update_camera_static_data) { #define _180_over_pi 57.295779513082320876798154814105 @@ -646,7 +646,7 @@ void gl_matrix4x3_oni_to_gl( *m++ = inM[1][0]; *m++ = inM[1][1]; *m++ = inM[1][2]; *m++ = 0.0f; *m++ = inM[2][0]; *m++ = inM[2][1]; *m++ = inM[2][2]; *m++ = 0.0f; *m++ = inM[3][0]; *m++ = inM[3][1]; *m++ = inM[3][2]; *m++ = 1.0f; - + return; } @@ -655,12 +655,12 @@ void gl_matrix4x4_oni_to_gl( float *m) { float **inM= (float **)in_matrix->m; - + *m++ = inM[0][0]; *m++ = inM[0][1]; *m++ = inM[0][2]; *m++ = inM[0][3]; *m++ = inM[1][0]; *m++ = inM[1][1]; *m++ = inM[1][2]; *m++ = inM[1][3]; *m++ = inM[2][0]; *m++ = inM[2][1]; *m++ = inM[2][2]; *m++ = inM[2][3]; *m++ = inM[3][0]; *m++ = inM[3][1]; *m++ = inM[3][2]; *m++ = inM[3][3]; - + return; } @@ -746,11 +746,11 @@ static void gl_set_texture_timestamp( { UUmAssert(texture_map); UUmAssert(gl); - + texture_map->pad1[0]= (UUtUns8)(gl->frame_count & 0x000000FF); texture_map->pad1[1]= (UUtUns8)((gl->frame_count & 0x0000FF00) >> 8); texture_map->pad1[2]= (UUtUns8)((gl->frame_count & 0x00FF0000) >> 16); - + return; } @@ -758,14 +758,14 @@ static UUtUns32 gl_get_texture_timestamp( M3tTextureMap *texture_map) { UUtUns32 timestamp; - + UUmAssert(texture_map); UUmAssert(gl); - + timestamp= texture_map->pad1[0] | (((UUtUns32)texture_map->pad1[1] << 8) & 0x0000FF00) | (((UUtUns32)texture_map->pad1[2] << 16) & 0x00FF0000); - + return timestamp; } @@ -776,10 +776,10 @@ static int UUcExternal_Call gl_sort_textures_by_timestamp_proc( // sort so that least recently used textures are at the front of the list; most recently used at the tail end UUtUns32 timestamp0, timestamp1; int ret; - + timestamp0= gl_get_texture_timestamp((M3tTextureMap *)t0); timestamp1= gl_get_texture_timestamp((M3tTextureMap *)t1); - + if (timestamp0 < timestamp1) { ret= -1; @@ -792,7 +792,7 @@ static int UUcExternal_Call gl_sort_textures_by_timestamp_proc( { ret= 0; } - + return ret; } @@ -803,7 +803,7 @@ static void gl_sort_textures_by_timestamp( { qsort(gl->loaded_texture_array, gl->num_loaded_textures, sizeof(M3tTextureMap *), gl_sort_textures_by_timestamp_proc); } - + return; } @@ -813,15 +813,15 @@ static void gl_purge_old_textures_with_memory_limit(UUtUns32 texture_memory_limi { UUtUns32 desired_resident_texture_memory_size; UUtUns32 start_index= 0; - + gl_sort_textures_by_timestamp(); - - + + if (texture_memory_limit > DESIRED_MINIMUM_FREE_TEXTURE_MEMORY) desired_resident_texture_memory_size= texture_memory_limit - DESIRED_MINIMUM_FREE_TEXTURE_MEMORY; else desired_resident_texture_memory_size= texture_memory_limit; - + while ((gl->current_texture_memory > desired_resident_texture_memory_size) && (gl->num_loaded_textures > MINIMUM_TEXTURE_PURGE_LIMIT) && gl->loaded_texture_array[start_index]) @@ -854,7 +854,7 @@ static void gl_purge_old_textures_as_needed( static UUtUns32 texture_memory_limit= 0L; // texture_memory_limit is a desired upper limit for the amount of OpenGL textures to keep in memory // (can be on the card or in RAM) - + if (texture_memory_limit == 0L) { #if defined(UUmPlatform) && (UUmPlatform == UUmPlatform_Mac) @@ -865,7 +865,7 @@ static void gl_purge_old_textures_as_needed( texture_memory_limit= MAX_DEFAULT_TEXTURE_MEMORY_LIMIT; #endif } - + gl_purge_old_textures_with_memory_limit(texture_memory_limit); } @@ -873,10 +873,10 @@ static boolean gl_texture_list_add( M3tTextureMap *texture_map) { boolean success= FALSE; - + UUmAssert(texture_map); UUmAssert(texture_map->opengl_texture_name); - + if (gl->loaded_texture_array == NULL) { gl->loaded_texture_array= (M3tTextureMap **)UUrMemory_Block_NewClear(KILO * sizeof(M3tTextureMap *)); @@ -885,7 +885,7 @@ static boolean gl_texture_list_add( gl->loaded_texture_array_length= KILO; } } - + if (gl->loaded_texture_array) { if (gl->num_loaded_textures < gl->loaded_texture_array_length) @@ -897,7 +897,7 @@ static boolean gl_texture_list_add( else // need to grow array { M3tTextureMap **temp= (M3tTextureMap **) UUrMemory_Block_NewClear((KILO + gl->loaded_texture_array_length) * sizeof(M3tTextureMap *)); - + if (temp) { UUrMemory_MoveFast(gl->loaded_texture_array, temp, gl->loaded_texture_array_length * sizeof(M3tTextureMap *)); @@ -910,7 +910,7 @@ static boolean gl_texture_list_add( } } } - + if (success) { gl_set_texture_timestamp(texture_map); @@ -926,10 +926,10 @@ static boolean gl_texture_list_remove( { boolean success= FALSE; UUtUns32 i= 0; - + UUmAssert(texture_map); UUmAssert(texture_map->opengl_texture_name); - + while (i < gl->num_loaded_textures) { if (gl->loaded_texture_array[i] == texture_map) @@ -939,7 +939,7 @@ static boolean gl_texture_list_remove( UUtUns32 size= (gl->num_loaded_textures - (i+1)) * sizeof(M3tTextureMap *); M3tTextureMap **src= gl->loaded_texture_array+i+1; M3tTextureMap **dst= gl->loaded_texture_array+i; - + UUrMemory_MoveOverlap(src, dst, size); } --gl->num_loaded_textures; @@ -975,9 +975,9 @@ UUtBool gl_texture_map_create( download_proc= gl_texture_map_download_generic; texture_info= &gl_texel_type_info_table[texture_map->texelType]; - + gl_purge_old_textures_as_needed(); - + switch (texture_info->download_type) { case _gl_pixel_download_S3: @@ -1007,9 +1007,9 @@ UUtBool gl_texture_map_create( success= FALSE; break; } - + mipmap= (texture_map->flags&M3cTextureFlags_HasMipMap) ? TRUE : FALSE; - + // generate opengl name if (texture_map->opengl_texture_name == 0) { @@ -1063,12 +1063,12 @@ UUtBool gl_texture_map_create( } GL_FXN(glTexParameteri)(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - + if (mipmap) { static boolean trilinear_mipmapping_supported= TRUE; - if (trilinear_mipmapping_supported && + if (trilinear_mipmapping_supported && // no trilinear filtering if graphics quality is minimum setting ONrMotoko_GraphicsQuality_SupportTrilinear()) { @@ -1128,10 +1128,10 @@ UUtBool gl_texture_map_create( height= UUmMax(height, 1); } } - + UUmAssert(GL_FXN(glIsTexture)(texture_map->opengl_texture_name) == GL_TRUE); UUmAssert(gl_GetError() == GL_NO_ERROR); - + texture_map->opengl_dirty= FALSE; success= gl_texture_list_add(texture_map); UUmAssert(success); @@ -1171,7 +1171,7 @@ static void gl_texture_map_download_generic( format= GL_RGB; } - error= IMrImage_ConvertPixelType(IMcDitherMode_Off, + error= IMrImage_ConvertPixelType(IMcDitherMode_Off, width, height, IMcNoMipMap, texture_map->texelType, src, new_pixel_type, buffer); UUmAssert(error == UUcError_None); @@ -1216,7 +1216,7 @@ static void gl_texture_map_download_packed_pixels( case IMcPixelType_RGB555: dst_pixel_type = IMcPixelType_RGBA5551; break; - + case IMcPixelType_DXT1: dst_pixel_type = IMcPixelType_RGBA5551; break; @@ -1236,7 +1236,7 @@ static void gl_texture_map_download_packed_pixels( if (dst_pixel_type != texture_map->texelType) { error = IMrImage_ConvertPixelType( - IMcDitherMode_Off, + IMcDitherMode_Off, width, height, IMcNoMipMap, @@ -1257,14 +1257,14 @@ static void gl_texture_map_download_packed_pixels( height, // height 0, // border {?} (GLint) GL_RGBA, // format of the pixel data (GLenum) - texture_info->download_info, // packed format (GLenum) + texture_info->download_info, // packed format (GLenum) tex_image_2d_buffer); { UUtInt32 error_code_test = GL_FXN(glGetError)(); UUtInt32 breakpoint_here = 0; } - + return; } @@ -1290,7 +1290,7 @@ static void gl_texture_map_download_classic( GL_FXN(glTexImage2D)(GL_TEXTURE_2D, level, texture_info->gl_internal_format, // GL format - width, height, 0, texture_info->download_info, + width, height, 0, texture_info->download_info, GL_UNSIGNED_BYTE, src); #ifdef REPORT_ON_COMPRESSION_GL gl_report_compression(texture_map, texture_info, level, width, height); @@ -1342,7 +1342,7 @@ static void gl_texture_map_download_DXT1( } UUmAssert(gl_GetError() == GL_NO_ERROR); - + return; } @@ -1361,7 +1361,7 @@ static boolean gl_enumerate_compressed_texture_formats( boolean compression_algorithm_selected= FALSE; GL_FXN(glGetIntegerv)(GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, num_compressed_texture_formats); - + if ((*num_compressed_texture_formats > 0) && (*num_compressed_texture_formats < num_array_elements)) { @@ -1425,7 +1425,7 @@ static boolean gl_enumerate_compressed_texture_formats( COMPRESS_FORMAT(IMcPixelType_RGB_Bytes, GL_COMPRESSED_RGB_FXT1_3DFX) // never used? COMPRESS_FORMAT(IMcPixelType_RGBA_Bytes, GL_COMPRESSED_RGBA_FXT1_3DFX) // never used? COMPRESS_FORMAT(IMcPixelType_DXT1, GL_COMPRESSED_RGB_FXT1_3DFX) // really a GL_RGB5_A1 - + compression_algorithm_selected= TRUE; */ } @@ -1436,7 +1436,7 @@ static boolean gl_enumerate_compressed_texture_formats( { *num_compressed_texture_formats= 0; } - + return success; } @@ -1528,7 +1528,7 @@ static int gl_texture_bytes( } size= bpp * width * height; - + if (include_mipmaps) { do @@ -1554,7 +1554,7 @@ static void gl_report_compression( if (gl_is_format_compressed(texture_info->gl_internal_format)) { GLint iscompressed, compressed_size; - + GL_FXN(glGetTexLevelParameteriv)(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_ARB, &iscompressed); if (iscompressed) { @@ -1733,7 +1733,7 @@ UUtError gl_texture_map_proc_handler( void *private_data) { M3tTextureMap *texture_map= instance_ptr; - + switch (message) { case TMcTemplateProcMessage_NewPostProcess: @@ -1743,7 +1743,7 @@ UUtError gl_texture_map_proc_handler( texture_map->opengl_dirty= TRUE; break; case TMcTemplateProcMessage_LoadPostProcess: - M3rTextureMap_Prepare(texture_map); + M3rTextureMap_Prepare(texture_map); texture_map->opengl_texture_name= 0; texture_map->opengl_dirty= TRUE; break; @@ -1811,7 +1811,7 @@ void gl_set_textures( constant_alpha_blend= FALSE; } #endif - + // handle blend factors if (texture0) { @@ -1826,7 +1826,7 @@ void gl_set_textures( { UUmAssert(dfactor != NONE); } - else + else { UUmAssert(dfactor == NONE); if (texture1 == NULL) @@ -1878,7 +1878,7 @@ void gl_set_textures( { GL_FXN(glEnable)(GL_TEXTURE_2D); GL_FXN(glBindTexture)(GL_TEXTURE_2D, texture0->opengl_texture_name); - + gl_set_texture_timestamp(texture0); } current_texture0= texture0; @@ -1889,7 +1889,7 @@ void gl_set_textures( // select & activate desired texture unit GL_EXT(glActiveTextureARB)(GL_TEXTURE1_ARB); GL_EXT(glClientActiveTextureARB)(GL_TEXTURE1_ARB); - + if (texture1 == NULL) { GL_FXN(glBindTexture)(GL_TEXTURE_2D, 0); @@ -1917,7 +1917,7 @@ void gl_set_textures( GL_FXN(glEnable)(GL_TEXTURE_2D); GL_FXN(glBindTexture)(GL_TEXTURE_2D, texture1->opengl_texture_name); } - + gl_set_texture_timestamp(texture1); } current_texture1= texture1; @@ -1941,7 +1941,7 @@ void gl_set_textures( } UUmAssert(gl_GetError() == GL_NO_ERROR); - + return; } @@ -1968,8 +1968,8 @@ void gl_sync_to_vtrace( #endif } #endif - - + + UUmAssert(gl_GetError() == GL_NO_ERROR); return; @@ -2010,13 +2010,13 @@ static void gl_setup_nv_combiners_for_env_maps( GL_EXT(glCombinerParameteriNV)(GL_NUM_GENERAL_COMBINERS_NV, 1); // glCombinerInputNV(GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage) // A= reflection map - GL_EXT(glCombinerInputNV)(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB); + GL_EXT(glCombinerInputNV)(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB); // B= base texture alpha - GL_EXT(glCombinerInputNV)(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA); + GL_EXT(glCombinerInputNV)(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA); // C= base texture rgb - GL_EXT(glCombinerInputNV)(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB); + GL_EXT(glCombinerInputNV)(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB); // D= 1 (0 inverted == 1) - GL_EXT(glCombinerInputNV)(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB); + GL_EXT(glCombinerInputNV)(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB); // output: spare0= (reflection map)*(base texture alpha) + (base texture rgb) //glCombinerOutputNV(GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum) // stage portion abOutput cdOutput sumOutput scale bias abDot cdDot muxSum @@ -2143,7 +2143,7 @@ static boolean gl_load_library( #if defined(UUmPlatform) && (UUmPlatform == UUmPlatform_Win32) success= gl_load_opengl_dll(); #endif - + /* this marks the end of standard API functions that are required to run optional extensions are loaded as needed @@ -2237,7 +2237,7 @@ float gl_calculate_fog_factor( world_point= UUrAlignMemory(world_buf); } *world_point= *point; - + MSrTransform_PointListToFrustumScreen(1, world_point, frustum_point, screen_point, &clip_code); if (screen_point->z <= gl->fog_start) { @@ -2261,7 +2261,7 @@ UUtBool gl_voodoo_card_full_screen( void) { UUtBool voodoo_fullscreen= UUcFalse; - + if ((gl != NULL) && (gl->renderer != NULL) && (strstr(gl->renderer, "3Dfx") || strstr(gl->renderer, "3dfx")) && M3gResolutionSwitch) { voodoo_fullscreen= UUcTrue; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/glext.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/glext.h index e557292..23618dd 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/glext.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/OpenGL/glext.h @@ -21,21 +21,21 @@ extern "C" { ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** +** ** http://oss.sgi.com/projects/FreeB -** +** ** Note that, as provided in the License, the Software is distributed on an ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** +** ** Original Code. The Original Code is: OpenGL Sample Implementation, ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. ** Copyright in any portions created by third parties is as indicated ** elsewhere herein. All Rights Reserved. -** +** ** Additional Notice Provisions: This software was created using the ** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has ** not been independently verified as being compliant with the OpenGL(R) diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Bitmap.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Bitmap.c index 812492b..7ef53bd 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Bitmap.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Bitmap.c @@ -1,12 +1,12 @@ /* FILE: MG_DC_Method_Bitmap.c - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: Nov 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997, 1998 */ @@ -34,28 +34,28 @@ RVrDrawContext_Method_Sprite( const M3tTextureCoord *inTextureCoords) // tl, tr, bl, br { TQAVTexture raveVertices[4]; - + UUmAssert(RVgActiveRaveContext != NULL); - + RVmVertex_ConvertTexture(raveVertices[0], inPoints[0], inTextureCoords[0]); RVmVertex_ConvertTexture(raveVertices[1], inPoints[1], inTextureCoords[1]); RVmVertex_ConvertTexture(raveVertices[2], inPoints[2], inTextureCoords[2]); RVmVertex_ConvertTexture(raveVertices[3], inPoints[3], inTextureCoords[3]); - + QADrawTriTexture( RVgActiveRaveContext, raveVertices + 0, raveVertices + 1, raveVertices + 2, kQATriFlags_None); - + QADrawTriTexture( RVgActiveRaveContext, raveVertices + 0, raveVertices + 2, raveVertices + 3, kQATriFlags_None); - + } UUtError @@ -65,4 +65,4 @@ RVrDrawContext_Method_ScreenCapture( { return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Bitmap.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Bitmap.h index 8cc4c60..f0f8fff 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Bitmap.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Bitmap.h @@ -1,12 +1,12 @@ /* FILE: RV_DC_Method_Bitmap.h - + AUTHOR: Brent H. Pease - + CREATED: Nov 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -19,7 +19,7 @@ RVrDrawContext_Method_Sprite( const M3tTextureCoord *inTextureCoords); // tl, tr, bl, br UUtError RVrDrawContext_Method_ScreenCapture( - const UUtRect *inRect, + const UUtRect *inRect, void *outBuffer); #endif /* RV_DC_METHOD_BITMAP_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Frame.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Frame.h index 20ff5a4..a894a98 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Frame.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Frame.h @@ -1,12 +1,12 @@ /* FILE: RV_DC_Method_Frame.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_LinePoint.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_LinePoint.c index b3f20f7..f33582f 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_LinePoint.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_LinePoint.c @@ -4,9 +4,9 @@ AUTHOR: Brent H. Pease CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -27,7 +27,7 @@ RVrDrawContext_Method_Point( } -void +void RVrDrawContext_Method_Line_Interpolate( UUtUns16 inVIndex0, UUtUns16 inVIndex1) @@ -35,7 +35,7 @@ RVrDrawContext_Method_Line_Interpolate( } -void +void RVrDrawContext_Method_Line_Flat( UUtUns16 inVIndex0, UUtUns16 inVIndex1) diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_LinePoint.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_LinePoint.h index 438c8a0..b153822 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_LinePoint.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_LinePoint.h @@ -1,28 +1,28 @@ /* FILE: RV_DC_Method_LinePoint.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef RV_DC_METHOD_LINEPOINT_H #define RV_DC_METHOD_LINEPOINT_H -void +void RVrDrawContext_Method_Point( M3tPointScreen* invCoord); -void +void RVrDrawContext_Method_Line_Interpolate( UUtUns16 inVIndex0, UUtUns16 inVIndex1); -void +void RVrDrawContext_Method_Line_Flat( UUtUns16 inVIndex0, UUtUns16 inVIndex1); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Pent.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Pent.c index 6d19794..4c98f4b 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Pent.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Pent.c @@ -5,8 +5,8 @@ CREATED: Sept 18, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Pent.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Pent.h index 3e3f58c..4abf560 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Pent.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Pent.h @@ -1,12 +1,12 @@ /* FILE: RV_DC_Method_Pent.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Quad.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Quad.c index 50049d3..8be8edf 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Quad.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Quad.c @@ -1,12 +1,12 @@ /* FILE: RV_DC_Method_Quad.c - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997, 1998 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Quad.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Quad.h index 8069d1d..ffb6797 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Quad.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Quad.h @@ -1,12 +1,12 @@ /* FILE: RV_DC_Method_Quad.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Query.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Query.h index 77d55c9..1dfbf8c 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Query.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Query.h @@ -17,4 +17,4 @@ RVrDrawContext_TextureFormatAvailable( IMtPixelType inTexelType); // ====================================================================== -#endif /* RV_DC_METHOD_QUERY_H */ \ No newline at end of file +#endif /* RV_DC_METHOD_QUERY_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_SmallQuad.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_SmallQuad.c index a0cb273..9991e9b 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_SmallQuad.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_SmallQuad.c @@ -1,12 +1,12 @@ /* FILE: RV_DC_Method_SmallQuad.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -23,7 +23,7 @@ // eventually fill these in -void +void RVrDrawContext_Method_SmallQuadGouraudInterpolate( UUtUns32 inIndices) { @@ -34,7 +34,7 @@ RVrDrawContext_Method_SmallQuadGouraudInterpolate( (UUtUns16) (inIndices >> 0) & 0xff); } -void +void RVrDrawContext_Method_SmallQuadGouraudFlat( UUtUns32 inIndices) { @@ -45,7 +45,7 @@ RVrDrawContext_Method_SmallQuadGouraudFlat( (UUtUns16) (inIndices >> 0) & 0xff); } -void +void RVrDrawContext_Method_SmallQuadTextureInterpolate( UUtUns32 inIndices) { @@ -67,7 +67,7 @@ RVrDrawContext_Method_SmallQuadTextureFlat( (UUtUns16) (inIndices >> 0) & 0xff); } -void +void RVrDrawContext_Method_SmallQuadLineFlat( UUtUns32 inIndices) { @@ -76,4 +76,4 @@ RVrDrawContext_Method_SmallQuadLineFlat( (UUtUns16) (inIndices >> 16) & 0xff, (UUtUns16) (inIndices >> 8) & 0xff, (UUtUns16) (inIndices >> 0) & 0xff); -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_SmallQuad.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_SmallQuad.h index c4114ed..0375245 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_SmallQuad.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_SmallQuad.h @@ -1,27 +1,27 @@ /* FILE: RV_DC_Method_SmallQuad.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef RV_DC_METHOD_SMALLQUAD_H #define RV_DC_METHOD_SMALLQUAD_H -void +void RVrDrawContext_Method_SmallQuadGouraudInterpolate( UUtUns32 inIndices); -void +void RVrDrawContext_Method_SmallQuadGouraudFlat( UUtUns32 inIndices); -void +void RVrDrawContext_Method_SmallQuadTextureInterpolate( UUtUns32 inIndices); @@ -29,7 +29,7 @@ void RVrDrawContext_Method_SmallQuadTextureFlat( UUtUns32 inIndices); -void +void RVrDrawContext_Method_SmallQuadLineFlat( UUtUns32 inIndices); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_State.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_State.c index bf3ef58..b93faee 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_State.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_State.c @@ -1,12 +1,12 @@ /* FILE: RV_DC_Method_State.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -38,7 +38,7 @@ UUtInt32 RVrDrawContext_Method_State_GetInt( M3tDrawStateIntType inDrawStateType) { - + return 0; } @@ -54,7 +54,7 @@ void* RVrDrawContext_Method_State_GetPtr( M3tDrawStatePtrType inDrawStateType) { - + return NULL; } @@ -62,7 +62,7 @@ UUtError RVrDrawContext_Method_State_Push( void) { - + return UUcError_None; } @@ -78,7 +78,7 @@ UUtError RVrDrawContext_Method_State_Commit( void) { - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_State.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_State.h index eccea84..8820e1a 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_State.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_State.h @@ -1,12 +1,12 @@ /* FILE: RV_DC_Method_State.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Triangle.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Triangle.c index db6cbdc..d47f5d4 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Triangle.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Triangle.c @@ -1,12 +1,12 @@ /* FILE: RV_DC_Method_Triangle.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Triangle.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Triangle.h index 74b8c1e..d083002 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Triangle.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Method_Triangle.h @@ -1,12 +1,12 @@ /* FILE: RV_DC_Method_Triangle.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Private.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Private.h index 06d1c91..fb7ee46 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DC_Private.h @@ -1,12 +1,12 @@ /* FILE: RV_DrawContext_Private.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 17, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -32,11 +32,11 @@ typedef struct RVtTextureMapPrivate UUtUns32 raveFlags; TQAImagePixelType pixelType; TQAImage image[9]; - + void* convertedData; - + TQATexture* raveTexture; - + } RVtTextureMapPrivate; #define RVcStateStack_MaxDepth 3 @@ -49,9 +49,9 @@ typedef struct RVtDrawContextPrivate UUtUns16 width; UUtUns16 height; - + UUtUns8 stateFlags; - + UUtUns16 stateTOS; void* statePtrStack[RVcStateStack_MaxDepth][M3cDrawStatePtrType_NumTypes]; UUtInt32 stateIntStack[RVcStateStack_MaxDepth][M3cDrawStateIntType_NumTypes]; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DrawEngine_Method.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DrawEngine_Method.c index ee6c1d5..5c6f31d 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DrawEngine_Method.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DrawEngine_Method.c @@ -1,12 +1,12 @@ /* FILE: RV_DrawEngine_Method.c - + AUTHOR: Kevin Armstrong, Michael Evans - + CREATED: January 5, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1998 */ @@ -47,16 +47,16 @@ typedef struct RVtDisplayDevice { TQADevice raveDevice; - + } RVtDisplayDevice; typedef struct RVtEngine { TQAEngine* raveEngine; - + UUtUns16 numDisplayDevices; RVtDisplayDevice displayDevices[RVcMaxDisplayDevices]; - + } RVtEngine; UUtUns16 RVgEngine_Num = 0; @@ -85,7 +85,7 @@ RViDrawEngine_AddDisplayDevice( UUtUns16 engineItr; RVtEngine* targetEngine = NULL; RVtDisplayDevice* targetDisplayDevice; - + for(engineItr = 0; engineItr < RVgEngine_Num; engineItr++) { if(RVgEngine_List[engineItr].raveEngine == inRaveEngine) @@ -94,16 +94,16 @@ RViDrawEngine_AddDisplayDevice( break; } } - + if(targetEngine == NULL) { targetEngine = RVgEngine_List + RVgEngine_Num++; targetEngine->numDisplayDevices = 0; targetEngine->raveEngine = inRaveEngine; } - + targetDisplayDevice = targetEngine->displayDevices + targetEngine->numDisplayDevices++; - + targetDisplayDevice->raveDevice = *inRaveDevice; } @@ -114,26 +114,26 @@ RViDrawEngine_DisplayDeviceList_Build( GDHandle curDevice; TQADevice raveDevice; TQAEngine* curRaveEngine; - + curDevice = GetDeviceList(); - + while(curDevice != NULL) { raveDevice.deviceType = kQADeviceGDevice; raveDevice.device.gDevice = curDevice; - + // loop through all the engines that support this display device curRaveEngine = QADeviceGetFirstEngine(&raveDevice); - + while(curRaveEngine != NULL) { RViDrawEngine_AddDisplayDevice( &raveDevice, curRaveEngine); - + curRaveEngine = QADeviceGetNextEngine(&raveDevice, curRaveEngine); } - + curDevice = GetNextDevice(curDevice); } } @@ -162,34 +162,34 @@ RVrDrawEngine_Method_ContextPrivateNew( UUtUns32 targetEngineIndex; TQARect raveRect; UUtUns16 itr; - + UUmAssert(RVgDrawContextPrivate.activeRaveContext == NULL); UUmAssert(inDrawContextDescriptor->type == M3cDrawContextType_OnScreen); - + *outAPI = M3cDrawAPI_RAVE; // find the right engine targetEngineCaps = M3rDrawEngine_GetCaps(M3gActiveDrawEngine); UUmAssertReadPtr(targetEngineCaps, sizeof(M3tDrawEngineCaps)); - + targetEngineIndex = (UUtUns32)targetEngineCaps->enginePrivate; targetRaveEngine = RVgEngine_List[targetEngineIndex].raveEngine; - + RVgEngine_ActiveIndex = targetEngineIndex; RVgDrawContextPrivate.activeRaveEngine = targetRaveEngine; - + // Setup the context parameters raveRect.top = inDrawContextDescriptor->drawContext.onScreen.rect.top; raveRect.left = inDrawContextDescriptor->drawContext.onScreen.rect.left; raveRect.bottom = inDrawContextDescriptor->drawContext.onScreen.rect.bottom; raveRect.right = inDrawContextDescriptor->drawContext.onScreen.rect.right; - + // setup the width and height RVgDrawContextPrivate.width = raveRect.right - raveRect.left; RVgDrawContextPrivate.height = raveRect.bottom - raveRect.top; - + // create the context - raveError = + raveError = QADrawContextNew( &RVgEngine_List[targetEngineIndex].displayDevices[M3gActiveDisplayDevice].raveDevice, &raveRect, @@ -201,7 +201,7 @@ RVrDrawEngine_Method_ContextPrivateNew( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not create RAVE context"); } - + // init the function parameters RVgDrawContextMethods.frameStart = RVrDrawContext_Method_Frame_Start; RVgDrawContextMethods.frameEnd = RVrDrawContext_Method_Frame_End; @@ -214,22 +214,22 @@ RVrDrawEngine_Method_ContextPrivateNew( RVgDrawContextMethods.sprite = RVrDrawContext_Method_Sprite; RVgDrawContextMethods.screenCapture = RVrDrawContext_Method_ScreenCapture; RVgDrawContextMethods.textureFormatAvailable = RVrDrawContext_TextureFormatAvailable; - + // initialize the state RVgDrawContextPrivate.stateTOS = 0; RVgDrawContextPrivate.statePtr = RVgDrawContextPrivate.statePtrStack[0]; RVgDrawContextPrivate.stateInt = RVgDrawContextPrivate.stateIntStack[0]; - + for(itr = 0; itr < M3cDrawStateIntType_NumTypes; itr++) { RVgDrawContextPrivate.stateInt[itr] = 0; } - + for(itr = 0; itr < M3cDrawStatePtrType_NumTypes; itr++) { RVgDrawContextPrivate.statePtr[itr] = NULL; } - + RVgDrawContextPrivate.stateInt[M3cDrawStateIntType_Appearence] = M3cDrawState_Appearence_Gouraud; RVgDrawContextPrivate.stateInt[M3cDrawStateIntType_Interpolation] = M3cDrawState_Interpolation_None; RVgDrawContextPrivate.stateInt[M3cDrawStateIntType_Fill] = M3cDrawState_Fill_Solid; @@ -237,8 +237,8 @@ RVrDrawEngine_Method_ContextPrivateNew( //RVgDrawContextPrivate->vertexList = MGgDrawContextPrivate->vertexListStack[0]; //RVgDrawContextPrivate->vertexBitVector = MGgDrawContextPrivate->vertexBVStack[0]; RVgDrawContextPrivate.stateFlags = 0xFF; - - + + return UUcError_None; } @@ -247,10 +247,10 @@ RVrDrawEngine_Method_Texture_Init( M3tTextureMap* inTextureMap) { //RVtTextureMapPrivate* privateData = (RVtTextureMapPrivate*)M3rManager_Texture_GetEnginePrivate(inTextureMap); - + //privateData->convertedData = NULL; //privateData->raveTexture = NULL; - + return UUcError_None; } @@ -260,12 +260,12 @@ RVrDrawEngine_Method_Texture_Load( { //TQAError raveError; //RVtTextureMapPrivate* privateData = (RVtTextureMapPrivate*) (M3rManager_Texture_GetEnginePrivate(inTextureMap)); - + //UUmAssert(privateData->raveTexture == NULL); //UUmAssert(RVgDrawContextPrivate.activeRaveEngine != NULL); - + #if 0 - raveError = + raveError = QATextureNew( RVgDrawContextPrivate.activeRaveEngine, privateData->raveFlags, @@ -277,7 +277,7 @@ RVrDrawEngine_Method_Texture_Load( UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not create rave texture"); } #endif - + return UUcError_None; } @@ -291,7 +291,7 @@ RVrDrawEngine_Method_Texture_Unload( UUmAssert(privateData->raveTexture != NULL); QATextureDelete(RVgDrawContextPrivate.activeRaveEngine, privateData->raveTexture); - + privateData->raveTexture = NULL; #endif @@ -306,9 +306,9 @@ RVrDrawEngine_Method_Texture_Update( UUtError error; RVtTextureMapPrivate* privateData = (RVtTextureMapPrivate*) (M3rManager_Texture_GetEnginePrivate(inTextureMap)); IMtPixel emptyPixel = {0}; - + // XXX - need to handle I8 case - + switch(inTextureMap->texelType) { case IMcPixelType_ARGB4444: @@ -316,28 +316,28 @@ RVrDrawEngine_Method_Texture_Update( privateData->image[0].rowBytes = sizeof(UUtUns16) * inTextureMap->width; privateData->image[0].pixmap = inTextureMap->data; break; - + case IMcPixelType_RGB555: privateData->pixelType = kQAPixel_RGB16; privateData->image[0].rowBytes = sizeof(UUtUns16) * inTextureMap->width; privateData->image[0].pixmap = inTextureMap->data; break; - + case IMcPixelType_ARGB1555: privateData->pixelType = kQAPixel_ARGB16; privateData->image[0].rowBytes = sizeof(UUtUns16) * inTextureMap->width; privateData->image[0].pixmap = inTextureMap->data; break; - + case IMcPixelType_I8: // need to convert to RGB16 - perhaps this is supported through ATI RAVE // XXX - Assert this is not mipmapped - + privateData->convertedData = UUrMemory_Block_New(inTextureMap->width * inTextureMap->height * sizeof(UUtUns16)); UUmError_ReturnOnNull(privateData->convertedData); - - error = + + error = IMrImage_ConvertPixelType( IMcDitherMode_On, inTextureMap->width, @@ -348,53 +348,53 @@ RVrDrawEngine_Method_Texture_Update( IMcPixelType_RGB555, privateData->convertedData); UUmError_ReturnOnError(error); - + privateData->pixelType = kQAPixel_RGB16; privateData->image[0].rowBytes = sizeof(UUtUns16) * inTextureMap->width; privateData->image[0].pixmap = privateData->convertedData; break; - + case IMcPixelType_I1: UUmAssert(0); break; - + case IMcPixelType_A8: UUmAssert(0); break; - + case IMcPixelType_A4I4: UUmAssert(0); break; - + case IMcPixelType_ARGB8888: privateData->pixelType = kQAPixel_ARGB32; privateData->image[0].rowBytes = sizeof(UUtUns32) * inTextureMap->width; privateData->image[0].pixmap = inTextureMap->data; break; - + case IMcPixelType_RGB888: privateData->pixelType = kQAPixel_RGB32; privateData->image[0].rowBytes = sizeof(UUtUns32) * inTextureMap->width; privateData->image[0].pixmap = inTextureMap->data; break; - + default: UUmAssert(!"Illegal pixel type"); } - + // create TQAImage privateData->image[0].width = inTextureMap->width; privateData->image[0].height = inTextureMap->width; - + // compute the rave texture flags privateData->raveFlags = kQATexture_NoCompression; - + if(inTextureMap->flags & M3cTextureFlags_HasMipMap) { // privateData->raveFlags |= kQATexture_Mipmap; // eventually build mipmaps } - + if(privateData->raveTexture != NULL) { if(RVgDrawContextPrivate.atiExtFuncs != NULL) @@ -408,7 +408,7 @@ RVrDrawEngine_Method_Texture_Update( RVrDrawEngine_Method_Texture_Load(inTextureMap); } } -#endif +#endif return UUcError_None; } @@ -418,13 +418,13 @@ RVrDrawEngine_Method_Texture_Delete( { #if 0 RVtTextureMapPrivate *privateData = (RVtTextureMapPrivate*) (M3rManager_Texture_GetEnginePrivate(inTextureMap)); - + if(privateData->convertedData != NULL) { UUrMemory_Block_Delete(privateData->convertedData); privateData->convertedData = NULL; } - + if(privateData->raveTexture != NULL) { QATextureDelete(RVgDrawContextPrivate.activeRaveEngine, privateData->raveTexture); @@ -440,30 +440,30 @@ RVrDrawEngine_Initialize( void) { UUtError error; - + M3tDrawEngineCaps drawEngineCaps; M3tDrawEngineMethods drawEngineMethods; - + UUtUns16 engineItr; char buffer[1024]; UUtUns32 nameLength; TQAError raveError; - + RViDrawEngine_DisplayDeviceList_Build(); - + if(RVgEngine_Num == 0) return; - + drawEngineMethods.contextPrivateNew = RVrDrawEngine_Method_ContextPrivateNew; drawEngineMethods.contextPrivateDelete = RVrDrawEngine_Method_ContextPrivateDelete; - + for(engineItr = 0; engineItr < RVgEngine_Num; engineItr++) { drawEngineCaps.engineFlags = M3cDrawEngineFlag_None; drawEngineCaps.enginePrivate = (void*)engineItr; - + UUrString_Copy(drawEngineCaps.engineName, M3cDrawEngine_RAVE, M3cMaxNameLen); - - raveError = + + raveError = QAEngineGestalt( RVgEngine_List[engineItr].raveEngine, kQAGestalt_ASCIINameLength, @@ -473,14 +473,14 @@ RVrDrawEngine_Initialize( UUrError_Report(UUcError_Generic, "could not get name length"); return; } - + if(nameLength >= 1024) { UUrError_Report(UUcError_Generic, "name length too long"); return; } - - raveError = + + raveError = QAEngineGestalt( RVgEngine_List[engineItr].raveEngine, kQAGestalt_ASCIIName, @@ -490,18 +490,18 @@ RVrDrawEngine_Initialize( UUrError_Report(UUcError_Generic, "Could get name length"); return; } - + UUrString_Copy(drawEngineCaps.engineDriver, buffer, M3cMaxNameLen); - + drawEngineCaps.engineVersion = RVcVersion; - + // XXX - Someday make this more real drawEngineCaps.numDisplayDevices = 1; drawEngineCaps.displayDevices[0].numDisplayModes = 1; drawEngineCaps.displayDevices[0].displayModes[0].width = 640; drawEngineCaps.displayDevices[0].displayModes[0].height = 480; drawEngineCaps.displayDevices[0].displayModes[0].bitDepth = 16; - + error = M3rManager_Register_DrawEngine( &drawEngineCaps, @@ -536,14 +536,14 @@ RVrDrawContext_Method_Frame_Start( return UUcError_None; } - + // ---------------------------------------------------------------------- UUtError RVrDrawContext_Method_Frame_End( UUtUns32 *outTextureBytesDownloaded) { QARenderEnd(RVgActiveRaveContext, NULL); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DrawEngine_Method.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DrawEngine_Method.h index 2db547f..6c5775b 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DrawEngine_Method.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DrawEngine_Method.h @@ -1,12 +1,12 @@ /* FILE: RV_DrawEngine_Method.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DrawEngine_Platform.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DrawEngine_Platform.h index 74c951f..31d06f3 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DrawEngine_Platform.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/RAVE/RV_DrawEngine_Platform.h @@ -1,12 +1,12 @@ /* FILE: RV_DrawEngine_Platform.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -21,5 +21,5 @@ RVrDrawEngine_Platform_SetupDrawContextPrivate( void RVrDrawEngine_Platform_DestroyDrawContextPrivate( RVtDrawContextPrivate* inDrawContextPrivate); - + #endif /* RV_DRAWENGINE_PLATFORM_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Bitmap.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Bitmap.c index 6650414..7807499 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Bitmap.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Bitmap.c @@ -1,12 +1,12 @@ /* FILE: MS_DC_Method_Bitmap.c - + AUTHOR: Brent H. Pease - + CREATED: Nov 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -100,7 +100,7 @@ // funcitons // ====================================================================== // ---------------------------------------------------------------------- -void +void MSrDrawContext_Method_Bitmap( M3tDrawContext *inDrawContext, M3tTextureMap *inBitmap, @@ -111,14 +111,14 @@ MSrDrawContext_Method_Bitmap( UUtUns16 inAlpha) /* 0 - 31 */ { UUtUns16 i, j; - + UUtUns16 alpha; UUtUns16 *src_texels, *src_texel; UUtUns32 src_rowtexels; UUtInt16 src_x, src_y; UUtUns16 src; - + UUtUns32 *src_32_texels, *src_32_texel; UUtUns32 src_32_rowtexels; @@ -130,7 +130,7 @@ MSrDrawContext_Method_Bitmap( UUtInt16 clip_left, clip_top, clip_right, clip_bottom; MStDrawContextPrivate *drawContextPrivate; - + // get access to the private context drawContextPrivate = (MStDrawContextPrivate *)inDrawContext->privateContext; if (drawContextPrivate->imageBufferBaseAddr == NULL) @@ -141,25 +141,25 @@ MSrDrawContext_Method_Bitmap( clip_top = 0; clip_right = (UUtUns16)drawContextPrivate->width; clip_bottom = (UUtUns16)drawContextPrivate->height; - + // if nothing is going to be drawn, exit now if (clip_left >= clip_right) return; if (clip_top >= clip_bottom) return; - + // set dst_x and dst_y dst_x = (UUtInt16)inDestPoint->x; dst_y = (UUtInt16)inDestPoint->y; - + // set src_x and src_y src_x = 0; src_y = 0; - + // set draw_width and draw_height draw_width = inWidth;//inBitmap->width; draw_height = inHeight;//inBitmap->height; - + if ((dst_x + draw_width) > clip_right) draw_width = clip_right - dst_x; if (dst_x < clip_left) @@ -176,15 +176,15 @@ MSrDrawContext_Method_Bitmap( dst_y = clip_top; draw_height -= src_y; } - + // get the rowpixels and a pointer to the dst pixels dst_rowtexels = drawContextPrivate->imageBufferRowBytes >> 1; dst_texels = drawContextPrivate->imageBufferBaseAddr + dst_x + (dst_y * dst_rowtexels); - - + + switch (inBitmap->texelType) { case M3cTextureType_ARGB4444: @@ -205,7 +205,7 @@ MSrDrawContext_Method_Bitmap( { dst_texel = dst_texels; src_texel = src_texels; - + for (j = 0; j < draw_width; j++) { alpha = CalcAlpha(*src_texel, inAlpha); @@ -217,13 +217,13 @@ MSrDrawContext_Method_Bitmap( src_texels += src_rowtexels; } break; - + case M3cTextureType_RGB555: for (i = 0; i < draw_height; i++) { dst_texel = dst_texels; src_texel = src_texels; - + for (j = 0; j < draw_width; j++) { *dst_texel = Mix555(*src_texel, *dst_texel, inAlpha); @@ -234,13 +234,13 @@ MSrDrawContext_Method_Bitmap( src_texels += src_rowtexels; } break; - + case M3cTextureType_ARGB1555: for (i = 0; i < draw_height; i++) { dst_texel = dst_texels; src_texel = src_texels; - + for (j = 0; j < draw_width; j++) { if (*src_texel & cAlphaBit1555) @@ -254,7 +254,7 @@ MSrDrawContext_Method_Bitmap( break; } break; - + case M3cTextureType_ARGB8888: // get a pointer to the source pixels src_32_rowtexels = inBitmap->rowBytes >> 2; @@ -262,12 +262,12 @@ MSrDrawContext_Method_Bitmap( ((UUtUns32*)inBitmap->data) + src_x + (src_y * src_32_rowtexels); - + for (i = 0; i < draw_height; i++) { dst_texel = dst_texels; src_32_texel = src_32_texels; - + for (j = 0; j < draw_width; j++) { src = (UUtUns16)M3mARGB32_to_16(*src_32_texel); @@ -280,7 +280,7 @@ MSrDrawContext_Method_Bitmap( src_32_texels += src_32_rowtexels; } break; - + default: UUmAssert(!"Unknown TexelType"); break; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Bitmap.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Bitmap.h index 62a1042..0e87f6d 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Bitmap.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Bitmap.h @@ -1,12 +1,12 @@ /* FILE: MS_DC_Method_Bitmap.h - + AUTHOR: Brent H. Pease - + CREATED: Nov 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -23,4 +23,4 @@ MSrDrawContext_Method_Bitmap( UUtUns16 inShade, UUtUns16 inAlpha); /* 0 - 31 */ -#endif /* MS_DC_METHOD_BITMAP_H */ \ No newline at end of file +#endif /* MS_DC_METHOD_BITMAP_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Frame.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Frame.h index dc78414..4324d5e 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Frame.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Frame.h @@ -1,12 +1,12 @@ /* FILE: MS_DC_Method_Frame.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_LinePoint.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_LinePoint.c index 88aa90a..fbb39d6 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_LinePoint.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_LinePoint.c @@ -4,9 +4,9 @@ AUTHOR: Brent H. Pease CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -32,37 +32,37 @@ MSrDrawContext_Method_Point( UUtUns32 targetZ; UUtUns16 *targetZPtr, *targetRGBPtr; MStDrawContextPrivate *drawContextPrivate = (MStDrawContextPrivate *)inDrawContext->privateContext; - + UUmAssert(invCoord->y >= 0.0 && invCoord->y < (float)drawContextPrivate->height); UUmAssert(invCoord->x >= 0.0 && invCoord->x < (float)drawContextPrivate->width); UUmAssert(invCoord->z >= 0.0 && invCoord->z <= 1.0); - + x = (UUtInt32)invCoord->x; y = (UUtInt32)invCoord->y; z = (UUtInt32)invCoord->z * MSmULongScale; - + //y = drawContext->height - y; - + targetZPtr = (UUtUns16 *)((char *)drawContextPrivate->zBufferBaseAddr + - y * drawContextPrivate->zBufferRowBytes + + y * drawContextPrivate->zBufferRowBytes + x * 2); - + targetZ = *targetZPtr << 16; - + if(z < targetZ) { *targetZPtr = (UUtUns16)(z >> 16); - + targetRGBPtr = (UUtUns16 *)((char *)drawContextPrivate->imageBufferBaseAddr + - y * drawContextPrivate->imageBufferRowBytes + + y * drawContextPrivate->imageBufferRowBytes + x * 2); - + *targetRGBPtr = inVShade; - + } } -void +void MSrDrawContext_Method_Line_Interpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -88,10 +88,10 @@ MSrDrawContext_Method_Line_Interpolate( long zRowBytes; float x0, y0, x1, y1; float dx, dy, fabs_dx, fabs_dy; - + M3tPointScreen *vCoordStart, *vCoordEnd; UUtUns16 vShadeStart, vShadeEnd; - + long major, minor; char *rgbAddress; char *zAddress; @@ -103,24 +103,24 @@ MSrDrawContext_Method_Line_Interpolate( float height = (float) drawContextPrivate->height; float width = (float) drawContextPrivate->width; - + M3tPointScreen* screenPoints; M3tPointScreen* vCoord0; M3tPointScreen* vCoord1; - + UUtUns16* vertexShades; UUtUns16 vShade0; UUtUns16 vShade1; - + screenPoints = drawContextPrivate->arrayData[M3cDrawArrayType_ScreenPoint]; vertexShades = (UUtUns16*)drawContextPrivate->arrayData[M3cDrawArrayType_ScreenShade_DC]; - + vCoord0 = screenPoints + inVIndex0; vCoord1 = screenPoints + inVIndex1; - + vShade0 = vertexShades[inVIndex0]; vShade1 = vertexShades[inVIndex1]; - + x0 = vCoord0->x; x1 = vCoord1->x; y0 = vCoord0->y; @@ -132,7 +132,7 @@ MSrDrawContext_Method_Line_Interpolate( * It appears that this functions requires clipped lines, I am adding assertions * */ - + UUmAssert(x0 >= 0.0); UUmAssert(x1 >= 0.0); UUmAssert(y0 >= 0.0); @@ -145,7 +145,7 @@ MSrDrawContext_Method_Line_Interpolate( dx = x1 - x0; dy = y1 - y0; - + rgbPixelBytes = M3cDrawRGBBytesPerPixel; zPixelBytes = M3cDrawZBytesPerPixel; @@ -154,18 +154,18 @@ MSrDrawContext_Method_Line_Interpolate( rgbRowBytes = drawContextPrivate->imageBufferRowBytes; zRowBytes = drawContextPrivate->zBufferRowBytes; - + if (fabs_dx > fabs_dy) { /* * Δx is larger, so the major axis will be X. */ - + rgbMajorIncrement = rgbPixelBytes; zMajorIncrement = zPixelBytes; rgbMinorIncrement = rgbRowBytes; zMinorIncrement = zRowBytes; - + if (dx > 0.0F) { vCoordStart = vCoord0; @@ -195,12 +195,12 @@ MSrDrawContext_Method_Line_Interpolate( /* * Δy is larger, so the major axis will be Y. */ - + rgbMajorIncrement = rgbRowBytes; zMajorIncrement = zRowBytes; rgbMinorIncrement = rgbPixelBytes; zMinorIncrement = zPixelBytes; - + if (dy > 0.0F) { vCoordStart = vCoord0; @@ -225,19 +225,19 @@ MSrDrawContext_Method_Line_Interpolate( } fabsMajorDelta = fabs_dy; } - + /* * Snap major axis endpoints, including a 0.5 pixel subpixel coverage rule. */ - + majorStartSnapped = (UUtInt32)(majorStart + 0.5F); - + /* Avoid Divide by zero error */ if(fabsMajorDelta == 0.0F) { return; } - + invLength = 1.0F / fabsMajorDelta; snapCorrection = (majorStartSnapped + 0.5F) - majorStart; tempEnd = majorEnd - 0.5F; @@ -249,7 +249,7 @@ MSrDrawContext_Method_Line_Interpolate( * reasons -- if we continue, the cast of fTemp to an int will produce * 0, which isn't correct. */ - + return; } majorEndSnapped = (UUtInt32)tempEnd; @@ -259,17 +259,17 @@ MSrDrawContext_Method_Line_Interpolate( * initial value. This isn't really necessary if kQAZFunction_None is set, but testing * for that isn't really worth while. */ - + { const float zScale = (float)MSmULongScale; const float zOffset = (float)MSmULongOffset; - + tempStart = vCoordStart->z * zScale + zOffset; tempEnd = vCoordEnd->z * zScale + zOffset; dTemp = (tempEnd - tempStart) * invLength; z = (UUtUns32)(tempStart + snapCorrection * dTemp); dZ = (long) dTemp; - + } tempStart = vShadeStart->r * charScale; @@ -277,33 +277,33 @@ MSrDrawContext_Method_Line_Interpolate( dTemp = (tempEnd - tempStart) * invLength; rScaled = (UUtInt32)tempStart; dRScaled = (UUtInt32)dTemp; - + tempStart = vShadeStart->g * charScale; tempEnd = vShadeEnd->g * charScale; dTemp = (tempEnd - tempStart) * invLength; gScaled = (UUtInt32)tempStart; dGScaled = (UUtInt32)dTemp; - + tempStart = vShadeStart->b * charScale; tempEnd = vShadeEnd->b * charScale; dTemp = (tempEnd - tempStart) * invLength; bScaled = (UUtInt32)tempStart; dBScaled = (UUtInt32)dTemp; - + /* * Determine the initial minor axis value, the minor axis delta per major axis pixel, * and whether the minor axis will increment or decrement as we move along the major axis. */ - + minorScaled = (UUtInt32)(minorStart * (float)MSmFractOne); dMinorScaled = (UUtInt32)(minorDelta * invLength * (float)MSmFractOne); - + if (minorDelta < 0.0F) { /* * Minor axis decrements, so negate the rgb/zMinorIncrement values. */ - + rgbMinorIncrement = -rgbMinorIncrement; zMinorIncrement = -zMinorIncrement; } @@ -311,10 +311,10 @@ MSrDrawContext_Method_Line_Interpolate( major = majorStartSnapped; minor = minorScaled >> MSmFractBits; minorScaled &= fractMask; - + rgbAddress = (char *)drawContextPrivate->imageBufferBaseAddr + major * rgbMajorIncrement + minor * abs (rgbMinorIncrement); - + zAddress = (char *)drawContextPrivate->zBufferBaseAddr + major * zMajorIncrement + minor * abs (zMinorIncrement); @@ -322,11 +322,11 @@ MSrDrawContext_Method_Line_Interpolate( { zPixel = *((unsigned short *) zAddress); zPixel = zPixel | (zPixel << 16); - + if (z < zPixel) { long rDithered, gDithered, bDithered; - + rDithered = rScaled >> MSmFractBits; gDithered = gScaled >> MSmFractBits; bDithered = bScaled >> MSmFractBits; @@ -338,7 +338,7 @@ MSrDrawContext_Method_Line_Interpolate( | ((gScaled >> (MSmFractBits + 3)) << 5) | (bScaled >> (MSmFractBits + 3))); } - + zAddress += zMajorIncrement; z += dZ; minorScaled += dMinorScaled; @@ -357,7 +357,7 @@ MSrDrawContext_Method_Line_Interpolate( } -void +void MSrDrawContext_Method_Line_Flat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -380,9 +380,9 @@ MSrDrawContext_Method_Line_Flat( long zRowBytes; float x0, y0, x1, y1; float dx, dy, fabs_dx, fabs_dy; - + M3tPointScreen *vCoordStart, *vCoordEnd; - + long major, minor; char *rgbAddress; char *zAddress; @@ -398,9 +398,9 @@ MSrDrawContext_Method_Line_Flat( M3tPointScreen* screenPoints; M3tPointScreen* vCoord0; M3tPointScreen* vCoord1; - + screenPoints = drawContextPrivate->statePtr[M3cDrawStatePtrType_ScreenPointArray]; - + vCoord0 = screenPoints + inVIndex0; vCoord1 = screenPoints + inVIndex1; @@ -415,7 +415,7 @@ MSrDrawContext_Method_Line_Flat( * It appears that this functions requires clipped lines, I am adding assertions * */ - + UUmAssert(x0 >= 0.0); UUmAssert(x1 >= 0.0); UUmAssert(y0 >= 0.0); @@ -424,7 +424,7 @@ MSrDrawContext_Method_Line_Flat( UUmAssert(vCoord1->z >= 0.0); UUmAssert(vCoord0->z <= 1.0); UUmAssert(vCoord1->z <= 1.0); - + UUmAssert(x0 < width); UUmAssert(x1 < width); UUmAssert(y0 < height); @@ -438,7 +438,7 @@ MSrDrawContext_Method_Line_Flat( dx = x1 - x0; dy = y1 - y0; - + rgbPixelBytes = M3cDrawRGBBytesPerPixel; zPixelBytes = M3cDrawZBytesPerPixel; @@ -447,18 +447,18 @@ MSrDrawContext_Method_Line_Flat( rgbRowBytes = drawContextPrivate->imageBufferRowBytes; zRowBytes = drawContextPrivate->zBufferRowBytes; - + if (fabs_dx > fabs_dy) { /* * Δx is larger, so the major axis will be X. */ - + rgbMajorIncrement = rgbPixelBytes; zMajorIncrement = zPixelBytes; rgbMinorIncrement = rgbRowBytes; zMinorIncrement = zRowBytes; - + if (dx > 0.0F) { vCoordStart = vCoord0; @@ -484,12 +484,12 @@ MSrDrawContext_Method_Line_Flat( /* * Δy is larger, so the major axis will be Y. */ - + rgbMajorIncrement = rgbRowBytes; zMajorIncrement = zRowBytes; rgbMinorIncrement = rgbPixelBytes; zMinorIncrement = zPixelBytes; - + if (dy > 0.0F) { vCoordStart = vCoord0; @@ -510,19 +510,19 @@ MSrDrawContext_Method_Line_Flat( } fabsMajorDelta = fabs_dy; } - + /* * Snap major axis endpoints, including a 0.5 pixel subpixel coverage rule. */ - + majorStartSnapped = (UUtInt32)(majorStart + 0.5F); - + /* Avoid Divide by zero error */ if(fabsMajorDelta == 0.0F) { return; } - + invLength = 1.0F / fabsMajorDelta; snapCorrection = (majorStartSnapped + 0.5F) - majorStart; tempEnd = majorEnd - 0.5F; @@ -534,7 +534,7 @@ MSrDrawContext_Method_Line_Flat( * reasons -- if we continue, the cast of fTemp to an int will produce * 0, which isn't correct. */ - + return; } majorEndSnapped = (UUtInt32)tempEnd; @@ -544,33 +544,33 @@ MSrDrawContext_Method_Line_Flat( * initial value. This isn't really necessary if kQAZFunction_None is set, but testing * for that isn't really worth while. */ - + { const float zScale = (float)MSmULongScale; const float zOffset = (float)MSmULongOffset; - + tempStart = vCoordStart->z * zScale + zOffset; tempEnd = vCoordEnd->z * zScale + zOffset; dTemp = (tempEnd - tempStart) * invLength; z = (UUtUns32)(tempStart + snapCorrection * dTemp); dZ = (long) dTemp; - + } /* * Determine the initial minor axis value, the minor axis delta per major axis pixel, * and whether the minor axis will increment or decrement as we move along the major axis. */ - + minorScaled = (UUtInt32)(minorStart * (float)MSmFractOne); dMinorScaled = (UUtInt32)(minorDelta * invLength * (float)MSmFractOne); - + if (minorDelta < 0.0F) { /* * Minor axis decrements, so negate the rgb/zMinorIncrement values. */ - + rgbMinorIncrement = -rgbMinorIncrement; zMinorIncrement = -zMinorIncrement; } @@ -578,10 +578,10 @@ MSrDrawContext_Method_Line_Flat( major = majorStartSnapped; minor = minorScaled >> MSmFractBits; minorScaled &= fractMask; - + rgbAddress = (char *)drawContextPrivate->imageBufferBaseAddr + major * rgbMajorIncrement + minor * abs (rgbMinorIncrement); - + zAddress = (char *)drawContextPrivate->zBufferBaseAddr + major * zMajorIncrement + minor * abs (zMinorIncrement); @@ -589,7 +589,7 @@ MSrDrawContext_Method_Line_Flat( { zPixel = *((unsigned short *) zAddress); zPixel = zPixel | (zPixel << 16); - + if (z < zPixel) { @@ -597,7 +597,7 @@ MSrDrawContext_Method_Line_Flat( *((UUtUns16 *) rgbAddress) = inShade; } - + zAddress += zMajorIncrement; z += dZ; minorScaled += dMinorScaled; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_LinePoint.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_LinePoint.h index 0c649c7..07fa2ad 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_LinePoint.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_LinePoint.h @@ -1,31 +1,31 @@ /* FILE: MS_DC_Method_LinePoint.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MS_DC_METHOD_LINEPOINT_H #define MS_DC_METHOD_LINEPOINT_H -void +void MSrDrawContext_Method_Point( M3tDrawContext* inDrawContext, M3tPointScreen* invCoord, UUtUns16 inVShade); -void +void MSrDrawContext_Method_Line_Interpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, UUtUns16 inVIndex1); -void +void MSrDrawContext_Method_Line_Flat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Pent.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Pent.c index b84fc43..cae79ae 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Pent.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Pent.c @@ -5,8 +5,8 @@ CREATED: Sept 18, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ @@ -20,7 +20,7 @@ #include "MS_DC_Method_Triangle.h" #include "MS_DC_Method_Pent.h" -void +void MSrDrawContext_Method_PentGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -47,7 +47,7 @@ MSrDrawContext_Method_PentGouraudInterpolate( } -void +void MSrDrawContext_Method_PentGouraudFlat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -78,7 +78,7 @@ MSrDrawContext_Method_PentGouraudFlat( } -void +void MSrDrawContext_Method_PentTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Pent.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Pent.h index 7cca53f..25f32b0 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Pent.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Pent.h @@ -1,19 +1,19 @@ /* FILE: MS_DC_Method_Pent.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MS_DC_METHOD_PENT_H #define MS_DC_METHOD_PENT_H -void +void MSrDrawContext_Method_PentGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -22,7 +22,7 @@ MSrDrawContext_Method_PentGouraudInterpolate( UUtUns16 inVIndex3, UUtUns16 inVIndex4); -void +void MSrDrawContext_Method_PentGouraudFlat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -32,7 +32,7 @@ MSrDrawContext_Method_PentGouraudFlat( UUtUns16 inVIndex4, UUtUns16 inFaceShade); -void +void MSrDrawContext_Method_PentTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Quad.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Quad.c index a912504..780acc1 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Quad.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Quad.c @@ -1,12 +1,12 @@ /* FILE: MS_DC_Method_Quad.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -20,7 +20,7 @@ #include "MS_DC_Method_Triangle.h" #include "MS_DC_Method_Quad.h" -void +void MSrDrawContext_Method_QuadGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -40,7 +40,7 @@ MSrDrawContext_Method_QuadGouraudInterpolate( inVIndex3); } -void +void MSrDrawContext_Method_QuadGouraudFlat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -64,7 +64,7 @@ MSrDrawContext_Method_QuadGouraudFlat( } -void +void MSrDrawContext_Method_QuadTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Quad.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Quad.h index 5ea2c4e..254ffae 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Quad.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Quad.h @@ -1,19 +1,19 @@ /* FILE: MS_DC_Method_Quad.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MS_DC_METHOD_QUAD_H #define MS_DC_METHOD_QUAD_H -void +void MSrDrawContext_Method_QuadGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -21,7 +21,7 @@ MSrDrawContext_Method_QuadGouraudInterpolate( UUtUns16 inVIndex2, UUtUns16 inVIndex3); -void +void MSrDrawContext_Method_QuadGouraudFlat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -30,7 +30,7 @@ MSrDrawContext_Method_QuadGouraudFlat( UUtUns16 inVIndex3, UUtUns16 inFaceShade); -void +void MSrDrawContext_Method_QuadTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Query.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Query.c index cd67140..2f2ca59 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Query.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Query.c @@ -24,12 +24,12 @@ MSrDrawContext_TextureFormatAvailable( case M3cTextureType_ARGB8888: return UUcTrue; break; - + default: return UUcFalse; break; } - + return UUcFalse; } @@ -40,7 +40,7 @@ MSrDrawContext_GetWidth( { MStDrawContextPrivate *drawContextPrivate; drawContextPrivate = (MStDrawContextPrivate *)inDrawContext->privateContext; - + return (UUtUns16)drawContextPrivate->width; } @@ -51,7 +51,7 @@ MSrDrawContext_GetHeight( { MStDrawContextPrivate *drawContextPrivate; drawContextPrivate = (MStDrawContextPrivate *)inDrawContext->privateContext; - + return (UUtUns16)drawContextPrivate->height; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Query.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Query.h index 6ae94b2..0e8a71b 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Query.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Query.h @@ -23,6 +23,6 @@ MSrDrawContext_GetWidth( UUtUns16 MSrDrawContext_GetHeight( M3tDrawContext *inDrawContext); - + // ====================================================================== -#endif /* MS_DC_METHOD_QUERY_H */ \ No newline at end of file +#endif /* MS_DC_METHOD_QUERY_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_SmallQuad.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_SmallQuad.c index 87c2d15..55fbc97 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_SmallQuad.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_SmallQuad.c @@ -1,12 +1,12 @@ /* FILE: MS_DC_Method_SmallQuad.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -20,7 +20,7 @@ #include "MS_DC_Method_Triangle.h" #include "MS_DC_Method_SmallQuad.h" -void +void MSrDrawContext_Method_SmallQuadGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns32 inIndices) @@ -37,7 +37,7 @@ MSrDrawContext_Method_SmallQuadGouraudInterpolate( (UUtUns16)(inIndices & 0xFF)); } -void +void MSrDrawContext_Method_SmallQuadGouraudFlat( M3tDrawContext* inDrawContext, UUtUns32 inIndices, @@ -57,7 +57,7 @@ MSrDrawContext_Method_SmallQuadGouraudFlat( inFaceShade); } -void +void MSrDrawContext_Method_SmallQuadTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns32 inIndices) diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_SmallQuad.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_SmallQuad.h index 5c4137f..77a22bb 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_SmallQuad.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_SmallQuad.h @@ -1,30 +1,30 @@ /* FILE: MS_DC_Method_SmallQuad.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MS_DC_METHOD_SMALLQUAD_H #define MS_DC_METHOD_SMALLQUAD_H -void +void MSrDrawContext_Method_SmallQuadGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns32 inIndices); -void +void MSrDrawContext_Method_SmallQuadGouraudFlat( M3tDrawContext* inDrawContext, UUtUns32 inIndices, UUtUns16 inFaceShade); -void +void MSrDrawContext_Method_SmallQuadTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns32 inIndices); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_State.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_State.c index 35f3bd8..c02b96c 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_State.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_State.c @@ -1,12 +1,12 @@ /* FILE: MS_DC_Method_State.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -32,14 +32,14 @@ MSrDrawContext_Method_State_SetInt( { MStDrawContextPrivate *drawContextPrivate = (MStDrawContextPrivate *)inDrawContext->privateContext; M3tDrawContextMethod method; - + if(drawContextPrivate->stateInt[inDrawStateType] == inDrawState) { return; } - + drawContextPrivate->stateInt[inDrawStateType] = inDrawState; - + if(inDrawStateType == M3cDrawStateIntType_Appearence) { switch((M3tDrawStateAppearence)inDrawState) @@ -50,50 +50,50 @@ MSrDrawContext_Method_State_SetInt( inDrawContext, M3cDrawContextMethodType_TriInterpolate, method); - + method.triFlat = MSrDrawContext_Method_TriGouraudFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_TriFlat, method); - + method.quadInterpolate = MSrDrawContext_Method_QuadGouraudInterpolate; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_QuadInterpolate, method); - + method.quadFlat = MSrDrawContext_Method_QuadGouraudFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_QuadFlat, method); - + method.smallQuadInterpolate = MSrDrawContext_Method_SmallQuadGouraudInterpolate; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_SmallQuadInterpolate, method); - + method.smallQuadFlat = MSrDrawContext_Method_SmallQuadGouraudFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_SmallQuadFlat, method); - + method.pentInterpolate = MSrDrawContext_Method_PentGouraudInterpolate; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_PentInterpolate, method); - + method.pentFlat = MSrDrawContext_Method_PentGouraudFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_PentFlat, method); break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: method.triInterpolate = MSrDrawContext_Method_TriTextureInterpolate; @@ -101,50 +101,50 @@ MSrDrawContext_Method_State_SetInt( inDrawContext, M3cDrawContextMethodType_TriInterpolate, method); - + method.triFlat = MSrDrawContext_Method_TriTextureFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_TriFlat, method); - + method.quadInterpolate = MSrDrawContext_Method_QuadTextureInterpolate; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_QuadInterpolate, method); - + method.quadFlat = MSrDrawContext_Method_QuadTextureFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_QuadFlat, method); - + method.smallQuadInterpolate = MSrDrawContext_Method_SmallQuadTextureInterpolate; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_SmallQuadInterpolate, method); - + method.smallQuadFlat = MSrDrawContext_Method_SmallQuadTextureFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_SmallQuadFlat, method); - + method.pentInterpolate = MSrDrawContext_Method_PentTextureInterpolate; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_PentInterpolate, method); - + method.pentFlat = MSrDrawContext_Method_PentTextureFlat; M3rManager_SetDrawContextFunc( inDrawContext, M3cDrawContextMethodType_PentFlat, method); break; - + default: UUmAssert(!"Unkown appearence type"); } @@ -157,7 +157,7 @@ MSrDrawContext_Method_State_GetInt( M3tDrawStateIntType inDrawStateType) { MStDrawContextPrivate *drawContextPrivate = (MStDrawContextPrivate *)inDrawContext->privateContext; - + return drawContextPrivate->stateInt[inDrawStateType]; } @@ -170,7 +170,7 @@ MSrDrawContext_Method_State_SetPtr( MStDrawContextPrivate *drawContextPrivate = (MStDrawContextPrivate *)inDrawContext->privateContext; drawContextPrivate->statePtr[inDrawStateType] = inDrawState; - + if(inDrawStateType == M3cDrawStatePtrType_BaseTextureMap) { M3rManager_Texture_EnsureAvailable((M3tTextureMap*)inDrawState); @@ -183,6 +183,6 @@ MSrDrawContext_Method_State_GetPtr( M3tDrawStatePtrType inDrawStateType) { MStDrawContextPrivate *drawContextPrivate = (MStDrawContextPrivate *)inDrawContext->privateContext; - + return drawContextPrivate->statePtr[inDrawStateType]; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_State.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_State.h index ea698fe..6823e40 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_State.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_State.h @@ -1,12 +1,12 @@ /* FILE: MS_DC_Method_State.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Triangle.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Triangle.c index 0c2602f..823c7be 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Triangle.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Triangle.c @@ -1,12 +1,12 @@ /* FILE: MS_DC_Method_Triangle.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Triangle.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Triangle.h index 5339e05..9435f2c 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Triangle.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Method_Triangle.h @@ -1,26 +1,26 @@ /* FILE: MS_DC_Method_Triangle.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ #ifndef MS_DC_METHOD_TRIANGLE_H #define MS_DC_METHOD_TRIANGLE_H -void +void MSrDrawContext_Method_TriGouraudInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, UUtUns16 inVIndex1, UUtUns16 inVIndex2); -void +void MSrDrawContext_Method_TriGouraudFlat( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, @@ -28,7 +28,7 @@ MSrDrawContext_Method_TriGouraudFlat( UUtUns16 inVIndex2, UUtUns16 inFaceShade); -void +void MSrDrawContext_Method_TriTextureInterpolate( M3tDrawContext* inDrawContext, UUtUns16 inVIndex0, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Private.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Private.h index 28dddde..8b9eb09 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DC_Private.h @@ -1,12 +1,12 @@ /* FILE: MS_DrawContext_Private.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 17, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -20,33 +20,33 @@ typedef void (*MStBufferProcPtr)( struct MtDrawContext *drawContext); - + typedef struct MStPlatformSpecific { - + UUtUns16 *frontImageBaseAddr; UUtInt32 frontImageRowBytes; - + void *realImageBufferMemory; MStBufferProcPtr zBufferClearProc; MStBufferProcPtr imageBufferClearProc; MStBufferProcPtr imageBufferCopyProc; MStBufferProcPtr imageBufferCopyAndClearProc; - + void *zBufferClearProcMemory; void *imageBufferClearProcMemory; void *imageBufferCopyProcMemory; void *imageBufferCopyAndClearProcMemory; - + UUtUns32 imageClearValue0; UUtUns32 imageClearValue1; - + void *realZBufferMemory; UUtUns32 zClearValue0; UUtUns32 zClearValue1; - + } MStPlatformSpecific; #elif UUmPlatform == UUmPlatform_Win32 @@ -54,7 +54,7 @@ typedef struct MStPlatformSpecific { LPDIRECTDRAW dd; - + LPDIRECTDRAWSURFACE frontBuffer; LPDIRECTDRAWSURFACE backBuffer; LPDIRECTDRAWSURFACE zBuffer; @@ -62,10 +62,10 @@ RECT rect; DWORD top; DWORD left; - + UUtUns32 imageClearValue0; UUtUns32 imageClearValue1; - + UUtUns32 zClearValue0; UUtUns32 zClearValue1; @@ -84,10 +84,10 @@ typedef struct MStDrawContextPrivate long height; M3tDrawContextType contextType; - + /* Platform specific struct */ MStPlatformSpecific platformSpecific; - + /* Rasterization stuff */ UUtUns16 *imageBufferBaseAddr; UUtUns16 *zBufferBaseAddr; @@ -96,18 +96,18 @@ typedef struct MStDrawContextPrivate UUtUns16 imageBufferRowBytes; UUtUns16 zBufferRowBytes; UUtUns16 pixelTouchRowBytes; - + /* Array data */ void* statePtr[M3cDrawStatePtrType_NumTypes]; UUtInt32 stateInt[M3cDrawStateIntType_NumTypes]; - + } MStDrawContextPrivate; typedef struct MStTextureMapPrivate { UUtUns16 nWidthBits; UUtUns16 nHeightBits; - + } MStTextureMapPrivate; #endif /* MS_DRAWCONTEXT_PRIVATE_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DrawEngine_Method.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DrawEngine_Method.c index 44b36c9..fbc57d5 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DrawEngine_Method.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DrawEngine_Method.c @@ -1,12 +1,12 @@ /* FILE: MS_DrawEngine_Method.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -43,40 +43,40 @@ MSrDrawEngine_Texture_TemplateHandler( M3tTextureMap* textureMap; MStTextureMapPrivate* privateData; UUtUns16 widthNBits, heightNBits; - + textureMap = (M3tTextureMap*)(inDataPtr); privateData = (MStTextureMapPrivate*)(TMmInstance_GetDynamicData(inDataPtr)); - + switch(inMessage) { case TMcTemplateProcMessage_NewPostProcess: case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_LoadPostProcess: case TMcTemplateProcMessage_Update: - + if(textureMap->numLongs > 1) { widthNBits = heightNBits = 15; - + while(!(textureMap->width & (1 << widthNBits))) widthNBits--; while(!(textureMap->height & (1 << heightNBits))) heightNBits--; - + UUmAssert(textureMap->width == 1 << widthNBits); UUmAssert(textureMap->height == 1 << heightNBits); - + privateData->nWidthBits = widthNBits; privateData->nHeightBits = heightNBits; } break; - + default: UUmAssert(!"Unkown message"); } - + return UUcError_None; - + } static void @@ -86,7 +86,7 @@ MSrDrawEngine_Method_ContextPrivateDelete( MStDrawContextPrivate* contextPrivate = (MStDrawContextPrivate *)inDrawContextPrivate; MSrDrawEngine_Platform_DestroyDrawContextPrivate(contextPrivate); - + UUrMemory_Block_Delete(inDrawContextPrivate); } @@ -100,12 +100,12 @@ MSrDrawEngine_Method_ContextPrivateNew( UUtError errorCode; MStDrawContextPrivate* newDrawContextPrivate; UUtUns16 i; - + *outDrawContextPrivate = NULL; *outAPI = M3cDrawAPI_Software; newDrawContextPrivate = UUrMemory_Block_New(sizeof(MStDrawContextPrivate)); - + if(newDrawContextPrivate == NULL) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not allocated private draw context"); @@ -113,7 +113,7 @@ MSrDrawEngine_Method_ContextPrivateNew( newDrawContextPrivate->contextType = inDrawContextDescriptor->type; - + if(inDrawContextDescriptor->type == M3cDrawContextType_OnScreen) { newDrawContextPrivate->screenFlags = inDrawContextDescriptor->drawContext.onScreen.flags; @@ -122,10 +122,10 @@ MSrDrawEngine_Method_ContextPrivateNew( { newDrawContextPrivate->screenFlags = M3cDrawContextScreenFlags_None; } - + newDrawContextPrivate->zBufferBaseAddr = NULL; newDrawContextPrivate->imageBufferBaseAddr = NULL; - + /* * Setup the platform specific data */ @@ -135,17 +135,17 @@ MSrDrawEngine_Method_ContextPrivateNew( newDrawContextPrivate, inFullScreen); UUmError_ReturnOnError(errorCode); - + for(i = 0; i < M3cDrawStateIntType_NumTypes; i++) { newDrawContextPrivate->stateInt[i] = 0; } - + for(i = 0; i < M3cDrawStatePtrType_NumTypes; i++) { newDrawContextPrivate->statePtr[i] = NULL; } - + *outDrawContextPrivate = (M3tDrawContextPrivate*)newDrawContextPrivate; return UUcError_None; @@ -165,211 +165,211 @@ MSrDrawEngine_Method_ContextMetaHandler( case M3cDrawContextMethodType_Frame_Start: outMethod->frameStart = MSrDrawContext_Method_Frame_Start; break; - + case M3cDrawContextMethodType_Frame_End: outMethod->frameEnd = MSrDrawContext_Method_Frame_End; break; - + case M3cDrawContextMethodType_Frame_Sync: outMethod->frameSync = MSrDrawContext_Method_Frame_Sync; break; - + case M3cDrawContextMethodType_State_SetInt: outMethod->stateSetInt = MSrDrawContext_Method_State_SetInt; break; - + case M3cDrawContextMethodType_State_GetInt: outMethod->stateGetInt = MSrDrawContext_Method_State_GetInt; break; - + case M3cDrawContextMethodType_State_SetPtr: outMethod->stateSetPtr = MSrDrawContext_Method_State_SetPtr; break; - + case M3cDrawContextMethodType_State_GetPtr: outMethod->stateGetPtr = MSrDrawContext_Method_State_GetPtr; break; - + case M3cDrawContextMethodType_TriInterpolate: switch(drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: outMethod->triInterpolate = MSrDrawContext_Method_TriGouraudInterpolate; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: outMethod->triInterpolate = MSrDrawContext_Method_TriTextureInterpolate; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_TriFlat: switch(drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: outMethod->triFlat = MSrDrawContext_Method_TriGouraudFlat; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: outMethod->triFlat = MSrDrawContext_Method_TriTextureFlat; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_TriSplit: outMethod->triSplit = MSrDrawContext_Method_TriTextureSplit; break; - + case M3cDrawContextMethodType_QuadInterpolate: switch(drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: outMethod->quadInterpolate = MSrDrawContext_Method_QuadGouraudInterpolate; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: outMethod->quadInterpolate = MSrDrawContext_Method_QuadTextureInterpolate; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_QuadFlat: switch(drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: outMethod->quadFlat = MSrDrawContext_Method_QuadGouraudFlat; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: outMethod->quadFlat = MSrDrawContext_Method_QuadTextureFlat; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_QuadSplit: outMethod->quadSplit = MSrDrawContext_Method_QuadTextureSplit; break; - + case M3cDrawContextMethodType_SmallQuadInterpolate: switch(drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: outMethod->smallQuadInterpolate = MSrDrawContext_Method_SmallQuadGouraudInterpolate; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: outMethod->smallQuadInterpolate = MSrDrawContext_Method_SmallQuadTextureInterpolate; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_SmallQuadFlat: switch(drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: outMethod->smallQuadFlat = MSrDrawContext_Method_SmallQuadGouraudFlat; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: outMethod->smallQuadFlat = MSrDrawContext_Method_SmallQuadTextureFlat; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_PentInterpolate: switch(drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: outMethod->pentInterpolate = MSrDrawContext_Method_PentGouraudInterpolate; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: outMethod->pentInterpolate = MSrDrawContext_Method_PentTextureInterpolate; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_PentFlat: switch(drawContextPrivate->stateInt[M3cDrawStateIntType_Appearence]) { case M3cDrawState_Appearence_Gouraud: outMethod->pentFlat = MSrDrawContext_Method_PentGouraudFlat; break; - + case M3cDrawState_Appearence_Texture_Lit: case M3cDrawState_Appearence_Texture_Unlit: outMethod->pentFlat = MSrDrawContext_Method_PentTextureFlat; break; - + default: UUmAssert(!"Unkown appearence type"); } break; - + case M3cDrawContextMethodType_PentSplit: outMethod->pentSplit = MSrDrawContext_Method_PentTextureSplit; break; - + case M3cDrawContextMethodType_Line_Interpolate: outMethod->lineInterpolate = MSrDrawContext_Method_Line_Interpolate; break; - + case M3cDrawContextMethodType_Line_Flat: outMethod->lineFlat = MSrDrawContext_Method_Line_Flat; break; - + case M3cDrawContextMethodType_Point: outMethod->point = MSrDrawContext_Method_Point; break; - + case M3cDrawContextMethodType_Bitmap: outMethod->bitmap = MSrDrawContext_Method_Bitmap; break; - + case M3cDrawContextMethodType_TextureFormatAvailable: outMethod->textureFormatAvailable = MSrDrawContext_TextureFormatAvailable; break; - + case M3cDrawContextMethodType_GetWidth: outMethod->getWidth = MSrDrawContext_GetWidth; break; - + case M3cDrawContextMethodType_GetHeight: outMethod->getHeight = MSrDrawContext_GetHeight; break; - + default: UUmAssert(!"There is some smelly shit going on here..."); } - + return UUcError_None; } @@ -379,23 +379,23 @@ MSrDrawEngine_Method_Texture_Init( { MStTextureMapPrivate* privateData = (MStTextureMapPrivate*)M3rManager_Texture_GetEnginePrivate(inTextureMap); UUtUns16 widthNBits, heightNBits; - + UUmAssert(privateData != NULL); - + if(inTextureMap->numLongs > 1 && inTextureMap->width > 0 && inTextureMap->height > 0) { widthNBits = heightNBits = 15; - + while(!(inTextureMap->width & (1 << widthNBits))) widthNBits--; while(!(inTextureMap->height & (1 << heightNBits))) heightNBits--; - + UUmAssert(inTextureMap->width == 1 << widthNBits); UUmAssert(inTextureMap->height == 1 << heightNBits); - + privateData->nWidthBits = widthNBits; privateData->nHeightBits = heightNBits; } - + return UUcError_None; } @@ -403,7 +403,7 @@ static UUtError MSrDrawEngine_Method_Texture_Load( M3tTextureMap* inTextureMap) { - + return UUcError_None; } @@ -411,7 +411,7 @@ static UUtError MSrDrawEngine_Method_Texture_Unload( M3tTextureMap* inTextureMap) { - + return UUcError_None; } @@ -419,7 +419,7 @@ static UUtError MSrDrawEngine_Method_Texture_Delete( M3tTextureMap* inTextureMap) { - + return UUcError_None; } @@ -428,34 +428,34 @@ MSrDrawEngine_Initialize( void) { UUtError error; - + M3tDrawEngineCaps drawEngineCaps; M3tDrawEngineMethods drawEngineMethods; - + drawEngineMethods.contextPrivateNew = MSrDrawEngine_Method_ContextPrivateNew; drawEngineMethods.contextPrivateDelete = MSrDrawEngine_Method_ContextPrivateDelete; drawEngineMethods.contextMetaHandler = MSrDrawEngine_Method_ContextMetaHandler; - + drawEngineMethods.textureInit = MSrDrawEngine_Method_Texture_Init; drawEngineMethods.textureLoad = MSrDrawEngine_Method_Texture_Load; drawEngineMethods.textureUnload = MSrDrawEngine_Method_Texture_Unload; drawEngineMethods.textureDelete = MSrDrawEngine_Method_Texture_Delete; drawEngineMethods.textureUpdate = MSrDrawEngine_Method_Texture_Init; - + drawEngineCaps.engineFlags = M3cDrawEngineFlag_CanHandleOffScreen; - + strncpy(drawEngineCaps.engineName, M3cDrawEngine_Software, M3cMaxNameLen); drawEngineCaps.engineDriver[0] = 0; - + drawEngineCaps.engineVersion = MScSoftware_Version; - + error = MSrDrawEngine_Platform_SetupEngineCaps(&drawEngineCaps); if(error != UUcError_None) { UUrError_Report(UUcError_Generic, "Could not setup engine caps"); return; } - + error = M3rManager_Register_DrawEngine( sizeof(MStTextureMapPrivate), diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DrawEngine_Method.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DrawEngine_Method.h index d4b620f..e8c9bf6 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DrawEngine_Method.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DrawEngine_Method.h @@ -1,12 +1,12 @@ /* FILE: MS_DrawEngine_Method.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DrawEngine_Platform.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DrawEngine_Platform.h index 056d260..9c752d8 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DrawEngine_Platform.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/MS_DrawEngine_Platform.h @@ -1,12 +1,12 @@ /* FILE: MS_DrawEngine_Platform.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -26,6 +26,6 @@ MSrDrawEngine_Platform_DestroyDrawContextPrivate( UUtError MSrDrawEngine_Platform_SetupEngineCaps( M3tDrawEngineCaps *ioDrawEngineCaps); - + #endif /* MS_DRAWENGINE_PLATFORM_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_DC_Platform_Mac.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_DC_Platform_Mac.c index d93e99a..136dc4c 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_DC_Platform_Mac.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_DC_Platform_Mac.c @@ -1,12 +1,12 @@ /* FILE: MS_DC_Platform_Mac.c - + AUTHOR: Brent H. Pease - + CREATED: May 19, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -26,32 +26,32 @@ MSrDrawContext_Method_Frame_Start( { MStDrawContextPrivate* drawContextPrivate = (MStDrawContextPrivate*)inDrawContext->privateContext; MStPlatformSpecific* platformSpecific; - + platformSpecific = &drawContextPrivate->platformSpecific; - + #if defined(MSmPixelTouch) && MSmPixelTouch - + { UUtUns16 x, y; double *p; - + double zero; UUtUns32 clearValue[2]; - + clearValue[0] = 0; clearValue[1] = 0; - + zero = *(double *)(clearValue); - + for(y = 0; y < drawContextPrivate->height; y++) { - + p = (double *)((char *)drawContextPrivate->pixelTouchBaseAddr + drawContextPrivate->pixelTouchRowBytes * y); - + for(x = 0; x < drawContextPrivate->pixelTouchRowBytes >> 5; x++) { UUrProcessor_ZeroCacheLine(p, 0); - + *p++ = zero; *p++ = zero; *p++ = zero; @@ -59,24 +59,24 @@ MSrDrawContext_Method_Frame_Start( } } } - + #else - + if(!(drawContextPrivate->screenFlags & M3cDrawContextScreenFlags_DoubleBuffer)) { MSrPPCAsm_CallProc( platformSpecific->zBufferClearProc, drawContextPrivate, (long)&platformSpecific->zClearValue0); - + MSrPPCAsm_CallProc( platformSpecific->imageBufferClearProc, drawContextPrivate, (long)&platformSpecific->imageClearValue0); } - + #endif - + return UUcError_None; } @@ -86,9 +86,9 @@ MSrDrawContext_Method_Frame_End( { MStDrawContextPrivate* drawContextPrivate = (MStDrawContextPrivate*)inDrawContext->privateContext; MStPlatformSpecific *platformSpecific; - + platformSpecific = &drawContextPrivate->platformSpecific; - + #if defined(MSmPixelTouch) && MSmPixelTouch { @@ -99,7 +99,7 @@ MSrDrawContext_Method_Frame_End( UUtUns16* curDstImagePtr; double imageClearValue; UUtInt16 i; - + imageClearValue = *(double *)&drawContextPrivate->platformSpecific.imageClearValue0; for(y = 0; y < drawContextPrivate->height; y++) @@ -107,11 +107,11 @@ MSrDrawContext_Method_Frame_End( curPixelTouch = (UUtUns16 *)((char *)drawContextPrivate->pixelTouchBaseAddr + drawContextPrivate->pixelTouchRowBytes * y); curSrcImagePtr = (UUtUns16 *)((char *)drawContextPrivate->imageBufferBaseAddr + drawContextPrivate->imageBufferRowBytes * y); curDstImagePtr = (UUtUns16 *)((char *)platformSpecific->frontImageBaseAddr + platformSpecific->frontImageRowBytes * y); - + for(x = 0; x < drawContextPrivate->width >> 4; x++) { pixelTouchVal = *curPixelTouch++; - + if(pixelTouchVal == 0) { *(double *)(curDstImagePtr) = imageClearValue; @@ -147,14 +147,14 @@ MSrDrawContext_Method_Frame_End( } } } - + //XXX - someday handle extra pixels } - + } - + #else - + if(drawContextPrivate->screenFlags & M3cDrawContextScreenFlags_DoubleBuffer) { MSrPPCAsm_CallProc( @@ -166,11 +166,11 @@ MSrDrawContext_Method_Frame_End( platformSpecific->zBufferClearProc, drawContextPrivate, (long)&platformSpecific->zClearValue0); - + } - + #endif - + return UUcError_None; } @@ -178,6 +178,6 @@ UUtError MSrDrawContext_Method_Frame_Sync( M3tDrawContext *drawContext) { - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_DrawEngine_Platform_Mac.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_DrawEngine_Platform_Mac.c index c6f88ae..b1ed599 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_DrawEngine_Platform_Mac.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_DrawEngine_Platform_Mac.c @@ -1,12 +1,12 @@ /* FILE: MS_DrawEngine_Platform_Mac.c - + AUTHOR: Brent H. Pease - + CREATED: May 19, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -36,26 +36,26 @@ UUtError MSrDrawEngine_Platform_SetupDrawContextPrivate( UUtUns32 frontBufferRowBytesAlignment; UUtUns32 rowBytesCacheLineAligned; M3tDrawContextScreenFlags screenFlags; - + UUtUns16 drawEngineIndex; UUtUns16 displayIndex; UUtUns16 modeIndex; M3tDrawEngineCapList* engineCapList; - + GDHandle gDevice; - + platformSpecific = &inDrawContextPrivate->platformSpecific; - + platformSpecific->zBufferClearProcMemory = NULL; platformSpecific->imageBufferClearProcMemory = NULL; platformSpecific->imageBufferCopyProcMemory = NULL; platformSpecific->imageBufferCopyAndClearProcMemory = NULL; - + platformSpecific->realImageBufferMemory = NULL; platformSpecific->realZBufferMemory = NULL; - + screenFlags = M3cDrawContextScreenFlags_None; - + /* * This is a total hack and needs a cleaner solution someday */ @@ -63,15 +63,15 @@ UUtError MSrDrawEngine_Platform_SetupDrawContextPrivate( &drawEngineIndex, &displayIndex, &modeIndex); - + engineCapList = M3rDrawEngine_GetCapList(); - + gDevice = (GDHandle)engineCapList->drawEngines[drawEngineIndex].displayDevices[displayIndex].platformDevice; - + if(inDrawContextDescriptor->type == M3cDrawContextType_OnScreen) { screenFlags = inDrawContextDescriptor->drawContext.onScreen.flags; - + devicePixMap = *(*gDevice)->gdPMap; inDrawContextPrivate->width = inDrawContextDescriptor->drawContext.onScreen.rect.right - inDrawContextDescriptor->drawContext.onScreen.rect.left; @@ -83,49 +83,49 @@ UUtError MSrDrawEngine_Platform_SetupDrawContextPrivate( platformSpecific->frontImageBaseAddr = (UUtUns16 *)(devicePixMap->baseAddr + inDrawContextDescriptor->drawContext.onScreen.rect.left * M3cDrawRGBBytesPerPixel + inDrawContextDescriptor->drawContext.onScreen.rect.top * platformSpecific->frontImageRowBytes); - - /* + + /* * Get the front image 8 byte alignment */ frontBufferBaseAddrAlignment = (unsigned long)platformSpecific->frontImageBaseAddr & 0x07; frontBufferRowBytesAlignment = platformSpecific->frontImageRowBytes & 0x07; - + /* * Compute the rowBytes thats aligned to a cache line */ rowBytesCacheLineAligned = (inDrawContextPrivate->width * M3cDrawRGBBytesPerPixel + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask; - + rowBytesCacheLineAligned |= frontBufferRowBytesAlignment; - + /* * Allocate the backBuffer memory including extra memory for alignment */ platformSpecific->realImageBufferMemory = UUrMemory_Block_New(inDrawContextPrivate->height * rowBytesCacheLineAligned + UUcProcessor_CacheLineSize); - + if(platformSpecific->realImageBufferMemory == NULL) { UUrError_Report(UUcError_OutOfMemory, "Could not allocate back buffer"); return UUcError_OutOfMemory; } - + /* * Start alignment process on a cache line boundary */ inDrawContextPrivate->imageBufferBaseAddr = (unsigned short *)(((unsigned long)platformSpecific->realImageBufferMemory + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask); - + /* * Add in the front image base addr alignment */ inDrawContextPrivate->imageBufferBaseAddr = (unsigned short *)( (unsigned long)inDrawContextPrivate->imageBufferBaseAddr | frontBufferBaseAddrAlignment); - + inDrawContextPrivate->imageBufferRowBytes = rowBytesCacheLineAligned; } else @@ -135,50 +135,50 @@ UUtError MSrDrawEngine_Platform_SetupDrawContextPrivate( inDrawContextDescriptor->drawContext.onScreen.rect.left * M3cDrawRGBBytesPerPixel + inDrawContextDescriptor->drawContext.onScreen.rect.top * inDrawContextPrivate->imageBufferRowBytes); } - + #if !(defined(MSmPixelTouch) && MSmPixelTouch) - + if(screenFlags & M3cDrawContextScreenFlags_DoubleBuffer) { errorCode = MSrMacCustomProc_BuildImageBufferCopy(inDrawContextPrivate); UUmError_ReturnOnErrorMsg(errorCode, "Could not build image buffer copy proc"); - + errorCode = MSrMacCustomProc_BuildImageBufferCopyAndClear(inDrawContextPrivate); UUmError_ReturnOnErrorMsg(errorCode, "Could not build image buffer copy and clear proc"); } - + #endif } else { inDrawContextPrivate->width = inDrawContextDescriptor->drawContext.offScreen.inWidth; inDrawContextPrivate->height = inDrawContextDescriptor->drawContext.offScreen.inHeight; - + inDrawContextPrivate->imageBufferRowBytes = platformSpecific->frontImageRowBytes = (inDrawContextPrivate->width * sizeof(UUtUns16) + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask; - + inDrawContextPrivate->imageBufferBaseAddr = platformSpecific->realImageBufferMemory = platformSpecific->frontImageBaseAddr = UUrMemory_Block_New(inDrawContextPrivate->height * platformSpecific->frontImageRowBytes); if(platformSpecific->frontImageBaseAddr == NULL) { return UUcError_OutOfMemory; } - + inDrawContextDescriptor->drawContext.offScreen.outBaseAddr = inDrawContextPrivate->imageBufferBaseAddr; inDrawContextDescriptor->drawContext.offScreen.outRowBytes = inDrawContextPrivate->imageBufferRowBytes; } - + platformSpecific->imageClearValue0 = 0; platformSpecific->imageClearValue1 = 0; /* * Allocate ZBuffer */ - platformSpecific->realZBufferMemory = - UUrMemory_Block_New(inDrawContextPrivate->width * inDrawContextPrivate->height * M3cDrawZBytesPerPixel + + platformSpecific->realZBufferMemory = + UUrMemory_Block_New(inDrawContextPrivate->width * inDrawContextPrivate->height * M3cDrawZBytesPerPixel + UUcProcessor_CacheLineSize); - + if(platformSpecific->realZBufferMemory == NULL) { UUrError_Report(UUcError_OutOfMemory, "Could not allocate z buffer"); @@ -186,22 +186,22 @@ UUtError MSrDrawEngine_Platform_SetupDrawContextPrivate( } inDrawContextPrivate->zBufferBaseAddr = (UUtUns16 *)( - ((unsigned long)platformSpecific->realZBufferMemory + + ((unsigned long)platformSpecific->realZBufferMemory + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask); - + inDrawContextPrivate->zBufferRowBytes = inDrawContextPrivate->width * M3cDrawZBytesPerPixel; - + platformSpecific->zClearValue0 = 0xFFFFFFFF; platformSpecific->zClearValue1 = 0xFFFFFFFF; - + #if !(defined(MSmPixelTouch) && MSmPixelTouch) - + errorCode = MSrMacCustomProc_BuildZBufferClear(inDrawContextPrivate); UUmError_ReturnOnErrorMsg(errorCode, "Could not build z buffer clear proc"); - + errorCode = MSrMacCustomProc_BuildImageBufferClear(inDrawContextPrivate); UUmError_ReturnOnErrorMsg(errorCode, "Could not build image buffer clear proc"); - + if(screenFlags & M3cDrawContextScreenFlags_DoubleBuffer) { MSrPPCAsm_CallProc( @@ -213,21 +213,21 @@ UUtError MSrDrawEngine_Platform_SetupDrawContextPrivate( inDrawContextPrivate, (long)&platformSpecific->zClearValue0); } - + #else - + inDrawContextPrivate->pixelTouchRowBytes = (inDrawContextPrivate->width + 7) >> 3; inDrawContextPrivate->pixelTouchRowBytes = (inDrawContextPrivate->pixelTouchRowBytes + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask; inDrawContextPrivate->pixelTouchBaseAddr = (UUtUns32 *)UUrMemory_Block_New( inDrawContextPrivate->pixelTouchRowBytes * inDrawContextPrivate->height); - + if(inDrawContextPrivate->pixelTouchBaseAddr == NULL) { UUrError_Report(UUcErrorSeverity_Fatal_Continue, UUcError_OutOfMemory, "Could not allocate pixel touch buffer"); return UUcError_OutOfMemory; - } - + } + #endif return UUcError_None; @@ -237,48 +237,48 @@ void MSrDrawEngine_Platform_DestroyDrawContextPrivate( MStDrawContextPrivate* inDrawContextPrivate) { MStPlatformSpecific *platformSpecific; - + platformSpecific = &inDrawContextPrivate->platformSpecific; - + if(platformSpecific->realImageBufferMemory != NULL) { UUrMemory_Block_Delete(platformSpecific->realImageBufferMemory); } - + if(platformSpecific->realZBufferMemory != NULL) { UUrMemory_Block_Delete(platformSpecific->realZBufferMemory); } - + if(platformSpecific->zBufferClearProcMemory != NULL) { UUrMemory_Block_Delete(platformSpecific->zBufferClearProcMemory); } - + if(platformSpecific->imageBufferClearProcMemory != NULL) { UUrMemory_Block_Delete(platformSpecific->imageBufferClearProcMemory); } - + if(platformSpecific->imageBufferCopyProcMemory != NULL) { UUrMemory_Block_Delete(platformSpecific->imageBufferCopyProcMemory); } - + if(platformSpecific->imageBufferCopyAndClearProcMemory != NULL) { UUrMemory_Block_Delete(platformSpecific->imageBufferCopyAndClearProcMemory); } - + #if defined(MSmPixelTouch) && MSmPixelTouch - + if(inDrawContextPrivate->pixelTouchBaseAddr != NULL) { UUrMemory_Block_Delete(inDrawContextPrivate->pixelTouchBaseAddr); } - + #endif - + } @@ -288,9 +288,9 @@ MSrDrawEngine_Platform_SetupEngineCaps( { GDHandle curGDevice; M3tDisplayDevice* curDisplayDevice; - + ioDrawEngineCaps->numDisplayDevices = 0; - + for(curGDevice = GetDeviceList(); curGDevice != NULL; curGDevice = GetNextDevice(curGDevice)) @@ -299,28 +299,28 @@ MSrDrawEngine_Platform_SetupEngineCaps( { break; } - + if((*(*curGDevice)->gdPMap)->pixelSize != 16) { continue; } - + curDisplayDevice = ioDrawEngineCaps->displayDevices + ioDrawEngineCaps->numDisplayDevices++; - + // XXX - Make this real curDisplayDevice->platformDevice = (void*)curGDevice; curDisplayDevice->numDisplayModes = 1; curDisplayDevice->displayModes[0].width = MSgResX; curDisplayDevice->displayModes[0].height = MSgResY; curDisplayDevice->displayModes[0].bitDepth = 16; - + } - + if(ioDrawEngineCaps->numDisplayDevices == 0) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find a monitor with bit depth 16"); } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_CustomProc.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_CustomProc.c index 49d413d..043f893 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_CustomProc.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_CustomProc.c @@ -1,12 +1,12 @@ /* FILE: MS_Mac_CustomProc.c - + AUTHOR: Brent H. Pease - + CREATED: May 19, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -27,21 +27,21 @@ UUtError MSrMacCustomProc_BuildZBufferClear( UUtUns32 *customProcBaseAddr; UUtUns32 *curInstrPtr; UUtUns32 *loopPC; - + UUtUns32 destAddrReg; UUtUns32 clearValueFReg; UUtUns32 tempReg0; MStPlatformSpecific *platformSpecific; - + platformSpecific = &drawContextPrivate->platformSpecific; UUmAssert(platformSpecific->zBufferClearProcMemory == NULL); - + destAddrReg = 4; clearValueFReg = 1; tempReg0 = 6; - - + + /* Do an initial pass to determine the size of the custom proc, generatingCode = 0 */ /* Do a second pass to generate the code, generatingCode = 1 */ for(generatingCode = 0; generatingCode < 2; generatingCode++) @@ -50,26 +50,26 @@ UUtError MSrMacCustomProc_BuildZBufferClear( { /* Allocate memory for the custom proc */ customProcMemory = UUrMemory_Block_New(customProcSize + UUcProcessor_CacheLineSize); - + if(customProcMemory == NULL) { UUrError_Report(UUcError_OutOfMemory, "Could not allocate z buffer clear memory"); - + return UUcError_OutOfMemory; } - + /* Make sure the function ptr is cache aligned */ customProcBaseAddr = (UUtUns32 *)(((UUtUns32)customProcMemory + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask); - + curInstrPtr = customProcBaseAddr; } else { customProcSize = 0; } - + /* r5 has a pointer to the zClearValue */ MSrPPCAsm_BuildOp_LFD( generatingCode, @@ -86,7 +86,7 @@ UUtError MSrMacCustomProc_BuildZBufferClear( &customProcSize, destAddrReg, (UUtUns32)drawContextPrivate->zBufferBaseAddr); - + /* * Load number of iterations into CTR */ @@ -101,16 +101,16 @@ UUtError MSrMacCustomProc_BuildZBufferClear( &curInstrPtr, &customProcSize, tempReg0); - + loopPC = curInstrPtr; - + MSrPPCAsm_BuildOp_DCBZ( generatingCode, &curInstrPtr, &customProcSize, 0, destAddrReg); - + #if 1 MSrPPCAsm_BuildOp_STFD( generatingCode, @@ -159,7 +159,7 @@ UUtError MSrMacCustomProc_BuildZBufferClear( &curInstrPtr, &customProcSize, loopPC); - + /* Return from the subroutine */ MSrPPCAsm_BuildOp_BLR( generatingCode, @@ -168,9 +168,9 @@ UUtError MSrMacCustomProc_BuildZBufferClear( } platformSpecific->zBufferClearProcMemory = customProcMemory; - + platformSpecific->zBufferClearProc = (MStBufferProcPtr)customProcBaseAddr; - + /* Flush the data cache so that we can execute our custom proc */ MakeDataExecutable(customProcBaseAddr, customProcSize); @@ -186,23 +186,23 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( UUtUns32 *customProcBaseAddr; UUtUns32 *curInstrPtr; UUtUns32 *loopPC; - + UUtInt32 destAddrReg; UUtInt32 tempReg0; UUtInt32 clearValueReg; UUtInt32 clearValueFReg; MStPlatformSpecific *platformSpecific; - + platformSpecific = &drawContextPrivate->platformSpecific; - + UUmAssert(platformSpecific->imageBufferClearProcMemory == NULL); - + destAddrReg = 4; tempReg0 = 6; clearValueReg = 7; clearValueFReg = 5; - - + + /* Do an initial pass to determine the size of the custom proc, generatingCode = 0 */ /* Do a second pass to generate the code, generatingCode = 1 */ for(generatingCode = 0; generatingCode < 2; generatingCode++) @@ -211,26 +211,26 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( { /* Allocate memory for the custom proc */ customProcMemory = UUrMemory_Block_New(customProcSize + UUcProcessor_CacheLineSize); - + if(customProcMemory == NULL) { UUrError_Report(UUcError_OutOfMemory, "Could not allocate image buffer clear memory"); - + return UUcError_OutOfMemory; } - + /* Make sure the function ptr is cache aligned */ customProcBaseAddr = (UUtUns32 *)(((UUtUns32)customProcMemory + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask); - + curInstrPtr = customProcBaseAddr; } else { customProcSize = 0; } - + /* Load the base address into destAddrReg */ MSrPPCAsm_BuildOp_L32( generatingCode, @@ -238,7 +238,7 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( &customProcSize, destAddrReg, (UUtUns32)drawContextPrivate->imageBufferBaseAddr); - + if(drawContextPrivate->screenFlags & M3cDrawContextScreenFlags_DoubleBuffer) { /* @@ -255,16 +255,16 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( &curInstrPtr, &customProcSize, tempReg0); - + loopPC = curInstrPtr; - + MSrPPCAsm_BuildOp_DCBZ( generatingCode, &curInstrPtr, &customProcSize, 0, destAddrReg); - + MSrPPCAsm_BuildOp_ADDI( generatingCode, &curInstrPtr, @@ -283,7 +283,7 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( offset = 0; imageRowBytes = drawContextPrivate->width * M3cDrawRGBBytesPerPixel; //imageRowBytes = platformSpecific->imageBufferBaseAddr; - + /* r5 has a pointer to the clearValue */ MSrPPCAsm_BuildOp_LFD( generatingCode, @@ -292,7 +292,7 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( clearValueFReg, 5, 0); - + MSrPPCAsm_BuildOp_LI( generatingCode, &curInstrPtr, @@ -314,14 +314,14 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( &curInstrPtr, &customProcSize, tempReg0); - + loopPC = curInstrPtr; - + if(addrAlignment & 0x01) { UUmAssert("Illegal condition"); } - + if(addrAlignment & 0x02) { MSrPPCAsm_BuildOp_STH( @@ -334,7 +334,7 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( offset += 2; addrAlignment += 2; } - + if(addrAlignment & 0x04) { MSrPPCAsm_BuildOp_STW( @@ -347,7 +347,7 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( offset += 4; addrAlignment += 4; } - + if(addrAlignment & 0x8) { MSrPPCAsm_BuildOp_STFD( @@ -360,7 +360,7 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( offset += 8; addrAlignment += 8; } - + if(addrAlignment & 0x10) { MSrPPCAsm_BuildOp_STFD( @@ -380,7 +380,7 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( offset += 16; addrAlignment += 16; } - + while((imageRowBytes - offset) >= UUcProcessor_CacheLineSize) { MSrPPCAsm_BuildOp_STFD( @@ -411,11 +411,11 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( clearValueFReg, destAddrReg, offset+24); - + offset += 32; addrAlignment += 32; } - + if((imageRowBytes - offset) >= 16) { MSrPPCAsm_BuildOp_STFD( @@ -435,7 +435,7 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( offset += 16; addrAlignment += 16; } - + if((imageRowBytes - offset) >= 8) { MSrPPCAsm_BuildOp_STFD( @@ -448,7 +448,7 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( offset += 8; addrAlignment += 8; } - + if((imageRowBytes - offset) >= 4) { MSrPPCAsm_BuildOp_STW( @@ -473,7 +473,7 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( offset += 2; addrAlignment += 2; } - + MSrPPCAsm_BuildOp_ADDI( generatingCode, &curInstrPtr, @@ -481,16 +481,16 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( destAddrReg, destAddrReg, drawContextPrivate->imageBufferRowBytes); - + } - + /* BDNZ back to top */ MSrPPCAsm_BuildOp_BDNZ( generatingCode, &curInstrPtr, &customProcSize, loopPC); - + /* Return from the subroutine */ MSrPPCAsm_BuildOp_BLR( generatingCode, @@ -499,9 +499,9 @@ UUtError MSrMacCustomProc_BuildImageBufferClear( } platformSpecific->imageBufferClearProcMemory = customProcMemory; - + platformSpecific->imageBufferClearProc = (MStBufferProcPtr)customProcBaseAddr; - + /* Flush the data cache so that we can execute our custom proc */ MakeDataExecutable(customProcBaseAddr, customProcSize); @@ -517,7 +517,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( UUtUns32 *customProcBaseAddr; UUtUns32 *curInstrPtr; UUtUns32 *loopPC; - + UUtInt32 destAddrReg; UUtInt32 srcAddrReg; UUtInt32 tempReg0; @@ -529,21 +529,21 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( UUtInt32 offset; UUtInt32 imageRowBytes; MStPlatformSpecific *platformSpecific; - + platformSpecific = &drawContextPrivate->platformSpecific; - + UUmAssert(platformSpecific->imageBufferCopyProcMemory == NULL); - + destAddrReg = 4; srcAddrReg = 5; tempReg0 = 6; - + tempFReg0 = 1; tempFReg1 = 2; tempFReg2 = 3; tempFReg3 = 4; - - + + /* Do an initial pass to determine the size of the custom proc, generatingCode = 0 */ /* Do a second pass to generate the code, generatingCode = 1 */ for(generatingCode = 0; generatingCode < 2; generatingCode++) @@ -552,26 +552,26 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( { /* Allocate memory for the custom proc */ customProcMemory = UUrMemory_Block_New(customProcSize + UUcProcessor_CacheLineSize); - + if(customProcMemory == NULL) { UUrError_Report(UUcError_OutOfMemory, "Could not allocate image buffer copy memory"); - + return UUcError_OutOfMemory; } - + /* Make sure the function ptr is cache aligned */ customProcBaseAddr = (UUtUns32 *)(((UUtUns32)customProcMemory + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask); - + curInstrPtr = customProcBaseAddr; } else { customProcSize = 0; } - + /* Load the dest base address into destAddrReg */ MSrPPCAsm_BuildOp_L32( generatingCode, @@ -579,7 +579,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( &customProcSize, destAddrReg, (UUtUns32)platformSpecific->frontImageBaseAddr); - + /* Load the src base address into srcAddrReg */ MSrPPCAsm_BuildOp_L32( generatingCode, @@ -587,11 +587,11 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( &customProcSize, srcAddrReg, (UUtUns32)drawContextPrivate->imageBufferBaseAddr); - + addrAlignment = (UUtUns32)platformSpecific->frontImageBaseAddr; offset = 0; imageRowBytes = drawContextPrivate->width * M3cDrawRGBBytesPerPixel; - + /* * Load number of iterations into CTR */ @@ -606,9 +606,9 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( &curInstrPtr, &customProcSize, tempReg0); - + loopPC = curInstrPtr; - + /* * Build scanline copy */ @@ -616,7 +616,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( { UUmAssert("Illegal condition"); } - + if(addrAlignment & 0x02) { MSrPPCAsm_BuildOp_LHZ( @@ -636,7 +636,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( offset += 2; addrAlignment += 2; } - + if(addrAlignment & 0x04) { MSrPPCAsm_BuildOp_LWZ( @@ -656,7 +656,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( offset += 4; addrAlignment += 4; } - + if(addrAlignment & 0x8) { MSrPPCAsm_BuildOp_LFD( @@ -676,7 +676,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( offset += 8; addrAlignment += 8; } - + if(addrAlignment & 0x10) { MSrPPCAsm_BuildOp_LFD( @@ -710,7 +710,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( offset += 16; addrAlignment += 16; } - + while((imageRowBytes - offset) >= UUcProcessor_CacheLineSize) { MSrPPCAsm_BuildOp_LFD( @@ -772,7 +772,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( offset += 32; addrAlignment += 32; } - + if((imageRowBytes - offset) >= 16) { MSrPPCAsm_BuildOp_LFD( @@ -806,7 +806,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( offset += 16; addrAlignment += 16; } - + if((imageRowBytes - offset) >= 8) { MSrPPCAsm_BuildOp_LFD( @@ -826,7 +826,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( offset += 8; addrAlignment += 8; } - + if((imageRowBytes - offset) >= 4) { MSrPPCAsm_BuildOp_LWZ( @@ -865,9 +865,9 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( offset += 2; addrAlignment += 2; } - - - + + + MSrPPCAsm_BuildOp_ADDI( generatingCode, &curInstrPtr, @@ -890,7 +890,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( &curInstrPtr, &customProcSize, loopPC); - + /* Return from the subroutine */ MSrPPCAsm_BuildOp_BLR( generatingCode, @@ -899,9 +899,9 @@ UUtError MSrMacCustomProc_BuildImageBufferCopy( } platformSpecific->imageBufferCopyProcMemory = customProcMemory; - + platformSpecific->imageBufferCopyProc = (MStBufferProcPtr)customProcBaseAddr; - + /* Flush the data cache so that we can execute our custom proc */ MakeDataExecutable(customProcBaseAddr, customProcSize); @@ -917,7 +917,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( UUtUns32 *customProcBaseAddr; UUtUns32 *curInstrPtr; UUtUns32 *loopPC; - + UUtInt32 destAddrReg; UUtInt32 srcAddrReg; UUtInt32 clearValueReg; @@ -931,22 +931,22 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( UUtInt32 offset; UUtInt32 imageRowBytes; MStPlatformSpecific *platformSpecific; - + platformSpecific = &drawContextPrivate->platformSpecific; - + UUmAssert(platformSpecific->imageBufferCopyAndClearProcMemory == NULL); - + destAddrReg = 4; srcAddrReg = 5; tempReg0 = 6; clearValueReg = 7; - + tempFReg0 = 1; tempFReg1 = 2; tempFReg2 = 3; tempFReg3 = 4; clearValueFReg = 5; - + /* Do an initial pass to determine the size of the custom proc, generatingCode = 0 */ /* Do a second pass to generate the code, generatingCode = 1 */ for(generatingCode = 0; generatingCode < 2; generatingCode++) @@ -955,26 +955,26 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( { /* Allocate memory for the custom proc */ customProcMemory = UUrMemory_Block_New(customProcSize + UUcProcessor_CacheLineSize); - + if(customProcMemory == NULL) { UUrError_Report(UUcError_OutOfMemory, "Could not allocate image buffer copy and clear memory"); - + return UUcError_OutOfMemory; } - + /* Make sure the function ptr is cache aligned */ customProcBaseAddr = (UUtUns32 *)(((UUtUns32)customProcMemory + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask); - + curInstrPtr = customProcBaseAddr; } else { customProcSize = 0; } - + /* r5 has a pointer to the clearValue */ MSrPPCAsm_BuildOp_LFD( generatingCode, @@ -983,14 +983,14 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( clearValueFReg, 5, 0); - + MSrPPCAsm_BuildOp_LI( generatingCode, &curInstrPtr, &customProcSize, clearValueReg, 0); - + /* Load the dest base address into destAddrReg */ MSrPPCAsm_BuildOp_L32( generatingCode, @@ -998,7 +998,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( &customProcSize, destAddrReg, (UUtUns32)platformSpecific->frontImageBaseAddr); - + /* Load the src base address into srcAddrReg */ MSrPPCAsm_BuildOp_L32( generatingCode, @@ -1006,11 +1006,11 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( &customProcSize, srcAddrReg, (UUtUns32)drawContextPrivate->imageBufferBaseAddr); - + addrAlignment = (UUtUns32)platformSpecific->frontImageBaseAddr; offset = 0; imageRowBytes = drawContextPrivate->width * M3cDrawRGBBytesPerPixel; - + /* * Load number of iterations into CTR */ @@ -1025,9 +1025,9 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( &curInstrPtr, &customProcSize, tempReg0); - + loopPC = curInstrPtr; - + /* * Build scanline copy */ @@ -1035,10 +1035,10 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( { UUmAssert("Illegal condition"); } - + if(addrAlignment & 0x02) { - + MSrPPCAsm_BuildOp_LHZ( generatingCode, &curInstrPtr, @@ -1063,7 +1063,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( offset += 2; addrAlignment += 2; } - + if(addrAlignment & 0x04) { MSrPPCAsm_BuildOp_LWZ( @@ -1090,7 +1090,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( offset += 4; addrAlignment += 4; } - + if(addrAlignment & 0x8) { MSrPPCAsm_BuildOp_LFD( @@ -1117,7 +1117,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( offset += 8; addrAlignment += 8; } - + if(addrAlignment & 0x10) { MSrPPCAsm_BuildOp_LFD( @@ -1165,7 +1165,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( offset += 16; addrAlignment += 16; } - + while((imageRowBytes - offset) >= UUcProcessor_CacheLineSize) { MSrPPCAsm_BuildOp_LFD( @@ -1253,11 +1253,11 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( clearValueFReg, srcAddrReg, offset+24); - + offset += 32; addrAlignment += 32; } - + if((imageRowBytes - offset) >= 16) { MSrPPCAsm_BuildOp_LFD( @@ -1305,7 +1305,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( offset += 16; addrAlignment += 16; } - + if((imageRowBytes - offset) >= 8) { MSrPPCAsm_BuildOp_LFD( @@ -1332,7 +1332,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( offset += 8; addrAlignment += 8; } - + if((imageRowBytes - offset) >= 4) { MSrPPCAsm_BuildOp_LWZ( @@ -1385,7 +1385,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( offset += 2; addrAlignment += 2; } - + MSrPPCAsm_BuildOp_ADDI( generatingCode, &curInstrPtr, @@ -1393,7 +1393,7 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( destAddrReg, destAddrReg, platformSpecific->frontImageRowBytes); - + MSrPPCAsm_BuildOp_ADDI( generatingCode, &curInstrPtr, @@ -1401,14 +1401,14 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( srcAddrReg, srcAddrReg, drawContextPrivate->imageBufferRowBytes); - + /* BDNZ back to top */ MSrPPCAsm_BuildOp_BDNZ( generatingCode, &curInstrPtr, &customProcSize, loopPC); - + /* Return from the subroutine */ MSrPPCAsm_BuildOp_BLR( generatingCode, @@ -1417,9 +1417,9 @@ UUtError MSrMacCustomProc_BuildImageBufferCopyAndClear( } platformSpecific->imageBufferCopyAndClearProcMemory = customProcMemory; - + platformSpecific->imageBufferCopyAndClearProc = (MStBufferProcPtr)customProcBaseAddr; - + /* Flush the data cache so that we can execute our custom proc */ MakeDataExecutable(customProcBaseAddr, customProcSize); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_CustomProc.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_CustomProc.h index dd81d2f..2d430a0 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_CustomProc.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_CustomProc.h @@ -1,12 +1,12 @@ /* FILE: MS_Mac_CustomProc.h - + AUTHOR: Brent H. Pease - + CREATED: May 19, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_PPCAsm.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_PPCAsm.c index 5c0d614..fc39034 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_PPCAsm.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_PPCAsm.c @@ -1,12 +1,12 @@ /* FILE: MS_Mac_PPCAsm.c - + AUTHOR: Brent H. Pease - + CREATED: April 2, 1997 - + PURPOSE: platform specific parts - + Copyright 1997 */ @@ -53,20 +53,20 @@ void MSrPPCAsm_BuildOp_LI( UUtUns32 value) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 14, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gpr, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( value, 16, 31 ); - + *(*curInstrPtr)++ = instruction; } else { *procSize += 4; } - + } void MSrPPCAsm_BuildOp_L32( @@ -77,20 +77,20 @@ void MSrPPCAsm_BuildOp_L32( UUtUns32 value) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 15, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gpr, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( (value >> 16) & 0xFFFF, 16, 31 ); - + *(*curInstrPtr)++ = instruction; - + instruction = MiPPCAsm_ShiftValue( 24, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gpr, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( gpr, 11, 15 ); instruction |= MiPPCAsm_ShiftValue( value & 0xFFFF, 16, 31 ); - + *(*curInstrPtr)++ = instruction; } else @@ -108,14 +108,14 @@ void MSrPPCAsm_BuildOp_MTCTR( UUtUns32 gpr) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 31, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gpr, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( 288, 11, 20 ); instruction |= MiPPCAsm_ShiftValue( 467, 21, 30 ); - + *(*curInstrPtr)++ = instruction; } else @@ -131,13 +131,13 @@ void MSrPPCAsm_BuildOp_BDNZ( UUtUns32 *pc) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 16, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( 16, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( pc - *curInstrPtr, 16, 29 ); - + *(*curInstrPtr)++ = instruction; } else @@ -152,13 +152,13 @@ void MSrPPCAsm_BuildOp_BLR( UUtUns32 *procSize) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 19, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( 20, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( 16, 21, 30 ); - + *(*curInstrPtr)++ = instruction; } else @@ -176,14 +176,14 @@ void MSrPPCAsm_BuildOp_ADDI( UUtUns32 value) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 14, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gprDest, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( gprA, 11, 15 ); instruction |= MiPPCAsm_ShiftValue( value, 16, 31 ); - + *(*curInstrPtr)++ = instruction; } else @@ -201,14 +201,14 @@ void MSrPPCAsm_BuildOp_STB( UUtUns32 disp) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 38, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gprS, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( gprAddr, 11, 15 ); instruction |= MiPPCAsm_ShiftValue( disp, 16, 31 ); - + *(*curInstrPtr)++ = instruction; } else @@ -226,14 +226,14 @@ void MSrPPCAsm_BuildOp_STH( UUtUns32 disp) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 44, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gprS, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( gprAddr, 11, 15 ); instruction |= MiPPCAsm_ShiftValue( disp, 16, 31 ); - + *(*curInstrPtr)++ = instruction; } else @@ -251,14 +251,14 @@ void MSrPPCAsm_BuildOp_STW( UUtUns32 disp) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 36, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gprS, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( gprAddr, 11, 15 ); instruction |= MiPPCAsm_ShiftValue( disp, 16, 31 ); - + *(*curInstrPtr)++ = instruction; } else @@ -276,14 +276,14 @@ void MSrPPCAsm_BuildOp_STFD( UUtUns32 disp) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 54, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( fS, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( gprAddr, 11, 15 ); instruction |= MiPPCAsm_ShiftValue( disp, 16, 31 ); - + *(*curInstrPtr)++ = instruction; } else @@ -301,14 +301,14 @@ void MSrPPCAsm_BuildOp_LBZ( UUtUns32 disp) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 34, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gprD, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( gprAddr, 11, 15 ); instruction |= MiPPCAsm_ShiftValue( disp, 16, 31 ); - + *(*curInstrPtr)++ = instruction; } else @@ -326,14 +326,14 @@ void MSrPPCAsm_BuildOp_LHZ( UUtUns32 disp) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 40, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gprD, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( gprAddr, 11, 15 ); instruction |= MiPPCAsm_ShiftValue( disp, 16, 31 ); - + *(*curInstrPtr)++ = instruction; } else @@ -351,14 +351,14 @@ void MSrPPCAsm_BuildOp_LWZ( UUtUns32 disp) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 32, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gprD, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( gprAddr, 11, 15 ); instruction |= MiPPCAsm_ShiftValue( disp, 16, 31 ); - + *(*curInstrPtr)++ = instruction; } else @@ -376,14 +376,14 @@ void MSrPPCAsm_BuildOp_LFD( UUtUns32 disp) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 50, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( fD, 6, 10 ); instruction |= MiPPCAsm_ShiftValue( gprAddr, 11, 15 ); instruction |= MiPPCAsm_ShiftValue( disp, 16, 31 ); - + *(*curInstrPtr)++ = instruction; } else @@ -400,14 +400,14 @@ void MSrPPCAsm_BuildOp_DCBZ( UUtUns32 gprB) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 31, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gprA, 11, 15 ); instruction |= MiPPCAsm_ShiftValue( gprB, 16, 20 ); instruction |= MiPPCAsm_ShiftValue( 1014, 21, 30 ); - + *(*curInstrPtr)++ = instruction; } else @@ -424,14 +424,14 @@ void MSrPPCAsm_BuildOp_DCBT( UUtUns32 gprB) { UUtUns32 instruction; - + if(generateCode) { instruction = MiPPCAsm_ShiftValue( 31, 0, 5 ); instruction |= MiPPCAsm_ShiftValue( gprA, 11, 15 ); instruction |= MiPPCAsm_ShiftValue( gprB, 16, 20 ); instruction |= MiPPCAsm_ShiftValue( 278, 21, 30 ); - + *(*curInstrPtr)++ = instruction; } else diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_PPCAsm.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_PPCAsm.h index 0266a6b..59cc1d8 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_PPCAsm.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_MacOS/MS_Mac_PPCAsm.h @@ -1,12 +1,12 @@ /* FILE: MS_Mac_PPCAsm.h - + AUTHOR: Brent H. Pease - + CREATED: April 2, 1997 - + PURPOSE: platform specific parts - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_Win32/MS_Platform_Win32.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_Win32/MS_Platform_Win32.c index 270096f..8f3fc7d 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_Win32/MS_Platform_Win32.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/DrawEngine/Software/Platform_Win32/MS_Platform_Win32.c @@ -1,12 +1,12 @@ /* FILE: MS_Platform_Mac.c - + AUTHOR: Brent H. Pease - + CREATED: May 19, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -34,7 +34,7 @@ static UUtBool MSgOS_NT_4; UUtError MSiInitBuffers( MStDrawContextPrivate *inDrawContextPrivate); - + static BOOL PASCAL MSiDeviceCallback( LPGUID inGuid, @@ -57,12 +57,12 @@ static void MSiPlatform_Win32_ClearZBuffer( UUtInt32 numDoubles; double *dPtr; double clearValue; - + numDoubles = drawContextPrivate->height * drawContextPrivate->zBufferRowBytes / sizeof(double); dPtr = (double *)drawContextPrivate->zBufferBaseAddr; - + clearValue = *(double *)&drawContextPrivate->platformSpecific.zClearValue0; - + while(numDoubles-- > 0) { *dPtr++ = clearValue; @@ -76,12 +76,12 @@ static void MSiPlatform_Win32_ClearImageBuffer( UUtInt32 numDoubles; double *dPtr; double clearValue; - + numDoubles = drawContextPrivate->height * drawContextPrivate->imageBufferRowBytes / sizeof(double); dPtr = (double *)drawContextPrivate->imageBufferBaseAddr; - + clearValue = *(double *)&drawContextPrivate->platformSpecific.imageClearValue0; - + while(numDoubles-- > 0) { *dPtr++ = clearValue; @@ -101,7 +101,7 @@ MSrDrawEngine_Platform_SetupDrawContextPrivate( UUtUns32 win_flags; M3tDrawContextDescriptorOnScreen *onScreen; OSVERSIONINFO info; - + M3tDrawEngineCaps *current_draw_engine_caps; M3tDrawEngineCapList *draw_engine_caps_list; UUtUns16 activeDrawEngine; @@ -110,10 +110,10 @@ MSrDrawEngine_Platform_SetupDrawContextPrivate( // get a pointer to onScreen onScreen = &inDrawContextDescriptor->drawContext.onScreen; - + // set use MSgOS_NT_4 to false MSgOS_NT_4 = UUcFalse; - + // find out which OS the game is running under info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx(&info)) @@ -122,22 +122,22 @@ MSrDrawEngine_Platform_SetupDrawContextPrivate( if (info.dwPlatformId == VER_PLATFORM_WIN32_NT) MSgOS_NT_4 = UUcTrue; } - + // ---------------------------------------- // Create the direct draw object // ---------------------------------------- - + // get a pointer tothe draw engine caps list draw_engine_caps_list = M3rDrawEngine_GetCapList(); - + UUmAssert(draw_engine_caps_list); - + // get the index of the active draw engine M3rManager_GetActiveDrawEngine(&activeDrawEngine, &activeDevice, &activeMode); - + // get a pointer to the current draw engine's caps current_draw_engine_caps = &draw_engine_caps_list->drawEngines[activeDrawEngine]; - + // create the DirectDraw object if (MSgOS_NT_4) { @@ -146,7 +146,7 @@ MSrDrawEngine_Platform_SetupDrawContextPrivate( DirectDrawCreate( NULL, &platformSpecific->dd, - NULL); + NULL); } else { @@ -155,18 +155,18 @@ MSrDrawEngine_Platform_SetupDrawContextPrivate( DirectDrawCreate( (LPGUID)current_draw_engine_caps->displayDevices[activeDevice].platformDevice, &platformSpecific->dd, - NULL); + NULL); } if (result != DD_OK) { UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + // ---------------------------------------- // Setup the connection to the window // ---------------------------------------- - + // set the flags for the window if (inFullScreen == UUcTrue) { @@ -176,7 +176,7 @@ MSrDrawEngine_Platform_SetupDrawContextPrivate( { win_flags = DDSCL_NOWINDOWCHANGES | DDSCL_NORMAL; } - + // set the cooperative level result = IDirectDraw_SetCooperativeLevel( @@ -188,14 +188,14 @@ MSrDrawEngine_Platform_SetupDrawContextPrivate( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + // ---------------------------------------- // setup the buffers and whatnots // ---------------------------------------- platformSpecific->imageClearValue0 = 0; platformSpecific->imageClearValue1 = 0; - + if (inDrawContextDescriptor->type == M3cDrawContextType_OnScreen) { // set dimension and location data @@ -224,7 +224,7 @@ MSrDrawEngine_Platform_SetupDrawContextPrivate( { UUmAssert(!"Must be onscreen"); } - + return UUcError_None; } @@ -251,7 +251,7 @@ MSrDrawContext_Method_Frame_Start( DDSURFACEDESC ddsd; // DDBLTFX dd_blt_fx; HRESULT ddResult = DD_OK; - + // use the blitter to do a color fill on the backbuffer /* dd_blt_fx.dwSize = sizeof(DDBLTFX); dd_blt_fx.dwFillColor = platformSpecific->imageClearValue0; @@ -266,7 +266,7 @@ MSrDrawContext_Method_Frame_Start( { UUmError_ReturnOnErrorMsg(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(ddResult)); } - + // use the blitter to do a color fill on the backbuffer dd_blt_fx.dwSize = sizeof(DDBLTFX); @@ -282,13 +282,13 @@ MSrDrawContext_Method_Frame_Start( { UUmError_ReturnOnErrorMsg(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(ddResult)); }*/ - + if(drawContextPrivate->screenFlags & M3cDrawContextScreenFlags_DoubleBuffer) { // lock the backBuffer UUrMemory_Clear(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); - + ddResult = IDirectDrawSurface_Lock( platformSpecific->backBuffer, NULL, @@ -299,15 +299,15 @@ MSrDrawContext_Method_Frame_Start( { UUmError_ReturnOnErrorMsg(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(ddResult)); } - - + + drawContextPrivate->imageBufferBaseAddr = ddsd.lpSurface; drawContextPrivate->imageBufferRowBytes = (UUtUns16)ddsd.lPitch; - + // lock the zBuffer UUrMemory_Clear(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); - + ddResult = IDirectDrawSurface_Lock( platformSpecific->zBuffer, NULL, @@ -318,13 +318,13 @@ MSrDrawContext_Method_Frame_Start( { UUmError_ReturnOnErrorMsg(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(ddResult)); } - + drawContextPrivate->zBufferBaseAddr = ddsd.lpSurface; drawContextPrivate->zBufferRowBytes = (UUtUns16)ddsd.lPitch; - + // clear the imageBuffer MSiPlatform_Win32_ClearImageBuffer(drawContextPrivate); - + // clear the zBuffer MSiPlatform_Win32_ClearZBuffer(drawContextPrivate); } @@ -332,10 +332,10 @@ MSrDrawContext_Method_Frame_Start( { UUmAssert(!"Implement me"); } - + return UUcError_None; } - + // ---------------------------------------------------------------------- UUtError MSrDrawContext_Method_Frame_End( @@ -345,7 +345,7 @@ MSrDrawContext_Method_Frame_End( MStPlatformSpecific* platformSpecific = &drawContextPrivate->platformSpecific; HRESULT ddResult = DD_OK; - + if(drawContextPrivate->screenFlags & M3cDrawContextScreenFlags_DoubleBuffer) { // unlock the zBuffer @@ -367,7 +367,7 @@ MSrDrawContext_Method_Frame_End( { UUmError_ReturnOnErrorMsg(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(ddResult)); } - + ddResult = IDirectDrawSurface_BltFast( platformSpecific->frontBuffer, @@ -385,7 +385,7 @@ MSrDrawContext_Method_Frame_End( { UUmAssert(!"Implement me"); } - + return UUcError_None; } @@ -394,7 +394,7 @@ UUtError MSrDrawContext_Method_Frame_Sync( M3tDrawContext *drawContext) { - + return UUcError_None; } @@ -406,14 +406,14 @@ MSrDrawEngine_Platform_SetupEngineCaps( HRESULT result; ioDrawEngineCaps->numDisplayDevices = 0; - + // enumerate the direct draw devices result = DirectDrawEnumerate(MSiDeviceCallback, ioDrawEngineCaps); if (result != DD_OK) { UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); } - + return UUcError_None; } @@ -429,13 +429,13 @@ MSiInitBuffers( { DDSURFACEDESC ddsd; HRESULT result; - + // setup the direct draw surface description for the front buffer UUrMemory_Clear(&ddsd, sizeof(DDSURFACEDESC)); ddsd.dwSize = sizeof(DDSURFACEDESC); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - + // create the frontBuffer result = IDirectDraw_CreateSurface( @@ -448,7 +448,7 @@ MSiInitBuffers( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + inDrawContextPrivate->platformSpecific.bpp = 16; // setup the direct draw surface description for the back buffer @@ -471,7 +471,7 @@ MSiInitBuffers( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + // create the zbuffer UUrMemory_Clear(&ddsd, sizeof(DDSURFACEDESC)); ddsd.dwSize = sizeof(DDSURFACEDESC); @@ -482,7 +482,7 @@ MSiInitBuffers( ddsd.dwWidth = inDrawContextPrivate->width; ddsd.dwHeight = inDrawContextPrivate->height; ddsd.dwZBufferBitDepth = inDrawContextPrivate->platformSpecific.bpp; - + result = IDirectDraw_CreateSurface( inDrawContextPrivate->platformSpecific.dd, @@ -494,10 +494,10 @@ MSiInitBuffers( UUrError_Report(UUcError_DirectDraw, M3rPlatform_GetErrorMsg(result)); return UUcError_DirectDraw; } - + inDrawContextPrivate->zBufferBaseAddr = ddsd.lpSurface; inDrawContextPrivate->zBufferRowBytes = (UUtUns16)ddsd.lPitch; - + inDrawContextPrivate->platformSpecific.zClearValue0 = 0xFFFFFFFF; inDrawContextPrivate->platformSpecific.zClearValue1 = 0xFFFFFFFF; @@ -516,27 +516,27 @@ MSiDeviceCallback( UUtUns32 index; LPDIRECTDRAW dd; HRESULT result; - + // if inData is null, something went terribly wrong if (inData == NULL) { return DDENUMRET_OK; } - + // get a pointer to the draw engine caps draw_engine_caps = (M3tDrawEngineCaps*)inData; - + // get an index into the display devices array index = draw_engine_caps->numDisplayDevices; if (index >= M3cMaxDisplayDevices) { return DDENUMRET_CANCEL; } - + // initialize the display device draw_engine_caps->displayDevices[index].platformDevice = (LPVOID)inGuid; draw_engine_caps->displayDevices[index].numDisplayModes = 0; - + // create the DirectDraw object result = DirectDrawCreate(inGuid, &dd, NULL); if (result != DD_OK) @@ -565,7 +565,7 @@ MSiDeviceCallback( // increment the number of display devices draw_engine_caps->numDisplayDevices++; - + cleanup: // cleanup before leaving @@ -574,8 +574,8 @@ MSiDeviceCallback( IDirectDraw_Release(dd); dd = NULL; } - - return DDENUMRET_OK; + + return DDENUMRET_OK; } // ---------------------------------------------------------------------- @@ -586,50 +586,50 @@ MSiModeCallback( { M3tDisplayDevice *display_device; UUtUns16 index; - + // if inData is NULL, something went terribly wrong if (inData == NULL) { return DDENUMRET_OK; } - + // if the surface description is null something went wrong if (inSurfaceDesc == NULL) { return DDENUMRET_CANCEL; } - + // double check structure size if (inSurfaceDesc->dwSize != sizeof(DDSURFACEDESC)) { return DDENUMRET_CANCEL; } - + // only use surfaces that have 16 bit pixels if (inSurfaceDesc->ddpfPixelFormat.dwRGBBitCount != 16) { return DDENUMRET_OK; } - + // get a pointer to the display device display_device = (M3tDisplayDevice*)inData; - + // get an index into the display modes array index = display_device->numDisplayModes; if (index >= M3cMaxDisplayModes) { return DDENUMRET_CANCEL; } - + // fill in info about the display mode display_device->displayModes[index].width = (UUtUns16)inSurfaceDesc->dwWidth; display_device->displayModes[index].height = (UUtUns16)inSurfaceDesc->dwHeight; display_device->displayModes[index].bitDepth = (UUtUns16)inSurfaceDesc->ddpfPixelFormat.dwRGBBitCount; display_device->displayModes[index].pad = 0; - + // increment the number of display devices display_device->numDisplayModes++; - + return DDENUMRET_OK; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Camera.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Camera.c index de090a0..cc0b7e1 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Camera.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Camera.c @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Camera.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Camera.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Camera.h index 0944df6..0b4f6ec 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Camera.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Camera.h @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Camera.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Env.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Env.c index 7b19ed4..d362328 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Env.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Env.c @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Env.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -26,7 +26,7 @@ UUtError EGrGeomContext_Method_Env_SetCamera( M3tGeomCamera* inCamera) { - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Env.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Env.h index 2cfff08..0f8878f 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Env.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Env.h @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Env.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -16,7 +16,7 @@ UUtError EGrGeomContext_Method_Env_SetCamera( M3tGeomCamera* inCamera); // If null use active camera in geom context - + UUtError EGrGeomContext_Method_Env_DrawGQBV( UUtUns32* inGQBV, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Frame.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Frame.c index 6e6ce6b..75a69d7 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Frame.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Frame.c @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Frame.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -24,7 +24,7 @@ UUtError EGrGeomContext_Method_Frame_Start( UUtUns32 inGameTime) { - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Frame.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Frame.h index 4eebb41..a680066 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Frame.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Frame.h @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Frame.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Geometry.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Geometry.c index 5508511..13b0d94 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Geometry.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Geometry.c @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Geometry.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -25,7 +25,7 @@ EGrGeomContext_Method_Geometry_BoundingBox_Draw( UUtUns16 inRGB555, M3tGeometry* inGeometryObject) { - + return UUcError_None; } @@ -33,10 +33,10 @@ UUtError EGrGeomContext_Method_Geometry_Draw( M3tGeometry* inGeometryObject) { - + return UUcError_None; } - + UUtError EGrGeomContext_Method_Geometry_PolyDraw( UUtUns16 inNumPoints, @@ -46,7 +46,7 @@ EGrGeomContext_Method_Geometry_PolyDraw( return UUcError_None; } - + UUtError EGrGeomContext_Method_Geometry_LineDraw( UUtUns16 inNumPoints, @@ -73,7 +73,7 @@ EGrGeomContext_Method_Geometry_PointDraw( M3tPoint3D* inPoints, UUtUns16 inShade) { - + return UUcError_None; } @@ -88,6 +88,6 @@ EGrGeomContext_Method_Sprite_Draw( M3tVector3D* inDirection, M3tMatrix3x3* inOrientation) { - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Geometry.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Geometry.h index e397679..cfd534f 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Geometry.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Geometry.h @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Geometry.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -27,18 +27,18 @@ EGrGeomContext_Method_Sprite_Draw( UUtUns16 inAlpha, float inRotation, M3tVector3D* inDirection, - M3tMatrix3x3* inOrientation); + M3tMatrix3x3* inOrientation); UUtError EGrGeomContext_Method_Geometry_Draw( M3tGeometry* inGeometryObject); - + UUtError EGrGeomContext_Method_Geometry_PolyDraw( UUtUns16 inNumPoints, M3tPoint3D* inPoints, UUtUns16 inShade); - + UUtError EGrGeomContext_Method_Geometry_LineDraw( UUtUns16 inNumPoints, @@ -50,7 +50,7 @@ EGrGeomContext_Method_Geometry_LineDraw2D( UUtUns16 inNumPoints, M3tPointScreen* inPoints, UUtUns16 inShade); - + UUtError EGrGeomContext_Method_Geometry_PointDraw( UUtUns16 inNumPoints, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Light.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Light.c index d864052..5b13aa2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Light.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Light.c @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Light.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Light.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Light.h index 4533824..581a595 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Light.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Light.h @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Light.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Matrix.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Matrix.c index 603f16e..d34a246 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Matrix.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Matrix.c @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Matrix.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -30,7 +30,7 @@ UUtError EGrGeomContext_Method_MatrixStack_Pop( void) { - + return UUcError_None; } @@ -46,7 +46,7 @@ UUtError EGrGeomContext_Method_MatrixStack_Identity( void) { - + return UUcError_None; } @@ -54,7 +54,7 @@ UUtError EGrGeomContext_Method_MatrixStack_Clear( void) { - + return UUcError_None; } @@ -106,38 +106,38 @@ EGrGeomContext_Method_MatrixStack_Multiply( void EGrGeomContext_Method_MatrixToQuat( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, M3tQuaternion *outQuat) { } void EGrGeomContext_Method_QuatToMatrix( - const M3tQuaternion *inQuat, + const M3tQuaternion *inQuat, M3tMatrix4x3 *outMatrix) { } -void +void EGrGeomContext_Method_Matrix_GetTranslation( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, M3tPoint3D *outTranslation) { } void EGrGeomContext_Method_Matrix_Multiply ( - const M3tMatrix4x3 *inMatrixA, - const M3tMatrix4x3 *inMatrixB, + const M3tMatrix4x3 *inMatrixA, + const M3tMatrix4x3 *inMatrixB, M3tMatrix4x3 *outResult) { } void EGrGeomContext_Method_Matrix_MultiplyPoints ( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, const UUtUns16 inNumPoints, - const M3tPoint3D *inPoints, + const M3tPoint3D *inPoints, M3tPoint3D *outPoints) { } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Matrix.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Matrix.h index 4d80e95..aa77b3c 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Matrix.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Matrix.h @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Matrix.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -60,30 +60,30 @@ EGrGeomContext_Method_MatrixStack_Multiply( void EGrGeomContext_Method_MatrixToQuat( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, M3tQuaternion *outQuat); void EGrGeomContext_Method_QuatToMatrix( - const M3tQuaternion *inQuat, + const M3tQuaternion *inQuat, M3tMatrix4x3 *outMatrix); -void +void EGrGeomContext_Method_Matrix_GetTranslation( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, M3tPoint3D *outTranslation); void EGrGeomContext_Method_Matrix_Multiply ( - const M3tMatrix4x3 *inMatrixA, - const M3tMatrix4x3 *inMatrixB, + const M3tMatrix4x3 *inMatrixA, + const M3tMatrix4x3 *inMatrixB, M3tMatrix4x3 *outResult); void EGrGeomContext_Method_Matrix_MultiplyPoints ( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, const UUtUns16 inNumPoints, - const M3tPoint3D *inPoint, + const M3tPoint3D *inPoint, M3tPoint3D *outPoint); void diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Pick.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Pick.c index c81e3f8..f5cbee3 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Pick.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Pick.c @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Pick.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Pick.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Pick.h index 9de07ed..c69fafd 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Pick.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_Pick.h @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_Pick.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_State.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_State.c index 321dfe4..127869c 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_State.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_State.c @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_State.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -37,7 +37,7 @@ UUtError EGrGeomContext_Method_State_Push( void) { - + return UUcError_None; } @@ -45,7 +45,7 @@ UUtError EGrGeomContext_Method_State_Pop( void) { - + return UUcError_None; } @@ -53,6 +53,6 @@ UUtError EGrGeomContext_Method_State_Commit( void) { - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_State.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_State.h index 87008cc..8578aa2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_State.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Method_State.h @@ -1,12 +1,12 @@ /* FILE: EM_GC_Method_State.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Private.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Private.h index 2d550ef..913d943 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GC_Private.h @@ -1,12 +1,12 @@ /* FILE: EM_GC_Private.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GeomEngine_Method.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GeomEngine_Method.c index 8643d23..4c92473 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GeomEngine_Method.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GeomEngine_Method.c @@ -1,12 +1,12 @@ /* FILE: EM_GeomEngine_Method.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -35,7 +35,7 @@ static UUtError EGrGeomEngine_Method_ContextPrivateNew( M3tDrawContextDescriptor* inDrawContextDescriptor) { - + return UUcError_None; } @@ -50,7 +50,7 @@ static UUtError EGrGeomEngine_Method_ContextSetEnvironment( struct AKtEnvironment* inEnvironment) { - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GeomEngine_Method.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GeomEngine_Method.h index 959919b..64fb02c 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GeomEngine_Method.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/EmptyGeomEngine/EM_GeomEngine_Method.h @@ -1,12 +1,12 @@ /* FILE: EM_GeomEngine_Method.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Camera.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Camera.c index 411c0df..c895344 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Camera.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Camera.c @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Camera.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -22,7 +22,7 @@ UUtError OGrGeomContext_Method_Camera_New( M3tGeomCamera* *outCamera) { - + return UUcError_None; } @@ -42,7 +42,7 @@ UUtError OGrGeomContext_Method_Camera_GetActive( M3tGeomCamera* *outCamera) { - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Camera.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Camera.h index 59dbad0..7816398 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Camera.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Camera.h @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Camera.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Env.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Env.c index 852016a..6c03716 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Env.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Env.c @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Env.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -28,7 +28,7 @@ #include "OG_GC_Method_Env.h" #include "OG_GC_Method_Camera.h" -static UUtUns8 g2BitSubtractor[256] = +static UUtUns8 g2BitSubtractor[256] = { 0x0, //00000000 -> 00000000 0x0, //00000001 -> 00000000 @@ -292,7 +292,7 @@ UUtError OGrGeomContext_Method_Env_SetCamera( M3tGeomCamera* inCamera) { - + return UUcError_None; } @@ -310,23 +310,23 @@ OGrGeomContext_Method_Env_DrawGQList( M3tPoint3D* worldPoints; M3tTextureCoord* baseUVs; M3tTextureMap** baseMapArray; - + AKtGQ_General* curGQGeneral; AKtGQ_Render* curGQRender; UUtUns32 curGQIndex; - + UUtBool useDebugMaps = UUcFalse; UUtBool drawGhostGQs = UUcFalse; UUtUns32 debugState; - + M3tPoint3D* tempPoints; M3tTextureCoord* tempBaseUVs; M3tTextureCoord* tempLightUVs; M3tTextureMap** tempBaseMaps; - + //UUtUns32 itr; - + UUtUns32 numGQBlock8; UUtUns32 block8Itr; UUtUns32 numGQLeftOver; @@ -335,9 +335,9 @@ OGrGeomContext_Method_Env_DrawGQList( UUtUns32 vertItr; //return UUcError_None; - + if(OGgGeomContextPrivate.environment == NULL) return UUcError_None; - + UUmAssertReadPtr(OGgGeomContextPrivate.environment, sizeof(*OGgGeomContextPrivate.environment)); worldPoints = OGgGeomContextPrivate.environment->pointArray->points; @@ -346,39 +346,39 @@ OGrGeomContext_Method_Env_DrawGQList( baseUVs = OGgGeomContextPrivate.environment->textureCoordArray->textureCoords; baseMapArray = OGgGeomContextPrivate.environment->textureMapArray->maps; - + // debugState = OGgGeomContextPrivate.stateInt[M3cGeomStateIntType_DebugMode]; debugState = 0; - + tempPoints = OGgGeomContextPrivate.tempPoints; tempBaseUVs = OGgGeomContextPrivate.tempBaseUVs; tempLightUVs = OGgGeomContextPrivate.tempLightUVs; tempBaseMaps = OGgGeomContextPrivate.tempBaseMaps; - + useDebugMaps = (UUtBool)((debugState & M3cGeomState_DebugMode_UseEnvDbgTexture) != 0); drawGhostGQs = (UUtBool)((debugState & M3cGeomState_DebugMode_DrawGhostGQs) != 0); - + if(inNumGQs == 0) return UUcError_None; - + OGLrCommon_Camera_Update(OGLcCameraMode_3D); - + #if 0 glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - + glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_INDEX_ARRAY); glDisableClientState(GL_EDGE_FLAG_ARRAY); #endif - + // Idea here is to build up a list of 8 quads and submit their vertices at once // and then submit the quads using glDrawArrays - + numGQBlock8 = inNumGQs >> 3; numGQLeftOver = inNumGQs - (numGQBlock8 << 3); numGQBlock8++; - + for(block8Itr = 0; block8Itr < numGQBlock8; block8Itr++) { if(block8Itr == numGQBlock8 - 1) @@ -389,7 +389,7 @@ OGrGeomContext_Method_Env_DrawGQList( { numGQItrs = 8; } - + //OGLgCommon.pglUnlockArraysEXT(); for(gqItr = 0, vertItr = 0; gqItr < numGQItrs; gqItr++, vertItr += 4) @@ -398,22 +398,22 @@ OGrGeomContext_Method_Env_DrawGQList( curGQGeneral = gqGeneralArray + curGQIndex; curGQRender = gqRenderArray + curGQIndex; - + tempPoints[vertItr + 0] = worldPoints[curGQGeneral->m3Quad.vertexIndices.indices[0]]; tempPoints[vertItr + 1] = worldPoints[curGQGeneral->m3Quad.vertexIndices.indices[1]]; tempPoints[vertItr + 2] = worldPoints[curGQGeneral->m3Quad.vertexIndices.indices[2]]; tempPoints[vertItr + 3] = worldPoints[curGQGeneral->m3Quad.vertexIndices.indices[3]]; - + tempBaseUVs[vertItr + 0] = baseUVs[curGQGeneral->m3Quad.baseUVIndices.indices[0]]; tempBaseUVs[vertItr + 1] = baseUVs[curGQGeneral->m3Quad.baseUVIndices.indices[1]]; tempBaseUVs[vertItr + 2] = baseUVs[curGQGeneral->m3Quad.baseUVIndices.indices[2]]; tempBaseUVs[vertItr + 3] = baseUVs[curGQGeneral->m3Quad.baseUVIndices.indices[3]]; - + // set the proper base texture map if((curGQGeneral->flags & AKcGQ_Flag_Draw_Flash)) { curGQGeneral->flags &= ~AKcGQ_Flag_Draw_Flash; - + if(curGQGeneral->flags & AKcGQ_Flag_Flash_State) { curGQGeneral->flags &= ~AKcGQ_Flag_Flash_State; @@ -430,13 +430,13 @@ OGrGeomContext_Method_Env_DrawGQList( tempBaseMaps[gqItr] = baseMapArray[curGQRender->textureMapIndex]; } } - + glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3, GL_FLOAT, 0, tempPoints); - + glTexCoordPointer(2, GL_FLOAT, 0, tempBaseUVs); - + //OGLgCommon.pglLockArraysEXT(0, numGQItrs << 3); for(gqItr = 0; gqItr < numGQItrs; gqItr++) { @@ -444,12 +444,12 @@ OGrGeomContext_Method_Env_DrawGQList( { OGLrCommon_TextureMap_Select(tempBaseMaps[gqItr], GL_TEXTURE0_ARB); } - + glDrawArrays(GL_POLYGON, gqItr << 2, 4); glFlush(); } } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Env.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Env.h index f18c6d6..54bf445 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Env.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Env.h @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Env.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -16,7 +16,7 @@ UUtError OGrGeomContext_Method_Env_SetCamera( M3tGeomCamera* inCamera); // If null use active camera in geom context - + UUtError OGrGeomContext_Method_Env_DrawGQList( UUtUns32 inNumGQs, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Frame.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Frame.c index 10de662..c2e6494 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Frame.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Frame.c @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Frame.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -25,7 +25,7 @@ UUtError OGrGeomContext_Method_Frame_Start( UUtUns32 inGameTime) { - + M3rDraw_Frame_Start(inGameTime); return UUcError_None; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Frame.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Frame.h index bf7f66a..00a5e02 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Frame.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Frame.h @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Frame.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Geometry.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Geometry.c index fe53778..4b6069f 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Geometry.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Geometry.c @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Geometry.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -31,15 +31,15 @@ OGiMatrix_Update( { M3tMatrix4x3* matrix_localToWorld; float m[16]; - + M3rMatrixStack_Get(&matrix_localToWorld); - + OGLrCommon_Matrix4x3_OniToGL( matrix_localToWorld, m); - + glMultMatrixf(m); - + } UUtError @@ -47,7 +47,7 @@ OGrGeomContext_Method_Geometry_BoundingBox_Draw( UUtUns32 inRGB555, M3tGeometry* inGeometryObject) { - + return UUcError_None; } @@ -57,32 +57,32 @@ OGrGeomContext_Method_Geometry_Draw( { GLuint geomDisplayListIndex; - + OGLrCommon_Camera_Update(OGLcCameraMode_3D); glPushMatrix(); - + OGiMatrix_Update(); - + //OGLrCommon_glEnable(GL_CULL_FACE); - + OGLrCommon_TextureMap_Select(inGeometryObject->baseMap, GL_TEXTURE0_ARB); - + TMrInstance_PrepareForUse(inGeometryObject); geomDisplayListIndex = (GLuint)TMrTemplate_Cache_Simple_GetDataPtr(OGgGeomContextPrivate.geometryCache, inGeometryObject); UUmAssert(glIsList(geomDisplayListIndex) == GL_TRUE); glCallList(geomDisplayListIndex); - + //OGLrCommon_glDisable(GL_CULL_FACE); glPopMatrix(); - + //OGLrCommon_glFlush(); - + return UUcError_None; } - + UUtError OGrGeomContext_Method_Geometry_PolyDraw( UUtUns32 inNumPoints, @@ -92,7 +92,7 @@ OGrGeomContext_Method_Geometry_PolyDraw( return UUcError_None; } - + UUtError OGrGeomContext_Method_Geometry_LineDraw( UUtUns32 inNumPoints, @@ -109,7 +109,7 @@ OGrGeomContext_Method_Geometry_PointDraw( M3tPoint3D* inPoints, UUtUns32 inShade) { - + return UUcError_None; } @@ -143,66 +143,66 @@ OGrGeomContext_Method_Sprite_Draw( OGLrCommon_Camera_Update(OGLcCameraMode_3D); M3rCamera_GetActive(&activeCamera); - + UUmAssert(activeCamera != NULL); - + M3rCamera_GetViewData_VxU(activeCamera, &cross); M3rCamera_GetViewData(activeCamera, NULL, NULL, &up); - + xr = cross.x * inHorizSize * OGcSpriteHorizWorldScale * 0.5f; yr = cross.y * inHorizSize * OGcSpriteHorizWorldScale * 0.5f; zr = cross.z * inHorizSize * OGcSpriteHorizWorldScale * 0.5f; - + xd = -up.x * inVertSize * OGcSpriteVertWorldScale * 0.5f; yd = -up.y * inVertSize * OGcSpriteVertWorldScale * 0.5f; zd = -up.z * inVertSize * OGcSpriteVertWorldScale * 0.5f; - + UUmAssert(UUmFloat_CompareEqu( MUrSqrt(cross.x * cross.x + cross.y * cross.y + cross.z * cross.z), 1.0f)); UUmAssert(UUmFloat_CompareEqu( MUrSqrt(up.x * up.x + up.y * up.y + up.z * up.z), 1.0f)); - + // tl tempPoints[0].x = inPoint->x - xr - xd; tempPoints[0].y = inPoint->y - yr - yd; tempPoints[0].z = inPoint->z - zr - zd; tempCoords[0].u = 0.0f; tempCoords[0].v = 1.0f; - + // tr tempPoints[1].x = inPoint->x + xr - xd; tempPoints[1].y = inPoint->y + yr - yd; tempPoints[1].z = inPoint->z + zr - zd; tempCoords[1].u = 1.0f; tempCoords[1].v = 1.0f; - + // br tempPoints[2].x = inPoint->x + xr + xd; tempPoints[2].y = inPoint->y + yr + yd; tempPoints[2].z = inPoint->z + zr + zd; tempCoords[2].u = 1.0f; tempCoords[2].v = 0.0f; - + // bl tempPoints[3].x = inPoint->x - xr + xd; tempPoints[3].y = inPoint->y - yr + yd; tempPoints[3].z = inPoint->z - zr + zd; tempCoords[3].u = 0.0f; tempCoords[3].v = 0.0f; - + OGLrCommon_glEnableClientState(GL_VERTEX_ARRAY); OGLrCommon_glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3, GL_FLOAT, 0, tempPoints); glTexCoordPointer(2, GL_FLOAT, 0, tempCoords); - + OGLrCommon_TextureMap_Select(inTextureMap, GL_TEXTURE0_ARB); - + glPushMatrix(); - + OGiMatrix_Update(); glDrawArrays(GL_POLYGON, 0, 4); - + glPopMatrix(); return UUcError_None; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Geometry.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Geometry.h index 386b673..f664474 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Geometry.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Geometry.h @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Geometry.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -31,7 +31,7 @@ OGrGeomContext_Method_Sprite_Draw( M3tMatrix3x3* inOrientation, float inXOffset, float inXShorten, - float inXChop); + float inXChop); UUtError OGrGeomContext_Method_Contrail_Draw( @@ -39,18 +39,18 @@ OGrGeomContext_Method_Contrail_Draw( float inV0, float inV1, M3tContrailData* inPoint0, - M3tContrailData* inPoint1); + M3tContrailData* inPoint1); UUtError OGrGeomContext_Method_Geometry_Draw( M3tGeometry* inGeometryObject); - + UUtError OGrGeomContext_Method_Geometry_PolyDraw( UUtUns32 inNumPoints, M3tPoint3D* inPoints, UUtUns32 inShade); - + UUtError OGrGeomContext_Method_Geometry_LineDraw( UUtUns32 inNumPoints, @@ -67,6 +67,6 @@ UUtBool OGrGeomContext_Method_PointVisible( M3tPoint3D* inPoint, float inTolerance); - + #endif /* OG_GC_METHOD_GEOMETRY_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Light.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Light.c index c5d46fe..b89fd4a 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Light.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Light.c @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Light.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Light.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Light.h index d4a996f..061088a 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Light.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Light.h @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Light.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Matrix.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Matrix.c index abb6dbb..6051a2d 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Matrix.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Matrix.c @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Matrix.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Matrix.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Matrix.h index 9b7c9a3..aa7b9e2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Matrix.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Matrix.h @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Matrix.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -61,30 +61,30 @@ OGrGeomContext_Method_MatrixStack_Multiply( void OGrGeomContext_Method_MatrixToQuat( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, M3tQuaternion *outQuat); void OGrGeomContext_Method_QuatToMatrix( - const M3tQuaternion *inQuat, + const M3tQuaternion *inQuat, M3tMatrix4x3 *outMatrix); -void +void OGrGeomContext_Method_Matrix_GetTranslation( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, M3tPoint3D *outTranslation); void OGrGeomContext_Method_Matrix_Multiply ( - const M3tMatrix4x3 *inMatrixA, - const M3tMatrix4x3 *inMatrixB, + const M3tMatrix4x3 *inMatrixA, + const M3tMatrix4x3 *inMatrixB, M3tMatrix4x3 *outResult); void OGrGeomContext_Method_Matrix_MultiplyPoints ( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, const UUtUns16 inNumPoints, - const M3tPoint3D *inPoint, + const M3tPoint3D *inPoint, M3tPoint3D *outPoint); void diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Pick.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Pick.c index f303a21..f20c0f1 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Pick.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Pick.c @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Pick.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Pick.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Pick.h index 44506b7..36f9e25 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Pick.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_Pick.h @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_Pick.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_State.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_State.c index 80b30d8..ce6acb4 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_State.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_State.c @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_State.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -37,7 +37,7 @@ UUtError OGrGeomContext_Method_State_Push( void) { - + return UUcError_None; } @@ -45,7 +45,7 @@ UUtError OGrGeomContext_Method_State_Pop( void) { - + return UUcError_None; } @@ -53,6 +53,6 @@ UUtError OGrGeomContext_Method_State_Commit( void) { - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_State.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_State.h index 3530253..7e083c9 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_State.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Method_State.h @@ -1,12 +1,12 @@ /* FILE: OG_GC_Method_State.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Private.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Private.h index ccdaded..1fccad7 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GC_Private.h @@ -1,12 +1,12 @@ /* FILE: OG_GC_Private.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -30,19 +30,19 @@ typedef struct OGtGeomContextPrivate OGtGeomContextPrivate; struct OGtGeomContextPrivate { M3tGeomContextMethods contextMethods; - + struct TMtCache_Simple* geometryCache; - + AKtEnvironment* environment; UUtUns32* evil_stateInt; - + M3tPoint3D tempPoints[OGcTempVertices_Num]; M3tTextureCoord tempBaseUVs[OGcTempVertices_Num]; M3tTextureCoord tempLightUVs[OGcTempVertices_Num]; M3tTextureMap* tempBaseMaps[OGcTempQuads_Num]; M3tTextureMap* tempLightMaps[OGcTempQuads_Num]; M3tTextureMap* tempCrudMaps[OGcTempQuads_Num]; - + }; extern OGtGeomContextPrivate OGgGeomContextPrivate; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GeomEngine_Method.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GeomEngine_Method.c index d14a931..c575e60 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GeomEngine_Method.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GeomEngine_Method.c @@ -1,12 +1,12 @@ /* FILE: OG_GeomEngine_Method.c - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -51,40 +51,40 @@ OGiCache_Geometry_Load( UUtUns32* curVertexPtr; UUtUns32 curIndex; M3tVector3D* curTriNormal; - + //COrConsole_Print("Loading geometry"); - + newIndex = glGenLists(1); if(newIndex == 0) UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "OGL: out of display lists"); - + OGLrCommon_glEnableClientState(GL_VERTEX_ARRAY); OGLrCommon_glEnableClientState(GL_TEXTURE_COORD_ARRAY); OGLrCommon_glEnableClientState(GL_NORMAL_ARRAY); - + OGLrCommon_glDisableClientState(GL_COLOR_ARRAY); OGLrCommon_glDisableClientState(GL_INDEX_ARRAY); OGLrCommon_glDisableClientState(GL_EDGE_FLAG_ARRAY); glNewList(newIndex, GL_COMPILE); - + glVertexPointer(3, GL_FLOAT, 0, geometry->pointArray->points); glNormalPointer(GL_FLOAT, 0, geometry->vertexNormalArray->vectors); glTexCoordPointer(2, GL_FLOAT, 0, geometry->texCoordArray->textureCoords); - + curVertexPtr = geometry->triStripArray->indices; lastVertexPtr = curVertexPtr + geometry->triStripArray->numIndices; curTriNormal = geometry->triNormalArray->vectors; - + glBegin(GL_TRIANGLE_STRIP); curIndex = *curVertexPtr++ & 0x7FFFFFFF; glArrayElement(curIndex); curIndex = *curVertexPtr++; glArrayElement(curIndex); - + while(curVertexPtr < lastVertexPtr) { curIndex = *curVertexPtr++; - + if(curIndex & 0x80000000) { glEnd(); @@ -95,17 +95,17 @@ OGiCache_Geometry_Load( glArrayElement(curIndex); curIndex = *curVertexPtr++; } - + glArrayElement(curIndex); } glEnd(); - + glEndList(); - + UUmAssert(glIsList(newIndex) == GL_TRUE); *outDataPtr = (void*)newIndex; - + return UUcError_None; } @@ -115,9 +115,9 @@ OGiCache_Geometry_Unload( void* inDataPtr) { //COrConsole_Print("Unoading geometry"); - + glDeleteLists((GLuint)inDataPtr, 1); - + } static UUtError @@ -126,7 +126,7 @@ OGiGeomEngine_Method_ContextPrivateNew( M3tGeomContextMethods* *outGeomContextFuncs) { UUtError error; - + /* * Initialize the methods */ @@ -147,19 +147,19 @@ OGiGeomEngine_Method_ContextPrivateNew( OGgGeomContextPrivate.contextMethods.envDrawGQList = OGrGeomContext_Method_Env_DrawGQList; OGgGeomContextPrivate.contextMethods.geometryDraw = OGrGeomContext_Method_Geometry_Draw; OGgGeomContextPrivate.contextMethods.pointVisible = OGrGeomContext_Method_PointVisible; - + OGgGeomContextPrivate.environment = NULL; - error = + error = TMrTemplate_Cache_Simple_New( M3cTemplate_Geometry, OGcMaxGeomEntries, OGiCache_Geometry_Load, OGiCache_Geometry_Unload, &OGgGeomContextPrivate.geometryCache); - + *outGeomContextFuncs = &OGgGeomContextPrivate.contextMethods; - + return UUcError_None; } @@ -175,7 +175,7 @@ OGiGeomEngine_Method_ContextSetEnvironment( struct AKtEnvironment* inEnvironment) { OGgGeomContextPrivate.environment = inEnvironment; - + return UUcError_None; } @@ -184,12 +184,12 @@ static UUtError OGiGeomEngine_Method_PrivateState_New( void* inState_Private) { - + return UUcError_None; } // This lets the engine delete a new private state structure -static void +static void OGiGeomEngine_Method_PrivateState_Delete( void* inState_Private) { @@ -203,16 +203,16 @@ OGiGeomEngine_Method_State_Update( UUtUns16 inState_IntFlags, const UUtInt32* inState_Int) { - + if(inState_IntFlags & (1 << M3cGeomStateIntType_Alpha)) { //float rgba[4]; - + //glGetFloatV(GL_CURRENT_COLOR, f); glColor4f(1.0, 1.0f, 1.0f, inState_Int[M3cGeomStateIntType_Alpha] * (1.0f / 255.0f)); - + } - + return UUcError_None; } @@ -240,26 +240,26 @@ OGrGeomEngine_Initialize( UUtUns16 numDrawEngines; UUtUns16 itrDrawEngine; M3tDrawEngineCaps* drawEngineCaps; - + geomEngineMethods.contextPrivateNew = OGiGeomEngine_Method_ContextPrivateNew; geomEngineMethods.contextPrivateDelete = OGiGeomEngine_Method_ContextPrivateDelete; geomEngineMethods.contextSetEnvironment = OGiGeomEngine_Method_ContextSetEnvironment; - + geomEngineMethods.privateStateSize = 0; geomEngineMethods.privateStateNew = OGiGeomEngine_Method_PrivateState_New; geomEngineMethods.privateStateDelete = OGiGeomEngine_Method_PrivateState_Delete; geomEngineMethods.privateStateUpdate = OGiGeomEngine_Method_State_Update; - + geomEngineMethods.cameraViewUpdate = OGiGeomEngine_Method_Camera_View_Update; geomEngineMethods.cameraStaticUpdate = OGiGeomEngine_Method_Camera_Static_Update; - + geomEngineCaps.engineFlags = M3tGeomEngineFlag_None; - + UUrString_Copy(geomEngineCaps.engineName, OGcGeomEngine_OpenGL, M3cMaxNameLen); geomEngineCaps.engineDriver[0] = 0; - + geomEngineCaps.engineVersion = OGcGeomVersion; - + // Find my compatable opengl draw engine numDrawEngines = M3rDrawEngine_GetNumber(); for(itrDrawEngine = 0; itrDrawEngine < numDrawEngines; itrDrawEngine++) @@ -267,18 +267,18 @@ OGrGeomEngine_Initialize( drawEngineCaps = M3rDrawEngine_GetCaps(itrDrawEngine); if(!strcmp(drawEngineCaps->engineName, M3cDrawEngine_OpenGL)) break; } - + // bail if we did not find the open gl draw engine if(itrDrawEngine >= numDrawEngines) return; - + geomEngineCaps.compatibleDrawEngineBV = 1 << itrDrawEngine; - + error = M3rManager_Register_GeomEngine(&geomEngineCaps, &geomEngineMethods); if(error != UUcError_None) { UUrError_Report(error, "Could not register motoko opengl geometry engine"); } - + } void diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GeomEngine_Method.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GeomEngine_Method.h index bb9ad3f..e9dc1ca 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GeomEngine_Method.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/GeomOpenGL/OG_GeomEngine_Method.h @@ -1,12 +1,12 @@ /* FILE: OG_GeomEngine_Method.h - + AUTHOR: Brent H. Pease - + CREATED: June 10, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Env_Clip.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Env_Clip.c index a459c5c..731449d 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Env_Clip.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Env_Clip.c @@ -1,12 +1,12 @@ /* FILE: MS_GC_Env_Clip.c - + AUTHOR: Brent H. Pease - + CREATED: Jan 14, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -130,7 +130,7 @@ static UUtUns32 iInterpShade_NoAlpha(UUtUns32 src, UUtUns32 dst, float in_t) static UUtBool MUrFrustumPoint_IsZero(M3tPoint4D *inPoint) { UUtBool is_zero = UUcTrue; - + is_zero &= UUmFloat_CompareEqu(inPoint->x, 0.f); is_zero &= UUmFloat_CompareEqu(inPoint->y, 0.f); is_zero &= UUmFloat_CompareEqu(inPoint->z, 0.f); @@ -142,17 +142,17 @@ static UUtBool MUrFrustumPoint_IsZero(M3tPoint4D *inPoint) static void MSrEnv_Clip_ComputeVertex_TriSplit( UUtUns32 inClipPlane, - + M3tTriSplit* inTriSplit, - + UUtUns32 inQSVertexIn0, UUtUns32 inQSVertexOut0, - + UUtUns32 inVIndexNew0, UUtUns32 inBaseUVIndexNew0, UUtUns32 *inShadeNew0, UUtUns8 *outClipCodeNew0, - + UUtUns32 inQSVertexIn1, UUtUns32 inQSVertexOut1, @@ -164,19 +164,19 @@ MSrEnv_Clip_ComputeVertex_TriSplit( M3tPoint4D* frustumPoints; M3tPointScreen* screenPoints; M3tTextureCoord* textureCoords; - + M3tPoint4D* frustumPointIn; M3tPoint4D* frustumPointOut; M3tPoint4D* frustumPointNew; - + M3tTextureCoord* textureCoordIn; M3tTextureCoord* textureCoordOut; M3tTextureCoord* textureCoordNew; - + M3tPointScreen* screenPointNew; - + float scaleX, scaleY; - + UUtUns8 newClipCode; float oneMinust, pIn, pOut, negW, invW; float hW, hX, hY, hZ; @@ -184,14 +184,14 @@ MSrEnv_Clip_ComputeVertex_TriSplit( float wIn, wOut; float t; UUtUns32 i; - + frustumPoints = MSgGeomContextPrivate->gqVertexData.frustumPoints; screenPoints = MSgGeomContextPrivate->gqVertexData.screenPoints; textureCoords = MSgGeomContextPrivate->gqVertexData.textureCoords; - + scaleX = MSgGeomContextPrivate->scaleX; scaleY = MSgGeomContextPrivate->scaleY; - + for(i = 0; i < 2; i++) { if(i == 0) @@ -208,113 +208,113 @@ MSrEnv_Clip_ComputeVertex_TriSplit( } UUmAssert(!MUrFrustumPoint_IsZero(frustumPointOut)); - + wIn = frustumPointIn->w; wOut = frustumPointOut->w; - - switch(inClipPlane) - { - case MScClipCode_PosX: - UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + + switch(inClipPlane) + { + case MScClipCode_PosX: + UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hX = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_NegX: - UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_NegX: + UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hX = -hW; + hX = -hW; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosY: - UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosY: + UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hY = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; break; - - case MScClipCode_NegY: - UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + + case MScClipCode_NegY: + UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; - hY = -hW; + hY = -hW; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosZ: - UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosZ: + UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = hW; - break; - - case MScClipCode_NegZ: - UUmAssert_Clip(frustumPointIn->z >= 0.0f); - UUmAssert_Clip(frustumPointOut->z < 0.0f); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = pIn / (pIn - pOut); - oneMinust = (1.0f - t); + hZ = hW; + break; + + case MScClipCode_NegZ: + UUmAssert_Clip(frustumPointIn->z >= 0.0f); + UUmAssert_Clip(frustumPointOut->z < 0.0f); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = pIn / (pIn - pOut); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = 0.0f; - break; + hZ = 0.0f; + break; } - + frustumPointNew->x = hX; frustumPointNew->y = hY; frustumPointNew->z = hZ; frustumPointNew->w = hW; - + if(i == 0) { textureCoordIn = textureCoords + inTriSplit->baseUVIndices.indices[inQSVertexIn0]; @@ -329,7 +329,7 @@ MSrEnv_Clip_ComputeVertex_TriSplit( } textureCoordNew->u = t * textureCoordOut->u + oneMinust * textureCoordIn->u; textureCoordNew->v = t * textureCoordOut->v + oneMinust * textureCoordIn->v; - + if(i == 0) { *inShadeNew0 = iInterpShade_NoAlpha(inTriSplit->shades[inQSVertexOut0], inTriSplit->shades[inQSVertexIn0], t); @@ -338,40 +338,40 @@ MSrEnv_Clip_ComputeVertex_TriSplit( { *inShadeNew1 = iInterpShade_NoAlpha(inTriSplit->shades[inQSVertexOut1], inTriSplit->shades[inQSVertexIn1], t); } - + negW = -hW; newClipCode = MScClipCode_None; - + if(hX > hW) { newClipCode |= MScClipCode_PosX; } - + if(hX < negW) { newClipCode |= MScClipCode_NegX; } - + if(hY > hW) { newClipCode |= MScClipCode_PosY; } - + if(hY < negW) { newClipCode |= MScClipCode_NegY; } - + if(hZ > hW) { newClipCode |= MScClipCode_PosZ; } - + if(hZ < 0.0) { newClipCode |= MScClipCode_NegZ; } - + if(i == 0) { screenPointNew = screenPoints + inVIndexNew0; @@ -380,7 +380,7 @@ MSrEnv_Clip_ComputeVertex_TriSplit( { screenPointNew = screenPoints + inVIndexNew1; } - + MSrClipCode_ValidateFrustum(frustumPointNew, newClipCode); if(newClipCode == 0) @@ -394,7 +394,7 @@ MSrEnv_Clip_ComputeVertex_TriSplit( { screenPointNew->x = (hX * invW + 1.0f) * scaleX; } - + if(hY == hW) { screenPointNew->y = 0.0f; @@ -403,13 +403,13 @@ MSrEnv_Clip_ComputeVertex_TriSplit( { screenPointNew->y = (hY * invW - 1.0f) * scaleY; } - + screenPointNew->z = hZ * invW; screenPointNew->invW = invW; - + MSiVerifyPointScreen(screenPointNew); } - + if(i == 0) { *outClipCodeNew0 = newClipCode; @@ -424,17 +424,17 @@ MSrEnv_Clip_ComputeVertex_TriSplit( static void MSrEnv_Clip_ComputeVertex_QuadSplit( UUtUns32 inClipPlane, - + M3tQuadSplit* inQuadSplit, - + UUtUns32 inQSVertexIn0, UUtUns32 inQSVertexOut0, - + UUtUns32 inVIndexNew0, UUtUns32 inBaseUVIndexNew0, UUtUns32 *inShadeNew0, UUtUns8 *outClipCodeNew0, - + UUtUns32 inQSVertexIn1, UUtUns32 inQSVertexOut1, @@ -446,19 +446,19 @@ MSrEnv_Clip_ComputeVertex_QuadSplit( M3tPoint4D* frustumPoints; M3tPointScreen* screenPoints; M3tTextureCoord* textureCoords; - + M3tPoint4D* frustumPointIn; M3tPoint4D* frustumPointOut; M3tPoint4D* frustumPointNew; - + M3tTextureCoord* textureCoordIn; M3tTextureCoord* textureCoordOut; M3tTextureCoord* textureCoordNew; - + M3tPointScreen* screenPointNew; - + float scaleX, scaleY; - + UUtUns8 newClipCode; float oneMinust, pIn, pOut, negW, invW; float hW, hX, hY, hZ; @@ -466,14 +466,14 @@ MSrEnv_Clip_ComputeVertex_QuadSplit( float wIn, wOut; float t; UUtUns32 i; - + frustumPoints = MSgGeomContextPrivate->gqVertexData.frustumPoints; screenPoints = MSgGeomContextPrivate->gqVertexData.screenPoints; textureCoords = MSgGeomContextPrivate->gqVertexData.textureCoords; - + scaleX = MSgGeomContextPrivate->scaleX; scaleY = MSgGeomContextPrivate->scaleY; - + for(i = 0; i < 2; i++) { if(i == 0) @@ -488,113 +488,113 @@ MSrEnv_Clip_ComputeVertex_QuadSplit( frustumPointOut = frustumPoints + inQuadSplit->vertexIndices.indices[inQSVertexOut1]; frustumPointNew = frustumPoints + inVIndexNew1; } - + wIn = frustumPointIn->w; wOut = frustumPointOut->w; - - switch(inClipPlane) - { - case MScClipCode_PosX: - UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + + switch(inClipPlane) + { + case MScClipCode_PosX: + UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hX = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_NegX: - UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_NegX: + UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hX = -hW; + hX = -hW; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosY: - UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosY: + UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hY = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; break; - - case MScClipCode_NegY: - UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + + case MScClipCode_NegY: + UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; - hY = -hW; + hY = -hW; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosZ: - UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosZ: + UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = hW; - break; - - case MScClipCode_NegZ: - UUmAssert_Clip(frustumPointIn->z >= 0.0f); - UUmAssert_Clip(frustumPointOut->z < 0.0f); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = pIn / (pIn - pOut); - oneMinust = (1.0f - t); + hZ = hW; + break; + + case MScClipCode_NegZ: + UUmAssert_Clip(frustumPointIn->z >= 0.0f); + UUmAssert_Clip(frustumPointOut->z < 0.0f); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = pIn / (pIn - pOut); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = 0.0f; - break; + hZ = 0.0f; + break; } - + frustumPointNew->x = hX; frustumPointNew->y = hY; frustumPointNew->z = hZ; frustumPointNew->w = hW; - + if(i == 0) { textureCoordIn = textureCoords + inQuadSplit->baseUVIndices.indices[inQSVertexIn0]; @@ -609,7 +609,7 @@ MSrEnv_Clip_ComputeVertex_QuadSplit( } textureCoordNew->u = t * textureCoordOut->u + oneMinust * textureCoordIn->u; textureCoordNew->v = t * textureCoordOut->v + oneMinust * textureCoordIn->v; - + if(i == 0) { *inShadeNew0 = iInterpShade_NoAlpha(inQuadSplit->shades[inQSVertexOut0], inQuadSplit->shades[inQSVertexIn0], t); @@ -618,40 +618,40 @@ MSrEnv_Clip_ComputeVertex_QuadSplit( { *inShadeNew1 = iInterpShade_NoAlpha(inQuadSplit->shades[inQSVertexOut1], inQuadSplit->shades[inQSVertexIn1], t); } - + negW = -hW; newClipCode = MScClipCode_None; - + if(hX > hW) { newClipCode |= MScClipCode_PosX; } - + if(hX < negW) { newClipCode |= MScClipCode_NegX; } - + if(hY > hW) { newClipCode |= MScClipCode_PosY; } - + if(hY < negW) { newClipCode |= MScClipCode_NegY; } - + if(hZ > hW) { newClipCode |= MScClipCode_PosZ; } - + if(hZ < 0.0) { newClipCode |= MScClipCode_NegZ; } - + if(i == 0) { screenPointNew = screenPoints + inVIndexNew0; @@ -660,7 +660,7 @@ MSrEnv_Clip_ComputeVertex_QuadSplit( { screenPointNew = screenPoints + inVIndexNew1; } - + MSrClipCode_ValidateFrustum(frustumPointNew, newClipCode); if(newClipCode == 0) @@ -674,7 +674,7 @@ MSrEnv_Clip_ComputeVertex_QuadSplit( { screenPointNew->x = (hX * invW + 1.0f) * scaleX; } - + if(hY == hW) { screenPointNew->y = 0.0f; @@ -683,13 +683,13 @@ MSrEnv_Clip_ComputeVertex_QuadSplit( { screenPointNew->y = (hY * invW - 1.0f) * scaleY; } - + screenPointNew->z = hZ * invW; screenPointNew->invW = invW; - + MSiVerifyPointScreen(screenPointNew); } - + if(i == 0) { *outClipCodeNew0 = newClipCode; @@ -716,15 +716,15 @@ MSrEnv_Clip_Tri( UUtUns8 newClipCode0; UUtUns8 newClipCode1; - UUtUns32 newVIndex0; - UUtUns32 newVIndex1; + UUtUns32 newVIndex0; + UUtUns32 newVIndex1; UUtUns32 newBaseUVIndex0; UUtUns32 newBaseUVIndex1; UUtInt32 i; UUtUns8 curClipPlane; - + M3tTriSplit newTriSplit; M3tQuadSplit newQuadSplit; @@ -732,22 +732,22 @@ MSrEnv_Clip_Tri( UUmAssert(!MUrFrustumPoint_IsZero(MSgGeomContextPrivate->gqVertexData.frustumPoints + inTriSplit->vertexIndices.indices[0])); UUmAssert(!MUrFrustumPoint_IsZero(MSgGeomContextPrivate->gqVertexData.frustumPoints + inTriSplit->vertexIndices.indices[1])); UUmAssert(!MUrFrustumPoint_IsZero(MSgGeomContextPrivate->gqVertexData.frustumPoints + inTriSplit->vertexIndices.indices[2])); - + if(inClipCode0 & inClipCode1 & inClipCode2) { return; } - + newVIndex0 = MSgGeomContextPrivate->gqVertexData.newClipVertexIndex++; newVIndex1 = MSgGeomContextPrivate->gqVertexData.newClipVertexIndex++; - + UUmAssert(MSgGeomContextPrivate->gqVertexData.newClipVertexIndex <= MSgGeomContextPrivate->gqVertexData.maxClipVertices); - + newBaseUVIndex0 = MSgGeomContextPrivate->gqVertexData.newClipTextureIndex++; newBaseUVIndex1 = MSgGeomContextPrivate->gqVertexData.newClipTextureIndex++; - + UUmAssert(MSgGeomContextPrivate->gqVertexData.newClipTextureIndex <= MSgGeomContextPrivate->gqVertexData.maxClipTextureCords); - + for(i = 6; i-- > 0;) { curClipPlane = (UUtUns8)(1 << i); @@ -755,17 +755,17 @@ MSrEnv_Clip_Tri( { continue; } - - if(curClipPlane & inClipCode0) - { - /* 0: Out, 1: ?, 2: ? */ - if(curClipPlane & inClipCode1) - { - /* 0: Out, 1: Out, 2: In */ - UUmAssert(!(curClipPlane & inClipCode2)); - - /* Compute 2 -> 0 intersection */ - /* Compute 2 -> 1 intersection */ + + if(curClipPlane & inClipCode0) + { + /* 0: Out, 1: ?, 2: ? */ + if(curClipPlane & inClipCode1) + { + /* 0: Out, 1: Out, 2: In */ + UUmAssert(!(curClipPlane & inClipCode2)); + + /* Compute 2 -> 0 intersection */ + /* Compute 2 -> 1 intersection */ MSrEnv_Clip_ComputeVertex_TriSplit( curClipPlane, inTriSplit, @@ -773,18 +773,18 @@ MSrEnv_Clip_Tri( newVIndex0, newBaseUVIndex0, &newTriSplit.shades[1], &newClipCode0, 2, 1, newVIndex1, newBaseUVIndex1, &newTriSplit.shades[2], &newClipCode1); - + newTriSplit.vertexIndices.indices[0] = inTriSplit->vertexIndices.indices[2]; newTriSplit.baseUVIndices.indices[0] = inTriSplit->baseUVIndices.indices[2]; newTriSplit.shades[0] = inTriSplit->shades[2]; - + newTriSplit.vertexIndices.indices[1] = newVIndex0; newTriSplit.baseUVIndices.indices[1] = newBaseUVIndex0; - + newTriSplit.vertexIndices.indices[2] = newVIndex1; newTriSplit.baseUVIndices.indices[2] = newBaseUVIndex1; - - /* Check for trivial accept on 2, new0, new1 */ + + /* Check for trivial accept on 2, new0, new1 */ if(inClipCode2 | newClipCode0 | newClipCode1) { MSrEnv_Clip_Tri( @@ -797,18 +797,18 @@ MSrEnv_Clip_Tri( M3rDraw_Triangle( &newTriSplit); } - - return; - } - else - { - /* 0: Out, 1: in, 2: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: Out, 1: In, 2: Out */ - - /* Compute 1 -> 0 Intersection */ - /* Compute 1 -> 2 Intersection */ + + return; + } + else + { + /* 0: Out, 1: in, 2: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: Out, 1: In, 2: Out */ + + /* Compute 1 -> 0 Intersection */ + /* Compute 1 -> 2 Intersection */ MSrEnv_Clip_ComputeVertex_TriSplit( curClipPlane, inTriSplit, @@ -816,17 +816,17 @@ MSrEnv_Clip_Tri( newVIndex0, newBaseUVIndex0, &newTriSplit.shades[2], &newClipCode0, 1, 2, newVIndex1, newBaseUVIndex1, &newTriSplit.shades[1], &newClipCode1); - + newTriSplit.vertexIndices.indices[0] = inTriSplit->vertexIndices.indices[1]; newTriSplit.baseUVIndices.indices[0] = inTriSplit->baseUVIndices.indices[1]; newTriSplit.shades[0] = inTriSplit->shades[1]; - + newTriSplit.vertexIndices.indices[1] = newVIndex1; newTriSplit.baseUVIndices.indices[1] = newBaseUVIndex1; - + newTriSplit.vertexIndices.indices[2] = newVIndex0; newTriSplit.baseUVIndices.indices[2] = newBaseUVIndex0; - + /* Check for trivial accept on 1, new1, new0 */ if(inClipCode1 | newClipCode1 | newClipCode0) { @@ -840,15 +840,15 @@ MSrEnv_Clip_Tri( M3rDraw_Triangle( &newTriSplit); } - - return; - } - else - { - /* 0: Out, 1: In, 2: In */ - - /* Compute 1 -> 0 intersection */ - /* Compute 2 -> 0 intersection */ + + return; + } + else + { + /* 0: Out, 1: In, 2: In */ + + /* Compute 1 -> 0 intersection */ + /* Compute 2 -> 0 intersection */ MSrEnv_Clip_ComputeVertex_TriSplit( curClipPlane, inTriSplit, @@ -856,22 +856,22 @@ MSrEnv_Clip_Tri( newVIndex0, newBaseUVIndex0, &newQuadSplit.shades[3], &newClipCode0, 2, 0, newVIndex1, newBaseUVIndex1, &newQuadSplit.shades[2], &newClipCode1); - + newQuadSplit.vertexIndices.indices[0] = inTriSplit->vertexIndices.indices[1]; newQuadSplit.baseUVIndices.indices[0] = inTriSplit->baseUVIndices.indices[1]; newQuadSplit.shades[0] = inTriSplit->shades[1]; - + newQuadSplit.vertexIndices.indices[1] = inTriSplit->vertexIndices.indices[2]; newQuadSplit.baseUVIndices.indices[1] = inTriSplit->baseUVIndices.indices[2]; newQuadSplit.shades[1] = inTriSplit->shades[2]; - + newQuadSplit.vertexIndices.indices[2] = newVIndex1; newQuadSplit.baseUVIndices.indices[2] = newBaseUVIndex1; - + newQuadSplit.vertexIndices.indices[3] = newVIndex0; newQuadSplit.baseUVIndices.indices[3] = newBaseUVIndex0; - /* Check for trivial accept on 1, 2, new1, new0 */ + /* Check for trivial accept on 1, 2, new1, new0 */ if(inClipCode1 | inClipCode2 | newClipCode1 | newClipCode0) { MSrEnv_Clip_Quad( @@ -884,23 +884,23 @@ MSrEnv_Clip_Tri( M3rDraw_Quad( &newQuadSplit); } - - return; - } + + return; + } } } - else - { - /* 0: In, 1: ?, 2: ? */ - if(curClipPlane & inClipCode1) - { - /* 0: In, 1: Out, 2: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: In, 1: Out, 2: Out */ - - /* Compute 0 -> 1 intersection */ - /* Compute 0 -> 2 intersection */ + else + { + /* 0: In, 1: ?, 2: ? */ + if(curClipPlane & inClipCode1) + { + /* 0: In, 1: Out, 2: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: In, 1: Out, 2: Out */ + + /* Compute 0 -> 1 intersection */ + /* Compute 0 -> 2 intersection */ MSrEnv_Clip_ComputeVertex_TriSplit( curClipPlane, inTriSplit, @@ -908,14 +908,14 @@ MSrEnv_Clip_Tri( newVIndex0, newBaseUVIndex0, &newTriSplit.shades[1], &newClipCode0, 0, 2, newVIndex1, newBaseUVIndex1, &newTriSplit.shades[2], &newClipCode1); - + newTriSplit.vertexIndices.indices[0] = inTriSplit->vertexIndices.indices[0]; newTriSplit.baseUVIndices.indices[0] = inTriSplit->baseUVIndices.indices[0]; newTriSplit.shades[0] = inTriSplit->shades[0]; - + newTriSplit.vertexIndices.indices[1] = newVIndex0; newTriSplit.baseUVIndices.indices[1] = newBaseUVIndex0; - + newTriSplit.vertexIndices.indices[2] = newVIndex1; newTriSplit.baseUVIndices.indices[2] = newBaseUVIndex1; @@ -932,15 +932,15 @@ MSrEnv_Clip_Tri( M3rDraw_Triangle( &newTriSplit); } - - return; - } - else - { - /* 0: In, 1: Out, 2: In */ - - /* Compute 0 -> 1 intersection */ - /* Compute 2 -> 1 intersection */ + + return; + } + else + { + /* 0: In, 1: Out, 2: In */ + + /* Compute 0 -> 1 intersection */ + /* Compute 2 -> 1 intersection */ MSrEnv_Clip_ComputeVertex_TriSplit( curClipPlane, inTriSplit, @@ -952,18 +952,18 @@ MSrEnv_Clip_Tri( newQuadSplit.vertexIndices.indices[0] = inTriSplit->vertexIndices.indices[2]; newQuadSplit.baseUVIndices.indices[0] = inTriSplit->baseUVIndices.indices[2]; newQuadSplit.shades[0] = inTriSplit->shades[2]; - + newQuadSplit.vertexIndices.indices[1] = inTriSplit->vertexIndices.indices[0]; newQuadSplit.baseUVIndices.indices[1] = inTriSplit->baseUVIndices.indices[0]; newQuadSplit.shades[1] = inTriSplit->shades[0]; - + newQuadSplit.vertexIndices.indices[2] = newVIndex0; newQuadSplit.baseUVIndices.indices[2] = newBaseUVIndex0; - + newQuadSplit.vertexIndices.indices[3] = newVIndex1; newQuadSplit.baseUVIndices.indices[3] = newBaseUVIndex1; - /* Check for trivial accept on 2, 0, new0, new1 */ + /* Check for trivial accept on 2, 0, new0, new1 */ if(inClipCode2 | inClipCode0 | newClipCode0 | newClipCode1) { MSrEnv_Clip_Quad( @@ -976,20 +976,20 @@ MSrEnv_Clip_Tri( M3rDraw_Quad( &newQuadSplit); } - - return; - } - - } - else - { - /* 0: In, 1: in, 2: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: In, 1: in, 2: Out */ - - /* Compute 0 -> 2 intersection */ - /* Compute 1 -> 2 intersection */ + + return; + } + + } + else + { + /* 0: In, 1: in, 2: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: In, 1: in, 2: Out */ + + /* Compute 0 -> 2 intersection */ + /* Compute 1 -> 2 intersection */ MSrEnv_Clip_ComputeVertex_TriSplit( curClipPlane, inTriSplit, @@ -997,22 +997,22 @@ MSrEnv_Clip_Tri( newVIndex0, newBaseUVIndex0, &newQuadSplit.shades[3], &newClipCode0, 1, 2, newVIndex1, newBaseUVIndex1, &newQuadSplit.shades[2], &newClipCode1); - + newQuadSplit.vertexIndices.indices[0] = inTriSplit->vertexIndices.indices[0]; newQuadSplit.baseUVIndices.indices[0] = inTriSplit->baseUVIndices.indices[0]; newQuadSplit.shades[0] = inTriSplit->shades[0]; - + newQuadSplit.vertexIndices.indices[1] = inTriSplit->vertexIndices.indices[1]; newQuadSplit.baseUVIndices.indices[1] = inTriSplit->baseUVIndices.indices[1]; newQuadSplit.shades[1] = inTriSplit->shades[1]; - + newQuadSplit.vertexIndices.indices[2] = newVIndex1; newQuadSplit.baseUVIndices.indices[2] = newBaseUVIndex1; - + newQuadSplit.vertexIndices.indices[3] = newVIndex0; newQuadSplit.baseUVIndices.indices[3] = newBaseUVIndex0; - /* Check for trivial accept on 0, 1, new1, new0 */ + /* Check for trivial accept on 0, 1, new1, new0 */ if(inClipCode0 | inClipCode1 | newClipCode1 | newClipCode0) { MSrEnv_Clip_Quad( @@ -1025,11 +1025,11 @@ MSrEnv_Clip_Tri( M3rDraw_Quad( &newQuadSplit); } - - return; - } - /* else all are in */ - } + + return; + } + /* else all are in */ + } } } @@ -1049,8 +1049,8 @@ MSrEnv_Clip_Quad( UUtUns8 newClipCode0; UUtUns8 newClipCode1; - UUtUns32 newVIndex0; - UUtUns32 newVIndex1; + UUtUns32 newVIndex0; + UUtUns32 newVIndex1; UUtUns32 newBaseUVIndex0; UUtUns32 newBaseUVIndex1; @@ -1058,7 +1058,7 @@ MSrEnv_Clip_Quad( M3tTriSplit newTriSplit; M3tQuadSplit newQuadSplit; M3tPentSplit newPentSplit; - + UUtInt32 i; UUtUns8 curClipPlane; @@ -1071,17 +1071,17 @@ MSrEnv_Clip_Quad( { return; } - + newVIndex0 = MSgGeomContextPrivate->gqVertexData.newClipVertexIndex++; newVIndex1 = MSgGeomContextPrivate->gqVertexData.newClipVertexIndex++; - + UUmAssert(MSgGeomContextPrivate->gqVertexData.newClipVertexIndex <= MSgGeomContextPrivate->gqVertexData.maxClipVertices); - + newBaseUVIndex0 = MSgGeomContextPrivate->gqVertexData.newClipTextureIndex++; newBaseUVIndex1 = MSgGeomContextPrivate->gqVertexData.newClipTextureIndex++; UUmAssert(MSgGeomContextPrivate->gqVertexData.newClipTextureIndex <= MSgGeomContextPrivate->gqVertexData.maxClipTextureCords); - + for(i = 6; i-- > 0;) { curClipPlane = (UUtUns8)(1 << i); @@ -1089,19 +1089,19 @@ MSrEnv_Clip_Quad( { continue; } - - if(curClipPlane & inClipCode0) - { - /* 0: Out, 1: ?, 2: ?, 3: ? */ - if(curClipPlane & inClipCode1) - { - /* 0: Out, 1: Out, 2: ?, 3: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: Out, 1: Out, 2: Out, 3: In */ - //UUmAssert(!(curClipPlane & inClipCode3)); - /* Compute 3 -> 0 intersection */ - /* Compute 3 -> 2 intersection */ + + if(curClipPlane & inClipCode0) + { + /* 0: Out, 1: ?, 2: ?, 3: ? */ + if(curClipPlane & inClipCode1) + { + /* 0: Out, 1: Out, 2: ?, 3: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: Out, 1: Out, 2: Out, 3: In */ + //UUmAssert(!(curClipPlane & inClipCode3)); + /* Compute 3 -> 0 intersection */ + /* Compute 3 -> 2 intersection */ MSrEnv_Clip_ComputeVertex_QuadSplit( curClipPlane, inQuadSplit, @@ -1109,17 +1109,17 @@ MSrEnv_Clip_Quad( newVIndex0, newBaseUVIndex0, &newTriSplit.shades[1], &newClipCode0, 3, 2, newVIndex1, newBaseUVIndex1, &newTriSplit.shades[2], &newClipCode1); - + newTriSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[3]; newTriSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[3]; newTriSplit.shades[0] = inQuadSplit->shades[3]; - + newTriSplit.vertexIndices.indices[1] = newVIndex0; newTriSplit.baseUVIndices.indices[1] = newBaseUVIndex0; - + newTriSplit.vertexIndices.indices[2] = newVIndex1; newTriSplit.baseUVIndices.indices[2] = newBaseUVIndex1; - + /* Check for trivial accept on 3, new0, new1 */ if(inClipCode3 | newClipCode0 | newClipCode1) { @@ -1134,15 +1134,15 @@ MSrEnv_Clip_Quad( &newTriSplit); } return; - } - else - { - /* 0: Out, 1: Out, 2: In, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: Out, 1: Out, 2: In, 3: Out */ - /* Compute 2 -> 1 intersection */ - /* Compute 2 -> 3 intersection */ + } + else + { + /* 0: Out, 1: Out, 2: In, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: Out, 1: Out, 2: In, 3: Out */ + /* Compute 2 -> 1 intersection */ + /* Compute 2 -> 3 intersection */ MSrEnv_Clip_ComputeVertex_QuadSplit( curClipPlane, inQuadSplit, @@ -1154,14 +1154,14 @@ MSrEnv_Clip_Quad( newTriSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[2]; newTriSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[2]; newTriSplit.shades[0] = inQuadSplit->shades[2]; - + newTriSplit.vertexIndices.indices[1] = newVIndex1; newTriSplit.baseUVIndices.indices[1] = newBaseUVIndex1; - + newTriSplit.vertexIndices.indices[2] = newVIndex0; newTriSplit.baseUVIndices.indices[2] = newBaseUVIndex0; - /* Check for trivial accept on 2, new1, new0 */ + /* Check for trivial accept on 2, new1, new0 */ if(inClipCode2 | newClipCode1 | newClipCode0) { MSrEnv_Clip_Tri( @@ -1175,12 +1175,12 @@ MSrEnv_Clip_Quad( &newTriSplit); } return; - } - else - { - /* 0: Out, 1: Out, 2: In, 3: In */ - /* Compute 2 -> 1 intersection */ - /* Compute 3 -> 0 intersection */ + } + else + { + /* 0: Out, 1: Out, 2: In, 3: In */ + /* Compute 2 -> 1 intersection */ + /* Compute 3 -> 0 intersection */ MSrEnv_Clip_ComputeVertex_QuadSplit( curClipPlane, inQuadSplit, @@ -1192,14 +1192,14 @@ MSrEnv_Clip_Quad( newQuadSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[2]; newQuadSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[2]; newQuadSplit.shades[0] = inQuadSplit->shades[2]; - + newQuadSplit.vertexIndices.indices[1] = inQuadSplit->vertexIndices.indices[3]; newQuadSplit.baseUVIndices.indices[1] = inQuadSplit->baseUVIndices.indices[3]; newQuadSplit.shades[1] = inQuadSplit->shades[3]; - + newQuadSplit.vertexIndices.indices[2] = newVIndex1; newQuadSplit.baseUVIndices.indices[2] = newBaseUVIndex1; - + newQuadSplit.vertexIndices.indices[3] = newVIndex0; newQuadSplit.baseUVIndices.indices[3] = newBaseUVIndex0; @@ -1217,18 +1217,18 @@ MSrEnv_Clip_Quad( &newQuadSplit); } return; - } - } - } - else - { - /* 0: Out, 1: In, 2: ?, 3: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: Out, 1: In, 2: Out, 3: Out */ - //UUmAssert(curClipPlane & inClipCode3); - /* Compute 1 -> 0 intersection */ - /* Compute 1 -> 2 intersection */ + } + } + } + else + { + /* 0: Out, 1: In, 2: ?, 3: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: Out, 1: In, 2: Out, 3: Out */ + //UUmAssert(curClipPlane & inClipCode3); + /* Compute 1 -> 0 intersection */ + /* Compute 1 -> 2 intersection */ MSrEnv_Clip_ComputeVertex_QuadSplit( curClipPlane, inQuadSplit, @@ -1240,14 +1240,14 @@ MSrEnv_Clip_Quad( newTriSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[1]; newTriSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[1]; newTriSplit.shades[0] = inQuadSplit->shades[1]; - + newTriSplit.vertexIndices.indices[1] = newVIndex1; newTriSplit.baseUVIndices.indices[1] = newBaseUVIndex1; - + newTriSplit.vertexIndices.indices[2] = newVIndex0; newTriSplit.baseUVIndices.indices[2] = newBaseUVIndex0; - - /* Check for trivial accept on 1, new1, new0 */ + + /* Check for trivial accept on 1, new1, new0 */ if(inClipCode1 | newClipCode1 | newClipCode0) { MSrEnv_Clip_Tri( @@ -1261,15 +1261,15 @@ MSrEnv_Clip_Quad( &newTriSplit); } return; - } - else - { - /* 0: Out, 1: In, 2: In, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: Out, 1: In, 2: In, 3: Out */ - /* Compute 1 -> 0 intersection */ - /* Compute 2 -> 3 intersection */ + } + else + { + /* 0: Out, 1: In, 2: In, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: Out, 1: In, 2: In, 3: Out */ + /* Compute 1 -> 0 intersection */ + /* Compute 2 -> 3 intersection */ MSrEnv_Clip_ComputeVertex_QuadSplit( curClipPlane, inQuadSplit, @@ -1281,14 +1281,14 @@ MSrEnv_Clip_Quad( newQuadSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[1]; newQuadSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[1]; newQuadSplit.shades[0] = inQuadSplit->shades[1]; - + newQuadSplit.vertexIndices.indices[1] = inQuadSplit->vertexIndices.indices[2]; newQuadSplit.baseUVIndices.indices[1] = inQuadSplit->baseUVIndices.indices[2]; newQuadSplit.shades[1] = inQuadSplit->shades[2]; - + newQuadSplit.vertexIndices.indices[2] = newVIndex1; newQuadSplit.baseUVIndices.indices[2] = newBaseUVIndex1; - + newQuadSplit.vertexIndices.indices[3] = newVIndex0; newQuadSplit.baseUVIndices.indices[3] = newBaseUVIndex0; @@ -1307,12 +1307,12 @@ MSrEnv_Clip_Quad( } return; - } - else - { - /* 0: Out, 1: In, 2: In, 3: In */ - /* Compute 1 -> 0 intersection */ - /* Compute 3 -> 0 intersection */ + } + else + { + /* 0: Out, 1: In, 2: In, 3: In */ + /* Compute 1 -> 0 intersection */ + /* Compute 3 -> 0 intersection */ MSrEnv_Clip_ComputeVertex_QuadSplit( curClipPlane, inQuadSplit, @@ -1327,14 +1327,14 @@ MSrEnv_Clip_Quad( newQuadSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[1]; newQuadSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[1]; newQuadSplit.shades[0] = inQuadSplit->shades[1]; - + newQuadSplit.vertexIndices.indices[1] = inQuadSplit->vertexIndices.indices[2]; newQuadSplit.baseUVIndices.indices[1] = inQuadSplit->baseUVIndices.indices[2]; newQuadSplit.shades[1] = inQuadSplit->shades[2]; - + newQuadSplit.vertexIndices.indices[2] = inQuadSplit->vertexIndices.indices[3]; newQuadSplit.baseUVIndices.indices[2] = inQuadSplit->baseUVIndices.indices[3]; - newQuadSplit.shades[2] = inQuadSplit->shades[3]; + newQuadSplit.shades[2] = inQuadSplit->shades[3]; newQuadSplit.vertexIndices.indices[3] = newVIndex1; newQuadSplit.baseUVIndices.indices[3] = newBaseUVIndex1; @@ -1352,15 +1352,15 @@ MSrEnv_Clip_Quad( M3rDraw_Quad( &newQuadSplit); } - + newTriSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[1]; newTriSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[1]; newTriSplit.shades[0] = inQuadSplit->shades[1]; - + newTriSplit.vertexIndices.indices[1] = newVIndex1; newTriSplit.baseUVIndices.indices[1] = newBaseUVIndex1; newTriSplit.shades[1] = newPentSplit.shades[3]; - + newTriSplit.vertexIndices.indices[2] = newVIndex0; newTriSplit.baseUVIndices.indices[2] = newBaseUVIndex0; newTriSplit.shades[2] = newPentSplit.shades[4]; @@ -1383,19 +1383,19 @@ MSrEnv_Clip_Quad( newPentSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[1]; newPentSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[1]; newPentSplit.shades[0] = inQuadSplit->shades[1]; - + newPentSplit.vertexIndices.indices[1] = inQuadSplit->vertexIndices.indices[2]; newPentSplit.baseUVIndices.indices[1] = inQuadSplit->baseUVIndices.indices[2]; newPentSplit.shades[1] = inQuadSplit->shades[2]; - + newPentSplit.vertexIndices.indices[2] = inQuadSplit->vertexIndices.indices[3]; newPentSplit.baseUVIndices.indices[2] = inQuadSplit->baseUVIndices.indices[3]; newPentSplit.shades[2] = inQuadSplit->shades[3]; - + newPentSplit.vertexIndices.indices[3] = newVIndex1; newPentSplit.baseUVIndices.indices[3] = newBaseUVIndex1; newPentSplit.shades[3] = newPentSplit.shades[3]; - + newPentSplit.vertexIndices.indices[4] = newVIndex0; newPentSplit.baseUVIndices.indices[4] = newBaseUVIndex0; newPentSplit.shades[4] = newPentSplit.shades[4]; @@ -1403,26 +1403,26 @@ MSrEnv_Clip_Quad( M3rDraw_Pent( &newPentSplit); } - + return; - } - } - } - } - else - { - /* 0: In, 1: ?, 2: ?, 3: ? */ - if(curClipPlane & inClipCode1) - { - /* 0: In, 1: Out, 2: ?, 3: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: In, 1: Out, 2: Out, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: In, 1: Out, 2: Out, 3: Out */ - /* Compute 0 -> 3 intersection */ - /* Compute 0 -> 1 intersection */ + } + } + } + } + else + { + /* 0: In, 1: ?, 2: ?, 3: ? */ + if(curClipPlane & inClipCode1) + { + /* 0: In, 1: Out, 2: ?, 3: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: In, 1: Out, 2: Out, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: In, 1: Out, 2: Out, 3: Out */ + /* Compute 0 -> 3 intersection */ + /* Compute 0 -> 1 intersection */ MSrEnv_Clip_ComputeVertex_QuadSplit( curClipPlane, inQuadSplit, @@ -1434,14 +1434,14 @@ MSrEnv_Clip_Quad( newTriSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[0]; newTriSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[0]; newTriSplit.shades[0] = inQuadSplit->shades[0]; - + newTriSplit.vertexIndices.indices[1] = newVIndex1; newTriSplit.baseUVIndices.indices[1] = newBaseUVIndex1; - + newTriSplit.vertexIndices.indices[2] = newVIndex0; newTriSplit.baseUVIndices.indices[2] = newBaseUVIndex0; - /* Check for trivial accept on 0, new1, new0 */ + /* Check for trivial accept on 0, new1, new0 */ if(inClipCode0 | newClipCode1 | newClipCode0) { MSrEnv_Clip_Tri( @@ -1455,12 +1455,12 @@ MSrEnv_Clip_Quad( &newTriSplit); } return; - } - else - { - /* 0: In, 1: Out, 2: Out, 3: In */ - /* Compute 3 -> 2 intersection */ - /* Compute 0 -> 1 intersection */ + } + else + { + /* 0: In, 1: Out, 2: Out, 3: In */ + /* Compute 3 -> 2 intersection */ + /* Compute 0 -> 1 intersection */ MSrEnv_Clip_ComputeVertex_QuadSplit( curClipPlane, inQuadSplit, @@ -1472,14 +1472,14 @@ MSrEnv_Clip_Quad( newQuadSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[3]; newQuadSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[3]; newQuadSplit.shades[0] = inQuadSplit->shades[3]; - + newQuadSplit.vertexIndices.indices[1] = inQuadSplit->vertexIndices.indices[0]; newQuadSplit.baseUVIndices.indices[1] = inQuadSplit->baseUVIndices.indices[0]; newQuadSplit.shades[1] = inQuadSplit->shades[0]; - + newQuadSplit.vertexIndices.indices[2] = newVIndex1; newQuadSplit.baseUVIndices.indices[2] = newBaseUVIndex1; - + newQuadSplit.vertexIndices.indices[3] = newVIndex0; newQuadSplit.baseUVIndices.indices[3] = newBaseUVIndex0; @@ -1498,14 +1498,14 @@ MSrEnv_Clip_Quad( } return; - } - } - else - { - /* 0: In, 1: Out, 2: In, 3: In */ - //UUmAssert(!(curClipPlane & inClipCode3)); - /* Compute 2 -> 1 intersection */ - /* Compute 0 -> 1 intersection */ + } + } + else + { + /* 0: In, 1: Out, 2: In, 3: In */ + //UUmAssert(!(curClipPlane & inClipCode3)); + /* Compute 2 -> 1 intersection */ + /* Compute 0 -> 1 intersection */ MSrEnv_Clip_ComputeVertex_QuadSplit( curClipPlane, inQuadSplit, @@ -1520,15 +1520,15 @@ MSrEnv_Clip_Quad( newQuadSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[2]; newQuadSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[2]; newQuadSplit.shades[0] = inQuadSplit->shades[2]; - + newQuadSplit.vertexIndices.indices[1] = inQuadSplit->vertexIndices.indices[3]; newQuadSplit.baseUVIndices.indices[1] = inQuadSplit->baseUVIndices.indices[3]; newQuadSplit.shades[1] = inQuadSplit->shades[3]; - + newQuadSplit.vertexIndices.indices[2] = inQuadSplit->vertexIndices.indices[0]; newQuadSplit.baseUVIndices.indices[2] = inQuadSplit->baseUVIndices.indices[0]; newQuadSplit.shades[2] = inQuadSplit->shades[0]; - + newQuadSplit.vertexIndices.indices[3] = newVIndex1; newQuadSplit.baseUVIndices.indices[3] = newBaseUVIndex1; newQuadSplit.shades[3] = newPentSplit.shades[3]; @@ -1545,15 +1545,15 @@ MSrEnv_Clip_Quad( M3rDraw_Quad( &newQuadSplit); } - + newTriSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[2]; newTriSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[2]; newTriSplit.shades[0] = inQuadSplit->shades[2]; - + newTriSplit.vertexIndices.indices[1] = newVIndex1; newTriSplit.baseUVIndices.indices[1] = newBaseUVIndex1; newTriSplit.shades[1] = newPentSplit.shades[3]; - + newTriSplit.vertexIndices.indices[2] = newVIndex0; newTriSplit.baseUVIndices.indices[2] = newBaseUVIndex0; newTriSplit.shades[2] = newPentSplit.shades[4]; @@ -1576,19 +1576,19 @@ MSrEnv_Clip_Quad( newPentSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[2]; newPentSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[2]; newPentSplit.shades[0] = inQuadSplit->shades[2]; - + newPentSplit.vertexIndices.indices[1] = inQuadSplit->vertexIndices.indices[3]; newPentSplit.baseUVIndices.indices[1] = inQuadSplit->baseUVIndices.indices[3]; newPentSplit.shades[1] = inQuadSplit->shades[3]; - + newPentSplit.vertexIndices.indices[2] = inQuadSplit->vertexIndices.indices[0]; newPentSplit.baseUVIndices.indices[2] = inQuadSplit->baseUVIndices.indices[0]; newPentSplit.shades[2] = inQuadSplit->shades[0]; - + newPentSplit.vertexIndices.indices[3] = newVIndex1; newPentSplit.baseUVIndices.indices[3] = newBaseUVIndex1; newPentSplit.shades[3] = newPentSplit.shades[3]; - + newPentSplit.vertexIndices.indices[4] = newVIndex0; newPentSplit.baseUVIndices.indices[4] = newBaseUVIndex0; newPentSplit.shades[4] = newPentSplit.shades[4]; @@ -1597,19 +1597,19 @@ MSrEnv_Clip_Quad( &newPentSplit); } return; - } - } - else - { - /* 0: In, 1: In, 2: ?, 3: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: In, 1: In, 2: Out, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: In, 1: In, 2: Out, 3: Out */ - /* Compute 0 -> 3 intersection */ - /* Compute 1 -> 2 intersection */ + } + } + else + { + /* 0: In, 1: In, 2: ?, 3: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: In, 1: In, 2: Out, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: In, 1: In, 2: Out, 3: Out */ + /* Compute 0 -> 3 intersection */ + /* Compute 1 -> 2 intersection */ MSrEnv_Clip_ComputeVertex_QuadSplit( curClipPlane, inQuadSplit, @@ -1621,14 +1621,14 @@ MSrEnv_Clip_Quad( newQuadSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[0]; newQuadSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[0]; newQuadSplit.shades[0] = inQuadSplit->shades[0]; - + newQuadSplit.vertexIndices.indices[1] = inQuadSplit->vertexIndices.indices[1]; newQuadSplit.baseUVIndices.indices[1] = inQuadSplit->baseUVIndices.indices[1]; newQuadSplit.shades[1] = inQuadSplit->shades[1]; - + newQuadSplit.vertexIndices.indices[2] = newVIndex1; newQuadSplit.baseUVIndices.indices[2] = newBaseUVIndex1; - + newQuadSplit.vertexIndices.indices[3] = newVIndex0; newQuadSplit.baseUVIndices.indices[3] = newBaseUVIndex0; @@ -1647,12 +1647,12 @@ MSrEnv_Clip_Quad( } return; - } - else - { - /* 0: In, 1: In, 2: Out, 3: In */ - /* Compute 3 -> 2 intersection */ - /* Compute 1 -> 2 intersection */ + } + else + { + /* 0: In, 1: In, 2: Out, 3: In */ + /* Compute 3 -> 2 intersection */ + /* Compute 1 -> 2 intersection */ MSrEnv_Clip_ComputeVertex_QuadSplit( curClipPlane, inQuadSplit, @@ -1667,14 +1667,14 @@ MSrEnv_Clip_Quad( newQuadSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[3]; newQuadSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[3]; newQuadSplit.shades[0] = inQuadSplit->shades[3]; - + newQuadSplit.vertexIndices.indices[1] = inQuadSplit->vertexIndices.indices[0]; newQuadSplit.baseUVIndices.indices[1] = inQuadSplit->baseUVIndices.indices[0]; newQuadSplit.shades[1] = inQuadSplit->shades[0]; - + newQuadSplit.vertexIndices.indices[2] = inQuadSplit->vertexIndices.indices[1]; newQuadSplit.baseUVIndices.indices[2] = inQuadSplit->baseUVIndices.indices[1]; - newQuadSplit.shades[2] = inQuadSplit->shades[1]; + newQuadSplit.shades[2] = inQuadSplit->shades[1]; newQuadSplit.vertexIndices.indices[3] = newVIndex1; newQuadSplit.baseUVIndices.indices[3] = newBaseUVIndex1; @@ -1692,15 +1692,15 @@ MSrEnv_Clip_Quad( M3rDraw_Quad( &newQuadSplit); } - + newTriSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[3]; newTriSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[3]; newTriSplit.shades[0] = inQuadSplit->shades[3]; - + newTriSplit.vertexIndices.indices[1] = newVIndex1; newTriSplit.baseUVIndices.indices[1] = newBaseUVIndex1; newTriSplit.shades[1] = newPentSplit.shades[3]; - + newTriSplit.vertexIndices.indices[2] = newVIndex0; newTriSplit.baseUVIndices.indices[2] = newBaseUVIndex0; newTriSplit.shades[2] = newPentSplit.shades[4]; @@ -1723,19 +1723,19 @@ MSrEnv_Clip_Quad( newPentSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[3]; newPentSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[3]; newPentSplit.shades[0] = inQuadSplit->shades[3]; - + newPentSplit.vertexIndices.indices[1] = inQuadSplit->vertexIndices.indices[0]; newPentSplit.baseUVIndices.indices[1] = inQuadSplit->baseUVIndices.indices[0]; newPentSplit.shades[1] = inQuadSplit->shades[0]; - + newPentSplit.vertexIndices.indices[2] = inQuadSplit->vertexIndices.indices[1]; newPentSplit.baseUVIndices.indices[2] = inQuadSplit->baseUVIndices.indices[1]; newPentSplit.shades[2] = inQuadSplit->shades[1]; - + newPentSplit.vertexIndices.indices[3] = newVIndex1; newPentSplit.baseUVIndices.indices[3] = newBaseUVIndex1; newPentSplit.shades[3] = newPentSplit.shades[3]; - + newPentSplit.vertexIndices.indices[4] = newVIndex0; newPentSplit.baseUVIndices.indices[4] = newBaseUVIndex0; newPentSplit.shades[4] = newPentSplit.shades[4]; @@ -1744,16 +1744,16 @@ MSrEnv_Clip_Quad( &newPentSplit); } return; - } - } - else - { - /* 0: In, 1: In, 2: In, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: In, 1: In, 2: In, 3: Out */ - /* Compute 0 -> 3 intersection */ - /* Compute 2 -> 3 intersection */ + } + } + else + { + /* 0: In, 1: In, 2: In, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: In, 1: In, 2: In, 3: Out */ + /* Compute 0 -> 3 intersection */ + /* Compute 2 -> 3 intersection */ MSrEnv_Clip_ComputeVertex_QuadSplit( curClipPlane, inQuadSplit, @@ -1768,15 +1768,15 @@ MSrEnv_Clip_Quad( newQuadSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[0]; newQuadSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[0]; newQuadSplit.shades[0] = inQuadSplit->shades[0]; - + newQuadSplit.vertexIndices.indices[1] = inQuadSplit->vertexIndices.indices[1]; newQuadSplit.baseUVIndices.indices[1] = inQuadSplit->baseUVIndices.indices[1]; newQuadSplit.shades[1] = inQuadSplit->shades[1]; - + newQuadSplit.vertexIndices.indices[2] = inQuadSplit->vertexIndices.indices[2]; newQuadSplit.baseUVIndices.indices[2] = inQuadSplit->baseUVIndices.indices[2]; newQuadSplit.shades[2] = inQuadSplit->shades[2]; - + newQuadSplit.vertexIndices.indices[3] = newVIndex1; newQuadSplit.baseUVIndices.indices[3] = newBaseUVIndex1; newQuadSplit.shades[3] = newPentSplit.shades[3]; @@ -1793,15 +1793,15 @@ MSrEnv_Clip_Quad( M3rDraw_Quad( &newQuadSplit); } - + newTriSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[0]; newTriSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[0]; newTriSplit.shades[0] = inQuadSplit->shades[0]; - + newTriSplit.vertexIndices.indices[1] = newVIndex1; newTriSplit.baseUVIndices.indices[1] = newBaseUVIndex1; newTriSplit.shades[1] = newPentSplit.shades[3]; - + newTriSplit.vertexIndices.indices[2] = newVIndex0; newTriSplit.baseUVIndices.indices[2] = newBaseUVIndex0; newTriSplit.shades[2] = newPentSplit.shades[4]; @@ -1824,19 +1824,19 @@ MSrEnv_Clip_Quad( newPentSplit.vertexIndices.indices[0] = inQuadSplit->vertexIndices.indices[0]; newPentSplit.baseUVIndices.indices[0] = inQuadSplit->baseUVIndices.indices[0]; newPentSplit.shades[0] = inQuadSplit->shades[0]; - + newPentSplit.vertexIndices.indices[1] = inQuadSplit->vertexIndices.indices[1]; newPentSplit.baseUVIndices.indices[1] = inQuadSplit->baseUVIndices.indices[1]; newPentSplit.shades[1] = inQuadSplit->shades[1]; - + newPentSplit.vertexIndices.indices[2] = inQuadSplit->vertexIndices.indices[2]; newPentSplit.baseUVIndices.indices[2] = inQuadSplit->baseUVIndices.indices[2]; newPentSplit.shades[2] = inQuadSplit->shades[2]; - + newPentSplit.vertexIndices.indices[3] = newVIndex1; newPentSplit.baseUVIndices.indices[3] = newBaseUVIndex1; newPentSplit.shades[3] = newPentSplit.shades[3]; - + newPentSplit.vertexIndices.indices[4] = newVIndex0; newPentSplit.baseUVIndices.indices[4] = newBaseUVIndex0; newPentSplit.shades[4] = newPentSplit.shades[4]; @@ -1845,10 +1845,10 @@ MSrEnv_Clip_Quad( &newPentSplit); } return; - } - /* else all are in */ - } - } + } + /* else all are in */ + } + } } } } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Env_Clip.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Env_Clip.h index 3de56be..4c681d0 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Env_Clip.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Env_Clip.h @@ -1,12 +1,12 @@ /* FILE: MS_GC_Env_Clip.h - + AUTHOR: Brent H. Pease - + CREATED: Jan 14, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_AltiVec.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_AltiVec.c index 70cba38..308fb1e 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_AltiVec.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_AltiVec.c @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_AltiVec.c - + AUTHOR: Brent H. Pease - + CREATED: Aug. 4, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -41,20 +41,20 @@ MSiAltiVec_Geometry_Draw_ClipAccept( UUtUns32* screenVertexShades; UUtUns16 i; UUtUns16 index0, index1, index2, index3; - + UUmAssert(geomPrivate->simdCacheEntryIndex != 0xFFFF); UUmAssertReadPtr(geomPrivate->pointSIMD, sizeof(float)); UUmAssertReadPtr(geomPrivate->vertexNormalSIMD, sizeof(float)); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_Vertex); - + numPoints = inGeometryObject->pointArray->numPoints; screenPoints = MSgGeomContextPrivate->objectVertexData.screenPoints; worldVertexNormals = MSgGeomContextPrivate->worldVertexNormals; screenVertexShades = (UUtUns32*)MSgGeomContextPrivate->shades_vertex; - + // Transform all points to screen space MSrTransform_ToScreen_AltiVec( numPoints, @@ -63,20 +63,20 @@ MSiAltiVec_Geometry_Draw_ClipAccept( screenPoints, MSgGeomContextPrivate->scaleX, MSgGeomContextPrivate->scaleY); - + // Transform all normals to world space MSrTransform_Normal_AltiVec( numPoints, MSgGeomContextPrivate->matrixStackTop, geomPrivate->vertexNormalSIMD, worldVertexNormals); - + // Shade all points MSrShade_Vertices_Gouraud_Directional_AltiVec( inGeometryObject, (float*)worldVertexNormals, screenVertexShades); - + // draw the tris and quads if(inGeometryObject->triArray != NULL) { @@ -86,75 +86,75 @@ MSiAltiVec_Geometry_Draw_ClipAccept( numTris = inGeometryObject->triArray->numTris; curTri = inGeometryObject->triArray->tris; - + for(i = 0; i < numTris; i++) { index0 = curTri->indices[0]; index1 = curTri->indices[1]; index2 = curTri->indices[2]; - + M3rDraw_Triangle( curTri); curTri++; } } - + if(inGeometryObject->quadArray != NULL) { M3tQuad* curQuad; UUtUns16 numQuads; numQuads = inGeometryObject->quadArray->numQuads; - + curQuad = inGeometryObject->quadArray->quads; - + for(i = 0; i < numQuads; i++) { index0 = curQuad->indices[0]; index1 = curQuad->indices[1]; index2 = curQuad->indices[2]; index3 = curQuad->indices[3]; - + M3rDraw_Quad( curQuad); - + curQuad++; } } -} +} UUtError MSrGeomContext_Method_AltiVec_Geometry_Draw( M3tGeometry* inGeometryObject) { MStClipStatus clipStatus; - + TMrInstance_PrepareForUse(inGeometryObject); - + MSrTransform_UpdateMatrices(); clipStatus = MSrTransform_DetermineClipStatus( &inGeometryObject->boundingBox, MSgGeomContextPrivate->matrix_localToFrustum); - + if(clipStatus == MScClipStatus_TrivialReject) { return UUcError_None; } - + M3rDraw_State_Push(); - + M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, inGeometryObject->pointArray->numPoints); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenPointArray, MSgGeomContextPrivate->objectVertexData.screenPoints); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenShadeArray_DC, MSgGeomContextPrivate->shades_vertex); @@ -166,11 +166,11 @@ MSrGeomContext_Method_AltiVec_Geometry_Draw( M3rDraw_State_SetPtr( M3cDrawStatePtrType_TextureCoordArray, inGeometryObject->texCoordArray->textureCoords); - + MSgGeomContextPrivate->objectVertexData.textureCoords = inGeometryObject->texCoordArray->textureCoords; - + UUmAssert(inGeometryObject->texCoordArray->numTextureCoords == inGeometryObject->pointArray->numPoints); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, inGeometryObject->baseMap); @@ -188,9 +188,9 @@ MSrGeomContext_Method_AltiVec_Geometry_Draw( } else { - + } - + M3rDraw_State_Pop(); return UUcError_None; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_AltiVec.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_AltiVec.h index 9b043a3..96ceb53 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_AltiVec.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_AltiVec.h @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_AltiVec.h - + AUTHOR: Brent H. Pease - + CREATED: Aug. 4, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Camera.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Camera.h index 6af0486..c2b1e74 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Camera.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Camera.h @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Camera.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -21,7 +21,7 @@ MSrCamera_Initialize( void MSrCamera_UpdateMatrices( MStGeomCamera* inCameraPrivate); - + UUtError MSrGeomContext_Method_Camera_New( M3tGeomCamera* *outCamera); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Env.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Env.c index 93682d0..5b57b46 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Env.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Env.c @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Env.c - + AUTHOR: Brent H. Pease - + CREATED: Jan 14, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -39,7 +39,7 @@ MSrGeomContext_Method_Env_SetCamera( UUmAssertReadPtr(inCamera, sizeof(M3tManager_GeomCamera)); MSgGeomContextPrivate->visCamera = (M3tManager_GeomCamera*)inCamera; - + return UUcError_None; } @@ -91,43 +91,43 @@ MSrGeomContext_Method_Env_DrawGQList( UUtUns8* clipCodes; M3tPoint3D* worldPoints; UUtUns32* gqVertexNeededBV; - + UUtUns32 curVertexItr; UUtUns32 curVertexIndex; - + UUtUns8 clipCodeOR; UUtUns8 clipCodeAND; - + AKtGQ_General* gqGeneralArray; AKtGQ_Render* gqRenderArray; AKtGQ_Collision* gqCollisionArray; AKtGQ_General* curGQGeneral; AKtGQ_Render* curGQRender; - + UUtUns32 numTextureCoords; UUtUns32 numPoints; - + // M3tTextureMap* texMap; M3tTextureMap** textureMapArray; - + UUtUns32 gqIndexItr; UUtUns32 curGQIndex; - + UUtBool useDebugMaps = UUcFalse; UUtBool drawGhostGQs = UUcFalse; UUtUns32 debugState; UUtUns16 reflectionPlaneIndex = 700; - + static UUtBool flash = 0; - + UUmAssertReadPtr(MSgGeomContextPrivate, sizeof(MSgGeomContextPrivate)); - + screenPoints = MSgGeomContextPrivate->gqVertexData.screenPoints; clipCodes = MSgGeomContextPrivate->gqVertexData.clipCodes; frustumPoints = MSgGeomContextPrivate->gqVertexData.frustumPoints; gqVertexNeededBV = MSgGeomContextPrivate->gqVertexData.bitVector; - - + + worldPoints = MSgGeomContextPrivate->environment->pointArray->points; gqGeneralArray = MSgGeomContextPrivate->environment->gqGeneralArray->gqGeneral; gqRenderArray = MSgGeomContextPrivate->environment->gqRenderArray->gqRender; @@ -136,47 +136,47 @@ MSrGeomContext_Method_Env_DrawGQList( // debugState = MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_DebugMode]; debugState = 0; - + useDebugMaps = (UUtBool)((debugState & M3cGeomState_DebugMode_UseEnvDbgTexture) != 0); drawGhostGQs = (UUtBool)((debugState & M3cGeomState_DebugMode_DrawGhostGQs) != 0); - + M3rDraw_State_Push(); - - + + #if 0 - + M3rDraw_State_SetInt( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Gouraud); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Fill, M3cDrawState_Fill_Line); - + #else M3rDraw_State_SetInt( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Texture_Unlit); - + M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, 0xFFFFFFFF); M3rDraw_State_SetInt( - M3cDrawStateIntType_Alpha, + M3cDrawStateIntType_Alpha, M3cMaxAlpha); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); - + #endif - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenPointArray, screenPoints); @@ -186,42 +186,42 @@ MSrGeomContext_Method_Env_DrawGQList( MSgGeomContextPrivate->environment->textureCoordArray->textureCoords); MSrTransform_UpdateMatrices(); - + numPoints = MSgGeomContextPrivate->environment->pointArray->numPoints; numTextureCoords = MSgGeomContextPrivate->environment->textureCoordArray->numTextureCoords; - + MSgGeomContextPrivate->gqVertexData.maxClipVertices = numPoints + M3cExtraCoords; MSgGeomContextPrivate->gqVertexData.maxClipTextureCords = numTextureCoords + M3cExtraCoords; - + M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, numPoints); - + M3rDraw_State_SetInt( M3cDrawStateIntType_VertexFormat, M3cDrawStateVertex_Split); - + UUmAssertReadPtr(gqVertexNeededBV, sizeof(UUtUns32)); - + UUrBitVector_ClearBitAll( gqVertexNeededBV, numPoints); - + // Traverse the bit vector for(gqIndexItr = 0; gqIndexItr < inNumGQs; gqIndexItr++) { curGQIndex = inGQIndices[gqIndexItr]; - + curGQGeneral = gqGeneralArray + curGQIndex; - + // mark all 4 vertices as needed for(curVertexItr = 0; curVertexItr < 4; curVertexItr++) { curVertexIndex = curGQGeneral->m3Quad.vertexIndices.indices[curVertexItr]; - + UUrBitVector_SetBit(gqVertexNeededBV, curVertexIndex); } - + //UUmAssert(!(curGQGeneral->flags & AKcGQ_Flag_Transparent)); } @@ -236,13 +236,13 @@ MSrGeomContext_Method_Env_DrawGQList( M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, gqVertexNeededBV); - + M3rDraw_State_Commit(); - + for(gqIndexItr = 0; gqIndexItr < inNumGQs; gqIndexItr++) { curGQIndex = inGQIndices[gqIndexItr]; - + curGQRender = gqRenderArray + curGQIndex; curGQGeneral = gqGeneralArray + curGQIndex; @@ -252,15 +252,15 @@ MSrGeomContext_Method_Env_DrawGQList( for(curVertexItr = 0; curVertexItr < 4; curVertexItr++) { curVertexIndex = curGQGeneral->m3Quad.vertexIndices.indices[curVertexItr]; - + clipCodeOR |= clipCodes[curVertexIndex]; clipCodeAND &= clipCodes[curVertexIndex]; - + } - + // trivial reject if(clipCodeAND != 0) continue; - + #if TOOL_VERSION // CB: flashTexture only exists in the tool version now if (gqIndexItr == AKgHighlightGQIndex) @@ -272,7 +272,7 @@ MSrGeomContext_Method_Env_DrawGQList( else if ((curGQGeneral->flags & AKcGQ_Flag_Draw_Flash)) { curGQGeneral->flags &= ~AKcGQ_Flag_Draw_Flash; - + if(curGQGeneral->flags & AKcGQ_Flag_Flash_State) { curGQGeneral->flags &= ~AKcGQ_Flag_Flash_State; @@ -312,7 +312,7 @@ MSrGeomContext_Method_Env_DrawGQList( if (inTransparentList) { M3rDraw_State_SetInt(M3cDrawStateIntType_Alpha, curGQRender->alpha); } - + M3rDraw_State_SetInt( M3cDrawStateIntType_Clipping, clipCodeOR != 0); @@ -336,7 +336,7 @@ MSrGeomContext_Method_Env_DrawGQList( // Clip xxx we turn environment quads to triangles so we clip right here // S.S. vertices reordered to correspond to geometry type // GL_TRIANGLE_FAN; previously used GL_QUAD - + MSgGeomContextPrivate->gqVertexData.newClipTextureIndex = numTextureCoords; MSgGeomContextPrivate->gqVertexData.newClipVertexIndex = numPoints; @@ -401,9 +401,9 @@ MSrGeomContext_Method_Env_DrawGQList( M3rDraw_Quad(&curGQGeneral->m3Quad); } } - + M3rDraw_State_Pop(); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Env.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Env.h index 036bc6d..a5acb52 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Env.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Env.h @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Env.h - + AUTHOR: Brent H. Pease - + CREATED: Jan 14, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -16,7 +16,7 @@ UUtError MSrGeomContext_Method_Env_SetCamera( M3tGeomCamera* inCamera); // If null use active camera in geom context - + UUtError MSrGeomContext_Method_Env_DrawGQList( UUtUns32 inNumGQs, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Frame.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Frame.c index b553a2a..84c002f 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Frame.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Frame.c @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Frame.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -25,17 +25,17 @@ MSrGeomContext_Method_Frame_Start( { UUtUns32 is_fast_mode = M3rGeom_State_Get(M3cGeomStateIntType_FastMode); M3rMatrixStack_Clear(); - + if (!is_fast_mode) { M3rDraw_Frame_Start(inGameTicksElapsed); - + if (MSgGeomContextPrivate->environment) { // clear env bit vectors here UUrBitVector_ClearBitAll( MSgGeomContextPrivate->gqVertexData.bitVector, MSgGeomContextPrivate->environment->pointArray->numPoints); - + #if 0 UUrBitVector_ClearBitAll( MSgGeomContextPrivate->otVertexData.bitVector, @@ -43,7 +43,7 @@ MSrGeomContext_Method_Frame_Start( #endif } } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Frame.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Frame.h index 86ec7a6..09d84ee 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Frame.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Frame.h @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Frame.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Geometry.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Geometry.c index f4d953e..2e71926 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Geometry.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Geometry.c @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Geometry.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -34,7 +34,7 @@ extern UUtBool gClipForce4D; extern UUtBool gNo4DClip; - + #endif #include "Motoko_Manager.h" @@ -51,26 +51,26 @@ MSrGeomContext_Method_Geometry_BoundingBox_Draw( M3tPoint4D *frustumPoints; M3tQuad quadIndices; UUtUns32 itr, boxShades[4 + M3cExtraCoords]; - + MSrTransform_UpdateMatrices(); - + clipCodes = MSgGeomContextPrivate->objectVertexData.clipCodes; frustumPoints = MSgGeomContextPrivate->objectVertexData.frustumPoints; screenPoints = MSgGeomContextPrivate->objectVertexData.screenPoints; - - clipStatus = + + clipStatus = MSgGeomContextPrivate->activeFunctions->transformBoundingBoxToFrustumScreen( inGeometryObject, frustumPoints, screenPoints, clipCodes); - + M3rDraw_State_Push(); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenPointArray, screenPoints); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Gouraud); @@ -86,13 +86,13 @@ MSrGeomContext_Method_Geometry_BoundingBox_Draw( M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, 8); - + M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, inShade); M3rDraw_State_Commit(); - + for (itr = 0; itr < 8; itr++) { boxShades[itr] = inShade; } @@ -105,7 +105,7 @@ MSrGeomContext_Method_Geometry_BoundingBox_Draw( { case MScClipStatus_TrivialReject: break; - + case MScClipStatus_TrivialAccept: // minZ side quadIndices.indices[0] = 0; @@ -113,35 +113,35 @@ MSrGeomContext_Method_Geometry_BoundingBox_Draw( quadIndices.indices[2] = 3; quadIndices.indices[3] = 2; M3rDraw_Quad(&quadIndices); - + // maxZ side quadIndices.indices[0] = 4; quadIndices.indices[1] = 5; quadIndices.indices[2] = 7; quadIndices.indices[3] = 6; M3rDraw_Quad(&quadIndices); - + // minY side quadIndices.indices[0] = 0; quadIndices.indices[1] = 1; quadIndices.indices[2] = 5; quadIndices.indices[3] = 4; M3rDraw_Quad(&quadIndices); - + // maxY side quadIndices.indices[0] = 2; quadIndices.indices[1] = 3; quadIndices.indices[2] = 7; quadIndices.indices[3] = 6; M3rDraw_Quad(&quadIndices); - + // minX side quadIndices.indices[0] = 0; quadIndices.indices[1] = 2; quadIndices.indices[2] = 6; quadIndices.indices[3] = 4; M3rDraw_Quad(&quadIndices); - + // maxX side quadIndices.indices[0] = 1; quadIndices.indices[1] = 3; @@ -149,10 +149,10 @@ MSrGeomContext_Method_Geometry_BoundingBox_Draw( quadIndices.indices[3] = 5; M3rDraw_Quad(&quadIndices); break; - + case MScClipStatus_NeedsClipping: MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_GouraudFlat; - + // minZ MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = 8; if(clipCodes[0] | clipCodes[1] | clipCodes[3] | clipCodes[2]) @@ -167,7 +167,7 @@ MSrGeomContext_Method_Geometry_BoundingBox_Draw( quadIndices.indices[3] = 2; M3rDraw_Quad(&quadIndices); } - + // maxZ MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = 8; if(clipCodes[4] | clipCodes[5] | clipCodes[7] | clipCodes[6]) @@ -182,7 +182,7 @@ MSrGeomContext_Method_Geometry_BoundingBox_Draw( quadIndices.indices[3] = 6; M3rDraw_Quad(&quadIndices); } - + // minY MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = 8; if(clipCodes[0] | clipCodes[1] | clipCodes[5] | clipCodes[4]) @@ -197,7 +197,7 @@ MSrGeomContext_Method_Geometry_BoundingBox_Draw( quadIndices.indices[3] = 4; M3rDraw_Quad(&quadIndices); } - + // maxY MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = 8; if(clipCodes[2] | clipCodes[3] | clipCodes[7] | clipCodes[6]) @@ -212,7 +212,7 @@ MSrGeomContext_Method_Geometry_BoundingBox_Draw( quadIndices.indices[3] = 6; M3rDraw_Quad(&quadIndices); } - + // minX MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = 8; if(clipCodes[0] | clipCodes[2] | clipCodes[6] | clipCodes[4]) @@ -227,7 +227,7 @@ MSrGeomContext_Method_Geometry_BoundingBox_Draw( quadIndices.indices[3] = 4; M3rDraw_Quad(&quadIndices); } - + // maxX MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = 8; if(clipCodes[1] | clipCodes[3] | clipCodes[7] | clipCodes[5]) @@ -246,7 +246,7 @@ MSrGeomContext_Method_Geometry_BoundingBox_Draw( } M3rDraw_State_Pop(); - + return UUcError_None; } @@ -267,20 +267,20 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeVertex( UUtUns32 numPoints; UUtUns32 numTris; UUtUns32* curIndexPtr; - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_Vertex); - + numPoints = inGeometryObject->pointArray->numPoints; - + worldPoints = MSgGeomContextPrivate->worldPoints; worldVertexNormals = MSgGeomContextPrivate->worldVertexNormals; screenVertexShades = (UUtUns32*)MSgGeomContextPrivate->shades_vertex; screenPoints = MSgGeomContextPrivate->objectVertexData.screenPoints; clipCodes = MSgGeomContextPrivate->objectVertexData.clipCodes; frustumPoints = MSgGeomContextPrivate->objectVertexData.frustumPoints; - + /* * Transform all points to screen space */ @@ -297,7 +297,7 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeVertex( inGeometryObject, worldPoints, worldVertexNormals); - + /* * Shade the vertices */ @@ -305,7 +305,7 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeVertex( MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Fill] == M3cGeomState_Fill_Solid && (inGeometryObject->geometryFlags & M3cGeometryFlag_ComputeSpecular)) { - + } else { @@ -315,21 +315,21 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeVertex( worldVertexNormals, screenVertexShades); } - + // M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, NULL); - + M3rDraw_State_Commit(); - + numTris = inGeometryObject->triNormalIndexArray->numIndices; curIndexPtr = inGeometryObject->triStripArray->indices; - + for(i = 0; i < numTris; i++) { index2 = *curIndexPtr++; - + if(index2 & 0x80000000) { index0 = (index2 & 0x7FFFFFFF); @@ -340,7 +340,7 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeVertex( } clipCode2 = clipCodes[index2]; - + if(clipCode0 & clipCode1 & clipCode2) { // Do nothing @@ -360,21 +360,21 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeVertex( else { M3tTri curTri; - + curTri.indices[0] = index0; curTri.indices[1] = index1; curTri.indices[2] = index2; - + M3rDraw_Triangle( &curTri); } - + index0 = index1; index1 = index2; clipCode0 = clipCode1; clipCode1 = clipCode2; } - + return UUcError_None; } @@ -394,25 +394,25 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeFace( UUtUns32 numPoints; UUtUns32 numTris; UUtUns32* curIndexPtr; - + M3rDraw_State_Push(); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); - + numPoints = inGeometryObject->pointArray->numPoints; numTris = inGeometryObject->triNormalIndexArray->numIndices; - + worldPoints = MSgGeomContextPrivate->worldPoints; worldTriNormals = MSgGeomContextPrivate->worldTriNormals; screenTriShades = (UUtUns32*)MSgGeomContextPrivate->shades_tris; screenPoints = MSgGeomContextPrivate->objectVertexData.screenPoints; clipCodes = MSgGeomContextPrivate->objectVertexData.clipCodes; frustumPoints = MSgGeomContextPrivate->objectVertexData.frustumPoints; - + MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = numPoints; - + MSgGeomContextPrivate->activeFunctions->transformPointListToFrustumScreen( inGeometryObject, frustumPoints, @@ -425,7 +425,7 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeFace( MSgGeomContextPrivate->activeFunctions->transformFaceNormalToWorld( inGeometryObject, worldTriNormals); - + /* * Shade the vertices */ @@ -433,7 +433,7 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeFace( MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Fill] == M3cGeomState_Fill_Solid && (inGeometryObject->geometryFlags & M3cGeometryFlag_ComputeSpecular)) { - + } else { @@ -444,18 +444,18 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeFace( worldTriNormals, screenTriShades); } - + // M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, NULL); - + curIndexPtr = inGeometryObject->triStripArray->indices; - + for(i = 0; i < numTris; i++) { index2 = *curIndexPtr++; - + if(index2 & 0x80000000) { index0 = (index2 & 0x7FFFFFFF); @@ -466,11 +466,11 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeFace( } clipCode2 = clipCodes[index2]; - + M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, *screenTriShades); - + M3rDraw_State_Commit(); if(clipCode0 & clipCode1 & clipCode2) @@ -492,15 +492,15 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeFace( else { M3tTri curTri; - + curTri.indices[0] = index0; curTri.indices[1] = index1; curTri.indices[2] = index2; - + M3rDraw_Triangle( &curTri); } - + index0 = index1; index1 = index2; clipCode0 = clipCode1; @@ -509,7 +509,7 @@ MSiGeometry_Draw_BackFaceKeep_Clip_ShadeFace( } M3rDraw_State_Pop(); - + return UUcError_None; } @@ -526,33 +526,33 @@ MSiGeometry_Draw_BackFaceKeep_ClipAccept_ShadeVertex( UUtUns32* curIndexPtr; UUtUns32 index0, index1, index2; UUtUns32 numTris; - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_Vertex); - + numPoints = inGeometryObject->pointArray->numPoints; - + worldPoints = MSgGeomContextPrivate->worldPoints; worldVertexNormals = MSgGeomContextPrivate->worldVertexNormals; screenVertexShades = (UUtUns32*)MSgGeomContextPrivate->shades_vertex; screenPoints = MSgGeomContextPrivate->objectVertexData.screenPoints; - + /* * Transform all points to screen space */ MSgGeomContextPrivate->activeFunctions->transformPointListToScreen( inGeometryObject, screenPoints); - + if(0) { UUtUns32 itr; - + MSrTransform_Geom_PointListToScreen( inGeometryObject, MSgGeomContextPrivate->gqVertexData.screenPoints); - + for(itr = 0; itr < numPoints; itr++) { UUmAssert(UUmFloat_CompareEqu(screenPoints[itr].x, MSgGeomContextPrivate->gqVertexData.screenPoints[itr].x)); @@ -561,8 +561,8 @@ MSiGeometry_Draw_BackFaceKeep_ClipAccept_ShadeVertex( UUmAssert(UUmFloat_CompareEqu(screenPoints[itr].invW, MSgGeomContextPrivate->gqVertexData.screenPoints[itr].invW)); } } - - + + /* * Transform all points and vertex normals to world space */ @@ -570,7 +570,7 @@ MSiGeometry_Draw_BackFaceKeep_ClipAccept_ShadeVertex( inGeometryObject, worldPoints, worldVertexNormals); - + /* * Shade the vertices */ @@ -578,7 +578,7 @@ MSiGeometry_Draw_BackFaceKeep_ClipAccept_ShadeVertex( MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Fill] == M3cGeomState_Fill_Solid && (inGeometryObject->geometryFlags & M3cGeometryFlag_ComputeSpecular)) { - + } else { @@ -588,21 +588,21 @@ MSiGeometry_Draw_BackFaceKeep_ClipAccept_ShadeVertex( worldVertexNormals, screenVertexShades); } - + // M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, NULL); - + M3rDraw_State_Commit(); - + numTris = inGeometryObject->triNormalIndexArray->numIndices; curIndexPtr = inGeometryObject->triStripArray->indices; - + for(i = 0; i < numTris; i++) { index2 = *curIndexPtr++; - + if(index2 & 0x80000000) { index0 = (index2 & 0x7FFFFFFF); @@ -612,15 +612,15 @@ MSiGeometry_Draw_BackFaceKeep_ClipAccept_ShadeVertex( { M3tTri curTri; - + curTri.indices[0] = index0; curTri.indices[1] = index1; curTri.indices[2] = index2; - + M3rDraw_Triangle( &curTri); } - + index0 = index1; index1 = index2; } @@ -641,19 +641,19 @@ MSiGeometry_Draw_BackFaceKeep_ClipAccept_ShadeFace( UUtUns32 numPoints; UUtUns32* curIndexPtr; UUtUns32 index0, index1, index2; - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); numPoints = inGeometryObject->pointArray->numPoints; numTris = inGeometryObject->triNormalIndexArray->numIndices; - + worldPoints = MSgGeomContextPrivate->worldPoints; worldTriNormals = MSgGeomContextPrivate->worldTriNormals; screenTriShades = (UUtUns32*)MSgGeomContextPrivate->shades_tris; screenPoints = MSgGeomContextPrivate->objectVertexData.screenPoints; - + /* * Transform all points to screen space */ @@ -667,7 +667,7 @@ MSiGeometry_Draw_BackFaceKeep_ClipAccept_ShadeFace( MSgGeomContextPrivate->activeFunctions->transformFaceNormalToWorld( inGeometryObject, worldTriNormals); - + /* * Shade the vertices */ @@ -675,7 +675,7 @@ MSiGeometry_Draw_BackFaceKeep_ClipAccept_ShadeFace( MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Fill] == M3cGeomState_Fill_Solid && (inGeometryObject->geometryFlags & M3cGeometryFlag_ComputeSpecular)) { - + } else { @@ -686,43 +686,43 @@ MSiGeometry_Draw_BackFaceKeep_ClipAccept_ShadeFace( worldTriNormals, screenTriShades); } - + // M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, NULL); - + numTris = inGeometryObject->triNormalIndexArray->numIndices; curIndexPtr = inGeometryObject->triStripArray->indices; - + for(i = 0; i < numTris; i++) { index2 = *curIndexPtr++; - + if(index2 & 0x80000000) { index0 = (index2 & 0x7FFFFFFF); index1 = *curIndexPtr++; index2 = *curIndexPtr++; } - + M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, *screenTriShades); - + M3rDraw_State_Commit(); { M3tTri curTri; - + curTri.indices[0] = index0; curTri.indices[1] = index1; curTri.indices[2] = index2; - + M3rDraw_Triangle( &curTri); } - + index0 = index1; index1 = index2; screenTriShades++; @@ -754,9 +754,9 @@ MSiGeometry_Draw_BackFaceRemove_Clip_ShadeVertex( UUtUns32* activeTrisBV; UUtUns32* activeVerticesBV; - + UUtUns32* curIndexPtr; - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_Vertex); @@ -771,7 +771,7 @@ MSiGeometry_Draw_BackFaceRemove_Clip_ShadeVertex( screenVertexShades = MSgGeomContextPrivate->shades_vertex; worldVertexNormals = MSgGeomContextPrivate->worldVertexNormals; - + // 0. init // - active face list // - active vertex list @@ -779,25 +779,25 @@ MSiGeometry_Draw_BackFaceRemove_Clip_ShadeVertex( MSgGeomContextPrivate->activeFunctions->transformFaceNormalToWorld( inGeometryObject, worldTriNormals); - + numTris = inGeometryObject->triNormalIndexArray->numIndices; activeTrisBV = MSgGeomContextPrivate->activeTrisBV; UUrBitVector_ClearBitAll( activeTrisBV, numTris); - + activeVerticesBV = MSgGeomContextPrivate->activeVerticesBV; UUrBitVector_ClearBitAll( activeVerticesBV, numPoints); - + // 2. Transform all points to world for backface test MSgGeomContextPrivate->activeFunctions->transformPointListAndVertexNormalToWorldComputeViewVector( inGeometryObject, worldPoints, worldViewVectors, worldVertexNormals); - + // 3. Do backface remove test // - mark all front facing faces as active // - mark all vertices belonging to front facing faces as active @@ -808,7 +808,7 @@ MSiGeometry_Draw_BackFaceRemove_Clip_ShadeVertex( worldTriNormals, activeTrisBV, activeVerticesBV); - + // 3. Transform all active vertices to frustum and screen space MSgGeomContextPrivate->activeFunctions->transformPointListToFrustumScreenActive( inGeometryObject, @@ -816,31 +816,31 @@ MSiGeometry_Draw_BackFaceRemove_Clip_ShadeVertex( frustumPoints, screenPoints, clipCodes); - + if(0) { UUtUns32 itr; - + MSrTransform_Geom_PointListToFrustumScreen( inGeometryObject, // activeVerticesBV, MSgGeomContextPrivate->gqVertexData.frustumPoints, MSgGeomContextPrivate->gqVertexData.screenPoints, MSgGeomContextPrivate->gqVertexData.clipCodes); - + for(itr = 0; itr < numPoints; itr++) { //if(!UUrBitVector_TestBit(activeVerticesBV, itr)) continue; - + UUmAssert(clipCodes[itr] == MSgGeomContextPrivate->gqVertexData.clipCodes[itr]); - + UUmAssert(UUmFloat_CompareEqu(screenPoints[itr].x, MSgGeomContextPrivate->gqVertexData.screenPoints[itr].x)); UUmAssert(UUmFloat_CompareEqu(screenPoints[itr].y, MSgGeomContextPrivate->gqVertexData.screenPoints[itr].y)); UUmAssert(UUmFloat_CompareEqu(screenPoints[itr].z, MSgGeomContextPrivate->gqVertexData.screenPoints[itr].z)); UUmAssert(UUmFloat_CompareEqu(screenPoints[itr].invW, MSgGeomContextPrivate->gqVertexData.screenPoints[itr].invW)); } } - + // 4. Shade all active vertices MSgGeomContextPrivate->activeFunctions->shadeVerticesGouraudActive( inGeometryObject, @@ -848,21 +848,21 @@ MSiGeometry_Draw_BackFaceRemove_Clip_ShadeVertex( worldVertexNormals, screenVertexShades, activeVerticesBV); - + // M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, activeVerticesBV); - + M3rDraw_State_Commit(); - + // 5. Clip and draw all active faces curIndexPtr = inGeometryObject->triStripArray->indices; - + UUmBitVector_Loop_Begin(i, numTris, activeTrisBV) { index2 = *curIndexPtr++; - + if(index2 & 0x80000000) { index0 = (index2 & 0x7FFFFFFF); @@ -873,14 +873,14 @@ MSiGeometry_Draw_BackFaceRemove_Clip_ShadeVertex( } clipCode2 = clipCodes[index2]; - + UUmBitVector_Loop_Test { - + UUmAssert(UUrBitVector_TestBit(activeVerticesBV, index0)); UUmAssert(UUrBitVector_TestBit(activeVerticesBV, index1)); UUmAssert(UUrBitVector_TestBit(activeVerticesBV, index2)); - + if(clipCode0 & clipCode1 & clipCode2) { // Do nothing @@ -900,16 +900,16 @@ MSiGeometry_Draw_BackFaceRemove_Clip_ShadeVertex( else { M3tTri curTri; - + curTri.indices[0] = index0; curTri.indices[1] = index1; curTri.indices[2] = index2; - + M3rDraw_Triangle( &curTri); } } - + index0 = index1; index1 = index2; clipCode0 = clipCode1; @@ -962,7 +962,7 @@ MSiGeometry_Draw_BackFaceRemove_ClipAccept_ShadeVertex( screenPoints = MSgGeomContextPrivate->objectVertexData.screenPoints; screenVertexShades = MSgGeomContextPrivate->shades_vertex; worldVertexNormals = MSgGeomContextPrivate->worldVertexNormals; - + // 0. init // - active face list // - active vertex list @@ -988,7 +988,7 @@ MSiGeometry_Draw_BackFaceRemove_ClipAccept_ShadeVertex( worldPoints, worldViewVectors, worldVertexNormals); - + #if TOOL_VERSION if(0) { @@ -1001,14 +1001,14 @@ MSiGeometry_Draw_BackFaceRemove_ClipAccept_ShadeVertex( float* nYYYY; float* nZZZZ; M3tVector3D* curViewVector = worldViewVectors; - + pXXXX = (float*)worldPoints; pYYYY = (float*)worldPoints + 4; pZZZZ = (float*)worldPoints + 8; nXXXX = (float*)worldVertexNormals; nYYYY = (float*)worldVertexNormals + 4; nZZZZ = (float*)worldVertexNormals + 8; - + for(itr = 0; itr < (numPoints >> 2); itr++) { newEnvMap = MSgGeomContextPrivate->debugEnvMap + MSgGeomContextPrivate->numDebugEnvMap++; @@ -1022,7 +1022,7 @@ MSiGeometry_Draw_BackFaceRemove_ClipAccept_ShadeVertex( newEnvMap->view.y = newEnvMap->origin.y + curViewVector->y; newEnvMap->view.z = newEnvMap->origin.z + curViewVector->z; curViewVector++; - + newEnvMap = MSgGeomContextPrivate->debugEnvMap + MSgGeomContextPrivate->numDebugEnvMap++; newEnvMap->origin.x = pXXXX[1]; newEnvMap->origin.y = pYYYY[1]; @@ -1034,7 +1034,7 @@ MSiGeometry_Draw_BackFaceRemove_ClipAccept_ShadeVertex( newEnvMap->view.y = newEnvMap->origin.y + curViewVector->y; newEnvMap->view.z = newEnvMap->origin.z + curViewVector->z; curViewVector++; - + newEnvMap = MSgGeomContextPrivate->debugEnvMap + MSgGeomContextPrivate->numDebugEnvMap++; newEnvMap->origin.x = pXXXX[2]; newEnvMap->origin.y = pYYYY[2]; @@ -1046,7 +1046,7 @@ MSiGeometry_Draw_BackFaceRemove_ClipAccept_ShadeVertex( newEnvMap->view.y = newEnvMap->origin.y + curViewVector->y; newEnvMap->view.z = newEnvMap->origin.z + curViewVector->z; curViewVector++; - + newEnvMap = MSgGeomContextPrivate->debugEnvMap + MSgGeomContextPrivate->numDebugEnvMap++; newEnvMap->origin.x = pXXXX[3]; newEnvMap->origin.y = pYYYY[3]; @@ -1093,7 +1093,7 @@ MSiGeometry_Draw_BackFaceRemove_ClipAccept_ShadeVertex( worldVertexNormals, screenVertexShades, activeVerticesBV); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, @@ -1103,7 +1103,7 @@ MSiGeometry_Draw_BackFaceRemove_ClipAccept_ShadeVertex( // 6. Clip and draw all active faces curIndexPtr = inGeometryObject->triStripArray->indices; - + #if 1 MSiGeometry_Draw_Triangles_In_BitVector(activeTrisBV, activeVerticesBV, numTris, curIndexPtr); #else @@ -1116,18 +1116,18 @@ MSiGeometry_Draw_BackFaceRemove_ClipAccept_ShadeVertex( unsigned int strips; unsigned int calls; } MSgCounters; - + MSgCounters.calls++; MSgCounters.tris += numTris; - + UUmBitVector_Loop_Begin(i, numTris, activeTrisBV) { index2 = *curIndexPtr++; - + if(index2 & 0x80000000) { MSgCounters.strips++; - + index0 = (index2 & 0x7FFFFFFF); index1 = *curIndexPtr++; index2 = *curIndexPtr++; @@ -1141,15 +1141,15 @@ MSiGeometry_Draw_BackFaceRemove_ClipAccept_ShadeVertex( { M3tTri curTri; - + curTri.indices[0] = index0; curTri.indices[1] = index1; curTri.indices[2] = index2; - + M3rDraw_Triangle(&curTri); } } - + index0 = index1; index1 = index2; } @@ -1164,13 +1164,13 @@ static void MSiGeometry_Draw_Triangles_In_BitVector(UUtUns32 *activeTrisBV, UUtU { UUtUns32 index0, index1, index2, i; // M3rDraw_Triangle_Func triFunc; - + // triFunc = M3rDraw_GetTriangleFunction(); - + UUmBitVector_Loop_Begin(i, numTris, activeTrisBV) { index2 = *indicies++; - + if(index2 & 0x80000000) { index0 = (index2 & 0x7FFFFFFF); @@ -1186,16 +1186,16 @@ static void MSiGeometry_Draw_Triangles_In_BitVector(UUtUns32 *activeTrisBV, UUtU { M3tTri curTri; - + curTri.indices[0] = index0; curTri.indices[1] = index1; curTri.indices[2] = index2; - + // triFunc(&curTri); M3rDraw_Triangle(&curTri); } } - + index0 = index1; index1 = index2; } @@ -1223,17 +1223,17 @@ MSrGeomContext_Method_Geometry_Draw( UUtError error; MSgGeomContextPrivate->numDebugEnvMap = 0; - + UUmAssertReadPtr(MSgGeomContextPrivate, sizeof(MStGeomContextPrivate)); UUmAssertReadPtr(inGeometryObject, sizeof(M3tGeometry)); - + clipCodes = MSgGeomContextPrivate->objectVertexData.clipCodes; frustumPoints = MSgGeomContextPrivate->objectVertexData.frustumPoints; screenPoints = MSgGeomContextPrivate->objectVertexData.screenPoints; - + UUmAssert(inGeometryObject->pointArray->numPoints < M3cMaxObjVertices); UUmAssert((inGeometryObject->triNormalArray == NULL) || inGeometryObject->triNormalArray->numVectors < M3cMaxObjTris); - + // TMrInstance_PrepareForUse(inGeometryObject); MSrTransform_UpdateMatrices(); @@ -1241,91 +1241,91 @@ MSrGeomContext_Method_Geometry_Draw( clipStatus = MSgGeomContextPrivate->activeFunctions->transformBoundingBoxClipStatus( inGeometryObject); - + if(clipStatus == MScClipStatus_TrivialReject) { return UUcError_None; } - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + if(gNo4DClip && clipStatus == MScClipStatus_Needs4DClipping) { return UUcError_None; } - + if(clipStatus == MScClipStatus_Needs3DClipping && gClipForce4D) { clipStatus = MScClipStatus_Needs4DClipping; } - + #endif - + M3rDraw_State_Push(); - + M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, inGeometryObject->pointArray->numPoints); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenPointArray, screenPoints); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenShadeArray_DC, MSgGeomContextPrivate->shades_vertex); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Clipping, clipStatus != MScClipStatus_TrivialAccept); - + M3rDraw_State_SetInt( M3cDrawStateIntType_VertexFormat, M3cDrawStateVertex_Unified); - + #if 0 *((UUtUns32*)&MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Appearance]) = M3cGeomState_Appearance_Gouraud; *((UUtUns32*)&MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Shade]) = M3cGeomState_Shade_Face; #endif - + // set up clip data //MSgGeomContextPrivate->curClipData = &MSgGeomContextPrivate->objectVertexData; MSgGeomContextPrivate->objectVertexData.newClipTextureIndex = 0x5555; // garbage MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = 0x5555; // garbage - will be set later - MSgGeomContextPrivate->objectVertexData.maxClipVertices = + MSgGeomContextPrivate->objectVertexData.maxClipVertices = MSgGeomContextPrivate->objectVertexData.newClipVertexIndex + M3cExtraCoords; MSgGeomContextPrivate->objectVertexData.maxClipTextureCords = 0; - + if(MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Appearance] == M3cGeomState_Appearance_Texture) { - + UUmAssert(inGeometryObject->baseMap != NULL); - - + + M3rDraw_State_SetPtr( M3cDrawStatePtrType_TextureCoordArray, inGeometryObject->texCoordArray->textureCoords); - + MSgGeomContextPrivate->objectVertexData.textureCoords = inGeometryObject->texCoordArray->textureCoords; - + UUmAssert(inGeometryObject->texCoordArray->numTextureCoords == inGeometryObject->pointArray->numPoints); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, inGeometryObject->baseMap); - + if(inGeometryObject->baseMap->flags & M3cTextureFlags_ReceivesEnvMap) { M3rDraw_State_SetInt( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Texture_Lit_EnvMap); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_EnvTextureCoordArray, MSgGeomContextPrivate->envMapCoords); - + if(inGeometryObject->baseMap->envMap != NULL) { M3rDraw_State_SetPtr( @@ -1336,7 +1336,7 @@ MSrGeomContext_Method_Geometry_Draw( { UUmAssert(M3rDraw_State_GetPtr(M3cDrawStatePtrType_EnvTextureMap) != NULL); } - MSgGeomContextPrivate->polyComputeVertexProc = + MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_TextureEnvInterpolate; } else @@ -1350,7 +1350,7 @@ MSrGeomContext_Method_Geometry_Draw( M3rDraw_State_SetPtr( M3cDrawStatePtrType_EnvTextureMap, NULL); - MSgGeomContextPrivate->polyComputeVertexProc = + MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_TextureInterpolate; } } @@ -1362,15 +1362,15 @@ MSrGeomContext_Method_Geometry_Draw( M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, IMcShade_Red); - MSgGeomContextPrivate->polyComputeVertexProc = + MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_GouraudInterpolate; } - + //Backfacing: On/Off //Clipping: Triv, 3D, 4D //Shade: Vert, Face error = UUcError_None; - + if(1 && (inGeometryObject->geometryFlags & M3cGeometryFlag_RemoveBackface)) { if(clipStatus == MScClipStatus_TrivialAccept) @@ -1431,37 +1431,37 @@ MSrGeomContext_Method_Geometry_Draw( } M3rDraw_State_Pop(); - + #if 0 && TOOL_VERSION { UUtUns32 dItr; - + M3rMatrixStack_Push(); M3rMatrixStack_Identity(); - + for(dItr = 0; dItr < MSgGeomContextPrivate->numDebugEnvMap; dItr++) { MSgGeomContextPrivate->submitPoints[0] = MSgGeomContextPrivate->debugEnvMap[dItr].origin; MSgGeomContextPrivate->submitPoints[1] = MSgGeomContextPrivate->debugEnvMap[dItr].normal; - + MSrGeomContext_Method_Geometry_LineDraw( 2, MSgGeomContextPrivate->submitPoints, IMcShade_White); - + #if 0 MSgGeomContextPrivate->submitPoints[0] = MSgGeomContextPrivate->debugEnvMap[dItr].origin; MSgGeomContextPrivate->submitPoints[1] = MSgGeomContextPrivate->debugEnvMap[dItr].reflection; - + MSrGeomContext_Method_Geometry_LineDraw( 2, MSgGeomContextPrivate->submitPoints, IMcShade_Red); #endif - + MSgGeomContextPrivate->submitPoints[0] = MSgGeomContextPrivate->debugEnvMap[dItr].origin; MSgGeomContextPrivate->submitPoints[1] = MSgGeomContextPrivate->debugEnvMap[dItr].view; - + MSrGeomContext_Method_Geometry_LineDraw( 2, MSgGeomContextPrivate->submitPoints, @@ -1474,7 +1474,7 @@ MSrGeomContext_Method_Geometry_Draw( return error; } - + UUtError MSrGeomContext_Method_Geometry_PolyDraw( UUtUns32 inNumPoints, @@ -1486,7 +1486,7 @@ MSrGeomContext_Method_Geometry_PolyDraw( UUtUns8* clipCodes; UUtUns32 i; M3tTri newTri; - + frustumPoints = MSgGeomContextPrivate->objectVertexData.frustumPoints; clipCodes = MSgGeomContextPrivate->objectVertexData.clipCodes; screenPoints = MSgGeomContextPrivate->objectVertexData.screenPoints; @@ -1527,13 +1527,13 @@ MSrGeomContext_Method_Geometry_PolyDraw( M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, inNumPoints); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, NULL); M3rDraw_State_Commit(); - + for(i = 1; i < inNumPoints - 1; i++) { if(clipCodes[0] | clipCodes[i] | clipCodes[i+1]) @@ -1552,7 +1552,7 @@ MSrGeomContext_Method_Geometry_PolyDraw( newTri.indices[0] = 0; newTri.indices[1] = i; newTri.indices[2] = (i+1); - + M3rDraw_Triangle(&newTri); } } @@ -1561,7 +1561,7 @@ MSrGeomContext_Method_Geometry_PolyDraw( return UUcError_None; } - + UUtError MSrGeomContext_Method_Geometry_LineDraw( UUtUns32 inNumPoints, @@ -1592,7 +1592,7 @@ MSrGeomContext_Method_Geometry_LineDraw( clipCodes); MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = inNumPoints; - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenPointArray, screenPoints); @@ -1600,7 +1600,7 @@ MSrGeomContext_Method_Geometry_LineDraw( M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, inShade); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Gouraud); @@ -1608,13 +1608,13 @@ MSrGeomContext_Method_Geometry_LineDraw( M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, 0); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, NULL); M3rDraw_State_Commit(); - + for(i = 0; i < inNumPoints - 1; i++) { if(clipCodes[i] | clipCodes[i+1]) @@ -1652,7 +1652,7 @@ MSrGeomContext_Method_Geometry_LineDraw2D( w = (float)M3rDraw_GetWidth(); h = (float)M3rDraw_GetHeight(); MSrTransform_UpdateMatrices(); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenPointArray, inPoints); @@ -1660,17 +1660,17 @@ MSrGeomContext_Method_Geometry_LineDraw2D( M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, inShade); - + M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, 0); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, NULL); M3rDraw_State_Commit(); - + for(i = 0; i < inNumPoints - 1; i++) { // Do braindead clipping @@ -1678,7 +1678,7 @@ MSrGeomContext_Method_Geometry_LineDraw2D( else if (inPoints[i].x > w) inPoints[i].x = w; if (inPoints[i].y < 0.0f) inPoints[i].y = 0.0f; else if (inPoints[i].y > h) inPoints[i].y = h; - + M3rDraw_Line(i, (i+1)); } @@ -1718,7 +1718,7 @@ MSrGeomContext_Method_Geometry_PointDraw( clipCodes); MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = inNumPoints; - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenPointArray, screenPoints); @@ -1726,17 +1726,17 @@ MSrGeomContext_Method_Geometry_PointDraw( M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, inShade); - + M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, 0); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, NULL); M3rDraw_State_Commit(); - + for(i = 0; i < inNumPoints; i++) { if(clipCodes[i]) @@ -1789,7 +1789,7 @@ MSiSprite_Draw_Unoriented( float yScale = drawHeight * 1.041666667f; // S.S. (500.f / 480.f); float preClipWidth, preClipHeight; - + UUmAssertReadPtr(inTextureMap, sizeof(*inTextureMap)); UUmAssertReadPtr(inPoint, sizeof(*inPoint)); @@ -1821,7 +1821,7 @@ MSiSprite_Draw_Unoriented( if (inXOffset != 0.f) { spriteScreenPoints[0].x = spriteScreenPoints[1].x = screenPoint->x + xd * inXOffset; } - + spriteScreenPoints[0].x -= xd; spriteScreenPoints[1].x += xd; spriteScreenPoints[0].y -= yd; spriteScreenPoints[1].y += yd; @@ -1838,7 +1838,7 @@ MSiSprite_Draw_Unoriented( if ((spriteScreenPoints[0].x >= drawWidth) || (spriteScreenPoints[0].y >= drawHeight) || (spriteScreenPoints[1].x <= 0) || - (spriteScreenPoints[1].y <= 0) || + (spriteScreenPoints[1].y <= 0) || (frustumPoint->z <= MSgGeomContextPrivate->activeCamera->zNear) || (frustumPoint->z >= MSgGeomContextPrivate->activeCamera->zFar)) { @@ -1896,17 +1896,17 @@ MSiSprite_Draw_Unoriented( spriteTextureFinal[2].v = spriteTextureCoords[1].v; spriteTextureFinal[3].u = spriteTextureCoords[1].u; // br spriteTextureFinal[3].v = spriteTextureCoords[1].v; - + M3rDraw_State_Push(); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, inTextureMap); - + M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, 0); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, NULL); @@ -1914,23 +1914,23 @@ MSiSprite_Draw_Unoriented( M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, inShade); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Alpha, inAlpha); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); - + M3rDraw_State_Commit(); - + M3rDraw_Sprite( - spriteScreenPoints, + spriteScreenPoints, spriteTextureFinal); - + M3rDraw_State_Pop(); - + return UUcError_None; } @@ -1962,7 +1962,7 @@ MSrGeomContext_Method_Sprite_Draw( } MSrTransform_UpdateMatrices(); - + // get the active camera's position and orientation cameraPos = &MSgGeomContextPrivate->activeCamera->cameraLocation; cameraFwd = &MSgGeomContextPrivate->activeCamera->viewVector; @@ -1986,14 +1986,14 @@ MSrGeomContext_Method_Sprite_Draw( case M3cGeomState_SpriteMode_Rotated: // CB: this is a rotated sprite that faces the screen. calculate the // orientation of the sprite. - - if (inOrientation != NULL) { + + if (inOrientation != NULL) { // oriented towards particle's +Y MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 1, &particleDir); // UUmAssert(MUmVector_IsNormalized(particleDir)); spriteorient_x = MUrVector_DotProduct(cameraRight, &particleDir); spriteorient_y = MUrVector_DotProduct(cameraUp, &particleDir); - + } else if (inDirection != NULL) { // oriented towards particle's direction spriteorient_x = MUrVector_DotProduct(cameraRight, inDirection); @@ -2003,7 +2003,7 @@ MSrGeomContext_Method_Sprite_Draw( spriteorient_x = 1.0f; spriteorient_y = 0.0f; } - + d = UUmSQR(spriteorient_x) + UUmSQR(spriteorient_y); if (d < 1e-08) { spriteorient_x = 1.0f; @@ -2014,7 +2014,7 @@ MSrGeomContext_Method_Sprite_Draw( spriteorient_x /= d; spriteorient_y /= d; } - + // the sprite faces the camera sprite_X.x = spriteorient_x * cameraRight->x + spriteorient_y * cameraUp->x; sprite_X.y = spriteorient_x * cameraRight->y + spriteorient_y * cameraUp->y; @@ -2027,8 +2027,8 @@ MSrGeomContext_Method_Sprite_Draw( case M3cGeomState_SpriteMode_Billboard: // CB: this sprite is oriented along its direction but perpendicular to the camera - if (inOrientation != NULL) { - MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 1, &sprite_X); + if (inOrientation != NULL) { + MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 1, &sprite_X); } else if (inDirection != NULL) { // oriented towards particle's direction d = MUmVector_GetLengthSquared(*inDirection); @@ -2044,7 +2044,7 @@ MSrGeomContext_Method_Sprite_Draw( } else { UUmAssert(!"oriented particle supplied no orientation or direction"); } - + MUmVector_Subtract(cameraDir, *inPoint, *cameraPos); MUrVector_CrossProduct(&sprite_X, &cameraDir, &sprite_Y); MUmVector_Normalize(sprite_Y); @@ -2053,22 +2053,22 @@ MSrGeomContext_Method_Sprite_Draw( case M3cGeomState_SpriteMode_Arrow: // CB: this sprite is oriented along its direction and upvector UUmAssert(inOrientation != NULL); - MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 1, &sprite_X); - MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 2, &sprite_Y); + MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 1, &sprite_X); + MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 2, &sprite_Y); break; case M3cGeomState_SpriteMode_Discus: // CB: this sprite is oriented along its direction and rightvector UUmAssert(inOrientation != NULL); - MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 1, &sprite_X); - MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 0, &sprite_Y); + MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 1, &sprite_X); + MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 0, &sprite_Y); break; case M3cGeomState_SpriteMode_Flat: // CB: this sprite is oriented perpendicular to its direction UUmAssert(inOrientation != NULL); - MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 0, &sprite_X); - MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 2, &sprite_Y); + MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 0, &sprite_X); + MUrMatrix_GetCol((M3tMatrix4x3 *) inOrientation, 2, &sprite_Y); break; default: @@ -2084,7 +2084,7 @@ MSrGeomContext_Method_Sprite_Draw( UUtInt16 pi_multiples; float theta, costheta, sintheta; M3tVector3D temp_x; - + // convert theta into radians between 0 and 2pi theta = inRotation * 0.01745329252f; // S.S. M3c2Pi / 360.0f; pi_multiples = (UUtInt16)(theta * 0.1591549431f); // S.S. (theta / M3c2Pi); @@ -2097,7 +2097,7 @@ MSrGeomContext_Method_Sprite_Draw( sintheta = MUrSqrt(1.0f - UUmSQR(costheta)); if (theta > M3cPi) sintheta = -sintheta; - + temp_x.x = sprite_X.x * costheta - sprite_Y.x * sintheta; temp_x.y = sprite_X.y * costheta - sprite_Y.y * sintheta; temp_x.z = sprite_X.z * costheta - sprite_Y.z * sintheta; @@ -2122,15 +2122,15 @@ MSrGeomContext_Method_Sprite_Draw( UUtUns8 clipCode[4]; MStClipStatus clipStatus; - + M3tQuad quadIndices; UUmAssertReadPtr(inTextureMap, sizeof(*inTextureMap)); UUmAssertReadPtr(inPoint, sizeof(*inPoint)); - + MSrTransform_UpdateMatrices(); - - + + MUmVector_Scale(sprite_X, inHorizSize); MUmVector_Scale(sprite_Y, inVertSize); @@ -2153,7 +2153,7 @@ MSrGeomContext_Method_Sprite_Draw( x_0 = (1.0f - inXShorten) * (inXOffset - 1.0f); u_0 = 0.0f - 0.5f * inXShorten * (inXOffset - 1.0f); x_1 = (1.0f - inXShorten) * (inXOffset + 1.0f); u_1 = 1.0f - 0.5f * inXShorten * (inXOffset + 1.0f); - + if (inXChop != 0.0f) { // remove a certain amount from the front of the sprite x_1 -= 2.0f * inXChop; @@ -2167,25 +2167,25 @@ MSrGeomContext_Method_Sprite_Draw( worldPoint[0].x = inPoint->x + x_0 * sprite_X.x - sprite_Y.x; worldPoint[0].y = inPoint->y + x_0 * sprite_X.y - sprite_Y.y; worldPoint[0].z = inPoint->z + x_0 * sprite_X.z - sprite_Y.z; - + worldPoint[1].x = inPoint->x + x_1 * sprite_X.x - sprite_Y.x; worldPoint[1].y = inPoint->y + x_1 * sprite_X.y - sprite_Y.y; worldPoint[1].z = inPoint->z + x_1 * sprite_X.z - sprite_Y.z; - + worldPoint[2].x = inPoint->x + x_0 * sprite_X.x + sprite_Y.x; worldPoint[2].y = inPoint->y + x_0 * sprite_X.y + sprite_Y.y; worldPoint[2].z = inPoint->z + x_0 * sprite_X.z + sprite_Y.z; - + worldPoint[3].x = inPoint->x + x_1 * sprite_X.x + sprite_Y.x; worldPoint[3].y = inPoint->y + x_1 * sprite_X.y + sprite_Y.y; worldPoint[3].z = inPoint->z + x_1 * sprite_X.z + sprite_Y.z; - + // transform these points into the global transformed object data arrays clipStatus = MSrTransform_PointListToFrustumScreen(4, worldPoint, frustumPoint, screenPoint, clipCode); - + if (clipStatus == MScClipStatus_TrivialReject) return UUcError_None; - + spriteTextureCoords[0].u = u_0; spriteTextureCoords[0].v = 0.f; spriteTextureCoords[1].u = u_1; @@ -2194,17 +2194,17 @@ MSrGeomContext_Method_Sprite_Draw( spriteTextureCoords[2].v = 1.f; spriteTextureCoords[3].u = u_1; spriteTextureCoords[3].v = 1.f; - + M3rDraw_State_Push(); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenPointArray, screenPoint); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, inTextureMap); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_TextureCoordArray, spriteTextureCoords); @@ -2213,25 +2213,25 @@ MSrGeomContext_Method_Sprite_Draw( M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, 4); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, NULL); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); - + M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, inShade); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Alpha, inAlpha); - + M3rDraw_State_Commit(); - + if (clipStatus == MScClipStatus_NeedsClipping) { MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = 4; MSgGeomContextPrivate->objectVertexData.maxClipTextureCords = 4 + M3cExtraCoords; @@ -2247,7 +2247,7 @@ MSrGeomContext_Method_Sprite_Draw( quadIndices.indices[3] = 2; M3rDraw_Quad(&quadIndices); } - + M3rDraw_State_Pop(); // we allocated contrailTextureCoords off the stack, so after our exit from here @@ -2294,7 +2294,7 @@ MSrGeomContext_Method_SpriteArray_Draw( float xScale = drawWidth * 0.78125f; // S.S. (500.f / 640.f); float yScale = drawHeight * 1.04166667f; // S.S. (500.f / 480.f); UUtUns32 i; - UUtBool old_sorting; + UUtBool old_sorting; float preClipWidth, preClipHeight; M3tSpriteInstance* instance; @@ -2311,7 +2311,7 @@ MSrGeomContext_Method_SpriteArray_Draw( UUmAssert(UUmFloat_CompareEqu(MUrVector_DotProduct(cameraUp, cameraFwd ), 0)); UUmAssert(UUmFloat_CompareEqu(MUrVector_DotProduct(cameraUp, cameraRight), 0)); UUmAssert(UUmFloat_CompareEqu(MUrVector_DotProduct(cameraFwd, cameraRight), 0)); -*/ +*/ old_sorting = M3gDraw_Sorting; M3gDraw_Sorting = UUcFalse; @@ -2338,7 +2338,7 @@ MSrGeomContext_Method_SpriteArray_Draw( M3gDraw_SpriteArray_ScreenPoints[j*2+1].x = screenPoint->x + xd; if( M3gDraw_SpriteArray_ScreenPoints[j*2+1].x <= 0 ) continue; - + M3gDraw_SpriteArray_ScreenPoints[j*2+1].y = screenPoint->y + yd; if( M3gDraw_SpriteArray_ScreenPoints[j*2+1].y <= 0 ) continue; @@ -2381,7 +2381,7 @@ MSrGeomContext_Method_SpriteArray_Draw( spriteTextureCoords[1].u -= 1.f - (newAmount / oldAmount); } - if( M3gDraw_SpriteArray_ScreenPoints[j*2+1].y >= drawHeight ) + if( M3gDraw_SpriteArray_ScreenPoints[j*2+1].y >= drawHeight ) { oldAmount = preClipHeight; newAmount = preClipHeight - (M3gDraw_SpriteArray_ScreenPoints[j*2+1].y - drawHeight); @@ -2402,24 +2402,24 @@ MSrGeomContext_Method_SpriteArray_Draw( j++; } - + //M3rDraw_State_Commit(); if( j ) { M3rDraw_State_Push(); - + M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap,inSpriteArray->texture_map); - + M3rDraw_State_SetInt(M3cDrawStateIntType_NumRealVertices,0); - + M3rDraw_State_SetPtr(M3cDrawStatePtrType_VertexBitVector,NULL); - + M3rDraw_State_SetInt(M3cDrawStateIntType_Alpha, M3cMaxAlpha); - + M3rDraw_State_SetInt(M3cDrawStateIntType_Interpolation,M3cDrawState_Interpolation_None); M3rDraw_State_Commit(); - + M3rDraw_SpriteArray( M3gDraw_SpriteArray_ScreenPoints, M3gDraw_SpriteArray_TextureCoords, M3gDraw_SpriteArray_Colors, j ); M3rDraw_State_Pop(); @@ -2445,20 +2445,20 @@ MSrGeomContext_Method_Contrail_Draw( M3tTextureCoord contrailTextureCoords[4 + M3cExtraCoords]; UUtUns32 contrailShades[4 + M3cExtraCoords]; UUtUns8 clipCode[4]; - MStClipStatus clipStatus; + MStClipStatus clipStatus; M3tQuad quadIndices; - + UUmAssertReadPtr(inTextureMap, sizeof(*inTextureMap)); UUmAssertReadPtr(inPoint0, sizeof(*inPoint0)); UUmAssertReadPtr(inPoint1, sizeof(*inPoint1)); - + MSrTransform_UpdateMatrices(); - + // make the contrail's world points and store in the global geomcontext's world point array worldPoint[0].x = inPoint0->position.x + inPoint0->width.x; worldPoint[0].y = inPoint0->position.y + inPoint0->width.y; worldPoint[0].z = inPoint0->position.z + inPoint0->width.z; - + worldPoint[1].x = inPoint0->position.x - inPoint0->width.x; worldPoint[1].y = inPoint0->position.y - inPoint0->width.y; worldPoint[1].z = inPoint0->position.z - inPoint0->width.z; @@ -2466,17 +2466,17 @@ MSrGeomContext_Method_Contrail_Draw( worldPoint[2].x = inPoint1->position.x + inPoint1->width.x; worldPoint[2].y = inPoint1->position.y + inPoint1->width.y; worldPoint[2].z = inPoint1->position.z + inPoint1->width.z; - + worldPoint[3].x = inPoint1->position.x - inPoint1->width.x; worldPoint[3].y = inPoint1->position.y - inPoint1->width.y; worldPoint[3].z = inPoint1->position.z - inPoint1->width.z; // transform these points into the global transformed object data arrays clipStatus = MSrTransform_PointListToFrustumScreen(4, worldPoint, frustumPoint, screenPoint, clipCode); - + if (clipStatus == MScClipStatus_TrivialReject) return UUcError_None; - + contrailTextureCoords[0].u = 0.f; contrailTextureCoords[0].v = inV0; contrailTextureCoords[1].u = 1.f; @@ -2485,17 +2485,17 @@ MSrGeomContext_Method_Contrail_Draw( contrailTextureCoords[2].v = inV1; contrailTextureCoords[3].u = 1.f; contrailTextureCoords[3].v = inV1; - + M3rDraw_State_Push(); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenPointArray, screenPoint); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, inTextureMap); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_TextureCoordArray, contrailTextureCoords); @@ -2504,11 +2504,11 @@ MSrGeomContext_Method_Contrail_Draw( M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, 4); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, NULL); - + if (inPoint0->tint == inPoint1->tint) { M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, @@ -2517,7 +2517,7 @@ MSrGeomContext_Method_Contrail_Draw( M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, inPoint0->tint); - + } else { contrailShades[0] = inPoint0->tint; contrailShades[1] = inPoint0->tint; @@ -2536,9 +2536,9 @@ MSrGeomContext_Method_Contrail_Draw( M3rDraw_State_SetInt( M3cDrawStateIntType_Alpha, inPoint0->alpha); - + M3rDraw_State_Commit(); - + if (clipStatus == MScClipStatus_NeedsClipping) { MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = 4; MSgGeomContextPrivate->objectVertexData.maxClipTextureCords = 4 + M3cExtraCoords; @@ -2553,7 +2553,7 @@ MSrGeomContext_Method_Contrail_Draw( quadIndices.indices[2] = 3; quadIndices.indices[3] = 2; M3rDraw_Quad(&quadIndices); - } + } // we allocated contrailTextureCoords off the stack, so after our exit from here // it will be invalid. nothing should be using MSgGeomContextPrivate->objectVertexData.textureCoords @@ -2624,7 +2624,7 @@ MSrGeomContext_Method_PointTestVisible( } else { float test_distance; M3tVector3D unit_vector; - + test_distance = MUmVector_GetLength(vector_to_pt); if (test_distance < 1e-03f) { // the points are coincident, we can see clearly @@ -2647,7 +2647,7 @@ MSrGeomContext_Method_PointTestVisible( float MSrGeomContext_Method_PointTestVisibleScale( - M3tPoint3D* inPoint, + M3tPoint3D* inPoint, M3tPoint2D* inTestOffsets, UUtUns32 inTestOffsetsCount ) { @@ -2667,7 +2667,7 @@ MSrGeomContext_Method_PointTestVisibleScale( UUmAssert( inTestOffsetsCount && inPoint && inTestOffsets ); - if (screenPoint == NULL) + if (screenPoint == NULL) { // set up the memory-aligned pointers screenPoint = UUrAlignMemory(screenBuf); @@ -2682,9 +2682,9 @@ MSrGeomContext_Method_PointTestVisibleScale( MUmVector_ScaleIncrement(*worldPoint, 0, MSgGeomContextPrivate->activeCamera->viewVector); MSrTransform_UpdateMatrices(); - + visible_count = 0; - + for( i = 0; i < inTestOffsetsCount; i++ ) { clip_status = MSrTransform_PointListToFrustumScreen(1, worldPoint, frustumPoint, screenPoint, &clip_code); @@ -2700,7 +2700,7 @@ MSrGeomContext_Method_PointTestVisibleScale( #define MScMinUV (0.0f) #define MScMaxUV (1.0f) -UUtError MSrGeomContext_Method_Skybox_Create( +UUtError MSrGeomContext_Method_Skybox_Create( M3tSkyboxData *inSkybox, M3tTextureMap** inTextures ) { @@ -2719,7 +2719,7 @@ UUtError MSrGeomContext_Method_Skybox_Create( { sky->textures[i] = inTextures[i]; } - + sky->cube_points[0].x = -sky_distance; sky->cube_points[0].y = sky_distance; sky->cube_points[0].z = -sky_distance; @@ -2789,7 +2789,7 @@ UUtError MSrGeomContext_Method_Skybox_Create( return UUcError_None; } -UUtError MSrGeomContext_Method_Skybox_Destroy( +UUtError MSrGeomContext_Method_Skybox_Destroy( M3tSkyboxData *inSkybox ) { return UUcError_None; @@ -2816,7 +2816,7 @@ UUtError MSrGeomContext_Method_Skybox_Draw( M3tSkyboxData *inSkybox ) // setup matricies and camera MSrTransform_UpdateMatrices(); - + // grab buffers aligned_points = UUrAlignMemory(point_buf); clip_codes = MSgGeomContextPrivate->objectVertexData.clipCodes; @@ -2853,15 +2853,15 @@ UUtError MSrGeomContext_Method_Skybox_Draw( M3tSkyboxData *inSkybox ) clip_status = MSrTransform_PointListToFrustumScreen( 4, aligned_points, frustum_points, screen_points, clip_codes ); if( clip_status == MScClipStatus_TrivialReject ) continue; - else if (clip_status == MScClipStatus_NeedsClipping) + else if (clip_status == MScClipStatus_NeedsClipping) { MSgGeomContextPrivate->objectVertexData.newClipVertexIndex = 4; MSgGeomContextPrivate->objectVertexData.maxClipTextureCords = M3cMaxSkyboxVerts; MSgGeomContextPrivate->objectVertexData.maxClipVertices = M3cMaxSkyboxVerts; MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_TextureFlat; MSrClip_Quad(0, 1, 2, 3, clip_codes[0], clip_codes[1], clip_codes[2], clip_codes[3], 0); - } - else + } + else { M3rDraw_Quad(&quad); } @@ -2900,7 +2900,7 @@ MSrGeomContext_Method_Decal_Draw( UUtUns8 point_buf[sizeof(M3tPoint3D) * M3cMaxSkyboxVerts + UUcProcessor_CacheLineSize]; UUtUns32 *shades; UUtUns32 alpha; - + MSrTransform_UpdateMatrices(); UUmAssertReadPtr(MSgGeomContextPrivate, sizeof(MSgGeomContextPrivate)); @@ -2909,7 +2909,7 @@ MSrGeomContext_Method_Decal_Draw( clip_codes = MSgGeomContextPrivate->objectVertexData.clipCodes; frustum_points = MSgGeomContextPrivate->objectVertexData.frustumPoints; screen_points = MSgGeomContextPrivate->objectVertexData.screenPoints; - + // if(MSgGeomContextPrivate->environment->lightMapArray != NULL) // lightMapArray = MSgGeomContextPrivate->environment->lightMapArray->maps; // else @@ -2959,16 +2959,16 @@ MSrGeomContext_Method_Decal_Draw( M3rDraw_State_Commit(); - for( i = 0; i < tri_count; i++ ) + for( i = 0; i < tri_count; i++ ) { UUtUns32 index0 = indices[i*3+0]; UUtUns32 index1 = indices[i*3+1]; UUtUns32 index2 = indices[i*3+2]; - + aligned_points[0] = points[index0]; aligned_points[1] = points[index1]; aligned_points[2] = points[index2]; - + texture_coords[0] = coords[index0]; texture_coords[1] = coords[index1]; texture_coords[2] = coords[index2]; @@ -2976,7 +2976,7 @@ MSrGeomContext_Method_Decal_Draw( clip_status = MSrTransform_PointListToFrustumScreen( 3, aligned_points, frustum_points, screen_points, clip_codes ); if( clip_status == MScClipStatus_TrivialReject ) continue; - if( clip_codes[0] || clip_codes[1] || clip_codes[2] ) + if( clip_codes[0] || clip_codes[1] || clip_codes[2] ) { MSgGeomContextPrivate->gqVertexData.newClipTextureIndex = 4; MSgGeomContextPrivate->gqVertexData.newClipVertexIndex = 4; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Geometry.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Geometry.h index 3c1d560..415e80e 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Geometry.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Geometry.h @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Geometry.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -31,7 +31,7 @@ MSrGeomContext_Method_Sprite_Draw( M3tMatrix3x3* inOrientation, float inXOffset, float inXShorten, - float inXChop); + float inXChop); UUtError MSrGeomContext_Method_SpriteArray_Draw( @@ -48,13 +48,13 @@ MSrGeomContext_Method_Contrail_Draw( UUtError MSrGeomContext_Method_Geometry_Draw( M3tGeometry* inGeometryObject); - + UUtError MSrGeomContext_Method_Geometry_PolyDraw( UUtUns32 inNumPoints, M3tPoint3D* inPoints, UUtUns32 inShade); - + UUtError MSrGeomContext_Method_Geometry_LineDraw( UUtUns32 inNumPoints, @@ -78,8 +78,8 @@ MSrGeomContext_Method_PointTestVisibleScale( M3tPoint2D* inTestOffsets, UUtUns32 inTestOffsetsCount ); -UUtError -MSrGeomContext_Method_Skybox_Draw( +UUtError +MSrGeomContext_Method_Skybox_Draw( M3tSkyboxData *inSkybox ); UUtError MSrGeomContext_Method_Skybox_Create( @@ -93,6 +93,6 @@ UUtError MSrGeomContext_Method_Decal_Draw( M3tDecalHeader* inDecal, UUtUns16 inAlpha); - + #endif /* MS_GC_METHOD_GEOMETRY_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Light.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Light.c index 9fee6c7..5437a08 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Light.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Light.c @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Light.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -33,32 +33,32 @@ MSrGeomContext_Method_LightList_Directional( UUtUns16 itr; float mag; float nx, ny, nz; - + if(inNumLights > MScDirectionalLight_Max) inNumLights = MScDirectionalLight_Max; - + MSgGeomContextPrivate->light_NumDirectionalLights = inNumLights; - + for(itr = 0; itr < inNumLights; itr++) { nx = inLightList[itr].direction.x; ny = inLightList[itr].direction.y; nz = inLightList[itr].direction.x; - + mag = MUrSqrt(nx * nx + ny * ny + nz * nz); - - MSgGeomContextPrivate->light_DirectionalList[itr].color.r = + + MSgGeomContextPrivate->light_DirectionalList[itr].color.r = inLightList[itr].color.r * mag; - MSgGeomContextPrivate->light_DirectionalList[itr].color.g = + MSgGeomContextPrivate->light_DirectionalList[itr].color.g = inLightList[itr].color.g * mag; - MSgGeomContextPrivate->light_DirectionalList[itr].color.b = + MSgGeomContextPrivate->light_DirectionalList[itr].color.b = inLightList[itr].color.b * mag; - + mag = 1.0f / mag; - + MSgGeomContextPrivate->light_DirectionalList[itr].normalizedDirection.x = nx * mag; MSgGeomContextPrivate->light_DirectionalList[itr].normalizedDirection.y = ny * mag; MSgGeomContextPrivate->light_DirectionalList[itr].normalizedDirection.z = nz * mag; - + } } @@ -69,9 +69,9 @@ MSrGeomContext_Method_LightList_Point( M3tLight_Point* inLightList) { if(inNumLights > MScPointLight_Max) inNumLights = MScPointLight_Max; - - - + + + } void diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Light.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Light.h index 9e5a364..97cca5d 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Light.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Light.h @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Light.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Matrix.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Matrix.c index 64a81e7..71b5572 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Matrix.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Matrix.c @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Matrix.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -35,23 +35,23 @@ MSrGeomContext_Method_MatrixStack_Push( { UUtInt32* tosPtr; UUtInt32 tosValue; - + if(MSgGeomContextPrivate->matrix_TOS >= M3cModelMatrix_MaxDepth) { return UUcError_Generic; } - + tosPtr = &MSgGeomContextPrivate->matrix_TOS; - + tosValue = *tosPtr; - + (MSgGeomContextPrivate->matrixStack)[tosValue + 1] = (MSgGeomContextPrivate->matrixStack)[tosValue]; - *tosPtr += 1; - + *tosPtr += 1; + MSgGeomContextPrivate->matrixStackTop++; - + MSgGeomContextPrivate->matrixStackDirty = UUcTrue; MSmStackVerify(); @@ -75,13 +75,13 @@ MSrGeomContext_Method_MatrixStack_Pop( { *tosPtr -= 1; } - + MSgGeomContextPrivate->matrixStackTop--; - + MSgGeomContextPrivate->matrixStackDirty = UUcTrue; MSmStackVerify(); - + return UUcError_None; } @@ -92,7 +92,7 @@ MSrGeomContext_Method_MatrixStack_Get( M3tMatrix4x3 *curModelMatrix = (M3tMatrix4x3 *) MSgGeomContextPrivate->matrixStackTop; UUmAssertWritePtr(outMatrix3, sizeof(M3tMatrix4x3)); - + *outMatrix3 = *curModelMatrix; return UUcError_None; @@ -104,32 +104,32 @@ MSrGeomContext_Method_MatrixStack_Identity( { M3tMatrix4x3* m; UUtInt32 tosValue; - + tosValue = MSgGeomContextPrivate->matrix_TOS; - + m = &(MSgGeomContextPrivate->matrixStack)[tosValue]; - // build identity matrix + // build identity matrix m->m[0][0] = 1.0f; m->m[0][1] = 0.0f; m->m[0][2] = 0.0f; - + m->m[1][0] = 0.0f; m->m[1][1] = 1.0f; m->m[1][2] = 0.0f; - + m->m[2][0] = 0.0f; m->m[2][1] = 0.0f; m->m[2][2] = 1.0f; - + m->m[3][0] = 0.0f; m->m[3][1] = 0.0f; m->m[3][2] = 0.0f; - + MSgGeomContextPrivate->matrixStackDirty = UUcTrue; MSmStackVerify(); - + return UUcError_None; } @@ -137,10 +137,10 @@ UUtError MSrGeomContext_Method_MatrixStack_Clear( void) { - + // remove everything from the stack and the final element is the identity MSgGeomContextPrivate->matrix_TOS = 0; - + MSgGeomContextPrivate->matrixStackTop = MSgGeomContextPrivate->matrixStack; MSrGeomContext_Method_MatrixStack_Identity(); @@ -148,7 +148,7 @@ MSrGeomContext_Method_MatrixStack_Clear( MSgGeomContextPrivate->matrixStackDirty = UUcTrue; MSmStackVerify(); - + return UUcError_None; } @@ -176,14 +176,14 @@ MSrGeomContext_Method_MatrixStack_Rotate( UUmAssert(inY > -1e9f && inY < 1e9f); UUmAssert(inZ > -1e9f && inZ < 1e9f); UUmAssertTrigRange(inRadians); - + MUrMatrix_BuildRotate( inRadians, inX, inY, inZ, &matrix); - + MSmMatrixVerify(&matrix); MSiStackMultiply(&matrix); MSmStackVerify(); @@ -240,7 +240,7 @@ MSrGeomContext_Method_MatrixStack_Multiply( } void MSrGeomContext_Method_MatrixToQuat( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, M3tQuaternion *outQuat) { M3tMatrix4x3 *privateInMatrix = (M3tMatrix4x3 *) inMatrix; @@ -250,7 +250,7 @@ void MSrGeomContext_Method_MatrixToQuat( void MSrGeomContext_Method_QuatToMatrix( - const M3tQuaternion *inQuat, + const M3tQuaternion *inQuat, M3tMatrix4x3 *outMatrix) { M3tMatrix4x3 *privateOutMatrix = (M3tMatrix4x3 *) outMatrix; @@ -258,9 +258,9 @@ MSrGeomContext_Method_QuatToMatrix( MUrQuatToMatrix(inQuat, privateOutMatrix); } -void +void MSrGeomContext_Method_Matrix_GetTranslation( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, M3tPoint3D *outTranslation) { M3tMatrix4x3 *privateInMatrix = (M3tMatrix4x3 *) inMatrix; @@ -270,8 +270,8 @@ MSrGeomContext_Method_Matrix_GetTranslation( void MSrGeomContext_Method_Matrix_Multiply ( - const M3tMatrix4x3 *inMatrixA, - const M3tMatrix4x3 *inMatrixB, + const M3tMatrix4x3 *inMatrixA, + const M3tMatrix4x3 *inMatrixB, M3tMatrix4x3 *outResult) { M3tMatrix4x3 *pInA = (M3tMatrix4x3 *) inMatrixA; @@ -283,9 +283,9 @@ MSrGeomContext_Method_Matrix_Multiply ( void MSrGeomContext_Method_Matrix_MultiplyPoints ( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, const UUtUns16 inNumPoints, - const M3tPoint3D *inPoints, + const M3tPoint3D *inPoints, M3tPoint3D *outPoints) { M3tMatrix4x3 *privateInMatrix = (M3tMatrix4x3 *) inMatrix; @@ -303,4 +303,4 @@ void MSrGeomContext_Method_Matrix_Alignment( { MUrMatrix_Alignment(inFrom, inTo, (M3tMatrix4x3 *) outMatrix); } -#endif \ No newline at end of file +#endif diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Matrix.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Matrix.h index 34fbc08..24650bc 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Matrix.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Matrix.h @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Matrix.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -61,30 +61,30 @@ MSrGeomContext_Method_MatrixStack_Multiply( const M3tMatrix4x3* inMatrix); void MSrGeomContext_Method_MatrixToQuat( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, M3tQuaternion *outQuat); void MSrGeomContext_Method_QuatToMatrix( - const M3tQuaternion *inQuat, + const M3tQuaternion *inQuat, M3tMatrix4x3 *outMatrix); -void +void MSrGeomContext_Method_Matrix_GetTranslation( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, M3tPoint3D *outTranslation); void MSrGeomContext_Method_Matrix_Multiply ( - const M3tMatrix4x3 *inMatrixA, - const M3tMatrix4x3 *inMatrixB, + const M3tMatrix4x3 *inMatrixA, + const M3tMatrix4x3 *inMatrixB, M3tMatrix4x3 *outResult); void MSrGeomContext_Method_Matrix_MultiplyPoints ( - const M3tMatrix4x3 *inMatrix, + const M3tMatrix4x3 *inMatrix, const UUtUns16 inNumPoints, - const M3tPoint3D *inPoint, + const M3tPoint3D *inPoint, M3tPoint3D *outPoint); void MSrGeomContext_Method_Matrix_Alignment( diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Pick.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Pick.c index 913a5cf..7109ef6 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Pick.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Pick.c @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Pick.c - + AUTHOR: Brent H. Pease - + CREATED: Jan 14, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -31,28 +31,28 @@ MSrGeomContext_Method_Pick_ScreenToWorld( { M3tMatrix4x4* matrix_frustumToWorld; M3tManager_GeomCamera* targetCamera; - + float hX, hY; - + float invW; - + /* Frustum to screen code is - + sX = (hX * invW + 1.0f) * scaleX; sY = (hY * invW - 1.0f) * scaleY; - + so the screen to frustum code is - + hX = (sX / scaleX - 1.0) * hW hY = (sY / scaleY + 1.0) * hW hZ = 0.0 - + hW = zNear - + XXX - The below code has been optimized more or less beyond recognition - cool. */ - + if(inCamera == NULL) { targetCamera = MSgGeomContextPrivate->activeCamera; @@ -61,15 +61,15 @@ MSrGeomContext_Method_Pick_ScreenToWorld( { targetCamera = (M3tManager_GeomCamera*)inCamera; } - + M3rManager_Camera_UpdateMatrices(targetCamera); - + matrix_frustumToWorld = &targetCamera->matrix_frustumToWorld; - + invW = 1.0f / matrix_frustumToWorld->m[3][3]; hX = (inScreenX / MSgGeomContextPrivate->scaleX - 1.0f); hY = (inScreenY / MSgGeomContextPrivate->scaleY + 1.0f); - + outWorldZNearPoint->x = (matrix_frustumToWorld->m[0][0] * hX + matrix_frustumToWorld->m[1][0] * hY + matrix_frustumToWorld->m[3][0]) * invW; @@ -79,5 +79,5 @@ MSrGeomContext_Method_Pick_ScreenToWorld( outWorldZNearPoint->z = (matrix_frustumToWorld->m[0][2] * hX + matrix_frustumToWorld->m[1][2] * hY + matrix_frustumToWorld->m[3][2]) * invW; - + } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Pick.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Pick.h index 5f2a07d..7a396bd 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Pick.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_Pick.h @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_Pick.h - + AUTHOR: Brent H. Pease - + CREATED: Jan 14, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_State.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_State.c index dc33de9..ed4921f 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_State.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_State.c @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_State.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -25,40 +25,40 @@ MSrGeomContext_Method_State_Set( M3tGeomStateIntType inGeomStateIntType, UUtInt32 inState) { - + MSgGeomContextPrivate->stateDirty = UUcTrue; - + MSgGeomContextPrivate->stateInt[inGeomStateIntType] = inState; - + switch(inGeomStateIntType) { case M3cGeomStateIntType_Fill: break; - + case M3cGeomStateIntType_Shade: break; - + case M3cGeomStateIntType_Appearance: break; - + case M3cGeomStateIntType_Hint: break; - + case M3cGeomStateIntType_SubmitMode: M3rDraw_State_SetInt( M3cDrawStateIntType_SubmitMode, inState); break; - + case M3cGeomStateIntType_Alpha: M3rDraw_State_SetInt( M3cDrawStateIntType_Alpha, inState); break; - + case M3cGeomStateIntType_DebugMode: break; - + default: UUmAssert(!"Unknown state type"); } @@ -78,22 +78,22 @@ MSrGeomContext_Method_State_Push( { UUtUns16 i; UUtUns16 tos; - + MSrGeomContext_Method_State_Commit(); - + M3rDraw_State_Push(); - + tos = ++MSgGeomContextPrivate->stateTOS; - + UUmAssert(tos < MScStateStack_MaxDepth); - + for(i = 0; i < M3cGeomStateIntType_NumTypes; i++) { MSgGeomContextPrivate->stateIntStack[tos][i] = MSgGeomContextPrivate->stateIntStack[tos-1][i]; } - + MSgGeomContextPrivate->stateInt = MSgGeomContextPrivate->stateIntStack[tos]; - + return UUcError_None; } @@ -104,16 +104,16 @@ MSrGeomContext_Method_State_Pop( UUtUns16 tos; M3rDraw_State_Pop(); - + UUmAssert(MSgGeomContextPrivate->stateTOS > 0); - + MSgGeomContextPrivate->stateTOS -= 1; tos = MSgGeomContextPrivate->stateTOS; MSgGeomContextPrivate->stateInt = MSgGeomContextPrivate->stateIntStack[tos]; MSgGeomContextPrivate->stateDirty = UUcTrue; - + return UUcError_None; } @@ -125,49 +125,49 @@ MSrGeomContext_Method_State_Commit( if(MSgGeomContextPrivate->stateDirty == UUcTrue) { MSgGeomContextPrivate->stateDirty = UUcFalse; - + switch(MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Fill]) { case M3cGeomState_Fill_Point: UUmAssert(0); break; - + case M3cGeomState_Fill_Line: M3rDraw_State_SetInt( M3cDrawStateIntType_Fill, M3cDrawState_Fill_Line); break; - + case M3cGeomState_Fill_Solid: M3rDraw_State_SetInt( M3cDrawStateIntType_Fill, M3cDrawState_Fill_Solid); break; - + default: UUmAssert(0); break; } - + switch(MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Shade]) { case M3cGeomState_Shade_Vertex: M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_Vertex); - + switch(MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Appearance]) { case M3cGeomState_Appearance_Gouraud: - MSgGeomContextPrivate->polyComputeVertexProc = + MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_GouraudInterpolate; break; - + case M3cGeomState_Appearance_Texture: - MSgGeomContextPrivate->polyComputeVertexProc = + MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_TextureInterpolate; break; - + default: UUmAssert(0); break; @@ -178,30 +178,30 @@ MSrGeomContext_Method_State_Commit( M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); - + switch(MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Appearance]) { case M3cGeomState_Appearance_Gouraud: - MSgGeomContextPrivate->polyComputeVertexProc = + MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_GouraudFlat; break; - + case M3cGeomState_Appearance_Texture: - MSgGeomContextPrivate->polyComputeVertexProc = + MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_TextureFlat; break; - + default: UUmAssert(0); break; } break; - + default: UUmAssert(0); break; } - + switch(MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Appearance]) { case M3cGeomState_Appearance_Gouraud: @@ -209,19 +209,19 @@ MSrGeomContext_Method_State_Commit( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Gouraud); break; - + case M3cGeomState_Appearance_Texture: M3rDraw_State_SetInt( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Texture_Lit); break; - + default: UUmAssert(0); break; } } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_State.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_State.h index ce0d482..348412d 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_State.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Method_State.h @@ -1,12 +1,12 @@ /* FILE: MS_GC_Method_State.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Private.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Private.h index 1a5a6b0..7e98b2a 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GC_Private.h @@ -1,12 +1,12 @@ /* FILE: MS_GC_Private.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 19, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -30,26 +30,26 @@ typedef struct MStGeomContextPrivate MStGeomContextPrivate; typedef void (*MSrClip_PolyComputeVertexProc)( UUtUns32 inClipPlane, - + UUtUns32 inIndexIn0, UUtUns32 inIndexOut0, UUtUns32 inIndexNew0, - + UUtUns32 inIndexIn1, UUtUns32 inIndexOut1, UUtUns32 inIndexNew1, - + UUtUns8 *outClipCodeNew0, UUtUns8 *outClipCodeNew1); typedef void (*MSrClip_LineComputeVertexProc)( UUtUns32 inClipPlane, - + UUtUns32 inIndexIn, UUtUns32 inIndexOut, UUtUns32 inIndexNew, - + UUtUns8 *outClipCodeNew); typedef void @@ -158,13 +158,13 @@ typedef struct MStProcessingFuncs MStTransform_FaceNormalToWorld transformFaceNormalToWorld; MStTransform_BoundingBoxToFrustumScreen transformBoundingBoxToFrustumScreen; MStTransform_BoundingBoxClipStatus transformBoundingBoxClipStatus; - + MStShade_Vertices_Gouraud shadeVerticesGouraud; MStShade_Vertices_GouraudActive shadeVerticesGouraudActive; MStShade_Faces_Gouraud shadeFacesGouraud; - + MStBackface_Remove backfaceRemove; - + } MStProcessingFuncs; typedef struct MStDebugEnvMap @@ -185,22 +185,22 @@ typedef struct MStTransformedVertexData UUtUns8* clipCodes; M3tTextureCoord* textureCoords; M3tPoint3D* worldPoints; - + // New indices - needs to be reset every time a clipping function is called UUtUns32 newClipTextureIndex; UUtUns32 newClipVertexIndex; - + // maximum extra vertices - used for debugging UUtUns32 maxClipVertices; UUtUns32 maxClipTextureCords; - + } MStTransformedVertexData; typedef struct MStLight_Directional { M3tVector3D normalizedDirection; M3tColorRGB color; - + } MStLight_Directional; #define MScDirectionalLight_Max (4) @@ -211,90 +211,90 @@ struct MStGeomContextPrivate M3tMatrix4x4 matrix_localToFrustum; //M3tPoint3D submitPoints[5]; - + long width; long height; - + float scaleX; float scaleY; - + UUtUns32 curFrame; - + const UUtInt32* stateInt; - + M3tManager_GeomCamera* activeCamera; - + // matrix M3tMatrix4x3* matrix_localToWorld; - + /* Light info */ M3tLight_Ambient light_Ambient; UUtUns32 light_NumDirectionalLights; MStLight_Directional light_DirectionalList[MScDirectionalLight_Max]; - + UUtUns32 light_NumPointLights; M3tLight_Point light_PointList[MScPointLight_Max]; // re-add these when they are supported //UUtUns32 light_NumConeLights; //M3tLight_Cone* light_ConeList; - + /* Temporary memory */ MStTransformedVertexData objectVertexData; - + M3tPoint3D* worldPoints; M3tVector3D* worldViewVectors; // Only used for SIMD M3tVector3D* worldTriNormals; M3tVector3D* worldVertexNormals; - + UUtUns32* activeVerticesBV; UUtUns32* activeTrisBV; - + void* shades_vertex; void* shades_tris; - + // Points to the texture coord array //M3tTextureCoord* textureCoords; //UUtUns32 maxTextureCoords; - + /* Attribute info */ M3tColorRGB diffuseColor; - + // Environment and visibility crap AKtEnvironment* environment; M3tManager_GeomCamera* visCamera; M3tBoundingBox_MinMax visBBox; - + MStTransformedVertexData gqVertexData; //MStTransformedVertexData otVertexData; - + // clipper function pointers MSrClip_PolyComputeVertexProc polyComputeVertexProc; MSrClip_LineComputeVertexProc lineComputeVertexProc; - + // debugging texture - NULL in ship version - M3tTextureMap* flashTexture; - + M3tTextureMap* flashTexture; + // debugging array - NULL in ship version UUtUns32 numDebugEnvMap; MStDebugEnvMap* debugEnvMap; // MStProcessingFuncs sisdFunctions; - + #if UUmSIMD != UUmSIMD_None - + MStProcessingFuncs simdFunctions; float* envPointSIMD; - + #endif - + MStProcessingFuncs* activeFunctions; - + // template env map texture cords M3tTextureCoord* envMapCoords; - + }; extern MStGeomContextPrivate* MSgGeomContextPrivate; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GeomEngine_Method.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GeomEngine_Method.c index e54b584..d8ffc48 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GeomEngine_Method.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GeomEngine_Method.c @@ -1,12 +1,12 @@ /* FILE: MS_GeomEngine_Method.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -39,7 +39,7 @@ #include "MS_Geom_Transform_AltiVec.h" #include "MS_Geom_Shade_AltiVec.h" - + #include "BFW_Platform.h" #endif @@ -59,13 +59,13 @@ MSrTransformedVertexData_Init( inData->frustumPoints = NULL; inData->screenPoints = NULL; inData->clipCodes = NULL; - + inData->newClipTextureIndex = 0x5555; inData->newClipVertexIndex = 0x5555; - + inData->maxClipVertices = 0; inData->maxClipTextureCords = 0; - + return UUcError_None; } @@ -77,7 +77,7 @@ MSrTransformedVertexData_Delete( if(inData->frustumPoints != NULL) UUrMemory_Block_Delete(inData->frustumPoints); if(inData->screenPoints != NULL) UUrMemory_Block_Delete(inData->screenPoints); if(inData->clipCodes != NULL) UUrMemory_Block_Delete(inData->clipCodes); - + MSrTransformedVertexData_Init(inData); } @@ -87,21 +87,21 @@ MSrTransformedVertexData_Alloc( UUtUns32 inArrayLength) { inData->arrayLength = inArrayLength; - + MSrTransformedVertexData_Delete(inData); - + inData->bitVector = UUrBitVector_New(inArrayLength); UUmError_ReturnOnNull(inData->bitVector); - + inData->frustumPoints = UUrMemory_Block_New(sizeof(M3tPoint4D) * inArrayLength); UUmError_ReturnOnNull(inData->frustumPoints); - + inData->screenPoints = UUrMemory_Block_New(sizeof(M3tPointScreen) * inArrayLength); UUmError_ReturnOnNull(inData->screenPoints); - + inData->clipCodes = UUrMemory_Block_New(sizeof(UUtUns8) * inArrayLength); UUmError_ReturnOnNull(inData->clipCodes); - + return UUcError_None; } @@ -111,15 +111,15 @@ MSrGeomEngine_Method_ContextPrivateNew( M3tGeomContextMethods* *outGeomContextFuncs) { UUtError error; - - + + MSgGeomContextPrivate = UUrMemory_Block_NewClear(sizeof(MStGeomContextPrivate)); - + if(MSgGeomContextPrivate == NULL) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not allocated private geom context"); } - + /* * Initialize the methods */ @@ -146,9 +146,9 @@ MSrGeomEngine_Method_ContextPrivateNew( MSgGeomContextMethods.skyboxDraw = MSrGeomContext_Method_Skybox_Draw; MSgGeomContextMethods.skyboxCreate = MSrGeomContext_Method_Skybox_Create; MSgGeomContextMethods.skyboxDestroy = MSrGeomContext_Method_Skybox_Destroy; - + *outGeomContextFuncs = &MSgGeomContextMethods; - + /* * Initialize temporary memory */ @@ -156,36 +156,36 @@ MSrGeomEngine_Method_ContextPrivateNew( MSrTransformedVertexData_Init(&MSgGeomContextPrivate->gqVertexData); //MSrTransformedVertexData_Init(&MSgGeomContextPrivate->otVertexData); - error = + error = MSrTransformedVertexData_Alloc( &MSgGeomContextPrivate->objectVertexData, M3cMaxObjVertices); UUmError_ReturnOnError(error); - + MSgGeomContextPrivate->worldTriNormals = UUrMemory_Block_New(sizeof(M3tVector3D) * M3cMaxObjTris); UUmError_ReturnOnNull(MSgGeomContextPrivate->worldTriNormals); MSgGeomContextPrivate->worldVertexNormals = UUrMemory_Block_New(sizeof(M3tPoint3D) * M3cMaxObjVertices); UUmError_ReturnOnNull(MSgGeomContextPrivate->worldVertexNormals); MSgGeomContextPrivate->worldPoints = UUrMemory_Block_New(sizeof(M3tPoint3D) * M3cMaxObjVertices); UUmError_ReturnOnNull(MSgGeomContextPrivate->worldPoints); - + MSgGeomContextPrivate->worldViewVectors = NULL; - + MSgGeomContextPrivate->shades_vertex = UUrMemory_Block_New(sizeof(M3tDiffuseRGB) * M3cMaxObjVertices); UUmError_ReturnOnNull(MSgGeomContextPrivate->shades_vertex); MSgGeomContextPrivate->shades_tris = UUrMemory_Block_New(sizeof(M3tDiffuseRGB) * M3cMaxObjVertices); UUmError_ReturnOnNull(MSgGeomContextPrivate->shades_tris); - + MSgGeomContextPrivate->activeVerticesBV = UUrBitVector_New(M3cMaxObjVertices); UUmError_ReturnOnNull(MSgGeomContextPrivate->activeVerticesBV); - + MSgGeomContextPrivate->activeTrisBV = UUrBitVector_New(MScMaxGQs); UUmError_ReturnOnNull(MSgGeomContextPrivate->activeTrisBV); MSgGeomContextPrivate->envMapCoords = UUrMemory_Block_New(sizeof(M3tTextureCoord) * M3cMaxObjVertices); UUmError_ReturnOnNull(MSgGeomContextPrivate->envMapCoords); - - + + /* * Initialize the light data */ @@ -200,7 +200,7 @@ MSrGeomEngine_Method_ContextPrivateNew( //MSgGeomContextPrivate->light_NumConeLights = 0; //MSgGeomContextPrivate->light_ConeList = NULL; - + /* * Initialize the scale values */ @@ -214,29 +214,29 @@ MSrGeomEngine_Method_ContextPrivateNew( MSgGeomContextPrivate->width = inDrawContextDescriptor->drawContext.offScreen.inWidth; MSgGeomContextPrivate->height = inDrawContextDescriptor->drawContext.offScreen.inHeight; } - + MSgGeomContextPrivate->scaleX = ((float)MSgGeomContextPrivate->width - 0.0001f) * 0.5f; // S.S. / 2.0f; MSgGeomContextPrivate->scaleY = - ((float)MSgGeomContextPrivate->height - 0.0001f) * 0.5f; // S.S. / 2.0f; - + // Initialize the state #if 0 MSgGeomContextPrivate->stateTOS = 0; MSgGeomContextPrivate->stateInt = MSgGeomContextPrivate->stateIntStack[0]; - + MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Fill] = M3cGeomState_Fill_Solid; MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Shade] = M3cGeomState_Shade_Vertex; MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Appearance] = M3cGeomState_Appearance_Texture; MSgGeomContextPrivate->stateInt[M3cGeomStateIntType_Hint] = M3tGeomState_Hint_None; - + MSgGeomContextPrivate->stateDirty = UUcTrue; #endif - + MSgGeomContextPrivate->stateInt = NULL; MSgGeomContextPrivate->lineComputeVertexProc = MSrClip_ComputeVertex_LineFlat; - + #if TOOL_VERSION - error = + error = M3rTextureMap_New( 16, 16, @@ -246,7 +246,7 @@ MSrGeomEngine_Method_ContextPrivateNew( "flash texture", &MSgGeomContextPrivate->flashTexture); UUmError_ReturnOnError(error); - + M3rTextureMap_Fill_Shade( MSgGeomContextPrivate->flashTexture, IMcShade_Red, @@ -279,9 +279,9 @@ MSrGeomEngine_Method_ContextPrivateNew( MSgGeomContextPrivate->sisdFunctions.shadeVerticesGouraudActive = MSrShade_Vertices_GouraudActive; MSgGeomContextPrivate->sisdFunctions.shadeFacesGouraud = MSrShade_Faces_Gouraud; MSgGeomContextPrivate->sisdFunctions.backfaceRemove = MSrBackface_Remove; - + #if UUmSIMD == UUmSIMD_AltiVec - + MSgGeomContextPrivate->simdFunctions.transformPointListToScreen = MSrTransform_Geom_PointListToScreen_AltiVec; MSgGeomContextPrivate->simdFunctions.transformPointListToScreenActive = MSrTransform_Geom_PointListToScreen_ActiveVertices_AltiVec; MSgGeomContextPrivate->simdFunctions.transformPointListToFrustumScreen = MSrTransform_Geom_PointListToFrustumScreen_AltiVec; @@ -298,37 +298,37 @@ MSrGeomEngine_Method_ContextPrivateNew( MSgGeomContextPrivate->simdFunctions.backfaceRemove = MSrBackface_Remove_AltiVec; #endif - + #if UUmSIMD != UUmSIMD_None - + if(UUrPlatform_SIMD_IsPresent()) { MSgGeomContextPrivate->worldViewVectors = UUrMemory_Block_New(sizeof(M3tVector3D) * M3cMaxObjVertices); UUmError_ReturnOnNull(MSgGeomContextPrivate->worldViewVectors); } - + #endif - + #if UUmSIMD == UUmSIMD_AltiVec - + if(1 && UUrPlatform_SIMD_IsPresent()) { MSgGeomContextPrivate->activeFunctions = &MSgGeomContextPrivate->simdFunctions; } else #endif - + { MSgGeomContextPrivate->activeFunctions = &MSgGeomContextPrivate->sisdFunctions; } - + // #if UUmSIMD != UUmSIMD_None - + MSgGeomContextPrivate->envPointSIMD = NULL; - + #endif - + return UUcError_None; } @@ -336,31 +336,31 @@ static void MSrGeomEngine_Method_ContextPrivateDelete( void) { - + MSrTransformedVertexData_Delete(&MSgGeomContextPrivate->objectVertexData); MSrTransformedVertexData_Delete(&MSgGeomContextPrivate->gqVertexData); //MSrTransformedVertexData_Delete(&MSgGeomContextPrivate->otVertexData); - + UUrMemory_Block_Delete(MSgGeomContextPrivate->worldTriNormals); UUrMemory_Block_Delete(MSgGeomContextPrivate->worldVertexNormals); UUrMemory_Block_Delete(MSgGeomContextPrivate->worldPoints); UUrMemory_Block_Delete(MSgGeomContextPrivate->shades_vertex); UUrMemory_Block_Delete(MSgGeomContextPrivate->shades_tris); - + UUrMemory_Block_Delete(MSgGeomContextPrivate->envMapCoords); - + if(MSgGeomContextPrivate->worldViewVectors != NULL) { UUrMemory_Block_Delete(MSgGeomContextPrivate->worldViewVectors); } - + UUrBitVector_Dispose(MSgGeomContextPrivate->activeVerticesBV); UUrBitVector_Dispose(MSgGeomContextPrivate->activeTrisBV); if (MSgGeomContextPrivate->debugEnvMap != NULL) { UUrMemory_Block_Delete(MSgGeomContextPrivate->debugEnvMap); MSgGeomContextPrivate->debugEnvMap = NULL; - } + } #if UUmSIMD != UUmSIMD_None if(MSgGeomContextPrivate->envPointSIMD != NULL) @@ -368,9 +368,9 @@ MSrGeomEngine_Method_ContextPrivateDelete( UUrMemory_Block_Delete(MSgGeomContextPrivate->envPointSIMD); } #endif - + UUrMemory_Block_Delete(MSgGeomContextPrivate); - + MSgGeomContextPrivate = NULL; } @@ -382,20 +382,20 @@ MSrGeomEngine_Method_ContextSetEnvironment( UUtUns32 numFloats; numFloats; - - if (NULL != inEnvironment) + + if (NULL != inEnvironment) { MSgGeomContextPrivate->environment = inEnvironment; - - error = + + error = MSrTransformedVertexData_Alloc( &MSgGeomContextPrivate->gqVertexData, inEnvironment->pointArray->numPoints + M3cExtraCoords); UUmError_ReturnOnError(error); - + MSgGeomContextPrivate->gqVertexData.textureCoords = inEnvironment->textureCoordArray->textureCoords; MSgGeomContextPrivate->gqVertexData.worldPoints = inEnvironment->pointArray->points; - + #if UUmSIMD != UUmSIMD_None { if(UUrPlatform_SIMD_IsPresent()) @@ -404,13 +404,13 @@ MSrGeomEngine_Method_ContextSetEnvironment( { UUrMemory_Block_Delete(MSgGeomContextPrivate->envPointSIMD); } - + numFloats = (inEnvironment->pointArray->numPoints + 3) & ~0x3; - numFloats *= 3; - + numFloats *= 3; + MSgGeomContextPrivate->envPointSIMD = UUrMemory_Block_New(numFloats * sizeof(float)); UUmError_ReturnOnNull(MSgGeomContextPrivate->envPointSIMD); - + AVrFloat_XYZ4ToXXXXYYYYZZZZ( inEnvironment->pointArray->numPoints, (float*)inEnvironment->pointArray->points, @@ -418,14 +418,14 @@ MSrGeomEngine_Method_ContextSetEnvironment( } } #endif - + } - else + else { MSgGeomContextPrivate->environment = NULL; - + MSrTransformedVertexData_Delete(&MSgGeomContextPrivate->gqVertexData); - + MSgGeomContextPrivate->gqVertexData.textureCoords = NULL; MSgGeomContextPrivate->gqVertexData.worldPoints = NULL; @@ -437,7 +437,7 @@ MSrGeomEngine_Method_ContextSetEnvironment( } #endif } - + return UUcError_None; } @@ -446,12 +446,12 @@ static UUtError MSrGeomEngine_Method_PrivateState_New( void* inState_Private) { - + return UUcError_None; } // This lets the engine delete a new private state structure -static void +static void MSrGeomEngine_Method_PrivateState_Delete( void* inState_Private) { @@ -466,7 +466,7 @@ MSrGeomEngine_Method_State_Update( const UUtInt32* inState_Int) { MSgGeomContextPrivate->stateInt = inState_Int; - + if(inState_IntFlags & (1 << M3cGeomStateIntType_Shade)) { switch(inState_Int[M3cGeomStateIntType_Shade]) @@ -475,15 +475,15 @@ MSrGeomEngine_Method_State_Update( switch(inState_Int[M3cGeomStateIntType_Appearance]) { case M3cGeomState_Appearance_Gouraud: - MSgGeomContextPrivate->polyComputeVertexProc = + MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_GouraudInterpolate; break; - + case M3cGeomState_Appearance_Texture: - MSgGeomContextPrivate->polyComputeVertexProc = + MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_TextureInterpolate; break; - + default: UUmAssert(0); break; @@ -494,21 +494,21 @@ MSrGeomEngine_Method_State_Update( switch(inState_Int[M3cGeomStateIntType_Appearance]) { case M3cGeomState_Appearance_Gouraud: - MSgGeomContextPrivate->polyComputeVertexProc = + MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_GouraudFlat; break; - + case M3cGeomState_Appearance_Texture: - MSgGeomContextPrivate->polyComputeVertexProc = + MSgGeomContextPrivate->polyComputeVertexProc = MSrClip_ComputeVertex_TextureFlat; break; - + default: UUmAssert(0); break; } break; - + default: UUmAssert(0); break; @@ -539,30 +539,30 @@ MSrGeomEngine_Initialize( UUtError error; M3tGeomEngineMethods geomEngineMethods; M3tGeomEngineCaps geomEngineCaps; - + geomEngineMethods.contextPrivateNew = MSrGeomEngine_Method_ContextPrivateNew; geomEngineMethods.contextPrivateDelete = MSrGeomEngine_Method_ContextPrivateDelete; geomEngineMethods.contextSetEnvironment = MSrGeomEngine_Method_ContextSetEnvironment; - + geomEngineMethods.privateStateSize = 0; geomEngineMethods.privateStateNew = MSrGeomEngine_Method_PrivateState_New; geomEngineMethods.privateStateDelete = MSrGeomEngine_Method_PrivateState_Delete; geomEngineMethods.privateStateUpdate = MSrGeomEngine_Method_State_Update; - + geomEngineMethods.cameraViewUpdate = MSrGeomEngine_Method_Camera_View_Update; geomEngineMethods.cameraStaticUpdate = MSrGeomEngine_Method_Camera_Static_Update; - + geomEngineCaps.engineFlags = M3tGeomEngineFlag_None; - + UUrString_Copy(geomEngineCaps.engineName, M3cGeomEngine_Software, M3cMaxNameLen); geomEngineCaps.engineDriver[0] = 0; - + geomEngineCaps.engineVersion = MScGeomVersion; - + geomEngineCaps.compatibleDrawEngineBV = 0xFFFF; - + error = M3rManager_Register_GeomEngine(&geomEngineCaps, &geomEngineMethods); - + if(error != UUcError_None) { UUrError_Report(error, "Could not register motoko software rasterizer engine"); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GeomEngine_Method.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GeomEngine_Method.h index 11a0163..98f9227 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GeomEngine_Method.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_GeomEngine_Method.h @@ -1,12 +1,12 @@ /* FILE: MS_GeomEngine_Method.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 13, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Clip.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Clip.c index 5ca34d5..0dcd73c 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Clip.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Clip.c @@ -1,12 +1,12 @@ /* FILE: MS_Geom_Clip.c - + AUTHOR: Brent H. Pease - + CREATED: May 21, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -46,39 +46,39 @@ void MSrClip_ComputeVertex_TextureInterpolate( UUtUns32 inClipPlane, - + UUtUns32 inVIndexIn0, UUtUns32 inVIndexOut0, UUtUns32 inVIndexNew0, - + UUtUns32 inVIndexIn1, UUtUns32 inVIndexOut1, UUtUns32 inVIndexNew1, - + UUtUns8 *outClipCodeNew0, UUtUns8 *outClipCodeNew1) { M3tPoint4D* frustumPoints; M3tPointScreen* screenPoints; M3tTextureCoord* textureCoords; - + M3tPoint4D* frustumPointIn; M3tPoint4D* frustumPointOut; M3tPoint4D* frustumPointNew; - + M3tTextureCoord* textureCoordIn; M3tTextureCoord* textureCoordOut; M3tTextureCoord* textureCoordNew; - + UUtUns32* shades; UUtUns32 shadeIn; UUtUns32 shadeOut; UUtUns32* shadeNew; - + M3tPointScreen* screenPointNew; - + float scaleX, scaleY; - + UUtUns8 newClipCode; float oneMinust, pIn, pOut, negW, invW; float hW, hX, hY, hZ; @@ -86,11 +86,11 @@ MSrClip_ComputeVertex_TextureInterpolate( float wIn, wOut; float t; UUtUns32 i; - + float rIn, gIn, bIn; float rOut, gOut, bOut; float rNew, gNew, bNew; - + frustumPoints = MSgGeomContextPrivate->objectVertexData.frustumPoints; UUmAssertReadPtr(frustumPoints, sizeof(M3tPoint4D)); @@ -102,10 +102,10 @@ MSrClip_ComputeVertex_TextureInterpolate( shades = MSgGeomContextPrivate->shades_vertex; UUmAssertReadPtr(shades, sizeof(UUtUns32)); - + scaleX = MSgGeomContextPrivate->scaleX; scaleY = MSgGeomContextPrivate->scaleY; - + for(i = 0; i < 2; i++) { if(i == 0) @@ -120,113 +120,113 @@ MSrClip_ComputeVertex_TextureInterpolate( frustumPointOut = frustumPoints + inVIndexOut1; frustumPointNew = frustumPoints + inVIndexNew1; } - + wIn = frustumPointIn->w; wOut = frustumPointOut->w; - - switch(inClipPlane) - { - case MScClipCode_PosX: - UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + + switch(inClipPlane) + { + case MScClipCode_PosX: + UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hX = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_NegX: - UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_NegX: + UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hX = -hW; + hX = -hW; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosY: - UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosY: + UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hY = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; break; - - case MScClipCode_NegY: - UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + + case MScClipCode_NegY: + UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; - hY = -hW; + hY = -hW; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosZ: - UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosZ: + UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = hW; - break; - - case MScClipCode_NegZ: - UUmAssert_Clip(frustumPointIn->z >= 0.0f); - UUmAssert_Clip(frustumPointOut->z < 0.0f); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = pIn / (pIn - pOut); - oneMinust = (1.0f - t); + hZ = hW; + break; + + case MScClipCode_NegZ: + UUmAssert_Clip(frustumPointIn->z >= 0.0f); + UUmAssert_Clip(frustumPointOut->z < 0.0f); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = pIn / (pIn - pOut); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = 0.0f; - break; + hZ = 0.0f; + break; } - + frustumPointNew->x = hX; frustumPointNew->y = hY; frustumPointNew->z = hZ; frustumPointNew->w = hW; - + if(i == 0) { textureCoordIn = textureCoords + inVIndexIn0; @@ -241,7 +241,7 @@ MSrClip_ComputeVertex_TextureInterpolate( } textureCoordNew->u = t * textureCoordOut->u + oneMinust * textureCoordIn->u; textureCoordNew->v = t * textureCoordOut->v + oneMinust * textureCoordIn->v; - + // XXX - optimize this someday if(i == 0) { @@ -255,57 +255,57 @@ MSrClip_ComputeVertex_TextureInterpolate( shadeOut = shades[inVIndexOut1]; shadeNew = shades + inVIndexNew1; } - + rOut = (float)((shadeOut >> 16) & 0xFF); gOut = (float)((shadeOut >> 8) & 0xFF); bOut = (float)((shadeOut >> 0) & 0xFF); - + rIn = (float)((shadeIn >> 16) & 0xFF); gIn = (float)((shadeIn >> 8) & 0xFF); bIn = (float)((shadeIn >> 0) & 0xFF); - + rNew = t * rOut + oneMinust * rIn; gNew = t * gOut + oneMinust * gIn; bNew = t * bOut + oneMinust * bIn; - - *shadeNew = + + *shadeNew = (UUtUns32) (MUrUnsignedSmallFloat_To_Uns_Round(rNew) << 16) | - (UUtUns32) (MUrUnsignedSmallFloat_To_Uns_Round(gNew) << 8) | + (UUtUns32) (MUrUnsignedSmallFloat_To_Uns_Round(gNew) << 8) | (UUtUns32) (MUrUnsignedSmallFloat_To_Uns_Round(bNew) << 0); negW = -hW; newClipCode = MScClipCode_None; - + if(hX > hW) { newClipCode |= MScClipCode_PosX; } - + if(hX < negW) { newClipCode |= MScClipCode_NegX; } - + if(hY > hW) { newClipCode |= MScClipCode_PosY; } - + if(hY < negW) { newClipCode |= MScClipCode_NegY; } - + if(hZ > hW) { newClipCode |= MScClipCode_PosZ; } - + if(hZ < 0.0) { newClipCode |= MScClipCode_NegZ; } - + if(i == 0) { screenPointNew = screenPoints + inVIndexNew0; @@ -314,7 +314,7 @@ MSrClip_ComputeVertex_TextureInterpolate( { screenPointNew = screenPoints + inVIndexNew1; } - + MSrClipCode_ValidateFrustum(frustumPointNew, newClipCode); if(newClipCode == 0) @@ -328,7 +328,7 @@ MSrClip_ComputeVertex_TextureInterpolate( { screenPointNew->x = (hX * invW + 1.0f) * scaleX; } - + if(hY == hW) { screenPointNew->y = 0.0f; @@ -337,13 +337,13 @@ MSrClip_ComputeVertex_TextureInterpolate( { screenPointNew->y = (hY * invW - 1.0f) * scaleY; } - + screenPointNew->z = hZ * invW; screenPointNew->invW = invW; - + MSiVerifyPointScreen(screenPointNew); } - + if(i == 0) { *outClipCodeNew0 = newClipCode; @@ -358,44 +358,44 @@ MSrClip_ComputeVertex_TextureInterpolate( void MSrClip_ComputeVertex_TextureEnvInterpolate( UUtUns32 inClipPlane, - + UUtUns32 inVIndexIn0, UUtUns32 inVIndexOut0, UUtUns32 inVIndexNew0, - + UUtUns32 inVIndexIn1, UUtUns32 inVIndexOut1, UUtUns32 inVIndexNew1, - + UUtUns8 *outClipCodeNew0, UUtUns8 *outClipCodeNew1) { M3tPoint4D* frustumPoints; M3tPointScreen* screenPoints; - + M3tPoint4D* frustumPointIn; M3tPoint4D* frustumPointOut; M3tPoint4D* frustumPointNew; - + M3tTextureCoord* textureCoords; M3tTextureCoord* textureCoordIn; M3tTextureCoord* textureCoordOut; M3tTextureCoord* textureCoordNew; - + M3tTextureCoord* envTextureCoords; M3tTextureCoord* envTextureCoordIn; M3tTextureCoord* envTextureCoordOut; M3tTextureCoord* envTextureCoordNew; - + UUtUns32* shades; UUtUns32 shadeIn; UUtUns32 shadeOut; UUtUns32* shadeNew; - + M3tPointScreen* screenPointNew; - + float scaleX, scaleY; - + UUtUns8 newClipCode; float oneMinust, pIn, pOut, negW, invW; float hW, hX, hY, hZ; @@ -403,11 +403,11 @@ MSrClip_ComputeVertex_TextureEnvInterpolate( float wIn, wOut; float t; UUtUns32 i; - + float rIn, gIn, bIn; float rOut, gOut, bOut; float rNew, gNew, bNew; - + frustumPoints = MSgGeomContextPrivate->objectVertexData.frustumPoints; UUmAssertReadPtr(frustumPoints, sizeof(M3tPoint4D)); @@ -422,10 +422,10 @@ MSrClip_ComputeVertex_TextureEnvInterpolate( shades = MSgGeomContextPrivate->shades_vertex; UUmAssertReadPtr(shades, sizeof(UUtUns32)); - + scaleX = MSgGeomContextPrivate->scaleX; scaleY = MSgGeomContextPrivate->scaleY; - + for(i = 0; i < 2; i++) { if(i == 0) @@ -440,119 +440,119 @@ MSrClip_ComputeVertex_TextureEnvInterpolate( frustumPointOut = frustumPoints + inVIndexOut1; frustumPointNew = frustumPoints + inVIndexNew1; } - + wIn = frustumPointIn->w; wOut = frustumPointOut->w; - - switch(inClipPlane) - { - case MScClipCode_PosX: - UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + + switch(inClipPlane) + { + case MScClipCode_PosX: + UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hX = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_NegX: - UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_NegX: + UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hX = -hW; + hX = -hW; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosY: - UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosY: + UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hY = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; break; - - case MScClipCode_NegY: - UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + + case MScClipCode_NegY: + UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; - hY = -hW; + hY = -hW; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosZ: - UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosZ: + UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = hW; - break; - - case MScClipCode_NegZ: - UUmAssert_Clip(frustumPointIn->z >= 0.0f); - UUmAssert_Clip(frustumPointOut->z < 0.0f); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = pIn / (pIn - pOut); - oneMinust = (1.0f - t); + hZ = hW; + break; + + case MScClipCode_NegZ: + UUmAssert_Clip(frustumPointIn->z >= 0.0f); + UUmAssert_Clip(frustumPointOut->z < 0.0f); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = pIn / (pIn - pOut); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = 0.0f; - break; + hZ = 0.0f; + break; } - + frustumPointNew->x = hX; frustumPointNew->y = hY; frustumPointNew->z = hZ; frustumPointNew->w = hW; - + if(i == 0) { textureCoordIn = textureCoords + inVIndexIn0; textureCoordOut = textureCoords + inVIndexOut0; textureCoordNew = textureCoords + inVIndexNew0; - + envTextureCoordIn = envTextureCoords + inVIndexIn0; envTextureCoordOut = envTextureCoords + inVIndexOut0; envTextureCoordNew = envTextureCoords + inVIndexNew0; @@ -562,7 +562,7 @@ MSrClip_ComputeVertex_TextureEnvInterpolate( textureCoordIn = textureCoords + inVIndexIn1; textureCoordOut = textureCoords + inVIndexOut1; textureCoordNew = textureCoords + inVIndexNew1; - + envTextureCoordIn = envTextureCoords + inVIndexIn1; envTextureCoordOut = envTextureCoords + inVIndexOut1; envTextureCoordNew = envTextureCoords + inVIndexNew1; @@ -571,7 +571,7 @@ MSrClip_ComputeVertex_TextureEnvInterpolate( textureCoordNew->v = t * textureCoordOut->v + oneMinust * textureCoordIn->v; envTextureCoordNew->u = t * envTextureCoordOut->u + oneMinust * envTextureCoordIn->u; envTextureCoordNew->v = t * envTextureCoordOut->v + oneMinust * envTextureCoordIn->v; - + // XXX - optimize this someday if(i == 0) { @@ -585,57 +585,57 @@ MSrClip_ComputeVertex_TextureEnvInterpolate( shadeOut = shades[inVIndexOut1]; shadeNew = shades + inVIndexNew1; } - + rOut = (float)((shadeOut >> 16) & 0xFF); gOut = (float)((shadeOut >> 8) & 0xFF); bOut = (float)((shadeOut >> 0) & 0xFF); - + rIn = (float)((shadeIn >> 16) & 0xFF); gIn = (float)((shadeIn >> 8) & 0xFF); bIn = (float)((shadeIn >> 0) & 0xFF); - + rNew = t * rOut + oneMinust * rIn; gNew = t * gOut + oneMinust * gIn; bNew = t * bOut + oneMinust * bIn; - - *shadeNew = + + *shadeNew = (UUtUns32) (MUrUnsignedSmallFloat_To_Uns_Round(rNew) << 16) | - (UUtUns32) (MUrUnsignedSmallFloat_To_Uns_Round(gNew) << 8) | + (UUtUns32) (MUrUnsignedSmallFloat_To_Uns_Round(gNew) << 8) | (UUtUns32) (MUrUnsignedSmallFloat_To_Uns_Round(bNew) << 0); negW = -hW; newClipCode = MScClipCode_None; - + if(hX > hW) { newClipCode |= MScClipCode_PosX; } - + if(hX < negW) { newClipCode |= MScClipCode_NegX; } - + if(hY > hW) { newClipCode |= MScClipCode_PosY; } - + if(hY < negW) { newClipCode |= MScClipCode_NegY; } - + if(hZ > hW) { newClipCode |= MScClipCode_PosZ; } - + if(hZ < 0.0) { newClipCode |= MScClipCode_NegZ; } - + if(i == 0) { screenPointNew = screenPoints + inVIndexNew0; @@ -644,7 +644,7 @@ MSrClip_ComputeVertex_TextureEnvInterpolate( { screenPointNew = screenPoints + inVIndexNew1; } - + MSrClipCode_ValidateFrustum(frustumPointNew, newClipCode); if(newClipCode == 0) @@ -658,7 +658,7 @@ MSrClip_ComputeVertex_TextureEnvInterpolate( { screenPointNew->x = (hX * invW + 1.0f) * scaleX; } - + if(hY == hW) { screenPointNew->y = 0.0f; @@ -667,13 +667,13 @@ MSrClip_ComputeVertex_TextureEnvInterpolate( { screenPointNew->y = (hY * invW - 1.0f) * scaleY; } - + screenPointNew->z = hZ * invW; screenPointNew->invW = invW; - + MSiVerifyPointScreen(screenPointNew); } - + if(i == 0) { *outClipCodeNew0 = newClipCode; @@ -688,34 +688,34 @@ MSrClip_ComputeVertex_TextureEnvInterpolate( void MSrClip_ComputeVertex_GouraudInterpolate( UUtUns32 inClipPlane, - + UUtUns32 inVIndexIn0, UUtUns32 inVIndexOut0, UUtUns32 inVIndexNew0, - + UUtUns32 inVIndexIn1, UUtUns32 inVIndexOut1, UUtUns32 inVIndexNew1, - + UUtUns8 *outClipCodeNew0, UUtUns8 *outClipCodeNew1) { M3tPoint4D* frustumPoints; M3tPointScreen* screenPoints; - + M3tPoint4D* frustumPointIn; M3tPoint4D* frustumPointOut; M3tPoint4D* frustumPointNew; - + UUtUns32* shades; UUtUns32 shadeIn; UUtUns32 shadeOut; UUtUns32* shadeNew; - + M3tPointScreen* screenPointNew; - + float scaleX, scaleY; - + UUtUns8 newClipCode; float oneMinust, pIn, pOut, negW, invW; float hW, hX, hY, hZ; @@ -723,11 +723,11 @@ MSrClip_ComputeVertex_GouraudInterpolate( float wIn, wOut; float t; UUtUns32 i; - + float rIn, gIn, bIn; float rOut, gOut, bOut; float rNew, gNew, bNew; - + frustumPoints = MSgGeomContextPrivate->objectVertexData.frustumPoints; UUmAssertReadPtr(frustumPoints, sizeof(M3tPoint4D)); @@ -736,10 +736,10 @@ MSrClip_ComputeVertex_GouraudInterpolate( shades = MSgGeomContextPrivate->shades_vertex; UUmAssertReadPtr(shades, sizeof(UUtUns32)); - + scaleX = MSgGeomContextPrivate->scaleX; scaleY = MSgGeomContextPrivate->scaleY; - + for(i = 0; i < 2; i++) { if(i == 0) @@ -754,113 +754,113 @@ MSrClip_ComputeVertex_GouraudInterpolate( frustumPointOut = frustumPoints + inVIndexOut1; frustumPointNew = frustumPoints + inVIndexNew1; } - + wIn = frustumPointIn->w; wOut = frustumPointOut->w; - - switch(inClipPlane) - { - case MScClipCode_PosX: - UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + + switch(inClipPlane) + { + case MScClipCode_PosX: + UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hX = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_NegX: - UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_NegX: + UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hX = -hW; + hX = -hW; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosY: - UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosY: + UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hY = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; break; - - case MScClipCode_NegY: - UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + + case MScClipCode_NegY: + UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; - hY = -hW; + hY = -hW; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosZ: - UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosZ: + UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = hW; - break; - - case MScClipCode_NegZ: - UUmAssert_Clip(frustumPointIn->z >= 0.0f); - UUmAssert_Clip(frustumPointOut->z < 0.0f); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = pIn / (pIn - pOut); - oneMinust = (1.0f - t); + hZ = hW; + break; + + case MScClipCode_NegZ: + UUmAssert_Clip(frustumPointIn->z >= 0.0f); + UUmAssert_Clip(frustumPointOut->z < 0.0f); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = pIn / (pIn - pOut); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = 0.0f; - break; + hZ = 0.0f; + break; } - + frustumPointNew->x = hX; frustumPointNew->y = hY; frustumPointNew->z = hZ; frustumPointNew->w = hW; - + // XXX - optimize this someday if(i == 0) { @@ -874,57 +874,57 @@ MSrClip_ComputeVertex_GouraudInterpolate( shadeOut = shades[inVIndexOut1]; shadeNew = shades + inVIndexNew1; } - + rOut = (float)((shadeOut >> 16) & 0xFF); gOut = (float)((shadeOut >> 8) & 0xFF); bOut = (float)((shadeOut >> 0) & 0xFF); - + rIn = (float)((shadeIn >> 16) & 0xFF); gIn = (float)((shadeIn >> 8) & 0xFF); bIn = (float)((shadeIn >> 0) & 0xFF); - + rNew = t * rOut + oneMinust * rIn; gNew = t * gOut + oneMinust * gIn; bNew = t * bOut + oneMinust * bIn; - - *shadeNew = + + *shadeNew = ((UUtUns32)rNew << 16) | ((UUtUns32)gNew << 8) | ((UUtUns32)bNew << 0); negW = -hW; newClipCode = MScClipCode_None; - + if(hX > hW) { newClipCode |= MScClipCode_PosX; } - + if(hX < negW) { newClipCode |= MScClipCode_NegX; } - + if(hY > hW) { newClipCode |= MScClipCode_PosY; } - + if(hY < negW) { newClipCode |= MScClipCode_NegY; } - + if(hZ > hW) { newClipCode |= MScClipCode_PosZ; } - + if(hZ < 0.0) { newClipCode |= MScClipCode_NegZ; } - + if(i == 0) { screenPointNew = screenPoints + inVIndexNew0; @@ -933,7 +933,7 @@ MSrClip_ComputeVertex_GouraudInterpolate( { screenPointNew = screenPoints + inVIndexNew1; } - + MSrClipCode_ValidateFrustum(frustumPointNew, newClipCode); if(newClipCode == 0) @@ -947,7 +947,7 @@ MSrClip_ComputeVertex_GouraudInterpolate( { screenPointNew->x = (hX * invW + 1.0f) * scaleX; } - + if(hY == hW) { screenPointNew->y = 0.0f; @@ -956,13 +956,13 @@ MSrClip_ComputeVertex_GouraudInterpolate( { screenPointNew->y = (hY * invW - 1.0f) * scaleY; } - + screenPointNew->z = hZ * invW; screenPointNew->invW = invW; - + MSiVerifyPointScreen(screenPointNew); } - + if(i == 0) { *outClipCodeNew0 = newClipCode; @@ -977,34 +977,34 @@ MSrClip_ComputeVertex_GouraudInterpolate( void MSrClip_ComputeVertex_TextureFlat( UUtUns32 inClipPlane, - + UUtUns32 inVIndexIn0, UUtUns32 inVIndexOut0, UUtUns32 inVIndexNew0, - + UUtUns32 inVIndexIn1, UUtUns32 inVIndexOut1, UUtUns32 inVIndexNew1, - + UUtUns8 *outClipCodeNew0, UUtUns8 *outClipCodeNew1) { M3tPoint4D* frustumPoints; M3tPointScreen* screenPoints; M3tTextureCoord* textureCoords; - + M3tPoint4D* frustumPointIn; M3tPoint4D* frustumPointOut; M3tPoint4D* frustumPointNew; - + M3tTextureCoord* textureCoordIn; M3tTextureCoord* textureCoordOut; M3tTextureCoord* textureCoordNew; - + M3tPointScreen* screenPointNew; - + float scaleX, scaleY; - + UUtUns8 newClipCode; float oneMinust, pIn, pOut, negW, invW; float hW, hX, hY, hZ; @@ -1012,7 +1012,7 @@ MSrClip_ComputeVertex_TextureFlat( float wIn, wOut; float t; UUtUns32 i; - + frustumPoints = MSgGeomContextPrivate->objectVertexData.frustumPoints; UUmAssertReadPtr(frustumPoints, sizeof(M3tPoint4D)); @@ -1021,10 +1021,10 @@ MSrClip_ComputeVertex_TextureFlat( textureCoords = MSgGeomContextPrivate->objectVertexData.textureCoords; UUmAssertReadPtr(textureCoords, sizeof(M3tTextureCoord)); - + scaleX = MSgGeomContextPrivate->scaleX; scaleY = MSgGeomContextPrivate->scaleY; - + for(i = 0; i < 2; i++) { if(i == 0) @@ -1039,113 +1039,113 @@ MSrClip_ComputeVertex_TextureFlat( frustumPointOut = frustumPoints + inVIndexOut1; frustumPointNew = frustumPoints + inVIndexNew1; } - + wIn = frustumPointIn->w; wOut = frustumPointOut->w; - - switch(inClipPlane) - { - case MScClipCode_PosX: - UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + + switch(inClipPlane) + { + case MScClipCode_PosX: + UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hX = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_NegX: - UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_NegX: + UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hX = -hW; + hX = -hW; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosY: - UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosY: + UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hY = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; break; - - case MScClipCode_NegY: - UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + + case MScClipCode_NegY: + UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; - hY = -hW; + hY = -hW; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosZ: - UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosZ: + UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = hW; - break; - - case MScClipCode_NegZ: - UUmAssert_Clip(frustumPointIn->z >= 0.0f); - UUmAssert_Clip(frustumPointOut->z < 0.0f); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = pIn / (pIn - pOut); - oneMinust = (1.0f - t); + hZ = hW; + break; + + case MScClipCode_NegZ: + UUmAssert_Clip(frustumPointIn->z >= 0.0f); + UUmAssert_Clip(frustumPointOut->z < 0.0f); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = pIn / (pIn - pOut); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = 0.0f; - break; + hZ = 0.0f; + break; } - + frustumPointNew->x = hX; frustumPointNew->y = hY; frustumPointNew->z = hZ; frustumPointNew->w = hW; - + if(i == 0) { textureCoordIn = textureCoords + inVIndexIn0; @@ -1160,40 +1160,40 @@ MSrClip_ComputeVertex_TextureFlat( } textureCoordNew->u = t * textureCoordOut->u + oneMinust * textureCoordIn->u; textureCoordNew->v = t * textureCoordOut->v + oneMinust * textureCoordIn->v; - + negW = -hW; newClipCode = MScClipCode_None; - + if(hX > hW) { newClipCode |= MScClipCode_PosX; } - + if(hX < negW) { newClipCode |= MScClipCode_NegX; } - + if(hY > hW) { newClipCode |= MScClipCode_PosY; } - + if(hY < negW) { newClipCode |= MScClipCode_NegY; } - + if(hZ > hW) { newClipCode |= MScClipCode_PosZ; } - + if(hZ < 0.0) { newClipCode |= MScClipCode_NegZ; } - + if(i == 0) { screenPointNew = screenPoints + inVIndexNew0; @@ -1202,7 +1202,7 @@ MSrClip_ComputeVertex_TextureFlat( { screenPointNew = screenPoints + inVIndexNew1; } - + MSrClipCode_ValidateFrustum(frustumPointNew, newClipCode); if(newClipCode == 0) @@ -1216,7 +1216,7 @@ MSrClip_ComputeVertex_TextureFlat( { screenPointNew->x = (hX * invW + 1.0f) * scaleX; } - + if(hY == hW) { screenPointNew->y = 0.0f; @@ -1225,13 +1225,13 @@ MSrClip_ComputeVertex_TextureFlat( { screenPointNew->y = (hY * invW - 1.0f) * scaleY; } - + screenPointNew->z = hZ * invW; screenPointNew->invW = invW; - + MSiVerifyPointScreen(screenPointNew); } - + if(i == 0) { *outClipCodeNew0 = newClipCode; @@ -1246,29 +1246,29 @@ MSrClip_ComputeVertex_TextureFlat( void MSrClip_ComputeVertex_GouraudFlat( UUtUns32 inClipPlane, - + UUtUns32 inVIndexIn0, UUtUns32 inVIndexOut0, UUtUns32 inVIndexNew0, - + UUtUns32 inVIndexIn1, UUtUns32 inVIndexOut1, UUtUns32 inVIndexNew1, - + UUtUns8 *outClipCodeNew0, UUtUns8 *outClipCodeNew1) { M3tPoint4D* frustumPoints; M3tPointScreen* screenPoints; - + M3tPoint4D* frustumPointIn; M3tPoint4D* frustumPointOut; M3tPoint4D* frustumPointNew; - + M3tPointScreen* screenPointNew; - + float scaleX, scaleY; - + UUtUns8 newClipCode; float oneMinust, pIn, pOut, negW, invW; float hW, hX, hY, hZ; @@ -1276,16 +1276,16 @@ MSrClip_ComputeVertex_GouraudFlat( float wIn, wOut; float t; UUtUns32 i; - + frustumPoints = MSgGeomContextPrivate->objectVertexData.frustumPoints; UUmAssertReadPtr(frustumPoints, sizeof(M3tPoint4D)); screenPoints = MSgGeomContextPrivate->objectVertexData.screenPoints; UUmAssertReadPtr(screenPoints, sizeof(M3tPointScreen)); - + scaleX = MSgGeomContextPrivate->scaleX; scaleY = MSgGeomContextPrivate->scaleY; - + for(i = 0; i < 2; i++) { if(i == 0) @@ -1300,146 +1300,146 @@ MSrClip_ComputeVertex_GouraudFlat( frustumPointOut = frustumPoints + inVIndexOut1; frustumPointNew = frustumPoints + inVIndexNew1; } - + wIn = frustumPointIn->w; wOut = frustumPointOut->w; - - switch(inClipPlane) - { - case MScClipCode_PosX: - UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + + switch(inClipPlane) + { + case MScClipCode_PosX: + UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hX = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_NegX: - UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_NegX: + UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hX = -hW; + hX = -hW; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosY: - UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosY: + UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hY = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; break; - - case MScClipCode_NegY: - UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + + case MScClipCode_NegY: + UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; - hY = -hW; + hY = -hW; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosZ: - UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosZ: + UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = hW; - break; - - case MScClipCode_NegZ: - UUmAssert_Clip(frustumPointIn->z >= 0.0f); - UUmAssert_Clip(frustumPointOut->z < 0.0f); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = pIn / (pIn - pOut); - oneMinust = (1.0f - t); + hZ = hW; + break; + + case MScClipCode_NegZ: + UUmAssert_Clip(frustumPointIn->z >= 0.0f); + UUmAssert_Clip(frustumPointOut->z < 0.0f); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = pIn / (pIn - pOut); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = 0.0f; - break; + hZ = 0.0f; + break; } - + frustumPointNew->x = hX; frustumPointNew->y = hY; frustumPointNew->z = hZ; frustumPointNew->w = hW; - + negW = -hW; newClipCode = MScClipCode_None; - + if(hX > hW) { newClipCode |= MScClipCode_PosX; } - + if(hX < negW) { newClipCode |= MScClipCode_NegX; } - + if(hY > hW) { newClipCode |= MScClipCode_PosY; } - + if(hY < negW) { newClipCode |= MScClipCode_NegY; } - + if(hZ > hW) { newClipCode |= MScClipCode_PosZ; } - + if(hZ < 0.0) { newClipCode |= MScClipCode_NegZ; } - + if(i == 0) { screenPointNew = screenPoints + inVIndexNew0; @@ -1448,7 +1448,7 @@ MSrClip_ComputeVertex_GouraudFlat( { screenPointNew = screenPoints + inVIndexNew1; } - + MSrClipCode_ValidateFrustum(frustumPointNew, newClipCode); if(newClipCode == 0) @@ -1462,7 +1462,7 @@ MSrClip_ComputeVertex_GouraudFlat( { screenPointNew->x = (hX * invW + 1.0f) * scaleX; } - + if(hY == hW) { screenPointNew->y = 0.0f; @@ -1471,13 +1471,13 @@ MSrClip_ComputeVertex_GouraudFlat( { screenPointNew->y = (hY * invW - 1.0f) * scaleY; } - + screenPointNew->z = hZ * invW; screenPointNew->invW = invW; - + MSiVerifyPointScreen(screenPointNew); } - + if(i == 0) { *outClipCodeNew0 = newClipCode; @@ -1499,27 +1499,27 @@ MSrClip_ComputeVertex_LineFlat( { M3tPoint4D* frustumPoints; M3tPointScreen* screenPoints; - + M3tPoint4D* frustumPointIn; M3tPoint4D* frustumPointOut; M3tPoint4D* frustumPointNew; - + M3tPointScreen* screenPointNew; - + float scaleX, scaleY; - + UUtUns8 newClipCode; float oneMinust, pIn, pOut, negW, invW; float hW, hX, hY, hZ; float wIn, wOut; float t; - + frustumPoints = MSgGeomContextPrivate->objectVertexData.frustumPoints; UUmAssertReadPtr(frustumPoints, sizeof(M3tPoint4D)); screenPoints = MSgGeomContextPrivate->objectVertexData.screenPoints; UUmAssertReadPtr(screenPoints, sizeof(M3tPointScreen)); - + scaleX = MSgGeomContextPrivate->scaleX; scaleY = MSgGeomContextPrivate->scaleY; @@ -1529,145 +1529,145 @@ MSrClip_ComputeVertex_LineFlat( wIn = frustumPointIn->w; wOut = frustumPointOut->w; - - switch(inClipPlane) - { - case MScClipCode_PosX: - UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + + switch(inClipPlane) + { + case MScClipCode_PosX: + UUmAssert_Clip(frustumPointIn->x <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x > frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hX = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_NegX: - UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); - - pIn = frustumPointIn->x; - pOut = frustumPointOut->x; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_NegX: + UUmAssert_Clip(frustumPointIn->x >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->x < -frustumPointOut->w); + + pIn = frustumPointIn->x; + pOut = frustumPointOut->x; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hX = -hW; + hX = -hW; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosY: - UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosY: + UUmAssert_Clip(frustumPointIn->y <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y > frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hY = hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; break; - - case MScClipCode_NegY: - UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); - - pIn = frustumPointIn->y; - pOut = frustumPointOut->y; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + + case MScClipCode_NegY: + UUmAssert_Clip(frustumPointIn->y >= -frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->y < -frustumPointOut->w); + + pIn = frustumPointIn->y; + pOut = frustumPointOut->y; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; - hY = -hW; + hY = -hW; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hZ = t * frustumPointOut->z + oneMinust * frustumPointIn->z; - break; - - case MScClipCode_PosZ: - UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); - UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosZ: + UUmAssert_Clip(frustumPointIn->z <= frustumPointIn->w); + UUmAssert_Clip(frustumPointOut->z > frustumPointOut->w); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = hW; - break; - - case MScClipCode_NegZ: - UUmAssert_Clip(frustumPointIn->z >= 0.0f); - UUmAssert_Clip(frustumPointOut->z < 0.0f); - - pIn = frustumPointIn->z; - pOut = frustumPointOut->z; - t = pIn / (pIn - pOut); - oneMinust = (1.0f - t); + hZ = hW; + break; + + case MScClipCode_NegZ: + UUmAssert_Clip(frustumPointIn->z >= 0.0f); + UUmAssert_Clip(frustumPointOut->z < 0.0f); + + pIn = frustumPointIn->z; + pOut = frustumPointOut->z; + t = pIn / (pIn - pOut); + oneMinust = (1.0f - t); UUmAssert_Clip(t <= 1.0f); - UUmAssert_Clip(t >= -1.0f); + UUmAssert_Clip(t >= -1.0f); hW = t * frustumPointOut->w + oneMinust * frustumPointIn->w; hX = t * frustumPointOut->x + oneMinust * frustumPointIn->x; hY = t * frustumPointOut->y + oneMinust * frustumPointIn->y; - hZ = 0.0f; - break; + hZ = 0.0f; + break; } - + frustumPointNew->x = hX; frustumPointNew->y = hY; frustumPointNew->z = hZ; frustumPointNew->w = hW; - + negW = -hW; newClipCode = MScClipCode_None; - + if(hX > hW) { newClipCode |= MScClipCode_PosX; } - + if(hX < negW) { newClipCode |= MScClipCode_NegX; } - + if(hY > hW) { newClipCode |= MScClipCode_PosY; } - + if(hY < negW) { newClipCode |= MScClipCode_NegY; } - + if(hZ > hW) { newClipCode |= MScClipCode_PosZ; } - + if(hZ < 0.0) { newClipCode |= MScClipCode_NegZ; } - + screenPointNew = screenPoints + inVIndexNew; - + MSrClipCode_ValidateFrustum(frustumPointNew, newClipCode); if(newClipCode == 0) @@ -1681,7 +1681,7 @@ MSrClip_ComputeVertex_LineFlat( { screenPointNew->x = (hX * invW + 1.0f) * scaleX; } - + if(hY == hW) { screenPointNew->y = 0.0f; @@ -1690,13 +1690,13 @@ MSrClip_ComputeVertex_LineFlat( { screenPointNew->y = (hY * invW - 1.0f) * scaleY; } - + screenPointNew->z = hZ * invW; screenPointNew->invW = invW; - + MSiVerifyPointScreen(screenPointNew); } - + *outClipCodeNew = newClipCode; } @@ -1710,36 +1710,36 @@ MSrClip_Line( { UUtInt8 i; UUtUns32 curClipPlane; - + UUtUns8 newClipCode; - UUtUns32 newVIndex; - + UUtUns32 newVIndex; + MSrClip_LineComputeVertexProc lineComputeVertexProc; - + if(inClipCode0 & inClipCode1) { return; } - + lineComputeVertexProc = MSgGeomContextPrivate->lineComputeVertexProc; - + newVIndex = MSgGeomContextPrivate->objectVertexData.newClipVertexIndex++; - + UUmAssert(newVIndex < M3cMaxObjVertices); #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + gClipNesting++; - + UUmAssert(gClipNesting < 10); UUmAssert(gClipNesting >= 0); - + MSiVerifyPoint4D( frustumPoint0); MSiVerifyPoint4D( frustumPoint1); - + MSrClipCode_ValidateFrustum( frustumPoint0, inClipCode0); @@ -1748,32 +1748,32 @@ MSrClip_Line( inClipCode1); #endif - + for(i = 6; i-- > 0;) { curClipPlane = 1 << i; - + if(inClippedPlanes & curClipPlane) { continue; } - + if(inClipCode0 & curClipPlane) { // clipCode0 is out of bounds // clipCode1 is in bounds - + lineComputeVertexProc( curClipPlane, inVIndex1, inVIndex0, newVIndex, &newClipCode); - + /* Check for trivial accept */ if(!(inClipCode1 | newClipCode)) { - + // Draw the line M3rDraw_Line(inVIndex1, newVIndex); } @@ -1787,7 +1787,7 @@ MSrClip_Line( newClipCode, (UUtUns8)(inClippedPlanes | curClipPlane)); } - + /* Check for trivial reject */ if(inClipCode0 & (newClipCode | curClipPlane)) { @@ -1804,7 +1804,7 @@ MSrClip_Line( (UUtUns8)(inClippedPlanes | curClipPlane)); } } - + if(inClipCode1 & curClipPlane) { // clipCode1 is out of bounds @@ -1815,7 +1815,7 @@ MSrClip_Line( inVIndex1, newVIndex, &newClipCode); - + /* Check for trivial accept */ if(!(inClipCode0 | newClipCode)) { @@ -1834,7 +1834,7 @@ MSrClip_Line( newClipCode, (UUtUns8)(inClippedPlanes | curClipPlane)); } - + /* Check for trivial reject */ if(inClipCode1 & (newClipCode | curClipPlane)) { @@ -1854,9 +1854,9 @@ MSrClip_Line( } #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + gClipNesting--; - + #endif } @@ -1872,30 +1872,30 @@ MSrClip_Triangle( { MSrClip_PolyComputeVertexProc computeVertexProc; - + UUtUns8 newClipCode0; UUtUns8 newClipCode1; - UUtUns32 newVIndex0; - UUtUns32 newVIndex1; + UUtUns32 newVIndex0; + UUtUns32 newVIndex1; UUtInt32 i; UUtUns8 curClipPlane; - + M3tTri newTri; M3tQuad newQuad; - + if(inClipCode0 & inClipCode1 & inClipCode2) { return; } - + newVIndex0 = MSgGeomContextPrivate->objectVertexData.newClipVertexIndex++; newVIndex1 = MSgGeomContextPrivate->objectVertexData.newClipVertexIndex++; - + computeVertexProc = MSgGeomContextPrivate->polyComputeVertexProc; - + UUmAssert(MSgGeomContextPrivate->objectVertexData.newClipVertexIndex <= MSgGeomContextPrivate->objectVertexData.maxClipVertices); - + for(i = 6; i-- > 0;) { curClipPlane = (UUtUns8)(1 << i); @@ -1903,24 +1903,24 @@ MSrClip_Triangle( { continue; } - - if(curClipPlane & inClipCode0) - { - /* 0: Out, 1: ?, 2: ? */ - if(curClipPlane & inClipCode1) - { - /* 0: Out, 1: Out, 2: In */ + + if(curClipPlane & inClipCode0) + { + /* 0: Out, 1: ?, 2: ? */ + if(curClipPlane & inClipCode1) + { + /* 0: Out, 1: Out, 2: In */ UUmAssert(!(curClipPlane & inClipCode2)); - - /* Compute 2 -> 0 intersection */ - /* Compute 2 -> 1 intersection */ + + /* Compute 2 -> 0 intersection */ + /* Compute 2 -> 1 intersection */ computeVertexProc( curClipPlane, - inVIndex2, inVIndex0, newVIndex0, - inVIndex2, inVIndex1, newVIndex1, + inVIndex2, inVIndex0, newVIndex0, + inVIndex2, inVIndex1, newVIndex1, &newClipCode0, &newClipCode1); - - /* Check for trivial accept on 2, new0, new1 */ + + /* Check for trivial accept on 2, new0, new1 */ if(inClipCode2 | newClipCode0 | newClipCode1) { MSrClip_Triangle( @@ -1933,28 +1933,28 @@ MSrClip_Triangle( newTri.indices[0] = inVIndex2; newTri.indices[1] = newVIndex0; newTri.indices[2] = newVIndex1; - + M3rDraw_Triangle( &newTri); } - - return; - } - else - { - /* 0: Out, 1: in, 2: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: Out, 1: In, 2: Out */ - - /* Compute 1 -> 0 Intersection */ - /* Compute 1 -> 2 Intersection */ + + return; + } + else + { + /* 0: Out, 1: in, 2: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: Out, 1: In, 2: Out */ + + /* Compute 1 -> 0 Intersection */ + /* Compute 1 -> 2 Intersection */ computeVertexProc( curClipPlane, - inVIndex1, inVIndex0, newVIndex0, - inVIndex1, inVIndex2, newVIndex1, + inVIndex1, inVIndex0, newVIndex0, + inVIndex1, inVIndex2, newVIndex1, &newClipCode0, &newClipCode1); - + /* Check for trivial accept on 1, new1, new0 */ if(inClipCode1 | newClipCode1 | newClipCode0) { @@ -1968,26 +1968,26 @@ MSrClip_Triangle( newTri.indices[0] = inVIndex1; newTri.indices[1] = newVIndex1; newTri.indices[2] = newVIndex0; - + M3rDraw_Triangle( &newTri); } - - return; - } - else - { - /* 0: Out, 1: In, 2: In */ - - /* Compute 1 -> 0 intersection */ - /* Compute 2 -> 0 intersection */ + + return; + } + else + { + /* 0: Out, 1: In, 2: In */ + + /* Compute 1 -> 0 intersection */ + /* Compute 2 -> 0 intersection */ computeVertexProc( curClipPlane, - inVIndex1, inVIndex0, newVIndex0, - inVIndex2, inVIndex0, newVIndex1, + inVIndex1, inVIndex0, newVIndex0, + inVIndex2, inVIndex0, newVIndex1, &newClipCode0, &newClipCode1); - - /* Check for trivial accept on 1, 2, new1, new0 */ + + /* Check for trivial accept on 1, 2, new1, new0 */ if(inClipCode1 | inClipCode2 | newClipCode1 | newClipCode0) { MSrClip_Quad( @@ -2001,33 +2001,33 @@ MSrClip_Triangle( newQuad.indices[1] = inVIndex2; newQuad.indices[2] = newVIndex1; newQuad.indices[3] = newVIndex0; - + M3rDraw_Quad( &newQuad); } - - return; - } + + return; + } } } - else - { - /* 0: In, 1: ?, 2: ? */ - if(curClipPlane & inClipCode1) - { - /* 0: In, 1: Out, 2: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: In, 1: Out, 2: Out */ - - /* Compute 0 -> 1 intersection */ - /* Compute 0 -> 2 intersection */ + else + { + /* 0: In, 1: ?, 2: ? */ + if(curClipPlane & inClipCode1) + { + /* 0: In, 1: Out, 2: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: In, 1: Out, 2: Out */ + + /* Compute 0 -> 1 intersection */ + /* Compute 0 -> 2 intersection */ computeVertexProc( curClipPlane, - inVIndex0, inVIndex1, newVIndex0, - inVIndex0, inVIndex2, newVIndex1, + inVIndex0, inVIndex1, newVIndex0, + inVIndex0, inVIndex2, newVIndex1, &newClipCode0, &newClipCode1); - + /* Check for trivial accept on 0, new0, new1 */ if(inClipCode0 | newClipCode0 | newClipCode1) { @@ -2041,26 +2041,26 @@ MSrClip_Triangle( newTri.indices[0] = inVIndex0; newTri.indices[1] = newVIndex0; newTri.indices[2] = newVIndex1; - + M3rDraw_Triangle( &newTri); } - - return; - } - else - { - /* 0: In, 1: Out, 2: In */ - - /* Compute 0 -> 1 intersection */ - /* Compute 2 -> 1 intersection */ + + return; + } + else + { + /* 0: In, 1: Out, 2: In */ + + /* Compute 0 -> 1 intersection */ + /* Compute 2 -> 1 intersection */ computeVertexProc( curClipPlane, - inVIndex0, inVIndex1, newVIndex0, - inVIndex2, inVIndex1, newVIndex1, + inVIndex0, inVIndex1, newVIndex0, + inVIndex2, inVIndex1, newVIndex1, &newClipCode0, &newClipCode1); - - /* Check for trivial accept on 2, 0, new0, new1 */ + + /* Check for trivial accept on 2, 0, new0, new1 */ if(inClipCode2 | inClipCode0 | newClipCode0 | newClipCode1) { MSrClip_Quad( @@ -2074,31 +2074,31 @@ MSrClip_Triangle( newQuad.indices[1] = inVIndex0; newQuad.indices[2] = newVIndex0; newQuad.indices[3] = newVIndex1; - + M3rDraw_Quad( &newQuad); } - - return; - } - - } - else - { - /* 0: In, 1: in, 2: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: In, 1: in, 2: Out */ - - /* Compute 0 -> 2 intersection */ - /* Compute 1 -> 2 intersection */ + + return; + } + + } + else + { + /* 0: In, 1: in, 2: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: In, 1: in, 2: Out */ + + /* Compute 0 -> 2 intersection */ + /* Compute 1 -> 2 intersection */ computeVertexProc( curClipPlane, - inVIndex0, inVIndex2, newVIndex0, - inVIndex1, inVIndex2, newVIndex1, + inVIndex0, inVIndex2, newVIndex0, + inVIndex1, inVIndex2, newVIndex1, &newClipCode0, &newClipCode1); - - /* Check for trivial accept on 0, 1, new1, new0 */ + + /* Check for trivial accept on 0, 1, new1, new0 */ if(inClipCode0 | inClipCode1 | newClipCode1 | newClipCode0) { MSrClip_Quad( @@ -2112,15 +2112,15 @@ MSrClip_Triangle( newQuad.indices[1] = inVIndex1; newQuad.indices[2] = newVIndex1; newQuad.indices[3] = newVIndex0; - + M3rDraw_Quad( &newQuad); } - - return; - } - /* else all are in */ - } + + return; + } + /* else all are in */ + } } } } @@ -2141,29 +2141,29 @@ MSrClip_Quad( UUtUns8 newClipCode0; UUtUns8 newClipCode1; - UUtUns32 newVIndex0; - UUtUns32 newVIndex1; + UUtUns32 newVIndex0; + UUtUns32 newVIndex1; UUtInt32 i; UUtUns8 curClipPlane; MSrClip_PolyComputeVertexProc computeVertexProc; - + M3tTri newTri; M3tQuad newQuad; M3tPent newPent; - + if(inClipCode0 & inClipCode1 & inClipCode2 & inClipCode3) { return; } - + newVIndex0 = MSgGeomContextPrivate->objectVertexData.newClipVertexIndex++; newVIndex1 = MSgGeomContextPrivate->objectVertexData.newClipVertexIndex++; - + UUmAssert(MSgGeomContextPrivate->objectVertexData.newClipVertexIndex <= MSgGeomContextPrivate->objectVertexData.maxClipVertices); - + computeVertexProc = MSgGeomContextPrivate->polyComputeVertexProc; - + for(i = 6; i-- > 0;) { curClipPlane = (UUtUns8)(1 << i); @@ -2171,25 +2171,25 @@ MSrClip_Quad( { continue; } - - if(curClipPlane & inClipCode0) - { - /* 0: Out, 1: ?, 2: ?, 3: ? */ - if(curClipPlane & inClipCode1) - { - /* 0: Out, 1: Out, 2: ?, 3: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: Out, 1: Out, 2: Out, 3: In */ - //UUmAssert(!(curClipPlane & inClipCode3)); - /* Compute 3 -> 0 intersection */ - /* Compute 3 -> 2 intersection */ + + if(curClipPlane & inClipCode0) + { + /* 0: Out, 1: ?, 2: ?, 3: ? */ + if(curClipPlane & inClipCode1) + { + /* 0: Out, 1: Out, 2: ?, 3: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: Out, 1: Out, 2: Out, 3: In */ + //UUmAssert(!(curClipPlane & inClipCode3)); + /* Compute 3 -> 0 intersection */ + /* Compute 3 -> 2 intersection */ computeVertexProc( curClipPlane, - inVIndex3, inVIndex0, newVIndex0, - inVIndex3, inVIndex2, newVIndex1, + inVIndex3, inVIndex0, newVIndex0, + inVIndex3, inVIndex2, newVIndex1, &newClipCode0, &newClipCode1); - + /* Check for trivial accept on 3, new0, new1 */ if(inClipCode3 | newClipCode0 | newClipCode1) { @@ -2203,27 +2203,27 @@ MSrClip_Quad( newTri.indices[0] = inVIndex3; newTri.indices[1] = newVIndex0; newTri.indices[2] = newVIndex1; - + M3rDraw_Triangle( &newTri); } return; - } - else - { - /* 0: Out, 1: Out, 2: In, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: Out, 1: Out, 2: In, 3: Out */ - /* Compute 2 -> 1 intersection */ - /* Compute 2 -> 3 intersection */ + } + else + { + /* 0: Out, 1: Out, 2: In, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: Out, 1: Out, 2: In, 3: Out */ + /* Compute 2 -> 1 intersection */ + /* Compute 2 -> 3 intersection */ computeVertexProc( curClipPlane, - inVIndex2, inVIndex1, newVIndex0, - inVIndex2, inVIndex3, newVIndex1, + inVIndex2, inVIndex1, newVIndex0, + inVIndex2, inVIndex3, newVIndex1, &newClipCode0, &newClipCode1); - /* Check for trivial accept on 2, new1, new0 */ + /* Check for trivial accept on 2, new1, new0 */ if(inClipCode2 | newClipCode1 | newClipCode0) { MSrClip_Triangle( @@ -2236,21 +2236,21 @@ MSrClip_Quad( newTri.indices[0] = inVIndex2; newTri.indices[1] = newVIndex1; newTri.indices[2] = newVIndex0; - + M3rDraw_Triangle( &newTri); } return; - } - else - { - /* 0: Out, 1: Out, 2: In, 3: In */ - /* Compute 2 -> 1 intersection */ - /* Compute 3 -> 0 intersection */ + } + else + { + /* 0: Out, 1: Out, 2: In, 3: In */ + /* Compute 2 -> 1 intersection */ + /* Compute 3 -> 0 intersection */ computeVertexProc( curClipPlane, - inVIndex2, inVIndex1, newVIndex0, - inVIndex3, inVIndex0, newVIndex1, + inVIndex2, inVIndex1, newVIndex0, + inVIndex3, inVIndex0, newVIndex1, &newClipCode0, &newClipCode1); /* Check for trivial accept on 2, 3, new1, new0 */ @@ -2267,30 +2267,30 @@ MSrClip_Quad( newQuad.indices[1] = inVIndex3; newQuad.indices[2] = newVIndex1; newQuad.indices[3] = newVIndex0; - + M3rDraw_Quad( &newQuad); } return; - } - } - } - else - { - /* 0: Out, 1: In, 2: ?, 3: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: Out, 1: In, 2: Out, 3: Out */ - //UUmAssert(curClipPlane & inClipCode3); - /* Compute 1 -> 0 intersection */ - /* Compute 1 -> 2 intersection */ + } + } + } + else + { + /* 0: Out, 1: In, 2: ?, 3: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: Out, 1: In, 2: Out, 3: Out */ + //UUmAssert(curClipPlane & inClipCode3); + /* Compute 1 -> 0 intersection */ + /* Compute 1 -> 2 intersection */ computeVertexProc( curClipPlane, - inVIndex1, inVIndex0, newVIndex0, - inVIndex1, inVIndex2, newVIndex1, + inVIndex1, inVIndex0, newVIndex0, + inVIndex1, inVIndex2, newVIndex1, &newClipCode0, &newClipCode1); - /* Check for trivial accept on 1, new1, new0 */ + /* Check for trivial accept on 1, new1, new0 */ if(inClipCode1 | newClipCode1 | newClipCode0) { MSrClip_Triangle( @@ -2303,24 +2303,24 @@ MSrClip_Quad( newTri.indices[0] = inVIndex1; newTri.indices[1] = newVIndex1; newTri.indices[2] = newVIndex0; - + M3rDraw_Triangle( &newTri); } return; - } - else - { - /* 0: Out, 1: In, 2: In, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: Out, 1: In, 2: In, 3: Out */ - /* Compute 1 -> 0 intersection */ - /* Compute 2 -> 3 intersection */ + } + else + { + /* 0: Out, 1: In, 2: In, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: Out, 1: In, 2: In, 3: Out */ + /* Compute 1 -> 0 intersection */ + /* Compute 2 -> 3 intersection */ computeVertexProc( curClipPlane, - inVIndex1, inVIndex0, newVIndex0, - inVIndex2, inVIndex3, newVIndex1, + inVIndex1, inVIndex0, newVIndex0, + inVIndex2, inVIndex3, newVIndex1, &newClipCode0, &newClipCode1); /* Check for trivial accept on 1, 2, new1, new0 */ @@ -2337,22 +2337,22 @@ MSrClip_Quad( newQuad.indices[1] = inVIndex2; newQuad.indices[2] = newVIndex1; newQuad.indices[3] = newVIndex0; - + M3rDraw_Quad( &newQuad); } return; - } - else - { - /* 0: Out, 1: In, 2: In, 3: In */ - /* Compute 1 -> 0 intersection */ - /* Compute 3 -> 0 intersection */ + } + else + { + /* 0: Out, 1: In, 2: In, 3: In */ + /* Compute 1 -> 0 intersection */ + /* Compute 3 -> 0 intersection */ computeVertexProc( curClipPlane, - inVIndex1, inVIndex0, newVIndex0, - inVIndex3, inVIndex0, newVIndex1, + inVIndex1, inVIndex0, newVIndex0, + inVIndex3, inVIndex0, newVIndex1, &newClipCode0, &newClipCode1); /* Check for trivial accept on 1, 2, 3, new1, new0 */ @@ -2371,11 +2371,11 @@ MSrClip_Quad( newQuad.indices[1] = inVIndex2; newQuad.indices[2] = inVIndex3; newQuad.indices[3] = newVIndex1; - + M3rDraw_Quad( &newQuad); } - + if(inClipCode1 | newClipCode1 | newClipCode0) { MSrClip_Triangle( @@ -2388,7 +2388,7 @@ MSrClip_Quad( newTri.indices[0] = inVIndex1; newTri.indices[1] = newVIndex1; newTri.indices[2] = newVIndex0; - + M3rDraw_Triangle( &newTri); } @@ -2400,37 +2400,37 @@ MSrClip_Quad( newPent.indices[2] = inVIndex3; newPent.indices[3] = newVIndex1; newPent.indices[4] = newVIndex0; - + M3rDraw_Pent( &newPent); } return; - } - } - } - } - else - { - /* 0: In, 1: ?, 2: ?, 3: ? */ - if(curClipPlane & inClipCode1) - { - /* 0: In, 1: Out, 2: ?, 3: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: In, 1: Out, 2: Out, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: In, 1: Out, 2: Out, 3: Out */ - /* Compute 0 -> 3 intersection */ - /* Compute 0 -> 1 intersection */ + } + } + } + } + else + { + /* 0: In, 1: ?, 2: ?, 3: ? */ + if(curClipPlane & inClipCode1) + { + /* 0: In, 1: Out, 2: ?, 3: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: In, 1: Out, 2: Out, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: In, 1: Out, 2: Out, 3: Out */ + /* Compute 0 -> 3 intersection */ + /* Compute 0 -> 1 intersection */ computeVertexProc( curClipPlane, - inVIndex0, inVIndex3, newVIndex0, - inVIndex0, inVIndex1, newVIndex1, - + inVIndex0, inVIndex3, newVIndex0, + inVIndex0, inVIndex1, newVIndex1, + &newClipCode0, &newClipCode1); - /* Check for trivial accept on 0, new1, new0 */ + /* Check for trivial accept on 0, new1, new0 */ if(inClipCode0 | newClipCode1 | newClipCode0) { MSrClip_Triangle( @@ -2443,21 +2443,21 @@ MSrClip_Quad( newTri.indices[0] = inVIndex0; newTri.indices[1] = newVIndex1; newTri.indices[2] = newVIndex0; - + M3rDraw_Triangle( &newTri); } return; - } - else - { - /* 0: In, 1: Out, 2: Out, 3: In */ - /* Compute 3 -> 2 intersection */ - /* Compute 0 -> 1 intersection */ + } + else + { + /* 0: In, 1: Out, 2: Out, 3: In */ + /* Compute 3 -> 2 intersection */ + /* Compute 0 -> 1 intersection */ computeVertexProc( curClipPlane, - inVIndex3, inVIndex2, newVIndex0, - inVIndex0, inVIndex1, newVIndex1, + inVIndex3, inVIndex2, newVIndex0, + inVIndex0, inVIndex1, newVIndex1, &newClipCode0, &newClipCode1); /* Check for trivial accept on 3, 0, new1, new0 */ @@ -2474,24 +2474,24 @@ MSrClip_Quad( newQuad.indices[1] = inVIndex0; newQuad.indices[2] = newVIndex1; newQuad.indices[3] = newVIndex0; - + M3rDraw_Quad( &newQuad); } return; - } - } - else - { - /* 0: In, 1: Out, 2: In, 3: In */ - //UUmAssert(!(curClipPlane & inClipCode3)); - /* Compute 2 -> 1 intersection */ - /* Compute 0 -> 1 intersection */ + } + } + else + { + /* 0: In, 1: Out, 2: In, 3: In */ + //UUmAssert(!(curClipPlane & inClipCode3)); + /* Compute 2 -> 1 intersection */ + /* Compute 0 -> 1 intersection */ computeVertexProc( curClipPlane, - inVIndex2, inVIndex1, newVIndex0, - inVIndex0, inVIndex1, newVIndex1, + inVIndex2, inVIndex1, newVIndex0, + inVIndex0, inVIndex1, newVIndex1, &newClipCode0, &newClipCode1); /* Check for trivial accept on 2, 3, 0, new1, new0 */ @@ -2510,11 +2510,11 @@ MSrClip_Quad( newQuad.indices[1] = inVIndex3; newQuad.indices[2] = inVIndex0; newQuad.indices[3] = newVIndex1; - + M3rDraw_Quad( &newQuad); } - + if(inClipCode2 | newClipCode1 | newClipCode0) { MSrClip_Triangle( @@ -2527,7 +2527,7 @@ MSrClip_Quad( newTri.indices[0] = inVIndex2; newTri.indices[1] = newVIndex1; newTri.indices[2] = newVIndex0; - + M3rDraw_Triangle( &newTri); } @@ -2539,28 +2539,28 @@ MSrClip_Quad( newPent.indices[2] = inVIndex0; newPent.indices[3] = newVIndex1; newPent.indices[4] = newVIndex0; - + M3rDraw_Pent( &newPent); } return; - } - } - else - { - /* 0: In, 1: In, 2: ?, 3: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: In, 1: In, 2: Out, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: In, 1: In, 2: Out, 3: Out */ - /* Compute 0 -> 3 intersection */ - /* Compute 1 -> 2 intersection */ + } + } + else + { + /* 0: In, 1: In, 2: ?, 3: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: In, 1: In, 2: Out, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: In, 1: In, 2: Out, 3: Out */ + /* Compute 0 -> 3 intersection */ + /* Compute 1 -> 2 intersection */ computeVertexProc( curClipPlane, - inVIndex0, inVIndex3, newVIndex0, - inVIndex1, inVIndex2, newVIndex1, + inVIndex0, inVIndex3, newVIndex0, + inVIndex1, inVIndex2, newVIndex1, &newClipCode0, &newClipCode1); /* Check for trivial accept on 0, 1, new1, new0 */ @@ -2577,22 +2577,22 @@ MSrClip_Quad( newQuad.indices[1] = inVIndex1; newQuad.indices[2] = newVIndex1; newQuad.indices[3] = newVIndex0; - + M3rDraw_Quad( &newQuad); } return; - } - else - { - /* 0: In, 1: In, 2: Out, 3: In */ - /* Compute 3 -> 2 intersection */ - /* Compute 1 -> 2 intersection */ + } + else + { + /* 0: In, 1: In, 2: Out, 3: In */ + /* Compute 3 -> 2 intersection */ + /* Compute 1 -> 2 intersection */ computeVertexProc( curClipPlane, - inVIndex3, inVIndex2, newVIndex0, - inVIndex1, inVIndex2, newVIndex1, + inVIndex3, inVIndex2, newVIndex0, + inVIndex1, inVIndex2, newVIndex1, &newClipCode0, &newClipCode1); /* Check for trivial accept on 3, 0, 1, new1, new0 */ @@ -2611,11 +2611,11 @@ MSrClip_Quad( newQuad.indices[1] = inVIndex0; newQuad.indices[2] = inVIndex1; newQuad.indices[3] = newVIndex1; - + M3rDraw_Quad( &newQuad); } - + if(inClipCode3 | newClipCode1 | newClipCode0) { MSrClip_Triangle( @@ -2628,7 +2628,7 @@ MSrClip_Quad( newTri.indices[0] = inVIndex3; newTri.indices[1] = newVIndex1; newTri.indices[2] = newVIndex0; - + M3rDraw_Triangle( &newTri); } @@ -2640,25 +2640,25 @@ MSrClip_Quad( newPent.indices[2] = inVIndex1; newPent.indices[3] = newVIndex1; newPent.indices[4] = newVIndex0; - + M3rDraw_Pent( &newPent); } return; - } - } - else - { - /* 0: In, 1: In, 2: In, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: In, 1: In, 2: In, 3: Out */ - /* Compute 0 -> 3 intersection */ - /* Compute 2 -> 3 intersection */ + } + } + else + { + /* 0: In, 1: In, 2: In, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: In, 1: In, 2: In, 3: Out */ + /* Compute 0 -> 3 intersection */ + /* Compute 2 -> 3 intersection */ computeVertexProc( curClipPlane, - inVIndex0, inVIndex3, newVIndex0, - inVIndex2, inVIndex3, newVIndex1, + inVIndex0, inVIndex3, newVIndex0, + inVIndex2, inVIndex3, newVIndex1, &newClipCode0, &newClipCode1); /* Check for trivial accept on 0, 1, 2, new1, new0 */ @@ -2677,11 +2677,11 @@ MSrClip_Quad( newQuad.indices[1] = inVIndex1; newQuad.indices[2] = inVIndex2; newQuad.indices[3] = newVIndex1; - + M3rDraw_Quad( &newQuad); } - + if(inClipCode0 | newClipCode1 | newClipCode0) { MSrClip_Triangle( @@ -2694,7 +2694,7 @@ MSrClip_Quad( newTri.indices[0] = inVIndex0; newTri.indices[1] = newVIndex1; newTri.indices[2] = newVIndex0; - + M3rDraw_Triangle( &newTri); } @@ -2706,15 +2706,15 @@ MSrClip_Quad( newPent.indices[2] = inVIndex2; newPent.indices[3] = newVIndex1; newPent.indices[4] = newVIndex0; - + M3rDraw_Pent( &newPent); } return; - } - /* else all are in */ - } - } + } + /* else all are in */ + } + } } } } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Clip.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Clip.h index eb4e56a..e88f3b3 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Clip.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Clip.h @@ -1,12 +1,12 @@ /* FILE: MS_Geom_Clip.h - + AUTHOR: Brent H. Pease - + CREATED: May 21, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 @@ -50,75 +50,75 @@ MSrClip_Quad( void MSrClip_ComputeVertex_TextureInterpolate( UUtUns32 inClipPlane, - + UUtUns32 inVIndexIn0, UUtUns32 inVIndexOut0, UUtUns32 inVIndexNew0, - + UUtUns32 inVIndexIn1, UUtUns32 inVIndexOut1, UUtUns32 inVIndexNew1, - + UUtUns8 *outClipCodeNew0, UUtUns8 *outClipCodeNew1); void MSrClip_ComputeVertex_TextureEnvInterpolate( UUtUns32 inClipPlane, - + UUtUns32 inVIndexIn0, UUtUns32 inVIndexOut0, UUtUns32 inVIndexNew0, - + UUtUns32 inVIndexIn1, UUtUns32 inVIndexOut1, UUtUns32 inVIndexNew1, - + UUtUns8 *outClipCodeNew0, UUtUns8 *outClipCodeNew1); void MSrClip_ComputeVertex_GouraudInterpolate( UUtUns32 inClipPlane, - + UUtUns32 inVIndexIn0, UUtUns32 inVIndexOut0, UUtUns32 inVIndexNew0, - + UUtUns32 inVIndexIn1, UUtUns32 inVIndexOut1, UUtUns32 inVIndexNew1, - + UUtUns8 *outClipCodeNew0, UUtUns8 *outClipCodeNew1); void MSrClip_ComputeVertex_TextureFlat( UUtUns32 inClipPlane, - + UUtUns32 inVIndexIn0, UUtUns32 inVIndexOut0, UUtUns32 inVIndexNew0, - + UUtUns32 inVIndexIn1, UUtUns32 inVIndexOut1, UUtUns32 inVIndexNew1, - + UUtUns8 *outClipCodeNew0, UUtUns8 *outClipCodeNew1); void MSrClip_ComputeVertex_GouraudFlat( UUtUns32 inClipPlane, - + UUtUns32 inVIndexIn0, UUtUns32 inVIndexOut0, UUtUns32 inVIndexNew0, - + UUtUns32 inVIndexIn1, UUtUns32 inVIndexOut1, UUtUns32 inVIndexNew1, - + UUtUns8 *outClipCodeNew0, UUtUns8 *outClipCodeNew1); @@ -129,7 +129,7 @@ MSrClip_ComputeVertex_LineFlat( UUtUns32 inVIndexOut, UUtUns32 inVIndexNew, UUtUns8 *outClipCodeNew); - + #endif diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade.c index be04e71..cf3ce3c 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade.c @@ -1,12 +1,12 @@ /* FILE: MS_Geom_Shade.c - + AUTHOR: Brent H. Pease - + CREATED: May 21, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -34,7 +34,7 @@ iComputeShade_Face( float inBaseR, float inBaseG, float inBaseB); - + void MSrShade_Vertices_Gouraud( @@ -44,27 +44,27 @@ MSrShade_Vertices_Gouraud( UUtUns32* inResultScreenShades) { UUtUns16 i; - + M3tPoint3D* curPoint = inWorldPoints; M3tVector3D* curNormal = inWorldVertexNormals; UUtUns32* curScreenShade = inResultScreenShades; UUtBool environmentMapping; M3tTextureCoord* curEnvMapCoord = NULL; M3tPoint3D* cameraLocation; - + cameraLocation = &MSgGeomContextPrivate->visCamera->cameraLocation; - + environmentMapping = (inGeometry->baseMap->flags & M3cTextureFlags_ReceivesEnvMap) != 0; - + MSgGeomContextPrivate->numDebugEnvMap = 0; UUmAssert(NULL != curPoint); - + if(0 || environmentMapping) { curEnvMapCoord = MSgGeomContextPrivate->envMapCoords; } - + if ((inGeometry->geometryFlags & M3cGeometryFlag_SelfIlluminent) || (inGeometry->baseMap->flags & M3cTextureFlags_SelfIlluminent)) { for(i = 0; i < inGeometry->pointArray->numPoints; i++) @@ -72,12 +72,12 @@ MSrShade_Vertices_Gouraud( *curScreenShade++ = 0xFFFFFFF; } } - else - { + else + { for(i = 0; i < inGeometry->pointArray->numPoints; i++) { *curScreenShade = iComputeShade(curPoint, curNormal, cameraLocation, curEnvMapCoord); - + curPoint++; curNormal++; curScreenShade++; @@ -95,29 +95,29 @@ MSrShade_Vertices_GouraudActive( UUtUns32* inActiveVerticesBV) { UUtUns32 i; - + M3tPoint3D* curPoint = inWorldPoints; M3tVector3D* curNormal = inWorldVertexNormals; UUtUns32* curScreenShade = inResultScreenShades; UUtBool environmentMapping; M3tTextureCoord* curEnvMapCoord = NULL; M3tPoint3D* cameraLocation; - + UUmAssertReadPtr(MSgGeomContextPrivate->visCamera, sizeof(*MSgGeomContextPrivate->visCamera)); UUmAssertReadPtr(MSgGeomContextPrivate, sizeof(*MSgGeomContextPrivate)); cameraLocation = &MSgGeomContextPrivate->visCamera->cameraLocation; - - + + environmentMapping = (inGeometry->baseMap->flags & M3cTextureFlags_ReceivesEnvMap) != 0; - + if(0 || environmentMapping) { curEnvMapCoord = MSgGeomContextPrivate->envMapCoords; } - + UUmAssert(NULL != curPoint); - + if ((inGeometry->geometryFlags & M3cGeometryFlag_SelfIlluminent) || (inGeometry->baseMap->flags & M3cTextureFlags_SelfIlluminent)) { for(i = 0; i < inGeometry->pointArray->numPoints; i++) @@ -231,7 +231,7 @@ MSrShade_Vertices_GouraudActive( } } } - else + else { UUtUns32 numPoints = inGeometry->pointArray->numPoints; @@ -241,7 +241,7 @@ MSrShade_Vertices_GouraudActive( { *curScreenShade = iComputeShade(curPoint, curNormal, cameraLocation, curEnvMapCoord); } - + curPoint++; curNormal++; curScreenShade++; @@ -369,12 +369,12 @@ MSrShade_Faces_Gouraud( UUtUns32* inResultFaceScreenShades) { UUtUns32 i; - + M3tVector3D* curFaceNormal; - UUtUns32* curFaceScreenShade; + UUtUns32* curFaceScreenShade; UUtUns16 count = 0; UUtUns16 stripIndexCount = 2; - + curFaceNormal = inWorldFaceNormals; curFaceScreenShade = inResultFaceScreenShades; @@ -385,8 +385,8 @@ MSrShade_Faces_Gouraud( *curFaceScreenShade++ = 0xFFFFFFF; } } - else - { + else + { for(i = 0; i < inNumFaces; i++) { if(inGeometry->triStripArray->indices[stripIndexCount++] & 0x80000000) @@ -395,14 +395,14 @@ MSrShade_Faces_Gouraud( if(count >= 32) count = 0; stripIndexCount += 2; } - + *curFaceScreenShade = iComputeShade_Face( curFaceNormal, gRTable[count], gGTable[count], gBTable[count]); - + curFaceNormal++; curFaceScreenShade++; } @@ -521,18 +521,18 @@ iComputeShade( //float inverseDistance, distanceSquared; MStLight_Directional* curDirectionalLight; //M3tLight_Point* curPointLight; - + UUtUns32 outShade; float normalX, normalY, normalZ; - + normalX = inNormal->x; normalY = inNormal->y; normalZ = inNormal->z; - + curR = MSgGeomContextPrivate->light_Ambient.color.r; curG = MSgGeomContextPrivate->light_Ambient.color.g; curB = MSgGeomContextPrivate->light_Ambient.color.b; - + // compute reflection vector if needed if(inEnvMapCoord != NULL) { @@ -541,7 +541,7 @@ iComputeShade( float one_over_magnitude; - // incident = world_points - view->position + // incident = world_points - view->position MUmVector_Subtract(incident, *inPoint, *inCameraLocation); reflect_vector3d(&incident, inNormal, &reflection); @@ -549,7 +549,7 @@ iComputeShade( inEnvMapCoord->u= 0.5f + reflection.x*one_over_magnitude; inEnvMapCoord->v= 0.5f + reflection.y*one_over_magnitude; } - + // directional for(itr = 0, curDirectionalLight = MSgGeomContextPrivate->light_DirectionalList; itr < MSgGeomContextPrivate->light_NumDirectionalLights; @@ -564,7 +564,7 @@ iComputeShade( lightZ = -curDirectionalLight->normalizedDirection.z; dotProduct = normalX * lightX + normalY * lightY + normalZ * lightZ; - + if (dotProduct > 0.0f) { curR += dotProduct * curDirectionalLight->color.r; @@ -572,7 +572,7 @@ iComputeShade( curB += dotProduct * curDirectionalLight->color.b; } } - + // turn color into a shade UUmAssert(curR >= 0.f); UUmAssert(curG >= 0.f); @@ -608,19 +608,19 @@ iComputeShade_Face( //float inverseDistance, distanceSquared; MStLight_Directional* curDirectionalLight; //M3tLight_Point* curPointLight; - + UUtUns32 outShade; float normalX, normalY, normalZ; - + normalX = inNormal->x; normalY = inNormal->y; normalZ = inNormal->z; - + curR = MSgGeomContextPrivate->light_Ambient.color.r; curG = MSgGeomContextPrivate->light_Ambient.color.g; curB = MSgGeomContextPrivate->light_Ambient.color.b; - - + + // directional for(itr = 0, curDirectionalLight = MSgGeomContextPrivate->light_DirectionalList; itr < MSgGeomContextPrivate->light_NumDirectionalLights; @@ -635,7 +635,7 @@ iComputeShade_Face( lightZ = -curDirectionalLight->normalizedDirection.z; dotProduct = normalX * lightX + normalY * lightY + normalZ * lightZ; - + if (dotProduct > 0.0f) { curR += dotProduct * curDirectionalLight->color.r; @@ -657,24 +657,24 @@ iComputeShade_Face( lightX = curPointLight->location.x - pointX; lightY = curPointLight->location.y - pointY; lightZ = curPointLight->location.z - pointZ; - + distanceSquared = UUmSQR(lightX) + UUmSQR(lightY) + UUmSQR(lightZ); if (0 == distanceSquared) continue; inverseDistance = MUrOneOverSqrt(distanceSquared); - + lightX *= inverseDistance; lightY *= inverseDistance; lightZ *= inverseDistance; - + dotProduct = normalX * lightX + normalY * lightY + normalZ * lightZ; - if (dotProduct > 0.0f) + if (dotProduct > 0.0f) { attenuation = curPointLight->a * inverseDistance * inverseDistance; attenuation += curPointLight->b * inverseDistance; attenuation += curPointLight->c; - + dotProduct *= attenuation; curR += dotProduct * curPointLight->color.r; curG += dotProduct * curPointLight->color.g; @@ -682,16 +682,16 @@ iComputeShade_Face( } } #endif - + // turn color into a shade UUmAssert(curR >= 0.f); UUmAssert(curG >= 0.f); UUmAssert(curB >= 0.f); - + curR = inBaseR; curG = inBaseG; curB = inBaseB; - + intR = (UUtUns8) MUrUnsignedSmallFloat_To_Uns_Round(UUmMin(curR * 255.0f, 255.0f)); intG = (UUtUns8) MUrUnsignedSmallFloat_To_Uns_Round(UUmMin(curG * 255.0f, 255.0f)); intB = (UUtUns8) MUrUnsignedSmallFloat_To_Uns_Round(UUmMin(curB * 255.0f, 255.0f)); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade.h index 7de9d56..93d9efe 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade.h @@ -1,12 +1,12 @@ /* FILE: MS_Geom_Shade.h - + AUTHOR: Brent H. Pease - + CREATED: May 21, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade_AltiVec.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade_AltiVec.c index bf83956..768e59c 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade_AltiVec.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade_AltiVec.c @@ -1,12 +1,12 @@ /* FILE: MS_Geom_Shade_AltiVec.c - + AUTHOR: Brent H. Pease - + CREATED: Aug. 4, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -35,60 +35,60 @@ MSrShade_Vertices_Gouraud_Directional_AltiVec( { UUtInt16 itr; UUtUns16 numVertices; - + vector float* curNormal; vector float nXXXX, nYYYY, nZZZZ; - + vector float rrrr, gggg, bbbb; - + vector float splatAmbientR, splatAmbientG, splatAmbientB; - + vector float splatDir0X, splatDir0Y, splatDir0Z; vector float splatDir0R, splatDir0G, splatDir0B; vector float splatDir1X, splatDir1Y, splatDir1Z; vector float splatDir1R, splatDir1G, splatDir1B; - + const vector float splatZero = AVcSplatZero; const vector float oneMinusEpsilon = AVcSplatOneMinusEpsilon; vector float dot; vector bool int selectVec; - + vector float vecR, vecG, vecB; - + vector unsigned long dRRRR, dGGGG, dBBBB; - + UUtUns32 blockDescNormal, blockDescShades; UUtInt32 numItrs; // 0 0 0 R1 | 0 0 0 R2 | 0 0 0 R3 | 0 0 0 R4 <- 0 // 0 1 2 3 | 4 5 6 7 | 8 9 A B | C D E F - + // 0 0 0 G1 | 0 0 0 G2 | 0 0 0 G3 | 0 0 0 G4 <- 1 // 0 1 2 3 | 4 5 6 7 | 8 9 A B | C D E F - + // 0 R1 G1 0 | 0 R2 G2 0 | 0 R3 G3 0 | 0 R4 G4 0 <- result - + // 00 03 13 00 | 00 07 17 00 | 00 0B 1B 00 | 00 0F 1F 00 const vector unsigned char perm0 = (vector unsigned char) (0x00, 0x03, 0x13, 0x00, 0x00, 0x07, 0x17, 0x00, 0x00, 0x0B, 0x1B, 0x00, 0x00, 0x0F, 0x1F, 0x00); - + // 0 R1 G1 0 | 0 R2 G2 0 | 0 R3 G3 0 | 0 R4 G4 0 <- 0 // 0 1 2 3 | 4 5 6 7 | 8 9 A B | C D E F - + // 0 0 0 B1 | 0 0 0 B2 | 0 0 0 B3 | 0 0 0 B4 <- 1 // 0 1 2 3 | 4 5 6 7 | 8 9 A B | C D E F - + // 0 R1 G1 B1 | 0 R2 G2 B2 | 0 R3 G3 B3 | 0 R4 G4 B4 <- result - + // 00 01 02 13 | 04 05 06 17 | 08 08 0A 1B | 0C 0D 0E 1D const vector unsigned char perm1 = (vector unsigned char) (0x00, 0x01, 0x02, 0x13, 0x04, 0x05, 0x06, 0x17, 0x08, 0x09, 0x0A, 0x1B, 0x0C, 0x0D, 0x0E, 0x1F); - + vector unsigned long* shadeVector; - + numVertices = inGeometry->pointArray->numPoints; - + if(inGeometry->geometryFlags & M3cGeometryFlag_SelfIlluminent) { for(itr = 0; itr < numVertices; itr++) @@ -97,9 +97,9 @@ MSrShade_Vertices_Gouraud_Directional_AltiVec( } return; } - + numItrs = (numVertices + 3) >> 2; - + blockDescNormal = AVmBuildBlockDST(3, numItrs, 3); blockDescShades = AVmBuildBlockDST(1, numItrs, 1); @@ -107,14 +107,14 @@ MSrShade_Vertices_Gouraud_Directional_AltiVec( vec_dstst((vector unsigned long *)outShades, blockDescShades, 1); UUmAssert(MSgGeomContextPrivate->light_NumDirectionalLights == 2); - + *(float*)&splatAmbientR = MSgGeomContextPrivate->light_Ambient.color.r; *(float*)&splatAmbientG = MSgGeomContextPrivate->light_Ambient.color.g; *(float*)&splatAmbientB = MSgGeomContextPrivate->light_Ambient.color.b; splatAmbientR = vec_splat(splatAmbientR, 0); splatAmbientG = vec_splat(splatAmbientG, 0); splatAmbientB = vec_splat(splatAmbientB, 0); - + *(float*)&splatDir0X = -MSgGeomContextPrivate->light_DirectionalList[0].normalizedDirection.x; *(float*)&splatDir0Y = -MSgGeomContextPrivate->light_DirectionalList[0].normalizedDirection.y; *(float*)&splatDir0Z = -MSgGeomContextPrivate->light_DirectionalList[0].normalizedDirection.z; @@ -127,7 +127,7 @@ MSrShade_Vertices_Gouraud_Directional_AltiVec( splatDir0R = vec_splat(splatDir0R, 0); splatDir0G = vec_splat(splatDir0G, 0); splatDir0B = vec_splat(splatDir0B, 0); - + *(float*)&splatDir1X = -MSgGeomContextPrivate->light_DirectionalList[1].normalizedDirection.x; *(float*)&splatDir1Y = -MSgGeomContextPrivate->light_DirectionalList[1].normalizedDirection.y; *(float*)&splatDir1Z = -MSgGeomContextPrivate->light_DirectionalList[1].normalizedDirection.z; @@ -140,74 +140,74 @@ MSrShade_Vertices_Gouraud_Directional_AltiVec( splatDir1R = vec_splat(splatDir1R, 0); splatDir1G = vec_splat(splatDir1G, 0); splatDir1B = vec_splat(splatDir1B, 0); - + curNormal = (vector float*)inWorldVertexNormals; shadeVector = (vector unsigned long*)outShades; - + for(itr = 0; itr < numItrs; itr++, curNormal += 3, shadeVector++) { if((itr & 0x3) == 0) UUrProcessor_ZeroCacheLine(shadeVector, 0); - + nXXXX = curNormal[0]; nYYYY = curNormal[1]; nZZZZ = curNormal[2]; - + rrrr = splatAmbientR; gggg = splatAmbientG; bbbb = splatAmbientB; - + // do dir light 0 dot = vec_madd(nXXXX, splatDir0X, splatZero); dot = vec_madd(nYYYY, splatDir0Y, dot); dot = vec_madd(nZZZZ, splatDir0Z, dot); - + selectVec = vec_cmpgt(dot, splatZero); - + vecR = vec_madd(dot, splatDir0R, splatZero); vecG = vec_madd(dot, splatDir0G, splatZero); vecB = vec_madd(dot, splatDir0B, splatZero); - + vecR = vec_sel(splatZero, vecR, selectVec); vecG = vec_sel(splatZero, vecG, selectVec); vecB = vec_sel(splatZero, vecB, selectVec); - + rrrr = vec_add(rrrr, vecR); gggg = vec_add(gggg, vecG); bbbb = vec_add(bbbb, vecB); - + // do dir light 1 dot = vec_madd(nXXXX, splatDir1X, splatZero); dot = vec_madd(nYYYY, splatDir1Y, dot); dot = vec_madd(nZZZZ, splatDir1Z, dot); - + selectVec = vec_cmpgt(dot, splatZero); - + vecR = vec_madd(dot, splatDir1R, splatZero); vecG = vec_madd(dot, splatDir1G, splatZero); vecB = vec_madd(dot, splatDir1B, splatZero); - + vecR = vec_sel(splatZero, vecR, selectVec); vecG = vec_sel(splatZero, vecG, selectVec); vecB = vec_sel(splatZero, vecB, selectVec); - + rrrr = vec_add(rrrr, vecR); gggg = vec_add(gggg, vecG); bbbb = vec_add(bbbb, vecB); - + // cap at one rrrr = vec_min(rrrr, oneMinusEpsilon); gggg = vec_min(gggg, oneMinusEpsilon); bbbb = vec_min(bbbb, oneMinusEpsilon); - + // convert to int dRRRR = vec_ctu(rrrr, 8); dGGGG = vec_ctu(gggg, 8); dBBBB = vec_ctu(bbbb, 8); - + // permute into 0RGB 0RGB 0RGB 0RGB dRRRR = vec_perm(dRRRR, dGGGG, perm0); dRRRR = vec_perm(dRRRR, dBBBB, perm1); - + *shadeVector = dRRRR; } @@ -224,60 +224,60 @@ MSrShade_Vertices_Gouraud_Directional_Active_AltiVec( { UUtInt16 itr; UUtUns16 numVertices; - + vector float* curNormal; vector float nXXXX, nYYYY, nZZZZ; - + vector float rrrr, gggg, bbbb; - + vector float splatAmbientR, splatAmbientG, splatAmbientB; - + vector float splatDir0X, splatDir0Y, splatDir0Z; vector float splatDir0R, splatDir0G, splatDir0B; vector float splatDir1X, splatDir1Y, splatDir1Z; vector float splatDir1R, splatDir1G, splatDir1B; - + const vector float splatZero = AVcSplatZero; const vector float oneMinusEpsilon = AVcSplatOneMinusEpsilon; vector float dot; vector bool int selectVec; - + vector float vecR, vecG, vecB; - + vector unsigned long dRRRR, dGGGG, dBBBB; - + UUtUns32 blockDescNormal, blockDescShades; UUtInt32 numItrs; // 0 0 0 R1 | 0 0 0 R2 | 0 0 0 R3 | 0 0 0 R4 <- 0 // 0 1 2 3 | 4 5 6 7 | 8 9 A B | C D E F - + // 0 0 0 G1 | 0 0 0 G2 | 0 0 0 G3 | 0 0 0 G4 <- 1 // 0 1 2 3 | 4 5 6 7 | 8 9 A B | C D E F - + // 0 R1 G1 0 | 0 R2 G2 0 | 0 R3 G3 0 | 0 R4 G4 0 <- result - + // 00 03 13 00 | 00 07 17 00 | 00 0B 1B 00 | 00 0F 1F 00 const vector unsigned char perm0 = (vector unsigned char) (0x00, 0x03, 0x13, 0x00, 0x00, 0x07, 0x17, 0x00, 0x00, 0x0B, 0x1B, 0x00, 0x00, 0x0F, 0x1F, 0x00); - + // 0 R1 G1 0 | 0 R2 G2 0 | 0 R3 G3 0 | 0 R4 G4 0 <- 0 // 0 1 2 3 | 4 5 6 7 | 8 9 A B | C D E F - + // 0 0 0 B1 | 0 0 0 B2 | 0 0 0 B3 | 0 0 0 B4 <- 1 // 0 1 2 3 | 4 5 6 7 | 8 9 A B | C D E F - + // 0 R1 G1 B1 | 0 R2 G2 B2 | 0 R3 G3 B3 | 0 R4 G4 B4 <- result - + // 00 01 02 13 | 04 05 06 17 | 08 08 0A 1B | 0C 0D 0E 1D const vector unsigned char perm1 = (vector unsigned char) (0x00, 0x01, 0x02, 0x13, 0x04, 0x05, 0x06, 0x17, 0x08, 0x09, 0x0A, 0x1B, 0x0C, 0x0D, 0x0E, 0x1F); - + vector unsigned long* shadeVector; - + numVertices = inGeometry->pointArray->numPoints; - + if(inGeometry->geometryFlags & M3cGeometryFlag_SelfIlluminent) { for(itr = 0; itr < numVertices; itr++) @@ -286,9 +286,9 @@ MSrShade_Vertices_Gouraud_Directional_Active_AltiVec( } return; } - + numItrs = (numVertices + 3) >> 2; - + blockDescNormal = AVmBuildBlockDST(3, numItrs, 3); blockDescShades = AVmBuildBlockDST(1, numItrs, 1); @@ -296,14 +296,14 @@ MSrShade_Vertices_Gouraud_Directional_Active_AltiVec( vec_dstst((vector unsigned long *)outShades, blockDescShades, 1); UUmAssert(MSgGeomContextPrivate->light_NumDirectionalLights == 2); - + *(float*)&splatAmbientR = MSgGeomContextPrivate->light_Ambient.color.r; *(float*)&splatAmbientG = MSgGeomContextPrivate->light_Ambient.color.g; *(float*)&splatAmbientB = MSgGeomContextPrivate->light_Ambient.color.b; splatAmbientR = vec_splat(splatAmbientR, 0); splatAmbientG = vec_splat(splatAmbientG, 0); splatAmbientB = vec_splat(splatAmbientB, 0); - + *(float*)&splatDir0X = -MSgGeomContextPrivate->light_DirectionalList[0].normalizedDirection.x; *(float*)&splatDir0Y = -MSgGeomContextPrivate->light_DirectionalList[0].normalizedDirection.y; *(float*)&splatDir0Z = -MSgGeomContextPrivate->light_DirectionalList[0].normalizedDirection.z; @@ -316,7 +316,7 @@ MSrShade_Vertices_Gouraud_Directional_Active_AltiVec( splatDir0R = vec_splat(splatDir0R, 0); splatDir0G = vec_splat(splatDir0G, 0); splatDir0B = vec_splat(splatDir0B, 0); - + *(float*)&splatDir1X = -MSgGeomContextPrivate->light_DirectionalList[1].normalizedDirection.x; *(float*)&splatDir1Y = -MSgGeomContextPrivate->light_DirectionalList[1].normalizedDirection.y; *(float*)&splatDir1Z = -MSgGeomContextPrivate->light_DirectionalList[1].normalizedDirection.z; @@ -329,76 +329,76 @@ MSrShade_Vertices_Gouraud_Directional_Active_AltiVec( splatDir1R = vec_splat(splatDir1R, 0); splatDir1G = vec_splat(splatDir1G, 0); splatDir1B = vec_splat(splatDir1B, 0); - + curNormal = (vector float*)inWorldVertexNormals; shadeVector = (vector unsigned long*)outShades; - + for(itr = 0; itr < numItrs; itr++, curNormal += 3, shadeVector++) { if((itr & 0x3) == 0) UUrProcessor_ZeroCacheLine(shadeVector, 0); - + if(!UUrBitVector_TestBitRange(inActiveVerticesBV, itr * 4, itr * 4 + 3)) continue; nXXXX = curNormal[0]; nYYYY = curNormal[1]; nZZZZ = curNormal[2]; - + rrrr = splatAmbientR; gggg = splatAmbientG; bbbb = splatAmbientB; - + // do dir light 0 dot = vec_madd(nXXXX, splatDir0X, splatZero); dot = vec_madd(nYYYY, splatDir0Y, dot); dot = vec_madd(nZZZZ, splatDir0Z, dot); - + selectVec = vec_cmpgt(dot, splatZero); - + vecR = vec_madd(dot, splatDir0R, splatZero); vecG = vec_madd(dot, splatDir0G, splatZero); vecB = vec_madd(dot, splatDir0B, splatZero); - + vecR = vec_sel(splatZero, vecR, selectVec); vecG = vec_sel(splatZero, vecG, selectVec); vecB = vec_sel(splatZero, vecB, selectVec); - + rrrr = vec_add(rrrr, vecR); gggg = vec_add(gggg, vecG); bbbb = vec_add(bbbb, vecB); - + // do dir light 1 dot = vec_madd(nXXXX, splatDir1X, splatZero); dot = vec_madd(nYYYY, splatDir1Y, dot); dot = vec_madd(nZZZZ, splatDir1Z, dot); - + selectVec = vec_cmpgt(dot, splatZero); - + vecR = vec_madd(dot, splatDir1R, splatZero); vecG = vec_madd(dot, splatDir1G, splatZero); vecB = vec_madd(dot, splatDir1B, splatZero); - + vecR = vec_sel(splatZero, vecR, selectVec); vecG = vec_sel(splatZero, vecG, selectVec); vecB = vec_sel(splatZero, vecB, selectVec); - + rrrr = vec_add(rrrr, vecR); gggg = vec_add(gggg, vecG); bbbb = vec_add(bbbb, vecB); - + // cap at one rrrr = vec_min(rrrr, oneMinusEpsilon); gggg = vec_min(gggg, oneMinusEpsilon); bbbb = vec_min(bbbb, oneMinusEpsilon); - + // convert to int dRRRR = vec_ctu(rrrr, 8); dGGGG = vec_ctu(gggg, 8); dBBBB = vec_ctu(bbbb, 8); - + // permute into 0RGB 0RGB 0RGB 0RGB dRRRR = vec_perm(dRRRR, dGGGG, perm0); dRRRR = vec_perm(dRRRR, dBBBB, perm1); - + *shadeVector = dRRRR; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade_AltiVec.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade_AltiVec.h index 760936b..81912e4 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade_AltiVec.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Shade_AltiVec.h @@ -1,12 +1,12 @@ /* FILE: MS_Geom_Shade_AltiVec.h - + AUTHOR: Brent H. Pease - + CREATED: Aug. 4, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform.c index a017ed7..21ff092 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform.c @@ -1,12 +1,12 @@ /* FILE: MS_Geom_Transform.c - + AUTHOR: Brent H. Pease - + CREATED: May 21, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -35,23 +35,23 @@ MSrTransform_PointListToFrustumScreen( float m01, m11, m21, m31; float m02, m12, m22, m32; float m03, m13, m23, m33; - + float iX, iY, iZ; float hX, hY, hZ, hW; float invW, negW; float scaleX, scaleY; - + const M3tPoint3D* curLocalPoint = inPointList; M3tPointScreen* curScreenPoint = outScreenPoints; M3tPoint4D* curFrustumPoint = outFrustumPoints; - + UUtUns8* curClipCodePtr = outClipCodeList; UUtUns8 curClipCodeValue; - + UUtUns8 clipCodeOR = 0; UUtUns8 clipCodeAND = (UUtUns8) ~0; UUtBool needs4DClipping = UUcFalse; - + UUmAssert(((unsigned long)inPointList & UUcProcessor_CacheLineSize_Mask) == 0); UUmAssert(((unsigned long)outScreenPoints & UUcProcessor_CacheLineSize_Mask) == 0); @@ -69,11 +69,11 @@ MSrTransform_PointListToFrustumScreen( { UUrProcessor_ZeroCacheLine(curScreenPoint, 0); UUrProcessor_ZeroCacheLine(curFrustumPoint, 0); - + iX = curLocalPoint->x; iY = curLocalPoint->y; iZ = curLocalPoint->z; - + MSmTransform_Local2FrustumInvW( iX, iY, iZ, hX, hY, hZ, hW, invW, @@ -81,44 +81,44 @@ MSrTransform_PointListToFrustumScreen( m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33); - + curFrustumPoint->x = hX; curFrustumPoint->y = hY; curFrustumPoint->z = hZ; curFrustumPoint->w = hW; negW = -hW; - + MSiVerifyPoint4D(curFrustumPoint); MSmTransform_FrustumClipTest(hX, hY, hZ, hW, negW, curClipCodeValue, needs4DClipping); - + // XXX - Might need another case where we don't do this for out of bounds verts MSmTransform_Frustum2Screen( curScreenPoint->x, curScreenPoint->y, curScreenPoint->z, curScreenPoint->invW, - hX, hY, hZ, invW, scaleX, scaleY); + hX, hY, hZ, invW, scaleX, scaleY); clipCodeOR |= curClipCodeValue; clipCodeAND &= curClipCodeValue; - + *curClipCodePtr = curClipCodeValue; - + if(i == 0 && (inNumVertices & 0x01)) { break; } - + curLocalPoint++; curScreenPoint++; curClipCodePtr++; curFrustumPoint++; - + iX = curLocalPoint->x; iY = curLocalPoint->y; iZ = curLocalPoint->z; - + MSmTransform_Local2FrustumInvW( iX, iY, iZ, hX, hY, hZ, hW, invW, @@ -126,36 +126,36 @@ MSrTransform_PointListToFrustumScreen( m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33); - + curFrustumPoint->x = hX; curFrustumPoint->y = hY; curFrustumPoint->z = hZ; curFrustumPoint->w = hW; negW = -hW; - + MSiVerifyPoint4D(curFrustumPoint); - + MSmTransform_FrustumClipTest(hX, hY, hZ, hW, negW, curClipCodeValue, needs4DClipping); - + // XXX - Might need another case where we don't do this for out of bounds verts MSmTransform_Frustum2Screen( curScreenPoint->x, curScreenPoint->y, curScreenPoint->z, curScreenPoint->invW, - hX, hY, hZ, invW, scaleX, scaleY); - + hX, hY, hZ, invW, scaleX, scaleY); + clipCodeOR |= curClipCodeValue; clipCodeAND &= curClipCodeValue; - + *curClipCodePtr = curClipCodeValue; - + curLocalPoint++; curScreenPoint++; curClipCodePtr++; curFrustumPoint++; } - + if (clipCodeAND != 0) { result = MScClipStatus_TrivialReject; @@ -164,7 +164,7 @@ MSrTransform_PointListToFrustumScreen( { result = MScClipStatus_NeedsClipping; } - else + else { result = MScClipStatus_TrivialAccept; } @@ -177,18 +177,18 @@ MSrTransform_UpdateMatrices( void) { M3tMatrix4x4 localToView; - + M3rCamera_GetActive((M3tGeomCamera**)&MSgGeomContextPrivate->activeCamera); - + M3rManager_Camera_UpdateMatrices(MSgGeomContextPrivate->activeCamera); - + M3rMatrixStack_Get(&MSgGeomContextPrivate->matrix_localToWorld); - + MUrMath_Matrix4x4Multiply4x3( &MSgGeomContextPrivate->activeCamera->matrix_worldToView, MSgGeomContextPrivate->matrix_localToWorld, &localToView); - + MUrMath_Matrix4x4Multiply( &MSgGeomContextPrivate->activeCamera->matrix_viewToFrustum, &localToView, @@ -205,21 +205,21 @@ MSrTransform_Geom_PointListToScreen( float m01, m11, m21, m31; float m02, m12, m22, m32; float m03, m13, m23, m33; - + float iX, iY, iZ; float hX, hY, hZ, hW; float invW; float scaleX, scaleY; - + M3tPoint3D* curLocalPoint = inGeometry->pointArray->points; M3tPointScreen* curScreenPoint = outResultScreenPoints; - + UUtUns32 numPoints = inGeometry->pointArray->numPoints; - + UUmAssert(inGeometry->pointArray->numPoints < M3cMaxObjVertices); UUmAssertReadPtr(inGeometry, sizeof(inGeometry)); UUmAssertReadPtr(outResultScreenPoints, sizeof(outResultScreenPoints)); - + UUmAssert(((unsigned long)curLocalPoint & UUcProcessor_CacheLineSize_Mask) == 0); UUmAssert(((unsigned long)outResultScreenPoints & UUcProcessor_CacheLineSize_Mask) == 0); @@ -232,7 +232,7 @@ MSrTransform_Geom_PointListToScreen( m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33); - + for(i = (UUtUns16) ((numPoints + 1) >> 1); i-- > 0;) { UUrProcessor_ZeroCacheLine(curScreenPoint, 0); @@ -240,7 +240,7 @@ MSrTransform_Geom_PointListToScreen( iX = curLocalPoint->x; iY = curLocalPoint->y; iZ = curLocalPoint->z; - + MSmTransform_Local2FrustumInvW( iX, iY, iZ, hX, hY, hZ, hW, invW, @@ -248,28 +248,28 @@ MSrTransform_Geom_PointListToScreen( m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33); - + MSmTransform_Frustum2Screen( curScreenPoint->x, curScreenPoint->y, curScreenPoint->z, curScreenPoint->invW, - hX, hY, hZ, invW, scaleX, scaleY); - + hX, hY, hZ, invW, scaleX, scaleY); + MSiVerifyPointScreen(curScreenPoint); - + if(i == 0 && (numPoints & 0x01)) { break; } - + curLocalPoint++; curScreenPoint++; - + iX = curLocalPoint->x; iY = curLocalPoint->y; iZ = curLocalPoint->z; - + MSmTransform_Local2FrustumInvW( iX, iY, iZ, hX, hY, hZ, hW, invW, @@ -277,14 +277,14 @@ MSrTransform_Geom_PointListToScreen( m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33); - + MSmTransform_Frustum2Screen( curScreenPoint->x, curScreenPoint->y, curScreenPoint->z, curScreenPoint->invW, - hX, hY, hZ, invW, scaleX, scaleY); - + hX, hY, hZ, invW, scaleX, scaleY); + MSiVerifyPointScreen(curScreenPoint); curLocalPoint++; @@ -304,7 +304,7 @@ MSrTransform_Geom_PointListToScreen_ActiveVertices( float m01, m11, m21, m31; float m02, m12, m22, m32; float m03, m13, m23, m33; - + float iX, iY, iZ; float hX, hY, hZ, hW; float invW; @@ -312,14 +312,14 @@ MSrTransform_Geom_PointListToScreen_ActiveVertices( M3tPoint3D* curLocalPoint = inGeometry->pointArray->points; M3tPointScreen* curScreenPoint = outResultScreenPoints; - + UUtUns32 numPoints = inGeometry->pointArray->numPoints; - + UUmAssert(inGeometry->pointArray->numPoints < M3cMaxObjVertices); UUmAssertReadPtr(inGeometry, sizeof(inGeometry)); UUmAssertReadPtr(outResultScreenPoints, sizeof(outResultScreenPoints)); UUmAssertReadPtr(inActiveVerticesBV, sizeof(inActiveVerticesBV)); - + UUmAssert(((unsigned long)curLocalPoint & UUcProcessor_CacheLineSize_Mask) == 0); UUmAssert(((unsigned long)curScreenPoint & UUcProcessor_CacheLineSize_Mask) == 0); @@ -332,20 +332,20 @@ MSrTransform_Geom_PointListToScreen_ActiveVertices( m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33); - + UUmBitVector_Loop_Begin(i, numPoints, inActiveVerticesBV) { if(!(i & 1)) { UUrProcessor_ZeroCacheLine(curScreenPoint, 0); } - + UUmBitVector_Loop_Test { iX = curLocalPoint->x; iY = curLocalPoint->y; iZ = curLocalPoint->z; - + MSmTransform_Local2FrustumInvW( iX, iY, iZ, hX, hY, hZ, hW, invW, @@ -353,17 +353,17 @@ MSrTransform_Geom_PointListToScreen_ActiveVertices( m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33); - + MSmTransform_Frustum2Screen( curScreenPoint->x, curScreenPoint->y, curScreenPoint->z, curScreenPoint->invW, - hX, hY, hZ, invW, scaleX, scaleY); - + hX, hY, hZ, invW, scaleX, scaleY); + MSiVerifyPointScreen(curScreenPoint); } - + curLocalPoint++; curScreenPoint++; } @@ -400,23 +400,23 @@ MSrTransform_Geom_PointListLocalToFrustumScreen_ActiveVertices( float m01, m11, m21, m31; float m02, m12, m22, m32; float m03, m13, m23, m33; - + float iX, iY, iZ; float hX, hY, hZ, hW; float invW, negW; float scaleX, scaleY; - + const M3tPoint3D* curLocalPoint = inGeometry->pointArray->points; M3tPointScreen* curScreenPoint = outScreenPoints; M3tPoint4D* curFrustumPoint = outFrustumPoints; - + UUtUns8* curClipCodePtr = outClipCodeList; UUtUns8 curClipCodeValue; - + UUtBool needs4DClipping = UUcFalse; - + UUtUns32 numPoints = inGeometry->pointArray->numPoints; - + UUmAssert(((unsigned long)curLocalPoint & UUcProcessor_CacheLineSize_Mask) == 0); UUmAssert(((unsigned long)curScreenPoint & UUcProcessor_CacheLineSize_Mask) == 0); @@ -437,13 +437,13 @@ MSrTransform_Geom_PointListLocalToFrustumScreen_ActiveVertices( UUrProcessor_ZeroCacheLine(curScreenPoint, 0); UUrProcessor_ZeroCacheLine(curFrustumPoint, 0); } - + UUmBitVector_Loop_Test { iX = curLocalPoint->x; iY = curLocalPoint->y; iZ = curLocalPoint->z; - + MSmTransform_Local2FrustumInvW( iX, iY, iZ, hX, hY, hZ, hW, invW, @@ -451,27 +451,27 @@ MSrTransform_Geom_PointListLocalToFrustumScreen_ActiveVertices( m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33); - + curFrustumPoint->x = hX; curFrustumPoint->y = hY; curFrustumPoint->z = hZ; curFrustumPoint->w = hW; negW = -hW; - + MSiVerifyPoint4D(curFrustumPoint); MSmTransform_FrustumClipTest(hX, hY, hZ, hW, negW, curClipCodeValue, needs4DClipping); - + MSmTransform_Frustum2Screen( curScreenPoint->x, curScreenPoint->y, curScreenPoint->z, curScreenPoint->invW, - hX, hY, hZ, invW, scaleX, scaleY); + hX, hY, hZ, invW, scaleX, scaleY); *curClipCodePtr = curClipCodeValue; } - + curLocalPoint++; curScreenPoint++; curClipCodePtr++; @@ -479,7 +479,7 @@ MSrTransform_Geom_PointListLocalToFrustumScreen_ActiveVertices( } UUmBitVector_Loop_End - + } @@ -492,38 +492,38 @@ MSrTransform_Geom_PointListAndVertexNormalToWorld( UUtInt32 i; UUtInt32 j; UUtUns32 block8; - + float m00, m10, m20, m30; float m01, m11, m21, m31; float m02, m12, m22, m32; - + float iX, iY, iZ; M3tPoint3D* curPoint = inGeometry->pointArray->points; M3tPoint3D* curWorldPoint = outResultWorldPoints; M3tVector3D* curVertexNormal = inGeometry->vertexNormalArray->vectors; M3tVector3D* curWorldVertexNormal = outResultWorldVertexNormals; - + M3tMatrix4x3* matrix3; - + UUtUns32 numPoints = inGeometry->pointArray->numPoints; - + UUmAssert(((unsigned long)curPoint & UUcProcessor_CacheLineSize_Mask) == 0); UUmAssert(((unsigned long)curWorldPoint & UUcProcessor_CacheLineSize_Mask) == 0); UUmAssert(((unsigned long)curVertexNormal & UUcProcessor_CacheLineSize_Mask) == 0); UUmAssert(((unsigned long)curWorldVertexNormal & UUcProcessor_CacheLineSize_Mask) == 0); - + matrix3 = MSgGeomContextPrivate->matrix_localToWorld; UUmAssertReadPtr(matrix3, sizeof(M3tMatrix4x3)); - + m00 = matrix3->m[0][0]; m01 = matrix3->m[0][1]; m02 = matrix3->m[0][2]; - + m10 = matrix3->m[1][0]; m11 = matrix3->m[1][1]; m12 = matrix3->m[1][2]; - + m20 = matrix3->m[2][0]; m21 = matrix3->m[2][1]; m22 = matrix3->m[2][2]; @@ -531,9 +531,9 @@ MSrTransform_Geom_PointListAndVertexNormalToWorld( m30 = matrix3->m[3][0]; m31 = matrix3->m[3][1]; m32 = matrix3->m[3][2]; - + block8 = (numPoints + 7) >> 3; - + for(i = block8; i-- > 0;) { UUrProcessor_ZeroCacheLine((char*)curWorldPoint, 0); @@ -542,57 +542,57 @@ MSrTransform_Geom_PointListAndVertexNormalToWorld( UUrProcessor_ZeroCacheLine((char*)curWorldVertexNormal, 0); UUrProcessor_ZeroCacheLine((char*)curWorldVertexNormal + UUcProcessor_CacheLineSize, 0); UUrProcessor_ZeroCacheLine((char*)curWorldVertexNormal + UUcProcessor_CacheLineSize * 2, 0); - + for(j = 0; j < 8; j++) { iX = curPoint->x; iY = curPoint->y; iZ = curPoint->z; - + curWorldPoint->x = m00 * iX + m10 * iY + m20 * iZ + m30; curWorldPoint->y = m01 * iX + m11 * iY + m21 * iZ + m31; curWorldPoint->z = m02 * iX + m12 * iY + m22 * iZ + m32; - + curPoint++; curWorldPoint++; iX = curVertexNormal->x; iY = curVertexNormal->y; iZ = curVertexNormal->z; - + curWorldVertexNormal->x = m00 * iX + m10 * iY + m20 * iZ; curWorldVertexNormal->y = m01 * iX + m11 * iY + m21 * iZ; curWorldVertexNormal->z = m02 * iX + m12 * iY + m22 * iZ; - + curVertexNormal++; curWorldVertexNormal++; } } - + UUrProcessor_ZeroCacheLine(curWorldPoint, 0); UUrProcessor_ZeroCacheLine(curWorldVertexNormal, 0); - + for(i = numPoints - (block8 * 8); i-- > 0;) { iX = curPoint->x; iY = curPoint->y; iZ = curPoint->z; - + curWorldPoint->x = m00 * iX + m10 * iY + m20 * iZ + m30; curWorldPoint->y = m01 * iX + m11 * iY + m21 * iZ + m31; curWorldPoint->z = m02 * iX + m12 * iY + m22 * iZ + m32; - + curPoint++; curWorldPoint++; iX = curVertexNormal->x; iY = curVertexNormal->y; iZ = curVertexNormal->z; - + curWorldVertexNormal->x = m00 * iX + m10 * iY + m20 * iZ; curWorldVertexNormal->y = m01 * iX + m11 * iY + m21 * iZ; curWorldVertexNormal->z = m02 * iX + m12 * iY + m22 * iZ; - + curVertexNormal++; curWorldVertexNormal++; } @@ -619,31 +619,31 @@ MSrTransform_Geom_FaceNormalToWorld( UUtInt32 i; UUtInt32 j; UUtUns32 block8; - + float m00, m10, m20, m30; float m01, m11, m21, m31; float m02, m12, m22, m32; - + float iX, iY, iZ; M3tVector3D *curVertexNormal; M3tVector3D *curWorldVertexNormal; - + M3tMatrix4x3* matrix3; - + UUtUns32 numVectors; - + matrix3 = MSgGeomContextPrivate->matrix_localToWorld; UUmAssertReadPtr(matrix3, sizeof(M3tMatrix4x3)); m00 = matrix3->m[0][0]; m01 = matrix3->m[0][1]; m02 = matrix3->m[0][2]; - + m10 = matrix3->m[1][0]; m11 = matrix3->m[1][1]; m12 = matrix3->m[1][2]; - + m20 = matrix3->m[2][0]; m21 = matrix3->m[2][1]; m22 = matrix3->m[2][2]; @@ -651,60 +651,60 @@ MSrTransform_Geom_FaceNormalToWorld( m30 = matrix3->m[3][0]; m31 = matrix3->m[3][1]; m32 = matrix3->m[3][2]; - + curVertexNormal = inGeometry->triNormalArray->vectors; curWorldVertexNormal = outResultWorldTriNormals; - + UUmAssert(((unsigned long)curVertexNormal & UUcProcessor_CacheLineSize_Mask) == 0); UUmAssert(((unsigned long)curWorldVertexNormal & UUcProcessor_CacheLineSize_Mask) == 0); numVectors = inGeometry->triNormalArray->numVectors; block8 = (numVectors + 7) >> 3; - + for(i = block8; i-- > 0;) { UUrProcessor_ZeroCacheLine((char*)curWorldVertexNormal, 0); UUrProcessor_ZeroCacheLine((char*)curWorldVertexNormal + UUcProcessor_CacheLineSize, 0); UUrProcessor_ZeroCacheLine((char*)curWorldVertexNormal + UUcProcessor_CacheLineSize * 2, 0); - + for(j = 0; j < 4; j++) { iX = curVertexNormal->x; iY = curVertexNormal->y; iZ = curVertexNormal->z; - + curWorldVertexNormal->x = m00 * iX + m10 * iY + m20 * iZ; curWorldVertexNormal->y = m01 * iX + m11 * iY + m21 * iZ; curWorldVertexNormal->z = m02 * iX + m12 * iY + m22 * iZ; - + curVertexNormal++; curWorldVertexNormal++; iX = curVertexNormal->x; iY = curVertexNormal->y; iZ = curVertexNormal->z; - + curWorldVertexNormal->x = m00 * iX + m10 * iY + m20 * iZ; curWorldVertexNormal->y = m01 * iX + m11 * iY + m21 * iZ; curWorldVertexNormal->z = m02 * iX + m12 * iY + m22 * iZ; - + curVertexNormal++; curWorldVertexNormal++; } } - + UUrProcessor_ZeroCacheLine(curWorldVertexNormal, 0); - + for(i = numVectors - (block8 * 8); i-- > 0;) { iX = curVertexNormal->x; iY = curVertexNormal->y; iZ = curVertexNormal->z; - + curWorldVertexNormal->x = m00 * iX + m10 * iY + m20 * iZ; curWorldVertexNormal->y = m01 * iX + m11 * iY + m21 * iZ; curWorldVertexNormal->z = m02 * iX + m12 * iY + m22 * iZ; - + curVertexNormal++; curWorldVertexNormal++; } @@ -717,7 +717,7 @@ MSrTransform_Geom_BoundingBoxToFrustumScreen( M3tPointScreen *outScreenPoints, UUtUns8 *outClipCodeList) { - + M3rMinMaxBBox_To_BBox(&inGeometry->pointArray->minmax_boundingBox, (M3tBoundingBox*)MSgGeomContextPrivate->worldPoints); return MSrTransform_PointListToFrustumScreen( @@ -739,36 +739,36 @@ MSrTransform_Geom_BoundingBoxClipStatus( float m01, m11, m21, m31; float m02, m12, m22, m32; float m03, m13, m23, m33; - + float iX, iY, iZ; float hX, hY, hZ, hW; float negW; - + M3tPoint3D* curLocalPoint; M3tBoundingBox bbox; - + UUtUns16 curClipCodeValue; - + UUtUns16 clipCodeOR = 0; UUtUns16 clipCodeAND = (UUtUns16) ~0; UUtBool needs4DClipping = UUcFalse; M3rMinMaxBBox_To_BBox(&inGeometry->pointArray->minmax_boundingBox, &bbox); curLocalPoint = bbox.localPoints; - + MSmTransform_Matrix4x4ToRegisters( MSgGeomContextPrivate->matrix_localToFrustum, m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33); - + for(i = 8; i-- > 0;) { iX = curLocalPoint->x; iY = curLocalPoint->y; iZ = curLocalPoint->z; - + MSmTransform_Local2FrustumNegW( iX, iY, iZ, hX, hY, hZ, hW, negW, @@ -776,15 +776,15 @@ MSrTransform_Geom_BoundingBoxClipStatus( m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33); - + MSmTransform_FrustumClipTest(hX, hY, hZ, hW, negW, curClipCodeValue, needs4DClipping); - + clipCodeOR |= curClipCodeValue; clipCodeAND &= curClipCodeValue; curLocalPoint++; } - + if (clipCodeAND != 0) { result = MScClipStatus_TrivialReject; @@ -793,7 +793,7 @@ MSrTransform_Geom_BoundingBoxClipStatus( { result = MScClipStatus_NeedsClipping; } - else + else { result = MScClipStatus_TrivialAccept; } @@ -813,25 +813,25 @@ MSrTransform_EnvPointListToFrustumScreen_ActiveVertices( float m01, m11, m21, m31; float m02, m12, m22, m32; float m03, m13, m23, m33; - + float iX, iY, iZ; float hX, hY, hZ, hW; float invW, negW; float scaleX, scaleY; - + const M3tPoint3D* worldPoints = MSgGeomContextPrivate->environment->pointArray->points; M3tPointScreen* screenPoints = outScreenPoints; M3tPoint4D* frustumPoints = outFrustumPoints; - + UUtUns8* clipCodePtrs = outClipCodeList; UUtUns32 curClipCodeValue; - + UUtUns32 clipCodeOR = 0; UUtUns32 clipCodeAND = ~0; UUtBool needs4DClipping = UUcFalse; - + UUtUns32 numPoints = MSgGeomContextPrivate->environment->pointArray->numPoints; - + scaleX = MSgGeomContextPrivate->scaleX; scaleY = MSgGeomContextPrivate->scaleY; @@ -848,7 +848,7 @@ MSrTransform_EnvPointListToFrustumScreen_ActiveVertices( iX = worldPoints[i].x; iY = worldPoints[i].y; iZ = worldPoints[i].z; - + MSmTransform_Local2FrustumInvW( iX, iY, iZ, hX, hY, hZ, hW, invW, @@ -856,23 +856,23 @@ MSrTransform_EnvPointListToFrustumScreen_ActiveVertices( m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33); - + frustumPoints[i].x = hX; frustumPoints[i].y = hY; frustumPoints[i].z = hZ; frustumPoints[i].w = hW; negW = -hW; - + MSiVerifyPoint4D(frustumPoints + i); MSmTransform_FrustumClipTest(hX, hY, hZ, hW, negW, curClipCodeValue, needs4DClipping); - + MSmTransform_Frustum2Screen( screenPoints[i].x, screenPoints[i].y, screenPoints[i].z, screenPoints[i].invW, - hX, hY, hZ, invW, scaleX, scaleY); + hX, hY, hZ, invW, scaleX, scaleY); clipCodePtrs[i] = (UUtUns8) curClipCodeValue; } @@ -898,7 +898,7 @@ MSrBackface_Remove( UUtUns32 numTris; UUtUns32* curIndexPtr; UUtUns32* triNormalIndices; - + //clX = MSgGeomContextPrivate->visCamera->cameraLocation.x; //clY = MSgGeomContextPrivate->visCamera->cameraLocation.y; //clZ = MSgGeomContextPrivate->visCamera->cameraLocation.z; @@ -909,25 +909,25 @@ MSrBackface_Remove( numTris = (UUtUns16)inGeometry->triNormalIndexArray->numIndices; triNormalIndices = inGeometry->triNormalIndexArray->indices; curIndexPtr = inGeometry->triStripArray->indices; - + for(i = 0; i < numTris; i++) { index2 = *curIndexPtr++; - + if(index2 & 0x80000000) { index0 = (index2 & 0x7FFFFFFF); index1 = *curIndexPtr++; index2 = *curIndexPtr++; } - + curPoint = inWorldPoints + index0; curNormal = inWorldTriNormals + triNormalIndices[i]; - + viewVectorX = clX - curPoint->x; viewVectorY = clY - curPoint->y; viewVectorZ = clZ - curPoint->z; - + if(viewVectorX * curNormal->x + viewVectorY * curNormal->y + viewVectorZ * curNormal->z >= 0) @@ -935,7 +935,7 @@ MSrBackface_Remove( UUrBitVector_SetBit( outActiveTrisBV, i); - + UUrBitVector_SetBit( outActiveVerticesBV, index0); @@ -946,7 +946,7 @@ MSrBackface_Remove( outActiveVerticesBV, index2); } - + index0 = index1; index1 = index2; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform.h index 9ec4cc2..acac3df 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform.h @@ -1,12 +1,12 @@ /* FILE: MS_Geom_Transform.h - + AUTHOR: Brent H. Pease - + CREATED: May 21, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform_AltiVec.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform_AltiVec.c index ca98cbe..1c52870 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform_AltiVec.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform_AltiVec.c @@ -1,12 +1,12 @@ /* FILE: MS_Geom_Transform_AltiVec.c - + AUTHOR: Brent H. Pease - + CREATED: May 21, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -33,26 +33,26 @@ MSrTransform_Geom_PointListToScreen_AltiVec( { M3tGeometry_Private* geomPrivate = (M3tGeometry_Private*)TMrTemplate_PrivateData_GetDataPtr(M3gTemplate_Geometry_PrivateData, inGeometry); UUtInt32 itr; - + vector float* mPtr; vector float* curPoint = (vector float*)geomPrivate->pointSIMD; vector float* curScreen = (vector float*)outResultScreenPoints; - + vector float tempRow0, tempRow1, tempRow2, tempRow3; - - + + vector float splatm00, splatm10, splatm20, splatm30; vector float splatm01, splatm11, splatm21, splatm31; vector float splatm02, splatm12, splatm22, splatm32; vector float splatm03, splatm13, splatm23, splatm33; - + vector float xxxx, yyyy, zzzz; - + vector float hXXXX, hYYYY, hZZZZ, hWWWW; vector float t1, t2; - + vector float splatScaleX, splatScaleY; - + const vector float zero = AVcSplatZero; const vector float one = AVcSplatOne; const vector float negOne = AVcSplatNegOne; @@ -63,91 +63,91 @@ MSrTransform_Geom_PointListToScreen_AltiVec( UUtUns32 blockDescPoint, blockDescScreen; UUtInt32 numItrs; - + UUmAssert(((UUtUns32)&MSgGeomContextPrivate->matrix_localToFrustum & 0xF) == 0); UUmAssert(((UUtUns32)curPoint & 0xF) == 0); UUmAssert(((UUtUns32)curScreen & 0xF) == 0); - + numItrs = (inGeometry->pointArray->numPoints + 3) >> 2; - + blockDescPoint = AVmBuildBlockDST(3, numItrs, 3); blockDescScreen = AVmBuildBlockDST(4, numItrs, 4); - + vec_dst((vector float *)curPoint, blockDescPoint, 0); vec_dstst((vector float *)curScreen, blockDescScreen, 1); - + mPtr = (vector float*)MSgGeomContextPrivate->matrix_localToFrustum.m; - + tempRow0 = mPtr[0]; tempRow1 = mPtr[1]; tempRow2 = mPtr[2]; tempRow3 = mPtr[3]; - + *(float *)&splatScaleX = MSgGeomContextPrivate->scaleX; *(float *)&splatScaleY = MSgGeomContextPrivate->scaleY; splatScaleX = vec_splat(splatScaleX, 0); splatScaleY = vec_splat(splatScaleY, 0); - + splatm00 = vec_splat(tempRow0, 0); splatm01 = vec_splat(tempRow0, 1); splatm02 = vec_splat(tempRow0, 2); splatm03 = vec_splat(tempRow0, 3); - + splatm10 = vec_splat(tempRow1, 0); splatm11 = vec_splat(tempRow1, 1); splatm12 = vec_splat(tempRow1, 2); splatm13 = vec_splat(tempRow1, 3); - + splatm20 = vec_splat(tempRow2, 0); splatm21 = vec_splat(tempRow2, 1); splatm22 = vec_splat(tempRow2, 2); splatm23 = vec_splat(tempRow2, 3); - + splatm30 = vec_splat(tempRow3, 0); splatm31 = vec_splat(tempRow3, 1); splatm32 = vec_splat(tempRow3, 2); splatm33 = vec_splat(tempRow3, 3); - + for(itr = 0; itr < numItrs; itr++, curPoint += 3, curScreen += 4) { if((itr & 1) == 0) UUrProcessor_ZeroCacheLine(curScreen, 0); - + xxxx = curPoint[0]; yyyy = curPoint[1]; zzzz = curPoint[2]; - + hXXXX = vec_madd(splatm00, xxxx, splatm30); hXXXX = vec_madd(splatm10, yyyy, hXXXX); hXXXX = vec_madd(splatm20, zzzz, hXXXX); - + hYYYY = vec_madd(splatm01, xxxx, splatm31); hYYYY = vec_madd(splatm11, yyyy, hYYYY); hYYYY = vec_madd(splatm21, zzzz, hYYYY); - + hZZZZ = vec_madd(splatm02, xxxx, splatm32); hZZZZ = vec_madd(splatm12, yyyy, hZZZZ); hZZZZ = vec_madd(splatm22, zzzz, hZZZZ); - + hWWWW = vec_madd(splatm03, xxxx, splatm33); hWWWW = vec_madd(splatm13, yyyy, hWWWW); hWWWW = vec_madd(splatm23, zzzz, hWWWW); - + t1 = vec_re(hWWWW); t2 = vec_nmsub(t1, hWWWW, one); hWWWW = vec_madd(t1, t2, t1); - + // hWWWW is now inv hWWWW - + hXXXX = vec_madd(hXXXX, hWWWW, one); hXXXX = vec_madd(hXXXX, splatScaleX, zero); - + hYYYY = vec_madd(hYYYY, hWWWW, negOne); hYYYY = vec_madd(hYYYY, splatScaleY, zero); - + hZZZZ = vec_madd(hZZZZ, hWWWW, zero); - + t1 = vec_perm(hXXXX, hYYYY, prl2Seq4x4_s0p0); t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p0); xxxx = vec_perm(t1, t2, prl2Seq4x4_s1p0); @@ -157,13 +157,13 @@ MSrTransform_Geom_PointListToScreen_AltiVec( t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p1); zzzz = vec_perm(t1, t2, prl2Seq4x4_s1p0); hWWWW = vec_perm(t1, t2, prl2Seq4x4_s1p1); - + curScreen[0] = xxxx; curScreen[1] = yyyy; curScreen[2] = zzzz; curScreen[3] = hWWWW; } - + //vec_dssall(); } @@ -175,26 +175,26 @@ MSrTransform_Geom_PointListToScreen_ActiveVertices_AltiVec( { M3tGeometry_Private* geomPrivate = (M3tGeometry_Private*)TMrTemplate_PrivateData_GetDataPtr(M3gTemplate_Geometry_PrivateData, inGeometry); UUtInt32 itr; - + vector float* mPtr; vector float* curPoint = (vector float*)geomPrivate->pointSIMD; vector float* curScreen = (vector float*)outResultScreenPoints; - + vector float tempRow0, tempRow1, tempRow2, tempRow3; - - + + vector float splatm00, splatm10, splatm20, splatm30; vector float splatm01, splatm11, splatm21, splatm31; vector float splatm02, splatm12, splatm22, splatm32; vector float splatm03, splatm13, splatm23, splatm33; - + vector float xxxx, yyyy, zzzz; - + vector float hXXXX, hYYYY, hZZZZ, hWWWW; vector float t1, t2; - + vector float splatScaleX, splatScaleY; - + const vector float zero = AVcSplatZero; const vector float one = AVcSplatOne; const vector float negOne = AVcSplatNegOne; @@ -205,93 +205,93 @@ MSrTransform_Geom_PointListToScreen_ActiveVertices_AltiVec( UUtUns32 blockDescPoint, blockDescScreen; UUtInt32 numItrs; - + UUmAssert(((UUtUns32)&MSgGeomContextPrivate->matrix_localToFrustum & 0xF) == 0); UUmAssert(((UUtUns32)curPoint & 0xF) == 0); UUmAssert(((UUtUns32)curScreen & 0xF) == 0); - + numItrs = (inGeometry->pointArray->numPoints + 3) >> 2; - + blockDescPoint = AVmBuildBlockDST(3, numItrs, 3); blockDescScreen = AVmBuildBlockDST(4, numItrs, 4); - + vec_dst((vector float *)curPoint, blockDescPoint, 0); vec_dstst((vector float *)curScreen, blockDescScreen, 1); - + mPtr = (vector float*)MSgGeomContextPrivate->matrix_localToFrustum.m; - + tempRow0 = mPtr[0]; tempRow1 = mPtr[1]; tempRow2 = mPtr[2]; tempRow3 = mPtr[3]; - + *(float *)&splatScaleX = MSgGeomContextPrivate->scaleX; *(float *)&splatScaleY = MSgGeomContextPrivate->scaleY; splatScaleX = vec_splat(splatScaleX, 0); splatScaleY = vec_splat(splatScaleY, 0); - + splatm00 = vec_splat(tempRow0, 0); splatm01 = vec_splat(tempRow0, 1); splatm02 = vec_splat(tempRow0, 2); splatm03 = vec_splat(tempRow0, 3); - + splatm10 = vec_splat(tempRow1, 0); splatm11 = vec_splat(tempRow1, 1); splatm12 = vec_splat(tempRow1, 2); splatm13 = vec_splat(tempRow1, 3); - + splatm20 = vec_splat(tempRow2, 0); splatm21 = vec_splat(tempRow2, 1); splatm22 = vec_splat(tempRow2, 2); splatm23 = vec_splat(tempRow2, 3); - + splatm30 = vec_splat(tempRow3, 0); splatm31 = vec_splat(tempRow3, 1); splatm32 = vec_splat(tempRow3, 2); splatm33 = vec_splat(tempRow3, 3); - + for(itr = 0; itr < numItrs; itr++, curPoint += 3, curScreen += 4) { if((itr & 1) == 0) UUrProcessor_ZeroCacheLine(curScreen, 0); - + if(!UUrBitVector_TestBitRange(inActiveVerticesBV, itr * 4, itr * 4 + 3)) continue; - + xxxx = curPoint[0]; yyyy = curPoint[1]; zzzz = curPoint[2]; - + hXXXX = vec_madd(splatm00, xxxx, splatm30); hXXXX = vec_madd(splatm10, yyyy, hXXXX); hXXXX = vec_madd(splatm20, zzzz, hXXXX); - + hYYYY = vec_madd(splatm01, xxxx, splatm31); hYYYY = vec_madd(splatm11, yyyy, hYYYY); hYYYY = vec_madd(splatm21, zzzz, hYYYY); - + hZZZZ = vec_madd(splatm02, xxxx, splatm32); hZZZZ = vec_madd(splatm12, yyyy, hZZZZ); hZZZZ = vec_madd(splatm22, zzzz, hZZZZ); - + hWWWW = vec_madd(splatm03, xxxx, splatm33); hWWWW = vec_madd(splatm13, yyyy, hWWWW); hWWWW = vec_madd(splatm23, zzzz, hWWWW); - + t1 = vec_re(hWWWW); t2 = vec_nmsub(t1, hWWWW, one); hWWWW = vec_madd(t1, t2, t1); - + // hWWWW is now inv hWWWW - + hXXXX = vec_madd(hXXXX, hWWWW, one); hXXXX = vec_madd(hXXXX, splatScaleX, zero); - + hYYYY = vec_madd(hYYYY, hWWWW, negOne); hYYYY = vec_madd(hYYYY, splatScaleY, zero); - + hZZZZ = vec_madd(hZZZZ, hWWWW, zero); - + t1 = vec_perm(hXXXX, hYYYY, prl2Seq4x4_s0p0); t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p0); xxxx = vec_perm(t1, t2, prl2Seq4x4_s1p0); @@ -301,13 +301,13 @@ MSrTransform_Geom_PointListToScreen_ActiveVertices_AltiVec( t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p1); zzzz = vec_perm(t1, t2, prl2Seq4x4_s1p0); hWWWW = vec_perm(t1, t2, prl2Seq4x4_s1p1); - + curScreen[0] = xxxx; curScreen[1] = yyyy; curScreen[2] = zzzz; curScreen[3] = hWWWW; } - + //vec_dssall(); } @@ -320,35 +320,35 @@ MSrTransform_Geom_PointListToFrustumScreen_AltiVec( { M3tGeometry_Private* geomPrivate = (M3tGeometry_Private*)TMrTemplate_PrivateData_GetDataPtr(M3gTemplate_Geometry_PrivateData, inGeometry); UUtInt32 itr; - + vector float* mPtr; vector float* curPoint = (vector float*)geomPrivate->pointSIMD; vector float* curScreen = (vector float*)outScreenPoints; vector float* curFrustum = (vector float*)outFrustumPoints; - + vector float tempRow0, tempRow1, tempRow2, tempRow3; - - + + vector float splatm00, splatm10, splatm20, splatm30; vector float splatm01, splatm11, splatm21, splatm31; vector float splatm02, splatm12, splatm22, splatm32; vector float splatm03, splatm13, splatm23, splatm33; - + vector float xxxx, yyyy, zzzz, wwww; - + vector float hXXXX, hYYYY, hZZZZ, hWWWW; vector float t1, t2; - + vector float splatScaleX, splatScaleY; vector float negwwww; - + vector unsigned int clipCodeXXXXPos, clipCodeYYYYPos, clipCodeZZZZPos; vector unsigned int clipCodeXXXXNeg, clipCodeYYYYNeg, clipCodeZZZZNeg; vector unsigned int clipCodeCum; vector unsigned int clipCode0123; vector unsigned char clipCode_lvsr; vector unsigned int mask; - + const vector float one = AVcSplatOne; const vector float negOne = AVcSplatNegOne; const vector unsigned char prl2Seq4x4_s0p0 = AVcPrl2Seq4x4_s0p0; @@ -361,63 +361,63 @@ MSrTransform_Geom_PointListToFrustumScreen_AltiVec( const vector unsigned int clipCodeY_mask = (const vector unsigned int)(3 << 2, 3 << 2, 3 << 2, 3 << 2); const vector unsigned int clipCodeZ_mask = (const vector unsigned int)(3 << 4, 3 << 4, 3 << 4, 3 << 4); const vector unsigned char clipCode_perm = (const vector unsigned char)(3, 7, 11, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - + const vector unsigned int splat_zero = (const vector unsigned int)(0, 0, 0, 0); const vector unsigned int splat_int_one = (const vector unsigned int)(1, 1, 1, 1); const vector unsigned int splat_int_allone = (const vector unsigned int)(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); - + UUtUns32 blockDescPoint, blockDescScreen; UUtInt32 numItrs; - + UUtUns32* clipCodePtr = (UUtUns32*)outClipCodeList; - + UUmAssert(((UUtUns32)&MSgGeomContextPrivate->matrix_localToFrustum & 0xF) == 0); UUmAssert(((UUtUns32)curPoint & 0xF) == 0); UUmAssert(((UUtUns32)curScreen & 0xF) == 0); UUmAssert(((UUtUns32)clipCodePtr & 0xF) == 0); - + numItrs = (inGeometry->pointArray->numPoints + 3) >> 2; - + blockDescPoint = AVmBuildBlockDST(3, numItrs, 3); blockDescScreen = AVmBuildBlockDST(4, numItrs, 4); - + vec_dst((vector float *)curPoint, blockDescPoint, 0); vec_dstst((vector float *)curScreen, blockDescScreen, 1); - + mPtr = (vector float*)MSgGeomContextPrivate->matrix_localToFrustum.m; - + tempRow0 = mPtr[0]; tempRow1 = mPtr[1]; tempRow2 = mPtr[2]; tempRow3 = mPtr[3]; - + *(float *)&splatScaleX = MSgGeomContextPrivate->scaleX; *(float *)&splatScaleY = MSgGeomContextPrivate->scaleY; splatScaleX = vec_splat(splatScaleX, 0); splatScaleY = vec_splat(splatScaleY, 0); - + splatm00 = vec_splat(tempRow0, 0); splatm01 = vec_splat(tempRow0, 1); splatm02 = vec_splat(tempRow0, 2); splatm03 = vec_splat(tempRow0, 3); - + splatm10 = vec_splat(tempRow1, 0); splatm11 = vec_splat(tempRow1, 1); splatm12 = vec_splat(tempRow1, 2); splatm13 = vec_splat(tempRow1, 3); - + splatm20 = vec_splat(tempRow2, 0); splatm21 = vec_splat(tempRow2, 1); splatm22 = vec_splat(tempRow2, 2); splatm23 = vec_splat(tempRow2, 3); - + splatm30 = vec_splat(tempRow3, 0); splatm31 = vec_splat(tempRow3, 1); splatm32 = vec_splat(tempRow3, 2); splatm33 = vec_splat(tempRow3, 3); - + clipCodeCum = vec_or(splat_zero, splat_zero); - + for(itr = 0; itr < numItrs; itr++, curPoint += 3, curFrustum += 4, curScreen += 4, clipCodePtr++) @@ -427,7 +427,7 @@ MSrTransform_Geom_PointListToFrustumScreen_AltiVec( UUrProcessor_ZeroCacheLine(curScreen, 0); UUrProcessor_ZeroCacheLine(curFrustum, 0); } - + // store the clip codes if needed if((itr % 4) == 0) { @@ -441,25 +441,25 @@ MSrTransform_Geom_PointListToFrustumScreen_AltiVec( xxxx = curPoint[0]; yyyy = curPoint[1]; zzzz = curPoint[2]; - + hXXXX = vec_madd(splatm00, xxxx, splatm30); hXXXX = vec_madd(splatm10, yyyy, hXXXX); hXXXX = vec_madd(splatm20, zzzz, hXXXX); - + hYYYY = vec_madd(splatm01, xxxx, splatm31); hYYYY = vec_madd(splatm11, yyyy, hYYYY); hYYYY = vec_madd(splatm21, zzzz, hYYYY); - + hZZZZ = vec_madd(splatm02, xxxx, splatm32); hZZZZ = vec_madd(splatm12, yyyy, hZZZZ); hZZZZ = vec_madd(splatm22, zzzz, hZZZZ); - + hWWWW = vec_madd(splatm03, xxxx, splatm33); hWWWW = vec_madd(splatm13, yyyy, hWWWW); hWWWW = vec_madd(splatm23, zzzz, hWWWW); - + negwwww = vec_sub((const vector float)splat_zero, hWWWW); - + // compute the clip codes clipCodeXXXXPos = (vector unsigned int)vec_cmpgt(hXXXX, hWWWW); clipCodeXXXXNeg = (vector unsigned int)vec_cmplt(hXXXX, negwwww); @@ -467,35 +467,35 @@ MSrTransform_Geom_PointListToFrustumScreen_AltiVec( clipCodeYYYYNeg = (vector unsigned int)vec_cmplt(hYYYY, negwwww); clipCodeZZZZPos = (vector unsigned int)vec_cmpgt(hZZZZ, hWWWW); clipCodeZZZZNeg = (vector unsigned int)vec_cmplt(hZZZZ, negwwww); - + mask = vec_or(splat_int_one, splat_int_one); clipCode0123 = vec_and(clipCodeXXXXPos, mask); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeXXXXNeg, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeYYYYPos, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeYYYYNeg, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeZZZZPos, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeZZZZNeg, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_perm(clipCode0123, clipCode0123, clipCode_perm); - + // we need to shift clipCode0123 based on clipCodePtr clipCode_lvsr = vec_lvsr(0, clipCodePtr); clipCode0123 = vec_perm(clipCode0123, clipCode0123, clipCode_lvsr); - + // or in clipCode0123 into clipCodeCum clipCodeCum = vec_or(clipCodeCum, clipCode0123); - + // store the frustum point t1 = vec_perm(hXXXX, hYYYY, prl2Seq4x4_s0p0); t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p0); @@ -511,21 +511,21 @@ MSrTransform_Geom_PointListToFrustumScreen_AltiVec( curFrustum[1] = yyyy; curFrustum[2] = zzzz; curFrustum[3] = wwww; - + t1 = vec_re(hWWWW); t2 = vec_nmsub(t1, hWWWW, one); hWWWW = vec_madd(t1, t2, t1); - + // hWWWW is now inv hWWWW - + hXXXX = vec_madd(hXXXX, hWWWW, one); hXXXX = vec_madd(hXXXX, splatScaleX, (const vector float)splat_zero); - + hYYYY = vec_madd(hYYYY, hWWWW, negOne); hYYYY = vec_madd(hYYYY, splatScaleY, (const vector float)splat_zero); - + hZZZZ = vec_madd(hZZZZ, hWWWW, (const vector float)splat_zero); - + t1 = vec_perm(hXXXX, hYYYY, prl2Seq4x4_s0p0); t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p0); xxxx = vec_perm(t1, t2, prl2Seq4x4_s1p0); @@ -535,13 +535,13 @@ MSrTransform_Geom_PointListToFrustumScreen_AltiVec( t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p1); zzzz = vec_perm(t1, t2, prl2Seq4x4_s1p0); hWWWW = vec_perm(t1, t2, prl2Seq4x4_s1p1); - + curScreen[0] = xxxx; curScreen[1] = yyyy; curScreen[2] = zzzz; curScreen[3] = hWWWW; } - + *(vector unsigned int*)(clipCodePtr-1) = clipCodeCum; //vec_dssall(); @@ -557,35 +557,35 @@ MSrTransform_Geom_PointListLocalToFrustumScreen_ActiveVertices_AltiVec( { M3tGeometry_Private* geomPrivate = (M3tGeometry_Private*)TMrTemplate_PrivateData_GetDataPtr(M3gTemplate_Geometry_PrivateData, inGeometry); UUtInt32 itr; - + vector float* mPtr; vector float* curPoint = (vector float*)geomPrivate->pointSIMD; vector float* curScreen = (vector float*)outScreenPoints; vector float* curFrustum = (vector float*)outFrustumPoints; - + vector float tempRow0, tempRow1, tempRow2, tempRow3; - - + + vector float splatm00, splatm10, splatm20, splatm30; vector float splatm01, splatm11, splatm21, splatm31; vector float splatm02, splatm12, splatm22, splatm32; vector float splatm03, splatm13, splatm23, splatm33; - + vector float xxxx, yyyy, zzzz, wwww; - + vector float hXXXX, hYYYY, hZZZZ, hWWWW; vector float t1, t2; - + vector float splatScaleX, splatScaleY; vector float negwwww; - + vector unsigned int clipCodeXXXXPos, clipCodeYYYYPos, clipCodeZZZZPos; vector unsigned int clipCodeXXXXNeg, clipCodeYYYYNeg, clipCodeZZZZNeg; vector unsigned int clipCodeCum; vector unsigned int clipCode0123; vector unsigned char clipCode_lvsr; vector unsigned int mask; - + const vector float one = AVcSplatOne; const vector float negOne = AVcSplatNegOne; const vector unsigned char prl2Seq4x4_s0p0 = AVcPrl2Seq4x4_s0p0; @@ -598,63 +598,63 @@ MSrTransform_Geom_PointListLocalToFrustumScreen_ActiveVertices_AltiVec( const vector unsigned int clipCodeY_mask = (const vector unsigned int)(3 << 2, 3 << 2, 3 << 2, 3 << 2); const vector unsigned int clipCodeZ_mask = (const vector unsigned int)(3 << 4, 3 << 4, 3 << 4, 3 << 4); const vector unsigned char clipCode_perm = (const vector unsigned char)(3, 7, 11, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - + const vector unsigned int splat_zero = (const vector unsigned int)(0, 0, 0, 0); const vector unsigned int splat_int_one = (const vector unsigned int)(1, 1, 1, 1); const vector unsigned int splat_int_allone = (const vector unsigned int)(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); - + UUtUns32 blockDescPoint, blockDescScreen; UUtInt32 numItrs; - + UUtUns32* clipCodePtr = (UUtUns32*)outClipCodeList; - + UUmAssert(((UUtUns32)&MSgGeomContextPrivate->matrix_localToFrustum & 0xF) == 0); UUmAssert(((UUtUns32)curPoint & 0xF) == 0); UUmAssert(((UUtUns32)curScreen & 0xF) == 0); UUmAssert(((UUtUns32)clipCodePtr & 0xF) == 0); - + numItrs = (inGeometry->pointArray->numPoints + 3) >> 2; - + blockDescPoint = AVmBuildBlockDST(3, numItrs, 3); blockDescScreen = AVmBuildBlockDST(4, numItrs, 4); - + vec_dst((vector float *)curPoint, blockDescPoint, 0); vec_dstst((vector float *)curScreen, blockDescScreen, 1); - + mPtr = (vector float*)MSgGeomContextPrivate->matrix_localToFrustum.m; - + tempRow0 = mPtr[0]; tempRow1 = mPtr[1]; tempRow2 = mPtr[2]; tempRow3 = mPtr[3]; - + *(float *)&splatScaleX = MSgGeomContextPrivate->scaleX; *(float *)&splatScaleY = MSgGeomContextPrivate->scaleY; splatScaleX = vec_splat(splatScaleX, 0); splatScaleY = vec_splat(splatScaleY, 0); - + splatm00 = vec_splat(tempRow0, 0); splatm01 = vec_splat(tempRow0, 1); splatm02 = vec_splat(tempRow0, 2); splatm03 = vec_splat(tempRow0, 3); - + splatm10 = vec_splat(tempRow1, 0); splatm11 = vec_splat(tempRow1, 1); splatm12 = vec_splat(tempRow1, 2); splatm13 = vec_splat(tempRow1, 3); - + splatm20 = vec_splat(tempRow2, 0); splatm21 = vec_splat(tempRow2, 1); splatm22 = vec_splat(tempRow2, 2); splatm23 = vec_splat(tempRow2, 3); - + splatm30 = vec_splat(tempRow3, 0); splatm31 = vec_splat(tempRow3, 1); splatm32 = vec_splat(tempRow3, 2); splatm33 = vec_splat(tempRow3, 3); - + clipCodeCum = vec_or(splat_zero, splat_zero); - + for(itr = 0; itr < numItrs; itr++, curPoint += 3, curFrustum += 4, curScreen += 4, clipCodePtr++) @@ -664,7 +664,7 @@ MSrTransform_Geom_PointListLocalToFrustumScreen_ActiveVertices_AltiVec( UUrProcessor_ZeroCacheLine(curScreen, 0); UUrProcessor_ZeroCacheLine(curFrustum, 0); } - + // store the clip codes if needed if((itr % 4) == 0) { @@ -680,25 +680,25 @@ MSrTransform_Geom_PointListLocalToFrustumScreen_ActiveVertices_AltiVec( xxxx = curPoint[0]; yyyy = curPoint[1]; zzzz = curPoint[2]; - + hXXXX = vec_madd(splatm00, xxxx, splatm30); hXXXX = vec_madd(splatm10, yyyy, hXXXX); hXXXX = vec_madd(splatm20, zzzz, hXXXX); - + hYYYY = vec_madd(splatm01, xxxx, splatm31); hYYYY = vec_madd(splatm11, yyyy, hYYYY); hYYYY = vec_madd(splatm21, zzzz, hYYYY); - + hZZZZ = vec_madd(splatm02, xxxx, splatm32); hZZZZ = vec_madd(splatm12, yyyy, hZZZZ); hZZZZ = vec_madd(splatm22, zzzz, hZZZZ); - + hWWWW = vec_madd(splatm03, xxxx, splatm33); hWWWW = vec_madd(splatm13, yyyy, hWWWW); hWWWW = vec_madd(splatm23, zzzz, hWWWW); - + negwwww = vec_sub((const vector float)splat_zero, hWWWW); - + // compute the clip codes clipCodeXXXXPos = (vector unsigned int)vec_cmpgt(hXXXX, hWWWW); clipCodeXXXXNeg = (vector unsigned int)vec_cmplt(hXXXX, negwwww); @@ -706,35 +706,35 @@ MSrTransform_Geom_PointListLocalToFrustumScreen_ActiveVertices_AltiVec( clipCodeYYYYNeg = (vector unsigned int)vec_cmplt(hYYYY, negwwww); clipCodeZZZZPos = (vector unsigned int)vec_cmpgt(hZZZZ, hWWWW); clipCodeZZZZNeg = (vector unsigned int)vec_cmplt(hZZZZ, negwwww); - + mask = vec_or(splat_int_one, splat_int_one); clipCode0123 = vec_and(clipCodeXXXXPos, mask); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeXXXXNeg, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeYYYYPos, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeYYYYNeg, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeZZZZPos, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeZZZZNeg, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_perm(clipCode0123, clipCode0123, clipCode_perm); - + // we need to shift clipCode0123 based on clipCodePtr clipCode_lvsr = vec_lvsr(0, clipCodePtr); clipCode0123 = vec_perm(clipCode0123, clipCode0123, clipCode_lvsr); - + // or in clipCode0123 into clipCodeCum clipCodeCum = vec_or(clipCodeCum, clipCode0123); - + // store the frustum point t1 = vec_perm(hXXXX, hYYYY, prl2Seq4x4_s0p0); t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p0); @@ -750,21 +750,21 @@ MSrTransform_Geom_PointListLocalToFrustumScreen_ActiveVertices_AltiVec( curFrustum[1] = yyyy; curFrustum[2] = zzzz; curFrustum[3] = wwww; - + t1 = vec_re(hWWWW); t2 = vec_nmsub(t1, hWWWW, one); hWWWW = vec_madd(t1, t2, t1); - + // hWWWW is now inv hWWWW - + hXXXX = vec_madd(hXXXX, hWWWW, one); hXXXX = vec_madd(hXXXX, splatScaleX, (const vector float)splat_zero); - + hYYYY = vec_madd(hYYYY, hWWWW, negOne); hYYYY = vec_madd(hYYYY, splatScaleY, (const vector float)splat_zero); - + hZZZZ = vec_madd(hZZZZ, hWWWW, (const vector float)splat_zero); - + t1 = vec_perm(hXXXX, hYYYY, prl2Seq4x4_s0p0); t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p0); xxxx = vec_perm(t1, t2, prl2Seq4x4_s1p0); @@ -774,13 +774,13 @@ MSrTransform_Geom_PointListLocalToFrustumScreen_ActiveVertices_AltiVec( t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p1); zzzz = vec_perm(t1, t2, prl2Seq4x4_s1p0); hWWWW = vec_perm(t1, t2, prl2Seq4x4_s1p1); - + curScreen[0] = xxxx; curScreen[1] = yyyy; curScreen[2] = zzzz; curScreen[3] = hWWWW; } - + *(vector unsigned int*)(clipCodePtr-1) = clipCodeCum; //vec_dssall(); @@ -794,48 +794,48 @@ MSrTransform_Geom_PointListAndVertexNormalToWorld_AltiVec( { M3tGeometry_Private* geomPrivate = (M3tGeometry_Private*)TMrTemplate_PrivateData_GetDataPtr(M3gTemplate_Geometry_PrivateData, inGeometry); UUtInt32 itr; - + vector float* mPtr; vector float* curNormal = (vector float*)geomPrivate->vertexNormalSIMD; vector float* curPoint = (vector float*)geomPrivate->pointSIMD; vector float* xfrmNormal = (vector float*)outResultWorldVertexNormals; vector float* xfrmPoint = (vector float*)outResultWorldPoints; - + vector float splatm00, splatm10, splatm20, splatm30; vector float splatm01, splatm11, splatm21, splatm31; vector float splatm02, splatm12, splatm22, splatm32; - + vector float tempRow0, tempRow1, tempRow2; - + vector float nxxxx, nyyyy, nzzzz; vector float pxxxx, pyyyy, pzzzz; - + vector float tfXXXX, tfYYYY, tfZZZZ; - + vector float zero = AVcSplatZero; - + UUtUns32 blockDesc; UUtInt32 numItrs; - + mPtr = (vector float*)MSgGeomContextPrivate->matrix_localToWorld->m; UUmAssert(((UUtUns32)curNormal & 0xF) == 0); UUmAssert(((UUtUns32)curPoint & 0xF) == 0); UUmAssert(((UUtUns32)xfrmNormal & 0xF) == 0); UUmAssert(((UUtUns32)xfrmPoint & 0xF) == 0); - + numItrs = (inGeometry->pointArray->numPoints + 3) >> 2; - + blockDesc = AVmBuildBlockDST(3, numItrs, 3); vec_dst((vector float *)curNormal, blockDesc, 0); vec_dst((vector float *)curPoint, blockDesc, 1); vec_dstst((vector float *)xfrmNormal, blockDesc, 2); vec_dstst((vector float *)xfrmPoint, blockDesc, 3); - + tempRow0 = mPtr[0]; tempRow1 = mPtr[1]; tempRow2 = mPtr[2]; - + splatm00 = vec_splat(tempRow0, 0); splatm01 = vec_splat(tempRow0, 1); splatm02 = vec_splat(tempRow0, 2); @@ -848,7 +848,7 @@ MSrTransform_Geom_PointListAndVertexNormalToWorld_AltiVec( splatm30 = vec_splat(tempRow2, 1); splatm31 = vec_splat(tempRow2, 2); splatm32 = vec_splat(tempRow2, 3); - + for(itr = 0; itr < numItrs; itr++, curNormal += 3, xfrmNormal += 3, curPoint += 3, xfrmPoint += 3) @@ -864,48 +864,48 @@ MSrTransform_Geom_PointListAndVertexNormalToWorld_AltiVec( UUrProcessor_ZeroCacheLine((char*)xfrmPoint + UUcProcessor_CacheLineSize * 2, 0); } #endif - + nxxxx = curNormal[0]; nyyyy = curNormal[1]; nzzzz = curNormal[2]; - + tfXXXX = vec_madd(splatm00, nxxxx, zero); tfXXXX = vec_madd(splatm10, nyyyy, tfXXXX); tfXXXX = vec_madd(splatm20, nzzzz, tfXXXX); - + tfYYYY = vec_madd(splatm01, nxxxx, zero); tfYYYY = vec_madd(splatm11, nyyyy, tfYYYY); tfYYYY = vec_madd(splatm21, nzzzz, tfYYYY); - + tfZZZZ = vec_madd(splatm02, nxxxx, zero); tfZZZZ = vec_madd(splatm12, nyyyy, tfZZZZ); tfZZZZ = vec_madd(splatm22, nzzzz, tfZZZZ); - + xfrmNormal[0] = tfXXXX; xfrmNormal[1] = tfYYYY; xfrmNormal[2] = tfZZZZ; - + pxxxx = curPoint[0]; pyyyy = curPoint[1]; pzzzz = curPoint[2]; - + tfXXXX = vec_madd(splatm00, pxxxx, splatm30); tfXXXX = vec_madd(splatm10, pyyyy, tfXXXX); tfXXXX = vec_madd(splatm20, pzzzz, tfXXXX); - + tfYYYY = vec_madd(splatm01, pxxxx, splatm31); tfYYYY = vec_madd(splatm11, pyyyy, tfYYYY); tfYYYY = vec_madd(splatm21, pzzzz, tfYYYY); - + tfZZZZ = vec_madd(splatm02, pxxxx, splatm32); tfZZZZ = vec_madd(splatm12, pyyyy, tfZZZZ); tfZZZZ = vec_madd(splatm22, pzzzz, tfZZZZ); - + xfrmPoint[0] = tfXXXX; xfrmPoint[1] = tfYYYY; xfrmPoint[2] = tfZZZZ; } - + //vec_dssall(); } @@ -918,67 +918,67 @@ MSrTransform_Geom_PointListAndVertexNormalToWorldComputeViewVector_AltiVec( { M3tGeometry_Private* geomPrivate = (M3tGeometry_Private*)TMrTemplate_PrivateData_GetDataPtr(M3gTemplate_Geometry_PrivateData, inGeometry); UUtInt32 itr; - + vector float* mPtr; vector float* curNormal = (vector float*)geomPrivate->vertexNormalSIMD; vector float* curPoint = (vector float*)geomPrivate->pointSIMD; vector float* xfrmNormal = (vector float*)outResultWorldVertexNormals; vector float* xfrmPoint = (vector float*)outResultWorldPoints; vector float* curViewVector = (vector float*)outResultWorldViewVectors; - + vector float splatm00, splatm10, splatm20, splatm30; vector float splatm01, splatm11, splatm21, splatm31; vector float splatm02, splatm12, splatm22, splatm32; - + vector float tempRow0, tempRow1, tempRow2; - + vector float nxxxx, nyyyy, nzzzz; vector float pxxxx, pyyyy, pzzzz; - + vector float tfXXXX, tfYYYY, tfZZZZ; - + vector float zero = AVcSplatZero; - + vector float splat_clX, splat_clY, splat_clZ; vector float viewVecXXXX, viewVecYYYY, viewVecZZZZ, len0123; vector float t0, t1, t2; - + const vector unsigned char perm_s0p0 = AVcPrl2Seq4x3_s0p0; const vector unsigned char perm_s0p1 = AVcPrl2Seq4x3_s0p1; const vector unsigned char perm_s0p2 = AVcPrl2Seq4x3_s0p2; const vector unsigned char perm_s1p0 = AVcPrl2Seq4x3_s1p0; const vector unsigned char perm_s1p1 = AVcPrl2Seq4x3_s1p1; const vector unsigned char perm_s1p2 = AVcPrl2Seq4x3_s1p2; - + const vector float splat_zero = (const vector float)((const vector unsigned int)(0, 0, 0, 0)); const vector float splat_onehalf = (const vector float)(0.5f, 0.5f, 0.5f, 0.5f); const vector float splat_one = (const vector float)(1.0f, 1.0f, 1.0f, 1.0f); - + UUtUns32 blockDesc; UUtInt32 numItrs; - + UUmAssertReadPtr(curViewVector, sizeof(*curViewVector)); - + mPtr = (vector float*)MSgGeomContextPrivate->matrix_localToWorld->m; UUmAssert(((UUtUns32)curNormal & 0xF) == 0); UUmAssert(((UUtUns32)curPoint & 0xF) == 0); UUmAssert(((UUtUns32)xfrmNormal & 0xF) == 0); UUmAssert(((UUtUns32)xfrmPoint & 0xF) == 0); UUmAssert(((UUtUns32)curViewVector & 0xF) == 0); - + numItrs = (inGeometry->pointArray->numPoints + 3) >> 2; - + blockDesc = AVmBuildBlockDST(3, numItrs, 3); vec_dst((vector float *)curNormal, blockDesc, 0); vec_dst((vector float *)curPoint, blockDesc, 1); vec_dstst((vector float *)xfrmNormal, blockDesc, 2); vec_dstst((vector float *)xfrmPoint, blockDesc, 3); - + tempRow0 = mPtr[0]; tempRow1 = mPtr[1]; tempRow2 = mPtr[2]; - + splatm00 = vec_splat(tempRow0, 0); splatm01 = vec_splat(tempRow0, 1); splatm02 = vec_splat(tempRow0, 2); @@ -991,18 +991,18 @@ MSrTransform_Geom_PointListAndVertexNormalToWorldComputeViewVector_AltiVec( splatm30 = vec_splat(tempRow2, 1); splatm31 = vec_splat(tempRow2, 2); splatm32 = vec_splat(tempRow2, 3); - + //*(float*)&splat_clX = MSgGeomContextPrivate->activeCamera->cameraLocation.x; //*(float*)&splat_clY = MSgGeomContextPrivate->activeCamera->cameraLocation.y; //*(float*)&splat_clZ = MSgGeomContextPrivate->activeCamera->cameraLocation.z; *(float*)&splat_clX = MSgGeomContextPrivate->visCamera->cameraLocation.x; *(float*)&splat_clY = MSgGeomContextPrivate->visCamera->cameraLocation.y; *(float*)&splat_clZ = MSgGeomContextPrivate->visCamera->cameraLocation.z; - + splat_clX = vec_splat(splat_clX, 0); splat_clY = vec_splat(splat_clY, 0); splat_clZ = vec_splat(splat_clZ, 0); - + for(itr = 0; itr < numItrs; itr++, curNormal += 3, xfrmNormal += 3, curPoint += 3, xfrmPoint += 3, curViewVector += 3) @@ -1018,86 +1018,86 @@ MSrTransform_Geom_PointListAndVertexNormalToWorldComputeViewVector_AltiVec( UUrProcessor_ZeroCacheLine((char*)xfrmPoint + UUcProcessor_CacheLineSize * 2, 0); } #endif - + nxxxx = curNormal[0]; nyyyy = curNormal[1]; nzzzz = curNormal[2]; - + tfXXXX = vec_madd(splatm00, nxxxx, zero); tfXXXX = vec_madd(splatm10, nyyyy, tfXXXX); tfXXXX = vec_madd(splatm20, nzzzz, tfXXXX); - + tfYYYY = vec_madd(splatm01, nxxxx, zero); tfYYYY = vec_madd(splatm11, nyyyy, tfYYYY); tfYYYY = vec_madd(splatm21, nzzzz, tfYYYY); - + tfZZZZ = vec_madd(splatm02, nxxxx, zero); tfZZZZ = vec_madd(splatm12, nyyyy, tfZZZZ); tfZZZZ = vec_madd(splatm22, nzzzz, tfZZZZ); - + xfrmNormal[0] = tfXXXX; xfrmNormal[1] = tfYYYY; xfrmNormal[2] = tfZZZZ; - + pxxxx = curPoint[0]; pyyyy = curPoint[1]; pzzzz = curPoint[2]; - + tfXXXX = vec_madd(splatm00, pxxxx, splatm30); tfXXXX = vec_madd(splatm10, pyyyy, tfXXXX); tfXXXX = vec_madd(splatm20, pzzzz, tfXXXX); - + tfYYYY = vec_madd(splatm01, pxxxx, splatm31); tfYYYY = vec_madd(splatm11, pyyyy, tfYYYY); tfYYYY = vec_madd(splatm21, pzzzz, tfYYYY); - + tfZZZZ = vec_madd(splatm02, pxxxx, splatm32); tfZZZZ = vec_madd(splatm12, pyyyy, tfZZZZ); tfZZZZ = vec_madd(splatm22, pzzzz, tfZZZZ); - + xfrmPoint[0] = tfXXXX; xfrmPoint[1] = tfYYYY; xfrmPoint[2] = tfZZZZ; - + // compute normalized view vector viewVecXXXX = vec_sub(splat_clX, tfXXXX); viewVecYYYY = vec_sub(splat_clY, tfYYYY); viewVecZZZZ = vec_sub(splat_clZ, tfZZZZ); - + len0123 = vec_madd(viewVecXXXX, viewVecXXXX, splat_zero); len0123 = vec_madd(viewVecYYYY, viewVecYYYY, len0123); len0123 = vec_madd(viewVecZZZZ, viewVecZZZZ, len0123); - + len0123 = vec_rsqrte(len0123); if(0) { vector float y0, t0, t1; - + y0 = vec_rsqrte(len0123); t0 = vec_madd(y0, y0, splat_zero); t1 = vec_madd(y0, splat_onehalf, splat_zero); t0 = vec_nmsub(len0123, t0, splat_one); len0123 = vec_madd(t0, t1, y0); } - + viewVecXXXX = vec_madd(viewVecXXXX, len0123, splat_zero); viewVecYYYY = vec_madd(viewVecYYYY, len0123, splat_zero); viewVecZZZZ = vec_madd(viewVecZZZZ, len0123, splat_zero); - + // switch to xyzxyzxyzxyz format t0 = vec_perm(viewVecXXXX, viewVecZZZZ, perm_s0p0); t1 = vec_perm(viewVecXXXX, viewVecYYYY, perm_s0p1); t2 = vec_perm(viewVecYYYY, viewVecZZZZ, perm_s0p2); - + viewVecXXXX = vec_perm(t0, t2, perm_s1p0); viewVecYYYY = vec_perm(t0, t1, perm_s1p1); viewVecZZZZ = vec_perm(t1, t2, perm_s1p2); - + curViewVector[0] = viewVecXXXX; curViewVector[1] = viewVecYYYY; curViewVector[2] = viewVecZZZZ; } - + //vec_dssall(); } @@ -1109,7 +1109,7 @@ MSrTransform_Geom_FaceNormalToWorld_AltiVec( M3tGeometry_Private* geomPrivate = (M3tGeometry_Private*)TMrTemplate_PrivateData_GetDataPtr(M3gTemplate_Geometry_PrivateData, inGeometry); UUtInt32 itr; UUtInt32 numItrs; - + vector float* mPtr; vector float* curNormal; vector float* xfrmNormal; @@ -1139,7 +1139,7 @@ MSrTransform_Geom_FaceNormalToWorld_AltiVec( tempRow0 = mPtr[0]; tempRow1 = mPtr[1]; tempRow2 = mPtr[2]; - + splatm00 = vec_splat(tempRow0, 0); splatm01 = vec_splat(tempRow0, 1); splatm02 = vec_splat(tempRow0, 2); @@ -1154,10 +1154,10 @@ MSrTransform_Geom_FaceNormalToWorld_AltiVec( curNormal = (vector float*)geomPrivate->triNormalSIMD; xfrmNormal = (vector float*)outResultWorldTriNormals; - + UUmAssert(((UUtUns32)curNormal & 0xF) == 0); UUmAssert(((UUtUns32)xfrmNormal & 0xF) == 0); - + for(itr = 0; itr < numItrs; itr++, curNormal += 3, xfrmNormal += 3) @@ -1165,23 +1165,23 @@ MSrTransform_Geom_FaceNormalToWorld_AltiVec( nxxxx = curNormal[0]; nyyyy = curNormal[1]; nzzzz = curNormal[2]; - + tfXXXX = vec_madd(splatm00, nxxxx, zero); tfXXXX = vec_madd(splatm10, nyyyy, tfXXXX); tfXXXX = vec_madd(splatm20, nzzzz, tfXXXX); - + tfYYYY = vec_madd(splatm01, nxxxx, zero); tfYYYY = vec_madd(splatm11, nyyyy, tfYYYY); tfYYYY = vec_madd(splatm21, nzzzz, tfYYYY); - + tfZZZZ = vec_madd(splatm02, nxxxx, zero); tfZZZZ = vec_madd(splatm12, nyyyy, tfZZZZ); tfZZZZ = vec_madd(splatm22, nzzzz, tfZZZZ); - + t0 = vec_perm(tfXXXX, tfZZZZ, perm_s0p0); t1 = vec_perm(tfXXXX, tfYYYY, perm_s0p1); t2 = vec_perm(tfYYYY, tfZZZZ, perm_s0p2); - + tfXXXX = vec_perm(t0, t2, perm_s1p0); tfYYYY = vec_perm(t0, t1, perm_s1p1); tfZZZZ = vec_perm(t1, t2, perm_s1p2); @@ -1190,7 +1190,7 @@ MSrTransform_Geom_FaceNormalToWorld_AltiVec( xfrmNormal[1] = tfYYYY; xfrmNormal[2] = tfZZZZ; } - + } void @@ -1201,35 +1201,35 @@ MSrTransform_EnvPointListToFrustumScreen_ActiveVertices_AltiVec( UUtUns8 *outClipCodeList) { UUtInt32 itr; - + vector float* mPtr; vector float* curPoint = (vector float*)MSgGeomContextPrivate->envPointSIMD; vector float* curScreen = (vector float*)outScreenPoints; vector float* curFrustum = (vector float*)outFrustumPoints; - + vector float tempRow0, tempRow1, tempRow2, tempRow3; - - + + vector float splatm00, splatm10, splatm20, splatm30; vector float splatm01, splatm11, splatm21, splatm31; vector float splatm02, splatm12, splatm22, splatm32; vector float splatm03, splatm13, splatm23, splatm33; - + vector float xxxx, yyyy, zzzz, wwww; - + vector float hXXXX, hYYYY, hZZZZ, hWWWW; vector float t1, t2; - + vector float splatScaleX, splatScaleY; vector float negwwww; - + vector unsigned int clipCodeXXXXPos, clipCodeYYYYPos, clipCodeZZZZPos; vector unsigned int clipCodeXXXXNeg, clipCodeYYYYNeg, clipCodeZZZZNeg; vector unsigned int clipCodeCum; vector unsigned int clipCode0123; vector unsigned char clipCode_lvsr; vector unsigned int mask; - + const vector float one = AVcSplatOne; const vector float negOne = AVcSplatNegOne; const vector unsigned char prl2Seq4x4_s0p0 = AVcPrl2Seq4x4_s0p0; @@ -1242,63 +1242,63 @@ MSrTransform_EnvPointListToFrustumScreen_ActiveVertices_AltiVec( const vector unsigned int clipCodeY_mask = (const vector unsigned int)(3 << 2, 3 << 2, 3 << 2, 3 << 2); const vector unsigned int clipCodeZ_mask = (const vector unsigned int)(3 << 4, 3 << 4, 3 << 4, 3 << 4); const vector unsigned char clipCode_perm = (const vector unsigned char)(3, 7, 11, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - + const vector unsigned int splat_zero = (const vector unsigned int)(0, 0, 0, 0); const vector unsigned int splat_int_one = (const vector unsigned int)(1, 1, 1, 1); const vector unsigned int splat_int_allone = (const vector unsigned int)(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); - + UUtUns32 blockDescPoint, blockDescScreen; UUtInt32 numItrs; - + UUtUns32* clipCodePtr = (UUtUns32*)outClipCodeList; - + UUmAssert(((UUtUns32)&MSgGeomContextPrivate->matrix_localToFrustum & 0xF) == 0); UUmAssert(((UUtUns32)curPoint & 0xF) == 0); UUmAssert(((UUtUns32)curScreen & 0xF) == 0); UUmAssert(((UUtUns32)clipCodePtr & 0xF) == 0); - + numItrs = (MSgGeomContextPrivate->environment->pointArray->numPoints + 3) >> 2; - + blockDescPoint = AVmBuildBlockDST(3, numItrs, 3); blockDescScreen = AVmBuildBlockDST(4, numItrs, 4); - + vec_dst((vector float *)curPoint, blockDescPoint, 0); vec_dstst((vector float *)curScreen, blockDescScreen, 1); - + mPtr = (vector float*)MSgGeomContextPrivate->matrix_localToFrustum.m; - + tempRow0 = mPtr[0]; tempRow1 = mPtr[1]; tempRow2 = mPtr[2]; tempRow3 = mPtr[3]; - + *(float *)&splatScaleX = MSgGeomContextPrivate->scaleX; *(float *)&splatScaleY = MSgGeomContextPrivate->scaleY; splatScaleX = vec_splat(splatScaleX, 0); splatScaleY = vec_splat(splatScaleY, 0); - + splatm00 = vec_splat(tempRow0, 0); splatm01 = vec_splat(tempRow0, 1); splatm02 = vec_splat(tempRow0, 2); splatm03 = vec_splat(tempRow0, 3); - + splatm10 = vec_splat(tempRow1, 0); splatm11 = vec_splat(tempRow1, 1); splatm12 = vec_splat(tempRow1, 2); splatm13 = vec_splat(tempRow1, 3); - + splatm20 = vec_splat(tempRow2, 0); splatm21 = vec_splat(tempRow2, 1); splatm22 = vec_splat(tempRow2, 2); splatm23 = vec_splat(tempRow2, 3); - + splatm30 = vec_splat(tempRow3, 0); splatm31 = vec_splat(tempRow3, 1); splatm32 = vec_splat(tempRow3, 2); splatm33 = vec_splat(tempRow3, 3); - + clipCodeCum = vec_or(splat_zero, splat_zero); - + for(itr = 0; itr < numItrs; itr++, curPoint += 3, curFrustum += 4, curScreen += 4, clipCodePtr++) @@ -1308,7 +1308,7 @@ MSrTransform_EnvPointListToFrustumScreen_ActiveVertices_AltiVec( UUrProcessor_ZeroCacheLine(curScreen, 0); UUrProcessor_ZeroCacheLine(curFrustum, 0); } - + // store the clip codes if needed if((itr % 4) == 0) { @@ -1324,25 +1324,25 @@ MSrTransform_EnvPointListToFrustumScreen_ActiveVertices_AltiVec( xxxx = curPoint[0]; yyyy = curPoint[1]; zzzz = curPoint[2]; - + hXXXX = vec_madd(splatm00, xxxx, splatm30); hXXXX = vec_madd(splatm10, yyyy, hXXXX); hXXXX = vec_madd(splatm20, zzzz, hXXXX); - + hYYYY = vec_madd(splatm01, xxxx, splatm31); hYYYY = vec_madd(splatm11, yyyy, hYYYY); hYYYY = vec_madd(splatm21, zzzz, hYYYY); - + hZZZZ = vec_madd(splatm02, xxxx, splatm32); hZZZZ = vec_madd(splatm12, yyyy, hZZZZ); hZZZZ = vec_madd(splatm22, zzzz, hZZZZ); - + hWWWW = vec_madd(splatm03, xxxx, splatm33); hWWWW = vec_madd(splatm13, yyyy, hWWWW); hWWWW = vec_madd(splatm23, zzzz, hWWWW); - + negwwww = vec_sub((const vector float)splat_zero, hWWWW); - + // compute the clip codes clipCodeXXXXPos = (vector unsigned int)vec_cmpgt(hXXXX, hWWWW); clipCodeXXXXNeg = (vector unsigned int)vec_cmplt(hXXXX, negwwww); @@ -1350,35 +1350,35 @@ MSrTransform_EnvPointListToFrustumScreen_ActiveVertices_AltiVec( clipCodeYYYYNeg = (vector unsigned int)vec_cmplt(hYYYY, negwwww); clipCodeZZZZPos = (vector unsigned int)vec_cmpgt(hZZZZ, hWWWW); clipCodeZZZZNeg = (vector unsigned int)vec_cmplt(hZZZZ, negwwww); - + mask = vec_or(splat_int_one, splat_int_one); clipCode0123 = vec_and(clipCodeXXXXPos, mask); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeXXXXNeg, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeYYYYPos, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeYYYYNeg, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeZZZZPos, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_or(clipCode0123, vec_and(clipCodeZZZZNeg, mask)); mask = vec_sl(mask, splat_int_one); - + clipCode0123 = vec_perm(clipCode0123, clipCode0123, clipCode_perm); - + // we need to shift clipCode0123 based on clipCodePtr clipCode_lvsr = vec_lvsr(0, clipCodePtr); clipCode0123 = vec_perm(clipCode0123, clipCode0123, clipCode_lvsr); - + // or in clipCode0123 into clipCodeCum clipCodeCum = vec_or(clipCodeCum, clipCode0123); - + // store the frustum point t1 = vec_perm(hXXXX, hYYYY, prl2Seq4x4_s0p0); t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p0); @@ -1394,21 +1394,21 @@ MSrTransform_EnvPointListToFrustumScreen_ActiveVertices_AltiVec( curFrustum[1] = yyyy; curFrustum[2] = zzzz; curFrustum[3] = wwww; - + t1 = vec_re(hWWWW); t2 = vec_nmsub(t1, hWWWW, one); hWWWW = vec_madd(t1, t2, t1); - + // hWWWW is now inv hWWWW - + hXXXX = vec_madd(hXXXX, hWWWW, one); hXXXX = vec_madd(hXXXX, splatScaleX, (const vector float)splat_zero); - + hYYYY = vec_madd(hYYYY, hWWWW, negOne); hYYYY = vec_madd(hYYYY, splatScaleY, (const vector float)splat_zero); - + hZZZZ = vec_madd(hZZZZ, hWWWW, (const vector float)splat_zero); - + t1 = vec_perm(hXXXX, hYYYY, prl2Seq4x4_s0p0); t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p0); xxxx = vec_perm(t1, t2, prl2Seq4x4_s1p0); @@ -1418,13 +1418,13 @@ MSrTransform_EnvPointListToFrustumScreen_ActiveVertices_AltiVec( t2 = vec_perm(hZZZZ, hWWWW, prl2Seq4x4_s0p1); zzzz = vec_perm(t1, t2, prl2Seq4x4_s1p0); hWWWW = vec_perm(t1, t2, prl2Seq4x4_s1p1); - + curScreen[0] = xxxx; curScreen[1] = yyyy; curScreen[2] = zzzz; curScreen[3] = hWWWW; } - + *(vector unsigned int*)(clipCodePtr-1) = clipCodeCum; //vec_dssall(); @@ -1443,7 +1443,7 @@ MSrBackface_Remove_AltiVec( { UUrBitVector_SetBitAll(outActiveTrisBV, inGeometry->triNormalIndexArray->numIndices); UUrBitVector_SetBitAll(outActiveVerticesBV, inGeometry->pointArray->numPoints); - + #if 0 M3tVector3D* curViewVector; M3tVector3D* curNormal; @@ -1451,7 +1451,7 @@ MSrBackface_Remove_AltiVec( M3tTri* curTri; M3tQuad* curQuad; UUtUns16 index0, index1, index2, index3; - + if(inGeometry->triArray != NULL) { for(i = 0, curTri = inGeometry->triArray->tris, @@ -1461,21 +1461,21 @@ MSrBackface_Remove_AltiVec( { index0 = curTri->indices[0]; curViewVector = inWorldViewVectors + index0; - + if(curViewVector->x * curNormal->x + curViewVector->y * curNormal->y + curViewVector->z * curNormal->z < M3gBackfaceRemoveThreshold) { continue; } - + UUrBitVector_SetBit( outActiveTrisBV, i); - + index1 = curTri->indices[1]; index2 = curTri->indices[2]; - + UUrBitVector_SetBit( outActiveVerticesBV, index0); @@ -1497,22 +1497,22 @@ MSrBackface_Remove_AltiVec( { index0 = curQuad->indices[0]; curViewVector = inWorldViewVectors + index0; - + if(curViewVector->x * curNormal->x + curViewVector->y * curNormal->y + curViewVector->z * curNormal->z < M3gBackfaceRemoveThreshold) { continue; } - + UUrBitVector_SetBit( outActiveQuadsBV, i); - + index1 = curQuad->indices[1]; index2 = curQuad->indices[2]; index3 = curQuad->indices[3]; - + UUrBitVector_SetBit( outActiveVerticesBV, index0); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform_AltiVec.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform_AltiVec.h index f3bdaf2..27b2b7d 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform_AltiVec.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/GeomEngine/Software/MS_Geom_Transform_AltiVec.h @@ -1,12 +1,12 @@ /* FILE: MS_Geom_Transform_AltiVec.h - + AUTHOR: Brent H. Pease - + CREATED: May 21, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -23,7 +23,7 @@ MSrTransform_Geom_PointListToScreen_ActiveVertices_AltiVec( M3tGeometry* inGeometry, UUtUns32* inActiveVerticesBV, M3tPointScreen *outResultScreenPoints); - + void MSrTransform_Geom_PointListToFrustumScreen_AltiVec( M3tGeometry* inGeometry, @@ -56,7 +56,7 @@ void MSrTransform_Geom_FaceNormalToWorld_AltiVec( M3tGeometry* inGeometry, M3tVector3D *outResultWorldTriNormals); - + void MSrTransform_EnvPointListToFrustumScreen_ActiveVertices_AltiVec( const UUtUns32* inActiveVerticesBV, @@ -72,5 +72,5 @@ MSrBackface_Remove_AltiVec( M3tVector3D* inWorldTriNormals, UUtUns32* outActiveTrisBV, UUtUns32* outActiveVerticesBV); - + #endif /* MS_GEOM_TRANFORM_ALTIVEC_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Common.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Common.c index fbf2648..96d180d 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Common.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Common.c @@ -1,12 +1,12 @@ /* FILE: OGL_DrawGeom_Common.c - + AUTHOR: Brent Pease, Kevin Armstrong, Michael Evans - + CREATED: January 5, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1998 */ @@ -25,8 +25,8 @@ #define GL_RGB_S3TC (0x83A0) #define GL_RGB4_S3TC (0x83A1) -#define GL_RGBA_S3TC (0x83A2) -#define GL_RGBA4_S3TC (0x83A3) +#define GL_RGBA_S3TC (0x83A2) +#define GL_RGBA4_S3TC (0x83A3) /*---------- S.S. */ @@ -38,14 +38,14 @@ typedef struct OGLtExtension_Function char* functionName; void** functionLocation; // can never be NULL UUtBool required; - + } OGLtExtension_Function; typedef struct OGLtExtension_Feature { char* featureName; UUtBool* featureFlag; // if NULL the feature is required - + } OGLtExtension_Feature; OGLtCommon OGLgCommon; @@ -57,7 +57,7 @@ typedef enum OGLtDownloadType OGLcDownloadClassic, OGLcDownloadGeneric, OGLcDownloadInvalid - + } OGLtDownloadType; @@ -84,7 +84,7 @@ typedef void OGLtExtension_Feature OGLgExtension_Features[] = { // required - + // optional {"GL_ARB_multitexture", &OGLgCommon.ext_arb_multitexture}, {"GL_EXT_vertex_array", &OGLgCommon.ext_vertex_array}, @@ -97,17 +97,17 @@ OGLtExtension_Feature OGLgExtension_Features[] = {"GL_EXT_point_parameters", &OGLgCommon.ext_point_parameters}, {"GL_EXT_stencil_wrap", &OGLgCommon.ext_stencil_wrap}, {"GL_EXT_texture_object", &OGLgCommon.ext_texture_object}, - {"GL_S3_s3tc", &OGLgCommon.ext_s3tc}, - + {"GL_S3_s3tc", &OGLgCommon.ext_s3tc}, + {NULL, NULL} }; OGLtExtension_Function OGLgExtension_Functions[] = { - + // required - + // optional {"glActiveTextureARB", (void**) &OGLgCommon.pglActiveTextureARB, UUcFalse}, {"glClientActiveTextureARB", (void**) &OGLgCommon.pglClientActiveTextureARB, UUcFalse}, @@ -115,11 +115,11 @@ OGLtExtension_Function OGLgExtension_Functions[] = {"glMultiTexCoord2fvARB", (void**) &OGLgCommon.pglMultiTexCoord2fvARB, UUcFalse}, {"glLockArraysEXT", (void**) &OGLgCommon.pglLockArraysEXT, UUcFalse}, {"glUnlockArraysEXT", (void**) &OGLgCommon.pglUnlockArraysEXT, UUcFalse}, - + {NULL, NULL} }; -const OGLtTexelTypeInfo OGLgTexInfoTable[] = +const OGLtTexelTypeInfo OGLgTexInfoTable[] = { { IMcPixelType_ARGB4444, OGLcDownloadPacked, UNSIGNED_SHORT_4_4_4_4, GL_RGBA4 }, { IMcPixelType_RGB555, OGLcDownloadPacked, UNSIGNED_SHORT_5_5_5_1, GL_RGB5 }, @@ -167,7 +167,7 @@ OGLiTextureMap_Download_Generic_NoAlpha( } error = IMrImage_ConvertPixelType( - IMcDitherMode_Off, + IMcDitherMode_Off, inWidth, inHeight, IMcNoMipMap, @@ -199,7 +199,7 @@ OGLiTextureMap_Download_Generic_NoAlpha( inHeight, // height 0, // border {?} (GLint) format, // format of the pixel data (GLenum) - GL_UNSIGNED_BYTE, // packed format (GLenum) + GL_UNSIGNED_BYTE, // packed format (GLenum) inBuffer); UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); @@ -222,7 +222,7 @@ OGLiTextureMap_Download_Generic( GLenum format; UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); - + if (IMrPixelType_HasAlpha(inTextureMap->texelType)) { newPixelType = IMcPixelType_RGBA_Bytes; @@ -235,7 +235,7 @@ OGLiTextureMap_Download_Generic( } error = IMrImage_ConvertPixelType( - IMcDitherMode_Off, + IMcDitherMode_Off, inWidth, inHeight, IMcNoMipMap, @@ -253,7 +253,7 @@ OGLiTextureMap_Download_Generic( inHeight, // height 0, // border {?} (GLint) format, // format of the pixel data (GLenum) - GL_UNSIGNED_BYTE, // packed format (GLenum) + GL_UNSIGNED_BYTE, // packed format (GLenum) inBuffer); UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); @@ -277,13 +277,13 @@ OGLiTextureMap_Download_Classic( GL_TEXTURE_2D, inLevel, inTextureInfo->glInternalFormat, - inWidth, - inHeight, - 0, - inTextureInfo->downloadInfo, - GL_UNSIGNED_BYTE, + inWidth, + inHeight, + 0, + inTextureInfo->downloadInfo, + GL_UNSIGNED_BYTE, inSrc); - + UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); return; @@ -332,9 +332,9 @@ OGLiTextureMap_Download_S3( inHeight, // height 0, // border {?} (GLint) GL_RGB4_S3TC, // format of the pixel data (GLenum) - inTextureInfo->downloadInfo, // packed format (GLenum) + inTextureInfo->downloadInfo, // packed format (GLenum) inBuffer); - + UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); return; @@ -359,7 +359,7 @@ OGLiTextureMap_Download_PackedPixels( pixelType = OGLiTextureMap_PackedTypeToPixelType(inTextureInfo->downloadInfo); error = IMrImage_ConvertPixelType( - IMcDitherMode_Off, + IMcDitherMode_Off, inWidth, inHeight, IMcNoMipMap, @@ -377,9 +377,9 @@ OGLiTextureMap_Download_PackedPixels( inHeight, // height 0, // border {?} (GLint) GL_RGBA, // format of the pixel data (GLenum) - inTextureInfo->downloadInfo, // packed format (GLenum) + inTextureInfo->downloadInfo, // packed format (GLenum) inBuffer); - + UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); return; @@ -400,13 +400,13 @@ OGLiTextureMap_Create( UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); UUmAssert(inTextureMap->opengl_dirty == UUcTrue); - + inTextureMap->opengl_dirty = UUcFalse; - + downloadProc = OGLiTextureMap_Download_Generic; - + textureInfo = OGLgTexInfoTable + inTextureMap->texelType; - + switch(textureInfo->downloadType) { case OGLcDownloadS3: @@ -434,19 +434,19 @@ OGLiTextureMap_Create( default: UUmAssert(!"blam"); } - + if(inTextureMap->flags & M3cTextureFlags_HasMipMap) { hasMipMap = UUcTrue; } - + // generate opengl name if(inTextureMap->opengl_texture_name == 0) { glGenTextures(1, (unsigned int*)&inTextureMap->opengl_texture_name); if(inTextureMap->opengl_texture_name == 0) return UUcError_Generic; } - + OGLrCommon_glBindTexture(GL_TEXTURE_2D, inTextureMap->opengl_texture_name); UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); @@ -472,7 +472,7 @@ OGLiTextureMap_Create( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); - + if (hasMipMap) { glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); @@ -496,7 +496,7 @@ OGLiTextureMap_Create( if (!hasMipMap) break; lod++; - base = ((char *) base) + IMrImage_ComputeSize(inTextureMap->texelType, IMcNoMipMap, width, height); + base = ((char *) base) + IMrImage_ComputeSize(inTextureMap->texelType, IMcNoMipMap, width, height); width >>= 1; height >>= 1; @@ -506,7 +506,7 @@ OGLiTextureMap_Create( height = UUmMax(height, 1); } } - + UUmAssert(glIsTexture(inTextureMap->opengl_texture_name) == GL_TRUE); UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); @@ -538,9 +538,9 @@ OGLiTextureMap_Delete( static UUtError OGLiTextureMap_Update( M3tTextureMap* inTextureMap) -{ +{ inTextureMap->opengl_dirty = UUcTrue; - + return UUcError_None; } @@ -552,7 +552,7 @@ OGLiTextureMap_ProcHandler( { UUtError error; M3tTextureMap* inTextureMap = inInstancePtr; - + UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); switch(inMessage) @@ -567,20 +567,20 @@ OGLiTextureMap_ProcHandler( case TMcTemplateProcMessage_LoadPostProcess: M3rTextureMap_Prepare(inTextureMap); - + inTextureMap->opengl_texture_name = 0; inTextureMap->opengl_dirty = UUcTrue; break; - + case TMcTemplateProcMessage_DisposePreProcess: OGLiTextureMap_Delete(inTextureMap); break; - + case TMcTemplateProcMessage_Update: error = OGLiTextureMap_Update(inTextureMap); UUmError_ReturnOnError(error); break; - + case TMcTemplateProcMessage_PrepareForUse: break; } @@ -602,7 +602,7 @@ OGLiTexture_EnsureLoaded( OGLiTextureMap_Create(inTextureMap); //COrConsole_Printf("made texture %d", inPrivateTextureData->texture_name); } - + UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); return; @@ -628,15 +628,15 @@ OGLrCommon_Initialize_OneTime( UUrStartupMessage("opengl renderer = %s", OGLgCommon.renderer); UUrStartupMessage("opengl version = %s", OGLgCommon.version); UUrStartupMessage("opengl extensions = %s", OGLgCommon.extensions); - + // get the feature extensions { OGLtExtension_Feature* curFeature = OGLgExtension_Features; - + while(curFeature->featureName != NULL) { present = strstr(OGLgCommon.extensions, curFeature->featureName) ? UUcTrue : UUcFalse; - + if(curFeature->featureFlag == NULL) { if(present == UUcFalse) @@ -648,7 +648,7 @@ OGLrCommon_Initialize_OneTime( { *curFeature->featureFlag = present; } - + curFeature++; } } @@ -657,11 +657,11 @@ OGLrCommon_Initialize_OneTime( { OGLtExtension_Function* curFunction = OGLgExtension_Functions; void* functionAddress; - + while(curFunction->functionName != NULL) { functionAddress = (void*)OGLrCommon_Platform_GetFunction(curFunction->functionName); - + if(curFunction->required == UUcTrue) { if(functionAddress == NULL) @@ -671,21 +671,21 @@ OGLrCommon_Initialize_OneTime( } *curFunction->functionLocation = functionAddress; - + curFunction++; } } - + if(OGLgCommon.ext_compiled_vertex_array == UUcTrue) { OGLgCommon.ext_vertex_array = UUcTrue; } - + /* S.S. if(OGLgCommon.ext_vertex_array == UUcFalse) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "opengl is missing extension vertex arrays"); }*/ - + // verify compiled vertex arrays if ((NULL == OGLgCommon.pglLockArraysEXT) || (NULL == OGLgCommon.pglUnlockArraysEXT)) { @@ -711,17 +711,17 @@ OGLrCommon_State_Initialize( OGLgCommon.width = inWidth; OGLgCommon.height = inHeight; - + OGLrCommon_glEnableClientState(GL_VERTEX_ARRAY); // OGLrCommon_glEnableClientState(GL_TEXTURE_COORD_ARRAY); // OGLrCommon_glEnableClientState(GL_NORMAL_ARRAY); - + OGLrCommon_glDisableClientState(GL_COLOR_ARRAY); OGLrCommon_glDisableClientState(GL_INDEX_ARRAY); OGLrCommon_glDisableClientState(GL_EDGE_FLAG_ARRAY); //glDepthRange(0,1); - + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glLoadIdentity(); @@ -730,23 +730,23 @@ OGLrCommon_State_Initialize( glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); glViewport(0, 0, OGLgCommon.width, OGLgCommon.height); - - OGLgCommon.convertedDataBuffer = UUrMemory_Block_New(256 * 256 * 4); + + OGLgCommon.convertedDataBuffer = UUrMemory_Block_New(256 * 256 * 4); UUmError_ReturnOnNull(OGLgCommon.convertedDataBuffer); // force update of the camera OGLgCommon.cameraMode = OGLcCameraMode_3D; OGLrCommon_Camera_Update(OGLcCameraMode_2D); - + // create the texture private array - error = + error = TMrTemplate_PrivateData_New( M3cTemplate_TextureMap, 0, OGLiTextureMap_ProcHandler, &OGLgCommon.texturePrivateData); UUmError_ReturnOnError(error); - + UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); return UUcError_None; @@ -765,30 +765,30 @@ OGLrCommon_Camera_Update( OGLtCameraMode inCameraMode) { UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); - + if(inCameraMode == OGLcCameraMode_2D && OGLgCommon.cameraMode == OGLcCameraMode_2D) return; - + if(inCameraMode == OGLcCameraMode_3D) { M3tManager_GeomCamera* activeCamera; - + M3rCamera_GetActive((M3tGeomCamera**)&activeCamera); - + M3rManager_Camera_UpdateMatrices(activeCamera); - + if(OGLgCommon.cameraMode != OGLcCameraMode_3D) { OGLgCommon.cameraMode = inCameraMode; OGLgCommon.update3DCamera_ViewData = UUcTrue; OGLgCommon.update3DCamera_StaticData = UUcTrue; } - + if(OGLgCommon.update3DCamera_ViewData) { OGLgCommon.update3DCamera_ViewData = UUcFalse; - + glLoadIdentity(); - + #if 0 gluLookAt( activeCamera->cameraLocation.x, @@ -803,25 +803,25 @@ OGLrCommon_Camera_Update( #else { float m[16]; - + OGLrCommon_Matrix4x4_OniToGL( &activeCamera->matrix_worldToView, m); - + glMultMatrixf(m); - + } #endif } - + if(OGLgCommon.update3DCamera_StaticData) { OGLgCommon.update3DCamera_StaticData = UUcFalse; - + glMatrixMode(GL_PROJECTION); - + glLoadIdentity(); - + #if 0 gluPerspective( activeCamera->fovy * 180.0f / M3cPi, @@ -831,16 +831,16 @@ OGLrCommon_Camera_Update( #else { float m[16]; - + OGLrCommon_Matrix4x4_OniToGL( &activeCamera->matrix_viewToFrustum, m); - + glMultMatrixf(m); - + } #endif - + glMatrixMode(GL_MODELVIEW); } } @@ -848,7 +848,7 @@ OGLrCommon_Camera_Update( { // set the ogl camera to 2d mode OGLgCommon.cameraMode = OGLcCameraMode_2D; - + glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho( @@ -857,7 +857,7 @@ OGLrCommon_Camera_Update( 0.f, -1.f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - + } UUmAssert((gl_error= glGetError()) == GL_NO_ERROR); @@ -871,27 +871,27 @@ OGLrCommon_Matrix4x3_OniToGL( float *outGLMatrix) { float* m = outGLMatrix; - + *m++ = inMatrix->m[0][0]; *m++ = inMatrix->m[0][1]; *m++ = inMatrix->m[0][2]; *m++ = 0.0f; - + *m++ = inMatrix->m[1][0]; *m++ = inMatrix->m[1][1]; *m++ = inMatrix->m[1][2]; *m++ = 0.0f; - + *m++ = inMatrix->m[2][0]; *m++ = inMatrix->m[2][1]; *m++ = inMatrix->m[2][2]; *m++ = 0.0f; - + *m++ = inMatrix->m[3][0]; *m++ = inMatrix->m[3][1]; *m++ = inMatrix->m[3][2]; *m++ = 1.0f; - + return; } @@ -901,27 +901,27 @@ OGLrCommon_Matrix4x4_OniToGL( float *outGLMatrix) { float* m = outGLMatrix; - + *m++ = inMatrix->m[0][0]; *m++ = inMatrix->m[0][1]; *m++ = inMatrix->m[0][2]; *m++ = inMatrix->m[0][3]; - + *m++ = inMatrix->m[1][0]; *m++ = inMatrix->m[1][1]; *m++ = inMatrix->m[1][2]; *m++ = inMatrix->m[1][3]; - + *m++ = inMatrix->m[2][0]; *m++ = inMatrix->m[2][1]; *m++ = inMatrix->m[2][2]; *m++ = inMatrix->m[2][3]; - + *m++ = inMatrix->m[3][0]; *m++ = inMatrix->m[3][1]; *m++ = inMatrix->m[3][2]; *m++ = inMatrix->m[3][3]; - + return; } @@ -946,7 +946,7 @@ OGLrCommon_TextureMap_Select( { OGLrCommon_glBindTexture(GL_TEXTURE_2D, 0); OGLrCommon_glDisable(GL_TEXTURE_2D); - + return; } @@ -961,15 +961,15 @@ OGLrCommon_TextureMap_Select( OGLrCommon_glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } } - + OGLiTexture_EnsureLoaded(inTextureMap); - + glEnable(GL_TEXTURE_2D); - + UUmAssert(glIsTexture(inTextureMap->opengl_texture_name) == GL_TRUE); - + OGLrCommon_glBindTexture(GL_TEXTURE_2D, inTextureMap->opengl_texture_name); - + #if 0 if (GL_TEXTURE1_ARB == inTMU) { @@ -1021,7 +1021,7 @@ OGLrCommon_DepthMode_Set( //inRead = UUcTrue; //inWrite = UUcTrue; - + if (inRead || inWrite) { if (!depth_enabled) @@ -1031,7 +1031,7 @@ OGLrCommon_DepthMode_Set( depth_read = !inRead; depth_write = !inWrite; } - + if ((inRead && !depth_read) || (!inRead && depth_read)) { @@ -1039,7 +1039,7 @@ OGLrCommon_DepthMode_Set( glDepthFunc(inRead ? GL_LEQUAL : GL_ALWAYS); depth_read = inRead; } - + if ((inWrite && !depth_write) || (!inWrite && depth_write)) { @@ -1088,9 +1088,9 @@ void OGLrCommon_glFogEnable( OGLgCommon.fog_color[3]= 1.f; OGLgCommon.fog_density= 0.5f; OGLgCommon.fog_mode= GL_EXP2; - + // OGLrCommon_glEnable(GL_FOG); - + glFogi(GL_FOG_MODE, OGLgCommon.fog_mode); // glHint(GL_FOG_HINT, GL_DONT_CARE); @@ -1120,7 +1120,7 @@ void OGLrCommon_glFogEnable( glClearColor(OGLgCommon.fog_color[0], OGLgCommon.fog_color[1], OGLgCommon.fog_color[2], OGLgCommon.fog_color[3]); - + return; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Common.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Common.h index feb3ca5..d40f6ff 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Common.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Common.h @@ -1,12 +1,12 @@ /* FILE: OGL_DrawGeom_Common.h - + AUTHOR: Brent Pease, Kevin Armstrong, Michael Evans - + CREATED: January 5, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1998 */ @@ -29,7 +29,7 @@ typedef enum OGLtCameraMode { OGLcCameraMode_2D, OGLcCameraMode_3D - + } OGLtCameraMode; // Extra GL header stuff @@ -126,7 +126,7 @@ typedef union gl_color_4ub { // S.S. #elif defined(UUmPlatform) && (UUmPlatform == UUmPlatform_Mac) UUtUns8 a, r, g, b; #else - #error "struct not setup for this platform" + #error "struct not setup for this platform" #endif }; UUtUns32 argb; @@ -154,9 +154,9 @@ typedef struct OGLtCommon const char* renderer; const char* version; const char* extensions; - + // only optional extension are here - + UUtBool ext_arb_multitexture; UUtBool ext_vertex_array; UUtBool ext_compiled_vertex_array; @@ -176,15 +176,15 @@ typedef struct OGLtCommon GLtClientActiveTextureARB pglClientActiveTextureARB; GLtMultiTexCoord4fARB pglMultiTexCoord4fARB; GLtMultiTexCoord2fvARB pglMultiTexCoord2fvARB; - + OGLtCameraMode cameraMode; - + UUtBool update3DCamera_ViewData; UUtBool update3DCamera_StaticData; - + UUtUns16 width; UUtUns16 height; - + TMtPrivateData* texturePrivateData; void* convertedDataBuffer; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Platform.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Platform.h index 9c78a52..709b3f5 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Platform.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Platform.h @@ -1,12 +1,12 @@ /* FILE: OGL_DrawGeom_Platform.h - + AUTHOR: Brent Pease, Kevin Armstrong, Michael Evans - + CREATED: January 5, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1998 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Platform_MacOS.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Platform_MacOS.c index ef37441..54d4ea4 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Platform_MacOS.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Platform_MacOS.c @@ -1,13 +1,13 @@ /* FILE: OGL_DrawGeom_Platform_MacOS.c - + AUTHOR: Brent Pease, Kevin Armstrong, Michael Evans - + CREATED: January 5, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1998 */ @@ -22,9 +22,9 @@ OGLrCommon_Platform_GetFunction( const char *inString) { void *function; - + function = NULL; - + if (strcmp(inString, "glLockArraysEXT") == 0) { function = glLockArraysEXT; @@ -53,7 +53,7 @@ OGLrCommon_Platform_GetFunction( { UUmAssert(!"Missing something here"); } - + return function; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Platform_Win32.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Platform_Win32.c index 2296002..702c716 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Platform_Win32.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Engines/OGL_Common/OGL_DrawGeom_Platform_Win32.c @@ -1,12 +1,12 @@ /* FILE: OGL_DrawGeom_Platform_Win32.c - + AUTHOR: Brent Pease, Kevin Armstrong, Michael Evans - + CREATED: January 5, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - 1998 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/AltiVec/Motoko_SIMDCache_AltiVec.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/AltiVec/Motoko_SIMDCache_AltiVec.c index 809d8c7..b1db3f0 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/AltiVec/Motoko_SIMDCache_AltiVec.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/AltiVec/Motoko_SIMDCache_AltiVec.c @@ -1,12 +1,12 @@ /* FILE: Motoko_SIMDCache_AltiVec.c - + AUTHOR: Brent H. Pease - + CREATED: Aug 4, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997-1999 */ @@ -33,17 +33,17 @@ M3rSIMDCache_Platform_Convert( M3tGeometry* inGeometry, M3tGeometry_SIMDCacheEntry* inCacheEntry) { - + AVrFloat_XYZ4ToXXXXYYYYZZZZ( inGeometry->pointArray->numPoints, (float*)inGeometry->pointArray->points, (float*)inCacheEntry->pointSIMD); - + AVrFloat_XYZ4ToXXXXYYYYZZZZ( inGeometry->pointArray->numPoints, (float*)inGeometry->vertexNormalArray->vectors, (float*)inCacheEntry->vertexNormalSIMD); - + AVrFloat_XYZ4ToXXXXYYYYZZZZ( inGeometry->triNormalArray->numVectors, (float*)inGeometry->triNormalArray->vectors, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/AltiVec/Motoko_SIMDCache_AltiVec.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/AltiVec/Motoko_SIMDCache_AltiVec.h index a7c15ad..d767b2f 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/AltiVec/Motoko_SIMDCache_AltiVec.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/AltiVec/Motoko_SIMDCache_AltiVec.h @@ -1,12 +1,12 @@ /* FILE: Motoko_SIMDCache_AltiVec.h - + AUTHOR: Brent H. Pease - + CREATED: Aug 4, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997-1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/BFW_Motoko_Template.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/BFW_Motoko_Template.c index dc6e783..6d58f06 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/BFW_Motoko_Template.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/BFW_Motoko_Template.c @@ -1,12 +1,12 @@ /* FILE: BFW_Motoko_Template.c - + AUTHOR: Brent H. Pease - + CREATED: May 5, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -20,7 +20,7 @@ M3rRegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register(M3cTemplate_PlaneEquationArray, sizeof(M3tPlaneEquationArray), TMcFolding_Allow); UUmError_ReturnOnError(error); error = TMrTemplate_Register(M3cTemplate_TextureMap, sizeof(M3tTextureMap), TMcFolding_Allow); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Draw.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Draw.c index dff763f..c63e3e9 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Draw.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Draw.c @@ -1,12 +1,12 @@ /* FILE: Motoko_Sort.c - + AUTHOR: Brent H. Pease - + CREATED: July 30, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -26,7 +26,7 @@ M3tTextureCoord sprite_uv[4] = { { 0.f, 0.f }, { 1.f, 0.f }, { 0.f, 1.f }, { 1.f M3tDrawContext_Counters M3gDrawContext_Counters; /* - * + * */ const M3tDrawContext_Counters* M3rDraw_Counters_Get( @@ -37,24 +37,24 @@ M3rDraw_Counters_Get( /* * Frame functions -*/ -UUtError +*/ +UUtError M3rDraw_Frame_Start( UUtUns32 inGameTime) { UUtError error; - + M3rDraw_State_SetInt(M3cDrawStateIntType_Time, inGameTime); - + error = M3rSort_Frame_Start(); UUmError_ReturnOnError(error); - + UUrMemory_Clear(&M3gDrawContext_Counters, sizeof(M3tDrawContext_Counters)); - + return M3gManagerDrawContext.drawFuncs->frameStart(inGameTime); } - -UUtError + +UUtError M3rDraw_Frame_End( void) { @@ -62,11 +62,11 @@ M3rDraw_Frame_End( error = M3rSort_Frame_End(); UUmError_ReturnOnError(error); - + return M3gManagerDrawContext.drawFuncs->frameEnd(&M3gDrawContext_Counters.textureDownload); } -UUtError +UUtError M3rDraw_Frame_Sync( void) { @@ -160,7 +160,7 @@ M3rDraw_Triangle( void* inTriangle) { M3gDrawContext_Counters.numTris++; - + if(!M3gDraw_Sorting) { M3gManagerDrawContext.drawFuncs->triangle(inTriangle); @@ -297,15 +297,15 @@ M3rDraw_SpriteArray( //} } -UUtError +UUtError M3rDraw_ScreenCapture( - const UUtRect* inRect, + const UUtRect* inRect, void* outBuffer) { return M3gManagerDrawContext.drawFuncs->screenCapture(inRect, outBuffer); } -UUtBool +UUtBool M3rDraw_PointVisible( const M3tPointScreen *inPoint, float inTolerance) @@ -313,7 +313,7 @@ M3rDraw_PointVisible( return M3gManagerDrawContext.drawFuncs->pointVisible(inPoint, inTolerance); } -UUtBool +UUtBool M3rDraw_SupportPointVisible( void) { @@ -340,7 +340,7 @@ UUtError M3rSpriteArray_Draw( M3tSpriteArray* inSpriteArray ) UUtError OGrGeomContext_Method_SpriteArray_Draw( - M3tSpriteArray* inSpriteArray); + M3tSpriteArray* inSpriteArray); */ @@ -352,4 +352,4 @@ UUtError M3rDraw_SetResolution(M3tDisplayMode mode) { return M3gManagerDrawContext.drawFuncs->changeMode(mode); -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Geom.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Geom.c index 981f80b..d6ec6e2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Geom.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Geom.c @@ -1,12 +1,12 @@ /* FILE: Motoko_Geom.c - + AUTHOR: Brent H. Pease - + CREATED: Dec 8, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997-1999 */ @@ -35,7 +35,7 @@ typedef enum M3tGeom_Alpha_Kind { M3cGeomAlphaKind_Sprite, M3cGeomAlphaKind_Object - + } M3tGeom_Alpha_Kind; typedef struct M3tGeom_Alpha_Sprite @@ -46,13 +46,13 @@ typedef struct M3tGeom_Alpha_Sprite float vertScale; UUtUns32 shade; UUtUns16 alpha; - + } M3tGeom_Alpha_Sprite; typedef struct M3tGeom_Alpha_Geom { M3tGeometry* geom; - + } M3tGeom_Alpha_Geom; @@ -61,16 +61,16 @@ typedef struct M3tGeom_Alpha_Object M3tGeom_Alpha_Kind kind; UUtUns16 bspNodeIndex; float distanceToCamera; - + M3tMatrix4x3 localToWorld; - + union { M3tGeom_Alpha_Geom geom; M3tGeom_Alpha_Sprite sprite; - + } u; - + } M3tGeom_Alpha_Object; #endif @@ -78,23 +78,23 @@ typedef struct M3tGeom_Alpha_Object typedef struct M3tGeomGlobals { AKtEnvironment* environment; - + UUtUns32 numSolidGQs; UUtUns32 solidGQs[AKcMaxVisibleGQs]; - + UUtUns32 numJelloGQs; UUtUns32 jelloGQs[AKcMaxTransparentGQs]; - + UUtUns32 numTransparentGQs; UUtUns32 transparentGQs[AKcMaxTransparentGQs]; - + UUtUns32* alphaGQBV; - + #if UNUSED_ALPHASORTING UUtUns16 numAlphaObjects; M3tGeom_Alpha_Object alphaObjects[M3cGeom_Alpha_MaxNumbers]; #endif - + } M3tGeomGlobals; M3tGeomGlobals M3gGeomGlobals; @@ -105,7 +105,7 @@ M3iGeom_AlphaObject_Get( void) { if(M3gGeomGlobals.numAlphaObjects >= M3cGeom_Alpha_MaxNumbers) return NULL; - + return M3gGeomGlobals.alphaObjects + M3gGeomGlobals.numAlphaObjects++; } #endif @@ -116,47 +116,47 @@ M3iGeom_TraverseBSP( UUtUns32 inNodeIndex) { AKtAlphaBSPTree_Node* bspNode; - AKtGQ_Collision* gqCollision; + AKtGQ_Collision* gqCollision; float a, b, c, d; - + if (0xFFFFFFFF == inNodeIndex) return; - + bspNode = M3gGeomGlobals.environment->alphaBSPNodeArray->nodes + inNodeIndex; - + UUmAssert(bspNode->gqIndex < M3gGeomGlobals.environment->gqCollisionArray->numGQs); - + gqCollision = M3gGeomGlobals.environment->gqCollisionArray->gqCollision + bspNode->gqIndex; - + // get the plane equation AKmPlaneEqu_GetComponents( gqCollision->planeEquIndex, M3gGeomGlobals.environment->planeArray->planes, a, b, c, d); - + if(a * inCameraLoc->x + b * inCameraLoc->y + c * inCameraLoc->z + d <= 0.0f) { // "Pos" side - + M3iGeom_TraverseBSP(inCameraLoc, bspNode->negNodeIndex); - + // process this quad - if(UUrBitVector_TestAndClearBit(M3gGeomGlobals.alphaGQBV, bspNode->gqIndex)) { + if(UUrBitVector_TestAndClearBit(M3gGeomGlobals.alphaGQBV, bspNode->gqIndex)) { M3gGeomGlobals.transparentGQs[M3gGeomGlobals.numTransparentGQs++] = bspNode->gqIndex; } - + M3iGeom_TraverseBSP(inCameraLoc, bspNode->posNodeIndex); } else { // "Neg" side - + M3iGeom_TraverseBSP(inCameraLoc, bspNode->posNodeIndex); - + // process this quad - if(UUrBitVector_TestAndClearBit(M3gGeomGlobals.alphaGQBV, bspNode->gqIndex)) { + if(UUrBitVector_TestAndClearBit(M3gGeomGlobals.alphaGQBV, bspNode->gqIndex)) { M3gGeomGlobals.transparentGQs[M3gGeomGlobals.numTransparentGQs++] = bspNode->gqIndex; } - + M3iGeom_TraverseBSP(inCameraLoc, bspNode->negNodeIndex); } @@ -175,12 +175,12 @@ M3rGeomContext_SetEnvironment( UUrBitVector_Dispose(M3gGeomGlobals.alphaGQBV); M3gGeomGlobals.alphaGQBV = NULL; } - + if(inEnvironment != NULL) { M3gGeomGlobals.alphaGQBV = UUrBitVector_New(inEnvironment->gqGeneralArray->numGQs); UUmError_ReturnOnNull(M3gGeomGlobals.alphaGQBV); } - + M3gGeomGlobals.numJelloGQs = 0; M3gGeomGlobals.numSolidGQs = 0; M3gGeomGlobals.numTransparentGQs = 0; @@ -208,7 +208,7 @@ M3rGeometry_Draw( } multitextured= ((inGeometryObject->baseMap != NULL) && (inGeometryObject->baseMap->envMap != NULL)) ? UUcTrue : UUcFalse; - + // determine how many passes to use for rendering this object if ((multitextured == UUcFalse) || M3rSinglePassMultitexturingAvailable() || @@ -241,7 +241,7 @@ M3rGeometry_Draw( gl_finish_multipass(); } } - + return error; } @@ -283,49 +283,49 @@ M3rSprite_Draw( M3tPoint3D worldPoint; M3tPoint3D cameraLocation; float dx, dy, dz; - + alphaObject = M3iGeom_AlphaObject_Get(); if(alphaObject == NULL) return UUcError_None; - + // get the active camera and location M3rCamera_GetActive(&activeCamera); - + M3rCamera_GetViewData(activeCamera, &cameraLocation, NULL, NULL); - + // compute the world point error = M3rMatrixStack_Get(&matrix); UUmError_ReturnOnError(error); - + MUrMatrix_MultiplyPoint(inPoint, matrix, &worldPoint); - + // compute the distance to the camera dx = cameraLocation.x - worldPoint.x; dy = cameraLocation.y - worldPoint.y; dz = cameraLocation.z - worldPoint.z; - + alphaObject->distanceToCamera = MUrSqrt(dx * dx + dy * dy + dz * dz); - + // save the matrix alphaObject->localToWorld = *matrix; - + // save the object - + // add it to the tree #endif - + return (M3gGeomContext)->spriteDraw(inTextureMap, inPoint, horizSize, vertSize, inShade, inAlpha, inRotation, inDirection, inOrientation, inXOffset, inXShortening, inXChop); } UUtError M3rSpriteArray_Draw( M3tSpriteArray* inSpriteArray ) -{ +{ return (M3gGeomContext)->spriteArrayDraw(inSpriteArray); } -UUtError -M3rDraw_Skybox( +UUtError +M3rDraw_Skybox( M3tSkyboxData *inSkybox ) { UUtUns32 is_fast_mode = M3rGeom_State_Get(M3cGeomStateIntType_FastMode); @@ -354,7 +354,7 @@ M3rDraw_DestroySkybox( } UUtError -M3rDecal_Draw( +M3rDecal_Draw( M3tDecalHeader* inDecal, UUtUns16 inAlpha ) { @@ -368,7 +368,7 @@ M3rContrail_Draw( float inV1, M3tContrailData* inPoint0, M3tContrailData* inPoint1) -{ +{ return (M3gGeomContext)->contrailDraw(inTextureMap, inV0, inV1, inPoint0, inPoint1); } @@ -403,25 +403,25 @@ M3rEnv_DrawGQList( UUtUns32 gqItr; AKtGQ_General* gqGeneralArray; - + AKtGQ_General* curGQGeneral; UUtUns32 is_fast_mode = M3rGeom_State_Get(M3cGeomStateIntType_FastMode); if (is_fast_mode) { return UUcError_None; } - + gqGeneralArray = M3gGeomGlobals.environment->gqGeneralArray->gqGeneral; - + // traverse the list and seperate out the solid quads from the transparent quads M3gGeomGlobals.numTransparentGQs = 0; M3gGeomGlobals.numJelloGQs = 0; M3gGeomGlobals.numSolidGQs = 0; - + for(gqItr = 0; gqItr < inNumGQs; gqItr++) { curGQGeneral = gqGeneralArray + inGQIndices[gqItr]; - + if (curGQGeneral->flags & AKcGQ_Flag_Jello) { M3gGeomGlobals.jelloGQs[M3gGeomGlobals.numJelloGQs++] = inGQIndices[gqItr]; } @@ -432,7 +432,7 @@ M3rEnv_DrawGQList( M3gGeomGlobals.solidGQs[M3gGeomGlobals.numSolidGQs++] = inGQIndices[gqItr]; } } - + error = (M3gGeomContext)->envDrawGQList(M3gGeomGlobals.numSolidGQs, M3gGeomGlobals.solidGQs, UUcFalse); UUmError_ReturnOnErrorMsg(error, "failed to draw the solid GQs"); @@ -456,14 +456,14 @@ M3rGeom_Clear_Jello( } } -UUtError +UUtError M3rGeom_Frame_Start( UUtUns32 inGameTicksElapsed) { #if UNUSED_ALPHASORTING M3gGeomGlobals.numAlphaObjects = 0; #endif - + return (M3gGeomContext)->frameStart(inGameTicksElapsed); } @@ -479,28 +479,28 @@ M3rGeom_Draw_Environment_Alpha( if (is_fast_mode) { return UUcError_None; } - + if(M3gGeomGlobals.environment != NULL) { // get the camera location M3rCamera_GetActive(&activeCamera); - + M3rCamera_GetViewData( activeCamera, &cameraLocation, NULL, NULL); - + if (M3gGeomGlobals.environment->alphaBSPNodeArray->numNodes > 0) { M3iGeom_TraverseBSP( &cameraLocation, 0); } - + M3rDraw_State_SetInt(M3cDrawStateIntType_ZWrite, M3cDrawState_ZWrite_Off); - + M3rDraw_State_Commit(); - + error = (M3gGeomContext)->envDrawGQList(M3gGeomGlobals.numTransparentGQs, M3gGeomGlobals.transparentGQs, UUcFalse); UUmError_ReturnOnError(error); } @@ -508,15 +508,15 @@ M3rGeom_Draw_Environment_Alpha( return UUcError_None; } - -UUtError + +UUtError M3rGeom_Frame_End( void) { UUtError error; - + error = (M3gGeomContext)->frameEnd(); - + return error; } @@ -534,21 +534,21 @@ M3rGeom_Draw_DebugSphere( M3tPoint3D *ring_XY = UUrAlignMemory(block_XY); M3tPoint3D *ring_YZ = UUrAlignMemory(block_YZ); UUtUns32 itr; - + for(itr = 0; itr < M3cGeom_Debug_RingPoints; itr++) { float theta; float cos_theta_radius; float sin_theta_radius; - + theta = M3c2Pi * (((float) itr) / M3cGeom_Debug_RingPoints); cos_theta_radius = MUrCos(theta) * inRadius; sin_theta_radius = MUrSin(theta) * inRadius; - + ring_XZ[itr].x = cos_theta_radius + inPoint->x; ring_XZ[itr].y = inPoint->y; ring_XZ[itr].z = sin_theta_radius + inPoint->z; - + ring_XY[itr].x = cos_theta_radius + inPoint->x; ring_XY[itr].y = sin_theta_radius + inPoint->y; ring_XY[itr].z = inPoint->z; @@ -562,7 +562,7 @@ M3rGeom_Draw_DebugSphere( ring_XZ[M3cGeom_Debug_RingPoints] = ring_XZ[0]; ring_XY[M3cGeom_Debug_RingPoints] = ring_XY[0]; ring_YZ[M3cGeom_Debug_RingPoints] = ring_YZ[0]; - + // draw the rings M3rGeometry_LineDraw((M3cGeom_Debug_RingPoints + 1), ring_XZ, inShade); M3rGeometry_LineDraw((M3cGeom_Debug_RingPoints + 1), ring_XY, inShade); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Geom_Camera.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Geom_Camera.c index ee0671e..f850755 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Geom_Camera.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Geom_Camera.c @@ -1,12 +1,12 @@ /* FILE: Motoko_Geom_Camera.c - + AUTHOR: Brent H. Pease - + CREATED: OCt 26, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -30,7 +30,7 @@ What Am I Looking At?" July 1988. With a few corrections, of course. * normalized viewing vector, Vv = (Vvx, Vvy, Vvz) * normalized up vector, Uv = (Uvx, Uvy, Uvz) * Vv and Uv are perpendicular - + Wanted: A world space to view space 4x4 transformation matrix such that the input world vertices are transformed into the view space where the camera @@ -40,84 +40,84 @@ What Am I Looking At?" July 1988. With a few corrections, of course. positive Z is comming out of the screen In equation form we want a matrix that satisfies the following constraints - + M * (Cl + Vv) = Transpose[0, 0, -1, 1] M * (Cl + Uv) = Transpose[0, 1, 0, 1] M * Cl = Transpose[0, 0, 0, 1] - + Derivation: - + The resulting matrix can be broken down into 2 matrices, one for translation and one for rotation. - + M = Mrot * Mtrans - + This means that the translation happens *before* the rotation. - + Translating the vertex to the camera origin is trivial so lets move on to the more interesting problem of rotation. - + Since we only need a pure rotation matrix lets just consider Mrot to be a 3x3 matrix for now. Later we will but it back into a 4x4 matrix. - + Now the constraining equations are: - + Mrot * Vv = Transpose[0, 0, -1] Mrot * Uv = Transpose[0, 1, 0] - + Being a resourceful engineer in the gamming business, I happened to have read Jim Blinn's article "Where Am I? What Am I Looking At?", so I know that the transpose of M equals the inverse of M when M is a purley rotational matrix. This is good news. - + Therefor, - + Vv = Transpose[Mrot] * Transpose[0, 0, -1] Uv = Transpose[Mrot] * Transpose[0, 1, 0] - + This means that the 3rd column of Transpose[Mrot] is -Vv and the second column of Transpose[Mrot] is Uv. - + Now we still have one column left. This is where Jim and I are going to wave our hands a little bit. Since the y axis cross the z axis equals the x axis we know that Uv cross Vv belongs in the first column of Transpose[M]. ta-da! - + Nv = Uv cross -Vv - + Transpose[Mrot] = [ Nv Uv -Vv ] - + Mrot = -- -- | Nvx Nvy Nvz | | Uvx Uvy Uvz | | -Vvx -Vvy -Vvz | -- -- - + Mtrans = -- -- | 1 0 0 -Clx | | 0 1 0 -Cly | | 0 0 1 -Clz | | 0 0 0 1 | -- -- - + M = -- -- | Nvx Nvy Nvz -(NvxClx + NvyCly + NvzClz) | | Uvx Uvy Uvz -(UvxClx + UvyCly + UvzClz) | | -Vvx -Vvy -Vvz (VvxClx + VvyCly + VvzClz) | | 0 0 0 1 | -- -- - + If you take the time to solve M * (Cl + Vv), etc you will find that you get the right answers(providing that you remember that UvxVvx + UvyVvy + UvzVvz is equal to Uv • Vv which by definition is 0) - + */ /* camera gunk */ M3tManager_GeomCamera M3gManager_Cameras[M3cManager_MaxCameras]; M3tManager_GeomCamera* M3gManager_ActiveCamera = NULL; - + static void MSiCamera_UpdateWorldFrustum( M3tManager_GeomCamera* inCameraPrivate) @@ -142,15 +142,15 @@ MSiCamera_UpdateWorldFrustum( float vx, vy, vz; float wx, wy, wz; float d; - + UUmAssert(inCameraPrivate != NULL); - + M3rManager_Camera_UpdateMatrices(inCameraPrivate); - + if(inCameraPrivate->vfnDirty == UUcTrue) { inCameraPrivate->vfnDirty = UUcFalse; - + /* 0 perp to zNear plane(toward camera) 1 right side @@ -159,30 +159,30 @@ MSiCamera_UpdateWorldFrustum( 4 top side 5 perp to zFar plane(away from camera) */ - + cos_fovyo2 = MUrCos(inCameraPrivate->fovy * 0.5f); sin_fovyo2 = MUrSin(inCameraPrivate->fovy * 0.5f); - + fovx02 = MUrATan(inCameraPrivate->aspect * sin_fovyo2 / cos_fovyo2); - + cos_fovxo2 = MUrCos(fovx02); sin_fovxo2 = MUrSin(fovx02); - + // perp to zNear plane(toward camera) inCameraPrivate->viewFrustumNormals[0].x = 0.0f; inCameraPrivate->viewFrustumNormals[0].y = 0.0f; inCameraPrivate->viewFrustumNormals[0].z = 1.0f; - + //right side inCameraPrivate->viewFrustumNormals[1].x = cos_fovxo2; inCameraPrivate->viewFrustumNormals[1].y = 0.0f; inCameraPrivate->viewFrustumNormals[1].z = sin_fovxo2; - + //left side inCameraPrivate->viewFrustumNormals[2].x = -cos_fovxo2; inCameraPrivate->viewFrustumNormals[2].y = 0.0f; inCameraPrivate->viewFrustumNormals[2].z = sin_fovxo2; - + //bottom side inCameraPrivate->viewFrustumNormals[3].x = 0.0f; inCameraPrivate->viewFrustumNormals[3].y = -cos_fovyo2; @@ -192,65 +192,65 @@ MSiCamera_UpdateWorldFrustum( inCameraPrivate->viewFrustumNormals[4].x = 0.0f; inCameraPrivate->viewFrustumNormals[4].y = cos_fovyo2; inCameraPrivate->viewFrustumNormals[4].z = sin_fovyo2; - + //perp to zFar plane(away from camera) inCameraPrivate->viewFrustumNormals[5].x = 0.0f; inCameraPrivate->viewFrustumNormals[5].y = 0.0f; inCameraPrivate->viewFrustumNormals[5].z = -1.0f; - + inCameraPrivate->wfpDirty = UUcTrue; } - + if(inCameraPrivate->wfpDirty == UUcTrue) { inCameraPrivate->wfpDirty = UUcFalse; - + MSmTransform_Matrix4x4ToRegisters( inCameraPrivate->matrix_frustumToWorld, m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33); - + invW = 1.0f / m33; - + s0 = (m30 + m10) * invW; s1 = (m31 + m11) * invW; s2 = (m32 + m12) * invW; - + u0 = m00 * invW; u1 = m01 * invW; u2 = m02 * invW; - + //0 left up near inCameraPrivate->worldFrustumPoints[0].x = s0 - u0; inCameraPrivate->worldFrustumPoints[0].y = s1 - u1; inCameraPrivate->worldFrustumPoints[0].z = s2 - u2; - + //1 right up near inCameraPrivate->worldFrustumPoints[1].x = s0 + u0; inCameraPrivate->worldFrustumPoints[1].y = s1 + u1; inCameraPrivate->worldFrustumPoints[1].z = s2 + u2; - + s0 = (m30 - m10) * invW; s1 = (m31 - m11) * invW; s2 = (m32 - m12) * invW; - + //2 left down near inCameraPrivate->worldFrustumPoints[2].x = s0 - u0; inCameraPrivate->worldFrustumPoints[2].y = s1 - u1; inCameraPrivate->worldFrustumPoints[2].z = s2 - u2; - + //3 right down near inCameraPrivate->worldFrustumPoints[3].x = s0 + u0; inCameraPrivate->worldFrustumPoints[3].y = s1 + u1; inCameraPrivate->worldFrustumPoints[3].z = s2 + u2; - + invW = 1.0f / ((m23 + m33)); t0 = (m20 + m30); t1 = (m21 + m31); t2 = (m22 + m32); - + s0 = (t0 + m10) * invW; s1 = (t1 + m11) * invW; s2 = (t2 + m12) * invW; @@ -258,17 +258,17 @@ MSiCamera_UpdateWorldFrustum( u0 = m00 * invW; u1 = m01 * invW; u2 = m02 * invW; - + //4 left up far inCameraPrivate->worldFrustumPoints[4].x = s0 - u0; inCameraPrivate->worldFrustumPoints[4].y = s1 - u1; inCameraPrivate->worldFrustumPoints[4].z = s2 - u2; - + //5 right up far inCameraPrivate->worldFrustumPoints[5].x = s0 + u0; inCameraPrivate->worldFrustumPoints[5].y = s1 + u1; inCameraPrivate->worldFrustumPoints[5].z = s2 + u2; - + s0 = (t0 - m10) * invW; s1 = (t1 - m11) * invW; s2 = (t2 - m12) * invW; @@ -277,12 +277,12 @@ MSiCamera_UpdateWorldFrustum( inCameraPrivate->worldFrustumPoints[6].x = s0 - u0; inCameraPrivate->worldFrustumPoints[6].y = s1 - u1; inCameraPrivate->worldFrustumPoints[6].z = s2 - u2; - + //7 right down far inCameraPrivate->worldFrustumPoints[7].x = s0 + u0; inCameraPrivate->worldFrustumPoints[7].y = s1 + u1; inCameraPrivate->worldFrustumPoints[7].z = s2 + u2; - + /* * now transform all the normals and compute the plane equations */ @@ -291,21 +291,21 @@ MSiCamera_UpdateWorldFrustum( m00, m10, m20, m01, m11, m21, m02, m12, m22); - + for(curIndex = 0; curIndex < 6; curIndex++) { vx = inCameraPrivate->viewFrustumNormals[curIndex].x; vy = inCameraPrivate->viewFrustumNormals[curIndex].y; vz = inCameraPrivate->viewFrustumNormals[curIndex].z; - + wx = m00 * vx + m10 * vy + m20 * vz; wy = m01 * vx + m11 * vy + m21 * vz; wz = m02 * vx + m12 * vy + m22 * vz; - + d = -(inCameraPrivate->worldFrustumPoints[curIndex].x * wx + inCameraPrivate->worldFrustumPoints[curIndex].y * wy + inCameraPrivate->worldFrustumPoints[curIndex].z * wz); - + inCameraPrivate->worldFrustumPlanes[curIndex].a = wx; inCameraPrivate->worldFrustumPlanes[curIndex].b = wy; inCameraPrivate->worldFrustumPlanes[curIndex].c = wz; @@ -313,79 +313,79 @@ MSiCamera_UpdateWorldFrustum( } } } - + void M3rManager_Camera_UpdateMatrices( M3tManager_GeomCamera* inCamera) { - + UUmAssert(inCamera != NULL); UUmAssert(inCamera->staticSet == UUcTrue && inCamera->viewSet == UUcTrue); - + if(inCamera->staticDirty == UUcTrue) { inCamera->staticDirty = UUcFalse; - - { - float fi, f; - float ti, t; + + { + float fi, f; + float ti, t; M3tMatrix4x4* viewToFrustum = &inCamera->matrix_viewToFrustum; M3tMatrix4x4* frustumToView = &inCamera->matrix_frustumToView; - - fi = (float)tan(inCamera->fovy * 0.5f); - f = 1.0f / fi; - ti = (inCamera->zNear - inCamera->zFar); - t = 1.0f / ti; - - /* column 1 */ - viewToFrustum->m[0][0] = f / inCamera->aspect; - viewToFrustum->m[0][1] = 0.0f; - viewToFrustum->m[0][2] = 0.0f; - viewToFrustum->m[0][3] = 0.0f; - - /* column 2 */ - viewToFrustum->m[1][0] = 0.0f; - viewToFrustum->m[1][1] = f; - viewToFrustum->m[1][2] = 0.0f; - viewToFrustum->m[1][3] = 0.0f; - - /* column 3 */ - viewToFrustum->m[2][0] = 0.0f; - viewToFrustum->m[2][1] = 0.0f; - viewToFrustum->m[2][2] = (inCamera->zFar + inCamera->zNear) * t; - viewToFrustum->m[2][3] = -1.0f; - - /* column 4 */ - viewToFrustum->m[3][0] = 0.0f; - viewToFrustum->m[3][1] = 0.0f; + + fi = (float)tan(inCamera->fovy * 0.5f); + f = 1.0f / fi; + ti = (inCamera->zNear - inCamera->zFar); + t = 1.0f / ti; + + /* column 1 */ + viewToFrustum->m[0][0] = f / inCamera->aspect; + viewToFrustum->m[0][1] = 0.0f; + viewToFrustum->m[0][2] = 0.0f; + viewToFrustum->m[0][3] = 0.0f; + + /* column 2 */ + viewToFrustum->m[1][0] = 0.0f; + viewToFrustum->m[1][1] = f; + viewToFrustum->m[1][2] = 0.0f; + viewToFrustum->m[1][3] = 0.0f; + + /* column 3 */ + viewToFrustum->m[2][0] = 0.0f; + viewToFrustum->m[2][1] = 0.0f; + viewToFrustum->m[2][2] = (inCamera->zFar + inCamera->zNear) * t; + viewToFrustum->m[2][3] = -1.0f; + + /* column 4 */ + viewToFrustum->m[3][0] = 0.0f; + viewToFrustum->m[3][1] = 0.0f; viewToFrustum->m[3][2] = 2.0f * inCamera->zFar * inCamera->zNear * t; - viewToFrustum->m[3][3] = 0.0f; - - /* column 1 */ - frustumToView->m[0][0] = fi * inCamera->aspect; - frustumToView->m[0][1] = 0.0f; - frustumToView->m[0][2] = 0.0f; - frustumToView->m[0][3] = 0.0f; - - /* column 2 */ - frustumToView->m[1][0] = 0.0f; - frustumToView->m[1][1] = fi; - frustumToView->m[1][2] = 0.0f; - frustumToView->m[1][3] = 0.0f; - - /* column 3 */ - frustumToView->m[2][0] = 0.0f; - frustumToView->m[2][1] = 0.0f; - frustumToView->m[2][2] = 0.0f; + viewToFrustum->m[3][3] = 0.0f; + + /* column 1 */ + frustumToView->m[0][0] = fi * inCamera->aspect; + frustumToView->m[0][1] = 0.0f; + frustumToView->m[0][2] = 0.0f; + frustumToView->m[0][3] = 0.0f; + + /* column 2 */ + frustumToView->m[1][0] = 0.0f; + frustumToView->m[1][1] = fi; + frustumToView->m[1][2] = 0.0f; + frustumToView->m[1][3] = 0.0f; + + /* column 3 */ + frustumToView->m[2][0] = 0.0f; + frustumToView->m[2][1] = 0.0f; + frustumToView->m[2][2] = 0.0f; frustumToView->m[2][3] = 1.0f / viewToFrustum->m[3][2]; - - /* column 4 */ - frustumToView->m[3][0] = 0.0f; - frustumToView->m[3][1] = 0.0f; - frustumToView->m[3][2] = -1.0f; + + /* column 4 */ + frustumToView->m[3][0] = 0.0f; + frustumToView->m[3][1] = 0.0f; + frustumToView->m[3][2] = -1.0f; frustumToView->m[3][3] = (inCamera->zFar + inCamera->zNear) / (2.0f * inCamera->zFar * inCamera->zNear); } - + inCamera->viewDirty = UUcTrue; inCamera->vfnDirty = UUcTrue; } @@ -393,104 +393,104 @@ M3rManager_Camera_UpdateMatrices( if(inCamera->viewDirty == UUcTrue) { inCamera->viewDirty = UUcFalse; - - { - float Nvx, Nvy, Nvz; - float Uvx, Uvy, Uvz; - float Vvx, Vvy, Vvz; - float Clx, Cly, Clz; - float invDenom; + + { + float Nvx, Nvy, Nvz; + float Uvx, Uvy, Uvz; + float Vvx, Vvy, Vvz; + float Clx, Cly, Clz; + float invDenom; M3tMatrix4x4* worldToView = &inCamera->matrix_worldToView; M3tMatrix4x4* viewToWorld = &inCamera->matrix_viewToWorld; - - Vvx = inCamera->viewVector.x; - Vvy = inCamera->viewVector.y; - Vvz = inCamera->viewVector.z; - - Uvx = inCamera->upVector.x; - Uvy = inCamera->upVector.y; - Uvz = inCamera->upVector.z; - + + Vvx = inCamera->viewVector.x; + Vvy = inCamera->viewVector.y; + Vvz = inCamera->viewVector.z; + + Uvx = inCamera->upVector.x; + Uvy = inCamera->upVector.y; + Uvz = inCamera->upVector.z; + Clx = inCamera->cameraLocation.x; Cly = inCamera->cameraLocation.y; Clz = inCamera->cameraLocation.z; - + Nvx = Uvz * Vvy - Uvy * Vvz; Nvy = Uvx * Vvz - Uvz * Vvx; Nvz = Uvy * Vvx - Uvx * Vvy; - + inCamera->crossVector.x = Nvx; inCamera->crossVector.y = Nvy; inCamera->crossVector.z = Nvz; - - invDenom = 1.0f / (Nvy * Uvz * Vvx - Nvz * Uvy * Vvx + Nvz * Uvx * Vvy - - Nvx * Uvz * Vvy - Nvy * Uvx * Vvz + Nvx * Uvy * Vvz); - - /* column 1 */ - worldToView->m[0][0] = Nvx; - worldToView->m[0][1] = Uvx; - worldToView->m[0][2] = -Vvx; - worldToView->m[0][3] = 0.0f; - - /* column 2 */ - worldToView->m[1][0] = Nvy; - worldToView->m[1][1] = Uvy; - worldToView->m[1][2] = -Vvy; - worldToView->m[1][3] = 0.0f; - - /* column 3 */ - worldToView->m[2][0] = Nvz; - worldToView->m[2][1] = Uvz; - worldToView->m[2][2] = -Vvz; - worldToView->m[2][3] = 0.0f; - - /* column 4 */ + + invDenom = 1.0f / (Nvy * Uvz * Vvx - Nvz * Uvy * Vvx + Nvz * Uvx * Vvy - + Nvx * Uvz * Vvy - Nvy * Uvx * Vvz + Nvx * Uvy * Vvz); + + /* column 1 */ + worldToView->m[0][0] = Nvx; + worldToView->m[0][1] = Uvx; + worldToView->m[0][2] = -Vvx; + worldToView->m[0][3] = 0.0f; + + /* column 2 */ + worldToView->m[1][0] = Nvy; + worldToView->m[1][1] = Uvy; + worldToView->m[1][2] = -Vvy; + worldToView->m[1][3] = 0.0f; + + /* column 3 */ + worldToView->m[2][0] = Nvz; + worldToView->m[2][1] = Uvz; + worldToView->m[2][2] = -Vvz; + worldToView->m[2][3] = 0.0f; + + /* column 4 */ worldToView->m[3][0] = - (Nvx * Clx + Nvy * Cly + Nvz * Clz); worldToView->m[3][1] = - (Uvx * Clx + Uvy * Cly + Uvz * Clz); worldToView->m[3][2] = (Vvx * Clx + Vvy * Cly + Vvz * Clz); - worldToView->m[3][3] = 1.0f; - - /* column 1 */ - viewToWorld->m[0][0] = (Uvy * Vvz - Uvz * Vvy) * invDenom; - viewToWorld->m[0][1] = (Uvz * Vvx - Uvx * Vvz) * invDenom; - viewToWorld->m[0][2] = (Uvx * Vvy - Uvy * Vvx) * invDenom; - viewToWorld->m[0][3] = 0.0f; - - /* column 2 */ - viewToWorld->m[1][0] = (Nvz * Vvy - Nvy * Vvz) * invDenom; - viewToWorld->m[1][1] = (Nvx * Vvz - Nvz * Vvx) * invDenom; - viewToWorld->m[1][2] = (Nvy * Vvx - Nvx * Vvy) * invDenom; - viewToWorld->m[1][3] = 0.0f; - - /* column 3 */ - viewToWorld->m[2][0] = (Nvz * Uvy - Nvy * Uvz) * invDenom; - viewToWorld->m[2][1] = (Nvx * Uvz - Nvz * Uvx) * invDenom; - viewToWorld->m[2][2] = (Nvy * Uvx - Nvx * Uvy) * invDenom; - viewToWorld->m[2][3] = 0.0f; - - /* column 4 */ - viewToWorld->m[3][0] = Clx; - viewToWorld->m[3][1] = Cly; - viewToWorld->m[3][2] = Clz; - viewToWorld->m[3][3] = 1.0f; + worldToView->m[3][3] = 1.0f; + + /* column 1 */ + viewToWorld->m[0][0] = (Uvy * Vvz - Uvz * Vvy) * invDenom; + viewToWorld->m[0][1] = (Uvz * Vvx - Uvx * Vvz) * invDenom; + viewToWorld->m[0][2] = (Uvx * Vvy - Uvy * Vvx) * invDenom; + viewToWorld->m[0][3] = 0.0f; + + /* column 2 */ + viewToWorld->m[1][0] = (Nvz * Vvy - Nvy * Vvz) * invDenom; + viewToWorld->m[1][1] = (Nvx * Vvz - Nvz * Vvx) * invDenom; + viewToWorld->m[1][2] = (Nvy * Vvx - Nvx * Vvy) * invDenom; + viewToWorld->m[1][3] = 0.0f; + + /* column 3 */ + viewToWorld->m[2][0] = (Nvz * Uvy - Nvy * Uvz) * invDenom; + viewToWorld->m[2][1] = (Nvx * Uvz - Nvz * Uvx) * invDenom; + viewToWorld->m[2][2] = (Nvy * Uvx - Nvx * Uvy) * invDenom; + viewToWorld->m[2][3] = 0.0f; + + /* column 4 */ + viewToWorld->m[3][0] = Clx; + viewToWorld->m[3][1] = Cly; + viewToWorld->m[3][2] = Clz; + viewToWorld->m[3][3] = 1.0f; } - + MUrMath_Matrix4x4Multiply( &inCamera->matrix_viewToFrustum, &inCamera->matrix_worldToView, &inCamera->matrix_worldToFrustum); - + MUrMath_Matrix4x4Multiply( &inCamera->matrix_viewToWorld, &inCamera->matrix_frustumToView, &inCamera->matrix_frustumToWorld); - + inCamera->wfpDirty = UUcTrue; - + #if defined(DEBUGGING) && DEBUGGING { UUtUns16 i, j; - + for(i = 0; i < 4; i++) { for(j = 0; j < 4; j++) @@ -505,7 +505,7 @@ M3rManager_Camera_UpdateMatrices( } } #endif - + } } @@ -515,9 +515,9 @@ M3rManager_Camera_Initialize( { UUtUns32 curCameraIndex; M3tManager_GeomCamera* curCamera; - + M3gManager_ActiveCamera = NULL; - + for(curCameraIndex = 0, curCamera = M3gManager_Cameras; curCameraIndex < M3cManager_MaxCameras; curCameraIndex++, curCamera++) @@ -532,7 +532,7 @@ M3rCamera_New( { UUtUns32 curCameraIndex; M3tManager_GeomCamera* curCamera; - + for(curCameraIndex = 0, curCamera = M3gManager_Cameras; curCameraIndex < M3cManager_MaxCameras; curCameraIndex++, curCamera++) @@ -540,43 +540,43 @@ M3rCamera_New( if(curCamera->inUse == UUcFalse) { curCamera->inUse = UUcTrue; - + curCamera->staticSet = UUcFalse; curCamera->viewSet = UUcFalse; - + *outNewCamera = (M3tGeomCamera*)curCamera; return UUcError_None; } } - + UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Ran out of camera space"); } - + void M3rCamera_Delete( M3tGeomCamera* inCamera) { M3tManager_GeomCamera* curCamera; - + curCamera = (M3tManager_GeomCamera*)inCamera; UUmAssert(curCamera != NULL && curCamera->inUse == UUcTrue); curCamera->inUse = UUcFalse; } - + void M3rCamera_SetActive( M3tGeomCamera* inCamera) { M3tManager_GeomCamera* curCamera; - + curCamera = (M3tManager_GeomCamera*)inCamera; UUmAssertReadPtr(curCamera, sizeof(*curCamera)); UUmAssert(curCamera->inUse == UUcTrue); - + M3gManager_ActiveCamera = curCamera; } - + UUtError M3rCamera_GetActive( M3tGeomCamera* *outCamera) @@ -585,13 +585,13 @@ M3rCamera_GetActive( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "No active camera"); } - + *outCamera = (M3tGeomCamera*)M3gManager_ActiveCamera; - + return UUcError_None; } - -void + +void M3rCamera_SetStaticData( M3tGeomCamera* inCamera, float inFOVy, @@ -600,24 +600,24 @@ M3rCamera_SetStaticData( float inZFar) { M3tManager_GeomCamera* curCamera; - + curCamera = (M3tManager_GeomCamera*)inCamera; - + UUmAssert(curCamera != NULL && curCamera->inUse == UUcTrue); - + curCamera->fovy = inFOVy; curCamera->aspect = inAspect; curCamera->zNear = inZNear; curCamera->zFar = inZFar; - + curCamera->staticSet = UUcTrue; curCamera->staticDirty = UUcTrue; UUmAssert(M3gActiveGeomEngine != UUcMaxUns16); M3gGeomEngineList[M3gActiveGeomEngine].methods.cameraStaticUpdate(); } - -void + +void M3rCamera_SetViewData( M3tGeomCamera* inCamera, M3tPoint3D* inCameraLocation, @@ -627,23 +627,23 @@ M3rCamera_SetViewData( M3tManager_GeomCamera* curCamera; curCamera = (M3tManager_GeomCamera*)inCamera; - + UUmAssert(curCamera != NULL && curCamera->inUse == UUcTrue); - + UUmAssert(curCamera->staticSet == UUcTrue); - + curCamera->cameraLocation = *inCameraLocation; curCamera->viewVector = *inViewDirection; curCamera->upVector = *inUpDirection; curCamera->viewDirty = UUcTrue; curCamera->viewSet = UUcTrue; - + UUmAssert(M3gActiveGeomEngine != UUcMaxUns16); M3gGeomEngineList[M3gActiveGeomEngine].methods.cameraViewUpdate(); } -void +void M3rCamera_GetStaticData( M3tGeomCamera* inCamera, float *outFOVy, @@ -654,16 +654,16 @@ M3rCamera_GetStaticData( M3tManager_GeomCamera* curCamera; curCamera = (M3tManager_GeomCamera*)inCamera; - + UUmAssert(curCamera != NULL && curCamera->inUse == UUcTrue); - + if(outFOVy != NULL) *outFOVy = curCamera->fovy; if(outAspect != NULL) *outAspect = curCamera->aspect; if(outZNear != NULL) *outZNear = curCamera->zNear; if(outZFar != NULL) *outZFar = curCamera->zFar; } - -void + +void M3rCamera_GetViewData( M3tGeomCamera* inCamera, M3tPoint3D *outCameraLocation, @@ -691,11 +691,11 @@ M3rCamera_GetViewData_VxU( UUmAssert(curCamera != NULL && curCamera->inUse == UUcTrue); UUmAssertReadPtr(outViewXUp, sizeof(*outViewXUp)); - + *outViewXUp = curCamera->crossVector; } -void +void M3rCamera_GetWorldFrustum( M3tGeomCamera* inCamera, M3tPoint3D *outPointList, @@ -703,32 +703,32 @@ M3rCamera_GetWorldFrustum( { M3tManager_GeomCamera* curCamera; UUtUns16 i; - + curCamera = (M3tManager_GeomCamera*)inCamera; UUmAssert(curCamera != NULL && curCamera->inUse == UUcTrue); UUmAssert(curCamera->staticSet == UUcTrue && curCamera->viewSet == UUcTrue); - + MSiCamera_UpdateWorldFrustum(curCamera); - + for(i = 0; i < 6; i++) { outPointList[i] = curCamera->worldFrustumPoints[i]; outPlaneEquList[i] = curCamera->worldFrustumPlanes[i]; } - + outPointList[6] = curCamera->worldFrustumPoints[6]; outPointList[7] = curCamera->worldFrustumPoints[7]; } -void +void M3rCamera_DrawWorldFrustum( M3tGeomCamera* inCamera) { M3tManager_GeomCamera* curCamera; - + curCamera = (M3tManager_GeomCamera*)inCamera; UUmAssert(curCamera != NULL && curCamera->inUse == UUcTrue); - + MSiCamera_UpdateWorldFrustum(curCamera); // Draw the near plane @@ -748,7 +748,7 @@ M3rCamera_DrawWorldFrustum( curCamera->worldFrustumPoints + 3, curCamera->worldFrustumPoints + 0, IMcShade_Blue); - + // Draw the far plane M3rGeom_Line_Light( curCamera->worldFrustumPoints + 4, @@ -766,44 +766,44 @@ M3rCamera_DrawWorldFrustum( curCamera->worldFrustumPoints + 7, curCamera->worldFrustumPoints + 4, IMcShade_Red); - + // Draw the frustum from the viewpoint to the near plane M3rGeom_Line_Light( &curCamera->cameraLocation, curCamera->worldFrustumPoints + 0, IMcShade_White); - + M3rGeom_Line_Light( &curCamera->cameraLocation, curCamera->worldFrustumPoints + 1, IMcShade_White); - + M3rGeom_Line_Light( &curCamera->cameraLocation, curCamera->worldFrustumPoints + 2, IMcShade_White); - + M3rGeom_Line_Light( &curCamera->cameraLocation, curCamera->worldFrustumPoints +3, IMcShade_White); - + // Draw the frustum from the near plane to the far plane M3rGeom_Line_Light( curCamera->worldFrustumPoints + 4, curCamera->worldFrustumPoints + 0, IMcShade_White); - + M3rGeom_Line_Light( curCamera->worldFrustumPoints + 5, curCamera->worldFrustumPoints + 1, IMcShade_White); - + M3rGeom_Line_Light( curCamera->worldFrustumPoints + 6, curCamera->worldFrustumPoints + 2, IMcShade_White); - + M3rGeom_Line_Light( curCamera->worldFrustumPoints + 7, curCamera->worldFrustumPoints + 3, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Geom_Matrix.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Geom_Matrix.c index a53e149..0595f02 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Geom_Matrix.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Geom_Matrix.c @@ -1,12 +1,12 @@ /* FILE: Motoko_Geom_Matrix.c - + AUTHOR: Brent H. Pease - + CREATED: April 2, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -20,7 +20,7 @@ typedef struct M3tManager_MatrixGlobals { - + /* Model matrix stack */ UUtInt32 matrix_TOS; M3tMatrix4x3* matrixStack; @@ -39,11 +39,11 @@ M3rMatrixStack_Push( UUmError_ReturnOnErrorMsg(UUcError_Generic, "Stack overflow"); } - M3gManager_MatrixGlobals.matrix_TOS++; - M3gManager_MatrixGlobals.matrixStackTop++; - + M3gManager_MatrixGlobals.matrix_TOS++; + M3gManager_MatrixGlobals.matrixStackTop++; + *M3gManager_MatrixGlobals.matrixStackTop = *(M3gManager_MatrixGlobals.matrixStackTop - 1); - + MSmStackVerify(); return UUcError_None; @@ -54,7 +54,7 @@ M3rMatrixStack_Get( M3tMatrix4x3* *outMatrix) { *outMatrix = M3gManager_MatrixGlobals.matrixStackTop; - + return UUcError_None; } @@ -66,41 +66,41 @@ M3rMatrixStack_Pop( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Stack underflow"); } - M3gManager_MatrixGlobals.matrix_TOS--; - M3gManager_MatrixGlobals.matrixStackTop--; - + M3gManager_MatrixGlobals.matrix_TOS--; + M3gManager_MatrixGlobals.matrixStackTop--; + MSmStackVerify(); return UUcError_None; } - + void M3rMatrixStack_Identity( void) { M3tMatrix4x3* matrix = M3gManager_MatrixGlobals.matrixStackTop; - + matrix->m[0][0] = 1.0f; matrix->m[0][1] = 0.0f; matrix->m[0][2] = 0.0f; - + matrix->m[1][0] = 0.0f; matrix->m[1][1] = 1.0f; matrix->m[1][2] = 0.0f; - + matrix->m[2][0] = 0.0f; matrix->m[2][1] = 0.0f; matrix->m[2][2] = 1.0f; - + matrix->m[3][0] = 0.0f; matrix->m[3][1] = 0.0f; matrix->m[3][2] = 0.0f; MSmStackVerify(); - + } -void +void M3rMatrixStack_Clear( void) { @@ -109,7 +109,7 @@ M3rMatrixStack_Clear( M3rMatrixStack_Identity(); } -void +void M3rMatrixStack_Rotate( float inRadians, float inX, @@ -122,14 +122,14 @@ M3rMatrixStack_Rotate( UUmAssert(inY > -1e9f && inY < 1e9f); UUmAssert(inZ > -1e9f && inZ < 1e9f); UUmAssertTrigRange(inRadians); - + MUrMatrix_BuildRotate( inRadians, inX, inY, inZ, &matrix); - + MSmMatrixVerify(&matrix); MUrMatrix_Multiply( M3gManager_MatrixGlobals.matrixStackTop, @@ -137,22 +137,22 @@ M3rMatrixStack_Rotate( M3gManager_MatrixGlobals.matrixStackTop); MSmStackVerify(); } - + void M3rMatrixStack_UniformScale( float inScale) { MUrMatrixStack_Scale(M3gManager_MatrixGlobals.matrixStackTop, inScale); } - -void + +void M3rMatrixStack_Translate( float inX, float inY, float inZ) { M3tVector3D translate; - + UUmAssert(inY > -1e9f && inY < 1e9f); UUmAssert(inZ > -1e9f && inZ < 1e9f); @@ -189,9 +189,9 @@ M3rManager_Matrix_Initialize( M3gManager_MatrixGlobals.matrix_TOS = -1; M3gManager_MatrixGlobals.matrixStack = UUrMemory_Block_New(sizeof(M3tMatrix4x4) * M3cModelMatrix_MaxDepth); UUmError_ReturnOnNull(M3gManager_MatrixGlobals.matrixStack); - + M3gManager_MatrixGlobals.matrixStackTop = M3gManager_MatrixGlobals.matrixStack; - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Manager.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Manager.c index c4e8007..bad8785 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Manager.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Manager.c @@ -1,12 +1,12 @@ /* FILE: Motoko_Manager.c - + AUTHOR: Brent H. Pease - + CREATED: May 5, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997-1999 */ @@ -98,19 +98,19 @@ M3iGeometryProcHandler( switch(inMessage) { - case TMcTemplateProcMessage_LoadPostProcess: + case TMcTemplateProcMessage_LoadPostProcess: M3gNumPoints += geometry->pointArray->numPoints; M3gNumObjs++; case TMcTemplateProcMessage_Update: #if defined(DEBUGGING) && DEBUGGING - + error = M3rVerify_Geometry(geometry); - + #endif - + geometry->geometryFlags |= M3cGeometryFlag_RemoveBackface; - + if(geometry->baseMap != NULL) { switch(geometry->baseMap->texelType) @@ -124,12 +124,12 @@ M3iGeometryProcHandler( break; } } - + break; case TMcTemplateProcMessage_NewPostProcess: break; - + case TMcTemplateProcMessage_PrepareForUse: break; } @@ -146,10 +146,10 @@ M3iBigTextureInit( // calculate the number of sub_textures needed inTextureMap->num_x = inTextureMap->width / M3cTextureMap_MaxWidth; inTextureMap->num_y = inTextureMap->height / M3cTextureMap_MaxHeight; - + if ((inTextureMap->width & (M3cTextureMap_MaxWidth - 1)) > 0) inTextureMap->num_x++; if ((inTextureMap->height & (M3cTextureMap_MaxHeight - 1)) > 0) inTextureMap->num_y++; - + return UUcError_None; } @@ -165,7 +165,7 @@ M3iBigTextureUpdate( { TMrInstance_Update(inTextureMap->textures[i]); } - + return UUcError_None; } @@ -178,35 +178,35 @@ M3iBigTextureProcHandler( { UUtError error; M3tTextureMap_Big *texture_map; - + UUmAssert(inInstancePtr); - + // get a pointer to the texture map texture_map = (M3tTextureMap_Big*)inInstancePtr; - + switch(inMessage) { case TMcTemplateProcMessage_NewPostProcess: break; - + case TMcTemplateProcMessage_LoadPostProcess: error = M3iBigTextureInit(texture_map); UUmError_ReturnOnError(error); break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: error = M3iBigTextureUpdate(texture_map); UUmError_ReturnOnError(error); break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } @@ -230,41 +230,41 @@ static UUtUns32 M3rCacheProc_ComputeSize( void* inInstanceData) { - + return 0; } -UUtError +UUtError M3rInitialize( void) { UUtError error; - + UUmAssert(M3cDrawStateIntType_NumTypes <= 32); // make sure we can fit in a UUtUns32 UUrStartupMessage("initializing 3D display system.."); - + /* * Register our templates */ error = M3rRegisterTemplates(); UUmError_ReturnOnError(error); - + M3gNumDrawEngines = 0; M3gNumGeomEngines = 0; - + error = M3rSort_Initialize(); UUmError_ReturnOnError(error); - + M3gSIMDPresent = UUrPlatform_SIMD_IsPresent(); - - + + UUrStartupMessage("initializing geometry engines..."); - + UUrStartupMessage("initializing draw engines..."); -/* good-bye, Glide! - if (!ONgCommandLine.useOpenGL) +/* good-bye, Glide! + if (!ONgCommandLine.useOpenGL) { MGrDrawEngine_Initialize(); } @@ -284,45 +284,45 @@ M3rInitialize( //RVrDrawEngine_Initialize(); //MSrDrawEngine_Initialize(); - + MSrGeomEngine_Initialize(); #ifndef __ONADA__ OGrGeomEngine_Initialize(); #endif - + #if UUmPlatform == UUmPlatform_Win32 //MDrDrawEngine_Initialize(); - + #endif - + error = M3rManager_Matrix_Initialize(); UUmError_ReturnOnError(error); - + error = M3rManager_Texture_Initialize(); UUmError_ReturnOnError(error); - - error = + + error = TMrTemplate_PrivateData_New( M3cTemplate_TextureMap_Big, 0, M3iBigTextureProcHandler, &M3gTemplate_TextureMapBig_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install big texture proc handler"); - - error = + + error = TMrTemplate_PrivateData_New( M3cTemplate_Geometry, 0, M3iGeometryProcHandler, &M3gTemplate_Geometry_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install geomety private data"); - + return UUcError_None; } -void +void M3rTerminate( void) { @@ -330,7 +330,7 @@ M3rTerminate( #if UUmPlatform == UUmPlatform_Win32 //MDrDrawEngine_Terminate(); #endif - + //GLrDrawEngine_Terminate(); //MGrDrawEngine_Terminate(); //MSrDrawEngine_Terminate(); @@ -363,15 +363,15 @@ M3rDrawEngine_MakeActive( UUtUns16 inDisplayModeIndex) // Only relevent for full screen mode { // UUmAssert(M3gGeomContext == NULL); -S.S. resolution changing caused this assert to fire - + UUmAssert(inDrawEngineIndex < M3gNumDrawEngines); - + M3gActiveDrawEngine = inDrawEngineIndex; M3gActiveDisplayDevice = inDisplayDeviceIndex; M3gActiveDisplayMode = inDisplayModeIndex; - + M3gFullScreen = inFullScreen; - + return UUcError_None; } @@ -384,11 +384,11 @@ M3rGeomEngine_MakeActive( UUtUns16 inGeomEngineIndex) { // UUmAssert(M3gGeomContext == NULL); -S.S. resolution swicthing code hits this - + UUmAssert(inGeomEngineIndex < M3gNumGeomEngines); M3gActiveGeomEngine = inGeomEngineIndex; - + return UUcError_None; } @@ -423,10 +423,10 @@ M3rDrawContext_New( UUtError error; UUmAssert(M3gActiveDrawEngine != 0xFFFF); - + error = M3rDraw_State_Initialize(); UUmError_ReturnOnError(error); - + error = M3gDrawEngineList[M3gActiveDrawEngine].methods.contextPrivateNew( inDrawContextDescriptor, @@ -434,15 +434,15 @@ M3rDrawContext_New( M3gFullScreen, &M3gManagerDrawContext.apiIndex); UUmError_ReturnOnErrorMsg(error, "Could not create draw context private"); - - error = + + error = TMrTemplate_CallProc( M3cTemplate_TextureMap, TMcTemplateProcMessage_LoadPostProcess); UUmError_ReturnOnError(error); - + M3gManagerDrawContext.bitVector = NULL; - + // initially we are not sorting M3gDraw_Sorting = UUcFalse; @@ -457,11 +457,11 @@ M3rDrawContext_Delete( TMrTemplate_CallProc( M3cTemplate_TextureMap, TMcTemplateProcMessage_DisposePreProcess); - + M3rDraw_State_Terminate(); - + M3gDrawEngineList[M3gActiveDrawEngine].methods.contextPrivateDelete(); - + if(M3gManagerDrawContext.bitVector != NULL) { UUrBitVector_Dispose(M3gManagerDrawContext.bitVector); @@ -475,45 +475,45 @@ M3rDrawContext_ResetTextures( M3gDrawEngineList[M3gActiveDrawEngine].methods.textureResetAll(); } -UUtError +UUtError M3rGeomContext_New( M3tDrawContextDescriptor* inDrawContextDescriptor) { UUtError error; - - // check to make sure that the active draw engine is compatable with this geom engine + + // check to make sure that the active draw engine is compatable with this geom engine if(((1 << M3gActiveDrawEngine) & M3gGeomEngineList[M3gActiveGeomEngine].caps.compatibleDrawEngineBV) == 0) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "active draw and geom engines are not compatable"); } - + error = M3rDrawContext_New( inDrawContextDescriptor); UUmError_ReturnOnErrorMsg(error, "Could not setup draw context"); - + error = M3gGeomEngineList[M3gActiveGeomEngine].methods.contextPrivateNew( inDrawContextDescriptor, &M3gManagerGeomContext.geomContext); UUmError_ReturnOnErrorMsg(error, "Could not setup draw context private"); - + UUmAssert(M3gManagerGeomContext.geomContext != NULL); if(M3gManagerGeomContext.geomContext == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not setup draw context private"); } - + // Initialize the camera M3rManager_Camera_Initialize(); - + error = M3rGeom_State_Initialize(); UUmError_ReturnOnError(error); - + M3gGeomContext = M3gManagerGeomContext.geomContext; M3rMatrixStack_Clear(); - + return UUcError_None; } @@ -521,37 +521,37 @@ void M3rGeomContext_Delete( void) { - + M3rGeom_State_Terminate(); - + M3gGeomEngineList[M3gActiveGeomEngine].methods.contextPrivateDelete(); - + M3rDrawContext_Delete(); - + M3gGeomContext = NULL; } -UUtError +UUtError M3rManager_Register_DrawEngine( M3tDrawEngineCaps* inDrawEngineCaps, M3tDrawEngineMethods* inDrawEngineMethods) { M3gDrawEngineList[M3gNumDrawEngines].methods = *inDrawEngineMethods; M3gDrawEngineList[M3gNumDrawEngines].caps = *inDrawEngineCaps; - + M3gNumDrawEngines++; - + return UUcError_None; } -UUtError +UUtError M3rManager_Register_GeomEngine( M3tGeomEngineCaps* inGeomEngineCaps, M3tGeomEngineMethods* inGeomEngineMethods) { M3gGeomEngineList[M3gNumGeomEngines].methods = *inGeomEngineMethods; M3gGeomEngineList[M3gNumGeomEngines].caps = *inGeomEngineCaps; - + M3gNumGeomEngines++; return UUcError_None; @@ -569,7 +569,7 @@ M3rDrawEngine_GetCaps( UUtUns16 inDrawEngineIndex) { UUmAssert(inDrawEngineIndex < M3gNumDrawEngines); - + return &M3gDrawEngineList[inDrawEngineIndex].caps; } @@ -585,18 +585,18 @@ M3rGeomEngine_GetCaps( UUtUns16 inGeomEngineIndex) { UUmAssert(inGeomEngineIndex < M3gNumGeomEngines); - + return &M3gGeomEngineList[inGeomEngineIndex].caps; } -void +void M3rGeometry_MultiplyAndDraw( M3tGeometry *inGeometryObject, const M3tMatrix4x3 *inMatrix) { M3rMatrixStack_Push(); - + M3rMatrixStack_Multiply(inMatrix); M3rGeometry_Draw(inGeometryObject); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Manager.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Manager.h index 05d7a7b..96bc11b 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Manager.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Manager.h @@ -1,12 +1,12 @@ /* FILE: Motoko_Manager.h - + AUTHOR: Brent H. Pease - + CREATED: May 5, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -28,7 +28,7 @@ typedef struct M3tManager_GeomCamera UUtBool staticSet; // has static been set? UUtBool viewSet; // has view data been set? UUtBool pad; - + M3tPoint3D cameraLocation; M3tVector3D viewVector; M3tVector3D upVector; @@ -37,21 +37,21 @@ typedef struct M3tManager_GeomCamera float aspect; float zNear; float zFar; - + M3tMatrix4x4 matrix_viewToFrustum; M3tMatrix4x4 matrix_frustumToView; - + M3tMatrix4x4 matrix_worldToView; M3tMatrix4x4 matrix_viewToWorld; M3tMatrix4x4 matrix_worldToFrustum; M3tMatrix4x4 matrix_frustumToWorld; - + M3tVector3D viewFrustumNormals[6]; M3tPlaneEquation worldFrustumPlanes[6]; M3tPoint3D worldFrustumPoints[8]; - + } M3tManager_GeomCamera; /* @@ -59,23 +59,23 @@ typedef struct M3tManager_GeomCamera */ /* * Frame functions - */ - typedef UUtError + */ + typedef UUtError (*M3tDrawContextMethod_Frame_Start)( UUtUns32 inGameTime); - - typedef UUtError + + typedef UUtError (*M3tDrawContextMethod_Frame_End)( UUtUns32 *outTextureBytesDownloaded); - typedef UUtError + typedef UUtError (*M3tDrawContextMethod_Frame_Sync)( void); - + /* * 2 1/2 D triangles */ - + typedef void (*M3tDrawContextMethod_Triangle)( void* inTriangle); @@ -86,7 +86,7 @@ typedef struct M3tManager_GeomCamera typedef void (*M3tDrawContextMethod_Quad)( void* inQuad); - + /* * Pent functions, these are generated by the clipper */ @@ -105,7 +105,7 @@ typedef struct M3tManager_GeomCamera typedef void (*M3tDrawContextMethod_Point)( M3tPointScreen* inCoord); - + /* * Bitmap drawing */ @@ -113,7 +113,7 @@ typedef struct M3tManager_GeomCamera (*M3tDrawContextMethod_TriSprite)( const M3tPointScreen *inPoints, // points[3] const M3tTextureCoord *inTextureCoords); // UVs[3] - + typedef void (*M3tDrawContextMethod_Sprite)( const M3tPointScreen *inPoints, // topleft, botright @@ -126,9 +126,9 @@ typedef struct M3tManager_GeomCamera const UUtUns32 *inColors, const UUtUns32 inCount ); - typedef UUtError + typedef UUtError (*M3tDrawContextMethod_ScreenCapture)( - const UUtRect* inRect, + const UUtRect* inRect, void* outBuffer); typedef UUtBool @@ -171,21 +171,21 @@ typedef struct M3tManager_GeomCamera M3tDrawContextMethod_Frame_Start frameStart; M3tDrawContextMethod_Frame_End frameEnd; M3tDrawContextMethod_Frame_Sync frameSync; - + M3tDrawContextMethod_Triangle triangle; M3tDrawContextMethod_Quad quad; M3tDrawContextMethod_Pent pent; - + M3tDrawContextMethod_Line line; M3tDrawContextMethod_Point point; - + M3tDrawContextMethod_TriSprite triSprite; M3tDrawContextMethod_Sprite sprite; M3tDrawContextMethod_SpriteArray spriteArray; M3tDrawContextMethod_ScreenCapture screenCapture; M3tDrawContextMethod_PointVisible pointVisible; M3tDrawContextMethod_SupportPointVisibility supportPointVisible; - + M3tDrawContextMethod_TextureFormatAvailable textureFormatAvailable; M3tDrawContextMethod_ChangeMode changeMode; @@ -205,28 +205,28 @@ typedef struct M3tManager_GeomCamera UUtBool inFullScreen, M3tDrawAPI *outAPI); - /* + /* * Engine draw context private delete */ typedef void (*M3tDrawEngineMethod_ContextPrivateDelete)( void); - + /* * Reset the entire texture state, including animated textures */ typedef void (*M3tDrawEngineMethod_Texture_ResetAll)( void); - + // This lets the engine allocate a new private state structure typedef UUtError (*M3tDrawEngineMethod_PrivateState_New)( void* inState_Private); - + // This lets the engine delete a new private state structure - typedef void + typedef void (*M3tDrawEngineMethod_PrivateState_Delete)( void* inState_Private); - + // This lets the engine update the state according to the update flags typedef UUtError (*M3tDrawEngineMethod_State_Update)( @@ -235,24 +235,24 @@ typedef struct M3tManager_GeomCamera const UUtInt32* inState_Int, UUtInt32 inState_PtrFlags, void** inState_Ptr); - + // This lets the engine allocate a new private state structure typedef UUtError (*M3tGeomEngineMethod_PrivateState_New)( void* inState_Private); - + // This lets the engine delete a new private state structure - typedef void + typedef void (*M3tGeomEngineMethod_PrivateState_Delete)( void* inState_Private); - + // This lets the engine update the state according to the update flags typedef UUtError (*M3tGeomEngineMethod_State_Update)( void* inState_Private, UUtUns16 inState_IntFlags, const UUtInt32* inState_Int); - + /* * Geom Engine methods */ @@ -269,14 +269,14 @@ typedef struct M3tManager_GeomCamera typedef UUtError (*M3tGeomEngineMethod_ContextSetEnvironment)( struct AKtEnvironment* inEnvironment); - /* + /* * Engine draw context private delete */ typedef void (*M3tGeomEngineMethod_ContextPrivateDelete)( void); - /* - * + /* + * */ typedef void (*M3tGeomEngineMethod_UpdateNotification)( void); @@ -286,12 +286,12 @@ typedef struct M3tDrawEngineMethods M3tDrawEngineMethod_ContextPrivateNew contextPrivateNew; M3tDrawEngineMethod_ContextPrivateDelete contextPrivateDelete; M3tDrawEngineMethod_Texture_ResetAll textureResetAll; - + UUtUns32 privateStateSize; M3tDrawEngineMethod_PrivateState_New privateStateNew; M3tDrawEngineMethod_PrivateState_Delete privateStateDelete; M3tDrawEngineMethod_State_Update privateStateUpdate; - + } M3tDrawEngineMethods; typedef struct M3tGeomEngineMethods @@ -304,11 +304,11 @@ typedef struct M3tGeomEngineMethods M3tGeomEngineMethod_PrivateState_New privateStateNew; M3tGeomEngineMethod_PrivateState_Delete privateStateDelete; M3tGeomEngineMethod_State_Update privateStateUpdate; - + M3tGeomEngineMethod_UpdateNotification cameraViewUpdate; M3tGeomEngineMethod_UpdateNotification cameraStaticUpdate; - - + + } M3tGeomEngineMethods; extern TMtPrivateData* M3gTemplate_Geometry_PrivateData; @@ -321,9 +321,9 @@ extern TMtPrivateData* M3gTemplate_Geometry_PrivateData; */ typedef void (*M3rDraw_Triangle_Func)(void *inTriangle); - + M3rDraw_Triangle_Func M3rDraw_GetTriangleFunction(); - + void M3rDraw_Triangle( void* inTriangle); // vertex type is specified via M3tDrawStateIntType_VertexFormat @@ -334,7 +334,7 @@ extern TMtPrivateData* M3gTemplate_Geometry_PrivateData; void M3rDraw_Quad( void* inQuad); // vertex type is specified via M3tDrawStateIntType_VertexFormat - + /* * Pent functions, these are generated by the clipper */ @@ -353,15 +353,15 @@ extern TMtPrivateData* M3gTemplate_Geometry_PrivateData; void M3rDraw_Point( M3tPointScreen* inCoord); - + /* * */ - + void M3rManager_Camera_UpdateMatrices( M3tManager_GeomCamera* inCamera); - + void M3rManager_Camera_Initialize( void); @@ -372,11 +372,11 @@ extern TMtPrivateData* M3gTemplate_Geometry_PrivateData; UUtError M3rManager_Matrix_Initialize( void); - + void M3rManager_Matrix_Terminate( void); - + /* * Functions to Register Motoko engines */ @@ -389,9 +389,9 @@ extern TMtPrivateData* M3gTemplate_Geometry_PrivateData; M3rManager_Register_GeomEngine( M3tGeomEngineCaps* inGeomEngineCaps, M3tGeomEngineMethods* inGeomEngineMethods); - + /* - * + * */ void M3rManager_GetActiveDrawEngine( diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Private.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Private.h index fe9a85c..1d825e6 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Private.h @@ -1,12 +1,12 @@ /* FILE: Motoko_Private.h - + AUTHOR: Brent H. Pease - + CREATED: May 13, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -21,15 +21,15 @@ typedef struct M3tManagerDrawContext { M3tDrawContextMethods* drawFuncs; // This is the context presented to the app - + UUtUns16 width; UUtUns16 height; UUtUns32* bitVector; - + M3tPointScreen* pointArray; M3tTextureCoord* baseUVArray; UUtUns32* shadeArray; - + M3tDrawAPI apiIndex; } M3tManagerDrawContext; @@ -37,7 +37,7 @@ typedef struct M3tManagerDrawContext typedef struct M3tManagerGeomContext { M3tGeomContextMethods* geomContext; - + } M3tManagerGeomContext; typedef struct M3tManagerTextureData @@ -52,14 +52,14 @@ typedef struct M3tManagerDrawEngine { M3tDrawEngineCaps caps; M3tDrawEngineMethods methods; - + } M3tManagerDrawEngine; typedef struct M3tManagerGeomEngine { M3tGeomEngineCaps caps; M3tGeomEngineMethods methods; - + } M3tManagerGeomEngine; extern M3tManagerDrawContext M3gManagerDrawContext; @@ -90,7 +90,7 @@ M3rDraw_State_Terminate( UUtError M3rGeom_State_Initialize( void); - + void M3rGeom_State_Terminate( void); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Sort.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Sort.c index 7898ab0..896222f 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Sort.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Sort.c @@ -1,12 +1,12 @@ /* FILE: Motoko_Draw.c - + AUTHOR: Brent H. Pease - + CREATED: Dec 12, 1998 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -36,7 +36,7 @@ typedef struct M3tSort_State UUtUns8 alpha; UUtBool fog; // S.S. UUtBool blend_with_constant_alpha; - + } M3tSort_State; //--------------------------------------------------- @@ -56,7 +56,7 @@ typedef struct M3tSort_State M3tPointScreen points[4]; M3tTextureCoord baseUVs[4]; UUtUns32 shades[4]; - + } M3tSort_Quad; //--------------------------------------------------- @@ -66,7 +66,7 @@ typedef struct M3tSort_State M3tPointScreen points[5]; M3tTextureCoord baseUVs[5]; UUtUns32 shades[5]; - + } M3tSort_Pent; //--------------------------------------------------- @@ -75,7 +75,7 @@ typedef struct M3tSort_State M3tSort_State state; M3tPointScreen points[2]; M3tTextureCoord textureCoords[4]; - + } M3tSort_Sprite; typedef void @@ -86,7 +86,7 @@ typedef struct M3tSort_Object { M3tSort_DrawFunc drawFunc; void* objPtr; - + } M3tSort_Object; static UUtUns16 gNumObjects = 0; @@ -146,24 +146,24 @@ M3iSort_Draw_Triangle( M3tSort_Triangle* inTriangle) { M3tTri triangle; - + M3iSort_Draw_SetState(&inTriangle->state); M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenPointArray, inTriangle->points); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_TextureCoordArray, inTriangle->baseUVs); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenShadeArray_DC, inTriangle->shades); - + M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, - 3); + 3); M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateUpdate( (char*)M3gDrawStatePrivateStack + M3gDrawStateTOS * M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateSize, @@ -171,14 +171,14 @@ M3iSort_Draw_Triangle( M3gDrawStateInt, M3gDrawState_PtrFlags, M3gDrawStatePtr); - + M3gDrawState_IntFlags = 0; M3gDrawState_PtrFlags = 0; - + triangle.indices[0] = 0; triangle.indices[1] = 1; triangle.indices[2] = 2; - + M3gManagerDrawContext.drawFuncs->triangle( &triangle); } @@ -189,24 +189,24 @@ M3iSort_Draw_Quad( M3tSort_Quad* inQuad) { M3tQuad quad; - + M3iSort_Draw_SetState(&inQuad->state); M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenPointArray, inQuad->points); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_TextureCoordArray, inQuad->baseUVs); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenShadeArray_DC, inQuad->shades); - + M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, - 4); + 4); M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateUpdate( (char*)M3gDrawStatePrivateStack + M3gDrawStateTOS * M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateSize, @@ -214,15 +214,15 @@ M3iSort_Draw_Quad( M3gDrawStateInt, M3gDrawState_PtrFlags, M3gDrawStatePtr); - + M3gDrawState_IntFlags = 0; M3gDrawState_PtrFlags = 0; - + quad.indices[0] = 0; quad.indices[1] = 1; quad.indices[2] = 2; quad.indices[3] = 3; - + M3gManagerDrawContext.drawFuncs->quad( &quad); } @@ -233,21 +233,21 @@ M3iSort_Draw_Pent( M3tSort_Pent* inPent) { M3tPent pent; - + M3iSort_Draw_SetState(&inPent->state); M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenPointArray, inPent->points); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_TextureCoordArray, inPent->baseUVs); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_ScreenShadeArray_DC, inPent->shades); - + M3rDraw_State_SetInt( M3cDrawStateIntType_NumRealVertices, 5); // we know that this does not matter @@ -258,16 +258,16 @@ M3iSort_Draw_Pent( M3gDrawStateInt, M3gDrawState_PtrFlags, M3gDrawStatePtr); - + M3gDrawState_IntFlags = 0; M3gDrawState_PtrFlags = 0; - + pent.indices[0] = 0; pent.indices[1] = 1; pent.indices[2] = 2; pent.indices[3] = 3; pent.indices[4] = 4; - + M3gManagerDrawContext.drawFuncs->pent( &pent); } @@ -279,14 +279,14 @@ M3iSort_Draw_Sprite( { M3iSort_Draw_SetState(&inSprite->state); - + M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateUpdate( (char*)M3gDrawStatePrivateStack + M3gDrawStateTOS * M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateSize, M3gDrawState_IntFlags, M3gDrawStateInt, M3gDrawState_PtrFlags, M3gDrawStatePtr); - + M3gDrawState_IntFlags = 0; M3gDrawState_PtrFlags = 0; @@ -296,13 +296,13 @@ M3iSort_Draw_Sprite( } static void M3iSort_Draw_BuildState(M3tSort_State *outState) -{ +{ outState->appearence = (UUtUns8)M3rDraw_State_GetInt(M3cDrawStateIntType_Appearence); outState->interpolation = (UUtUns8)M3rDraw_State_GetInt(M3cDrawStateIntType_Interpolation); outState->fill = (UUtUns8)M3rDraw_State_GetInt(M3cDrawStateIntType_Fill); outState->zCompare = (UUtUns8)M3rDraw_State_GetInt(M3cDrawStateIntType_ZCompare); outState->constantColor = M3rDraw_State_GetInt(M3cDrawStateIntType_ConstantColor); - outState->alpha = (UUtUns8)M3rDraw_State_GetInt(M3cDrawStateIntType_Alpha); + outState->alpha = (UUtUns8)M3rDraw_State_GetInt(M3cDrawStateIntType_Alpha); outState->textureMap = M3rDraw_State_GetPtr(M3cDrawStatePtrType_BaseTextureMap); outState->fog= (UUtBool)M3rDraw_State_GetInt(M3cDrawStateIntType_Fog); outState->blend_with_constant_alpha = (UUtBool) M3rDraw_State_GetInt(M3cDrawStateIntType_FrameBufferBlendWithConstantAlpha); @@ -316,7 +316,7 @@ M3iSort_AddObject( void* inObjPtr, float inW) { - if (gNumObjects >= M3cMaxSortedObjects) + if (gNumObjects >= M3cMaxSortedObjects) { static UUtUns32 last_time = 0; @@ -344,7 +344,7 @@ M3rSort_Initialize( gNumObjects = 0; gMemoryPool = UUrMemory_Pool_New(M3cMaxSortedObjects * sizeof(M3tSort_Pent), UUcPool_Growable); UUmError_ReturnOnNull(gMemoryPool); - + return UUcError_None; } @@ -362,11 +362,11 @@ UUtError M3rSort_Frame_Start( void) { - + gNumObjects = 0; - + UUrMemory_Pool_Reset(gMemoryPool); - + return UUcError_None; } @@ -390,11 +390,11 @@ M3rSort_Frame_End( //UUtBool oldSorting; if(gNumObjects == 0) return UUcError_None; - + M3gDrawContext_Counters.numAlphaSortedObjs += gNumObjects; - + M3rDraw_State_Push(); - + M3rDraw_State_SetInt( M3cDrawStateIntType_VertexFormat, M3cDrawStateVertex_Unified); @@ -402,13 +402,13 @@ M3rSort_Frame_End( M3rDraw_State_SetInt( M3cDrawStateIntType_Clipping, 0); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_VertexBitVector, NULL); - + AUrQSort_16(gSortedObjIndexList, gNumObjects, iObject_List_Compare); - + for(itr = 0; itr < gNumObjects; itr++) { UUtUns16 index = gSortedObjIndexList[itr]; @@ -416,17 +416,17 @@ M3rSort_Frame_End( UUmAssert(index < gNumObjects); curObj = gObjList + index; - + curObj->drawFunc( curObj->objPtr); } - + M3rDraw_State_Pop(); - + return UUcError_None; } -void +void M3rSort_Draw_Triangle( M3tTri* inTri) { @@ -435,11 +435,11 @@ M3rSort_Draw_Triangle( M3tPointScreen* pointArray; UUtUns32* shadeArray; M3tSort_Triangle* triangle; - + pointArray = M3gManagerDrawContext.pointArray; baseUVArray = M3gManagerDrawContext.baseUVArray; shadeArray = M3gManagerDrawContext.shadeArray; - + UUmAssertReadPtr(pointArray, sizeof(M3tPoint3D)); triangle = UUrMemory_Pool_Block_New(gMemoryPool, sizeof(M3tSort_Triangle)); @@ -452,17 +452,17 @@ M3rSort_Draw_Triangle( M3iSort_Draw_BuildState(&triangle->state); w = UUmMin3( - pointArray[inTri->indices[0]].invW, - pointArray[inTri->indices[1]].invW, + pointArray[inTri->indices[0]].invW, + pointArray[inTri->indices[1]].invW, pointArray[inTri->indices[2]].invW); - + UUmAssert(pointArray[inTri->indices[0]].x < 2000.0f); UUmAssert(pointArray[inTri->indices[1]].x < 2000.0f); UUmAssert(pointArray[inTri->indices[2]].x < 2000.0f); UUmAssert(pointArray[inTri->indices[0]].y < 2000.0f); UUmAssert(pointArray[inTri->indices[1]].y < 2000.0f); UUmAssert(pointArray[inTri->indices[2]].y < 2000.0f); - + triangle->points[0] = pointArray[inTri->indices[0]]; triangle->points[1] = pointArray[inTri->indices[1]]; triangle->points[2] = pointArray[inTri->indices[2]]; @@ -475,7 +475,7 @@ M3rSort_Draw_Triangle( triangle->baseUVs[1] = baseUVArray[inTri->indices[1]]; triangle->baseUVs[2] = baseUVArray[inTri->indices[2]]; } - + if(triangle->state.interpolation == M3cDrawState_Interpolation_Vertex) { UUmAssertReadPtr(shadeArray, sizeof(UUtUns16)); @@ -488,7 +488,7 @@ M3rSort_Draw_Triangle( UUmAssert(M3rVerify_PointScreen(triangle->points + 0) == UUcError_None); UUmAssert(M3rVerify_PointScreen(triangle->points + 1) == UUcError_None); UUmAssert(M3rVerify_PointScreen(triangle->points + 2) == UUcError_None); - + M3iSort_AddObject( (M3tSort_DrawFunc)M3iSort_Draw_Triangle, triangle, @@ -503,10 +503,10 @@ M3rSort_Draw_TriSplit( M3tTextureCoord* baseUVArray; M3tPointScreen* pointArray; M3tSort_Triangle* triangle; - + pointArray = M3gManagerDrawContext.pointArray; baseUVArray = M3gManagerDrawContext.baseUVArray; - + UUmAssertReadPtr(pointArray, sizeof(M3tPoint3D)); UUmAssertReadPtr(baseUVArray, sizeof(M3tTextureCoord)); @@ -520,14 +520,14 @@ M3rSort_Draw_TriSplit( M3iSort_Draw_BuildState(&triangle->state); w = UUmMin3( - pointArray[inTriSplit->vertexIndices.indices[0]].invW, - pointArray[inTriSplit->vertexIndices.indices[1]].invW, + pointArray[inTriSplit->vertexIndices.indices[0]].invW, + pointArray[inTriSplit->vertexIndices.indices[1]].invW, pointArray[inTriSplit->vertexIndices.indices[2]].invW); triangle->points[0] = pointArray[inTriSplit->vertexIndices.indices[0]]; triangle->points[1] = pointArray[inTriSplit->vertexIndices.indices[1]]; triangle->points[2] = pointArray[inTriSplit->vertexIndices.indices[2]]; - + triangle->baseUVs[0] = baseUVArray[inTriSplit->baseUVIndices.indices[0]]; triangle->baseUVs[1] = baseUVArray[inTriSplit->baseUVIndices.indices[1]]; triangle->baseUVs[2] = baseUVArray[inTriSplit->baseUVIndices.indices[2]]; @@ -535,14 +535,14 @@ M3rSort_Draw_TriSplit( UUmAssert(M3rVerify_PointScreen(triangle->points + 0) == UUcError_None); UUmAssert(M3rVerify_PointScreen(triangle->points + 1) == UUcError_None); UUmAssert(M3rVerify_PointScreen(triangle->points + 2) == UUcError_None); - + M3iSort_AddObject( (M3tSort_DrawFunc)M3iSort_Draw_Triangle, triangle, w); } -void +void M3rSort_Draw_Quad( M3tQuad* inQuad) { @@ -551,11 +551,11 @@ M3rSort_Draw_Quad( M3tPointScreen* pointArray; UUtUns32* shadeArray; M3tSort_Quad* quad; - + pointArray = M3gManagerDrawContext.pointArray; baseUVArray = M3gManagerDrawContext.baseUVArray; shadeArray = M3gManagerDrawContext.shadeArray; - + UUmAssertReadPtr(pointArray, sizeof(M3tPoint3D)); quad = UUrMemory_Pool_Block_New(gMemoryPool, sizeof(M3tSort_Quad)); @@ -568,11 +568,11 @@ M3rSort_Draw_Quad( M3iSort_Draw_BuildState(&quad->state); w = UUmMin4( - pointArray[inQuad->indices[0]].invW, - pointArray[inQuad->indices[1]].invW, + pointArray[inQuad->indices[0]].invW, + pointArray[inQuad->indices[1]].invW, pointArray[inQuad->indices[2]].invW, pointArray[inQuad->indices[3]].invW); - + quad->points[0] = pointArray[inQuad->indices[0]]; quad->points[1] = pointArray[inQuad->indices[1]]; quad->points[2] = pointArray[inQuad->indices[2]]; @@ -587,7 +587,7 @@ M3rSort_Draw_Quad( quad->baseUVs[2] = baseUVArray[inQuad->indices[2]]; quad->baseUVs[3] = baseUVArray[inQuad->indices[3]]; } - + if(quad->state.interpolation == M3cDrawState_Interpolation_Vertex) { UUmAssertReadPtr(shadeArray, sizeof(UUtUns16)); @@ -617,10 +617,10 @@ M3rSort_Draw_QuadSplit( M3tTextureCoord* baseUVArray; M3tPointScreen* pointArray; M3tSort_Quad* quad; - + pointArray = M3gManagerDrawContext.pointArray; baseUVArray = M3gManagerDrawContext.baseUVArray; - + UUmAssertReadPtr(pointArray, sizeof(M3tPoint3D)); UUmAssertReadPtr(baseUVArray, sizeof(M3tTextureCoord)); @@ -634,8 +634,8 @@ M3rSort_Draw_QuadSplit( M3iSort_Draw_BuildState(&quad->state); w = UUmMin4( - pointArray[inQuadSplit->vertexIndices.indices[0]].invW, - pointArray[inQuadSplit->vertexIndices.indices[1]].invW, + pointArray[inQuadSplit->vertexIndices.indices[0]].invW, + pointArray[inQuadSplit->vertexIndices.indices[1]].invW, pointArray[inQuadSplit->vertexIndices.indices[2]].invW, pointArray[inQuadSplit->vertexIndices.indices[3]].invW); @@ -653,14 +653,14 @@ M3rSort_Draw_QuadSplit( UUmAssert(M3rVerify_PointScreen(quad->points + 1) == UUcError_None); UUmAssert(M3rVerify_PointScreen(quad->points + 2) == UUcError_None); UUmAssert(M3rVerify_PointScreen(quad->points + 3) == UUcError_None); - + M3iSort_AddObject( (M3tSort_DrawFunc)M3iSort_Draw_Quad, quad, w); } -void +void M3rSort_Draw_Pent( M3tPent* inPent) { @@ -669,11 +669,11 @@ M3rSort_Draw_Pent( M3tPointScreen* pointArray; UUtUns32* shadeArray; M3tSort_Pent* pent; - + pointArray = M3gManagerDrawContext.pointArray; baseUVArray = M3gManagerDrawContext.baseUVArray; shadeArray = M3gManagerDrawContext.shadeArray; - + UUmAssertReadPtr(pointArray, sizeof(M3tPoint3D)); pent = UUrMemory_Pool_Block_New(gMemoryPool, sizeof(M3tSort_Pent)); @@ -686,8 +686,8 @@ M3rSort_Draw_Pent( M3iSort_Draw_BuildState(&pent->state); w = UUmMin5( - pointArray[inPent->indices[0]].invW, - pointArray[inPent->indices[1]].invW, + pointArray[inPent->indices[0]].invW, + pointArray[inPent->indices[1]].invW, pointArray[inPent->indices[2]].invW, pointArray[inPent->indices[3]].invW, pointArray[inPent->indices[4]].invW); @@ -697,7 +697,7 @@ M3rSort_Draw_Pent( pent->points[2] = pointArray[inPent->indices[2]]; pent->points[3] = pointArray[inPent->indices[3]]; pent->points[4] = pointArray[inPent->indices[4]]; - + if(pent->state.appearence != M3cDrawState_Appearence_Gouraud) { UUmAssertReadPtr(baseUVArray, sizeof(M3tTextureCoord)); @@ -708,7 +708,7 @@ M3rSort_Draw_Pent( pent->baseUVs[3] = baseUVArray[inPent->indices[3]]; pent->baseUVs[4] = baseUVArray[inPent->indices[4]]; } - + if(pent->state.interpolation == M3cDrawState_Interpolation_Vertex) { UUmAssertReadPtr(shadeArray, sizeof(UUtUns16)); @@ -725,7 +725,7 @@ M3rSort_Draw_Pent( UUmAssert(M3rVerify_PointScreen(pent->points + 2) == UUcError_None); UUmAssert(M3rVerify_PointScreen(pent->points + 3) == UUcError_None); UUmAssert(M3rVerify_PointScreen(pent->points + 4) == UUcError_None); - + M3iSort_AddObject( (M3tSort_DrawFunc)M3iSort_Draw_Pent, pent, @@ -740,13 +740,13 @@ M3rSort_Draw_PentSplit( M3tTextureCoord* baseUVArray; M3tPointScreen* pointArray; M3tSort_Pent* pent; - + pointArray = M3gManagerDrawContext.pointArray; baseUVArray = M3gManagerDrawContext.baseUVArray; - + UUmAssertReadPtr(pointArray, sizeof(M3tPoint3D)); UUmAssertReadPtr(baseUVArray, sizeof(M3tTextureCoord)); - + pent = UUrMemory_Pool_Block_New(gMemoryPool, sizeof(M3tSort_Pent)); if(pent == NULL) { @@ -757,8 +757,8 @@ M3rSort_Draw_PentSplit( M3iSort_Draw_BuildState(&pent->state); w = UUmMin5( - pointArray[inPentSplit->vertexIndices.indices[0]].invW, - pointArray[inPentSplit->vertexIndices.indices[1]].invW, + pointArray[inPentSplit->vertexIndices.indices[0]].invW, + pointArray[inPentSplit->vertexIndices.indices[1]].invW, pointArray[inPentSplit->vertexIndices.indices[2]].invW, pointArray[inPentSplit->vertexIndices.indices[3]].invW, pointArray[inPentSplit->vertexIndices.indices[4]].invW); @@ -768,7 +768,7 @@ M3rSort_Draw_PentSplit( pent->points[2] = pointArray[inPentSplit->vertexIndices.indices[2]]; pent->points[3] = pointArray[inPentSplit->vertexIndices.indices[3]]; pent->points[4] = pointArray[inPentSplit->vertexIndices.indices[4]]; - + pent->baseUVs[0] = baseUVArray[inPentSplit->baseUVIndices.indices[0]]; pent->baseUVs[1] = baseUVArray[inPentSplit->baseUVIndices.indices[1]]; pent->baseUVs[2] = baseUVArray[inPentSplit->baseUVIndices.indices[2]]; @@ -780,7 +780,7 @@ M3rSort_Draw_PentSplit( UUmAssert(M3rVerify_PointScreen(pent->points + 2) == UUcError_None); UUmAssert(M3rVerify_PointScreen(pent->points + 3) == UUcError_None); UUmAssert(M3rVerify_PointScreen(pent->points + 4) == UUcError_None); - + M3iSort_AddObject( (M3tSort_DrawFunc)M3iSort_Draw_Pent, pent, @@ -793,7 +793,7 @@ M3rSort_Draw_Sprite( const M3tTextureCoord *inTextureCoords) { M3tSort_Sprite* sprite; - + sprite = UUrMemory_Pool_Block_New(gMemoryPool, sizeof(M3tSort_Sprite)); if(sprite == NULL) { @@ -802,14 +802,14 @@ M3rSort_Draw_Sprite( } M3iSort_Draw_BuildState(&sprite->state); - + sprite->points[0] = inPoints[0]; sprite->points[1] = inPoints[1]; sprite->textureCoords[0] = inTextureCoords[0]; sprite->textureCoords[1] = inTextureCoords[1]; sprite->textureCoords[2] = inTextureCoords[2]; sprite->textureCoords[3] = inTextureCoords[3]; - + M3iSort_AddObject( (M3tSort_DrawFunc)M3iSort_Draw_Sprite, sprite, diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Sort.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Sort.h index 9c57923..e291458 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Sort.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Sort.h @@ -1,12 +1,12 @@ /* FILE: Motoko_Sort.h - + AUTHOR: Brent H. Pease - + CREATED: Dec 12, 1998 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -21,7 +21,7 @@ UUtError M3rSort_Frame_End( void); -void +void M3rSort_Draw_Triangle( M3tTri* inTri); @@ -29,7 +29,7 @@ void M3rSort_Draw_TriSplit( M3tTriSplit* inTri); -void +void M3rSort_Draw_Quad( M3tQuad* inQuad); @@ -37,7 +37,7 @@ void M3rSort_Draw_QuadSplit( M3tQuadSplit* inQuad); -void +void M3rSort_Draw_Pent( M3tPent* inPent); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_State_Draw.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_State_Draw.c index a8b074e..de23ab4 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_State_Draw.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_State_Draw.c @@ -1,12 +1,12 @@ /* FILE: Motoko_State_Draw.c - + AUTHOR: Brent H. Pease - + CREATED: July 28, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997-1999 */ @@ -25,7 +25,7 @@ void* M3gDrawStatePrivateStack; void** M3gDrawStatePtr; UUtInt32* M3gDrawStateInt; - + UUtUns32 M3gDrawState_IntFlags; UUtUns32 M3gDrawState_PtrFlags; @@ -59,7 +59,7 @@ M3iResolveTexture(M3tTextureMap *inTexture, UUtUns32 inTime) } else { time = inTime; } - + if (inTexture->flags & M3cTextureFlags_Anim_RandomStart) { time += M3gDrawStateInt[M3cDrawStateIntType_TextureInstance]; @@ -72,10 +72,10 @@ M3iResolveTexture(M3tTextureMap *inTexture, UUtUns32 inTime) // this code is to try to make our seed useful for the random // code, should get pushed up to a higher level UUgLocalRandomSeed = 0xfdedfded; - UUgLocalRandomSeed ^= - ((seed & 0x000000ff) << 24) | - ((seed & 0x0000ff00) << 8) | - ((seed & 0x00ff0000) >> 8) | + UUgLocalRandomSeed ^= + ((seed & 0x000000ff) << 24) | + ((seed & 0x0000ff00) << 8) | + ((seed & 0x00ff0000) >> 8) | ((seed & 0xff000000) >> 24); frame = UUmLocalRandomRange(0, animation->numFrames); @@ -119,43 +119,43 @@ M3rDraw_State_Initialize( void) { UUtUns16 stateItr; - + M3gDrawStateTOS = 0; M3gDrawState_IntFlags = UUcMaxUns32; M3gDrawState_PtrFlags = UUcMaxUns32; - + for(stateItr = 0; stateItr < M3cStateStack_MaxDepth; stateItr++) { M3gDrawStatePtrStack[stateItr] = UUrMemory_Block_New(sizeof(void*) * M3cDrawStatePtrType_NumTypes); M3gDrawStateIntStack[stateItr] = UUrMemory_Block_New(sizeof(UUtUns32) * M3cDrawStateIntType_NumTypes); } - + M3gDrawStatePtr = M3gDrawStatePtrStack[M3gDrawStateTOS]; M3gDrawStateInt = M3gDrawStateIntStack[M3gDrawStateTOS]; - + M3gDrawStatePrivateStack = NULL; - + if(M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateSize != 0) { M3gDrawStatePrivateStack = UUrMemory_Block_New( - M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateSize * + M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateSize * M3cStateStack_MaxDepth); UUmError_ReturnOnNull(M3gDrawStatePrivateStack); for(stateItr = 0; stateItr < M3cStateStack_MaxDepth; stateItr++) { M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateNew( - (void*)((char*)M3gDrawStatePrivateStack + + (void*)((char*)M3gDrawStatePrivateStack + M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateSize * stateItr)); } } - + UUrMemory_Clear(M3gDrawStateInt, sizeof(UUtUns32) * M3cDrawStateIntType_NumTypes); UUrMemory_Clear(M3gDrawStatePtr, sizeof(void*) * M3cDrawStatePtrType_NumTypes); - + M3gDrawStateInt[M3cDrawStateIntType_Alpha] = 0xFF; - + return UUcError_None; } @@ -164,7 +164,7 @@ M3rDraw_State_Terminate( void) { UUtUns16 stateItr; - + for(stateItr = 0; stateItr < M3cStateStack_MaxDepth; stateItr++) { UUrMemory_Block_Delete(M3gDrawStatePtrStack[stateItr]); @@ -176,10 +176,10 @@ M3rDraw_State_Terminate( for(stateItr = 0; stateItr < M3cStateStack_MaxDepth; stateItr++) { M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateDelete( - (void*)((char*)M3gDrawStatePrivateStack + + (void*)((char*)M3gDrawStatePrivateStack + M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateSize * stateItr)); } - + UUrMemory_Block_Delete(M3gDrawStatePrivateStack); M3gDrawStatePrivateStack = NULL; } @@ -193,7 +193,7 @@ M3rDraw_GetWidth( displayDevices[M3gActiveDisplayDevice]. displayModes[M3gActiveDisplayMode].width; } - + UUtUns16 M3rDraw_GetHeight( void) @@ -209,10 +209,10 @@ M3rDraw_State_SetInt( UUtInt32 inDrawState) { UUmAssert(inDrawStateType < M3cDrawStateIntType_NumTypes); - + if(inDrawStateType != M3cDrawStateIntType_NumRealVertices && M3gDrawStateInt[inDrawStateType] == inDrawState) return; - + M3gDrawStateInt[inDrawStateType] = inDrawState; M3gDrawState_IntFlags |= (1 << (UUtUns32)inDrawStateType); } @@ -225,7 +225,7 @@ M3rDraw_State_GetInt( return M3gDrawStateInt[inDrawStateType]; } - + void M3rDraw_State_SetPtr( M3tDrawStatePtrType inDrawStateType, @@ -247,7 +247,7 @@ M3rDraw_State_GetPtr( UUmAssert(inDrawStateType < M3cDrawStatePtrType_NumTypes); return M3gDrawStatePtr[inDrawStateType]; } - + UUtError M3rDraw_State_Push( void) @@ -258,23 +258,23 @@ M3rDraw_State_Push( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Stack too deep"); } - + UUrMemory_MoveFast( M3gDrawStateInt, M3gDrawStateIntStack[M3gDrawStateTOS], sizeof(UUtUns32) * M3cDrawStateIntType_NumTypes); - + UUrMemory_MoveFast( M3gDrawStatePtr, M3gDrawStatePtrStack[M3gDrawStateTOS], sizeof(UUtUns32) * M3cDrawStatePtrType_NumTypes); - + M3gDrawStatePtr = M3gDrawStatePtrStack[M3gDrawStateTOS]; M3gDrawStateInt = M3gDrawStateIntStack[M3gDrawStateTOS]; return UUcError_None; } - + UUtError M3rDraw_State_Pop( void) @@ -287,13 +287,13 @@ M3rDraw_State_Pop( M3gDrawStateTOS--; M3gDrawState_IntFlags = UUcMaxUns32; M3gDrawState_PtrFlags = UUcMaxUns32; - + M3gDrawStatePtr = M3gDrawStatePtrStack[M3gDrawStateTOS]; M3gDrawStateInt = M3gDrawStateIntStack[M3gDrawStateTOS]; return UUcError_None; } - + UUtError M3rDraw_State_Commit( void) @@ -304,23 +304,23 @@ M3rDraw_State_Commit( UUtInt32 alpha; time = M3gDrawStateInt[M3cDrawStateIntType_Time]; - + if(M3gDrawState_PtrFlags & (1 << M3cDrawStatePtrType_BaseTextureMap)) { - M3gDrawStatePtr[M3cDrawStatePtrType_BaseTextureMap] = + M3gDrawStatePtr[M3cDrawStatePtrType_BaseTextureMap] = M3iResolveTexture( M3gDrawStatePtr[M3cDrawStatePtrType_BaseTextureMap], time); } - + if(M3gDrawState_PtrFlags & (1 << M3cDrawStatePtrType_LightTextureMap)) { - M3gDrawStatePtr[M3cDrawStatePtrType_LightTextureMap] = + M3gDrawStatePtr[M3cDrawStatePtrType_LightTextureMap] = M3iResolveTexture( M3gDrawStatePtr[M3cDrawStatePtrType_LightTextureMap], time); } - + texture = M3gDrawStatePtr[M3cDrawStatePtrType_BaseTextureMap]; alpha = M3gDrawStateInt[M3cDrawStateIntType_Alpha]; @@ -331,7 +331,7 @@ M3rDraw_State_Commit( if((texture != NULL) && (texture->flags & M3cTextureFlags_Blend_Additive)) M3gDraw_Sorting = UUcTrue; #endif - if (M3gDrawStateInt[M3cDrawStateIntType_SubmitMode] == M3cDrawState_SubmitMode_SortAlphaTris) + if (M3gDrawStateInt[M3cDrawStateIntType_SubmitMode] == M3cDrawState_SubmitMode_SortAlphaTris) { M3gDraw_Sorting = alpha < 0xff; @@ -348,7 +348,7 @@ M3rDraw_State_Commit( } else if (texture->flags & M3cTextureFlags_ReceivesEnvMap) { - // CB: + // CB: M3gDraw_Sorting = UUcFalse; } else @@ -360,12 +360,12 @@ M3rDraw_State_Commit( else { M3gDraw_Sorting = UUcFalse; } - + if(M3gDraw_Sorting) { M3gDraw_Vertex_Unified = M3gDrawStateInt[M3cDrawStateIntType_VertexFormat] == M3cDrawStateVertex_Unified; /* - } + } if(M3gDraw_Sorting) { */ @@ -373,8 +373,8 @@ M3rDraw_State_Commit( M3gManagerDrawContext.baseUVArray = (M3tTextureCoord*)M3gDrawStatePtr[M3cDrawStatePtrType_TextureCoordArray]; M3gManagerDrawContext.shadeArray = (UUtUns32*)M3gDrawStatePtr[M3cDrawStatePtrType_ScreenShadeArray_DC]; } - - error = + + error = M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateUpdate( (char*)M3gDrawStatePrivateStack + M3gDrawStateTOS * M3gDrawEngineList[M3gActiveDrawEngine].methods.privateStateSize, M3gDrawState_IntFlags, @@ -382,7 +382,7 @@ M3rDraw_State_Commit( M3gDrawState_PtrFlags, M3gDrawStatePtr); UUmError_ReturnOnError(error); - + M3gDrawState_IntFlags = 0; M3gDrawState_PtrFlags = 0; diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_State_Geom.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_State_Geom.c index 1d043b5..bb2d5c6 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_State_Geom.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_State_Geom.c @@ -1,12 +1,12 @@ /* FILE: Motoko_State_Geom.c - + AUTHOR: Brent H. Pease - + CREATED: July 28, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997-1999 */ @@ -33,27 +33,27 @@ M3rGeom_State_Initialize( M3gGeomStateTOS = 0; M3gGeomState_IntFlags = 0xFFFF; M3gGeomStateInt = M3gGeomStateIntStack[M3gGeomStateTOS]; - + if(M3gGeomEngineList[M3gActiveGeomEngine].methods.privateStateSize != 0) { M3gGeomStatePrivateStack = UUrMemory_Block_New( - M3gGeomEngineList[M3gActiveGeomEngine].methods.privateStateSize * + M3gGeomEngineList[M3gActiveGeomEngine].methods.privateStateSize * M3cStateStack_MaxDepth); UUmError_ReturnOnNull(M3gGeomStatePrivateStack); for(stateItr = 0; stateItr < M3cStateStack_MaxDepth; stateItr++) { M3gGeomEngineList[M3gActiveGeomEngine].methods.privateStateNew( - (void*)((char*)M3gGeomStatePrivateStack + + (void*)((char*)M3gGeomStatePrivateStack + M3gGeomEngineList[M3gActiveGeomEngine].methods.privateStateSize * stateItr)); } } - + UUrMemory_Clear(M3gGeomStateInt, sizeof(UUtUns32) * M3cGeomStateIntType_NumTypes); - + return UUcError_None; - + } void @@ -61,13 +61,13 @@ M3rGeom_State_Terminate( void) { UUtUns16 stateItr; - + if(M3gGeomStatePrivateStack != NULL) { for(stateItr = 0; stateItr < M3cStateStack_MaxDepth; stateItr++) { M3gGeomEngineList[M3gActiveGeomEngine].methods.privateStateDelete( - (void*)((char*)M3gGeomStatePrivateStack + + (void*)((char*)M3gGeomStatePrivateStack + M3gGeomEngineList[M3gActiveGeomEngine].methods.privateStateSize * stateItr)); } } @@ -79,7 +79,7 @@ M3rGeom_State_Set( UUtInt32 inState) { if(M3gGeomStateInt[inGeomStateIntType] == inState) return; - + M3gGeomStateInt[inGeomStateIntType] = inState; M3gGeomState_IntFlags |= (1 << (UUtUns16)inGeomStateIntType); } @@ -96,21 +96,21 @@ M3rGeom_State_Push( void) { M3gGeomStateTOS++; - + if(M3gGeomStateTOS >= M3cStateStack_MaxDepth) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Stack too deep"); } - + UUrMemory_MoveFast( M3gGeomStateInt, M3gGeomStateIntStack[M3gGeomStateTOS], sizeof(UUtUns32) * M3cGeomStateIntType_NumTypes); - + M3gGeomStateInt = M3gGeomStateIntStack[M3gGeomStateTOS]; - + M3rDraw_State_Push(); - + return UUcError_None; } @@ -122,14 +122,14 @@ M3rGeom_State_Pop( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Stack underflow"); } - + M3rDraw_State_Pop(); - + M3gGeomStateTOS--; M3gGeomState_IntFlags = 0xFFFF; - + M3gGeomStateInt = M3gGeomStateIntStack[M3gGeomStateTOS]; - + return UUcError_None; } @@ -160,25 +160,25 @@ M3rGeom_State_Commit( case M3cGeomState_Fill_Point: UUmAssert(0); break; - + case M3cGeomState_Fill_Line: M3rDraw_State_SetInt( M3cDrawStateIntType_Fill, M3cDrawState_Fill_Line); break; - + case M3cGeomState_Fill_Solid: M3rDraw_State_SetInt( M3cDrawStateIntType_Fill, M3cDrawState_Fill_Solid); break; - + default: UUmAssert(0); break; } } - + if(M3gGeomState_IntFlags & (1 << M3cGeomStateIntType_Appearance)) { switch(M3gGeomStateInt[M3cGeomStateIntType_Appearance]) @@ -188,13 +188,13 @@ M3rGeom_State_Commit( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Gouraud); break; - + case M3cGeomState_Appearance_Texture: M3rDraw_State_SetInt( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Texture_Lit); break; - + default: UUmAssert(0); break; @@ -216,13 +216,13 @@ M3rGeom_State_Commit( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); break; - + default: UUmAssert(0); break; } } - error = + error = M3gGeomEngineList[M3gActiveGeomEngine].methods.privateStateUpdate( (char*)M3gGeomStatePrivateStack + M3gGeomStateTOS * M3gGeomEngineList[M3gActiveGeomEngine].methods.privateStateSize, M3gGeomState_IntFlags, @@ -230,8 +230,8 @@ M3rGeom_State_Commit( UUmError_ReturnOnError(error); M3gGeomState_IntFlags = 0; - + M3rDraw_State_Commit(); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Texture.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Texture.c index 6b79e91..d4b3b17 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Texture.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Texture.c @@ -64,7 +64,7 @@ M3iTextureByteSwapper( // swap texels individually numTexels = IMrImage_NumPixels(hasMipMap, inTextureMap->width, inTextureMap->height); } - + switch(inTextureMap->texelType) { case IMcPixelType_DXT1: @@ -86,14 +86,14 @@ M3iTextureByteSwapper( UUrSwap_2Byte(sp++); } break; - + case IMcPixelType_I8: case IMcPixelType_I1: case IMcPixelType_A8: case IMcPixelType_A4I4: // does not need swapping break; - + case IMcPixelType_ARGB8888: case IMcPixelType_RGB888: // needs 4 byte swapping @@ -103,11 +103,11 @@ M3iTextureByteSwapper( UUrSwap_4Byte(lp++); } break; - + default: UUmAssert(!"Unknown texture format"); } - + return; } @@ -121,7 +121,7 @@ M3rTextureMap_Prepare_Internal( // CB: this texturemap has permanently-resident data that must be byte-swapped now void *offset; UUtBool swap; - + // CB: note that I changed this code so that it no longer sets the flag // M3cTextureFlags_LittleEndian after it byte-swaps a texture. this means // that we will incorrectly double byte-swap if someone clears the @@ -208,7 +208,7 @@ M3rTextureMap_TemporarilyLoad_Internal( if (error == UUcError_None) { UUtBool swap; - + // set up the texture so that it points to the temporary storage ioTextureMap->pixels = (void *) M3gManager_TextureStorage.temporaryStorage; M3gManager_TextureStorage.temporaryTexture = ioTextureMap; @@ -259,13 +259,13 @@ M3rTextureMap_New( UUmAssert(inWidth > 0); UUmAssert(inHeight > 0); UUmAssertReadPtr(outTextureMap, sizeof(*outTextureMap)); - + // calculate the width, height, and rowbytes of the texture M3rTextureMap_GetTextureSize(inWidth, inHeight, &width, &height); hasMipMap = (inFlags & M3cTextureFlags_HasMipMap) ? IMcHasMipMap : IMcNoMipMap; size_of_texture = IMrImage_ComputeSize(inTexelType, hasMipMap, width, height); - + // create a new instance of the texture if (inAllocMemory & M3cTexture_AllocMemory) { @@ -283,9 +283,9 @@ M3rTextureMap_New( UUmError_ReturnOnErrorMsg(error, "Unable to create a new texture."); #if 0 - UUrDebuggerMessage("texture %s ptr %x %s\n", - inDebugName, - new_texture_map, + UUrDebuggerMessage("texture %s ptr %x %s\n", + inDebugName, + new_texture_map, (inAllocMemory & M3cTexture_UseTempMem) ? "temporary" : "permanent"); #endif @@ -313,11 +313,11 @@ M3rTextureMap_New( if (new_texture_map->pixels == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to allocate the pixels."); } - + // update the texture map data error = TMrInstance_Update(new_texture_map); UUmError_ReturnOnErrorMsg(error, "Unable to update the data of the texture."); - + // save the outgoing texture map *outTextureMap = new_texture_map; @@ -339,8 +339,8 @@ M3rTextureMap_Big_New( M3tTextureMap_Big *new_texture_map; UUtUns16 num_x; - UUtUns16 num_y; - + UUtUns16 num_y; + UUtUns16 x; UUtUns16 y; @@ -348,14 +348,14 @@ M3rTextureMap_Big_New( UUmAssert(inWidth > 0); UUmAssert(inHeight > 0); UUmAssertReadPtr(outTextureMap, sizeof(*outTextureMap)); - + // calculate the number of M3tTextureMaps it will take to hold the texture num_x = inWidth / M3cTextureMap_MaxWidth; num_y = inHeight / M3cTextureMap_MaxHeight; - + if ((inWidth & (M3cTextureMap_MaxWidth - 1)) > 0) num_x++; if ((inHeight & (M3cTextureMap_MaxHeight - 1)) > 0) num_y++; - + // create a new instance of the M3tTextureMap_Big error = TMrInstance_Dynamic_New( @@ -364,7 +364,7 @@ M3rTextureMap_Big_New( num_x * num_y, &new_texture_map); UUmError_ReturnOnErrorMsg(error, "Unable to create a new texture."); - + // set up the texture map new_texture_map->width = inWidth; new_texture_map->height = inHeight; @@ -381,20 +381,20 @@ M3rTextureMap_Big_New( UUtUns16 top; UUtUns16 texture_width; UUtUns16 texture_height; - + UUtUns16 index; - + M3tTextureMap *texture; - + // calculate the index number of the texture index = x + (y * num_x); - + // calculate the texture width and height left = (x * M3cTextureMap_MaxWidth); top = (y * M3cTextureMap_MaxHeight); texture_width = UUmMin(M3cTextureMap_MaxWidth, inWidth - left); texture_height = UUmMin(M3cTextureMap_MaxHeight, inHeight - top); - + // create a new texture error = M3rTextureMap_New( @@ -406,15 +406,15 @@ M3rTextureMap_Big_New( inDebugName, &texture); UUmError_ReturnOnErrorMsg(error, "Unable to create texture map"); - + // save the texture pointer new_texture_map->textures[index] = texture; } } - + // save the new texture *outTextureMap = new_texture_map; - + return UUcError_None; } @@ -436,7 +436,7 @@ void M3rTextureMap_Big_Unload(M3tTextureMap_Big *inTextureMap) if (NULL == texture) { continue; } - + M3rDraw_Texture_Unload(texture); } @@ -490,7 +490,7 @@ M3rTextureMap_Big_Fill( { UUtUns16 x; UUtUns16 y; - + for (y = 0; y < inTextureMap->num_y; y++) { for (x = 0; x < inTextureMap->num_x; x++) @@ -499,13 +499,13 @@ M3rTextureMap_Big_Fill( UUtRect *bounds_ptr; UUtUns16 index; M3tTextureMap *texture; - + // calculate the index of the texture index = x + (y * inTextureMap->num_x); - + // get a pointer to the current texture texture = inTextureMap->textures[index]; - + if (inBounds == M3cFillEntireMap) { // set bounds ptr @@ -514,23 +514,23 @@ M3rTextureMap_Big_Fill( else { UUtRect texture_rect; - + // set bounds ptr bounds_ptr = &bounds; - + // set the texture_rect texture_rect.left = x * M3cTextureMap_MaxWidth; texture_rect.top = y * M3cTextureMap_MaxHeight; texture_rect.right = texture_rect.left + texture->width; texture_rect.bottom = texture_rect.top + texture->height; - + // calculate the bounds to fill IMrRect_Intersect(inBounds, &texture_rect, &bounds); - + // offset the rect to the origin of the bitmap IMrRect_Offset(&bounds, -texture_rect.left, -texture_rect.top); } - + // fill in the texture map M3rTextureMap_Fill( texture, @@ -561,29 +561,29 @@ M3rTextureMap_Copy( // UUtUns16 dst_height; UUtUns16 dst_x; UUtUns16 dst_y; - + // get the template tags src_template_tag = TMrInstance_GetTemplateTag(inSrcTexture); dst_template_tag = TMrInstance_GetTemplateTag(inDstTexture); - + if (src_template_tag == M3cTemplate_TextureMap) { M3tTextureMap *src_texture = (M3tTextureMap*)inSrcTexture; - + M3rTextureMap_TemporarilyLoad(src_texture, 0); // calculate the source width and height src_width = (inSrcRect->right - inSrcRect->left); src_height = (inSrcRect->bottom - inSrcRect->top); - + // set the source location src_location.x = inSrcRect->left; src_location.y = inSrcRect->top; - + if (dst_template_tag == M3cTemplate_TextureMap) { M3tTextureMap *dst_texture = (M3tTextureMap*)inDstTexture; - + if ((src_texture->pixels == NULL) || (dst_texture->pixels == NULL)) { // CB: we cannot copy texturemaps that are not loaded (i.e. templated // data, not allocated data) @@ -599,7 +599,7 @@ M3rTextureMap_Copy( // set the destination location dst_location.x = inDstRect->left; dst_location.y = inDstRect->top; - + // copy the data IMrImage_Copy( src_width, @@ -619,9 +619,9 @@ M3rTextureMap_Copy( else if (dst_template_tag == M3cTemplate_TextureMap_Big) { M3tTextureMap_Big *dst_texture = (M3tTextureMap_Big*)inDstTexture; - + UUmAssert_Untested(); - + for (dst_y = 0; dst_y < dst_texture->num_y; dst_y++) { for (dst_x = 0; dst_x < dst_texture->num_x; dst_x++) @@ -630,11 +630,11 @@ M3rTextureMap_Copy( UUtUns16 index; UUtRect dst_bounds; UUtRect dst_rect; - + // get the texture[x][y] index = dst_x + (dst_y * dst_texture->num_x); texture = dst_texture->textures[index]; - + if ((src_texture->pixels == NULL) || (texture->pixels == NULL)) { // CB: we cannot copy texturemaps that are not loaded (i.e. templated // data, not allocated data) @@ -652,22 +652,22 @@ M3rTextureMap_Copy( dst_bounds.top = dst_y * M3cTextureMap_MaxHeight; dst_bounds.right = dst_bounds.left + texture->width; dst_bounds.bottom = dst_bounds.top + texture->height; - + // calculate the intersection IMrRect_Intersect(&dst_bounds, inDstRect, &dst_rect); - + // check to see if this texture map contains pixels that need // to be copied if (((dst_rect.right - dst_rect.left) == 0) || ((dst_rect.bottom - dst_rect.top) == 0)) continue; - + // move the rect toward the origin IMrRect_Offset(&dst_rect, -dst_bounds.left, -dst_bounds.top); - + // set the destination locatoin dst_location.x = dst_rect.left; dst_location.y = dst_rect.top; - + // copy the data IMrImage_Copy( src_width, @@ -746,33 +746,33 @@ M3rTextureRef_GetSize( TMtTemplateTag template_tag; UUtUns16 width; UUtUns16 height; - + template_tag = TMrInstance_GetTemplateTag(inTextureRef); - + if (template_tag == M3cTemplate_TextureMap) { M3tTextureMap *texture; texture = (M3tTextureMap*)inTextureRef; - + width = texture->width; height = texture->height; } else if (template_tag == M3cTemplate_TextureMap_Big) { M3tTextureMap_Big *texture_big; - + texture_big = (M3tTextureMap_Big*)inTextureRef; width = texture_big->width; height = texture_big->height; } - + if (outWidth) { *outWidth = width; } - + if (outHeight) { *outHeight = height; @@ -790,14 +790,14 @@ M3iTextureMap_CalcNearestPowerOfTwo( UUtUns16 inSize) { UUtInt16 num_bits = 15; - + if (inSize == 0) return 0; - + while(!(inSize & (1 << num_bits))) num_bits--; if (inSize > (1 << num_bits)) num_bits++; - + return (1 << num_bits); } @@ -822,7 +822,7 @@ M3rTextureMap_GetTextureSize( { height = width >> 3 /* S.S. / 8*/; } - + if (width < (height >> 3 /* S.S. / 8*/)) { width = height >> 3 /* S.S. / 8*/; @@ -879,7 +879,7 @@ static void iBuildMipMapRGB555(M3tTextureMap *inTextureMap, UUtUns16 width, UUtU red >>= 2; // S.S. /= 4; boxFilter = (1 << 15) | (red << 10) | (grn << 5) | (blu << 0); - + *dst++ = boxFilter; } } @@ -950,7 +950,7 @@ M3rTextureMap_BuildMipMap( } UUmError_ReturnOnError(error); - + width /= 2; height /= 2; @@ -959,7 +959,7 @@ M3rTextureMap_BuildMipMap( srcPtr = dstPtr; } - + return UUcError_None; } @@ -976,27 +976,27 @@ M3rTextureCoord_FindMinMax( float minU, minV; float maxU, maxV; float curU, curV; - + UUmAssertReadPtr(outMinU, sizeof(float)); UUmAssertReadPtr(outMinV, sizeof(float)); UUmAssertReadPtr(outMaxU, sizeof(float)); UUmAssertReadPtr(outMaxV, sizeof(float)); - + minU = minV = 1e9; maxU = maxV = -1e9; - + for(itr = 0; itr < inNumCoords; itr++) { curU = inTextureCoords[itr].u; curV = inTextureCoords[itr].v; - + if(curU < minU) minU = curU; if(curV < minV) minV = curV; - + if(curU > maxU) maxU = curU; if(curV > maxV) maxV = curV; } - + *outMinU = minU; *outMinV = minV; *outMaxU = maxU; @@ -1021,7 +1021,7 @@ M3rDraw_Sprite_Debug( UUtInt32 endY = inStartY + inHeight; UUtInt32 x; UUtInt32 y; - + if (inTextureMap->pixels == NULL) { // CB: we cannot display non-memory-resident texturemaps like this UUmAssert(!"M3rDraw_Sprite_Debug: cannot display texture, not loaded"); @@ -1090,7 +1090,7 @@ M3rDraw_Sprite_Debug( // br points[3].x += 5; points[3].y += 5; - + M3rDraw_Line(0, 3); // tl - br M3rDraw_Line(1, 2); // tr - bl } diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Utility.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Utility.c index b7b7d6f..38f02f9 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Utility.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Utility.c @@ -1,12 +1,12 @@ /* FILE: Motoko_Utility.c - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: May 5, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997-1999 */ @@ -64,7 +64,7 @@ UUtBool M3rIntersect_BBox( { M3tPoint3D bboxA[8]; M3tPoint3D bboxB[8]; - UUtUns16 bboxEdgeList[12][2] = + UUtUns16 bboxEdgeList[12][2] = { {0, 1}, {0, 2}, @@ -137,7 +137,7 @@ UUtBool M3rIntersect_BBox( * | ' | / * |' |/ * 1*-------------*5 - * + * * quads plane equ * ===== ======= * 0 1 3 2 -1, 0, 0, 0.x @@ -169,7 +169,7 @@ const M3tQuad M3gBBox_QuadList[6] = // Do NOT make this UUtUns8 { // Look-up table for which indices to use to form each box side { 0,1,3,2 }, // 0 { 4,6,7,5 }, // 1 - { 0,4,5,1 }, // 2 + { 0,4,5,1 }, // 2 { 2,3,7,6 }, // 3 { 0,2,6,4 }, // 4 { 1,5,7,3 } // 5 @@ -214,41 +214,41 @@ const M3tQuad *M3rBBox_GetSide( return result; } - + void M3rMinMaxBBox_To_BBox( - const M3tBoundingBox_MinMax *inBBox, + const M3tBoundingBox_MinMax *inBBox, M3tBoundingBox *outBoundingBox) { UUmAssertReadPtr(outBoundingBox, sizeof(*outBoundingBox)); - + outBoundingBox->localPoints[0].x = inBBox->minPoint.x; outBoundingBox->localPoints[0].y = inBBox->minPoint.y; outBoundingBox->localPoints[0].z = inBBox->minPoint.z; - + outBoundingBox->localPoints[1].x = inBBox->minPoint.x; outBoundingBox->localPoints[1].y = inBBox->minPoint.y; outBoundingBox->localPoints[1].z = inBBox->maxPoint.z; - + outBoundingBox->localPoints[2].x = inBBox->minPoint.x; outBoundingBox->localPoints[2].y = inBBox->maxPoint.y; outBoundingBox->localPoints[2].z = inBBox->minPoint.z; - + outBoundingBox->localPoints[3].x = inBBox->minPoint.x; outBoundingBox->localPoints[3].y = inBBox->maxPoint.y; outBoundingBox->localPoints[3].z = inBBox->maxPoint.z; - + outBoundingBox->localPoints[4].x = inBBox->maxPoint.x; outBoundingBox->localPoints[4].y = inBBox->minPoint.y; outBoundingBox->localPoints[4].z = inBBox->minPoint.z; - + outBoundingBox->localPoints[5].x = inBBox->maxPoint.x; outBoundingBox->localPoints[5].y = inBBox->minPoint.y; outBoundingBox->localPoints[5].z = inBBox->maxPoint.z; - + outBoundingBox->localPoints[6].x = inBBox->maxPoint.x; outBoundingBox->localPoints[6].y = inBBox->maxPoint.y; outBoundingBox->localPoints[6].z = inBBox->minPoint.z; - + outBoundingBox->localPoints[7].x = inBBox->maxPoint.x; outBoundingBox->localPoints[7].y = inBBox->maxPoint.y; outBoundingBox->localPoints[7].z = inBBox->maxPoint.z; @@ -331,7 +331,7 @@ void M3rBBox_To_EdgeBBox( M3tBoundingBox_Edge *outBoundingBox) { UUtUns16 edgeIndex; - + for (edgeIndex=0; edgeIndex<12; edgeIndex++) { outBoundingBox->edges[edgeIndex].a = inBoundingBox->localPoints[M3gBBox_EdgeList[edgeIndex][0]]; @@ -344,7 +344,7 @@ void M3rEdgeBBox_Offset( M3tPoint3D *inOffset) { UUtUns16 e; - + for (e=0; e<12; e++) { MUmVector_Increment(ioBoundingBox->edges[e].a,*inOffset); @@ -362,7 +362,7 @@ void M3rMinMaxBBox_Draw_Line( M3rMinMaxBBox_To_BBox(inMinMaxBBox, &bbox); - for(itr = 0; itr < 12; itr++) + for(itr = 0; itr < 12; itr++) { magicPoints[0] = bbox.localPoints[M3gBBox_EdgeList[itr][0]]; magicPoints[1] = bbox.localPoints[M3gBBox_EdgeList[itr][1]]; @@ -378,8 +378,8 @@ void M3rBBox_Draw_Line( UUtUns32 inShade) { UUtUns8 itr; - - for(itr = 0; itr < 12; itr++) + + for(itr = 0; itr < 12; itr++) { M3tPoint3D *from, *to; @@ -494,7 +494,7 @@ void M3rGeom_Line_Light(const M3tPoint3D *point1, const M3tPoint3D *point2, UUtU } -void +void M3rDraw_Bitmap( M3tTextureMap *inBitmap, const M3tPointScreen *inDestPoint, @@ -529,13 +529,13 @@ M3rDraw_Bitmap( // bl uv[2].u = 0.f; uv[2].v = uv[3].v; - + M3rDraw_State_Push(); M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, inBitmap); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Texture_Unlit); @@ -557,7 +557,7 @@ M3rDraw_Bitmap( M3cDrawState_Fill_Solid); M3rDraw_State_Commit(); - + M3rDraw_Sprite( screenPoints, uv); @@ -568,7 +568,7 @@ M3rDraw_Bitmap( } // ---------------------------------------------------------------------- -void +void M3rDraw_BitmapUV( M3tTextureMap *inBitmap, const M3tTextureCoord *inUV, @@ -584,13 +584,13 @@ M3rDraw_BitmapUV( screenPoints[1] = *inDestPoint; screenPoints[1].x = screenPoints[0].x + inWidth; screenPoints[1].y = screenPoints[0].y + inHeight; - + M3rDraw_State_Push(); M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, inBitmap); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Texture_Unlit); @@ -612,7 +612,7 @@ M3rDraw_BitmapUV( inAlpha); M3rDraw_State_Commit(); - + M3rDraw_Sprite( screenPoints, inUV); @@ -623,7 +623,7 @@ M3rDraw_BitmapUV( } // ---------------------------------------------------------------------- -void +void M3rDraw_BigBitmap( M3tTextureMap_Big *inBigBitmap, const M3tPointScreen *inDestPoint, @@ -634,7 +634,7 @@ M3rDraw_BigBitmap( { UUtUns16 x; UUtUns16 y; - + // draw the subtextures that are visible for (y = 0; y < inBigBitmap->num_y; y++) { @@ -645,30 +645,30 @@ M3rDraw_BigBitmap( M3tPointScreen dest_point; UUtUns16 width; UUtUns16 height; - - UUtInt16 temp; + + UUtInt16 temp; UUtInt32 x_times_maxwidth; UUtInt32 y_times_maxheight; - + // get a pointer to the texture to be drawn index = x + (y * inBigBitmap->num_x); texture = inBigBitmap->textures[index]; - + x_times_maxwidth = x * M3cTextureMap_MaxWidth; y_times_maxheight = y * M3cTextureMap_MaxHeight; - + // calculate the dest_point of the texture dest_point.x = inDestPoint->x + (float)x_times_maxwidth; dest_point.y = inDestPoint->y + (float)y_times_maxheight; dest_point.z = inDestPoint->z; dest_point.invW = inDestPoint->invW; - + // calculate the width and height temp = (UUtInt16)UUmMax(0, (UUtInt32)inWidth - x_times_maxwidth); width = UUmMin(M3cTextureMap_MaxWidth, (UUtUns16)temp); temp = (UUtInt16)UUmMax(0, (UUtInt32)inHeight - y_times_maxheight); height = UUmMin(M3cTextureMap_MaxHeight, (UUtUns16)temp); - + // draw the sub_texture M3rDraw_Bitmap( texture, @@ -686,9 +686,9 @@ UUtError M3rDrawEngine_FindGrayscalePixelType( { #define numGrayscaleTextureFormats 6 UUtUns16 itr; - + // array is in order of preference - IMtPixelType table[numGrayscaleTextureFormats] = + IMtPixelType table[numGrayscaleTextureFormats] = { IMcPixelType_I8, IMcPixelType_A4I4, @@ -724,27 +724,27 @@ M3rGroup_GetColor( GRtElementType elementType; GRtElementArray* array; char* string; - + error = GRrGroup_GetElement(inGroup, inVarName, &elementType, &array); if(error != UUcError_None) return error; - + if(elementType != GRcElementType_Array) return UUcError_Generic; - + error = GRrGroup_Array_GetElement(array, 0, &elementType, &string); if(error != UUcError_None) return error; if(elementType != GRcElementType_String) return UUcError_Generic; sscanf(string, "%f", &outColor->r); - + error = GRrGroup_Array_GetElement(array, 1, &elementType, &string); if(error != UUcError_None) return error; if(elementType != GRcElementType_String) return UUcError_Generic; sscanf(string, "%f", &outColor->g); - + error = GRrGroup_Array_GetElement(array, 2, &elementType, &string); if(error != UUcError_None) return error; if(elementType != GRcElementType_String) return UUcError_Generic; sscanf(string, "%f", &outColor->b); - + return UUcError_None; } @@ -777,7 +777,7 @@ void M3rDisplay_Circle(M3tPoint3D *inCenter, float inRadius, UUtUns32 inShade) /************** * Draws a wireframe circle in the XZ plane */ - + #define cNumPoints 16 M3tBoundingCircle circle; @@ -834,7 +834,7 @@ M3tTextureMap *M3rTextureMap_GetFromName(const char *inTemplateName) if (UUcError_None == error) { texture = dataPtr; - } + } return texture; } @@ -933,7 +933,7 @@ static void M3rOptimize_Setup(MXtNode *inNode) M3gOptimizeTriangles = UUrMemory_Block_New(sizeof(OptimizeTriangle) * inNode->numTriangles); - // pass 1: setup the list + // pass 1: setup the list for(itr = 0; itr < inNode->numTriangles; itr++) { UUtUns32 edge_itr; @@ -948,9 +948,9 @@ static void M3rOptimize_Setup(MXtNode *inNode) dst_face->used = 0; MUrVector_NormalFromPoints( - &inNode->points[src_face->indices[0]].point, - &inNode->points[src_face->indices[1]].point, - &inNode->points[src_face->indices[2]].point, + &inNode->points[src_face->indices[0]].point, + &inNode->points[src_face->indices[1]].point, + &inNode->points[src_face->indices[2]].point, &dst_face->normal); if (MUrVector_DotProduct(&src_face->dont_use_this_normal, &dst_face->normal) < 0.f) { @@ -1349,7 +1349,7 @@ static UUtBool build_quad( &node->points[quad->indices[C]].point, &node->points[quad->indices[D]].point, &normal1); - + if (success) { dot = normal0.x * normal1.x + normal0.y * normal1.y + normal0.z * normal1.z; if (dot < 0.8f) { @@ -1448,11 +1448,11 @@ void *M3rOptimizeNode( a= node->triangles[i].indices[A]; b= node->triangles[i].indices[B]; c= node->triangles[i].indices[C]; - + MUrVector_NormalFromPoints(&node->points[a].point, &node->points[b].point, &node->points[c].point, &triangle_datum[i].normal); - + length= triangle_datum[i].normal.x * triangle_datum[i].normal.x + triangle_datum[i].normal.y * triangle_datum[i].normal.y + triangle_datum[i].normal.z + triangle_datum[i].normal.z; @@ -1503,7 +1503,7 @@ void *M3rOptimizeNode( if they share an edge and are parallel, they are coplanar & therefor can be combined into a quad */ - + // ab == a'b' if (edge_shared(t0_ab, t1_ab)) { @@ -1699,7 +1699,7 @@ void *M3rOptimizeNode( int sizeof_triangles= num_tris * sizeof(MXtFace); int sizeof_quads= num_quads * sizeof(MXtFace); char *buffer= UUrMemory_Block_New(sizeof_header + sizeof_points + sizeof_triangles + sizeof_quads); - + new_node= (MXtNode *) buffer; UUmAssert(new_node); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Verify.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Verify.c index 2429750..4b083a1 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Verify.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Verify.c @@ -1,12 +1,12 @@ /* FILE: Motoko_Verify.h - + AUTHOR: Brent H. Pease - + CREATED: May 5, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997-1999 */ @@ -30,8 +30,8 @@ M3rVerify_Geometry( { error = M3rVerify_Point3D(inGeometry->pointArray->points + itr); UUmAssert(UUcError_None == error); - } - + } + if (instanceName != NULL) { int set_breakpoint_here_if_you_like = 0; @@ -45,10 +45,10 @@ M3rVerify_Geometry( } // verify the tri normal indices - + for(itr = 0; itr < inGeometry->triNormalIndexArray->numIndices; itr++) { - UUmAssert(inGeometry->triNormalIndexArray->indices[itr] < + UUmAssert(inGeometry->triNormalIndexArray->indices[itr] < inGeometry->triNormalArray->numVectors); } @@ -133,7 +133,7 @@ void MSrMatrix3x3Verify(const M3tMatrix3x3 *m) void MSrStackVerify_Debug(void) { M3tMatrix4x3* m; - + M3rMatrixStack_Get(&m); MSmMatrixVerify(m); diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Verify.h b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Verify.h index 91125fe..fb5133a 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Verify.h +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Motoko_Verify.h @@ -1,12 +1,12 @@ /* FILE: Motoko_Verify.h - + AUTHOR: Brent H. Pease - + CREATED: May 5, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997-1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Win32/DriverManager.c b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Win32/DriverManager.c index 705a7d4..d016329 100644 --- a/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Win32/DriverManager.c +++ b/BungieFrameWork/BFW_Source/BFW_Motoko/Manager/Win32/DriverManager.c @@ -51,7 +51,7 @@ struct DMtDD_SurfaceInfo { // mode info DDSURFACEDESC surface_desc; // Complete surface descriptrion - + // list info struct DMtDD_SurfaceInfo *next; // next surface info in list @@ -62,21 +62,21 @@ struct DMtD3D_DeviceInfo { // D3D driver info UUtUns32 flags; // info flags - + // D3D info GUID guid; // GUID char name[DMcMaxNameLength+1]; // name of driver char desc[DMcMaxDescLength+1]; // description of driver D3DDEVICEDESC HALdesc; // HAL description D3DDEVICEDESC HELdesc; // HEL description - + // texture formats UUtInt32 num_formats; // number of texture formats struct DMtDD_SurfaceInfo *format_list; // list of texture formats - + // list info struct DMtD3D_DeviceInfo *next; // next device info in list - + }; // ---------------------------------------------------------------------- @@ -89,19 +89,19 @@ struct DMtDD_DriverInfo GUID guid; // guid for the device char name[DMcMaxNameLength+1]; // name of driver char desc[DMcMaxDescLength+1]; // description of driver - + // driver caps DDCAPS HALcaps; // HAL caps DDCAPS HELcaps; // HEL caps - + // mode info UUtInt32 num_modes; // number of modes struct DMtDD_SurfaceInfo *mode_list; // list of modes - + // D3D info UUtInt32 num_d3d_devices; // number of devices struct DMtD3D_DeviceInfo *d3d_device_list; // list of d3d devices - + // list info struct DMtDD_DriverInfo *next; // next driver info in list @@ -112,17 +112,17 @@ typedef struct DMtDRVRMGR { // data UUtUns32 flags; // info flags - + // DD driver info UUtInt32 num_dd_drivers; // number of DD drivers struct DMtDD_DriverInfo *dd_driver_list; // list of DD drivers - + // configuration info struct DMtDD_DriverInfo *current_dd_driver; // DD driver being used struct DMtDD_SurfaceInfo *current_mode; // current mode in DD driver struct DMtD3D_DeviceInfo *current_d3d_device; // current d3d device struct DMtDD_SurfaceInfo *current_texture_format;// current texture format - + } DMtDRVRMGR; // ====================================================================== @@ -149,7 +149,7 @@ DMiDRVRMGR_initOn( static void DMiDRVRMGR_initOff( DMtDRVRMGR *inDriverManager); - + static UUtError DMiDRVRMGR_LoadDrivers( DMtDRVRMGR *inDriverManager, @@ -163,7 +163,7 @@ static UUtError DMiDRVRMGR_AddDriver( DMtDRVRMGR *inDriverManager, DMtDD_DriverInfo *inDriverInfo); - + // ---------------------------------------------------------------------- static DMtDD_DriverInfo* DMiDD_DI_New( @@ -181,7 +181,7 @@ DMiDD_DI_LoadModes( DMtDD_DriverInfo *inDriverInfo, LPDIRECTDRAW inDirectDraw, DMtModeDescription *inModeDescription); - + static void DMiDD_DI_UnloadModes( DMtDD_DriverInfo *inDriverInfo); @@ -232,11 +232,11 @@ DMiDD_DI_primaryOff( static UUtBool DMiDD_DI_devicesLoaded( DMtDD_DriverInfo *inDriverInfo); - + static void DMiDD_DI_devicesLoadedOn( DMtDD_DriverInfo *inDriverInfo); - + static void DMiDD_DI_devicesLoadedOff( DMtDD_DriverInfo *inDriverInfo); @@ -244,7 +244,7 @@ DMiDD_DI_devicesLoadedOff( static UUtBool DMiDD_DI_modesLoaded( DMtDD_DriverInfo *inDriverInfo); - + static void DMiDD_DI_modesLoadedOn( DMtDD_DriverInfo *inDriverInfo); @@ -326,7 +326,7 @@ static BOOL PASCAL DDiDD_ModeEnumCallback( LPDDSURFACEDESC inSurfaceDesc, LPVOID inData); - + static HRESULT PASCAL DMiD3D_DeviceEnumCallback( LPGUID inGuid, @@ -351,23 +351,23 @@ DMrDRVRMGR_Initialize( DMtModeDescription *inModeDescription) { UUtError error; - + // if the driver manager has already been initialized, terminate it // and then initialize it if (DMiDRVRMGR_isInitialized(&DMgDRVRMGR)) { DMrDRVRMGR_Terminate(); } - + // it isn't so clear the data UUrMemory_Clear(&DMgDRVRMGR, sizeof(DMtDRVRMGR)); - + // build the driver list error = DMiDRVRMGR_LoadDrivers(&DMgDRVRMGR, inModeDescription); UUmError_ReturnOnErrorMsg(error, "Unable to load DD drivers."); - + DMiDRVRMGR_initOn(&DMgDRVRMGR); - + return UUcError_None; } @@ -381,7 +381,7 @@ DMrDRVRMGR_Terminate( { // delete all the data associated with the drivers DMiDRVRMGR_UnloadDrivers(&DMgDRVRMGR); - + // DRVRMGR is no longer initialized DMiDRVRMGR_initOff(&DMgDRVRMGR); } @@ -401,14 +401,14 @@ DMrDRVRMGR_FindDriver( #if 0 DMtDD_DriverInfo *curr; UUtError error; - + // Make sure the DRVRMGR has been initialized if (!DMiDRVRMGR_isInitialized(&DMgDRVRMGR)) { UUrError_Report(UUcError_Generic, "The Driver manager is not initialized."); return UUcError_Generic; } - + // find the driver with the correct name for (curr = DMgDRVRMGR.dd_driver_list; curr != NULL; curr = curr->next) { @@ -418,16 +418,16 @@ DMrDRVRMGR_FindDriver( break; } } - + if (curr == NULL) { UUrError_Report(UUcError_Generic, "Unable to find driver."); return UUcError_Generic; } - + // set the driver DMgDRVRMGR.current_dd_driver = curr; - + // Find the d3d device if (inDirect3D) { @@ -468,13 +468,13 @@ DMiDRVRMGR_LoadDrivers( { DMtDD_CallbackInfo cb_info; HRESULT result; - + // initialize all valid drivers in system cb_info.result = UUcTrue; cb_info.count = 0; cb_info.data = (void*)inDriverManager; cb_info.mode = inModeDescription; - + // enumerate the drivers result = DirectDrawEnumerate(DMiDD_DriverEnumCallback, &cb_info); if (result != DD_OK) @@ -484,7 +484,7 @@ DMiDRVRMGR_LoadDrivers( DMrGetErrorMsg(result)); return UUcError_DirectDraw; } - + // double check the count if ( (!cb_info.result) || (cb_info.count == 0) || @@ -492,7 +492,7 @@ DMiDRVRMGR_LoadDrivers( { return UUcError_Generic; } - + return UUcError_None; } @@ -502,17 +502,17 @@ DMiDRVRMGR_UnloadDrivers( DMtDRVRMGR *inDriverManager) { DMtDD_DriverInfo *curr; - + // walk the driver list and destroy all D3D devices curr = inDriverManager->dd_driver_list; while (curr) { // remove curr from the list inDriverManager->dd_driver_list = curr->next; - + // destroy curr DMiDD_DI_Delete(curr); - + // move on to next driver in the list curr = inDriverManager->dd_driver_list; } @@ -530,7 +530,7 @@ DMiDRVRMGR_AddDriver( UUrError_Report(UUcError_Generic, "Parameter error."); return UUcError_Generic; } - + // Add new mode to end of list if (inDriverManager->dd_driver_list == NULL) { @@ -539,24 +539,24 @@ DMiDRVRMGR_AddDriver( else { DMtDD_DriverInfo *curr; - + // find the end of the list curr = inDriverManager->dd_driver_list; while (curr->next) { curr = curr->next; } - + // insert inDriverInfo at the end of the list curr->next = inDriverInfo; - + // make sure list ends inDriverInfo->next = NULL; } - + // update count inDriverManager->num_dd_drivers++; - + return UUcError_None; } @@ -605,7 +605,7 @@ DMrDD_DI_FindD3DDevice( { #if 0 DMtD3D_DeviceInfo *curr; - + // find the device with the correct name for ( curr = inDriverInfo->d3d_device_list; curr != NULL; @@ -617,13 +617,13 @@ DMrDD_DI_FindD3DDevice( break; } } - + if (curr == NULL) { UUrError_Report(UUcError_Generic, "Unable to find the device."); return UUcError_Generic; } - + // set the device DMgDRVRMGR.current_d3d_device = curr; #endif @@ -645,13 +645,13 @@ DMiDD_DI_New( HRESULT result; UUtError error; char *errorMsg; - + dd = NULL; d3d2 = NULL; result = DD_OK; error = UUcError_None; errorMsg = "\0"; - + // allocate memory for the structure driverInfo = (DMtDD_DriverInfo*)UUrMemory_Block_New(sizeof(DMtDD_DriverInfo)); if (driverInfo == NULL) @@ -660,7 +660,7 @@ DMiDD_DI_New( return NULL; } UUrMemory_Clear(driverInfo, sizeof(DMtDD_DriverInfo)); - + // copy GUID if (!inGuid) { @@ -670,7 +670,7 @@ DMiDD_DI_New( { driverInfo->guid = *inGuid; } - + // copy the name and description strncpy(driverInfo->name, inName, DMcMaxNameLength); if (inDescription) @@ -681,7 +681,7 @@ DMiDD_DI_New( { strcpy(driverInfo->desc, "Unknown\0"); } - + // create the DirectDraw object result = DirectDrawCreate(inGuid, &dd, NULL); if (result != DD_OK) @@ -692,11 +692,11 @@ DMiDD_DI_New( DMrGetErrorMsg(result)); goto cleanup; } - + // get the driver caps driverInfo->HALcaps.dwSize = sizeof(DDCAPS); driverInfo->HELcaps.dwSize = sizeof(DDCAPS); - + result = IDirectDraw_GetCaps( dd, @@ -710,11 +710,11 @@ DMiDD_DI_New( DMrGetErrorMsg(result)); goto cleanup; } - + // enumerate all modes for this DD driver driverInfo->num_modes = 0; - DMiDD_DI_modesLoadedOff(driverInfo); - + DMiDD_DI_modesLoadedOff(driverInfo); + error = DMiDD_DI_LoadModes(driverInfo, dd, inModeDescription); if (error != UUcError_None) { @@ -722,10 +722,10 @@ DMiDD_DI_New( UUrError_Report(error, errorMsg); goto cleanup; } - + // mark as valid driver DMiDD_DI_validOn(driverInfo); - + // -------------------------------------------------- // get the Direct3D interface, if it is available // -------------------------------------------------- @@ -740,11 +740,11 @@ DMiDD_DI_New( DMrGetErrorMsg(result)); goto cleanup; } - + // enumerate all D3D devices for the DD driver driverInfo->num_d3d_devices = 0; DMiDD_DI_devicesLoadedOff(driverInfo); - + error = DMiDD_DI_LoadDevices(driverInfo, d3d2); if (error != UUcError_None) { @@ -761,18 +761,18 @@ DMiDD_DI_New( IDirect3D2_Release(d3d2); d3d2 = NULL; } - + if (dd) { IDirectDraw_Release(dd); dd = NULL; } - + if (error != UUcError_None) { UUrError_Report(error, errorMsg); } - + return driverInfo; } @@ -783,10 +783,10 @@ DMiDD_DI_Delete( { // destroy all the devices DMiDD_DI_UnloadDevices(inDriverInfo); - + // destroy all the modes DMiDD_DI_UnloadModes(inDriverInfo); - + // delete the structure UUrMemory_Block_Delete(inDriverInfo); } @@ -804,19 +804,19 @@ DMiDD_DI_LoadModes( UUrError_Report(UUcError_Generic, "Parameter Error."); return UUcError_Generic; } - + // Have the modes already been loaded? if (!DMiDD_DI_modesLoaded(inDriverInfo)) { DMtDD_CallbackInfo cb_info; HRESULT result; - + // enumerte all modes for this driver cb_info.result = UUcTrue; cb_info.count = 0; cb_info.data = (void*)inDriverInfo; cb_info.mode = inModeDescription; - + result = IDirectDraw_EnumDisplayModes( inDirectDraw, @@ -831,7 +831,7 @@ DMiDD_DI_LoadModes( DMrGetErrorMsg(result)); return UUcError_DirectDraw; } - + // double check the count if ( (!cb_info.result) || (cb_info.count == 0) || @@ -843,7 +843,7 @@ DMiDD_DI_LoadModes( // mark modes as loaded DMiDD_DI_modesLoadedOn(inDriverInfo); } - + return UUcError_None; } @@ -853,18 +853,18 @@ DMiDD_DI_UnloadModes( DMtDD_DriverInfo *inDriverInfo) { DMtDD_SurfaceInfo *mode_info; - + mode_info = inDriverInfo->mode_list; - + // walk the linked list and destroy all d3d device nodes while (mode_info) { // remove d3d_device_info from the list inDriverInfo->mode_list = mode_info->next; - + // delete the d3d_device_info structure DMiDD_SI_Delete(mode_info); - + // move to the next node mode_info = inDriverInfo->mode_list; } @@ -882,7 +882,7 @@ DMiDD_DI_AddMode( UUrError_Report(UUcError_Generic, "Parameter error.\0"); return UUcError_Generic; } - + // Add new mode to end of list if (inDriverInfo->mode_list == NULL) { @@ -891,24 +891,24 @@ DMiDD_DI_AddMode( else { DMtDD_SurfaceInfo *curr; - + // find the end of the list curr = inDriverInfo->mode_list; while (curr->next) { curr = curr->next; } - + // insert inModeInfo at the end of the list curr->next = inModeInfo; - + // make sure list ends inModeInfo->next = NULL; } - + // update count inDriverInfo->num_modes++; - + return UUcError_None; } @@ -930,12 +930,12 @@ DMiDD_DI_LoadDevices( { DMtDD_CallbackInfo cb_info; HRESULT result; - + // enumerte all devices for this driver cb_info.result = UUcTrue; cb_info.count = 0; cb_info.data = (void*)inDriverInfo; - + result = IDirect3D2_EnumDevices( inDirect3D2, @@ -946,7 +946,7 @@ DMiDD_DI_LoadDevices( UUrError_Report(UUcError_DirectDraw, "Direct3D Error."); return UUcError_DirectDraw; } - + // double check the count if ( (!cb_info.result) || (cb_info.count == 0) || @@ -956,7 +956,7 @@ DMiDD_DI_LoadDevices( } } - + return UUcError_None; } @@ -966,18 +966,18 @@ DMiDD_DI_UnloadDevices( DMtDD_DriverInfo *inDriverInfo) { DMtD3D_DeviceInfo *d3d_device_info; - + d3d_device_info = inDriverInfo->d3d_device_list; - + // walk the linked list and destroy all d3d device nodes while (d3d_device_info) { // remove d3d_device_info from the list inDriverInfo->d3d_device_list = d3d_device_info->next; - + // delete the d3d_device_info structure DMiD3D_DI_Delete(d3d_device_info); - + // move to the next node d3d_device_info = inDriverInfo->d3d_device_list; } @@ -995,7 +995,7 @@ DMiDD_DI_AddDevice( UUrError_Report(UUcError_Generic, "Parameter error.\0"); return UUcError_Generic; } - + // Add new mode to end of list if (inDriverInfo->d3d_device_list == NULL) { @@ -1004,24 +1004,24 @@ DMiDD_DI_AddDevice( else { DMtD3D_DeviceInfo *curr; - + // find the end of the list curr = inDriverInfo->d3d_device_list; while (curr->next) { curr = curr->next; } - + // insert inD3DDeviceInfo at the end of the list curr->next = inD3DDeviceInfo; - + // make sure the list ends inD3DDeviceInfo->next = NULL; } - + // update count inDriverInfo->num_d3d_devices++; - + return UUcError_None; } @@ -1133,7 +1133,7 @@ DMiDD_SI_New( DMtModeDescription *inModeDescription) { DMtDD_SurfaceInfo *surface_desc; - + if (inModeDescription) { // if the mode capabilities meet or exceed the capabilities of @@ -1144,7 +1144,7 @@ DMiDD_SI_New( { return NULL; } - + if (inModeDescription->use_zbuffer && (inModeDescription->zbuffer_bitdepth <= DMrFlagsToBitDepth(inSurfaceDesc->dwZBufferBitDepth))) @@ -1152,7 +1152,7 @@ DMiDD_SI_New( return NULL; } } - + // allocate memory for the surface desc surface_desc = UUrMemory_Block_New(sizeof(DMtDD_SurfaceInfo)); if (surface_desc == NULL) @@ -1164,11 +1164,11 @@ DMiDD_SI_New( // copy the surface desc data surface_desc->surface_desc = *inSurfaceDesc; - + // return the pointer to the new surface description return surface_desc; } - + // ---------------------------------------------------------------------- static void DMiDD_SI_Delete( @@ -1187,9 +1187,9 @@ DMiDD_SI_MatchPixelFormat( UUmAssert(inSurfaceInfo); UUmAssert(inDDPixelFormat); - + ddpf = &inSurfaceInfo->surface_desc.ddpfPixelFormat; - + // check to see that the important parts are the same if ((ddpf->dwFlags & DDPF_RGB) == (inDDPixelFormat->dwFlags & DDPF_RGB)) { @@ -1209,7 +1209,7 @@ DMiDD_SI_MatchPixelFormat( } } } - + return UUcFalse; } @@ -1266,19 +1266,19 @@ DMrD3D_DI_LoadFormats( UUrError_Report(UUcError_Generic, "Parameter Error."); return UUcError_Generic; } - + // Have the formats already been loaded? if (!DMiD3D_DI_formatsLoaded(inDeviceInfo)) { DMtDD_CallbackInfo cb_info; HRESULT result; - + // enumerte all modes for this driver cb_info.result = UUcTrue; cb_info.count = 0; cb_info.data = (void*)inDeviceInfo; cb_info.mode = NULL; - + result = IDirect3DDevice2_EnumTextureFormats( inD3DDevice2, @@ -1291,7 +1291,7 @@ DMrD3D_DI_LoadFormats( DMrGetErrorMsg(result)); return UUcError_DirectDraw; } - + // double check the count if ( (!cb_info.result) || (cb_info.count == 0) || @@ -1303,7 +1303,7 @@ DMrD3D_DI_LoadFormats( // mark formats as loaded DMiD3D_DI_formatsLoadedOn(inDeviceInfo); } - + return UUcError_None; } @@ -1313,18 +1313,18 @@ DMiD3D_DI_UnloadFormats( DMtD3D_DeviceInfo *inDeviceInfo) { DMtDD_SurfaceInfo *format_info; - + format_info = inDeviceInfo->format_list; - + // walk the linked list and destroy all the texture formats while (format_info) { // remove format_info from the list inDeviceInfo->format_list = format_info->next; - + // delete the format info structure DMiDD_SI_Delete(format_info); - + // move to the next format format_info = inDeviceInfo->format_list; } @@ -1337,7 +1337,7 @@ DMrD3D_DI_FindFormat( LPDDPIXELFORMAT inDDPixelFormat) { DMtDD_SurfaceInfo *curr; - + // search the list for the mode that matches the pixel format for ( curr = inDeviceInfo->format_list; curr != NULL; @@ -1346,7 +1346,7 @@ DMrD3D_DI_FindFormat( if (DMiDD_SI_MatchPixelFormat(curr, inDDPixelFormat)) break; } - + return curr; } @@ -1362,7 +1362,7 @@ DMiD3D_DI_AddFormat( UUrError_Report(UUcError_Generic, "Parameter error.\0"); return UUcError_Generic; } - + // Add new format to end of list if (inDeviceInfo->format_list == NULL) { @@ -1371,24 +1371,24 @@ DMiD3D_DI_AddFormat( else { DMtDD_SurfaceInfo *curr; - + // find the end of the list curr = inDeviceInfo->format_list; while (curr->next) { curr = curr->next; } - + // insert inFormatInfo at the end of the list curr->next = inFormatInfo; - + // make sure list ends inFormatInfo->next = NULL; } - + // update count inDeviceInfo->num_formats++; - + return UUcError_None; } @@ -1402,7 +1402,7 @@ DMiD3D_DI_New( LPD3DDEVICEDESC inHELDesc) { DMtD3D_DeviceInfo *d3d_device_info; - + // allocate memory for the D3D device info structure d3d_device_info = UUrMemory_Block_New(sizeof(DMtD3D_DeviceInfo)); if (d3d_device_info == NULL) @@ -1413,12 +1413,12 @@ DMiD3D_DI_New( return NULL; } UUrMemory_Clear(d3d_device_info, sizeof(DMtD3D_DeviceInfo)); - + // copy the in data to the fields of the structure d3d_device_info->guid = *inGuid; d3d_device_info->HALdesc = *inHALDesc; d3d_device_info->HELdesc = *inHELDesc; - + strncpy(d3d_device_info->name, inName, DMcMaxNameLength); if (inDescription) { @@ -1428,20 +1428,20 @@ DMiD3D_DI_New( { strcpy(d3d_device_info->desc, "Unknown."); } - + // set the nubmer of texture formats to 0 and mark the list as not loaded d3d_device_info->num_formats = 0; d3d_device_info->format_list = NULL; - + DMiD3D_DI_formatsLoadedOff(d3d_device_info); - + // mark as valid DMiD3D_DI_validOn(d3d_device_info); - + // return pointer to new d3d device info structure return d3d_device_info; } - + // ---------------------------------------------------------------------- static void DMiD3D_DI_Delete( @@ -1521,11 +1521,11 @@ DMiDD_DriverEnumCallback( { return DDENUMRET_OK; } - + // get a pointer to the callback info cb_info = (DMtDD_CallbackInfo*)inData; drvr_mgr = (DMtDRVRMGR*)cb_info->data; - + // create a new driver info structure dd_driver_info = DMiDD_DI_New(inGuid, inName, inDescription, cb_info->mode); if (dd_driver_info == NULL) @@ -1533,7 +1533,7 @@ DMiDD_DriverEnumCallback( // not enough memory, go on to next one return DDENUMRET_OK; } - + // add the driver to the driver list error = DMiDRVRMGR_AddDriver(drvr_mgr, dd_driver_info); if (error != UUcError_None) @@ -1541,10 +1541,10 @@ DMiDD_DriverEnumCallback( // unable to add to the driver list, go on to next one return DDENUMRET_OK; } - + // increment the driver count cb_info->count++; - + // continue processing return DDENUMRET_OK; } @@ -1559,13 +1559,13 @@ DDiDD_ModeEnumCallback( DMtDD_SurfaceInfo *dd_mode_info; DMtDD_DriverInfo *dd_driver_info; UUtError error; - + // if inData is NULL, something went terribly wrong if (inData == NULL) { return DDENUMRET_OK; } - + // if the surface description is null something went wrong if (inSurfaceDesc == NULL) { @@ -1575,19 +1575,19 @@ DDiDD_ModeEnumCallback( // get pointers to the data cb_info = (DMtDD_CallbackInfo*)inData; dd_driver_info = (DMtDD_DriverInfo*)cb_info->data; - + // make sure dd_driver_info is good if (dd_driver_info == NULL) { return DDENUMRET_CANCEL; } - + // double check structure size if (inSurfaceDesc->dwSize != sizeof(DDSURFACEDESC)) { return DDENUMRET_CANCEL; } - + // Create the mode structure dd_mode_info = DMiDD_SI_New(inSurfaceDesc, cb_info->mode); if (dd_mode_info == NULL) @@ -1595,17 +1595,17 @@ DDiDD_ModeEnumCallback( // unable to allocate space, go on return DDENUMRET_OK; } - + // Add Mode to Driver Mode list error = DMiDD_DI_AddMode(dd_driver_info, dd_mode_info); if (error != UUcError_None) { return DDENUMRET_OK; } - + // increment mode count cb_info->count++; - + // continue processing return DDENUMRET_OK; } @@ -1624,23 +1624,23 @@ DMiD3D_DeviceEnumCallback( DMtDD_DriverInfo *dd_driver_info; DMtD3D_DeviceInfo *d3d_device_info; UUtError error; - + // if inData is NULL, something went terribly wrong if (inData == NULL) { return DDENUMRET_OK; } - + // get pointers to the data cb_info = (DMtDD_CallbackInfo*)inData; dd_driver_info = (DMtDD_DriverInfo*)cb_info->data; - + // make sure dd_driver_info is good if (dd_driver_info == NULL) { return DDENUMRET_CANCEL; } - + // create a D3D device info structure d3d_device_info = DMiD3D_DI_New( @@ -1654,7 +1654,7 @@ DMiD3D_DeviceEnumCallback( // unable to allocate space, go on return DDENUMRET_OK; } - + // Add device to list error = DMiDD_DI_AddDevice(dd_driver_info, d3d_device_info); if (error != UUcError_None) @@ -1662,10 +1662,10 @@ DMiD3D_DeviceEnumCallback( UUrError_Report(error, "Unable to add Direct3D device to list."); return DDENUMRET_OK; } - + // increment device count cb_info->count++; - + // continue processing return DDENUMRET_OK; } @@ -1687,17 +1687,17 @@ DMiD3D_TextureFormatEnumCallback( { return DDENUMRET_OK; } - + // get pointers to the data cb_info = (DMtDD_CallbackInfo*)inData; d3d_device_info = (DMtD3D_DeviceInfo*)cb_info->data; - + // make sure d3d_device_info is good if (d3d_device_info == NULL) { return DDENUMRET_CANCEL; } - + // create a Texture Format info structure format_info = DMiDD_SI_New(inTextureFormat, NULL); if (format_info == NULL) @@ -1705,7 +1705,7 @@ DMiD3D_TextureFormatEnumCallback( // unable to allocate space, go on return DDENUMRET_OK; } - + // Add format to list error = DMiD3D_DI_AddFormat(d3d_device_info, format_info); if (error != UUcError_None) @@ -1713,10 +1713,10 @@ DMiD3D_TextureFormatEnumCallback( UUrError_Report(error, "Unable to add Texture format to list."); return DDENUMRET_OK; } - + // increment device count cb_info->count++; - + // continue processing return DDENUMRET_OK; } diff --git a/BungieFrameWork/BFW_Source/BFW_NetworkManager/BFW_NetworkManager.c b/BungieFrameWork/BFW_Source/BFW_NetworkManager/BFW_NetworkManager.c index 5a7ec4b..7dd8034 100644 --- a/BungieFrameWork/BFW_Source/BFW_NetworkManager/BFW_NetworkManager.c +++ b/BungieFrameWork/BFW_Source/BFW_NetworkManager/BFW_NetworkManager.c @@ -29,7 +29,7 @@ NMrAddressToString( const NMtNetAddress *inNetAddress) { char *address_string; - + #if (UUmPlatform == UUmPlatform_Mac) address_string = NMrOT_AddressToString(inNetAddress); #elif (UUmPlatform == UUmPlatform_Win32) @@ -49,11 +49,11 @@ NMrRegisterService( UUmAssert(inNetServiceMethods); UUmAssert((inNetServiceCaps->type >= NMcUDP) && (inNetServiceCaps->type < NMcNumServiceTypes)); - + // add the service NMgNetServicesList[inNetServiceCaps->type].service = *inNetServiceCaps; NMgNetServicesList[inNetServiceCaps->type].methods = *inNetServiceMethods; - + return UUcError_None; } @@ -68,11 +68,11 @@ NMrNetContext_Delete( NMtNetContext **inNetContext) { UUmAssert(*inNetContext); - + // release the memory used by inNetContext UUrMemory_Block_Delete(*inNetContext); *inNetContext = NULL; - + return UUcError_None; } @@ -86,9 +86,9 @@ NMrNetContext_New( { UUtError error; NMtNetContext *net_context; - + UUmAssert((inServiceType >= NMcUDP) && (inServiceType < NMcNumServiceTypes)); - + // make sure the requested service is registered if (NMgNetServicesList[inServiceType].methods.start_protocol == NULL) { @@ -96,30 +96,30 @@ NMrNetContext_New( UUcError_Generic, "That network service is unavailable."); } - + // allocate memory for a new net context net_context = (NMtNetContext*)UUrMemory_Block_NewClear(sizeof(NMtNetContext)); UUmError_ReturnOnNull(net_context); - + // clear the flags net_context->flags = 0; - + // set the methods of the network context net_context->methods = NMgNetServicesList[inServiceType].methods; - + // set the port number net_context->port_number = inPortNumber; - + // start the protocol error = NMrNetContext_StartProtocol(net_context, inFlags); UUmError_ReturnOnError(error); - + // set the initialized flag net_context->flags |= NMcInitialized; - + // set the return value *outNetContext = net_context; - + return UUcError_None; } @@ -134,10 +134,10 @@ NMrInitialize( void) { UUtError error; - + // initialize the net services list UUrMemory_Clear(NMgNetServicesList, sizeof(NMgNetServicesList)); - + // initialize the plugins #if (UUmPlatform == UUmPlatform_Mac) error = NMrOT_UDP_Initialize(); @@ -146,7 +146,7 @@ NMrInitialize( #endif UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_OpenTransport/NM_OpenTransport.c b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_OpenTransport/NM_OpenTransport.c index a5b44a1..9c84aa2 100644 --- a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_OpenTransport/NM_OpenTransport.c +++ b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_OpenTransport/NM_OpenTransport.c @@ -38,7 +38,7 @@ static char NMgOT_UDP_String[32]; // ====================================================================== // prototype -// ====================================================================== +// ====================================================================== static UUtError NMiOT_UDP_WriteData( NMtNetContext *inNetContext, @@ -67,7 +67,7 @@ NMiOT_UDP_HandleRead( // is called. The next call to OTRcvUData() will have data so to keep the // function from exiting, use this boolean to handle this case. first_read = UUcTrue; - + // continuously read until no queues are available or a kOTNoDataErr is encountered while (1) { @@ -75,20 +75,20 @@ NMiOT_UDP_HandleRead( data_buffer = NMrQueue_DequeueBuffer( &inNetContext->private_data->queues, - NMcIncomingEmptyQueue); + NMcIncomingEmptyQueue); if (data_buffer == NULL) { inNetContext->out_of_incoming_buffers = UUcTrue; break; } - + // set up the unit_data unit_data.addr.buf = (UUtUns8*)&data_buffer->data.address; unit_data.addr.maxlen = sizeof(InetAddress); unit_data.opt.maxlen = 0; unit_data.udata.buf = data_buffer->data.buffer; unit_data.udata.maxlen = NMcPacketSize; - + // receive the data status = OTRcvUData( @@ -102,7 +102,7 @@ NMiOT_UDP_HandleRead( &inNetContext->private_data->queues, NMcIncomingEmptyQueue, data_buffer); - + // process the error if ((status == kOTNoDataErr) && (first_read == UUcTrue)) { @@ -113,13 +113,13 @@ NMiOT_UDP_HandleRead( { status = OTLook(inNetContext->private_data->endpoint); } - + break; } - + // save the buffer length data_buffer->data.buffer_length = unit_data.udata.len; - + // put the data into the incoming queue NMrQueue_EnqueueBuffer( &inNetContext->private_data->queues, @@ -142,17 +142,17 @@ NMiOT_UDP_OTAvailable( if (NMgOT_UDP_HasOT_tested == UUcFalse) { OTResult status; - + // Check whether Open Transport is installed. status = Gestalt(gestaltOpenTpt, &NMgOT_UDP_OTGestaltResult); if (status == noErr) { NMgOT_UDP_HasOT = UUcTrue; } - + NMgOT_UDP_HasOT_tested = UUcTrue; } - + return NMgOT_UDP_HasOT; } @@ -166,26 +166,26 @@ NMiOT_UDP_NotifyProc( { NMtNetContext *net_context; OTResult status; - + // get a pointer to the net_context net_context = (NMtNetContext*)inContextPtr; - + switch (inCode) { case T_OPENCOMPLETE: // the endpoint has been opened, record the endpointref in the net_context net_context->private_data->endpoint = (EndpointRef)inCookie; break; - + case T_UDERR: // clear the error status = OTRcvUDErr(net_context->private_data->endpoint, NULL); break; - + case T_DATA: NMiOT_UDP_HandleRead(net_context); break; - + default: break; } @@ -207,13 +207,13 @@ NMiOT_UDP_Broadcast( UUtError error; NMtNetAddress address; InetAddress *address_ptr; - + // get a pointer to the address address_ptr = (InetAddress*)address; - + // init address OTInitInetAddress(address_ptr, inPortNumber, 0xFFFFFFFF); - + // send the data to every machine on the local network error = NMiOT_UDP_WriteData( @@ -233,12 +233,12 @@ NMiOT_UDP_CloseProtocol( NMtNetContext *inNetContext) { OTResult status; - + if ((inNetContext == NULL) || (inNetContext->private_data == NULL)) { return UUcError_Generic; } - + // unbind the connection to the endpoint if (inNetContext->private_data->endpoint != kOTInvalidEndpointRef) { @@ -258,7 +258,7 @@ NMiOT_UDP_CloseProtocol( UUmAssert(status == kOTNoError); return UUcError_Generic; } - + // close the endpoint status = OTCloseProvider(inNetContext->private_data->endpoint); if (status != kOTNoError) @@ -272,11 +272,11 @@ NMiOT_UDP_CloseProtocol( if (status == T_DATA) { NMtDataBuffer *data_buffer; - - // there are reads pending that need to be cleared, so + + // there are reads pending that need to be cleared, so // handle the read NMiOT_UDP_HandleRead(inNetContext); - + // since we don't care about the data coming in, just put // the data buffers in the incoming queue back into the // incoming empty queue @@ -290,7 +290,7 @@ NMiOT_UDP_CloseProtocol( &inNetContext->private_data->queues, NMcIncomingEmptyQueue, data_buffer); - + data_buffer = NMrQueue_DequeueBuffer( &inNetContext->private_data->queues, @@ -304,25 +304,25 @@ NMiOT_UDP_CloseProtocol( } } while (status != kOTNoError); - } - + } + // the endpoint is no longer valid inNetContext->private_data->endpoint = kOTInvalidEndpointRef; } - + // terminate the queues NMrQueue_Terminate(&inNetContext->private_data->queues); - + // free the private_data if (inNetContext->private_data) { UUrMemory_Block_Delete(inNetContext->private_data); inNetContext->private_data = NULL; } - + // close OT CloseOpenTransport(); - + return UUcError_None; } @@ -335,16 +335,16 @@ NMiOT_UDP_CompareAddresses( { InetAddress *addr_1; InetAddress *addr_2; - + // get a pointer to the two addresses addr_1 = (InetAddress*)inAddress1; addr_2 = (InetAddress*)inAddress2; - + if (addr_1->fHost == addr_2->fHost) { return UUcTrue; } - + return UUcFalse; } @@ -355,7 +355,7 @@ NMiOT_UDP_GetAddress( { // clear the string NMgOT_UDP_String[0] = '\0'; - + // convert the address to a string OTInetHostToString( inNetContext->private_data->host, @@ -377,7 +377,7 @@ NMiOT_UDP_ReadData( TUDErr rcv_error; InetAddress from_address; NMtPacket *data_packet; - + // look for async events result = OTLook(inNetContext->private_data->endpoint); switch (result) @@ -389,7 +389,7 @@ NMiOT_UDP_ReadData( rcv_error.opt.len = 0; result = OTRcvUDErr(inNetContext->private_data->endpoint, &rcv_error); break; - + case T_DATA: NMiOT_UDP_HandleRead(inNetContext); break; @@ -404,10 +404,10 @@ NMiOT_UDP_ReadData( { return UUcFalse; } - + // get a pointer to the data_packet data_packet = (NMtPacket*)&data_buffer->data.buffer; - + // set the outgoing data UUrMemory_MoveFast( &data_buffer->data.address, @@ -415,13 +415,13 @@ NMiOT_UDP_ReadData( sizeof(NMtNetAddress)); *outNumBytes = data_packet->packet_header.packet_data_size; UUrMemory_MoveFast(&data_packet->packet_data, outDataBuffer, *outNumBytes); - + // put the buffer onto the incoming empty queue NMrQueue_EnqueueBuffer( &inNetContext->private_data->queues, NMcIncomingEmptyQueue, data_buffer); - + return UUcTrue; } @@ -445,14 +445,14 @@ NMiOT_UDP_StartProtocol( { return UUcError_Generic; } - + // initialize OT status = InitOpenTransport(); if (status != kOTNoError) { return UUcError_Generic; } - + // allocate memory for the private data inNetContext->private_data = (NMtNetContextPrivate*)UUrMemory_Block_New( @@ -461,7 +461,7 @@ NMiOT_UDP_StartProtocol( { return UUcError_OutOfMemory; } - + // clear the private_data UUrMemory_Clear( inNetContext->private_data, @@ -474,7 +474,7 @@ NMiOT_UDP_StartProtocol( NMcOT_UDP_NumIncomingBuffers, NMcOT_UDP_NumOutgoingBuffers); UUmError_ReturnOnError(error); - + // get an OT configuration if (NMgOT_UDP_Config) { @@ -486,7 +486,7 @@ NMiOT_UDP_StartProtocol( config = OTCreateConfiguration(kUDPName); NMgOT_UDP_Config = OTCloneConfiguration(config); } - + // create the udp endpoint that is asynchronous status = OTAsyncOpenEndpoint( @@ -502,10 +502,10 @@ NMiOT_UDP_StartProtocol( // close OT CloseOpenTransport(); - + return UUcError_Generic; } - + // init in_address OTInitInetAddress(&in_address, inNetContext->port_number, 0); status = OTInetGetInterfaceInfo(&info, kDefaultInetInterface); @@ -524,22 +524,22 @@ NMiOT_UDP_StartProtocol( { in_address.fHost = info.fAddress; } - + // save the host address inNetContext->private_data->host = info.fAddress; - + // set up the requested_addr requested_addr.addr.buf = (UInt8*)&in_address; requested_addr.addr.len = sizeof(InetAddress); requested_addr.qlen = 0; - + // set up the returned_addr returned_addr.addr.buf = (UInt8*)&out_address; returned_addr.addr.maxlen = sizeof(InetAddress); requested_addr.qlen = 0; - + // bind the endpoint - status = + status = OTBind( inNetContext->private_data->endpoint, &requested_addr, @@ -549,7 +549,7 @@ NMiOT_UDP_StartProtocol( NMiOT_UDP_CloseProtocol(inNetContext); return UUcError_Generic; } - + // get a reference to the internet services inNetContext->private_data->internet_services = OTOpenInternetServices( @@ -561,14 +561,14 @@ NMiOT_UDP_StartProtocol( NMiOT_UDP_CloseProtocol(inNetContext); return UUcError_Generic; } - + status = OTGetEndpointState(inNetContext->private_data->endpoint); if (status != T_IDLE) { UUmAssert(status == T_IDLE); return UUcError_Generic; } - + return UUcError_None; } @@ -582,11 +582,11 @@ NMiOT_UDP_StringToAddress( { InetHostInfo host_info; OTResult status; - + if (inString) { // turn the string into an address - status = + status = OTInetStringToAddress( inNetContext->private_data->internet_services, inString, @@ -595,7 +595,7 @@ NMiOT_UDP_StringToAddress( { return UUcError_Generic; } - + // initialize the inet address OTInitInetAddress((InetAddress*)outNetAddress, inPortNumber, host_info.addrs[0]); } @@ -612,7 +612,7 @@ NMiOT_UDP_StringToAddress( } ((InetAddress*)outNetAddress)->fHost = info.fAddress; } - + return UUcError_None; } @@ -622,7 +622,7 @@ NMiOT_UDP_Update( NMtNetContext *inNetContext) { UUtError error; - + // if there were no buffers for NMiOT_UDP_HandleRead(), then a T_DATA is // still pending and needs to be handled. Call NMiOT_UDP_HandleRead() // hopefully there will be some buffers available. @@ -647,7 +647,7 @@ NMiOT_UDP_Update( inNetContext->out_of_incoming_buffers = UUcFalse; NMiOT_UDP_HandleRead(inNetContext); } - + if (inNetContext->out_of_outgoing_buffers) { error = @@ -668,7 +668,7 @@ NMiOT_UDP_Update( } inNetContext->out_of_outgoing_buffers = UUcFalse; } - + return UUcError_None; } @@ -686,37 +686,37 @@ NMiOT_UDP_WriteData( NMtPacket raw; NMtPacket *data_packet; UUtUns16 packet_length; - + // calculate the packet_length packet_length = sizeof(NMtPacketHeader) + inNumBytes; - + // get a pointer to the data_packet - data_packet = &raw; + data_packet = &raw; // initialize the packet data_packet->packet_header.packet_flags = inFlags; data_packet->packet_header.packet_data_size = inNumBytes; - + // copy the data into the packet UUrMemory_MoveFast( inDataBuffer, data_packet->packet_data, inNumBytes); - + // set the unit_data fields unit_data.addr.buf = (UUtUns8*)inDestAddress; unit_data.addr.len = sizeof(InetAddress); unit_data.opt.len = 0; unit_data.udata.buf = (UUtUns8*)data_packet; unit_data.udata.len = packet_length; - + // send the data immediately status = OTSndUData(inNetContext->private_data->endpoint, &unit_data); if (status != kOTNoError) { return UUcError_Generic; } - + return UUcError_None; } @@ -731,11 +731,11 @@ NMrOT_AddressToString( const NMtNetAddress *inAddress) { InetAddress *inet_address; - + inet_address = (InetAddress*)inAddress; - + OTInetHostToString(inet_address->fHost, NMgOT_UDP_String); - + return NMgOT_UDP_String; } @@ -747,13 +747,13 @@ NMrOT_UDP_Initialize( UUtError error; NMtNetServiceCaps caps; NMtNetContextMethods methods; - + // clear the methods struct UUrMemory_Clear(&methods, sizeof(NMtNetContextMethods)); - + // set the caps caps.type = NMcUDP; - + // set the function pointers in the methods struct methods.broadcast = NMiOT_UDP_Broadcast; methods.close_protocol = NMiOT_UDP_CloseProtocol; @@ -764,11 +764,11 @@ NMrOT_UDP_Initialize( methods.string_to_address = NMiOT_UDP_StringToAddress; methods.update = NMiOT_UDP_Update; methods.write_data = NMiOT_UDP_WriteData; - + // register the methods with the net manager error = NMrRegisterService(&caps, &methods); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_OpenTransport/NM_OpenTransport.h b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_OpenTransport/NM_OpenTransport.h index 571098b..5452cd6 100644 --- a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_OpenTransport/NM_OpenTransport.h +++ b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_OpenTransport/NM_OpenTransport.h @@ -25,4 +25,4 @@ NMrOT_UDP_Terminate( void); // ====================================================================== -#endif /* NM_OT_UDP_H */ \ No newline at end of file +#endif /* NM_OT_UDP_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_OpenTransport/NM_OpenTransport_Private.h b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_OpenTransport/NM_OpenTransport_Private.h index 510228f..dec341c 100644 --- a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_OpenTransport/NM_OpenTransport_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_OpenTransport/NM_OpenTransport_Private.h @@ -21,8 +21,8 @@ struct NMtNetContextPrivate InetSvcRef internet_services; InetHost host; NMtQueues queues; - + }; // ====================================================================== -#endif /* NM_OT_UDP_PRIVATE_H */ \ No newline at end of file +#endif /* NM_OT_UDP_PRIVATE_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_Queues/NM_Queues.c b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_Queues/NM_Queues.c index e85955a..af831da 100644 --- a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_Queues/NM_Queues.c +++ b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_Queues/NM_Queues.c @@ -15,7 +15,7 @@ NMtQueue* NMiGetQueue( NMtQueues *inQueues, NMtQueueRef inQueueRef); - + // ====================================================================== // functions // ====================================================================== @@ -49,25 +49,25 @@ NMrQueue_Initialize( UUtUns16 inNumOutgoingBuffers) { UUtUns32 i, j; - + // initialize the queues inQueues->incoming_queue.head = NULL; inQueues->incoming_queue.tail = NULL; - + inQueues->incoming_empty_queue.head = NULL; inQueues->incoming_empty_queue.tail = NULL; - + inQueues->outgoing_queue.head = NULL; inQueues->outgoing_queue.tail = NULL; - + inQueues->outgoing_empty_queue.head = NULL; inQueues->outgoing_empty_queue.tail = NULL; - + // allocate buffers and put them in the incoming empty queue for (i = 0; i < inNumIncomingBuffers; i++) { NMtDataBuffer *temp; - + // allocate the buffer temp = (NMtDataBuffer*)UUrMemory_Block_New(sizeof(NMtDataBuffer)); if (temp == NULL) @@ -86,19 +86,19 @@ NMrQueue_Initialize( // delete the buffer UUrMemory_Block_Delete(temp); } - + return UUcError_Generic; } - + // put the buffer into the incoming empty queue NMrQueue_EnqueueBuffer(inQueues, NMcIncomingEmptyQueue, temp); } - + // allocate buffers and put them in the outgoing empty queue for (i = 0; i < inNumOutgoingBuffers; i++) { NMtDataBuffer *temp; - + // allocate the buffer temp = (NMtDataBuffer*)UUrMemory_Block_New(sizeof(NMtDataBuffer)); if (temp == NULL) @@ -117,10 +117,10 @@ NMrQueue_Initialize( // delete the buffer UUrMemory_Block_Delete(temp); } - + return UUcError_Generic; } - + // put the buffer into the outgoing empty queue NMrQueue_EnqueueBuffer(inQueues, NMcOutgoingEmptyQueue, temp); } @@ -135,7 +135,7 @@ NMrQueue_Terminate( { NMtDataBuffer *temp; NMtQueueRef i; - + // dequeue all of the buffers in all of the queue for (i = NMcIncomingQueue; i <= NMcOutgoingEmptyQueue; i++) { @@ -145,7 +145,7 @@ NMrQueue_Terminate( { // delete the buffer UUrMemory_Block_Delete(temp); - + // get the next buffer temp = NMrQueue_DequeueBuffer(inQueues, i); } @@ -166,30 +166,30 @@ NMrQueue_AddBuffers( { NMtQueue *queue; UUtUns16 i; - + UUmAssert(inQueues); UUmAssert((inQueueRef == NMcIncomingEmptyQueue) || (inQueueRef == NMcOutgoingEmptyQueue)); - + // get a pointer to the queue being referenced queue = NMiGetQueue(inQueues, inQueueRef); - + // allocate buffers and add them to the desired queue for (i = 0; i < inNumBuffersToAdd; i++) { NMtDataBuffer *temp; - + // allocate the buffer temp = (NMtDataBuffer*)UUrMemory_Block_New(sizeof(NMtDataBuffer)); if (temp == NULL) return UUcError_OutOfMemory; - + // put the buffer into the incoming empty queue NMrQueue_EnqueueBuffer(inQueues, inQueueRef, temp); } - + return UUcError_None; } - + // ---------------------------------------------------------------------- NMtDataBuffer* NMrQueue_DequeueBuffer( @@ -198,17 +198,17 @@ NMrQueue_DequeueBuffer( { NMtQueue *queue; NMtDataBuffer *temp; - + // get a pointer to the queue being referenced queue = NMiGetQueue(inQueues, inQueueRef); - + // remove the first element in the queue temp = queue->head; if (queue->head != NULL) { // set queue head to the next element in the queue queue->head = queue->head->next; - + // if there are no more elements in the queue then // set the tail to NULL if (queue->head == NULL) @@ -220,12 +220,12 @@ NMrQueue_DequeueBuffer( // set the new heads prev to NULL queue->head->prev = NULL; } - + // set temp's pointers to NULL temp->next = NULL; temp->prev = NULL; } - + return temp; } @@ -237,14 +237,14 @@ NMrQueue_EnqueueBuffer( NMtDataBuffer *inDataBuffer) { NMtQueue *queue; - + // get a pointer to the queue being referenced queue = NMiGetQueue(inQueues, inQueueRef); - + // set the pointers of the data buffer inDataBuffer->next = NULL; inDataBuffer->prev = NULL; - + // set the queue head if (queue->head == NULL) { @@ -262,10 +262,10 @@ NMrQueue_EnqueueBuffer( { // set the previous pointer to the current tail inDataBuffer->prev = queue->tail; - + // insert after the current tail queue->tail->next = inDataBuffer; - + // update the queue tail to point to the new last element queue->tail = inDataBuffer; } @@ -280,21 +280,21 @@ NMrQueue_GetBufferCount( NMtQueue *queue; UUtUns16 count = 0; NMtDataBuffer *temp; - + // get a pointer to the queue being referenced queue = NMiGetQueue(inQueues, inQueueRef); if (queue) { // count the number of buffers in the queue temp = queue->head; - + while (temp) { count++; temp = temp->next; } } - + return count; } @@ -311,7 +311,7 @@ NMrQueue_GetNextBuffer( NMtDataBuffer *inDataBuffer) { NMtDataBuffer *return_buffer; - + // if inDataBuffer != NULL then return the next data buffer in the queue if (inDataBuffer) { @@ -321,13 +321,13 @@ NMrQueue_GetNextBuffer( { // inDataBuffer == NULL, return the first data buffer in the queue NMtQueue *queue; - + // get a pointer to the queue being referenced queue = NMiGetQueue(inQueues, inQueueRef); - + return_buffer = queue->head; } - + return return_buffer; } @@ -342,7 +342,7 @@ NMrQueue_RemoveBuffer( // get a pointer to the queue being referenced queue = NMiGetQueue(inQueues, inQueueRef); - + // update the next buffers prev pointer if (inDataBuffer->next) { @@ -354,7 +354,7 @@ NMrQueue_RemoveBuffer( // needs to be set to the buffer's prev pointer queue->tail = inDataBuffer->prev; } - + // update the prev buffers next pointer if (inDataBuffer->prev) { @@ -366,7 +366,7 @@ NMrQueue_RemoveBuffer( // needs to be set to the buffer's next pointer queue->head = inDataBuffer->next; } - + // set the buffer's pointer's to NULL inDataBuffer->next = NULL; inDataBuffer->prev = NULL; diff --git a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_Queues/NM_Queues.h b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_Queues/NM_Queues.h index e7bb90b..d3057a7 100644 --- a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_Queues/NM_Queues.h +++ b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_Queues/NM_Queues.h @@ -28,7 +28,7 @@ typedef enum NMtQueueRef NMcIncomingEmptyQueue = 2, NMcOutgoingQueue = 3, NMcOutgoingEmptyQueue = 4 - + } NMtQueueRef; // ====================================================================== @@ -39,14 +39,14 @@ typedef struct NMtDataBuffer struct NMtDataBuffer *next; struct NMtDataBuffer *prev; NMtUDPData data; - + } NMtDataBuffer; typedef struct NMtQueue { NMtDataBuffer *head; NMtDataBuffer *tail; - + } NMtQueue; typedef struct NMtQueues @@ -56,7 +56,7 @@ typedef struct NMtQueues NMtQueue outgoing_queue; NMtQueue outgoing_empty_queue; - + } NMtQueues; // ====================================================================== @@ -78,7 +78,7 @@ NMrQueue_AddBuffers( NMtQueues *inQueues, NMtQueueRef inQueueRef, UUtUns16 inNumBuffersToAdd); - + NMtDataBuffer* NMrQueue_DequeueBuffer( NMtQueues *inQueues, @@ -89,7 +89,7 @@ NMrQueue_EnqueueBuffer( NMtQueues *inQueues, NMtQueueRef inQueueRef, NMtDataBuffer *inDataBuffer); - + NMtDataBuffer* NMrQueue_GetNextBuffer( NMtQueues *inQueues, @@ -108,4 +108,4 @@ NMrQueue_GetBufferCount( NMtQueueRef inQueueRef); // ====================================================================== -#endif /* NM_QUEUES_H */ \ No newline at end of file +#endif /* NM_QUEUES_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_WinSock/NM_WinSock.c b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_WinSock/NM_WinSock.c index 962690b..c605a60 100644 --- a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_WinSock/NM_WinSock.c +++ b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_WinSock/NM_WinSock.c @@ -36,7 +36,7 @@ NMiWS_UDP_WriteData( UUtUns8 *inDataBuffer, UUtUns16 inNumBytes, UUtUns16 inFlags); - + // ====================================================================== // functions // ====================================================================== @@ -47,7 +47,7 @@ NMiWS_UDP_HandleRead( { UUtUns32 return_val; WSANETWORKEVENTS events; - + // poll for read events return_val = WSAWaitForMultipleEvents( @@ -60,7 +60,7 @@ NMiWS_UDP_HandleRead( { return; } - + // handle the events return_val = WSAEnumNetworkEvents( @@ -71,11 +71,11 @@ NMiWS_UDP_HandleRead( { return; } - + if (events.lNetworkEvents & FD_READ) { NMtDataBuffer *data_buffer; - + // continually read until recvfrom returns no data while (1) { @@ -90,7 +90,7 @@ NMiWS_UDP_HandleRead( inNetContext->out_of_incoming_buffers = UUcTrue; break; } - + data_buffer->data.address_length = NMcMaxAddressLength; // read the data @@ -105,26 +105,26 @@ NMiWS_UDP_HandleRead( if ((return_val == SOCKET_ERROR) || (return_val == 0)) { error_val = GetLastError(); - + // put the data_buffer into the incoming empty queue NMrQueue_EnqueueBuffer( &inNetContext->private_data->queues, NMcIncomingEmptyQueue, data_buffer); - + break; } else { NMtPacket *data_packet; - + // get a pointer to the data_packet data_packet = (NMtPacket*)&data_buffer->data.buffer; - + // swap the data UUrSwap_4Byte(&data_packet->packet_header.packet_flags); UUrSwap_4Byte(&data_packet->packet_header.packet_data_size); - + // put the data into the incoming empty queue NMrQueue_EnqueueBuffer( &inNetContext->private_data->queues, @@ -134,7 +134,7 @@ NMiWS_UDP_HandleRead( } } } - + // ====================================================================== #if 0 #pragma mark - @@ -151,16 +151,16 @@ NMiWS_UDP_CloseSocket( WSACloseEvent(inNetContext->private_data->event); inNetContext->private_data->event = WSA_INVALID_EVENT; } - + // close the socket if (inNetContext->private_data->socket != INVALID_SOCKET) { closesocket(inNetContext->private_data->socket); inNetContext->private_data->socket = INVALID_SOCKET; } - + // delete - + return UUcError_None; } @@ -183,12 +183,12 @@ NMiWS_UDP_Broadcast( // get a pointer to the address address = (SOCKADDR_IN*)raw; - + // init address address->sin_family = AF_INET; address->sin_port = htons(inPortNumber); address->sin_addr.s_addr = INADDR_BROADCAST; - + // send the data to every machine on the local network error = NMiWS_UDP_WriteData( @@ -198,7 +198,7 @@ NMiWS_UDP_Broadcast( inNumBytes, NMcPacketFlags_None); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -212,19 +212,19 @@ NMiWS_UDP_CloseProtocol( // close the socket error = NMiWS_UDP_CloseSocket(inNetContext); UUmError_ReturnOnError(error); - + // terminate the queues NMrQueue_Terminate(&inNetContext->private_data->queues); - + // free the private_data if (inNetContext->private_data) { UUrMemory_Block_Delete(inNetContext->private_data); } - + // shutdown winsock WSACleanup(); - + return UUcError_None; } @@ -237,16 +237,16 @@ NMiWS_UDP_CompareAddresses( { SOCKADDR_IN *addr_1; SOCKADDR_IN *addr_2; - + // get a pointer to the two addresses addr_1 = (SOCKADDR_IN*)inAddress1; addr_2 = (SOCKADDR_IN*)inAddress2; - + if (addr_1->sin_addr.s_addr == addr_2->sin_addr.s_addr) { return UUcTrue; } - + return UUcFalse; } @@ -259,19 +259,19 @@ NMiWS_UDP_GetAddress( UUtUns32 return_val; HOSTENT *host_ent; IN_ADDR address; - + return_val = gethostname(host_name, sizeof(host_name)); if (return_val == SOCKET_ERROR) return NULL; - + host_ent = gethostbyname(host_name); if (host_ent == NULL) return NULL; - + if (host_ent->h_addr_list[0] != NULL) { UUrMemory_MoveFast(host_ent->h_addr_list[0], &address, sizeof(IN_ADDR)); return (UUtUns8*)inet_ntoa(address); } - + return NULL; } @@ -295,10 +295,10 @@ NMiWS_UDP_ReadData( { return UUcFalse; } - + // get a pointer to the data_packet data_packet = (NMtPacket*)&data_buffer->data.buffer; - + // set the outgoing data UUrMemory_MoveFast( &data_buffer->data.address, @@ -306,13 +306,13 @@ NMiWS_UDP_ReadData( sizeof(NMtNetAddress)); *outNumBytes = (UUtUns16)data_packet->packet_header.packet_data_size; UUrMemory_MoveFast(&data_packet->packet_data, outDataBuffer, *outNumBytes); - + // put the buffer onto the incoming empty queue NMrQueue_EnqueueBuffer( &inNetContext->private_data->queues, NMcIncomingEmptyQueue, data_buffer); - + return UUcTrue; } @@ -334,14 +334,14 @@ NMiWS_UDP_StartProtocol( WSACleanup(); return UUcError_Generic; } - + // check winsock version if (wsaData.wVersion != NMcDesiredWinSockVersion) { WSACleanup(); return UUcError_Generic; } - + // allocate memory for the private data inNetContext->private_data = (NMtNetContextPrivate*)UUrMemory_Block_New( @@ -351,18 +351,18 @@ NMiWS_UDP_StartProtocol( WSACleanup(); return UUcError_OutOfMemory; } - + // clear the private_data UUrMemory_Clear( inNetContext->private_data, sizeof(NMtNetContextPrivate)); - + // set the socket and event to invalid values inNetContext->private_data->socket = INVALID_SOCKET; inNetContext->private_data->event = WSA_INVALID_EVENT; - + // create a socket - inNetContext->private_data->socket = + inNetContext->private_data->socket = socket( AF_INET, SOCK_DGRAM, @@ -372,11 +372,11 @@ NMiWS_UDP_StartProtocol( NMiWS_UDP_CloseProtocol(inNetContext); return UUcError_Generic; } - + if (inFlags & NMcFlag_Broadcast) { BOOL option_val; - + // set the SO_BROADCAST option for the socket option_val = UUcTrue; return_val = @@ -392,7 +392,7 @@ NMiWS_UDP_StartProtocol( return UUcError_Generic; } } - + // initialize the queues error = NMrQueue_Initialize( @@ -400,11 +400,11 @@ NMiWS_UDP_StartProtocol( NMcWS_UDP_NumIncomingBuffers, NMcWS_UDP_NumOutgoingBuffers); UUmError_ReturnOnError(error); - + // set the number of buffers inNetContext->num_incoming_buffers = NMcWS_UDP_NumIncomingBuffers; inNetContext->num_outgoing_buffers = NMcWS_UDP_NumOutgoingBuffers; - + // create an event object inNetContext->private_data->event = WSACreateEvent(); if (inNetContext->private_data->event == WSA_INVALID_EVENT) @@ -412,7 +412,7 @@ NMiWS_UDP_StartProtocol( NMiWS_UDP_CloseProtocol(inNetContext); return UUcError_Generic; } - + // make the socket nonblocking and tell it which events // to respond to return_val = @@ -425,13 +425,13 @@ NMiWS_UDP_StartProtocol( NMiWS_UDP_CloseProtocol(inNetContext); return UUcError_Generic; } - + // set the address server_address.sin_family = AF_INET; server_address.sin_addr.s_addr = INADDR_ANY; server_address.sin_port = htons((UUtUns16)inNetContext->port_number); - + // bind the name to the socket return_val = bind( @@ -443,7 +443,7 @@ NMiWS_UDP_StartProtocol( NMiWS_UDP_CloseProtocol(inNetContext); return UUcError_Generic; } - + return UUcError_None; } @@ -456,24 +456,24 @@ NMiWS_UDP_StringToAddress( NMtNetAddress *outNetAddress) { SOCKADDR_IN temp_address; - + // fill in the temp_address temp_address.sin_family = AF_INET; temp_address.sin_port = htons(inPortNumber); temp_address.sin_addr.s_addr = inet_addr((const char*)inString); - + // make sure the address is legitimate if (temp_address.sin_addr.s_addr == INADDR_NONE) { return UUcError_Generic; } - + // copy the temp address into the outNetAddress UUrMemory_MoveFast( &temp_address, outNetAddress, sizeof(NMtNetAddress)); - + return UUcError_None; } @@ -483,7 +483,7 @@ NMiWS_UDP_Update( NMtNetContext *inNetContext) { UUtError error; - + if (inNetContext->out_of_incoming_buffers) { error = @@ -528,7 +528,7 @@ NMiWS_UDP_Update( // read incoming packets and put them into the incoming queue NMiWS_UDP_HandleRead(inNetContext); - + return UUcError_None; } @@ -545,27 +545,27 @@ NMiWS_UDP_WriteData( NMtPacket raw; NMtPacket *data_packet; UUtUns16 packet_length; - + // calculate the packet length packet_length = sizeof(NMtPacketHeader) + inNumBytes; - + // get a pointer to the data_packet - data_packet = &raw; + data_packet = &raw; // initialize the packet data_packet->packet_header.packet_flags = inFlags; data_packet->packet_header.packet_data_size = inNumBytes; - + // swap the data UUrSwap_4Byte(&data_packet->packet_header.packet_flags); UUrSwap_4Byte(&data_packet->packet_header.packet_data_size); - + // copy the data into the packet UUrMemory_MoveFast( inDataBuffer, data_packet->packet_data, inNumBytes); - + // send the data return_val = sendto( @@ -594,9 +594,9 @@ NMrWS_AddressToString( const NMtNetAddress *inNetAddress) { SOCKADDR_IN *address; - + address = (SOCKADDR_IN*)inNetAddress; - + return (char*)inet_ntoa(address->sin_addr); } @@ -618,23 +618,23 @@ NMrWS_UDP_Initialize( WSACleanup(); return UUcError_Generic; } - + // check winsock version if (wsaData.wVersion < NMcDesiredWinSockVersion) { WSACleanup(); return UUcError_Generic; } - + // close Winsock WSACleanup(); - + // clear the methods struct UUrMemory_Clear(&methods, sizeof(NMtNetContextMethods)); - + // set the caps caps.type = NMcUDP; - + // set the function pointers in the methods struct methods.broadcast = NMiWS_UDP_Broadcast; methods.close_protocol = NMiWS_UDP_CloseProtocol; @@ -645,11 +645,11 @@ NMrWS_UDP_Initialize( methods.string_to_address = NMiWS_UDP_StringToAddress; methods.update = NMiWS_UDP_Update; methods.write_data = NMiWS_UDP_WriteData; - + // register the methods with the net manager error = NMrRegisterService(&caps, &methods); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_WinSock/NM_WinSock.h b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_WinSock/NM_WinSock.h index dfe001a..36b357f 100644 --- a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_WinSock/NM_WinSock.h +++ b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_WinSock/NM_WinSock.h @@ -17,7 +17,7 @@ char* NMrWS_AddressToString( const NMtNetAddress *inNetAddress); - + UUtError NMrWS_UDP_Initialize( void); @@ -27,4 +27,4 @@ NMrWS_UDP_Terminate( void); // ====================================================================== -#endif /* NM_WS_UDP_H */ \ No newline at end of file +#endif /* NM_WS_UDP_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_WinSock/NM_WinSock_Private.h b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_WinSock/NM_WinSock_Private.h index a1806e3..8b65e84 100644 --- a/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_WinSock/NM_WinSock_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_NetworkManager/NM_WinSock/NM_WinSock_Private.h @@ -18,8 +18,8 @@ struct NMtNetContextPrivate SOCKET socket; WSAEVENT event; NMtQueues queues; - + }; // ====================================================================== -#endif /* NM_WS_UDP_PRIVATE_H */ \ No newline at end of file +#endif /* NM_WS_UDP_PRIVATE_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Object/BFW_Doors.c b/BungieFrameWork/BFW_Source/BFW_Object/BFW_Doors.c index 2e2f889..57282f6 100644 --- a/BungieFrameWork/BFW_Source/BFW_Object/BFW_Doors.c +++ b/BungieFrameWork/BFW_Source/BFW_Object/BFW_Doors.c @@ -1,12 +1,12 @@ /* FILE: BFW_Doors.c - + AUTHOR: Quinn Dunki - + CREATED: 4/8/98 - + PURPOSE: Door stuff - + Copyright 1998 */ @@ -83,14 +83,14 @@ static ONtCharacter *OBiDoor_FirstCharacterProximity( for(itr = 0; itr < count; itr++) { ONtCharacter *character; - + character = character_list[itr]; UUmAssert(character->flags & ONcCharacterFlag_InUse); UUmAssert(!(character->flags & ONcCharacterFlag_Dead)); //if (UUrBitVector_TestBit(&inDoor->doorClass->invisibility,character->teamNumber)) continue; - + if (OBiDoor_CharacterProximity(inDoor,character)) { return character; } @@ -131,10 +131,10 @@ static UUtBool OBiDoor_CanOpen( */ OBtDoor *link; - + UUmAssert(inDoor->object); if (inDoor == OBgDoorChainRoot && !OBgDoorChainFirst) return UUcTrue; // End circular recursion - + // Check linked doors recursively first OBgDoorChainFirst = UUcFalse; if (inDoor->doorClass->linkID) @@ -177,11 +177,11 @@ static void OBiDoor_Open( */ OBtDoor *link; - + UUmAssert(inDoor); UUmAssert(inDoor->object); if (inDoor == OBgDoorChainRoot && !OBgDoorChainFirst) return; // End circular recursion - + // Activate linked doors recursively first OBgDoorChainFirst = UUcFalse; if (inDoor->doorClass->linkID) @@ -208,7 +208,7 @@ static void OBiDoor_Open( inDoor->doorClass->openCloseAnim, inDoor->object->physics->animContext.animationFrame, inDoor->doorClass->openCloseAnim->doorOpenFrames); - inDoor->object->physics->animContext.animationFrame = + inDoor->object->physics->animContext.animationFrame = inDoor->doorClass->openCloseAnim->numFrames - inDoor->object->physics->animContext.animationFrame - 1; } } @@ -223,10 +223,10 @@ static UUtBool OBiDoor_CanClose( OBtDoor *link; ONtCharacter *character; - + UUmAssert(inDoor->object); if (inDoor == OBgDoorChainRoot && !OBgDoorChainFirst) return UUcTrue; // End circular recursion - + // Check linked doors recursively first OBgDoorChainFirst = UUcFalse; if (inDoor->doorClass->linkID) @@ -280,10 +280,10 @@ static void OBiDoor_Close( */ OBtDoor *link; - + UUmAssert(inDoor->object); if (inDoor == OBgDoorChainRoot && !OBgDoorChainFirst) return; // End circular recursion - + // Activate linked doors recursively first OBgDoorChainFirst = UUcFalse; if (inDoor->doorClass->linkID) @@ -309,7 +309,7 @@ static void OBiDoor_Close( inDoor->doorClass->openCloseAnim, inDoor->object->physics->animContext.animationFrame, inDoor->doorClass->openCloseAnim->numFrames); - inDoor->object->physics->animContext.animationFrame = + inDoor->object->physics->animContext.animationFrame = inDoor->doorClass->openCloseAnim->numFrames - inDoor->object->physics->animContext.animationFrame; } } @@ -323,10 +323,10 @@ static void OBiDoor_Lock( */ OBtDoor *link; - + UUmAssert(inDoor->object); if (inDoor == OBgDoorChainRoot && !OBgDoorChainFirst) return; // End circular recursion - + // Activate linked doors recursively first OBgDoorChainFirst = UUcFalse; if (inDoor->doorClass->linkID) @@ -353,10 +353,10 @@ static void OBiDoor_Unlock( */ OBtDoor *link; - + UUmAssert(inDoor->object); if (inDoor == OBgDoorChainRoot && !OBgDoorChainFirst) return; // End circular recursion - + // Activate linked doors recursively first OBgDoorChainFirst = UUcFalse; if (inDoor->doorClass->linkID) @@ -484,7 +484,7 @@ void OBrDoor_Array_Update( check_player_activate = ((player_active->inputState.buttonWentDown & LIc_BitMask_Action) > 0); best_angle = +1e09; best_door = NULL; - + // Update doors for (i=0; inumDoors; i++) { @@ -504,7 +504,7 @@ void OBrDoor_Array_Update( } else { - if (door->state == OBcDoorState_Open) + if (door->state == OBcDoorState_Open) { OBrDoor_Close(door,character); } @@ -524,7 +524,7 @@ void OBrDoor_Array_Update( MUmVector_Subtract(charToDoor,door->object->physics->position,charSource); MUrNormalize(&charToDoor); door_angle = MUrAngleBetweenVectors3D(&charToDoor,&player_character->facingVector); - + if (door_angle < best_angle) { best_door = door; best_angle = door_angle; @@ -543,7 +543,7 @@ void OBrDoor_Array_Update( OBrDoor_Open(best_door, player_character); } } -} +} static UUtError OBrObjectArrayFromDoorID( UUtUns16 inID, OBtObject ***ioArray, UUtUns32 *ioCount ) { @@ -571,10 +571,10 @@ static UUtError OBrObjectArrayFromDoorID( UUtUns16 inID, OBtObject ***ioArray, U *ioCount = 0; return UUcError_None; } - + new_array = (OBtObject**) UUrMemory_Block_New(sizeof(OBtObject*) * count ); count = 0; - + for (i=0; inumObjects; i++) { object = oblist->object_list + i; @@ -620,7 +620,7 @@ UUtError OBrDoor_Array_LevelBegin( UUtUns16 i; OBtDoor *door; - + if (inClasses == NULL) { inDoors->numDoors = 0; inDoors->doors = NULL; @@ -664,7 +664,7 @@ void OBrDoor_Array_LevelEnd( * Clean up doors from a level */ - if (inDoors != NULL) + if (inDoors != NULL) { if (inDoors->doors != NULL) { diff --git a/BungieFrameWork/BFW_Source/BFW_Object/BFW_Object.c b/BungieFrameWork/BFW_Source/BFW_Object/BFW_Object.c index de7053f..6937751 100644 --- a/BungieFrameWork/BFW_Source/BFW_Object/BFW_Object.c +++ b/BungieFrameWork/BFW_Source/BFW_Object/BFW_Object.c @@ -1,12 +1,12 @@ /* FILE: BFW_Object.c - + AUTHOR: Quinn Dunki, Michael Evans - + CREATED: 4/8/98 - + PURPOSE: Object engine - + Copyright (c) Bungie Software 1998,2000 */ @@ -186,8 +186,8 @@ static UUtBool OBiIsVisible(OBtObject *inObject) M3rCamera_GetStaticData(ONgVisibilityCamera, &fov, NULL, NULL, &farP); M3rCamera_GetViewData(ONgVisibilityCamera, &camera_location, &view_vector, NULL); - distance_squared = MUrPoint_Distance_Squared(¢er, &camera_location); - + distance_squared = MUrPoint_Distance_Squared(¢er, &camera_location); + MUmVector_Subtract(toObj, center, camera_location); MUrNormalize(&toObj); @@ -213,7 +213,7 @@ static UUtBool OBiIsVisible(OBtObject *inObject) AKrEnvironment_NodeList_Get(&bbox, OBcObjectNodeCount, inObject->oct_tree_node_index, 0); inObject->last_position= center; } - + object_is_visible= AKrEnvironment_NodeList_Visible(inObject->oct_tree_node_index); } } @@ -250,7 +250,7 @@ void OBrShow(OBtObject *inObject, UUtBool inShow) } else { inObject->flags |= OBcFlags_Invisible; - + if (NULL != inObject->physics) { inObject->physics->flags |= PHcFlags_Physics_NoCollision; } @@ -276,11 +276,11 @@ static void OBiCallback_PostCollision( PHtCollider *collider; ONtCharacter *victim; PHtPhysicsContext *otherContext; - + for (i=0; i<*ioColliderCount; i++) { collider = ioColliderArray + i; - + // Character effects if (collider->type == PHcCollider_Phy) { @@ -298,7 +298,7 @@ static void OBiUpdate(OBtObject *ioObject) /****************** * Updates an object for this frame */ - + // Track physics UUmAssert(ioObject->physics->sphereTree); @@ -313,31 +313,31 @@ static void OBiUpdate(OBtObject *ioObject) } static void OBiDraw(OBtObject *inObject) -{ +{ UUtBool draw_object_bounding_boxes = UUcFalse; if (inObject->flags & OBcFlags_Invisible) { return; } - + if (OBgObjectsShowDebug) - { + { UUtUns32 index = inObject->physics - PHgPhysicsContextArray->contexts; M3rGeom_State_Push(); - + // Draw bounding spheres and boxes M3rGeom_State_Set(M3cGeomStateIntType_Fill, M3cGeomState_Fill_Line); M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor,IMcShade_White); M3rGeom_State_Set(M3cGeomStateIntType_Appearance, M3cGeomState_Appearance_Gouraud); - + if (inObject->physics->sphereTree) PHrSphereTree_Draw(inObject->physics->sphereTree); if (NULL != inObject->physics->worldAlignedBounds) { M3rBVolume_Draw_Line(inObject->physics->worldAlignedBounds, IMcShade_Green); } - + M3rGeom_State_Pop(); } @@ -346,8 +346,8 @@ static void OBiDraw(OBtObject *inObject) M3tMatrix4x3 *matrix = &inObject->physics->matrix; M3rMatrixStack_Push(); - M3rMatrixStack_Multiply(matrix); - + M3rMatrixStack_Multiply(matrix); + if (inObject->flags & OBcFlags_JelloObjects) { M3rGeom_State_Set(M3cGeomStateIntType_Alpha, 31); inObject->flags &= ~OBcFlags_JelloObjects; @@ -356,8 +356,8 @@ static void OBiDraw(OBtObject *inObject) M3rGeom_State_Set(M3cGeomStateIntType_Alpha, M3cMaxAlpha); } - if (inObject->flags & OBcFlags_FlatLighting) { - const static float shade_scale = 1.f / 255.f; // S.S. + if (inObject->flags & OBcFlags_FlatLighting) { + const static float shade_scale = 1.f / 255.f; // S.S. float r = shade_scale * ((inObject->flat_lighting_shade & 0xFF0000) >> 16); float g = shade_scale * ((inObject->flat_lighting_shade & 0xFF00) >> 8); float b = shade_scale * ((inObject->flat_lighting_shade & 0xFF) >> 0); @@ -368,7 +368,7 @@ static void OBiDraw(OBtObject *inObject) M3rGeom_State_Commit(); for( i = 0; i < inObject->geometry_count; i++ ) - { + { M3rGeometry_Draw(inObject->geometry_list[i]); } @@ -415,7 +415,7 @@ void OBrList_Delete(OBtObjectList *inList) if (!inList) return; - for (i=0; inumObjects; i++) + for (i=0; inumObjects; i++) { if (inList->object_list[i].flags & OBcFlags_InUse) { OBrDelete(inList->object_list + i); @@ -432,11 +432,11 @@ void OBrList_Update( { UUtUns16 itr; OBtObject *object; - + UUmAssertReadPtr(ioObjectList, sizeof(OBtObjectList)); - + if (!ioObjectList->numObjects) return; - + // Update all the objects for(itr=0; itr < ioObjectList->numObjects; itr++) { @@ -467,7 +467,7 @@ void OBrList_Draw(OBtObjectList *inObjectList) } M3rGeom_State_Pop(); - + return; } @@ -478,7 +478,7 @@ OBtObject *OBrList_Add(OBtObjectList *inObjectList) UUmAssertReadPtr(inObjectList, sizeof(OBtObjectList)); - for(itr = 0; itr < inObjectList->numObjects; itr++) + for(itr = 0; itr < inObjectList->numObjects; itr++) { if (inObjectList->object_list[itr].flags & OBcFlags_InUse) { continue; @@ -486,7 +486,7 @@ OBtObject *OBrList_Add(OBtObjectList *inObjectList) object = inObjectList->object_list + itr; } - + if (NULL == object) { if (inObjectList->numObjects < inObjectList->maxObjects) { object = inObjectList->object_list + inObjectList->numObjects; @@ -530,7 +530,7 @@ void OBrAnim_Stop( if (ioAnimContext->animationFrame >= ioAnimContext->animation->numFrames) { ioAnimContext->animationFrame = ioAnimContext->animation->numFrames-1; } - + if (ioAnimContext->animationFrame < 0) { ioAnimContext->animationFrame = 0; } @@ -555,9 +555,9 @@ void OBrAnim_Matrix( M3tMatrix4x3 *outMatrix) { OBrAnimation_GetMatrix( - ioAnimContext->animation, - ioAnimContext->animationFrame, - ioAnimContext->animContextFlags, + ioAnimContext->animation, + ioAnimContext->animationFrame, + ioAnimContext->animContextFlags, outMatrix); return; @@ -581,7 +581,7 @@ void OBrAnimation_GetMatrix( M3tQuaternion quat; M3tPoint3D translation; - + M3tMatrix4x3 rotateTM, translateTM, finalTM; UUmAssertReadPtr(inAnimation, sizeof(*inAnimation)); @@ -647,11 +647,11 @@ void OBrAnimation_GetMatrix( if (inAnimation->animFlags & OBcAnimFlags_Localized) MUrMatrix_FromMax(outMatrix); -// if (inAnimContextFlags & OBcAnimContextFlags_RotateY180) +// if (inAnimContextFlags & OBcAnimContextFlags_RotateY180) // MUrMatrixStack_RotateY( outMatrix, M3cPi ); /* - if (inAnimContextFlags & OBcAnimContextFlags_RotateY180) + if (inAnimContextFlags & OBcAnimContextFlags_RotateY180) { M3tMatrix4x3 m1; MUrMatrix_Identity(&m1); @@ -717,7 +717,7 @@ void OBrDelete( PHrPhysicsContext_Remove(ioObject->physics); ioObject->physics = NULL; - + return; } @@ -758,7 +758,7 @@ static PHtSphereTree *OBiMakeSphereTree( UUtError OBrInit( OBtObject *ioObject, - OBtObjectSetup *inSetup) + OBtObjectSetup *inSetup) { /********** * Allocates an object @@ -778,7 +778,7 @@ UUtError OBrInit( bounding_volume_memory = &ioObject->bounding_volume_memory; } - + ioObject->ignoreCharacterIndex = 0xffff; // note make this a constant, in oni character ? ioObject->flat_lighting_shade = IMcShade_White; @@ -789,7 +789,7 @@ UUtError OBrInit( physics = ioObject->physics; PHrPhysics_Init(physics); OBrAnim_Reset(&physics->animContext); - + // Set up basic physics goo UUrMemory_Clear(&callback, sizeof(callback)); callback.type= PHcCallback_Object; @@ -806,7 +806,7 @@ UUtError OBrInit( physics->callback = &callback; physics->staticFriction = PHcDefaultStaticFriction; physics->dynamicFriction = PHcDefaultDynamicFriction; - + // Perform Setup setup if (inSetup) { @@ -816,14 +816,14 @@ UUtError OBrInit( ioObject->flags = (UUtUns16)inSetup->flags; ioObject->setup = inSetup; - - UUmAssert(inSetup->geometry_array->numGeometries <= OBcMaxGeometries); + + UUmAssert(inSetup->geometry_array->numGeometries <= OBcMaxGeometries); ioObject->geometry_count = UUmMin(inSetup->geometry_array->numGeometries, OBcMaxGeometries); - + for( i = 0; i < ioObject->geometry_count; i++ ) - { + { ioObject->geometry_list[i] = inSetup->geometry_array->geometries[i]; - + if( i == 0 ) { limits = ioObject->geometry_list[i]->pointArray->minmax_boundingBox; @@ -838,14 +838,14 @@ UUtError OBrInit( limits.maxPoint.y = UUmMax( ioObject->geometry_list[i]->pointArray->minmax_boundingBox.maxPoint.y, limits.maxPoint.y ); limits.maxPoint.z = UUmMax( ioObject->geometry_list[i]->pointArray->minmax_boundingBox.maxPoint.z, limits.maxPoint.z ); } - + if (ioObject->geometry_list[i]->triNormalArray->numVectors == 1) { M3tPlaneEquation plane; M3tPoint3D *point; M3tVector3D *normal; const float growAmt = 5.f; - + UUmAssert(ioObject->geometry_list[i]->pointArray != NULL); point = ioObject->geometry_list[i]->pointArray->points; @@ -858,8 +858,8 @@ UUtError OBrInit( M3rBBox_GrowFromPlane(&ioObject->physics->axisBox, &plane, growAmt); } - } - + } + M3rMinMaxBBox_To_BBox(&limits, &physics->axisBox); // Set up the bounding volumes tree = OBiMakeSphereTree(ioObject,inSetup); @@ -891,7 +891,7 @@ UUtError OBrInit( if (ioObject->flags & OBcFlags_NoGravity) { ioObject->physics->flags |= PHcFlags_Physics_NoGravity; } - + physics->origin = inSetup->debugOrigMatrix; physics->sphereTree = tree; physics->orientation = inSetup->orientation; @@ -908,7 +908,7 @@ UUtError OBrInit( else { physics->level = (PHtPhysicsLevel)inSetup->physicsLevel; } - + // Set up attached particles ioObject->particleArray = inSetup->particleArray; error = OBrSetParticles(ioObject, UUcTrue); @@ -1058,8 +1058,8 @@ void OBrNotifyPhysicsCollision(OBtObject *inObject, const PHtPhysicsContext *inC gNumObjectCollisionPoints = UUmMax(gNumObjectCollisionPoints, gNextObjectCollisionPoint); // compare this direction with the normal vector of the collision - dot_product = collider->plane.a * direction_of_motion.x + - collider->plane.b * direction_of_motion.y + + dot_product = collider->plane.a * direction_of_motion.x + + collider->plane.b * direction_of_motion.y + collider->plane.c * direction_of_motion.z; if (dot_product < 0.5f) { // our direction of movement is away from the plane of the collision, we can continue moving diff --git a/BungieFrameWork/BFW_Source/BFW_Object/BFW_Object_Templates.h b/BungieFrameWork/BFW_Source/BFW_Object/BFW_Object_Templates.h index 8542082..42e8c8b 100644 --- a/BungieFrameWork/BFW_Source/BFW_Object/BFW_Object_Templates.h +++ b/BungieFrameWork/BFW_Source/BFW_Object/BFW_Object_Templates.h @@ -1,12 +1,12 @@ /* FILE: BFW_Object_Templates.h - + AUTHOR: Quinn Dunki, Michael Evans - + CREATED: 4/8/98 - + PURPOSE: Interface to the Object engine - + Copyright (c) Bungie Software 1998-2000 */ @@ -34,7 +34,7 @@ typedef tm_template('O','B','A','N',"Object animation") OBtAnimation { // implied 8 bytes here - + // char owner[64]; // Must be same as OBcMaxObjectName tm_pad pad0[12]; @@ -47,7 +47,7 @@ OBtAnimation UUtUns16 numFrames; UUtUns16 doorOpenFrames; - + tm_varindex UUtUns16 numKeyFrames; tm_vararray OBtAnimationKeyFrame keyFrames[1]; } OBtAnimation; @@ -56,7 +56,7 @@ OBtAnimation typedef struct OBtAnimationContext { OBtAnimation *animation; - + UUtUns16 animContextFlags; UUtInt16 animationFrame; UUtInt16 animationStep; @@ -77,35 +77,35 @@ typedef struct OBtAnimationContext M3tGeometryArray *geometry_array; OBtAnimation* animation; - + EPtEnvParticleArray* particleArray; - + UUtUns32 flags; UUtUns32 doorGhostIndex; UUtUns32 doorScriptID; // 0 if not a door UUtUns32 physicsLevel; UUtUns32 scriptID; - + M3tPoint3D position; M3tQuaternion orientation; float scale; M3tMatrix4x3 debugOrigMatrix; - + char objName[64]; // Must match OBcMaxObjectName above char fileName[64]; // Must match OBcMaxObjectName above } OBtObjectSetup; - + #define OBcTemplate_ObjectArray UUm4CharToUns32('O','B','O','A') typedef tm_template('O','B','O','A', "Starting Object Array") OBtObjectSetupArray { tm_pad pad0[22]; - + tm_varindex UUtUns16 numObjects; tm_vararray OBtObjectSetup objects[1]; } OBtObjectSetupArray; - - -#endif // __BFW_OBJECT_TEMPLATES_H__ \ No newline at end of file + + +#endif // __BFW_OBJECT_TEMPLATES_H__ diff --git a/BungieFrameWork/BFW_Source/BFW_Object/BFW_Physics.c b/BungieFrameWork/BFW_Source/BFW_Object/BFW_Physics.c index 9f977c4..ed5362c 100644 --- a/BungieFrameWork/BFW_Source/BFW_Object/BFW_Physics.c +++ b/BungieFrameWork/BFW_Source/BFW_Object/BFW_Physics.c @@ -1,12 +1,12 @@ /* FILE: BFW_Physics.c - + AUTHOR: Quinn Dunki, Michael Evans - + CREATED: 4/8/98 - + PURPOSE: Physics engine - + Copyright (c) Bungie Software 1998, 1999, 2000 */ @@ -40,7 +40,7 @@ static void PHiPhysics_Apply_Gravity(PHtPhysicsContext *inContext) { /************ * Applies gravity to an object - */ + */ if (inContext->flags & PHcFlags_Physics_NoGravity) { } else { @@ -88,7 +88,7 @@ static PHtSphereTree *OBiCollision_SphereTree_Env( inSkipFlag, inV); - if (collision) + if (collision) { return collision; } @@ -148,7 +148,7 @@ UUtBool PHrCollision_Point_SphereTree( { break; } - } + } } if (outChildB) @@ -193,7 +193,7 @@ UUtBool PHrCollision_Volume_SphereTree( normalV = *inAV; d = MUmVector_GetLength(normalV); - + discardByAV = !(inUseMinimumDiscardThreshold && (fabs(d) < PHcBackfacingMinVelocity)); if (discardByAV) { if (d!=0.0f) MUmVector_Scale(normalV,1.0f/d); @@ -283,7 +283,7 @@ PHtSphereTree *PHrCollision_SphereTree_SphereTree( * * Collides iff a leaf node of a collides with leaf node of b * - * returns the leaf of a that collide and in outChildB sets the + * returns the leaf of a that collide and in outChildB sets the * leaf of B that collided * */ @@ -341,7 +341,7 @@ PHtSphereTree *PHrCollision_SphereTree_SphereTree( { break; } - } + } } if (outChildB) @@ -427,7 +427,7 @@ UUtBool PHrPhysics_Update_Animation( // Autostart animation OBrAnim_Start(ioAnimContext); } - + if (ioAnimContext->animContextFlags & OBcAnimContextFlags_Animate) { // Track frame number @@ -476,7 +476,7 @@ UUtBool PHrPhysics_Update_Animation( } static void PHiRemoveBackfacingCollisions( - PHtPhysicsContext *inContext, + PHtPhysicsContext *inContext, const M3tVector3D *inVelocity, PHtCollider *ioColliders, UUtUns16 *ioNumColliders) @@ -512,7 +512,7 @@ static void PHiRemoveBackfacingCollisions( remove = UUcTrue; } } - + if (remove) { count -= 1; @@ -552,7 +552,7 @@ static int UUcExternal_Call sort_collisions_callback(const void *elem_1, const v } static void sort_collisions( - const PHtPhysicsContext *inContext, + const PHtPhysicsContext *inContext, PHtCollider *colliders, UUtUns16 numColliders) { @@ -582,7 +582,7 @@ UUtBool OBrPhysics_Update_Reflect(PHtPhysicsContext *inContext, M3tVector3D *inV MUmAssertVector(*inVelocityThisFrame, 1e9f); numColliders = 0; - + switch (inContext->level) { case PHcPhysics_None: @@ -617,8 +617,8 @@ UUtBool OBrPhysics_Update_Reflect(PHtPhysicsContext *inContext, M3tVector3D *inV // sort_collisions(inContext, colliders, numColliders); - - if (inContext->flags & PHcFlags_Physics_IgnoreReflection) { + + if (inContext->flags & PHcFlags_Physics_IgnoreReflection) { goto skip_reflection; } @@ -640,7 +640,7 @@ UUtBool OBrPhysics_Update_Reflect(PHtPhysicsContext *inContext, M3tVector3D *inV if (!MUmVector_IsZero(pushBackVector)) { reflected = UUcTrue; - + if (inContext->callback->applyForce != NULL) { inContext->callback->applyForce(inContext, colliders + itr); } @@ -694,11 +694,11 @@ UUtBool OBrPhysics_Update_ReflectHalt(PHtPhysicsContext *inContext, M3tVector3D PHtPhysicsContext *pushedContext; // 3. recollide & respond with a halt - + // PHtCollider *closest_collider; numColliders = 0; - + switch (inContext->level) { case PHcPhysics_None: @@ -724,9 +724,9 @@ UUtBool OBrPhysics_Update_ReflectHalt(PHtPhysicsContext *inContext, M3tVector3D default: UUmAssert(!"Unsupported physics type"); } - + PHiRemoveBackfacingCollisions(inContext, inVelocityThisFrame, colliders, &numColliders); - + // closest_collider = find_closest_collider(numColliders, colliders); // distance_to_plane = magic_compute_distance_to_plane(inContext, closest_collider.plane); // MUrVector_Set_Length(inVelocityThisFrame, distance_to_plane); @@ -798,7 +798,7 @@ static void OBiPhysics_Update(PHtPhysicsContext *inContext) M3tVector3D velocityThisFrame; AKtEnvironment *environment = ONgGameState->level->environment; - + // set up for the new frame inContext->flags &= ~PHcFlags_Physics_CollidedThisFrame; @@ -899,9 +899,9 @@ static void OBiPhysics_Update(PHtPhysicsContext *inContext) MUmAssertVector(inContext->velocity, 1e9f); MUmAssertVector(velocityThisFrame, 1e9f); - + // 5. private movement - if (NULL != inContext->callback->privateMovement) + if (NULL != inContext->callback->privateMovement) { inContext->callback->privateMovement(inContext); } @@ -926,7 +926,7 @@ static void OBiPhysics_Update(PHtPhysicsContext *inContext) MUmAssertVector(velocityThisFrame, 1e9f); // 8. update - if (NULL != inContext->callback->update) + if (NULL != inContext->callback->update) { inContext->callback->update(inContext); } @@ -1018,7 +1018,7 @@ void PHrPhysicsContext_Delete(void) for (itr = 0; itr < count; itr++) { - if (PHgPhysicsContextArray->contexts[itr].flags & PHcFlags_Physics_InUse) { + if (PHgPhysicsContextArray->contexts[itr].flags & PHcFlags_Physics_InUse) { PHrPhysics_Delete(PHgPhysicsContextArray->contexts + itr); } } @@ -1044,7 +1044,7 @@ PHtPhysicsContext *PHrPhysicsContext_Add(void) if (NULL != PHgPhysicsContextArray) { UUtUns32 itr; - + for (itr=0; itr < PHgPhysicsContextArray->max_contexts; itr++) { if (PHgPhysicsContextArray->contexts[itr].flags & PHcFlags_Physics_InUse) { @@ -1062,7 +1062,7 @@ PHtPhysicsContext *PHrPhysicsContext_Add(void) } UUmAssert(!"Ran out of physics contexts! Fatal!"); - + exit: return result; } @@ -1191,7 +1191,7 @@ void PHrSphereTree_Delete(PHtSphereTree *inTree) */ if (!inTree) return; - if (inTree->sibling) + if (inTree->sibling) { PHrSphereTree_Delete(inTree->sibling); PHrSphereTree_Delete(inTree->child); @@ -1207,7 +1207,7 @@ static void PHiSphereTree_Draw(PHtSphereTree *tree) */ ONrDrawSphere( - NULL, + NULL, tree->sphere.radius, &tree->sphere.center); @@ -1220,7 +1220,7 @@ static void PHiSphereTree_Draw(PHtSphereTree *tree) { PHiSphereTree_Draw(tree->sibling); } - + return; } @@ -1248,10 +1248,10 @@ void PHrPhysics_MaintainMatrix(PHtPhysicsContext *physics) M3tPoint3D *point; M3tPlaneEquation *plane; UUtUns32 i; - + // Apply all positional data MUmAssertVector(physics->position, 1e9f); - + switch (physics->level) { case PHcPhysics_Static: @@ -1279,13 +1279,13 @@ noanim: case PHcPhysics_Newton: OBrAnim_Matrix(&physics->animContext, &physics->matrix); } - if (physics->animContext.animation->animFlags & OBcAnimFlags_Localized) + if (physics->animContext.animation->animFlags & OBcAnimFlags_Localized) { MUrMatrix_Multiply(&physics->origin, &physics->matrix, &physics->matrix); } // FIXME: jtd - this is a hack for double doors - if (physics->animContext.animContextFlags & OBcAnimContextFlags_RotateY180) + if (physics->animContext.animContextFlags & OBcAnimContextFlags_RotateY180) { MUrMatrixStack_RotateY( &physics->matrix, M3cPi ); MUrMatrixStack_RotateZ( &physics->matrix, M3cPi ); @@ -1309,7 +1309,7 @@ noanim: case PHcPhysics_Newton: &physics->matrix, physics->axisBox.localPoints, physics->worldAlignedBounds->worldPoints); - + // Update face planes and projections for (i=0; iworldAlignedBounds->normals + i, &physics->matrix, &normal); - + point = physics->worldAlignedBounds->worldPoints + physics->worldAlignedBounds->faces[i].indices[0]; plane = physics->worldAlignedBounds->curPlanes + i; @@ -1343,12 +1343,12 @@ void PHrPhysics_Delete(PHtPhysicsContext *ioPhysics) * Cleans up a physics context */ - if (ioPhysics->callback->preDispose) + if (ioPhysics->callback->preDispose) { ioPhysics->callback->preDispose(ioPhysics); } - if (ioPhysics->sphereTree) + if (ioPhysics->sphereTree) { PHrSphereTree_Delete(ioPhysics->sphereTree); } @@ -1389,8 +1389,8 @@ static UUtError PHrStatus( SLtErrorContext* inErrorContext, UUtUns32 inParameterListLength, SLtParameter_Actual *inParameterList, - UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtUns32 *outTicksTillCompletion, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { UUtUns32 itr; @@ -1501,7 +1501,7 @@ void PHrPhysics_Callback_FindEnvCollisions( else { AKrCollision_Sphere( - inEnvironment, + inEnvironment, &inContext->sphereTree->sphere, &localVelocity, collision_skipflag, @@ -1514,9 +1514,9 @@ void PHrPhysics_Callback_FindEnvCollisions( AKtGQ_General *gqGeneral = inEnvironment->gqGeneralArray->gqGeneral + curCollision->gqIndex; AKtGQ_Collision *gqCollision = inEnvironment->gqCollisionArray->gqCollision + curCollision->gqIndex; UUtBool touched; - + touched = UUcTrue; - + if (touched) { M3tPlaneEquation plane; @@ -1557,7 +1557,7 @@ void PHrPhysics_Callback_FindEnvCollisions( } } } - + return; } @@ -1581,7 +1581,7 @@ PHrPhysics_Single_PhyCollision( if (inTargetContext->flags & PHcFlags_Physics_DontBlock) return UUcFalse; if (inContext->flags & PHcFlags_Physics_NoCollision) return UUcFalse; if (inTargetContext->flags & PHcFlags_Physics_NoCollision) return UUcFalse; - + oldNumColliders = *ioNumColliders; useDiscardThreshold = (inTargetContext->level == PHcPhysics_Animate) && (inContext->flags & PHcFlags_Physics_InitialCollisionPass); @@ -1623,7 +1623,7 @@ PHrPhysics_Single_PhyCollision( else { collideTree = PHrCollision_SphereTree_SphereTree( - inContext->sphereTree, + inContext->sphereTree, inVelocity, inTargetContext->sphereTree, NULL); @@ -1655,33 +1655,33 @@ PHrPhysics_Single_PhyCollision( plane.b = 1.0f; plane.c = 0; plane.d = - collisionPoint.y; - } else { + } else { // targetPoint = target_center + radius * vectorToMe temp = vectorToMe; MUmVector_Scale(temp, inTargetContext->sphereTree->sphere.radius); targetPoint = inTargetContext->sphereTree->sphere.center; MUmVector_Increment(targetPoint, temp); - + // myPoint = my_center + -radius * vectorToMe temp = vectorToMe; MUmVector_Scale(temp, -inContext->sphereTree->sphere.radius); myPoint = inContext->sphereTree->sphere.center; MUmVector_Increment(myPoint, temp); - + // average those two points MUmVector_Add(collisionPoint, targetPoint, myPoint); MUmVector_Scale(collisionPoint, 0.5f); - + // compute the plane plane.a = vectorToMe.x; plane.b = vectorToMe.y; plane.c = vectorToMe.z; - + // ax + by + cz + d = 0 // d = -(ax + by + cz) plane.d = -( - (plane.a * collisionPoint.x) + - (plane.b * collisionPoint.y) + + (plane.a * collisionPoint.x) + + (plane.b * collisionPoint.y) + (plane.c * collisionPoint.z)); } @@ -1689,7 +1689,7 @@ PHrPhysics_Single_PhyCollision( newCollider->data = inTargetContext; newCollider->plane = plane; newCollider->planePoint = collisionPoint; - + (*ioNumColliders) += 1; } @@ -1717,7 +1717,7 @@ PHrPhysics_Callback_FindPhyCollisions( { UUtUns32 i; PHtCallback_SkipPhyCollisions skip_callback; - + skip_callback = inContext->callback->skipPhyCollisions; for (i = 0; i < PHgPhysicsContextArray->max_contexts; i++) @@ -1742,7 +1742,7 @@ PHrPhysics_Callback_FindPhyCollisions( } void PHrPhysics_Accelerate( - PHtPhysicsContext *physics, + PHtPhysicsContext *physics, const M3tVector3D *inAcceleration) { MUmVector_Increment(physics->acceleration, *inAcceleration); @@ -1849,7 +1849,7 @@ PHrCollision_Quad_SphereTreeVector( if (collide) { break; } } } - + return collide; } @@ -1865,7 +1865,7 @@ PHrPhysics_Colliders_GetFromSphere( UUtUns16 maxColliders; UUtUns16 curColliderIndex = 0; PHtCollider* curCollider; - + UUmAssertReadPtr(PHgPhysicsContextArray, sizeof(*PHgPhysicsContextArray)); UUmAssertReadPtr(inSphere, sizeof(*inSphere)); UUmAssertReadPtr(ioNumColliders, sizeof(*ioNumColliders)); @@ -1875,31 +1875,31 @@ PHrPhysics_Colliders_GetFromSphere( sphereTree.sphere = *inSphere; sphereTree.child = sphereTree.sibling = NULL; - + for(itr = 0; itr < PHgPhysicsContextArray->num_contexts; itr++) { PHtPhysicsContext *targetContext = PHgPhysicsContextArray->contexts + itr; - + if (!(targetContext->flags & PHcFlags_Physics_InUse)) continue; if (PHrCollision_SphereTree_SphereTree(&sphereTree, inVector, targetContext->sphereTree, NULL) != NULL) { // add this to colliders curCollider = outColliders + curColliderIndex++; - + curCollider->type = PHcCollider_Phy; curCollider->data = targetContext; curCollider->distanceSquared = MUmVector_GetDistanceSquared(sphereTree.sphere.center, targetContext->sphereTree->sphere.center); - + if(curColliderIndex >= maxColliders) break; } } - + if(curColliderIndex > 1) { qsort(outColliders, curColliderIndex, sizeof(PHtCollider), sort_collisions_callback); } - + *ioNumColliders = curColliderIndex; } diff --git a/BungieFrameWork/BFW_Source/BFW_Particle/BFW_Decal.c b/BungieFrameWork/BFW_Source/BFW_Particle/BFW_Decal.c index 96eee40..05e3069 100644 --- a/BungieFrameWork/BFW_Source/BFW_Particle/BFW_Decal.c +++ b/BungieFrameWork/BFW_Source/BFW_Particle/BFW_Decal.c @@ -1,12 +1,12 @@ /* FILE: BFW_Decal.c - + AUTHOR: Jason Duncan, Chris Butcher - + CREATED: June 03, 2000 - + PURPOSE: routines for decals - + Copyright 2000 bungie/microsoft */ @@ -360,9 +360,9 @@ static void P3iDecal_LinePlaneIntersection(M3tPoint3D *inPoint0, M3tPoint3D *inP { M3tVector3D inLine, delta_vec; float denom, t, one_minus_t, interp; - + MUmVector_Subtract(inLine, *inPoint1, *inPoint0); - + denom = inPlane->a * inLine.x + inPlane->b * inLine.y + inPlane->c * inLine.z; if ((float)fabs(denom) < P3cDecal_PlaneDenomTolerance) { // this is done purely because we _must_ return a value @@ -377,7 +377,7 @@ static void P3iDecal_LinePlaneIntersection(M3tPoint3D *inPoint0, M3tPoint3D *inP MUmVector_Copy(*outPoint, *inPoint0); MUmVector_ScaleIncrement(*outPoint, t, inLine); } - + if (outUV != NULL) { outUV->u = inUV1->u * t + inUV0->u * one_minus_t; outUV->v = inUV1->v * t + inUV0->v * one_minus_t; @@ -771,7 +771,7 @@ static UUtBool P3iDecal_ProcessAdjacency(AKtEnvironment *inEnvironment, UUtUns32 UUtUns32 found_adjacencies; P3tDecalEdge * current_adjacency; P3tDecalEdge * adjacencies[P3cDecal_MaxAdjacencies]; - + // source point buffer M3tPoint3D unprojected_points[4]; P3tDecalPointBuffer source_buffer; @@ -1532,7 +1532,7 @@ static UUtBool P3iDecal_ProcessAdjacency(AKtEnvironment *inEnvironment, UUtUns32 // we flipped this two-sided quote, make a note of such plane_index ^= 0x80000000; } - + if (num_quad_points > 3) { MUmVector_Subtract(quad_midvector, quad_points[2], quad_points[0]); MUmVector_ScaleCopy(quad_reversemidvector, -1, quad_midvector); @@ -1714,7 +1714,7 @@ UUtError P3rCreateDecal(M3tTextureMap *inTexture, UUtUns32 inGQIndex, UUtUns32 i // no collision, can't create decal return UUcError_Generic; } - + position = AKgCollisionList[0].collisionPoint; inGQIndex = AKgCollisionList[0].gqIndex; } else { @@ -1726,7 +1726,7 @@ UUtError P3rCreateDecal(M3tTextureMap *inTexture, UUtUns32 inGQIndex, UUtUns32 i } position = *inPosition; } - + // collide a sphere with the environment to find all nearby quads sphere.radius = MUrSqrt(UUmSQR(inXScale) + UUmSQR(inYScale)); sphere.center = position; @@ -1979,7 +1979,7 @@ UUtError P3rCreateDecal(M3tTextureMap *inTexture, UUtUns32 inGQIndex, UUtUns32 i continue; } - if (((float)fabs(P3gDecalBuildBuffer.points[j].x - compare_point.x) > P3cDecal_SharedPointTolerance) || + if (((float)fabs(P3gDecalBuildBuffer.points[j].x - compare_point.x) > P3cDecal_SharedPointTolerance) || ((float)fabs(P3gDecalBuildBuffer.points[j].y - compare_point.y) > P3cDecal_SharedPointTolerance) || ((float)fabs(P3gDecalBuildBuffer.points[j].z - compare_point.z) > P3cDecal_SharedPointTolerance)) { // the points are different and cannot be snapped to each other @@ -2080,7 +2080,7 @@ UUtError P3rCreateDecal(M3tTextureMap *inTexture, UUtUns32 inGQIndex, UUtUns32 i decal_size = sizeof(M3tDecalHeader); decal_size += vert_count * (sizeof(M3tVector3D) + sizeof(M3tTextureCoord) + sizeof(UUtUns32)); decal_size += index_count * sizeof(UUtUns16); - + if (inDecalFlags & P3cDecalFlag_Manual) { // write into the supplied decal buffer decal_data = (char*) inDecalData->decal_header; @@ -2191,7 +2191,7 @@ static void P3iLRAR_PurgeProc(void *inUserData) P3tParticle *particle; P3tParticleClass *particle_class; P3tDecalData *data_ptr; - + if( !inUserData ) return; diff --git a/BungieFrameWork/BFW_Source/BFW_Particle/BFW_EnvParticle.c b/BungieFrameWork/BFW_Source/BFW_Particle/BFW_EnvParticle.c index a3c763f..c2cf920 100644 --- a/BungieFrameWork/BFW_Source/BFW_Particle/BFW_EnvParticle.c +++ b/BungieFrameWork/BFW_Source/BFW_Particle/BFW_EnvParticle.c @@ -1,12 +1,12 @@ /* FILE: BFW_EnvParticle.c - + AUTHOR: Chris Butcher - + CREATED: May 26, 2000 - + PURPOSE: support for environmental particles - + Copyright (c) 2000, Bungie Software */ @@ -64,7 +64,7 @@ void EPrNotifyMatrixChange(EPtEnvParticle *inParticle, UUtUns32 inTime, UUtBool UUtUns32 *p_texture, *p_lensframes; AKtOctNodeIndexCache *p_envcache; UUtBool is_dead; - + // if we haven't been created, don't do anything if ((inParticle->flags & EPcParticleFlag_Created) == 0) return; @@ -78,7 +78,7 @@ void EPrNotifyMatrixChange(EPtEnvParticle *inParticle, UUtUns32 inTime, UUtBool EPrNewParticle( inParticle, inTime ); return; } - + // make sure there is a particle before going any further if (inParticle->particle == NULL) return; @@ -87,25 +87,25 @@ void EPrNotifyMatrixChange(EPtEnvParticle *inParticle, UUtUns32 inTime, UUtBool p_position = P3rGetPositionPtr(inParticle->particle_class, inParticle->particle, &is_dead); if (is_dead) return; - + // set up the particle's position from the envparticle's matrix *p_position = MUrMatrix_GetTranslation(&inParticle->matrix); - + p_orientation = P3rGetOrientationPtr(inParticle->particle_class, inParticle->particle); if (p_orientation != NULL) { MUrMatrix3x3_ExtractFrom4x3(p_orientation, &inParticle->matrix); } - + p_velocity = P3rGetVelocityPtr(inParticle->particle_class, inParticle->particle); if (p_velocity != NULL) { MUmVector_Set(*p_velocity, 0, 0, 0); } - + p_offset = P3rGetOffsetPosPtr(inParticle->particle_class, inParticle->particle); if (p_offset != NULL) { MUmVector_Set(*p_offset, 0, 0, 0); } - + p_dynamicmatrix = P3rGetDynamicMatrixPtr(inParticle->particle_class, inParticle->particle); if (p_dynamicmatrix != NULL) { *p_dynamicmatrix = inParticle->dynamic_matrix; @@ -116,7 +116,7 @@ void EPrNotifyMatrixChange(EPtEnvParticle *inParticle, UUtUns32 inTime, UUtBool break; } } - + /* everything below here only needs to be done once when the particle is created */ if (!inInitialize) return; @@ -125,13 +125,13 @@ void EPrNotifyMatrixChange(EPtEnvParticle *inParticle, UUtUns32 inTime, UUtBool if (p_owner != NULL) { *p_owner = 0; // flags this particle as an environmental particle } - + // randomise texture start index p_texture = P3rGetTextureIndexPtr(inParticle->particle_class, inParticle->particle); if (p_texture != NULL) { *p_texture = (UUtUns32) UUrLocalRandom(); } - + // set texture time index to be now p_texture = P3rGetTextureTimePtr(inParticle->particle_class, inParticle->particle); if (p_texture != NULL) { @@ -181,7 +181,7 @@ static UUtBool EPrNewDecal(EPtEnvParticle *inParticle, UUtUns32 inTime) environment = ONrGameState_GetEnvironment(); AKrCollision_Point(environment, &position, &findwall_ray, AKcGQ_Flag_Obj_Col_Skip, 1); - if (AKgNumCollisions == 0) + if (AKgNumCollisions == 0) return UUcFalse; quad_index = AKgCollisionList[0].gqIndex; @@ -191,7 +191,7 @@ static UUtBool EPrNewDecal(EPtEnvParticle *inParticle, UUtUns32 inTime) UUrMemory_Clear(&effect_data, sizeof(effect_data)); effect_data.cause_type = P3cEffectCauseType_ParticleHitWall; effect_data.cause_data.particle_wall.gq_index = quad_index; - effect_data.time = inTime; + effect_data.time = inTime; effect_data.position = AKgCollisionList[0].collisionPoint; MUrMatrix_GetCol(&inParticle->matrix, 2, &effect_data.upvector); effect_data.decal_xscale = inParticle->decal_xscale; @@ -222,12 +222,12 @@ static UUtBool EPrNewDecal(EPtEnvParticle *inParticle, UUtUns32 inTime) // ---------------------------------------------------------------------- // create an env particle UUtBool EPrNewParticle(EPtEnvParticle *inParticle, UUtUns32 inTime) -{ +{ inParticle->flags |= EPcParticleFlag_Created; if (inParticle->particle_class == NULL) return UUcFalse; - + if (inParticle->particle_class->definition->flags2 & P3cParticleClassFlag2_Appearance_Decal) { // create a decal instead return EPrNewDecal(inParticle, inTime); @@ -237,12 +237,12 @@ UUtBool EPrNewParticle(EPtEnvParticle *inParticle, UUtUns32 inTime) inParticle->particle = P3rCreateParticle(inParticle->particle_class, inTime); if (inParticle->particle == NULL) return UUcFalse; - + // save the particle's self_ref inParticle->particle_self_ref = inParticle->particle->header.self_ref; - + EPrNotifyMatrixChange(inParticle, inTime, UUcTrue); - + P3rSendEvent(inParticle->particle_class, inParticle->particle, P3cEvent_Create, ((float) inTime) / UUcFramesPerSecond); return UUcTrue; @@ -257,7 +257,7 @@ UUtBool EPrKillParticle(EPtEnvParticle *inParticle) if (inParticle->particle == NULL) { return UUcFalse; } - + if (inParticle->particle->header.self_ref != inParticle->particle_self_ref) { // this particle is already dead inParticle->particle_self_ref = P3cParticleReference_Null; @@ -268,11 +268,11 @@ UUtBool EPrKillParticle(EPtEnvParticle *inParticle) // we have a particle, we must have a particle class UUmAssert(inParticle->particle_class != NULL); - + P3rKillParticle(inParticle->particle_class, inParticle->particle); inParticle->particle = NULL; inParticle->particle_self_ref = P3cParticleReference_Null; - + return UUcTrue; } @@ -479,7 +479,7 @@ void EPrEnumerateByTag(char *inTag, EPtEnumCallback_EnvParticle inCallback, UUtU UUmAssertReadPtr(particle, sizeof(EPtEnvParticle)); inCallback(particle, inUserData); - + particle = particle->taglist; } } @@ -624,7 +624,7 @@ void EPrNew(EPtEnvParticle *inParticle, UUtUns32 inTime) void EPrDelete(EPtEnvParticle *inParticle) { UUtBool was_in_hash; - + // this should never be called for a particle that // hasn't already been added to the particle list UUmAssert(inParticle->flags & EPcParticleFlag_InUse); @@ -671,7 +671,7 @@ UUtError EPrArray_New(EPtEnvParticleArray *inParticleArray, UUtUns16 inOwnerType EPtEnvParticle *particle; char particle_tag[256]; UUtBool skip_prefix = ((inTagPrefix == NULL) || (inTagPrefix[0] == '\0')); - + if (inParticleArray == NULL) return UUcError_None; @@ -693,7 +693,7 @@ UUtError EPrArray_New(EPtEnvParticleArray *inParticleArray, UUtUns16 inOwnerType EPrNew(particle, inTime); } - + return UUcError_None; } @@ -701,7 +701,7 @@ void EPrArray_Delete(EPtEnvParticleArray *inParticleArray) { UUtUns32 itr; EPtEnvParticle *particle; - + if (inParticleArray == NULL) return; @@ -736,11 +736,11 @@ static void EPiDrawPositionMarker(EPtEnvParticle *inParticle, UUtUns32 inUserDat MUmVector_Set(tri[2], -0.8660f, 0.0f, -0.5f); tri[3] = tri[0]; M3rGeometry_LineDraw(4, tri, shade); - + MUmVector_Set(tri[0], 0.0f, 0.0f, 0.0f); MUmVector_Set(tri[1], 0.0f, 1.0f, 0.0f); M3rGeometry_LineDraw(2, tri, shade); - + M3rMatrixStack_Pop(); } @@ -772,7 +772,7 @@ UUtError EPrInitialize(void) UUtError EPrRegisterTemplates(void) { UUtError error; - + error = TMrTemplate_Register(EPcTemplate_EnvParticleArray, sizeof(EPtEnvParticleArray), TMcFolding_Allow); UUmError_ReturnOnError(error); @@ -825,4 +825,4 @@ void EPrDisplay(void) { if (EPgDrawParticles) EPrEnumerateAllParticles(EPiDrawPositionMarker, 0); -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_Particle/BFW_Particle3.c b/BungieFrameWork/BFW_Source/BFW_Particle/BFW_Particle3.c index 55c9de6..ec7b772 100644 --- a/BungieFrameWork/BFW_Source/BFW_Particle/BFW_Particle3.c +++ b/BungieFrameWork/BFW_Source/BFW_Particle/BFW_Particle3.c @@ -1,12 +1,12 @@ /* FILE: BFW_Particle3.c - + AUTHOR: Chris Butcher - + CREATED: Feb 03, 2000 - + PURPOSE: routines for new particle system (iteration 3) - + Copyright 2000 */ @@ -755,17 +755,17 @@ P3tActionTemplate P3gActionInfo[P3cNumActionTypes] = { {"swirl deltarate",P3cDataType_Float}, {"swirl speed", P3cDataType_Float}, VARS_4}}, - + {P3cActionType_FloatAbovePlayer, 0, "Follow Player",P3iAction_FloatAbovePlayer, 0, 1, { {"height", P3cDataType_Float}, VARS_1}}, - + {P3cActionType_StopIfSlow, 0, "Stop BelowSpeed",P3iAction_StopIfSlow, 0, 1, { {"speed", P3cDataType_Float}, VARS_1}}, - + {P3cActionType_SuperParticle, 0, "Super Particle", P3iAction_SuperParticle, 1, 4, { {"variable", P3cDataType_Float}, @@ -774,7 +774,7 @@ P3tActionTemplate P3gActionInfo[P3cNumActionTypes] = { {"min value",P3cDataType_Float}, {"max value",P3cDataType_Float}, VARS_5}}, - + /* * link control */ @@ -834,8 +834,8 @@ P3tEnumTypeInfo P3gEnumTypeInfo[P3cEnumType_Max >> P3cEnumShift] = { #define END {(UUtUns32) -1, "", 0, NO_PARAMS} -P3tEmitterSettingDescription P3gEmitterRateDesc[] = {{P3cEmitterRate_Continuous, "continuous", 1, - {{"emit interval", P3cDataType_Float}, +P3tEmitterSettingDescription P3gEmitterRateDesc[] = {{P3cEmitterRate_Continuous, "continuous", 1, + {{"emit interval", P3cDataType_Float}, {"", P3cDataType_None}, {"", P3cDataType_None}, {"", P3cDataType_None}}}, @@ -863,33 +863,33 @@ P3tEmitterSettingDescription P3gEmitterPositionDesc[] = {{P3cEmitterPosition_Poi {"", P3cDataType_None}, {"", P3cDataType_None}, {"", P3cDataType_None}}}, - {P3cEmitterPosition_Circle, "circle", 2, - {{"inner radius", P3cDataType_Float}, + {P3cEmitterPosition_Circle, "circle", 2, + {{"inner radius", P3cDataType_Float}, {"outer radius", P3cDataType_Float}, {"", P3cDataType_None}, {"", P3cDataType_None}}}, {P3cEmitterPosition_Sphere, "sphere", 2, - {{"inner radius", P3cDataType_Float}, + {{"inner radius", P3cDataType_Float}, {"outer radius", P3cDataType_Float}, {"", P3cDataType_None}, {"", P3cDataType_None}}}, {P3cEmitterPosition_Offset, "offset", 3, - {{"x", P3cDataType_Float}, + {{"x", P3cDataType_Float}, {"y", P3cDataType_Float}, {"z", P3cDataType_Float}, {"", P3cDataType_None}}}, {P3cEmitterPosition_Cylinder,"cylinder", 3, - {{"height", P3cDataType_Float}, + {{"height", P3cDataType_Float}, {"inner radius", P3cDataType_Float}, {"outer radius", P3cDataType_Float}, {"", P3cDataType_None}}}, {P3cEmitterPosition_BodySurface,"body-surface", 1, - {{"offsetradius", P3cDataType_Float}, + {{"offsetradius", P3cDataType_Float}, {"", P3cDataType_None}, {"", P3cDataType_None}, {"", P3cDataType_None}}}, {P3cEmitterPosition_BodyBones,"body-bones", 1, - {{"offsetradius", P3cDataType_Float}, + {{"offsetradius", P3cDataType_Float}, {"", P3cDataType_None}, {"", P3cDataType_None}, {"", P3cDataType_None}}}, @@ -897,31 +897,31 @@ P3tEmitterSettingDescription P3gEmitterPositionDesc[] = {{P3cEmitterPosition_Poi P3tEmitterSettingDescription P3gEmitterDirectionDesc[] = {{P3cEmitterDirection_Linear, "straight", 0, NO_PARAMS}, {P3cEmitterDirection_Random, "random", 0, NO_PARAMS}, - {P3cEmitterDirection_Conical, "cone", 2, - {{"angle", P3cDataType_Float}, + {P3cEmitterDirection_Conical, "cone", 2, + {{"angle", P3cDataType_Float}, {"center bias", P3cDataType_Float}, {"", P3cDataType_None}, {"", P3cDataType_None}}}, - {P3cEmitterDirection_Ring, "ring", 2, - {{"angle", P3cDataType_Float}, + {P3cEmitterDirection_Ring, "ring", 2, + {{"angle", P3cDataType_Float}, {"offset", P3cDataType_Float}, {"", P3cDataType_None}, {"", P3cDataType_None}}}, {P3cEmitterDirection_OffsetDir, "offset", 3, - {{"x", P3cDataType_Float}, + {{"x", P3cDataType_Float}, {"y", P3cDataType_Float}, {"z", P3cDataType_Float}, {"", P3cDataType_None}}}, {P3cEmitterDirection_Inaccurate,"inaccurate", 3, - {{"base angle", P3cDataType_Float}, + {{"base angle", P3cDataType_Float}, {"inaccuracy", P3cDataType_Float}, {"center bias", P3cDataType_Float}, {"", P3cDataType_None}}}, {P3cEmitterDirection_Attractor, "attractor", 0, NO_PARAMS}, END}; -P3tEmitterSettingDescription P3gEmitterSpeedDesc[] = {{P3cEmitterSpeed_Uniform, "uniform", 1, - {{"speed", P3cDataType_Float}, +P3tEmitterSettingDescription P3gEmitterSpeedDesc[] = {{P3cEmitterSpeed_Uniform, "uniform", 1, + {{"speed", P3cDataType_Float}, {"", P3cDataType_None}, {"", P3cDataType_None}, {"", P3cDataType_None}}}, @@ -1230,7 +1230,7 @@ UUtError P3rInitialize(void) P3gDebugCollisionEnable = UUcFalse; P3gDebugCollisionPoints = NULL; - + P3gNextTraverseIndex = 0; P3gFirstActiveClass = P3cClass_None; @@ -1265,11 +1265,11 @@ void P3rTerminate(void) // dispose of memory allocated for the definition mem_block = P3gClassTable[itr].memory.block; if (mem_block != NULL) - UUrMemory_Block_Delete(mem_block); + UUrMemory_Block_Delete(mem_block); mem_block = P3gClassTable[itr].originalcopy.block; if (mem_block != NULL) - UUrMemory_Block_Delete(mem_block); + UUrMemory_Block_Delete(mem_block); } P3gNumClasses = 0; @@ -1685,7 +1685,7 @@ P3tParticle *P3rCreateEffect(P3tEffectSpecification *inSpecification, P3tEffectD UUmAssert( &P3gClassTable[particle->header.class_index] == new_class ); if (inData->parent_particle != NULL) { - if (inData->parent_particle->header.flags & P3cParticleFlag_Temporary) { + if (inData->parent_particle->header.flags & P3cParticleFlag_Temporary) { // temporary particles emit temporary particles particle->header.flags |= P3cParticleFlag_Temporary; new_class->non_persistent_flags |= @@ -1696,7 +1696,7 @@ P3tParticle *P3rCreateEffect(P3tEffectSpecification *inSpecification, P3tEffectD // this effect is being generated as a result of a cutscene killing some particles particle->header.flags |= P3cParticleFlag_CutsceneKilled; } - + p_position = P3rGetPositionPtr(new_class, particle, &is_dead); if (is_dead) { return NULL; @@ -1797,7 +1797,7 @@ P3tParticle *P3rCreateEffect(P3tEffectSpecification *inSpecification, P3tEffectD break; } // if we didn't succeed, fall through to the next type (P3cEnumCollisionOrientation_Unchanged) - + case P3cEnumCollisionOrientation_Unchanged: if (inData->parent_orientation != NULL) { // copy the parent's orientation @@ -1941,7 +1941,7 @@ P3tParticle *P3rCreateEffect(P3tEffectSpecification *inSpecification, P3tEffectD // get the decal's texture error = TMrInstance_GetDataPtr(M3cTemplate_TextureMap, new_class->definition->appearance.instance, &texture); - if (error != UUcError_None) + if (error != UUcError_None) { if ((new_class->non_persistent_flags & P3cParticleClass_NonPersistentFlag_WarnedAboutNotFound) == 0) { COrConsole_Printf("DECAL TEXTURE NOT FOUND: decal '%s' texture '%s'", new_class->classname, new_class->definition->appearance.instance); @@ -1994,7 +1994,7 @@ P3tParticle *P3rCreateEffect(P3tEffectSpecification *inSpecification, P3tEffectD // calculate the coordinate system for this decal UUmAssert(MUmVector_IsNormalized(inData->normal)); MUrVector_CrossProduct(&inData->normal, &inData->upvector, &right_dir); - + if (MUrVector_Normalize_ZeroTest(&right_dir)) { // the upvector and the normal are aligned. try an upvector of world Y... // cross product of a vector (vx, vy, vz) with (0, 1, 0) is (-vz, 0, vx) @@ -2134,7 +2134,7 @@ void P3rDisposeParticle(P3tParticleClass *inClass, P3tParticle *inParticle) } } } - + // if the particle is playing a sound, stop it if (inParticle->header.flags & P3cParticleFlag_PlayingAmbientSound) { #if PERFORMANCE_TIMER @@ -2176,7 +2176,7 @@ void P3rDeleteParticle(P3tParticleClass *inClass, P3tParticle *inParticle) } else { inParticle->header.prevptr->header.nextptr = inParticle->header.nextptr; } - + UUmAssert(inClass->num_particles > 0); UUmAssert(P3gTotalParticles > 0); inClass->num_particles--; @@ -2344,12 +2344,12 @@ void P3rListBrokenLinks(BFtFile *inFile) char text[2048]; UUtUns32 itr; P3tParticleClass *classptr; - + // printf a header BFrFile_Printf(inFile, "********** Particle Sound Links **********"UUmNL); BFrFile_Printf(inFile, "Particle Class\tType\tSound Name"UUmNL); BFrFile_Printf(inFile, UUmNL); - + for (itr = 0, classptr = P3gClassTable; itr < P3gNumClasses; itr++, classptr++) { UUtUns16 itr2; P3tActionInstance *action; @@ -2357,7 +2357,7 @@ void P3rListBrokenLinks(BFtFile *inFile) if ((classptr->non_persistent_flags & P3cParticleClass_NonPersistentFlag_HasSoundPointers) == 0) { continue; } - + for (itr2 = 0, action = classptr->definition->action; itr2 < classptr->definition->num_actions; itr2++, action++) { switch (action->action_type) { case P3cActionType_SoundStart: @@ -2400,7 +2400,7 @@ void P3rListCollision(void) UUtBool collide_env, collide_char; P3tParticleClass *classptr; FILE *out_file; - + out_file = fopen("particle_collision.txt", "wt"); if (out_file == NULL) { COrConsole_Printf("### could not open particle_collision.txt"); @@ -2410,7 +2410,7 @@ void P3rListCollision(void) // printf a header fprintf(out_file, "********** Particle Collision Info **********\n"); fprintf(out_file, "\n"); - + for (itr = 0, classptr = P3gClassTable; itr < P3gNumClasses; itr++, classptr++) { collide_env = ((classptr->definition->flags & P3cParticleClassFlag_Physics_CollideEnv) > 0); collide_char = ((classptr->definition->flags & P3cParticleClassFlag_Physics_CollideChar) > 0); @@ -2454,20 +2454,20 @@ void P3rUpdateActionData(P3tParticleClass *inClass, P3tActionInstance *inAction) switch(inAction->action_type) { case P3cActionType_CreateDecal: - if (inAction->action_value[0].type == P3cValueType_String) + if (inAction->action_value[0].type == P3cValueType_String) { UUtError error; M3tTextureMap *texturemap; P3iCalculateValue(NULL, &inAction->action_value[0], (void *) &classname); error = TMrInstance_GetDataPtr(M3cTemplate_TextureMap, classname, &texturemap); - if (error != UUcError_None) + if (error != UUcError_None) { COrConsole_Printf("DECAL TEXTURE NOT FOUND: particle class '%s': Create Decal action texture '%s'", inClass->classname, classname); // default texture if none can be found error = TMrInstance_GetDataPtr(M3cTemplate_TextureMap, "notfoundtex", &texturemap); - if (error != UUcError_None) + if (error != UUcError_None) { texturemap = NULL; } @@ -2489,7 +2489,7 @@ void P3rUpdateActionData(P3tParticleClass *inClass, P3tActionInstance *inAction) } break; - case P3cActionType_SoundStart: + case P3cActionType_SoundStart: if (inAction->action_value[0].type == P3cValueType_String) { // look up the ambient sound with this name inAction->action_data = (UUtUns32) OSrAmbient_GetByName(inAction->action_value[0].u.string_const.val); @@ -2499,7 +2499,7 @@ void P3rUpdateActionData(P3tParticleClass *inClass, P3tActionInstance *inAction) } break; - case P3cActionType_ImpulseSound: + case P3cActionType_ImpulseSound: if (inAction->action_value[0].type == P3cValueType_String) { // look up the impulse sound with this name inAction->action_data = (UUtUns32) OSrImpulse_GetByName(inAction->action_value[0].u.string_const.val); @@ -2666,7 +2666,7 @@ static UUtBool P3iProcessParticleClass(P3tParticleClass *inClass) if (var_info->offset == P3cNoVar) { continue; } - + data_size = P3iGetDataSize(var_info->type); if ((data_size == 0) || (var_info->offset < 0) || (sizeof(P3tParticleHeader) + var_info->offset + data_size > inClass->particle_size)) { // this variable is corrupt, reset it @@ -3123,7 +3123,7 @@ void P3rKillAll(void) // delete all decal data that we missed in the previous pass (shouldn't be any, but be sure) P3rDecalDeleteAllDynamic(); - + // restore the memory manager to an empty state (but don't deallocate its memory) P3gMemory.cur_block = 0; P3gMemory.total_used = 0; @@ -3147,9 +3147,9 @@ static void P3iRemoveDangerousProjectiles(void) P3tParticle *particle, *next_particle; UUtUns16 index; UUtBool kill_particles; - + UUmAssert(P3gRemoveDangerousProjectiles == UUcTrue); - + P3iActiveList_Lock(); // make all particles with the 'dangerous projectile' flag set expire @@ -3282,7 +3282,7 @@ static void P3iActiveList_Unlock(void) P3cParticleClass_NonPersistentFlag_Active) == 0); UUmAssert(P3gClassTable[particle_class->prev_active_class].num_particles > 0); - P3gClassTable[particle_class->prev_active_class].next_active_class = particle_class->next_active_class; + P3gClassTable[particle_class->prev_active_class].next_active_class = particle_class->next_active_class; } else { P3gFirstDeferredActiveClass = particle_class->next_active_class; } @@ -3294,7 +3294,7 @@ static void P3iActiveList_Unlock(void) P3cParticleClass_NonPersistentFlag_Active) == 0); UUmAssert(P3gClassTable[particle_class->next_active_class].num_particles > 0); - P3gClassTable[particle_class->next_active_class].prev_active_class = P3cClass_None; + P3gClassTable[particle_class->next_active_class].prev_active_class = P3cClass_None; } // remove this particle class from the deferred add list @@ -3443,7 +3443,7 @@ static void P3iActiveClass_Remove(P3tParticleClass *inClass) UUmAssert(P3gClassTable[inClass->prev_active_class].non_persistent_flags & P3cParticleClass_NonPersistentFlag_DeferredAddMask); - P3gClassTable[inClass->prev_active_class].next_active_class = inClass->next_active_class; + P3gClassTable[inClass->prev_active_class].next_active_class = inClass->next_active_class; } else { P3gFirstDeferredActiveClass = inClass->next_active_class; } @@ -3458,7 +3458,7 @@ static void P3iActiveClass_Remove(P3tParticleClass *inClass) UUmAssert(P3gClassTable[inClass->next_active_class].non_persistent_flags & P3cParticleClass_NonPersistentFlag_DeferredAddMask); - P3gClassTable[inClass->next_active_class].prev_active_class = inClass->prev_active_class; + P3gClassTable[inClass->next_active_class].prev_active_class = inClass->prev_active_class; } inClass->prev_active_class = P3cClass_None; @@ -3888,7 +3888,7 @@ static UUtError P3iUpdateVersion(const char *inIdentifier, P3tParticleDefinition } if (num_emitters > 0) { - // every emitter expands by several new variables - total of + // every emitter expands by several new variables - total of // 2 * sizeof(P3tEmitterOrientationType) + sizeof(float) new_size = (*ioDefinition)->definition_size + num_emitters * (2 * sizeof(P3tEmitterOrientationType) + sizeof(float)); @@ -3931,7 +3931,7 @@ static UUtError P3iUpdateVersion(const char *inIdentifier, P3tParticleDefinition (2 * sizeof(P3tEmitterOrientationType) + sizeof(float)) - 2 * sizeof(P3tEmitterOrientationType)); copysize = sizeof(P3tEmitterLinkType) + sizeof(P3tEmitterRateType) + - sizeof(P3tEmitterPositionType) + sizeof(P3tEmitterDirectionType) + + sizeof(P3tEmitterPositionType) + sizeof(P3tEmitterDirectionType) + sizeof(P3tEmitterSpeedType); UUrMemory_MoveOverlap(copyfrom, copyto, copysize); @@ -3939,7 +3939,7 @@ static UUtError P3iUpdateVersion(const char *inIdentifier, P3tParticleDefinition // move the data before burst_size copyfrom = (UUtUns8 *) &def_maxcontrail ->emitter[itr]; copyto = (UUtUns8 *) &def_emitterorient->emitter[itr]; - UUmAssert((UUtUns32) (copyto - copyfrom) == itr * + UUmAssert((UUtUns32) (copyto - copyfrom) == itr * (2 * sizeof(P3tEmitterOrientationType) + sizeof(float))); copysize = (P3cParticleClassNameLength + 1) + sizeof(P3tParticleClass *) + @@ -3952,7 +3952,7 @@ static UUtError P3iUpdateVersion(const char *inIdentifier, P3tParticleDefinition if (inSwapBytes) { UUrSwap_2Byte((void *) &def_emitterorient->emitter[itr].emit_chance); } - + // burst size is the floating-point equivalent of what it was before if (inSwapBytes) { UUrSwap_2Byte((void *) &burst_size); @@ -4124,7 +4124,7 @@ static UUtError P3iUpdateVersion(const char *inIdentifier, P3tParticleDefinition def_attractor->attractor.max_distance.u.float_const.val = 150.0f; def_attractor->attractor.max_angle.type = P3cValueType_Float; def_attractor->attractor.max_angle.u.float_const.val = 30.0f; - + if (inSwapBytes) { UUrSwap_4Byte((void *) &def_attractor->attractor.iterator_type); UUrSwap_4Byte((void *) &def_attractor->attractor.selector_type); @@ -4165,7 +4165,7 @@ static UUtError P3iUpdateVersion(const char *inIdentifier, P3tParticleDefinition def_attractorangle->attractor.select_thetamax.u.float_const.val = 20.0f; def_attractorangle->attractor.select_thetaweight.type = P3cValueType_Float; def_attractorangle->attractor.select_thetaweight.u.float_const.val = 3.0f; - + if (inSwapBytes) { P3iSwap_Value((void *) &def_attractorangle->attractor.select_thetamin, UUcTrue); P3iSwap_Value((void *) &def_attractorangle->attractor.select_thetamax, UUcTrue); @@ -4456,7 +4456,7 @@ UUtError P3iSwap_ParticleDefinition(void *ioPtr, UUtBool inCurrentlyUsable) P3iSwap_Value((void *) &definition->lifetime, inCurrentlyUsable); P3iSwap_Value((void *) &definition->collision_radius, inCurrentlyUsable); - + UUrSwap_4Byte((void *) &definition->dodge_radius); UUrSwap_4Byte((void *) &definition->alert_radius); @@ -4527,9 +4527,9 @@ UUtError P3iSwap_Variable(void *ioPtr, UUtBool inCurrentlyUsable) UUtError P3iSwap_VarRef(void *ioPtr, UUtBool inCurrentlyUsable) { P3tVariableReference * varref = (P3tVariableReference *) ioPtr; - + UUrSwap_4Byte((void *) &varref->type); - + return UUcError_None; } @@ -4607,7 +4607,7 @@ UUtError P3iSwap_EffectSpecification(void *ioPtr, UUtBool inCurrentlyUsable) } switch(effect_spec->location_type) { case P3cEffectLocationType_Default: - case P3cEffectLocationType_AttachedToObject: + case P3cEffectLocationType_AttachedToObject: // nothing to swap break; @@ -4620,9 +4620,9 @@ UUtError P3iSwap_EffectSpecification(void *ioPtr, UUtBool inCurrentlyUsable) UUrSwap_4Byte((void *) &effect_spec->location_data.findwall.radius); break; - case P3cEffectLocationType_Decal: // S.S. no clue if this is correct ahem cough cough + case P3cEffectLocationType_Decal: // S.S. no clue if this is correct ahem cough cough break; - + default: UUmError_ReturnOnErrorMsg(UUcError_Generic, "P3iSwap_EffectSpecification: unknown location type"); break; @@ -4703,7 +4703,7 @@ UUtError P3iSwap_Value(void *ioPtr, UUtBool inCurrentlyUsable) case P3cValueType_Enum: UUrSwap_4Byte((void *) &value->u.enum_const.val); break; - + default: UUmError_ReturnOnErrorMsg(UUcError_Generic, "P3iSwap_Value: unknown patricle type"); } @@ -4808,7 +4808,7 @@ M3tPoint3D *P3rGetPositionPtr(P3tParticleClass *inClass, P3tParticle *inParticle if (P3gCurrentCollision.collided) { MUmVector_Copy(inParticle->header.position, P3gCurrentCollision.hit_point); } - + *inDead = P3rSendEvent(cur_class, cur_particle, P3cEvent_BrokenLink, cur_particle->header.current_time); break; } @@ -4836,7 +4836,7 @@ UUtBool P3rGetRealPosition(P3tParticleClass *inClass, P3tParticle *inParticle, M p_position = P3rGetPositionPtr(inClass, inParticle, &is_dead); if (is_dead) return UUcTrue; - + p_offset = P3rGetOffsetPosPtr(inClass, inParticle); p_dynmatrix = P3rGetDynamicMatrixPtr(inClass, inParticle); dynmatrix = (p_dynmatrix == NULL) ? NULL : *p_dynmatrix; @@ -4895,7 +4895,7 @@ M3tVector3D *P3rGetRealVelocityPtr(P3tParticleClass *inClass, P3tParticle *inPar if (cur_class->definition->flags & P3cParticleClassFlag_HasVelocity) { vel_offset = cur_class->optionalvar_offset[P3cParticleOptionalVar_Velocity]; - UUmAssert((vel_offset >= 0) && + UUmAssert((vel_offset >= 0) && (vel_offset < (UUtUns16) (cur_class->particle_size - sizeof(P3tParticleHeader)))); return (M3tVector3D *) &cur_particle->vararray[vel_offset]; @@ -5079,7 +5079,7 @@ UUtBool P3iCalculateValue(P3tParticle *inParticle, P3tValue *inValueDef, case P3cValueType_Enum: *((UUtUns32 *) outStore) = inValueDef->u.enum_const.val; break; - + // floating point value that cycles over gametime case P3cValueType_FloatTimeBased: cycle_val = P3gApproxCurrentTime / inValueDef->u.float_timebased.cycle_length; @@ -5256,7 +5256,7 @@ static void P3iCheckEmitter(P3tParticleClass *inClass, P3tParticle *inParticle, // we are recharging and cannot emit now break; } - + // find attractors nearby, and store them in the global buffer check_ticks = MUrUnsignedSmallFloat_To_Uns_Round(check_attractor_time * UUcFramesPerSecond); P3rIterateAttractors(inClass, inParticle, check_ticks); @@ -5316,7 +5316,7 @@ static void P3iCheckEmitter(P3tParticleClass *inClass, P3tParticle *inParticle, if (P3iCalculateValue(inParticle, &emitter->emitter_value[P3cEmitterValue_RateValOffset + 0], (void *) &threshold) != UUcTrue) break; - + ref = inEmitterData->last_particle; if (ref == P3cParticleReference_Null) { // we have not emitted a particle, emit one now @@ -5328,7 +5328,7 @@ static void P3iCheckEmitter(P3tParticleClass *inClass, P3tParticle *inParticle, if (is_dead) { break; } - + p_offset = P3rGetOffsetPosPtr(inClass, inParticle); if (p_offset != NULL) { MUmVector_Add(calculated_emitter_position, *emitter_position, *p_offset); @@ -5351,7 +5351,7 @@ static void P3iCheckEmitter(P3tParticleClass *inClass, P3tParticle *inParticle, if (is_dead) { break; } - + p_offset = P3rGetOffsetPosPtr(last_class, last_particle); if (p_offset != NULL) { MUmVector_Add(calculated_lastparticle_position, *p_position, *p_offset); @@ -5446,7 +5446,7 @@ static UUtBool P3iEmitParticle(P3tParticleClass *inClass, P3tParticle *inParticl IMtShade * p_tint; emitter_data = ((P3tParticleEmitterData *) inParticle->vararray) + inEmitterIndex; - + if (inEmitter->emittedclass == NULL) return UUcFalse; @@ -5479,7 +5479,7 @@ static UUtBool P3iEmitParticle(P3tParticleClass *inClass, P3tParticle *inParticl num_particles++; } - require_attractor = ((inEmitter->direction_type == P3cEmitterDirection_Attractor) || + require_attractor = ((inEmitter->direction_type == P3cEmitterDirection_Attractor) || (inEmitter->emittedclass->definition->attractor.iterator_type == P3cAttractorIterator_EmittedTowards)); if (require_attractor) { P3rIterateAttractors(inClass, inParticle, 0); @@ -5673,11 +5673,11 @@ static UUtBool P3iEmitParticle(P3tParticleClass *inClass, P3tParticle *inParticl case P3cEmitterDirection_Linear: MUmVector_Set(particle_dir, 0, 1, 0); break; - + case P3cEmitterDirection_Random: P3rGetRandomUnitVector3D(&particle_dir); break; - + case P3cEmitterDirection_Conical: if ((P3iCalculateValue(inParticle, &inEmitter->emitter_value[P3cEmitterValue_DirectionValOffset + 0], (void *) &r_outer) == UUcTrue) && @@ -5762,7 +5762,7 @@ static UUtBool P3iEmitParticle(P3tParticleClass *inClass, P3tParticle *inParticl break; default: - UUmAssert(!"unknown emitter direction type"); + UUmAssert(!"unknown emitter direction type"); } // determine the particle's speed @@ -5771,7 +5771,7 @@ static UUtBool P3iEmitParticle(P3tParticleClass *inClass, P3tParticle *inParticl P3iCalculateValue(inParticle, &inEmitter->emitter_value[P3cEmitterValue_SpeedValOffset + 0], (void *) &particle_speed); break; - + case P3cEmitterSpeed_Stratified: if (P3iCalculateValue(inParticle, &inEmitter->emitter_value[P3cEmitterValue_SpeedValOffset + 0], (void *) &particle_speed) == UUcTrue) { @@ -5787,7 +5787,7 @@ static UUtBool P3iEmitParticle(P3tParticleClass *inClass, P3tParticle *inParticl break; default: - UUmAssert(!"unknown emitter speed type"); + UUmAssert(!"unknown emitter speed type"); } // create a new particle @@ -5810,7 +5810,7 @@ static UUtBool P3iEmitParticle(P3tParticleClass *inClass, P3tParticle *inParticl } } - if (inParticle->header.flags & P3cParticleFlag_Temporary) { + if (inParticle->header.flags & P3cParticleFlag_Temporary) { // temporary particles emit temporary particles new_particle->header.flags |= P3cParticleFlag_Temporary; inEmitter->emittedclass->non_persistent_flags |= @@ -5827,15 +5827,15 @@ static UUtBool P3iEmitParticle(P3tParticleClass *inClass, P3tParticle *inParticl case P3cEmitterLinkType_None: new_particle->header.user_ref = P3cParticleReference_Null; break; - + case P3cEmitterLinkType_Emitter: new_particle->header.user_ref = inParticle->header.self_ref; break; - + case P3cEmitterLinkType_OurLink: new_particle->header.user_ref = inParticle->header.user_ref; break; - + default: other_emitter_index = inEmitter->link_type - P3cEmitterLinkType_LastEmission; if ((other_emitter_index < 0) || (other_emitter_index >= inClass->definition->num_emitters)) { @@ -5860,7 +5860,7 @@ static UUtBool P3iEmitParticle(P3tParticleClass *inClass, P3tParticle *inParticl } } - parent_matrix = P3rGetDynamicMatrixPtr(inClass, inParticle); + parent_matrix = P3rGetDynamicMatrixPtr(inClass, inParticle); p_matrix = P3rGetDynamicMatrixPtr(inEmitter->emittedclass, new_particle); if (override_matrix) { if (p_matrix) { @@ -6608,7 +6608,7 @@ void P3rConstructOrientation(P3tEmitterOrientationType inOrientDir, P3tEmitterOr void P3rDebugCollision(UUtBool inEnable) { P3gDebugCollisionEnable = inEnable; - + if (P3gDebugCollisionEnable) { if (P3gDebugCollisionPoints == NULL) { P3gDebugCollisionPoints = UUrMemory_Block_New(P3cDebugCollisionMaxPoints * sizeof(M3tPoint3D)); @@ -6738,7 +6738,7 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart // track this timestep's collision and store it in the global debugging buffer P3gDebugCollisionPoints[P3gDebugCollision_NextPoint] = *complete_position; MUmVector_Add(P3gDebugCollisionPoints[P3gDebugCollision_NextPoint + 1], *complete_position, P3gCurrentCollision.hit_direction); - + P3gDebugCollision_NextPoint += 2; P3gDebugCollision_UsedPoints = UUmMax(P3gDebugCollision_UsedPoints, P3gDebugCollision_NextPoint); if (P3gDebugCollision_NextPoint >= P3cDebugCollisionMaxPoints) { @@ -6780,7 +6780,7 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart } } else { P3mPerfTrack(inClass, P3cPerfEvent_EnvSphereCol); - AKrCollision_Sphere(environment, &particle_tree.sphere, &P3gCurrentCollision.hit_direction, + AKrCollision_Sphere(environment, &particle_tree.sphere, &P3gCurrentCollision.hit_direction, AKcGQ_Flag_Obj_Col_Skip, 1); } @@ -6838,7 +6838,7 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart if (P3gCurrentCollision.collided) { // we have collided already in this step. set our delta position correctly so that // we don't go past this timepoint when looking for character collisions. - new_delta_t = P3gCurrentCollision.hit_t - inCurrentT; + new_delta_t = P3gCurrentCollision.hit_t - inCurrentT; MUmVector_Scale(P3gCurrentCollision.hit_direction, new_delta_t / delta_t); delta_t = new_delta_t; } else { @@ -6904,7 +6904,7 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart // we already have an earlier collision continue; } - + // use this newly found collision P3gCurrentCollision.hit_t = thiscollision_t; MUmVector_Copy(P3gCurrentCollision.hit_point, thiscollision_point); @@ -6913,7 +6913,7 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart P3gCurrentCollision.hit_normal.z = plane_equ.c; MUmVector_Verify(P3gCurrentCollision.hit_normal); - } else { + } else { if (collide_context->callback->type == PHcCallback_Character) { // perform exact intersection test with character's body parts P3mPerfTrack(inClass, P3cPerfEvent_PhyCharCol); @@ -6948,11 +6948,11 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart // collide with a general physics context P3mPerfTrack(inClass, P3cPerfEvent_PhySphereCol); if (point_intersect) { - hit_context = PHrCollision_Point_SphereTree(complete_position, &P3gCurrentCollision.hit_direction, + hit_context = PHrCollision_Point_SphereTree(complete_position, &P3gCurrentCollision.hit_direction, collide_context->sphereTree, &hit_tree); - + } else { - hit_context = (NULL != PHrCollision_SphereTree_SphereTree(&particle_tree, &P3gCurrentCollision.hit_direction, + hit_context = (NULL != PHrCollision_SphereTree_SphereTree(&particle_tree, &P3gCurrentCollision.hit_direction, collide_context->sphereTree, &hit_tree)); } @@ -6961,17 +6961,17 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart continue; } - // construct the hit point from the sphere that we hit + // construct the hit point from the sphere that we hit UUmAssert(hit_tree != NULL); - + // CB: none of this should be necessary, but the spheretree code is set up to only do // bounding tests and not actual intersection tests. agh! - + // how far from the hit sphere is the particle center? MUmVector_Subtract(vector_from_sphere, *complete_position, hit_tree->sphere.center); d_from_sphere_sq = MUmVector_GetLengthSquared(vector_from_sphere); d_from_sphere = MUrSqrt(d_from_sphere_sq); - + if (point_intersect) { if (d_from_sphere < hit_tree->sphere.radius) { // particle is inside the bounding sphere to start with @@ -6980,7 +6980,7 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart // we already have an earlier collision continue; } - + // use this newly found collision P3gCurrentCollision.hit_t = thiscollision_t; MUmVector_Copy(P3gCurrentCollision.hit_point, *complete_position); @@ -6994,17 +6994,17 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart equ_a = MUrVector_DotProduct(&P3gCurrentCollision.hit_direction, &P3gCurrentCollision.hit_direction); equ_b = 2 * MUrVector_DotProduct(&P3gCurrentCollision.hit_direction, &vector_from_sphere); equ_c = d_from_sphere_sq - UUmSQR(hit_tree->sphere.radius); - + // if particle is heading away from sphere, no intersection if (equ_b > 0) continue; - + disc = UUmSQR(equ_b) - 4 * equ_a * equ_c; if (disc < 0) continue; // this should never happen... - + temp_t = (- equ_b - MUrSqrt(disc)) / (2 * equ_a); - + // build the actual time of collision thiscollision_t = temp_t; thiscollision_t = inCurrentT + thiscollision_t * delta_t; @@ -7013,17 +7013,17 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart // we already have an earlier collision continue; } - + // use this newly found collision P3gCurrentCollision.hit_t = thiscollision_t; // build the hit point MUmVector_ScaleCopy(P3gCurrentCollision.hit_point, temp_t, P3gCurrentCollision.hit_direction); - MUmVector_Add(P3gCurrentCollision.hit_point, P3gCurrentCollision.hit_point, *complete_position); + MUmVector_Add(P3gCurrentCollision.hit_point, P3gCurrentCollision.hit_point, *complete_position); MUmVector_Copy(P3gCurrentCollision.hit_normal, vector_from_sphere); MUmVector_Verify(P3gCurrentCollision.hit_normal); } - + } else { // calculate the time of collision if (stationary) { @@ -7031,7 +7031,7 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart } else { d_from_sphere -= particle_tree.sphere.radius + hit_tree->sphere.radius; thiscollision_t = d_from_sphere / MUmVector_GetLength(P3gCurrentCollision.hit_direction); - + thiscollision_t = inCurrentT + thiscollision_t * delta_t; thiscollision_t = UUmPin(thiscollision_t, inCurrentT, *inEndT); } @@ -7039,24 +7039,24 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart // we already have an earlier collision continue; } - + // use this newly found collision P3gCurrentCollision.hit_t = thiscollision_t; // an exact computation of the spheres' contact points is possible, but for now just take a // point along the line that joins them. this point is defined at the ratio where they would be // touching if the distance was right. - + totalrad = hit_tree->sphere.radius + particle_tree.sphere.radius; - + MUmVector_ScaleCopy(P3gCurrentCollision.hit_point, hit_tree->sphere.radius / totalrad, *complete_position); MUmVector_ScaleIncrement(P3gCurrentCollision.hit_point, particle_tree.sphere.radius / totalrad, hit_tree->sphere.center); - + MUmVector_Copy(P3gCurrentCollision.hit_normal, vector_from_sphere); MUmVector_Verify(P3gCurrentCollision.hit_normal); - } + } } } @@ -7082,7 +7082,7 @@ static UUtBool P3iCheckCollisions(P3tParticleClass *inClass, P3tParticle *inPart delta_t = 0.0f; break; } - + MUmVector_Scale(P3gCurrentCollision.hit_direction, new_delta_t / delta_t); delta_t = new_delta_t; @@ -7229,7 +7229,7 @@ static void P3iUpdateParticleClass(P3tParticleClass *inClass, UUtUns32 inNewTime last_t = 0.0f; last_emit_num = UUcMaxUns16; - + while ((current_t < final_t - 0.001f) && (!is_dead)) { UUmAssert((particle->header.flags & P3cParticleFlag_Deleted) == 0); @@ -7248,7 +7248,7 @@ static void P3iUpdateParticleClass(P3tParticleClass *inClass, UUtUns32 inNewTime /* * determine how long we should run the timestep for */ - + // if this particle has emitters, call them to determine whether they will emit during this // time period; if so, we need to only update until this time if (check_emit) { @@ -7257,7 +7257,7 @@ static void P3iUpdateParticleClass(P3tParticleClass *inClass, UUtUns32 inNewTime itr < inClass->definition->num_emitters; itr++, emitter_data++) { if (emitter_data->num_emitted == P3cEmitterDisabled) continue; - + // check to see if we will emit before this time - sets do_emit, emit_num // and changes run_t if yes P3iCheckEmitter(inClass, particle, itr, emitter_data, current_t, &do_emit, &emit_num, &run_t); @@ -7297,20 +7297,20 @@ static void P3iUpdateParticleClass(P3tParticleClass *inClass, UUtUns32 inNewTime // run the particle up to this point delta_t = run_t - current_t; - is_dead = P3iPerformActionList(inClass, particle, P3cEvent_Update, actionlist + P3cEvent_Update, current_t, delta_t, do_collide); + is_dead = P3iPerformActionList(inClass, particle, P3cEvent_Update, actionlist + P3cEvent_Update, current_t, delta_t, do_collide); if (is_dead) { break; } // the particle has moved, the endpoint is no longer valid P3gCurrentStep_EndPointValid = UUcFalse; - + // check to see if the particle's lifetime has expired if (particle->header.lifetime != 0) { particle->header.lifetime -= delta_t; if (particle->header.lifetime < (1.0f / UUcFramesPerSecond)) { particle->header.lifetime = 0; - + // if there is a 'lifetime' action list, run that. otherwise die. // don't run the action list if we are already fading out or being chopped. if (((particle->header.flags & (P3cParticleFlag_FadeOut | P3cParticleFlag_Chop)) == 0) && @@ -7327,7 +7327,7 @@ static void P3iUpdateParticleClass(P3tParticleClass *inClass, UUtUns32 inNewTime if (is_dead) { break; } - + /* * perform post-update computation */ @@ -7339,7 +7339,7 @@ static void P3iUpdateParticleClass(P3tParticleClass *inClass, UUtUns32 inNewTime p_velocity = (M3tVector3D *) &particle->vararray[vel_offset]; p_orientation = (M3tMatrix3x3 *) &particle->vararray[orient_offset]; - P3rConstructOrientation(P3cEmitterOrientation_Velocity, P3cEmitterOrientation_ParentPosZ, + P3rConstructOrientation(P3cEmitterOrientation_Velocity, P3cEmitterOrientation_ParentPosZ, p_orientation, NULL, p_velocity, p_orientation); } @@ -7347,17 +7347,17 @@ static void P3iUpdateParticleClass(P3tParticleClass *inClass, UUtUns32 inNewTime if (do_emit) { UUmAssert((emit_num >= 0) && (emit_num < inClass->definition->num_emitters)); emitter = &inClass->definition->emitter[emit_num]; - + is_dead = P3iEmitParticle(inClass, particle, emitter, emit_num, run_t); if (is_dead) { break; } - + // track the number of particles that have been emitted emitter_data = ((P3tParticleEmitterData *) particle->vararray) + emit_num; if (emitter->flags & P3cEmitterFlag_IncreaseEmitCount) { emitter_data->num_emitted++; - + if (emitter->flags & P3cEmitterFlag_DeactivateWhenEmitCountThreshold) { if (emitter_data->num_emitted >= emitter->particle_limit) { emitter_data->num_emitted = P3cEmitterDisabled; @@ -7373,7 +7373,7 @@ static void P3iUpdateParticleClass(P3tParticleClass *inClass, UUtUns32 inNewTime emitter_data->time_last_emission = run_t; last_emit_num = emit_num; } - + // run our deferred collision if (do_collide) { is_dead = P3iDoCollision(inClass, particle, run_t); @@ -7391,7 +7391,7 @@ static void P3iUpdateParticleClass(P3tParticleClass *inClass, UUtUns32 inNewTime if (((current_t - last_t) < 0.0001f) && (emit_num == last_emit_num)) { current_t += 1.0f / UUcFramesPerSecond; } - + last_t = current_t; UUmAssert((particle->header.flags & P3cParticleFlag_Deleted) == 0); @@ -7442,7 +7442,7 @@ static UUtBool P3iDecalFade(P3tParticleClass *inClass, P3tParticle *inParticle) UUtBool returnval; float current_alpha; - if ((inParticle->header.flags & P3cParticleFlag_FadeOut) || + if ((inParticle->header.flags & P3cParticleFlag_FadeOut) || (inClass->definition->appearance.decal_fadeframes == 0)) { // kill the decal P3rKillParticle(inClass, inParticle); @@ -7542,26 +7542,26 @@ static void P3iUpdateDecalClass(P3tParticleClass *inClass, UUtUns32 inNewTime) particle->header.lifetime -= delta_t; if (particle->header.lifetime < (1.0f / UUcFramesPerSecond)) { particle->header.lifetime = 0; - + is_dead = P3iDecalFade(inClass, particle); } } - + if (!is_dead && ((particle->header.flags & P3cParticleFlag_FadeOut) == 0) && (itr < overflow_particles)) { // fade out any non-faded particles that are over the limit, starting from the head UUmAssertReadPtr(decal_data->decal_header, sizeof(M3tDecalHeader)); is_dead = P3iDecalFade(inClass, particle); } - + if (!is_dead) { UUmAssertReadPtr(decal_data->decal_header, sizeof(M3tDecalHeader)); - if (particle->header.flags & P3cParticleFlag_FadeOut) + if (particle->header.flags & P3cParticleFlag_FadeOut) { if ((decal_data != NULL) && (decal_data->decal_header != NULL)) { decal_data->decal_header->alpha = (UUtUns16) MUrUnsignedSmallFloat_To_Uns_Round(M3cMaxAlpha * particle->header.lifetime / particle->header.fadeout_time); } - } + } particle->header.current_tick = inNewTime; particle->header.current_time = final_t; @@ -7715,7 +7715,7 @@ void P3rPerformanceEnd(void) } } } - + for (itr = 0; itr < P3gPerfDisplayNumClasses; itr++) { particle_class = P3gPerfDisplayClasses[itr]; @@ -7989,7 +7989,7 @@ UUtBool P3rRevert(P3tParticleClass *ioClass) UUrMemory_Block_Delete(mem_block); // the main particle class is now the copy that we made earlier. - // we no longer have a second copy + // we no longer have a second copy ioClass->memory = ioClass->originalcopy; ioClass->originalcopy.size = 0; ioClass->originalcopy.block = NULL; @@ -8172,7 +8172,7 @@ UUtBool P3rDescribeEmitterLinkType(P3tParticleClass *inClass, P3tEmitter *inEmit case P3cEmitterLinkType_None: strcpy(outString, "none"); return UUcTrue; - + case P3cEmitterLinkType_Emitter: strcpy(outString, "back to emitter"); return UUcTrue; @@ -8180,7 +8180,7 @@ UUtBool P3rDescribeEmitterLinkType(P3tParticleClass *inClass, P3tEmitter *inEmit case P3cEmitterLinkType_OurLink: strcpy(outString, "same as us"); return UUcTrue; - + default: emitter_index = inLinkType - P3cEmitterLinkType_LastEmission; if ((emitter_index < 0) || (emitter_index >= inClass->definition->num_emitters)) { @@ -8191,7 +8191,7 @@ UUtBool P3rDescribeEmitterLinkType(P3tParticleClass *inClass, P3tEmitter *inEmit } return UUcFalse; } else { - sprintf(outString, "last particle emitted from %d: %s", + sprintf(outString, "last particle emitted from %d: %s", emitter_index, inClass->definition->emitter[emitter_index].classname); return UUcTrue; } @@ -8285,7 +8285,7 @@ void P3rSetDefaultInitialiser(P3tDataType inVarType, P3tValue *outValue) // recurse over all action lists in the particle definition, and update their indices // so that they are still correct after a grow or shrink operation. -static void P3iUpdateActionLists(P3tParticleDefinition *inDefinition, UUtUns16 inListIndex, +static void P3iUpdateActionLists(P3tParticleDefinition *inDefinition, UUtUns16 inListIndex, UUtUns16 inLocationIndex, UUtInt32 inOffsetIndex) { UUtUns16 itr; @@ -8323,7 +8323,7 @@ UUtError P3rClass_NewAction(P3tParticleClass *ioClass, UUtUns16 inListIndex, UUt UUmAssert(P3mVerifyDefinitionSize(ioClass->definition)); UUmAssert((inActionIndex >= 0) && (inActionIndex <= ioClass->definition->num_actions)); - UUmAssert((inActionIndex >= ioClass->definition->eventlist[inListIndex].start_index) && + UUmAssert((inActionIndex >= ioClass->definition->eventlist[inListIndex].start_index) && (inActionIndex <= ioClass->definition->eventlist[inListIndex].end_index)); // resize the particle class to accomodate the new action @@ -8498,7 +8498,7 @@ UUtError P3rClass_DeleteAction(P3tParticleClass *ioClass, UUtUns16 inListIndex, UUmAssert((inActionIndex >= 0) && (inActionIndex < def->num_actions)); UUmAssert((inListIndex >= 0) && (inListIndex < P3cMaxNumEvents)); - UUmAssert((inActionIndex >= ioClass->definition->eventlist[inListIndex].start_index) && + UUmAssert((inActionIndex >= ioClass->definition->eventlist[inListIndex].start_index) && (inActionIndex < ioClass->definition->eventlist[inListIndex].end_index)); UUmAssert(P3mVerifyDefinitionSize(def)); @@ -8620,7 +8620,7 @@ static void P3iReallocateParticles(P3tParticleClass *ioClass, UUtUns16 new_size_ new_particle = P3rNewParticle(ioClass); new_particle->header = particle->header; - + // map the new particle's variables to the old values for (itr = 0; itr < new_vararray_size; itr++) { from_index = remap_table[itr]; @@ -8657,7 +8657,7 @@ static void P3iReallocateParticles(P3tParticleClass *ioClass, UUtUns16 new_size_ new_particle->header.next_decorative->header.prev_decorative = new_particle->header.prev_decorative; } - + // add the new particle to the tail of the new decorative-particle list new_particle->header.prev_decorative = new_sci->decorative_tail; if (new_particle->header.prev_decorative == NULL) { @@ -8775,7 +8775,7 @@ void P3rPackVariables(P3tParticleClass *ioClass, UUtBool inChangedVars) // perform sanity checks on remap table for (itr = 0; itr < new_particle_size - sizeof(P3tParticleHeader); itr++) { UUmAssert((remap_table[itr] == P3cNoVar) || - ((remap_table[itr] >= 0) && + ((remap_table[itr] >= 0) && (remap_table[itr] < ioClass->particle_size - sizeof(P3tParticleHeader)))); } #endif @@ -8821,7 +8821,7 @@ void P3rTraverseVarRef(P3tParticleDefinition *inDefinition, // traverse over all actions for (itr = 0, action = inDefinition->action; itr < inDefinition->num_actions; itr++, action++) { - + // traverse over all variables for each action num_vars = P3gActionInfo[action->action_type].num_variables; for (itr2 = 0; itr2 < num_vars; itr2++) { @@ -8832,7 +8832,7 @@ void P3rTraverseVarRef(P3tParticleDefinition *inDefinition, } inProc(&action->action_var[itr2], location); } - + // traverse over all parameters for each action - look for parameters that are a variable num_params = P3gActionInfo[action->action_type].num_parameters; for (itr2 = 0, val = action->action_value; itr2 < num_params; itr2++, val++) { @@ -9091,7 +9091,7 @@ UUtBool P3rDescribeEnum(P3tParticleClass *inClass, P3tEnumType inType, UUtUns32 } sprintf(outDescription, "%d: %s", inVal, P3gActionInfo[action->action_type].name); - return UUcTrue; + return UUcTrue; case P3cEnumType_Emitter: UUmAssert(inClass != NULL); @@ -9103,7 +9103,7 @@ UUtBool P3rDescribeEnum(P3tParticleClass *inClass, P3tEnumType inType, UUtUns32 } else { sprintf(outDescription, "emitter %d (%s)", inVal, inClass->definition->emitter[inVal].classname); } - return UUcTrue; + return UUcTrue; case P3cEnumType_Falloff: switch(inVal) { @@ -9229,7 +9229,7 @@ UUtBool P3rDescribeEnum(P3tParticleClass *inClass, P3tEnumType inType, UUtUns32 } default: - return UUcFalse; + return UUcFalse; } } @@ -9265,7 +9265,7 @@ void P3iDisplayParticleClass(P3tParticleClass *inClass, UUtUns32 inCurrentTick, return; } } - + if (!inLensFlares && (inClass->definition->flags2 & P3cParticleClassFlag2_Appearance_LensFlare)) { // this is a lens-flare class and must be drawn in a separate pass if (P3gNumLensFlares >= P3cMaxLensFlares) { @@ -9294,7 +9294,7 @@ void P3iDisplayParticleClass(P3tParticleClass *inClass, UUtUns32 inCurrentTick, sprite_mode = (M3tGeomState_SpriteMode) ((inClass->definition->flags & P3cParticleClassFlag_Appearance_SpriteTypeMask) >> P3cParticleClassFlags_SpriteTypeShift); - + if ((sprite_mode == M3cGeomState_SpriteMode_Contrail) || (sprite_mode == M3cGeomState_SpriteMode_ContrailRotated)) { if (inClass->definition->flags2 & P3cParticleClassFlag2_ContrailEmitter) { @@ -9310,7 +9310,7 @@ void P3iDisplayParticleClass(P3tParticleClass *inClass, UUtUns32 inCurrentTick, } else { P3rDisplayClass_Contrail(inClass, inCurrentTick, inDrawTicks, sprite_mode, UUcFalse); } - + } else { P3rDisplayClass_Sprite(inClass, inCurrentTick, inDrawTicks, sprite_mode); } @@ -9329,7 +9329,7 @@ void P3rDisplay( UUtBool inLensFlares ) UUtUns32 itr, draw_ticks, current_tick, num_contrailemitters; P3tParticleClass * current_class; M3tGeomState_SpriteMode sprite_mode; - + #if PARTICLE_PROFILE_DISPLAY UUrProfile_State_Set(UUcProfile_State_On); #endif @@ -9347,14 +9347,14 @@ void P3rDisplay( UUtBool inLensFlares ) M3rGeom_State_Set(M3cGeomStateIntType_SubmitMode, M3cGeomState_SubmitMode_SortAlphaTris); M3rDraw_State_SetInt(M3cDrawStateIntType_ZWrite, M3cDrawState_ZWrite_Off); if (inLensFlares) { - M3rDraw_State_SetInt(M3cDrawStateIntType_ZCompare, M3cDrawState_ZCompare_Off); + M3rDraw_State_SetInt(M3cDrawStateIntType_ZCompare, M3cDrawState_ZCompare_Off); } M3rGeom_State_Commit(); num_contrailemitters = 0; if (inLensFlares) { // draw the separate lensflare pass, which comes at the end of most other game display. - // the lensflares particle classes found here + // the lensflares particle classes found here for (itr = 0; itr < P3gNumLensFlares; itr++) { P3iDisplayParticleClass(P3gLensFlares[itr], current_tick, draw_ticks, UUcTrue, &num_contrailemitters); } @@ -9393,7 +9393,7 @@ void P3rDisplay( UUtBool inLensFlares ) sprite_mode = (M3tGeomState_SpriteMode) ((current_class->definition->flags & P3cParticleClassFlag_Appearance_SpriteTypeMask) >> P3cParticleClassFlags_SpriteTypeShift); - + P3rDisplayClass_Contrail(current_class, current_tick, draw_ticks, sprite_mode, UUcTrue); } @@ -9426,7 +9426,7 @@ static UUtUns16 P3rModifyAlphaByFogFromDepth( alpha= (UUtUns16)((float)alpha * fog_factor); alpha= UUmMin(alpha, 0xFF); } - + return alpha; } @@ -9455,7 +9455,7 @@ void P3rDisplayClass_Geometry(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns if (inClass->definition->flags & P3cParticleClassFlag_HasLensFrames) { lensframes_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_LensFrames]; - UUmAssert((lensframes_offset >= 0) && + UUmAssert((lensframes_offset >= 0) && (lensframes_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { lensframes_offset = P3cNoVar; @@ -9468,7 +9468,7 @@ void P3rDisplayClass_Geometry(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns matrixtype = P3cMatrix_Orientation; orient_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_Orientation]; - UUmAssert((orient_offset >= 0) && + UUmAssert((orient_offset >= 0) && (orient_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else if (inClass->definition->flags & P3cParticleClassFlag_HasVelocity) { @@ -9476,34 +9476,34 @@ void P3rDisplayClass_Geometry(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns matrixtype = P3cMatrix_Velocity; vel_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_Velocity]; - UUmAssert((vel_offset >= 0) && + UUmAssert((vel_offset >= 0) && (vel_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { // no orientation; use identity matrixtype = P3cMatrix_Identity; - + } // is there an offset position? if (inClass->definition->flags & P3cParticleClassFlag_HasOffsetPos) { offsetpos_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_OffsetPos]; - UUmAssert((offsetpos_offset >= 0) && + UUmAssert((offsetpos_offset >= 0) && (offsetpos_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { offsetpos_offset = P3cNoVar; } - + // is there a dynamic matrix? if (inClass->definition->flags & P3cParticleClassFlag_HasDynamicMatrix) { dynmatrix_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_DynamicMatrix]; - UUmAssert((dynmatrix_offset >= 0) && + UUmAssert((dynmatrix_offset >= 0) && (dynmatrix_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { dynmatrix_offset = P3cNoVar; } - + appearance_params = (P3tAppearance *) &inClass->definition->appearance; - + dynamic_scale = P3iValueIsDynamic(&appearance_params->scale); if (dynamic_scale) { do_scale = UUcTrue; @@ -9515,7 +9515,7 @@ void P3rDisplayClass_Geometry(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns do_scale = UUcTrue; } } - + dynamic_alpha = P3iValueIsDynamic(&appearance_params->alpha); if (!dynamic_alpha) { P3iCalculateValue(NULL, &appearance_params->alpha, (void *) &floatalpha); @@ -9525,7 +9525,7 @@ void P3rDisplayClass_Geometry(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns currentalpha = constalpha; } - + error = TMrInstance_GetDataPtr(M3cTemplate_Geometry, appearance_params->instance, &geometry); if (error != UUcError_None) { if ((inClass->non_persistent_flags & P3cParticleClass_NonPersistentFlag_WarnedAboutNotFound) == 0) { @@ -9540,21 +9540,21 @@ void P3rDisplayClass_Geometry(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns return; } } - - + + for (particle = inClass->headptr; particle != NULL; particle = next_particle) { next_particle = particle->header.nextptr; - + if (particle->header.flags & P3cParticleFlag_Hidden) continue; - + // calculate the translational component of the position matrix // (offset position is taken care of below, when the matrix is actually computed) positionptr = P3rGetPositionPtr(inClass, particle, &is_dead); if (is_dead) { continue; } - + // if we are fading out then use the current lifetime and fade time to calculate alpha if (particle->header.flags & P3cParticleFlag_FadeOut) { realalpha = (UUtUns16) (M3cMaxAlpha * particle->header.lifetime / particle->header.fadeout_time); @@ -9562,7 +9562,7 @@ void P3rDisplayClass_Geometry(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns M3rGeom_State_Commit(); currentalpha = realalpha; - + } else { if (dynamic_alpha) { P3iCalculateValue(particle, &appearance_params->alpha, (void *) &floatalpha); @@ -9611,38 +9611,38 @@ void P3rDisplayClass_Geometry(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns // evaluate any dynamic appearance parameters for this particle if (dynamic_scale) P3iCalculateValue(particle, &appearance_params->scale, (void *) &scale); - + switch(matrixtype) { case P3cMatrix_Orientation: UUrMemory_MoveFast(&particle->vararray[orient_offset], (M3tMatrix3x3 *) &geom_matrix, sizeof(M3tMatrix3x3)); break; - + case P3cMatrix_Velocity: // build an orientation matrix along velocity and upvector -> world Y P3rConstructOrientation(P3cEmitterOrientation_Velocity, P3cEmitterOrientation_WorldPosY, NULL, NULL, (M3tVector3D *) &particle->vararray[vel_offset], (M3tMatrix3x3 *) &geom_matrix); break; - + case P3cMatrix_Identity: MUrMatrix3x3_Identity((M3tMatrix3x3 *) &geom_matrix); break; } - + geom_matrix.m[3][0] = positionptr->x; geom_matrix.m[3][1] = positionptr->y; geom_matrix.m[3][2] = positionptr->z; - if (offsetpos_offset != P3cNoVar) + if (offsetpos_offset != P3cNoVar) { positionptr = (M3tVector3D *) &particle->vararray[offsetpos_offset]; geom_matrix.m[3][0] += positionptr->x; geom_matrix.m[3][1] += positionptr->y; geom_matrix.m[3][2] += positionptr->z; } - + M3rMatrixStack_Push(); - + // apply the dynamic matrix if there is one if (dynmatrix_offset != P3cNoVar) { matrixptr = *((M3tMatrix4x3 **) &particle->vararray[dynmatrix_offset]); @@ -9650,13 +9650,13 @@ void P3rDisplayClass_Geometry(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns M3rMatrixStack_Multiply(matrixptr); } } - + M3rMatrixStack_Multiply(&geom_matrix); - + if (do_scale) { M3rMatrixStack_UniformScale(scale); } - + M3rGeometry_Draw(geometry); M3rMatrixStack_Pop(); } @@ -9685,7 +9685,7 @@ void P3rDisplayClass_Vector(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 if (inClass->definition->flags & P3cParticleClassFlag_HasLensFrames) { lensframes_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_LensFrames]; - UUmAssert((lensframes_offset >= 0) && + UUmAssert((lensframes_offset >= 0) && (lensframes_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { lensframes_offset = P3cNoVar; @@ -9695,7 +9695,7 @@ void P3rDisplayClass_Vector(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 // get the velocity if (inClass->definition->flags & P3cParticleClassFlag_HasVelocity) { vel_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_Velocity]; - UUmAssert((vel_offset >= 0) && + UUmAssert((vel_offset >= 0) && (vel_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { // vector particles cannot be drawn without a velocity! @@ -9703,41 +9703,41 @@ void P3rDisplayClass_Vector(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 inClass->classname); return; } - + // is there an offset position? if (inClass->definition->flags & P3cParticleClassFlag_HasOffsetPos) { offsetpos_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_OffsetPos]; - UUmAssert((offsetpos_offset >= 0) && + UUmAssert((offsetpos_offset >= 0) && (offsetpos_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); - + // set up for inside loop positionptr = &calculatedposition; } else { offsetpos_offset = P3cNoVar; } - + // is there a dynamic matrix? if (inClass->definition->flags & P3cParticleClassFlag_HasDynamicMatrix) { dynmatrix_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_DynamicMatrix]; - UUmAssert((dynmatrix_offset >= 0) && + UUmAssert((dynmatrix_offset >= 0) && (dynmatrix_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { dynmatrix_offset = P3cNoVar; } - + appearance_params = (P3tAppearance *) &inClass->definition->appearance; - + dynamic_scale = P3iValueIsDynamic(&appearance_params->scale); if (dynamic_scale) { do_scale = UUcTrue; } else { P3iCalculateValue(NULL, &appearance_params->scale, (void *) &scale); } - + dynamic_tint = P3iValueIsDynamic(&appearance_params->tint); if (!dynamic_tint) P3iCalculateValue(NULL, &appearance_params->tint, (void *) &tint); - + dynamic_alpha = P3iValueIsDynamic(&appearance_params->alpha); if (!dynamic_alpha) { P3iCalculateValue(NULL, &appearance_params->alpha, (void *) &floatalpha); @@ -9747,37 +9747,37 @@ void P3rDisplayClass_Vector(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 currentalpha = constalpha; } - + for (particle = inClass->headptr; particle != NULL; particle = next_particle) { next_particle = particle->header.nextptr; - + if (particle->header.flags & P3cParticleFlag_Hidden) continue; - + positionptr = P3rGetPositionPtr(inClass, particle, &is_dead); if (is_dead) { continue; } - + if (offsetpos_offset != P3cNoVar) { MUmVector_Add(calculatedposition, *positionptr, *((M3tVector3D *) &particle->vararray[offsetpos_offset])); positionptr = &calculatedposition; } - + if (dynamic_scale) P3iCalculateValue(particle, &appearance_params->scale, (void *) &scale); - + MUmVector_Copy(endpoint, *positionptr); MUmVector_ScaleIncrement(endpoint, scale, *((M3tVector3D *) &particle->vararray[vel_offset])); - + if (dynmatrix_offset != P3cNoVar) { matrixptr = (M3tMatrix4x3 *) &particle->vararray[dynmatrix_offset]; MUrMatrix_MultiplyPoint(positionptr, matrixptr, &calculatedposition); positionptr = &calculatedposition; MUrMatrix_MultiplyPoint(&endpoint, matrixptr, &endpoint); } - + // if we are fading out then use the current lifetime and fade time to calculate alpha if (particle->header.flags & P3cParticleFlag_FadeOut) { realalpha = (UUtUns16) (M3cMaxAlpha * particle->header.lifetime / particle->header.fadeout_time); @@ -9785,7 +9785,7 @@ void P3rDisplayClass_Vector(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 M3rGeom_State_Commit(); currentalpha = realalpha; - + } else { if (dynamic_alpha) { P3iCalculateValue(particle, &appearance_params->alpha, (void *) &floatalpha); @@ -9825,7 +9825,7 @@ void P3rDisplayClass_Vector(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 // evaluate any dynamic appearance parameters for this particle if (dynamic_tint) P3iCalculateValue(particle, &appearance_params->tint, (void *) &tint); - + M3rGeom_Line_Light(positionptr, &endpoint, tint); } } @@ -9861,7 +9861,7 @@ void P3rDisplayClass_Sprite(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 if (inClass->definition->flags & P3cParticleClassFlag_HasLensFrames) { lensframes_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_LensFrames]; - UUmAssert((lensframes_offset >= 0) && + UUmAssert((lensframes_offset >= 0) && (lensframes_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { lensframes_offset = P3cNoVar; @@ -9869,7 +9869,7 @@ void P3rDisplayClass_Sprite(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 } appearance_params = (P3tAppearance *) &inClass->definition->appearance; - + do_edgefade = ((inClass->definition->flags2 & P3cParticleClassFlag2_Appearance_EdgeFade) != 0); twosided_edgefade = ((inClass->definition->flags2 & P3cParticleClassFlag2_Appearance_EdgeFade_OneSided) == 0); if (do_edgefade) { @@ -9895,7 +9895,7 @@ void P3rDisplayClass_Sprite(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 } else { // fall through to next case - which determines orientation } - + case M3cGeomState_SpriteMode_Rotated: case M3cGeomState_SpriteMode_Billboard : // this sprite drawing mode requires an orientation, either from a 3x3 matrix or @@ -9903,31 +9903,31 @@ void P3rDisplayClass_Sprite(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 if (inClass->definition->flags & P3cParticleClassFlag_HasOrientation) { // use matrix by preference, because it's already normalised orient_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_Orientation]; - UUmAssert((orient_offset >= 0) && + UUmAssert((orient_offset >= 0) && (orient_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); vel_offset = P3cNoVar; - + } else if (inClass->definition->flags & P3cParticleClassFlag_HasVelocity) { // use velocity vector otherwise vel_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_Velocity]; - UUmAssert((vel_offset >= 0) && + UUmAssert((vel_offset >= 0) && (vel_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); orient_offset = P3cNoVar; - + } else { COrConsole_Printf("### '%s' requires velocity or orientation to use this sprite mode!", inClass->classname); return; } break; - + case M3cGeomState_SpriteMode_Arrow: case M3cGeomState_SpriteMode_Discus: case M3cGeomState_SpriteMode_Flat: // this sprite drawing mode requires an orientation matrix. if (inClass->definition->flags & P3cParticleClassFlag_HasOrientation) { orient_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_Orientation]; - UUmAssert((orient_offset >= 0) && + UUmAssert((orient_offset >= 0) && (orient_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); vel_offset = P3cNoVar; } else { @@ -9936,94 +9936,94 @@ void P3rDisplayClass_Sprite(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 return; } break; - + default: COrConsole_Printf("### '%s' unknown sprite mode!", inClass->classname); break; } - + // is there an offset position? if (inClass->definition->flags & P3cParticleClassFlag_HasOffsetPos) { offsetpos_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_OffsetPos]; - UUmAssert((offsetpos_offset >= 0) && + UUmAssert((offsetpos_offset >= 0) && (offsetpos_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { offsetpos_offset = P3cNoVar; } - + // is there a dynamic matrix? if (inClass->definition->flags & P3cParticleClassFlag_HasDynamicMatrix) { dynmatrix_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_DynamicMatrix]; - UUmAssert((dynmatrix_offset >= 0) && + UUmAssert((dynmatrix_offset >= 0) && (dynmatrix_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { dynmatrix_offset = P3cNoVar; } - + // is there a texture index? if (inClass->definition->flags & P3cParticleClassFlag_HasTextureIndex) { texindex_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_TextureIndex]; - UUmAssert((texindex_offset >= 0) && + UUmAssert((texindex_offset >= 0) && (texindex_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { texindex_offset = P3cNoVar; - } - + } + // is there a texture time? if (inClass->definition->flags & P3cParticleClassFlag_HasTextureTime) { textime_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_TextureTime]; - UUmAssert((textime_offset >= 0) && + UUmAssert((textime_offset >= 0) && (textime_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { textime_offset = P3cNoVar; - } - + } + // set up drawing parameters for this class M3rGeom_State_Set(M3cGeomStateIntType_SpriteMode, inMode); M3rGeom_State_Commit(); - + dynamic_scale = P3iValueIsDynamic(&appearance_params->scale); if (!dynamic_scale) P3iCalculateValue(NULL, &appearance_params->scale, (void *) &scale); - + dynamic_xoffset = P3iValueIsDynamic(&appearance_params->x_offset); if (!dynamic_xoffset) P3iCalculateValue(NULL, &appearance_params->x_offset, (void *) &x_offset); - + dynamic_xshorten = P3iValueIsDynamic(&appearance_params->x_shorten); if (!dynamic_xshorten) P3iCalculateValue(NULL, &appearance_params->x_shorten, (void *) &x_shorten); - + if (inClass->definition->flags & P3cParticleClassFlag_Appearance_UseSeparateYScale) { use_yscale = UUcTrue; - + dynamic_yscale = P3iValueIsDynamic(&appearance_params->y_scale); if (!dynamic_yscale) P3iCalculateValue(NULL, &appearance_params->y_scale, (void *) &y_scale); } else { use_yscale = dynamic_yscale = UUcFalse; } - + dynamic_rotation = P3iValueIsDynamic(&appearance_params->rotation); if (!dynamic_rotation) P3iCalculateValue(NULL, &appearance_params->rotation, (void *) &rotation); - + if (inClass->definition->flags & P3cParticleClassFlag_Appearance_ScaleToVelocity) { scale_to_velocity = UUcTrue; } else { scale_to_velocity = UUcFalse; } - + dynamic_alpha = P3iValueIsDynamic(&appearance_params->alpha); if (!dynamic_alpha) { P3iCalculateValue(NULL, &appearance_params->alpha, (void *) &floatalpha); constalpha = (UUtUns16) (floatalpha * M3cMaxAlpha); } - + dynamic_tint = P3iValueIsDynamic(&appearance_params->tint); if (!dynamic_tint) P3iCalculateValue(NULL, &appearance_params->tint, (void *) &tint); - + error = TMrInstance_GetDataPtr(M3cTemplate_TextureMap, appearance_params->instance, &texturemap); if (error != UUcError_None) { if ((inClass->non_persistent_flags & P3cParticleClass_NonPersistentFlag_WarnedAboutNotFound) == 0) { @@ -10038,14 +10038,14 @@ void P3rDisplayClass_Sprite(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 return; } } - - + + for (particle = inClass->headptr; particle != NULL; particle = next_particle) { next_particle = particle->header.nextptr; - + if (particle->header.flags & P3cParticleFlag_Hidden) continue; - + // calculate this particle's position positionptr = P3rGetPositionPtr(inClass, particle, &is_dead); if (is_dead) { @@ -10064,13 +10064,13 @@ void P3rDisplayClass_Sprite(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 *((M3tVector3D *) &particle->vararray[offsetpos_offset])); positionptr = &calculatedposition; } - + // apply the dynamic matrix to the position if (matrixptr) { MUrMatrix_MultiplyPoint(positionptr, matrixptr, &calculatedposition); positionptr = &calculatedposition; } - + if (dynamic_alpha) { P3iCalculateValue(particle, &appearance_params->alpha, (void *) &floatalpha); realalpha = (UUtUns16) (floatalpha * M3cMaxAlpha); @@ -10103,22 +10103,22 @@ void P3rDisplayClass_Sprite(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 // evaluate any dynamic appearance parameters for this particle if (dynamic_scale) P3iCalculateValue(particle, &appearance_params->scale, (void *) &scale); - + if (dynamic_xoffset) P3iCalculateValue(particle, &appearance_params->x_offset, (void *) &x_offset); - + if (dynamic_xshorten) P3iCalculateValue(particle, &appearance_params->x_shorten, (void *) &x_shorten); - + if (dynamic_rotation) P3iCalculateValue(particle, &appearance_params->rotation, (void *) &rotation); - + if (dynamic_yscale) P3iCalculateValue(particle, &appearance_params->y_scale, (void *) &y_scale); - + if (dynamic_tint) P3iCalculateValue(particle, &appearance_params->tint, (void *) &tint); - + // calculate the velocity and orientation if (vel_offset == P3cNoVar) { velocityptr = NULL; @@ -10130,12 +10130,12 @@ void P3rDisplayClass_Sprite(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 } else { orientationptr = (M3tMatrix3x3 *) &particle->vararray[orient_offset]; } - + currentscale = scale; if (scale_to_velocity && (velocityptr != NULL)) { currentscale *= 1.0f + MUmVector_GetLength(*velocityptr); } - + // apply the dynamic matrix to the velocity and orientation if there is one // this is done in a different place to the matrix application to position to speed // up lensflare culling @@ -10149,19 +10149,19 @@ void P3rDisplayClass_Sprite(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 orientationptr = &new_orientation; } } - + // set up the texture instance index if (texindex_offset != P3cNoVar) { texval = *((UUtUns32 *) &particle->vararray[texindex_offset]); M3rDraw_State_SetInt(M3cDrawStateIntType_TextureInstance, texval); } - + // set up the texture time index if (textime_offset != P3cNoVar) { texval = *((UUtUns32 *) &particle->vararray[textime_offset]); M3rDraw_State_SetInt(M3cDrawStateIntType_Time, inTime - texval); } - + // if we are fading out then use the current lifetime and fade time to calculate alpha // NB: this does *NOT* use the previous value of realalpha because when fading out, we calculate // fadeout_time to take our dynamic alpha into account. this means that lensflares can't fade out @@ -10169,14 +10169,14 @@ void P3rDisplayClass_Sprite(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns32 if (particle->header.flags & P3cParticleFlag_FadeOut) { realalpha = (UUtUns16) (M3cMaxAlpha * particle->header.lifetime / particle->header.fadeout_time); } - + // are we being chopped? if (particle->header.flags & P3cParticleFlag_Chop) { chopval = 1.0f - particle->header.lifetime / particle->header.fadeout_time; } else { chopval = 0.0f; } - + if (do_edgefade) { MUmVector_Subtract(cameraDir, cameraPos, *positionptr); MUmVector_Normalize(cameraDir); @@ -10295,14 +10295,14 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns } contraildata_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_ContrailData]; - UUmAssert((contraildata_offset >= 0) && + UUmAssert((contraildata_offset >= 0) && (contraildata_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); - + if (inMode == M3cGeomState_SpriteMode_Contrail) { // this sprite drawing mode requires an orientation matrix if (inClass->definition->flags & P3cParticleClassFlag_HasOrientation) { orient_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_Orientation]; - UUmAssert((orient_offset >= 0) && + UUmAssert((orient_offset >= 0) && (orient_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { COrConsole_Printf("### '%s' requires orientation to use this contrail mode!", @@ -10312,7 +10312,7 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns } else { orient_offset = P3cNoVar; } - + is_lensflare = ((inClass->definition->flags2 & P3cParticleClassFlag2_Appearance_LensFlare) != 0); lensflare_tolerance = 0.0f; if (is_lensflare) { @@ -10320,7 +10320,7 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns if (inClass->definition->flags & P3cParticleClassFlag_HasLensFrames) { lensframes_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_LensFrames]; - UUmAssert((lensframes_offset >= 0) && + UUmAssert((lensframes_offset >= 0) && (lensframes_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { lensframes_offset = P3cNoVar; @@ -10330,56 +10330,56 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns // is there an offset position? if (inClass->definition->flags & P3cParticleClassFlag_HasOffsetPos) { offsetpos_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_OffsetPos]; - UUmAssert((offsetpos_offset >= 0) && + UUmAssert((offsetpos_offset >= 0) && (offsetpos_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { offsetpos_offset = P3cNoVar; } - + // is there a dynamic matrix? if (inClass->definition->flags & P3cParticleClassFlag_HasDynamicMatrix) { dynmatrix_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_DynamicMatrix]; - UUmAssert((dynmatrix_offset >= 0) && + UUmAssert((dynmatrix_offset >= 0) && (dynmatrix_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { dynmatrix_offset = P3cNoVar; } - + // is there a texture index? if (inClass->definition->flags & P3cParticleClassFlag_HasTextureIndex) { texindex_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_TextureIndex]; - UUmAssert((texindex_offset >= 0) && + UUmAssert((texindex_offset >= 0) && (texindex_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { texindex_offset = P3cNoVar; - } - + } + // is there a texture time? if (inClass->definition->flags & P3cParticleClassFlag_HasTextureTime) { textime_offset = inClass->optionalvar_offset[P3cParticleOptionalVar_TextureTime]; - UUmAssert((textime_offset >= 0) && + UUmAssert((textime_offset >= 0) && (textime_offset < (UUtUns16) (inClass->particle_size - sizeof(P3tParticleHeader)))); } else { textime_offset = P3cNoVar; - } - + } + appearance_params = (P3tAppearance *) &inClass->definition->appearance; - + // set up drawing parameters for this class dynamic_scale = P3iValueIsDynamic(&appearance_params->scale); if (!dynamic_scale) P3iCalculateValue(NULL, &appearance_params->scale, (void *) &scale); - + dynamic_alpha = P3iValueIsDynamic(&appearance_params->alpha); if (!dynamic_alpha) { P3iCalculateValue(NULL, &appearance_params->alpha, (void *) &floatalpha); constalpha = (UUtUns16) (floatalpha * M3cMaxAlpha); } - + dynamic_tint = P3iValueIsDynamic(&appearance_params->tint); if (!dynamic_tint) P3iCalculateValue(NULL, &appearance_params->tint, (void *) &tint); - + do_edgefade = ((inClass->definition->flags2 & P3cParticleClassFlag2_Appearance_EdgeFade) != 0); if (do_edgefade) { if (P3iValueIsDynamic(&appearance_params->edgefade_min) || P3iValueIsDynamic(&appearance_params->edgefade_max)) { @@ -10414,7 +10414,7 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns return; } } - + // do we need to know where the camera is? if ((inMode == M3cGeomState_SpriteMode_ContrailRotated) || (do_edgefade)) { // get the camera's location @@ -10454,13 +10454,13 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns if (link_class->definition->flags & P3cParticleClassFlag_HasContrailData) { linkcontraildata_offset = link_class->optionalvar_offset[P3cParticleOptionalVar_ContrailData]; - UUmAssert((linkcontraildata_offset >= 0) && + UUmAssert((linkcontraildata_offset >= 0) && (linkcontraildata_offset < (UUtUns16) (link_class->particle_size - sizeof(P3tParticleHeader)))); } else { COrConsole_Printf("### '%s': emitted contrail particle has no contrail data!", inClass->classname); return; } - + } else { linkcontraildata_offset = contraildata_offset; @@ -10470,13 +10470,13 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns // set up drawing parameters for this class M3rGeom_State_Set(M3cGeomStateIntType_SpriteMode, inMode); M3rGeom_State_Commit(); - + for (particle = inClass->headptr; particle != NULL; particle = next_particle) { next_particle = particle->header.nextptr; - + if (particle->header.flags & P3cParticleFlag_Hidden) continue; - + // calculate this particle's position positionptr = P3rGetPositionPtr(inClass, particle, &is_dead); if (is_dead) { @@ -10499,7 +10499,7 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns MUmVector_Add(contraildataptr->position, contraildataptr->position, *((M3tVector3D *) &particle->vararray[offsetpos_offset])); } - + // apply the dynamic matrix to position if (matrixptr) { MUrMatrix_MultiplyPoint(&contraildataptr->position, matrixptr, &contraildataptr->position); @@ -10536,26 +10536,26 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns if (dynamic_scale) P3iCalculateValue(particle, &appearance_params->scale, (void *) &scale); - + // calculate the orientation if (orient_offset == P3cNoVar) { orientationptr = NULL; } else { orientationptr = (M3tMatrix3x3 *) &particle->vararray[orient_offset]; } - + // apply the dynamic matrix to orientation if (matrixptr && (orientationptr != NULL)) { MUrMatrix3x3_Multiply((M3tMatrix3x3 *) matrixptr, orientationptr, &new_orientation); orientationptr = &new_orientation; } - + if (dynamic_tint) { P3iCalculateValue(particle, &appearance_params->tint, (void *) &contraildataptr->tint); } else { contraildataptr->tint = tint; } - + // if we are fading out then use the current lifetime and fade time to calculate alpha if (particle->header.flags & P3cParticleFlag_FadeOut) { contraildataptr->alpha = (UUtUns16) (M3cMaxAlpha * particle->header.lifetime @@ -10563,7 +10563,7 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns } else { contraildataptr->alpha = realalpha; } - + if (inEmitter) { emitter_data = ((P3tParticleEmitterData *) particle->vararray) + emit_num; @@ -10595,7 +10595,7 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns ref = particle->header.user_ref; if (ref == P3cParticleReference_Null) continue; - + P3mUnpackParticleReference(ref, link_class, link_particle); if (link_class != inClass) { COrConsole_Printf("### '%s' contrail-link points to a different class!", inClass->classname); @@ -10640,10 +10640,10 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns MUrVector_CrossProduct(&contrailDir, &cameraDir, &contraildataptr->width); contrail_width = MUmVector_GetLength(contraildataptr->width); - if (contrail_width > 0.01f) + if (contrail_width > 0.01f) MUmVector_Scale(contraildataptr->width, scale / contrail_width); } - + // if we are the first section of the contrail (i.e. our linked particle has a link to // a null reference) then our linked particle never got to set up its contraildata's width. // copy ours. @@ -10703,13 +10703,13 @@ void P3rDisplayClass_Contrail(P3tParticleClass *inClass, UUtUns32 inTime, UUtUns texval = *((UUtUns32 *) &particle->vararray[texindex_offset]); M3rDraw_State_SetInt(M3cDrawStateIntType_TextureInstance, texval); } - + // set up the texture time index if (textime_offset != P3cNoVar) { texval = *((UUtUns32 *) &particle->vararray[textime_offset]); M3rDraw_State_SetInt(M3cDrawStateIntType_Time, inTime - texval); } - + #if 0 if ((inTime % 30) == 0) { // COrConsole_Printf("draw %f - %f", contraildataptr->position.x, linkcontraildataptr->position.x); @@ -10855,46 +10855,46 @@ void P3rEmitterSubsection(UUtUns16 inSection, P3tEmitter *inEmitter, UUtUns32 ** *outOffset = P3cEmitterValue_RateValOffset; strcpy(outDesc, "rate"); break; - + case 1: *outPropertyPtr = (UUtUns32 *)&inEmitter->position_type; *outClass = P3gEmitterPositionDesc; *outOffset = P3cEmitterValue_PositionValOffset; strcpy(outDesc, "position"); break; - + case 2: *outPropertyPtr = (UUtUns32 *)&inEmitter->direction_type; *outClass = P3gEmitterDirectionDesc; *outOffset = P3cEmitterValue_DirectionValOffset; strcpy(outDesc, "direction"); break; - + case 3: *outPropertyPtr = (UUtUns32 *)&inEmitter->speed_type; *outClass = P3gEmitterSpeedDesc; *outOffset = P3cEmitterValue_SpeedValOffset; strcpy(outDesc, "speed"); break; - + case 4: *outPropertyPtr = (UUtUns32 *)&inEmitter->orientdir_type; *outClass = P3gEmitterOrientationDesc; *outOffset = P3cEmitterValue_OrientationValOffset; strcpy(outDesc, "orient dir"); break; - + case 5: *outPropertyPtr = (UUtUns32 *)&inEmitter->orientup_type; *outClass = P3gEmitterOrientationDesc; *outOffset = P3cEmitterValue_OrientationValOffset; strcpy(outDesc, "orient up"); break; - + default: UUmAssert(0); } -} +} // create space for a new particle class static P3tParticleClass *P3iAllocateParticleClass(void) @@ -11074,7 +11074,7 @@ P3tParticleClass *P3rDuplicateParticleClass(P3tParticleClass *inClass, char *inN new_class->prev_active_class = new_class->next_active_class = P3cClass_None; new_class->particle_size = inClass->particle_size; new_class->size_class = inClass->size_class; - + // there must be enough room for the incoming class in the block that it has had allocated UUmAssert(inClass->memory.size >= inClass->definition->definition_size); @@ -11228,7 +11228,7 @@ UUtBool P3rDecodeAttractorIndex(UUtUns32 inAttractorID, UUtBool inPredictVelocit } else if (inAttractorID & P3cAttractor_ParticleReference) { P3tParticleClass *classptr; P3tParticle *particle; - + P3mUnpackParticleReference(inAttractorID, classptr, particle); if ((particle->header.self_ref != inAttractorID) || (P3rGetRealPosition(classptr, particle, outPoint))) { // attractor is dead @@ -11305,7 +11305,7 @@ void P3rIterateAttractors(P3tParticleClass *inClass, P3tParticle *inParticle, UU // nothing found yet P3gAttractorBuf_NumAttractors = 0; P3gAttractorBuf_Valid = UUcTrue; - + if (iterator_func == NULL) { if (attractor_data->index != (UUtUns32) -1) { P3gAttractorBuf_Storage[0] = attractor_data->index; @@ -11450,7 +11450,7 @@ void P3rFindAttractor(P3tParticleClass *inClass, P3tParticle *inParticle, UUtUns // nothing found yet attractor_index = (UUtUns32) -1; - + P3mAssertFloatValue(attractor->max_distance); P3iCalculateValue(inParticle, &attractor->max_distance, (void *) &max_distance); @@ -11755,7 +11755,7 @@ UUtBool P3iAttractorSelector_Distance(P3tParticleClass *inClass, P3tParticle *in M3tVector3D delta_pos; // static selection-sequence state variables - static float current_score; + static float current_score; static UUtUns32 previous_id; static M3tPoint3D our_point; static AKtEnvironment *env; @@ -12651,7 +12651,7 @@ UUtBool P3iAction_MoveSpiral(P3tParticleClass *inClass, P3tParticle *inParticle, } else { orientation = (M3tMatrix3x3 *) &inParticle->vararray[ori_offset]; UUmAssertReadPtr(orientation, sizeof(M3tMatrix3x3)); - + // set up offset position directly from orientation's X and Z axes offsetpos->x = radius * (costheta * orientation->m[0][0] - sintheta * orientation->m[2][0]); offsetpos->y = radius * (costheta * orientation->m[0][1] - sintheta * orientation->m[2][1]); @@ -12834,7 +12834,7 @@ UUtBool P3iAction_ChangeClass(P3tParticleClass *inClass, P3tParticle *inParticle p_matrix = P3rGetDynamicMatrixPtr(new_class, new_particle); if (p_matrix != NULL) { - our_matrix = P3rGetDynamicMatrixPtr(inClass, inParticle); + our_matrix = P3rGetDynamicMatrixPtr(inClass, inParticle); if (our_matrix == NULL) { *p_matrix = NULL; } else { @@ -13043,7 +13043,7 @@ UUtBool P3iAction_Bounce(P3tParticleClass *inClass, P3tParticle *inParticle, if (!p_velocity) { return UUcFalse; } - + #if 0 && defined(DEBUGGING) && DEBUGGING { float mag_0, mag_1; @@ -13066,7 +13066,7 @@ UUtBool P3iAction_Bounce(P3tParticleClass *inClass, P3tParticle *inParticle, mag_1 = MUmVector_GetLength(*p_velocity); if ((mag_0 / mag_1 > 1.01f) || (mag_0 / mag_1 < 0.99f)) { - COrConsole_Printf("### bounce %f -> %f, norm %f %f %f (%s)", mag_0, mag_1, + COrConsole_Printf("### bounce %f -> %f, norm %f %f %f (%s)", mag_0, mag_1, P3gCurrentCollision.hit_normal.x, P3gCurrentCollision.hit_normal.y, P3gCurrentCollision.hit_normal.z, (P3gCurrentCollision.env_collision) ? "env" : "phy"); @@ -13139,7 +13139,7 @@ UUtBool P3iAction_StickToWall(P3tParticleClass *inClass, P3tParticle *inParticle inParticle->header.flags |= (P3cParticleFlag_VelocityChanged | P3cParticleFlag_Stopped); inParticle->header.flags &= ~P3cParticleFlag_OrientToVelocity; } - + return UUcFalse; } @@ -13367,7 +13367,7 @@ UUtBool P3iAction_ImpactEffect(P3tParticleClass *inClass, P3tParticle *inParticl // FIXME: get the material for this physics context (somehow) // this is tricky because it might be a character, which has materials, or some // other kind of physics context - + material_type = P3iPhysicsGetMaterialType(effect_data.cause_data.particle_physics.context); } } else { @@ -13406,7 +13406,7 @@ UUtBool P3iAction_DamageChar(P3tParticleClass *inClass, P3tParticle *inParticle, // don't kill people with exploding munitions caused by a cutscene return UUcFalse; } - + if ((!P3gCurrentCollision.collided) || (P3gCurrentCollision.env_collision) || (P3gCurrentCollision.damaged_hit) || (P3gCurrentCollision.hit_context->callback->type != PHcCallback_Character)) return UUcFalse; @@ -13423,12 +13423,12 @@ UUtBool P3iAction_DamageChar(P3tParticleClass *inClass, P3tParticle *inParticle, returnval = P3iCalculateValue(inParticle, &inAction->action_value[0], (void *) &damage); if (!returnval) return UUcFalse; - + P3mAssertFloatValue(inAction->action_value[1]); returnval = P3iCalculateValue(inParticle, &inAction->action_value[1], (void *) &stundamage); if (!returnval) return UUcFalse; - + P3mAssertFloatValue(inAction->action_value[2]); returnval = P3iCalculateValue(inParticle, &inAction->action_value[2], (void *) &knockback); if (!returnval) @@ -13445,7 +13445,7 @@ UUtBool P3iAction_DamageChar(P3tParticleClass *inClass, P3tParticle *inParticle, P3mAssertEnumValue(inAction->action_value[4], P3cEnumType_Bool); self_immune = (UUtBool) inAction->action_value[4].u.enum_const.val; - + if (inAction->action_value[5].type == P3cValueType_Enum) { P3mAssertEnumValue(inAction->action_value[5], P3cEnumType_Bool); can_damage_multiple = (UUtBool) inAction->action_value[5].u.enum_const.val; @@ -13456,7 +13456,7 @@ UUtBool P3iAction_DamageChar(P3tParticleClass *inClass, P3tParticle *inParticle, p_owner = P3rGetOwnerPtr(inClass, inParticle); if (NULL == p_owner) { owner = 0; - } + } else { owner = *p_owner; } @@ -13468,7 +13468,7 @@ UUtBool P3iAction_DamageChar(P3tParticleClass *inClass, P3tParticle *inParticle, owner = 0; } - + if (WPcDamageOwner_Falling == (owner & WPcDamageOwner_TypeMask)) { COrConsole_Printf("particle %s doing 'Falling' damage", inClass->classname) ; @@ -13510,25 +13510,25 @@ UUtBool P3iAction_DamageBlast(P3tParticleClass *inClass, P3tParticle *inParticle returnval = P3iCalculateValue(inParticle, &inAction->action_value[0], (void *) &damage); if (!returnval) return UUcFalse; - + P3mAssertFloatValue(inAction->action_value[1]); returnval = P3iCalculateValue(inParticle, &inAction->action_value[1], (void *) &stundamage); if (!returnval) return UUcFalse; - + P3mAssertFloatValue(inAction->action_value[2]); returnval = P3iCalculateValue(inParticle, &inAction->action_value[2], (void *) &knockback); if (!returnval) return UUcFalse; - + P3mAssertFloatValue(inAction->action_value[3]); returnval = P3iCalculateValue(inParticle, &inAction->action_value[3], (void *) &radius); if (!returnval) return UUcFalse; - + P3mAssertEnumValue(inAction->action_value[4], P3cEnumType_Falloff); falloff_type = (P3tEnumFalloff)inAction->action_value[4].u.enum_const.val; - + if (inAction->action_value[5].type == P3cValueType_Enum) { damage_type = (P3tEnumDamageType) inAction->action_value[5].u.enum_const.val; if ((damage_type < 0) || (damage_type >= P3cEnumDamageType_Max)) { @@ -13540,7 +13540,7 @@ UUtBool P3iAction_DamageBlast(P3tParticleClass *inClass, P3tParticle *inParticle P3mAssertEnumValue(inAction->action_value[6], P3cEnumType_Bool); self_immune = (UUtBool) inAction->action_value[6].u.enum_const.val; - + if (inAction->action_value[7].type == P3cValueType_Enum) { P3mAssertEnumValue(inAction->action_value[7], P3cEnumType_Bool); damage_environment = (UUtBool) inAction->action_value[7].u.enum_const.val; @@ -13566,7 +13566,7 @@ UUtBool P3iAction_DamageBlast(P3tParticleClass *inClass, P3tParticle *inParticle #endif hit = P3gCurrentCollision.hit_context->callbackData; } - } + } } // look for all quads within the blast radius and damage them @@ -13614,7 +13614,7 @@ UUtBool P3iAction_DamageBlast(P3tParticleClass *inClass, P3tParticle *inParticle #endif return UUcFalse; } - + // COrConsole_Printf("p3 blast damage %s %d", inClass->classname, damage_type); #if PARTICLE_DEBUG_BLAST @@ -13623,7 +13623,7 @@ UUtBool P3iAction_DamageBlast(P3tParticleClass *inClass, P3tParticle *inParticle radius, damage, stundamage, knockback); #endif WPrBlast(&blast_sphere.center, damage_type, damage, stundamage, knockback, radius, - falloff_type, owner, hit, inParticle->header.self_ref, self_immune); + falloff_type, owner, hit, inParticle->header.self_ref, self_immune); return UUcFalse; } @@ -13648,12 +13648,12 @@ UUtBool P3iAction_GlassCharge(P3tParticleClass *inClass, P3tParticle *inParticle returnval = P3iCalculateValue(inParticle, &inAction->action_value[0], (void *) &blast_vel); if (!returnval) return UUcFalse; - + P3mAssertFloatValue(inAction->action_value[1]); returnval = P3iCalculateValue(inParticle, &inAction->action_value[1], (void *) &radius); if (!returnval) return UUcFalse; - + // create blast at current location blast_sphere.radius = radius; is_dead = P3rGetRealPosition(inClass, inParticle, &blast_sphere.center); @@ -13717,7 +13717,7 @@ UUtBool P3iAction_DamageEnvironment(P3tParticleClass *inClass, P3tParticle *inPa returnval = P3iCalculateValue(inParticle, &inAction->action_value[0], (void *) &damage); if (!returnval) return UUcFalse; - + // damage just the quad that we hit env = ONrGameState_GetEnvironment(); P3iDamageQuad(env, P3gCurrentCollision.hit_gqindex, damage, NULL, NULL, 0, UUcFalse); @@ -14325,7 +14325,7 @@ UUtBool P3iAction_Chop(P3tParticleClass *inClass, P3tParticle *inParticle, inParticle->header.fadeout_time = chop_time; inParticle->header.flags |= P3cParticleFlag_Chop; - return UUcFalse; + return UUcFalse; } // make a particle fly away from its spiral path. called once - translates spiral position into linear velocity @@ -14565,7 +14565,7 @@ static UUtBool P3iAmbientSound_Update(P3tParticleClass *inClass, P3tParticle *in UUtBool is_dead; M3tMatrix3x3 *p_orientation; M3tVector3D position, *directionptr, direction, *velocityptr; - + #if PERFORMANCE_TIMER UUrPerformanceTimer_Enter(P3g_ParticleSound); #endif @@ -14603,7 +14603,7 @@ static UUtBool P3iAmbientSound_Update(P3tParticleClass *inClass, P3tParticle *in COrConsole_Printf("P3iAmbientSound_Update (%s | %d) from 0x%08X", (inAmbientSound == NULL) ? "update" : inAmbientSound->ambient_name, inParticle->header.current_sound, inParticle->header.self_ref); #endif - + #if PERFORMANCE_TIMER UUrPerformanceTimer_Exit(P3g_ParticleSound); #endif @@ -14647,7 +14647,7 @@ UUtBool P3iAction_ImpulseSound(P3tParticleClass *inClass, P3tParticle *inParticl M3tMatrix3x3 *p_orientation; M3tVector3D position, *directionptr, direction, *velocityptr; SStImpulse *impulse_sound; - + #if PERFORMANCE_TIMER UUrPerformanceTimer_Enter(P3g_ParticleSound); #endif @@ -14660,7 +14660,7 @@ UUtBool P3iAction_ImpulseSound(P3tParticleClass *inClass, P3tParticle *inParticl #endif return UUcFalse; } - + // find the particle's real position is_dead = P3rGetRealPosition(inClass, inParticle, &position); if (is_dead) { @@ -14683,7 +14683,7 @@ UUtBool P3iAction_ImpulseSound(P3tParticleClass *inClass, P3tParticle *inParticl velocityptr = P3rGetVelocityPtr(inClass, inParticle); OSrImpulse_Play(impulse_sound, &position, directionptr, velocityptr, NULL); - + #if PERFORMANCE_TIMER UUrPerformanceTimer_Exit(P3g_ParticleSound); #endif @@ -14881,7 +14881,7 @@ UUtBool P3iAction_AttractHoming(P3tParticleClass *inClass, P3tParticle *inPartic if (q_angle > turn_speed) { MUrQuat_SetValue(&rotate_q, qx, qy, qz, turn_speed); } - + MUrQuatToMatrix(&rotate_q, &rotate_matrix); MUrMatrix3x3_MultiplyPoint(velocity, (M3tMatrix3x3 *) &rotate_matrix, velocity); @@ -15232,7 +15232,7 @@ UUtBool P3iAction_FloatAbovePlayer(P3tParticleClass *inClass, P3tParticle *inPar float height; UUtBool returnval; ONtCharacter *player_character; - + P3mAssertFloatValue(inAction->action_value[0]); returnval = P3iCalculateValue(inParticle, &inAction->action_value[0], (void *) &height); if (!returnval) @@ -15255,7 +15255,7 @@ UUtBool P3iAction_StopIfSlow(P3tParticleClass *inClass, P3tParticle *inParticle, float speed, cur_speed; UUtBool returnval; M3tVector3D *velocity; - + P3mAssertFloatValue(inAction->action_value[0]); returnval = P3iCalculateValue(inParticle, &inAction->action_value[0], (void *) &speed); if (!returnval) diff --git a/BungieFrameWork/BFW_Source/BFW_Path/BFW_Path.c b/BungieFrameWork/BFW_Source/BFW_Path/BFW_Path.c index 6bfdef3..f8bd3d5 100644 --- a/BungieFrameWork/BFW_Source/BFW_Path/BFW_Path.c +++ b/BungieFrameWork/BFW_Source/BFW_Path/BFW_Path.c @@ -1,8 +1,8 @@ /* BFW_Path.c - + This file contains all BFW pathfinding related code - + Author: Quinn Dunki c1998 Bungie */ @@ -38,13 +38,13 @@ void PHrTerminate(void) } void PHrBresenham2( - UUtInt16 x1, - UUtInt16 y1, - UUtInt16 x2, - UUtInt16 y2, - PHtSquare *grid, - UUtUns32 inWidth, - UUtUns32 inHeight, + UUtInt16 x1, + UUtInt16 y1, + UUtInt16 x2, + UUtInt16 y2, + PHtSquare *grid, + UUtUns32 inWidth, + UUtUns32 inHeight, PHtSquare *fill, PHtRasterizationCallback callback); @@ -59,7 +59,7 @@ void PHrPutObstruction( { if (s>=0 && s=0 && tweight; if (cell_macro_value.weight < weight) - { - PutCell(s,t,weight); - DEBUG_PH_PLOT; + { + PutCell(s,t,weight); + DEBUG_PH_PLOT; } } } - + void PHrCheckAndBlastCell( PHtSquare *grid, UUtUns16 height, @@ -100,15 +100,15 @@ void PHrCheckAndBlastCell( PHtSquare cell_macro_value; UUtUns8 weight; - if (s>=0 && s=0 && t=0 && s=0 && tweight; PutCell(s,t,weight); DEBUG_PH_PLOT; - } + } } void PHrGridToWorldSpace(UUtUns16 inGridX, UUtUns16 inGridY, const float *inAltitude, M3tPoint3D *outWorld, const PHtRoomData *inRoom) @@ -118,7 +118,7 @@ void PHrGridToWorldSpace(UUtUns16 inGridX, UUtUns16 inGridY, const float *inAlti * to the grid defined for 'inRoom'. Pass the altitude of the room at (inGridX,inGridY) * if known, otherwise NULL */ - + outWorld->x = (float)(inGridX+inRoom->gox) * inRoom->squareSize + inRoom->squareSize/2.0f + inRoom->origin.x; if (inAltitude) outWorld->y = *inAltitude; @@ -139,7 +139,7 @@ void PHrWorldToGridSpace(UUtUns16 *outGridX, UUtUns16 *outGridY, const M3tPoint3 UUmAssertWritePtr(outGridY, sizeof(UUtUns16)); UUmAssertReadPtr(inWorld, sizeof(M3tPoint3D)); UUmAssertReadPtr(inRoom, sizeof(PHtRoomData)); - + gridX = MUrFloat_Round_To_Int(((inWorld->x - inRoom->squareSize * 0.5f /* S.S./2.0f*/ - inRoom->origin.x) / inRoom->squareSize - (float)inRoom->gox)); gridY = MUrFloat_Round_To_Int(((inWorld->z - inRoom->squareSize * 0.5f /* S.S./2.0f*/ - inRoom->origin.z) / inRoom->squareSize - (float)inRoom->goy)); @@ -170,14 +170,14 @@ UUtBool PHrWorldInGridSpace(const M3tPoint3D *inWorld, const PHtRoomData *inRoom UUmAssertReadPtr(inWorld, sizeof(M3tPoint3D)); UUmAssertReadPtr(inRoom, sizeof(PHtRoomData)); - + gridX = MUrFloat_Round_To_Int(((inWorld->x - inRoom->squareSize * 0.5f/* S.S. /2.0f*/ - inRoom->origin.x) / inRoom->squareSize - (float)inRoom->gox)); gridY = MUrFloat_Round_To_Int(((inWorld->z - inRoom->squareSize * 0.5f/*/2.0f*/ - inRoom->origin.z) / inRoom->squareSize - (float)inRoom->goy)); success = (gridX >= 0) && ((UUtUns32) gridX < inRoom->gridX) && (gridY >= 0) && ((UUtUns32) gridY < inRoom->gridY); - return success; + return success; } void PHrWorldToGridSpaceDangerous(UUtInt16 *outGridX, UUtInt16 *outGridY, const M3tPoint3D *inWorld, const PHtRoomData *inRoom) @@ -188,7 +188,7 @@ void PHrWorldToGridSpaceDangerous(UUtInt16 *outGridX, UUtInt16 *outGridY, const * for the coordinate system of the grid in question. Don't use this routine unless you * know what you're doing. */ - + UUmAssertWritePtr(outGridX, sizeof(UUtUns16)); UUmAssertWritePtr(outGridY, sizeof(UUtUns16)); UUmAssertReadPtr(inWorld, sizeof(M3tPoint3D)); @@ -207,10 +207,10 @@ void PHrWaypointFromGunk(AKtEnvironment *inEnv, AKtGQ_General *inGQGeneral, M3tP * getting to that quad from 'inPoint'. Pass NULL in 'inPoint' * to return the center of the quad on the floor */ - + M3tPoint3D *lowest_point_1; M3tPoint3D *lowest_point_2; - + // Find lowest two points of quad { M3tQuad *quad = &inGQGeneral->m3Quad.vertexIndices; @@ -218,10 +218,10 @@ void PHrWaypointFromGunk(AKtEnvironment *inEnv, AKtGQ_General *inGQGeneral, M3tP AUrQuad_LowestPoints(quad,points,&lowest_point_1,&lowest_point_2); } - + // If the doorway is narrow or an SAT, or we want the center, head for the middle of it if ( - (NULL == inPoint) || + (NULL == inPoint) || (MUrPoint_Distance_Squared(lowest_point_1,lowest_point_2) <= UUmSQR(PHcComfortDistance * 2.0f)) ) { @@ -248,22 +248,22 @@ void PHrWaypointFromGunk(AKtEnvironment *inEnv, AKtGQ_General *inGQGeneral, M3tP MUmVector_Subtract(*outPoint, *lowest_point_1, *lowest_point_2); MUrVector_SetLength(outPoint, PHcComfortDistance); - MUmVector_Increment(*outPoint, *lowest_point_2); + MUmVector_Increment(*outPoint, *lowest_point_2); } } - + outPoint->y += 1.0f; } void PHrBresenhamAA( - UUtInt16 x1, - UUtInt16 y1, - UUtInt16 x2, + UUtInt16 x1, + UUtInt16 y1, + UUtInt16 x2, UUtInt16 y2, - PHtSquare *grid, - UUtUns32 width, - UUtUns32 height, - PHtSquare *fill, + PHtSquare *grid, + UUtUns32 width, + UUtUns32 height, + PHtSquare *fill, PHtSquare *blend, PHtRasterizationCallback callback) { @@ -271,14 +271,14 @@ void PHrBresenhamAA( * Draws an antialiased bresenham line with 'fill' as the line, * and using 'blend' to smooth the edges. */ - + UUtInt16 dx,dy; - + PHrBresenham2(x1,y1,x2,y2,grid,width,height,fill,callback); - + dx = UUmABS(x2-x1); dy = UUmABS(y2-y1); - + if (dx > dy) { PHrBresenham2(x1,y1-1,x2,y2-1,grid,width,height,blend,callback); @@ -292,15 +292,15 @@ void PHrBresenhamAA( return; } - + void PHrBresenham2( - UUtInt16 x1, - UUtInt16 y1, - UUtInt16 x2, - UUtInt16 y2, - PHtSquare *grid, - UUtUns32 inWidth, - UUtUns32 inHeight, + UUtInt16 x1, + UUtInt16 y1, + UUtInt16 x2, + UUtInt16 y2, + PHtSquare *grid, + UUtUns32 inWidth, + UUtUns32 inHeight, PHtSquare *fill, PHtRasterizationCallback callback) { @@ -311,12 +311,12 @@ void PHrBresenham2( * input validation. Will not overwrite squares of heavier weight unless * the fill colour is PHcClear (which indicates we want to erase) */ - + UUtInt32 width = inWidth; UUtInt32 height = inHeight; UUtInt16 ax,ay,dx,dy,x,y,e,xdir,ydir; UUtBool overwrite; - + overwrite = (PHcClear == fill->weight) ? UUcTrue : UUcFalse; gOverwrite = overwrite; @@ -325,18 +325,18 @@ void PHrBresenham2( gFill = *fill; //symwuline((int)x1,(int)y1,(int)x2,(int)y2); //return; - + UUmAssert(inWidth <= UUcMaxInt32); UUmAssert(inHeight <= UUcMaxInt32); - + // UUmAssert(x1 >= 0 && x1 < width && y1 >= 0 && y1 < height); // UUmAssert(x2 >= 0 && x2 < width && y2 >= 0 && y2 < height); - + dx = x2-x1; dy = y2-y1; ax = UUmABS(x2-x1); ay = UUmABS(y2-y1); - + if (dx < 0) { xdir = -1; } @@ -356,10 +356,10 @@ void PHrBresenham2( else { ydir = 1; } - + x = x1; y = y1; - + if (ax > ay) { e = (ay-ax)/2; @@ -371,14 +371,14 @@ void PHrBresenham2( if (!overwrite) PHrCheckAndPutCell(grid,(UUtUns16)height,(UUtUns16)width,x,y,fill); else PHrCheckAndBlastCell(grid,(UUtUns16)height,(UUtUns16)width,x,y,fill); - + if (x==x2) return; if (e>=0) { y+=ydir; e-=ax; } - + x+=xdir; e+=ay; } @@ -394,14 +394,14 @@ void PHrBresenham2( if (!overwrite) PHrCheckAndPutCell(grid,(UUtUns16)height,(UUtUns16)width,x,y,fill); else PHrCheckAndBlastCell(grid,(UUtUns16)height,(UUtUns16)width,x,y,fill); - + if (y==y2) return; if (e>=0) { x+=xdir; e-=ay; } - + y+=ydir; e+=ax; } @@ -410,13 +410,13 @@ void PHrBresenham2( void PHrDynamicBresenham2( - UUtInt16 x1, - UUtInt16 y1, - UUtInt16 x2, - UUtInt16 y2, - PHtDynamicSquare *grid, - UUtUns32 inWidth, - UUtUns32 inHeight, + UUtInt16 x1, + UUtInt16 y1, + UUtInt16 x2, + UUtInt16 y2, + PHtDynamicSquare *grid, + UUtUns32 inWidth, + UUtUns32 inHeight, UUtUns8 inObstruction, UUtBool inOverwrite) { @@ -427,19 +427,19 @@ void PHrDynamicBresenham2( * input validation. Will not overwrite existing obstructions unless * inOverwrite is set. */ - + UUtInt32 width = inWidth; UUtInt32 height = inHeight; UUtInt16 ax,ay,dx,dy,x,y,e,xdir,ydir; - + UUmAssert(inWidth <= UUcMaxInt32); UUmAssert(inHeight <= UUcMaxInt32); - + dx = x2-x1; dy = y2-y1; ax = UUmABS(x2-x1); ay = UUmABS(y2-y1); - + if (dx < 0) { xdir = -1; } @@ -459,10 +459,10 @@ void PHrDynamicBresenham2( else { ydir = 1; } - + x = x1; y = y1; - + if (ax > ay) { e = (ay-ax)/2; @@ -473,14 +473,14 @@ void PHrDynamicBresenham2( grid[x + y*width].obstruction = inObstruction; } } - + if (x==x2) return; if (e>=0) { y+=ydir; e-=ax; } - + x+=xdir; e+=ay; } @@ -495,14 +495,14 @@ void PHrDynamicBresenham2( grid[x + y*width].obstruction = inObstruction; } } - + if (y==y2) return; if (e>=0) { x+=xdir; e-=ay; } - + y+=ydir; e+=ax; } diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang.c b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang.c index 1d7b648..1a5b919 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang.c +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang.c @@ -1,12 +1,12 @@ /* FILE: BFW_ScriptLang.c - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -40,7 +40,7 @@ BFtDebugFile* SLgDebugFile = NULL; const char *SLcTypeName[SLcType_Max] = {"integer", "string", "float", "bool", "void"}; -UUtError +UUtError SLrScript_CommandTable_Register_Void(SLtRegisterVoidFunctionTable *inTable) { SLtRegisterVoidFunctionTable *current_entry; @@ -191,12 +191,12 @@ SLrScript_Schedule( { UUtError error; SLtErrorContext errorContext; - + errorContext.fileName = "(called from engine)"; errorContext.funcName = UUrMemory_String_GetStr(SLgLexemMemory, inName); errorContext.line = 0; - error = + error = SLrScheduler_Execute( inName, &errorContext, @@ -207,8 +207,8 @@ SLrScript_Schedule( inNumberOfTimes, ioReferencePtr); if(error != UUcError_None) return error; - - return UUcError_None; + + return UUcError_None; } UUtError // error code can probably be ignore - i will decide later @@ -216,7 +216,7 @@ SLrScript_ExecuteOnce( const char* inName, UUtUns16 inParameterListLength, SLtParameter_Actual* inParameterList, - SLtParameter_Actual *ioReturnValue, + SLtParameter_Actual *ioReturnValue, SLtContext ** ioReferencePtr) // used for getting a reference to track currently-running scripts { UUtError error; @@ -225,12 +225,12 @@ SLrScript_ExecuteOnce( if (inParameterListLength) UUrMemory_MoveFast(inParameterList, local_buffer, sizeof(SLtParameter_Actual) * inParameterListLength); - + errorContext.fileName = "(called from engine)"; errorContext.funcName = UUrMemory_String_GetStr(SLgLexemMemory, inName); errorContext.line = 0; - error = + error = SLrScheduler_Execute( inName, &errorContext, @@ -241,8 +241,8 @@ SLrScript_ExecuteOnce( 1, ioReferencePtr); if(error != UUcError_None) return error; - - return UUcError_None; + + return UUcError_None; } void @@ -264,28 +264,28 @@ SLrScript_Database_Add( SLtToken* curToken; SLtContext* context; SLtErrorContext errorContext; - + UUrMemory_String_GetStr(SLgLexemMemory, inFileName); errorContext.fileName = UUrMemory_String_GetStr(SLgLexemMemory, inFileName); - + error = SLrScript_TextToToken(SLgLexemMemory, inFileName, inText, &numTokens, &tokens); UUmError_ReturnOnError(error); - + curToken = tokens; - + context = SLrContext_New(NULL); UUmError_ReturnOnNull(context); - + context->curFuncState = context->funcStack; context->curFuncState->parseTOS = 0; context->curFuncState->curToken = tokens; context->funcTOS = 1; - + error = SLrScript_Parse(context, &errorContext, SLcParseMode_AddToDatabase); if(error != UUcError_None) return error; - + SLrContext_Delete(context); - + return UUcError_None; } @@ -300,12 +300,12 @@ SLrGlobalVariable_Register( // use to register a variable that is to be expo { UUtError error; SLtErrorContext errorContext; - + errorContext.fileName = "(called from engine)"; errorContext.funcName = "(called from engine)"; errorContext.line = 0; - - error = + + error = SLrScript_Database_Var_Engine_Add( inName, inDescription, @@ -315,7 +315,7 @@ SLrGlobalVariable_Register( // use to register a variable that is to be expo inVariableAddress, inNotificationProc); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -394,7 +394,7 @@ SLrScript_Update( UUtUns32 inGameTime) { SLrScheduler_Update(inGameTime); - + return UUcError_None; } @@ -409,7 +409,7 @@ SLiScript_ConsoleHook( UUtUns16 numTokens; SLtToken* tokens; SLtContext* context; - + errorContext.fileName = "(called from console)"; errorContext.funcName = "(called from console)"; errorContext.line = 0; @@ -422,47 +422,47 @@ SLiScript_ConsoleHook( &numTokens, &tokens); if(error != UUcError_None) return UUcFalse; - + if(numTokens == 0) return UUcTrue; - + context = SLrContext_New(NULL); if(context == NULL) return UUcFalse; - + error = SLrParse_FuncStack_Push_Console(context, &errorContext, tokens); if(error != UUcError_None) goto done; - - error = + + error = SLrScript_Parse( context, &errorContext, SLcParseMode_InitialExecution); - + switch(context->returnType) { case SLcType_Int32: COrConsole_Printf("int32: %d", context->returnValue.i); break; - + case SLcType_Bool: COrConsole_Printf("bool: %d", context->returnValue.b); break; - + case SLcType_Float: COrConsole_Printf("float: %f", context->returnValue.f); break; - + case SLcType_String: COrConsole_Printf("string: %s", context->returnValue.str); break; } - + if ((context->ticksTillCompletion == 0) && (!context->stalled)) { SLrContext_Delete(context); } done: - - return error == UUcError_None ? UUcTrue : UUcFalse; + + return error == UUcError_None ? UUcTrue : UUcFalse; } UUtError @@ -470,36 +470,36 @@ SLrScript_Initialize( void) { UUtError error; - + SLgLexemMemory = UUrMemory_String_New(SLcLexem_TableSize); UUmError_ReturnOnNull(SLgLexemMemory); - + SLgPermStringMemory = UUrMemory_String_New(SLcLexem_TableSize); UUmError_ReturnOnNull(SLgPermStringMemory); - + SLgDatabaseHeap = UUrMemory_Heap_New(SLcDatabase_HeapSize, UUcFalse); UUmError_ReturnOnNull(SLgDatabaseHeap); - + SLgPermanentMem = UUrMemory_Pool_New(SLcPermanent_PoolSize, UUcFalse); UUmError_ReturnOnNull(SLgPermanentMem); - + error = SLrScheduler_Initialize(); UUmError_ReturnOnError(error); - - error = + + error = SLrScript_Command_Register_Void( "dump_docs", "Shows all registered variables and commands", "", SLrDatabase_Command_DumpAll); UUmError_ReturnOnErrorMsg(error, "Unable to create a new command."); - + error = COrConsole_AddHook("", 0, SLiScript_ConsoleHook); UUmError_ReturnOnError(error); - + SLgDebugFile = BFrDebugFile_Open("script_debug.txt"); UUmAssert(SLgDebugFile); - + return UUcError_None; } @@ -508,12 +508,12 @@ SLrScript_Terminate( void) { SLrScheduler_Terminate(); - + UUrMemory_String_Delete(SLgPermStringMemory); UUrMemory_String_Delete(SLgLexemMemory); UUrMemory_Heap_Delete(SLgDatabaseHeap); UUrMemory_Pool_Delete(SLgPermanentMem); - + BFrDebugFile_Close(SLgDebugFile); return; diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Context.c b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Context.c index 2457872..d5364c0 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Context.c +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Context.c @@ -1,12 +1,12 @@ /* FILE: BFW_ScriptLang_Context.c - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -27,12 +27,12 @@ SLrContext_New( SLtContext ** inReferencePtr) { SLtContext* newContext; - + newContext = UUrMemory_Heap_Block_New(SLgDatabaseHeap, sizeof(*newContext)); if(newContext == NULL) return NULL; - + UUrMemory_Clear(newContext, sizeof(*newContext)); - + if ((newContext->referenceptr = inReferencePtr) != NULL) { // store a reference to this context UUmAssertWritePtr(newContext->referenceptr, sizeof(SLtContext *)); diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Context.h b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Context.h index 2138050..40659b2 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Context.h +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Context.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_ScriptLang_Context.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Database.c b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Database.c index 1c34e21..a2ed133 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Database.c +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Database.c @@ -1,12 +1,12 @@ /* FILE: BFW_ScriptLang_Database.c - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -44,7 +44,7 @@ SLiSymbol_Find( { SLtSymbol* curSymbol; UUtInt16 curLevel; - + if(inContext != NULL) { for(curLevel = inContext->curFuncState->scopeLevel + 1; curLevel-- > 0;) @@ -60,12 +60,12 @@ SLiSymbol_Find( { if(!strcmp(curSymbol->name, inName) && curSymbol->kind == inKind) return curSymbol; } - + for(curSymbol = SLgPermanentSymbolList; curSymbol; curSymbol = curSymbol->next) { if(!strcmp(curSymbol->name, inName) && curSymbol->kind == inKind) return curSymbol; } - + return NULL; } @@ -79,27 +79,27 @@ SLiSymbol_New_AddToScope( SLtSymbol* symbol; UUtUns16 scopeLevel; UUtBool makePerm; - + if (inContext) scopeLevel = inContext->curFuncState->scopeLevel; else scopeLevel = 0; makePerm = (inKind == SLcSymbolKind_Func_Command || inKind == SLcSymbolKind_Iterator || inKind == SLcSymbolKind_VarAddr); - + // first make sure that this name does not exist at this level symbol = SLiSymbol_Find(inContext, inName, inKind); if(symbol != NULL && symbol->scopeLevel == scopeLevel) { // error duplicate symbol SLrScript_Error_Semantic(inErrorContext, "Identifer \"%s\" already declared", inName); - + return NULL; } - + if(makePerm == UUcTrue) { SLgPermanentSymbolList_Dirty = UUcTrue; - + symbol = UUrMemory_Pool_Block_New(SLgPermanentMem, sizeof(SLtSymbol)); if(symbol == NULL) return NULL; } @@ -108,20 +108,20 @@ SLiSymbol_New_AddToScope( symbol = UUrMemory_Heap_Block_New(SLgDatabaseHeap, sizeof(SLtSymbol)); if(symbol == NULL) return NULL; } - + symbol->name = inName; if(symbol->name == NULL) return NULL; - + symbol->fileName = inErrorContext->fileName; if(symbol->fileName == NULL) return NULL; symbol->kind = inKind; symbol->scopeLevel = scopeLevel; symbol->line = inErrorContext->line; - + if(inContext == NULL) { - + if(makePerm == UUcTrue) { symbol->next = SLgPermanentSymbolList; @@ -130,7 +130,7 @@ SLiSymbol_New_AddToScope( { SLgPermanentSymbolList->prev = symbol; } - + SLgPermanentSymbolList = symbol; } else @@ -141,7 +141,7 @@ SLiSymbol_New_AddToScope( { SLgGlobalSymbolList->prev = symbol; } - + SLgGlobalSymbolList = symbol; } } @@ -149,15 +149,15 @@ SLiSymbol_New_AddToScope( { symbol->next = inContext->curFuncState->symbolList[scopeLevel]; symbol->prev = NULL; - + if(inContext->curFuncState->symbolList[scopeLevel] != NULL) { inContext->curFuncState->symbolList[scopeLevel]->prev = symbol; } - + inContext->curFuncState->symbolList[scopeLevel] = symbol; - } - + } + return symbol; } @@ -166,7 +166,7 @@ SLiSymbol_Delete( SLtContext* inContext, SLtSymbol* inSymbol) { - + if(inSymbol->prev == NULL) { if(inContext == NULL) @@ -182,12 +182,12 @@ SLiSymbol_Delete( { inSymbol->prev->next = inSymbol->next; } - + if(inSymbol->next != NULL) { inSymbol->next->prev = inSymbol->prev; } - + UUrMemory_Heap_Block_Delete(SLgDatabaseHeap, inSymbol); } @@ -196,7 +196,7 @@ SLrScript_Database_Internal_Reset( void) { UUrMemory_Heap_Reset(SLgDatabaseHeap); - + SLgGlobalSymbolList = NULL; } @@ -211,28 +211,28 @@ SLrScript_Database_FunctionScript_Add( SLtToken* inStartToken) { SLtSymbol* newSymbol; - SLtToken* newTokens; + SLtToken* newTokens; if(inNumParams > SLcScript_MaxNumParams) { SLrScript_Error_Semantic(inErrorContext, "Too many parameters, talk to brent"); return UUcError_Generic; } - + newSymbol = SLiSymbol_New_AddToScope(NULL, inName, inErrorContext, SLcSymbolKind_Func_Script); if(newSymbol == NULL) return UUcError_Generic; // don't let semantic errors cause asserts - + newTokens = UUrMemory_Heap_Block_New(SLgDatabaseHeap, sizeof(SLtToken) * inNumTokens); UUmError_ReturnOnNull(newTokens); - + UUrMemory_MoveFast(inStartToken, newTokens, sizeof(SLtToken) * inNumTokens); - + UUrMemory_MoveFast(inParamList, newSymbol->u.funcScript.paramList, sizeof(*inParamList) * inNumParams); newSymbol->u.funcScript.returnType = inReturnType; newSymbol->u.funcScript.startToken = newTokens; newSymbol->u.funcScript.numParams = inNumParams; - + return UUcError_None; } @@ -241,14 +241,14 @@ typedef enum SLtParamElemType { SLcParamElemType_Formal, SLcParamElemType_Group - + } SLtParamElemType; typedef enum SLtGroupType { SLcGroupType_And, SLcGroupType_Or - + } SLtGroupType; typedef struct SLtParamElem SLtParamElem; @@ -256,16 +256,16 @@ typedef struct SLtParamElem SLtParamElem; typedef struct SLtParam_Group { SLtGroupType type; - + SLtParamElem* a; SLtParamElem* b; - + } SLtParam_Group; struct SLtParamElem { SLtParamElemType type; - + union { SLtParameterOption paramOpt; @@ -282,15 +282,15 @@ SLiParamGroup_New( void) { SLtParamElem* newParamGroup; - + if(SLgDatabase_NumParamElems > SLcDatabase_MaxParamElems) return NULL; - + newParamGroup = SLgDatabase_TempParamElems + SLgDatabase_NumParamElems++; - + UUrMemory_Clear(newParamGroup, sizeof(*newParamGroup)); - + newParamGroup->type = SLcParamElemType_Group; - + return newParamGroup; } @@ -299,15 +299,15 @@ SLiParamFormal_New( void) { SLtParamElem* newParamGroup; - + if(SLgDatabase_NumParamElems > SLcDatabase_MaxParamElems) return NULL; - + newParamGroup = SLgDatabase_TempParamElems + SLgDatabase_NumParamElems++; - + UUrMemory_Clear(newParamGroup, sizeof(*newParamGroup)); - + newParamGroup->type = SLcParamElemType_Formal; - + return newParamGroup; } @@ -323,47 +323,47 @@ SLiParameterSpec_BuildFormal( newFormal = SLiParamFormal_New(); UUmError_ReturnOnNull(newFormal); - + *outFormal = newFormal; - + newFormal->u.paramOpt.formalParam.name = curToken->lexem; - + curToken++; - + if(curToken->token != SLcToken_Colon) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Ilegal param spec, colon expected"); } curToken++; - + error = SLrParse_TokenToType((SLtToken_Code)curToken->token, &newFormal->u.paramOpt.formalParam.type); UUmError_ReturnOnErrorMsg(error, "Illegal type spec"); - + curToken++; - + if(curToken->token == SLcToken_LeftCurley) { // parse legal value curToken++; - + while(1) { // parse value - error = + error = SLrParse_ConstTokenToTypeAndVal( curToken, &type, &newFormal->u.paramOpt.legalValue[newFormal->u.paramOpt.numLegalValues]); UUmError_ReturnOnErrorMsg(error, "Illegal type"); newFormal->u.paramOpt.numLegalValues++; - + if(type != newFormal->u.paramOpt.formalParam.type) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Illegal type"); } - + curToken++; - + if (curToken->token == SLcToken_RightCurley) break; @@ -391,9 +391,9 @@ SLiParameterSpec_BuildFormal( { newFormal->u.paramOpt.repeats = UUcFalse; } - + *ioCurToken = curToken; - + return UUcError_None; } @@ -406,7 +406,7 @@ SLiParameterSpec_BuildGroup_Recursive( SLtToken* curToken = *ioCurToken; SLtParamElem* newGroup; SLtParamElem* leftElem; - + if(curToken->token == SLcToken_RightBracket) { *outGroup = NULL; @@ -419,7 +419,7 @@ SLiParameterSpec_BuildGroup_Recursive( curToken++; error = SLiParameterSpec_BuildGroup_Recursive(&curToken, &leftElem); UUmError_ReturnOnError(error); - + if(curToken->token != SLcToken_RightBracket) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "expecting a ]"); @@ -431,18 +431,18 @@ SLiParameterSpec_BuildGroup_Recursive( error = SLiParameterSpec_BuildFormal(&curToken, &leftElem); UUmError_ReturnOnError(error); } - + if(curToken->token == SLcToken_EOF || curToken->token == SLcToken_RightBracket) { *outGroup = leftElem; goto done; } - + newGroup = SLiParamGroup_New(); UUmError_ReturnOnNull(newGroup); - + *outGroup = newGroup; - + if(curToken->token == SLcToken_Bar) { curToken++; @@ -452,9 +452,9 @@ SLiParameterSpec_BuildGroup_Recursive( { newGroup->u.group.type = SLcGroupType_And; } - + newGroup->u.group.a = leftElem; - + #if 0 if(curToken->token == SLcToken_EOF || curToken->token == SLcToken_RightBracket) { @@ -462,14 +462,14 @@ SLiParameterSpec_BuildGroup_Recursive( goto done; } #endif - + error = SLiParameterSpec_BuildGroup_Recursive(&curToken, &newGroup->u.group.b); UUmError_ReturnOnError(error); - + done: *ioCurToken = curToken; - + return UUcError_None; } @@ -492,16 +492,16 @@ SLiParameterSpec_Options_Build( UUtUns16 itrLeft; UUtUns16 itrRight; UUtUns16 curListIndex; - + //UUrMemory_Clear(leftLists, SLcScript_MaxNumParamLists * sizeof(*leftLists)); //UUrMemory_Clear(rightLists, SLcScript_MaxNumParamLists * sizeof(*rightLists)); - + if(inParamElem == NULL) { *outNumParamLists = 0; return UUcError_None; } - + if(inParamElem->type == SLcParamElemType_Formal) { *outNumParamLists = 1; @@ -518,7 +518,7 @@ SLiParameterSpec_Options_Build( &numLeftLists, leftLists); UUmError_ReturnOnError(error); - + // build right list error = SLiParameterSpec_Options_Build( @@ -526,7 +526,7 @@ SLiParameterSpec_Options_Build( &numRightLists, rightLists); UUmError_ReturnOnError(error); - + if(inParamElem->u.group.type == SLcGroupType_Or) { // concate the left and right sides @@ -553,21 +553,21 @@ SLiParameterSpec_Options_Build( else if(inParamElem->u.group.type == SLcGroupType_And) { UUmAssert(numLeftLists > 0 && numRightLists > 0); - + // for each left list add all the right lists *outNumParamLists = numLeftLists * numRightLists; if(*outNumParamLists >= SLcScript_MaxNumParamLists) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "too many possible opts"); } - + curListIndex = 0; for(itrLeft = 0; itrLeft < numLeftLists; itrLeft++) { for(itrRight = 0; itrRight < numRightLists; itrRight++) { outParamLists[curListIndex].numParams = leftLists[itrLeft].numParams + rightLists[itrRight].numParams; - + if(leftLists[itrLeft].hasRepeating || rightLists[itrRight].hasRepeating) { outParamLists[curListIndex].hasRepeating = UUcTrue; @@ -576,17 +576,17 @@ SLiParameterSpec_Options_Build( { outParamLists[curListIndex].hasRepeating = UUcFalse; } - + UUrMemory_MoveFast( leftLists[itrLeft].params, outParamLists[curListIndex].params, leftLists[itrLeft].numParams * sizeof(SLtParameterOption)); - + UUrMemory_MoveFast( rightLists[itrRight].params, outParamLists[curListIndex].params + leftLists[itrLeft].numParams, rightLists[itrRight].numParams * sizeof(SLtParameterOption)); - + curListIndex++; } } @@ -600,7 +600,7 @@ SLiParameterSpec_Options_Build( { UUmAssert(0); } - + return UUcError_None; } @@ -614,10 +614,10 @@ SLiParameterSpec_Build( SLtToken* tokens; UUtUns16 numTokens; SLtParamElem* paramGroup; - + SLgDatabase_NumParamElems = 0; SLgDatabase_NumListOptions = 0; - + error = SLrScript_TextToToken( SLgPermStringMemory, @@ -626,18 +626,18 @@ SLiParameterSpec_Build( &numTokens, &tokens); UUmError_ReturnOnError(error); - - error = + + error = SLiParameterSpec_BuildGroup_Recursive( &tokens, ¶mGroup); UUmError_ReturnOnError(error); - + SLiParameterSpec_Options_Build( paramGroup, outNumParamListOptions, outParamListOptions); - + return UUcError_None; } @@ -652,18 +652,18 @@ SLrScript_Database_FunctionEngine_Add( UUtError error; SLtSymbol* newSymbol; SLtErrorContext errorContext; - + errorContext.funcName = inName; errorContext.fileName = "(engine)"; errorContext.line = 0; - + newSymbol = SLiSymbol_New_AddToScope(NULL, inName, &errorContext, SLcSymbolKind_Func_Command); if(newSymbol == NULL) return UUcError_Generic; // don't let semantic errors cause asserts newSymbol->u.funcCommand.command = inCommand; newSymbol->u.funcCommand.desc = inDesc; newSymbol->u.funcCommand.paramSpec = inParameterSpecification; - + if(inParameterSpecification != NULL) { if(inParameterSpecification[0] == 0) @@ -673,7 +673,7 @@ SLrScript_Database_FunctionEngine_Add( } else { - error = + error = SLiParameterSpec_Build( inParameterSpecification, &newSymbol->u.funcCommand.numParamListOptions, @@ -685,7 +685,7 @@ SLrScript_Database_FunctionEngine_Add( { newSymbol->u.funcCommand.numParamListOptions = 0; } - + return UUcError_None; } @@ -698,13 +698,13 @@ SLrScript_Database_Var_Add( SLtValue inValue) { SLtSymbol* newSymbol; - + newSymbol = SLiSymbol_New_AddToScope(inContext, inName, inErrorContext, SLcSymbolKind_Var); if(newSymbol == NULL) return UUcError_None; // don't let semantic errors cause asserts - + newSymbol->u.var.type = inType; newSymbol->u.var.val = inValue; - + return UUcError_None; } @@ -719,15 +719,15 @@ SLrScript_Database_Var_Engine_Add( SLtNotificationProc inNotificationProc) { SLtSymbol* newSymbol; - + newSymbol = SLiSymbol_New_AddToScope(NULL, inName, inErrorContext, SLcSymbolKind_VarAddr); if(newSymbol == NULL) return UUcError_None; // don't let semantic errors cause asserts - + newSymbol->u.varAddr.type = inType; newSymbol->u.varAddr.valAddr = inValueAddr; newSymbol->u.varAddr.readWrite = inReadWrite; newSymbol->u.varAddr.noticeProc = inNotificationProc; - + return UUcError_None; } @@ -742,23 +742,23 @@ SLrScript_Database_Var_GetValue( UUtError error; SLtSymbol* symbol; SLtValue returnVal; - + returnVal.i = 0; - + error = SLrScript_Database_Symbol_Get(inContext, inName, &symbol); - + if(error != UUcError_None) { SLrScript_Error_Semantic(inErrorContext, "could not find variable name \"%s\"", inName); return error; } - + if(symbol->kind != SLcSymbolKind_Var && symbol->kind != SLcSymbolKind_VarAddr) { SLrScript_Error_Semantic(inErrorContext, "symbol \"%s\" is not a variable (function most likely)", inName); return UUcError_Generic; } - + if(symbol->kind == SLcSymbolKind_Var) { *outType = symbol->u.var.type; @@ -767,7 +767,7 @@ SLrScript_Database_Var_GetValue( else { *outType = symbol->u.varAddr.type; - + switch(symbol->u.varAddr.type) { case SLcType_Int32: @@ -786,12 +786,12 @@ SLrScript_Database_Var_GetValue( UUmAssertReadPtr(symbol->u.varAddr.valAddr, sizeof(char)); outvalue->str = (char*)symbol->u.varAddr.valAddr; break; - + default: UUmAssert(0); } } - + return UUcError_None; } @@ -804,21 +804,21 @@ SLrScript_Database_Var_SetValue( { UUtError error; SLtSymbol* symbol; - + error = SLrScript_Database_Symbol_Get(inContext, inName, &symbol); - + if(error != UUcError_None) { SLrScript_Error_Semantic(inErrorContext, "could not find variable name \"%s\"", inName); return error; } - + if(symbol->kind != SLcSymbolKind_Var && symbol->kind != SLcSymbolKind_VarAddr) { SLrScript_Error_Semantic(inErrorContext, "symbol \"%s\" is not a variable", inName); return UUcError_Generic; } - + if(symbol->kind == SLcSymbolKind_Var) { symbol->u.var.val = inValue; @@ -830,7 +830,7 @@ SLrScript_Database_Var_SetValue( SLrScript_Error_Semantic(inErrorContext, "symbol \"%s\" is read only", inName); return UUcError_Generic; } - + switch(symbol->u.varAddr.type) { case SLcType_Int32: @@ -848,11 +848,11 @@ SLrScript_Database_Var_SetValue( case SLcType_String: UUrString_Copy(symbol->u.varAddr.valAddr, inValue.str, SLcScript_String_MaxLength); break; - + default: UUmAssert(0); } - + if(symbol->u.varAddr.noticeProc != NULL) { symbol->u.varAddr.noticeProc(); @@ -871,18 +871,18 @@ SLrScript_Database_Iterator_Add( { SLtSymbol* newSymbol; SLtErrorContext errorContext; - + errorContext.funcName = inIteratorName; errorContext.fileName = "(engine)"; errorContext.line = 0; - + newSymbol = SLiSymbol_New_AddToScope(NULL, inIteratorName, &errorContext, SLcSymbolKind_Iterator); if(newSymbol == NULL) return UUcError_None; // don't let semantic errors cause asserts - + newSymbol->u.iterator.type = inVariableType; newSymbol->u.iterator.getFirst = inGetFirstFunc; newSymbol->u.iterator.getNext = inGetNextFunc; - + return UUcError_None; } @@ -899,22 +899,22 @@ SLrScript_Database_Scope_Leave( { SLtSymbol* curSymbol; SLtSymbol* nextSymbol; - + UUmAssert(inContext->curFuncState->scopeLevel > 0); - + curSymbol = inContext->curFuncState->symbolList[inContext->curFuncState->scopeLevel]; - + while(curSymbol) { nextSymbol = curSymbol->next; SLiSymbol_Delete(inContext, curSymbol); - + curSymbol = nextSymbol; - } - + } + inContext->curFuncState->symbolList[inContext->curFuncState->scopeLevel] = NULL; - + inContext->curFuncState->scopeLevel--; } @@ -926,7 +926,7 @@ SLrScript_Database_Symbol_Get( { SLtSymbol* curSymbol; UUtInt16 curLevel; - + *outSymbol = NULL; if (inName == NULL) { return UUcError_Generic; @@ -946,7 +946,7 @@ SLrScript_Database_Symbol_Get( } } } - + for(curSymbol = SLgGlobalSymbolList; curSymbol; curSymbol = curSymbol->next) { if(!strcmp(curSymbol->name, inName)) @@ -955,7 +955,7 @@ SLrScript_Database_Symbol_Get( return UUcError_None; } } - + for(curSymbol = SLgPermanentSymbolList; curSymbol; curSymbol = curSymbol->next) { if(!strcmp(curSymbol->name, inName)) @@ -964,7 +964,7 @@ SLrScript_Database_Symbol_Get( return UUcError_None; } } - + return UUcError_Generic; } @@ -1009,7 +1009,7 @@ SLiParameterCast( if (ioParameter->type == inFormalType) { return SLcParameter_Match; } - + switch(inFormalType) { case SLcType_Int32: if (ioParameter->type == SLcType_Bool) { @@ -1111,7 +1111,7 @@ SLrScript_ParameterCheckAndPromote( return UUcError_Generic; } } - + // we must have expanded or contracted the parameter list by the right amount by now, set its length *ioGivenParams_Num = inScript->numParams; return UUcError_None; @@ -1150,7 +1150,7 @@ SLrCommand_ParameterCheckAndPromote( // assess the current candidate parameter list current_fail = UUcFalse; current_discarded = current_added = current_promoted = 0; - + for(itrFormal = 0, curParamOpt = curParamList->params, itrGiven = 0; itrFormal < curParamList->numParams; itrFormal++, curParamOpt++) { matched_parameter = UUcFalse; do { @@ -1199,7 +1199,7 @@ SLrCommand_ParameterCheckAndPromote( itrGiven++; } while (curParamOpt->repeats); - + if (!matched_parameter) { // couldn't find anything to match this parameter, fail the current parameter list current_fail = UUcTrue; @@ -1248,7 +1248,7 @@ SLrCommand_ParameterCheckAndPromote( UUrMemory_MoveFast(current_parameters, final_parameters, *ioGivenParams_Num * sizeof(SLtParameter_Actual)); } } - + if (choiceParamList == NULL) { // the given set of parameters didn't match any of the formal parameter lists SLrScript_Error_Semantic(inErrorContext, "\"%s\": parameter list does not match: %s", inCommandName, inCommand->paramSpec); @@ -1287,34 +1287,34 @@ SLrScript_Database_ConsoleCompletionList_Get( UUtUns32* sortedIndexList; AUtSharedString* list; UUtUns32 itr; - + sortedStringArray = AUrSharedStringArray_New(); - + for(curSymbol = SLgPermanentSymbolList; curSymbol; curSymbol = curSymbol->next) { UUmAssert(NULL != curSymbol->name); error = AUrSharedStringArray_AddString( - sortedStringArray, + sortedStringArray, curSymbol->name, (UUtInt32)curSymbol, NULL); UUmAssert(UUcError_None == error); } - + for(curSymbol = SLgGlobalSymbolList; curSymbol; curSymbol = curSymbol->next) { UUmAssert(NULL != curSymbol->name); error = AUrSharedStringArray_AddString( - sortedStringArray, + sortedStringArray, curSymbol->name, (UUtInt32)curSymbol, NULL); UUmAssert(UUcError_None == error); } - + numEntries = AUrSharedStringArray_GetNum(sortedStringArray); sortedIndexList = AUrSharedStringArray_GetSortedIndexList(sortedStringArray); list = AUrSharedStringArray_GetList(sortedStringArray); @@ -1323,9 +1323,9 @@ SLrScript_Database_ConsoleCompletionList_Get( COrConsole_Printf("exceeded scripting command completion limit of %d", SLcCompletionList_MaxLength); numEntries = SLcCompletionList_MaxLength; } - + SLgCompletionList_Length = numEntries; - + for(itr = 0; itr < numEntries; itr++) { const char *completion_list_string = ((SLtSymbol*)list[sortedIndexList[itr]].data)->name; @@ -1334,15 +1334,15 @@ SLrScript_Database_ConsoleCompletionList_Get( SLgCompletionList[itr] = completion_list_string; } - + AUrSharedStringArray_Delete(sortedStringArray); - + SLgPermanentSymbolList_Dirty = UUcFalse; } - + *outNumNames = SLgCompletionList_Length; *outList = (char **)SLgCompletionList; - + return; } @@ -1357,9 +1357,9 @@ SLrDatabase_Command_DumpAll( { SLtSymbol* curSymbol; FILE* file; - + file = fopen("script_commands.txt", "w"); - + for(curSymbol = SLgPermanentSymbolList; curSymbol; curSymbol = curSymbol->next) { fprintf(file, "============================================\n"); @@ -1367,27 +1367,27 @@ SLrDatabase_Command_DumpAll( { case SLcSymbolKind_Var: break; - + case SLcSymbolKind_VarAddr: fprintf(file, "var: %s\n", curSymbol->name); break; - + case SLcSymbolKind_Func_Script: break; - + case SLcSymbolKind_Func_Command: fprintf(file, "command: %s\n", curSymbol->name); fprintf(file, "desc: %s\n", curSymbol->u.funcCommand.desc); fprintf(file, "param: %s\n", curSymbol->u.funcCommand.paramSpec); break; - + case SLcSymbolKind_Iterator: break; } } - + fclose(file); - + return UUcError_None; } @@ -1397,17 +1397,17 @@ SLrDatabase_IsFunctionCall( { UUtError error; SLtSymbol* symbol; - - error = + + error = SLrScript_Database_Symbol_Get( NULL, inName, &symbol); if(error != UUcError_None) return UUcFalse; - - if(symbol->kind == SLcSymbolKind_Func_Script || + + if(symbol->kind == SLcSymbolKind_Func_Script || symbol->kind == SLcSymbolKind_Func_Command) return UUcTrue; - + return UUcFalse; } diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Database.h b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Database.h index c9adb96..083ab91 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Database.h +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Database.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_ScriptLang_Database.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Error.c b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Error.c index 322a29e..c0b2e90 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Error.c +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Error.c @@ -1,12 +1,12 @@ /* FILE: BFW_ScriptLang_Error.c - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -68,17 +68,17 @@ SLrScript_ReportError( char buffer2[2048]; va_list arglist; int return_value; - + va_start(arglist, inMsg); return_value= vsprintf(buffer, inMsg, arglist); va_end(arglist); - + sprintf(buffer2, "Func \"%s\", File \"%s\", Line %d: %s", inErrorContext->funcName, inErrorContext->fileName, inErrorContext->line, buffer); - + SLrScript_DisplayError("%s", buffer2); return; @@ -95,13 +95,13 @@ SLrScript_Error_Parse( char buffer2[2048]; va_list arglist; int return_value; - + va_start(arglist, inMsg); return_value= vsprintf(buffer, inMsg, arglist); va_end(arglist); - + sprintf(buffer2, "parse error, token \"%s\", msg: %s", inToken->lexem, buffer); - + SLrScript_ReportError(inErrorContext, buffer2); } @@ -116,13 +116,13 @@ SLrScript_Error_Lexical( char buffer2[2048]; va_list arglist; int return_value; - + va_start(arglist, inMsg); return_value= vsprintf(buffer, inMsg, arglist); va_end(arglist); - + sprintf(buffer2, "lexical error, \'%c\', msg : %s", inChar, inMsg); - + SLrScript_ReportError(inErrorContext, buffer2); } @@ -133,13 +133,13 @@ SLrScript_Error_Parse_IllegalToken( SLtToken_Code inTokenCode) { char buffer[2048]; - + sprintf( buffer, "Illegal token, got \"%s\" expected \"%s\"", inToken->lexem, SLrTokenCode_ConvertToString(inTokenCode)); - + SLrScript_ReportError(inErrorContext, buffer); } @@ -152,24 +152,24 @@ SLrScript_Error_Semantic( char buffer[2048]; char buffer2[2048]; va_list arglist; - + va_start(arglist, inMsg); vsprintf(buffer, inMsg, arglist); va_end(arglist); - + sprintf(buffer2, "semantic error, %s", buffer); - + SLrScript_ReportError(inErrorContext, buffer2); } - - + + void SLrDebugMessage_LogParamList( UUtUns16 inParameterListLength, SLtParameter_Actual* inParameterList) { UUtUns16 itr; - + for(itr = 0; itr < inParameterListLength; itr++) { switch(inParameterList[itr].type) @@ -177,19 +177,19 @@ SLrDebugMessage_LogParamList( case SLcType_Int32: BFrDebugFile_Printf(SLgDebugFile, "int: %d", inParameterList[itr].val.i); break; - + case SLcType_String: BFrDebugFile_Printf(SLgDebugFile, "string: %s", inParameterList[itr].val.str); break; - + case SLcType_Float: BFrDebugFile_Printf(SLgDebugFile, "float: %f", inParameterList[itr].val.f); break; - + case SLcType_Bool: BFrDebugFile_Printf(SLgDebugFile, "bool: %d", inParameterList[itr].val.b); break; - + default: UUmAssert(0); } diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Error.h b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Error.h index 94771c9..ad1abc9 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Error.h +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Error.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_ScriptLang_Error.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -44,12 +44,12 @@ void UUcArglist_Call SLrDebugMessage_Log( char* inMsg, ...); - + void SLrDebugMessage_LogParamList( UUtUns16 inParameterListLength, SLtParameter_Actual* inParameterList); - + #endif diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Eval.c b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Eval.c index 0d2ec7d..114246e 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Eval.c +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Eval.c @@ -1,12 +1,12 @@ /* FILE: BFW_ScriptLang_Eval.c - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -28,7 +28,7 @@ SLtExpr* SLrExpr_Pop(SLtContext *inContext) { SLtExpr *result; UUmAssert(inContext->curFuncState->exprTOS > 0); - + if (inContext->curFuncState->exprTOS > 0) { inContext->curFuncState->exprTOS--; @@ -38,7 +38,7 @@ SLtExpr* SLrExpr_Pop(SLtContext *inContext) COrConsole_Printf("failed to pop expression stack"); result = NULL; } - + return result; } @@ -47,7 +47,7 @@ SLrExpr_PopRemove( SLtContext* inContext) { if(inContext->curFuncState->exprTOS == 0) return; - + inContext->curFuncState->exprTOS--; } @@ -77,8 +77,8 @@ static void SLrExpr_MakeRoom(SLtContext *inContext) { if (SLcContext_ExprStack_MaxDepth == inContext->curFuncState->exprTOS) { UUrMemory_MoveOverlap( - inContext->curFuncState->exprStack + 1, - inContext->curFuncState->exprStack + 0, + inContext->curFuncState->exprStack + 1, + inContext->curFuncState->exprStack + 0, sizeof(SLtExpr) * (SLcContext_ExprStack_MaxDepth - 1)); inContext->curFuncState->exprTOS--; @@ -97,11 +97,11 @@ SLrExpr_Push_Const( UUmAssert(inContext->curFuncState->exprTOS < SLcContext_ExprStack_MaxDepth); - + inContext->curFuncState->exprStack[inContext->curFuncState->exprTOS].kind = SLcExprKind_Constant; inContext->curFuncState->exprStack[inContext->curFuncState->exprTOS].type = inType; inContext->curFuncState->exprStack[inContext->curFuncState->exprTOS].u.constant.val = inVal; - + inContext->curFuncState->exprTOS++; } @@ -117,7 +117,7 @@ SLrExpr_Push_Ident( inContext->curFuncState->exprStack[inContext->curFuncState->exprTOS].kind = SLcExprKind_Identifier; inContext->curFuncState->exprStack[inContext->curFuncState->exprTOS].type = (SLtType)-1; inContext->curFuncState->exprStack[inContext->curFuncState->exprTOS].u.ident.name = inName; - + inContext->curFuncState->exprTOS++; } @@ -131,7 +131,7 @@ SLrExpr_Eval( { UUtError error; SLtSymbol* symbol; - + if (inExpr == NULL) { return UUcError_Generic; } @@ -142,9 +142,9 @@ SLrExpr_Eval( *outType = inExpr->type; *outVal = inExpr->u.constant.val; break; - + case SLcExprKind_Identifier: - error = + error = SLrScript_Database_Symbol_Get( inContext, inExpr->u.ident.name, @@ -156,7 +156,7 @@ SLrExpr_Eval( } else { - error = + error = SLrScript_Database_Var_GetValue( inErrorContext, inContext, @@ -166,11 +166,11 @@ SLrExpr_Eval( if(error != UUcError_None) return error; } break; - + default: UUmAssert(0); } - + return UUcError_None; } @@ -179,7 +179,7 @@ SLrStatement_Evaluate( SLtContext* inContext) { UUmAssert(inContext->curFuncState->statementLevel > 0); - + return inContext->curFuncState->statementEval[inContext->curFuncState->statementLevel - 1]; } @@ -189,7 +189,7 @@ SLrStatement_Level_Push( UUtBool inEval) { if(inContext->curFuncState->statementLevel > 0 && SLrStatement_Evaluate(inContext)) inContext->curFuncState->statement_TargetLevel = inContext->curFuncState->statementLevel + 1; - + inContext->curFuncState->statementEval[inContext->curFuncState->statementLevel++] = inEval; } @@ -198,7 +198,7 @@ SLrStatement_Level_Pop( SLtContext* inContext) { UUmAssert(inContext->curFuncState->statementLevel > 0); - + inContext->curFuncState->statementLevel--; } @@ -221,21 +221,21 @@ SLrExpr_GetResult( { UUtError error; SLtExpr* expr; - + if(inContext->curFuncState->exprTOS == 0) return UUcFalse; - + expr = SLrExpr_Pop(inContext); if (NULL == expr) { return UUcFalse; } - + error = SLrExpr_Eval(inContext, inErrorContext, expr, outType, outVal); if(error != UUcError_None) { return UUcFalse; } - + return UUcTrue; } @@ -250,15 +250,15 @@ SLrExprListToParamList( SLtType type; SLtValue val; SLtContext_FuncState* curFuncState; - + curFuncState = inContext->curFuncState; - + // CB: this is done so that we don't trash over statically allocated fixed-length buffers curFuncState->numParams = UUmMin(curFuncState->numParams, SLcScript_MaxNumParams); for(itr = 0; itr < curFuncState->numParams; itr++) { - error = + error = SLrExpr_Eval( inContext, inErrorContext, @@ -266,11 +266,11 @@ SLrExprListToParamList( &type, &val); if(error != UUcError_None) return error; - + outParamList[itr].type = type; outParamList[itr].val = val; } - + return UUcError_None; } @@ -285,21 +285,21 @@ SLrExpr_CompareValues_Eq( case SLcType_Int32: return inValA.i == inValB.i ? UUcTrue : UUcFalse; break; - + case SLcType_Float: return inValA.f == inValB.f ? UUcTrue : UUcFalse; break; - + case SLcType_String: return !strcmp(inValA.str, inValB.str) ? UUcTrue : UUcFalse; break; - + case SLcType_Bool: return inValA.b == inValB.b ? UUcTrue : UUcFalse; break; - + } - + UUmAssert(0); return UUcFalse; } @@ -317,8 +317,8 @@ SLrExpr_ValAndType_To_Int( { return inVal.b; } - + UUmAssert(0); - + return 0; } diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Eval.h b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Eval.h index 15b73ff..5fd551e 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Eval.h +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Eval.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_ScriptLang_Eval.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -56,7 +56,7 @@ void SLrStatement_Level_Push( SLtContext* inContext, UUtBool inEval); - + void SLrStatement_Level_Pop( SLtContext* inContext); @@ -64,7 +64,7 @@ SLrStatement_Level_Pop( void SLrStatement_Level_Invert( SLtContext* inContext); - + UUtError SLrExprListToParamList( SLtContext* inContext, @@ -91,6 +91,6 @@ UUtInt32 SLrExpr_ValAndType_To_Int( SLtType inType, SLtValue inVal); - + #endif /* BFW_SCRIPTLANG_EVAL */ diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Expr.c b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Expr.c index a707ddd..f985155 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Expr.c +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Expr.c @@ -1,12 +1,12 @@ /* FILE: BFW_ScriptLang_Expr.c - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -25,16 +25,16 @@ SLiExpr_OpStack_Pop( SLtContext* inContext) { SLtExpr_OpStack* opStack; - + UUmAssertReadPtr(inContext->curFuncState->curParenStack, sizeof(SLtExpr_OpStack)); - + opStack = inContext->curFuncState->curParenStack; - + if(opStack->tos > 0) { return opStack->stack[--opStack->tos]; } - + return NULL; } @@ -45,19 +45,19 @@ SLiExpr_OpStack_Push( SLtToken* inToken) { SLtExpr_OpStack* opStack; - + UUmAssertReadPtr(inContext->curFuncState->curParenStack, sizeof(SLtExpr_OpStack)); - + opStack = inContext->curFuncState->curParenStack; - + if(opStack->tos >= SLcExprOpStack_MaxDepth) { SLrScript_Error_Semantic(inErrorContext, "expression too complex"); return UUcError_Generic; } - + opStack->stack[opStack->tos++] = inToken; - + return UUcError_None; } @@ -66,16 +66,16 @@ SLiExpr_OpStack_TOS( SLtContext* inContext) { SLtExpr_OpStack* opStack; - + UUmAssertReadPtr(inContext->curFuncState->curParenStack, sizeof(SLtExpr_OpStack)); - + opStack = inContext->curFuncState->curParenStack; - + if(opStack->tos > 0) { return opStack->stack[opStack->tos - 1]; } - + return NULL; } @@ -84,7 +84,7 @@ SLiExpr_UnaryOp_TypeCheck( SLtToken* inToken, SLtType inType) { - + return UUcError_None; } @@ -94,7 +94,7 @@ SLiExpr_BinaryOp_TypeCheck( SLtType inLeftType, SLtType inRightType) { - + return UUcError_None; } @@ -121,18 +121,18 @@ SLiExpr_Evaluate( rightSide = SLrExpr_Pop(inContext); leftSide = SLrExpr_Pop(inContext); - + inErrorContext->line = inToken->line; error = SLrExpr_Eval(inContext, inErrorContext, rightSide, &rightType, &rightVal); if(error != UUcError_None) return error; - + inErrorContext->line = inToken->line; error = SLrExpr_Eval(inContext, inErrorContext, leftSide, &leftType, &leftVal); if(error != UUcError_None) return error; - + error = SLiExpr_BinaryOp_TypeCheck(inToken, leftType, rightType); if(error != UUcError_None) return error; - + switch(inToken->token) { case SLcToken_Assign: @@ -141,21 +141,21 @@ SLiExpr_Evaluate( SLrScript_Error_Semantic(inErrorContext, "The left side of an assignment must be an identifier"); return UUcError_Generic; } - + SLrExpr_ConvertValue(inErrorContext, rightType, leftType, &rightVal); - - error = + + error = SLrScript_Database_Var_SetValue( inErrorContext, inContext, leftSide->u.ident.name, rightVal); if(error != UUcError_None) return error; - + resultType = rightType; resultVal = rightVal; break; - + case SLcToken_Plus: resultType = leftType; if(leftType == SLcType_Int32) @@ -167,7 +167,7 @@ SLiExpr_Evaluate( resultVal.f = leftVal.f + rightVal.f; } break; - + case SLcToken_Minus: resultType = leftType; if(leftType == SLcType_Int32) @@ -179,21 +179,21 @@ SLiExpr_Evaluate( resultVal.f = leftVal.f - rightVal.f; } break; - + case SLcToken_LogicalAnd: resultType = SLcType_Bool; leftInt = SLrExpr_ValAndType_To_Int(leftType, leftVal); rightInt = SLrExpr_ValAndType_To_Int(rightType, rightVal); resultVal.b = leftInt && rightInt; break; - + case SLcToken_LogicalOr: resultType = SLcType_Bool; leftInt = SLrExpr_ValAndType_To_Int(leftType, leftVal); rightInt = SLrExpr_ValAndType_To_Int(rightType, rightVal); resultVal.b = leftInt || rightInt; break; - + case SLcToken_Cmp_EQ: resultType = SLcType_Int32; if(leftType == SLcType_Int32 || leftType == SLcType_Bool) @@ -205,7 +205,7 @@ SLiExpr_Evaluate( resultVal.i = leftVal.f == rightVal.f; } break; - + case SLcToken_Cmp_NE: resultType = SLcType_Int32; if(leftType == SLcType_Int32 || leftType == SLcType_Bool) @@ -217,7 +217,7 @@ SLiExpr_Evaluate( resultVal.i = leftVal.f != rightVal.f; } break; - + case SLcToken_Cmp_LT: resultType = SLcType_Int32; if(leftType == SLcType_Int32 || leftType == SLcType_Bool) @@ -229,7 +229,7 @@ SLiExpr_Evaluate( resultVal.i = leftVal.f < rightVal.f; } break; - + case SLcToken_Cmp_GT: resultType = SLcType_Int32; if(leftType == SLcType_Int32 || leftType == SLcType_Bool) @@ -241,7 +241,7 @@ SLiExpr_Evaluate( resultVal.i = leftVal.f > rightVal.f; } break; - + case SLcToken_Cmp_LE: resultType = SLcType_Int32; if(leftType == SLcType_Int32 || leftType == SLcType_Bool) @@ -253,7 +253,7 @@ SLiExpr_Evaluate( resultVal.i = leftVal.f <= rightVal.f; } break; - + case SLcToken_Cmp_GE: resultType = SLcType_Int32; if(leftType == SLcType_Int32 || leftType == SLcType_Bool) @@ -265,7 +265,7 @@ SLiExpr_Evaluate( resultVal.i = leftVal.f >= rightVal.f; } break; - + default: UUmAssert(0); } @@ -275,16 +275,16 @@ SLiExpr_Evaluate( SLtExpr* expr; SLtType exprType; SLtValue exprVal; - + expr = SLrExpr_Pop(inContext); - + inErrorContext->line = inToken->line; error = SLrExpr_Eval(inContext, inErrorContext, expr, &exprType, &exprVal); if(error != UUcError_None) return error; - + error = SLiExpr_UnaryOp_TypeCheck(inToken, exprType); if(error != UUcError_None) return error; - + switch(inToken->token) { case SLcToken_LogicalNot: @@ -297,12 +297,12 @@ SLiExpr_Evaluate( case SLcType_Bool: resultVal.b = !exprVal.b; break; - + default: UUmAssert(0); } break; - + default: UUmAssert(0); } @@ -313,11 +313,11 @@ SLiExpr_Evaluate( } SLrExpr_Push_Const(inContext, resultType, resultVal); - + return UUcError_None; } -UUtUns8 SLgExpr_PrecedenceTable[SLcToken_NumOperators] = +UUtUns8 SLgExpr_PrecedenceTable[SLcToken_NumOperators] = { /* = */ 0, /* + */ 20, @@ -347,22 +347,22 @@ SLrExpr_Parse_LeftParen( SLtErrorContext* inErrorContext) { SLtContext_FuncState* curFuncState; - + curFuncState = inContext->curFuncState; - + if(curFuncState->parenTOS >= SLcContext_ParenStack_MaxDepth) { SLrScript_Error_Semantic(inErrorContext, "expression too complex"); return UUcError_Generic; } - + curFuncState->curParenStack = curFuncState->parenStack + curFuncState->parenTOS; - + curFuncState->parenTOS++; - + return UUcError_None; } - + UUtError SLrExpr_Parse_RightParen( SLtContext* inContext, @@ -370,7 +370,7 @@ SLrExpr_Parse_RightParen( { SLtContext_FuncState* curFuncState; SLtToken* op; - + curFuncState = inContext->curFuncState; if(curFuncState->parenTOS == 0) @@ -378,25 +378,25 @@ SLrExpr_Parse_RightParen( SLrScript_Error_Semantic(inErrorContext, "Too many )'s"); return UUcError_Generic; } - + while(1) { // pop the operator off the operator stack op = SLiExpr_OpStack_Pop(inContext); - + if(op == NULL) break; - + // evaluate the operator and push the result on the stack SLiExpr_Evaluate(inContext, inErrorContext, op); } - + curFuncState->parenTOS--; - + curFuncState->curParenStack = curFuncState->parenStack + curFuncState->parenTOS - 1; - + return UUcError_None; } - + UUtError SLrExpr_Parse_Op_Unary( SLtContext* inContext, @@ -404,23 +404,23 @@ SLrExpr_Parse_Op_Unary( SLtToken* inToken) { UUtError error; - + error = SLiExpr_OpStack_Push(inContext, inErrorContext, inToken); if(error != UUcError_None) return error; - + return UUcError_None; } - + UUtError SLrExpr_Parse_Identifier( SLtContext* inContext, SLtToken* inToken) { SLrExpr_Push_Ident(inContext, inToken->lexem); - + return UUcError_None; } - + UUtError SLrExpr_Parse_Op_Constant( SLtContext* inContext, @@ -429,12 +429,12 @@ SLrExpr_Parse_Op_Constant( UUtError error; SLtType type; SLtValue val; - + error = SLrParse_ConstTokenToTypeAndVal(inToken, &type, &val); if(error != UUcError_None) return error; - + SLrExpr_Push_Const(inContext, type, val); - + return UUcError_None; } @@ -446,21 +446,21 @@ SLrExpr_Parse_Op_Binary( { UUtError error; SLtToken* op; - + // check to see if there is a higher precedence operator on the stack op = SLiExpr_OpStack_TOS(inContext); - + // if so evaluate it if(op != NULL && SLiExpr_Op_Higher(op, inToken)) { SLiExpr_OpStack_Pop(inContext); SLiExpr_Evaluate(inContext, inErrorContext, op); } - + // push this operator on the stack error = SLiExpr_OpStack_Push(inContext, inErrorContext, inToken); if(error != UUcError_None) return error; - + return UUcError_None; } @@ -469,7 +469,7 @@ SLrExpr_Parse_Final( SLtContext* inContext, SLtErrorContext* inErrorContext) { - + return UUcError_None; } @@ -479,12 +479,12 @@ SLrExpr_Parse_FunctionCall_Ident( SLtToken* inToken) { SLtContext_FuncState* curFuncState; - + curFuncState = inContext->curFuncState; - + curFuncState->funcIdent = inToken->lexem; curFuncState->numParams = 0; - + return UUcError_None; } @@ -498,11 +498,11 @@ SLrExpr_Parse_Param( curFuncState = inContext->curFuncState; // pop it off the stack - + expr = SLrExpr_Pop(inContext); - + curFuncState->paramExprs[curFuncState->numParams++] = *expr; - + return UUcError_None; } @@ -524,7 +524,7 @@ SLrExpr_Parse_Param_Old( SLrExpr_MakeStringConstant(curFuncState->paramExprs + curFuncState->numParams, inToken->lexem); } curFuncState->numParams++; - + return UUcError_None; } @@ -538,17 +538,17 @@ SLrExpr_Parse_FunctionCall_Make( SLtParameter_Actual paramList[SLcScript_MaxNumParams]; curFuncState = inContext->curFuncState; - + inContext->returnType = SLcType_Void; - error = + error = SLrExprListToParamList( inContext, inErrorContext, paramList); if(error != UUcError_None) return error; - error = + error = SLrParse_FuncStack_Push( inContext, inErrorContext, @@ -556,7 +556,7 @@ SLrExpr_Parse_FunctionCall_Make( paramList, curFuncState->funcIdent); if(error != UUcError_None) return error; - + return UUcError_None; } @@ -568,7 +568,7 @@ SLrExpr_ConvertValue( SLtValue *ioValue) { UUtBool illegalConvertion = UUcFalse; - + switch(inFromType) { case SLcType_Int32: @@ -576,69 +576,69 @@ SLrExpr_ConvertValue( { case SLcType_Int32: break; - + case SLcType_Float: ioValue->f = (float)ioValue->i; break; - + case SLcType_Bool: ioValue->b = (ioValue->i == 0) ? UUcFalse : UUcTrue; break; - + default: illegalConvertion = UUcTrue; } break; - + case SLcType_Float: switch(inToType) { case SLcType_Int32: ioValue->i = (UUtInt32)ioValue->f; break; - + case SLcType_Float: break; - + case SLcType_Bool: ioValue->b = (UUtBool)ioValue->f; break; - + default: illegalConvertion = UUcTrue; } break; - + case SLcType_Bool: switch(inToType) { case SLcType_Int32: ioValue->i = (UUtUns32)ioValue->b; break; - + case SLcType_Float: ioValue->f = (float)ioValue->b; break; - + case SLcType_Bool: break; - + default: illegalConvertion = UUcTrue; } break; - + case SLcType_String: switch(inToType) { case SLcType_String: break; - + default: illegalConvertion = UUcTrue; } break; - + default: illegalConvertion = UUcTrue; } @@ -648,6 +648,6 @@ SLrExpr_ConvertValue( SLrScript_Error_Semantic(inErrorContext, "Illegal type convertion"); return UUcError_Generic; } - - return UUcError_None; + + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Expr.h b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Expr.h index f873d55..0065ed7 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Expr.h +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Expr.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_ScriptLang_Expr.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -18,28 +18,28 @@ UUtError SLrExpr_Parse_LeftParen( SLtContext* inContext, SLtErrorContext* inErrorContext); - + UUtError SLrExpr_Parse_RightParen( SLtContext* inContext, SLtErrorContext* inErrorContext); - + UUtError SLrExpr_Parse_Op_Unary( SLtContext* inContext, SLtErrorContext* inErrorContext, SLtToken* inToken); - + UUtError SLrExpr_Parse_Identifier( SLtContext* inContext, SLtToken* inToken); - + UUtError SLrExpr_Parse_Op_Constant( SLtContext* inContext, SLtToken* inToken); - + UUtError SLrExpr_Parse_Op_Binary( SLtContext* inContext, @@ -49,16 +49,16 @@ SLrExpr_Parse_Op_Binary( UUtError SLrExpr_Parse_Final( SLtContext* inContext, - SLtErrorContext* inErrorContext); + SLtErrorContext* inErrorContext); UUtError SLrExpr_Parse_FunctionCall_Ident( SLtContext* inContext, - SLtToken* inToken); - + SLtToken* inToken); + UUtError SLrExpr_Parse_Param( - SLtContext* inContext); + SLtContext* inContext); UUtError SLrExpr_Parse_Param_Old( @@ -68,7 +68,7 @@ SLrExpr_Parse_Param_Old( UUtError SLrExpr_Parse_FunctionCall_Make( SLtContext* inContext, - SLtErrorContext* inErrorContext); + SLtErrorContext* inErrorContext); UUtError SLrExpr_ConvertValue( @@ -76,6 +76,6 @@ SLrExpr_ConvertValue( SLtType inFromType, SLtType inToType, SLtValue *ioValue); - -#endif /* BFW_SCRIPTLANG_EXPR_H */ \ No newline at end of file + +#endif /* BFW_SCRIPTLANG_EXPR_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Parse.c b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Parse.c index 8a24a79..bc50fb3 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Parse.c +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Parse.c @@ -1,12 +1,12 @@ /* FILE: BFW_ScriptLang_Eval.c - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -78,7 +78,7 @@ static const char *SLiParseStateToString(UUtUns8 inParseState) const char *string; } parse_state_to_string_table; - parse_state_to_string_table table[] = + parse_state_to_string_table table[] = { { SLcParseState_Global, "SLcParseState_Global" }, { SLcParseState_DataDef, "SLcParseState_DataDef" }, @@ -193,9 +193,9 @@ SLiContext_Dump_Info(SLtContext *inContext, SLtToken *curToken) { #if SUPPORT_DEBUG_FILES static BFtDebugFile *stream = NULL; - UUtInt32 itr; + UUtInt32 itr; - if (NULL == stream) { + if (NULL == stream) { stream = BFrDebugFile_Open("hard_core_script_debug.txt"); } @@ -211,7 +211,7 @@ SLiContext_Dump_Info(SLtContext *inContext, SLtToken *curToken) { BFrDebugFile_Printf(stream, "\t%s\n", SLiExprToString(inContext->curFuncState->exprStack + itr)); } - + BFrDebugFile_Printf(stream, "parse stack %d\n", inContext->curFuncState->parseTOS); BFrDebugFile_Printf(stream, "-------------------------\n"); @@ -236,7 +236,7 @@ SLiScript_Parse_Statement( SLtToken* *ioCurToken, SLtParse_Block_Statement* inParseBlock_Statement, SLtParse_Block_Expression* inParseBlock_Expr); - + static UUtError SLiScript_Parse_Statements( SLtToken* *ioCurToken, @@ -258,7 +258,7 @@ SLiScript_Parse_TokenStarts_DataDefinition( { return UUcTrue; } - + return UUcFalse; } @@ -270,7 +270,7 @@ SLiScript_Parse_TokenStarts_FuncDefinition( { return UUcTrue; } - + return UUcFalse; } @@ -319,7 +319,7 @@ SLiScript_Parse_TokenStarts_Expression( { return UUcTrue; } - + return UUcFalse; } @@ -331,7 +331,7 @@ SLrScript_Parse_TokenStarts_Operator_Unary( { return UUcTrue; } - + return UUcFalse; } @@ -354,7 +354,7 @@ SLrScript_Parse_TokenStarts_Operator_Binary( { return UUcTrue; } - + return UUcFalse; } @@ -368,7 +368,7 @@ SLiScript_Parse_TokenStarts_Operator_Arith( { return UUcTrue; } - + return UUcFalse; } @@ -386,7 +386,7 @@ SLiScript_Parse_TokenStarts_Operator_Cmp( { return UUcTrue; } - + return UUcFalse; } @@ -400,7 +400,7 @@ SLiScript_Parse_TokenStarts_Operator_Logical( { return UUcTrue; } - + return UUcFalse; } @@ -412,7 +412,7 @@ SLiScript_Parse_TokenStarts_Operator_Assign( { return UUcTrue; } - + return UUcFalse; } @@ -425,7 +425,7 @@ SLiScript_Parse_TokenStarts_OldParameter( { return UUcTrue; } - + return UUcFalse; } @@ -441,7 +441,7 @@ SLiScript_Parse_TokenStarts_OldFunctionCall( { return UUcTrue; } - + return UUcFalse; } @@ -457,9 +457,9 @@ SLiScript_Parse_TokenStarts_FunctionCall( { return UUcTrue; } - + if(SLiScript_Parse_TokenStarts_OldFunctionCall(inCurToken, inExecuting)) return UUcTrue; - + return UUcFalse; } @@ -480,8 +480,8 @@ SLiScript_Parse_TokenStarts_Statement( { return UUcTrue; } - - return UUcFalse; + + return UUcFalse; } static UUtError @@ -497,10 +497,10 @@ SLiScript_Parse_VerifyToken( inErrorContext, inCurToken, inDesiredToken); - + return UUcError_Generic; } - + return UUcError_None; } @@ -510,7 +510,7 @@ SLiParse_Stack_Push( UUtUns8 inNewState) { UUmAssert(inContext->curFuncState->parseTOS < SLcContext_ParseStack_MaxDepth); - + inContext->curFuncState->parseStack[inContext->curFuncState->parseTOS++] = inNewState; } @@ -521,7 +521,7 @@ SLiParse_Stack_Pop( if (inContext->curFuncState->parseTOS == 0) { UUmAssert(0); return SLcParseState_DefaultReturn; - } else { + } else { return inContext->curFuncState->parseStack[--inContext->curFuncState->parseTOS]; } } @@ -533,26 +533,26 @@ SLrParse_FuncStack_Push_Console( SLtToken* inToken) { SLtContext_FuncState* newState; - + newState = inContext->funcStack + inContext->funcTOS++; inContext->curFuncState = newState; - + UUrMemory_Clear(newState, sizeof(*newState)); - + newState->funcName = "(console)"; newState->symbol = NULL; - + newState->curToken = inToken; - + newState->scopeLevel = 1; - + SLiParse_Stack_Push(inContext, SLcParseState_DefaultReturn); SLiParse_Stack_Push(inContext, SLcParseState_Statements); SLrStatement_Level_Push(inContext, UUcTrue); return UUcError_None; } - + UUtError SLrParse_FuncStack_Push( @@ -566,35 +566,35 @@ SLrParse_FuncStack_Push( SLtContext_FuncState* newState; SLtSymbol* funcSymbol; UUtUns16 itr; - + BFrDebugFile_Printf(SLgDebugFile, "pushing context \"%s\"", inFuncName); SLrDebugMessage_LogParamList(inParameterListLength, inParameterList); - + error = SLrScript_Database_Symbol_Get(inContext, inFuncName, &funcSymbol); if(error != UUcError_None) { SLrScript_Error_Semantic(inErrorContext, "Could not find function \"%s\"", inFuncName); return UUcError_Generic; } - + if(inContext->funcTOS >= SLcContext_FuncState_MaxDepth) { UUmAssert(0); return UUcError_Generic; } - + if(funcSymbol->kind == SLcSymbolKind_Func_Script) { newState = inContext->funcStack + inContext->funcTOS++; inContext->curFuncState = newState; - + UUrMemory_Clear(newState, sizeof(*newState)); - + newState->funcName = inFuncName; newState->symbol = funcSymbol; newState->scopeLevel = 1; - - error = + + error = SLrScript_ParameterCheckAndPromote( inErrorContext, inFuncName, @@ -602,11 +602,11 @@ SLrParse_FuncStack_Push( &inParameterListLength, inParameterList); if(error != UUcError_None) return error; - + // enter all the parameters for(itr = 0; itr < inParameterListLength; itr++) { - error = + error = SLrScript_Database_Var_Add( inContext, funcSymbol->u.funcScript.paramList[itr].name, @@ -617,7 +617,7 @@ SLrParse_FuncStack_Push( } newState->curToken = funcSymbol->u.funcScript.startToken; - + SLiParse_Stack_Push(inContext, SLcParseState_DefaultReturn); SLiParse_Stack_Push(inContext, SLcParseState_Statements); SLrStatement_Level_Push(inContext, UUcTrue); @@ -625,10 +625,10 @@ SLrParse_FuncStack_Push( else if(funcSymbol->kind == SLcSymbolKind_Func_Command) { SLtParameter_Actual resultParameter; - + if(funcSymbol->u.funcCommand.numParamListOptions > 0) { - error = + error = SLrCommand_ParameterCheckAndPromote( inErrorContext, inFuncName, @@ -642,8 +642,8 @@ SLrParse_FuncStack_Push( inContext->stalled = UUcFalse; resultParameter.type = SLcType_Void; resultParameter.val.i = 0; - - error = + + error = funcSymbol->u.funcCommand.command( inErrorContext, inParameterListLength, @@ -661,33 +661,33 @@ SLrParse_FuncStack_Push( } // COrConsole_Printf("slr %s %d | %d", inFuncName, inContext->stalled, inContext->ticksTillCompletion); - + if ((inContext->ticksTillCompletion > 0) || (inContext->stalled)) { // we are only here if we are sleeping or stalled - + // schedule this task to be executed later - error = + error = SLrScheduler_Schedule( inContext, inErrorContext, inContext->stalled ? 1 : inContext->ticksTillCompletion); if(error != UUcError_None) return error; - + if(inContext->stalled) { newState = inContext->funcStack + inContext->funcTOS++; inContext->curFuncState = newState; - + UUrMemory_Clear(newState, sizeof(*newState)); - + newState->funcName = inFuncName; newState->symbol = funcSymbol; // copy over the parameters newState->numParams = inParameterListLength; UUrMemory_MoveFast(inParameterList, newState->params, inParameterListLength * sizeof(*inParameterList)); - } + } } } else @@ -695,18 +695,18 @@ SLrParse_FuncStack_Push( SLrScript_Error_Semantic(inErrorContext, "Could not find function \"%s\"", inFuncName); return UUcError_Generic; } - + return UUcError_None; } -static UUtError +static UUtError SLrParse_FuncStack_Pop( SLtContext* inContext) { if (inContext->funcTOS == 0) { UUmAssert(0); return UUcError_Generic; - } else { + } else { inContext->funcTOS--; inContext->curFuncState = inContext->funcStack + inContext->funcTOS - 1; return UUcError_None; @@ -737,9 +737,9 @@ SLrScript_Parse( SLtToken* iteratorSavedToken; SLtSymbol* iteratorSymbol; SLtSymbol* iteratorVarSymbol; - SLtToken* stalledToken; + SLtToken* stalledToken; SLtContext_FuncState* curFuncState; - + inContext->ticksTillCompletion = 0; curFuncState = inContext->curFuncState; @@ -749,24 +749,24 @@ SLrScript_Parse( if(inMode == SLcParseMode_AddToDatabase) { - + SLiParse_Stack_Push(inContext, SLcParseState_Global); inErrorContext->funcName = "(global scope)"; } else if(inMode == SLcParseMode_InitialExecution) { - + } else if(inMode == SLcParseMode_ContinueExecution) { // check for stalled function call - if (inContext->stalled) { + if (inContext->stalled) { UUmAssert(curFuncState->symbol->kind == SLcSymbolKind_Func_Command); inContext->ticksTillCompletion = 0; inContext->stalled = UUcFalse; - - error = + + error = curFuncState->symbol->u.funcCommand.command( inErrorContext, curFuncState->numParams, @@ -775,11 +775,11 @@ SLrScript_Parse( &inContext->stalled, NULL); if (error != UUcError_None) return error; - + if ((inContext->ticksTillCompletion > 0) || (inContext->stalled)) { // schedule this task to be executed later - error = + error = SLrScheduler_Schedule( inContext, inErrorContext, @@ -794,16 +794,16 @@ SLrScript_Parse( return error; } } - + } } else { UUmAssert(!"Illegal mode"); } - - -startOver: + + +startOver: curFuncState = inContext->curFuncState; curToken = curFuncState->curToken; @@ -814,14 +814,14 @@ SLrScript_Parse( inErrorContext->line = curToken->line; curFuncState = inContext->curFuncState; inErrorContext->funcName = curFuncState->funcIdent; - + switch(SLiParse_Stack_Pop(inContext)) { case SLcParseState_Global: UUmAssert(inMode == SLcParseMode_AddToDatabase); - + globalScope = UUcTrue; - + SLiParse_Stack_Push(inContext, SLcParseState_Global); if(SLiScript_Parse_TokenStarts_DataDefinition(curToken)) { @@ -841,29 +841,29 @@ SLrScript_Parse( inErrorContext, curToken, "expected either a data definition or a function definition"); - + return UUcError_Generic; } break; - + case SLcParseState_DataDef: error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_Var); if(error != UUcError_None) return error; curToken++; - + SLiParse_Stack_Push(inContext, SLcParseState_DataDef2); SLiParse_Stack_Push(inContext, SLcParseState_TypeSpec); break; - + case SLcParseState_DataDef2: identToken = curToken; error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_Identifier); if(error != UUcError_None) return error; curToken++; - + SLiParse_Stack_Push(inContext, SLcParseState_DataDef3); - + // check for an initialization if(curToken->token == SLcToken_Assign) { @@ -872,14 +872,14 @@ SLrScript_Parse( } eval = inMode != SLcParseMode_AddToDatabase || globalScope; break; - + case SLcParseState_DataDef3: error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_SemiColon); if(error != UUcError_None) return error; curToken++; - + inErrorContext->line = curToken->line; - + if(eval == UUcFalse || SLrExpr_GetResult( inContext, @@ -890,10 +890,10 @@ SLrScript_Parse( resultVal.i = 0; resultType = typeSpec; } - + error = SLrExpr_ConvertValue(inErrorContext, resultType, typeSpec, &resultVal); if(error != UUcError_None) return error; - + if(globalScope || inMode != SLcParseMode_AddToDatabase) { SLrScript_Database_Var_Add( @@ -905,67 +905,67 @@ SLrScript_Parse( } eval = inMode != SLcParseMode_AddToDatabase; break; - + case SLcParseState_TypeSpec: switch(curToken->token) { case SLcToken_String: typeSpec = SLcType_String; break; - + case SLcToken_Float: typeSpec = SLcType_Float; break; - + case SLcToken_Int: typeSpec = SLcType_Int32; break; - + case SLcToken_Void: typeSpec = SLcType_Void; break; - + case SLcToken_Bool: typeSpec = SLcType_Bool; break; - + default: SLrScript_Error_Parse( inErrorContext, curToken, "expected a type specification here"); - + return UUcError_Generic; } curToken++; break; - + case SLcParseState_FuncDef: error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_Func); if(error != UUcError_None) return error; curToken++; - + SLiParse_Stack_Push(inContext, SLcParseState_FuncDef2); - + typeSpec = SLcType_Void; - + if(SLiScript_Parse_TokenStarts_TypeSpec(curToken)) { SLiParse_Stack_Push(inContext, SLcParseState_TypeSpec); } break; - + case SLcParseState_FuncDef2: funcDefIdentToken = curToken; funcDefReturnType = typeSpec; - + error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_Identifier); if(error != UUcError_None) return error; curToken++; - + funcDefParamIndex = 0; SLiParse_Stack_Push(inContext, SLcParseState_FuncDef3); - + if(curToken->token == SLcToken_LeftParen) { curToken++; @@ -985,10 +985,10 @@ SLrScript_Parse( error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_LeftCurley); if(error != UUcError_None) return error; curToken++; - + funcDefStartToken = curToken; globalScope = UUcFalse; - + SLiParse_Stack_Push(inContext, SLcParseState_FuncDef4); SLiParse_Stack_Push(inContext, SLcParseState_Statements); break; @@ -997,7 +997,7 @@ SLrScript_Parse( error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_RightCurley); if(error != UUcError_None) return error; curToken++; - + if(inMode == SLcParseMode_AddToDatabase) { inErrorContext->line = curToken->line; @@ -1017,7 +1017,7 @@ SLrScript_Parse( SLrStatement_Level_Pop(inContext); } break; - + case SLcParseState_FuncDef_FormalParamList: SLiParse_Stack_Push(inContext, SLcParseState_FuncDef_FormalParamList_Finished); if(curToken->token == SLcToken_Void) @@ -1030,16 +1030,16 @@ SLrScript_Parse( SLiParse_Stack_Push(inContext, SLcParseState_TypeSpec); } break; - + case SLcParseState_FuncDef_FormalParamList2: funcDefParams[funcDefParamIndex].name = curToken->lexem; funcDefParams[funcDefParamIndex].type = typeSpec; funcDefParamIndex++; - + error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_Identifier); if(error != UUcError_None) return error; curToken++; - + if(curToken->token == SLcToken_Comma) { curToken++; @@ -1047,33 +1047,33 @@ SLrScript_Parse( SLiParse_Stack_Push(inContext, SLcParseState_TypeSpec); } break; - + case SLcParseState_FuncDef_FormalParamList_Finished: error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_RightParen); if(error != UUcError_None) return error; curToken++; break; - + case SLcParseState_Statements: SLiParse_Stack_Push(inContext, SLcParseState_Statements2); SLiParse_Stack_Push(inContext, SLcParseState_Statement); break; - + case SLcParseState_Statements2: if(SLiScript_Parse_TokenStarts_Statement(curToken)) { SLiParse_Stack_Push(inContext, SLcParseState_Statements); } break; - + case SLcParseState_Statement: - + if(curToken->token == SLcToken_LeftCurley) { curToken++; SLiParse_Stack_Push(inContext, SLcParseState_Statement_ReturnFromCurley); SLiParse_Stack_Push(inContext, SLcParseState_Statements); - + if(inMode != SLcParseMode_AddToDatabase && SLrStatement_Evaluate(inContext)) { SLrScript_Database_Scope_Enter(inContext); @@ -1091,21 +1091,21 @@ SLrScript_Parse( inContext->stalled = UUcFalse; stalledToken = curToken; UUmAssert(curFuncState->parenTOS == 0); - + } else if(curToken->token == SLcToken_Schedule) { curToken++; SLiParse_Stack_Push(inContext, SLcParseState_Statement_Schdl_ReturnFromFuncCall); SLiParse_Stack_Push(inContext, SLcParseState_Expression_FunctionCall); - + } else if(curToken->token == SLcToken_Fork) { curToken++; SLiParse_Stack_Push(inContext, SLcParseState_Statement_Fork_ReturnFromFuncCall); SLiParse_Stack_Push(inContext, SLcParseState_Expression_FunctionCall); - + } else if(curToken->token == SLcToken_Sleep) { @@ -1140,10 +1140,10 @@ SLrScript_Parse( error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_Identifier); if(error != UUcError_None) return error; - + if(inMode != SLcParseMode_AddToDatabase && SLrStatement_Evaluate(inContext)) { - error = + error = SLrScript_Database_Symbol_Get( inContext, curToken->lexem, @@ -1153,21 +1153,21 @@ SLrScript_Parse( SLrScript_Error_Semantic(inErrorContext, "iterator \"%s\" does not exist", curToken->lexem); return UUcError_Generic; } - + } - + curToken++; - + error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_Using); if(error != UUcError_None) return error; curToken++; - + error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_Identifier); if(error != UUcError_None) return error; - + if(inMode != SLcParseMode_AddToDatabase && SLrStatement_Evaluate(inContext)) { - error = + error = SLrScript_Database_Symbol_Get( inContext, curToken->lexem, @@ -1177,13 +1177,13 @@ SLrScript_Parse( SLrScript_Error_Semantic(inErrorContext, "iterator variable \"%s\" does not exist", curToken->lexem); return UUcError_Generic; } - + if(iteratorSymbol->u.iterator.type != iteratorVarSymbol->u.var.type) { SLrScript_Error_Semantic(inErrorContext, "iterator variable \"%s\" types do not match", curToken->lexem); return UUcError_Generic; } - + if(iteratorSymbol->u.iterator.getFirst(&iteratorVarSymbol->u.var.val)) { iteratorSavedToken = curToken + 1; @@ -1191,7 +1191,7 @@ SLrScript_Parse( } } curToken++; - + SLiParse_Stack_Push(inContext, SLcParseState_Statement); } else @@ -1199,10 +1199,10 @@ SLrScript_Parse( // empty statement do nothing } break; - + case SLcParseState_Statement_Iterating: UUmAssert(inMode != SLcParseMode_AddToDatabase && SLrStatement_Evaluate(inContext)); - + if(iteratorSymbol->u.iterator.getNext(&iteratorVarSymbol->u.var.val)) { curToken = iteratorSavedToken; @@ -1210,17 +1210,17 @@ SLrScript_Parse( SLiParse_Stack_Push(inContext, SLcParseState_Statement); } break; - - + + case SLcParseState_Statement_If_ReturnFromExpr: error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_RightParen); if(error != UUcError_None) return error; curToken++; - + SLiParse_Stack_Push(inContext, SLcParseState_Statement_If_ReturnFromExpr3); SLiParse_Stack_Push(inContext, SLcParseState_Statement_If_ReturnFromExpr2); SLiParse_Stack_Push(inContext, SLcParseState_Statement); - + if(inMode != SLcParseMode_AddToDatabase) { if(SLrStatement_Evaluate(inContext) == UUcFalse) @@ -1234,18 +1234,18 @@ SLrScript_Parse( { UUmAssert(0); } - + if(resultType != SLcType_Int32 && resultType != SLcType_Bool) { SLrScript_Error_Semantic(inErrorContext, "if needs an integer or boolean"); return UUcError_Generic; } - + SLrStatement_Level_Push(inContext, resultVal.i == 0 ? UUcFalse : UUcTrue); } } break; - + case SLcParseState_Statement_If_ReturnFromExpr2: if(curToken->token == SLcToken_Else) { @@ -1257,14 +1257,14 @@ SLrScript_Parse( } } break; - + case SLcParseState_Statement_If_ReturnFromExpr3: if(inMode != SLcParseMode_AddToDatabase) { SLrStatement_Level_Pop(inContext); } break; - + case SLcParseState_Statement_Return_ReturnFromExpr: if(!(curToken[-1].flags & SLcTokenFlag_PrecedesNewline)) { @@ -1278,7 +1278,7 @@ SLrScript_Parse( // ; is optional curToken++; } - + // pop the expr and put it in the result slot if(SLrExpr_GetResult( inContext, @@ -1289,11 +1289,11 @@ SLrScript_Parse( inContext->returnType = SLcType_Void; inContext->returnValue.i = 0; } - + if(inMode != SLcParseMode_AddToDatabase) goto done; - + break; - + case SLcParseState_Statement_Sleep_ReturnFromExpr: if(!(curToken[-1].flags & SLcTokenFlag_PrecedesNewline)) { @@ -1307,7 +1307,7 @@ SLrScript_Parse( // ; is optional curToken++; } - + if(inMode == SLcParseMode_AddToDatabase) { if(funcDefReturnType != SLcType_Void) @@ -1320,7 +1320,7 @@ SLrScript_Parse( else if(SLrStatement_Evaluate(inContext)) { curFuncState->curToken = curToken; - + // schedule this context to be slept if(SLrExpr_GetResult( inContext, @@ -1332,18 +1332,18 @@ SLrScript_Parse( return UUcError_Generic; } UUmAssert(resultType == SLcType_Int32); - - error = + + error = SLrScheduler_Schedule( inContext, inErrorContext, resultVal.i); if(error != UUcError_None) return error; - + return UUcError_None; } break; - + case SLcParseState_Statement_ReturnFromCurley: error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_RightCurley); if(error != UUcError_None) return error; @@ -1353,7 +1353,7 @@ SLrScript_Parse( SLrScript_Database_Scope_Leave(inContext); } break; - + case SLcParseState_Statement_Expr_ReturnFromExpr: if(!(curToken[-1].flags & SLcTokenFlag_PrecedesNewline)) { @@ -1367,7 +1367,7 @@ SLrScript_Parse( // ; is optional curToken++; } - + if(inMode != SLcParseMode_AddToDatabase && SLrStatement_Evaluate(inContext)) { if(SLrExpr_GetResult( @@ -1378,7 +1378,7 @@ SLrScript_Parse( { inContext->returnType = SLcType_Void; } - + if(curFuncState->parenTOS != 0) { SLrScript_Error_Semantic(inErrorContext, "Missing some )'s"); @@ -1386,7 +1386,7 @@ SLrScript_Parse( } } break; - + case SLcParseState_Statement_Schdl_ReturnFromFuncCall: if(curToken->token == SLcToken_At) { @@ -1416,7 +1416,7 @@ SLrScript_Parse( } } break; - + case SLcParseState_Statement_Schdl_At: if(!(curToken[-1].flags & SLcTokenFlag_PrecedesNewline)) { @@ -1430,7 +1430,7 @@ SLrScript_Parse( // ; is optional curToken++; } - + if(inMode != SLcParseMode_AddToDatabase && SLrStatement_Evaluate(inContext)) { inErrorContext->line = curToken->line; @@ -1443,20 +1443,20 @@ SLrScript_Parse( UUmAssert(0); return UUcError_Generic; } - + if(resultType != SLcType_Int32) { SLrScript_Error_Semantic(inErrorContext, "schedule at needs an integer"); return UUcError_Generic; } - - error = + + error = SLrExprListToParamList( inContext, inErrorContext, paramList); if(error != UUcError_None) return error; - + inErrorContext->line = curToken->line; error = SLrScript_Schedule( @@ -1492,12 +1492,12 @@ SLrScript_Parse( // ; is optional curToken++; } - + if(inMode != SLcParseMode_AddToDatabase && SLrStatement_Evaluate(inContext)) { UUtUns32 numberOfTimes; UUtUns32 timeDelta; - + inErrorContext->line = curToken->line; if(SLrExpr_GetResult( inContext, @@ -1508,15 +1508,15 @@ SLrScript_Parse( UUmAssert(0); return UUcError_Generic; } - + if(resultType != SLcType_Int32) { SLrScript_Error_Semantic(inErrorContext, "schedule at needs an integer"); return UUcError_Generic; } - + timeDelta = resultVal.i; - + if(SLrExpr_GetResult( inContext, inErrorContext, @@ -1526,22 +1526,22 @@ SLrScript_Parse( UUmAssert(0); return UUcError_Generic; } - + if(resultType != SLcType_Int32) { SLrScript_Error_Semantic(inErrorContext, "schedule at needs an integer"); return UUcError_Generic; } - + numberOfTimes = resultVal.i; - - error = + + error = SLrExprListToParamList( inContext, inErrorContext, paramList); if(error != UUcError_None) return error; - + inErrorContext->line = curToken->line; error = SLrScript_Schedule( @@ -1565,7 +1565,7 @@ SLrScript_Parse( if(error != UUcError_None) return error; } break; - + case SLcParseState_Expression2: if(curToken->token == SLcToken_LeftParen) { @@ -1574,7 +1574,7 @@ SLrScript_Parse( error = SLrExpr_Parse_LeftParen(inContext, inErrorContext); if(error != UUcError_None) return error; } - + curToken++; SLiParse_Stack_Push(inContext, SLcParseState_Expression3); SLiParse_Stack_Push(inContext, SLcParseState_Expression2); @@ -1586,7 +1586,7 @@ SLrScript_Parse( error = SLrExpr_Parse_Op_Unary(inContext, inErrorContext, curToken); if(error != UUcError_None) return error; } - + curToken++; SLiParse_Stack_Push(inContext, SLcParseState_Expression2); } @@ -1605,7 +1605,7 @@ SLrScript_Parse( error = SLrExpr_Parse_Identifier(inContext, curToken); if(error != UUcError_None) return error; } - + curToken++; SLiParse_Stack_Push(inContext, SLcParseState_Expression4); } @@ -1617,12 +1617,12 @@ SLrScript_Parse( error = SLrExpr_Parse_Op_Constant(inContext, curToken); if(error != UUcError_None) return error; } - + curToken++; SLiParse_Stack_Push(inContext, SLcParseState_Expression4); } break; - + case SLcParseState_Expression4: if(SLrScript_Parse_TokenStarts_Operator_Binary(curToken)) { @@ -1631,23 +1631,23 @@ SLrScript_Parse( error = SLrExpr_Parse_Op_Binary(inContext, inErrorContext, curToken); if(error != UUcError_None) return error; } - + curToken++; SLiParse_Stack_Push(inContext, SLcParseState_Expression2); } break; - + case SLcParseState_Expression_Finish: if(eval || (inMode != SLcParseMode_AddToDatabase && SLrStatement_Evaluate(inContext))) { error = SLrExpr_Parse_RightParen(inContext, inErrorContext); if(error != UUcError_None) return error; - + error = SLrExpr_Parse_Final(inContext, inErrorContext); if(error != UUcError_None) return error; } break; - + case SLcParseState_Expression_FunctionCall: UUmAssert(curToken->token == SLcToken_Identifier); if(inMode != SLcParseMode_AddToDatabase && SLrStatement_Evaluate(inContext)) @@ -1655,7 +1655,7 @@ SLrScript_Parse( error = SLrExpr_Parse_FunctionCall_Ident(inContext, curToken); if(error != UUcError_None) return error; } - + if(SLiScript_Parse_TokenStarts_OldFunctionCall(curToken, inMode != SLcParseMode_AddToDatabase)) { if(!(curToken->flags & SLcTokenFlag_PrecedesNewline)) @@ -1672,21 +1672,21 @@ SLrScript_Parse( curToken++; } break; - + case SLcParseState_Expression3: error = SLiScript_Parse_VerifyToken(inErrorContext, curToken, SLcToken_RightParen); if(error != UUcError_None) return error; - + if(eval || (inMode != SLcParseMode_AddToDatabase && SLrStatement_Evaluate(inContext))) { error = SLrExpr_Parse_RightParen(inContext, inErrorContext); if(error != UUcError_None) return error; } - + curToken++; SLiParse_Stack_Push(inContext, SLcParseState_Expression4); break; - + case SLcParseState_Expression_FunctionCall_ParamList_New: if(curToken->token == SLcToken_RightParen) { @@ -1705,7 +1705,7 @@ SLrScript_Parse( error = SLrExpr_Parse_Param(inContext); if(error != UUcError_None) return error; } - + if(curToken->token == SLcToken_Comma) { curToken++; @@ -1740,22 +1740,22 @@ SLrScript_Parse( } curToken++; break; - + case SLcParseState_Expression_FunctionCall_Finish: if(inMode != SLcParseMode_AddToDatabase && SLrStatement_Evaluate(inContext)) { curFuncState->curToken = curToken; - + error = SLrExpr_Parse_FunctionCall_Make(inContext, inErrorContext); if(error != UUcError_None) return error; - + if(inContext->ticksTillCompletion > 0 || inContext->stalled) { // we need to sleep for a while - + return UUcError_None; } - + if(inContext->returnType != SLcType_Void) { SLrExpr_Push_Const( @@ -1763,17 +1763,17 @@ SLrScript_Parse( inContext->returnType, inContext->returnValue); } - + curToken = inContext->curFuncState->curToken; - + } break; - + case SLcParseState_DefaultReturn: //inContext->returnType = SLcType_Void; //inContext->returnValue.i = 0; goto done; - + case SLcParseState_Statement_Fork_ReturnFromFuncCall: if(!(curToken[-1].flags & SLcTokenFlag_PrecedesNewline)) { @@ -1787,10 +1787,10 @@ SLrScript_Parse( // ; is optional curToken++; } - + if(inMode != SLcParseMode_AddToDatabase && SLrStatement_Evaluate(inContext)) { - error = + error = SLrExprListToParamList( inContext, inErrorContext, @@ -1806,23 +1806,23 @@ SLrScript_Parse( if(error != UUcError_None) return error; } break; - - - + + + default: UUmAssert(0); } } done: - + if(inContext->funcTOS == 1) return UUcError_None; - + error = SLrParse_FuncStack_Pop(inContext); if (error != UUcError_None) { return error; } - + // if the result is not NULL then put the result on this stack if(inContext->returnType != SLcType_Void) { @@ -1831,10 +1831,10 @@ SLrScript_Parse( inContext->returnType, inContext->returnValue); } - + goto startOver; - - + + return UUcError_None; } @@ -1848,24 +1848,24 @@ SLrParse_TokenToType( case SLcToken_Float: *outVariableType = SLcType_Float; return UUcError_None; - + case SLcToken_String: *outVariableType = SLcType_String; return UUcError_None; - + case SLcToken_Void: *outVariableType = SLcType_Void; return UUcError_None; - + case SLcToken_Int: *outVariableType = SLcType_Int32; return UUcError_None; - + case SLcToken_Bool: *outVariableType = SLcType_Bool; return UUcError_None; } - + return UUcError_Generic; } @@ -1880,47 +1880,47 @@ SLrParse_ConstTokenToTypeAndVal( case SLcToken_Constant_Int: *outType = SLcType_Int32; break; - + case SLcToken_Constant_Float: *outType = SLcType_Float; break; - + case SLcToken_Constant_String: *outType = SLcType_String; break; - + case SLcToken_Constant_Bool: *outType = SLcType_Bool; break; - + default: UUmAssert(0); return UUcError_Generic; } - + switch(*outType) { case SLcType_Int32: UUrString_To_Int32(inToken->lexem, &outVal->i); break; - + case SLcType_String: outVal->str = (char*)inToken->lexem; break; - + case SLcType_Float: UUrString_To_Float(inToken->lexem, &outVal->f); break; - + case SLcType_Bool: outVal->b = inToken->lexem[0] == '0' ? UUcFalse : UUcTrue; break; - + default: UUmAssert(0); return UUcError_Generic; } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Parse.h b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Parse.h index 8911c95..a65626f 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Parse.h +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Parse.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_ScriptLang_Parse.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -20,7 +20,7 @@ typedef enum SLtParse_Mode SLcParseMode_AddToDatabase, SLcParseMode_InitialExecution, SLcParseMode_ContinueExecution - + } SLtParse_Mode; UUtError @@ -41,7 +41,7 @@ UUtError SLrParse_TokenToType( SLtToken_Code inTokenCode, SLtType *outVariableType); - + UUtError SLrParse_ConstTokenToTypeAndVal( SLtToken* inToken, @@ -57,7 +57,7 @@ SLrParse_FuncStack_Push_Console( UUtBool SLrScript_Parse_TokenStarts_Operator_Unary( SLtToken* inCurToken); - + UUtBool SLrScript_Parse_TokenStarts_Operator_Binary( SLtToken* inCurToken); @@ -65,5 +65,5 @@ SLrScript_Parse_TokenStarts_Operator_Binary( UUtBool SLrScript_Parse_TokenStarts_Constant( SLtToken* inCurToken); - -#endif \ No newline at end of file + +#endif diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Private.h b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Private.h index 59c2c1d..7116c7e 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Private.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_ScriptLang_Private.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -40,9 +40,9 @@ typedef enum SLtToken_Code SLcToken_Cmp_GT, SLcToken_Cmp_LE, SLcToken_Cmp_GE, - + SLcToken_NumOperators, - + SLcToken_LeftParen = SLcToken_NumOperators, SLcToken_RightParen, SLcToken_LeftCurley, @@ -52,15 +52,15 @@ typedef enum SLtToken_Code SLcToken_SemiColon, SLcToken_Colon, SLcToken_Comma, - + SLcToken_Bar, - + SLcToken_Identifier, SLcToken_Constant_Int, SLcToken_Constant_Bool, SLcToken_Constant_Float, SLcToken_Constant_String, - + SLcToken_Schedule, SLcToken_Iterate, SLcToken_Repeat, @@ -83,9 +83,9 @@ typedef enum SLtToken_Code SLcToken_Var, SLcToken_At, SLcToken_If, - + SLcToken_EOF - + } SLtToken_Code; typedef struct SLtToken SLtToken; @@ -94,7 +94,7 @@ typedef enum SLtToken_Flags { SLcTokenFlag_None = 0, SLcTokenFlag_PrecedesNewline = (1 << 0) - + } SLtToken_Flags; struct SLtToken @@ -113,15 +113,15 @@ typedef enum SLtSymbol_Kind SLcSymbolKind_Func_Script, SLcSymbolKind_Func_Command, SLcSymbolKind_Iterator - + } SLtSymbol_Kind; typedef struct SLtSymbol_Var { SLtType type; - + SLtValue val; - + } SLtSymbol_Var; typedef struct SLtSymbol_VarAddr @@ -131,18 +131,18 @@ typedef struct SLtSymbol_VarAddr void* valAddr; SLtNotificationProc noticeProc; char* desc; - + } SLtSymbol_VarAddr; typedef struct SLtParameterOption { SLtParameter_Formal formalParam; - + UUtBool repeats; - + UUtUns16 numLegalValues; SLtValue legalValue[SLcMaxLegalValues]; - + } SLtParameterOption; typedef struct SLtParameterList @@ -150,7 +150,7 @@ typedef struct SLtParameterList UUtBool hasRepeating; UUtUns16 numParams; SLtParameterOption params[SLcScript_MaxNumParams]; - + } SLtParameterList; typedef struct SLtSymbol_Func_Script @@ -159,7 +159,7 @@ typedef struct SLtSymbol_Func_Script SLtToken* startToken; UUtUns16 numParams; SLtParameter_Formal paramList[SLcScript_MaxNumParams]; - + } SLtSymbol_Func_Script; typedef struct SLtSymbol_Func_Command @@ -169,18 +169,18 @@ typedef struct SLtSymbol_Func_Command const char* paramSpec; UUtBool checkParams; SLtType returnType; - + UUtUns16 numParamListOptions; SLtParameterList paramListOptions[SLcScript_MaxNumParamLists]; - + } SLtSymbol_Func_Command; typedef struct SLtSymbol_Iterator -{ +{ SLtScript_Iterator_GetFirst getFirst; SLtScript_Iterator_GetNext getNext; SLtType type; - + } SLtSymbol_Iterator; @@ -193,7 +193,7 @@ struct SLtSymbol UUtUns16 line; UUtUns16 scopeLevel; SLtSymbol_Kind kind; - + union { SLtSymbol_Var var; @@ -201,44 +201,44 @@ struct SLtSymbol SLtSymbol_Func_Script funcScript; SLtSymbol_Func_Command funcCommand; SLtSymbol_Iterator iterator; - + } u; - + SLtSymbol* prev; SLtSymbol* next; - + }; typedef enum SLtExpr_Kind { SLcExprKind_Constant, SLcExprKind_Identifier - + } SLtExpr_Kind; typedef struct SLtExpr_Ident { const char* name; - + } SLtExpr_Ident; typedef struct SLtExpr_Const { SLtValue val; - + } SLtExpr_Const; typedef struct SLtExpr { SLtExpr_Kind kind; SLtType type; - + union { SLtExpr_Ident ident; SLtExpr_Const constant; } u; - + } SLtExpr; #define SLcExprOpStack_MaxDepth (4) @@ -255,31 +255,31 @@ typedef struct SLtContext_FuncState { UUtUns16 parseTOS; UUtUns8 parseStack[SLcContext_ParseStack_MaxDepth]; - + UUtUns16 exprTOS; SLtExpr exprStack[SLcContext_ExprStack_MaxDepth]; UUtUns16 parenLevel; - + UUtUns16 parenTOS; SLtExpr_OpStack parenStack[SLcContext_ParenStack_MaxDepth]; SLtExpr_OpStack* curParenStack; - + SLtSymbol* symbolList[SLcMaxScopeLevel]; UUtUns16 scopeLevel; - + SLtToken* curToken; UUtUns16 statementLevel; UUtBool statementEval[SLcContext_StatementStack_MaxDepth]; UUtUns16 statement_TargetLevel; - + const char* funcName; SLtSymbol* symbol; - + UUtUns16 numParams; SLtExpr paramExprs[SLcScript_MaxNumParams]; SLtParameter_Actual params[SLcScript_MaxNumParams]; - + const char* funcIdent; } SLtContext_FuncState; @@ -290,14 +290,14 @@ struct SLtContext SLtContext_FuncState funcStack[SLcContext_FuncState_MaxDepth]; SLtContext_FuncState* curFuncState; - + // common state that is shared SLtType returnType; SLtValue returnValue; - + UUtUns32 ticksTillCompletion; UUtBool stalled; - + // whereabouts the rest of the engine has a pointer to us stored struct SLtContext **referenceptr; @@ -310,4 +310,4 @@ extern UUtMemory_String* SLgPermStringMemory; extern BFtDebugFile* SLgDebugFile; -#endif /* BFW_SCRIPTLANG_PRIVATE */ \ No newline at end of file +#endif /* BFW_SCRIPTLANG_PRIVATE */ diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Scheduler.c b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Scheduler.c index ce8f04c..1de6a2c 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Scheduler.c +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Scheduler.c @@ -1,12 +1,12 @@ /* FILE: BFW_ScriptLang_Scheduler.c - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -33,7 +33,7 @@ typedef enum SLtScheduledTask_Type SLcScheduledTask_Type_Unused, SLcScheduledTask_Type_Script, SLcScheduledTask_Type_Command - + } SLtScheduledTask_Type; typedef struct SLtScheduledTask_Script @@ -41,25 +41,25 @@ typedef struct SLtScheduledTask_Script SLtContext* context; UUtUns32 wakeTime; UUtBool sleeping; - + } SLtScheduledTask_Script; typedef struct SLtScheduledTask_Command { SLtEngineCommand command; - + } SLtScheduledTask_Command; typedef struct SLtScheduledTask { SLtScheduledTask_Type type; - + UUtUns32 count; UUtUns32 delta; UUtUns32 nextGameTime; - + SLtErrorContext errorContext; - + const char* name; UUtUns16 numParams; SLtParameter_Actual params[SLcScript_MaxNumParams]; @@ -68,9 +68,9 @@ typedef struct SLtScheduledTask { SLtScheduledTask_Script script; SLtScheduledTask_Command command; - + } u; - + } SLtScheduledTask; SLtScheduledTask SLgSchedule_Tasks[SLcScheduler_MaxTasks]; @@ -81,7 +81,7 @@ SLiSchedule_Task_Find( SLtContext* inContext) { UUtUns16 itr; - + if(inContext == NULL) { for(itr = 0; itr < SLcScheduler_MaxTasks; itr++) @@ -100,7 +100,7 @@ SLiSchedule_Task_Find( } } } - + return NULL; } @@ -129,7 +129,7 @@ SLiSchedule_Task_Delete( { SLrContext_Delete(inTask->u.script.context); } - + inTask->type = SLcScheduledTask_Type_Unused; } @@ -144,7 +144,7 @@ SLiSchedule_Add_Script( UUtUns32 inNumberOfTimes) { SLtScheduledTask* newTask; - + newTask = SLiSchedule_Task_Find(NULL); if (NULL == newTask) { @@ -152,16 +152,16 @@ SLiSchedule_Add_Script( } UUmError_ReturnOnNull(newTask); - + newTask->u.script.context = inContext; newTask->u.script.sleeping = UUcFalse; - + newTask->numParams = inNumParams; if(inNumParams > 0) { UUrMemory_MoveFast(inParams, newTask->params, inNumParams * sizeof(*inParams)); } - + SLiSchedule_Task_Add( newTask, inErrorContext, @@ -169,7 +169,7 @@ SLiSchedule_Add_Script( inName, inTimeDelta, inNumberOfTimes); - + return UUcError_None; } @@ -184,15 +184,15 @@ SLiSchedule_Add_Command( UUtUns32 inNumberOfTimes) { SLtScheduledTask* newTask; - + newTask = SLiSchedule_Task_Find(NULL); UUmError_ReturnOnNull(newTask); - + newTask->numParams = inNumParams; UUrMemory_MoveFast(inParams, newTask->params, inNumParams * sizeof(*inParams)); - + newTask->u.command.command = inCommand; - + SLiSchedule_Task_Add( newTask, inErrorContext, @@ -218,20 +218,20 @@ SLrSchedule_Function_Script( { UUtError error; SLtContext* context; - + // create the context context = SLrContext_New(ioReferencePtr); UUmError_ReturnOnNull(context); - - - - + + + + if(inTimeDelta == 0 && inNumberOfTimes == 1) { // run immediately - + // push the initial state on the function stack - error = + error = SLrParse_FuncStack_Push( context, inErrorContext, @@ -239,14 +239,14 @@ SLrSchedule_Function_Script( inPassedInParams, inName); if(error != UUcError_None) return error; - - error = + + error = SLrScript_Parse( context, inErrorContext, SLcParseMode_InitialExecution); if(error != UUcError_None) return error; - + if(ioReturnValue != NULL) { // process return value here @@ -265,7 +265,7 @@ SLrSchedule_Function_Script( SLrScript_Error_Semantic(inErrorContext, "function \"%s\" can be scheduled and return a value", inName); return UUcError_Generic; } - + // schedule this context SLiSchedule_Add_Script( inName, @@ -292,11 +292,11 @@ SLrSchedule_Function_Engine( UUtUns32 inNumberOfTimes) { UUtError error; - + if(inTimeDelta == 0 && inNumberOfTimes == 1) { // run immediately - error = + error = inCommand->command( inErrorContext, inParameterListLength, @@ -305,12 +305,12 @@ SLrSchedule_Function_Engine( NULL, ioReturnValue); if(error != UUcError_None) return error; - + } else { // schedule - error = + error = SLiSchedule_Add_Command( inName, inErrorContext, @@ -321,11 +321,11 @@ SLrSchedule_Function_Engine( inNumberOfTimes); if(error != UUcError_None) return error; } - + return UUcError_None; } -UUtError +UUtError SLrScheduler_Execute( const char* inName, SLtErrorContext* inErrorContext, @@ -338,25 +338,25 @@ SLrScheduler_Execute( { UUtError error; SLtSymbol* symbol; - + SLtSymbol_Func_Script* script; SLtSymbol_Func_Command* command; - + error = SLrScript_Database_Symbol_Get(NULL, inName, &symbol); if(error != UUcError_None) { SLrScript_Error_Semantic(inErrorContext, "function \"%s\" does not exist", inName); return UUcError_Generic; } - + switch(symbol->kind) { case SLcSymbolKind_Func_Script: script = &symbol->u.funcScript; - + inErrorContext->fileName = symbol->fileName; - - error = + + error = SLrSchedule_Function_Script( inName, inErrorContext, @@ -369,10 +369,10 @@ SLrScheduler_Execute( ioReferencePtr); if(error != UUcError_None) return error; // someday report something meaningful here break; - + case SLcSymbolKind_Func_Command: command = &symbol->u.funcCommand; - + if(command->numParamListOptions > 0) { error = @@ -384,8 +384,8 @@ SLrScheduler_Execute( inParameterList); if(error != UUcError_None) return error; } - - error = + + error = SLrSchedule_Function_Engine( inName, inErrorContext, @@ -396,12 +396,12 @@ SLrScheduler_Execute( inTimeDelta, inNumberOfTimes); break; - + default: SLrScript_Error_Semantic(inErrorContext, "identifier is not a function"); return UUcError_Generic; } - + return UUcError_None; } @@ -413,11 +413,11 @@ SLrScheduler_Schedule( { UUtError error; SLtScheduledTask* targetTask; - + targetTask = SLiSchedule_Task_Find(inContext); if(targetTask == NULL) { - error = + error = SLiSchedule_Add_Script( inContext->funcStack[0].funcName, inContext, @@ -431,10 +431,10 @@ SLrScheduler_Schedule( UUmAssertReadPtr(targetTask, sizeof(*targetTask)); } targetTask->errorContext = *inErrorContext; - + targetTask->u.script.sleeping = UUcTrue; targetTask->u.script.wakeTime = SLgSchedule_GameTime + inTicksTillWake; - + return UUcError_None; } @@ -451,7 +451,7 @@ SLrScheduler_Remove( void * inContext) { SLtScheduledTask* task; - + if (inContext == NULL) { return UUcError_Generic; } @@ -474,7 +474,7 @@ SLrScheduler_ForceDelete( void * inContext) { SLtScheduledTask* task; - + task = SLiSchedule_Task_Find((SLtContext *) inContext); if (task != NULL) { SLrContext_Delete((SLtContext *) inContext); @@ -489,11 +489,11 @@ SLrScheduler_Update( UUtUns16 itr; SLtScheduledTask* curTask; UUtBool sleeping; - + sleeping = UUcFalse; - + SLgSchedule_GameTime = inGameTime; - + for(itr = 0, curTask = SLgSchedule_Tasks; itr < SLcScheduler_MaxTasks; itr++, curTask++) @@ -507,7 +507,7 @@ SLrScheduler_Update( { curTask->u.script.sleeping = UUcFalse; // continue execution - error = + error = SLrScript_Parse( curTask->u.script.context, &curTask->errorContext, @@ -517,7 +517,7 @@ SLrScheduler_Update( SLiSchedule_Task_Delete(curTask); return error; } - + if(!curTask->u.script.sleeping && curTask->count <= 1) { SLiSchedule_Task_Delete(curTask); @@ -528,8 +528,8 @@ SLrScheduler_Update( { // start execution curTask->u.script.context->funcTOS = 0; - - error = + + error = SLrParse_FuncStack_Push( curTask->u.script.context, &curTask->errorContext, @@ -537,8 +537,8 @@ SLrScheduler_Update( curTask->params, curTask->name); if(error != UUcError_None) return error; - - error = + + error = SLrScript_Parse( curTask->u.script.context, &curTask->errorContext, @@ -549,7 +549,7 @@ SLrScheduler_Update( SLiSchedule_Task_Delete(curTask); return error; } - + if(!curTask->u.script.sleeping) { curTask->count--; @@ -570,9 +570,9 @@ SLrScheduler_Update( if(curTask->nextGameTime <= inGameTime) { UUtBool stalled = UUcFalse; - + // start execution - error = + error = curTask->u.command.command( &curTask->errorContext, curTask->numParams, @@ -585,7 +585,7 @@ SLrScheduler_Update( SLiSchedule_Task_Delete(curTask); return error; } - + if(!stalled) { curTask->count--; @@ -603,7 +603,7 @@ SLrScheduler_Update( break; } } - + return UUcError_None; } @@ -612,12 +612,12 @@ SLrScheduler_Initialize( void) { UUtUns16 itr; - + for(itr = 0; itr < SLcScheduler_MaxTasks; itr++) { SLgSchedule_Tasks[itr].type = SLcScheduledTask_Type_Unused; } - + SLgSchedule_GameTime = 0; return UUcError_None; @@ -665,14 +665,14 @@ void SLrScript_Debug_Console(void) { UUtUns32 itr; - + for(itr = 0; itr < SLcScheduler_MaxTasks; itr++) { if(SLgSchedule_Tasks[itr].type != SLcScheduledTask_Type_Unused) { - COrConsole_Printf("task #%d %s %s %d", - itr, - SLgSchedule_Tasks[itr].errorContext.fileName, - SLgSchedule_Tasks[itr].errorContext.funcName, + COrConsole_Printf("task #%d %s %s %d", + itr, + SLgSchedule_Tasks[itr].errorContext.fileName, + SLgSchedule_Tasks[itr].errorContext.funcName, SLgSchedule_Tasks[itr].errorContext.line); } } diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Scheduler.h b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Scheduler.h index cdcff60..3359b72 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Scheduler.h +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Scheduler.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_ScriptLang_Scheduler.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -16,7 +16,7 @@ // This will execute a command and schedule it if needed // This only schedules stuff called from the engine -UUtError +UUtError SLrScheduler_Execute( const char* inName, SLtErrorContext* inErrorContext, diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Token.c b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Token.c index 8d16387..1332a1a 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Token.c +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Token.c @@ -1,12 +1,12 @@ /* FILE: BFW_ScriptLang_Token.c - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ @@ -48,7 +48,7 @@ SLiLexem_AddChar( char inC) { UUmAssertReadPtr(SLgLexem_CurPtr, sizeof(char)); - + if(SLgLexemBuffer_Len < SLcLexem_Buffer_MaxSize) { *SLgLexem_CurPtr++ = inC; @@ -69,7 +69,7 @@ SLiLexem_IsReservedWord( SLtToken_Code *outReservedWord) { if(SLgLexemBuffer_Len > 8 || SLgLexemBuffer_Len < 2) return UUcFalse; - + switch(SLgLexemBuffer_Len) { case 2: @@ -112,7 +112,7 @@ SLiLexem_IsReservedWord( break; } break; - + case 3: switch(SLgLexemBuffer[0]) { @@ -146,7 +146,7 @@ SLiLexem_IsReservedWord( break; } break; - + case 4: switch(SLgLexemBuffer[0]) { @@ -199,7 +199,7 @@ SLiLexem_IsReservedWord( break; } break; - + case 5: switch(SLgLexemBuffer[0]) { @@ -238,7 +238,7 @@ SLiLexem_IsReservedWord( break; } break; - + case 6: switch(SLgLexemBuffer[0]) { @@ -263,7 +263,7 @@ SLiLexem_IsReservedWord( break; } break; - + case 7: if(!strncmp(SLgLexemBuffer, "iterate", 7)) { @@ -271,7 +271,7 @@ SLiLexem_IsReservedWord( return UUcTrue; } break; - + case 8: if(!strncmp(SLgLexemBuffer, "schedule", 8)) { @@ -280,7 +280,7 @@ SLiLexem_IsReservedWord( } break; } - + return UUcFalse; } @@ -295,42 +295,42 @@ SLiToken_Make( char c; SLtToken_Code reservedWord; SLtToken_Code constantType; - + *outAllocationFailed = UUcFalse; outCurToken->lexem = NULL; outCurToken->line = SLgLineNum; outCurToken->flags = SLcTokenFlag_None; - + startOver: SLiLexem_Start(); - + c = *cp++; - + if(c == 0) { outCurToken->token = SLcToken_EOF; if(SLgLastToken != NULL) SLgLastToken->flags |= SLcTokenFlag_PrecedesNewline; } - + else if(c == '\n') { if(*cp == '\r') cp++; SLgLineNum++; - + if(SLgLastToken != NULL) SLgLastToken->flags |= SLcTokenFlag_PrecedesNewline; - + goto startOver; } else if(c == '\r') { if(*cp == '\n') cp++; SLgLineNum++; - + if(SLgLastToken != NULL) SLgLastToken->flags |= SLcTokenFlag_PrecedesNewline; - + goto startOver; } - + else if(isspace(c)) { while(isspace(c) && c != '\n' && c != '\r' && c != 0) @@ -338,15 +338,15 @@ SLiToken_Make( c = *cp++; } cp--; - + goto startOver; } else if(c == 'f' && isdigit(cp[0])) { c = *cp++; - + constantType = SLcToken_Constant_Int; - + while((isdigit(c) || (c == '.')) && c != 0) { if(c == '.') constantType = SLcToken_Constant_Float; @@ -354,7 +354,7 @@ SLiToken_Make( c = *cp++; } cp--; - + outCurToken->token = constantType; } else if(isalpha(c) || c == '_') @@ -365,9 +365,9 @@ SLiToken_Make( c = *cp++; } cp--; - + SLiLexem_End(); - + if(SLiLexem_IsReservedWord(&reservedWord)) { if(reservedWord == SLcToken_True) @@ -392,11 +392,11 @@ SLiToken_Make( outCurToken->token = SLcToken_Identifier; } } - + else if(isdigit(c) || (c == '.') || ((c == '-') && isdigit(cp[0]))) { constantType = SLcToken_Constant_Int; - + while((isdigit(c) || (c == '.') || (c == '-')) && c != 0) { if(c == '.') constantType = SLcToken_Constant_Float; @@ -404,10 +404,10 @@ SLiToken_Make( c = *cp++; } cp--; - + outCurToken->token = constantType; } - + else { switch(c) @@ -416,7 +416,7 @@ SLiToken_Make( SLiLexem_AddChar(c); outCurToken->token = SLcToken_LogicalNot; break; - + case '\"': c = *cp++; while(c != '\"' && c != 0 && c != '\n' && c != '\r') @@ -434,75 +434,75 @@ SLiToken_Make( } outCurToken->token = SLcToken_Constant_String; break; - + case '(': SLiLexem_AddChar(c); outCurToken->token = SLcToken_LeftParen; break; - + case ')': SLiLexem_AddChar(c); outCurToken->token = SLcToken_RightParen; break; - + case '[': SLiLexem_AddChar(c); outCurToken->token = SLcToken_LeftBracket; break; - + case ']': SLiLexem_AddChar(c); outCurToken->token = SLcToken_RightBracket; break; - + case '+': SLiLexem_AddChar(c); outCurToken->token = SLcToken_Plus; break; - + case ',': SLiLexem_AddChar(c); outCurToken->token = SLcToken_Comma; break; - + case '-': SLiLexem_AddChar(c); outCurToken->token = SLcToken_Minus; break; - + case ';': SLiLexem_AddChar(c); outCurToken->token = SLcToken_SemiColon; break; - + case ':': SLiLexem_AddChar(c); outCurToken->token = SLcToken_Colon; break; - + case '=': SLiLexem_AddChar(c); outCurToken->token = SLcToken_Assign; break; - + case '{': SLiLexem_AddChar(c); outCurToken->token = SLcToken_LeftCurley; break; - + case '}': SLiLexem_AddChar(c); outCurToken->token = SLcToken_RightCurley; break; - + case '|': SLiLexem_AddChar(c); outCurToken->token = SLcToken_Bar; break; - + case '<': SLiLexem_AddChar(c); - + if(cp[0] == '=') { SLiLexem_AddChar(c); @@ -514,10 +514,10 @@ SLiToken_Make( outCurToken->token = SLcToken_Cmp_LT; } break; - + case '>': SLiLexem_AddChar(c); - + if(cp[0] == '=') { SLiLexem_AddChar(c); @@ -529,16 +529,16 @@ SLiToken_Make( outCurToken->token = SLcToken_Cmp_GT; } break; - - + + case '#': - + while(1) { c = *cp++; - + if(c == 0) break; - + if(c == '\n') { if(*cp == '\r') cp++; @@ -549,34 +549,34 @@ SLiToken_Make( if(*cp == '\n') cp++; break; } - + } if(c == 0) cp--; SLgLineNum++; goto startOver; - + default: SLgToken_ErrorContext.line = SLgLineNum; SLrScript_Error_Lexical( &SLgToken_ErrorContext, c, "Illegal character"); - + return UUcError_Generic; } } - + SLiLexem_End(); if(*SLgLexemBuffer != 0) { outCurToken->lexem = UUrMemory_String_GetStr(inMemoryString, SLgLexemBuffer); } - + *ioCP = cp; - + SLgLastToken = outCurToken; - + return UUcError_None; } @@ -594,14 +594,14 @@ SLrScript_TextToToken( UUtUns32 string_size; UUtUns16 numTokens = 0; - + SLgLineNum = 1; - + SLgToken_ErrorContext.funcName = "(none)"; SLgToken_ErrorContext.fileName = inFileName; - + SLgLastToken = NULL; - + while(1) { UUmAssert(numTokens < SLcMaxTokens); @@ -609,7 +609,7 @@ SLrScript_TextToToken( if (numTokens >= SLcMaxTokens) { UUmError_ReturnOnErrorMsgP(UUcError_Generic, "script file %s had more then %d tokens", (UUtUns32) inFileName, SLcMaxTokens, 0); } - + SLiToken_Make(inMemoryString, &cp, &allocation_failed, ct); if (allocation_failed) { @@ -619,14 +619,14 @@ SLrScript_TextToToken( } if(ct->token == SLcToken_EOF) break; - + numTokens++; ct++; } - + *outNumTokens = numTokens; *outTokens = SLgTokenArray; - + return UUcError_None; } @@ -646,127 +646,127 @@ SLrTokenCode_ConvertToString( { case SLcToken_LeftParen: return "("; - + case SLcToken_RightParen: return ")"; - + case SLcToken_LeftCurley: return "{"; - + case SLcToken_RightCurley: return "}"; - + case SLcToken_SemiColon: return ";"; - + case SLcToken_Comma: return ","; - + case SLcToken_Assign: return "="; - + case SLcToken_Plus: return "+"; - + case SLcToken_Minus: return "-"; - + case SLcToken_LogicalAnd: return "and"; - + case SLcToken_LogicalOr: return "or"; - + case SLcToken_LogicalNot: return "!"; - + case SLcToken_Cmp_EQ: return "eq"; - + case SLcToken_Cmp_NE: return "ne"; - + case SLcToken_Cmp_LT: return "<"; - + case SLcToken_Cmp_GT: return ">"; - + case SLcToken_Cmp_LE: return "<="; - + case SLcToken_Cmp_GE: return ">="; - + case SLcToken_Identifier: return "identifier"; - + case SLcToken_Constant_Int: return "int"; - + case SLcToken_Constant_Float: return "float"; - + case SLcToken_Constant_String: return "string"; - + case SLcToken_Schedule: return "schedule"; - + case SLcToken_Iterate: return "iterate"; - + case SLcToken_Repeat: return "repeat"; - + case SLcToken_Return: return "return"; - + case SLcToken_String: return "string"; - + case SLcToken_Every: return "every"; - + case SLcToken_Float: return "float"; - + case SLcToken_Using: return "using"; - + case SLcToken_Sleep: return "sleep"; - + case SLcToken_Else: return "else"; - + case SLcToken_Func: return "func"; - + case SLcToken_Over: return "over"; - + case SLcToken_Void: return "void"; - + case SLcToken_For: return "for"; - + case SLcToken_Int: return "int"; - + case SLcToken_Var: return "var"; - + case SLcToken_At: return "at"; - + case SLcToken_If: return "if"; - + case SLcToken_EOF: return "EOF"; - + default: UUmAssert(0); return "Unknown"; diff --git a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Token.h b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Token.h index 690722e..c8a750f 100644 --- a/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Token.h +++ b/BungieFrameWork/BFW_Source/BFW_ScriptLang/BFW_ScriptLang_Token.h @@ -1,13 +1,13 @@ #pragma once /* FILE: BFW_ScriptLang_Token.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 29, 1999 - - PURPOSE: - + + PURPOSE: + Copyright 1999 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Camera.h b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Camera.h index 3ffbfd3..16c7cea 100644 --- a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Camera.h +++ b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Camera.h @@ -1,13 +1,13 @@ #error remove me /* FILE: BFW_Shared_Camera.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 23, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -16,9 +16,9 @@ /* The following is taken directly from OpenGL - + Matrices are currently stored in column major */ - - + + #endif /* BFW_SHARED_CAMERA_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Clip.c b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Clip.c index 8e7aaad..25edc55 100644 --- a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Clip.c +++ b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Clip.c @@ -1,12 +1,12 @@ /* FILE: BFW_Shared_Clip.c - + AUTHOR: Brent H. Pease - + CREATED: Oct 23, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -26,7 +26,7 @@ MSiVerifyPoint4D( UUmAssert(inPoint4D->y > -1e13f && inPoint4D->y < 1e13f); UUmAssert(inPoint4D->z > -1e13f && inPoint4D->z < 1e13f); UUmAssert(inPoint4D->w > -1e13f && inPoint4D->w < 1e13f); - + } void @@ -52,7 +52,7 @@ MSrClipCode_ValidateFrustum( { UUmAssert(inFrustumPoint->x <= inFrustumPoint->w); } - + if(inClipCode & MScClipCode_NegX) { UUmAssert(inFrustumPoint->x < -inFrustumPoint->w); @@ -61,7 +61,7 @@ MSrClipCode_ValidateFrustum( { UUmAssert(inFrustumPoint->x >= -inFrustumPoint->w); } - + if(inClipCode & MScClipCode_PosY) { UUmAssert(inFrustumPoint->y > inFrustumPoint->w); @@ -70,7 +70,7 @@ MSrClipCode_ValidateFrustum( { UUmAssert(inFrustumPoint->y <= inFrustumPoint->w); } - + if(inClipCode & MScClipCode_NegY) { UUmAssert(inFrustumPoint->y < -inFrustumPoint->w); @@ -79,7 +79,7 @@ MSrClipCode_ValidateFrustum( { UUmAssert(inFrustumPoint->y >= -inFrustumPoint->w); } - + if(inClipCode & MScClipCode_PosZ) { UUmAssert(inFrustumPoint->z > inFrustumPoint->w); @@ -88,7 +88,7 @@ MSrClipCode_ValidateFrustum( { UUmAssert(inFrustumPoint->z <= inFrustumPoint->w); } - + if(inClipCode & MScClipCode_NegZ) { UUmAssert(inFrustumPoint->z < 0.0f); @@ -114,7 +114,7 @@ MSrClipCode_ValidateScreen( { UUmAssert(inScreenPoint->x < inScreenWidth); } - + if(inClipCode & MScClipCode_NegX) { UUmAssert(inScreenPoint->x < 0.0f); @@ -123,7 +123,7 @@ MSrClipCode_ValidateScreen( { UUmAssert(inScreenPoint->x >= 0.0f); } - + if(inClipCode & MScClipCode_PosY) { UUmAssert(inScreenPoint->y < 0.0f); @@ -132,7 +132,7 @@ MSrClipCode_ValidateScreen( { UUmAssert(inScreenPoint->y >= 0.0f); } - + if(inClipCode & MScClipCode_NegY) { UUmAssert(inScreenPoint->y >= inScreenHeight); @@ -141,7 +141,7 @@ MSrClipCode_ValidateScreen( { UUmAssert(inScreenPoint->y < inScreenHeight); } - + if(inClipCode & MScClipCode_PosZ) { UUmAssert(inScreenPoint->z >= 1.0f); @@ -150,7 +150,7 @@ MSrClipCode_ValidateScreen( { UUmAssert(inScreenPoint->z < 1.0f); } - + if(inClipCode & MScClipCode_NegZ) { UUmAssert(inScreenPoint->z < 0.0f); diff --git a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Clip.h b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Clip.h index d20a19a..705521f 100644 --- a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Clip.h +++ b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Clip.h @@ -1,12 +1,12 @@ /* FILE: BFW_Shared_Clip.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 23, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -18,19 +18,19 @@ typedef enum MStClipStatus MScClipStatus_TrivialAccept, MScClipStatus_TrivialReject, MScClipStatus_NeedsClipping - + } MStClipStatus; enum { MScClipCode_None = 0, - + MScClipCode_PosX = 0x01, MScClipCode_NegX = 0x02, - + MScClipCode_PosY = 0x04, MScClipCode_NegY = 0x08, - + MScClipCode_PosZ = 0x10, MScClipCode_NegZ = 0x20 }; @@ -63,13 +63,13 @@ enum UUtUns32 inClipCode); #else - + #define MSiVerifyPoint4D(x) #define MSiVerifyPointScreen(x) - + #define MSrClipCode_ValidateScreen(a, b, c, d) #define MSrClipCode_ValidateFrustum(a, b) - + #endif #endif /* BFW_SHARED_CLIP_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_ClipCompPoint_c.h b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_ClipCompPoint_c.h index 339c79d..85f9e0e 100644 --- a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_ClipCompPoint_c.h +++ b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_ClipCompPoint_c.h @@ -1,12 +1,12 @@ /* FILE: BFW_Shared_ClipCompPoint_c.h - + AUTHOR: Brent H. Pease - + CREATED: May 22, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -15,9 +15,9 @@ !defined(MSmGeomClipCompPoint_4DFunctionName) || \ !defined(MSmGeomClipCompPoint_InterpShading) || \ !defined(MSmGeomClipCompPoint_IsVisible) - + #error some macros have not been defined - + #endif static void @@ -34,49 +34,49 @@ MSmGeomClipCompPoint_4DFunctionName( register float t, oneMinust, wIn, wOut, pIn, pOut, negW, invW; register float hW, hX, hY, hZ; register UUtUns16 curClipCodeValue; - - + + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + MSiVerifyPoint4D(inFrustumPointIn); MSiVerifyPoint4D(inFrustumPointOut); - + switch(inClipPlane) { case MScClipCode_PosX: UUmAssert(inFrustumPointIn->x <= inFrustumPointIn->w); UUmAssert(inFrustumPointOut->x > inFrustumPointOut->w); break; - + case MScClipCode_NegX: UUmAssert(inFrustumPointIn->x >= -inFrustumPointIn->w); UUmAssert(inFrustumPointOut->x < -inFrustumPointOut->w); break; - + case MScClipCode_PosY: UUmAssert(inFrustumPointIn->y <= inFrustumPointIn->w); UUmAssert(inFrustumPointOut->y > inFrustumPointOut->w); break; - + case MScClipCode_NegY: UUmAssert(inFrustumPointIn->y >= -inFrustumPointIn->w); UUmAssert(inFrustumPointOut->y < -inFrustumPointOut->w); break; - + case MScClipCode_PosZ: UUmAssert(inFrustumPointIn->z <= inFrustumPointIn->w); UUmAssert(inFrustumPointOut->z > inFrustumPointOut->w); break; - + case MScClipCode_NegZ: UUmAssert(inFrustumPointIn->z >= 0.0); UUmAssert(inFrustumPointOut->z < 0.0); break; - + } - + #endif - + wIn = inFrustumPointIn->w; wOut = inFrustumPointOut->w; @@ -85,7 +85,7 @@ MSmGeomClipCompPoint_4DFunctionName( case MScClipCode_PosX: pIn = inFrustumPointIn->x; pOut = inFrustumPointOut->x; - + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); oneMinust = (1.0f - t); @@ -93,109 +93,109 @@ MSmGeomClipCompPoint_4DFunctionName( UUmAssert(t >= -1.0f); hX = hW = t * inFrustumPointOut->w + oneMinust * inFrustumPointIn->w; - + hY = t * inFrustumPointOut->y + oneMinust * inFrustumPointIn->y; - + hZ = t * inFrustumPointOut->z + oneMinust * inFrustumPointIn->z; break; - + case MScClipCode_NegX: pIn = inFrustumPointIn->x; pOut = inFrustumPointOut->x; - + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); oneMinust = (1.0f - t); - + UUmAssert(t <= 1.0f); UUmAssert(t >= -1.0f); hW = t * inFrustumPointOut->w + oneMinust * inFrustumPointIn->w; - + hY = t * inFrustumPointOut->y + oneMinust * inFrustumPointIn->y; - + hX = -hW; - + hZ = t * inFrustumPointOut->z + oneMinust * inFrustumPointIn->z; break; - + case MScClipCode_PosY: pIn = inFrustumPointIn->y; pOut = inFrustumPointOut->y; t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); oneMinust = (1.0f - t); - + UUmAssert(t <= 1.0f); UUmAssert(t >= -1.0f); hY = hW = t * inFrustumPointOut->w + oneMinust * inFrustumPointIn->w; - + hX = t * inFrustumPointOut->x + oneMinust * inFrustumPointIn->x; - + hZ = t * inFrustumPointOut->z + oneMinust * inFrustumPointIn->z; break; - + case MScClipCode_NegY: pIn = inFrustumPointIn->y; pOut = inFrustumPointOut->y; t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); oneMinust = (1.0f - t); - + UUmAssert(t <= 1.0f); UUmAssert(t >= -1.0f); hW = t * inFrustumPointOut->w + oneMinust * inFrustumPointIn->w; - + hY = -hW; - + hX = t * inFrustumPointOut->x + oneMinust * inFrustumPointIn->x; - + hZ = t * inFrustumPointOut->z + oneMinust * inFrustumPointIn->z; break; - + case MScClipCode_PosZ: pIn = inFrustumPointIn->z; pOut = inFrustumPointOut->z; t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); oneMinust = (1.0f - t); - + UUmAssert(t <= 1.0f); UUmAssert(t >= -1.0f); hW = t * inFrustumPointOut->w + oneMinust * inFrustumPointIn->w; - + hX = t * inFrustumPointOut->x + oneMinust * inFrustumPointIn->x; - + hY = t * inFrustumPointOut->y + oneMinust * inFrustumPointIn->y; - + hZ = hW; break; - + case MScClipCode_NegZ: pIn = inFrustumPointIn->z; pOut = inFrustumPointOut->z; t = pIn / (pIn - pOut); oneMinust = (1.0f - t); - + UUmAssert(t <= 1.0f); UUmAssert(t >= -1.0f); hW = t * inFrustumPointOut->w + oneMinust * inFrustumPointIn->w; - + hX = t * inFrustumPointOut->x + oneMinust * inFrustumPointIn->x; - + hY = t * inFrustumPointOut->y + oneMinust * inFrustumPointIn->y; - + hZ = 0.0; break; - + default: UUmAssert(!"Illegal code"); } - + negW = -hW; - + curClipCodeValue = MScClipCode_None; - + if(hX > hW) { curClipCodeValue |= MScClipCode_PosX; @@ -220,24 +220,24 @@ MSmGeomClipCompPoint_4DFunctionName( { curClipCodeValue |= MScClipCode_NegZ; } - + inResultFrustumPoint->x = hX; inResultFrustumPoint->y = hY; inResultFrustumPoint->z = hZ; inResultFrustumPoint->w = hW; - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + MSrClipCode_ValidateFrustum( inResultFrustumPoint, curClipCodeValue); - + #endif - + if(curClipCodeValue == 0) { invW = 1.0f / hW; - + if(hX == negW) { inResultScreenPoint->x = 0.0f; @@ -246,7 +246,7 @@ MSmGeomClipCompPoint_4DFunctionName( { inResultScreenPoint->x = (hX * invW + 1.0f) * inScaleX; } - + if(hY == hW) { inResultScreenPoint->y = 0.0f; @@ -255,16 +255,16 @@ MSmGeomClipCompPoint_4DFunctionName( { inResultScreenPoint->y = (hY * invW - 1.0f) * inScaleY; } - + UUmAssert(inResultScreenPoint->y >= 0.0f); UUmAssert(inResultScreenPoint->y < 480.0f); - + inResultScreenPoint->z = hZ * invW; inResultScreenPoint->invW = invW; - + MSiVerifyPointScreen(inResultScreenPoint); } - + *inResultClipCode = curClipCodeValue; } @@ -284,41 +284,41 @@ MSmGeomClipCompPoint_3DFunctionName( float wIn, wOut, wNew; float t; UUtUns16 clipCodeNew; - + // XXX - Eventually handle W - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + MSiVerifyPointScreen(inScreenPointIn); MSiVerifyPointScreen(inScreenPointOut); - + switch(inClipPlane) { case MScClipCode_PosX: UUmAssert(inScreenPointIn->x < inScreenWidth); UUmAssert(inScreenPointOut->x >= inScreenWidth); break; - + case MScClipCode_NegX: UUmAssert(inScreenPointIn->x >= 0.0); UUmAssert(inScreenPointOut->x < 0.0); break; - + case MScClipCode_PosY: UUmAssert(inScreenPointIn->y >= 0.0); UUmAssert(inScreenPointOut->y < 0.0); break; - + case MScClipCode_NegY: UUmAssert(inScreenPointIn->y < inScreenHeight); UUmAssert(inScreenPointOut->y >= inScreenHeight); break; - + case MScClipCode_PosZ: UUmAssert(inScreenPointIn->z < 1.0); UUmAssert(inScreenPointOut->z >= 1.0); break; - + case MScClipCode_NegZ: UUmAssert(inScreenPointIn->z >= 0.0); UUmAssert(inScreenPointOut->z < 0.0); @@ -334,7 +334,7 @@ MSmGeomClipCompPoint_3DFunctionName( yOut = inScreenPointOut->y; zOut = inScreenPointOut->z; wOut = 1.0f / inScreenPointOut->invW; - + switch(inClipPlane) { case MScClipCode_PosX: @@ -344,7 +344,7 @@ MSmGeomClipCompPoint_3DFunctionName( xNew = inScreenWidth - 0.0001f; // fudge it in a little; wNew = wIn + t * (wOut - wIn); break; - + case MScClipCode_NegX: t = (0.0f - xOut) / (xIn - xOut); yNew = yOut + t * (yIn - yOut); @@ -352,7 +352,7 @@ MSmGeomClipCompPoint_3DFunctionName( xNew = 0.0; wNew = wOut + t * (wIn - wOut); break; - + case MScClipCode_PosY: t = (0.0f - yOut) / (yIn - yOut); xNew = xOut + t * (xIn - xOut); @@ -360,7 +360,7 @@ MSmGeomClipCompPoint_3DFunctionName( yNew = 0.0; wNew = wOut + t * (wIn - wOut); break; - + case MScClipCode_NegY: t = (inScreenHeight - yIn) / (yOut - yIn); xNew = xIn + t * (xOut - xIn); @@ -368,7 +368,7 @@ MSmGeomClipCompPoint_3DFunctionName( yNew = inScreenHeight - 0.0001f; // fudge it in a little; wNew = wIn + t * (wOut - wIn); break; - + case MScClipCode_PosZ: t = (1.0f - zIn) / (zOut - zIn); xNew = xIn + t * (xOut - xIn); @@ -376,7 +376,7 @@ MSmGeomClipCompPoint_3DFunctionName( zNew = 0.9999f; // fudge it in a little; wNew = wIn + t * (wOut - wIn); break; - + case MScClipCode_NegZ: t = (0.0f - zOut) / (zIn - zOut); xNew = xOut + t * (xIn - xOut); @@ -384,57 +384,57 @@ MSmGeomClipCompPoint_3DFunctionName( zNew = 0.0; wNew = wOut + t * (wIn - wOut); break; - + default: UUmAssert("Illegal clip plane"); } - + clipCodeNew = 0; - + if(xNew < 0.0f) { clipCodeNew |= MScClipCode_NegX; } - + if(xNew >= inScreenWidth) { clipCodeNew |= MScClipCode_PosX; } - + if(yNew < 0.0f) { clipCodeNew |= MScClipCode_PosY; // This is not a bug } - + if(yNew >= inScreenHeight) { clipCodeNew |= MScClipCode_NegY; // This is not a bug } - + if(zNew >= 1.0f) { clipCodeNew |= MScClipCode_PosZ; } - + if(zNew < 0.0f) { clipCodeNew |= MScClipCode_NegZ; } - + *inResultClipCode = clipCodeNew; - + inResultScreenPoint->x = xNew; inResultScreenPoint->y = yNew; inResultScreenPoint->z = zNew; inResultScreenPoint->invW = 1.0f / wNew; - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + MSrClipCode_ValidateScreen( inResultScreenPoint, clipCodeNew, inScreenWidth, inScreenHeight); - + #endif } diff --git a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_ClipPoly_c.h b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_ClipPoly_c.h index 39bf77a..1ac3655 100644 --- a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_ClipPoly_c.h +++ b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_ClipPoly_c.h @@ -1,16 +1,16 @@ /* FILE: BFW_Shared_ClipPoly_c.h - + AUTHOR: Brent H. Pease - + CREATED: May 22, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 - + NOTE - + THIS CODE IS ONE UGLY PIECE OF HACKED UP SHIT */ @@ -32,9 +32,9 @@ !defined(MSmGeomClipPoly_BlockFrustum) || \ !defined(MSmGeomClipPoly_CheckFrustum) || \ !defined(MSmGeomClipPoly_SplitTexturePoint) - + #error some macros have not been defined - + #endif #undef MSmGeomClipPoly_ReturnValue @@ -51,23 +51,23 @@ #undef MSmGeomClipPoly_QuadContinueClipping #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + #define MSmGeomClipPoly_Finished_Debug() gClipNesting--; UUmAssert(gClipNesting >= 0) - + #else - + #define MSmGeomClipPoly_Finished_Debug() - + #endif #if MSmGeomClipPoly_BlockFrustum - + #define MSmGeomClipPoly_ReturnValue static void #define MSmGeomClipPoly_BufferWidth (float)(contextPrivate->width) #define MSmGeomClipPoly_BufferHeight (float)(contextPrivate->height) #define MSmGeomClipPoly_ContextType M3tGeomContext - + #define MSmGeomClipPoly_TriFinished( \ index0, index1, index2, \ texIndex0, texIndex1, texIndex2) \ @@ -86,7 +86,7 @@ M3rDraw_VisPentBlock( \ inContext->drawContext, \ index0, index1, index2, index3, index4); - + #define MSmGeomClipPoly_TriContinueClipping( \ index0, index1, index2, \ texIndex0, texIndex1, texIndex2, \ @@ -98,7 +98,7 @@ index0, index1, index2, \ clipCode0, clipCode1, clipCode2, \ clippedPlanes); - + #define MSmGeomClipPoly_QuadContinueClipping( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3, \ @@ -110,17 +110,17 @@ index0, index1, index2, index3, \ clipCode0, clipCode1, clipCode2, clipCode3, \ clippedPlanes); - + #define MSmGeomClipPoly_Return MSmGeomClipPoly_Finished_Debug(); return #elif MSmGeomClipPoly_CheckFrustum - + #define MSmGeomClipPoly_ReturnValue static UUtBool #define MSmGeomClipPoly_BufferWidth (float)(contextPrivate->width) #define MSmGeomClipPoly_BufferHeight (float)(contextPrivate->height) #define MSmGeomClipPoly_ContextType M3tGeomContext - + #define MSmGeomClipPoly_TriFinished( \ index0, index1, index2, \ texIndex0, texIndex1, texIndex2) \ @@ -139,7 +139,7 @@ if(M3rDraw_VisPentCheck( \ inContext->drawContext, \ index0, index1, index2, index3, index4) == UUcTrue) return UUcTrue; - + #define MSmGeomClipPoly_TriContinueClipping( \ index0, index1, index2, \ texIndex0, texIndex1, texIndex2, \ @@ -151,7 +151,7 @@ index0, index1, index2, \ clipCode0, clipCode1, clipCode2, \ clippedPlanes) == UUcTrue) return UUcTrue; - + #define MSmGeomClipPoly_QuadContinueClipping( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3, \ @@ -163,16 +163,16 @@ index0, index1, index2, index3, \ clipCode0, clipCode1, clipCode2, clipCode3, \ clippedPlanes) == UUcTrue) return UUcTrue; - + #define MSmGeomClipPoly_Return MSmGeomClipPoly_Finished_Debug(); return UUcFalse; #elif MSmGeomClipPoly_BBox - + #define MSmGeomClipPoly_ReturnValue static void #define MSmGeomClipPoly_BufferWidth (float)(contextPrivate->width) #define MSmGeomClipPoly_BufferHeight (float)(contextPrivate->height) #define MSmGeomClipPoly_ContextType M3tGeomContext - + #define MSmGeomClipPoly_TriFinished( \ index0, index1, index2, \ texIndex0, texIndex1, texIndex2) \ @@ -194,7 +194,7 @@ MSiVis_Block_ClipFrustum_Tri( \ inContext, \ index0, index3, index4) - + #define MSmGeomClipPoly_TriContinueClipping( \ index0, index1, index2, \ texIndex0, texIndex1, texIndex2, \ @@ -206,7 +206,7 @@ index0, index1, index2, \ clipCode0, clipCode1, clipCode2, \ clippedPlanes); - + #define MSmGeomClipPoly_QuadContinueClipping( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3, \ @@ -218,37 +218,37 @@ index0, index1, index2, index3, \ clipCode0, clipCode1, clipCode2, clipCode3, \ clippedPlanes); - + #define MSmGeomClipPoly_Return MSmGeomClipPoly_Finished_Debug(); return - + #else #define MSmGeomClipPoly_ReturnValue void #define MSmGeomClipPoly_BufferWidth (float)(contextPrivate->width) #define MSmGeomClipPoly_BufferHeight (float)(contextPrivate->height) #define MSmGeomClipPoly_ContextType M3tGeomContext - + #if MSmGeomClipPoly_InterpShading - + #define MSmGeomClipPoly_TriFinished( \ index0, index1, index2, \ texIndex0, texIndex1, texIndex2) \ M3rDraw_TriInterpolate( \ inContext->drawContext, \ - index0, index1, index2) + index0, index1, index2) #define MSmGeomClipPoly_QuadFinished( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ M3rDraw_QuadInterpolate( \ inContext->drawContext, \ - index0, index1, index2, index3) + index0, index1, index2, index3) #define MSmGeomClipPoly_PentFinished( \ index0, index1, index2, index3, index4, \ texIndex0, texIndex1, texIndex2, texIndex3, texIndex4) \ M3rDraw_PentInterpolate( \ inContext->drawContext, \ - index0, index1, index2, index3, index4) - + index0, index1, index2, index3, index4) + #define MSmGeomClipPoly_TriContinueClipping( \ index0, index1, index2, \ texIndex0, texIndex1, texIndex2, \ @@ -271,31 +271,31 @@ clippedPlanes) #else - + #if MSmGeomClipPoly_SplitTexturePoint - + #define MSmGeomClipPoly_TriFinished( \ index0, index1, index2, \ texIndex0, texIndex1, texIndex2) \ M3rDraw_TriSplit( \ inContext->drawContext, \ index0, index1, index2, \ - texIndex0, texIndex1, texIndex2) + texIndex0, texIndex1, texIndex2) #define MSmGeomClipPoly_QuadFinished( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ M3rDraw_QuadSplit( \ inContext->drawContext, \ index0, index1, index2, index3, \ - texIndex0, texIndex1, texIndex2, texIndex3) + texIndex0, texIndex1, texIndex2, texIndex3) #define MSmGeomClipPoly_PentFinished( \ index0, index1, index2, index3, index4, \ texIndex0, texIndex1, texIndex2, texIndex3, texIndex4) \ M3rDraw_PentSplit( \ inContext->drawContext, \ index0, index1, index2, index3, index4, \ - texIndex0, texIndex1, texIndex2, texIndex3, texIndex4) - + texIndex0, texIndex1, texIndex2, texIndex3, texIndex4) + #define MSmGeomClipPoly_TriContinueClipping( \ index0, index1, index2, \ texIndex0, texIndex1, texIndex2, \ @@ -319,26 +319,26 @@ clipCode0, clipCode1, clipCode2, clipCode3, \ clippedPlanes) #else - + #define MSmGeomClipPoly_TriFinished( \ index0, index1, index2, \ texIndex0, texIndex1, texIndex2) \ M3rDraw_TriFlat( \ inContext->drawContext, \ - index0, index1, index2, inShade) + index0, index1, index2, inShade) #define MSmGeomClipPoly_QuadFinished( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ M3rDraw_QuadFlat( \ inContext->drawContext, \ - index0, index1, index2, index3, inShade) + index0, index1, index2, index3, inShade) #define MSmGeomClipPoly_PentFinished( \ index0, index1, index2, index3, index4, \ texIndex0, texIndex1, texIndex2, texIndex3, texIndex4) \ M3rDraw_PentFlat( \ inContext->drawContext, \ - index0, index1, index2, index3, index4, inShade) - + index0, index1, index2, index3, index4, inShade) + #define MSmGeomClipPoly_TriContinueClipping( \ index0, index1, index2, \ texIndex0, texIndex1, texIndex2, \ @@ -362,11 +362,11 @@ clippedPlanes, \ inShade) #endif - + #endif - + #define MSmGeomClipPoly_Return MSmGeomClipPoly_Finished_Debug(); return - + #endif #undef MSmGeomClipPoly_CheckTrivialAcceptTri @@ -409,7 +409,7 @@ texIndex0, texIndex1, texIndex2, texIndex3, \ clipCode0, clipCode1, clipCode2, clipCode3, \ (UUtUns16)(clippedPlanes)); \ - } + } #undef MSmGeomClipPoly_CheckTrivialAcceptPent #define MSmGeomClipPoly_CheckTrivialAcceptPent( \ @@ -468,7 +468,7 @@ #define MSmGeomClipPoly_VerifyTrivialRejectQuad(clipCode0, clipCode1, clipCode2, clipCode3) #undef MSmGeomClipPoly_VerifyTrivialRejectPent #define MSmGeomClipPoly_VerifyTrivialRejectPent(clipCode0, clipCode1, clipCode2, clipCode3, clipCode4) - + #endif #undef MSmGeomClipPoly_ComputeNewClipPoints @@ -476,7 +476,7 @@ #if MSmGeomClipPoly_4D #if MSmGeomClipPoly_BlockFrustum || MSmGeomClipPoly_CheckFrustum - + #define MSmGeomClipPoly_ComputeNewClipPoints( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ @@ -502,11 +502,11 @@ &newClipCode1); #elif MSmGeomClipPoly_TextureMap - + #if MSmGeomClipPoly_SplitTexturePoint - + #if MSmGeomClipPoly_InterpShading - + #define MSmGeomClipPoly_ComputeNewClipPoints( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ @@ -542,7 +542,7 @@ &newClipCode1); #else - + #define MSmGeomClipPoly_ComputeNewClipPoints( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ @@ -574,13 +574,13 @@ scaleX, \ scaleY, \ &newClipCode1); - + #endif - + #else - + #if MSmGeomClipPoly_InterpShading - + #define MSmGeomClipPoly_ComputeNewClipPoints( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ @@ -608,9 +608,9 @@ scaleX, \ scaleY, \ &newClipCode1); - + #else - + #define MSmGeomClipPoly_ComputeNewClipPoints( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ @@ -636,21 +636,21 @@ scaleX, \ scaleY, \ &newClipCode1); - + #endif - + #endif - + #else - + #if MSmGeomClipPoly_SplitTexturePoint - + #error What? - + #endif - + #if MSmGeomClipPoly_InterpShading - + #define MSmGeomClipPoly_ComputeNewClipPoints( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ @@ -676,9 +676,9 @@ scaleX, \ scaleY, \ &newClipCode1); - + #else - + #define MSmGeomClipPoly_ComputeNewClipPoints( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ @@ -702,9 +702,9 @@ scaleX, \ scaleY, \ &newClipCode1); - + #endif - + #endif #elif MSmGeomClipPoly_BBox @@ -732,15 +732,15 @@ #else #if MSmGeomClipPoly_TextureMap - + #if MSmGeomClipPoly_SplitTexturePoint - + #if MSmGeomClipPoly_InterpShading - + #error - + #endif - + #define MSmGeomClipPoly_ComputeNewClipPoints( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ @@ -770,11 +770,11 @@ MSmGeomClipPoly_BufferWidth, \ MSmGeomClipPoly_BufferHeight, \ &newClipCode1); - + #else - + #if MSmGeomClipPoly_InterpShading - + #define MSmGeomClipPoly_ComputeNewClipPoints( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ @@ -800,9 +800,9 @@ MSmGeomClipPoly_BufferWidth, \ MSmGeomClipPoly_BufferHeight, \ &newClipCode1); - + #else - + #define MSmGeomClipPoly_ComputeNewClipPoints( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ @@ -826,22 +826,22 @@ MSmGeomClipPoly_BufferWidth, \ MSmGeomClipPoly_BufferHeight, \ &newClipCode1); - + #endif - + #endif - + #else - + #if MSmGeomClipPoly_SplitTexturePoint - + #error what? - + #endif - - + + #if MSmGeomClipPoly_InterpShading - + #define MSmGeomClipPoly_ComputeNewClipPoints( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ @@ -865,9 +865,9 @@ MSmGeomClipPoly_BufferWidth, \ MSmGeomClipPoly_BufferHeight, \ &newClipCode1); - + #else - + #define MSmGeomClipPoly_ComputeNewClipPoints( \ index0, index1, index2, index3, \ texIndex0, texIndex1, texIndex2, texIndex3) \ @@ -889,54 +889,54 @@ MSmGeomClipPoly_BufferWidth, \ MSmGeomClipPoly_BufferHeight, \ &newClipCode1); - + #endif - + #endif - + #endif static void MSmGeomClipPoly_ClipPointFunctionName( - + #if MSmGeomClipPoly_BBox - + M3tPoint3D* inWorldPoints, M3tBoundingBox_MinMax* inBBox, - + #else - + M3tPointScreen* inScreenPoints, - + #endif - + #if MSmGeomClipPoly_InterpShading - + UUtUns16* inScreenShades, - + #endif - + #if MSmGeomClipPoly_4D - + M3tPoint4D* inFrustumPoints, #endif - + #if MSmGeomClipPoly_TextureMap - + #if 0//MSmGeomClipPoly_SplitTexturePoint - + M3tEnvTextureCoord* inTextureCoords, - + #else - + M3tTextureCoord* inTextureCoords, - + #endif - + #endif - + UUtUns16 inClipPlane, UUtUns16 inIndexIn, UUtUns16 inIndexOut, @@ -951,63 +951,63 @@ MSmGeomClipPoly_ClipPointFunctionName( UUtUns16 inTexIndexIn, UUtUns16 inTexIndexOut, UUtUns16 inTexIndexNew, - + #else #define inTexIndexIn inIndexIn #define inTexIndexOut inIndexOut #define inTexIndexNew inIndexNew - + #endif - + #if !MSmGeomClipPoly_BBox - + float inXFactor, float inYFactor, - + #endif - + UUtUns16 *outClipCodeNew) { UUtUns16 newClipCode; - + #if MSmGeomClipPoly_4D - + float oneMinust, pIn, pOut, negW, invW; float hW, hX, hY, hZ; - + #else - + float xIn, xOut, xNew; float yIn, yOut, yNew; float zIn, zOut, zNew; - + #if !MSmGeomClipPoly_BBox - + float wNew; #endif - + #endif - + #if MSmGeomClipPoly_InterpShading - + UUtUns16 shadeIn, shadeOut; float rOut, gOut, bOut; float rIn, gIn, bIn; float rNew, gNew, bNew; - + #endif - + #if !MSmGeomClipPoly_BBox - + float wIn, wOut; - + #endif - + float t; - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + if(gClipDumping) { fprintf(gClipFile, "Entering %s\n", UUmStringize(MSmGeomClipPoly_ClipPointFunctionName)); @@ -1018,16 +1018,16 @@ MSmGeomClipPoly_ClipPointFunctionName( MSiDump_ClipCodes(gClipFile, inClipPlane); fprintf(gClipFile, "\n"); } - + #endif - + #if MSmGeomClipPoly_4D - + MSiVerifyPoint4D(inFrustumPoints + inIndexIn); MSiVerifyPoint4D(inFrustumPoints + inIndexOut); - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + if(gClipDumping) { fprintf(gClipFile, "\tinFrust: (%f, %f, %f, %f)\n", @@ -1041,138 +1041,138 @@ MSmGeomClipPoly_ClipPointFunctionName( (inFrustumPoints + inIndexOut)->z, (inFrustumPoints + inIndexOut)->w); } - + #endif - + wIn = (inFrustumPoints + inIndexIn)->w; wOut = (inFrustumPoints + inIndexOut)->w; - - switch(inClipPlane) - { - case MScClipCode_PosX: - UUmAssert((inFrustumPoints + inIndexIn)->x <= (inFrustumPoints + inIndexIn)->w); - UUmAssert((inFrustumPoints + inIndexOut)->x > (inFrustumPoints + inIndexOut)->w); - - pIn = (inFrustumPoints + inIndexIn)->x; - pOut = (inFrustumPoints + inIndexOut)->x; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + + switch(inClipPlane) + { + case MScClipCode_PosX: + UUmAssert((inFrustumPoints + inIndexIn)->x <= (inFrustumPoints + inIndexIn)->w); + UUmAssert((inFrustumPoints + inIndexOut)->x > (inFrustumPoints + inIndexOut)->w); + + pIn = (inFrustumPoints + inIndexIn)->x; + pOut = (inFrustumPoints + inIndexOut)->x; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert(t <= 1.0f); - UUmAssert(t >= -1.0f); + UUmAssert(t >= -1.0f); hX = hW = t * (inFrustumPoints + inIndexOut)->w + oneMinust * (inFrustumPoints + inIndexIn)->w; hY = t * (inFrustumPoints + inIndexOut)->y + oneMinust * (inFrustumPoints + inIndexIn)->y; hZ = t * (inFrustumPoints + inIndexOut)->z + oneMinust * (inFrustumPoints + inIndexIn)->z; - break; - - case MScClipCode_NegX: - UUmAssert((inFrustumPoints + inIndexIn)->x >= -(inFrustumPoints + inIndexIn)->w); - UUmAssert((inFrustumPoints + inIndexOut)->x < -(inFrustumPoints + inIndexOut)->w); - - pIn = (inFrustumPoints + inIndexIn)->x; - pOut = (inFrustumPoints + inIndexOut)->x; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_NegX: + UUmAssert((inFrustumPoints + inIndexIn)->x >= -(inFrustumPoints + inIndexIn)->w); + UUmAssert((inFrustumPoints + inIndexOut)->x < -(inFrustumPoints + inIndexOut)->w); + + pIn = (inFrustumPoints + inIndexIn)->x; + pOut = (inFrustumPoints + inIndexOut)->x; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert(t <= 1.0f); - UUmAssert(t >= -1.0f); + UUmAssert(t >= -1.0f); hW = t * (inFrustumPoints + inIndexOut)->w + oneMinust * (inFrustumPoints + inIndexIn)->w; hY = t * (inFrustumPoints + inIndexOut)->y + oneMinust * (inFrustumPoints + inIndexIn)->y; - hX = -hW; + hX = -hW; hZ = t * (inFrustumPoints + inIndexOut)->z + oneMinust * (inFrustumPoints + inIndexIn)->z; - break; - - case MScClipCode_PosY: - UUmAssert((inFrustumPoints + inIndexIn)->y <= (inFrustumPoints + inIndexIn)->w); - UUmAssert((inFrustumPoints + inIndexOut)->y > (inFrustumPoints + inIndexOut)->w); - - pIn = (inFrustumPoints + inIndexIn)->y; - pOut = (inFrustumPoints + inIndexOut)->y; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosY: + UUmAssert((inFrustumPoints + inIndexIn)->y <= (inFrustumPoints + inIndexIn)->w); + UUmAssert((inFrustumPoints + inIndexOut)->y > (inFrustumPoints + inIndexOut)->w); + + pIn = (inFrustumPoints + inIndexIn)->y; + pOut = (inFrustumPoints + inIndexOut)->y; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert(t <= 1.0f); - UUmAssert(t >= -1.0f); + UUmAssert(t >= -1.0f); hY = hW = t * (inFrustumPoints + inIndexOut)->w + oneMinust * (inFrustumPoints + inIndexIn)->w; hX = t * (inFrustumPoints + inIndexOut)->x + oneMinust * (inFrustumPoints + inIndexIn)->x; hZ = t * (inFrustumPoints + inIndexOut)->z + oneMinust * (inFrustumPoints + inIndexIn)->z; break; - - case MScClipCode_NegY: - UUmAssert((inFrustumPoints + inIndexIn)->y >= -(inFrustumPoints + inIndexIn)->w); - UUmAssert((inFrustumPoints + inIndexOut)->y < -(inFrustumPoints + inIndexOut)->w); - - pIn = (inFrustumPoints + inIndexIn)->y; - pOut = (inFrustumPoints + inIndexOut)->y; - t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); - oneMinust = (1.0f - t); + + case MScClipCode_NegY: + UUmAssert((inFrustumPoints + inIndexIn)->y >= -(inFrustumPoints + inIndexIn)->w); + UUmAssert((inFrustumPoints + inIndexOut)->y < -(inFrustumPoints + inIndexOut)->w); + + pIn = (inFrustumPoints + inIndexIn)->y; + pOut = (inFrustumPoints + inIndexOut)->y; + t = (pIn + wIn) / ((pIn - pOut) + (wIn - wOut)); + oneMinust = (1.0f - t); UUmAssert(t <= 1.0f); - UUmAssert(t >= -1.0f); + UUmAssert(t >= -1.0f); hW = t * (inFrustumPoints + inIndexOut)->w + oneMinust * (inFrustumPoints + inIndexIn)->w; - hY = -hW; + hY = -hW; hX = t * (inFrustumPoints + inIndexOut)->x + oneMinust * (inFrustumPoints + inIndexIn)->x; hZ = t * (inFrustumPoints + inIndexOut)->z + oneMinust * (inFrustumPoints + inIndexIn)->z; - break; - - case MScClipCode_PosZ: - UUmAssert((inFrustumPoints + inIndexIn)->z <= (inFrustumPoints + inIndexIn)->w); - UUmAssert((inFrustumPoints + inIndexOut)->z > (inFrustumPoints + inIndexOut)->w); - - pIn = (inFrustumPoints + inIndexIn)->z; - pOut = (inFrustumPoints + inIndexOut)->z; - t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); - oneMinust = (1.0f - t); + break; + + case MScClipCode_PosZ: + UUmAssert((inFrustumPoints + inIndexIn)->z <= (inFrustumPoints + inIndexIn)->w); + UUmAssert((inFrustumPoints + inIndexOut)->z > (inFrustumPoints + inIndexOut)->w); + + pIn = (inFrustumPoints + inIndexIn)->z; + pOut = (inFrustumPoints + inIndexOut)->z; + t = (wIn - pIn) / ((pOut - pIn) - (wOut - wIn)); + oneMinust = (1.0f - t); UUmAssert(t <= 1.0f); - UUmAssert(t >= -1.0f); + UUmAssert(t >= -1.0f); hW = t * (inFrustumPoints + inIndexOut)->w + oneMinust * (inFrustumPoints + inIndexIn)->w; hX = t * (inFrustumPoints + inIndexOut)->x + oneMinust * (inFrustumPoints + inIndexIn)->x; hY = t * (inFrustumPoints + inIndexOut)->y + oneMinust * (inFrustumPoints + inIndexIn)->y; - hZ = hW; - break; - - case MScClipCode_NegZ: - UUmAssert((inFrustumPoints + inIndexIn)->z >= 0.0f); - UUmAssert((inFrustumPoints + inIndexOut)->z < 0.0f); - - pIn = (inFrustumPoints + inIndexIn)->z; - pOut = (inFrustumPoints + inIndexOut)->z; - t = pIn / (pIn - pOut); - oneMinust = (1.0f - t); + hZ = hW; + break; + + case MScClipCode_NegZ: + UUmAssert((inFrustumPoints + inIndexIn)->z >= 0.0f); + UUmAssert((inFrustumPoints + inIndexOut)->z < 0.0f); + + pIn = (inFrustumPoints + inIndexIn)->z; + pOut = (inFrustumPoints + inIndexOut)->z; + t = pIn / (pIn - pOut); + oneMinust = (1.0f - t); UUmAssert(t <= 1.0f); - UUmAssert(t >= -1.0f); + UUmAssert(t >= -1.0f); hW = t * (inFrustumPoints + inIndexOut)->w + oneMinust * (inFrustumPoints + inIndexIn)->w; hX = t * (inFrustumPoints + inIndexOut)->x + oneMinust * (inFrustumPoints + inIndexIn)->x; hY = t * (inFrustumPoints + inIndexOut)->y + oneMinust * (inFrustumPoints + inIndexIn)->y; - hZ = 0.0f; - break; + hZ = 0.0f; + break; } - + #if MSmGeomClipPoly_InterpShading - + // XXX - optimize this someday shadeOut = *(inScreenShades + inIndexOut); shadeIn = *(inScreenShades + inIndexIn); - + rOut = (float)((shadeOut >> 10) & 0x1F); gOut = (float)((shadeOut >> 5) & 0x1F); bOut = (float)((shadeOut >> 0) & 0x1F); - + rIn = (float)((shadeIn >> 10) & 0x1F); gIn = (float)((shadeIn >> 5) & 0x1F); bIn = (float)((shadeIn >> 0) & 0x1F); - + rNew = t * rOut + oneMinust * rIn; gNew = t * gOut + oneMinust * gIn; bNew = t * bOut + oneMinust * bIn; - - *(inScreenShades + inIndexNew) = + + *(inScreenShades + inIndexNew) = ((UUtUns16)rNew << 10) | ((UUtUns16)gNew << 5) | ((UUtUns16)bNew << 0); - + #endif - + #if MSmGeomClipPoly_TextureMap - + #if MSmGeomClipPoly_SplitTexturePoint - + inTexIndexNew <<= 1; inTexIndexOut <<= 1; inTexIndexIn <<= 1; @@ -1183,56 +1183,56 @@ MSmGeomClipPoly_ClipPointFunctionName( inTexIndexIn += 1; (inTextureCoords + inTexIndexNew)->u = t * (inTextureCoords + inTexIndexOut)->u + oneMinust * (inTextureCoords + inTexIndexIn)->u; (inTextureCoords + inTexIndexNew)->v = t * (inTextureCoords + inTexIndexOut)->v + oneMinust * (inTextureCoords + inTexIndexIn)->v; - + #else - + (inTextureCoords + inTexIndexNew)->u = t * (inTextureCoords + inTexIndexOut)->u + oneMinust * (inTextureCoords + inTexIndexIn)->u; (inTextureCoords + inTexIndexNew)->v = t * (inTextureCoords + inTexIndexOut)->v + oneMinust * (inTextureCoords + inTexIndexIn)->v; - + #endif - + #endif - + negW = -hW; newClipCode = MScClipCode_None; - + if(hX > hW) { newClipCode |= MScClipCode_PosX; } - + if(hX < negW) { newClipCode |= MScClipCode_NegX; } - + if(hY > hW) { newClipCode |= MScClipCode_PosY; } - + if(hY < negW) { newClipCode |= MScClipCode_NegY; } - + if(hZ > hW) { newClipCode |= MScClipCode_PosZ; } - + if(hZ < 0.0) { newClipCode |= MScClipCode_NegZ; } - + (inFrustumPoints + inIndexNew)->x = hX; (inFrustumPoints + inIndexNew)->y = hY; (inFrustumPoints + inIndexNew)->z = hZ; (inFrustumPoints + inIndexNew)->w = hW; - + MSrClipCode_ValidateFrustum((inFrustumPoints + inIndexNew), newClipCode); - + if(newClipCode == 0) { invW = 1.0f / hW; @@ -1244,7 +1244,7 @@ MSmGeomClipPoly_ClipPointFunctionName( { (inScreenPoints + inIndexNew)->x = (hX * invW + 1.0f) * inXFactor; } - + if(hY == hW) { (inScreenPoints + inIndexNew)->y = 0.0f; @@ -1253,97 +1253,97 @@ MSmGeomClipPoly_ClipPointFunctionName( { (inScreenPoints + inIndexNew)->y = (hY * invW - 1.0f) * inYFactor; } - + (inScreenPoints + inIndexNew)->z = hZ * invW; (inScreenPoints + inIndexNew)->invW = invW; - + MSiVerifyPointScreen((inScreenPoints + inIndexNew)); } - + #elif MSmGeomClipPoly_BBox - - xIn = (inWorldPoints + inIndexIn)->x; - yIn = (inWorldPoints + inIndexIn)->y; - zIn = (inWorldPoints + inIndexIn)->z; - xOut = (inWorldPoints + inIndexOut)->x; - yOut = (inWorldPoints + inIndexOut)->y; - zOut = (inWorldPoints + inIndexOut)->z; - - switch(inClipPlane) - { - case MScClipCode_PosX: -// UUmAssert((inScreenPoints + inIndexIn)->x < inXFactor); -// UUmAssert((inScreenPoints + inIndexOut)->x >= inXFactor); - + + xIn = (inWorldPoints + inIndexIn)->x; + yIn = (inWorldPoints + inIndexIn)->y; + zIn = (inWorldPoints + inIndexIn)->z; + xOut = (inWorldPoints + inIndexOut)->x; + yOut = (inWorldPoints + inIndexOut)->y; + zOut = (inWorldPoints + inIndexOut)->z; + + switch(inClipPlane) + { + case MScClipCode_PosX: +// UUmAssert((inScreenPoints + inIndexIn)->x < inXFactor); +// UUmAssert((inScreenPoints + inIndexOut)->x >= inXFactor); + xNew = inBBox->maxPoint.x; t = (xOut - xNew) / (xOut - xIn); UUmAssert(t >= 0.0f && t <= 1.0f); - yNew = yOut + t * (yIn - yOut); - zNew = zOut + t * (zIn - zOut); - break; - - case MScClipCode_NegX: -// UUmAssert((inScreenPoints + inIndexIn)->x >= 0.0f); -// UUmAssert((inScreenPoints + inIndexOut)->x < 0.0f); - + yNew = yOut + t * (yIn - yOut); + zNew = zOut + t * (zIn - zOut); + break; + + case MScClipCode_NegX: +// UUmAssert((inScreenPoints + inIndexIn)->x >= 0.0f); +// UUmAssert((inScreenPoints + inIndexOut)->x < 0.0f); + xNew = inBBox->minPoint.x; - t = (xNew - xOut) / (xIn - xOut); + t = (xNew - xOut) / (xIn - xOut); UUmAssert(t >= 0.0f && t <= 1.0f); - yNew = yOut + t * (yIn - yOut); - zNew = zOut + t * (zIn - zOut); - break; - - case MScClipCode_PosY: -// UUmAssert((inScreenPoints + inIndexIn)->y >= 0.0f); -// UUmAssert((inScreenPoints + inIndexOut)->y < 0.0f); - + yNew = yOut + t * (yIn - yOut); + zNew = zOut + t * (zIn - zOut); + break; + + case MScClipCode_PosY: +// UUmAssert((inScreenPoints + inIndexIn)->y >= 0.0f); +// UUmAssert((inScreenPoints + inIndexOut)->y < 0.0f); + yNew = inBBox->maxPoint.y; t = (yOut - yNew) / (yOut - yIn); UUmAssert(t >= 0.0f && t <= 1.0f); - xNew = xOut + t * (xIn - xOut); - zNew = zOut + t * (zIn - zOut); - break; - - case MScClipCode_NegY: -// UUmAssert((inScreenPoints + inIndexIn)->y < inYFactor); + xNew = xOut + t * (xIn - xOut); + zNew = zOut + t * (zIn - zOut); + break; + + case MScClipCode_NegY: +// UUmAssert((inScreenPoints + inIndexIn)->y < inYFactor); // UUmAssert((inScreenPoints + inIndexOut)->y >= inYFactor); - + yNew = inBBox->minPoint.y; - t = (yNew - yOut) / (yIn - yOut); + t = (yNew - yOut) / (yIn - yOut); UUmAssert(t >= 0.0f && t <= 1.0f); - xNew = xOut + t * (xIn - xOut); - zNew = zOut + t * (zIn - zOut); - break; - - case MScClipCode_PosZ: -// UUmAssert((inScreenPoints + inIndexIn)->z < 1.0); -// UUmAssert((inScreenPoints + inIndexOut)->z >= 1.0); - + xNew = xOut + t * (xIn - xOut); + zNew = zOut + t * (zIn - zOut); + break; + + case MScClipCode_PosZ: +// UUmAssert((inScreenPoints + inIndexIn)->z < 1.0); +// UUmAssert((inScreenPoints + inIndexOut)->z >= 1.0); + zNew = inBBox->maxPoint.z; t = (zOut - zNew) / (zOut - zIn); UUmAssert(t >= 0.0f && t <= 1.0f); - xNew = xOut + t * (xIn - xOut); - yNew = yOut + t * (yIn - yOut); - break; - - case MScClipCode_NegZ: -// UUmAssert((inScreenPoints + inIndexIn)->z >= 0.0f); -// UUmAssert((inScreenPoints + inIndexOut)->z < 0.0f); - + xNew = xOut + t * (xIn - xOut); + yNew = yOut + t * (yIn - yOut); + break; + + case MScClipCode_NegZ: +// UUmAssert((inScreenPoints + inIndexIn)->z >= 0.0f); +// UUmAssert((inScreenPoints + inIndexOut)->z < 0.0f); + zNew = inBBox->minPoint.z; - t = (zNew - zOut) / (zIn - zOut); + t = (zNew - zOut) / (zIn - zOut); UUmAssert(t >= 0.0f && t <= 1.0f); - xNew = xOut + t * (xIn - xOut); - yNew = yOut + t * (yIn - yOut); - break; + xNew = xOut + t * (xIn - xOut); + yNew = yOut + t * (yIn - yOut); + break; } - - (inWorldPoints + inIndexNew)->x = xNew; - (inWorldPoints + inIndexNew)->y = yNew; - (inWorldPoints + inIndexNew)->z = zNew; - + + (inWorldPoints + inIndexNew)->x = xNew; + (inWorldPoints + inIndexNew)->y = yNew; + (inWorldPoints + inIndexNew)->z = zNew; + newClipCode = 0; - + if(xNew > inBBox->maxPoint.x) { newClipCode |= MScClipCode_PosX; @@ -1352,7 +1352,7 @@ MSmGeomClipPoly_ClipPointFunctionName( { newClipCode |= MScClipCode_NegX; } - + if(yNew > inBBox->maxPoint.y) { newClipCode |= MScClipCode_PosY; @@ -1361,7 +1361,7 @@ MSmGeomClipPoly_ClipPointFunctionName( { newClipCode |= MScClipCode_NegY; } - + if(zNew > inBBox->maxPoint.z) { newClipCode |= MScClipCode_PosZ; @@ -1370,132 +1370,132 @@ MSmGeomClipPoly_ClipPointFunctionName( { newClipCode |= MScClipCode_NegZ; } - + #else - - MSiVerifyPointScreen(inScreenPoints + inIndexIn); - MSiVerifyPointScreen(inScreenPoints + inIndexOut); - - wIn = (inScreenPoints + inIndexIn)->invW; - xIn = (inScreenPoints + inIndexIn)->x; - yIn = (inScreenPoints + inIndexIn)->y; - zIn = (inScreenPoints + inIndexIn)->z; - wOut = (inScreenPoints + inIndexOut)->invW; - xOut = (inScreenPoints + inIndexOut)->x; - yOut = (inScreenPoints + inIndexOut)->y; - zOut = (inScreenPoints + inIndexOut)->z; - - switch(inClipPlane) - { - case MScClipCode_PosX: -// UUmAssert((inScreenPoints + inIndexIn)->x < inXFactor); -// UUmAssert((inScreenPoints + inIndexOut)->x >= inXFactor); - + + MSiVerifyPointScreen(inScreenPoints + inIndexIn); + MSiVerifyPointScreen(inScreenPoints + inIndexOut); + + wIn = (inScreenPoints + inIndexIn)->invW; + xIn = (inScreenPoints + inIndexIn)->x; + yIn = (inScreenPoints + inIndexIn)->y; + zIn = (inScreenPoints + inIndexIn)->z; + wOut = (inScreenPoints + inIndexOut)->invW; + xOut = (inScreenPoints + inIndexOut)->x; + yOut = (inScreenPoints + inIndexOut)->y; + zOut = (inScreenPoints + inIndexOut)->z; + + switch(inClipPlane) + { + case MScClipCode_PosX: +// UUmAssert((inScreenPoints + inIndexIn)->x < inXFactor); +// UUmAssert((inScreenPoints + inIndexOut)->x >= inXFactor); + t = (xOut - inXFactor) / (xOut - xIn); - yNew = yOut + t * (yIn - yOut); - zNew = zOut + t * (zIn - zOut); - xNew = inXFactor - 0.0001f; - wNew = wOut + t * (wIn - wOut); - break; - - case MScClipCode_NegX: -// UUmAssert((inScreenPoints + inIndexIn)->x >= 0.0f); -// UUmAssert((inScreenPoints + inIndexOut)->x < 0.0f); - - t = (0.0f - xOut) / (xIn - xOut); - yNew = yOut + t * (yIn - yOut); - zNew = zOut + t * (zIn - zOut); - xNew = 0.0; - wNew = wOut + t * (wIn - wOut); - break; - - case MScClipCode_PosY: -// UUmAssert((inScreenPoints + inIndexIn)->y >= 0.0f); -// UUmAssert((inScreenPoints + inIndexOut)->y < 0.0f); - - t = (0.0f - yOut) / (yIn - yOut); - xNew = xOut + t * (xIn - xOut); - zNew = zOut + t * (zIn - zOut); - yNew = 0.0; - wNew = wOut + t * (wIn - wOut); - break; - - case MScClipCode_NegY: -// UUmAssert((inScreenPoints + inIndexIn)->y < inYFactor); + yNew = yOut + t * (yIn - yOut); + zNew = zOut + t * (zIn - zOut); + xNew = inXFactor - 0.0001f; + wNew = wOut + t * (wIn - wOut); + break; + + case MScClipCode_NegX: +// UUmAssert((inScreenPoints + inIndexIn)->x >= 0.0f); +// UUmAssert((inScreenPoints + inIndexOut)->x < 0.0f); + + t = (0.0f - xOut) / (xIn - xOut); + yNew = yOut + t * (yIn - yOut); + zNew = zOut + t * (zIn - zOut); + xNew = 0.0; + wNew = wOut + t * (wIn - wOut); + break; + + case MScClipCode_PosY: +// UUmAssert((inScreenPoints + inIndexIn)->y >= 0.0f); +// UUmAssert((inScreenPoints + inIndexOut)->y < 0.0f); + + t = (0.0f - yOut) / (yIn - yOut); + xNew = xOut + t * (xIn - xOut); + zNew = zOut + t * (zIn - zOut); + yNew = 0.0; + wNew = wOut + t * (wIn - wOut); + break; + + case MScClipCode_NegY: +// UUmAssert((inScreenPoints + inIndexIn)->y < inYFactor); // UUmAssert((inScreenPoints + inIndexOut)->y >= inYFactor); - + t = (yOut - inYFactor) / (yOut - yIn); - xNew = xOut + t * (xIn - xOut); - zNew = zOut + t * (zIn - zOut); - yNew = inYFactor - 0.0001f; - wNew = wOut + t * (wIn - wOut); - break; - - case MScClipCode_PosZ: -// UUmAssert((inScreenPoints + inIndexIn)->z < 1.0); -// UUmAssert((inScreenPoints + inIndexOut)->z >= 1.0); - - t = (zOut - 1.0f) / (zOut - zIn); - xNew = xOut + t * (xIn - xOut); - yNew = yOut + t * (yIn - yOut); + xNew = xOut + t * (xIn - xOut); + zNew = zOut + t * (zIn - zOut); + yNew = inYFactor - 0.0001f; + wNew = wOut + t * (wIn - wOut); + break; + + case MScClipCode_PosZ: +// UUmAssert((inScreenPoints + inIndexIn)->z < 1.0); +// UUmAssert((inScreenPoints + inIndexOut)->z >= 1.0); + + t = (zOut - 1.0f) / (zOut - zIn); + xNew = xOut + t * (xIn - xOut); + yNew = yOut + t * (yIn - yOut); zNew = 0.9999f; - wNew = wOut + t * (wIn - wOut); - break; - - case MScClipCode_NegZ: -// UUmAssert((inScreenPoints + inIndexIn)->z >= 0.0f); -// UUmAssert((inScreenPoints + inIndexOut)->z < 0.0f); - - t = (0.0f - zOut) / (zIn - zOut); - xNew = xOut + t * (xIn - xOut); - yNew = yOut + t * (yIn - yOut); - zNew = 0.0; - wNew = wOut + t * (wIn - wOut); - break; + wNew = wOut + t * (wIn - wOut); + break; + + case MScClipCode_NegZ: +// UUmAssert((inScreenPoints + inIndexIn)->z >= 0.0f); +// UUmAssert((inScreenPoints + inIndexOut)->z < 0.0f); + + t = (0.0f - zOut) / (zIn - zOut); + xNew = xOut + t * (xIn - xOut); + yNew = yOut + t * (yIn - yOut); + zNew = 0.0; + wNew = wOut + t * (wIn - wOut); + break; } #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + if(gClipDumping) { fprintf(gClipFile, "\tt = %f\n", t); } - + #endif - + #if MSmGeomClipPoly_InterpShading - + // XXX - optimize this someday shadeOut = *(inScreenShades + inIndexOut); shadeIn = *(inScreenShades + inIndexIn); - + rOut = (float)((shadeOut >> 10) & 0x1F); gOut = (float)((shadeOut >> 5) & 0x1F); bOut = (float)((shadeOut >> 0) & 0x1F); - + rIn = (float)((shadeIn >> 10) & 0x1F); gIn = (float)((shadeIn >> 5) & 0x1F); bIn = (float)((shadeIn >> 0) & 0x1F); - + rNew = rOut + t * (rIn - rOut); gNew = gOut + t * (gIn - gOut); bNew = bOut + t * (bIn - bOut); - - *(inScreenShades + inIndexNew) = + + *(inScreenShades + inIndexNew) = ((UUtUns16)rNew << 10) | ((UUtUns16)gNew << 5) | ((UUtUns16)bNew << 0); - + #endif #if MSmGeomClipPoly_TextureMap - + #if MSmGeomClipPoly_SplitTexturePoint - { + { float uIn, uOut, uNew; float vIn, vOut, vNew; - + inTexIndexNew <<= 1; inTexIndexOut <<= 1; inTexIndexIn <<= 1; @@ -1507,12 +1507,12 @@ MSmGeomClipPoly_ClipPointFunctionName( vIn *= wIn; uOut *= wOut; vOut *= wOut; - + uNew = uOut + t * (uIn - uOut); vNew = vOut + t * (vIn - vOut); uNew /= wNew; vNew /= wNew; - + (inTextureCoords + inTexIndexNew)->u = uNew; (inTextureCoords + inTexIndexNew)->v = vNew; @@ -1528,12 +1528,12 @@ MSmGeomClipPoly_ClipPointFunctionName( vIn *= wIn; uOut *= wOut; vOut *= wOut; - + uNew = uOut + t * (uIn - uOut); vNew = vOut + t * (vIn - vOut); uNew /= wNew; vNew /= wNew; - + (inTextureCoords + inTexIndexNew)->u = uNew; (inTextureCoords + inTexIndexNew)->v = vNew; @@ -1542,7 +1542,7 @@ MSmGeomClipPoly_ClipPointFunctionName( { float uIn, uOut, uNew; float vIn, vOut, vNew; - + uIn = (inTextureCoords + inTexIndexIn)->u; vIn = (inTextureCoords + inTexIndexIn)->v; uOut = (inTextureCoords + inTexIndexOut)->u; @@ -1551,20 +1551,20 @@ MSmGeomClipPoly_ClipPointFunctionName( vIn *= wIn; uOut *= wOut; vOut *= wOut; - + uNew = uOut + t * (uIn - uOut); vNew = vOut + t * (vIn - vOut); uNew /= wNew; vNew /= wNew; - + (inTextureCoords + inTexIndexNew)->u = uNew; (inTextureCoords + inTexIndexNew)->v = vNew; - + //(inTextureCoords + inTexIndexNew)->u = (inTextureCoords + inTexIndexOut)->u + t * ((inTextureCoords + inTexIndexIn)->u - (inTextureCoords + inTexIndexOut)->u); //(inTextureCoords + inTexIndexNew)->v = (inTextureCoords + inTexIndexOut)->v + t * ((inTextureCoords + inTexIndexIn)->v - (inTextureCoords + inTexIndexOut)->v); - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + if(gClipDumping) { fprintf(gClipFile, "\tinTex: (%f, %f)\n", @@ -1577,27 +1577,27 @@ MSmGeomClipPoly_ClipPointFunctionName( (inTextureCoords + inTexIndexNew)->u, (inTextureCoords + inTexIndexNew)->v); } - + #endif } #endif - + #endif - newClipCode = 0; - if(xNew < 0.0f) newClipCode |= MScClipCode_NegX; + newClipCode = 0; + if(xNew < 0.0f) newClipCode |= MScClipCode_NegX; if(xNew >= inXFactor) newClipCode |= MScClipCode_PosX; if(yNew < 0.0f) newClipCode |= MScClipCode_PosY; /* This is not a bug */ if(yNew >= inYFactor) newClipCode |= MScClipCode_NegY; /* This is not a bug */ - if(zNew >= 1.0f) newClipCode |= MScClipCode_PosZ; - if(zNew < 0.0f) newClipCode |= MScClipCode_NegZ; - (inScreenPoints + inIndexNew)->x = xNew; - (inScreenPoints + inIndexNew)->y = yNew; - (inScreenPoints + inIndexNew)->z = zNew; - (inScreenPoints + inIndexNew)->invW = wNew; - + if(zNew >= 1.0f) newClipCode |= MScClipCode_PosZ; + if(zNew < 0.0f) newClipCode |= MScClipCode_NegZ; + (inScreenPoints + inIndexNew)->x = xNew; + (inScreenPoints + inIndexNew)->y = yNew; + (inScreenPoints + inIndexNew)->z = zNew; + (inScreenPoints + inIndexNew)->invW = wNew; + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + if(gClipDumping) { fprintf(gClipFile, "\tinScreen: (%f, %f, %f, %f)\n", @@ -1619,19 +1619,19 @@ MSmGeomClipPoly_ClipPointFunctionName( MSiDump_ClipCodes(gClipFile, newClipCode); fprintf(gClipFile, "\n"); } - + #endif - MSrClipCode_ValidateScreen( - (inScreenPoints + inIndexNew), - newClipCode, - inXFactor, - inYFactor); - + MSrClipCode_ValidateScreen( + (inScreenPoints + inIndexNew), + newClipCode, + inXFactor, + inYFactor); + MSiVerifyPointScreen(inScreenPoints + inIndexNew); - + #endif - + *outClipCodeNew = newClipCode; } @@ -1657,14 +1657,14 @@ MSmGeomClipPoly_TriFunctionName( #define inTexIndex0 inVIndex0 #define inTexIndex1 inVIndex1 #define inTexIndex2 inVIndex2 - + #endif UUtUns16 inClipCode0, UUtUns16 inClipCode1, UUtUns16 inClipCode2, UUtUns16 inClippedPlanes - + #if !MSmGeomClipPoly_BBox && \ !MSmGeomClipPoly_SplitTexturePoint && \ !MSmGeomClipPoly_InterpShading && \ @@ -1672,7 +1672,7 @@ MSmGeomClipPoly_TriFunctionName( !MSmGeomClipPoly_CheckFrustum , - + UUtUns16 inShade #endif @@ -1684,8 +1684,8 @@ MSmGeomClipPoly_TriFunctionName( UUtUns16 newClipCode0; UUtUns16 newClipCode1; - UUtUns16 newVIndex0; - UUtUns16 newVIndex1; + UUtUns16 newVIndex0; + UUtUns16 newVIndex1; #undef newTexIndex0 #undef newTexIndex1 @@ -1694,7 +1694,7 @@ MSmGeomClipPoly_TriFunctionName( UUtUns16 newTexIndex0; UUtUns16 newTexIndex1; - + #else #define newTexIndex0 newVIndex0 @@ -1703,90 +1703,90 @@ MSmGeomClipPoly_TriFunctionName( #endif #if MSmGeomClipPoly_BBox - + M3tPoint3D* worldPoints; M3tBoundingBox_MinMax* bBox; #else - + M3tPointScreen* screenPoints; - + #endif - + #if MSmGeomClipPoly_InterpShading - + UUtUns16* screenShades; - + #endif - + #if MSmGeomClipPoly_4D - + M3tPoint4D* frustumPoints; float scaleX, scaleY; - + #endif - + #if MSmGeomClipPoly_TextureMap - + #if 0//MSmGeomClipPoly_SplitTexturePoint - + M3tEnvTextureCoord* textureCoords; - + #else - + M3tTextureCoord* textureCoords; - + #endif - + #endif - + UUtInt16 i; UUtUns16 curClipPlane; #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + gClipNesting++; - + UUmAssert(gClipNesting < 10); UUmAssert(gClipNesting >= 0); - + #endif - + if(inClipCode0 & inClipCode1 & inClipCode2) { MSmGeomClipPoly_Return; } - + UUmAssert(contextPrivate->curClipData->newClipVertexIndex < contextPrivate->curClipData->maxClipVertices); - + newVIndex0 = contextPrivate->curClipData->newClipVertexIndex++; newVIndex1 = contextPrivate->curClipData->newClipVertexIndex++; - + #if MSmGeomClipPoly_SplitTexturePoint UUmAssert(contextPrivate->curClipData->newClipTextureIndex < contextPrivate->curClipData->maxClipTextureCords); - + newTexIndex0 = contextPrivate->curClipData->newClipTextureIndex++; newTexIndex1 = contextPrivate->curClipData->newClipTextureIndex++; #endif - + #if MSmGeomClipPoly_BBox - + worldPoints = contextPrivate->environment->pointArray->points; bBox = &contextPrivate->visBBox; - + #else - + screenPoints = contextPrivate->curClipData->screenPoints; - + #endif - + #if MSmGeomClipPoly_InterpShading - + screenShades = (UUtUns16*)contextPrivate->screenVertexShades; - + #endif - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING if(gClipDumping) @@ -1796,7 +1796,7 @@ MSmGeomClipPoly_TriFunctionName( fprintf(gClipFile, "\t\tv0: %d\n", inVIndex0); fprintf(gClipFile, "\t\tv1: %d\n", inVIndex1); fprintf(gClipFile, "\t\tv2: %d\n", inVIndex2); - + fprintf(gClipFile, "\tNew indices\n"); fprintf(gClipFile, "\t\tnv0: %d\n", newVIndex0); fprintf(gClipFile, "\t\tnv1: %d\n", newVIndex1); @@ -1820,18 +1820,18 @@ MSmGeomClipPoly_TriFunctionName( fprintf(gClipFile, "\t\tv2: (%f, %f, %f, %f)\n", screenPoints[inVIndex2].x, screenPoints[inVIndex2].y, screenPoints[inVIndex2].z, screenPoints[inVIndex2].invW); } - + #endif - + #if MSmGeomClipPoly_4D - + frustumPoints = contextPrivate->curClipData->frustumPoints; - + scaleX = contextPrivate->scaleX; scaleY = contextPrivate->scaleY; - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + if(gClipDumping) { fprintf(gClipFile, "\tfrustum\n"); @@ -1842,15 +1842,15 @@ MSmGeomClipPoly_TriFunctionName( fprintf(gClipFile, "\t\tv2: (%f, %f, %f, %f)\n", frustumPoints[inVIndex2].x, frustumPoints[inVIndex2].y, frustumPoints[inVIndex2].z, frustumPoints[inVIndex2].w); } - + #endif #endif - + #if MSmGeomClipPoly_TextureMap - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + if(gClipDumping) { fprintf(gClipFile, "\tTexture indices\n"); @@ -1862,51 +1862,51 @@ MSmGeomClipPoly_TriFunctionName( fprintf(gClipFile, "\t\tnv0: %d\n", newTexIndex0); fprintf(gClipFile, "\t\tnv1: %d\n", newTexIndex1); } - + #endif - + #if MSmGeomClipPoly_SplitTexturePoint - + textureCoords = contextPrivate->environment->textureCoordArray->textureCoords; - + #else - + textureCoords = contextPrivate->textureCoords; - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + if(gClipDumping) { fprintf(gClipFile, "\ttexture coords\n"); - fprintf(gClipFile, "\t\tv0: (%f, %f)\n", + fprintf(gClipFile, "\t\tv0: (%f, %f)\n", textureCoords[inTexIndex0].u, textureCoords[inTexIndex0].v); - fprintf(gClipFile, "\t\tv1: (%f, %f)\n", + fprintf(gClipFile, "\t\tv1: (%f, %f)\n", textureCoords[inTexIndex1].u, textureCoords[inTexIndex1].v); - fprintf(gClipFile, "\t\tv2: (%f, %f)\n", + fprintf(gClipFile, "\t\tv2: (%f, %f)\n", textureCoords[inTexIndex2].u, textureCoords[inTexIndex2].v); } - + #endif #endif - + #endif - + #if defined(DEBUGGING_CLIPPING_RANDCOLORS) && DEBUGGING_CLIPPING_RANDCOLORS - + #if !MSmGeomClipPoly_InterpShading - + inShade = rand() & 0xFFFF; - + #endif - + #endif - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + #if MSmGeomClipPoly_4D - + MSiVerifyPoint4D( frustumPoints + inVIndex0); MSiVerifyPoint4D( @@ -1923,16 +1923,16 @@ MSmGeomClipPoly_TriFunctionName( MSrClipCode_ValidateFrustum( frustumPoints + inVIndex2, inClipCode2); - + #else - + MSiVerifyPointScreen( screenPoints + inVIndex0); MSiVerifyPointScreen( screenPoints + inVIndex1); MSiVerifyPointScreen( screenPoints + inVIndex2); - + MSrClipCode_ValidateScreen( screenPoints + inVIndex0, inClipCode0, @@ -1950,9 +1950,9 @@ MSmGeomClipPoly_TriFunctionName( (float)MSmGeomClipPoly_BufferHeight); #endif - + #endif - + for(i = 6; i-- > 0;) { curClipPlane = (UUtUns16)(1 << i); @@ -1960,194 +1960,194 @@ MSmGeomClipPoly_TriFunctionName( { continue; } - - if(curClipPlane & inClipCode0) - { - /* 0: Out, 1: ?, 2: ? */ - if(curClipPlane & inClipCode1) - { - /* 0: Out, 1: Out, 2: In */ - UUmAssert(!(curClipPlane & inClipCode2)); - - /* Compute 2 -> 0 intersection */ - /* Compute 2 -> 1 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex2, inVIndex0, - inVIndex2, inVIndex1, - inTexIndex2, inTexIndex0, - inTexIndex2, inTexIndex1); - - /* Check for trivial accept on 2, new0, new1 */ - MSmGeomClipPoly_CheckTrivialAcceptTri( - inClipCode2, newClipCode0, newClipCode1, - inVIndex2, newVIndex0, newVIndex1, - inTexIndex2, newTexIndex0, newTexIndex1, - inClippedPlanes | curClipPlane); - - /* Verify trivial reject on 0, 1, new1, new0 */ - MSmGeomClipPoly_VerifyTrivialRejectQuad( - inClipCode0, - inClipCode1, - (newClipCode1 | curClipPlane), - (newClipCode0 | curClipPlane)); - - MSmGeomClipPoly_Return; - } - else - { - /* 0: Out, 1: in, 2: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: Out, 1: In, 2: Out */ - - /* Compute 1 -> 0 Intersection */ - /* Compute 1 -> 2 Intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex1, inVIndex0, - inVIndex1, inVIndex2, - inTexIndex1, inTexIndex0, - inTexIndex1, inTexIndex2); - + + if(curClipPlane & inClipCode0) + { + /* 0: Out, 1: ?, 2: ? */ + if(curClipPlane & inClipCode1) + { + /* 0: Out, 1: Out, 2: In */ + UUmAssert(!(curClipPlane & inClipCode2)); + + /* Compute 2 -> 0 intersection */ + /* Compute 2 -> 1 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex2, inVIndex0, + inVIndex2, inVIndex1, + inTexIndex2, inTexIndex0, + inTexIndex2, inTexIndex1); + + /* Check for trivial accept on 2, new0, new1 */ + MSmGeomClipPoly_CheckTrivialAcceptTri( + inClipCode2, newClipCode0, newClipCode1, + inVIndex2, newVIndex0, newVIndex1, + inTexIndex2, newTexIndex0, newTexIndex1, + inClippedPlanes | curClipPlane); + + /* Verify trivial reject on 0, 1, new1, new0 */ + MSmGeomClipPoly_VerifyTrivialRejectQuad( + inClipCode0, + inClipCode1, + (newClipCode1 | curClipPlane), + (newClipCode0 | curClipPlane)); + + MSmGeomClipPoly_Return; + } + else + { + /* 0: Out, 1: in, 2: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: Out, 1: In, 2: Out */ + + /* Compute 1 -> 0 Intersection */ + /* Compute 1 -> 2 Intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex1, inVIndex0, + inVIndex1, inVIndex2, + inTexIndex1, inTexIndex0, + inTexIndex1, inTexIndex2); + /* Check for trivial accept on 1, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptTri( + MSmGeomClipPoly_CheckTrivialAcceptTri( inClipCode1, newClipCode1, newClipCode0, - inVIndex1, newVIndex1, newVIndex0, - inTexIndex1, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); - + inVIndex1, newVIndex1, newVIndex0, + inTexIndex1, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 2, 0, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectQuad( - inClipCode2, - inClipCode0, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); - - MSmGeomClipPoly_Return; - } - else - { - /* 0: Out, 1: In, 2: In */ - - /* Compute 1 -> 0 intersection */ - /* Compute 2 -> 0 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex1, inVIndex0, - inVIndex2, inVIndex0, - inTexIndex1, inTexIndex0, - inTexIndex2, inTexIndex0); - - /* Check for trivial accept on 1, 2, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptQuad( + MSmGeomClipPoly_VerifyTrivialRejectQuad( + inClipCode2, + inClipCode0, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); + + MSmGeomClipPoly_Return; + } + else + { + /* 0: Out, 1: In, 2: In */ + + /* Compute 1 -> 0 intersection */ + /* Compute 2 -> 0 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex1, inVIndex0, + inVIndex2, inVIndex0, + inTexIndex1, inTexIndex0, + inTexIndex2, inTexIndex0); + + /* Check for trivial accept on 1, 2, new1, new0 */ + MSmGeomClipPoly_CheckTrivialAcceptQuad( inClipCode1, inClipCode2, newClipCode1, newClipCode0, - inVIndex1, inVIndex2, newVIndex1, newVIndex0, - inTexIndex1, inTexIndex2, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); - + inVIndex1, inVIndex2, newVIndex1, newVIndex0, + inTexIndex1, inTexIndex2, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 0, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectTri( - inClipCode0, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); - - MSmGeomClipPoly_Return; - } + MSmGeomClipPoly_VerifyTrivialRejectTri( + inClipCode0, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); + + MSmGeomClipPoly_Return; + } } } - else - { - /* 0: In, 1: ?, 2: ? */ - if(curClipPlane & inClipCode1) - { - /* 0: In, 1: Out, 2: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: In, 1: Out, 2: Out */ - - /* Compute 0 -> 1 intersection */ - /* Compute 0 -> 2 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex0, inVIndex1, - inVIndex0, inVIndex2, - inTexIndex0, inTexIndex1, - inTexIndex0, inTexIndex2); - + else + { + /* 0: In, 1: ?, 2: ? */ + if(curClipPlane & inClipCode1) + { + /* 0: In, 1: Out, 2: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: In, 1: Out, 2: Out */ + + /* Compute 0 -> 1 intersection */ + /* Compute 0 -> 2 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex0, inVIndex1, + inVIndex0, inVIndex2, + inTexIndex0, inTexIndex1, + inTexIndex0, inTexIndex2); + /* Check for trivial accept on 0, new0, new1 */ - MSmGeomClipPoly_CheckTrivialAcceptTri( + MSmGeomClipPoly_CheckTrivialAcceptTri( inClipCode0, newClipCode0, newClipCode1, - inVIndex0, newVIndex0, newVIndex1, - inTexIndex0, newTexIndex0, newTexIndex1, - inClippedPlanes | curClipPlane); - + inVIndex0, newVIndex0, newVIndex1, + inTexIndex0, newTexIndex0, newTexIndex1, + inClippedPlanes | curClipPlane); + /* Verfiy trivial reject on 1, 2, new1, new0 */ - MSmGeomClipPoly_VerifyTrivialRejectQuad( - inClipCode1, - inClipCode2, - (newClipCode1 | curClipPlane), - (newClipCode0 | curClipPlane)); - - MSmGeomClipPoly_Return; - } - else - { - /* 0: In, 1: Out, 2: In */ - - /* Compute 0 -> 1 intersection */ - /* Compute 2 -> 1 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex0, inVIndex1, - inVIndex2, inVIndex1, - inTexIndex0, inTexIndex1, - inTexIndex2, inTexIndex1); - - /* Check for trivial accept on 2, 0, new0, new1 */ - MSmGeomClipPoly_CheckTrivialAcceptQuad( + MSmGeomClipPoly_VerifyTrivialRejectQuad( + inClipCode1, + inClipCode2, + (newClipCode1 | curClipPlane), + (newClipCode0 | curClipPlane)); + + MSmGeomClipPoly_Return; + } + else + { + /* 0: In, 1: Out, 2: In */ + + /* Compute 0 -> 1 intersection */ + /* Compute 2 -> 1 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex0, inVIndex1, + inVIndex2, inVIndex1, + inTexIndex0, inTexIndex1, + inTexIndex2, inTexIndex1); + + /* Check for trivial accept on 2, 0, new0, new1 */ + MSmGeomClipPoly_CheckTrivialAcceptQuad( inClipCode2, inClipCode0, newClipCode0, newClipCode1, - inVIndex2, inVIndex0, newVIndex0, newVIndex1, - inTexIndex2, inTexIndex0, newTexIndex0, newTexIndex1, - inClippedPlanes | curClipPlane); - + inVIndex2, inVIndex0, newVIndex0, newVIndex1, + inTexIndex2, inTexIndex0, newTexIndex0, newTexIndex1, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 1, new1, new0 */ - MSmGeomClipPoly_VerifyTrivialRejectTri( - inClipCode1, - (newClipCode1 | curClipPlane), - (newClipCode0 | curClipPlane)); - - MSmGeomClipPoly_Return; - } - - } - else - { - /* 0: In, 1: in, 2: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: In, 1: in, 2: Out */ - - /* Compute 0 -> 2 intersection */ - /* Compute 1 -> 2 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex0, inVIndex2, - inVIndex1, inVIndex2, - inTexIndex0, inTexIndex2, - inTexIndex1, inTexIndex2); - - /* Check for trivial accept on 0, 1, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptQuad( + MSmGeomClipPoly_VerifyTrivialRejectTri( + inClipCode1, + (newClipCode1 | curClipPlane), + (newClipCode0 | curClipPlane)); + + MSmGeomClipPoly_Return; + } + + } + else + { + /* 0: In, 1: in, 2: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: In, 1: in, 2: Out */ + + /* Compute 0 -> 2 intersection */ + /* Compute 1 -> 2 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex0, inVIndex2, + inVIndex1, inVIndex2, + inTexIndex0, inTexIndex2, + inTexIndex1, inTexIndex2); + + /* Check for trivial accept on 0, 1, new1, new0 */ + MSmGeomClipPoly_CheckTrivialAcceptQuad( inClipCode0, inClipCode1, newClipCode1, newClipCode0, - inVIndex0, inVIndex1, newVIndex1, newVIndex0, - inTexIndex0, inTexIndex1, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); - + inVIndex0, inVIndex1, newVIndex1, newVIndex0, + inTexIndex0, inTexIndex1, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 2, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectTri( - inClipCode2, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); - - MSmGeomClipPoly_Return; - } - /* else all are in */ - } + MSmGeomClipPoly_VerifyTrivialRejectTri( + inClipCode2, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); + + MSmGeomClipPoly_Return; + } + /* else all are in */ + } } } @@ -2182,7 +2182,7 @@ MSmGeomClipPoly_QuadFunctionName( #define inTexIndex1 inVIndex1 #define inTexIndex2 inVIndex2 #define inTexIndex3 inVIndex3 - + #endif UUtUns16 inClipCode0, @@ -2190,7 +2190,7 @@ MSmGeomClipPoly_QuadFunctionName( UUtUns16 inClipCode2, UUtUns16 inClipCode3, UUtUns16 inClippedPlanes - + #if !MSmGeomClipPoly_BBox && \ !MSmGeomClipPoly_SplitTexturePoint && \ !MSmGeomClipPoly_InterpShading && \ @@ -2198,7 +2198,7 @@ MSmGeomClipPoly_QuadFunctionName( !MSmGeomClipPoly_CheckFrustum , - + UUtUns16 inShade #endif @@ -2210,14 +2210,14 @@ MSmGeomClipPoly_QuadFunctionName( UUtUns16 newClipCode0; UUtUns16 newClipCode1; - UUtUns16 newVIndex0; - UUtUns16 newVIndex1; + UUtUns16 newVIndex0; + UUtUns16 newVIndex1; #if MSmGeomClipPoly_SplitTexturePoint UUtUns16 newTexIndex0; UUtUns16 newTexIndex1; - + #else #define newTexIndex0 newVIndex0 @@ -2226,106 +2226,106 @@ MSmGeomClipPoly_QuadFunctionName( #endif #if MSmGeomClipPoly_BBox - + M3tPoint3D* worldPoints; M3tBoundingBox_MinMax* bBox; #else - + M3tPointScreen* screenPoints; - + #endif - + #if MSmGeomClipPoly_InterpShading - + UUtUns16* screenShades; - + #endif - + #if MSmGeomClipPoly_4D - + M3tPoint4D* frustumPoints; float scaleX, scaleY; - + #endif #if MSmGeomClipPoly_TextureMap - + #if 0//MSmGeomClipPoly_SplitTexturePoint - + M3tEnvTextureCoord* textureCoords; - + #else - + M3tTextureCoord* textureCoords; - + #endif - + #endif UUtInt16 i; UUtUns16 curClipPlane; #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + gClipNesting++; - + UUmAssert(gClipNesting < 10); UUmAssert(gClipNesting >= 0); - + #endif - + if(inClipCode0 & inClipCode1 & inClipCode2 & inClipCode3) { MSmGeomClipPoly_Return; } - + UUmAssert(contextPrivate->curClipData->newClipVertexIndex < contextPrivate->curClipData->maxClipVertices); - + newVIndex0 = contextPrivate->curClipData->newClipVertexIndex++; newVIndex1 = contextPrivate->curClipData->newClipVertexIndex++; - + #if MSmGeomClipPoly_SplitTexturePoint UUmAssert(contextPrivate->curClipData->newClipTextureIndex < contextPrivate->curClipData->maxClipTextureCords); - + newTexIndex0 = contextPrivate->curClipData->newClipTextureIndex++; newTexIndex1 = contextPrivate->curClipData->newClipTextureIndex++; #endif #if MSmGeomClipPoly_BBox - + worldPoints = contextPrivate->environment->pointArray->points; bBox = &contextPrivate->visBBox; - + #else - + screenPoints = contextPrivate->curClipData->screenPoints; - + #endif #if MSmGeomClipPoly_InterpShading - + screenShades = (UUtUns16*)contextPrivate->screenVertexShades; - + #endif - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING if(gClipDumping) { fprintf(gClipFile, "Entering %s(%d)\n", UUmStringize(MSmGeomClipPoly_QuadFunctionName), gClipNesting); - + fprintf(gClipFile, "\tIndices\n"); fprintf(gClipFile, "\t\tv0: %d\n", inVIndex0); fprintf(gClipFile, "\t\tv1: %d\n", inVIndex1); fprintf(gClipFile, "\t\tv2: %d\n", inVIndex2); fprintf(gClipFile, "\t\tv3: %d\n", inVIndex3); - + fprintf(gClipFile, "\tNew indices\n"); fprintf(gClipFile, "\t\tnv0: %d\n", newVIndex0); fprintf(gClipFile, "\t\tnv1: %d\n", newVIndex1); - + fprintf(gClipFile, "\tClip Codes\n"); fprintf(gClipFile, "\t\tv0: "); MSiDump_ClipCodes(gClipFile, inClipCode0); @@ -2339,7 +2339,7 @@ MSmGeomClipPoly_QuadFunctionName( fprintf(gClipFile, "\t\tv3: "); MSiDump_ClipCodes(gClipFile, inClipCode3); fprintf(gClipFile, "\n"); - + fprintf(gClipFile, "\tscreen\n"); fprintf(gClipFile, "\t\tv0: (%f, %f, %f, %f)\n", screenPoints[inVIndex0].x, screenPoints[inVIndex0].y, screenPoints[inVIndex0].z, screenPoints[inVIndex0].invW); @@ -2350,19 +2350,19 @@ MSmGeomClipPoly_QuadFunctionName( fprintf(gClipFile, "\t\tv3: (%f, %f, %f, %f)\n", screenPoints[inVIndex3].x, screenPoints[inVIndex3].y, screenPoints[inVIndex3].z, screenPoints[inVIndex3].invW); } - + #endif #if MSmGeomClipPoly_4D - - + + frustumPoints = contextPrivate->curClipData->frustumPoints; - + scaleX = contextPrivate->scaleX; scaleY = contextPrivate->scaleY; - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + if(gClipDumping) { fprintf(gClipFile, "\tfrustum\n"); @@ -2375,15 +2375,15 @@ MSmGeomClipPoly_QuadFunctionName( fprintf(gClipFile, "\t\tv3: (%f, %f, %f, %f)\n", frustumPoints[inVIndex3].x, frustumPoints[inVIndex3].y, frustumPoints[inVIndex3].z, frustumPoints[inVIndex3].w); } - + #endif #endif - + #if MSmGeomClipPoly_TextureMap - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + if(gClipDumping) { fprintf(gClipFile, "\tTexture indices\n"); @@ -2396,52 +2396,52 @@ MSmGeomClipPoly_QuadFunctionName( fprintf(gClipFile, "\t\tnv0: %d\n", newTexIndex0); fprintf(gClipFile, "\t\tnv1: %d\n", newTexIndex1); } - + #endif - + #if MSmGeomClipPoly_SplitTexturePoint - + textureCoords = contextPrivate->environment->textureCoordArray->textureCoords; - + #else - + textureCoords = contextPrivate->textureCoords; - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + if(gClipDumping) { fprintf(gClipFile, "\ttexture coords\n"); - fprintf(gClipFile, "\t\tv0: (%f, %f)\n", + fprintf(gClipFile, "\t\tv0: (%f, %f)\n", textureCoords[inTexIndex0].u, textureCoords[inTexIndex0].v); - fprintf(gClipFile, "\t\tv1: (%f, %f)\n", + fprintf(gClipFile, "\t\tv1: (%f, %f)\n", textureCoords[inTexIndex1].u, textureCoords[inTexIndex1].v); - fprintf(gClipFile, "\t\tv2: (%f, %f)\n", + fprintf(gClipFile, "\t\tv2: (%f, %f)\n", textureCoords[inTexIndex2].u, textureCoords[inTexIndex2].v); - fprintf(gClipFile, "\t\tv3: (%f, %f)\n", + fprintf(gClipFile, "\t\tv3: (%f, %f)\n", textureCoords[inTexIndex3].u, textureCoords[inTexIndex3].v); } - + #endif - + #endif - + #endif - + #if defined(DEBUGGING_CLIPPING_RANDCOLORS) && DEBUGGING_CLIPPING_RANDCOLORS - + #if !MSmGeomClipPoly_InterpShading - + inShade = rand() & 0xFFFF; - + #endif - + #endif - + #if defined(DEBUGGING_CLIPPING) && DEBUGGING_CLIPPING - + #if MSmGeomClipPoly_4D - + MSiVerifyPoint4D( frustumPoints + inVIndex0); MSiVerifyPoint4D( @@ -2463,9 +2463,9 @@ MSmGeomClipPoly_QuadFunctionName( MSrClipCode_ValidateFrustum( frustumPoints + inVIndex3, inClipCode3); - + #else - + MSiVerifyPointScreen( screenPoints + inVIndex0); MSiVerifyPointScreen( @@ -2474,7 +2474,7 @@ MSmGeomClipPoly_QuadFunctionName( screenPoints + inVIndex2); MSiVerifyPointScreen( screenPoints + inVIndex3); - + MSrClipCode_ValidateScreen( screenPoints + inVIndex0, inClipCode0, @@ -2497,9 +2497,9 @@ MSmGeomClipPoly_QuadFunctionName( (float)MSmGeomClipPoly_BufferHeight); #endif - + #endif - + for(i = 6; i-- > 0;) { curClipPlane = (UUtUns16)(1 << i); @@ -2507,358 +2507,358 @@ MSmGeomClipPoly_QuadFunctionName( { continue; } - - if(curClipPlane & inClipCode0) - { - /* 0: Out, 1: ?, 2: ?, 3: ? */ - if(curClipPlane & inClipCode1) - { - /* 0: Out, 1: Out, 2: ?, 3: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: Out, 1: Out, 2: Out, 3: In */ - //UUmAssert(!(curClipPlane & inClipCode3)); - /* Compute 3 -> 0 intersection */ - /* Compute 3 -> 2 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex3, inVIndex0, - inVIndex3, inVIndex2, - inTexIndex3, inTexIndex0, - inTexIndex3, inTexIndex2); - /* Check for trivial accept on 3, new0, new1 */ - MSmGeomClipPoly_CheckTrivialAcceptTri( - inClipCode3, newClipCode0, newClipCode1, - inVIndex3, newVIndex0, newVIndex1, - inTexIndex3, newTexIndex0, newTexIndex1, - inClippedPlanes | curClipPlane); - /* Verify trivial reject on 0, 1, 2, new1, new0 */ - MSmGeomClipPoly_VerifyTrivialRejectPent( - inClipCode0, - inClipCode1, - inClipCode2, - (newClipCode1 | curClipPlane), - (newClipCode0 | curClipPlane)); - + + if(curClipPlane & inClipCode0) + { + /* 0: Out, 1: ?, 2: ?, 3: ? */ + if(curClipPlane & inClipCode1) + { + /* 0: Out, 1: Out, 2: ?, 3: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: Out, 1: Out, 2: Out, 3: In */ + //UUmAssert(!(curClipPlane & inClipCode3)); + /* Compute 3 -> 0 intersection */ + /* Compute 3 -> 2 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex3, inVIndex0, + inVIndex3, inVIndex2, + inTexIndex3, inTexIndex0, + inTexIndex3, inTexIndex2); + /* Check for trivial accept on 3, new0, new1 */ + MSmGeomClipPoly_CheckTrivialAcceptTri( + inClipCode3, newClipCode0, newClipCode1, + inVIndex3, newVIndex0, newVIndex1, + inTexIndex3, newTexIndex0, newTexIndex1, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 0, 1, 2, new1, new0 */ + MSmGeomClipPoly_VerifyTrivialRejectPent( + inClipCode0, + inClipCode1, + inClipCode2, + (newClipCode1 | curClipPlane), + (newClipCode0 | curClipPlane)); + MSmGeomClipPoly_Return; - } - else - { - /* 0: Out, 1: Out, 2: In, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: Out, 1: Out, 2: In, 3: Out */ - /* Compute 2 -> 1 intersection */ - /* Compute 2 -> 3 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex2, inVIndex1, - inVIndex2, inVIndex3, - inTexIndex2, inTexIndex1, - inTexIndex2, inTexIndex3); - /* Check for trivial accept on 2, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptTri( - inClipCode2, newClipCode1, newClipCode0, - inVIndex2, newVIndex1, newVIndex0, - inTexIndex2, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); + } + else + { + /* 0: Out, 1: Out, 2: In, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: Out, 1: Out, 2: In, 3: Out */ + /* Compute 2 -> 1 intersection */ + /* Compute 2 -> 3 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex2, inVIndex1, + inVIndex2, inVIndex3, + inTexIndex2, inTexIndex1, + inTexIndex2, inTexIndex3); + /* Check for trivial accept on 2, new1, new0 */ + MSmGeomClipPoly_CheckTrivialAcceptTri( + inClipCode2, newClipCode1, newClipCode0, + inVIndex2, newVIndex1, newVIndex0, + inTexIndex2, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); /* Verify trivial reject on 3, 0, 1, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectPent( - inClipCode3, - inClipCode0, - inClipCode1, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); + MSmGeomClipPoly_VerifyTrivialRejectPent( + inClipCode3, + inClipCode0, + inClipCode1, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); MSmGeomClipPoly_Return; - } - else - { - /* 0: Out, 1: Out, 2: In, 3: In */ - /* Compute 2 -> 1 intersection */ - /* Compute 3 -> 0 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex2, inVIndex1, - inVIndex3, inVIndex0, - inTexIndex2, inTexIndex1, - inTexIndex3, inTexIndex0); + } + else + { + /* 0: Out, 1: Out, 2: In, 3: In */ + /* Compute 2 -> 1 intersection */ + /* Compute 3 -> 0 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex2, inVIndex1, + inVIndex3, inVIndex0, + inTexIndex2, inTexIndex1, + inTexIndex3, inTexIndex0); /* Check for trivial accept on 2, 3, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptQuad( + MSmGeomClipPoly_CheckTrivialAcceptQuad( inClipCode2, inClipCode3, newClipCode1, newClipCode0, - inVIndex2, inVIndex3, newVIndex1, newVIndex0, - inTexIndex2, inTexIndex3, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); - /* Verify trivial reject on 0, 1, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectQuad( - inClipCode0, - inClipCode1, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); + inVIndex2, inVIndex3, newVIndex1, newVIndex0, + inTexIndex2, inTexIndex3, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 0, 1, new0, new1 */ + MSmGeomClipPoly_VerifyTrivialRejectQuad( + inClipCode0, + inClipCode1, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); MSmGeomClipPoly_Return; - } - } - } - else - { - /* 0: Out, 1: In, 2: ?, 3: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: Out, 1: In, 2: Out, 3: Out */ - //UUmAssert(curClipPlane & inClipCode3); - /* Compute 1 -> 0 intersection */ - /* Compute 1 -> 2 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex1, inVIndex0, - inVIndex1, inVIndex2, - inTexIndex1, inTexIndex0, - inTexIndex1, inTexIndex2); - /* Check for trivial accept on 1, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptTri( - inClipCode1, newClipCode1, newClipCode0, - inVIndex1, newVIndex1, newVIndex0, - inTexIndex1, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); + } + } + } + else + { + /* 0: Out, 1: In, 2: ?, 3: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: Out, 1: In, 2: Out, 3: Out */ + //UUmAssert(curClipPlane & inClipCode3); + /* Compute 1 -> 0 intersection */ + /* Compute 1 -> 2 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex1, inVIndex0, + inVIndex1, inVIndex2, + inTexIndex1, inTexIndex0, + inTexIndex1, inTexIndex2); + /* Check for trivial accept on 1, new1, new0 */ + MSmGeomClipPoly_CheckTrivialAcceptTri( + inClipCode1, newClipCode1, newClipCode0, + inVIndex1, newVIndex1, newVIndex0, + inTexIndex1, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); /* Check for trivial reject on 2, 3, 0, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectPent( - inClipCode2, - inClipCode3, - inClipCode0, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); + MSmGeomClipPoly_VerifyTrivialRejectPent( + inClipCode2, + inClipCode3, + inClipCode0, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); MSmGeomClipPoly_Return; - } - else - { - /* 0: Out, 1: In, 2: In, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: Out, 1: In, 2: In, 3: Out */ - /* Compute 1 -> 0 intersection */ - /* Compute 2 -> 3 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex1, inVIndex0, - inVIndex2, inVIndex3, - inTexIndex1, inTexIndex0, - inTexIndex2, inTexIndex3); + } + else + { + /* 0: Out, 1: In, 2: In, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: Out, 1: In, 2: In, 3: Out */ + /* Compute 1 -> 0 intersection */ + /* Compute 2 -> 3 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex1, inVIndex0, + inVIndex2, inVIndex3, + inTexIndex1, inTexIndex0, + inTexIndex2, inTexIndex3); /* Check for trivial accept on 1, 2, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptQuad( + MSmGeomClipPoly_CheckTrivialAcceptQuad( inClipCode1, inClipCode2, newClipCode1, newClipCode0, - inVIndex1, inVIndex2, newVIndex1, newVIndex0, - inTexIndex1, inTexIndex2, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); - /* Verify trivial reject on 3, 0, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectQuad( - inClipCode3, - inClipCode0, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); + inVIndex1, inVIndex2, newVIndex1, newVIndex0, + inTexIndex1, inTexIndex2, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 3, 0, new0, new1 */ + MSmGeomClipPoly_VerifyTrivialRejectQuad( + inClipCode3, + inClipCode0, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); MSmGeomClipPoly_Return; - } - else - { - /* 0: Out, 1: In, 2: In, 3: In */ - /* Compute 1 -> 0 intersection */ - /* Compute 3 -> 0 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex1, inVIndex0, - inVIndex3, inVIndex0, - inTexIndex1, inTexIndex0, - inTexIndex3, inTexIndex0); + } + else + { + /* 0: Out, 1: In, 2: In, 3: In */ + /* Compute 1 -> 0 intersection */ + /* Compute 3 -> 0 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex1, inVIndex0, + inVIndex3, inVIndex0, + inTexIndex1, inTexIndex0, + inTexIndex3, inTexIndex0); /* Check for trivial accept on 1, 2, 3, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptPent( + MSmGeomClipPoly_CheckTrivialAcceptPent( inClipCode1, inClipCode2, inClipCode3, newClipCode1, newClipCode0, - inVIndex1, inVIndex2, inVIndex3, newVIndex1, newVIndex0, - inTexIndex1, inTexIndex2, inTexIndex3, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); - /* Verify trivial reject on 0, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectTri( - inClipCode0, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); + inVIndex1, inVIndex2, inVIndex3, newVIndex1, newVIndex0, + inTexIndex1, inTexIndex2, inTexIndex3, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 0, new0, new1 */ + MSmGeomClipPoly_VerifyTrivialRejectTri( + inClipCode0, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); MSmGeomClipPoly_Return; - } - } - } - } - else - { - /* 0: In, 1: ?, 2: ?, 3: ? */ - if(curClipPlane & inClipCode1) - { - /* 0: In, 1: Out, 2: ?, 3: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: In, 1: Out, 2: Out, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: In, 1: Out, 2: Out, 3: Out */ - /* Compute 0 -> 3 intersection */ - /* Compute 0 -> 1 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex0, inVIndex3, - inVIndex0, inVIndex1, - inTexIndex0, inTexIndex3, - inTexIndex0, inTexIndex1); - /* Check for trivial accept on 0, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptTri( - inClipCode0, newClipCode1, newClipCode0, - inVIndex0, newVIndex1, newVIndex0, - inTexIndex0, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); + } + } + } + } + else + { + /* 0: In, 1: ?, 2: ?, 3: ? */ + if(curClipPlane & inClipCode1) + { + /* 0: In, 1: Out, 2: ?, 3: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: In, 1: Out, 2: Out, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: In, 1: Out, 2: Out, 3: Out */ + /* Compute 0 -> 3 intersection */ + /* Compute 0 -> 1 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex0, inVIndex3, + inVIndex0, inVIndex1, + inTexIndex0, inTexIndex3, + inTexIndex0, inTexIndex1); + /* Check for trivial accept on 0, new1, new0 */ + MSmGeomClipPoly_CheckTrivialAcceptTri( + inClipCode0, newClipCode1, newClipCode0, + inVIndex0, newVIndex1, newVIndex0, + inTexIndex0, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); /* Verify trivial reject on 1, 2, 3, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectPent( - inClipCode1, - inClipCode2, - inClipCode3, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); + MSmGeomClipPoly_VerifyTrivialRejectPent( + inClipCode1, + inClipCode2, + inClipCode3, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); MSmGeomClipPoly_Return; - } - else - { - /* 0: In, 1: Out, 2: Out, 3: In */ - /* Compute 3 -> 2 intersection */ - /* Compute 0 -> 1 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex3, inVIndex2, - inVIndex0, inVIndex1, - inTexIndex3, inTexIndex2, - inTexIndex0, inTexIndex1); + } + else + { + /* 0: In, 1: Out, 2: Out, 3: In */ + /* Compute 3 -> 2 intersection */ + /* Compute 0 -> 1 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex3, inVIndex2, + inVIndex0, inVIndex1, + inTexIndex3, inTexIndex2, + inTexIndex0, inTexIndex1); /* Check for trivial accept on 3, 0, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptQuad( + MSmGeomClipPoly_CheckTrivialAcceptQuad( inClipCode3, inClipCode0, newClipCode1, newClipCode0, - inVIndex3, inVIndex0, newVIndex1, newVIndex0, - inTexIndex3, inTexIndex0, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); - /* Verify trivial reject on 1, 2, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectQuad( - inClipCode1, - inClipCode2, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); + inVIndex3, inVIndex0, newVIndex1, newVIndex0, + inTexIndex3, inTexIndex0, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 1, 2, new0, new1 */ + MSmGeomClipPoly_VerifyTrivialRejectQuad( + inClipCode1, + inClipCode2, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); MSmGeomClipPoly_Return; - } - } - else - { - /* 0: In, 1: Out, 2: In, 3: In */ - //UUmAssert(!(curClipPlane & inClipCode3)); - /* Compute 2 -> 1 intersection */ - /* Compute 0 -> 1 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex2, inVIndex1, - inVIndex0, inVIndex1, - inTexIndex2, inTexIndex1, - inTexIndex0, inTexIndex1); + } + } + else + { + /* 0: In, 1: Out, 2: In, 3: In */ + //UUmAssert(!(curClipPlane & inClipCode3)); + /* Compute 2 -> 1 intersection */ + /* Compute 0 -> 1 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex2, inVIndex1, + inVIndex0, inVIndex1, + inTexIndex2, inTexIndex1, + inTexIndex0, inTexIndex1); /* Check for trivial accept on 2, 3, 0, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptPent( + MSmGeomClipPoly_CheckTrivialAcceptPent( inClipCode2, inClipCode3, inClipCode0, newClipCode1, newClipCode0, - inVIndex2, inVIndex3, inVIndex0, newVIndex1, newVIndex0, - inTexIndex2, inTexIndex3, inTexIndex0, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); - /* Verify trivial reject on 1, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectTri( - inClipCode1, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); + inVIndex2, inVIndex3, inVIndex0, newVIndex1, newVIndex0, + inTexIndex2, inTexIndex3, inTexIndex0, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 1, new0, new1 */ + MSmGeomClipPoly_VerifyTrivialRejectTri( + inClipCode1, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); MSmGeomClipPoly_Return; - } - } - else - { - /* 0: In, 1: In, 2: ?, 3: ? */ - if(curClipPlane & inClipCode2) - { - /* 0: In, 1: In, 2: Out, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: In, 1: In, 2: Out, 3: Out */ - /* Compute 0 -> 3 intersection */ - /* Compute 1 -> 2 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex0, inVIndex3, - inVIndex1, inVIndex2, - inTexIndex0, inTexIndex3, - inTexIndex1, inTexIndex2); + } + } + else + { + /* 0: In, 1: In, 2: ?, 3: ? */ + if(curClipPlane & inClipCode2) + { + /* 0: In, 1: In, 2: Out, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: In, 1: In, 2: Out, 3: Out */ + /* Compute 0 -> 3 intersection */ + /* Compute 1 -> 2 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex0, inVIndex3, + inVIndex1, inVIndex2, + inTexIndex0, inTexIndex3, + inTexIndex1, inTexIndex2); /* Check for trivial accept on 0, 1, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptQuad( + MSmGeomClipPoly_CheckTrivialAcceptQuad( inClipCode0, inClipCode1, newClipCode1, newClipCode0, - inVIndex0, inVIndex1, newVIndex1, newVIndex0, - inTexIndex0, inTexIndex1, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); - /* Verify trivial reject on 2, 3, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectQuad( - inClipCode2, - inClipCode3, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); + inVIndex0, inVIndex1, newVIndex1, newVIndex0, + inTexIndex0, inTexIndex1, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 2, 3, new0, new1 */ + MSmGeomClipPoly_VerifyTrivialRejectQuad( + inClipCode2, + inClipCode3, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); MSmGeomClipPoly_Return; - } - else - { - /* 0: In, 1: In, 2: Out, 3: In */ - /* Compute 3 -> 2 intersection */ - /* Compute 1 -> 2 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex3, inVIndex2, - inVIndex1, inVIndex2, - inTexIndex3, inTexIndex2, - inTexIndex1, inTexIndex2); + } + else + { + /* 0: In, 1: In, 2: Out, 3: In */ + /* Compute 3 -> 2 intersection */ + /* Compute 1 -> 2 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex3, inVIndex2, + inVIndex1, inVIndex2, + inTexIndex3, inTexIndex2, + inTexIndex1, inTexIndex2); /* Check for trivial accept on 3, 0, 1, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptPent( + MSmGeomClipPoly_CheckTrivialAcceptPent( inClipCode3, inClipCode0, inClipCode1, newClipCode1, newClipCode0, - inVIndex3, inVIndex0, inVIndex1, newVIndex1, newVIndex0, - inTexIndex3, inTexIndex0, inTexIndex1, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); - /* Verify trivial reject on 2, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectTri( - inClipCode2, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); + inVIndex3, inVIndex0, inVIndex1, newVIndex1, newVIndex0, + inTexIndex3, inTexIndex0, inTexIndex1, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 2, new0, new1 */ + MSmGeomClipPoly_VerifyTrivialRejectTri( + inClipCode2, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); MSmGeomClipPoly_Return; - } - } - else - { - /* 0: In, 1: In, 2: In, 3: ? */ - if(curClipPlane & inClipCode3) - { - /* 0: In, 1: In, 2: In, 3: Out */ - /* Compute 0 -> 3 intersection */ - /* Compute 2 -> 3 intersection */ - MSmGeomClipPoly_ComputeNewClipPoints( - inVIndex0, inVIndex3, - inVIndex2, inVIndex3, - inTexIndex0, inTexIndex3, - inTexIndex2, inTexIndex3); + } + } + else + { + /* 0: In, 1: In, 2: In, 3: ? */ + if(curClipPlane & inClipCode3) + { + /* 0: In, 1: In, 2: In, 3: Out */ + /* Compute 0 -> 3 intersection */ + /* Compute 2 -> 3 intersection */ + MSmGeomClipPoly_ComputeNewClipPoints( + inVIndex0, inVIndex3, + inVIndex2, inVIndex3, + inTexIndex0, inTexIndex3, + inTexIndex2, inTexIndex3); /* Check for trivial accept on 0, 1, 2, new1, new0 */ - MSmGeomClipPoly_CheckTrivialAcceptPent( + MSmGeomClipPoly_CheckTrivialAcceptPent( inClipCode0, inClipCode1, inClipCode2, newClipCode1, newClipCode0, - inVIndex0, inVIndex1, inVIndex2, newVIndex1, newVIndex0, - inTexIndex0, inTexIndex1, inTexIndex2, newTexIndex1, newTexIndex0, - inClippedPlanes | curClipPlane); - /* Verify trivial reject on 3, new0, new1 */ - MSmGeomClipPoly_VerifyTrivialRejectTri( - inClipCode3, - (newClipCode0 | curClipPlane), - (newClipCode1 | curClipPlane)); + inVIndex0, inVIndex1, inVIndex2, newVIndex1, newVIndex0, + inTexIndex0, inTexIndex1, inTexIndex2, newTexIndex1, newTexIndex0, + inClippedPlanes | curClipPlane); + /* Verify trivial reject on 3, new0, new1 */ + MSmGeomClipPoly_VerifyTrivialRejectTri( + inClipCode3, + (newClipCode0 | curClipPlane), + (newClipCode1 | curClipPlane)); MSmGeomClipPoly_Return; - } - /* else all are in */ - } - } + } + /* else all are in */ + } + } } } //UUmAssert(!"Should never get here"); - + MSmGeomClipPoly_Return; } diff --git a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Math.c b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Math.c index b0c78ed..cd827d8 100644 --- a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Math.c +++ b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Math.c @@ -1,12 +1,12 @@ /* FILE: BFW_Shared_Math.c - + AUTHOR: Brent H. Pease - + CREATED: Oct 23, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Math.h b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Math.h index 4449a5f..9042203 100644 --- a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Math.h +++ b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_Math.h @@ -1,12 +1,12 @@ /* FILE: BFW_Shared_Math.h - + AUTHOR: Brent H. Pease - + CREATED: Oct 23, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 -- -- -- -- -- -- @@ -15,43 +15,43 @@ | A02 A12 A22 A32 | /\ | B02 B12 B22 B32 | == | C02 C12 C22 C32 | | A03 A13 A23 A33 | | B03 B13 B23 B33 | | C03 C13 C23 C33 | -- -- -- -- -- -- - + C00 = A00 * B00 + A10 * B01 + A20 * B02 + A30 * B03 - + ... - + C33 = A02 * B30 + A13 * B31 + A23 * B32 + A33 * B33 - + NOTE: If the product of AB is applied to a vertex as in ABv the transformation defined in B affects vertex v before the transformation defined in A, ie OpenGL. - + -- -- -- -- -- -- | A00 A10 A20 A30 | | X | | X' | | A01 A11 A21 A31 | \/ | Y | == | Y' | | A02 A12 A22 A32 | /\ | Z | == | Z' | | A03 A13 A23 A33 | | W | | W' | -- -- -- -- -- -- - + X' = A00 * X + A10 * Y + A20 * Z + A30 * W - + ... - + W' = A03 * X + A13 * Y + A23 * Z + A33 * W - + In the camera and viewing code a 4x4 matrix is interpreted as follows - + -- -- -- -- -- -- | A00 A10 A20 T30 | | X | | X' | | A01 A11 A21 T31 | \/ | Y | == | Y' | | A02 A12 A22 T32 | /\ | Z | == | Z' | | P03 P13 P23 0.0 | | W | | W' | -- -- -- -- -- -- - + T30, T31, T32 is used for translation - + P03, P13, P23 is used for perspective correction - + Aij is used for scale and rotation. Note that nonuniform scales are *not* allowed since this would require an inverstion for computing normals. */ @@ -172,7 +172,7 @@ negW = -hW; \ hY = m01 * lX + m11 * lY + m21 * lZ + m31; \ hZ = m02 * lX + m12 * lY + m22 * lZ + m32; - + #define MSmTransform_Local2FrustumInvW( \ lX, lY, lZ, \ hX, hY, hZ, hW, invW, \ @@ -186,7 +186,7 @@ invW = 1.0f / hW; \ hY = m01 * lX + m11 * lY + m21 * lZ + m31; \ hZ = m02 * lX + m12 * lY + m22 * lZ + m32; - + #define MSmTransform_Local2FrustumNegW( \ lX, lY, lZ, \ hX, hY, hZ, hW, negW, \ @@ -200,7 +200,7 @@ negW = -hW; \ hY = m01 * lX + m11 * lY + m21 * lZ + m31; \ hZ = m02 * lX + m12 * lY + m22 * lZ + m32; - + #define MSmTransform_Matrix4x4ToRegisters( \ matrix, \ m00, m10, m20, m30, \ diff --git a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_TriRaster.h b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_TriRaster.h index 8834e20..a418e71 100644 --- a/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_TriRaster.h +++ b/BungieFrameWork/BFW_Source/BFW_Shared/BFW_Shared_TriRaster.h @@ -1,12 +1,12 @@ /* FILE: MS_TriRasterize.h - + AUTHOR: Brent H. Pease - + CREATED: April 3, 1997 - + PURPOSE: Assert interface files - + Copyright 1997 */ @@ -30,6 +30,6 @@ #define MSmSubPixelUnits (1<width #define MSmTriRaster_BufferHeight contextPrivate->height - + #endif MSmTriRaster_ReturnType @@ -71,24 +71,24 @@ MSmTriRaster_FunctionName register UUtUns16 inVIndex0Min, register UUtUns16 inVIndex1Mid, register UUtUns16 inVIndex2Max - + #if MSmTriRaster_Split - + , register UUtUns16 inETextIndex0Min, register UUtUns16 inETextIndex1Mid, register UUtUns16 inETextIndex2Max - + #endif - + #if !MSmTriRaster_IsVisible && !MSmTriRaster_RasterZOnly && !MSmTriRaster_Split - + #if !MSmTriRaster_InterpShading && !MSmTriRaster_TextureNoShade , register UUtUns16 faceShade - + #endif - + #endif ) { @@ -105,58 +105,58 @@ MSmTriRaster_FunctionName MStDrawContextPrivate* contextPrivate = (MStDrawContextPrivate *)inContext->privateContext; #endif - + #if MSmTriRaster_Texture - + MStTextureMapPrivate* textureMapPrivate = (MStTextureMapPrivate*)(M3rManager_Texture_GetEnginePrivate(contextPrivate->statePtr[M3cDrawStatePtrType_BaseTextureMap])); - + #if 0//MSmTriRaster_Split - + MStTextureMapPrivate* ltextureMapPrivate; - + #endif - + #endif - + /* - * + * */ M3tPointScreen* screenPoints; - + #if MSmTriRaster_InterpShading - + UUtUns16* vShades; UUtUns16 vShadeMin; UUtUns16 vShadeMid; UUtUns16 vShadeMax; - + #endif - + #if MSmTriRaster_Texture - + #if MSmTriRaster_Split - + M3tTextureCoord* textureCoords; - + #else - + M3tTextureCoord* textureCoords; - + #endif - + #endif - + /* * Key to variable names - * + * * ddx = d/dx, horizontal incremental change * ddy = d/dy, vertical incremental change * * The type is appended to ease the scheduling of integer and floating point variables */ - + #if !MSmTriRaster_Lightmap - + /* * Z parameters */ @@ -164,9 +164,9 @@ MSmTriRaster_FunctionName UUtUns32 z_ddy_uns; UUtUns32 z_longEdge_uns; float z_min_float, z_mid_float, z_max_float; - + #endif - + /* * x left and right variables */ @@ -175,117 +175,117 @@ MSmTriRaster_FunctionName UUtInt32 x_rightEdge_int, x_rightEdge_ddy_int; UUtInt32 x_shortEdgeBottom_int, x_shortEdgeBottom_ddy_int; UUtInt32 x_shortEdgeTop_int, x_shortEdgeTop_ddy_int; - + #if MSmTriRaster_InterpShading - + UUtInt32 m10_int, m11_int, m12_int; /* - * These variables have double duty. They are used to store the int version of the + * These variables have double duty. They are used to store the int version of the * min, mid, max rgb values and the variable interpolation values for rgb */ UUtInt32 r_max_ddy_int, g_max_ddy_int, b_max_ddy_int; UUtInt32 r_mid_ddx_int, g_mid_ddx_int, b_mid_ddx_int; UUtInt32 r_min_longEdge_int, g_min_longEdge_int, b_min_longEdge_int; #endif - + #if MSmTriRaster_Texture - + /* - * Texture UV + * Texture UV */ float uOverW_ddx_float, vOverW_ddx_float, invW_ddx_float; float uOverWMin_float, uOverWMid_float, uOverWMax_float; float vOverWMin_float, vOverWMid_float, vOverWMax_float; float invWMin_float, invWMid_float, invWMax_float; - + float uOverW_longEdge_float, vOverW_longEdge_float, invW_longEdge_float; float uOverW_longEdge_ddy_float, vOverW_longEdge_ddy_float, invW_longEdge_ddy_float; - + float uOverW_float, vOverW_float, invW_float, w_float; float u_float, v_float; UUtInt32 u_int, v_int; - + char *textureBase; UUtInt32 nUResolutionBits_int, nVResolutionBits_int; UUtInt32 pageResolutionMaskU_int; UUtInt32 pageResolutionMaskV_int; - + UUtInt32 texelOffset; UUtUns16 texel; - + #if MSmTriRaster_Split - + UUtBool useLightMap; - + //float luOverW_ddx_float, lvOverW_ddx_float; //float luOverWMin_float, luOverWMid_float, luOverWMax_float; //float lvOverWMin_float, lvOverWMid_float, lvOverWMax_float; - + //float luOverW_longEdge_float, lvOverW_longEdge_float; //float luOverW_longEdge_ddy_float, lvOverW_longEdge_ddy_float; - + //float luOverW_float, lvOverW_float; //float lu_float, lv_float; //UUtInt32 lu_int, lv_int; - + //char *ltextureBase; //UUtInt32 lnUResolutionBits_int, lnVResolutionBits_int; //UUtInt32 lpageResolutionMaskU_int; //UUtInt32 lpageResolutionMaskV_int; - + //UUtInt32 ltexelOffset; //UUtUns16 ltexel; - - + + #endif - + #endif - + /* * top, middle, and bottom scanlines */ UUtInt32 scanline_min_int, scanline_mid_int, scanline_max_int; - + /* * Pointers into the buffers and the rowBytes */ #if !MSmTriRaster_IsVisible && !MSmTriRaster_RasterZOnly - + UUtUns16* imageScanlineLeft_ptr; UUtUns16 imageRowBytes_uns; - + #endif - + #if !MSmTriRaster_Lightmap - + UUtUns16* z_scanlineLeft_ptr; UUtUns16 zRowBytes_uns; - + #endif - + #if MSmTriRaster_PixelTouch - + UUtUns32* pixelTouch_scanLeft_ptr; UUtUns16 pixelTouchRowBytes_uns; - + UUtUns32 pixelTouchBitMask; UUtUns32 pixelTouchBitMaskOrig; - + #endif - + /* * Used to indicate whether scanline traversal is left->right or right->left */ UUtInt16 spanDirection_int; - + /* * min, mid, and max variables for x and y */ float y_min_float, y_mid_float, y_max_float; float x_min_float, x_mid_float, x_max_float; float y0_float, y1_float, y2_float; - + /* * Plane equation variables */ @@ -293,108 +293,108 @@ MSmTriRaster_FunctionName float invDet_float; float y_maxMinusMin_float, y_midMinusMin_float; float x_maxMinusMin_float, x_midMinusMin_float; - + /* * Error variables */ float y_minError_float, y_midError_float; - + /* * Temporary variables */ float temp_float; UUtUns16 temp_uns16; - + #if !MSmTriRaster_TextureNoShade && !MSmTriRaster_IsVisible && MSmTriRaster_InterpShading && !MSmTriRaster_RasterZOnly - + UUtInt32 r_temp_int, g_temp_int, b_temp_int; - + #endif - + /* * floating point constants */ #if !MSmTriRaster_Lightmap - + float z_scale_float = (float)MSmULongScale; float z_offset_float = (float)MSmULongOffset; - + #endif - + float x_scale_float = MSmFractOne * MSmSubPixelUnits; float oneHalf_float = 0.5F; float one_float = 1.0F; - + /* * Scanline variables */ UUtInt32 scanline_int; - + UUtInt32 ptr_ddx_int; - + #if !MSmTriRaster_Lightmap - + UUtUns32 z_uns, z_target_uns; UUtUns16 *z_ptr; - + #endif - + #if !MSmTriRaster_IsVisible && !MSmTriRaster_RasterZOnly - + UUtUns16 *image_ptr; - + #endif - - + + #if MSmTriRaster_PixelTouch - + UUtUns32 pixelTouch_uns; UUtUns32* pixelTouch_ptr; - + #endif - + /* * Pixel variables - */ + */ UUtInt32 x_pixelLeft_int, x_pixelRight_int; UUtInt32 i; - + /* * DDA variables */ float invHeight_float; UUtInt32 invHeight_int; - + #if 0//MmCOMPILER_MW - + __dcbt(vCoord0Min,0); __dcbt(vCoord1Mid,0); __dcbt(vCoord2Max,0); __dcbt(vShade0Min,0); __dcbt(vShade1Mid,0); __dcbt(vShade2Max,0); - + #endif - + /* * Step 1. Sort the vertices according to y. Sort in place to save registers */ /* prefetch y mid, min, max, these should be cache misses */ #if MSmTriRaster_IsVisible || MSmTriRaster_RasterZOnly || MSmTriRaster_Lightmap - + screenPoints = (M3tPointScreen*)contextPrivate->screenPoints; #else - + screenPoints = (M3tPointScreen*)contextPrivate->statePtr[M3cDrawStatePtrType_ScreenPointArray]; - + #endif - + y0_float = (screenPoints + inVIndex0Min)->y; y1_float = (screenPoints + inVIndex1Mid)->y; y2_float = (screenPoints + inVIndex2Max)->y; - + UUmAssert(y0_float >= 0.0 && y0_float < (float)MSmTriRaster_BufferHeight); UUmAssert(y1_float >= 0.0 && y1_float < (float)MSmTriRaster_BufferHeight); UUmAssert(y2_float >= 0.0 && y2_float < (float)MSmTriRaster_BufferHeight); @@ -408,167 +408,167 @@ MSmTriRaster_FunctionName { y_min_float = y1_float; y_mid_float = y0_float; - + temp_uns16 = inVIndex0Min; inVIndex0Min = inVIndex1Mid; inVIndex1Mid = temp_uns16; - + #if MSmTriRaster_Split - + temp_uns16 = inETextIndex0Min; inETextIndex0Min = inETextIndex1Mid; inETextIndex1Mid = temp_uns16; - + #endif } - + if (y2_float < y_min_float) { y_max_float = y_mid_float; y_mid_float = y_min_float; y_min_float = y2_float; - + temp_uns16 = inVIndex2Max; inVIndex2Max = inVIndex1Mid; inVIndex1Mid = inVIndex0Min; inVIndex0Min = temp_uns16; - + #if MSmTriRaster_Split - + temp_uns16 = inETextIndex2Max; inETextIndex2Max = inETextIndex1Mid; inETextIndex1Mid = inETextIndex0Min; inETextIndex0Min = temp_uns16; - + #endif - + } else if (y2_float < y_mid_float) { y_max_float = y_mid_float; y_mid_float = y2_float; - - + + temp_uns16 = inVIndex2Max; inVIndex2Max = inVIndex1Mid; inVIndex1Mid = temp_uns16; - + #if MSmTriRaster_Split - + temp_uns16 = inETextIndex2Max; inETextIndex2Max = inETextIndex1Mid; inETextIndex1Mid = temp_uns16; - + #endif - + } else { y_max_float = y2_float; } - + /* * Step 2. Compute plane equations and interwind load/store operations */ - + #if MSmTriRaster_Lightmap - + vShades = (UUtUns16*)contextPrivate->vShades; - + #elif MSmTriRaster_InterpShading - + vShades = (UUtUns16*)contextPrivate->statePtr[M3cDrawStatePtrType_ScreenShadeArray_DC]; - + #endif - + /* prefetch x mid, min, max */ x_min_float = (screenPoints + inVIndex0Min)->x; x_mid_float = (screenPoints + inVIndex1Mid)->x; x_max_float = (screenPoints + inVIndex2Max)->x; - + UUmAssert(x_min_float >= 0.0 && x_min_float < (float)MSmTriRaster_BufferWidth); UUmAssert(x_mid_float >= 0.0 && x_mid_float < (float)MSmTriRaster_BufferWidth); UUmAssert(x_max_float >= 0.0 && x_max_float < (float)MSmTriRaster_BufferWidth); #if MSmTriRaster_InterpShading - + vShadeMin = vShades[inVIndex0Min]; vShadeMid = vShades[inVIndex1Mid]; vShadeMax = vShades[inVIndex2Max]; - + /* prefetch min rgb */ /* Calc plane equation stuff */ r_min_longEdge_int = ((vShadeMin >> 10) & 0x1F) << 3; y_maxMinusMin_float = y_max_float - y_min_float; g_min_longEdge_int = ((vShadeMin >> 5) & 0x1F) << 3; x_midMinusMin_float = x_mid_float - x_min_float; b_min_longEdge_int = ((vShadeMin & 0x1F)) << 3; y_midMinusMin_float = y_mid_float - y_min_float; x_maxMinusMin_float = x_max_float - x_min_float; - + /* prefetch mid rgb */ /* Continue plane equation stuff */ r_mid_ddx_int = ((vShadeMid >> 10) & 0x1F) << 3; invDet_float = y_maxMinusMin_float * x_midMinusMin_float - y_midMinusMin_float * x_maxMinusMin_float; g_mid_ddx_int = ((vShadeMid >> 5) & 0x1F) << 3; b_mid_ddx_int = ((vShadeMid & 0x1F)) << 3; invDet_float = one_float / invDet_float; - + #if !MSmTriRaster_Lightmap - - /* prefetch z */ - z_min_float = (screenPoints + inVIndex0Min)->z; + + /* prefetch z */ + z_min_float = (screenPoints + inVIndex0Min)->z; z_mid_float = (screenPoints + inVIndex1Mid)->z; z_max_float = (screenPoints + inVIndex2Max)->z; - + UUmAssert(z_min_float >= 0.0 && z_min_float < 1.0); UUmAssert(z_mid_float >= 0.0 && z_mid_float < 1.0); UUmAssert(z_max_float >= 0.0 && z_max_float < 1.0); - + z_min_float = z_min_float * z_scale_float + z_offset_float; - z_mid_float = z_mid_float * z_scale_float + z_offset_float; - z_max_float = z_max_float * z_scale_float + z_offset_float; - + z_mid_float = z_mid_float * z_scale_float + z_offset_float; + z_max_float = z_max_float * z_scale_float + z_offset_float; + #endif - - /* Prefetch max rgb */ /* scale z */ - r_max_ddy_int = ((vShadeMax >> 10) & 0x1F) << 3; - g_max_ddy_int = ((vShadeMax >> 5) & 0x1F) << 3; - b_max_ddy_int = ((vShadeMax & 0x1F)) << 3; - + + /* Prefetch max rgb */ /* scale z */ + r_max_ddy_int = ((vShadeMax >> 10) & 0x1F) << 3; + g_max_ddy_int = ((vShadeMax >> 5) & 0x1F) << 3; + b_max_ddy_int = ((vShadeMax & 0x1F)) << 3; + #else - + #if !MSmTriRaster_TextureNoShade && !MSmTriRaster_IsVisible && MSmTriRaster_RGB565 && !MSmTriRaster_RasterZOnly && !MSmTriRaster_Split - + faceShade = ((faceShade >> 10) & 0x1F) << 11 | ((faceShade >> 5) & 0x1F) << 6 | (faceShade & 0x1F); - + #endif - + /* Calc plane equation stuff */ - y_maxMinusMin_float = y_max_float - y_min_float; - x_midMinusMin_float = x_mid_float - x_min_float; - y_midMinusMin_float = y_mid_float - y_min_float; + y_maxMinusMin_float = y_max_float - y_min_float; + x_midMinusMin_float = x_mid_float - x_min_float; + y_midMinusMin_float = y_mid_float - y_min_float; x_maxMinusMin_float = x_max_float - x_min_float; - + /* Continue plane equation stuff */ invDet_float = y_maxMinusMin_float * x_midMinusMin_float - y_midMinusMin_float * x_maxMinusMin_float; invDet_float = one_float / invDet_float; - + #if !MSmTriRaster_Lightmap - - /* prefetch z */ - z_min_float = (screenPoints + inVIndex0Min)->z; + + /* prefetch z */ + z_min_float = (screenPoints + inVIndex0Min)->z; z_mid_float = (screenPoints + inVIndex1Mid)->z; z_max_float = (screenPoints + inVIndex2Max)->z; - + UUmAssert(z_min_float >= 0.0 && z_min_float <= 1.0); UUmAssert(z_mid_float >= 0.0 && z_mid_float <= 1.0); UUmAssert(z_max_float >= 0.0 && z_max_float <= 1.0); - /* scale z */ - z_min_float = z_min_float * z_scale_float + z_offset_float; - z_mid_float = z_mid_float * z_scale_float + z_offset_float; - z_max_float = z_max_float * z_scale_float + z_offset_float; - + /* scale z */ + z_min_float = z_min_float * z_scale_float + z_offset_float; + z_mid_float = z_mid_float * z_scale_float + z_offset_float; + z_max_float = z_max_float * z_scale_float + z_offset_float; + #endif - + #endif - + if (invDet_float > 0.0F) { spanDirection_int = 1; @@ -578,25 +578,25 @@ MSmTriRaster_FunctionName invDet_float = -invDet_float; spanDirection_int = -1; } - + /* Compute plane equation */ m10_float = (y_mid_float - y_max_float) * invDet_float; m11_float = y_maxMinusMin_float * invDet_float; m12_float = -y_midMinusMin_float * invDet_float; - + #if !MSmTriRaster_Lightmap - - /* compute ddx for Z */ + + /* compute ddx for Z */ temp_float = m10_float * z_min_float; temp_float += m11_float * z_mid_float; temp_float += m12_float * z_max_float; - + #endif - + #if MSmTriRaster_Texture - + // XXX - Schedule this better - + #if MSmTriRaster_Split textureCoords = (M3tTextureCoord*)contextPrivate->statePtr[M3cDrawStatePtrType_TextureCoordArray]; @@ -604,29 +604,29 @@ MSmTriRaster_FunctionName uOverWMin_float = (textureCoords + inETextIndex0Min)->u; uOverWMid_float = (textureCoords + inETextIndex1Mid)->u; uOverWMax_float = (textureCoords + inETextIndex2Max)->u; - + vOverWMin_float = (textureCoords + inETextIndex0Min)->v; vOverWMid_float = (textureCoords + inETextIndex1Mid)->v; vOverWMax_float = (textureCoords + inETextIndex2Max)->v; - + #if 0 //luOverWMin_float = (textureCoords + inETextIndex0Min)->light.u; //luOverWMid_float = (textureCoords + inETextIndex1Mid)->light.u; //luOverWMax_float = (textureCoords + inETextIndex2Max)->light.u; - + lvOverWMin_float = (textureCoords + inETextIndex0Min)->light.v; lvOverWMid_float = (textureCoords + inETextIndex1Mid)->light.v; lvOverWMax_float = (textureCoords + inETextIndex2Max)->light.v; #endif - + invWMin_float = (screenPoints + inVIndex0Min)->invW; invWMid_float = (screenPoints + inVIndex1Mid)->invW; invWMax_float = (screenPoints + inVIndex2Max)->invW; - + uOverWMin_float *= invWMin_float; uOverWMid_float *= invWMid_float; uOverWMax_float *= invWMax_float; - + vOverWMin_float *= invWMin_float; vOverWMid_float *= invWMid_float; vOverWMax_float *= invWMax_float; @@ -635,41 +635,41 @@ MSmTriRaster_FunctionName luOverWMin_float *= invWMin_float; luOverWMid_float *= invWMid_float; luOverWMax_float *= invWMax_float; - + lvOverWMin_float *= invWMin_float; lvOverWMid_float *= invWMid_float; lvOverWMax_float *= invWMax_float; #endif - + #else - + textureCoords = (M3tTextureCoord*)contextPrivate->statePtr[M3cDrawStatePtrType_TextureCoordArray]; uOverWMin_float = (textureCoords + inVIndex0Min)->u; uOverWMid_float = (textureCoords + inVIndex1Mid)->u; uOverWMax_float = (textureCoords + inVIndex2Max)->u; - + vOverWMin_float = (textureCoords + inVIndex0Min)->v; vOverWMid_float = (textureCoords + inVIndex1Mid)->v; vOverWMax_float = (textureCoords + inVIndex2Max)->v; - + invWMin_float = (screenPoints + inVIndex0Min)->invW; invWMid_float = (screenPoints + inVIndex1Mid)->invW; invWMax_float = (screenPoints + inVIndex2Max)->invW; - + uOverWMin_float *= invWMin_float; uOverWMid_float *= invWMid_float; uOverWMax_float *= invWMax_float; - + vOverWMin_float *= invWMin_float; vOverWMid_float *= invWMid_float; vOverWMax_float *= invWMax_float; - + #endif - + #endif - - + + /* * Step 4. compute ddx parameters and the first, mid and bottom scanlines * Step 5. Set up the vertical DDA @@ -677,29 +677,29 @@ MSmTriRaster_FunctionName #if !MSmTriRaster_Lightmap z_ddx_uns = (long)temp_float; #endif - + scanline_min_int = (UUtInt32)(y_min_float + oneHalf_float); scanline_mid_int = (UUtInt32)(y_mid_float + oneHalf_float); y_minError_float = ((float)scanline_min_int + oneHalf_float) - y_min_float; y_midError_float = ((float)scanline_mid_int + oneHalf_float) - y_mid_float; - + #if MSmTriRaster_IsVisible - + z_ddx_uns <<= 1; - + #endif - + #if MSmTriRaster_InterpShading - + m10_int = (UUtInt32)(m10_float * (float)MSmFractOne); m11_int = (UUtInt32)(m11_float * (float)MSmFractOne); m12_int = (UUtInt32)(m12_float * (float)MSmFractOne); - + /* start using r_mid_ddx_int as the ddx instead of the mid */ r_mid_ddx_int = m11_int * r_mid_ddx_int; temp_float = y_max_float - oneHalf_float; g_mid_ddx_int = m11_int * g_mid_ddx_int; invHeight_float = x_scale_float / y_midMinusMin_float; b_mid_ddx_int = m11_int * b_mid_ddx_int; x_min_float = x_min_float * x_scale_float; - + /* If the triangle does not hit the first scanline on the screen bail */ if(temp_float < 0.5f) { @@ -712,17 +712,17 @@ MSmTriRaster_FunctionName * This code section sets up the vertical DDA for all three edges. * Begin by computing the inverse of the height of the short top edge. */ - + r_mid_ddx_int += m10_int * r_min_longEdge_int; g_mid_ddx_int += m10_int * g_min_longEdge_int; b_mid_ddx_int += m10_int * b_min_longEdge_int; temp_float = x_midMinusMin_float * invHeight_float; - r_mid_ddx_int += m12_int * r_max_ddy_int; - g_mid_ddx_int += m12_int * g_max_ddy_int; - b_mid_ddx_int += m12_int * b_max_ddy_int; - + r_mid_ddx_int += m12_int * r_max_ddy_int; + g_mid_ddx_int += m12_int * g_max_ddy_int; + b_mid_ddx_int += m12_int * b_max_ddy_int; + #else - + temp_float = y_max_float - oneHalf_float; invHeight_float = x_scale_float / y_midMinusMin_float; x_min_float = x_min_float * x_scale_float; @@ -730,117 +730,117 @@ MSmTriRaster_FunctionName if(temp_float < 0.5f) { #if MSmTriRaster_IsVisible - + return UUcFalse; - + #else - + return; - + #endif - + } scanline_max_int = (UUtInt32)temp_float; temp_float = x_midMinusMin_float * invHeight_float; - + #endif - + #if MSmTriRaster_Texture - + uOverW_ddx_float = m10_float * uOverWMin_float + m11_float * uOverWMid_float + m12_float * uOverWMax_float; vOverW_ddx_float = m10_float * vOverWMin_float + m11_float * vOverWMid_float + m12_float * vOverWMax_float; - invW_ddx_float = m10_float * invWMin_float + m11_float * invWMid_float + m12_float * invWMax_float; - + invW_ddx_float = m10_float * invWMin_float + m11_float * invWMid_float + m12_float * invWMax_float; + #if 0//MSmTriRaster_Split - + luOverW_ddx_float = m10_float * luOverWMin_float + m11_float * luOverWMid_float + m12_float * luOverWMax_float; lvOverW_ddx_float = m10_float * lvOverWMin_float + m11_float * lvOverWMid_float + m12_float * lvOverWMax_float; #endif - + #endif - + x_shortEdgeTop_int = (UUtInt32)(x_min_float + y_minError_float * temp_float); x_shortEdgeTop_ddy_int = (UUtInt32)temp_float; - + /* * Compute the inverse of the height of the long edge (and do a bit more * pointer setup). */ invHeight_float = one_float / y_maxMinusMin_float; - + #if !MSmTriRaster_IsVisible && !MSmTriRaster_RasterZOnly - + imageRowBytes_uns = contextPrivate->imageBufferRowBytes; imageScanlineLeft_ptr = (UUtUns16 *)((char *)contextPrivate->imageBufferBaseAddr + (scanline_min_int * imageRowBytes_uns)); - + #endif - + #if !MSmTriRaster_Lightmap - + zRowBytes_uns = (UUtUns16)(MSmTriRaster_BufferWidth * M3cDrawZBytesPerPixel); - + z_scanlineLeft_ptr = (UUtUns16 *)((char *)contextPrivate->zBufferBaseAddr + (scanline_min_int * zRowBytes_uns)); #endif - + #if MSmTriRaster_PixelTouch - + pixelTouchRowBytes_uns = contextPrivate->pixelTouchRowBytes; - pixelTouch_scanLeft_ptr = (UUtUns32 *)((char *)contextPrivate->pixelTouchBaseAddr + + pixelTouch_scanLeft_ptr = (UUtUns32 *)((char *)contextPrivate->pixelTouchBaseAddr + scanline_min_int * pixelTouchRowBytes_uns); - + #endif - + invHeight_int = (UUtInt32)(invHeight_float * (float)MSmFractOne); - + #if MSmTriRaster_Texture - + /* * Grab some texture info */ textureBase = (char *)((M3tTextureMap*)contextPrivate->statePtr[M3cDrawStatePtrType_BaseTextureMap])->data; nUResolutionBits_int = textureMapPrivate->nWidthBits; nVResolutionBits_int = textureMapPrivate->nHeightBits; - + /* * Handle some texture stuff */ { float uResolution_float, vResolution_float; - + uResolution_float = (float)(1 << nUResolutionBits_int); vResolution_float = (float)(1 << nVResolutionBits_int); - + uOverW_longEdge_ddy_float = (uOverWMax_float - uOverWMin_float) * invHeight_float; vOverW_longEdge_ddy_float = (vOverWMax_float - vOverWMin_float) * invHeight_float; invW_longEdge_ddy_float = (invWMax_float - invWMin_float) * invHeight_float; - + uOverW_longEdge_float = uOverWMin_float + y_minError_float * uOverW_longEdge_ddy_float; vOverW_longEdge_float = vOverWMin_float + y_minError_float * vOverW_longEdge_ddy_float; invW_longEdge_float = invWMin_float + y_minError_float * invW_longEdge_ddy_float; - + uOverW_longEdge_ddy_float *= uResolution_float; vOverW_longEdge_ddy_float *= vResolution_float; - + uOverW_longEdge_float *= uResolution_float; vOverW_longEdge_float *= vResolution_float; - + uOverW_ddx_float *= uResolution_float; vOverW_ddx_float *= vResolution_float; - + pageResolutionMaskU_int = (1 << nUResolutionBits_int) - 1; pageResolutionMaskV_int = (1 << nUResolutionBits_int) - 1; } - + #if MSmTriRaster_Split - + /* * Grab some texture info */ useLightMap = (UUtBool)(contextPrivate->statePtr[M3cDrawStatePtrType_LightTextureMap] != NULL); - + #if 0 if(useLightMap) { @@ -848,75 +848,75 @@ MSmTriRaster_FunctionName ltextureMapPrivate = (MStTextureMapPrivate*)(M3rManager_Texture_GetEnginePrivate(contextPrivate->statePtr[M3cDrawStatePtrType_LightTextureMap])); lnUResolutionBits_int = ltextureMapPrivate->nWidthBits; lnVResolutionBits_int = ltextureMapPrivate->nHeightBits; - + /* * Handle some texture stuff */ { float luResolution_float, lvResolution_float; - + luResolution_float = (float)(1 << lnUResolutionBits_int); lvResolution_float = (float)(1 << lnVResolutionBits_int); - + luOverW_longEdge_ddy_float = (luOverWMax_float - luOverWMin_float) * invHeight_float; lvOverW_longEdge_ddy_float = (lvOverWMax_float - lvOverWMin_float) * invHeight_float; - + luOverW_longEdge_float = luOverWMin_float + y_minError_float * luOverW_longEdge_ddy_float; lvOverW_longEdge_float = lvOverWMin_float + y_minError_float * lvOverW_longEdge_ddy_float; - + luOverW_longEdge_ddy_float *= luResolution_float; lvOverW_longEdge_ddy_float *= lvResolution_float; - + luOverW_longEdge_float *= luResolution_float; lvOverW_longEdge_float *= lvResolution_float; - + luOverW_ddx_float *= luResolution_float; lvOverW_ddx_float *= lvResolution_float; - + lpageResolutionMaskU_int = (1 << lnUResolutionBits_int) - 1; lpageResolutionMaskV_int = (1 << lnUResolutionBits_int) - 1; } } #endif - + #endif - + #endif - + /* * Compute the initial value and forward difference for all interpolated parameters * along the long edge. */ - + temp_float = x_maxMinusMin_float * x_scale_float * invHeight_float; x_longEdge_int = (UUtInt32)(x_min_float + y_minError_float * temp_float); x_longEdge_ddy_int = (UUtInt32)temp_float; #if !MSmTriRaster_Lightmap - + temp_float = (z_max_float - z_min_float) * invHeight_float; z_longEdge_uns = (UUtUns32)(z_min_float + y_minError_float * temp_float); z_ddy_uns = (UUtInt32) temp_float; /* Cast to long first to retain negative values */ - + #endif - + #if MSmTriRaster_InterpShading - + r_max_ddy_int = (r_max_ddy_int - r_min_longEdge_int) * invHeight_int; invHeight_float = x_scale_float / (y_maxMinusMin_float - y_midMinusMin_float); g_max_ddy_int = (g_max_ddy_int - g_min_longEdge_int) * invHeight_int; b_max_ddy_int = (b_max_ddy_int - b_min_longEdge_int) * invHeight_int; - + r_min_longEdge_int = r_min_longEdge_int << MSmFractBits; temp_float = (x_max_float - x_mid_float) * invHeight_float; g_min_longEdge_int = g_min_longEdge_int << MSmFractBits; b_min_longEdge_int = b_min_longEdge_int << MSmFractBits; - + { UUtUns32 y_minError_int; - + y_minError_int = (UUtInt32)(y_minError_float * 255.9f); - + UUmAssert(y_minError_float > 0.0); - + /* Cheesy hack to handle subpixel error */ if(r_max_ddy_int < 0) { @@ -943,22 +943,22 @@ MSmTriRaster_FunctionName b_min_longEdge_int += (b_max_ddy_int * y_minError_int) >> 8; } } - + UUmAssert((scanline_max_int < scanline_min_int) || (unsigned long)(r_min_longEdge_int >> MSmFractBits) <= 0xFF); UUmAssert((scanline_max_int < scanline_min_int) || (unsigned long)(g_min_longEdge_int >> MSmFractBits) <= 0xFF); UUmAssert((scanline_max_int < scanline_min_int) || (unsigned long)(b_min_longEdge_int >> MSmFractBits) <= 0xFF); #else - + invHeight_float = x_scale_float / (y_maxMinusMin_float - y_midMinusMin_float); temp_float = (x_max_float - x_mid_float) * invHeight_float; - + #endif - + /* * Compute the inital value and forward difference of X for the bottom short edge. */ - + // XXX - VisC++ bug { float t2; @@ -974,20 +974,20 @@ MSmTriRaster_FunctionName * the bottom short edge is left or right, so add the appropriate sub-pixel bias * to xShortBottom as well. */ - + if (spanDirection_int > 0) { /* * vMin-vMax (long) is left edge. vMin-vMid (shortTop) is the top right edge, * and vMid-vMax is the bottom right edge. */ - + x_leftEdge_int = x_longEdge_int; x_leftEdge_ddy_int = x_longEdge_ddy_int; - + x_rightEdge_int = x_shortEdgeTop_int; x_rightEdge_ddy_int = x_shortEdgeTop_ddy_int; - + x_shortEdgeBottom_int -= (MSmHalfSubPixel + 1) << MSmFractBits; } else @@ -996,33 +996,33 @@ MSmTriRaster_FunctionName * vMin-vMax (short) is right edge, vMin-vMid (shortTop) is the top left edge, * and vMid-vMax is the bottom left edge. */ - + x_rightEdge_int = x_longEdge_int; x_rightEdge_ddy_int = x_longEdge_ddy_int; - + x_leftEdge_int = x_shortEdgeTop_int; x_leftEdge_ddy_int = x_shortEdgeTop_ddy_int; - + x_shortEdgeBottom_int += (MSmHalfSubPixel - 1) << MSmFractBits; } - + /* * Add in the sub-pixel coverage bias to xLeft and xRight. */ - + x_leftEdge_int += (MSmHalfSubPixel - 1) << MSmFractBits; x_rightEdge_int -= (MSmHalfSubPixel + 1) << MSmFractBits; - + for (scanline_int = scanline_min_int; scanline_int <= scanline_max_int; ++scanline_int) { #if MSmTriRaster_Dither - + unsigned char *ditherLUT; - + #endif - + if (scanline_int == scanline_mid_int) { if (spanDirection_int > 0) @@ -1032,7 +1032,7 @@ MSmTriRaster_FunctionName * Set xRight to the exact subpixel-accurate value that was computed * earlier. */ - + x_rightEdge_ddy_int = x_shortEdgeBottom_ddy_int; x_rightEdge_int = x_shortEdgeBottom_int; } @@ -1043,22 +1043,22 @@ MSmTriRaster_FunctionName * Set xLeft to the exact subpixel-accurate value that was computed * earlier. */ - + x_leftEdge_ddy_int = x_shortEdgeBottom_ddy_int; x_leftEdge_int = x_shortEdgeBottom_int; } } - + /* * Render a horizontal span. Note that the sub-pixel coverage bias has * already been added into xLeft and xRight. */ - + x_pixelLeft_int = x_leftEdge_int >> (MSmSubPixelBits + MSmFractBits); x_pixelRight_int = x_rightEdge_int >> (MSmSubPixelBits + MSmFractBits); - + #if MSmTriRaster_Dither - + ditherLUT = MgDitherLUT; if (scanline_int & 0x1) @@ -1067,7 +1067,7 @@ MSmTriRaster_FunctionName } #endif - + if (spanDirection_int > 0) { /* @@ -1075,39 +1075,39 @@ MSmTriRaster_FunctionName * pixel in the span. */ #if !MSmTriRaster_Lightmap - + z_ptr = z_scanlineLeft_ptr + x_pixelLeft_int; - + #endif - + #if !MSmTriRaster_IsVisible && !MSmTriRaster_RasterZOnly - + image_ptr = imageScanlineLeft_ptr + x_pixelLeft_int; - + #endif - + #if MSmTriRaster_PixelTouch - + pixelTouch_ptr = pixelTouch_scanLeft_ptr + (x_pixelLeft_int >> 5); - + pixelTouchBitMask = 1 << (31 - (x_pixelLeft_int & 0x1f)); - + pixelTouchBitMaskOrig = 1 << 31; - + #endif - + ptr_ddx_int = 1; - + #if MSmTriRaster_Dither /* * See comments above. If xPixelLeft (the initial pixel) is odd, XOR dither offset * with 6. - */ + */ if (x_pixelLeft_int & 0x1) { saturationLUT = (unsigned char *) (((unsigned long) saturationLUT) ^ dither6); } - + #endif } else @@ -1116,29 +1116,29 @@ MSmTriRaster_FunctionName * We are rasterizing from right to left. */ #if !MSmTriRaster_Lightmap - + z_ptr = z_scanlineLeft_ptr + x_pixelRight_int; - + #endif - + #if !MSmTriRaster_IsVisible && !MSmTriRaster_RasterZOnly - + image_ptr = imageScanlineLeft_ptr + x_pixelRight_int; - + #endif - + ptr_ddx_int = -1; #if MSmTriRaster_PixelTouch - + pixelTouch_ptr = pixelTouch_scanLeft_ptr + (x_pixelRight_int >> 5); - + pixelTouchBitMask = 1 << (31 - (x_pixelRight_int & 0x1f)); - + pixelTouchBitMaskOrig = 1; - + #endif - + #if MSmTriRaster_Dither /* @@ -1149,139 +1149,139 @@ MSmTriRaster_FunctionName { saturationLUT = (unsigned char *) (((unsigned long) saturationLUT) ^ dither6); } - + #endif } - + #if MSmTriRaster_IsVisible - + ptr_ddx_int <<= 1; - + #endif - + #if MSmTriRaster_InterpShading && !MSmTriRaster_TextureNoShade - + r_temp_int = r_min_longEdge_int; g_temp_int = g_min_longEdge_int; b_temp_int = b_min_longEdge_int; - + #endif - + #if MSmTriRaster_Texture - + uOverW_float = uOverW_longEdge_float; vOverW_float = vOverW_longEdge_float; invW_float = invW_longEdge_float; - + #if 0//MSmTriRaster_Split - + luOverW_float = luOverW_longEdge_float; lvOverW_float = lvOverW_longEdge_float; - + #endif - + #endif - - + + /* * Note that we cast z_a to a long, so that the shift is signed, and that we * shift _before_ the multiple to overflow when the magnitude of z_ddx is large. */ #if !MSmTriRaster_Lightmap - + z_uns = z_longEdge_uns; - + /* * Prefetch the first Z target value. Note that we test against the * extended Z address range (<= zPtr < dbgZAddrMax), to allow for the * 1 pixel overshoot that can occur on Z prefetches. This test is * repeated with < dbgZAddrMax in the inner loop as well. */ - + z_target_uns = *z_ptr << 16; - + #endif - + #if MSmTriRaster_PixelTouch - + pixelTouch_uns = *pixelTouch_ptr; - + #endif - + /* * Horizontal interpolation loop. */ { #if MSmTriRaster_Texture - + w_float = 1.0F / invW_float; - + #endif - + #if MSmTriRaster_IsVisible - + for (i = 1 + x_pixelRight_int - x_pixelLeft_int; (i -= 2) > 0; /* Nothing */) - + #else - + for (i = 1 + x_pixelRight_int - x_pixelLeft_int; i-- > 0; /* Nothing */) - + #endif { - + #if !MSmTriRaster_TextureNoShade && !MSmTriRaster_IsVisible && MSmTriRaster_InterpShading && !MSmTriRaster_RasterZOnly - + UUmAssert((unsigned long)(r_temp_int >> MSmFractBits) <= 0xFF); UUmAssert((unsigned long)(g_temp_int >> MSmFractBits) <= 0xFF); UUmAssert((unsigned long)(b_temp_int >> MSmFractBits) <= 0xFF); - + #endif - + #if MSmTriRaster_PixelTouch - + if(!(pixelTouch_uns & pixelTouchBitMask) || - (z_uns < z_target_uns)) + (z_uns < z_target_uns)) { - + pixelTouch_uns |= pixelTouchBitMask; - + #elif MSmTriRaster_Lightmap - + if(1) { - + #else - - + + if (z_uns < z_target_uns) { - + #endif #if MSmTriRaster_IsVisible - + return UUcTrue; - + #else - + #if !MSmTriRaster_Lightmap - + *z_ptr = (UUtUns16)(z_uns >> 16); - + #endif - + #if !MSmTriRaster_RasterZOnly - + #if MSmTriRaster_Texture - + u_float = uOverW_float * w_float; v_float = vOverW_float * w_float; - + u_int = (UUtInt32)u_float; v_int = (UUtInt32)v_float; - + /* - * Compute texel offset + * Compute texel offset */ texelOffset = ((pageResolutionMaskV_int & v_int) << nUResolutionBits_int) + (pageResolutionMaskU_int & u_int); @@ -1289,52 +1289,52 @@ MSmTriRaster_FunctionName #if MSmTriRaster_RGB565 texel = *(UUtUns16 *)(textureBase + (texelOffset << 1)); - + texel = ((texel << 1) & 0xFFE) | (texel & 0x1F); - + #else - + texel = *(UUtUns16 *)(textureBase + (texelOffset << 1)); #endif - + #if MSmTriRaster_Split #if 0 if(useLightMap) { UUtUns32 texelR, texelG, texelB; - + // THIS IS HIGHLY UNOPTIMIZED FOR EXPERIMENTATION - + lu_float = luOverW_float * w_float; lv_float = lvOverW_float * w_float; - + lu_int = (UUtInt32)lu_float; lv_int = (UUtInt32)lv_float; - + /* - * Compute texel offset + * Compute texel offset */ ltexelOffset = ((lpageResolutionMaskV_int & lv_int) << lnUResolutionBits_int) + (lpageResolutionMaskU_int & lu_int); - + texelR = (texel >> 10) & 0x1F; texelR = (texelR << 3) | (texelR >> 2); texelG = (texel >> 5) & 0x1F; texelG = (texelG << 3) | (texelG >> 2); texelB = (texel >> 0) & 0x1F; texelB = (texelB << 3) | (texelB >> 2); - + ltexel = *(UUtUns8*)(ltextureBase + ltexelOffset); - + texelR = (texelR * ltexel) >> 8; texelG = (texelG * ltexel) >> 8; texelB = (texelB * ltexel) >> 8; - + texelR = texelR >> 3; texelG = texelG >> 3; texelB = texelB >> 3; - + texel = (UUtUns16)((texelR << 10) | (texelG << 5) | (texelB)); } else @@ -1346,84 +1346,84 @@ MSmTriRaster_FunctionName *image_ptr = texel; - - + + #else - + /* * Render Gouraud color. */ #if MSmTriRaster_Alpha - - + + #else - + #if MSmTriRaster_InterpShading - + #if MSmTriRaster_RGB565 - + *image_ptr = (UUtUns16)( ((r_temp_int >> (MSmFractBits - (10 - 3))) & (0x1F << 11)) | ((g_temp_int >> (MSmFractBits - (5 - 2))) & (0x1F << 5)) | ((b_temp_int >> (MSmFractBits + 3)))); #else - + *image_ptr = (UUtUns16)( ((r_temp_int >> (MSmFractBits - (10 - 3))) & (0x1F << 10)) | ((g_temp_int >> (MSmFractBits - (5 - 3))) & (0x1F << 5)) | ((b_temp_int >> (MSmFractBits + 3)))); - + #endif - + #else - + *image_ptr = (UUtUns16)(faceShade); - + #endif - + #endif - + #endif - + #endif - + #endif - + } /* if z test */ - + #if MSmTriRaster_Texture - + invW_float += invW_ddx_float; w_float = 1.0F / invW_float; uOverW_float += uOverW_ddx_float; vOverW_float += vOverW_ddx_float; - + #if 0//MSmTriRaster_Split luOverW_float += luOverW_ddx_float; - lvOverW_float += lvOverW_ddx_float; - + lvOverW_float += lvOverW_ddx_float; + #endif - + #endif - + #if !MSmTriRaster_Lightmap - + z_ptr += ptr_ddx_int; z_uns += z_ddx_uns; z_target_uns = *z_ptr << 16; - + #endif - + #if !MSmTriRaster_IsVisible && !MSmTriRaster_RasterZOnly - + image_ptr += ptr_ddx_int; - + #endif - + #if MSmTriRaster_PixelTouch - + if(ptr_ddx_int < 0) { pixelTouchBitMask <<= 1; @@ -1432,100 +1432,100 @@ MSmTriRaster_FunctionName { pixelTouchBitMask >>= 1; } - + if(pixelTouchBitMask == 0) { *pixelTouch_ptr = pixelTouch_uns; - + pixelTouch_ptr += ptr_ddx_int; - + pixelTouch_uns = *pixelTouch_ptr; - + pixelTouchBitMask = pixelTouchBitMaskOrig; } - + #endif - + #if MSmTriRaster_InterpShading && !MSmTriRaster_TextureNoShade r_temp_int += r_mid_ddx_int; g_temp_int += g_mid_ddx_int; b_temp_int += b_mid_ddx_int; - + #endif - + #if MSmTriRaster_Dither saturationLUT = (unsigned char *) (((unsigned long) saturationLUT) ^ dither6); - + #endif } } #if MSmTriRaster_PixelTouch - + if(pixelTouchBitMask != 0) { *pixelTouch_ptr = pixelTouch_uns; } - + #endif - + /* * Advance to next scanline */ - + x_leftEdge_int += x_leftEdge_ddy_int; x_rightEdge_int += x_rightEdge_ddy_int; - + #if MSmTriRaster_Texture - + uOverW_longEdge_float += uOverW_longEdge_ddy_float; vOverW_longEdge_float += vOverW_longEdge_ddy_float; invW_longEdge_float += invW_longEdge_ddy_float; - + #if 0//MSmTriRaster_Split - + luOverW_longEdge_float += luOverW_longEdge_ddy_float; lvOverW_longEdge_float += lvOverW_longEdge_ddy_float; - + #endif - + #endif - + #if !MSmTriRaster_Lightmap - + z_longEdge_uns += z_ddy_uns; z_scanlineLeft_ptr = (UUtUns16 *)((char *)z_scanlineLeft_ptr + zRowBytes_uns); - + #endif - + #if !MSmTriRaster_IsVisible && !MSmTriRaster_RasterZOnly - + imageScanlineLeft_ptr = (UUtUns16 *)((char *)imageScanlineLeft_ptr + imageRowBytes_uns); - + #endif - + #if MSmTriRaster_PixelTouch - + pixelTouch_scanLeft_ptr = (UUtUns32 *)((char *)pixelTouch_scanLeft_ptr + pixelTouchRowBytes_uns); - + #endif - + #if MSmTriRaster_InterpShading - + r_min_longEdge_int += r_max_ddy_int; g_min_longEdge_int += g_max_ddy_int; b_min_longEdge_int += b_max_ddy_int; - + #endif - + } - + #if MSmTriRaster_IsVisible - + return UUcFalse; - + #endif } diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem/BFW_SS2_RegisterTemplate.c b/BungieFrameWork/BFW_Source/BFW_SoundSystem/BFW_SS2_RegisterTemplate.c index d63ca68..a485d55 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem/BFW_SS2_RegisterTemplate.c +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem/BFW_SS2_RegisterTemplate.c @@ -19,7 +19,7 @@ SS2rRegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register( SScTemplate_Subtitle, @@ -33,6 +33,6 @@ SS2rRegisterTemplates( sizeof(SStSoundData), TMcFolding_Allow); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem/BFW_SS_Private.h b/BungieFrameWork/BFW_Source/BFW_SoundSystem/BFW_SS_Private.h index d3c4cb1..04d2a47 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem/BFW_SS_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem/BFW_SS_Private.h @@ -15,8 +15,8 @@ typedef struct SStSoundData_PrivateData { SStSound *soundList; - + } SStSoundData_PrivateData; // ====================================================================== -#endif /* BFW_SOUNDSYSTEM_PRIVATE_H */ \ No newline at end of file +#endif /* BFW_SOUNDSYSTEM_PRIVATE_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem/Platform_MacOS/BFW_SS_Platform_MacOS.c b/BungieFrameWork/BFW_Source/BFW_SoundSystem/Platform_MacOS/BFW_SS_Platform_MacOS.c index b851842..a87bed4 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem/Platform_MacOS/BFW_SS_Platform_MacOS.c +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem/Platform_MacOS/BFW_SS_Platform_MacOS.c @@ -43,15 +43,15 @@ SSiPlatform_SoundChannel_Callback( SndCommand *inSoundCommand) { SStSoundChannel *soundChannel; - + // get the sound channel being used soundChannel = (SStSoundChannel*)inSoundCommand->param2; - + if (soundChannel->flags & SScFlag_Loop) { SndCommand cmd; OSErr err; - + // play the sound again SSmSetSndCommand(cmd, bufferCmd, 0, (UUtUns32)soundChannel->ps.sound); err = SndDoImmediate(soundChannel->ps.sound_channel, &cmd); @@ -73,16 +73,16 @@ SSiPlatform_SoundChannel_Terminate( char *inErrorString) { OSErr err; - + if (inErrorString) { UUrError_Report(UUcError_Generic, inErrorString); } - + if (inSoundChannel->ps.sound_channel) { // stop the sound channel - err = + err = SndDisposeChannel( inSoundChannel->ps.sound_channel, UUcTrue); @@ -125,16 +125,16 @@ SSrPlatform_SoundChannel_Initialize( { OSErr err; ExtSoundHeaderPtr sound; - + UUmAssert(SSgPlatformInitialized); - + // clear the vars inSoundChannel->ps.sound_channel = NULL; inSoundChannel->ps.sound = NULL; inSoundChannel->ps.pan = SScPan_Middle; inSoundChannel->ps.volume = SScVolume_Max; inSoundChannel->ps.status = SScStatus_None; - + // ------------------------------ // Sound Channel // ------------------------------ @@ -152,7 +152,7 @@ SSrPlatform_SoundChannel_Initialize( "Unable to initialize the sound channel"); return; } - + // ------------------------------ // Sound // ------------------------------ @@ -165,7 +165,7 @@ SSrPlatform_SoundChannel_Initialize( inSoundChannel, "Unable to allocate memory for the sound"); } - + // get a pointer to the sound sound = inSoundChannel->ps.sound; @@ -175,7 +175,7 @@ SSrPlatform_SoundChannel_Initialize( sound->sampleRate = 0; sound->numFrames = 0; sound->sampleSize = 0; - + sound->loopStart = 0; sound->loopEnd = 0; sound->encode = extSH; @@ -189,7 +189,7 @@ SSrPlatform_SoundChannel_GetStatus( SStSoundChannel *inSoundChannel) { UUmAssert(SSgPlatformInitialized); - + return inSoundChannel->ps.status; } @@ -200,32 +200,32 @@ SSrPlatform_SoundChannel_Play( { SndCommand cmd; OSErr err; - + UUmAssert(SSgPlatformInitialized); - + // flush the sound channels command buffer SSmSetSndCommand(cmd, flushCmd, 0, 0); err = SndDoImmediate(inSoundChannel->ps.sound_channel, &cmd); SSmCheckSndError(err); - + // set the volume SSrPlatform_SoundChannel_SetVolume(inSoundChannel, inSoundChannel->ps.volume); - + // set the pan SSrPlatform_SoundChannel_SetPan(inSoundChannel, inSoundChannel->ps.pan); - + // set the status field inSoundChannel->ps.status = SScStatus_Playing; if (inSoundChannel->flags & SScFlag_Loop) { inSoundChannel->ps.status = SScStatus_Looping; } - + // play the sound SSmSetSndCommand(cmd, bufferCmd, 0, (UUtUns32)inSoundChannel->ps.sound); err = SndDoImmediate(inSoundChannel->ps.sound_channel, &cmd); SSmCheckSndError(err); - + // queue a callback if (err == noErr) { @@ -257,16 +257,16 @@ SSrPlatform_SoundChannel_SetPan( UUtUns16 right_volume; UUtUns16 left_volume; float scale; - + UUmAssert(SSgPlatformInitialized); - + // set the new pan inSoundChannel->ps.pan = inPan; - + // set up the volumes right_volume = left_volume = inSoundChannel->ps.volume; - - + + // calculate the new pan if (inPan > SScPan_Middle) { @@ -280,7 +280,7 @@ SSrPlatform_SoundChannel_SetPan( scale = (float)inPan / (float)(SScPan_Left - SScPan_Middle); right_volume = (UUtUns32)((float)right_volume * scale); } - + // set the sound channel's pan SSmSetSndCommand(cmd, volumeCmd, 0, UUmMakeLong(right_volume, left_volume)); err = SndDoImmediate(inSoundChannel->ps.sound_channel, &cmd); @@ -294,31 +294,31 @@ SSrPlatform_SoundChannel_SetSound( SStSound *inSound) { ExtSoundHeaderPtr sound; - + UUmAssert(SSgPlatformInitialized); - + // if inSound == NULL, then exit, the buffer has been cleared if (inSound == NULL) { return UUcTrue; } - + // get a pointer to the sound sound = inSoundChannel->ps.sound; - + // set up the sound sound->samplePtr = (char*)inSound->data; sound->numChannels = inSound->numChannels; sound->sampleRate = inSound->sampleRate << 16; - sound->numFrames = + sound->numFrames = (inSound->numBits == 8) ? (inSound->numBytes) / inSound->numChannels : (inSound->numBytes / 2) / inSound->numChannels; sound->sampleSize = inSound->numBits; - + // set the sound inSoundChannel->sound = inSound; - + return UUcTrue; } @@ -329,10 +329,10 @@ SSrPlatform_SoundChannel_SetVolume( UUtInt32 inVolume) { UUmAssert(SSgPlatformInitialized); - + // set the volume variable inSoundChannel->ps.volume = inVolume; - + // let SSrPlatform_SoundChannel_SetPan() set the volume for the // left and right channels SSrPlatform_SoundChannel_SetPan( @@ -347,19 +347,19 @@ SSrPlatform_SoundChannel_Stop( { OSErr err; SndCommand cmd; - + UUmAssert(SSgPlatformInitialized); - + // stop the sound channel SSmSetSndCommand(cmd, quietCmd, 0, 0); err = SndDoImmediate(inSoundChannel->ps.sound_channel, &cmd); SSmCheckSndError(err); - + // flush the queue SSmSetSndCommand(cmd, flushCmd, 0, 0); err = SndDoImmediate(inSoundChannel->ps.sound_channel, &cmd); SSmCheckSndError(err); - + // set the status field inSoundChannel->ps.status = SScStatus_None; } @@ -400,25 +400,25 @@ SSrPlatform_Initialize( NumVersion sound_manager_version; OSErr err; UUtInt32 response; - + // ------------------------------ // make sure the needed sound capabilities exist on this hardware // ------------------------------ - + // get the sound manager version sound_manager_version = SndSoundManagerVersion(); if (sound_manager_version.majorRev < 3) return UUcError_Generic; - + // gestalt the sound attributes err = Gestalt(gestaltSoundAttr, &response); if (err != noErr) return UUcError_Generic; - + // check for needed properties if (!(response & (1 << gestaltStereoCapability))) return UUcError_Generic; if (!(response & (1 << gestaltMultiChannels))) return UUcError_Generic; if (!(response & (1 << gestalt16BitSoundIO))) return UUcError_Generic; if (!(response & (1 << gestalt16BitAudioSupport))) return UUcError_Generic; - + // ------------------------------ // Sound Callback // ------------------------------ @@ -429,19 +429,19 @@ SSrPlatform_Initialize( UUrError_Report(UUcError_Generic, "Unable to create sound callback UPP"); return UUcError_Generic; } - + #if 0 // install the byte swapper - error = + error = TMrTemplate_InstallByteSwap( SScTemplate_Sound, SSiPlatform_SoundByteSwapper); UUmError_ReturnOnErrorMsg(error, "Could not install sound byte swapper"); #endif - + // init the main vars SSgPlatformInitialized = UUcTrue; - + return UUcError_None; } @@ -490,12 +490,12 @@ SSrPlatform_Sound_ProcHandler( { SStSound *sound; SStSound_PrivateData *private_data; - + // get the data sound = (SStSound*)inInstancePtr; private_data = (SStSound_PrivateData*)inPrivateData; UUmAssert(private_data); - + // handle the message switch(inMessage) { @@ -506,22 +506,22 @@ SSrPlatform_Sound_ProcHandler( UUtUns32 i; UUtUns32 num_shorts; UUtUns16 *data; - + // setup the vars num_shorts = sound->numBytes / 2; data = (UUtUns16*)sound->data; - + // swap all of the data for (i = 0; i < num_shorts; i++) { UUrSwap_2Byte(data++); } - + private_data->byte_swapped = UUcTrue; } break; } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem/Platform_MacOS/BFW_SS_Platform_MacOS.h b/BungieFrameWork/BFW_Source/BFW_SoundSystem/Platform_MacOS/BFW_SS_Platform_MacOS.h index a6361a7..d4fc1b2 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem/Platform_MacOS/BFW_SS_Platform_MacOS.h +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem/Platform_MacOS/BFW_SS_Platform_MacOS.h @@ -19,7 +19,7 @@ typedef struct SStPlatformSpecific UUtInt32 pan; UUtInt32 volume; UUtInt16 status; - + } SStPlatformSpecific; // ====================================================================== diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_IMA.c b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_IMA.c index 7670d4b..81df793 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_IMA.c +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_IMA.c @@ -24,7 +24,7 @@ typedef struct SStIMA_DecompressorState const UUtUns8 *source_samples; UUtInt16 predsample; UUtInt8 index; - + } SStIMA_DecompressorState; typedef struct SStIMA_Intermediate @@ -37,7 +37,7 @@ typedef struct SStIMA_Intermediate short number_of_channels; long sample_frame_count; void *samples; - + } SStIMA_Intermediate; // ====================================================================== @@ -46,8 +46,8 @@ typedef struct SStIMA_Intermediate const UUtInt8 SSgIndextab[]= { -1,-1,-1,-1, 2, 4, 6, 8, -1,-1,-1,-1, 2, 4, 6, 8}; - -const UUtInt16 SSgSteptab[89]= { + +const UUtInt16 SSgSteptab[89]= { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, @@ -71,8 +71,8 @@ static void SSiIMA_CompressPacket( short *source, unsigned int number_of_samples, - UUtUns8 *destination, - short *compression_index, + UUtUns8 *destination, + short *compression_index, short *predicted) { PCM_32 predsample; @@ -80,12 +80,12 @@ SSiIMA_CompressPacket( int step; int codebuf; UUtUns32 sample; - + predsample = *predicted; index = *compression_index; step = SSgSteptab[index]; codebuf = 0; - + for (sample = 0; sample < number_of_samples; sample++) { int i; @@ -93,9 +93,9 @@ SSiIMA_CompressPacket( int code; int tempstep; PCM_32 diff; - + diff = (PCM_32)source[sample] - predsample; /* difference may require 17 bits! */ - + if (diff >= 0) /* set sign bit */ { code = 0; @@ -105,7 +105,7 @@ SSiIMA_CompressPacket( code = 8; diff = -diff; } - + mask = 4; tempstep = step; for(i = 0; i < 3; i++) /* quantize diff sample */ @@ -118,31 +118,31 @@ SSiIMA_CompressPacket( tempstep >>= 1; mask >>= 1; } - + // cache the writes - if (sample & 1) + if (sample & 1) { destination[sample >> 1] = (code << 4) | codebuf; } - else + else { codebuf = code & 0xf; /* buffer for write with next nibble */ } - + /* compute new sample estimate predsample */ diff = step >> 3; if (code & 4) { diff += step; } if (code & 2) { diff += step >> 1; } if (code & 1) { diff += step >> 2; } - + if (code & 8) { diff = -diff; } predsample= UUmPin(predsample + diff, -32768, 32767); - + /* compute new stepsize step */ - index = UUmPin(index + SSgIndextab[code], 0, 88); + index = UUmPin(index + SSgIndextab[code], 0, 88); step = SSgSteptab[index]; } - + *predicted = (short) predsample; *compression_index = index; } @@ -164,12 +164,12 @@ SSiIMA_CompressMono( short *samples; int silence; char *new_samples; - + UUmAssert(inNumChannels == 1); UUmAssert(inBuffer); UUmAssert(outCompressedBuffer); UUmAssert(outCompressedBufferNumFrames); - + /* Simply take the original samples, grab them in chunks of packets, and compress them. @@ -182,13 +182,13 @@ SSiIMA_CompressMono( padded_length = sizeof(short) * padded_samples_per_channel; samples = (short*)UUrMemory_Block_New(padded_length); silence = (inNumBits == 8) ? 0x80 : 0; - + UUmAssert(samples); - + // fill with silence and copy the original data into the padded buffer. UUrMemory_Set8(samples, silence, padded_length); UUrMemory_MoveFast(inBuffer, samples, sizeof(short) * number_of_samples); - + // compress the padded buffer new_samples = (char*) UUrMemory_Block_New(packet_count * sizeof(SStIMA_SampleData)); @@ -198,12 +198,12 @@ SSiIMA_CompressMono( short ima_index; short ima_predicted; long index; - + sample_data = (SStIMA_SampleData*)new_samples; source = samples; ima_index = 0; ima_predicted = 0; - + for (index = 0; index < packet_count; ++index) { // These two bytes of "state" contain the step index, a 7 bit value @@ -213,22 +213,22 @@ SSiIMA_CompressMono( (short)(ima_predicted & 0xFF80) | (ima_index & 0x007F); UUmSwapBig_2Byte(&sample_data->state); - + SSiIMA_CompressPacket( source, SScIMA_SamplesPerPacket, sample_data->samples, &ima_index, &ima_predicted); - + sample_data++; source += SScIMA_SamplesPerPacket; } - + *outCompressedBuffer = (UUtUns8*)new_samples; *outCompressedBufferNumFrames = packet_count; } - + if (samples) { UUrMemory_Block_Delete(samples); @@ -259,7 +259,7 @@ SSiIMA_CompressStereo( short *left; short *right; int index; - + /* The original stereo sound samples (from the AIFF chunk) come in the format L0 R0 L1 R1 L2 R2 L3 R3 .... Ln Rn @@ -268,14 +268,14 @@ SSiIMA_CompressStereo( pain in the ass for us. Thus, if there are, say, 3 samples per packet, the Mac wants this: L0 L1 L2 R0 R1 R2 .... Ln Ln+1 Ln+2 Rn Rn+1 Rn+2 */ - + UUmAssert(inNumChannels == 2); UUmAssert(inBuffer); UUmAssert(outCompressedBuffer); UUmAssert(outCompressedBufferNumFrames); - + number_of_samples_per_channel = inNumFrames; - + // Pad, if necessary, to an even multiple of SScIMA_SamplesPerPacket packets_per_channel = (number_of_samples_per_channel / SScIMA_SamplesPerPacket) + @@ -283,92 +283,92 @@ SSiIMA_CompressStereo( padded_samples_per_channel = packets_per_channel * SScIMA_SamplesPerPacket; padded_length = sizeof(short) * padded_samples_per_channel; total_packet_count = inNumChannels * packets_per_channel; - + left_samples = (short*)UUrMemory_Block_New(padded_length); right_samples = (short*)UUrMemory_Block_New(padded_length); silence = (inNumBits == 8) ? 0x80 : 0; - + UUmAssert(left_samples); UUmAssert(right_samples); - + // Initially fill with silence UUrMemory_Set8(left_samples, silence, padded_length); - UUrMemory_Set8(right_samples, silence, padded_length); - + UUrMemory_Set8(right_samples, silence, padded_length); + // Split the old sound samples into left and right sample buffers source = (short*)inBuffer; left = left_samples; right = right_samples; - + for (index = 0; index < number_of_samples_per_channel; ++index) { *left++ = *source++; *right++ = *source++; } - + // IMA compress the left and right buffers, alternating left packet, right packet... new_samples = (char*)UUrMemory_Block_New( total_packet_count * sizeof(SStIMA_SampleData)); - + if(new_samples) { SStIMA_SampleData *sample_data; short left_ima_index; short left_ima_predicted; - + short right_ima_index; short right_ima_predicted; - + sample_data = (SStIMA_SampleData*)new_samples; left = left_samples; left_ima_index = 0; left_ima_predicted = 0; - + right = right_samples; right_ima_index = 0; right_ima_predicted = 0; - + for(index = 0; index < packets_per_channel; ++index) { // These two bytes of "state" contains the step index, a 7 bit value in the // low byte, and the 9 most significant bits of the predictor value. - + sample_data->state = (short)(left_ima_predicted & 0xFF80) | (left_ima_index & 0x007F); UUmSwapBig_2Byte(&sample_data->state); - + SSiIMA_CompressPacket( left, SScIMA_SamplesPerPacket, sample_data->samples, &left_ima_index, &left_ima_predicted); - + sample_data++; left += SScIMA_SamplesPerPacket; - + sample_data->state = (short)(right_ima_predicted & 0xFF80) | (right_ima_index & 0x007F); UUmSwapBig_2Byte(&sample_data->state); - + SSiIMA_CompressPacket( right, SScIMA_SamplesPerPacket, sample_data->samples, &right_ima_index, &right_ima_predicted); - + sample_data++; right += SScIMA_SamplesPerPacket; } - + *outCompressedBuffer = (UUtUns8*)new_samples; *outCompressedBufferNumFrames = packets_per_channel; } - + // Release the left and right sample buffers if (left_samples) { UUrMemory_Block_Delete(left_samples); } if (right_samples) { UUrMemory_Block_Delete(right_samples); } @@ -395,7 +395,7 @@ SSrIMA_CompressSoundData_Internal( outCompressedBuffer, outCompressedBufferNumFrames); break; - + case 1: SSiIMA_CompressMono( inNumChannels, @@ -425,7 +425,7 @@ SSrIMA_CompressSoundData( // inSoundData has been compressed UUrMemory_Block_Delete(inSoundData->data); inSoundData->data = compressed_buffer; - + inSoundData->flags |= SScSoundDataFlag_Compressed; inSoundData->num_bytes = (compressed_buffer_num_packets * sizeof(SStIMA_SampleData) * num_channels); } @@ -442,7 +442,7 @@ SSrIMA_CompressSoundData( #if 1 // ---------------------------------------------------------------------- -static void +static void SSiIMA_DecompressState( SStIMA_DecompressorState *ioState) { @@ -452,24 +452,24 @@ SSiIMA_DecompressState( UUtUns8 codebuf; UUtInt8 index; UUtUns16 *destination; - + UUmAssert(ioState); UUmAssert(ioState->source_samples); UUmAssert(ioState->destination); - + destination = ioState->destination; predsample = ioState->predsample; index = ioState->index; codebuf = 0; // just a reminder. (read first time through) - + // reset the step.. step = SSgSteptab[index]; - + for (sample = 0; sample < SScIMA_SamplesPerPacket; sample++) { PCM_32 diff; UUtUns8 code; - + // cache every other sample. if (sample & 1) /* two samples per inbuf char */ { @@ -480,19 +480,19 @@ SSiIMA_DecompressState( codebuf = ioState->source_samples[sample>>1]; /* buffer two IMA nibbles */ code = codebuf & 0xF; } - + /* compute new sample estimate predsample */ diff = step >> 3; if (code & 4) { diff += step; } if (code & 2) { diff += step >> 1; } if (code & 1) { diff += step >> 2; } - + if (code & 8) { diff = -diff; } predsample = UUmPin(predsample + diff, -32768, 32767); - + *destination = (UUtUns16)predsample; /* store estimate to output buffer */ destination++; - + /* compute new stepsize step */ index = UUmPin(index + SSgIndextab[code], 0, 88); step = SSgSteptab[index]; @@ -509,13 +509,13 @@ SSiIMA_DecompressPacket( SStIMA_DecompressorState ima_state; UUmAssert(inDestination); - + // apple has 64 samples per packet.. ima_state.destination = inDestination; ima_state.source_samples = inSamples; ima_state.predsample = (inState & 0xFF80); // 9 bit predictor ima_state.index = (inState & 0x007F); // 7 bit index - + // override the defaults... SSiIMA_DecompressState(&ima_state); } @@ -536,23 +536,23 @@ SSiIMA_DecompressSoundData_Mono( UUtUns32 packet_count = inSoundData->num_bytes / (num_channels * sizeof(SStIMA_SampleData)); number_of_packets = UUmMin(inDecompressDataLength, (packet_count - inStartPacket)); - + destination = (UUtUns16*)ioDecompressedData; sample_data = ((SStIMA_SampleData*)inSoundData->data) + inStartPacket; - + for (packet_index = 0; packet_index < number_of_packets; packet_index++) { UUtUns16 state; - + state = sample_data->state; UUmSwapBig_2Byte(&state); - + SSiIMA_DecompressPacket(state, sample_data->samples, destination); - + destination += SScIMA_SamplesPerPacket; sample_data++; } - + return number_of_packets; } @@ -572,16 +572,16 @@ SSiIMA_DecompressSoundData_Stereo( UUtUns32 packet_count = inSoundData->num_bytes / (num_channels * sizeof(SStIMA_SampleData)); number_of_packets = UUmMin(inDecompressDataLength, (packet_count - inStartPacket)); - + destination = (UUtUns16*)ioDecompressedData; sample_data = ((SStIMA_SampleData*)inSoundData->data) + (inStartPacket * 2); - + for (packet_index = 0; packet_index < number_of_packets; packet_index++) { UUtUns16 state; UUtUns16 left_samples[SScIMA_SamplesPerPacket]; UUtUns16 right_samples[SScIMA_SamplesPerPacket]; - + state = sample_data->state; UUmSwapBig_2Byte(&state); SSiIMA_DecompressPacket(state, sample_data->samples, left_samples); sample_data++; @@ -589,7 +589,7 @@ SSiIMA_DecompressSoundData_Stereo( state = sample_data->state; UUmSwapBig_2Byte(&state); SSiIMA_DecompressPacket(state, sample_data->samples, right_samples); sample_data++; - + // Interleave the samples from the left and right channels { UUtUns16 *left = left_samples; @@ -603,7 +603,7 @@ SSiIMA_DecompressSoundData_Stereo( } } } - + return number_of_packets; } @@ -617,11 +617,11 @@ SSrIMA_DecompressSoundData( { UUtUns32 num_packets_decompressed; UUtUns32 num_channels = SSrSound_GetNumChannels(inSoundData); - + UUmAssert(inSoundData); UUmAssert(ioDecompressedData); UUmAssert(inDecompressDataLength != 0); - + num_packets_decompressed = 0; if (num_channels == 1) { @@ -630,7 +630,7 @@ SSrIMA_DecompressSoundData( inSoundData, ioDecompressedData, inDecompressDataLength, - inStartPacket); + inStartPacket); } else if (num_channels == 2) { @@ -641,8 +641,8 @@ SSrIMA_DecompressSoundData( inDecompressDataLength, inStartPacket); } - + return num_packets_decompressed; } -#endif \ No newline at end of file +#endif diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_IMA.h b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_IMA.h index 7ce7ef9..993782f 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_IMA.h +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_IMA.h @@ -23,7 +23,7 @@ typedef struct SStIMA_SampleData { UUtUns16 state; UUtUns8 samples[32]; - + } SStIMA_SampleData; // ====================================================================== @@ -40,6 +40,6 @@ SSrIMA_DecompressSoundData( void SSrIMA_CompressSoundData( SStSoundData *inSoundData); - + // ====================================================================== #endif /* BFW_SS2_IMA_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_MSADPCM.c b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_MSADPCM.c index add7847..ec0c79b 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_MSADPCM.c +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_MSADPCM.c @@ -12,7 +12,7 @@ #if defined(UUmPlatform) && (UUmPlatform == UUmPlatform_Win32) -WAVEFORMATEX wave_format_ex_mono = +WAVEFORMATEX wave_format_ex_mono = { WAVE_FORMAT_PCM, 1, @@ -23,7 +23,7 @@ WAVEFORMATEX wave_format_ex_mono = 0 }; -WAVEFORMATEX wave_format_ex_stereo = +WAVEFORMATEX wave_format_ex_stereo = { WAVE_FORMAT_PCM, 2, @@ -51,13 +51,13 @@ SSrMSADPCM_CompressSoundData( UUtUns32 buffer_size; WAVEFORMATEX *src_wave_format_ex = SSrSound_IsStereo(inSoundData) ? &wave_format_ex_stereo : &wave_format_ex_mono; WAVEFORMATEX *dst_wave_format_ex = (WAVEFORMATEX *) (SSrSound_IsStereo(inSoundData) ? &SSgWaveFormat_Stereo : &SSgWaveFormat_Mono); - + buffer = NULL; acm = NULL; delete_me = NULL; - + if (inSoundData->data == NULL) { return; } - + // get the format for the PCM header result = acmFormatSuggest( @@ -67,7 +67,7 @@ SSrMSADPCM_CompressSoundData( sizeof(SStFormat), ACM_FORMATSUGGESTF_WFORMATTAG); if (result != 0) { goto cleanup; } - + // open the stream result = acmStreamOpen( @@ -80,7 +80,7 @@ SSrMSADPCM_CompressSoundData( 0, ACM_STREAMOPENF_NONREALTIME); if (result != 0) { goto cleanup; } - + // calculate the buffer size result = acmStreamSize( @@ -89,11 +89,11 @@ SSrMSADPCM_CompressSoundData( &buffer_size, ACM_STREAMSIZEF_SOURCE); if (result != 0) { goto cleanup; } - + // allocate memory for the decompression buffer buffer = (UUtUns8*)UUrMemory_Block_NewClear(buffer_size); if (buffer == NULL) { goto cleanup; } - + // prepare the stream header UUrMemory_Clear(&stream, sizeof(ACMSTREAMHEADER)); stream.cbStruct = sizeof(ACMSTREAMHEADER); @@ -101,39 +101,39 @@ SSrMSADPCM_CompressSoundData( stream.cbSrcLength = inSoundData->num_bytes; stream.pbDst = buffer; stream.cbDstLength = buffer_size; - + result = acmStreamPrepareHeader(acm, &stream, 0); if (result != 0) { goto cleanup; } - + // decompress the sound data into the buffer result = acmStreamConvert(acm, &stream, 0); if (result == 0) { delete_me = inSoundData->data; - + // inSoundData has been compressed inSoundData->flags |= SScSoundDataFlag_Compressed; inSoundData->num_bytes = stream.cbDstLengthUsed; inSoundData->data = buffer; } - + // unprepare the stream header result = acmStreamUnprepareHeader(acm, &stream, 0); if (result != 0) { goto cleanup; } - + cleanup: if (delete_me != NULL) { UUrMemory_Block_Delete(delete_me); delete_me = NULL; } - + if ((inSoundData->data != buffer) && (buffer != NULL)) { UUrMemory_Block_Delete(buffer); buffer = NULL; } - + if (acm != NULL) { result = acmStreamClose(acm, 0); @@ -152,7 +152,7 @@ SSrMSADPCM_CalculateNumSamples( HACMSTREAM acm; UUtUns32 buffer_size; WAVEFORMATEX *wave_format_ex = (WAVEFORMATEX *) (SSrSound_IsStereo(inSoundData) ? &SSgWaveFormat_Stereo : &SSgWaveFormat_Mono); - + UUmAssert(inSoundData); if ((inSoundData->flags & SScSoundDataFlag_Compressed) == 0) { UUmAssert(0); @@ -161,7 +161,7 @@ SSrMSADPCM_CalculateNumSamples( num_samples = 0; acm = NULL; - + // get the format for the PCM header DstFormat.wFormatTag = WAVE_FORMAT_PCM; result = @@ -172,7 +172,7 @@ SSrMSADPCM_CalculateNumSamples( sizeof(WAVEFORMATEX), ACM_FORMATSUGGESTF_WFORMATTAG); if (result != 0) { goto cleanup; } - + // open the stream result = acmStreamOpen( @@ -185,7 +185,7 @@ SSrMSADPCM_CalculateNumSamples( 0, ACM_STREAMOPENF_NONREALTIME); if (result != 0) { goto cleanup; } - + // calculate the buffer size result = acmStreamSize( @@ -194,17 +194,17 @@ SSrMSADPCM_CalculateNumSamples( &buffer_size, ACM_STREAMSIZEF_SOURCE); if (result != 0) { goto cleanup; } - + // calculate the approximate number of samples that fit into this buffer size (in bytes) num_samples = buffer_size / (DstFormat.wBitsPerSample >> 3); -cleanup: +cleanup: if (acm != NULL) { result = acmStreamClose(acm, 0); acm = NULL; } - + return num_samples; } diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_MSADPCM.h b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_MSADPCM.h index 22dec3a..af7b160 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_MSADPCM.h +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_MSADPCM.h @@ -24,6 +24,6 @@ SSrMSADPCM_CompressSoundData( UUtUns32 SSrMSADPCM_CalculateNumSamples( SStSoundData *inSoundData); - + // ====================================================================== #endif /* BFW_SS2_MSADPCM_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_Platform.h b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_Platform.h index 586b216..ace59e3 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_Platform.h +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_Platform.h @@ -23,26 +23,26 @@ SS2rPlatform_SoundChannel_Initialize( void SS2rPlatform_SoundChannel_Pause( SStSoundChannel *inSoundChannel); - + void SS2rPlatform_SoundChannel_Play( SStSoundChannel *inSoundChannel); - + void SS2rPlatform_SoundChannel_Resume( SStSoundChannel *inSoundChannel); - + #if UUmOpenAL UUtBool SS2rPlatform_SoundChannel_IsPlaying( SStSoundChannel *inSoundChannel); #endif - + UUtBool SS2rPlatform_SoundChannel_SetSoundData( SStSoundChannel *inSoundChannel, SStSoundData *inSoundData); - + void SS2rPlatform_SoundChannel_SetPan( SStSoundChannel *inSoundChannel, @@ -53,7 +53,7 @@ void SSiSoundChannel_SetPaused( SStSoundChannel *inSoundChannel, UUtBool inPaused); - + void SS2rPlatform_SoundChannel_SetPitch( SStSoundChannel *inSoundChannel, @@ -63,19 +63,19 @@ void SS2rPlatform_SoundChannel_SetVolume( SStSoundChannel *inSoundChannel, float inVolume); - + void SS2rPlatform_SoundChannel_Silence( SStSoundChannel *inSoundChannel); - + void SS2rPlatform_SoundChannel_Stop( SStSoundChannel *inSoundChannel); - + void SS2rPlatform_SoundChannel_Terminate( SStSoundChannel *inSoundChannel); - + // ---------------------------------------------------------------------- UUtError SS2rPlatform_Initialize( @@ -86,7 +86,7 @@ SS2rPlatform_Initialize( UUtError SS2rPlatform_InitializeThread( void); - + void SS2rPlatform_TerminateThread( void); @@ -120,14 +120,14 @@ SS2rPlatform_GetDebugNeeds( void SS2rPlatform_ShowDebugInfo_Overall( IMtPoint2D *inDest); - + void SS2rPlatform_PerformanceStartFrame( void); - + void SS2rPlatform_PerformanceEndFrame( void); - + // ====================================================================== #endif /* BFW_SS2_PLATFORM_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_Private.h b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_Private.h index ffdcafa..6c9a5ee 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_Private.h @@ -69,12 +69,12 @@ struct SStSoundChannel float channel_volume; float distance_volume; float permutation_volume; - + float pan_left; // only used for debugging float pan_right; // only used for debugging - + SStSoundChannel_PlatformData pd; - + }; // ====================================================================== @@ -92,27 +92,27 @@ SSiSoundChannel_CanPan( UUtBool SSiSoundChannel_IsAmbient( SStSoundChannel *inSoundChannel); - + UUtBool SSiSoundChannel_IsLocked( SStSoundChannel *inSoundChannel); - + UUtBool SSiSoundChannel_IsLooping( SStSoundChannel *inSoundChannel); - + UUtBool SSiSoundChannel_IsPaused( SStSoundChannel *inSoundChannel); - + UUtBool SSiSoundChannel_IsPlaying( SStSoundChannel *inSoundChannel); - + UUtBool SSiSoundChannel_IsUpdating( SStSoundChannel *inSoundChannel); - + void SSiSoundChannel_SetAmbient( SStSoundChannel *inSoundChannel, @@ -151,11 +151,11 @@ SSiSoundChannels_GetChannelByID( UUtUns32 SSiSoundChannels_GetNumChannels( void); - + // ---------------------------------------------------------------------- UUtBool SSiPlayingAmbient_UpdateSoundChannel( SStSoundChannel *inSoundChannel); - + // ====================================================================== #endif /* BFW_SS2_PRIVATE_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_RegisterTemplate.c b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_RegisterTemplate.c index 113d86d..573e18a 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_RegisterTemplate.c +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SS2_RegisterTemplate.c @@ -19,10 +19,10 @@ SS2rRegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register(SScTemplate_SoundData, sizeof(SStSoundData), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(SScTemplate_Subtitle, sizeof(SStSubtitle), TMcFolding_Allow); UUmError_ReturnOnError(error); diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SoundSystem2.c b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SoundSystem2.c index 8c45183..52bae32 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SoundSystem2.c +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/BFW_SoundSystem2.c @@ -49,7 +49,7 @@ #define UUmGet4BytesFromBuffer(src,dst,type,swap_it) \ (dst) = *((type*)(src)); \ *(UUtInt8**)&(src) += sizeof(type); \ - if ((swap_it)) { UUrSwap_4Byte(&(dst)); } + if ((swap_it)) { UUrSwap_4Byte(&(dst)); } #define UUmWrite4BytesToBuffer(buf,val,type,num_bytes,write_big) \ *((type*)(buf)) = (val); \ @@ -60,7 +60,7 @@ #define UUmGet2BytesFromBuffer(src,dst,type,swap_it) \ (dst) = *((type*)(src)); \ *(UUtInt8**)&(src) += sizeof(type); \ - if ((swap_it)) { UUrSwap_2Byte(&(dst)); } + if ((swap_it)) { UUrSwap_2Byte(&(dst)); } #define UUmWrite2BytesToBuffer(buf,val,type,num_bytes,write_big) \ *((type*)(buf)) = (val); \ @@ -97,7 +97,7 @@ enum enum { SScPAStage_None, - + SScPAStage_Done, SScPAStage_Start, SScPAStage_InSoundStart, @@ -131,7 +131,7 @@ typedef struct SStExtCommonChunk UUtInt16 sampleSize; /* number of bits per sample */ UUtUns32 sampleRate; /* number of frames per second */ UUtUns32 compressionType; /* compression type (4 character code) (undefined for non compressed AIFF files) */ - + } SStExtCommonChunk; typedef struct SStSoundDataChunk @@ -140,7 +140,7 @@ typedef struct SStSoundDataChunk UUtInt32 ckSize; /* chunk size */ UUtInt32 offset; /* offset to sound data */ UUtInt32 blockSize; /* size of alignment blocks */ - + } SStSoundDataChunk; // ---------------------------------------------------------------------- @@ -152,7 +152,7 @@ typedef struct SStPlayingAmbient SStSoundChannel *channel1; SStSoundChannel *channel2; UUtUns32 detail_time; - + UUtBool has_position; M3tPoint3D position; M3tVector3D direction; @@ -160,11 +160,11 @@ typedef struct SStPlayingAmbient float max_volume_distance; float min_volume_distance; float channel_volume; - + UUtUns32 volume_adjust_start_time; float volume_adjust_delta; float volume_adjust_final_volume; - + } SStPlayingAmbient; // ====================================================================== @@ -173,8 +173,8 @@ typedef struct SStPlayingAmbient #if UUmPlatform == UUmPlatform_Win32 -WAVEFORMAT_EX_ADPCM SSgWaveFormat_Mono = -{ +WAVEFORMAT_EX_ADPCM SSgWaveFormat_Mono = +{ WAVE_FORMAT_ADPCM, 1, 22050, @@ -207,8 +207,8 @@ WAVEFORMAT_EX_ADPCM SSgWaveFormat_Mono = (UUtInt16) 0xFF18 }; -WAVEFORMAT_EX_ADPCM SSgWaveFormat_Stereo = -{ +WAVEFORMAT_EX_ADPCM SSgWaveFormat_Stereo = +{ WAVE_FORMAT_ADPCM, 2, 22050, @@ -305,15 +305,15 @@ SStGuard *SSgGuardAll; static void SSiPlayingAmbient_Halt( SStPlayingAmbient *inPlayingAmbient); - + static void SS2iVolume_Update( void); - + static void SSiPlayingAmbient_Stall( SStSoundChannel *inSoundChannel); - + // ====================================================================== // functions // ====================================================================== @@ -322,9 +322,9 @@ SSiPlayingAmbient_Stall( static UUtUns32 SSiGetCacheFileVersion(void) { UUtUns32 version; - + version = SScSoundDataCacheFile_Version_Internal; - + if (SScCompressionMode_Mac == SSgCompressionMode) { version |= 0x80000000; } @@ -348,19 +348,19 @@ x80tof( { UUtInt16 sign; UUtInt16 exponent; - UUtUns32 mantissa; + UUtUns32 mantissa; float outf; - + /* 80-bit = sign 1, exp 15, mantissa 64 */ /* 32-bit = sign 1, exp 8, mantissa 23 */ UUmSwapBig_2Byte(&inData[0]); UUmSwapBig_2Byte(&inData[1]); UUmSwapBig_2Byte(&inData[2]); - + sign = inData[0] >> 15; exponent = (inData[0] & 0x7FFF) - 16382; mantissa = (inData[1] << 16) | inData[2]; - + outf = ((float)mantissa/(float)UUcMaxUns32) * (float)(1 << exponent) * @@ -380,7 +380,7 @@ UUrFindTag( char *src; UUtBool found; UUtUns32 src_tag; - + // find inTag in inSource src = (char*)inSource; src_tag = UUm4CharToUns32(src[0], src[1], src[2], src[3]); @@ -393,9 +393,9 @@ UUrFindTag( found = UUcTrue; break; } - + src++; - + src_tag <<= 8; src_tag |= src[3]; } @@ -416,15 +416,15 @@ UUrFindTagData( // clear the outgoing data *outData = NULL; *outLength = 0; - + if (UUrFindTag(inSource, inSourceLength, inTag, outData) == UUcTrue) { UUtUns32 length; UUtUns8 *src; - + // step over the tag src = *outData + 4; - + // get the length of the data length = *(UUtUns32*)src; if (inFileEndian == UUcFile_BigEndian) @@ -435,22 +435,22 @@ UUrFindTagData( { UUmSwapLittle_4Byte(&length); } - + if (length > inSourceLength) { return UUcError_Generic; } - + // step over the length src += 4; - + // set the outgoing data *outData = (UUtUns8*)src; *outLength = length; - + return UUcError_None; } - + return UUcError_Generic; } @@ -465,21 +465,21 @@ UUrWriteTagDataToBuffer( UUtFileEndian inWriteEndian) { UUtTag tag; - + UUmAssert(sizeof(UUtTag) == ((sizeof(UUtUns8) * 4) + sizeof(UUtUns32))); - + if (inDestinationSize < (inSourceDataLength + sizeof(UUtTag))) { UUmAssert(!"inDestinationSize is too small"); return 0; } - + tag.tag[0] = (UUtUns8)(inTag >> 24); tag.tag[1] = (UUtUns8)(inTag >> 16); tag.tag[2] = (UUtUns8)(inTag >> 8); tag.tag[3] = (UUtUns8)inTag; tag.size = inSourceDataLength; - + if (inWriteEndian == UUcFile_BigEndian) { UUmSwapBig_4Byte(&tag.size); @@ -488,14 +488,14 @@ UUrWriteTagDataToBuffer( { UUmSwapLittle_4Byte(&tag.size); } - + // write the tag to the destination buffer UUrMemory_MoveFast(&tag, inDestinationBuffer, sizeof(UUtTag)); inDestinationBuffer += sizeof(UUtTag); - + // write teh source data to the destination buffer UUrMemory_MoveFast(inSourceData, inDestinationBuffer, inSourceDataLength); - + return (inSourceDataLength + sizeof(UUtTag)); } @@ -520,9 +520,9 @@ SSrShowDebugInfo( UUtError error; TStFontFamily *font_family; UUtUns32 platform_numlines; - + if (SSgShowDebugInfo == UUcFalse) { return; } - + error = TSrFontFamily_Get(TScFontFamily_Default, &font_family); if (error == UUcError_None) { @@ -530,70 +530,70 @@ SSrShowDebugInfo( } DCrText_SetSize(TScFontSize_Default); DCrText_SetStyle(TScFontStyle_Default); - + num_channels = SSiSoundChannels_GetNumChannels(); - + SS2rPlatform_GetDebugNeeds(&platform_numlines); width = 275; height = (10 + (UUtInt16)DCrText_GetLineHeight() * ((UUtInt16)num_channels + (UUtInt16)platform_numlines)); - + screen_dest.x = (float)((UUtInt16)M3rDraw_GetWidth() - width); screen_dest.y = 10.0f; screen_dest.z = 0.5f; screen_dest.invW = 2.0f; - + partspec = PSrPartSpec_LoadByType(PScPartSpecType_BackgroundColor_Blue); PSrPartSpec_Draw(partspec, PScPart_All, &screen_dest, (UUtInt16) width, (UUtInt16) height, (M3cMaxAlpha >> 2)); - + DCrText_SetFormat(TSc_HLeft); - + dest.y = (UUtInt16)(screen_dest.y) + DCrText_GetLineHeight(); - + for (i = 0; i < num_channels; i++) { SStSoundChannel *channel; IMtShade shade; - + channel = SSiSoundChannels_GetChannelByID(i); if (channel == NULL) { break; } - + shade = (channel->flags & SScSoundChannelFlag_Mono) ? IMcShade_Green : IMcShade_Red; DCrText_SetShade(shade); - + dest.x = (UUtInt16)screen_dest.x + 5; sprintf(string, "chnl %d", i); DCrText_DrawText(string, NULL, &dest); dest.x += 35; - + sprintf(string, "%1.3f", channel->volume); - DCrText_DrawText(string, NULL, &dest); + DCrText_DrawText(string, NULL, &dest); dest.x += 25; - + // sprintf(string, "%1.3f", channel->distance_to_listener); -// DCrText_DrawText(string, NULL, &dest); +// DCrText_DrawText(string, NULL, &dest); // dest.x += 25; - + if (SSiSoundChannel_IsPlaying(channel)) { sprintf(string, "%s", "P"); DCrText_DrawText(string, NULL, &dest); } dest.x += 10; - + if (SSiSoundChannel_IsLooping(channel)) { sprintf(string, "%s", "l"); DCrText_DrawText(string, NULL, &dest); } dest.x += 10; - + if (SSiSoundChannel_IsLocked(channel)) { sprintf(string, "%s", "L"); DCrText_DrawText(string, NULL, &dest); } dest.x += 10; - + if (SSiSoundChannel_CanPan(channel)) { sprintf(string, "%1.1f %1.1f", channel->pan_left, channel->pan_right); @@ -606,7 +606,7 @@ SSrShowDebugInfo( DCrText_DrawText(string, NULL, &dest); } dest.x += 40; - + DCrText_SetShade(shade); if (SSiSoundChannel_IsPlaying(channel)) { @@ -621,10 +621,10 @@ SSrShowDebugInfo( } } dest.x += 150; - + dest.y += DCrText_GetLineHeight(); } - + dest.x = (UUtInt16)screen_dest.x + 5; SS2rPlatform_ShowDebugInfo_Overall(&dest); } @@ -660,7 +660,7 @@ SSrNameIsValidDialogName( static const char* SSiSubtitleArray_FindByName( SStSubtitle *inArray, - const char *inName) + const char *inName) { const char *result = NULL; @@ -713,10 +713,10 @@ SSiSubtitleArray_FindByNumber( UUtBool is_equal; const char *name; UUtUns32 compare_len; - + if (isdigit(compare_string[0])) { name = inName + 1; } else { name = inName; } - + compare_len = strlen(compare_string); is_equal = (UUrString_CompareLen_NoCase(compare_string, name, compare_len) == 0); @@ -727,7 +727,7 @@ SSiSubtitleArray_FindByNumber( is_equal &= compare_string[4] == inName[4]; is_equal &= compare_string[6] == inName[6]; is_equal &= compare_string[7] == inName[7]; - + if (isalpha(compare_string[8]) == UUcTrue) { is_equal &= compare_string[8] == inName[8]; }*/ @@ -746,7 +746,7 @@ SSiSubtitleArray_FindByNumber( // ---------------------------------------------------------------------- const char* SSrSubtitle_Find( - const char *inName) + const char *inName) { return SSiSubtitleArray_FindByNumber(TMrInstance_GetFromName(SScTemplate_Subtitle, "subtitles"), inName); } @@ -754,7 +754,7 @@ SSrSubtitle_Find( // ---------------------------------------------------------------------- const char* SSrMessage_Find( - const char *inName) + const char *inName) { return SSiSubtitleArray_FindByName(TMrInstance_GetFromName(SScTemplate_Subtitle, "messages"), inName); } @@ -774,13 +774,13 @@ SSiSoundData_Compare( const SStSoundData *item2; const char *item1_name; const char *item2_name; - + item1 = *((SStSoundData**)inItem1); item2 = *((SStSoundData**)inItem2); - + item1_name = SSrSoundData_GetName(item1); item2_name = SSrSoundData_GetName(item2); - + return strcmp(item1_name, item2_name); } @@ -793,7 +793,7 @@ SSiSoundData_AddToArray( SStSoundData **sound_data_array; UUtUns32 num_elements; UUtUns32 found_location; - + // find the point in the array to insert the element sound_data_array = (SStSoundData**)UUrMemory_Array_GetMemory(SSgDynamicSoundData); num_elements = UUrMemory_Array_GetUsedElems(SSgDynamicSoundData); @@ -836,14 +836,14 @@ SSiSoundData_AddToArray( UUmAssert((found_location >= 0) && (found_location <= num_elements)); error = UUrMemory_Array_InsertElement(SSgDynamicSoundData, found_location, NULL); UUmError_ReturnOnError(error); - + // set the array element sound_data_array = (SStSoundData**)UUrMemory_Array_GetMemory(SSgDynamicSoundData); sound_data_array[found_location] = inSoundData; - + return UUcError_None; } - + // ---------------------------------------------------------------------- static void SSiSoundData_StoreDeallocatedPointer(SStSoundData *inSoundData) { @@ -863,7 +863,7 @@ static void SSiSoundData_StoreDeallocatedPointer(SStSoundData *inSoundData) static void SSiSoundData_Delete(SStSoundData *inSoundData) { UUmAssert(inSoundData); - + SSiSoundData_StoreDeallocatedPointer(inSoundData); // dispose of the data @@ -872,7 +872,7 @@ static void SSiSoundData_Delete(SStSoundData *inSoundData) UUrMemory_Block_Delete(inSoundData->data); inSoundData->data = NULL; } - + // dispose of the sound_data UUrMemory_Block_Delete(inSoundData); } @@ -885,9 +885,9 @@ SSiSoundData_ProcHandler( void *inPrivateData) { SStSoundData *sound_data; - + sound_data = (SStSoundData*)inInstancePtr; - + // handle the message switch (inMessage) { @@ -899,7 +899,7 @@ SSiSoundData_ProcHandler( SSiSoundData_StoreDeallocatedPointer(sound_data); break; } - + return UUcError_None; } @@ -923,7 +923,7 @@ void SSrSoundData_GetByName_StartCache(void) if (sound_directory) { UUrMemory_Block_Delete(sound_directory); } - } + } } SSgSoundCacheDepth++; @@ -1004,17 +1004,17 @@ SS2rSoundData_FlushDeallocatedPointers( // go through all of the groups and NULL out the sound_data pointers if they've been deleted group_array = (SStGroup**)UUrMemory_Array_GetMemory(SSgSoundGroups); - num_groups = UUrMemory_Array_GetUsedElems(SSgSoundGroups); + num_groups = UUrMemory_Array_GetUsedElems(SSgSoundGroups); for (itr = 0; itr < num_groups; itr++) { SStGroup *group; SStPermutation *perm_array; UUtUns32 num_perms; UUtUns32 itr2; - + // get a pointer to the sound group group = group_array[itr]; - + // update the sound data pointers for the permutations of the group perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(group->permutations); num_perms = UUrMemory_Array_GetUsedElems(group->permutations); @@ -1078,12 +1078,12 @@ SSrSoundData_GetByName( { UUtError error; SStSoundData *sound_data; - - + + UUmAssert(inSoundDataName); - + sound_data = NULL; - + // look for the a template instance of the sound data error = TMrInstance_GetDataPtr( @@ -1094,7 +1094,7 @@ SSrSoundData_GetByName( { return sound_data; } - + #if SHIPPING_VERSION == 0 { SStSoundData **sound_data_h; @@ -1107,13 +1107,13 @@ SSrSoundData_GetByName( // look for the sound in the dynamically allocated sound list sound_data_array = (SStSoundData**)UUrMemory_Array_GetMemory(SSgDynamicSoundData); num_sound_data = UUrMemory_Array_GetUsedElems(SSgDynamicSoundData); - + UUrString_Copy(search_sound_data_name, inSoundDataName, SScMaxNameLength); search_sound_data.flags = SScSoundDataFlag_DynamicAlloc; // so SSrSoundData_GetName() looks in the data pointer search_sound_data.data = search_sound_data_name; search_sound_data.num_bytes = 0; search_sound_data_ptr = &search_sound_data; - + sound_data_h = (SStSoundData**)bsearch( &search_sound_data_ptr, @@ -1129,7 +1129,7 @@ SSrSoundData_GetByName( } } -/*#if 0 // CB: this debugging information is no longer useful as +/*#if 0 // CB: this debugging information is no longer useful as // we are now storing all binary sound data in level 0, // but many sounds in specific levels -> this is not // necessarily a problem, so I'm removing this. @@ -1171,9 +1171,9 @@ SSrSoundData_GetName( const SStSoundData *inSoundData) { const char *name; - + UUmAssert(inSoundData); - + // if the sound data was dynamically allocated then the sound name is // stored at the end of the sound data if ((inSoundData->flags & SScSoundDataFlag_DynamicAlloc) != 0) @@ -1184,7 +1184,7 @@ SSrSoundData_GetName( { name = TMrInstance_GetInstanceName(inSoundData); } - + return name; } @@ -1230,7 +1230,7 @@ SSrSoundData_ReadCacheFile( if (error != UUcError_None) { goto exit; } - + BFrFile_Read(file, sizeof(UUtUns32), &version); BFrFile_Read(file, sizeof(UUtUns32), &time); @@ -1239,17 +1239,17 @@ SSrSoundData_ReadCacheFile( BFrFile_Close(file); goto exit; } - + // allocate space for the new sound new_sound_data = (SStSoundData*)UUrMemory_Block_New(sizeof(SStSoundData)); if (new_sound_data == NULL) { BFrFile_Close(file); goto exit; } - + // read the SStSoundData into new_sound_data BFrFile_Read(file, sizeof(SStSoundData), new_sound_data); - + // allocate memory for the data length = new_sound_data->num_bytes; new_sound_data->data = (UUtUns8*)UUrMemory_Block_NewClear(length); @@ -1260,13 +1260,13 @@ SSrSoundData_ReadCacheFile( new_sound_data = NULL; goto exit; } - + // read the file data into the data BFrFile_Read(file, length, new_sound_data->data); - + // close the file BFrFile_Close(file); - + exit: return new_sound_data; } @@ -1275,8 +1275,8 @@ SSrSoundData_ReadCacheFile( static SStSoundData * SSrSoundData_New_Uncached( BFtFileRef *inFileRef) -{ - UUtError error; +{ + UUtError error; SStSoundData temp_sound_data; SStSoundData *new_sound_data = NULL; UUtUns8 *uncompressed_data = NULL; @@ -1285,7 +1285,7 @@ SSrSoundData_New_Uncached( UUtUns8 *raw_data; UUtUns32 file_length, raw_data_length; const char *leaf_name; - + // load the file error = BFrFileRef_LoadIntoMemory(inFileRef, &file_length, &file_data); if (error != UUcError_None) { goto exit; } @@ -1303,14 +1303,14 @@ SSrSoundData_New_Uncached( &raw_data, &raw_data_length); if (error != UUcError_None) { goto exit; } - + // allocate space for the sound data new_sound_data = (SStSoundData*)UUrMemory_Block_New(sizeof(SStSoundData)); if (new_sound_data == NULL) { goto exit; } - + // copy temp_sound_data into new_sound_data UUrMemory_MoveFast(&temp_sound_data, new_sound_data, sizeof(SStSoundData)); - + // allocate space for the sound data data new_sound_data->data = (UUtUns8*)UUrMemory_Block_NewClear(raw_data_length); if (new_sound_data->data == NULL) { @@ -1318,18 +1318,18 @@ SSrSoundData_New_Uncached( new_sound_data = NULL; goto exit; } - + // copy the raw_data into new_sound_data->data UUrMemory_MoveFast(raw_data, new_sound_data->data, raw_data_length); - + exit: if (file_data != NULL) { UUrMemory_Block_Delete(file_data); } - + return new_sound_data; } - + // ---------------------------------------------------------------------- UUtError SSrSoundData_Load( @@ -1341,14 +1341,14 @@ SSrSoundData_Load( SStSoundData *sound_data = NULL; BFtFileRef ssc_file_ref; UUtUns32 uncompressed_time_stamp; - + UUmAssert(inFileRef); UUmAssert(outSoundData); ssc_file_ref = *inFileRef; BFrFileRef_SetLeafNameSuffex(&ssc_file_ref, "ssc"); - + // if the ssc file exists load it if (BFrFileRef_FileExists(&ssc_file_ref)) { // get the modification time @@ -1358,11 +1358,11 @@ SSrSoundData_Load( returncode = error; goto cleanup; } - + // load the ssc file sound_data = SSrSoundData_ReadCacheFile(inFileRef, &ssc_file_ref, uncompressed_time_stamp); } - + // if the ssc file does not exist, then read the sound file if (NULL == sound_data) { // load the sound file @@ -1372,7 +1372,7 @@ SSrSoundData_Load( returncode = UUcError_Generic; goto cleanup; } - + // compress the sound data if (SScCompressionMode_Mac == SSgCompressionMode) { SSrIMA_CompressSoundData(sound_data); @@ -1383,7 +1383,7 @@ SSrSoundData_Load( else { UUmAssert(!"invalid compression mode"); } - + // write a cache file error = SSrSoundData_WriteCacheFile(sound_data, uncompressed_time_stamp, &ssc_file_ref); @@ -1392,11 +1392,11 @@ SSrSoundData_Load( goto cleanup; } } - + // store the sound data inStoreSoundCallback(sound_data, BFrFileRef_GetLeafName(inFileRef)); - -cleanup: + +cleanup: // return the sound data *outSoundData = sound_data; @@ -1419,12 +1419,12 @@ SSrSoundData_New( SStSoundData **outSoundData) { UUtError error; - + SStSoundData *sound_data = NULL; - + UUmAssert(inFileRef); UUmAssert(outSoundData); - + error = SSrSoundData_Load( inFileRef, @@ -1435,17 +1435,17 @@ SSrSoundData_New( if (sound_data == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "couldn't load sound data from file, no error flagged"); } - + // allocate memory for the sound data and the sound name sound_data->data = UUrMemory_Block_Realloc( sound_data->data, sound_data->num_bytes + SScMaxNameLength); if (sound_data->data == NULL) { goto cleanup; } - + // this sound_data was dynamically allocated sound_data->flags |= SScSoundDataFlag_DynamicAlloc; - + // put the file name at the end of the sound data { char *dest = ((char*)sound_data->data + sound_data->num_bytes); @@ -1453,16 +1453,16 @@ SSrSoundData_New( UUrString_Copy(dest, BFrFileRef_GetLeafName(inFileRef), SScMaxNameLength); UUrString_MakeLowerCase(dest, SScMaxNameLength); } - + // add sound to SSgDynamicSoundData error = SSiSoundData_AddToArray(sound_data); if (error != UUcError_None) { goto cleanup; } // set the outgoing sound data *outSoundData = sound_data; - + return UUcError_None; - + cleanup: // delete the sound data if (sound_data) @@ -1473,7 +1473,7 @@ SSrSoundData_New( } UUrMemory_Block_Delete(sound_data); } - + *outSoundData = NULL; return error; @@ -1519,24 +1519,24 @@ SSiSoundData_ProcessAIFF( SStSoundDataChunk *sound; UUtUns32 sound_size; UUtBool swap_it; - + UUmAssert(inFileData); UUmAssertWritePtr(outSoundData, sizeof(SStSoundData)); UUmAssertWritePtr(outRawData, sizeof(UUtUns8*)); UUmAssertWritePtr(outRawDataLength, sizeof(UUtUns32)); - + // set swap it #if UUmEndian == UUmEndian_Big swap_it = UUcFalse; #else swap_it = UUcTrue; #endif - + // clear the outgoing data UUrMemory_Clear(outSoundData, sizeof(SStSoundData)); *outRawData = NULL; *outRawDataLength = 0; - + // find the FORM data error = UUrFindTagData( @@ -1547,10 +1547,10 @@ SSiSoundData_ProcessAIFF( (UUtUns8**)&form, &form_size); UUmError_ReturnOnErrorMsg(error, "Unable to find FORM tag"); - + // back up 8 bytes to get to beginning of SStContainerChunk *(UUtInt8**)&form -= (sizeof(UUtUns32) + sizeof(UUtInt32)); - + // determine if the AIFF is compressed or not UUmSwapBig_4Byte(&form->formType); if (form->formType == UUm4CharToUns32('A', 'I', 'F', 'C')) @@ -1558,7 +1558,7 @@ SSiSoundData_ProcessAIFF( UUmAssert(!"compressed aiff files are not supported"); return UUcError_Generic; } - + // find the COMM data error = UUrFindTagData( @@ -1569,14 +1569,14 @@ SSiSoundData_ProcessAIFF( &common_data, &common_size); UUmError_ReturnOnErrorMsg(error, "Unable to find COMM tag"); - + // read the common data UUmGet2BytesFromBuffer(common_data, common.numChannels, UUtInt16, swap_it); UUmGet4BytesFromBuffer(common_data, common.numSampleFrames, UUtInt32, swap_it); UUmGet2BytesFromBuffer(common_data, common.sampleSize, UUtInt16, swap_it); common.sampleRate = (UUtUns32)x80tof((UUtUns16*)common_data); common_data += 10; /* skip over the 80 bytes */ - + // find the SSND data error = UUrFindTagData( @@ -1587,10 +1587,10 @@ SSiSoundData_ProcessAIFF( (UUtUns8**)&sound, &sound_size); UUmError_ReturnOnErrorMsg(error, "Unable to find SSND tag"); - + // back up 8 bytes to get to beginning of SStContainerChunk *(UUtInt8**)&sound -= (sizeof(UUtUns32) + sizeof(UUtInt32)); - + // get the offset to the sound data UUmSwapBig_4Byte(&sound->ckSize); UUmSwapBig_4Byte(&sound->offset); @@ -1619,12 +1619,12 @@ SSiSoundData_ProcessAIFF( outSoundData->num_bytes = length_in_bytes; outSoundData->data = NULL; - + *outRawDataLength = length_in_bytes; } - + // set the return data { UUtBool valid_sample_rate; @@ -1652,11 +1652,11 @@ SSiSoundData_ProcessAIFF( // determine the exact duration of the sound - outSoundData->duration_ticks = (UUtUns16) ((*outRawDataLength * UUcFramesPerSecond) / + outSoundData->duration_ticks = (UUtUns16) ((*outRawDataLength * UUcFramesPerSecond) / (common.numChannels * SScBytesPerSample * SScSamplesPerSecond)); } - - + + return UUcError_None; } @@ -1680,17 +1680,17 @@ SSiSoundData_ProcessWAVE( UUtUns8 *data; UUtUns32 data_size; UUtBool found; - + UUmAssert(inFileData); UUmAssertWritePtr(outSoundData, sizeof(SStSoundData)); UUmAssertWritePtr(outRawData, sizeof(UUtUns8*)); UUmAssertWritePtr(outRawDataLength, sizeof(UUtUns32)); - + // clear the outgoing data UUrMemory_Clear(outSoundData, sizeof(SStSoundData)); *outRawData = NULL; *outRawDataLength = 0; - + // find the RIFF data error = UUrFindTagData( @@ -1701,7 +1701,7 @@ SSiSoundData_ProcessWAVE( &riff, &riff_size); UUmError_ReturnOnErrorMsg(error, "Unable to find WAVE tag"); - + // find the WAVE found = UUrFindTag( @@ -1713,7 +1713,7 @@ SSiSoundData_ProcessWAVE( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to find WAVE tag"); } - + // find the format data error = UUrFindTagData( @@ -1724,7 +1724,7 @@ SSiSoundData_ProcessWAVE( &((UUtUns8*)format), &format_size); UUmError_ReturnOnErrorMsg(error, "Unable to find format data"); - + // find the data error = UUrFindTagData( @@ -1735,7 +1735,7 @@ SSiSoundData_ProcessWAVE( &data, &data_size); UUmError_ReturnOnErrorMsg(error, "Unable to find data data"); - + // process the format UUmSwapLittle_2Byte(&format->wFormatTag); UUmSwapLittle_2Byte(&format->nChannels); @@ -1744,11 +1744,11 @@ SSiSoundData_ProcessWAVE( UUmSwapLittle_2Byte(&format->nBlockAlign); UUmSwapLittle_2Byte(&format->wBitsPerSample); UUmSwapLittle_2Byte(&format->cbSize); - + // set the return data outSoundData->flags = (format->wFormatTag == 2) ? SScSoundDataFlag_MSADPCM : SScSoundDataFlag_PCM_Little; outSoundData->f = *format; - + *outRawData = data; *outRawDataLength = data_size; @@ -1757,7 +1757,7 @@ SSiSoundData_ProcessWAVE( outSoundData->duration_ticks = 0; } else { // this data is uncompressed, calculate the sound's duration in ticks - outSoundData->duration_ticks = (UUtUns16) ((*outRawDataLength * UUcFramesPerSecond) / + outSoundData->duration_ticks = (UUtUns16) ((*outRawDataLength * UUcFramesPerSecond) / (format->nChannels * (format->wBitsPerSample >> 3) * format->nSamplesPerSec)); } @@ -1769,10 +1769,10 @@ SSiSoundData_ProcessWAVE( UUtUns32 i; UUtUns32 num_shorts; UUtUns16 *shorts; - + num_shorts = (*outRawDataLength) >> 1; shorts = (UUtUns16*)(*outRawData); - + for (i = 0; i < num_shorts; i++) { UUmSwapLittle_2Byte((void*)shorts); @@ -1780,7 +1780,7 @@ SSiSoundData_ProcessWAVE( } } #endif - + return UUcError_None; } #endif @@ -1798,7 +1798,7 @@ SSrSoundData_Process( UUtError error; UUtUns8 *data; UUtUns32 data_size; - + // if RIFF data is found, the file is a WAVE file so process it as such error = UUrFindTagData( @@ -1823,10 +1823,10 @@ SSrSoundData_Process( #endif UUmAssert(!"wave file format not supported"); - + return UUcError_None; } - + // if FORM data is found, the file is an AIFF file so process it as such error = UUrFindTagData( @@ -1847,10 +1847,10 @@ SSrSoundData_Process( outRawData, outRawDataLength); UUmError_ReturnOnError(error); - + return UUcError_None; } - + return UUcError_Generic; } @@ -1951,16 +1951,16 @@ SSiSoundChannel_Play( SStSoundData *inSoundData) { UUtBool result; - + UUmAssert(inSoundChannel); UUmAssert(inSoundData); // play inSoundData on the inSoundChannel result = SS2rPlatform_SoundChannel_SetSoundData(inSoundChannel, inSoundData); if (result == UUcFalse) { return UUcFalse; } - + SS2rPlatform_SoundChannel_Play(inSoundChannel); - + return UUcTrue; } @@ -1990,7 +1990,7 @@ SSiSoundChannel_SetAmbient( UUtBool inAmbient) { UUmAssert(inSoundChannel); - + if (inAmbient) { inSoundChannel->status |= SScSCStatus_Ambient; @@ -2008,7 +2008,7 @@ SSiSoundChannel_SetCanPan( UUtBool inCanPan) { UUmAssert(inSoundChannel); - + if (inCanPan) { inSoundChannel->status |= SScSCStatus_CanPan; @@ -2063,26 +2063,26 @@ SSiSoundChannel_SetPan( float inPan) { UUmAssert(inSoundChannel); - + switch (inPanFlag) { case SScPanFlag_Left: inSoundChannel->pan_left = 1.0f; inSoundChannel->pan_right = inPan; break; - + case SScPanFlag_Right: inSoundChannel->pan_left = inPan; inSoundChannel->pan_right = 1.0f; break; - + case SScPanFlag_None: default: inSoundChannel->pan_left = 1.0f; inSoundChannel->pan_right = 1.0f; break; } - + SS2rPlatform_SoundChannel_SetPan(inSoundChannel, inPanFlag, inPan); } @@ -2111,17 +2111,17 @@ SSiSoundChannel_SetPitch( float inPitch) { float prev_pitch; - + UUmAssert(inSoundChannel); - + prev_pitch = inSoundChannel->pitch; inSoundChannel->pitch = inPitch; - + if (inSoundChannel->group != NULL) { inSoundChannel->pitch *= inSoundChannel->group->group_pitch; } - + if (prev_pitch != inSoundChannel->pitch) { SS2rPlatform_SoundChannel_SetPitch(inSoundChannel, inSoundChannel->pitch); @@ -2169,12 +2169,12 @@ static void SSiSoundChannel_CalcVolume( SStSoundChannel *inSoundChannel) { - inSoundChannel->volume = + inSoundChannel->volume = SSgOverallVolume * inSoundChannel->channel_volume * inSoundChannel->distance_volume * inSoundChannel->permutation_volume; - + if (inSoundChannel->group != NULL) { inSoundChannel->volume *= inSoundChannel->group->group_volume; @@ -2188,7 +2188,7 @@ SSiSoundChannel_SetChannelVolume( float inChannelVolume) { UUmAssert(inSoundChannel); - + inSoundChannel->channel_volume = UUmPin(inChannelVolume, 0.0f, 2.0f); SSiSoundChannel_CalcVolume(inSoundChannel); SS2rPlatform_SoundChannel_SetVolume(inSoundChannel, inSoundChannel->volume); @@ -2237,13 +2237,13 @@ SSiSoundChannel_Spatialize( float theta; float pan; UUtUns32 pan_flag; - + M3tPoint3D position; M3tPoint3D listener; float dist_squared; - + UUmAssert(inSoundChannel); - + // calculate the distance to the listener if (inPosition == NULL) { inSoundChannel->position = SSgListener_Position; @@ -2256,7 +2256,7 @@ SSiSoundChannel_Spatialize( inSoundChannel->distance_to_listener = MUrPoint_Distance(inPosition, &SSgListener_Position) * SScFootToDist; } - + if (inSoundChannel->distance_to_listener < inMaxVolDistance) { // the volume is at it's max @@ -2265,9 +2265,9 @@ SSiSoundChannel_Spatialize( else { float diff; - + diff = (inMinVolDistance - inMaxVolDistance); - + // calculate the distance_volume if (diff <= 0.0f) { @@ -2279,11 +2279,11 @@ SSiSoundChannel_Spatialize( if (distance_volume < 0.0f) { distance_volume = 0.0f; } } } - + // set the distance volume SSiSoundChannel_SetDistanceVolume(inSoundChannel, distance_volume); if (distance_volume <= 0.0f) { return UUcFalse; } - + // exit if the channel doesn't calculate the pan inSoundChannel->pan_left = 1.0f; inSoundChannel->pan_right = 1.0f; @@ -2334,10 +2334,10 @@ SSiSoundChannel_Spatialize( pan = 1.0f; } } - + // set the pan volume SSiSoundChannel_SetPan(inSoundChannel, pan_flag, pan); - + return UUcTrue; } @@ -2358,15 +2358,15 @@ SSiSoundChannels_GetChannelForPlay( UUtUns32 i; UUtUns32 num_channels; float distance; - + UUmAssert(inSoundChannels); - + found_channel = NULL; distance = 0.0f; - + sound_channel_array = inSoundChannels; num_channels = inNumChannels; - + // look for a channel which isn't locked and isn't playing anything for (i = 0; i < num_channels; i++) { @@ -2377,7 +2377,7 @@ SSiSoundChannels_GetChannelForPlay( break; } } - + // get the first available channel which isn't locked and is playing a sound that // has a lower priority if (found_channel == NULL) @@ -2396,7 +2396,7 @@ SSiSoundChannels_GetChannelForPlay( } } } - + // look for a channel which is playing any sound of the same or lower or equal priority // that isn't locked and is near zero volume if (found_channel == NULL) @@ -2416,13 +2416,13 @@ SSiSoundChannels_GetChannelForPlay( } } } - + // look for a channel which is playing with a lower or equal priority but // with a lower volume if (found_channel == NULL) { float min_volume = 1.0f; - + for (i = 0; i < num_channels; i++) { if ((sound_channel_array[i].priority <= inPriority) && @@ -2432,7 +2432,7 @@ SSiSoundChannels_GetChannelForPlay( min_volume = found_channel->volume; } } - + if (found_channel) { if (SSiSoundChannel_IsAmbient(found_channel) == UUcTrue) @@ -2445,7 +2445,7 @@ SSiSoundChannels_GetChannelForPlay( } } } - + // init found_channel if (found_channel != NULL) { @@ -2454,7 +2454,7 @@ SSiSoundChannels_GetChannelForPlay( found_channel->pan_left = 1.0f; found_channel->pan_right = 1.0f; } - + return found_channel; } @@ -2466,7 +2466,7 @@ SSiSoundChannels_GetChannelByID( SStSoundChannel *sound_channel_array; UUtUns32 i; UUtUns32 num_channels; - + // search for the channel in the mono channel array sound_channel_array = SSgSoundChannels_Mono; num_channels = SSgSoundChannels_NumMono; @@ -2477,7 +2477,7 @@ SSiSoundChannels_GetChannelByID( return &sound_channel_array[i]; } } - + // search for the channel in the stereo channel array sound_channel_array = SSgSoundChannels_Stereo; num_channels = SSgSoundChannels_NumStereo; @@ -2488,7 +2488,7 @@ SSiSoundChannels_GetChannelByID( return &sound_channel_array[i]; } } - + return NULL; } @@ -2498,9 +2498,9 @@ SSiSoundChannels_GetNumChannels( void) { UUtUns32 num_channels; - + num_channels = SSgSoundChannels_NumMono + SSgSoundChannels_NumStereo; - + return num_channels; } @@ -2516,17 +2516,17 @@ SSiSoundChannels_Initialize( UUtUns32 num_stereo_channels; UUtUns32 num_mono_channels; UUtUns16 sound_channel_id; - + UUmAssert(SSgSoundChannels_Stereo == NULL); UUmAssert(SSgSoundChannels_Mono == NULL); - + // calculate the number of stereo channels num_stereo_channels = (UUtUns32)(((float)inNumChannels * SScPercentStereo) + 0.5f); num_mono_channels = inNumChannels - num_stereo_channels; - + *outNumStereoChannels = num_stereo_channels; *outNumMonoChannels = num_mono_channels; - + // allocate memory for the stereo sound channels if (num_stereo_channels > 0) { @@ -2543,7 +2543,7 @@ SSiSoundChannels_Initialize( } sound_channel_id = 0; - + // initialize each stereo sound channel sound_channels = SSgSoundChannels_Stereo; for (i = 0; i < num_stereo_channels; i++) @@ -2567,7 +2567,7 @@ SSiSoundChannels_Initialize( sound_channels[i].pan_right = 1.0f; SS2rPlatform_SoundChannel_Initialize(&sound_channels[i]); } - + // initialize each mono sound channel sound_channels = SSgSoundChannels_Mono; for (i = 0; i < num_mono_channels; i++) @@ -2591,7 +2591,7 @@ SSiSoundChannels_Initialize( sound_channels[i].pan_right = 1.0f; SS2rPlatform_SoundChannel_Initialize(&sound_channels[i]); } - + return UUcError_None; } @@ -2603,9 +2603,9 @@ SSiSoundChannels_Silence( UUtUns32 i; SStSoundChannel *sound_channel_array; UUtUns32 num_elements; - + SSrWaitGuard(SSgGuardAll); - + if (SSgSoundChannels_Mono) { // go through the sound channels and do any platform specific termination @@ -2631,7 +2631,7 @@ SSiSoundChannels_Silence( SS2rPlatform_SoundChannel_SetVolume(&sound_channel_array[i], 0.0f); } } - + SSrReleaseGuard(SSgGuardAll); } @@ -2643,7 +2643,7 @@ SSiSoundChannels_Terminate( UUtUns32 i; SStSoundChannel *sound_channel_array; UUtUns32 num_elements; - + if (SSgSoundChannels_Mono) { // go through the sound channels and do any platform specific termination @@ -2653,7 +2653,7 @@ SSiSoundChannels_Terminate( { SS2rPlatform_SoundChannel_Terminate(&sound_channel_array[i]); } - + // delete the sound channel array UUrMemory_Block_Delete(SSgSoundChannels_Mono); SSgSoundChannels_Mono = NULL; @@ -2669,7 +2669,7 @@ SSiSoundChannels_Terminate( { SS2rPlatform_SoundChannel_Terminate(&sound_channel_array[i]); } - + // delete the sound channel array UUrMemory_Block_Delete(SSgSoundChannels_Stereo); SSgSoundChannels_Stereo = NULL; @@ -2702,9 +2702,9 @@ SSrPermutation_Play( float play_volume; float play_pitch; SStSoundChannel *sound_channel; - + UUmAssert(inPermutation); - + if (SSgUsable == UUcFalse) { return; } if (inPermutation->sound_data == NULL) @@ -2715,13 +2715,13 @@ SSrPermutation_Play( UUcFalse); if (inPermutation->sound_data == NULL) { - COrConsole_Printf("SOUND NOT FOUND: %s %s - sound %s", + COrConsole_Printf("SOUND NOT FOUND: %s %s - sound %s", (inDebugSoundType == NULL) ? "" : inDebugSoundType, (inDebugSoundName == NULL) ? "" : inDebugSoundName, inPermutation->sound_data_name); return; } } - + // search for a channel to use if (inSoundChannel) { @@ -2749,25 +2749,25 @@ SSrPermutation_Play( } } if (sound_channel == NULL) { return; } - + // pick a volume play_volume = UUmRandomRangeFloat( inPermutation->min_volume_percent, inPermutation->max_volume_percent); - + // pick a pitch play_pitch = UUmRandomRangeFloat( inPermutation->min_pitch_percent, inPermutation->max_pitch_percent); - + // set the volume SSiSoundChannel_SetPermutationVolume(sound_channel, play_volume); - + // play the permutation SSiSoundChannel_Play(sound_channel, inPermutation->sound_data); - + // set the pitch SSiSoundChannel_SetPitch(sound_channel, play_pitch); } @@ -2785,10 +2785,10 @@ SSiGroup_Compare( { const SStGroup *group1; const SStGroup *group2; - + group1 = *((SStGroup**)inItem1); group2 = *((SStGroup**)inItem2); - + return strcmp(group1->group_name, group2->group_name); } @@ -2806,21 +2806,21 @@ SSiGroup_SelectPermutation( UUtBool done; UUtUns32 count; UUtUns16 selected; - + // get the number of permutations and a pointer to the permutation_array num_permutations = UUrMemory_Array_GetUsedElems(inGroup->permutations); permutation_array = (SStPermutation*)UUrMemory_Array_GetMemory(inGroup->permutations); - + if (num_permutations == 0) { return NULL; } if (num_permutations == 1) { return &permutation_array[0]; } - + // calculate the sum of all the weights of the permutations total_weight = 0; for (i = 0; i < num_permutations; i++) { total_weight += permutation_array[i].weight; } - + done = UUcTrue; count = 0; selected = 0; @@ -2828,7 +2828,7 @@ SSiGroup_SelectPermutation( { // pick a permutation random_num = UUmLocalRandomRange(0, total_weight); - + // find the permutation which corresponds to this random number permutation = NULL; cumulative_weight = 0; @@ -2844,7 +2844,7 @@ SSiGroup_SelectPermutation( } UUmAssert(i < num_permutations); UUmAssert(permutation != NULL); - + // when the prevent repeats flag is set, then pick a new permutation // if this is the same permutation that was picked the previous time // this sound group was played @@ -2854,13 +2854,13 @@ SSiGroup_SelectPermutation( { done = UUcFalse; } - + count++; } while ((done == UUcFalse) && (count < 10)); - + inGroup->flag_data = selected; - + return permutation; } @@ -2872,7 +2872,7 @@ SSrGroup_CheckSoundData( UUtUns32 num_permutations; SStPermutation *permutation_array; UUtUns32 itr; - + // get the number of permutations and a pointer to the permutation_array num_permutations = UUrMemory_Array_GetUsedElems(inGroup->permutations); permutation_array = (SStPermutation*)UUrMemory_Array_GetMemory(inGroup->permutations); @@ -2880,7 +2880,7 @@ SSrGroup_CheckSoundData( { if (permutation_array[itr].sound_data == NULL) { return UUcFalse; } } - + return UUcTrue; } @@ -2892,25 +2892,25 @@ SSrGroup_Copy( { UUtError error; UUtUns32 num_permutations; - + UUmAssert(inSource); UUmAssert(inSource->permutations); UUmAssert(ioDest); UUmAssert(ioDest->permutations); - + // clear ioDest's permutations array num_permutations = UUrMemory_Array_GetUsedElems(ioDest->permutations); if (num_permutations > 0) - { + { while (num_permutations--) { UUrMemory_Array_DeleteElement(ioDest->permutations, 0); } } - + // copy the permutations from inSource to ioDest ioDest->num_channels = inSource->num_channels; - + num_permutations = UUrMemory_Array_GetUsedElems(inSource->permutations); if (num_permutations > 0) { @@ -2918,26 +2918,26 @@ SSrGroup_Copy( SStPermutation *dst_permutations; UUtBool mem_moved; UUtUns32 i; - + // set the number of permutations used in ioDest error = UUrMemory_Array_SetUsedElems(ioDest->permutations, num_permutations, &mem_moved); UUmError_ReturnOnError(error); - + // get a pointer to the inSource permutations src_permutations = (SStPermutation*)UUrMemory_Array_GetMemory(inSource->permutations); UUmAssert(src_permutations); - + // get a pointer to the ioDest permutations dst_permutations = (SStPermutation*)UUrMemory_Array_GetMemory(ioDest->permutations); UUmAssert(dst_permutations); - + // copy the permutation data from inSource to ioDest for (i = 0; i < num_permutations; i++) { dst_permutations[i] = src_permutations[i]; } } - + return UUcError_None; } @@ -2950,10 +2950,10 @@ SSrGroup_Delete( UUtUns32 num_sound_groups; SStGroup **group_array; UUtUns32 i; - + num_sound_groups = UUrMemory_Array_GetUsedElems(SSgSoundGroups); group_array = (SStGroup**)UUrMemory_Array_GetMemory(SSgSoundGroups); - + for (i = 0; i < num_sound_groups; i++) { if (UUrString_Compare_NoCase(group_array[i]->group_name, inGroupName) != 0) { continue; } @@ -2964,20 +2964,20 @@ SSrGroup_Delete( UUrMemory_Array_Delete(group_array[i]->permutations); group_array[i]->permutations = NULL; } - + // delete the sound group UUrMemory_Block_Delete(group_array[i]); - + // delete the sound group pointer UUrMemory_Array_DeleteElement(SSgSoundGroups, i); - + if (inUpdatePointers == UUcTrue) { // update the pointers SSrAmbient_UpdateGroupName(inGroupName, NULL); SSrImpulse_UpdateGroupName(inGroupName, NULL); } - + break; } } @@ -2992,17 +2992,17 @@ SSrGroup_GetByName( SStGroup *find_me_ptr = &find_me; SStGroup **found_group; UUtUns32 num_elements; - + if (inGroupName == NULL) { return NULL; } - + UUrString_Copy(find_me.group_name, inGroupName, SScMaxNameLength); - + // get a pointer to the array group_array = (SStGroup**)UUrMemory_Array_GetMemory(SSgSoundGroups); if (group_array == NULL) { return NULL; } - + num_elements = UUrMemory_Array_GetUsedElems(SSgSoundGroups); - + found_group = (SStGroup**)bsearch( &find_me_ptr, @@ -3022,12 +3022,12 @@ SSrGroup_GetByIndex( { UUtUns32 num_sound_groups; SStGroup **group_array; - + num_sound_groups = UUrMemory_Array_GetUsedElems(SSgSoundGroups); group_array = (SStGroup**)UUrMemory_Array_GetMemory(SSgSoundGroups); - + UUmAssert(num_sound_groups > inIndex); - + return group_array[inIndex]; } @@ -3066,14 +3066,14 @@ SSrGroup_New( { UUtError error; SStGroup *group; - + UUmAssert(inGroupName); UUmAssert(outGroup); - + // allocate memory for the group sound group = (SStGroup*)UUrMemory_Block_NewClear(sizeof(SStGroup)); UUmError_ReturnOnNull(group); - + // initialize the group group->group_volume = 1.0f; group->group_pitch = 1.0f; @@ -3092,51 +3092,51 @@ SSrGroup_New( UUrMemory_Block_Delete(group); return UUcError_OutOfMemory; } - + // insert the group into the sound groups list { SStGroup **array; UUtUns32 num_elements; UUtInt32 min, max, midpoint, compare; UUtUns32 found_location; - + array = (SStGroup**)UUrMemory_Array_GetMemory(SSgSoundGroups); num_elements = UUrMemory_Array_GetUsedElems(SSgSoundGroups); - - min = 0; + + min = 0; max = num_elements - 1; - + while(min <= max) { midpoint = (min + max) >> 1; // S.S. / 2; - + compare = SSiGroup_Compare(&group, &array[midpoint]); - + if (compare < 0) { // must lie below here max = midpoint - 1; - + } else { // must lie above here min = midpoint + 1; } } - + found_location = (UUtUns32)min; - + // create space in the array at the desired location UUmAssert((found_location >= 0) && (found_location <= num_elements)); error = UUrMemory_Array_InsertElement(SSgSoundGroups, found_location, NULL); UUmError_ReturnOnError(error); - + // set the array element array = (SStGroup**)UUrMemory_Array_GetMemory(SSgSoundGroups); array[found_location] = group; } - + // set the outgoing data if (outGroup) { *outGroup = group; } - + return UUcError_None; } @@ -3147,13 +3147,13 @@ SSrGroup_Permutation_Delete( UUtUns32 inPermIndex) { UUmAssert(ioGroup); - + // check the index's range if (inPermIndex >= UUrMemory_Array_GetUsedElems(ioGroup->permutations)) { return; } - + // delete the permutation UUrMemory_Array_DeleteElement(ioGroup->permutations, inPermIndex); } @@ -3165,18 +3165,18 @@ SSrGroup_Permutation_Get( UUtUns32 inPermIndex) { SStPermutation *perms; - + UUmAssert(inGroup); - + // check the index's range if (inPermIndex >= UUrMemory_Array_GetUsedElems(inGroup->permutations)) { return NULL; } - + perms = (SStPermutation*)UUrMemory_Array_GetMemory(inGroup->permutations); if (perms == NULL) { return NULL; } - + return &perms[inPermIndex]; } @@ -3192,13 +3192,13 @@ SSrGroup_Permutation_New( UUtBool mem_moved; SStPermutation *perms; UUtUns32 in_sound_data_num_channels = SSrSound_GetNumChannels(inSoundData); - + UUmAssert(ioGroup); UUmAssert(inSoundData); UUmAssert(outPermutationIndex); - + *outPermutationIndex = UUcMaxUns32; - + // make sure the number of sound channels of the permutations match if (UUrMemory_Array_GetUsedElems(ioGroup->permutations) > 0) { @@ -3211,15 +3211,15 @@ SSrGroup_Permutation_New( { ioGroup->num_channels = in_sound_data_num_channels; } - + // allocate a new permutation in the permutations array error = UUrMemory_Array_GetNewElement(ioGroup->permutations, &index, &mem_moved); UUmError_ReturnOnError(error); - + // get a pointer to the permutataions array perms = (SStPermutation*)UUrMemory_Array_GetMemory(ioGroup->permutations); UUmAssert(perms); - + // initialize the permutation perms[index].weight = 10; perms[index].min_volume_percent = 1.0; @@ -3231,9 +3231,9 @@ SSrGroup_Permutation_New( perms[index].sound_data_name, SSrSoundData_GetName(inSoundData), SScMaxNameLength); - + *outPermutationIndex = index; - + return UUcError_None; } @@ -3248,16 +3248,16 @@ SSrGroup_Play( UUtUns32 num_permutations; SStPermutation *permutation; SStSoundChannel *sound_channel; - + UUmAssert(inGroup); UUmAssert(inGroup->permutations); - + if (SSgUsable == UUcFalse) { return; } // get the number of permutations num_permutations = UUrMemory_Array_GetUsedElems(inGroup->permutations); if (num_permutations == 0) { return; } - + // pick the permutation to play permutation = SSiGroup_SelectPermutation(inGroup); if (permutation == NULL) { @@ -3265,12 +3265,12 @@ SSrGroup_Play( return; } else if (permutation->sound_data == NULL) { - COrConsole_Printf("SOUND NOT FOUND: %s %s - sound %s", + COrConsole_Printf("SOUND NOT FOUND: %s %s - sound %s", (inDebugSoundType == NULL) ? "" : inDebugSoundType, (inDebugSoundName == NULL) ? "" : inDebugSoundName, permutation->sound_data_name); return; } - + SSrWaitGuard(SSgGuardAll); // get a sound channel @@ -3303,7 +3303,7 @@ SSrGroup_Play( sound_channel = NULL; } } - + if (sound_channel == NULL) { SSrReleaseGuard(SSgGuardAll); return; @@ -3312,7 +3312,7 @@ SSrGroup_Play( // SSrWaitGuard(&sound_channel->guard); sound_channel->group = inGroup; - + // play the permutation SSrPermutation_Play(permutation, sound_channel, inDebugSoundType, inDebugSoundName); @@ -3339,16 +3339,16 @@ SSiGroup_PlaySpatialized( SStPermutation *permutation; SStSoundChannel *sound_channel; UUtBool result; - + UUmAssert(inGroup); UUmAssert(inGroup->permutations); - + if (SSgUsable == UUcFalse) { return UUcFalse; } // get the number of permutations num_permutations = UUrMemory_Array_GetUsedElems(inGroup->permutations); if (num_permutations == 0) { return UUcFalse; } - + // pick the permutation to play permutation = SSiGroup_SelectPermutation(inGroup); if (permutation == NULL) { @@ -3356,7 +3356,7 @@ SSiGroup_PlaySpatialized( return UUcFalse; } else if (permutation->sound_data == NULL) { - COrConsole_Printf("SOUND NOT FOUND: %s %s - group %s - sound %s", + COrConsole_Printf("SOUND NOT FOUND: %s %s - group %s - sound %s", (inDebugSoundType == NULL) ? "" : inDebugSoundType, (inDebugSoundName == NULL) ? "" : inDebugSoundName, inGroup->group_name, permutation->sound_data_name); @@ -3390,23 +3390,23 @@ SSiGroup_PlaySpatialized( sound_channel = NULL; } } - + if (sound_channel == NULL) { /* if (SSgShowDebugInfo) { COrConsole_Printf("SSrGroup_PlaySpatialized: didn't play %s, no channels available", inGroup->group_name); }*/ - + SSrReleaseGuard(SSgGuardAll); return UUcFalse; } - + // setup the channel SSiSoundChannel_SetLooping(sound_channel, UUcFalse); SSiSoundChannel_SetChannelVolume(sound_channel, inVolume); SSiSoundChannel_SetCanPan(sound_channel, UUcTrue); - + // spacialize the sound channel result = SSiSoundChannel_Spatialize( @@ -3416,16 +3416,16 @@ SSiGroup_PlaySpatialized( inPosition, inDirection, inVelocity); - + // play the permutation if (result == UUcTrue) { sound_channel->group = inGroup; SSrPermutation_Play(permutation, sound_channel, inDebugSoundType, inDebugSoundName); } - + SSrReleaseGuard(SSgGuardAll); - + return result; } @@ -3438,27 +3438,27 @@ SSrGroup_UpdateSoundDataPointers( UUtUns32 num_groups; UUtUns32 itr; UUtBool search_on_disk; - + #if SHIPPING_VERSION == 0 search_on_disk = SSgSearchOnDisk; #else search_on_disk = UUcFalse; #endif - + // go through all of the groups and updates the sound_data pointers of their // permutations group_array = (SStGroup**)UUrMemory_Array_GetMemory(SSgSoundGroups); - num_groups = UUrMemory_Array_GetUsedElems(SSgSoundGroups); + num_groups = UUrMemory_Array_GetUsedElems(SSgSoundGroups); for (itr = 0; itr < num_groups; itr++) { SStGroup *group; SStPermutation *perm_array; UUtUns32 num_perms; UUtUns32 itr2; - + // get a pointer to the sound group group = group_array[itr]; - + // update the sound data pointers for the permutations of the group perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(group->permutations); num_perms = UUrMemory_Array_GetUsedElems(group->permutations); @@ -3485,10 +3485,10 @@ SSiImpulse_Compare( { const SStImpulse *impulse1; const SStImpulse *impulse2; - + impulse1 = *((SStImpulse**)inItem1); impulse2 = *((SStImpulse**)inItem2); - + return strcmp(impulse1->impulse_name, impulse2->impulse_name); } @@ -3500,7 +3500,7 @@ SSrImpulse_Copy( { UUmAssert(inSource); UUmAssert(ioDest); - + // restore the id after copying the data ioDest->impulse_group = inSource->impulse_group; UUrString_Copy(ioDest->impulse_group_name, inSource->impulse_group_name, SScMaxNameLength); @@ -3510,7 +3510,7 @@ SSrImpulse_Copy( ioDest->max_volume_angle = inSource->max_volume_angle; ioDest->min_volume_angle = inSource->min_volume_angle; ioDest->min_angle_attenuation = inSource->min_angle_attenuation; - + return UUcError_None; } @@ -3523,10 +3523,10 @@ SSrImpulse_Delete( UUtUns32 num_impulse_sounds; SStImpulse **impulse_array, *deleted_element = NULL; UUtUns32 i; - + num_impulse_sounds = UUrMemory_Array_GetUsedElems(SSgImpulseSounds); impulse_array = (SStImpulse**)UUrMemory_Array_GetMemory(SSgImpulseSounds); - + for (i = 0; i < num_impulse_sounds; i++) { if (UUrString_Compare_NoCase(impulse_array[i]->impulse_name, inImpulseName) == 0) @@ -3551,12 +3551,12 @@ SSrImpulse_GetByIndex( { UUtUns32 num_impulse_sounds; SStImpulse **impulse_array; - + num_impulse_sounds = UUrMemory_Array_GetUsedElems(SSgImpulseSounds); impulse_array = (SStImpulse**)UUrMemory_Array_GetMemory(SSgImpulseSounds); - + UUmAssert(num_impulse_sounds > inIndex); - + return impulse_array[inIndex]; } @@ -3570,17 +3570,17 @@ SSrImpulse_GetByName( SStImpulse *find_me_ptr = &find_me; SStImpulse **found_impulse; UUtUns32 num_elements; - + if (inImpulseName == NULL) { return NULL; } - + UUrString_Copy(find_me.impulse_name, inImpulseName, SScMaxNameLength); - + // get a pointer to the array impulse_array = (SStImpulse**)UUrMemory_Array_GetMemory(SSgImpulseSounds); if (impulse_array == NULL) { return NULL; } - + num_elements = UUrMemory_Array_GetUsedElems(SSgImpulseSounds); - + found_impulse = (SStImpulse**)bsearch( &find_me_ptr, @@ -3610,14 +3610,14 @@ SSrImpulse_New( { UUtError error; SStImpulse *impulse; - + UUmAssert(inImpulseName); UUmAssert(outImpulse); - + // allocate memory for the impulse sound impulse = (SStImpulse*)UUrMemory_Block_New(sizeof(SStImpulse)); UUmError_ReturnOnNull(impulse); - + // initialize the impulse sound UUrString_Copy(impulse->impulse_name, inImpulseName, SScMaxNameLength); impulse->impulse_group = NULL; @@ -3633,43 +3633,43 @@ SSrImpulse_New( UUrMemory_Clear(impulse->alt_impulse_name, SScMaxNameLength); impulse->impact_velocity = 0.0f; impulse->min_occlusion = 0.0f; - + // insert the impulse sound into the impulse sound list { SStImpulse **array; UUtUns32 num_elements; UUtInt32 min, max, midpoint, compare; UUtUns32 found_location; - + array = (SStImpulse**)UUrMemory_Array_GetMemory(SSgImpulseSounds); num_elements = UUrMemory_Array_GetUsedElems(SSgImpulseSounds); - - min = 0; + + min = 0; max = num_elements - 1; - + while(min <= max) { midpoint = (min + max) >> 1; // S.S. / 2; - + compare = SSiImpulse_Compare(&impulse, &array[midpoint]); - + if (compare < 0) { // must lie below here max = midpoint - 1; - + } else { // must lie above here min = midpoint + 1; } } - + found_location = (UUtUns32)min; - + // create space in the array at the desired location UUmAssert((found_location >= 0) && (found_location <= num_elements)); error = UUrMemory_Array_InsertElement(SSgImpulseSounds, found_location, NULL); UUmError_ReturnOnError(error); - + // set the array element array = (SStImpulse**)UUrMemory_Array_GetMemory(SSgImpulseSounds); array[found_location] = impulse; @@ -3677,7 +3677,7 @@ SSrImpulse_New( // set the outgoing data if (outImpulse) { *outImpulse = impulse; } - + return UUcError_None; } @@ -3692,14 +3692,14 @@ SSrImpulse_Play( { float volume; UUtBool result; - + UUmAssert(inImpulse); - + if (SSgUsable == UUcFalse) { return; } // find the impulse sound group if it isn't already set if (inImpulse->impulse_group == NULL) { return; } - + if (inVolume == NULL) { volume = 1.0f; @@ -3708,14 +3708,14 @@ SSrImpulse_Play( { volume = *inVolume; } - + if (inImpulse->alt_threshold > 0) { SStSoundChannel *channel_array; UUtUns32 num_channels; UUtUns32 i; UUtUns32 num_playing; - + // scan the appropriate sound channels to determine if // this group has being played the maximum number of times it // is allowed to be played @@ -3729,7 +3729,7 @@ SSrImpulse_Play( channel_array = SSgSoundChannels_Mono; num_channels = SSgSoundChannels_NumMono; } - + SSrWaitGuard(SSgGuardAll); num_playing = 0; @@ -3737,11 +3737,11 @@ SSrImpulse_Play( { if (SSiSoundChannel_IsPlaying(&channel_array[i]) == UUcFalse) { continue; } if (channel_array[i].group != inImpulse->impulse_group) { continue; } - + num_playing++; if (num_playing >= inImpulse->alt_threshold) { break; } } - + SSrReleaseGuard(SSgGuardAll); if (num_playing >= inImpulse->alt_threshold) @@ -3758,7 +3758,7 @@ SSrImpulse_Play( return; } } - + result = SSiGroup_PlaySpatialized( inImpulse->impulse_group, @@ -3807,17 +3807,17 @@ SSrImpulse_UpdateGroupName( UUtUns32 num_impulse_sounds; SStImpulse **impulse_array; UUtUns32 i; - + num_impulse_sounds = UUrMemory_Array_GetUsedElems(SSgImpulseSounds); impulse_array = (SStImpulse**)UUrMemory_Array_GetMemory(SSgImpulseSounds); - + // get a new pointer to each SStGroup for (i = 0; i < num_impulse_sounds; i++) { SStImpulse *impulse; - + impulse = impulse_array[i]; - + // update the impulse sound group if (UUrString_Compare_NoCase(impulse->impulse_group_name, inOldGroupName) == 0) { @@ -3842,20 +3842,20 @@ SSrImpulse_UpdateGroupPointers( UUtUns32 num_impulse_sounds; SStImpulse **impulse_array; UUtUns32 i; - + num_impulse_sounds = UUrMemory_Array_GetUsedElems(SSgImpulseSounds); impulse_array = (SStImpulse**)UUrMemory_Array_GetMemory(SSgImpulseSounds); - + // get a new pointer to each SStGroup for (i = 0; i < num_impulse_sounds; i++) { SStImpulse *impulse; - + impulse = impulse_array[i]; - + // get a pointer to the impulse group impulse->impulse_group = SSrGroup_GetByName(impulse->impulse_group_name); - + // update the alt_impulse if (impulse->alt_threshold > 0) { @@ -3876,15 +3876,15 @@ SSiPAUpdate_CalcNextDetailTime( { float detail_time; UUtUns32 time; - + if (inPlayingAmbient->ambient->detail == NULL) { return; } - + // get the amount of time to wait - detail_time = + detail_time = UUmRandomRangeFloat( inPlayingAmbient->ambient->min_detail_time, inPlayingAmbient->ambient->max_detail_time); - + // calculate the next detail time time = UUrMachineTime_Sixtieths(); inPlayingAmbient->detail_time = time + (UUtUns32)(detail_time * 60.0f); @@ -3899,14 +3899,14 @@ SSiPAUpdate_ReserveChannel( UUtBool inCanPan) { SStSoundChannel *channel; - + // get a channel channel = SSiSoundChannels_GetChannelForPlay( ((inNumChannels == 2) ? SSgSoundChannels_Stereo : SSgSoundChannels_Mono), ((inNumChannels == 2) ? SSgSoundChannels_NumStereo : SSgSoundChannels_NumMono), inPriority); - + if (channel != NULL) { // set the status flags @@ -3915,7 +3915,7 @@ SSiPAUpdate_ReserveChannel( SSiSoundChannel_SetLooping(channel, UUcFalse); SSiSoundChannel_SetUpdating(channel, UUcFalse); SSiSoundChannel_SetCanPan(channel, inCanPan); - + // initialize the volumes, pan, and pitch. // the channel volume must be set first in order to keep the distance volume // from making the channel audible before it should be @@ -3924,7 +3924,7 @@ SSiPAUpdate_ReserveChannel( SSiSoundChannel_SetPitch(channel, 1.0f); SSiSoundChannel_SetPan(channel, SScPanFlag_None, 1.0f); } - + return channel; } @@ -3936,16 +3936,16 @@ SSiPAUpdate_Start( SStGroup *group; UUtUns32 num_channels; UUtBool pan; - + // ------------------------------ // reserve channel1 // ------------------------------ group = inPlayingAmbient->ambient->base_track1; if (group == NULL) { group = inPlayingAmbient->ambient->in_sound; } if (group == NULL) { group = inPlayingAmbient->ambient->out_sound; } - - pan = ((inPlayingAmbient->ambient->flags & SScAmbientFlag_Pan) != 0); - + + pan = ((inPlayingAmbient->ambient->flags & SScAmbientFlag_Pan) != 0); + if (group != NULL) { num_channels = SSrGroup_GetNumChannels(group); @@ -3955,14 +3955,14 @@ SSiPAUpdate_Start( inPlayingAmbient->ambient->priority, inPlayingAmbient->channel_volume, pan); - + // get a channel /* inPlayingAmbient->channel1 = SSiSoundChannels_GetChannelForPlay( ((num_channels == 2) ? SSgSoundChannels_Stereo : SSgSoundChannels_Mono), ((num_channels == 2) ? SSgSoundChannels_NumStereo : SSgSoundChannels_NumMono), inPlayingAmbient->ambient->priority); - + if (inPlayingAmbient->channel1 != NULL) { // set the status flags @@ -3971,7 +3971,7 @@ SSiPAUpdate_Start( SSiSoundChannel_SetLooping(inPlayingAmbient->channel1, UUcFalse); SSiSoundChannel_SetUpdating(inPlayingAmbient->channel1, UUcFalse); SSiSoundChannel_SetCanPan(inPlayingAmbient->channel1, pan); - + // initialize the volumes, pan, and pitch. // the channel volume must be set first in order to keep the distance volume // from making the channel audible before it should be @@ -3983,12 +3983,12 @@ SSiPAUpdate_Start( SSiSoundChannel_SetPan(inPlayingAmbient->channel1, SScPanFlag_None, 1.0f); }*/ } - + // ------------------------------ // reserve channel2 // ------------------------------ group = inPlayingAmbient->ambient->base_track2; - + if (group != NULL) { num_channels = SSrGroup_GetNumChannels(group); @@ -3998,14 +3998,14 @@ SSiPAUpdate_Start( inPlayingAmbient->ambient->priority, inPlayingAmbient->channel_volume, pan); - + // get a channel /* inPlayingAmbient->channel2 = SSiSoundChannels_GetChannelForPlay( ((num_channels == 2) ? SSgSoundChannels_Stereo : SSgSoundChannels_Mono), ((num_channels == 2) ? SSgSoundChannels_NumStereo : SSgSoundChannels_NumMono), inPlayingAmbient->ambient->priority); - + if (inPlayingAmbient->channel2 != NULL) { // set the status flags @@ -4014,7 +4014,7 @@ SSiPAUpdate_Start( SSiSoundChannel_SetAmbient(inPlayingAmbient->channel2, UUcTrue); SSiSoundChannel_SetUpdating(inPlayingAmbient->channel2, UUcFalse); SSiSoundChannel_SetCanPan(inPlayingAmbient->channel2, pan); - + // initialize the volumes, pan, and pitch // the channel volume must be set first in order to keep the distance volume // from making the channel audible before it should be @@ -4026,7 +4026,7 @@ SSiPAUpdate_Start( SSiSoundChannel_SetPan(inPlayingAmbient->channel2, SScPanFlag_None, 1.0f); }*/ } - + // ------------------------------ // move on to the next stage // ------------------------------ @@ -4045,7 +4045,7 @@ SSiPAUpdate_Start( { inPlayingAmbient->stage = SScPAStage_InSoundStart; } - + return UUcTrue; } @@ -4064,7 +4064,7 @@ SSiPAUpdate_InSoundStart( SSrGroup_Play(inPlayingAmbient->ambient->in_sound, inPlayingAmbient->channel1, "ambient in", inPlayingAmbient->ambient->ambient_name); } - + return UUcTrue; } @@ -4074,9 +4074,9 @@ SSiPAUpdate_InSoundPlaying( SStPlayingAmbient *inPlayingAmbient) { UUtBool next_stage; - + next_stage = UUcFalse; - + // if channel1 is NULL then the in_sound is not playing so // move on to the Body_Start stage. Otherwise, wait for the in_sound // to stop playing @@ -4091,7 +4091,7 @@ SSiPAUpdate_InSoundPlaying( inPlayingAmbient->stage = SScPAStage_BodyStart; next_stage = UUcTrue; } - + return next_stage; } @@ -4107,7 +4107,7 @@ SSiPAUpdate_DetailOnly( M3tPoint3D position; float x; float z; - + // get the position of the sound if (inPlayingAmbient->has_position) { @@ -4117,7 +4117,7 @@ SSiPAUpdate_DetailOnly( { position = SSgListener_Position; } - + // calculate a random offset from the current position x = UUmRandomRangeFloat( -inPlayingAmbient->ambient->sphere_radius, @@ -4125,10 +4125,10 @@ SSiPAUpdate_DetailOnly( z = UUmRandomRangeFloat( -inPlayingAmbient->ambient->sphere_radius, inPlayingAmbient->ambient->sphere_radius); - + position.x += x; position.z += z; - + // play the detail SSiGroup_PlaySpatialized( inPlayingAmbient->ambient->detail, @@ -4141,7 +4141,7 @@ SSiPAUpdate_DetailOnly( SScPriority2_Low, "ambient detail", inPlayingAmbient->ambient->ambient_name); - + // calculate the next time to play the detail SSiPAUpdate_CalcNextDetailTime(inPlayingAmbient); } @@ -4155,9 +4155,9 @@ SSiPAUpdate_BodyStart( SStPlayingAmbient *inPlayingAmbient) { UUtBool next_stage; - + next_stage = UUcFalse; - + if ((SSiSoundChannel_IsUpdating(inPlayingAmbient->channel1) == UUcFalse) && (SSiSoundChannel_IsUpdating(inPlayingAmbient->channel2) == UUcFalse)) { @@ -4169,12 +4169,12 @@ SSiPAUpdate_BodyStart( SSiSoundChannel_SetLooping( inPlayingAmbient->channel1, ((inPlayingAmbient->ambient->flags & SScAmbientFlag_PlayOnce) == 0)); - + // play the base_track1 SSrGroup_Play(inPlayingAmbient->ambient->base_track1, inPlayingAmbient->channel1, "ambient base1", inPlayingAmbient->ambient->ambient_name); } - + // if the ambient sound has a base_track2, then play it if ((inPlayingAmbient->ambient->base_track2 != NULL) && (inPlayingAmbient->channel2)) @@ -4183,15 +4183,15 @@ SSiPAUpdate_BodyStart( SSiSoundChannel_SetLooping( inPlayingAmbient->channel2, ((inPlayingAmbient->ambient->flags & SScAmbientFlag_PlayOnce) == 0)); - + // play the base_track2 SSrGroup_Play(inPlayingAmbient->ambient->base_track2, inPlayingAmbient->channel2, "ambient base2", inPlayingAmbient->ambient->ambient_name); } - + // set the time for the detail track if there is one SSiPAUpdate_CalcNextDetailTime(inPlayingAmbient); - + // move on to the next appropriate stage if ((inPlayingAmbient->channel1 != NULL) || (inPlayingAmbient->channel2 != NULL)) { @@ -4204,7 +4204,7 @@ SSiPAUpdate_BodyStart( next_stage = UUcTrue; } } - + return next_stage; } @@ -4217,16 +4217,16 @@ SSiPAUpdate_BodyPlaying( UUtBool channel2_playing; UUtUns32 num_channels; UUtBool can_pan; - + // determine if the sound channels are playing channel1_playing = SSiSoundChannel_IsPlaying(inPlayingAmbient->channel1); channel2_playing = SSiSoundChannel_IsPlaying(inPlayingAmbient->channel2); - + // recover from losing channels if ((inPlayingAmbient->ambient->base_track1 != NULL) && (inPlayingAmbient->channel1 == NULL)) { - can_pan = ((inPlayingAmbient->ambient->flags & SScAmbientFlag_Pan) != 0); + can_pan = ((inPlayingAmbient->ambient->flags & SScAmbientFlag_Pan) != 0); num_channels = SSrGroup_GetNumChannels(inPlayingAmbient->ambient->base_track1); inPlayingAmbient->channel1 = SSiPAUpdate_ReserveChannel( @@ -4236,11 +4236,11 @@ SSiPAUpdate_BodyPlaying( can_pan); SSrAmbient_SetVolume(inPlayingAmbient->id, inPlayingAmbient->channel_volume, 0.5f); } - + if ((inPlayingAmbient->ambient->base_track2 != NULL) && (inPlayingAmbient->channel2 == NULL)) { - can_pan = ((inPlayingAmbient->ambient->flags & SScAmbientFlag_Pan) != 0); + can_pan = ((inPlayingAmbient->ambient->flags & SScAmbientFlag_Pan) != 0); num_channels = SSrGroup_GetNumChannels(inPlayingAmbient->ambient->base_track2); inPlayingAmbient->channel2 = SSiPAUpdate_ReserveChannel( @@ -4250,7 +4250,7 @@ SSiPAUpdate_BodyPlaying( can_pan); SSrAmbient_SetVolume(inPlayingAmbient->id, inPlayingAmbient->channel_volume, 0.5f); } - + // update base_track1 playing if ((inPlayingAmbient->ambient->base_track1 != NULL) && (inPlayingAmbient->channel1 != NULL) && @@ -4261,7 +4261,7 @@ SSiPAUpdate_BodyPlaying( SSrGroup_Play(inPlayingAmbient->ambient->base_track1, inPlayingAmbient->channel1, "ambient base1", inPlayingAmbient->ambient->ambient_name); } - + // update base_track2 playing if ((inPlayingAmbient->ambient->base_track2 != NULL) && (inPlayingAmbient->channel2 != NULL) && @@ -4279,14 +4279,14 @@ SSiPAUpdate_BodyPlaying( if (SSiSoundChannel_IsLooping(inPlayingAmbient->channel1) == UUcTrue) { SSiSoundChannel_SetLooping(inPlayingAmbient->channel1, UUcFalse); - + // move on to body stopping inPlayingAmbient->stage = SScPAStage_BodyStopping; return UUcTrue; } } } - + // if both channels have stopped playing move on to the body stopping stage if ((channel1_playing == UUcFalse) && (channel2_playing == UUcFalse)) { @@ -4302,7 +4302,7 @@ SSiPAUpdate_BodyPlaying( inPlayingAmbient->stage = SScPAStage_BodyStopping; return UUcTrue; } - + // update the detail_track playing if ((inPlayingAmbient->ambient->detail != NULL) && (inPlayingAmbient->detail_time < UUrMachineTime_Sixtieths()) && @@ -4312,7 +4312,7 @@ SSiPAUpdate_BodyPlaying( float x; float z; UUtBool result; - + // get the position of the sound if (inPlayingAmbient->has_position) { @@ -4322,7 +4322,7 @@ SSiPAUpdate_BodyPlaying( { position = SSgListener_Position; } - + // calculate a random offset from the current position x = UUmRandomRangeFloat( -inPlayingAmbient->ambient->sphere_radius, @@ -4330,12 +4330,12 @@ SSiPAUpdate_BodyPlaying( z = UUmRandomRangeFloat( -inPlayingAmbient->ambient->sphere_radius, inPlayingAmbient->ambient->sphere_radius); - + position.x += x; position.z += z; - + // play the detail - result = + result = SSiGroup_PlaySpatialized( inPlayingAmbient->ambient->detail, inPlayingAmbient->ambient->max_volume_distance, @@ -4353,11 +4353,11 @@ SSiPAUpdate_BodyPlaying( "SSiPAUpdate_BodyPlaying: unable to play %s", inPlayingAmbient->ambient->ambient_name); }*/ - + // calculate the next time to play the detail SSiPAUpdate_CalcNextDetailTime(inPlayingAmbient); } - + return UUcFalse; } @@ -4369,24 +4369,24 @@ SSiPAUpdate_BodyStopping( UUtBool next_stage; UUtBool channel1_playing; UUtBool channel2_playing; - + next_stage = UUcFalse; - + // make sure the channels aren't looping if (SSiSoundChannel_IsLooping(inPlayingAmbient->channel1)) { SSiSoundChannel_SetLooping(inPlayingAmbient->channel1, UUcFalse); } - + if (SSiSoundChannel_IsLooping(inPlayingAmbient->channel2)) { SSiSoundChannel_SetLooping(inPlayingAmbient->channel2, UUcFalse); } - + // determine if the sound channels are playing channel1_playing = SSiSoundChannel_IsPlaying(inPlayingAmbient->channel1); channel2_playing = SSiSoundChannel_IsPlaying(inPlayingAmbient->channel2); - + // when both channels have stopped playing move on to playing the out sound if ((channel1_playing == UUcFalse) && (channel2_playing == UUcFalse)) { @@ -4407,7 +4407,7 @@ SSiPAUpdate_BodyStopping( inPlayingAmbient->stage = SScPAStage_OutSoundStart; next_stage = UUcTrue; } - + return next_stage; } @@ -4418,19 +4418,19 @@ SSiPAUpdate_OutSoundStart( { // wait for the out sound to finish in the out sound playing stage inPlayingAmbient->stage = SScPAStage_OutSoundPlaying; - + // start the out sound if ((inPlayingAmbient->ambient->out_sound != NULL) && (inPlayingAmbient->channel1 != NULL)) { // make sure the channel isn't going to loop SSiSoundChannel_SetLooping(inPlayingAmbient->channel1, UUcFalse); - + // play the out sound SSrGroup_Play(inPlayingAmbient->ambient->out_sound, inPlayingAmbient->channel1, "ambient out", inPlayingAmbient->ambient->ambient_name); } - + // release channel2 if (inPlayingAmbient->channel2) { @@ -4439,7 +4439,7 @@ SSiPAUpdate_OutSoundStart( SSiSoundChannel_SetLock(inPlayingAmbient->channel2, UUcFalse); inPlayingAmbient->channel2 = NULL; } - + return UUcFalse; } @@ -4455,7 +4455,7 @@ SSiPAUpdate_OutSoundPlaying( inPlayingAmbient->stage = SScPAStage_Done; return UUcTrue; } - + return UUcFalse; } @@ -4466,7 +4466,7 @@ SSiPAUpdate_NonAudible( { SSiPlayingAmbient_Halt(inPlayingAmbient); inPlayingAmbient->stage = SScPAStage_Done; - + return UUcTrue; } @@ -4492,7 +4492,7 @@ SSiPAUpdate_Done( SSiSoundChannel_SetLock(inPlayingAmbient->channel2, UUcFalse); inPlayingAmbient->channel2 = NULL; } - + inPlayingAmbient->stage = SScPAStage_None; return UUcTrue; } @@ -4503,7 +4503,7 @@ SSiPAUpdate_Position( SStPlayingAmbient *inPlayingAmbient) { if (inPlayingAmbient->has_position == UUcFalse) { return; } - + // update the position of the ambient sound if (inPlayingAmbient->channel1 != NULL) { @@ -4515,7 +4515,7 @@ SSiPAUpdate_Position( &inPlayingAmbient->direction, &inPlayingAmbient->velocity); } - + if (inPlayingAmbient->channel2 != NULL) { SSiSoundChannel_Spatialize( @@ -4535,17 +4535,17 @@ SSiPAUpdate_Volume( { UUtUns32 time; UUtInt32 delta; - + if ((inPlayingAmbient->volume_adjust_final_volume == inPlayingAmbient->channel_volume) || (UUmFabs(inPlayingAmbient->volume_adjust_delta) < SScVolumeAdjustEpsilon)) { return; } - + time = UUrMachineTime_Sixtieths(); delta = time - inPlayingAmbient->volume_adjust_start_time; inPlayingAmbient->volume_adjust_start_time = time; - + inPlayingAmbient->channel_volume += (inPlayingAmbient->volume_adjust_delta * (float)delta); if (inPlayingAmbient->volume_adjust_delta > 0.0f) @@ -4558,14 +4558,14 @@ SSiPAUpdate_Volume( inPlayingAmbient->channel_volume = UUmPin(inPlayingAmbient->channel_volume, inPlayingAmbient->volume_adjust_final_volume, 1.0f); } - + if (inPlayingAmbient->channel1 != NULL) { SSiSoundChannel_SetChannelVolume( inPlayingAmbient->channel1, inPlayingAmbient->channel_volume); } - + if (inPlayingAmbient->channel2 != NULL) { SSiSoundChannel_SetChannelVolume( @@ -4582,11 +4582,11 @@ SSiPAUpdate_StopNonAudible( float volume; float distance_to_listener; float previous_distance_to_listener; - + // if the ambient sound isn't spatialized, don't stop the channel if (inPlayingAmbient->has_position == UUcFalse) { return; } if (inPlayingAmbient->stage <= SScPAStage_InSoundStart) { return; } - + // get the distance to listener if (inPlayingAmbient->channel1 != NULL) { @@ -4606,7 +4606,7 @@ SSiPAUpdate_StopNonAudible( { return; } - + // or if the volume is greater than zero, // or if the distance to the listener is less than the distance threshold // or if the distance to the listener is decreasing, @@ -4614,7 +4614,7 @@ SSiPAUpdate_StopNonAudible( if (volume > 0.0f) { return; } if (distance_to_listener < SScDistanceThreshold) { return; } if (distance_to_listener <= previous_distance_to_listener) { return; } - + inPlayingAmbient->stage = SScPAStage_NonAudible; } @@ -4624,19 +4624,19 @@ SSiPlayingAmbient_Halt( SStPlayingAmbient *inPlayingAmbient) { UUmAssert(inPlayingAmbient); - + // stop channel1 completely if (inPlayingAmbient->channel1 != NULL) { SSiSoundChannel_Stop(inPlayingAmbient->channel1); } - + // stop channel2 completely if (inPlayingAmbient->channel2 != NULL) { SSiSoundChannel_Stop(inPlayingAmbient->channel2); } - + // go to next stage inPlayingAmbient->stage = SScPAStage_Done; } @@ -4648,7 +4648,7 @@ SSiPlayingAmbient_Update( UUtUns32 inIndex) { UUtBool next_stage; - + do { switch (inPlayingAmbient->stage) @@ -4656,61 +4656,61 @@ SSiPlayingAmbient_Update( case SScPAStage_None: return; break; - + case SScPAStage_Done: next_stage = SSiPAUpdate_Done(inPlayingAmbient); break; - + case SScPAStage_Start: next_stage = SSiPAUpdate_Start(inPlayingAmbient); break; - + case SScPAStage_InSoundStart: next_stage = SSiPAUpdate_InSoundStart(inPlayingAmbient); break; - + case SScPAStage_InSoundPlaying: next_stage = SSiPAUpdate_InSoundPlaying(inPlayingAmbient); break; - + case SScPAStage_BodyStart: next_stage = SSiPAUpdate_BodyStart(inPlayingAmbient); break; - + case SScPAStage_BodyPlaying: next_stage = SSiPAUpdate_BodyPlaying(inPlayingAmbient); break; - + case SScPAStage_BodyStopping: next_stage = SSiPAUpdate_BodyStopping(inPlayingAmbient); break; - + case SScPAStage_OutSoundStart: next_stage = SSiPAUpdate_OutSoundStart(inPlayingAmbient); break; - + case SScPAStage_OutSoundPlaying: next_stage = SSiPAUpdate_OutSoundPlaying(inPlayingAmbient); break; - + case SScPAStage_NonAudible: next_stage = SSiPAUpdate_NonAudible(inPlayingAmbient); break; - + case SScPAStage_DetailOnly: next_stage = SSiPAUpdate_DetailOnly(inPlayingAmbient); break; } } while (next_stage == UUcTrue); - + // update the volume SSiPAUpdate_Volume(inPlayingAmbient); - + // update the position SSiPAUpdate_Position(inPlayingAmbient); - - // stop playing ambient sounds that are no longer audible + + // stop playing ambient sounds that are no longer audible // and likely won't be SSiPAUpdate_StopNonAudible(inPlayingAmbient); } @@ -4722,7 +4722,7 @@ SSiPlayingAmbient_UpdateList( { SStPlayingAmbient *playing_ambient_array; UUtUns32 i; - + SSrWaitGuard(SSgGuardAll); // update all of the playing ambient sounds @@ -4746,9 +4746,9 @@ SSiPlayingAmbient_UpdateSoundChannel( SStPlayingAmbient *playing_ambient_array; UUtUns32 i; UUtBool updated; - + updated = UUcFalse; - + SSrWaitGuard(SSgGuardAll); // update all of the playing ambient sounds @@ -4756,21 +4756,21 @@ SSiPlayingAmbient_UpdateSoundChannel( for (i = 0; i < SSgNumPlayingAmbients; i++) { SStPlayingAmbient *playing_ambient; - + playing_ambient = &playing_ambient_array[i]; if (playing_ambient->stage == SScPAStage_None) { continue; } - + if ((playing_ambient->channel1 != inSoundChannel) && (playing_ambient->channel2 != inSoundChannel)) { continue; } - + // update the sound channel SSiPlayingAmbient_Update(playing_ambient, i); updated = UUcTrue; - + break; } @@ -4785,7 +4785,7 @@ SSiPlayingAmbient_GetNextID( void) { SSgPlayID++; - + if (SSgPlayID == SScInvalidID) { SSgPlayID = 0; @@ -4801,23 +4801,23 @@ SSiPlayingAmbient_Stall( { SStPlayingAmbient *playing_ambient_array; UUtUns32 i; - + SSrWaitGuard(SSgGuardAll); /* if (SSgShowDebugInfo) { COrConsole_Printf("SSiPlayingAmbient_Stall %d %s", inSoundChannel->id, inSoundChannel->group->group_name); }*/ - + // update all of the playing ambient sounds playing_ambient_array = SSgPlayingAmbient; for (i = 0; i < SSgNumPlayingAmbients; i++) { SStPlayingAmbient *playing_ambient; - + playing_ambient = &playing_ambient_array[i]; if (playing_ambient->stage == SScPAStage_None) { continue; } - + // stall the channel if (playing_ambient->channel1 == inSoundChannel) { @@ -4837,7 +4837,7 @@ SSiPlayingAmbient_Stall( { continue; } - + break; } @@ -4857,10 +4857,10 @@ SSiAmbient_Compare( { const SStAmbient *ambient1; const SStAmbient *ambient2; - + ambient1 = *((SStAmbient**)inItem1); ambient2 = *((SStAmbient**)inItem2); - + return strcmp(ambient1->ambient_name, ambient2->ambient_name); } @@ -4880,19 +4880,19 @@ SSiAmbient_CheckPointers( { ioAmbient->base_track1 = SSrGroup_GetByName(ioAmbient->base_track1_name); } - + // check base_track2_id if ((ioAmbient->base_track2 == NULL) && (ioAmbient->base_track2_name[0] != '\0')) { ioAmbient->base_track2 = SSrGroup_GetByName(ioAmbient->base_track2_name); } - + // check in_sound if ((ioAmbient->in_sound == NULL) && (ioAmbient->in_sound_name[0] != '\0')) { ioAmbient->in_sound = SSrGroup_GetByName(ioAmbient->in_sound_name); } - + // check out_sound if ((ioAmbient->out_sound == NULL) && (ioAmbient->out_sound_name[0] != '\0')) { @@ -4906,39 +4906,39 @@ SSrAmbient_CheckSoundData( const SStAmbient *inAmbient) { UUtBool all_sounds_found; - + UUmAssert(inAmbient); - + if (inAmbient->detail) { all_sounds_found = SSrGroup_CheckSoundData(inAmbient->detail); if (all_sounds_found == UUcFalse) { return UUcFalse; } } - + if (inAmbient->base_track1) { all_sounds_found = SSrGroup_CheckSoundData(inAmbient->base_track1); if (all_sounds_found == UUcFalse) { return UUcFalse; } } - + if (inAmbient->base_track2) - { + { all_sounds_found = SSrGroup_CheckSoundData(inAmbient->base_track2); if (all_sounds_found == UUcFalse) { return UUcFalse; } } - + if (inAmbient->in_sound) - { + { all_sounds_found = SSrGroup_CheckSoundData(inAmbient->in_sound); if (all_sounds_found == UUcFalse) { return UUcFalse; } } - + if (inAmbient->out_sound) - { + { all_sounds_found = SSrGroup_CheckSoundData(inAmbient->out_sound); if (all_sounds_found == UUcFalse) { return UUcFalse; } } - + return UUcTrue; } @@ -4950,7 +4950,7 @@ SSrAmbient_Copy( { UUmAssert(inSource); UUmAssert(ioDest); - + // restore the id after copying the data ioDest->priority = inSource->priority; ioDest->flags = inSource->flags; @@ -4969,7 +4969,7 @@ SSrAmbient_Copy( UUrString_Copy(ioDest->base_track2_name, inSource->base_track2_name, SScMaxNameLength); UUrString_Copy(ioDest->in_sound_name, inSource->in_sound_name, SScMaxNameLength); UUrString_Copy(ioDest->out_sound_name, inSource->out_sound_name, SScMaxNameLength); - + return UUcError_None; } @@ -4982,10 +4982,10 @@ SSrAmbient_Delete( UUtUns32 num_ambient_sounds; SStAmbient **ambient_array, *deleted_element = NULL; UUtUns32 i; - + num_ambient_sounds = UUrMemory_Array_GetUsedElems(SSgAmbientSounds); ambient_array = (SStAmbient**)UUrMemory_Array_GetMemory(SSgAmbientSounds); - + // delete the ambient sound which has an id equal to inAmbientID for (i = 0; i < num_ambient_sounds; i++) { @@ -5011,12 +5011,12 @@ SSrAmbient_GetByIndex( { UUtUns32 num_ambient_sounds; SStAmbient **ambient_array; - + num_ambient_sounds = UUrMemory_Array_GetUsedElems(SSgAmbientSounds); ambient_array = (SStAmbient**)UUrMemory_Array_GetMemory(SSgAmbientSounds); - + UUmAssert(inIndex < num_ambient_sounds); - + return ambient_array[inIndex]; } @@ -5030,17 +5030,17 @@ SSrAmbient_GetByName( SStAmbient *find_me_ptr = &find_me; SStAmbient **found_ambient; UUtUns32 num_elements; - + if (inAmbientName == NULL) { return NULL; } - + UUrString_Copy(find_me.ambient_name, inAmbientName, SScMaxNameLength); - + // get a pointer to the array ambient_array = (SStAmbient**)UUrMemory_Array_GetMemory(SSgAmbientSounds); if (ambient_array == NULL) { return NULL; } - + num_elements = UUrMemory_Array_GetUsedElems(SSgAmbientSounds); - + found_ambient = (SStAmbient**)bsearch( &find_me_ptr, @@ -5070,9 +5070,9 @@ SSrAmbient_GetSubtitle( if (SScInvalidSubtitle == inAmbient->subtitle) { const char *ambient_name; - + inAmbient->subtitle = NULL; - + ambient_name = inAmbient->ambient_name; if (SSrNameIsValidDialogName(ambient_name)) { @@ -5080,7 +5080,7 @@ SSrAmbient_GetSubtitle( inAmbient->subtitle = SSrSubtitle_Find(ambient_name); } } - + return inAmbient->subtitle; } @@ -5092,9 +5092,9 @@ SSrAmbient_Halt( SStPlayingAmbient *playing_ambient_array; UUtUns32 i; UUtUns32 num_playing_ambients; - + if (inPlayID == SScInvalidID) { return; } - + SSrWaitGuard(SSgGuardAll); // get the playing ambient with id == inPlayID @@ -5103,15 +5103,15 @@ SSrAmbient_Halt( for(i = 0; i < num_playing_ambients; i++) { SStPlayingAmbient *playing_ambient; - + playing_ambient = &playing_ambient_array[i]; if (playing_ambient->stage == SScPAStage_None) { continue; } if (playing_ambient->id != inPlayID) { continue; } - + SSiPlayingAmbient_Halt(playing_ambient); SSiPlayingAmbient_Update(playing_ambient, i); - + break; } @@ -5126,16 +5126,16 @@ SSrAmbient_New( { UUtError error; SStAmbient *ambient; - + UUmAssert(inAmbientName); UUmAssert(outAmbient); - + if (outAmbient) { *outAmbient = NULL; } - + // allocate memory for the ambient sound ambient = (SStAmbient*)UUrMemory_Block_New(sizeof(SStAmbient)); UUmError_ReturnOnNull(ambient); - + // initialize the ambient sound UUrString_Copy(ambient->ambient_name, inAmbientName, SScMaxNameLength); ambient->priority = SScPriority2_Normal; @@ -5158,51 +5158,51 @@ SSrAmbient_New( ambient->in_sound_name[0] = '\0'; ambient->out_sound_name[0] = '\0'; ambient->subtitle = SScInvalidSubtitle; - + // insert the ambient sound into the ambient sound list { SStAmbient **array; UUtUns32 num_elements; UUtInt32 min, max, midpoint, compare; UUtUns32 found_location; - + array = (SStAmbient**)UUrMemory_Array_GetMemory(SSgAmbientSounds); num_elements = UUrMemory_Array_GetUsedElems(SSgAmbientSounds); - - min = 0; + + min = 0; max = num_elements - 1; - + while(min <= max) { midpoint = (min + max) >> 1; // S.S. / 2; - + compare = SSiAmbient_Compare(&ambient, &array[midpoint]); - + if (compare < 0) { // must lie below here max = midpoint - 1; - + } else { // must lie above here min = midpoint + 1; } } - + found_location = (UUtUns32)min; - + // create space in the array at the desired location UUmAssert((found_location >= 0) && (found_location <= num_elements)); error = UUrMemory_Array_InsertElement(SSgAmbientSounds, found_location, NULL); UUmError_ReturnOnError(error); - + // set the array element array = (SStAmbient**)UUrMemory_Array_GetMemory(SSgAmbientSounds); array[found_location] = ambient; } - + // set the outgoing data if (outAmbient) { *outAmbient = ambient; } - + return UUcError_None; } @@ -5227,12 +5227,12 @@ SSrAmbient_SetPitch( { if (playing_ambient_array[i].stage == SScPAStage_None) { continue; } if (playing_ambient_array[i].id != inPlayID) { continue; } - + if (playing_ambient_array[i].channel1 != NULL) { SSiSoundChannel_SetPitch(playing_ambient_array[i].channel1, inPitch); } - + if (playing_ambient_array[i].channel2 != NULL) { SSiSoundChannel_SetPitch(playing_ambient_array[i].channel2, inPitch); @@ -5256,23 +5256,23 @@ SSrAmbient_SetVolume( if (SSgUsable == UUcFalse) { return; } SSrWaitGuard(SSgGuardAll); - + // make sure it is in range inVolume = UUmPin(inVolume, 0.0f, 1.0f); - + // get the playing ambient with id == inPlayID playing_ambient_array = SSgPlayingAmbient; num_playing_ambients = SSgNumPlayingAmbients; for(i = 0; i < num_playing_ambients; i++) { float volume_adjust_ticks; - + if (playing_ambient_array[i].stage == SScPAStage_None) { continue; } if (playing_ambient_array[i].id != inPlayID) { continue; } - + // break if the final volume is already set if (playing_ambient_array[i].volume_adjust_final_volume == inVolume) { break; } - + volume_adjust_ticks = inTime * 60.0f; if (volume_adjust_ticks > 0.0f) { @@ -5287,19 +5287,19 @@ SSrAmbient_SetVolume( // to use playing_ambient_array[i].channel_volume = inVolume; playing_ambient_array[i].volume_adjust_final_volume = playing_ambient_array[i].channel_volume; - + // set the volume of channel1 and channel2 if (playing_ambient_array[i].channel1 != NULL) { SSiSoundChannel_SetChannelVolume(playing_ambient_array[i].channel1, inVolume); } - + if (playing_ambient_array[i].channel2 != NULL) { SSiSoundChannel_SetChannelVolume(playing_ambient_array[i].channel2, inVolume); } } - + break; } @@ -5322,19 +5322,19 @@ SSrAmbient_Start( UUtUns32 num_elements; UUtUns32 itr; UUtUns32 num_playing; - + UUmAssert(inAmbient); - + if (SSgUsable == UUcFalse) { return SScInvalidID; } - + SSrWaitGuard(SSgGuardAll); - + // count the number of instances of this ambient sound that are already playing // and keep track of the first available index of the SSgPlayingAmbient list index = SScInvalidID; num_playing = 0; playing_ambient_array = SSgPlayingAmbient; - num_elements = SSgNumPlayingAmbients; + num_elements = SSgNumPlayingAmbients; for (itr = 0; itr < num_elements; itr++) { if (playing_ambient_array[itr].stage == SScPAStage_None) @@ -5346,21 +5346,21 @@ SSrAmbient_Start( if (playing_ambient_array[itr].stage >= SScPAStage_OutSoundStart) { continue; } num_playing++; } - + // stop playing if the ambient threshold has been reached if (num_playing >= inAmbient->threshold) { SSrReleaseGuard(SSgGuardAll); return SScInvalidID; } - + // add the ambient sound to the SSgPlayingAmbient list if (index == SScInvalidID) { SSrReleaseGuard(SSgGuardAll); return SScInvalidID; } - + playing_ambient_array[index].id = SSiPlayingAmbient_GetNextID(); playing_ambient_array[index].stage = SScPAStage_Start; playing_ambient_array[index].ambient = inAmbient; @@ -5379,12 +5379,12 @@ SSrAmbient_Start( playing_ambient_array[index].volume_adjust_start_time = UUrMachineTime_Sixtieths(); playing_ambient_array[index].volume_adjust_delta = 0.0f; playing_ambient_array[index].volume_adjust_final_volume = playing_ambient_array[index].channel_volume; - + if (inPosition) { playing_ambient_array[index].position = *inPosition; playing_ambient_array[index].has_position = UUcTrue; - + if (inDirection) { playing_ambient_array[index].direction = *inDirection; } if (inVelocity) { playing_ambient_array[index].velocity = *inVelocity; } playing_ambient_array[index].max_volume_distance = inMaxVolDistance; @@ -5395,9 +5395,9 @@ SSrAmbient_Start( playing_ambient_array[index].max_volume_distance = inAmbient->max_volume_distance; playing_ambient_array[index].min_volume_distance = inAmbient->min_volume_distance; } - + SSiPlayingAmbient_Update(&playing_ambient_array[index], index); - + /* if (SSgShowDebugInfo) { COrConsole_Printf( @@ -5405,9 +5405,9 @@ SSrAmbient_Start( playing_ambient_array[index].id, playing_ambient_array[index].ambient->ambient_name); }*/ - + SSrReleaseGuard(SSgGuardAll); - + return playing_ambient_array[index].id; } @@ -5428,7 +5428,7 @@ SSrAmbient_Stop( SStPlayingAmbient *playing_ambient_array; UUtUns32 i; UUtUns32 num_playing_ambients; - + if (SSgUsable == UUcFalse) { return; } SSrWaitGuard(SSgGuardAll); @@ -5446,8 +5446,8 @@ SSrAmbient_Stop( { break; } - - + + if ((playing_ambient_array[i].ambient->flags & SScAmbientFlag_InterruptOnStop) != 0) { // stop channel 1 @@ -5455,7 +5455,7 @@ SSrAmbient_Stop( { SSiSoundChannel_Stop(playing_ambient_array[i].channel1); } - + // stop channel 2 if (playing_ambient_array[i].channel2 != NULL) { @@ -5480,10 +5480,10 @@ SSrAmbient_Stop( } } } - + // go to next stage playing_ambient_array[i].stage = SScPAStage_BodyStopping; - + /* if (SSgShowDebugInfo) { COrConsole_Printf( @@ -5491,10 +5491,10 @@ SSrAmbient_Stop( playing_ambient_array[i].id, playing_ambient_array[i].ambient->ambient_name); }*/ - + break; } - + SSrReleaseGuard(SSgGuardAll); } @@ -5511,7 +5511,7 @@ SSrAmbient_Update( UUtUns32 num_playing_ambients; UUtUns32 i; UUtBool active; - + if (SSgUsable == UUcFalse) { return UUcFalse; } SSrWaitGuard(SSgGuardAll); @@ -5524,7 +5524,7 @@ SSrAmbient_Update( { if (playing_ambient_array[i].stage == SScPAStage_None) { continue; } if (playing_ambient_array[i].id != inPlayID) { continue; } - + // update the position, direction, and velocity of the playing ambient if (inPosition) { @@ -5533,18 +5533,18 @@ SSrAmbient_Update( } if (inDirection) { playing_ambient_array[i].direction = *inDirection; } if (inVelocity) { playing_ambient_array[i].velocity = *inVelocity; } - + if (inVolume) { playing_ambient_array[i].channel_volume = *inVolume; - + if (playing_ambient_array[i].channel1 != NULL) { SSiSoundChannel_SetChannelVolume( playing_ambient_array[i].channel1, playing_ambient_array[i].channel_volume); } - + if (playing_ambient_array[i].channel2 != NULL) { SSiSoundChannel_SetChannelVolume( @@ -5552,12 +5552,12 @@ SSrAmbient_Update( playing_ambient_array[i].channel_volume); } } - + active = UUcTrue; - + break; } - + SSrReleaseGuard(SSgGuardAll); return active; @@ -5572,17 +5572,17 @@ SSrAmbient_UpdateGroupName( UUtUns32 num_ambient_sounds; SStAmbient **ambient_array; UUtUns32 i; - + num_ambient_sounds = UUrMemory_Array_GetUsedElems(SSgAmbientSounds); ambient_array = (SStAmbient**)UUrMemory_Array_GetMemory(SSgAmbientSounds); - + // get a new pointer to each SStGroup for (i = 0; i < num_ambient_sounds; i++) { SStAmbient *ambient; - + ambient = ambient_array[i]; - + // update the detail group if (UUrString_Compare_NoCase(ambient->detail_name, inOldGroupName) == 0) { @@ -5663,17 +5663,17 @@ SSrAmbient_UpdateGroupPointers( UUtUns32 num_ambient_sounds; SStAmbient **ambient_array; UUtUns32 i; - + num_ambient_sounds = UUrMemory_Array_GetUsedElems(SSgAmbientSounds); ambient_array = (SStAmbient**)UUrMemory_Array_GetMemory(SSgAmbientSounds); - + // get a new pointer to each SStGroup for (i = 0; i < num_ambient_sounds; i++) { SStAmbient *ambient; - + ambient = ambient_array[i]; - + // get pointers to all of the detail groups ambient->detail = SSrGroup_GetByName(ambient->detail_name); ambient->base_track1 = SSrGroup_GetByName(ambient->base_track1_name); @@ -5715,7 +5715,7 @@ SSrGetSoundDirectory( char *soundDirName; char soundDirNameStr[BFcMaxPathLength]; BFtFileRef *soundDirRef; - + // find the preferences file #if defined(SHIPPING_VERSION) && (!SHIPPING_VERSION) error = BFrFileRef_Search("Preferences.txt", &prefFileRef); @@ -5726,7 +5726,7 @@ SSrGetSoundDirectory( *outDirectoryRef = NULL; return UUcError_Generic; } - + // create a group from the file error = GRrGroup_Context_NewFromFileRef( @@ -5736,44 +5736,44 @@ SSrGetSoundDirectory( &prefGroupContext, &prefGroup); if (error != UUcError_None) { return error; } - + // get the data file directory error = GRrGroup_GetString(prefGroup, "SoundFileDir", &soundDirName); if (error != UUcError_None) { char *dataFileDir; - + // get the data file directory error = GRrGroup_GetString(prefGroup, "DataFileDir", &dataFileDir); if (error != UUcError_None) { return error; } - + // set the sound Dir name sprintf(soundDirNameStr, "%s\\%s", dataFileDir, SScSoundDirectory); soundDirName = soundDirNameStr; } - + // make a file ref for the sound data folder error = BFrFileRef_MakeFromName(soundDirName, &soundDirRef); if (error != UUcError_None) { return error; } - + // delete the group context GRrGroup_Context_Delete(prefGroupContext); prefGroupContext = NULL; - + // see if the directory exists if (BFrFileRef_FileExists(soundDirRef) == UUcFalse) { // the directory was not found delete the folder ref UUrMemory_Block_Delete(soundDirRef); soundDirRef = NULL; - + *outDirectoryRef = NULL; - + return UUcError_Generic; } - + *outDirectoryRef = soundDirRef; - + return UUcError_None; } @@ -5790,11 +5790,11 @@ SSiTextFile_WriteAmbient( UUtUns32 num_ambients; UUtUns32 i; char string[2048]; - + // write the header sprintf(string, "Name\tPriority\tIn Sound\tOut Sound\tBase Track 1\tBase Track 2\tDetail Track\tMin Detail Time\tMax Detail Time\tSphere Radius\tMax Volume Distance\tMin Volume Distance\tInterrupt On Stop\tPlay Once\n"); BFrFile_Write(inFile, strlen(string), string); - + // write the ambient sounds num_ambients = SSrAmbient_GetNumAmbientSounds(); for (i = 0; i < num_ambients; i++) @@ -5802,12 +5802,12 @@ SSiTextFile_WriteAmbient( SStAmbient *ambient; char number[128]; const char *priority_name; - + ambient = SSrAmbient_GetByIndex(i); if (ambient == NULL) { continue; } - + string[0] = '\0'; - + strcat(string, ambient->ambient_name); strcat(string, "\t"); switch(ambient->priority) @@ -5818,14 +5818,14 @@ SSiTextFile_WriteAmbient( case SScPriority2_Highest: priority_name = SSgPriority_Name[ambient->priority]; break; - + default: priority_name = ""; break; } strcat(string, priority_name); strcat(string, "\t"); - + if (ambient->in_sound) { strcat(string, ambient->in_sound->group_name); } strcat(string, "\t"); @@ -5840,7 +5840,7 @@ SSiTextFile_WriteAmbient( if (ambient->detail) { strcat(string, ambient->detail->group_name); } strcat(string, "\t"); - + sprintf(number, "%5.3f", ambient->min_detail_time); strcat(string, number); strcat(string, "\t"); sprintf(number, "%5.3f", ambient->max_detail_time); strcat(string, number); strcat(string, "\t"); sprintf(number, "%5.3f", ambient->sphere_radius); strcat(string, number); strcat(string, "\t"); @@ -5851,12 +5851,12 @@ SSiTextFile_WriteAmbient( strcat(string, "\t"); if ((ambient->flags & SScAmbientFlag_PlayOnce) != 0) { strcat(string, "Y"); } - + strcat(string, "\n"); BFrFile_Write(inFile, strlen(string), string); } - + return UUcError_None; } @@ -5868,11 +5868,11 @@ SSiTextFile_WriteImpulse( UUtUns32 num_impulses; UUtUns32 i; char string[2048]; - + // write the header sprintf(string, "Name\tPriority\tSound\tMax Volume Distance\tMin Volume Distance\n"); BFrFile_Write(inFile, strlen(string), string); - + // write the impulse sounds num_impulses = SSrImpulse_GetNumImpulseSounds(); for (i = 0; i < num_impulses; i++) @@ -5880,14 +5880,14 @@ SSiTextFile_WriteImpulse( SStImpulse *impulse; char number[128]; const char *priority_name; - + impulse = SSrImpulse_GetByIndex(i); if (impulse == NULL) { continue; } - + string[0] = '\0'; - + strcat(string, impulse->impulse_name); strcat(string, "\t"); - + switch(impulse->priority) { case SScPriority2_Low: @@ -5896,17 +5896,17 @@ SSiTextFile_WriteImpulse( case SScPriority2_Highest: priority_name = SSgPriority_Name[impulse->priority]; break; - + default: priority_name = ""; break; } - + strcat(string, priority_name); strcat(string, "\t"); if (impulse->impulse_group) { strcat(string, impulse->impulse_group->group_name); } strcat(string, "\t"); - + sprintf(number, "%5.3f", impulse->min_volume_distance); strcat(string, number); strcat(string, "\t"); sprintf(number, "%5.3f", impulse->max_volume_distance); strcat(string, number); @@ -5914,7 +5914,7 @@ SSiTextFile_WriteImpulse( BFrFile_Write(inFile, strlen(string), string); } - + return UUcError_None; } @@ -5926,13 +5926,13 @@ SSiTextFile_WriteGroup( UUtUns32 num_groups; UUtUns32 i; char string[2048]; - + // write the header sprintf(string, "Name\tVolume\n"); BFrFile_Write(inFile, strlen(string), string); sprintf(string, "Perm\tFile Name\tWeight\tMin Volume Percent\tMax Volume Percent\tMin Pitch Percent\tMax Pitch Percent\n"); BFrFile_Write(inFile, strlen(string), string); - + // write the groups num_groups = SSrGroup_GetNumSoundGroups(); for (i = 0; i < num_groups; i++) @@ -5941,19 +5941,19 @@ SSiTextFile_WriteGroup( SStPermutation *perm_array; UUtUns32 num_permutations; UUtUns32 j; - + group = SSrGroup_GetByIndex(i); if (group == NULL) { continue; } - + sprintf(string, "%s \t %5.3f \n", group->group_name, group->group_volume); BFrFile_Write(inFile, strlen(string), string); - + perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(group->permutations); num_permutations = UUrMemory_Array_GetUsedElems(group->permutations); for (j = 0; j < num_permutations; j++) { SStPermutation *perm; - + perm = &perm_array[j]; sprintf( string, @@ -5968,7 +5968,7 @@ SSiTextFile_WriteGroup( BFrFile_Write(inFile, strlen(string), string); } } - + return UUcError_None; } @@ -5981,25 +5981,25 @@ SSiTextFile_Write( char filename[128]; BFtFileRef *file_ref; BFtFile *file; - + // create the env file ref switch (inType) { case SScType_Ambient: sprintf(filename, "Sound_Ambient.txt"); break; - + case SScType_Impulse: sprintf(filename, "Sound_Impulse.txt"); break; - + case SScType_Group: sprintf(filename, "Sound_Group.txt"); break; } error = BFrFileRef_MakeFromName(filename, &file_ref); UUmError_ReturnOnError(error); - + // create the .TXT file if it doesn't already exist if (BFrFileRef_FileExists(file_ref) == UUcFalse) { @@ -6007,26 +6007,26 @@ SSiTextFile_Write( error = BFrFile_Create(file_ref); UUmError_ReturnOnError(error); } - + // open the file error = BFrFile_Open(file_ref, "rw", &file); UUmError_ReturnOnError(error); - + // set the position to 0 error = BFrFile_SetPos(file, 0); UUmError_ReturnOnError(error); - + // write the items switch (inType) { case SScType_Ambient: SSiTextFile_WriteAmbient(file); break; - + case SScType_Impulse: SSiTextFile_WriteImpulse(file); break; - + case SScType_Group: SSiTextFile_WriteGroup(file); break; @@ -6034,15 +6034,15 @@ SSiTextFile_Write( // set the end of the file BFrFile_SetEOF(file); - + // close the file BFrFile_Close(file); file = NULL; - + // delete the file ref BFrFileRef_Dispose(file_ref); file_ref = NULL; - + return UUcError_None; } @@ -6052,7 +6052,7 @@ SSrTextFile_Write( void) { UUtError error; - + error = SSiTextFile_Write(SScType_Ambient); UUmError_ReturnOnError(error); @@ -6061,7 +6061,7 @@ SSrTextFile_Write( error = SSiTextFile_Write(SScType_Group); UUmError_ReturnOnError(error); - + return error; } @@ -6083,11 +6083,11 @@ SSrListBrokenSounds( UUtUns32 num_groups; UUtUns32 i; char text[1024]; - + // make sure all of the pointers are up to date SSrAmbient_UpdateGroupPointers(); SSrImpulse_UpdateGroupPointers(); - + // printf a header BFrFile_Printf(inFile, "********** Ambient Sound Links **********"UUmNL); BFrFile_Printf(inFile, UUmNL); @@ -6098,14 +6098,14 @@ SSrListBrokenSounds( { BFrFile_Printf(inFile, "Ambient\tGroup\tGroup Name"UUmNL); } - + ambient_array = (SStAmbient**)UUrMemory_Array_GetMemory(SSgAmbientSounds); for (i = 0; i < num_ambients; i++) { SStAmbient *ambient; - + ambient = ambient_array[i]; - + if ((ambient->in_sound_name[0] != '\0') && (ambient->in_sound == NULL)) { sprintf(text, "%sin_sound\t%s", ambient->ambient_name, ambient->in_sound_name); @@ -6141,13 +6141,13 @@ SSrListBrokenSounds( BFrFile_Printf(inFile, "%s"UUmNL, text); } } - + if (num_ambients > 0) { BFrFile_Printf(inFile, UUmNL); BFrFile_Printf(inFile, UUmNL); } - + // go through all of the impulse sounds and list ones which can't find their groups num_impulses = UUrMemory_Array_GetUsedElems(SSgImpulseSounds); if (num_impulses > 0) @@ -6158,9 +6158,9 @@ SSrListBrokenSounds( for (i = 0; i < num_impulses; i++) { SStImpulse *impulse; - + impulse = impulse_array[i]; - + if ((impulse->impulse_group_name[0] != '\0') && (impulse->impulse_group == NULL)) { sprintf(text, "%s\t%s", impulse->impulse_name, impulse->impulse_group_name); @@ -6168,7 +6168,7 @@ SSrListBrokenSounds( BFrFile_Printf(inFile, "%s"UUmNL, text); } } - + if (num_impulses > 0) { BFrFile_Printf(inFile, UUmNL); @@ -6189,18 +6189,18 @@ SSrListBrokenSounds( UUtUns32 j; SStPermutation *perm_array; UUtUns32 num_permutations; - + group = group_array[i]; - + perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(group->permutations); num_permutations = UUrMemory_Array_GetUsedElems(group->permutations); - + for (j = 0; j < num_permutations; j++) { SStPermutation *perm; - + perm = &perm_array[j]; - + if (perm->sound_data == NULL) { if (perm->sound_data_name[0] == '\0') @@ -6225,12 +6225,12 @@ SSrListBrokenSounds( } } } - + BFrFile_Printf(inFile, UUmNL); BFrFile_Printf(inFile, UUmNL); BFrFile_Printf(inFile, UUmNL); } - + return UUcError_None; } @@ -6270,9 +6270,9 @@ SS2rInitializeBasic( UUtBool inUseSound) { UUtError error; - + UUrStartupMessage("initializing basic sound system 2 layer..."); - + SSgSoundChannels_Mono = NULL; SSgSoundChannels_Stereo = NULL; SSgSoundChannels_NumStereo = 0; @@ -6284,7 +6284,7 @@ SS2rInitializeBasic( // initialize the platform specific sound stuff error = SS2rPlatform_Initialize(inWindow, &SSgSoundChannels_NumTotal, inUseSound); if (error != UUcError_None) { goto exit; } - + // initialize the sound channels error = SSiSoundChannels_Initialize( @@ -6292,14 +6292,14 @@ SS2rInitializeBasic( &SSgSoundChannels_NumStereo, &SSgSoundChannels_NumMono); if (error != UUcError_None) { goto exit; } - + SSgChannelsInitialized = UUcTrue; SSgEnabled = (SSgSoundChannels_NumTotal > 0); // start the thread error = SS2rPlatform_InitializeThread(); if (error != UUcError_None) { goto exit; } - + exit: return UUcError_None; } @@ -6311,16 +6311,16 @@ SS2rInitializeFull( { UUtError error; UUtUns32 itr; - + UUrStartupMessage("initializing full sound system 2..."); /* if (!SSgChannelsInitialized) { // this requires the base level to be initialized first goto exit; }*/ - + SSrWaitGuard(SSgGuardAll); - + // no pointer handlers yet SSgImpulseHandler = NULL; SSgAmbientHandler = NULL; @@ -6328,12 +6328,12 @@ SS2rInitializeFull( // register the templates error = SS2rRegisterTemplates(); if (error != UUcError_None) { goto exit; } - + // register the at exit callback UUrAtExit_Register(SS2rTerminate); - + // set the proc handler - error = + error = TMrTemplate_PrivateData_New( SScTemplate_SoundData, 0, @@ -6349,7 +6349,7 @@ SS2rInitializeFull( 0, 0); if (SSgSoundGroups == NULL) { goto exit; } - + // allocate memory for the ambient sounds SSgAmbientSounds = UUrMemory_Array_New( @@ -6358,7 +6358,7 @@ SS2rInitializeFull( 0, 0); if (SSgAmbientSounds == NULL) { goto exit; } - + // allocate memory for the impulse sounds SSgImpulseSounds = UUrMemory_Array_New( @@ -6367,7 +6367,7 @@ SS2rInitializeFull( 0, 0); if (SSgImpulseSounds == NULL) { goto exit; } - + // allocate memory for the dynamically allocated SStSoundData array SSgDynamicSoundData = UUrMemory_Array_New( @@ -6376,7 +6376,7 @@ SS2rInitializeFull( 0, 0); if (SSgDynamicSoundData == NULL) { goto exit; } - + // allocate memory for the dynamic deallocation of SStSoundData SSgDeallocatedSoundData = UUrMemory_Array_New( @@ -6397,7 +6397,7 @@ SS2rInitializeFull( SSgNumPlayingAmbients = 0; goto exit; } - + for (itr = 0; itr < SSgNumPlayingAmbients; itr++) { SSgPlayingAmbient[itr].stage = SScPAStage_None; @@ -6408,14 +6408,14 @@ SS2rInitializeFull( SSgOverallVolume = 1.0f; SSgDesiredVolume = SSgOverallVolume; MUmVector_Set(SSgListener_Facing, 1.0f, 0.0f, 0.0f); - + error = SLrGlobalVariable_Register_Bool( "sound_show_debug", "Displays sound debugging info", &SSgShowDebugInfo); if (error != UUcError_None) { goto exit; } - + SSgPlaybackInitialized = UUcTrue; SSgUsable = SSgEnabled; @@ -6449,9 +6449,9 @@ SSrPlayingChannels_Pause( UUtUns32 i; SStSoundChannel *sound_channels; UUtUns32 num_channels; - + SSrWaitGuard(SSgGuardAll); - + if (SSgSoundChannels_Stereo != NULL) { // pause all playing stereo channels @@ -6463,7 +6463,7 @@ SSrPlayingChannels_Pause( SSiSoundChannel_Pause(&sound_channels[i]); } } - + if (SSgSoundChannels_Mono != NULL) { // initialize each mono sound channel @@ -6475,7 +6475,7 @@ SSrPlayingChannels_Pause( SSiSoundChannel_Pause(&sound_channels[i]); } } - + SSrReleaseGuard(SSgGuardAll); } @@ -6487,9 +6487,9 @@ SSrPlayingChannels_Resume( UUtUns32 i; SStSoundChannel *sound_channels; UUtUns32 num_channels; - + SSrWaitGuard(SSgGuardAll); - + if (SSgSoundChannels_Stereo != NULL) { // pause all playing stereo channels @@ -6505,7 +6505,7 @@ SSrPlayingChannels_Resume( SSiSoundChannel_Resume(&sound_channels[i]); } } - + if (SSgSoundChannels_Mono != NULL) { // initialize each mono sound channel @@ -6521,7 +6521,7 @@ SSrPlayingChannels_Resume( SSiSoundChannel_Resume(&sound_channels[i]); } } - + SSrReleaseGuard(SSgGuardAll); } @@ -6535,7 +6535,7 @@ SSrStopAll( UUtUns32 num_playing_ambients; SStSoundChannel *sound_channels; UUtUns32 num_channels; - + SSrWaitGuard(SSgGuardAll); if (SSgPlayingAmbient != NULL) @@ -6548,7 +6548,7 @@ SSrStopAll( SSrAmbient_Halt(playing_ambient_array[i].id); } } - + if (SSgSoundChannels_Stereo != NULL) { // stop all remaining playing sounds @@ -6560,7 +6560,7 @@ SSrStopAll( sound_channels[i].sound_data = NULL; } } - + if (SSgSoundChannels_Mono != NULL) { // initialize each mono sound channel @@ -6586,21 +6586,21 @@ SS2rTerminate( SStImpulse **impulse_sound_array; SStAmbient **ambient_sound_array; UUtUns32 i; - + SSgUsable = UUcFalse; - + if (SSgGuardAll) { SSrWaitGuard(SSgGuardAll); } - + // stop the platform-specific thread so it doesn't try to update while we // are in the midst of terminating SS2rPlatform_TerminateThread(); - + // terminate the sound channels SSiSoundChannels_Terminate(); - + // delete the group, array if (SSgSoundGroups) { @@ -6612,7 +6612,7 @@ SS2rTerminate( UUrMemory_Array_Delete(SSgSoundGroups); SSgSoundGroups = NULL; } - + // delete the impulse array if (SSgImpulseSounds) { @@ -6624,7 +6624,7 @@ SS2rTerminate( UUrMemory_Array_Delete(SSgImpulseSounds); SSgImpulseSounds = NULL; } - + // delete the ambient array if (SSgAmbientSounds) { @@ -6636,7 +6636,7 @@ SS2rTerminate( UUrMemory_Array_Delete(SSgAmbientSounds); SSgAmbientSounds = NULL; } - + // delete the deallocated-pointer array // CB: this must come before we delete the sound data array, otherwise // we will store ALL of the sound data pointers (which isn't useful). @@ -6658,21 +6658,21 @@ SS2rTerminate( UUrMemory_Array_Delete(SSgDynamicSoundData); SSgDynamicSoundData = NULL; } - + // delete the playing ambient if (SSgPlayingAmbient) { UUrMemory_Block_Delete(SSgPlayingAmbient); SSgPlayingAmbient = NULL; } - + SSgTemplate_PrivateData = NULL; - + SS2rPlatform_Terminate(); SSgPlaybackInitialized = UUcFalse; SSgChannelsInitialized = UUcFalse; - + if (SSgGuardAll) { SSrReleaseGuard(SSgGuardAll); @@ -6687,13 +6687,13 @@ SS2rUpdate( void) { if (SSgUsable == UUcFalse) { return; } - + SS2iVolume_Update(); - + SS2rPlatform_PerformanceStartFrame(); - + SSiPlayingAmbient_UpdateList(); - + SS2rPlatform_PerformanceEndFrame(); } @@ -6714,13 +6714,13 @@ SS2rVolume_Set( float inVolume) { float old_volume; - + if (SSgUsable == UUcFalse) { return 0.0f; } - + old_volume = SSgOverallVolume; inVolume = UUmPin(inVolume, 0.0f, 1.0f); SSgDesiredVolume = inVolume; - + return old_volume; } @@ -6733,10 +6733,10 @@ SS2iVolume_Update( UUtUns32 num_channels; SStSoundChannel *sound_channel_array; UUtUns32 i; - + if (SSgUsable == UUcFalse) { return; } if (SSgOverallVolume == SSgDesiredVolume) { return; } - + // calculate the adjustment volume_delta = SSgDesiredVolume - SSgOverallVolume; if (volume_delta > 0.0f) @@ -6747,11 +6747,11 @@ SS2iVolume_Update( { volume_delta = UUmMax(volume_delta, -SScVolumeAdjust); } - + // adjust the volume SSgOverallVolume += volume_delta; SSgOverallVolume = UUmPin(SSgOverallVolume, 0.0f, 1.0f); - + // adjust the volume of the sound channels if (SSgSoundChannels_Stereo) { @@ -6776,5 +6776,5 @@ SS2iVolume_Update( sound_channel_array[i].channel_volume); } } - + } diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_MacOS/BFW_SS2_Platform_MacOS.c b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_MacOS/BFW_SS2_Platform_MacOS.c index 49bf496..b28ffe6 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_MacOS/BFW_SS2_Platform_MacOS.c +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_MacOS/BFW_SS2_Platform_MacOS.c @@ -47,7 +47,7 @@ SS2iPlatform_SoundChannel_ApplyVolume( UUtUns32 volume; UUtUns16 left_volume; UUtUns16 right_volume; - + // calculate the left and right volumes left_volume = (UUtUns16)(inSoundChannel->pd.volume * @@ -57,10 +57,10 @@ SS2iPlatform_SoundChannel_ApplyVolume( (UUtUns16)(inSoundChannel->pd.volume * SScPlatform_MaxVolume* inSoundChannel->pd.right_pan); - + // set the volume volume = UUmMakeLong(right_volume, left_volume); - + // set the channel volume SSmSetSndCommand(cmd, volumeCmd, 0, volume); err = SndDoImmediate(inSoundChannel->pd.sound_channel, &cmd); @@ -74,10 +74,10 @@ SSiPlatform_SoundChannel_Callback( SndCommand *inSoundCommand) { SStSoundChannel *sound_channel; - + // get the sound channel being used sound_channel = (SStSoundChannel*)inSoundCommand->param2; - + if (SSiSoundChannel_IsLooping(sound_channel)) { // play another permutation in the group @@ -101,16 +101,16 @@ SSiPlatform_SoundChannel_Terminate( char *inErrorString) { OSErr err; - + if (inErrorString) { UUrError_Report(UUcError_Generic, inErrorString); } - + if (inSoundChannel->pd.sound_channel) { // stop the sound channel - err = + err = SndDisposeChannel( inSoundChannel->pd.sound_channel, UUcTrue); @@ -136,7 +136,7 @@ SS2rPlatform_SoundChannel_Initialize( { OSErr err; UUtInt32 init_flag; - + // clear the vars inSoundChannel->pd.sound_channel = NULL; inSoundChannel->pd.sound = NULL; @@ -144,7 +144,7 @@ SS2rPlatform_SoundChannel_Initialize( inSoundChannel->pd.left_pan = 1.0f; inSoundChannel->pd.right_pan = 1.0f; inSoundChannel->pd.pitch = (UUcMaxUns16 + 1); - + // ------------------------------ // Sound Channel // ------------------------------ @@ -156,7 +156,7 @@ SS2rPlatform_SoundChannel_Initialize( { init_flag = initStereo; } - + // intialize the sound channel err = SndNewChannel( @@ -171,7 +171,7 @@ SS2rPlatform_SoundChannel_Initialize( "Unable to initialize the sound channel."); return; } - + // ------------------------------ // Sound // ------------------------------ @@ -194,10 +194,10 @@ SS2rPlatform_SoundChannel_Play( { SndCommand cmd; OSErr err; - + UUmAssert(inSoundChannel->pd.sound_channel); UUmAssert(inSoundChannel->pd.sound); - + // set the status field SSiSoundChannel_SetPlaying(inSoundChannel, UUcTrue); @@ -205,18 +205,18 @@ SS2rPlatform_SoundChannel_Play( SSmSetSndCommand(cmd, bufferCmd, 0, (UUtUns32)inSoundChannel->pd.sound); err = SndDoCommand(inSoundChannel->pd.sound_channel, &cmd, UUcTrue); if (err != noErr) { goto cleanup; } - + // queue the callback SSmSetSndCommand(cmd, callBackCmd, 0, (UUtUns32)inSoundChannel); err = SndDoCommand(inSoundChannel->pd.sound_channel, &cmd, UUcTrue); if (err != noErr) { goto cleanup; } - + return; - + cleanup: SSmSetSndCommand(cmd, quietCmd, 0, 0); SndDoImmediate(inSoundChannel->pd.sound_channel, &cmd); - + // set the status field SSiSoundChannel_SetPlaying(inSoundChannel, UUcTrue); } @@ -229,10 +229,10 @@ SS2rPlatform_SoundChannel_SetSoundData( { // UUtUns32 num_frames; UUtUns32 num_channels = SSrSound_GetNumChannels(inSoundData); - + UUmAssert(inSoundChannel->pd.sound_channel); UUmAssert(inSoundChannel->pd.sound); - + // make sure a mono channel plays on a mono sound if (((inSoundChannel->flags & SScSoundChannelFlag_Mono) == SScSoundChannelFlag_Mono) && (num_channels != 1)) @@ -246,7 +246,7 @@ SS2rPlatform_SoundChannel_SetSoundData( { return UUcFalse; } - + #if 0 num_frames = (SScBitsPerSample == 8) ? @@ -259,10 +259,10 @@ SS2rPlatform_SoundChannel_SetSoundData( { CmpSoundHeader *cmp_sound; UUtUns32 packet_count = inSoundData->num_bytes / (num_channels * sizeof(SStIMA_SampleData)); - + cmp_sound = (CmpSoundHeader*)inSoundChannel->pd.sound; UUrMemory_Clear(cmp_sound, sizeof(CmpSoundHeader)); - + // setup the compressed sound header cmp_sound->samplePtr = (char*)inSoundData->data; cmp_sound->numChannels = num_channels; @@ -282,15 +282,15 @@ SS2rPlatform_SoundChannel_SetSoundData( // cmp_sound->snthID = 0; cmp_sound->sampleSize = SScBitsPerSample; } - + #if 0 else if ((inSoundData->flags & SScSoundDataFlag_PCM_Little) != 0) { CmpSoundHeader *cmp_sound; - + cmp_sound = (CmpSoundHeader*)inSoundChannel->pd.sound; UUrMemory_Clear(cmp_sound, sizeof(CmpSoundHeader)); - + // setup the compressed sound header cmp_sound->samplePtr = (char*)inSoundData->data; cmp_sound->numChannels = inSoundData->f.nChannels; @@ -313,10 +313,10 @@ SS2rPlatform_SoundChannel_SetSoundData( else if ((inSoundData->flags & SScSoundDataFlag_PCM_Big) != 0) { ExtSoundHeader *ext_sound; - + ext_sound = (ExtSoundHeader*)inSoundChannel->pd.sound; UUrMemory_Clear(ext_sound, sizeof(ExtSoundHeader)); - + // setup the extended sound header ext_sound->samplePtr = (char*)inSoundData->data; ext_sound->numChannels = inSoundData->f.nChannels; @@ -356,24 +356,24 @@ SS2rPlatform_SoundChannel_SetPan( inSoundChannel->pd.left_pan = 1.0f; inSoundChannel->pd.right_pan = 1.0f; break; - + case SScPanFlag_Left: // lower right volume inSoundChannel->pd.left_pan = 1.0f; inSoundChannel->pd.right_pan = inPan; break; - + case SScPanFlag_Right: // lower right volume inSoundChannel->pd.left_pan = inPan; inSoundChannel->pd.right_pan = 1.0f; break; } - + // apply the pan SS2iPlatform_SoundChannel_ApplyVolume(inSoundChannel); } - + // ---------------------------------------------------------------------- void SS2rPlatform_SoundChannel_SetPitch( @@ -383,11 +383,11 @@ SS2rPlatform_SoundChannel_SetPitch( SndCommand cmd; OSErr err; UUtUns32 rate; - + // calculate the rate rate = (UUtUns32)(inPitch * (float)(UUcMaxUns16 + 1)); inSoundChannel->pitch = rate; - + // set the rate if (!(inSoundChannel->status & SScSCStatus_Paused)) { SSmSetSndCommand(cmd, rateCmd, 0, rate); @@ -406,7 +406,7 @@ SS2rPlatform_SoundChannel_SetVolume( { // set the volume inSoundChannel->pd.volume = inVolume; - + // apply the volume SS2iPlatform_SoundChannel_ApplyVolume(inSoundChannel); } @@ -418,12 +418,12 @@ SS2rPlatform_SoundChannel_Stop( { SndCommand cmd; OSErr err; - + // flush the commands from the channel SSmSetSndCommand(cmd, flushCmd, 0, 0); err = SndDoImmediate(inSoundChannel->pd.sound_channel, &cmd); SSmCheckSndError(err); - + // stop the sound that is playing SSmSetSndCommand(cmd, quietCmd, 0, 0); err = SndDoImmediate(inSoundChannel->pd.sound_channel, &cmd); @@ -456,11 +456,11 @@ SS2rPlatform_Initialize( NumVersion sound_manager_version; OSErr err; UUtInt32 response; - + // ------------------------------ // make sure the needed sound capabilities exist on this hardware // ------------------------------ - + // get the sound manager version sound_manager_version = SndSoundManagerVersion(); if (sound_manager_version.majorRev < 3) { return UUcError_Generic; } @@ -468,17 +468,17 @@ SS2rPlatform_Initialize( { return UUcError_Generic; } - + // gestalt the sound attributes err = Gestalt(gestaltSoundAttr, &response); if (err != noErr) { return UUcError_Generic; } - + // check for needed properties if ((response & (1 << gestaltStereoCapability)) == 0) { return UUcError_Generic; } if ((response & (1 << gestaltMultiChannels)) == 0) { return UUcError_Generic; } if ((response & (1 << gestalt16BitSoundIO)) == 0) { return UUcError_Generic; } if ((response & (1 << gestalt16BitAudioSupport)) == 0) { return UUcError_Generic; } - + // ------------------------------ // Create the Sound Callback // ------------------------------ @@ -490,11 +490,11 @@ SS2rPlatform_Initialize( UUrError_Report(UUcError_Generic, "Unable to create sound callback UPP"); return UUcError_Generic; } - + // ------------------------------ // set the number of sound channels *outNumChannels = SScMaxSoundChannels; - + return UUcError_None; } @@ -574,7 +574,7 @@ void SS2rPlatform_GetDebugNeeds( UUtUns32 *outNumLines) { *outNumLines= 0L; - + return; } @@ -583,7 +583,7 @@ void SS2rPlatform_PerformanceStartFrame( { return; } - + void SS2rPlatform_PerformanceEndFrame( void) { @@ -629,16 +629,16 @@ SS2rPlatform_SoundChannel_Pause( { SndCommand cmd; OSErr err; - + UUmAssert(inSoundChannel); - + // make sure the channel is playing if (SSiSoundChannel_IsPlaying(inSoundChannel) == UUcFalse) { return; } - + SSmSetSndCommand(cmd, rateCmd, 0, 0); err = SndDoImmediate(inSoundChannel->pd.sound_channel, &cmd); SSmCheckSndError(err); - + // set the status field SSiSoundChannel_SetPaused(inSoundChannel, UUcTrue); @@ -651,16 +651,16 @@ SS2rPlatform_SoundChannel_Resume( { SndCommand cmd; OSErr err; - + UUmAssert(inSoundChannel); - + // make sure the channel is playing and paused if ((SSiSoundChannel_IsPlaying(inSoundChannel) == UUcFalse) || (SSiSoundChannel_IsPaused(inSoundChannel) == UUcFalse)) { return; } - + SSmSetSndCommand(cmd, rateCmd, 0, inSoundChannel->pd.pitch); err = SndDoImmediate(inSoundChannel->pd.sound_channel, &cmd); SSmCheckSndError(err); @@ -678,7 +678,7 @@ void SS2rPlatform_SoundChannel_Silence( { return; } - + /* end S.S. */ diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_MacOS/BFW_SS2_Platform_MacOS.h b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_MacOS/BFW_SS2_Platform_MacOS.h index b774f9d..bca1c34 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_MacOS/BFW_SS2_Platform_MacOS.h +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_MacOS/BFW_SS2_Platform_MacOS.h @@ -27,7 +27,7 @@ typedef struct SStSoundChannel_PlatformData UUtUns32 pitch; float left_pan; float right_pan; - + } SStSoundChannel_PlatformData; // ====================================================================== diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_OpenAL/BFW_SS2_Platform_OpenAL.c b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_OpenAL/BFW_SS2_Platform_OpenAL.c index 7644adb..b956460 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_OpenAL/BFW_SS2_Platform_OpenAL.c +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_OpenAL/BFW_SS2_Platform_OpenAL.c @@ -140,7 +140,7 @@ SS2rPlatform_SoundChannel_Play( alSourcei(inSoundChannel->pd.source, AL_LOOPING, SSiSoundChannel_IsLooping(inSoundChannel) == UUcTrue ? AL_TRUE : AL_FALSE); alSourcePlay(inSoundChannel->pd.source); CHECK_AL_ERROR(); - + SSiSoundChannel_SetPlaying(inSoundChannel, UUcTrue); } @@ -175,19 +175,19 @@ SS2r_DecompressMSADPCM( { UUtBool success = UUcFalse; unsigned channels = SSrSound_GetNumChannels(inSoundData); - + *samples = 0; - + if (SScSamplesPerSecond != 8 && SScBitsPerSample != 16) { UUrPrintWarning("Unexpected SScBitsPerSample: %d", SScBitsPerSample); return UUcFalse; } - + #ifdef DEBUGGING av_log_set_level(AV_LOG_DEBUG); #endif - + const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_ADPCM_MS); if (!codec) { UUrPrintWarning("Failed to find ADPCM_MS codec"); @@ -219,7 +219,7 @@ SS2r_DecompressMSADPCM( char *frame = inSoundData->data; char *frames_end = frame + inSoundData->num_bytes; const size_t framesz = 512 * channels; - + AVFrame *decoded_frame = av_frame_alloc(); if (!decoded_frame) { UUrPrintWarning("Failed to allocate libav frame"); @@ -282,12 +282,12 @@ SS2r_DecompressMSADPCM( } av_frame_unref(decoded_frame); av_frame_free(&decoded_frame); - + error: av_packet_free(&pkt); ctx_error: avcodec_free_context(&c); - + return success; } @@ -319,7 +319,7 @@ SS2rPlatform_SoundChannel_SetSoundData( UUrPrintWarning("Invalid format. bps=%d, SStSoundChannel flags = %x", SScBitsPerSample, inSoundChannel->flags); return UUcFalse; } - + // MSADPCM offers near 4:1 compression UUtUns16 *decoded = UUrMemory_Block_New(inSoundData->num_bytes * 4); if (!decoded) { @@ -327,7 +327,7 @@ SS2rPlatform_SoundChannel_SetSoundData( } size_t samples = 0; UUtBool success = SS2r_DecompressMSADPCM(inSoundChannel, inSoundData, decoded, &samples); - + if (success) { alSourcei(inSoundChannel->pd.source, AL_BUFFER, 0); @@ -336,9 +336,9 @@ SS2rPlatform_SoundChannel_SetSoundData( alSourcei(inSoundChannel->pd.source, AL_BUFFER, inSoundChannel->pd.buffer); CHECK_AL_ERROR(); } - + UUrMemory_Block_Delete(decoded); - + return success; } @@ -357,10 +357,10 @@ SS2rPlatform_SoundChannel_SetPan( case SScPanFlag_Left: inPan = -inPan; break; - + case SScPanFlag_Right: break; - + case SScPanFlag_None: default: inPan = 0.0f; @@ -416,7 +416,7 @@ SS2rPlatform_SoundChannel_Terminate( alDeleteSources(1, &inSoundChannel->pd.source); inSoundChannel->pd.source = 0; CHECK_AL_ERROR(); - + alDeleteBuffers(1, &inSoundChannel->pd.buffer); inSoundChannel->pd.buffer = 0; CHECK_AL_ERROR(); @@ -435,11 +435,11 @@ SS2rPlatform_Initialize( UUtBool inUseSound) { *outNumChannels = 0; - + SSgDevice = alcOpenDevice(NULL); CHECK_AL_ERROR(); UUmError_ReturnOnNull(SSgDevice); - + //FIXME: the number of channels will be split across mono/stereo ALCint attrs[] = { ALC_FREQUENCY, SScSamplesPerSecond, @@ -450,16 +450,16 @@ SS2rPlatform_Initialize( SSgContext = alcCreateContext(SSgDevice, &attrs); CHECK_AL_ERROR(); UUmError_ReturnOnNull(SSgContext); - + ALCint numMono, numStereo; alcGetIntegerv(SSgDevice, ALC_MONO_SOURCES, 1, &numMono); alcGetIntegerv(SSgDevice, ALC_STEREO_SOURCES, 1, &numStereo); CHECK_AL_ERROR(); *outNumChannels = UUmMin(numMono, numStereo); - + alcMakeContextCurrent(SSgContext); CHECK_AL_ERROR(); - + return UUcError_None; } @@ -489,7 +489,7 @@ SS2rPlatform_Terminate( CHECK_AL_ERROR(); SSgContext = NULL; } - + if (SSgDevice) { alcCloseDevice(SSgDevice); diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_Win32/BFW_SS2_Platform_Win32.c b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_Win32/BFW_SS2_Platform_Win32.c index e50502a..58ddf48 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_Win32/BFW_SS2_Platform_Win32.c +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_Win32/BFW_SS2_Platform_Win32.c @@ -95,15 +95,15 @@ SSiSoundChannelList_Add( UUtError error; UUtUns32 index; SStSoundChannel **sound_channel_array; - + error = UUrMemory_Array_GetNewElement(SSgSoundChannelList, &index, NULL); UUmError_ReturnOnError(error); - + sound_channel_array = (SStSoundChannel**)UUrMemory_Array_GetMemory(SSgSoundChannelList); UUmAssert(sound_channel_array); - + sound_channel_array[index] = inSoundChannel; - + return UUcError_None; } @@ -115,7 +115,7 @@ SSiSoundChannelList_Delete( SStSoundChannel **sound_channel_array; UUtUns32 num_elements; UUtUns32 i; - + sound_channel_array = (SStSoundChannel**)UUrMemory_Array_GetMemory(SSgSoundChannelList); num_elements = UUrMemory_Array_GetUsedElems(SSgSoundChannelList); for (i = 0; i < num_elements; i++) @@ -134,14 +134,14 @@ static UUtError SSiSoundChannelList_Initialize( void) { - SSgSoundChannelList = + SSgSoundChannelList = UUrMemory_Array_New( sizeof(SStSoundChannel*), 5, 0, SScMaxSoundChannels); UUmError_ReturnOnNull(SSgSoundChannelList); - + return UUcError_None; } @@ -173,12 +173,12 @@ SSiPlatform_SoundChannel_MSADPCM_Initialize( #if defined(SScMSADPCMTimer) && (SScMSADPCMTimer == 1) t1 = timeGetTime(); #endif - + // determine the best format for the destination UUrMemory_Clear(&inSoundChannel->pd.DstHeader, sizeof(WAVEFORMATEX)); inSoundChannel->pd.DstHeader.wFormatTag = WAVE_FORMAT_PCM; - + // get the format for the PCM header result = acmFormatSuggest( @@ -192,13 +192,13 @@ SSiPlatform_SoundChannel_MSADPCM_Initialize( return_val = UUcFalse; goto end; } - + if (inSoundChannel->pd.acm != NULL) { acmStreamClose(inSoundChannel->pd.acm, 0); inSoundChannel->pd.acm = NULL; } - + // open the stream result = acmStreamOpen( @@ -233,18 +233,18 @@ SSiPlatform_SoundChannel_MSADPCM_Initialize( return_val = UUcFalse; goto end; } - + #if defined(SScMSADPCMTimer) && (SScMSADPCMTimer == 1) t2 = timeGetTime(); - + SSgMSADPCMTimer_Max = UUmMax(SSgMSADPCMTimer_Max, (t2 - t1)); SSgMSADPCMTimer_Min = UUmMin(SSgMSADPCMTimer_Min, (t2 - t1)); - + decomp_time += (t2 - t1); #endif - + return_val = UUcTrue; - + end: return return_val; } @@ -255,7 +255,7 @@ SSiPlatform_SoundChannel_MSADPCM_Terminate( SStSoundChannel *inSoundChannel) { HRESULT result; - + #if defined(SScMSADPCMTimer) && (SScMSADPCMTimer == 1) t1 = timeGetTime();; #endif @@ -268,10 +268,10 @@ SSiPlatform_SoundChannel_MSADPCM_Terminate( #if defined(SScMSADPCMTimer) && (SScMSADPCMTimer == 1) t2 = timeGetTime(); - + SSgMSADPCMTimer_Max = UUmMax(SSgMSADPCMTimer_Max, (t2 - t1)); SSgMSADPCMTimer_Min = UUmMin(SSgMSADPCMTimer_Min, (t2 - t1)); - + decomp_time += (t2 - t1); #endif } @@ -291,7 +291,7 @@ SSiPlatform_SoundChannel_MSADPCM_DecompressData( UUtUns32 src_size; UUtUns32 write_size; UUtBool return_val; - + #if defined(SScMSADPCMTimer) && (SScMSADPCMTimer == 1) t1 = timeGetTime(); #endif @@ -307,16 +307,16 @@ SSiPlatform_SoundChannel_MSADPCM_DecompressData( return_val = UUcFalse; goto end; } - + src = ((UUtUns8*)inSoundChannel->sound_data->data) + inSoundChannel->pd.num_packets_decompressed; - - src_size = + + src_size = UUmMin( inSoundChannel->pd.DefaultReadSize, (inSoundChannel->sound_data->num_bytes - inSoundChannel->pd.num_packets_decompressed)); - + // determine the write size result = acmStreamSize( @@ -329,9 +329,9 @@ SSiPlatform_SoundChannel_MSADPCM_DecompressData( return_val = UUcFalse; goto end; } - + UUmAssert(write_size <= inSoundChannel->pd.decompressed_data_length); - + // prepare the stream ZeroMemory(&inSoundChannel->pd.stream, sizeof(ACMSTREAMHEADER)); inSoundChannel->pd.stream.cbStruct = sizeof(ACMSTREAMHEADER); @@ -339,7 +339,7 @@ SSiPlatform_SoundChannel_MSADPCM_DecompressData( inSoundChannel->pd.stream.cbSrcLength = src_size; inSoundChannel->pd.stream.pbDst = inSoundChannel->pd.decompressed_data; inSoundChannel->pd.stream.cbDstLength = write_size; - + result = acmStreamPrepareHeader( inSoundChannel->pd.acm, @@ -350,7 +350,7 @@ SSiPlatform_SoundChannel_MSADPCM_DecompressData( return_val = UUcFalse; goto end; } - + // decompress sound data into the buffer result = acmStreamConvert( @@ -362,7 +362,7 @@ SSiPlatform_SoundChannel_MSADPCM_DecompressData( return_val = UUcFalse; goto end; } - + #if defined(DEBUGGING) && (DEBUGGING != 0) if (inSoundChannel->pd.stream.cbDstLengthUsed == 0) { @@ -375,26 +375,26 @@ SSiPlatform_SoundChannel_MSADPCM_DecompressData( inSoundChannel->pd.decompressed_packets_length = inSoundChannel->pd.stream.cbDstLengthUsed; inSoundChannel->pd.num_packets_decompressed += inSoundChannel->pd.stream.cbSrcLengthUsed; inSoundChannel->pd.bytes_read = 0; - + result = acmStreamUnprepareHeader( inSoundChannel->pd.acm, &inSoundChannel->pd.stream, 0); - + #if defined(SScMSADPCMTimer) && (SScMSADPCMTimer == 1) t2 = timeGetTime(); - + SSgMSADPCMTimer_Max = UUmMax(SSgMSADPCMTimer_Max, (t2 - t1)); SSgMSADPCMTimer_Min = UUmMin(SSgMSADPCMTimer_Min, (t2 - t1)); - + decomp_time += (t2 - t1); decomp_count++; #endif - + return_val = UUcTrue; - + end: return return_val; } @@ -407,12 +407,12 @@ SSiPlatform_SoundChannel_IMA_DecompressData( UUtUns32 number_of_packets_decompressed; UUtUns32 num_channels = SSrSound_IsStereo(inSoundChannel->sound_data) ? 2 : 1; WAVEFORMATEX *wave_format_ex = (WAVEFORMATEX *) (SSrSound_IsStereo(inSoundChannel->sound_data) ? &SSgWaveFormat_Stereo : &SSgWaveFormat_Mono); - + if (inSoundChannel->pd.num_packets_decompressed >= wave_format_ex->nBlockAlign) { return UUcFalse; } - + // decompress sound data into the buffer number_of_packets_decompressed = SSrIMA_DecompressSoundData( @@ -420,7 +420,7 @@ SSiPlatform_SoundChannel_IMA_DecompressData( inSoundChannel->pd.decompressed_data, SScNumPacketsToDecompress, inSoundChannel->pd.num_packets_decompressed); - + inSoundChannel->pd.decompressed_packets_length = number_of_packets_decompressed * sizeof(UUtUns16) * @@ -439,18 +439,18 @@ SSiPlatform_SoundChannel_Terminate( char *inErrorString) { HRESULT result; - + if (inErrorString) { UUrError_Report(UUcError_Generic, inErrorString); } - + if (inSoundChannel->pd.decompressed_data != NULL) { UUrMemory_Block_Delete(inSoundChannel->pd.decompressed_data); inSoundChannel->pd.decompressed_data = NULL; } - + if (inSoundChannel->pd.soundBuffer3D) { result = IDirectSound3DBuffer_Release(inSoundChannel->pd.soundBuffer3D); @@ -460,7 +460,7 @@ SSiPlatform_SoundChannel_Terminate( } inSoundChannel->pd.soundBuffer3D = NULL; } - + if (inSoundChannel->pd.soundBuffer) { result = IDirectSoundBuffer_Release(inSoundChannel->pd.soundBuffer); @@ -470,7 +470,7 @@ SSiPlatform_SoundChannel_Terminate( } inSoundChannel->pd.soundBuffer = NULL; } - + SSiSoundChannelList_Delete(inSoundChannel); } @@ -492,12 +492,12 @@ SSiPlatform_UpdateSoundBuffer_MSADPCM( UUtBool data_decompressed; WAVEFORMATEX *wave_format_ex = (WAVEFORMATEX *) (SSrSound_IsStereo(inSoundChannel->sound_data) ? &SSgWaveFormat_Stereo : &SSgWaveFormat_Mono); - + // determine which half of the buffer to fill section = inSoundChannel->pd.section; - + // lock the buffer - result = + result = IDirectSoundBuffer_Lock( inSoundChannel->pd.soundBuffer, inSoundChannel->pd.buffer_pos[section], @@ -508,42 +508,42 @@ SSiPlatform_UpdateSoundBuffer_MSADPCM( &audioDataSize2, 0); if (result != DS_OK) { return UUcFalse; } - + bytes_remaining = 0; write_size = 0; dest = (UUtUns8*)audioData; - + do { - if ((inSoundChannel->pd.bytes_read == 0) || + if ((inSoundChannel->pd.bytes_read == 0) || (inSoundChannel->pd.bytes_read == inSoundChannel->pd.decompressed_packets_length)) { // decompress some more sound data data_decompressed = SSiPlatform_SoundChannel_MSADPCM_DecompressData(inSoundChannel); - //data_decompressed = SSiPlatform_SoundChannel_IMA_DecompressData(inSoundChannel); + //data_decompressed = SSiPlatform_SoundChannel_IMA_DecompressData(inSoundChannel); if (!data_decompressed) { bytes_remaining = (inSoundChannel->pd.section_size - inSoundChannel->pd.bytes_written); break; } } - + // determine how many bytes to write write_size = UUmMin( (inSoundChannel->pd.section_size - inSoundChannel->pd.bytes_written), (inSoundChannel->pd.decompressed_packets_length - inSoundChannel->pd.bytes_read)); if (write_size == 0) { break; } - + // copy data from the decompressed_data into the buffer src = inSoundChannel->pd.decompressed_data + inSoundChannel->pd.bytes_read; dest = ((UUtUns8*)audioData) + inSoundChannel->pd.bytes_written; UUrMemory_MoveFast(src, dest, write_size); - + // increment the number of sound bytes read and the number of buffer bytes written inSoundChannel->pd.bytes_read += write_size; inSoundChannel->pd.bytes_written += write_size; - + bytes_remaining = (inSoundChannel->pd.section_size - inSoundChannel->pd.bytes_written); } while (bytes_remaining > 0); @@ -552,24 +552,24 @@ SSiPlatform_UpdateSoundBuffer_MSADPCM( { dest += write_size; UUrMemory_Set8( - dest, + dest, ((wave_format_ex->wBitsPerSample == 8) ? 0x80 : 0), bytes_remaining); - + if (SSiSoundChannel_IsAmbient(inSoundChannel) == UUcFalse) { bytes_remaining = 0; } - + inSoundChannel->pd.stop = UUcTrue; inSoundChannel->pd.stop_section = section; inSoundChannel->pd.stop_pos = inSoundChannel->pd.bytes_written + (section * inSoundChannel->pd.section_size); } - + // unlock the buffer - result = + result = IDirectSoundBuffer_Unlock( inSoundChannel->pd.soundBuffer, audioData, @@ -577,7 +577,7 @@ SSiPlatform_UpdateSoundBuffer_MSADPCM( audioData2, audioDataSize2); if (result != DS_OK) { return UUcFalse; } - + // if this is a looping sound, fill in the remaining bytes with another permutation if (bytes_remaining > 0) { @@ -593,7 +593,7 @@ SSiPlatform_UpdateSoundBuffer_MSADPCM( SSiSoundChannel_SetUpdating(inSoundChannel, UUcFalse); } } - + return UUcTrue; } @@ -614,12 +614,12 @@ SSiPlatform_UpdateSoundBuffer_IMA( UUtUns8 *dest; UUtInt32 bytes_remaining; UUtBool data_decompressed; - + // determine which half of the buffer to fill section = inSoundChannel->pd.section; - + // lock the buffer - result = + result = IDirectSoundBuffer_Lock( inSoundChannel->pd.soundBuffer, inSoundChannel->pd.buffer_pos[section], @@ -630,14 +630,14 @@ SSiPlatform_UpdateSoundBuffer_IMA( &audioDataSize2, 0); if (result != DS_OK) { return UUcFalse; } - + bytes_remaining = 0; write_size = 0; dest = (UUtUns8*)audioData; - + do { - if ((inSoundChannel->pd.bytes_read == 0) || + if ((inSoundChannel->pd.bytes_read == 0) || (inSoundChannel->pd.bytes_read == inSoundChannel->pd.decompressed_packets_length)) { // decompress some more sound data @@ -648,23 +648,23 @@ SSiPlatform_UpdateSoundBuffer_IMA( break; } } - + // determine how many bytes to write write_size = UUmMin( (inSoundChannel->pd.section_size - inSoundChannel->pd.bytes_written), (inSoundChannel->pd.decompressed_packets_length - inSoundChannel->pd.bytes_read)); if (write_size == 0) { break; } - + // copy data from the decompressed_data into the buffer src = inSoundChannel->pd.decompressed_data + inSoundChannel->pd.bytes_read; dest = ((UUtUns8*)audioData) + inSoundChannel->pd.bytes_written; UUrMemory_MoveFast(src, dest, write_size); - + // increment the number of sound bytes read and the number of buffer bytes written inSoundChannel->pd.bytes_read += write_size; inSoundChannel->pd.bytes_written += write_size; - + bytes_remaining = (inSoundChannel->pd.section_size - inSoundChannel->pd.bytes_written); } while (bytes_remaining > 0); @@ -673,24 +673,24 @@ SSiPlatform_UpdateSoundBuffer_IMA( { dest += write_size; UUrMemory_Set8( - dest, + dest, ((inSoundChannel->sound_data->f.wBitsPerSample == 8) ? 0x80 : 0), bytes_remaining); - + if (SSiSoundChannel_IsAmbient(inSoundChannel) == UUcFalse) { bytes_remaining = 0; } - + inSoundChannel->pd.stop = UUcTrue; inSoundChannel->pd.stop_section = section; inSoundChannel->pd.stop_pos = inSoundChannel->pd.bytes_written + (section * inSoundChannel->pd.section_size); } - + // unlock the buffer - result = + result = IDirectSoundBuffer_Unlock( inSoundChannel->pd.soundBuffer, audioData, @@ -698,7 +698,7 @@ SSiPlatform_UpdateSoundBuffer_IMA( audioData2, audioDataSize2); if (result != DS_OK) { return UUcFalse; } - + // if this is a looping sound, fill in the remaining bytes with another permutation if (bytes_remaining > 0) { @@ -714,7 +714,7 @@ SSiPlatform_UpdateSoundBuffer_IMA( SSiSoundChannel_SetUpdating(inSoundChannel, UUcFalse); } } - + return UUcTrue; } #endif @@ -735,10 +735,10 @@ SSiPlatform_UpdateSoundBuffer_Uncompressed( UUtUns8 *src; UUtUns8 *dest; UUtInt32 bytes_remaining; - + // determine which half of the buffer to fill section = inSoundChannel->pd.section; - + // determine how many bytes to write write_size = UUmMin( @@ -749,12 +749,12 @@ SSiPlatform_UpdateSoundBuffer_Uncompressed( inSoundChannel->pd.stop = UUcTrue; return UUcFalse; } - + // set the source pointer src = ((UUtUns8*)inSoundChannel->sound_data->data) + inSoundChannel->pd.bytes_read; // lock the buffer - result = + result = IDirectSoundBuffer_Lock( inSoundChannel->pd.soundBuffer, inSoundChannel->pd.buffer_pos[section], @@ -765,15 +765,15 @@ SSiPlatform_UpdateSoundBuffer_Uncompressed( &audioDataSize2, 0); if (result != DS_OK) { return UUcFalse; } - + // copy data from the sound data into the buffer dest = ((UUtUns8*)audioData) + inSoundChannel->pd.bytes_written; UUrMemory_MoveFast(src, dest, write_size); - + // increment the number of sound bytes read and the number of buffer bytes written inSoundChannel->pd.bytes_read += write_size; inSoundChannel->pd.bytes_written += write_size; - + // fill the remaining bytes with silence if this is not a looping channel bytes_remaining = (inSoundChannel->pd.section_size - inSoundChannel->pd.bytes_written); if ((bytes_remaining > 0) && (SSiSoundChannel_IsLooping(inSoundChannel) == UUcFalse)) @@ -783,21 +783,21 @@ SSiPlatform_UpdateSoundBuffer_Uncompressed( dest, ((inSoundChannel->sound_data->f.wBitsPerSample == 8) ? 0x80 : 0), bytes_remaining); - + if (SSiSoundChannel_IsAmbient(inSoundChannel) == UUcFalse) { bytes_remaining = 0; } - + inSoundChannel->pd.stop = UUcTrue; inSoundChannel->pd.stop_section = section; inSoundChannel->pd.stop_pos = inSoundChannel->pd.bytes_written + (section * inSoundChannel->pd.section_size); } - + // unlock the buffer - result = + result = IDirectSoundBuffer_Unlock( inSoundChannel->pd.soundBuffer, audioData, @@ -805,7 +805,7 @@ SSiPlatform_UpdateSoundBuffer_Uncompressed( audioData2, audioDataSize2); if (result != DS_OK) { return UUcFalse; } - + // if this is a looping sound, fill in the remaining bytes with another permutation if (bytes_remaining > 0) { @@ -821,7 +821,7 @@ SSiPlatform_UpdateSoundBuffer_Uncompressed( SSiSoundChannel_SetUpdating(inSoundChannel, UUcFalse); } } - + return UUcTrue; } #endif @@ -832,9 +832,9 @@ SSiPlatform_UpdateSoundBuffer( SStSoundChannel *inSoundChannel) { UUtBool result; - + result = SSiPlatform_UpdateSoundBuffer_MSADPCM(inSoundChannel); - + return result; } @@ -845,9 +845,9 @@ SSiPlatform_GetPlaySection( UUtUns32 inPlayPos) { UUtUns32 section; - + section = inPlayPos / inSoundChannel->pd.section_size; - + return section; } @@ -863,9 +863,9 @@ SSiPlatform_SilenceSection( void *audioData2; UUtUns32 audioDataSize2; UUtUns8 *dest; - + // lock the buffer - result = + result = IDirectSoundBuffer_Lock( inSoundChannel->pd.soundBuffer, inSoundChannel->pd.buffer_pos[inSection], @@ -876,18 +876,18 @@ SSiPlatform_SilenceSection( &audioDataSize2, 0); if (result != DS_OK) { return; } - + // copy data from the sound data into the buffer dest = (UUtUns8*)audioData; - + // write silence into the buffer UUrMemory_Set8( dest, 0, inSoundChannel->pd.section_size); - + // unlock the buffer - result = + result = IDirectSoundBuffer_Unlock( inSoundChannel->pd.soundBuffer, audioData, @@ -907,16 +907,16 @@ SSiPlatform_Update( SStSoundChannel **sound_channel_array; UUtUns32 num_elements; UUtUns32 i; - + if (!SS2rEnabled()) { // CB: the sound system is not actually enabled, exit the thread ExitThread(0); } - + SSrWaitGuard(SSgGuardAll); // go through all of the notifications and toggle the events - // of the buffers that have reached their + // of the buffers that have reached their num_elements = UUrMemory_Array_GetUsedElems(SSgSoundChannelList); sound_channel_array = (SStSoundChannel**)UUrMemory_Array_GetMemory(SSgSoundChannelList); for (i = 0; i < num_elements; i++) @@ -925,27 +925,27 @@ SSiPlatform_Update( UUtUns32 play_pos; UUtUns32 current; UUtUns32 next; - + sound_channel = sound_channel_array[i]; - + // only check buffers which are playing if (SSiSoundChannel_IsPlaying(sound_channel) == UUcFalse) { continue; } - + // get the position of the buffer IDirectSoundBuffer_GetCurrentPosition(sound_channel->pd.soundBuffer, &play_pos, NULL); - + current = sound_channel->pd.section; next = current + 1; if (next >= SScNotifiesPerChannel) { next = 0; } - + // update the sound channel if the play position is past the buffer_pos if (sound_channel->pd.stop == UUcTrue) { UUtUns32 play_section; - + play_section = SSiPlatform_GetPlaySection(sound_channel, play_pos); if (play_section == sound_channel->pd.stop_section) { @@ -953,7 +953,7 @@ SSiPlatform_Update( SSiPlatform_SilenceSection(sound_channel, next); } - + if (sound_channel->pd.can_stop == UUcTrue) { if ((sound_channel->pd.stop_pos <= play_pos) || @@ -963,13 +963,13 @@ SSiPlatform_Update( } } } - else + else { if ((current == 0) && (sound_channel->pd.buffer_pos[next] < play_pos)) { continue; } - + if (sound_channel->pd.buffer_pos[current] <= play_pos) { // update the sound buffer @@ -980,13 +980,13 @@ SSiPlatform_Update( } } SSrReleaseGuard(SSgGuardAll); - + Sleep(25); } - + // exit the thread ExitThread(0); - + return 0; } @@ -1011,16 +1011,16 @@ SS2rPlatform_ShowDebugInfo_Overall( #if defined(SScMSADPCMTimer) && (SScMSADPCMTimer == 1) char string[128]; float avg; - + sprintf( string, "max %d min %d", SSgMSADPCMTimer_Max, SSgMSADPCMTimer_Min); - + DCrText_DrawText(string, NULL, inDest); inDest->y += DCrText_GetLineHeight(); - + if (SSgMSADPCMTimer_NumDecompress_Frame != 0) { avg = (float)SSgMSADPCMTimer_DecompressTime_Frame / (float)SSgMSADPCMTimer_NumDecompress_Frame; @@ -1035,10 +1035,10 @@ SS2rPlatform_ShowDebugInfo_Overall( SSgMSADPCMTimer_DecompressTime_Frame, SSgMSADPCMTimer_NumDecompress_Frame, avg); - + DCrText_DrawText(string, NULL, inDest); inDest->y += DCrText_GetLineHeight(); - + if (SSgMSADPCMTimer_NumDecompress_Total != 0) { avg = (float)SSgMSADPCMTimer_DecompressTime_Total / (float)SSgMSADPCMTimer_NumDecompress_Total; @@ -1053,14 +1053,14 @@ SS2rPlatform_ShowDebugInfo_Overall( SSgMSADPCMTimer_DecompressTime_Total, SSgMSADPCMTimer_NumDecompress_Total, avg); - + DCrText_DrawText(string, NULL, inDest); inDest->y += DCrText_GetLineHeight(); #else - + return; - + #endif } @@ -1082,7 +1082,7 @@ SS2rPlatform_PerformanceEndFrame( { #if defined(SScMSADPCMTimer) && (SScMSADPCMTimer == 1) t1 = timeGetTime(); - + SSgMSADPCMTimer_NumDecompress_Frame = decomp_count; SSgMSADPCMTimer_NumDecompress_Total += decomp_count; SSgMSADPCMTimer_DecompressTime_Frame = decomp_time; @@ -1104,7 +1104,7 @@ SS2rPlatform_SoundChannel_Initialize( DSBUFFERDESC buffer_desc; HRESULT result; UUtUns32 i; - + // initialize the sound channel inSoundChannel->pd.soundBuffer = NULL; inSoundChannel->pd.soundBuffer3D = NULL; @@ -1119,7 +1119,7 @@ SS2rPlatform_SoundChannel_Initialize( inSoundChannel->pd.num_packets_decompressed = 0; inSoundChannel->pd.decompressed_packets_length = 0; inSoundChannel->pd.acm = NULL; - + for (i = 0; i < SScNotifiesPerChannel; i++) { inSoundChannel->pd.buffer_pos[i] = 0; @@ -1134,7 +1134,7 @@ SS2rPlatform_SoundChannel_Initialize( wave_format.nBlockAlign = wave_format.wBitsPerSample * wave_format.nChannels / 8; wave_format.nAvgBytesPerSec = wave_format.nSamplesPerSec * wave_format.nBlockAlign; wave_format.cbSize = 0; - + // set up the buffer description UUrMemory_Clear(&buffer_desc, sizeof(DSBUFFERDESC)); buffer_desc.dwSize = sizeof(DSBUFFERDESC); @@ -1147,11 +1147,11 @@ SS2rPlatform_SoundChannel_Initialize( DSBCAPS_CTRLFREQUENCY; buffer_desc.dwBufferBytes = wave_format.nAvgBytesPerSec * 3; buffer_desc.lpwfxFormat = &wave_format; - + // save the buffer size inSoundChannel->pd.buffer_size = buffer_desc.dwBufferBytes; inSoundChannel->pd.section_size = buffer_desc.dwBufferBytes / SScNotifiesPerChannel; - + // create the sound buffer result = IDirectSound_CreateSoundBuffer( @@ -1164,25 +1164,25 @@ SS2rPlatform_SoundChannel_Initialize( UUrError_Report(UUcError_Generic, SSiP_DS_GetErrorMsg(result)); return; } - + // add the channel to the list - + // set the buffer_positions for the update to watch for for (i = 0; i < SScNotifiesPerChannel; i++) { inSoundChannel->pd.buffer_pos[i] = (inSoundChannel->pd.section_size * i); } - + // add the sound channel to the sound channel update list SSiSoundChannelList_Add(inSoundChannel); - + // allocate memory for SScNumPacketsToDecompress packet worth of decompressed data inSoundChannel->pd.decompressed_data_length = (SScIMA_SamplesPerPacket * sizeof(UUtUns16) * SScNumPacketsToDecompress * wave_format.nChannels); - inSoundChannel->pd.decompressed_data = + inSoundChannel->pd.decompressed_data = UUrMemory_Block_New(inSoundChannel->pd.decompressed_data_length); inSoundChannel->pd.decompressed_packets_length = 0; inSoundChannel->pd.num_packets_decompressed = 0; @@ -1194,19 +1194,19 @@ SS2rPlatform_SoundChannel_Pause( SStSoundChannel *inSoundChannel) { HRESULT result; - + UUmAssert(inSoundChannel); - + // make sure the channel is playing if (SSiSoundChannel_IsPlaying(inSoundChannel) == UUcFalse) { return; } - + // stop the channel buffer result = IDirectSoundBuffer_Stop(inSoundChannel->pd.soundBuffer); if (result != DS_OK) { UUrError_Report(UUcError_Generic, SSiP_DS_GetErrorMsg(result)); } - + // set the status field SSiSoundChannel_SetPaused(inSoundChannel, UUcTrue); } @@ -1217,20 +1217,20 @@ SS2rPlatform_SoundChannel_Play( SStSoundChannel *inSoundChannel) { HRESULT result; - + UUmAssert(inSoundChannel); UUmAssert(inSoundChannel->pd.soundBuffer); - + // if the channel is already playing then don't do anything if (SSiSoundChannel_IsPlaying(inSoundChannel) == UUcTrue) { return; } - + // play the sound result = IDirectSoundBuffer_Play(inSoundChannel->pd.soundBuffer, 0, 0, DSBPLAY_LOOPING); if (result != DS_OK) { UUrError_Report(UUcError_Generic, SSiP_DS_GetErrorMsg(result)); } - + // set the status field SSiSoundChannel_SetPlaying(inSoundChannel, UUcTrue); } @@ -1241,23 +1241,23 @@ SS2rPlatform_SoundChannel_Resume( SStSoundChannel *inSoundChannel) { HRESULT result; - + UUmAssert(inSoundChannel); - + // make sure the channel is playing and paused if ((SSiSoundChannel_IsPlaying(inSoundChannel) == UUcFalse) || (SSiSoundChannel_IsPaused(inSoundChannel) == UUcFalse)) { return; } - + // stop the channel buffer result = IDirectSoundBuffer_Play(inSoundChannel->pd.soundBuffer, 0, 0, DSBPLAY_LOOPING); if (result != DS_OK) { UUrError_Report(UUcError_Generic, SSiP_DS_GetErrorMsg(result)); } - + // set the status field SSiSoundChannel_SetPaused(inSoundChannel, UUcFalse); } @@ -1269,11 +1269,11 @@ SS2rPlatform_SoundChannel_SetSoundData( SStSoundData *inSoundData) { UUtBool result; - + UUmAssert(inSoundChannel); UUmAssert(inSoundChannel->pd.soundBuffer); - UUmAssert(inSoundData); - + UUmAssert(inSoundData); + // SSrWaitGuard(&inSoundChannel->guard); // set the sound data and number of bytes read @@ -1283,17 +1283,17 @@ SS2rPlatform_SoundChannel_SetSoundData( inSoundChannel->pd.stop = UUcFalse; inSoundChannel->pd.can_stop = UUcFalse; inSoundChannel->pd.stop_pos = 0; - + // decompress data from the sound data into the buffer if ((inSoundChannel->sound_data->flags & SScSoundDataFlag_Compressed) != 0) { inSoundChannel->pd.num_packets_decompressed = 0; - + if (inSoundChannel->pd.acm != NULL) { SSiPlatform_SoundChannel_MSADPCM_Terminate(inSoundChannel); } - + result = SSiPlatform_SoundChannel_MSADPCM_Initialize(inSoundChannel); if (result == UUcFalse) { @@ -1302,21 +1302,21 @@ SS2rPlatform_SoundChannel_SetSoundData( return result; } } - + // set the section if the sound is not playing if ((SSiSoundChannel_IsPlaying(inSoundChannel) == UUcFalse) && (SSiSoundChannel_IsUpdating(inSoundChannel) == UUcFalse)) { // set the section to 0 so that section zero gets filled inSoundChannel->pd.section = 0; - + // set the position IDirectSoundBuffer_SetCurrentPosition(inSoundChannel->pd.soundBuffer, 0); } - + // fill in the section result = SSiPlatform_UpdateSoundBuffer(inSoundChannel); - + // SSrReleaseGuard(&inSoundChannel->guard); return result; @@ -1330,7 +1330,7 @@ SS2rPlatform_SoundChannel_SetPan( float inPan) { UUtInt32 pan; - + // calculate the pan switch (inPanFlags) { @@ -1344,7 +1344,7 @@ SS2rPlatform_SoundChannel_SetPan( pan = DSBPAN_LEFT; } break; - + case SScPanFlag_Right: if (inPan > SScZeroSound) { @@ -1355,13 +1355,13 @@ SS2rPlatform_SoundChannel_SetPan( pan = DSBPAN_RIGHT; } break; - + case SScPanFlag_None: default: pan = DSBPAN_CENTER; break; } - + // set the pan IDirectSoundBuffer_SetPan(inSoundChannel->pd.soundBuffer, pan); } @@ -1373,10 +1373,10 @@ SS2rPlatform_SoundChannel_SetPitch( float inPitch) { UUtInt32 frequency; - + // calculate the frequency frequency = (UUtInt32)(22050.0f * inPitch); - + // set the frequency IDirectSoundBuffer_SetFrequency(inSoundChannel->pd.soundBuffer, frequency); } @@ -1388,7 +1388,7 @@ SS2rPlatform_SoundChannel_SetVolume( float inVolume) { UUtInt32 volume; - + // calculate the volume if (inVolume > SScZeroSound) { @@ -1398,7 +1398,7 @@ SS2rPlatform_SoundChannel_SetVolume( { volume = DSBVOLUME_MIN; } - + // set the volume IDirectSoundBuffer_SetVolume(inSoundChannel->pd.soundBuffer, volume); } @@ -1413,7 +1413,7 @@ SS2rPlatform_SoundChannel_Silence( UUtUns32 audioDataSize; // lock the buffer - result = + result = IDirectSoundBuffer_Lock( inSoundChannel->pd.soundBuffer, 0, @@ -1424,12 +1424,12 @@ SS2rPlatform_SoundChannel_Silence( NULL, DSBLOCK_ENTIREBUFFER); if (result != DS_OK) { return; } - + // write silence into the buffer UUrMemory_Set16(audioData, 0, (audioDataSize >> 1)); - + // unlock the buffer - result = + result = IDirectSoundBuffer_Unlock( inSoundChannel->pd.soundBuffer, audioData, @@ -1445,15 +1445,15 @@ SS2rPlatform_SoundChannel_Stop( SStSoundChannel *inSoundChannel) { HRESULT result; - + // set the status field SSiSoundChannel_SetPlaying(inSoundChannel, UUcFalse); - + // clear some of the platform data inSoundChannel->pd.bytes_read = 0; inSoundChannel->pd.bytes_written = 0; inSoundChannel->pd.section = 0; - + // stop the buffer result = IDirectSoundBuffer_Stop(inSoundChannel->pd.soundBuffer); if (result != DS_OK) @@ -1496,7 +1496,7 @@ SS2rPlatform_Initialize( OSVERSIONINFO info; UUtError error; BOOL success; - + *outNumChannels = 0; // init the main vars @@ -1508,7 +1508,7 @@ SS2rPlatform_Initialize( SSgEventThread = NULL; SSgEventThreadID = 0; SSgSoundChannelList = NULL; - + if (!inUseSound) { return UUcError_None; } @@ -1553,7 +1553,7 @@ SS2rPlatform_Initialize( return UUcError_Generic; } UUmAssert(SSgDirectSound); - + // get the capabilities of the device SSgDSCaps.dwSize = sizeof(SSgDSCaps); result = IDirectSound_GetCaps(SSgDirectSound, &SSgDSCaps); @@ -1589,12 +1589,12 @@ SS2rPlatform_Initialize( UUrStartupMessage("direct sound dwTotalHwMemBytes = %d", SSgDSCaps.dwTotalHwMemBytes); UUrStartupMessage("direct sound dwUnlockTransferRateHwBuffers = %d", SSgDSCaps.dwUnlockTransferRateHwBuffers); - + // set the number of channels // SSgNumChannels = SSgDSCaps.dwFreeHwMixingStreamingBuffers; // if (SSgNumChannels == 0) { SSgNumChannels = SScMaxSoundChannels; } SSgNumChannels = SScMaxSoundChannels; - + UUrStartupMessage("setting the direct sound cooperative level"); // set cooperative level @@ -1605,7 +1605,7 @@ SS2rPlatform_Initialize( // UUrError_Report(UUcError_Generic, SSiP_DS_GetErrorMsg(result)); goto cleanup; } - + // ------------------------------ // Create the Primary Buffer // ------------------------------ @@ -1613,12 +1613,12 @@ SS2rPlatform_Initialize( UUrMemory_Clear(&pb_desc, sizeof(DSBUFFERDESC)); pb_desc.dwSize = sizeof(DSBUFFERDESC); pb_desc.dwFlags = DSBCAPS_PRIMARYBUFFER; - + /* if (SSgUse3DSound) { pb_desc.dwFlags |= DSBCAPS_CTRL3D; }*/ - + // create the primary buffer result = IDirectSound_CreateSoundBuffer( @@ -1629,21 +1629,21 @@ SS2rPlatform_Initialize( if (result != DS_OK) { // UUrError_Report(UUcError_Generic, SSiP_DS_GetErrorMsg(result)); - goto cleanup; + goto cleanup; } - + // set up the wave format structure UUrMemory_Clear(&wave_format, sizeof(WAVEFORMATEX)); wave_format.wFormatTag = WAVE_FORMAT_PCM; wave_format.nChannels = 2; wave_format.nSamplesPerSec = 22050; wave_format.wBitsPerSample = 16; - wave_format.nBlockAlign = + wave_format.nBlockAlign = wave_format.wBitsPerSample * wave_format.nChannels / 8; wave_format.nAvgBytesPerSec = wave_format.nSamplesPerSec * wave_format.nBlockAlign; wave_format.cbSize = 0; - + // set the primary buffer's format result = IDirectSoundBuffer_SetFormat(SSgPrimaryBuffer, &wave_format); if (result != DS_OK) @@ -1651,7 +1651,7 @@ SS2rPlatform_Initialize( UUrError_Report(UUcError_Generic, SSiP_DS_GetErrorMsg(result)); goto cleanup; } - + // play the primary sound buffer result = IDirectSoundBuffer_Play(SSgPrimaryBuffer, 0, 0, DSBPLAY_LOOPING); if (result != DS_OK) @@ -1659,7 +1659,7 @@ SS2rPlatform_Initialize( // UUrError_Report(UUcError_Generic, SSiP_DS_GetErrorMsg(result)); goto cleanup; } - + // ------------------------------ // Intitialize the buffer update // ------------------------------ @@ -1670,7 +1670,7 @@ SS2rPlatform_Initialize( // UUrError_Report(error, "Unable to create the sound channel list."); goto cleanup; } - + // ------------------------------ // Intitialize Direct Sound 3D // ------------------------------ @@ -1682,7 +1682,7 @@ SS2rPlatform_Initialize( { SSgUse3DSound = UUcFalse; } - + // do reverb initialization if (SSgUseReverb) { @@ -1693,17 +1693,17 @@ SS2rPlatform_Initialize( } } }*/ - + // ------------------------------ // set the number of sound channels // ------------------------------ *outNumChannels = SSgNumChannels; - + return UUcError_None; cleanup: SS2rPlatform_Terminate(); - + return UUcError_Generic; } @@ -1726,7 +1726,7 @@ SS2rPlatform_InitializeThread( { return UUcError_Generic; } - + return UUcError_None; } @@ -1736,7 +1736,7 @@ SS2rPlatform_TerminateThread( void) { SSgUpdate_Run = UUcFalse; - + // clear the thread vars if (SSgEventThread) { @@ -1752,11 +1752,11 @@ SS2rPlatform_Terminate( void) { HRESULT result; - + SS2rPlatform_TerminateThread(); - + SSiSoundChannelList_Terminate(); - + // release the primary sound buffer if (SSgPrimaryBuffer) { @@ -1774,7 +1774,7 @@ SS2rPlatform_Terminate( SSgPrimaryBuffer = NULL; } - + // release the direct sound object if (SSgDirectSound) { @@ -1786,7 +1786,7 @@ SS2rPlatform_Terminate( SSgDirectSound = NULL; } - + SSgNumChannels = 0; } @@ -1801,7 +1801,7 @@ SSrDeleteGuard( SStGuard *inGuard) { DeleteCriticalSection(inGuard); - + UUrMemory_Block_Delete(inGuard); } @@ -1811,10 +1811,10 @@ SSrCreateGuard( SStGuard **inGuard) { SStGuard *guard; - + guard = UUrMemory_Block_New(sizeof(CRITICAL_SECTION)); InitializeCriticalSection(guard); - + *inGuard = guard; } @@ -1845,78 +1845,78 @@ SSiP_DS_GetErrorMsg( HRESULT inResult) { char *errorMsg; - + switch (inResult) { case DSERR_ALLOCATED: errorMsg = "The call failed because resources (such as a priority level) were already being used by another caller."; break; - + case DSERR_CONTROLUNAVAIL: errorMsg = "The control (vol,pan,etc.) requested by the caller is not available."; break; - + case DSERR_INVALIDPARAM: errorMsg = "An invalid parameter was passed to the returning function."; break; - + case DSERR_INVALIDCALL: errorMsg = "This call is not valid for the current state of this object."; break; - + case DSERR_GENERIC: errorMsg = "An undetermined error occured inside the DirectSound subsystem."; break; - + case DSERR_PRIOLEVELNEEDED: errorMsg = "The caller does not have the priority level required for the function to succeed."; break; - + case DSERR_OUTOFMEMORY: errorMsg = "Not enough free memory is available to complete the operation."; break; - + case DSERR_BADFORMAT: errorMsg = "The specified WAVE format is not supported."; break; - + case DSERR_UNSUPPORTED: errorMsg = "The function called is not supported at this time."; break; - + case DSERR_NODRIVER: errorMsg = "No sound driver is available for use."; break; - + case DSERR_ALREADYINITIALIZED: errorMsg = "This object is already initialized."; break; - + case DSERR_NOAGGREGATION: errorMsg = "This object does not support aggregation."; break; - + case DSERR_BUFFERLOST: errorMsg = "The buffer memory has been lost, and must be restored."; break; - + case DSERR_OTHERAPPHASPRIO: errorMsg = "Another app has a higher priority level, preventing this call from succeeding."; break; - + case DSERR_UNINITIALIZED: errorMsg = "This object has not been initialized."; break; - + case DSERR_NOINTERFACE: errorMsg = "The requested COM interface is not available."; break; - + default: errorMsg = "Unknown error."; break; } - + return errorMsg; } diff --git a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_Win32/BFW_SS2_Platform_Win32.h b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_Win32/BFW_SS2_Platform_Win32.h index 520e637..5979c3c 100644 --- a/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_Win32/BFW_SS2_Platform_Win32.h +++ b/BungieFrameWork/BFW_Source/BFW_SoundSystem2/Platform_Win32/BFW_SS2_Platform_Win32.h @@ -30,30 +30,30 @@ typedef struct SStSoundChannel_PlatformData { LPDIRECTSOUNDBUFFER soundBuffer; LPDIRECTSOUND3DBUFFER soundBuffer3D; - + UUtUns32 buffer_size; UUtUns32 buffer_pos[SScNotifiesPerChannel]; UUtUns32 stop_pos; UUtUns32 stop_section; - + UUtUns32 section_size; UUtUns32 section; UUtUns32 bytes_read; UUtUns32 bytes_written; UUtBool stop; UUtBool can_stop; - + UUtUns8 *decompressed_data; UUtUns32 decompressed_data_length; UUtUns32 num_packets_decompressed; UUtUns32 decompressed_packets_length; - + WAVEFORMATEX DstHeader; HACMSTREAM acm; ACMSTREAMHEADER stream; UUtUns32 DefaultReadSize; - + } SStSoundChannel_PlatformData; // ====================================================================== diff --git a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Common.c b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Common.c index c35217d..f2246d6 100644 --- a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Common.c +++ b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Common.c @@ -1,12 +1,12 @@ /* FILE: BFW_TM3_Utility.c - + AUTHOR: Brent H. Pease - + CREATED: July 10, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -60,9 +60,9 @@ TMiSwapCode_Dump_Indent( UUtUns32 inSwapCodeOffset) { UUtUns32 itr; - + fprintf(inFile, "[%04d, %04d]", inSwapCodeOffset, inDataOffset); - + for(itr = 0; itr < inIndent; itr++) { fprintf(inFile, "\t"); @@ -83,15 +83,15 @@ TMiSwapCode_Dump_Recursive( UUtBool stop; UUtUns8 count; UUtUns32 savedDataOffset; - + curSwapCode = *ioSwapCode; stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: @@ -99,25 +99,25 @@ TMiSwapCode_Dump_Recursive( fprintf(inFile, "8Byte(%02x)\n", TMcSwapCode_8Byte); curDataOffset += 8; break; - + case TMcSwapCode_4Byte: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "4Byte(%02x)\n", TMcSwapCode_4Byte); curDataOffset += 4; break; - + case TMcSwapCode_2Byte: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "2Byte(%02x)\n", TMcSwapCode_2Byte); curDataOffset += 2; break; - + case TMcSwapCode_1Byte: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "1Byte(%02x)\n", TMcSwapCode_1Byte); curDataOffset += 1; break; - + case TMcSwapCode_BeginArray: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "begin array(%02x)\n", TMcSwapCode_BeginArray); @@ -133,13 +133,13 @@ TMiSwapCode_Dump_Recursive( inSwapCodeBase); curDataOffset += (curDataOffset - savedDataOffset) * (count - 1); break; - + case TMcSwapCode_EndArray: stop = UUcTrue; TMiSwapCode_Dump_Indent(inFile, inIndent-1, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "end array(%02x)\n", TMcSwapCode_EndArray); break; - + case TMcSwapCode_BeginVarArray: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "begin vararray(%02x)\n", TMcSwapCode_BeginVarArray); @@ -162,7 +162,7 @@ TMiSwapCode_Dump_Recursive( default: UUmAssert(!"Swap codes damaged"); } - + TMiSwapCode_Dump_Recursive( inFile, inIndent+1, @@ -170,13 +170,13 @@ TMiSwapCode_Dump_Recursive( &curDataOffset, inSwapCodeBase); break; - + case TMcSwapCode_EndVarArray: TMiSwapCode_Dump_Indent(inFile, inIndent-1, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "end vararray(%02x)\n", TMcSwapCode_EndVarArray); stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "templatePtr(%02x): %c%c%c%c\n", TMcSwapCode_TemplatePtr, @@ -184,16 +184,16 @@ TMiSwapCode_Dump_Recursive( (*(UUtUns32*)curSwapCode >> 16) & 0xFF, (*(UUtUns32*)curSwapCode >> 8) & 0xFF, (*(UUtUns32*)curSwapCode >> 0) & 0xFF); - + curSwapCode += 4; curDataOffset += 4; break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataOffset = curDataOffset; } @@ -209,9 +209,9 @@ TMrInitialize( BFtFileRef* inGameDataFolderRef) { UUtError error; - + TMgInGame = inGame; - + UUmAssert(sizeof(TMtInstanceFile_Header) == UUcProcessor_CacheLineSize * 2); /* @@ -219,9 +219,9 @@ TMrInitialize( */ TMgDataFolderRef = *inGameDataFolderRef; UUrStartupMessage("DataFolder = %s", BFrFileRef_GetLeafName(&TMgDataFolderRef)); - + TMrTemplate_BuildList(); - + if(inGame == UUcTrue) { error = TMrGame_Initialize(); @@ -270,23 +270,23 @@ TMrTemplate_Register( TMtAllowFolding inAllowFolding) { TMtTemplateDefinition *curTemplateDefinition; - + curTemplateDefinition = TMrUtility_Template_FindDefinition(inTemplateTag); if(curTemplateDefinition == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "template does not exist"); } - + if(curTemplateDefinition->flags & TMcTemplateFlag_Registered) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "template already registered"); } - + // Add 4 to make up for preamble if(curTemplateDefinition->size + curTemplateDefinition->varArrayElemSize != inSize + TMcPreDataSize) { - AUrMessageBox(AUcMBType_OK, "Template %s size %d var elem size %d inSize %d pre data size %d", + AUrMessageBox(AUcMBType_OK, "Template %s size %d var elem size %d inSize %d pre data size %d", curTemplateDefinition->name, curTemplateDefinition->size, curTemplateDefinition->varArrayElemSize, @@ -299,12 +299,12 @@ TMrTemplate_Register( } curTemplateDefinition->flags |= TMcTemplateFlag_Registered; - + if(inAllowFolding == TMcFolding_Allow) { curTemplateDefinition->flags |= TMcTemplateFlag_AllowFolding; } - + return UUcError_None; } @@ -314,17 +314,17 @@ TMrSwapCode_DumpDefinition( TMtTemplateDefinition* inTemplateDefinition) { fprintf(inFile, "Name: %s\n", inTemplateDefinition->name); - fprintf(inFile, "Tag: %c%c%c%c\n", + fprintf(inFile, "Tag: %c%c%c%c\n", (inTemplateDefinition->tag >> 24) & 0xFF, (inTemplateDefinition->tag >> 16) & 0xFF, (inTemplateDefinition->tag >> 8) & 0xFF, (inTemplateDefinition->tag >> 0) & 0xFF); - + fprintf(inFile, "Swap Codes:\n"); { UUtUns8* swapCodes = inTemplateDefinition->swapCodes; UUtUns32 dataOffset = 0; - + TMiSwapCode_Dump_Indent(inFile, 0, 0, 0); fprintf(inFile, "begin array\n"); TMiSwapCode_Dump_Recursive(inFile, 1, &swapCodes, &dataOffset, inTemplateDefinition->swapCodes); @@ -336,13 +336,13 @@ TMrSwapCode_DumpAll( FILE* inFile) { UUtUns32 itr; - + for(itr = 0; itr < TMgNumTemplateDefinitions; itr++) { fprintf(inFile, "******************************************\n"); TMrSwapCode_DumpDefinition(inFile, TMgTemplateDefinitionArray + itr); } - + } UUtError @@ -351,17 +351,17 @@ TMrTemplate_InstallByteSwap( TMtTemplateProc_ByteSwap inProc) { TMtTemplateDefinition* templatePtr; - + templatePtr = TMrUtility_Template_FindDefinition(inTemplateTag); if(templatePtr == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find template"); } - + UUmAssert(templatePtr->varArrayElemSize > 0); - + templatePtr->byteSwapProc = inProc; - + return UUcError_None; } @@ -371,7 +371,7 @@ TMrUtility_Template_FindDefinition( { TMtTemplateDefinition* curTemplate = TMgTemplateDefinitionArray; UUtInt32 i; - + if(TMgTemplateDefinitionArray == NULL) return NULL; for(i = TMgNumTemplateDefinitions; i-- > 0;) @@ -380,10 +380,10 @@ TMrUtility_Template_FindDefinition( { return curTemplate; } - + curTemplate++; } - + if(TMgInGame) { UUmAssert(0); @@ -394,7 +394,7 @@ TMrUtility_Template_FindDefinition( (inTemplateTag >> 8) & 0xFF, (inTemplateTag >> 0) & 0xFF); } - + return NULL; } @@ -402,19 +402,19 @@ void TMrUtility_SkipVarArray( UUtUns8* *ioSwapCode) { - + UUtBool stop; UUtUns8* curSwapCode; char swapCode; - + curSwapCode = *ioSwapCode; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: @@ -422,43 +422,43 @@ TMrUtility_SkipVarArray( case TMcSwapCode_4Byte: break; - + case TMcSwapCode_2Byte: break; - + case TMcSwapCode_1Byte: break; - + case TMcSwapCode_BeginArray: curSwapCode++; - + TMrUtility_SkipVarArray(&curSwapCode); break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: curSwapCode++; TMrUtility_SkipVarArray( &curSwapCode); break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: curSwapCode += 4; break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; } @@ -477,9 +477,9 @@ TMrUtility_VarArrayReset_Recursive( curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { switch(*curSwapCode++) @@ -487,39 +487,39 @@ TMrUtility_VarArrayReset_Recursive( case TMcSwapCode_8Byte: curDataPtr += 8; break; - + case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMrUtility_VarArrayReset_Recursive( &curSwapCode, &curDataPtr, inInitialVarArrayLength); } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -527,23 +527,23 @@ TMrUtility_VarArrayReset_Recursive( *(UUtUns64 *)curDataPtr = inInitialVarArrayLength; curDataPtr += 8; break; - + case TMcSwapCode_4Byte: *(UUtUns32 *)curDataPtr = inInitialVarArrayLength; curDataPtr += 4; break; - + case TMcSwapCode_2Byte: *(UUtUns16 *)curDataPtr = (UUtUns16)inInitialVarArrayLength; curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(inInitialVarArrayLength > 0) { for(i = 0; i < inInitialVarArrayLength; i++) @@ -561,22 +561,22 @@ TMrUtility_VarArrayReset_Recursive( TMrUtility_SkipVarArray(&curSwapCode); } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: *(void**)curDataPtr = NULL; curSwapCode += 4; curDataPtr += 4; break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; } @@ -594,38 +594,38 @@ TMrUtility_LevelInfo_Get( char* dot; char* cp; UUtUns32 levelNum; - + UUtUns32 checksum = 0; UUtUns32 factor = 1; UUtUns32 c; - + UUrString_Copy(nameBuffer, BFrFileRef_GetLeafName(inInstanceFileRef), BFcMaxFileNameLength); - + underscore = strchr(nameBuffer, '_'); if(underscore == NULL) { return UUcError_Generic; } - + *underscore = 0; - + sscanf(nameBuffer + 5, "%d", &levelNum); - + cp = underscore + 1; - + dot = strchr(cp, '.'); if(dot == NULL) { return UUcError_Generic; } - + *dot = 0; - + if(outLevelSuffix != NULL) { UUrString_Copy(outLevelSuffix, cp, BFcMaxFileNameLength); } - + if(!strcmp(cp, "Final")) { if(outFinal != NULL) @@ -644,26 +644,26 @@ TMrUtility_LevelInfo_Get( { c = *cp++; if(c == 0) break; - + checksum += (toupper(c) - 'A' + 1) * factor++; } } - + if(levelNum >= 128) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Can not have a level number larger than 127"); } - + if(outLevelNumber != NULL) { *outLevelNumber = levelNum; } - + if(outInstanceFileID != NULL) { *outInstanceFileID = (levelNum << 25) | ((checksum & 0xFFFFFF) << 1) | 1; } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Construction.c b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Construction.c index 7b7d9ce..5cfbf71 100644 --- a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Construction.c +++ b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Construction.c @@ -1,12 +1,12 @@ /* FILE: BFW_TM3_Construction.c - + AUTHOR: Brent H. Pease - + CREATED: July 10, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -28,7 +28,7 @@ * D E F I N E S * ========================================================================= */ - + #define TMcConstruction_MaxInstances (128 * 1024) //#define TMcConstruction_MaxInstancesPerTemplate (32 * 1024) #define TMcConstructionPoolChunkSize (10 * 1024 * 1024) @@ -36,19 +36,19 @@ #if defined(DEBUGGING) && DEBUGGING #define TMmConstruction_Verify_AllTouched() TMiConstruction_Verify_AllTouched() - + #define TMmConstruction_Verify_InstanceData(x) TMiConstruction_Verify_InstanceData(x) #define TMmConstruction_Verify_InstanceDesc(x) TMiConstruction_Verify_InstanceDesc(x) - + #else #define TMmConstruction_Verify_AllTouched() - + #define TMmConstruction_Verify_InstanceData(x) - + #define TMmConstruction_Verify_InstanceDesc(x) - + #endif /* @@ -56,7 +56,7 @@ * T Y P E S * ========================================================================= */ - + /* * Template related build data */ @@ -65,13 +65,13 @@ typedef struct TMtTemplate_ConstructionData { UUtUns32 numInstancesUsed; UUtUns32 totalSizeOfAllInstances; - + UUtUns32 nextInstanceIndex; UUtUns32* instanceIndexList; - + UUtUns32 numInstancesRemoved; UUtUns32 removedSize; - + } TMtTemplate_ConstructionData; typedef struct TMtRawTracking @@ -143,7 +143,7 @@ TMiConstruction_DataPtr_InstanceFileID_Set( TMtInstanceFile_ID inInstanceFileID) { UUmAssertReadPtr(inDataPtr, sizeof(UUtUns32)); - + UUmAssert((((UUtUns32)inDataPtr - TMcPreDataSize) & 0x1F) == 0); *(TMtInstanceFile_ID*)((char *)inDataPtr - sizeof(TMtInstanceFile_ID)) = inInstanceFileID; @@ -154,7 +154,7 @@ TMiConstruction_DataPtr_PlaceHolder_Get( const void* inDataPtr) { UUmAssert((((UUtUns32)inDataPtr - TMcPreDataSize) & 0x1F) == 0); - + return *(TMtPlaceHolder*)((char *)inDataPtr - TMcPreDataSize); } @@ -173,10 +173,10 @@ TMiPlaceHolder_GetIndex( TMtPlaceHolder inPlaceHolder) { UUtUns32 index; - + index = TMmPlaceHolder_GetIndex(inPlaceHolder); UUmAssert(index < TMgConstruction_NumInstanceDescriptors); - + return index; } @@ -185,7 +185,7 @@ TMiPlaceHolder_MakeFromIndex( UUtUns32 inIndex) { UUmAssert(inIndex < TMgConstruction_NumInstanceDescriptors); - + return TMmPlaceHolder_MakeFromIndex(inIndex); } @@ -193,9 +193,9 @@ static void TMiPlaceHolder_EnsureIndex( TMtPlaceHolder *ioPlaceHolder) { - + if(*ioPlaceHolder == 0) return; - + if(TMmPlaceHolder_IsPtr(*ioPlaceHolder)) { *ioPlaceHolder = TMiConstruction_DataPtr_PlaceHolder_Get((void*)*ioPlaceHolder); @@ -208,11 +208,11 @@ TMiConstruction_Verify_InstanceData( { TMtPlaceHolder placeHolder; UUtUns32 index; - + placeHolder = TMiConstruction_DataPtr_PlaceHolder_Get(inDataPtr); - + index = TMiPlaceHolder_GetIndex(placeHolder); - + UUmAssert(index < TMgConstruction_NumInstanceDescriptors); } @@ -220,13 +220,13 @@ static void TMiConstruction_Verify_InstanceDesc( const TMtInstanceDescriptor* inInstanceDescriptor) { - + } static TMtInstanceDescriptor* TMiPlaceHolder_GetInstanceDesc( TMtPlaceHolder inPlaceHolder) -{ +{ TMtInstanceDescriptor* instanceDesc; TMtPlaceHolder placeHolder; UUtUns32 index; @@ -234,9 +234,9 @@ TMiPlaceHolder_GetInstanceDesc( if(TMmPlaceHolder_IsPtr(inPlaceHolder)) { TMmConstruction_Verify_InstanceData((void*)inPlaceHolder); - + placeHolder = TMiConstruction_DataPtr_PlaceHolder_Get((void*)inPlaceHolder); - + UUmAssert(!TMmPlaceHolder_IsPtr(placeHolder)); index = TMiPlaceHolder_GetIndex(placeHolder); @@ -249,9 +249,9 @@ TMiPlaceHolder_GetInstanceDesc( instanceDesc = TMgConstruction_InstanceDescriptors + index; } - + TMmConstruction_Verify_InstanceDesc(instanceDesc); - + return instanceDesc; } @@ -261,30 +261,30 @@ TMiConstruction_Remap_Recursive( UUtUns8* *ioDataPtr, UUtUns32* inRemapArray) { - + UUtBool stop; UUtUns8* curSwapCode; UUtUns8* curDataPtr; char swapCode; - + TMtPlaceHolder targetPlaceHolder; TMtInstanceDescriptor* targetInstanceDesc; - + UUtUns8* origSwapCode; UUtUns32 count; UUtUns32 i; - + //UUmAssert(gInGame == UUcFalse); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: @@ -294,35 +294,35 @@ TMiConstruction_Remap_Recursive( case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiConstruction_Remap_Recursive( &curSwapCode, &curDataPtr, inRemapArray); } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -335,18 +335,18 @@ TMiConstruction_Remap_Recursive( count = (*(UUtUns32 *)curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = (*(UUtUns16 *)curDataPtr); curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(count == 0) { TMrUtility_SkipVarArray( @@ -357,7 +357,7 @@ TMiConstruction_Remap_Recursive( for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiConstruction_Remap_Recursive( &curSwapCode, &curDataPtr, @@ -365,23 +365,23 @@ TMiConstruction_Remap_Recursive( } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: - + targetInstanceDesc = NULL; targetPlaceHolder = *(TMtPlaceHolder*)curDataPtr; - + if(targetPlaceHolder != 0) { if(TMmPlaceHolder_IsPtr(targetPlaceHolder)) { TMiPlaceHolder_EnsureIndex((TMtPlaceHolder*)curDataPtr); // This maps it to the correct index targetPlaceHolder = *(TMtPlaceHolder*)curDataPtr; - + targetInstanceDesc = TMgConstruction_InstanceDescriptors + TMmPlaceHolder_GetIndex(targetPlaceHolder); } else @@ -389,18 +389,18 @@ TMiConstruction_Remap_Recursive( //targetPlaceHolder is an index and needs to be remapped UUtUns32 originalIndex = TMmPlaceHolder_GetIndex(targetPlaceHolder); UUtUns32 remappedIndex = inRemapArray[originalIndex]; - + if(remappedIndex != UUcMaxUns32) { UUmAssert(remappedIndex < TMgConstruction_NumInstanceDescriptors); - + *(TMtPlaceHolder*)curDataPtr = TMmPlaceHolder_MakeFromIndex(remappedIndex); } else { UUmAssert(0); } - + targetInstanceDesc = TMgConstruction_InstanceDescriptors + remappedIndex; } } @@ -409,16 +409,16 @@ TMiConstruction_Remap_Recursive( { UUmAssert(*(TMtTemplateTag*)curSwapCode == targetInstanceDesc->templatePtr->tag); } - + curSwapCode += 4; curDataPtr += 4; break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; } @@ -436,58 +436,58 @@ TMiConstruction_CheckExists_Recursive( UUtUns32 count; UUtUns8 *origSwapCode; UUtBool result; - + UUmAssert(NULL != ioSwapCode); UUmAssert(NULL != ioDataPtr); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: curDataPtr += 8; break; - + case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: - + count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + result = TMiConstruction_CheckExists_Recursive( &curSwapCode, &curDataPtr); if(result == UUcFalse) return UUcFalse; } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -495,21 +495,21 @@ TMiConstruction_CheckExists_Recursive( count = (UUtUns32) *(UUtUns64 *)curDataPtr; curDataPtr += 8; break; - + case TMcSwapCode_4Byte: count = *(UUtUns32 *)curDataPtr; curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = *(UUtUns16 *)curDataPtr; curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + if(count == 0) { TMrUtility_SkipVarArray(&curSwapCode); @@ -517,11 +517,11 @@ TMiConstruction_CheckExists_Recursive( else { origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + result = TMiConstruction_CheckExists_Recursive( &curSwapCode, &curDataPtr); @@ -529,57 +529,57 @@ TMiConstruction_CheckExists_Recursive( } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: { TMtInstanceDescriptor *targetDesc; void *targetData; - + targetData = *(void **)curDataPtr; - + if(targetData != NULL) { targetDesc = TMiPlaceHolder_GetInstanceDesc((TMtPlaceHolder)targetData); TMmConstruction_Verify_InstanceDesc(targetDesc); - + if((targetDesc->flags & TMcDescriptorFlags_Unique) && targetDesc->dataPtr == NULL) { return UUcFalse; } - + if(targetDesc->dataPtr != NULL) { UUtUns8* swapCode; UUtUns8* dataPtr; - + swapCode = targetDesc->templatePtr->swapCodes; dataPtr = targetDesc->dataPtr - TMcPreDataSize; - + result = TMiConstruction_CheckExists_Recursive( &swapCode, &dataPtr); if(result == UUcFalse) return UUcFalse; } - + } curSwapCode += 4; curDataPtr += 4; } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; - + return UUcTrue; } @@ -595,29 +595,29 @@ TMiConstruction_Compare_Recursive( UUtUns8* curDataPtrA; UUtUns8* curDataPtrB; char swapCode; - + UUtInt8 result; - + UUtUns8* origSwapCode; UUtUns32 count; UUtUns32 i; UUtUns16 startCount = 0; - + curSwapCode = *ioSwapCode; curDataPtrA = *ioDataPtrA; curDataPtrB = *ioDataPtrB; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + if(startCount > 1) inStart = UUcFalse; - + startCount++; - - + + switch(swapCode) { case TMcSwapCode_8Byte: @@ -636,30 +636,30 @@ TMiConstruction_Compare_Recursive( curDataPtrA += 4; curDataPtrB += 4; break; - + case TMcSwapCode_2Byte: if(*(UUtUns16*)curDataPtrA > *(UUtUns16*)curDataPtrB) return -1; if(*(UUtUns16*)curDataPtrA < *(UUtUns16*)curDataPtrB) return 1; curDataPtrA += 2; curDataPtrB += 2; break; - + case TMcSwapCode_1Byte: if(*(UUtUns8*)curDataPtrA > *(UUtUns8*)curDataPtrB) return -1; if(*(UUtUns8*)curDataPtrA < *(UUtUns8*)curDataPtrB) return 1; curDataPtrA += 1; curDataPtrB += 1; break; - + case TMcSwapCode_BeginArray: count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + result = TMiConstruction_Compare_Recursive( &curSwapCode, &curDataPtrA, @@ -668,11 +668,11 @@ TMiConstruction_Compare_Recursive( if(result != 0) return result; } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -691,7 +691,7 @@ TMiConstruction_Compare_Recursive( curDataPtrA += 4; curDataPtrB += 4; break; - + case TMcSwapCode_2Byte: if(*(UUtUns16*)curDataPtrA > *(UUtUns16*)curDataPtrB) return -1; if(*(UUtUns16*)curDataPtrA < *(UUtUns16*)curDataPtrB) return 1; @@ -699,13 +699,13 @@ TMiConstruction_Compare_Recursive( curDataPtrA += 2; curDataPtrB += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(count == 0) { TMrUtility_SkipVarArray( @@ -716,7 +716,7 @@ TMiConstruction_Compare_Recursive( for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + result = TMiConstruction_Compare_Recursive( &curSwapCode, &curDataPtrA, @@ -726,48 +726,48 @@ TMiConstruction_Compare_Recursive( } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: { TMtPlaceHolder targetPlaceHolderA; TMtPlaceHolder targetPlaceHolderB; TMtInstanceDescriptor* targetDescA; TMtInstanceDescriptor* targetDescB; - + targetPlaceHolderA = *(TMtPlaceHolder*)curDataPtrA; targetPlaceHolderB = *(TMtPlaceHolder*)curDataPtrB; - + if(targetPlaceHolderA == 0) return 1; if(targetPlaceHolderB == 0) return -1; - + targetDescA = TMiPlaceHolder_GetInstanceDesc(targetPlaceHolderA); targetDescB = TMiPlaceHolder_GetInstanceDesc(targetPlaceHolderB); - + if(targetDescA->dataPtr == NULL) return 1; if(targetDescB->dataPtr == NULL) return -1; - + if(targetDescA != targetDescB) { if(targetDescA->size > targetDescB->size) return -1; if(targetDescA->size < targetDescB->size) return 1; - + if(targetDescA->templatePtr < targetDescB->templatePtr) return -1; if(targetDescA->templatePtr > targetDescB->templatePtr) return 1; - + { UUtUns8* swapCode; UUtUns8* dataPtrA; UUtUns8* dataPtrB; - + swapCode = targetDescA->templatePtr->swapCodes; - + dataPtrA = targetDescA->dataPtr - TMcPreDataSize; dataPtrB = targetDescB->dataPtr - TMcPreDataSize; - + result = TMiConstruction_Compare_Recursive( &swapCode, &dataPtrA, @@ -776,22 +776,22 @@ TMiConstruction_Compare_Recursive( if(result != 0) return result; } } - + curSwapCode += 4; curDataPtrA += 4; curDataPtrB += 4; break; } - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtrA = curDataPtrA; *ioDataPtrB = curDataPtrB; - + return 0; } @@ -807,83 +807,83 @@ TMiConstruction_Clean_Recursive( UUtUns32 i; UUtUns32 count; UUtUns8 *origSwapCode; - + UUmAssert(NULL != ioSwapCode); UUmAssert(NULL != ioDataPtr); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: #if DEBUGGING_MEMORY - + *(UUtUns64*)curDataPtr = UUmMemoryBlock_Garbage; - + #endif - + curDataPtr += 8; break; - + case TMcSwapCode_4Byte: #if DEBUGGING_MEMORY - + // This is bad cause it trashes our placeholder stuff //*(UUtUns32*)curDataPtr = UUmMemoryBlock_Garbage; - + #endif - + curDataPtr += 4; break; - + case TMcSwapCode_2Byte: #if DEBUGGING_MEMORY - + *(UUtUns16*)curDataPtr = (UUtUns16)UUmMemoryBlock_Garbage; - + #endif curDataPtr += 2; break; - + case TMcSwapCode_1Byte: #if DEBUGGING_MEMORY - + *(UUtUns8*)curDataPtr = (UUtUns8)UUmMemoryBlock_Garbage; - + #endif curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: - + count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiConstruction_Clean_Recursive( &curSwapCode, &curDataPtr); - + } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -891,21 +891,21 @@ TMiConstruction_Clean_Recursive( count = (UUtUns32) *(UUtUns64 *)curDataPtr; curDataPtr += 8; break; - + case TMcSwapCode_4Byte: count = *(UUtUns32 *)curDataPtr; curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = *(UUtUns16 *)curDataPtr; curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + if(count == 0) { TMrUtility_SkipVarArray(&curSwapCode); @@ -913,42 +913,42 @@ TMiConstruction_Clean_Recursive( else { origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiConstruction_Clean_Recursive( &curSwapCode, &curDataPtr); } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: { TMtInstanceDescriptor *targetDesc; void *targetData; - + targetData = *(void **)curDataPtr; - + if(targetData != NULL) { targetDesc = TMiPlaceHolder_GetInstanceDesc((TMtPlaceHolder)targetData); TMmConstruction_Verify_InstanceDesc(targetDesc); - + if((targetDesc->flags & TMcDescriptorFlags_Unique) && targetDesc->dataPtr != NULL) { UUtUns8* swapCode; UUtUns8* dataPtr; - + swapCode = targetDesc->templatePtr->swapCodes; dataPtr = targetDesc->dataPtr - TMcPreDataSize; - + TMiConstruction_Clean_Recursive( &swapCode, &dataPtr); @@ -959,7 +959,7 @@ TMiConstruction_Clean_Recursive( { targetDesc->flags |= TMcDescriptorFlags_DeleteMe; } - + #if DEBUGGING_MEMORY { *(UUtUns32*)curDataPtr = UUmMemoryBlock_Garbage; @@ -971,12 +971,12 @@ TMiConstruction_Clean_Recursive( curDataPtr += 4; } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; } @@ -990,23 +990,23 @@ TMiConstruction_NullOutDeletedRefs( UUtUns8* curSwapCode; UUtUns8* curDataPtr; char swapCode; - + TMtInstanceDescriptor* targetDesc; TMtPlaceHolder targetPlaceHolder; - + UUtUns8* origSwapCode; UUtUns32 count; UUtUns32 i; - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: @@ -1016,34 +1016,34 @@ TMiConstruction_NullOutDeletedRefs( case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiConstruction_NullOutDeletedRefs( &curSwapCode, &curDataPtr); } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -1056,18 +1056,18 @@ TMiConstruction_NullOutDeletedRefs( count = (*(UUtUns32 *)curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = (*(UUtUns16 *)curDataPtr); curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(count == 0) { TMrUtility_SkipVarArray( @@ -1078,41 +1078,41 @@ TMiConstruction_NullOutDeletedRefs( for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiConstruction_NullOutDeletedRefs( &curSwapCode, &curDataPtr); } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: - + targetPlaceHolder = *(TMtPlaceHolder*)curDataPtr; - + if(targetPlaceHolder != 0) { targetDesc = TMiPlaceHolder_GetInstanceDesc(targetPlaceHolder); - + if(targetDesc->flags & TMcDescriptorFlags_DeleteMe) { *(void**)curDataPtr = NULL; } } - + curSwapCode += 4; curDataPtr += 4; break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; } @@ -1140,7 +1140,7 @@ TMiConstruction_Touch_Recursive_Array( curSwapCode += 1; oneTypeArray = (*(curSwapCode + 1) == TMcSwapCode_EndArray); - + if ((*curSwapCode == TMcSwapCode_8Byte) && oneTypeArray) { curDataPtr += 8 * count; @@ -1161,20 +1161,20 @@ TMiConstruction_Touch_Recursive_Array( curDataPtr += 1 * count; curSwapCode += 2; } - else + else { UUtUns8 *oldSwapCode = curSwapCode; for(i = 0; i < count; i++) { curSwapCode = oldSwapCode; - + TMiConstruction_Touch_Recursive( &curSwapCode, &curDataPtr); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; } @@ -1199,23 +1199,23 @@ TMiConstruction_Touch_Recursive_VarArray( count = (UUtUns32) (*(UUtUns64 *)curDataPtr); curDataPtr += 8; break; - + case TMcSwapCode_4Byte: count = (*(UUtUns32 *)curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = (*(UUtUns16 *)curDataPtr); curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(count == 0) { TMrUtility_SkipVarArray(&curSwapCode); @@ -1223,7 +1223,7 @@ TMiConstruction_Touch_Recursive_VarArray( else { UUtBool oneElementArray = (*(curSwapCode + 1) == TMcSwapCode_EndVarArray); - + if ((*curSwapCode == TMcSwapCode_8Byte) && oneElementArray) { curDataPtr += 8 * count; @@ -1244,12 +1244,12 @@ TMiConstruction_Touch_Recursive_VarArray( curDataPtr += 1 * count; curSwapCode += 2; } - else + else { for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiConstruction_Touch_Recursive( &curSwapCode, &curDataPtr); @@ -1270,71 +1270,71 @@ TMiConstruction_Touch_Recursive( UUtUns8 *curSwapCode; UUtUns8 swapCode; UUtUns8 *curDataPtr; - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: curDataPtr += 8; break; - + case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: TMiConstruction_Touch_Recursive_Array( &curSwapCode, &curDataPtr); break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: TMiConstruction_Touch_Recursive_VarArray( &curSwapCode, &curDataPtr); break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: { TMtInstanceDescriptor *targetDesc; void *targetData; - + targetData = *(void **)curDataPtr; - + if(targetData != NULL) { targetDesc = TMiPlaceHolder_GetInstanceDesc((TMtPlaceHolder)targetData); UUmAssert(targetDesc != NULL); TMmConstruction_Verify_InstanceDesc(targetDesc); - + if(!(targetDesc->flags & TMcDescriptorFlags_Touched)) { targetDesc->flags |= TMcDescriptorFlags_Touched; - + if(targetDesc->flags & TMcDescriptorFlags_PlaceHolder) { // Make sure a touched place holder does not get deleted @@ -1344,12 +1344,12 @@ TMiConstruction_Touch_Recursive( { UUtUns8* swapCode; UUtUns8* dataPtr; - + TMmConstruction_Verify_InstanceData(targetDesc->dataPtr); swapCode = targetDesc->templatePtr->swapCodes; dataPtr = targetDesc->dataPtr - TMcPreDataSize; - + TMiConstruction_Touch_Recursive( &swapCode, &dataPtr); @@ -1361,12 +1361,12 @@ TMiConstruction_Touch_Recursive( curDataPtr += 4; } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; } @@ -1376,9 +1376,9 @@ TMiConstruction_Verify_AllTouched( void) { UUtUns32 curDescIndex; - + TMtInstanceDescriptor* curInstDesc; - + UUtUns8* swapCodes; UUtUns8* dataPtr; @@ -1389,30 +1389,30 @@ TMiConstruction_Verify_AllTouched( { curInstDesc->flags &= (TMtDescriptorFlags)~TMcDescriptorFlags_Touched; } - + for( curDescIndex = 0, curInstDesc = TMgConstruction_InstanceDescriptors; curDescIndex < TMgConstruction_NumInstanceDescriptors; curDescIndex++, curInstDesc++) { if((curDescIndex % 500) == 0) fputc('.', stderr); - + if(curInstDesc->flags & (TMcDescriptorFlags_Unique | TMcDescriptorFlags_PlaceHolder)) { continue; } - + if(curInstDesc->dataPtr == NULL) continue; - + swapCodes = curInstDesc->templatePtr->swapCodes; dataPtr = curInstDesc->dataPtr - TMcPreDataSize; - + TMiConstruction_Touch_Recursive( &swapCodes, &dataPtr); } fputc('\n', stderr); - + for( curDescIndex = 0, curInstDesc = TMgConstruction_InstanceDescriptors; curDescIndex < TMgConstruction_NumInstanceDescriptors; @@ -1423,8 +1423,8 @@ TMiConstruction_Verify_AllTouched( //if(curInstDesc->flags & TMcDescriptorFlags_PlaceHolder) continue; UUmAssert(!(curInstDesc->flags & TMcDescriptorFlags_DeleteMe)); if(!(curInstDesc->flags & TMcDescriptorFlags_Unique)) continue; - - if(curInstDesc->flags & TMcDescriptorFlags_Touched) continue; + + if(curInstDesc->flags & TMcDescriptorFlags_Touched) continue; if (!ignore) { AUtMB_ButtonChoice button; @@ -1450,25 +1450,25 @@ TMiConstruction_DeleteUnusedInstances( TMtNameDescriptor* curNameDesc; UUtUns32* deletedRemapArray = NULL; - + UUtUns8* swapCodes; UUtUns8* dataPtr; - + UUtUns32 newInstanceIndex; - + TMtInstanceDescriptor* originalDescriptorList; - + fprintf(stderr, "Deleting unused...\n"); - + deletedRemapArray = UUrMemory_Block_New(TMgConstruction_NumInstanceDescriptors * sizeof(UUtInt32)); UUmError_ReturnOnNull(deletedRemapArray); - + UUrMemory_Set32(deletedRemapArray, UUcMaxUns32, TMgConstruction_NumInstanceDescriptors * sizeof(UUtInt32)); - + originalDescriptorList = UUrMemory_Block_New(TMgConstruction_NumInstanceDescriptors * sizeof(TMtInstanceDescriptor)); UUmError_ReturnOnNull(originalDescriptorList); - - + + UUrMemory_Block_VerifyList(); /* @@ -1480,7 +1480,7 @@ TMiConstruction_DeleteUnusedInstances( curDescIndex++, curDesc++) { TMmConstruction_Verify_InstanceDesc(curDesc); - + if(!(curDesc->flags & TMcDescriptorFlags_Touched)) { // instance has not been touched, delete it @@ -1499,7 +1499,7 @@ TMiConstruction_DeleteUnusedInstances( { swapCodes = curDesc->templatePtr->swapCodes; dataPtr = curDesc->dataPtr - TMcPreDataSize; - + TMiConstruction_Clean_Recursive( &swapCodes, &dataPtr); @@ -1508,7 +1508,7 @@ TMiConstruction_DeleteUnusedInstances( } } } - + /* * NULL out pointers to deleted instances */ @@ -1523,36 +1523,36 @@ TMiConstruction_DeleteUnusedInstances( swapCodes = curDesc->templatePtr->swapCodes; dataPtr = (UUtUns8 *)curDesc->dataPtr - TMcPreDataSize; - + TMiConstruction_NullOutDeletedRefs(&swapCodes, &dataPtr); } - - + + UUrMemory_MoveFast(TMgConstruction_InstanceDescriptors, originalDescriptorList, TMgConstruction_NumInstanceDescriptors * sizeof(TMtInstanceDescriptor)); - + /* * Compute the remap array */ newInstanceIndex = 0; - + for(curDescIndex = 0, curDesc = originalDescriptorList; curDescIndex < TMgConstruction_NumInstanceDescriptors; curDescIndex++, curDesc++) { TMmConstruction_Verify_InstanceDesc(curDesc); - + if(!(curDesc->flags & TMcDescriptorFlags_DeleteMe)) { TMgConstruction_InstanceDescriptors[newInstanceIndex] = *curDesc; deletedRemapArray[curDescIndex] = newInstanceIndex++; continue; } - + if(curDesc->namePtr == NULL) { continue; } - + /* we must delete the name descriptor */ for(curNameDescIndex = 0, curNameDesc = TMgConstruction_NameDescriptors; curNameDescIndex < TMgConstruction_NumNameDescriptors; @@ -1561,18 +1561,18 @@ TMiConstruction_DeleteUnusedInstances( if(curNameDesc->instanceDescIndex == curDescIndex) { UUmAssert(strcmp(curNameDesc->namePtr, curDesc->namePtr) == 0); - + UUrMemory_MoveOverlap( TMgConstruction_NameDescriptors + curNameDescIndex + 1, TMgConstruction_NameDescriptors + curNameDescIndex, (TMgConstruction_NumNameDescriptors - curNameDescIndex) * sizeof(TMtNameDescriptor)); - + TMgConstruction_NumNameDescriptors--; break; } } } - + for(curDescIndex = 0, curDesc = originalDescriptorList; curDescIndex < TMgConstruction_NumInstanceDescriptors; curDescIndex++, curDesc++) @@ -1581,16 +1581,16 @@ TMiConstruction_DeleteUnusedInstances( { TMtInstanceDescriptor* originalDesc = originalDescriptorList + curDescIndex; TMtInstanceDescriptor* newDesc = TMgConstruction_InstanceDescriptors + deletedRemapArray[curDescIndex]; - + UUmAssert(originalDesc->templatePtr == newDesc->templatePtr); UUmAssert(originalDesc->dataPtr == newDesc->dataPtr); - } + } } - + TMgConstruction_NumInstanceDescriptors = newInstanceIndex; UUrMemory_Block_VerifyList(); - + /* * Remap the name descriptor indices */ @@ -1600,13 +1600,13 @@ TMiConstruction_DeleteUnusedInstances( { curNameDesc->instanceDescIndex = deletedRemapArray[curNameDesc->instanceDescIndex]; UUmAssert(curNameDesc->instanceDescIndex < TMgConstruction_NumInstanceDescriptors); - + UUmAssert(TMgConstruction_InstanceDescriptors[curNameDesc->instanceDescIndex].namePtr != NULL); UUmAssert(strcmp( TMgConstruction_InstanceDescriptors[curNameDesc->instanceDescIndex].namePtr, curNameDesc->namePtr) == 0); } - + /* * update the place holder data */ @@ -1615,13 +1615,13 @@ TMiConstruction_DeleteUnusedInstances( curDescIndex++, curDesc++) { if(curDesc->dataPtr == NULL) continue; - + TMiConstruction_DataPtr_PlaceHolder_Set( curDesc->dataPtr, TMiPlaceHolder_MakeFromIndex(curDescIndex)); //OLD - TMmInstanceData_GetPlaceHolder(curDesc->dataPtr) = TMmPlaceHolder_MakeFromIndex(curDescIndex); } - + /* * update the place holder data and apply the remap */ @@ -1630,18 +1630,18 @@ TMiConstruction_DeleteUnusedInstances( curDescIndex++, curDesc++) { if(curDesc->dataPtr == NULL) continue; - + swapCodes = curDesc->templatePtr->swapCodes; dataPtr = curDesc->dataPtr - TMcPreDataSize; - + TMiConstruction_Remap_Recursive(&swapCodes, &dataPtr, deletedRemapArray); } - + UUrMemory_Block_Delete(deletedRemapArray); UUrMemory_Block_Delete(originalDescriptorList); - + UUrMemory_Block_VerifyList(); - + return UUcError_None; } @@ -1655,33 +1655,33 @@ TMiConstruction_RemoveIdentical_Compare( { TMtInstanceDescriptor* instanceDescA = TMgConstruction_InstanceDescriptors + inA; TMtInstanceDescriptor* instanceDescB = TMgConstruction_InstanceDescriptors + inB; - + UUmAssert(instanceDescA->templatePtr == instanceDescB->templatePtr); - + if(TMgCompare_TemplateIndex != UUcMaxUns32) { UUtInt32 extIndex = instanceDescA->templatePtr - TMgTemplateDefinitionArray; - + UUmAssert(TMgCompare_TemplateIndex == (UUtUns32)extIndex); } - + // first compare based on size if(instanceDescA->size > instanceDescB->size) return -1; if(instanceDescA->size < instanceDescB->size) return 1; - + if(instanceDescA->dataPtr == NULL) return 1; if(instanceDescB->dataPtr == NULL) return -1; - + // next compare based on value of the data { UUtUns8* swapCode; UUtUns8* dataPtrA; UUtUns8* dataPtrB; - + swapCode = instanceDescA->templatePtr->swapCodes; dataPtrA = instanceDescA->dataPtr - TMcPreDataSize; dataPtrB = instanceDescB->dataPtr - TMcPreDataSize; - + return TMiConstruction_Compare_Recursive(&swapCode, &dataPtrA, &dataPtrB, UUcTrue); } } @@ -1702,7 +1702,7 @@ TMiDumpStats_Compare_InstanceCount( UUtUns32 inB) { UUmAssertReadPtr(gTemplateConstructionList, sizeof(TMtTemplateDescriptor)); - + if(gTemplateConstructionList[inA].numInstancesUsed >= gTemplateConstructionList[inB].numInstancesUsed) return 0; return 1; @@ -1714,7 +1714,7 @@ TMiDumpStats_Compare_MemSize( UUtUns32 inB) { UUmAssertReadPtr(gTemplateConstructionList, sizeof(TMtTemplateDescriptor)); - + if(gTemplateConstructionList[inA].totalSizeOfAllInstances >= gTemplateConstructionList[inB].totalSizeOfAllInstances) return 0; return 1; @@ -1726,7 +1726,7 @@ TMiDumpStats_Compare_NumRemoved( UUtUns32 inB) { UUmAssertReadPtr(gTemplateConstructionList, sizeof(TMtTemplateDescriptor)); - + if(gTemplateConstructionList[inA].numInstancesRemoved >= gTemplateConstructionList[inB].numInstancesRemoved) return 0; return 1; @@ -1738,7 +1738,7 @@ TMiConstruction_RemoveIdentical( { TMtTemplate_ConstructionData* curTemplateData; UUtUns32 curTemplateDataIndex; - + UUtUns32 curInstanceIndex; UUtUns32 targetCheckInstanceIndex; UUtUns32 curInstanceIndexItr; @@ -1747,83 +1747,83 @@ TMiConstruction_RemoveIdentical( TMtInstanceDescriptor* targetCheckInstance; UUtUns32* duplicateRemapArray; TMtTemplate_ConstructionData* templateConstructionData; - + UUtUns32 numTemplateDescriptors = 0; - + UUtUns32 numTotalInstancesRemoved = 0; UUtUns32 totalRemovedSize = 0; - + UUtUns32 numNewInstances; - + UUtUns32 curNameDescIndex; TMtNameDescriptor* curNameDesc; - + TMtInstanceDescriptor* originalDescriptorList; UUtUns32* originalDuplicateIndexArray; - + UUtUns32* templateInstanceIndexMemory; UUtUns32* curTemplateInstanceIndexMem; - + fprintf(stderr, "Removing identical...\n"); - + duplicateRemapArray = UUrMemory_Block_New(TMgConstruction_NumInstanceDescriptors * sizeof(UUtInt32)); UUmError_ReturnOnNull(duplicateRemapArray); - + UUrMemory_Set32(duplicateRemapArray, UUcMaxUns32, TMgConstruction_NumInstanceDescriptors * sizeof(UUtUns32)); - + templateConstructionData = UUrMemory_Block_NewClear(TMgNumTemplateDefinitions * sizeof(TMtTemplate_ConstructionData)); UUmError_ReturnOnNull(templateConstructionData); - + UUmAssertReadPtr(TMgConstruction_DuplicateIndexArray, sizeof(UUtUns32)); - + UUrMemory_Set32(TMgConstruction_DuplicateIndexArray, UUcMaxUns32, TMgConstruction_NumInstanceDescriptors * sizeof(UUtUns32)); - + originalDescriptorList = UUrMemory_Block_New(TMgConstruction_NumInstanceDescriptors * sizeof(TMtInstanceDescriptor)); UUmError_ReturnOnNull(originalDescriptorList); - + originalDuplicateIndexArray = UUrMemory_Block_New(TMgConstruction_NumInstanceDescriptors * sizeof(UUtUns32)); UUmError_ReturnOnNull(originalDuplicateIndexArray); - + // Build the template construction data for(curInstanceIndex = 0, curInstanceDesc = TMgConstruction_InstanceDescriptors; curInstanceIndex < TMgConstruction_NumInstanceDescriptors; curInstanceIndex++, curInstanceDesc++) { UUtInt32 templateIndex = curInstanceDesc->templatePtr - TMgTemplateDefinitionArray; - + UUmAssert(templateIndex >= 0); UUmAssert(templateIndex < (UUtInt32)TMgNumTemplateDefinitions); templateConstructionData[templateIndex].totalSizeOfAllInstances += curInstanceDesc->size; - + templateConstructionData[templateIndex].numInstancesUsed++; } - + templateInstanceIndexMemory = curTemplateInstanceIndexMem = UUrMemory_Block_New(TMgConstruction_NumInstanceDescriptors * sizeof(UUtUns32)); UUmError_ReturnOnNull(templateInstanceIndexMemory); - + for(curTemplateDataIndex = 0, curTemplateData = templateConstructionData; curTemplateDataIndex < TMgNumTemplateDefinitions; curTemplateDataIndex++, curTemplateData++) { curTemplateData->instanceIndexList = curTemplateInstanceIndexMem; - + curTemplateInstanceIndexMem += curTemplateData->numInstancesUsed; } - + for(curInstanceIndex = 0, curInstanceDesc = TMgConstruction_InstanceDescriptors; curInstanceIndex < TMgConstruction_NumInstanceDescriptors; curInstanceIndex++, curInstanceDesc++) { UUtInt32 templateIndex = curInstanceDesc->templatePtr - TMgTemplateDefinitionArray; - + curTemplateData = templateConstructionData + templateIndex; - + UUmAssert(curTemplateData->nextInstanceIndex < curTemplateData->numInstancesUsed); - + curTemplateData->instanceIndexList[curTemplateData->nextInstanceIndex++] = curInstanceIndex; } - + for(curTemplateDataIndex = 0, curTemplateData = templateConstructionData; curTemplateDataIndex < TMgNumTemplateDefinitions; curTemplateDataIndex++, curTemplateData++) @@ -1832,32 +1832,32 @@ TMiConstruction_RemoveIdentical( } UUrMemory_Block_VerifyList(); - + fprintf(stderr, "\tSorting each template type"); - + // Sort the instances for each template type for(curTemplateDataIndex = 0, curTemplateData = templateConstructionData; curTemplateDataIndex < TMgNumTemplateDefinitions; curTemplateDataIndex++, curTemplateData++) { if((curTemplateDataIndex % 10) == 0) fprintf(stderr, "."); - + if(curTemplateData->nextInstanceIndex > 0) numTemplateDescriptors++; - + if(curTemplateData->nextInstanceIndex <= 1) continue; - + TMgCompare_TemplateIndex = curTemplateDataIndex; - + AUrQSort_32( curTemplateData->instanceIndexList, curTemplateData->nextInstanceIndex, TMiConstruction_RemoveIdentical_Compare_QSort); - + TMgCompare_TemplateIndex = UUcMaxUns32; } - + fprintf(stderr, "\n\tLooking for duplicates"); - + // now look for duplicates for(curTemplateDataIndex = 0, curTemplateData = templateConstructionData; curTemplateDataIndex < TMgNumTemplateDefinitions; @@ -1867,7 +1867,7 @@ TMiConstruction_RemoveIdentical( if(curTemplateData->nextInstanceIndex == 0) continue; if(!(TMgTemplateDefinitionArray[curTemplateDataIndex].flags & TMcTemplateFlag_AllowFolding)) continue; - + TMgCompare_TemplateIndex = curTemplateDataIndex; // go through the indices comparing the current one to the subsequent ones looking for identical instances @@ -1877,67 +1877,67 @@ TMiConstruction_RemoveIdentical( targetCheckInstanceIndexItr = curInstanceIndexItr; targetCheckInstanceIndex = curTemplateData->instanceIndexList[targetCheckInstanceIndexItr]; targetCheckInstance = TMgConstruction_InstanceDescriptors + targetCheckInstanceIndex; - + // make sure the target is not already a duplicate UUmAssert(!(targetCheckInstance->flags & TMcDescriptorFlags_Duplicate)); while(++curInstanceIndexItr < curTemplateData->nextInstanceIndex) { curInstanceIndex = curTemplateData->instanceIndexList[curInstanceIndexItr]; - + if(TMiConstruction_RemoveIdentical_Compare( targetCheckInstanceIndex, curInstanceIndex) != 0) break; - + // we have an identical instance - + // make sure it has not beeing assigned a target instance already UUmAssert(TMgConstruction_DuplicateIndexArray[curInstanceIndex] == UUcMaxUns32); - + // assign this instance a source(target) TMgConstruction_DuplicateIndexArray[curInstanceIndex] = targetCheckInstanceIndex; // This needs to get remaped later - + // Mark the target instance as a source targetCheckInstance->flags |= TMcDescriptorFlags_DuplicatedSrc; - + // make sure the source is not a duplicate itself UUmAssert(!(targetCheckInstance->flags & TMcDescriptorFlags_Duplicate)); - + curInstanceDesc = TMgConstruction_InstanceDescriptors + curInstanceIndex; - + // make sure this instance is not a source - because it is a duplicate UUmAssert(!(curInstanceDesc->flags & TMcDescriptorFlags_DuplicatedSrc)); - + // mark this instance as being a duplicate curInstanceDesc->flags |= TMcDescriptorFlags_Duplicate; - + // update some stats curTemplateData->numInstancesRemoved++; numTotalInstancesRemoved++; - + curTemplateData->removedSize += curInstanceDesc->size; - + totalRemovedSize += curInstanceDesc->size; - + UUmAssert(curTemplateData->numInstancesUsed > 0); UUmAssert(curTemplateData->totalSizeOfAllInstances > curInstanceDesc->size); - + curTemplateData->numInstancesUsed--; curTemplateData->totalSizeOfAllInstances -= curInstanceDesc->size; } } TMgCompare_TemplateIndex = UUcMaxUns32; } - + fprintf(stderr, "\n"); fprintf(stderr, "\tRemapping"); UUrMemory_MoveFast(TMgConstruction_DuplicateIndexArray, originalDuplicateIndexArray, TMgConstruction_NumInstanceDescriptors * sizeof(UUtUns32)); UUrMemory_MoveFast(TMgConstruction_InstanceDescriptors, originalDescriptorList, TMgConstruction_NumInstanceDescriptors * sizeof(TMtInstanceDescriptor)); - + // compute the remap array and move the structures numNewInstances = 0; - + for(curInstanceIndex = 0, curInstanceDesc = originalDescriptorList; curInstanceIndex < TMgConstruction_NumInstanceDescriptors; curInstanceIndex++, curInstanceDesc++) @@ -1952,7 +1952,7 @@ TMiConstruction_RemoveIdentical( { UUmAssert(originalDuplicateIndexArray[curInstanceIndex] == UUcMaxUns32); } - + if(!(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate) || curInstanceDesc->dataPtr == NULL || curInstanceDesc->namePtr != NULL) { TMgConstruction_DuplicateIndexArray[numNewInstances] = originalDuplicateIndexArray[curInstanceIndex]; @@ -1963,7 +1963,7 @@ TMiConstruction_RemoveIdentical( { UUmAssert(originalDuplicateIndexArray[curInstanceIndex] < TMgConstruction_NumInstanceDescriptors); } - + } @@ -1973,27 +1973,27 @@ TMiConstruction_RemoveIdentical( curInstanceIndex++, curInstanceDesc++) { UUtUns32 remappedInstanceIndex = duplicateRemapArray[curInstanceIndex]; - + if((curInstanceIndex % 1000) == 0) fprintf(stderr, "."); if(remappedInstanceIndex == UUcMaxUns32) { // curInstanceIndex is being deleted - + // make sure it has a duplicate UUmAssert(originalDuplicateIndexArray[curInstanceIndex] < TMgConstruction_NumInstanceDescriptors); - + targetCheckInstance = originalDescriptorList + originalDuplicateIndexArray[curInstanceIndex]; - + // make sure that the duplicate flag is set UUmAssert(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate); - + // make sure its source is marked UUmAssert(targetCheckInstance->flags & TMcDescriptorFlags_DuplicatedSrc); - + // make sure it should really be deleted UUmAssert(curInstanceDesc->namePtr == NULL); - + // this deleted instance need to point to the duplicate source duplicateRemapArray[curInstanceIndex] = duplicateRemapArray[originalDuplicateIndexArray[curInstanceIndex]]; UUmAssert(duplicateRemapArray[curInstanceIndex] < numNewInstances); @@ -2001,32 +2001,32 @@ TMiConstruction_RemoveIdentical( else { // curInstanceIndex is not being deleted - + // make sure it is legal UUmAssert(remappedInstanceIndex < numNewInstances); - + // if it is a duplicate then set its dataPtr to NULL if(originalDuplicateIndexArray[curInstanceIndex] != UUcMaxUns32) { UUmAssert(originalDuplicateIndexArray[curInstanceIndex] < TMgConstruction_NumInstanceDescriptors); - + // curInstanceIndex is a duplicate and it is not being deleted // screwing up tests - curInstanceDesc->dataPtr = NULL; // This gets remapped to the duplicate data later } } - + if(originalDuplicateIndexArray[curInstanceIndex] != UUcMaxUns32) { // curInstanceDesc has a duplicate - + targetCheckInstance = originalDescriptorList + originalDuplicateIndexArray[curInstanceIndex]; // make sure it is legal UUmAssert(originalDuplicateIndexArray[curInstanceIndex] < TMgConstruction_NumInstanceDescriptors); - + // make sure its dupicate it not being deleted UUmAssert(duplicateRemapArray[originalDuplicateIndexArray[curInstanceIndex]] != UUcMaxUns32); - + UUmAssert(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate); // make sure its source is marked @@ -2035,13 +2035,13 @@ TMiConstruction_RemoveIdentical( else { // curInstanceDesc does not have a duplicate - + UUmAssert(!(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate)); } } - + TMgConstruction_NumInstanceDescriptors = numNewInstances; - + fprintf(stderr, "\n"); fprintf(stderr, "\tUpdating place holders"); @@ -2055,21 +2055,21 @@ TMiConstruction_RemoveIdentical( if(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate) { UUmAssert(TMgConstruction_DuplicateIndexArray[curInstanceIndex] != UUcMaxUns32); - + TMgConstruction_DuplicateIndexArray[curInstanceIndex] = duplicateRemapArray[TMgConstruction_DuplicateIndexArray[curInstanceIndex]]; - + UUmAssert(TMgConstruction_DuplicateIndexArray[curInstanceIndex] < TMgConstruction_NumInstanceDescriptors); - + } else { UUmAssert(TMgConstruction_DuplicateIndexArray[curInstanceIndex] == UUcMaxUns32); } - + if(curInstanceDesc->dataPtr == NULL) continue; - + } - + fprintf(stderr, "\n\tRemapping instance data"); // remap everthing @@ -2083,19 +2083,19 @@ TMiConstruction_RemoveIdentical( { UUtUns8* swapCode; UUtUns8* dataPtr; - + TMiConstruction_DataPtr_PlaceHolder_Set( curInstanceDesc->dataPtr, TMiPlaceHolder_MakeFromIndex(curInstanceIndex)); - + swapCode = curInstanceDesc->templatePtr->swapCodes; dataPtr = curInstanceDesc->dataPtr - TMcPreDataSize; - + TMiConstruction_Remap_Recursive(&swapCode, &dataPtr, duplicateRemapArray); } } - + // do some more verifing for(curInstanceIndex = 0, curInstanceDesc = TMgConstruction_InstanceDescriptors; curInstanceIndex < TMgConstruction_NumInstanceDescriptors; @@ -2104,12 +2104,12 @@ TMiConstruction_RemoveIdentical( if(TMgConstruction_DuplicateIndexArray[curInstanceIndex] != UUcMaxUns32) { // curInstanceDesc has a duplicate - + targetCheckInstance = TMgConstruction_InstanceDescriptors + TMgConstruction_DuplicateIndexArray[curInstanceIndex]; // make sure it is legal UUmAssert(TMgConstruction_DuplicateIndexArray[curInstanceIndex] < TMgConstruction_NumInstanceDescriptors); - + UUmAssert(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate); // make sure its source is marked @@ -2118,20 +2118,20 @@ TMiConstruction_RemoveIdentical( else { // curInstanceDesc does not have a duplicate - + UUmAssert(!(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate)); } } - + // now remap the name descriptor array for(curNameDescIndex = 0, curNameDesc = TMgConstruction_NameDescriptors; curNameDescIndex < TMgConstruction_NumNameDescriptors; curNameDescIndex++, curNameDesc++) { UUtUns32 remapedIndex = duplicateRemapArray[curNameDesc->instanceDescIndex]; - + UUmAssert(remapedIndex < TMgConstruction_NumInstanceDescriptors); - + UUmAssert(TMgConstruction_InstanceDescriptors[remapedIndex].namePtr != NULL); UUmAssert(strcmp( TMgConstruction_InstanceDescriptors[remapedIndex].namePtr, @@ -2152,66 +2152,66 @@ TMiConstruction_RemoveIdentical( fprintf(stderr, "\nnum instances saved: %d\n", numTotalInstancesRemoved); fprintf(stderr, "size saved: %d\n", totalRemovedSize); - + UUrMemory_Block_Delete(duplicateRemapArray); TMgConstruction_NumTemplateDescriptors = numTemplateDescriptors; - + if(TMgConstruction_TemplateDescriptors != NULL) { UUrMemory_Block_Delete(TMgConstruction_TemplateDescriptors); } - + TMgConstruction_TemplateDescriptors = UUrMemory_Block_New(numTemplateDescriptors * sizeof(TMtTemplateDescriptor)); numTemplateDescriptors = 0; - + for(curTemplateDataIndex = 0, curTemplateData = templateConstructionData; curTemplateDataIndex < TMgNumTemplateDefinitions; curTemplateDataIndex++, curTemplateData++) { if(curTemplateData->numInstancesUsed == 0) continue; - + TMgConstruction_TemplateDescriptors[numTemplateDescriptors].checksum = TMgTemplateDefinitionArray[curTemplateDataIndex].checksum; TMgConstruction_TemplateDescriptors[numTemplateDescriptors].tag = TMgTemplateDefinitionArray[curTemplateDataIndex].tag; TMgConstruction_TemplateDescriptors[numTemplateDescriptors].numUsed = curTemplateData->numInstancesUsed; numTemplateDescriptors++; } - + { UUtUns32 curDescIndex; UUtUns32* sortedList; FILE* file; char instanceFileName[BFcMaxFileNameLength]; char fileName[BFcMaxFileNameLength]; - + UUrString_Copy(instanceFileName, BFrFileRef_GetLeafName(TMgConstruction_FileRef), BFcMaxFileNameLength); UUrString_StripExtension(instanceFileName); - + sprintf(fileName, "%s_stats.txt", instanceFileName); - + file = fopen(fileName, "w"); - + if(file != NULL) { { UUtUns32 raw_itr; fprintf(file, "raw stats:\n"); - + AUrQSort_32( - TMgRawTrackingList, - TMgRawTrackingCount, + TMgRawTrackingList, + TMgRawTrackingCount, TMrRawTrackingCompare); for(raw_itr = 0; raw_itr < TMgRawTrackingCount; raw_itr++) { TMtRawTracking *tracking_ptr = AUrHashTable_Find(TMgRawTrackingHashTable, TMgRawTrackingList + raw_itr); - fprintf(file, "\t %c%c%c%c = %d/%d\n", - (tracking_ptr->identifier >> 24) & 0xff, - (tracking_ptr->identifier >> 16) & 0xff, - (tracking_ptr->identifier >> 8) & 0xff, - (tracking_ptr->identifier >> 0) & 0xff, + fprintf(file, "\t %c%c%c%c = %d/%d\n", + (tracking_ptr->identifier >> 24) & 0xff, + (tracking_ptr->identifier >> 16) & 0xff, + (tracking_ptr->identifier >> 8) & 0xff, + (tracking_ptr->identifier >> 0) & 0xff, tracking_ptr->raw_count, tracking_ptr->separate_count); } @@ -2220,10 +2220,10 @@ TMiConstruction_RemoveIdentical( } gTemplateConstructionList = templateConstructionData; - + sortedList = UUrMemory_Block_New(TMgNumTemplateDefinitions * sizeof(UUtUns32)); UUmError_ReturnOnNull(sortedList); - + for(curDescIndex = 0; curDescIndex < TMgNumTemplateDefinitions; curDescIndex++) { sortedList[curDescIndex] = curDescIndex; @@ -2242,7 +2242,7 @@ TMiConstruction_RemoveIdentical( UUtInt32 templateDefIndex = sortedList[curDescIndex]; TMtTemplate_ConstructionData* curTemplateData = templateConstructionData + templateDefIndex; TMtTemplateDefinition* templateDef = TMgTemplateDefinitionArray + templateDefIndex; - + if(curTemplateData->numInstancesUsed == 0) continue; total_instances_used += curTemplateData->numInstancesUsed; @@ -2258,7 +2258,7 @@ TMiConstruction_RemoveIdentical( fprintf(file, "\tMemory Saved: %d\n", total_memory_saved); fprintf(file, "\t*******************************\n"); } - + AUrQSort_32( sortedList, TMgNumTemplateDefinitions, @@ -2272,7 +2272,7 @@ TMiConstruction_RemoveIdentical( UUtInt32 templateDefIndex = sortedList[curDescIndex]; TMtTemplate_ConstructionData* curTemplateData = templateConstructionData + templateDefIndex; TMtTemplateDefinition* templateDef = TMgTemplateDefinitionArray + templateDefIndex; - + if(curTemplateData->numInstancesUsed == 0) continue; fprintf(file, "\tName: %s\n", templateDef->name); @@ -2287,20 +2287,20 @@ TMiConstruction_RemoveIdentical( fprintf(file, "\tMemory Saved: %d\n", curTemplateData->removedSize); fprintf(file, "\t*******************************\n"); } - + for(curDescIndex = 0; curDescIndex < TMgNumTemplateDefinitions; curDescIndex++) { sortedList[curDescIndex] = curDescIndex; } - + AUrQSort_32( sortedList, TMgNumTemplateDefinitions, TMiDumpStats_Compare_InstanceCount); - + fprintf(file, "Instance file dump\n"); fprintf(file, "fileName: %s\n", BFrFileRef_GetLeafName(TMgConstruction_FileRef)); - + fprintf(file, "Template descriptor list(sorted by instance count)\n"); for(curDescIndex = 0; curDescIndex < TMgNumTemplateDefinitions; @@ -2309,9 +2309,9 @@ TMiConstruction_RemoveIdentical( UUtInt32 templateDefIndex = sortedList[curDescIndex]; TMtTemplate_ConstructionData* curTemplateData = templateConstructionData + templateDefIndex; TMtTemplateDefinition* templateDef = TMgTemplateDefinitionArray + templateDefIndex; - + if(curTemplateData->numInstancesUsed == 0) continue; - + fprintf(file, "\tName: %s\n", templateDef->name); fprintf(file, "\tTag: %c%c%c%c\n", (templateDef->tag >> 24) & 0xFF, @@ -2324,12 +2324,12 @@ TMiConstruction_RemoveIdentical( fprintf(file, "\tMemory Saved: %d\n", curTemplateData->removedSize); fprintf(file, "\t*******************************\n"); } - + for(curDescIndex = 0; curDescIndex < TMgNumTemplateDefinitions; curDescIndex++) { sortedList[curDescIndex] = curDescIndex; } - + AUrQSort_32( sortedList, TMgNumTemplateDefinitions, @@ -2343,9 +2343,9 @@ TMiConstruction_RemoveIdentical( UUtInt32 templateDefIndex = sortedList[curDescIndex]; TMtTemplate_ConstructionData* curTemplateData = templateConstructionData + templateDefIndex; TMtTemplateDefinition* templateDef = TMgTemplateDefinitionArray + templateDefIndex; - + if(curTemplateData->numInstancesUsed == 0) continue; - + fprintf(file, "\tName: %s\n", templateDef->name); fprintf(file, "\tTag: %c%c%c%c\n", (templateDef->tag >> 24) & 0xFF, @@ -2358,18 +2358,18 @@ TMiConstruction_RemoveIdentical( fprintf(file, "\tMemory Saved: %d\n", curTemplateData->removedSize); fprintf(file, "\t*******************************\n"); } - + fclose(file); - + UUrMemory_Block_Delete(sortedList); } } - + UUrMemory_Block_Delete(templateConstructionData); UUrMemory_Block_Delete(originalDuplicateIndexArray); UUrMemory_Block_Delete(originalDescriptorList); UUrMemory_Block_Delete(templateInstanceIndexMemory); - + return UUcError_None; } @@ -2398,62 +2398,62 @@ TMiConstruction_Save( { UUtError error; BFtFile* instancePhysicalFile; - + UUtUns32 curDescIndex; TMtInstanceDescriptor* curDesc; - + UUtUns32 curDataFilePos; UUtUns32 curNameFilePos; - + UUtUns32 curDataOffset; UUtUns32 curNameOffset; - + UUtUns32 curNameLen; - + TMtTemplateDefinition* templateDefinition; - + TMtInstanceFile_Header fileHeader; - + UUmAssertReadPtr(TMgConstruction_FileRef, sizeof(UUtUns32)); - + UUrMemory_Block_VerifyList(); - + if(TMgConstruction_NumInstanceDescriptors == 0) { return UUcError_None; } - + if(TMgConstruction_DuplicateIndexArray != NULL) { UUrMemory_Block_Delete(TMgConstruction_DuplicateIndexArray); TMgConstruction_DuplicateIndexArray = NULL; } - + TMgConstruction_DuplicateIndexArray = UUrMemory_Block_New(TMgConstruction_NumInstanceDescriptors * sizeof(UUtUns32)); UUmError_ReturnOnNull(TMgConstruction_DuplicateIndexArray); - + // delete unused instances error = TMiConstruction_DeleteUnusedInstances(); UUmError_ReturnOnError(error); - + /* * Remove identical instance */ error = TMiConstruction_RemoveIdentical(); UUmError_ReturnOnError(error); - + /* - * Prepare all instances for disk + * Prepare all instances for disk */ for(curDescIndex = 0, curDesc = TMgConstruction_InstanceDescriptors; curDescIndex < TMgConstruction_NumInstanceDescriptors; curDescIndex++, curDesc++) { templateDefinition = curDesc->templatePtr; - + curDesc->templatePtr = (void*)templateDefinition->tag; } - + UUrMemory_Block_VerifyList(); /* @@ -2467,43 +2467,43 @@ TMiConstruction_Save( * Delete any old instance file */ BFrFile_Delete(TMgConstruction_FileRef); - + error = BFrFile_Create(TMgConstruction_FileRef); UUmError_ReturnOnErrorMsg(error, "Could create instance file"); - + /* * open the instance files for writing */ error = BFrFile_Open(TMgConstruction_FileRef, "w", &instancePhysicalFile); UUmError_ReturnOnErrorMsg(error, "Could not open instance file for writing"); - + /* * Calculate the new file header */ fileHeader.version = TMcInstanceFile_Version; - + fileHeader.sizeofHeader = sizeof(TMtInstanceFile_Header); fileHeader.sizeofInstanceDescriptor = sizeof(TMtInstanceDescriptor); fileHeader.sizeofTemplateDescriptor = sizeof(TMtTemplateDescriptor); fileHeader.sizeofNameDescriptor = sizeof(TMtNameDescriptor); - + fileHeader.totalTemplateChecksum = TMgTemplateChecksum; fileHeader.numInstanceDescriptors = TMgConstruction_NumInstanceDescriptors; fileHeader.numNameDescriptors = TMgConstruction_NumNameDescriptors; fileHeader.numTemplateDescriptors = TMgConstruction_NumTemplateDescriptors; fileHeader.dataBlockOffset = - sizeof(TMtInstanceFile_Header) + - fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + + sizeof(TMtInstanceFile_Header) + + fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + fileHeader.numNameDescriptors * sizeof(TMtNameDescriptor) + fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor); fileHeader.dataBlockOffset = UUmMakeMultipleCacheLine(fileHeader.dataBlockOffset); - + /* * Write out the instance data and compute the new offsets */ curDataOffset = 0; curDataFilePos = fileHeader.dataBlockOffset; - + for(curDescIndex = 0, curDesc = TMgConstruction_InstanceDescriptors; curDescIndex < TMgConstruction_NumInstanceDescriptors; curDescIndex++, curDesc++) @@ -2512,11 +2512,11 @@ TMiConstruction_Save( { continue; } - + TMiConstruction_DataPtr_InstanceFileID_Set( curDesc->dataPtr, TMgConstruction_InstanceFileID); - + // First write the data to the new offset error = BFrFile_WritePos( @@ -2530,7 +2530,7 @@ TMiConstruction_Save( curDataOffset += curDesc->size; curDataFilePos += curDesc->size; } - + for(curDescIndex = 0, curDesc = TMgConstruction_InstanceDescriptors; curDescIndex < TMgConstruction_NumInstanceDescriptors; curDescIndex++, curDesc++) @@ -2540,14 +2540,14 @@ TMiConstruction_Save( curDesc->dataPtr = TMgConstruction_InstanceDescriptors[TMgConstruction_DuplicateIndexArray[curDescIndex]].dataPtr; } } - + UUrMemory_Block_VerifyList(); fileHeader.dataBlockLength = curDataOffset; - + curNameOffset = 0; fileHeader.nameBlockOffset = curNameFilePos = curDataFilePos; - + for(curDescIndex = 0, curDesc = TMgConstruction_InstanceDescriptors; curDescIndex < TMgConstruction_NumInstanceDescriptors; curDescIndex++, curDesc++) @@ -2556,10 +2556,10 @@ TMiConstruction_Save( { continue; } - + // First write the name to the new offset curNameLen = strlen(curDesc->namePtr) + 1; - + error = BFrFile_WritePos( instancePhysicalFile, @@ -2570,35 +2570,35 @@ TMiConstruction_Save( curDesc->namePtr = (char*)curNameOffset; curNameOffset += curNameLen; - + curNameFilePos += curNameLen; } fileHeader.nameBlockLength = curNameOffset; - + UUrMemory_Block_VerifyList(); /* * Write out the file header */ UUmAssert(fileHeader.numNameDescriptors <= fileHeader.numInstanceDescriptors); - UUmAssert(fileHeader.dataBlockOffset >= - sizeof(TMtInstanceFile_Header) + - fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + + UUmAssert(fileHeader.dataBlockOffset >= + sizeof(TMtInstanceFile_Header) + + fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + fileHeader.numNameDescriptors * sizeof(TMtNameDescriptor) + fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor)); - UUmAssert(fileHeader.nameBlockOffset >= - sizeof(TMtInstanceFile_Header) + - fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + - fileHeader.numNameDescriptors * sizeof(TMtNameDescriptor) + - fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor) + + UUmAssert(fileHeader.nameBlockOffset >= + sizeof(TMtInstanceFile_Header) + + fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + + fileHeader.numNameDescriptors * sizeof(TMtNameDescriptor) + + fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor) + fileHeader.dataBlockLength); - + UUmAssert(fileHeader.dataBlockOffset + fileHeader.dataBlockLength <= fileHeader.nameBlockOffset); error = BFrFile_WritePos(instancePhysicalFile, 0, sizeof(TMtInstanceFile_Header), &fileHeader); UUmError_ReturnOnErrorMsg(error, "Could not write endian detector"); - + /* * Write out the instance descriptors */ @@ -2609,7 +2609,7 @@ TMiConstruction_Save( fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor), TMgConstruction_InstanceDescriptors); UUmError_ReturnOnErrorMsg(error, "Could not write instance descriptors"); - + /* * Write out the name descriptors */ @@ -2620,7 +2620,7 @@ TMiConstruction_Save( fileHeader.numNameDescriptors * sizeof(TMtNameDescriptor), TMgConstruction_NameDescriptors); UUmError_ReturnOnErrorMsg(error, "Could not write name descriptors"); - + /* * Write out the template descriptors */ @@ -2633,13 +2633,13 @@ TMiConstruction_Save( fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor), TMgConstruction_TemplateDescriptors); UUmError_ReturnOnErrorMsg(error, "Could not write name descriptors"); - + BFrFile_Close(instancePhysicalFile); - + UUrMemory_Block_VerifyList(); UUrMemory_Pool_Reset(TMgConstructionPool); - + return UUcError_None; } @@ -2651,10 +2651,10 @@ TMiConstruction_DumpPlaceHolders( UUtUns32 curDescIndex; TMtNameDescriptor* curNameDesc; UUtUns32 numPlaceHolders = 0; - + fprintf(inFile, "Place holder dump"UUmNL); fprintf(inFile, "fileName: %s"UUmNL, BFrFileRef_GetLeafName(TMgConstruction_FileRef)); - + for(curDescIndex = 0, curNameDesc = TMgConstruction_NameDescriptors; curDescIndex < TMgConstruction_NumNameDescriptors; curDescIndex++, curNameDesc++) @@ -2665,7 +2665,7 @@ TMiConstruction_DumpPlaceHolders( numPlaceHolders++; } } - + if(numPlaceHolders > 0) { fprintf(stderr, "YO: I found %d place holders see %s for details."UUmNL, numPlaceHolders, inFileName); @@ -2679,10 +2679,10 @@ TMiConstruction_DumpInstanceNames( { UUtUns32 curDescIndex; TMtNameDescriptor* curNameDesc; - + fprintf(inFile, "Instance name dump"UUmNL); fprintf(inFile, "fileName: %s"UUmNL, BFrFileRef_GetLeafName(TMgConstruction_FileRef)); - + for(curDescIndex = 0, curNameDesc = TMgConstruction_NameDescriptors; curDescIndex < TMgConstruction_NumNameDescriptors; curDescIndex++, curNameDesc++) @@ -2698,13 +2698,13 @@ TMiConstruction_FindInstanceDescriptor( { UUtUns32 curDescIndex; TMtNameDescriptor* curDesc; - + for(curDescIndex = 0, curDesc = TMgConstruction_NameDescriptors; curDescIndex < TMgConstruction_NumNameDescriptors; curDescIndex++, curDesc++) { UUmAssert(curDesc->namePtr != NULL); - + if( curDesc->namePtr[0] == (char)((inTemplateTag >> 24) & 0xFF) && curDesc->namePtr[1] == (char)((inTemplateTag >> 16) & 0xFF) && curDesc->namePtr[2] == (char)((inTemplateTag >> 8) & 0xFF) && @@ -2718,7 +2718,7 @@ TMiConstruction_FindInstanceDescriptor( } } } - + return NULL; } @@ -2727,10 +2727,10 @@ TMiConstruction_CreateNewDescriptor( TMtTemplateTag inTemplateTag, const char* inInstanceName, UUtUns32 *outNewDescIndex) -{ +{ TMtTemplateDefinition* templateDefinition; TMtInstanceDescriptor* newInstanceDescriptor; - + char* newNamePtr; UUtUns32 newIndex; @@ -2738,24 +2738,24 @@ TMiConstruction_CreateNewDescriptor( UUtUns32 curNameDescIndex; TMtNameDescriptor* curNameDesc; TMtNameDescriptor* newNameDescriptor; - + UUrMemory_Block_VerifyList(); - + *outNewDescIndex = UUcMaxUns32; - + templateDefinition = TMrUtility_Template_FindDefinition(inTemplateTag); if(templateDefinition == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find template definition"); } - + if(TMgConstruction_NumInstanceDescriptors >= TMcConstruction_MaxInstances) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Exceeded maximum number of instances in a file"); } - + newIndex = TMgConstruction_NumInstanceDescriptors++; - + newInstanceDescriptor = TMgConstruction_InstanceDescriptors + newIndex; if(inInstanceName != NULL) @@ -2765,7 +2765,7 @@ TMiConstruction_CreateNewDescriptor( { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not alloc contruction pool"); } - + strcpy(newNamePtr + 4, inInstanceName); newNamePtr[0] = (char)((inTemplateTag >> 24) & 0xFF); newNamePtr[1] = (char)((inTemplateTag >> 16) & 0xFF); @@ -2776,13 +2776,13 @@ TMiConstruction_CreateNewDescriptor( { newNamePtr = NULL; } - + newInstanceDescriptor->templatePtr = templateDefinition; newInstanceDescriptor->namePtr = newNamePtr; newInstanceDescriptor->flags = inInstanceName == NULL ? TMcDescriptorFlags_Unique : TMcDescriptorFlags_None; newInstanceDescriptor->dataPtr = NULL; newInstanceDescriptor->size = 0; - + newInstanceDescriptor->flags |= TMcDescriptorFlags_Touched; if(inInstanceName != NULL) @@ -2796,22 +2796,22 @@ TMiConstruction_CreateNewDescriptor( break; } } - + UUrMemory_MoveOverlap( TMgConstruction_NameDescriptors + curNameDescIndex, TMgConstruction_NameDescriptors + curNameDescIndex + 1, (TMgConstruction_NumInstanceDescriptors - curNameDescIndex) * sizeof(TMtNameDescriptor)); newNameDescriptor = TMgConstruction_NameDescriptors + curNameDescIndex; - + newNameDescriptor->namePtr = newInstanceDescriptor->namePtr; newNameDescriptor->instanceDescIndex = newIndex; - + TMgConstruction_NumNameDescriptors++; } - + *outNewDescIndex = newIndex; - + return UUcError_None; } @@ -2824,27 +2824,27 @@ TMiConstruction_Instance_Create( UUtError error; TMtTemplateDefinition* templateDefinition; TMtInstanceDescriptor* newInstanceDescriptor; - + UUtUns8* newDataPtr; UUtUns32 dataSize; - + UUtUns32 newDescIndex; - + if(inInstanceName != NULL) { UUmAssertReadPtr(inInstanceName, 1); UUmAssert(strlen(inInstanceName) < TMcInstanceName_MaxLength); } - + templateDefinition = TMrUtility_Template_FindDefinition(inTemplateTag); if(templateDefinition == NULL) { UUrError_Report(UUcError_Generic, "Could not find template definition"); return NULL; } - + newInstanceDescriptor = NULL; - + if(inInstanceName != NULL) { /* @@ -2863,14 +2863,14 @@ TMiConstruction_Instance_Create( } // Replace the place holder newInstanceDescriptor->flags &= (TMtDescriptorFlags)~TMcDescriptorFlags_PlaceHolder; - + newDescIndex = newInstanceDescriptor - TMgConstruction_InstanceDescriptors; } } - + if(newInstanceDescriptor == NULL) { - error = + error = TMiConstruction_CreateNewDescriptor( inTemplateTag, inInstanceName, @@ -2880,12 +2880,12 @@ TMiConstruction_Instance_Create( UUrError_Report(UUcError_Generic, "Could not create descriptor"); return NULL; } - + newInstanceDescriptor = TMgConstruction_InstanceDescriptors + newDescIndex; } dataSize = templateDefinition->size + inVarArrayLength * templateDefinition->varArrayElemSize; - + dataSize = (dataSize + UUcProcessor_CacheLineSize_Mask) & ~UUcProcessor_CacheLineSize_Mask; newDataPtr = UUrMemory_Pool_Block_New(TMgConstructionPool, dataSize); @@ -2894,26 +2894,26 @@ TMiConstruction_Instance_Create( UUmAssert(!"Out of memory"); return NULL; } - + UUrMemory_Set32(newDataPtr, 0xDEADDEAD, dataSize); - + UUmAssertAlignedPtr(newDataPtr); - + newDataPtr = newDataPtr + TMcPreDataSize; - + TMiConstruction_DataPtr_PlaceHolder_Set( newDataPtr, TMiPlaceHolder_MakeFromIndex(newDescIndex)); UUmAssertReadPtr(newDataPtr, dataSize); - + newInstanceDescriptor->size = dataSize; newInstanceDescriptor->dataPtr = newDataPtr; { UUtUns8* dataPtr = newDataPtr - TMcPreDataSize; UUtUns8* swapCodes = newInstanceDescriptor->templatePtr->swapCodes; - + TMrUtility_VarArrayReset_Recursive( &swapCodes, &dataPtr, @@ -2930,31 +2930,31 @@ TMiConstruction_Instance_Clean( { UUtUns8* swapCode; UUtUns8* dataPtr; - + TMtInstanceDescriptor* targetDesc; - + targetDesc = TMiConstruction_FindInstanceDescriptor(inTemplateTag, inInstanceName); if(targetDesc == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find descriptor"); } - + if(targetDesc->dataPtr == NULL) { return UUcError_None; } - + targetDesc->flags |= TMcDescriptorFlags_Touched; - + swapCode = targetDesc->templatePtr->swapCodes; dataPtr = targetDesc->dataPtr - TMcPreDataSize; - + TMiConstruction_Clean_Recursive( &swapCode, &dataPtr); - + return UUcError_None; -} +} static void* TMiConstruction_Instance_ResizeVarArray( @@ -2965,41 +2965,41 @@ TMiConstruction_Instance_ResizeVarArray( UUtUns32 newSize; UUtUns8* newDataPtr; TMtPlaceHolder placeHolder; - + TMmConstruction_Verify_InstanceData(inDataPtr); - + instanceDesc = TMiPlaceHolder_GetInstanceDesc((TMtPlaceHolder)inDataPtr); UUmAssert(instanceDesc != NULL); TMmConstruction_Verify_InstanceDesc(instanceDesc); - + newSize = instanceDesc->templatePtr->size + instanceDesc->templatePtr->varArrayElemSize * inVarArrayLength + TMcPreDataSize; - + newSize = (newSize + UUcProcessor_CacheLineSize_Mask) & ~UUcProcessor_CacheLineSize_Mask; newDataPtr = UUrMemory_Pool_Block_New(TMgConstructionPool, newSize); - + if(newDataPtr == NULL) { return NULL; } - + newDataPtr = newDataPtr + TMcPreDataSize; - + placeHolder = TMiConstruction_DataPtr_PlaceHolder_Get(inDataPtr); TMiConstruction_DataPtr_PlaceHolder_Set(newDataPtr, placeHolder); - + instanceDesc->dataPtr = newDataPtr; - + { UUtUns8* dataPtr = newDataPtr - TMcPreDataSize; UUtUns8* swapCodes = instanceDesc->templatePtr->swapCodes; - + TMrUtility_VarArrayReset_Recursive( &swapCodes, &dataPtr, inVarArrayLength); } - + return newDataPtr; } @@ -3012,36 +3012,36 @@ TMiConstruction_Instance_CreatePlaceHolder( UUtError error; UUtUns32 newIndex; TMtInstanceDescriptor* targetDesc; - - error = + + error = TMiConstruction_CreateNewDescriptor( inTemplateTag, inInstanceName, &newIndex); UUmError_ReturnOnError(error); - + *outPlaceHolder = TMmPlaceHolder_MakeFromIndex(newIndex); - + targetDesc = TMiPlaceHolder_GetInstanceDesc(*outPlaceHolder); targetDesc->flags |= TMcDescriptorFlags_PlaceHolder; - + return UUcError_None; } - + static void TMiConstruction_Instance_Touch( TMtInstanceDescriptor* inInstanceDescriptor) { UUtUns8* swapCodes; UUtUns8* dataPtr; - + TMmConstruction_Verify_InstanceDesc(inInstanceDescriptor); - + if(inInstanceDescriptor->dataPtr != NULL) { swapCodes = inInstanceDescriptor->templatePtr->swapCodes; dataPtr = inInstanceDescriptor->dataPtr - TMcPreDataSize; - + TMiConstruction_Touch_Recursive( &swapCodes, &dataPtr); @@ -3061,10 +3061,10 @@ TMrConstruction_Initialize( { TMgConstruction_InstanceDescriptors = UUrMemory_Block_New(sizeof(TMtInstanceDescriptor) * TMcConstruction_MaxInstances); UUmError_ReturnOnNull(TMgConstruction_InstanceDescriptors); - + TMgConstruction_NameDescriptors = UUrMemory_Block_New(sizeof(TMtNameDescriptor) * TMcConstruction_MaxInstances); UUmError_ReturnOnNull(TMgConstruction_NameDescriptors); - + TMgConstructionPool = UUrMemory_Pool_New(TMcConstructionPoolChunkSize, UUcPool_Growable); UUmError_ReturnOnNull(TMgConstructionPool); @@ -3076,7 +3076,7 @@ TMrConstruction_Terminate( void) { UUtUns32 i; - + // dispose of memory if(TMgConstruction_InstanceDescriptors != NULL) { @@ -3088,19 +3088,19 @@ TMrConstruction_Terminate( UUrMemory_Block_Delete(TMgConstruction_NameDescriptors); TMgConstruction_NameDescriptors = NULL; } - + if(TMgConstructionPool != NULL) { UUrMemory_Pool_Delete(TMgConstructionPool); TMgConstructionPool = NULL; } - + if(TMgConstruction_DuplicateIndexArray != NULL) { UUrMemory_Block_Delete(TMgConstruction_DuplicateIndexArray); TMgConstruction_DuplicateIndexArray = NULL; } - + if(TMgConstruction_TemplateDescriptors != NULL) { UUrMemory_Block_Delete(TMgConstruction_TemplateDescriptors); @@ -3109,7 +3109,7 @@ TMrConstruction_Terminate( if(TMgTemplateDefinitionsAlloced != NULL) { for(i = 0; i < TMgNumTemplateDefinitions; i++) - { + { if(TMgTemplateDefinitionArray[i].swapCodes != NULL) { UUrMemory_Block_Delete(TMgTemplateDefinitionArray[i].swapCodes); @@ -3119,7 +3119,7 @@ TMrConstruction_Terminate( UUrMemory_Block_Delete(TMgTemplateDefinitionsAlloced); TMgTemplateDefinitionsAlloced = NULL; } - + if(TMgTemplateNameAlloced != NULL) { UUrMemory_String_Delete(TMgTemplateNameAlloced); @@ -3144,7 +3144,7 @@ TMiConstruction_PrepareBinaryFile( error = BFrFile_Open(*outFileRef, "w", outFile); UUmError_ReturnOnError(error); - + if (*outFile == NULL) { return UUcError_Generic; } @@ -3164,33 +3164,33 @@ TMrConstruction_Start( { UUtError error; UUtUns32 levelNum; - + UUmAssertReadPtr(TMgConstruction_InstanceDescriptors, sizeof(TMtInstanceDescriptor) * TMcConstruction_MaxInstances); UUmAssertReadPtr(TMgConstruction_NameDescriptors, sizeof(TMtNameDescriptor) * TMcConstruction_MaxInstances); - + TMgConstruction_NumInstanceDescriptors = 0; UUrMemory_Clear(TMgConstruction_InstanceDescriptors, sizeof(TMtInstanceDescriptor) * TMcConstruction_MaxInstances); - + TMgConstruction_NumNameDescriptors = 0; UUrMemory_Clear(TMgConstruction_NameDescriptors, sizeof(TMtNameDescriptor) * TMcConstruction_MaxInstances); - + TMgConstruction_NumTemplateDescriptors = 0; - + TMgConstruction_FileRef = inInstanceFileRef; UUmAssert(sizeof(TMtTemplateTag) == sizeof(UUtUns32)); TMgRawTrackingHashTable = AUrHashTable_New(sizeof(TMtRawTracking), TMcMaxIdentifiers, AUrHash_4Byte_Hash, AUrHash_4Byte_IsEqual); TMgRawTrackingCount = 0; - + error = TMiConstruction_PrepareBinaryFile(inInstanceFileRef, &TMgConstruction_RawFileRef, &TMgConstruction_RawFile, &TMgConstruction_RawBytes, "raw"); UUmError_ReturnOnError(error); - - error = TMiConstruction_PrepareBinaryFile(inInstanceFileRef, &TMgConstruction_SeparateFileRef, + + error = TMiConstruction_PrepareBinaryFile(inInstanceFileRef, &TMgConstruction_SeparateFileRef, &TMgConstruction_SeparateFile, &TMgConstruction_SeparateBytes, "sep"); UUmError_ReturnOnError(error); - - error = + + error = TMrUtility_LevelInfo_Get( inInstanceFileRef, &levelNum, @@ -3198,7 +3198,7 @@ TMrConstruction_Start( NULL, &TMgConstruction_InstanceFileID); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -3218,51 +3218,51 @@ TMrConstruction_Stop( delta = -UUrMachineTime_High(); UUmAssert(TMgInGame == UUcFalse); - + fprintf(stderr, "running major check... \n"); TMmConstruction_MajorCheck(); - + fprintf(stderr, "writing to disk... \n"); error = TMiConstruction_Save(); UUmError_ReturnOnError(error); - + //fprintf(stderr, "verifying all touched... \n"); //TMmConstruction_Verify_AllTouched(); - + // dump place holders printf("dumping placeholders... "UUmNL); - + sprintf(temp, "%s", BFrFileRef_GetLeafName(TMgConstruction_FileRef)); p = strchr(temp, '.'); if(p != NULL) *p = 0; - + sprintf(fileName, "%s_phs.txt", temp); - + file = fopen(fileName, "wb"); TMiConstruction_DumpPlaceHolders(fileName, file); fclose(file); - + // dump names printf("dumping names... "UUmNL); - + sprintf(temp, "%s", BFrFileRef_GetLeafName(TMgConstruction_FileRef)); p = strchr(temp, '.'); if(p != NULL) *p = 0; - + sprintf(fileName, "%s_nms.txt", temp); - + file = fopen(fileName, "wb"); TMiConstruction_DumpInstanceNames(fileName, file); fclose(file); - + delta += UUrMachineTime_High(); fprintf(stderr, "unaccounted time %f seconds\n", UUrMachineTime_High_To_Seconds(delta)); AUrHashTable_Delete(TMgRawTrackingHashTable); TMgRawTrackingHashTable = NULL; - + return UUcError_None; } @@ -3275,16 +3275,16 @@ TMrConstruction_Instance_Renew( { void* dataPtr; TMtInstanceDescriptor* targetInstDesc; - + UUmAssert(TMgInGame == UUcFalse); - + *outNewInstance = NULL; - + if(inInstanceName == NULL) { return TMrConstruction_Instance_NewUnique(inTemplateTag, inInitialVarArrayLength, outNewInstance); } - + targetInstDesc = TMiConstruction_FindInstanceDescriptor(inTemplateTag, inInstanceName); if(targetInstDesc == NULL || targetInstDesc->dataPtr == NULL) { @@ -3295,22 +3295,22 @@ TMrConstruction_Instance_Renew( { TMiConstruction_Instance_Clean(inTemplateTag, inInstanceName); dataPtr = TMiConstruction_Instance_ResizeVarArray(targetInstDesc->dataPtr, inInitialVarArrayLength); - + targetInstDesc->dataPtr = dataPtr; } - + if(dataPtr == NULL) { return UUcError_OutOfMemory; } - + UUmAssert(targetInstDesc != NULL); - + if(!(targetInstDesc->templatePtr->flags & TMcTemplateFlag_Registered)) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "template not registered"); } - + targetInstDesc->flags |= (TMtDescriptorFlags)(TMcDescriptorFlags_Touched | TMcDescriptorFlags_InBatchFile); // CB: don't flag this instance for deletion, it actually has some data now! (if it was initially created @@ -3319,9 +3319,9 @@ TMrConstruction_Instance_Renew( targetInstDesc->flags &= ~((TMtDescriptorFlags)TMcDescriptorFlags_DeleteMe); TMmConstruction_Verify_InstanceData(dataPtr); - + *outNewInstance = dataPtr; - + return UUcError_None; } @@ -3349,7 +3349,7 @@ static void *TMiConstruction_Binary_New(UUtUns32 inBytes, TMtTemplateTag inTempl tracking_block.identifier = inTemplateTag; tracking_block.raw_count = 0; tracking_block.separate_count = 0; - + tracking_ptr = AUrHashTable_Add(TMgRawTrackingHashTable, &tracking_block); TMgRawTrackingList[TMgRawTrackingCount] = inTemplateTag; @@ -3368,7 +3368,7 @@ static void *TMiConstruction_Binary_New(UUtUns32 inBytes, TMtTemplateTag inTempl } ptr = (UUtUns32 *) UUrMemory_Block_New(alloc_size); - + if (NULL != ptr) { ptr[0] = inBytes; ptr += 8; @@ -3395,7 +3395,7 @@ static void *TMiConstruction_Binary_Write(BFtFile *inFile, UUtUns32 *ioBytes, vo UUmAssert(TMgInGame == UUcFalse); - if (NULL == inPtr) { + if (NULL == inPtr) { return NULL; } @@ -3437,14 +3437,14 @@ TMrConstruction_Instance_GetPlaceHolder( UUmAssertReadPtr(inInstanceName, sizeof(char)); UUmAssertWritePtr(outPlaceHolder, sizeof(TMtPlaceHolder)); UUmAssert(TMgInGame == UUcFalse); - - if('\0' == inInstanceName[0]) + + if('\0' == inInstanceName[0]) { return UUcError_Generic; } - + *outPlaceHolder = 0; - + targetDesc = TMiConstruction_FindInstanceDescriptor(inTemplateTag, inInstanceName); if(targetDesc == NULL) { @@ -3454,16 +3454,16 @@ TMrConstruction_Instance_GetPlaceHolder( inInstanceName, outPlaceHolder); UUmError_ReturnOnErrorMsg(error, "Could not create place holder"); - + targetDesc = TMiConstruction_FindInstanceDescriptor(inTemplateTag, inInstanceName); UUmAssert(targetDesc != NULL); } - + TMiConstruction_Instance_Touch(targetDesc); - + // Always return an index *outPlaceHolder = TMmPlaceHolder_MakeFromIndex(targetDesc - TMgConstruction_InstanceDescriptors); - + return UUcError_None; } @@ -3476,34 +3476,34 @@ TMrConstruction_Instance_CheckExists( UUtUns8* swapCode; UUtUns8* dataPtr; UUtBool result; - + targetDesc = TMiConstruction_FindInstanceDescriptor(inTemplateTag, inInstanceName); if(targetDesc == NULL || targetDesc->dataPtr == NULL) { return UUcFalse; } - + /* * Recursively look for unique instances that got out of date */ { swapCode = targetDesc->templatePtr->swapCodes; dataPtr = targetDesc->dataPtr - TMcPreDataSize; - + result = TMiConstruction_CheckExists_Recursive( &swapCode, &dataPtr); - + if(result == UUcFalse) return UUcFalse; } - + TMiConstruction_Instance_Touch(targetDesc); - + targetDesc->flags |= (TMtDescriptorFlags)(TMcDescriptorFlags_Touched | TMcDescriptorFlags_InBatchFile); - + return UUcTrue; } - + UUtError TMrConstruction_Instance_NewUnique( TMtTemplateTag inTemplateTag, @@ -3512,28 +3512,28 @@ TMrConstruction_Instance_NewUnique( { void* dataPtr; TMtTemplateDefinition* templatePtr; - + UUmAssert(TMgInGame == UUcFalse); - + templatePtr = TMrUtility_Template_FindDefinition(inTemplateTag); - + #if defined(DEBUGGING) && DEBUGGING - + if(!(templatePtr->flags & TMcTemplateFlag_Registered)) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "template not registered"); } - + #endif - + dataPtr = TMiConstruction_Instance_Create( inTemplateTag, 0, inInitialVarArrayLength); - + *outReference = dataPtr; - + return UUcError_None; } @@ -3543,17 +3543,17 @@ TMrConstruction_Instance_Keep( char* inInstanceName) { TMtInstanceDescriptor* targetDesc; - + targetDesc = TMiConstruction_FindInstanceDescriptor(inTemplateTag, inInstanceName); if(targetDesc == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find instance"); } - + TMiConstruction_Instance_Touch(targetDesc); - + targetDesc->flags |= (TMtDescriptorFlags)(TMcDescriptorFlags_Touched | TMcDescriptorFlags_InBatchFile); - + return UUcError_None; } @@ -3561,7 +3561,7 @@ UUtError TMrConstruction_ConvertToNativeEndian( void) { - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Construction.h b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Construction.h index 4e9b498..614fd00 100644 --- a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Construction.h +++ b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Construction.h @@ -1,12 +1,12 @@ /* FILE: BFW_TM_Construction.h - + AUTHOR: Brent H. Pease - + CREATED: June 8, 1997 - + PURPOSE: Manage data file construction - + Copyright 1997 */ @@ -27,13 +27,13 @@ extern "C" { void TMrConstruction_MajorCheck( void); - + #define TMmConstruction_MajorCheck() TMrConstruction_MajorCheck() - + #else #define TMmConstruction_MajorCheck() - + #endif UUtError @@ -80,7 +80,7 @@ UUtBool TMrConstruction_Instance_CheckExists( TMtTemplateTag inTemplateTag, const char* inInstanceName); - + UUtError TMrConstruction_Instance_NewUnique( TMtTemplateTag inTemplateTag, diff --git a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Game.c b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Game.c index fe8c931..a5cbe77 100644 --- a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Game.c +++ b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Game.c @@ -1,12 +1,12 @@ /* FILE: BFW_TM3_InGame.c - + AUTHOR: Brent H. Pease - + CREATED: July 10, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -38,10 +38,10 @@ UUtBool TMgTimeLevelLoad = UUcFalse; #define TMcPrivateData_Max (64) #define TMcCacheData_Max (16) - + #define TMcInstanceFileRefs_Max (16) - + #if TOOL_VERSION #define TMcDynamic_Instance_Perm_Max (16) #define TMcDynamic_Memory_Perm_Size (100 * 1024) @@ -62,10 +62,10 @@ UUtBool TMgTimeLevelLoad = UUcFalse; #else #define TMcGame_InstanceFile_Dynamic_Num (1) #endif - + #define TMcGame_InstancePtrList_Max (4) #define TMcGame_PrivateInfosPerInstanceFile_Max (20) - + /* * ========================================================================= * T Y P E S @@ -74,9 +74,9 @@ UUtBool TMgTimeLevelLoad = UUcFalse; typedef enum TMtInstanceFile_PrivateInfo_Type { - TMcPrivateInfo_PrivateData + TMcPrivateInfo_PrivateData } TMtInstanceFile_PrivateInfo_Type; - + /* * */ @@ -84,44 +84,44 @@ UUtBool TMgTimeLevelLoad = UUcFalse; { UUtUns32 timeStamp; TMtInstancePriorities priority; - + } TMtInstance_DynamicData; - + struct TMtPrivateData { TMtTemplateTag templateTag; UUtUns32 dataSize; TMtTemplateProc_Handler procHandler; - + }; - + struct TMtCache_Simple { TMtTemplateTag templateTag; - + UUtUns32 maxNumEntries; - + TMtCacheProc_Simple_Load loadProc; TMtCacheProc_Simple_Unload unloadProc; - + void** entryList; }; - + typedef struct TMtInstanceFile_PrivateInfo { TMtInstanceFile_PrivateInfo_Type type; - + void* owner; TMtTemplateTag templateTag; UUtUns16 instanceListIndex; // if this is UUcMaxUns16 then there is no instance list void* memoryPool; - + } TMtInstanceFile_PrivateInfo; - + /* * */ - + /* * This is the instance file */ @@ -129,17 +129,17 @@ UUtBool TMgTimeLevelLoad = UUcFalse; { char fileName[BFcMaxFileNameLength]; UUtUns32 fileIndex; - + UUtUns32 maxInstanceDescriptors; UUtUns32 numInstanceDescriptors; TMtInstanceDescriptor* instanceDescriptors; - + UUtUns32 numNameDescriptors; TMtNameDescriptor* nameDescriptors; // Used for binary search - + UUtUns32 numTemplateDescriptors; TMtTemplateDescriptor* templateDescriptors; - + BFtFileMapping* mapping; // if file mapping is used BFtFileMapping* rawMapping; void* rawPtr; @@ -148,48 +148,48 @@ UUtBool TMgTimeLevelLoad = UUcFalse; UUtUns8* dataBlock; char* nameBlock; - + UUtBool final; UUtBool preparedForMemory; - + UUtUns32 dynamicBytesUsed; // used for dynamic instances UUtMemory_Pool* dynamicPool; - + UUtUns32 numInstancePtrLists; void** instancePtrLists[TMcGame_InstancePtrList_Max]; - + UUtUns32 numPrivateInfos; TMtInstanceFile_PrivateInfo privateInfos[TMcGame_PrivateInfosPerInstanceFile_Max]; - + }; typedef struct TMtInstanceFileRef { BFtFileRef instanceFileRef; UUtUns32 fileIndex; - + } TMtInstanceFileRef; - + /* * ========================================================================= * G L O B A L S * ========================================================================= */ static UUtBool TMgGame_ValidLevels[TMcLevels_MaxNum]; - + static UUtUns16 TMgGame_InstanceFileRefs_Num = 0; static TMtInstanceFileRef TMgGame_InstanceFileRefs_List[TMcInstanceFileRefs_Max]; - + static UUtUns16 TMgGame_LoadedInstanceFiles_Num = 0; static TMtInstanceFile* TMgGame_LoadedInstanceFiles_List[TMcInstanceFileRefs_Max]; - + static TMtInstanceFile* TMgGame_DynamicInstanceFile_Temp = NULL; // CB: this is now deprecated static TMtInstanceFile* TMgGame_DynamicInstanceFile_Perm = NULL; - + static UUtUns16 TMgGame_PrivateData_Num = 0; static TMtPrivateData TMgGame_PrivateData_List[TMcPrivateData_Max]; - - + + /* * ========================================================================= * P R I V A T E F U N C T I O N S @@ -226,7 +226,7 @@ TMiGame_InstanceFile_GetInstanceDesc( static TMtInstanceFile* TMiGame_InstanceFile_GetFromIndex( UUtUns32 inInstanceFileIndex); - + static UUtBool TMiGame_Level_IsValid( BFtFileRef* inInstanceFileRef, @@ -240,9 +240,9 @@ TMiGame_Level_IsValid( UUtUns32 itr; TMtTemplateDefinition* templatePtr; UUtBool level_exists = UUcTrue; - + UUmAssertReadPtr(inInstanceFileRef, sizeof(void*)); - + error = BFrFile_Open(inInstanceFileRef, "r", &datFile); if (error != UUcError_None) { @@ -250,7 +250,7 @@ TMiGame_Level_IsValid( level_exists = UUcFalse; goto done; } - + error = TMiGame_InstanceFile_LoadHeader(datFile, &fileHeader, &needsSwapping); if (error != UUcError_None) { @@ -258,14 +258,14 @@ TMiGame_Level_IsValid( level_exists = UUcFalse; goto done; } - + if(fileHeader.numTemplateDescriptors == 0) { UUrDebuggerMessage("level %d: no templates" UUmNL, inLevelNumber); level_exists = UUcFalse; goto done; } - + templateDescriptors = UUrMemory_Block_New(fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor)); if(templateDescriptors == NULL) { @@ -273,13 +273,13 @@ TMiGame_Level_IsValid( level_exists = UUcFalse; goto done; } - + // Read in the template descriptors - error = + error = BFrFile_ReadPos( datFile, sizeof(TMtInstanceFile_Header) + - fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + + fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + fileHeader.numNameDescriptors * sizeof(TMtNameDescriptor), fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor), templateDescriptors); @@ -289,7 +289,7 @@ TMiGame_Level_IsValid( level_exists = UUcFalse; goto done; } - + // check to make sure all template checksums match for(itr = 0; itr < fileHeader.numTemplateDescriptors; itr++) { @@ -297,7 +297,7 @@ TMiGame_Level_IsValid( { UUrSwap_4Byte(&templateDescriptors[itr].tag); } - + templatePtr = TMrUtility_Template_FindDefinition(templateDescriptors[itr].tag); if(templatePtr == NULL) { @@ -310,7 +310,7 @@ TMiGame_Level_IsValid( level_exists = UUcFalse; goto done; } - + if(needsSwapping) { UUrSwap_8Byte(&templateDescriptors[itr].checksum); @@ -330,15 +330,15 @@ TMiGame_Level_IsValid( #endif } } - + done: BFrFile_Close(datFile); - + if(templateDescriptors != NULL) { UUrMemory_Block_Delete(templateDescriptors); } - + return level_exists; } @@ -352,14 +352,14 @@ TMiGame_Instance_FileAndIndex_Get( TMtPlaceHolder placeHolder; UUtUns32 instanceIndex; TMtInstanceFile* instanceFile; - + UUmAssertReadPtr(inDataPtr, sizeof(void*)); UUmAssertReadPtr(outInstanceFile, sizeof(*outInstanceFile)); UUmAssertReadPtr(outInstanceIndex, sizeof(*outInstanceIndex)); - + placeHolder = ((UUtUns32*)inDataPtr)[-2]; instanceFileID = ((UUtUns32*)inDataPtr)[-1]; - + if(TMmInstanceFile_ID_IsIndex(instanceFileID)) { instanceFile = TMiGame_InstanceFile_GetFromIndex(instanceFileID); @@ -367,13 +367,13 @@ TMiGame_Instance_FileAndIndex_Get( } else { - + instanceFile = (TMtInstanceFile*)instanceFileID; - + #if defined(DEBUGGING) && DEBUGGING { UUtUns16 itr; - + for(itr = 0; itr < TMgGame_LoadedInstanceFiles_Num; itr++) { if(TMgGame_LoadedInstanceFiles_List[itr] == instanceFile) break; @@ -383,17 +383,17 @@ TMiGame_Instance_FileAndIndex_Get( #endif } - + UUmAssertReadPtr(instanceFile, sizeof(*instanceFile)); instanceIndex = TMmPlaceHolder_GetIndex(placeHolder); - + UUmAssert(instanceIndex < instanceFile->numInstanceDescriptors); - + *outInstanceFile = instanceFile; *outInstanceIndex = instanceIndex; - - + + } @@ -406,13 +406,13 @@ TMiGame_Instance_File_Get( UUtUns32 instanceFileID; TMtPlaceHolder placeHolder; TMtInstanceFile* instanceFile; - + UUmAssertReadPtr(inDataPtr, sizeof(void*)); UUmAssertReadPtr(outInstanceFile, sizeof(*outInstanceFile)); - + placeHolder = ((UUtUns32*)inDataPtr)[-2]; instanceFileID = ((UUtUns32*)inDataPtr)[-1]; - + if(TMmInstanceFile_ID_IsIndex(instanceFileID)) { instanceFile = TMiGame_InstanceFile_GetFromIndex(instanceFileID); @@ -420,13 +420,13 @@ TMiGame_Instance_File_Get( } else { - + instanceFile = (TMtInstanceFile*)instanceFileID; - + #if defined(DEBUGGING) && DEBUGGING { UUtUns16 itr; - + for(itr = 0; itr < TMgGame_LoadedInstanceFiles_Num; itr++) { if(TMgGame_LoadedInstanceFiles_List[itr] == instanceFile) break; @@ -436,7 +436,7 @@ TMiGame_Instance_File_Get( #endif } - + *outInstanceFile = instanceFile; } @@ -453,10 +453,10 @@ TMiGame_Instance_ByteSwap_Array( UUtUns8 count; UUtUns8 i; UUtBool oneElementArray; - + UUmAssertReadPtr(ioSwapCode, sizeof(*ioSwapCode)); UUmAssertReadPtr(ioDataPtr, sizeof(*ioDataPtr)); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; @@ -464,7 +464,7 @@ TMiGame_Instance_ByteSwap_Array( curSwapCode += 1; oneElementArray = (*(curSwapCode + 1) == TMcSwapCode_EndArray); - + if ((*curSwapCode == TMcSwapCode_8Byte) && oneElementArray) { for(i = 0; i < count; i++) @@ -497,15 +497,15 @@ TMiGame_Instance_ByteSwap_Array( curDataPtr += 1 * count; curSwapCode += 2; } - else + else { UUtUns8 *oldSwapCode = curSwapCode; for(i = 0; i < count; i++) { curSwapCode = oldSwapCode; - - error = + + error = TMiGame_Instance_ByteSwap( &curSwapCode, &curDataPtr, @@ -515,7 +515,7 @@ TMiGame_Instance_ByteSwap_Array( UUmError_ReturnOnError(error); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; @@ -556,17 +556,17 @@ TMiGame_Instance_ByteSwap_VarArray( count = (*(UUtUns32 *)curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: UUrSwap_2Byte(curDataPtr); count = (*(UUtUns16 *)curDataPtr); curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + if(inByteSwapProc != NULL) { inByteSwapProc(inData); @@ -579,7 +579,7 @@ TMiGame_Instance_ByteSwap_VarArray( else { UUtBool oneElementArray = (*(curSwapCode + 1) == TMcSwapCode_EndVarArray); - + if ((*curSwapCode == TMcSwapCode_8Byte) && oneElementArray) { for(i = 0; i < count; i++) @@ -612,15 +612,15 @@ TMiGame_Instance_ByteSwap_VarArray( curDataPtr += 1 * count; curSwapCode += 2; } - else + else { origSwapCode = curSwapCode; for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - - error = + + error = TMiGame_Instance_ByteSwap( &curSwapCode, &curDataPtr, @@ -652,40 +652,40 @@ TMiGame_Instance_ByteSwap( UUtUns8* curDataPtr; char swapCode; TMtPlaceHolder targetPlaceHolder; - + UUmAssertReadPtr(ioSwapCode, sizeof(*ioSwapCode)); UUmAssertReadPtr(ioDataPtr, sizeof(*ioDataPtr)); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: UUrSwap_8Byte(curDataPtr); curDataPtr += 8; break; - + case TMcSwapCode_4Byte: UUrSwap_4Byte(curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: UUrSwap_2Byte(curDataPtr); curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: error = TMiGame_Instance_ByteSwap_Array( @@ -694,11 +694,11 @@ TMiGame_Instance_ByteSwap( inInstanceFile); UUmError_ReturnOnError(error); break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: error = TMiGame_Instance_ByteSwap_VarArray( @@ -709,21 +709,21 @@ TMiGame_Instance_ByteSwap( inOriginalDataPtr); UUmError_ReturnOnError(error); break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_RawPtr: UUrSwap_4Byte(curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_SeparateIndex: UUrSwap_4Byte(curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_TemplatePtr: // I think this crash means engine and data are out of sync - Michael UUmAssertReadPtr(curDataPtr, sizeof(TMtPlaceHolder)); @@ -731,22 +731,22 @@ TMiGame_Instance_ByteSwap( UUrSwap_4Byte(curDataPtr); targetPlaceHolder = *(TMtPlaceHolder*)curDataPtr; - + UUmAssert(targetPlaceHolder == 0 || !TMmPlaceHolder_IsPtr(targetPlaceHolder)); UUmAssert(targetPlaceHolder == 0 || TMmPlaceHolder_GetIndex(targetPlaceHolder) < inInstanceFile->numInstanceDescriptors); curSwapCode += 4; curDataPtr += 4; break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; - + return UUcError_None; } @@ -774,7 +774,7 @@ TMiGame_Instance_PrepareForMemory_Array( curSwapCode += 1; oneTypeArray = (*(curSwapCode + 1) == TMcSwapCode_EndArray); - + if ((*curSwapCode == TMcSwapCode_8Byte) && oneTypeArray) { curDataPtr += 8 * count; @@ -795,15 +795,15 @@ TMiGame_Instance_PrepareForMemory_Array( curDataPtr += 1 * count; curSwapCode += 2; } - else + else { UUtUns8 *oldSwapCode = curSwapCode; for(i = 0; i < count; i++) { curSwapCode = oldSwapCode; - - error = + + error = TMiGame_Instance_PrepareForMemory( &curSwapCode, &curDataPtr, @@ -813,7 +813,7 @@ TMiGame_Instance_PrepareForMemory_Array( UUmError_ReturnOnError(error); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; @@ -851,18 +851,18 @@ TMiGame_Instance_PrepareForMemory_VarArray( count = (*(UUtUns32 *)curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = (*(UUtUns16 *)curDataPtr); curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(count == 0) { TMrUtility_SkipVarArray(&curSwapCode); @@ -870,7 +870,7 @@ TMiGame_Instance_PrepareForMemory_VarArray( else { UUtBool oneElementArray = (*(curSwapCode + 1) == TMcSwapCode_EndVarArray); - + if ((*curSwapCode == TMcSwapCode_8Byte) && oneElementArray) { curDataPtr += 8 * count; @@ -891,13 +891,13 @@ TMiGame_Instance_PrepareForMemory_VarArray( curDataPtr += 1 * count; curSwapCode += 2; } - else + else { for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - - error = + + error = TMiGame_Instance_PrepareForMemory( &curSwapCode, &curDataPtr, @@ -905,7 +905,7 @@ TMiGame_Instance_PrepareForMemory_VarArray( inMsg, UUcFalse); UUmError_ReturnOnError(error); - + } } } @@ -933,43 +933,43 @@ TMiGame_Instance_PrepareForMemory( UUtUns8* curSwapCode; UUtUns8* curDataPtr; char swapCode; - + TMtPlaceHolder targetPlaceHolder; - + TMtInstanceDescriptor* targetDesc; static char msg[2048]; - + UUmAssertReadPtr(ioSwapCode, sizeof(*ioSwapCode)); UUmAssertReadPtr(ioDataPtr, sizeof(*ioDataPtr)); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: curDataPtr += 8; break; - + case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: error = TMiGame_Instance_PrepareForMemory_Array( @@ -979,11 +979,11 @@ TMiGame_Instance_PrepareForMemory( inMsg); UUmError_ReturnOnError(error); break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: if(inIsVarArrayLeaf) return UUcError_None; error = @@ -994,24 +994,24 @@ TMiGame_Instance_PrepareForMemory( inMsg); UUmError_ReturnOnError(error); break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: // I think this crash means engine and data are out of sync - Michael UUmAssertReadPtr(curDataPtr, sizeof(TMtPlaceHolder)); targetPlaceHolder = *(TMtPlaceHolder*)curDataPtr; - + if(targetPlaceHolder != 0) { UUmAssert(!TMmPlaceHolder_IsPtr(targetPlaceHolder)); - + targetDesc = TMiGame_InstanceFile_GetInstanceDesc(inInstanceFile, targetPlaceHolder); UUmAssertReadPtr(targetDesc, sizeof(*targetDesc)); - + if(targetDesc->namePtr == NULL) { if(targetDesc->dataPtr == NULL) @@ -1038,7 +1038,7 @@ TMiGame_Instance_PrepareForMemory( } if (NULL != placeholder_file) { - BFrDebugFile_Printf(placeholder_file, + BFrDebugFile_Printf(placeholder_file, "%s: could not find needed data - template %s[%s], name %s\n", inMsg, targetDesc->templatePtr->name, @@ -1049,19 +1049,19 @@ TMiGame_Instance_PrepareForMemory( #endif } } - + curSwapCode += 4; curDataPtr += 4; break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; - + return UUcError_None; } @@ -1079,28 +1079,28 @@ TMiGame_Instance_Callback( TMtTemplateTag targetTemplateTag; TMtPrivateData* targetPrivateData; void** targetInstancePtrList; - + UUmAssertReadPtr(inDataPtr, sizeof(void*)); - + TMiGame_Instance_FileAndIndex_Get( inDataPtr, &targetInstanceFile, &targetInstanceIndex); - + targetInstanceDesc = targetInstanceFile->instanceDescriptors + targetInstanceIndex; - + targetTemplateTag = targetInstanceDesc->templatePtr->tag; - + for(itrPrivateInfo = 0, curPrivateInfo = targetInstanceFile->privateInfos; itrPrivateInfo < targetInstanceFile->numPrivateInfos; itrPrivateInfo++, curPrivateInfo++) { if(curPrivateInfo->type != TMcPrivateInfo_PrivateData) continue; if(curPrivateInfo->templateTag != targetTemplateTag) continue; - + targetPrivateData = curPrivateInfo->owner; UUmAssertReadPtr(targetPrivateData, sizeof(*targetPrivateData)); - + if(curPrivateInfo->instanceListIndex != UUcMaxUns16) { UUmAssert(curPrivateInfo->instanceListIndex < targetInstanceFile->numInstancePtrLists); @@ -1110,16 +1110,16 @@ TMiGame_Instance_Callback( { targetInstancePtrList = NULL; } - + UUmAssert(targetPrivateData->procHandler != NULL); - error = + error = targetPrivateData->procHandler( inMessage, inDataPtr, targetInstancePtrList ? targetInstancePtrList[targetInstanceIndex] : NULL); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -1136,17 +1136,17 @@ TMiGame_InstanceFile_Callback( TMtTemplateTag targetTemplateTag; TMtPrivateData* targetPrivateData; void** targetInstancePtrList; - + UUmAssertReadPtr(inInstanceFile, sizeof(*inInstanceFile)); - + for(itrPrivateInfo = 0, curPrivateInfo = inInstanceFile->privateInfos; itrPrivateInfo < inInstanceFile->numPrivateInfos; itrPrivateInfo++, curPrivateInfo++) { if(curPrivateInfo->type != TMcPrivateInfo_PrivateData) continue; - + targetTemplateTag = curPrivateInfo->templateTag; - + targetPrivateData = curPrivateInfo->owner; UUmAssertReadPtr(targetPrivateData, sizeof(*targetPrivateData)); @@ -1159,7 +1159,7 @@ TMiGame_InstanceFile_Callback( { targetInstancePtrList = NULL; } - + for(curDescIndex = 0, curInstanceDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curInstanceDesc++) @@ -1168,7 +1168,7 @@ TMiGame_InstanceFile_Callback( if(curInstanceDesc->dataPtr == NULL) continue; if(targetTemplateTag != template_def->tag) continue; - + if (TMgTimeLevelLoad) { if (NULL == template_def->timer) { template_def->timer = UUrTimer_Allocate("callback", template_def->name); @@ -1176,8 +1176,8 @@ TMiGame_InstanceFile_Callback( UUrTimer_Begin(template_def->timer); } - - error = + + error = targetPrivateData->procHandler( inMessage, curInstanceDesc->dataPtr, @@ -1189,7 +1189,7 @@ TMiGame_InstanceFile_Callback( } } } - + return UUcError_None; } @@ -1201,56 +1201,56 @@ TMiGame_InstanceFile_LoadHeaderFromMemory( UUtBool needsSwapping; needsSwapping = inFileHeader->version != TMcInstanceFile_Version; - + if(needsSwapping) { UUrSwap_4Byte(&inFileHeader->version); - + if(inFileHeader->version != TMcInstanceFile_Version) { return TMcError_DataCorrupt; } - + UUrSwap_2Byte(&inFileHeader->sizeofHeader); UUrSwap_2Byte(&inFileHeader->sizeofInstanceDescriptor); UUrSwap_2Byte(&inFileHeader->sizeofTemplateDescriptor); UUrSwap_2Byte(&inFileHeader->sizeofNameDescriptor); - + UUrSwap_8Byte(&inFileHeader->totalTemplateChecksum); UUrSwap_4Byte(&inFileHeader->numInstanceDescriptors); UUrSwap_4Byte(&inFileHeader->numNameDescriptors); UUrSwap_4Byte(&inFileHeader->numTemplateDescriptors); - + UUrSwap_4Byte(&inFileHeader->dataBlockOffset); UUrSwap_4Byte(&inFileHeader->dataBlockLength); UUrSwap_4Byte(&inFileHeader->nameBlockOffset); UUrSwap_4Byte(&inFileHeader->nameBlockLength); } - + if(inFileHeader->sizeofHeader != sizeof(TMtInstanceFile_Header)) return TMcError_DataCorrupt; if(inFileHeader->sizeofInstanceDescriptor != sizeof(TMtInstanceDescriptor)) return TMcError_DataCorrupt; if(inFileHeader->sizeofTemplateDescriptor != sizeof(TMtTemplateDescriptor)) return TMcError_DataCorrupt; if(inFileHeader->sizeofNameDescriptor != sizeof(TMtNameDescriptor)) return TMcError_DataCorrupt; - + UUmAssert(inFileHeader->numNameDescriptors <= inFileHeader->numInstanceDescriptors); - UUmAssert(inFileHeader->dataBlockOffset >= - sizeof(TMtInstanceFile_Header) + - inFileHeader->numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + + UUmAssert(inFileHeader->dataBlockOffset >= + sizeof(TMtInstanceFile_Header) + + inFileHeader->numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + inFileHeader->numNameDescriptors * sizeof(TMtNameDescriptor) + inFileHeader->numTemplateDescriptors * sizeof(TMtTemplateDescriptor)); - UUmAssert(inFileHeader->nameBlockOffset >= - sizeof(TMtInstanceFile_Header) + - inFileHeader->numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + - inFileHeader->numNameDescriptors * sizeof(TMtNameDescriptor) + + UUmAssert(inFileHeader->nameBlockOffset >= + sizeof(TMtInstanceFile_Header) + + inFileHeader->numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + + inFileHeader->numNameDescriptors * sizeof(TMtNameDescriptor) + inFileHeader->numTemplateDescriptors * sizeof(TMtTemplateDescriptor) + inFileHeader->dataBlockLength); - + UUmAssert(inFileHeader->dataBlockOffset + inFileHeader->dataBlockLength <= inFileHeader->nameBlockOffset); - + *outNeedsSwapping = needsSwapping; - + return UUcError_None; } @@ -1261,8 +1261,8 @@ TMiGame_InstanceFile_LoadHeader( UUtBool *outNeedsSwapping) { UUtError error; - - error = + + error = BFrFile_ReadPos( inFile, 0, @@ -1288,13 +1288,13 @@ TMiGame_InstanceFile_PrivateInfo_New( UUtUns32 itr; UUtBool indexUsed[TMcGame_InstancePtrList_Max]; UUtUns16 targetInstanceListIndex; - + UUmAssertReadPtr(inInstanceFile, sizeof(*inInstanceFile)); UUmAssertReadPtr(inOwner, sizeof(void*)); UUmAssertReadPtr(outPrivateInfo, sizeof(*outPrivateInfo)); - + *outPrivateInfo = NULL; - + // first check to see if this private info has already has been added for(itr = 0; itr < inInstanceFile->numPrivateInfos; itr++) { @@ -1303,12 +1303,12 @@ TMiGame_InstanceFile_PrivateInfo_New( return UUcError_None; } } - + if(inInstanceFile->numPrivateInfos >= TMcGame_PrivateInfosPerInstanceFile_Max) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Exceeded max private infos per instance file"); } - + // look for a instance ptr list index if(inAllocateList) { @@ -1325,28 +1325,28 @@ TMiGame_InstanceFile_PrivateInfo_New( } } } - + for(targetInstanceListIndex = 0; targetInstanceListIndex < TMcGame_InstancePtrList_Max; targetInstanceListIndex++) { if(indexUsed[targetInstanceListIndex] == UUcFalse) break; } - + // return an error if no more slots are available if(targetInstanceListIndex == TMcGame_InstancePtrList_Max) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "no ore instance ptr lists"); } - + // allocate a new instance ptr list if needed if(targetInstanceListIndex >= inInstanceFile->numInstancePtrLists) { UUmAssert(inInstanceFile->numInstancePtrLists == targetInstanceListIndex); - + inInstanceFile->instancePtrLists[inInstanceFile->numInstancePtrLists] = UUrMemory_Block_NewClear(inInstanceFile->maxInstanceDescriptors * sizeof(void*)); - + UUmError_ReturnOnNull(inInstanceFile->instancePtrLists[inInstanceFile->numInstancePtrLists]); - + inInstanceFile->numInstancePtrLists++; } } @@ -1354,10 +1354,10 @@ TMiGame_InstanceFile_PrivateInfo_New( { targetInstanceListIndex = UUcMaxUns16; } - + // create the new private info newPrivateInfo = inInstanceFile->privateInfos + inInstanceFile->numPrivateInfos++; - + newPrivateInfo->type = inPrivateInfoType; newPrivateInfo->owner = inOwner; newPrivateInfo->templateTag = inTemplateTag; @@ -1365,7 +1365,7 @@ TMiGame_InstanceFile_PrivateInfo_New( newPrivateInfo->instanceListIndex = targetInstanceListIndex; *outPrivateInfo = newPrivateInfo; - + return UUcError_None; } @@ -1392,7 +1392,7 @@ TMiGame_InstanceFile_PrivateInfo_Delete( { UUtUns16 itrPrivateInfo; TMtInstanceFile_PrivateInfo* curPrivateInfo; - + UUmAssertReadPtr(inInstanceFile, sizeof(*inInstanceFile)); UUmAssertReadPtr(inOwner, sizeof(void*)); @@ -1401,17 +1401,17 @@ TMiGame_InstanceFile_PrivateInfo_Delete( itrPrivateInfo++, curPrivateInfo++) { if(curPrivateInfo->owner == inOwner) - { + { TMiGame_InstanceFile_PrivateInfo_Delete_ForRealThisTime(inInstanceFile, curPrivateInfo); - + UUrMemory_ArrayElement_Delete( inInstanceFile->privateInfos, itrPrivateInfo, inInstanceFile->numPrivateInfos, sizeof(TMtInstanceFile_PrivateInfo)); - + inInstanceFile->numPrivateInfos--; - + return; } } @@ -1430,11 +1430,11 @@ TMiGame_InstanceFile_PrivateData_New( UUtUns32 numInstances = 0; UUtUns8* curMemoryPtr; void** targetInstancePtrList; - + UUmAssertReadPtr(inInstanceFile, sizeof(*inInstanceFile)); UUmAssertReadPtr(inPrivateData, sizeof(*inPrivateData)); - - error = + + error = TMiGame_InstanceFile_PrivateInfo_New( inInstanceFile, TMcPrivateInfo_PrivateData, @@ -1443,22 +1443,22 @@ TMiGame_InstanceFile_PrivateData_New( inPrivateData->dataSize > 0 ? UUcTrue : UUcFalse, &newPrivateInfo); UUmError_ReturnOnError(error); - + if(inPrivateData->dataSize == 0) return UUcError_None; if(inAllocateDynamicData == UUcFalse) return UUcError_None; - + for(itr = 0, curInstanceDesc = inInstanceFile->instanceDescriptors; itr < inInstanceFile->numInstanceDescriptors; itr++, curInstanceDesc++) { if(curInstanceDesc->dataPtr == NULL) continue; - + if(curInstanceDesc->templatePtr->tag == inPrivateData->templateTag) numInstances++; } - + newPrivateInfo->memoryPool = curMemoryPtr = UUrMemory_Block_New(numInstances * inPrivateData->dataSize); UUmError_ReturnOnNull(newPrivateInfo->memoryPool); - + UUmAssert(newPrivateInfo->instanceListIndex < inInstanceFile->numInstancePtrLists); targetInstancePtrList = inInstanceFile->instancePtrLists[newPrivateInfo->instanceListIndex]; @@ -1474,7 +1474,7 @@ TMiGame_InstanceFile_PrivateData_New( curMemoryPtr += inPrivateData->dataSize; } } - + return UUcError_None; } @@ -1483,7 +1483,7 @@ TMiGame_InstanceFile_PrivateData_Delete( TMtInstanceFile* inInstanceFile, TMtPrivateData* inPrivateData) { - + UUmAssertReadPtr(inInstanceFile, sizeof(*inInstanceFile)); UUmAssertReadPtr(inPrivateData, sizeof(*inPrivateData)); @@ -1501,7 +1501,7 @@ TMiGame_InstanceFile_Dynamic_New( *outInstanceFile = NULL; - + /* * Create the instance file structure */ @@ -1509,13 +1509,13 @@ TMiGame_InstanceFile_Dynamic_New( UUmError_ReturnOnNull(newInstanceFile); UUrString_Copy(newInstanceFile->fileName, "dynamic", BFcMaxFileNameLength); - + newInstanceFile->fileIndex = inInstanceFileIndex; newInstanceFile->numInstanceDescriptors = 0; newInstanceFile->instanceDescriptors = UUrMemory_Block_NewClear(inInstance_Max * sizeof(TMtInstanceDescriptor)); UUmError_ReturnOnNull(newInstanceFile->instanceDescriptors); - + newInstanceFile->maxInstanceDescriptors = inInstance_Max; newInstanceFile->numNameDescriptors = 0; newInstanceFile->nameDescriptors = NULL; @@ -1533,12 +1533,12 @@ TMiGame_InstanceFile_Dynamic_New( newInstanceFile->dynamicBytesUsed = 0; newInstanceFile->dynamicPool = UUrMemory_Pool_New(inMemoryPool_Size, UUcPool_Fixed); UUmError_ReturnOnNull(newInstanceFile->dynamicPool); - + newInstanceFile->numInstancePtrLists = 0; newInstanceFile->numPrivateInfos = 0; - + *outInstanceFile = newInstanceFile; - + return UUcError_None; } @@ -1555,8 +1555,8 @@ TMiGame_InstanceFile_Dynamic_Reset( inInstanceFile->dynamicBytesUsed = 0; UUrMemory_Pool_Reset(inInstanceFile->dynamicPool); } - - + + static UUtError TMiGame_InstanceFile_New_FromFileRef( BFtFileRef* inInstanceFileRef, @@ -1576,13 +1576,13 @@ TMiGame_InstanceFile_New_FromFileRef( UUmAssertReadPtr(inInstanceFileRef, sizeof(void*)); *outInstanceFile = NULL; - + /* * Create the instance file structure */ newInstanceFile = (TMtInstanceFile *)UUrMemory_Block_New(sizeof(TMtInstanceFile)); UUmError_ReturnOnNull(newInstanceFile); - + /* * map the file */ @@ -1598,7 +1598,7 @@ TMiGame_InstanceFile_New_FromFileRef( error = error != UUcError_OutOfMemory ? TMcError_DataCorrupt : UUcError_OutOfMemory; UUmError_ReturnOnErrorMsg(error, "Could not open instance file"); } - + { BFtFileRef *rawFileRef; @@ -1615,7 +1615,7 @@ TMiGame_InstanceFile_New_FromFileRef( BFrFileRef_Dispose(rawFileRef); } - + { BFtFileRef *separateFileRef; @@ -1632,28 +1632,28 @@ TMiGame_InstanceFile_New_FromFileRef( fileHeader = (TMtInstanceFile_Header *) mappingPtr; error = TMiGame_InstanceFile_LoadHeaderFromMemory(fileHeader, &needsSwapping); - + UUmAssert(totalFileLength == fileHeader->nameBlockOffset + fileHeader->nameBlockLength); - + UUrString_Copy(newInstanceFile->fileName, BFrFileRef_GetLeafName(inInstanceFileRef), BFcMaxFileNameLength); - + newInstanceFile->preparedForMemory = UUcFalse; newInstanceFile->numInstanceDescriptors = newInstanceFile->maxInstanceDescriptors = fileHeader->numInstanceDescriptors; newInstanceFile->numNameDescriptors = fileHeader->numNameDescriptors; newInstanceFile->numTemplateDescriptors = 0; newInstanceFile->templateDescriptors = NULL; - + newInstanceFile->instanceDescriptors = (struct TMtInstanceDescriptor *) (mappingPtr + sizeof(TMtInstanceFile_Header)); newInstanceFile->nameDescriptors = (struct TMtNameDescriptor *) (mappingPtr + sizeof(TMtInstanceFile_Header) + newInstanceFile->numInstanceDescriptors * sizeof(TMtInstanceDescriptor)); newInstanceFile->dataBlock = (mappingPtr + fileHeader->dataBlockOffset); newInstanceFile->nameBlock = (char*)(mappingPtr + fileHeader->nameBlockOffset); newInstanceFile->dynamicBytesUsed = 0; newInstanceFile->dynamicPool = NULL; - + newInstanceFile->numInstancePtrLists = 0; newInstanceFile->numPrivateInfos = 0; - + // traverse the instance descriptors for(curDescIndex = 0, curDesc = newInstanceFile->instanceDescriptors; curDescIndex < newInstanceFile->numInstanceDescriptors; @@ -1667,25 +1667,25 @@ TMiGame_InstanceFile_New_FromFileRef( UUrSwap_4Byte(&curDesc->size); UUrSwap_4Byte(&curDesc->flags); } - + curDesc->templatePtr = TMrUtility_Template_FindDefinition((TMtTemplateTag)curDesc->templatePtr); - + UUmAssert(curDesc->templatePtr != NULL); curDesc->flags = (TMtDescriptorFlags)(curDesc->flags & TMcDescriptorFlags_PersistentMask); - + if(!(curDesc->flags & TMcDescriptorFlags_PlaceHolder)) { curDesc->dataPtr = newInstanceFile->dataBlock + (UUtUns32)curDesc->dataPtr; - + if(needsSwapping && !(curDesc->flags & TMcDescriptorFlags_Duplicate)) { UUtUns8* swapCode; UUtUns8* dataPtr; - + swapCode = curDesc->templatePtr->swapCodes; dataPtr = curDesc->dataPtr - TMcPreDataSize; - + error = TMiGame_Instance_ByteSwap(&swapCode, &dataPtr, newInstanceFile, curDesc->templatePtr->byteSwapProc, curDesc->dataPtr); UUmError_ReturnOnError(error); } @@ -1694,7 +1694,7 @@ TMiGame_InstanceFile_New_FromFileRef( { curDesc->dataPtr = NULL; } - + if(!(curDesc->flags & TMcDescriptorFlags_Unique)) { curDesc->namePtr = (char*)newInstanceFile->nameBlock + (UUtUns32)curDesc->namePtr; @@ -1704,7 +1704,7 @@ TMiGame_InstanceFile_New_FromFileRef( curDesc->namePtr = NULL; } } - + // Traverse through the name descs and update pointers for(curDescIndex = 0, curNameDesc = newInstanceFile->nameDescriptors; curDescIndex < newInstanceFile->numNameDescriptors; @@ -1714,19 +1714,19 @@ TMiGame_InstanceFile_New_FromFileRef( { UUrSwap_4Byte(&curNameDesc->instanceDescIndex); } - + UUmAssert(curNameDesc->instanceDescIndex < newInstanceFile->numInstanceDescriptors); - - curNameDesc->namePtr = + + curNameDesc->namePtr = (newInstanceFile->instanceDescriptors + curNameDesc->instanceDescIndex)->namePtr; - + UUmAssert(curNameDesc->namePtr != NULL); } - + // add the private datas to this instance file - + *outInstanceFile = newInstanceFile; - + return UUcError_None; } @@ -1736,44 +1736,44 @@ TMiGame_InstanceFile_Delete( { UUtUns16 itr; TMtInstanceFile_PrivateInfo* curPrivateInfo; - + UUmAssertReadPtr(inInstanceFile, sizeof(*inInstanceFile)); - + TMiGame_InstanceFile_Callback(inInstanceFile, TMcTemplateProcMessage_DisposePreProcess); - + for(itr = 0, curPrivateInfo = inInstanceFile->privateInfos; itr < inInstanceFile->numPrivateInfos; itr++, curPrivateInfo++) { TMiGame_InstanceFile_PrivateInfo_Delete_ForRealThisTime(inInstanceFile, curPrivateInfo); } - + for(itr = 0; itr < inInstanceFile->numInstancePtrLists; itr++) { UUrMemory_Block_Delete(inInstanceFile->instancePtrLists[itr]); } - + if(inInstanceFile->mapping != NULL) { BFrFile_UnMap(inInstanceFile->mapping); } - + if (inInstanceFile->rawMapping != NULL) { BFrFile_UnMap(inInstanceFile->rawMapping); } - + if (inInstanceFile->separateFile != NULL) { BFrFile_Close(inInstanceFile->separateFile); } - + if(inInstanceFile->dynamicPool != NULL) { UUrMemory_Pool_Delete(inInstanceFile->dynamicPool); UUrMemory_Block_Delete(inInstanceFile->instanceDescriptors); } - + UUrMemory_Block_Delete(inInstanceFile); } @@ -1783,7 +1783,7 @@ TMiGame_InstanceFile_GetInstanceDesc( TMtPlaceHolder inPlaceHolder) { UUtUns32 index; - + UUmAssertReadPtr(inInstanceFile, sizeof(*inInstanceFile)); if(TMmPlaceHolder_IsPtr(inPlaceHolder)) @@ -1793,12 +1793,12 @@ TMiGame_InstanceFile_GetInstanceDesc( else { index = TMmPlaceHolder_GetIndex(inPlaceHolder); - + UUmAssert(index < inInstanceFile->numInstanceDescriptors); - + return inInstanceFile->instanceDescriptors + index; } - + return NULL; } @@ -1806,14 +1806,14 @@ static void* TMiGame_InstanceFile_GetDataPtr( TMtInstanceFile* inInstanceFile, TMtTemplateTag inTemplateTag, - const char* inInstanceName) + const char* inInstanceName) { UUtUns32 midIndex; UUtUns32 lowIndex, highIndex; TMtNameDescriptor* curNameDesc; char buffer[BFcMaxFileNameLength * 2]; UUtInt16 compareResult; - + UUmAssertReadPtr(inInstanceFile, sizeof(*inInstanceFile)); UUmAssertReadPtr(inInstanceName, 1); UUmAssert(strlen(inInstanceName) < TMcInstanceName_MaxLength); @@ -1822,20 +1822,20 @@ TMiGame_InstanceFile_GetDataPtr( buffer[1] = (char)((inTemplateTag >> 16) & 0xFF); buffer[2] = (char)((inTemplateTag >> 8) & 0xFF); buffer[3] = (char)((inTemplateTag >> 0) & 0xFF); - + UUrString_Copy(buffer + 4, inInstanceName, BFcMaxFileNameLength * 2 - 4); - + lowIndex = 0; highIndex = inInstanceFile->numNameDescriptors; - + while(lowIndex < highIndex) { midIndex = (lowIndex + highIndex) >> 1; - + curNameDesc = inInstanceFile->nameDescriptors + midIndex; - + compareResult = strcmp(buffer, curNameDesc->namePtr); - + if(compareResult == 0) { return (inInstanceFile->instanceDescriptors + curNameDesc->instanceDescIndex)->dataPtr; @@ -1849,7 +1849,7 @@ TMiGame_InstanceFile_GetDataPtr( highIndex = midIndex; } } - + #if 0 for(itrNameDesc = 0, curNameDesc = inInstanceFile->nameDescriptors; itrNameDesc < inInstanceFile->numNameDescriptors; @@ -1859,14 +1859,14 @@ TMiGame_InstanceFile_GetDataPtr( curNameDesc->namePtr[1] != c1 || curNameDesc->namePtr[2] != c2 || curNameDesc->namePtr[3] != c3) continue; - + if(!strcmp(curNameDesc->namePtr + 4, inInstanceName)) { return (inInstanceFile->instanceDescriptors + curNameDesc->instanceDescIndex)->dataPtr; } } #endif - + return NULL; } @@ -1877,29 +1877,29 @@ TMiGame_InstanceFile_PrepareForMemory( UUtError error; UUtUns32 curDescIndex; TMtInstanceDescriptor* curDesc; - + UUtUns8* swapCode; UUtUns8* dataPtr; char msg[2048]; - + UUmAssertReadPtr(inInstanceFile, sizeof(*inInstanceFile)); - + if(inInstanceFile->preparedForMemory == UUcTrue) return UUcError_None; inInstanceFile->preparedForMemory = UUcTrue; - + for(curDescIndex = 0, curDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) { if(curDesc->templatePtr->flags & TMcTemplateFlag_Leaf) continue; - + if(curDesc->flags & TMcDescriptorFlags_Duplicate) continue; - + if(curDesc->dataPtr == NULL) continue; swapCode = curDesc->templatePtr->swapCodes; dataPtr = curDesc->dataPtr - TMcPreDataSize; - + sprintf( msg, "%s: template %s[%s], name %s", @@ -1907,8 +1907,8 @@ TMiGame_InstanceFile_PrepareForMemory( curDesc->templatePtr->name, UUrTag2Str(curDesc->templatePtr->tag), (curDesc->namePtr!=NULL) ? curDesc->namePtr + 4 : "NULL"); - - error = + + error = TMiGame_Instance_PrepareForMemory( &swapCode, &dataPtr, @@ -1917,10 +1917,10 @@ TMiGame_InstanceFile_PrepareForMemory( (curDesc->templatePtr->flags & TMcTemplateFlag_VarArrayIsLeaf) ? UUcTrue : UUcFalse); UUmError_ReturnOnError(error); } - + error = TMiGame_InstanceFile_Callback(inInstanceFile, TMcTemplateProcMessage_LoadPostProcess); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1929,7 +1929,7 @@ TMiGame_InstanceFile_GetFromIndex( UUtUns32 inInstanceFileIndex) { UUtUns16 itr; - + for(itr = 0; itr < TMgGame_LoadedInstanceFiles_Num; itr++) { if(TMgGame_LoadedInstanceFiles_List[itr]->fileIndex == inInstanceFileIndex) @@ -1937,7 +1937,7 @@ TMiGame_InstanceFile_GetFromIndex( return TMgGame_LoadedInstanceFiles_List[itr]; } } - + return NULL; } @@ -1960,64 +1960,64 @@ TMiGame_InstanceFile_Instance_Dynamic_New( void* newPrivateData; void** targetInstancePtrList; TMtPrivateData* targetPDOwner; - + UUmAssertReadPtr(inInstanceFile, sizeof(*inInstanceFile)); *outDataPtr = NULL; - + templateDef = TMrUtility_Template_FindDefinition(inTemplateTag); if(templateDef == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find template definition"); } - + if(inInstanceFile->numInstanceDescriptors >= inInstanceFile->maxInstanceDescriptors) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Out of instance descriptors"); } - + newInstanceDescIndex = inInstanceFile->numInstanceDescriptors++; newInstanceDesc = inInstanceFile->instanceDescriptors + newInstanceDescIndex; - + newInstanceDesc->templatePtr = templateDef; newInstanceDesc->namePtr = NULL; - + dataSize = templateDef->size + inInitialVarArrayLength * templateDef->varArrayElemSize; - + dataSize = (dataSize + UUcProcessor_CacheLineSize_Mask) & ~UUcProcessor_CacheLineSize_Mask; inInstanceFile->dynamicBytesUsed += dataSize; newDataPtr = UUrMemory_Pool_Block_New(inInstanceFile->dynamicPool, dataSize); UUmError_ReturnOnNull(newDataPtr); - + //UUrMemory_Set32(newDataPtr, 0xBADBADBA, dataSize); - + ((UUtUns32*)newDataPtr)[0] = TMmPlaceHolder_MakeFromIndex(newInstanceDescIndex); ((TMtInstanceFile**)newDataPtr)[1] = inInstanceFile; - + newDataPtr = newDataPtr + TMcPreDataSize; newInstanceDesc->size = dataSize; newInstanceDesc->dataPtr = newDataPtr; - + { UUtUns8* dataPtr = newDataPtr - TMcPreDataSize; UUtUns8* swapCodes = templateDef->swapCodes; - + TMrUtility_VarArrayReset_Recursive( &swapCodes, &dataPtr, inInitialVarArrayLength); } - + UUrMemory_Leak_ForceGlobal_Begin(); - + // make sure that all private datas of this template type are added to this instance file for(itr = 0; itr < TMgGame_PrivateData_Num; itr++) { if(TMgGame_PrivateData_List[itr].templateTag == inTemplateTag) { - error = + error = TMiGame_InstanceFile_PrivateData_New( inInstanceFile, TMgGame_PrivateData_List + itr, @@ -2025,34 +2025,34 @@ TMiGame_InstanceFile_Instance_Dynamic_New( UUmError_ReturnOnError(error); } } - + // allocate all the private data needed for(itrPrivateInfo = 0, curPrivateInfo = inInstanceFile->privateInfos; itrPrivateInfo < inInstanceFile->numPrivateInfos; itrPrivateInfo++, curPrivateInfo++) { if(curPrivateInfo->type != TMcPrivateInfo_PrivateData) continue; - + targetPDOwner = curPrivateInfo->owner; if(targetPDOwner->dataSize == 0) continue; - + UUmAssert(curPrivateInfo->instanceListIndex < inInstanceFile->numInstancePtrLists); targetInstancePtrList = inInstanceFile->instancePtrLists[curPrivateInfo->instanceListIndex]; - + inInstanceFile->dynamicBytesUsed += targetPDOwner->dataSize; newPrivateData = UUrMemory_Pool_Block_New( inInstanceFile->dynamicPool, targetPDOwner->dataSize); UUmError_ReturnOnNull(newPrivateData); - + targetInstancePtrList[newInstanceDescIndex] = newPrivateData; } - + UUrMemory_Leak_ForceGlobal_End(); - + *outDataPtr = newDataPtr; - + return UUcError_None; } @@ -2063,7 +2063,7 @@ TMiGame_InstanceFile_ContainsTemplate( { UUtUns32 itr; TMtInstanceDescriptor* curInstanceDesc; - + UUmAssertReadPtr(inInstanceFile, sizeof(*inInstanceFile)); for(itr = 0, curInstanceDesc = inInstanceFile->instanceDescriptors; @@ -2071,10 +2071,10 @@ TMiGame_InstanceFile_ContainsTemplate( itr++, curInstanceDesc++) { if(curInstanceDesc->dataPtr == NULL) continue; - + if(curInstanceDesc->templatePtr->tag == inTemplateTag) return UUcTrue; } - + return UUcFalse; } @@ -2085,15 +2085,15 @@ TMiGame_InstanceFile_PrivateInfo_GetDataPtr( UUtUns32 inInstanceIndex) { void** targetInstancePtrList; - + if(inPrivateInfo->instanceListIndex == UUcMaxUns16) return NULL; - + UUmAssert(inPrivateInfo->instanceListIndex < inInstanceFile->numInstancePtrLists); - + targetInstancePtrList = inInstanceFile->instancePtrLists[inPrivateInfo->instanceListIndex]; - + return targetInstancePtrList[inInstanceIndex]; -} +} static UUtError TMiGame_LoadedInstanceFiles_Add( @@ -2103,20 +2103,20 @@ TMiGame_LoadedInstanceFiles_Add( TMtInstanceFileRef* targetInstanceFileRef; TMtInstanceFile* newInstanceFile; UUtUns16 itr; - + targetInstanceFileRef = TMgGame_InstanceFileRefs_List + inInstanceFileRefIndex; - + error = TMiGame_InstanceFile_New_FromFileRef( &targetInstanceFileRef->instanceFileRef, &newInstanceFile); UUmError_ReturnOnError(error); - + newInstanceFile->fileIndex = targetInstanceFileRef->fileIndex; - + TMgGame_LoadedInstanceFiles_List[TMgGame_LoadedInstanceFiles_Num] = newInstanceFile; TMgGame_LoadedInstanceFiles_Num++; - + // loop through all the private datas and see if any applied to this instance file for(itr = 0; itr < TMgGame_PrivateData_Num; itr++) { @@ -2124,7 +2124,7 @@ TMiGame_LoadedInstanceFiles_Add( newInstanceFile, TMgGame_PrivateData_List[itr].templateTag) == UUcTrue) { - error = + error = TMiGame_InstanceFile_PrivateData_New( newInstanceFile, TMgGame_PrivateData_List + itr, @@ -2132,7 +2132,7 @@ TMiGame_LoadedInstanceFiles_Add( UUmError_ReturnOnError(error); } } - + return UUcError_None; } @@ -2142,13 +2142,13 @@ TMiGame_LoadedInstanceFiles_Remove( { UUtInt16 itr; UUtUns16 numDeleted = 0; - + for(itr = TMgGame_LoadedInstanceFiles_Num; itr-- > 0;) { if(TMmFileIndex_LevelNumber_Get(TMgGame_LoadedInstanceFiles_List[itr]->fileIndex) == inLevelNumber) { TMiGame_InstanceFile_Delete(TMgGame_LoadedInstanceFiles_List[itr]); - + if(TMgGame_LoadedInstanceFiles_Num - itr - 1 > 0) { UUrMemory_ArrayElement_Delete( @@ -2157,7 +2157,7 @@ TMiGame_LoadedInstanceFiles_Remove( TMgGame_LoadedInstanceFiles_Num, sizeof(TMtInstanceFile*)); } - + TMgGame_LoadedInstanceFiles_Num--; } } @@ -2168,7 +2168,7 @@ TMiGame_LoadedInstanceFiles_PrepareForMemory( void) { UUtUns16 itr; - + for(itr = 0; itr < TMgGame_LoadedInstanceFiles_Num; itr++) { TMiGame_InstanceFile_PrepareForMemory(TMgGame_LoadedInstanceFiles_List[itr]); @@ -2181,9 +2181,9 @@ TMiGame_LoadedInstanceFiles_PrivateData_Add( { UUtError error; UUtUns16 itr; - + UUmAssertReadPtr(inPrivateData, sizeof(*inPrivateData)); - + // loop through all the loaded files. If a file has some instances of the same template as inPrivateData // then add a private data instance file entry for(itr = 0; itr < TMgGame_LoadedInstanceFiles_Num; itr++) @@ -2193,7 +2193,7 @@ TMiGame_LoadedInstanceFiles_PrivateData_Add( inPrivateData->templateTag) == UUcTrue) { // create and add a TMtPrivateData_InstanceFile - error = + error = TMiGame_InstanceFile_PrivateData_New( TMgGame_LoadedInstanceFiles_List[itr], inPrivateData, @@ -2201,7 +2201,7 @@ TMiGame_LoadedInstanceFiles_PrivateData_Add( UUmError_ReturnOnError(error); } } - + return UUcError_None; } @@ -2211,16 +2211,16 @@ TMiGame_LoadedInstanceFiles_PrivateData_Remove( { UUtUns16 itrInstanceFile; TMtInstanceFile* curInstanceFile; - + UUmAssertReadPtr(inPrivateData, sizeof(*inPrivateData)); - + for(itrInstanceFile = 0; itrInstanceFile < TMgGame_LoadedInstanceFiles_Num; itrInstanceFile++) { curInstanceFile = TMgGame_LoadedInstanceFiles_List[itrInstanceFile]; - + TMiGame_InstanceFile_PrivateData_Delete(curInstanceFile, inPrivateData); } - + } static UUtError @@ -2237,13 +2237,13 @@ TMiGame_LoadedInstanceFiles_PrivateData_Callback( TMtInstanceDescriptor* curInstanceDesc; TMtTemplateTag targetTemplateTag; void** targetInstancePtrList; - + targetTemplateTag = inPrivateData->templateTag; for(itrInstanceFile = 0; itrInstanceFile < TMgGame_LoadedInstanceFiles_Num; itrInstanceFile++) { curInstanceFile = TMgGame_LoadedInstanceFiles_List[itrInstanceFile]; - + // check to see if this private data is in this instance file for(itrPrivateInfo = 0, curPrivateInfo = curInstanceFile->privateInfos; itrPrivateInfo < curInstanceFile->numPrivateInfos; @@ -2251,7 +2251,7 @@ TMiGame_LoadedInstanceFiles_PrivateData_Callback( { if(curPrivateInfo->owner == inPrivateData) break; } - + if(itrPrivateInfo < curInstanceFile->numPrivateInfos) { if(curPrivateInfo->instanceListIndex != UUcMaxUns16) @@ -2263,17 +2263,17 @@ TMiGame_LoadedInstanceFiles_PrivateData_Callback( { targetInstancePtrList = NULL; } - + // do the callback for(curDescIndex = 0, curInstanceDesc = curInstanceFile->instanceDescriptors; curDescIndex < curInstanceFile->numInstanceDescriptors; curDescIndex++, curInstanceDesc++) { if(curInstanceDesc->dataPtr == NULL) continue; - + if(targetTemplateTag == curInstanceDesc->templatePtr->tag) { - error = + error = inPrivateData->procHandler( inMessage, curInstanceDesc->dataPtr, @@ -2283,7 +2283,7 @@ TMiGame_LoadedInstanceFiles_PrivateData_Callback( } } } - + return UUcError_None; } @@ -2293,7 +2293,7 @@ TMiGame_InstanceFileRef_Add( UUtUns32 inInstanceFileIndex) { UUtUns16 itr; - + UUmAssertReadPtr(inInstanceFileRef, sizeof(void*)); for(itr = 0; itr < TMgGame_InstanceFileRefs_Num; itr++) @@ -2303,11 +2303,11 @@ TMiGame_InstanceFileRef_Add( UUmError_ReturnOnErrorMsg(UUcError_Generic, "Conflicting file indices"); } } - + TMgGame_InstanceFileRefs_List[TMgGame_InstanceFileRefs_Num].instanceFileRef = *inInstanceFileRef; TMgGame_InstanceFileRefs_List[TMgGame_InstanceFileRefs_Num].fileIndex = inInstanceFileIndex; TMgGame_InstanceFileRefs_Num++; - + return UUcError_None; } @@ -2318,7 +2318,7 @@ TMiGame_InstanceFileRef_LoadLevel( { UUtError error; UUtUns16 itr; - + for(itr = 0; itr < TMgGame_InstanceFileRefs_Num; itr++) { if(TMmFileIndex_LevelNumber_Get(TMgGame_InstanceFileRefs_List[itr].fileIndex) == inLevelNumber) @@ -2327,9 +2327,9 @@ TMiGame_InstanceFileRef_LoadLevel( UUmError_ReturnOnError(error); } } - + return UUcError_None; -} +} /* @@ -2349,11 +2349,11 @@ TMrGame_Initialize( UUtBool curFileLevelIsFinal; UUtUns32 curFileIndex; char curFileSuffix[BFcMaxFileNameLength]; - + // Initialize the global variables for(itr = 0; itr < TMcLevels_MaxNum; itr++) TMgGame_ValidLevels[itr] = UUcFalse; - - // Loop through each level and check to see if it is legal + + // Loop through each level and check to see if it is legal error = BFrDirectory_FileIterator_New( &TMgDataFolderRef, @@ -2366,7 +2366,7 @@ TMrGame_Initialize( return UUcFalse; } UUrStartupMessage("Created a file iterator for the data folder."); - + while(1) { BFtFileRef curDatFileRef; @@ -2390,15 +2390,15 @@ TMrGame_Initialize( if (is_tool_file) { UUrStartupMessage("skipping tool file %s", file_leaf_name); - + continue; } } } #endif - + // Get the file info - error = + error = TMrUtility_LevelInfo_Get( &curDatFileRef, &curFileLevelNum, @@ -2411,19 +2411,19 @@ TMrGame_Initialize( continue; } UUrStartupMessage("Got Level Info for %s.", BFrFileRef_GetLeafName(&curDatFileRef)); - + // Check to see if this is really a up to date level if(TMiGame_Level_IsValid(&curDatFileRef, curFileLevelNum)) { if(curFileLevelIsFinal) { UUmAssert(TMgGame_ValidLevels[curFileLevelNum] == UUcFalse); - + TMgGame_ValidLevels[curFileLevelNum] = UUcTrue; UUrStartupMessage("Valid Level %s", BFrFileRef_GetLeafName(&curDatFileRef)); } - - error = + + error = TMiGame_InstanceFileRef_Add( &curDatFileRef, curFileIndex); @@ -2434,9 +2434,9 @@ TMrGame_Initialize( UUrStartupMessage("Invalid Level %s", BFrFileRef_GetLeafName(&curDatFileRef)); } } - + BFrDirectory_FileIterator_Delete(fileIterator); - + // create the dynamic instance files #if ENABLE_TEMPORARY_INSTANCES @@ -2460,7 +2460,7 @@ TMrGame_Initialize( TMcDynamic_InstanceFileIndex_Perm, &TMgGame_DynamicInstanceFile_Perm); UUmError_ReturnOnError(error); - + #if ENABLE_TEMPORARY_INSTANCES TMgGame_LoadedInstanceFiles_List[0] = TMgGame_DynamicInstanceFile_Temp; TMgGame_LoadedInstanceFiles_List[1] = TMgGame_DynamicInstanceFile_Perm; @@ -2486,7 +2486,7 @@ TMrGame_Terminate( if (TMgGame_DynamicInstanceFile_Perm != NULL) { TMiGame_InstanceFile_Delete(TMgGame_DynamicInstanceFile_Perm); } - + TMgGame_LoadedInstanceFiles_Num = 0; TMgGame_InstanceFileRefs_Num = 0; TMgGame_PrivateData_Num = 0; @@ -2506,7 +2506,7 @@ TMrLevel_Exists( UUtUns16 inLevelNumber) { if(inLevelNumber >= TMcLevels_MaxNum) return UUcFalse; - + return TMgGame_ValidLevels[inLevelNumber]; } @@ -2517,7 +2517,7 @@ TMrLevel_Load( { UUtError error; static UUtTimerRef timer = NULL; - + if (TMgTimeLevelLoad) { if (NULL == timer) { timer = UUrTimer_Allocate("level load timer", ""); @@ -2525,29 +2525,29 @@ TMrLevel_Load( UUrTimer_Begin(timer); } - + if(TMgGame_ValidLevels[inLevelNumber] == UUcFalse) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "This level is not valid"); } - + if (TMgGame_DynamicInstanceFile_Temp != NULL) { // Reset temporary dynamic memory TMiGame_InstanceFile_Dynamic_Reset(TMgGame_DynamicInstanceFile_Temp); // XXX - Might want to do this at a "real" level load since we support multiple levels loaded simultaneously now } - + error = TMiGame_InstanceFileRef_LoadLevel(inLevelNumber, inAllowPrivateData); UUmError_ReturnOnError(error); - + // prepare for memory TMiGame_LoadedInstanceFiles_PrepareForMemory(); - + if (TMgTimeLevelLoad) { UUrTimer_End(timer); UUrTimerSystem_WriteToDisk(); } - + return UUcError_None; } @@ -2557,7 +2557,7 @@ TMrLevel_Unload( { TMiGame_LoadedInstanceFiles_Remove(inLevelNumber); } - + UUtError TMrInstance_GetDataPtr( TMtTemplateTag inTemplateTag, @@ -2565,13 +2565,13 @@ TMrInstance_GetDataPtr( void* *outDataPtr) { UUtError error; - + UUmAssertReadPtr(outDataPtr, sizeof(void*)); UUmAssertReadPtr(inInstanceName, 1); UUmAssert(strlen(inInstanceName) < TMcInstanceName_MaxLength); - + *outDataPtr = TMrInstance_GetFromName(inTemplateTag, inInstanceName); - + error = (*outDataPtr != NULL) ? UUcError_None : UUcError_Generic; return error; @@ -2581,7 +2581,7 @@ void *TMrInstance_GetFromName(TMtTemplateTag inTemplateTag, const char *inInstan { UUtUns16 itr; void *dataPtr = NULL; - + UUmAssertReadPtr(inInstanceName, 1); UUmAssert(strlen(inInstanceName) < TMcInstanceName_MaxLength); @@ -2593,7 +2593,7 @@ void *TMrInstance_GetFromName(TMtTemplateTag inTemplateTag, const char *inInstan break; } } - + return dataPtr; } @@ -2609,16 +2609,16 @@ static void TMrInstance_DataPtr_Loop(TMtTemplateTag inTemplateTag, void *inRefCo void* dataPtr; UUtUns16 itrInstanceFile; TMtInstanceFile* curInstanceFile; - + c0 = (char)((inTemplateTag >> 24) & 0xFF); c1 = (char)((inTemplateTag >> 16) & 0xFF); c2 = (char)((inTemplateTag >> 8) & 0xFF); c3 = (char)((inTemplateTag >> 0) & 0xFF); - + for(itrInstanceFile = 0; itrInstanceFile < TMgGame_LoadedInstanceFiles_Num; itrInstanceFile++) { curInstanceFile = TMgGame_LoadedInstanceFiles_List[itrInstanceFile]; - + for(itrNameDesc = 0, curNameDesc = curInstanceFile->nameDescriptors; itrNameDesc < curInstanceFile->numNameDescriptors; itrNameDesc++, curNameDesc++) @@ -2632,7 +2632,7 @@ static void TMrInstance_DataPtr_Loop(TMtTemplateTag inTemplateTag, void *inRefCo dataPtr = (curInstanceFile->instanceDescriptors + curNameDesc->instanceDescIndex)->dataPtr; - if (NULL == dataPtr) { continue; } + if (NULL == dataPtr) { continue; } continue_looping = inCallback(dataPtr, inRefCon); @@ -2771,7 +2771,7 @@ TMrInstance_Dynamic_New( { UUtError error; TMtInstanceFile* targetInstanceFile = NULL; - + if(inDynamicPoolType == TMcDynamicPool_Type_Temporary) { @@ -2785,28 +2785,28 @@ TMrInstance_Dynamic_New( { UUmAssert(!"Unknown dynamic pool type"); } - + if (targetInstanceFile == NULL) { // we cannot allocate an instance from this pool UUmAssert(!"attempted to use deprecated dynamic instance file"); return UUcError_Generic; } - error = + error = TMiGame_InstanceFile_Instance_Dynamic_New( targetInstanceFile, inTemplateTag, inInitialVarArrayLength, outDataPtr); UUmError_ReturnOnError(error); - + // Call the new callback - error = + error = TMiGame_Instance_Callback( *outDataPtr, TMcTemplateProcMessage_NewPostProcess); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2851,10 +2851,10 @@ TMrInstance_Update( void* inDataPtr) { UUtError error; - + UUmAssertReadPtr(inDataPtr, sizeof(void*)); - error = + error = TMiGame_Instance_Callback( inDataPtr, TMcTemplateProcMessage_Update); @@ -2869,15 +2869,15 @@ TMrInstance_PrepareForUse( { TMtInstanceFile* targetInstanceFile; UUtUns32 targetInstanceIndex; - + UUmAssertReadPtr(inDataPtr, sizeof(void*)); - + // mark date TMiGame_Instance_FileAndIndex_Get( inDataPtr, &targetInstanceFile, &targetInstanceIndex); - + return UUcError_None; } @@ -2887,7 +2887,7 @@ TMrInstance_GetTemplateTag( { TMtInstanceFile* targetInstanceFile; UUtUns32 targetInstanceIndex; - + TMiGame_Instance_FileAndIndex_Get( inDataPtr, &targetInstanceFile, @@ -2908,7 +2908,7 @@ TMrInstance_GetInstanceName( if (NULL == inDataPtr) { return NULL; } - + TMiGame_Instance_FileAndIndex_Get( inDataPtr, &targetInstanceFile, @@ -2925,7 +2925,7 @@ TMrInstance_GetRawOffset( const void* inDataPtr) { TMtInstanceFile* targetInstanceFile; - + TMiGame_Instance_File_Get( inDataPtr, &targetInstanceFile); @@ -2938,7 +2938,7 @@ TMrInstance_GetSeparateFile( const void* inDataPtr) { TMtInstanceFile* targetInstanceFile; - + TMiGame_Instance_File_Get( inDataPtr, &targetInstanceFile); @@ -2964,31 +2964,31 @@ TMrTemplate_PrivateData_New( UUtError error; UUtUns16 newPrivateDataIndex; TMtPrivateData* newPrivateData; - + *outPrivateData = NULL; - + UUmAssert(inProcHandler != NULL); - + if(TMgGame_PrivateData_Num >= TMcPrivateData_Max) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Too many private datas"); } - + newPrivateDataIndex = TMgGame_PrivateData_Num++; newPrivateData = TMgGame_PrivateData_List + newPrivateDataIndex; - + newPrivateData->templateTag = inTemplateTag; newPrivateData->dataSize = inDataSize; newPrivateData->procHandler = inProcHandler; - + error = TMiGame_LoadedInstanceFiles_PrivateData_Add(newPrivateData); UUmError_ReturnOnError(error); - + error = TMiGame_LoadedInstanceFiles_PrivateData_Callback(newPrivateData, TMcTemplateProcMessage_LoadPostProcess); UUmError_ReturnOnError(error); - + *outPrivateData = newPrivateData; - + return UUcError_None; } @@ -2997,24 +2997,24 @@ TMrTemplate_PrivateData_Delete( TMtPrivateData* inPrivateData) { UUtInt16 targetPrivateDataIndex; - + targetPrivateDataIndex = inPrivateData - TMgGame_PrivateData_List; - + UUmAssert(targetPrivateDataIndex >= 0); if(targetPrivateDataIndex >= TMgGame_PrivateData_Num) return; - + TMiGame_LoadedInstanceFiles_PrivateData_Callback(inPrivateData, TMcTemplateProcMessage_DisposePreProcess); TMiGame_LoadedInstanceFiles_PrivateData_Remove(inPrivateData); - + UUrMemory_ArrayElement_Delete( TMgGame_PrivateData_List, targetPrivateDataIndex, TMgGame_PrivateData_Num, sizeof(TMtPrivateData)); - + TMgGame_PrivateData_Num--; - + } void* @@ -3027,14 +3027,14 @@ TMrTemplate_PrivateData_GetDataPtr( UUtUns16 itrPrivateInfo; TMtInstanceFile_PrivateInfo* curPrivateInfo; void** targetInstancePtrList; - + if(inInstancePtr == NULL) return NULL; TMiGame_Instance_FileAndIndex_Get( inInstancePtr, &targetInstanceFile, &targetInstanceIndex); - + for(itrPrivateInfo = 0, curPrivateInfo = targetInstanceFile->privateInfos; itrPrivateInfo < targetInstanceFile->numPrivateInfos; itrPrivateInfo++, curPrivateInfo++) @@ -3042,15 +3042,15 @@ TMrTemplate_PrivateData_GetDataPtr( if(curPrivateInfo->owner == inPrivateData) { if(inPrivateData->dataSize == 0) return NULL; - + UUmAssert(curPrivateInfo->instanceListIndex < targetInstanceFile->numInstancePtrLists); targetInstancePtrList = targetInstanceFile->instancePtrLists[curPrivateInfo->instanceListIndex]; - + return targetInstancePtrList[targetInstanceIndex]; } } - + UUmAssert(0); - + return NULL; } diff --git a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Private.h b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Private.h index 9154f47..ca26a32 100644 --- a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TM_Private.h @@ -1,12 +1,12 @@ /* FILE: BFW_TM_Private.h - + AUTHOR: Brent H. Pease - + CREATED: June 17, 1997 - + PURPOSE: This is shared between BFW_TemplateManager.c and the template extractor - + Copyright 1997 */ @@ -42,10 +42,10 @@ typedef struct TMtInstanceFile TMtInstanceFile; */ typedef enum TMtSwapCode { - TMcSwapCode_8Byte = 1, - TMcSwapCode_4Byte, - TMcSwapCode_2Byte, - TMcSwapCode_1Byte, + TMcSwapCode_8Byte = 1, + TMcSwapCode_4Byte, + TMcSwapCode_2Byte, + TMcSwapCode_1Byte, TMcSwapCode_BeginArray, // Begin fixed length array TMcSwapCode_EndArray, // End fixed length array TMcSwapCode_BeginVarArray, // Begin variable length array @@ -66,14 +66,14 @@ typedef struct TMtInstanceFile TMtInstanceFile; TMcDescriptorFlags_PlaceHolder = (1 << 1), TMcDescriptorFlags_Duplicate = (1 << 2), // This instance does not point to its own data - it points to its duplicates TMcDescriptorFlags_DuplicatedSrc = (1 << 3), // This instance is being used by duplicate instances as a source - + /* These are not saved */ TMcDescriptorFlags_Touched = (1 << 20), TMcDescriptorFlags_InBatchFile = (1 << 21), TMcDescriptorFlags_DeleteMe = (1 << 22), - + TMcDescriptorFlags_PersistentMask = 0xFFFF - + } TMtDescriptorFlags; /* @@ -84,7 +84,7 @@ typedef struct TMtInstanceFile TMtInstanceFile; UUtUns64 checksum; // The checksum at the time instance file was created TMtTemplateTag tag; // The tag of the template UUtUns32 numUsed; // The number of instances that use this template - + } TMtTemplateDescriptor; /* @@ -96,9 +96,9 @@ typedef struct TMtInstanceFile TMtInstanceFile; UUtUns8* dataPtr; char* namePtr; UUtUns32 size; // This is the total size including entire var array that is written to disk - TMtDescriptorFlags flags; + TMtDescriptorFlags flags; } TMtInstanceDescriptor; - + typedef struct TMtNameDescriptor { UUtUns32 instanceDescIndex; @@ -125,12 +125,12 @@ typedef struct TMtInstanceFile TMtInstanceFile; UUtUns32 dataBlockOffset; UUtUns32 dataBlockLength; - + UUtUns32 nameBlockOffset; UUtUns32 nameBlockLength; - + UUtUns32 pad2[4]; - + } TMtInstanceFile_Header; extern UUtBool TMgInGame; diff --git a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TemplateManager.c b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TemplateManager.c index 8455193..9fa1db0 100644 --- a/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TemplateManager.c +++ b/BungieFrameWork/BFW_Source/BFW_TemplateManager/BFW_TemplateManager.c @@ -1,16 +1,16 @@ /* FILE: BFW_TemplateManager.c - + AUTHOR: Brent H. Pease - + CREATED: June 8, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 WARNING: Leave this evil place! Go! Run! Do not look back! - + However, if you stay there is a moral to be learned. Never try to rewrite something really complex in a day. */ @@ -60,7 +60,7 @@ UUtMemory_String* gTemplateNameAlloced = NULL; /* * pre instance data memory map - + -1: Place holder -2: Ptr to instance file -3: Ptr to dynamic data <- To go away @@ -75,7 +75,7 @@ UUtMemory_String* gTemplateNameAlloced = NULL; */ #define TMmInstanceData_GetInstanceFile(instanceDataPtr) \ (*((TMtInstanceFile**)instanceDataPtr - 2)) - + /* * Get the place holder of this instance */ @@ -98,21 +98,21 @@ UUtMemory_String* gTemplateNameAlloced = NULL; #define TMmInstanceDesc_Verify(instanceDesc) \ UUmAssert(instanceDesc->templatePtr->checksum == instanceDesc->checksum) - + #define TMmInstanceFile_Verify(instanceFile) \ UUmAssert(instanceFile->magicCookie == TMcMagicCookie) - + #define TMmTemplatePtr_Verify(templatePtr) \ UUmAssert(templatePtr->magicCookie == TMcMagicCookie) - + #define TMmInstanceData_Verify(dataPtr) \ UUmAssert(NULL != ((void *) dataPtr)); \ UUmAssertAlignedPtr(dataPtr); \ UUmAssert(TMmInstanceData_GetTemplateDefinition(dataPtr)->magicCookie == TMcMagicCookie); \ UUmAssert(TMmInstanceData_GetMagicCookie(dataPtr) == TMcMagicCookie) - + #define TMmInstanceFile_VerifyAllTouched(instanceFile) TMiInstanceFile_VerifyAllTouched(instanceFile) - + #else #define TMmInstanceDesc_Verify(instanceDataPtr) @@ -126,10 +126,10 @@ UUtMemory_String* gTemplateNameAlloced = NULL; #if defined(DEBUGGING) && DEBUGGING && !(defined(TMmBrentSucks) && TMmBrentSucks) #define TMmInstanceFile_MajorCheck(instanceFile, absolutePlaceHolder) TMiInstanceFile_MajorCheck(instanceFile, absolutePlaceHolder) - + #else - #define TMmInstanceFile_MajorCheck(instanceFile, absolutePlaceHolder) + #define TMmInstanceFile_MajorCheck(instanceFile, absolutePlaceHolder) #endif @@ -143,14 +143,14 @@ UUtMemory_String* gTemplateNameAlloced = NULL; TMcDescriptorFlags_PlaceHolder = (1 << 1), TMcDescriptorFlags_Duplicate = (1 << 2), // This instance does not point to its own data - it points to its duplicates TMcDescriptorFlags_DuplicatedSrc = (1 << 3), // This instance is being used by duplicate instances as a source - + /* These are not saved */ TMcDescriptorFlags_Touched = (1 << 20), TMcDescriptorFlags_InBatchFile = (1 << 21), TMcDescriptorFlags_DeleteMe = (1 << 22) - + } TMtDescriptorFlags; - + #define TMcFlags_PersistentMask (0xFFFF) /* @@ -161,13 +161,13 @@ typedef struct TMtTemplate_ConstructionData { UUtUns32 numInstancesUsed; UUtUns32 totalSizeOfAllInstances; - + UUtUns32 nextInstanceIndex; UUtUns32 instanceIndexList[TMcMaxInstancesPerTemplate]; - + UUtUns32 numInstancesRemoved; UUtUns32 removedSize; - + } TMtTemplate_ConstructionData; @@ -179,7 +179,7 @@ typedef struct TMtTemplate_ConstructionData UUtUns64 checksum; // The checksum at the time instance file was created TMtTemplateTag tag; // The tag of the template UUtUns32 numUsed; // The number of instances that use this template - + } TMtTemplateDescriptor; /* @@ -194,53 +194,53 @@ typedef struct TMtTemplate_ConstructionData UUtUns32 size; // This is the total size including entire var array that is written to disk TMtDescriptorFlags flags; UUtUns32 creationDate; // in seconds since 1900 - + } TMtInstanceDescriptor; - + typedef struct TMtNameDescriptor { UUtUns32 instanceDescIndex; char* namePtr; - + char pad[24]; } TMtNameDescriptor; - + /* * This is the instance file */ typedef struct TMtInstanceFile { char fileName[BFcMaxFileNameLength]; - + BFtFileRef* instanceFileRef; - + UUtUns32 numInstanceDescriptors; TMtInstanceDescriptor* instanceDescriptors; - + UUtUns32 numNameDescriptors; TMtNameDescriptor* nameDescriptors; // Used for binary search - + UUtUns32 numTemplateDescriptors; TMtTemplateDescriptor* templateDescriptors; - + void* allocBlock; // The pointer which is used to alloc entire disk data BFtFileMapping* mapping; // if file mapping is used - + UUtUns32 dataBlockLength; void* dataBlock; UUtUns32 nameBlockLength; char* nameBlock; - + void* dynamicMemory; - + UUtBool final; - + #if defined(DEBUGGING) && DEBUGGING - + UUtUns32 magicCookie; - + #endif } TMtInstanceFile; @@ -261,12 +261,12 @@ typedef struct TMtInstanceFile_Header UUtUns32 dataBlockOffset; UUtUns32 dataBlockLength; - + UUtUns32 nameBlockOffset; UUtUns32 nameBlockLength; - + UUtUns32 pad2[5]; - + } TMtInstanceFile_Header; /* @@ -277,38 +277,38 @@ typedef struct TMtInstanceFile_Header void* instance; UUtUns32 cachedSize; UUtUns32 offset; - + } TMtCache_Entry; - + struct TMtCache { TMtTemplateDefinition* templatePtr; - + UUtUns32 maxNumEntries; UUtUns32 memoryPoolSize; - + TMtCacheProc_Load loadProc; TMtCacheProc_Unload unloadProc; TMtCacheProc_ComputeSize computeSizeProc; - + void** entryList; UUtMemory_Pool* memoryPool; - + }; - + struct TMtPrivateData { UUtUns32 dataSize; UUtMemory_Pool* memoryPool; }; - + /* * TMgTemplateData points to the template definition data loaded from template.dat * TMgTemplateNameData points to the template name data loaded from template.nam */ UUtUns8* TMgTemplateData = NULL; char* TMgTemplateNameData = NULL; - + UUtBool gInGame; /* @@ -340,23 +340,23 @@ typedef struct TMtInstanceFile_Header */ UUtUns16 TMgNumCurLevelFiles = 0; TMtInstanceFile* TMgCurLevelFiles[TMcMaxLevelDatFiles]; - + UUtUns16 TMgLevelLoadStack = 0; - + /* * Memory for dynamic instances */ UUtMemory_Pool* TMgPermPool = NULL; UUtMemory_Pool* TMgTempPool = NULL; - + TMtInstanceFile TMgPermInstanceFile; TMtInstanceFile TMgTempInstanceFile; UUtMemory_Array* TMgPermDescriptorArray = NULL; UUtMemory_Array* TMgTempDescriptorArray = NULL; - + #define TMcPermPoolChunkSize (10 * 1024 * 1024) #define TMcTempPoolChunkSize (15 * 1024 * 1024) - + #define TMcConstructionPoolChunkSize (10 * 1024 * 1024) extern UUtUns64 gTemplateChecksum; @@ -382,19 +382,19 @@ static void TMiSkipVarArray( UUtUns8* *ioSwapCode) { - + UUtBool stop; UUtUns8* curSwapCode; char swapCode; - + curSwapCode = *ioSwapCode; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: @@ -402,49 +402,49 @@ TMiSkipVarArray( case TMcSwapCode_4Byte: break; - + case TMcSwapCode_2Byte: break; - + case TMcSwapCode_1Byte: break; - + case TMcSwapCode_BeginArray: curSwapCode++; - + TMiSkipVarArray(&curSwapCode); break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: curSwapCode++; TMiSkipVarArray( &curSwapCode); break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: curSwapCode += 4; break; - + case TMcSwapCode_TemplateReference: break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; } - + #if defined(DEBUGGING) && DEBUGGING static UUtUns32 @@ -452,18 +452,18 @@ TMrPlaceHolder_GetIndex( TMtPlaceHolder inPlaceHolder) { UUtUns32 result; - + if(gInGame == UUcFalse) { UUmAssert(gConstructionFile != NULL); - + UUmAssert(!TMmPlaceHolder_IsPtr(inPlaceHolder)); } - + result = (UUtUns32)(inPlaceHolder >> 8); - + //UUmAssert(result < gConstructionFile->numInstanceDescriptors); - + return result; } @@ -476,7 +476,7 @@ TMrPlaceHolder_MakeFromIndex( UUmAssert(gConstructionFile != NULL); UUmAssert(inIndex < gConstructionFile->numInstanceDescriptors); } - + return (inIndex << 8) | (0x0001); } @@ -486,19 +486,19 @@ static TMtInstanceDescriptor* TMrPlaceHolder_GetInstanceDesc( TMtInstanceFile* inInstanceFile, TMtPlaceHolder inPlaceHolder) -{ +{ TMtInstanceDescriptor* instanceDesc; TMtPlaceHolder placeHolder; UUtUns32 index; TMmInstanceFile_Verify(inInstanceFile); - + if(TMmPlaceHolder_IsPtr(inPlaceHolder)) { TMmInstanceData_Verify(inPlaceHolder); - + placeHolder = TMmInstanceData_GetPlaceHolder(inPlaceHolder); - + UUmAssert(!TMmPlaceHolder_IsPtr(placeHolder)); index = TMmPlaceHolder_GetIndex(placeHolder); @@ -515,9 +515,9 @@ TMrPlaceHolder_GetInstanceDesc( instanceDesc = inInstanceFile->instanceDescriptors + index; } - + TMmInstanceDesc_Verify(instanceDesc); - + return instanceDesc; } @@ -525,9 +525,9 @@ static void TMrPlaceHolder_EnsureIndex( TMtPlaceHolder *ioPlaceHolder) { - + if(*ioPlaceHolder == 0) return; - + if(TMmPlaceHolder_IsPtr(*ioPlaceHolder)) { *ioPlaceHolder = TMmInstanceData_GetPlaceHolder(*ioPlaceHolder); @@ -554,18 +554,18 @@ TMiInstance_MajorCheck_Recursive( UUtUns32 count; UUtUns8 *origSwapCode; char msg[2048]; - + TMmInstanceFile_Verify(inInstanceFile); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: @@ -575,27 +575,27 @@ TMiInstance_MajorCheck_Recursive( case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: - + count = *curSwapCode++; - + origSwapCode = curSwapCode; - + UUmAssert(count < 10000); // Arbitrary number - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiInstance_MajorCheck_Recursive( &curSwapCode, &curDataPtr, @@ -604,14 +604,14 @@ TMiInstance_MajorCheck_Recursive( inMsg, inBaseDataPtr, inAbsolutePlaceHolder); - + } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -624,16 +624,16 @@ TMiInstance_MajorCheck_Recursive( count = *(UUtUns32 *)curDataPtr; curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = *(UUtUns16 *)curDataPtr; curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + if(count == 0) { TMiSkipVarArray(&curSwapCode); @@ -641,11 +641,11 @@ TMiInstance_MajorCheck_Recursive( else { origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiInstance_MajorCheck_Recursive( &curSwapCode, &curDataPtr, @@ -657,52 +657,52 @@ TMiInstance_MajorCheck_Recursive( } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: case TMcSwapCode_TemplateReference: { TMtInstanceDescriptor *targetDesc; void *targetData; - + targetData = *(void **)curDataPtr; - + if(targetData != NULL) { targetDesc = TMrPlaceHolder_GetInstanceDesc(inInstanceFile, (TMtPlaceHolder)targetData); UUmAssert(targetDesc != NULL); TMmInstanceDesc_Verify(targetDesc); - + if(inAbsolutePlaceHolder == UUcTrue) { UUmAssert(!TMmPlaceHolder_IsPtr(targetData)); } - + if(targetDesc->flags & TMcDescriptorFlags_DeleteMe) { UUmAssert(targetDesc->dataPtr == NULL); } - + if(targetDesc->dataPtr != NULL && TMmPlaceHolder_IsPtr(targetData)) { UUmAssert(!(targetDesc->flags & TMcDescriptorFlags_DeleteMe)); UUmAssert(targetDesc->dataPtr == targetData); } - + #if defined(DEBUGGING) && DEBUGGING - - if(swapCode == TMcSwapCode_TemplatePtr && + + if(swapCode == TMcSwapCode_TemplatePtr && *(TMtTemplateTag*)curSwapCode != targetDesc->templatePtr->tag) { char expectedTag[5]; char actualTag[5]; - + UUrString_Copy(expectedTag, UUrTag2Str(*(long*)curSwapCode), 5); UUrString_Copy(actualTag, UUrTag2Str(targetDesc->templatePtr->tag), 5); - + sprintf( msg, "%s: Expecting template tag %s at offset %d, instead got tag %s, name %s", @@ -713,26 +713,26 @@ TMiInstance_MajorCheck_Recursive( targetDesc->namePtr ? targetDesc->namePtr + 4 : "no name"); UUrError_Report(UUcError_Generic, msg); } - + #endif - + sprintf(msg, "%s -> Template: %s, name: %s", inMsg, UUrTag2Str(targetDesc->templatePtr->tag), targetDesc->namePtr ? targetDesc->namePtr + 4 : "no name"); - + if(!(targetDesc->flags & (TMcDescriptorFlags_PlaceHolder | TMcDescriptorFlags_DeleteMe))) { UUtUns8* swapCode; UUtUns8* dataPtr; - + UUmAssertAlignedPtr(targetDesc->dataPtr); swapCode = targetDesc->templatePtr->swapCodes; dataPtr = targetDesc->dataPtr; - + TMmInstanceData_Verify(targetDesc->dataPtr); - + TMiInstance_MajorCheck_Recursive( &swapCode, &dataPtr, @@ -754,15 +754,15 @@ TMiInstance_MajorCheck_Recursive( } } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; - + } static void @@ -771,18 +771,18 @@ TMiInstanceFile_MajorCheck( UUtBool inAbsolutePlaceHolder) { UUtUns32 curDescIndex; - + TMtInstanceDescriptor* curInstDesc; TMtNameDescriptor* curNameDesc; - + TMtPlaceHolder curPlaceHolder; UUtUns32 curIndex; UUtUns8* swapCodes; UUtUns8* dataPtr; - + char msg[2048]; - + for( curDescIndex = 0, curInstDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; @@ -792,35 +792,35 @@ TMiInstanceFile_MajorCheck( { UUmAssert(curInstDesc->flags & TMcDescriptorFlags_Unique); } - + if(curInstDesc->flags & TMcDescriptorFlags_Unique) { UUmAssert(curInstDesc->namePtr == NULL); } - + if(curInstDesc->flags & TMcDescriptorFlags_PlaceHolder) { UUmAssert(curInstDesc->dataPtr == NULL); } - + if(curInstDesc->dataPtr == NULL) { UUmAssert(curInstDesc->flags & (TMcDescriptorFlags_PlaceHolder | TMcDescriptorFlags_DeleteMe)); continue; } - + //UUmAssert(!((curInstDesc->flags & TMcDescriptorFlags_Touched) && (curInstDesc->flags & TMcDescriptorFlags_DeleteMe))); TMmInstanceData_Verify(curInstDesc->dataPtr); - + curPlaceHolder = TMmInstanceData_GetPlaceHolder(curInstDesc->dataPtr); UUmAssert(!TMmPlaceHolder_IsPtr(curPlaceHolder)); - + curIndex = curPlaceHolder >> 16; - + UUmAssert(curIndex == curDescIndex); } - + for( curDescIndex = 0, curNameDesc = inInstanceFile->nameDescriptors; curDescIndex < inInstanceFile->numNameDescriptors; @@ -830,7 +830,7 @@ TMiInstanceFile_MajorCheck( UUmAssert((inInstanceFile->instanceDescriptors + curNameDesc->instanceDescIndex)->namePtr != NULL); UUmAssert(strcmp(curNameDesc->namePtr, (inInstanceFile->instanceDescriptors + curNameDesc->instanceDescIndex)->namePtr) == 0); } - + for( curDescIndex = 0, curInstDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; @@ -838,15 +838,15 @@ TMiInstanceFile_MajorCheck( { swapCodes = curInstDesc->templatePtr->swapCodes; dataPtr = curInstDesc->dataPtr; - + if(dataPtr == NULL) continue; - + if(curInstDesc->flags & TMcDescriptorFlags_DeleteMe) continue; - + sprintf(msg, "Template: %s, name: %s", UUrTag2Str(curInstDesc->templatePtr->tag), curInstDesc->namePtr ? curInstDesc->namePtr + 4 : "no name"); - + TMiInstance_MajorCheck_Recursive( &swapCodes, &dataPtr, @@ -866,26 +866,26 @@ TMiTemplate_FindDefinition( { TMtTemplateDefinition* curTemplate = TMgTemplateDefinitionArray; UUtInt32 i; - + for(i = TMgNumTemplateDefinitions; i-- > 0;) { if(curTemplate->tag == inTemplateTag) { TMmTemplatePtr_Verify(curTemplate); - + return curTemplate; } - + curTemplate++; } - + UUrDebuggerMessage( "Could not find template %c%c%c%c", (inTemplateTag >> 24) & 0xFF, (inTemplateTag >> 16) & 0xFF, (inTemplateTag >> 8) & 0xFF, (inTemplateTag >> 0) & 0xFF); - + return NULL; } @@ -898,13 +898,13 @@ TMiTemplate_InitializePostProcess( UUtBool inNeedsSwapping) { UUtError error; - + UUtUns8 *curSwapCode; UUtBool stop; UUtUns8 count; - + stop = UUcFalse; - + curSwapCode = *ioSwapCode; while(!stop) @@ -916,24 +916,24 @@ TMiTemplate_InitializePostProcess( case TMcSwapCode_2Byte: case TMcSwapCode_1Byte: break; - + case TMcSwapCode_BeginArray: count = *curSwapCode++; - + error = TMiTemplate_InitializePostProcess( &curSwapCode, inNeedsSwapping); UUmError_ReturnOnError(error); break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: { - + switch(*curSwapCode++) { case TMcSwapCode_8Byte: @@ -941,28 +941,28 @@ TMiTemplate_InitializePostProcess( case TMcSwapCode_4Byte: break; - + case TMcSwapCode_2Byte: break; - + default: UUrError_Report(UUcError_Generic, "illegal swap code"); return UUcError_Generic; } - + error = TMiTemplate_InitializePostProcess( &curSwapCode, inNeedsSwapping); UUmError_ReturnOnError(error); - + } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: if(inNeedsSwapping) { @@ -970,18 +970,18 @@ TMiTemplate_InitializePostProcess( } curSwapCode += 4; break; - + case TMcSwapCode_TemplateReference: break; - + default: UUrError_Report(UUcError_Generic, "illegal swap code"); return UUcError_Generic; } } - + *ioSwapCode = curSwapCode; - + return UUcError_None; } @@ -995,34 +995,34 @@ TMiInstance_PrepareForDisk( TMtInstanceFile* inInstanceFile, UUtBool inRemap) { - + UUtBool stop; UUtUns8* curSwapCode; UUtUns8* curDataPtr; char swapCode; - + UUtUns32 index; - + TMtInstanceDescriptor* targetDesc; TMtPlaceHolder targetPlaceHolder; - + UUtUns8* origSwapCode; UUtUns32 count; UUtUns32 i; - + //UUmAssert(gInGame == UUcFalse); - + TMmInstanceFile_Verify(inInstanceFile); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: @@ -1032,24 +1032,24 @@ TMiInstance_PrepareForDisk( case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiInstance_PrepareForDisk( &curSwapCode, &curDataPtr, @@ -1057,11 +1057,11 @@ TMiInstance_PrepareForDisk( inRemap); } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -1074,18 +1074,18 @@ TMiInstance_PrepareForDisk( count = (*(UUtUns32 *)curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = (*(UUtUns16 *)curDataPtr); curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(count == 0) { TMiSkipVarArray( @@ -1094,11 +1094,11 @@ TMiInstance_PrepareForDisk( else { //UUmAssert(count < 160000); //artifically random number to check against large numbers - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiInstance_PrepareForDisk( &curSwapCode, &curDataPtr, @@ -1107,22 +1107,22 @@ TMiInstance_PrepareForDisk( } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplateReference: case TMcSwapCode_TemplatePtr: - + targetPlaceHolder = *(TMtPlaceHolder*)curDataPtr; - + if(targetPlaceHolder != 0) { if(TMmPlaceHolder_IsPtr(targetPlaceHolder)) { TMmInstanceData_Verify((void*)targetPlaceHolder); - + *(TMtPlaceHolder*)curDataPtr = TMmInstanceData_GetPlaceHolder(targetPlaceHolder); TMrPlaceHolder_EnsureIndex((TMtPlaceHolder*)curDataPtr); } @@ -1132,7 +1132,7 @@ TMiInstance_PrepareForDisk( UUmAssert(index < inInstanceFile->numInstanceDescriptors); } } - + if(targetPlaceHolder != 0) { targetPlaceHolder = *(TMtPlaceHolder*)curDataPtr; @@ -1140,19 +1140,19 @@ TMiInstance_PrepareForDisk( } #if defined(DEBUGGING) && DEBUGGING - + if(targetPlaceHolder != 0) { UUmAssert(!(targetDesc->flags & TMcDescriptorFlags_DeleteMe)); - + if(swapCode == TMcSwapCode_TemplatePtr) { UUmAssert(targetDesc->templatePtr->tag == *(TMtTemplateTag*)curSwapCode); } } - + #endif - + if(swapCode == TMcSwapCode_TemplatePtr) { curSwapCode += 4; @@ -1176,7 +1176,7 @@ TMiInstance_PrepareForDisk( UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; } @@ -1188,32 +1188,32 @@ TMiInstance_Remap_Recursive( UUtUns32* inRemapArray, TMtInstanceFile* inInstanceFile) { - + UUtBool stop; UUtUns8* curSwapCode; UUtUns8* curDataPtr; char swapCode; - + TMtPlaceHolder targetPlaceHolder; TMtInstanceDescriptor* targetInstanceDesc; - + UUtUns8* origSwapCode; UUtUns32 count; UUtUns32 i; - + //UUmAssert(gInGame == UUcFalse); - + TMmInstanceFile_Verify(inInstanceFile); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: @@ -1223,24 +1223,24 @@ TMiInstance_Remap_Recursive( case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiInstance_Remap_Recursive( &curSwapCode, &curDataPtr, @@ -1248,11 +1248,11 @@ TMiInstance_Remap_Recursive( inInstanceFile); } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -1265,18 +1265,18 @@ TMiInstance_Remap_Recursive( count = (*(UUtUns32 *)curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = (*(UUtUns16 *)curDataPtr); curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(count == 0) { TMiSkipVarArray( @@ -1287,7 +1287,7 @@ TMiInstance_Remap_Recursive( for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiInstance_Remap_Recursive( &curSwapCode, &curDataPtr, @@ -1296,24 +1296,24 @@ TMiInstance_Remap_Recursive( } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplateReference: case TMcSwapCode_TemplatePtr: - + targetInstanceDesc = NULL; targetPlaceHolder = *(TMtPlaceHolder*)curDataPtr; - + if(targetPlaceHolder != 0) { if(TMmPlaceHolder_IsPtr(targetPlaceHolder)) { TMrPlaceHolder_EnsureIndex((TMtPlaceHolder*)curDataPtr); // This maps it to the correct index targetPlaceHolder = *(TMtPlaceHolder*)curDataPtr; - + targetInstanceDesc = inInstanceFile->instanceDescriptors + TMmPlaceHolder_GetIndex(targetPlaceHolder); } else @@ -1321,18 +1321,18 @@ TMiInstance_Remap_Recursive( //targetPlaceHolder is an index and needs to be remapped UUtUns32 originalIndex = TMmPlaceHolder_GetIndex(targetPlaceHolder); UUtUns32 remappedIndex = inRemapArray[originalIndex]; - + if(remappedIndex != UUcMaxUns32) { UUmAssert(remappedIndex < inInstanceFile->numInstanceDescriptors); - + *(TMtPlaceHolder*)curDataPtr = TMmPlaceHolder_MakeFromIndex(remappedIndex); } else { UUmAssert(0); } - + targetInstanceDesc = inInstanceFile->instanceDescriptors + remappedIndex; } } @@ -1342,7 +1342,7 @@ TMiInstance_Remap_Recursive( { UUmAssert(*(TMtTemplateTag*)curSwapCode == targetInstanceDesc->templatePtr->tag); } - + curSwapCode += 4; curDataPtr += 4; } @@ -1351,12 +1351,12 @@ TMiInstance_Remap_Recursive( curDataPtr += 8; } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; } @@ -1368,31 +1368,31 @@ TMiInstance_Compare_Recursive( UUtUns8* *ioDataPtrB, TMtInstanceFile* inInstanceFile) { - + UUtBool stop; UUtUns8* curSwapCode; UUtUns8* curDataPtrA; UUtUns8* curDataPtrB; char swapCode; - + UUtInt8 result; - + UUtUns8* origSwapCode; UUtUns32 count; UUtUns32 i; - + TMmInstanceFile_Verify(inInstanceFile); curSwapCode = *ioSwapCode; curDataPtrA = *ioDataPtrA; curDataPtrB = *ioDataPtrB; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: @@ -1408,30 +1408,30 @@ TMiInstance_Compare_Recursive( curDataPtrA += 4; curDataPtrB += 4; break; - + case TMcSwapCode_2Byte: if(*(UUtUns16*)curDataPtrA > *(UUtUns16*)curDataPtrB) return -1; if(*(UUtUns16*)curDataPtrA < *(UUtUns16*)curDataPtrB) return 1; curDataPtrA += 2; curDataPtrB += 2; break; - + case TMcSwapCode_1Byte: if(*(UUtUns8*)curDataPtrA > *(UUtUns8*)curDataPtrB) return -1; if(*(UUtUns8*)curDataPtrA < *(UUtUns8*)curDataPtrB) return 1; curDataPtrA += 1; curDataPtrB += 1; break; - + case TMcSwapCode_BeginArray: count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + result = TMiInstance_Compare_Recursive( &curSwapCode, &curDataPtrA, @@ -1440,11 +1440,11 @@ TMiInstance_Compare_Recursive( if(result != 0) return result; } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -1463,7 +1463,7 @@ TMiInstance_Compare_Recursive( curDataPtrA += 4; curDataPtrB += 4; break; - + case TMcSwapCode_2Byte: if(*(UUtUns16*)curDataPtrA > *(UUtUns16*)curDataPtrB) return -1; if(*(UUtUns16*)curDataPtrA < *(UUtUns16*)curDataPtrB) return 1; @@ -1471,13 +1471,13 @@ TMiInstance_Compare_Recursive( curDataPtrA += 2; curDataPtrB += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(count == 0) { TMiSkipVarArray( @@ -1488,7 +1488,7 @@ TMiInstance_Compare_Recursive( for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + result = TMiInstance_Compare_Recursive( &curSwapCode, &curDataPtrA, @@ -1498,11 +1498,11 @@ TMiInstance_Compare_Recursive( } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplateReference: case TMcSwapCode_TemplatePtr: { @@ -1510,37 +1510,37 @@ TMiInstance_Compare_Recursive( TMtPlaceHolder targetPlaceHolderB; TMtInstanceDescriptor* targetDescA; TMtInstanceDescriptor* targetDescB; - + targetPlaceHolderA = *(TMtPlaceHolder*)curDataPtrA; targetPlaceHolderB = *(TMtPlaceHolder*)curDataPtrB; - + if(targetPlaceHolderA == 0) return 1; if(targetPlaceHolderB == 0) return -1; - + targetDescA = TMrPlaceHolder_GetInstanceDesc(inInstanceFile, targetPlaceHolderA); targetDescB = TMrPlaceHolder_GetInstanceDesc(inInstanceFile, targetPlaceHolderB); - + if(targetDescA->dataPtr == NULL) return 1; if(targetDescB->dataPtr == NULL) return -1; - + if(targetDescA != targetDescB) { if(targetDescA->size > targetDescB->size) return -1; if(targetDescA->size < targetDescB->size) return 1; - + if(targetDescA->templatePtr < targetDescB->templatePtr) return -1; if(targetDescA->templatePtr > targetDescB->templatePtr) return 1; - + { UUtUns8* swapCode; UUtUns8* dataPtrA; UUtUns8* dataPtrB; - + swapCode = targetDescA->templatePtr->swapCodes; - + dataPtrA = targetDescA->dataPtr; dataPtrB = targetDescB->dataPtr; - + result = TMiInstance_Compare_Recursive( &swapCode, &dataPtrA, @@ -1549,7 +1549,7 @@ TMiInstance_Compare_Recursive( if(result != 0) return result; } } - + if(swapCode == TMcSwapCode_TemplatePtr) { curSwapCode += 4; @@ -1563,16 +1563,16 @@ TMiInstance_Compare_Recursive( } break; } - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtrA = curDataPtrA; *ioDataPtrB = curDataPtrB; - + return 0; } @@ -1585,32 +1585,32 @@ TMiInstance_NullOutDeletedRefs( UUtUns8* *ioDataPtr, TMtInstanceFile* inInstanceFile) { - + UUtBool stop; UUtUns8* curSwapCode; UUtUns8* curDataPtr; char swapCode; - + TMtInstanceDescriptor* targetDesc; TMtPlaceHolder targetPlaceHolder; - + UUtUns8* origSwapCode; UUtUns32 count; UUtUns32 i; - + UUmAssert(gInGame == UUcFalse); - + TMmInstanceFile_Verify(inInstanceFile); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: @@ -1620,35 +1620,35 @@ TMiInstance_NullOutDeletedRefs( case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiInstance_NullOutDeletedRefs( &curSwapCode, &curDataPtr, inInstanceFile); } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -1661,18 +1661,18 @@ TMiInstance_NullOutDeletedRefs( count = (*(UUtUns32 *)curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = (*(UUtUns16 *)curDataPtr); curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(count == 0) { TMiSkipVarArray( @@ -1683,7 +1683,7 @@ TMiInstance_NullOutDeletedRefs( for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiInstance_NullOutDeletedRefs( &curSwapCode, &curDataPtr, @@ -1691,26 +1691,26 @@ TMiInstance_NullOutDeletedRefs( } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplateReference: case TMcSwapCode_TemplatePtr: - + targetPlaceHolder = *(TMtPlaceHolder*)curDataPtr; - + if(targetPlaceHolder != 0) { targetDesc = TMrPlaceHolder_GetInstanceDesc(inInstanceFile, targetPlaceHolder); - + if(targetDesc->flags & TMcDescriptorFlags_DeleteMe) { *(void**)curDataPtr = NULL; } } - + if(swapCode == TMcSwapCode_TemplatePtr) { curSwapCode += 4; @@ -1721,12 +1721,12 @@ TMiInstance_NullOutDeletedRefs( curDataPtr += 8; } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; } @@ -1752,7 +1752,7 @@ TMiInstance_PrepareForMemory_Array( curSwapCode += 1; oneTypeArray = (*(curSwapCode + 1) == TMcSwapCode_EndArray); - + if ((*curSwapCode == TMcSwapCode_8Byte) && oneTypeArray) { curDataPtr += 8 * count; @@ -1773,15 +1773,15 @@ TMiInstance_PrepareForMemory_Array( curDataPtr += 1 * count; curSwapCode += 2; } - else + else { UUtUns8 *oldSwapCode = curSwapCode; for(i = 0; i < count; i++) { curSwapCode = oldSwapCode; - - error = + + error = TMiInstance_PrepareForMemory( &curSwapCode, &curDataPtr, @@ -1791,7 +1791,7 @@ TMiInstance_PrepareForMemory_Array( UUmError_ReturnOnError(error); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; @@ -1826,18 +1826,18 @@ TMiInstance_PrepareForMemory_VarArray( count = (*(UUtUns32 *)curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = (*(UUtUns16 *)curDataPtr); curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(count == 0) { TMiSkipVarArray(&curSwapCode); @@ -1845,7 +1845,7 @@ TMiInstance_PrepareForMemory_VarArray( else { UUtBool oneElementArray = (*(curSwapCode + 1) == TMcSwapCode_EndVarArray); - + if ((*curSwapCode == TMcSwapCode_8Byte) && oneElementArray) { curDataPtr += 8 * count; @@ -1866,13 +1866,13 @@ TMiInstance_PrepareForMemory_VarArray( curDataPtr += 1 * count; curSwapCode += 2; } - else + else { for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - - error = + + error = TMiInstance_PrepareForMemory( &curSwapCode, &curDataPtr, @@ -1880,7 +1880,7 @@ TMiInstance_PrepareForMemory_VarArray( inMsg, UUcFalse); UUmError_ReturnOnError(error); - + } } } @@ -1905,45 +1905,45 @@ TMiInstance_PrepareForMemory( UUtUns8* curSwapCode; UUtUns8* curDataPtr; char swapCode; - + TMtPlaceHolder targetPlaceHolder; - + TMtInstanceDescriptor* targetDesc; static char msg[2048]; - + UUmAssert(NULL != ioSwapCode); UUmAssert(NULL != ioDataPtr); - + TMmInstanceFile_Verify(inInstanceFile); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: curDataPtr += 8; break; - + case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: error = TMiInstance_PrepareForMemory_Array( &curSwapCode, @@ -1952,11 +1952,11 @@ TMiInstance_PrepareForMemory( inMsg); UUmError_ReturnOnError(error); break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: if(inIsVarArrayLeaf) return UUcError_None; error = TMiInstance_PrepareForMemory_VarArray( @@ -1966,18 +1966,18 @@ TMiInstance_PrepareForMemory( inMsg); UUmError_ReturnOnError(error); break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: case TMcSwapCode_TemplateReference: // I think this crash means engine and data are out of sync - Michael UUmAssertReadPtr(curDataPtr, sizeof(TMtPlaceHolder)); targetPlaceHolder = *(TMtPlaceHolder*)curDataPtr; - + if(targetPlaceHolder != 0) { if(!TMmPlaceHolder_IsPtr(targetPlaceHolder)) @@ -1985,7 +1985,7 @@ TMiInstance_PrepareForMemory( targetDesc = TMrPlaceHolder_GetInstanceDesc(inInstanceFile, targetPlaceHolder); UUmAssert(targetDesc != NULL); TMmInstanceDesc_Verify(targetDesc); - + if(gInGame == UUcFalse) { if(!(targetDesc->flags & TMcDescriptorFlags_PlaceHolder)) @@ -2031,7 +2031,7 @@ TMiInstance_PrepareForMemory( TMmInstanceData_Verify(targetPlaceHolder); } } - + if(swapCode == TMcSwapCode_TemplatePtr) { curSwapCode += 4; @@ -2042,15 +2042,15 @@ TMiInstance_PrepareForMemory( curDataPtr += 8; } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; - + return UUcError_None; } @@ -2073,7 +2073,7 @@ TMiInstance_ByteSwap_Array( curSwapCode += 1; oneElementArray = (*(curSwapCode + 1) == TMcSwapCode_EndArray); - + if ((*curSwapCode == TMcSwapCode_8Byte) && oneElementArray) { for(i = 0; i < count; i++) @@ -2106,15 +2106,15 @@ TMiInstance_ByteSwap_Array( curDataPtr += 1 * count; curSwapCode += 2; } - else + else { UUtUns8 *oldSwapCode = curSwapCode; for(i = 0; i < count; i++) { curSwapCode = oldSwapCode; - - error = + + error = TMiInstance_ByteSwap( &curSwapCode, &curDataPtr, @@ -2122,7 +2122,7 @@ TMiInstance_ByteSwap_Array( UUmError_ReturnOnError(error); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; @@ -2159,17 +2159,17 @@ TMiInstance_ByteSwap_VarArray( count = (*(UUtUns32 *)curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: UUrSwap_2Byte(curDataPtr); count = (*(UUtUns16 *)curDataPtr); curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + if(inByteSwapProc != NULL) { inByteSwapProc(inData); @@ -2182,7 +2182,7 @@ TMiInstance_ByteSwap_VarArray( else { UUtBool oneElementArray = (*(curSwapCode + 1) == TMcSwapCode_EndVarArray); - + if ((*curSwapCode == TMcSwapCode_8Byte) && oneElementArray) { for(i = 0; i < count; i++) @@ -2226,15 +2226,15 @@ TMiInstance_ByteSwap_VarArray( curDataPtr += 1 * count; curSwapCode += 2; } - else + else { origSwapCode = curSwapCode; for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - - error = + + error = TMiInstance_ByteSwap( &curSwapCode, &curDataPtr, @@ -2261,40 +2261,40 @@ TMiInstance_ByteSwap( UUtUns8* curSwapCode; UUtUns8* curDataPtr; char swapCode; - + UUmAssert(NULL != ioSwapCode); UUmAssert(NULL != ioDataPtr); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: UUrSwap_8Byte(curDataPtr); curDataPtr += 8; break; - + case TMcSwapCode_4Byte: UUrSwap_4Byte(curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: UUrSwap_2Byte(curDataPtr); curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: error = TMiInstance_ByteSwap_Array( @@ -2302,11 +2302,11 @@ TMiInstance_ByteSwap( &curDataPtr); UUmError_ReturnOnError(error); break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: error = TMiInstance_ByteSwap_VarArray( @@ -2316,11 +2316,11 @@ TMiInstance_ByteSwap( *ioDataPtr); UUmError_ReturnOnError(error); break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: case TMcSwapCode_TemplateReference: // I think this crash means engine and data are out of sync - Michael @@ -2339,15 +2339,15 @@ TMiInstance_ByteSwap( curDataPtr += 8; } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; - + return UUcError_None; } @@ -2367,85 +2367,85 @@ TMiInstance_Clean_Recursive( UUtUns32 i; UUtUns32 count; UUtUns8 *origSwapCode; - + UUmAssert(NULL != ioSwapCode); UUmAssert(NULL != ioDataPtr); - + TMmInstanceFile_Verify(inInstanceFile); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: #if defined(DEBUGGING) && DEBUGGING - + *(UUtUns64*)curDataPtr = UUmMemoryBlock_Garbage; - + #endif - + curDataPtr += 8; break; - + case TMcSwapCode_4Byte: #if defined(DEBUGGING) && DEBUGGING - + *(UUtUns32*)curDataPtr = UUmMemoryBlock_Garbage; - + #endif - + curDataPtr += 4; break; - + case TMcSwapCode_2Byte: #if defined(DEBUGGING) && DEBUGGING - + *(UUtUns16*)curDataPtr = (UUtUns16)UUmMemoryBlock_Garbage; - + #endif curDataPtr += 2; break; - + case TMcSwapCode_1Byte: #if defined(DEBUGGING) && DEBUGGING - + *(UUtUns8*)curDataPtr = (UUtUns8)UUmMemoryBlock_Garbage; - + #endif curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: - + count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiInstance_Clean_Recursive( &curSwapCode, &curDataPtr, inInstanceFile); - + } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -2453,21 +2453,21 @@ TMiInstance_Clean_Recursive( count = (UUtUns32) *(UUtUns64 *)curDataPtr; curDataPtr += 8; break; - + case TMcSwapCode_4Byte: count = *(UUtUns32 *)curDataPtr; curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = *(UUtUns16 *)curDataPtr; curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + if(count == 0) { TMiSkipVarArray(&curSwapCode); @@ -2475,11 +2475,11 @@ TMiInstance_Clean_Recursive( else { origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiInstance_Clean_Recursive( &curSwapCode, &curDataPtr, @@ -2487,32 +2487,32 @@ TMiInstance_Clean_Recursive( } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: case TMcSwapCode_TemplateReference: { TMtInstanceDescriptor *targetDesc; void *targetData; - + targetData = *(void **)curDataPtr; - + if(targetData != NULL) { targetDesc = TMrPlaceHolder_GetInstanceDesc(inInstanceFile, (TMtPlaceHolder)targetData); TMmInstanceDesc_Verify(targetDesc); - + if((targetDesc->flags & TMcDescriptorFlags_Unique) && targetDesc->dataPtr != NULL) { UUtUns8* swapCode; UUtUns8* dataPtr; - + swapCode = targetDesc->templatePtr->swapCodes; dataPtr = targetDesc->dataPtr; - + TMiInstance_Clean_Recursive( &swapCode, &dataPtr, @@ -2542,12 +2542,12 @@ TMiInstance_Clean_Recursive( } } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; } @@ -2569,49 +2569,49 @@ TMiInstance_CheckExists_Recursive( UUtUns32 count; UUtUns8 *origSwapCode; UUtBool result; - + UUmAssert(NULL != ioSwapCode); UUmAssert(NULL != ioDataPtr); - + TMmInstanceFile_Verify(inInstanceFile); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: curDataPtr += 8; break; - + case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: - + count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + result = TMiInstance_CheckExists_Recursive( &curSwapCode, &curDataPtr, @@ -2619,11 +2619,11 @@ TMiInstance_CheckExists_Recursive( if(result == UUcFalse) return UUcFalse; } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -2631,21 +2631,21 @@ TMiInstance_CheckExists_Recursive( count = (UUtUns32) *(UUtUns64 *)curDataPtr; curDataPtr += 8; break; - + case TMcSwapCode_4Byte: count = *(UUtUns32 *)curDataPtr; curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = *(UUtUns16 *)curDataPtr; curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + if(count == 0) { TMiSkipVarArray(&curSwapCode); @@ -2653,11 +2653,11 @@ TMiInstance_CheckExists_Recursive( else { origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + result = TMiInstance_CheckExists_Recursive( &curSwapCode, &curDataPtr, @@ -2666,44 +2666,44 @@ TMiInstance_CheckExists_Recursive( } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: case TMcSwapCode_TemplateReference: { TMtInstanceDescriptor *targetDesc; void *targetData; - + targetData = *(void **)curDataPtr; - + if(targetData != NULL) { targetDesc = TMrPlaceHolder_GetInstanceDesc(inInstanceFile, (TMtPlaceHolder)targetData); TMmInstanceDesc_Verify(targetDesc); - + if((targetDesc->flags & TMcDescriptorFlags_Unique) && targetDesc->dataPtr == NULL) { return UUcFalse; } - + if(targetDesc->dataPtr != NULL) { UUtUns8* swapCode; UUtUns8* dataPtr; - + swapCode = targetDesc->templatePtr->swapCodes; dataPtr = targetDesc->dataPtr; - + result = TMiInstance_CheckExists_Recursive( &swapCode, &dataPtr, inInstanceFile); if(result == UUcFalse) return UUcFalse; } - + } if(swapCode == TMcSwapCode_TemplatePtr) { @@ -2716,15 +2716,15 @@ TMiInstance_CheckExists_Recursive( } } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; - + return UUcTrue; } @@ -2753,7 +2753,7 @@ TMiInstance_Touch_Recursive_Array( curSwapCode += 1; oneTypeArray = (*(curSwapCode + 1) == TMcSwapCode_EndArray); - + if ((*curSwapCode == TMcSwapCode_8Byte) && oneTypeArray) { curDataPtr += 8 * count; @@ -2774,21 +2774,21 @@ TMiInstance_Touch_Recursive_Array( curDataPtr += 1 * count; curSwapCode += 2; } - else + else { UUtUns8 *oldSwapCode = curSwapCode; for(i = 0; i < count; i++) { curSwapCode = oldSwapCode; - + TMiInstance_Touch_Recursive( &curSwapCode, &curDataPtr, inInstanceFile); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; } @@ -2814,23 +2814,23 @@ TMiInstance_Touch_Recursive_VarArray( count = (UUtUns32) (*(UUtUns64 *)curDataPtr); curDataPtr += 8; break; - + case TMcSwapCode_4Byte: count = (*(UUtUns32 *)curDataPtr); curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = (*(UUtUns16 *)curDataPtr); curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(count == 0) { TMiSkipVarArray(&curSwapCode); @@ -2838,7 +2838,7 @@ TMiInstance_Touch_Recursive_VarArray( else { UUtBool oneElementArray = (*(curSwapCode + 1) == TMcSwapCode_EndVarArray); - + if ((*curSwapCode == TMcSwapCode_8Byte) && oneElementArray) { curDataPtr += 8 * count; @@ -2859,12 +2859,12 @@ TMiInstance_Touch_Recursive_VarArray( curDataPtr += 1 * count; curSwapCode += 2; } - else + else { for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiInstance_Touch_Recursive( &curSwapCode, &curDataPtr, @@ -2887,76 +2887,76 @@ TMiInstance_Touch_Recursive( UUtUns8 *curSwapCode; UUtUns8 swapCode; UUtUns8 *curDataPtr; - + TMmInstanceFile_Verify(inInstanceFile); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: curDataPtr += 8; break; - + case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: TMiInstance_Touch_Recursive_Array( &curSwapCode, &curDataPtr, inInstanceFile); break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: TMiInstance_Touch_Recursive_VarArray( &curSwapCode, &curDataPtr, inInstanceFile); break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: case TMcSwapCode_TemplateReference: { TMtInstanceDescriptor *targetDesc; void *targetData; - + targetData = *(void **)curDataPtr; - + if(targetData != NULL) { targetDesc = TMrPlaceHolder_GetInstanceDesc(inInstanceFile, (TMtPlaceHolder)targetData); UUmAssert(targetDesc != NULL); TMmInstanceDesc_Verify(targetDesc); - + if(!(targetDesc->flags & TMcDescriptorFlags_Touched)) { targetDesc->flags |= TMcDescriptorFlags_Touched; - + if(targetDesc->flags & TMcDescriptorFlags_PlaceHolder) { // Make sure a touched place holder does not get deleted @@ -2966,12 +2966,12 @@ TMiInstance_Touch_Recursive( { UUtUns8* swapCode; UUtUns8* dataPtr; - + swapCode = targetDesc->templatePtr->swapCodes; dataPtr = targetDesc->dataPtr; - + TMmInstanceData_Verify(targetDesc->dataPtr); - + TMiInstance_Touch_Recursive( &swapCode, &dataPtr, @@ -2990,15 +2990,15 @@ TMiInstance_Touch_Recursive( } } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; - + } static UUtUns32 @@ -3014,61 +3014,61 @@ TMiInstance_ComputeSize_Recursive( UUtUns32 i; UUtUns32 count; UUtUns8 *origSwapCode; - + UUtUns32 curSize = 0; - + TMmInstanceFile_Verify(inInstanceFile); - + curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: curDataPtr += 8; break; - + case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: - + count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + curSize += TMiInstance_ComputeSize_Recursive( &curSwapCode, &curDataPtr, inInstanceFile); - + } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -3076,21 +3076,21 @@ TMiInstance_ComputeSize_Recursive( count = (UUtUns32) *(UUtUns64 *)curDataPtr; curDataPtr += 8; break; - + case TMcSwapCode_4Byte: count = *(UUtUns32 *)curDataPtr; curDataPtr += 4; break; - + case TMcSwapCode_2Byte: count = *(UUtUns16 *)curDataPtr; curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + if(count == 0) { TMiSkipVarArray(&curSwapCode); @@ -3098,11 +3098,11 @@ TMiInstance_ComputeSize_Recursive( else { origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + curSize += TMiInstance_ComputeSize_Recursive( &curSwapCode, @@ -3111,11 +3111,11 @@ TMiInstance_ComputeSize_Recursive( } } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: case TMcSwapCode_TemplateReference: { @@ -3123,29 +3123,29 @@ TMiInstance_ComputeSize_Recursive( void *targetData; UUmAssertReadPtr(curDataPtr, sizeof(void *)); - + targetData = *(void **)curDataPtr; - + if(targetData != NULL) { targetDesc = TMrPlaceHolder_GetInstanceDesc(inInstanceFile, (TMtPlaceHolder)targetData); UUmAssert(targetDesc != NULL); TMmInstanceDesc_Verify(targetDesc); - + targetDesc->flags |= TMcDescriptorFlags_Touched; - + curSize += targetDesc->size; - + if(!(targetDesc->flags & TMcDescriptorFlags_PlaceHolder)) { UUtUns8* swapCode; UUtUns8* dataPtr; - + swapCode = targetDesc->templatePtr->swapCodes; dataPtr = targetDesc->dataPtr; - + TMmInstanceData_Verify(targetDesc->dataPtr); - + TMiInstance_ComputeSize_Recursive( &swapCode, &dataPtr, @@ -3163,15 +3163,15 @@ TMiInstance_ComputeSize_Recursive( } } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; - + return curSize; } @@ -3190,14 +3190,14 @@ TMiInstance_VarArray_Reset_Recursive( UUtUns32 i; UUtUns32 count; UUtUns8 *origSwapCode; - + // UUmAssert(gInGame == UUcFalse); curSwapCode = *ioSwapCode; curDataPtr = *ioDataPtr; - + stop = UUcFalse; - + while(!stop) { switch(*curSwapCode++) @@ -3205,40 +3205,40 @@ TMiInstance_VarArray_Reset_Recursive( case TMcSwapCode_8Byte: curDataPtr += 8; break; - + case TMcSwapCode_4Byte: curDataPtr += 4; break; - + case TMcSwapCode_2Byte: curDataPtr += 2; break; - + case TMcSwapCode_1Byte: curDataPtr += 1; break; - + case TMcSwapCode_BeginArray: count = *curSwapCode++; - + origSwapCode = curSwapCode; - + for(i = 0; i < count; i++) { curSwapCode = origSwapCode; - + TMiInstance_VarArray_Reset_Recursive( &curSwapCode, &curDataPtr, inInitialVarArrayLength); - + } break; - + case TMcSwapCode_EndArray: stop = UUcTrue; break; - + case TMcSwapCode_BeginVarArray: switch(*curSwapCode++) { @@ -3246,23 +3246,23 @@ TMiInstance_VarArray_Reset_Recursive( *(UUtUns64 *)curDataPtr = inInitialVarArrayLength; curDataPtr += 8; break; - + case TMcSwapCode_4Byte: *(UUtUns32 *)curDataPtr = inInitialVarArrayLength; curDataPtr += 4; break; - + case TMcSwapCode_2Byte: *(UUtUns16 *)curDataPtr = (UUtUns16)inInitialVarArrayLength; curDataPtr += 2; break; - + default: UUmDebugStr("swap codes are messed up."); } - + origSwapCode = curSwapCode; - + if(inInitialVarArrayLength > 0) { for(i = 0; i < inInitialVarArrayLength; i++) @@ -3280,27 +3280,27 @@ TMiInstance_VarArray_Reset_Recursive( TMiSkipVarArray(&curSwapCode); } break; - + case TMcSwapCode_EndVarArray: stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: *(void**)curDataPtr = NULL; curSwapCode += 4; curDataPtr += 4; break; - + case TMcSwapCode_TemplateReference: *(void**)curDataPtr = NULL; curDataPtr += 8; break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataPtr = curDataPtr; } @@ -3314,10 +3314,10 @@ TMiInstanceFile_DumpPlaceHolders( UUtUns32 curDescIndex; TMtNameDescriptor* curNameDesc; UUtUns32 numPlaceHolders = 0; - + fprintf(inFile, "Place holder dump"UUmNL); fprintf(inFile, "fileName: %s"UUmNL, BFrFileRef_GetLeafName(inInstanceFile->instanceFileRef)); - + for(curDescIndex = 0, curNameDesc = inInstanceFile->nameDescriptors; curDescIndex < inInstanceFile->numNameDescriptors; curDescIndex++, curNameDesc++) @@ -3328,7 +3328,7 @@ TMiInstanceFile_DumpPlaceHolders( numPlaceHolders++; } } - + if(numPlaceHolders > 0) { fprintf(stderr, "YO: I found %d place holders see %s for details."UUmNL, numPlaceHolders, inFileName); @@ -3343,32 +3343,32 @@ TMiInstanceFile_PrepareForMemory( UUtError error; UUtUns32 curDescIndex; TMtInstanceDescriptor* curDesc; - + UUtUns8* swapCode; UUtUns8* dataPtr; char msg[2048]; - + TMmInstanceFile_Verify(inInstanceFile); - + for(curDescIndex = 0, curDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) { if(curDesc->templatePtr->flags & TMcTemplateFlag_Leaf) continue; - + swapCode = curDesc->templatePtr->swapCodes; dataPtr = (UUtUns8 *)curDesc->dataPtr; - + if(dataPtr == NULL) continue; if (NULL == dataPtr) { UUmError_ReturnOnErrorMsgP(UUcError_Generic, "Loading, could not resolve place holder '%s'.", (UUtUns32) curDesc->namePtr, 0, 0); } - + UUmAssert(dataPtr != NULL); // && "This probably means that there is a bogus place holder..."); TMmInstanceDesc_Verify(curDesc); - + sprintf( msg, "%s: template %s[%s], name %s", @@ -3376,8 +3376,8 @@ TMiInstanceFile_PrepareForMemory( curDesc->templatePtr->name, UUrTag2Str(curDesc->templatePtr->tag), (curDesc->namePtr!=NULL) ? curDesc->namePtr + 4 : "NULL"); - - error = + + error = TMiInstance_PrepareForMemory( &swapCode, &dataPtr, @@ -3386,7 +3386,7 @@ TMiInstanceFile_PrepareForMemory( (curDesc->templatePtr->flags & TMcTemplateFlag_VarArrayIsLeaf) ? UUcTrue : UUcFalse ); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -3396,10 +3396,10 @@ TMiInstanceFile_PrepareForDisk( { UUtUns32 curDescIndex; TMtInstanceDescriptor* curDesc; - + UUtUns8* swapCode; UUtUns8* dataPtr; - + TMmInstanceFile_Verify(inInstanceFile); for(curDescIndex = 0, curDesc = inInstanceFile->instanceDescriptors; @@ -3408,18 +3408,18 @@ TMiInstanceFile_PrepareForDisk( { swapCode = curDesc->templatePtr->swapCodes; dataPtr = (UUtUns8 *)curDesc->dataPtr; - + TMmInstanceDesc_Verify(curDesc); - + if(dataPtr == NULL) continue; - + TMiInstance_PrepareForDisk( &swapCode, &dataPtr, inInstanceFile, UUcFalse); } - + return UUcError_None; } @@ -3431,24 +3431,24 @@ TMiInstanceFile_CallProcs( UUtError error; UUtUns32 curDescIndex; TMtInstanceDescriptor* curDesc; - + TMmInstanceFile_Verify(inInstanceFile); - + for(curDescIndex = 0, curDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) { TMmInstanceDesc_Verify(curDesc); - + if(curDesc->dataPtr == NULL) continue; - + if(curDesc->templatePtr->handler != NULL) { error = curDesc->templatePtr->handler(inMessage, curDesc->templatePtr->tag, curDesc->dataPtr); UUmError_ReturnOnErrorMsg(error, "Could not call proc"); } } - + return UUcError_None; } @@ -3459,7 +3459,7 @@ TMiInstanceFile_New( BFtFile* emptyFile; UUtError error; TMtInstanceFile_Header fileHeader; - + // make it an empty template file (delete, create, open, write file header goo and close) error = BFrFile_Delete(inInstanceFileRef); @@ -3471,7 +3471,7 @@ TMiInstanceFile_New( error = BFrFile_Open(inInstanceFileRef, "w", &emptyFile); UUmError_ReturnOnError(error); - + fileHeader.version = TMcInstanceFile_Version; fileHeader.totalTemplateChecksum = gTemplateChecksum; fileHeader.numInstanceDescriptors = 0; @@ -3481,16 +3481,16 @@ TMiInstanceFile_New( fileHeader.nameBlockOffset = sizeof(TMtInstanceFile_Header); fileHeader.dataBlockLength = 0; fileHeader.nameBlockLength = 0; - + // Write out endian detector error = BFrFile_WritePos(emptyFile, 0, sizeof(fileHeader), &fileHeader); UUmError_ReturnOnError(error); - + BFrFile_Close(emptyFile); return UUcError_None; } - + static UUtError TMiInstanceFile_LoadHeaderFromMemory( TMtInstanceFile_Header *inFileHeader, @@ -3499,46 +3499,46 @@ TMiInstanceFile_LoadHeaderFromMemory( UUtBool needsSwapping; needsSwapping = inFileHeader->version != TMcInstanceFile_Version; - + if(needsSwapping) { UUrSwap_4Byte(&inFileHeader->version); - + if(inFileHeader->version != TMcInstanceFile_Version) { return TMcError_DataCorrupt; } - + UUrSwap_8Byte(&inFileHeader->totalTemplateChecksum); UUrSwap_4Byte(&inFileHeader->numInstanceDescriptors); UUrSwap_4Byte(&inFileHeader->numNameDescriptors); UUrSwap_4Byte(&inFileHeader->numTemplateDescriptors); - + UUrSwap_4Byte(&inFileHeader->dataBlockOffset); UUrSwap_4Byte(&inFileHeader->dataBlockLength); UUrSwap_4Byte(&inFileHeader->nameBlockOffset); UUrSwap_4Byte(&inFileHeader->nameBlockLength); } - + UUmAssert(inFileHeader->numNameDescriptors <= inFileHeader->numInstanceDescriptors); - UUmAssert(inFileHeader->dataBlockOffset >= - sizeof(TMtInstanceFile_Header) + - inFileHeader->numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + + UUmAssert(inFileHeader->dataBlockOffset >= + sizeof(TMtInstanceFile_Header) + + inFileHeader->numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + inFileHeader->numNameDescriptors * sizeof(TMtNameDescriptor) + inFileHeader->numTemplateDescriptors * sizeof(TMtTemplateDescriptor)); - UUmAssert(inFileHeader->nameBlockOffset >= - sizeof(TMtInstanceFile_Header) + - inFileHeader->numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + - inFileHeader->numNameDescriptors * sizeof(TMtNameDescriptor) + + UUmAssert(inFileHeader->nameBlockOffset >= + sizeof(TMtInstanceFile_Header) + + inFileHeader->numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + + inFileHeader->numNameDescriptors * sizeof(TMtNameDescriptor) + inFileHeader->numTemplateDescriptors * sizeof(TMtTemplateDescriptor) + inFileHeader->dataBlockLength); - + UUmAssert(inFileHeader->dataBlockOffset + inFileHeader->dataBlockLength <= inFileHeader->nameBlockOffset); - + *outNeedsSwapping = needsSwapping; - + return UUcError_None; } @@ -3549,8 +3549,8 @@ TMiInstanceFile_LoadHeader( UUtBool *outNeedsSwapping) { UUtError error; - - error = + + error = BFrFile_ReadPos( inFile, 0, @@ -3574,13 +3574,13 @@ TMiInstanceFile_TraverseAndSet( UUtUns32 curDescIndex; TMtInstanceDescriptor* curDesc; UUtUns32 dynamicMemSize; - + TMtNameDescriptor* curNameDesc; UUrMemory_Block_VerifyList(); - + dynamicMemSize = 0; - + UUmAssertAlignedPtr(inInstanceFile->dataBlock); // Traverse through the instances and set the fields @@ -3598,13 +3598,13 @@ TMiInstanceFile_TraverseAndSet( UUrSwap_4Byte(&curDesc->creationDate); UUrSwap_8Byte(&curDesc->checksum); } - + curDesc->templatePtr = TMiTemplate_FindDefinition((TMtTemplateTag)curDesc->templatePtr); - + UUmAssert(curDesc->templatePtr != NULL); curDesc->flags = (TMtDescriptorFlags)(curDesc->flags & TMcFlags_PersistentMask); - + if(!(curDesc->flags & TMcDescriptorFlags_PlaceHolder)) { // Check for an out of date instance @@ -3614,7 +3614,7 @@ TMiInstanceFile_TraverseAndSet( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "instance checksum does not match"); } - + curDesc->dataPtr = NULL; if(curDesc->flags & TMcDescriptorFlags_Unique) { @@ -3630,15 +3630,15 @@ TMiInstanceFile_TraverseAndSet( { curDesc->dataPtr = (char*)inInstanceFile->dataBlock + (UUtUns32)curDesc->dataPtr; } - + if(inNeedsSwapping) { UUtUns8* swapCode; UUtUns8* dataPtr; - + swapCode = curDesc->templatePtr->swapCodes; dataPtr = curDesc->dataPtr; - + error = TMiInstance_ByteSwap(&swapCode, &dataPtr, curDesc->templatePtr->byteSwapProc); UUmError_ReturnOnError(error); } @@ -3647,7 +3647,7 @@ TMiInstanceFile_TraverseAndSet( { curDesc->dataPtr = NULL; } - + if(!(curDesc->flags & TMcDescriptorFlags_Unique)) { curDesc->namePtr = (char*)inInstanceFile->nameBlock + (UUtUns32)curDesc->namePtr; @@ -3656,10 +3656,10 @@ TMiInstanceFile_TraverseAndSet( { curDesc->namePtr = NULL; } - + dynamicMemSize += curDesc->templatePtr->privateDataSize; - + // this is where all the majority of the time is spent loading the file (on the PC) if(curDesc->dataPtr != NULL) { @@ -3680,15 +3680,15 @@ TMiInstanceFile_TraverseAndSet( { UUrSwap_4Byte(&curNameDesc->instanceDescIndex); } - + UUmAssert(curNameDesc->instanceDescIndex < inInstanceFile->numInstanceDescriptors); - - curNameDesc->namePtr = + + curNameDesc->namePtr = (inInstanceFile->instanceDescriptors + curNameDesc->instanceDescIndex)->namePtr; - + UUmAssert(curNameDesc->namePtr != NULL); } - + *outDynamicMemSize = dynamicMemSize; return UUcError_None; @@ -3699,26 +3699,26 @@ TMiInstanceFile_Reload_InGame( TMtInstanceFile* inInstanceFile) { UUtError error; - + BFtFile* instancePhysicalFile = NULL; UUtBool needsSwapping; - + UUtUns32 totalFileLength; - + UUtUns32 curDescIndex; TMtInstanceDescriptor* curDesc; - + UUtUns32 dynamicMemSize; char* curDynamicMemPtr; UUtUns8 *mappingPtr; - + TMtInstanceFile_Header *fileHeader; - + UUrMemory_Block_VerifyList(); TMmInstanceFile_Verify(inInstanceFile); - + /* * open the instance file data */ @@ -3741,13 +3741,13 @@ TMiInstanceFile_Reload_InGame( error = error != UUcError_OutOfMemory ? TMcError_DataCorrupt : UUcError_OutOfMemory; UUmError_ReturnOnErrorMsg(error, "Could not open instance file"); } - + UUrMemory_Block_VerifyList(); - + fileHeader = (TMtInstanceFile_Header *) mappingPtr; error = TMiInstanceFile_LoadHeaderFromMemory(fileHeader, &needsSwapping); - + UUmAssert(totalFileLength == fileHeader->nameBlockOffset + fileHeader->nameBlockLength); inInstanceFile->numInstanceDescriptors = fileHeader->numInstanceDescriptors; @@ -3758,18 +3758,18 @@ TMiInstanceFile_Reload_InGame( inInstanceFile->numTemplateDescriptors = 0; inInstanceFile->templateDescriptors = NULL; - UUrMemory_Block_VerifyList(); + UUrMemory_Block_VerifyList(); // map the stuff inInstanceFile->instanceDescriptors = (struct TMtInstanceDescriptor *) (mappingPtr + sizeof(TMtInstanceFile_Header)); inInstanceFile->nameDescriptors = (struct TMtNameDescriptor *) (mappingPtr + sizeof(TMtInstanceFile_Header) + inInstanceFile->numInstanceDescriptors * sizeof(TMtInstanceDescriptor)); inInstanceFile->dataBlock = (mappingPtr + fileHeader->dataBlockOffset); inInstanceFile->nameBlock = (char*)(mappingPtr + fileHeader->nameBlockOffset); - + /// xxxx error = TMiInstanceFile_TraverseAndSet(inInstanceFile, needsSwapping, &dynamicMemSize); UUmError_ReturnOnErrorMsg(error, "TMiInstanceFile_TraverseAndSet failed"); - + UUrMemory_Block_VerifyList(); // If in game allocate dynamic memory @@ -3780,7 +3780,7 @@ TMiInstanceFile_Reload_InGame( { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not allocate dynamic mem"); } - + for(curDescIndex = 0, curDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) @@ -3802,13 +3802,13 @@ TMiInstanceFile_Reload_InGame( curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) { - if (curDesc->dataPtr != NULL) + if (curDesc->dataPtr != NULL) { TMmInstance_GetDynamicData(curDesc->dataPtr) = NULL; } } } - + return UUcError_None; } @@ -3819,19 +3819,19 @@ TMiInstanceFile_Reload( UUtBool inOKToRebuild) { UUtError error; - + BFtFile* instancePhysicalFile = NULL; UUtBool needsSwapping; - + UUtUns32 totalFileLength; - + UUtUns32 curDescIndex; TMtInstanceDescriptor* curDesc; - + UUtUns32 dynamicMemSize; char* curDynamicMemPtr; - + TMtInstanceFile_Header fileHeader; UUmAssert(gInGame == UUcTrue ? inOKToRebuild == UUcFalse : 1); @@ -3843,7 +3843,7 @@ TMiInstanceFile_Reload( UUrMemory_Block_VerifyList(); TMmInstanceFile_Verify(inInstanceFile); - + /* * open the instance file data */ @@ -3853,17 +3853,17 @@ TMiInstanceFile_Reload( if ((error != UUcError_None) && (gInGame == UUcFalse)) { instancePhysicalFile = NULL; - + fuckingRebuild: //UUmAssert(!"Rebuilding, ok to continue"); - + inOKToRebuild = UUcFalse; - + if(instancePhysicalFile != NULL) { BFrFile_Close(instancePhysicalFile); } - + error = TMiInstanceFile_New(inInstanceFile->instanceFileRef); UUmError_ReturnOnErrorMsg(error, "Could not create instance file"); @@ -3878,27 +3878,27 @@ TMiInstanceFile_Reload( } #if defined(TMmBrentSucks) && TMmBrentSucks - + if(inOKToRebuild) goto fuckingRebuild; - + #endif - + UUrMemory_Block_VerifyList(); // Get total file length - error = + error = BFrFile_GetLength( instancePhysicalFile, &totalFileLength); UUmError_ReturnOnError(error); - + error = TMiInstanceFile_LoadHeader(instancePhysicalFile, &fileHeader, &needsSwapping); if(error != UUcError_None && inOKToRebuild && gInGame) { inOKToRebuild = UUcFalse; goto fuckingRebuild; } - + UUmAssert(totalFileLength == fileHeader.nameBlockOffset + fileHeader.nameBlockLength); inInstanceFile->numInstanceDescriptors = fileHeader.numInstanceDescriptors; @@ -3917,32 +3917,32 @@ TMiInstanceFile_Reload( { UUrMemory_Block_Delete(inInstanceFile->allocBlock); } - + inInstanceFile->allocBlock = UUrMemory_Block_New(totalFileLength - sizeof(TMtInstanceFile_Header)); if(inInstanceFile->allocBlock == NULL) { - UUmError_ReturnOnErrorMsgP(UUcError_OutOfMemory, "%s big alloc of %d", + UUmError_ReturnOnErrorMsgP(UUcError_OutOfMemory, "%s big alloc of %d", (UUtUns32) BFrFileRef_GetLeafName(inInstanceFile->instanceFileRef), totalFileLength - sizeof(TMtInstanceFile_Header), 0); } - + inInstanceFile->instanceDescriptors = (TMtInstanceDescriptor*)(inInstanceFile->allocBlock); - + inInstanceFile->nameDescriptors = - (TMtNameDescriptor*)((char*)inInstanceFile->allocBlock + + (TMtNameDescriptor*)((char*)inInstanceFile->allocBlock + inInstanceFile->numInstanceDescriptors * sizeof(TMtInstanceDescriptor)); - + inInstanceFile->dataBlock = (char*)inInstanceFile->allocBlock + fileHeader.dataBlockOffset - sizeof(TMtInstanceFile_Header); - + inInstanceFile->nameBlock = (char*)inInstanceFile->allocBlock + fileHeader.nameBlockOffset - sizeof(TMtInstanceFile_Header); } else { if(gInstanceDescriptorArray == NULL) { - gInstanceDescriptorArray = + gInstanceDescriptorArray = UUrMemory_Array_New( sizeof(TMtInstanceDescriptor), 20, @@ -3958,10 +3958,10 @@ TMiInstanceFile_Reload( error = UUrMemory_Array_SetUsedElems(gInstanceDescriptorArray, fileHeader.numInstanceDescriptors, NULL); UUmError_ReturnOnErrorMsg(error, "Could not initialize gInstanceDescriptorArray"); } - + if(gNameDescriptorArray == NULL) { - gNameDescriptorArray = + gNameDescriptorArray = UUrMemory_Array_New( sizeof(TMtNameDescriptor), 20, @@ -3977,29 +3977,29 @@ TMiInstanceFile_Reload( error = UUrMemory_Array_SetUsedElems(gNameDescriptorArray, fileHeader.numNameDescriptors, NULL); UUmError_ReturnOnErrorMsg(error, "Could not initialize gNameDescriptorArray"); } - + inInstanceFile->instanceDescriptors = UUrMemory_Array_GetMemory(gInstanceDescriptorArray); UUmAssert(inInstanceFile->instanceDescriptors != NULL); - + inInstanceFile->nameDescriptors = UUrMemory_Array_GetMemory(gNameDescriptorArray); UUmAssert(inInstanceFile->nameDescriptors != NULL); - + inInstanceFile->allocBlock = NULL; - + if(inInstanceFile->dataBlock != NULL) { UUrMemory_Block_Delete(inInstanceFile->dataBlock); inInstanceFile->dataBlock = NULL; } - + if(inInstanceFile->nameBlock != NULL) { UUrMemory_Block_Delete(inInstanceFile->nameBlock); inInstanceFile->nameBlock = NULL; } - + UUrMemory_Block_VerifyList(); - + if(inInstanceFile->dataBlockLength > 0) { inInstanceFile->dataBlock = UUrMemory_Block_New(inInstanceFile->dataBlockLength); @@ -4008,7 +4008,7 @@ TMiInstanceFile_Reload( UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not alloc data block"); } } - + if(inInstanceFile->nameBlockLength > 0) { inInstanceFile->nameBlock = UUrMemory_Block_New(inInstanceFile->nameBlockLength); @@ -4017,7 +4017,7 @@ TMiInstanceFile_Reload( UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not alloc name block"); } } - + // load the template descriptor array if(fileHeader.numTemplateDescriptors > 0) { @@ -4025,7 +4025,7 @@ TMiInstanceFile_Reload( UUmAssert(inInstanceFile->numTemplateDescriptors < TMgNumTemplateDefinitions); inInstanceFile->templateDescriptors = UUrMemory_Block_New(inInstanceFile->numTemplateDescriptors * sizeof(TMtTemplateDescriptor)); UUmError_ReturnOnNull(inInstanceFile->templateDescriptors); - error = + error = BFrFile_ReadPos( instancePhysicalFile, sizeof(TMtInstanceFile_Header) + @@ -4039,11 +4039,11 @@ TMiInstanceFile_Reload( } } } - + if(inInstanceFile->numInstanceDescriptors > 0) { //Read in the instance descriptors - error = + error = BFrFile_ReadPos( instancePhysicalFile, sizeof(TMtInstanceFile_Header), @@ -4054,12 +4054,12 @@ TMiInstanceFile_Reload( UUmError_ReturnOnErrorMsg(TMcError_DataCorrupt, "Could not read instance descs"); } } - + UUrMemory_Block_VerifyList(); if(inInstanceFile->numNameDescriptors > 0) { //Read in the name descriptors - error = + error = BFrFile_ReadPos( instancePhysicalFile, sizeof(TMtInstanceFile_Header) + inInstanceFile->numInstanceDescriptors * sizeof(TMtInstanceDescriptor), @@ -4070,12 +4070,12 @@ TMiInstanceFile_Reload( UUmError_ReturnOnErrorMsg(TMcError_DataCorrupt, "Could not read instance descs"); } } - + UUrMemory_Block_VerifyList(); if(fileHeader.dataBlockLength > 0) { //Read in the data block - error = + error = BFrFile_ReadPos( instancePhysicalFile, fileHeader.dataBlockOffset, @@ -4086,12 +4086,12 @@ TMiInstanceFile_Reload( UUmError_ReturnOnErrorMsg(TMcError_DataCorrupt, "Could not read instance descs"); } } - + UUrMemory_Block_VerifyList(); if(fileHeader.nameBlockLength > 0) { //Read in the name block - error = + error = BFrFile_ReadPos( instancePhysicalFile, fileHeader.nameBlockOffset, @@ -4102,13 +4102,13 @@ TMiInstanceFile_Reload( UUmError_ReturnOnErrorMsg(TMcError_DataCorrupt, "Could not read instance descs"); } } - + UUrMemory_Block_VerifyList(); - + /// xxxx error = TMiInstanceFile_TraverseAndSet(inInstanceFile, needsSwapping, &dynamicMemSize); - UUmError_ReturnOnErrorMsg(error, "TMiInstanceFile_TraverseAndSet failed"); - + UUmError_ReturnOnErrorMsg(error, "TMiInstanceFile_TraverseAndSet failed"); + UUrMemory_Block_VerifyList(); // If in game allocate dynamic memory @@ -4119,7 +4119,7 @@ TMiInstanceFile_Reload( { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not allocate dynamic mem"); } - + for(curDescIndex = 0, curDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) @@ -4141,20 +4141,20 @@ TMiInstanceFile_Reload( curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) { - if (curDesc->dataPtr != NULL) + if (curDesc->dataPtr != NULL) { TMmInstance_GetDynamicData(curDesc->dataPtr) = NULL; } } } - + BFrFile_Close(instancePhysicalFile); - + if(!gInGame) { TMmInstanceFile_MajorCheck(inInstanceFile, UUcTrue); } - + return UUcError_None; } @@ -4166,9 +4166,9 @@ TMiInstanceFile_MakeFromFileRef( { UUtError error; TMtInstanceFile *newInstanceFile; - + *outNewInstanceFile = NULL; - + /* * Create the instance file structure */ @@ -4178,7 +4178,7 @@ TMiInstanceFile_MakeFromFileRef( UUrError_Report(UUcError_OutOfMemory, "Could not open instance file"); return UUcError_OutOfMemory; } - + /* * Copy the instanceFileRef into the new structure */ @@ -4196,21 +4196,21 @@ TMiInstanceFile_MakeFromFileRef( newInstanceFile->nameBlockLength = 0; newInstanceFile->numInstanceDescriptors = 0; newInstanceFile->numNameDescriptors = 0; - + if(!gInGame) { gConstructionFile = newInstanceFile; } - + #if defined(DEBUGGING) && DEBUGGING - + newInstanceFile->magicCookie = TMcMagicCookie; - + #endif - + error = TMiInstanceFile_Reload(newInstanceFile, inOKToRebuild); UUmError_ReturnOnErrorMsg(error, "Could not reload file"); - + *outNewInstanceFile = newInstanceFile; return UUcError_None; @@ -4227,35 +4227,35 @@ TMiInstanceFile_RemoveIdentical_Compare( { TMtInstanceDescriptor* instanceDescA = TMgCompare_InstanceBase + inA; TMtInstanceDescriptor* instanceDescB = TMgCompare_InstanceBase + inB; - + UUmAssertReadPtr(TMgCompare_InstanceFile, sizeof(*TMgCompare_InstanceFile)); - + UUmAssert(instanceDescA->templatePtr == instanceDescB->templatePtr); - + if(TMgCompare_TemplateIndex != UUcMaxUns32) { UUtInt32 extIndex = instanceDescA->templatePtr - TMgTemplateDefinitionArray; - + UUmAssert(TMgCompare_TemplateIndex == (UUtUns32)extIndex); } - + // first compare based on size if(instanceDescA->size > instanceDescB->size) return -1; if(instanceDescA->size < instanceDescB->size) return 1; - + if(instanceDescA->dataPtr == NULL) return 1; if(instanceDescB->dataPtr == NULL) return -1; - + // next compare based on value of the data { UUtUns8* swapCode; UUtUns8* dataPtrA; UUtUns8* dataPtrB; - + swapCode = instanceDescA->templatePtr->swapCodes; dataPtrA = instanceDescA->dataPtr; dataPtrB = instanceDescB->dataPtr; - + return TMiInstance_Compare_Recursive(&swapCode, &dataPtrA, &dataPtrB, TMgCompare_InstanceFile); } } @@ -4268,7 +4268,7 @@ TMiDumpStats_Compare_InstanceCount( UUtUns32 inB) { UUmAssertReadPtr(gTemplateConstructionList, sizeof(TMtTemplateDescriptor)); - + if(gTemplateConstructionList[inA].numInstancesUsed == gTemplateConstructionList[inB].numInstancesUsed) return 0; if(gTemplateConstructionList[inA].numInstancesUsed > gTemplateConstructionList[inB].numInstancesUsed) return -1; return 1; @@ -4280,7 +4280,7 @@ TMiDumpStats_Compare_MemSize( UUtUns32 inB) { UUmAssertReadPtr(gTemplateConstructionList, sizeof(TMtTemplateDescriptor)); - + if(gTemplateConstructionList[inA].totalSizeOfAllInstances == gTemplateConstructionList[inB].totalSizeOfAllInstances) return 0; if(gTemplateConstructionList[inA].totalSizeOfAllInstances > gTemplateConstructionList[inB].totalSizeOfAllInstances) return -1; return 1; @@ -4292,7 +4292,7 @@ TMiDumpStats_Compare_NumRemoved( UUtUns32 inB) { UUmAssertReadPtr(gTemplateConstructionList, sizeof(TMtTemplateDescriptor)); - + if(gTemplateConstructionList[inA].numInstancesRemoved == gTemplateConstructionList[inB].numInstancesRemoved) return 0; if(gTemplateConstructionList[inA].numInstancesRemoved > gTemplateConstructionList[inB].numInstancesRemoved) return -1; return 1; @@ -4304,7 +4304,7 @@ TMiInstanceFile_RemoveIdentical( { TMtTemplate_ConstructionData* curTemplateData; UUtUns32 curTemplateDataIndex; - + UUtUns32 curInstanceIndex; UUtUns32 targetCheckInstanceIndex; UUtUns32 curInstanceIndexItr; @@ -4313,91 +4313,91 @@ TMiInstanceFile_RemoveIdentical( TMtInstanceDescriptor* targetCheckInstance; UUtUns32* duplicateRemapArray; TMtTemplate_ConstructionData* templateConstructionData; - + UUtUns32 numTemplateDescriptors = 0; - + UUtUns32 numTotalInstancesRemoved = 0; UUtUns32 totalRemovedSize = 0; - + UUtUns32 numNewInstances; - + UUtUns32 curNameDescIndex; TMtNameDescriptor* curNameDesc; - + TMtInstanceDescriptor* originalDescriptorList; UUtUns32* originalDuplicateDescriptorArray; - + fprintf(stderr, "Removing identical...\n"); - + TMgCompare_InstanceFile = inInstanceFile; TMgCompare_InstanceBase = inInstanceFile->instanceDescriptors; - + duplicateRemapArray = UUrMemory_Block_New(inInstanceFile->numInstanceDescriptors * sizeof(UUtInt32)); UUmError_ReturnOnNull(duplicateRemapArray); - + UUrMemory_Set32(duplicateRemapArray, UUcMaxUns32, inInstanceFile->numInstanceDescriptors * sizeof(UUtUns32)); - + templateConstructionData = UUrMemory_Block_NewClear(TMgNumTemplateDefinitions * sizeof(TMtTemplate_ConstructionData)); UUmError_ReturnOnNull(templateConstructionData); - + UUmAssertReadPtr(gInstanceDuplicateArray, sizeof(UUtUns32)); - + UUrMemory_Set32(gInstanceDuplicateArray, UUcMaxUns32, inInstanceFile->numInstanceDescriptors * sizeof(UUtUns32)); - + originalDescriptorList = UUrMemory_Block_New(inInstanceFile->numInstanceDescriptors * sizeof(TMtInstanceDescriptor)); UUmError_ReturnOnNull(originalDescriptorList); - + originalDuplicateDescriptorArray = UUrMemory_Block_New(inInstanceFile->numInstanceDescriptors * sizeof(UUtUns32)); UUmError_ReturnOnNull(originalDuplicateDescriptorArray); - + // Build the template construction data for(curInstanceIndex = 0, curInstanceDesc = inInstanceFile->instanceDescriptors; curInstanceIndex < inInstanceFile->numInstanceDescriptors; curInstanceIndex++, curInstanceDesc++) { UUtInt32 templateIndex = curInstanceDesc->templatePtr - TMgTemplateDefinitionArray; - + UUmAssert(templateIndex >= 0); UUmAssert(templateIndex < (UUtInt32)TMgNumTemplateDefinitions); templateConstructionData[templateIndex].totalSizeOfAllInstances += curInstanceDesc->size; - + if(templateConstructionData[templateIndex].numInstancesUsed >= TMcMaxInstancesPerTemplate) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Too many instances for template"); } - + templateConstructionData[templateIndex].numInstancesUsed++; - + templateConstructionData[templateIndex].instanceIndexList[templateConstructionData[templateIndex].nextInstanceIndex++] = curInstanceIndex; } - + fprintf(stderr, "\tSorting each template type"); - + // Sort the instances for each template type for(curTemplateDataIndex = 0, curTemplateData = templateConstructionData; curTemplateDataIndex < TMgNumTemplateDefinitions; curTemplateDataIndex++, curTemplateData++) { if((curTemplateDataIndex % 10) == 0) fprintf(stderr, "."); - + if(curTemplateData->nextInstanceIndex > 0) numTemplateDescriptors++; - + if(curTemplateData->nextInstanceIndex <= 1) continue; - + TMgCompare_TemplateIndex = curTemplateDataIndex; - + AUrQSort_32( curTemplateData->instanceIndexList, curTemplateData->nextInstanceIndex, TMiInstanceFile_RemoveIdentical_Compare); - + TMgCompare_TemplateIndex = UUcMaxUns32; } - + fprintf(stderr, "\n"); fprintf(stderr, "\tLooking for duplicates"); - + // now look for duplicates for(curTemplateDataIndex = 0, curTemplateData = templateConstructionData; curTemplateDataIndex < TMgNumTemplateDefinitions; @@ -4407,7 +4407,7 @@ TMiInstanceFile_RemoveIdentical( if(curTemplateData->nextInstanceIndex == 0) continue; if(!(TMgTemplateDefinitionArray[curTemplateDataIndex].flags & TMcTemplateFlag_AllowFolding)) continue; - + TMgCompare_TemplateIndex = curTemplateDataIndex; // go through the indices comparing the current one to the subsequent ones looking for identical instances @@ -4417,67 +4417,67 @@ TMiInstanceFile_RemoveIdentical( targetCheckInstanceIndexItr = curInstanceIndexItr; targetCheckInstanceIndex = curTemplateData->instanceIndexList[targetCheckInstanceIndexItr]; targetCheckInstance = inInstanceFile->instanceDescriptors + targetCheckInstanceIndex; - + // make sure the target is not already a duplicate UUmAssert(!(targetCheckInstance->flags & TMcDescriptorFlags_Duplicate)); while(++curInstanceIndexItr < curTemplateData->nextInstanceIndex) { curInstanceIndex = curTemplateData->instanceIndexList[curInstanceIndexItr]; - + if(TMiInstanceFile_RemoveIdentical_Compare( targetCheckInstanceIndex, curInstanceIndex) != 0) break; - + // we have an identical instance - + // make sure it has not beeing assigned a target instance already UUmAssert(gInstanceDuplicateArray[curInstanceIndex] == UUcMaxUns32); - + // assign this instance a source(target) gInstanceDuplicateArray[curInstanceIndex] = targetCheckInstanceIndex; // This needs to get remaped later - + // Mark the target instance as a source targetCheckInstance->flags |= TMcDescriptorFlags_DuplicatedSrc; - + // make sure the source is not a duplicate itself UUmAssert(!(targetCheckInstance->flags & TMcDescriptorFlags_Duplicate)); - + curInstanceDesc = inInstanceFile->instanceDescriptors + curInstanceIndex; - + // make sure this instance is not a source - because it is a duplicate UUmAssert(!(curInstanceDesc->flags & TMcDescriptorFlags_DuplicatedSrc)); - + // mark this instance as being a duplicate curInstanceDesc->flags |= TMcDescriptorFlags_Duplicate; - + // update some stats curTemplateData->numInstancesRemoved++; numTotalInstancesRemoved++; - + curTemplateData->removedSize += curInstanceDesc->size; - + totalRemovedSize += curInstanceDesc->size; - + UUmAssert(curTemplateData->numInstancesUsed > 0); UUmAssert(curTemplateData->totalSizeOfAllInstances > curInstanceDesc->size); - + curTemplateData->numInstancesUsed--; curTemplateData->totalSizeOfAllInstances -= curInstanceDesc->size; } } TMgCompare_TemplateIndex = UUcMaxUns32; } - + fprintf(stderr, "\n"); fprintf(stderr, "\tRemapping"); UUrMemory_MoveFast(gInstanceDuplicateArray, originalDuplicateDescriptorArray, inInstanceFile->numInstanceDescriptors * sizeof(UUtUns32)); UUrMemory_MoveFast(inInstanceFile->instanceDescriptors, originalDescriptorList, inInstanceFile->numInstanceDescriptors * sizeof(TMtInstanceDescriptor)); - + // compute the remap array and move the structures numNewInstances = 0; - + for(curInstanceIndex = 0, curInstanceDesc = originalDescriptorList; curInstanceIndex < inInstanceFile->numInstanceDescriptors; curInstanceIndex++, curInstanceDesc++) @@ -4492,7 +4492,7 @@ TMiInstanceFile_RemoveIdentical( { UUmAssert(originalDuplicateDescriptorArray[curInstanceIndex] == UUcMaxUns32); } - + if(!(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate) || curInstanceDesc->dataPtr == NULL || curInstanceDesc->namePtr != NULL) { gInstanceDuplicateArray[numNewInstances] = originalDuplicateDescriptorArray[curInstanceIndex]; @@ -4503,9 +4503,9 @@ TMiInstanceFile_RemoveIdentical( { UUmAssert(originalDuplicateDescriptorArray[curInstanceIndex] < inInstanceFile->numInstanceDescriptors); } - + } - + TMgCompare_InstanceBase = originalDescriptorList; fprintf(stderr, "\n"); @@ -4517,27 +4517,27 @@ TMiInstanceFile_RemoveIdentical( curInstanceIndex++, curInstanceDesc++) { UUtUns32 remappedInstanceIndex = duplicateRemapArray[curInstanceIndex]; - + if((curInstanceIndex % 1000) == 0) fprintf(stderr, "."); if(remappedInstanceIndex == UUcMaxUns32) { // curInstanceIndex is being deleted - + // make sure it has a duplicate UUmAssert(originalDuplicateDescriptorArray[curInstanceIndex] < inInstanceFile->numInstanceDescriptors); - + targetCheckInstance = originalDescriptorList + originalDuplicateDescriptorArray[curInstanceIndex]; - + // make sure that the duplicate flag is set UUmAssert(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate); - + // make sure its source is marked UUmAssert(targetCheckInstance->flags & TMcDescriptorFlags_DuplicatedSrc); - + // make sure it should really be deleted UUmAssert(curInstanceDesc->namePtr == NULL); - + // this deleted instance need to point to the duplicate source duplicateRemapArray[curInstanceIndex] = duplicateRemapArray[originalDuplicateDescriptorArray[curInstanceIndex]]; UUmAssert(duplicateRemapArray[curInstanceIndex] < numNewInstances); @@ -4545,32 +4545,32 @@ TMiInstanceFile_RemoveIdentical( else { // curInstanceIndex is not being deleted - + // make sure it is legal UUmAssert(remappedInstanceIndex < numNewInstances); - + // if it is a duplicate then set its dataPtr to NULL if(originalDuplicateDescriptorArray[curInstanceIndex] != UUcMaxUns32) { UUmAssert(originalDuplicateDescriptorArray[curInstanceIndex] < inInstanceFile->numInstanceDescriptors); - + // curInstanceIndex is a duplicate and it is not being deleted // screwing up tests - curInstanceDesc->dataPtr = NULL; // This gets remapped to the duplicate data later } } - + if(originalDuplicateDescriptorArray[curInstanceIndex] != UUcMaxUns32) { // curInstanceDesc has a duplicate - + targetCheckInstance = originalDescriptorList + originalDuplicateDescriptorArray[curInstanceIndex]; // make sure it is legal UUmAssert(originalDuplicateDescriptorArray[curInstanceIndex] < inInstanceFile->numInstanceDescriptors); - + // make sure its dupicate it not being deleted UUmAssert(duplicateRemapArray[originalDuplicateDescriptorArray[curInstanceIndex]] != UUcMaxUns32); - + UUmAssert(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate); // make sure its source is marked @@ -4579,14 +4579,14 @@ TMiInstanceFile_RemoveIdentical( else { // curInstanceDesc does not have a duplicate - + UUmAssert(!(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate)); } } - + UUrMemory_Array_SetUsedElems(gInstanceDescriptorArray, numNewInstances, NULL); inInstanceFile->numInstanceDescriptors = numNewInstances; - + fprintf(stderr, "\n"); fprintf(stderr, "\tUpdating place holders"); @@ -4600,22 +4600,22 @@ TMiInstanceFile_RemoveIdentical( if(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate) { UUmAssert(gInstanceDuplicateArray[curInstanceIndex] != UUcMaxUns32); - + gInstanceDuplicateArray[curInstanceIndex] = duplicateRemapArray[gInstanceDuplicateArray[curInstanceIndex]]; - + UUmAssert(gInstanceDuplicateArray[curInstanceIndex] < inInstanceFile->numInstanceDescriptors); - + } else { UUmAssert(gInstanceDuplicateArray[curInstanceIndex] == UUcMaxUns32); } - + if(curInstanceDesc->dataPtr == NULL) continue; - + TMmInstanceData_GetPlaceHolder(curInstanceDesc->dataPtr) = TMmPlaceHolder_MakeFromIndex(curInstanceIndex); } - + fprintf(stderr, "\n"); fprintf(stderr, "\tRemapping instance data"); @@ -4630,15 +4630,15 @@ TMiInstanceFile_RemoveIdentical( { UUtUns8* swapCode; UUtUns8* dataPtr; - + swapCode = curInstanceDesc->templatePtr->swapCodes; dataPtr = curInstanceDesc->dataPtr; - + TMiInstance_Remap_Recursive(&swapCode, &dataPtr, duplicateRemapArray, inInstanceFile); } } - + // do some more verifing for(curInstanceIndex = 0, curInstanceDesc = inInstanceFile->instanceDescriptors; curInstanceIndex < inInstanceFile->numInstanceDescriptors; @@ -4647,12 +4647,12 @@ TMiInstanceFile_RemoveIdentical( if(gInstanceDuplicateArray[curInstanceIndex] != UUcMaxUns32) { // curInstanceDesc has a duplicate - + targetCheckInstance = inInstanceFile->instanceDescriptors + gInstanceDuplicateArray[curInstanceIndex]; // make sure it is legal UUmAssert(gInstanceDuplicateArray[curInstanceIndex] < inInstanceFile->numInstanceDescriptors); - + UUmAssert(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate); // make sure its source is marked @@ -4661,20 +4661,20 @@ TMiInstanceFile_RemoveIdentical( else { // curInstanceDesc does not have a duplicate - + UUmAssert(!(curInstanceDesc->flags & TMcDescriptorFlags_Duplicate)); } } - + // now remap the name descriptor array for(curNameDescIndex = 0, curNameDesc = inInstanceFile->nameDescriptors; curNameDescIndex < inInstanceFile->numNameDescriptors; curNameDescIndex++, curNameDesc++) { UUtUns32 remapedIndex = duplicateRemapArray[curNameDesc->instanceDescIndex]; - + UUmAssert(remapedIndex < inInstanceFile->numInstanceDescriptors); - + UUmAssert(inInstanceFile->instanceDescriptors[remapedIndex].namePtr != NULL); UUmAssert(strcmp( inInstanceFile->instanceDescriptors[remapedIndex].namePtr, @@ -4695,25 +4695,25 @@ TMiInstanceFile_RemoveIdentical( fprintf(stderr, "num instances saved: %d\n", numTotalInstancesRemoved); fprintf(stderr, "size saved: %d\n", totalRemovedSize); - + UUrMemory_Block_Delete(duplicateRemapArray); inInstanceFile->numTemplateDescriptors = numTemplateDescriptors; inInstanceFile->templateDescriptors = UUrMemory_Block_New(numTemplateDescriptors * sizeof(TMtTemplateDescriptor)); numTemplateDescriptors = 0; - + for(curTemplateDataIndex = 0, curTemplateData = templateConstructionData; curTemplateDataIndex < TMgNumTemplateDefinitions; curTemplateDataIndex++, curTemplateData++) { if(curTemplateData->numInstancesUsed == 0) continue; - + inInstanceFile->templateDescriptors[numTemplateDescriptors].checksum = TMgTemplateDefinitionArray[curTemplateDataIndex].checksum; inInstanceFile->templateDescriptors[numTemplateDescriptors].tag = TMgTemplateDefinitionArray[curTemplateDataIndex].tag; inInstanceFile->templateDescriptors[numTemplateDescriptors].numUsed = curTemplateData->numInstancesUsed; numTemplateDescriptors++; } - + { UUtUns32 curDescIndex; @@ -4721,34 +4721,34 @@ TMiInstanceFile_RemoveIdentical( FILE* file; char instanceFileName[BFcMaxFileNameLength]; char fileName[BFcMaxFileNameLength]; - + UUrString_Copy(instanceFileName, BFrFileRef_GetLeafName(inInstanceFile->instanceFileRef), BFcMaxFileNameLength); UUrString_StripExtension(instanceFileName); - + sprintf(fileName, "%s_stats.txt", instanceFileName); - + file = fopen(fileName, "w"); - + if(file != NULL) { gTemplateConstructionList = templateConstructionData; - + sortedList = UUrMemory_Block_New(TMgNumTemplateDefinitions * sizeof(UUtUns32)); UUmError_ReturnOnNull(sortedList); - + for(curDescIndex = 0; curDescIndex < TMgNumTemplateDefinitions; curDescIndex++) { sortedList[curDescIndex] = curDescIndex; } - + AUrQSort_32( sortedList, TMgNumTemplateDefinitions, TMiDumpStats_Compare_InstanceCount); - + fprintf(file, "Instance file dump\n"); fprintf(file, "fileName: %s\n", BFrFileRef_GetLeafName(inInstanceFile->instanceFileRef)); - + fprintf(file, "Template descriptor list(sorted by instance count)\n"); for(curDescIndex = 0; curDescIndex < TMgNumTemplateDefinitions; @@ -4757,9 +4757,9 @@ TMiInstanceFile_RemoveIdentical( UUtInt32 templateDefIndex = sortedList[curDescIndex]; TMtTemplate_ConstructionData* curTemplateData = templateConstructionData + templateDefIndex; TMtTemplateDefinition* templateDef = TMgTemplateDefinitionArray + templateDefIndex; - + if(curTemplateData->numInstancesUsed == 0) continue; - + fprintf(file, "\tName: %s\n", templateDef->name); fprintf(file, "\tTag: %c%c%c%c\n", (templateDef->tag >> 24) & 0xFF, @@ -4772,12 +4772,12 @@ TMiInstanceFile_RemoveIdentical( fprintf(file, "\tMemory Saved: %d\n", curTemplateData->removedSize); fprintf(file, "\t*******************************\n"); } - + for(curDescIndex = 0; curDescIndex < TMgNumTemplateDefinitions; curDescIndex++) { sortedList[curDescIndex] = curDescIndex; } - + AUrQSort_32( sortedList, TMgNumTemplateDefinitions, @@ -4791,7 +4791,7 @@ TMiInstanceFile_RemoveIdentical( UUtInt32 templateDefIndex = sortedList[curDescIndex]; TMtTemplate_ConstructionData* curTemplateData = templateConstructionData + templateDefIndex; TMtTemplateDefinition* templateDef = TMgTemplateDefinitionArray + templateDefIndex; - + if(curTemplateData->numInstancesUsed == 0) continue; fprintf(file, "\tName: %s\n", templateDef->name); @@ -4806,12 +4806,12 @@ TMiInstanceFile_RemoveIdentical( fprintf(file, "\tMemory Saved: %d\n", curTemplateData->removedSize); fprintf(file, "\t*******************************\n"); } - + for(curDescIndex = 0; curDescIndex < TMgNumTemplateDefinitions; curDescIndex++) { sortedList[curDescIndex] = curDescIndex; } - + AUrQSort_32( sortedList, TMgNumTemplateDefinitions, @@ -4825,9 +4825,9 @@ TMiInstanceFile_RemoveIdentical( UUtInt32 templateDefIndex = sortedList[curDescIndex]; TMtTemplate_ConstructionData* curTemplateData = templateConstructionData + templateDefIndex; TMtTemplateDefinition* templateDef = TMgTemplateDefinitionArray + templateDefIndex; - + if(curTemplateData->numInstancesUsed == 0) continue; - + fprintf(file, "\tName: %s\n", templateDef->name); fprintf(file, "\tTag: %c%c%c%c\n", (templateDef->tag >> 24) & 0xFF, @@ -4840,19 +4840,19 @@ TMiInstanceFile_RemoveIdentical( fprintf(file, "\tMemory Saved: %d\n", curTemplateData->removedSize); fprintf(file, "\t*******************************\n"); } - + fclose(file); - + UUrMemory_Block_Delete(sortedList); } } - + UUrMemory_Block_Delete(templateConstructionData); UUrMemory_Block_Delete(originalDuplicateDescriptorArray); UUrMemory_Block_Delete(originalDescriptorList); - + TMgCompare_InstanceFile = NULL; - + return UUcError_None; } @@ -4868,25 +4868,25 @@ TMiInstanceFile_DeleteUnusedInstances( TMtNameDescriptor* curNameDesc; UUtUns32* deletedRemapArray = NULL; - + UUtUns8* swapCodes; UUtUns8* dataPtr; - + UUtUns32 newInstanceIndex; - + TMtInstanceDescriptor* originalDescriptorList; - + fprintf(stderr, "Deleting unused...\n"); - + deletedRemapArray = UUrMemory_Block_New(inInstanceFile->numInstanceDescriptors * sizeof(UUtInt32)); UUmError_ReturnOnNull(deletedRemapArray); - + UUrMemory_Set32(deletedRemapArray, UUcMaxUns32, inInstanceFile->numInstanceDescriptors * sizeof(UUtInt32)); - + originalDescriptorList = UUrMemory_Block_New(inInstanceFile->numInstanceDescriptors * sizeof(TMtInstanceDescriptor)); UUmError_ReturnOnNull(originalDescriptorList); - - + + UUrMemory_Block_VerifyList(); /* @@ -4898,7 +4898,7 @@ TMiInstanceFile_DeleteUnusedInstances( curDescIndex++, curDesc++) { TMmInstanceDesc_Verify(curDesc); - + if(!(curDesc->flags & TMcDescriptorFlags_Touched)) { // instance has not been touched, delete it @@ -4917,7 +4917,7 @@ TMiInstanceFile_DeleteUnusedInstances( { swapCodes = curDesc->templatePtr->swapCodes; dataPtr = curDesc->dataPtr; - + TMiInstance_Clean_Recursive( &swapCodes, &dataPtr, @@ -4927,7 +4927,7 @@ TMiInstanceFile_DeleteUnusedInstances( } } } - + /* * NULL out pointers to deleted instances */ @@ -4937,7 +4937,7 @@ TMiInstanceFile_DeleteUnusedInstances( { swapCodes = curDesc->templatePtr->swapCodes; dataPtr = (UUtUns8 *)curDesc->dataPtr; - + if((curDesc->flags & TMcDescriptorFlags_DeleteMe) || dataPtr == NULL) { continue; @@ -4945,33 +4945,33 @@ TMiInstanceFile_DeleteUnusedInstances( TMiInstance_NullOutDeletedRefs(&swapCodes, &dataPtr, inInstanceFile); } - - + + UUrMemory_MoveFast(inInstanceFile->instanceDescriptors, originalDescriptorList, inInstanceFile->numInstanceDescriptors * sizeof(TMtInstanceDescriptor)); - + /* * Compute the remap array */ newInstanceIndex = 0; - + for(curDescIndex = 0, curDesc = originalDescriptorList; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) { TMmInstanceDesc_Verify(curDesc); - + if(!(curDesc->flags & TMcDescriptorFlags_DeleteMe)) { inInstanceFile->instanceDescriptors[newInstanceIndex] = *curDesc; deletedRemapArray[curDescIndex] = newInstanceIndex++; continue; } - + if(curDesc->namePtr == NULL) { continue; } - + /* we must delete the name descriptor */ for(curNameDescIndex = 0, curNameDesc = inInstanceFile->nameDescriptors; curNameDescIndex < inInstanceFile->numNameDescriptors; @@ -4980,14 +4980,14 @@ TMiInstanceFile_DeleteUnusedInstances( if(curNameDesc->instanceDescIndex == curDescIndex) { UUmAssert(strcmp(curNameDesc->namePtr, curDesc->namePtr) == 0); - + UUrMemory_Array_DeleteElement(gNameDescriptorArray, curNameDescIndex); inInstanceFile->numNameDescriptors--; break; } } } - + for(curDescIndex = 0, curDesc = originalDescriptorList; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) @@ -4996,17 +4996,17 @@ TMiInstanceFile_DeleteUnusedInstances( { TMtInstanceDescriptor* originalDesc = originalDescriptorList + curDescIndex; TMtInstanceDescriptor* newDesc = inInstanceFile->instanceDescriptors + deletedRemapArray[curDescIndex]; - + UUmAssert(originalDesc->templatePtr == newDesc->templatePtr); UUmAssert(originalDesc->dataPtr == newDesc->dataPtr); - } + } } - + inInstanceFile->numInstanceDescriptors = newInstanceIndex; UUrMemory_Array_SetUsedElems(gInstanceDescriptorArray, newInstanceIndex, NULL); UUrMemory_Block_VerifyList(); - + /* * Remap the name descriptor indices */ @@ -5016,13 +5016,13 @@ TMiInstanceFile_DeleteUnusedInstances( { curNameDesc->instanceDescIndex = deletedRemapArray[curNameDesc->instanceDescIndex]; UUmAssert(curNameDesc->instanceDescIndex < inInstanceFile->numInstanceDescriptors); - + UUmAssert(inInstanceFile->instanceDescriptors[curNameDesc->instanceDescIndex].namePtr != NULL); UUmAssert(strcmp( inInstanceFile->instanceDescriptors[curNameDesc->instanceDescIndex].namePtr, curNameDesc->namePtr) == 0); } - + /* * update the place holder data */ @@ -5031,10 +5031,10 @@ TMiInstanceFile_DeleteUnusedInstances( curDescIndex++, curDesc++) { if(curDesc->dataPtr == NULL) continue; - + TMmInstanceData_GetPlaceHolder(curDesc->dataPtr) = TMmPlaceHolder_MakeFromIndex(curDescIndex); } - + /* * update the place holder data and apply the remap */ @@ -5043,18 +5043,18 @@ TMiInstanceFile_DeleteUnusedInstances( curDescIndex++, curDesc++) { if(curDesc->dataPtr == NULL) continue; - + swapCodes = curDesc->templatePtr->swapCodes; dataPtr = curDesc->dataPtr; - + TMiInstance_Remap_Recursive(&swapCodes, &dataPtr, deletedRemapArray, inInstanceFile); } - + UUrMemory_Block_Delete(deletedRemapArray); UUrMemory_Block_Delete(originalDescriptorList); - + UUrMemory_Block_VerifyList(); - + return UUcError_None; } @@ -5064,85 +5064,85 @@ TMiInstanceFile_Save( { UUtError error; BFtFile* instancePhysicalFile; - + UUtUns32 curDescIndex; TMtInstanceDescriptor* curDesc; - + UUtUns32 curDataFilePos; UUtUns32 curNameFilePos; - + UUtUns32 curDataOffset; UUtUns32 curNameOffset; - + UUtUns32 curNameLen; - + TMtTemplateDefinition* templateDefinition; - - + + TMtInstanceFile_Header fileHeader; - + TMmInstanceFile_Verify(inInstanceFile); - + UUrMemory_Block_VerifyList(); - + if(inInstanceFile->numInstanceDescriptors == 0) { UUmAssert(inInstanceFile->numNameDescriptors == 0); UUmAssert(inInstanceFile->numTemplateDescriptors == 0); UUmAssert(inInstanceFile->dataBlockLength == 0); UUmAssert(inInstanceFile->nameBlockLength == 0); - + return UUcError_None; } - + if(gInstanceDuplicateArray != NULL) { UUrMemory_Block_Delete(gInstanceDuplicateArray); } - + gInstanceDuplicateArray = UUrMemory_Block_New(inInstanceFile->numInstanceDescriptors * sizeof(UUtUns32)); UUmError_ReturnOnNull(gInstanceDuplicateArray); - + // delete unused instances error = TMiInstanceFile_DeleteUnusedInstances(inInstanceFile); UUmError_ReturnOnError(error); - + /* * Remove identical instance */ error = TMiInstanceFile_RemoveIdentical(inInstanceFile); UUmError_ReturnOnError(error); - + /* - * Prepare all instances for disk + * Prepare all instances for disk */ - + for(curDescIndex = 0, curDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) { templateDefinition = curDesc->templatePtr; - + curDesc->templatePtr = (void*)templateDefinition->tag; } - + UUrMemory_Block_VerifyList(); - + /* * Delete the instance file */ error = BFrFile_Delete(inInstanceFile->instanceFileRef); UUmError_ReturnOnErrorMsg(error, "Could not open instance file for writing"); - + error = BFrFile_Create(inInstanceFile->instanceFileRef); UUmError_ReturnOnErrorMsg(error, "Could not open instance file for writing"); - + /* * open the instance files for writing */ error = BFrFile_Open(inInstanceFile->instanceFileRef, "w", &instancePhysicalFile); UUmError_ReturnOnErrorMsg(error, "Could not open instance file for writing"); - + /* * Calculate the new file header */ @@ -5152,18 +5152,18 @@ TMiInstanceFile_Save( fileHeader.numNameDescriptors = inInstanceFile->numNameDescriptors; fileHeader.numTemplateDescriptors = inInstanceFile->numTemplateDescriptors; fileHeader.dataBlockOffset = - sizeof(TMtInstanceFile_Header) + - fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + + sizeof(TMtInstanceFile_Header) + + fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + fileHeader.numNameDescriptors * sizeof(TMtNameDescriptor) + fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor); fileHeader.dataBlockOffset = UUmMakeMultipleCacheLine(fileHeader.dataBlockOffset); - + /* * Write out the instance data and compute the new offsets */ curDataOffset = 0; curDataFilePos = fileHeader.dataBlockOffset; - + for(curDescIndex = 0, curDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) @@ -5172,10 +5172,10 @@ TMiInstanceFile_Save( { continue; } - + curDataOffset += TMcPreDataBuffer; curDataFilePos += TMcPreDataBuffer; - + // First write the data to the new offset error = BFrFile_WritePos( @@ -5188,9 +5188,9 @@ TMiInstanceFile_Save( curDesc->dataPtr = (void*)curDataOffset; curDataOffset += curDesc->size; curDataFilePos += curDesc->size; - + } - + for(curDescIndex = 0, curDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) @@ -5200,14 +5200,14 @@ TMiInstanceFile_Save( curDesc->dataPtr = inInstanceFile->instanceDescriptors[gInstanceDuplicateArray[curDescIndex]].dataPtr; } } - + UUrMemory_Block_VerifyList(); fileHeader.dataBlockLength = inInstanceFile->dataBlockLength = curDataOffset; - + curNameOffset = 0; fileHeader.nameBlockOffset = curNameFilePos = curDataFilePos; - + for(curDescIndex = 0, curDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curDesc++) @@ -5216,10 +5216,10 @@ TMiInstanceFile_Save( { continue; } - + // First write the name to the new offset curNameLen = strlen(curDesc->namePtr) + 1; - + error = BFrFile_WritePos( instancePhysicalFile, @@ -5230,35 +5230,35 @@ TMiInstanceFile_Save( curDesc->namePtr = (char*)curNameOffset; curNameOffset += curNameLen; - + curNameFilePos += curNameLen; } fileHeader.nameBlockLength = inInstanceFile->nameBlockLength = curNameOffset; - + UUrMemory_Block_VerifyList(); /* * Write out the file header */ UUmAssert(fileHeader.numNameDescriptors <= fileHeader.numInstanceDescriptors); - UUmAssert(fileHeader.dataBlockOffset >= - sizeof(TMtInstanceFile_Header) + - fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + + UUmAssert(fileHeader.dataBlockOffset >= + sizeof(TMtInstanceFile_Header) + + fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + fileHeader.numNameDescriptors * sizeof(TMtNameDescriptor) + fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor)); - UUmAssert(fileHeader.nameBlockOffset >= - sizeof(TMtInstanceFile_Header) + - fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + - fileHeader.numNameDescriptors * sizeof(TMtNameDescriptor) + - fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor) + + UUmAssert(fileHeader.nameBlockOffset >= + sizeof(TMtInstanceFile_Header) + + fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + + fileHeader.numNameDescriptors * sizeof(TMtNameDescriptor) + + fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor) + fileHeader.dataBlockLength); - + UUmAssert(fileHeader.dataBlockOffset + fileHeader.dataBlockLength <= fileHeader.nameBlockOffset); error = BFrFile_WritePos(instancePhysicalFile, 0, sizeof(TMtInstanceFile_Header), &fileHeader); UUmError_ReturnOnErrorMsg(error, "Could not write endian detector"); - + /* * Write out the instance descriptors */ @@ -5269,7 +5269,7 @@ TMiInstanceFile_Save( inInstanceFile->numInstanceDescriptors * sizeof(TMtInstanceDescriptor), inInstanceFile->instanceDescriptors); UUmError_ReturnOnErrorMsg(error, "Could not write instance descriptors"); - + /* * Write out the name descriptors */ @@ -5280,7 +5280,7 @@ TMiInstanceFile_Save( inInstanceFile->numNameDescriptors * sizeof(TMtNameDescriptor), inInstanceFile->nameDescriptors); UUmError_ReturnOnErrorMsg(error, "Could not write name descriptors"); - + /* * Write out the template descriptors */ @@ -5293,16 +5293,16 @@ TMiInstanceFile_Save( inInstanceFile->numTemplateDescriptors * sizeof(TMtTemplateDescriptor), inInstanceFile->templateDescriptors); UUmError_ReturnOnErrorMsg(error, "Could not write name descriptors"); - + BFrFile_Close(instancePhysicalFile); - + UUrMemory_Block_VerifyList(); UUrMemory_Pool_Reset(gConstructionPool); - + UUrMemory_Block_Delete(inInstanceFile->templateDescriptors); inInstanceFile->templateDescriptors = NULL; - + return TMiInstanceFile_Reload(inInstanceFile, UUcFalse); } @@ -5311,13 +5311,13 @@ TMiInstanceFile_Dispose( TMtInstanceFile* inInstanceFile) { TMmInstanceFile_Verify(inInstanceFile); - + BFrFileRef_Dispose(inInstanceFile->instanceFileRef); - + if(gInGame == UUcTrue) { BFrFile_UnMap(inInstanceFile->mapping); - + if(inInstanceFile->dynamicMemory != NULL) { UUrMemory_Block_Delete(inInstanceFile->dynamicMemory); @@ -5326,23 +5326,23 @@ TMiInstanceFile_Dispose( else { UUmAssert(inInstanceFile->allocBlock == NULL); - + if(inInstanceFile->dataBlock != NULL) { UUrMemory_Block_Delete(inInstanceFile->dataBlock); } - + if(inInstanceFile->nameBlock != NULL) { UUrMemory_Block_Delete(inInstanceFile->nameBlock); } - + if(inInstanceFile->templateDescriptors != NULL) { UUrMemory_Block_Delete(inInstanceFile->templateDescriptors); } } - + UUrMemory_Block_Delete(inInstanceFile); } @@ -5354,15 +5354,15 @@ TMiInstanceFile_Instance_FindInstanceDescriptor( { UUtUns32 curDescIndex; TMtNameDescriptor* curDesc; - + TMmInstanceFile_Verify(inInstanceFile); - + for(curDescIndex = 0, curDesc = inInstanceFile->nameDescriptors; curDescIndex < inInstanceFile->numNameDescriptors; curDescIndex++, curDesc++) { UUmAssert(curDesc->namePtr != NULL); - + if( curDesc->namePtr[0] == (char)((inTemplateTag >> 24) & 0xFF) && curDesc->namePtr[1] == (char)((inTemplateTag >> 16) & 0xFF) && curDesc->namePtr[2] == (char)((inTemplateTag >> 8) & 0xFF) && @@ -5376,7 +5376,7 @@ TMiInstanceFile_Instance_FindInstanceDescriptor( } } } - + return NULL; } @@ -5393,31 +5393,31 @@ TMiInstanceFile_Instance_GetDataPtr_DoesNotWork( UUtInt16 result; TMtNameDescriptor* curNameDesc; TMtInstanceDescriptor* targetInstanceDesc; - + TMmInstanceFile_Verify(inInstanceFile); - + lowRange = 0; highRange = inInstanceFile->numNameDescriptors; - + while(1) { if(lowRange >= highRange) break; - + midPoint = (lowRange + highRange) >> 1; - + curNameDesc = inInstanceFile->nameDescriptors + midPoint; - + result = strcmp(inName, curNameDesc->namePtr); - + if(result == 0) { UUmAssert(curNameDesc->instanceDescIndex < inInstanceFile->numInstanceDescriptors); - + targetInstanceDesc = inInstanceFile->instanceDescriptors + curNameDesc->instanceDescIndex; - + TMmInstanceDesc_Verify(targetInstanceDesc); TMmInstanceData_Verify(targetInstanceDesc->dataPtr); - + return targetInstanceDesc->dataPtr; } else if(result < 0) @@ -5429,7 +5429,7 @@ TMiInstanceFile_Instance_GetDataPtr_DoesNotWork( lowRange = midPoint; } } - + return NULL; } #endif @@ -5442,10 +5442,10 @@ TMiInstanceFile_Instance_CreateNewDescriptor( UUtUns32 *outIndex) { UUtError error; - + TMtTemplateDefinition* templateDefinition; TMtInstanceDescriptor* newInstanceDescriptor; - + char* newNamePtr; UUtUns32 newIndex; @@ -5453,14 +5453,14 @@ TMiInstanceFile_Instance_CreateNewDescriptor( UUtUns32 curNameDescIndex; TMtNameDescriptor* curNameDesc; TMtNameDescriptor* newNameDescriptor; - + TMmInstanceFile_Verify(inInstanceFile); UUmAssert(gInGame == UUcFalse); - + UUrMemory_Block_VerifyList(); - + *outIndex = 0xFFFF; - + templateDefinition = TMiTemplate_FindDefinition(inTemplateTag); if(templateDefinition == NULL) { @@ -5469,14 +5469,14 @@ TMiInstanceFile_Instance_CreateNewDescriptor( error = UUrMemory_Array_GetNewElement(gInstanceDescriptorArray, &newIndex, NULL); UUmError_ReturnOnErrorMsg(error, "Could not get new index"); - + if(newIndex > TMcMaxInstances) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Exceeded maximum number of instances in a file"); } - + inInstanceFile->instanceDescriptors = UUrMemory_Array_GetMemory(gInstanceDescriptorArray); - + newInstanceDescriptor = inInstanceFile->instanceDescriptors + newIndex; if(inName != NULL) @@ -5486,7 +5486,7 @@ TMiInstanceFile_Instance_CreateNewDescriptor( { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not alloc contruction pool"); } - + strcpy(newNamePtr + 4, inName); newNamePtr[0] = (char)((inTemplateTag >> 24) & 0xFF); newNamePtr[1] = (char)((inTemplateTag >> 16) & 0xFF); @@ -5497,7 +5497,7 @@ TMiInstanceFile_Instance_CreateNewDescriptor( { newNamePtr = NULL; } - + UUrMemory_Block_VerifyList(); newInstanceDescriptor->templatePtr = templateDefinition; @@ -5507,9 +5507,9 @@ TMiInstanceFile_Instance_CreateNewDescriptor( newInstanceDescriptor->creationDate = UUrGetSecsSince1900(); newInstanceDescriptor->dataPtr = NULL; newInstanceDescriptor->size = 0; - + newInstanceDescriptor->flags |= TMcDescriptorFlags_Touched; - + UUrMemory_Block_VerifyList(); if(inName != NULL) @@ -5523,7 +5523,7 @@ TMiInstanceFile_Instance_CreateNewDescriptor( break; } } - + UUrMemory_Block_VerifyList(); error = UUrMemory_Array_InsertElement(gNameDescriptorArray, curNameDescIndex, NULL); @@ -5533,17 +5533,17 @@ TMiInstanceFile_Instance_CreateNewDescriptor( } inInstanceFile->nameDescriptors = UUrMemory_Array_GetMemory(gNameDescriptorArray); newNameDescriptor = inInstanceFile->nameDescriptors + curNameDescIndex; - + newNameDescriptor->namePtr = newInstanceDescriptor->namePtr; newNameDescriptor->instanceDescIndex = newIndex; - + inInstanceFile->numNameDescriptors++; } - + inInstanceFile->numInstanceDescriptors++; - + *outIndex = newIndex; - + return UUcError_None; } @@ -5557,22 +5557,22 @@ TMiInstanceFile_Instance_CreatePlaceHolder( UUtError error; UUtUns32 newIndex; TMtInstanceDescriptor* targetDesc; - + TMmInstanceFile_Verify(inInstanceFile); - - error = + + error = TMiInstanceFile_Instance_CreateNewDescriptor( inInstanceFile, inTemplateTag, inName, &newIndex); UUmError_ReturnOnError(error); - + *outPlaceHolder = TMmPlaceHolder_MakeFromIndex(newIndex); - + targetDesc = TMrPlaceHolder_GetInstanceDesc(inInstanceFile, *outPlaceHolder); targetDesc->flags |= TMcDescriptorFlags_PlaceHolder; - + return UUcError_None; } @@ -5586,23 +5586,23 @@ TMiInstanceFile_Instance_Create( UUtError error; TMtTemplateDefinition* templateDefinition; TMtInstanceDescriptor* newInstanceDescriptor; - + void* newDataPtr; UUtUns32 dataSize; - + UUtUns32 newDescIndex; - + TMmInstanceFile_Verify(inInstanceFile); - + templateDefinition = TMiTemplate_FindDefinition(inTemplateTag); if(templateDefinition == NULL) { UUrError_Report(UUcError_Generic, "Could not find template definition"); return NULL; } - + newInstanceDescriptor = NULL; - + if(inName != NULL) { /* @@ -5622,14 +5622,14 @@ TMiInstanceFile_Instance_Create( } // Replace the place holder newInstanceDescriptor->flags &= (TMtDescriptorFlags)~TMcDescriptorFlags_PlaceHolder; - + newDescIndex = newInstanceDescriptor - inInstanceFile->instanceDescriptors; } } - + if(newInstanceDescriptor == NULL) { - error = + error = TMiInstanceFile_Instance_CreateNewDescriptor( inInstanceFile, inTemplateTag, @@ -5640,12 +5640,12 @@ TMiInstanceFile_Instance_Create( UUrError_Report(UUcError_Generic, "Could not create descriptor"); return NULL; } - + newInstanceDescriptor = inInstanceFile->instanceDescriptors + newDescIndex; } dataSize = templateDefinition->size + inVarArrayLength * templateDefinition->varArrayElemSize; - + dataSize = (dataSize + UUcProcessor_CacheLineSize_Mask) & ~UUcProcessor_CacheLineSize_Mask; newDataPtr = UUrMemory_Pool_Block_New(gConstructionPool, dataSize + TMcPreDataBuffer); @@ -5654,20 +5654,20 @@ TMiInstanceFile_Instance_Create( UUmAssert(!"Out of memory"); return NULL; } - + UUrMemory_Set32(newDataPtr, 0xDEADDEAD, dataSize + TMcPreDataBuffer); - + UUmAssertAlignedPtr(newDataPtr); newDataPtr = (char*)newDataPtr + TMcPreDataBuffer; - + UUmAssertReadPtr(newDataPtr, dataSize); - + TMmInstanceData_GetPlaceHolder(newDataPtr) = TMmPlaceHolder_MakeFromIndex(newDescIndex); TMmInstanceData_GetInstanceFile(newDataPtr) = inInstanceFile; TMmInstanceData_GetMagicCookie(newDataPtr) = TMcMagicCookie; TMmInstanceData_GetTemplateDefinition(newDataPtr) = templateDefinition; - + newInstanceDescriptor->checksum = templateDefinition->checksum; newInstanceDescriptor->size = dataSize; newInstanceDescriptor->dataPtr = newDataPtr; @@ -5675,7 +5675,7 @@ TMiInstanceFile_Instance_Create( { UUtUns8* dataPtr = newDataPtr; UUtUns8* swapCodes = newInstanceDescriptor->templatePtr->swapCodes; - + TMiInstance_VarArray_Reset_Recursive( &swapCodes, &dataPtr, @@ -5693,32 +5693,32 @@ TMiInstanceFile_Instance_Clean( { UUtUns8* swapCode; UUtUns8* dataPtr; - + TMtInstanceDescriptor* targetDesc; - + TMmInstanceFile_Verify(inInstanceFile); - + targetDesc = TMiInstanceFile_Instance_FindInstanceDescriptor(inInstanceFile, inTemplateTag, inName); if(targetDesc == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find descriptor"); } - + if(targetDesc->dataPtr == NULL) { return UUcError_None; } - + targetDesc->flags |= TMcDescriptorFlags_Touched; - + swapCode = targetDesc->templatePtr->swapCodes; dataPtr = targetDesc->dataPtr; - + TMiInstance_Clean_Recursive( &swapCode, &dataPtr, inInstanceFile); - + return UUcError_None; } @@ -5730,42 +5730,42 @@ TMiInstanceFile_Instance_ResizeVarArray( TMtInstanceDescriptor* instanceDesc; UUtUns32 newSize; void* newDataPtr; - + TMmInstanceData_Verify(inDataPtr); - + instanceDesc = TMrPlaceHolder_GetInstanceDesc(gConstructionFile, (TMtPlaceHolder)inDataPtr); UUmAssert(instanceDesc != NULL); TMmInstanceDesc_Verify(instanceDesc); - - newSize = instanceDesc->templatePtr->size + + + newSize = instanceDesc->templatePtr->size + instanceDesc->templatePtr->varArrayElemSize * inVarArrayLength; - + newDataPtr = UUrMemory_Pool_Block_New(gConstructionPool, newSize + TMcPreDataBuffer); - + if(newDataPtr == NULL) { return NULL; } - + newDataPtr = (char*)newDataPtr + TMcPreDataBuffer; - + TMmInstanceData_GetInstanceFile(newDataPtr) = TMmInstanceData_GetInstanceFile(instanceDesc->dataPtr); TMmInstanceData_GetPlaceHolder(newDataPtr) = TMmInstanceData_GetPlaceHolder(instanceDesc->dataPtr); TMmInstanceData_GetMagicCookie(newDataPtr) = TMcMagicCookie; TMmInstanceData_GetTemplateDefinition(newDataPtr) = instanceDesc->templatePtr; - + instanceDesc->dataPtr = newDataPtr; - + { UUtUns8* dataPtr = newDataPtr; UUtUns8* swapCodes = instanceDesc->templatePtr->swapCodes; - + TMiInstance_VarArray_Reset_Recursive( &swapCodes, &dataPtr, inVarArrayLength); } - + return newDataPtr; } @@ -5776,15 +5776,15 @@ TMiInstanceFile_Instance_Touch( { UUtUns8* swapCodes; UUtUns8* dataPtr; - + TMmInstanceFile_Verify(inInstanceFile); TMmInstanceDesc_Verify(inInstanceDesc); - + if(inInstanceDesc->dataPtr != NULL) { swapCodes = inInstanceDesc->templatePtr->swapCodes; dataPtr = inInstanceDesc->dataPtr; - + TMiInstance_Touch_Recursive( &swapCodes, &dataPtr, @@ -5799,9 +5799,9 @@ TMiInstanceFile_VerifyAllTouched( TMtInstanceFile* inInstanceFile) { UUtUns32 curDescIndex; - + TMtInstanceDescriptor* curInstDesc; - + UUtUns8* swapCodes; UUtUns8* dataPtr; @@ -5812,31 +5812,31 @@ TMiInstanceFile_VerifyAllTouched( { curInstDesc->flags &= (TMtDescriptorFlags)~TMcDescriptorFlags_Touched; } - + for( curDescIndex = 0, curInstDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; curDescIndex++, curInstDesc++) { if((curDescIndex % 100) == 0) fputc('.', stderr); - + if(curInstDesc->flags & (TMcDescriptorFlags_Unique | TMcDescriptorFlags_PlaceHolder)) { continue; } - + swapCodes = curInstDesc->templatePtr->swapCodes; dataPtr = curInstDesc->dataPtr; - + if(dataPtr == NULL) continue; - + TMiInstance_Touch_Recursive( &swapCodes, &dataPtr, inInstanceFile); } fputc('\n', stderr); - + for( curDescIndex = 0, curInstDesc = inInstanceFile->instanceDescriptors; curDescIndex < inInstanceFile->numInstanceDescriptors; @@ -5847,8 +5847,8 @@ TMiInstanceFile_VerifyAllTouched( //if(curInstDesc->flags & TMcDescriptorFlags_PlaceHolder) continue; UUmAssert(!(curInstDesc->flags & TMcDescriptorFlags_DeleteMe)); if(!(curInstDesc->flags & TMcDescriptorFlags_Unique)) continue; - - if(curInstDesc->flags & TMcDescriptorFlags_Touched) continue; + + if(curInstDesc->flags & TMcDescriptorFlags_Touched) continue; if (!ignore) { AUtMB_ButtonChoice button; @@ -5892,20 +5892,20 @@ TMrInitialize( BFtFileRef* inGameDataFolderRef) { UUtError error; - + gInGame = inGame; - + UUmAssert(sizeof(TMtInstanceFile_Header) == UUcProcessor_CacheLineSize * 2); - + /* * Get the folder ref */ error = BFrFileRef_Duplicate(inGameDataFolderRef, &TMgDataFolderRef); UUmError_ReturnOnErrorMsg(error, "Could not duplicate game data file ref"); - + TMrTemplate_BuildList(); - - + + if(inGame == UUcTrue) { /* @@ -5917,14 +5917,14 @@ TMrInitialize( UUrError_Report(UUcError_OutOfMemory, "could not create perm memory pool"); return UUcError_OutOfMemory; } - + TMgTempPool = UUrMemory_Pool_New(TMcTempPoolChunkSize, UUcPool_Fixed); if(TMgTempPool == NULL) { UUrError_Report(UUcError_OutOfMemory, "could not create Temp memory pool"); return UUcError_OutOfMemory; } - + /* * Initialize the dynamic instance fies */ @@ -5947,15 +5947,15 @@ TMrInitialize( TMgTempInstanceFile.nameBlockLength = 0; TMgTempInstanceFile.nameBlock = NULL; TMgTempInstanceFile.dynamicMemory = NULL; - + #if defined(DEBUGGING) && DEBUGGING - + TMgPermInstanceFile.magicCookie = TMcMagicCookie; TMgTempInstanceFile.magicCookie = TMcMagicCookie; - + #endif - - TMgPermDescriptorArray = + + TMgPermDescriptorArray = UUrMemory_Array_New( sizeof(TMtInstanceDescriptor), 20, @@ -5965,10 +5965,10 @@ TMrInitialize( { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not alloc perm desc array"); } - + TMgPermInstanceFile.instanceDescriptors = UUrMemory_Array_GetMemory(TMgPermDescriptorArray); - - TMgTempDescriptorArray = + + TMgTempDescriptorArray = UUrMemory_Array_New( sizeof(TMtInstanceDescriptor), 20, @@ -5986,7 +5986,7 @@ TMrInitialize( gConstructionPool = UUrMemory_Pool_New(TMcConstructionPoolChunkSize, UUcPool_Growable); UUmError_ReturnOnNull(gConstructionPool); } - + return UUcError_None; } @@ -6007,14 +6007,14 @@ TMrTerminate( TMgPermDescriptorArray = NULL; UUrMemory_Array_Delete(TMgTempDescriptorArray); TMgTempDescriptorArray = NULL; - + } if(gTemplateDefinitionsAlloced != NULL) { - + for(i = 0; i < TMgNumTemplateDefinitions; i++) - { + { if(TMgTemplateDefinitionArray[i].swapCodes != NULL) { UUrMemory_Block_Delete(TMgTemplateDefinitionArray[i].swapCodes); @@ -6024,45 +6024,45 @@ TMrTerminate( UUrMemory_Block_Delete(gTemplateDefinitionsAlloced); gTemplateDefinitionsAlloced = NULL; } - + if(gTemplateNameAlloced != NULL) { UUrMemory_String_Delete(gTemplateNameAlloced); } - + if(TMgTemplateNameData != NULL) { UUrMemory_Block_Delete(TMgTemplateNameData); } - + if(TMgTemplateData != NULL) { UUrMemory_Block_Delete(TMgTemplateData); } - + if(TMgPermPool != NULL) { UUrMemory_Pool_Delete(TMgPermPool); TMgPermPool = NULL; } - + if(TMgTempPool != NULL) { UUrMemory_Pool_Delete(TMgTempPool); TMgTempPool = NULL; } - + if(TMgDataFolderRef != NULL) { BFrFileRef_Dispose(TMgDataFolderRef); } - + TMgTemplateData = NULL; TMgTemplateNameData = NULL; TMgNumTemplateDefinitions = 0; - + UUmAssert(gConstructionFile == NULL); - + if(gInGame == UUcFalse) { if(gInstanceDescriptorArray != NULL) @@ -6070,19 +6070,19 @@ TMrTerminate( UUrMemory_Array_Delete(gInstanceDescriptorArray); gInstanceDescriptorArray = NULL; } - + if(gNameDescriptorArray != NULL) { UUrMemory_Array_Delete(gNameDescriptorArray); gNameDescriptorArray = NULL; } - + if(gConstructionPool != NULL) { UUrMemory_Pool_Delete(gConstructionPool); gConstructionPool = NULL; } - + if(gInstanceDuplicateArray != NULL) { UUrMemory_Block_Delete(gInstanceDuplicateArray); @@ -6101,7 +6101,7 @@ TMrMameAndDestroy( BFtFileRef* datFileRef; BFtFile* datFile; void* garbage; - + error = BFrDirectory_FileIterator_New( TMgDataFolderRef, @@ -6109,12 +6109,12 @@ TMrMameAndDestroy( ".dat", &fileIterator); UUmError_ReturnOnErrorMsg(error, "Could not create file iterator"); - + garbage = UUrMemory_Block_New(TMcMameAndDestroy_Garb_Size); UUmError_ReturnOnNull(garbage); - + UUrMemory_Set32(garbage, 0xDEAD, TMcMameAndDestroy_Garb_Size); - + while(1) { error = BFrDirectory_FileIterator_Next(fileIterator, &datFileRef); @@ -6122,7 +6122,7 @@ TMrMameAndDestroy( { break; } - + error = BFrFile_Open(datFileRef, "w", &datFile); if(error == UUcError_None) @@ -6130,14 +6130,14 @@ TMrMameAndDestroy( BFrFile_Write(datFile, TMcMameAndDestroy_Garb_Size, garbage); BFrFile_Close(datFile); } - + BFrFileRef_Dispose(datFileRef); - } - + } + BFrDirectory_FileIterator_Delete(fileIterator); - + UUrMemory_Block_Delete(garbage); - + return UUcError_None; } @@ -6156,33 +6156,33 @@ TMrTemplate_Register( TMtAllowFolding inAllowFolding) { TMtTemplateDefinition *curTemplateDefinition; - + curTemplateDefinition = TMiTemplate_FindDefinition(inTemplateTag); if(curTemplateDefinition == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "template does not exist"); } - + if(curTemplateDefinition->flags & TMcTemplateFlag_Registered) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "template already registered"); } - + if(curTemplateDefinition->size + curTemplateDefinition->varArrayElemSize != inSize) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "size mismatch, either you need to run the extractor or structure padding is wrong"); } curTemplateDefinition->flags |= TMcTemplateFlag_Registered; - + if(inAllowFolding == TMcFolding_Allow) { curTemplateDefinition->flags |= TMcTemplateFlag_AllowFolding; } - + curTemplateDefinition->handler = NULL; - + return UUcError_None; } @@ -6197,22 +6197,22 @@ TMrTemplate_InstallPrivateData( TMtTemplateProc_Handler inProcHandler) { TMtTemplateDefinition* templatePtr; - + templatePtr = TMiTemplate_FindDefinition(inTemplateTag); if(templatePtr == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find template"); } - + if(templatePtr->handler != NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "A handler is already installed"); } - + templatePtr->privateDataSize = inDynamicSize; templatePtr->handler = inProcHandler; - + return UUcError_None; } @@ -6222,17 +6222,17 @@ TMrTemplate_InstallByteSwap( TMtTemplateProc_ByteSwap inProc) { TMtTemplateDefinition* templatePtr; - + templatePtr = TMiTemplate_FindDefinition(inTemplateTag); if(templatePtr == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find template"); } - + UUmAssert(templatePtr->varArrayElemSize > 0); - + templatePtr->byteSwapProc = inProc; - + return UUcError_None; } @@ -6245,7 +6245,7 @@ TMrTemplate_CallProc( TMtTemplateProc_Message inMessage) { UUtUns32 curFileIndex; - + for(curFileIndex = 0; curFileIndex < TMgNumLevel0Files; curFileIndex++) { if(TMgLevel0Files[curFileIndex] != NULL) @@ -6253,7 +6253,7 @@ TMrTemplate_CallProc( TMiInstanceFile_CallProcs(TMgLevel0Files[curFileIndex], inMessage); } } - + for(curFileIndex = 0; curFileIndex < TMgNumCurLevelFiles; curFileIndex++) { if(TMgCurLevelFiles[curFileIndex] != NULL) @@ -6261,7 +6261,7 @@ TMrTemplate_CallProc( TMiInstanceFile_CallProcs(TMgCurLevelFiles[curFileIndex], inMessage); } } - + return UUcError_None; } @@ -6282,12 +6282,12 @@ TMrInstance_GetDataPtr( UUtUns32 curFileIndex; TMtInstanceDescriptor* targetInstDesc; TMtTemplateDefinition* templatePtr; - + UUmAssert(gInGame == UUcTrue); UUmAssert(gConstructionFile == NULL); - + *outDataPtr = NULL; - + templatePtr = TMiTemplate_FindDefinition(inTemplateTag); if(templatePtr == NULL) { @@ -6300,27 +6300,27 @@ TMrInstance_GetDataPtr( inInstanceName); UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find template definition"); } - + // First look in non final current level instance finals for(curFileIndex = 0; curFileIndex < TMgNumCurLevelFiles; curFileIndex++) { if(TMgCurLevelFiles[curFileIndex]->final == UUcTrue) continue; - + targetInstDesc = TMiInstanceFile_Instance_FindInstanceDescriptor( TMgCurLevelFiles[curFileIndex], inTemplateTag, inInstanceName); - + if(targetInstDesc != NULL && targetInstDesc->dataPtr != NULL) { TMmInstanceData_Verify(targetInstDesc->dataPtr); - + *outDataPtr = targetInstDesc->dataPtr; return UUcError_None; } } - + // Look in final current level instance finals for(curFileIndex = 0; curFileIndex < TMgNumCurLevelFiles; curFileIndex++) { @@ -6331,21 +6331,21 @@ TMrInstance_GetDataPtr( TMgCurLevelFiles[curFileIndex], inTemplateTag, inInstanceName); - + if(targetInstDesc != NULL && targetInstDesc->dataPtr != NULL) { TMmInstanceData_Verify(targetInstDesc->dataPtr); - + *outDataPtr = targetInstDesc->dataPtr; return UUcError_None; } } - + // First look in non final level 0 instance finals for(curFileIndex = 0; curFileIndex < TMgNumLevel0Files; curFileIndex++) { if(TMgLevel0Files[curFileIndex]->final == UUcTrue) continue; - + targetInstDesc = TMiInstanceFile_Instance_FindInstanceDescriptor( TMgLevel0Files[curFileIndex], @@ -6353,19 +6353,19 @@ TMrInstance_GetDataPtr( inInstanceName); if(targetInstDesc != NULL && targetInstDesc->dataPtr != NULL) { - + TMmInstanceData_Verify(targetInstDesc->dataPtr); - + *outDataPtr = targetInstDesc->dataPtr; return UUcError_None; } } - + // Look in final level 0 instance finals for(curFileIndex = 0; curFileIndex < TMgNumLevel0Files; curFileIndex++) { if(TMgLevel0Files[curFileIndex]->final == UUcFalse) continue; - + targetInstDesc = TMiInstanceFile_Instance_FindInstanceDescriptor( TMgLevel0Files[curFileIndex], @@ -6373,14 +6373,14 @@ TMrInstance_GetDataPtr( inInstanceName); if(targetInstDesc != NULL && targetInstDesc->dataPtr != NULL) { - + TMmInstanceData_Verify(targetInstDesc->dataPtr); - + *outDataPtr = targetInstDesc->dataPtr; return UUcError_None; } } - + return UUcError_Generic; } @@ -6395,27 +6395,27 @@ TMrInstance_GetDataPtr_List( TMtInstanceDescriptor* curDesc; TMtTemplateDefinition* templatePtr; UUtUns32 curDescIndex; - + UUtUns32 numPtrs; - + UUmAssert(gInGame == UUcTrue); UUmAssert(gConstructionFile == NULL); - + numPtrs = 0; - + templatePtr = TMiTemplate_FindDefinition(inTemplateTag); if(templatePtr == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find template definition"); } - + // First look in the non final files for(curFileIndex = 0; curFileIndex < TMgNumCurLevelFiles; curFileIndex++) { UUmAssertReadPtr(TMgCurLevelFiles[curFileIndex], sizeof(TMtInstanceFile)); - + if(TMgCurLevelFiles[curFileIndex]->final == UUcTrue) continue; - + for(curDescIndex = 0, curDesc = TMgCurLevelFiles[curFileIndex]->instanceDescriptors; curDescIndex < TMgCurLevelFiles[curFileIndex]->numInstanceDescriptors; curDescIndex++, curDesc++) @@ -6434,12 +6434,12 @@ TMrInstance_GetDataPtr_List( } } } - + // next look in the final files for(curFileIndex = 0; curFileIndex < TMgNumCurLevelFiles; curFileIndex++) { if(TMgCurLevelFiles[curFileIndex]->final == UUcFalse) continue; - + for(curDescIndex = 0, curDesc = TMgCurLevelFiles[curFileIndex]->instanceDescriptors; curDescIndex < TMgCurLevelFiles[curFileIndex]->numInstanceDescriptors; curDescIndex++, curDesc++) @@ -6458,11 +6458,11 @@ TMrInstance_GetDataPtr_List( } } } - + for(curFileIndex = 0; curFileIndex < TMgNumLevel0Files; curFileIndex++) { if(TMgLevel0Files[curFileIndex]->final == UUcTrue) continue; - + for(curDescIndex = 0, curDesc = TMgLevel0Files[curFileIndex]->instanceDescriptors; curDescIndex < TMgLevel0Files[curFileIndex]->numInstanceDescriptors; curDescIndex++, curDesc++) @@ -6481,11 +6481,11 @@ TMrInstance_GetDataPtr_List( } } } - + for(curFileIndex = 0; curFileIndex < TMgNumLevel0Files; curFileIndex++) { if(TMgLevel0Files[curFileIndex]->final == UUcFalse) continue; - + for(curDescIndex = 0, curDesc = TMgLevel0Files[curFileIndex]->instanceDescriptors; curDescIndex < TMgLevel0Files[curFileIndex]->numInstanceDescriptors; curDescIndex++, curDesc++) @@ -6504,9 +6504,9 @@ TMrInstance_GetDataPtr_List( } } } - + *outNumPtrs = numPtrs; - + return UUcError_None; } @@ -6578,32 +6578,32 @@ TMrInstance_Dynamic_New( TMtInstanceDescriptor* newDesc; UUtUns32 newIndex; void* newDynamicMemory; - + UUmAssert(gInGame == UUcTrue); UUmAssert(gConstructionFile == NULL); UUmAssert((TMcTemporarySpace == inTempSpace) || (TMcPermanentSpace == inTempSpace)); - + templatePtr = TMiTemplate_FindDefinition(inTemplateTag); if(templatePtr == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find template"); } - + newDynamicMemory = NULL; - + size = templatePtr->size + templatePtr->varArrayElemSize * inInitialVarArrayLength; - + if(inTempSpace == TMcTemporarySpace) { newDataPtr = UUrMemory_Pool_Block_New(TMgTempPool, size + TMcPreDataBuffer); - + error = UUrMemory_Array_MakeRoom(TMgTempDescriptorArray, TMgTempInstanceFile.numInstanceDescriptors + 1, NULL); UUmError_ReturnOnErrorMsg(error, "Could not make room"); - + TMgTempInstanceFile.instanceDescriptors = UUrMemory_Array_GetMemory(TMgTempDescriptorArray); newDesc = TMgTempInstanceFile.instanceDescriptors + TMgTempInstanceFile.numInstanceDescriptors; newIndex = TMgTempInstanceFile.numInstanceDescriptors++; - + if(templatePtr->privateDataSize != 0) { newDynamicMemory = UUrMemory_Pool_Block_New(TMgTempPool, templatePtr->privateDataSize); @@ -6616,14 +6616,14 @@ TMrInstance_Dynamic_New( else { newDataPtr = UUrMemory_Pool_Block_New(TMgPermPool, size + TMcPreDataBuffer); - + error = UUrMemory_Array_MakeRoom(TMgPermDescriptorArray, TMgPermInstanceFile.numInstanceDescriptors + 1, NULL); UUmError_ReturnOnErrorMsg(error, "Could not make room"); - + TMgPermInstanceFile.instanceDescriptors = UUrMemory_Array_GetMemory(TMgPermDescriptorArray); newDesc = TMgPermInstanceFile.instanceDescriptors + TMgPermInstanceFile.numInstanceDescriptors; newIndex = TMgPermInstanceFile.numInstanceDescriptors++; - + if(templatePtr->privateDataSize != 0) { newDynamicMemory = UUrMemory_Pool_Block_New(TMgPermPool, templatePtr->privateDataSize); @@ -6633,12 +6633,12 @@ TMrInstance_Dynamic_New( } } } - + if(newDataPtr == NULL) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "could not allocate dynamic instance"); } - + newDataPtr = (char*)newDataPtr + TMcPreDataBuffer; newDesc->templatePtr = templatePtr; @@ -6646,35 +6646,35 @@ TMrInstance_Dynamic_New( newDesc->namePtr = NULL; newDesc->size = size; newDesc->checksum = templatePtr->checksum; - + TMmInstance_GetDynamicData(newDataPtr) = newDynamicMemory; - + TMmInstanceData_GetInstanceFile(newDataPtr) = (inTempSpace == TMcTemporarySpace) ? &TMgTempInstanceFile : &TMgPermInstanceFile; TMmInstanceData_GetPlaceHolder(newDataPtr) = TMmPlaceHolder_MakeFromIndex(newIndex); TMmInstanceData_GetMagicCookie(newDataPtr) = TMcMagicCookie; TMmInstanceData_GetTemplateDefinition(newDataPtr) = templatePtr; - + /* * Set the variable length array */ { UUtUns8* swapCode = templatePtr->swapCodes; UUtUns8* dataPtr = (UUtUns8 *)newDataPtr; - + TMiInstance_VarArray_Reset_Recursive( &swapCode, &dataPtr, inInitialVarArrayLength); } - + if(templatePtr->handler != NULL) { error = templatePtr->handler(TMcTemplateProcMessage_NewPostProcess, templatePtr->tag, newDataPtr); UUmError_ReturnOnErrorMsg(error, "Could not new post process"); } - + *outDataPtr = newDataPtr; - + return UUcError_None; } @@ -6686,13 +6686,13 @@ TMrInstance_Update( void* inDataPtr) { TMtTemplateDefinition* templatePtr; - + TMmInstanceData_Verify(inDataPtr); templatePtr = TMmInstanceData_GetTemplateDefinition(inDataPtr); - + if(templatePtr->handler == NULL) return UUcError_None; - + return templatePtr->handler(TMcTemplateProcMessage_Update, templatePtr->tag, inDataPtr); } @@ -6704,11 +6704,11 @@ TMrInstance_PrepareForUse( void* inDataPtr) { TMtTemplateDefinition* templatePtr; - + TMmInstanceData_Verify(inDataPtr); templatePtr = TMmInstanceData_GetTemplateDefinition(inDataPtr); - + if(templatePtr->handler == NULL) return UUcError_None; return templatePtr->handler(TMcTemplateProcMessage_PrepareForUse, templatePtr->tag, inDataPtr); @@ -6723,15 +6723,15 @@ TMrInstance_GetTemplateTag( { TMtInstanceDescriptor* targetDesc; TMtInstanceFile* targetInstanceFile; - + TMmInstanceData_Verify(inDataPtr); targetInstanceFile = TMmInstanceData_GetInstanceFile(inDataPtr); TMmInstanceFile_Verify(targetInstanceFile); - + targetDesc = targetInstanceFile->instanceDescriptors + TMmPlaceHolder_GetIndex(TMmInstanceData_GetPlaceHolder(inDataPtr)); TMmInstanceDesc_Verify(targetDesc); - + return targetDesc->templatePtr->tag; } @@ -6745,7 +6745,7 @@ TMrInstance_GetInstanceName( TMtInstanceDescriptor* targetDesc; TMtInstanceFile* targetInstanceFile; char * namePtr; - + TMmInstanceData_Verify(inDataPtr); targetInstanceFile = TMmInstanceData_GetInstanceFile(inDataPtr); @@ -6756,14 +6756,14 @@ TMrInstance_GetInstanceName( namePtr = targetDesc->namePtr; - if (NULL != namePtr) + if (NULL != namePtr) { namePtr += 4; } - + return namePtr; } - + // ---------------------------------------------------------------------- UUtBool TMrLevel_Exists( @@ -6772,7 +6772,7 @@ TMrLevel_Exists( { UUtError error; UUtBool level_exists = UUcFalse; - + char fileName[128]; BFtFileIterator* fileIterator; @@ -6784,16 +6784,16 @@ TMrLevel_Exists( BFtFile* datFile; TMtInstanceFile_Header fileHeader; - + UUtBool needsSwapping; - + TMtTemplateDescriptor* templateDescriptors = NULL; UUtUns32 itr; TMtTemplateDefinition* templatePtr; - + level_exists = UUcFalse; datFileRef = NULL; - + // set the file name sprintf(fileName, "level%d", inLevelNumber); @@ -6808,7 +6808,7 @@ TMrLevel_Exists( { return UUcFalse; } - + // go through all the files in the file iterator and look for // a file with the same level number as inLevelNumber while (1) @@ -6820,17 +6820,17 @@ TMrLevel_Exists( datFileRef = NULL; break; } - + // copy the name of the file UUrString_Copy(curFileName, BFrFileRef_GetLeafName(datFileRef), 256); - + // get the level number from the file name temp = strrchr(curFileName, '_'); UUmAssert(temp != NULL); *temp = 0; - + sscanf(curFileName + 5, "%d", &curFileLevelNum); - + if(curFileLevelNum == inLevelNumber && inCheckTemplateChecksum) { error = BFrFile_Open(datFileRef, "r", &datFile); @@ -6840,7 +6840,7 @@ TMrLevel_Exists( level_exists = UUcFalse; goto done; } - + error = TMiInstanceFile_LoadHeader(datFile, &fileHeader, &needsSwapping); if (error != UUcError_None) { @@ -6848,19 +6848,19 @@ TMrLevel_Exists( level_exists = UUcFalse; goto done; } - + if(fileHeader.numTemplateDescriptors == 0) { UUrDebuggerMessage("level %d: no templates", inLevelNumber); level_exists = UUcFalse; goto done; } - + if(templateDescriptors != NULL) { UUrMemory_Block_Delete(templateDescriptors); } - + templateDescriptors = UUrMemory_Block_New(fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor)); if(templateDescriptors == NULL) { @@ -6868,13 +6868,13 @@ TMrLevel_Exists( level_exists = UUcFalse; goto done; } - + //Read in the template descriptors - error = + error = BFrFile_ReadPos( datFile, sizeof(TMtInstanceFile_Header) + - fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + + fileHeader.numInstanceDescriptors * sizeof(TMtInstanceDescriptor) + fileHeader.numNameDescriptors * sizeof(TMtNameDescriptor), fileHeader.numTemplateDescriptors * sizeof(TMtTemplateDescriptor), templateDescriptors); @@ -6884,7 +6884,7 @@ TMrLevel_Exists( level_exists = UUcFalse; goto done; } - + // check to make sure all template checksums match for(itr = 0; itr < fileHeader.numTemplateDescriptors; itr++) { @@ -6892,7 +6892,7 @@ TMrLevel_Exists( { UUrSwap_4Byte(&templateDescriptors[itr].tag); } - + templatePtr = TMiTemplate_FindDefinition(templateDescriptors[itr].tag); if(templatePtr == NULL) { @@ -6905,7 +6905,7 @@ TMrLevel_Exists( level_exists = UUcFalse; goto done; } - + if(needsSwapping) { UUrSwap_8Byte(&templateDescriptors[itr].checksum); @@ -6923,10 +6923,10 @@ TMrLevel_Exists( goto done; } } - + BFrFile_Close(datFile); } - + if(curFileLevelNum == inLevelNumber) { level_exists = UUcTrue; @@ -6935,17 +6935,17 @@ TMrLevel_Exists( BFrFileRef_Dispose(datFileRef); datFileRef = NULL; } - + done: - + // delete the file iterator BFrDirectory_FileIterator_Delete(fileIterator); - + if(datFileRef != NULL) { BFrFileRef_Dispose(datFileRef); } - + if(templateDescriptors != NULL) { UUrMemory_Block_Delete(templateDescriptors); @@ -6959,9 +6959,9 @@ TMrLevel_Unload( void) { UUtUns32 curFileIndex; - + TMgLevelLoadStack--; - + if(TMgLevelLoadStack == 0) { for(curFileIndex = 0; curFileIndex < TMgNumLevel0Files; curFileIndex++) @@ -6970,7 +6970,7 @@ TMrLevel_Unload( TMiInstanceFile_Dispose(TMgLevel0Files[curFileIndex]); TMgLevel0Files[curFileIndex] = NULL; } - + // Delete all the level instance files after calling dispose TMiInstanceFile_CallProcs(&TMgPermInstanceFile, TMcTemplateProcMessage_DisposePreProcess); } @@ -6985,10 +6985,10 @@ TMrLevel_Unload( TMiInstanceFile_Dispose(TMgCurLevelFiles[curFileIndex]); TMgCurLevelFiles[curFileIndex] = NULL; } - + #if 0 BHP - no longer do this because it prevents us from accessing level 0 after an unload - /* + /* * Next prepare the level 0 files for disk */ for(curFileIndex = 0; curFileIndex < TMgNumLevel0Files; curFileIndex++) @@ -6996,15 +6996,15 @@ TMrLevel_Unload( TMiInstanceFile_CallProcs(TMgLevel0Files[curFileIndex], TMcTemplateProcMessage_DisposePreProcess); TMiInstanceFile_PrepareForDisk(TMgLevel0Files[curFileIndex]); } - + #endif } - + // Next delete the temporary dynamic instances TMiInstanceFile_CallProcs(&TMgTempInstanceFile, TMcTemplateProcMessage_DisposePreProcess); TMgTempInstanceFile.numInstanceDescriptors = 0; UUrMemory_Pool_Reset(TMgTempPool); - + TMgNumCurLevelFiles = 0; } @@ -7019,36 +7019,36 @@ TMrLevel_Load( UUtError error; char *desiredSuffix; - + BFtFileIterator* fileIterator; char fileName[128]; - + BFtFileRef* datFileRef; - + UUtUns16 curFileIndex; char msg[256]; - + TMtInstanceFile* curInstanceFile; char* temp; char curFileName[256]; - + TMtInstanceFile* (*instanceFileArray)[TMcMaxLevelDatFiles]; UUtUns16 numLevelFiles; - + UUtUns32 curFileLevelNum; - + UUmAssert(gInGame == UUcTrue); UUmAssert(gConstructionFile == NULL); - + sprintf(fileName, "level%d", inLevelNumber); - + if(inLevelNumber == 0) { if(TMrLevel_Exists(0, UUcTrue) == UUcFalse) { UUmError_ReturnOnErrorMsg(TMcError_DataCorrupt, "Level 0 out of data"); } - + UUmAssert(TMgNumLevel0Files == 0); instanceFileArray = &TMgLevel0Files; } @@ -7066,7 +7066,7 @@ TMrLevel_Load( { desiredSuffix = "_Final.dat"; } - + error = BFrDirectory_FileIterator_New( TMgDataFolderRef, @@ -7074,9 +7074,9 @@ TMrLevel_Load( desiredSuffix, &fileIterator); UUmError_ReturnOnErrorMsg(error, "Could not create file iterator"); - + numLevelFiles = 0; - + while(1) { error = BFrDirectory_FileIterator_Next(fileIterator, &datFileRef); @@ -7084,21 +7084,21 @@ TMrLevel_Load( { break; } - + UUrString_Copy(curFileName, BFrFileRef_GetLeafName(datFileRef), 256); - + temp = strrchr(curFileName, '_'); UUmAssert(temp != NULL); *temp = 0; - + sscanf(curFileName + 5, "%d", &curFileLevelNum); - + if((UUtUns32)curFileLevelNum != inLevelNumber) { BFrFileRef_Dispose(datFileRef); continue; } - + // Create the instance file from a file ref error = TMiInstanceFile_MakeFromFileRef( @@ -7106,9 +7106,9 @@ TMrLevel_Load( &(*instanceFileArray)[numLevelFiles], UUcFalse); UUmError_ReturnOnErrorMsg(error, "Could not make instance file"); - + curInstanceFile = (*instanceFileArray)[numLevelFiles]; - + curInstanceFile->final = (strncmp(temp + 1, "Final", 5) == 0); UUrString_Copy( curInstanceFile->fileName, @@ -7117,9 +7117,9 @@ TMrLevel_Load( numLevelFiles++; BFrFileRef_Dispose(datFileRef); } - + BFrDirectory_FileIterator_Delete(fileIterator); - + if(numLevelFiles == 0) { UUmError_ReturnOnErrorMsg(TMcError_NoDatFile, "Could not find and .dat files"); @@ -7139,7 +7139,7 @@ TMrLevel_Load( error = TMiInstanceFile_PrepareForMemory(TMgLevel0Files[curFileIndex], msg); UUmError_ReturnOnErrorMsg(error, "Could not prepare instance file for memory"); } - + /* * Call the load postprocess message */ @@ -7162,7 +7162,7 @@ TMrLevel_Load( error = TMiInstanceFile_PrepareForMemory(TMgCurLevelFiles[curFileIndex], msg); UUmError_ReturnOnErrorMsg(error, "Could not prepare instance file for memory"); } - + /* * Call the load postprocess message */ @@ -7173,9 +7173,9 @@ TMrLevel_Load( UUmError_ReturnOnErrorMsg(error, "Could not prepare instance file for memory"); } } - + TMgLevelLoadStack++; - + return UUcError_None; } @@ -7184,11 +7184,11 @@ TMrConstruction_Start( BFtFileRef* inInstanceFileRef) { UUtError error; - + UUmAssert(gInGame == UUcFalse); - + error = TMiInstanceFile_MakeFromFileRef(inInstanceFileRef, &gConstructionFile, UUcTrue); - + return error; } @@ -7203,32 +7203,32 @@ TMrConstruction_Stop( UUmAssert(gInGame == UUcFalse); UUmAssert(gConstructionFile != NULL); - + printf("running major check... "UUmNL); TMmInstanceFile_MajorCheck(gConstructionFile, UUcFalse); - + printf("writing to disk... "UUmNL); TMiInstanceFile_Save(gConstructionFile); - + printf("verifying all touched... "UUmNL); TMmInstanceFile_VerifyAllTouched(gConstructionFile); - + printf("dumping placeholders... "UUmNL); - + sprintf(temp, "%s", BFrFileRef_GetLeafName(gConstructionFile->instanceFileRef)); p = strchr(temp, '.'); if(p != NULL) *p = 0; - + sprintf(fileName, "%s_phs.txt", temp); - + file = fopen(fileName, "wb"); TMiInstanceFile_DumpPlaceHolders(gConstructionFile, fileName, file); fclose(file); - + TMiInstanceFile_Dispose(gConstructionFile); gConstructionFile = NULL; - + return UUcError_None; } @@ -7241,17 +7241,17 @@ TMrConstruction_Instance_Renew( { void* dataPtr; TMtInstanceDescriptor* targetInstDesc; - + UUmAssert(gInGame == UUcFalse); UUmAssert(gConstructionFile != NULL); - + *outNewInstance = NULL; - + if(inInstanceName == NULL) { return TMrConstruction_Instance_NewUnique(inTemplateTag, inVarArrayLength, outNewInstance); } - + targetInstDesc = TMiInstanceFile_Instance_FindInstanceDescriptor(gConstructionFile, inTemplateTag, inInstanceName); if(targetInstDesc == NULL || targetInstDesc->dataPtr == NULL) { @@ -7262,32 +7262,32 @@ TMrConstruction_Instance_Renew( { TMiInstanceFile_Instance_Clean(gConstructionFile, inTemplateTag, inInstanceName); dataPtr = TMiInstanceFile_Instance_ResizeVarArray(targetInstDesc->dataPtr, inVarArrayLength); - + targetInstDesc->dataPtr = dataPtr; } - + if(dataPtr == NULL) { return UUcError_OutOfMemory; } - + UUmAssert(targetInstDesc != NULL); - + #if defined(DEBUGGING) && DEBUGGING - + if(!(targetInstDesc->templatePtr->flags & TMcTemplateFlag_Registered)) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "template not registered"); } - + #endif - + targetInstDesc->flags |= (TMtDescriptorFlags)(TMcDescriptorFlags_Touched | TMcDescriptorFlags_InBatchFile); TMmInstanceData_Verify(dataPtr); - + *outNewInstance = dataPtr; - + return UUcError_None; } @@ -7299,30 +7299,30 @@ TMrConstruction_Instance_NewUnique( { void* dataPtr; TMtTemplateDefinition* templatePtr; - + UUmAssert(gInGame == UUcFalse); UUmAssert(gConstructionFile != NULL); - + templatePtr = TMiTemplate_FindDefinition(inTemplateTag); - + #if defined(DEBUGGING) && DEBUGGING - + if(!(templatePtr->flags & TMcTemplateFlag_Registered)) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "template not registered"); } - + #endif - + dataPtr = TMiInstanceFile_Instance_Create( gConstructionFile, inTemplateTag, 0, inVarArrayLength); - + *outReference = dataPtr; - + return UUcError_None; } @@ -7338,21 +7338,21 @@ TMrConstruction_Instance_GetPlaceHolder( UUmAssertReadPtr(inInstanceName, sizeof(char)); UUmAssertWritePtr(outPlaceHolder, sizeof(TMtPlaceHolder)); - if('\0' == inInstanceName[0]) + if('\0' == inInstanceName[0]) { return UUcError_Generic; } - + if(gInGame == UUcTrue) { return TMrInstance_GetDataPtr(inTemplateTag, inInstanceName, (void**)outPlaceHolder); } - + //UUmAssert(gInGame == UUcFalse); //UUmAssert(gConstructionFile != NULL); - + *outPlaceHolder = 0; - + targetDesc = TMiInstanceFile_Instance_FindInstanceDescriptor(gConstructionFile, inTemplateTag, inInstanceName); if(targetDesc == NULL) { @@ -7366,9 +7366,9 @@ TMrConstruction_Instance_GetPlaceHolder( targetDesc = TMiInstanceFile_Instance_FindInstanceDescriptor(gConstructionFile, inTemplateTag, inInstanceName); UUmAssert(targetDesc != NULL); } - + TMiInstanceFile_Instance_Touch(gConstructionFile, targetDesc); - + // Always return an index if( 0 && targetDesc->dataPtr != NULL) { @@ -7378,7 +7378,7 @@ TMrConstruction_Instance_GetPlaceHolder( { *outPlaceHolder = TMmPlaceHolder_MakeFromIndex(targetDesc - gConstructionFile->instanceDescriptors); } - + return UUcError_None; } @@ -7392,37 +7392,37 @@ TMrConstruction_Instance_CheckExists( UUtUns8* swapCode; UUtUns8* dataPtr; UUtBool result; - + targetDesc = TMiInstanceFile_Instance_FindInstanceDescriptor(gConstructionFile, inTemplateTag, inInstanceName); if(targetDesc == NULL || targetDesc->dataPtr == NULL) { return UUcFalse; } - + /* * Recursively look for unique instances that got out of date */ { swapCode = targetDesc->templatePtr->swapCodes; dataPtr = targetDesc->dataPtr; - + result = TMiInstance_CheckExists_Recursive( &swapCode, &dataPtr, gConstructionFile); - + if(result == UUcFalse) return UUcFalse; } - + TMiInstanceFile_Instance_Touch(gConstructionFile, targetDesc); - + targetDesc->flags |= (TMtDescriptorFlags)(TMcDescriptorFlags_Touched | TMcDescriptorFlags_InBatchFile); - + if(outCreationDate != NULL) { *outCreationDate = targetDesc->creationDate; } - + return UUcTrue; } @@ -7432,17 +7432,17 @@ TMrConstruction_Instance_Keep( char* inInstanceName) { TMtInstanceDescriptor* targetDesc; - + targetDesc = TMiInstanceFile_Instance_FindInstanceDescriptor(gConstructionFile, inTemplateTag, inInstanceName); if(targetDesc == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find instance"); } - + TMiInstanceFile_Instance_Touch(gConstructionFile, targetDesc); - + targetDesc->flags |= (TMtDescriptorFlags)(TMcDescriptorFlags_Touched | TMcDescriptorFlags_InBatchFile); - + return UUcError_None; } @@ -7470,7 +7470,7 @@ TMrConstruction_ConvertToNativeEndian( TMtInstanceFile* instanceFile; TMtInstanceDescriptor* curInstDesc; UUtUns32 curDescIndex; - + // create the file iterator error = BFrDirectory_FileIterator_New( @@ -7479,7 +7479,7 @@ TMrConstruction_ConvertToNativeEndian( ".dat", &fileIterator); UUmError_ReturnOnError(error); - + while (1) { // get the next file in the directory from the file iterator @@ -7488,20 +7488,20 @@ TMrConstruction_ConvertToNativeEndian( { break; } - + error = BFrFile_Open(datFileRef, "r", &datFile); UUmError_ReturnOnError(error); error = TMiInstanceFile_LoadHeader(datFile, &fileHeader, &needsSwapping); UUmError_ReturnOnError(error); - + if(needsSwapping) { fprintf(stderr, "converting instance file %s\n", BFrFileRef_GetLeafName(datFileRef)); - + error = TMiInstanceFile_MakeFromFileRef(datFileRef, &instanceFile, UUcFalse); UUmError_ReturnOnError(error); - + BFrFile_Close(datFile); BFrFileRef_Dispose(datFileRef); @@ -7512,16 +7512,16 @@ TMrConstruction_ConvertToNativeEndian( curDescIndex++, curInstDesc++) { curInstDesc->flags |= TMcDescriptorFlags_Touched; - + if(!(curInstDesc->flags & TMcDescriptorFlags_PlaceHolder)) { curInstDesc->flags |= TMcDescriptorFlags_InBatchFile; } } - + error = TMiInstanceFile_Save(instanceFile); UUmError_ReturnOnError(error); - + TMiInstanceFile_Dispose(instanceFile); } else @@ -7530,12 +7530,12 @@ TMrConstruction_ConvertToNativeEndian( BFrFileRef_Dispose(datFileRef); } } - + // delete the file iterator BFrDirectory_FileIterator_Delete(fileIterator); - + gConstructionFile = NULL; - + return UUcError_None; } @@ -7547,7 +7547,7 @@ TMiInstanceFile_VerifyRobust( { UUtUns32 curDescIndex; TMtInstanceDescriptor* curDesc; - + TMmInstanceFile_Verify(inInstanceFile); for(curDescIndex = 0, curDesc = inInstanceFile->instanceDescriptors; @@ -7572,7 +7572,7 @@ TMrVerifyAll( UUtUns16 curFileIndex; TMiInstanceFile_VerifyRobust(&TMgTempInstanceFile); - + for(curFileIndex = 0; curFileIndex < TMgNumLevel0Files; curFileIndex++) { TMiInstanceFile_VerifyRobust(TMgLevel0Files[curFileIndex]); @@ -7582,7 +7582,7 @@ TMrVerifyAll( { TMiInstanceFile_VerifyRobust(TMgCurLevelFiles[curFileIndex]); } - + } static void @@ -7593,9 +7593,9 @@ TMiSwapCode_Dump_Indent( UUtUns32 inSwapCodeOffset) { UUtUns32 itr; - + fprintf(inFile, "[%04d, %04d]", inSwapCodeOffset, inDataOffset); - + for(itr = 0; itr < inIndent; itr++) { fprintf(inFile, "\t"); @@ -7616,15 +7616,15 @@ TMiSwapCode_Dump_Recursive( UUtBool stop; UUtUns8 count; UUtUns32 savedDataOffset; - + curSwapCode = *ioSwapCode; stop = UUcFalse; - + while(!stop) { swapCode = *curSwapCode++; - + switch(swapCode) { case TMcSwapCode_8Byte: @@ -7632,25 +7632,25 @@ TMiSwapCode_Dump_Recursive( fprintf(inFile, "8Byte(%02x)\n", TMcSwapCode_8Byte); curDataOffset += 8; break; - + case TMcSwapCode_4Byte: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "4Byte(%02x)\n", TMcSwapCode_4Byte); curDataOffset += 4; break; - + case TMcSwapCode_2Byte: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "2Byte(%02x)\n", TMcSwapCode_2Byte); curDataOffset += 2; break; - + case TMcSwapCode_1Byte: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "1Byte(%02x)\n", TMcSwapCode_1Byte); curDataOffset += 1; break; - + case TMcSwapCode_BeginArray: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "begin array(%02x)\n", TMcSwapCode_BeginArray); @@ -7666,13 +7666,13 @@ TMiSwapCode_Dump_Recursive( inSwapCodeBase); curDataOffset += (curDataOffset - savedDataOffset) * (count - 1); break; - + case TMcSwapCode_EndArray: stop = UUcTrue; TMiSwapCode_Dump_Indent(inFile, inIndent-1, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "end array(%02x)\n", TMcSwapCode_EndArray); break; - + case TMcSwapCode_BeginVarArray: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "begin vararray(%02x)\n", TMcSwapCode_BeginVarArray); @@ -7695,7 +7695,7 @@ TMiSwapCode_Dump_Recursive( default: UUmAssert(!"Swap codes fucked up"); } - + TMiSwapCode_Dump_Recursive( inFile, inIndent+1, @@ -7703,13 +7703,13 @@ TMiSwapCode_Dump_Recursive( &curDataOffset, inSwapCodeBase); break; - + case TMcSwapCode_EndVarArray: TMiSwapCode_Dump_Indent(inFile, inIndent-1, curDataOffset, curSwapCode - inSwapCodeBase - 1); fprintf(inFile, "end vararray(%02x)\n", TMcSwapCode_EndVarArray); stop = UUcTrue; break; - + case TMcSwapCode_TemplatePtr: case TMcSwapCode_TemplateReference: TMiSwapCode_Dump_Indent(inFile, inIndent, curDataOffset, curSwapCode - inSwapCodeBase - 1); @@ -7720,7 +7720,7 @@ TMiSwapCode_Dump_Recursive( (*(UUtUns32*)curSwapCode >> 16) & 0xFF, (*(UUtUns32*)curSwapCode >> 8) & 0xFF, (*(UUtUns32*)curSwapCode >> 0) & 0xFF); - + curSwapCode += 4; curDataOffset += 4; } @@ -7730,12 +7730,12 @@ TMiSwapCode_Dump_Recursive( curDataOffset += 8; } break; - + default: UUmDebugStr("swap codes are messed up."); } } - + *ioSwapCode = curSwapCode; *ioDataOffset = curDataOffset; } @@ -7746,17 +7746,17 @@ TMrSwapCode_DumpDefinition( TMtTemplateDefinition* inTemplateDefinition) { fprintf(inFile, "Name: %s\n", inTemplateDefinition->name); - fprintf(inFile, "Tag: %c%c%c%c\n", + fprintf(inFile, "Tag: %c%c%c%c\n", (inTemplateDefinition->tag >> 24) & 0xFF, (inTemplateDefinition->tag >> 16) & 0xFF, (inTemplateDefinition->tag >> 8) & 0xFF, (inTemplateDefinition->tag >> 0) & 0xFF); - + fprintf(inFile, "Swap Codes:\n"); { UUtUns8* swapCodes = inTemplateDefinition->swapCodes; UUtUns32 dataOffset = 0; - + TMiSwapCode_Dump_Indent(inFile, 0, 0, 0); fprintf(inFile, "begin array\n"); TMiSwapCode_Dump_Recursive(inFile, 1, &swapCodes, &dataOffset, inTemplateDefinition->swapCodes); @@ -7768,11 +7768,11 @@ TMrSwapCode_DumpAll( FILE* inFile) { UUtUns32 itr; - + for(itr = 0; itr < TMgNumTemplateDefinitions; itr++) { fprintf(inFile, "******************************************\n"); TMrSwapCode_DumpDefinition(inFile, TMgTemplateDefinitionArray + itr); } - + } diff --git a/BungieFrameWork/BFW_Source/BFW_TextSystem/BFW_TS_Private.h b/BungieFrameWork/BFW_Source/BFW_TextSystem/BFW_TS_Private.h index f8e4871..741b3e9 100644 --- a/BungieFrameWork/BFW_Source/BFW_TextSystem/BFW_TS_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_TextSystem/BFW_TS_Private.h @@ -32,7 +32,7 @@ struct TStTextContext UUtUns16 font_size; // desired font size TStFontStyle font_style; // desired font style - + UUtBool use_formatting_commands; }; @@ -51,4 +51,4 @@ typedef struct TStFormatCharacterColor extern TStFormatCharacterColor TSgColorFormattingCharacters[]; // ====================================================================== -#endif /* BFW_TEXTSYSTEM_PRIVATE_H */ \ No newline at end of file +#endif /* BFW_TEXTSYSTEM_PRIVATE_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_TextSystem/BFW_TextSystem.c b/BungieFrameWork/BFW_Source/BFW_TextSystem/BFW_TextSystem.c index ea1969b..991e063 100644 --- a/BungieFrameWork/BFW_Source/BFW_TextSystem/BFW_TextSystem.c +++ b/BungieFrameWork/BFW_Source/BFW_TextSystem/BFW_TextSystem.c @@ -1,12 +1,12 @@ /* FILE: BFW_TextSystem.c - + AUTHOR: Kevin Armstrong - + CREATED: ???? PURPOSE: text - + Copyright 1997-1998 */ @@ -111,7 +111,7 @@ // hi level mixers #define Mix8888(s,d,i) (MixAlpha8888(s,d,i) | MixRed8888(s,d,i) | MixGreen8888(s,d,i) | \ MixBlue8888(s,d,i)) - + #define Mix4444(s,d,i) (MixAlpha4444(s,d,i) | MixRed4444(s,d,i) | MixGreen4444(s,d,i) | \ MixBlue4444(s,d,i)) @@ -177,7 +177,7 @@ typedef struct TStCell TStGlyph *glyph; UUtUns32 time; M3tTextureCoord uv[2]; // (left, top) and (right, bottom) - + } TStCell; typedef struct TStFont_PrivateData @@ -189,11 +189,11 @@ typedef struct TStFont_PrivateData UUtUns32 num_cells_y; float u_ratio; float v_ratio; - + M3tTextureMap *texture; TStCell *cells; - + } TStFont_PrivateData; #endif // SINGLE_TEXTURE_CACHE @@ -223,7 +223,7 @@ static TStGlyph* TSiFont_GetGlyph( const TStFont *inFont, const UUtUns16 inCharacter); - + static void TSiGlyph_Draw( TStGlyph *inGlyph, @@ -243,14 +243,14 @@ TSiFont_GetTexture( static void TSiTextureCache_RemoveRow( void); - + // ====================================================================== // functions // ====================================================================== #if SINGLE_TEXTURE_CACHE // ====================================================================== -#if 0 +#if 0 #pragma mark - #endif // ====================================================================== @@ -269,7 +269,7 @@ TSrTextureCache_Initialize( "Font Texture Cache", &TSgTextureCache.texture); UUmError_ReturnOnErrorMsg(error, "Unable to create font texture cache"); - M3rTextureMap_Fill_Shade(TSgTextureCache.texture, IMcShade_None, NULL); + M3rTextureMap_Fill_Shade(TSgTextureCache.texture, IMcShade_None, NULL); // set up the texture cache TSgTextureCache.draw_color = IMrPixel_FromShade(TSgTextureCache.texture->texelType, IMcShade_White); @@ -351,7 +351,7 @@ TSiTextureCache_RemoveRow( } } -// COrConsole_Printf(" removed %d (%d) -> now free %d (%d)", row->y_start, row->y_height, +// COrConsole_Printf(" removed %d (%d) -> now free %d (%d)", row->y_start, row->y_height, // TSgTextureCache.free_start, TSgTextureCache.free_height); #if defined(DEBUGGING) && DEBUGGING @@ -369,7 +369,7 @@ TSiTextureCache_RemoveRow( UUmAssert(bounds.bottom <= TSgTextureCache.texture->height); UUmAssert(bounds.right >= bounds.left); UUmAssert(bounds.bottom >= bounds.top); - + M3rTextureMap_Fill_Shade(TSgTextureCache.texture, IMcShade_None, &bounds); } #endif @@ -400,7 +400,7 @@ TSiTextureCache_GetCell( // determine whether we must make a new row for this glyph row = NULL; - if (TSgTextureCache.row_count > 0) { + if (TSgTextureCache.row_count > 0) { // find the last row row_index = (TSgTextureCache.row_start + TSgTextureCache.row_count - 1) % TScTextureCache_MaxRows; row = &TSgTextureCache.rows[row_index]; @@ -512,7 +512,7 @@ TSiTextureCache_GetCell( } // we must remove the oldest row and keep checking -// COrConsole_Printf("removerow: free %d (%d), request row at %d -> %d", +// COrConsole_Printf("removerow: free %d (%d), request row at %d -> %d", // TSgTextureCache.free_start, TSgTextureCache.free_height, row->y_start, inHeight); TSiTextureCache_RemoveRow(); } @@ -628,7 +628,7 @@ TSiTextureCache_RequireGlyph( } } #endif - + cell = &TSgTextureCache.cells[cell_index]; cell->font = inFont; cell->glyph = ioGlyph; @@ -670,10 +670,10 @@ TSiTextureCache_RenderGlyph( IMtPoint2D texture_origin; UUtRect bounds; IMtPoint2D dest; - + texture_origin.x = 0; texture_origin.y = 0; - + bounds.left = inCell->position.x; bounds.top = inCell->position.y; bounds.right = bounds.left + (UUtInt16) (inGlyph->width); @@ -688,9 +688,9 @@ TSiTextureCache_RenderGlyph( UUmAssert(bounds.bottom <= TSgTextureCache.texture->height); UUmAssert(bounds.right >= bounds.left); UUmAssert(bounds.bottom >= bounds.top); - + M3rTextureMap_Fill_Shade(TSgTextureCache.texture, IMcShade_None, &bounds); - + TSiGlyph_Draw(inGlyph, inFont, TSgTextureCache.texture, &texture_origin, &bounds, &dest, TSgTextureCache.draw_color); } @@ -698,7 +698,7 @@ TSiTextureCache_RenderGlyph( #endif // SINGLE_TEXTURE_CACHE // ====================================================================== -#if 0 +#if 0 #pragma mark - #endif // ====================================================================== @@ -724,11 +724,11 @@ TSiString_GetNextCharacter( const char *inString) { UUtUns16 character; - + character = (UUtUns16)((UUtUns8)inString[0] << 8); if (character == 0) return character; character |= (UUtUns16)((UUtUns8)inString[1]); - + if (TSiCharacter_IsDoubleByte(character) == UUcFalse) { character >>= 8; @@ -738,7 +738,7 @@ TSiString_GetNextCharacter( } // ====================================================================== -#if 0 +#if 0 #pragma mark - #endif // ====================================================================== @@ -754,11 +754,11 @@ TSiGlyph_Draw( IMtPixel inColor) { UUtUns16 i, j; - + UUtUns8 *src_texels, *src_texel; UUtUns32 src_rowtexels; UUtInt16 src_x, src_y; - + UUtUns16 *dst_texels_16, *dst_texel_16; UUtUns32 *dst_texels_32, *dst_texel_32; UUtUns8 *dst_texels_8, *dst_texel_8; @@ -766,12 +766,12 @@ TSiGlyph_Draw( UUtInt16 dst_x, dst_y; UUtInt16 draw_width, draw_height; - + UUtUns32 textColorTexelValue; - + UUtRect texture_rect; UUtRect dest_rect; - + if (inTexture->pixels == NULL) { UUmAssert(!"TSiGlyph_Draw: cannot draw into texture, not loaded"); return; @@ -782,34 +782,34 @@ TSiGlyph_Draw( texture_rect.top = inTextureOrigin->y; texture_rect.right = texture_rect.left + inTexture->width; texture_rect.bottom = texture_rect.top + inTexture->height; - + // intersect the texture_rect with inBounds IMrRect_Intersect( &texture_rect, inBounds, &dest_rect); - + // do the rectangles interect? if ((dest_rect.right == 0) || (dest_rect.bottom == 0)) return; - + // set dst_x and dst_y dst_x = inDestination->x - inGlyph->origin_x; dst_y = inDestination->y - inGlyph->origin_y; - + // set src_x and src_y src_x = 0; src_y = 0; - + // set draw_width and draw_height draw_width = inGlyph->width; draw_height = inGlyph->height; - + // check right edge of visible area if ((dst_x + draw_width) > dest_rect.right) { draw_width = dest_rect.right - dst_x; } - + // check left edge of visible area if (dst_x < dest_rect.left) { @@ -817,13 +817,13 @@ TSiGlyph_Draw( dst_x = dest_rect.left; draw_width -= src_x; } - + // check bottom edge of visible area if ((dst_y + draw_height) > dest_rect.bottom) { draw_height = dest_rect.bottom - dst_y; } - + // check top edge of visible area if (dst_y < dest_rect.top) { @@ -831,17 +831,17 @@ TSiGlyph_Draw( dst_y = dest_rect.top; draw_height -= src_y; } - + // don't draw if there is nothing to draw if ((draw_width <= 0) || (draw_height <= 0)) return; - + // offset the dst_x and dst_y by the texture_origin dst_x -= inTextureOrigin->x; dst_y -= inTextureOrigin->y; - + // set the color textColorTexelValue = inColor.value; - + // get a pointer to the source pixels src_rowtexels = inGlyph->width; src_texels = @@ -861,7 +861,7 @@ TSiGlyph_Draw( ((UUtUns8*)inTexture->pixels) + dst_x + (dst_y * dst_rowtexels); - + switch(inTexture->texelType) { case IMcPixelType_A8: @@ -869,7 +869,7 @@ TSiGlyph_Draw( { dst_texel_8 = dst_texels_8; src_texel = src_texels; - + for (j = 0; j < draw_width; j++) { *dst_texel_8 = 0xFF - *src_texel; @@ -887,7 +887,7 @@ TSiGlyph_Draw( { dst_texel_8 = dst_texels_8; src_texel = src_texels; - + for (j = 0; j < draw_width; j++) { *dst_texel_8 = Mix8(*dst_texel_8, (UUtUns8) textColorTexelValue, *src_texel); @@ -905,7 +905,7 @@ TSiGlyph_Draw( { dst_texel_8 = dst_texels_8; src_texel = src_texels; - + for (j = 0; j < draw_width; j++) { *dst_texel_8 = MixA4I4(*dst_texel_8, (UUtUns8) textColorTexelValue, *src_texel); @@ -934,7 +934,7 @@ TSiGlyph_Draw( ((UUtUns16*)inTexture->pixels) + dst_x + (dst_y * dst_rowtexels); - + switch (inTexture->texelType) { case IMcPixelType_ARGB4444: @@ -942,7 +942,7 @@ TSiGlyph_Draw( { dst_texel_16 = dst_texels_16; src_texel = src_texels; - + for (j = 0; j < draw_width; j++) { *dst_texel_16 = Mix4444(*dst_texel_16, (UUtUns16)textColorTexelValue, *src_texel); @@ -959,7 +959,7 @@ TSiGlyph_Draw( { dst_texel_16 = dst_texels_16; src_texel = src_texels; - + for (j = 0; j < draw_width; j++) { *dst_texel_16 = Mix555(*dst_texel_16, (UUtUns16)textColorTexelValue, *src_texel); @@ -970,13 +970,13 @@ TSiGlyph_Draw( src_texels += src_rowtexels; } break; - + case IMcPixelType_ARGB1555: for (i = 0; i < draw_height; i++) { dst_texel_16 = dst_texels_16; src_texel = src_texels; - + for (j = 0; j < draw_width; j++) { *dst_texel_16 = Mix1555(*dst_texel_16, (UUtUns16)textColorTexelValue, *src_texel); @@ -992,7 +992,7 @@ TSiGlyph_Draw( UUmAssert(0); } break; - + // draw into a 32bit texture case IMcPixelType_ARGB8888: dst_rowtexels = inTexture->width; @@ -1000,12 +1000,12 @@ TSiGlyph_Draw( ((UUtUns32*)inTexture->pixels) + dst_x + (dst_y * dst_rowtexels); - + for (i = 0; i < draw_height; i++) { dst_texel_32 = dst_texels_32; src_texel = src_texels; - + for (j = 0; j < draw_width; j++) { *dst_texel_32 = Mix8888(*dst_texel_32, textColorTexelValue, *src_texel); @@ -1016,7 +1016,7 @@ TSiGlyph_Draw( src_texels += src_rowtexels; } break; - + default: UUmAssert(0); break; @@ -1033,11 +1033,11 @@ TSiTextureCache_GetCellUVs( // set lt and rb outUVs[0] = inCell->uv[0]; outUVs[3] = inCell->uv[1]; - + // set rt outUVs[1].u = outUVs[3].u; outUVs[1].v = outUVs[0].v; - + // set lb outUVs[2].u = outUVs[0].u; outUVs[2].v = outUVs[3].v; @@ -1058,12 +1058,12 @@ TSiGlyph_DrawToCell( UUtRect bounds; IMtPoint2D dest; IMtPixel color; - + color = IMrPixel_FromShade(inPrivateData->texture->texelType, IMcShade_White); - + texture_origin.x = 0; texture_origin.y = 0; - + bounds.left = inX * (UUtInt16)inPrivateData->cell_width; bounds.top = inY * (UUtInt16)inPrivateData->cell_height; bounds.right = bounds.left + (UUtInt16)inPrivateData->cell_width; @@ -1075,7 +1075,7 @@ TSiGlyph_DrawToCell( UUmAssert(bounds.bottom <= inPrivateData->texture->height); UUmAssert(bounds.right >= bounds.left); UUmAssert(bounds.bottom >= bounds.top); - + dest.x = bounds.left; dest.y = bounds.top + inFont->ascending_height; @@ -1083,7 +1083,7 @@ TSiGlyph_DrawToCell( inPrivateData->texture, IMcShade_None, &bounds); - + TSiGlyph_Draw( inGlyph, inFont, @@ -1101,24 +1101,24 @@ TSiGlyph_SetUVsFromCell( M3tTextureCoord *outUVs) { TStCell *cell; - + UUmAssert(inGlyph); UUmAssertWritePtr(outUVs, sizeof(M3tTextureCoord) * 4); - + cell = (TStCell*)inGlyph->cell; UUmAssert(cell); - + // update it's usage cell->time = UUrMachineTime_Sixtieths(); // set lt and rb outUVs[0] = cell->uv[0]; outUVs[3] = cell->uv[1]; - + // set rt outUVs[1].u = outUVs[3].u; outUVs[1].v = outUVs[0].v; - + // set lb outUVs[2].u = outUVs[0].u; outUVs[2].v = outUVs[3].v; @@ -1126,7 +1126,7 @@ TSiGlyph_SetUVsFromCell( #endif // SINGLE_TEXTURE_CACHE // ====================================================================== -#if 0 +#if 0 #pragma mark - #endif // ====================================================================== @@ -1153,10 +1153,10 @@ TSrFont_DisplayCacheTexture( M3rDraw_State_SetInt(M3cDrawStateIntType_Fill, M3cDrawState_Fill_Solid); M3rDraw_State_SetInt(M3cDrawStateIntType_ZCompare, M3cDrawState_ZCompare_Off); M3rDraw_State_SetInt(M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Texture_Unlit); - M3rDraw_State_SetInt(M3cDrawStateIntType_Fill, M3cDrawState_Fill_Solid); + M3rDraw_State_SetInt(M3cDrawStateIntType_Fill, M3cDrawState_Fill_Solid); M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_White); M3rDraw_State_SetInt(M3cDrawStateIntType_Alpha, M3cMaxAlpha); - M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, TSgTextureCache.texture); + M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, TSgTextureCache.texture); M3rDraw_State_Commit(); @@ -1177,7 +1177,7 @@ TSrFont_DisplayCacheTexture( uv[2].v = 1.0f; uv[3].u = 1.0f; uv[3].v = 1.0f; - + M3rDraw_Sprite(points, uv); M3rGeom_State_Pop(); @@ -1220,10 +1220,10 @@ TSiFont_DisplayCacheTexture( uv[2].v = 1.0f; uv[3].u = 1.0f; uv[3].v = 1.0f; - + M3rDraw_Sprite(points, uv); } - + if (inCell) { M3tTextureMap *font_texture = TSiFont_GetTexture(inFont); @@ -1231,7 +1231,7 @@ TSiFont_DisplayCacheTexture( UUtInt32 start_y = (UUtInt32) (inCell->uv[0].v * font_texture->height); UUtInt32 end_x = (UUtInt32) (inCell->uv[1].u * font_texture->width); UUtInt32 end_y = (UUtInt32) (inCell->uv[1].v * font_texture->height); - + M3rDraw_Sprite_Debug(font_texture, &screen_dest, start_x, start_y, end_x-start_x, end_y-start_y); } } @@ -1250,10 +1250,10 @@ TSiFont_Initialize( UUtUns32 num_glyphs; TStGlyph *glyph; UUtUns32 needed_cells_y; - + // clear the memory UUrMemory_Clear(inPrivateData, sizeof(TStFont_PrivateData)); - + // get the number of glyphs in the font and the width of the widest glyph num_glyphs = 0; max_glyph_width = 0; @@ -1263,14 +1263,14 @@ TSiFont_Initialize( if (glyph) { num_glyphs++; - + if (glyph->width > max_glyph_width) { max_glyph_width = glyph->width; } } } - + // initialize the private data inPrivateData->cell_width = max_glyph_width; inPrivateData->cell_height = TSrFont_GetAscendingHeight(inFont) + @@ -1278,7 +1278,7 @@ TSiFont_Initialize( inPrivateData->num_cells_x = M3cTextureMap_MaxWidth / inPrivateData->cell_width; inPrivateData->num_cells_y = M3cTextureMap_MaxWidth / inPrivateData->cell_height; inPrivateData->num_cells = inPrivateData->num_cells_x * inPrivateData->num_cells_y; - + // try to adjust inPrivateData->num_cells_y to minimize the number of cells created needed_cells_y = (num_glyphs / inPrivateData->num_cells_x) + 1; if (needed_cells_y < inPrivateData->num_cells_y) @@ -1286,7 +1286,7 @@ TSiFont_Initialize( inPrivateData->num_cells_y = needed_cells_y; inPrivateData->num_cells = inPrivateData->num_cells_x * inPrivateData->num_cells_y; } - + // create a texture map error = M3rTextureMap_New( @@ -1298,12 +1298,12 @@ TSiFont_Initialize( "Font Texture", &inPrivateData->texture); UUmError_ReturnOnErrorMsg(error, "Unable to create texture map"); - + M3rTextureMap_Fill_Shade( - inPrivateData->texture, + inPrivateData->texture, IMcShade_None, NULL); - + // calculate the u and v ratios inPrivateData->u_ratio = 1.0f / (float)inPrivateData->texture->width; inPrivateData->v_ratio = 1.0f / (float)inPrivateData->texture->height; @@ -1311,26 +1311,26 @@ TSiFont_Initialize( // allocate the cells inPrivateData->cells = (TStCell*)UUrMemory_Block_NewClear(sizeof(TStCell) * inPrivateData->num_cells); UUmError_ReturnOnNull(inPrivateData->cells); - + // preload some characters #if 1 if (1) { UUtInt16 x; UUtInt16 y; - char *string = + char *string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "_=+-[]{};:'\",./<>?!@#$%^&*()" "abcdefghijklmnopqrstuvwxyz" "1234567890"; - + for (y = 0; y < (UUtInt16)inPrivateData->num_cells_y; y++) { for (x = 0; x < (UUtInt16)inPrivateData->num_cells_x; x++) { TStGlyph *glyph; UUtUns16 character; - + character = TSiString_GetNextCharacter(string); glyph = TSiFont_GetGlyph(inFont, character); if (glyph == NULL) { break; } @@ -1366,20 +1366,20 @@ TSiFont_GetGlyph( { UUtUns8 glyph_array_index; TStGlyph *glyph; - + // no glyph yet glyph = NULL; - + // get the index of the glyph array glyph_array_index = HIGH_BYTE(inCharacter); - + // make sure the glyph array exists if (inFont->glyph_arrays[glyph_array_index]) { // return the glyph glyph = &inFont->glyph_arrays[glyph_array_index]->glyphs[LOW_BYTE(inCharacter)]; } - + return glyph; } @@ -1390,11 +1390,11 @@ TSiFont_GetTexture( const TStFont *inFont) { TStFont_PrivateData *private_data; - + // get the private data private_data = (TStFont_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(TSgTemplate_Font_PrivateData, inFont); UUmAssert(private_data); - + return private_data->texture; } @@ -1408,15 +1408,15 @@ TSiFont_ProcHandler( UUtError error; TStFont *font; TStFont_PrivateData *private_data; - + // get a pointer to the font font = (TStFont*)inInstancePtr; UUmAssert(font); - + // get a pointer to the font's private data private_data = (TStFont_PrivateData*)inPrivateData; UUmAssert(private_data); - + switch(inMessage) { case TMcTemplateProcMessage_NewPostProcess: @@ -1424,7 +1424,7 @@ TSiFont_ProcHandler( error = TSiFont_Initialize(font, private_data); UUmError_ReturnOnError(error); break; - + case TMcTemplateProcMessage_DisposePreProcess: if (private_data->cells) { @@ -1432,10 +1432,10 @@ TSiFont_ProcHandler( private_data->cells = NULL; } break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; @@ -1457,15 +1457,15 @@ TSiFont_PutGlyphInCell( TStCell *cell; float x; float y; - + // get the private data private_data = (TStFont_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(TSgTemplate_Font_PrivateData, inFont); UUmAssert(private_data); - + // find the oldest cell oldest_time = UUrMachineTime_Sixtieths(); oldest_cell = 0; - + for (i = 0; i < private_data->num_cells; i++) { if (private_data->cells[i].glyph == NULL) @@ -1473,53 +1473,53 @@ TSiFont_PutGlyphInCell( oldest_cell = i; break; } - + if (private_data->cells[i].time < oldest_time) { oldest_time = private_data->cells[i].time; oldest_cell = i; } } - + // get a pointer to the cell cell = &private_data->cells[oldest_cell]; - + // make sure the old glyph no longer points to this cell if (cell->glyph) { cell->glyph->cell = 0; } - - // put the new glyph into the cell + + // put the new glyph into the cell ioGlyph->cell = (UUtUns32)cell; cell->glyph = ioGlyph; cell->time = UUrMachineTime_Sixtieths(); - + // calculate the x and y of the cell y = (float)(oldest_cell / private_data->num_cells_x); x = (float)(oldest_cell - (y * private_data->num_cells_x)); - + // calculate (left, top) cell->uv[0].u = x * private_data->cell_width; cell->uv[0].v = y * private_data->cell_height; - + // calculate (right, bottom) cell->uv[1].u = cell->uv[0].u + (float)ioGlyph->width; cell->uv[1].v = cell->uv[0].v + (float)(inFont->ascending_height + inFont->descending_height); - + // divide (left, top) and (right, bottom) values by the texture width and height cell->uv[0].u *= private_data->u_ratio; cell->uv[0].v *= private_data->v_ratio; cell->uv[1].u *= private_data->u_ratio; cell->uv[1].v *= private_data->v_ratio; - + // draw the glyph into the texture TSiGlyph_DrawToCell(ioGlyph, inFont, private_data, (UUtInt16)x, (UUtInt16)y); } #endif // !SINGLE_TEXTURE_CACHE // ====================================================================== -#if 0 +#if 0 #pragma mark - #endif // ====================================================================== @@ -1531,29 +1531,29 @@ TSiFontFamily_IsBreakingCharacter( { char *string; UUtBool result; - + string = inFontFamily->font_language->breaking_2; result = UUcFalse; - + while (1) { UUtUns16 character; - + character = TSiString_GetNextCharacter(string); - + // stop if inCharacter is found in the list if (character == inCharacter) { result = UUcTrue; break; } - + // stop if character is '\0' if (character == '\0') { break; } - + if (TSiCharacter_IsDoubleByte(character)) { string += 2; @@ -1563,12 +1563,12 @@ TSiFontFamily_IsBreakingCharacter( string += 1; } } - + return result; } // ====================================================================== -#if 0 +#if 0 #pragma mark - #endif // ====================================================================== @@ -1600,10 +1600,10 @@ TSiContext_DrawLine( UUtError i; IMtPoint2D dest; IMtPixel color; - + // copy the destination dest = *inDestination; - + // pre-clip top and bottom edge XXX - this may not work quite right if (((dest.y + TSrFont_GetLineHeight(inTextContext->font)) < inTextureOrigin->y) || (dest.y > (inTextureOrigin->y + inTexture->height))) @@ -1611,18 +1611,18 @@ TSiContext_DrawLine( // this line is not visible return; } - + // calculate the color color = IMrPixel_FromShade(inTexture->texelType, inShade); - + for (i = 0; i < inNumCharacters; i++) { TStGlyph *glyph; UUtUns16 character; - + // get the next character character = TSiString_GetNextCharacter(inString); - + // get the glyph for the character @@ -1634,11 +1634,11 @@ TSiContext_DrawLine( { // move to location of next character dest.x += glyph->kerning; - + // this character is not visible go on to the next one continue; } - + // pre-clip right edge if (dest.x > (inTextureOrigin->x + inTexture->width)) { @@ -1655,7 +1655,7 @@ TSiContext_DrawLine( inBounds, &dest, color); - + // move to location of next character dest.x += glyph->kerning; } @@ -1664,7 +1664,7 @@ TSiContext_DrawLine( // change the font style TSiContext_SetFontStyleByChar(inTextContext, character); }*/ - + // advance the string to the next character if (TSiCharacter_IsDoubleByte(character)) { @@ -1730,15 +1730,15 @@ TSiContext_DrawTextLine( M3tTextureCoord sprite_uv[4 * TScTextLineDrawClumpSize], *cur_uv; M3tPointScreen sprite_dest[2 * TScTextLineDrawClumpSize], *cur_dest; M3tTextureMap *font_texture; - + UUmAssert(inTextContext); UUmAssert(inString); UUmAssert(inBounds); - + // get a pointer to the font font = inTextContext->font; UUmAssert(font); - + #if SINGLE_TEXTURE_CACHE font_texture = TSgTextureCache.texture; #else @@ -1746,7 +1746,7 @@ TSiContext_DrawTextLine( #endif if (font_texture == NULL) { return; } - + // set up the states M3rDraw_State_Push(); @@ -1754,7 +1754,7 @@ TSiContext_DrawTextLine( M3rDraw_State_SetInt(M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); M3rDraw_State_SetInt(M3cDrawStateIntType_Fill, M3cDrawState_Fill_Solid); M3rDraw_State_SetInt(M3cDrawStateIntType_ZCompare, M3cDrawState_ZCompare_Off); - M3rDraw_State_SetInt(M3cDrawStateIntType_Fill, M3cDrawState_Fill_Solid); + M3rDraw_State_SetInt(M3cDrawStateIntType_Fill, M3cDrawState_Fill_Solid); M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, inShade); M3rDraw_State_SetInt(M3cDrawStateIntType_Alpha, inAlpha); M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, font_texture); @@ -1774,10 +1774,10 @@ TSiContext_DrawTextLine( { TStGlyph *glyph; UUtUns16 character; - + // get the next character character = TSiString_GetNextCharacter(inString); - + // get the glyph for the character glyph = TSiFont_GetGlyph(font, character); if (glyph) @@ -1817,14 +1817,14 @@ TSiContext_DrawTextLine( // set the UVs TSiGlyph_SetUVsFromCell(glyph, cur_uv); - + // set up the bounds bounds.left = dest.x; bounds.top = dest.y; bounds.right = bounds.left + glyph->width; bounds.bottom = bounds.top + font->ascending_height + font->descending_height; #endif - + // draw the glyph if it is visible if ((error == UUcError_None) && (WMrClipRect(inBounds, &bounds, cur_uv))) { @@ -1832,12 +1832,12 @@ TSiContext_DrawTextLine( cur_dest[0].y = (float)(bounds.top); cur_dest[0].z = 0.5f; cur_dest[0].invW = 2.f; - + cur_dest[1].x = (float)(bounds.right); cur_dest[1].y = (float)(bounds.bottom); cur_dest[1].z = 0.5f; cur_dest[1].invW = 2.f; - + num_sprites++; cur_dest += 2; cur_uv += 4; @@ -1852,9 +1852,9 @@ TSiContext_DrawTextLine( update_texture = UUcFalse; } } - + dest.x += glyph->kerning; - + // advance the string to the next character if (TSiCharacter_IsDoubleByte(character)) { @@ -1874,7 +1874,7 @@ TSiContext_DrawTextLine( } // ====================================================================== -#if 0 +#if 0 #pragma mark - #endif // ====================================================================== @@ -1884,16 +1884,16 @@ TSrInitialize( void) { UUtError error; - + // register the templates of the Text System error = TSrRegisterTemplates(); UUmError_ReturnOnError(error); error = TSrTextureCache_Initialize(); UUmError_ReturnOnError(error); - + #if !SINGLE_TEXTURE_CACHE - error = + error = TMrTemplate_PrivateData_New( TScTemplate_Font, sizeof(TStFont_PrivateData), @@ -1902,7 +1902,7 @@ TSrInitialize( UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); #endif - error = + error = TMrTemplate_InstallByteSwap( TScTemplate_Font, TSiFont_ByteSwapper); @@ -1910,7 +1910,7 @@ TSrInitialize( return UUcError_None; } - + // ---------------------------------------------------------------------- void TSrTerminate( @@ -1919,7 +1919,7 @@ TSrTerminate( } // ====================================================================== -#if 0 +#if 0 #pragma mark - #endif // ====================================================================== @@ -1939,13 +1939,13 @@ TSiContext_GetBestFont( // try the desired style ioTextContext->font = TSrFontFamily_GetFont( - ioTextContext->font_family, + ioTextContext->font_family, i, ioTextContext->font_style); if (ioTextContext->font != NULL) { break; } - + // try plain style ioTextContext->font = TSrFontFamily_GetFont( @@ -1976,7 +1976,7 @@ TSiContext_GetBestFont( i++; } } - + if (ioTextContext->font == NULL) { return UUcError_Generic; } else { @@ -1991,11 +1991,11 @@ TSrContext_Delete( TStTextContext *inTextContext) { UUmAssert(inTextContext != NULL); - + // delete the memory held by the text context UUrMemory_Block_Delete(inTextContext); } - + // ---------------------------------------------------------------------- UUtError TSrContext_DrawString( @@ -2018,12 +2018,12 @@ TSrContext_DrawString( UUmAssert(inBounds != NULL); UUmAssert(inDestination != NULL); UUmAssert(inTextContext->font_family != NULL); - + // format the string error = TSrContext_FormatString(inTextContext, inString, inBounds, inDestination, &string_format); UUmError_ReturnOnError(error); - + // get the template_tag for the texture template_tag = TMrInstance_GetTemplateTag(inTexture); switch (template_tag) @@ -2033,7 +2033,7 @@ TSrContext_DrawString( // set the texture origin texture_origin.x = 0; texture_origin.y = 0; - + // draw each segment of the string for (i = 0; i < string_format.num_segments; i++) { @@ -2050,31 +2050,31 @@ TSrContext_DrawString( } } break; - + case M3cTemplate_TextureMap_Big: { - M3tTextureMap_Big *texture_map_big; - + M3tTextureMap_Big *texture_map_big; + // get a pointer to the texture map big texture_map_big = (M3tTextureMap_Big*)inTexture; - + // draw each line of the string for (i = 0; i < string_format.num_segments; i++) { UUtUns16 x; UUtUns16 y; - + for (y = 0; y < texture_map_big->num_y; y++) { for (x = 0; x < texture_map_big->num_x; x++) { UUtUns16 index; M3tTextureMap *texture_map; - + // get a pointer to the texture to draw into index = x + (y * texture_map_big->num_x); texture_map = texture_map_big->textures[index]; - + // set the texture origin texture_origin.x = x * M3cTextureMap_MaxWidth; texture_origin.y = y * M3cTextureMap_MaxHeight; @@ -2094,12 +2094,12 @@ TSrContext_DrawString( } } break; - + default: UUmAssert(!"unkown texture map template tag"); break; } - + // update the texture error = TMrInstance_Update(inTexture); UUmError_ReturnOnError(error); @@ -2131,7 +2131,7 @@ TSrContext_DrawFormattedText( bounds.bottom += inOffset->y; } shade = (inOverrideColor == NULL) ? inStringFormat->colors[i] : *inOverrideColor; - + TSiContext_DrawTextLine( inTextContext, inStringFormat->segments[i], @@ -2141,7 +2141,7 @@ TSrContext_DrawFormattedText( &bounds, NULL); } - + return UUcError_None; } @@ -2176,11 +2176,11 @@ TSrContext_DrawText( bounds.right = M3rDraw_GetWidth(); bounds.bottom = M3rDraw_GetHeight(); } - + // format the string error = TSrContext_FormatString(inTextContext, inString, &bounds, inDestination, &string_format); UUmError_ReturnOnError(error); - + // draw each line for (i = 0; i < string_format.num_segments; i++) { @@ -2193,7 +2193,7 @@ TSrContext_DrawText( &string_format.bounds[i], NULL); } - + return UUcError_None; } @@ -2232,17 +2232,17 @@ TSrContext_DrawText_DC( bounds.right = M3rDraw_GetWidth(); bounds.bottom = M3rDraw_GetHeight(); } - + // format the string error = TSrContext_FormatString(inTextContext, inString, &bounds, inDestination, &string_format); UUmError_ReturnOnError(error); - + if (outStringRect) { width = 0; height = 0; } - + // draw each line for (i = 0; i < string_format.num_segments; i++) { @@ -2254,22 +2254,22 @@ TSrContext_DrawText_DC( M3cMaxAlpha, &string_format.bounds[i], inDrawContext); - + if (outStringRect) { width = UUmMax(width, (string_format.bounds[i].right - string_format.bounds[i].left)); height += (string_format.bounds[i].bottom - string_format.bounds[i].top); } } - + if (outStringRect) { - outStringRect->left = 0; + outStringRect->left = 0; outStringRect->top = 0; outStringRect->right = width; outStringRect->bottom = height; } - + return UUcError_None; } @@ -2300,7 +2300,7 @@ TSrContext_FormatString( IMtShade cur_shade; TStFormatCharacterColor *formatcharacter; - + never_wrap = ((inTextContext->format & (TSc_SingleLine | TSc_VBottom)) != 0); string = (char*)inString; bounds_width = inBounds->right - inBounds->left; @@ -2334,7 +2334,7 @@ TSrContext_FormatString( UUtUns16 character; UUtUns16 num_chars; UUtUns16 prev_breaking; - + starting_string = string; prev_breaking = 0; num_chars = 0; @@ -2355,17 +2355,17 @@ TSrContext_FormatString( { // get the next character in the string character = TSiString_GetNextCharacter(string); - + // stop if the end of the string is reached if (character == 0) { done = UUcTrue; break; } - + if (inTextContext->use_formatting_commands) { if (character == TScFormatCharacter_Begin) { - // begin a new section of the line + // begin a new section of the line string += 1; begin_formatting = UUcTrue; intraline_break = UUcTrue; @@ -2416,7 +2416,7 @@ TSrContext_FormatString( if (glyph) { segment_width += glyph->kerning; - + // stop if the line exceeds the bounds rect must_break = ((!never_wrap) && (line_width + segment_width > bounds_width)); } @@ -2424,12 +2424,12 @@ TSrContext_FormatString( { // change to new font style TSiContext_SetFontStyleByChar(inTextContext, character); - + // save the tallest line height and descending height line_height = UUmMax(TSrFont_GetLineHeight(inTextContext->font), line_height); ascending_height = UUmMax(TSrFont_GetAscendingHeight(inTextContext->font), ascending_height); }*/ - + // advance to the next character in the string if (TSiCharacter_IsDoubleByte(character)) { @@ -2439,7 +2439,7 @@ TSrContext_FormatString( { string += 1; } - + if (must_break || ((num_chars + 1) >= TScMaxCharsPerSegment)) { // break this segment @@ -2454,7 +2454,7 @@ TSrContext_FormatString( prev_breaking = num_chars; } } - + if ((!done) && (!intraline_break) && (!never_wrap)) { // we must break this line @@ -2464,7 +2464,7 @@ TSrContext_FormatString( // back up to a break character // ------------------------------ char *temp_string; - + temp_string = string = &starting_string[prev_breaking]; // subtract the width of the glyphs from prev_breaking to num_chars from segment_width @@ -2494,7 +2494,7 @@ TSrContext_FormatString( temp_string += 1; } } - + num_chars = prev_breaking; } else if (outStringFormat->line_num_segments[line_num] > 0) @@ -2537,14 +2537,14 @@ TSrContext_FormatString( // set the text at the destination's x coordinate line_x = inDestination->x; } - + segment_x = line_x; for (i = segment_startindex; i < segment_num; i++) { // store the position of this segment. note that the final vertical position will be set // after all the lines have been processed. in the meantime, save the ascending_height of the line. outStringFormat->destination[i].x = segment_x; outStringFormat->destination[i].y = ascending_height; - + // set the bounds rect of the line outStringFormat->bounds[i].left = segment_x; outStringFormat->bounds[i].top = 0; @@ -2553,14 +2553,14 @@ TSrContext_FormatString( segment_x = outStringFormat->bounds[i].right; } - + line_num++; start_new_line = UUcTrue; } else { // continue the existing line start_new_line = UUcFalse; } - + // set up for the next segment if (restore_formatting) { cur_shade = inTextContext->shade; @@ -2577,7 +2577,7 @@ TSrContext_FormatString( outStringFormat->num_segments = segment_num; outStringFormat->num_lines = line_num; } - + // ------------------------------ // calculate the vertical positions // ------------------------------ @@ -2585,7 +2585,7 @@ TSrContext_FormatString( if (inTextContext->format & TSc_VCenter) { UUtUns16 total_height; - + // calculate how tall all the lines are total_height = 0; segment_startindex = 0; @@ -2608,7 +2608,7 @@ TSrContext_FormatString( // be drawn. line_y = inDestination->y - outStringFormat->destination[0].y; } - + // set the y coordinates for each line and the bounds top and bottom segment_startindex = 0; for (i = 0; i < outStringFormat->num_lines; i++) @@ -2619,12 +2619,12 @@ TSrContext_FormatString( outStringFormat->bounds[j + segment_startindex].bottom += line_y; outStringFormat->destination[j + segment_startindex].y += line_y; } - + line_y = outStringFormat->bounds[segment_startindex].bottom; segment_startindex += outStringFormat->line_num_segments[i]; } UUmAssert(segment_startindex == outStringFormat->num_segments); - + return UUcError_None; } @@ -2635,10 +2635,10 @@ TSrContext_GetFont( TStFontStyle inStyle) { TStFont *font; - + UUmAssert(inTextContext); UUmAssert((inStyle >= 0) && (inStyle <= TScStyle_NumStyles)); - + font = NULL; if (inStyle == TScStyle_InUse) { @@ -2647,13 +2647,13 @@ TSrContext_GetFont( } else { - font = + font = TSrFontFamily_GetFont( inTextContext->font_family, inTextContext->font_size, inStyle); } - + return font; } @@ -2667,33 +2667,33 @@ TSrContext_GetStringRect( UUtUns16 string_length; UUtUns16 i; UUtUns16 width; - + UUmAssert(inTextContext); UUmAssert(inString); UUmAssert(outRect); - + // clear the width width = 0; - + // calculate the length of the string (aka number of characters) string_length = TSrString_GetLength(inString); - + // calculate the width of the string for (i = 0; i < string_length; i++) { TStGlyph *glyph; UUtUns16 character; - + // get the next character in the string character = TSiString_GetNextCharacter(inString); - + // add the glyph width glyph = TSiFont_GetGlyph(inTextContext->font, character); if (glyph) { width += glyph->kerning; } - + if (TSiCharacter_IsDoubleByte(character)) { inString += 2; @@ -2703,13 +2703,13 @@ TSrContext_GetStringRect( inString += 1; } } - + // set the return values outRect->left = 0; outRect->top = 0; outRect->right = width; outRect->bottom = TSrFont_GetLineHeight(inTextContext->font); - + return UUcError_None; } @@ -2727,16 +2727,16 @@ TSrContext_New( UUmAssert(inFontFamily != NULL); UUmAssert(outTextContext != NULL); - + // make sure we have a place to store the text context's pointer if (outTextContext == NULL) return UUcError_Generic; - + // allocate the memory for the text context *outTextContext = UUrMemory_Block_New(sizeof(TStTextContext)); if (*outTextContext == NULL) return UUcError_Generic; - + // initialize the text context (**outTextContext).font_family = inFontFamily; (**outTextContext).format = inFormat; @@ -2749,17 +2749,17 @@ TSrContext_New( error = TSrContext_SetFontFamily(*outTextContext, inFontFamily); if (error != UUcError_None) return UUcError_Generic; - + // set the font style error = TSrContext_SetFontStyle(*outTextContext, inStyle); if (error != UUcError_None) return UUcError_Generic; - + // set the font size error = TSrContext_SetFontSize(*outTextContext, inSize); if (error != UUcError_None) return UUcError_Generic; - + return UUcError_None; } @@ -2770,18 +2770,18 @@ TSrContext_SetFontFamily( TStFontFamily *inFontFamily) { UUtError error; - + UUmAssert(ioTextContext != NULL); UUmAssert(inFontFamily != NULL); if ((ioTextContext == NULL) || (inFontFamily == NULL)) { return UUcError_Generic; } // save the font family ioTextContext->font_family = inFontFamily; - + // get the best font error = TSiContext_GetBestFont(ioTextContext); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2792,17 +2792,17 @@ TSrContext_SetFontSize( UUtUns16 inSize) { UUtError error; - + UUmAssert(ioTextContext != NULL); if (ioTextContext == NULL) { return UUcError_Generic; } - + // save the desired size ioTextContext->font_size = inSize; - + // get the best font error = TSiContext_GetBestFont(ioTextContext); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2813,19 +2813,19 @@ TSrContext_SetFontStyle( TStFontStyle inStyle) { UUtError error; - + UUmAssert(ioTextContext != NULL); if (ioTextContext == NULL) { return UUcError_Generic; } - + // save the desired style ioTextContext->font_style = inStyle; - + // get the best font error = TSiContext_GetBestFont(ioTextContext); UUmError_ReturnOnError(error); - + return UUcError_None; -} +} // ---------------------------------------------------------------------- UUtError @@ -2835,7 +2835,7 @@ TSrContext_SetFormat( { UUmAssert(ioTextContext != NULL); if (ioTextContext == NULL) { return UUcError_Generic; } - + ioTextContext->format = inFontFormat; return UUcError_None; } @@ -2867,7 +2867,7 @@ TSrContext_SetFormatting( } // ====================================================================== -#if 0 +#if 0 #pragma mark - #endif // ====================================================================== @@ -2890,21 +2890,21 @@ TSrFontFamily_GetFont( { UUtUns32 i; TStFont *found_font; - + found_font = NULL; for (i = 0; i < inFontFamily->num_fonts; i++) { TStFont *font; - + font = inFontFamily->fonts[i]; - + if (font == NULL) { continue; } if ((font->font_size != inSize) || (font->font_style != inStyle)) { continue; } - + found_font = font; break; } - + return found_font; } @@ -2923,25 +2923,25 @@ TSrFont_Get( TStFontFamily *font_family; TStFont *font; UUtUns32 i; - + font_family = TMrInstance_GetFromName(TScTemplate_FontFamily, inName); if (font_family == NULL) { return NULL; } - + font = NULL; - + for (i = 0; i < font_family->num_fonts; i++) { TStFont *temp_font; - + temp_font = font_family->fonts[i]; - + if ((temp_font->font_size == inSize) && (temp_font->font_style == inStyle)) { font = temp_font; break; } } - + return font; } @@ -2951,7 +2951,7 @@ TSrFont_GetAscendingHeight( TStFont *inFont) { UUmAssert(inFont != NULL); - + return inFont->ascending_height; } @@ -2966,13 +2966,13 @@ TSrFont_GetCharacterSize( TStGlyph *glyph; UUtUns16 width; UUtUns16 height; - + UUmAssert(inFont != NULL); - + // initialize width and height - width = 0; + width = 0; height = 0; - + // get the glyph glyph = TSiFont_GetGlyph(inFont, inCharacter); if (glyph) @@ -2980,12 +2980,12 @@ TSrFont_GetCharacterSize( width = glyph->width; height = glyph->height; } - + if (outWidth) { *outWidth = width; } - + if (outHeight) { *outHeight = height; @@ -2998,7 +2998,7 @@ TSrFont_GetLeadingHeight( TStFont *inFont) { UUmAssert(inFont != NULL); - + return inFont->leading_height; } @@ -3008,7 +3008,7 @@ TSrFont_GetLineHeight( TStFont *inFont) { UUmAssert(inFont != NULL); - + return inFont->ascending_height + inFont->descending_height + inFont->leading_height; } @@ -3018,12 +3018,12 @@ TSrFont_GetDescendingHeight( TStFont *inFont) { UUmAssert(inFont != NULL); - + return inFont->descending_height; } // ====================================================================== -#if 0 +#if 0 #pragma mark - #endif // ====================================================================== @@ -3035,17 +3035,17 @@ TSrString_AppendChar( const UUtUns16 inMaxCharsInString) { UUtUns16 insert_before; - + // set insert_before to the point after the last character in the string insert_before = TSrString_GetLength(ioString); - + // insert the char at the end of the string TSrString_InsertChar( ioString, insert_before, inChar, inMaxCharsInString); - + return UUcTrue; } @@ -3060,10 +3060,10 @@ TSrString_DeleteChar( char *copy_to; char *copy_from; UUtUns32 i; - + // check the range of inInsertBefore if (inDeleteIndex > inMaxCharsInString) { return UUcFalse; } - + // find the copy_to point copy_to = ioString; for (i = 0; i < inDeleteIndex; i++) @@ -3078,7 +3078,7 @@ TSrString_DeleteChar( copy_to += 1; } } - + // copy_to is now at position to copy data from copy_from = copy_to; @@ -3092,7 +3092,7 @@ TSrString_DeleteChar( { copy_from += 1; } - + // copy from copy_from to copy_to while (1) { @@ -3103,7 +3103,7 @@ TSrString_DeleteChar( *((UUtUns8*)copy_to) = (UUtUns8)character; break; } - + if (TSiCharacter_IsDoubleByte(character)) { copy_from += 2; @@ -3117,7 +3117,7 @@ TSrString_DeleteChar( copy_to += 1; } } - + return UUcTrue; } @@ -3130,12 +3130,12 @@ TSrString_GetCharacterAtIndex( UUtUns16 i; const char *string; UUtUns16 character; - + string = inString; for (i = 0; i < inIndex; i++) { character = TSiString_GetNextCharacter(string); - + if (TSiCharacter_IsDoubleByte(character)) { string += 2; @@ -3145,9 +3145,9 @@ TSrString_GetCharacterAtIndex( string += 1; } } - + character = TSiString_GetNextCharacter(string); - + return character; } @@ -3158,7 +3158,7 @@ TSrString_GetLength( { UUtUns16 character = 0; UUtUns16 length = 0; - + while (1) { character = TSiString_GetNextCharacter(inString); @@ -3166,7 +3166,7 @@ TSrString_GetLength( { break; } - + if (TSiCharacter_IsDoubleByte(character)) { inString += 2; @@ -3175,10 +3175,10 @@ TSrString_GetLength( { inString += 1; } - + length++; } - + return length; } @@ -3197,22 +3197,22 @@ TSrString_InsertChar( UUtUns32 i; UUtUns16 character; UUtUns32 num_bytes; - + // check the range of inInsertBefore if (inInsertBefore > inMaxCharsInString) { return UUcFalse; } - + // make sure there is enough room to insert the character string_length = TSrString_GetLength(ioString); if ((string_length + 1) >= inMaxCharsInString) { return UUcFalse; } if (inInsertBefore > string_length) { inInsertBefore = string_length; } - + // find the start of the strings to copy from start = ioString; for (i = 0; i < inInsertBefore; i++) { character = TSiString_GetNextCharacter(start); if (character == 0) { break; } - + if (TSiCharacter_IsDoubleByte(character)) { start += 2; @@ -3222,7 +3222,7 @@ TSrString_InsertChar( start += 1; } } - + // find the end of the string end = start; while (1) @@ -3232,7 +3232,7 @@ TSrString_InsertChar( { break; } - + if (TSiCharacter_IsDoubleByte(character)) { end += 2; @@ -3242,13 +3242,13 @@ TSrString_InsertChar( end += 1; } } - + // calculate the number of bytes to copy, including the \0 at the end of the string num_bytes = (end - start) + 1; - + // set the position to copy from to the current end position copy_from = end; - + // calculate the new end position if (TSiCharacter_IsDoubleByte(inChar)) { @@ -3258,13 +3258,13 @@ TSrString_InsertChar( { end += 1; } - + // copy the data for (i = 0; i < num_bytes; i++) { *end-- = *copy_from--; } - + // insert the new character if (TSiCharacter_IsDoubleByte(inChar)) { @@ -3274,7 +3274,7 @@ TSrString_InsertChar( { *((UUtUns8*)start) = (UUtUns8)inChar; } - + return UUcTrue; } diff --git a/BungieFrameWork/BFW_Source/BFW_TextSystem/BFW_TextSystem_Template.c b/BungieFrameWork/BFW_Source/BFW_TextSystem/BFW_TextSystem_Template.c index 1e7f0d3..7419554 100644 --- a/BungieFrameWork/BFW_Source/BFW_TextSystem/BFW_TextSystem_Template.c +++ b/BungieFrameWork/BFW_Source/BFW_TextSystem/BFW_TextSystem_Template.c @@ -1,12 +1,12 @@ /* FILE: BFW_TextSystem_Template.c - + AUTHOR: Kevin Armstrong - + CREATED: ???? PURPOSE: text - + Copyright 1997-1998 */ @@ -21,7 +21,7 @@ TSrRegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register(TScTemplate_Font, sizeof(TStFont), TMcFolding_Allow); UUmError_ReturnOnError(error); error = TMrTemplate_Register(TScTemplate_GlyphArray, sizeof(TStGlyphArray), TMcFolding_Allow); @@ -30,6 +30,6 @@ TSrRegisterTemplates( UUmError_ReturnOnError(error); error = TMrTemplate_Register(TScTemplate_FontFamily, sizeof(TStFontFamily), TMcFolding_Allow); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro.c b/BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro.c index 83c224d..955216a 100644 --- a/BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro.c +++ b/BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro.c @@ -1,17 +1,17 @@ /* FILE: BFW_Totoro.c - + AUTHOR: Michael Evans - + CREATED: Sept 25, 1997 - + PURPOSE: animation engine - + Copyright 1997 */ -/* +/* optimzation notes @@ -93,7 +93,7 @@ static void TRrAnimation_Prepare(TRtAnimation *animation); static const TRtAttack *TRrAnimation_GetAttack(const TRtAnimation *inAnimation, TRtAnimTime inTime, UUtUns32 inPartIndex); // -// Danger, Danger, these tables aren't really sin(pheta) and cos(pheta), +// Danger, Danger, these tables aren't really sin(pheta) and cos(pheta), // but rather sin(pheta-PI) cos(pheta-PI). This matches the data file // format. // @@ -1183,7 +1183,7 @@ static void M3rQuaternion_Uncompress3_Single(M3tCompressedQuaternion3 *inCompres outQuat->x = cos_long * cos_lat * sin_angle; outQuat->y = sin_long * cos_lat * sin_angle; outQuat->z = sin_lat * sin_angle; - + } @@ -1309,7 +1309,7 @@ TRrInitialize( error = TRrRegisterTemplates(); UUmError_ReturnOnError(error); - + error = TMrTemplate_PrivateData_New(TRcTemplate_AnimationCollection, 0, TRrTemplateHandler_AnimationCollection, &TRgAnimationCollection_PrivateData); UUmError_ReturnOnError(error); @@ -1318,7 +1318,7 @@ TRrInitialize( error = TMrTemplate_PrivateData_New(TRcTemplate_Body, 0, TRrTemplateHandler_Body, &TRgBody_PrivateData); UUmError_ReturnOnError(error); - + error = TRrInitialize_IntersectionTables(); UUmError_ReturnOnError(error); @@ -1329,7 +1329,7 @@ TRrInitialize( return UUcError_None; } - + void TRrTerminate( void) @@ -1378,7 +1378,7 @@ void TRrBody_BuildMatricies( const TRtExtraBody* inExtraBody, M3tQuaternion *inQuaternions, const M3tMatrix4x3 *inMatrix, - UUtUns32 inMask, + UUtUns32 inMask, M3tMatrix4x3* outMatricies) { UUmAssert(NULL != inBody); @@ -1391,7 +1391,7 @@ void TRrBody_BuildMatricies( // walk the extra list and draw any that need drawing // clean this up later for(extraItr = 0; extraItr < inExtraBody->numParts; extraItr++) - { + { const TRtExtraBodyPart *extraPart = inExtraBody->parts + extraItr; if (NULL != extraPart->geometry) { @@ -1422,7 +1422,7 @@ void TRrBody_Draw( UUtUns32 whiteBits) { UUtUns16 itr; - + M3rGeom_State_Commit(); for(itr = 0; itr < inBody->numParts; itr++) @@ -1453,7 +1453,7 @@ void TRrBody_Draw( } } } - + M3rMatrixStack_Pop(); } @@ -1463,7 +1463,7 @@ void TRrBody_Draw( // walk the extra list and draw any that need drawing // clean this up later for(extraItr = 0; extraItr < inExtraBody->numParts; extraItr++) - { + { const TRtExtraBodyPart *extraPart = inExtraBody->parts + extraItr; if (NULL == extraPart->geometry) { continue; } @@ -1487,7 +1487,7 @@ void TRrBody_DrawMagic( const UUtUns8 * inPartAlpha) { UUtUns16 itr; - + M3rGeom_State_Push(); M3rGeom_State_Commit(); @@ -1509,7 +1509,7 @@ void TRrBody_DrawMagic( } geometry->baseMap = old_texture_map; - + M3rMatrixStack_Pop(); } @@ -1548,20 +1548,20 @@ void TRrQuatArray_Zero( // based. Each quaternion in an animation frame specifies the rotation of // some joint on a biped model with respect to it's "parent" joint. IE, // a quaternion may specify the orientation of a hand with respect to the -// arm, or a lower arm with respect to the upper arm. The model is +// arm, or a lower arm with respect to the upper arm. The model is // hierarchitcal, in the sense that the hand depends on the lower // arm, which depends on the upper arm, which depends on the body, etc. // // This set of subroutines pulls out all of these "body part" quaternions // for a particular frame in the animation. In the original Oni code the -// data is stored in a two dimensional array of quaternions. IE, +// data is stored in a two dimensional array of quaternions. IE, // quaternion = animation_quaternions[frame][body_part]. All of the // quaternions for a particular frame can be passed to a decompression // routine which will unpack the quaternion from whatever bit format // it's in (I believe 8, 12, 16, and 32 bits are supported right now) // into a structure of 4 floats, x,y,z and w. While this gave some // compression, I believed it was possible to do at least an order -// of magnitude better using a lossy compression algorithm. +// of magnitude better using a lossy compression algorithm. // // How the algorithm works: // @@ -1575,11 +1575,11 @@ void TRrQuatArray_Zero( // Each Time value represents the number of frames between the two // key frames. All 'frames' are assumed to be 60 frames per second // right now. Values of intermediate frames are calculated by -// interpolating between the two key frame values. +// interpolating between the two key frame values. // // Example: -// -// I want to represent 4 unique quaternions, A, B, C, and D, in the +// +// I want to represent 4 unique quaternions, A, B, C, and D, in the // animation sequence A A A A B B C D D D // // If we look at this animation as a signal being sampled, we might @@ -1589,7 +1589,7 @@ void TRrQuatArray_Zero( // // Frame 0 A A // -// Frame 1 A +// Frame 1 A // 3 // Frame 2 A // @@ -1598,11 +1598,11 @@ void TRrQuatArray_Zero( // Frame 4 B B // 1 // Frame 5 B B -// 1 +// 1 // Frame 6 C C // 1 // Frame 7 D D -// +// // Frame 8 D 2 // // Frame 9 D D @@ -1613,7 +1613,7 @@ void TRrQuatArray_Zero( // If I want to compute frame 2 I start at frame 0, I see that the // "gap" between frame 0's key frame and frame 3's key frame is 3 frames, // I interpolate (lerp) 2/3rds of the way between the key frame quaternions, -// and I get the value A. If I want the value for frame 3.25 I interpolate +// and I get the value A. If I want the value for frame 3.25 I interpolate // 25% between the second A keyframe and the first B key frame. // // The length of each body part's compressed animation sequence now @@ -1673,7 +1673,7 @@ static void TRrQuatArray_SetAnimationInternal( // frame_gap is the gap between the two key-frames. // into-gap is how many "frames" past current quaternion the - // key frame was. + // key frame was. int frame_gap; int into_gap; @@ -1700,7 +1700,7 @@ static void TRrQuatArray_SetAnimationInternal( swapped= (((swapped & 0xFF00) >> 8) | ((swapped & 0x00FF) << 8)); compressed= ((UUtUns8 *)inAnimation->data) + swapped; } - #else + #else compressed=((UUtUns8 *) inAnimation->data) + ((unsigned short *) inAnimation->data)[i]; #endif // Set up the initial quaternion. "current quaternion" is the last @@ -1794,7 +1794,7 @@ static void TRrQuatArray_SetAnimationInternal( M3rQuaternion_Uncompress4((void *)tmem, 2, interp); break; - + case TRcAnimationCompression6: memcpy(tmem,last_quaternion,compressionSize); memcpy(tmem+compressionSize,current_quaternion, @@ -1832,7 +1832,7 @@ static void TRrQuatArray_SetAnimationInternal( } else if (into_gap==frame_gap) { quaternions[i]=interp[1]; - } + } else { MUrQuat_Lerp(interp,interp+1, ((float) into_gap)/((float) frame_gap), quaternions+i); } @@ -1893,7 +1893,7 @@ void TRrQuatArray_SetAnimation( // UUmAssert(floatFrameNum >= frameNum); // UUmAssert(floatFrameNum < (frameNum+1)); - // if not 60 fps, we compress to two different internal arrays and LERP to + // if not 60 fps, we compress to two different internal arrays and LERP to UUmAssertReadPtr(inAnimation, sizeof(*inAnimation)); UUmAssertWritePtr(inDest, inAnimation->numParts * sizeof(M3tQuaternion)); UUmAssert(inTime < inAnimation->numFrames); @@ -1950,7 +1950,7 @@ void TRrQuatArray_Lerp4( float amt01; float amt23; - // basic path: + // basic path: // lerp 1 & 2 // lerp 3 & 4 // lerp (1&2) & (3&4) @@ -1960,7 +1960,7 @@ void TRrQuatArray_Lerp4( if (amt01 > UUcEpsilon) { float lerp01; - + TRrQuatArray_Lerp(inNumParts, amountA, inSrc1, inSrc2, TRgQuatArrayPrivateA); src5 = TRgQuatArrayPrivateA; } @@ -2084,7 +2084,7 @@ static UUtUns16 TRrCollection_BinarySearch(const TRtAnimationCollection *inColle while(guess > 0) { entry = inCollection->entry + guess - 1; found = lookupTarget == entry->lookupValue; - + if (!found) { result = guess; goto exit; @@ -2150,20 +2150,20 @@ static const TRtAnimation *TRrCollection_Lookup_Internal(const TRtAnimationColle else { continue; } } - if ((inType != animation->type) && (inType != 0)) { + if ((inType != animation->type) && (inType != 0)) { if (inType != 0) { break; } else { continue; } } - if (animation->varient & badVarientFlags) { - continue; + if (animation->varient & badVarientFlags) { + continue; } if (animation->firstLevel > TRgLevelNumber) { // we need to skip this animation - + #if defined(DEBUGGING) && DEBUGGING - if ((itr + 1) < inCollection->numAnimations) { + if ((itr + 1) < inCollection->numAnimations) { UUtBool same_from_state = entry->virtualFromState == inCollection->entry[itr + 1].virtualFromState; UUtBool same_type = entry->animation->type == inCollection->entry[itr + 1].animation->type; UUtBool same_varient = entry->animation->varient == inCollection->entry[itr + 1].animation->varient; @@ -2198,7 +2198,7 @@ static const TRtAnimation *TRrCollection_Lookup_Internal(const TRtAnimationColle if (TRcWeight_OnlyEntry == entry->weight) { - break; + break; } if (!foundFirstValidAnimation) @@ -2232,12 +2232,12 @@ static const TRtAnimation *TRrCollection_Lookup_Internal(const TRtAnimationColle return result; } -void +void TRrCollection_Lookup_Range( - TRtAnimationCollection *inCollection, - TRtAnimType inType, - TRtAnimState inState, - TRtAnimationCollectionPart **outFirst, + TRtAnimationCollection *inCollection, + TRtAnimType inType, + TRtAnimState inState, + TRtAnimationCollectionPart **outFirst, UUtInt32 *outCount) { UUtInt32 loop; @@ -2288,9 +2288,9 @@ const TRtAnimation *TRrCollection_Lookup(const TRtAnimationCollection *inCollect lookup_depth++; - // two steps, + // two steps, UUmAssert(inType != TRcAnimState_Anything); - + // look for a real hit lookupResult = TRrCollection_Lookup_Internal(inCollection, inType, inState, inVarient); @@ -2373,9 +2373,9 @@ static void iAnimationCollection_SortAndWeight(TRtAnimationCollection *ioCollect #endif // sort the table by type and fromState - qsort( ioCollection->entry, - ioCollection->numAnimations, - sizeof(TRtAnimationCollectionPart), + qsort( ioCollection->entry, + ioCollection->numAnimations, + sizeof(TRtAnimationCollectionPart), iCollectionCompare); #if ANIM_PRINT_TABLE @@ -2409,7 +2409,7 @@ static void iAnimationCollection_SortAndWeight(TRtAnimationCollection *ioCollect thisID = imGetAnimSortID(ioCollection->entry + itr); thisVarient = ioCollection->entry[itr].animation->varient; - + if (((UUtUns32)(itr + 1)) < ioCollection->numAnimations) { nextID = imGetAnimSortID(ioCollection->entry + itr + 1); nextVarient = ioCollection->entry[itr + 1].animation->varient; @@ -2466,7 +2466,7 @@ static void iAnimationCollection_SortAndWeight(TRtAnimationCollection *ioCollect fprintf(stream, "----------------------------------\n"); fflush(stream); #endif -} +} static void iAnimationCollection_DiskToMemory(TRtAnimationCollection *ioCollection) { @@ -2492,7 +2492,7 @@ static void iAnimationCollection_DiskToMemory(TRtAnimationCollection *ioCollecti for(itr = 0; itr < ioCollection->numAnimations; itr++) { TRtAnimationCollectionPart *part; UUmAssert(ioCollection->entry[itr].animation != NULL); - + part = ioCollection->entry + itr; part->virtualFromState = ioCollection->entry[itr].animation->fromState; @@ -2507,11 +2507,11 @@ static void iAnimationCollection_DiskToMemory(TRtAnimationCollection *ioCollecti TRtAnimation *curAnimation = ioCollection->entry[itr].animation; TRrAnimation_Prepare(curAnimation); - + for(shortcutItr = 0; shortcutItr < curAnimation->numShortcuts; shortcutItr++) { - TRtAnimationCollectionPart *recursivePart; + TRtAnimationCollectionPart *recursivePart; - recursiveCollection = UUrMemory_Block_Realloc(recursiveCollection, + recursiveCollection = UUrMemory_Block_Realloc(recursiveCollection, sizeof(TRtAnimationCollection) + (recursiveCount * sizeof(TRtAnimationCollectionPart))); recursivePart = recursiveCollection->entry + recursiveCount; @@ -2521,7 +2521,7 @@ static void iAnimationCollection_DiskToMemory(TRtAnimationCollection *ioCollecti recursivePart->animation = curAnimation; recursivePart->lookupValue = (curAnimation->type << 16) | (recursivePart->virtualFromState << 0); - recursiveCount += 1; + recursiveCount += 1; recursiveCollection->numAnimations = recursiveCount; } @@ -2563,7 +2563,7 @@ TRrTemplateHandler_AnimationCollection( void* inPrivateData) { TRtAnimationCollection *collection; - + collection = (TRtAnimationCollection*)(inDataPtr); switch(inMessage) @@ -2571,18 +2571,18 @@ TRrTemplateHandler_AnimationCollection( case TMcTemplateProcMessage_DisposePreProcess: iAnimationCollection_Unload(collection); break; - + case TMcTemplateProcMessage_LoadPostProcess: iAnimationCollection_DiskToMemory(collection); break; - + case TMcTemplateProcMessage_NewPostProcess: case TMcTemplateProcMessage_Update: default: UUmDebugStr("you can't new, update or watchimicallit this template with some more C mister."); } - - return UUcError_None; + + return UUcError_None; } static UUtError @@ -2592,27 +2592,27 @@ TRrTemplateHandler_Body( void* inPrivateData) { TRtBody *body; - + body = (TRtBody*)(inDataPtr); switch(inMessage) { case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_LoadPostProcess: body->geometries = body->geometryStorage->geometries; body->translations = body->translationStorage->translations; body->indexBlocks = body->indexBlockStorage->indexBlocks; break; - + case TMcTemplateProcMessage_NewPostProcess: case TMcTemplateProcMessage_Update: default: UUmDebugStr("you can't new, update or watchimicallit this template with some more C mister."); } - - return UUcError_None; + + return UUcError_None; } @@ -2705,25 +2705,25 @@ TRrTemplateHandler_Animation( void* inPrivateData) { TRtAnimation *animation; - + animation = (TRtAnimation*)(inDataPtr); switch(inMessage) { case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_LoadPostProcess: TRrAnimation_Prepare(animation); break; - + case TMcTemplateProcMessage_NewPostProcess: case TMcTemplateProcMessage_Update: break; } - + return UUcError_None; - + } TRtAnimVarient TRrAnimation_GetVarient(const TRtAnimation *inAnimation) @@ -2776,7 +2776,7 @@ void TRrAnimation_GetPosition(const TRtAnimation *inAnimation, TRtAnimTime inTim outPosition->x = inAnimation->positions[(frameNum * 2)]; outPosition->z = inAnimation->positions[(frameNum * 2) + 1]; outPosition->y = 0.f; - + } else { outPosition->x = 0; @@ -2794,7 +2794,7 @@ UUtBool TRrAnimation_IsSoundFrame(const TRtAnimation *inAnimation, TRtAnimTime i UUtUns16 frameNum = TRmAnimationTimeToFrame(inAnimation, inTime); UUtBool isFrame = TRmAnimationTimeIsFrame(inAnimation, inTime); UUtBool result = UUcFalse; - + UUmAssertReadPtr(inAnimation, sizeof(*inAnimation)); UUmAssert(frameNum < inAnimation->numFrames); UUmAssert(inTime < inAnimation->duration); @@ -2809,7 +2809,7 @@ UUtBool TRrAnimation_IsSoundFrame(const TRtAnimation *inAnimation, TRtAnimTime i result = UUcTrue; } } - + return result; } @@ -2824,20 +2824,20 @@ const char* TRrAnimation_GetNewSoundForFrame(const TRtAnimation *inAnimation, TR UUtUns16 frameNum = TRmAnimationTimeToFrame(inAnimation, inTime); UUtBool isFrame = TRmAnimationTimeIsFrame(inAnimation, inTime); const char *result = NULL; - + UUmAssertReadPtr(inAnimation, sizeof(*inAnimation)); UUmAssert(frameNum < inAnimation->numFrames); UUmAssert(inTime < inAnimation->duration); if ((isFrame) && (inAnimation->numNewSounds > 0) && (inAnimation->newSounds != NULL)) { - UUtUns32 itr; + UUtUns32 itr; for (itr = 0; itr < inAnimation->numNewSounds; itr++) { if (frameNum != inAnimation->newSounds[itr].frameNum) { continue; } result = inAnimation->newSounds[itr].impulseName; break; } } - + return result; } @@ -2845,7 +2845,7 @@ const char* TRrAnimation_GetNewSoundForFrame(const TRtAnimation *inAnimation, TR void TRrAnimation_SetSoundName(TRtAnimation *inAnimation, const char *inSoundName, UUtUns16 inFrame) { UUmAssert(inAnimation); - + inAnimation->soundName = (UUtUns32)inSoundName; inAnimation->soundFrame = inFrame; } @@ -2872,7 +2872,7 @@ float TRrAnimation_GetHeight(const TRtAnimation *inAnimation, TRtAnimTime inTime float from = inAnimation->heights[frameNum]; float to = inAnimation->heights[frameNum + 1]; float dist = floatFrameNum - frameNum; - + height = (from * (1 - dist)) + (to * dist); } @@ -2943,10 +2943,10 @@ UUtUns32 TRrAnimation_GetMaximumDamage(const TRtAnimation *inAnimation) for(attackIndex = 0; attackIndex < inAnimation->numAttacks; attackIndex++) { const TRtAttack *attack = inAnimation->attacks + attackIndex; - + damage = UUmMax(damage, attack->damage); } - + return damage; } @@ -2957,7 +2957,7 @@ UUtUns32 TRrAnimation_GetMaximumSelfDamage(const TRtAnimation *inAnimation) for(itr = 0; itr < inAnimation->numTakeDamages; itr++) { damage += inAnimation->takeDamages[itr].damage; } - + return damage; } @@ -3088,7 +3088,7 @@ UUtBool TRrAnimation_IsDirect(const TRtAnimation *inFromAnim, const TRtAnimatio UUtUns16 TRrAnimation_GetHardPause(const TRtAnimation *inFromAnim, const TRtAnimation *inToAnim) { UUtUns16 hardPause; - + if (TRrAnimation_IsDirect(inFromAnim, inToAnim)) { hardPause = 0; } @@ -3102,7 +3102,7 @@ UUtUns16 TRrAnimation_GetHardPause(const TRtAnimation *inFromAnim, const TRtAnim UUtUns16 TRrAnimation_GetSoftPause(const TRtAnimation *inFromAnim, const TRtAnimation *inToAnim) { UUtUns16 softPause; - + if (TRrAnimation_IsDirect(inFromAnim, inToAnim)) { softPause = 0; } @@ -3232,7 +3232,7 @@ UUtBool TRrAnimation_IsAtomic(const TRtAnimation *inAnimation, TRtAnimTime inTim } UUtUns16 TRrAnimation_GetEndInterpolation(const TRtAnimation *inFromAnim, const TRtAnimation *inToAnim) -{ +{ #define cVarientInterpolation 8 UUtUns16 endInterpolation = 0; @@ -3253,7 +3253,7 @@ UUtUns16 TRrAnimation_GetEndInterpolation(const TRtAnimation *inFromAnim, const } UUmAssert(endInterpolation < 60); - + return endInterpolation; } @@ -3284,7 +3284,7 @@ void TRrOverlay_Apply( else { interpolate_amount = 1.f; } - + TRrQuatArray_SetAnimation(inAnimation, inTime, TRgQuatArrayPrivate_Aiming_1); for (node_index= 0; node_index < inNumParts; ++node_index) @@ -3409,9 +3409,9 @@ const TRtAimingScreen *TRrAimingScreen_Lookup( void TRrAnimation_GetAttacks( - const TRtAnimation *inAnimation, - TRtAnimTime inTime, - UUtUns8 *outNumAttacks, + const TRtAnimation *inAnimation, + TRtAnimTime inTime, + UUtUns8 *outNumAttacks, TRtAttack *outAttacks, UUtUns8 *outindices) { @@ -3479,7 +3479,7 @@ void TRrVerifyAnimation(const TRtAnimation *inAnimation) for(part = 0; part < inAnimation->numParts; part++) { - MUmQuat_VerifyUnit(verifyQuatArray + part); + MUmQuat_VerifyUnit(verifyQuatArray + part); } } @@ -3497,7 +3497,7 @@ const TRtAnimation *TRrAnimation_GetFromName(const char *inTemplateName) if (UUcError_None == error) { animation = dataPtr; } - + return animation; } @@ -3615,7 +3615,7 @@ void TRrAimingScreen_Clip( *ioDirection = 0.f; *ioElevation = 0.f; } - else { + else { float min_direction = -(inAimingScreen->negativeYawDelta * inAimingScreen->negativeYawFrameCount); float max_direction = inAimingScreen->positiveYawDelta * inAimingScreen->positiveYawFrameCount; float min_elevation = -(inAimingScreen->negativePitchDelta * inAimingScreen->negativePitchFrameCount); @@ -3754,7 +3754,7 @@ void TRrAnimation_SwapFootsteps(TRtAnimation *animation) { UUtUns16 itr; - for(itr = 0; itr < animation->numFootsteps; itr++) + for(itr = 0; itr < animation->numFootsteps; itr++) { TRtFootstep *footstep = animation->footsteps + itr; @@ -3849,11 +3849,11 @@ void TRrAnimation_SwapNewSounds(TRtAnimation *animation) { UUtUns32 itr; TRtSound *newSound; - + for (itr = 0, newSound = animation->newSounds; itr < animation->numNewSounds; itr++, newSound++) { UUmSwapLittle_2Byte(&newSound->frameNum); - + UUmAssert(2 == sizeof(newSound->frameNum)); } } @@ -3992,7 +3992,7 @@ static void TRrAimingScreen_Prepare( TRrQuatArray_SetAnimation(animation, elevation_index*direction_width + (direction_index+1), frame_d1_e0); TRrQuatArray_SetAnimation(animation, (elevation_index+1)*direction_width + direction_index, frame_d0_e1); TRrQuatArray_SetAnimation(animation, (elevation_index+1)*direction_width + (direction_index+1), frame_d1_e1); - + valid= UUcTrue; } } @@ -4018,11 +4018,11 @@ static void TRrAimingScreen_Prepare( // interpolate rotation //quaternions_interpolate(&frame_d0_e0->nodes[node_index].rotation, &frame_d1_e0->nodes[node_index].rotation, &e0_quaternion, d0); - MUrQuat_Lerp(frame_d0_e0 + node_index, frame_d1_e0 + node_index, d0, &e0_quaternion); + MUrQuat_Lerp(frame_d0_e0 + node_index, frame_d1_e0 + node_index, d0, &e0_quaternion); //quaternions_interpolate(&frame_d0_e1->nodes[node_index].rotation, &frame_d1_e1->nodes[node_index].rotation, &e1_quaternion, d0); - MUrQuat_Lerp(frame_d0_e1 + node_index, frame_d1_e1 + node_index, d0, &e1_quaternion); + MUrQuat_Lerp(frame_d0_e1 + node_index, frame_d1_e1 + node_index, d0, &e1_quaternion); //quaternions_interpolate(&e0_quaternion, &e1_quaternion, &interpolated_quaternion, e0); - MUrQuat_Lerp(&e0_quaternion, &e1_quaternion, e0, &interpolated_quaternion); + MUrQuat_Lerp(&e0_quaternion, &e1_quaternion, e0, &interpolated_quaternion); outQuat[node_index] = interpolated_quaternion; } @@ -4604,7 +4604,7 @@ UUtBool TRrCheckAnimationBounds(TRtAnimIntersectContext *inContext) } else { // get the point in the middle that is the closest on the line (has zero dot product) interp = (0 - start_dot) / dot_delta; - + mid_x = target_pt.x + interp * (end_pt.x - target_pt.x); mid_y = target_pt.y + interp * (end_pt.y - target_pt.y); @@ -4750,7 +4750,7 @@ UUtBool TRrCheckAnimationBounds(TRtAnimIntersectContext *inContext) } // neither point touches the line. check to see if the midpoint might. - if ((end_y * start_y < 0) && + if ((end_y * start_y < 0) && !((end_x < -target_radius) && (start_x < -target_radius)) && !((end_x > line_length + target_radius) && (start_x > line_length + target_radius))) { mid_x = start_x + ((0 - start_y) / (end_y - start_y)) * (end_x - start_x); @@ -4788,7 +4788,7 @@ UUtBool TRrCheckAnimationBounds(TRtAnimIntersectContext *inContext) #endif } } - + // the bounds of the attack animation overlap the target, return true #if DEBUG_SHOWINTERSECTIONS if (TRgStoreThisIntersection) { @@ -4927,7 +4927,7 @@ UUtBool TRrIntersectAnimations(TRtAnimIntersectContext *inContext) exact_pt->attack_dist = cur_extent->attack_distance * TRcPositionGranularity; exact_pt->attack_angle = cur_extent->attack_angle; } -#endif +#endif if (targetspace_maxheight < target_feet + TRcIntersect_MinHeightOverlap) { // this attack is below the target's height bounds num_reject_belowfeet++; @@ -5169,7 +5169,7 @@ static void TRiDrawCircle(float radius, M3tPoint3D *center_pt, IMtShade shade) center_pt->y + radius * TRgRingDirectionTable[TRcExtentRingSamples - 1][1], center_pt->z); for (itr = 0; itr < TRcExtentRingSamples; itr++) { MUmVector_Set(this_pt, center_pt->x + radius * TRgRingDirectionTable[itr][0], - center_pt->y + radius * TRgRingDirectionTable[itr][1], center_pt->z); + center_pt->y + radius * TRgRingDirectionTable[itr][1], center_pt->z); M3rGeom_Line_Light(&last_pt, &this_pt, shade); last_pt = this_pt; } @@ -5191,7 +5191,7 @@ void TRrDisplayLastIntersection(void) // set up a transformation from targetspace to worldspace M3rMatrixStack_Push(); M3rMatrixStack_Translate(gIntersection.last_context.target.position.location.x, - gIntersection.last_context.target.position.location.y, + gIntersection.last_context.target.position.location.y, gIntersection.last_context.target.position.location.z); M3rMatrixStack_Rotate(gIntersection.last_context.target.position.facing, 0, 1, 0); M3rMatrixStack_Multiply(&max2oni); @@ -5209,11 +5209,11 @@ void TRrDisplayLastIntersection(void) pt1.y = gIntersection.last_context.target_velocity_estimate.y; M3rGeom_Line_Light(&pt0, &pt1, IMcShade_Blue); M3rMatrixStack_Pop(); - + // set up a transformation from attacker space to worldspace M3rMatrixStack_Push(); M3rMatrixStack_Translate(gIntersection.last_context.attacker.position.location.x, - gIntersection.last_context.attacker.position.location.y, + gIntersection.last_context.attacker.position.location.y, gIntersection.last_context.attacker.position.location.z); M3rMatrixStack_Rotate(gIntersection.last_context.attacker.position.facing, 0, 1, 0); M3rMatrixStack_Multiply(&max2oni); @@ -5360,7 +5360,7 @@ void TRrDisplayLastIntersection(void) // draw attack extent height bar center_pt = MUrMatrix_GetTranslation(&gIntersection.last_context.current_location_matrix); - + this_pt = center_pt; last_pt = center_pt; this_pt.z = gIntersection.extentptr->attack_ring.min_height; last_pt.z = gIntersection.extentptr->attack_ring.max_height; @@ -5396,7 +5396,7 @@ void TRrDisplayLastIntersection(void) // the inverse of the matrix that takes points from targetanimspace into animbase space M3rMatrixStack_Push(); M3rMatrixStack_Translate(gIntersection.last_context.target.position.location.x, - gIntersection.last_context.target.position.location.y, + gIntersection.last_context.target.position.location.y, gIntersection.last_context.target.position.location.z); M3rMatrixStack_Rotate(gIntersection.last_context.target.position.facing, 0, 1, 0); M3rMatrixStack_Multiply(&max2oni); @@ -5464,7 +5464,7 @@ void TRrDisplayLastIntersection(void) hit_at = gIntersection.hit_line - gIntersection.start_itr; if (hit_at < 0) hit_at += TRcExtentRingSamples; - + from_hit = hit_at - from_start; if (from_hit == 0) { @@ -5654,7 +5654,7 @@ static void TRrDumpAnimation(FILE *stream, const TRtAnimation *inAnimation) static void TRrDumpAnimationCollection(FILE *stream, const TRtAnimationCollection *inCollection) { - + UUtUns32 itr; for(itr = 0; itr < inCollection->numAnimations; itr++) @@ -5752,7 +5752,7 @@ DumpLookup( SLtParameter_Actual *ioReturnValue) { char file_name[128]; - + sprintf(file_name, "%s.txt", inParameterList[0].val.str); gLookupStream = fopen(file_name, "w"); @@ -5802,7 +5802,7 @@ void TRrInstallConsoleVariables(void) error = SLrScript_Command_Register_Void("tr_stop_lookup", "bla bla bla", "", StopDumpLookup); UUmAssert(UUcError_None == error); - + return; } diff --git a/BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro_Private.h b/BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro_Private.h index fbbe6e0..801a8d6 100644 --- a/BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro_Private.h @@ -1,12 +1,12 @@ /* FILE: BFW_Totoro.h - + AUTHOR: Michael Evans - + CREATED: Sept 25, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997, 1998 */ @@ -46,7 +46,7 @@ typedef struct M3tCompressedQuaternion6 UUtUns16 rx; UUtUns16 ry; UUtUns16 rz; -} M3tCompressedQuaternion6; +} M3tCompressedQuaternion6; typedef struct M3tCompressedQuaternion8 { @@ -54,7 +54,7 @@ typedef struct M3tCompressedQuaternion8 UUtInt16 y; UUtInt16 z; UUtInt16 w; -} M3tCompressedQuaternion8; +} M3tCompressedQuaternion8; enum { TRcAnimationFlag_Reversable = 0x01 @@ -79,7 +79,7 @@ enum { typedef tm_struct TRtBlur { UUtUns32 blurParts; - UUtUns16 firstBlurFrame; + UUtUns16 firstBlurFrame; UUtUns16 lastBlurFrame; UUtUns8 blurQuantity; UUtUns8 blurAmount; @@ -103,7 +103,7 @@ typedef struct TRtShortcut typedef struct TRtThrowInfo { M3tVector3D throwOffset; - float relativeThrowFacing; + float relativeThrowFacing; float throwDistance; UUtUns16 throwType; @@ -119,7 +119,7 @@ typedef struct TRtSound { char impulseName[SScMaxNameLength]; UUtUns16 frameNum; - + } TRtSound; // an animation of a translation, rotation Body @@ -140,9 +140,9 @@ TRtAnimation tm_raw(void *) data; tm_raw(TRtSound *) newSounds; - UUtUns32 flags; + UUtUns32 flags; TRtAnimation *directAnimation[2]; // skips pause & end interpolation - UUtUns32 usedParts; + UUtUns32 usedParts; UUtUns32 replaceParts; float finalRotation; @@ -156,23 +156,23 @@ TRtAnimation UUtUns16 hardPause; // pause (no block) UUtUns16 softPause; // pause (can block) - + UUtUns32 numNewSounds; // number of items in the new_sounds list UUtUns32 soundName; // only valid at runtime (typecast to char*) UUtUns16 soundFrame; // only valid at runtime - - UUtUns16 fps; - UUtUns16 compressionSize; + UUtUns16 fps; + + UUtUns16 compressionSize; UUtUns16 type; UUtUns16 aimingType; UUtUns16 fromState; - - UUtUns16 toState; - UUtUns16 numParts; - UUtUns16 numFrames; + UUtUns16 toState; + UUtUns16 numParts; + + UUtUns16 numFrames; UUtUns16 duration; UUtUns16 varient; @@ -202,7 +202,7 @@ TRtAnimation tm_template('T', 'R', 'A', 'S', "Totoro Aiming Screen") TRtAimingScreen { - + TRtAnimation *animation; float negativeYawDelta; @@ -219,7 +219,7 @@ TRtAimingScreen }; -/* +/* * functions for getting quaternion arrays */ @@ -257,7 +257,7 @@ TRtScreenCollection tm_pad pad0[22]; tm_varindex UUtUns16 numScreens; - tm_vararray TRtAimingScreen *screen[1]; + tm_vararray TRtAimingScreen *screen[1]; }; void TRrVerifyAnimation(const TRtAnimation *inAnimation); diff --git a/BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro_Template.c b/BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro_Template.c index 236aeb6..a2d187b 100644 --- a/BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro_Template.c +++ b/BungieFrameWork/BFW_Source/BFW_Totoro/BFW_Totoro_Template.c @@ -1,12 +1,12 @@ /* FILE: BFW_Totoro_Template.c - + AUTHOR: Michael Evans - + CREATED: Sept 25, 1997 - + PURPOSE: animation engine - + Copyright 1997 */ @@ -23,7 +23,7 @@ TRrRegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register(TRcTemplate_Body, sizeof(TRtBody), TMcFolding_Allow); UUmError_ReturnOnError(error); @@ -36,10 +36,10 @@ TRrRegisterTemplates( error = TMrTemplate_Register(TRcTemplate_BodyTextures, sizeof(TRtBodyTextures), TMcFolding_Allow); UUmError_ReturnOnError(error); - error = TMrTemplate_Register(TRcTemplate_AnimationCollection, sizeof(TRtAnimationCollection), TMcFolding_Allow); + error = TMrTemplate_Register(TRcTemplate_AnimationCollection, sizeof(TRtAnimationCollection), TMcFolding_Allow); UUmError_ReturnOnError(error); - error = TMrTemplate_Register(TRcTemplate_FacingTable, sizeof(TRtFacingTable), TMcFolding_Allow); + error = TMrTemplate_Register(TRcTemplate_FacingTable, sizeof(TRtFacingTable), TMcFolding_Allow); UUmError_ReturnOnError(error); error = TMrTemplate_Register(TRcTemplate_AimingScreen, sizeof(TRtAimingScreen), TMcFolding_Allow); diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_BitVector.c b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_BitVector.c index a9bca33..461affd 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_BitVector.c +++ b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_BitVector.c @@ -99,7 +99,7 @@ UUtUns32 *UUrBitVector_New(UUtUns32 size) { UUtUns32 *result; UUtUns32 temp= UUmBitVector_Sizeof(size); - + result= UUrMemory_Block_NewClear(temp); return result; @@ -170,7 +170,7 @@ UUtBool UUrBitVector_TestBitRange(const UUtUns32 *bitVector, UUtUns32 start, UUt UUtUns32 end_mask= BV_MASK(end); UUtUns32 start_index= BV_INDEX(start); UUtUns32 end_index= BV_INDEX(end); - + UUmAssert(bitVector); if (start_index==end_index) { @@ -181,17 +181,17 @@ UUtBool UUrBitVector_TestBitRange(const UUtUns32 *bitVector, UUtUns32 start, UUt else { UUtUns32 iterator= start_index+1; - + if (bitVector[start_index] & start_mask) return UUcTrue; - + while (iterator!=end_index) { if (bitVector[iterator++]) return UUcTrue; } - + if (bitVector[end_index] & end_mask) return UUcTrue; } - + return UUcFalse; } @@ -201,10 +201,10 @@ void UUrBitVector_SetBitRange(UUtUns32 *bitVector, UUtUns32 start, UUtUns32 end) UUtUns32 end_mask= BV_MASK(end); UUtUns32 start_index= BV_INDEX(start); UUtUns32 end_index= BV_INDEX(end); - + UUmAssert(bitVector); if (start_index!=end_index) - { + { UUtUns32 iterator= start_index+1; // loop over the middle @@ -229,10 +229,10 @@ void UUrBitVector_ClearBitRange(UUtUns32 *bitVector, UUtUns32 start, UUtUns32 en UUtUns32 end_mask= ~BV_MASK(end); UUtUns32 start_index= BV_INDEX(start); UUtUns32 end_index= BV_INDEX(end); - + UUmAssert(bitVector); if (start_index!=end_index) - { + { UUtUns32 iterator= start_index+1; // loop over the middle @@ -247,7 +247,7 @@ void UUrBitVector_ClearBitRange(UUtUns32 *bitVector, UUtUns32 start, UUtUns32 en { start_mask &= ~end_mask; } - + bitVector[start_index] &= ~start_mask; } @@ -257,10 +257,10 @@ void UUrBitVector_ToggleBitRange(UUtUns32 *bitVector, UUtUns32 start, UUtUns32 e UUtUns32 end_mask= BV_MASK(end); UUtUns32 start_index= BV_INDEX(start); UUtUns32 end_index= BV_INDEX(end); - + UUmAssert(bitVector); if (start_index!=end_index) - { + { UUtUns32 iterator= start_index+1; // loop over the middle @@ -288,7 +288,7 @@ UUtUns32 __fastcall UUrBitVector_FindFirstSet(UUtInt32 r3) __asm { mov eax, 32 // if ecx = 0, eax is unset so move 32 to eax - bsf eax, ecx + bsf eax, ecx } } @@ -297,20 +297,20 @@ UUtUns32 __fastcall UUrBitVector_FindFirstSet(UUtInt32 r3) #elif defined(i_cntlzw) // POWERPC count trailing zeroes -// # R3 contains x -// addi R4,R3,-1 # x - 1 -// andc R4,R4,R3 # ~x & (x - 1) -// cntlzw R4,R4 # t = nlz(~x & (x - 1)) -// subfic R4,R4,32 # ntz(x) = 32 - t +// # R3 contains x +// addi R4,R3,-1 # x - 1 +// andc R4,R4,R3 # ~x & (x - 1) +// cntlzw R4,R4 # t = nlz(~x & (x - 1)) +// subfic R4,R4,32 # ntz(x) = 32 - t UUtUns32 UUrBitVector_FindFirstSet(UUtInt32 r3) { UUtUns32 r4; - r4 = r3 - 1; // addi R4,R3,-1 # x - 1 - r4 = ~r3 & r4; // andc R4,R4,R3 # ~x & (x - 1) + r4 = r3 - 1; // addi R4,R3,-1 # x - 1 + r4 = ~r3 & r4; // andc R4,R4,R3 # ~x & (x - 1) r4 = i_cntlzw(r4); // cntlzw R4,R4 # t = nlz(~x & (x - 1)) - r4 = 32 - r4; // subfic R4,R4,32 # ntz(x) = 32 - t + r4 = 32 - r4; // subfic R4,R4,32 # ntz(x) = 32 - t return r4; } @@ -321,7 +321,7 @@ UUtUns32 UUrBitVector_FindFirstSet(UUtInt32 value) { // this implementation will work for other platforms int i; - + for (i=0; i < 32; i++) { if (value & BV_MASK(i)) @@ -329,7 +329,7 @@ UUtUns32 UUrBitVector_FindFirstSet(UUtInt32 value) break; } } - + return i; } @@ -348,18 +348,18 @@ UUtInt32 UUrBitVector_FindFirstSetRange(const UUtUns32 *bitVector, UUtInt32 star UUtUns32 num; UUtUns32 start_mask= BV_START_MASK(start); UUtInt32 result = UUcBitVector_None; - + UUmAssert(bitVector); - + if (start > end) { return UUcBitVector_None; } - + if (start_index==end_index) { num= UUrBitVector_FindFirstSet(bitVector[start_index] & (start_mask & BV_MASK(end))); - if (num < UUcUns32Bits) + if (num < UUcUns32Bits) { result = ((start_index * UUcUns32Bits) + num); goto exit; @@ -369,17 +369,17 @@ UUtInt32 UUrBitVector_FindFirstSetRange(const UUtUns32 *bitVector, UUtInt32 star { // only check just inside the start num= UUrBitVector_FindFirstSet(bitVector[start_index] & start_mask); - if (num < UUcUns32Bits) + if (num < UUcUns32Bits) { result = ((start_index * UUcUns32Bits) + num); goto exit; } - + // loop through the middle for (index= start_index+1; index < end_index; index++) { num= UUrBitVector_FindFirstSet(bitVector[index]); - if (num < UUcUns32Bits) + if (num < UUcUns32Bits) { result = ((index * UUcUns32Bits) + num); goto exit; @@ -388,12 +388,12 @@ UUtInt32 UUrBitVector_FindFirstSetRange(const UUtUns32 *bitVector, UUtInt32 star // only check upto the end num= UUrBitVector_FindFirstSet(bitVector[end_index] & BV_MASK(end)); - if (num < UUcUns32Bits) + if (num < UUcUns32Bits) { result = ((end_index * UUcUns32Bits) + num); goto exit; } - } + } exit: return result; @@ -410,21 +410,21 @@ UUtInt32 UUrBitVector_FindFirstClearRange(const UUtUns32 *bitVector, UUtInt32 st UUtInt32 result = UUcBitVector_None; UUtUns32 final_mask; UUtUns32 inv_mask; - + UUmAssert(bitVector); - + if (start > end) { return UUcBitVector_None; } - + if (start_index==end_index) { final_mask = (start_mask & BV_MASK(end)); inv_mask = ~final_mask; - + num= UUrBitVector_FindFirstClear((bitVector[start_index] & final_mask) | inv_mask); - if (num < UUcUns32Bits) + if (num < UUcUns32Bits) { result = ((start_index * UUcUns32Bits) + num); goto exit; @@ -434,17 +434,17 @@ UUtInt32 UUrBitVector_FindFirstClearRange(const UUtUns32 *bitVector, UUtInt32 st { // only check just inside the start num= UUrBitVector_FindFirstClear((bitVector[start_index] & start_mask) | ~start_mask); - if (num < UUcUns32Bits) + if (num < UUcUns32Bits) { result = ((start_index * UUcUns32Bits) + num); goto exit; } - + // loop through the middle for (index= start_index+1; index < end_index; index++) { num= UUrBitVector_FindFirstClear(bitVector[index]); - if (num < UUcUns32Bits) + if (num < UUcUns32Bits) { result = ((index * UUcUns32Bits) + num); goto exit; @@ -455,12 +455,12 @@ UUtInt32 UUrBitVector_FindFirstClearRange(const UUtUns32 *bitVector, UUtInt32 st final_mask = BV_MASK(end); inv_mask = ~final_mask; num= UUrBitVector_FindFirstClear((bitVector[end_index] & final_mask) | inv_mask); - if (num < UUcUns32Bits) + if (num < UUcUns32Bits) { result = ((end_index * UUcUns32Bits) + num); goto exit; } - } + } exit: return result; @@ -501,14 +501,14 @@ void UUrBitVector_SetBitAll(UUtUns32 *bitVector, UUtUns32 size) void UUrBitVectors_Xor(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 size) { UUtUns32 index; - + UUmAssert(vector1); UUmAssert(vector2); for (index= 0; index < BV_INDEX(size); index++) { vector2[index] ^= vector1[index]; } - + if (BV_NUM(size)) { vector2[BV_INDEX(size)] ^= (vector1[BV_INDEX(size)] & BV_MASK(size)); @@ -519,14 +519,14 @@ void UUrBitVectors_Xor(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 size void UUrBitVectors_Or(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 size) { UUtUns32 index; - + UUmAssert(vector1); UUmAssert(vector2); for (index= 0; index < BV_INDEX(size); index++) { vector2[index] |= vector1[index]; } - + if (BV_NUM(size)) { vector2[BV_INDEX(size)] |= (vector1[BV_INDEX(size)] & BV_MASK(size)); @@ -537,14 +537,14 @@ void UUrBitVectors_Or(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 size) void UUrBitVectors_And(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 size) { UUtUns32 index; - + UUmAssert(vector1); UUmAssert(vector2); for (index= 0; index < BV_INDEX(size); index++) { vector2[index] &= vector1[index]; } - + if (BV_NUM(size)) { vector2[BV_INDEX(size)] &= (vector1[BV_INDEX(size)] & BV_MASK(size)); @@ -556,7 +556,7 @@ void UUrBitVectors_Nor(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 size { UUtUns32 index; UUtUns32 temp; - + UUmAssert(vector1); UUmAssert(vector2); for (index= 0; index < BV_INDEX(size); index++) @@ -564,7 +564,7 @@ void UUrBitVectors_Nor(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 size temp= (vector2[index] | vector1[index]); vector2[index]= ~temp; } - + if (BV_NUM(size)) { temp= vector2[BV_INDEX(size)] | (vector1[BV_INDEX(size)] & BV_MASK(size)); @@ -576,7 +576,7 @@ void UUrBitVectors_Nor(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 size void UUrBitVectors_Nand(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 size) { UUtUns32 index; UUtUns32 temp; - + UUmAssert(vector1); UUmAssert(vector2); for (index= 0; index < BV_INDEX(size); index++) @@ -584,7 +584,7 @@ void UUrBitVectors_Nand(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 siz temp= (vector2[index] & vector1[index]); vector2[index]= ~temp; } - + if (BV_NUM(size)) { temp= vector2[BV_INDEX(size)] & (vector1[BV_INDEX(size)] & BV_MASK(size)); @@ -596,14 +596,14 @@ void UUrBitVectors_Nand(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 siz void UUrBitVectors_Andc(const UUtUns32 *vector1, const UUtUns32 *vector2, UUtUns32 *vectorDest, UUtUns32 size) { UUtUns32 index; - + UUmAssert(vector1); UUmAssert(vector2); for (index= 0; index < BV_INDEX(size); index++) { vectorDest[index] = vector1[index] & ~vector2[index]; } - + if (BV_NUM(size)) { vectorDest[BV_INDEX(size)] = (vector1[index] & ~vector2[BV_INDEX(size)]) & BV_MASK(size); @@ -615,7 +615,7 @@ void UUrBitVectors_Xnor(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 siz { UUtUns32 index; UUtUns32 temp; - + UUmAssert(vector1); UUmAssert(vector2); for (index= 0; index < BV_INDEX(size); index++) @@ -623,7 +623,7 @@ void UUrBitVectors_Xnor(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 siz temp= (vector2[index] ^ vector1[index]); vector2[index]= ~temp; } - + if (BV_NUM(size)) { temp= vector2[BV_INDEX(size)] ^ (vector1[BV_INDEX(size)] & BV_MASK(size)); @@ -635,14 +635,14 @@ void UUrBitVectors_Xnor(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 siz void UUrBitVector_Copy(const UUtUns32 *vector1, UUtUns32 *vector2, UUtUns32 size) { UUtUns32 index; - + UUmAssert(vector1); UUmAssert(vector2); for (index= 0; index < BV_INDEX(size); index++) { vector2[index] = vector1[index]; } - + if (BV_NUM(size)) { vector2[BV_INDEX(size)] = (vector1[BV_INDEX(size)] & BV_MASK(size)); @@ -671,14 +671,14 @@ UUtBool UUrBitVector_Expand16Bit( UUtUns32 end_index= BV_INDEX(end); UUtUns32 i; UUtUns32 pattern; - + UUmAssert(bitVector); if (start_index==end_index) { start_mask &= end_mask; - + pattern = bitVector[start_index] & start_mask; - + for(i = 32; i-- > 0;) { if(start_mask & (1 << i)) @@ -697,9 +697,9 @@ UUtBool UUrBitVector_Expand16Bit( else { UUtUns32 iterator= start_index+1; - + pattern = bitVector[start_index] & start_mask; - + for(i = 32; i-- > 0;) { if(start_mask & (1 << i)) @@ -714,7 +714,7 @@ UUtBool UUrBitVector_Expand16Bit( } } } - + while (iterator!=end_index) { pattern = bitVector[iterator++]; @@ -741,9 +741,9 @@ UUtBool UUrBitVector_Expand16Bit( } } } - + pattern = bitVector[end_index] & end_mask; - + for(i = 32; i-- > 0;) { if(end_mask & (1 << i)) @@ -759,13 +759,13 @@ UUtBool UUrBitVector_Expand16Bit( } } } - + return UUcFalse; } #endif -static UUtUns8 g2BitSubtractor[256] = +static UUtUns8 g2BitSubtractor[256] = { 0x0, //00000000 -> 00000000 0x0, //00000001 -> 00000000 @@ -1068,18 +1068,18 @@ void UUr2BitVector_Decrement(UUtUns32 *in2BitVector, UUtUns32 inSize) UUtUns32 byte4; byte1 = (long_value >> 24) & 0xff; - byte1 = g2BitSubtractor[byte1]; + byte1 = g2BitSubtractor[byte1]; byte2 = (long_value >> 16) & 0xff; - byte2 = g2BitSubtractor[byte2]; + byte2 = g2BitSubtractor[byte2]; byte3 = (long_value >> 8) & 0xff; - byte3 = g2BitSubtractor[byte3]; + byte3 = g2BitSubtractor[byte3]; byte4 = (long_value >> 0) & 0xff; - byte4 = g2BitSubtractor[byte4]; + byte4 = g2BitSubtractor[byte4]; - *curLong = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | (byte4 << 0); + *curLong = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | (byte4 << 0); } return; diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Error.c b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Error.c index 7c2df18..b5bf0b2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Error.c +++ b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Error.c @@ -1,12 +1,12 @@ /* FILE: BFW_Error.c - + AUTHOR: Brent H. Pease - + CREATED: May 18, 1997 - + PURPOSE: Interface to the Motoko 3D engine (uhh... hehe) - + Copyright 1997 */ @@ -32,9 +32,9 @@ enum { _button_abort= 1, _button_retry, _button_ignore, - + MAC_ERROR_ALERT_RES_ID= 129, - + MAX_STRING_LENGTH= 256 }; @@ -62,7 +62,7 @@ static void iAppendDebugFileMessage(char *msg) iDebugFile = fopen("debugger.txt", "wb"); #endif } - + if (iDebugFile != NULL) { fprintf(iDebugFile, "%s"UUmNL, msg); @@ -87,20 +87,20 @@ static UUtBool iDebuggerMessageBox(char *msg) MSG quitMsg; UUrString_Copy(buffer, msg, MAX_STRING_LENGTH); - + // remove a quit message if required (otherwise the dialog quits for us, thanks!) - bQuit = PeekMessage(&quitMsg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE); + bQuit = PeekMessage(&quitMsg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE); - // bring up the dialog + // bring up the dialog UUrString_Cat(buffer, UUmNL UUmNL "(Retry will enter the debugger)", MAX_STRING_LENGTH); ShowCursor(TRUE); - msgbox_result = MessageBox(NULL, buffer, "Assertion Failed", + msgbox_result = MessageBox(NULL, buffer, "Assertion Failed", MB_TASKMODAL|MB_ICONHAND|MB_ABORTRETRYIGNORE|MB_SETFOREGROUND); ShowCursor(FALSE); // restore the quit message if required if (bQuit) - PostQuitMessage(quitMsg.wParam); + PostQuitMessage(quitMsg.wParam); switch(msgbox_result) { @@ -133,22 +133,22 @@ static UUtBool iDebuggerMessageBox( { char buffer[MAX_STRING_LENGTH]; int alert_result; - + extern void mac_hide_cursor(void); extern void mac_show_cursor(void); UUrString_Copy(buffer, msg, MAX_STRING_LENGTH); - // bring up the dialog + // bring up the dialog UUrString_Cat(buffer, " (Retry will enter the debugger)", MAX_STRING_LENGTH); - + mac_show_cursor(); - + c2pstrcpy((StringPtr)buffer, buffer); // this call can do in-place conversion, so this is OK ParamText((StringPtr)buffer, NULL, NULL, NULL); alert_result= Alert(MAC_ERROR_ALERT_RES_ID, NULL); - - mac_hide_cursor(); + + mac_hide_cursor(); switch (alert_result) { @@ -168,7 +168,7 @@ static UUtBool iDebuggerMessageBox( return return_value; } #endif - + #if UUmPlatform == UUmPlatform_Mac static void iDebugCStrG(char *str) @@ -176,7 +176,7 @@ static void iDebugCStrG(char *str) #if TOOL_VERSION unsigned char buffer[MAX_STRING_LENGTH]; UUtUns8 length = strlen(str) > (MAX_STRING_LENGTH-2) ? (MAX_STRING_LENGTH-2) : strlen(str); - + UUrString_Copy((char *)buffer + 1, str, (MAX_STRING_LENGTH-1)); buffer[length + 1] = ';'; buffer[length + 2] = 'g'; @@ -186,7 +186,7 @@ static void iDebugCStrG(char *str) } #endif - + void UUrError_Report_Internal( const char* file, unsigned long line, @@ -194,13 +194,13 @@ void UUrError_Report_Internal( const char* message) { char buffer[MAX_STRING_LENGTH]; - + sprintf(buffer, "Error %x reported from File: %s, Line: %d (message follows)",error, file, line); - iAppendDebugFileMessage(buffer); + iAppendDebugFileMessage(buffer); sprintf(buffer, "%s", message); - + #if TOOL_VERSION #if (UUmPlatform == UUmPlatform_Win32) { @@ -224,9 +224,9 @@ void UUrError_Report_Internal( } #endif #endif - + iAppendDebugFileMessage(""); - + return; } @@ -250,7 +250,7 @@ UUtError UUrError_Initialize( { return UUcError_None; } - + void UUrError_Terminate( void) { @@ -365,7 +365,7 @@ char *UUrError_DirectDraw2Str( name= "< unknown >"; break; } - + return name; } @@ -375,10 +375,10 @@ int UUrEnterDebuggerInline( char *msg) { int enterDebugger = 0; - - + + #if defined(DEBUGGING) && DEBUGGING - + #if UUmPlatform == UUmPlatform_Mac // enterDebugger= iDebuggerMessageBox(msg); enterDebugger = 1; @@ -386,15 +386,15 @@ int UUrEnterDebuggerInline( // enterDebugger= iDebuggerMessageBox(msg); enterDebugger = 1; #else - + #error implement me - + #endif - + #else - + /* XXX - Someday print a message to the console or something */ - + #endif return enterDebugger; @@ -405,16 +405,16 @@ void UUcArglist_Call UUrEnterDebugger(const char *format, ...) char msg[257]; /* [length byte] + [255 string bytes] + [null] */ va_list arglist; int return_value; - + va_start(arglist, format); return_value= vsprintf(msg, format, arglist); va_end(arglist); - + iAppendDebugFileMessage(msg); #if defined(DEBUGGING) && DEBUGGING - + #if UUmPlatform == UUmPlatform_Mac { UUtBool enter_debugger; @@ -441,15 +441,15 @@ void UUcArglist_Call UUrEnterDebugger(const char *format, ...) } } #else - + #error implement me - + #endif - + #else - + /* XXX - Someday print a message to the console or something */ - + #endif } @@ -461,14 +461,14 @@ void UUcArglist_Call UUrDebuggerMessage( char buffer[2048]; va_list arglist; int return_value; - + va_start(arglist, format); return_value= vsprintf(buffer, format, arglist); va_end(arglist); iAppendDebugFileMessage(buffer); #if defined(DEBUGGING) && DEBUGGING -#if UUmPlatform == UUmPlatform_Mac +#if UUmPlatform == UUmPlatform_Mac iDebugCStrG(buffer); #elif UUmPlatform == UUmPlatform_Win32 OutputDebugString(buffer); @@ -486,7 +486,7 @@ void UUcArglist_Call UUrStartupMessage( char buffer[8192]; va_list arglist; int return_value; - + va_start(arglist, format); return_value= vsnprintf(buffer, sizeof(buffer), format, arglist); va_end(arglist); diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Error.h b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Error.h index 4cb3a31..a77ecea 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Error.h +++ b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Error.h @@ -1,12 +1,12 @@ /* FILE: BFW_Error.h - + AUTHOR: Brent H. Pease - + CREATED: May 18, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -15,7 +15,7 @@ UUtError UUrError_Initialize( void); - + void UUrError_Terminate( void); diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Memory.c b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Memory.c index 4f04a8a..59d7314 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Memory.c +++ b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Memory.c @@ -1,12 +1,12 @@ /* FILE: BFW_Memory.c - + AUTHOR: Brent H. Pease - + CREATED: May 18, 1997 - + PURPOSE: memory manager - + Copyright 1997 */ @@ -45,7 +45,7 @@ struct UUtMemory_Pool_Heap { char *heapMemory; UUtUns32 nextFreeIndex; - + UUtMemory_Pool_Heap *next; }; @@ -54,7 +54,7 @@ struct UUtMemory_Pool UUtBool fixed; UUtUns32 chunkSize; UUtMemory_Pool_Heap *heapList; - + UUtMemory_Pool_Heap *activeHeap; }; @@ -64,9 +64,9 @@ struct UUtMemory_Heap_Subheap { char* memory; UUtUns32* blockBV; - + UUtUns32 blocksLeft; - + UUtMemory_Heap_Subheap *next; }; @@ -85,14 +85,14 @@ struct UUtMemory_Array UUtUns32 allocChunkSize; UUtUns32 numElemsAlloced; void *data; - + }; struct UUtMemory_ParallelArray_Member { UUtUns32 elemSize; void *data; - + }; struct UUtMemory_ParallelArray @@ -102,22 +102,22 @@ struct UUtMemory_ParallelArray UUtUns32 numMemberArrays; UUtUns32 allocChunkSize; UUtMemory_ParallelArray_Member members[UUcMemory_ParallelArray_MaxMembers]; - + }; #if DEBUGGING_MEMORY - + #define UUcMemory_MinUsageThreshold (10 * 1024 * 1024) UUtUns32 gMemoryTracker_NumRecords = 0; UUtUns32 gMemoryTracker_NumBlocks; - + typedef struct UUtMemory_LeakStack { char* fileName; UUtInt32 lineNum; UUtUns32 timeStamp; const char* comment; - + } UUtMemory_LeakStack; #define cMaxLeakStackLength 30 @@ -128,34 +128,34 @@ struct UUtMemory_ParallelArray UUtInt32 gCurMemUsage = 0; UUtInt32 gMaxMemUsage = 0; - + UUtBool gReport_ForceGlobal = UUcFalse; UUtBool UUgMemory_VerifyForceDisable = UUcFalse; UUtBool UUgMemory_VerifyForceEnable = UUcFalse; UUtBool UUgMemory_VerifyEnable = UUcTrue; - + #if !defined(UUmDebugMemAggressive) - + #define UUmDebugMemAggressive 0 - + #endif - + #if !defined(UUmDebugDelete) - + #define UUmDebugDelete 0 - + #endif - + #define UUcMaxDebugFileLength 256 #define UUcMaxCallChainLength 100 - + typedef struct UUtBookkeepBlock { struct UUtBookkeepBlock *next; - + UUtUns32 numChains; UUtUns32 callChainList[UUcMaxCallChainLength]; - + char file[UUcMaxDebugFileLength]; UUtInt32 line; UUtUns32 realBytes; // memory requested @@ -163,58 +163,58 @@ struct UUtMemory_ParallelArray UUtInt32 *beginMagic; UUtInt32 *endMagic; void* realBlock; - + #if defined(UUmDebugMemAggressive) && UUmDebugMemAggressive - + UUtInt32 *endAggressive; - + #endif - + UUtInt32 checkSum; - + UUtUns32 timeStamp; - + UUtUns32 numTimesRealloced; - + UUtUns16 reported; - + UUtUns16 stackLevel; - + } UUtBookkeepBlock; - + #if defined(UUmDebugDelete) && UUmDebugDelete - + typedef struct UUtDeletedBookkeepBlock { struct UUtDeletedBookkeepBlock *next; - + char file[UUcMaxDebugFileLength]; UUtInt32 line; - + void *addr; - + } UUtDeletedBookkeepBlock; - + UUtDeletedBookkeepBlock *gDeletedBlockList = NULL; - + #endif - + #define UUcMemoryTracker_FileLength (32) - + typedef struct UUtMemoryTracker { char fileName[UUcMemoryTracker_FileLength]; UUtUns32 lineNum; - + UUtUns32 memoryAllocated; - + } UUtMemoryTracker; - + /* Eventually move this into a per instance structure */ UUtBookkeepBlock *gBlockListHead = NULL; AUtSharedElemArray* gMemoryTracker = NULL; - + #endif /* DEBUGGING_MEMORY */ @@ -224,7 +224,7 @@ struct UUtMemory_ParallelArray Since Oni doesn't handle allocation failure, I'm doing it here. Anyone who has a problem with that can start working on the Mac build and then come yell at me :o) -*/ +*/ enum { RELIEF_FUND_SIZE= 1024 * 32 @@ -239,7 +239,7 @@ static void out_of_memory( free(stefans_emergency_relief_fund); stefans_emergency_relief_fund= NULL; AUrMessageBox(AUcMBType_OK, "Sorry, Oni has run out of memory!"); - + #if UUmPlatform == UUmPlatform_Mac // somehow, someway, even calling ExitToShell() is causing atexit-registered functions // to be triggered, which tends to blow up on the Mac @@ -251,7 +251,7 @@ static void out_of_memory( ExitToShell(); } #endif - + exit(1); return; @@ -276,10 +276,10 @@ static UUtUns32 iSizeToAllocSize(UUtUns32 inSize) void *UUrAlignMemory(void *inMemory) { UUtUns32 alignedMemory; - + alignedMemory = (UUtUns32)(((UUtUns32)inMemory + UUcProcessor_CacheLineSize_Mask) & ~UUcProcessor_CacheLineSize_Mask); - + return (void *) alignedMemory; } @@ -289,10 +289,10 @@ void *UUrAlignMemory(void *inMemory) static void *iAlignMemory_PlusPointerSpace(void *inMemory) { UUtUns32 alignedMemory; - + alignedMemory = (UUtUns32)(((UUtUns32)inMemory + UUcProcessor_CacheLineSize_Mask + 4) & ~UUcProcessor_CacheLineSize_Mask); - + return (void *) alignedMemory; } @@ -372,13 +372,13 @@ UUrMemory_Tracker_Compare( UUtMemoryTracker* inElemB) { UUtInt16 result; - + result = strcmp(inElemA->fileName, inElemB->fileName); if(result != 0) return result; - + if(inElemA->lineNum > inElemB->lineNum) return 1; if(inElemA->lineNum < inElemB->lineNum) return -1; - + return 0; } @@ -390,7 +390,7 @@ UUiMemory_Debug_FindBookkeepBlock( void* inMemory) { UUtBookkeepBlock *bookkeepBlock; - + for( bookkeepBlock = gBlockListHead; bookkeepBlock; @@ -402,34 +402,34 @@ UUiMemory_Debug_FindBookkeepBlock( break; } } - + return bookkeepBlock; } /******************************************************************************* * ******************************************************************************/ -static void +static void UUiMemory_Debug_VerifyBlock( UUtBookkeepBlock* inBookkeepBlock) { - + if(*inBookkeepBlock->beginMagic != UUmMemoryBeginMagic) { UUmDebugStr("beginMagic is bogus"); return; } - + if(*inBookkeepBlock->endMagic != UUmMemoryEndMagic) { UUmDebugStr("endMagic is bogus"); return; } - + #if defined(UUmDebugMemAggressive) && UUmDebugMemAggressive { UUtInt32 *curLong; - + for( curLong = inBookkeepBlock->endMagic + 1; curLong < inBookkeepBlock->endAggressive; @@ -448,12 +448,12 @@ UUiMemory_Debug_VerifyBlock( /******************************************************************************* * ******************************************************************************/ -void +void UUrMemory_Block_VerifyList( void) { UUtBookkeepBlock *bookkeepBlock; - + if (UUgMemory_VerifyForceDisable || !(UUgMemory_VerifyForceEnable || UUgMemory_VerifyEnable)) return; @@ -469,19 +469,19 @@ UUrMemory_Block_VerifyList( /******************************************************************************* * ******************************************************************************/ -void +void UUrMemory_Block_Verify( void* inMemory) { UUtBookkeepBlock *bookkeepBlock; - + bookkeepBlock = UUiMemory_Debug_FindBookkeepBlock(inMemory); - + if (NULL == bookkeepBlock) { UUmDebugStr("This is not a valid BFW Memory Block"); } - + UUiMemory_Debug_VerifyBlock(bookkeepBlock); } @@ -534,9 +534,9 @@ UUrMemory_ArrayElement_Delete( UUmAssertReadPtr(inBasePtr, inElemSize * inArrayLength); UUmAssert(inDeleteElemIndex < inArrayLength); UUmAssert(inElemSize > 0); - + if(inDeleteElemIndex == inArrayLength - 1) return; // no need to delete because it is the last element - + memmove( (char*)inBasePtr + inDeleteElemIndex * inElemSize, (char*)inBasePtr + (inDeleteElemIndex + 1) * inElemSize, @@ -573,12 +573,12 @@ void UUrMemory_Set32(void *inDst, UUtUns32 inFillValue, UUtUns32 inSize) { UUtUns32 original_write_size = inSize; UUtUns32 *p32Dst = (UUtUns32 *) inDst; - + UUmAssert(((UUtUns32)inDst & 0x3) == 0); UUmAssertWritePtr(inDst, inSize); - + UUmAssert(UUcProcessor_CacheLineSize == 32); - + if (inSize >= UUcProcessor_CacheLineSize) { // align to cache line boundary @@ -592,7 +592,7 @@ void UUrMemory_Set32(void *inDst, UUtUns32 inFillValue, UUtUns32 inSize) while(inSize > UUcProcessor_CacheLineSize) { UUrProcessor_ZeroCacheLine(p32Dst, 0); - + *p32Dst++ = inFillValue; *p32Dst++ = inFillValue; *p32Dst++ = inFillValue; @@ -601,7 +601,7 @@ void UUrMemory_Set32(void *inDst, UUtUns32 inFillValue, UUtUns32 inSize) *p32Dst++ = inFillValue; *p32Dst++ = inFillValue; *p32Dst++ = inFillValue; - + inSize -= UUcProcessor_CacheLineSize; } } @@ -624,14 +624,14 @@ void UUrMemory_Set32(void *inDst, UUtUns32 inFillValue, UUtUns32 inSize) inSize--; } } - + } /******************************************************************************* * NOTE: I know my memory begins on a cache aligned boundary and has at least * a cache line of slop at the end ******************************************************************************/ -static void +static void UUiMemory_Block_Copy( void* inDest, void* inSrc, @@ -646,40 +646,40 @@ UUiMemory_Block_Copy( srcPtr = (double *)inSrc; destPtr = (double *)inDest; - + UUmAssert(((unsigned long)inDest & UUcProcessor_CacheLineSize_Mask) == 0); UUmAssert(((unsigned long)inSrc & UUcProcessor_CacheLineSize_Mask) == 0); - + for(i = (inLen + UUcProcessor_CacheLineSize_Mask) >> UUcProcessor_CacheLineBits; i-- > 0;) { UUrProcessor_ZeroCacheLine(destPtr, 0); - + #if UUcProcessor_CacheLineBits == 5 - + /* XXX - Does this suck on intel ? */ - + ft0 = srcPtr[0]; ft1 = srcPtr[1]; ft2 = srcPtr[2]; ft3 = srcPtr[3]; srcPtr += 4; - + destPtr[0] = ft0; destPtr[1] = ft1; destPtr[2] = ft2; destPtr[3] = ft3; destPtr += 4; - + #else - + #error handle me - + #endif } } /******************************************************************************* - * Make sure memory is cache line aligned and has at least an extra cache line + * Make sure memory is cache line aligned and has at least an extra cache line * at the end. This lets me make some very convient assumptions about my memory! ******************************************************************************/ void * @@ -690,11 +690,11 @@ UUrMemory_Block_New_Real( UUtUns32 alignedMemory; UUtUns32 mungedSize; - if (0 == inSize) + if (0 == inSize) { return NULL; } - + // Make sure that we allocate memory in cache size chunks mungedSize = (inSize + UUcProcessor_CacheLineSize_Mask) & ~UUcProcessor_CacheLineSize_Mask; @@ -705,14 +705,14 @@ UUrMemory_Block_New_Real( out_of_memory(); return NULL; } - + // Align to cache line alignedMemory = ((UUtUns32)newMemory + UUcProcessor_CacheLineSize_Mask + 4) & ~UUcProcessor_CacheLineSize_Mask; - + // Keep the original pointer *(UUtUns32 *)(alignedMemory - 4) = (UUtUns32)newMemory; - + return (void *)(alignedMemory); } @@ -723,13 +723,13 @@ UUrMemory_Block_NewClear_Real( UUtUns32 inSize) { void* newMemory; - + newMemory = UUrMemory_Block_New_Real(inSize); if (NULL != newMemory) { UUrMemory_Clear(newMemory, inSize); } - + return newMemory; } @@ -746,39 +746,39 @@ UUrMemory_Block_RecordUsage( UUtMemoryTracker* addedTracker; if(gMemoryTracker == NULL) return; - + gMemoryTracker_NumRecords++; - + AUrSharedElemArray_Reset(gMemoryTracker); - + gMemoryTracker_NumBlocks = 0; - + for( curBookkeepBlock = gBlockListHead; curBookkeepBlock != NULL; curBookkeepBlock = curBookkeepBlock->next) { UUrString_Copy(curTracker.fileName, curBookkeepBlock->file, UUcMemoryTracker_FileLength); - + curTracker.lineNum = curBookkeepBlock->line; curTracker.memoryAllocated = 0; - - error = + + error = AUrSharedElemArray_AddElem( gMemoryTracker, &curTracker, &curTrackerIndex); if(error != UUcError_None) return; - + addedTracker = (UUtMemoryTracker*)AUrSharedElemArray_GetList(gMemoryTracker) + curTrackerIndex; addedTracker->memoryAllocated += curBookkeepBlock->allocedBytes; - + gMemoryTracker_NumBlocks++; } } /******************************************************************************* - * Since we want to return memory that is cache line aligned and has an extra + * Since we want to return memory that is cache line aligned and has an extra * cache line of slop at the end this code embarks the reader on a journey to hell. * enjoy. ******************************************************************************/ @@ -797,23 +797,23 @@ UUrMemory_Block_New_Debug( { return NULL; } - + UUrMemory_Block_VerifyList(); - + // Make sure that we allocate memory in cache size chunks mungedSize = (inSize + UUcProcessor_CacheLineSize_Mask) & ~UUcProcessor_CacheLineSize_Mask; - + // Add space for the begin magic cookie, need to keep start address cache line aligned allocSize = mungedSize + UUcProcessor_CacheLineSize; - + // Add space for the end magic cookie allocSize += 4; - + #if defined(UUmDebugMemAggressive) && UUmDebugMemAggressive - + // Add enough space for end slop allocSize += UUmMemory_EndSlopSize; - + #endif // Allocated the debug block @@ -830,29 +830,29 @@ UUrMemory_Block_New_Debug( UUrMemory_Block_Delete_Real(newBookkeepBlock); return NULL; } - + newBookkeepBlock->realBlock = newRealBlock; - + #if defined(UUmDebugMemAggressive) && UUmDebugMemAggressive - + newBookkeepBlock->endAggressive = (UUtInt32 *)(newRealBlock + allocSize); - + #endif - + // Skip over the initial cache line for the begin magic cookie newRealBlock += UUcProcessor_CacheLineSize; - + // construct the bookkeeping block - + // get the call chain newBookkeepBlock->numChains = UUrStack_GetPCChain( newBookkeepBlock->callChainList, UUcMaxCallChainLength); - + { char* rc; - + rc = strrchr(inFile, BFcPathSeparator); if(rc != NULL) { @@ -871,7 +871,7 @@ UUrMemory_Block_New_Debug( } } } - + newBookkeepBlock->line = inLine; newBookkeepBlock->realBytes = inSize; newBookkeepBlock->allocedBytes = allocSize; @@ -881,7 +881,7 @@ UUrMemory_Block_New_Debug( newBookkeepBlock->stackLevel = gReport_ForceGlobal ? 0 : gLeakStack_TOS - 1; newBookkeepBlock->reported = UUcFalse; newBookkeepBlock->numTimesRealloced = 0; - + #if 0 // add this to the shared array if(gMemoryTracker != NULL) @@ -890,23 +890,23 @@ UUrMemory_Block_New_Debug( UUtError error; UUtUns32 curTrackerIndex; UUtMemoryTracker* addedTracker; - + curTracker.fileName = inFile; curTracker.lineNum = inLine; curTracker.memoryAllocated = 0; - - error = + + error = AUrSharedElemArray_AddElem( gMemoryTracker, &curTracker, &curTrackerIndex); if(error != UUcError_None) return NULL; - + addedTracker = (UUtMemoryTracker*)AUrSharedElemArray_GetList(gMemoryTracker) + curTrackerIndex; addedTracker->memoryAllocated += allocSize; } #endif - + // set our magic values that warn us if we wandered past the ends *newBookkeepBlock->beginMagic = UUmMemoryBeginMagic; *newBookkeepBlock->endMagic = UUmMemoryEndMagic; @@ -915,29 +915,29 @@ UUrMemory_Block_New_Debug( #if defined(DEBUGGING_JUNKMEM) && DEBUGGING_JUNKMEM UUrMemory_Set32(newRealBlock, UUmMemoryBlock_Garbage, mungedSize); #endif - + #if defined(UUmDebugMemAggressive) && UUmDebugMemAggressive // Clear out the end slop space to garbage UUrMemory_Set32(newBookkeepBlock->endMagic + 1, UUmMemoryBlock_Garbage, UUmMemory_EndSlopSize); #endif - + /* add to our bookkeeping list */ newBookkeepBlock->next = gBlockListHead; gBlockListHead = newBookkeepBlock; - + gCurMemUsage += inSize; if(gCurMemUsage > gMaxMemUsage) { gMaxMemUsage = gCurMemUsage; - + if(gCurMemUsage >= UUcMemory_MinUsageThreshold) { UUrMemory_Block_RecordUsage(); } } - + return newRealBlock; } @@ -948,13 +948,13 @@ UUrMemory_Block_NewClear_Debug( UUtUns32 inSize) { void* newMemory; - + newMemory = UUrMemory_Block_New_Debug(inFile, inLine, inSize); if (NULL != newMemory) { UUrMemory_Clear(newMemory, inSize); } - + return newMemory; } @@ -963,16 +963,16 @@ UUrMemory_Block_NewClear_Debug( /******************************************************************************* * ******************************************************************************/ -void +void UUrMemory_Block_Delete_Real( void *inMemory) { unsigned long *realMemory; UUmAssert(NULL != inMemory); // we could use real memory w/ assertions some day - + realMemory = (unsigned long *)((char *)inMemory - 4); - + free((void *)*realMemory); } @@ -981,7 +981,7 @@ UUrMemory_Block_Delete_Real( /******************************************************************************* * ******************************************************************************/ -void +void UUrMemory_Block_Delete_Debug( char *inFile, UUtInt32 inLine, @@ -991,10 +991,10 @@ UUrMemory_Block_Delete_Debug( void *targetDeleteMemory; UUmAssert(NULL != inMemory); - + (void)(inLine); (void)(inFile); - + UUrMemory_Block_VerifyList(); for( curBlock = gBlockListHead, prevBlock = NULL; @@ -1005,30 +1005,30 @@ UUrMemory_Block_Delete_Debug( { break; } - + prevBlock = curBlock; } - + if(curBlock == NULL) { #if defined(UUmDebugDelete) && UUmDebugDelete { UUtDeletedBookkeepBlock *curDeletedBlock; - + /* Traverse the deleted block list */ - + curDeletedBlock = gDeletedBlockList; - + while(curDeletedBlock) { if(curDeletedBlock->addr == inMemory) { break; } - + curDeletedBlock = curDeletedBlock->next; } - + if(curDeletedBlock == NULL) { UUmDebugStr("This block was never allocated nor deleted by me..."); @@ -1036,29 +1036,29 @@ UUrMemory_Block_Delete_Debug( else { char buffer[UUcMaxFunctionHistoryLength + 512]; - + sprintf( buffer, "This block was deleted before by:"UUmNL"File: %s"UUmNL"Line: %d"UUmNL"FuncHistory: Not Available"UUmNL, curDeletedBlock->file, curDeletedBlock->line); - + UUrEnterDebugger(buffer); } } #else - + UUmDebugStr("This is not a valid UU memory block"); - + #endif } - + UUmAssert((char *)inMemory == (char *)curBlock->beginMagic + 4); - - + + targetDeleteMemory = curBlock->realBlock; - - + + /* Remove this block from the list of alloced blocks */ if(prevBlock == NULL) { @@ -1068,35 +1068,35 @@ UUrMemory_Block_Delete_Debug( { prevBlock->next = curBlock->next; } - + /* Garbage Out the memory */ #if defined(DEBUGGING_JUNKMEM) && DEBUGGING_JUNKMEM UUrMemory_Set32(targetDeleteMemory, UUm4CharToUns32('D', 'L', 'T', 'D'), curBlock->allocedBytes); #endif - + { /* Actually delete the memory */ - + UUrMemory_Block_Delete_Real(targetDeleteMemory); - + } - + #if defined(UUmDebugDelete) && UUmDebugDelete - { + { UUtDeletedBookkeepBlock *newDeletedBlock; - + /* Add a new deleted block to gDeletedBlockList */ - + newDeletedBlock = (UUtDeletedBookkeepBlock *)UUrMemory_Block_New_Real(sizeof(UUtDeletedBookkeepBlock)); - + if(newDeletedBlock != NULL) { - + UUrString_Copy(newDeletedBlock->file, inFile, UUcMaxDebugFileLength); newDeletedBlock->line = inLine; newDeletedBlock->addr = inMemory; - + newDeletedBlock->next = gDeletedBlockList; gDeletedBlockList = newDeletedBlock; } @@ -1104,19 +1104,19 @@ UUrMemory_Block_Delete_Debug( { /* Do nothing */ } - } + } #endif - + gCurMemUsage -= curBlock->realBytes; - + UUmAssert(gCurMemUsage >= 0); - + /* Delete the book keeping memory */ - UUrMemory_Block_Delete_Real(curBlock); + UUrMemory_Block_Delete_Real(curBlock); } #endif - + /* starting at memory location inMemory shift everything shift @@ -1126,7 +1126,7 @@ UUrMemory_Block_Delete_Debug( static void iShiftMemory(UUtUns32 inMemory, UUtUns32 len, int shift) { UUtUns32 dst; - + dst = inMemory; dst += shift; @@ -1135,11 +1135,11 @@ static void iShiftMemory(UUtUns32 inMemory, UUtUns32 len, int shift) /******************************************************************************* - realloc returns a void pointer to the reallocated (and possibly moved) memory block. - The return value is NULL if the size is zero and the buffer argument is not NULL, or + realloc returns a void pointer to the reallocated (and possibly moved) memory block. + The return value is NULL if the size is zero and the buffer argument is not NULL, or if there is not enough available memory to expand the block to the given size. In the first case, - the original block is freed. In the second, the original block is unchanged. The return value points - to a storage space that is guaranteed to be suitably aligned for storage of any type of object. + the original block is freed. In the second, the original block is unchanged. The return value points + to a storage space that is guaranteed to be suitably aligned for storage of any type of object. To get a pointer to a type other than void, use a type cast on the return value. ******************************************************************************/ @@ -1231,7 +1231,7 @@ UUrMemory_Block_Realloc_Debug( UUtInt32 inLine, void *inMemory, UUtUns32 inSize) -{ +{ UUrMemory_Block_VerifyList(); // case 1 (NULL == inMemory) this is an allocate @@ -1241,7 +1241,7 @@ UUrMemory_Block_Realloc_Debug( // case 1 (NULL == inMemory) this is an allocate if (NULL == inMemory) { void *allocated = UUrMemory_Block_New_Debug(inFile, inLine, inSize); - + return allocated; } @@ -1258,7 +1258,7 @@ UUrMemory_Block_Realloc_Debug( UUtBookkeepBlock* oldBookkeep = UUiMemory_Debug_FindBookkeepBlock(inMemory); char* newMemory = UUrMemory_Block_New_Debug(inFile, inLine, inSize); UUtBookkeepBlock* newBookkeep = UUiMemory_Debug_FindBookkeepBlock(newMemory); - + // we must find the bookkeep block UUmAssert(NULL != oldBookkeep); @@ -1266,26 +1266,26 @@ UUrMemory_Block_Realloc_Debug( if (NULL == newMemory) { return NULL; - } + } // otherwise copy and then delete the old UUrMemory_MoveFast( inMemory, newMemory, UUmMin(oldBookkeep->realBytes, inSize)); - + UUrString_Copy(newBookkeep->file, oldBookkeep->file, UUcMaxDebugFileLength); - + newBookkeep->line = oldBookkeep->line; newBookkeep->timeStamp = oldBookkeep->timeStamp; newBookkeep->stackLevel = oldBookkeep->stackLevel; newBookkeep->numTimesRealloced = oldBookkeep->numTimesRealloced; - + newBookkeep->numTimesRealloced++; - + UUrMemory_Block_Delete_Debug(inFile, inLine, inMemory); - return newMemory; + return newMemory; } } @@ -1299,37 +1299,37 @@ UUiMemory_Pool_AddHeap( UUtMemory_Pool *inMemoryPool) { UUtMemory_Pool_Heap *newHeap; - + if(inMemoryPool->activeHeap && inMemoryPool->activeHeap->next != NULL) { inMemoryPool->activeHeap = inMemoryPool->activeHeap->next; - + goto done; } - + UUrMemory_Leak_ForceGlobal_Begin(); - + newHeap = UUrMemory_Block_New(sizeof(UUtMemory_Pool_Heap)); if(newHeap == NULL) { return UUcError_OutOfMemory; } - + newHeap->heapMemory = UUrMemory_Block_New(inMemoryPool->chunkSize); if(newHeap->heapMemory == NULL) { UUrMemory_Block_Delete(newHeap); - + return UUcError_OutOfMemory; } - + //UUrMemory_Set32(newHeap->heapMemory, 0xBEEFBEEF, inMemoryPool->chunkSize); - + UUrMemory_Leak_ForceGlobal_End(); newHeap->nextFreeIndex = 0; newHeap->next = NULL; - + if(inMemoryPool->activeHeap != NULL) { inMemoryPool->activeHeap->next = newHeap; @@ -1341,21 +1341,21 @@ UUiMemory_Pool_AddHeap( } done: - + #if 0// DEBUGGING_MEMORY { UUtUns32 i; - + for(i = 0; i < 1000; i++) { UUmAssert(*((UUtUns32*)inMemoryPool->activeHeap->heapMemory + i) == UUmMemoryBlock_Garbage); } - + UUrMemory_Set32(inMemoryPool->activeHeap->heapMemory, UUmMemoryBlock_Garbage, inMemoryPool->chunkSize); } - + #endif - + return UUcError_None; } @@ -1363,14 +1363,14 @@ UUiMemory_Pool_AddHeap( * ******************************************************************************/ -UUtMemory_Pool* +UUtMemory_Pool* UUrMemory_Pool_New_Real( UUtUns32 inChunkSize, UUtBool inFixed) { UUtMemory_Pool *newMemoryPool; UUtUns32 mungedSize; - + newMemoryPool = UUrMemory_Block_New(sizeof(UUtMemory_Pool)); if(newMemoryPool == NULL) { @@ -1378,41 +1378,41 @@ UUrMemory_Pool_New_Real( } mungedSize = (inChunkSize + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask; - + newMemoryPool->chunkSize = mungedSize; newMemoryPool->heapList = NULL; newMemoryPool->activeHeap = NULL; newMemoryPool->fixed = inFixed; - + if(UUiMemory_Pool_AddHeap(newMemoryPool) != UUcError_None) { return NULL; } - + return newMemoryPool; } - + /******************************************************************************* * ******************************************************************************/ -void +void UUrMemory_Pool_Delete_Real( UUtMemory_Pool *inMemoryPool) { UUtMemory_Pool_Heap *curHeap, *nextHeap; - + curHeap = inMemoryPool->heapList; - + while(curHeap != NULL) { nextHeap = curHeap->next; - + UUrMemory_Block_Delete(curHeap->heapMemory); UUrMemory_Block_Delete(curHeap); - + curHeap = nextHeap; } - + UUrMemory_Block_Delete(inMemoryPool); } @@ -1420,7 +1420,7 @@ UUrMemory_Pool_Delete_Real( /******************************************************************************* * ******************************************************************************/ -UUtMemory_Pool* +UUtMemory_Pool* UUrMemory_Pool_New_Debug( char *inFile, long inLine, @@ -1433,7 +1433,7 @@ UUrMemory_Pool_New_Debug( /******************************************************************************* * ******************************************************************************/ -void +void UUrMemory_Pool_Delete_Debug( char *inFile, long inLine, @@ -1473,9 +1473,9 @@ UUrMemory_Pool_Block_New( UUtError error; UUmAssertReadPtr(inMemoryPool, sizeof(*inMemoryPool)); - + mungedSize = (inSize + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask; - + if(mungedSize > inMemoryPool->chunkSize) { return NULL; @@ -1488,17 +1488,17 @@ UUrMemory_Pool_Block_New( { returnMemory = inMemoryPool->activeHeap->heapMemory + inMemoryPool->activeHeap->nextFreeIndex; UUmAssertReadPtr(returnMemory, inSize); - + inMemoryPool->activeHeap->nextFreeIndex += mungedSize; - + goto done; }; - + if(inMemoryPool->fixed == UUcTrue) { return NULL; } - + /* * Check previous heaps */ @@ -1509,14 +1509,14 @@ UUrMemory_Pool_Block_New( { returnMemory = curHeap->heapMemory + curHeap->nextFreeIndex; UUmAssertReadPtr(returnMemory, inSize); - + curHeap->nextFreeIndex += mungedSize; goto done; } - + curHeap = curHeap->next; } - + /* * Add a new heap */ @@ -1525,51 +1525,51 @@ UUrMemory_Pool_Block_New( { return NULL; } - + returnMemory = inMemoryPool->activeHeap->heapMemory; UUmAssertReadPtr(returnMemory, inSize); - + inMemoryPool->activeHeap->nextFreeIndex += mungedSize; done: - + UUmAssertReadPtr(returnMemory, inSize); - + #if defined(DEBUGGING_JUNKMEM) && DEBUGGING_JUNKMEM - + UUrMemory_Set32(returnMemory, UUmMemoryBlock_Garbage, inSize); #endif - + return returnMemory; } /******************************************************************************* * ******************************************************************************/ -void +void UUrMemory_Pool_Reset( UUtMemory_Pool *inMemoryPool) { UUtMemory_Pool_Heap *curHeap; UUmAssert(NULL != inMemoryPool); - + curHeap = inMemoryPool->heapList; - + while(curHeap) { curHeap->nextFreeIndex = 0; - + #if defined(DEBUGGING_JUNKMEM) && DEBUGGING_JUNKMEM - + UUrMemory_Set32(curHeap->heapMemory, UUmMemoryBlock_Garbage, inMemoryPool->chunkSize); - + #endif - + curHeap = curHeap->next; } - + inMemoryPool->activeHeap = inMemoryPool->heapList; } @@ -1581,24 +1581,24 @@ UUiMemory_Heap_AddSubheap( UUtMemory_Heap *inMemoryHeap) { UUtMemory_Heap_Subheap *newSubheap; - + newSubheap = UUrMemory_Block_New(sizeof(UUtMemory_Heap_Subheap)); UUmError_ReturnOnNull(newSubheap); - + newSubheap->memory = UUrMemory_Block_New(inMemoryHeap->chunkSize); UUmError_ReturnOnNull(newSubheap->memory); - + newSubheap->blockBV = UUrBitVector_New(inMemoryHeap->blocksPerHeap); UUmError_ReturnOnNull(newSubheap->blockBV); - + UUrBitVector_ClearBitAll(newSubheap->blockBV, inMemoryHeap->blocksPerHeap); - + newSubheap->next = NULL; newSubheap->blocksLeft = inMemoryHeap->blocksPerHeap; - + newSubheap->next = inMemoryHeap->subheapList; inMemoryHeap->subheapList = newSubheap; - + return UUcError_None; } @@ -1610,7 +1610,7 @@ UUrMemory_Heap_Reset( UUtMemory_Heap *inMemoryHeap) { UUtMemory_Heap_Subheap *curSubheap; - + for(curSubheap = inMemoryHeap->subheapList; curSubheap; curSubheap = curSubheap->next) { UUrBitVector_ClearBitAll(curSubheap->blockBV, inMemoryHeap->blocksPerHeap); @@ -1622,7 +1622,7 @@ UUrMemory_Heap_Reset( /******************************************************************************* * ******************************************************************************/ -UUtMemory_Heap* +UUtMemory_Heap* UUrMemory_Heap_New_Debug( char *inFile, long inLine, @@ -1635,7 +1635,7 @@ UUrMemory_Heap_New_Debug( /******************************************************************************* * ******************************************************************************/ -void +void UUrMemory_Heap_Delete_Debug( char *inFile, long inLine, @@ -1653,7 +1653,7 @@ UUrMemory_Heap_Delete_Debug( /******************************************************************************* * ******************************************************************************/ -UUtMemory_Heap* +UUtMemory_Heap* UUrMemory_Heap_New_Real( UUtUns32 inChunkSize, UUtBool inFixed) @@ -1661,10 +1661,10 @@ UUrMemory_Heap_New_Real( UUtMemory_Heap *newMemoryHeap; UUtUns32 blocksPerHeap; UUtUns32 chunkSize; - + newMemoryHeap = UUrMemory_Block_New(sizeof(UUtMemory_Heap)); if(newMemoryHeap == NULL) return NULL; - + chunkSize = (inChunkSize + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask; newMemoryHeap->chunkSize = chunkSize; @@ -1673,37 +1673,37 @@ UUrMemory_Heap_New_Real( newMemoryHeap->subheapList = NULL; newMemoryHeap->fixed = inFixed; - + if(UUiMemory_Heap_AddSubheap(newMemoryHeap) != UUcError_None) { return NULL; } - + return newMemoryHeap; } - + /******************************************************************************* * ******************************************************************************/ -void +void UUrMemory_Heap_Delete_Real( UUtMemory_Heap *inMemoryHeap) { UUtMemory_Heap_Subheap *curSubheap, *nextSubheap; - + curSubheap = inMemoryHeap->subheapList; - + while(curSubheap != NULL) { nextSubheap = curSubheap->next; - + UUrMemory_Block_Delete(curSubheap->memory); UUrMemory_Block_Delete(curSubheap->blockBV); UUrMemory_Block_Delete(curSubheap); - + curSubheap = nextSubheap; } - + UUrMemory_Block_Delete(inMemoryHeap); } @@ -1746,37 +1746,37 @@ UUrMemory_Heap_Block_New_Real( UUtError error; UUtUns32 numBlocks; UUtMemory_Heap_Subheap* curSubheap; - + UUtUns32 blocksPerHeap; UUtUns32 curBlockIndex; UUtUns32 nextBlockIndex; - + char* resultMemory; - + UUmAssert(NULL != inMemoryHeap); - + UUrMemory_Block_VerifyList(); - + numBlocks = (inSize + UUcProcessor_CacheLineSize - 1) & ~UUcProcessor_CacheLineSize_Mask; numBlocks >>= UUcProcessor_CacheLineBits; - + curSubheap = inMemoryHeap->subheapList; - + blocksPerHeap = inMemoryHeap->blocksPerHeap; - + if(numBlocks > blocksPerHeap) return NULL; - + if(numBlocks < 2) numBlocks = 2; - + for( curSubheap = inMemoryHeap->subheapList; curSubheap != NULL; curSubheap = curSubheap->next) { if(numBlocks > curSubheap->blocksLeft) continue; - + curBlockIndex = 0; - + while(curBlockIndex != UUcBitVector_None && curBlockIndex + numBlocks < blocksPerHeap) { nextBlockIndex = @@ -1784,14 +1784,14 @@ UUrMemory_Heap_Block_New_Real( curSubheap->blockBV, curBlockIndex, curBlockIndex+numBlocks-1); - + if(nextBlockIndex == UUcBitVector_None) { // found a space big enough resultMemory = curSubheap->memory + curBlockIndex * UUcProcessor_CacheLineSize; goto found; } - + curBlockIndex = UUrBitVector_FindFirstSetRange( curSubheap->blockBV, @@ -1799,23 +1799,23 @@ UUrMemory_Heap_Block_New_Real( blocksPerHeap) + 1; } } - + error = UUiMemory_Heap_AddSubheap(inMemoryHeap); if(error != UUcError_None) return NULL; - + UUmAssert(inMemoryHeap->subheapList->blocksLeft == blocksPerHeap); curBlockIndex = 0; curSubheap = inMemoryHeap->subheapList; resultMemory = curSubheap->memory; - + found: - + UUrBitVector_SetBit(curSubheap->blockBV, curBlockIndex); UUrBitVector_SetBit(curSubheap->blockBV, curBlockIndex+numBlocks-1); - - curSubheap->blocksLeft -= numBlocks; - + + curSubheap->blocksLeft -= numBlocks; + return resultMemory; } @@ -1832,7 +1832,7 @@ UUrMemory_Heap_Block_Delete_Real( // This is used to allocate a block within a h UUtUns32 startBVIndex; UUtUns32 endBVIndex; UUtUns32 blocksPerHeap; - + chunkSize = inMemoryHeap->chunkSize; blocksPerHeap = inMemoryHeap->blocksPerHeap; @@ -1844,11 +1844,11 @@ UUrMemory_Heap_Block_Delete_Real( // This is used to allocate a block within a h if((curSubheap->memory <= (char*)inBlock) && ((char*)inBlock < curSubheap->memory + chunkSize)) { startBVIndex = ((char*)inBlock - curSubheap->memory) >> UUcProcessor_CacheLineBits; - + UUmAssert(UUrBitVector_TestBit(curSubheap->blockBV, startBVIndex)); - + UUrBitVector_ClearBit(curSubheap->blockBV, startBVIndex); - endBVIndex = + endBVIndex = UUrBitVector_FindFirstSetRange( curSubheap->blockBV, startBVIndex + 1, @@ -1857,13 +1857,13 @@ UUrMemory_Heap_Block_Delete_Real( // This is used to allocate a block within a h UUmAssert(UUrBitVector_TestBit(curSubheap->blockBV, endBVIndex)); UUrBitVector_ClearBit(curSubheap->blockBV, endBVIndex); - + curSubheap->blocksLeft += endBVIndex - startBVIndex + 1; - + return; } } - + UUmAssert(0); } @@ -1895,7 +1895,7 @@ UUrMemory_Heap_Block_Verify( UUmAssert(!"This block is illegal"); } } - + UUmAssert(!"This block is illegal"); } #endif @@ -1903,7 +1903,7 @@ UUrMemory_Heap_Block_Verify( /******************************************************************************* * ******************************************************************************/ -UUtMemory_Array* +UUtMemory_Array* UUrMemory_Array_New_Real( // This is used to create a new array UUtUns32 inElementSize, // The size of each element UUtUns32 inAllocChunkSize, // The chunk size of incremental allocations @@ -1911,19 +1911,19 @@ UUrMemory_Array_New_Real( // This is used to create a new array UUtUns32 inNumElemsToAlloc) // The number of elements to allocate { UUtMemory_Array *newMemoryArray; - + newMemoryArray = UUrMemory_Block_New(sizeof(UUtMemory_Array)); - if (NULL == newMemoryArray) + if (NULL == newMemoryArray) { return NULL; } - + newMemoryArray->elemSize = inElementSize; newMemoryArray->allocChunkSize = inAllocChunkSize; newMemoryArray->numElemsUsed = inNumInitialElemsUsed; newMemoryArray->numElemsAlloced = inNumElemsToAlloc; - + if(inNumElemsToAlloc > 0) { newMemoryArray->data = UUrMemory_Block_New(inElementSize * inNumElemsToAlloc); @@ -1936,13 +1936,13 @@ UUrMemory_Array_New_Real( // This is used to create a new array { newMemoryArray->data = NULL; } - + return newMemoryArray; } #if DEBUGGING_MEMORY -UUtMemory_Array* +UUtMemory_Array* UUrMemory_Array_New_Debug( // This is used to create a new array char* inFile, UUtInt32 inLine, @@ -1952,19 +1952,19 @@ UUrMemory_Array_New_Debug( // This is used to create a new array UUtUns32 inNumElemsToAlloc) // The number of elements to allocate { UUtMemory_Array *newMemoryArray; - + newMemoryArray = UUrMemory_Block_New_Debug(inFile, inLine, sizeof(UUtMemory_Array)); - if (NULL == newMemoryArray) + if (NULL == newMemoryArray) { return NULL; } - + newMemoryArray->elemSize = inElementSize; newMemoryArray->allocChunkSize = inAllocChunkSize; newMemoryArray->numElemsUsed = inNumInitialElemsUsed; newMemoryArray->numElemsAlloced = inNumElemsToAlloc; - + if (inNumElemsToAlloc > 0) { newMemoryArray->data = UUrMemory_Block_New(inElementSize * inNumElemsToAlloc); @@ -1977,7 +1977,7 @@ UUrMemory_Array_New_Debug( // This is used to create a new array { newMemoryArray->data = NULL; } - + return newMemoryArray; } @@ -1986,35 +1986,35 @@ UUrMemory_Array_New_Debug( // This is used to create a new array /******************************************************************************* * ******************************************************************************/ -void +void UUrMemory_Array_Delete_Real( // This is used to delete a array UUtMemory_Array* inMemoryArray) { UUmAssert(inMemoryArray != NULL); - + if(inMemoryArray->data != NULL) { UUrMemory_Block_Delete(inMemoryArray->data); } - + UUrMemory_Block_Delete(inMemoryArray); } #if DEBUGGING_MEMORY -void +void UUrMemory_Array_Delete_Debug( // This is used to delete a array char* inFile, UUtInt32 inLine, UUtMemory_Array* inMemoryArray) { UUmAssert(inMemoryArray != NULL); - + if(inMemoryArray->data != NULL) { UUrMemory_Block_Delete_Debug(inFile, inLine, inMemoryArray->data); } - + UUrMemory_Block_Delete(inMemoryArray); } @@ -2023,21 +2023,21 @@ UUrMemory_Array_Delete_Debug( // This is used to delete a array /******************************************************************************* * ******************************************************************************/ -UUtError +UUtError UUrMemory_Array_MakeRoom( // This is used to make sure that enough elems have been allocated UUtMemory_Array* inMemoryArray, UUtUns32 inNumElems, UUtBool *outMemoryMoved) { void *newData; - + UUmAssert(inMemoryArray != NULL); - + if(outMemoryMoved != NULL) { *outMemoryMoved = UUcFalse; } - + if(inNumElems > inMemoryArray->numElemsAlloced) { if(inMemoryArray->data == NULL) @@ -2054,16 +2054,16 @@ UUrMemory_Array_MakeRoom( // This is used to make sure that enough elems have { goto failure; } - + if(outMemoryMoved != NULL) { *outMemoryMoved = UUcTrue; } - + inMemoryArray->data = newData; inMemoryArray->numElemsAlloced = inNumElems; } - + return UUcError_None; failure: @@ -2093,16 +2093,16 @@ UUrMemory_Array_GetNewElement( // This is used to get an additional element fro UUtBool *outMemoryMoved) { UUtUns32 newIndex; - + UUmAssert(inMemoryArray != NULL); if(outMemoryMoved != NULL) { *outMemoryMoved = UUcFalse; } - + newIndex = inMemoryArray->numElemsUsed++; - + if(inMemoryArray->numElemsUsed >= inMemoryArray->numElemsAlloced) { if(UUrMemory_Array_MakeRoom( @@ -2113,13 +2113,13 @@ UUrMemory_Array_GetNewElement( // This is used to get an additional element fro goto failure; } } - + *outNewIndex = newIndex; - + return UUcError_None; failure: - + return UUcError_OutOfMemory; } @@ -2134,11 +2134,11 @@ UUrMemory_Array_DeleteElement( // This always moves memory { UUmAssert(inMemoryArray != NULL); UUmAssert(inMemoryArray->numElemsUsed > 0); - + UUmAssert(inIndex < inMemoryArray->numElemsUsed); - + inMemoryArray->numElemsUsed -= 1; - + if(inIndex < inMemoryArray->numElemsUsed) { char *dst = (char *)inMemoryArray->data + inMemoryArray->elemSize * inIndex; @@ -2146,7 +2146,7 @@ UUrMemory_Array_DeleteElement( // This always moves memory UUtUns32 size = inMemoryArray->elemSize * (inMemoryArray->numElemsUsed - inIndex); UUrMemory_MoveOverlap(src, dst, size); - } + } } /******************************************************************************* @@ -2173,7 +2173,7 @@ UUrMemory_Array_SetUsedElems( // This is used to set the number of elements in u UUmAssert(inMemoryArray != NULL); inMemoryArray->numElemsUsed = inElemsUsed; - + return UUrMemory_Array_MakeRoom(inMemoryArray, inElemsUsed, outMemoryMoved); } @@ -2181,55 +2181,55 @@ UUrMemory_Array_SetUsedElems( // This is used to set the number of elements in u * ******************************************************************************/ UUtError -UUrMemory_Array_InsertElement( +UUrMemory_Array_InsertElement( UUtMemory_Array* inMemoryArray, UUtUns32 inIndex, UUtBool *outMemoryMoved) { UUtError error; - + inMemoryArray->numElemsUsed++; - + error = UUrMemory_Array_MakeRoom(inMemoryArray, inMemoryArray->numElemsUsed, outMemoryMoved); UUmError_ReturnOnError(error); - + UUrMemory_MoveOverlap( (char*)inMemoryArray->data + inMemoryArray->elemSize * inIndex, (char*)inMemoryArray->data + inMemoryArray->elemSize * (inIndex + 1), (inMemoryArray->numElemsUsed - inIndex - 1) * inMemoryArray->elemSize); - + return UUcError_None; } /******************************************************************************* * ******************************************************************************/ -UUtMemory_ParallelArray* +UUtMemory_ParallelArray* UUrMemory_ParallelArray_New_Real( // This is used to create a new parallel array UUtUns32 inAllocChunkSize, // The chunk size of incremental allocations UUtUns32 inNumInitialElemsUsed, // The number of elements initially used UUtUns32 inNumElemsToAlloc) // The number of elements to allocate { UUtMemory_ParallelArray *newParallelArray; - + newParallelArray = UUrMemory_Block_New(sizeof(UUtMemory_ParallelArray)); - + if (newParallelArray == NULL) { return NULL; } - + newParallelArray->numElemsUsed = inNumInitialElemsUsed; newParallelArray->numElemsAlloced = inNumElemsToAlloc; newParallelArray->allocChunkSize = inAllocChunkSize; newParallelArray->numMemberArrays = 0; - + return newParallelArray; } #if DEBUGGING_MEMORY -UUtMemory_ParallelArray* +UUtMemory_ParallelArray* UUrMemory_ParallelArray_New_Debug( char* inFile, long inLine, @@ -2238,23 +2238,23 @@ UUrMemory_ParallelArray_New_Debug( UUtUns32 inNumElemsToAlloc) { UUtMemory_ParallelArray *newParallelArray; - + newParallelArray = UUrMemory_Block_New_Debug(inFile, inLine, sizeof(UUtMemory_ParallelArray)); - + if (newParallelArray == NULL) { goto failure; } - + newParallelArray->numElemsUsed = inNumInitialElemsUsed; newParallelArray->numElemsAlloced = inNumElemsToAlloc; newParallelArray->allocChunkSize = inAllocChunkSize; newParallelArray->numMemberArrays = 0; - + return newParallelArray; failure: - + return NULL; } @@ -2263,14 +2263,14 @@ UUrMemory_ParallelArray_New_Debug( /******************************************************************************* * ******************************************************************************/ -void +void UUrMemory_ParallelArray_Delete_Real( // This is used to delete a parallel array UUtMemory_ParallelArray* inParallelArray) { UUtUns32 i; UUmAssert(NULL != inParallelArray); - + for(i = 0; i < inParallelArray->numMemberArrays; i++) { if(inParallelArray->members[i].data != NULL) @@ -2278,13 +2278,13 @@ UUrMemory_ParallelArray_Delete_Real( // This is used to delete a parallel array UUrMemory_Block_Delete(inParallelArray->members[i].data); } } - + UUrMemory_Block_Delete(inParallelArray); } #if DEBUGGING_MEMORY -void +void UUrMemory_ParallelArray_Delete_Debug( char* inFile, long inLine, @@ -2301,7 +2301,7 @@ UUrMemory_ParallelArray_Delete_Debug( UUrMemory_Block_Delete_Debug(inFile, inLine, inParallelArray->members[i].data); } } - + UUrMemory_Block_Delete_Debug(inFile, inLine, inParallelArray); } @@ -2309,7 +2309,7 @@ UUrMemory_ParallelArray_Delete_Debug( /******************************************************************************* * ******************************************************************************/ -UUtMemory_ParallelArray_Member* +UUtMemory_ParallelArray_Member* UUrMemory_ParallelArray_Member_New( // This is used to create a new member array UUtMemory_ParallelArray* inParallelArray, UUtUns32 inElementSize) @@ -2317,38 +2317,38 @@ UUrMemory_ParallelArray_Member_New( // This is used to create a new member array UUtMemory_ParallelArray_Member *newParallelArrayMember; UUmAssert(NULL != inParallelArray); - + if(inParallelArray->numMemberArrays >= UUcMemory_ParallelArray_MaxMembers) { return NULL; } - + newParallelArrayMember = &inParallelArray->members[inParallelArray->numMemberArrays++]; - + newParallelArrayMember->elemSize = inElementSize; - + if(inParallelArray->numElemsAlloced > 0) { newParallelArrayMember->data = UUrMemory_Block_New(inElementSize * inParallelArray->numElemsAlloced); - + if(newParallelArrayMember->data == NULL) { goto failure; } } - + return newParallelArrayMember; - + failure: - + return NULL; - + } /******************************************************************************* * ******************************************************************************/ -UUtError +UUtError UUrMemory_ParallelArray_MakeRoom( // This is used to make sure that enough elems have been allocated UUtMemory_ParallelArray* inParallelArray, UUtUns32 inNumElems, @@ -2363,7 +2363,7 @@ UUrMemory_ParallelArray_MakeRoom( // This is used to make sure that enough elem { *outMemoryMoved = UUcFalse; } - + if(inNumElems > inParallelArray->numElemsAlloced) { inParallelArray->numElemsAlloced = inNumElems; @@ -2371,7 +2371,7 @@ UUrMemory_ParallelArray_MakeRoom( // This is used to make sure that enough elem { *outMemoryMoved = UUcTrue; } - + for(i = 0; i < inParallelArray->numMemberArrays; i++) { if(inParallelArray->members[i].data == NULL) @@ -2389,12 +2389,12 @@ UUrMemory_ParallelArray_MakeRoom( // This is used to make sure that enough elem { goto failure; } - + inParallelArray->members[i].data = newData; } } } - + return UUcError_None; failure: @@ -2413,9 +2413,9 @@ UUrMemory_ParallelArray_DeleteElement( // This is used to delete a element in ev UUtUns32 i; UUmAssert(NULL != inParallelArray); - + inParallelArray->numElemsUsed -= 1; - + for(i = 0; i < inParallelArray->numMemberArrays; i++) { char *src = (char *)inParallelArray->members[i].data + inParallelArray->members[i].elemSize * (inIndex + 1); @@ -2448,12 +2448,12 @@ UUrMemory_ParallelArray_SetUsedElems( // This is used to set the number of eleme UUtBool *outMemoryMoved) { UUmAssert(inParallelArray != NULL); - + inParallelArray->numElemsUsed = inElemsUsed; return UUrMemory_ParallelArray_MakeRoom(inParallelArray, inElemsUsed, outMemoryMoved); } - + /******************************************************************************* * ******************************************************************************/ @@ -2471,7 +2471,7 @@ UUrMemory_ParallelArray_AddNewElem( // This adds a new element to every member if (NULL != outMemoryMoved) { *outMemoryMoved = UUcFalse; } - + if(inParallelArray->numElemsUsed >= inParallelArray->numElemsAlloced) { if(UUrMemory_ParallelArray_MakeRoom( @@ -2482,7 +2482,7 @@ UUrMemory_ParallelArray_AddNewElem( // This adds a new element to every member return UUcError_OutOfMemory; } } - + return UUcError_None; } @@ -2541,17 +2541,17 @@ UUrMemory_String_New( UUtUns32 inTableSize) { UUtMemory_String* newMemoryString; - + newMemoryString = UUrMemory_Block_New(sizeof(UUtMemory_String) + inTableSize - 4); - + if(newMemoryString == NULL) { return NULL; } - + newMemoryString->tableSize = inTableSize; newMemoryString->data[0] = 0; - + return newMemoryString; } @@ -2579,38 +2579,38 @@ UUrMemory_String_GetStr( if ('\0' == *inStr) { return UUgMemory_String_Zero; } - + length = (UUtInt32)strlen(inStr); if(length >= (UUtInt32)inMemoryString->tableSize) return NULL; - + p = inMemoryString->data; - + while(1) { if(*p == 0) { break; } - + if(!strcmp(p, inStr)) { return p; } - + p += strlen(p) + 1; } - + length = strlen(inStr); - + if((UUtUns32)((p - inMemoryString->data) + length + 2) > inMemoryString->tableSize) { return NULL; } - + strcpy(p, inStr); *(p + length) = 0; *(p + length + 1) = 0; - + return p; } @@ -2646,12 +2646,12 @@ UUrMemory_Leak_Start_Real( const char* inComment) { UUmAssert(gLeakStack_TOS < cMaxLeakStackLength); - + gLeakStack[gLeakStack_TOS].fileName = inFileName; gLeakStack[gLeakStack_TOS].lineNum = inLineNum; gLeakStack[gLeakStack_TOS].timeStamp = UUrMachineTime_Sixtieths(); gLeakStack[gLeakStack_TOS].comment = inComment; - + gLeakStack_TOS++; } @@ -2663,7 +2663,7 @@ UUrMemory_Leak_StopAndReport_Real( void) { UUtError error; - + FILE *memLeakFile = NULL; UUtBookkeepBlock* curBookkeepBlock; @@ -2674,16 +2674,16 @@ UUrMemory_Leak_StopAndReport_Real( UUtUns32 line; UUtUns16 itr; UUtBool firstTime = UUcTrue; - + gLeakStack_TOS--; - + if (memLeakFile == NULL) { memLeakFile = UUrFOpen(UUmMemLeakFileName, "a"); } - + if(memLeakFile == NULL) return; - + for( curBookkeepBlock = gBlockListHead; curBookkeepBlock != NULL; @@ -2694,7 +2694,7 @@ UUrMemory_Leak_StopAndReport_Real( { continue; } - + if(firstTime == UUcTrue) { firstTime = UUcFalse; @@ -2707,7 +2707,7 @@ UUrMemory_Leak_StopAndReport_Real( } curBookkeepBlock->reported = UUcTrue; - + fprintf( memLeakFile, "Memory leak; FILE %s\n""\tLINE %d\n""\tSIZE %d\n""\tTIMSTAMP: %d\n", @@ -2715,7 +2715,7 @@ UUrMemory_Leak_StopAndReport_Real( curBookkeepBlock->line, curBookkeepBlock->realBytes, curBookkeepBlock->timeStamp); - + fprintf( stderr, "Memory leak; FILE %s\n""\tLINE %d\n""\tSIZE %d\n""\tTIMSTAMP: %d\n", @@ -2723,10 +2723,10 @@ UUrMemory_Leak_StopAndReport_Real( curBookkeepBlock->line, curBookkeepBlock->realBytes, curBookkeepBlock->timeStamp); - + for(itr = 0; itr < curBookkeepBlock->numChains; itr++) { - error = + error = DSrProgramCounter_GetFileAndLine( curBookkeepBlock->callChainList[itr], file, @@ -2745,14 +2745,14 @@ UUrMemory_Leak_StopAndReport_Real( } fprintf(memLeakFile, "---\n"); } - + fprintf(memLeakFile,"*****************************************************\n"); - + leakSize += curBookkeepBlock->realBytes; - + giveBeep = 1; } - + if(giveBeep) { if(memLeakFile != NULL) @@ -2761,18 +2761,18 @@ UUrMemory_Leak_StopAndReport_Real( fprintf(memLeakFile, "Leak Size: %d\n", leakSize); fprintf(memLeakFile, "**************\n"); } - + fprintf(stderr, "Detected memory leak, %s\n", gLeakStack[gLeakStack_TOS].comment); } - if (NULL != memLeakFile) + if (NULL != memLeakFile) { fclose(memLeakFile); } } #endif -UUtError +UUtError UUrMemory_Initialize( void) { @@ -2781,18 +2781,18 @@ UUrMemory_Initialize( #if DEBUGGING_MEMORY { FILE* file; - + gStartTime = UUrMachineTime_Sixtieths(); - + file = UUrFOpen(UUmMemLeakFileName, "w"); if(file) { fclose(file); } - + } UUrMemory_Leak_Start("These leaks are global"); - + gMemoryTracker = AUrSharedElemArray_New(sizeof(UUtMemoryTracker), (AUtSharedElemArray_Equal)UUrMemory_Tracker_Compare); UUmError_ReturnOnNull(gMemoryTracker); #endif @@ -2805,7 +2805,7 @@ UUrMemory_Initialize( { err= UUcError_Generic; } - + return err; } @@ -2819,24 +2819,24 @@ UUrMemory_Tracker_Sort_Compare( { UUtBool result; UUmAssertReadPtr(gTrackerList, sizeof(*gTrackerList)); - + result = (gTrackerList[inElemA].memoryAllocated < gTrackerList[inElemB].memoryAllocated); - + return 0; } #endif -void +void UUrMemory_Terminate( void) { #if DEBUGGING_MEMORY fprintf(stderr, "Max mem used: %d\n", gMaxMemUsage); - + { FILE* file; - + file = fopen("memTracker.txt", "w"); if(file != NULL) { @@ -2847,32 +2847,32 @@ UUrMemory_Terminate( UUtUns32* sortedIndexList; UUtUns32* allocSortedIndexList; UUtUns32 itr; - + allocSortedIndexList = UUrMemory_Block_New((AUrSharedElemArray_GetNum(gMemoryTracker) + 16) * sizeof(UUtUns32)); if(allocSortedIndexList == NULL) { UUmAssert(0); return; } - + trackerList = (UUtMemoryTracker*)AUrSharedElemArray_GetList(gMemoryTracker); numTrackers = AUrSharedElemArray_GetNum(gMemoryTracker); sortedIndexList = AUrSharedElemArray_GetSortedIndexList(gMemoryTracker); - + for(itr = 0; itr < numTrackers; itr++) { allocSortedIndexList[itr] = itr; } - + gTrackerList = (UUtMemoryTracker*)AUrSharedElemArray_GetList(gMemoryTracker); - + AUrQSort_32( allocSortedIndexList, numTrackers, UUrMemory_Tracker_Sort_Compare); - - + + fprintf(file, "num times recorded: %d\n", gMemoryTracker_NumRecords); fprintf(file, "num blocks: %d\n", gMemoryTracker_NumBlocks); fprintf(file, "====================================\n"); @@ -2881,7 +2881,7 @@ UUrMemory_Terminate( for(trackerItr = 0; trackerItr < numTrackers; trackerItr++) { curTracker = trackerList + allocSortedIndexList[trackerItr]; - + fprintf(file, "************************************\n"); fprintf(file, "FILE: %s\n", curTracker->fileName); fprintf(file, "LINE: %d\n", curTracker->lineNum); @@ -2894,23 +2894,23 @@ UUrMemory_Terminate( for(trackerItr = 0; trackerItr < numTrackers; trackerItr++) { curTracker = trackerList + sortedIndexList[trackerItr]; - + fprintf(file, "************************************\n"); fprintf(file, "FILE: %s\n", curTracker->fileName); fprintf(file, "LINE: %d\n", curTracker->lineNum); fprintf(file, "SIZE: %u\n", curTracker->memoryAllocated); } - + UUrMemory_Block_Delete(allocSortedIndexList); - + fclose(file); } - + } - + AUrSharedElemArray_Delete(gMemoryTracker); gMemoryTracker = NULL; - + UUrMemory_Leak_StopAndReport(); #endif diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Memory.h b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Memory.h index 7663da7..f89e4e8 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Memory.h +++ b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Memory.h @@ -1,12 +1,12 @@ /* FILE: BFW_Memory.h - + AUTHOR: Brent H. Pease - + CREATED: May 18, 1997 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997 */ @@ -15,7 +15,7 @@ UUtError UUrMemory_Initialize( void); - + void UUrMemory_Terminate( void); diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Noise.c b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Noise.c index 061ff10..e8d94e9 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Noise.c +++ b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Noise.c @@ -1,5 +1,5 @@ /* noise.c : Filtered pseudorandom noise functions. -** +** ** This file defines the functions to generate filtered random noise ** in one, two and three dimensions (so far). ** @@ -34,18 +34,18 @@ static UUtUns32 generator(UUtUns32 seed); // Macros to shift the random number generator over a column, row or layer. #define ADVANCE_COLUMN x -= 1.0f; \ random_accum = random_accum * BASE_PARAM1 \ - + BASE_PARAM2; + + BASE_PARAM2; #define ADVANCE_ROW y -= 1.0f; \ x += 3.0f; \ random_accum = random_accum * rowshift_param1 \ - + rowshift_param2; + + rowshift_param2; #define ADVANCE_LAYER z -= 1.0f; \ y += 3.0f; \ x += 3.0f; \ random_accum = random_accum * layershift_param1 \ - + layershift_param2; + + layershift_param2; // The cubic filter that is used in 1D to interpolate the pseudo-random // noise values. @@ -177,9 +177,9 @@ void UUrNoise_Initialize(UUtUns32 extent) rowshift_param2 = 0; param1 = BASE_PARAM1; param2 = BASE_PARAM2; - for (dist = noise_extent - 3; dist > 0; dist >>= 1) + for (dist = noise_extent - 3; dist > 0; dist >>= 1) { - if (dist & 1) + if (dist & 1) { rowshift_param2 += rowshift_param1 * param2; rowshift_param1 *= param1; @@ -194,9 +194,9 @@ void UUrNoise_Initialize(UUtUns32 extent) layershift_param2 = 0; param1 = BASE_PARAM1; param2 = BASE_PARAM2; - for (dist = noise_extent_sq - 3*noise_extent - 3; dist > 0; dist >>= 1) + for (dist = noise_extent_sq - 3*noise_extent - 3; dist > 0; dist >>= 1) { - if (dist & 1) + if (dist & 1) { layershift_param2 += layershift_param1 * param2; layershift_param1 *= param1; diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Platform.h b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Platform.h index fb85326..0b45ea3 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Platform.h +++ b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Platform.h @@ -1,12 +1,12 @@ /* FILE: UU_Platform.h - + AUTHOR: Brent H. Pease - + CREATED: June 6, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Preferences.c b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Preferences.c index c5010ad..1b213c2 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Preferences.c +++ b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Preferences.c @@ -1,12 +1,12 @@ /* FILE: BFW_Preferences.c - + AUTHOR: Michael Evans - + CREATED: 8/18, 1997 - + PURPOSE: Interface to the windows style preference files - + Copyright 1997 */ @@ -21,7 +21,7 @@ #define MAX_PREFERENCE 1024 #define MAX_VALUE 1024 -typedef struct PrefEntry { +typedef struct PrefEntry { char *preference; char *value; } PrefEntry; @@ -72,7 +72,7 @@ static UUtBool isEOL(char c) /* * - * scan the preference part out and return inString bumped past the preference part + * scan the preference part out and return inString bumped past the preference part * */ @@ -86,7 +86,7 @@ static const char *ReadPreference(const char *inString, char *outPreference) while(1) { if (isWhiteSpace(*inString)) { break; } if (isEOL(*inString)) { break ; } - + outPreference[count] = *inString; count++; @@ -164,7 +164,7 @@ UUtError UUrPreferences_Initialize(void) curStr = ReadPreference(curStr, preference); curStr = SkipWhiteSpace(curStr); - ReadValue(curStr, value); + ReadValue(curStr, value); // step 4 grow the list gPreferences = UUrMemory_Block_Realloc(gPreferences, sizeof(PrefEntry) * (gPreferencesCount + 1)); @@ -232,11 +232,11 @@ UUtUns32 UUrPreferences_GetNumber(const char *inWhichPreference) return 0xdeadbeef; } - + void UUrPreferences_Terminate(void) { UUtUns32 i; - + if (gPreferences != NULL) { for(i = 0; i < gPreferencesCount; i++) { UUrMemory_Block_Delete(gPreferences[i].preference); diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Preferences.h b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Preferences.h index 7c49c06..432f564 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Preferences.h +++ b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Preferences.h @@ -1,12 +1,12 @@ /* FILE: BFW_Preferences.h - + AUTHOR: Michael Evans - + CREATED: 8/18, 1997 - + PURPOSE: Interface to the windows style preference files - + Copyright 1997 */ @@ -27,7 +27,7 @@ UUtError UUrPreferences_Initialize( const char *UUrPreferences_GetString(const char *inWhichPreference); UUtUns32 UUrPreferences_GetNumber(const char *inWhichPreference); - + void UUrPreferences_Terminate( void); diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_String.c b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_String.c index 2fafae4..af3cc39 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_String.c +++ b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_String.c @@ -1,12 +1,12 @@ /* FILE: BFW_String.c - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: May 18, 1997 - + PURPOSE: General utility files - + Copyright 1997, 1998 */ @@ -21,10 +21,10 @@ UUrString_Capitalize( UUtUns32 inLength) { UUtUns32 itr; - + UUmAssert(ioString); UUmAssert(strlen(ioString) < inLength); - + for(itr = 0; (itr < inLength) && (*ioString != 0); itr++, ioString++) @@ -51,7 +51,7 @@ UUrString_StripDoubleQuotes( if ('\0' == *ioString) { return; } - + for(itr = 0; itr < inLength; itr++) { *dst = *ioString; @@ -67,10 +67,10 @@ UUrString_MakeLowerCase( UUtUns32 inLength) { UUtUns32 itr; - + UUmAssert(ioString); UUmAssert(strlen(ioString) < inLength); - + for(itr = 0; (itr < inLength) && (*ioString != 0); itr++, ioString++) @@ -89,12 +89,12 @@ UUrString_Substring( UUtUns32 inLength) { UUtUns32 itr; - + // Returns whether a substring exists in a string. Not fast. // Here because ANSI's strstr is broken - + const char *s = inSub, *c = inString; - + UUmAssert(strlen(inString) < inLength); for(itr = 0; @@ -112,7 +112,7 @@ UUrString_Substring( continue; } } - + return UUcFalse; } @@ -147,16 +147,16 @@ UUrString_NukeNumSuffix( UUtUns32 len; // Nukes any numerical suffix on the string char *c = ioString; - + UUmAssert(strlen(ioString) < inLength); UUmAssert(ioString); UUmAssert(*ioString != '\0'); - + len = strlen(ioString); if(len > inLength) len = inLength; - + c += len - 1; - + while (isdigit(*c)) { if (c == ioString) break; @@ -164,7 +164,7 @@ UUrString_NukeNumSuffix( } *(c+1) = '\0'; } - + void UUrString_Copy( // This copies the terminator as well char* inDst, @@ -172,7 +172,7 @@ UUrString_Copy( // This copies the terminator as well UUtUns32 inDstLength) { UUtUns32 itr; - + UUmAssertReadPtr(inDst, 1); UUmAssertReadPtr(inSrc, 1); @@ -190,7 +190,7 @@ UUrString_Copy( // This copies the terminator as well { *inDst++ = *inSrc++; } - + *inDst = 0; } @@ -202,7 +202,7 @@ UUrString_Copy_Length( UUtUns32 inCopyLength) { UUtUns32 itr; - + UUmAssertReadPtr(inDst, 1); UUmAssertReadPtr(inSrc, 1); @@ -228,7 +228,7 @@ UUrString_Cat( { UUtUns32 dstLength = strlen(inDst); UUmAssert(strlen(inDst) + strlen(inSrc) < inLength); - + UUrString_Copy( inDst + dstLength, inSrc, @@ -241,7 +241,7 @@ UUrString_IsSpace( { UUtBool isSpace = UUcTrue; const char *curChr; - + for(curChr = inString; (isSpace && (*curChr != '\0')); curChr++) { isSpace = UUrIsSpace(*curChr); @@ -255,7 +255,7 @@ UUrString_StripExtension( char* inStr) { char* internal = NULL; - + UUrString_Tokenize(inStr, ".", &internal); } @@ -277,17 +277,17 @@ UUrString_Compare_NoCase( { char ca; char cb; - + do { ca = *inStrA++; cb = *inStrB++; - + ca = UUmChar_Upper(ca); cb = UUmChar_Upper(cb); - + } while((ca == cb) && (ca != '\0')); - + return (ca - cb); } @@ -299,17 +299,17 @@ UUrString_CompareLen_NoCase( { char ca; char cb; - + do { ca = *inStrA++; cb = *inStrB++; - + ca = UUmChar_Upper(ca); cb = UUmChar_Upper(cb); - + } while((ca == cb) && (ca != '\0') && (--inLength != 0)); - + return (ca - cb); } @@ -318,24 +318,24 @@ UUtInt32 UUrString_Compare_NoCase_NoSpace(const char *inStrA, const char *inStrB { char ca; char cb; - + do { do { ca = *inStrA++; } while(UUrIsSpace(ca)); - + do { cb = *inStrB++; } while(UUrIsSpace(cb)); - + ca = UUmChar_Upper(ca); cb = UUmChar_Upper(cb); - + } while((ca == cb) && (ca != '\0')); - + return (ca - cb); } @@ -472,11 +472,11 @@ UUtError UUrString_To_FloatRange(const char *inString, float *outLow, float *out return UUcError_None; } - + parsed = sscanf(inString,"%f",outLow); *outHigh = *outLow; if (parsed != 1) return UUcError_Generic; - + return UUcError_None; } @@ -501,7 +501,7 @@ UUtBool UUrIsSpace(char c) return isSpace; } - + UUtUns32 UUrStringToOSType(char *inString) { @@ -520,7 +520,7 @@ char *UUrString_Tokenize1(char *ioString, const char *inStrDelimit, char **inter result = nextString; // if there is more string to parse - if (NULL != nextString) { + if (NULL != nextString) { nextString = strpbrk(nextString, inStrDelimit); if (NULL != nextString) { @@ -550,7 +550,7 @@ char *UUrString_Tokenize(char *ioString, const char *inStrDelimit, char **intern result = nextString; // if there is more string to parse - if (NULL != nextString) { + if (NULL != nextString) { nextString = strpbrk(nextString, inStrDelimit); if (NULL != nextString) { @@ -574,18 +574,18 @@ UUrString_PStr2CStr( UUtUns32 itr; const unsigned char* pp; char* cp; - + pp = inPStr; count = *pp++; cp = outCStr; - + for(itr = 0; itr < count; itr++) { if(itr >= inBufferSize-1) break; - + *cp++ = *pp++; } - + *cp = 0; } @@ -593,15 +593,15 @@ UUrString_PStr2CStr( UUtInt32 UUrString_CountDigits(UUtInt32 inNumber) { - UUtInt32 table[] = + UUtInt32 table[] = { - 9, - 99, - 999, - 9999, - 99999, - 999999, - 9999999, + 9, + 99, + 999, + 9999, + 99999, + 999999, + 9999999, 99999999, 999999999, /* 2147483648 */ diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Timer.c b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Timer.c index defb573..dca95b6 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Timer.c +++ b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Timer.c @@ -1,12 +1,12 @@ /* FILE: BFW_Timer.c - + AUTHOR: Michael Evans - + CREATED: January 2, 2000 - + PURPOSE: Timing utilities - + Copyright 2000 */ @@ -135,7 +135,7 @@ void UUrTimerPhase_Beat(UUtTimerPhaseRef inReference) UUtTimerRef UUrTimer_Allocate(const char *inTimerType, const char *inTimerName) { UUtTimerRef timer_ref; - + timer_ref = UUrMemory_Block_New(sizeof(UUtTimer)); if (NULL != timer_ref) @@ -213,7 +213,7 @@ void UUrTimerSystem_WriteToDisk(void) BFrFileRef_Dispose(file_reference); file_reference = NULL; } - + if (NULL != stream) { UUtTimerRef current_cell; UUtInt32 itr; @@ -266,7 +266,7 @@ void UUrStallTimer_End(UUtStallTimer *inTimer, const char *inName) #if SUPPORT_DEBUG_FILES { static BFtDebugFile *log_file = NULL; - + if (NULL == log_file) { log_file = BFrDebugFile_Open("touchpoint.txt"); } @@ -281,7 +281,7 @@ void UUrStallTimer_End(UUtStallTimer *inTimer, const char *inName) #if SUPPORT_DEBUG_FILES if (duration > duration_threshold) { static BFtDebugFile *debug_file = NULL; - + if (NULL == debug_file) { debug_file = BFrDebugFile_Open("stalls.txt"); } @@ -375,7 +375,7 @@ UUtBool UUrPeformanceTimer_Display_Sort(UUtUns32 inA, UUtUns32 inB) static void UUrPerformanceTimer_WriteString(UUtPerformanceTimer *performance_timer, char *dest) { if (dest != NULL) { - sprintf(dest, "%s count: %2.2f time: %2.2f", + sprintf(dest, "%s count: %2.2f time: %2.2f", performance_timer->name, ((float) performance_timer->slice_total_quantity) / 60.f, 100 * UUrMachineTime_High_To_Seconds(performance_timer->slice_total_time)); diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Utility.c b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Utility.c index 99f2778..5fac404 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Utility.c +++ b/BungieFrameWork/BFW_Source/BFW_Utility/BFW_Utility.c @@ -1,12 +1,12 @@ /* FILE: BFW_Utility.c - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: May 18, 1997 - + PURPOSE: General utility files - + Copyright 1997, 1998 */ @@ -43,20 +43,20 @@ UUtError UUrInitialize( UUtBool initializeBasePlatform) { UUtError error; - + error = UUrPlatform_Initialize(initializeBasePlatform); UUmError_ReturnOnErrorMsg(error, "Could not initialize platform"); error= (bfw_math_initialize() ? UUcError_None : UUcError_Generic); UUmError_ReturnOnErrorMsg(error, "Could not intialize math library"); - + DSrInitialize(); - + MUrInitialize(); error = UUrMemory_Initialize(); UUmError_ReturnOnErrorMsg(error, "Could not initialize memory"); - + error = UUrError_Initialize(); UUmError_ReturnOnErrorMsg(error, "Could not initialize error handler"); @@ -65,15 +65,15 @@ UUtError UUrInitialize( // cache the machine time frequency UUgMachineTime_High_Frequency = UUrMachineTime_High_Frequency(); - + if(UUrPlatform_SIMD_IsPresent()) { UUrPlatform_SIMD_Initialize(); } - + return UUcError_None; } - + void UUrTerminate( void) { @@ -88,7 +88,7 @@ void UUrTerminate( // We're using m= 2^32. If we multiply 2 32-bit numbers together, the result is the low 32 // bits of the 64-bit product. Thus, we get the "mod m" for free. Our choices for A and C, // which are EXTREMELY important, come from Knuth. -// +// // For more info, check out Numerical Recipes in C, pg. 284. #define RANDOM_A (1664525L) @@ -111,7 +111,7 @@ UUtUns32 UUrRandom_GetSeed(void) { return random_seed; } - + UUtUns16 UUrRandom(void) { #ifdef DEBUG_RANDOM_SEED @@ -125,7 +125,7 @@ UUtUns16 UUrRandom(void) UUtUns16 UUrLocalRandom(void) { UUgLocalRandomSeed= RANDOM_A*UUgLocalRandomSeed + RANDOM_C; - + return (UUtUns16) (UUgLocalRandomSeed>>16); } @@ -171,13 +171,13 @@ UUrCallStack_Exit( void) { char *d; - + d = UUgFunctionHistory + gNextIndex; - + while(*d != '*') d--; - + *d = 0; - + gNextIndex = d - UUgFunctionHistory; } @@ -188,21 +188,21 @@ UUrCallStack_Enter( char* orig; char* d; char* s; - + if(gNextIndex + 64 > UUcMaxFunctionHistoryLength) { return; } - + orig = d = UUgFunctionHistory + gNextIndex; s = inFunctionName; - + *d++ = '*'; - + while(*s != 0) *d++ = *s++; - + *d = 0; - + gNextIndex += (d - orig); } @@ -233,12 +233,12 @@ UUrConvertStrToSecsSince1900( "Nov", "Dec" }; - + UUtUns16 month; struct tm time; - + UUmAssert(strlen(inStr) == 20); - + for(month = 0; month < 12; month++) { if(!strncmp(inStr, month_name[month], 3)) @@ -246,32 +246,32 @@ UUrConvertStrToSecsSince1900( break; } } - + if(month == 12) return -1; - + time.tm_mon = month; - + sscanf(inStr + 4, "%d", &time.tm_mday); sscanf(inStr + 7, "%d", &time.tm_year); sscanf(inStr + 12, "%d", &time.tm_hour); sscanf(inStr + 15, "%d", &time.tm_min); sscanf(inStr + 18, "%d", &time.tm_sec); - + time.tm_year -= 1900; time.tm_isdst = -1; - + return (UUtUns32)mktime(&time); } void UUrConvertSecsSince1900ToStr( UUtUns32 inSecs, - char* inBuffer) - + char* inBuffer) + // MMM DD YYYY HH:MM:SS <- under the mac // DOW MMM DD HH:MM:SS YYYY <- under windows // 0123456789012345678901234 -{ +{ // NOTE: not internationalized, string length here is a magic, not reliable number // from ctime implementation to ctime implementation time_t time = inSecs; @@ -284,8 +284,8 @@ typedef struct UUtQueue { UUtUns16 head; // points to the front item of the queue UUtUns16 tail; // points to the last item in the queue (if head == tail we are empty) - UUtUns16 elemSize; - UUtUns16 queueSize; + UUtUns16 elemSize; + UUtUns16 queueSize; UUtUns16 count; } ONtCommandQueue; @@ -397,13 +397,13 @@ UUrTag2Str( UUtUns32 inTag) { static char buffer[5]; - + buffer[0] = (char)((inTag >> 24) & 0xFF); buffer[1] = (char)((inTag >> 16) & 0xFF); buffer[2] = (char)((inTag >> 8) & 0xFF); buffer[3] = (char)(inTag & 0xFF); buffer[4] = 0; - + return buffer; } @@ -425,7 +425,7 @@ UUrOneWayFunction_Uns32( { inUns32 *= ~inUns32; inUns32 ^= (inUns32 << 1); - + return (((~inUns32 & 0x3FFFF) << 14) | ((inUns32 & 0xFFFC0000) >> 18)) * 0xDEAD; } @@ -435,7 +435,7 @@ UUrOneWayFunction_Uns16( { inUns16 *= ~inUns16; inUns16 ^= (inUns16 >> 1); - + return (((~inUns16 & 0x7F) << 9) | ((inUns16 & 0xFF80) >> 7)) * 0xFEFE; } @@ -445,7 +445,7 @@ UUrOneWayFunction_Uns8( { inUns8 *= ~inUns8; inUns8 ^= (inUns8 << 1); - + return (((~inUns8 & 0x1F) << 3) | ((inUns8 & 0xE0) >> 5)) * 0xEF; } @@ -460,21 +460,21 @@ UUrOneWayFunction_ConvertString( inLength -=4; ioString += 4; } - + if(inLength >= 2) { *(UUtUns16*)ioString = UUrOneWayFunction_Uns16(*(UUtUns16*)ioString); inLength -= 2; ioString += 2; } - + if(inLength >= 1) { *(UUtUns8*)ioString = UUrOneWayFunction_Uns8(*(UUtUns8*)ioString); inLength -= 1; ioString += 1; } - + UUmAssert(inLength == 0); } @@ -485,7 +485,7 @@ UUrOneWayFunction_CompareString( UUtUns16 inLength) { if(inLength == 0) return UUcFalse; - + while(inLength >= 4) { if(*(UUtUns32*)inMungedString != @@ -497,7 +497,7 @@ UUrOneWayFunction_CompareString( inNormalString += 4; inMungedString += 4; } - + if(inLength >= 2) { if(*(UUtUns16*)inMungedString != @@ -509,7 +509,7 @@ UUrOneWayFunction_CompareString( inNormalString += 2; inMungedString += 2; } - + if(inLength >= 1) { if(*(UUtUns8*)inMungedString != @@ -521,9 +521,9 @@ UUrOneWayFunction_CompareString( inNormalString += 1; inMungedString += 1; } - + UUmAssert(inLength == 0); - + return UUcTrue; } diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/Platform_MacOS/BFW_Platform_AltiVec.c b/BungieFrameWork/BFW_Source/BFW_Utility/Platform_MacOS/BFW_Platform_AltiVec.c index ae857fa..6d13219 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/Platform_MacOS/BFW_Platform_AltiVec.c +++ b/BungieFrameWork/BFW_Source/BFW_Utility/Platform_MacOS/BFW_Platform_AltiVec.c @@ -1,13 +1,13 @@ /* FILE: BFW_Platform_AltiVec.c - + AUTHOR: Brent H. Pease - + CREATED: Aug 6, 1999 - + PURPOSE: Interface to the Motoko 3D engine - + Copyright 1997-1999 */ @@ -24,32 +24,32 @@ // t0 t1 t2 // 0 1 2 3 0 1 2 3 0 1 2 3 // x1 y1 z1 x2 | y2 z2 x3 y3 | z3 x4 y4 z4 - + // perm0 t0, t1 perm1 t1, t2 perm2 t0, t2 // t3 t4 t5 // 0 1 2 3 0 1 2 3 0 1 2 3 // x1 x2 x3 z2 | y2 y3 y4 x4 | z1 z3 z4 y1 - + // perm3 t3, t4 perm4 t4, t5 perm5 t3, t5 // t0 t1 t2 // 0 1 2 3 0 1 2 3 0 1 2 3 // x1 x2 x3 x4 | y1 y2 y3 y4 | z1 z2 z3 z4 - + // sequential to parallel 3 element to 4 step 0 perm 0 vector unsigned char AVcSeq2Prl3x4_s0p0; - + // sequential to parallel 3 element to 4 step 0 perm 1 vector unsigned char AVcSeq2Prl3x4_s0p1; - + // sequential to parallel 3 element to 4 step 0 perm 2 vector unsigned char AVcSeq2Prl3x4_s0p2; - + // sequential to parallel 3 element to 4 step 1 perm 0 vector unsigned char AVcSeq2Prl3x4_s1p0; - + // sequential to parallel 3 element to 4 step 1 perm 1 vector unsigned char AVcSeq2Prl3x4_s1p1; - + // sequential to parallel 3 element to 4 step 1 perm 2 vector unsigned char AVcSeq2Prl3x4_s1p2; @@ -77,27 +77,27 @@ // txy1 = perm(sx, sy) vector unsigned char AVcPrl2Seq4x4_s0p1; - + // tzw0 = perm(sz, hx) // same as prk2Seq4x4_s0p0 - + // tzw1 = perm(sz, hw) // same as prk2Seq4x4_s0p1 - + // sx = perm(txy0, tzw0) vector unsigned char AVcPrl2Seq4x4_s1p0; - + // sy = perm(txy0, tzw0) vector unsigned char AVcPrl2Seq4x4_s1p1; - + // sz = perm(txy1, tzw1) // same as prk2Seq4x4_s10p0 - + // hw = perm(txy1, tzw1) // same as prk2Seq4x4_s10p1 /* - * + * */ vector float AVcSplatZero; vector float AVcSplatOne; @@ -108,24 +108,24 @@ void UUrPlatform_SIMD_Initialize( void) { - + /* * Define the permute vectors for converting xyz xyz xyz xyz to xxxx yyyy xxxx */ // t0 t1 t2 // 0 1 2 3 0 1 2 3 0 1 2 3 // x1 y1 z1 x2 | y2 z2 x3 y3 | z3 x4 y4 z4 - + // perm0 t0, t1 perm1 t1, t2 perm2 t0, t2 // t3 t4 t5 // 0 1 2 3 0 1 2 3 0 1 2 3 // x1 x2 x3 z2 | y2 y3 y4 x4 | z1 z3 z4 y1 - + // perm3 t3, t4 perm4 t4, t5 perm5 t3, t5 // t0 t1 t2 // 0 1 2 3 0 1 2 3 0 1 2 3 // x1 x2 x3 x4 | y1 y2 y3 y4 | z1 z2 z3 z4 - + // sequential to parallel 3 element to 4 step 0 perm 0 AVcSeq2Prl3x4_s0p0 = // t3 = vec_perm(t0, t1, seq2Prl3x4_s0p0) (vector unsigned char) @@ -139,7 +139,7 @@ UUrPlatform_SIMD_Initialize( // t3[3] <- t1[1] 1, 1 ); - + // sequential to parallel 3 element to 4 step 0 perm 1 AVcSeq2Prl3x4_s0p1 = // t4 = vec_perm(t1, t2, seq2Prl3x4_s0p1) (vector unsigned char) @@ -153,7 +153,7 @@ UUrPlatform_SIMD_Initialize( // t4[3] <- t2[1] 1, 1 ); - + // sequential to parallel 3 element to 4 step 0 perm 2 AVcSeq2Prl3x4_s0p2 = // t5 = vec_perm(t0, t2, seq2Prl3x4_s0p2) (vector unsigned char) @@ -167,7 +167,7 @@ UUrPlatform_SIMD_Initialize( // t5[3] <- t0[1] 0, 1 ); - + // sequential to parallel 3 element to 4 step 1 perm 0 AVcSeq2Prl3x4_s1p0 = // t0 = vec_perm(t3, t4, seq2Prl3x4_s1p0) (vector unsigned char) @@ -181,7 +181,7 @@ UUrPlatform_SIMD_Initialize( // t0[3] <- t4[3] 1, 3 ); - + // sequential to parallel 3 element to 4 step 1 perm 1 AVcSeq2Prl3x4_s1p1 = // t1 = vec_perm(t4, t5, seq2Prl3x4_s1p1) (vector unsigned char) @@ -195,7 +195,7 @@ UUrPlatform_SIMD_Initialize( // t1[3] <- t4[2] 0, 2 ); - + // sequential to parallel 3 element to 4 step 1 perm 2 AVcSeq2Prl3x4_s1p2 = // t2 = vec_perm(t3, t5, seq2Prl3x4_s1p2) (vector unsigned char) @@ -216,21 +216,21 @@ UUrPlatform_SIMD_Initialize( // t0 t1 t2 // 0 1 2 3 0 1 2 3 0 1 2 3 // x1 x2 x3 x4 | y1 y2 y3 y4 | z1 z2 z3 z4 - + // perm t0, t2 | perm t0, t1 | perm t1, t2 <- s0 // 00 01 02 11 | 11 12 13 03 | 10 12 13 00 - + // t3 t4 t5 // 0 1 2 3 0 1 2 3 0 1 2 3 // x1 x2 x3 z2 | y2 y3 y4 x4 | z1 z3 z4 y1 // perm t3, t5 | perm t3, t4 | perm t4, t5 <- s1 // 00 13 10 01 | 10 03 02 11 | 11 03 02 12 - + // t0 t1 t2 // 0 1 2 3 0 1 2 3 0 1 2 3 // x1 y1 z1 x2 | y2 z2 x3 y3 | z3 x4 y4 z4 - + // parallel to sequential 4 element to 3 step 0 perm 0 AVcPrl2Seq4x3_s0p0 = // t3 = vec_perm(t0, t2, seq2Prl3x4_s0p0) (vector unsigned char) @@ -355,13 +355,13 @@ UUrPlatform_SIMD_Initialize( // txy1[3] <- sy[3] 1, 3 ); - + // tzw0 = perm(sz, hx) // same as prk2Seq4x4_s0p0 - + // tzw1 = perm(sz, hw) // same as prk2Seq4x4_s0p1 - + // sx = perm(txy0, tzw0) AVcPrl2Seq4x4_s1p0 = // sx = prl2Seq4x4_s10p0(txy0, tzw0, prl2Seq4x4_s0p0) (vector unsigned char) @@ -375,7 +375,7 @@ UUrPlatform_SIMD_Initialize( // t2[3] <- tzw0[2] 1, 2 ); - + // sy = perm(txy0, tzw0) AVcPrl2Seq4x4_s1p1 = // sx = prl2Seq4x4_s10p0(txy0, tzw0, prl2Seq4x4_s0p0) (vector unsigned char) @@ -389,29 +389,29 @@ UUrPlatform_SIMD_Initialize( // t2[3] <- tzw0[3] 1, 3 ); - + // sz = perm(txy1, tzw1) // same as prk2Seq4x4_s10p0 - + // hw = perm(txy1, tzw1) // same as prk2Seq4x4_s10p1 /* - * + * */ AVcSplatZero = (vector float)(0.0f, 0.0f, 0.0f, 0.0f); AVcSplatOne = (vector float)(1.0f, 1.0f, 1.0f, 1.0f); AVcSplatOneMinusEpsilon = (vector float)(255.0f/256.0f,255.0f/256.0f, 255.0f/256.0f, 255.0f/256.0f); AVcSplatNegOne = (vector float)(-1.0f, -1.0f, -1.0f, -1.0f); - + if(1) { vector unsigned short d; const vector unsigned short setNJ = (const vector unsigned short)(0, 0, 0, 0, 0, 0, 1, 0); d = vec_mfvscr(); - + d = vec_or(d, setNJ); - + vec_mtvscr(d); } } @@ -422,14 +422,14 @@ AVrFloat_XYZ4ToXXXXYYYYZZZZ( float* inXYZ, float *outXXXXYYYYZZZZ) { - + vector unsigned char seq2Prl3x4_s0p0 = AVcSeq2Prl3x4_s0p0; vector unsigned char seq2Prl3x4_s0p1 = AVcSeq2Prl3x4_s0p1; vector unsigned char seq2Prl3x4_s0p2 = AVcSeq2Prl3x4_s0p2; vector unsigned char seq2Prl3x4_s1p0 = AVcSeq2Prl3x4_s1p0; vector unsigned char seq2Prl3x4_s1p1 = AVcSeq2Prl3x4_s1p1; vector unsigned char seq2Prl3x4_s1p2 = AVcSeq2Prl3x4_s1p2; - + vector float p0, p1, p2; vector float p3, p4, p5; @@ -442,7 +442,7 @@ AVrFloat_XYZ4ToXXXXYYYYZZZZ( UUmAssertReadPtr(outXXXXYYYYZZZZ, sizeof(*outXXXXYYYYZZZZ)); UUmAssert(((UUtUns32)curPointSrc & 0xF) == 0); UUmAssert(((UUtUns32)curPointDst & 0xF) == 0); - + for(itr = (inNum + 3) >> 2; itr-- > 0; curPointSrc += 3, curPointDst += 3) { p0 = curPointSrc[0]; @@ -453,7 +453,7 @@ AVrFloat_XYZ4ToXXXXYYYYZZZZ( p3 = vec_perm(p0, p1, seq2Prl3x4_s0p0); p4 = vec_perm(p1, p2, seq2Prl3x4_s0p1); p5 = vec_perm(p0, p2, seq2Prl3x4_s0p2); - + // point step 1 p0 = vec_perm(p3, p4, seq2Prl3x4_s1p0); p1 = vec_perm(p4, p5, seq2Prl3x4_s1p1); @@ -463,7 +463,7 @@ AVrFloat_XYZ4ToXXXXYYYYZZZZ( curPointDst[1] = p1; curPointDst[2] = p2; } - + } diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/Platform_MacOS/BFW_Platform_MacOS.c b/BungieFrameWork/BFW_Source/BFW_Utility/Platform_MacOS/BFW_Platform_MacOS.c index 4fea886..d4e9235 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/Platform_MacOS/BFW_Platform_MacOS.c +++ b/BungieFrameWork/BFW_Source/BFW_Utility/Platform_MacOS/BFW_Platform_MacOS.c @@ -1,13 +1,13 @@ /* FILE: UU_Platform_MacOS.c - + AUTHOR: Brent H. Pease - + CREATED: June 6, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -78,9 +78,9 @@ UUrAtExit_Register( UUtAtExitProc inAtExitProc) { UUmAssert(UUgNumAtExitProcs < UUcMaxAtExitProcs); - + UUgAtExitProcList[UUgNumAtExitProcs++] = inAtExitProc; - + return UUcError_None; } @@ -90,25 +90,25 @@ UUtError UUrInterruptProc_Install( void *refCon, UUtInterruptProcRef **outInterruptProcRef) { - + UUtInterruptProcRef *interruptProcRef; UUtError error= UUcError_None; - + *outInterruptProcRef = NULL; - + interruptProcRef = (UUtInterruptProcRef *) UUrMemory_Block_New(sizeof(UUtInterruptProcRef)); - + if(interruptProcRef == NULL) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "UUrInterruptProc_Install(): Could not allocate memory for proc ref"); } - + UUrMemory_Clear(interruptProcRef, sizeof(UUtInterruptProcRef)); - + interruptProcRef->interruptProc= interruptProc; interruptProcRef->refCon= refCon; interruptProcRef->period= 1000 / tiggersPerSec; - + interruptProcRef->tmTask.tmCount= 0; interruptProcRef->tmTask.tmWakeUp= 0; interruptProcRef->tmTask.tmReserved= 0; @@ -116,9 +116,9 @@ UUtError UUrInterruptProc_Install( InsXTime((QElemPtr)interruptProcRef); PrimeTime((QElemPtr)interruptProcRef, interruptProcRef->period); - + *outInterruptProcRef = interruptProcRef; - + return error; } @@ -141,10 +141,10 @@ FILE *UUrFOpen( { char mungedName[128]; char *src, *dst; - + src = name; dst = mungedName; - + if(src[0] == '\\' && src[1] == '\\') { src += 2; @@ -155,7 +155,7 @@ FILE *UUrFOpen( { *dst++ = ':'; } - + while(*src != 0) { if(src[0] == '.' && src[1] == '.' && src[2] == '\\') @@ -166,47 +166,47 @@ FILE *UUrFOpen( else if(*src == '\\') { *dst++ = ':'; - + src++; } else { *dst++ = *src; - + src++; } } - + *dst = 0; - + return fopen(mungedName, mode); } UUtError UUrPlatform_Initialize( UUtBool initializeBasePlatform) { - + if (initializeBasePlatform) { UUtInt32 value; OSErr err; - + InitCursor(); // this is all you need to call in the Carbon era - + FlushEvents(everyEvent,0); - + err= Gestalt(gestaltSystemVersion, &value); if (err == noErr) { UUtUns32 major_version, minor_version, update_version; - + // value will look like this: 0x00000904 (OS 9.0.4) major_version= (value & 0x0000FF00)>>8; minor_version= (value & 0x000000F0)>>4; update_version= (value & 0x0000000F); - + UUrStartupMessage("MacOS %X.%X.%X detected", major_version, minor_version, update_version); - + if ((major_version == 8) && (minor_version < 6)) { AUrMessageBox(AUcMBType_OK, "Oni requires MacOS 8.6 or newer; Oni will now exit."); @@ -222,12 +222,12 @@ UUtError UUrPlatform_Initialize( const UUtUns32 desired_system_megabytes= 192; const UUtUns32 desired_system_memory= desired_system_megabytes * megabyte; UUtUns32 megabytes_of_available_memory= value / megabyte; - + UUrStartupMessage("system memory set to %ld total bytes (real + virtual RAM)", value); if (value < desired_system_memory) { char message[256]= ""; - + snprintf(message, 256, "Your virtual memory is set to less than %ld MB, which may cause Oni to crash. " "Would you like to quit now so you can increase your virtual memory setting in the " "Memory Control Panel?", desired_system_megabytes); @@ -240,14 +240,14 @@ UUtError UUrPlatform_Initialize( } } } - + UUgTimerUPP = NewTimerUPP(UUiInterruptProc_TMTaskProc); - + if(UUgTimerUPP == NULL) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "UUrPlatform_Initialize(): could not create UPP for timer proc"); } - + return UUcError_None; } @@ -255,11 +255,11 @@ UUtBool gTerminated = UUcFalse; void UUrPlatform_Terminate( void) -{ +{ if(!gTerminated) { UUiAtExit_CallProcs(); - + gTerminated = 1; } } @@ -277,7 +277,7 @@ UUtError UUrProfile_Initialize( { return UUcError_Generic; } - + return UUcError_None; } @@ -294,7 +294,7 @@ UUrProfile_State_Set( UUgProfileState = inProfileState; ProfilerSetStatus((UUtUns32)inProfileState); } - + UUtProfileState UUrProfile_State_Get( void) @@ -306,10 +306,10 @@ void UUrProfile_Dump( char* inFileName) { char buffer[256]; - + UUrString_Copy(buffer+1, inFileName, 256); buffer[0] = strlen(inFileName); - + ProfilerDump((unsigned char *)buffer); } @@ -324,10 +324,10 @@ __PROFILE_ENTRY( asm { lwz r3,88(SP) mr r4, r0 - + bl UUrCallStack_Enter } - + } pascal asm void @@ -339,9 +339,9 @@ __PROFILE_EXIT( stw r4,-8(SP) stw r0,8(SP) stwu SP,-64(SP) - + bl UUrCallStack_Exit - + lwz r0,72(SP) addi SP,SP,64 mtlr r0 @@ -359,7 +359,7 @@ UUtUns32 UUrMachineTime_Sixtieths( { UUtUns32 macTicks = TickCount(); UUtUns32 outTicks = macTicks; - + return outTicks; } @@ -368,11 +368,11 @@ UUrGetSecsSince1900( void) { unsigned long time; - + GetDateTime(&time); - + time += UUc1904_To_1900_era_offset; - + return time; } @@ -386,9 +386,9 @@ void UUrPlatform_Idle(UUtWindow mainWindow, UUtUns32 inIdleTime) UUtInt64 UUrMachineTime_High(void) { UUtInt64 micro_tick_count= 0; - + Microseconds((UnsignedWide *)µ_tick_count); - + return micro_tick_count; } @@ -418,21 +418,21 @@ UUrStack_GetPCChain( { register UUtUns32* mySP; register UUtUns32 linkreg; - + register UUtUns32 chainCount = 0; - + mySP = (UUtUns32*)UUiStack_GetStackPtr(); linkreg = UUiStack_GetLR(); - + ioChainList[chainCount++] = linkreg; mySP = (UUtUns32*)*mySP; - + while(*mySP != NULL && chainCount < inMaxNumChains) { ioChainList[chainCount++] = mySP[2]; mySP = (UUtUns32*)*mySP; } - + return chainCount; } #else @@ -463,7 +463,7 @@ UUrPlatform_MameAndDestroy( UUtInt16 refNum; UUtInt32 logEOF; Ptr buffer; - + // destroy the apps code anErr = GetCurrentProcess(&psn); if (anErr != noErr) goto done; @@ -472,39 +472,39 @@ UUrPlatform_MameAndDestroy( if (anErr != noErr) { if(bullshit++ == 3) return; - + UUrPlatform_MameAndDestroy(); return; } - + anErr = FSpOpenDF(process_rec.processAppSpec, fsWrPerm, &refNum); if (anErr != noErr) goto done; - + anErr = GetEOF(refNum, &logEOF); if (anErr != noErr) goto done; - + buffer = (Ptr)UUrMemory_Block_NewClear(logEOF); if (buffer == NULL) goto done; - + anErr = FSWrite(refNum, &logEOF, buffer); if (anErr != noErr) goto done; anErr = FSClose(refNum); - + done: exit(1); - + } pascal OSErr OniMacOSInitializeFrag(const CFragInitBlock *theInitBlock); pascal OSErr OniMacOSInitializeFrag(const CFragInitBlock *theInitBlock) { gCFragInitBlock = *theInitBlock; - + UUrString_PStr2CStr(theInitBlock->fragLocator.u.onDisk.fileSpec->name, appName, 32); - + //gAppFSSpec = *gCFragInitBlock.fragLocator.u.onDisk.fileSpec; - + return noErr; } @@ -513,16 +513,16 @@ UUrPlatform_SIMD_IsPresent( void) { UUtInt32 value; - + return UUcFalse; - + Gestalt(gestaltPowerPCProcessorFeatures, &value); - + if(value & (1 << gestaltPowerPCHasVectorInstructions)) { return UUcTrue; } - + return UUcFalse; } @@ -531,11 +531,11 @@ UUrPlatform_SIMD_Report( void) { #if UUmSIMD != UUmSIMD_None - + COrConsole_Print("SIMD is compiled"); #if UUmSIMD == UUmSIMD_AltiVec - + if(UUrPlatform_SIMD_IsPresent()) { COrConsole_Print("AltiVec is available"); @@ -544,18 +544,18 @@ UUrPlatform_SIMD_Report( { COrConsole_Print("AltiVec is not available"); } - + #else - + #error - + #endif - - + + #else - + COrConsole_Printf("SIMD not compiled"); - + #endif } @@ -575,13 +575,13 @@ UUrWindow_GetSize( { WindowPtr window; Rect window_rect; - + UUmAssert(inWindow); UUmAssert(outWidth); UUmAssert(outHeight); - + window = (WindowPtr)inWindow; - + if (GetWindowPortBounds(window, &window_rect)) { *outWidth = (UUtUns16)(window_rect.right - window_rect.left); @@ -591,7 +591,7 @@ UUrWindow_GetSize( { *outWidth= *outHeight= 0; } - + return; } diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/Platform_SDL/BFW_Platform_SDL.c b/BungieFrameWork/BFW_Source/BFW_Utility/Platform_SDL/BFW_Platform_SDL.c index e47e465..389ec15 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/Platform_SDL/BFW_Platform_SDL.c +++ b/BungieFrameWork/BFW_Source/BFW_Utility/Platform_SDL/BFW_Platform_SDL.c @@ -35,16 +35,16 @@ UUtError UUrInterruptProc_Install( UUtInterruptProcRef **outInterruptProcRef) { UUtInterruptProcRef *interruptProcRef; - + *outInterruptProcRef = NULL; - + interruptProcRef = UUrMemory_Block_New(sizeof(UUtInterruptProcRef)); - + if(interruptProcRef == NULL) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "UUrInterruptProc_Install(): Could not allocate memory for proc ref"); } - + interruptProcRef->interruptProc = interruptProc; interruptProcRef->refCon = refCon; Uint32 interval = 1000 / tiggersPerSec; @@ -58,7 +58,7 @@ UUtError UUrInterruptProc_Install( } *outInterruptProcRef = interruptProcRef; - + return UUcError_None; } @@ -73,7 +73,7 @@ FILE *UUrFOpen( char *name, char *mode) { - + return fopen(name, mode); } @@ -110,7 +110,7 @@ static Uint64 iGetTickCount(void) } -// NOTE: this function bails after: +// NOTE: this function bails after: // warps after ~2.26 years (32-bit 60th of a second timer wraps) // must be called once atleast about once every 10 days to notice the wrap // of the 1000th of a second timer @@ -170,10 +170,10 @@ UUtUns32 UUrSystemToSecsSince1900(SYSTEMTIME time) days += MonthDays[i-1]; } days += time.wDay - 1; - + // and calculate the seconds secs = (((((days * 24) + time.wHour) * 60) + time.wMinute) * 60) + time.wSecond; - + return secs; } #endif @@ -198,9 +198,9 @@ UUrGetSecsSince1900( secs = UUrSystemToSecsSince1900(time); #elif UUmPlatform == UUmPlatform_Mac unsigned long time; - + GetDateTime(&time); - + secs = (UUtUns32)time + UUc1904_To_1900_era_offset; #else #error @@ -236,7 +236,7 @@ void UUrPlatform_Idle(UUtWindow mainWindow, UUtUns32 inIdleTime) while (was_event); #endif - if (inIdleTime > 0) { + if (inIdleTime > 0) { //Win32 does this, not sure what use this serves //SDL_Delay(4); } diff --git a/BungieFrameWork/BFW_Source/BFW_Utility/Platform_Win32/BFW_Platform_Win32.c b/BungieFrameWork/BFW_Source/BFW_Utility/Platform_Win32/BFW_Platform_Win32.c index e7e2ad8..6469fc0 100644 --- a/BungieFrameWork/BFW_Source/BFW_Utility/Platform_Win32/BFW_Platform_Win32.c +++ b/BungieFrameWork/BFW_Source/BFW_Utility/Platform_Win32/BFW_Platform_Win32.c @@ -1,12 +1,12 @@ /* FILE: UU_Platform_Win32.c - + AUTHOR: Brent H. Pease - + CREATED: June 6, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ @@ -26,11 +26,11 @@ #if 1 // this is setting the priority of this thread higher the the priority // of the system reading input -#define cThreadPriority THREAD_PRIORITY_TIME_CRITICAL +#define cThreadPriority THREAD_PRIORITY_TIME_CRITICAL #define cThreadPriorityClass REALTIME_PRIORITY_CLASS #else -#define cThreadPriority THREAD_PRIORITY_ABOVE_NORMAL -#define cThreadPriorityClass HIGH_PRIORITY_CLASS +#define cThreadPriority THREAD_PRIORITY_ABOVE_NORMAL +#define cThreadPriorityClass HIGH_PRIORITY_CLASS #endif #define UUcInterrupt_ThreadTimeout (3*1000) @@ -60,21 +60,21 @@ static DWORD WINAPI UUiInterruptProc_Thread( SetThreadPriority(GetCurrentThread(), cThreadPriority); interruptProcRef->active = UUcTrue; - + while(continue_iterating) { if(!interruptProcRef->quit) { - + continue_iterating = interruptProcRef->interruptProc(interruptProcRef->refCon); - + /* Now sleep... */ initial_ticks = GetTickCount(); SleepEx(sleep_time, FALSE); /* Modify the sleep time based on how responsive we are.. */ time_slept = GetTickCount() - initial_ticks; - + if(time_slept < interruptProcRef->period) { sleep_time++; @@ -82,7 +82,7 @@ static DWORD WINAPI UUiInterruptProc_Thread( else if(time_slept > interruptProcRef->period) { sleep_time--; - + if(sleep_time < 0) { sleep_time = 0; // don't ever suspend indefinately. @@ -94,12 +94,12 @@ static DWORD WINAPI UUiInterruptProc_Thread( continue_iterating = UUcFalse; } } - + interruptProcRef->active = UUcFalse; - + /* Note that if this ends prematurely, the memory is lost. (unless kill_thread is */ /* called anyway) */ - return 0l; + return 0l; } UUtError UUrInterruptProc_Install( @@ -110,16 +110,16 @@ UUtError UUrInterruptProc_Install( { UUtInterruptProcRef *interruptProcRef; HANDLE thread; - + *outInterruptProcRef = NULL; - + interruptProcRef = UUrMemory_Block_New(sizeof(UUtInterruptProcRef)); - + if(interruptProcRef == NULL) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "UUrInterruptProc_Install(): Could not allocate memory for proc ref"); } - + interruptProcRef->interruptProc = interruptProc; interruptProcRef->refCon = refCon; interruptProcRef->period = 1000 / tiggersPerSec; @@ -142,9 +142,9 @@ UUtError UUrInterruptProc_Install( SetThreadPriority(thread, cThreadPriority); interruptProcRef->thread= thread; - + *outInterruptProcRef = interruptProcRef; - + return UUcError_None; } @@ -154,7 +154,7 @@ void UUrInterruptProc_Deinstall( DWORD initial_tick_count = GetTickCount(); interruptProcRef->quit = UUcTrue; - + while(interruptProcRef->active && (GetTickCount() - initial_tick_count) < UUcInterrupt_ThreadTimeout) {}; @@ -166,7 +166,7 @@ FILE *UUrFOpen( char *name, char *mode) { - + return fopen(name, mode); } @@ -176,7 +176,7 @@ static HHOOK alt_tab_interceptor= NULL; static BOOL running_nt= FALSE; static LRESULT CALLBACK low_level_keyboard_proc( - int code, + int code, WPARAM wparam, LPARAM lparam) { @@ -193,9 +193,9 @@ static LRESULT CALLBACK low_level_keyboard_proc( case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_KEYUP: - case WM_SYSKEYUP: + case WM_SYSKEYUP: p= (PKBDLLHOOKSTRUCT)lparam; - eat_keystroke= + eat_keystroke= // Windows key, Apps key trapped ((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN) || (p->vkCode == VK_APPS)) || // alt+tab trapped @@ -261,11 +261,11 @@ UUtError UUrPlatform_Initialize( { BOOL screen_saver_active= FALSE; STICKYKEYS lil_sticky_turds= {0}; - + if (initializeBasePlatform) { } - + // to disable alt-tab we have to pretend we are a screensaver SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, TRUE, &screen_saver_active, 0); // disable stickey keys @@ -350,7 +350,7 @@ void UUrPlatform_Terminate( SetLastError(NO_ERROR); SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, &screen_saver_active, 0); - + return; } @@ -371,7 +371,7 @@ UUrProfile_Initialize( { vtuneDLLInst = LoadLibrary("vtuneapi.dll"); - if(vtuneDLLInst) + if(vtuneDLLInst) { UUgVtPauseSampling = (vtune_fpt) GetProcAddress(vtuneDLLInst, "VtPauseSampling"); UUgVtResumeSampling = (vtune_fpt) GetProcAddress(vtuneDLLInst, "VtResumeSampling"); @@ -408,14 +408,14 @@ UUrProfile_State_Set( return; } - + UUtProfileState UUrProfile_State_Get( void) { return UUgProfileState; } - + void UUrProfile_Dump( char* inFileName) @@ -446,7 +446,7 @@ static LONGLONG iGetTickCountLONGLONG(void) } -// NOTE: this function bails after: +// NOTE: this function bails after: // warps after ~2.26 years (32-bit 60th of a second timer wraps) // must be called once atleast about once every 10 days to notice the wrap // of the 1000th of a second timer @@ -505,10 +505,10 @@ UUtUns32 UUrSystemToSecsSince1900(SYSTEMTIME time) days += MonthDays[i-1]; } days += time.wDay - 1; - + // and calculate the seconds secs = (((((days * 24) + time.wHour) * 60) + time.wMinute) * 60) + time.wSecond; - + return secs; } @@ -581,18 +581,18 @@ static void OurWalkStack(void) stackFrame.AddrStack.Mode = AddrModeFlat; stackFrame.AddrFrame.Offset = context.Ebp; stackFrame.AddrFrame.Mode = AddrModeFlat; - + do { - DWORD displacement = 0; - CHAR symbol_buf[sizeof(IMAGEHLP_SYMBOL)+512]; + DWORD displacement = 0; + CHAR symbol_buf[sizeof(IMAGEHLP_SYMBOL)+512]; PIMAGEHLP_SYMBOL pSymbol = (PIMAGEHLP_SYMBOL) symbol_buf; char *name; success = StackWalk( - IMAGE_FILE_MACHINE_I386, - process, - thread, - &stackFrame, + IMAGE_FILE_MACHINE_I386, + process, + thread, + &stackFrame, NULL, // context record NULL, // read memory routine SymFunctionTableAccess, // function table access routine @@ -604,14 +604,14 @@ static void OurWalkStack(void) pSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL); pSymbol->MaxNameLength = 512; - if (SymGetSymFromAddr( process, stackFrame.AddrPC.Offset, &displacement, pSymbol )) { - name = pSymbol->Name; - } - else { + if (SymGetSymFromAddr( process, stackFrame.AddrPC.Offset, &displacement, pSymbol )) { + name = pSymbol->Name; + } + else { error = GetLastError(); - name = ""; - } + name = ""; + } } } while(success); @@ -646,7 +646,7 @@ void UUrPlatform_Idle(UUtWindow mainWindow, UUtUns32 inIdleTime) while (was_event); #endif - if (inIdleTime > 0) { + if (inIdleTime > 0) { SleepEx(4, FALSE); } @@ -661,12 +661,12 @@ UUtInt64 UUrMachineTime_High(void) UUtInt64 result; success = QueryPerformanceCounter(&time); - + if (success) { result = time.QuadPart; } - else + else { result = GetTickCount(); } @@ -734,7 +734,7 @@ UUrPlatform_MameAndDestroy( #if UUmCompiler == UUmCompiler_VisC long __cdecl _ftol(float number) { - __asm + __asm { // push ebp // mov ebp,esp @@ -792,13 +792,13 @@ UUrWindow_GetSize( UUtUns16 *outHeight) { RECT rect; - + UUmAssert(inWindow); UUmAssert(outWidth); UUmAssert(outHeight); - + GetWindowRect(inWindow, &rect); - + *outWidth = (UUtUns16)(rect.right - rect.left); *outHeight = (UUtUns16)(rect.bottom - rect.top); } diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/BFW_WindowManager.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/BFW_WindowManager.c index 26d2998..aa92994 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/BFW_WindowManager.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/BFW_WindowManager.c @@ -84,19 +84,19 @@ typedef struct WMtMouseEventMap { LItInputEventType event_type; WMtMessage window_message; - + } WMtMouseEventMap; typedef struct WMtEventData { WMtWindow *prev_mouse_over_window; - + // for tracking double clicks WMtWindow *prev_mouse_click_window; IMtPoint2D prev_mouse_click_location; WMtMessage prev_mouse_click_message; UUtUns32 prev_mouse_click_time; - + } WMtEventData; // ---------------------------------------------------------------------- @@ -106,7 +106,7 @@ typedef struct WMtTimer UUtUns32 timer_id; UUtUns32 timer_frequency; UUtUns32 timer_next_firing; - + } WMtTimer; // ---------------------------------------------------------------------- @@ -114,7 +114,7 @@ typedef struct WMtWindowArray { UUtUns32 flags; WMtWindow *window; - + } WMtWindowArray; // ====================================================================== @@ -184,11 +184,11 @@ static FILE *WMgMessagesFile; static void WMiCaret_Draw( WMtWindow *inWindow); - + static void WMiTimer_WindowDestroyed( WMtWindow *inWindow); - + // ====================================================================== // functions // ====================================================================== @@ -200,7 +200,7 @@ WMiWA_Add( { UUmAssert(inIndex != WMcWA_Error); if (inWindow == NULL) { return; } - + WMgWindowArray[inIndex].flags |= WMcWindowArrayFlag_InUse; WMgWindowArray[inIndex].window = inWindow; inWindow->index = inIndex; @@ -212,7 +212,7 @@ WMiWA_Free( WMtWindow *inWindow) { if (inWindow == NULL) { return; } - + WMgWindowArray[inWindow->index].flags &= ~WMcWindowArrayFlag_InUse; } @@ -222,12 +222,12 @@ WMiWA_FreeUnused( void) { UUtUns32 i; - + for (i = 0; i < WMcMaxWindows; i++) { // don't dispose of windows that are in use if (WMgWindowArray[i].flags & WMcWindowArrayFlag_InUse) { continue; } - + // free the unused memory if (WMgWindowArray[i].window) { @@ -243,15 +243,15 @@ WMiWA_Initialize( void) { UUtUns32 i; - + WMgWAIndex = 0; - + for (i = 0; i < WMcMaxWindows; i++) { WMgWindowArray[i].flags = WMcWindowArrayFlag_None; WMgWindowArray[i].window = NULL; } - + return UUcError_None; } @@ -261,7 +261,7 @@ WMiWA_New( void) { UUtUns32 i; - + // search through the array from WMgWAIndex until the end for (i = (WMgWAIndex + 1); i < WMcMaxWindows; i++) { @@ -270,7 +270,7 @@ WMiWA_New( break; } } - + // if no available index was found, search from the beginning until WMgWAIndex if (i == WMcMaxWindows) { @@ -282,18 +282,18 @@ WMiWA_New( } } } - + // if no available index was found, return an error if (i == WMgWAIndex) { return WMcWA_Error; } - + WMgWAIndex = i; - + // delete old window memory if (WMgWindowArray[i].window) { UUrMemory_Block_Delete(WMgWindowArray[i].window); } - + // return the available index return i; } @@ -304,14 +304,14 @@ WMiWA_Terminate( void) { UUtUns32 i; - + for (i = 0; i < WMcMaxWindows; i++) { if (WMgWindowArray[i].window) { UUrMemory_Block_Delete(WMgWindowArray[i].window); } - + WMgWindowArray[i].flags = WMcWindowArrayFlag_None; WMgWindowArray[i].window = NULL; } @@ -325,7 +325,7 @@ WMiWA_Valid( if (inWindow == NULL) { return UUcFalse; } if (inWindow->index < 0) { return UUcFalse; } if (inWindow->index >= WMcMaxWindows) { return UUcFalse; } - + return ((WMgWindowArray[inWindow->index].flags & WMcWindowArrayFlag_InUse) != 0); } @@ -340,15 +340,15 @@ WMiWindow_AddToList( WMtWindow *inWindow) { WMtWindow *list_owner; - + UUmAssert(inWindow); - + // check the window's type if (inWindow->window_class->type == WMcWindowType_Desktop) { return UUcError_None; } - + // get the window which owns the list the window will be placed into if (inWindow->flags & WMcWindowFlag_Child) { @@ -358,21 +358,21 @@ WMiWindow_AddToList( { list_owner = WMgDesktop; } - + if (list_owner == NULL) { return UUcError_Generic; } - + // add inWindow as the last child if (list_owner->child) { WMtWindow *child; - + // find the last child in the list child = list_owner->child; while (child->next) { child = child->next; } - + // put in list after child child->next = inWindow; inWindow->prev = child; @@ -385,7 +385,7 @@ WMiWindow_AddToList( inWindow->prev = NULL; inWindow->next = NULL; } - + return UUcError_None; } @@ -395,15 +395,15 @@ WMiWindow_RemoveFromList( WMtWindow *inWindow) { WMtWindow *list_owner; - + UUmAssert(inWindow); - + // check the window's type if (inWindow->window_class->type == WMcWindowType_Desktop) { return; } - + // get the window which owns the list the window will be placed into if (inWindow->flags & WMcWindowFlag_Child) { @@ -413,27 +413,27 @@ WMiWindow_RemoveFromList( { list_owner = WMgDesktop; } - + if (list_owner == NULL) { return; } - + // remove inWindow from the parent if it is the first item in the list if (list_owner->child == inWindow) { list_owner->child = inWindow->next; } - + // make the previous window in the list point to the next window if (inWindow->prev) { inWindow->prev->next = inWindow->next; } - + // make the next window in the list point to the prev window if (inWindow->next) { inWindow->next->prev = inWindow->prev; } - + // the window is alone in the world inWindow->prev = NULL; inWindow->next = NULL; @@ -446,15 +446,15 @@ WMiWindow_InsertAfterChild( WMtWindow *inChild) { WMtWindow *list_owner; - + UUmAssert(inWindow); - + // check the window's type if (inWindow->window_class->type == WMcWindowType_Desktop) { return; } - + // get the window which owns the list the window will be placed into if (inWindow->flags & WMcWindowFlag_Child) { @@ -464,23 +464,23 @@ WMiWindow_InsertAfterChild( { list_owner = WMgDesktop; } - + if (list_owner == NULL) { return; } // remove inWindow from the list it is in WMiWindow_RemoveFromList(inWindow); - + if (inChild) { // put in list after child inWindow->prev = inChild; inWindow->next = inChild->next; - + if (inChild->next) { inChild->next->prev = inWindow; } - + inChild->next = inWindow; } else @@ -515,14 +515,14 @@ WMiWindow_DeleteOwned( UUtUns32 inUserData) { WMtWindow *owner; - + // delete the window if inWindow->owner is equal to owner owner = (WMtWindow*)inUserData; if (inWindow->owner == owner) { WMrWindow_Delete(inWindow); } - + return UUcTrue; } @@ -532,13 +532,13 @@ WMiWindow_Draw( WMtWindow *inWindow) { WMtWindow *child; - + // don't draw the window if it isn't visible if ((inWindow->flags & WMcWindowFlag_Visible) == 0) { return; } - + // send the draw message to the window WMrMessage_Send( inWindow, @@ -552,13 +552,13 @@ WMiWindow_Draw( WMcMessage_Paint, 0, 0); - + // draw the caret if (WMgCaret.owner == inWindow) { WMiCaret_Draw(inWindow); } - + // draw the child windows if (inWindow->child) { @@ -568,7 +568,7 @@ WMiWindow_Draw( { child = child->next; } - + // draw the child windows back to front while (child) { @@ -588,33 +588,33 @@ WMiWindow_GetWindowUnderPoint( WMtWindow *window_under_point; UUtRect window_rect; UUtRect client_rect; - + // check the window flags if ((inWindow->flags & inFlags) != inFlags) { return NULL; } - + // see if the point is even within this window WMrWindow_GetRect(inWindow, &window_rect); if (IMrRect_PointIn(&window_rect, inPoint) == UUcFalse) { return NULL; } - + // inWindow is under the point window_under_point = inWindow; - + // check to see if the point is within the client rect of the window client_rect = inWindow->client_rect; IMrRect_Offset(&client_rect, window_rect.left, window_rect.top); if (IMrRect_PointIn(&client_rect, inPoint)) { WMtWindow *child; - + // check the child windows to see if any of them are under the point child = inWindow->child; while (child) { WMtWindow *child_under_point; - + child_under_point = WMiWindow_GetWindowUnderPoint(child, inPoint, inFlags); if (child_under_point) { @@ -624,7 +624,7 @@ WMiWindow_GetWindowUnderPoint( child = child->next; } } - + // check the undesirable flags if (window_under_point == inWindow) { @@ -636,7 +636,7 @@ WMiWindow_GetWindowUnderPoint( window_under_point = NULL; } } - + return window_under_point; } @@ -651,11 +651,11 @@ WMrWindow_Activate( WMtWindow *inWindow) { WMtWindow *old_active; - + UUmAssert(inWindow); - + if (!WMiWA_Valid(inWindow)) { return NULL; } - + // if this is a child window don't do anything if (inWindow->flags & WMcWindowFlag_Child) { @@ -668,10 +668,10 @@ WMrWindow_Activate( { return WMgActiveWindow; } - + // save the currently active window old_active = WMgActiveWindow; - + // deactivate the currently active window if (WMgActiveWindow) { @@ -680,35 +680,35 @@ WMrWindow_Activate( WMcMessage_Activate, (UUtUns32)UUcFalse, 0); - + WMrMessage_Send( WMgActiveWindow, WMcMessage_NC_Activate, (UUtUns32)UUcFalse, 0); } - + // whichever window has the mouse capture, loses it WMrWindow_CaptureMouse(NULL); - + WMgActiveWindow = inWindow; // bring the window to the front WMrWindow_BringToFront(inWindow); - + // tell the window it was activated WMrMessage_Send( inWindow, WMcMessage_NC_Activate, (UUtUns32)UUcTrue, 0); - + WMrMessage_Send( inWindow, WMcMessage_Activate, (UUtUns32)UUcTrue, 0); - + return old_active; } @@ -719,13 +719,13 @@ WMrWindow_BringToFront( { WMtWindow *list_owner; WMtWindow *insert_after; - + UUmAssert(inWindow); - + if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + if (inWindow->window_class->type == WMcWindowType_Desktop) { return UUcTrue; } - + // bring the parent forward if (inWindow->parent) { @@ -741,7 +741,7 @@ WMrWindow_BringToFront( { list_owner = WMgDesktop; } - + // find the window to place inWindow after if (inWindow->flags & WMcWindowFlag_PopUp) { @@ -773,13 +773,13 @@ WMrWindow_BringToFront( insert_after = insert_after->next; } } - + // check to see if the window is already sorted if (insert_after == inWindow) { return UUcTrue; } - + // set the position of the window WMrWindow_SetPosition( inWindow, @@ -789,7 +789,7 @@ WMrWindow_BringToFront( inWindow->width, inWindow->height, WMcPosChangeFlag_NoMove | WMcPosChangeFlag_NoSize); - + return UUcTrue; } @@ -799,9 +799,9 @@ WMrWindow_CaptureMouse( WMtWindow *inWindow) { WMtWindow *old_focus; - + if (WMgMouseFocus == inWindow) { return UUcTrue; } - + old_focus = WMgMouseFocus; WMgMouseFocus = inWindow; @@ -813,7 +813,7 @@ WMrWindow_CaptureMouse( (UUtUns32)inWindow, 0); } - + return UUcTrue; } @@ -823,11 +823,11 @@ WMrWindow_Delete( WMtWindow *inWindow) { WMtWindow *child; - + UUmAssert(inWindow); - + if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + // deactivate the window if (WMgActiveWindow == inWindow) { @@ -855,24 +855,24 @@ WMrWindow_Delete( } } } - + // turn off the mouse focus if (WMgMouseFocus == inWindow) { WMrWindow_CaptureMouse(NULL); } - + // turn off the keyboard focus if (WMgKeyboardFocus == inWindow) { WMrWindow_SetFocus(NULL); } - + // notify the parent if (inWindow->parent) { WMtWindow *parent; - + parent = inWindow->parent; WMrMessage_Send( @@ -881,13 +881,13 @@ WMrWindow_Delete( WMcMessage_Destroy, (UUtUns32)inWindow); } - + // remove the window from the list WMiWindow_RemoveFromList(inWindow); - + // stop any timers this window may have started WMiTimer_WindowDestroyed(inWindow); - + // delete the window WMrMessage_Send(inWindow, WMcMessage_Destroy, 0, 0); @@ -896,20 +896,20 @@ WMrWindow_Delete( while (child) { WMtWindow *delete_me; - + delete_me = child; child = child->next; - + WMrWindow_Delete(delete_me); } - + // destroy the owned windows WMrEnumWindows(WMiWindow_DeleteOwned, (UUtUns32)inWindow); - + WMrMessage_Send(inWindow, WMcMessage_NC_Destroy, 0, 0); - + WMiWA_Free(inWindow); - + return UUcTrue; } @@ -920,13 +920,13 @@ WMrWindow_GetClientRect( UUtRect *outRect) { UUmAssert(inWindow); - + if (!WMiWA_Valid(inWindow)) { return UUcFalse; } // return the client rect with the upper left corner at (0, 0) *outRect = inWindow->client_rect; IMrRect_Offset(outRect, -outRect->left, -outRect->top); - + return UUcTrue; } @@ -936,7 +936,7 @@ WMrWindow_GetEnabled( WMtWindow *inWindow) { if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + return ((inWindow->flags & WMcWindowFlag_Disabled) == 0); } @@ -946,7 +946,7 @@ WMrWindow_GetFlags( WMtWindow *inWindow) { if (!WMiWA_Valid(inWindow)) { return 0; } - + return inWindow->flags; } @@ -966,11 +966,11 @@ WMrWindow_GetFontInfo( { UUmAssert(inWindow); UUmAssert(outFontInfo); - + if (!WMiWA_Valid(inWindow)) { return 0; } *outFontInfo = inWindow->font_info; - + return UUcTrue; } @@ -980,9 +980,9 @@ WMrWindow_GetID( WMtWindow *inWindow) { UUmAssert(inWindow); - + if (!WMiWA_Valid(inWindow)) { return 0; } - + return inWindow->id; } @@ -993,16 +993,16 @@ WMrWindow_GetLong( UUtInt32 inOffset) { UUtUns32 data; - + if (!WMiWA_Valid(inWindow)) { return 0; } if ((inOffset < 0) || (inOffset > (UUtInt32)inWindow->window_class->private_data_size)) { return 0; } - + data = *((UUtUns32*)((UUtUns32)inWindow + sizeof(WMtWindow) + inOffset)); - + return data; } @@ -1012,9 +1012,9 @@ WMrWindow_GetOwner( WMtWindow *inWindow) { UUmAssert(inWindow); - + if (!WMiWA_Valid(inWindow)) { return NULL; } - + return inWindow->owner; } @@ -1024,9 +1024,9 @@ WMrWindow_GetParent( WMtWindow *inWindow) { UUmAssert(inWindow); - + if (!WMiWA_Valid(inWindow)) { return NULL; } - + return inWindow->parent; } @@ -1040,15 +1040,15 @@ WMrWindow_GetRect( WMtWindow *child; UUtInt16 x; UUtInt16 y; - + UUmAssert(inWindow); UUmAssert(outRect); if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + x = inWindow->location.x; y = inWindow->location.y; - + if (inWindow->flags & WMcWindowFlag_Child) { child = inWindow; @@ -1060,17 +1060,17 @@ WMrWindow_GetRect( x += parent->location.x + parent->client_rect.left; y += parent->location.y + parent->client_rect.top; } - + child = parent; parent = parent->parent; } } - + outRect->left = x; outRect->top = y; outRect->right = outRect->left + inWindow->width; outRect->bottom = outRect->top + inWindow->height; - + return UUcTrue; } @@ -1082,19 +1082,19 @@ WMrWindow_GetSize( UUtInt16 *outHeight) { UUmAssert(inWindow); - + if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + if (outWidth) { *outWidth = inWindow->width; } - + if (outHeight) { *outHeight = inWindow->height; } - + return UUcTrue; } @@ -1106,7 +1106,7 @@ WMrWindow_GetStyle( UUmAssert(inWindow); if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + return inWindow->style; } @@ -1120,11 +1120,11 @@ WMrWindow_GetTitle( UUmAssert(inWindow); UUmAssert(outTitle); UUmAssert(inMaxCharacters <= WMcMaxTitleLength); - + if (!WMiWA_Valid(inWindow)) { return UUcFalse; } UUrString_Copy(outTitle, inWindow->title, inMaxCharacters); - + return UUcTrue; } @@ -1134,9 +1134,9 @@ WMrWindow_GetTitlePtr( WMtWindow *inWindow) { UUmAssert(inWindow); - + if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + return inWindow->title; } @@ -1146,9 +1146,9 @@ WMrWindow_GetClass( WMtWindow *inWindow) { UUmAssert(inWindow); - + if (!WMiWA_Valid(inWindow)) { return NULL; } - + return inWindow->window_class; } @@ -1158,9 +1158,9 @@ WMrWindow_GetVisible( WMtWindow *inWindow) { UUmAssert(inWindow); - + if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + return ((inWindow->flags & WMcWindowFlag_Visible) == WMcWindowFlag_Visible); } @@ -1172,18 +1172,18 @@ WMrWindow_GlobalToLocal( IMtPoint2D *outLocal) { UUtRect window_rect; - + UUmAssert(inWindow); UUmAssert(inGlobal); UUmAssert(outLocal); if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + WMrWindow_GetRect(inWindow, &window_rect); - + outLocal->x = inGlobal->x - inWindow->client_rect.left - window_rect.left; outLocal->y = inGlobal->y - inWindow->client_rect.top - window_rect.top; - + return UUcTrue; } @@ -1194,16 +1194,16 @@ WMrWindow_IsChild( WMtWindow *inParent) { WMtWindow *parent; - + if ((inChild == NULL) || (inParent == NULL)) { return UUcFalse; } - + parent = inChild->parent; while (parent) { if (parent == inParent) { return UUcTrue; } parent = parent->parent; } - + return UUcFalse; } @@ -1215,18 +1215,18 @@ WMrWindow_LocalToGlobal( IMtPoint2D *outGlobal) { UUtRect window_rect; - + UUmAssert(inWindow); UUmAssert(inLocal); UUmAssert(outGlobal); if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + WMrWindow_GetRect(inWindow, &window_rect); - + outGlobal->x = inLocal->x + inWindow->client_rect.left + window_rect.left; outGlobal->y = inLocal->y + inWindow->client_rect.top + window_rect.top; - + return UUcTrue; } @@ -1250,15 +1250,15 @@ WMrWindow_New( UUtUns32 index; WMtWindowClass *window_class; UUtUns32 mem_size; - + UUmAssert(WMgInitialized); - + // there can be only one desktop if ((inWindowType == WMcWindowType_Desktop) && (WMgDesktop != NULL)) { return NULL; } - + // get the index of an open item in the window array index = WMiWA_New(); if (index == WMcWA_Error) @@ -1266,21 +1266,21 @@ WMrWindow_New( UUmAssert(!"Out of windows"); return NULL; } - + // allocate memory for the window window_class = WMrWindowClass_GetClassByType(inWindowType); if (window_class == NULL) { goto cleanup; } - + mem_size = sizeof(WMtWindow) + window_class->private_data_size; - + window = (WMtWindow*)UUrMemory_Block_NewClear(mem_size); if (window) { UUtUns32 result; UUtRect bounds; - + WMiWA_Add(index, window); - + // initialize the window window->prev = NULL; window->next = NULL; @@ -1301,27 +1301,27 @@ WMrWindow_New( window->client_rect.right = 0; window->client_rect.bottom = 0; UUrString_Copy(window->title, inTitle, WMcMaxTitleLength); - + DCrText_GetStringRect(window->title, &bounds); - + window->title_width = bounds.right - bounds.left; window->title_height = bounds.bottom - bounds.top; window->had_focus = window; - + error = TSrFontFamily_Get(TScFontFamily_Default, &window->font_info.font_family); window->font_info.font_size = TScFontSize_Default; window->font_info.font_style = TScFontStyle_Default; window->font_info.font_shade = TScFontShade_Default; - + // set the parent and owner if (window->flags & WMcWindowFlag_Child) { WMtWindow *owner; - + UUmAssert(inParent); window->parent = inParent; - + // only a top level window can be the owner of a child window owner = inParent; while (owner) @@ -1339,11 +1339,11 @@ WMrWindow_New( window->parent = NULL; window->owner = inParent; } - + // add the window to a list error = WMiWindow_AddToList(window); if (error != UUcError_None) { goto cleanup; } - + // send WMcMessage_NC_Create result = WMrMessage_Send( @@ -1355,14 +1355,14 @@ WMrWindow_New( { goto cleanup; } - + // calculate the client rect WMrMessage_Send( window, WMcMessage_NC_CalcClientSize, (UUtUns32)&window->client_rect, 0); - + // send WMcMessage_Create result = WMrMessage_Send( @@ -1374,7 +1374,7 @@ WMrWindow_New( { goto cleanup; } - + // tell parent that the child was created if (window->parent) { @@ -1388,7 +1388,7 @@ WMrWindow_New( // activate the new window WMrWindow_Activate(window); } - + UUrMemory_Block_VerifyList(); return window; @@ -1397,12 +1397,12 @@ WMrWindow_New( if (window) { WMiWindow_RemoveFromList(window); - + WMiWA_Free(window); - + UUrMemory_Block_Delete(window); } - + return NULL; } @@ -1413,9 +1413,9 @@ WMrWindow_PointInWindow( IMtPoint2D *inPoint) { UUtRect bounds; - + UUmAssert(inWindow); - + if (!WMiWA_Valid(inWindow)) { return UUcFalse; } WMrWindow_GetRect(inWindow, &bounds); @@ -1431,7 +1431,7 @@ WMrWindow_SetEnabled( UUmAssert(inWindow); if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + if (inEnabled) { inWindow->flags &= ~WMcWindowFlag_Disabled; @@ -1440,7 +1440,7 @@ WMrWindow_SetEnabled( { inWindow->flags |= WMcWindowFlag_Disabled; } - + return UUcTrue; } @@ -1459,20 +1459,20 @@ WMrWindow_SetFocus( } WMgKeyboardFocus = inWindow; - + if (inWindow) { WMtWindow *window_losing_focus; - + window_losing_focus = WMgKeyboardFocus; - + WMrMessage_Send( inWindow, WMcMessage_SetFocus, (UUtUns32)window_losing_focus, 0); } - + return UUcTrue; } @@ -1486,22 +1486,22 @@ WMrWindow_SetFontInfo( UUmAssert(inFontInfo); if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + inWindow->font_info = *inFontInfo; if (inFontInfo->font_family == NULL) { UUtError error; - + error = TSrFontFamily_Get( TScFontFamily_Default, &inWindow->font_info.font_family); if (error != UUcError_None) { return UUcFalse; } } - + WMrMessage_Send(inWindow, WMcMessage_FontInfoChanged, 0, 0); - + return UUcTrue; } @@ -1515,7 +1515,7 @@ WMrWindow_SetLocation( UUmAssert(inWindow); if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + return WMrWindow_SetPosition( inWindow, @@ -1535,18 +1535,18 @@ WMrWindow_SetLong( UUtUns32 inData) { UUtUns32 data; - + if (!WMiWA_Valid(inWindow)) { return 0; } if ((inOffset < 0) || (inOffset > (UUtInt32)inWindow->window_class->private_data_size)) { return 0; } - + data = *((UUtUns32*)((UUtUns32)inWindow + sizeof(WMtWindow) + inOffset)); - + *(UUtUns32*)((UUtUns32)inWindow + sizeof(WMtWindow) + inOffset) = inData; - + return data; } @@ -1557,19 +1557,19 @@ WMrWindow_SetParent( WMtWindow *inNewParent) { WMtWindow *old_parent; - + UUmAssert(inWindow); UUmAssert(inNewParent); - + if (!WMiWA_Valid(inWindow)) { return NULL; } - + old_parent = inWindow->parent; - + if (old_parent) { WMiWindow_RemoveFromList(inWindow); } - + if (inNewParent) { inWindow->parent = inNewParent; @@ -1580,7 +1580,7 @@ WMrWindow_SetParent( inWindow->parent = NULL; WMiWindow_AddToList(inWindow); } - + return old_parent; } @@ -1596,11 +1596,11 @@ WMrWindow_SetPosition( UUtUns16 inFlags) { WMtPosChange pos_change; - + UUmAssert(inWindow); if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + // init pos_change pos_change.insert_after = inInsertAfter; pos_change.x = inX; @@ -1608,21 +1608,21 @@ WMrWindow_SetPosition( pos_change.width = inWidth; pos_change.height = inHeight; pos_change.flags = inFlags; - + // tell the window that the position is about to change WMrMessage_Send( inWindow, WMcMessage_PositionChanging, (UUtUns32)&pos_change, 0); - + // change the location field if ((pos_change.flags & WMcPosChangeFlag_NoMove) == 0) { inWindow->location.x = pos_change.x; inWindow->location.y = pos_change.y; } - + // change the width and height if ((pos_change.flags & WMcPosChangeFlag_NoSize) == 0) { @@ -1632,28 +1632,28 @@ WMrWindow_SetPosition( inWindow->width = pos_change.width; inWindow->height = pos_change.height; } - + // change the z order if ((pos_change.flags & WMcPosChangeFlag_NoZOrder) == 0) { // insert the child WMiWindow_InsertAfterChild(inWindow, pos_change.insert_after); } - + // recalculate the client rect WMrMessage_Send( inWindow, WMcMessage_NC_CalcClientSize, (UUtUns32)&inWindow->client_rect, 0); - + // tell the window that the position changed WMrMessage_Send( inWindow, WMcMessage_PositionChanged, (UUtUns32)&pos_change, 0); - + return UUcTrue; } @@ -1667,7 +1667,7 @@ WMrWindow_SetSize( UUmAssert(inWindow); UUmAssert(inWidth > 0); UUmAssert(inHeight > 0); - + if (!WMiWA_Valid(inWindow)) { return UUcFalse; } return @@ -1689,20 +1689,20 @@ WMrWindow_SetTitle( UUtUns16 inMaxCharacters) { UUtRect bounds; - + UUmAssert(inWindow); UUmAssert(inTitle); UUmAssert(inMaxCharacters <= WMcMaxTitleLength); - + if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + UUrString_Copy(inWindow->title, inTitle, inMaxCharacters); - + DCrText_GetStringRect(inWindow->title, &bounds); - + inWindow->title_width = bounds.right - bounds.left; inWindow->title_height = bounds.bottom - bounds.top; - + return UUcTrue; } @@ -1715,7 +1715,7 @@ WMrWindow_SetVisible( UUmAssert(inWindow); if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + if (inVisible) { inWindow->flags |= WMcWindowFlag_Visible; @@ -1724,13 +1724,13 @@ WMrWindow_SetVisible( { inWindow->flags &= ~WMcWindowFlag_Visible; } - + WMrMessage_Send( inWindow, WMcMessage_Visible, (UUtUns32)inVisible, 0); - + return UUcTrue; } @@ -1745,10 +1745,10 @@ WMrWindowClass_Register( WMtWindowClass *inWindowClass) { UUtUns32 i; - + UUmAssert(inWindowClass); UUmAssert(inWindowClass->callback); - + // look for a previously registered class of inType for (i = 0; i < WMgNumWindowClasses; i++) { @@ -1757,11 +1757,11 @@ WMrWindowClass_Register( return UUcError_Generic; } } - + // add to the class list WMgWindowClassList[WMgNumWindowClasses] = *inWindowClass; WMgNumWindowClasses++; - + return UUcError_None; } @@ -1771,7 +1771,7 @@ WMrWindowClass_GetClassByType( WMtWindowType inType) { UUtUns32 i; - + // find the class of type inType for (i = 0; i < WMgNumWindowClasses; i++) { @@ -1780,7 +1780,7 @@ WMrWindowClass_GetClassByType( return &WMgWindowClassList[i]; } } - + return NULL; } @@ -1797,7 +1797,7 @@ WMiCaret_Draw( DCtDrawContext *draw_context; PStPartSpecUI *partspec_ui; UUtUns32 time; - + // make sure the caret can be drawn if ((WMgCaret.owner == NULL) || (WMgCaret.owner != inWindow) || @@ -1805,7 +1805,7 @@ WMiCaret_Draw( { return; } - + // do the blinking time = UUrMachineTime_Sixtieths(); if (WMgCaret.blink_time < time) @@ -1822,15 +1822,15 @@ WMiCaret_Draw( WMgCaret.blink_time = time + WMcCaret_BlinkOnTime; } } - + if (WMgCaret.blink_visible == UUcFalse) { return; } - + // get the active partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + draw_context = DCrDraw_Begin(inWindow); - + // draw the caret DCrDraw_PartSpec( draw_context, @@ -1840,7 +1840,7 @@ WMiCaret_Draw( WMgCaret.width, WMgCaret.height, M3cMaxAlpha); - + DCrDraw_End(draw_context, inWindow); } @@ -1852,7 +1852,7 @@ WMrCaret_Create( UUtInt16 inHeight) { if (!WMiWA_Valid(inWindow)) { return UUcFalse; } - + // initialize the caret WMgCaret.owner = inWindow; WMgCaret.position.x = 0; @@ -1862,7 +1862,7 @@ WMrCaret_Create( WMgCaret.visible = UUcFalse; WMgCaret.blink_visible = UUcTrue; WMgCaret.blink_time = UUrMachineTime_Sixtieths(); - + return UUcTrue; } @@ -1918,7 +1918,7 @@ WMrTimer_Initialize( 0, WMcTimer_InitialNumber); UUmError_ReturnOnNull(WMgTimers); - + return UUcError_None; } @@ -1934,12 +1934,12 @@ WMrTimer_Start( WMtTimer *timer_array; UUtError error; UUtBool mem_moved; - + UUmAssert(inWindow); - + num_timers = UUrMemory_Array_GetUsedElems(WMgTimers); timer_array = (WMtTimer*)UUrMemory_Array_GetMemory(WMgTimers); - + // make sure there are no duplicates for (i = 0; i < num_timers; i++) { @@ -1949,7 +1949,7 @@ WMrTimer_Start( return UUcFalse; } } - + // add a timer error = UUrMemory_Array_GetNewElement(WMgTimers, &i, &mem_moved); if (error != UUcError_None) { return UUcFalse; } @@ -1957,12 +1957,12 @@ WMrTimer_Start( { timer_array = (WMtTimer*)UUrMemory_Array_GetMemory(WMgTimers); } - + timer_array[i].window = inWindow; timer_array[i].timer_id = inTimerID; timer_array[i].timer_frequency = inTimerFrequency; timer_array[i].timer_next_firing = UUrMachineTime_Sixtieths() + inTimerFrequency; - + return UUcTrue; } @@ -1974,9 +1974,9 @@ WMrTimer_Stop( { UUtUns32 i; WMtTimer *timer_array; - + UUmAssert(inWindow); - + // find the timer in the list timer_array = (WMtTimer*)UUrMemory_Array_GetMemory(WMgTimers); for (i = 0; i < UUrMemory_Array_GetUsedElems(WMgTimers); i++) @@ -2007,10 +2007,10 @@ WMiTimer_Update( UUtUns32 time; WMtTimer *timer_array; UUtUns32 num_timers; - + time = UUrMachineTime_Sixtieths(); -update: +update: timer_array = (WMtTimer*)UUrMemory_Array_GetMemory(WMgTimers); num_timers = UUrMemory_Array_GetUsedElems(WMgTimers); for (i = 0; i < num_timers; i++) @@ -2019,7 +2019,7 @@ WMiTimer_Update( { // calculate the next firing timer_array[i].timer_next_firing = time + timer_array[i].timer_frequency; - + // send the timer message WMrMessage_Send( timer_array[i].window, @@ -2028,7 +2028,7 @@ WMiTimer_Update( 0); // don't do any more processing with this timer after the message is sent // because the window may have destroyed it or itself during the message - + if (num_timers != UUrMemory_Array_GetUsedElems(WMgTimers)) { // the timer and or window was delete start the update over @@ -2045,7 +2045,7 @@ WMiTimer_WindowDestroyed( { UUtUns32 i; WMtTimer *timer_array; - + destroyer: timer_array = (WMtTimer*)UUrMemory_Array_GetMemory(WMgTimers); for (i = 0; i < UUrMemory_Array_GetUsedElems(WMgTimers); i++) @@ -2069,7 +2069,7 @@ isarrow( UUtInt16 inKey) { UUtBool result; - + switch (inKey) { case LIcKeyCode_UpArrow: @@ -2078,12 +2078,12 @@ isarrow( case LIcKeyCode_RightArrow: result = UUcTrue; break; - + default: result = UUcFalse; break; } - + return result; } @@ -2093,19 +2093,19 @@ isdelete( UUtInt16 inKey) { UUtBool result; - + switch (inKey) { case LIcKeyCode_BackSpace: case LIcKeyCode_Delete: result = UUcTrue; break; - + default: result = UUcFalse; break; } - + return result; } @@ -2115,7 +2115,7 @@ isnavigation( UUtInt16 inKey) { UUtBool result; - + switch (inKey) { case LIcKeyCode_Home: @@ -2124,12 +2124,12 @@ isnavigation( case LIcKeyCode_PageDown: result = UUcTrue; break; - + default: result = UUcFalse; break; } - + return result; } @@ -2139,19 +2139,19 @@ WMiEvent_GetKeyCategory( LItInputEvent *inInputEvent) { UUtUns32 result; - + result = WMcKeyCategory_None; - + if (isalpha(inInputEvent->key) != 0) { result |= WMcKeyCategory_Alpha; } if (isdigit(inInputEvent->key) != 0) { result |= WMcKeyCategory_Digit; } if (ispunct(inInputEvent->key) != 0) { result |= WMcKeyCategory_Punctuation; } if (isarrow(inInputEvent->key) != 0) { result |= WMcKeyCategory_Arrow; } if (isnavigation(inInputEvent->key) != 0) { result |= WMcKeyCategory_Navigation; } - + // don't let delete be part of control if (isdelete(inInputEvent->key) != 0) { result |= WMcKeyCategory_Delete; } else if (iscntrl(inInputEvent->key) != 0) { result |= WMcKeyCategory_Control; } - + return result; } @@ -2164,10 +2164,10 @@ WMiEvent_IsDoubleClick( { UUtBool is_double_click; WMtMessage message; - + is_double_click = UUcFalse; message = *ioMessage; - + switch (message) { case WMcMessage_NC_LMouseUp: @@ -2179,13 +2179,13 @@ WMiEvent_IsDoubleClick( { UUtUns32 time; float distance; - + time = UUrMachineTime_Sixtieths(); distance = IMrPoint2D_Distance( &WMgEventData.prev_mouse_click_location, &inInputEvent->where); - + if ((WMgEventData.prev_mouse_click_window == inWindow) && (WMgEventData.prev_mouse_click_message == message) && (time < (WMgEventData.prev_mouse_click_time + WMcDoubleClickDelta)) && @@ -2200,12 +2200,12 @@ WMiEvent_IsDoubleClick( case WMcMessage_MMouseUp: message = WMcMessage_MMouseDblClck; break; case WMcMessage_RMouseUp: message = WMcMessage_RMouseDblClck; break; } - + // clear the info WMgEventData.prev_mouse_click_window = NULL; WMgEventData.prev_mouse_click_time = 0; WMgEventData.prev_mouse_click_message = WMcMessage_None; - + is_double_click = UUcTrue; } else @@ -2219,7 +2219,7 @@ WMiEvent_IsDoubleClick( } break; } - + *ioMessage = message; return is_double_click; } @@ -2233,21 +2233,21 @@ WMiEvents_HandleMouseEvent( WMtMessage message; UUtUns32 param1; UUtUns32 param2; - + WMtMouseEventMap *event_map; - + WMtWindowArea part; UUtBool is_dbl_click; - - + + // record the cursor position for the cursor drawing to happen later WMgCursorPosition = inInputEvent->where; - + // get the window under the mouse window = WMrGetWindowUnderPoint(&inInputEvent->where); - + // check the undesirable flags - if (NULL != window) + if (NULL != window) { UUtUns32 undesirable_flags = WMcWindowFlag_Disabled | WMcWindowFlag_MouseTransparent; @@ -2256,31 +2256,31 @@ WMiEvents_HandleMouseEvent( window = NULL; } } - + // set the window to the Mouse Focus window if (WMgMouseFocus) { window = WMgMouseFocus; } - + // set param1 param1 = UUmMakeLong(inInputEvent->where.x, inInputEvent->where.y); - + // get the part of the window the mouse is over if (window == NULL) { part = WMcWindowArea_Client; } else - { - part = + { + part = (WMtWindowArea)WMrMessage_Send( window, WMcMessage_NC_HitTest, param1, 0); - } - + } + // set the message type based on the hittest if (part == WMcWindowArea_Client) { @@ -2290,9 +2290,9 @@ WMiEvents_HandleMouseEvent( else { event_map = WMgMouseNCEventMap; - param2 = (UUtUns32)part; + param2 = (UUtUns32)part; } - + for (; event_map->window_message != WMcMessage_None; event_map++) @@ -2303,19 +2303,19 @@ WMiEvents_HandleMouseEvent( break; } } - + // don't generate WMcMessage_NC_MouseMove messages when the mouse is captured if ((WMgMouseFocus) && (message == WMcMessage_NC_MouseMove)) { message = WMcMessage_MouseMove; } - + // check for double clicks is_dbl_click = WMiEvent_IsDoubleClick(inInputEvent, window, &message); - + // send a message to the window WMrMessage_Post(window, message, param1, param2); - + // send a mouse up message if message is a double clicked message if (is_dbl_click) { @@ -2328,7 +2328,7 @@ WMiEvents_HandleMouseEvent( case WMcMessage_MMouseDblClck: message = WMcMessage_MMouseUp; break; case WMcMessage_RMouseDblClck: message = WMcMessage_RMouseUp; break; } - + WMrMessage_Post(window, message, param1, param2); } } @@ -2342,13 +2342,13 @@ WMiEvents_HandleKeyEvent( UUtUns32 param1; UUtUns32 param2; WMtWindow *window; - + if (WMgKeyboardFocus == NULL) return; // set param1 and param2 param1 = (UUtUns32)inInputEvent->key; param2 = (UUtUns32)inInputEvent->modifiers; - + // set the message switch (inInputEvent->type) { @@ -2356,25 +2356,25 @@ WMiEvents_HandleKeyEvent( case LIcInputEvent_KeyRepeat: message = WMcMessage_KeyDown; break; - + case LIcInputEvent_KeyUp: message = WMcMessage_KeyUp; break; } - + // if the keyboard focus is the child window of a dialog then determine // if the child or the dialog should get the keyboard event window = WMgKeyboardFocus; if (window->flags & WMcWindowFlag_Child) { WMtWindow *parent; - + parent = WMrWindow_GetParent(window); if ((parent) && (parent->window_class->type == WMcWindowType_Dialog)) { UUtUns32 result; UUtUns32 key_category; - + key_category = WMiEvent_GetKeyCategory(inInputEvent); result = WMrMessage_Send(window, WMcMessage_GetDialogCode, 0, 0); switch (key_category) @@ -2382,23 +2382,23 @@ WMiEvents_HandleKeyEvent( case WMcKeyCategory_Alpha: if ((result & WMcDialogCode_WantAlphas) == 0) { window = parent; } break; - + case WMcKeyCategory_Digit: if ((result & WMcDialogCode_WantDigits) == 0) { window = parent; } break; - + case WMcKeyCategory_Punctuation: if ((result & WMcDialogCode_WantPunctuation) == 0) { window = parent; } break; - + case WMcKeyCategory_Control: window = parent; break; - + case WMcKeyCategory_Navigation: if ((result & WMcDialogCode_WantNavigation) == 0) { window = parent; } break; - + case WMcKeyCategory_Arrow: if ((result & WMcDialogCode_WantArrows) == 0) { window = parent; } break; @@ -2409,7 +2409,7 @@ WMiEvents_HandleKeyEvent( } } } - + // send a message to the focused view WMrMessage_Post(window, message, param1, param2); } @@ -2420,9 +2420,9 @@ WMiEvents_Process( void) { UUtUns32 i; - + if (LIrMode_Get() == LIcMode_Game) return; - + // get the events and send them to the dialog for (i = 0; i < WMcMaxEventsPerUpdate; i++) { @@ -2442,7 +2442,7 @@ WMiEvents_Process( if (input_event.where.y > WMgDesktop->height) { input_event.where.y = WMgDesktop->height; } } - + // handle the input event switch (input_event.type) { @@ -2455,7 +2455,7 @@ WMiEvents_Process( case LIcInputEvent_RMouseUp: WMiEvents_HandleMouseEvent(&input_event); break; - + case LIcInputEvent_KeyDown: case LIcInputEvent_KeyRepeat: WMiEvents_HandleKeyEvent(&input_event); @@ -2481,7 +2481,7 @@ WMiCursor_Load( { return UUcError_Generic; } - + return UUcError_None; } @@ -2501,14 +2501,14 @@ WMiDesktop_Paint( IMtPoint2D dest; UUtInt16 desktop_width; UUtInt16 desktop_height; - + // start drawing draw_context = DCrDraw_Begin(inDesktop); - + // get the background background = (void*)WMrWindow_GetLong(inDesktop, 0); if (background == 0) { return; } - + // get the size of the desktop WMrWindow_GetSize(inDesktop, &desktop_width, &desktop_height); @@ -2520,7 +2520,7 @@ WMiDesktop_Paint( // set the dest dest.x = 0; dest.y = 0; - + // draw the partspec DCrDraw_PartSpec( draw_context, @@ -2531,7 +2531,7 @@ WMiDesktop_Paint( desktop_height, M3cMaxAlpha); break; - + case M3cTemplate_TextureMap: case M3cTemplate_TextureMap_Big: { @@ -2540,11 +2540,11 @@ WMiDesktop_Paint( // get the size of the texture M3rTextureRef_GetSize(background, &width, &height); - + // set the dest dest.x = (desktop_width - (UUtInt16)width) >> 1; dest.y = (desktop_height - (UUtInt16)height) >> 1; - + DCrDraw_TextureRef( draw_context, background, @@ -2556,7 +2556,7 @@ WMiDesktop_Paint( } break; } - + // stop drawing DCrDraw_End(draw_context, inDesktop); } @@ -2574,27 +2574,27 @@ WMiDesktop_Callback( case WMcMessage_Create: WMrWindow_SetLong(inDesktop, 0, 0); return WMcResult_Handled; - + case WMcMessage_Destroy: WMrWindow_SetLong(inDesktop, 0, 0); return WMcResult_Handled; - + case WMcMessage_Paint: WMiDesktop_Paint(inDesktop); return WMcResult_Handled; - + case WMcMessage_ResolutionChanged: WMrWindow_SetSize( inDesktop, (UUtInt16)UUmHighWord(inParam1), (UUtInt16)UUmLowWord(inParam1)); break; - + case DTcMessage_SetBackground: WMrWindow_SetLong(inDesktop, 0, inParam1); return WMcResult_Handled; } - + return WMrWindow_DefaultCallback(inDesktop, inMessage, inParam1, inParam2); } @@ -2605,18 +2605,18 @@ WMiDesktop_Create( { WMtWindowClass window_class; UUtError error; - + UUmAssert(WMgDesktop == NULL); - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_Desktop; window_class.callback = WMiDesktop_Callback; window_class.private_data_size = sizeof(UUtUns32); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + // create the oni window WMgDesktop = WMrWindow_New( @@ -2632,7 +2632,7 @@ WMiDesktop_Create( NULL, 0); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2647,12 +2647,12 @@ WMrMessage_Dispatch( WMtEvent *inEvent) { UUtUns32 result; - + if (inEvent->window) { WMtWindow *mouse_over; IMtPoint2D point; - + // get the window the mouse was actually clicked on mouse_over = NULL; switch (inEvent->message) @@ -2668,12 +2668,12 @@ WMrMessage_Dispatch( point.y = UUmLowWord(inEvent->param1); mouse_over = WMrGetWindowUnderPoint(&point); if (mouse_over == inEvent->window) { mouse_over = NULL; } - + // activate the window the user clicked on WMrWindow_Activate(inEvent->window); break; } - + // send the message to the window result = WMrMessage_Send( @@ -2681,7 +2681,7 @@ WMrMessage_Dispatch( inEvent->message, inEvent->param1, inEvent->param2); - + // activate the window the mouse was actually clicked on if (mouse_over) { WMrWindow_Activate(mouse_over); } } @@ -2689,7 +2689,7 @@ WMrMessage_Dispatch( { result = WMcResult_NoWindow; } - + return result; } @@ -2697,20 +2697,20 @@ WMrMessage_Dispatch( UUtBool WMrMessage_Get( WMtEvent *outEvent) -{ +{ // if the event pointed to by the head has a message of none, // there are no messages if (WMgEvents[WMgEventHead].message == WMcMessage_None) { return UUcFalse; } - + // set the output *outEvent = WMgEvents[WMgEventHead]; - + // clear the message WMgEvents[WMgEventHead].message = WMcMessage_None; - + // advance the message head to the next message, but don't pass the tail if (WMgEventHead != WMgEventTail) { @@ -2720,7 +2720,7 @@ WMrMessage_Get( WMgEventHead = 0; } } - + return UUcTrue; } @@ -2730,7 +2730,7 @@ WMiMessage_Initialize( void) { UUtUns32 i; - + // initialize the events for (i = 0; i < WMcMaxNumEvents; i++) { @@ -2739,11 +2739,11 @@ WMiMessage_Initialize( WMgEvents[i].param1 = 0; WMgEvents[i].param2 = 0; } - + // initialize the queue indices WMgEventHead = 0; WMgEventTail = 0; - + return UUcError_None; } @@ -2754,25 +2754,25 @@ WMrMessage_Post( WMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2) -{ +{ // store the event at the tail WMgEvents[WMgEventTail].window = inWindow; WMgEvents[WMgEventTail].message = inMessage; WMgEvents[WMgEventTail].param1 = inParam1; WMgEvents[WMgEventTail].param2 = inParam2; - + // update the tail WMgEventTail++; if (WMgEventTail >= WMcMaxNumEvents) { WMgEventTail = 0; } - + if (WMgEventTail == WMgEventHead) { UUmAssert(!"went all the way araound"); } - + return UUcTrue; } @@ -2785,7 +2785,7 @@ WMrMessage_Send( UUtUns32 inParam2) { if (inWindow == NULL) { return 0; } - + if (!WMiWA_Valid(inWindow)) { return 0; } return inWindow->window_class->callback(inWindow, inMessage, inParam1, inParam2); @@ -2799,14 +2799,14 @@ WMrMessage_TranslateKeyCommand( WMtWindow *inDestWindow) { UUtUns32 i; - + UUmAssert(inEvent); UUmAssert(inKeyboardCommands); - + // only key downs get changed into commands if (inEvent->message != WMcMessage_KeyDown) { return UUcFalse; } if (inEvent->param2 != LIcKeyState_CommandDown) { return UUcFalse; } - + // look for the key in the inKeyboardCommands table for (i = 0; i < inKeyboardCommands->num_commands; i++) { @@ -2816,12 +2816,12 @@ WMrMessage_TranslateKeyCommand( inEvent->window = inDestWindow; inEvent->message = WMcMessage_KeyCommand; inEvent->param2 = 0; - + // exit return UUcTrue; } } - + return UUcFalse; } @@ -2836,10 +2836,10 @@ WMrActivate( void) { LItInputEvent event; - + WMgActive = UUcTrue; WMrCursor_SetVisible(UUcTrue); - + // get the current mouse position LIrInputEvent_GetMouse(&event); WMgCursorPosition = event.where; @@ -2855,19 +2855,19 @@ WMrDisplay( M3rDraw_State_SetInt(M3cDrawStateIntType_SubmitMode, M3cDrawState_SubmitMode_Normal); M3rDraw_State_SetInt(M3cDrawStateIntType_ZWrite, M3cDrawState_ZWrite_Off); M3rDraw_State_SetInt(M3cDrawStateIntType_ZCompare, M3cDrawState_ZCompare_Off); - + // draw the windows if (WMgDesktop) { WMiWindow_Draw(WMgDesktop); } - + // draw the cursor if (WMgCursor) { WMrCursor_Draw(WMgCursor, &WMgCursorPosition); } - + // set the draw state M3rDraw_State_Pop(); } @@ -2888,18 +2888,18 @@ WMrEnumWindows( UUtUns32 inUserData) { WMtWindow *child; - + UUmAssert(inEnumCallback); - + child = WMgDesktop->child; while (child) { UUtBool result; WMtWindow *enum_window; - + enum_window = child; child = child->next; - + result = inEnumCallback(enum_window, inUserData); if (result == UUcFalse) { break; } } @@ -2927,7 +2927,7 @@ WMrInitialize( void) { UUtError error; - + // initialize globals WMgEventOverride = UUcFalse; WMgDesktop = NULL; @@ -2935,70 +2935,70 @@ WMrInitialize( WMgActiveWindow = NULL; WMgMouseFocus = NULL; WMgKeyboardFocus = NULL; - + // initialize the sub-systems error = WMiWA_Initialize(); UUmError_ReturnOnError(error); - + error = WMiMessage_Initialize(); UUmError_ReturnOnError(error); - + error = PSrInitialize(); UUmError_ReturnOnError(error); - + error = WMrTimer_Initialize(); UUmError_ReturnOnError(error); - + // clear the window class list WMgNumWindowClasses = 0; UUrMemory_Clear(WMgWindowClassList, sizeof(WMgWindowClassList)); - + // initialize the standard windows error = WMrBox_Initialize(); UUmError_ReturnOnError(error); - + error = WMrButton_Initialize(); UUmError_ReturnOnError(error); - + error = WMrCheckBox_Initialize(); UUmError_ReturnOnError(error); - + error = WMrDialog_Initialize(); UUmError_ReturnOnError(error); - + error = WMrEditField_Initialize(); UUmError_ReturnOnError(error); - + error = WMrListBox_Initialize(); UUmError_ReturnOnError(error); - + error = WMrMenu_Initialize(); UUmError_ReturnOnError(error); - + error = WMrMenuBar_Initialize(); UUmError_ReturnOnError(error); - + error = WMrPicture_Initialize(); UUmError_ReturnOnError(error); - + error = WMrPopupMenu_Initialize(); UUmError_ReturnOnError(error); - + error = WMrProgressBar_Initialize(); UUmError_ReturnOnError(error); - + error = WMrRadioButton_Initialize(); UUmError_ReturnOnError(error); - + error = WMrScrollbar_Initialize(); UUmError_ReturnOnError(error); - + error = WMrSlider_Initialize(); UUmError_ReturnOnError(error); - + error = WMrText_Initialize(); UUmError_ReturnOnError(error); - + WMgInitialized = UUcTrue; return UUcError_None; @@ -3018,22 +3018,22 @@ WMrRegisterTemplates( void) { UUtError error; - + error = PSrRegisterTemplates(); UUmError_ReturnOnError(error); - + error = WMrDialog_RegisterTemplates(); UUmError_ReturnOnError(error); - + error = WMrCursor_RegisterTemplates(); UUmError_ReturnOnError(error); - + error = WMrMenu_RegisterTemplates(); UUmError_ReturnOnError(error); - + error = WMrMenuBar_RegisterTemplates(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -3074,22 +3074,22 @@ WMrStartup( void) { UUtError error; - + // initialize the draw context text error = DCrText_Initialize(); UUmError_ReturnOnError(error); - + // create the desktop error = WMiDesktop_Create(); UUmError_ReturnOnError(error); - + // load the cursor error = WMiCursor_Load(); UUmError_ReturnOnError(error); - + return UUcError_None; } - + // ---------------------------------------------------------------------- void WMrTerminate( @@ -3100,18 +3100,18 @@ WMrTerminate( { WMrWindow_Delete(WMgDesktop); } - + // delete the window classes WMgNumWindowClasses = 0; UUrMemory_Clear(WMgWindowClassList, sizeof(WMgWindowClassList)); - + // terminate the sub-systems DCrText_Terminate(); WMiWA_Terminate(); WMiTimer_Terminate(); - + UUrMemory_Block_VerifyList(); - + WMgInitialized = UUcFalse; } @@ -3121,12 +3121,12 @@ WMrUpdate( void) { if (WMgActive == UUcFalse) return; - + // ------------------------------ // update the timers // ------------------------------ WMiTimer_Update(); - + // ------------------------------ // process events // ------------------------------ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/BFW_WindowManager_Private.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/BFW_WindowManager_Private.h index f4f4c79..60807b1 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/BFW_WindowManager_Private.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/BFW_WindowManager_Private.h @@ -18,7 +18,7 @@ enum { WMcDesktopStyle_None = 0x0000 - + }; enum @@ -37,16 +37,16 @@ enum struct WMtCaret { WMtWindow *owner; - + IMtPoint2D position; UUtInt16 width; UUtInt16 height; - + UUtBool visible; - + UUtBool blink_visible; UUtUns32 blink_time; - + }; // ---------------------------------------------------------------------- @@ -54,38 +54,38 @@ struct WMtWindow { WMtWindow *prev; WMtWindow *next; - + WMtWindow *parent; WMtWindow *owner; WMtWindow *child; - + WMtWindowClass *window_class; UUtUns32 flags; UUtUns32 style; UUtUns16 id; - + UUtUns32 index; - + IMtPoint2D location; UUtInt16 width; UUtInt16 height; - + UUtRect client_rect; UUtRect restored_rect; - + char title[WMcMaxTitleLength + 1]; UUtInt16 title_width; UUtInt16 title_height; - + WMtWindow *had_focus; - + TStFontInfo font_info; - + // nc mouse event data IMtPoint2D prev_mouse_location; UUtUns32 window_data; // bits 31 - 0, 31 = part hilite, 30 = flattened, 29 = zoomed, 15 - 0 = window area - + }; // ====================================================================== -#endif /* BFW_WINDOWMANAGER_PRIVATE_H */ \ No newline at end of file +#endif /* BFW_WINDOWMANAGER_PRIVATE_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/BFW_WindowManager_Public.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/BFW_WindowManager_Public.h index 194fb1c..9e1d2af 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/BFW_WindowManager_Public.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/BFW_WindowManager_Public.h @@ -41,19 +41,19 @@ enum { // Window Manager Messages WMcMessage_None, - + // Window non-client Messages WMcMessage_NC_Create, WMcMessage_NC_Destroy, WMcMessage_NC_HitTest, WMcMessage_NC_Paint, - + WMcMessage_NC_MouseMove, WMcMessage_NC_LMouseDown, WMcMessage_NC_LMouseUp, WMcMessage_NC_LMouseDblClck, - + WMcMessage_NC_MMouseDown, WMcMessage_NC_MMouseUp, WMcMessage_NC_MMouseDblClck, @@ -61,20 +61,20 @@ enum WMcMessage_NC_RMouseDown, WMcMessage_NC_RMouseUp, WMcMessage_NC_RMouseDblClck, - + WMcMessage_NC_Activate, WMcMessage_NC_Update, - + WMcMessage_NC_CalcClientSize, - + // Window Client Messages WMcMessage_Create, WMcMessage_Destroy, - + WMcMessage_Close, WMcMessage_Flatten, WMcMessage_Zoom, - + WMcMessage_Command, WMcMessage_KeyCommand, WMcMessage_MenuCommand, @@ -82,16 +82,16 @@ enum WMcMessage_MenuInit, WMcMessage_Timer, - + WMcMessage_KeyDown, WMcMessage_KeyUp, - + WMcMessage_MouseMove, WMcMessage_LMouseDown, WMcMessage_LMouseUp, WMcMessage_LMouseDblClck, - + WMcMessage_MMouseDown, WMcMessage_MMouseUp, WMcMessage_MMouseDblClck, @@ -99,50 +99,50 @@ enum WMcMessage_RMouseDown, WMcMessage_RMouseUp, WMcMessage_RMouseDblClck, - + WMcMessage_Activate, WMcMessage_SetFocus, WMcMessage_KillFocus, - + WMcMessage_Paint, WMcMessage_Update, - + WMcMessage_GetValue, WMcMessage_SetValue, - + WMcMessage_Visible, - + WMcMessage_CaptureChanged, WMcMessage_ParentNotify, - + WMcMessage_PositionChanging, WMcMessage_PositionChanged, - + WMcMessage_ResolutionChanged, - + WMcMessage_FontInfoChanged, - + WMcMessage_DrawItem, WMcMessage_CompareItems, - + WMcMessage_GetDialogCode, WMcMessage_Quit, - + // Toggle Button Messages TBcMessage_SetToggle, - + // Check Box Messages CBcMessage_SetCheck, - + // Desktop Message DTcMessage_SetBackground, - + // Dialog Manager Messages WMcMessage_InitDialog, WMcMessage_GetDefaultID, WMcMessage_SetDefaultID, - + // Edit Field Messages EFcMessage_GetText, EFcMessage_SetMaxChars, @@ -167,24 +167,24 @@ enum LBcMessage_SetNumLines, LBcMessage_SetSelection, LBcMessage_SetLineColor, /* unsupported */ - + // Picture PTcMessage_SetPartSpec, PTcMessage_SetPicture, - + // Scroll Bar Messages SBcMessage_HorizontalScroll, SBcMessage_VerticalScroll, - + // Tab Messages /* TbcMessage_InitTab,*/ - + // Radio Button Messages RBcMessage_SetCheck, - + // all user messages must come after this one WMcMessage_User - + }; @@ -222,52 +222,52 @@ enum WMcWindowType_Tab, WMcWindowType_TabGroup, WMcWindowType_Text, - + WMcWindowType_UserDefined = 0x4000 - + }; // window areas typedef enum WMtWindowArea { WMcWindowArea_None = 0x0000, - + WMcWindowArea_NC_Border = 0x0001, - + WMcWindowArea_NC_Left = 0x0002, WMcWindowArea_NC_Right = 0x0004, WMcWindowArea_NC_Top = 0x0008, WMcWindowArea_NC_Bottom = 0x0010, - + WMcWindowArea_NC_TopLeft = WMcWindowArea_NC_Top | WMcWindowArea_NC_Left, WMcWindowArea_NC_TopRight = WMcWindowArea_NC_Top | WMcWindowArea_NC_Right, WMcWindowArea_NC_BottomLeft = WMcWindowArea_NC_Bottom | WMcWindowArea_NC_Left, WMcWindowArea_NC_BottomRight = WMcWindowArea_NC_Bottom | WMcWindowArea_NC_Right, - + WMcWindowArea_NC_Drag = 0x0020, WMcWindowArea_NC_Grow = 0x0040, - + WMcWindowArea_NC_Close = 0x0080, WMcWindowArea_NC_Flatten = 0x0100, WMcWindowArea_NC_Zoom = 0x0200, - + WMcWindowArea_Client = 0x8000 - + } WMtWindowArea; // window flags enum { WMcWindowFlag_None = 0x0000, - + WMcWindowFlag_Visible = 0x0001, WMcWindowFlag_Disabled = 0x0002, WMcWindowFlag_MouseTransparent = 0x0004, - + WMcWindowFlag_Child = 0x2000, WMcWindowFlag_TopMost = 0x4000, WMcWindowFlag_PopUp = 0x8000 - + }; // standard window styles @@ -282,7 +282,7 @@ enum WMcWindowStyle_HasZoom = 0x00000020, WMcWindowStyle_HasFlatten = 0x00000040, WMcWindowStyle_HasGrowBox = 0x00000080 /* not supported yet */ - + }; #define WMcWindowStyle_Basic (WMcWindowStyle_HasBackground | WMcWindowStyle_HasDrag | WMcWindowStyle_HasTitle | WMcWindowStyle_HasClose) @@ -301,16 +301,16 @@ enum enum { WMcCommonFlag_None = 0x0000, - + WMcCommonFlag_Text_HLeft = 0x0100, WMcCommonFlag_Text_HCenter = 0x0200, WMcCommonFlag_Text_HRight = 0x0400, WMcCommonFlag_Text_VCenter = 0x0800, - + WMcCommonFlag_Text_Small = 0x1000, WMcCommonFlag_Text_Bold = 0x2000, WMcCommonFlag_Text_Italic = 0x4000 - + }; // notify flags @@ -318,7 +318,7 @@ enum { WMcNotify_Click = 1, WMcNotify_DoubleClick = 2 - + }; // draw item states @@ -353,7 +353,7 @@ typedef struct WMtWindowClass WMtWindowType type; WMtWindowCallback callback; UUtUns32 private_data_size; - + } WMtWindowClass; // ---------------------------------------------------------------------- @@ -363,14 +363,14 @@ typedef struct WMtEvent WMtMessage message; UUtUns32 param1; UUtUns32 param2; - + } WMtEvent; typedef struct WMtKeyboardCommands { UUtUns32 num_commands; UUtUns16 commands[WMcMaxKeyboardCommand]; - + } WMtKeyboardCommands; // ---------------------------------------------------------------------- @@ -382,7 +382,7 @@ typedef struct WMtPosChange UUtInt16 width; UUtInt16 height; UUtUns16 flags; - + } WMtPosChange; // ---------------------------------------------------------------------- @@ -396,7 +396,7 @@ typedef struct WMtDrawItem UUtRect rect; const char *string; UUtUns32 data; - + } WMtDrawItem; // ---------------------------------------------------------------------- @@ -404,12 +404,12 @@ typedef struct WMtCompareItems { WMtWindow *window; UUtUns16 window_id; - + UUtUns32 item1_index; UUtUns32 item1_data; UUtUns32 item2_index; UUtUns32 item2_data; - + } WMtCompareItems; // ====================================================================== @@ -421,20 +421,20 @@ WMrWindow_DefaultCallback( WMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2); - + // ---------------------------------------------------------------------- WMtWindow* WMrWindow_Activate( WMtWindow *inWindow); - + UUtBool WMrWindow_BringToFront( WMtWindow *inWindow); - + UUtBool WMrWindow_CaptureMouse( WMtWindow *inWindow); - + UUtBool WMrWindow_Delete( WMtWindow *inWindow); @@ -443,66 +443,66 @@ UUtBool WMrWindow_GetClientRect( WMtWindow *inWindow, UUtRect *outRect); - + UUtBool WMrWindow_GetEnabled( WMtWindow *inWindow); - + UUtUns32 WMrWindow_GetFlags( WMtWindow *inWindow); - + WMtWindow* WMrWindow_GetFocus( void); - + UUtBool WMrWindow_GetFontInfo( WMtWindow *inWindow, TStFontInfo *outFontInfo); - + UUtUns16 WMrWindow_GetID( WMtWindow *inWindow); - + UUtUns32 WMrWindow_GetLong( WMtWindow *inWindow, UUtInt32 inOffset); - + WMtWindow* WMrWindow_GetOwner( WMtWindow *inWindow); - + WMtWindow* WMrWindow_GetParent( WMtWindow *inWindow); - + UUtBool WMrWindow_GetRect( WMtWindow *inWindow, UUtRect *outRect); - + UUtBool WMrWindow_GetSize( WMtWindow *inWindow, UUtInt16 *outWidth, UUtInt16 *outHeight); - + UUtUns32 WMrWindow_GetStyle( WMtWindow *inWindow); - + UUtBool WMrWindow_GetTitle( WMtWindow *inWindow, char *outTitle, UUtUns16 inMaxCharacters); - + char* WMrWindow_GetTitlePtr( WMtWindow *inWindow); - + WMtWindowClass* WMrWindow_GetClass( WMtWindow *inWindow); @@ -510,24 +510,24 @@ WMrWindow_GetClass( UUtBool WMrWindow_GetVisible( WMtWindow *inWindow); - + UUtBool WMrWindow_IsChild( WMtWindow *inChild, WMtWindow *inParent); - + UUtBool WMrWindow_GlobalToLocal( WMtWindow *inWindow, IMtPoint2D *inGlobal, IMtPoint2D *outLocal); - + UUtBool WMrWindow_LocalToGlobal( WMtWindow *inWindow, IMtPoint2D *inLocal, IMtPoint2D *outGlobal); - + WMtWindow* WMrWindow_New( WMtWindowType inWindowType, @@ -546,38 +546,38 @@ UUtBool WMrWindow_PointInWindow( WMtWindow *inWindow, IMtPoint2D *inPoint); - + UUtBool WMrWindow_SetEnabled( WMtWindow *inWindow, UUtBool inEnabled); - + UUtBool WMrWindow_SetFocus( WMtWindow *inWindow); - + UUtBool WMrWindow_SetFontInfo( WMtWindow *inWindow, const TStFontInfo *inFontInfo); - + UUtBool WMrWindow_SetLocation( WMtWindow *inWindow, UUtInt16 inX, UUtInt16 inY); - + UUtUns32 WMrWindow_SetLong( WMtWindow *inWindow, UUtInt32 inOffset, UUtUns32 inData); - + WMtWindow* WMrWindow_SetParent( WMtWindow *inWindow, WMtWindow *inNewParent); - + UUtBool WMrWindow_SetPosition( WMtWindow *inWindow, @@ -587,7 +587,7 @@ WMrWindow_SetPosition( UUtInt16 inWidth, UUtInt16 inHeight, UUtUns16 inFlags); - + UUtBool WMrWindow_SetSize( WMtWindow *inWindow, @@ -599,17 +599,17 @@ WMrWindow_SetTitle( WMtWindow *inWindow, const char *inTitle, UUtUns16 inMaxCharacters); - + UUtBool WMrWindow_SetVisible( WMtWindow *inWindow, UUtBool inVisible); - + // ---------------------------------------------------------------------- UUtError WMrWindowClass_Register( WMtWindowClass *inWindowClass); - + WMtWindowClass* WMrWindowClass_GetClassByType( WMtWindowType inType); @@ -624,11 +624,11 @@ WMrCaret_Create( void WMrCaret_Destroy( void); - + void WMrCaret_GetPosition( IMtPoint2D *outPosition); - + void WMrCaret_SetPosition( UUtInt16 inX, @@ -637,35 +637,35 @@ WMrCaret_SetPosition( void WMrCaret_SetVisible( UUtBool inIsVisible); - + // ---------------------------------------------------------------------- UUtBool WMrTimer_Start( UUtUns32 inTimerID, UUtUns32 inTimerFrequency, WMtWindow *inWindow); - + void WMrTimer_Stop( UUtUns32 inTimerID, WMtWindow *inWindow); - + // ---------------------------------------------------------------------- UUtUns32 WMrMessage_Dispatch( WMtEvent *inEvent); - + UUtBool WMrMessage_Get( WMtEvent *outEvent); - + UUtBool WMrMessage_Post( WMtWindow *inWindow, WMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2); - + UUtUns32 WMrMessage_Send( WMtWindow *inWindow, @@ -678,33 +678,33 @@ WMrMessage_TranslateKeyCommand( WMtEvent *inEvent, WMtKeyboardCommands *inKeyboardCommands, WMtWindow *inDestWindow); - + // ---------------------------------------------------------------------- void WMrActivate( void); - + void WMrDisplay( void); - + void WMrDeactivate( void); - + void WMrEnumWindows( WMtWindowEnumCallback inEnumCallback, UUtUns32 inUserData); - + WMtWindow* WMrGetDesktop( void); - + WMtWindow* WMrGetWindowUnderPoint( IMtPoint2D *inPoint); - + UUtError WMrInitialize( void); @@ -712,32 +712,32 @@ WMrInitialize( void WMrLevel_Unload( void); - + UUtError WMrRegisterTemplates( void); - + void WMrSetDesktopBackground( void *inBackground); - + void WMrSetResolution( UUtInt16 inWidth, UUtInt16 inHeight); - + UUtError WMrStartup( void); - + void WMrTerminate( void); - + void WMrUpdate( void); // ====================================================================== -#endif /* BFW_WINDOWMANAGER_H */ \ No newline at end of file +#endif /* BFW_WINDOWMANAGER_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Cursor/WM_Cursor.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Cursor/WM_Cursor.c index dbad737..c07fd53 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Cursor/WM_Cursor.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Cursor/WM_Cursor.c @@ -33,14 +33,14 @@ WMrCursor_Draw( IMtPoint2D *inDestination) { M3tPointScreen dest; - + if (WMgCursor_Visible == UUcFalse) { return; } - + dest.x = (float)(inDestination->x - WMcCursor_Center_X); dest.y = (float)(inDestination->y - WMcCursor_Center_Y); dest.z = 0.5f; dest.invW = 1.0f / 0.5f; - + PSrPartSpec_Draw( inCursor->cursor_partspec, PScPart_MiddleMiddle, @@ -59,7 +59,7 @@ WMrCursor_Get( WMtCursorList *cursor_list; UUtUns32 i; WMtCursor *cursor; - + error = TMrInstance_GetDataPtr( WMcTemplate_CursorList, @@ -69,9 +69,9 @@ WMrCursor_Get( { return NULL; } - + cursor = NULL; - + for (i = 0; i < cursor_list->num_cursors; i++) { if (cursor_list->cursors[i].cursor_type == inCursorType) @@ -80,7 +80,7 @@ WMrCursor_Get( break; } } - + return cursor; } @@ -103,7 +103,7 @@ WMrCursor_RegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register( WMcTemplate_CursorList, diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Cursor/WM_Cursor.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Cursor/WM_Cursor.h index 995fcba..38788f8 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Cursor/WM_Cursor.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Cursor/WM_Cursor.h @@ -18,7 +18,7 @@ typedef enum WMtCursorType { WMcCursorType_None, - WMcCursorType_Arrow + WMcCursorType_Arrow } WMtCursorType; @@ -29,7 +29,7 @@ typedef tm_struct WMtCursor { UUtInt32 cursor_type; tm_templateref cursor_partspec; - + } WMtCursor; #define WMcTemplate_CursorList UUm4CharToUns32('W', 'M', 'C', 'L') @@ -37,10 +37,10 @@ typedef tm_template('W', 'M', 'C', 'L', "WM Cursor List") WMtCursorList { tm_pad pad[20]; - + tm_varindex UUtUns32 num_cursors; tm_vararray WMtCursor cursors[1]; - + } WMtCursorList; // ====================================================================== @@ -50,7 +50,7 @@ void WMrCursor_Draw( WMtCursor *inCursor, IMtPoint2D *inDestination); - + WMtCursor* WMrCursor_Get( WMtCursorType inCursorType); @@ -58,11 +58,11 @@ WMrCursor_Get( void WMrCursor_SetVisible( UUtBool inIsVisible); - + // ---------------------------------------------------------------------- UUtError WMrCursor_RegisterTemplates( void); // ====================================================================== -#endif /* WM_CURSOR_H */ \ No newline at end of file +#endif /* WM_CURSOR_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Dialog/WM_Dialog.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Dialog/WM_Dialog.c index 77460ef..9b09e5a 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Dialog/WM_Dialog.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Dialog/WM_Dialog.c @@ -20,12 +20,12 @@ enum { WMcMessageBox = 50, WMcGetString = 51, - + MBcTxt_Message = 100, MBcBtn_1 = 101, MBcBtn_2 = 102, MBcBtn_3 = 103 - + }; // ====================================================================== @@ -36,21 +36,21 @@ typedef struct WMtDialog_CreationData WMtDialogData *dialog_data; WMtDialogCallback dialog_callback; UUtUns32 user_data; - + } WMtDialog_CreationData; // ---------------------------------------------------------------------- typedef struct WMtDialog_PrivateData { WMtDialogCallback dialog_callback; - + UUtBool quit_dialog; UUtUns32 out_message; - + UUtUns32 default_item_id; - + UUtUns32 user_data; - + } WMtDialog_PrivateData; // ---------------------------------------------------------------------- @@ -58,7 +58,7 @@ typedef struct WMtMessageBox_Init { char *title; char *message; - WMtMessageBoxStyle style; + WMtMessageBoxStyle style; } WMtMessageBox_Init; typedef struct WMtGetString_Private @@ -87,13 +87,13 @@ WMiDialog_Center( WMtDialog *inDialog) { WMtWindow *parent; - + parent = WMrWindow_GetParent(inDialog); if (parent == NULL) { parent = WMrGetDesktop(); } - + if (parent != NULL) { UUtInt16 parent_width; @@ -107,10 +107,10 @@ WMiDialog_Center( WMrWindow_GetRect(parent, &parent_rect); WMrWindow_GetSize(parent, &parent_width, &parent_height); WMrWindow_GetSize(inDialog, &dialog_width, &dialog_height); - + x = parent_rect.left + ((parent_width - dialog_width) >> 1); y = parent_rect.top + ((parent_height - dialog_height) >> 1); - + WMrWindow_SetLocation(inDialog, x, y); } } @@ -123,21 +123,21 @@ WMiDialog_Create( { UUtUns32 i; WMtDialog_PrivateData *private_data; - + // get the private data private_data = (WMtDialog_PrivateData*)UUrMemory_Block_NewClear(sizeof(WMtDialog_PrivateData)); if (private_data == NULL) { goto cleanup; } WMrWindow_SetLong(inDialog, 0, (UUtUns32)private_data); - + if (inDialogCreationData == NULL) return WMcResult_Handled; - + private_data->dialog_callback = inDialogCreationData->dialog_callback; private_data->user_data = inDialogCreationData->user_data; - + for (i = 0; i < inDialogCreationData->dialog_data->num_items; i++) { WMtWindow *dialog_item; - + dialog_item = WMrWindow_New( inDialogCreationData->dialog_data->items[i].windowtype, @@ -156,28 +156,28 @@ WMiDialog_Create( UUmAssert(!"Unable to create the dialog item"); goto cleanup; } - + WMrWindow_SetFontInfo( dialog_item, &inDialogCreationData->dialog_data->items[i].font_info); } - + // set the position of the dialog if (inDialogCreationData->dialog_data->style & WMcDialogStyle_Centered) { WMiDialog_Center(inDialog); } - + return WMcResult_Handled; cleanup: - + if (private_data) { UUrMemory_Block_Delete(private_data); WMrWindow_SetLong(inDialog, 0, 0); } - + return WMcResult_Error; } @@ -187,11 +187,11 @@ WMiDialog_Destroy( WMtDialog *inDialog) { WMtDialog_PrivateData *private_data; - + // get the private data private_data = (WMtDialog_PrivateData*)WMrWindow_GetLong(inDialog, 0); if (private_data == NULL) { return; } - + UUrMemory_Block_Delete(private_data); WMrWindow_SetLong(inDialog, 0, 0); } @@ -202,11 +202,11 @@ WMiDialog_GetDefaultID( WMtDialog *inDialog) { WMtDialog_PrivateData *private_data; - + // get the private data private_data = (WMtDialog_PrivateData*)WMrWindow_GetLong(inDialog, 0); if (private_data == NULL) { return WMcResult_Error; } - + return private_data->default_item_id; } @@ -220,7 +220,7 @@ WMiDialog_HandleCommand( { UUtBool user_result; WMtDialog_PrivateData *private_data; - + // get the private data private_data = (WMtDialog_PrivateData*)WMrWindow_GetLong(inDialog, 0); if (private_data == NULL) { return WMcResult_Error; } @@ -246,7 +246,7 @@ WMiDialog_HandleCommand( } } } - + return WMcResult_Handled; } @@ -259,9 +259,9 @@ WMiDialog_HandleKeyEvent( UUtUns32 inParam2) { UUtUns32 result; - + if (inMessage == WMcMessage_KeyUp) { return; } - + switch (inParam1) { case LIcKeyCode_Return: @@ -270,7 +270,7 @@ WMiDialog_HandleKeyEvent( if (result != WMcDialogItem_None) { WMtWindow *default_dialog_item; - + default_dialog_item = WMrDialog_GetItemByID(inDialog, (UUtUns16)result); if ((default_dialog_item) && (WMrWindow_GetEnabled(default_dialog_item) == UUcTrue)) @@ -283,16 +283,16 @@ WMiDialog_HandleKeyEvent( } } break; - + case LIcKeyCode_Escape: case LIcKeyCode_Star: WMrMessage_Post(inDialog, WMcMessage_Close, 0, 0); break; - + /* case LIcKeyCode_Tab: { WMtWindow *has_focus; - + has_focus = WMrWindow_GetFocus(); if (WMrWindow_IsChild(has_focus, inDialog)) { @@ -320,18 +320,18 @@ WMiDialog_HandleDefault( { WMtDialog_PrivateData *private_data; UUtBool result; - + result = UUcFalse; - + // get the private data private_data = (WMtDialog_PrivateData*)WMrWindow_GetLong(inDialog, 0); if (private_data == NULL) { return result; } - + if (private_data->dialog_callback) { result = private_data->dialog_callback(inDialog, inMessage, inParam1, inParam2); } - + return result; } @@ -346,7 +346,7 @@ WMiDialog_HandleResolutionChanged( UUtRect rect; UUtInt16 new_x; UUtInt16 new_y; - + // if the window is suppose to be centered, re-center it style = WMrWindow_GetStyle(inDialog); if ((style & WMcDialogStyle_Centered) != 0) @@ -359,7 +359,7 @@ WMiDialog_HandleResolutionChanged( WMrWindow_GetRect(inDialog, &rect); new_x = rect.left; new_y = rect.top; - + if (rect.left >= inWidth) { new_x = inWidth - (rect.right - rect.left); @@ -368,7 +368,7 @@ WMiDialog_HandleResolutionChanged( { new_y = 0; } - + if (rect.top >= inHeight) { new_y = inHeight - (rect.bottom - rect.top); @@ -377,7 +377,7 @@ WMiDialog_HandleResolutionChanged( { new_y = 0; } - + WMrWindow_SetLocation(inDialog, new_x, new_y); } } @@ -389,11 +389,11 @@ WMiDialog_SetDefaultID( UUtUns32 inParam1) { WMtDialog_PrivateData *private_data; - + // get the private data private_data = (WMtDialog_PrivateData*)WMrWindow_GetLong(inDialog, 0); if (private_data == NULL) { return; } - + private_data->default_item_id = inParam1; } @@ -405,10 +405,10 @@ WMiDialog_TranslateModalEvent( { // the event is already going to the dialog if (ioEvent->window == inDialog) { return; } - + // if the event is going to a child window, don't interfere if (WMrWindow_IsChild(ioEvent->window, inDialog)) { return; } - + // make any mouse events go to the dialog switch (ioEvent->message) { @@ -450,7 +450,7 @@ WMiDialog_Callback( UUtUns32 inParam2) { UUtUns32 result; - + switch (inMessage) { case WMcMessage_NC_Create: @@ -471,12 +471,12 @@ WMiDialog_Callback( case WMcMessage_NC_Update: case WMcMessage_NC_CalcClientSize: break; - + case WMcMessage_KeyDown: case WMcMessage_KeyUp: WMiDialog_HandleKeyEvent(inDialog, inMessage, inParam1, inParam2); return WMcResult_Handled; - + case WMcMessage_Close: WMrMessage_Send( inDialog, @@ -484,49 +484,49 @@ WMiDialog_Callback( UUmMakeLong(WMcNotify_Click, WMcDialogItem_Cancel), (UUtUns32)NULL); return WMcResult_Handled; - + case WMcMessage_Create: result = WMiDialog_Create(inDialog, (WMtDialog_CreationData*)inParam1); WMmResult_ReturnOnError(result); return WMcResult_Handled; - + case WMcMessage_Destroy: WMiDialog_HandleDefault(inDialog, inMessage, inParam1, inParam2); WMiDialog_Destroy(inDialog); return WMcResult_Handled; - + case WMcMessage_Command: result = WMiDialog_HandleCommand(inDialog, inMessage, inParam1, inParam2); WMmResult_ReturnOnError(result); return WMcResult_Handled; - + case WMcMessage_CompareItems: result = WMiDialog_HandleDefault(inDialog, inMessage, inParam1, inParam2); return result; break; - + case WMcMessage_GetDefaultID: result = WMiDialog_GetDefaultID(inDialog); return result; break; - + case WMcMessage_SetDefaultID: WMiDialog_SetDefaultID(inDialog, inParam1); return WMcResult_Handled; - + case WMcMessage_ResolutionChanged: WMiDialog_HandleResolutionChanged( inDialog, (UUtInt16)UUmHighWord(inParam1), (UUtInt16)UUmLowWord(inParam1)); return WMcResult_Handled; - + default: result = WMiDialog_HandleDefault(inDialog, inMessage, inParam1, inParam2); if (result == UUcTrue) { return WMcResult_Handled; } break; } - + return WMrWindow_DefaultCallback(inDialog, inMessage, inParam1, inParam2); } @@ -544,19 +544,19 @@ WMiMessageBox_InitDialog( WMtWindow *btn_1; WMtWindow *btn_2; WMtWindow *btn_3; - + // save the dialog's style WMrDialog_SetUserData(inDialog, WMgMessageBox_Init.style); // set the title of the dialog WMrWindow_SetTitle(inDialog, WMgMessageBox_Init.title, WMcMaxTitleLength); - + // get pointers to the child windows message = WMrDialog_GetItemByID(inDialog, MBcTxt_Message); btn_1 = WMrDialog_GetItemByID(inDialog, MBcBtn_1); btn_2 = WMrDialog_GetItemByID(inDialog, MBcBtn_2); btn_3 = WMrDialog_GetItemByID(inDialog, MBcBtn_3); - + // set up the child windows WMrWindow_SetTitle(message, WMgMessageBox_Init.message, WMcMaxTitleLength); WMrWindow_SetVisible(btn_2, UUcFalse); @@ -572,12 +572,12 @@ WMiMessageBox_InitDialog( WMrWindow_SetTitle(btn_1, "Cancel", WMcMaxTitleLength); WMrWindow_SetVisible(btn_1, UUcTrue); break; - + case WMcMessageBoxStyle_OK: WMrWindow_SetTitle(btn_1, "OK", WMcMaxTitleLength); WMrWindow_SetVisible(btn_1, UUcTrue); break; - + case WMcMessageBoxStyle_Yes_No_Cancel: WMrWindow_SetTitle(btn_3, "Yes", WMcMaxTitleLength); WMrWindow_SetVisible(btn_3, UUcTrue); @@ -588,7 +588,7 @@ WMiMessageBox_InitDialog( WMrWindow_SetTitle(btn_1, "Cancel", WMcMaxTitleLength); WMrWindow_SetVisible(btn_1, UUcTrue); break; - + case WMcMessageBoxStyle_Yes_No: WMrWindow_SetTitle(btn_2, "Yes", WMcMaxTitleLength); WMrWindow_SetVisible(btn_2, UUcTrue); @@ -607,9 +607,9 @@ WMiMessageBox_HandleCommand( UUtUns32 inParam2) { UUtUns32 style; - + style = WMrDialog_GetUserData(inDialog); - + switch (style) { case WMcMessageBoxStyle_OK: @@ -632,28 +632,28 @@ WMiMessageBox_HandleCommand( case MBcBtn_2: WMrDialog_ModalEnd(inDialog, WMcDialogItem_OK); break; - + case MBcBtn_1: WMrDialog_ModalEnd(inDialog, WMcDialogItem_Cancel); break; - + case MBcBtn_3: UUmAssert(!"BLAM"); break; } break; - + case WMcMessageBoxStyle_Yes_No: switch (UUmLowWord(inParam1)) { case MBcBtn_2: WMrDialog_ModalEnd(inDialog, WMcDialogItem_Yes); break; - + case MBcBtn_1: WMrDialog_ModalEnd(inDialog, WMcDialogItem_No); break; - + case MBcBtn_3: UUmAssert(!"BLAM"); break; @@ -666,17 +666,17 @@ WMiMessageBox_HandleCommand( case MBcBtn_3: WMrDialog_ModalEnd(inDialog, WMcDialogItem_Yes); break; - + case MBcBtn_2: WMrDialog_ModalEnd(inDialog, WMcDialogItem_No); break; - + case MBcBtn_1: WMrDialog_ModalEnd(inDialog, WMcDialogItem_Cancel); break; } break; - } + } } // ---------------------------------------------------------------------- @@ -688,24 +688,24 @@ WMiMessageBox_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: WMiMessageBox_InitDialog(inDialog); break; - + case WMcMessage_Command: WMiMessageBox_HandleCommand(inDialog, inParam1, inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -722,7 +722,7 @@ static UUtBool WMiGetString_Callback( WMtWindow *edit_field = WMrDialog_GetItemByID(inDialog, 100); handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -736,11 +736,11 @@ static UUtBool WMiGetString_Callback( WMrWindow_SetTitle(prompt, privateData->inPrompt, WMcMaxTitleLength); WMrWindow_SetVisible(prompt, UUcTrue); } - + WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32) privateData->ioBuffer, 0); WMrMessage_Send(edit_field, EFcMessage_SetMaxChars, privateData->inBufferSize, 0); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -757,12 +757,12 @@ static UUtBool WMiGetString_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -786,10 +786,10 @@ WMrDialog_Create( UUtUns32 num_dialog_data; UUtUns32 i; WMtDialog_CreationData creation_data; - + // create the dialog dialog = NULL; - + // get a list of dialogs error = TMrInstance_GetDataPtr_List( @@ -798,7 +798,7 @@ WMrDialog_Create( &num_dialog_data, dialog_data); UUmError_ReturnOnError(error); - + // find the desired dialog for (i = 0; i < num_dialog_data; i++) { @@ -807,18 +807,18 @@ WMrDialog_Create( break; } } - + if (i == num_dialog_data) { UUmAssert(!"dialog not found"); return UUcError_Generic; } - + // create the dialog creation_data.dialog_data = dialog_data[i]; creation_data.dialog_callback = inDialogCallback; creation_data.user_data = inUserData; - + dialog = WMrWindow_New( WMcWindowType_Dialog, @@ -837,16 +837,16 @@ WMrDialog_Create( UUmAssert(!"unable to create the dialog"); return UUcError_Generic; } - + // tell the dialog callback that the dialog has been created inDialogCallback( dialog, WMcMessage_InitDialog, 0, 0); - + *outDialog = dialog; - + return UUcError_None; } @@ -857,7 +857,7 @@ WMrDialog_GetItemByID( UUtUns16 inID) { WMtWindow *child; - + child = inDialog->child; while (child) { @@ -865,10 +865,10 @@ WMrDialog_GetItemByID( { break; } - + child = child->next; } - + return child; } @@ -878,13 +878,13 @@ WMrDialog_GetUserData( WMtDialog *inDialog) { WMtDialog_PrivateData *private_data; - + UUmAssert(inDialog); - + // get the private data private_data = (WMtDialog_PrivateData*)WMrWindow_GetLong(inDialog, 0); UUmAssert(private_data); - + return private_data->user_data; } @@ -898,12 +898,12 @@ WMrDialog_MessageBox( { UUtError error; UUtUns32 message; - + // set the initialization parameters WMgMessageBox_Init.title = inTitle; WMgMessageBox_Init.message = inMessage; WMgMessageBox_Init.style = inStyle; - + // run the message box error = WMrDialog_ModalBegin( @@ -912,7 +912,7 @@ WMrDialog_MessageBox( WMiMessageBox_Callback, (UUtUns32) -1, &message); - + return message; } @@ -963,7 +963,7 @@ WMrDialog_ModalBegin( UUtError error; WMtDialog *dialog; WMtDialog_PrivateData *private_data; - + // load the dialog error = WMrDialog_Create( @@ -973,15 +973,15 @@ WMrDialog_ModalBegin( inUserData, &dialog); UUmError_ReturnOnError(error); - + // get the private data private_data = (WMtDialog_PrivateData*)WMrWindow_GetLong(dialog, 0); if (private_data == NULL) { return UUcError_Generic; } - + while (!private_data->quit_dialog) { WMtEvent event; - + // setup state information so frame start will be happy M3rDraw_State_SetInt(M3cDrawStateIntType_ZWrite, M3cDrawState_ZWrite_On); M3rDraw_State_SetInt(M3cDrawStateIntType_ZCompare, M3cDrawState_ZCompare_On); @@ -998,31 +998,31 @@ WMrDialog_ModalBegin( WMrDisplay(); M3rGeom_Frame_End(); - + // update the window manager WMrUpdate(); - + while (WMrMessage_Get(&event)) { WMiDialog_TranslateModalEvent(dialog, &event); WMrMessage_Dispatch(&event); } - // most likely error here is you are calling + // most likely error here is you are calling // WMrWindow_Delete instead of WMrDialog_ModalEnd UUrMemory_Block_Verify(private_data); } - + // set the output message if (outMessage) { *outMessage = private_data->out_message; } - + // close the dialog WMrWindow_Delete(dialog); dialog = NULL; - + return UUcError_None; } @@ -1033,13 +1033,13 @@ WMrDialog_ModalEnd( UUtUns32 inOutMessage) { WMtDialog_PrivateData *private_data; - + UUmAssert(inDialog); - + // get the private data private_data = (WMtDialog_PrivateData*)WMrWindow_GetLong(inDialog, 0); UUmAssert(private_data); - + private_data->out_message = inOutMessage; private_data->quit_dialog = UUcTrue; } @@ -1054,19 +1054,19 @@ WMrDialog_RadioButtonCheck( { UUtUns16 i; WMtRadioButton *radiobutton; - + for (i = inFirstRadioButtonID; i <= inLastRadioButtonID; i++) { radiobutton = WMrDialog_GetItemByID(inDialog, i); if (radiobutton == NULL) continue; - + WMrMessage_Send( radiobutton, RBcMessage_SetCheck, (UUtUns32)UUcFalse, 0); } - + radiobutton = WMrDialog_GetItemByID(inDialog, inCheckRadioButtonID); if (radiobutton != NULL) { @@ -1088,19 +1088,19 @@ WMrDialog_ToggleButtonCheck( { UUtUns16 i; WMtWindow *togglebutton; - + for (i = inFirstToggleButtonID; i <= inLastToggleButtonID; i++) { togglebutton = WMrDialog_GetItemByID(inDialog, i); if (togglebutton == NULL) continue; - + WMrMessage_Send( togglebutton, TBcMessage_SetToggle, (UUtUns32)UUcFalse, 0); } - + togglebutton = WMrDialog_GetItemByID(inDialog, inSetToggleButtonID); if (togglebutton != NULL) { @@ -1119,13 +1119,13 @@ WMrDialog_SetUserData( UUtUns32 inUserData) { WMtDialog_PrivateData *private_data; - + UUmAssert(inDialog); - + // get the private data private_data = (WMtDialog_PrivateData*)WMrWindow_GetLong(inDialog, 0); UUmAssert(private_data); - + private_data->user_data = inUserData; } @@ -1141,16 +1141,16 @@ WMrDialog_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_Dialog; window_class.callback = WMiDialog_Callback; window_class.private_data_size = sizeof(WMtDialog_PrivateData*); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1160,7 +1160,7 @@ WMrDialog_RegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register( WMcTemplate_DialogData, diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Dialog/WM_Dialog.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Dialog/WM_Dialog.h index 9ab6431..a406059 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Dialog/WM_Dialog.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Dialog/WM_Dialog.h @@ -19,10 +19,10 @@ enum { WMcDialogStyle_None = (0x0000 << 16), WMcDialogStyle_Centered = (0x0001 << 16), - + WMcDialogStyle_Modal = (WMcWindowStyle_HasBackground | WMcWindowStyle_HasDrag | WMcWindowStyle_HasTitle | WMcDialogStyle_Centered), WMcDialogStyle_Standard = (WMcWindowStyle_Basic | WMcDialogStyle_Centered) - + }; // standard dialog item IDs @@ -42,7 +42,7 @@ typedef enum WMtMessageBoxStyle WMcMessageBoxStyle_OK_Cancel, WMcMessageBoxStyle_Yes_No, WMcMessageBoxStyle_Yes_No_Cancel - + } WMtMessageBoxStyle; @@ -77,20 +77,20 @@ typedef UUtBool typedef tm_struct WMtDialogItemData { char title[256]; // WMcMaxTitleLength + 1 - + UUtUns16 windowtype; // WMtWindowType UUtUns16 id; - + UUtUns32 flags; UUtUns32 style; - + UUtInt16 x; UUtInt16 y; UUtInt16 width; UUtInt16 height; - + TStFontInfo font_info; - + } WMtDialogItemData; #define WMcTemplate_DialogData UUm4CharToUns32('W', 'M', 'D', 'D') @@ -98,18 +98,18 @@ typedef tm_template('W', 'M', 'D', 'D', "WM Dialog Data") WMtDialogData { char title[256]; // WMcMaxTitleLength + 1 - + UUtUns16 id; UUtUns16 unused; - + UUtUns32 flags; UUtUns32 style; - + UUtInt16 x; UUtInt16 y; UUtInt16 width; UUtInt16 height; - + tm_varindex UUtUns32 num_items; tm_vararray WMtDialogItemData items[1]; @@ -125,12 +125,12 @@ WMrDialog_Create( WMtDialogCallback inDialogCallback, UUtUns32 inUserData, WMtDialog **outDialog); - + WMtWindow* WMrDialog_GetItemByID( WMtDialog *inDialog, UUtUns16 inID); - + UUtUns32 WMrDialog_GetUserData( WMtDialog *inDialog); @@ -152,7 +152,7 @@ WMrDialog_MessageBox( char *inTitle, char *inMessage, WMtMessageBoxStyle inStyle); - + UUtError WMrDialog_ModalBegin( WMtDialogID inDialogID, @@ -160,7 +160,7 @@ WMrDialog_ModalBegin( WMtDialogCallback inDialogCallback, UUtUns32 inUserData, UUtUns32 *outMessage); - + void WMrDialog_ModalEnd( WMtDialog *inDialog, @@ -179,12 +179,12 @@ WMrDialog_ToggleButtonCheck( UUtUns16 inFirstToggleButtonID, UUtUns16 inLastToggleButtonID, UUtUns16 inSetToggleButtonID); - + void WMrDialog_SetUserData( WMtDialog *inDialog, UUtUns32 inUserData); - + // ---------------------------------------------------------------------- typedef void @@ -201,4 +201,4 @@ WMrDialog_RegisterTemplates( void); // ====================================================================== -#endif /* WM_DIALOG_H */ \ No newline at end of file +#endif /* WM_DIALOG_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_DrawContext/WM_DrawContext.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_DrawContext/WM_DrawContext.c index efbb052..9acf21a 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_DrawContext/WM_DrawContext.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_DrawContext/WM_DrawContext.c @@ -31,7 +31,7 @@ struct DCtDrawContext UUtUns32 shade; UUtInt16 x_offset; UUtInt16 y_offset; - + }; // ====================================================================== @@ -41,7 +41,7 @@ typedef struct DCtDC_ListElement { UUtBool inUse; DCtDrawContext draw_context; - + } DCtDC_ListElement; // ====================================================================== @@ -63,13 +63,13 @@ WMrClipRect( { UUmAssert(ioTextureRect); UUmAssert(ioUVs); - + // don't clip if inClipRect is NULL if (inClipRect == NULL) { return UUcTrue; } - + // do trivial reject if ((ioTextureRect->right < inClipRect->left) || (ioTextureRect->left > inClipRect->right) || @@ -78,7 +78,7 @@ WMrClipRect( { return UUcFalse; } - + // clip if (ioTextureRect->left < inClipRect->left) { @@ -89,7 +89,7 @@ WMrClipRect( (float)(ioTextureRect->right - ioTextureRect->left))); ioTextureRect->left = inClipRect->left; } - + if (ioTextureRect->top < inClipRect->top) { ioUVs[0].v = ioUVs[1].v = @@ -99,7 +99,7 @@ WMrClipRect( (float)(ioTextureRect->bottom - ioTextureRect->top))); ioTextureRect->top = inClipRect->top; } - + if (ioTextureRect->right > inClipRect->right) { ioUVs[1].u = ioUVs[3].u = @@ -109,7 +109,7 @@ WMrClipRect( (float)(ioTextureRect->right - ioTextureRect->left))); ioTextureRect->right = inClipRect->right; } - + if (ioTextureRect->bottom > inClipRect->bottom) { ioUVs[2].v = ioUVs[3].v = @@ -119,7 +119,7 @@ WMrClipRect( (float)(ioTextureRect->bottom - ioTextureRect->top))); ioTextureRect->bottom = inClipRect->bottom; } - + return UUcTrue; } @@ -135,9 +135,9 @@ DCrDraw_Begin( { UUtUns32 i; DCtDrawContext *draw_context; - + UUmAssert(inWindow); - + // get a draw context to draw with draw_context = NULL; for (i = 0; i < DCcDC_MaxListElements; i++) @@ -148,7 +148,7 @@ DCrDraw_Begin( break; } } - + if (draw_context != NULL) { UUtRect window_rect; @@ -157,53 +157,53 @@ DCrDraw_Begin( UUtInt16 dest_y; UUtInt16 x_offset; UUtInt16 y_offset; - + // set the x and y offset x_offset = 0; y_offset = 0; - + // get the client rect of the window WMrWindow_GetRect(inWindow, &window_rect); client_rect = inWindow->client_rect; - + // if this window is a child, it has to fit inside it's parent's client rect if (inWindow->flags & WMcWindowFlag_Child) { WMtWindow *window; UUtRect offset_rect; - + // put inWindow's client rect in world coordinates IMrRect_Offset(&client_rect, window_rect.left, window_rect.top); - + // save the client_rect to calculate the x and y offset later offset_rect = client_rect; - + // go up the list of parents and clip client_rect to the parent's client_rect window = inWindow->parent; while (window) { UUtRect win_rect; UUtRect clip_rect; - - // get the clip rect from window and put it in global coordinates + + // get the clip rect from window and put it in global coordinates WMrWindow_GetRect(window, &win_rect); clip_rect = window->client_rect; IMrRect_Offset(&clip_rect, win_rect.left, win_rect.top); - + // clip the client_rect to the parent IMrRect_Intersect(&client_rect, &clip_rect, &client_rect); - + // stop when a top level window has been reached if ((window->flags & WMcWindowFlag_Child) == 0) { break; } - + // get the next parent window = window->parent; } - + // calculate the x and y offset x_offset = offset_rect.left - client_rect.left; y_offset = offset_rect.top - client_rect.top; - + dest_x = client_rect.left; dest_y = client_rect.top; } @@ -212,9 +212,9 @@ DCrDraw_Begin( dest_x = client_rect.left + window_rect.left; dest_y = client_rect.top + window_rect.top; } - + IMrRect_Offset(&client_rect, -client_rect.left, -client_rect.top); - + // initialize the draw_context draw_context->id = i; draw_context->window = inWindow; @@ -227,7 +227,7 @@ DCrDraw_Begin( draw_context->x_offset = x_offset; draw_context->y_offset = y_offset; } - + return draw_context; } @@ -239,7 +239,7 @@ DCrDraw_End( { UUmAssert(inDrawContext); UUmAssert(inWindow); - + DCgDC_List[inDrawContext->id].inUse = UUcFalse; } @@ -252,12 +252,12 @@ DCrDraw_Glyph( M3tTextureCoord *inUVs) { UUtRect screen_dest; - + screen_dest.left = (UUtInt16)inScreenDest[0].x; screen_dest.top = (UUtInt16)inScreenDest[0].y; screen_dest.right = (UUtInt16)inScreenDest[1].x; screen_dest.bottom = (UUtInt16)inScreenDest[1].y; - + // clip the inScreenDest coords to inDrawContext->clip_rect; if (WMrClipRect(&inDrawContext->clip_rect, &screen_dest, inUVs)) { @@ -265,7 +265,7 @@ DCrDraw_Glyph( inScreenDest[0].y = (float)screen_dest.top + inDrawContext->screen_dest.y; inScreenDest[1].x = (float)screen_dest.right + inDrawContext->screen_dest.x; inScreenDest[1].y = (float)screen_dest.bottom + inDrawContext->screen_dest.y; - + M3rDraw_Sprite(inScreenDest, inUVs); } } @@ -278,17 +278,17 @@ DCrDraw_Line( IMtPoint2D *inPoint2) { /* M3tPointScreen dest[2]; - + UUmAssert(inDrawContext); - + dest[1] = inDrawContext->screen_dest; dest[1].x += (float)inPoint1->x; dest[1].y += (float)inPoint1->y; - + dest[2] = inDrawContext->screen_dest; dest[2].x += (float)inPoint2->x; dest[2].y += (float)inPoint2->y; - + M3rGeometry_LineDraw2D(2, dest, inDrawContext->shade);*/ } @@ -299,9 +299,9 @@ DCrDraw_NC_Begin( { UUtUns32 i; DCtDrawContext *draw_context; - + UUmAssert(inWindow); - + // get a draw context to draw with draw_context = NULL; for (i = 0; i < DCcDC_MaxListElements; i++) @@ -312,55 +312,55 @@ DCrDraw_NC_Begin( break; } } - + if (draw_context != NULL) { UUtRect rect; UUtRect offset_rect; UUtInt16 x_offset; UUtInt16 y_offset; - + // set the x and y offset x_offset = 0; y_offset = 0; - + // get the rect of the window WMrWindow_GetRect(inWindow, &rect); - + if (inWindow->flags & WMcWindowFlag_Child) { WMtWindow *parent; - + // save rect for use when calculate the x and y offste offset_rect = rect; - + // go through the parents and clip to their client rects parent = inWindow->parent; while (parent) { UUtRect win_rect; UUtRect clip_rect; - + // get the clip rect from the parent and put it into world coordinates WMrWindow_GetRect(parent, &win_rect); clip_rect = parent->client_rect; IMrRect_Offset(&clip_rect, win_rect.left, win_rect.top); - + // clip the rect to the clip rect IMrRect_Intersect(&rect, &clip_rect, &rect); - + // calculate the x and y offset x_offset = offset_rect.left - rect.left; y_offset = offset_rect.top - rect.top; - + // stop when parent is no longer a child window if ((parent->flags & WMcWindowFlag_Child) == 0) { break; } - + // get the next parent parent = parent->parent; } } - + // initialize the draw context draw_context->id = i; draw_context->window = inWindow; @@ -372,12 +372,12 @@ DCrDraw_NC_Begin( draw_context->shade = IMcShade_White; draw_context->x_offset = x_offset; draw_context->y_offset = y_offset; - + IMrRect_Offset(&draw_context->clip_rect, -rect.left, -rect.top); } - + return draw_context; -} +} // ---------------------------------------------------------------------- void @@ -387,9 +387,9 @@ DCrDraw_NC_End( { UUmAssert(inDrawContext); UUmAssert(inWindow); - + DCgDC_List[inDrawContext->id].inUse = UUcFalse; -} +} // ---------------------------------------------------------------------- void @@ -406,35 +406,35 @@ DCrDraw_PartSpec( M3tTextureMap *texture; PStPartSpec_PrivateData *private_data; IMtPoint2D dest; - + UUtInt16 l_width; UUtInt16 m_width; UUtInt16 r_width; - + UUtInt16 t_height; UUtInt16 m_height; UUtInt16 b_height; - + UUtRect bounds; M3tTextureCoord uv[4]; M3tPointScreen screen_dest[2]; - + UUtUns16 i; UUtUns16 j; - + UUtInt16 width; UUtInt16 height; - + M3tTextureCoord *uv_list; - + UUtUns16 columns[3] = {PScPart_LeftColumn, PScPart_MiddleColumn, PScPart_RightColumn}; - + UUtUns16 parts[3][3] = { {PScPart_LeftTop, PScPart_LeftMiddle, PScPart_LeftBottom}, {PScPart_MiddleTop, PScPart_MiddleMiddle, PScPart_MiddleBottom}, {PScPart_RightTop, PScPart_RightMiddle, PScPart_RightBottom}}; - + // CB: prevents integer division by zero nastiness if ((inWidth == 0) || (inHeight == 0)) return; @@ -446,12 +446,12 @@ DCrDraw_PartSpec( // get the private data private_data = (PStPartSpec_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(PSgTemplate_PartSpec_PrivateData, inPartSpec); UUmAssert(private_data); - + texture = (M3tTextureMap*)inPartSpec->texture; - + // set the shade and alpha shade = IMcShade_White; - + // calculate the heights and widths if ((private_data->t_height + private_data->b_height) > inHeight) { @@ -463,7 +463,7 @@ DCrDraw_PartSpec( { t_height = private_data->t_height * private_data->t_height / inHeight; } - + if (private_data->b_height > inHeight) { b_height = inHeight; @@ -479,7 +479,7 @@ DCrDraw_PartSpec( b_height = private_data->b_height; } m_height = (UUtUns16)UUmMax(0, inHeight - (t_height + b_height)); - + if ((private_data->l_width + private_data->r_width) > inWidth) { if (private_data->l_width > inWidth) @@ -490,7 +490,7 @@ DCrDraw_PartSpec( { l_width = private_data->l_width * private_data->l_width / inWidth; } - + if (private_data->r_width > inWidth) { r_width = inWidth; @@ -506,13 +506,13 @@ DCrDraw_PartSpec( r_width = private_data->r_width; } m_width = (UUtUns16)UUmMax(0, inWidth - (l_width + r_width)); - + if (inFlags == PScPart_MiddleMiddle) { m_height = inHeight; m_width = inWidth; } - + // set up the states M3rDraw_State_Push(); @@ -535,13 +535,13 @@ DCrDraw_PartSpec( M3rDraw_State_SetInt( M3cDrawStateIntType_Alpha, inAlpha); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, texture); - + M3rDraw_State_Commit(); - + for (i = 0; i < 3; i++) { // go through each column and setup the destination @@ -554,7 +554,7 @@ DCrDraw_PartSpec( case PScPart_LeftColumn: width = l_width; break; - + case PScPart_MiddleColumn: width = m_width; @@ -563,10 +563,10 @@ DCrDraw_PartSpec( dest.x += l_width; } break; - + case PScPart_RightColumn: width = r_width; - + if (inFlags & PScPart_LeftColumn) { dest.x += l_width; @@ -578,14 +578,14 @@ DCrDraw_PartSpec( } break; } - + // draw the visible parts in each column for (j = 0; j < 3; j++) { UUtBool draw; - + draw = UUcTrue; - + switch (inFlags & parts[i][j]) { case PScPart_LeftTop: @@ -632,24 +632,24 @@ DCrDraw_PartSpec( height = b_height; uv_list = private_data->rb; break; - + default: draw = UUcFalse; break; } - + if (draw) { bounds.left = dest.x; bounds.top = dest.y; bounds.right = bounds.left + width; bounds.bottom = bounds.top + height; - + uv[0] = uv_list[0]; uv[1] = uv_list[1]; uv[2] = uv_list[2]; uv[3] = uv_list[3]; - + if (WMrClipRect(&inDrawContext->clip_rect, &bounds, uv)) { screen_dest[0] = inDrawContext->screen_dest; @@ -658,12 +658,12 @@ DCrDraw_PartSpec( screen_dest[0].y += (float)bounds.top; screen_dest[1].x += (float)bounds.right; screen_dest[1].y += (float)bounds.bottom; - + M3rDraw_Sprite( screen_dest, uv); } - + dest.y += height; } } @@ -695,11 +695,11 @@ DCrDraw_String2( UUtRect *outStringRect) { UUtRect bounds; - + UUmAssert(inDrawContext); UUmAssert(inString); UUmAssert(inDestination); - + // handle inBounds of NULL if (inBounds == NULL) { @@ -709,7 +709,7 @@ DCrDraw_String2( { bounds = *inBounds; } - + // do a trivial reject if (((bounds.right - bounds.left) <= 0) || ((bounds.bottom - bounds.top) <= 0)) @@ -721,7 +721,7 @@ DCrDraw_String2( { return; } - + // draw the string TSrContext_DrawText_DC( DCgTextContext, @@ -761,23 +761,23 @@ DCrDraw_TextureRef( M3tTextureMap *texture; M3tTextureMap_Big *texture_big; IMtPoint2D offset_location; - + UUmAssert(inDrawContext); UUmAssert(inTextureRef); UUmAssert(inLocation); - + if (inTextureRef == NULL) return; - + // get the template tag of the current background template_tag = TMrInstance_GetTemplateTag(inTextureRef); - + // set the shade and alpha shade = IMcShade_White; - + // offset the location offset_location.x = inLocation->x + inDrawContext->x_offset; offset_location.y = inLocation->y + inDrawContext->y_offset; - + switch (template_tag) { case M3cTemplate_TextureMap: @@ -788,17 +788,17 @@ DCrDraw_TextureRef( // get a pointer to the texture texture = inTextureRef; - + if (inWidth == -1) draw_width = texture->width; else draw_width = inWidth; - + if (inHeight == -1) draw_height = texture->height; else draw_height = inHeight; - + // set UVs // br if (inScale) @@ -811,94 +811,94 @@ DCrDraw_TextureRef( uv[3].u = (float)draw_width / (float)texture->width; uv[3].v = (float)draw_height / (float)texture->height; } - + // tl uv[0].u = 0.f; uv[0].v = 0.f; - + // tr uv[1].u = uv[3].u; uv[1].v = 0.f; - + // bl uv[2].u = 0.f; uv[2].v = uv[3].v; - + // build the texture rect texture_rect.left = offset_location.x; texture_rect.top = offset_location.y; texture_rect.right = texture_rect.left + draw_width; - texture_rect.bottom = texture_rect.top + draw_height; - + texture_rect.bottom = texture_rect.top + draw_height; + // clip the rect if (WMrClipRect(&inDrawContext->clip_rect, &texture_rect, uv) == UUcFalse) { return; } - + // set dest dest[0] = inDrawContext->screen_dest; dest[1] = inDrawContext->screen_dest; - + dest[0].x += (float)texture_rect.left; dest[0].y += (float)texture_rect.top; dest[1].x += (float)texture_rect.right; dest[1].y += (float)texture_rect.bottom; - + M3rDraw_State_Push(); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Texture_Unlit); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Fill, M3cDrawState_Fill_Solid); - + M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, shade); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Alpha, inAlpha); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, texture); - + M3rDraw_State_Commit(); - + M3rDraw_Sprite( dest, uv); - + M3rDraw_State_Pop(); } break; - + case M3cTemplate_TextureMap_Big: { UUtUns16 x; UUtUns16 y; - + // get a pointer to the texture texture_big = inTextureRef; - + if (inWidth == -1) draw_width = texture_big->width; else draw_width = inWidth; - + if (inHeight == -1) draw_height = texture_big->height; else draw_height = inHeight; - + // draw the subtextures that are visible for (y = 0; y < texture_big->num_y; y++) { @@ -908,28 +908,28 @@ DCrDraw_TextureRef( IMtPoint2D texture_dest; UUtUns16 width; UUtUns16 height; - - UUtInt16 temp; + + UUtInt16 temp; UUtInt16 x_times_maxwidth; UUtInt16 y_times_maxheight; - + // get a pointer to the texture to be drawn index = x + (y * texture_big->num_x); texture = texture_big->textures[index]; - + x_times_maxwidth = x * M3cTextureMap_MaxWidth; y_times_maxheight = y * M3cTextureMap_MaxHeight; - + // calculate the dest_point of the texture texture_dest.x = offset_location.x + x_times_maxwidth; texture_dest.y = offset_location.y + y_times_maxheight; - + // calculate the width and height temp = (UUtInt16)UUmMax(0, draw_width - x_times_maxwidth); width = UUmMin(M3cTextureMap_MaxWidth, temp); temp = (UUtInt16)UUmMax(0, draw_height - y_times_maxheight); height = UUmMin(M3cTextureMap_MaxHeight, temp); - + // draw the sub_texture DCrDraw_TextureRef( inDrawContext, @@ -961,9 +961,9 @@ DCrText_DrawString( { UUtRect bounds; IMtPoint2D dest; - + UUmAssert(DCgTextContext); - + if (inBounds == NULL) { TSrContext_GetStringRect( @@ -975,7 +975,7 @@ DCrText_DrawString( { bounds = *inBounds; } - + if (inDestination == NULL) { dest.x = 0; @@ -985,7 +985,7 @@ DCrText_DrawString( { dest = *inDestination; } - + TSrContext_DrawString( DCgTextContext, inTextureRef, @@ -1010,12 +1010,12 @@ DCrText_GetAscendingHeight( void) { UUtUns16 descending_height; - + UUmAssert(DCgTextContext); - + descending_height = TSrFont_GetAscendingHeight(TSrContext_GetFont(DCgTextContext, TScStyle_InUse)); - + return descending_height; } @@ -1033,12 +1033,12 @@ DCrText_GetDescendingHeight( void) { UUtUns16 descending_height; - + UUmAssert(DCgTextContext); - + descending_height = TSrFont_GetDescendingHeight(TSrContext_GetFont(DCgTextContext, TScStyle_InUse)); - + return descending_height; } @@ -1056,9 +1056,9 @@ DCrText_GetLeadingHeight( void) { UUtUns16 leading_height; - + UUmAssert(DCgTextContext); - + leading_height = TSrFont_GetLeadingHeight(TSrContext_GetFont(DCgTextContext, TScStyle_InUse)); return leading_height; @@ -1070,11 +1070,11 @@ DCrText_GetLineHeight( void) { UUtUns16 line_height; - + UUmAssert(DCgTextContext); - + line_height = TSrFont_GetLineHeight(TSrContext_GetFont(DCgTextContext, TScStyle_InUse)); - + return line_height; } @@ -1097,9 +1097,9 @@ DCrText_Initialize( { UUtError error; TStFontFamily *font_family; - + DCgTextContext = NULL; - + // get the font family error = TMrInstance_GetDataPtr( @@ -1107,7 +1107,7 @@ DCrText_Initialize( TScFontFamily_Default, &font_family); UUmError_ReturnOnErrorMsg(error, "Unable to load font family"); - + // create a new text context error = TSrContext_New( @@ -1118,7 +1118,7 @@ DCrText_Initialize( UUcFalse, &DCgTextContext); UUmError_ReturnOnErrorMsg(error, "Unable to create text context"); - + // set the default color error = TSrContext_SetShade(DCgTextContext, IMcShade_Black); UUmError_ReturnOnErrorMsg(error, "Unable to set text context color"); @@ -1133,7 +1133,7 @@ DCrText_SetFontFamily( { UUmAssert(DCgTextContext); UUmAssert(inFontFamily); - + TSrContext_SetFontFamily(DCgTextContext, inFontFamily); } @@ -1145,7 +1145,7 @@ DCrText_SetFontInfo( UUmAssert(DCgTextContext); UUmAssert(inFontInfo); UUmAssert(inFontInfo->font_family); - + TSrContext_SetFontFamily(DCgTextContext, inFontInfo->font_family); TSrContext_SetFontSize(DCgTextContext, inFontInfo->font_size); TSrContext_SetFontStyle(DCgTextContext, inFontInfo->font_style); @@ -1158,7 +1158,7 @@ DCrText_SetFormat( TStFormat inFormat) { UUmAssert(DCgTextContext); - + TSrContext_SetFormat(DCgTextContext, inFormat); } @@ -1168,7 +1168,7 @@ DCrText_SetShade( UUtUns32 inShade) { UUmAssert(DCgTextContext); - + TSrContext_SetShade(DCgTextContext, inShade); } @@ -1178,7 +1178,7 @@ DCrText_SetSize( UUtUns16 inSize) { UUmAssert(DCgTextContext); - + TSrContext_SetFontSize(DCgTextContext, inSize); } @@ -1188,7 +1188,7 @@ DCrText_SetStyle( TStFontStyle inStyle) { UUmAssert(DCgTextContext); - + TSrContext_SetFontStyle(DCgTextContext, inStyle); } @@ -1202,4 +1202,4 @@ DCrText_Terminate( TSrContext_Delete(DCgTextContext); DCgTextContext = NULL; } -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_DrawContext/WM_DrawContext.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_DrawContext/WM_DrawContext.h index 61ab24a..929c093 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_DrawContext/WM_DrawContext.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_DrawContext/WM_DrawContext.h @@ -43,7 +43,7 @@ DCrDraw_Glyph( const DCtDrawContext *inDrawContext, M3tPointScreen *inScreenDest, M3tTextureCoord *inUVs); - + void DCrDraw_Line( DCtDrawContext *inDrawContext, @@ -53,12 +53,12 @@ DCrDraw_Line( DCtDrawContext* DCrDraw_NC_Begin( WMtWindow *inWindow); - + void DCrDraw_NC_End( DCtDrawContext *inDrawContext, WMtWindow *inWindow); - + void DCrDraw_PartSpec( DCtDrawContext *inDrawContext, @@ -81,14 +81,14 @@ DCrDraw_String2( const UUtRect *inBounds, const IMtPoint2D *inDestination, UUtRect *outStringRect); - + void DCrDraw_String( DCtDrawContext *inDrawContext, const char *inString, const UUtRect *inBounds, const IMtPoint2D *inDestination); - + void DCrDraw_TextureRef( DCtDrawContext *inDrawContext, @@ -106,33 +106,33 @@ DCrText_DrawString( char *inString, UUtRect *inBounds, IMtPoint2D *inDestination); - + void DCrText_DrawText( char *inString, UUtRect *inBounds, IMtPoint2D *inDestination); - + UUtUns16 DCrText_GetAscendingHeight( void); - + const TStTextContext* DCrText_GetTextContext( void); - + UUtUns16 DCrText_GetDescendingHeight( void); - + TStFont* DCrText_GetFont( void); - + UUtUns16 DCrText_GetLeadingHeight( void); - + UUtUns16 DCrText_GetLineHeight( void); @@ -149,30 +149,30 @@ DCrText_Initialize( void DCrText_SetFontFamily( TStFontFamily *inFontFamily); - + void DCrText_SetFontInfo( TStFontInfo *inFontInfo); - + void DCrText_SetFormat( TStFormat inFormat); - + void DCrText_SetShade( UUtUns32 inShade); - + void DCrText_SetSize( UUtUns16 inSize); - + void DCrText_SetStyle( TStFontStyle inStyle); - + void DCrText_Terminate( void); // ====================================================================== -#endif /* WM_DRAWCONTEXT_H */ \ No newline at end of file +#endif /* WM_DRAWCONTEXT_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_PartSpecification/WM_PartSpecification.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_PartSpecification/WM_PartSpecification.c index 09ced96..9d6f8fc 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_PartSpecification/WM_PartSpecification.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_PartSpecification/WM_PartSpecification.c @@ -35,30 +35,30 @@ PSiPartSpec_CalcUV( float ru; float tv; float bv; - + texture = (M3tTextureMap*)inPartSpec->texture; - + invTextureWidth = 1.0f / (float)texture->width; invTextureHeight = 1.0f / (float)texture->height; - + lu = (float)inPartSpec->part_matrix_tl[inColumn][inRow].x * invTextureWidth; tv = (float)inPartSpec->part_matrix_tl[inColumn][inRow].y * invTextureHeight; - + bv = (float)inPartSpec->part_matrix_br[inColumn][inRow].y * invTextureHeight; ru = (float)inPartSpec->part_matrix_br[inColumn][inRow].x * invTextureWidth; - + // tl ioUVs[0].u = lu; ioUVs[0].v = tv; - + // tr ioUVs[1].u = ru; ioUVs[1].v = tv; - + // bl ioUVs[2].u = lu; ioUVs[2].v = bv; - + // br ioUVs[3].u = ru; ioUVs[3].v = bv; @@ -73,16 +73,16 @@ PSiPartSpec_ProcHandler( { PStPartSpec *part_spec; PStPartSpec_PrivateData *private_data; - + UUmAssert(inInstancePtr); - + // get a pointer to the part spec part_spec = (PStPartSpec*)inInstancePtr; // get a pointer to the view's private data private_data = (PStPartSpec_PrivateData*)inPrivateData; UUmAssert(private_data); - + switch(inMessage) { case TMcTemplateProcMessage_NewPostProcess: @@ -99,40 +99,40 @@ PSiPartSpec_ProcHandler( PSiPartSpec_CalcUV(part_spec, private_data->rt, 2, 0); PSiPartSpec_CalcUV(part_spec, private_data->rm, 2, 1); PSiPartSpec_CalcUV(part_spec, private_data->rb, 2, 2); - + private_data->l_width = UUmABS( (UUtInt16)(part_spec->part_matrix_br[0][0].x - part_spec->part_matrix_tl[0][0].x)); - + private_data->r_width = UUmABS( (UUtInt16)(part_spec->part_matrix_br[2][0].x - part_spec->part_matrix_tl[2][0].x)); - + private_data->t_height = UUmABS( (UUtInt16)(part_spec->part_matrix_br[0][0].y - part_spec->part_matrix_tl[0][0].y)); - + private_data->b_height = UUmABS( (UUtInt16)(part_spec->part_matrix_br[0][2].y - part_spec->part_matrix_tl[0][2].y)); break; - + case TMcTemplateProcMessage_DisposePreProcess: break; - + case TMcTemplateProcMessage_Update: break; - + default: UUmAssert(!"Illegal message"); break; } - + return UUcError_None; } @@ -155,25 +155,25 @@ PSrPartSpec_Draw( M3tTextureMap *texture; PStPartSpec_PrivateData *private_data; M3tPointScreen dest; - + UUtInt16 l_width; UUtInt16 m_width; UUtInt16 r_width; - + UUtInt16 t_height; UUtInt16 m_height; UUtInt16 b_height; - - + + // get the private data private_data = (PStPartSpec_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(PSgTemplate_PartSpec_PrivateData, inPartSpec); UUmAssert(private_data); - + texture = (M3tTextureMap*)inPartSpec->texture; - + // set the shade and alpha shade = IMcShade_White; - + // calculate the heights and widths if ((private_data->t_height + private_data->b_height) > inHeight) { @@ -186,7 +186,7 @@ PSrPartSpec_Draw( b_height = private_data->b_height; } m_height = (UUtUns16)UUmMax(0, inHeight - (t_height + b_height)); - + if ((private_data->l_width + private_data->r_width) > inWidth) { l_width = private_data->l_width * private_data->l_width / inWidth; @@ -198,13 +198,13 @@ PSrPartSpec_Draw( r_width = private_data->r_width; } m_width = (UUtUns16)UUmMax(0, inWidth - (l_width + r_width)); - + if (inFlags == PScPart_MiddleMiddle) { m_height = inHeight; m_width = inWidth; } - + // draw the left column dest = *inLocation; @@ -245,7 +245,7 @@ PSrPartSpec_Draw( shade, inAlpha); } - + // draw the middle column dest = *inLocation; if (inFlags & PScPart_LeftColumn) @@ -290,14 +290,14 @@ PSrPartSpec_Draw( shade, inAlpha); } - + // draw the right column dest = *inLocation; if (inFlags & PScPart_MiddleColumn) { dest.x += private_data->l_width + m_width; } - + if (inFlags & PScPart_RightTop) { M3rDraw_BitmapUV( @@ -348,44 +348,44 @@ PSrPartSpec_GetSize( PStPartSpec_PrivateData *private_data; UUtInt16 width; UUtInt16 height; - + UUmAssert(inPartSpec); - + // get the private data private_data = (PStPartSpec_PrivateData*)TMrTemplate_PrivateData_GetDataPtr(PSgTemplate_PartSpec_PrivateData, inPartSpec); UUmAssert(private_data); - + width = 0; height = 0; - + switch (inPart) { case PScPart_LeftTop: width = private_data->l_width; height = private_data->t_height; break; - + case PScPart_LeftBottom: width = private_data->l_width; height = private_data->b_height; break; - + case PScPart_RightTop: width = private_data->r_width; height = private_data->t_height; break; - + case PScPart_RightBottom: width = private_data->r_width; height = private_data->b_height; break; } - + if (outWidth) { *outWidth = width; } - + if (outHeight) { *outHeight = height; @@ -400,9 +400,9 @@ PSrPartSpec_LoadByType( UUtError error; PStPartSpecList *partspec_list; UUtUns32 i; - + UUrMemory_Block_VerifyList(); - + // get the partspec list error = TMrInstance_GetDataPtr( @@ -413,9 +413,9 @@ PSrPartSpec_LoadByType( { return NULL; } - + UUrMemory_Block_VerifyList(); - + // find the desired partspec in the partspec list for (i = 0; i < partspec_list->num_partspec_descs; i++) { @@ -424,7 +424,7 @@ PSrPartSpec_LoadByType( return partspec_list->partspec_descs[i].partspec; } } - + return NULL; } @@ -472,20 +472,20 @@ PSrInitialize( void) { UUtError error; - + PSgPartSpecUI_Active = NULL; - + error = PSrRegisterTemplates(); UUmError_ReturnOnError(error); - - error = + + error = TMrTemplate_PrivateData_New( PScTemplate_PartSpecification, sizeof(PStPartSpec_PrivateData), PSiPartSpec_ProcHandler, &PSgTemplate_PartSpec_PrivateData); UUmError_ReturnOnErrorMsg(error, "Could not install the proc handler"); - + return UUcError_None; } @@ -495,7 +495,7 @@ PSrRegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register( PScTemplate_PartSpecification, @@ -518,4 +518,4 @@ PSrRegisterTemplates( UUmError_ReturnOnError(error); return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_PartSpecification/WM_PartSpecification.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_PartSpecification/WM_PartSpecification.h index 6f405b3..3858249 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_PartSpecification/WM_PartSpecification.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_PartSpecification/WM_PartSpecification.h @@ -23,12 +23,12 @@ enum PScPartSpecType_BackgroundColor_Red = 0x0003, PScPartSpecType_BackgroundColor_Green = 0x0004, PScPartSpecType_BackgroundColor_Blue = 0x0005, - + PScPartSpecType_BorderType_None = 0x0000, PScPartSpecType_BorderType_Square = 0x0010, PScPartSpecType_BorderType_Curved = 0x0020, PScPartSpecType_BorderType_Bevel = 0x0030, - + PScPartSpecType_BorderColor_None = 0x0000, PScPartSpecType_BorderColor_Black = 0x0100, PScPartSpecType_BorderColor_White = 0x0200, @@ -56,7 +56,7 @@ enum PScPart_MiddleRow = PScPart_LeftMiddle | PScPart_MiddleMiddle | PScPart_RightMiddle, PScPart_BottomRow = PScPart_LeftBottom | PScPart_MiddleBottom | PScPart_RightBottom, PScPart_All = 0xFFFF - + }; enum @@ -80,11 +80,11 @@ typedef UUtUns16 PStPartSpecType; typedef tm_template('P', 'S', 'p', 'c', "Part Specification") PStPartSpec { - + IMtPoint2D part_matrix_tl[3][3]; // [column][row] IMtPoint2D part_matrix_br[3][3]; // [column][row] tm_templateref texture; - + } PStPartSpec; typedef struct PStPartSpec_PrivateData @@ -96,11 +96,11 @@ typedef struct PStPartSpec_PrivateData M3tTextureCoord mt[4]; M3tTextureCoord mm[4]; M3tTextureCoord mb[4]; - + M3tTextureCoord rt[4]; M3tTextureCoord rm[4]; M3tTextureCoord rb[4]; - + UUtInt16 l_width; UUtInt16 r_width; UUtInt16 t_height; @@ -115,7 +115,7 @@ typedef tm_struct PStPartSpecDesc { UUtUns32 partspec_type; tm_templateref partspec; - + } PStPartSpecDesc; #define PScTemplate_PartSpecList UUm4CharToUns32('P', 'S', 'p', 'L') @@ -123,10 +123,10 @@ typedef tm_template('P', 'S', 'p', 'L', "Part Specification List") PStPartSpecList { tm_pad pad[20]; - + tm_varindex UUtUns32 num_partspec_descs; tm_vararray PStPartSpecDesc partspec_descs[1]; - + } PStPartSpecList; // ---------------------------------------------------------------------- @@ -139,82 +139,82 @@ PStPastSpecUI PStPartSpec *border; PStPartSpec *title; PStPartSpec *grow; - + PStPartSpec *close_idle; PStPartSpec *close_pressed; - + PStPartSpec *zoom_idle; PStPartSpec *zoom_pressed; - + PStPartSpec *flatten_idle; PStPartSpec *flatten_pressed; - + // text PStPartSpec *text_caret; - + // box PStPartSpec *outline; - + // button PStPartSpec *button_off; PStPartSpec *default_button; PStPartSpec *button_on; - + // checkbox PStPartSpec *checkbox_on; PStPartSpec *checkbox_off; - + // editfield PStPartSpec *editfield; PStPartSpec *ef_hasfocus; - + // listbox uses editfield - + // menu uses background and outline PStPartSpec *hilite; PStPartSpec *divider; PStPartSpec *check; - + // menubar uses background and hilite - + // popup menu PStPartSpec *popup_menu; - + // progress bar PStPartSpec *progressbar_track; PStPartSpec *progressbar_fill; - + // radio button PStPartSpec *radiobutton_on; PStPartSpec *radiobutton_off; - + // scrollbar PStPartSpec *up_arrow; PStPartSpec *up_arrow_pressed; PStPartSpec *dn_arrow; PStPartSpec *dn_arrow_pressed; PStPartSpec *sb_v_track; - + PStPartSpec *lt_arrow; PStPartSpec *lt_arrow_pressed; PStPartSpec *rt_arrow; PStPartSpec *rt_arrow_pressed; PStPartSpec *sb_h_track; - + PStPartSpec *sb_thumb; - + // slider PStPartSpec *sl_thumb; PStPartSpec *sl_track; - + // Tab PStPartSpec *tab_active; PStPartSpec *tab_inactive; - + // files & folders PStPartSpec *file; PStPartSpec *folder; - + } PStPartSpecUI; // ====================================================================== @@ -235,24 +235,24 @@ PSrPartSpec_GetSize( UUtUns16 inPart, UUtInt16 *outWidth, UUtInt16 *outHeight); - + PStPartSpec* PSrPartSpec_LoadByType( PStPartSpecType inPartSpecType); - + // ---------------------------------------------------------------------- PStPartSpecUI* PSrPartSpecUI_GetActive( void); - + PStPartSpecUI* PSrPartSpecUI_GetByName( const char *inName); - + void PSrPartSpecUI_SetActive( PStPartSpecUI *inPartSpecUI); - + // ---------------------------------------------------------------------- UUtError PSrInitialize( diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Utilities/WM_Utilities.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Utilities/WM_Utilities.c index 10baa1a..cb33234 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Utilities/WM_Utilities.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Utilities/WM_Utilities.c @@ -24,15 +24,15 @@ WMrCreate_Texture( UUtError error; *outTextureRef = NULL; - + // ------------------------------ // create the appropriate texture map // ------------------------------ - if ((inWidth > M3cTextureMap_MaxWidth) || + if ((inWidth > M3cTextureMap_MaxWidth) || (inHeight > M3cTextureMap_MaxHeight)) { M3tTextureMap_Big *texture_big; - + // create a big texture map error = M3rTextureMap_Big_New( @@ -44,13 +44,13 @@ WMrCreate_Texture( "VUrCreate_Texture Big", &texture_big); UUmError_ReturnOnErrorMsg(error, "Unable to create texture map"); - + *outTextureRef = (void*)texture_big; } else { M3tTextureMap *texture; - + // create a texture map error = M3rTextureMap_New( @@ -65,7 +65,7 @@ WMrCreate_Texture( *outTextureRef = (void*)texture; } - + return UUcError_None; } @@ -79,12 +79,12 @@ WMrCreate_StringTexture( UUtRect *outStringBounds) { UUtError error; - + IMtPixel background_color; UUtRect bounds; IMtPoint2D dest; - + UUmAssert(inString); UUmAssert(outStringTexture); UUmAssert(outStringBounds); @@ -94,12 +94,12 @@ WMrCreate_StringTexture( outStringBounds->top = 0; outStringBounds->right = 0; outStringBounds->bottom = 0; - + // ------------------------------ // set the colors to draw with // ------------------------------ background_color = IMrPixel_FromShade(WMcPrefered_PixelType, WMcColor_Background); - + DCrText_SetShade(WMcColor_Text); // ------------------------------ @@ -107,30 +107,30 @@ WMrCreate_StringTexture( // ------------------------------ // set the style DCrText_SetStyle(inStyle); - + // set the format DCrText_SetFormat(inFormat); - + // ------------------------------ // create the appropriate texture map // ------------------------------ // get the bounds of the string DCrText_GetStringRect(inString, &bounds); - + // create the texture error = WMrCreate_Texture(bounds.right, bounds.bottom, outStringTexture); UUmError_ReturnOnErrorMsg(error, "Unable to create texture map"); - + // clear the texture WMrClearTexture(*outStringTexture, NULL, background_color); - + // ------------------------------ // draw the text on the texture // ------------------------------ // set the dest dest.x = 0; dest.y = 0; - + // draw the text into the texture map DCrText_DrawString( *outStringTexture, @@ -139,7 +139,7 @@ WMrCreate_StringTexture( &dest); *outStringBounds = bounds; - + return UUcError_None; } @@ -152,14 +152,14 @@ WMrClearTexture( { TMtTemplateTag tag; UUtRect bounds; - + tag = TMrInstance_GetTemplateTag(inTexture); if (tag == M3cTemplate_TextureMap) { M3tTextureMap *texture; - + texture = (M3tTextureMap*)inTexture; - + if (inBounds == NULL) { bounds.left = 0; @@ -171,16 +171,16 @@ WMrClearTexture( { bounds = *inBounds; } - + // fill the texture map with the background color M3rTextureMap_Fill(texture, inColor, &bounds); } else if (tag == M3cTemplate_TextureMap_Big) { M3tTextureMap_Big *texture_big; - + texture_big = (M3tTextureMap_Big*)inTexture; - + if (inBounds == NULL) { bounds.left = 0; @@ -192,9 +192,9 @@ WMrClearTexture( { bounds = *inBounds; } - + // fill the texture map with the background color M3rTextureMap_Big_Fill(texture_big, inColor, &bounds); } } - \ No newline at end of file + diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Utilities/WM_Utilities.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Utilities/WM_Utilities.h index ca40b97..c24d732 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Utilities/WM_Utilities.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Utilities/WM_Utilities.h @@ -35,4 +35,4 @@ WMrClearTexture( IMtPixel inColor); // ====================================================================== -#endif /* WM_UTILITIES_H */ \ No newline at end of file +#endif /* WM_UTILITIES_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Box.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Box.c index 4f033b1..2ce218d 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Box.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Box.c @@ -25,27 +25,27 @@ WMiBox_Paint( UUtInt16 height; UUtUns32 style; UUtBool enabled; - + partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + WMrWindow_GetSize(inBox, &width, &height); style = WMrWindow_GetStyle(inBox); - + // set dest dest.x = 0; dest.y = 0; - + if (style & WMcBoxStyle_HasTitle) { dest.y = DCrText_GetLineHeight() >> 1; height -= dest.y; } - + draw_context = DCrDraw_Begin(inBox); - + enabled = WMrWindow_GetEnabled(inBox); - + DCrDraw_PartSpec( draw_context, partspec_ui->outline, @@ -54,26 +54,26 @@ WMiBox_Paint( width, height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); - + if (style & WMcBoxStyle_HasTitle) { UUtRect bounds; TStFontInfo font_info; - + WMrWindow_GetFontInfo(inBox, &font_info); DCrText_SetFontInfo(&font_info); - + DCrText_GetStringRect(WMrWindow_GetTitlePtr(inBox), &bounds); IMrRect_Offset(&bounds, 5, 0); - + dest.x = bounds.left; dest.y = bounds.top; - + if (style & WMcBoxStyle_HasBackground) { width = bounds.right - bounds.left; height = bounds.bottom - bounds.top; - + DCrDraw_PartSpec( draw_context, partspec_ui->background, @@ -83,12 +83,12 @@ WMiBox_Paint( height, M3cMaxAlpha); } - + DCrText_SetShade(enabled ? font_info.font_shade : IMcShade_Gray50); DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrDraw_String(draw_context, WMrWindow_GetTitlePtr(inBox), &bounds, &dest); } - + DCrDraw_End(draw_context, inBox); } @@ -111,7 +111,7 @@ WMiBox_Callback( WMiBox_Paint(inBox); return WMcResult_Handled; } - + return WMrWindow_DefaultCallback(inBox, inMessage, inParam1, inParam2); } @@ -127,15 +127,15 @@ WMrBox_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_Box; window_class.callback = WMiBox_Callback; window_class.private_data_size = 0; - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Box.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Box.h index 2a7c607..2685083 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Box.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Box.h @@ -21,10 +21,10 @@ enum WMcBoxStyle_HasOutline = (0x0001 << 16), WMcBoxStyle_HasBackground = (0x0002 << 16), WMcBoxStyle_HasTitle = (0x0004 << 16), - + WMcBoxStyle_PlainBox = (WMcBoxStyle_HasOutline), WMcBoxStyle_GroupBox = (WMcBoxStyle_HasOutline | WMcBoxStyle_HasTitle | WMcBoxStyle_HasBackground) - + }; // ====================================================================== @@ -40,4 +40,4 @@ WMrBox_Initialize( void); // ====================================================================== -#endif /* WM_BOX_H */ \ No newline at end of file +#endif /* WM_BOX_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Button.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Button.c index 28944b6..1d0c388 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Button.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Button.c @@ -26,7 +26,7 @@ enum WMcButtonFlag_None = 0x0000 << 16, WMcButtonFlag_Hilite = 0x0001 << 16, WMcButtonFlag_Toggle = 0x0002 << 16 - + }; // ====================================================================== @@ -43,12 +43,12 @@ WMiButton_Create( WMtButton *inButton) { UUtUns32 button_data; - + // initialize button_data = WMrWindow_GetLong(inButton, 0); button_data = LIcMouseState_None; WMrWindow_SetLong(inButton, 0, button_data); - + if ((WMrWindow_GetStyle(inButton) & WMcButtonStyle_Default) != 0) { WMrMessage_Send( @@ -57,12 +57,12 @@ WMiButton_Create( WMrWindow_GetID(inButton), 0); } - + if (WMgWindow_ClickSound == NULL) { WMgWindow_ClickSound = SSrImpulse_GetByName(WMcButton_ClickSound); } - + return UUcError_None; } @@ -79,21 +79,21 @@ WMiButton_HandleMouseEvent( IMtPoint2D global_mouse; UUtUns32 button_data; UUtUns32 style; - + // get the button data button_data = WMrWindow_GetLong(inButton, 0); - + // get the button style style = WMrWindow_GetStyle(inButton); - + // get the mouse location global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam1); - + // determine if the mouse is over the button WMrWindow_GetRect(inButton, &button_rect); mouse_over_button = IMrRect_PointIn(&button_rect, &global_mouse); - + switch (inMessage) { case WMcMessage_MouseMove: @@ -111,7 +111,7 @@ WMiButton_HandleMouseEvent( WMrWindow_SetLong(inButton, 0, button_data); } break; - + case WMcMessage_LMouseDown: // save the button data changes button_data |= WMcButtonFlag_Hilite; @@ -121,18 +121,18 @@ WMiButton_HandleMouseEvent( WMrWindow_SetFocus(inButton); WMrWindow_CaptureMouse(inButton); break; - + case WMcMessage_LMouseUp: { UUtBool was_down; - + was_down = (UUmLowWord(button_data) == LIcMouseState_LButtonDown); - + // save the button data changes button_data &= ~WMcButtonFlag_Hilite; button_data &= ~LIcMouseState_LButtonDown; WMrWindow_SetLong(inButton, 0, button_data); - + WMrWindow_CaptureMouse(NULL); if ((mouse_over_button) && (was_down == UUcTrue)) { @@ -142,7 +142,7 @@ WMiButton_HandleMouseEvent( SSrImpulse_Play(WMgWindow_ClickSound, NULL, NULL, NULL, NULL); } #endif - + // tell the parent WMrMessage_Send( WMrWindow_GetParent(inButton), @@ -169,25 +169,25 @@ WMiButton_Paint( UUtUns32 style; PStPartSpec *part; UUtBool enabled; - + partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) return; draw_context = DCrDraw_Begin(inButton); - + enabled = WMrWindow_GetEnabled(inButton); style = WMrWindow_GetStyle(inButton); - + // set the dest dest.x = 0; dest.y = 0; - + // get the window rect WMrWindow_GetSize(inButton, &width, &height); - + // get the button data button_data = WMrWindow_GetLong(inButton, 0); - + // draw the background if (style & WMcButtonStyle_HasBackground) { @@ -217,23 +217,23 @@ WMiButton_Paint( height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); } - + // draw the title if (style & WMcButtonStyle_HasTitle) { UUtRect bounds; TStFontInfo font_info; - + WMrWindow_GetFontInfo(inButton, &font_info); DCrText_SetFontInfo(&font_info); - + WMrWindow_GetClientRect(inButton, &bounds); - + DCrText_SetShade(enabled ? font_info.font_shade : IMcShade_Gray50); DCrText_SetFormat(TSc_HCenter | TSc_VCenter); DCrDraw_String(draw_context, WMrWindow_GetTitlePtr(inButton), &bounds, &dest); } - + DCrDraw_End(draw_context, inButton); } @@ -245,14 +245,14 @@ WMiButton_HandleSetToggle( { UUtUns32 style; UUtUns32 button_data; - + // make sure this is a toggle button style = WMrWindow_GetStyle(inButton); if ((style & WMcButtonStyle_Toggle) == 0) { return; } - + // get the button data button_data = WMrWindow_GetLong(inButton, 0); - + if (inToggle == UUcTrue) { button_data |= WMcButtonFlag_Toggle; @@ -261,7 +261,7 @@ WMiButton_HandleSetToggle( { button_data &= ~WMcButtonFlag_Toggle; } - + // set the button data WMrWindow_SetLong(inButton, 0, button_data); } @@ -280,12 +280,12 @@ WMiButton_Callback( UUtUns32 inParam2) { UUtError error; - + switch(inMessage) { case WMcMessage_NC_HitTest: return WMcWindowArea_Client; - + case WMcMessage_Create: error = WMiButton_Create(inButton); if (error != UUcError_None) @@ -293,29 +293,29 @@ WMiButton_Callback( return WMcResult_Error; } return WMcResult_Handled; - + case WMcMessage_MouseMove: case WMcMessage_LMouseDown: case WMcMessage_LMouseUp: WMiButton_HandleMouseEvent(inButton, inMessage, inParam1, inParam2); return WMcResult_Handled; - + case WMcMessage_Paint: WMiButton_Paint(inButton); return WMcResult_Handled; - + case WMcMessage_GetDialogCode: if ((WMrWindow_GetStyle(inButton) & WMcButtonStyle_Default) != 0) { return WMcDialogCode_Default; } break; - + case TBcMessage_SetToggle: WMiButton_HandleSetToggle(inButton, (UUtBool)inParam1); return WMcResult_Handled; } - + return WMrWindow_DefaultCallback(inButton, inMessage, inParam1, inParam2); } @@ -331,16 +331,16 @@ WMrButton_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_Button; window_class.callback = WMiButton_Callback; window_class.private_data_size = sizeof(UUtUns32); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Button.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Button.h index 27c806e..8626750 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Button.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Button.h @@ -23,7 +23,7 @@ enum WMcButtonStyle_HasIcon = (0x0004 << 16), /* not supported yet */ WMcButtonStyle_Toggle = (0x0008 << 16), WMcButtonStyle_Default = (0x0010 << 16), - + WMcButtonStyle_PushButton = (WMcButtonStyle_HasBackground | WMcButtonStyle_HasTitle), WMcButtonStyle_DefaultPushButton = (WMcButtonStyle_HasBackground | WMcButtonStyle_HasTitle | WMcButtonStyle_Default), WMcButtonStyle_IconButton = (WMcButtonStyle_HasBackground | WMcButtonStyle_HasIcon), @@ -48,4 +48,4 @@ WMrButton_IsHighlighted( WMtWindow *inWindow); // ====================================================================== -#endif /* WM_BUTTON_H */ \ No newline at end of file +#endif /* WM_BUTTON_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_CheckBox.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_CheckBox.c index a555f39..c7b52d0 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_CheckBox.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_CheckBox.c @@ -24,7 +24,7 @@ enum { WMcCheckBoxFlag_None = 0x0000 << 16, WMcCheckBoxFlag_On = 0x0001 << 16 - + }; // ====================================================================== @@ -36,12 +36,12 @@ WMiCheckBox_Create( WMtCheckBox *inCheckBox) { UUtUns32 checkbox_data; - + // initialize checkbox_data = WMrWindow_GetLong(inCheckBox, 0); checkbox_data = 0; WMrWindow_SetLong(inCheckBox, 0, checkbox_data); - + return UUcError_None; } @@ -58,18 +58,18 @@ WMiCheckBox_HandleMouseEvent( IMtPoint2D global_mouse; UUtUns32 checkbox_data; UUtBool notify; - + // get the checkbox data checkbox_data = WMrWindow_GetLong(inCheckBox, 0); - + // get the mouse location global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam1); - + // determine if the mouse is over the checkbox WMrWindow_GetRect(inCheckBox, &checkbox_rect); mouse_over_checkbox = IMrRect_PointIn(&checkbox_rect, &global_mouse); - + // handle the message notify = UUcFalse; switch (inMessage) @@ -79,7 +79,7 @@ WMiCheckBox_HandleMouseEvent( WMrWindow_CaptureMouse(inCheckBox); checkbox_data |= LIcMouseState_LButtonDown; break; - + case WMcMessage_LMouseUp: WMrWindow_CaptureMouse(NULL); if ((mouse_over_checkbox) && @@ -93,13 +93,13 @@ WMiCheckBox_HandleMouseEvent( { checkbox_data |= WMcCheckBoxFlag_On; } - + notify = UUcTrue; } checkbox_data &= ~LIcMouseState_LButtonDown; break; } - + // save the checkbox data WMrWindow_SetLong(inCheckBox, 0, checkbox_data); @@ -129,32 +129,32 @@ WMiCheckBox_Paint( UUtUns32 style; PStPartSpec *part; UUtBool enabled; - + // get the checkbox_data checkbox_data = WMrWindow_GetLong(inCheckBox, 0); - + // get partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + // get the window size WMrWindow_GetSize(inCheckBox, NULL, &height); - + // get the partspec size PSrPartSpec_GetSize( partspec_ui->checkbox_on, PScPart_LeftTop, &part_width, &part_height); - - // calculate the location for the part + + // calculate the location for the part dest.x = 0; dest.y = (height - part_height) >> 1; draw_context = DCrDraw_Begin(inCheckBox); - + enabled = WMrWindow_GetEnabled(inCheckBox); - + // draw the checkbox if (checkbox_data & WMcCheckBoxFlag_On) { @@ -163,7 +163,7 @@ WMiCheckBox_Paint( else { part = partspec_ui->checkbox_off; - } + } DCrDraw_PartSpec( draw_context, @@ -173,26 +173,26 @@ WMiCheckBox_Paint( part_width, part_height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); - + // draw the title style = WMrWindow_GetStyle(inCheckBox); if (style & WMcCheckBoxStyle_HasTitle) { UUtRect bounds; TStFontInfo font_info; - + WMrWindow_GetFontInfo(inCheckBox, &font_info); DCrText_SetFontInfo(&font_info); - + dest.x = part_width + WMcCheckBox_Buffer; - + WMrWindow_GetClientRect(inCheckBox, &bounds); - + DCrText_SetShade(enabled ? font_info.font_shade : IMcShade_Gray50); DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrDraw_String(draw_context, WMrWindow_GetTitlePtr(inCheckBox), &bounds, &dest); } - + DCrDraw_End(draw_context, inCheckBox); } @@ -212,15 +212,15 @@ WMiCheckBox_Callback( UUtError error; UUtUns32 result; UUtUns32 checkbox_data; - + // get the checkbox_data checkbox_data = WMrWindow_GetLong(inCheckBox, 0); - + switch(inMessage) { case WMcMessage_NC_HitTest: return WMcWindowArea_Client; - + case WMcMessage_Create: error = WMiCheckBox_Create(inCheckBox); if (error != UUcError_None) @@ -228,7 +228,7 @@ WMiCheckBox_Callback( return WMcResult_Error; } return WMcResult_Handled; - + case WMcMessage_LMouseDown: case WMcMessage_LMouseUp: WMiCheckBox_HandleMouseEvent( @@ -241,7 +241,7 @@ WMiCheckBox_Callback( case WMcMessage_Paint: WMiCheckBox_Paint(inCheckBox); return WMcResult_Handled; - + case WMcMessage_GetValue: if (checkbox_data & WMcCheckBoxFlag_On) { @@ -265,7 +265,7 @@ WMiCheckBox_Callback( WMrWindow_SetLong(inCheckBox, 0, checkbox_data); return WMcResult_Handled; } - + return WMrWindow_DefaultCallback(inCheckBox, inMessage, inParam1, inParam2); } @@ -281,24 +281,24 @@ WMrCheckBox_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_CheckBox; window_class.callback = WMiCheckBox_Callback; window_class.private_data_size = sizeof(UUtUns32); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; } -void +void WMrCheckBox_SetCheck(WMtCheckBox *inCheckBox, UUtBool inValue) { WMrMessage_Send(inCheckBox, CBcMessage_SetCheck, inValue, 0); - + return; } diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_CheckBox.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_CheckBox.h index 8b8eea9..8d58925 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_CheckBox.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_CheckBox.h @@ -20,10 +20,10 @@ enum WMcCheckBoxStyle_None = (0x0000 << 16), WMcCheckBoxStyle_HasTitle = (0x0001 << 16), WMcCheckBoxStyle_HasIcon = (0x0002 << 16), /* not supported yet */ - + WMcCheckBoxStyle_TextCheckBox = (WMcCheckBoxStyle_HasTitle), WMcCheckBoxStyle_IconCheckBox = (WMcCheckBoxStyle_HasIcon) - + }; // ====================================================================== @@ -38,11 +38,11 @@ UUtError WMrCheckBox_Initialize( void); -void +void WMrCheckBox_SetCheck(WMtCheckBox *inCheckBox, UUtBool inValue); UUtBool WMrCheckBox_GetCheck(WMtCheckBox *inCheckBox); // ====================================================================== -#endif /* WM_CHECKBOX_H */ \ No newline at end of file +#endif /* WM_CHECKBOX_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_EditField.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_EditField.c index 5f788bc..bfd1a9c 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_EditField.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_EditField.c @@ -38,13 +38,13 @@ typedef struct WMtEditField_PrivateData { UUtUns16 max_chars; char *string; - + UUtUns32 editfield_data; UUtInt32 insert_before; UUtUns16 insert_segment; - + UUtRect text_bounds; - + } WMtEditField_PrivateData; // ====================================================================== @@ -64,26 +64,26 @@ WMiEditField_SetCaretPosition( TStStringFormat string_format; UUtUns16 index_in_segment; TStFontInfo font_info; - + WMrWindow_GetFontInfo(inEditField, &font_info); DCrText_SetFontInfo(&font_info); - + // if this edit field doesn't have the focus then don't set the caret's position if ((inPrivateData->editfield_data & WMcEditFieldFlag_HasFocus) == 0) { return; } - + // generate a formated string if one hasn't been supplied if (inStringFormat == NULL) { UUtError error; IMtPoint2D dest; - + // format the text dest.x = inPrivateData->text_bounds.left + WMcEditField_Text_Buffer; dest.y = inPrivateData->text_bounds.top + DCrText_GetAscendingHeight() + DCrText_GetLeadingHeight(); - + error = TSrContext_FormatString( DCrText_GetTextContext(), @@ -92,10 +92,10 @@ WMiEditField_SetCaretPosition( &dest, &string_format); if (error != UUcError_None) { return; } - + inStringFormat = &string_format; } - + // figure out which segment the caret should be on index_in_segment = (UUtUns16) inPrivateData->insert_before; for (i = 0; i < inStringFormat->num_segments; i++) @@ -119,7 +119,7 @@ WMiEditField_SetCaretPosition( { UUtUns16 character; UUtUns16 width; - + character = TSrString_GetCharacterAtIndex(inStringFormat->segments[inPrivateData->insert_segment], i); TSrFont_GetCharacterSize(font, character, &width, NULL); x += (UUtInt16)width; @@ -156,17 +156,17 @@ WMiEditField_SetInsertBeforeFromPoint( IMtPoint2D dest; UUtInt16 test; TStFontInfo font_info; - + WMrWindow_GetFontInfo(inEditField, &font_info); DCrText_SetFontInfo(&font_info); - + // format the text dest.x = inPrivateData->text_bounds.left + WMcEditField_Text_Buffer; dest.y = inPrivateData->text_bounds.top + DCrText_GetAscendingHeight() + DCrText_GetLeadingHeight(); - + error = TSrContext_FormatString( DCrText_GetTextContext(), @@ -175,19 +175,19 @@ WMiEditField_SetInsertBeforeFromPoint( &dest, &string_format); if (error != UUcError_None) { return; } - + // find out which line the user clicked in inPrivateData->insert_before = 0; segment_index = 0; for (i = 0; i < string_format.num_lines; i++) { test = string_format.bounds[segment_index].bottom; - + if (inLocalPoint->y < test) { break; } - + for (j = 0; j < string_format.line_num_segments[i]; j++, segment_index++) { inPrivateData->insert_before += string_format.num_characters[segment_index]; } @@ -212,34 +212,34 @@ WMiEditField_SetInsertBeforeFromPoint( x = string_format.bounds[segment_index].left + WMcEditField_Text_Buffer; string_length = TSrString_GetLength(string_format.segments[segment_index]); font = DCrText_GetFont(); - + for (i = 0; i < string_length; i++) { UUtUns16 character; UUtUns16 width; - + character = TSrString_GetCharacterAtIndex(string_format.segments[segment_index], i); TSrFont_GetCharacterSize(font, character, &width, NULL); - + // when testing the position, test to see if the user clicked // in the first half of the character test = x + (width >> 1); - + if (inLocalPoint->x < test) { break; } - + // add in the second half of the character x += width; } - + // i is the index of the character that the insertion point should go before // note that i == string_length, a point in the string wasn't found, the // user clicked beyond the text so we put the insert before point at the end of the string. inPrivateData->insert_before += i; } - + // update the caret position WMiEditField_SetCaretPosition(inEditField, inPrivateData, &string_format); } @@ -260,49 +260,49 @@ WMiEditField_Create( UUtInt16 right_width; UUtInt16 bottom_height; WMtEditField_PrivateData *private_data; - + // create the private data - private_data = + private_data = (WMtEditField_PrivateData*)UUrMemory_Block_NewClear( sizeof(WMtEditField_PrivateData)); UUmError_ReturnOnNull(private_data); WMrWindow_SetLong(inEditField, 0, (UUtUns32)private_data); - + // initialize private_data->max_chars = WMcEditField_DefaultMaxChars; private_data->string = NULL; private_data->editfield_data = WMcEditFieldFlag_None; private_data->insert_before = 0; - + // allocate memory for the string private_data->string = UUrMemory_Block_NewClear(private_data->max_chars + 1); UUmError_ReturnOnNull(private_data->string); - + // get the active partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return UUcError_Generic; } - + // get the size of the parts PSrPartSpec_GetSize( partspec_ui->editfield, PScPart_LeftTop, &left_width, &top_height); - + PSrPartSpec_GetSize( partspec_ui->editfield, PScPart_RightBottom, &right_width, &bottom_height); - + // set the text bounds WMrWindow_GetClientRect(inEditField, &private_data->text_bounds); - + private_data->text_bounds.left += left_width; private_data->text_bounds.top += top_height; private_data->text_bounds.right -= right_width; private_data->text_bounds.bottom -= bottom_height; - + return UUcError_None; } @@ -312,18 +312,18 @@ WMiEditField_Destroy( WMtEditField *inEditField) { WMtEditField_PrivateData *private_data; - + // get the private data private_data = (WMtEditField_PrivateData*)WMrWindow_GetLong(inEditField, 0); if (private_data == NULL) { return; } - + // delete the string if (private_data->string) { UUrMemory_Block_Delete(private_data->string); private_data->string = NULL; } - + // delete the private data UUrMemory_Block_Delete(private_data); WMrWindow_SetLong(inEditField, 0, 0); @@ -335,7 +335,7 @@ WMiEditField_HandleGetDialogCode( WMtEditField *inEditField) { UUtUns32 result; - + result = WMcDialogCode_WantDigits | WMcDialogCode_WantPunctuation | @@ -345,7 +345,7 @@ WMiEditField_HandleGetDialogCode( { result |= WMcDialogCode_WantAlphas; } - + return result; } @@ -357,7 +357,7 @@ static UUtUns32 WMiEditField_HandleGetFloat( UUtError error; WMtEditField_PrivateData *private_data; - + private_data = (WMtEditField_PrivateData*)WMrWindow_GetLong(inEditField, 0); if (private_data == NULL) { return UUcError_Generic; } @@ -376,7 +376,7 @@ static UUtUns32 WMiEditField_HandleGetInt( UUtError error; WMtEditField_PrivateData *private_data; - + private_data = (WMtEditField_PrivateData*)WMrWindow_GetLong(inEditField, 0); if (private_data == NULL) { return UUcError_Generic; } @@ -396,14 +396,14 @@ WMiEditField_HandleGetText( { WMtEditField_PrivateData *private_data; UUtUns32 string_length; - + private_data = (WMtEditField_PrivateData*)WMrWindow_GetLong(inEditField, 0); if (private_data == NULL) { return 0; } if (private_data->string == NULL) { return 0; } - + string_length = TSrString_GetLength(private_data->string); UUrString_Copy(outStringBuffer, private_data->string, inStringBufferLength); - + return string_length; } @@ -418,31 +418,31 @@ WMiEditField_HandleKeyDown( UUtUns16 string_length; UUtBool notify_parent; UUtBool inserted; - + // disabled edit fields don't handle key events if (WMrWindow_GetEnabled(inEditField) == UUcFalse) { return; } - + private_data = (WMtEditField_PrivateData*)WMrWindow_GetLong(inEditField, 0); if (private_data == NULL) { return; } if (private_data->string == NULL) { return; } - + style = WMrWindow_GetStyle(inEditField); - + notify_parent = UUcTrue; - string_length = TSrString_GetLength(private_data->string); - + string_length = TSrString_GetLength(private_data->string); + switch (inKey) { case LIcKeyCode_Tab: { UUtUns32 i; - + if (style & WMcEditFieldStyle_NumbersOnly) { break; } - + // insert 4 spaces for (i = 0; i < 4; i ++) { - inserted = + inserted = TSrString_InsertChar( private_data->string, (UUtUns16)private_data->insert_before, @@ -455,7 +455,7 @@ WMiEditField_HandleKeyDown( } } break; - + case LIcKeyCode_BackSpace: if (private_data->insert_before > 0) { @@ -463,18 +463,18 @@ WMiEditField_HandleKeyDown( private_data->string, (private_data->insert_before - 1), private_data->max_chars); - + private_data->insert_before--; } break; - + case LIcKeyCode_Delete: /* forward delete */ TSrString_DeleteChar( private_data->string, (UUtUns16)private_data->insert_before, private_data->max_chars); break; - + case LIcKeyCode_Return: case LIcKeyCode_PageUp: case LIcKeyCode_PageDown: @@ -485,7 +485,7 @@ WMiEditField_HandleKeyDown( case LIcKeyCode_DownArrow: notify_parent = UUcFalse; break; - + case LIcKeyCode_RightArrow: if (private_data->insert_before < string_length) { @@ -493,7 +493,7 @@ WMiEditField_HandleKeyDown( } notify_parent = UUcFalse; break; - + case LIcKeyCode_LeftArrow: if (private_data->insert_before > 0) { @@ -501,7 +501,7 @@ WMiEditField_HandleKeyDown( } notify_parent = UUcFalse; break; - + default: // check the numbers only style if ((style & WMcEditFieldStyle_NumbersOnly) && @@ -514,7 +514,7 @@ WMiEditField_HandleKeyDown( notify_parent = UUcFalse; break; } - + // insert the key into the string inserted = TSrString_InsertChar( @@ -528,7 +528,7 @@ WMiEditField_HandleKeyDown( } break; } - + // update the caret position WMiEditField_SetCaretPosition(inEditField, private_data, NULL); @@ -552,16 +552,16 @@ WMiEditField_HandleMouseEvent( WMtEditField_PrivateData *private_data; IMtPoint2D global_mouse; IMtPoint2D local_mouse; - + // get the private data private_data = (WMtEditField_PrivateData*)WMrWindow_GetLong(inEditField, 0); if (private_data == NULL) { return; } - + // get the mouse in local coordinates global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam1); WMrWindow_GlobalToLocal(inEditField, &global_mouse, &local_mouse); - + // set the position of the cursor if (private_data->editfield_data & WMcEditFieldFlag_FocusClick) { @@ -571,7 +571,7 @@ WMiEditField_HandleMouseEvent( { WMiEditField_SetInsertBeforeFromPoint(inEditField, private_data, &local_mouse); } - + // notify the parent of the click WMrMessage_Send( WMrWindow_GetParent(inEditField), @@ -587,15 +587,15 @@ WMiEditField_HandleSetFocus( UUtBool inHasFocus) { WMtEditField_PrivateData *private_data; - + // get the private data private_data = (WMtEditField_PrivateData*)WMrWindow_GetLong(inEditField, 0); if (private_data == NULL) { return; } - + if (inHasFocus) { private_data->editfield_data |= (WMcEditFieldFlag_HasFocus | WMcEditFieldFlag_FocusClick); - + // initialize the caret WMrCaret_Create( inEditField, @@ -607,7 +607,7 @@ WMiEditField_HandleSetFocus( else { private_data->editfield_data &= ~WMcEditFieldFlag_HasFocus; - + // destroy the caret WMrCaret_Destroy(); } @@ -621,28 +621,28 @@ WMiEditField_HandleSetMaxChars( { WMtEditField_PrivateData *private_data; char *new_string; - + // get the private data private_data = (WMtEditField_PrivateData*)WMrWindow_GetLong(inEditField, 0); if (private_data == NULL) { return UUcError_None; } - + // set the new number of maximum characters private_data->max_chars = (UUtUns16)inMaxChars; - + // allocate memory for the string new_string = UUrMemory_Block_NewClear(private_data->max_chars + 1); UUmError_ReturnOnNull(new_string); - + // copy the data from the old string to the new string UUrString_Copy(new_string, private_data->string, (private_data->max_chars + 1)); - + // delete the old string UUrMemory_Block_Delete(private_data->string); - + // set the string to the new string private_data->string = new_string; - - return UUcError_None; + + return UUcError_None; } // ---------------------------------------------------------------------- @@ -652,11 +652,11 @@ WMiEditField_HandleSetText( char *inString) { WMtEditField_PrivateData *private_data; - + private_data = (WMtEditField_PrivateData*)WMrWindow_GetLong(inEditField, 0); if (private_data == NULL) { return; } if (private_data->string == NULL) { return; } - + UUrString_Copy(private_data->string, inString, (private_data->max_chars + 1)); private_data->insert_before = TSrString_GetLength(private_data->string); WMiEditField_SetCaretPosition(inEditField, private_data, NULL); @@ -676,26 +676,26 @@ WMiEditField_Paint( UUtBool enabled; UUtBool has_focus; TStFontInfo font_info; - + // get the private_data private_data = (WMtEditField_PrivateData*)WMrWindow_GetLong(inEditField, 0); if (private_data == NULL) { return; } - + // get the active partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + WMrWindow_GetSize(inEditField, &width, &height); - + draw_context = DCrDraw_Begin(inEditField); - + enabled = WMrWindow_GetEnabled(inEditField); has_focus = (private_data->editfield_data & WMcEditFieldFlag_HasFocus) != 0; - + // set dest dest.x = 0; dest.y = 0; - + // draw the background DCrDraw_PartSpec( draw_context, @@ -705,20 +705,20 @@ WMiEditField_Paint( width, height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); - + dest.x = private_data->text_bounds.left; dest.y = private_data->text_bounds.top; - + WMrWindow_GetFontInfo(inEditField, &font_info); DCrText_SetFontInfo(&font_info); - + DCrText_SetShade(enabled ? font_info.font_shade : IMcShade_Gray50); DCrText_SetFormat(TSc_HLeft); dest.x += WMcEditField_Text_Buffer; dest.y += DCrText_GetAscendingHeight() + DCrText_GetLeadingHeight(); - + DCrDraw_String(draw_context, private_data->string, &private_data->text_bounds, &dest); - + DCrDraw_End(draw_context, inEditField); } @@ -737,12 +737,12 @@ WMiEditField_Callback( { UUtError error; UUtUns32 result; - + switch(inMessage) { case WMcMessage_NC_HitTest: return WMcWindowArea_Client; - + case WMcMessage_Create: error = WMiEditField_Create(inEditField); if (error != UUcError_None) @@ -750,30 +750,30 @@ WMiEditField_Callback( return WMcResult_Error; } return WMcResult_Handled; - + case WMcMessage_Destroy: WMiEditField_Destroy(inEditField); return WMcResult_Handled; - + case WMcMessage_Paint: WMiEditField_Paint(inEditField); return WMcResult_Handled; - + case WMcMessage_KeyDown: WMiEditField_HandleKeyDown(inEditField, (UUtUns16)inParam1); return WMcResult_Handled; - + case WMcMessage_LMouseDown: if (WMrWindow_GetFocus() != inEditField) { WMrWindow_SetFocus(inEditField); } return WMcResult_Handled; - + case WMcMessage_LMouseUp: WMiEditField_HandleMouseEvent(inEditField, inParam1); return WMcResult_Handled; - + case WMcMessage_SetFocus: WMiEditField_HandleSetFocus(inEditField, UUcTrue); return WMcResult_Handled; @@ -781,7 +781,7 @@ WMiEditField_Callback( case WMcMessage_KillFocus: WMiEditField_HandleSetFocus(inEditField, UUcFalse); return WMcResult_Handled; - + case EFcMessage_GetText: result = WMiEditField_HandleGetText(inEditField, (char*)inParam1, inParam2); return result; @@ -801,12 +801,12 @@ WMiEditField_Callback( case EFcMessage_SetText: WMiEditField_HandleSetText(inEditField, (char*)inParam1); return WMcResult_Handled; - + case WMcMessage_GetDialogCode: result = WMiEditField_HandleGetDialogCode(inEditField); return result; } - + return WMrWindow_DefaultCallback(inEditField, inMessage, inParam1, inParam2); } @@ -822,16 +822,16 @@ WMrEditField_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_EditField; window_class.callback = WMiEditField_Callback; window_class.private_data_size = sizeof(WMtEditField_PrivateData*); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -841,7 +841,7 @@ WMrEditField_GetInt32(WMtEditField *inEditField) { UUtInt32 edit_field_number; UUtError error; - + error = (UUtError) WMrMessage_Send(inEditField, EFcMessage_GetInt, (UUtUns32) &edit_field_number, 0); if (UUcError_None != error) { @@ -856,7 +856,7 @@ WMrEditField_GetFloat(WMtEditField *inEditField) { float edit_field_number; UUtError error; - + error = (UUtError) WMrMessage_Send(inEditField, EFcMessage_GetFloat, (UUtUns32) &edit_field_number, 0); if (UUcError_None != error) { @@ -893,7 +893,7 @@ WMrEditField_SetFloat(WMtEditField *inEditField, float inFloat) buffer[--len] = '\0'; } } - + WMrMessage_Send(inEditField, EFcMessage_SetText, (UUtUns32) buffer, 0); return; diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_EditField.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_EditField.h index c9642c8..06e1748 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_EditField.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_EditField.h @@ -19,7 +19,7 @@ enum { WMcEditFieldStyle_None = (0x0000 << 16), WMcEditFieldStyle_NumbersOnly = (0x0001 << 16) - + }; enum @@ -58,4 +58,4 @@ void WMrEditField_GetText(WMtEditField *inEditField, char *outString, UUtUns32 inStringLength); // ====================================================================== -#endif /* WM_EDITFIELD_H */ \ No newline at end of file +#endif /* WM_EDITFIELD_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ListBox.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ListBox.c index b46e27e..2584c84 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ListBox.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ListBox.c @@ -39,26 +39,26 @@ typedef struct WMtListBox_PrivateData UUtUns16 mouse_state; UUtBool double_click; UUtBool has_focus; - + UUtUns32 key_down_delta; char prefix_buffer[LBcDefaultCharsPerItem]; - + // item data UUtMemory_Array *item_array; UUtUns32 num_visible_items; - + UUtInt16 item_width; UUtInt16 item_height; - + UUtUns32 start_index; /* index of first item displayed */ - + // scrollbar data WMtScrollbar *v_scrollbar; UUtInt32 v_scroll_max; UUtInt32 v_scroll_pos; - + float start_ratio; /* used to convert from v_scroll_pos to start_index */ - + } WMtListBox_PrivateData; // ---------------------------------------------------------------------- @@ -71,7 +71,7 @@ typedef struct WMtListBox_Item UUtInt16 height; UUtBool selected; - + } WMtListBox_Item; // ====================================================================== @@ -80,11 +80,11 @@ typedef struct WMtListBox_Item static void WMiListBox_HandleFontInfoChanged( WMtListBox *inListBox); - + static UUtUns32 WMiListBox_GetSelection( WMtListBox *inListBox); - + static UUtUns32 WMiListBox_InsertString( WMtListBox *inListBox, @@ -94,19 +94,19 @@ WMiListBox_InsertString( static UUtUns32 WMiListBox_Reset( WMtListBox *inListBox); - + static UUtUns32 WMiListBox_SetItemData( WMtListBox *inListBox, UUtUns32 inItemIndex, UUtUns32 inParam1); - + static UUtUns32 WMiListBox_SetSelection( WMtListBox *inListBox, UUtUns32 inItemIndex, UUtBool inNotifyParent); - + // ====================================================================== // functions // ====================================================================== @@ -117,9 +117,9 @@ WMiListBox_AdjustScrollbar( WMtListBox_PrivateData *inPrivateData) { UUtUns32 num_items; - + num_items = UUrMemory_Array_GetUsedElems(inPrivateData->item_array); - + // make sure the start_index is the proper distance from the last item if ((num_items > inPrivateData->num_visible_items) && ((inPrivateData->start_index + inPrivateData->num_visible_items) > num_items)) @@ -127,15 +127,15 @@ WMiListBox_AdjustScrollbar( inPrivateData->start_index = num_items - inPrivateData->num_visible_items; UUmAssert((UUtInt32)inPrivateData->start_index >= 0); } - + // calculate the scroll max inPrivateData->v_scroll_max = UUmMax(0, num_items); - + // calculate the scroll position inPrivateData->v_scroll_pos = (UUtInt32)((float)inPrivateData->start_index * ((float)num_items / (float)inPrivateData->num_visible_items)); - + // set the scrollbar range and position WMrScrollbar_SetRange( inPrivateData->v_scrollbar, @@ -164,13 +164,13 @@ WMiListBox_FindInsertPos( WMtListBox_Item *items; UUtUns32 i; UUtUns32 num_items; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + style = WMrWindow_GetStyle(inListBox); - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); if (items == NULL) @@ -179,12 +179,12 @@ WMiListBox_FindInsertPos( *outInsertIndex = -1; return LBcNoError; } - + num_items = UUrMemory_Array_GetUsedElems(private_data->item_array); for (i = 0; i < num_items; i++) { UUtInt32 result; - + // compare the items based on the style of the listbox if (style & WMcListBoxStyle_HasStrings) { @@ -193,14 +193,14 @@ WMiListBox_FindInsertPos( else if (style & WMcListBoxStyle_OwnerDraw) { WMtCompareItems compare_items; - + compare_items.window = inListBox; compare_items.window_id = WMrWindow_GetID(inListBox); compare_items.item1_index = (UUtUns32)-1; compare_items.item1_data = inParam1; compare_items.item2_index = i; compare_items.item2_data = items[i].data; - + result = (UUtInt8)WMrMessage_Send( WMrWindow_GetOwner(inListBox), @@ -212,13 +212,13 @@ WMiListBox_FindInsertPos( { return LBcError; } - + // stop if inParam1 goes before the item if (result < 0) { break; } } - + *outInsertIndex = i; - + return LBcNoError; } @@ -232,14 +232,14 @@ WMiListBox_FindPrefix( WMtListBox_Item *items; UUtUns32 style; UUtUns32 i; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return; } - + style = WMrWindow_GetStyle(inListBox); if ((style & WMcListBoxStyle_HasStrings) == 0) { return; } - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); for (i = 0; i < UUrMemory_Array_GetUsedElems(private_data->item_array); i++) @@ -247,7 +247,7 @@ WMiListBox_FindPrefix( if (UUrString_Compare_NoCase((char*)items[i].string, inPrefix) >= 0) { WMiListBox_SetSelection(inListBox, i, UUcTrue); - break; + break; } } } @@ -265,13 +265,13 @@ WMiListBox_NC_Create( WMtListBox_PrivateData *private_data; // create the private data - private_data = + private_data = (WMtListBox_PrivateData*)UUrMemory_Block_NewClear(sizeof(WMtListBox_PrivateData)); if (private_data == NULL) { return WMcResult_Error; } - + // save the private data WMrWindow_SetLong(inListBox, 0, (UUtUns32)private_data); - + return WMcResult_Handled; } @@ -281,11 +281,11 @@ WMiListBox_NC_Destroy( WMtListBox *inListBox) { WMtListBox_PrivateData *private_data; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return; } - + UUrMemory_Block_Delete(private_data); WMrWindow_SetLong(inListBox, 0, 0); } @@ -300,18 +300,18 @@ WMiListBox_NC_Paint( IMtPoint2D dest; UUtInt16 width; UUtInt16 height; - + partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + WMrWindow_GetSize(inListBox, &width, &height); - + draw_context = DCrDraw_NC_Begin(inListBox); - + // set the dest dest.x = 0; dest.y = 0; - + // draw the outline DCrDraw_PartSpec( draw_context, @@ -321,7 +321,7 @@ WMiListBox_NC_Paint( width, height, M3cMaxAlpha); - + DCrDraw_NC_End(draw_context, inListBox); } @@ -336,27 +336,27 @@ WMiListBox_NC_CalcClientSize( UUtInt16 window_height; UUtInt16 part_width; UUtInt16 part_height; - + WMrWindow_GetSize(inListBox, &window_width, &window_height); - + partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + PSrPartSpec_GetSize( partspec_ui->editfield, PScPart_LeftTop, &part_width, &part_height); - + outRect->left = part_width; outRect->top = part_height; - + PSrPartSpec_GetSize( partspec_ui->editfield, PScPart_RightBottom, &part_width, &part_height); - + outRect->right = window_width - part_width; outRect->bottom = window_height - part_height; } @@ -371,20 +371,20 @@ WMiListBox_NC_HitTest( IMtPoint2D global_mouse; IMtPoint2D local_mouse; WMtWindowArea part; - + part = WMcWindowArea_None; global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam1); - + WMrWindow_GlobalToLocal(inListBox, &global_mouse, &local_mouse); - + WMrWindow_GetClientRect(inListBox, &bounds); if (IMrRect_PointIn(&bounds, &local_mouse)) { part = WMcWindowArea_Client; } - + return (UUtUns32)part; } @@ -400,13 +400,13 @@ WMiListBox_Create( { WMtListBox_PrivateData *private_data; UUtUns32 style; - + // ------------------------------ // create the private data // ------------------------------ private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { goto cleanup; } - + // ------------------------------ // initialize the item array // ------------------------------ @@ -418,7 +418,7 @@ WMiListBox_Create( 0, LBcDefaultNumItems); if (private_data->item_array == NULL) { goto cleanup; } - + // ------------------------------ // create the scrollbars // ------------------------------ @@ -440,17 +440,17 @@ WMiListBox_Create( 0); if (private_data->v_scrollbar == NULL) { goto cleanup; } } - + // ------------------------------ // calculate the sizes // ------------------------------ WMiListBox_HandleFontInfoChanged(inListBox); - + return WMcResult_Handled; cleanup: UUmAssert(0); - + if (private_data) { if (private_data->item_array) @@ -458,12 +458,12 @@ WMiListBox_Create( UUrMemory_Array_Delete(private_data->item_array); private_data->item_array = NULL; } - + UUrMemory_Block_Delete(private_data); private_data = NULL; WMrWindow_SetLong(inListBox, 0, 0); } - + return WMcResult_Error; } /* @@ -482,13 +482,13 @@ WMiListBox_Create( UUtInt16 window_height; UUtInt16 diff; TStFontInfo font_info; - + // ------------------------------ // create the private data // ------------------------------ private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { goto cleanup; } - + // ------------------------------ // initialize // ------------------------------ @@ -496,22 +496,22 @@ WMiListBox_Create( WMrWindow_GetClientRect(inListBox, &client_bounds); width = client_bounds.right - client_bounds.left; height = client_bounds.bottom - client_bounds.top; - + WMrWindow_GetFontInfo(inListBox, &font_info); DCrText_SetFontInfo(&font_info); - + private_data->item_width = width; private_data->item_height = (UUtInt16)DCrText_GetLineHeight(); - + private_data->start_index = 0; - + // initialize the private data private_data->double_click = UUcFalse; - + private_data->num_visible_items = height / private_data->item_height; - + private_data->v_scroll_pos = 0; - + // adjust the height of the listbox WMrWindow_GetRect(inListBox, &window_bounds); window_width = window_bounds.right - window_bounds.left; @@ -519,12 +519,12 @@ WMiListBox_Create( diff = window_height - height; window_height = (private_data->item_height * (UUtInt16)private_data->num_visible_items) + diff; WMrWindow_SetSize(inListBox, window_width, window_height); - + // get the client bounds again WMrWindow_GetClientRect(inListBox, &client_bounds); width = client_bounds.right - client_bounds.left; height = client_bounds.bottom - client_bounds.top; - + // ------------------------------ // initialize the item array // ------------------------------ @@ -536,7 +536,7 @@ WMiListBox_Create( 0, LBcDefaultNumItems); if (private_data->item_array == NULL) { goto cleanup; } - + // ------------------------------ // create the scrollbars // ------------------------------ @@ -557,23 +557,23 @@ WMiListBox_Create( inListBox, 0); if (private_data->v_scrollbar == NULL) { goto cleanup; } - + // set the location of the v_scrollbar within the listbox WMrWindow_GetSize(private_data->v_scrollbar, &scrollbar_width, NULL); WMrWindow_SetLocation(private_data->v_scrollbar, width - scrollbar_width + 1, -1); - + // adjust the scrollbar WMiListBox_AdjustScrollbar(inListBox, private_data); - + // adjust the item_width private_data->item_width -= scrollbar_width - 1; } - + return WMcResult_Handled; cleanup: UUmAssert(0); - + if (private_data) { if (private_data->item_array) @@ -581,12 +581,12 @@ WMiListBox_Create( UUrMemory_Array_Delete(private_data->item_array); private_data->item_array = NULL; } - + UUrMemory_Block_Delete(private_data); private_data = NULL; WMrWindow_SetLong(inListBox, 0, 0); } - + return WMcResult_Error; } */ @@ -596,14 +596,14 @@ WMiListBox_Destroy( WMtListBox *inListBox) { WMtListBox_PrivateData *private_data; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return; } - + // reset the contents WMiListBox_Reset(inListBox); - + // delete the item array if (private_data->item_array) { @@ -619,11 +619,11 @@ WMiListBox_Focus( WMtMessage inMessage) { WMtListBox_PrivateData *private_data; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return; } - + if (inMessage == WMcMessage_SetFocus) { private_data->has_focus = UUcTrue; @@ -653,10 +653,10 @@ WMiListBox_HandleFontInfoChanged( WMtListBox_Item *items; UUtUns32 num_items; UUtUns32 i; - + private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return; } - + // ------------------------------ // setup the window size based on the font info // ------------------------------ @@ -664,22 +664,22 @@ WMiListBox_HandleFontInfoChanged( WMrWindow_GetClientRect(inListBox, &client_bounds); width = client_bounds.right - client_bounds.left; height = client_bounds.bottom - client_bounds.top; - + WMrWindow_GetFontInfo(inListBox, &font_info); DCrText_SetFontInfo(&font_info); - + private_data->item_width = width; private_data->item_height = (UUtInt16)DCrText_GetLineHeight(); - + private_data->start_index = 0; - + // initialize the private data private_data->double_click = UUcFalse; - + private_data->num_visible_items = height / private_data->item_height; - + private_data->v_scroll_pos = 0; - + // adjust the height of the listbox WMrWindow_GetRect(inListBox, &window_bounds); window_width = window_bounds.right - window_bounds.left; @@ -687,7 +687,7 @@ WMiListBox_HandleFontInfoChanged( diff = window_height - height; window_height = (private_data->item_height * (UUtInt16)private_data->num_visible_items) + diff; WMrWindow_SetSize(inListBox, window_width, window_height); - + // get the client bounds WMrWindow_GetClientRect(inListBox, &client_bounds); height = client_bounds.bottom - client_bounds.top; @@ -701,17 +701,17 @@ WMiListBox_HandleFontInfoChanged( // set the location of the v_scrollbar within the listbox WMrWindow_GetSize(private_data->v_scrollbar, &scrollbar_width, NULL); WMrWindow_SetLocation(private_data->v_scrollbar, width - scrollbar_width + 1, -1); - + WMrWindow_GetSize(private_data->v_scrollbar, &width, NULL); WMrWindow_SetSize(private_data->v_scrollbar, width, height + 2); - + // adjust the scrollbar WMiListBox_AdjustScrollbar(inListBox, private_data); - + // adjust the item_width private_data->item_width -= scrollbar_width - 1; } - + // ------------------------------ // adjust the height of each item // ------------------------------ @@ -734,21 +734,21 @@ WMiListBox_HandleKeyEvent( UUtUns32 inParam2) { WMtListBox_PrivateData *private_data; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return; } - + switch (inMessage) { case WMcMessage_KeyDown: { UUtUns32 index; UUtUns32 num_items; - + index = WMiListBox_GetSelection(inListBox); num_items = UUrMemory_Array_GetUsedElems(private_data->item_array); - + switch (inParam1) { case LIcKeyCode_UpArrow: @@ -756,33 +756,33 @@ WMiListBox_HandleKeyEvent( if (index > num_items) { index = 0; } WMiListBox_SetSelection(inListBox, index, UUcTrue); break; - + case LIcKeyCode_DownArrow: index++; if (index >= num_items) { index = num_items - 1; } WMiListBox_SetSelection(inListBox, index, UUcTrue); break; - + case LIcKeyCode_Home: WMiListBox_SetSelection(inListBox, 0, UUcTrue); break; - + case LIcKeyCode_End: WMiListBox_SetSelection(inListBox, (num_items - 1), UUcTrue); break; - + case LIcKeyCode_PageUp: index -= private_data->num_visible_items; if (index > num_items) { index = 0; } WMiListBox_SetSelection(inListBox, index, UUcTrue); break; - + case LIcKeyCode_PageDown: index += private_data->num_visible_items; if (index >= num_items) { index = num_items - 1; } WMiListBox_SetSelection(inListBox, index, UUcTrue); break; - + default: { char char_string[2]; @@ -792,22 +792,22 @@ WMiListBox_HandleKeyEvent( // reset the buffer private_data->prefix_buffer[0] = '\0'; } - + // concatenate inParam1 to the end of the buffer char_string[0] = (char)inParam1; char_string[1] = '\0'; - + UUrString_Cat( private_data->prefix_buffer, char_string, LBcDefaultCharsPerItem); - + // search for that file WMiListBox_FindPrefix(inListBox, private_data->prefix_buffer); } break; } - + private_data->key_down_delta = UUrMachineTime_Sixtieths() + LBcKeyDownDelta; } break; @@ -825,19 +825,19 @@ WMiListBox_HandleMouseEvent( WMtListBox_PrivateData *private_data; IMtPoint2D global_mouse; IMtPoint2D local_mouse; - + // disabled list boxes don't handle mouse events if (WMrWindow_GetEnabled(inListBox) == UUcFalse) { return; } - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return; } - + // get the local mouse position global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam1); WMrWindow_GlobalToLocal(inListBox, &global_mouse, &local_mouse); - + // handle the message switch (inMessage) { @@ -846,11 +846,11 @@ WMiListBox_HandleMouseEvent( private_data->mouse_state = LIcMouseState_LButtonDown; private_data->double_click = UUcFalse; break; - + case WMcMessage_LMouseDblClck: private_data->double_click = UUcTrue; break; - + case WMcMessage_LMouseUp: { UUtInt32 i; @@ -858,12 +858,12 @@ WMiListBox_HandleMouseEvent( UUtInt32 stop_index; UUtRect bounds; WMtListBox_Item *items; - + // make sure the mouse went down in the list box if (private_data->mouse_state != LIcMouseState_LButtonDown) { break; } - + private_data->mouse_state &= ~LIcMouseState_LButtonDown; - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); @@ -873,26 +873,26 @@ WMiListBox_HandleMouseEvent( UUmMin( UUrMemory_Array_GetUsedElems(private_data->item_array), (private_data->start_index + private_data->num_visible_items)); - + bounds.left = 0; bounds.top = 0; bounds.right = 0; bounds.bottom = 0; - + for (i = start_index; i < stop_index; i++) { bounds.right = items[i].width; bounds.bottom = bounds.top + items[i].height; - + if (IMrRect_PointIn(&bounds, &local_mouse)) { WMiListBox_SetSelection(inListBox, i, UUcTrue); break; } - + bounds.top += items[i].height; } - + if ((i != stop_index) && (private_data->double_click)) { // tell the parent @@ -918,49 +918,49 @@ WMiListBox_HandleVerticalScroll( WMtListBox_PrivateData *private_data; UUtInt32 client_height; UUtRect client_rect; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return; } - + // calculate the client height WMrWindow_GetClientRect(inListBox, &client_rect); client_height = client_rect.bottom - client_rect.top; - + // interpret the parameters of the message switch (UUmHighWord(inParam1)) { case SBcNotify_LineUp: scroll_increment = -1; break; - + case SBcNotify_LineDown: scroll_increment = 1; break; - + case SBcNotify_PageUp: scroll_increment = UUmMin( -1, -client_height / private_data->item_height); break; - + case SBcNotify_PageDown: scroll_increment = UUmMax( 1, client_height / private_data->item_height); break; - + case SBcNotify_ThumbPosition: scroll_increment = inParam2 - private_data->v_scroll_pos; break; - + default: scroll_increment = 0; break; } - + // calculate the increment scroll_increment = UUmMax( @@ -968,7 +968,7 @@ WMiListBox_HandleVerticalScroll( UUmMin( scroll_increment, private_data->v_scroll_max - private_data->v_scroll_pos)); - + // adjust the the thumb position if (scroll_increment != 0) { @@ -999,35 +999,35 @@ WMiListBox_Paint( UUtBool enabled; UUtUns32 style; TStFontInfo font_info; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return; } - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); - + // get the partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + style = WMrWindow_GetStyle(inListBox); - + WMrWindow_GetFontInfo(inListBox, &font_info); DCrText_SetFontInfo(&font_info); - + ascending_height = DCrText_GetAscendingHeight(); - + draw_context = DCrDraw_Begin(inListBox); - + enabled = WMrWindow_GetEnabled(inListBox); - + // set the dest dest.x = 0; dest.y = 0; - + WMrWindow_GetClientRect(inListBox, &bounds); - + // calculate the start and stop index start_index = (UUtInt32) private_data->start_index; start_index = UUmMax(0, start_index); @@ -1035,7 +1035,7 @@ WMiListBox_Paint( UUmMin( UUrMemory_Array_GetUsedElems(private_data->item_array), (private_data->start_index + private_data->num_visible_items)); - + // draw the contents for (i = start_index, draw_line = 0; i < stop_index; i++, draw_line++) { @@ -1050,11 +1050,11 @@ WMiListBox_Paint( items[i].height, M3cMaxAlpha); } - + if (style & WMcListBoxStyle_OwnerDraw) { WMtDrawItem draw_item; - + // set up the owner draw struct draw_item.draw_context = draw_context; draw_item.window = inListBox; @@ -1067,12 +1067,12 @@ WMiListBox_Paint( draw_item.rect.bottom = dest.y + items[i].height; draw_item.string = items[i].string; draw_item.data = items[i].data; - + if (items[i].selected) { draw_item.state = WMcDrawItemState_Selected; } - + WMrMessage_Send( WMrWindow_GetOwner(inListBox), WMcMessage_DrawItem, @@ -1082,13 +1082,13 @@ WMiListBox_Paint( else if (style & WMcListBoxStyle_HasStrings) { IMtPoint2D item_dest; - + item_dest = dest; - + if ((style & WMcListBoxStyle_Directory) == WMcListBoxStyle_Directory) { PStPartSpec *icon; - + switch (items[i].data) { case LBcDirItemType_File: @@ -1098,14 +1098,14 @@ WMiListBox_Paint( case LBcDirItemType_Directory: icon = partspec_ui->folder; break; - + case LBcDirItemType_Volume: break; } - + item_dest.x += 2; item_dest.y += 1; - + DCrDraw_PartSpec( draw_context, icon, @@ -1114,7 +1114,7 @@ WMiListBox_Paint( (items[i].height - 3), (items[i].height - 3), M3cMaxAlpha); - + item_dest.x += items[i].height; item_dest.y -= 1; } @@ -1122,23 +1122,23 @@ WMiListBox_Paint( { item_dest.x += LBcDefaultTextOffset_X; } - + item_dest.y += (UUtInt16)ascending_height; - + // always set these in case some per line text formatting needs to be done DCrText_SetShade(enabled ? font_info.font_shade : IMcShade_Gray50); DCrText_SetFormat(TSc_HLeft); - + DCrDraw_String( draw_context, (char*)items[i].string, NULL, &item_dest); } - + dest.y += items[i].height; } - + DCrDraw_End(draw_context, inListBox); } @@ -1156,23 +1156,23 @@ WMiListBox_AddString( WMtListBox_PrivateData *private_data; UUtInt32 item_index; UUtUns32 style; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } item_index = -1; style = WMrWindow_GetStyle(inListBox); - + // sort the array if (style & WMcListBoxStyle_Sort) { UUtUns32 result; - + result = WMiListBox_FindInsertPos(inListBox, private_data, inParam1, &item_index); if (result != LBcNoError) { return result; } } - + return WMiListBox_InsertString(inListBox, item_index, inParam1); } @@ -1185,11 +1185,11 @@ WMiListBox_DeleteString( WMtListBox_PrivateData *private_data; WMtListBox_Item *items; UUtUns32 style; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + style = WMrWindow_GetStyle(inListBox); // check the range @@ -1198,26 +1198,26 @@ WMiListBox_DeleteString( { return LBcError; } - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); - + // delete the item data if ((style & WMcListBoxStyle_HasStrings) != 0) { UUrMemory_Block_Delete((char*)items[inItemIndex].string); items[inItemIndex].string = NULL; } - + // delete the item UUrMemory_Array_DeleteElement(private_data->item_array, inItemIndex); - + // adjust the scrollbar if (style & WMcListBoxStyle_HasScrollbar) { WMiListBox_AdjustScrollbar(inListBox, private_data); } - + return LBcNoError; } @@ -1231,11 +1231,11 @@ WMiListBox_GetItemData( WMtListBox_Item *items; UUtUns32 index; UUtUns32 data; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + if (inItemIndex == LBcSelected) { index = WMiListBox_GetSelection(inListBox); @@ -1244,21 +1244,21 @@ WMiListBox_GetItemData( { index = inItemIndex; } - + // check the bounds on the index if ((index < 0) || (index >= UUrMemory_Array_GetUsedElems(private_data->item_array))) { return LBcError; } - + // get a pointer to the items array items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); if (items == NULL) { return LBcError; } - + // get the data data = items[index].data; - + return data; } @@ -1268,11 +1268,11 @@ WMiListBox_GetNumLines( WMtListBox *inListBox) { WMtListBox_PrivateData *private_data; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + return UUrMemory_Array_GetUsedElems(private_data->item_array); } @@ -1287,13 +1287,13 @@ WMiListBox_GetText( UUtUns32 index; WMtListBox_Item *items; UUtUns32 style; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } style = WMrWindow_GetStyle(inListBox); - + // set the index if (inItemIndex == LBcSelected) { @@ -1303,17 +1303,17 @@ WMiListBox_GetText( { index = inItemIndex; } - + // check the bounds on the index if ((index < 0) || (index >= UUrMemory_Array_GetUsedElems(private_data->item_array))) { return LBcError; } - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); - + // assume that outString is big enough to hold the contents of the array if ((style & WMcListBoxStyle_HasStrings) != 0) { @@ -1327,7 +1327,7 @@ WMiListBox_GetText( { *((UUtUns32*)outString) = items[index].data; } - + return LBcNoError; } @@ -1342,11 +1342,11 @@ WMiListBox_GetTextLength( WMtListBox_Item *items; UUtUns16 string_length; UUtUns32 style; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + style = WMrWindow_GetStyle(inListBox); if ((style & WMcListBoxStyle_HasStrings) == 0) { return LBcError; } @@ -1359,20 +1359,20 @@ WMiListBox_GetTextLength( { index = inItemIndex; } - + // check the bounds on the index if ((index < 0) || (index >= UUrMemory_Array_GetUsedElems(private_data->item_array))) { return LBcError; } - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); - + // get the length of the string string_length = TSrString_GetLength((char*)items[index].data); - + return string_length; } @@ -1385,14 +1385,14 @@ WMiListBox_GetSelection( WMtListBox_Item *items; UUtUns32 i; UUtUns32 style; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + style = WMrWindow_GetStyle(inListBox); if (style & WMcListBoxStyle_MultipleSelection) { return LBcError; } - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); @@ -1403,7 +1403,7 @@ WMiListBox_GetSelection( return i; } } - + return LBcError; } @@ -1420,13 +1420,13 @@ WMiListBox_InsertString( WMtListBox_Item *items; UUtUns32 index; UUtUns32 style; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + style = WMrWindow_GetStyle(inListBox); - + // make room in the array if (inItemIndex != -1) { @@ -1437,7 +1437,7 @@ WMiListBox_InsertString( inItemIndex, &mem_moved); if (error != UUcError_None) { return LBcError; } - + index = inItemIndex; } else @@ -1450,10 +1450,10 @@ WMiListBox_InsertString( &mem_moved); if (error != UUcError_None) { return LBcError; } } - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); - + // initialize the element items[index].data = 0; items[index].width = private_data->item_width; @@ -1478,13 +1478,13 @@ WMiListBox_InsertString( { items[index].data = inParam1; } - + // adjust the scrollbar if (style & WMcListBoxStyle_HasScrollbar) { WMiListBox_AdjustScrollbar(inListBox, private_data); } - + return (UUtUns32)index; } @@ -1498,11 +1498,11 @@ WMiListBox_ReplaceString( WMtListBox_PrivateData *private_data; WMtListBox_Item *items; UUtUns32 style; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + style = WMrWindow_GetStyle(inListBox); // CB: check that we are within the bounds of the array @@ -1511,10 +1511,10 @@ WMiListBox_ReplaceString( { return LBcError; } - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); - + // set the new item for the element if ((style & WMcListBoxStyle_HasStrings) != 0) { @@ -1533,7 +1533,7 @@ WMiListBox_ReplaceString( { items[inItemIndex].data = inParam1; } - + return (UUtUns32)inItemIndex; } @@ -1546,20 +1546,20 @@ WMiListBox_Reset( UUtUns32 num_items; WMtListBox_Item *items; UUtUns32 style; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } style = WMrWindow_GetStyle(inListBox); - + // clear the array num_items = UUrMemory_Array_GetUsedElems(private_data->item_array); if (num_items == 0) { return LBcNoError; } - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); - + // delete all the items in the array while (num_items--) { @@ -1569,10 +1569,10 @@ WMiListBox_Reset( UUrMemory_Block_Delete((char*)items[num_items].string); items[num_items].string = NULL; } - + UUrMemory_Array_DeleteElement(private_data->item_array, num_items); } - + private_data->start_index = 0; private_data->start_ratio = 0.0f; @@ -1581,7 +1581,7 @@ WMiListBox_Reset( { WMiListBox_AdjustScrollbar(inListBox, private_data); } - + return LBcNoError; } @@ -1598,34 +1598,34 @@ WMiListBox_SelectString( UUtUns32 i; UUtUns32 start_index; UUtBool found; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + style = WMrWindow_GetStyle(inListBox); if ((style & WMcListBoxStyle_HasStrings) == 0) { return LBcError; } - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); - + found = UUcFalse; start_index = inItemIndex; if (start_index == LBcSelected) { start_index = 0; } - + for (i = start_index; i < UUrMemory_Array_GetUsedElems(private_data->item_array); i++) { if (strcmp((char*)items[i].string, inString) == 0) { WMiListBox_SetSelection(inListBox, i, UUcTrue); found = UUcTrue; - break; + break; } } - + if (i == UUrMemory_Array_GetUsedElems(private_data->item_array)) { for (i = 0; i < start_index; i++) @@ -1634,11 +1634,11 @@ WMiListBox_SelectString( { WMiListBox_SetSelection(inListBox, i, UUcTrue); found = UUcTrue; - break; + break; } } } - + if (!found) { // CB: we could not find the string. deselect. @@ -1661,25 +1661,25 @@ WMiListBox_SetDirectoryInfo( UUtUns32 result; BFtFileIterator *file_iterator; UUtError error; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + style = WMrWindow_GetStyle(inListBox); if ((style & WMcListBoxStyle_Directory) != WMcListBoxStyle_Directory) { return LBcError; } - + // get a pointer to the directory info directory_info = (WMtListBox_DirectoryInfo*)inParam1; if (directory_info == NULL) { return LBcError; } - + // clear the listbox if (inReset) { result = WMiListBox_Reset(inListBox); if (result == LBcError) { return LBcError; } } - + // make a directory file iterator if ((directory_info->flags & LBcDirectoryInfoFlag_Files) != 0) { @@ -1690,20 +1690,20 @@ WMiListBox_SetDirectoryInfo( (directory_info->suffix[0] == '\0') ? NULL : directory_info->suffix, &file_iterator); if (error != UUcError_None) { return LBcError; } - + // fill the listbox with files while (1) { BFtFileRef file_ref; - + // get a file ref error = BFrDirectory_FileIterator_Next(file_iterator, &file_ref); if (error != UUcError_None) { break; } - + // add the name of the file to the listbox result = WMiListBox_AddString(inListBox, (UUtUns32)BFrFileRef_GetLeafName(&file_ref)); if (result == LBcError) { break; } - + // add the file type result = WMiListBox_SetItemData(inListBox, result, LBcDirItemType_File); } @@ -1712,7 +1712,7 @@ WMiListBox_SetDirectoryInfo( UUrMemory_Block_Delete(file_iterator); file_iterator = NULL; } - + // fill the listbox with directories if ((directory_info->flags & LBcDirectoryInfoFlag_Directory) != 0) { @@ -1723,35 +1723,35 @@ WMiListBox_SetDirectoryInfo( NULL, &file_iterator); if (error != UUcError_None) { return LBcError; } - + // fill the listbox with directories while (1) { BFtFileRef dir_ref; - + // get a directory ref error = BFrDirectory_FileIterator_Next(file_iterator, &dir_ref); if (error != UUcError_None) { break; } - + // determine if the dir_ref is really a directory if (BFrFileRef_IsDirectory(&dir_ref) == UUcFalse) { continue; } - + // add the name of the directory to the listbox result = WMiListBox_AddString(inListBox, (UUtUns32)BFrFileRef_GetLeafName(&dir_ref)); if (result == LBcError) { break; } - + // add the directory type result = WMiListBox_SetItemData(inListBox, result, LBcDirItemType_Directory); } - + // delete the file_iterator UUrMemory_Block_Delete(file_iterator); file_iterator = NULL; } - + return LBcNoError; } @@ -1768,20 +1768,20 @@ WMiListBox_SetItemData( // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + // check the range of inItemIndex if ((inItemIndex < 0) || (inItemIndex >= UUrMemory_Array_GetUsedElems(private_data->item_array))) { return LBcError; } - + // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); - + // set the item data for the specified item items[inItemIndex].data = inParam1; - + return LBcNoError; } @@ -1793,15 +1793,15 @@ WMiListBox_SetNumLines( { WMtListBox_PrivateData *private_data; UUtUns32 result; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + // reset the listbox result = WMiListBox_Reset(inListBox); if (result == LBcError) { return result; } - + // set the number of elements in the private_data->item_array to inNumLines UUrMemory_Array_MakeRoom(private_data->item_array, inNumLines, NULL); @@ -1819,17 +1819,17 @@ WMiListBox_SetSelection( WMtListBox_Item *items; UUtUns32 style; UUtUns32 i; - + // get the private data private_data = (WMtListBox_PrivateData*)WMrWindow_GetLong(inListBox, 0); if (private_data == NULL) { return LBcError; } - + style = WMrWindow_GetStyle(inListBox); if (style & WMcListBoxStyle_MultipleSelection) { return LBcError; } // get the array pointer items = (WMtListBox_Item*)UUrMemory_Array_GetMemory(private_data->item_array); - + if (inItemIndex == LBcSelected) { // clear the selection @@ -1841,42 +1841,42 @@ WMiListBox_SetSelection( else { UUtInt32 diff; - + // clear the previous selection for (i = 0; i < UUrMemory_Array_GetUsedElems(private_data->item_array); i++) { items[i].selected = UUcFalse; } - + // check the bounds on the index if ((inItemIndex < 0) || (inItemIndex >= UUrMemory_Array_GetUsedElems(private_data->item_array))) { return LBcError; } - + // set the selection items[inItemIndex].selected = UUcTrue; - + // adjust the list to see the newly selected item diff = (UUtInt32)(private_data->start_index - inItemIndex); if (diff > 0) { // current selection is above the scroll pos in the list - if (((UUtInt32)inItemIndex - diff) < (UUtInt32)private_data->start_index) + if (((UUtInt32)inItemIndex - diff) < (UUtInt32)private_data->start_index) { // set the new start index private_data->start_index = inItemIndex; UUmAssert((UUtInt32)private_data->start_index >= 0); - - // the scroll position needs to be changed to make the + + // the scroll position needs to be changed to make the // current selection visible if (private_data->start_ratio != 0.0f) { private_data->v_scroll_pos = (UUtInt32)((float)private_data->start_index / private_data->start_ratio); } - + WMrScrollbar_SetPosition(private_data->v_scrollbar, private_data->v_scroll_pos); } } @@ -1889,20 +1889,20 @@ WMiListBox_SetSelection( private_data->start_index = inItemIndex - private_data->num_visible_items + 1; UUmAssert((UUtInt32)private_data->start_index >= 0); - - // the scroll position needs to be changed to make the + + // the scroll position needs to be changed to make the // current selection visible if (private_data->start_ratio) { private_data->v_scroll_pos = (UUtInt32)((float)private_data->start_index / private_data->start_ratio); } - + WMrScrollbar_SetPosition(private_data->v_scrollbar, private_data->v_scroll_pos); } } } - + if (inNotifyParent) { // tell the parent @@ -1912,7 +1912,7 @@ WMiListBox_SetSelection( UUmMakeLong(LBcNotify_SelectionChanged, WMrWindow_GetID(inListBox)), (UUtUns32)inListBox); } - + return LBcNoError; } @@ -1930,42 +1930,42 @@ WMiListBox_Callback( UUtUns32 inParam2) { UUtUns32 result; - + switch(inMessage) { case WMcMessage_NC_Create: result = WMiListBox_NC_Create(inListBox); if (result == WMcResult_Error) { return WMcResult_Error; } break; /* the default window needs to handle the message as well */ - + case WMcMessage_NC_Destroy: WMiListBox_NC_Destroy(inListBox); break; - + case WMcMessage_NC_HitTest: result = WMiListBox_NC_HitTest(inListBox, inParam1); return result; - + case WMcMessage_NC_Paint: WMiListBox_NC_Paint(inListBox); return WMcResult_Handled; - + case WMcMessage_NC_CalcClientSize: WMiListBox_NC_CalcClientSize(inListBox, (UUtRect*)inParam1); return WMcResult_Handled; - + case WMcMessage_Create: result = WMiListBox_Create(inListBox); return result; - + case WMcMessage_Destroy: WMiListBox_Destroy(inListBox); return WMcResult_Handled; - + case WMcMessage_Paint: WMiListBox_Paint(inListBox); return WMcResult_Handled; - + case WMcMessage_LMouseDown: case WMcMessage_LMouseUp: case WMcMessage_LMouseDblClck: @@ -1975,7 +1975,7 @@ WMiListBox_Callback( inParam1, inParam2); return WMcResult_Handled; - + case WMcMessage_KeyDown: WMiListBox_HandleKeyEvent( inListBox, @@ -1983,12 +1983,12 @@ WMiListBox_Callback( inParam1, inParam1); return WMcResult_Handled; - + case WMcMessage_SetFocus: case WMcMessage_KillFocus: WMiListBox_Focus(inListBox, inMessage); break; - + case WMcMessage_GetDialogCode: result = WMcDialogCode_WantAlphas | @@ -1996,11 +1996,11 @@ WMiListBox_Callback( WMcDialogCode_WantNavigation | WMcDialogCode_WantArrows; return result; - + case WMcMessage_FontInfoChanged: WMiListBox_HandleFontInfoChanged(inListBox); break; - + case LBcMessage_AddString: result = WMiListBox_AddString(inListBox, inParam1); return result; @@ -2008,68 +2008,68 @@ WMiListBox_Callback( case LBcMessage_DeleteString: result = WMiListBox_DeleteString(inListBox, inParam2); return result; - + case LBcMessage_GetItemData: result = WMiListBox_GetItemData(inListBox, inParam2); return result; - + case LBcMessage_GetNumLines: result = WMiListBox_GetNumLines(inListBox); return result; - + case LBcMessage_GetSelection: result = WMiListBox_GetSelection(inListBox); return result; - + case LBcMessage_GetText: result = WMiListBox_GetText(inListBox, inParam2, (char*)inParam1); return result; - + case LBcMessage_GetTextLength: result = WMiListBox_GetTextLength(inListBox, inParam2); return result; - + case LBcMessage_InsertString: result = WMiListBox_InsertString(inListBox, inParam2, inParam1); return result; - + case LBcMessage_ReplaceString: result = WMiListBox_ReplaceString(inListBox, inParam2, inParam1); return result; - + case LBcMessage_Reset: result = WMiListBox_Reset(inListBox); return result; - + case LBcMessage_SelectString: result = WMiListBox_SelectString(inListBox, inParam1, (char*)inParam2); return result; - + case LBcMessage_SetDirectoryInfo: result = WMiListBox_SetDirectoryInfo(inListBox, inParam1, (UUtBool)inParam2); return result; - + case LBcMessage_SetItemData: result = WMiListBox_SetItemData(inListBox, inParam2, inParam1); return result; - + case LBcMessage_SetNumLines: result = WMiListBox_SetNumLines(inListBox, inParam1); break; - + case LBcMessage_SetSelection: result = WMiListBox_SetSelection(inListBox, inParam2, (UUtBool)inParam1); return result; - + case LBcMessage_SetLineColor: return LBcError; - + case SBcMessage_VerticalScroll: WMiListBox_HandleVerticalScroll(inListBox, inParam1, inParam2); WMrWindow_SetFocus(inListBox); return WMcResult_Handled; } - + return WMrWindow_DefaultCallback(inListBox, inMessage, inParam1, inParam2); } @@ -2085,20 +2085,20 @@ WMrListBox_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_ListBox; window_class.callback = WMiListBox_Callback; window_class.private_data_size = sizeof(WMtListBox_PrivateData*); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; } -void +void WMrListBox_Reset(WMtListBox *inListBox) { UUtUns32 result; @@ -2108,7 +2108,7 @@ WMrListBox_Reset(WMtListBox *inListBox) return; } -void +void WMrListBox_SetSelection(WMtListBox *inListBox, UUtBool inNotifyParent, UUtUns32 inIndex) { UUtUns32 result; @@ -2128,7 +2128,7 @@ WMrListBox_AddString(WMtListBox *inListBox, const char *inString) return result; } -void +void WMrListBox_SetItemData(WMtListBox *inListBox, UUtUns32 inItemData, UUtUns32 inIndex) { UUtUns32 result; @@ -2138,7 +2138,7 @@ WMrListBox_SetItemData(WMtListBox *inListBox, UUtUns32 inItemData, UUtUns32 inIn return; } -void +void WMrListBox_GetText(WMtListBox *inListBox, char *ioBuffer, UUtUns32 inIndex) { UUtUns32 result; @@ -2173,9 +2173,9 @@ WMrListBox_GetSelection( WMtListBox *inListBox) { UUtUns32 result; - + result = WMrMessage_Send(inListBox, LBcMessage_GetSelection, 0, 0); - + return result; } @@ -2190,19 +2190,19 @@ WMrListBox_SetDirectoryInfo( { UUtUns32 result; WMtListBox_DirectoryInfo dir_info; - + dir_info.directory_ref = inDirectoryRef; dir_info.flags = inFlags; UUrString_Copy(dir_info.prefix, inPrefix, BFcMaxFileNameLength); UUrString_Copy(dir_info.suffix, inSuffix, BFcMaxFileNameLength); - + result = WMrMessage_Send( inListBox, LBcMessage_SetDirectoryInfo, (UUtUns32)&dir_info, (UUtUns32)inReset); - + return result; } @@ -2212,8 +2212,8 @@ WMrListBox_SelectString( const char *inString) { UUtUns32 result; - + result = WMrMessage_Send(inListBox, LBcMessage_SelectString, LBcSelected, (UUtUns32)inString); - + return result; } diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ListBox.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ListBox.h index 47d6e08..40305ee 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ListBox.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ListBox.h @@ -28,7 +28,7 @@ enum WMcListBoxStyle_HasScrollbar | WMcListBoxStyle_HasStrings | WMcListBoxStyle_Sort), - + WMcListBoxStyle_SimpleListBox = (WMcListBoxStyle_HasStrings | WMcListBoxStyle_HasScrollbar), WMcListBoxStyle_SortedListBox = (WMcListBoxStyle_SimpleListBox | WMcListBoxStyle_Sort) }; @@ -72,7 +72,7 @@ typedef struct WMtListBox_DirectoryInfo UUtUns32 flags; char prefix[BFcMaxFileNameLength]; char suffix[BFcMaxFileNameLength]; - + } WMtListBox_DirectoryInfo; // ====================================================================== @@ -82,19 +82,19 @@ UUtError WMrListBox_Initialize( void); -void +void WMrListBox_Reset(WMtListBox *inListBox); #define LBcNotifyParent UUcTrue #define LBcDontNotifyParent UUcFalse -void +void WMrListBox_SetSelection(WMtListBox *inListBox, UUtBool inNotifyParent, UUtUns32 inIndex); UUtUns32 WMrListBox_AddString(WMtListBox *inListBox, const char *inString); -void +void WMrListBox_SetItemData(WMtListBox *inListBox, UUtUns32 inItemData, UUtUns32 inIndex); UUtUns32 @@ -118,11 +118,11 @@ WMrListBox_SetDirectoryInfo( const char *inPrefix, const char *inSuffix, UUtBool inReset); - + UUtUns32 WMrListBox_SelectString( WMtListBox *inListBox, const char *inString); - + // ====================================================================== -#endif /* WM_LISTBOX_H */ \ No newline at end of file +#endif /* WM_LISTBOX_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Menu.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Menu.c index 877dd38..2a494bd 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Menu.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Menu.c @@ -36,7 +36,7 @@ typedef struct WMtMenuItem WMtMenuItemData item_data; UUtInt16 line_height; UUtInt16 line_width; - + } WMtMenuItem; typedef struct WMtMenuColumn @@ -58,10 +58,10 @@ typedef struct WMtMenu_PrivateData UUtInt16 max_width; UUtUns32 hilited_item; // index of menu_item that the mouse is currently over - - UUtMemory_Array *menu_items; // array of menu items - UUtMemory_Array *menu_columns; // array of menu columns - + + UUtMemory_Array *menu_items; // array of menu items + UUtMemory_Array *menu_columns; // array of menu columns + } WMtMenu_PrivateData; // ====================================================================== @@ -94,7 +94,7 @@ WMiMenu_Layout( UUtInt16 border_width; UUtInt16 border_height; WMtMenu_PrivateData *private_data; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return; } @@ -104,7 +104,7 @@ WMiMenu_Layout( if (partspec_ui == NULL) { return; } - + // get the width and height of the border PSrPartSpec_GetSize(partspec_ui->background, PScPart_LeftTop, &border_width, &border_height); @@ -149,7 +149,7 @@ WMiMenu_Layout( i++; } } - + // layout is done, don't need to recalculate again inPrivateData->recalc_layout = UUcFalse; } @@ -170,7 +170,7 @@ WMrMenu_Locate( UUtInt16 border_width; UUtInt16 border_height; WMtMenu_PrivateData *private_data; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return; } @@ -191,7 +191,7 @@ WMrMenu_Locate( if (partspec_ui == NULL) { goto exit; } - + // get the width and height of the border PSrPartSpec_GetSize(partspec_ui->background, PScPart_LeftTop, &border_width, &border_height); @@ -205,7 +205,7 @@ WMrMenu_Locate( total_height = 2 * border_height; for (i = 0; i < num_items; i++) { total_height += menu_items[i].line_height; - } + } if (total_height + ioLocation->y + WMcMenu_Buffer_Bottom < desktop_rect.bottom) { // we can place the menu at the desired location @@ -264,7 +264,7 @@ WMrMenu_Locate( private_data->rect_width = UUmMin(total_width, desktop_rect.right); ioLocation->x = desktop_rect.right - private_data->rect_width; } - } + } exit: WMrWindow_SetLocation(inMenu, ioLocation->x, ioLocation->y); @@ -296,10 +296,10 @@ WMiMenu_GetItemUnderPoint( // get the partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return WMcMenu_NoItem; } - + // get the width and height of the border PSrPartSpec_GetSize(partspec_ui->background, PScPart_LeftTop, &border_width, &border_height); - + // set the bounds column_bounds.left = 0; column_bounds.top = border_height; @@ -328,20 +328,20 @@ WMiMenu_GetItemUnderPoint( for (i = menu_columns[c].item_baseindex; i < (UUtUns32) (menu_columns[c].item_baseindex + menu_columns[c].item_count); i++) { item_bounds.bottom = item_bounds.top + menu_items[i].line_height; - + // check the point if (IMrRect_PointIn(&item_bounds, inPoint)) { return i; } - - item_bounds.top = item_bounds.bottom; + + item_bounds.top = item_bounds.bottom; } } column_bounds.left = column_bounds.right; } - + return WMcMenu_NoItem; } @@ -355,22 +355,22 @@ WMiMenu_RecalcLineSizes( UUtUns32 num_items; WMtMenuItem *menu_items; UUtUns32 i; - + WMrWindow_GetFontInfo(inMenu, &font_info); DCrText_SetFontInfo(&font_info); - + num_items = UUrMemory_Array_GetUsedElems(inPrivateData->menu_items); menu_items = (WMtMenuItem *)UUrMemory_Array_GetMemory(inPrivateData->menu_items); for (i = 0; i < num_items; i++) { UUtRect rect; - + // calculate the dimensions of the string DCrText_GetStringRect(menu_items[i].item_data.title, &rect); menu_items[i].line_width = rect.right - rect.left; menu_items[i].line_height = rect.bottom - rect.top; } - + inPrivateData->recalc_layout = UUcTrue; } @@ -387,18 +387,18 @@ WMiMenu_Create( { UUtError error; WMtMenu_PrivateData *private_data; - + // create the private data private_data = (WMtMenu_PrivateData*)UUrMemory_Block_NewClear(sizeof(WMtMenu_PrivateData)); if (private_data == NULL) { goto cleanup; } WMrWindow_SetLong(inMenu, 0, (UUtUns32)private_data); - + // initialize private_data->rect_width = 0; private_data->rect_height = 0; private_data->recalc_layout = UUcTrue; private_data->hilited_item = WMcMenu_NoItem; - + // ------------------------------ // allocate memory for the menu items // ------------------------------ @@ -427,12 +427,12 @@ WMiMenu_Create( if (error != UUcError_None) { goto cleanup; } } } - + return WMcResult_Handled; cleanup: UUmAssert(0); - + if (private_data) { if (private_data->menu_items) @@ -440,7 +440,7 @@ WMiMenu_Create( UUrMemory_Array_Delete(private_data->menu_items); private_data->menu_items = NULL; } - + if (private_data->menu_columns) { UUrMemory_Array_Delete(private_data->menu_columns); @@ -451,7 +451,7 @@ WMiMenu_Create( private_data = NULL; } WMrWindow_SetLong(inMenu, 0, 0); - + return WMcResult_Error; } @@ -461,17 +461,17 @@ WMiMenu_Destroy( WMtMenu *inMenu) { WMtMenu_PrivateData *private_data; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return; } - + if (private_data->menu_items) { UUrMemory_Array_Delete(private_data->menu_items); private_data->menu_items = NULL; } - + if (private_data->menu_columns) { UUrMemory_Array_Delete(private_data->menu_columns); @@ -493,24 +493,24 @@ WMiMenu_HandleMouseEvent( IMtPoint2D global_mouse_location; IMtPoint2D mouse_location; WMtMenu_PrivateData *private_data; - + // only handle mouse events if the window is enabled if (WMrWindow_GetEnabled(inMenu) == UUcFalse) { return; } // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return; } - + // get the global mouse location global_mouse_location.x = (UUtInt16)UUmHighWord(inParam1); global_mouse_location.y = (UUtInt16)UUmLowWord(inParam1); - + // make sure the mouse is within the menu's bounds if (WMrWindow_PointInWindow(inMenu, &global_mouse_location) == UUcFalse) { return; } - + WMrWindow_GlobalToLocal(inMenu, &global_mouse_location, &mouse_location); switch (inMessage) @@ -518,20 +518,20 @@ WMiMenu_HandleMouseEvent( case WMcMessage_MouseMove: private_data->hilited_item = WMiMenu_GetItemUnderPoint(inMenu, private_data, &mouse_location); break; - + case WMcMessage_LMouseDown: WMrWindow_SetFocus(inMenu); // fall through - + case WMcMessage_LMouseUp: { UUtUns32 selected_item; WMtMenuItem *menu_items; - + // get the array pointer menu_items = (WMtMenuItem*)UUrMemory_Array_GetMemory(private_data->menu_items); if (menu_items == NULL) { break; } - + // send a MenuSelect message to the menu's parent if an enabled menu item was // hilited when the mousebutton went up selected_item = WMiMenu_GetItemUnderPoint(inMenu, private_data, &mouse_location); @@ -543,7 +543,7 @@ WMiMenu_HandleMouseEvent( WMrWindow_GetOwner(inMenu), WMcMessage_MenuCommand, UUmMakeLong( - menu_items[selected_item].item_data.flags, + menu_items[selected_item].item_data.flags, menu_items[selected_item].item_data.id), (UUtUns32)inMenu); } @@ -558,7 +558,7 @@ WMiMenu_HandleVisible( WMtMenu *inMenu) { WMtMenu_PrivateData *private_data; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return; } @@ -572,11 +572,11 @@ WMiMenu_HandleFontInfoChanged( WMtMenu *inMenu) { WMtMenu_PrivateData *private_data; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return; } - + WMiMenu_RecalcLineSizes(inMenu, private_data); } @@ -599,7 +599,7 @@ WMiMenu_Paint( // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return; } - + // lay out our items if we have to if (private_data->recalc_layout) { WMiMenu_Layout(inMenu, private_data); @@ -615,16 +615,16 @@ WMiMenu_Paint( partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + // get the width and height of the border PSrPartSpec_GetSize(partspec_ui->background, PScPart_LeftTop, &border_width, &border_height); - + draw_context = DCrDraw_Begin(inMenu); - + // get the font info WMrWindow_GetFontInfo(inMenu, &font_info); DCrText_SetFontInfo(&font_info); - + column_dest.x = 0; column_dest.y = 0; for (c = 0; c < num_columns; c++) { @@ -639,12 +639,12 @@ WMiMenu_Paint( if (menu_items[i].item_data.flags & WMcMenuItemFlag_Divider) { IMtPoint2D divider_dest; - + item_dest.y += (menu_items[i].line_height >> 1); - + divider_dest.x = column_dest.x + border_width; divider_dest.y = item_dest.y; - + // draw divider DCrDraw_PartSpec( draw_context, @@ -654,13 +654,13 @@ WMiMenu_Paint( menu_columns[c].column_width - 2*border_width, menu_items[i].line_height, M3cMaxAlpha); - + item_dest.y += (menu_items[i].line_height >> 1); } else { UUtBool enabled; - + if (WMrWindow_GetEnabled(inMenu)) { enabled = (menu_items[i].item_data.flags & WMcMenuItemFlag_Enabled) != 0; @@ -669,15 +669,15 @@ WMiMenu_Paint( { enabled = UUcFalse; } - + // draw hilite if ((private_data->hilited_item == i) && (enabled)) { IMtPoint2D hilite_dest; - + hilite_dest.x = column_dest.x + border_width; hilite_dest.y = item_dest.y; - + DCrDraw_PartSpec( draw_context, partspec_ui->hilite, @@ -687,23 +687,23 @@ WMiMenu_Paint( menu_items[i].line_height, M3cMaxAlpha); } - + // draw check if ((menu_items[i].item_data.flags & WMcMenuItemFlag_Checked) != 0) { UUtInt16 check_width; UUtInt16 check_height; IMtPoint2D check_dest; - + PSrPartSpec_GetSize(partspec_ui->check, PScPart_LeftTop, &check_width, &check_height); if (check_height > menu_items[i].line_height) { check_height = menu_items[i].line_height; } - + check_dest.x = column_dest.x + border_width; check_dest.y = item_dest.y + ((menu_items[i].line_height - check_height) >> 1); - + DCrDraw_PartSpec( draw_context, partspec_ui->check, @@ -713,7 +713,7 @@ WMiMenu_Paint( check_height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); } - + item_dest.y += DCrText_GetAscendingHeight(); DCrText_SetShade(enabled ? font_info.font_shade : IMcShade_Gray50); DCrText_SetFormat(TSc_HLeft); @@ -723,14 +723,14 @@ WMiMenu_Paint( NULL, &item_dest); item_dest.y -= DCrText_GetAscendingHeight(); - + item_dest.y += menu_items[i].line_height; } } column_dest.x += menu_columns[c].column_width; } - + DCrDraw_End(draw_context, inMenu); } @@ -748,39 +748,39 @@ WMiMenu_Callback( UUtUns32 inParam2) { UUtUns32 result; - + switch(inMessage) { case WMcMessage_NC_HitTest: return WMcWindowArea_Client; - + case WMcMessage_Create: result = WMiMenu_Create(inMenu, (WMtMenuData*)inParam1); return result; - + case WMcMessage_Destroy: WMiMenu_Destroy(inMenu); return WMcResult_Handled; - + case WMcMessage_MouseMove: case WMcMessage_LMouseDown: case WMcMessage_LMouseUp: WMiMenu_HandleMouseEvent(inMenu, inMessage, inParam1, inParam2); return WMcResult_Handled; - + case WMcMessage_Paint: WMiMenu_Paint(inMenu); return WMcResult_Handled; - + case WMcMessage_Visible: WMiMenu_HandleVisible(inMenu); return WMcResult_Handled; - + case WMcMessage_FontInfoChanged: WMiMenu_HandleFontInfoChanged(inMenu); break; } - + return WMrWindow_DefaultCallback(inMenu, inMessage, inParam1, inParam2); } @@ -805,7 +805,7 @@ WMrMenu_Create( WMtWindow *inParent) { WMtMenu *menu; - + menu = WMrWindow_New( WMcWindowType_Menu, @@ -833,12 +833,12 @@ WMrMenu_CheckItem( WMtMenu_PrivateData *private_data; WMtMenuItem *menu_items; UUtUns32 i; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return UUcFalse; } if (private_data->menu_items == NULL) { return UUcFalse; } - + // get the array pointer menu_items = (WMtMenuItem*)UUrMemory_Array_GetMemory(private_data->menu_items); if (menu_items == NULL) { return UUcFalse; } @@ -849,7 +849,7 @@ WMrMenu_CheckItem( if (menu_items[i].item_data.id == inItemID) { break; } } if (i == UUrMemory_Array_GetUsedElems(private_data->menu_items)) { return UUcFalse; } - + // check/uncheck the menu item if (inCheck) { @@ -859,7 +859,7 @@ WMrMenu_CheckItem( { menu_items[i].item_data.flags &= ~WMcMenuItemFlag_Checked; } - + return UUcTrue; } @@ -873,12 +873,12 @@ WMrMenu_EnableItem( WMtMenu_PrivateData *private_data; WMtMenuItem *menu_items; UUtUns32 i; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return UUcFalse; } if (private_data->menu_items == NULL) { return UUcFalse; } - + // get the array pointer menu_items = (WMtMenuItem*)UUrMemory_Array_GetMemory(private_data->menu_items); if (menu_items == NULL) { return UUcFalse; } @@ -889,7 +889,7 @@ WMrMenu_EnableItem( if (menu_items[i].item_data.id == inItemID) { break; } } if (i == UUrMemory_Array_GetUsedElems(private_data->menu_items)) { return UUcFalse; } - + // enable/disable the menu item if (inEnable) { @@ -899,7 +899,7 @@ WMrMenu_EnableItem( { menu_items[i].item_data.flags &= ~WMcMenuItemFlag_Enabled; } - + return UUcTrue; } @@ -920,12 +920,12 @@ WMrMenu_FindItemByText_Internal( WMtMenu_PrivateData *private_data; WMtMenuItem *menu_items; UUtUns32 i; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return UUcFalse; } if (private_data->menu_items == NULL) { return UUcFalse; } - + // get the array pointer menu_items = (WMtMenuItem*)UUrMemory_Array_GetMemory(private_data->menu_items); if (menu_items == NULL) { return UUcFalse; } @@ -946,7 +946,7 @@ WMrMenu_FindItemByText_Internal( } } if (i == UUrMemory_Array_GetUsedElems(private_data->menu_items)) { return UUcFalse; } - + *outItemID = menu_items[i].item_data.id; return UUcTrue; } @@ -977,7 +977,7 @@ WMrMenu_FindItemByText_NoCase( return result; } - + // ---------------------------------------------------------------------- UUtBool WMrMenu_GetItemFlags( @@ -988,11 +988,11 @@ WMrMenu_GetItemFlags( WMtMenu_PrivateData *private_data; WMtMenuItem *menu_items; UUtUns32 i; - + UUmAssert(inMenu); - + *outFlags = WMcMenuItemFlag_None; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return UUcFalse; } @@ -1008,10 +1008,10 @@ WMrMenu_GetItemFlags( if (menu_items[i].item_data.id == inItemID) { break; } } if (i == UUrMemory_Array_GetUsedElems(private_data->menu_items)) { return UUcFalse; } - + // set outFlags *outFlags = menu_items[i].item_data.flags; - + return UUcTrue; } @@ -1024,16 +1024,16 @@ WMrMenu_GetItemID( { WMtMenu_PrivateData *private_data; WMtMenuItem *menu_items; - + UUmAssert(inMenu); - + *outID = 0; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return UUcFalse; } if (private_data->menu_items == NULL) { return UUcFalse; } - + // make sure item number is in range if ((inItemIndex < 0) || (inItemIndex >= (UUtInt16)UUrMemory_Array_GetUsedElems(private_data->menu_items))) { @@ -1046,7 +1046,7 @@ WMrMenu_GetItemID( // set the id *outID = menu_items[inItemIndex].item_data.id; - + return UUcTrue; } @@ -1060,17 +1060,17 @@ WMrMenu_GetItemText( WMtMenu_PrivateData *private_data; WMtMenuItem *menu_items; UUtUns32 i; - + UUmAssert(inMenu); UUmAssert(outText); - + outText[0] = '\0'; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return UUcFalse; } if (private_data->menu_items == NULL) { return UUcFalse; } - + // get the array pointer menu_items = (WMtMenuItem*)UUrMemory_Array_GetMemory(private_data->menu_items); if (menu_items == NULL) { return UUcFalse; } @@ -1081,13 +1081,13 @@ WMrMenu_GetItemText( if (menu_items[i].item_data.id == inItemID) { break; } } if (i == UUrMemory_Array_GetUsedElems(private_data->menu_items)) { return UUcFalse; } - + // copy the title UUrString_Copy( outText, menu_items[i].item_data.title, WMcMaxTitleLength); - + return UUcTrue; } @@ -1098,16 +1098,16 @@ WMrMenu_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_Menu; window_class.callback = WMiMenu_Callback; window_class.private_data_size = sizeof(WMtMenu_PrivateData*); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1131,20 +1131,20 @@ WMrMenu_InsertItem( private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return UUcError_Generic; } if (private_data->menu_items == NULL) { return UUcError_Generic; } - + // make sure inPosition is a valid number if ((inPosition < -1) || (inPosition > (UUtInt16)UUrMemory_Array_GetUsedElems(private_data->menu_items))) { return UUcError_Generic; } - + // get the partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return UUcError_Generic; } - + // get the width and height of the border PSrPartSpec_GetSize(partspec_ui->background, PScPart_LeftTop, &border_width, &border_height); - + // insert the item at the specified position in the menu item list or // append it to the end index = WMcMenu_NoItem; @@ -1162,7 +1162,7 @@ WMrMenu_InsertItem( { // set the index index = (UUtUns32)inPosition; - + // insert the item into the array error = UUrMemory_Array_InsertElement( @@ -1171,20 +1171,20 @@ WMrMenu_InsertItem( &mem_moved); UUmError_ReturnOnError(error); } - + // get the array pointer menu_items = (WMtMenuItem*)UUrMemory_Array_GetMemory(private_data->menu_items); if (menu_items == NULL) { goto cleanup; } - + // initialize the menu item menu_items[index].item_data = *inMenuItemData; menu_items[index].line_width = 0; menu_items[index].line_height = 0; - + if (menu_items[index].item_data.flags & WMcMenuItemFlag_Divider) { UUtInt16 divider_height; - + // calculate the divider height PSrPartSpec_GetSize(partspec_ui->divider, PScPart_LeftTop, NULL, ÷r_height); @@ -1195,11 +1195,11 @@ WMrMenu_InsertItem( { TStFontInfo font_info; UUtRect rect; - + // get the font info WMrWindow_GetFontInfo(inMenu, &font_info); DCrText_SetFontInfo(&font_info); - + // get the dimensions of the string DCrText_GetStringRect(menu_items[index].item_data.title, &rect); menu_items[index].line_width = rect.right - rect.left; @@ -1208,9 +1208,9 @@ WMrMenu_InsertItem( // we must recalculate our layout before we can draw or accept mouse events private_data->recalc_layout = UUcTrue; - + UUrMemory_Block_VerifyList(); - + return UUcError_None; cleanup: @@ -1218,7 +1218,7 @@ WMrMenu_InsertItem( { UUrMemory_Array_DeleteElement(private_data->menu_items, index); } - + return UUcError_Generic; } @@ -1228,7 +1228,7 @@ WMrMenu_RegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register( WMcTemplate_MenuData, @@ -1248,29 +1248,29 @@ WMrMenu_RemoveItem( WMtMenu_PrivateData *private_data; WMtMenuItem *menu_items; UUtUns32 i; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return UUcError_Generic; } if (private_data->menu_items == NULL) { return UUcError_Generic; } - + // get the array pointer menu_items = (WMtMenuItem*)UUrMemory_Array_GetMemory(private_data->menu_items); if (menu_items == NULL) { return UUcError_Generic; } - + // find the specified item by id for (i = 0; i < UUrMemory_Array_GetUsedElems(private_data->menu_items); i++) { if (menu_items[i].item_data.id == inItemID) { break; } } if (i == UUrMemory_Array_GetUsedElems(private_data->menu_items)) { return UUcError_None; } - + // we must recalculate our layout before we can draw or accept mouse events private_data->recalc_layout = UUcTrue; - + // remove the specified item UUrMemory_Array_DeleteElement(private_data->menu_items, i); - + return UUcError_None; } @@ -1280,17 +1280,17 @@ WMrMenu_Reset( WMtMenu *inMenu) { WMtMenu_PrivateData *private_data; - + // get the private data private_data = (WMtMenu_PrivateData*)WMrWindow_GetLong(inMenu, 0); if (private_data == NULL) { return UUcError_Generic; } if (private_data->menu_items == NULL) { return UUcError_Generic; } - + // remove all of the menu items UUrMemory_Array_SetUsedElems(private_data->menu_items, 0, NULL); - + // we must recalculate our layout before we can draw or accept mouse events private_data->recalc_layout = UUcTrue; - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Menu.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Menu.h index bed6614..8012c3f 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Menu.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Menu.h @@ -16,7 +16,7 @@ enum { WMcMenuStyle_None = (0x0000 << 16), - + // CB: menus now do their own background drawing, rather than using NC drawing code WMcMenuStyle_Standard = 0 }; @@ -27,7 +27,7 @@ enum WMcMenuItemFlag_Divider = 0x0001, WMcMenuItemFlag_Enabled = 0x0002, WMcMenuItemFlag_Checked = 0x0004 - + }; // ====================================================================== @@ -41,7 +41,7 @@ typedef tm_struct WMtMenuItemData UUtUns16 flags; UUtUns16 id; char title[64]; // WMcMaxTitleLength + 1 - + } WMtMenuItemData; #define WMcTemplate_MenuData UUm4CharToUns32('W', 'M', 'M', '_') @@ -49,13 +49,13 @@ typedef tm_template('W', 'M', 'M', '_', "WM Menu") WMtMenuData { tm_pad pad0[18]; - + UUtUns16 id; char title[64]; // WMcMaxTitleLength + 1 - + tm_varindex UUtUns32 num_items; tm_vararray WMtMenuItemData items[1]; - + } WMtMenuData; // ====================================================================== @@ -65,24 +65,24 @@ UUtError WMrMenu_AppendItem( WMtMenu *inMenu, WMtMenuItemData *inMenuItemData); - + WMtMenu* WMrMenu_Create( WMtMenuData *inMenuData, WMtWindow *inParent); - + UUtBool WMrMenu_EnableItem( WMtMenu *inMenu, UUtUns16 inItemID, UUtBool inEnable); - + UUtBool WMrMenu_CheckItem( WMtMenu *inMenu, UUtUns16 inItemID, UUtBool inCheck); - + UUtBool WMrMenu_FindItemByText( WMtMenu *inMenu, @@ -94,25 +94,25 @@ WMrMenu_FindItemByText_NoCase( WMtMenu *inMenu, char *inText, UUtUns16 *outItemID); - + UUtBool WMrMenu_GetItemFlags( WMtMenu *inMenu, UUtUns16 inItemID, UUtUns16 *outFlags); - + UUtBool WMrMenu_GetItemID( WMtMenu *inMenu, UUtInt16 inItemIndex, UUtUns16 *outID); - + UUtBool WMrMenu_GetItemText( WMtMenu *inMenu, UUtUns16 inItemID, char *outText); - + UUtError WMrMenu_Initialize( void); @@ -126,16 +126,16 @@ WMrMenu_InsertItem( UUtError WMrMenu_RegisterTemplates( void); - + UUtError WMrMenu_RemoveItem( WMtMenu *inMenu, UUtUns16 inItemID); - + UUtError WMrMenu_Reset( WMtMenu *inMenu); - + void WMrMenu_Locate( WMtMenu *inMenu, @@ -147,4 +147,4 @@ WMrMenu_GetWidth( WMtMenu *inMenu); // ====================================================================== -#endif /* WM_MENU_H */ \ No newline at end of file +#endif /* WM_MENU_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_MenuBar.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_MenuBar.c index 709dc98..077915c 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_MenuBar.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_MenuBar.c @@ -42,7 +42,7 @@ typedef struct WMtMenuBarItem IMtPoint2D location; UUtUns16 width; // text width UUtUns16 height; // text height - + } WMtMenuBarItem; @@ -52,10 +52,10 @@ typedef struct WMtMenuBar_PrivateData UUtInt32 hilited_menu; UUtBool is_sticky; UUtBool active; - + UUtInt32 num_menubar_items; WMtMenuBarItem menubar_items[WMcMenuBar_MaxNumMenus]; - + } WMtMenuBar_PrivateData; // ====================================================================== @@ -70,26 +70,26 @@ WMiMenuBar_GetMenuUnderPoint( { UUtInt32 i; UUtInt16 menubar_height; - + WMrWindow_GetSize(inMenuBar, NULL, &menubar_height); - + for (i = 0; i < inPrivateData->num_menubar_items; i++) { UUtRect bounds; - + // setup the bounds bounds.left = inPrivateData->menubar_items[i].location.x; bounds.top = 0; bounds.right = bounds.left + inPrivateData->menubar_items[i].width + WMcMenuBar_Spacing; bounds.bottom = menubar_height; - + // check the point if (IMrRect_PointIn(&bounds, inPoint)) { return i; } } - + return WMcMenuBar_MaxNumMenus; } @@ -101,36 +101,36 @@ WMiMenuBar_RecalcMenuBarItemPositions( { UUtInt32 i; IMtPoint2D title_location; - + // make sure that there are menubar items and a text context if (inPrivateData->num_menubar_items == 0) { return; } - + // set the start location for the menu titles title_location.x = WMcMenuBar_Unused_Left; title_location.y = 0; - - // set the location of the menus + + // set the location of the menus for (i = 0; i < inPrivateData->num_menubar_items; i++) { UUtRect bounds; // move to the location of the title title_location.x += WMcMenuBar_Spacing_Left; - + // set the location of the menu's title inPrivateData->menubar_items[i].location = title_location; - + // get the string bounding the title DCrText_GetStringRect( WMrWindow_GetTitlePtr(inPrivateData->menubar_items[i].menu), &bounds); - + // add in the width of the title string title_location.x += bounds.right; - + // move to the location of the next menu title title_location.x += WMcMenuBar_Spacing_Right; } @@ -157,12 +157,12 @@ WMiMenuBar_Create( UUtInt16 menubar_height; WMtMenuBar_PrivateData *private_data; TStFontInfo font_info; - + // get the private data private_data = (WMtMenuBar_PrivateData*)UUrMemory_Block_NewClear(sizeof(WMtMenuBar_PrivateData)); if (private_data == NULL) { return WMcResult_Error; } WMrWindow_SetLong(inMenuBar, 0, (UUtUns32)private_data); - + if (inMenuBarData->num_menus > WMcMenuBar_MaxNumMenus) { return UUcError_Generic; @@ -171,35 +171,35 @@ WMiMenuBar_Create( // get the height of the background's borders partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { goto cleanup; } - + PSrPartSpec_GetSize(partspec_ui->background, PScPart_LeftTop, NULL, &top_height); PSrPartSpec_GetSize(partspec_ui->background, PScPart_RightBottom, NULL, &bottom_height); - + WMrWindow_GetFontInfo(inMenuBar, &font_info); DCrText_SetFontInfo(&font_info); - + // set the height of the menubar height = top_height + bottom_height + DCrText_GetLineHeight(); - + WMrWindow_GetSize(inMenuBar, &menubar_width, &menubar_height); - + if ((UUtUns16)menubar_height < height) { WMrWindow_SetSize(inMenuBar, menubar_width, height); } - + // create the menu windows private_data->num_menubar_items = 0; for (i = 0; i < inMenuBarData->num_menus; i++) { WMtMenu *menu; - + menu = WMrMenu_Create(inMenuBarData->menus[i], inMenuBar); if (menu == NULL) { goto cleanup; } - + error = WMrMenuBar_AppendMenu(inMenuBar, menu); if (error != UUcError_None) { goto cleanup; } } @@ -207,17 +207,17 @@ WMiMenuBar_Create( private_data->hilited_menu = WMcMenuBar_MaxNumMenus; private_data->is_sticky = UUcFalse; private_data->active = UUcFalse; - + return WMcResult_Handled; cleanup: UUmAssert(0); - + if (private_data) { UUrMemory_Block_Delete(private_data); } - + return WMcResult_Error; } @@ -227,11 +227,11 @@ WMiMenuBar_Destroy( WMtMenuBar *inMenuBar) { WMtMenuBar_PrivateData *private_data; - + // get the private data private_data = (WMtMenuBar_PrivateData*)WMrWindow_GetLong(inMenuBar, 0); if (private_data == NULL) { return; } - + UUrMemory_Block_Delete(private_data); WMrWindow_SetLong(inMenuBar, 0, 0); } @@ -244,17 +244,17 @@ WMiMenuBar_HiliteMenu( { UUtUns32 menu_index; WMtMenuBar_PrivateData *private_data; - + // get the private data private_data = (WMtMenuBar_PrivateData*)WMrWindow_GetLong(inMenuBar, 0); if (private_data == NULL) { return; } - + menu_index = WMiMenuBar_GetMenuUnderPoint(inMenuBar, private_data, inLocalMouse); if (menu_index != WMcMenuBar_MaxNumMenus) { UUtRect window_rect; IMtPoint2D menu_location; - + // set the location of the menu WMrWindow_GetRect(inMenuBar, &window_rect); WMrWindow_LocalToGlobal( @@ -262,16 +262,16 @@ WMiMenuBar_HiliteMenu( &private_data->menubar_items[menu_index].location, &menu_location); menu_location.y = window_rect.bottom - 1; - + WMrMenu_Locate((WMtMenu *) private_data->menubar_items[menu_index].menu, &menu_location, UUcTrue); - + // tell the parent that the menu is about to become active WMrMessage_Send( WMrWindow_GetParent(inMenuBar), WMcMessage_MenuInit, (UUtUns32)private_data->menubar_items[menu_index].menu, UUmMakeLong(WMrWindow_GetID(private_data->menubar_items[menu_index].menu), menu_index)); - + // make the menu visible WMrWindow_SetVisible(private_data->menubar_items[menu_index].menu, UUcTrue); private_data->hilited_menu = menu_index; @@ -285,11 +285,11 @@ WMiMenuBar_UnhiliteMenu( UUtBool inIsSticky) { WMtMenuBar_PrivateData *private_data; - + // get the private data private_data = (WMtMenuBar_PrivateData*)WMrWindow_GetLong(inMenuBar, 0); if (private_data == NULL) { return; } - + if (private_data->hilited_menu != WMcMenuBar_MaxNumMenus) { WMrWindow_SetVisible( @@ -297,7 +297,7 @@ WMiMenuBar_UnhiliteMenu( UUcFalse); private_data->hilited_menu = WMcMenuBar_MaxNumMenus; } - + private_data->is_sticky = inIsSticky; } @@ -310,11 +310,11 @@ WMiMenuBar_ForwardMessage( UUtUns32 inParam2) { WMtMenuBar_PrivateData *private_data; - + // get the private data private_data = (WMtMenuBar_PrivateData*)WMrWindow_GetLong(inMenuBar, 0); if (private_data == NULL) { return; } - + if (private_data->hilited_menu != WMcMenuBar_MaxNumMenus) { WMrMessage_Send( @@ -332,15 +332,15 @@ WMiMenuBar_HandleCaptureChanged( WMtMenuBar *inMenuBar) { WMtMenuBar_PrivateData *private_data; - + // get the private data private_data = (WMtMenuBar_PrivateData*)WMrWindow_GetLong(inMenuBar, 0); if (private_data == NULL) { return; } - + // turn off the previously hilited menu WMiMenuBar_UnhiliteMenu(inMenuBar, UUcFalse); - - private_data->active = UUcFalse; + + private_data->active = UUcFalse; } // ---------------------------------------------------------------------- @@ -354,17 +354,17 @@ WMiMenuBar_HandleMouseEvent( IMtPoint2D global_mouse; IMtPoint2D local_mouse; WMtMenuBar_PrivateData *private_data; - + // get the private data private_data = (WMtMenuBar_PrivateData*)WMrWindow_GetLong(inMenuBar, 0); if (private_data == NULL) { return; } - + // get the global mouse location global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam1); - + WMrWindow_GlobalToLocal(inMenuBar, &global_mouse, &local_mouse); - + switch (inMessage) { case WMcMessage_MouseMove: @@ -375,7 +375,7 @@ WMiMenuBar_HandleMouseEvent( { // unhilite the currently hilited menu WMiMenuBar_UnhiliteMenu(inMenuBar, UUcTrue); - + // hilite the newly hilited menu WMiMenuBar_HiliteMenu(inMenuBar, &local_mouse); } @@ -386,10 +386,10 @@ WMiMenuBar_HandleMouseEvent( } } break; - + case WMcMessage_LMouseDown: WMrWindow_SetFocus(inMenuBar); - + if (private_data->active) { // forward the message @@ -399,12 +399,12 @@ WMiMenuBar_HandleMouseEvent( { // the menu bar is active private_data->active = UUcTrue; - + if (private_data->is_sticky) { // no longer sticky private_data->is_sticky = UUcFalse; - + // release the mouse (this will cause the menu to close because // it will send WMcMessage_CaptureChanged to the menubar callback) WMrWindow_CaptureMouse(NULL); @@ -413,22 +413,22 @@ WMiMenuBar_HandleMouseEvent( { // capture the mouse WMrWindow_CaptureMouse(inMenuBar); - + // hilite the menu under the mouse point visible WMiMenuBar_HiliteMenu(inMenuBar, &local_mouse); } - + // save the time the mouse went down private_data->mouse_sticky_time = UUrMachineTime_Sixtieths() + WMcMenuBar_StickyDelay; } break; - + case WMcMessage_LMouseUp: { UUtUns32 time; - + time = UUrMachineTime_Sixtieths(); - + // check for sticky menu if ((private_data->mouse_sticky_time > time ) && (private_data->hilited_menu != WMcMenuBar_MaxNumMenus)) @@ -439,11 +439,11 @@ WMiMenuBar_HandleMouseEvent( { // forward the message to the open menu WMiMenuBar_ForwardMessage(inMenuBar, inMessage, inParam1, inParam2); - + // release the mouse (this will cause the menu to close because // it will send WMcMessage_CaptureChanged to the menubar callback) WMrWindow_CaptureMouse(NULL); - + // the menu bar is no longer active private_data->active = UUcFalse; } @@ -462,39 +462,39 @@ WMiMenuBar_Paint( PStPartSpecUI *partspec_ui; WMtMenuBar_PrivateData *private_data; TStFontInfo font_info; - + // get the private data private_data = (WMtMenuBar_PrivateData*)WMrWindow_GetLong(inMenuBar, 0); if (private_data == NULL) { return; } - + partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) return; - + draw_context = DCrDraw_Begin(inMenuBar); - + WMrWindow_GetFontInfo(inMenuBar, &font_info); DCrText_SetFontInfo(&font_info); - + // draw the menu titles for (i = 0; i < private_data->num_menubar_items; i++) { UUtBool enabled; IMtPoint2D dest; - + dest.x = private_data->menubar_items[i].location.x; dest.y = 0; - + enabled = WMrWindow_GetEnabled(private_data->menubar_items[i].menu); - + if ((private_data->hilited_menu == i) && (enabled)) { UUtUns16 width; UUtUns16 height; - + // set the width and height width = private_data->menubar_items[i].width + WMcMenuBar_Spacing; height = private_data->menubar_items[i].height; - + DCrDraw_PartSpec( draw_context, partspec_ui->hilite, @@ -504,10 +504,10 @@ WMiMenuBar_Paint( (UUtInt16)height, M3cMaxAlpha); } - + dest.x += WMcMenuBar_Spacing_Left; dest.y += DCrText_GetAscendingHeight(); - + DCrText_SetShade(enabled ? font_info.font_shade : IMcShade_Gray50); DCrText_SetFormat(TSc_HLeft); DCrDraw_String( @@ -516,7 +516,7 @@ WMiMenuBar_Paint( NULL, &dest); } - + DCrDraw_End(draw_context, inMenuBar); } @@ -534,40 +534,40 @@ WMiMenuBar_Callback( UUtUns32 inParam2) { UUtUns32 result; - + // handle the message switch (inMessage) { case WMcMessage_NC_HitTest: return WMcWindowArea_Client; - + case WMcMessage_Create: // create the menubar result = WMiMenuBar_Create(inMenuBar, (WMtMenuBarData*)inParam1); return result; - + case WMcMessage_Destroy: WMiMenuBar_Destroy(inMenuBar); return WMcResult_Handled; - + case WMcMessage_MouseMove: case WMcMessage_LMouseDown: case WMcMessage_LMouseUp: WMiMenuBar_HandleMouseEvent(inMenuBar, inMessage, inParam1, inParam2); return WMcResult_Handled; - + case WMcMessage_Paint: WMiMenuBar_Paint(inMenuBar); return WMcResult_Handled; - + case WMcMessage_CaptureChanged: WMiMenuBar_HandleCaptureChanged(inMenuBar); return WMcResult_Handled; - + case WMcMessage_MenuCommand: // turn off the previously hilited menu WMiMenuBar_UnhiliteMenu(inMenuBar, UUcFalse); - + // turn off mouse capture WMrWindow_CaptureMouse(NULL); @@ -580,7 +580,7 @@ WMiMenuBar_Callback( inParam2); return result; } - + return WMrWindow_DefaultCallback(inMenuBar, inMessage, inParam1, inParam2); } @@ -610,7 +610,7 @@ WMrMenuBar_Create( UUtInt16 width; WMtMenuBarData *menubar_data; UUtUns32 flags; - + // get the menubar data error = TMrInstance_GetDataPtr( @@ -618,17 +618,17 @@ WMrMenuBar_Create( inMenuBarName, &menubar_data); if (error != UUcError_None) { return NULL; } - + // set the flags flags = WMcWindowFlag_Visible | WMcWindowFlag_TopMost; if (inParent) { flags |= WMcWindowFlag_Child; } - + // get the width of the parent WMrWindow_GetClientRect(inParent, &client_rect); - + // calculate the width of the client rect width = client_rect.right - client_rect.left; - + // create the menubar menubar = WMrWindow_New( @@ -655,18 +655,18 @@ WMrMenuBar_GetMenu( WMtMenu *menu; WMtMenuBar_PrivateData *private_data; UUtInt32 i; - + // get the private data private_data = (WMtMenuBar_PrivateData*)WMrWindow_GetLong(inMenuBar, 0); UUmAssert(private_data); - + menu = NULL; - + // find the menu with id == inMenuID for (i = 0; i < private_data->num_menubar_items; i++) { UUtUns16 id; - + id = WMrWindow_GetID(private_data->menubar_items[i].menu); if (id == inMenuID) { @@ -674,7 +674,7 @@ WMrMenuBar_GetMenu( break; } } - + return menu; } @@ -688,16 +688,16 @@ WMrMenuBar_InsertMenu( UUtInt32 index; WMtMenuBar_PrivateData *private_data; UUtRect bounds; - + // get the private data private_data = (WMtMenuBar_PrivateData*)WMrWindow_GetLong(inMenuBar, 0); UUmAssert(private_data); - + if (private_data->num_menubar_items == WMcMenuBar_MaxNumMenus) { return UUcError_Generic; } - + // insert the menu if (inIndex == -1) { @@ -713,32 +713,32 @@ WMrMenuBar_InsertMenu( else { UUtInt32 i; - + for (i = (UUtInt32)inIndex; i < private_data->num_menubar_items; i++) { private_data->menubar_items[i + 1] = private_data->menubar_items[i]; } - + index = (UUtInt32)inIndex; } } - + // set the menubar item info private_data->menubar_items[index].location.x = 0; private_data->menubar_items[index].location.y = 0; private_data->menubar_items[index].menu = inMenu; private_data->num_menubar_items++; - + DCrText_GetStringRect( WMrWindow_GetTitlePtr(private_data->menubar_items[index].menu), &bounds); - + private_data->menubar_items[index].width = bounds.right - bounds.left; private_data->menubar_items[index].height = bounds.bottom - bounds.top; - + // recalc menu positions WMiMenuBar_RecalcMenuBarItemPositions(inMenuBar, private_data); - + return UUcError_None; } @@ -749,16 +749,16 @@ WMrMenuBar_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_MenuBar; window_class.callback = WMiMenuBar_Callback; window_class.private_data_size = sizeof(WMtMenuBar_PrivateData*); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -768,7 +768,7 @@ WMrMenuBar_RegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register( WMcTemplate_MenuBarData, @@ -786,13 +786,13 @@ WMrMenuBar_RemoveMenu( UUtUns16 inMenuID) { WMtMenuBar_PrivateData *private_data; - + // get the private data private_data = (WMtMenuBar_PrivateData*)WMrWindow_GetLong(inMenuBar, 0); UUmAssert(private_data); - + UUmAssert(!"The rest isn't written yet"); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_MenuBar.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_MenuBar.h index f882615..b163293 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_MenuBar.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_MenuBar.h @@ -32,12 +32,12 @@ typedef tm_template('W', 'M', 'M', 'B', "WM Menu Bar") WMtMenuBarData { tm_pad pad[18]; - + UUtUns16 id; - + tm_varindex UUtUns32 num_menus; tm_vararray WMtMenuData *menus[1]; - + } WMtMenuBarData; // ====================================================================== @@ -52,12 +52,12 @@ WMtMenuBar* WMrMenuBar_Create( WMtWindow *inParent, char *inMenuBarName); - + WMtMenu* WMrMenuBar_GetMenu( WMtMenuBar *inMenuBar, UUtUns16 inMenuID); - + UUtError WMrMenuBar_Initialize( void); @@ -78,4 +78,4 @@ WMrMenuBar_RemoveMenu( UUtUns16 inMenuID); // ====================================================================== -#endif /* WM_MENUBAR_H */ \ No newline at end of file +#endif /* WM_MENUBAR_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Picture.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Picture.c index d59832a..2df24ee 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Picture.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Picture.c @@ -21,9 +21,9 @@ WMiPicture_Create( UUtError error; UUtUns32 style; void *texture_ref; - + texture_ref = NULL; - + style = WMrWindow_GetStyle(inPicture); if ((style & WMcPictureStyle_SetAtRuntime) == 0) { @@ -41,14 +41,14 @@ WMiPicture_Create( WMrWindow_GetTitlePtr(inPicture), &texture_ref); } - + WMrWindow_SetLong(inPicture, 0, (UUtUns32)texture_ref); } else { WMrWindow_SetLong(inPicture, 0, (UUtUns32)texture_ref); } - + return WMcResult_Handled; } @@ -59,14 +59,14 @@ WMiPicture_HandleSetPartSpec( UUtUns32 inParam1) { TMtTemplateTag template_tag; - + // get the template tag template_tag = TMrInstance_GetTemplateTag((void*)inParam1); if (template_tag != PScTemplate_PartSpecification) { return; } - + WMrWindow_SetLong(inPicture, 0, inParam1); } @@ -77,7 +77,7 @@ WMiPicture_HandleSetPicture( UUtUns32 inParam1) { TMtTemplateTag template_tag; - + // get the template tag template_tag = TMrInstance_GetTemplateTag((void*)inParam1); if ((template_tag != M3cTemplate_TextureMap) && @@ -85,7 +85,7 @@ WMiPicture_HandleSetPicture( { return; } - + WMrWindow_SetLong(inPicture, 0, inParam1); } @@ -101,19 +101,19 @@ WMiPicture_Paint( void *template_ref; TMtTemplateTag template_tag; UUtUns32 style; - + // get the template ref stored in the long template_ref = (void*)WMrWindow_GetLong(inPicture, 0); if (template_ref == NULL) { return; } - + draw_context = DCrDraw_Begin(inPicture); - + // get the width and height of the window WMrWindow_GetSize(inPicture, &width, &height); - + dest.x = 0; dest.y = 0; - + template_tag = TMrInstance_GetTemplateTag(template_ref); switch (template_tag) { @@ -121,18 +121,18 @@ WMiPicture_Paint( case M3cTemplate_TextureMap_Big: // get the picture style style = WMrWindow_GetStyle(inPicture); - + if ((style & WMcPictureStyle_Scale) == 0) { UUtUns16 texture_width; UUtUns16 texture_height; - + M3rTextureRef_GetSize(template_ref, &texture_width, &texture_height); - + width = UUmMin(width, texture_width); height = UUmMin(height, texture_height); } - + // draw the texture ref DCrDraw_TextureRef( draw_context, @@ -143,7 +143,7 @@ WMiPicture_Paint( UUcFalse, M3cMaxAlpha); break; - + case PScTemplate_PartSpecification: // draw the part spec DCrDraw_PartSpec( @@ -156,7 +156,7 @@ WMiPicture_Paint( M3cMaxAlpha); break; } - + DCrDraw_End(draw_context, inPicture); } @@ -174,26 +174,26 @@ WMiPicture_Callback( UUtUns32 inParam2) { UUtUns32 result; - + switch(inMessage) { case WMcMessage_Create: result = WMiPicture_Create(inPicture); return result; - + case WMcMessage_Paint: WMiPicture_Paint(inPicture); return WMcResult_Handled; - + case PTcMessage_SetPartSpec: WMiPicture_HandleSetPartSpec(inPicture, inParam1); return WMcResult_Handled; - + case PTcMessage_SetPicture: WMiPicture_HandleSetPicture(inPicture, inParam1); return WMcResult_Handled; } - + return WMrWindow_DefaultCallback(inPicture, inMessage, inParam1, inParam2); } @@ -209,16 +209,16 @@ WMrPicture_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_Picture; window_class.callback = WMiPicture_Callback; window_class.private_data_size = sizeof(UUtUns32); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -230,7 +230,7 @@ WMrPicture_SetPartSpec( { UUmAssert(inPicture); UUmAssert(inPartSpec); - + WMrMessage_Send(inPicture, PTcMessage_SetPartSpec, (UUtUns32)inPartSpec, 0); } @@ -242,6 +242,6 @@ WMrPicture_SetPicture( { UUmAssert(inPicture); UUmAssert(inTexture); - + WMrMessage_Send(inPicture, PTcMessage_SetPicture, (UUtUns32)inTexture, 0); -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Picture.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Picture.h index 920db2e..3dc918a 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Picture.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Picture.h @@ -20,7 +20,7 @@ enum WMcPictureStyle_None = (0x0000 << 16), WMcPictureStyle_Scale = (0x0001 << 16), WMcPictureStyle_SetAtRuntime = (0x0002 << 16) - + }; // ====================================================================== @@ -39,11 +39,11 @@ void WMrPicture_SetPartSpec( WMtPicture *inPicture, void *inPartSpec); - + void WMrPicture_SetPicture( WMtPicture *inPicture, void *inTexture); - + // ====================================================================== -#endif /* WM_PICTURE_H */ \ No newline at end of file +#endif /* WM_PICTURE_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_PopupMenu.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_PopupMenu.c index 50e89d5..8002de9 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_PopupMenu.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_PopupMenu.c @@ -26,10 +26,10 @@ typedef struct WMtPopupMenu_PrivateData { UUtUns32 mouse_sticky_time; UUtBool is_sticky; - + WMtMenu *menu; UUtUns16 visible_itemID; - + } WMtPopupMenu_PrivateData; // ====================================================================== @@ -43,17 +43,17 @@ WMiPopupMenu_SetMenuPosition( WMtPopupMenu_PrivateData *private_data; UUtRect popup_menu_rect; IMtPoint2D dest; - + // get the private data private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return; } - + // make sure there is a menu if (private_data->menu == NULL) { return; } - + // get the popup menu rect WMrWindow_GetRect(inPopupMenu, &popup_menu_rect); - + // calculate the position of the menu dest.x = popup_menu_rect.left; dest.y = popup_menu_rect.top; @@ -76,22 +76,22 @@ WMiPopupMenu_Update( char title[WMcMaxTitleLength + 1]; UUtUns32 style; TStFontInfo font_info; - + // get the font info WMrWindow_GetFontInfo(inPopupMenu, &font_info); DCrText_SetFontInfo(&font_info); - + // get the private data private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return; } - + // make sure there is a menu if (private_data->menu == NULL) { return; } - + // get the active partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + // get the part sizes PSrPartSpec_GetSize( partspec_ui->popup_menu, @@ -103,19 +103,19 @@ WMiPopupMenu_Update( PScPart_RightBottom, &part_right_width, &part_bottom_height); - + // get the height of the popup popup_height = part_top_height + part_bottom_height + DCrText_GetLineHeight(); - + // get the text of the currently selected menu item WMrMenu_GetItemText(private_data->menu, private_data->visible_itemID, title); - + // set the title text WMrWindow_SetTitle(inPopupMenu, title, WMcMaxTitleLength); - + // adjust the width of the popup style = WMrWindow_GetStyle(inPopupMenu); if (((style & WMcPopupMenuStyle_NoResize) == 0) && @@ -123,7 +123,7 @@ WMiPopupMenu_Update( { // get the width of the menu popup_width = WMrMenu_GetWidth(private_data->menu); - + if (popup_width > 0) { // set the size of the popup @@ -148,28 +148,28 @@ WMiPopupMenu_Create( char title[WMcMaxTitleLength + 1]; UUtUns32 style; TStFontInfo font_info; - + // get the private data private_data = (WMtPopupMenu_PrivateData*)UUrMemory_Block_NewClear( sizeof(WMtPopupMenu_PrivateData)); if (private_data == NULL) { return WMcResult_Error; } WMrWindow_SetLong(inPopupMenu, 0, (UUtUns32)private_data); - + // initialize private_data->mouse_sticky_time = 0; private_data->is_sticky = UUcFalse; private_data->menu = NULL; private_data->visible_itemID = 0; - + menu_data = NULL; - + style = WMrWindow_GetStyle(inPopupMenu); if ((style & WMcPopupMenuStyle_BuildAtRuntime) == 0) { // get the menu instance name WMrWindow_GetTitle(inPopupMenu, title, WMcMaxTitleLength); - + // get the menu data error = TMrInstance_GetDataPtr( @@ -178,25 +178,25 @@ WMiPopupMenu_Create( &menu_data); if (error != UUcError_None) { goto cleanup; } } - + // create the data private_data->menu = WMrMenu_Create(menu_data, inPopupMenu); if (private_data->menu == NULL) { goto cleanup; } - + // set the font info of the menu WMrWindow_GetFontInfo(inPopupMenu, &font_info); WMrWindow_SetFontInfo(private_data->menu, &font_info); - + // get the item id of the first item in the list WMrMenu_GetItemID(private_data->menu, 0, &private_data->visible_itemID); - + // update the popup menu WMiPopupMenu_Update(inPopupMenu); - + return WMcResult_Handled; cleanup: - + if (private_data) { UUrMemory_Block_Delete(private_data); @@ -213,21 +213,21 @@ WMiPopupMenu_Destroy( WMtPopupMenu *inPopupMenu) { WMtPopupMenu_PrivateData *private_data; - + // get the private data private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return; } - + // delete the menu if (private_data->menu) { WMrWindow_Delete(private_data->menu); private_data->menu = NULL; } - + UUrMemory_Block_Delete(private_data); private_data = NULL; - + WMrWindow_SetLong(inPopupMenu, 0, 0); } @@ -241,12 +241,12 @@ WMiPopupMenu_HandleCaptureChanged( // get the private data private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return; } - + if (private_data->menu) { WMrWindow_SetVisible(private_data->menu, UUcFalse); } - + private_data->is_sticky = UUcFalse; } @@ -259,24 +259,24 @@ WMiPopupMenu_HandleMenuCommand( { WMtPopupMenu_PrivateData *private_data; UUtUns32 result; - + // get the private data private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return WMcResult_Error; } - + // hide the menu if (private_data->menu) { WMrWindow_SetVisible(private_data->menu, UUcFalse); } private_data->is_sticky = UUcFalse; - + // save the menu item selected private_data->visible_itemID = (UUtUns16)UUmLowWord(inParam1); - + // update the popup menu WMiPopupMenu_Update(inPopupMenu); - + // turn off the mouse capture WMrWindow_CaptureMouse(NULL); @@ -301,23 +301,23 @@ WMiPopupMenu_HandleMouseEvent( WMtPopupMenu_PrivateData *private_data; IMtPoint2D global_mouse; IMtPoint2D local_mouse; - + // disabled popup menus don't handle mouse events if (WMrWindow_GetEnabled(inPopupMenu) == UUcFalse) { return; } - + // get the private data private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return; } - + // there is no point in running the rest of the function if there is no menu if (private_data->menu == NULL) { return; } - + // get the local mouse location global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam2); - + WMrWindow_GlobalToLocal(inPopupMenu, &global_mouse, &local_mouse); - + switch (inMessage) { case WMcMessage_MouseMove: @@ -327,22 +327,22 @@ WMiPopupMenu_HandleMouseEvent( WMrMessage_Send(private_data->menu, inMessage, inParam1, inParam2); } break; - + case WMcMessage_LMouseDown: WMrWindow_SetFocus(inPopupMenu); - + if (WMrWindow_GetVisible(private_data->menu) == UUcTrue) { // forward the message - WMrMessage_Send(private_data->menu, inMessage, inParam1, inParam2); + WMrMessage_Send(private_data->menu, inMessage, inParam1, inParam2); break; } - + if (private_data->is_sticky) { // no longer sticky private_data->is_sticky = UUcFalse; - + // release the mouse (this will cause the menu to close because it // will send WMcMessage_CaptureChanged to the popup menu callback) WMrWindow_CaptureMouse(NULL); @@ -351,31 +351,31 @@ WMiPopupMenu_HandleMouseEvent( { // capture the mouse WMrWindow_CaptureMouse(inPopupMenu); - + // set the position of the menu WMiPopupMenu_SetMenuPosition(inPopupMenu); - + // tell the parent that the menu is about to become active WMrMessage_Send( WMrWindow_GetParent(inPopupMenu), WMcMessage_MenuInit, (UUtUns32)private_data->menu, UUmMakeLong(WMrWindow_GetID(private_data->menu), 0)); - + // make the menu visible WMrWindow_SetVisible(private_data->menu, UUcTrue); } - + // save the time the mouse went down private_data->mouse_sticky_time = UUrMachineTime_Sixtieths() + WMcPopupMenu_StickyDelay; break; - + case WMcMessage_LMouseUp: { UUtUns32 time; - + time = UUrMachineTime_Sixtieths(); - + // check for sticky menu if (private_data->mouse_sticky_time > time) { @@ -385,7 +385,7 @@ WMiPopupMenu_HandleMouseEvent( { // forward the message WMrMessage_Send(private_data->menu, inMessage, inParam1, inParam2); - + // release the mouse (this will cause the menu to close because it // will send WMcMessage_CaptureChanged to the popup menu callback) WMrWindow_CaptureMouse(NULL); @@ -402,14 +402,14 @@ WMiPopupMenu_HandleFontInfoChanged( { WMtPopupMenu_PrivateData *private_data; TStFontInfo font_info; - + // get the private data private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return; } - + WMrWindow_GetFontInfo(inPopupMenu, &font_info); WMiPopupMenu_Update(inPopupMenu); - + if (private_data->menu != NULL) { WMrWindow_SetFontInfo(private_data->menu, &font_info); @@ -429,31 +429,31 @@ WMiPopupMenu_Paint( UUtInt16 height; UUtBool enabled; TStFontInfo font_info; - + // get the active part spec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + // get the private data private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return; } - + // get a draw context draw_context = DCrDraw_Begin(inPopupMenu); - + // set the font info WMrWindow_GetFontInfo(inPopupMenu, &font_info); DCrText_SetFontInfo(&font_info); - + // set the dest dest.x = 0; dest.y = 0; - + enabled = WMrWindow_GetEnabled(inPopupMenu); - + // get the width and height WMrWindow_GetSize(inPopupMenu, &width, &height); - + // draw the popup menu's popup menu DCrDraw_PartSpec( draw_context, @@ -463,14 +463,14 @@ WMiPopupMenu_Paint( width, height, M3cMaxAlpha); - + // get the size of the left column of the popupmenu partspec PSrPartSpec_GetSize( partspec_ui->popup_menu, PScPart_LeftTop, &width, NULL); - + // draw the popup menu's title dest.x += 2 + width; DCrText_SetShade(enabled ? font_info.font_shade : IMcShade_Gray50); @@ -480,7 +480,7 @@ WMiPopupMenu_Paint( WMrWindow_GetTitlePtr(inPopupMenu), NULL, &dest); - + // stop drawing DCrDraw_End(draw_context, inPopupMenu); } @@ -504,38 +504,38 @@ WMiPopupMenu_Callback( { case WMcMessage_NC_HitTest: return WMcWindowArea_Client; - + case WMcMessage_Create: result = WMiPopupMenu_Create(inPopupMenu); return result; - + case WMcMessage_Destroy: WMiPopupMenu_Destroy(inPopupMenu); return WMcResult_Handled; - + case WMcMessage_Paint: WMiPopupMenu_Paint(inPopupMenu); return WMcResult_Handled; - + case WMcMessage_MouseMove: case WMcMessage_LMouseDown: case WMcMessage_LMouseUp: WMiPopupMenu_HandleMouseEvent(inPopupMenu, inMessage, inParam1, inParam2); return WMcResult_Handled; - + case WMcMessage_CaptureChanged: WMiPopupMenu_HandleCaptureChanged(inPopupMenu); return WMcResult_Handled; - + case WMcMessage_FontInfoChanged: WMiPopupMenu_HandleFontInfoChanged(inPopupMenu); return WMcResult_Handled; - + case WMcMessage_MenuCommand: result = WMiPopupMenu_HandleMenuCommand(inPopupMenu, inParam1, inParam2); return result; } - + return WMrWindow_DefaultCallback(inPopupMenu, inMessage, inParam1, inParam2); } @@ -556,7 +556,7 @@ WMrPopupMenu_AppendItem( private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return UUcError_Generic; } if (private_data->menu == NULL) { return UUcError_Generic; } - + return WMrMenu_AppendItem(private_data->menu, inMenuItemData); } @@ -607,12 +607,12 @@ WMrPopupMenu_GetItemID( { WMtPopupMenu_PrivateData *private_data; UUtBool result; - + // get the private data private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return UUcFalse; } if (private_data->menu == NULL) { return UUcFalse; } - + // get the item id if (inItemIndex == -1) { @@ -640,7 +640,7 @@ WMrPopupMenu_GetItemText( private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return UUcFalse; } if (private_data->menu == NULL) { return UUcFalse; } - + return WMrMenu_GetItemText(private_data->menu, inItemID, outText); } @@ -651,16 +651,16 @@ WMrPopupMenu_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_PopupMenu; window_class.callback = WMiPopupMenu_Callback; window_class.private_data_size = sizeof(UUtUns32); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -677,7 +677,7 @@ WMrPopupMenu_InsertItem( private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return UUcError_Generic; } if (private_data->menu == NULL) { return UUcError_Generic; } - + return WMrMenu_InsertItem(private_data->menu, inMenuItemData, inPosition); } @@ -694,11 +694,11 @@ WMrPopupMenu_RemoveItem( private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return UUcError_Generic; } if (private_data->menu == NULL) { return UUcError_Generic; } - + // reset the popup menu error = WMrMenu_RemoveItem(private_data->menu, inItemID); UUmError_ReturnOnError(error); - + // update the popup menu WMiPopupMenu_Update(inPopupMenu); @@ -717,14 +717,14 @@ WMrPopupMenu_Reset( private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return UUcError_Generic; } if (private_data->menu == NULL) { return UUcError_Generic; } - + // reset the popup menu error = WMrMenu_Reset(private_data->menu); UUmError_ReturnOnError(error); - + // update the popup menu WMiPopupMenu_Update(inPopupMenu); - + return UUcError_None; } @@ -736,21 +736,21 @@ WMrPopupMenu_SetSelection( { WMtPopupMenu_PrivateData *private_data; UUtUns16 flags; - + // get the private data private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return UUcError_Generic; } if (private_data->menu == NULL) { return UUcError_Generic; } - + // save the menu item selected private_data->visible_itemID = inItemID; - + // get the item flags WMrMenu_GetItemFlags(private_data->menu, inItemID, &flags); - + // update the popup menu WMiPopupMenu_Update(inPopupMenu); - + // tell the parent that a menu was selected WMrMessage_Send( WMrWindow_GetParent(inPopupMenu), @@ -769,12 +769,12 @@ WMrPopupMenu_SelectString( { WMtPopupMenu_PrivateData *private_data; UUtUns16 itemID; - + // get the private data private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return UUcError_Generic; } if (private_data->menu == NULL) { return UUcError_Generic; } - + // find the item to select if (WMrMenu_FindItemByText(private_data->menu, inString, &itemID) == UUcFalse) { itemID = (UUtUns16) -1; @@ -792,12 +792,12 @@ WMrPopupMenu_SelectString_NoCase( { WMtPopupMenu_PrivateData *private_data; UUtUns16 itemID; - + // get the private data private_data = (WMtPopupMenu_PrivateData*)WMrWindow_GetLong(inPopupMenu, 0); if (private_data == NULL) { return UUcError_Generic; } if (private_data->menu == NULL) { return UUcError_Generic; } - + // find the item to select if (WMrMenu_FindItemByText_NoCase(private_data->menu, inString, &itemID) == UUcFalse) { itemID = (UUtUns16) -1; @@ -805,7 +805,7 @@ WMrPopupMenu_SelectString_NoCase( return WMrPopupMenu_SetSelection(inPopupMenu, itemID); } - + UUtError WMrPopupMenu_AppendStringList( @@ -820,7 +820,7 @@ WMrPopupMenu_AppendStringList( return UUcError_Generic; } - for (itr = 0; itr < inCount; itr++) + for (itr = 0; itr < inCount; itr++) { error = WMrPopupMenu_AppendItem_Light(inPopupMenu, (UUtUns16) itr, inList[itr]); @@ -831,4 +831,4 @@ WMrPopupMenu_AppendStringList( } return error; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_PopupMenu.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_PopupMenu.h index 4dcb5a8..98dc957 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_PopupMenu.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_PopupMenu.h @@ -42,7 +42,7 @@ WMrPopupMenu_AppendItem_Light( UUtError WMrPopupMenu_AppendItem_Divider( WMtPopupMenu *inPopupMenu); - + UUtError WMrPopupMenu_AppendItem( WMtPopupMenu *inPopupMenu, @@ -59,13 +59,13 @@ WMrPopupMenu_GetItemID( WMtPopupMenu *inPopupMenu, UUtInt16 inItemIndex, UUtUns16 *outID); - + UUtBool WMrPopupMenu_GetItemText( WMtPopupMenu *inPopupMenu, UUtUns16 inItemID, char *outText); - + UUtError WMrPopupMenu_Initialize( void); @@ -75,7 +75,7 @@ WMrPopupMenu_InsertItem( WMtPopupMenu *inPopupMenu, WMtMenuItemData *inMenuItemData, UUtInt16 inPosition); - + UUtError WMrPopupMenu_RemoveItem( WMtPopupMenu *inPopupMenu, @@ -84,12 +84,12 @@ WMrPopupMenu_RemoveItem( UUtError WMrPopupMenu_Reset( WMtPopupMenu *inPopupMenu); - + UUtError WMrPopupMenu_SetSelection( WMtPopupMenu *inPopupMenu, UUtUns16 inItemID); - + UUtError WMrPopupMenu_SelectString( WMtPopupMenu *inPopupMenu, @@ -99,6 +99,6 @@ UUtError WMrPopupMenu_SelectString_NoCase( WMtPopupMenu *inPopupMenu, char *inString); - + // ====================================================================== -#endif /* WM_POPUPMENU_H */ \ No newline at end of file +#endif /* WM_POPUPMENU_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ProgressBar.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ProgressBar.c index 4f54dbc..ddfae77 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ProgressBar.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ProgressBar.c @@ -19,7 +19,7 @@ WMiProgressBar_Create( WMtProgressBar *inProgressBar) { WMrWindow_SetLong(inProgressBar, 0, 0); - + return WMcResult_Handled; } @@ -35,24 +35,24 @@ WMiProgressBar_Paint( UUtInt16 window_width; UUtInt16 window_height; UUtBool enabled; - + // get the progressbar data progressbar_data = WMrWindow_GetLong(inProgressBar, 0); - + // get the partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + // get the width and height of the window WMrWindow_GetSize(inProgressBar, &window_width, &window_height); - + draw_context = DCrDraw_Begin(inProgressBar); - + enabled = WMrWindow_GetEnabled(inProgressBar); - + dest.x = 0; dest.y = 0; - + DCrDraw_PartSpec( draw_context, partspec_ui->progressbar_track, @@ -61,7 +61,7 @@ WMiProgressBar_Paint( window_width, window_height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); - + if (enabled && (progressbar_data > 0)) { UUtInt16 lt_part_width; @@ -69,27 +69,27 @@ WMiProgressBar_Paint( UUtInt16 rb_part_width; UUtInt16 rb_part_height; UUtInt16 width; - + PSrPartSpec_GetSize( partspec_ui->progressbar_track, PScPart_LeftTop, <_part_width, <_part_height); - + PSrPartSpec_GetSize( partspec_ui->progressbar_track, PScPart_RightBottom, &rb_part_width, &rb_part_height); - + dest.x = lt_part_width - 1; dest.y = lt_part_height - 1; - + window_width = window_width - (lt_part_width + rb_part_width) + 2; window_height = window_height - (lt_part_height + rb_part_height) + 2; - + width = ((UUtInt16)progressbar_data * window_width) / 100; - + if (width < (lt_part_width + rb_part_width)) { width = lt_part_width + rb_part_width; @@ -104,7 +104,7 @@ WMiProgressBar_Paint( window_height, M3cMaxAlpha); } - + DCrDraw_End(draw_context, inProgressBar); } @@ -114,10 +114,10 @@ WMiProgressBar_HandleGetValue( WMtProgressBar *inProgressBar) { UUtUns32 progressbar_data; - + // get the progressbar data progressbar_data = WMrWindow_GetLong(inProgressBar, 0); - + return progressbar_data; } @@ -128,10 +128,10 @@ WMiProgressBar_HandleSetValue( UUtUns32 inPercent) { UUtUns32 progressbar_data; - + // get the progressbar data progressbar_data = WMrWindow_GetLong(inProgressBar, 0); - + if (inPercent < 100) { progressbar_data = inPercent; @@ -140,7 +140,7 @@ WMiProgressBar_HandleSetValue( { progressbar_data = 100; } - + // save the progressbar data WMrWindow_SetLong(inProgressBar, 0, progressbar_data); } @@ -159,26 +159,26 @@ WMiProgressBar_Callback( UUtUns32 inParam2) { UUtUns32 result; - + switch(inMessage) { case WMcMessage_Create: result = WMiProgressBar_Create(inProgressBar); return result; - + case WMcMessage_Paint: WMiProgressBar_Paint(inProgressBar); return WMcResult_Handled; - + case WMcMessage_GetValue: result = WMiProgressBar_HandleGetValue(inProgressBar); return result; - + case WMcMessage_SetValue: WMiProgressBar_HandleSetValue(inProgressBar, inParam1); return WMcResult_Handled; } - + return WMrWindow_DefaultCallback(inProgressBar, inMessage, inParam1, inParam2); } @@ -194,15 +194,15 @@ WMrProgressBar_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_ProgressBar; window_class.callback = WMiProgressBar_Callback; window_class.private_data_size = sizeof(UUtUns32); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ProgressBar.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ProgressBar.h index 512f4e2..767356b 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ProgressBar.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_ProgressBar.h @@ -18,7 +18,7 @@ enum { WMcProgressBarStyle_None = (0x0000 << 16) - + }; // ====================================================================== @@ -34,4 +34,4 @@ WMrProgressBar_Initialize( void); // ====================================================================== -#endif /* WM_PROGRESSBAR_H */ \ No newline at end of file +#endif /* WM_PROGRESSBAR_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_RadioButton.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_RadioButton.c index b298562..f5c309b 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_RadioButton.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_RadioButton.c @@ -24,7 +24,7 @@ enum { WMcRadioButtonFlag_None = 0x0000 << 16, WMcRadioButtonFlag_On = 0x0001 << 16 - + }; // ====================================================================== @@ -36,12 +36,12 @@ WMiRadioButton_Create( WMtRadioButton *inRadioButton) { UUtUns32 radiobutton_data; - + // initialize radiobutton_data = WMrWindow_GetLong(inRadioButton, 0); radiobutton_data = 0; WMrWindow_SetLong(inRadioButton, 0, radiobutton_data); - + return UUcError_None; } @@ -58,17 +58,17 @@ WMiRadioButton_HandleMouseEvent( IMtPoint2D global_mouse; UUtUns32 radiobutton_data; UUtBool notify; - + // get the mouse location global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam1); - + // determine if the mouse is over the radiobutton WMrWindow_GetRect(inRadioButton, &radiobutton_rect); mouse_over_radiobutton = IMrRect_PointIn(&radiobutton_rect, &global_mouse); - + notify = UUcFalse; - + switch (inMessage) { case WMcMessage_LMouseDown: @@ -77,7 +77,7 @@ WMiRadioButton_HandleMouseEvent( radiobutton_data = WMrWindow_GetLong(inRadioButton, 0); radiobutton_data |= LIcMouseState_LButtonDown; break; - + case WMcMessage_LMouseUp: WMrWindow_CaptureMouse(NULL); radiobutton_data = WMrWindow_GetLong(inRadioButton, 0); @@ -86,16 +86,16 @@ WMiRadioButton_HandleMouseEvent( { notify = UUcTrue; } - + // the radio button data may have changed radiobutton_data = WMrWindow_GetLong(inRadioButton, 0); radiobutton_data &= ~LIcMouseState_LButtonDown; break; } - + // save the checkbox data WMrWindow_SetLong(inRadioButton, 0, radiobutton_data); - + // tell the parent if (notify) { @@ -122,32 +122,32 @@ WMiRadioButton_Paint( PStPartSpec *part; UUtUns32 style; UUtBool enabled; - + // get the radiobutton_data radiobutton_data = WMrWindow_GetLong(inRadioButton, 0); - + // get partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + // get the window size WMrWindow_GetSize(inRadioButton, NULL, &height); - + // get the partspec size PSrPartSpec_GetSize( partspec_ui->radiobutton_on, PScPart_LeftTop, &part_width, &part_height); - - // calculate the location for the part + + // calculate the location for the part dest.x = 0; dest.y = (height - part_height) >> 1; enabled = WMrWindow_GetEnabled(inRadioButton); draw_context = DCrDraw_Begin(inRadioButton); - + // draw the checkbox if (radiobutton_data & WMcRadioButtonFlag_On) { @@ -157,7 +157,7 @@ WMiRadioButton_Paint( { part = partspec_ui->radiobutton_off; } - + DCrDraw_PartSpec( draw_context, part, @@ -166,25 +166,25 @@ WMiRadioButton_Paint( part_width, part_height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); - + // draw the title style = WMrWindow_GetStyle(inRadioButton); if (style & WMcRadioButtonStyle_HasTitle) { UUtRect bounds; TStFontInfo font_info; - + WMrWindow_GetFontInfo(inRadioButton, &font_info); DCrText_SetFontInfo(&font_info); - + dest.x = part_width + WMcRadioButton_Buffer; - + WMrWindow_GetClientRect(inRadioButton, &bounds); DCrText_SetShade(enabled ? font_info.font_shade : IMcShade_Gray50); DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrDraw_String(draw_context, WMrWindow_GetTitlePtr(inRadioButton), &bounds, &dest); } - + DCrDraw_End(draw_context, inRadioButton); } @@ -204,15 +204,15 @@ WMiRadioButton_Callback( UUtError error; UUtUns32 result; UUtUns32 radiobutton_data; - + // get the radiobutton_data radiobutton_data = WMrWindow_GetLong(inRadioButton, 0); - + switch(inMessage) { case WMcMessage_NC_HitTest: return WMcWindowArea_Client; - + case WMcMessage_Create: error = WMiRadioButton_Create(inRadioButton); if (error != UUcError_None) @@ -220,7 +220,7 @@ WMiRadioButton_Callback( return WMcResult_Error; } return WMcResult_Handled; - + case WMcMessage_LMouseDown: case WMcMessage_LMouseUp: WMiRadioButton_HandleMouseEvent( @@ -257,7 +257,7 @@ WMiRadioButton_Callback( WMrWindow_SetLong(inRadioButton, 0, radiobutton_data); return WMcResult_Handled; } - + return WMrWindow_DefaultCallback(inRadioButton, inMessage, inParam1, inParam2); } @@ -273,15 +273,15 @@ WMrRadioButton_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_RadioButton; window_class.callback = WMiRadioButton_Callback; window_class.private_data_size = sizeof(UUtUns32); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_RadioButton.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_RadioButton.h index bcf0ea9..7871cb0 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_RadioButton.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_RadioButton.h @@ -20,10 +20,10 @@ enum WMcRadioButtonStyle_None = (0x0000 << 16), WMcRadioButtonStyle_HasTitle = (0x0001 << 16), WMcRadioButtonStyle_HasIcon = (0x0002 << 16), /* not supported yet */ - + WMcRadioButtonStyle_TextRadioButton = (WMcRadioButtonStyle_HasTitle), WMcRadioButtonStyle_IconRadioButton = (WMcRadioButtonStyle_HasIcon) - + }; enum @@ -45,4 +45,4 @@ WMrRadioButton_Initialize( void); // ====================================================================== -#endif /* WM_RADIOBUTTON_H */ \ No newline at end of file +#endif /* WM_RADIOBUTTON_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Scrollbar.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Scrollbar.c index e61a470..523d62e 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Scrollbar.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Scrollbar.c @@ -43,18 +43,18 @@ typedef struct WMtScrollbar_PrivateData UUtUns16 mouse_state; UUtBool is_vertical; UUtUns8 mouse_down_part; - + // scrollbar values UUtInt32 min; UUtInt32 max; UUtInt32 current_value; float range_visible; - + // thumb data IMtPoint2D thumb_location; UUtInt16 thumb_width; UUtInt16 thumb_height; - + // mouse offsets UUtInt16 mouse_x_offset; UUtInt16 mouse_y_offset; @@ -96,10 +96,10 @@ WMiScrollbar_CalculateThumbSize( WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_Track, &track_bounds); int_track_bounds_width = (track_bounds.right - track_bounds.left); int_track_bounds_height = (track_bounds.bottom - track_bounds.top); - + // calculate the range range = (float)(inPrivateData->max - inPrivateData->min); - + if (UUmFloat_CompareEqu(range, 0.0f)) { // set the thumb height and width @@ -114,7 +114,7 @@ WMiScrollbar_CalculateThumbSize( // convert width and height to float float_track_bounds_width = (float)int_track_bounds_width; float_track_bounds_height = (float)int_track_bounds_height; - + if (inPrivateData->is_vertical) { // calculate the thumb height @@ -161,26 +161,26 @@ WMiScrollbar_GetBounds( UUtInt16 part_height; UUtInt16 track_height; UUtInt16 track_width; - + UUtRect track_bounds; UUtRect thumb_bounds; - + UUmAssert(outBounds); - + outBounds->left = 0; outBounds->top = 0; outBounds->right = 0; outBounds->bottom = 0; - + // get the active UI partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + // get the window size WMrWindow_GetSize(inScrollbar, &window_width, &window_height); track_height = window_height; track_width = window_width; - + if (inPrivateData->is_vertical) { switch (inScrollbarPart) @@ -190,43 +190,43 @@ WMiScrollbar_GetBounds( track_height -= part_height; outBounds->right = part_width; outBounds->top = part_height - 1; - + PSrPartSpec_GetSize(partspec_ui->dn_arrow, PScPart_LeftTop, NULL, &part_height); track_height -= part_height; - + outBounds->bottom = outBounds->top + track_height + 2; break; - + case WMcSBPart_PageUp: WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_Track, &track_bounds); WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_Thumb, &thumb_bounds); - + outBounds->left = track_bounds.left; outBounds->top = track_bounds.top; outBounds->right = track_bounds.right; outBounds->bottom = thumb_bounds.top + 1; break; - + case WMcSBPart_PageDown: WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_Track, &track_bounds); WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_Thumb, &thumb_bounds); - + outBounds->left = track_bounds.left; outBounds->top = thumb_bounds.bottom - 1; outBounds->right = track_bounds.right; outBounds->bottom = track_bounds.bottom; break; - + case WMcSBPart_LineUp: PSrPartSpec_GetSize(partspec_ui->up_arrow, PScPart_LeftTop, NULL, &part_height); - + outBounds->right = window_width; outBounds->bottom = part_height; break; case WMcSBPart_LineDown: PSrPartSpec_GetSize(partspec_ui->dn_arrow, PScPart_LeftTop, NULL, &part_height); - + outBounds->top = window_height - part_height; outBounds->right = window_width; outBounds->bottom = window_height; @@ -250,43 +250,43 @@ WMiScrollbar_GetBounds( track_width -= part_width; outBounds->left = part_width - 1; outBounds->bottom = part_height; - + PSrPartSpec_GetSize(partspec_ui->rt_arrow, PScPart_LeftTop, &part_width, NULL); track_width -= part_width; - + outBounds->right = outBounds->left + track_width + 2; break; - + case WMcSBPart_PageUp: WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_Track, &track_bounds); WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_Thumb, &thumb_bounds); - + outBounds->left = track_bounds.left; outBounds->top = track_bounds.top; outBounds->right = thumb_bounds.left + 1; outBounds->bottom = track_bounds.bottom; break; - + case WMcSBPart_PageDown: WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_Track, &track_bounds); WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_Thumb, &thumb_bounds); - + outBounds->left = thumb_bounds.right - 1; outBounds->top = track_bounds.top; outBounds->right = track_bounds.right; outBounds->bottom = track_bounds.bottom; break; - + case WMcSBPart_LineUp: PSrPartSpec_GetSize(partspec_ui->lt_arrow, PScPart_LeftTop, &part_width, NULL); - + outBounds->right = part_width; outBounds->bottom = window_height; break; - + case WMcSBPart_LineDown: PSrPartSpec_GetSize(partspec_ui->rt_arrow, PScPart_LeftTop, &part_width, NULL); - + outBounds->left = window_width - part_width; outBounds->right = window_width; outBounds->bottom = window_height; @@ -315,18 +315,18 @@ WMiScrollBar_GetMouseOverPart( UUtBool in_pageup; UUtBool in_pagedn; UUtBool in_thumb; - + UUtRect bounds; - + // find out what part the mouse is over WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_Thumb, &bounds); in_thumb = IMrRect_PointIn(&bounds, inLocalMouse); if (in_thumb) { return WMcSBPart_Thumb; } - + WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_PageUp, &bounds); in_pageup = IMrRect_PointIn(&bounds, inLocalMouse); if (in_pageup) { return WMcSBPart_PageUp; } - + WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_PageDown, &bounds); in_pagedn = IMrRect_PointIn(&bounds, inLocalMouse); if (in_pagedn) { return WMcSBPart_PageDown; } @@ -334,12 +334,12 @@ WMiScrollBar_GetMouseOverPart( WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_LineUp, &bounds); in_lineup = IMrRect_PointIn(&bounds, inLocalMouse); if (in_lineup) { return WMcSBPart_LineUp; } - + WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_LineDown, &bounds); in_linedn = IMrRect_PointIn(&bounds, inLocalMouse); if (in_linedn) { return WMcSBPart_LineDown; } - - return WMcSBPart_None; + + return WMcSBPart_None; } // ---------------------------------------------------------------------- @@ -353,27 +353,27 @@ WMiScrollbar_GetNewValue( float range; UUtInt32 new_value; UUtRect track_bounds; - + // calculate the range range = (float)(inPrivateData->max - inPrivateData->min); - + // get the track bounds WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_Track, &track_bounds); - + if (inPrivateData->is_vertical) { float track_height; float y_value; - + // calculate the track height minus the thumb height track_height = (float)(track_bounds.bottom - track_bounds.top - inPrivateData->thumb_height); - + // calculate the value of y y_value = (float)((inMouseLocation->y - track_bounds.top) + inPrivateData->mouse_y_offset); - + // calculate the scale scale = range / track_height; - + // calculate the new value new_value = inPrivateData->min + (UUtInt32)(y_value * scale); } @@ -381,20 +381,20 @@ WMiScrollbar_GetNewValue( { float track_width; float x_value; - + // calculate the track width minus the thumb width track_width = (float)(track_bounds.right - track_bounds.left - inPrivateData->thumb_width); - + // calculate the new value of x x_value = (float)((inMouseLocation->x - track_bounds.left) + inPrivateData->mouse_x_offset); - + // calculate the scale scale = range / track_width; - + // calculate the new value new_value = inPrivateData->min + (UUtInt32)(x_value * scale); } - + // keep new_value within range if (new_value < inPrivateData->min) new_value = inPrivateData->min; @@ -413,22 +413,22 @@ WMiScrollbar_SetThumbLocation( float scale; float range; float current_val; - + UUtRect track_bounds; float track_width; float track_height; - + // get the track bounds WMiScrollbar_GetBounds(inScrollbar, inPrivateData, WMcSBPart_Track, &track_bounds); - + // calculate the width minuse the thumb width and height minuse the thumb height track_width = (float)(track_bounds.right - track_bounds.left - inPrivateData->thumb_width); track_height = (float)(track_bounds.bottom - track_bounds.top - inPrivateData->thumb_height); - + // calculate the range range = (float)(inPrivateData->max - inPrivateData->min); current_val = (float)(inPrivateData->current_value - inPrivateData->min); - + if (UUmFloat_CompareEqu(range, 0.0f)) { if (inPrivateData->is_vertical) @@ -446,10 +446,10 @@ WMiScrollbar_SetThumbLocation( { // calculate the scale scale = track_height / range; - + // set the thumb location inPrivateData->thumb_location.x = track_bounds.left; - inPrivateData->thumb_location.y = + inPrivateData->thumb_location.y = track_bounds.top + (UUtUns16)(current_val * scale); } @@ -457,9 +457,9 @@ WMiScrollbar_SetThumbLocation( { // calculate the scale scale = track_width / range; - + // set the thumb location - inPrivateData->thumb_location.x = + inPrivateData->thumb_location.x = track_bounds.left + (UUtUns16)(current_val * scale); inPrivateData->thumb_location.y = track_bounds.top; @@ -483,26 +483,26 @@ WMiScrollbar_Create( UUtInt16 part_height; WMtScrollbar_PrivateData *private_data; UUtUns32 style; - + // create the private data private_data = (WMtScrollbar_PrivateData*)UUrMemory_Block_NewClear(sizeof(WMtScrollbar_PrivateData)); if (private_data == NULL) { goto cleanup; } WMrWindow_SetLong(inScrollbar, 0, (UUtUns32)private_data); - + // get the active UI partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { goto cleanup; } - + style = WMrWindow_GetStyle(inScrollbar); - + // get the size of the up and left arrows PSrPartSpec_GetSize(partspec_ui->up_arrow, PScPart_LeftTop, &part_width, NULL); PSrPartSpec_GetSize(partspec_ui->lt_arrow, PScPart_LeftTop, NULL, &part_height); - + // the minumum thumb height is the same as the thumb width WMgScrollbar_MinThumbHeight = part_width; WMgScrollbar_MinThumbWidth = part_height; - + // Set the size of the scrollbar WMrWindow_GetSize(inScrollbar, &window_width, &window_height); if ((window_width == -1) && (window_height == -1)) @@ -519,7 +519,7 @@ WMiScrollbar_Create( // set the window height WMrWindow_SetSize(inScrollbar, window_width, part_height); } - + // initialize private_data->mouse_state = LIcMouseState_None; private_data->is_vertical = window_height > window_width; @@ -527,22 +527,22 @@ WMiScrollbar_Create( private_data->max = 0; private_data->current_value = 0; private_data->range_visible = 0; - + WMiScrollbar_CalculateThumbSize(inScrollbar, private_data); WMiScrollbar_SetThumbLocation(inScrollbar, private_data); - + // start the timer WMrTimer_Start(WMcScrollbar_TimerID, WMcScrollbar_TimerFrequency, inScrollbar); - + return WMcResult_Handled; cleanup: UUmAssert(0); - + if (private_data) { UUrMemory_Block_Delete(private_data); - WMrWindow_SetLong(inScrollbar, 0, 0); + WMrWindow_SetLong(inScrollbar, 0, 0); } return WMcResult_Error; } @@ -553,14 +553,14 @@ WMiScrollbar_Destroy( WMtScrollbar *inScrollbar) { WMtScrollbar_PrivateData *private_data; - + // get the private data private_data = (WMtScrollbar_PrivateData*)WMrWindow_GetLong(inScrollbar, 0); if (private_data == NULL) { return; } - + UUrMemory_Block_Delete(private_data); WMrWindow_SetLong(inScrollbar, 0, 0); - + // stop the timer WMrTimer_Stop(WMcScrollbar_TimerID, inScrollbar); } @@ -581,28 +581,28 @@ WMiScrollbar_HandleMouseEvent( UUtUns16 scrollbar_id; UUtUns32 param1; UUtUns32 param2; - + WMtScrollbar_PrivateData *private_data; - + UUtUns8 mouse_over_part; - + // get the private data private_data = (WMtScrollbar_PrivateData*)WMrWindow_GetLong(inScrollbar, 0); if (private_data == NULL) { return; } - + // get the local mouse position global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam1); - + WMrWindow_GlobalToLocal(inScrollbar, &global_mouse, &local_mouse); - + // set the message pieces message = private_data->is_vertical ? SBcMessage_VerticalScroll : SBcMessage_HorizontalScroll; scrollbar_id = WMrWindow_GetID(inScrollbar); - + // get the part the mouse is over mouse_over_part = WMiScrollBar_GetMouseOverPart(inScrollbar, private_data, &local_mouse); - + switch(inMessage) { case WMcMessage_MouseMove: @@ -610,7 +610,7 @@ WMiScrollbar_HandleMouseEvent( (private_data->mouse_down_part == WMcSBPart_Thumb)) { new_value = WMiScrollbar_GetNewValue(inScrollbar, private_data, &local_mouse); - + // tell the parent of the thumb move WMrMessage_Send( WMrWindow_GetParent(inScrollbar), @@ -619,12 +619,12 @@ WMiScrollbar_HandleMouseEvent( (UUtUns32)new_value); } break; - + case WMcMessage_LMouseDown: private_data->mouse_state |= LIcMouseState_LButtonDown; WMrWindow_SetFocus(inScrollbar); WMrWindow_CaptureMouse(inScrollbar); - + if ((private_data->mouse_down_part == WMcSBPart_None) || (private_data->mouse_down_part == mouse_over_part)) { @@ -637,10 +637,10 @@ WMiScrollbar_HandleMouseEvent( { break; } - + mouse_over_part = private_data->mouse_down_part; } - + // set the message for the parts the mouse was in switch (mouse_over_part) { @@ -652,25 +652,25 @@ WMiScrollbar_HandleMouseEvent( private_data->mouse_y_offset = private_data->thumb_location.y - local_mouse.y; } break; - + case WMcSBPart_PageUp: param1 = (UUtUns32)UUmMakeLong(SBcNotify_PageUp, scrollbar_id); param2 = (UUtUns32)private_data->current_value; private_data->mouse_down_part = WMcSBPart_PageUp; break; - + case WMcSBPart_PageDown: param1 = (UUtUns32)UUmMakeLong(SBcNotify_PageDown, scrollbar_id); param2 = (UUtUns32)private_data->current_value; private_data->mouse_down_part = WMcSBPart_PageDown; break; - + case WMcSBPart_LineUp: param1 = (UUtUns32)UUmMakeLong(SBcNotify_LineUp, scrollbar_id); param2 = (UUtUns32)private_data->current_value; private_data->mouse_down_part = WMcSBPart_LineUp; break; - + case WMcSBPart_LineDown: param1 = (UUtUns32)UUmMakeLong(SBcNotify_LineDown, scrollbar_id); param2 = (UUtUns32)private_data->current_value; @@ -686,7 +686,7 @@ WMiScrollbar_HandleMouseEvent( param2); } break; - + case WMcMessage_LMouseUp: private_data->mouse_state &= ~LIcMouseState_LButtonDown; private_data->mouse_down_part = WMcSBPart_None; @@ -703,11 +703,11 @@ WMiScrollbar_HandlePositionChanged( WMtScrollbar_PrivateData *private_data; UUtInt16 width; UUtInt16 height; - + // get the private data private_data = (WMtScrollbar_PrivateData*)WMrWindow_GetLong(inScrollbar, 0); if (private_data == NULL) { return; } - + WMrWindow_GetSize(inScrollbar, &width, &height); private_data->is_vertical = height > width; } @@ -716,9 +716,9 @@ WMiScrollbar_HandlePositionChanged( static void WMiScrollbar_HandleTimer( WMtScrollbar *inScrollbar) -{ +{ WMtScrollbar_PrivateData *private_data; - + // get the private data private_data = (WMtScrollbar_PrivateData*)WMrWindow_GetLong(inScrollbar, 0); if (private_data == NULL) { return; } @@ -726,9 +726,9 @@ WMiScrollbar_HandleTimer( if (private_data->mouse_state & LIcMouseState_LButtonDown) { LItInputEvent event; - + LIrInputEvent_GetMouse(&event); - + WMiScrollbar_HandleMouseEvent( inScrollbar, WMcMessage_LMouseDown, @@ -755,17 +755,17 @@ WMiScrollbar_Paint( UUtInt16 height; WMtScrollbar_PrivateData *private_data; UUtBool enabled; - + // get the private data private_data = (WMtScrollbar_PrivateData*)WMrWindow_GetLong(inScrollbar, 0); if (private_data == NULL) { return; } - + // get the active ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + enabled = WMrWindow_GetEnabled(inScrollbar); - + // get the appropriate parts for the orientation if (private_data->is_vertical) { @@ -783,19 +783,19 @@ WMiScrollbar_Paint( line_dn = (private_data->mouse_down_part == WMcSBPart_LineDown) ? partspec_ui->rt_arrow_pressed : partspec_ui->rt_arrow; thumb = partspec_ui->sb_thumb; } - + draw_context = DCrDraw_Begin(inScrollbar); - + // draw the page up part of the track WMiScrollbar_GetBounds(inScrollbar, private_data, WMcSBPart_PageUp, &bounds); if ((bounds.top != bounds.bottom) && (bounds.left != bounds.right)) { dest.x = bounds.left; dest.y = bounds.top; - + width = bounds.right - bounds.left; height = bounds.bottom - bounds.top; - + DCrDraw_PartSpec( draw_context, page_up, @@ -805,17 +805,17 @@ WMiScrollbar_Paint( height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); } - + // draw the page dn part of the track WMiScrollbar_GetBounds(inScrollbar, private_data, WMcSBPart_PageDown, &bounds); if ((bounds.top != bounds.bottom) && (bounds.left != bounds.right)) { dest.x = bounds.left; dest.y = bounds.top; - + width = bounds.right - bounds.left; height = bounds.bottom - bounds.top; - + DCrDraw_PartSpec( draw_context, page_dn, @@ -825,16 +825,16 @@ WMiScrollbar_Paint( height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); } - + // draw the line up WMiScrollbar_GetBounds(inScrollbar, private_data, WMcSBPart_LineUp, &bounds); - + dest.x = bounds.left; dest.y = bounds.top; - + width = bounds.right - bounds.left; height = bounds.bottom - bounds.top; - + DCrDraw_PartSpec( draw_context, line_up, @@ -843,16 +843,16 @@ WMiScrollbar_Paint( width, height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); - + // draw the line down WMiScrollbar_GetBounds(inScrollbar, private_data, WMcSBPart_LineDown, &bounds); - + dest.x = bounds.left; dest.y = bounds.top; - + width = bounds.right - bounds.left; height = bounds.bottom - bounds.top; - + DCrDraw_PartSpec( draw_context, line_dn, @@ -861,13 +861,13 @@ WMiScrollbar_Paint( width, height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); - + // draw the thumb WMiScrollbar_GetBounds(inScrollbar, private_data, WMcSBPart_Thumb, &bounds); - + dest.x = bounds.left; dest.y = bounds.top; - + DCrDraw_PartSpec( draw_context, thumb, @@ -876,7 +876,7 @@ WMiScrollbar_Paint( private_data->thumb_width, private_data->thumb_height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); - + DCrDraw_End(draw_context, inScrollbar); } @@ -894,20 +894,20 @@ WMiScrollbar_Callback( UUtUns32 inParam2) { UUtUns32 result; - + switch(inMessage) { case WMcMessage_NC_HitTest: return WMcWindowArea_Client; - + case WMcMessage_Create: result = WMiScrollbar_Create(inScrollbar); return result; - + case WMcMessage_Destroy: WMiScrollbar_Destroy(inScrollbar); return WMcResult_Handled; - + case WMcMessage_MouseMove: case WMcMessage_LMouseDown: case WMcMessage_LMouseUp: @@ -917,15 +917,15 @@ WMiScrollbar_Callback( inParam1, inParam2); return WMcResult_Handled; - + case WMcMessage_Paint: WMiScrollbar_Paint(inScrollbar); return WMcResult_Handled; - + case WMcMessage_PositionChanged: WMiScrollbar_HandlePositionChanged(inScrollbar); return WMcResult_Handled; - + case WMcMessage_Timer: if (inParam1 == WMcScrollbar_TimerID) { @@ -933,7 +933,7 @@ WMiScrollbar_Callback( } return WMcResult_Handled; } - + return WMrWindow_DefaultCallback(inScrollbar, inMessage, inParam1, inParam2); } @@ -948,13 +948,13 @@ WMrScrollbar_GetPosition( WMtScrollbar *inScrollbar) { WMtScrollbar_PrivateData *private_data; - + UUmAssert(inScrollbar); - + // get the private data private_data = (WMtScrollbar_PrivateData*)WMrWindow_GetLong(inScrollbar, 0); if (private_data == NULL) { return 0; } - + // return the current position return private_data->current_value; } @@ -968,15 +968,15 @@ WMrScrollbar_GetRange( UUtInt32 *outRangeVisible) { WMtScrollbar_PrivateData *private_data; - + UUmAssert(inScrollbar); UUmAssert(outMin); UUmAssert(outMax); - + // get the private data private_data = (WMtScrollbar_PrivateData*)WMrWindow_GetLong(inScrollbar, 0); if (private_data == NULL) { return; } - + *outMin = private_data->min; *outMax = private_data->max; *outRangeVisible = (UUtInt32)private_data->range_visible; @@ -989,16 +989,16 @@ WMrScrollbar_SetPosition( UUtInt32 inPosition) { WMtScrollbar_PrivateData *private_data; - + UUmAssert(inScrollbar); - + // get the private data private_data = (WMtScrollbar_PrivateData*)WMrWindow_GetLong(inScrollbar, 0); if (private_data == NULL) { return; } - + // set the new position private_data->current_value = inPosition; - + // make sure the new value is within the range if (private_data->current_value < private_data->min) private_data->current_value = private_data->min; @@ -1017,19 +1017,19 @@ WMrScrollbar_SetRange( UUtInt32 inRangeVisible) { WMtScrollbar_PrivateData *private_data; - + UUmAssert(inScrollbar); - + // get the private data private_data = (WMtScrollbar_PrivateData*)WMrWindow_GetLong(inScrollbar, 0); if (private_data == NULL) { return; } - + // set the new range values private_data->min = inMin; private_data->max = inMax; private_data->current_value = inMin; private_data->range_visible = (float)inRangeVisible; - + WMiScrollbar_CalculateThumbSize(inScrollbar, private_data); WMiScrollbar_SetThumbLocation(inScrollbar, private_data); } @@ -1046,15 +1046,15 @@ WMrScrollbar_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_Scrollbar; window_class.callback = WMiScrollbar_Callback; window_class.private_data_size = sizeof(WMtScrollbar_PrivateData*); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Scrollbar.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Scrollbar.h index ac29b29..ba5989f 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Scrollbar.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Scrollbar.h @@ -22,7 +22,7 @@ enum WMcScrollbarStyle_Horizontal = (0x0002 << 16), WMcScrollbarStyle_HasDoubleArrows = (0x0004 << 16), /* not supported yet */ WMcScrollbarStyle_ArrowsAtBothEnds = (0x0008 << 16) /* not supported yet */ - + }; enum @@ -50,19 +50,19 @@ WMrScrollbar_Initialize( UUtInt32 WMrScrollbar_GetPosition( WMtScrollbar *inScrollbar); - + void WMrScrollbar_GetRange( WMtScrollbar *inScrollbar, UUtInt32 *outMin, UUtInt32 *outMax, UUtInt32 *outRangeVisible); - + void WMrScrollbar_SetPosition( WMtScrollbar *inScrollbar, UUtInt32 inPosition); - + void WMrScrollbar_SetRange( WMtScrollbar *inScrollbar, @@ -71,4 +71,4 @@ WMrScrollbar_SetRange( UUtInt32 inRangeVisible); // ====================================================================== -#endif /* WM_SCROLLBAR_H */ \ No newline at end of file +#endif /* WM_SCROLLBAR_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Slider.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Slider.c index 9849f49..aaebf96 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Slider.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Slider.c @@ -37,16 +37,16 @@ typedef struct WMtSlider_PrivateData UUtInt32 min; UUtInt32 max; UUtInt32 current_value; - + UUtUns8 mouse_state; UUtBool mouse_down_in_thumb; UUtInt16 mouse_x_offset; - + // thumb data IMtPoint2D thumb_location; UUtInt16 thumb_width; UUtInt16 thumb_height; - + } WMtSlider_PrivateData; @@ -66,21 +66,21 @@ WMiSlider_GetBounds( UUtInt16 window_height; UUtInt16 part_width; UUtInt16 part_height; - + UUtRect track_bounds; UUtRect thumb_bounds; - + UUmAssert(outBounds); - + outBounds->left = 0; outBounds->top = 0; outBounds->right = 0; outBounds->bottom = 0; - + // get the active UI partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + // get the window size WMrWindow_GetSize(inSlider, &window_width, &window_height); @@ -88,33 +88,33 @@ WMiSlider_GetBounds( { case WMcSLPart_Track: PSrPartSpec_GetSize(partspec_ui->sl_track, PScPart_LeftTop, &part_width, &part_height); - + outBounds->top = (window_height - part_height) >> 1; outBounds->right = window_width; outBounds->bottom = outBounds->top + part_height; break; - + case WMcSLPart_PageUp: WMiSlider_GetBounds(inSlider, inPrivateData, WMcSLPart_Track, &track_bounds); WMiSlider_GetBounds(inSlider, inPrivateData, WMcSLPart_Thumb, &thumb_bounds); - + outBounds->left = track_bounds.left; outBounds->right = thumb_bounds.left + 1; outBounds->bottom = window_height; break; - + case WMcSLPart_PageDown: WMiSlider_GetBounds(inSlider, inPrivateData, WMcSLPart_Track, &track_bounds); WMiSlider_GetBounds(inSlider, inPrivateData, WMcSLPart_Thumb, &thumb_bounds); - + outBounds->left = thumb_bounds.right - 1; outBounds->right = track_bounds.right; outBounds->bottom = window_height; break; - + case WMcSLPart_Thumb: PSrPartSpec_GetSize(partspec_ui->sl_thumb, PScPart_LeftTop, &part_width, &part_height); - + outBounds->left = inPrivateData->thumb_location.x; outBounds->top = inPrivateData->thumb_location.y - (part_height >> 1); outBounds->right = outBounds->left + part_width; @@ -133,7 +133,7 @@ WMiSlider_GetTrackBounds( PStPartSpecUI *partspec_ui; UUtInt16 left_width; UUtInt16 right_width; - + // initialize outMoveBounds->left = 0; outMoveBounds->top = 0; @@ -143,14 +143,14 @@ WMiSlider_GetTrackBounds( // get the partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + // get the size of the track left_width, and right_width of the track part PSrPartSpec_GetSize(partspec_ui->sl_track, PScPart_LeftTop, &left_width, NULL); PSrPartSpec_GetSize(partspec_ui->sl_track, PScPart_RightTop, &right_width, NULL); - + // get the track bounds WMiSlider_GetBounds(inSlider, inPrivateData, WMcSLPart_Track, outMoveBounds); - + // add in the left and right buffer areas of the move bounds outMoveBounds->left += left_width;// + (inPrivateData->thumb_width >> 1); outMoveBounds->right -= right_width;// + (inPrivateData->thumb_width >> 1); @@ -165,37 +165,37 @@ WMiSlider_GetNewValue( { UUtRect track_bounds; float track_width; - + float scale; float range; float x_value; UUtInt32 new_value; - + // calculate the range range = (float)(inPrivateData->max - inPrivateData->min); - + // get the track bounds WMiSlider_GetTrackBounds(inSlider, inPrivateData, &track_bounds); - + // calculate the track width minus the thumb width track_width = (float)(track_bounds.right - track_bounds.left - inPrivateData->thumb_width); - + // calculate the value of x x_value = (float)((inMouseLocation->x - track_bounds.left) + inPrivateData->mouse_x_offset); - + // calculate the scale scale = range / track_width; - + // calculate the new value new_value = inPrivateData->min + (UUtInt32)(x_value * scale); - + // keep new_value within range if (new_value < inPrivateData->min) new_value = inPrivateData->min; if (new_value > inPrivateData->max) new_value = inPrivateData->max; - + return new_value; } @@ -208,27 +208,27 @@ WMiSlider_SetThumbLocation( float scale; float range; float current_val; - + UUtRect track_bounds; float track_width; UUtInt16 track_height; - + // get the track bounds WMiSlider_GetTrackBounds(inSlider, inPrivateData, &track_bounds); - + // calculate the track width minus thumb width and track height track_width = (float)(track_bounds.right - track_bounds.left - inPrivateData->thumb_width); track_height = track_bounds.bottom - track_bounds.top; - + // calculate the range and current_val range = (float)(inPrivateData->max - inPrivateData->min); current_val = (float)(inPrivateData->current_value - inPrivateData->min); - + // calculate the scale scale = track_width / range; - + // set the thumb location - inPrivateData->thumb_location.x = + inPrivateData->thumb_location.x = track_bounds.left + (UUtUns16)(current_val * scale); inPrivateData->thumb_location.y = track_bounds.top + (track_height >> 1); @@ -246,26 +246,26 @@ WMiSlider_Create( { WMtSlider_PrivateData *private_data; UUtRect thumb_bounds; - + // create the private data private_data = (WMtSlider_PrivateData*)UUrMemory_Block_NewClear(sizeof(WMtSlider_PrivateData)); if (private_data == NULL) { goto cleanup; } - + // save the private data WMrWindow_SetLong(inSlider, 0, (UUtUns32)private_data); - + // calculate the thumb width and height WMiSlider_GetBounds(inSlider, private_data, WMcSLPart_Thumb, &thumb_bounds); private_data->thumb_width = thumb_bounds.right - thumb_bounds.left; private_data->thumb_height = thumb_bounds.bottom - thumb_bounds.top; - + // initialize WMiSlider_SetThumbLocation(inSlider, private_data); - + // start the timer WMrTimer_Start(WMcSlider_TimerID, WMcSlider_TimerFrequency, inSlider); - + return WMcResult_Handled; cleanup: @@ -275,7 +275,7 @@ WMiSlider_Create( private_data = NULL; } WMrWindow_SetLong(inSlider, 0, 0); - + return WMcResult_Error; } @@ -285,7 +285,7 @@ WMiSlider_Destroy( WMtSlider *inSlider) { WMtSlider_PrivateData *private_data; - + private_data = (WMtSlider_PrivateData*)WMrWindow_GetLong(inSlider, 0); if (private_data) { @@ -316,7 +316,7 @@ WMiSlider_HandleKeyEvent( // get the private data private_data = (WMtSlider_PrivateData*)WMrWindow_GetLong(inSlider, 0); if (private_data == NULL) { return; } - + // get the scroll range scroll_range = private_data->max - private_data->min; scroll_increment = 0; @@ -326,32 +326,32 @@ WMiSlider_HandleKeyEvent( case LIcKeyCode_LeftArrow: scroll_increment = -1; break; - + case LIcKeyCode_RightArrow: scroll_increment = 1; break; - + case LIcKeyCode_PageUp: scroll_increment = UUmMin(-1, -scroll_range / 10); break; - + case LIcKeyCode_PageDown: scroll_increment = UUmMax(1, scroll_range / 10); break; - + case LIcKeyCode_Home: scroll_increment = private_data->min - private_data->current_value; break; - + case LIcKeyCode_End: scroll_increment = private_data->max - private_data->current_value; break; } - + if (scroll_increment != 0) { WMrSlider_SetPosition(inSlider, private_data->current_value + scroll_increment); - + // tell the parent WMrMessage_Send( WMrWindow_GetParent(inSlider), @@ -376,29 +376,29 @@ WMiSlider_HandleMouseEvent( UUtBool in_pageup; UUtBool in_pagedn; UUtBool in_thumb; - + WMtSlider_PrivateData *private_data; - + UUtInt32 scroll_increment; UUtInt32 scroll_range; - + // disabled sliders don't move if (WMrWindow_GetEnabled(inSlider) == UUcFalse) { return; } - + // get the private data private_data = (WMtSlider_PrivateData*)WMrWindow_GetLong(inSlider, 0); if (private_data == NULL) { return; } - + // get the local mouse position global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam1); - + WMrWindow_GlobalToLocal(inSlider, &global_mouse, &local_mouse); - + // get the scroll range scroll_range = private_data->max - private_data->min; scroll_increment = 0; - + switch(inMessage) { case WMcMessage_MouseMove: @@ -410,19 +410,19 @@ WMiSlider_HandleMouseEvent( private_data->current_value; } break; - + case WMcMessage_LMouseDown: private_data->mouse_state |= LIcMouseState_LButtonDown; WMrWindow_SetFocus(inSlider); WMrWindow_CaptureMouse(inSlider); - + // find out what part the mouse is over WMiSlider_GetBounds(inSlider, private_data, WMcSLPart_Thumb, &bounds); in_thumb = IMrRect_PointIn(&bounds, &local_mouse); WMiSlider_GetBounds(inSlider, private_data, WMcSLPart_PageUp, &bounds); in_pageup = IMrRect_PointIn(&bounds, &local_mouse); - + WMiSlider_GetBounds(inSlider, private_data, WMcSLPart_PageDown, &bounds); in_pagedn = IMrRect_PointIn(&bounds, &local_mouse); @@ -441,18 +441,18 @@ WMiSlider_HandleMouseEvent( scroll_increment = UUmMax(1, scroll_range / 10); } break; - + case WMcMessage_LMouseUp: private_data->mouse_state &= ~LIcMouseState_LButtonDown; private_data->mouse_down_in_thumb = UUcFalse; WMrWindow_CaptureMouse(NULL); break; } - + if (scroll_increment != 0) { WMrSlider_SetPosition(inSlider, private_data->current_value + scroll_increment); - + // tell the parent WMrMessage_Send( WMrWindow_GetParent(inSlider), @@ -466,9 +466,9 @@ WMiSlider_HandleMouseEvent( static void WMiSlider_HandleTimer( WMtSlider *inSlider) -{ +{ WMtSlider_PrivateData *private_data; - + // get the private data private_data = (WMtSlider_PrivateData*)WMrWindow_GetLong(inSlider, 0); if (private_data == NULL) { return; } @@ -476,9 +476,9 @@ WMiSlider_HandleTimer( if (private_data->mouse_state & LIcMouseState_LButtonDown) { LItInputEvent event; - + LIrInputEvent_GetMouse(&event); - + WMiSlider_HandleMouseEvent( inSlider, WMcMessage_LMouseDown, @@ -500,26 +500,26 @@ WMiSlider_Paint( IMtPoint2D dest; UUtRect thumb_bounds; UUtRect track_bounds; - + // get the private data private_data = (WMtSlider_PrivateData*)WMrWindow_GetLong(inSlider, 0); if (private_data == NULL) { return; } - + // get the partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + draw_context = DCrDraw_Begin(inSlider); enabled = WMrWindow_GetEnabled(inSlider); // get the bounds of the tracks WMiSlider_GetBounds(inSlider, private_data, WMcSLPart_Track, &track_bounds); - + // set the dest for the track dest.x = track_bounds.left; dest.y = track_bounds.top; - + // draw the track DCrDraw_PartSpec( draw_context, @@ -529,13 +529,13 @@ WMiSlider_Paint( (UUtUns16)(track_bounds.right - track_bounds.left), (UUtUns16)(track_bounds.bottom - track_bounds.top), M3cMaxAlpha); - + // get the bounds of the thumb WMiSlider_GetBounds(inSlider, private_data, WMcSLPart_Thumb, &thumb_bounds); - + dest.x = thumb_bounds.left; dest.y = thumb_bounds.top; - + DCrDraw_PartSpec( draw_context, partspec_ui->sl_thumb, @@ -544,7 +544,7 @@ WMiSlider_Paint( private_data->thumb_width, private_data->thumb_height, enabled ? (UUtUns16)WMcAlpha_Enabled : (UUtUns16)WMcAlpha_Disabled); - + DCrDraw_End(draw_context, inSlider); } @@ -562,28 +562,28 @@ WMiSlider_Callback( UUtUns32 inParam2) { UUtUns32 result; - + switch(inMessage) { case WMcMessage_NC_HitTest: return WMcWindowArea_Client; - + case WMcMessage_Create: result = WMiSlider_Create(inSlider); return result; - + case WMcMessage_Destroy: WMiSlider_Destroy(inSlider); return WMcResult_Handled; - + case WMcMessage_Paint: WMiSlider_Paint(inSlider); return WMcResult_Handled; - + case WMcMessage_KeyDown: WMiSlider_HandleKeyEvent(inSlider, inParam1); break; - + case WMcMessage_MouseMove: case WMcMessage_LMouseDown: case WMcMessage_LMouseUp: @@ -596,12 +596,12 @@ WMiSlider_Callback( WMiSlider_HandleTimer(inSlider); } return WMcResult_Handled; - + case WMcMessage_GetDialogCode: return (WMcDialogCode_WantNavigation | WMcDialogCode_WantArrows); break; } - + return WMrWindow_DefaultCallback(inSlider, inMessage, inParam1, inParam2); } @@ -616,13 +616,13 @@ WMrSlider_GetPosition( WMtSlider *inSlider) { WMtSlider_PrivateData *private_data; - + UUmAssert(inSlider); - + // get the private data private_data = (WMtSlider_PrivateData*)WMrWindow_GetLong(inSlider, 0); if (private_data == NULL) { return 0; } - + // return the current position return private_data->current_value; } @@ -635,15 +635,15 @@ WMrSlider_GetRange( UUtInt32 *outMax) { WMtSlider_PrivateData *private_data; - + UUmAssert(inSlider); UUmAssert(outMin); UUmAssert(outMax); - + // get the private data private_data = (WMtSlider_PrivateData*)WMrWindow_GetLong(inSlider, 0); if (private_data == NULL) { return; } - + *outMin = private_data->min; *outMax = private_data->max; } @@ -655,16 +655,16 @@ WMrSlider_SetPosition( UUtInt32 inPosition) { WMtSlider_PrivateData *private_data; - + UUmAssert(inSlider); - + // get the private data private_data = (WMtSlider_PrivateData*)WMrWindow_GetLong(inSlider, 0); if (private_data == NULL) { return; } - + // set the new position private_data->current_value = inPosition; - + // make sure the new value is within the range if (private_data->current_value < private_data->min) private_data->current_value = private_data->min; @@ -682,18 +682,18 @@ WMrSlider_SetRange( UUtInt32 inMax) { WMtSlider_PrivateData *private_data; - + UUmAssert(inSlider); - + // get the private data private_data = (WMtSlider_PrivateData*)WMrWindow_GetLong(inSlider, 0); if (private_data == NULL) { return; } - + // set the new range values private_data->min = inMin; private_data->max = inMax; private_data->current_value = inMin; - + WMiSlider_SetThumbLocation(inSlider, private_data); } @@ -709,15 +709,15 @@ WMrSlider_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_Slider; window_class.callback = WMiSlider_Callback; window_class.private_data_size = sizeof(WMtSlider_PrivateData*); - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Slider.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Slider.h index d42bb98..13e6927 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Slider.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Slider.h @@ -18,13 +18,13 @@ enum { WMcSliderStyle_None = (0x0000 << 16) - + }; enum { SLcNotify_NewPosition = 1 - + }; // ====================================================================== @@ -38,28 +38,28 @@ typedef WMtWindow WMtSlider; UUtInt32 WMrSlider_GetPosition( WMtSlider *inSlider); - + void WMrSlider_GetRange( WMtSlider *inSlider, UUtInt32 *outMin, UUtInt32 *outMax); - + void WMrSlider_SetPosition( WMtSlider *inSlider, UUtInt32 inPosition); - + void WMrSlider_SetRange( WMtSlider *inSlider, UUtInt32 inMin, UUtInt32 inMax); - + // ---------------------------------------------------------------------- UUtError WMrSlider_Initialize( void); // ====================================================================== -#endif /* WM_SLIDER_H */ \ No newline at end of file +#endif /* WM_SLIDER_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Text.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Text.c index ecfdc4a..6550a8a 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Text.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Text.c @@ -24,15 +24,15 @@ WMiText_Paint( IMtPoint2D dest; UUtUns32 style; TStFormat format; - + draw_context = DCrDraw_Begin(inText); - + // get the style flags style = WMrWindow_GetStyle(inText); if (style & WMcTextStyle_OwnerDraw) { WMtDrawItem draw_item; - + // set up the owner draw struct draw_item.draw_context = draw_context; draw_item.window = inText; @@ -42,7 +42,7 @@ WMiText_Paint( WMrWindow_GetClientRect(inText, &draw_item.rect); draw_item.string = WMrWindow_GetTitlePtr(inText); draw_item.data = 0; - + WMrMessage_Send( WMrWindow_GetOwner(inText), WMcMessage_DrawItem, @@ -52,7 +52,7 @@ WMiText_Paint( else { TStFontInfo font_info; - + // set the format format = TSc_HLeft; if (style & WMcTextStyle_HCenter) @@ -63,25 +63,25 @@ WMiText_Paint( { format = TSc_HRight; } - + if (style & WMcTextStyle_VCenter) { format |= TSc_VCenter; } - + // set dest dest.x = 0; dest.y = DCrText_GetAscendingHeight(); - + WMrWindow_GetFontInfo(inText, &font_info); DCrText_SetFontInfo(&font_info); - + WMrWindow_GetClientRect(inText, &bounds); DCrText_SetShade(WMrWindow_GetEnabled(inText) ? font_info.font_shade : IMcShade_Gray50); DCrText_SetFormat(format); DCrDraw_String(draw_context, WMrWindow_GetTitlePtr(inText), &bounds, &dest); } - + DCrDraw_End(draw_context, inText); } @@ -104,7 +104,7 @@ WMiText_Callback( WMiText_Paint(inText); return WMcResult_Handled; } - + return WMrWindow_DefaultCallback(inText, inMessage, inParam1, inParam2); } @@ -120,16 +120,16 @@ WMrText_Initialize( { UUtError error; WMtWindowClass window_class; - + // register the window class UUrMemory_Clear(&window_class, sizeof(WMtWindowClass)); window_class.type = WMcWindowType_Text; window_class.callback = WMiText_Callback; window_class.private_data_size = 0; - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -141,14 +141,14 @@ WMrText_SetShade( { UUtBool result; TStFontInfo font_info; - + result = WMrWindow_GetFontInfo(inWindow, &font_info); if (result != UUcTrue) { return result; } - + font_info.font_shade = inShade; - + result = WMrWindow_SetFontInfo(inWindow, &font_info); if (result != UUcTrue) { return result; } - + return UUcTrue; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Text.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Text.h index 419d6f0..83a6fb7 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Text.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Text.h @@ -26,10 +26,10 @@ enum WMcTextStyle_VBottom = (0x0020 << 16), WMcTextStyle_SingleLine = (0x0040 << 16), WMcTextStyle_OwnerDraw = (0x0080 << 16), - + WMcTextStyle_Basic = (WMcTextStyle_HLeft | WMcTextStyle_VTop), WMcTextStyle_Standard = (WMcTextStyle_HLeft | WMcTextStyle_VCenter) - + }; // ====================================================================== @@ -48,6 +48,6 @@ UUtBool WMrText_SetShade( WMtWindow *inWindow, IMtShade inShade); - + // ====================================================================== -#endif /* WM_TEXT_H */ \ No newline at end of file +#endif /* WM_TEXT_H */ diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Window.c b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Window.c index 3afc68d..eafb431 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Window.c +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Window.c @@ -36,11 +36,11 @@ WMiWindow_GetBorderSizes( UUtInt16 *outBottomHeight) { PStPartSpecUI *partspec_ui; - + // get the partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + if (inWindow->style & WMcWindowStyle_HasBorder) { PSrPartSpec_GetSize( @@ -48,7 +48,7 @@ WMiWindow_GetBorderSizes( PScPart_LeftTop, outLeftWidth, outTopHeight); - + PSrPartSpec_GetSize( partspec_ui->border, PScPart_RightBottom, @@ -62,7 +62,7 @@ WMiWindow_GetBorderSizes( PScPart_LeftTop, outLeftWidth, outTopHeight); - + PSrPartSpec_GetSize( partspec_ui->background, PScPart_RightBottom, @@ -87,21 +87,21 @@ WMiWindow_GetPartSizes( UUtInt16 *outHeight) { PStPartSpecUI *partspec_ui; - + UUmAssert(outWidth); UUmAssert(outHeight); - + // get the partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + switch (inWindow->style & inStylePart) { case WMcWindowStyle_None: *outWidth = 0; *outHeight = 0; break; - + case WMcWindowStyle_HasClose: case WMcWindowStyle_HasZoom: case WMcWindowStyle_HasFlatten: @@ -124,37 +124,37 @@ WMiWindow_NC_HitTest( { UUtRect window_rect; IMtPoint2D global_mouse; - + UUtUns16 close_width; UUtUns16 zoom_width; UUtUns16 flatten_width; - + UUtInt16 border_left_width; UUtInt16 border_top_height; UUtInt16 border_right_width; UUtInt16 border_bottom_height; - + WMtWindowArea part; - + // get the mouse global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam1); - + // get the window rect WMrWindow_GetRect(inWindow, &window_rect); - + // check to see if mouse is even inside the window if (IMrRect_PointIn(&window_rect, &global_mouse) == UUcFalse) { return WMcWindowArea_None; } - + // initialize close_width = 0; zoom_width = 0; flatten_width = 0; part = WMcWindowArea_None; - + // remove the border from the window rect WMiWindow_GetBorderSizes( inWindow, @@ -167,7 +167,7 @@ WMiWindow_NC_HitTest( window_rect.top += border_top_height; window_rect.right -= border_right_width; window_rect.bottom -= border_bottom_height; - + // test the border if (inWindow->style & WMcWindowStyle_HasBorder) { @@ -176,40 +176,40 @@ WMiWindow_NC_HitTest( if (global_mouse.y <= window_rect.top) part |= WMcWindowArea_NC_Top; - + if (global_mouse.x >= window_rect.right) part |= WMcWindowArea_NC_Right; - + if (global_mouse.y >= window_rect.bottom) part |= WMcWindowArea_NC_Bottom; } - + // test the title if ((part == WMcWindowArea_None) && (inWindow->style & WMcWindowStyle_HasTitle)) { window_rect.bottom = window_rect.top + inWindow->title_height; - + if (IMrRect_PointIn(&window_rect, &global_mouse)) { UUtInt16 part_width; UUtInt16 part_height; - + // test the close box if ((part == WMcWindowArea_None) && (inWindow->style & WMcWindowStyle_HasClose)) { WMiWindow_GetPartSizes(inWindow, WMcWindowStyle_HasClose, &part_width, &part_height); - + window_rect.right -= WMcWindow_Control_Buffer; window_rect.left = window_rect.right - part_width; - + if (IMrRect_PointIn(&window_rect, &global_mouse)) { part = WMcWindowArea_NC_Close; } } - + // test the flatten box if ((part == WMcWindowArea_None) && (inWindow->style & WMcWindowStyle_HasFlatten)) @@ -218,13 +218,13 @@ WMiWindow_NC_HitTest( window_rect.right = window_rect.left - WMcWindow_Control_Buffer; window_rect.left = window_rect.right - part_width; - + if (IMrRect_PointIn(&window_rect, &global_mouse)) { part = WMcWindowArea_NC_Flatten; } } - + // test the zoom box if ((part == WMcWindowArea_None) && (inWindow->style & WMcWindowStyle_HasZoom)) @@ -233,13 +233,13 @@ WMiWindow_NC_HitTest( window_rect.right = window_rect.left - WMcWindow_Control_Buffer; window_rect.left = window_rect.right - part_width; - + if (IMrRect_PointIn(&window_rect, &global_mouse)) { part = WMcWindowArea_NC_Zoom; } } - + if (part == WMcWindowArea_None) { part = WMcWindowArea_NC_Drag; @@ -252,14 +252,14 @@ WMiWindow_NC_HitTest( (inWindow->style & WMcWindowStyle_HasGrowBox)) { } - + // default to client area if ((part == WMcWindowArea_None) && (inWindow->style & WMcWindowStyle_HasBackground)) { part = WMcWindowArea_Client; } - + return part; } @@ -274,22 +274,22 @@ WMiWindow_NC_Paint( UUtInt16 height; PStPartSpecUI *partspec_ui; UUtBool enabled; - + // get the active partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) return; - + draw_context = DCrDraw_NC_Begin(inWindow); - + // set the dest dest.x = 0; dest.y = 0; - + // get the window rect WMrWindow_GetSize(inWindow, &width, &height); enabled = WMrWindow_GetEnabled(inWindow); - + // draw the window background if (inWindow->style & WMcWindowStyle_HasBackground) { @@ -302,7 +302,7 @@ WMiWindow_NC_Paint( (UUtUns16)height, M3cMaxAlpha); } - + // draw the window border if (inWindow->style & WMcWindowStyle_HasBorder) { @@ -315,7 +315,7 @@ WMiWindow_NC_Paint( (UUtUns16)height, M3cMaxAlpha); } - + // draw the title if (inWindow->style & WMcWindowStyle_HasDrag) { @@ -326,20 +326,20 @@ WMiWindow_NC_Paint( UUtInt16 border_bottom_height; UUtInt16 part_width; UUtInt16 part_height; - + WMiWindow_GetBorderSizes( inWindow, &border_left_width, &border_top_height, &border_right_width, &border_bottom_height); - + dest.x = border_left_width; dest.y = border_top_height; - + width -= (border_left_width + border_right_width); height = inWindow->title_height; - + // draw the draw area DCrDraw_PartSpec( draw_context, @@ -349,35 +349,35 @@ WMiWindow_NC_Paint( (UUtUns16)width, (UUtUns16)height, M3cMaxAlpha); - + if (inWindow->style & WMcWindowStyle_HasTitle) { UUtUns16 ascending_height; UUtRect drag_bounds; - + drag_bounds.left = dest.x; drag_bounds.top = dest.y; drag_bounds.right = drag_bounds.left + width; drag_bounds.bottom = drag_bounds.top + height; - + ascending_height = DCrText_GetAscendingHeight(); - + dest.x += 2; dest.y += ascending_height; - + DCrText_SetShade(enabled ? IMcShade_Black : IMcShade_Gray50); DCrText_SetFormat(TSc_HLeft); - + DCrDraw_String( draw_context, inWindow->title, &drag_bounds, &dest); - + dest.x -= 2; dest.y -= ascending_height; } - + // move the dest to the right hand side of the window dest.x += width; dest.y += WMcWindow_Control_Buffer; @@ -388,7 +388,7 @@ WMiWindow_NC_Paint( WMiWindow_GetPartSizes(inWindow, WMcWindowStyle_HasClose, &part_width, &part_height); dest.x -= (part_width + WMcWindow_Control_Buffer); - + if ((UUmLowWord(inWindow->window_data) == WMcWindowArea_NC_Close) && (inWindow->window_data & WMcWindowDataFlag_PartHilite)) { @@ -398,7 +398,7 @@ WMiWindow_NC_Paint( { draw_me = partspec_ui->close_idle; } - + DCrDraw_PartSpec( draw_context, draw_me, @@ -408,14 +408,14 @@ WMiWindow_NC_Paint( part_height, M3cMaxAlpha); } - + // draw the flatten box if (inWindow->style & WMcWindowStyle_HasFlatten) - { + { WMiWindow_GetPartSizes(inWindow, WMcWindowStyle_HasFlatten, &part_width, &part_height); dest.x -= (part_width + WMcWindow_Control_Buffer); - + if ((UUmLowWord(inWindow->window_data) == WMcWindowArea_NC_Flatten) && (inWindow->window_data & WMcWindowDataFlag_PartHilite)) { @@ -425,7 +425,7 @@ WMiWindow_NC_Paint( { draw_me = partspec_ui->flatten_idle; } - + DCrDraw_PartSpec( draw_context, draw_me, @@ -435,14 +435,14 @@ WMiWindow_NC_Paint( part_height, M3cMaxAlpha); } - + // draw the zoom box if (inWindow->style & WMcWindowStyle_HasZoom) { WMiWindow_GetPartSizes(inWindow, WMcWindowStyle_HasZoom, &part_width, &part_height); dest.x -= (part_width + WMcWindow_Control_Buffer); - + if ((UUmLowWord(inWindow->window_data) == WMcWindowArea_NC_Zoom) && (inWindow->window_data & WMcWindowDataFlag_PartHilite)) { @@ -452,7 +452,7 @@ WMiWindow_NC_Paint( { draw_me = partspec_ui->zoom_idle; } - + DCrDraw_PartSpec( draw_context, draw_me, @@ -463,7 +463,7 @@ WMiWindow_NC_Paint( M3cMaxAlpha); } } - + DCrDraw_NC_End(draw_context, inWindow); } @@ -478,17 +478,17 @@ WMiWindow_NC_HandleMouseEvent( IMtPoint2D global_mouse; IMtPoint2D local_mouse; WMtWindowArea part; - - // get the mouse location + + // get the mouse location global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam1); - + // get the local mouse coordinates WMrWindow_GlobalToLocal(inWindow, &global_mouse, &local_mouse); - + // get the part part = (WMtWindowArea)inParam2; - + // handle the event switch (inMessage) { @@ -497,12 +497,12 @@ WMiWindow_NC_HandleMouseEvent( inWindow->window_data = (inWindow->window_data & 0xFFFF0000) | (part & 0x0000FFFF); inWindow->window_data |= WMcWindowDataFlag_PartHilite; break; - + case WMcMessage_NC_LMouseUp: if ((WMtWindowArea)UUmLowWord(inWindow->window_data) == part) { WMtMessage message; - + switch (part) { case WMcWindowArea_NC_Close: message = WMcMessage_Close; break; @@ -510,18 +510,18 @@ WMiWindow_NC_HandleMouseEvent( case WMcWindowArea_NC_Zoom: message = WMcMessage_Zoom; break; default: message = WMcMessage_None; break; } - + if (message != WMcMessage_None) { WMrMessage_Send(inWindow, message, 0, 0); } } - + inWindow->window_data &= 0x7FFF0000; WMrWindow_CaptureMouse(NULL); break; } - + inWindow->prev_mouse_location = global_mouse; } @@ -535,7 +535,7 @@ WMiWindow_NC_CalcClientSize( UUtInt16 border_top_height; UUtInt16 border_right_width; UUtInt16 border_bottom_height; - + // get the width and height of the border WMiWindow_GetBorderSizes( inWindow, @@ -543,13 +543,13 @@ WMiWindow_NC_CalcClientSize( &border_top_height, &border_right_width, &border_bottom_height); - + // set the client rect outClientRect->left = border_left_width; outClientRect->top = border_top_height; outClientRect->right = inWindow->width - border_right_width; outClientRect->bottom = inWindow->height - border_bottom_height; - + if (inWindow->style & WMcWindowStyle_HasDrag) { outClientRect->top += inWindow->title_height; @@ -568,12 +568,12 @@ WMiWindow_Flatten( { UUtInt16 new_width; UUtInt16 new_height; - + if (inWindow->window_data & WMcWindowDataFlag_Flattened) { new_width = inWindow->restored_rect.right - inWindow->restored_rect.left; new_height = inWindow->restored_rect.bottom - inWindow->restored_rect.top; - + inWindow->window_data &= ~WMcWindowDataFlag_Flattened; inWindow->window_data &= ~WMcWindowDataFlag_Zoomed; } @@ -600,7 +600,7 @@ WMiWindow_Flatten( { UUtInt16 part_width; UUtInt16 part_height; - + new_width += inWindow->title_width; new_height += inWindow->title_height; @@ -610,14 +610,14 @@ WMiWindow_Flatten( new_width += (part_width + WMcWindow_Control_Buffer); } - + if (inWindow->style & WMcWindowStyle_HasFlatten) { WMiWindow_GetPartSizes(inWindow, WMcWindowStyle_HasFlatten, &part_width, &part_height); new_width += (part_width + WMcWindow_Control_Buffer); } - + if (inWindow->style & WMcWindowStyle_HasZoom) { WMiWindow_GetPartSizes(inWindow, WMcWindowStyle_HasZoom, &part_width, &part_height); @@ -625,14 +625,14 @@ WMiWindow_Flatten( new_width += (part_width + WMcWindow_Control_Buffer); } } - + // save the current bounds WMrWindow_GetRect(inWindow, &inWindow->restored_rect); - + inWindow->window_data |= WMcWindowDataFlag_Flattened; inWindow->window_data &= ~WMcWindowDataFlag_Zoomed; } - + // set the new size WMrWindow_SetSize(inWindow, new_width, new_height); } @@ -644,7 +644,7 @@ WMiWindow_HandleActivate( UUtBool inActivate) { if ((inWindow->flags & WMcWindowFlag_Child) != 0) { return; } - + if (inActivate) { WMrWindow_SetFocus(inWindow->had_focus); @@ -652,7 +652,7 @@ WMiWindow_HandleActivate( else { WMtWindow *has_focus; - + // save the current focus has_focus = WMrWindow_GetFocus(); if (WMrWindow_IsChild(has_focus, inWindow)) @@ -681,19 +681,19 @@ WMiWindow_HandleResolutionChanged( UUtUns32 inParam1) { WMtWindow *child; - + // tell all the windows that the resolution changed if (inWindow->child == NULL) { return; } - + child = inWindow->child; while (child != NULL) { // windows flagged as child windows don't get notified if ((child->flags & WMcWindowFlag_Child) != 0) { continue; } - + // notify the child window WMrMessage_Send(child, WMcMessage_ResolutionChanged, inParam1, 0); - + child = child->next; } } @@ -707,32 +707,32 @@ WMiWindow_HandleSizeMove( { IMtPoint2D global_mouse; IMtPoint2D local_mouse; - + IMtPoint2D new_dest; UUtInt16 new_width; UUtInt16 new_height; - + UUtInt16 min_width; UUtInt16 min_height; - + UUtInt16 diff_x; UUtInt16 diff_y; - + UUtInt16 mouse_diff; UUtInt32 i; - + UUtRect window_rect; - + UUtInt16 border_left_width; UUtInt16 border_top_height; UUtInt16 border_right_width; UUtInt16 border_bottom_height; - + // initialize new_dest = inWindow->location; new_width = inWindow->width; new_height = inWindow->height; - + // get the width and height of the border WMiWindow_GetBorderSizes( inWindow, @@ -744,20 +744,20 @@ WMiWindow_HandleSizeMove( // calculate the min width and height min_width = border_left_width + border_right_width; min_height = border_top_height + border_bottom_height; - + // get the mouse positions global_mouse.x = (UUtInt16)UUmHighWord(inParam1); global_mouse.y = (UUtInt16)UUmLowWord(inParam1); - + WMrWindow_GetRect(inWindow, &window_rect); local_mouse.x = global_mouse.x - window_rect.left; local_mouse.y = global_mouse.y - window_rect.top; - + if (inWindow->style & WMcWindowStyle_HasTitle) { UUtInt16 part_width; UUtInt16 part_height; - + min_width += inWindow->title_width; min_height += inWindow->title_height; @@ -767,14 +767,14 @@ WMiWindow_HandleSizeMove( min_width += (part_width + WMcWindow_Control_Buffer); } - + if (inWindow->style & WMcWindowStyle_HasFlatten) { WMiWindow_GetPartSizes(inWindow, WMcWindowStyle_HasFlatten, &part_width, &part_height); min_width += (part_width + WMcWindow_Control_Buffer); } - + if (inWindow->style & WMcWindowStyle_HasZoom) { WMiWindow_GetPartSizes(inWindow, WMcWindowStyle_HasZoom, &part_width, &part_height); @@ -782,18 +782,18 @@ WMiWindow_HandleSizeMove( min_width += (part_width + WMcWindow_Control_Buffer); } } - + // calculate the difference between the previous and current mouse locations diff_x = global_mouse.x - inWindow->prev_mouse_location.x; diff_y = global_mouse.y - inWindow->prev_mouse_location.y; - + switch (UUmLowWord(inWindow->window_data)) { case WMcWindowArea_NC_Drag: new_dest.x = inWindow->location.x + diff_x; new_dest.y = inWindow->location.y + diff_y; break; - + case WMcWindowArea_NC_Close: case WMcWindowArea_NC_Flatten: case WMcWindowArea_NC_Zoom: @@ -807,7 +807,7 @@ WMiWindow_HandleSizeMove( inWindow->window_data &= ~WMcWindowDataFlag_PartHilite; } break; - + default: for (i = WMcWindowArea_NC_Left; i <= WMcWindowArea_NC_Bottom; i = (i << 1)) { @@ -819,15 +819,15 @@ WMiWindow_HandleSizeMove( { break; } - + // calculate the new width and dest new_width = inWindow->width - diff_x; new_dest.x = inWindow->location.x + diff_x; break; - + case WMcWindowArea_NC_Right: mouse_diff = local_mouse.x - inWindow->width; - + if (((diff_x < 0) && (mouse_diff > 0)) || ((diff_x > 0) && (mouse_diff < 0))) { @@ -837,7 +837,7 @@ WMiWindow_HandleSizeMove( // calculate the new width new_width = inWindow->width + diff_x; break; - + case WMcWindowArea_NC_Top: if (((diff_y < 0) && (local_mouse.y > 0)) || ((diff_y > 0) && (local_mouse.y < 0))) @@ -849,16 +849,16 @@ WMiWindow_HandleSizeMove( new_height = inWindow->height - diff_y; new_dest.y = inWindow->location.y + diff_y; break; - + case WMcWindowArea_NC_Bottom: mouse_diff = local_mouse.y - inWindow->height; - + if (((diff_y < 0) && (mouse_diff > 0)) || ((diff_y > 0) && (mouse_diff < 0))) { break; } - + // calculate the new height new_height = inWindow->height + diff_y; break; @@ -866,14 +866,14 @@ WMiWindow_HandleSizeMove( } break; } - + switch(UUmLowWord(inWindow->window_data)) { case WMcWindowArea_NC_Drag: // set the windows new location WMrWindow_SetLocation(inWindow, new_dest.x, new_dest.y); break; - + case WMcWindowArea_NC_Left: case WMcWindowArea_NC_Top: case WMcWindowArea_NC_Right: @@ -893,12 +893,12 @@ WMiWindow_HandleSizeMove( new_width, new_height, WMcPosChangeFlag_NoZOrder); - + // window is no longer in one of these states inWindow->window_data &= ~(WMcWindowDataFlag_Flattened | WMcWindowDataFlag_Zoomed); } break; - + default: { UUtBool convenient; @@ -906,7 +906,7 @@ WMiWindow_HandleSizeMove( } break; } - + // save the mouse position inWindow->prev_mouse_location = global_mouse; } @@ -925,21 +925,21 @@ WMrWindow_DefaultCallback( UUtUns32 inParam2) { UUtUns32 result; - + result = WMcResult_Handled; - + switch (inMessage) { // ------------------------------ case WMcMessage_NC_HitTest: result = (UUtUns32)WMiWindow_NC_HitTest(inWindow, inParam1); break; - + // ------------------------------ case WMcMessage_NC_Paint: WMiWindow_NC_Paint(inWindow); break; - + // ------------------------------ case WMcMessage_NC_MouseMove: case WMcMessage_NC_LMouseDown: @@ -953,7 +953,7 @@ WMrWindow_DefaultCallback( case WMcMessage_NC_RMouseDblClck: WMiWindow_NC_HandleMouseEvent(inWindow, inMessage, inParam1, inParam2); break; - + // ------------------------------ case WMcMessage_NC_CalcClientSize: WMiWindow_NC_CalcClientSize(inWindow, (UUtRect*)inParam1); @@ -963,16 +963,16 @@ WMrWindow_DefaultCallback( case WMcMessage_Close: WMrWindow_Delete(inWindow); break; - + // ------------------------------ case WMcMessage_Flatten: WMiWindow_Flatten(inWindow); break; - + // ------------------------------ case WMcMessage_Zoom: break; - + // ------------------------------ case WMcMessage_MouseMove: if (UUmLowWord(inWindow->window_data) != WMcWindowArea_None) @@ -980,7 +980,7 @@ WMrWindow_DefaultCallback( WMiWindow_HandleSizeMove(inWindow, inParam1, inParam2); } break; - + // ------------------------------ case WMcMessage_Activate: WMiWindow_HandleActivate(inWindow, (UUtBool)inParam1); @@ -1001,6 +1001,6 @@ WMrWindow_DefaultCallback( WMiWindow_HandleResolutionChanged(inWindow, inParam1); break; } - + return result; } diff --git a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Window.h b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Window.h index 0f71d1d..5d6ba13 100644 --- a/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Window.h +++ b/BungieFrameWork/BFW_Source/BFW_WindowManager/WM_Windows/WM_Window.h @@ -11,4 +11,4 @@ #include "BFW_WindowManager.h" // ====================================================================== -#endif /* WM_WINDOW_H */ \ No newline at end of file +#endif /* WM_WINDOW_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI2.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI2.c index 43e13e1..cd8fd2e 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI2.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI2.c @@ -1,12 +1,12 @@ /* FILE: Imp_AI2.c - + AUTHOR: Chris Butcher - + CREATED: April 11, 2000 - + PURPOSE: AI data importer - + Copyright (c) 2000 Bungie Software */ @@ -25,7 +25,7 @@ #include #include -AUtFlagElement IMPgAI2BehaviorFlags[] = +AUtFlagElement IMPgAI2BehaviorFlags[] = { { "never-startle", @@ -114,7 +114,7 @@ UUtError Imp_AI2_ReadClassBehavior( error = GRrGroup_GetFloat(inGroup, "daze_delay_min", &dazed_delay); if (error == UUcError_None) { - inClass->ai2_behavior.dazed_minframes = + inClass->ai2_behavior.dazed_minframes = (UUtUns16) MUrUnsignedSmallFloat_To_Uns_Round(UUcFramesPerSecond * dazed_delay); } else { inClass->ai2_behavior.dazed_minframes = 60; @@ -122,7 +122,7 @@ UUtError Imp_AI2_ReadClassBehavior( error = GRrGroup_GetFloat(inGroup, "daze_delay_max", &dazed_delay); if (error == UUcError_None) { - inClass->ai2_behavior.dazed_maxframes = + inClass->ai2_behavior.dazed_maxframes = (UUtUns16) MUrUnsignedSmallFloat_To_Uns_Round(UUcFramesPerSecond * dazed_delay); } else { inClass->ai2_behavior.dazed_maxframes = 100; @@ -168,26 +168,26 @@ UUtError Imp_AI2_ReadClassBehavior( */ #if TARGETING_MISS_DECAY - error = GRrGroup_GetFloat(inGroup, "startle_miss_angle_min", + error = GRrGroup_GetFloat(inGroup, "startle_miss_angle_min", &inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_angle_min); if (error != UUcError_None) inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_angle_min = 4.5f; inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_angle_min *= M3cDegToRad; - error = GRrGroup_GetFloat(inGroup, "startle_miss_angle_max", + error = GRrGroup_GetFloat(inGroup, "startle_miss_angle_max", &inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_angle_max); - if (error != UUcError_None) + if (error != UUcError_None) inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_angle_max = 30.0f; inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_angle_max *= M3cDegToRad; - error = GRrGroup_GetFloat(inGroup, "startle_miss_decay", + error = GRrGroup_GetFloat(inGroup, "startle_miss_decay", &inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_decay); if (error != UUcError_None) inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_decay = 0.5f; #else - error = GRrGroup_GetFloat(inGroup, "startle_miss_angle", + error = GRrGroup_GetFloat(inGroup, "startle_miss_angle", &inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_angle); - if (error != UUcError_None) + if (error != UUcError_None) inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_angle = 30.0f; inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_angle = @@ -195,7 +195,7 @@ UUtError Imp_AI2_ReadClassBehavior( inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_angle = MUrSin(inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_angle * M3cDegToRad); - error = GRrGroup_GetFloat(inGroup, "startle_miss_distance", + error = GRrGroup_GetFloat(inGroup, "startle_miss_distance", &inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_distance); if (error != UUcError_None) inClass->ai2_behavior.combat_parameters.targeting_params.startle_miss_distance = 120.0f; @@ -204,29 +204,29 @@ UUtError Imp_AI2_ReadClassBehavior( * enemy movement prediction */ - error = GRrGroup_GetFloat(inGroup, "predict_amount", + error = GRrGroup_GetFloat(inGroup, "predict_amount", &inClass->ai2_behavior.combat_parameters.targeting_params.predict_amount); - if (error != UUcError_None) + if (error != UUcError_None) inClass->ai2_behavior.combat_parameters.targeting_params.predict_amount = 1.0f; - error = GRrGroup_GetUns32(inGroup, "predict_positiondelayframes", + error = GRrGroup_GetUns32(inGroup, "predict_positiondelayframes", &inClass->ai2_behavior.combat_parameters.targeting_params.predict_positiondelayframes); - if (error != UUcError_None) + if (error != UUcError_None) inClass->ai2_behavior.combat_parameters.targeting_params.predict_positiondelayframes = 0; - error = GRrGroup_GetUns32(inGroup, "predict_predictdelayframes", + error = GRrGroup_GetUns32(inGroup, "predict_predictdelayframes", &inClass->ai2_behavior.combat_parameters.targeting_params.predict_delayframes); - if (error != UUcError_None) + if (error != UUcError_None) inClass->ai2_behavior.combat_parameters.targeting_params.predict_delayframes = 5; - error = GRrGroup_GetUns32(inGroup, "predict_velocityframes", + error = GRrGroup_GetUns32(inGroup, "predict_velocityframes", &inClass->ai2_behavior.combat_parameters.targeting_params.predict_velocityframes); - if (error != UUcError_None) + if (error != UUcError_None) inClass->ai2_behavior.combat_parameters.targeting_params.predict_velocityframes = 15; - error = GRrGroup_GetUns32(inGroup, "predict_trendframes", + error = GRrGroup_GetUns32(inGroup, "predict_trendframes", &inClass->ai2_behavior.combat_parameters.targeting_params.predict_trendframes); - if (error != UUcError_None) + if (error != UUcError_None) inClass->ai2_behavior.combat_parameters.targeting_params.predict_trendframes = 60; /* @@ -386,7 +386,7 @@ UUtError Imp_AI2_ReadClassBehavior( Imp_PrintMessage(IMPcMsg_Important, " %s\n", AI2cVocalizationTypeName[type_index]); } IMPmError_ReturnOnErrorMsg(UUcError_Generic, "vocalization table: unknown type"); - } + } // read the sound name error = GRrGroup_Array_GetElement(sub_array, cVocalization_Sound, &elemType, &element); diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI2.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI2.h index b1bdd71..0337bef 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI2.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI2.h @@ -1,12 +1,12 @@ /* FILE: Imp_AI2.h - + AUTHOR: Chris Butcher - + CREATED: April 11, 2000 - + PURPOSE: Definitions for AI2 data importer - + Copyright (c) 2000 Bungie Software */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI_Script.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI_Script.c index e22bbeb..5e01ed6 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI_Script.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI_Script.c @@ -1,8 +1,8 @@ /* Imp_AI_Script.c - + Script level AI stuff - + Author: Quinn Dunki c1998 Bungie */ @@ -11,7 +11,7 @@ #include #include #include - + #include "BFW.h" #include "BFW_FileManager.h" #include "BFW_TemplateManager.h" @@ -45,7 +45,7 @@ static UUtError AIiScript_LoadRemapTable( UUtError error = UUcError_None; BFtFileRef *fileRef; BFtFile *outFile; - + // If there are no quads remapped in memory, look for them on disk if (!IMPgAI_QuadRemapCount) { @@ -85,7 +85,7 @@ static void AIiScript_StatementProcess_QuadRefToIndex( UUtUns32 ref,lowestIdx; UUtUns16 i; UUtError error; - + lowestIdx = inLowest ? 0xFFFFFFFF : 0; error = AIiScript_LoadRemapTable(); @@ -101,7 +101,7 @@ static void AIiScript_StatementProcess_QuadRefToIndex( } } } - + if ((inLowest && lowestIdx == 0xFFFFFFFF) || (!inLowest && lowestIdx == 0) || error != UUcError_None) @@ -110,7 +110,7 @@ static void AIiScript_StatementProcess_QuadRefToIndex( " exist or you need to import the environment again, or the remap quad file is missing",ref); return; } - + sprintf(inParm,"%d",lowestIdx); } @@ -123,12 +123,12 @@ void IMPrScript_AddQuadRemap( // Adds a quad remapping index if (IMPgAI_QuadRemapCount >= IMPcMaxQuadRemaps) return; - + UUmAssert(inQuadIndex < UUcMaxUns16); IMPgAI_QuadRefRemap[0][IMPgAI_QuadRemapCount] = (UUtUns16)inQuadIndex; IMPgAI_QuadRefRemap[1][IMPgAI_QuadRemapCount] = (UUtUns16)inRefNumber; IMPgAI_QuadRemapCount++; - + // Note the location of the texture GRrGroup_GetString(inEnvGroup,"textureDirectory",&string); UUrString_Copy(IMPgAI_EnvTextureDirectory,string,128); @@ -193,7 +193,7 @@ static UUtError Imp_Parse_SuperTable( char *curLine,*string; UUtBool skipDoors = UUcFalse; UUtBool haveID0 = UUcFalse; - + UUmAssertReadPtr(inTableFileRef, 1); UUmAssertWritePtr(outCharacterSetup, sizeof(*outCharacterSetup)); @@ -205,7 +205,7 @@ static UUtError Imp_Parse_SuperTable( error = BFrTextFile_OpenForRead(inTableFileRef, &textFile); UUmError_ReturnOnError(error); - + // 1. arbitray white lines // 2. line the contains 'characters' // 3 @@ -264,9 +264,9 @@ static UUtError Imp_Parse_SuperTable( // default script id curField = UUrTableGetNextEntry(curLine, &internal); error = UUrString_To_Uns16(curField, &curSetup->defaultScriptID); - + if(curSetup->defaultScriptID == 0) haveID0 = UUcTrue; - + // default flag id curField = UUrTableGetNextEntry(NULL, &internal); error = UUrString_To_Int16(curField, &curSetup->defaultFlagID); @@ -275,8 +275,8 @@ static UUtError Imp_Parse_SuperTable( curField = UUrTableGetNextEntry(NULL, &internal); if (0 == UUrString_Compare_NoCase_NoSpace(curField, "")) { } else if (0 == UUrString_Compare_NoCase_NoSpace(curField, "n")) { } - else if (0 == UUrString_Compare_NoCase_NoSpace(curField, "y")) { - curSetup->flags |= AIcSetup_Flag_AutoFreeze; + else if (0 == UUrString_Compare_NoCase_NoSpace(curField, "y")) { + curSetup->flags |= AIcSetup_Flag_AutoFreeze; } else { Imp_PrintWarning("looking for y/n got %s. I will asssume n.", curField); @@ -314,19 +314,19 @@ static UUtError Imp_Parse_SuperTable( curField = UUrTableGetNextEntry(NULL, &internal); { char *subInternal = NULL; - + string = UUrString_Tokenize(curField,"/",&subInternal); error = UUrString_To_Uns16(string, &curSetup->ammo); if (error!=UUcError_None) curSetup->ammo = 0; - + string = UUrString_Tokenize(NULL,"/",&subInternal); error = UUrString_To_Uns16(string, &curSetup->leaveAmmo); if (error!=UUcError_None) curSetup->leaveAmmo = UUcMaxUns16; - + string = UUrString_Tokenize(NULL,"/",&subInternal); error = UUrString_To_Uns16(string, &curSetup->leaveClips); if (error!=UUcError_None) curSetup->leaveClips = 0; - + string = UUrString_Tokenize(NULL,"/",&subInternal); error = UUrString_To_Uns16(string, &curSetup->leaveCells); if (error!=UUcError_None) curSetup->leaveCells = 0; @@ -335,11 +335,11 @@ static UUtError Imp_Parse_SuperTable( error = UUrString_To_Uns16(string, &curSetup->leaveHypos); if (error!=UUcError_None) curSetup->leaveHypos = 0; } - + /* * ADD THESE BACK IN AS THEY ARE NEEDED */ - + // idle curField = UUrTableGetNextEntry(NULL, &internal); if (!UUrString_IsSpace(curField)) { @@ -412,13 +412,13 @@ static UUtError Imp_Parse_SuperTable( //UUmError_ReturnOnError(error); } } - + // CB: this is not an error any more, it is handled by the AI2 system in the engine /* if(haveID0 == UUcFalse) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Did not find character with ID 0"); }*/ - + spawnArray = UUrMemory_Block_New(sizeof(*spawnArray)); if (NULL == spawnArray) { goto failure; @@ -434,9 +434,9 @@ static UUtError Imp_Parse_SuperTable( if (UUrString_IsSpace(curLine)) { continue; } if (UUrString_HasPrefix(curLine, "triggers")) break; - for(curField = UUrString_Tokenize(curLine, " \t", &strtokPrivate); - curField != NULL; - curField = UUrString_Tokenize(NULL, " \t", &strtokPrivate)) + for(curField = UUrString_Tokenize(curLine, " \t", &strtokPrivate); + curField != NULL; + curField = UUrString_Tokenize(NULL, " \t", &strtokPrivate)) { if (UUrString_IsSpace(curLine)) { continue; } @@ -454,7 +454,7 @@ static UUtError Imp_Parse_SuperTable( UUmError_ReturnOnError(error); } - spawnArray->spawnFlagIDs[spawnArray->numSpawnFlagIDs++] = thisSpawnPoint; + spawnArray->spawnFlagIDs[spawnArray->numSpawnFlagIDs++] = thisSpawnPoint; } } @@ -469,7 +469,7 @@ static UUtError Imp_Parse_SuperTable( AItScriptTriggerClass curTrigger; char *curField; char *internal; - + if (UUrString_IsSpace(curLine)) { continue; } if (UUrString_HasPrefix(curLine, "doors")) break; if (UUrString_HasPrefix(curLine, "scripts")) @@ -528,7 +528,7 @@ static UUtError Imp_Parse_SuperTable( } // ADD TRIGGER SCRIPTS BACK IN WHEN NEW TOOL IS READY - BHP - + // offscript curField = UUrTableGetNextEntry(NULL, &internal); @@ -569,7 +569,7 @@ static UUtError Imp_Parse_SuperTable( else { error = UUrString_To_Uns16(curField, &curTrigger.team); - if (error) { + if (error) { Imp_PrintWarning("trigger had an invalid team %s", curField); } } @@ -583,13 +583,13 @@ static UUtError Imp_Parse_SuperTable( else { error = UUrString_To_Uns16(curField, &curTrigger.refRestrict); - if (error) { + if (error) { Imp_PrintWarning("trigger had an invalid character %s", curField); } } scriptTriggerArray = UUrMemory_Block_Realloc(scriptTriggerArray, sizeof(AItScriptTriggerClassArray) + sizeof(AItScriptTriggerClass) * scriptTriggerArray->numTriggers); - scriptTriggerArray->triggers[scriptTriggerArray->numTriggers++] = curTrigger; + scriptTriggerArray->triggers[scriptTriggerArray->numTriggers++] = curTrigger; } // Parse doors @@ -610,34 +610,34 @@ static UUtError Imp_Parse_SuperTable( if (UUrString_HasPrefix(curLine, "#")) { continue; } if (UUrString_IsSpace(curLine)) { continue; } if (UUrString_HasPrefix(curLine, "scripts")) break; - + UUrMemory_Clear(&curDoor, sizeof(curDoor)); - + // id open type open anim open key close type close key radius open snd close snd invis teams flags link - - + + // id curField = UUrTableGetNextEntry(curLine, &internal); error = UUrString_To_Uns16(curField, &curDoor.id); if (UUcError_None != error || curDoor.id == 0) { Imp_PrintWarning("door had invalid id"); } - + // open type curField = UUrTableGetNextEntry(NULL, &internal); if (UUmString_IsEqual_NoCase_NoSpace(curField, "manual")) { curDoor.flags |= OBcDoorClassFlag_OpenManual; } - + // open anim curField = UUrTableGetNextEntry(NULL, &internal); error = TMrConstruction_Instance_GetPlaceHolder(OBcTemplate_Animation,curField,(TMtPlaceHolder *)&curDoor.openCloseAnim); if (UUcError_None != error) { Imp_PrintWarning("door had invalid open animation"); - + } - + // open key curField = UUrTableGetNextEntry(NULL, &internal); error = UUrString_To_Uns16(curField, &curDoor.openKey); @@ -650,7 +650,7 @@ static UUtError Imp_Parse_SuperTable( { curDoor.flags |= OBcDoorClassFlag_CloseManual; } - + #if 0 // close anim curField = UUrTableGetNextEntry(NULL, &internal); @@ -659,7 +659,7 @@ static UUtError Imp_Parse_SuperTable( Imp_PrintWarning("door had invalid close animation"); } #endif - + // close key curField = UUrTableGetNextEntry(NULL, &internal); error = UUrString_To_Uns16(curField, &curDoor.closeKey); @@ -671,13 +671,13 @@ static UUtError Imp_Parse_SuperTable( error = UUrString_To_Float(curField, &curDoor.activationRadiusSquared); if (error!=UUcError_None) Imp_PrintWarning("Door had invalid activation radius"); curDoor.activationRadiusSquared *= curDoor.activationRadiusSquared; - + // invisible teams curField = UUrTableGetNextEntry(NULL, &internal); UUrString_StripDoubleQuotes(curField,strlen(curField)+1); error = AUrParseNumericalRangeString(curField,&curDoor.invisibility,AIcMaxTeams); if (UUcError_None != error) curDoor.invisibility = 0; - + // flags curField = UUrTableGetNextEntry(NULL, &internal); error = UUrString_To_Uns16(curField, &flags); @@ -688,10 +688,10 @@ static UUtError Imp_Parse_SuperTable( curField = UUrTableGetNextEntry(NULL, &internal); error = UUrString_To_Uns16(curField, &curDoor.linkID); if (error!=UUcError_None) curDoor.linkID = 0; - + // Create the instance doorArray = UUrMemory_Block_Realloc(doorArray, sizeof(OBtDoorClassArray) + sizeof(OBtDoorClass) * doorArray->numDoors); - doorArray->doors[doorArray->numDoors++] = curDoor; + doorArray->doors[doorArray->numDoors++] = curDoor; } } @@ -747,7 +747,7 @@ UUtError Imp_AddAIScriptTable( // 2. parse file // 3. create instance - error = + error = Imp_Common_BuildInstance( inSourceFile, inSourceFileModDate, @@ -765,7 +765,7 @@ UUtError Imp_AddAIScriptTable( return UUcError_None; } - error = + error = Imp_Parse_SuperTable( tableFileRef, &srcCharacterSetup, @@ -773,9 +773,9 @@ UUtError Imp_AddAIScriptTable( &srcTriggerArray, &srcDoorArray); UUmError_ReturnOnError(error); - + BFrFileRef_Dispose(tableFileRef); - + // character setup error = TMrConstruction_Instance_Renew( AIcTemplate_CharacterSetupArray, @@ -785,9 +785,9 @@ UUtError Imp_AddAIScriptTable( UUmError_ReturnOnError(error); UUrMemory_MoveFast( - srcCharacterSetup, - dstCharacterSetup, - sizeof(AItCharacterSetupArray) + + srcCharacterSetup, + dstCharacterSetup, + sizeof(AItCharacterSetupArray) + sizeof(AItCharacterSetup) * (srcCharacterSetup->numCharacterSetups - 1)); // spawn points @@ -799,9 +799,9 @@ UUtError Imp_AddAIScriptTable( UUmError_ReturnOnError(error); UUrMemory_MoveFast( - srcSpawnArray, - dstSpawnArray, - sizeof(ONtSpawnArray) + + srcSpawnArray, + dstSpawnArray, + sizeof(ONtSpawnArray) + sizeof(UUtInt16) * (srcSpawnArray->numSpawnFlagIDs - 1)); // triggers @@ -813,9 +813,9 @@ UUtError Imp_AddAIScriptTable( UUmError_ReturnOnError(error); UUrMemory_MoveFast( - srcTriggerArray, - dstTriggerArray, - sizeof(AItScriptTriggerClassArray) + + srcTriggerArray, + dstTriggerArray, + sizeof(AItScriptTriggerClassArray) + sizeof(AItScriptTriggerClass) * (srcTriggerArray->numTriggers - 1)); // doors @@ -827,9 +827,9 @@ UUtError Imp_AddAIScriptTable( UUmError_ReturnOnError(error); UUrMemory_MoveFast( - srcDoorArray, - dstDoorArray, - sizeof(OBtDoorClassArray) + + srcDoorArray, + dstDoorArray, + sizeof(OBtDoorClassArray) + sizeof(OBtDoorClass) * (srcDoorArray->numDoors - 1)); // free up memory diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI_Script.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI_Script.h index 4d5ee22..c7471dd 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI_Script.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_AI_Script.h @@ -1,8 +1,8 @@ /* Imp_AI_Script.h - + Script level AI stuff - + Author: Quinn Dunki c1998 Bungie */ @@ -27,12 +27,12 @@ UUtError Imp_AddAIScriptTable( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + void IMPrScript_AddQuadRemap( UUtUns32 inQuadIndex, UUtUns32 inRefNumber, GRtGroup *inEnvGroup); - + UUtError IMPrScript_GetRemapData( UUtUns16 *outCount); diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_ANSI.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_ANSI.c index 5341283..44efba7 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_ANSI.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_ANSI.c @@ -115,7 +115,7 @@ main( UUtUns32 itr; FILE *stream; - + for(itr = 1; itr <= 17; itr++) { @@ -145,47 +145,47 @@ main( { UUtError error; BFtFileRef* instanceFileRef; - + char fileName[256]; const char* leafName; char* temp; char targetName[256]; - + BFtFileRef prefFileRef; GRtGroup_Context* prefGroupContext; GRtGroup* prefGroup; char *dataFileDir; char batchDirFileName[256]; - + BFtFileRef* batchDirFileRef; - + UUtBool processFinal = UUcFalse; UUtBool addDebugFile = UUcFalse; UUtBool processFinalOnly = UUcFalse; UUtBool dumpStuff = UUcFalse; UUtBool stopAfterTE = UUcFalse; - + UUtBool runTE = UUcFalse; - + UUtBool convertToNativeEndiean = UUcFalse; - + UUtUns16 i; BFtFileIterator* fileIterator; - + BFtFileRef gameDataRef; - + UUtUns32* targetLevelBV; UUtUns32 itr; UUtBool gotLevel = UUcFalse; - + #if defined(UUmCompiler) && (UUmCompiler == UUmCompiler_VisC) #if defined(UUmPlatform) && (UUmPlatform == UUmPlatform_Win32) && defined(SHIPPING_VERSION) && (SHIPPING_VERSION != 1) __try { stack_walk_initialize(); #endif #endif - + /* * Initialize the Universal Utilities. This does a base level platform init. So if * this succedes we can bring up error dialogs @@ -200,25 +200,25 @@ main( } #if UUmPlatform == UUmPlatform_Mac - + runTE = UUcTrue; - + UUgError_HaltOnError = UUcTrue; - + #else - + UUgError_PrintWarning = UUcTrue; - + #endif - + targetLevelBV = UUrBitVector_New(IMPcMaxNumLevels); if(targetLevelBV == NULL) return 1; - + #if defined(PROFILE) && PROFILE UUrProfile_Initialize(); UUrProfile_State_Set(UUcProfile_State_Off); - #endif - + #endif + argc = CLrGetCommandLine(argc, argv, &argv); UUrProfile_State_Set(UUcProfile_State_On); @@ -232,7 +232,7 @@ main( /* * Parse the command line */ - + for(i = 1; i < argc; i++) { if(strcmp(argv[i], "-final") == 0) @@ -242,7 +242,7 @@ main( else if (strcmp(argv[i], "-skipanykey") == 0) { IMPgSkipAnyKey= UUcTrue; - } + } else if (strcmp(argv[i], "-green") == 0) { IMPgGreen = UUcTrue; @@ -304,9 +304,9 @@ main( { goto ohYeaBaby; } - + iParseLevel(argv[i], targetLevelBV); - + gotLevel = UUcTrue; } else if (strcmp(argv[i], "-anim_angle") == 0) @@ -334,12 +334,12 @@ main( else if (0 == strcmp(argv[i], "-lp1")) { #if UUmPlatform == UUmPlatform_Mac - + Imp_PrintWarning("-lp is only supported on the PC"); goto ohYeaBaby; - + #endif - + IMPgLightmap_OutputPrepFile = UUcTrue; IMPgLightmap_OutputPrepFileOne = UUcTrue; IMPgConstructing = UUcFalse; @@ -351,7 +351,7 @@ main( IMPgLightMap_HighQuality = UUcFalse; } else if (0 == strcmp(argv[i], "-lm")) - { + { IMPgLightingFromLSFiles = UUcTrue; } else if (0 == strcmp(argv[i], "-quiet")) @@ -390,7 +390,7 @@ main( } } } - else if (0 == strcmp(argv[i], "-unselect")) + else if (0 == strcmp(argv[i], "-unselect")) { char *internal; char *cur_select; @@ -463,14 +463,14 @@ main( goto ohYeaBaby; } } - + goto iMissBasic; ohYeaBaby: Imp_PrintWarning("%s [-nodialog] [-lightmaps] [-final] [-finalOnly] [-debug] [-grid] [-dumpStuff] [-t] [-tOnly] [-level num]"UUmNL, argv[0]); fprintf(stdout, "done, press any key that is labeled enter"); fgetc(stdin); return -1; - + iMissBasic: /* @@ -494,18 +494,18 @@ main( error = TMrInitialize(UUcFalse, &gameDataRef); UUmError_ReturnOnError(error); - + if(convertToNativeEndiean) { TMrConstruction_ConvertToNativeEndian(); goto doneConverting; } - + if(gotLevel == UUcFalse) { UUrBitVector_SetBitAll(targetLevelBV, IMPcMaxNumLevels); } - + if(runTE) { Imp_PrintMessage(IMPcMsg_Cosmetic, "Running the template extractor"UUmNL); @@ -513,14 +513,14 @@ main( if (UUcError_None != error) { Imp_PrintWarning("Errors with the template extractor"); } - + if (stopAfterTE) exit(0); } - + Imp_PrintMessage(IMPcMsg_Cosmetic, "Imp_Initialize"UUmNL); error = Imp_Initialize(); UUmError_ReturnOnError(error); - + if(0) { UUtRect rect; @@ -528,16 +528,16 @@ main( rect.left = 20; rect.bottom = rect.top + 1024; rect.right = rect.left + 1024; - + gDebugWindow = AUrWindow_New(&rect); } - + Imp_PrintMessage(IMPcMsg_Cosmetic, "Finding Preferences.txt"UUmNL); error = BFrFileRef_Search("Preferences.txt", &prefFileRef); UUmError_ReturnOnErrorMsg(error, "Could not find preferences file"); - + Imp_PrintMessage(IMPcMsg_Cosmetic, "Making the preferences group"UUmNL); - error = + error = GRrGroup_Context_NewFromFileRef( &prefFileRef, NULL, @@ -545,7 +545,7 @@ main( &prefGroupContext, &prefGroup); UUmError_ReturnOnErrorMsg(error, "Could not make preferences group"); - + gPreferencesGroup = prefGroup; Imp_PrintMessage(IMPcMsg_Cosmetic, "Looking up DataFileDir"UUmNL); @@ -556,14 +556,14 @@ main( Imp_PrintMessage(IMPcMsg_Cosmetic, "Finding the batch file directory"UUmNL); error = BFrFileRef_MakeFromName(batchDirFileName, &batchDirFileRef); UUmError_ReturnOnErrorMsg(error, "Could not find OniBatchFiles directory"); - + /* * Initialize importers that need it */ error = Imp_Character_Initialize(); UUmError_ReturnOnError(error); - - + + /* * Loop through all the _bat files */ @@ -571,7 +571,7 @@ main( if (!BFrFileRef_FileExists(batchDirFileRef)) { Imp_PrintWarning("The batch file directory (%s) could not be found", BFrFileRef_GetLeafName(batchDirFileRef)); } - + // tell user what levels will be processed Imp_PrintMessage(IMPcMsg_Important, "Building levels: "); for(itr = 0; itr < IMPcMaxNumLevels; itr++) @@ -582,7 +582,7 @@ main( } } Imp_PrintMessage(IMPcMsg_Important, UUmNL); - + error = BFrDirectory_FileIterator_New( batchDirFileRef, @@ -590,7 +590,7 @@ main( "_bat.txt", &fileIterator); UUmError_ReturnOnErrorMsg(error, "Could not create iterator"); - + Imp_PrintMessage(IMPcMsg_Cosmetic, "Looping through the batch files"UUmNL); while(1) { @@ -601,10 +601,10 @@ main( { break; } - + leafName = BFrFileRef_GetLeafName(&batchFileRef); Imp_PrintMessage(IMPcMsg_Cosmetic, "batch file %s"UUmNL, leafName); - + temp = strchr(leafName, '_'); if(temp == NULL) { @@ -613,15 +613,15 @@ main( } sscanf(leafName + 5, "%d", &IMPgCurLevel); - + if(IMPgCurLevel >= TMcMaxLevelNum) { fprintf(stderr, "ERROR: Illegal level number: %s\n", leafName); continue; } - + UUrString_Copy(targetName, temp + 1, 256); - + temp = strrchr(targetName, '_'); if(temp == NULL) { @@ -630,12 +630,12 @@ main( } *temp = 0; - + if(!UUrBitVector_TestBit(targetLevelBV, IMPgCurLevel)) { continue; } - + if(strcmp(targetName, "Final") == 0) { if(processFinal == UUcFalse) @@ -647,7 +647,7 @@ main( { continue; } - + /* * Load the .dat instance file, create if needed */ @@ -660,20 +660,20 @@ main( } Imp_PrintMessage(IMPcMsg_Important, "Starting construction on %s."UUmNL, fileName); - + error = BFrFileRef_DuplicateAndAppendName( &gameDataRef, fileName, &instanceFileRef); UUmError_ReturnOnError(error); - + if(IMPgLightmap_OI) { IMPgLightmap_Output = UUcTrue; IMPgConstructing = UUcFalse; } - + goAgain: if(IMPgConstructing) @@ -681,11 +681,11 @@ main( error = TMrConstruction_Start(instanceFileRef); UUmError_ReturnOnError(error); } - + /* * Process the final instances */ - Imp_PrintMessage(IMPcMsg_Important, "processing"UUmNL); + Imp_PrintMessage(IMPcMsg_Important, "processing"UUmNL); error = Imp_BatchFile_Process(&batchFileRef); UUmError_ReturnOnError(error); @@ -693,13 +693,13 @@ main( /* * Save and dispose */ - Imp_PrintMessage(IMPcMsg_Important, "stopping and disposing"UUmNL); - + Imp_PrintMessage(IMPcMsg_Important, "stopping and disposing"UUmNL); + if(IMPgConstructing) { TMrConstruction_Stop(dumpStuff); } - + // go again if we need to for lightmaps if(IMPgLightmap_OI == UUcTrue && IMPgLightmap_Output == UUcTrue) { @@ -707,18 +707,18 @@ main( IMPgConstructing = UUcTrue; goto goAgain; } - + BFrFileRef_Dispose(instanceFileRef); } - + BFrDirectory_FileIterator_Delete(fileIterator); - Imp_PrintMessage(IMPcMsg_Important, "done looping "UUmNL, leafName); - + Imp_PrintMessage(IMPcMsg_Important, "done looping "UUmNL, leafName); + Imp_WriteTextureSize(); GRrGroup_Context_Delete(prefGroupContext); - + BFrFileRef_Dispose(batchDirFileRef); if (IMPgSuppressedWarnings || IMPgSuppressedErrors) { @@ -731,23 +731,23 @@ main( doneConverting: TMrTerminate(); - + if(gDebugWindow != NULL) AUrWindow_Delete(gDebugWindow); - + #if defined(PROFILE) && PROFILE UUrProfile_State_Set(UUcProfile_State_Off); UUrProfile_Dump("ImpProfile"); UUrProfile_Terminate(); - #endif - + #endif + UUrBitVector_Dispose(targetLevelBV); - + IMrTerminate(); - + UUrTerminate(); - + #if ((UUmPlatform == UUmPlatform_Win32) && (UUmCompiler != UUmCompiler_MWerks)) - + fprintf(stdout, "done, press any key that is labeled enter"); if (!IMPgSkipAnyKey) { fgetc(stdin); @@ -760,7 +760,7 @@ main( __except (handle_exception(GetExceptionInformation())) {} #endif #endif - + return 0; } #endif diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_BatchFile.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_BatchFile.c index b45ad3a..a292570 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_BatchFile.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_BatchFile.c @@ -72,7 +72,7 @@ typedef struct tParseData UUtBool parseThisType; } tParseData; -tParseData gParseData[] = +tParseData gParseData[] = { { "texture", Imp_AddTexture, UUcTrue }, { "texture_big", Imp_AddTexture_Big, UUcTrue }, @@ -140,9 +140,9 @@ iStripNonFileNameStuff( char* inStr) { char* p = inStr; - + while((*p != 0) && !UUrIsSpace(*p) && *p != '#') p++; - + *p = 0; } @@ -157,12 +157,12 @@ static UUtError Imp_Process_InsTxt(BFtFileRef *inSourceFileRef) char *instanceNameStr; UUtUns32 sourceModDate; tParseData *curParseData; - - - curFileName = BFrFileRef_GetLeafName(inSourceFileRef); - + + + curFileName = BFrFileRef_GetLeafName(inSourceFileRef); + UUrMemory_Leak_Start(curFileName); - + error = GRrGroup_Context_NewFromFileRef( inSourceFileRef, @@ -170,12 +170,12 @@ static UUtError Imp_Process_InsTxt(BFtFileRef *inSourceFileRef) NULL, &fileGroupContext, &fileGroup); - if (error) + if (error) { Imp_PrintWarning("Could not create group"); goto errorExit; } - + /* * Get the parse name */ @@ -190,7 +190,7 @@ static UUtError Imp_Process_InsTxt(BFtFileRef *inSourceFileRef) Imp_PrintWarning("File \"%s\": Could not get template string", (UUtUns32)curFileName, 0, 0); goto errorExit; } - + /* * Get the instance name */ @@ -205,7 +205,7 @@ static UUtError Imp_Process_InsTxt(BFtFileRef *inSourceFileRef) Imp_PrintWarning("File \"%s\": Could not get instance string", (UUtUns32)curFileName, 0, 0); goto errorExit; } - + /* * Get the instance source file mod date */ @@ -217,8 +217,8 @@ static UUtError Imp_Process_InsTxt(BFtFileRef *inSourceFileRef) Imp_PrintWarning("Could not get instance source mod date"); goto errorExit; } - - + + /* * Parse the data */ @@ -226,25 +226,25 @@ static UUtError Imp_Process_InsTxt(BFtFileRef *inSourceFileRef) while(curParseData->name != 0) { if(!strcmp(curParseData->name, parserNameStr)) break; - + curParseData++; - } - + } + if ((curParseData->name != 0) && (curParseData->parseThisType)) { Imp_PrintMessage(IMPcMsg_Cosmetic, "template: %s"UUmNL, parserNameStr); Imp_PrintMessage(IMPcMsg_Important, "\tinstanceName: %s"UUmNL, instanceNameStr); Imp_PrintMessage(IMPcMsg_Cosmetic, "\tprocessing %s"UUmNL, curParseData->name); - + if(IMPgConstructing) TMmConstruction_MajorCheck(); - + // cheesy hack to only parse environments when outputting lightmaps if(IMPgLightmaps && IMPgLightmap_Output && (curParseData->parseFunction != IMPrEnv_Add)) { goto errorExit; } - + error = curParseData->parseFunction( inSourceFileRef, sourceModDate, @@ -253,8 +253,8 @@ static UUtError Imp_Process_InsTxt(BFtFileRef *inSourceFileRef) if(error != UUcError_None) { - Imp_PrintWarning("error %d Could not parse instance file %s.", - error, + Imp_PrintWarning("error %d Could not parse instance file %s.", + error, BFrFileRef_GetLeafName(inSourceFileRef)); } @@ -264,14 +264,14 @@ static UUtError Imp_Process_InsTxt(BFtFileRef *inSourceFileRef) { fprintf(stderr, "\tNO PARSER FOUND"UUmNL); } - + errorExit: if (NULL != fileGroupContext) { GRrGroup_Context_Delete(fileGroupContext); } UUrMemory_Leak_StopAndReport(); - + return error; } @@ -285,17 +285,17 @@ UUtError Imp_Process_Bin(BFtFileRef *inSourceFileRef) void *separate_data; UUtUns32 data_length; UUtError error; - + // don't processes bin files when outputting lightmaps if ((IMPgLightmaps) && (IMPgLightmap_Output)) { return UUcError_None; } - + curFileName = BFrFileRef_GetLeafName(inSourceFileRef); UUrMemory_Leak_Start(curFileName); - + // allocate memory and copy the file's contents into that memory error = BFrFileRef_LoadIntoMemory( @@ -303,7 +303,7 @@ UUtError Imp_Process_Bin(BFtFileRef *inSourceFileRef) &data_length, &data); IMPmError_ReturnOnErrorMsg(error, "Unable to load binary file into memory"); - + if (data_length > 0) { Imp_PrintMessage(IMPcMsg_Important, "\tbinaryFileName: %s"UUmNL, curFileName); @@ -335,7 +335,7 @@ UUtError Imp_Process_Bin(BFtFileRef *inSourceFileRef) 0, &binary_data); IMPmError_ReturnOnErrorMsg(error, "Unable to create binary data instance"); - + // copy the file data into the raw template data separate_data = TMrConstruction_Separate_New(data_length, BDcTemplate_BinaryData); if (separate_data == NULL) { @@ -346,18 +346,18 @@ UUtError Imp_Process_Bin(BFtFileRef *inSourceFileRef) data, separate_data, data_length); - + binary_data->data_size = data_length; binary_data->data_index = (TMtSeparateFileOffset) TMrConstruction_Separate_Write(separate_data); if(IMPgConstructing) { TMmConstruction_MajorCheck(); } } - + // dispose of the allocated memory UUrMemory_Block_Delete(data); - + UUrMemory_Leak_StopAndReport(); - + return UUcError_None; } @@ -366,17 +366,17 @@ static UUtError Imp_Process_OneSourceFile(BFtFileRef *inSourceFileRef) UUtError error; const char *curFileName; char *suffix; - - curFileName = BFrFileRef_GetLeafName(inSourceFileRef); - + + curFileName = BFrFileRef_GetLeafName(inSourceFileRef); + if(BFrFileRef_FileExists(inSourceFileRef) == UUcFalse) { Imp_PrintWarning( - "Batch file referred to instance file \"%s\" but that file does not exist!", + "Batch file referred to instance file \"%s\" but that file does not exist!", curFileName); return UUcError_Generic; } - + suffix = strrchr(curFileName, '.'); if (strcmp(suffix, ".bin") == 0) { @@ -389,28 +389,28 @@ static UUtError Imp_Process_OneSourceFile(BFtFileRef *inSourceFileRef) error = Imp_Process_InsTxt(inSourceFileRef); } IMPmError_ReturnOnError(error); - + return UUcError_None; } UUtError Imp_BatchFile_Process( BFtFileRef* inBatchFileRef) -{ +{ UUtError error; BFtTextFile* batchFile; char* curFileName; - BFtFileRef* sourceFileRef; + BFtFileRef* sourceFileRef; UUtBool retry,processList,abort; UUtUns16 numFiles,i; BFtFileRef *dir[IMPcMaxDirInclude]; UUtInt64 startTime = UUrMachineTime_High(); UUtUns32 startInstances = TMrConstruction_GetNumInstances(); char* includeName; - + error = BFrTextFile_OpenForRead(inBatchFileRef, &batchFile); UUmError_ReturnOnErrorMsg(error, "Could not open batch file"); - + while(1) { curFileName = BFrTextFile_GetNextStr(batchFile); @@ -418,18 +418,18 @@ Imp_BatchFile_Process( break; } processList = UUcFalse; - + if ('+' == curFileName[0]) { UUtBool retryFindBatchFile = UUcFalse; includeName = curFileName + 1; - + iStripNonFileNameStuff(includeName); Imp_PrintMessage(IMPcMsg_Important, "include"UUmNL); Imp_PrintMessage(IMPcMsg_Important, "\tfileName: %s"UUmNL, includeName); Imp_PrintMessage(IMPcMsg_Important, "*************begin*include*************"UUmNL); abort = UUcFalse; - do + do { error = BFrFileRef_DuplicateAndReplaceName( @@ -437,7 +437,7 @@ Imp_BatchFile_Process( includeName, &sourceFileRef); UUmError_ReturnOnErrorMsgP(error, "Include File \"%s\" was not found", (UUtUns32)curFileName, 0, 0); - + if(BFrFileRef_FileExists(sourceFileRef)) { retryFindBatchFile = UUcFalse; } @@ -477,19 +477,19 @@ Imp_BatchFile_Process( char *ins_txt_suffix = "_ins.txt"; char *bin_suffix = ".bin"; UUtUns16 num_bin_files; - + includeName = curFileName + 1; - + iStripNonFileNameStuff(includeName); Imp_PrintMessage(IMPcMsg_Important, "include multiple"UUmNL); Imp_PrintMessage(IMPcMsg_Important, "\tfileName: %s"UUmNL, includeName); - + error = BFrFileRef_DuplicateAndReplaceName( inBatchFileRef, includeName, &sourceFileRef); UUmError_ReturnOnErrorMsgP(error, "Unable to open directory \"%s\"", (UUtUns32)includeName,0,0); - + error = BFrDirectory_GetFileList( sourceFileRef, NULL, @@ -507,10 +507,10 @@ Imp_BatchFile_Process( &num_bin_files, (dir + numFiles)); UUmError_ReturnOnErrorMsgP(error, "Unable to get file list \"%s\"", (UUtUns32)includeName,0,0); - + numFiles += num_bin_files; processList = UUcTrue; - + BFrFileRef_Dispose(sourceFileRef); } else if ('!' == curFileName[0]) { @@ -521,11 +521,11 @@ Imp_BatchFile_Process( else if ('#' == curFileName[0]) { continue; } - + if (!processList) { iStripNonFileNameStuff(curFileName); - + if (0 == curFileName[0]) { continue; } @@ -538,13 +538,13 @@ Imp_BatchFile_Process( UUmError_ReturnOnErrorMsgP(error, "File \"%s\" was not found", (UUtUns32)curFileName, 0, 0); numFiles = 1; } - + for (i=0; inumNodes, &body->translationStorage); IMPmError_ReturnOnError(error); - + error = TMrConstruction_Instance_NewUnique( TRcTemplate_IndexArray, @@ -1008,7 +1008,7 @@ static UUtError Imp_CreateBody( part_translations->y = 0.f; part_translations->z = 0.f; } - + UUmAssert(curNode->child < UUcMaxUns8); UUmAssert(curNode->sibling < UUcMaxUns8); @@ -1035,7 +1035,7 @@ static UUtError Imp_CreateBody( Imp_EnvFile_Delete(header); *outBody = body; - + return UUcError_None; } @@ -1080,7 +1080,7 @@ static IMPtTextureName *Imp_GetTextureList(BFtFileRef *inMMEFile, UUtUns32 *outC cache_obsolete = cache_mod_time < mme_mod_time; } - + // try reading cache if (!cache_obsolete) { BFtTextFile *cache_read_file; @@ -1120,7 +1120,7 @@ static IMPtTextureName *Imp_GetTextureList(BFtFileRef *inMMEFile, UUtUns32 *outC { MXtHeader *header; UUtUns16 mxtNodeItr; - + error = Imp_ParseEnvFile(inMMEFile, &header); UUmAssert(UUcError_None == error); @@ -1191,7 +1191,7 @@ Imp_ProcessBodyTextures( IMPtTextureName *texture_list; tTextureFlags flags; - + texture_list = Imp_GetTextureList(inMMEFile, &count, &fileModDate); if(TMrConstruction_Instance_CheckExists(TRcTemplate_BodyTextures, inInstanceName)) { @@ -1205,7 +1205,7 @@ Imp_ProcessBodyTextures( count, &bodyTextures); IMPmError_ReturnOnError(error); - + // read the texture names textureFileNames = (char **) UUrMemory_Block_New(sizeof(char *) * count); UUmError_ReturnOnNull(textureFileNames); @@ -1218,15 +1218,15 @@ Imp_ProcessBodyTextures( const char *diffuseTexture; diffuseTexture = texture_list[nodeItr].texture_name; - + textureFileNames[nodeItr] = UUrMemory_Block_New(cMaxNameLength); UUmError_ReturnOnNull(textureFileNames[nodeItr]); - + sprintf(textureFileNames[nodeItr], "%s", diffuseTexture); texturePlaceholderNames[nodeItr] = UUrMemory_Block_New(cMaxNameLength * 2 * sizeof(char)); UUmError_ReturnOnNull(texturePlaceholderNames[nodeItr]); - + UUmAssert(strlen(textureFileNames[nodeItr]) < cMaxNameLength); UUmAssert(strlen(directoryLeafName) < cMaxNameLength); @@ -1234,12 +1234,12 @@ Imp_ProcessBodyTextures( UUrString_Cat(texturePlaceholderNames[nodeItr], "/", cMaxNameLength); UUrString_Cat(texturePlaceholderNames[nodeItr], diffuseTexture, cMaxNameLength); } - + // set the texture flags outside of the loop Imp_ClearTextureFlags(&flags); flags.hasFlagFile = cTextureFlagFile_Yes; flags.flags = M3cTextureFlags_HasMipMap; - + // ==== load in all the textures ==== for(nodeItr = 0; nodeItr < count; nodeItr++) { @@ -1252,7 +1252,7 @@ Imp_ProcessBodyTextures( textureFileNames[nodeItr], &BMPFileRef); IMPmError_ReturnOnError(error); - + error = Imp_ProcessTexture( BMPFileRef, IMPgLowMemory ? 2 : 0, @@ -1261,10 +1261,10 @@ Imp_ProcessBodyTextures( texturePlaceholderNames[nodeItr], IMPcIgnoreTextureRef); IMPmError_ReturnOnError(error); - + UUmAssert(strchr(texturePlaceholderNames[nodeItr], '.') == NULL); bodyTextures->maps[nodeItr] = M3rTextureMap_GetPlaceholder(texturePlaceholderNames[nodeItr]); - + BFrFileRef_Dispose(BMPFileRef); } @@ -1281,11 +1281,11 @@ Imp_ProcessBodyTextures( UUrMemory_Block_Delete(textureFileNames); UUrMemory_Block_Delete(texturePlaceholderNames); UUrMemory_Block_Delete(texture_list); - + return UUcError_None; } -UUtError +UUtError Imp_AddBodyTextures( BFtFileRef* inSourceFile, UUtUns32 inSourceFileModDate, @@ -1299,8 +1299,8 @@ Imp_AddBodyTextures( char* directoryFileName; BFtFileRef* directoryFileRef; - - // build the model file ref + + // build the model file ref error = GRrGroup_GetString(inGroup, "file", &modelFileName); IMPmError_ReturnOnError(error); @@ -1511,7 +1511,7 @@ static UUtError iInsertAnimationArrays( TRtAnimation *ioAnimation, max2oni.m[0][1] = 0.0; max2oni.m[1][1] = 0.0; max2oni.m[2][1] = 1.f; - max2oni.m[3][1] = 0.0; + max2oni.m[3][1] = 0.0; max2oni.m[0][2] = 0.0; max2oni.m[1][2] = -1.f; @@ -1520,7 +1520,7 @@ static UUtError iInsertAnimationArrays( TRtAnimation *ioAnimation, // // step 1 build in max coorindate system - // + // #ifndef LOSSY_ANIM ioAnimation->data = TMrConstruction_Raw_New(rotationDataSize, 4, TRcTemplate_Animation); @@ -1565,7 +1565,7 @@ static UUtError iInsertAnimationArrays( TRtAnimation *ioAnimation, } } - if (ioAnimation->flags & (1 << ONcAnimFlag_ThrowSource)) { + if (ioAnimation->flags & (1 << ONcAnimFlag_ThrowSource)) { ioAnimation->throwInfo = TMrConstruction_Raw_New(sizeof(TRtThrowInfo), 4, TRcTemplate_Animation); UUrMemory_MoveFast(throwInfo, ioAnimation->throwInfo, sizeof(TRtThrowInfo)); } @@ -1601,14 +1601,14 @@ static UUtError iInsertAnimationArrays( TRtAnimation *ioAnimation, srcTime = 0; } else { - srcTime = ioAnimation->duration; + srcTime = ioAnimation->duration; } if (ioAnimation->flags & (1 << ONcAnimFlag_ThrowTarget)) { // this is necessary, because throw target characters have wacky orientation suppress_attack_warnings = UUcTrue; } - + if (ioAnimation->numAttacks > 0) { // work out the direction of this attack anim_direction = (TRtDirection) ioAnimation->moveDirection; @@ -1752,10 +1752,10 @@ static UUtError iInsertAnimationArrays( TRtAnimation *ioAnimation, } MUmQuat_VerifyUnit(&thisQuat); - + iCompressQuaternion( - &thisQuat, - &(((UUtUns8 *)(ioAnimation->data)) [dstIndex]), + &thisQuat, + &(((UUtUns8 *)(ioAnimation->data)) [dstIndex]), ioAnimation->compressionSize); } #endif @@ -1825,8 +1825,8 @@ static UUtError iInsertAnimationArrays( TRtAnimation *ioAnimation, ioAnimation->takeDamages = TMrConstruction_Raw_Write(ioAnimation->takeDamages); ioAnimation->blurs = TMrConstruction_Raw_Write(ioAnimation->blurs); ioAnimation->shortcuts = TMrConstruction_Raw_Write(ioAnimation->shortcuts); - ioAnimation->throwInfo = TMrConstruction_Raw_Write(ioAnimation->throwInfo); - ioAnimation->footsteps = TMrConstruction_Raw_Write(ioAnimation->footsteps); + ioAnimation->throwInfo = TMrConstruction_Raw_Write(ioAnimation->throwInfo); + ioAnimation->footsteps = TMrConstruction_Raw_Write(ioAnimation->footsteps); ioAnimation->particles = TMrConstruction_Raw_Write(ioAnimation->particles); ioAnimation->positionPoints = TMrConstruction_Raw_Write(ioAnimation->positionPoints); ioAnimation->extentInfo.attackExtents = TMrConstruction_Raw_Write(ioAnimation->extentInfo.attackExtents); @@ -1836,13 +1836,13 @@ static UUtError iInsertAnimationArrays( TRtAnimation *ioAnimation, } static UUtError iCreateBlankAnimation( - char *inInstanceName, - UUtUns16 inDuration, + char *inInstanceName, + UUtUns16 inDuration, UUtUns16 inFPS, - UUtUns16 inNumNodes, - UUtUns8 inCompressionSize, - TMtPlaceHolder inSoundPlaceHolders[TRcMaxSounds], - UUtUns16 inSoundFrames[TRcMaxSounds], + UUtUns16 inNumNodes, + UUtUns8 inCompressionSize, + TMtPlaceHolder inSoundPlaceHolders[TRcMaxSounds], + UUtUns16 inSoundFrames[TRcMaxSounds], TRtAttack inAttacks[TRcMaxAttacks], TRtBlur inBlurs[TRcMaxBlurs], @@ -1858,7 +1858,7 @@ static UUtError iCreateBlankAnimation( UUmAssert(inFPS > 0); // create the template with the correctly sized variable array - error = + error = TMrConstruction_Instance_Renew( TRcTemplate_Animation, inInstanceName, @@ -1866,9 +1866,9 @@ static UUtError iCreateBlankAnimation( outAnimation); UUmError_ReturnOnErrorMsgP(error, "failed to renew animation name = %s", (UUtUns32) inInstanceName, 0, 0); - + (*outAnimation)->positions = NULL; - (*outAnimation)->heights = NULL; + (*outAnimation)->heights = NULL; (*outAnimation)->particles = NULL; (*outAnimation)->extentInfo.attackExtents = NULL; (*outAnimation)->positionPoints = NULL; @@ -1982,27 +1982,27 @@ static UUtError Imp_ANMFile_Read( error = BFrTextFile_VerifyNextStr(textFile, "start frame"); IMPmError_ReturnOnError(error); - outHeader->startFrame = BFrTextFile_GetUUtInt32(textFile); + outHeader->startFrame = BFrTextFile_GetUUtInt32(textFile); error = BFrTextFile_VerifyNextStr(textFile, "end frame"); IMPmError_ReturnOnError(error); - outHeader->endFrame = BFrTextFile_GetUUtInt32(textFile); + outHeader->endFrame = BFrTextFile_GetUUtInt32(textFile); error = BFrTextFile_VerifyNextStr(textFile, "ticks per frame"); IMPmError_ReturnOnError(error); - outHeader->ticksPerFrame = BFrTextFile_GetUUtUns32(textFile); + outHeader->ticksPerFrame = BFrTextFile_GetUUtUns32(textFile); error = BFrTextFile_VerifyNextStr(textFile, "start time"); IMPmError_ReturnOnError(error); - outHeader->startTime = BFrTextFile_GetUUtUns32(textFile); + outHeader->startTime = BFrTextFile_GetUUtUns32(textFile); error = BFrTextFile_VerifyNextStr(textFile, "end time"); IMPmError_ReturnOnError(error); - outHeader->endTime = BFrTextFile_GetUUtUns32(textFile); + outHeader->endTime = BFrTextFile_GetUUtUns32(textFile); error = BFrTextFile_VerifyNextStr(textFile, ""); IMPmError_ReturnOnError(error); @@ -2099,7 +2099,7 @@ static UUtError Imp_ANMFile_Read( } // compute euler, make quaternion - if (writeThisNode) + if (writeThisNode) { euler = MUrMatrixToEuler(&matrix, MUcEulerOrderZYZs); quaternion = MUrEulerToQuat(&euler); @@ -2189,7 +2189,7 @@ static UUtError Imp_ANDFile_Write( numQuat = inHeader->numFileFrames * inHeader->numNodes; error = BFrFile_Open(inDataFile, "w", &dstFile); - UUmError_ReturnOnErrorMsgP(error, "failed to open %s w/ write priv", + UUmError_ReturnOnErrorMsgP(error, "failed to open %s w/ write priv", (UUtUns32) BFrFileRef_GetLeafName(inDataFile), 0, 0); error = BFrFile_Write(dstFile, sizeof(stamp), &stamp); @@ -2337,7 +2337,7 @@ static BFtFileRef *iMakeANDFileRef(BFtFileRef *inFileRef) UUmAssertReadPtr(inFileRef, 4); UUrString_Copy(newLeafName, oldLeafName, BFcMaxFileNameLength); - + scan = newLeafName; while((*scan != '.') && (*scan != '\0')) { scan++; } @@ -2359,7 +2359,7 @@ static BFtFileRef *iMakeANDFileRef(BFtFileRef *inFileRef) static UUtBool iSetAttackDirection_From_State(TRtAnimState state, TRtDirection *outDirection) { - switch(state) + switch(state) { case ONcAnimState_Running_Right_Down: case ONcAnimState_Running_Left_Down: @@ -2397,10 +2397,10 @@ static UUtBool iSetAttackDirection_From_State(TRtAnimState state, TRtDirection * static void iSetAttackDirection(UUtUns32 inFlags, UUtUns8 inNumAttacks, TRtAnimType inAnimType, TRtAnimState inFromState, UUtUns8 inNumShortcuts, TRtShortcut *inShortcuts, TRtDirection *outDirection) { - const UUtUns32 aim_mask = - (1 << ONcAnimFlag_Aim_Forward) | - (1 << ONcAnimFlag_Aim_Left) | - (1 << ONcAnimFlag_Aim_Right) | + const UUtUns32 aim_mask = + (1 << ONcAnimFlag_Aim_Forward) | + (1 << ONcAnimFlag_Aim_Left) | + (1 << ONcAnimFlag_Aim_Right) | (1 << ONcAnimFlag_Aim_Backward) | (1 << ONcAnimFlag_Aim_360); UUtUns32 itr; @@ -2453,7 +2453,7 @@ static void iSetAttackDirection(UUtUns32 inFlags, UUtUns8 inNumAttacks, TRtAnimT case ONcAnimType_Sidestep_Left_Punch: *outDirection = TRcDirection_Left; return; - + case ONcAnimType_Kick_Right: case ONcAnimType_Punch_Right: case ONcAnimType_Sidestep_Right_Kick: @@ -2547,7 +2547,7 @@ void iGetTransformedBBox(M3tGeometry *inGeometry, M3tMatrix4x3 *inMatrix, M3tBo outBBox->minPoint.z = UUmMin(outBBox->minPoint.z, local.z); outBBox->maxPoint.x = UUmMax(outBBox->maxPoint.x, local.x); outBBox->maxPoint.y = UUmMax(outBBox->maxPoint.y, local.y); - outBBox->maxPoint.z = UUmMax(outBBox->maxPoint.z, local.z); + outBBox->maxPoint.z = UUmMax(outBBox->maxPoint.z, local.z); } return; @@ -2578,7 +2578,7 @@ void HandleFootstep(TRtFootstepClass *inTypeClass, TRtFootstepClass *inDetectCla iGetTransformedBBox(IMPgLastBiped->geometries[in_foot_index], inMatricies + in_foot_index, &foot_bbox); if (IMPgDebugFootsteps) { - Imp_PrintMessage(IMPcMsg_Important, "%d (%2.2f, %2.2f, %2.2f) (%2.2f, %2.2f, %2.2f)"UUmNL, inFrameItr, + Imp_PrintMessage(IMPcMsg_Important, "%d (%2.2f, %2.2f, %2.2f) (%2.2f, %2.2f, %2.2f)"UUmNL, inFrameItr, foot_bbox.minPoint.x, foot_bbox.minPoint.y, foot_bbox.minPoint.z, foot_bbox.maxPoint.x, foot_bbox.maxPoint.y, foot_bbox.maxPoint.z); } @@ -2765,7 +2765,7 @@ static UUtError iBuildFramePositions(UUtUns32 inFlags, TRtAnimType inAnimType, A this_dist = MUrSqrt(UUmSQR(delta.x) + UUmSQR(delta.y)); this_angle = MUrATan2(delta.x, -delta.y); UUmTrig_Clip(this_angle); - + // update our attack's extent ring attack_ring.max_distance = UUmMax(this_dist, attack_ring.max_distance); attack_ring.max_height = UUmMax(delta.z, attack_ring.max_height); @@ -2817,7 +2817,7 @@ static UUtError iBuildFramePositions(UUtUns32 inFlags, TRtAnimType inAnimType, A */ if ((numAttackFrames > 0) && (inDirection == TRcDirection_None)) { - + if (max_dist == max_dir_dist[0]) { inDirection = computed_direction = TRcDirection_Forwards; @@ -2959,8 +2959,8 @@ static UUtError iBuildFramePositions(UUtUns32 inFlags, TRtAnimType inAnimType, A outExtentInfo->computed_attack_direction = computed_direction; - // build the footsteps - + // build the footsteps + { TRtFootstepClass *footstep_type_class, *footstep_detect_class; TRtFootstepList *footstep_list; @@ -2982,12 +2982,12 @@ static UUtError iBuildFramePositions(UUtUns32 inFlags, TRtAnimType inAnimType, A if (NULL != footstep_detect_class) { UUtBool is_left_foot_ready; UUtBool is_right_foot_ready; - + M3tPoint3D *root_location_this_frame = inPointArray + 0; { M3tBoundingBox_MinMax initial_bbox; - + iGetTransformedBBox(IMPgLastBiped->geometries[ONcLFoot_Index], inMatrixArray + ONcLFoot_Index, &initial_bbox); is_left_foot_ready = (initial_bbox.minPoint.z) >= footstep_detect_class->foostep_initial_clear_threshold; @@ -2996,17 +2996,17 @@ static UUtError iBuildFramePositions(UUtUns32 inFlags, TRtAnimType inAnimType, A } - for (frameItr = 0, matrixPtr = inMatrixArray; frameItr < inHeader->numFileFrames; matrixPtr += inHeader->numNodes, frameItr++) + for (frameItr = 0, matrixPtr = inMatrixArray; frameItr < inHeader->numFileFrames; matrixPtr += inHeader->numNodes, frameItr++) { HandleFootstep(footstep_type_class, footstep_detect_class, &is_left_foot_ready, frameItr, ONcLFoot_Index, TRcFootstep_Left, matrixPtr, inPointArray + frameItr, &footstep_list); HandleFootstep(footstep_type_class, footstep_detect_class, &is_right_foot_ready, frameItr, ONcRFoot_Index, TRcFootstep_Right, matrixPtr, root_location_this_frame, &footstep_list); - } + } } *outFootstepList = footstep_list; } - + return UUcError_None; } @@ -3014,7 +3014,7 @@ static UUtError iBuildFramePositions(UUtUns32 inFlags, TRtAnimType inAnimType, A static UUtError iProcessAnimationFile( - BFtFileRef *inANMFileRef, + BFtFileRef *inANMFileRef, UUtUns32 inFlags, TRtAnimType inAnimType, TRtAnimType inFootstepDetectType, @@ -3059,7 +3059,7 @@ static UUtError iProcessAnimationFile( error = BFrFileRef_GetModTime(inANMFileRef, &ANMTimestamp); UUmError_ReturnOnErrorMsg(error, "failed to get anm file mod time"); - + if (IMPgForceANDRebuild) { // don't even bother looking for the file build_andfile = UUcTrue; @@ -3135,13 +3135,13 @@ static UUtError iMakeAnimationOverlay( // move the data up to where the old frame 0 data was UUrMemory_MoveOverlap( - outQuatArray + outHeader->numNodes, - outQuatArray, - sizeof(M3tQuaternion) * outHeader->numNodes * (outHeader->numFileFrames - 1)); + outQuatArray + outHeader->numNodes, + outQuatArray, + sizeof(M3tQuaternion) * outHeader->numNodes * (outHeader->numFileFrames - 1)); UUrMemory_MoveOverlap( - outPositionArray + 1, - outPositionArray, + outPositionArray + 1, + outPositionArray, sizeof(M3tPoint3D) * (outHeader->numFileFrames - 1)); outHeader->numFileFrames -= 1; @@ -3167,7 +3167,7 @@ static UUtError iMakeAnimationOverlay( usedParts |= 1 << nodeItr; UUmAssert(nodeItr < 32); } - + // subtract off frame 0, node n MUrQuatToMatrix(frame0Quats + nodeItr, &first_rotation_matrix); MUrMatrix_Inverse(&first_rotation_matrix, &first_rotation_matrix); @@ -3177,9 +3177,9 @@ static UUtError iMakeAnimationOverlay( } } } - + UUrMemory_Block_Delete(frame0Quats); - + *outUsedParts = usedParts; return UUcError_None; @@ -3192,14 +3192,14 @@ UUtError Imp_GetAnimState(GRtGroup *inGroup, const char *inName, TRtAnimState *o TRtAnimState state; error = GRrGroup_GetString(inGroup, inName, &stateString); - if (error) { - Imp_PrintWarning("invalid field %s", inName); + if (error) { + Imp_PrintWarning("invalid field %s", inName); return error; } error = iStringToAnimState(stateString, &state); - if (error) { - Imp_PrintWarning("'%s' is an invalid state", stateString); + if (error) { + Imp_PrintWarning("'%s' is an invalid state", stateString); return error; } @@ -3216,13 +3216,13 @@ UUtError Imp_GetAnimType(GRtGroup *inGroup, const char *inName, TRtAnimType *out // find the type of animation this is and the type that follows error = GRrGroup_GetString(inGroup, inName, &typeString); - if (error) { + if (error) { return error; } error = IMPrStringToAnimType(typeString, &type); - if (error) { - Imp_PrintWarning("'%s' is an invalid animType", typeString); + if (error) { + Imp_PrintWarning("'%s' is an invalid animType", typeString); return error; } @@ -3238,13 +3238,13 @@ static UUtError iGetAnimStateQuietly(GRtGroup *inGroup, const char *inName, TRtA TRtAnimState state; error = GRrGroup_GetString(inGroup, inName, &stateString); - if (error) { + if (error) { return UUcError_None; } error = iStringToAnimState(stateString, &state); - if (error) { - Imp_PrintWarning("'%s' is an invalid state", stateString); + if (error) { + Imp_PrintWarning("'%s' is an invalid state", stateString); return error; } @@ -3296,7 +3296,7 @@ static UUtBool iGetShortcut(TRtAnimState inFromState, GRtGroup *inGroup, const c AUrMessageBox(AUcMBType_OK, "ShortcutState %d (%s) is none/invalid!", inNumber, shortcutStateString); return UUcFalse; } - + if (inFromState == outShortcut->state) { AUrMessageBox(AUcMBType_OK, "ShortcutState %d (%s) matches fromState!", inNumber, shortcutStateString); return UUcFalse; @@ -3321,9 +3321,9 @@ static UUtBool iGetShortcut(TRtAnimState inFromState, GRtGroup *inGroup, const c sprintf(varName, "%sLength%d", inPrefix, inNumber+1); error = GRrGroup_GetUns16(inGroup, varName, &(outShortcut->length)); - Imp_PrintMessage(IMPcMsg_Cosmetic, "shortcut %d state %s length %d"UUmNL, - inNumber, - iStateToString(outShortcut->state), + Imp_PrintMessage(IMPcMsg_Cosmetic, "shortcut %d state %s length %d"UUmNL, + inNumber, + iStateToString(outShortcut->state), outShortcut->length); if (UUcError_None != error) { @@ -3357,7 +3357,7 @@ typedef struct tBPMbuild { char *name; UUtUns16 part_index; - + } tBPMbuild; static UUtError @@ -3393,9 +3393,9 @@ Imp_BodyPartMaterials( { "RHand", ONcRHand_Index }, { NULL, 0 } }; - + *outBodyPartMaterials = NULL; - + // create an instance of a body part material template error = TMrConstruction_Instance_NewUnique( @@ -3403,7 +3403,7 @@ Imp_BodyPartMaterials( 0, &body_part_materials); UUmError_ReturnOnErrorMsg(error, "Unable to create body part materials"); - + // get a pointer to the body part materials group error = GRrGroup_GetElement( @@ -3415,29 +3415,29 @@ Imp_BodyPartMaterials( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to find bodyPartMaterials"); } - + // get the elements from the group for (part = body_parts; part->name != NULL; part++) { char *material_name; TMtPlaceHolder material; - + // get the material name for the body part error = GRrGroup_GetString(body_part_group, part->name, &material_name); UUmError_ReturnOnErrorMsg(error, "Unable to get the name of a body part material"); - + error = TMrConstruction_Instance_GetPlaceHolder( MAcTemplate_Material, material_name, &material); UUmError_ReturnOnErrorMsg(error, "Unable to create placeholder for material"); - + body_part_materials->materials[part->part_index] = (MAtMaterial*)material; } - + *outBodyPartMaterials = body_part_materials; - + return UUcError_None; } @@ -3474,9 +3474,9 @@ Imp_BodyPartImpacts( { "RHand", ONcRHand_Index }, { NULL, 0 } }; - + *outBodyPartImpacts = NULL; - + // create an instance of a body part impacts template error = TMrConstruction_Instance_NewUnique( @@ -3484,7 +3484,7 @@ Imp_BodyPartImpacts( 0, &body_part_impacts); UUmError_ReturnOnErrorMsg(error, "Unable to create body part impacts"); - + /* * read the hit impacts */ @@ -3500,27 +3500,27 @@ Imp_BodyPartImpacts( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to find hitImpacts"); } - + // get the elements from the group for (part = body_parts; part->name != NULL; part++) { char *impact_name; TMtPlaceHolder impact; - + // get the impact name for the body part error = GRrGroup_GetString(body_part_group, part->name, &impact_name); UUmError_ReturnOnErrorMsg(error, "Unable to get the name of a body part impact"); - + error = TMrConstruction_Instance_GetPlaceHolder( MAcTemplate_Impact, impact_name, &impact); UUmError_ReturnOnErrorMsg(error, "Unable to create placeholder for impact"); - + body_part_impacts->hit_impacts[part->part_index] = (MAtImpact*)impact; } - + /* * read the blocked impacts */ @@ -3536,27 +3536,27 @@ Imp_BodyPartImpacts( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to find blockedImpacts"); } - + // get the elements from the group for (part = body_parts; part->name != NULL; part++) { char *impact_name; TMtPlaceHolder impact; - + // get the impact name for the body part error = GRrGroup_GetString(body_part_group, part->name, &impact_name); UUmError_ReturnOnErrorMsg(error, "Unable to get the name of a body part impact"); - + error = TMrConstruction_Instance_GetPlaceHolder( MAcTemplate_Impact, impact_name, &impact); UUmError_ReturnOnErrorMsg(error, "Unable to create placeholder for impact"); - + body_part_impacts->blocked_impacts[part->part_index] = (MAtImpact*)impact; } - + /* * read the killed impacts */ @@ -3572,27 +3572,27 @@ Imp_BodyPartImpacts( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to find killedImpacts"); } - + // get the elements from the group for (part = body_parts; part->name != NULL; part++) { char *impact_name; TMtPlaceHolder impact; - + // get the impact name for the body part error = GRrGroup_GetString(body_part_group, part->name, &impact_name); UUmError_ReturnOnErrorMsg(error, "Unable to get the name of a body part impact"); - + error = TMrConstruction_Instance_GetPlaceHolder( MAcTemplate_Impact, impact_name, &impact); UUmError_ReturnOnErrorMsg(error, "Unable to create placeholder for impact"); - + body_part_impacts->killed_impacts[part->part_index] = (MAtImpact*)impact; } - + *outBodyPartImpacts = body_part_impacts; return UUcError_None; @@ -3605,10 +3605,10 @@ iCompareFrameNum( { const TRtSound *sound1; const TRtSound *sound2; - + sound1 = (TRtSound*)inItem1; sound2 = (TRtSound*)inItem2; - + return sound1->frameNum - sound2->frameNum; } @@ -3704,7 +3704,7 @@ iParseAnimationParticles( if (sscanf((char *) element, "%hd", &particle->startFrame) == 0) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "animation particle: start frame must be a number"); } - + // read the particle start frame error = GRrGroup_Array_GetElement(sub_array, cParticleArray_EndFrame, &element_type, &element); IMPmError_ReturnOnError(error); @@ -3718,7 +3718,7 @@ iParseAnimationParticles( particle->pad = 0; } - + return UUcError_None; } @@ -3835,7 +3835,7 @@ Imp_AddAnimation( // sounds TRtSound *new_sounds = NULL; UUtUns32 num_new_sounds = 0; - + // these are storage before we build the arrays we will actually use M3tPoint3D *positionArray = NULL; M3tQuaternion *quatArray = NULL; @@ -3846,7 +3846,7 @@ Imp_AddAnimation( { char *badName; - const char *validNames[] = + const char *validNames[] = { "template", "instance", @@ -3976,7 +3976,7 @@ Imp_AddAnimation( "reverseShortcutFlag8", "reverseShortcutFlags8", "reverseShortcutLength8", - + "damage", "damageBits", "firstDamageFrame", @@ -4025,11 +4025,11 @@ Imp_AddAnimation( "stagger1", "stagger2", - "softPause", - "hardPause", + "softPause", + "hardPause", "pause", - "compression", - "reverseInstance", + "compression", + "reverseInstance", "reverseAnimType", "reverseFromState", "reverseToState", @@ -4075,7 +4075,7 @@ Imp_AddAnimation( UUmError_ReturnOnErrorMsgP(error, "Invalid group string %s", (UUtUns32) badName, 0, 0); } - error = + error = Imp_Common_BuildInstance( inSourceFile, inSourceFileModDate, @@ -4099,10 +4099,10 @@ Imp_AddAnimation( { char *footstep_string; - + error = GRrGroup_GetString(inGroup, "footsteps", &footstep_string); - - + + if (UUcError_None == error) { char *cur_footstep_string; char *strtok_internal; @@ -4111,7 +4111,7 @@ Imp_AddAnimation( forcedFootstepList = UUrMemory_Block_NewClear(sizeof(TRtFootstepList)); - cur_footstep_string = UUrString_Tokenize1(footstep_string, ".", &strtok_internal); + cur_footstep_string = UUrString_Tokenize1(footstep_string, ".", &strtok_internal); while(cur_footstep_string != NULL) { @@ -4159,13 +4159,13 @@ Imp_AddAnimation( } } } - + { char *footstep_string; - + error = GRrGroup_GetString(inGroup, "reverseFootsteps", &footstep_string); - - + + if (UUcError_None == error) { char *cur_footstep_string; char *strtok_internal; @@ -4174,7 +4174,7 @@ Imp_AddAnimation( forcedReverseFootstepList = UUrMemory_Block_NewClear(sizeof(TRtFootstepList)); - cur_footstep_string = UUrString_Tokenize1(footstep_string, ".", &strtok_internal); + cur_footstep_string = UUrString_Tokenize1(footstep_string, ".", &strtok_internal); while(cur_footstep_string != NULL) { @@ -4304,20 +4304,20 @@ Imp_AddAnimation( error = GRrGroup_GetFloat(inGroup, "finalRotation", &finalRotation); if (error) { finalRotation = 0; } - else { - if (3.14f == finalRotation) { - Imp_PrintWarning("finalRotation should be in degrees"); + else { + if (3.14f == finalRotation) { + Imp_PrintWarning("finalRotation should be in degrees"); } - finalRotation *= M3c2Pi / 360.f; + finalRotation *= M3c2Pi / 360.f; } error = GRrGroup_GetString(inGroup, "varients", &varientStr); - if (error) { + if (error) { error = GRrGroup_GetString(inGroup, "varient", &varientStr); if (error) { - Imp_PrintWarning("no varients field"); - return error; + Imp_PrintWarning("no varients field"); + return error; } } @@ -4376,7 +4376,7 @@ Imp_AddAnimation( { UUtMemory_Array *sound_array; TRtSound *sound_array_list; - + sound_array = UUrMemory_Array_New(sizeof(TRtSound), 1, 0, 10); UUmError_ReturnOnNull(sound_array); for (itr = 0; ; itr++) @@ -4384,11 +4384,11 @@ Imp_AddAnimation( char *sound_name; UUtUns16 frame_num; UUtUns32 index; - + sprintf(suffix, "%d", itr + 1); sprintf(varName, "new_sound%s", suffix); error = GRrGroup_GetString(inGroup, varName, &sound_name); - + // for itr 0 try sound as awell as sound1 if ((UUcError_None != error) && (0 == itr)) { sprintf(suffix, ""); @@ -4396,50 +4396,50 @@ Imp_AddAnimation( error = GRrGroup_GetString(inGroup, varName, &sound_name); } if (UUcError_None != error) { break; } - + sprintf(varName, "new_soundFrame%s", suffix); error = GRrGroup_GetUns16(inGroup, varName, &frame_num); UUmError_ReturnOnErrorMsg(error, "invalid soundFrame"); - + // add the new_sound to the sound_array error = UUrMemory_Array_GetNewElement(sound_array, &index, NULL); UUmError_ReturnOnErrorMsg(error, "unable to add new sound to sound array"); - + sound_array_list = (TRtSound*)UUrMemory_Array_GetMemory(sound_array); - + UUrString_Copy(sound_array_list[index].impulseName, sound_name, SScMaxNameLength); sound_array_list[index].frameNum = frame_num; - + // byte swap the frame number UUmSwapLittle_2Byte(&sound_array_list[index].frameNum); } - + // add the sounds to the raw data new_sounds = NULL; num_new_sounds = UUrMemory_Array_GetUsedElems(sound_array); if (num_new_sounds > 0) { sound_array_list = (TRtSound*)UUrMemory_Array_GetMemory(sound_array); - + // sort by frame number qsort(sound_array_list, num_new_sounds, sizeof(TRtSound), iCompareFrameNum); - + // create the raw data new_sounds = TMrConstruction_Raw_New((sizeof(TRtSound) * num_new_sounds), 4, TRcTemplate_Animation); UUmError_ReturnOnNull(new_sounds); - + // copy the sound_array_list into the raw data UUrMemory_MoveFast(sound_array_list, new_sounds, (sizeof(TRtSound) * num_new_sounds)); - + // write the raw data new_sounds = TMrConstruction_Raw_Write(new_sounds); } - + // cleanup UUrMemory_Array_Delete(sound_array); sound_array = NULL; } - + //// direct animations for(itr = 0; itr < TRcMaxDirectAnimations; itr++) { @@ -4459,10 +4459,10 @@ Imp_AddAnimation( if (UUcError_None == error) { error = TMrConstruction_Instance_GetPlaceHolder( - TRcTemplate_Animation, - directAnimationNames[itr], + TRcTemplate_Animation, + directAnimationNames[itr], &(directAnimationPlaceHolder[itr])); - UUmError_ReturnOnErrorMsg(error, "Imp_AddAnimation: could not make an animation placeholder"); + UUmError_ReturnOnErrorMsg(error, "Imp_AddAnimation: could not make an animation placeholder"); } } @@ -4549,7 +4549,7 @@ Imp_AddAnimation( sprintf(varName, "damageBits%s", suffix); error = iGetPartMask(inGroup, varName, &(attacks[numAttacks].damageBits)); - + if (error != UUcError_None) { Imp_PrintWarning("could not find valid %s", varName); return error; @@ -4578,8 +4578,8 @@ Imp_AddAnimation( } else { error = TMrConstruction_Instance_GetPlaceHolder( - SScTemplate_Sound, - hitSoundName, + SScTemplate_Sound, + hitSoundName, &hitSoundPlaceHolder); UUmError_ReturnOnErrorMsg(error, "Imp_AddAnimation: could not make the hit sound placeholder"); @@ -4645,7 +4645,7 @@ Imp_AddAnimation( { float floatBlurAmount; - // clear the blur + // clear the blur blurs[numBlurs].blurParts = 0; blurs[numBlurs].firstBlurFrame = 1; blurs[numBlurs].lastBlurFrame = 0; @@ -4681,7 +4681,7 @@ Imp_AddAnimation( blurs[numBlurs].blurSkip = 1; } - floatBlurAmount = UUmPin(floatBlurAmount, 0.f, 1.f); + floatBlurAmount = UUmPin(floatBlurAmount, 0.f, 1.f); blurs[numBlurs].blurAmount = (UUtUns8) (floatBlurAmount * 255.f); numBlurs++; @@ -4708,7 +4708,7 @@ Imp_AddAnimation( } else { compressionSize = IMPgDefaultCompressionSize; - } + } } // get the actionFrame which may also be called the swapWeaponFrame @@ -4770,7 +4770,7 @@ Imp_AddAnimation( if (error) { continue; } numTakeDamages++; - } + } // animation particles numParticles = 0; @@ -4813,7 +4813,7 @@ Imp_AddAnimation( UUrMemory_Clear(&extentInfo, sizeof(extentInfo)); error = iProcessAnimationFile( - ANMFileRef, + ANMFileRef, flags, animType, footstepDetectType, @@ -4854,7 +4854,7 @@ Imp_AddAnimation( } if (header->numNodes >= TRcMaxParts) { - AUrMessageBox(AUcMBType_OK, "ANMFile %s had %d nodes, %d is the maximum allowed!", + AUrMessageBox(AUcMBType_OK, "ANMFile %s had %d nodes, %d is the maximum allowed!", BFrFileRef_GetLeafName(ANMFileRef), header->numNodes, TRcMaxParts); @@ -4865,10 +4865,10 @@ Imp_AddAnimation( * create the animation templated structures */ - error = iCreateBlankAnimation(inInstanceName, header->duration, fps, header->numNodes, compressionSize, + error = iCreateBlankAnimation(inInstanceName, header->duration, fps, header->numNodes, compressionSize, soundPlaceHolders, soundFrames, attacks, blurs, directAnimationPlaceHolder, &animation); IMPmError_ReturnOnError(error); - + UUmAssertWritePtr(animation, sizeof(*animation)); animation->instanceName = NULL; animation->type = animType; @@ -4901,10 +4901,10 @@ Imp_AddAnimation( UUrString_Copy(animation->attackName, attack_impact_name, ONcCharacterAttackNameLength + 1); if (NULL != reverseName) { - error = iCreateBlankAnimation(reverseName, header->duration, fps, header->numNodes, compressionSize, + error = iCreateBlankAnimation(reverseName, header->duration, fps, header->numNodes, compressionSize, soundPlaceHolders, soundFrames, attacks, blurs, directAnimationPlaceHolder, &reverseAnimation); IMPmError_ReturnOnError(error); - + UUmAssertWritePtr(reverseAnimation, sizeof(*reverseAnimation)); reverseAnimation->instanceName = NULL; reverseAnimation->type = reverseAnimType; @@ -5035,7 +5035,7 @@ Imp_AddAnimation( useFootsteps); UUmError_ReturnOnError(error); } - + if (forcedFootstepList != NULL) { UUrMemory_Block_Delete(forcedFootstepList); } @@ -5045,7 +5045,7 @@ Imp_AddAnimation( iCloseAnimationFile(ANMMappingRef, header, positionArray, quatArray, framePositionArray, automaticFootstepList); BFrFileRef_Dispose(ANMFileRef); - + return UUcError_None; } @@ -5066,17 +5066,17 @@ Imp_AddAnimationCollection( AUtMB_ButtonChoice buttonChoice; char *recursiveLookupString; - + if(TMrConstruction_Instance_CheckExists(TRcTemplate_AnimationCollection, inInstanceName)) { Imp_PrintMessage(IMPcMsg_Important, "animation collection already imported"UUmNL); return UUcError_None; } - + // open our group array error = GRrGroup_GetElement( - inGroup, - "tagList", - &elementType, + inGroup, + "tagList", + &elementType, &animationList); if ((error != UUcError_None) || (elementType != GRcElementType_Array)) @@ -5105,13 +5105,13 @@ Imp_AddAnimationCollection( // check for a recursiveSearch table error = GRrGroup_GetString(inGroup, "lookup", &recursiveLookupString); - + if (UUcError_None == error) { Imp_PrintMessage(IMPcMsg_Cosmetic, "recursive lookup table %s"UUmNL, recursiveLookupString); error = TMrConstruction_Instance_GetPlaceHolder( - TRcTemplate_AnimationCollection, - recursiveLookupString, + TRcTemplate_AnimationCollection, + recursiveLookupString, (TMtPlaceHolder*)&(collection->recursiveLookup)); UUmError_ReturnOnErrorMsg(error, "Imp_AddAnimationCollection: could not make a placeholder"); } @@ -5146,16 +5146,16 @@ Imp_AddAnimationCollection( if (0 == strcmp(instanceTag, "")) { Imp_PrintWarning("animation tags should not be blank"); } - + error = GRrGroup_GetUns16(animListEntryGroup, "weight", &weight); UUmError_ReturnOnErrorMsg(error, "could not find weight"); - + error = TMrConstruction_Instance_GetPlaceHolder( - TRcTemplate_Animation, - instanceTag, + TRcTemplate_Animation, + instanceTag, (TMtPlaceHolder*)&animation); UUmError_ReturnOnErrorMsg(error, "Imp_AddAnimationCollection: could not make a placeholder"); - + collection->entry[itr].animation = animation; collection->entry[itr].weight = weight; collection->entry[itr].virtualFromState = TRcAnimState_None; @@ -5180,7 +5180,7 @@ Imp_AddScreenCollection( GRtElementArray* animationList; AUtMB_ButtonChoice buttonChoice; - + if(TMrConstruction_Instance_CheckExists(TRcTemplate_ScreenCollection, inInstanceName)) { Imp_PrintMessage(IMPcMsg_Important, "screen collection already imported"UUmNL); return UUcError_None; @@ -5188,9 +5188,9 @@ Imp_AddScreenCollection( // open our group array error = GRrGroup_GetElement( - inGroup, - "tagList", - &elementType, + inGroup, + "tagList", + &elementType, &animationList); if ((error != UUcError_None) || (elementType != GRcElementType_Array)) @@ -5237,13 +5237,13 @@ Imp_AddScreenCollection( if (0 == strcmp(instanceTag, "")) { Imp_PrintWarning("aiming screen tags should not be blank"); } - + error = TMrConstruction_Instance_GetPlaceHolder( - TRcTemplate_AimingScreen, - instanceTag, + TRcTemplate_AimingScreen, + instanceTag, (TMtPlaceHolder*)&screen); UUmError_ReturnOnErrorMsg(error, "Imp_AddAnimationCollection: could not make a placeholder"); - + collection->screen[itr] = screen; } @@ -5345,7 +5345,7 @@ IMPiParseCharacterParticleElement( // particle class will be set up at runtime particle.particle_class = NULL; - + // success, copy the particle into the array and increment the number of particles if we have to ioParticles[itr] = particle; if (itr >= *ioNumParticles) { @@ -5436,7 +5436,7 @@ IMPiParseCharacterParticles( inClass->particles->numParticles = num_particles; UUrMemory_MoveFast(&particle_storage, &inClass->particles->particle, num_particles * sizeof(ONtCharacterParticle)); inClass->particles->classes_found = UUcFalse; - + return UUcError_None; } @@ -5527,7 +5527,7 @@ IMPiParseCharacterImpacts( impact->impact_type = MAcInvalidID; impact->modifier_type = ONcIEModType_Any; } - + return UUcError_None; } @@ -5592,7 +5592,7 @@ IMPiParseCharacterAnimationImpacts( Imp_PrintMessage(IMPcMsg_Important, " %s\n", type_ptr->name); } IMPmError_ReturnOnErrorMsg(UUcError_Generic, "character animation impact: unknown impact anim type"); - } + } UUmAssert((type_ptr->type >= 0) && (type_ptr->type < ONcAnimationImpact_Max)); impact = &outImpacts->impact[type_ptr->type]; @@ -5668,7 +5668,7 @@ Imp_AddCharacterClass( Imp_PrintWarning("character class %s has no 'variant' tag in any of its definition files!", inInstanceName); variantName = "unknown"; } - + // model error = GRrGroup_GetString(inGroup, "bodyTag", &bodyTag); UUmError_ReturnOnErrorMsg(error, "could not find bodyTag"); @@ -5686,15 +5686,15 @@ Imp_AddCharacterClass( error = TMrConstruction_Instance_GetPlaceHolder(TRcTemplate_BodyTextures, textureTag, (TMtPlaceHolder*)&(characterClass->textures)); UUmError_ReturnOnErrorMsg(error, "could not find body textures"); - + // body part materials error = Imp_BodyPartMaterials(inGroup, &characterClass->bodyPartMaterials); UUmError_ReturnOnErrorMsg(error, "could not process the body part materials"); - + // body part impacts error = Imp_BodyPartImpacts(inGroup, &characterClass->bodyPartImpacts); UUmError_ReturnOnErrorMsg(error, "could not process the body part impacts"); - + // fight mode duration error = GRrGroup_GetUns32(inGroup, "fightModeDuration", &(characterClass->fightModeDuration)); UUmError_ReturnOnErrorMsg(error, "could not find fightModeDuration"); @@ -5858,7 +5858,7 @@ Imp_AddCharacterClass( error = GRrGroup_GetFloat(inGroup, "jump_forward", &(characterClass->jumpConstants.jumpDistance)); UUmError_ReturnOnErrorMsg(error, "could not find jump forward distance"); - characterClass->jumpConstants.jumpDistanceSquares = + characterClass->jumpConstants.jumpDistanceSquares = (UUtUns8)(characterClass->jumpConstants.jumpDistance / PHcSquareSize); // Cover finding constants @@ -5883,7 +5883,7 @@ Imp_AddCharacterClass( error = GRrGroup_GetFloat(inGroup, "autofreeze_v", &(characterClass->autofreezeConstants.distance_y)); UUmError_ReturnOnErrorMsg(error, "could not find autofreeze V distance"); - // Inventory constants + // Inventory constants error = GRrGroup_GetUns16(inGroup, "inv_hypoTime", &(characterClass->inventoryConstants.hypoTime)); UUmError_ReturnOnErrorMsg(error, "could not find hypo time"); @@ -5907,7 +5907,7 @@ Imp_AddCharacterClass( characterClass->lodConstants.distance_squared[lod_distance_itr] = UUmSQR(characterClass->lodConstants.distance_squared[lod_distance_itr]); } } - + // scale constants error = GRrGroup_GetFloat(inGroup, "scale_low", &(characterClass->scaleLow)); @@ -5926,7 +5926,7 @@ Imp_AddCharacterClass( characterClass->vision.central_distance = UUmMax(characterClass->vision.periph_distance, characterClass->vision.central_distance); } else { characterClass->vision.periph_distance = characterClass->vision.central_distance; - } + } error = GRrGroup_GetFloat(inGroup, "vision_vertical", &(characterClass->vision.vertical_range)); UUmError_ReturnOnError(error); @@ -6136,9 +6136,9 @@ Imp_AddFacingTable( UUtUns16 numAnimStates; GRtElementType elementType; GRtElementArray* facingList; - + buildInstance = !TMrConstruction_Instance_CheckExists(TRcTemplate_FacingTable, inInstanceName); - + if (!buildInstance) { return UUcError_None; @@ -6150,9 +6150,9 @@ Imp_AddFacingTable( // open our group array error = GRrGroup_GetElement( - inGroup, - "facingList", - &elementType, + inGroup, + "facingList", + &elementType, &facingList); if (elementType != GRcElementType_Array) { @@ -6162,7 +6162,7 @@ Imp_AddFacingTable( tableSize = (UUtUns16) GRrGroup_Array_GetLength(facingList); if (GRrGroup_Array_GetLength(facingList) > UUcMaxUns16) { - + } UUmError_ReturnOnErrorMsg(error, "facing list to long"); @@ -6242,12 +6242,12 @@ static UUtError MakeStringArray(GRtGroup *inGroup, UUtBool inBuild, char *inInst UUtUns16 numStrings; GRtElementArray* stringList; - + // open our group array error = GRrGroup_GetElement( - inGroup, - "stringList", - &elementType, + inGroup, + "stringList", + &elementType, &stringList); if (elementType != GRcElementType_Array) { @@ -6328,12 +6328,12 @@ Imp_AddStringList( UUtError error; TMtStringArray *outStrings; UUtBool buildInstance; - - + + buildInstance = !TMrConstruction_Instance_CheckExists(TMcTemplate_StringArray, inInstanceName); if (buildInstance) - { + { error = MakeStringArray(inGroup, UUcTrue, inInstanceName, &outStrings); } @@ -6347,11 +6347,11 @@ static UUtError LoadStringTable(const char *inPath, TMtStringArray **outArray) UUtError error; TMtStringArray *array = NULL; BFtFileRef *fileRef; - + error = BFrFileRef_MakeFromName(inPath, &fileRef); UUmError_ReturnOnErrorMsg(error, "could not open shortcut flags"); - if (!BFrFileRef_FileExists(fileRef)) { + if (!BFrFileRef_FileExists(fileRef)) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "could not open shortcut flags file"); } @@ -6424,7 +6424,7 @@ static UUtError iLoadTables(void) error = LoadStringTable(path, &gStringToBodyFlagTable); UUmError_ReturnOnErrorMsg(error, "could not open body flags"); } - + return UUcError_None; } @@ -6434,7 +6434,7 @@ static UUtError iParamListToVarients(const char *varientStr, UUtUns16 *varients) { UUtError error; UUtUns32 tempVarients; - + UUmAssert(gStringToAnimVarientTable); // should have been loaded by init error = AUrParamListToBitfield(varientStr, gStringToAnimVarientTable, &tempVarients); @@ -6448,7 +6448,7 @@ static UUtError iParamListToVarients(const char *varientStr, UUtUns16 *varients) static UUtError iParamListToAnimFlags(const char *inFlagStr, UUtUns32 *outFlags) { UUtError error; - + UUmAssert(gStringToAnimFlagTable); error = AUrParamListToBitfield(inFlagStr, gStringToAnimFlagTable, outFlags); @@ -6459,7 +6459,7 @@ static UUtError iParamListToAnimFlags(const char *inFlagStr, UUtUns32 *outFlags) static UUtError iParamListToShortcutFlags(const char *inFlagStr, UUtUns32 *outFlags) { UUtError error; - + UUmAssert(gStringToShortcutFlagTable); error = AUrParamListToBitfield(inFlagStr, gStringToShortcutFlagTable, outFlags); @@ -6470,7 +6470,7 @@ static UUtError iParamListToShortcutFlags(const char *inFlagStr, UUtUns32 *outFl static UUtError iParamListToAttackFlags(const char *inFlagStr, UUtUns32 *outFlags) { UUtError error; - + UUmAssert(gStringToAttackFlagTable); error = AUrParamListToBitfield(inFlagStr, gStringToAttackFlagTable, outFlags); @@ -6481,7 +6481,7 @@ static UUtError iParamListToAttackFlags(const char *inFlagStr, UUtUns32 *outFlag static UUtError iParamListToBodyFlags(const char *inFlagStr, UUtUns32 *outFlags) { UUtError error; - + UUmAssert(gStringToAttackFlagTable); error = AUrParamListToBitfield(inFlagStr, gStringToBodyFlagTable, outFlags); @@ -6494,7 +6494,7 @@ UUtError IMPrStringToAnimType(const char *inString, TRtAnimType *result) { UUtError error = UUcError_None; UUtInt16 lookup; - + UUmAssert(gStringToAnimTypeTable); lookup = AUrLookupString(inString, gStringToAnimTypeTable); @@ -6511,7 +6511,7 @@ UUtError IMPrStringToAnimType(const char *inString, TRtAnimType *result) static char *iStateToString(TRtAnimType type) { - + UUmAssert(gStringToAnimStateTable); UUmAssert(type < gStringToAnimStateTable->numStrings); @@ -6523,7 +6523,7 @@ UUtError iStringToAnimState(const char *inString, TRtAnimState *result) { UUtError error = UUcError_None; UUtInt16 lookup; - + UUmAssert(gStringToAnimStateTable); lookup = AUrLookupString(inString, gStringToAnimStateTable); @@ -6541,7 +6541,7 @@ UUtError iStringToAnimState(const char *inString, TRtAnimState *result) static UUtUns16 iNumAnimStates(void) { UUtError error = UUcError_None; - + UUmAssert(gStringToAnimStateTable); return gStringToAnimStateTable->numStrings; @@ -6582,9 +6582,9 @@ Imp_AddAimingScreen( UUtBool buildInstance; char *animationTag; - + buildInstance = !TMrConstruction_Instance_CheckExists(TRcTemplate_AimingScreen, inInstanceName); - + if (!buildInstance) { return UUcError_None; @@ -6738,8 +6738,8 @@ Imp_AddSavedFilm( //newFilm->pad4 = 0; UUrMemory_MoveFast( - filmDataKeys, - newFilm->keys, + filmDataKeys, + newFilm->keys, filmData->numKeys * sizeof(ONtFilmKey)); BFrFile_UnMap(mappingRef); @@ -6794,7 +6794,7 @@ Imp_AddAnimCache( Imp_OpenAnimCache(cacheRef); BFrFileRef_Dispose(cacheRef); - + return UUcError_None; } @@ -6808,30 +6808,30 @@ Imp_AddVariant( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(ONcTemplate_VariantList, inInstanceName); - + if (build_instance) { char *variant_name; char *upgrade_name; char *parent_name; ONtCharacterVariant *variant; - + // get the name of the variant error = GRrGroup_GetString(inGroup, "name", &variant_name); IMPmError_ReturnOnErrorMsg(error, "Unable to get variant name"); - + // get the name of the upgraded variant error = GRrGroup_GetString(inGroup, "upgrade_name", &upgrade_name); if (error != UUcError_None) { upgrade_name = ""; } - + // get the name of the parent error = GRrGroup_GetString(inGroup, "parent", &parent_name); IMPmError_ReturnOnErrorMsg(error, "Unable to get parent name"); - + // build an instance of the variant name list error = TMrConstruction_Instance_Renew( @@ -6840,11 +6840,11 @@ Imp_AddVariant( 0, &variant); IMPmError_ReturnOnErrorMsg(error, "Unable to create dialog data instance"); - + // copy the variant names into the variant UUrString_Copy(variant->name, variant_name, ONcMaxVariantNameLength); UUrString_Copy(variant->upgrade_name, upgrade_name, ONcMaxVariantNameLength); - + // set the parent if (UUrString_Compare_NoCase(parent_name, "none") != 0) { @@ -6861,7 +6861,7 @@ Imp_AddVariant( variant->parent = NULL; } } - + return UUcError_None; } @@ -6875,10 +6875,10 @@ Imp_AddVariantList( UUtError error; UUtBool build_instance; - + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(ONcTemplate_VariantList, inInstanceName); - + if (build_instance) { GRtElementType element_type; @@ -6897,13 +6897,13 @@ Imp_AddVariantList( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get variants array"); } - + num_items = GRrGroup_Array_GetLength(variants_array); if (num_items == 0) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "The variants array is empty"); } - + // build an instance of the variant name list error = TMrConstruction_Instance_Renew( @@ -6912,11 +6912,11 @@ Imp_AddVariantList( num_items, &variant_list); IMPmError_ReturnOnErrorMsg(error, "Unable to create variant list instance"); - + for (i = 0; i < num_items; i++) { char *variant_name; - + // get the ith item from the variants array error = GRrGroup_Array_GetElement( @@ -6925,12 +6925,12 @@ Imp_AddVariantList( &element_type, &variant_name); IMPmError_ReturnOnErrorMsg(error, "unable to get variant name from array"); - + if (element_type != GRcElementType_String) { IMPmError_ReturnOnErrorMsg(error, "variant array item was not a string"); } - + // get a reference to the template error = TMrConstruction_Instance_GetPlaceHolder( @@ -6940,7 +6940,7 @@ Imp_AddVariantList( UUmError_ReturnOnErrorMsg(error, "could not set variant placeholder"); } } - + return UUcError_None; } @@ -6954,10 +6954,10 @@ Imp_Character_Initialize( void) { UUtError error; - + error = iLoadTables(); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Character.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Character.h index 578575a..028f790 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Character.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Character.h @@ -1,13 +1,13 @@ /* FILE: Imp_Character.h - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: Nov 1, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997, 1998 */ @@ -33,7 +33,7 @@ Imp_AddAnimCache( UUtError Imp_AddBiped( BFtFileRef* inSourceFile, - UUtUns32 inSourceFileModDate, + UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); @@ -50,7 +50,7 @@ Imp_AddBody( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + UUtError Imp_AddAnimation( BFtFileRef* inSourceFile, @@ -127,19 +127,19 @@ Imp_AddVariant( UUtUns32 inSourceFileModDate, GRtGroup *inGroup, char *inInstanceName); - + UUtError Imp_AddVariantList( BFtFileRef *inSourceFile, UUtUns32 inSourceFileModDate, GRtGroup *inGroup, char *inInstanceName); - + UUtError Imp_Character_Initialize( void); -void +void Imp_Character_Terminate(void); UUtError Imp_GetAnimState(GRtGroup *inGroup, const char *inName, TRtAnimState *outState); diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Common.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Common.c index a1e7e30..d76a6e2 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Common.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Common.c @@ -51,45 +51,45 @@ Imp_Initialize( { UUtError error; - + /* * Initialize the other managers */ error = TMrRegisterTemplates(); UUmError_ReturnOnError(error); - + error = IMPrEnv_Initialize(); UUmError_ReturnOnError(error); - + error = IMPrModel_Initialize(); UUmError_ReturnOnError(error); - + error = ONrRegisterTemplates(); // register all our oni templates error = M3rRegisterTemplates(); UUmError_ReturnOnError(error); - + error = LIrRegisterTemplates(); UUmError_ReturnOnError(error); - + error = AKrRegisterTemplates(); UUmError_ReturnOnError(error); - + error = TRrRegisterTemplates(); UUmError_ReturnOnError(error); - + error = TSrRegisterTemplates(); UUmError_ReturnOnError(error); - + error = SS2rRegisterTemplates(); UUmError_ReturnOnError(error); - + error = BDrRegisterTemplates(); UUmError_ReturnOnError(error); - + error = WMrRegisterTemplates(); UUmError_ReturnOnError(error); - + error = FXrRegisterTemplates(); UUmError_ReturnOnError(error); @@ -98,16 +98,16 @@ Imp_Initialize( error = IMrInitialize(); UUmError_ReturnOnError(error); - + error = MArMaterials_RegisterTemplates(); UUmError_ReturnOnError(error); - + error = ONrInGameUI_RegisterTemplates(); UUmError_ReturnOnError(error); - + error = OSrRegisterTemplates(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -116,8 +116,8 @@ Imp_Terminate( void) { // close everything - - + + Imp_Character_Terminate(); IMPrEnv_Terminate(); IMPrModel_Terminate(); @@ -134,7 +134,7 @@ Imp_Common_GetFileRefAndModDate( UUtError error; GRtElementType elementType; char* fileName; - + error = GRrGroup_GetElement( inGroup, @@ -145,16 +145,16 @@ Imp_Common_GetFileRefAndModDate( { UUmError_ReturnOnErrorMsgP(UUcError_Generic, "Could not get \"%s\" name string", (UUtUns32)inVariableName, 0, 0); } - + error = BFrFileRef_DuplicateAndReplaceName(inSourceFile, fileName, outFileRef); UUmError_ReturnOnErrorMsgP(error, "Could not find file \"%s\"", (UUtUns32)fileName, 0, 0); - + if(!BFrFileRef_FileExists(*outFileRef)) { Imp_PrintWarning("source file %s could not find data file \"%s\"", BFrFileRef_GetLeafName(inSourceFile), fileName); UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find file"); } - + return UUcError_None; } @@ -170,17 +170,17 @@ Imp_Common_BuildInstance( UUtBool *outBuildInstance) { UUtError error; - + UUtBool buildInstance; - + buildInstance = !TMrConstruction_Instance_CheckExists(inTemplateTag, inInstanceName); - + if (!BFrFileRef_FileExists(inSourceFileRef)) { Imp_PrintWarning("inInstanceName %s, Could not find file %s"UUmNL, inInstanceName, BFrFileRef_GetLeafName(inSourceFileRef)); return UUcError_Generic; } - + error = Imp_Common_GetFileRefAndModDate( inSourceFileRef, @@ -188,11 +188,11 @@ Imp_Common_BuildInstance( "file", outFileRef); UUmError_ReturnOnErrorMsg(error, "Could not get file name"); - + //fprintf(stderr, "data file mod time: %s", ctime((time_t*)&fileModDate)); - + *outBuildInstance = buildInstance; - + return UUcError_None; } @@ -287,7 +287,7 @@ Imp_Common_Scan_Group( UUtError Imp_OpenGroupStack( BFtFileRef *inSourceFileRef, - GRtGroup *ioGroup, + GRtGroup *ioGroup, GRtGroup_Context *inContext, const char *parentVarName) { @@ -295,7 +295,7 @@ UUtError Imp_OpenGroupStack( GRtGroup *curGroup; curGroup = ioGroup; - + while(1) { BFtFileRef *fileRef; @@ -322,9 +322,9 @@ UUtError Imp_OpenGroupStack( NULL, &newGroup); UUmError_ReturnOnError(error); - + BFrFileRef_Dispose(fileRef); - + GRrGroup_SetRecursive(curGroup, newGroup); curGroup = newGroup; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Common.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Common.h index 54107da..bb26c8e 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Common.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Common.h @@ -45,7 +45,7 @@ Imp_Common_Scan_Group( UUtError Imp_OpenGroupStack( BFtFileRef *inSourceFileRef, - GRtGroup *ioGroup, + GRtGroup *ioGroup, GRtGroup_Context *inContext, const char *parentVarName); @@ -77,7 +77,7 @@ UUtError Imp_OpenGroupStack( return error; \ } else { \ UUmError_ReturnOnErrorMsgP(error, msg, p0, p1, p2); \ - } + } #endif void UUcArglist_Call Imp_PrintWarning(const char *format, ...); diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Console.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Console.c index ee30994..1e7e737 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Console.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Console.c @@ -33,7 +33,7 @@ static UUtError IMPiAddConsole( BFtFileRef* inSourceFileRef, GRtGroup* inGroup, char* inInstanceName) { BFtFileRef *file_ref; - UUtError error; + UUtError error; MXtHeader *header; OBJtFurnGeomArray *geom_array; M3tGeometry *screen_geom; @@ -53,7 +53,7 @@ static UUtError IMPiAddConsole( BFtFileRef* inSourceFileRef, GRtGroup* inGroup, M3tVector3D action_point; M3tVector3D action_vector; char *default_basemap; - UUtUns32 gq_flags; + UUtUns32 gq_flags; // find the model name error = GRrGroup_GetElement( inGroup, "model", &elementType, &model_path ); @@ -70,7 +70,7 @@ static UUtError IMPiAddConsole( BFtFileRef* inSourceFileRef, GRtGroup* inGroup, screen_node = -1; screen_geom = NULL; action_marker = NULL; - + error = BFrFileRef_DuplicateAndReplaceName(inSourceFileRef, model_path, &file_ref); IMPmError_ReturnOnError(error); @@ -84,11 +84,11 @@ static UUtError IMPiAddConsole( BFtFileRef* inSourceFileRef, GRtGroup* inGroup, // parse the .env file error = Imp_ParseEnvFile(file_ref, &header); IMPmError_ReturnOnError(error); - + // copy the file name into name UUrString_Copy(name, BFrFileRef_GetLeafName(file_ref), BFcMaxFileNameLength); UUrString_StripExtension(name); - + // calculate the number of geometries, grab the screen node and action marker for (i = 0; i < header->numNodes; i++) { @@ -115,7 +115,7 @@ static UUtError IMPiAddConsole( BFtFileRef* inSourceFileRef, GRtGroup* inGroup, // build the geometry array instance error = TMrConstruction_Instance_NewUnique( OBJcTemplate_FurnGeomArray, num_geoms, &geom_array ); IMPmError_ReturnOnError(error); - + // initialize the geoms and get the flag and light data for (i = 0, geom_index = 0; i < header->numNodes; i++) { @@ -126,37 +126,37 @@ static UUtError IMPiAddConsole( BFtFileRef* inSourceFileRef, GRtGroup* inGroup, geom_array->furn_geom[geom_index].gq_flags = AKcGQ_Flag_None; geom_array->furn_geom[geom_index].geometry = NULL; geom_array->furn_geom[geom_index].ls_data = NULL; - + // get the GQ flags geom_array->furn_geom[geom_index].gq_flags = IMPrEnv_GetNodeFlags(&header->nodes[i]); - + // get the light data IMPrFurniture_GetLightData( &header->nodes[i], i, &geom_array->furn_geom[geom_index]); } } - + for (i = 0, geom_index = 0; i < header->numNodes; i++) { if( i == (UUtUns32) screen_node ) continue; for (m = 0; m < header->nodes[i].numMaterials; m++, geom_index++) { M3tGeometry *geometry; - + // build the geometry instance error = TMrConstruction_Instance_NewUnique( M3cTemplate_Geometry, 0, &geometry ); IMPmError_ReturnOnError(error); - + geometry->animation = NULL; - + // put the tris and quads associated with material m into a geometry Imp_NodeMaterial_To_Geometry_ApplyMatrix(&header->nodes[i], (UUtUns16)m, geometry); - + // grab the texture basemap if( default_basemap ) textureName = default_basemap; else textureName = header->nodes[i].materials[0].maps[MXcMapping_DI].name; - + // grab a placeholder to the texture geometry->baseMap = M3rTextureMap_GetPlaceholder_StripExtension_UpperCase(textureName); UUmAssert(geometry->baseMap); @@ -177,7 +177,7 @@ static UUtError IMPiAddConsole( BFtFileRef* inSourceFileRef, GRtGroup* inGroup, error = Imp_Node_To_Geometry_ApplyMatrix( &header->nodes[screen_node], screen_geom ); UUmError_ReturnOnErrorMsg(error, "failed to build the geometry"); - + // set a place holder for the default texture textureName = header->nodes[screen_node].materials[0].maps[MXcMapping_DI].name; @@ -233,7 +233,7 @@ static UUtError IMPiAddConsole( BFtFileRef* inSourceFileRef, GRtGroup* inGroup, { UUrString_Copy( console->screen_inactive, textureName, BFcMaxFileNameLength ); } - + // active state error = GRrGroup_GetElement( inGroup, "active_screen", &elementType, &textureName ); if(error != UUcError_None || elementType != GRcElementType_String) @@ -263,7 +263,7 @@ static UUtError IMPiAddConsole( BFtFileRef* inSourceFileRef, GRtGroup* inGroup, // delete the header Imp_EnvFile_Delete(header); - + return UUcError_None; } @@ -275,7 +275,7 @@ UUtError Imp_AddConsole( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFileModDa error = IMPiAddConsole( inSourceFileRef, inGroup, inInstanceName ); IMPmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Console.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Console.h index 361be3b..9a13424 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Console.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Console.h @@ -21,4 +21,4 @@ Imp_AddConsole( char* inInstanceName); // ====================================================================== -#endif /* IMP_Trigger_H */ \ No newline at end of file +#endif /* IMP_Trigger_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Cursor.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Cursor.c index faf6fa9..3a0ca3a 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Cursor.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Cursor.c @@ -48,13 +48,13 @@ Imp_AddCursor( UUtUns16 i; DCtCursor *cursor; UUtUns16 temp; - + UUtBool bool_result; UUtBool build_instance; - + UUtUns32 create_date; UUtUns32 compile_date; - + // check to see if the dialogs need to be built bool_result = TMrConstruction_Instance_CheckExists( @@ -64,7 +64,7 @@ Imp_AddCursor( if (bool_result) { compile_date = UUrConvertStrToSecsSince1900(gCursorCompileTime); - + build_instance = (UUtBool)(create_date < inSourceFileModDate || create_date < compile_date); } @@ -72,11 +72,11 @@ Imp_AddCursor( { build_instance = UUcTrue; } - + if (!build_instance) return UUcError_None; // get a pointer to the cursor list array - error = + error = GRrGroup_GetElement( inGroup, "cursor_list", @@ -90,7 +90,7 @@ Imp_AddCursor( // get the number of cursors in the cursor list array num_cursors = (UUtUns16)GRrGroup_Array_GetLength(cursor_list_array); - + // create a new cursor list template error = TMrConstruction_Instance_Renew( @@ -99,7 +99,7 @@ Imp_AddCursor( num_cursors, &cursor); IMPmError_ReturnOnError(error); - + // get the animation rate error = GRrGroup_GetUns16( @@ -110,7 +110,7 @@ Imp_AddCursor( cursor->animation_rate = DCcCursor_DefaultAnimationRate; else cursor->animation_rate = temp; - + // process the cursors for (i = 0; i < num_cursors; i++) { @@ -118,7 +118,7 @@ Imp_AddCursor( BFtFileRef *cursor_file_ref; const char *cursor_name; TMtPlaceHolder cursor_ref; - + // get the cursor filename of cursor_list_array[i] error = GRrGroup_Array_GetElement( @@ -131,7 +131,7 @@ Imp_AddCursor( Imp_PrintWarning("Could not get the cursor file name"); return UUcError_Generic; } - + // create a new file ref using the file name error = BFrFileRef_DuplicateAndReplaceName( @@ -139,24 +139,24 @@ Imp_AddCursor( cursor_file_name, &cursor_file_ref); IMPmError_ReturnOnErrorMsg(error, "cursor file was not found"); - + // set the cursors name cursor_name = BFrFileRef_GetLeafName(cursor_file_ref); - + // process the texture map file error = Imp_ProcessTexture_File( cursor_file_ref, cursor_name, &cursor_ref); - + // save the cursor ref cursor->cursors[i].texture_ref = (void*)cursor_ref; - + // dispose of the file ref BFrFileRef_Dispose(cursor_file_ref); } - + return UUcError_None; } @@ -172,7 +172,7 @@ Imp_AddCursorTypeList( UUtBool bool_result; UUtBool build_instance; - + UUtUns32 create_date; UUtUns32 compile_date; @@ -185,7 +185,7 @@ Imp_AddCursorTypeList( if (bool_result) { compile_date = UUrConvertStrToSecsSince1900(gCursorCompileTime); - + build_instance = (UUtBool)(create_date < inSourceFileModDate || create_date < compile_date); } @@ -193,7 +193,7 @@ Imp_AddCursorTypeList( { build_instance = UUcTrue; } - + // build the cursor type list if necessary if (build_instance) { @@ -205,7 +205,7 @@ Imp_AddCursorTypeList( DCtCursorType cursor_type; char *cursor_name; GRtGroup *pair; - + // get a pointer to the cursor_type_array error = GRrGroup_GetElement( @@ -218,7 +218,7 @@ Imp_AddCursorTypeList( Imp_PrintWarning("Could not get the cursor type array"); return UUcError_Generic; } - + // get the number of pairs in the cursor_type_array num_pairs = (UUtUns16)GRrGroup_Array_GetLength(cursor_type_array); @@ -230,7 +230,7 @@ Imp_AddCursorTypeList( num_pairs, &cursor_type_list); IMPmError_ReturnOnError(error); - + // process the pairs for (i = 0; i < num_pairs; i++) { @@ -246,24 +246,24 @@ Imp_AddCursorTypeList( Imp_PrintWarning("Could not get the cursor pair"); return UUcError_Generic; } - + // get the type of the pair error = GRrGroup_GetUns16(pair, "cursor_type", &cursor_type); IMPmError_ReturnOnError(error); - + cursor_type_list->cursor_type_pair[i].cursor_type = cursor_type; - + // get the name of the pair error = GRrGroup_GetString(pair, "cursor_name", &cursor_name); IMPmError_ReturnOnError(error); - + UUrString_Copy( cursor_type_list->cursor_type_pair[i].cursor_name, cursor_name, DCcMaxCursorNameLength); } } - + return UUcError_None; }*/ @@ -277,9 +277,9 @@ Imp_AddCursorList( { UUtError error; UUtBool build_instance; - + build_instance = !TMrConstruction_Instance_CheckExists(WMcTemplate_CursorList,inInstanceName); - + // build the cursor list if necessary if (build_instance) { @@ -288,7 +288,7 @@ Imp_AddCursorList( UUtUns32 num_elements; UUtUns32 i; WMtCursorList *cursor_list; - + // get the cursor list array error = GRrGroup_GetElement( @@ -301,15 +301,15 @@ Imp_AddCursorList( Imp_PrintWarning("Could not get the cursor list array"); return UUcError_Generic; } - + // get the number of elements in the cursor list array num_elements = GRrGroup_Array_GetLength(cursor_list_array); - + if (num_elements == 0) { return UUcError_None; } - + // create a new cursor type list template error = TMrConstruction_Instance_Renew( @@ -318,14 +318,14 @@ Imp_AddCursorList( num_elements, &cursor_list); IMPmError_ReturnOnError(error); - + for (i = 0; i < num_elements; i++) { GRtGroup *cursor_desc_group; char *cursor_type; char *cursor_partspec_name; TMtPlaceHolder cursor_partspec; - + // get a group from the array error = GRrGroup_Array_GetElement( @@ -338,7 +338,7 @@ Imp_AddCursorList( Imp_PrintWarning("Could not get the cursor desc group"); return UUcError_Generic; } - + // get the cursor type string error = GRrGroup_GetString( @@ -346,7 +346,7 @@ Imp_AddCursorList( "type", &cursor_type); IMPmError_ReturnOnError(error); - + // interpret the cursor type string error = AUrFlags_ParseFromGroupArray( @@ -363,18 +363,18 @@ Imp_AddCursorList( "partspec", &cursor_partspec_name); IMPmError_ReturnOnError(error); - - error = + + error = TMrConstruction_Instance_GetPlaceHolder( PScTemplate_PartSpecification, cursor_partspec_name, &cursor_partspec); IMPmError_ReturnOnErrorMsg(error, "Could not get partspec placeholder"); - + // save the partspec cursor_list->cursors[i].cursor_partspec = (void*)cursor_partspec; } } - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Descriptor.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Descriptor.c index 03b8866..b071a32 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Descriptor.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Descriptor.c @@ -34,16 +34,16 @@ Imp_AddLevelDescriptor( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(ONcTemplate_Level_Descriptor, inInstanceName); - + if (build_instance) { ONtLevel_Descriptor *descriptor; char *level_name; - + // create a template instance error = TMrConstruction_Instance_Renew( @@ -52,12 +52,12 @@ Imp_AddLevelDescriptor( 0, &descriptor); IMPmError_ReturnOnErrorMsg(error, "Could not create a descriptor template"); - + // default initialization // descriptor->default_reverb = SScRP_None; descriptor->level_number = 0; descriptor->level_name[0] = '\0'; - + // get the default reverb /* error = IMPrProcessReverb( @@ -66,7 +66,7 @@ Imp_AddLevelDescriptor( SScRP_None, &descriptor->default_reverb); IMPmError_ReturnOnErrorMsg(error, "Could not process the default reverb");*/ - + // get the level number error = GRrGroup_GetUns16( @@ -74,7 +74,7 @@ Imp_AddLevelDescriptor( "level_number", &descriptor->level_number); IMPmError_ReturnOnErrorMsg(error, "Could not get the descriptor's level number"); - + error = GRrGroup_GetUns16( inGroup, @@ -95,6 +95,6 @@ Imp_AddLevelDescriptor( UUrString_Copy(descriptor->level_name, level_name, ONcMaxLevelName); } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Descriptor.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Descriptor.h index 81e6405..54aa629 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Descriptor.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Descriptor.h @@ -21,4 +21,4 @@ Imp_AddLevelDescriptor( char* inInstanceName); // ====================================================================== -#endif /* IMP_DESCRIPTOR_H */ \ No newline at end of file +#endif /* IMP_DESCRIPTOR_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Dialog.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Dialog.c index 72eb0fe..6b9c57b 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Dialog.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Dialog.c @@ -41,7 +41,7 @@ typedef struct tViewProc // ====================================================================== static char* gDialogCompileTime = __DATE__" "__TIME__; -static AUtFlagElement IMPgDialogFlags[] = +static AUtFlagElement IMPgDialogFlags[] = { { "none", DMcDialogFlag_None }, { "dialog_centered", DMcDialogFlag_Centered }, @@ -49,7 +49,7 @@ static AUtFlagElement IMPgDialogFlags[] = { NULL, 0 } }; -static AUtFlagElement IMPgViewFlags[] = +static AUtFlagElement IMPgViewFlags[] = { { "none", VMcViewFlag_None }, { "view_visible", VMcViewFlag_Visible }, @@ -88,7 +88,7 @@ iProcessControls( UUtUns16 i; // get pointer to control list - error = + error = GRrGroup_GetElement( inGroup, "controlList", @@ -99,7 +99,7 @@ iProcessControls( Imp_PrintWarning("Could not get the control list"); return error; } - + // get the number of controls in the control_list num_controls = (UUtUns16)GRrGroup_Array_GetLength(control_list); @@ -117,7 +117,7 @@ iProcessControls( DMtControl *control; GRtGroup *control_group; char *control_name; - + // get the control element error = GRrGroup_Array_GetElement( @@ -130,7 +130,7 @@ iProcessControls( Imp_PrintWarning("Could not get the control group"); return error; } - + // create an instance of this control error = TMrConstruction_Instance_NewUnique( @@ -149,7 +149,7 @@ iProcessControls( "width", &control->width); IMPmError_ReturnOnError(error); - + // get the height error = GRrGroup_GetUns16( @@ -157,7 +157,7 @@ iProcessControls( "height", &control->height); IMPmError_ReturnOnError(error); - + // get the controls location error = Imp_ProcessLocation(control_group, &control->location); if (error != UUcError_None) @@ -165,7 +165,7 @@ iProcessControls( Imp_PrintWarning("Could not process the control's location"); return error; } - + // get the controls id number error = GRrGroup_GetUns16( @@ -177,7 +177,7 @@ iProcessControls( Imp_PrintWarning("Could not get the controls id number"); return error; } - + // get the controls name error = GRrGroup_GetString( @@ -185,15 +185,15 @@ iProcessControls( "control_name", &control_name); IMPmError_ReturnOnErrorMsg(error, "Cound not get the controls name"); - + // process the control flags error = Imp_ProcessDialogFlags(control_group, IMPgControlFlags, &control->flags); IMPmError_ReturnOnErrorMsg(error, "Error processing the flags."); - + // what type of control are we dealing with if (strncmp(control_name, "button", strlen("button")) == 0) { - error = + error = TMrConstruction_Instance_GetPlaceHolder( DMcTemplate_Control_Button, control_name, @@ -201,7 +201,7 @@ iProcessControls( } else if (strncmp(control_name, "edit", strlen("edit")) == 0) { - error = + error = TMrConstruction_Instance_GetPlaceHolder( DMcTemplate_Control_EditField, control_name, @@ -209,7 +209,7 @@ iProcessControls( } else if (strncmp(control_name, "picture", strlen("picture")) == 0) { - error = + error = TMrConstruction_Instance_GetPlaceHolder( DMcTemplate_Control_Picture, control_name, @@ -217,7 +217,7 @@ iProcessControls( } else if (strncmp(control_name, "text", strlen("text")) == 0) { - error = + error = TMrConstruction_Instance_GetPlaceHolder( DMcTemplate_Control_Text, control_name, @@ -227,17 +227,17 @@ iProcessControls( { error = UUcError_Generic; } - + if (error != UUcError_None) { Imp_PrintWarning("Could not get the control's control_ref"); return error; } - + // set the control inDialog->dialog_controls->controls[i] = control; } - + return UUcError_None; }*/ @@ -257,13 +257,13 @@ Imp_ProcessDialogFlags( GRtElementType element_type; GRtElementArray *flag_array; UUtUns32 flags; - + // init the flags *outFlags = 0; flags = 0; - + // get the flag string - error = + error = GRrGroup_GetElement( inGroup, "flags", @@ -274,7 +274,7 @@ Imp_ProcessDialogFlags( { IMPmError_ReturnOnErrorMsg(error, "Error getting flags"); } - + // process the flags error = AUrFlags_ParseFromGroupArray( @@ -286,10 +286,10 @@ Imp_ProcessDialogFlags( { IMPmError_ReturnOnErrorMsg(error, "Unable to parse the flags."); } - + // set the outgoing string *outFlags = flags; - + return UUcError_None; } @@ -302,11 +302,11 @@ Imp_ProcessLocation( UUtError error; GRtElementType element_type; GRtGroup *location; - + // initialize outLocation outLocation->x = 0; outLocation->y = 0; - + // get the location group error = GRrGroup_GetElement( @@ -323,15 +323,15 @@ Imp_ProcessLocation( Imp_PrintWarning("Could not get location"); return UUcError_Generic; } - + // get the location x error = GRrGroup_GetUns16(location, "x", (UUtUns16*)&outLocation->x); IMPmError_ReturnOnError(error); - + // get the location y error = GRrGroup_GetUns16(location, "y", (UUtUns16*)&outLocation->y); IMPmError_ReturnOnError(error); - + return UUcError_None; } @@ -351,7 +351,7 @@ Imp_ProcessTextures( // get pointer to texture list // it is okay for the list not to exist - error = + error = GRrGroup_GetElement( inGroup, inTextureListName, @@ -359,16 +359,16 @@ Imp_ProcessTextures( &texture_list); if (error != UUcError_None) return UUcError_None; - + if (element_type != GRcElementType_Array) { Imp_PrintWarning("Could not get the texture list"); return UUcError_Generic; } - + // get the number of textures in the texture_list num_textures = (UUtUns16)GRrGroup_Array_GetLength(texture_list); - + // create a new texture list template error = TMrConstruction_Instance_NewUnique( @@ -376,7 +376,7 @@ Imp_ProcessTextures( num_textures, inTextureList); IMPmError_ReturnOnError(error); - + // process the textures for (i = 0; i < num_textures; i++) { @@ -384,9 +384,9 @@ Imp_ProcessTextures( BFtFileRef *texture_file_ref; char *texture_name; TMtPlaceHolder texture_ref; - + // get the name of texture[i] - error = + error = GRrGroup_Array_GetElement( texture_list, i, @@ -397,7 +397,7 @@ Imp_ProcessTextures( Imp_PrintWarning("Could not get the texture file name"); return UUcError_Generic; } - + // create a new file ref using the texture's file name error = BFrFileRef_DuplicateAndReplaceName( @@ -405,21 +405,21 @@ Imp_ProcessTextures( texture_file, &texture_file_ref); IMPmError_ReturnOnErrorMsg(error, "texture file was not found"); - + // set the textures name - texture_name = BFrFileRef_GetLeafName(texture_file_ref); - + texture_name = BFrFileRef_GetLeafName(texture_file_ref); + // process the texture map file error = Imp_ProcessTexture_Big_File(texture_file_ref, texture_name, &texture_ref); IMPmError_ReturnOnErrorMsg(error, "Could not import the texture file."); - + // save the texture ref (*inTextureList)->textures[i].texture_ref = (void*)texture_ref; // dispose of the file ref BFrFileRef_Dispose(texture_file_ref); } - + return UUcError_None; } @@ -440,10 +440,10 @@ Imp_AddView( UUtBool bool_result; UUtBool build_instance; - + UUtUns32 create_date; UUtUns32 compile_date; - + // check to see if the dialogs need to be built bool_result = TMrConstruction_Instance_CheckExists( @@ -453,7 +453,7 @@ Imp_AddView( if (bool_result) { compile_date = UUrConvertStrToSecsSince1900(gDialogCompileTime); - + build_instance = (UUtBool)(create_date < inSourceFileModDate || create_date < compile_date); } @@ -461,7 +461,7 @@ Imp_AddView( { build_instance = UUcTrue; } - + if (build_instance) { UUtUns16 id; @@ -478,7 +478,7 @@ Imp_AddView( TMtPlaceHolder view_data; UUtUns16 i; tViewProc *viewproc; - + // get the id error = GRrGroup_GetUns16( @@ -486,7 +486,7 @@ Imp_AddView( "id", &id); IMPmError_ReturnOnErrorMsg(error, "Unable to get view id"); - + // get the type name error = GRrGroup_GetString( @@ -494,7 +494,7 @@ Imp_AddView( "type", &type_name); IMPmError_ReturnOnErrorMsg(error, "Unable to get view type"); - + // get the flags error = Imp_ProcessDialogFlags( @@ -502,14 +502,14 @@ Imp_AddView( IMPgViewFlags, &flags); IMPmError_ReturnOnErrorMsg(error, "Unable to get view flags"); - + // get the location error = Imp_ProcessLocation( inGroup, &location); IMPmError_ReturnOnErrorMsg(error, "Unable to get view location"); - + // get the width error = GRrGroup_GetInt16( @@ -525,7 +525,7 @@ Imp_AddView( "height", &height); IMPmError_ReturnOnErrorMsg(error, "Unable to get view height"); - + // get the view data view_data = NULL; for (viewproc = IMPgViewProc; @@ -537,7 +537,7 @@ Imp_AddView( viewproc->view_proc(inGroup, &view_data); } } - + // get the views array error = GRrGroup_GetElement( @@ -558,13 +558,13 @@ Imp_AddView( views_array = NULL; } } - + // get the number of elements in the views array if (views_array) num_child_views = (UUtUns16)GRrGroup_Array_GetLength(views_array); else num_child_views = 0; - + // create an view template instance error = TMrConstruction_Instance_Renew( @@ -573,7 +573,7 @@ Imp_AddView( num_child_views, &view); IMPmError_ReturnOnErrorMsg(error, "Could not create a view template"); - + // set the fields of view view->id = id; view->type = type; @@ -582,14 +582,14 @@ Imp_AddView( view->width = width; view->height = height; view->view_data = (TMtPlaceHolder*)view_data; - + // copy the views from the views_array for (i = 0; i < num_child_views; i++) { void *view_description; TMtPlaceHolder view_ref; char *instance_name; - + // get the name of the view error = GRrGroup_Array_GetElement( @@ -598,7 +598,7 @@ Imp_AddView( &element_type, &view_description); IMPmError_ReturnOnErrorMsg(error, "Could not get view ref name"); - + if (element_type == GRcElementType_String) { instance_name = view_description; @@ -612,7 +612,7 @@ Imp_AddView( "instance", &instance_name); IMPmError_ReturnOnErrorMsg(error, "Could not get instance name"); - + // process the group error = Imp_AddView( @@ -624,7 +624,7 @@ Imp_AddView( } // get a place holder for the view - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View, instance_name, @@ -634,7 +634,7 @@ Imp_AddView( view->child_views[i].view_ref = (void*)view_ref; } } - + return UUcError_None; } @@ -650,10 +650,10 @@ Imp_AddDialogData( UUtBool bool_result; UUtBool build_instance; - + UUtUns32 create_date; UUtUns32 compile_date; - + DMtDialogData *dialogdata; // check to see if the dialogs need to be built @@ -665,7 +665,7 @@ Imp_AddDialogData( if (bool_result) { compile_date = UUrConvertStrToSecsSince1900(gDialogCompileTime); - + build_instance = (UUtBool)(create_date < inSourceFileModDate || create_date < compile_date); } @@ -673,7 +673,7 @@ Imp_AddDialogData( { build_instance = UUcTrue; } - + // build the dialogs if necessary if (build_instance) { @@ -685,7 +685,7 @@ Imp_AddDialogData( 0, &dialogdata); IMPmError_ReturnOnErrorMsg(error, "Could not create a dialogdata template"); - + // get the animation rate error = GRrGroup_GetUns16( @@ -705,7 +705,7 @@ Imp_AddDialogData( dialogdata->animation_rate = 0; } } - + // import the background error = Imp_ProcessTextures( @@ -723,9 +723,9 @@ Imp_AddDialogData( &dialogdata->flags); IMPmError_ReturnOnErrorMsg(error, "Unable to get the dialogdata location"); }*/ - + return UUcError_None; -} +} // ---------------------------------------------------------------------- UUtError @@ -739,10 +739,10 @@ Imp_AddDialog( UUtBool bool_result; UUtBool build_instance; - + UUtUns32 create_date; UUtUns32 compile_date; - + DMtDialog *dialog; // check to see if the dialogs need to be built @@ -754,7 +754,7 @@ Imp_AddDialog( if (bool_result) { compile_date = UUrConvertStrToSecsSince1900(gDialogCompileTime); - + build_instance = (UUtBool)(create_date < inSourceFileModDate || create_date < compile_date); } @@ -762,12 +762,12 @@ Imp_AddDialog( { build_instance = UUcTrue; } - + // build the dialogs if necessary if (build_instance) { char *view_name; - + // create a new dialog template error = TMrConstruction_Instance_Renew( @@ -776,7 +776,7 @@ Imp_AddDialog( 0, &dialog); IMPmError_ReturnOnErrorMsg(error, "Could not create a dialog template"); - + // get the name of the view error = GRrGroup_GetString( @@ -784,16 +784,16 @@ Imp_AddDialog( "view", &view_name); IMPmError_ReturnOnErrorMsg(error, "Could not find a view in the dialog ins file"); - + // get a place holder for the view - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View, view_name, (TMtPlaceHolder*)&dialog->view_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get view placeholder for dialog"); } - + return UUcError_None; } @@ -809,7 +809,7 @@ Imp_AddDialogTypeList( UUtBool bool_result; UUtBool build_instance; - + UUtUns32 create_date; UUtUns32 compile_date; @@ -822,7 +822,7 @@ Imp_AddDialogTypeList( if (bool_result) { compile_date = UUrConvertStrToSecsSince1900(gDialogCompileTime); - + build_instance = (UUtBool)(create_date < inSourceFileModDate || create_date < compile_date); } @@ -830,7 +830,7 @@ Imp_AddDialogTypeList( { build_instance = UUcTrue; } - + // build the dialogs if necessary if (build_instance) { @@ -842,7 +842,7 @@ Imp_AddDialogTypeList( DMtDialogType dialog_type; char *dialog_name; GRtGroup *pair; - + // get a pointer to the dialog_type_array error = GRrGroup_GetElement( @@ -855,7 +855,7 @@ Imp_AddDialogTypeList( Imp_PrintWarning("Could not get the dialog type array"); return UUcError_Generic; } - + // get the number of pairs in the dialog_type_array num_pairs = (UUtUns16)GRrGroup_Array_GetLength(dialog_type_array); @@ -867,12 +867,12 @@ Imp_AddDialogTypeList( num_pairs, &dialog_type_list); IMPmError_ReturnOnError(error); - + // process the pairs for (i = 0; i < num_pairs; i++) { UUtUns16 j; - + // get pair[i] error = GRrGroup_Array_GetElement( @@ -885,11 +885,11 @@ Imp_AddDialogTypeList( Imp_PrintWarning("Could not get the pair"); return UUcError_Generic; } - + // get the type of the pair error = GRrGroup_GetUns16(pair, "dialog_type", &dialog_type); IMPmError_ReturnOnError(error); - + // check for duplicates for (j = 0; j < i; j++) { @@ -898,19 +898,19 @@ Imp_AddDialogTypeList( Imp_PrintWarning("WARNING: Two dialogs have the same dialog type."); } } - + dialog_type_list->dialog_type_pair[i].dialog_type = dialog_type; - + // get the name of the pair error = GRrGroup_GetString(pair, "dialog_name", &dialog_name); IMPmError_ReturnOnError(error); - + UUrString_Copy( dialog_type_list->dialog_type_pair[i].dialog_name, dialog_name, DMcMaxDialogNameLength); } } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Dialog.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Dialog.h index 3ccbc97..9a8a930 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Dialog.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Dialog.h @@ -22,33 +22,33 @@ Imp_ProcessDialogFlags( GRtGroup *inGroup, AUtFlagElement *inFlagList, UUtUns16 *outFlags); - + UUtError Imp_ProcessTextures( BFtFileRef* inSourceFile, GRtGroup *inGroup, VMtTextureList **inTextureList, char *inTextureListName); - + UUtError Imp_ProcessLocation( GRtGroup *inGroup, IMtPoint2D *outLocation); - + UUtError Imp_AddView( BFtFileRef* inSourceFile, UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + UUtError Imp_AddDialogData( BFtFileRef* inSourceFile, UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + UUtError Imp_AddDialog( BFtFileRef* inSourceFile, @@ -62,7 +62,7 @@ Imp_AddDialogTypeList( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + // ---------------------------------------------------------------------- UUtError Imp_AddControl_Button( @@ -77,7 +77,7 @@ Imp_AddControl_EditField( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + UUtError Imp_AddControl_Picture( BFtFileRef* inSourceFile, @@ -91,7 +91,7 @@ Imp_AddControl_Tab( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + UUtError Imp_AddControl_Text( BFtFileRef* inSourceFile, @@ -106,7 +106,7 @@ Imp_AddCursor( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + UUtError Imp_AddCursorTypeList( BFtFileRef* inSourceFile, @@ -115,4 +115,4 @@ Imp_AddCursorTypeList( char* inInstanceName); // ====================================================================== -#endif /* IMP_DIALOG_H */ \ No newline at end of file +#endif /* IMP_DIALOG_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogData.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogData.c index 81648db..ada947b 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogData.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogData.c @@ -39,11 +39,11 @@ enum cItemY, cItemWidth, cItemHeight, - + cNumItems, - + cItemFormat = cNumItems, - + cMaxNumItems }; @@ -71,23 +71,23 @@ static AUtFlagElement IMPgWindowStyles[] = { "has_close", WMcWindowStyle_HasClose }, { "has_zoom", WMcWindowStyle_HasZoom }, { "has_flatten", WMcWindowStyle_HasFlatten }, - + // window styles { "window_basic", WMcWindowStyle_Basic }, { "window_standard", WMcWindowStyle_Standard }, - + // dialog styles { "dialog_centered", WMcDialogStyle_Centered }, { "dialog_modal", WMcDialogStyle_Modal }, { "dialog_standard", WMcDialogStyle_Standard }, - + // box styles { "box_has_outline", WMcBoxStyle_HasOutline }, { "box_has_background", WMcBoxStyle_HasBackground }, { "box_has_title", WMcBoxStyle_HasTitle }, { "box_plain", WMcBoxStyle_PlainBox }, { "box_group", WMcBoxStyle_GroupBox }, - + // button styles { "btn_has_background", WMcButtonStyle_HasBackground }, { "btn_has_title", WMcButtonStyle_HasTitle }, @@ -99,16 +99,16 @@ static AUtFlagElement IMPgWindowStyles[] = { "btn_icon_button", WMcButtonStyle_IconButton }, { "btn_toggle_button", WMcButtonStyle_ToggleButton }, { "btn_toggle_icon_button", WMcButtonStyle_ToggleIconButton }, - + // checkbox styles { "cb_has_title", WMcCheckBoxStyle_HasTitle }, { "cb_has_icon", WMcCheckBoxStyle_HasIcon }, { "cb_text_checkbox", WMcCheckBoxStyle_TextCheckBox }, { "cb_icon_checkbox", WMcCheckBoxStyle_IconCheckBox }, - + // editfield styles { "ef_number_only", WMcEditFieldStyle_NumbersOnly }, - + // listbox styles { "lb_has_scrollbar", WMcListBoxStyle_HasScrollbar }, { "lb_sort", WMcListBoxStyle_Sort }, @@ -118,29 +118,29 @@ static AUtFlagElement IMPgWindowStyles[] = { "lb_directory", WMcListBoxStyle_Directory }, { "lb_simple_listbox", WMcListBoxStyle_SimpleListBox }, { "lb_sorted_listbox", WMcListBoxStyle_SortedListBox }, - + // menu styles // menubar styles - + // picture { "pt_scale", WMcPictureStyle_Scale }, { "pt_set_at_runtime", WMcPictureStyle_SetAtRuntime }, - + // popup menu { "pm_no_resize", WMcPopupMenuStyle_NoResize }, { "pm_build_at_runtime", WMcPopupMenuStyle_BuildAtRuntime }, - + // progressbar styles - + // radiobutton styles { "rb_has_title", WMcRadioButtonStyle_HasTitle }, { "rb_has_icon", WMcRadioButtonStyle_HasIcon }, { "rb_text_radiobutton", WMcRadioButtonStyle_TextRadioButton }, { "rb_icon_radiobutton", WMcRadioButtonStyle_IconRadioButton }, - + // scrollbar styles // slider styles - + // text styles { "text_hleft", WMcTextStyle_HLeft }, { "text_hcenter", WMcTextStyle_HCenter }, @@ -152,7 +152,7 @@ static AUtFlagElement IMPgWindowStyles[] = { "text_owner_draw", WMcTextStyle_OwnerDraw }, { "text_basic", WMcTextStyle_Basic }, { "text_standard", WMcTextStyle_Standard }, - + { NULL, 0 } }; @@ -220,7 +220,7 @@ IMPrProcess_FontInfo( { UUtError error; GRtElementType element_type; - + char *font_name; TMtPlaceHolder font_family; void *font_size_data; @@ -229,7 +229,7 @@ IMPrProcess_FontInfo( UUtUns32 font_style; void *font_shade_data; UUtUns32 font_shade; - + if (inData == NULL) { font_name = TScFontFamily_Default; @@ -241,13 +241,13 @@ IMPrProcess_FontInfo( { error = GRrGroup_GetString(inData, "font", &font_name); IMPmError_ReturnOnErrorMsg(error, "Unable to get font name"); - + error = GRrGroup_GetUns32(inData, "font_size", &font_size); IMPmError_ReturnOnErrorMsg(error, "Unable to get font size"); error = GRrGroup_GetElement(inData, "font_style", &element_type, &font_style_data); IMPmError_ReturnOnErrorMsg(error, "Unable to get font style data"); - + error = AUrFlags_ParseFromGroupArray( IMPgFontStyleTypes, @@ -255,10 +255,10 @@ IMPrProcess_FontInfo( font_style_data, &font_style); IMPmError_ReturnOnErrorMsg(error, "Unable to process font style data"); - + error = GRrGroup_GetElement(inData, "font_shade", &element_type, &font_shade_data); IMPmError_ReturnOnErrorMsg(error, "Unable to get font shade"); - + error = AUrFlags_ParseFromGroupArray( IMPgFontShadeTypes, @@ -276,15 +276,15 @@ IMPrProcess_FontInfo( { error = GRrGroup_Array_GetElement(inData, cInfoFont, &element_type, &font_name); IMPmError_ReturnOnErrorMsg(error, "Unable to get font name"); - + error = GRrGroup_Array_GetElement(inData, cInfoSize, &element_type, &font_size_data); IMPmError_ReturnOnErrorMsg(error, "Unable to get font size"); - + sscanf((char*)font_size_data, "%d", &font_size); - + error = GRrGroup_Array_GetElement(inData, cInfoStyle, &element_type, &font_style_data); IMPmError_ReturnOnErrorMsg(error, "Unable to get font size"); - + error = AUrFlags_ParseFromGroupArray( IMPgFontStyleTypes, @@ -292,10 +292,10 @@ IMPrProcess_FontInfo( font_style_data, &font_style); IMPmError_ReturnOnErrorMsg(error, "Unable to process font style data"); - + error = GRrGroup_Array_GetElement(inData, cInfoShade, &element_type, &font_shade_data); IMPmError_ReturnOnErrorMsg(error, "Unable to get font shade"); - + error = AUrFlags_ParseFromGroupArray( IMPgFontShadeTypes, @@ -316,21 +316,21 @@ IMPrProcess_FontInfo( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to process formatting data"); } - + // get a placeholder for the font - error = + error = TMrConstruction_Instance_GetPlaceHolder( TScTemplate_FontFamily, font_name, &font_family); IMPmError_ReturnOnErrorMsg(error, "Could not get partspec placeholder"); - - // save the font info + + // save the font info outFontInfo->font_family = (TStFontFamily*)font_family; outFontInfo->font_size = (UUtUns16)font_size; outFontInfo->font_style = (TStFontStyle)font_style; outFontInfo->font_shade = font_shade; - + return UUcError_None; } @@ -356,24 +356,24 @@ IMPiProcess_Group( GRtElementType element_type; void *format_data; TStFontInfo font_info; - + // get the elements from the item group - + // get the item type error = GRrGroup_GetElement(inItemGroup, "type", &element_type, &type_name); IMPmError_ReturnOnErrorMsg(error, "Unable to get type name"); - + error = AUrFlags_ParseFromGroupArray(IMPgWindowTypes, element_type, type_name, &type); IMPmError_ReturnOnErrorMsg(error, "Unable to process item type"); - + // get the item name error = GRrGroup_GetString(inItemGroup, "name", &name); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog name"); - + // get the item id error = GRrGroup_GetUns16(inItemGroup, "id", &id); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog id"); - + // get the item flags error = GRrGroup_GetElement( @@ -385,7 +385,7 @@ IMPiProcess_Group( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get dialog item flags"); } - + error = AUrFlags_ParseFromGroupArray( IMPgWindowFlags, @@ -393,7 +393,7 @@ IMPiProcess_Group( flags_array, &flags); IMPmError_ReturnOnErrorMsg(error, "Unable to process flags"); - + // get the item styles error = GRrGroup_GetElement( @@ -405,7 +405,7 @@ IMPiProcess_Group( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get dialog item styles"); } - + error = AUrFlags_ParseFromGroupArray( IMPgWindowStyles, @@ -413,23 +413,23 @@ IMPiProcess_Group( styles_array, &style); IMPmError_ReturnOnErrorMsg(error, "Unable to process styles"); - + // get the item X error = GRrGroup_GetInt16(inItemGroup, "x", &x); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog x coordinate"); - + // get the item Y error = GRrGroup_GetInt16(inItemGroup, "y", &y); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog y coordinate"); - + // get the item Width error = GRrGroup_GetInt16(inItemGroup, "width", &width); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog width"); - + // get the item Height error = GRrGroup_GetInt16(inItemGroup, "height", &height); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog height"); - + // get the optional formatting info error = GRrGroup_GetElement(inItemGroup, "formatting", &element_type, &format_data); if (error == GRcError_ElementNotFound) @@ -446,7 +446,7 @@ IMPiProcess_Group( error = IMPrProcess_FontInfo(format_data, element_type, &font_info); IMPmError_ReturnOnErrorMsg(error, "Unable to process the formatting"); } - + // initialize the item UUrString_Copy(ioItemData->title, name, WMcMaxTitleLength); ioItemData->windowtype = (UUtUns16)type; @@ -458,7 +458,7 @@ IMPiProcess_Group( ioItemData->width = width; ioItemData->height = height; ioItemData->font_info = font_info; - + return UUcError_None; } @@ -484,75 +484,75 @@ IMPiProcess_Array( UUtUns32 width; UUtUns32 height; TStFontInfo font_info; - + // get the number of items in the array if ((GRrGroup_Array_GetLength(inItemArray) != cNumItems) && (GRrGroup_Array_GetLength(inItemArray) != cMaxNumItems)) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "The items doesn't have the proper number of fields"); } - + // get the item type error = GRrGroup_Array_GetElement(inItemArray, cItemType, &element_type, &type_name); IMPmError_ReturnOnError(error); - + error = AUrFlags_ParseFromGroupArray(IMPgWindowTypes, element_type, type_name, &type); IMPmError_ReturnOnErrorMsg(error, "Unable to process item type"); - + // get the item name error = GRrGroup_Array_GetElement(inItemArray, cItemName, &element_type, &name); IMPmError_ReturnOnError(error); - + // get the item id error = GRrGroup_Array_GetElement(inItemArray, cItemID, &element_type, &item_data); IMPmError_ReturnOnError(error); - + sscanf((char*)item_data, "%d", &id); - + // get the item flags error = GRrGroup_Array_GetElement(inItemArray, cItemFlags, &element_type, &flags_array); IMPmError_ReturnOnError(error); - + error = AUrFlags_ParseFromGroupArray(IMPgWindowFlags, element_type, flags_array, &flags); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog item flags"); - + // get the item styles error = GRrGroup_Array_GetElement(inItemArray, cItemStyles, &element_type, &styles_array); IMPmError_ReturnOnError(error); - + error = AUrFlags_ParseFromGroupArray(IMPgWindowStyles, element_type, styles_array, &style); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog item styles"); - + // get the item X error = GRrGroup_Array_GetElement(inItemArray, cItemX, &element_type, &item_data); IMPmError_ReturnOnError(error); - + sscanf((char*)item_data, "%d", &x); - + // get the item Y error = GRrGroup_Array_GetElement(inItemArray, cItemY, &element_type, &item_data); IMPmError_ReturnOnError(error); - + sscanf((char*)item_data, "%d", &y); - + // get the item Y error = GRrGroup_Array_GetElement(inItemArray, cItemY, &element_type, &item_data); IMPmError_ReturnOnError(error); - + sscanf((char*)item_data, "%d", &y); - + // get the item width error = GRrGroup_Array_GetElement(inItemArray, cItemWidth, &element_type, &item_data); IMPmError_ReturnOnError(error); - + sscanf((char*)item_data, "%d", &width); - + // get the item height error = GRrGroup_Array_GetElement(inItemArray, cItemHeight, &element_type, &item_data); IMPmError_ReturnOnError(error); - + sscanf((char*)item_data, "%d", &height); - + // get the optional formatting info if (GRrGroup_Array_GetLength(inItemArray) == cMaxNumItems) { @@ -567,7 +567,7 @@ IMPiProcess_Array( error = IMPrProcess_FontInfo(NULL, element_type, &font_info); IMPmError_ReturnOnErrorMsg(error, "Unable to process the formatting"); } - + // initialize the item UUrString_Copy(ioItemData->title, name, WMcMaxTitleLength); ioItemData->windowtype = (UUtUns16)type; @@ -579,7 +579,7 @@ IMPiProcess_Array( ioItemData->width = (UUtInt16)width; ioItemData->height = (UUtInt16)height; ioItemData->font_info = font_info; - + return UUcError_None; } @@ -594,14 +594,14 @@ Imp_AddDialogData( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists( WMcTemplate_DialogData, inInstanceName); - + if (build_instance) { char *name; @@ -619,14 +619,14 @@ Imp_AddDialogData( UUtUns32 num_items; WMtDialogData *dialog_data; UUtUns32 i; - + // get all the elements that will make up a dialog data instance error = GRrGroup_GetString(inGroup, "name", &name); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog name"); - + error = GRrGroup_GetUns16(inGroup, "id", &id); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog id"); - + error = GRrGroup_GetElement( inGroup, @@ -634,7 +634,7 @@ Imp_AddDialogData( &element_type, &flags_array); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog data flags"); - + error = AUrFlags_ParseFromGroupArray( IMPgWindowFlags, @@ -642,7 +642,7 @@ Imp_AddDialogData( flags_array, &flags); IMPmError_ReturnOnErrorMsg(error, "Unable to process button flags"); - + error = GRrGroup_GetElement( inGroup, @@ -650,7 +650,7 @@ Imp_AddDialogData( &element_type, &styles_array); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog data flags"); - + error = AUrFlags_ParseFromGroupArray( IMPgWindowStyles, @@ -658,19 +658,19 @@ Imp_AddDialogData( styles_array, &style); IMPmError_ReturnOnErrorMsg(error, "Unable to process dialog styles"); - + error = GRrGroup_GetInt16(inGroup, "x", &x); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog x coordinate"); error = GRrGroup_GetInt16(inGroup, "y", &y); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog y coordinate"); - + error = GRrGroup_GetInt16(inGroup, "width", &width); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog width"); error = GRrGroup_GetInt16(inGroup, "height", &height); IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog height"); - + error = GRrGroup_GetElement( inGroup, @@ -681,13 +681,13 @@ Imp_AddDialogData( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get dialog items array"); } - + num_items = GRrGroup_Array_GetLength(items_array); if (num_items == 0) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "The dialog items array is empty"); } - + // create the dialog data instance error = TMrConstruction_Instance_Renew( @@ -696,7 +696,7 @@ Imp_AddDialogData( num_items, &dialog_data); IMPmError_ReturnOnErrorMsg(error, "Unable to create dialog data instance"); - + // initialize the dialog_data UUrString_Copy(dialog_data->title, name, WMcMaxTitleLength); dialog_data->id = id; @@ -707,12 +707,12 @@ Imp_AddDialogData( dialog_data->y = y; dialog_data->width = width; dialog_data->height = height; - + // process the items for (i = 0; i < num_items; i++) { void *item_stuff; - + // get the ith item from the items_array error = GRrGroup_Array_GetElement( @@ -721,7 +721,7 @@ Imp_AddDialogData( &element_type, &item_stuff); IMPmError_ReturnOnErrorMsg(error, "unable to get item stuff"); - + if (element_type == GRcElementType_Group) { error = IMPiProcess_Group(item_stuff, &dialog_data->items[i]); @@ -738,6 +738,6 @@ Imp_AddDialogData( } } } - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogData.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogData.h index 66e88b9..8e5eda3 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogData.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogData.h @@ -43,6 +43,6 @@ IMPrProcess_FontInfo( void *inData, GRtElementType inElementType, TStFontInfo *outFontInfo); - + // ====================================================================== -#endif /* IMP_DIALOGDATA_H */ \ No newline at end of file +#endif /* IMP_DIALOGDATA_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogList.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogList.c index 7194495..160ebaa 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogList.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogList.c @@ -34,10 +34,10 @@ Imp_AddDialogList( UUtBool bool_result; UUtBool build_instance; - + UUtUns32 create_date; UUtUns32 compile_date; - + // check to see if the dialogs need to be built bool_result = TMrConstruction_Instance_CheckExists( @@ -47,7 +47,7 @@ Imp_AddDialogList( if (bool_result) { compile_date = UUrConvertStrToSecsSince1900(gDialogListCompileTime); - + build_instance = (UUtBool)(create_date < inSourceFileModDate || create_date < compile_date); } @@ -55,7 +55,7 @@ Imp_AddDialogList( { build_instance = UUcTrue; } - + if (build_instance) { GRtElementType element_type; @@ -63,7 +63,7 @@ Imp_AddDialogList( DMtDialogList *dialog_list; UUtUns16 num_dialogs; UUtUns16 i; - + // get the dialog list array error = GRrGroup_GetElement( @@ -75,10 +75,10 @@ Imp_AddDialogList( { IMPmError_ReturnOnErrorMsg(error, "Unable to get element array"); } - + // get the number of elements in the dialog list num_dialogs = (UUtUns16)GRrGroup_Array_GetLength(dialog_list_array); - + // create an dialog list template instance error = TMrConstruction_Instance_Renew( @@ -87,13 +87,13 @@ Imp_AddDialogList( num_dialogs, &dialog_list); IMPmError_ReturnOnErrorMsg(error, "Could not create a dialog list template"); - + // fill in the dialog list for (i = 0; i < num_dialogs; i++) { char *dialog_name; TMtPlaceHolder dialog_ref; - + // get the name of the dialog instance error = GRrGroup_Array_GetElement( @@ -105,19 +105,19 @@ Imp_AddDialogList( { IMPmError_ReturnOnErrorMsg(error, "Unable to get dialog instance name"); } - + // get a place holder for the dialog - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View, dialog_name, &dialog_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get dialog placeholder"); - + // save the dialog ref dialog_list->dialogs[i].dialog_ref = (void*)dialog_ref; } } - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogList.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogList.h index 07abdc8..457a796 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogList.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_DialogList.h @@ -22,4 +22,4 @@ Imp_AddDialogList( char* inInstanceName); // ====================================================================== -#endif /* IMP_DIALOGLIST_H */ \ No newline at end of file +#endif /* IMP_DIALOGLIST_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Door.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Door.c index 66c0e2b..0a61b7a 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Door.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Door.c @@ -45,7 +45,7 @@ static AUtFlagElement IMPgDoorFlags[] = // ====================================================================== static UUtError IMPiDoor_ImportFurnitureGeometryArray( BFtFileRef* inSourceFileRef, OBJtFurnGeomArray **ioGeomArray ) { - UUtError error; + UUtError error; MXtHeader *header; OBJtFurnGeomArray *geom_array; char name[BFcMaxFileNameLength]; @@ -60,13 +60,13 @@ static UUtError IMPiDoor_ImportFurnitureGeometryArray( BFtFileRef* inSourceFileR // parse the .env file error = Imp_ParseEnvFile(inSourceFileRef, &header); IMPmError_ReturnOnError(error); - + // copy the file name into name UUrString_Copy(name, BFrFileRef_GetLeafName(inSourceFileRef), BFcMaxFileNameLength); UUrString_StripExtension(name); - + num_geoms = 0; - + // calculate the number of geometries, grab the screen node and action marker for( i = 0; i < header->numNodes; i++ ) { @@ -86,32 +86,32 @@ static UUtError IMPiDoor_ImportFurnitureGeometryArray( BFtFileRef* inSourceFileR geom_array->furn_geom[geom_index].gq_flags = AKcGQ_Flag_None; geom_array->furn_geom[geom_index].geometry = NULL; geom_array->furn_geom[geom_index].ls_data = NULL; - + // get the GQ flags geom_array->furn_geom[geom_index].gq_flags = IMPrEnv_GetNodeFlags(&header->nodes[i]); - + // get the light data IMPrFurniture_GetLightData( &header->nodes[i], i, &geom_array->furn_geom[geom_index]); } } - + for (i = 0, geom_index = 0; i < header->numNodes; i++) { for (m = 0; m < header->nodes[i].numMaterials; m++, geom_index++) { M3tGeometry *geometry; - + // build the geometry instance error = TMrConstruction_Instance_NewUnique( M3cTemplate_Geometry, 0, &geometry ); IMPmError_ReturnOnError(error); - + geometry->animation = NULL; - + // put the tris and quads associated with material m into a geometry Imp_NodeMaterial_To_Geometry(&header->nodes[i], (UUtUns16)m, geometry); - + textureName = header->nodes[i].materials[0].maps[MXcMapping_DI].name; - + geometry->baseMap = M3rTextureMap_GetPlaceholder_StripExtension_UpperCase(textureName); UUmAssert(geometry->baseMap); @@ -132,7 +132,7 @@ static UUtError IMPiDoor_ImportFurnitureGeometryArray( BFtFileRef* inSourceFileR static UUtError IMPiAddDoor( BFtFileRef* inSourceFileRef, GRtGroup* inGroup, char* inInstanceName) { BFtFileRef *file_ref; - UUtError error; + UUtError error; OBJtDoorClass *door; GRtElementType elementType; char *model_path, *string; @@ -306,7 +306,7 @@ UUtError Imp_AddDoor( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFileModDate, error = IMPiAddDoor( inSourceFileRef, inGroup, inInstanceName ); IMPmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Door.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Door.h index 42703d5..70b97be 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Door.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Door.h @@ -16,4 +16,4 @@ UUtError Imp_AddDoor(BFtFileRef* inSourceFileRef, UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); // ====================================================================== -#endif \ No newline at end of file +#endif diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2.c index 68a553c..954fb87 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2.c @@ -5,8 +5,8 @@ CREATED: Sept 3, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ @@ -86,21 +86,21 @@ IMPrEnv_LogError( ...) { va_list ap; - + if(IMPgEnv_ErrorFile == NULL) return; IMPgEnv_Errors = UUcTrue; va_start(ap, inMsg); - + vfprintf(IMPgEnv_ErrorFile, inMsg, ap); - + va_end(ap); - + fprintf(IMPgEnv_ErrorFile, ""UUmNL); - + fprintf(IMPgEnv_ErrorFile, "*************************"UUmNL); - - fflush(IMPgEnv_ErrorFile); + + fflush(IMPgEnv_ErrorFile); } @@ -113,18 +113,18 @@ IMPiEnv_BuildData_New( double sizeOfBuildData = sizeof(IMPtEnv_BuildData) / (1024.0 * 1024.0); Imp_PrintMessage( - IMPcMsg_Important, + IMPcMsg_Important, "size of build data is %f megabytes"UUmNL, sizeOfBuildData); - + newBuildData = UUrMemory_Block_New(sizeof(IMPtEnv_BuildData)); - if (newBuildData == NULL) + if (newBuildData == NULL) { Imp_PrintWarning("failed to allocate build data"); return NULL; } - + newBuildData->maxGQs = 0; newBuildData->numGQs = 0; newBuildData->maxBNVs = 0; @@ -133,27 +133,27 @@ IMPiEnv_BuildData_New( newBuildData->numObjects = 0; newBuildData->numEnvParticles = 0; - + newBuildData->numAlphaQuads = 0; - + newBuildData->bnvList = NULL; newBuildData->gqList = NULL; - - + + newBuildData->textureMapArray = NULL; newBuildData->sharedPointArray = NULL; newBuildData->sharedPlaneEquArray = NULL; newBuildData->sharedBNVQuadArray = NULL; - + newBuildData->bspPointArray = NULL; newBuildData->bspQuadArray = NULL; newBuildData->tempMemoryPool = NULL; //newBuildData->rnotData.octTreePointArray = NULL; newBuildData->gqTakenBV = NULL; - + newBuildData->textureMapArray = AUrSharedStringArray_New(); if(newBuildData->textureMapArray == NULL) return NULL; - + newBuildData->sharedPointArray = AUrSharedPointArray_New(); if(newBuildData->sharedPointArray == NULL) return NULL; @@ -165,29 +165,29 @@ IMPiEnv_BuildData_New( newBuildData->sharedTextureCoordArray = AUrSharedTexCoordArray_New(); if(newBuildData->sharedTextureCoordArray == NULL) return NULL; - + newBuildData->bspPointArray = AUrSharedPointArray_New(); if(newBuildData->bspPointArray == NULL) return NULL; newBuildData->bspQuadArray = AUrSharedQuadArray_New(); if(newBuildData->bspQuadArray == NULL) return NULL; - + newBuildData->tempMemoryPool = UUrMemory_Pool_New(1024 * 1024, UUcPool_Growable); if(newBuildData->tempMemoryPool == NULL) return NULL; - + newBuildData->edgeArray = AUrSharedEdgeArray_New(); if(newBuildData->edgeArray == NULL) return NULL; - + newBuildData->debugStringTable = AUrHashTable_New(sizeof(DebugStringHashTableEntry), 1024 * 16, AUrHash_String_Hash, AUrHash_String_IsEqual); if (newBuildData->debugStringTable == NULL) return NULL; newBuildData->debugStringBytes = 0; newBuildData->debugStringBytes = 0; - // gunked object ID list + // gunked object ID list newBuildData->object_tags = UUrMemory_Array_New(sizeof( UUtUns32), sizeof( UUtUns32) * 16, 0, 0 ); newBuildData->object_quads = UUrMemory_Array_New(sizeof( UUtUns32), sizeof( UUtUns32) * 16, 0, 0 ); - + // door frames newBuildData->door_count = 0; newBuildData->door_frame_texture = 0xFFFF; @@ -202,68 +202,68 @@ IMPiEnv_BuildData_Delete( UUmAssert(inBuildData != NULL); IMPrFixedOctTree_Delete(inBuildData); - + if(inBuildData->textureMapArray != NULL) { AUrSharedStringArray_Delete(inBuildData->textureMapArray); } - + if(inBuildData->sharedPointArray != NULL) { AUrSharedPointArray_Delete(inBuildData->sharedPointArray); } - + if(inBuildData->sharedPlaneEquArray != NULL) { AUrSharedPlaneEquArray_Delete(inBuildData->sharedPlaneEquArray); } - + if(inBuildData->sharedBNVQuadArray != NULL) { AUrSharedQuadArray_Delete(inBuildData->sharedBNVQuadArray); } - + if(inBuildData->sharedTextureCoordArray != NULL) { AUrSharedTexCoordArray_Delete(inBuildData->sharedTextureCoordArray); } - + if(inBuildData->bspPointArray != NULL) { AUrSharedPointArray_Delete(inBuildData->bspPointArray); } - + if(inBuildData->bspQuadArray != NULL) { AUrSharedQuadArray_Delete(inBuildData->bspQuadArray); } - + if(inBuildData->tempMemoryPool != NULL) { UUrMemory_Pool_Delete(inBuildData->tempMemoryPool); } - + if(inBuildData->edgeArray != NULL) { AUrSharedEdgeArray_Delete(inBuildData->edgeArray); } - + if(inBuildData->bnvList != NULL) { UUrMemory_Block_Delete(inBuildData->bnvList); } - + if(inBuildData->gqList != NULL) { UUrMemory_Block_Delete(inBuildData->gqList); } - - + + if(inBuildData->gqTakenBV != NULL) { UUrBitVector_Dispose(inBuildData->gqTakenBV); } - + if (inBuildData->debugStringTable != NULL) { AUrHashTable_Delete(inBuildData->debugStringTable); @@ -278,7 +278,7 @@ IMPiEnv_BuildData_Delete( { UUrMemory_Array_Delete(inBuildData->object_quads); } - + UUrMemory_Block_Delete(inBuildData); } @@ -291,7 +291,7 @@ IMPrEnv_Initialize( { IMPmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not create error file"); } - + IMPgEnv_MemoryPool = UUrMemory_Pool_New(50 * 1024 * 1024, UUcPool_Growable); if(IMPgEnv_MemoryPool == NULL) { @@ -318,13 +318,13 @@ IMPrEnv_Add( char* inInstanceName) { UUtError error; - + IMPtEnv_BuildData* buildData; - + UUtBool buildInstance; - + // get the inches per pixel for lightmaps - error = + error = GRrGroup_GetFloat( inGroup, "ipp", @@ -333,7 +333,7 @@ IMPrEnv_Add( { IMPgEnv_InchesPerPixel = 12.0f; } - + // 1. Allocate build data memory buildData = IMPiEnv_BuildData_New(); if(buildData == NULL) @@ -341,7 +341,7 @@ IMPrEnv_Add( IMPmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not allocate build data"); } buildData->environmentGroup = inGroup; - + // 2. Check the exists and mod date if(IMPgConstructing) { @@ -351,32 +351,32 @@ IMPrEnv_Add( { buildInstance = UUcTrue; } - + // create the stats file { char buffer[128]; - + sprintf(buffer, "%s_stats.txt", inInstanceName); - + IMPgEnv_StatsFile = fopen(buffer, "wb"); UUmError_ReturnOnNullMsg(IMPgEnv_StatsFile, "could not create stats folder"); } - + // 4. Parse the data into our internal data structures - error = + error = IMPrEnv_Parse( inSourceFileRef, inGroup, buildData, &buildInstance); IMPmError_ReturnOnError(error); - + if(buildInstance == UUcTrue) { - // 5. Process the data + // 5. Process the data error = IMPrEnv_Process(buildData, inSourceFileRef); IMPmError_ReturnOnError(error); - + if(IMPgConstructing) { // 6. Create the final instance @@ -395,14 +395,14 @@ IMPrEnv_Add( // 7. Delete the internal data structures IMPiEnv_BuildData_Delete(buildData); - + fclose(IMPgEnv_StatsFile); - + if(IMPgEnv_Errors) { Imp_PrintMessage(IMPcMsg_Important, "There are environment issues - please look at enverrors.txt"UUmNL); } - + return UUcError_None; } @@ -416,7 +416,7 @@ static UUtBool IMPiEnvAnim_IsMoving( */ UUtUns16 i; - + for (i=0; imatricies, inNode->matricies+i)) return UUcTrue; @@ -433,7 +433,7 @@ static UUtBool comp_u16(UUtUns16 inA, UUtUns16 inB) } static void AddKeyFrames( - UUtUns16 inFirstFrame, + UUtUns16 inFirstFrame, UUtUns16 inLastFrame, UUtUns16 inSkip, UUtUns16 **ioKeyFrameList, @@ -476,21 +476,21 @@ static void AddKeyFrames( } static UUtError CreateObjAnimKeyFrameList( - const AXtNode *inCurNode, - UUtUns16 inNumFrames, - GRtGroup *inGroup, - UUtUns16 **outKeyFrameList, + const AXtNode *inCurNode, + UUtUns16 inNumFrames, + GRtGroup *inGroup, + UUtUns16 **outKeyFrameList, UUtUns16 *outNumKeyFrames) { UUtError error; char *keyFrameString; UUtUns16 *keyFrameList = NULL; UUtUns16 numKeyFrames; - + // add basic keyframes numKeyFrames = 2; keyFrameList = UUrMemory_Block_Realloc(keyFrameList, sizeof(UUtUns16) * numKeyFrames); - + keyFrameList[0] = 0; keyFrameList[1] = inNumFrames - 1; @@ -552,7 +552,7 @@ static UUtError CreateObjAnimKeyFrameList( // pin key frames to legal range keyFrameStart = UUmPin(keyFrameStart, 0, inNumFrames - 1); keyFrameEnd = UUmPin(keyFrameEnd, 0, inNumFrames - 1); - + // generate frequency for keyframes over this range colon = strpbrk(field, ":"); @@ -597,7 +597,7 @@ IMPrEnvAnim_Add( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName) -{ +{ UUtError error = UUcError_Generic; AXtHeader *header = NULL; BFtFileRef *EVAFileRef = NULL; @@ -634,9 +634,9 @@ IMPrEnvAnim_Add( error = UUcError_Generic; goto exit; } - + error = Imp_ParseEvaFile(EVAFileRef, &header); - + found = UUcFalse; // File parsed, now create the instances @@ -655,10 +655,10 @@ IMPrEnvAnim_Add( UUtUns16 *keyFrameList; error = CreateObjAnimKeyFrameList( - curNode, - header->numFrames, - inGroup, - &keyFrameList, + curNode, + header->numFrames, + inGroup, + &keyFrameList, &numKeyFrames); UUmError_ReturnOnError(error); @@ -692,7 +692,7 @@ IMPrEnvAnim_Add( curNode->matricies, &anim->startMatrix, sizeof(M3tMatrix4x3)); - + MUrMatrix_To_ScaleMatrix(curNode->matricies, &anim->scale); // Parse flags @@ -707,7 +707,7 @@ IMPrEnvAnim_Add( &anim->animFlags); UUmError_ReturnOnError(error); } - + // Parse door open length (for door animations only) error = GRrGroup_GetUns16(inGroup,"openframes",&anim->doorOpenFrames); if (error != UUcError_None) @@ -720,7 +720,7 @@ IMPrEnvAnim_Add( } } - if (!found) + if (!found) { Imp_PrintWarning("could not find %s in %s", inInstanceName, BFrFileRef_GetLeafName(inSourceFile)); error = UUcError_Generic; @@ -737,7 +737,7 @@ IMPrEnvAnim_Add( { BFrFileRef_Dispose(EVAFileRef); } - + return error; } @@ -753,7 +753,7 @@ UUtError Imp_AddQuadMaterial( //GRtElementArray *groupFlags; //GRtElementType groupType; //char *string; - + if (TMrConstruction_Instance_CheckExists(AKcTemplate_GQ_Material, inInstanceName)) { @@ -770,13 +770,13 @@ UUtError Imp_AddQuadMaterial( // Initialize UUrMemory_Clear(material,sizeof(AKtGQMaterial)); - + // Colour error = GRrGroup_GetUns16(inGroup,"damage",&material->damage); UUmError_ReturnOnError(error); error = GRrGroup_GetUns16(inGroup,"effectDelay",&material->effectTime); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -811,4 +811,4 @@ char *Imp_AddDebugString( } return hash_table_entry->raw_string; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2.h index 010394c..31f437b 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2.h @@ -1,12 +1,12 @@ /* FILE: Imp_Environment.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 3, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_CreateInst.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_CreateInst.c index 1248c35..3cd4457 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_CreateInst.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_CreateInst.c @@ -5,8 +5,8 @@ CREATED: Sept 3, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ @@ -72,7 +72,7 @@ static void FixedTree_Loop(float min, float max, float fixed_min, float fixed_ma *out_max = result_max; return; -} +} void IMPrFixedOctTree_Delete(IMPtEnv_BuildData* inBuildData) { @@ -177,12 +177,12 @@ void IMPrFixedOctTree_Create(IMPtEnv_BuildData* inBuildData) } list[count++] = itr; - + inBuildData->fixed_oct_tree_node_count[itr_x][itr_y][itr_z] = count; inBuildData->fixed_oct_tree_node[itr_x][itr_y][itr_z] = list; } } - } + } } for(itr_x = 0; itr_x < IMPcFixedOctTreeNode_Count; itr_x++) @@ -260,12 +260,12 @@ void IMPrFixedOctTree_Test(IMPtEnv_BuildData *inBuildData, float minx, float max for(itr = 0; itr < count; itr++) { AUrDict_TestAndAdd(inBuildData->fixed_oct_tree_temp_list, list[itr]); - } + } } } } - return; + return; } @@ -275,7 +275,7 @@ IMPrEnv_CreateInstance_EnvParticles( UUtUns32 inNumEnvParticles, EPtEnvParticle* inEnvParticles, EPtEnvParticleArray* *outTemplate); - + UUtError IMPrEnv_CreateInstance_EnvParticles( UUtUns32 inNumEnvParticles, @@ -283,25 +283,25 @@ IMPrEnv_CreateInstance_EnvParticles( EPtEnvParticleArray* *outTemplate) { UUtError error; - + if(inNumEnvParticles == 0) { *outTemplate = NULL; return UUcError_None; } - + error = TMrConstruction_Instance_NewUnique( EPcTemplate_EnvParticleArray, inNumEnvParticles, outTemplate); UUmError_ReturnOnError(error); - + UUrMemory_MoveFast( inEnvParticles, (*outTemplate)->particle, inNumEnvParticles * sizeof(EPtEnvParticle)); - + return UUcError_None; } @@ -320,9 +320,9 @@ IMPiEnv_Verify_Pathfinding( for (curIndex=0; curIndexnumGQs; curIndex++) { curGQ = &inBuildData->gqList[curIndex]; - + if (!(curGQ->flags & AKcGQ_Flag_Ghost)) continue; - + if (!curGQ->ghostUsed) { M3tPoint3D *pointArray = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); M3tPoint3D midpoint; @@ -346,17 +346,17 @@ IMPiEnv_Verify_Pathfinding( if (!(bnv->flags & AKcBNV_Flag_Room)) { IMPrEnv_LogError("Warning: BNV %s in file %s is not a room",bnv->objName,bnv->fileName); } - + for (curSideIndex=0; curSideIndexnumSides; curSideIndex++) - { + { adj += bnv->sides[curSideIndex].numAdjacencies; } - + if (!adj && !(bnv->flags & AKcBNV_Flag_NonAI)) { IMPrEnv_LogError("Warning: BNV %s in file %s has no ghost GQs",bnv->objName,bnv->fileName); } } - + if (IMPgBNVDebug) { out = fopen("bnvdebug.txt","wb+"); @@ -380,7 +380,7 @@ IMPiEnv_CreateInstance_CombatProfiles(IMPtEnv_BuildData *inBuildData, AKtEnviron static UUtError IMPiEnv_CreateInstance_TacticalProfiles(IMPtEnv_BuildData *inBuildData, AKtEnvironment *environment) { - // Create the tactical profiles in Akira (obsolete) + // Create the tactical profiles in Akira (obsolete) return UUcError_None; } @@ -392,7 +392,7 @@ IMPiEnv_CreateInstance_Markers(IMPtEnv_BuildData *inBuildData, ONtLevel *level) MXtMarker *marker; ONtMarker *gameMarker; UUtError error; - + // Create marker array error = TMrConstruction_Instance_NewUnique( ONcTemplate_MarkerArray, @@ -420,7 +420,7 @@ IMPiEnv_CreateInstance_Markers(IMPtEnv_BuildData *inBuildData, ONtLevel *level) MUmVector_Decrement(gameMarker->direction,gameMarker->position); MUrNormalize(&gameMarker->direction); } - + return UUcError_None; } @@ -432,18 +432,18 @@ IMPiEnv_CreateInstance_Objects(IMPtEnv_BuildData *inBuildData, ONtLevel *level) OBtObjectSetup *curAkiraObject; UUtError error; AKtEnvironment *environment = level->environment; - + // Create the starting object array in Akira error = TMrConstruction_Instance_NewUnique( OBcTemplate_ObjectArray, inBuildData->numObjects + IMPcDynamicSetups, &level->objectSetupArray); UUmError_ReturnOnError(error); - + for (curIndex=0; curIndex < level->objectSetupArray->numObjects; curIndex++) { curObject = &inBuildData->objectList[curIndex]; curAkiraObject = &level->objectSetupArray->objects[curIndex]; UUrMemory_Clear(curAkiraObject,sizeof(OBtObjectSetup)); - + if (curIndex >= inBuildData->numObjects) continue; // Dynamic obj setups are just cleared // Copy over the basics @@ -458,22 +458,22 @@ IMPiEnv_CreateInstance_Objects(IMPtEnv_BuildData *inBuildData, ONtLevel *level) curAkiraObject->doorGhostIndex = curObject->door_gq; UUrMemory_MoveFast(&curObject->debugOrigMatrix,&curAkiraObject->debugOrigMatrix,sizeof(M3tMatrix4x3)); - + // Store debugging names UUrString_Copy(curAkiraObject->fileName, curObject->fileName, OBcMaxObjectName); UUrString_Copy(curAkiraObject->objName, curObject->objName, OBcMaxObjectName); - + // Create the array of geometry error = TMrConstruction_Instance_NewUnique( M3cTemplate_GeometryArray, curObject->geometry_count, &curAkiraObject->geometry_array ); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); for (i = 0; i < curObject->geometry_count; i++) { curAkiraObject->geometry_array->geometries[i] = curObject->geometry_list[i]; } - + // Create the initial environmental particle array IMPrEnv_CreateInstance_EnvParticles(curObject->numParticles, curObject->particles, &curAkiraObject->particleArray); - } + } return UUcError_None; } @@ -509,7 +509,7 @@ static void iParseFlagFileFlags(BFtFileRef *inFileRef, ONtFlag **outFlags, UUtUn if (error != UUcError_None) { Imp_PrintWarning("failed to open %s", BFrFileRef_GetLeafName(inFileRef)); - + goto exit; } @@ -525,39 +525,39 @@ static void iParseFlagFileFlags(BFtFileRef *inFileRef, ONtFlag **outFlags, UUtUn flagCount = BFrTextFile_GetUUtUns16(textFile); flagList = UUrMemory_Block_NewClear(sizeof(ONtFlag) * flagCount); - if (NULL == flagList) { + if (NULL == flagList) { Imp_PrintWarning("out of memory"); goto exit; } - for(itr = 0; itr < flagCount; itr++) { + for(itr = 0; itr < flagCount; itr++) { ONtFlag *curFlag = flagList + itr; // matrix curLine = BFrTextFile_GetNextStr(textFile); - sscanf(curLine, "%f %f %f %f", - &curFlag->matrix.m[0][0], - &curFlag->matrix.m[1][0], + sscanf(curLine, "%f %f %f %f", + &curFlag->matrix.m[0][0], + &curFlag->matrix.m[1][0], &curFlag->matrix.m[2][0], &curFlag->matrix.m[3][0]); curLine = BFrTextFile_GetNextStr(textFile); - sscanf(curLine, "%f %f %f %f", - &curFlag->matrix.m[0][1], - &curFlag->matrix.m[1][1], + sscanf(curLine, "%f %f %f %f", + &curFlag->matrix.m[0][1], + &curFlag->matrix.m[1][1], &curFlag->matrix.m[2][1], &curFlag->matrix.m[3][1]); curLine = BFrTextFile_GetNextStr(textFile); - sscanf(curLine, "%f %f %f %f", - &curFlag->matrix.m[0][2], - &curFlag->matrix.m[1][2], + sscanf(curLine, "%f %f %f %f", + &curFlag->matrix.m[0][2], + &curFlag->matrix.m[1][2], &curFlag->matrix.m[2][2], &curFlag->matrix.m[3][2]); // translation curLine = BFrTextFile_GetNextStr(textFile); - sscanf(curLine, "%f %f %f", + sscanf(curLine, "%f %f %f", &curFlag->location.x, &curFlag->location.y, &curFlag->location.z); @@ -595,8 +595,8 @@ IMPiEnv_CreateInstance_Flags(BFtFileRef* inSourceFileRef, UUmAssert(NULL == level->flagArray); error = BFrFileRef_DuplicateAndReplaceName( - inSourceFileRef, - "flag_file.txt", + inSourceFileRef, + "flag_file.txt", &flagFileRef); if (UUcError_None != error) { @@ -613,7 +613,7 @@ IMPiEnv_CreateInstance_Flags(BFtFileRef* inSourceFileRef, maxFlags += flagFileCount; } - + BFrFileRef_Dispose(flagFileRef); error = TMrConstruction_Instance_NewUnique( @@ -642,7 +642,7 @@ IMPiEnv_CreateInstance_Flags(BFtFileRef* inSourceFileRef, dstFlag->idNumber = (UUtInt16) srcFlag->idNumber; dstFlag->deleted = UUcFalse; dstFlag->maxFlag = UUcTrue; - + // rotation { M3tPoint3D rotPoint; @@ -666,7 +666,7 @@ IMPiEnv_CreateInstance_Flags(BFtFileRef* inSourceFileRef, UUrMemory_MoveFast(flagFileFlags, level->flagArray->flags + inBuildData->numFlags, sizeof(ONtFlag) * flagFileCount); if (NULL != flagFileFlags) { UUrMemory_Block_Delete(flagFileFlags); } - + return UUcError_None; } @@ -686,8 +686,8 @@ IMPiEnv_CreateInstance_Triggers(BFtFileRef* inSourceFileRef, UUmAssert(NULL == level->triggerArray); error = BFrFileRef_DuplicateAndReplaceName( - inSourceFileRef, - "trigger_file.txt", + inSourceFileRef, + "trigger_file.txt", &triggerFileRef); if (UUcError_None != error) { @@ -704,7 +704,7 @@ IMPiEnv_CreateInstance_Triggers(BFtFileRef* inSourceFileRef, //maxFlags += triggerFileCount; } - + BFrFileRef_Dispose(triggerFileRef); error = TMrConstruction_Instance_NewUnique( @@ -722,7 +722,7 @@ IMPiEnv_CreateInstance_Triggers(BFtFileRef* inSourceFileRef, UUrMemory_MoveFast(triggerFileTriggers, level->triggerArray->triggers, sizeof(ONtFlag) * triggerFileCount); if (NULL != triggerFileTriggers) { UUrMemory_Block_Delete(triggerFileTriggers); } - + return UUcError_None; } @@ -734,76 +734,76 @@ IMPiEnv_CreateInstance_OctTree( { UUtError error; AKtOctTree* octTree; - - error = + + error = TMrConstruction_Instance_NewUnique( AKcTemplate_OctTree, 0, &octTree); UUmError_ReturnOnError(error); - + *outOctTree = octTree; - - error = + + error = TMrConstruction_Instance_NewUnique( AKcTemplate_OctTree_InteriorNodeArray, inOTData->nextInteriorNodeIndex, &octTree->interiorNodeArray); UUmError_ReturnOnError(error); - - error = + + error = TMrConstruction_Instance_NewUnique( AKcTemplate_OctTree_LeafNodeArray, inOTData->nextLeafNodeIndex, &octTree->leafNodeArray); UUmError_ReturnOnError(error); - - error = + + error = TMrConstruction_Instance_NewUnique( AKcTemplate_QuadTree_NodeArray, inOTData->nextQTNodeIndex, &octTree->qtNodeArray); UUmError_ReturnOnError(error); - - error = + + error = TMrConstruction_Instance_NewUnique( TMcTemplate_IndexArray, inOTData->nextGQIndex, &octTree->gqIndices); UUmError_ReturnOnError(error); - - error = + + error = TMrConstruction_Instance_NewUnique( TMcTemplate_IndexArray, inOTData->nextBNVIndex, &octTree->bnvIndices); UUmError_ReturnOnError(error); - + UUrMemory_MoveFast( inOTData->interiorNodes, octTree->interiorNodeArray->nodes, inOTData->nextInteriorNodeIndex * sizeof(AKtOctTree_InteriorNode)); - + UUrMemory_MoveFast( inOTData->leafNodes, octTree->leafNodeArray->nodes, inOTData->nextLeafNodeIndex * sizeof(AKtOctTree_LeafNode)); - + UUrMemory_MoveFast( inOTData->qtNodes, octTree->qtNodeArray->nodes, inOTData->nextQTNodeIndex * sizeof(AKtQuadTree_Node)); - + UUrMemory_MoveFast( inOTData->gqIndexArray, octTree->gqIndices->indices, inOTData->nextGQIndex * sizeof(UUtUns32)); - + UUrMemory_MoveFast( inOTData->bnv_index_array, octTree->bnvIndices->indices, inOTData->nextBNVIndex * sizeof(UUtUns32)); - + return UUcError_None; } @@ -828,21 +828,21 @@ IMPiEnv_CreateInstance_GQArray( UUtUns32 numTransparent; UUtUns32 numLightVolume; - error = + error = TMrConstruction_Instance_NewUnique( AKcTemplate_GQ_General, inBuildData->numGQs, &environment->gqGeneralArray); IMPmError_ReturnOnErrorMsg(error, "Could not create general gunk quad array"); - - error = + + error = TMrConstruction_Instance_NewUnique( AKcTemplate_GQ_Render, inBuildData->numGQs, &environment->gqRenderArray); IMPmError_ReturnOnErrorMsg(error, "Could not create render gunk quad array"); - - error = + + error = TMrConstruction_Instance_NewUnique( AKcTemplate_GQ_Collision, inBuildData->numGQs, @@ -850,7 +850,7 @@ IMPiEnv_CreateInstance_GQArray( IMPmError_ReturnOnErrorMsg(error, "Could not create collision gunk quad array"); if (IMPgEnvironmentDebug) { - error = + error = TMrConstruction_Instance_NewUnique( AKcTemplate_GQ_Debug, inBuildData->numGQs, @@ -859,18 +859,18 @@ IMPiEnv_CreateInstance_GQArray( } else { environment->gqDebugArray = NULL; } - + fprintf(IMPgEnv_StatsFile, "num gqs: %d"UUmNL, inBuildData->numGQs); - + UUmAssertReadPtr(environment->gqGeneralArray->gqGeneral, sizeof(AKtGQ_General) * inBuildData->numGQs); UUmAssertReadPtr(environment->gqRenderArray->gqRender, sizeof(AKtGQ_Render) * inBuildData->numGQs); UUmAssertReadPtr(environment->gqCollisionArray->gqCollision, sizeof(AKtGQ_Collision) * inBuildData->numGQs); if (IMPgEnvironmentDebug) { UUmAssertReadPtr(environment->gqDebugArray->gqDebug, sizeof(AKtGQ_Debug) * inBuildData->numGQs); } - + UUrMemory_Block_VerifyList(); - + // copy the GQs and generate statistics numTris = 0; numVisIgnored = 0; @@ -891,7 +891,7 @@ IMPiEnv_CreateInstance_GQArray( for(curGQIndex = 0; curGQIndex < inBuildData->numGQs; curGQIndex++) { if((curGQIndex % 500) == 0) Imp_PrintMessage(IMPcMsg_Important, "."); - + curAkiraGQGeneral->m3Quad.vertexIndices.indices[0] = curGQ->visibleQuad.indices[0]; curAkiraGQGeneral->m3Quad.vertexIndices.indices[1] = curGQ->visibleQuad.indices[1]; curAkiraGQGeneral->m3Quad.vertexIndices.indices[2] = curGQ->visibleQuad.indices[2]; @@ -901,7 +901,7 @@ IMPiEnv_CreateInstance_GQArray( curAkiraGQGeneral->m3Quad.baseUVIndices.indices[1] = curGQ->baseMapIndices.indices[1]; curAkiraGQGeneral->m3Quad.baseUVIndices.indices[2] = curGQ->baseMapIndices.indices[2]; curAkiraGQGeneral->m3Quad.baseUVIndices.indices[3] = curGQ->baseMapIndices.indices[3]; - + if (IMPrLM_DontProcessGQ(curGQ) || (!IMPgLightmaps)) { UUtUns32 default_vertex_lighting = (IMPgGreen) ? IMPcEnv_DefaultVertexLighting_Green : IMPcEnv_DefaultVertexLighting_Normal; @@ -917,26 +917,26 @@ IMPiEnv_CreateInstance_GQArray( curAkiraGQGeneral->m3Quad.shades[2] = curGQ->shade[2]; curAkiraGQGeneral->m3Quad.shades[3] = curGQ->shade[3]; } - + /* curAkiraGQRender->adjGQIndices[0] = curGQ->adjGQIndices[0]; curAkiraGQRender->adjGQIndices[1] = curGQ->adjGQIndices[1]; curAkiraGQRender->adjGQIndices[2] = curGQ->adjGQIndices[2]; curAkiraGQRender->adjGQIndices[3] = curGQ->adjGQIndices[3];*/ - curAkiraGQCollision->bBox = curGQ->bBox; + curAkiraGQCollision->bBox = curGQ->bBox; curAkiraGQGeneral->flags = curGQ->flags; curAkiraGQGeneral->object_tag = curGQ->object_tag; curAkiraGQCollision->planeEquIndex = curGQ->planeEquIndex; curAkiraGQRender->textureMapIndex = curGQ->textureMapIndex; curAkiraGQGeneral->flags |= (curGQ->projection << AKcGQ_Flag_Projection_Shift); //curAkiraGQ->patchArea = curGQ->patchArea; - + if (IMPgEnvironmentDebug) { // Debugging goo curAkiraGQDebug->object_name = Imp_AddDebugString(inBuildData, curGQ->objName); curAkiraGQDebug->file_name = Imp_AddDebugString(inBuildData, curGQ->fileName); } - + if( curGQ->object_tag != 0xFFFFFFFF ) { IMPrEnv_Add_ObjectTag( inBuildData, curGQ->object_tag, curGQIndex ); @@ -950,25 +950,25 @@ IMPiEnv_CreateInstance_GQArray( { numTransparent++; } - + if(curAkiraGQGeneral->flags & AKcGQ_Flag_No_Occlusion) { numVisIgnored++; } - + if(curAkiraGQGeneral->flags & AKcGQ_Flag_2Sided) { num2Sided++; } - + if(curAkiraGQGeneral->flags & AKcGQ_Flag_Ghost) { numGhost++; } - + if(curAkiraGQGeneral->flags & AKcGQ_Flag_Door) { - numDoor++; + numDoor++; } curGQ++; @@ -1012,7 +1012,7 @@ static UUtError IMPiEnv_CreateObjectTagArray( UUtUns32* gq_array; UUmAssert( inBuildData && inBuildData->object_tags ); - + new_array = UUrMemory_Array_New( sizeof(UUtUns32), sizeof(UUtUns32) * 16, 0, 0 ); new_tags = (UUtUns32*) UUrMemory_Array_GetMemory( new_array ); unique_tags = 0; @@ -1023,7 +1023,7 @@ static UUtError IMPiEnv_CreateObjectTagArray( if( !tag_count ) return UUcError_None; - + tag_array = (UUtUns32*) UUrMemory_Array_GetMemory( inBuildData->object_tags ); gq_array = (UUtUns32*) UUrMemory_Array_GetMemory( inBuildData->object_quads ); @@ -1042,7 +1042,7 @@ static UUtError IMPiEnv_CreateObjectTagArray( if( !found ) { error = UUrMemory_Array_GetNewElement( new_array, &new_index, NULL ); - + UUmAssert( error == UUcError_None ); new_tags = (UUtUns32*) UUrMemory_Array_GetMemory( new_array ); @@ -1052,7 +1052,7 @@ static UUtError IMPiEnv_CreateObjectTagArray( unique_tags++; } } - + if( !unique_tags ) return UUcError_None; @@ -1071,7 +1071,7 @@ static UUtError IMPiEnv_CreateObjectTagArray( object_gunk = &object_array->objects[i]; object_gunk->object_tag = object_tag; gq_count = 0; - + for( j = 0; j indices[k++] = gq_array[j]; } - } + } object_gunk->gq_array = quad_array; } else @@ -1134,7 +1134,7 @@ static UUtError IMPiEnv_CreateTheDoors( ONtLevel* inLevel, IMPtEnv_BuildData* in M3tPoint3D center_point; float width; float height; - M3tBoundingBox_MinMax bBox; + M3tBoundingBox_MinMax bBox; float delta_x; float delta_z; @@ -1163,7 +1163,7 @@ static UUtError IMPiEnv_CreateTheDoors( ONtLevel* inLevel, IMPtEnv_BuildData* in rend = &env->gqRenderArray->gqRender[ gq_index ]; collision = &env->gqCollisionArray->gqCollision[ gq_index ]; - // make sure we have a door quad + // make sure we have a door quad UUmAssert( gq->flags & AKcGQ_Flag_Door ); // add some flags @@ -1188,11 +1188,11 @@ static UUtError IMPiEnv_CreateTheDoors( ONtLevel* inLevel, IMPtEnv_BuildData* in points[1] = env->pointArray->points[v2]; points[2] = env->pointArray->points[v3]; points[3] = env->pointArray->points[v4]; - + center_point.x = points[0].x + points[1].x + points[2].x + points[3].x; center_point.y = points[0].y + points[1].y + points[2].y + points[3].y; center_point.z = points[0].z + points[1].z + points[2].z + points[3].z; - + center_point.x /= 4; center_point.y /= 4; center_point.z /= 4; @@ -1208,7 +1208,7 @@ static UUtError IMPiEnv_CreateTheDoors( ONtLevel* inLevel, IMPtEnv_BuildData* in door_frame->width = width; door_frame->height = height; } - + env->door_frames = door_frame_array; return UUcError_None; @@ -1236,16 +1236,16 @@ IMPrEnv_CreateCorpses( error = TMrConstruction_Instance_NewUnique(ONcTemplate_CorpseArray, IMPcMaxCorpses, &corpse_array); corpse_array->max_corpses = IMPcMaxCorpses; corpse_array->static_corpses = 0; - + for(itr = 0; itr < corpse_array->max_corpses; itr++) { ONtCorpse *corpse = corpse_array->corpses + itr; UUrMemory_Clear(corpse , sizeof(*corpse)); - if (itr < num_corpse_files) + if (itr < num_corpse_files) { BFtFile *stream = NULL; - + BFrFile_Open(corpse_files[itr], "r", &stream); if (NULL != stream) { @@ -1253,38 +1253,38 @@ IMPrEnv_CreateCorpses( UUtUns16 i; UUrString_Copy(corpse->corpse_name, BFrFileRef_GetLeafName(corpse_files[itr]), sizeof(corpse->corpse_name)); - + BFrFile_Read(stream, 128, &character_class_name); BFrFile_Read(stream, sizeof(corpse->corpse_data), &corpse->corpse_data); - + for (i = 0; i < ONcNumCharacterParts; i++) { UUtUns16 j; M3tMatrix4x3 *matrix; - + matrix = &corpse->corpse_data.matricies[i]; - + for (j = 0; j < 4; j++) { UUtUns16 k; - + for (k = 0; k < 3; k++) { UUmSwapLittle_4Byte(&matrix->m[j][k]); } } } - + UUmSwapLittle_4Byte(&corpse->corpse_data.corpse_bbox.minPoint.x); UUmSwapLittle_4Byte(&corpse->corpse_data.corpse_bbox.minPoint.y); UUmSwapLittle_4Byte(&corpse->corpse_data.corpse_bbox.minPoint.z); - + UUmSwapLittle_4Byte(&corpse->corpse_data.corpse_bbox.maxPoint.x); UUmSwapLittle_4Byte(&corpse->corpse_data.corpse_bbox.maxPoint.y); UUmSwapLittle_4Byte(&corpse->corpse_data.corpse_bbox.maxPoint.z); - + TMrConstruction_Instance_GetPlaceHolder(TRcTemplate_CharacterClass, character_class_name, (UUtUns32 *) &corpse->corpse_data.characterClass); - + BFrFile_Close(stream); } @@ -1308,54 +1308,54 @@ IMPrEnv_CreateInstance( UUtError error; AKtEnvironment* environment; ONtLevel* level; - + AKtBNVNodeArray* bnvNodeArray; - + UUtUns32 curBNVIndex; IMPtEnv_BNV* curBNV; - + UUtUns32 curSideIndex; IMPtEnv_BNV_Side* curSide; - - + + AKtBNVNode* curAkiraNode; AKtBNV_BSPNode* curBSPNode; - + UUtUns32 numVisibleQuads = 0; UUtUns32 numBSPNodes = 0; UUtUns32 numBNVQuadIndices = 0; UUtUns32 numPartitionIndices = 0; - + UUtUns32 posNodeIndex; UUtUns32 negNodeIndex; - + UUtUns32 numGQIndIndices = 0; - + UUtUns32 numSides = 0; AKtBNVNode_Side* curAkiraSide; - + UUtUns32 curBSPIndex; - + UUtUns32 curIndex; - + UUtUns32 numAdjacencies; AKtAdjacency* curAkiraAdjacency; - + UUtUns16 curTextureIndex; AUtSharedString* curEnvTextureMap; AUtSharedString* textureList; UUtUns16 numTextures; char* string; UUtInt64 time; - + fprintf(IMPgEnv_StatsFile, "** environment data"UUmNL); - + time = UUrMachineTime_High(); Imp_PrintMessage(IMPcMsg_Important, "building instance..."); // Create level - - error = + + error = TMrConstruction_Instance_Renew( ONcTemplate_Level, inInstanceName, @@ -1367,10 +1367,10 @@ IMPrEnv_CreateInstance( IMPrEnv_CreateCorpses(level, inSourceFileRef); - + // Create environment - - error = + + error = TMrConstruction_Instance_Renew( AKcTemplate_Environment, inInstanceName, @@ -1378,11 +1378,11 @@ IMPrEnv_CreateInstance( &level->environment); IMPmError_ReturnOnErrorMsg(error, "Could not renew environment"); environment = level->environment; - + level->environment->inchesPerPixel = IMPgEnv_InchesPerPixel; // Create the point array - error = + error = AUrSharedPointArray_CreateTemplate( inBuildData->sharedPointArray, NULL, @@ -1390,9 +1390,9 @@ IMPrEnv_CreateInstance( IMPmError_ReturnOnErrorMsg(error, "Could not create shared point array"); Imp_PrintMessage(IMPcMsg_Cosmetic, "num points: %d"UUmNL, environment->pointArray->numPoints); fprintf(IMPgEnv_StatsFile, "num points: %d"UUmNL, environment->pointArray->numPoints); - + // Create the planeArray - error = + error = AUrSharedPlaneEquArray_CreateTemplate( inBuildData->sharedPlaneEquArray, NULL, @@ -1400,9 +1400,9 @@ IMPrEnv_CreateInstance( IMPmError_ReturnOnErrorMsg(error, "Could not create shared plane array"); Imp_PrintMessage(IMPcMsg_Cosmetic, "num planes: %d"UUmNL, environment->planeArray->numPlanes); fprintf(IMPgEnv_StatsFile, "num planes: %d"UUmNL, environment->planeArray->numPlanes); - + // Create the texture coord array - error = + error = AUrSharedTexCoordArray_CreateTemplate( inBuildData->sharedTextureCoordArray, NULL, @@ -1410,32 +1410,32 @@ IMPrEnv_CreateInstance( IMPmError_ReturnOnErrorMsg(error, "Could not create shared texture coord array"); Imp_PrintMessage(IMPcMsg_Cosmetic, "num texture coords: %d"UUmNL, environment->textureCoordArray->numTextureCoords); fprintf(IMPgEnv_StatsFile, "num texture coords: %d"UUmNL, environment->textureCoordArray->numTextureCoords); - + // Create the oct tree - error = + error = IMPiEnv_CreateInstance_OctTree( inBuildData, &inBuildData->otData, &environment->octTree); UUmError_ReturnOnError(error); - + // Create the gunk quad array error = IMPiEnv_CreateInstance_GQArray(inBuildData, environment); IMPmError_ReturnOnErrorMsg(error, "Could not create the GQ array"); - + // Create the texture map array textureList = AUrSharedStringArray_GetList(inBuildData->textureMapArray); numTextures = (UUtUns16)AUrSharedStringArray_GetNum(inBuildData->textureMapArray); - + fprintf(IMPgEnv_StatsFile, "num texture maps: %d"UUmNL, numTextures); - error = + error = TMrConstruction_Instance_NewUnique( M3cTemplate_TextureMapArray, numTextures, &environment->textureMapArray); IMPmError_ReturnOnErrorMsg(error, "Could not create texturemap array"); - + for(curTextureIndex = 0, curEnvTextureMap = textureList; curTextureIndex < numTextures; curTextureIndex++, curEnvTextureMap++) @@ -1448,66 +1448,66 @@ IMPrEnv_CreateInstance( environment->textureMapArray->maps[curTextureIndex] = inBuildData->envTextureList[curTextureIndex].texture; } fprintf(IMPgEnv_StatsFile, "num texture maps: %d"UUmNL, numTextures); - - + + // Create the node array - error = + error = TMrConstruction_Instance_NewUnique( AKcTemplate_BNVNodeArray, inBuildData->numBNVs, &environment->bnvNodeArray); IMPmError_ReturnOnErrorMsg(error, "Could not create node array"); fprintf(IMPgEnv_StatsFile, "num BNVs: %d"UUmNL, inBuildData->numBNVs); - + bnvNodeArray = environment->bnvNodeArray; - + for(curBNVIndex = 0, curBNV = inBuildData->bnvList; curBNVIndex < inBuildData->numBNVs; curBNVIndex++, curBNV++) { curAkiraNode = bnvNodeArray->nodes + curBNVIndex; curAkiraNode->index = (UUtUns32)curBNVIndex; - + // Assign child and next nodes curAkiraNode->childIndex = curBNV->child; - curAkiraNode->nextIndex = curBNV->next; - + curAkiraNode->nextIndex = curBNV->next; + // Assign root bsp node curAkiraNode->bspRootNode = numBSPNodes; numBSPNodes += curBNV->numNodes; - + // Assign the side indices curAkiraNode->sideStartIndex = numSides; numSides += curBNV->numSides; curAkiraNode->sideEndIndex = numSides; - + // Assign gunk quad nodes //curAkiraNode->gunkQuadStartIndex = numGunkQuads; //numGunkQuads += curBNV->numGQs; //curAkiraNode->gunkQuadEndIndex = numGunkQuads; - + // Set type flags curAkiraNode->flags = curBNV->flags; - + // Store plane and height of stairs curAkiraNode->stairPlane = curBNV->stairPlane; curAkiraNode->stairHeight = curBNV->stairHeight; - + // Pathfinding node will be set at runtime curAkiraNode->pathnodeIndex = (UUtUns32) -1; } - + // Create the side array - error = + error = TMrConstruction_Instance_NewUnique( AKcTemplate_BNVNodeSideArray, numSides, &environment->bnvSideArray); IMPmError_ReturnOnErrorMsg(error, "Could not create node array"); - + curAkiraSide = environment->bnvSideArray->sides; numAdjacencies = 0; - + for(curBNVIndex = 0, curBNV = inBuildData->bnvList; curBNVIndex < inBuildData->numBNVs; curBNVIndex++, curBNV++) @@ -1516,37 +1516,37 @@ IMPrEnv_CreateInstance( curSideIndex < curBNV->numSides; curSideIndex++, curSide++) { - + curAkiraSide->planeEquIndex = curSide->planeEquIndex; - + // Init adjacency indices curAkiraSide->adjacencyStartIndex = numAdjacencies; UUmAssert(curSide->numAdjacencies>=0 && curSide->numAdjacenciesnumAdjacencies; curAkiraSide->adjacencyEndIndex = numAdjacencies; - + // Init ghost quad indices curAkiraSide->ghostGQStartIndIndex = numGQIndIndices; numGQIndIndices += curSide->numGQGhostIndices; curAkiraSide->ghostGQEndIndIndex = numGQIndIndices; - + // Assign solid quad and partition index curAkiraSide->bnvQuadStartIndIndex = numBNVQuadIndices; numBNVQuadIndices += curSide->numBNVQuads; curAkiraSide->bnvQuadEndIndIndex = numBNVQuadIndices; - + curAkiraSide++; } } // Create the BSP node array - error = + error = TMrConstruction_Instance_NewUnique( AKcTemplate_BSPNodeArray, numBSPNodes, &environment->bspNodeArray); IMPmError_ReturnOnErrorMsg(error, "Could not create node array"); - + for(curBNVIndex = 0, curBNV = inBuildData->bnvList, curAkiraNode = bnvNodeArray->nodes; curBNVIndex < inBuildData->numBNVs; curBNVIndex++, curBNV++, curAkiraNode++) @@ -1556,10 +1556,10 @@ IMPrEnv_CreateInstance( curBSPIndex++, curBSPNode++) { curBSPNode->planeEquIndex = curBNV->bspNodes[curBSPIndex].planeEquIndex; - + posNodeIndex = curBNV->bspNodes[curBSPIndex].posNodeIndex; negNodeIndex = curBNV->bspNodes[curBSPIndex].negNodeIndex; - + if(posNodeIndex == 0xFFFFFFFF) { curBSPNode->posNodeIndex = 0xFFFFFFFF; @@ -1568,7 +1568,7 @@ IMPrEnv_CreateInstance( { curBSPNode->posNodeIndex = curBNV->bspNodes[curBSPIndex].posNodeIndex + curAkiraNode->bspRootNode; } - + if(negNodeIndex == 0xFFFFFFFF) { curBSPNode->negNodeIndex = 0xFFFFFFFF; @@ -1579,43 +1579,43 @@ IMPrEnv_CreateInstance( } } } - + // create the alpha bsp node array #if 1 - error = + error = TMrConstruction_Instance_NewUnique( AKcTemplate_AlphaBSPTree_NodeArray, inBuildData->numAlphaBSPNodes, &environment->alphaBSPNodeArray); IMPmError_ReturnOnErrorMsg(error, "Could not create node array"); - + UUrMemory_MoveFast( inBuildData->alphaBSPNodes, environment->alphaBSPNodeArray->nodes, inBuildData->numAlphaBSPNodes * sizeof(AKtAlphaBSPTree_Node)); #else - + environment->alphaBSPNodeArray = NULL; - + #endif // Create the adjacency data - + UUmAssert(numAdjacencies == IMPgEnv_VerifyAdjCount); - error = + error = TMrConstruction_Instance_NewUnique( AKcTemplate_AdjacencyArray, numAdjacencies, &environment->adjacencyArray); - + curAkiraAdjacency = environment->adjacencyArray->adjacencies; - - numSides = 0; + + numSides = 0; for(curBNVIndex = 0, curBNV = inBuildData->bnvList; curBNVIndex < inBuildData->numBNVs; curBNVIndex++, curBNV++) { if (!(curBNV->flags & AKcBNV_Flag_Room)) continue; - + for(curSideIndex = 0, curSide = curBNV->sides; curSideIndex < curBNV->numSides; curSideIndex++, curSide++) @@ -1629,7 +1629,7 @@ IMPrEnv_CreateInstance( } } } - + // Create the quad remap array { UUtUns16 remapCount; @@ -1673,7 +1673,7 @@ IMPrEnv_CreateInstance( PHrCreateRoomData(inBuildData,&inBuildData->bnvList[curBNVIndex],curAkiraNode,environment); } - + time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); @@ -1681,33 +1681,33 @@ IMPrEnv_CreateInstance( extern UUtUns32 PHgOriginalMemoryUsage; extern UUtUns32 PHgCompressedMemoryUsage; - Imp_PrintMessage(IMPcMsg_Important, UUmNL "pathfinding memory usage %2.2fk (old was %2.2fk)" UUmNL, + Imp_PrintMessage(IMPcMsg_Important, UUmNL "pathfinding memory usage %2.2fk (old was %2.2fk)" UUmNL, PHgCompressedMemoryUsage / (1024.f), PHgOriginalMemoryUsage / (1024.f)); - } - + } + // Set up objects IMPiEnv_CreateInstance_Objects(inBuildData,level); - + // Set up marker nodes IMPiEnv_CreateInstance_Markers(inBuildData,level); - + // Set up flags IMPiEnv_CreateInstance_Flags(inSourceFileRef, inBuildData, level); // Set up triggers IMPiEnv_CreateInstance_Triggers(inSourceFileRef, inBuildData, level); - + // Create the environmental particles IMPrEnv_CreateInstance_EnvParticles( inBuildData->numEnvParticles, inBuildData->envParticles, &level->envParticleArray); - + // Set up combat profiles IMPiEnv_CreateInstance_CombatProfiles(inBuildData,environment); - IMPiEnv_CreateInstance_TacticalProfiles(inBuildData,environment); - + IMPiEnv_CreateInstance_TacticalProfiles(inBuildData,environment); + // Character setup array error = GRrGroup_GetString(inBuildData->environmentGroup,"scripts",&string); if (UUcError_None != error) { @@ -1737,7 +1737,7 @@ IMPrEnv_CreateInstance( // sky error = GRrGroup_GetString(inBuildData->environmentGroup,"sky",&string); - if (UUcError_None != error) + if (UUcError_None != error) { //Imp_PrintWarning("Environment was missing sky name"); level->sky_class = NULL; @@ -1760,7 +1760,7 @@ IMPrEnv_CreateInstance( Imp_PrintMessage(IMPcMsg_Important,"Verifying pathfinding..."UUmNL); IMPiEnv_Verify_Pathfinding(inBuildData); - // build the extents + // build the extents level->environment->bbox.minPoint.x = inBuildData->minX; level->environment->bbox.minPoint.y = inBuildData->minY; level->environment->bbox.minPoint.z = inBuildData->minZ; @@ -1768,7 +1768,7 @@ IMPrEnv_CreateInstance( level->environment->bbox.maxPoint.x = inBuildData->maxX; level->environment->bbox.maxPoint.y = inBuildData->maxY; level->environment->bbox.maxPoint.z = inBuildData->maxZ; - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_LightMaps2.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_LightMaps2.c index dc46f6a..0d02511 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_LightMaps2.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_LightMaps2.c @@ -5,8 +5,8 @@ CREATED: Sept 3, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997, 2000 */ @@ -36,7 +36,7 @@ /* texture page memory layout - + base addr v v 0 1 @@ -64,20 +64,20 @@ typedef struct IMPtLM_FillPixel { UUtUns16 x, y; - + } IMPtLM_FillPixel; typedef struct IMPtLM_SortedUVEntry { UUtUns8 u; UUtUns8 v; - + } IMPtLM_SortedUVEntry; typedef struct IMPtLM_TexturePage_Entry { UUtUns32 gqIndex; - + } IMPtLM_TexturePage_Entry; UUtUns32 gLMFillPixel_Num[2]; @@ -116,20 +116,20 @@ IMPiLM_Process_LSData_Read( UUtUns16 numLSDataFiles = 0; IMPtEnv_LSData lsDataFiles[IMPcEnv_MaxFilesInDir]; - + UUtUns16 itr; #if ((UUmPlatform == UUmPlatform_Win32) || (UUmPlatform == UUmPlatform_Linux)) && (UUmCompiler != UUmCompiler_MWerks) - + error = BFrFileRef_DuplicateAndReplaceName( inSourceFileRef, "Conversion_Files\\LS", &lsDirectory); - + if(error == UUcError_None && BFrFileRef_FileExists(lsDirectory)) { - error = + error = BFrDirectory_GetFileList( lsDirectory, NULL, @@ -138,30 +138,30 @@ IMPiLM_Process_LSData_Read( &numLSDataFiles, lsDataFileRefs); UUmError_ReturnOnErrorMsg(error, "Could not get LS Files"); - + Imp_PrintMessage(IMPcMsg_Important, "Preprocessing LS Data files from LS directory (%d files)..."UUmNL, numLSDataFiles); for(itr = 0; itr < numLSDataFiles; itr++) { - error = + error = LSrData_CreateFromLSFile( BFrFileRef_GetFullPath(lsDataFileRefs[itr]), &lsDataFiles[itr].lsData); UUmError_ReturnOnError(error); - + if(strcmp(lsDataFiles[itr].lsData->prepVersion, LScPrepVersion)) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "LS preperation version is wrong"); } - + UUrString_Copy(lsDataFiles[itr].fileName, BFrFileRef_GetLeafName(lsDataFileRefs[itr]), BFcMaxFileNameLength); - + BFrFileRef_Dispose(lsDataFileRefs[itr]); } - + BFrFileRef_Dispose(lsDirectory); } else - + #endif // ok, turn our lighting files into a list of lighting points @@ -182,7 +182,7 @@ IMPiLM_Process_LSData_Read( IMPgLightingBBox.maxPoint.x = UUmMax(IMPgLightingBBox.maxPoint.x, lsData->bbox.maxPoint.x); IMPgLightingBBox.maxPoint.y = UUmMax(IMPgLightingBBox.maxPoint.y, lsData->bbox.maxPoint.y); - IMPgLightingBBox.maxPoint.z = UUmMax(IMPgLightingBBox.maxPoint.z, lsData->bbox.maxPoint.z); + IMPgLightingBBox.maxPoint.z = UUmMax(IMPgLightingBBox.maxPoint.z, lsData->bbox.maxPoint.z); } } @@ -240,7 +240,7 @@ IMPiLM_Process_LS_Cache_Data_Read( M3tBoundingBox_MinMax bbox; UUtUns32 point_size; BFtFile *lighting_file; - + error = BFrFile_Open(&lighting_file_ref, "r", &lighting_file); UUmError_ReturnOnErrorMsg(error, "failed to open ls cache file"); @@ -250,7 +250,7 @@ IMPiLM_Process_LS_Cache_Data_Read( if (LIGHTING_CACHE_VERSION != version) { Imp_PrintWarning("failed to read lighting.dat"); - + error = UUcError_Generic; goto exit; } @@ -305,9 +305,9 @@ IMPiLM_Process_LS_Cache_Data_Read( IMPgLightingBBox.maxPoint.x = UUmMax(IMPgLightingBBox.maxPoint.x, bbox.maxPoint.x); IMPgLightingBBox.maxPoint.y = UUmMax(IMPgLightingBBox.maxPoint.y, bbox.maxPoint.y); - IMPgLightingBBox.maxPoint.z = UUmMax(IMPgLightingBBox.maxPoint.z, bbox.maxPoint.z); + IMPgLightingBBox.maxPoint.z = UUmMax(IMPgLightingBBox.maxPoint.z, bbox.maxPoint.z); } - + exit: return error; @@ -333,7 +333,7 @@ IMPiLM_Process_LS_Cache_Data_Write( { UUtUns32 version = LIGHTING_CACHE_VERSION; - + error = BFrFile_Write(lighting_file, sizeof(UUtUns32), &version); UUmError_ReturnOnError(error); } @@ -372,7 +372,7 @@ IMPiLM_Process_LS_Cache_Data_Write( BFrFile_Close(lighting_file); } - + return error; } @@ -519,14 +519,14 @@ static UUtUns32 LightingOctTree_GetCount(const M3tPoint3D *inPoint) if (inPoint->y > lighting_bbox.maxPoint.y) { goto exit; } - + if (inPoint->z > lighting_bbox.maxPoint.z) { goto exit; } x = UUmPin(x, 0, (LIGHTING_OCT_TREE_SIZE - 1)); y = UUmPin(y, 0, (LIGHTING_OCT_TREE_SIZE - 1)); - z = UUmPin(z, 0, (LIGHTING_OCT_TREE_SIZE - 1)); + z = UUmPin(z, 0, (LIGHTING_OCT_TREE_SIZE - 1)); count = lighting_oct_tree_size[x][y][z]; @@ -563,14 +563,14 @@ static LStPoint **LightingOctTree_GetList(const M3tPoint3D *inPoint) if (inPoint->y > lighting_bbox.maxPoint.y) { goto exit; } - + if (inPoint->z > lighting_bbox.maxPoint.z) { goto exit; } x = UUmPin(x, 0, (LIGHTING_OCT_TREE_SIZE - 1)); y = UUmPin(y, 0, (LIGHTING_OCT_TREE_SIZE - 1)); - z = UUmPin(z, 0, (LIGHTING_OCT_TREE_SIZE - 1)); + z = UUmPin(z, 0, (LIGHTING_OCT_TREE_SIZE - 1)); list = lighting_oct_tree[x][y][z]; @@ -604,7 +604,7 @@ IMPiLightEnvironmentVertex( max_point = point_list + point_count; - for(current_point_in_list = point_list; current_point_in_list < max_point; current_point_in_list++) + for(current_point_in_list = point_list; current_point_in_list < max_point; current_point_in_list++) { LStPoint *current_point = *current_point_in_list; UUtInt32 dot_product_approximation = 0; @@ -661,7 +661,7 @@ IMPiLightEnvironmentVertex( } } - if (approximation == approximation_to_beat) { + if (approximation == approximation_to_beat) { shade = current_point->shade; shade = (shade & 0xFFFFFF00) | UUmMax((shade & 0x0000FF), (current_point->shade & 0x0000FF)); @@ -696,7 +696,7 @@ IMPiLightEnvironmentVertex( shade = IMPiLightEnvironmentVertex(inBuildData, inLocation, inNormal, UUcTrue); } } - + return shade; } @@ -732,29 +732,29 @@ IMPiLM_Process( } Imp_PrintMessage(IMPcMsg_Important, "\tread %d lighting points"UUmNL, IMPgLightingPointCount); - + Imp_PrintMessage(IMPcMsg_Important, "\tbuilding lighting oct tree"UUmNL); BuildLightingOctTree(inBuildData); - + Imp_PrintMessage(IMPcMsg_Important, "\tprocessing vertex lighting"); AKgLightingFailure = 0; Imp_PrintMessage(IMPcMsg_Important, "%d gqs:", inBuildData->numGQs); - + // Loop over each gq for(itr = 0; itr < inBuildData->numGQs; itr++) { IMPtEnv_GQ *current_gq = inBuildData->gqList + itr; if ((itr % 100) == 0) { - Imp_PrintMessage(IMPcMsg_Important, "."); + Imp_PrintMessage(IMPcMsg_Important, "."); } if ((itr % 1000) == 0) { - Imp_PrintMessage(IMPcMsg_Important, " %d%% [%d fail %d 2nd pass]", (100 * itr) / inBuildData->numGQs, AKgLightingFailure, AKgLightingSecondPass); + Imp_PrintMessage(IMPcMsg_Important, " %d%% [%d fail %d 2nd pass]", (100 * itr) / inBuildData->numGQs, AKgLightingFailure, AKgLightingSecondPass); } { @@ -790,7 +790,7 @@ IMPiLM_Process( IMPgLightingPoints = UUrMemory_Block_Realloc(IMPgLightingPoints, 0); IMPgLightingPointCount = 0; - + return UUcError_None; } @@ -802,7 +802,7 @@ IMPrLM_DontProcessGQ( if(inGQ->lmFlags & IMPcGQ_LM_ForceOff) return UUcTrue; if(inGQ->isLuminaire) return UUcTrue; if(inGQ->flags & AKcGQ_Flag_DontLight) return UUcTrue; - + return UUcFalse; } @@ -817,16 +817,16 @@ IMPrEnv_Process_LightMap( time = UUrMachineTime_High(); Imp_PrintMessage(IMPcMsg_Important, "preparing to compute lightmaps"); - + IMPgLM_LastFlushedTextureMapIndex = 0; IMPgLM_TableArea = 0; - + time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); - + Imp_PrintMessage(IMPcMsg_Important, "lightmaps"); - time = UUrMachineTime_High(); - + time = UUrMachineTime_High(); + if(IMPgLightmaps) { if(IMPgLightmap_OutputPrepFile) @@ -838,14 +838,14 @@ IMPrEnv_Process_LightMap( BFtFileRef* lpOutputDir; BFtFileRef* curLPFileRef; UUtUns16 curFileIndex; - + error = BFrFileRef_DuplicateAndReplaceName( inSourceFileRef, "Conversion_Files\\LP", &lpOutputDir); UUmError_ReturnOnErrorMsg(error, "Could not locate LP directory"); - + if(!BFrFileRef_FileExists(lpOutputDir)) { error = BFrDirectory_Create(lpOutputDir, NULL); @@ -855,7 +855,7 @@ IMPrEnv_Process_LightMap( { BFrDirectory_DeleteContentsOnly(lpOutputDir); } - + if(IMPgLightmap_OutputPrepFileOne) { char tempName[BFcMaxFileNameLength]; @@ -863,10 +863,10 @@ IMPrEnv_Process_LightMap( char* cp; sprintf(tempName, "%s", BFrFileRef_GetLeafName(inSourceFileRef)); - + cp = strchr(tempName, '.'); if(cp != NULL) *cp = 0; - + sprintf(allOneFileName, "%s_lp1.lp", tempName); error = @@ -875,15 +875,15 @@ IMPrEnv_Process_LightMap( allOneFileName, &curLPFileRef); UUmError_ReturnOnErrorMsg(error, "Could not locate LP directory"); - + // create the LP file - error = + error = LSrPreperationFile_Create( inBuildData, NULL, BFrFileRef_GetFullPath(curLPFileRef)); UUmError_ReturnOnError(error); - + BFrFileRef_Dispose(curLPFileRef); } else @@ -896,21 +896,21 @@ IMPrEnv_Process_LightMap( inBuildData->gqFileNames[curFileIndex], &curLPFileRef); UUmError_ReturnOnErrorMsg(error, "Could not locate LP directory"); - + BFrFileRef_SetLeafNameSuffex(curLPFileRef, "lp"); - + // create the LP file - error = + error = LSrPreperationFile_Create( inBuildData, inBuildData->gqFileNames[curFileIndex], BFrFileRef_GetFullPath(curLPFileRef)); UUmError_ReturnOnError(error); - + BFrFileRef_Dispose(curLPFileRef); } } - + BFrFileRef_Dispose(lpOutputDir); } #endif @@ -919,7 +919,7 @@ IMPrEnv_Process_LightMap( IMPiLM_Process(inBuildData, inSourceFileRef); } } - + time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_OctTree2.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_OctTree2.c index 1d48842..0fec8b7 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_OctTree2.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_OctTree2.c @@ -5,8 +5,8 @@ CREATED: Sept 3, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ @@ -71,29 +71,29 @@ IMPiEnv_QuadTree_Build( AKtQuadTree_Node* qtNode; UUtUns32 itr; AKtOctTree_InteriorNode* otInteriorNode; - + if(AKmOctTree_IsLeafNode(inOTNodeIndex)) { *outQuadTreeIndex = inOTNodeIndex; - + return UUcError_None; } - + // create a new interior quad tree node if(inOTData->nextQTNodeIndex >= IMPcEnv_MaxQTNodes) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "out of interior nodes"); } - + newQTNodeIndex = inOTData->nextQTNodeIndex++; - + qtNode = inOTData->qtNodes + newQTNodeIndex; - + otInteriorNode = inOTData->interiorNodes + inOTNodeIndex; - + for(itr = 0; itr < 4; itr++) { - error = + error = IMPiEnv_QuadTree_Build( inBuildData, inOTData, @@ -102,9 +102,9 @@ IMPiEnv_QuadTree_Build( &qtNode->children[itr]); UUmError_ReturnOnError(error); } - + *outQuadTreeIndex = newQTNodeIndex; - + return UUcError_None; } @@ -115,27 +115,27 @@ IMPiEnv_OctTree_Init( UUtUns32 i; inOTData->maxDepth = 0; - + for(i = 0; i < IMPcEnv_OT_MaxGQsPerNode; i++) { inOTData->gqsPerNodeDist[i] = 0; } - + for(i = 0; i < IMPcEnv_OT_MaxBNVsPerNode; i++) { inOTData->bnvsPerNodeDist[i] = 0; } - + for(i = 0; i < IMPcEnv_OT_NumLeafNodeDims; i++) { inOTData->leafNodeSizeDist[i] = 0; } - + inOTData->nextLeafNodeIndex = 0; inOTData->nextInteriorNodeIndex = 0; - + inOTData->nextGQIndex = 0; - + inOTData->nextQTNodeIndex = 0; inOTData->nextBNVIndex = 0; } @@ -151,7 +151,7 @@ IMPiEnv_OctTree_PrintStats( fprintf(inFile, "num leaf nodes: %d"UUmNL, inOTData->nextLeafNodeIndex); fprintf(inFile, "max depth: %d"UUmNL, inOTData->maxDepth); fprintf(inFile, "distribution"UUmNL); - + for(i = 0; i < IMPcEnv_OT_MaxGQsPerNode; i++) { fprintf(inFile, "GQsPerNode[%d] = %d"UUmNL, i, inOTData->gqsPerNodeDist[i]); @@ -184,7 +184,7 @@ IMPiEnv_OctTree_FindIntersectionGQs( M3tPoint3D* pointArray; M3tPlaneEquation* planeArray; UUtUns32 numIndices = 0; - + UUmAssert(outNewGQIndexArray != NULL); pointArray = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); @@ -196,12 +196,12 @@ IMPiEnv_OctTree_FindIntersectionGQs( { curGQIndex = inGQIndexArray[index]; curGQ = inBuildData->gqList + curGQIndex; - + if(curGQ->flags & AKcGQ_Flag_NoTextureMask) { continue; } - + if(CLrQuad_Box( curGQ->projection, pointArray, @@ -215,7 +215,7 @@ IMPiEnv_OctTree_FindIntersectionGQs( outNewGQIndexArray[numIndices++] = curGQIndex; } } - + *outNewGQIndexCount = numIndices; } @@ -233,7 +233,7 @@ IMPiEnv_OctTree_Build_BNVInfo_CheckQuad( M3tQuad targetQuad; M3tQuad* curQuad; M3tQuad* quadArray; - + pointArray = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); quadArray = AUrSharedQuadArray_GetList(inBuildData->sharedBNVQuadArray); @@ -244,12 +244,12 @@ IMPiEnv_OctTree_Build_BNVInfo_CheckQuad( for(curQuadIndex = 0; curQuadIndex < curSide->numBNVQuads; curQuadIndex++) { curQuad = quadArray + curSide->bnvQuadList[curQuadIndex]; - + targetQuad.indices[0] = (curQuad->indices[0]); targetQuad.indices[1] = (curQuad->indices[1]); targetQuad.indices[2] = (curQuad->indices[2]); targetQuad.indices[3] = (curQuad->indices[3]); - + if(CLrQuad_Quad( CLcProjection_Unknown, // projection A inPointList, // point array A @@ -269,7 +269,7 @@ IMPiEnv_OctTree_Build_BNVInfo_CheckQuad( ) != CLcCollision_None) return UUcTrue; } } - + return UUcFalse; } @@ -285,22 +285,22 @@ IMPiEnv_OctTree_Build_BNVInfo_Check( IMPtEnv_BNV_Side* curSide; UUtUns32 curQuadIndex; UUtUns32 curVertexIndex; - + M3tQuad* quadArray; M3tPoint3D* pointArray; M3tQuad* curQuad; M3tPoint3D* curPoint; - + float minX, minY, minZ; float maxX, maxY, maxZ; - + minX = inBBox->minPoint.x; minY = inBBox->minPoint.y; minZ = inBBox->minPoint.z; maxX = inBBox->maxPoint.x; maxY = inBBox->maxPoint.y; maxZ = inBBox->maxPoint.z; - + // First check if any ot vertices are in the BNV's bsp tree points[0].x = minX; points[0].y = minY; points[0].z = minZ; if(IMPiEnv_Process_BSP_PointInBSP(inBuildData, inBNV, &points[0], 0) == UUcTrue) return UUcTrue; @@ -325,7 +325,7 @@ IMPiEnv_OctTree_Build_BNVInfo_Check( points[7].x = maxX; points[7].y = maxY; points[7].z = maxZ; if(IMPiEnv_Process_BSP_PointInBSP(inBuildData, inBNV, &points[7], 0) == UUcTrue) return UUcTrue; - + quadArray = AUrSharedQuadArray_GetList(inBuildData->sharedBNVQuadArray); pointArray = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); @@ -337,11 +337,11 @@ IMPiEnv_OctTree_Build_BNVInfo_Check( for(curQuadIndex = 0; curQuadIndex < curSide->numBNVQuads; curQuadIndex++) { curQuad = quadArray + curSide->bnvQuadList[curQuadIndex]; - + for(curVertexIndex = 0; curVertexIndex < 4; curVertexIndex++) { curPoint = pointArray + curQuad->indices[curVertexIndex]; - + if(minX <= curPoint->x && curPoint->x <= maxX && minY <= curPoint->y && curPoint->y <= maxY && minZ <= curPoint->z && curPoint->z <= maxZ) @@ -351,7 +351,7 @@ IMPiEnv_OctTree_Build_BNVInfo_Check( } } } - + // minX plane quad.indices[0] = 0; quad.indices[1] = 2; quad.indices[2] = 6; quad.indices[3] = 4; if(IMPiEnv_OctTree_Build_BNVInfo_CheckQuad( @@ -359,7 +359,7 @@ IMPiEnv_OctTree_Build_BNVInfo_Check( inBNV, points, &quad) == UUcTrue) return UUcTrue; - + // maxX plane quad.indices[0] = 1; quad.indices[1] = 3; quad.indices[2] = 7; quad.indices[3] = 5; if(IMPiEnv_OctTree_Build_BNVInfo_CheckQuad( @@ -367,7 +367,7 @@ IMPiEnv_OctTree_Build_BNVInfo_Check( inBNV, points, &quad) == UUcTrue) return UUcTrue; - + // minY plane quad.indices[0] = 0; quad.indices[1] = 1; quad.indices[2] = 5; quad.indices[3] = 4; if(IMPiEnv_OctTree_Build_BNVInfo_CheckQuad( @@ -375,7 +375,7 @@ IMPiEnv_OctTree_Build_BNVInfo_Check( inBNV, points, &quad) == UUcTrue) return UUcTrue; - + // maxY plane quad.indices[0] = 2; quad.indices[1] = 3; quad.indices[2] = 7; quad.indices[3] = 6; if(IMPiEnv_OctTree_Build_BNVInfo_CheckQuad( @@ -383,7 +383,7 @@ IMPiEnv_OctTree_Build_BNVInfo_Check( inBNV, points, &quad) == UUcTrue) return UUcTrue; - + // minZ plane quad.indices[0] = 0; quad.indices[1] = 1; quad.indices[2] = 3; quad.indices[3] = 2; if(IMPiEnv_OctTree_Build_BNVInfo_CheckQuad( @@ -391,7 +391,7 @@ IMPiEnv_OctTree_Build_BNVInfo_Check( inBNV, points, &quad) == UUcTrue) return UUcTrue; - + // maxZ plane quad.indices[0] = 4; quad.indices[1] = 5; quad.indices[2] = 7; quad.indices[3] = 6; if(IMPiEnv_OctTree_Build_BNVInfo_CheckQuad( @@ -399,7 +399,7 @@ IMPiEnv_OctTree_Build_BNVInfo_Check( inBNV, points, &quad) == UUcTrue) return UUcTrue; - + return UUcFalse; } @@ -418,7 +418,7 @@ IMPiEnv_OctTree_FindIntersectionBNVs( M3tPoint3D* pointArray; M3tPlaneEquation* planeArray; UUtUns32 numIndices = 0; - + UUmAssert(outNewBNVIndexArray != NULL); pointArray = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); @@ -441,7 +441,7 @@ IMPiEnv_OctTree_FindIntersectionBNVs( outNewBNVIndexArray[numIndices++] = curBNVIndex; } } - + *outNewBNVIndexCount = numIndices; } @@ -453,13 +453,13 @@ IMPiEnv_OctTree_NodeContainsNode( { AKtOctTree_InteriorNode* interiorNode; UUtUns32 itr; - + if(inCurNodeIndex == inDesiredNode) return UUcTrue; - + if(AKmOctTree_IsLeafNode(inCurNodeIndex)) return UUcFalse; - + interiorNode = inOTData->interiorNodes + inCurNodeIndex; - + for(itr = 0; itr < 8; itr++) { if(IMPiEnv_OctTree_NodeContainsNode( @@ -470,10 +470,10 @@ IMPiEnv_OctTree_NodeContainsNode( return UUcTrue; } } - + return UUcFalse; } - + static void IMPiEnv_OctTree_Verify_ExtraInfo_Adjacent( IMPtEnv_OTData* inOTData, @@ -483,7 +483,7 @@ IMPiEnv_OctTree_Verify_ExtraInfo_Adjacent( { UUtUns32 adjIndex; UUtUns32 mirrorSide; - UUtUns32 mirrorSideTable[] = + UUtUns32 mirrorSideTable[] = { AKcOctTree_Side_PosX, AKcOctTree_Side_NegX, @@ -494,11 +494,11 @@ IMPiEnv_OctTree_Verify_ExtraInfo_Adjacent( }; IMPtEnv_OTExtraNodeInfo* adjExtraNodeInfo; UUtBool nodeContaintsNode; - + adjIndex = inNodeExtraInfo->adjacent[inSide]; - + if(adjIndex == 0xFFFFFFFF) return; - + if(AKmOctTree_IsLeafNode(adjIndex)) { adjExtraNodeInfo = inOTData->leafNodeExtras + AKmOctTree_GetLeafIndex(adjIndex); @@ -507,7 +507,7 @@ IMPiEnv_OctTree_Verify_ExtraInfo_Adjacent( { adjExtraNodeInfo = inOTData->interiorNodeExtras + adjIndex; } - + switch(inSide) { case AKcOctTree_Side_NegX: @@ -529,11 +529,11 @@ IMPiEnv_OctTree_Verify_ExtraInfo_Adjacent( UUmAssert(inNodeExtraInfo->maxZIndex == adjExtraNodeInfo->minZIndex); break; } - + mirrorSide = mirrorSideTable[inSide]; - + UUmAssert(inNodeExtraInfo->depth >= adjExtraNodeInfo->depth); - + nodeContaintsNode = IMPiEnv_OctTree_NodeContainsNode( inOTData, @@ -561,35 +561,35 @@ IMPiEnv_OctTree_Verify_SideRecursive( float maxX, maxY, maxZ; float minX, minY, minZ; UUtUns32 targetLeafNodeIndex; - + if(inTargetAdjInfo == 0xFFFFFFFF) return; - + if(AKmOctTree_IsLeafNode(inTargetAdjInfo)) { targetLeafNodeIndex = AKmOctTree_GetLeafIndex(inTargetAdjInfo); targetLeafNode = inOTData->leafNodes + targetLeafNodeIndex; - + if(AKmOctTree_IsLeafNode(targetLeafNode->adjInfo[inTargetAdjsCurSideIndex])) { UUmAssert(targetLeafNode->adjInfo[inTargetAdjsCurSideIndex] == AKmOctTree_MakeLeafIndex(inCurLeafNodeIndex)); } - + dimIndex = ((targetLeafNode->dim_Encode >> AKcOctTree_Shift_Dim) & AKcOctTree_Mask_Dim); UUmAssert(dimIndex < 9); curDim = AKgIntToFloatDim[dimIndex]; - + maxXIndex = ((targetLeafNode->dim_Encode >> AKcOctTree_Shift_X) & AKcOctTree_Mask_X); UUmAssert(maxXIndex < 512); maxX = AKgIntToFloatXYZ[maxXIndex]; - + maxYIndex = ((targetLeafNode->dim_Encode >> AKcOctTree_Shift_Y) & AKcOctTree_Mask_Y); UUmAssert(maxYIndex < 512); maxY = AKgIntToFloatXYZ[maxYIndex]; - + maxZIndex = ((targetLeafNode->dim_Encode >> AKcOctTree_Shift_Z) & AKcOctTree_Mask_Z); UUmAssert(maxZIndex < 512); maxZ = AKgIntToFloatXYZ[maxZIndex]; - + minX = maxX - curDim; minY = maxY - curDim; minZ = maxZ - curDim; @@ -619,7 +619,7 @@ IMPiEnv_OctTree_Verify_SideRecursive( else { curQuadNode = inOTData->qtNodes + inTargetAdjInfo; - + for(itr = 0; itr < 4; itr++) { IMPiEnv_OctTree_Verify_SideRecursive( @@ -649,11 +649,11 @@ IMPiEnv_OctTree_Verify_SideAdjInfo_IMeanItThisTime( UUtUns32 inCorrectLeafIndex) { UUtUns32 theFuckingIndex; - + if(AKmOctTree_IsLeafNode(inAdjInfo)) { theFuckingIndex = AKmOctTree_GetLeafIndex(inAdjInfo); - + UUmAssert(theFuckingIndex == inCorrectLeafIndex); } else @@ -663,13 +663,13 @@ IMPiEnv_OctTree_Verify_SideAdjInfo_IMeanItThisTime( inOTData, 0, inTargetLeafNodeIndex); - + // compute the difference between the target leaf node level and the current level // this is the number of levels in the quad tree - + } } - + static void IMPiEnv_OctTree_Verify_SideAdjInfo( IMPtEnv_OTData* inOTData, @@ -682,16 +682,16 @@ IMPiEnv_OctTree_Verify_SideAdjInfo( UUtUns32 targetAdjLeafIndex; UUtUns32 itr; AKtQuadTree_Node* curQuadTreeNode; - + if(inAdjInfo == 0xFFFFFFFF) return; - + if(AKmOctTree_IsLeafNode(inAdjInfo)) { targetLeafIndex = AKmOctTree_GetLeafIndex(inAdjInfo); targetLeafNode = inOTData->leafNodes + targetLeafIndex; - + targetAdjLeafIndex = targetLeafNode->adjInfo[inSideIndex]; - + IMPiEnv_OctTree_Verify_SideAdjInfo_IMeanItThisTime( inOTData, targetAdjLeafIndex, @@ -701,7 +701,7 @@ IMPiEnv_OctTree_Verify_SideAdjInfo( else { curQuadTreeNode = inOTData->qtNodes + inAdjInfo; - + for(itr = 0; itr < 4; itr++) { IMPiEnv_OctTree_Verify_SideAdjInfo( @@ -723,13 +723,13 @@ IMPiEnv_OctTree_Verify_SideAdjInfoRecursive( UUtUns32 itr; AKtOctTree_InteriorNode* curInteriorNode; AKtOctTree_LeafNode* curLeafNode; - + if(AKmOctTree_IsLeafNode(inCurIndex)) { leafIndex = AKmOctTree_GetLeafIndex(inCurIndex); - + curLeafNode = inOTData->leafNodes + leafIndex; - + IMPiEnv_OctTree_Verify_SideAdjInfo( inOTData, curLeafNode->adjInfo[AKcOctTree_Side_NegX], @@ -764,7 +764,7 @@ IMPiEnv_OctTree_Verify_SideAdjInfoRecursive( else { curInteriorNode = inOTData->interiorNodes + inCurIndex; - + for(itr = 0; itr < 8; itr++) { IMPiEnv_OctTree_Verify_SideAdjInfoRecursive( @@ -788,13 +788,13 @@ IMPiEnv_OctTree_Verify( UUtUns32 maxXIndex; UUtUns32 maxYIndex; UUtUns32 maxZIndex; - + // Second verify that indices match up between adjacent nodes IMPiEnv_OctTree_Verify_SideAdjInfoRecursive( inOTData, 0, 0xFFFFFFFF); - + // first check that all side values match for(itr = 0, curLeafNode = inOTData->leafNodes; itr < inOTData->nextLeafNodeIndex; @@ -803,23 +803,23 @@ IMPiEnv_OctTree_Verify( dimIndex = ((curLeafNode->dim_Encode >> AKcOctTree_Shift_Dim) & AKcOctTree_Mask_Dim); UUmAssert(dimIndex < 9); curDim = AKgIntToFloatDim[dimIndex]; - + maxXIndex = ((curLeafNode->dim_Encode >> AKcOctTree_Shift_X) & AKcOctTree_Mask_X); UUmAssert(maxXIndex < 512); maxX = AKgIntToFloatXYZ[maxXIndex]; - + maxYIndex = ((curLeafNode->dim_Encode >> AKcOctTree_Shift_Y) & AKcOctTree_Mask_Y); UUmAssert(maxYIndex < 512); maxY = AKgIntToFloatXYZ[maxYIndex]; - + maxZIndex = ((curLeafNode->dim_Encode >> AKcOctTree_Shift_Z) & AKcOctTree_Mask_Z); UUmAssert(maxZIndex < 512); maxZ = AKgIntToFloatXYZ[maxZIndex]; - + minX = maxX - curDim; minY = maxY - curDim; minZ = maxZ - curDim; - + // Verify current node's negX side with adj nodes posX side IMPiEnv_OctTree_Verify_SideRecursive( inOTData, @@ -834,7 +834,7 @@ IMPiEnv_OctTree_Verify( curLeafNode->adjInfo[AKcOctTree_Side_PosX], AKcOctTree_Side_NegX, maxX); - + // Verify this negY side with adj posY side IMPiEnv_OctTree_Verify_SideRecursive( inOTData, @@ -849,7 +849,7 @@ IMPiEnv_OctTree_Verify( curLeafNode->adjInfo[AKcOctTree_Side_PosY], AKcOctTree_Side_NegY, maxY); - + // Verify this negZ side with adj posZ side IMPiEnv_OctTree_Verify_SideRecursive( inOTData, @@ -866,7 +866,7 @@ IMPiEnv_OctTree_Verify( maxZ); } -} +} UUtUns32 oct_tree_bnv_memory_saved = 0; UUtUns32 oct_tree_gq_memory_saved = 0; @@ -887,14 +887,14 @@ static void IMPiEnv_OctTree_LeafNode_CreateGQList( inOTData->leafNodeSizeDist[inNodeExtraInfo->dimIndex]++; ioLeafNode->dim_Encode = inNodeExtraInfo->dimIndex << AKcOctTree_Shift_Dim; - + ioLeafNode->dim_Encode |= inNodeExtraInfo->maxXIndex << AKcOctTree_Shift_X; ioLeafNode->dim_Encode |= inNodeExtraInfo->maxYIndex << AKcOctTree_Shift_Y; ioLeafNode->dim_Encode |= inNodeExtraInfo->maxZIndex << AKcOctTree_Shift_Z; - + // Update the gq stuff inOTData->gqsPerNodeDist[gq_index_count]++; - + if(gq_index_count == 0) { ioLeafNode->gqIndirectIndex_Encode = 0; } @@ -904,7 +904,7 @@ static void IMPiEnv_OctTree_LeafNode_CreateGQList( ioLeafNode->gqIndirectIndex_Encode = (inOTData->nextGQIndex << AKcOctTree_GQInd_Start_Shift) | gq_index_count; } - + if(gq_index_count > 0) { for(itr = 0; itr < gq_index_count; itr++) @@ -912,7 +912,7 @@ static void IMPiEnv_OctTree_LeafNode_CreateGQList( if(gGQ_RemapArray[inGQIndexArray[itr]] == 0xFFFFFFFF) { gGQ_RemapArray[inGQIndexArray[itr]] = gGQ_NumRemapped++; } - + gGQ_RemapArray_CreateGQList[itr] = gGQ_RemapArray[inGQIndexArray[itr]]; } } @@ -936,7 +936,7 @@ static void IMPiEnv_OctTree_LeafNode_CreateGQList( UUmAssert(itr >= 0); UUmAssert(((UUtUns32) itr) < inOTData->nextGQIndex); - + test_memory = inOTData->gqIndexArray + itr; is_equal = UUrMemory_IsEqual(test_memory, gGQ_RemapArray_CreateGQList, gq_index_count * sizeof(UUtUns32)); @@ -1002,7 +1002,7 @@ static void IMPiEnv_OctTree_LeafNode_CreateBNVList( UUmAssert(itr >= 0); UUmAssert(((UUtUns32) itr) < inOTData->nextBNVIndex); - + test_memory = inOTData->bnv_index_array + itr; is_equal = UUrMemory_IsEqual(test_memory, inBNVIndexArray, inBNVIndexCount * sizeof(UUtUns32)); @@ -1069,7 +1069,7 @@ IMPiEnv_OctTree_Build_Recursive( AKtOctTree_LeafNode* leafNode; AKtOctTree_InteriorNode* interiorNode; - + M3tBoundingBox_MinMax childBBox; UUtUns32 childGQIndexCount; UUtUns32* childGQIndexArray; @@ -1081,12 +1081,12 @@ IMPiEnv_OctTree_Build_Recursive( UUtUns32* childBNVIndexArray; static UUtUns32 statusDotCounter = 0; - + float nodeCenterX, nodeCenterY, nodeCenterZ; UUtUns32 *top_of_stack = inTopOfStack; UUmAssert((top_of_stack >= IMPgOctree2_StackBase) && (top_of_stack < IMPgOctree2_StackMax)); - + // Print out the cheesy status dots if(statusDotCounter++ % 2000 == 0) Imp_PrintMessage(IMPcMsg_Important,"."); @@ -1095,10 +1095,10 @@ IMPiEnv_OctTree_Build_Recursive( { inOTData->maxDepth = inLevel; } - + // Get this node's dimension nodeDim = inBoundingBox->maxPoint.x - inBoundingBox->minPoint.x; - + UUmAssert(nodeDim > 0.0f); UUmAssert(nodeDim == (inBoundingBox->maxPoint.y - inBoundingBox->minPoint.y)); UUmAssert(nodeDim == (inBoundingBox->maxPoint.z - inBoundingBox->minPoint.z)); @@ -1121,12 +1121,12 @@ IMPiEnv_OctTree_Build_Recursive( Imp_PrintWarning("oct tree node had too many gqs (%d / %d)", inGQIndexCount, IMPcEnv_OT_MaxGQsPerNode); UUmError_ReturnOnErrorMsg(UUcError_Generic, "Environment too complex for oct tree, too many GQs"); } - + if(inBNVIndexCount >= IMPcEnv_OT_MaxBNVsPerNode) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Environment too complex for oct tree, too many BNVs"); } - + if(inOTData->nextLeafNodeIndex >= IMPcEnv_MaxLeafNodes) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Too many parent nodes"); @@ -1145,17 +1145,17 @@ IMPiEnv_OctTree_Build_Recursive( nodeExtraInfo = inOTData->interiorNodeExtras + nodeIndex; interiorNode = inOTData->interiorNodes + nodeIndex; } - + // create the node extra info { float tf1 = (float)(log(nodeDim) / log(2.0)); float tf2 = (float)(log(AKcMinOTDim) / log(2.0)); - + nodeExtraInfo->dimIndex = (UUtUns32) (tf1 - tf2); } //nodeExtraInfo->dimIndex = ((log(nodeDim) - log(AKcMinOTDim))/log(2.0)); - + nodeExtraInfo->minXIndex = (UUtUns16) (inBoundingBox->minPoint.x / AKcMinOTDim + 255.0f); nodeExtraInfo->minYIndex = (UUtUns16) (inBoundingBox->minPoint.y / AKcMinOTDim + 255.0f); nodeExtraInfo->minZIndex = (UUtUns16) (inBoundingBox->minPoint.z / AKcMinOTDim + 255.0f); @@ -1171,11 +1171,11 @@ IMPiEnv_OctTree_Build_Recursive( UUmAssert(nodeExtraInfo->maxXIndex >= 0); UUmAssert(nodeExtraInfo->maxYIndex >= 0); UUmAssert(nodeExtraInfo->maxZIndex >= 0); - + nodeExtraInfo->depth = inLevel; nodeExtraInfo->parent = inParent; nodeExtraInfo->myOctant = inOctant; - + // if we are in a leaf node then create it if(nodeIsLeaf) { @@ -1184,10 +1184,10 @@ IMPiEnv_OctTree_Build_Recursive( { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Too many gq indices."); } - + UUmAssert(outChildIndex != NULL); *outChildIndex = AKmOctTree_MakeLeafIndex(nodeIndex); - + if (inGQIndexCount > AKcOctTree_GQInd_Len_Mask) { // CB: we can store at most AKcOctTree_GQInd_Len_Mask GQs in a single leaf node due to the bitmask packing. warn about this // and truncate the GQ list so that we don't corrupt other fields in the bitmask. @@ -1199,35 +1199,35 @@ IMPiEnv_OctTree_Build_Recursive( IMPiEnv_OctTree_LeafNode_CreateGQList(leafNode, nodeExtraInfo, inBuildData, inOTData, inGQIndexCount, inGQIndexArray); IMPiEnv_OctTree_LeafNode_CreateBNVList(leafNode, inBuildData, inOTData, inBNVIndexCount, inBNVIndexArray); - + return UUcError_None; } - // we are in an interior node + // we are in an interior node if(outChildIndex != NULL) { *outChildIndex = nodeIndex; } - + childGQIndexArray = top_of_stack; top_of_stack += inGQIndexCount; - + childBNVIndexArray = top_of_stack; top_of_stack += inBNVIndexCount; - + UUmAssert((top_of_stack >= IMPgOctree2_StackBase) && (top_of_stack < IMPgOctree2_StackMax)); - + nodeCenterX = (inBoundingBox->minPoint.x + inBoundingBox->maxPoint.x) * 0.5f; nodeCenterY = (inBoundingBox->minPoint.y + inBoundingBox->maxPoint.y) * 0.5f; nodeCenterZ = (inBoundingBox->minPoint.z + inBoundingBox->maxPoint.z) * 0.5f; - + // First find all the leaf nodes for(childOctantItr = 0; childOctantItr < 8; childOctantItr++) { childBBox.minPoint.x = (childOctantItr & AKcOctTree_SideBV_X) ? nodeCenterX : inBoundingBox->minPoint.x; childBBox.minPoint.y = (childOctantItr & AKcOctTree_SideBV_Y) ? nodeCenterY : inBoundingBox->minPoint.y; childBBox.minPoint.z = (childOctantItr & AKcOctTree_SideBV_Z) ? nodeCenterZ : inBoundingBox->minPoint.z; - + childBBox.maxPoint.x = (childOctantItr & AKcOctTree_SideBV_X) ? inBoundingBox->maxPoint.x : nodeCenterX; childBBox.maxPoint.y = (childOctantItr & AKcOctTree_SideBV_Y) ? inBoundingBox->maxPoint.y : nodeCenterY; childBBox.maxPoint.z = (childOctantItr & AKcOctTree_SideBV_Z) ? inBoundingBox->maxPoint.z : nodeCenterZ; @@ -1241,7 +1241,7 @@ IMPiEnv_OctTree_Build_Recursive( &childGQIndexCount); childGQTotal += childGQIndexCount; - + IMPiEnv_OctTree_FindIntersectionBNVs( inBuildData, inBNVIndexCount, @@ -1251,8 +1251,8 @@ IMPiEnv_OctTree_Build_Recursive( &childBNVIndexCount); childBNVTotal += childBNVIndexCount; - - error = + + error = IMPiEnv_OctTree_Build_Recursive( inBuildData, inOTData, @@ -1268,10 +1268,10 @@ IMPiEnv_OctTree_Build_Recursive( &interiorNode->children[childOctantItr]); UUmError_ReturnOnError(error); } - + UUmAssert(childGQTotal >= inGQIndexCount); UUmAssert(childBNVTotal >= inBNVIndexCount); - + return UUcError_None; } @@ -1288,19 +1288,19 @@ IMPiEnv_OctTree_Build_AdjInfo_ForSide( UUtError error; UUtUns32 adjInfoIndex; AKtOctTree_LeafNode* leafNode; - + adjInfoIndex = inNodeExtraInfo->adjacent[inSide]; - + leafNode = inOTData->leafNodes + inNodeIndex; - + if(AKmOctTree_IsLeafNode(adjInfoIndex)) { leafNode->adjInfo[inSide] = adjInfoIndex; - + return UUcError_None; } - - error = + + error = IMPiEnv_QuadTree_Build( inBuildData, inOTData, @@ -1308,7 +1308,7 @@ IMPiEnv_OctTree_Build_AdjInfo_ForSide( adjInfoIndex, &leafNode->adjInfo[inSide]); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1319,14 +1319,14 @@ IMPiEnv_OctTree_Build_AdjInfo( { UUtError error; IMPtEnv_OTExtraNodeInfo* curExtraNodeInfo; - UUtUns32 nodeIndexItr; + UUtUns32 nodeIndexItr; for(nodeIndexItr = 0, curExtraNodeInfo = inOTData->leafNodeExtras; nodeIndexItr < inOTData->nextLeafNodeIndex; nodeIndexItr++, curExtraNodeInfo++) { // Compute info for neg x side - error = + error = IMPiEnv_OctTree_Build_AdjInfo_ForSide( inBuildData, inOTData, @@ -1337,7 +1337,7 @@ IMPiEnv_OctTree_Build_AdjInfo( 0); UUmError_ReturnOnError(error); // Compute info for pos x side - error = + error = IMPiEnv_OctTree_Build_AdjInfo_ForSide( inBuildData, inOTData, @@ -1347,9 +1347,9 @@ IMPiEnv_OctTree_Build_AdjInfo( AKcOctTree_SideAxis_X, 1); UUmError_ReturnOnError(error); - + // Compute info for neg y side - error = + error = IMPiEnv_OctTree_Build_AdjInfo_ForSide( inBuildData, inOTData, @@ -1360,7 +1360,7 @@ IMPiEnv_OctTree_Build_AdjInfo( 0); UUmError_ReturnOnError(error); // Compute info for pos y side - error = + error = IMPiEnv_OctTree_Build_AdjInfo_ForSide( inBuildData, inOTData, @@ -1370,9 +1370,9 @@ IMPiEnv_OctTree_Build_AdjInfo( AKcOctTree_SideAxis_Y, 1); UUmError_ReturnOnError(error); - + // Compute info for neg z side - error = + error = IMPiEnv_OctTree_Build_AdjInfo_ForSide( inBuildData, inOTData, @@ -1383,7 +1383,7 @@ IMPiEnv_OctTree_Build_AdjInfo( 0); UUmError_ReturnOnError(error); // Compute info for pos z side - error = + error = IMPiEnv_OctTree_Build_AdjInfo_ForSide( inBuildData, inOTData, @@ -1394,7 +1394,7 @@ IMPiEnv_OctTree_Build_AdjInfo( 1); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -1413,7 +1413,7 @@ IMPiEnv_OctTree_Build_ExtraInfo_ForSide( UUtUns32 curOctant; UUtUns32 octantStack[16]; UUtInt16 octantTOS = 0; - + if(AKmOctTree_IsLeafNode(curNodeIndex)) { UUmAssert(AKmOctTree_GetLeafIndex(curNodeIndex) < inOTData->nextLeafNodeIndex); @@ -1422,7 +1422,7 @@ IMPiEnv_OctTree_Build_ExtraInfo_ForSide( { UUmAssert(curNodeIndex < inOTData->nextInteriorNodeIndex); } - + // go up until we can move into a sibling while(1) { @@ -1431,9 +1431,9 @@ IMPiEnv_OctTree_Build_ExtraInfo_ForSide( inNodeExtraInfo->adjacent[inSide] = 0xFFFFFFFF; return; } - + octantStack[octantTOS++] = curNodeExtraInfo->myOctant; - + if(inPosNeg) { if(!(curNodeExtraInfo->myOctant & inAxis)) break; @@ -1442,37 +1442,37 @@ IMPiEnv_OctTree_Build_ExtraInfo_ForSide( { if(curNodeExtraInfo->myOctant & inAxis) break; } - + curNodeIndex = curNodeExtraInfo->parent; - + UUmAssert(curNodeIndex < inOTData->nextInteriorNodeIndex); curNodeExtraInfo = inOTData->interiorNodeExtras + curNodeIndex; } - + UUmAssert(curNodeExtraInfo->myOctant != 0xFFFFFFFF); - + UUmAssert(inNodeExtraInfo->depth >= curNodeExtraInfo->depth); - + curNodeIndex = curNodeExtraInfo->parent; - + while(octantTOS > 0) { curOctant = octantStack[--octantTOS]; - + UUmAssert(curOctant < 8); - + curOctant = (curOctant & ~inAxis) | (~curOctant & inAxis); - + potentialNextIndex = inOTData->interiorNodes[curNodeIndex].children[curOctant]; - + UUmAssert(potentialNextIndex != 0xFFFFFFFF); - + curNodeIndex = potentialNextIndex; - + if(AKmOctTree_IsLeafNode(curNodeIndex)) break; } - + if(!AKmOctTree_IsLeafNode(curNodeIndex)) { curNodeExtraInfo = inOTData->interiorNodeExtras + curNodeIndex; @@ -1492,8 +1492,8 @@ IMPiEnv_OctTree_Build_ExtraInfo( IMPtEnv_OTData* inOTData) { IMPtEnv_OTExtraNodeInfo* curExtraNodeInfo; - UUtUns32 nodeIndexItr; - + UUtUns32 nodeIndexItr; + for(nodeIndexItr = 0, curExtraNodeInfo = inOTData->interiorNodeExtras; nodeIndexItr < inOTData->nextInteriorNodeIndex; nodeIndexItr++, curExtraNodeInfo++) @@ -1514,7 +1514,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( AKcOctTree_Side_PosX, AKcOctTree_SideBV_X, 1); - + // Compute info for neg y side IMPiEnv_OctTree_Build_ExtraInfo_ForSide( inOTData, @@ -1531,7 +1531,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( AKcOctTree_Side_PosY, AKcOctTree_SideBV_Y, 1); - + // Compute info for neg z side IMPiEnv_OctTree_Build_ExtraInfo_ForSide( inOTData, @@ -1549,7 +1549,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( AKcOctTree_SideBV_Z, 1); } - + for(nodeIndexItr = 0, curExtraNodeInfo = inOTData->leafNodeExtras; nodeIndexItr < inOTData->nextLeafNodeIndex; nodeIndexItr++, curExtraNodeInfo++) @@ -1570,7 +1570,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( AKcOctTree_Side_PosX, AKcOctTree_SideBV_X, 1); - + // Compute info for neg y side IMPiEnv_OctTree_Build_ExtraInfo_ForSide( inOTData, @@ -1587,7 +1587,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( AKcOctTree_Side_PosY, AKcOctTree_SideBV_Y, 1); - + // Compute info for neg z side IMPiEnv_OctTree_Build_ExtraInfo_ForSide( inOTData, @@ -1605,7 +1605,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( AKcOctTree_SideBV_Z, 1); } - + for(nodeIndexItr = 0, curExtraNodeInfo = inOTData->interiorNodeExtras; nodeIndexItr < inOTData->nextInteriorNodeIndex; nodeIndexItr++, curExtraNodeInfo++) @@ -1616,7 +1616,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( UUmAssert(inOTData->interiorNodeExtras[curExtraNodeInfo->parent].depth == curExtraNodeInfo->depth - 1); UUmAssert(inOTData->interiorNodeExtras[curExtraNodeInfo->parent].dimIndex == curExtraNodeInfo->dimIndex + 1); } - + // Verify IMPiEnv_OctTree_Verify_ExtraInfo_Adjacent( inOTData, @@ -1629,7 +1629,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( curExtraNodeInfo, nodeIndexItr, AKcOctTree_Side_PosX); - + // Verify IMPiEnv_OctTree_Verify_ExtraInfo_Adjacent( inOTData, @@ -1642,7 +1642,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( curExtraNodeInfo, nodeIndexItr, AKcOctTree_Side_PosY); - + // Verify IMPiEnv_OctTree_Verify_ExtraInfo_Adjacent( inOTData, @@ -1656,7 +1656,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( nodeIndexItr, AKcOctTree_Side_PosZ); } - + for(nodeIndexItr = 0, curExtraNodeInfo = inOTData->leafNodeExtras; nodeIndexItr < inOTData->nextLeafNodeIndex; nodeIndexItr++, curExtraNodeInfo++) @@ -1681,7 +1681,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( curExtraNodeInfo, AKmOctTree_MakeLeafIndex(nodeIndexItr), AKcOctTree_Side_PosX); - + // Verify IMPiEnv_OctTree_Verify_ExtraInfo_Adjacent( inOTData, @@ -1694,7 +1694,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( curExtraNodeInfo, AKmOctTree_MakeLeafIndex(nodeIndexItr), AKcOctTree_Side_PosY); - + // Verify IMPiEnv_OctTree_Verify_ExtraInfo_Adjacent( inOTData, @@ -1709,7 +1709,7 @@ IMPiEnv_OctTree_Build_ExtraInfo( AKcOctTree_Side_PosZ); } } - + static UUtError IMPiEnv_OctTree_Build( IMPtEnv_BuildData* inBuildData, @@ -1717,7 +1717,7 @@ IMPiEnv_OctTree_Build( { UUtError error; UUtUns32 i; - + UUtUns32* initialGQIndexArray; UUtUns32* initialBNVIndexArray; UUtUns32 oct_tree_stack_size; @@ -1740,21 +1740,21 @@ IMPiEnv_OctTree_Build( top_of_stack = initial_stack; initialGQIndexArray = top_of_stack; - top_of_stack += inBuildData->numGQs; - - for(i = 0; i < inBuildData->numGQs; i++) + top_of_stack += inBuildData->numGQs; + + for(i = 0; i < inBuildData->numGQs; i++) { initialGQIndexArray[i] = i; } - + initialBNVIndexArray = top_of_stack; - top_of_stack += inBuildData->numBNVs; - + top_of_stack += inBuildData->numBNVs; + for(i = 0; i < inBuildData->numBNVs; i++) { initialBNVIndexArray[i] = i; } - + bBox.minPoint.x = -AKcMaxHalfOTDim; bBox.minPoint.y = -AKcMaxHalfOTDim; bBox.minPoint.z = -AKcMaxHalfOTDim; @@ -1762,7 +1762,7 @@ IMPiEnv_OctTree_Build( bBox.maxPoint.y = AKcMaxHalfOTDim; bBox.maxPoint.z = AKcMaxHalfOTDim; - + error = IMPiEnv_OctTree_Build_Recursive( inBuildData, @@ -1779,26 +1779,26 @@ IMPiEnv_OctTree_Build( NULL); Imp_PrintMessage(IMPcMsg_Important, ""UUmNL); - Imp_PrintMessage(IMPcMsg_Important, "compaction saved %d/%d -> %d/%d = %d/%d (bnv/gq),bytes"UUmNL, + Imp_PrintMessage(IMPcMsg_Important, "compaction saved %d/%d -> %d/%d = %d/%d (bnv/gq),bytes"UUmNL, oct_tree_bnv_memory_saved + (inOTData->nextBNVIndex * 2), oct_tree_gq_memory_saved + (inOTData->nextGQIndex * 2), inOTData->nextBNVIndex * 2, inOTData->nextGQIndex * 2, oct_tree_bnv_memory_saved, oct_tree_gq_memory_saved); - + UUrMemory_Block_Delete(initial_stack); - + IMPiEnv_OctTree_Build_ExtraInfo( inBuildData, inOTData); - - error = + + error = IMPiEnv_OctTree_Build_AdjInfo( inBuildData, inOTData); UUmError_ReturnOnError(error); - - + + IMPiEnv_OctTree_Verify(inOTData); - + return error; } @@ -1811,41 +1811,41 @@ IMPrEnv_Process_OctTrees2( M3tPoint3D* pointArray; float globalMinX, globalMinY, globalMinZ; float globalMaxX, globalMaxY, globalMaxZ; - + UUtUns32 curPointIndex; M3tPoint3D* curPoint; UUtUns32 numPoints; UUtInt64 time; - + IMPtEnv_GQ* newGQList; UUtUns32 itr; UUtUns32 point_NumRemapped; UUtUns32* point_RemapArray; IMPtEnv_GQ* curGQ; UUtUns32 vertexItr; - + M3tQuad* curQuad; M3tQuad* quadList; UUtUns32 numQuads; - + gGQ_NumRemapped = 0; gGQ_RemapArray = UUrMemory_Block_New(inBuildData->numGQs * sizeof(UUtUns32)); UUmError_ReturnOnNull(gGQ_RemapArray); gGQ_RemapArray_CreateGQList = UUrMemory_Block_New(inBuildData->numGQs * sizeof(UUtUns32)); - UUmError_ReturnOnNull(gGQ_RemapArray_CreateGQList); - + UUmError_ReturnOnNull(gGQ_RemapArray_CreateGQList); + UUrMemory_Set32(gGQ_RemapArray, 0xFFFFFFFF, inBuildData->numGQs * sizeof(UUtUns32)); - + newGQList = UUrMemory_Block_New(inBuildData->numGQs * sizeof(IMPtEnv_GQ)); UUmError_ReturnOnNull(newGQList); - + globalMinX = globalMinY = globalMinZ = 1e9; globalMaxX = globalMaxY = globalMaxZ = -1e9; pointArray = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); numPoints = AUrSharedPointArray_GetNum(inBuildData->sharedPointArray); - + // First find the global min max for(curPointIndex = 0, curPoint = pointArray; curPointIndex < numPoints; @@ -1870,7 +1870,7 @@ IMPrEnv_Process_OctTrees2( IMPrEnv_LogError("Exceeded max environment dimension - octree bounds (%f %f %f) - (%f %f %f)", globalMinX, globalMinY, globalMinZ, globalMaxX, globalMaxY, globalMaxZ); } - + // Compute Oct Tree for collision detection time = UUrMachineTime_High(); @@ -1883,7 +1883,7 @@ IMPrEnv_Process_OctTrees2( time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); - + // Fill the rest of the remap array for(itr = 0; itr < inBuildData->numGQs; itr++) { @@ -1892,20 +1892,20 @@ IMPrEnv_Process_OctTrees2( gGQ_RemapArray[itr] = gGQ_NumRemapped++; } } - + UUmAssert(gGQ_NumRemapped == inBuildData->numGQs); - + for(itr = 0; itr < inBuildData->numGQs; itr++) { newGQList[gGQ_RemapArray[itr]] = inBuildData->gqList[itr]; } - - UUrMemory_Block_Delete(gGQ_RemapArray); - UUrMemory_Block_Delete(gGQ_RemapArray_CreateGQList); + + UUrMemory_Block_Delete(gGQ_RemapArray); + UUrMemory_Block_Delete(gGQ_RemapArray_CreateGQList); UUrMemory_Block_Delete(inBuildData->gqList); - + inBuildData->gqList = newGQList; - + AUrSharedElemArray_Resort((AUtSharedElemArray*)inBuildData->sharedPointArray); point_NumRemapped = 0; @@ -1913,9 +1913,9 @@ IMPrEnv_Process_OctTrees2( UUrMemory_Block_New( AUrSharedPointArray_GetNum(inBuildData->sharedPointArray) * sizeof(UUtUns32)); UUmError_ReturnOnNull(point_RemapArray); - + UUrMemory_Set32(point_RemapArray, 0xFFFFFFFF, AUrSharedPointArray_GetNum(inBuildData->sharedPointArray) * sizeof(UUtUns32)); - + for(itr = 0, curGQ = inBuildData->gqList; itr < inBuildData->numGQs; itr++, curGQ++) @@ -1929,10 +1929,10 @@ IMPrEnv_Process_OctTrees2( curGQ->visibleQuad.indices[vertexItr] = point_RemapArray[curGQ->visibleQuad.indices[vertexItr]]; } } - + quadList = AUrSharedQuadArray_GetList(inBuildData->sharedBNVQuadArray); numQuads = AUrSharedQuadArray_GetNum(inBuildData->sharedBNVQuadArray); - + for(itr = 0, curQuad = quadList; itr < numQuads; itr++, curQuad++) @@ -1946,7 +1946,7 @@ IMPrEnv_Process_OctTrees2( curQuad->indices[vertexItr] = point_RemapArray[curQuad->indices[vertexItr]]; } } - + for(itr = 0; itr < AUrSharedPointArray_GetNum(inBuildData->sharedPointArray); itr++) @@ -1956,21 +1956,21 @@ IMPrEnv_Process_OctTrees2( point_RemapArray[itr] = point_NumRemapped++; } } - + UUmAssert(point_NumRemapped == AUrSharedPointArray_GetNum(inBuildData->sharedPointArray)); - + error = AUrSharedPointArray_Reorder(inBuildData->sharedPointArray, point_RemapArray); UUmError_ReturnOnError(error); - + UUrMemory_Block_Delete(point_RemapArray); - + AUrSharedQuadArray_Resort(inBuildData->sharedBNVQuadArray); pointArray = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); - + fprintf(IMPgEnv_StatsFile, "**ot stats"UUmNL); IMPiEnv_OctTree_PrintStats(IMPgEnv_StatsFile, &inBuildData->otData); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Parse.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Parse.c index cc1cd8a..c7b2c72 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Parse.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Parse.c @@ -5,8 +5,8 @@ CREATED: Sept 3, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ @@ -69,7 +69,7 @@ float IMPgEnv_LS_FieldAngle; extern GRtGroup* gPreferencesGroup; -AUtFlagElement IMPgLSParamFlags[] = +AUtFlagElement IMPgLSParamFlags[] = { { "not_occluding", @@ -89,7 +89,7 @@ AUtFlagElement IMPgLSParamFlags[] = } }; -AUtFlagElement IMPgGunkFlags[] = +AUtFlagElement IMPgGunkFlags[] = { { "door", @@ -165,7 +165,7 @@ AUtFlagElement IMPgGunkFlags[] = } }; -AUtFlagElement IMPgLMFlags[] = +AUtFlagElement IMPgLMFlags[] = { { "forceon", @@ -225,7 +225,7 @@ AUtFlagElement IMPgGunkObjectFlags[] = } }; -AUtFlagElement IMPgBNVFlags[] = +AUtFlagElement IMPgBNVFlags[] = { { "stairs", @@ -254,8 +254,8 @@ static UUtUns32 IMPiEnv_Parse_GQ_ObjectTag( GRtGroup* inGroup, IMPtEnv_BuildData UUtError error; UUtUns32 object_tag; - error = GRrGroup_GetUns32(inGroup,"object_tag", &object_tag); - if (error == UUcError_None) + error = GRrGroup_GetUns32(inGroup,"object_tag", &object_tag); + if (error == UUcError_None) { return object_tag; } @@ -267,7 +267,7 @@ void IMPrEnv_Add_ObjectTag( IMPtEnv_BuildData* inBuildData, UUtUns32 inTag, UUtU UUtError error; UUtUns32* array; UUtUns32 new_index; - + UUmAssert( inBuildData->object_tags && inBuildData->object_quads ); error = UUrMemory_Array_GetNewElement( inBuildData->object_tags, &new_index, NULL ); @@ -288,25 +288,25 @@ IMPiEnv_Parse_Point( const MXtPoint* inPoint) { UUtError error; - + if(index >= IMPcEnv_MaxRemapPoints) { Imp_PrintWarning("exceeded max remap indices"); return UUcError_Generic; } - + IMPgEnv_RawPoints[index] = inPoint->point; AUrSharedPointArray_RoundPoint(IMPgEnv_RawPoints + index); - + error = AUrSharedPointArray_AddPoint( inBuildData->sharedPointArray, inPoint->point.x, inPoint->point.y, inPoint->point.z, &IMPgEnv_PointIndexRemap[index]); UUmError_ReturnOnErrorMsg(error, "Could not add point"); - + IMPgEnv_TextureCoords[index] = inPoint->uv; - + return UUcError_None; } @@ -323,7 +323,7 @@ IMPiEnv_Parse_Point_ForFlag( } inFlagPoints[index] = inPoint->point; - + return UUcError_None; } @@ -340,10 +340,10 @@ IMPiEnv_Parse_BNV_AddQuad( UUtError error; UUtUns32 quadIndex; IMPtEnv_BNV* curBNV; - + UUtUns16 curSideIndex; IMPtEnv_BNV_Side* curSide; - + M3tPoint3D* shared_point_list = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); M3tPoint3D* curPoint; float d; @@ -364,7 +364,7 @@ IMPiEnv_Parse_BNV_AddQuad( ny = normal.y; nz = normal.z; } - + planeArray = AUrSharedPlaneEquArray_GetList(inBuildData->sharedPlaneEquArray); // Add the quad @@ -374,15 +374,15 @@ IMPiEnv_Parse_BNV_AddQuad( ri0, ri1, ri2, ri3, &quadIndex); UUmError_ReturnOnErrorMsg(error, "Could not add quad"); - + // Compute the temporary plane equation curPoint = AUrSharedPointArray_GetList(inBuildData->sharedPointArray) + ri0; - + d = -(curPoint->x * nx + curPoint->y * ny + curPoint->z * nz); - - + + curBNV = inBuildData->bnvList + inBuildData->numBNVs; - + // check for other quads on this plane for(curSideIndex = 0, curSide = curBNV->sides; curSideIndex < curBNV->numSides; @@ -392,7 +392,7 @@ IMPiEnv_Parse_BNV_AddQuad( curSide->planeEquIndex, planeArray, sideA, sideB, sideC, sideD); - + if(UUmFloat_CompareEqu(sideA, nx) && UUmFloat_CompareEqu(sideB, ny) && UUmFloat_CompareEqu(sideC, nz) && @@ -403,38 +403,38 @@ IMPiEnv_Parse_BNV_AddQuad( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Too many side BNV quads"); } - + curSide->bnvQuadList[curSide->numBNVQuads++] = quadIndex; - + return UUcError_None; } } - + if(curBNV->numSides >= IMPcEnv_MaxBNVSides) { UUmError_ReturnOnErrorMsgP( - UUcError_Generic, + UUcError_Generic, "Exceeeded max BNV sides on file \"%s\", thank Brent.", (UUtUns32)curBNV->fileName, 0, 0); } - + curSide = curBNV->sides + curBNV->numSides++; - + curSide->numGQGhostIndices = 0; - + curSide->numBNVQuads = 1; curSide->bnvQuadList[0] = quadIndex; - + error = AUrSharedPlaneEquArray_AddPlaneEqu( inBuildData->sharedPlaneEquArray, nx, ny, nz, d, &curSide->planeEquIndex); UUmError_ReturnOnError(error); - + return UUcError_None; } - + static UUtError IMPiEnv_Parse_BNV_Quad( IMPtEnv_BuildData* inBuildData, @@ -442,19 +442,19 @@ IMPiEnv_Parse_BNV_Quad( { UUtError error; UUtUns32 ri0, ri1, ri2, ri3; - + ri0 = IMPgEnv_PointIndexRemap[inFace->indices[0]]; ri1 = IMPgEnv_PointIndexRemap[inFace->indices[1]]; ri2 = IMPgEnv_PointIndexRemap[inFace->indices[2]]; ri3 = IMPgEnv_PointIndexRemap[inFace->indices[3]]; - + error = IMPiEnv_Parse_BNV_AddQuad( inBuildData, ri0, ri1, ri2, ri3, &inFace->dont_use_this_normal); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -465,34 +465,34 @@ IMPiEnv_Parse_BNV_Tri( { UUtError error; UUtUns32 ri0, ri1, ri2, ri3; - + float midX, midY, midZ; M3tPoint3D* sharedPoints; - + sharedPoints = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); - + ri0 = IMPgEnv_PointIndexRemap[inFace->indices[0]]; ri1 = IMPgEnv_PointIndexRemap[inFace->indices[1]]; ri2 = IMPgEnv_PointIndexRemap[inFace->indices[2]]; - + midX = (sharedPoints[ri0].x + sharedPoints[ri2].x) * 0.5f; midY = (sharedPoints[ri0].y + sharedPoints[ri2].y) * 0.5f; midZ = (sharedPoints[ri0].z + sharedPoints[ri2].z) * 0.5f; - + error = AUrSharedPointArray_AddPoint( inBuildData->sharedPointArray, midX, midY, midZ, &ri3); UUmError_ReturnOnErrorMsg(error, "Could not add point"); - + error = IMPiEnv_Parse_BNV_AddQuad( inBuildData, ri0, ri1, ri2, ri3, &inFace->dont_use_this_normal); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -512,7 +512,7 @@ IMPiEnv_Parse_BNV( MXtNode* curNode; MXtPoint* curPoint; MXtFace* curFace; - + UUtUns16 nodeItr; UUtUns16 faceItr; UUtUns16 pointItr; @@ -521,7 +521,7 @@ IMPiEnv_Parse_BNV( for(nodeItr = 0, curNode = inEnvData->nodes; nodeItr < inEnvData->numNodes; nodeItr++, curNode++) { UUmAssert(inBuildData->numBNVs < inBuildData->maxBNVs); - + if (UUrString_HasPrefix(curNode->name, IMPcGunkFlagNamePrefix) || UUrString_HasPrefix(curNode->name, IMPcParticle2Prefix) || UUrString_HasPrefix(curNode->name, IMPcFXPrefix)) @@ -532,20 +532,20 @@ IMPiEnv_Parse_BNV( } curBNV = inBuildData->bnvList + inBuildData->numBNVs; - + bnvFlags = 0; - + // Read user data for BNVs if(curNode->userDataCount > 0 && *curNode->userData != 0) { // We have user data, so parse it error = GRrGroup_Context_NewFromString(curNode->userData,gPreferencesGroup,NULL,&groupContext,&group); UUmError_ReturnOnError(error); - + // Read off the BNV property flags error = GRrGroup_GetElement(group, "type", &groupType, &groupFlags); if(error == UUcError_None) { - error = + error = AUrFlags_ParseFromGroupArray( IMPgBNVFlags, groupType, @@ -555,11 +555,11 @@ IMPiEnv_Parse_BNV( GRrGroup_Context_Delete(groupContext); } - + curBNV->flags = bnvFlags; - - // read the world - + + // read the world + curBNV->parent = 0xFFFFFFFF; curBNV->level = 0xFFFFFFFF; curBNV->child = 0xFFFFFFFF; @@ -569,14 +569,14 @@ IMPiEnv_Parse_BNV( curBNV->isLeaf = 0; curBNV->error = UUcFalse; curBNV->numGQs = 0; - + UUrString_Copy(curBNV->fileName, inFileName, IMPcEnv_MaxNameLength); UUrString_Copy(curBNV->objName, curNode->name, IMPcEnv_MaxNameLength); for(pointItr = 0, curPoint = curNode->points; pointItr < curNode->numPoints; pointItr++, curPoint++) { MUrMatrix_MultiplyPoint(&curPoint->point, &curNode->matrix, &curPoint->point); - + error = IMPiEnv_Parse_Point(inBuildData, pointItr, curPoint); UUmError_ReturnOnError(error); @@ -599,7 +599,7 @@ IMPiEnv_Parse_BNV( error = IMPiEnv_Parse_BNV_Tri(inBuildData, curFace); UUmError_ReturnOnError(error); } - + for(faceItr = 0, curFace = curNode->quads; faceItr < curNode->numQuads; faceItr++, curFace++) { MUrMatrix_MultiplyNormal(&curFace->dont_use_this_normal, &curNode->matrix, &curFace->dont_use_this_normal); @@ -610,7 +610,7 @@ IMPiEnv_Parse_BNV( inBuildData->numBNVs++; } - + return UUcError_None; } @@ -618,12 +618,12 @@ IMPiEnv_Parse_BNV( static UUtUns16 IMPiEnv_Parse_GQ_AddTexture( IMPtEnv_BuildData* inBuildData, const char* inTextureName) { UUtError error; - + UUtUns16 newIndex; char fileName[BFcMaxFileNameLength]; - + UUmAssert(*inTextureName != 0); - + if(1 || !(IMPg_Gunk_Flags & AKcGQ_Flag_NoTextureMask)) { UUtUns32 temp; @@ -631,8 +631,8 @@ static UUtUns16 IMPiEnv_Parse_GQ_AddTexture( IMPtEnv_BuildData* inBuildData, con UUrString_Copy(fileName, inTextureName, BFcMaxFileNameLength); UUrString_Capitalize(fileName, BFcMaxFileNameLength); UUrString_StripExtension(fileName); - - error = + + error = AUrSharedStringArray_AddString( inBuildData->textureMapArray, fileName, @@ -651,7 +651,7 @@ static UUtUns16 IMPiEnv_Parse_GQ_AddTexture( IMPtEnv_BuildData* inBuildData, con { newIndex = 0xFFFF; } - + return newIndex; } @@ -682,9 +682,9 @@ IMPiEnv_Parse_GQ_AddQuadProperSize( M3tVector3D edge0, edge1, edge2; M3tVector3D normal0, normal1; float dot; - + pointArray = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); - + // Check for degenerate quads if(ri0 == ri1 || ri0 == ri2 || ri0 == ri3 || ri1 == ri2 || ri1 == ri3) @@ -698,7 +698,7 @@ IMPiEnv_Parse_GQ_AddQuadProperSize( } return UUcError_None; } - + if(ri2 == ri3 && !(localFlags & AKcGQ_Flag_Triangle)) { // this GQ should be triangular @@ -776,13 +776,13 @@ IMPiEnv_Parse_GQ_AddQuadProperSize( MUmVector_Subtract(edge2, pointArray[ri3], pointArray[ri0]); MUrVector_CrossProduct(&edge0, &edge1, &normal0); - MUrVector_CrossProduct(&edge1, &edge2, &normal1); + MUrVector_CrossProduct(&edge1, &edge2, &normal1); dot = MUrVector_DotProduct(&normal0, &normal1); if(dot < 0) { IMPrEnv_LogError("pretzel quad, %s, %s, %s [norm012 %f %f %f, norm023 %f %f %f orig_n %f %f %f] dot %f...", - IMPg_Gunk_FileName, IMPg_Gunk_ObjName, IMPg_Gunk_TextureName, + IMPg_Gunk_FileName, IMPg_Gunk_ObjName, IMPg_Gunk_TextureName, normal0.x, normal0.y, normal0.z, normal1.x, normal1.y, normal1.z, nx, ny, nz, dot); @@ -808,23 +808,23 @@ IMPiEnv_Parse_GQ_AddQuadProperSize( } // FIXME: check for concave quads? - - + + if(inBuildData->numGQs >= inBuildData->maxGQs) { UUmError_ReturnOnErrorMsgP( - UUcError_Generic, + UUcError_Generic, "Exceeeded max num GQs in file \"%s\".", (UUtUns32)IMPg_Gunk_FileName, 0, 0); } - + if (!(inBuildData->numGQs % 500)) Imp_PrintMessage(IMPcMsg_Important, "."); curGQ = inBuildData->gqList + inBuildData->numGQs; curGQ->object_tag = IMPg_Gunk_ObjectTag; - + curGQ->ghostUsed = UUcFalse; curGQ->stairBNVIndex = (UUtUns32) -1; @@ -832,38 +832,38 @@ IMPiEnv_Parse_GQ_AddQuadProperSize( curGQ->visibleQuad.indices[1] = ri1; curGQ->visibleQuad.indices[2] = ri2; curGQ->visibleQuad.indices[3] = ri3; - + UUrMemory_Clear(curGQ->gqMaterialName, IMPcEnv_MaxNameLength); - + curTextureIndex = IMPiEnv_Parse_GQ_AddTexture(inBuildData, IMPg_Gunk_TextureName); - + if(!(IMPg_Gunk_Flags & AKcGQ_Flag_NoTextureMask)) { - error = + error = AUrSharedTexCoordArray_AddTexCoord( inBuildData->sharedTextureCoordArray, inBaseTextureCoords[0].u, inBaseTextureCoords[0].v, &curGQ->baseMapIndices.indices[0]); UUmError_ReturnOnError(error); - - error = + + error = AUrSharedTexCoordArray_AddTexCoord( inBuildData->sharedTextureCoordArray, inBaseTextureCoords[1].u, inBaseTextureCoords[1].v, &curGQ->baseMapIndices.indices[1]); UUmError_ReturnOnError(error); - - error = + + error = AUrSharedTexCoordArray_AddTexCoord( inBuildData->sharedTextureCoordArray, inBaseTextureCoords[2].u, inBaseTextureCoords[2].v, &curGQ->baseMapIndices.indices[2]); UUmError_ReturnOnError(error); - - error = + + error = AUrSharedTexCoordArray_AddTexCoord( inBuildData->sharedTextureCoordArray, inBaseTextureCoords[3].u, @@ -873,31 +873,31 @@ IMPiEnv_Parse_GQ_AddQuadProperSize( } else { - error = + error = AUrSharedTexCoordArray_AddTexCoord( inBuildData->sharedTextureCoordArray, 0.0f, 0.0f, &curGQ->baseMapIndices.indices[0]); UUmError_ReturnOnError(error); - - error = + + error = AUrSharedTexCoordArray_AddTexCoord( inBuildData->sharedTextureCoordArray, 1.0f, 0.0f, &curGQ->baseMapIndices.indices[1]); UUmError_ReturnOnError(error); - - error = + + error = AUrSharedTexCoordArray_AddTexCoord( inBuildData->sharedTextureCoordArray, 1.0f, 1.0f, &curGQ->baseMapIndices.indices[2]); UUmError_ReturnOnError(error); - - error = + + error = AUrSharedTexCoordArray_AddTexCoord( inBuildData->sharedTextureCoordArray, 0.0f, @@ -905,23 +905,23 @@ IMPiEnv_Parse_GQ_AddQuadProperSize( &curGQ->baseMapIndices.indices[3]); UUmError_ReturnOnError(error); } - + curGQ->textureMapIndex = curTextureIndex; - + /* curGQ->adjGQIndices[0] = 0xFFFFFFFF; curGQ->adjGQIndices[1] = 0xFFFFFFFF; curGQ->adjGQIndices[2] = 0xFFFFFFFF; curGQ->adjGQIndices[3] = 0xFFFFFFFF;*/ - + curPoint = pointArray + curGQ->visibleQuad.indices[0]; //d = -(curPoint->x * nx + curPoint->y * ny + curPoint->z * nz); - error = + error = AUrSharedPlaneEquArray_AddPlaneEqu( inBuildData->sharedPlaneEquArray, nx, ny, nz, realD, &curGQ->planeEquIndex); UUmError_ReturnOnError(error); - + curGQ->flags = IMPg_Gunk_Flags | localFlags; curGQ->lmFlags = IMPg_Gunk_LMFlags; curGQ->scriptID = IMPg_Gunk_ScriptID; @@ -947,31 +947,31 @@ IMPiEnv_Parse_GQ_AddQuadProperSize( pointArray[curGQ->visibleQuad.indices[3]].z); return UUcError_None; } - + UUrString_Copy(curGQ->fileName, IMPg_Gunk_FileName, IMPcEnv_MaxNameLength); UUrString_Copy(curGQ->objName, IMPg_Gunk_ObjName, IMPcEnv_MaxNameLength); UUrString_Copy(curGQ->materialName, IMPg_Gunk_MaterialName, IMPcEnv_MaxNameLength); - + // Add LS info curGQ->fileRelativeGQIndex = IMPg_Gunk_FileRelativeGQIndex++; - + curGQ->isLuminaire = IMPgEnv_LS; if(curGQ->isLuminaire) { curGQ->filterColor[0] = IMPgEnv_LS_FilterColor[0]; curGQ->filterColor[1] = IMPgEnv_LS_FilterColor[1]; curGQ->filterColor[2] = IMPgEnv_LS_FilterColor[2]; - + curGQ->lightType = IMPgEnv_LS_Type; - + curGQ->intensity = IMPgEnv_LS_Intensity; - + curGQ->distribution = IMPgEnv_LS_Distribution; curGQ->beamAngle = IMPgEnv_LS_BeamAngle; curGQ->fieldAngle = IMPgEnv_LS_FieldAngle; } curGQ->lightParams = IMPgEnv_LS_ParamFlags; - + // testing if(0 && inBuildData->numGQs == 0) { @@ -982,16 +982,16 @@ IMPiEnv_Parse_GQ_AddQuadProperSize( curGQ->lightType = IMPcLS_LightType_Area; curGQ->intensity = 3800000; } - + // check for nonplanar problems planeProblem = UUcFalse; maxDist = -1e13f; for(i = 1; i < 4; i++) { curPoint = pointArray + curGQ->visibleQuad.indices[i]; - + testD = -(curPoint->x * nx + curPoint->y * ny + curPoint->z * nz); - + curDist = (float)fabs(realD - testD); if(curDist > 0.01f) { @@ -999,7 +999,7 @@ IMPiEnv_Parse_GQ_AddQuadProperSize( if(curDist > maxDist) maxDist = curDist; } } - + if(planeProblem) { IMPrEnv_LogError( @@ -1037,7 +1037,7 @@ IMPiEnv_Parse_GQ_AddQuad( { UUtError error; - error = + error = IMPiEnv_Parse_GQ_AddQuadProperSize( inBuildData, ri0, @@ -1051,7 +1051,7 @@ IMPiEnv_Parse_GQ_AddQuad( realD, localFlags); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1153,7 +1153,7 @@ static void IMPiEnv_Parse_GQ_Quad_BuildNormal( return; } - + static UUtError IMPiEnv_Parse_GQ_Quad( @@ -1164,7 +1164,7 @@ IMPiEnv_Parse_GQ_Quad( UUtUns32 ri0, ri1, ri2, ri3; M3tPoint3D* curPoint; M3tTextureCoord gqTexCoords[4]; - + curPoint = IMPgEnv_RawPoints + inFace->indices[0]; ri0 = IMPgEnv_PointIndexRemap[inFace->indices[0]]; @@ -1176,14 +1176,14 @@ IMPiEnv_Parse_GQ_Quad( gqTexCoords[1] = IMPgEnv_TextureCoords[inFace->indices[1]]; gqTexCoords[2] = IMPgEnv_TextureCoords[inFace->indices[2]]; gqTexCoords[3] = IMPgEnv_TextureCoords[inFace->indices[3]]; - - + + if(!(IMPg_Gunk_Flags & AKcGQ_Flag_NoTextureMask)) { IMPg_Gunk_MaterialName = inNode->materials[inFace->material].name; IMPg_Gunk_TextureName = inNode->materials[inFace->material].maps[MXcMapping_DI].name; - + if(!strcmp(IMPg_Gunk_TextureName, "")) { IMPg_Gunk_TextureName = "NONE"; @@ -1198,11 +1198,11 @@ IMPiEnv_Parse_GQ_Quad( IMPg_Gunk_TextureName = "BLUEGRID02.PSD"; IMPg_Gunk_MaterialName = "BLUEGRID02.PSD"; } - + UUrString_Capitalize(IMPg_Gunk_TextureName, BFcMaxFileNameLength); - + IMPiEnv_Parse_GQ_Quad_BuildNormal(inBuildData, ri0, ri1, ri2, ri3, gqTexCoords, &inFace->dont_use_this_normal); - + return UUcError_None; } @@ -1215,7 +1215,7 @@ IMPiEnv_Parse_GQ_Tri( UUtUns32 ri0, ri1, ri2; M3tPoint3D* curPoint; M3tTextureCoord gqTexCoords[4]; - + curPoint = IMPgEnv_RawPoints + inFace->indices[0]; gqTexCoords[0] = IMPgEnv_TextureCoords[inFace->indices[0]]; @@ -1227,7 +1227,7 @@ IMPiEnv_Parse_GQ_Tri( ri1 = IMPgEnv_PointIndexRemap[inFace->indices[1]]; ri2 = IMPgEnv_PointIndexRemap[inFace->indices[2]]; - + if(!(IMPg_Gunk_Flags & AKcGQ_Flag_NoTextureMask)) { IMPg_Gunk_MaterialName = inNode->materials[inFace->material].name; @@ -1235,7 +1235,7 @@ IMPiEnv_Parse_GQ_Tri( IMPg_Gunk_TextureName = inNode->materials[inFace->material].maps[MXcMapping_DI].name; if(!strcmp(IMPg_Gunk_TextureName, "")) - { + { IMPg_Gunk_TextureName = "NONE"; } else if(!strcmp(IMPg_Gunk_MaterialName, "")) @@ -1248,11 +1248,11 @@ IMPiEnv_Parse_GQ_Tri( IMPg_Gunk_TextureName = "BLUEGRID02.PSD"; IMPg_Gunk_MaterialName = "BLUEGRID02.PSD"; } - + UUrString_Capitalize(IMPg_Gunk_TextureName, BFcMaxFileNameLength); - + IMPiEnv_Parse_GQ_Tri_BuildNormal(inBuildData, ri0, ri1, ri2, gqTexCoords, &inFace->dont_use_this_normal); - + return UUcError_None; } @@ -1273,8 +1273,8 @@ IMPiEnv_Parse_GQ_Flag( error = UUrString_To_Int32(inNode->name + strlen(IMPcGunkFlagNamePrefix), &pFlag->idNumber); if (error) { - Imp_PrintWarning("failed to parse flag %s in file %s", - inNode->name, + Imp_PrintWarning("failed to parse flag %s in file %s", + inNode->name, BFrFileRef_GetLeafName(inFileRef)); //UUmError_ReturnOnError(error); @@ -1282,9 +1282,9 @@ IMPiEnv_Parse_GQ_Flag( } pFlag->matrix = inNode->matrix; - + inBuildData->numFlags += 1; - + return UUcError_None; } @@ -1310,7 +1310,7 @@ IMPiEnv_Parse_GQ_Object_GeometryList( M3tGeometry *objectGeometry; MXtHeader* geomData; MXtNode* curNode; - + // Determine where to find the geometries error = GRrGroup_GetString(inBuildData->environmentGroup, "propsDirectory", &geometryFileDirName); @@ -1321,19 +1321,19 @@ IMPiEnv_Parse_GQ_Object_GeometryList( setupO->numDefGeometry = 0; return UUcError_None; } - + UUrString_Copy(munge, inNode->name + strlen(IMPcGunkObjectNamePrefix), 64); - + sprintf(geometryFileDirNameMunged,"%s\\%s", geometryFileDirName, munge); - + UUrString_NukeNumSuffix(geometryFileDirNameMunged, 128); - + // Fetch the list of geometries UUmError_ReturnOnErrorMsg(error, "Could not get props texture file info"); error = BFrFileRef_MakeFromName(geometryFileDirNameMunged, &geometryFileDirRef); UUmError_ReturnOnErrorMsg(error, "Could not make props texture file dir ref"); - - error = + + error = BFrDirectory_GetFileList( geometryFileDirRef, setupO->defGeomPrefix, @@ -1349,7 +1349,7 @@ IMPiEnv_Parse_GQ_Object_GeometryList( setupO->numDefGeometry = 0; return UUcError_None; } - + // Process and store the geometries for(curEnvGeometryIndex = 0, curEnvGeometry = setupO->defGeomList; curEnvGeometryIndex < numGeometryFiles; @@ -1360,7 +1360,7 @@ IMPiEnv_Parse_GQ_Object_GeometryList( UUrString_Copy(tempFileName, leafName, BFcMaxFileNameLength); tempFileName[strlen(tempFileName)-5] = '\0'; // blow away the .env - + // Open the geometry file error = Imp_ParseEnvFile(geometryFileRefArray[curEnvGeometryIndex], &geomData); if (error != UUcError_None) @@ -1368,9 +1368,9 @@ IMPiEnv_Parse_GQ_Object_GeometryList( Imp_PrintWarning("Unable to find deformed geometry %s for object %s"UUmNL,tempFileName,inNode->name); continue; } - + curNode = geomData->nodes; - + if (curNode->userDataCount > 0 && *curNode->userData != 0) { error = GRrGroup_Context_NewFromString(curNode->userData,gPreferencesGroup,NULL,&groupContext,&group); @@ -1385,28 +1385,28 @@ IMPiEnv_Parse_GQ_Object_GeometryList( { textureName = "NONE"; } - + if(textureName == NULL || *textureName == 0) { textureName = "NONE"; } - - + + // Check to see if we have this geometry yet if (IMPgConstructing && !TMrConstruction_Instance_CheckExists(M3cTemplate_Geometry,tempFileName)) { M3tMatrix4x3 identity = { 1.0f,0,0,0, 0,1.0f,0,0, 0,0,1.0f,0 }; - + error = TMrConstruction_Instance_Renew(M3cTemplate_Geometry,tempFileName,0,&objectGeometry); UUmError_ReturnOnError(error); - + // Parse the geometry error = Imp_Node_To_Geometry(geomData->nodes, objectGeometry); UUmError_ReturnOnError(error); - - objectGeometry->geometryFlags = M3cGeometryFlag_None; + + objectGeometry->geometryFlags = M3cGeometryFlag_None; // Add the texture placeholder UUmAssert(strchr(textureName, '.') == NULL); @@ -1414,20 +1414,20 @@ IMPiEnv_Parse_GQ_Object_GeometryList( objectGeometry->baseMap = M3rTextureMap_GetPlaceholder(textureName); UUmAssert(objectGeometry->baseMap); } - + Imp_EnvFile_Delete(geomData); - + // Create the geometry placeholder if(IMPgConstructing) { - error = + error = TMrConstruction_Instance_GetPlaceHolder( M3cTemplate_Geometry, tempFileName, (TMtPlaceHolder*)curEnvGeometry); } - - // Make a note of the new deformed geometry entry + + // Make a note of the new deformed geometry entry setupO->numDefGeometry++; if (setupO->numDefGeometry > IMPcEnv_MaxDefGeometry) break; } @@ -1472,7 +1472,7 @@ IMPiEnv_Parse_GQ_Object( setupO->bounces = OBcInfinity; setupO->hitpoints = OBcInfinity; setupO->scriptID = OBcInfinity; - + animName[0] = '\0'; objectName = inNode->name+strlen(IMPcGunkObjectNamePrefix); @@ -1497,58 +1497,58 @@ IMPiEnv_Parse_GQ_Object( // grab the object tag if it exits... tag = IMPiEnv_Parse_GQ_ObjectTag( group, inBuildData ); IMPrEnv_Add_ObjectTag( inBuildData, tag, 0xFFFFFFFF ); - + // Read the optional fields error = GRrGroup_GetElement(group, "lifespan", &groupType, &string); if (UUcError_None == error) { Imp_PrintMessage(IMPcMsg_Important, "object had obsolete field lifespan"); } - + error = GRrGroup_GetElement(group, "bouncelimit", &groupType, &string); if (UUcError_None == error) { Imp_PrintMessage(IMPcMsg_Important, "object had obsolete field bounce limit"); } - + error = GRrGroup_GetElement(group, "hitpoints", &groupType, &string); if (UUcError_None == error) { Imp_PrintMessage(IMPcMsg_Important, "object had obsolete field hitpoints"); } - + error = GRrGroup_GetElement(group, "damage", &groupType, &string); if (UUcError_None == error) { Imp_PrintMessage(IMPcMsg_Important, "object had obsolete field damage"); } - + error = GRrGroup_GetElement(group, "physics", &groupType, &string); if (error == UUcError_None) sscanf(string,"%u",&setupO->physicsLevel); - + error = GRrGroup_GetElement(group, "ref", &groupType, &string); if (error == UUcError_None) sscanf(string,"%u",&setupO->scriptID); - + error = GRrGroup_GetString(group, "anim", &string); if (error == UUcError_None) UUrString_Copy(animName,string,OBcMaxObjectName); - + error = GRrGroup_GetElement(group, "node_index", &groupType, &string); if (error == UUcError_None) sscanf(string,"%u",&node_index); - + // Read the deformation fields error = GRrGroup_GetElement(group,"deftex",&groupType,&string); if (error == UUcError_None) UUrString_Copy(setupO->defTexturePrefix,string,IMPcEnv_MaxPrefixLength); error = GRrGroup_GetElement(group,"defgeom",&groupType,&string); if (error == UUcError_None) UUrString_Copy(setupO->defGeomPrefix,string,IMPcEnv_MaxPrefixLength); - + IMPiEnv_Parse_GQ_Object_GeometryList(inBuildData,setupO,inNode); - + // Close off the user data GRrGroup_Context_Delete(groupContext); } //else IMPrEnv_LogError("Object %s in file %s has no user data",inNode->name,inFileName); - + // Intelligently set the temp and bounce flags - + setupO->flags = flagResults; - + // find the original setup object if it exists setup_original = NULL; @@ -1560,10 +1560,10 @@ IMPiEnv_Parse_GQ_Object( if( !UUrString_Compare_NoCase( inBuildData->objectList[i].objName, inNode->name ) ) { setup_original = &inBuildData->objectList[i]; - } + } } } - + if( setup_original ) { setupO = setup_original; @@ -1586,10 +1586,10 @@ IMPiEnv_Parse_GQ_Object( scanned = sscanf(junk,"%d",&door); setupO->door_id = door; if (!scanned) return UUcError_Generic; - if (!(setupO->flags & OBcFlags_NoCollision)) + if (!(setupO->flags & OBcFlags_NoCollision)) setupO->flags |= OBcFlags_FaceCollision; } - + // Check to see if we have geometry for this object type yet if( node_index == -1 ) { @@ -1597,7 +1597,7 @@ IMPiEnv_Parse_GQ_Object( storeGeom = UUcFalse; } } - + if (storeGeom) { // This object has geometry exported for it, so parse it @@ -1608,34 +1608,34 @@ IMPiEnv_Parse_GQ_Object( error = TMrConstruction_Instance_Renew(M3cTemplate_Geometry, geometry_name, 0, &objectGeometry); UUmError_ReturnOnError(error); - objectGeometry->geometryFlags = M3cGeometryFlag_None; + objectGeometry->geometryFlags = M3cGeometryFlag_None; error = Imp_Node_To_Geometry(inNode, objectGeometry); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); textureName = inNode->materials->maps[MXcMapping_DI].name; - + if(!strcmp(inNode->materials->name, "")) { textureName = "NONE"; } - + if(textureName == NULL || *textureName == 0) { textureName = "NONE"; } - + UUrString_Capitalize(textureName, BFcMaxFileNameLength); - + // Add the texture placeholder and note the texture for later creation UUmAssert(strchr(textureName, '.') == NULL); - + objectGeometry->baseMap = M3rTextureMap_GetPlaceholder(textureName); UUmAssert(objectGeometry->baseMap); - - if ((!textureName) || (textureName[0] == '\0')) + + if ((!textureName) || (textureName[0] == '\0')) IMPg_Gunk_Flags = AKcGQ_Flag_NoTextureMask; - else + else IMPg_Gunk_Flags = 0; IMPiEnv_Parse_GQ_AddTexture(inBuildData,textureName); @@ -1644,13 +1644,13 @@ IMPiEnv_Parse_GQ_Object( { sprintf( geometry_name, "%s", objectName ); } - + if(IMPgConstructing) { // Create the geometry placeholder error = TMrConstruction_Instance_GetPlaceHolder( M3cTemplate_Geometry, geometry_name, (TMtPlaceHolder*)&setupO->geometry_list[setupO->geometry_count++] ); } - + // Position the object strip = inNode->matrix; setupO->debugOrigMatrix = strip; @@ -1659,15 +1659,15 @@ IMPiEnv_Parse_GQ_Object( error = MUrMatrix_GetUniformScale(&strip, &setupO->scale); - if (error != UUcError_None) - { + if (error != UUcError_None) + { Imp_PrintMessage(IMPcMsg_Critical, "Detected non uniform scale in %s", inNode->name); setupO->scale = 1.0f; } MUrMatrix_StripScale(&strip,&strip); MUrMatrixToQuat(&strip,&setupO->orientation); - + // Check for animation if (*animName && IMPgConstructing) { @@ -1678,7 +1678,7 @@ IMPiEnv_Parse_GQ_Object( if (error != UUcError_None) setupO->animation = NULL; else setupO->physicsLevel = PHcPhysics_Animate; } - + // if this node has any markers traverse them setupO->numParticles = 0; skipFX = UUcFalse; @@ -1709,7 +1709,7 @@ IMPiEnv_Parse_GQ_Object( } } } - + return UUcError_None; } @@ -1741,13 +1741,13 @@ UUtUns32 IMPrEnv_GetNodeFlags(MXtNode *inNode) goto exit; } - error = + error = AUrFlags_ParseFromGroupArray( IMPgGunkFlags, groupType, groupFlags, &gunkFlags); - + if (UUcError_None != error) { Imp_PrintWarning("gunk in file %s, node %s had an invalid flag", IMPg_Gunk_FileName, inNode->name); } @@ -1773,13 +1773,13 @@ IMPrEnv_GetLSData( UUtError error; GRtElementType groupType; GRtElementType elemType; - + GRtElementArray* filterColor; char* color; char* type; char* intensity; UUtUns16 itr; - + // initialize outFilterColor[0] = 0.0f; outFilterColor[1] = 0.0f; @@ -1789,29 +1789,29 @@ IMPrEnv_GetLSData( *outIntensity = 0; *outBeamAngle = 120.0f; *outFieldAngle = 120.0f; - + // process group error = GRrGroup_GetElement(inLSGroup, "filterColor", &groupType, &filterColor); IMPmError_ReturnOnErrorMsg(error, "Could not parse filter color"); - + if (GRrGroup_Array_GetLength(filterColor) != 3) { IMPmError_ReturnOnErrorMsg( UUcError_Generic, "Filter Color must only have 3 floats"); } - + for(itr = 0; itr < 3; itr++) { error = GRrGroup_Array_GetElement(filterColor, itr, &elemType, &color); IMPmError_ReturnOnErrorMsg(error, "Could not parse filter color"); - + sscanf(color, "%f", &outFilterColor[itr]); } - + error = GRrGroup_GetElement(inLSGroup, "type", &elemType, &type); IMPmError_ReturnOnErrorMsg(error, "Could not ls light type"); - + if(!strcmp(type, "point")) { *outLightType = IMPcLS_LightType_Point; @@ -1828,7 +1828,7 @@ IMPrEnv_GetLSData( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "unknown ls light type"); } - + error = GRrGroup_GetElement(inLSGroup, "distribution", &elemType, &type); if(error == UUcError_None) { @@ -1851,19 +1851,19 @@ IMPrEnv_GetLSData( { sscanf(intensity, "%d", outIntensity); } - + error = GRrGroup_GetElement(inLSGroup, "beamAngle", &elemType, &intensity); if(error == UUcError_None) { sscanf(intensity, "%f", outBeamAngle); } - + error = GRrGroup_GetElement(inLSGroup, "fieldAngle", &elemType, &intensity); if(error == UUcError_None) { sscanf(intensity, "%f", outFieldAngle); } - + return UUcError_None; } @@ -1883,12 +1883,12 @@ IMPiEnv_Parse_GQ( UUtUns32 gunkFlags; UUtUns32 lmFlags; GRtGroup* lsGroup; - + MXtNode* curNode; MXtPoint* curPoint; MXtFace* curFace; MXtMarker* curMarker; - + UUtUns16 nodeItr; UUtUns16 faceItr; UUtUns16 pointItr; @@ -1925,7 +1925,7 @@ IMPiEnv_Parse_GQ( else if (UUrString_HasPrefix(curNode->name,IMPcGunkObjectNamePrefix)) { // We have an object - + // hack- Parse non physics objects as gunk for Dec 1/98 deadline // 07/99 - update- artists requested this hack be left in, and it doesn't hurt anything, so... if (curNode->userDataCount > 0 && *curNode->userData != 0) @@ -1934,7 +1934,7 @@ IMPiEnv_Parse_GQ( continue; } } - + gunkFlags = 0; lmFlags = 0; @@ -1947,10 +1947,10 @@ IMPiEnv_Parse_GQ( // We have user data, so parse it error = GRrGroup_Context_NewFromString(curNode->userData,gPreferencesGroup,NULL,&groupContext,&group); UUmError_ReturnOnError(error); - + error = GRrGroup_GetUns16(group,"ref",&scriptID); if (error != UUcError_None) scriptID = 0xFFFF; - + error = GRrGroup_GetString(group,"material",&materialName); if (error != UUcError_None) materialName = NULL; else @@ -1964,18 +1964,18 @@ IMPiEnv_Parse_GQ( error = GRrGroup_GetElement(group, "lm", &groupType, &groupFlags); if(error == UUcError_None) { - error = + error = AUrFlags_ParseFromGroupArray( IMPgLMFlags, groupType, groupFlags, &lmFlags); } - + error = GRrGroup_GetElement(group, "lsparams", &groupType, &groupFlags); if(error == UUcError_None) { - error = + error = AUrFlags_ParseFromGroupArray( IMPgLSParamFlags, groupType, @@ -2001,18 +2001,18 @@ IMPiEnv_Parse_GQ( IMPgEnv_LS = UUcTrue; } } - + // grab the object tag if it exits... IMPg_Gunk_ObjectTag = IMPiEnv_Parse_GQ_ObjectTag( group, inBuildData ); GRrGroup_Context_Delete(groupContext); } - + IMPg_Gunk_FileName = inFileName; IMPg_Gunk_ObjName = curNode->name; IMPg_Gunk_Flags = gunkFlags; IMPg_Gunk_LMFlags = (UUtUns16) lmFlags; IMPg_Gunk_ScriptID = scriptID; - + for(pointItr = 0, curPoint = curNode->points; pointItr < curNode->numPoints; pointItr++, curPoint++) @@ -2021,8 +2021,8 @@ IMPiEnv_Parse_GQ( &curPoint->point, &curNode->matrix, &curPoint->point); - - error = + + error = IMPiEnv_Parse_Point( inBuildData, pointItr, @@ -2039,14 +2039,14 @@ IMPiEnv_Parse_GQ( &curNode->matrix, &curFace->dont_use_this_normal); - error = + error = IMPiEnv_Parse_GQ_Tri( inBuildData, curNode, curFace); UUmError_ReturnOnError(error); } - + gq_index = inBuildData->numGQs; lastGQ = inBuildData->gqList + inBuildData->numGQs; for(faceItr = 0, curFace = curNode->quads; faceItr < curNode->numQuads; faceItr++, curFace++) @@ -2069,7 +2069,7 @@ IMPiEnv_Parse_GQ( } else itrGQ->gqMaterialName[0] = '\0'; } - } + } // look for environmental-particle markers. for (markerItr = 0, curMarker = curNode->markers; markerItr < curNode->numMarkers; markerItr++, curMarker++) @@ -2094,7 +2094,7 @@ IMPiEnv_Parse_GQ( } } } - + // eventually dispose envData return UUcError_None; @@ -2104,7 +2104,7 @@ IMPiEnv_Parse_GQ( static UUtUns32 IMPiEnv_Parse_ComputeNumGQsNeeded(MXtNode* inNode) { UUtUns32 max_gqs_needed = inNode->numTriangles + (inNode->numQuads * 2); // quads might be subdivided into 2 triangles - + return max_gqs_needed; } @@ -2205,35 +2205,35 @@ IMPrEnv_Parse_Textures( UUtBool *ioBuildInstance) { UUtError error; - + char* textureFileDirName; BFtFileRef* textureFileDirRef; BFtFileRef* textureFileRefArray[IMPcEnv_MaxTextures]; UUtUns16 numTextureFiles; UUtUns16 curTextureIndex; - + UUtUns16 curFileIndex; - + char tempFileName[BFcMaxFileNameLength]; char suffix[4]; UUtUns32 numTextures; AUtSharedString* curEnvTextureRef; IMPtEnv_Texture* curEnvTexture; - - + + AUtSharedString* envTextureList; AUtSharedString* textureDirectoryList; AUtSharedStringArray* textureDirectoryArray; UUtUns32 textureIndex; - + UUtUns32* envTextureSortedIndices; - + const char* textureRefSuffix; //char* string; - - + + UUtInt64 time = UUrMachineTime_High(); Imp_PrintMessage(IMPcMsg_Important, UUmNL"Environment Texturemap"); @@ -2247,8 +2247,8 @@ IMPrEnv_Parse_Textures( // add the textures we require and the textures we will skip (just make placeholders for) IMPiEnv_Add_Required_Textures(textureFileDirRef, inBuildData); IMPiEnv_Add_Skip_Textures(textureFileDirRef, inBuildData); - - error = + + error = BFrDirectory_GetFileList( textureFileDirRef, NULL, @@ -2257,12 +2257,12 @@ IMPrEnv_Parse_Textures( &numTextureFiles, textureFileRefArray); UUmError_ReturnOnErrorMsg(error, "Could not get files in bnv dir"); - + BFrFileRef_Dispose(textureFileDirRef); - + textureDirectoryArray = AUrSharedStringArray_New(); UUmError_ReturnOnNull(textureDirectoryArray); - + for(curTextureIndex = 0; curTextureIndex < numTextureFiles; curTextureIndex++) { textureRefSuffix = BFrFileRef_GetSuffixName(textureFileRefArray[curTextureIndex]); @@ -2274,20 +2274,20 @@ IMPrEnv_Parse_Textures( suffix, textureRefSuffix, 4); - + UUrString_Capitalize(suffix, 4); - + if(strncmp(suffix, "BMP", 3) && strncmp(suffix, "PSD", 3)) continue; - + UUrString_Copy( tempFileName, BFrFileRef_GetLeafName(textureFileRefArray[curTextureIndex]), BFcMaxFileNameLength); - + UUrString_Capitalize(tempFileName, BFcMaxFileNameLength); UUrString_StripExtension(tempFileName); - - error = + + error = AUrSharedStringArray_AddString( textureDirectoryArray, tempFileName, @@ -2295,11 +2295,11 @@ IMPrEnv_Parse_Textures( NULL); UUmError_ReturnOnError(error); } - + numTextures = AUrSharedStringArray_GetNum(inBuildData->textureMapArray); - + textureDirectoryList = AUrSharedStringArray_GetList(textureDirectoryArray); - + for(curTextureIndex = 0, curEnvTextureRef = AUrSharedStringArray_GetList(inBuildData->textureMapArray), curEnvTexture = inBuildData->envTextureList; @@ -2320,7 +2320,7 @@ IMPrEnv_Parse_Textures( curEnvTexture->flags.flags = M3cTextureFlags_HasMipMap; curEnvTexture->texture = NULL; - + if(AUrSharedStringArray_GetIndex(textureDirectoryArray, curEnvTextureRef->string, &textureIndex)) { if(IMPgConstructing) @@ -2331,7 +2331,7 @@ IMPrEnv_Parse_Textures( UUmAssert(curEnvTexture->texture); } else { - error = + error = Imp_ProcessTexture( textureFileRefArray[textureDirectoryList[textureIndex].data], IMPgLowMemory ? 2 : 0, @@ -2340,7 +2340,7 @@ IMPrEnv_Parse_Textures( curEnvTextureRef->string, IMPcIgnoreTextureRef); IMPmError_ReturnOnErrorMsg(error, "Could not make texture"); - + UUmAssert(strchr(curEnvTextureRef->string, '.') == NULL); curEnvTexture->texture = M3rTextureMap_GetPlaceholder(curEnvTextureRef->string); @@ -2359,23 +2359,23 @@ IMPrEnv_Parse_Textures( IMPrEnv_LogError( "Could not find texture %s", curEnvTextureRef->string); - + curEnvTexture->texture = M3rTextureMap_GetPlaceholder("NONE"); UUmAssert(curEnvTexture->texture); } } - + Imp_PrintMessage(IMPcMsg_Important, UUmNL); fprintf(IMPgEnv_StatsFile, "**Texture Map stats"UUmNL); - + envTextureSortedIndices = AUrSharedStringArray_GetSortedIndexList(inBuildData->textureMapArray); envTextureList = AUrSharedStringArray_GetList(inBuildData->textureMapArray); - + for(curTextureIndex = 0; curTextureIndex < numTextures; curTextureIndex++) { - fprintf(IMPgEnv_StatsFile, "\t%s"UUmNL, + fprintf(IMPgEnv_StatsFile, "\t%s"UUmNL, envTextureList[envTextureSortedIndices[curTextureIndex]].string); } @@ -2385,7 +2385,7 @@ IMPrEnv_Parse_Textures( { BFrFileRef_Dispose(textureFileRefArray[curFileIndex]); } - + time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); @@ -2404,43 +2404,43 @@ IMPrEnv_Parse( //char* bnvFileDirName; //char* gqFileDirName; - - + + UUtUns16 numBNVfiles; BFtFileRef* bnvFileDirRef; BFtFileRef* bnvFileRefArray[IMPcEnv_MaxFilesInDir]; MXtHeader* bnvEnvDataArray[IMPcEnv_MaxFilesInDir]; - + UUtUns16 numGQfiles; BFtFileRef* gqFileDirRef; BFtFileRef* gqFileRefArray[IMPcEnv_MaxFilesInDir]; MXtHeader* gqEnvDataArray[IMPcEnv_MaxFilesInDir]; - + UUtUns16 curFileIndex; - + UUtBool buildInstance; UUtUns32 createDate = 0; UUtUns32 curModTime; - + M3tPoint3D *pointList; - - - + + + UUtUns16 nodeItr; MXtNode* curNode; const char* leafName; //char* string; UUtUns32 newIndex; - + M3tColorRGB reflectivity_color; - + UUtUns32 numGQsNeeded; UUtInt64 time; - + AUrSharedStringArray_Reset(inBuildData->textureMapArray); - + // setup default door frame texture error = AUrSharedStringArray_AddString( inBuildData->textureMapArray, "_DOOR_FRAME", 0, &newIndex); UUmAssert( error == UUcError_None ); @@ -2460,11 +2460,11 @@ IMPrEnv_Parse( "Conversion_Files\\Gunk", &gqFileDirRef); UUmError_ReturnOnError(error); - + // Get the default reflectivity inBuildData->reflectivity_specified = UUcFalse; - - error = + + error = M3rGroup_GetColor( inGroup, "reflectivity", @@ -2476,10 +2476,10 @@ IMPrEnv_Parse( Imp_PrintMessage(IMPcMsg_Important, "reflectivity = %f,%f,%f"UUmNL, inBuildData->reflectivity_color.r, inBuildData->reflectivity_color.g, inBuildData->reflectivity_color.b); } - - + + // Get the file lists - error = + error = BFrDirectory_GetFileList( bnvFileDirRef, NULL, @@ -2488,8 +2488,8 @@ IMPrEnv_Parse( &numBNVfiles, bnvFileRefArray); UUmError_ReturnOnErrorMsg(error, "Could not get files in bnv dir"); - - error = + + error = BFrDirectory_GetFileList( gqFileDirRef, NULL, @@ -2498,10 +2498,10 @@ IMPrEnv_Parse( &numGQfiles, gqFileRefArray); UUmError_ReturnOnErrorMsg(error, "Could not get files in gq dir"); - - + + buildInstance = *ioBuildInstance; - + for(curFileIndex = 0; curFileIndex < numBNVfiles && !buildInstance; curFileIndex++) { error = BFrFileRef_GetModTime(bnvFileRefArray[curFileIndex], &curModTime); @@ -2527,29 +2527,29 @@ IMPrEnv_Parse( } // Collect all the dirtmap file names inBuildData->maxBNVs = 0; - + time = UUrMachineTime_High(); Imp_PrintMessage(IMPcMsg_Important, "Parsing BNVs"); - + for(curFileIndex = 0; curFileIndex < numBNVfiles; curFileIndex++) { if((curFileIndex % 5) == 0) { Imp_PrintMessage(IMPcMsg_Important, "."); } - + leafName = BFrFileRef_GetLeafName(bnvFileRefArray[curFileIndex]); Imp_PrintMessage(IMPcMsg_Cosmetic, "%s"UUmNL, leafName); error = Imp_ParseEnvFile(bnvFileRefArray[curFileIndex], &bnvEnvDataArray[curFileIndex]); UUmError_ReturnOnError(error); - + inBuildData->maxBNVs += bnvEnvDataArray[curFileIndex]->numNodes; } - + inBuildData->bnvList = UUrMemory_Block_New(sizeof(IMPtEnv_BNV) * inBuildData->maxBNVs); UUmError_ReturnOnNull(inBuildData->bnvList); - + for(curFileIndex = 0; curFileIndex < numBNVfiles; curFileIndex++) { if((curFileIndex % 5) == 0) @@ -2563,7 +2563,7 @@ IMPrEnv_Parse( inBuildData); UUmError_ReturnOnError(error); } - + for(curFileIndex = 0; curFileIndex < numBNVfiles; curFileIndex++) { Imp_EnvFile_Delete(bnvEnvDataArray[curFileIndex]); @@ -2571,15 +2571,15 @@ IMPrEnv_Parse( time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); - + time = UUrMachineTime_High(); Imp_PrintMessage(IMPcMsg_Important, UUmNL"GQs"); inBuildData->maxGQs = 0; inBuildData->numGQFiles = numGQfiles; - + numGQsNeeded = 0; - + inBuildData->numMarkers = 0; for(curFileIndex = 0; curFileIndex < numGQfiles; curFileIndex++) { @@ -2592,15 +2592,15 @@ IMPrEnv_Parse( error = Imp_ParseEnvFile(gqFileRefArray[curFileIndex], &gqEnvDataArray[curFileIndex]); UUmError_ReturnOnError(error); - + for(nodeItr = 0, curNode = gqEnvDataArray[curFileIndex]->nodes; nodeItr < gqEnvDataArray[curFileIndex]->numNodes; nodeItr++, curNode++) { inBuildData->maxGQs += curNode->numTriangles + curNode->numQuads; - + numGQsNeeded += IMPiEnv_Parse_ComputeNumGQsNeeded(curNode); - + for (newIndex=0; newIndexnumMarkers; newIndex++) { if (inBuildData->numMarkers >= IMPcEnv_MaxMarkerNodes) { @@ -2613,30 +2613,30 @@ IMPrEnv_Parse( inBuildData->numMarkers++; } } - + UUrString_Copy(inBuildData->gqFileNames[curFileIndex], BFrFileRef_GetLeafName(gqFileRefArray[curFileIndex]), BFcMaxFileNameLength); } time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); - + inBuildData->maxGQs = numGQsNeeded + (numGQsNeeded >> 1); if(inBuildData->maxGQs < 4000) inBuildData->maxGQs = 4000; - + Imp_PrintMessage(IMPcMsg_Important, UUmNL"max gqs = %d"UUmNL, inBuildData->maxGQs); - + inBuildData->gqList = UUrMemory_Block_New(sizeof(IMPtEnv_GQ) * inBuildData->maxGQs); UUmError_ReturnOnNull(inBuildData->gqList); - + inBuildData->gqTakenBV = UUrBitVector_New(inBuildData->maxGQs); UUmError_ReturnOnNull(inBuildData->gqTakenBV); for(curFileIndex = 0; curFileIndex < numGQfiles; curFileIndex++) { IMPg_Gunk_FileRelativeGQIndex = 0; - + error = IMPiEnv_Parse_GQ( inBuildData, @@ -2645,18 +2645,18 @@ IMPrEnv_Parse( gqFileRefArray[curFileIndex]); UUmError_ReturnOnError(error); } - + Imp_PrintMessage(IMPcMsg_Important,UUmNL"%d found"UUmNL,inBuildData->numGQs); pointList = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); - + IMPrEnv_Parse_Textures(inSourceFileRef, curModTime, inGroup, inBuildData, ioBuildInstance); - + for(curFileIndex = 0; curFileIndex < numGQfiles; curFileIndex++) { BFrFileRef_Dispose(gqFileRefArray[curFileIndex]); } - + for(curFileIndex = 0; curFileIndex < numBNVfiles; curFileIndex++) { BFrFileRef_Dispose(bnvFileRefArray[curFileIndex]); @@ -2666,11 +2666,11 @@ IMPrEnv_Parse( { Imp_EnvFile_Delete(gqEnvDataArray[curFileIndex]); } - + BFrFileRef_Dispose(gqFileDirRef); BFrFileRef_Dispose(bnvFileDirRef); - + *ioBuildInstance = buildInstance; - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Private.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Private.h index 9e25baa..3414ff5 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Private.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Private.h @@ -5,8 +5,8 @@ CREATED: Sept 3, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997-1999 */ @@ -132,7 +132,7 @@ enum IMPcGQ_LM_None = 0, IMPcGQ_LM_ForceOn = (1 << 0), IMPcGQ_LM_ForceOff = (1 << 1) - + }; /* @@ -143,36 +143,36 @@ enum IMPcAbsSide_Postive, IMPcAbsSide_Negative, IMPcAbsSide_BothPosNeg - + } IMPtEnv_BSP_AbsoluteSideFlag; typedef struct IMPtEnv_BSP_Quad { UUtUns32 ref; // user field UUtUns32 bspQuadIndex; - + } IMPtEnv_BSP_Quad; - + #define IMPcEnv_MaxQuadsPerPlane (2048) typedef struct IMPtEnv_BSP_Plane { UUtUns32 planeEquIndex; UUtUns32 ref; // user field - + UUtUns32 numQuads; IMPtEnv_BSP_Quad quads[IMPcEnv_MaxQuadsPerPlane]; - + } IMPtEnv_BSP_Plane; typedef struct IMPtEnv_BSP_Node { IMPtEnv_BSP_Plane* splittingPlane; // user data IMPtEnv_BSP_Quad splittingQuad; - + UUtUns32 posNodeIndex; UUtUns32 negNodeIndex; - + } IMPtEnv_BSP_Node; /* @@ -183,31 +183,31 @@ enum IMPcLS_LightType_Point, IMPcLS_LightType_Linear, IMPcLS_LightType_Area - + } IMPtLS_LightType; - + typedef enum IMPtLS_LightParam { IMPcLS_LightParam_None = 0, IMPcLS_LightParam_NotOccluding = (1 << 0), IMPcLS_LightParam_Window = (1 << 1), IMPcLS_LightParam_NotReflecting = (1 << 2) - + } IMPtLS_LightParam; - + typedef enum IMPtLS_Distribution { IMPcLS_Distribution_Diffuse = 0, IMPcLS_Distribution_Spot = 1 - + } IMPtLS_Distribution; - + /* * GQ related structs */ typedef struct IMPtEnv_GQ { - M3tPoint3D *hi1; // \ + M3tPoint3D *hi1; // \ M3tPoint3D *hi2; // | - Don't move these. VTuned M3tPoint3D *lo1; // | M3tPoint3D *lo2; // / @@ -220,32 +220,32 @@ enum char gqMaterialName[IMPcEnv_MaxNameLength]; UUtUns32 fileRelativeGQIndex; - + UUtUns32 scriptID; M3tQuad visibleQuad; M3tQuad baseMapIndices; // Indices into the uv array for the base map - + M3tQuad edgeIndices; // UUtUns32 adjGQIndices[4]; - + UUtUns32 flags; UUtUns32 lmFlags; - + UUtUns32 planeEquIndex; - + CLtQuadProjection projection; - + UUtUns16 textureMapIndex; - + UUtUns32 stairBNVIndex; // CB: only valid for SAT quads - + UUtBool used; UUtBool ghostUsed; - + //UUtUns32 myPatchIndex; //UUtUns32 myPlaneIndex; - + UUtBool isLuminaire; float filterColor[3]; IMPtLS_LightType lightType; @@ -253,13 +253,13 @@ enum IMPtLS_Distribution distribution; float beamAngle; float fieldAngle; - + UUtUns32 lightParams; - + float patchArea; - + M3tBoundingBox_MinMax bBox; - + UUtUns32 object_tag; } IMPtEnv_GQ; @@ -267,18 +267,18 @@ enum * BNV related structs */ typedef struct IMPtEnv_BNV_Side - { + { UUtUns32 planeEquIndex; UUtUns32 numBNVQuads; UUtUns32 bnvQuadList[IMPcEnv_MaxQuadsPerSide]; - + UUtUns32 numGQGhostIndices; UUtUns32 gqGhostIndices[IMPcEnv_MaxQuadsPerSide]; - + UUtUns32 numAdjacencies; AKtAdjacency adjacencyList[IMPcEnv_MaxAdjacencies]; - + } IMPtEnv_BNV_Side; typedef struct IMPtEnv_BNV @@ -297,42 +297,42 @@ enum char fileName[IMPcEnv_MaxNameLength]; char objName[IMPcEnv_MaxNameLength]; - + UUtUns32 parent; UUtUns32 level; - + UUtUns32 child; UUtUns32 next; - + UUtBool isLeaf; UUtUns32 flags; - + float volume; - + UUtUns32 numSides; IMPtEnv_BNV_Side sides[IMPcEnv_MaxBNVSides]; - + UUtUns32 numNodes; AKtBNV_BSPNode bspNodes[IMPcEnv_MaxNumBNVBSPNodes]; - + UUtUns32 numGQs; UUtUns32 gqList[IMPcEnv_MaxGQsPerBNV]; - + M3tPoint3D origin; // Bounding box M3tPoint3D antiOrigin; M3tPlaneEquation stairPlane; float stairHeight; - + UUtBool error; - + } IMPtEnv_BNV; - + enum { IMPcEnv_TexturePageFlags_None = 0 }; - - + + /* * lightscape stuff */ @@ -341,7 +341,7 @@ enum { char fileName[32]; struct LStData* lsData; - + } IMPtEnv_LSData; /* @@ -353,10 +353,10 @@ enum UUtUns32 geometry_count; struct OBtAnimation *animation; - + UUtUns32 numParticles; EPtEnvParticle particles[IMPcEnv_MaxObjectParticles]; - + UUtUns32 lifeSpan; UUtUns32 bounces; UUtUns32 flags; @@ -368,15 +368,15 @@ enum UUtUns32 door_gq; char defPiecesPrefix[IMPcEnv_MaxPrefixLength][IMPcEnv_MaxPiecesLists]; - + char defTexturePrefix[IMPcEnv_MaxPrefixLength]; AUtSharedString defTextureList[IMPcEnv_MaxDefTextures]; UUtUns32 numDefTextures; - + char defGeomPrefix[IMPcEnv_MaxPrefixLength]; M3tGeometry *defGeomList[IMPcEnv_MaxDefGeometry]; UUtUns32 numDefGeometry; - + M3tPoint3D position; M3tQuaternion orientation; float scale; @@ -390,13 +390,13 @@ enum /* * character setup stuff */ - + typedef struct IMPtEnv_Flag { UUtInt32 idNumber; M3tMatrix4x3 matrix; } IMPtEnv_Flag; - + /* * general build data */ @@ -406,136 +406,136 @@ enum UUtUns32 parent; UUtUns32 myOctant; UUtUns32 adjacent[6]; // Direct adjacent node - if no adjacent its 0xFFFFFFFF - + UUtInt16 minXIndex; UUtInt16 minYIndex; UUtInt16 minZIndex; UUtInt16 maxXIndex; UUtInt16 maxYIndex; UUtInt16 maxZIndex; - + UUtUns32 dimIndex; - + } IMPtEnv_OTExtraNodeInfo; - + typedef struct IMPtEnv_OTData { UUtUns32 maxDepth; UUtUns32 gqsPerNodeDist[IMPcEnv_OT_MaxGQsPerNode]; UUtUns32 bnvsPerNodeDist[IMPcEnv_OT_MaxBNVsPerNode]; UUtUns32 leafNodeSizeDist[IMPcEnv_OT_NumLeafNodeDims]; - + UUtUns32 nextLeafNodeIndex; UUtUns32 nextInteriorNodeIndex; UUtUns32 nextQTNodeIndex; - + UUtUns32 nextGQIndex; UUtUns32 gqIndexArray[IMPcEnv_MaxGQIndexArray]; - + AKtOctTree_LeafNode leafNodes[IMPcEnv_MaxLeafNodes]; IMPtEnv_OTExtraNodeInfo leafNodeExtras[IMPcEnv_MaxLeafNodes]; AKtOctTree_InteriorNode interiorNodes[IMPcEnv_MaxInteriorNodes]; IMPtEnv_OTExtraNodeInfo interiorNodeExtras[IMPcEnv_MaxInteriorNodes]; - + AKtQuadTree_Node qtNodes[IMPcEnv_MaxQTNodes]; - + UUtUns32 nextBNVIndex; UUtUns32 bnv_index_array[IMPcEnv_MaxBNVIndexArray]; - + } IMPtEnv_OTData; - + typedef struct IMPtEnv_GQPatch { UUtUns32 gqStartIndirectIndex; // This is an index into the gunk quad index list UUtUns32 gqEndIndirectIndex; - + //UUtUns32 numPlanes; //IMPtEnv_TexturePlane* texturePlanes; - + } IMPtEnv_GQPatch; - + typedef struct IMPtEnv_Texture { tTextureFlags flags; M3tTextureMap* texture; - + } IMPtEnv_Texture; #define IMPcFixedOctTreeNode_Count 16 #define IMPcFixedOctTreeNode_ChunkSize 32 - + typedef struct IMPtEnv_BuildData { UUtUns32 maxGQs; - + UUtUns32 numGQs; IMPtEnv_GQ* gqList; - + UUtUns32 maxBNVs; UUtUns32 numBNVs; IMPtEnv_BNV* bnvList; - + AUtSharedStringArray* textureMapArray; IMPtEnv_Texture envTextureList[IMPcEnv_MaxTextures]; - + UUtUns16 numFlags; IMPtEnv_Flag flagList[IMPcEnv_MaxFlags]; - + UUtUns32 numMarkers; MXtMarker markerList[IMPcEnv_MaxMarkerNodes]; UUtUns32 numObjects; IMPtEnv_Object objectList[IMPcEnv_MaxObjects]; // Must be cache-aligned - + AUtSharedPointArray* sharedPointArray; // shared points AUtSharedPlaneEquArray* sharedPlaneEquArray; // shared plane equations AUtSharedQuadArray* sharedBNVQuadArray; // shared quads AUtSharedTexCoordArray* sharedTextureCoordArray; // - + AUtSharedPointArray* bspPointArray; // shared points for bsp construction AUtSharedQuadArray* bspQuadArray; // shared quads for bsp construction - + IMPtEnv_OTData otData; - + UUtMemory_Pool* tempMemoryPool; - + GRtGroup* environmentGroup; - + // gq patch data UUtUns32 numPatches; IMPtEnv_GQPatch patches[IMPcEnv_MaxPatches]; - + UUtUns32 numPatchIndIndices; UUtUns32 patchIndIndices[IMPcEnv_MaxGQIndexArray]; - + AUtSharedEdgeArray* edgeArray; - + // lightmap data UUtUns32 numGQFiles; char gqFileNames[IMPcEnv_MaxFilesInDir][BFcMaxFileNameLength]; - + UUtUns32* gqTakenBV; // generally useful - + UUtBool reflectivity_specified; M3tColorRGB reflectivity_color; - + // initial particle data UUtUns32 numEnvParticles; EPtEnvParticle envParticles[IMPcEnv_MaxEnvParticles]; AItCharacterSetupArray *characterSetup; - + float totalGQArea; AUtHashTable *debugStringTable; UUtUns32 debugStringBytes; - + UUtUns32 numAlphaQuads; UUtUns32 alphaQuads[IMPcEnv_MaxAlphaQuads]; - + UUtUns32 numBSPNodes; IMPtEnv_BSP_Node bspNodes[IMPcEnv_MaxNumBSPNodes]; - + UUtUns32 numAlphaBSPNodes; AKtAlphaBSPTree_Node alphaBSPNodes[IMPcEnv_MaxNumBSPNodes]; @@ -551,7 +551,7 @@ enum // gunked objects tag list UUtMemory_Array *object_tags; UUtMemory_Array *object_quads; - + UUtUns16 door_frame_texture; UUtUns32 door_count; UUtUns32 door_gq_indexes[IMPcEnv_MaxNumDoors]; @@ -564,7 +564,7 @@ enum extern UUtMemory_Pool* IMPgEnv_MemoryPool; extern FILE* IMPgEnv_StatsFile; extern float IMPgEnv_InchesPerPixel; - + /* * some prototypes */ @@ -589,13 +589,13 @@ UUtError IMPrEnv_Process( IMPtEnv_BuildData* inBuildData, BFtFileRef* inSourceFileRef); - + UUtError IMPrEnv_CreateInstance( char* inInstanceName, BFtFileRef* inSourceFileRef, IMPtEnv_BuildData* inBuildData); - + UUtError IMPrEnv_CreateInstance_Debug( char* inInstanceName, @@ -612,14 +612,14 @@ IMPrEnv_Process_BNV_ContainsStairBNV( IMPtEnv_BuildData* inBuildData, IMPtEnv_BNV* inParentBNV, IMPtEnv_BNV* inChildBNV); - + UUtBool IMPiEnv_Process_BSP_PointInBSP( IMPtEnv_BuildData* inBuildData, IMPtEnv_BNV* inBNV, M3tPoint3D* inPoint, float inTolerance); - + UUtError IMPrEnv_Process_BNV_ComputeProperties( IMPtEnv_BuildData* inBuildData); @@ -631,14 +631,14 @@ void IMPiCalculateNodeOrigins( M3tPoint3D *outAntiOrigin); void Imp_Env_AddAdjacency( - IMPtEnv_BNV_Side *inSrcSide, - IMPtEnv_BNV *inSrcBNV, - IMPtEnv_BNV_Side *inDestSide, + IMPtEnv_BNV_Side *inSrcSide, + IMPtEnv_BNV *inSrcBNV, + IMPtEnv_BNV_Side *inDestSide, UUtUns32 inDestBNVIndex, UUtUns32 inConnectingGQIndex, UUtUns16 inFlags, IMPtEnv_BuildData *inBuildData); - + void Imp_Env_DoStairAdjacency(UUtUns32 ioCurNodeIndex, IMPtEnv_BuildData *inBuildData); UUtUns32 Imp_Env_ConnectStairsToLanding(IMPtEnv_GQ *inSAT, IMPtEnv_BuildData *inBuildData); UUtBool Imp_Env_PointInNode(M3tPoint3D* inPoint,IMPtEnv_BuildData* inBuildData, IMPtEnv_BNV* inNode); @@ -651,7 +651,7 @@ UUtError IMPrEnv_Process_LightMap( IMPtEnv_BuildData* inBuildData, BFtFileRef* inSourceFileRef); - + UUtError IMPrEnv_Process_OctTrees( IMPtEnv_BuildData* inBuildData); @@ -664,7 +664,7 @@ UUtBool IMPrLM_DontProcessGQ( IMPtEnv_GQ* inGQ); -UUtUns32 +UUtUns32 IMPrEnv_GetNodeFlags( MXtNode *inNode); @@ -677,17 +677,17 @@ IMPrEnv_GetLSData( UUtUns32 *outIntensity, float *outBeamAngle, float *outFieldAngle); - + void IMPrFixedOctTree_Create(IMPtEnv_BuildData* inBuildData); void IMPrFixedOctTree_Delete(IMPtEnv_BuildData* inBuildData); void IMPrFixedOctTree_Test( - IMPtEnv_BuildData *inBuildData, - float minx, - float maxx, - float miny, - float maxy, - float minz, + IMPtEnv_BuildData *inBuildData, + float minx, + float maxx, + float miny, + float maxy, + float minz, float maxz); void PHrCreateRoomData(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV *inBNV, AKtBNVNode *node, AKtEnvironment *env); diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Process.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Process.c index ca35298..138baa5 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Process.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Process.c @@ -5,8 +5,8 @@ CREATED: Sept 3, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ @@ -62,12 +62,12 @@ iPrintSideIndices( IMPtEnv_BSP_Plane* inPlanes) { UUtUns16 i; - + for(i = 0; i < inNumPlanes; i++) { fprintf(inFile, "%02d ", inPlanes[i].ref); } - + fprintf(inFile, UUmNL); } @@ -77,7 +77,7 @@ iPrintTabs( UUtUns16 inNumTabs) { UUtUns16 i; - + for(i = 0; i < inNumTabs; i++) { fprintf(inFile, "|\t"); @@ -92,35 +92,35 @@ IMPiEnv_Process_BSP_QuadAbsSide_Get( { M3tQuad* quadArray; M3tQuad* curQuad; - + M3tPlaneEquation* planeEqu; M3tPlaneEquation* planeArray; UUtUns32 numPoints; float a, b, c, d; float result; - + M3tPoint3D* pointArray; M3tPoint3D* targetPoint; - + UUtUns16 numPos = 0; UUtUns16 numNeg = 0; UUtUns16 numEqual = 0; - + UUtUns16 i; - - + + planeArray = AUrSharedPlaneEquArray_GetList(inBuildData->sharedPlaneEquArray); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); quadArray = AUrSharedQuadArray_GetList(inBuildData->bspQuadArray); numPoints = AUrSharedPointArray_GetNum(inBuildData->sharedPointArray); - + planeEqu = planeArray + (inPlaneEquIndex & 0x7FFFFFFF); - + a = planeEqu->a; b = planeEqu->b; c = planeEqu->c; d = planeEqu->d; - + if(inPlaneEquIndex & 0x80000000) { a = -a; @@ -128,9 +128,9 @@ IMPiEnv_Process_BSP_QuadAbsSide_Get( c = -c; d = -d; } - + curQuad = quadArray + inBSPQuadIndex; - + UUmAssert(curQuad->indices[0] != curQuad->indices[1]); UUmAssert(curQuad->indices[0] != curQuad->indices[2]); UUmAssert(curQuad->indices[0] != curQuad->indices[3]); @@ -141,21 +141,21 @@ IMPiEnv_Process_BSP_QuadAbsSide_Get( for(i = 0; i < 4; i++) { if(curQuad->indices[i] == UUcMaxUns32) continue; - + UUmAssert(curQuad->indices[i] < numPoints); targetPoint = pointArray + curQuad->indices[i]; - + result = targetPoint->x * a + targetPoint->y * b + targetPoint->z * c + d; - + if(UUmFloat_CompareEqu(result, 0.0f)) numEqual++; - + else if(result < 0.0f) numPos++; else numNeg++; } - + if(numEqual == 4) return IMPcAbsSide_Postive; - + if(numNeg == 0) return IMPcAbsSide_Postive; if(numPos == 0) return IMPcAbsSide_Negative; return IMPcAbsSide_BothPosNeg; @@ -171,24 +171,24 @@ IMPiEnv_Process_BSP_PlaneAbsSide_Get( IMPtEnv_BSP_AbsoluteSideFlag absSide; UUtUns16 numPos = 0; UUtUns16 numNeg = 0; - + for(quadItr = 0; quadItr < inPlane->numQuads; quadItr++) { - absSide = + absSide = IMPiEnv_Process_BSP_QuadAbsSide_Get( inBuildData, inPlaneEquIndex, inPlane->quads[quadItr].bspQuadIndex); - + if(absSide == IMPcAbsSide_BothPosNeg) return IMPcAbsSide_BothPosNeg; - + if(absSide == IMPcAbsSide_Postive) numPos++; else numNeg++; } - + if(numPos == 0) return IMPcAbsSide_Negative; if(numNeg == 0) return IMPcAbsSide_Postive; - + return IMPcAbsSide_BothPosNeg; } @@ -199,41 +199,41 @@ IMPiEnv_Process_BSP_ChooseDividingPlane( IMPtEnv_BSP_Plane* inPlanes) { UUtInt32 posNegDiff; - + UUtInt32 minDiff = UUcMaxInt32; UUtUns32 minDiffPlaneIndex = UUcMaxUns32; UUtUns32 itr0, itr1; IMPtEnv_BSP_AbsoluteSideFlag absSide; UUtUns32 numBoth = 0; - + for(itr0 = 0; itr0 < inNumPlanes; itr0++) { posNegDiff = 0; - + for(itr1 = 0; itr1 < inNumPlanes; itr1++) { if(itr0 == itr1) continue; - - absSide = + + absSide = IMPiEnv_Process_BSP_PlaneAbsSide_Get( inBuildData, inPlanes[itr0].planeEquIndex, inPlanes + itr1); - + if(absSide == IMPcAbsSide_Postive) posNegDiff++; else if(absSide == IMPcAbsSide_Negative) posNegDiff--; else numBoth++; } - + posNegDiff = abs(posNegDiff); - + if(posNegDiff < minDiff) { minDiff = posNegDiff; minDiffPlaneIndex = itr0; } } - + return inPlanes + minDiffPlaneIndex; } @@ -243,7 +243,7 @@ static UUtError IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( IMPtEnv_BuildData* inBuildData, UUtUns32 inPlaneEquIndex, - IMPtEnv_BSP_AbsoluteSideFlag inSideToKeep, + IMPtEnv_BSP_AbsoluteSideFlag inSideToKeep, UUtUns32 inV0, UUtUns32 inV1, UUtUns32 inV2, @@ -252,15 +252,15 @@ IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( IMPtEnv_BSP_Plane *ioPlane) { UUtError error; - UUtBool added = UUcFalse; + UUtBool added = UUcFalse; //IMPtEnv_BSP_AbsoluteSideFlag debugSide; - + if(inV0 == inV1) { if(inV3 != UUcMaxUns32) { added = UUcTrue; - error = + error = AUrSharedQuadArray_AddQuad( inBuildData->bspQuadArray, inV0, @@ -278,7 +278,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( else if(inV0 == inV3) { added = UUcTrue; - error = + error = AUrSharedQuadArray_AddQuad( inBuildData->bspQuadArray, inV0, @@ -293,7 +293,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( if(inV3 != UUcMaxUns32) { added = UUcTrue; - error = + error = AUrSharedQuadArray_AddQuad( inBuildData->bspQuadArray, inV0, @@ -307,7 +307,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( else if(inV1 == inV3) { added = UUcTrue; - error = + error = AUrSharedQuadArray_AddQuad( inBuildData->bspQuadArray, inV0, @@ -320,7 +320,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( else if(inV2 == inV3) { added = UUcTrue; - error = + error = AUrSharedQuadArray_AddQuad( inBuildData->bspQuadArray, inV0, @@ -333,7 +333,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( else { added = UUcTrue; - error = + error = AUrSharedQuadArray_AddQuad( inBuildData->bspQuadArray, inV0, @@ -343,61 +343,61 @@ IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( &ioPlane->quads[ioPlane->numQuads].bspQuadIndex); UUmError_ReturnOnError(error); } - + if(added) { ioPlane->quads[ioPlane->numQuads].ref = inQuadRef; ioPlane->numQuads++; } - + return UUcError_None; } static UUtError IMPiEnv_Process_BSP_Quad_AddSplit( IMPtEnv_BuildData* inBuildData, - IMPtEnv_BSP_AbsoluteSideFlag inSideToKeep, + IMPtEnv_BSP_AbsoluteSideFlag inSideToKeep, UUtUns32 inPlaneEquIndex, IMPtEnv_BSP_Plane *ioPlane, UUtUns32 inQuadToSplit, UUtUns32 inQuadRef) { UUtError error; - + M3tPoint3D* pointArray; M3tPoint3D* targetPoint; - + M3tQuad* quadArray; M3tQuad* targetQuad; - + M3tPlaneEquation* planeEqu; M3tPlaneEquation* planeArray; UUtUns32 curPointIndex; - + UUtUns16 clipCode = 0; // bit vector, 1 means out of bounds - + UUtUns32 n0, n1; - + float a, b, c, d; float result; - + gUniqueNum++; - + planeArray = AUrSharedPlaneEquArray_GetList(inBuildData->sharedPlaneEquArray); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); quadArray = AUrSharedQuadArray_GetList(inBuildData->bspQuadArray); targetQuad = AUrSharedQuadArray_GetList(inBuildData->bspQuadArray) + inQuadToSplit; - + UUmAssert(pointArray != NULL); - + planeEqu = planeArray + (inPlaneEquIndex & 0x7FFFFFFF); - + a = planeEqu->a; b = planeEqu->b; c = planeEqu->c; d = planeEqu->d; - + if(inPlaneEquIndex & 0x80000000) { a = -a; @@ -405,18 +405,18 @@ IMPiEnv_Process_BSP_Quad_AddSplit( c = -c; d = -d; } - - + + for(curPointIndex = 0; curPointIndex < 4; curPointIndex++) { if(targetQuad->indices[curPointIndex] == UUcMaxUns32) continue; - + targetPoint = pointArray + targetQuad->indices[curPointIndex]; - + result = targetPoint->x * a + targetPoint->y * b + targetPoint->z * c + d; - + if(UUmFloat_CompareEqu(result, 0.0f)) continue; - + if(inSideToKeep == IMPcAbsSide_Postive) { if(result > 0.0f) @@ -432,16 +432,16 @@ IMPiEnv_Process_BSP_Quad_AddSplit( } } } - + if(targetQuad->indices[3] == UUcMaxUns32) { // CLIP A TRIANGLE - + /* only a few possibilities here... - + 1 is out, 0 is in - + v2 v1 v0 =========== 0 0 0 0 <- Not Possible @@ -453,14 +453,14 @@ IMPiEnv_Process_BSP_Quad_AddSplit( 6 1 1 0 7 1 1 1 <- Not Possible */ - + switch(clipCode) { case 0x0: case 0x7: UUmAssert(!"Illegal case"); break; - + case 0x1: // 0 is out, 1, 2 are in // \ *0 @@ -471,11 +471,11 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // / *n0 // / |\ // 2*------*1\ - + // Need to compute v1 -> v0 intersection, n0 // Need to compute v2 -> v0 intersection, n1 // New quad is (1, 2, n1, n0) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -485,7 +485,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -493,8 +493,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[0], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -507,7 +507,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0x2: // 1 is out, 0, 2 are in // \ *1 @@ -518,11 +518,11 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // / *n0 // / |\ // 0*------*2\ - + // Need to compute v2 -> v1 intersection, n0 // Need to compute v0 -> v1 intersection, n1 // New quad is (2, 0, n1, n0) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -532,7 +532,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -540,8 +540,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[1], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -554,7 +554,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0x3: // 0, 1 are out, 2 is in // \ *2 @@ -565,11 +565,11 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // / *n0 // / |\ // 1*------*0\ - + // Need to compute v2 -> v0 intersection, n0 // Need to compute v2 -> v1 intersection, n1 // New quad is (n0, n1, 2) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -579,7 +579,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -587,8 +587,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[1], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -601,7 +601,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0x4: // 2 is out, 0, 1 are in // \ *2 @@ -612,11 +612,11 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // / *n0 // / |\ // 1*------*0\ - + // Need to compute v0 -> v2 intersection, n0 // Need to compute v1 -> v2 intersection, n1 // New quad is (0, 1, n1, n0) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -626,7 +626,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -634,8 +634,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[2], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -648,7 +648,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0x5: // 0, 2 are out, 1 is in // \ *1 @@ -659,11 +659,11 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // / *n0 // / |\ // 0*------*2\ - + // Need to compute v1 -> v2 intersection, n0 // Need to compute v1 -> v0 intersection, n1 // New quad is (1, n0, n1) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -673,7 +673,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -681,8 +681,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[0], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -694,10 +694,10 @@ IMPiEnv_Process_BSP_Quad_AddSplit( inQuadRef, ioPlane); UUmError_ReturnOnError(error); - - #if defined(DEBUGGING) && DEBUGGING + + #if defined(DEBUGGING) && DEBUGGING { - IMPtEnv_BSP_AbsoluteSideFlag debugSide; + IMPtEnv_BSP_AbsoluteSideFlag debugSide; debugSide = IMPiEnv_Process_BSP_QuadAbsSide_Get( @@ -709,7 +709,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( } #endif break; - + case 0x6: // 1, 2 are out, 0 is in // \ *0 @@ -720,11 +720,11 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // / *n0 // / |\ // 2*------*1\ - + // Need to compute v0 -> v1 intersection, n0 // Need to compute v0 -> v2 intersection, n1 // New quad is (0, n0, n1) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -734,7 +734,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -742,8 +742,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[2], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -756,22 +756,22 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + default: UUmAssert(0); - + } - + } else { // CLIP A QUAD - + /* only a few possibilities here... - + 1 is out, 0 is in - + v3 v2 v1 v0 ============== 0 0 0 0 0 <- Not Possible @@ -791,7 +791,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( E 1 1 1 0 F 1 1 1 1 <- Not Possible */ - + switch(clipCode) { case 0x0: @@ -800,7 +800,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( case 0xF: UUmAssert(!"Illegal case"); break; - + case 0x1: // 0 is out, 1, 2, 3 is in // \ @@ -811,11 +811,11 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // | n0 // | |\ // 2*--------*1\ - + // Need to compute v1 -> v0 intersection, n0 // Need to compute v3 -> v0 intersection, n1 // New quads are (1, 2, n0) and (2, 3, n1, n0) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -823,9 +823,9 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[0], &n0); UUmError_ReturnOnError(error); - + pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -833,8 +833,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[0], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -849,7 +849,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( quadArray = AUrSharedQuadArray_GetList(inBuildData->bspQuadArray); targetQuad = quadArray + inQuadToSplit; - error = + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -862,7 +862,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0x2: // 1 is out, 0, 2, 3 is in // \ @@ -873,11 +873,11 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // | n0 // | |\ // 3*--------*2\ - + // Need to compute v2 -> v1 intersection, n0 // Need to compute v0 -> v1 intersection, n1 // New quads are (2, 3, n0) and (3, 0, n1, n0) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -886,7 +886,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n0); UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -894,8 +894,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[1], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -910,8 +910,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( quadArray = AUrSharedQuadArray_GetList(inBuildData->bspQuadArray); targetQuad = quadArray + inQuadToSplit; - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -924,7 +924,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0x3: // 0, 1 is out, 2, 3 is in // | @@ -940,7 +940,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // Need to compute v2 -> v1 intersection, n0 // Need to compute v3 -> v0 intersection, n1 // New quads are (2, 3, n1, n0) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -949,7 +949,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n0); UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -957,8 +957,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[0], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -971,7 +971,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0x4: // 2 is out, 0, 1, 3 is in // \ @@ -982,11 +982,11 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // | n0 // | |\ // 0*--------*3\ - + // Need to compute v3 -> v2 intersection, n0 // Need to compute v1 -> v2 intersection, n1 // New quads are (3, 0, n0) and (0, 1, n1, n0) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -995,7 +995,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n0); UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1003,8 +1003,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[2], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -1016,11 +1016,11 @@ IMPiEnv_Process_BSP_Quad_AddSplit( inQuadRef, ioPlane); UUmError_ReturnOnError(error); - + quadArray = AUrSharedQuadArray_GetList(inBuildData->bspQuadArray); targetQuad = quadArray + inQuadToSplit; - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -1033,7 +1033,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0x6: // 1, 2 is out, 0, 3 is in // | @@ -1049,7 +1049,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // Need to compute v3 -> v2 intersection, n0 // Need to compute v0 -> v1 intersection, n1 // New quads are (3, 0, n1, n0) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1058,7 +1058,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n0); UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1066,8 +1066,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[1], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -1080,23 +1080,23 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0x7: // 0, 1, 2 is out, 3 is in - // + // // 0*--------*1 // | | // \| | // n0 | // |\ | - // | \ | - // 3*--n1----*2 + // | \ | + // 3*--n1----*2 // \ - + // Need to compute v3 -> v0 intersection, n0 // Need to compute v3 -> v2 intersection, n1 // New quads are (3, n0, n1) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1105,7 +1105,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n0); UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1114,7 +1114,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n1); UUmError_ReturnOnError(error); - error = + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -1127,7 +1127,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0x8: // 3 is out, 0, 1, 2 is in // \ @@ -1138,11 +1138,11 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // | n0 // | |\ // 1*--------*0\ - + // Need to compute v0 -> v3 intersection, n0 // Need to compute v2 -> v3 intersection, n1 // New quads are (0, 1, n0) and (1, 2, n1, n0) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1151,7 +1151,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n0); UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1159,8 +1159,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[3], &n1); UUmError_ReturnOnError(error); - - error = + + error = AUrSharedQuadArray_AddQuad( inBuildData->bspQuadArray, targetQuad->indices[0], @@ -1169,11 +1169,11 @@ IMPiEnv_Process_BSP_Quad_AddSplit( UUcMaxUns32, &ioPlane->quads[ioPlane->numQuads].bspQuadIndex); UUmError_ReturnOnError(error); - + quadArray = AUrSharedQuadArray_GetList(inBuildData->bspQuadArray); targetQuad = quadArray + inQuadToSplit; - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -1186,7 +1186,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0x9: // 0, 3 is out, 1, 2 is in // | @@ -1203,7 +1203,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // Need to compute v2 -> v3 intersection, n1 // New quads are (1, 2, n1, n0) pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1212,7 +1212,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n0); UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1220,8 +1220,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[3], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -1234,23 +1234,23 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0xB: // 0, 1, 3 is out, 2 is in - // + // // 3*--------*0 // | | // \| | // n0 | // |\ | - // | \ | + // | \ | // 2*--n1----*1 // \ - + // Need to compute v2 -> v3 intersection, n0 // Need to compute v2 -> v1 intersection, n1 // New quads are (2, n0, n1) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1259,7 +1259,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n0); UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1268,7 +1268,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n1); UUmError_ReturnOnError(error); - error = + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -1281,7 +1281,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0xC: // 2, 3 is out, 0, 1 is in // | @@ -1297,7 +1297,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( // Need to compute v0 -> v3 intersection, n0 // Need to compute v1 -> v2 intersection, n1 // New quads are (0, 1, n1, n0) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1306,7 +1306,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n0); UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1314,8 +1314,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[2], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -1328,23 +1328,23 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0xD: // 0, 2, 3 is out,1 is in - // + // // 2*--------*3 // | | // \| | // n0 | // |\ | - // | \ | + // | \ | // 1*--n1----*0 // \ - + // Need to compute v1 -> v2 intersection, n0 // Need to compute v1 -> v0 intersection, n1 // New quads are (1, n0, n1) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1353,7 +1353,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n0); UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1361,8 +1361,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[0], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -1375,23 +1375,23 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + case 0xE: // 1, 2, 3 is out, 0 is in - // + // // 1*--------*2 // | | // \| | // n0 | // |\ | - // | \ | + // | \ | // 0*--n1----*3 // \ - + // Need to compute v0 -> v1 intersection, n0 // Need to compute v0 -> v3 intersection, n1 // New quads are (0, n0, n1) - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1400,7 +1400,7 @@ IMPiEnv_Process_BSP_Quad_AddSplit( &n0); UUmError_ReturnOnError(error); pointArray = AUrSharedPointArray_GetList(inBuildData->bspPointArray); - error = + error = AUrSharedPointArray_InterpolatePoint( inBuildData->bspPointArray, a, b, c, d, @@ -1408,8 +1408,8 @@ IMPiEnv_Process_BSP_Quad_AddSplit( pointArray + targetQuad->indices[3], &n1); UUmError_ReturnOnError(error); - - error = + + error = IMPiEnv_Process_BSP_Quad_AddSplit_AddQuad( inBuildData, inPlaneEquIndex, @@ -1422,12 +1422,12 @@ IMPiEnv_Process_BSP_Quad_AddSplit( ioPlane); UUmError_ReturnOnError(error); break; - + default: UUmAssert(!"Illegal case"); } } - + return UUcError_None; } @@ -1442,19 +1442,19 @@ IMPiEnv_Process_BSP_Plane_Split( UUtError error; UUtUns16 quadItr; IMPtEnv_BSP_AbsoluteSideFlag quadAbsSide; - + outResultPlane->planeEquIndex = inPlaneToSplit->planeEquIndex; outResultPlane->ref = inPlaneToSplit->ref; outResultPlane->numQuads = 0; for(quadItr = 0; quadItr < inPlaneToSplit->numQuads; quadItr++) { - quadAbsSide = + quadAbsSide = IMPiEnv_Process_BSP_QuadAbsSide_Get( inBuildData, inSplittingPlaneEquIndex, inPlaneToSplit->quads[quadItr].bspQuadIndex); - + if(quadAbsSide == IMPcAbsSide_BothPosNeg) { @@ -1462,9 +1462,9 @@ IMPiEnv_Process_BSP_Plane_Split( { UUmError_ReturnOnErrorMsg(UUcError_Generic,"Too many quads on a plane"); } - - - error = + + + error = IMPiEnv_Process_BSP_Quad_AddSplit( inBuildData, inSideToKeep, @@ -1473,7 +1473,7 @@ IMPiEnv_Process_BSP_Plane_Split( inPlaneToSplit->quads[quadItr].bspQuadIndex, inPlaneToSplit->quads[quadItr].ref); UUmError_ReturnOnError(error); - + } else if(quadAbsSide == inSideToKeep) { @@ -1481,11 +1481,11 @@ IMPiEnv_Process_BSP_Plane_Split( { UUmError_ReturnOnErrorMsg(UUcError_Generic,"Too many quads on a plane"); } - + outResultPlane->quads[outResultPlane->numQuads++] = inPlaneToSplit->quads[quadItr]; } } - + return UUcError_None; } @@ -1508,13 +1508,13 @@ IMPiEnv_Process_BSP_Plane_BuildNewList( UUtUns32 numNewPlanes = 0; IMPtEnv_BSP_AbsoluteSideFlag absPlaneSide; IMPtEnv_BSP_Plane* newAllocatedList; - + planeEquIndex = inDividingPlane->planeEquIndex; for(planeItr = 0; planeItr < inNumPlanes; planeItr++) { curPlane = inPlanes + planeItr; - + if(curPlane == inDividingPlane) { if(inSideToKeep == IMPcAbsSide_Postive && inDividingPlane->numQuads > 0) @@ -1523,16 +1523,16 @@ IMPiEnv_Process_BSP_Plane_BuildNewList( } continue; } - + absPlaneSide = IMPiEnv_Process_BSP_PlaneAbsSide_Get( inBuildData, planeEquIndex, curPlane); - + if(absPlaneSide == IMPcAbsSide_BothPosNeg) { - error = + error = IMPiEnv_Process_BSP_Plane_Split( inBuildData, inSideToKeep, @@ -1540,7 +1540,7 @@ IMPiEnv_Process_BSP_Plane_BuildNewList( curPlane, IMPgEnv_NewPlanes + numNewPlanes); UUmError_ReturnOnError(error); - + if(IMPgEnv_NewPlanes[numNewPlanes].numQuads > 0) numNewPlanes++; } else if(absPlaneSide == inSideToKeep) @@ -1548,11 +1548,11 @@ IMPiEnv_Process_BSP_Plane_BuildNewList( IMPgEnv_NewPlanes[numNewPlanes++] = *curPlane; } } - + #if 0 for(planeItr = 0; planeItr < numNewPlanes; planeItr++) { - absPlaneSide = + absPlaneSide = IMPiEnv_Process_BSP_PlaneAbsSide_Get( inBuildData, inDividingPlane->planeEquIndex, @@ -1560,20 +1560,20 @@ IMPiEnv_Process_BSP_Plane_BuildNewList( UUmAssert(absPlaneSide == inSideToKeep); } #endif - + // allocate and create new plane list - - newAllocatedList = + + newAllocatedList = UUrMemory_Pool_Block_New( IMPgEnv_MemoryPool, numNewPlanes * sizeof(IMPtEnv_BSP_Plane)); UUmError_ReturnOnNull(newAllocatedList); - + UUrMemory_MoveFast(IMPgEnv_NewPlanes, newAllocatedList, numNewPlanes * sizeof(IMPtEnv_BSP_Plane)); - + *outNumNewPlanes = numNewPlanes; *outPlaneList = newAllocatedList; - + return UUcError_None; } @@ -1591,36 +1591,36 @@ IMPiEnv_Process_BSP_Build_Recursive( UUtUns32 numNewNegPlanes; IMPtEnv_BSP_Plane* newPosPlanes; IMPtEnv_BSP_Plane* newNegPlanes; - + IMPtEnv_BSP_Node* newNode; UUtUns32 length = 0; if ((0 == inNumPlanes) && (NULL == outNewIndex)) { return UUcError_None; } - + // find dividing plane divPlane = IMPiEnv_Process_BSP_ChooseDividingPlane( inBuildData, inNumPlanes, inPlanes); - + UUmAssert(divPlane->numQuads > 0); - - // create the node + + // create the node if(inBuildData->numBSPNodes >= IMPcEnv_MaxNumBSPNodes) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Ran out of BSP nodes"); } - + newNode = inBuildData->bspNodes + inBuildData->numBSPNodes++; - + if((inBuildData->numBSPNodes % 50) == 0) Imp_PrintMessage(IMPcMsg_Important,"."); - + newNode->splittingPlane = divPlane; newNode->splittingQuad = divPlane->quads[--divPlane->numQuads]; - + if(outNewIndex != NULL) *outNewIndex = inBuildData->numBSPNodes - 1; // Find all the GQs on the positive div plane @@ -1632,14 +1632,14 @@ IMPiEnv_Process_BSP_Build_Recursive( inPlanes, &numNewPosPlanes, &newPosPlanes); - + if(numNewPosPlanes == 0) { newNode->posNodeIndex = 0xFFFFFFFF; } else { - error = + error = IMPiEnv_Process_BSP_Build_Recursive( inBuildData, inLevel + 1, @@ -1648,7 +1648,7 @@ IMPiEnv_Process_BSP_Build_Recursive( &newNode->posNodeIndex); UUmError_ReturnOnError(error); } - + // Find all the GQs on the neg div plane IMPiEnv_Process_BSP_Plane_BuildNewList( inBuildData, @@ -1658,14 +1658,14 @@ IMPiEnv_Process_BSP_Build_Recursive( inPlanes, &numNewNegPlanes, &newNegPlanes); - + if(numNewNegPlanes == 0) { newNode->negNodeIndex = 0xFFFFFFFF; } else { - error = + error = IMPiEnv_Process_BSP_Build_Recursive( inBuildData, inLevel + 1, @@ -1674,9 +1674,9 @@ IMPiEnv_Process_BSP_Build_Recursive( &newNode->negNodeIndex); UUmError_ReturnOnError(error); } - + UUmAssert((numNewPosPlanes + numNewNegPlanes) >= (inNumPlanes - 1)); - + return UUcError_None; } @@ -1686,26 +1686,26 @@ IMPiEnv_Process_BSP_BNV_Build( IMPtEnv_BNV* inBNV) { UUtError error; - + IMPtEnv_BSP_Plane* bspPlaneList; IMPtEnv_BSP_Plane* curBSPPlane; - + UUtUns16 curBNVSideIndex; IMPtEnv_BNV_Side* curBNVSide; - + M3tPoint3D* pointArray; - + UUtUns32 curQuadIndex; - + M3tQuad newQuad; - + UUtUns32 curPointIndex; M3tPoint3D* targetPoint; - + M3tQuad* curQuad; M3tQuad* quadArray; UUtUns16 nodeItr; - + inBuildData->numBSPNodes = 0; pointArray = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); @@ -1714,10 +1714,10 @@ IMPiEnv_Process_BSP_BNV_Build( UUrMemory_Pool_Reset(IMPgEnv_MemoryPool); AUrSharedPointArray_Reset(inBuildData->bspPointArray); AUrSharedQuadArray_Reset(inBuildData->bspQuadArray); - + bspPlaneList = UUrMemory_Pool_Block_New(IMPgEnv_MemoryPool, inBNV->numSides * sizeof(IMPtEnv_BSP_Plane)); UUmError_ReturnOnNull(bspPlaneList); - + for(curBNVSideIndex = 0, curBNVSide = inBNV->sides, curBSPPlane = bspPlaneList; curBNVSideIndex < inBNV->numSides; curBNVSideIndex++, curBNVSide++, curBSPPlane++) @@ -1725,16 +1725,16 @@ IMPiEnv_Process_BSP_BNV_Build( curBSPPlane->numQuads = curBNVSide->numBNVQuads; curBSPPlane->planeEquIndex = curBNVSide->planeEquIndex; curBSPPlane->ref = curBNVSideIndex; - + for(curQuadIndex = 0; curQuadIndex < curBNVSide->numBNVQuads; curQuadIndex++) { curQuad = quadArray + curBNVSide->bnvQuadList[curQuadIndex]; - + for(curPointIndex = 0; curPointIndex < 4; curPointIndex++) { targetPoint = pointArray + curQuad->indices[curPointIndex]; - - error = + + error = AUrSharedPointArray_AddPoint( inBuildData->bspPointArray, targetPoint->x, @@ -1743,7 +1743,7 @@ IMPiEnv_Process_BSP_BNV_Build( &newQuad.indices[curPointIndex]); UUmError_ReturnOnError(error); } - + UUmAssert(newQuad.indices[0] != newQuad.indices[1]); UUmAssert(newQuad.indices[0] != newQuad.indices[2]); UUmAssert(newQuad.indices[0] != newQuad.indices[3]); @@ -1751,7 +1751,7 @@ IMPiEnv_Process_BSP_BNV_Build( UUmAssert(newQuad.indices[1] != newQuad.indices[3]); UUmAssert(newQuad.indices[2] != newQuad.indices[3]); - error = + error = AUrSharedQuadArray_AddQuad( inBuildData->bspQuadArray, newQuad.indices[0], @@ -1760,12 +1760,12 @@ IMPiEnv_Process_BSP_BNV_Build( newQuad.indices[3], &curBSPPlane->quads[curQuadIndex].bspQuadIndex); UUmError_ReturnOnError(error); - + curBSPPlane->quads[curQuadIndex].ref = 0xE1117E; } } - - error = + + error = IMPiEnv_Process_BSP_Build_Recursive( inBuildData, 0, @@ -1773,22 +1773,22 @@ IMPiEnv_Process_BSP_BNV_Build( bspPlaneList, NULL); UUmError_ReturnOnError(error); - + // convert to BNV bsp nodes if(inBuildData->numBSPNodes > IMPcEnv_MaxNumBNVBSPNodes) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "too many bnv bsp nodes"); } - + inBNV->numNodes = inBuildData->numBSPNodes; - + for(nodeItr = 0; nodeItr < inBuildData->numBSPNodes; nodeItr++) { inBNV->bspNodes[nodeItr].planeEquIndex = inBuildData->bspNodes[nodeItr].splittingPlane->planeEquIndex; inBNV->bspNodes[nodeItr].posNodeIndex = inBuildData->bspNodes[nodeItr].posNodeIndex; inBNV->bspNodes[nodeItr].negNodeIndex = inBuildData->bspNodes[nodeItr].negNodeIndex; } - + return UUcError_None; } @@ -1800,31 +1800,31 @@ IMPiEnv_Process_BSP_PointInBSP( float inTolerance) { AKtBNV_BSPNode* curNode; - + M3tPlaneEquation* planeEqu; M3tPlaneEquation* planeArray; - + float a, b, c, d, threshold; UUtUns32 curNodeIndex; static UUtBool invalid_bnv_once = UUcTrue; - + UUmAssert(inBNV->numNodes > 0); UUmAssert(inBNV->numSides > 0); if (((0 == inBNV->numNodes) || (0 == inBNV->numSides)) && invalid_bnv_once) { - Imp_PrintWarning("BNV file %s object %s had %d nodes and %d sides, it should have atleast one of each. You will only get this error once per importer session.", - inBNV->fileName, + Imp_PrintWarning("BNV file %s object %s had %d nodes and %d sides, it should have atleast one of each. You will only get this error once per importer session.", + inBNV->fileName, inBNV->objName, inBNV->numNodes, inBNV->numSides); invalid_bnv_once = UUcFalse; } - + planeArray = AUrSharedPlaneEquArray_GetList(inBuildData->sharedPlaneEquArray); - + curNodeIndex = 0; - + while(1) { UUmAssert(curNodeIndex < inBNV->numNodes); @@ -1834,12 +1834,12 @@ IMPiEnv_Process_BSP_PointInBSP( planeEqu = planeArray + (curNode->planeEquIndex & 0x7FFFFFFF); UUmAssertReadPtr(planeEqu, sizeof(*planeEqu)); - + a = planeEqu->a; b = planeEqu->b; c = planeEqu->c; d = planeEqu->d; - + if(curNode->planeEquIndex & 0x80000000) { a = -a; @@ -1847,11 +1847,11 @@ IMPiEnv_Process_BSP_PointInBSP( c = -c; d = -d; } - + threshold = (curNode->negNodeIndex == 0xFFFFFFFF) ? inTolerance : 0.0f; - if(UUmFloat_CompareLE(inPoint->x * a + - inPoint->y * b + + if(UUmFloat_CompareLE(inPoint->x * a + + inPoint->y * b + inPoint->z * c + d, threshold)) { if(0xFFFFFFFF == curNode->posNodeIndex) @@ -1892,24 +1892,24 @@ IMPiEnv_Process_Alpha_BSP_Build( UUtUns32 gqItr; UUtUns32 planeItr; IMPtEnv_BSP_Quad* curPlaneQuad; - + UUtUns32 numPlanes = 0; IMPtEnv_BSP_Plane* planes; UUtUns16 nodeItr; UUtInt64 time = UUrMachineTime_High(); - + //return UUcError_None; - + Imp_PrintMessage(IMPcMsg_Important,"Building Alpha BSP tree (%d gqs)...", inNumGQs); - + inBuildData->numBSPNodes = 0; - + pointArray = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); UUrMemory_Pool_Reset(IMPgEnv_MemoryPool); AUrSharedPointArray_Reset(inBuildData->bspPointArray); AUrSharedQuadArray_Reset(inBuildData->bspQuadArray); - + planes = UUrMemory_Pool_Block_New( IMPgEnv_MemoryPool, @@ -1918,11 +1918,11 @@ IMPiEnv_Process_Alpha_BSP_Build( Imp_PrintWarning("failed to allocate %d bytes", inNumGQs * sizeof(IMPtEnv_BSP_Plane)); return UUcError_OutOfMemory; } - + for(gqItr = 0; gqItr < inNumGQs; gqItr++) { curGQ = inBuildData->gqList + inGQIndices[gqItr]; - + // check to see if an existing plane exists for this gq for(planeItr = 0; planeItr < numPlanes; planeItr++) { @@ -1930,7 +1930,7 @@ IMPiEnv_Process_Alpha_BSP_Build( break; } } - + // alloc new plane if needed if(planeItr >= numPlanes) { @@ -1939,7 +1939,7 @@ IMPiEnv_Process_Alpha_BSP_Build( planes[numPlanes].ref = 0x7175; // this is not used planeItr = numPlanes++; } - + if(planes[planeItr].numQuads >= (IMPcEnv_MaxQuadsPerPlane / 2)) { UUmAssert(0); @@ -1948,17 +1948,17 @@ IMPiEnv_Process_Alpha_BSP_Build( planes[numPlanes].ref = 0x7175; // this is not used planeItr = numPlanes++; } - + // add this gq to this plane curPlaneQuad = planes[planeItr].quads + planes[planeItr].numQuads++; - + curPlaneQuad->ref = inGQIndices[gqItr]; - + for(curPointIndex = 0; curPointIndex < 4; curPointIndex++) { targetPoint = pointArray + curGQ->visibleQuad.indices[curPointIndex]; - - error = + + error = AUrSharedPointArray_AddPoint( inBuildData->bspPointArray, targetPoint->x, @@ -1966,12 +1966,12 @@ IMPiEnv_Process_Alpha_BSP_Build( targetPoint->z, &newQuad.indices[curPointIndex]); UUmError_ReturnOnError(error); - + } - + if(newQuad.indices[2] == newQuad.indices[3]) { - error = + error = AUrSharedQuadArray_AddQuad( inBuildData->bspQuadArray, newQuad.indices[0], @@ -1982,8 +1982,8 @@ IMPiEnv_Process_Alpha_BSP_Build( UUmError_ReturnOnError(error); } else - { - error = + { + error = AUrSharedQuadArray_AddQuad( inBuildData->bspQuadArray, newQuad.indices[0], @@ -1994,8 +1994,8 @@ IMPiEnv_Process_Alpha_BSP_Build( UUmError_ReturnOnError(error); } } - - error = + + error = IMPiEnv_Process_BSP_Build_Recursive( inBuildData, 0, @@ -2003,11 +2003,11 @@ IMPiEnv_Process_Alpha_BSP_Build( planes, NULL); UUmError_ReturnOnError(error); - + // convert the bsp nodes into alpha bsp nodes { inBuildData->numAlphaBSPNodes = inBuildData->numBSPNodes; - + for(nodeItr = 0; nodeItr < inBuildData->numBSPNodes; nodeItr++) { inBuildData->alphaBSPNodes[nodeItr].gqIndex = inBuildData->bspNodes[nodeItr].splittingQuad.ref; @@ -2016,7 +2016,7 @@ IMPiEnv_Process_Alpha_BSP_Build( inBuildData->alphaBSPNodes[nodeItr].negNodeIndex = inBuildData->bspNodes[nodeItr].negNodeIndex; } } - + fprintf(IMPgEnv_StatsFile, "**Alpha BSP stats"UUmNL); fprintf(IMPgEnv_StatsFile,"\tnodes = %d\n", inBuildData->numAlphaBSPNodes); @@ -2036,17 +2036,17 @@ IMPiEnv_Process_BNV_ContainsBNV( UUtUns32 curSideIndex; UUtUns32 pointCount = 0; IMPtEnv_BNV_Side* curSide; - + M3tQuad* quadList; M3tQuad* curQuad; M3tPoint3D* pointList; M3tPoint3D centerPoint = {0,0,0}; M3tPlaneEquation* planeEquList; - + quadList = AUrSharedQuadArray_GetList(inBuildData->sharedBNVQuadArray); pointList = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); planeEquList = AUrSharedPlaneEquArray_GetList(inBuildData->sharedPlaneEquArray); - + for(curSideIndex = 0, curSide = inChildBNV->sides; curSideIndex < inChildBNV->numSides; curSideIndex++, curSide++) @@ -2054,7 +2054,7 @@ IMPiEnv_Process_BNV_ContainsBNV( for(curQuadIndex = 0; curQuadIndex < curSide->numBNVQuads; curQuadIndex++) { curQuad = quadList + curSide->bnvQuadList[curQuadIndex]; - + for(i = 0; i < 4; i++) { if (inChildBNV->flags & AKcBNV_Flag_Stairs) @@ -2063,7 +2063,7 @@ IMPiEnv_Process_BNV_ContainsBNV( MUmVector_Increment(centerPoint,*(pointList + curQuad->indices[i])); pointCount++; } - + else if(IMPiEnv_Process_BSP_PointInBSP( inBuildData, inParentBNV, @@ -2074,7 +2074,7 @@ IMPiEnv_Process_BNV_ContainsBNV( } } } - + if (inChildBNV->flags & AKcBNV_Flag_Stairs) { MUmVector_Scale(centerPoint,(1.0f / (float)pointCount)); @@ -2083,25 +2083,25 @@ IMPiEnv_Process_BNV_ContainsBNV( inParentBNV, ¢erPoint, 0) == UUcFalse) return UUcFalse; } - + return UUcTrue; } - + static void IMPiEnv_Process_BNV_FindParents( IMPtEnv_BuildData* inBuildData) { IMPtEnv_BNV* curChildBNV; IMPtEnv_BNV* curParentBNV; - + UUtUns16 curChildIndex, curParentIndex; - + float parentVolume; UUtUns32 parentIndex; - + UUtBool isLeaf; UUtInt64 time = UUrMachineTime_High(); - + Imp_PrintMessage(IMPcMsg_Important, "determining BNV parents"); for( @@ -2113,11 +2113,11 @@ IMPiEnv_Process_BNV_FindParents( { Imp_PrintMessage(IMPcMsg_Important, "."); } - + parentIndex = 0xFFFFFFFF; parentVolume = UUcFloat_Max; isLeaf = UUcTrue; - + // Idea here is to find the tightest fit enclosing BNV for( curParentIndex = 0, curParentBNV = inBuildData->bnvList; @@ -2132,23 +2132,23 @@ IMPiEnv_Process_BNV_FindParents( { /// XXX preventing Power Plant from imping - Add this again someday? UUmAssert(curChildBNV->volume <= curParentBNV->volume); } - + if(curParentBNV->volume < parentVolume) { parentVolume = curParentBNV->volume; parentIndex = curParentIndex; } } - + if(IMPiEnv_Process_BNV_ContainsBNV(inBuildData, curChildBNV, curParentBNV)) { //isLeaf = UUcFalse; } } } - + curChildBNV->isLeaf = isLeaf; - + if(parentIndex == 0xFFFFFFFF) { curChildBNV->parent = 0xFFFFFFFF; @@ -2158,7 +2158,7 @@ IMPiEnv_Process_BNV_FindParents( curChildBNV->parent = parentIndex; } } - + time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); } @@ -2173,9 +2173,9 @@ IMPiEnv_Process_BNV_AnalyzeParents_Recursive( UUtUns16 curBNVIndex; IMPtEnv_BNV* curBNV; UUtBool foundChild; - + foundChild = UUcFalse; - + for(curBNVIndex = 0, curBNV = inBuildData->bnvList; curBNVIndex < inBuildData->numBNVs; curBNVIndex++, curBNV++) @@ -2183,9 +2183,9 @@ IMPiEnv_Process_BNV_AnalyzeParents_Recursive( if(curBNV->parent == inParent) { UUmAssert(0xFFFFFFFF == curBNV->level); - + foundChild = UUcTrue; - + curBNV->level = inLevel; IMPiEnv_Process_BNV_AnalyzeParents_Recursive( inBuildData, @@ -2194,7 +2194,7 @@ IMPiEnv_Process_BNV_AnalyzeParents_Recursive( inLevel+1); } } - + if(foundChild == UUcFalse) { UUmAssert(inBNV->isLeaf == UUcTrue); @@ -2203,7 +2203,7 @@ IMPiEnv_Process_BNV_AnalyzeParents_Recursive( { //UUmAssert(inBNV->isLeaf == UUcFalse); } - + if(inBNV->isLeaf == UUcTrue) { //UUmAssert(foundChild == UUcFalse); @@ -2221,12 +2221,12 @@ IMPiEnv_Process_BNV_AnalyzeParents( // IMPtEnv_BNV* curChildBNV; UUtUns16* bnvInsertionArray; UUtInt64 time = UUrMachineTime_High(); - + Imp_PrintMessage(IMPcMsg_Important, "analyzing BNV parents"); bnvInsertionArray = UUrMemory_Block_NewClear(sizeof(UUtUns16) * inBuildData->numBNVs); UUmError_ReturnOnNull(bnvInsertionArray); - + // compute the levels for(curBNVIndex = 0, curBNV = inBuildData->bnvList; curBNVIndex < inBuildData->numBNVs; @@ -2240,11 +2240,11 @@ IMPiEnv_Process_BNV_AnalyzeParents( if(0xFFFFFFFF == curBNV->parent) { curBNV->level = 0; - + IMPiEnv_Process_BNV_AnalyzeParents_Recursive(inBuildData, curBNV, curBNVIndex, 1); } } - + // Compute the child and next pointers for(curBNVIndex = 0, curBNV = inBuildData->bnvList; curBNVIndex < inBuildData->numBNVs; @@ -2270,7 +2270,7 @@ IMPiEnv_Process_BNV_AnalyzeParents( bnvInsertionArray[curBNV->parent] = curBNVIndex; } } - + // Do one more pass for room flag and error reporting for(curBNVIndex = 0, curBNV = inBuildData->bnvList; curBNVIndex < inBuildData->numBNVs; @@ -2286,9 +2286,9 @@ IMPiEnv_Process_BNV_AnalyzeParents( curBNV->flags |= AKcBNV_Flag_Room; } } - + UUrMemory_Block_Delete(bnvInsertionArray); - + time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); @@ -2304,13 +2304,13 @@ IMPiEnv_Process_BNV_QuadLiesOnSide( { UUtUns16 curPointIndex; UUtUns16 curQuadIndex; - + M3tPoint3D* pointArray; M3tQuad* quadArray; - + M3tPoint3D* curPoint; M3tPoint3D centerPoint; - + float minX, minY, minZ; float maxX, maxY, maxZ; @@ -2321,7 +2321,7 @@ IMPiEnv_Process_BNV_QuadLiesOnSide( { return UUcFalse; } - + // Compute center of this quad curPoint = pointArray + quadArray[inQuadIndex].indices[0]; @@ -2332,12 +2332,12 @@ IMPiEnv_Process_BNV_QuadLiesOnSide( for(curPointIndex = 1; curPointIndex < 4; curPointIndex++) { curPoint = pointArray + quadArray[inQuadIndex].indices[curPointIndex]; - + UUmMinMax(curPoint->x, minX, maxX); UUmMinMax(curPoint->y, minY, maxY); UUmMinMax(curPoint->z, minZ, maxZ); } - + centerPoint.x = (minX + maxX) * 0.5f; centerPoint.y = (minY + maxY) * 0.5f; centerPoint.z = (minZ + maxZ) * 0.5f; @@ -2346,14 +2346,14 @@ IMPiEnv_Process_BNV_QuadLiesOnSide( { if(CLrQuad_PointInQuad( CLcProjection_Unknown, - pointArray, + pointArray, quadArray + inBNVSide->bnvQuadList[curQuadIndex], ¢erPoint) == UUcTrue) { return UUcTrue; } } - + return UUcFalse; } @@ -2367,7 +2367,7 @@ IMPrEnv_Process_BNV_BuildBSP( Imp_PrintMessage(IMPcMsg_Important, UUmNL"computing BNV BSP trees"); - + for(curBNVIndex = 0, curBNV = inBuildData->bnvList; curBNVIndex < inBuildData->numBNVs; curBNVIndex++, curBNV++) @@ -2383,14 +2383,14 @@ IMPrEnv_Process_BNV_BuildBSP( time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); - + return UUcError_None; } static UUtBool IsGhostQuadOnThisSide( - IMPtEnv_BuildData *inBuildData, - IMPtEnv_BNV_Side *curSide, + IMPtEnv_BuildData *inBuildData, + IMPtEnv_BNV_Side *curSide, IMPtEnv_GQ *current_ghost_quad) { // RULE #1 the planes must be almost coplanar (normal facing doesn't matter) @@ -2423,7 +2423,7 @@ IsGhostQuadOnThisSide( for(curQuadIndex = 0; curQuadIndex < curSide->numBNVQuads; curQuadIndex++) { M3tQuad *current_bnv_face_quad = sharedQuads + curSide->bnvQuadList[curQuadIndex]; - + if (CLrQuad_PointInQuad(CLcProjection_Unknown, sharedPoints, current_bnv_face_quad, ghost_quad_vertex)) { ghost_quad_vertex_lies_on_this_side = UUcTrue; break; @@ -2436,7 +2436,7 @@ IsGhostQuadOnThisSide( } is_ghost_quad_on_this_side = UUcTrue; - + exit: return is_ghost_quad_on_this_side; } @@ -2445,7 +2445,7 @@ static void FindSpecialQuadsOnThisSide(IMPtEnv_BuildData *inBuildData, IMPtEnv_B { UUtUns32 special_quad_itr; M3tPoint3D *sharedPoints = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); - + for(special_quad_itr = 0; special_quad_itr < num_special_quads; special_quad_itr++) { UUtUns32 current_ghost_index = special_quad_indicies[special_quad_itr]; @@ -2472,12 +2472,12 @@ static void FindSpecialQuadsOnThisSide(IMPtEnv_BuildData *inBuildData, IMPtEnv_B continue; } } - + // if we get here then current_ghost_quad is on this side if(curSide->numGQGhostIndices > IMPcEnv_MaxQuadsPerSide) { Imp_PrintWarning("Exceeded max number of GQ ghost things FILE %s LINE %d",__FILE__, __LINE__); } - + curSide->gqGhostIndices[curSide->numGQGhostIndices++] = current_ghost_index; } @@ -2510,7 +2510,7 @@ static void IMP_BNV_Compute_BoundingBox_And_Volume(IMPtEnv_BuildData *inBuildDat for(curPointIndex = 0; curPointIndex < 4; curPointIndex++) { const M3tPoint3D *curPoint = sharedPoints + sharedQuads[curSide->bnvQuadList[curQuadIndex]].indices[curPointIndex]; - + UUmMinMax(curPoint->x, curBNV->minX, curBNV->maxX); UUmMinMax(curPoint->y, curBNV->minY, curBNV->maxY); UUmMinMax(curPoint->z, curBNV->minZ, curBNV->maxZ); @@ -2531,17 +2531,17 @@ IMPrEnv_Process_BNV_ComputeProperties( UUtUns16 curBNVIndex, curSideIndex; IMPtEnv_BNV* curBNV; IMPtEnv_BNV_Side* curSide; - + M3tPoint3D* curPoint; M3tPoint3D* sharedPoints; M3tQuad* sharedQuads; - + UUtUns32 curGQIndex; UUtUns32 curVertexIndex; - + IMPtEnv_GQ* curGQ; - - + + M3tPlaneEquation* planes; UUtInt64 time; @@ -2557,7 +2557,7 @@ IMPrEnv_Process_BNV_ComputeProperties( sharedQuads = AUrSharedQuadArray_GetList(inBuildData->sharedBNVQuadArray); sharedPoints = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); planes = AUrSharedPlaneEquArray_GetList(inBuildData->sharedPlaneEquArray); - + num_special_quads = 0; for(curGQIndex = 0, curGQ = inBuildData->gqList; curGQIndex < inBuildData->numGQs; curGQIndex++, curGQ++) { @@ -2582,7 +2582,7 @@ IMPrEnv_Process_BNV_ComputeProperties( time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); - + time = UUrMachineTime_High(); Imp_PrintMessage(IMPcMsg_Important, "computing BNV properties"); @@ -2593,23 +2593,23 @@ IMPrEnv_Process_BNV_ComputeProperties( if((curBNVIndex % 10) == 0) { Imp_PrintMessage(IMPcMsg_Important, "."); } - + // Check for BNVs less then 5 sides if(curBNV->numSides < 5) { Imp_PrintWarning("BNV %d has less then 5 sides File: %s, Obj: %s", curBNVIndex, curBNV->fileName, curBNV->objName); - } + } - // Compute bounding box + // Compute bounding box IMP_BNV_Compute_BoundingBox_And_Volume(inBuildData, curBNV); // test the oct tree IMPrFixedOctTree_Test( - inBuildData, - curBNV->minX - 2.f, - curBNV->maxX + 2.f, - curBNV->minY - 2.f, - curBNV->maxY + 2.f, - curBNV->minZ - 2.f, + inBuildData, + curBNV->minX - 2.f, + curBNV->maxX + 2.f, + curBNV->minY - 2.f, + curBNV->maxY + 2.f, + curBNV->minZ - 2.f, curBNV->maxZ + 2.f); // we are going to build up the gq ghost indices for each side of this BNV @@ -2624,9 +2624,9 @@ IMPrEnv_Process_BNV_ComputeProperties( continue; } - FindSpecialQuadsOnThisSide(inBuildData, curBNV, curSide, special_quad_indicies, num_special_quads); + FindSpecialQuadsOnThisSide(inBuildData, curBNV, curSide, special_quad_indicies, num_special_quads); } - + #if defined(DEBUGGING) && DEBUGGING // CB: this test makes sure that a ghost quad isn't mistakenly added to multiple sides for (curSideIndex = 0; curSideIndex < curBNV->numSides; curSideIndex++) { @@ -2660,16 +2660,16 @@ IMPrEnv_Process_BNV_ComputeProperties( } curGQ = inBuildData->gqList + curGQIndex; - + for(curVertexIndex = 0; curVertexIndex < 4; curVertexIndex++) { curPoint = sharedPoints + curGQ->visibleQuad.indices[curVertexIndex]; - + if (IMPiEnv_Process_BSP_PointInBSP(inBuildData, curBNV, curPoint, 0)) { if (curBNV->numGQs >= IMPcEnv_MaxGQsPerBNV) { - Imp_PrintWarning("Exceeded IMPcEnv_MaxGQsPerBNV in FILE: \"%s\" OBJ: \"%s\" max is %d", - curBNV->fileName, + Imp_PrintWarning("Exceeded IMPcEnv_MaxGQsPerBNV in FILE: \"%s\" OBJ: \"%s\" max is %d", + curBNV->fileName, curBNV->objName, IMPcEnv_MaxGQsPerBNV); } @@ -2678,9 +2678,9 @@ IMPrEnv_Process_BNV_ComputeProperties( break; } - } + } } - + // Compute plane of stairs between bottoms of SATs for standard stairs if (curBNV->flags & AKcBNV_Flag_Stairs_Standard) { M3tPoint3D *a, *b, *up0,*up1,*dn0,*dn1, *ph0, *ph1, *ph2, *ph3; @@ -2688,7 +2688,7 @@ IMPrEnv_Process_BNV_ComputeProperties( float h0, h1, h2, h3; UUtUns32 upsat_number = 0, downsat_number = 0; IMPtEnv_GQ *upsat, *downsat; - + up0 = up1 = dn0 = dn1 = NULL; upsat = downsat = NULL; for(curSideIndex = 0, curSide = curBNV->sides; @@ -2779,7 +2779,7 @@ IMPrEnv_Process_BNV_ComputeProperties( time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); - + return UUcError_None; } @@ -2788,18 +2788,18 @@ IMPrEnv_Process_BNV_ComputeAdjacency( IMPtEnv_BuildData* inBuildData) { // Create the adjacency data for each node - Warning! Icky O(n^2) algorithm! Ew! Eek! - + UUtUns32 curBNVIndex,curSideIndex,curGQIndex; UUtUns32 curBNVIndex2,curSideIndex2,curGQIndex2; IMPtEnv_BNV *curBNV,*curBNV2; IMPtEnv_BNV_Side *curSide,*curSide2; IMPtEnv_GQ *curGQ; UUtInt64 time = UUrMachineTime_High(); - + //#define DEBUG_ADJ Imp_PrintMessage(IMPcMsg_Important,"Finding adjacencies..."); IMPgEnv_VerifyAdjCount = 0; - + for(curBNVIndex = 0; curBNVIndex < inBuildData->numBNVs; curBNVIndex++) { if((curBNVIndex % 20) == 0) @@ -2812,7 +2812,7 @@ IMPrEnv_Process_BNV_ComputeAdjacency( Imp_PrintMessage(IMPcMsg_Important,"- Adjacency for node %d -"UUmNL,curBNVIndex); #endif curBNV = &inBuildData->bnvList[curBNVIndex]; - + // Cycle through all the sides of the node for (curSideIndex = 0; curSideIndex < curBNV->numSides; curSideIndex++) { @@ -2821,7 +2821,7 @@ IMPrEnv_Process_BNV_ComputeAdjacency( curSide->numAdjacencies = 0; if (!(curBNV->flags & AKcBNV_Flag_Room)) continue; // Tree node sides are done now if (curBNV->flags & AKcBNV_Flag_NonAI) continue; - + for (curGQIndex=0; curGQIndexnumGQGhostIndices; curGQIndex++) { // Now check all the other nodes for matching ghosts @@ -2842,7 +2842,7 @@ IMPrEnv_Process_BNV_ComputeAdjacency( { // Found a shared ghost- make a note of it Imp_Env_AddAdjacency(curSide,curBNV,curSide2,curBNVIndex2,curSide2->gqGhostIndices[curGQIndex2],0,inBuildData); - + #ifdef DEBUG_ADJ Imp_PrintMessage(IMPcMsg_Important,"\tNode %d, sharing ghost #%d"UUmNL,curBNVIndex2,curSide2->gqGhostIndices[curGQIndex2]); #endif @@ -2853,8 +2853,8 @@ IMPrEnv_Process_BNV_ComputeAdjacency( } } } - - // Check for stair adjacencies + + // Check for stair adjacencies for(curBNVIndex = 0; curBNVIndex < inBuildData->numBNVs; curBNVIndex++) { if((curBNVIndex % 20) == 0) @@ -2866,7 +2866,7 @@ IMPrEnv_Process_BNV_ComputeAdjacency( if (!(curBNV->flags & AKcBNV_Flag_Room)) continue; // Only room nodes from here on! if (curBNV->flags & AKcBNV_Flag_Stairs) continue; // Skip stairs at this stage if (curBNV->flags & AKcBNV_Flag_NonAI) continue; // Skip non AI - + for(curBNVIndex2 = 0; curBNVIndex2 < inBuildData->numBNVs; curBNVIndex2++) { if (curBNVIndex2 == curBNVIndex) continue; @@ -2874,7 +2874,7 @@ IMPrEnv_Process_BNV_ComputeAdjacency( if (!(curBNV2->flags & AKcBNV_Flag_Room)) continue; // Only room nodes! if (!(curBNV2->flags & AKcBNV_Flag_Stairs)) continue; // Only stairs! if (curBNV->flags & AKcBNV_Flag_NonAI) continue; // Skip non AI - + for (curSideIndex2 = 0; curSideIndex2 < curBNV2->numSides; curSideIndex2++) { curSide2 = &curBNV2->sides[curSideIndex2]; @@ -2882,24 +2882,24 @@ IMPrEnv_Process_BNV_ComputeAdjacency( { M3tPoint3D centroid; UUtUns32 curGQGlobalIndex; - + curGQGlobalIndex = curSide2->gqGhostIndices[curGQIndex2]; curGQ = &inBuildData->gqList[curGQGlobalIndex]; if (!(curGQ->flags & (AKcGQ_Flag_SAT_Up | AKcGQ_Flag_SAT_Down))) continue; - + AUrQuad_ComputeCenter( AUrSharedPointArray_GetList(inBuildData->sharedPointArray), &curGQ->visibleQuad, ¢roid.x, ¢roid.y, ¢roid.z); - + if (Imp_Env_PointInNode(¢roid,inBuildData,curBNV)) { M3tPoint3D *lowPoint; UUtUns32 adj_index, fwd_conn_toside; UUtBool found_fwd_conn, found_back_conn; - + // Potential SAT- make sure SAT touches floor AUrQuad_LowestPoints(&curGQ->visibleQuad,AUrSharedPointArray_GetList(inBuildData->sharedPointArray),&lowPoint,NULL); if ((float)fabs(lowPoint->y - curBNV->origin.y) > IMPcGhostFloorThreshold) @@ -2952,7 +2952,7 @@ IMPrEnv_Process_BNV_ComputeAdjacency( } } } - + #if defined(DEBUGGING) && DEBUGGING // CB: this test makes sure that no BNVs have the same adjacency on multiple sides for(curBNVIndex = 0; curBNVIndex < inBuildData->numBNVs; curBNVIndex++) @@ -2995,9 +2995,9 @@ IMPrEnv_Process_BNV_ComputeAdjacency( void Imp_Env_AddAdjacency( - IMPtEnv_BNV_Side *inSrcSide, - IMPtEnv_BNV *inSrcBNV, - IMPtEnv_BNV_Side *inDestSide, + IMPtEnv_BNV_Side *inSrcSide, + IMPtEnv_BNV *inSrcBNV, + IMPtEnv_BNV_Side *inDestSide, UUtUns32 inDestBNVIndex, UUtUns32 inConnectingGQIndex, UUtUns16 inFlags, @@ -3006,18 +3006,18 @@ void Imp_Env_AddAdjacency( /*************** * Adds an adjacency from inSrcSide to inDestSide (which is part of inBNVIndex) */ - + AKtAdjacency *adj = &inSrcSide->adjacencyList[inSrcSide->numAdjacencies]; - + adj->adjacentBNVIndex = inDestBNVIndex; adj->adjacentGQIndex = inConnectingGQIndex; adj->adjacencyFlags = inFlags; - + inBuildData->gqList[inConnectingGQIndex].ghostUsed = UUcTrue; - + inSrcSide->numAdjacencies++; IMPgEnv_VerifyAdjCount++; - + if (inSrcSide->numAdjacencies > IMPcEnv_MaxAdjacencies) { inSrcSide->numAdjacencies--; @@ -3036,25 +3036,25 @@ IMPiEnv_Process_Stairs( M3tPlaneEquation *planeArray; UUtUns32 curGQIndex; IMPtEnv_GQ* curGQ; - + M3tQuad* quadArray; - + UUtUns32 curPointIndex; - + M3tPoint3D* pointArray; M3tPoint3D* curPoint; - + UUtBool gqIsEnclosed; - + UUtUns16 numStairGQs; UUtInt64 time = UUrMachineTime_High(); - + Imp_PrintMessage(IMPcMsg_Important, "Finding and processing stairs"); pointArray = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); quadArray = AUrSharedQuadArray_GetList(inBuildData->sharedBNVQuadArray); planeArray = AUrSharedPlaneEquArray_GetList(inBuildData->sharedPlaneEquArray); - + for(curBNVIndex = 0, curBNV = inBuildData->bnvList; curBNVIndex < inBuildData->numBNVs; curBNVIndex++, curBNV++) @@ -3070,13 +3070,13 @@ IMPiEnv_Process_Stairs( // Next find the enclosed stairs numStairGQs = 0; for(curGQIndex = 0, curGQ = inBuildData->gqList; curGQIndex < inBuildData->numGQs; curGQIndex++, curGQ++) - { + { gqIsEnclosed = UUcTrue; - + for(curPointIndex = 0; curPointIndex < 4; curPointIndex++) { curPoint = pointArray + curGQ->visibleQuad.indices[curPointIndex]; - + if(IMPiEnv_Process_BSP_PointInBSP( inBuildData, curBNV, @@ -3086,13 +3086,13 @@ IMPiEnv_Process_Stairs( goto gqDone; } } - + gqDone: if(gqIsEnclosed) { // This may be a stair- is it pointing up or down? if ((float)fabs(planeArray[curGQ->planeEquIndex & 0x7FFFFFFF].b) > PHcFlatNormal) - { + { curGQ->flags |= AKcGQ_Flag_Stairs; curGQ->used = UUcTrue; numStairGQs++; @@ -3100,7 +3100,7 @@ IMPiEnv_Process_Stairs( } } } - + if(numStairGQs == 0) { IMPrEnv_LogError( @@ -3111,7 +3111,7 @@ IMPiEnv_Process_Stairs( curBNV->error = UUcTrue; } } - + time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); @@ -3123,50 +3123,50 @@ IMPrEnv_Process_GQVis( IMPtEnv_BuildData* inBuildData) { UUtError error; - + UUtUns32 curGQIndex; IMPtEnv_GQ* curGQ; IMPtEnv_GQ* targetGQ; - + M3tPoint3D* sharedPoints; - + UUtUns32* gqTakenBV; - + IMPtEnv_GQPatch* newPatch; - + UUtUns32 nextIndIndex; - + UUtUns32 newIndIndexIndex; - + UUtUns32 curPatchIndex; IMPtEnv_GQPatch* curPatch; - + UUtUns32 curIndIndex; UUtUns32 nextGQIndex; UUtUns32 curEdgeItr; - - + + AUtEdge* edgeList; AUtEdge* targetEdge; - + UUtUns32 targetGQIndex; UUtUns32 curQuadItr; UUtUns32 numEdges; float totalGQArea = 0.0f; UUtInt64 time = UUrMachineTime_High(); - + Imp_PrintMessage(IMPcMsg_Important, "Computing gq patches for visibility..."); inBuildData->numPatches = 0; inBuildData->numPatchIndIndices = 0; - + sharedPoints = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); - + gqTakenBV = UUrBitVector_New(inBuildData->numGQs); UUmError_ReturnOnNull(gqTakenBV); - + UUrBitVector_ClearBitAll(gqTakenBV, inBuildData->numGQs); - + Imp_PrintMessage(IMPcMsg_Cosmetic, UUmNL "\tbuilding gq edge list"); for(curGQIndex = 0, curGQ = inBuildData->gqList; curGQIndex < inBuildData->numGQs; @@ -3181,10 +3181,10 @@ IMPrEnv_Process_GQVis( UUrBitVector_SetBit(gqTakenBV, curGQIndex); continue; } - + if(curGQ->flags & AKcGQ_Flag_Triangle) { - error = + error = AUrSharedEdgeArray_AddPoly( inBuildData->edgeArray, 3, @@ -3195,7 +3195,7 @@ IMPrEnv_Process_GQVis( } else { - error = + error = AUrSharedEdgeArray_AddPoly( inBuildData->edgeArray, 4, @@ -3205,11 +3205,11 @@ IMPrEnv_Process_GQVis( UUmError_ReturnOnError(error); } } - + Imp_PrintMessage(IMPcMsg_Cosmetic, UUmNL"\tbuilding patch list"); edgeList = AUrSharedEdgeArray_GetList(inBuildData->edgeArray); - + // Build a list of patches. each patch contains a list of gqs that share an edge for(curGQIndex = 0, curGQ = inBuildData->gqList; curGQIndex < inBuildData->numGQs; @@ -3217,58 +3217,58 @@ IMPrEnv_Process_GQVis( { // look for a gq that has not been taken if(UUrBitVector_TestAndSetBit(gqTakenBV, curGQIndex)) continue; - + // we now have a gq that has not been taken - + // get a new patch if(inBuildData->numPatches >= IMPcEnv_MaxPatches) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Not enough patch memory"); } - + newPatch = inBuildData->patches + inBuildData->numPatches++; - + if((inBuildData->numPatches % 200) == 0) Imp_PrintMessage(IMPcMsg_Important,"."); - + // get a new ind index if(inBuildData->numPatchIndIndices >= IMPcEnv_MaxGQIndexArray) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Not enough patch indIndex memory"); } newIndIndexIndex = inBuildData->numPatchIndIndices++; - + // start the new patch nextIndIndex = newPatch->gqStartIndirectIndex = newIndIndexIndex; newPatch->gqEndIndirectIndex = newIndIndexIndex + 1; - + inBuildData->patchIndIndices[newIndIndexIndex] = curGQIndex; - + // loop through all the gqs in the patch so far and look for adjacencies // stop when no new gqs are added while(nextIndIndex < newPatch->gqEndIndirectIndex) { targetGQIndex = inBuildData->patchIndIndices[nextIndIndex]; - + targetGQ = inBuildData->gqList + targetGQIndex; - + numEdges = (targetGQ->flags & AKcGQ_Flag_Triangle) ? 3 : 4; - + for(curEdgeItr = 0; curEdgeItr < numEdges; curEdgeItr++) { targetEdge = edgeList + targetGQ->edgeIndices.indices[curEdgeItr]; - + for(curQuadItr = 0; curQuadItr < AUcMaxQuadsPerEdge; curQuadItr++) { if(targetEdge->quadIndices[curQuadItr] == targetGQIndex) continue; if(targetEdge->quadIndices[curQuadItr] == UUcMaxUns32) break; - + nextGQIndex = targetEdge->quadIndices[curQuadItr]; - + /* if(curQuadItr < 2) { targetGQ->adjGQIndices[curEdgeItr] = nextGQIndex; }*/ - + if(!UUrBitVector_TestAndSetBit(gqTakenBV, nextGQIndex)) { if(inBuildData->numPatchIndIndices >= IMPcEnv_MaxGQIndexArray) @@ -3276,55 +3276,55 @@ IMPrEnv_Process_GQVis( UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Not enough patch indIndex memory"); } newIndIndexIndex = inBuildData->numPatchIndIndices++; - + newPatch->gqEndIndirectIndex = newIndIndexIndex + 1; - + inBuildData->patchIndIndices[newIndIndexIndex] = nextGQIndex; } } } - + nextIndIndex++; } } - + Imp_PrintMessage(IMPcMsg_Cosmetic, UUmNL"\tanalyzing patch list"UUmNL); - + for(curPatchIndex = 0, curPatch = inBuildData->patches; curPatchIndex < inBuildData->numPatches; curPatchIndex++, curPatch++) { float totalArea; - + totalArea = 0; - + for(curIndIndex = curPatch->gqStartIndirectIndex; curIndIndex < curPatch->gqEndIndirectIndex; curIndIndex++) { targetGQ = inBuildData->gqList + inBuildData->patchIndIndices[curIndIndex]; - - totalArea += + + totalArea += MUrTriangle_Area( sharedPoints + targetGQ->visibleQuad.indices[0], sharedPoints + targetGQ->visibleQuad.indices[1], - sharedPoints + targetGQ->visibleQuad.indices[2]) + + sharedPoints + targetGQ->visibleQuad.indices[2]) + MUrTriangle_Area( sharedPoints + targetGQ->visibleQuad.indices[0], sharedPoints + targetGQ->visibleQuad.indices[2], sharedPoints + targetGQ->visibleQuad.indices[3]); } - + totalGQArea += totalArea; } - + inBuildData->totalGQArea = totalGQArea; - + time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); - + UUrBitVector_Dispose(gqTakenBV); - + return UUcError_None; } @@ -3335,7 +3335,7 @@ static UUtError IMPrEnv_Process_GQDoors( IMPtEnv_BuildData* inBuildData ) UUtInt64 time = UUrMachineTime_High(); // UUtUns32 new_index; // UUtError error; - + Imp_PrintMessage(IMPcMsg_Important, "Processing door GQs..."); inBuildData->door_count = 0; @@ -3362,11 +3362,11 @@ static UUtError IMPrEnv_Process_GQDoors( IMPtEnv_BuildData* inBuildData ) time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, " %d" UUmNL "total time = %f" UUmNL UUmNL, inBuildData->door_count, UUrMachineTime_High_To_Seconds(time)); - + return UUcError_None; } - + UUtBool Imp_Env_PointInNode( M3tPoint3D* inPoint, @@ -3386,7 +3386,7 @@ IMPiEnv_Process_Flags( for (i=0; inumFlags; i++) { } - + return UUcError_None; } @@ -3405,7 +3405,7 @@ static IMPtEnv_Object *IMPiFindDoorOnQuad( { object = inBuildData->objectList + i; AKmPlaneEqu_GetComponents(inGQ->planeEquIndex,planeList,plane.a,plane.b,plane.c,plane.d); - + if (AUrPlane_Distance_Squared(&plane,&object->position,NULL) < UUmSQR(IMPcDoorPlaneThresh)) { return object; } @@ -3417,7 +3417,7 @@ static IMPtEnv_Object *IMPiFindDoorOnQuad( static UUtError IMPiCreateQuadRemapFile( IMPtEnv_BuildData* inBuildData) -{ +{ char filename[64]; BFtFile *outFile; BFtFileRef *fileRef; @@ -3451,14 +3451,14 @@ IMPiCreateQuadRemapFile( return UUcError_None; } - + static UUtError IMPrEnv_Process_GQMinMax( IMPtEnv_BuildData* inBuildData) { UUtUns32 curGQIndex; IMPtEnv_GQ* curGQ; - + IMPtEnv_Object *object; UUtInt64 time = UUrMachineTime_High(); @@ -3477,10 +3477,10 @@ IMPrEnv_Process_GQMinMax( { float minX, minY, minZ; float maxX, maxY, maxZ; - + const M3tPoint3D* curPoint; UUtUns8 i; - + { const float floor_angle = 0.5f; M3tPlaneEquation* planeEqu = planeArray + (curGQ->planeEquIndex & 0x7FFFFFFF); @@ -3510,15 +3510,15 @@ IMPrEnv_Process_GQMinMax( } // Remap indices for scripting - if (curGQ->scriptID != 0xFFFF) + if (curGQ->scriptID != 0xFFFF) { IMPrScript_AddQuadRemap( curGQIndex, curGQ->scriptID, inBuildData->environmentGroup); } - - // Quad extrema + + // Quad extrema AUrQuad_HighestPoints(&curGQ->visibleQuad,sharedPoints,&curGQ->hi1,&curGQ->hi2); AUrQuad_LowestPoints(&curGQ->visibleQuad,sharedPoints,&curGQ->lo1,&curGQ->lo2); @@ -3527,7 +3527,7 @@ IMPrEnv_Process_GQMinMax( minX = maxX = curPoint->x; minY = maxY = curPoint->y; minZ = maxZ = curPoint->z; - + for(i = 1; i < 4; i++) { float curX, curY, curZ; @@ -3537,12 +3537,12 @@ IMPrEnv_Process_GQMinMax( curX = curPoint->x; curY = curPoint->y; curZ = curPoint->z; - + UUmMinMax(curX, minX, maxX); UUmMinMax(curY, minY, maxY); UUmMinMax(curZ, minZ, maxZ); } - + curGQ->bBox.minPoint.x = minX; curGQ->bBox.minPoint.y = minY; curGQ->bBox.minPoint.z = minZ; @@ -3550,7 +3550,7 @@ IMPrEnv_Process_GQMinMax( curGQ->bBox.maxPoint.y = maxY; curGQ->bBox.maxPoint.z = maxZ; } - + time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); @@ -3570,7 +3570,7 @@ IMPiEnv_Process_CalculateOrigins( for(curBNVIndex = 0; curBNVIndex < inBuildData->numBNVs; curBNVIndex++) { IMPtEnv_BNV *curNode = &inBuildData->bnvList[curBNVIndex]; - + if((curBNVIndex % 10) == 0) { Imp_PrintMessage(IMPcMsg_Important, "."); @@ -3582,7 +3582,7 @@ IMPiEnv_Process_CalculateOrigins( time = UUrMachineTime_High() - time; Imp_PrintMessage(IMPcMsg_Important, UUmNL "total time = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(time)); - + return UUcError_None; } @@ -3594,7 +3594,7 @@ IMPrEnv_Process( UUtError error; UUtUns32 gqItr; IMPtEnv_GQ* curGQ; - + // 1. Initialize stuff error = IMPrEnv_Process_BNV_BuildBSP(inBuildData); @@ -3609,20 +3609,20 @@ IMPrEnv_Process( // loop through the gqs and set the proper flags based on the texture map for(gqItr = 0, curGQ = inBuildData->gqList; gqItr < inBuildData->numGQs; gqItr++, curGQ++) { - if(curGQ->textureMapIndex != 0xFFFF) + if(curGQ->textureMapIndex != 0xFFFF) { - if(IMrPixelType_HasAlpha(inBuildData->envTextureList[curGQ->textureMapIndex].flags.pixelType)) + if(IMrPixelType_HasAlpha(inBuildData->envTextureList[curGQ->textureMapIndex].flags.pixelType)) { - curGQ->flags |= (AKcGQ_Flag_DrawBothSides | AKcGQ_Flag_Transparent); + curGQ->flags |= (AKcGQ_Flag_DrawBothSides | AKcGQ_Flag_Transparent); } - } - if (curGQ->flags & AKcGQ_Flag_Transparent) + } + if (curGQ->flags & AKcGQ_Flag_Transparent) { - if (inBuildData->numAlphaQuads < IMPcEnv_MaxAlphaQuads) + if (inBuildData->numAlphaQuads < IMPcEnv_MaxAlphaQuads) { inBuildData->alphaQuads[inBuildData->numAlphaQuads++] = gqItr; } - else + else { Imp_PrintMessage(IMPcMsg_Important, UUmNL"TOO MANY ALPHA QUADS"UUmNL); } @@ -3633,7 +3633,7 @@ IMPrEnv_Process( { error = IMPrEnv_Process_GQMinMax(inBuildData); UUmError_ReturnOnError(error); - + #if 1 // 11. build the alpha quad bsp IMPiEnv_Process_Alpha_BSP_Build( @@ -3652,40 +3652,40 @@ IMPrEnv_Process( Imp_PrintMessage(IMPcMsg_Important, UUmNL "time to build fixed node oct tree = %f" UUmNL UUmNL, UUrMachineTime_High_To_Seconds(fixed_oct_tree_time)); } - - // 2. Compute the BNV volume node tree + + // 2. Compute the BNV volume node tree error = IMPrEnv_Process_BNV_ComputeProperties(inBuildData); UUmError_ReturnOnError(error); - + IMPiEnv_Process_BNV_FindParents(inBuildData); IMPiEnv_Process_BNV_AnalyzeParents(inBuildData); - + // 3. Process the stair GQs and BNVs error = IMPiEnv_Process_Stairs(inBuildData); UUmError_ReturnOnError(error); - + // 4. Calculate origins error = IMPiEnv_Process_CalculateOrigins(inBuildData); UUmError_ReturnOnError(error); - + // 5. Find adjacencies - IMPrEnv_Process_BNV_ComputeAdjacency(inBuildData); + IMPrEnv_Process_BNV_ComputeAdjacency(inBuildData); } - + // 6. Look for GQs that should be ignored IMPrEnv_Process_GQVis(inBuildData); - - + + if(IMPgConstructing) { IMPiCreateQuadRemapFile(inBuildData); } - + // 9. lightmaps error = IMPrEnv_Process_LightMap(inBuildData, inSourceFileRef); UUmError_ReturnOnError(error); - + if(IMPgConstructing) { // 10. Process the marker flags and objects @@ -3694,10 +3694,10 @@ IMPrEnv_Process( error = IMPiEnv_Process_Flags(inBuildData); UUmError_ReturnOnError(error); - Imp_PrintMessage(IMPcMsg_Important, "."UUmNL); + Imp_PrintMessage(IMPcMsg_Important, "."UUmNL); // 12. Clean up } - + return UUcError_None; - + } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Process_RastLM.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Process_RastLM.c index 92cd8b2..b75749c 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Process_RastLM.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Env2_Process_RastLM.c @@ -5,8 +5,8 @@ CREATED: Sept 3, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ @@ -64,12 +64,12 @@ extern UUtBool renderLightmap; static void iRGB2HSV(float r, float g, float b, float* h, float *s, float *v) { float maxv,minv,diff,rd,gd,bd; - + maxv = UUmMax3(r,g,b); minv = UUmMin3(r,g,b); diff = maxv-minv; if (diff==0.0f) diff = 0.00001f; - + *v = maxv; if (maxv != 0.0f) *s = diff/maxv; else @@ -77,7 +77,7 @@ static void iRGB2HSV(float r, float g, float b, float* h, float *s, float *v) *h = *s = *v = 0; return; } - + rd = (maxv-r)/diff; gd = (maxv-g)/diff; bd = (maxv-b)/diff; @@ -90,10 +90,10 @@ static void iRGB2HSV(float r, float g, float b, float* h, float *s, float *v) { *h = 4.0f + gd - rd; } - + *h *= 60.0f; if (*h < 0) *h += 360.0f; - + UUmAssert(*h >=0 && *h<=360.0f); } @@ -101,7 +101,7 @@ static void iHSV2RGB(float h, float s, float v, float *r, float *g, float *b) { float f,p,q,t; UUtUns32 i; - + h = UUmPin(h,0.0f,360.0f); if (s==0.0f) { @@ -159,7 +159,7 @@ static void iHSV2RGB(float h, float s, float v, float *r, float *g, float *b) static void iRGB5552HSV(UUtUns8 r, UUtUns8 g, UUtUns8 b, float *h, float *s, float *v) { float fr,fg,fb; - + fr = ((float)(r<<3)) / 255.0f; fg = ((float)(g<<3)) / 255.0f; fb = ((float)(b<<3)) / 255.0f; @@ -170,7 +170,7 @@ static void iHSV2RGBFilter(float h, float s, float v, UUtUns8 *r, UUtUns8 *g, UU { float fr,fg,fb,minD,d,fh,fs,fv; UUtUns8 ir,ig,ib,minr,ming,minb; - + iHSV2RGB(h,s,v,&fr,&fg,&fb); fr*=255.0; fg*=255.0; @@ -178,12 +178,12 @@ static void iHSV2RGBFilter(float h, float s, float v, UUtUns8 *r, UUtUns8 *g, UU fr = UUmPin(fr,0.0f,255.0f); fg = UUmPin(fg,0.0f,255.0f); fb = UUmPin(fb,0.0f,255.0f); - + ir = ((UUtUns8)fr) >>3; ig = ((UUtUns8)fg) >>3; ib = ((UUtUns8)fb) >>3; minD = 1e9; - + iRGB5552HSV(ir,ig,ib,&fh,&fs,&fv); // 000 d = UUmFabs(fh-h); if (UUmFabs(fh-h) < minD) { minD = d; minr = ir; ming = ig; minb = ib; } @@ -215,16 +215,16 @@ static void iHSV2RGBFilter(float h, float s, float v, UUtUns8 *r, UUtUns8 *g, UU iRGB5552HSV(ir,ig,ib,&fh,&fs,&fv); d = UUmFabs(fh-h); if (UUmFabs(fh-h) < minD) { minD = d; minr = ir; ming = ig; minb = ib; } - + *r = minr <<3; *g = ming <<3; *b = minb <<3; } - + /***************************************************************** * TAG( make_square ) - * + * * Build the magic square for a given number of levels. * Inputs: * N: Pixel values per level (255.0 / levels). @@ -233,7 +233,7 @@ static void iHSV2RGBFilter(float h, float s, float v, UUtUns8 *r, UUtUns8 *g, UU * modN: Integer remainder between pixval and divN[pixval]*N * magic: Magic square for dithering to N sublevels. * Assumptions: - * + * * Algorithm: * divN[pixval] = (int)(pixval / N) maps pixval to its appropriate level. * modN[pixval] = pixval - (int)(N * divN[pixval]) maps pixval to @@ -261,7 +261,7 @@ iMakeMagicSquare(double N, int divN[256], int modN[256], int magic[16][16] ) /* * Expand 4x4 dither pattern to 16x16. 4x4 leaves obvious patterning, * and doesn't give us full intensity range (only 17 sublevels). - * + * * magicfact is (N - 1)/16 so that we get numbers in the matrix from 0 to * N - 1: mod N gives numbers in 0 to N - 1, don't ever want all * pixels incremented to the next level (this is reserved for the @@ -278,7 +278,7 @@ iMakeMagicSquare(double N, int divN[256], int modN[256], int magic[16][16] ) } - + static void iDitherMap(int levels, double gamma, int rgbmap[][3], int divN[256], int modN[256], int magic[16][16] ) { @@ -287,7 +287,7 @@ iDitherMap(int levels, double gamma, int rgbmap[][3], int divN[256], int modN[25 register int i; int levelsq, levelsc; int gammamap[256]; - + for ( i = 0; i < 256; i++ ) gammamap[i] = (int)(0.5 + 255 * pow( i / 255.0, 1.0/gamma )); @@ -296,7 +296,7 @@ iDitherMap(int levels, double gamma, int rgbmap[][3], int divN[256], int modN[25 N = 255.0 / (levels - 1); /* Get size of each step */ - /* + /* * Set up the color map entries. */ for(i = 0; i < levelsc; i++) { @@ -316,7 +316,7 @@ static int iDitherRGB(int x, int y, int r, int g, int b, int levels, int divN[25 int col = x % 16, row = y % 16; if (!haveMagicSquare) iDitherMap(256,0.5,grgbmap,gdivn,gmodn,gmagic); - + return DMAP(r, col, row) + DMAP(g, col, row) * levels + DMAP(b, col, row) * levels*levels; @@ -350,10 +350,10 @@ iReduceColourSpace( { UUtInt32 i, p, q; UUtUns8 *rgb = ioR; - + // Initialize if (!haveJitterTables) iCreateJitterTables(); - + if (inNoise == 0) { *ioR &= 0xF8; @@ -366,7 +366,7 @@ iReduceColourSpace( { if (i==1) rgb = ioG; else if (i==2) rgb = ioB; - + if (*rgb < 248) { p = *rgb % 8; @@ -403,21 +403,21 @@ iRasterize_LightMap16( UUtBool inDaylightOn, UUtBool inIsExterior) { - + IMPtEnv_LM_Vertex* vertex_min; IMPtEnv_LM_Vertex* vertex_mid; IMPtEnv_LM_Vertex* vertex_max; - + /* * Key to variable names - * + * * ddx = d/dx, horizontal incremental change * ddy = d/dy, vertical incremental change * * The type is appended to ease the scheduling of integer and floating point variables */ - - + + /* * x left and right variables */ @@ -426,39 +426,39 @@ iRasterize_LightMap16( UUtInt32 u_rightEdge_int, u_rightEdge_ddv_int; UUtInt32 u_shortEdgeBottom_int, u_shortEdgeBottom_ddv_int; UUtInt32 u_shortEdgeTop_int, u_shortEdgeTop_ddv_int; - + /* - * These variables have double duty. They are used to store the int version of the + * These variables have double duty. They are used to store the int version of the * min, mid, max rgb values and the variable interpolation values for rgb */ float r_max_ddv_float, g_max_ddv_float, b_max_ddv_float; float r_mid_ddu_float, g_mid_ddu_float, b_mid_ddu_float; float r_min_longEdge_float, g_min_longEdge_float, b_min_longEdge_float; - + /* * top, middle, and bottom scanlines */ UUtInt32 scanline_min_int, scanline_mid_int, scanline_max_int; - + /* * Pointers into the buffers and the rowBytes */ - + UUtUns16* imageScanlineLeft_ptr; UUtUns16 imageRowBytes_uns; - + /* * Used to indicate whether scanline traversal is left->right or right->left */ UUtInt16 spanDirection_int; - + /* * min, mid, and max variables for x and y */ float v_min_float, v_mid_float, v_max_float; float u_min_float, u_mid_float, u_max_float; float v0_float, v1_float, v2_float; - + /* * Plane equation variables */ @@ -466,53 +466,53 @@ iRasterize_LightMap16( float invDet_float; float v_maxMinusMin_float, v_midMinusMin_float; float u_maxMinusMin_float, u_midMinusMin_float; - + /* * Error variables */ float v_minError_float, v_midError_float; - + /* * Temporary variables */ float temp_float; float r_temp_float, g_temp_float, b_temp_float; - + /* * floating point constants */ - + float u_scale_float = MSmFractOne * MSmSubPixelUnits; float oneHalf_float = 0.5F; float one_float = 1.0F; - + /* * Scanline variables */ UUtInt32 scanline_int; - + UUtInt32 ptr_ddu_int; - + UUtUns16 *image_ptr; - + /* * Pixel & lightmap variables - */ + */ UUtInt32 u_pixelLeft_int, u_pixelRight_int; UUtInt32 i; float a, b, c; float intensity, f; float red, green, blue; UUtUns8 intR,intG,intB; - - + + /* * DDA variables */ float invHeight_float; - - - // Set up irradiance coefficients + + + // Set up irradiance coefficients { float mag, power, step, stepsize, res, powerBot; float orders_of_mag = 5.0f; @@ -536,13 +536,13 @@ iRasterize_LightMap16( /* * Step 1. Sort the vertices according to v. Sort in place to save registers */ - + triVisible = UUcFalse; - + v0_float = inVertex0->v; v1_float = inVertex1->v; v2_float = inVertex2->v; - + if (v0_float < v1_float) { v_min_float = v0_float; @@ -555,17 +555,17 @@ iRasterize_LightMap16( { v_min_float = v1_float; v_mid_float = v0_float; - + vertex_min = inVertex1; vertex_mid = inVertex0; } - + if (v2_float < v_min_float) { v_max_float = v_mid_float; v_mid_float = v_min_float; v_min_float = v2_float; - + vertex_max = vertex_mid; vertex_mid = vertex_min; vertex_min = inVertex2; @@ -574,7 +574,7 @@ iRasterize_LightMap16( { v_max_float = v_mid_float; v_mid_float = v2_float; - + vertex_max = vertex_mid; vertex_mid = inVertex2; } @@ -583,20 +583,20 @@ iRasterize_LightMap16( v_max_float = v2_float; vertex_max = inVertex2; } - + UUmAssert(v_max_float >= v_mid_float); UUmAssert(v_mid_float >= v_min_float); /* * Step 2. Compute plane equations and interwind load/store operations */ - + /* prefetch x mid, min, max */ u_min_float = vertex_min->u; u_mid_float = vertex_mid->u; u_max_float = vertex_max->u; - - + + // Vertex irradiance setup #define colour_convert(ir,ig,ib,dr,dg,db) \ intensity = UUmFabs(ir) * 0.263f + \ @@ -613,12 +613,12 @@ iRasterize_LightMap16( green = UUmPin(green, 0.0f, 1.0f); \ blue = UUmPin(blue, 0.0f, 1.0f); \ iRGB2HSV(red,green,blue,&dr,&dg,&db); - - + + colour_convert(vertex_min->r,vertex_min->g,vertex_min->b,r_min_longEdge_float,g_min_longEdge_float,b_min_longEdge_float); colour_convert(vertex_mid->r,vertex_mid->g,vertex_mid->b,r_mid_ddu_float,g_mid_ddu_float,b_mid_ddu_float); colour_convert(vertex_max->r,vertex_max->g,vertex_max->b,r_max_ddv_float,g_max_ddv_float,b_max_ddv_float); - + /* Calc plane equation stuff */ v_maxMinusMin_float = v_max_float - v_min_float; u_midMinusMin_float = u_mid_float - u_min_float; @@ -626,7 +626,7 @@ iRasterize_LightMap16( u_maxMinusMin_float = u_max_float - u_min_float; invDet_float = v_maxMinusMin_float * u_midMinusMin_float - v_midMinusMin_float * u_maxMinusMin_float; invDet_float = one_float / invDet_float; - + if (invDet_float > 0.0f) { spanDirection_int = 1; @@ -636,31 +636,31 @@ iRasterize_LightMap16( invDet_float = -invDet_float; spanDirection_int = -1; } - + /* Compute plane equation */ m10_float = (v_mid_float - v_max_float) * invDet_float; m11_float = v_maxMinusMin_float * invDet_float; m12_float = -v_midMinusMin_float * invDet_float; - + /* * Step 4. compute ddx parameters and the first, mid and bottom scanlines * Step 5. Set up the vertical DDA */ - + scanline_min_int = (UUtInt32)(v_min_float + oneHalf_float); scanline_mid_int = (UUtInt32)(v_mid_float + oneHalf_float); v_minError_float = ((float)scanline_min_int + oneHalf_float) - v_min_float; v_midError_float = ((float)scanline_mid_int + oneHalf_float) - v_mid_float; - + /* start using r_mid_ddx_int as the ddx instead of the mid */ - r_mid_ddu_float = m11_float * r_mid_ddu_float; - g_mid_ddu_float = m11_float * g_mid_ddu_float; - b_mid_ddu_float = m11_float * b_mid_ddu_float; - + r_mid_ddu_float = m11_float * r_mid_ddu_float; + g_mid_ddu_float = m11_float * g_mid_ddu_float; + b_mid_ddu_float = m11_float * b_mid_ddu_float; + temp_float = v_max_float - oneHalf_float; invHeight_float = u_scale_float / v_midMinusMin_float; u_min_float = u_min_float * u_scale_float; - + /* If the triangle does not hit the first scanline on the screen bail */ if(temp_float < 0.5f) { @@ -673,58 +673,58 @@ iRasterize_LightMap16( * This code section sets up the vertical DDA for all three edges. * Begin by computing the inverse of the height of the short top edge. */ - + r_mid_ddu_float += m10_float * r_min_longEdge_float; g_mid_ddu_float += m10_float * g_min_longEdge_float; b_mid_ddu_float += m10_float * b_min_longEdge_float; - + temp_float = u_midMinusMin_float * invHeight_float; - + r_mid_ddu_float += m12_float * r_max_ddv_float; g_mid_ddu_float += m12_float * g_max_ddv_float; b_mid_ddu_float += m12_float * b_max_ddv_float; - + u_shortEdgeTop_int = (UUtInt32)(u_min_float + v_minError_float * temp_float); u_shortEdgeTop_ddv_int = (UUtInt32)temp_float; - + /* * Compute the inverse of the height of the long edge (and do a bit more * pointer setup). */ invHeight_float = one_float / v_maxMinusMin_float; - + imageRowBytes_uns = inRowBytes; - + imageScanlineLeft_ptr = (UUtUns16 *)((char *)inMapMemory + (scanline_min_int * imageRowBytes_uns)); - + /* * Compute the initial value and forward difference for all interpolated parameters * along the long edge. */ - + temp_float = u_maxMinusMin_float * u_scale_float * invHeight_float; u_longEdge_int = (UUtInt32)(u_min_float + v_minError_float * temp_float); u_longEdge_ddv_int = (UUtInt32)temp_float; - r_max_ddv_float = (r_max_ddv_float - r_min_longEdge_float) * invHeight_float; + r_max_ddv_float = (r_max_ddv_float - r_min_longEdge_float) * invHeight_float; g_max_ddv_float = (g_max_ddv_float - g_min_longEdge_float) * invHeight_float; b_max_ddv_float = (b_max_ddv_float - b_min_longEdge_float) * invHeight_float; - + invHeight_float = u_scale_float / (v_maxMinusMin_float - v_midMinusMin_float); - + temp_float = (u_max_float - u_mid_float) * invHeight_float; - + r_min_longEdge_float += (r_max_ddv_float * v_minError_float); g_min_longEdge_float += (g_max_ddv_float * v_minError_float); b_min_longEdge_float += (b_max_ddv_float * v_minError_float); - - + + /* * Compute the inital value and forward difference of X for the bottom short edge. */ - + // XXX - Fucking VisC++ bug { float t2; @@ -740,20 +740,20 @@ iRasterize_LightMap16( * the bottom short edge is left or right, so add the appropriate sub-pixel bias * to xShortBottom as well. */ - + if (spanDirection_int > 0) { /* * vMin-vMax (long) is left edge. vMin-vMid (shortTop) is the top right edge, * and vMid-vMax is the bottom right edge. */ - + u_leftEdge_int = u_longEdge_int; u_leftEdge_ddv_int = u_longEdge_ddv_int; - + u_rightEdge_int = u_shortEdgeTop_int; u_rightEdge_ddv_int = u_shortEdgeTop_ddv_int; - + u_shortEdgeBottom_int -= (MSmHalfSubPixel + 1) << MSmFractBits; } else @@ -762,23 +762,23 @@ iRasterize_LightMap16( * vMin-vMax (short) is right edge, vMin-vMid (shortTop) is the top left edge, * and vMid-vMax is the bottom left edge. */ - + u_rightEdge_int = u_longEdge_int; u_rightEdge_ddv_int = u_longEdge_ddv_int; - + u_leftEdge_int = u_shortEdgeTop_int; u_leftEdge_ddv_int = u_shortEdgeTop_ddv_int; - + u_shortEdgeBottom_int += (MSmHalfSubPixel - 1) << MSmFractBits; } - + /* * Add in the sub-pixel coverage bias to xLeft and xRight. */ - + u_leftEdge_int += (MSmHalfSubPixel - 1) << MSmFractBits; u_rightEdge_int -= (MSmHalfSubPixel + 1) << MSmFractBits; - + for (scanline_int = scanline_min_int; scanline_int <= scanline_max_int; ++scanline_int) @@ -787,7 +787,7 @@ iRasterize_LightMap16( { break; } - + if (scanline_int == scanline_mid_int) { if (spanDirection_int > 0) @@ -797,7 +797,7 @@ iRasterize_LightMap16( * Set xRight to the exact subpixel-accurate value that was computed * earlier. */ - + u_rightEdge_ddv_int = u_shortEdgeBottom_ddv_int; u_rightEdge_int = u_shortEdgeBottom_int; } @@ -808,49 +808,49 @@ iRasterize_LightMap16( * Set xLeft to the exact subpixel-accurate value that was computed * earlier. */ - + u_leftEdge_ddv_int = u_shortEdgeBottom_ddv_int; u_leftEdge_int = u_shortEdgeBottom_int; } } - + /* * Render a horizontal span. Note that the sub-pixel coverage bias has * already been added into xLeft and xRight. */ - + u_pixelLeft_int = u_leftEdge_int >> (MSmSubPixelBits + MSmFractBits); u_pixelRight_int = u_rightEdge_int >> (MSmSubPixelBits + MSmFractBits); - + if (spanDirection_int > 0) { /* * We are rasterizing from left to right. Compute the pointers to the first * pixel in the span. */ - + image_ptr = imageScanlineLeft_ptr + u_pixelLeft_int; - + ptr_ddu_int = 1; - + } else { /* * We are rasterizing from right to left. */ - + image_ptr = imageScanlineLeft_ptr + u_pixelRight_int; - + ptr_ddu_int = -1; - + } - + r_temp_float = r_min_longEdge_float; g_temp_float = g_min_longEdge_float; b_temp_float = b_min_longEdge_float; - + /* * Horizontal interpolation loop. */ @@ -861,16 +861,16 @@ iRasterize_LightMap16( if(image_ptr >= imageScanlineLeft_ptr && image_ptr < (UUtUns16*)((char *)imageScanlineLeft_ptr + imageRowBytes_uns)) { iHSV2RGBFilter(r_temp_float,g_temp_float,b_temp_float,&intR,&intG,&intB); - - *image_ptr = + + *image_ptr = ((UUtUns8)(intR >> 3) << 10) | ((UUtUns8)(intG >> 3) << 5) | ((UUtUns8)(intB >> 3) << 0); triVisible = UUcTrue; } - + image_ptr += ptr_ddu_int; - + r_temp_float += r_mid_ddu_float; g_temp_float += g_mid_ddu_float; b_temp_float += b_mid_ddu_float; @@ -880,17 +880,17 @@ iRasterize_LightMap16( /* * Advance to next scanline */ - + u_leftEdge_int += u_leftEdge_ddv_int; u_rightEdge_int += u_rightEdge_ddv_int; - + imageScanlineLeft_ptr = (UUtUns16 *)((char *)imageScanlineLeft_ptr + imageRowBytes_uns); - + r_min_longEdge_float += r_max_ddv_float; g_min_longEdge_float += g_max_ddv_float; b_min_longEdge_float += b_max_ddv_float; } - + //if (renderLightmap) UUmAssert(triVisible == UUcTrue); } @@ -908,21 +908,21 @@ iRasterize_LightMap32( UUtBool inDaylightOn, UUtBool inIsExterior) { - + IMPtEnv_LM_Vertex* vertex_min; IMPtEnv_LM_Vertex* vertex_mid; IMPtEnv_LM_Vertex* vertex_max; - + /* * Key to variable names - * + * * ddx = d/dx, horizontal incremental change * ddy = d/dy, vertical incremental change * * The type is appended to ease the scheduling of integer and floating point variables */ - - + + /* * x left and right variables */ @@ -931,39 +931,39 @@ iRasterize_LightMap32( UUtInt32 u_rightEdge_int, u_rightEdge_ddv_int; UUtInt32 u_shortEdgeBottom_int, u_shortEdgeBottom_ddv_int; UUtInt32 u_shortEdgeTop_int, u_shortEdgeTop_ddv_int; - + /* - * These variables have double duty. They are used to store the int version of the + * These variables have double duty. They are used to store the int version of the * min, mid, max rgb values and the variable interpolation values for rgb */ float r_max_ddv_float, g_max_ddv_float, b_max_ddv_float; float r_mid_ddu_float, g_mid_ddu_float, b_mid_ddu_float; float r_min_longEdge_float, g_min_longEdge_float, b_min_longEdge_float; - + /* * top, middle, and bottom scanlines */ UUtInt32 scanline_min_int, scanline_mid_int, scanline_max_int; - + /* * Pointers into the buffers and the rowBytes */ - + UUtUns32* imageScanlineLeft_ptr; UUtUns16 imageRowBytes_uns; - + /* * Used to indicate whether scanline traversal is left->right or right->left */ UUtInt16 spanDirection_int; - + /* * min, mid, and max variables for x and y */ float v_min_float, v_mid_float, v_max_float; float u_min_float, u_mid_float, u_max_float; float v0_float, v1_float, v2_float; - + /* * Plane equation variables */ @@ -971,51 +971,51 @@ iRasterize_LightMap32( float invDet_float; float v_maxMinusMin_float, v_midMinusMin_float; float u_maxMinusMin_float, u_midMinusMin_float; - + /* * Error variables */ float v_minError_float, v_midError_float; - + /* * Temporary variables */ float temp_float; float r_temp_float, g_temp_float, b_temp_float; - + /* * floating point constants */ - + float u_scale_float = MSmFractOne * MSmSubPixelUnits; float oneHalf_float = 0.5F; float one_float = 1.0F; - + /* * Scanline variables */ UUtInt32 scanline_int; - + UUtInt32 ptr_ddu_int; - + UUtUns32 *image_ptr; - + /* * Pixel & lightmap variables - */ + */ UUtInt32 u_pixelLeft_int, u_pixelRight_int; UUtInt32 i; - + /* * DDA variables */ float invHeight_float; - + // Irradience stuff float a, b, c; float intensity, f; - // Set up irradiance coefficients + // Set up irradiance coefficients { float mag, power, step, stepsize, res, powerBot; float orders_of_mag = 5.0f; @@ -1038,13 +1038,13 @@ iRasterize_LightMap32( /* * Step 1. Sort the vertices according to v. Sort in place to save registers */ - + triVisible = UUcFalse; - + v0_float = inVertex0->v; v1_float = inVertex1->v; v2_float = inVertex2->v; - + if (v0_float < v1_float) { v_min_float = v0_float; @@ -1057,17 +1057,17 @@ iRasterize_LightMap32( { v_min_float = v1_float; v_mid_float = v0_float; - + vertex_min = inVertex1; vertex_mid = inVertex0; } - + if (v2_float < v_min_float) { v_max_float = v_mid_float; v_mid_float = v_min_float; v_min_float = v2_float; - + vertex_max = vertex_mid; vertex_mid = vertex_min; vertex_min = inVertex2; @@ -1076,7 +1076,7 @@ iRasterize_LightMap32( { v_max_float = v_mid_float; v_mid_float = v2_float; - + vertex_max = vertex_mid; vertex_mid = inVertex2; } @@ -1085,20 +1085,20 @@ iRasterize_LightMap32( v_max_float = v2_float; vertex_max = inVertex2; } - + UUmAssert(v_max_float >= v_mid_float); UUmAssert(v_mid_float >= v_min_float); /* * Step 2. Compute plane equations and interwind load/store operations */ - + /* prefetch x mid, min, max */ u_min_float = vertex_min->u; u_mid_float = vertex_mid->u; u_max_float = vertex_max->u; - - + + // Vertex irradiance setup #undef colour_convert #define colour_convert(ir,ig,ib,dr,dg,db) \ @@ -1115,12 +1115,12 @@ iRasterize_LightMap32( dr = UUmPin(dr, 0.0f, 1.0f) * 255.9f; \ dg = UUmPin(dg, 0.0f, 1.0f) * 255.9f; \ db = UUmPin(db, 0.0f, 1.0f) * 255.9f; - - + + colour_convert(vertex_min->r,vertex_min->g,vertex_min->b,r_min_longEdge_float,g_min_longEdge_float,b_min_longEdge_float); colour_convert(vertex_mid->r,vertex_mid->g,vertex_mid->b,r_mid_ddu_float,g_mid_ddu_float,b_mid_ddu_float); colour_convert(vertex_max->r,vertex_max->g,vertex_max->b,r_max_ddv_float,g_max_ddv_float,b_max_ddv_float); - + /* Calc plane equation stuff */ v_maxMinusMin_float = v_max_float - v_min_float; u_midMinusMin_float = u_mid_float - u_min_float; @@ -1128,7 +1128,7 @@ iRasterize_LightMap32( u_maxMinusMin_float = u_max_float - u_min_float; invDet_float = v_maxMinusMin_float * u_midMinusMin_float - v_midMinusMin_float * u_maxMinusMin_float; invDet_float = one_float / invDet_float; - + if (invDet_float > 0.0f) { spanDirection_int = 1; @@ -1138,31 +1138,31 @@ iRasterize_LightMap32( invDet_float = -invDet_float; spanDirection_int = -1; } - + /* Compute plane equation */ m10_float = (v_mid_float - v_max_float) * invDet_float; m11_float = v_maxMinusMin_float * invDet_float; m12_float = -v_midMinusMin_float * invDet_float; - + /* * Step 4. compute ddx parameters and the first, mid and bottom scanlines * Step 5. Set up the vertical DDA */ - + scanline_min_int = (UUtInt32)(v_min_float + oneHalf_float); scanline_mid_int = (UUtInt32)(v_mid_float + oneHalf_float); v_minError_float = ((float)scanline_min_int + oneHalf_float) - v_min_float; v_midError_float = ((float)scanline_mid_int + oneHalf_float) - v_mid_float; - + /* start using r_mid_ddx_int as the ddx instead of the mid */ - r_mid_ddu_float = m11_float * r_mid_ddu_float; - g_mid_ddu_float = m11_float * g_mid_ddu_float; - b_mid_ddu_float = m11_float * b_mid_ddu_float; - + r_mid_ddu_float = m11_float * r_mid_ddu_float; + g_mid_ddu_float = m11_float * g_mid_ddu_float; + b_mid_ddu_float = m11_float * b_mid_ddu_float; + temp_float = v_max_float - oneHalf_float; invHeight_float = u_scale_float / v_midMinusMin_float; u_min_float = u_min_float * u_scale_float; - + /* If the triangle does not hit the first scanline on the screen bail */ if(temp_float < 0.5f) { @@ -1175,58 +1175,58 @@ iRasterize_LightMap32( * This code section sets up the vertical DDA for all three edges. * Begin by computing the inverse of the height of the short top edge. */ - + r_mid_ddu_float += m10_float * r_min_longEdge_float; g_mid_ddu_float += m10_float * g_min_longEdge_float; b_mid_ddu_float += m10_float * b_min_longEdge_float; - + temp_float = u_midMinusMin_float * invHeight_float; - + r_mid_ddu_float += m12_float * r_max_ddv_float; g_mid_ddu_float += m12_float * g_max_ddv_float; b_mid_ddu_float += m12_float * b_max_ddv_float; - + u_shortEdgeTop_int = (UUtInt32)(u_min_float + v_minError_float * temp_float); u_shortEdgeTop_ddv_int = (UUtInt32)temp_float; - + /* * Compute the inverse of the height of the long edge (and do a bit more * pointer setup). */ invHeight_float = one_float / v_maxMinusMin_float; - + imageRowBytes_uns = inRowBytes; - + imageScanlineLeft_ptr = (UUtUns32 *)((char *)inMapMemory + (scanline_min_int * imageRowBytes_uns)); - + /* * Compute the initial value and forward difference for all interpolated parameters * along the long edge. */ - + temp_float = u_maxMinusMin_float * u_scale_float * invHeight_float; u_longEdge_int = (UUtInt32)(u_min_float + v_minError_float * temp_float); u_longEdge_ddv_int = (UUtInt32)temp_float; - r_max_ddv_float = (r_max_ddv_float - r_min_longEdge_float) * invHeight_float; + r_max_ddv_float = (r_max_ddv_float - r_min_longEdge_float) * invHeight_float; g_max_ddv_float = (g_max_ddv_float - g_min_longEdge_float) * invHeight_float; b_max_ddv_float = (b_max_ddv_float - b_min_longEdge_float) * invHeight_float; - + invHeight_float = u_scale_float / (v_maxMinusMin_float - v_midMinusMin_float); - + temp_float = (u_max_float - u_mid_float) * invHeight_float; - + r_min_longEdge_float += (r_max_ddv_float * v_minError_float); g_min_longEdge_float += (g_max_ddv_float * v_minError_float); b_min_longEdge_float += (b_max_ddv_float * v_minError_float); - - + + /* * Compute the inital value and forward difference of X for the bottom short edge. */ - + // XXX - Fucking VisC++ bug { float t2; @@ -1242,20 +1242,20 @@ iRasterize_LightMap32( * the bottom short edge is left or right, so add the appropriate sub-pixel bias * to xShortBottom as well. */ - + if (spanDirection_int > 0) { /* * vMin-vMax (long) is left edge. vMin-vMid (shortTop) is the top right edge, * and vMid-vMax is the bottom right edge. */ - + u_leftEdge_int = u_longEdge_int; u_leftEdge_ddv_int = u_longEdge_ddv_int; - + u_rightEdge_int = u_shortEdgeTop_int; u_rightEdge_ddv_int = u_shortEdgeTop_ddv_int; - + u_shortEdgeBottom_int -= (MSmHalfSubPixel + 1) << MSmFractBits; } else @@ -1264,23 +1264,23 @@ iRasterize_LightMap32( * vMin-vMax (short) is right edge, vMin-vMid (shortTop) is the top left edge, * and vMid-vMax is the bottom left edge. */ - + u_rightEdge_int = u_longEdge_int; u_rightEdge_ddv_int = u_longEdge_ddv_int; - + u_leftEdge_int = u_shortEdgeTop_int; u_leftEdge_ddv_int = u_shortEdgeTop_ddv_int; - + u_shortEdgeBottom_int += (MSmHalfSubPixel - 1) << MSmFractBits; } - + /* * Add in the sub-pixel coverage bias to xLeft and xRight. */ - + u_leftEdge_int += (MSmHalfSubPixel - 1) << MSmFractBits; u_rightEdge_int -= (MSmHalfSubPixel + 1) << MSmFractBits; - + for (scanline_int = scanline_min_int; scanline_int <= scanline_max_int; ++scanline_int) @@ -1289,7 +1289,7 @@ iRasterize_LightMap32( { break; } - + if (scanline_int == scanline_mid_int) { if (spanDirection_int > 0) @@ -1299,7 +1299,7 @@ iRasterize_LightMap32( * Set xRight to the exact subpixel-accurate value that was computed * earlier. */ - + u_rightEdge_ddv_int = u_shortEdgeBottom_ddv_int; u_rightEdge_int = u_shortEdgeBottom_int; } @@ -1310,49 +1310,49 @@ iRasterize_LightMap32( * Set xLeft to the exact subpixel-accurate value that was computed * earlier. */ - + u_leftEdge_ddv_int = u_shortEdgeBottom_ddv_int; u_leftEdge_int = u_shortEdgeBottom_int; } } - + /* * Render a horizontal span. Note that the sub-pixel coverage bias has * already been added into xLeft and xRight. */ - + u_pixelLeft_int = u_leftEdge_int >> (MSmSubPixelBits + MSmFractBits); u_pixelRight_int = u_rightEdge_int >> (MSmSubPixelBits + MSmFractBits); - + if (spanDirection_int > 0) { /* * We are rasterizing from left to right. Compute the pointers to the first * pixel in the span. */ - + image_ptr = imageScanlineLeft_ptr + u_pixelLeft_int; - + ptr_ddu_int = 1; - + } else { /* * We are rasterizing from right to left. */ - + image_ptr = imageScanlineLeft_ptr + u_pixelRight_int; - + ptr_ddu_int = -1; - + } - + r_temp_float = r_min_longEdge_float; g_temp_float = g_min_longEdge_float; b_temp_float = b_min_longEdge_float; - + /* * Horizontal interpolation loop. */ @@ -1362,16 +1362,16 @@ iRasterize_LightMap32( { if(image_ptr >= imageScanlineLeft_ptr && image_ptr < (UUtUns32*)((char *)imageScanlineLeft_ptr + imageRowBytes_uns)) { - *image_ptr = + *image_ptr = ((UUtUns8)r_temp_float << 16) | ((UUtUns8)g_temp_float << 8) | ((UUtUns8)b_temp_float << 0); triVisible = UUcTrue; } - + image_ptr += ptr_ddu_int; - + r_temp_float += r_mid_ddu_float; g_temp_float += g_mid_ddu_float; b_temp_float += b_mid_ddu_float; @@ -1381,17 +1381,17 @@ iRasterize_LightMap32( /* * Advance to next scanline */ - + u_leftEdge_int += u_leftEdge_ddv_int; u_rightEdge_int += u_rightEdge_ddv_int; - + imageScanlineLeft_ptr = (UUtUns32 *)((char *)imageScanlineLeft_ptr + imageRowBytes_uns); - + r_min_longEdge_float += r_max_ddv_float; g_min_longEdge_float += g_max_ddv_float; b_min_longEdge_float += b_max_ddv_float; } - + //if (renderLightmap) UUmAssert(triVisible == UUcTrue); } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_EnvParticle.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_EnvParticle.c index 81c7674..905ec5d 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_EnvParticle.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_EnvParticle.c @@ -21,7 +21,7 @@ // internal globals // ====================================================================== -AUtFlagElement IMPgEnvParticleFlags[] = +AUtFlagElement IMPgEnvParticleFlags[] = { { "not-created", @@ -57,7 +57,7 @@ UUtError IMPrParse_EnvParticle( M3tVector3D marker_z; M3tVector3D particle_x, particle_y, particle_z; M3tVector3D position; - + groupContext = NULL; // clear the particle to zero (default values) @@ -69,7 +69,7 @@ UUtError IMPrParse_EnvParticle( { goto cleanup; } - + // create a GRtGroup from the user data error = GRrGroup_Context_NewFromString( @@ -80,7 +80,7 @@ UUtError IMPrParse_EnvParticle( &group); if (error != UUcError_None) goto cleanup; - + error = GRrGroup_GetString(group, "particle_class", &stringptr); if (error != UUcError_None) goto cleanup; @@ -90,8 +90,8 @@ UUtError IMPrParse_EnvParticle( if (error == UUcError_None) { UUrString_Copy(outParticle->tagname, stringptr, P3cParticleClassNameLength + 1); } - - // construct an orthonormal basis from the input matrix + + // construct an orthonormal basis from the input matrix MUrMatrix_GetCol(inMatrix, 1, &particle_y); MUmVector_Normalize(particle_y); @@ -130,7 +130,7 @@ UUtError IMPrParse_EnvParticle( // successfully parsed particle error = UUcError_None; - + cleanup: if (groupContext) { diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_EnvParticle.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_EnvParticle.h index e6fe2ea..0684105 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_EnvParticle.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_EnvParticle.h @@ -24,4 +24,4 @@ UUtError IMPrParse_EnvParticle( EPtEnvParticle *outParticle); // ====================================================================== -#endif /* IMP_ENVPARTICLE_H */ \ No newline at end of file +#endif /* IMP_ENVPARTICLE_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Environment.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Environment.c index ae8b583..cee785e 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Environment.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Environment.c @@ -5,8 +5,8 @@ CREATED: Sept 3, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ @@ -56,21 +56,21 @@ IMPrEnv_LogError( ...) { va_list ap; - + if(IMPgEnv_ErrorFile == NULL) return; IMPgEnv_Errors = UUcTrue; va_start(ap, inMsg); - + vfprintf(IMPgEnv_ErrorFile, inMsg, ap); - + va_end(ap); - + fprintf(IMPgEnv_ErrorFile, "\n\r"); - + fprintf(IMPgEnv_ErrorFile, "*************************\n\r"); - - fflush(IMPgEnv_ErrorFile); + + fflush(IMPgEnv_ErrorFile); } static UUtError @@ -79,18 +79,18 @@ IMPiEnv_Textures_Process( UUtUns32 inSourceFileModDate) { UUtError error; - + char* textureDirectoryName; BFtFileRef* textureDirectoryRef; BFtFileRef* textureFileRef; BFtFileIterator* fileIterator; - + error = GRrGroup_GetString(inGroup, "textureDirectory", &textureDirectoryName); UUmError_ReturnOnErrorMsg(error, "Could not find textureDirectory name"); - + error = BFrFileRef_MakeFromName(textureDirectoryName, &textureDirectoryRef); UUmError_ReturnOnErrorMsg(error, "Could not find textureDirectory"); - + error = BFrDirectory_FileIterator_New( textureDirectoryRef, @@ -98,13 +98,13 @@ IMPiEnv_Textures_Process( ".BMP", &fileIterator); UUmError_ReturnOnErrorMsg(error, "Could not create file iterator"); - + while(1) { const char *leafName = NULL; char capitalLeafName[255]; - error = + error = BFrDirectory_FileIterator_Next( fileIterator, &textureFileRef); @@ -112,31 +112,31 @@ IMPiEnv_Textures_Process( { break; } - + leafName = BFrFileRef_GetLeafName(textureFileRef); printf("%s\n\r", leafName); strcpy(capitalLeafName, leafName); iCapitalizeString(capitalLeafName); - - error = + + error = Imp_ProcessTexture( textureFileRef, inSourceFileModDate, BMPcFlagFile_Yes, M3cTextureFlags_HasMipMap, capitalLeafName); - + if(error != UUcError_None) { IMPrEnv_LogError("Could not process texture %s", BFrFileRef_GetLeafName(textureFileRef)); } - + BFrFileRef_Dispose(textureFileRef); } - + BFrDirectory_FileIterator_Delete(fileIterator); - + return UUcError_None; } @@ -145,42 +145,42 @@ IMPiEnv_BuildData_New( void) { IMPtEnv_BuildData* newBuildData; - + newBuildData = UUrMemory_Block_New(sizeof(IMPtEnv_BuildData)); - + if(newBuildData == NULL) { return NULL; } - + newBuildData->numPRTs = 0; newBuildData->numPSGs = 0; newBuildData->numBNVs = 1; - + newBuildData->numVisibleQuads = 0; - + newBuildData->sharedPointArray = NULL; newBuildData->sharedPlaneEquArray = NULL; newBuildData->sharedQuadArray = NULL; newBuildData->sharedTexCoordArray = NULL; newBuildData->sharedEnvTexCoordArray = NULL; - + newBuildData->bspPointArray = NULL; newBuildData->bspQuadArray = NULL; - + newBuildData->sharedPointArray = AUrSharedPointArray_New(); newBuildData->sharedPlaneEquArray = AUrSharedPlaneEquArray_New(); newBuildData->sharedQuadArray = AUrSharedQuadArray_New(); newBuildData->sharedTexCoordArray = AUrSharedTexCoordArray_New(); newBuildData->sharedEnvTexCoordArray = AUrSharedEnvTexCoordArray_New(); - + newBuildData->sharedPSGPlaneArray = AUrSharedPlaneEquArray_New(); - + newBuildData->bspPointArray = AUrSharedPointArray_New(); newBuildData->bspQuadArray = AUrSharedQuadArray_New(); - + newBuildData->octTreeNodes = UUrMemory_Block_New(sizeof(IMPtEnv_OctTreeNode) * IMPcEnv_MaxOctTreeNodes); - + if( newBuildData->sharedPointArray == NULL || newBuildData->sharedPlaneEquArray == NULL || @@ -193,7 +193,7 @@ IMPiEnv_BuildData_New( { return NULL; } - + return newBuildData; } @@ -202,52 +202,52 @@ IMPiEnv_BuildData_Delete( IMPtEnv_BuildData* inBuildData) { UUmAssert(inBuildData != NULL); - + if(inBuildData->sharedPointArray != NULL) { AUrSharedPointArray_Delete(inBuildData->sharedPointArray); } - + if(inBuildData->sharedPlaneEquArray != NULL) { AUrSharedPlaneEquArray_Delete(inBuildData->sharedPlaneEquArray); } - + if(inBuildData->sharedQuadArray != NULL) { AUrSharedQuadArray_Delete(inBuildData->sharedQuadArray); } - + if(inBuildData->sharedTexCoordArray != NULL) { AUrSharedTexCoordArray_Delete(inBuildData->sharedTexCoordArray); } - + if(inBuildData->sharedEnvTexCoordArray != NULL) { AUrSharedEnvTexCoordArray_Delete(inBuildData->sharedEnvTexCoordArray); } - + if(inBuildData->sharedPSGPlaneArray != NULL) { AUrSharedPlaneEquArray_Delete(inBuildData->sharedPSGPlaneArray); } - + if(inBuildData->bspPointArray != NULL) { AUrSharedPointArray_Delete(inBuildData->bspPointArray); } - + if(inBuildData->bspQuadArray != NULL) { AUrSharedQuadArray_Delete(inBuildData->bspQuadArray); } - + if(inBuildData->octTreeNodes != NULL) { UUrMemory_Block_Delete(inBuildData->octTreeNodes); } - + UUrMemory_Block_Delete(inBuildData); } @@ -260,7 +260,7 @@ IMPrEnv_Initialize( { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not create error file"); } - + return UUcError_None; } @@ -301,7 +301,7 @@ UUtError IMPiEnv_CreateObjectTagArray( if( new_tags[j] == object_tag ) { error = UUrMemory_Array_GetNewElement( new_array, &new_index, NULL ); - + UUmAssert( error == UUcError_None ); new_tags = (UUtUns32*) UUrMemory_Array_GetMemory( new_array ); @@ -314,7 +314,7 @@ UUtError IMPiEnv_CreateObjectTagArray( } } } - + // build master object tag list error = TMrConstruction_Instance_Renew( TMcTemplate_IndexArray, "ObjectTags", unique_tags, &object_array ); IMPmError_ReturnOnErrorMsg(error, "Could not create object oid"); @@ -337,21 +337,21 @@ IMPrEnv_Add( char* inInstanceName) { UUtError error; - + IMPtEnv_BuildData* buildData; - + UUtBool buildInstance; UUtUns32 createDate; UUtUns32 compileDate; float globalSlopX, globalSlopY, globalSlopZ; - + // 1. Allocate build data memory buildData = IMPiEnv_BuildData_New(); if(buildData == NULL) { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not allocate build data"); } - + // 2. Check the exists and mod date if( TMrConstruction_Instance_CheckExists( @@ -365,11 +365,11 @@ IMPrEnv_Add( { buildInstance = (UUtBool)(createDate < inSourceFileModDate); } - + compileDate = UUrConvertStrToSecsSince1900(IMPgEnv_CompileTime); - + buildInstance = buildInstance || (createDate < compileDate); - + // 3. Process all the textures printf("adding the texture maps\n\r"); error = @@ -379,39 +379,39 @@ IMPrEnv_Add( UUmError_ReturnOnError(error); // 4. Parse the data into our internal data structures - error = + error = IMPrEnv_Parse( inSourceFileRef, inGroup, buildData, &buildInstance); UUmError_ReturnOnError(error); - + if(buildInstance == UUcTrue) { // 5. Process the data - + error = GRrGroup_GetFloat(inGroup, "globalSlopX", &globalSlopX); if(error != UUcError_None) { globalSlopX = 0.0f; } - + error = GRrGroup_GetFloat(inGroup, "globalSlopY", &globalSlopY); if(error != UUcError_None) { globalSlopY = 0.0f; } - + error = GRrGroup_GetFloat(inGroup, "globalSlopZ", &globalSlopZ); if(error != UUcError_None) { globalSlopZ = 0.0f; } - + error = IMPrEnv_Process(buildData, globalSlopX, globalSlopY, globalSlopZ); UUmError_ReturnOnError(error); - + // 6. Create the final instance if(1 || IMPgEnv_Errors == UUcFalse) { @@ -426,10 +426,10 @@ IMPrEnv_Add( } // 7. Create the gunked object tag list IMPiEnv_CreateObjectTagArray(buildData); - + // 8. Delete the internal data structures IMPiEnv_BuildData_Delete(buildData); - + return UUcError_None; } @@ -441,13 +441,13 @@ IMPrEnv_Add_Debug( char* inInstanceName) { UUtError error; - + IMPtEnv_BuildData* buildData; - + UUtBool buildInstance; UUtUns32 createDate; UUtUns32 compileDate; - + float globalSlopX, globalSlopY, globalSlopZ; // 1. Allocate build data memory @@ -456,7 +456,7 @@ IMPrEnv_Add_Debug( { UUmError_ReturnOnErrorMsg(UUcError_OutOfMemory, "Could not allocate build data"); } - + // 2. Check the exists and mod date if( TMrConstruction_Instance_CheckExists( @@ -470,11 +470,11 @@ IMPrEnv_Add_Debug( { buildInstance = (UUtBool)(createDate < inSourceFileModDate); } - + compileDate = UUrConvertStrToSecsSince1900(IMPgEnv_CompileTime); - + buildInstance = buildInstance || (createDate < compileDate); - + // 3. Process all the textures error = IMPiEnv_Textures_Process( @@ -483,14 +483,14 @@ IMPrEnv_Add_Debug( UUmError_ReturnOnError(error); // 4. Parse the data into our internal data structures - error = + error = IMPrEnv_Parse( inSourceFileRef, inGroup, buildData, &buildInstance); UUmError_ReturnOnError(error); - + if(buildInstance == UUcTrue) { // 5. Process the data @@ -499,22 +499,22 @@ IMPrEnv_Add_Debug( { globalSlopX = 0.0f; } - + error = GRrGroup_GetFloat(inGroup, "globalSlopY", &globalSlopY); if(error != UUcError_None) { globalSlopY = 0.0f; } - + error = GRrGroup_GetFloat(inGroup, "globalSlopZ", &globalSlopZ); if(error != UUcError_None) { globalSlopZ = 0.0f; } - + error = IMPrEnv_Process(buildData, globalSlopX, globalSlopY, globalSlopZ); UUmError_ReturnOnError(error); - + // 6. Create the final instance error = IMPrEnv_CreateInstance_Debug(inInstanceName, buildData); UUmError_ReturnOnError(error); @@ -525,6 +525,6 @@ IMPrEnv_Add_Debug( // 8. Delete the internal data structures IMPiEnv_BuildData_Delete(buildData); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Environment.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Environment.h index b1b4756..5a32d7d 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Environment.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Environment.h @@ -1,12 +1,12 @@ /* FILE: Imp_Environment.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 3, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_FX.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_FX.c index ed4b94b..7823076 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_FX.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_FX.c @@ -5,8 +5,8 @@ CREATED: Sept 3, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_FX.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_FX.h index 9978339..f218455 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_FX.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_FX.h @@ -5,8 +5,8 @@ CREATED: Sept 3, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ @@ -29,4 +29,4 @@ UUtError Imp_AddSkyClass( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); -#endif \ No newline at end of file +#endif diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Font.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Font.c index 34b52bc..c1a71ca 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Font.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Font.c @@ -23,11 +23,11 @@ static int sizeof_font_character( struct font_character *character) { int bitmap_size = character->bitmap_width * character->bitmap_height; - + /* vassert(character->bitmap_width>=0 && character->bitmap_height>=0 && character->bitmap_widthbitmap_heightbitmap_width, character->bitmap_height)); -*/ +*/ return sizeof(struct font_character) + bitmap_size + ((bitmap_size & 1) ? 1 : 0); } @@ -56,34 +56,34 @@ iComputeNumLongsForCharacters( UUtUns16 bitmap_height; font_character* character = inCharacters; UUtInt32 bitmap_size = character->bitmap_width * character->bitmap_height; - + num_longs = 0; - + // go through all the characters and copy the data into a glyph for (i = 0; i < inNumCharacters; ++i) { bitmap_width = character->bitmap_width; bitmap_height = character->bitmap_height; - + #if UUmEndian == UUmEndian_Little UUrSwap_2Byte(&bitmap_width); UUrSwap_2Byte(&bitmap_height); - + #endif - + bitmap_size = bitmap_width * bitmap_height; bitmap_size = sizeof(struct font_character) + bitmap_size + ((bitmap_size & 1) ? 1 : 0); - + // calculate the number of bytes in the character->pixels[] num_bytes = (bitmap_width * bitmap_height) + 3; - + // calculate the number of longs that will be used by those pixels num_longs += (num_bytes >> 2); // go to next character (u_byte *)character += bitmap_size; } - + return num_longs; } @@ -99,13 +99,13 @@ iBitmapIsDuplicate( font_character *current_character; UUtUns16 character_to_test_bitmap_size; UUtUns16 i; - + // clear the duplicate character pointers *outDuplicateCharacter = NULL; - + // get a pointer to the current character current_character = inCharacterList; - + // calculate the current characters bitmap size character_to_test_bitmap_size = inCharacterToTest->bitmap_width * @@ -115,18 +115,18 @@ iBitmapIsDuplicate( for (i = 0; i < inNumberOfCharacters; i++) { UUtUns16 current_character_bitmap_size; - + // calculate the current characters bitmap size current_character_bitmap_size = current_character->bitmap_width * current_character->bitmap_height; - + // do the characters have the same bitmap? if ((current_character->character_width == inCharacterToTest->character_width) && (current_character_bitmap_size == character_to_test_bitmap_size)) { UUtUns16 result; - + // check the pixels of the two characters result = memcmp( @@ -139,7 +139,7 @@ iBitmapIsDuplicate( return; } } - + // go to next character (u_byte *)current_character += sizeof_font_character(current_character); } @@ -164,7 +164,7 @@ iProcessFont( UUtUns8 glyph_index; TStFont *font; TStGlyph *glyph; - + font_character *character; UUtInt32 i; UUtUns32 j; @@ -173,17 +173,17 @@ iProcessFont( UUtUns8 *dst; UUtUns8 *src; UUtUns16 curGlyphArrayIndex; - + // read the font data error = BFrFileRef_LoadIntoMemory( inFileRef, &file_length, &data); IMPmError_ReturnOnError(error); - + // go to specific location in the data header = (tag_header*)data; - + #if UUmEndian == UUmEndian_Little UUrSwap_4Byte(&header->group); UUrSwap_4Byte(&header->subgroup); @@ -195,8 +195,8 @@ iProcessFont( UUrSwap_4Byte(&header->user_data); UUrSwap_4Byte(&header->tag); #endif - - definition = (font_definition*)(data + SIZEOF_STRUCT_TAG_HEADER); + + definition = (font_definition*)(data + SIZEOF_STRUCT_TAG_HEADER); #if UUmEndian == UUmEndian_Little UUrSwap_4Byte(&definition->flags); @@ -207,21 +207,21 @@ iProcessFont( #endif characters = data + SIZEOF_STRUCT_TAG_HEADER + SIZEOF_STRUCT_FONT_DEFINITION; - + // create an instance of the font error = TMrConstruction_Instance_NewUnique( TScTemplate_Font, iComputeNumLongsForCharacters((font_character*)characters, definition->number_of_characters), outFont); IMPmError_ReturnOnError(error); - + font = *outFont; - + for(curGlyphArrayIndex = 0; curGlyphArrayIndex < 256; curGlyphArrayIndex++) { font->glyph_arrays[curGlyphArrayIndex] = NULL; } - + // set the font characteristics font->ascending_height = definition->ascending_height; font->descending_height = definition->descending_height; @@ -234,7 +234,7 @@ iProcessFont( { num_bytes = 0; num_longs = 0; - + // go through all the characters and copy the data into a glyph for (i = 0; i < definition->number_of_characters; ++i) { @@ -246,9 +246,9 @@ iProcessFont( UUrSwap_2Byte(&character->bitmap_origin_x); UUrSwap_2Byte(&character->bitmap_origin_y); #endif - + glyph_array_index = HIGH_BYTE(character->character); - + // allocate space for glyphArrays[glyph_array_index] if it is needed if (font->glyph_arrays[glyph_array_index] == NULL) { @@ -261,13 +261,13 @@ iProcessFont( UUrMemory_Clear(font->glyph_arrays[glyph_array_index], sizeof(TStGlyphArray)); } - + if (font->glyph_arrays[glyph_array_index]) { // get a pointer to the glyph being modified glyph_index = LOW_BYTE(character->character); glyph = &font->glyph_arrays[glyph_array_index]->glyphs[glyph_index]; - + // if the glyph hasn't already been set, copy the character data into it if (glyph->code != character->character) { @@ -281,7 +281,7 @@ iProcessFont( glyph->cell = 0; } } - + // go to next character (u_byte *)character += sizeof_font_character(character); } @@ -291,22 +291,22 @@ iProcessFont( for (i = 0; i < definition->number_of_characters; ++i) { font_character *duplicate_character; - + // get a pointer to the glyph being modified glyph_array_index = HIGH_BYTE(character->character); glyph_index = LOW_BYTE(character->character); glyph = &font->glyph_arrays[glyph_array_index]->glyphs[glyph_index]; - + if (glyph->longs_offset != 0) { // go to next character (u_byte *)character += sizeof_font_character(character); continue; } - + // calculate the number of bytes to copy num_bytes = character->bitmap_width * character->bitmap_height; - + // look for duplicate character bitmaps iBitmapIsDuplicate( (font_character*)characters, @@ -319,13 +319,13 @@ iProcessFont( UUtUns16 similar_glyph_array_index; UUtUns16 similar_glyph_index; TStGlyph *similar_glyph; - + // get a pointer to the glyph with the same bitmap similar_glyph_array_index = HIGH_BYTE(duplicate_character->character); similar_glyph_index = LOW_BYTE(duplicate_character->character); similar_glyph = &font->glyph_arrays[similar_glyph_array_index]-> glyphs[similar_glyph_index]; - + // set the longs_offset of the glyph glyph->longs_offset = similar_glyph->longs_offset; } @@ -333,28 +333,28 @@ iProcessFont( { // set the longs_offset of the glyph glyph->longs_offset = num_longs; - + // calculate the number of longs that will be used by those pixels num_longs += (num_bytes + 3) >> 2; - + // get a pointer to the font->longs[] destination dst = (UUtUns8*)(&font->longs[glyph->longs_offset]); src = character->pixels; - - // when copying the bitmap, switch the byte to the form we want + + // when copying the bitmap, switch the byte to the form we want for (j = 0; j < num_bytes; j++) { *dst++ = *src++; } } - + // go to next character (u_byte *)character += sizeof_font_character(character); } } - + UUrMemory_Block_Delete(data); - + return UUcError_None; } @@ -368,18 +368,18 @@ iFindStyleInList( UUtError error; UUtUns32 numStyles; UUtUns32 i; - + GRtElementType elementType; GRtGroup* styleGroup; TStFontStyle curStyle; - + char* styleStr; - + numStyles = GRrGroup_Array_GetLength(inStyleList); - + for(i = 0; i < numStyles; i++) { - error = + error = GRrGroup_Array_GetElement( inStyleList, i, @@ -389,8 +389,8 @@ iFindStyleInList( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Could not get style group"); } - - error = + + error = GRrGroup_GetElement( styleGroup, "style", @@ -417,7 +417,7 @@ iFindStyleInList( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unknown style string"); } - + if(inStyleIndex == curStyle) { *outStyleGroup = styleGroup; @@ -429,7 +429,7 @@ iFindStyleInList( } // ====================================================================== -#if UUmCompiler == UUmCompiler_MWerks +#if UUmCompiler == UUmCompiler_MWerks #pragma mark - #endif // ---------------------------------------------------------------------- @@ -442,7 +442,7 @@ Imp_AddFontFamily( { UUtError error; UUtBool buildInstance; - + buildInstance = !TMrConstruction_Instance_CheckExists(TScTemplate_FontFamily, inInstanceName); if(buildInstance == UUcTrue) @@ -456,9 +456,9 @@ Imp_AddFontFamily( char *style_string; GRtGroup *font_group; char *languageStr; - + // get a pointer to the font array - error = + error = GRrGroup_GetElement( inGroup, "fonts", @@ -468,9 +468,9 @@ Imp_AddFontFamily( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Could not get font list"); } - + num_fonts = GRrGroup_Array_GetLength(font_array); - + // create the font family error = TMrConstruction_Instance_Renew( @@ -479,7 +479,7 @@ Imp_AddFontFamily( num_fonts, &font_family); IMPmError_ReturnOnError(error); - + // process the font array for (i = 0; i < num_fonts; i++) { @@ -494,30 +494,30 @@ Imp_AddFontFamily( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Cound not get font_group from font_array"); } - + // get the file ref of the font - error = + error = Imp_Common_GetFileRefAndModDate( inSourceFileRef, font_group, "file", &fileRef); IMPmError_ReturnOnError(error); - + // process the font error = iProcessFont(fileRef, &font_family->fonts[i]); IMPmError_ReturnOnErrorMsg(error, "Error processing the font data"); - + BFrFileRef_Dispose(fileRef); fileRef = NULL; - + // set the size and style of the font error = GRrGroup_GetUns16(font_group, "size", &font_family->fonts[i]->font_size); IMPmError_ReturnOnErrorMsg(error, "Unable to get the font size"); error = GRrGroup_GetString(font_group, "style", &style_string); IMPmError_ReturnOnErrorMsg(error, "Unable to get the font style string"); - + error = AUrFlags_ParseFromGroupArray( IMPgStyleFlags, @@ -526,7 +526,7 @@ Imp_AddFontFamily( (UUtUns32*)&font_family->fonts[i]->font_style); IMPmError_ReturnOnErrorMsg(error, "Unable to process flags"); } - + // process the language error = GRrGroup_GetElement( @@ -538,15 +538,15 @@ Imp_AddFontFamily( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Could not get language string"); } - - error = + + error = TMrConstruction_Instance_GetPlaceHolder( TScTemplate_FontLanguage, languageStr, (TMtPlaceHolder*)&font_family->font_language); IMPmError_ReturnOnErrorMsg(error, "Could not find font language"); } - + return UUcError_None; } @@ -560,16 +560,16 @@ Imp_AddLanguage( { UUtError error; TStFontLanguage *font_language; - + GRtElementType elementType; char* breaking_1; char* breaking_2; char* breaking_3; char* breaking_4; char* breaking_5; - + UUtBool buildInstance; - + buildInstance = !TMrConstruction_Instance_CheckExists(TScTemplate_FontLanguage, inInstanceName); if(buildInstance == UUcTrue) @@ -584,7 +584,7 @@ Imp_AddLanguage( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Could not get breaking1"); } - + error = GRrGroup_GetElement( inGroup, @@ -595,7 +595,7 @@ Imp_AddLanguage( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Could not get breaking1"); } - + error = GRrGroup_GetElement( inGroup, @@ -606,7 +606,7 @@ Imp_AddLanguage( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Could not get breaking1"); } - + error = GRrGroup_GetElement( inGroup, @@ -617,7 +617,7 @@ Imp_AddLanguage( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Could not get breaking1"); } - + error = GRrGroup_GetElement( inGroup, @@ -628,7 +628,7 @@ Imp_AddLanguage( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Could not get breaking1"); } - + // create an instance of the font error = TMrConstruction_Instance_Renew( TScTemplate_FontLanguage, @@ -636,7 +636,7 @@ Imp_AddLanguage( 0, &font_language); IMPmError_ReturnOnError(error); - + // don't keep the quotes at the beginning and end of the breaking lists { UUtInt16 len_breaking_1; @@ -644,26 +644,26 @@ Imp_AddLanguage( UUtInt16 len_breaking_3; UUtInt16 len_breaking_4; UUtInt16 len_breaking_5; - + breaking_1++; breaking_2++; breaking_3++; breaking_4++; breaking_5++; - + len_breaking_1 = UUmMax(strlen(breaking_1) - 1, 0); len_breaking_2 = UUmMax(strlen(breaking_2) - 1, 0); len_breaking_3 = UUmMax(strlen(breaking_3) - 1, 0); len_breaking_4 = UUmMax(strlen(breaking_4) - 1, 0); len_breaking_5 = UUmMax(strlen(breaking_5) - 1, 0); - + breaking_1[len_breaking_1] = '\0'; breaking_2[len_breaking_2] = '\0'; breaking_3[len_breaking_3] = '\0'; breaking_4[len_breaking_4] = '\0'; breaking_5[len_breaking_5] = '\0'; } - + // set the font languages's characteristics UUrString_Copy(font_language->breaking_1, breaking_1, 64); UUrString_Copy(font_language->breaking_2, breaking_2, 64); @@ -671,7 +671,7 @@ Imp_AddLanguage( UUrString_Copy(font_language->breaking_4, breaking_4, 64); UUrString_Copy(font_language->breaking_5, breaking_5, 64); } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Font.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Font.h index efad4cb..e2a59e5 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Font.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Font.h @@ -49,12 +49,12 @@ typedef struct tag_header // 64 bytes // unsigned long flags... word tag_version; word flags; - + long offset, size; - + unsigned long user_data; - file_tag tag; + file_tag tag; } tag_header; enum // styles @@ -72,7 +72,7 @@ enum { FONT_DEFINITION_VERSION_NUMBER= 1, MAXIMUM_FONT_DEFINITIONS_PER_MAP= 16, - + NUMBER_OF_LEAD_BYTE_CHARACTER_TABLES= 256, NUMBER_OF_TRAILING_CHARACTERS_PER_TABLE= 256 }; @@ -83,21 +83,21 @@ enum typedef struct font_definition { unsigned long flags; - + short ascending_height, descending_height; // character_height == ascending_height + descending_height short leading_height; // line_height == character_height + leading_height short leading_width; // amount to inset from left edge of rectangle - + int number_of_characters, characters_offset, characters_size; - + file_tag style_font_tags[NUMBER_OF_FONT_STYLES]; - + short unused[2]; - + struct bitmap_data *hardware_bitmap; - + short style_font_indexes[NUMBER_OF_FONT_STYLES]; - + struct font_character *characters; // memory-based struct font_character ***lead_byte_character_tables; // memory-based } font_definition; @@ -111,13 +111,13 @@ typedef struct font_character short bitmap_width, bitmap_height; // of bitmap short bitmap_origin_x, bitmap_origin_y; // in bitmap coordinates, can be outside of bitmap - + short hardware_texture_origin_x, hardware_texture_origin_y; - + // bitmap_width*bitmap_height bytes of 8-bit bitmap data follows // zero is transparent, 255 is opaque u_byte pixels[]; } font_character; // ====================================================================== -#endif /* FONTEXTRACTOR_H */ \ No newline at end of file +#endif /* FONTEXTRACTOR_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Furniture.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Furniture.c index 6af4243..61540fa 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Furniture.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Furniture.c @@ -44,10 +44,10 @@ IMPrFurniture_GetLightData( GRtGroup *group; GRtElementType groupType; GRtGroup *ls_group; - + IMPtLS_LightType light_type; IMPtLS_Distribution light_distribution; - + // init groupContext = NULL; @@ -56,7 +56,7 @@ IMPrFurniture_GetLightData( { goto cleanup; } - + // create a GRtGroup from the user data error = GRrGroup_Context_NewFromString( @@ -66,7 +66,7 @@ IMPrFurniture_GetLightData( &groupContext, &group); if (error != UUcError_None) { goto cleanup; } - + // get the ls group from the user data group error = GRrGroup_GetElement( @@ -75,7 +75,7 @@ IMPrFurniture_GetLightData( &groupType, &ls_group); if (error != UUcError_None) { goto cleanup; } - + // create the OBJtLSData instance error = TMrConstruction_Instance_Renew( @@ -84,11 +84,11 @@ IMPrFurniture_GetLightData( 0, &ioFurnGeom->ls_data); if (error != UUcError_None) { goto cleanup; } - + // init ioFurnGeom->ls_data->index = inIndex; ioFurnGeom->ls_data->light_flags = OBJcLightFlag_HasLight; - + // process the user data error = IMPrEnv_GetLSData( @@ -100,7 +100,7 @@ IMPrFurniture_GetLightData( &ioFurnGeom->ls_data->beam_angle, &ioFurnGeom->ls_data->field_angle); if (error != UUcError_None) { goto cleanup; } - + // set the light type flags if (light_type == IMPcLS_LightType_Area) { @@ -114,7 +114,7 @@ IMPrFurniture_GetLightData( { ioFurnGeom->ls_data->light_flags |= OBJcLightFlag_Type_Point; } - + // set the light distribution flags if (light_distribution == IMPcLS_Distribution_Diffuse) { @@ -124,7 +124,7 @@ IMPrFurniture_GetLightData( { ioFurnGeom->ls_data->light_flags |= OBJcLightFlag_Dist_Spot; } - + cleanup: if (groupContext) { @@ -139,7 +139,7 @@ IMPiAddFurniture( { UUtError error; BFtFileIterator *file_iterator; - + // create the file iterator for the directory error = BFrDirectory_FileIterator_New( @@ -148,7 +148,7 @@ IMPiAddFurniture( ".ENV", &file_iterator); IMPmError_ReturnOnError(error); - + while (1) { MXtHeader *header; @@ -164,11 +164,11 @@ IMPiAddFurniture( UUtUns32 m; UUtUns32 num_particles; EPtEnvParticle particle[IMPcFurniture_MaxParticles]; - + // get file ref for the file error = BFrDirectory_FileIterator_Next(file_iterator, &file_ref); if (error != UUcError_None) { break; } - + // init header = NULL; furn_geom_array = NULL; @@ -177,18 +177,18 @@ IMPiAddFurniture( // parse the .env file error = Imp_ParseEnvFile(&file_ref, &header); IMPmError_ReturnOnError(error); - + // copy the file name into name UUrString_Copy(name, BFrFileRef_GetLeafName(&file_ref), BFcMaxFileNameLength); UUrString_StripExtension(name); - + // calculate the number of geometries num_geoms = 0; for (i = 0; i < header->numNodes; i++) { num_geoms += header->nodes[i].numMaterials; } - + // build the geometry array instance error = TMrConstruction_Instance_Renew( @@ -197,7 +197,7 @@ IMPiAddFurniture( num_geoms, &furn_geom_array); IMPmError_ReturnOnError(error); - + // initialize the furn_geoms and get the flag and light data // yes this is a bit inneficient, but it is import time and won't be that big // of a deal @@ -209,11 +209,11 @@ IMPiAddFurniture( furn_geom_array->furn_geom[geom_index].gq_flags = AKcGQ_Flag_None; furn_geom_array->furn_geom[geom_index].geometry = NULL; furn_geom_array->furn_geom[geom_index].ls_data = NULL; - + // get the GQ flags furn_geom_array->furn_geom[geom_index].gq_flags = IMPrEnv_GetNodeFlags(&header->nodes[i]); - + // get the light data IMPrFurniture_GetLightData( &header->nodes[i], @@ -221,17 +221,17 @@ IMPiAddFurniture( &furn_geom_array->furn_geom[geom_index]); } } - + for (i = 0, geom_index = 0; i < header->numNodes; i++) { for (m = 0; m < header->nodes[i].numMaterials; m++, geom_index++) { char geom_name[BFcMaxFileNameLength]; M3tGeometry *geometry; - + // set up the name sprintf(geom_name, "%s_%d", name, geom_index); - + // build the geometry instance error = TMrConstruction_Instance_Renew( @@ -240,24 +240,24 @@ IMPiAddFurniture( 0, &geometry); IMPmError_ReturnOnError(error); - + geometry->animation = NULL; - + // put the tris and quads associated with material m into a geometry Imp_NodeMaterial_To_Geometry_ApplyMatrix(&header->nodes[i], (UUtUns16)m, geometry); - + // set the geometry furn_geom_array->furn_geom[geom_index].geometry = geometry; - + // get the texture name textureName = header->nodes[i].materials[m].maps[MXcMapping_DI].name; - + // strip off the extension UUrString_Copy(mungedTextureName, textureName, BFcMaxFileNameLength); UUrString_Capitalize(mungedTextureName, BFcMaxFileNameLength); UUrString_StripExtension(mungedTextureName); UUmAssert(strchr(mungedTextureName, '.') == NULL); - + // get a placeholder to the texture map geometry->baseMap = M3rTextureMap_GetPlaceholder(mungedTextureName); UUmAssert(geometry->baseMap); @@ -288,15 +288,15 @@ IMPiAddFurniture( IMPrEnv_CreateInstance_EnvParticles(num_particles, particle, &furn_geom_array->particle_array); } - + // delete the header Imp_EnvFile_Delete(header); header = NULL; } - + BFrDirectory_FileIterator_Delete(file_iterator); file_iterator = NULL; - + return UUcError_None; } @@ -307,7 +307,7 @@ IMPiAddFurnitureTextures( { UUtError error; BFtFileIterator *file_iterator; - + // create the file iterator for the directory error = BFrDirectory_FileIterator_New( @@ -316,13 +316,13 @@ IMPiAddFurnitureTextures( NULL, &file_iterator); IMPmError_ReturnOnError(error); - + while (1) { BFtFileRef file_ref; char name[BFcMaxFileNameLength]; TMtPlaceHolder texture_ref; - + // get file ref for the file error = BFrDirectory_FileIterator_Next(file_iterator, &file_ref); if (error != UUcError_None) { break; } @@ -337,19 +337,19 @@ IMPiAddFurnitureTextures( valid_image_suffix = UUmString_IsEqual_NoCase(file_suffix, "bmp") || UUmString_IsEqual_NoCase(file_suffix, "psd"); if (!valid_image_suffix) { continue; } } - + // get the file name - UUrString_Copy(name, BFrFileRef_GetLeafName(&file_ref), BFcMaxFileNameLength); + UUrString_Copy(name, BFrFileRef_GetLeafName(&file_ref), BFcMaxFileNameLength); UUrString_Capitalize(name, BFcMaxFileNameLength); UUrString_StripExtension(name); - + error = Imp_ProcessTexture_File(&file_ref, name, &texture_ref); IMPmError_ReturnOnError(error); } - + BFrDirectory_FileIterator_Delete(file_iterator); file_iterator = NULL; - + return UUcError_None; } @@ -365,11 +365,11 @@ Imp_AddFurniture( BFtFileRef *furniture_dir; BFtFileRef *texture_dir; char *dir_name; - + // get the dir_name the files are in error = GRrGroup_GetString(inGroup, "path", &dir_name); UUmError_ReturnOnError(error); - + // create the furniture directory file ref error = BFrFileRef_DuplicateAndReplaceName( @@ -377,7 +377,7 @@ Imp_AddFurniture( dir_name, &furniture_dir); IMPmError_ReturnOnError(error); - + // create the texture directory file ref error = BFrFileRef_DuplicateAndAppendName( @@ -385,17 +385,17 @@ Imp_AddFurniture( "textures", &texture_dir); IMPmError_ReturnOnError(error); - + // import the furniture error = IMPiAddFurniture(furniture_dir); IMPmError_ReturnOnError(error); - + // import the textures error = IMPiAddFurnitureTextures(texture_dir); IMPmError_ReturnOnError(error); BFrFileRef_Dispose(furniture_dir); BFrFileRef_Dispose(texture_dir); - - return UUcError_None; -} \ No newline at end of file + + return UUcError_None; +} diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Furniture.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Furniture.h index d221798..535948f 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Furniture.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Furniture.h @@ -19,7 +19,7 @@ IMPrFurniture_GetLightData( MXtNode *inNode, UUtUns32 inIndex, OBJtFurnGeom *ioFurnGeom); - + UUtError Imp_AddFurniture( BFtFileRef* inSourceFileRef, @@ -28,4 +28,4 @@ Imp_AddFurniture( char* inInstanceName); // ====================================================================== -#endif /* IMP_FURNITURE_H */ \ No newline at end of file +#endif /* IMP_FURNITURE_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_GameSettings.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_GameSettings.c index 2fa8d33..180891a 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_GameSettings.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_GameSettings.c @@ -32,12 +32,12 @@ static void Imp_GetDifficultyMultipliers(GRtGroup *inGroup, const char *inName, float *outMultipliers) { - UUtError error; + UUtError error; GRtElementType element_type; GRtElementArray *multiplier_array; void *element; UUtUns32 itr, array_length; - + UUmAssertWritePtr(outMultipliers, ONcDifficultyLevel_Count * sizeof(float)); @@ -58,14 +58,14 @@ static void Imp_GetDifficultyMultipliers(GRtGroup *inGroup, const char *inName, if ((error == UUcError_None) && (element_type == GRcElementType_String)) { UUrString_To_Float((const char *) element, &outMultipliers[itr]); - } + } } } } UUtError Imp_AddGameSettings( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName ) { - UUtError error; + UUtError error; ONtGameSettings *settings; GRtElementType element_type; GRtElementArray *sub_array, *main_array; @@ -146,28 +146,28 @@ UUtError Imp_AddGameSettings( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFile // get the value of this point on the ramp error = GRrGroup_Array_GetElement(sub_array, cHealthColor_Value, &element_type, &element); - if ((error != UUcError_None) || (element_type != GRcElementType_String) || + if ((error != UUcError_None) || (element_type != GRcElementType_String) || (UUrString_To_Float((const char *) element, &temp_float) != UUcError_None)) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "game settings: health color values must be numbers"); - } + } settings->healthcolor_values[itr] = temp_float / 100.0f; // get the color of this point error = GRrGroup_Array_GetElement(sub_array, cHealthColor_Red, &element_type, &element); - if ((error != UUcError_None) || (element_type != GRcElementType_String) || + if ((error != UUcError_None) || (element_type != GRcElementType_String) || (UUrString_To_Uns32((const char *) element, &r) != UUcError_None)) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "game settings: health color red values must be numbers"); - } + } error = GRrGroup_Array_GetElement(sub_array, cHealthColor_Green, &element_type, &element); - if ((error != UUcError_None) || (element_type != GRcElementType_String) || + if ((error != UUcError_None) || (element_type != GRcElementType_String) || (UUrString_To_Uns32((const char *) element, &g) != UUcError_None)) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "game settings: health color green values must be numbers"); - } + } error = GRrGroup_Array_GetElement(sub_array, cHealthColor_Blue, &element_type, &element); - if ((error != UUcError_None) || (element_type != GRcElementType_String) || + if ((error != UUcError_None) || (element_type != GRcElementType_String) || (UUrString_To_Uns32((const char *) element, &b) != UUcError_None)) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "game settings: health color blue values must be numbers"); - } + } settings->healthcolor_colors[itr] = 0xFF000000 | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF); } @@ -259,12 +259,12 @@ UUtError Imp_AddGameSettings( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFile // get the start and end levels for which this prompt will be displayed error = GRrGroup_Array_GetElement(sub_array, cAutoPrompt_StartLevel, &element_type, &element); - if ((error != UUcError_None) || (element_type != GRcElementType_String) || + if ((error != UUcError_None) || (element_type != GRcElementType_String) || (UUrString_To_Uns16((const char *) element, &settings->autoprompts[itr].start_level) != UUcError_None)) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "game settings: autoprompt start level values must be numbers"); } error = GRrGroup_Array_GetElement(sub_array, cAutoPrompt_EndLevel, &element_type, &element); - if ((error != UUcError_None) || (element_type != GRcElementType_String) || + if ((error != UUcError_None) || (element_type != GRcElementType_String) || (UUrString_To_Uns16((const char *) element, &settings->autoprompts[itr].end_level) != UUcError_None)) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "game settings: autoprompt end level values must be numbers"); } @@ -277,7 +277,7 @@ UUtError Imp_AddGameSettings( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFile UUrString_Copy(settings->autoprompts[itr].message_name, (const char *) element, 32); } } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_InGameUI.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_InGameUI.c index a83121b..96486ab 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_InGameUI.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_InGameUI.c @@ -51,7 +51,7 @@ static AUtFlagElement IMPgMoveKeys[] = { "quick", ONcKey_Quick }, { "w", ONcKey_Wait }, { "wait", ONcKey_Wait }, - + { NULL, 0 } }; @@ -63,7 +63,7 @@ static AUtFlagElement IMPgPowerupTypes[] = { "shield", WPcPowerup_ShieldBelt }, { "invis", WPcPowerup_Invisibility }, { "lsi", WPcPowerup_LSI }, - + { NULL, WPcPowerup_None } }; @@ -77,14 +77,14 @@ typedef struct ONtIGUI_StringListElem { char id[ONcIGUI_ElemName_MaxChars]; char *text; - + } ONtIGUI_StringListElem; typedef struct ONtIGUI_StringList { UUtUns32 num_lines; ONtIGUI_StringListElem lines[1024]; - + } ONtIGUI_StringList; // ====================================================================== @@ -98,18 +98,18 @@ IGUIiStringList_Get( UUtError error; BFtTextFile *text_file; ONtIGUI_StringList *string_list; - + text_file = NULL; string_list = NULL; - + error = BFrTextFile_MapForRead(inSourceFile, &text_file); if (error != UUcError_None) { return NULL; } - + // find the "#strings" line do { char *start; - + start = BFrTextFile_GetNextStr(text_file); if (start == NULL) { goto exit; } if (UUrString_CompareLen_NoCase(start, "#strings", strlen("#strings")) == 0) @@ -118,11 +118,11 @@ IGUIiStringList_Get( } } while (1); - + // the file has a string list, so allocate an ONtIGUI_StringList string_list = (ONtIGUI_StringList*)UUrMemory_Block_NewClear(sizeof(ONtIGUI_StringList)); string_list->num_lines = 0; - + // the following are the actual text do { @@ -130,13 +130,13 @@ IGUIiStringList_Get( char elem_name[ONcIGUI_ElemName_MaxChars]; UUtUns32 i; UUtUns32 index; - + string = BFrTextFile_GetNextStr(text_file); if (string == NULL) { break; } - + // skip lines that don't begin with # if (string[0] != '#') { continue; } - + // read the element name UUrMemory_Clear(elem_name, ONcIGUI_ElemName_MaxChars); for (i = 0; i < ONcIGUI_ElemName_MaxChars; i++) @@ -144,7 +144,7 @@ IGUIiStringList_Get( if (UUrIsSpace(string[i + 1])) { break; } elem_name[i] = string[i + 1]; } - + // find the start of the string do { @@ -154,30 +154,30 @@ IGUIiStringList_Get( string++; } while (1); - + // create the ONtIGUI_StringListElem index = string_list->num_lines; UUrString_Copy( string_list->lines[index].id, elem_name, ONcIGUI_ElemName_MaxChars); - + string_list->lines[index].text = (char*)UUrMemory_Block_New((strlen(string) + 1)); if (string_list->lines[index].text != NULL) { UUrString_Copy(string_list->lines[index].text, string, (strlen(string) + 1)); } - + string_list->num_lines++; } while (1); - + exit: if (text_file) { BFrTextFile_Close(text_file); } - + return string_list; } @@ -189,26 +189,26 @@ IGUIiStringList_GetText( { UUtUns32 i; char *text; - + if ((inStringList == NULL) || (inElemName == NULL)) { return NULL; } - + text = NULL; - + for (i = 0; i < inStringList->num_lines; i++) { UUtInt32 result; - + result = UUrString_Compare_NoCase( inStringList->lines[i].id, inElemName); - + if (result != 0) { continue; } - + text = inStringList->lines[i].text; break; } - + return text; } @@ -218,9 +218,9 @@ IGUIiStringList_Delete( ONtIGUI_StringList *inStringList) { UUtUns32 i; - + if (inStringList == NULL) { return; } - + for (i = 0; i < inStringList->num_lines; i++) { if (inStringList->lines[i].text != NULL) @@ -229,7 +229,7 @@ IGUIiStringList_Delete( inStringList->lines[i].text = NULL; } } - + UUrMemory_Block_Delete(inStringList); inStringList = NULL; } @@ -250,11 +250,11 @@ iGetTextureByPath( BFtFileRef *texture_file_ref; const char *texture_name; TMtPlaceHolder texture_map; - + UUmAssert(inPath); UUmAssert(inParentDir); UUmAssert(outTextureMap); - + // create a new file ref using the file name error = BFrFileRef_DuplicateAndReplaceName( @@ -262,10 +262,10 @@ iGetTextureByPath( inPath, &texture_file_ref); IMPmError_ReturnOnErrorMsg(error, "texture file was not found"); - + // set the textures name texture_name = BFrFileRef_GetLeafName(texture_file_ref); - + // process the texture map file error = Imp_ProcessTexture_File( @@ -273,11 +273,11 @@ iGetTextureByPath( texture_name, &texture_map); IMPmError_ReturnOnErrorMsg(error, "unable to process the texture"); - + BFrFileRef_Dispose(texture_file_ref); - + *outTextureMap = texture_map; - + return UUcError_None; } @@ -292,11 +292,11 @@ iGetTextureBigByPath( BFtFileRef *texture_file_ref; const char *texture_name; TMtPlaceHolder texture_map; - + UUmAssert(inPath); UUmAssert(inParentDir); UUmAssert(outTextureMap); - + // create a new file ref using the file name error = BFrFileRef_DuplicateAndReplaceName( @@ -304,10 +304,10 @@ iGetTextureBigByPath( inPath, &texture_file_ref); IMPmError_ReturnOnErrorMsg(error, "texture file was not found"); - + // set the textures name texture_name = BFrFileRef_GetLeafName(texture_file_ref); - + // process the texture map file error = Imp_ProcessTexture_Big_File( @@ -315,11 +315,11 @@ iGetTextureBigByPath( texture_name, &texture_map); IMPmError_ReturnOnErrorMsg(error, "unable to process the texture"); - + BFrFileRef_Dispose(texture_file_ref); - + *outTextureMap = texture_map; - + return UUcError_None; } @@ -344,9 +344,9 @@ Imp_IGUI_FontInfo( // initialize the font info UUrMemory_Clear(outFontInfo, sizeof(ONtIGUI_FontInfo)); outFontInfo->flags = IGUIcFontInfoFlag_None; - + if (inGroup == NULL) { return; } - + // get the font_info from the group error = GRrGroup_GetElement( @@ -366,14 +366,14 @@ Imp_IGUI_FontInfo( { outFontInfo->flags |= IGUIcFontInfoFlag_FontFamily; } - + // get teh font size error = GRrGroup_GetUns32(data, "font_size", &font_size); if (error == UUcError_None) { outFontInfo->flags |= IGUIcFontInfoFlag_FontSize; } - + // get the font style error = GRrGroup_GetElement(data, "font_style", &element_type, &font_style_data); if (error == UUcError_None) @@ -389,7 +389,7 @@ Imp_IGUI_FontInfo( outFontInfo->flags |= IGUIcFontInfoFlag_FontStyle; } } - + // get the font shade error = GRrGroup_GetElement(data, "font_shade", &element_type, &font_shade_data); if (error == UUcError_None) @@ -423,16 +423,16 @@ Imp_IGUI_FontInfo( { outFontInfo->flags |= IGUIcFontInfoFlag_FontFamily; } - + // get teh font size error = GRrGroup_Array_GetElement(data, cInfoSize, &element_type, &font_size_data); if (error == UUcError_None) { outFontInfo->flags |= IGUIcFontInfoFlag_FontSize; } - + sscanf((char*)font_size_data, "%d", &font_size); - + // get the font style error = GRrGroup_Array_GetElement(data, cInfoStyle, &element_type, &font_style_data); if (error == UUcError_None) @@ -448,7 +448,7 @@ Imp_IGUI_FontInfo( outFontInfo->flags |= IGUIcFontInfoFlag_FontStyle; } } - + // get the font shade error = GRrGroup_Array_GetElement(data, cInfoShade, &element_type, &font_shade_data); if (error == UUcError_None) @@ -474,12 +474,12 @@ Imp_IGUI_FontInfo( } } } - + // setup the outFontInfo data if ((outFontInfo->flags & IGUIcFontInfoFlag_FontFamily) != 0) { // get a placeholder for the font - error = + error = TMrConstruction_Instance_GetPlaceHolder( TScTemplate_FontFamily, font_name, @@ -494,7 +494,7 @@ Imp_IGUI_FontInfo( { outFontInfo->font_size = (UUtUns16)font_size; } - + if ((outFontInfo->flags & IGUIcFontInfoFlag_FontStyle) != 0) { outFontInfo->font_style = (TStFontStyle)font_style; @@ -520,7 +520,7 @@ Imp_IGUI_String( UUtUns32 length; UUtBool no_quotes; char *last_quote; - + // create the string error = TMrConstruction_Instance_NewUnique( @@ -532,23 +532,23 @@ Imp_IGUI_String( Imp_PrintWarning("Unable to create string instance."); return NULL; } - + switch (inElementType) { case GRcElementType_String: // get the text elem_name = (char*)inData; - + // get the font info Imp_IGUI_FontInfo(NULL, &string->font_info); break; - + case GRcElementType_Group: { GRtGroup *group; - + group = (GRtGroup*)inData; - + // get the text error = GRrGroup_GetString(group, "text", &elem_name); if (error != UUcError_None) @@ -556,18 +556,18 @@ Imp_IGUI_String( Imp_PrintWarning("Unable to get text from text_array group."); return NULL; } - + // get the font info Imp_IGUI_FontInfo(group, &string->font_info); } break; - + default: Imp_PrintWarning("can't process that element type"); return NULL; break; } - + // get the string from the inStringList text = IGUIiStringList_GetText(inStringList, elem_name); if (text == NULL) @@ -575,7 +575,7 @@ Imp_IGUI_String( Imp_PrintWarning("Unable to get text %s from the string list", elem_name); return NULL; } - + // make sure the strings will have at least one character in it and that it begins // with a quotation mark no_quotes = UUcFalse; @@ -584,7 +584,7 @@ Imp_IGUI_String( { no_quotes = UUcTrue; } - + if (no_quotes == UUcFalse) { // find the last quotation mark and make sure there is only white space @@ -592,11 +592,11 @@ Imp_IGUI_String( // one quote on the line if this code is reached last_quote = strrchr(text, '"'); last_quote++; - + while (1) { char c; - + c = *last_quote++; if (c == 0) { break; } if (UUrIsSpace(c) == UUcFalse) @@ -606,7 +606,7 @@ Imp_IGUI_String( } } } - + if (no_quotes == UUcTrue) { if (length < 3) @@ -629,14 +629,14 @@ Imp_IGUI_String( { text[ONcIGUI_MaxStringLength - 1] = '\0'; } - + // copy the text into the string UUrString_Copy(string->string, (text + 1), ONcIGUI_MaxStringLength); - + length = strlen(string->string); string->string[length - 1] = '\0'; } - + // return the string return string; } @@ -654,7 +654,7 @@ Imp_IGUI_StringArray( UUtUns32 num_elements; ONtIGUI_StringArray *string_array; UUtUns32 i; - + error = GRrGroup_GetElement( inGroup, @@ -666,14 +666,14 @@ Imp_IGUI_StringArray( // Imp_PrintWarning("Unable to get string array from group"); return NULL; } - + num_elements = GRrGroup_Array_GetLength(text_array); if (num_elements == 0) { // Imp_PrintWarning("The string array has no items in it"); return NULL; } - + // create the text array error = TMrConstruction_Instance_NewUnique( @@ -685,13 +685,13 @@ Imp_IGUI_StringArray( Imp_PrintWarning("Unable to create string array instance."); return NULL; } - + for (i = 0; i < num_elements; i++) { void *data; - + string_array->string[i] = NULL; - + // get the text from the array error = GRrGroup_Array_GetElement( @@ -704,11 +704,11 @@ Imp_IGUI_StringArray( Imp_PrintWarning("Unable to get element from text array"); continue; } - + // process the string string_array->string[i] = Imp_IGUI_String(data, element_type, inStringList); } - + // return the string array return string_array; } @@ -726,12 +726,12 @@ Imp_IGUI_Page( ONtIGUI_Page *page; char *part_name; TMtPlaceHolder part; - + pict = 0; path = NULL; page = NULL; part = 0; - + // create the template instance error = TMrConstruction_Instance_NewUnique( @@ -743,14 +743,14 @@ Imp_IGUI_Page( Imp_PrintWarning("Unable to create the page instance"); return NULL; } - + // import the pict error = GRrGroup_GetString(inGroup, "pict", &path); if (error == UUcError_None) { error = iGetTextureByPath(path, inSourceFile, &pict); } - + // import the part if (pict == 0) { @@ -763,16 +763,16 @@ Imp_IGUI_Page( &part); } } - + // set the data if (pict != 0) { page->pict = (void*)pict; } else { page->pict = (void*)part; } page->text = Imp_IGUI_StringArray(inGroup, "text", inStringList); page->hint = Imp_IGUI_StringArray(inGroup, "hint", inStringList); - - // get the font info + + // get the font info Imp_IGUI_FontInfo(inGroup, &page->font_info); - + return page; } @@ -790,7 +790,7 @@ Imp_IGUI_PageArray( GRtElementArray *element_array; ONtIGUI_PageArray *page_array; UUtUns32 i; - + // get the page_array element array error = GRrGroup_GetElement( @@ -803,7 +803,7 @@ Imp_IGUI_PageArray( Imp_PrintWarning("Unable to get page_array from group"); return NULL; } - + // get the number of elements num_elements = GRrGroup_Array_GetLength(element_array); if (num_elements == 0) @@ -811,9 +811,9 @@ Imp_IGUI_PageArray( Imp_PrintWarning("The page_array doesn't have any elements in it."); return NULL; } - + // create the template instance - error = + error = TMrConstruction_Instance_NewUnique( ONcTemplate_IGUI_PageArray, num_elements, @@ -823,12 +823,12 @@ Imp_IGUI_PageArray( Imp_PrintWarning("Unable to create the page array instance"); return NULL; } - + // process the array elements for (i = 0; i < num_elements; i++) { GRtGroup *page_group; - + error = GRrGroup_Array_GetElement( element_array, @@ -840,11 +840,11 @@ Imp_IGUI_PageArray( Imp_PrintWarning("Unable to process page group in page_array"); continue; } - + page_array->pages[i] = Imp_IGUI_Page(inSourceFile, page_group, inStringList); } - - return page_array; + + return page_array; } // ---------------------------------------------------------------------- @@ -858,11 +858,11 @@ Imp_AddDiaryPage( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(ONcTemplate_DiaryPage, inInstanceName); - + if (build_instance) { GRtElementType element_type; @@ -875,21 +875,21 @@ Imp_AddDiaryPage( UUtUns32 i; ONtIGUI_Page *page; ONtIGUI_StringList *string_list; - + // get the level number error = GRrGroup_GetInt16(inGroup, "level_number", &level_number); IMPmError_ReturnOnErrorMsg(error, "unable to get level number"); - + // get the page number error = GRrGroup_GetInt16(inGroup, "page_number", &page_number); IMPmError_ReturnOnErrorMsg(error, "unable to get page number"); - + // get the page number error = GRrGroup_GetBool(inGroup, "has_new_move", &has_new_move); if (error != UUcError_None) { has_new_move = UUcFalse; } - + // get the move keys error = GRrGroup_GetElement( @@ -901,16 +901,16 @@ Imp_AddDiaryPage( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "unable to get key array"); } - + UUrMemory_Clear(keys, sizeof(ONtKey) * ONcMaxNumKeys); for (i = 0; i < GRrGroup_Array_GetLength(key_array); i++) { UUtUns32 flag; void *element; - + error = GRrGroup_Array_GetElement(key_array, i, &element_type, &element); - IMPmError_ReturnOnErrorMsg(error, "unable to get element from key array"); - + IMPmError_ReturnOnErrorMsg(error, "unable to get element from key array"); + error = AUrFlags_ParseFromGroupArray( IMPgMoveKeys, @@ -918,10 +918,10 @@ Imp_AddDiaryPage( element, &flag); IMPmError_ReturnOnErrorMsg(error, "Unable to process keys"); - + keys[i] = (ONtKey)flag; } - + // get the string list string_list = IGUIiStringList_Get(inSourceFile); if (string_list == NULL) @@ -929,10 +929,10 @@ Imp_AddDiaryPage( Imp_PrintWarning("Unable to get the string list for the Diary Page"); return UUcError_None; } - + // get the IGUI page page = Imp_IGUI_Page(inSourceFile, inGroup, string_list); - + // create the DiaryPage instance error = TMrConstruction_Instance_Renew( @@ -944,16 +944,16 @@ Imp_AddDiaryPage( { IGUIiStringList_Delete(string_list); string_list = NULL; - + IMPmError_ReturnOnErrorMsg(error, "Unable to create diary page instance"); } - + // fill in the elements of the diary_page diary_page->level_number = level_number; diary_page->page_number = page_number; diary_page->has_new_move = has_new_move; diary_page->page = page; - + for (i = 0; i < ONcMaxNumKeys; i++) { diary_page->keys[i] = keys[i]; @@ -962,7 +962,7 @@ Imp_AddDiaryPage( IGUIiStringList_Delete(string_list); string_list = NULL; } - + return UUcError_None; } @@ -977,16 +977,16 @@ Imp_AddHelpPage( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(ONcTemplate_HelpPage, inInstanceName); - + if (build_instance) { ONtHelpPage *help_page; ONtIGUI_StringList *string_list; - + // get the strings string_list = IGUIiStringList_Get(inSourceFile); if (string_list == NULL) @@ -1003,11 +1003,11 @@ Imp_AddHelpPage( 0, &help_page); IMPmError_ReturnOnErrorMsg(error, "unable to create the help page"); - + // create the text page help_page->page = Imp_IGUI_Page(inSourceFile, inGroup, string_list); } - + return UUcError_None; } @@ -1022,7 +1022,7 @@ Imp_AddItemPage( UUtError error; UUtBool build_instance; - + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(ONcTemplate_ItemPage, inInstanceName); @@ -1032,7 +1032,7 @@ Imp_AddItemPage( UUtUns32 powerup_type; ONtItemPage *item_page; ONtIGUI_StringList *string_list; - + // get the strings string_list = IGUIiStringList_Get(inSourceFile); if (string_list == NULL) @@ -1044,7 +1044,7 @@ Imp_AddItemPage( // get the type error = GRrGroup_GetString(inGroup, "type", &type); IMPmError_ReturnOnErrorMsg(error, "unable to get the item page type"); - + error = AUrFlags_ParseFromGroupArray( IMPgPowerupTypes, @@ -1052,7 +1052,7 @@ Imp_AddItemPage( type, &powerup_type); IMPmError_ReturnOnErrorMsg(error, "Unable to process keys"); - + // create the template instance error = TMrConstruction_Instance_Renew( @@ -1061,12 +1061,12 @@ Imp_AddItemPage( 0, &item_page); IMPmError_ReturnOnErrorMsg(error, "Unable to create item page instance"); - + // set the data item_page->powerup_type = (WPtPowerupType)powerup_type; item_page->page = Imp_IGUI_Page(inSourceFile, inGroup, string_list); } - + return UUcError_None; } @@ -1081,18 +1081,18 @@ Imp_AddObjectivePage( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(ONcTemplate_ObjectivePage, inInstanceName); - + if (build_instance) { UUtInt16 level_number; ONtObjectivePage *objective_page; ONtIGUI_PageArray *objective_page_array; ONtIGUI_StringList *string_list; - + // get the strings string_list = IGUIiStringList_Get(inSourceFile); if (string_list == NULL) @@ -1104,7 +1104,7 @@ Imp_AddObjectivePage( // get the level number error = GRrGroup_GetInt16(inGroup, "level_number", &level_number); IMPmError_ReturnOnErrorMsg(error, "Unable to get the level number"); - + objective_page_array = Imp_IGUI_PageArray(inSourceFile, inGroup, "objective_array", string_list); if (objective_page_array == NULL) { @@ -1119,11 +1119,11 @@ Imp_AddObjectivePage( 0, &objective_page); IMPmError_ReturnOnErrorMsg(error, "Unable to create objective page instance"); - + objective_page->level_number = level_number; objective_page->objectives = objective_page_array; } - + return UUcError_None; } @@ -1138,17 +1138,17 @@ Imp_AddWeaponPage( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(ONcTemplate_WeaponPage, inInstanceName); - + if (build_instance) { char *weapon_class; ONtWeaponPage *weapon_page; ONtIGUI_StringList *string_list; - + // get the strings string_list = IGUIiStringList_Get(inSourceFile); if (string_list == NULL) @@ -1160,7 +1160,7 @@ Imp_AddWeaponPage( // get the weapon class error = GRrGroup_GetString(inGroup, "weaponClass", &weapon_class); IMPmError_ReturnOnErrorMsg(error, "unable to get weapon class"); - + // create the weapon page template instance error = TMrConstruction_Instance_Renew( @@ -1169,7 +1169,7 @@ Imp_AddWeaponPage( 0, &weapon_page); IMPmError_ReturnOnErrorMsg(error, "unable to create the weapon page"); - + // save a placeholder to the weapon class error = TMrConstruction_Instance_GetPlaceHolder( @@ -1177,11 +1177,11 @@ Imp_AddWeaponPage( weapon_class, (TMtPlaceHolder*)&(weapon_page->weaponClass)); UUmError_ReturnOnErrorMsg(error, "could not set weapon page's weapon class"); - + // create the text page weapon_page->page = Imp_IGUI_Page(inSourceFile, inGroup, string_list); } - + return UUcError_None; } @@ -1198,10 +1198,10 @@ Imp_AddEnemyScannerUI( UUtBool bool_result; UUtBool build_instance; - + UUtUns32 create_date; UUtUns32 compile_date; - + // check to see if the dialogs need to be built bool_result = TMrConstruction_Instance_CheckExists( @@ -1211,7 +1211,7 @@ Imp_AddEnemyScannerUI( if (bool_result) { compile_date = UUrConvertStrToSecsSince1900(gInGameUICompileTime); - + build_instance = (UUtBool)(create_date < inSourceFileModDate || create_date < compile_date); } @@ -1219,7 +1219,7 @@ Imp_AddEnemyScannerUI( { build_instance = UUcTrue; } - + if (build_instance) { char *focus_texture_path; @@ -1227,21 +1227,21 @@ Imp_AddEnemyScannerUI( TMtPlaceHolder focus_texture; TMtPlaceHolder background_texture; ONtEnemyScannerUI *enemy_scanner_ui; - + // get a pointer to all of the textures error = GRrGroup_GetString(inGroup, "focus_texture", &focus_texture_path); IMPmError_ReturnOnErrorMsg(error, "Unable to get path for focus texture"); - + error = GRrGroup_GetString(inGroup, "background_texture", &background_texture_path); IMPmError_ReturnOnErrorMsg(error, "Unable to get path for backgrouind texture"); - + // create placeholders for the textures error = iGetTextureByPath(focus_texture_path, inSourceFile, &focus_texture); IMPmError_ReturnOnErrorMsg(error, "unable to process the focus texture"); - + error = iGetTextureBigByPath(background_texture_path, inSourceFile, &background_texture); IMPmError_ReturnOnErrorMsg(error, "unable to process the background texture"); - + // create an instance of the enemy scanner ui error = TMrConstruction_Instance_Renew( @@ -1250,13 +1250,13 @@ Imp_AddEnemyScannerUI( 0, &enemy_scanner_ui); IMPmError_ReturnOnErrorMsg(error, "Unable to create enemy scanner ui"); - + // save the pointers enemy_scanner_ui->focus = (M3tTextureMap*)focus_texture; enemy_scanner_ui->background = (M3tTextureMap_Big*)background_texture; } #endif - + return UUcError_None; } @@ -1271,118 +1271,118 @@ Imp_AddKeyIcons( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(ONcTemplate_KeyIcons, inInstanceName); - + if (build_instance) { char *path; TMtPlaceHolder place_holder; ONtKeyIcons *key_icons; - + // build the key icons - error = + error = TMrConstruction_Instance_Renew( ONcTemplate_KeyIcons, inInstanceName, 0, &key_icons); IMPmError_ReturnOnErrorMsg(error,"Unable to create the key icons instance"); - + // load the icons // ------------------------------ error = GRrGroup_GetString(inGroup, "punch", &path); IMPmError_ReturnOnErrorMsg(error, "Unable to get path"); - + error = iGetTextureByPath(path, inSourceFile, &place_holder); IMPmError_ReturnOnErrorMsg(error, "unable to texture place holder"); - + key_icons->punch = (M3tTextureMap*)place_holder; // ------------------------------ error = GRrGroup_GetString(inGroup, "kick", &path); IMPmError_ReturnOnErrorMsg(error, "Unable to get path"); - + error = iGetTextureByPath(path, inSourceFile, &place_holder); IMPmError_ReturnOnErrorMsg(error, "unable to texture place holder"); - + key_icons->kick = (M3tTextureMap*)place_holder; // ------------------------------ error = GRrGroup_GetString(inGroup, "forward", &path); IMPmError_ReturnOnErrorMsg(error, "Unable to get path"); - + error = iGetTextureByPath(path, inSourceFile, &place_holder); IMPmError_ReturnOnErrorMsg(error, "unable to texture place holder"); - + key_icons->forward = (M3tTextureMap*)place_holder; // ------------------------------ error = GRrGroup_GetString(inGroup, "backward", &path); IMPmError_ReturnOnErrorMsg(error, "Unable to get path"); - + error = iGetTextureByPath(path, inSourceFile, &place_holder); IMPmError_ReturnOnErrorMsg(error, "unable to texture place holder"); - + key_icons->backward = (M3tTextureMap*)place_holder; // ------------------------------ error = GRrGroup_GetString(inGroup, "left", &path); IMPmError_ReturnOnErrorMsg(error, "Unable to get path"); - + error = iGetTextureByPath(path, inSourceFile, &place_holder); IMPmError_ReturnOnErrorMsg(error, "unable to texture place holder"); - + key_icons->left = (M3tTextureMap*)place_holder; // ------------------------------ error = GRrGroup_GetString(inGroup, "right", &path); IMPmError_ReturnOnErrorMsg(error, "Unable to get path"); - + error = iGetTextureByPath(path, inSourceFile, &place_holder); IMPmError_ReturnOnErrorMsg(error, "unable to texture place holder"); - + key_icons->right = (M3tTextureMap*)place_holder; // ------------------------------ error = GRrGroup_GetString(inGroup, "crouch", &path); IMPmError_ReturnOnErrorMsg(error, "Unable to get path"); - + error = iGetTextureByPath(path, inSourceFile, &place_holder); IMPmError_ReturnOnErrorMsg(error, "unable to texture place holder"); - + key_icons->crouch = (M3tTextureMap*)place_holder; // ------------------------------ error = GRrGroup_GetString(inGroup, "jump", &path); IMPmError_ReturnOnErrorMsg(error, "Unable to get path"); - + error = iGetTextureByPath(path, inSourceFile, &place_holder); IMPmError_ReturnOnErrorMsg(error, "unable to texture place holder"); - + key_icons->jump = (M3tTextureMap*)place_holder; // ------------------------------ error = GRrGroup_GetString(inGroup, "hold", &path); IMPmError_ReturnOnErrorMsg(error, "Unable to get path"); - + error = iGetTextureByPath(path, inSourceFile, &place_holder); IMPmError_ReturnOnErrorMsg(error, "unable to texture place holder"); - + key_icons->hold = (M3tTextureMap*)place_holder; // ------------------------------ error = GRrGroup_GetString(inGroup, "plus", &path); IMPmError_ReturnOnErrorMsg(error, "Unable to get path"); - + error = iGetTextureByPath(path, inSourceFile, &place_holder); IMPmError_ReturnOnErrorMsg(error, "unable to texture place holder"); - + key_icons->plus = (M3tTextureMap*)place_holder; } - + return UUcError_None; } @@ -1395,10 +1395,10 @@ Imp_AddTextConsole( char* inInstanceName) { UUtError error; - + UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(ONcTemplate_TextConsole, inInstanceName); @@ -1407,7 +1407,7 @@ Imp_AddTextConsole( ONtIGUI_StringList *string_list; ONtIGUI_PageArray *console_data; ONtTextConsole *text_console; - + // get the strings string_list = IGUIiStringList_Get(inSourceFile); if (string_list == NULL) @@ -1415,21 +1415,21 @@ Imp_AddTextConsole( Imp_PrintWarning("Unable to get the string list for the text console"); return UUcError_None; } - + // get the console_data console_data = Imp_IGUI_PageArray(inSourceFile, inGroup, "text", string_list); if (console_data == NULL) { IGUIiStringList_Delete(string_list); string_list = NULL; - + Imp_PrintWarning("Unable to get the text for the text console"); return UUcError_None; } - + IGUIiStringList_Delete(string_list); string_list = NULL; - + // create the text console instance error = TMrConstruction_Instance_Renew( @@ -1438,11 +1438,11 @@ Imp_AddTextConsole( 0, &text_console); IMPmError_ReturnOnErrorMsg(error, "Unable to create the text console instance"); - + // set the console_data of the text_console text_console->console_data = console_data; } - + return UUcError_None; } @@ -1457,10 +1457,10 @@ Imp_AddHUDHelp( UUtError error; UUtBool build_instance; - + // check to see if the instance needs to be built build_instance = !TMrConstruction_Instance_CheckExists(ONcTemplate_IGUI_HUDHelp, inInstanceName); - + if (build_instance) { char *leftTexture; @@ -1476,7 +1476,7 @@ Imp_AddHUDHelp( ONtIGUI_HUDTextItem *item_array; char *text_line, *stringptr, *string_end; ONtIGUI_HUDHelp *help_instance; - + // get the textures error = GRrGroup_GetString(inGroup, "left_texture", &leftTexture); IMPmError_ReturnOnErrorMsg(error, "unable to get left texture"); @@ -1487,7 +1487,7 @@ Imp_AddHUDHelp( // get the offsets error = GRrGroup_GetInt16(inGroup, "left_offset_x", &leftOffset.x); IMPmError_ReturnOnErrorMsg(error, "unable to get left x offset"); - + error = GRrGroup_GetInt16(inGroup, "left_offset_y", &leftOffset.y); IMPmError_ReturnOnErrorMsg(error, "unable to get left y offset"); @@ -1576,7 +1576,7 @@ Imp_AddHUDHelp( left_items + right_items, &help_instance); IMPmError_ReturnOnErrorMsg(error, "Unable to create HUD help info instance"); - + // fill in the elements of the help_instance error = TMrConstruction_Instance_GetPlaceHolder(M3cTemplate_TextureMap, leftTexture, (TMtPlaceHolder *) &help_instance->left_texture); IMPmError_ReturnOnErrorMsg(error, "Unable to get left-texture placeholder"); @@ -1592,7 +1592,7 @@ Imp_AddHUDHelp( UUrMemory_MoveFast(left_itemarray, &help_instance->text_items[0], left_items * sizeof(ONtIGUI_HUDTextItem)); UUrMemory_MoveFast(right_itemarray, &help_instance->text_items[left_items], right_items * sizeof(ONtIGUI_HUDTextItem)); } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_InGameUI.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_InGameUI.h index 4056ac6..969ac2f 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_InGameUI.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_InGameUI.h @@ -27,7 +27,7 @@ Imp_AddHelpPage( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + UUtError Imp_AddItemPage( BFtFileRef* inSourceFile, @@ -56,7 +56,7 @@ Imp_AddEnemyScannerUI( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + // ---------------------------------------------------------------------- UUtError Imp_AddKeyIcons( @@ -64,7 +64,7 @@ Imp_AddKeyIcons( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + // ---------------------------------------------------------------------- UUtError Imp_AddTextConsole( @@ -72,7 +72,7 @@ Imp_AddTextConsole( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + // ---------------------------------------------------------------------- UUtError Imp_AddHUDHelp( @@ -82,4 +82,4 @@ Imp_AddHUDHelp( char* inInstanceName); // ====================================================================== -#endif /* IMP_INGAMEUI_H */ \ No newline at end of file +#endif /* IMP_INGAMEUI_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Input.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Input.h index 29128ab..deef93e 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Input.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Input.h @@ -1,12 +1,12 @@ /* FILE: Imp_Input.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 3, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Material.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Material.c index ab123e4..36956f3 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Material.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Material.c @@ -36,20 +36,20 @@ Imp_AddMaterial( UUtError error; UUtBool build_instance; - - + + // check to see if the material needs to be built build_instance = !TMrConstruction_Instance_CheckExists(MAcTemplate_Material, inInstanceName); - + if (build_instance) { char *parent_name; MAtMaterial *material; - + // get the name of the parent error = GRrGroup_GetString(inGroup, "parent", &parent_name); IMPmError_ReturnOnErrorMsg(error, "Unable to get parent name"); - + // build an instance of the material error = TMrConstruction_Instance_Renew( @@ -58,7 +58,7 @@ Imp_AddMaterial( 0, &material); IMPmError_ReturnOnErrorMsg(error, "Unable to create material instance"); - + // the real id will be set at runtime material->id = MAcInvalidID; @@ -89,7 +89,7 @@ Imp_AddMaterial( } } } - + return UUcError_None; } @@ -104,20 +104,20 @@ Imp_AddImpact( UUtError error; UUtBool build_instance; - - + + // check to see if the impact needs to be built build_instance = !TMrConstruction_Instance_CheckExists(MAcTemplate_Impact, inInstanceName); - + if (build_instance) { char *parent_name; MAtImpact *impact; - + // get the name of the parent error = GRrGroup_GetString(inGroup, "parent", &parent_name); IMPmError_ReturnOnErrorMsg(error, "Unable to get parent name"); - + // build an instance of the impact error = TMrConstruction_Instance_Renew( @@ -126,7 +126,7 @@ Imp_AddImpact( 0, &impact); IMPmError_ReturnOnErrorMsg(error, "Unable to create impact instance"); - + // the real id will be set at runtime impact->id = MAcInvalidID; @@ -157,7 +157,7 @@ Imp_AddImpact( } } } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Material.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Material.h index 6e887f5..b0c2f82 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Material.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Material.h @@ -36,4 +36,4 @@ Imp_AddMaterialList( char *inInstanceName); // ====================================================================== -#endif /* IMP_MATERIAL_H */ \ No newline at end of file +#endif /* IMP_MATERIAL_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_MenuStuff.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_MenuStuff.c index be1b37a..888056d 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_MenuStuff.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_MenuStuff.c @@ -44,11 +44,11 @@ Imp_AddMenu( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(WMcTemplate_MenuData, inInstanceName); - + if (build_instance) { GRtElementType element_type; @@ -57,7 +57,7 @@ Imp_AddMenu( UUtUns32 i; char *menu_title; WMtMenuData *menu; - + // get the items array error = GRrGroup_GetElement( @@ -69,14 +69,14 @@ Imp_AddMenu( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get items array"); } - + // get the number of elements in the items array num_elements = GRrGroup_Array_GetLength(items_array); if (num_elements == 0) { return UUcError_None; } - + // create an instance of the menu template error = TMrConstruction_Instance_Renew( @@ -85,7 +85,7 @@ Imp_AddMenu( num_elements, &menu); IMPmError_ReturnOnError(error); - + // get the menu id error = GRrGroup_GetUns16( @@ -93,7 +93,7 @@ Imp_AddMenu( "id", &menu->id); IMPmError_ReturnOnError(error); - + // get the menu title error = GRrGroup_GetString( @@ -101,9 +101,9 @@ Imp_AddMenu( "title", &menu_title); IMPmError_ReturnOnError(error); - + UUrString_Copy(menu->title, menu_title, WMcMaxTitleLength); - + // process the items of the items array for (i = 0; i < num_elements; i++) { @@ -111,7 +111,7 @@ Imp_AddMenu( char *item_title; UUtUns32 item_flags; GRtElementArray *item_flags_array; - + // get the item group error = GRrGroup_Array_GetElement( @@ -123,7 +123,7 @@ Imp_AddMenu( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get item group"); } - + // get the item title from the item group error = GRrGroup_GetString( @@ -131,16 +131,16 @@ Imp_AddMenu( "title", &item_title); IMPmError_ReturnOnError(error); - + UUrString_Copy(menu->items[i].title, item_title, WMcMaxTitleLength); - + // get the item id from the item group error = GRrGroup_GetUns16( item_group, "id", &menu->items[i].id); - + // get the item flags array from the item group error = GRrGroup_GetElement( @@ -152,7 +152,7 @@ Imp_AddMenu( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get flags array"); } - + // process the item flags array error = AUrFlags_ParseFromGroupArray( @@ -161,7 +161,7 @@ Imp_AddMenu( item_flags_array, &item_flags); IMPmError_ReturnOnErrorMsg(error, "Unable to process button flags"); - + menu->items[i].flags = (UUtUns16)item_flags; } } @@ -180,11 +180,11 @@ Imp_AddMenuBar( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(WMcTemplate_MenuBarData, inInstanceName); - + if (build_instance) { GRtElementArray *menus_array; @@ -192,7 +192,7 @@ Imp_AddMenuBar( UUtUns32 i; GRtElementType element_type; WMtMenuBarData *menubar; - + // get the menus array error = GRrGroup_GetElement( @@ -204,14 +204,14 @@ Imp_AddMenuBar( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get menus array"); } - + // get the number of elements in the menus array num_elements = GRrGroup_Array_GetLength(menus_array); if (num_elements == 0) { return UUcError_None; } - + // create an instance of a menubar template error = TMrConstruction_Instance_Renew( @@ -220,7 +220,7 @@ Imp_AddMenuBar( num_elements, &menubar); IMPmError_ReturnOnError(error); - + // get the item id of the menubar error = GRrGroup_GetUns16( @@ -228,13 +228,13 @@ Imp_AddMenuBar( "id", &menubar->id); IMPmError_ReturnOnErrorMsg(error, "Unable to get the id of the menubar"); - + // process the elements in the menus array for (i = 0; i < num_elements; i++) { char *menu_name; TMtPlaceHolder menu_ref; - + // get an item from the menus_array error = GRrGroup_Array_GetElement( @@ -246,15 +246,15 @@ Imp_AddMenuBar( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get menu name from array"); } - + // get a placeholder for the item - error = + error = TMrConstruction_Instance_GetPlaceHolder( WMcTemplate_MenuData, menu_name, &menu_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get menu placeholder"); - + menubar->menus[i] = (WMtMenuData*)menu_ref; } } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_MenuStuff.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_MenuStuff.h index d0f3ede..24626bb 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_MenuStuff.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_MenuStuff.h @@ -27,4 +27,4 @@ Imp_AddMenuBar( char* inInstanceName); // ====================================================================== -#endif /* IMP_MENUSTUFF_H */ \ No newline at end of file +#endif /* IMP_MENUSTUFF_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Model.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Model.c index ec6569e..653731a 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Model.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Model.c @@ -6,7 +6,7 @@ CREATED: August 14, 1997 PURPOSE: Loads models into the game - + Copyright 1997, 1998 */ @@ -44,7 +44,7 @@ typedef struct IMPtModel_Tri UUtUns32 triIndex; UUtUns32 sharedPrevEdge; UUtUns32 sharedNextEdge; - + } IMPtModel_Tri; AUtSharedEdgeArray* IMPgModel_TriEdgeArray = NULL; @@ -81,7 +81,7 @@ IMPiModel_FindOtherVertexIndex( { UUtUns32 itr; UUtUns32 bv = 0; - + for(itr = 0; itr < 3; itr++) { if(inTri->indices[itr] == inEdge->vIndex0 || inTri->indices[itr] == inEdge->vIndex1) @@ -89,13 +89,13 @@ IMPiModel_FindOtherVertexIndex( bv |= 1 << itr; } } - + if(bv == 3) return inTri->indices[2]; else if(bv == 5) return inTri->indices[1]; else if(bv == 6) return inTri->indices[0]; - + UUmAssert(0); - + return 0; } @@ -109,40 +109,40 @@ IMPiStripify_BuildOneStrip_ForReal( UUtUns32 itr; M3tTri* curTri; UUtUns32 otherVertexIndex; - + index0 = IMPgModel_ActiveStripIndices[1]; index1 = IMPgModel_ActiveStripIndices[2]; - - // find the initial sharedEdge + + // find the initial sharedEdge sharedEdge = AUrSharedEdge_Triangle_FindEdge(IMPgModel_TriEdgeArray, IMPgModel_TriEdgeList + inTriIndex, index0, index1); UUmAssert(sharedEdge != NULL); - + while(1) { if(IMPgModel_ActiveStrip_Length >= IMPcModel_MaxStripLength) UUmError_ReturnOnErrorMsg(UUcError_Generic, "Out of strip mem"); - + // record the curTri UUrBitVector_SetBit(IMPgModel_TriUsedBV, curTriIndex); IMPgModel_ActiveTriIndices[IMPgModel_ActiveStrip_Length - 3] = curTriIndex; - + // try to move into the next tri curTriIndex = (UUtUns16)AUrSharedEdge_GetOtherFaceIndex(sharedEdge, curTriIndex); if(curTriIndex == UUcMaxUns16 || UUrBitVector_TestBit(IMPgModel_TriUsedBV, curTriIndex)) break; - + curTri = IMPgModel_TriList + curTriIndex; - + // find the vertex to add otherVertexIndex = IMPiModel_FindOtherVertexIndex(curTri, sharedEdge); - + IMPgModel_ActiveStripIndices[IMPgModel_ActiveStrip_Length++] = otherVertexIndex; - + // find the new shared edge sharedEdge = AUrSharedEdge_Triangle_FindEdge(IMPgModel_TriEdgeArray, IMPgModel_TriEdgeList + curTriIndex, index1, otherVertexIndex); UUmAssert(sharedEdge != NULL); - + index1 = otherVertexIndex; } - + // if this is the longest strip so far then save it if(IMPgModel_ActiveStrip_Length > IMPgModel_Strip_Length) { @@ -150,13 +150,13 @@ IMPiStripify_BuildOneStrip_ForReal( UUrMemory_MoveFast(IMPgModel_ActiveStripIndices, IMPgModel_StripIndices, IMPgModel_ActiveStrip_Length * sizeof(UUtUns32)); UUrMemory_MoveFast(IMPgModel_ActiveTriIndices, IMPgModel_TriIndices, (IMPgModel_ActiveStrip_Length - 2) * sizeof(UUtUns32)); } - + // undo all the set bits for(itr = 0; itr < IMPgModel_ActiveStrip_Length - 2; itr++) { UUrBitVector_ClearBit(IMPgModel_TriUsedBV, IMPgModel_ActiveTriIndices[itr]); } - + return UUcError_None; } @@ -168,9 +168,9 @@ IMPiStripify_BuildOneStrip( UUtUns16 itrTri; M3tTri* curTri; UUtBool done = UUcTrue; - + IMPgModel_Strip_Length = 0; - + for(itrTri = 0; itrTri < IMPgModel_NumTris; itrTri++) { // only consider tris that are not taken @@ -178,31 +178,31 @@ IMPiStripify_BuildOneStrip( { done = UUcFalse; curTri = IMPgModel_TriList + itrTri; - + IMPgModel_ActiveStrip_Length = 3; IMPgModel_ActiveStripIndices[0] = curTri->indices[0]; IMPgModel_ActiveStripIndices[1] = curTri->indices[1]; IMPgModel_ActiveStripIndices[2] = curTri->indices[2]; error = IMPiStripify_BuildOneStrip_ForReal(itrTri); UUmError_ReturnOnError(error); - + IMPgModel_ActiveStrip_Length = 3; IMPgModel_ActiveStripIndices[0] = curTri->indices[1]; IMPgModel_ActiveStripIndices[1] = curTri->indices[2]; IMPgModel_ActiveStripIndices[2] = curTri->indices[0]; error = IMPiStripify_BuildOneStrip_ForReal(itrTri); UUmError_ReturnOnError(error); - + IMPgModel_ActiveStrip_Length = 3; IMPgModel_ActiveStripIndices[0] = curTri->indices[2]; IMPgModel_ActiveStripIndices[1] = curTri->indices[0]; IMPgModel_ActiveStripIndices[2] = curTri->indices[1]; error = IMPiStripify_BuildOneStrip_ForReal(itrTri); UUmError_ReturnOnError(error); - + } } - + if(!done) { for(itrTri = 0; itrTri < IMPgModel_Strip_Length - 2; itrTri++) @@ -210,9 +210,9 @@ IMPiStripify_BuildOneStrip( UUrBitVector_SetBit(IMPgModel_TriUsedBV, IMPgModel_TriIndices[itrTri]); } } - + *outDone = done; - + return UUcError_None; } @@ -222,43 +222,43 @@ IMPiStripify_BuildStrips_Longest( { UUtError error; UUtBool done; - + UUrBitVector_ClearBitAll(IMPgModel_TriUsedBV, IMPgModel_NumTris); - + IMPgModel_VertexFinalListLength = 0; IMPgModel_TriFinalListLength = 0; - + while(1) { IMPgModel_Strip_Length = 0; error = IMPiStripify_BuildOneStrip(&done); UUmError_ReturnOnError(error); - + if(done) break; - + if(IMPgModel_VertexFinalListLength >= IMPcModel_MaxTris) UUmError_ReturnOnErrorMsg(UUcError_Generic, "out of strip final mem"); - + // copy the current list into the final list UUrMemory_MoveFast( IMPgModel_TriIndices, IMPgModel_TriFinalList + IMPgModel_TriFinalListLength, (IMPgModel_Strip_Length - 2) * sizeof(UUtUns32)); - + IMPgModel_TriFinalListLength += IMPgModel_Strip_Length - 2; - + UUrMemory_MoveFast( IMPgModel_StripIndices, IMPgModel_VertexFinalList + IMPgModel_VertexFinalListLength, IMPgModel_Strip_Length * sizeof(UUtUns32)); - + IMPgModel_VertexFinalList[IMPgModel_VertexFinalListLength] |= 0x80000000; // signel the beggining of a strip - + IMPgModel_VertexFinalListLength += IMPgModel_Strip_Length; - + gTotal_StripDist[IMPgModel_Strip_Length]++; gTotal_NumStrips++; } - + return UUcError_None; } @@ -272,7 +272,7 @@ IMPiModel_Stripify( M3tTri* curTri; M3tTri* curTriLarge; UUtUns32 tempList[4]; - + AUrSharedEdgeArray_Reset(IMPgModel_TriEdgeArray); // compute the edge list @@ -283,8 +283,8 @@ IMPiModel_Stripify( tempList[0] = curTri->indices[0]; tempList[1] = curTri->indices[1]; tempList[2] = curTri->indices[2]; - - error = + + error = AUrSharedEdgeArray_AddPoly( IMPgModel_TriEdgeArray, 3, @@ -293,15 +293,15 @@ IMPiModel_Stripify( curTriLarge->indices); UUmError_ReturnOnError(error); } - + IMPgModel_EdgeList = AUrSharedEdgeArray_GetList(IMPgModel_TriEdgeArray); IMPgModel_TriNumEdges = (UUtUns16)AUrSharedEdgeArray_GetNum(IMPgModel_TriEdgeArray); - + // build the list - error = + error = IMPiStripify_BuildStrips_Longest(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -313,11 +313,11 @@ IMPiModel_Process_Points( { UUtError error; UUtUns16 i; - + M3tVector3DArray* vertexNormalArray; M3tTextureCoordArray* textureCoordArray; - M3tPoint3DArray* pointArray; - + M3tPoint3DArray* pointArray; + M3tBoundingBox_MinMax minMax; float centerX; float centerY; @@ -330,28 +330,28 @@ IMPiModel_Process_Points( inNode->numPoints, &inGeometry->pointArray); IMPmError_ReturnOnError(error); - + pointArray = inGeometry->pointArray; - + error = TMrConstruction_Instance_NewUnique( M3cTemplate_Vector3DArray, inNode->numPoints, &inGeometry->vertexNormalArray); IMPmError_ReturnOnError(error); - + vertexNormalArray = inGeometry->vertexNormalArray; - + error = TMrConstruction_Instance_NewUnique( M3cTemplate_TextureCoordArray, inNode->numPoints + M3cExtraCoords, &inGeometry->texCoordArray); IMPmError_ReturnOnError(error); - + textureCoordArray = inGeometry->texCoordArray; textureCoordArray->numTextureCoords = inNode->numPoints; - + minMax.minPoint.x = minMax.minPoint.y = minMax.minPoint.z = 1e13f; minMax.maxPoint.x = minMax.maxPoint.y = minMax.maxPoint.z = -1e13f; @@ -369,12 +369,12 @@ IMPiModel_Process_Points( minMax.minPoint.x = UUmMin(curX, minMax.minPoint.x); minMax.minPoint.y = UUmMin(curY, minMax.minPoint.y); minMax.minPoint.z = UUmMin(curZ, minMax.minPoint.z); - + minMax.maxPoint.x = UUmMax(curX, minMax.maxPoint.x); minMax.maxPoint.y = UUmMax(curY, minMax.maxPoint.y); minMax.maxPoint.z = UUmMax(curZ, minMax.maxPoint.z); } - + pointArray->minmax_boundingBox = minMax; centerX = (minMax.minPoint.x + minMax.maxPoint.x) / 2.f; @@ -385,7 +385,7 @@ IMPiModel_Process_Points( pointArray->boundingSphere.center.y = centerY; pointArray->boundingSphere.center.z = centerZ; - pointArray->boundingSphere.radius = + pointArray->boundingSphere.radius = MUrPoint_Distance(&pointArray->minmax_boundingBox.minPoint,&pointArray->boundingSphere.center); UUmAssert(pointArray->boundingSphere.radius < 10000.0f); @@ -403,36 +403,36 @@ IMPiModel_Process_MaterialPoints( UUtError error; UUtUns16 i; UUtUns16 j; - + UUtUns32 num_points; UUtUns16 index; UUtUns16 point_index; - + M3tVector3DArray* vertexNormalArray; M3tTextureCoordArray* textureCoordArray; - M3tPoint3DArray* pointArray; - + M3tPoint3DArray* pointArray; + M3tBoundingBox_MinMax minMax; float centerX; float centerY; float centerZ; float curX, curY, curZ; - + UUtUns32 *bitvector; - + // calculate the number of points associated with the material num_points = 0; bitvector = UUrBitVector_New(inNode->numPoints); UUrBitVector_ClearBitAll(bitvector, inNode->numPoints); - + for (i = 0; i < inNode->numTriangles; i++) { if (inNode->triangles[i].material != inMaterialIndex) { continue; } - + for (j = 0; j < 3; j++) { index = inNode->triangles[i].indices[j]; - + if (UUrBitVector_TestBit(bitvector, index) == UUcFalse) { UUrBitVector_SetBit(bitvector, index); @@ -440,15 +440,15 @@ IMPiModel_Process_MaterialPoints( } } } - + for (i = 0; i < inNode->numQuads; i++) { if (inNode->quads[i].material != inMaterialIndex) { continue; } - + for (j = 0; j < 4; j++) { index = inNode->quads[i].indices[j]; - + if (UUrBitVector_TestBit(bitvector, index) == UUcFalse) { UUrBitVector_SetBit(bitvector, index); @@ -456,7 +456,7 @@ IMPiModel_Process_MaterialPoints( } } } - + // create the template instances error = TMrConstruction_Instance_NewUnique( @@ -464,32 +464,32 @@ IMPiModel_Process_MaterialPoints( num_points, &ioGeometry->pointArray); IMPmError_ReturnOnError(error); - + pointArray = ioGeometry->pointArray; - + error = TMrConstruction_Instance_NewUnique( M3cTemplate_Vector3DArray, num_points, &ioGeometry->vertexNormalArray); IMPmError_ReturnOnError(error); - + vertexNormalArray = ioGeometry->vertexNormalArray; - + error = TMrConstruction_Instance_NewUnique( M3cTemplate_TextureCoordArray, num_points + M3cExtraCoords, &ioGeometry->texCoordArray); IMPmError_ReturnOnError(error); - + textureCoordArray = ioGeometry->texCoordArray; textureCoordArray->numTextureCoords = (UUtUns16)num_points; - + // initialize minMax minMax.minPoint.x = minMax.minPoint.y = minMax.minPoint.z = 1e13f; minMax.maxPoint.x = minMax.maxPoint.y = minMax.maxPoint.z = -1e13f; - + index = 0; UUrBitVector_ClearBitAll(bitvector, inNode->numPoints); @@ -498,7 +498,7 @@ IMPiModel_Process_MaterialPoints( { // if this triangle isn't associated with the material, skip it if (inNode->triangles[i].material != inMaterialIndex) { continue; } - + // process the points in the triangle for (j = 0; j < 3; j++) { @@ -507,36 +507,36 @@ IMPiModel_Process_MaterialPoints( if (UUrBitVector_TestBit(bitvector, point_index) == UUcTrue) { continue; } UUrBitVector_SetBit(bitvector, point_index); ioFromTo[point_index] = index; - + // copy the point, normal, and texture coordinates pointArray->points[index] = inNode->points[point_index].point; vertexNormalArray->vectors[index] = inNode->points[point_index].normal; textureCoordArray->textureCoords[index] = inNode->points[point_index].uv; - + // adjust the min max points curX = inNode->points[point_index].point.x; curY = inNode->points[point_index].point.y; curZ = inNode->points[point_index].point.z; - + minMax.minPoint.x = UUmMin(curX, minMax.minPoint.x); minMax.minPoint.y = UUmMin(curY, minMax.minPoint.y); minMax.minPoint.z = UUmMin(curZ, minMax.minPoint.z); - + minMax.maxPoint.x = UUmMax(curX, minMax.maxPoint.x); minMax.maxPoint.y = UUmMax(curY, minMax.maxPoint.y); minMax.maxPoint.z = UUmMax(curZ, minMax.maxPoint.z); - + // go to next index index++; } } - + // put all the vertices associated with the quads into the array for (i = 0; i < inNode->numQuads; i++) { // if this quad isn't associated with the material, skip it if (inNode->quads[i].material != inMaterialIndex) { continue; } - + // process the points in the quad for (j = 0; j < 4; j++) { @@ -545,52 +545,52 @@ IMPiModel_Process_MaterialPoints( if (UUrBitVector_TestBit(bitvector, point_index) == UUcTrue) { continue; } UUrBitVector_SetBit(bitvector, point_index); ioFromTo[point_index] = index; - + // copy the point, normal, and texture coordinates pointArray->points[index] = inNode->points[point_index].point; vertexNormalArray->vectors[index] = inNode->points[point_index].normal; textureCoordArray->textureCoords[index] = inNode->points[point_index].uv; - + // adjust the min max points curX = inNode->points[point_index].point.x; curY = inNode->points[point_index].point.y; curZ = inNode->points[point_index].point.z; - + minMax.minPoint.x = UUmMin(curX, minMax.minPoint.x); minMax.minPoint.y = UUmMin(curY, minMax.minPoint.y); minMax.minPoint.z = UUmMin(curZ, minMax.minPoint.z); - + minMax.maxPoint.x = UUmMax(curX, minMax.maxPoint.x); minMax.maxPoint.y = UUmMax(curY, minMax.maxPoint.y); minMax.maxPoint.z = UUmMax(curZ, minMax.maxPoint.z); - + // go to next index index++; } } - + // save the min max bounding box pointArray->minmax_boundingBox = minMax; - + // calculate the center of the bounding sphere centerX = (minMax.minPoint.x + minMax.maxPoint.x) / 2.0f; centerY = (minMax.minPoint.y + minMax.maxPoint.y) / 2.0f; centerZ = (minMax.minPoint.z + minMax.maxPoint.z) / 2.0f; - + pointArray->boundingSphere.center.x = centerX; pointArray->boundingSphere.center.y = centerY; pointArray->boundingSphere.center.z = centerZ; - + // calculate the radius of the bounding sphere - pointArray->boundingSphere.radius = + pointArray->boundingSphere.radius = MUrPoint_Distance( &pointArray->minmax_boundingBox.minPoint, &pointArray->boundingSphere.center); - + UUmAssert(pointArray->boundingSphere.radius < 10000.0f); - + UUrBitVector_Dispose(bitvector); - + return UUcError_None; } @@ -608,22 +608,22 @@ IMPiModel_Process_TrisAndQuads( UUtUns32* curTriNormalIndexPtr; UUtUns32 curTriNormalIndex = 0; UUtBool recordNormal; - - + + if(inNode->numTriangles + inNode->numQuads * 2 > IMPcModel_MaxTris) UUmError_ReturnOnErrorMsg(UUcError_Generic, "too many tris"); - + curTri = IMPgModel_TriList; curTriNormal = IMPgModel_TriNormalList; curTriNormalIndexPtr = IMPgModel_TriNormalIndexList; - + for(i = 0; i < inNode->numTriangles; i++) { M3tVector3D this_triangles_normal; MUrVector_NormalFromPoints( - ioGeometry->pointArray->points + inNode->triangles[i].indices[0], - ioGeometry->pointArray->points + inNode->triangles[i].indices[1], - ioGeometry->pointArray->points + inNode->triangles[i].indices[2], + ioGeometry->pointArray->points + inNode->triangles[i].indices[0], + ioGeometry->pointArray->points + inNode->triangles[i].indices[1], + ioGeometry->pointArray->points + inNode->triangles[i].indices[2], &this_triangles_normal); if (MUrVector_DotProduct(&inNode->triangles[i].dont_use_this_normal, &this_triangles_normal) < 0.f) { @@ -638,7 +638,7 @@ IMPiModel_Process_TrisAndQuads( tri_point[j] = &ioGeometry->pointArray->points[curTri->indices[j]]; #endif } - + // don't import degenerate triangles if(!(curTri->indices[0] == curTri->indices[1] || curTri->indices[0] == curTri->indices[2] || @@ -657,15 +657,15 @@ IMPiModel_Process_TrisAndQuads( #endif } } - + for(i = 0; i < inNode->numQuads; i++) { M3tVector3D this_quads_normal; MUrVector_NormalFromPoints( - ioGeometry->pointArray->points + inNode->quads[i].indices[0], - ioGeometry->pointArray->points + inNode->quads[i].indices[1], - ioGeometry->pointArray->points + inNode->quads[i].indices[2], + ioGeometry->pointArray->points + inNode->quads[i].indices[0], + ioGeometry->pointArray->points + inNode->quads[i].indices[1], + ioGeometry->pointArray->points + inNode->quads[i].indices[2], &this_quads_normal); if (MUrVector_DotProduct(&inNode->quads[i].dont_use_this_normal, &this_quads_normal) < 0.f) { @@ -677,11 +677,11 @@ IMPiModel_Process_TrisAndQuads( curTri->indices[0] = (UUtUns16) inNode->quads[i].indices[0]; curTri->indices[1] = (UUtUns16) inNode->quads[i].indices[1]; curTri->indices[2] = (UUtUns16) inNode->quads[i].indices[2]; - + UUmAssert(curTri->indices[0] != UUcMaxUns16); UUmAssert(curTri->indices[1] != UUcMaxUns16); UUmAssert(curTri->indices[2] != UUcMaxUns16); - + #if TRI_AREA_TEST tri_point[0] = &ioGeometry->pointArray->points[curTri->indices[0]]; tri_point[1] = &ioGeometry->pointArray->points[curTri->indices[1]]; @@ -689,7 +689,7 @@ IMPiModel_Process_TrisAndQuads( #endif recordNormal = UUcFalse; - + // don't import degenerate triangles if(!(curTri->indices[0] == curTri->indices[1] || curTri->indices[0] == curTri->indices[2] || @@ -714,7 +714,7 @@ IMPiModel_Process_TrisAndQuads( UUmAssert(curTri->indices[0] != UUcMaxUns16); UUmAssert(curTri->indices[1] != UUcMaxUns16); UUmAssert(curTri->indices[2] != UUcMaxUns16); - + #if TRI_AREA_TEST tri_point[0] = &ioGeometry->pointArray->points[curTri->indices[0]]; tri_point[1] = &ioGeometry->pointArray->points[curTri->indices[1]]; @@ -722,7 +722,7 @@ IMPiModel_Process_TrisAndQuads( #endif recordNormal = UUcFalse; - + // don't import degenerate triangles if(!(curTri->indices[0] == curTri->indices[1] || curTri->indices[0] == curTri->indices[2] || @@ -738,19 +738,19 @@ IMPiModel_Process_TrisAndQuads( } #endif } - + if(recordNormal == UUcTrue) { *curTriNormal++ = this_quads_normal; curTriNormalIndex++; } } - + IMPgModel_NumTris = curTri - IMPgModel_TriList; gTotal_NumTris += IMPgModel_NumTris; IMPgModel_NumTriNormals = curTriNormalIndex; - + return UUcError_None; } @@ -770,34 +770,34 @@ IMPiModel_Process_MaterialTrisAndQuads( UUtUns32* curTriNormalIndexPtr; UUtUns32 curTriNormalIndex = 0; UUtBool recordNormal; - - + + if (inNode->numTriangles + inNode->numQuads * 2 > IMPcModel_MaxTris) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "too many tris"); } - + curTri = IMPgModel_TriList; curTriNormal = IMPgModel_TriNormalList; curTriNormalIndexPtr = IMPgModel_TriNormalIndexList; - + for (i = 0; i < inNode->numTriangles; i++) { M3tVector3D this_triangles_normal; - + // only process triangles associated with inMaterialIndex if (inNode->triangles[i].material != inMaterialIndex) { continue; } - + MUrVector_NormalFromPoints( - ioGeometry->pointArray->points + inFromTo[inNode->triangles[i].indices[0]], - ioGeometry->pointArray->points + inFromTo[inNode->triangles[i].indices[1]], - ioGeometry->pointArray->points + inFromTo[inNode->triangles[i].indices[2]], + ioGeometry->pointArray->points + inFromTo[inNode->triangles[i].indices[0]], + ioGeometry->pointArray->points + inFromTo[inNode->triangles[i].indices[1]], + ioGeometry->pointArray->points + inFromTo[inNode->triangles[i].indices[2]], &this_triangles_normal); - + if (MUrVector_DotProduct(&inNode->triangles[i].dont_use_this_normal, &this_triangles_normal) < 0.f) { MUmVector_Negate(this_triangles_normal); } - + for(j = 0; j < 3; j++) { curTri->indices[j] = inFromTo[inNode->triangles[i].indices[j]]; @@ -806,7 +806,7 @@ IMPiModel_Process_MaterialTrisAndQuads( tri_point[j] = &ioGeometry->pointArray->points[curTri->indices[j]]; #endif } - + // don't import degenerate triangles if(!(curTri->indices[0] == curTri->indices[1] || curTri->indices[0] == curTri->indices[2] || @@ -826,34 +826,34 @@ IMPiModel_Process_MaterialTrisAndQuads( #endif } } - + for (i = 0; i < inNode->numQuads; i++) { M3tVector3D this_quads_normal; - + // only process quads associated with inMaterialIndex if (inNode->quads[i].material != inMaterialIndex) { continue; } - + MUrVector_NormalFromPoints( - ioGeometry->pointArray->points + inFromTo[inNode->quads[i].indices[0]], - ioGeometry->pointArray->points + inFromTo[inNode->quads[i].indices[1]], - ioGeometry->pointArray->points + inFromTo[inNode->quads[i].indices[2]], + ioGeometry->pointArray->points + inFromTo[inNode->quads[i].indices[0]], + ioGeometry->pointArray->points + inFromTo[inNode->quads[i].indices[1]], + ioGeometry->pointArray->points + inFromTo[inNode->quads[i].indices[2]], &this_quads_normal); - + if (MUrVector_DotProduct(&inNode->quads[i].dont_use_this_normal, &this_quads_normal) < 0.f) { MUmVector_Negate(this_quads_normal); } - + *curTriNormal = this_quads_normal; - + curTri->indices[0] = inFromTo[inNode->quads[i].indices[0]]; curTri->indices[1] = inFromTo[inNode->quads[i].indices[1]]; curTri->indices[2] = inFromTo[inNode->quads[i].indices[2]]; - + UUmAssert(curTri->indices[0] != UUcMaxUns16); UUmAssert(curTri->indices[1] != UUcMaxUns16); UUmAssert(curTri->indices[2] != UUcMaxUns16); - + #if TRI_AREA_TEST tri_point[0] = &ioGeometry->pointArray->points[curTri->indices[0]]; tri_point[1] = &ioGeometry->pointArray->points[curTri->indices[1]]; @@ -861,7 +861,7 @@ IMPiModel_Process_MaterialTrisAndQuads( #endif recordNormal = UUcFalse; - + // don't import degenerate triangles if(!(curTri->indices[0] == curTri->indices[1] || curTri->indices[0] == curTri->indices[2] || @@ -909,19 +909,19 @@ IMPiModel_Process_MaterialTrisAndQuads( } #endif } - + if(recordNormal == UUcTrue) { *curTriNormal++ = this_quads_normal; curTriNormalIndex++; } } - + IMPgModel_NumTris = curTri - IMPgModel_TriList; gTotal_NumTris += IMPgModel_NumTris; IMPgModel_NumTriNormals = curTriNormalIndex; - + return UUcError_None; } @@ -934,71 +934,71 @@ IMPiModel_Finish( //UUtUns16* curIndexPtr; //UUtUns16 index0, index1, index2; //M3tPoint3D* pointArray; - + error = TMrConstruction_Instance_NewUnique( M3cTemplate_Vector3DArray, IMPgModel_NumTriNormals, &ioGeometry->triNormalArray); UUmError_ReturnOnError(error); - + for(itr = 0; itr < IMPgModel_NumTriNormals; itr++) { ioGeometry->triNormalArray->vectors[itr] = IMPgModel_TriNormalList[itr]; } - + error = TMrConstruction_Instance_NewUnique( TMcTemplate_IndexArray, IMPgModel_VertexFinalListLength, &ioGeometry->triStripArray); UUmError_ReturnOnError(error); - + UUrMemory_MoveFast(IMPgModel_VertexFinalList, ioGeometry->triStripArray->indices, IMPgModel_VertexFinalListLength * sizeof(UUtUns32)); - + error = TMrConstruction_Instance_NewUnique( TMcTemplate_IndexArray, IMPgModel_TriFinalListLength, &ioGeometry->triNormalIndexArray); UUmError_ReturnOnError(error); - + //curIndexPtr = ioGeometry->triStripArray->indices; //pointArray = ioGeometry->pointArray->points; - + for(itr = 0; itr < IMPgModel_TriFinalListLength; itr++) { ioGeometry->triNormalIndexArray->indices[itr] = IMPgModel_TriNormalIndexList[IMPgModel_TriFinalList[itr]]; - + #if 0 { M3tVector3D computedNormal; M3tVector3D* realNormal; - + index2 = *curIndexPtr++; - + if(index2 & 0x80000000) { index0 = (index2 & 0x7FFF); index1 = *curIndexPtr++; index2 = *curIndexPtr++; } - + MUrVector_NormalFromPoints( pointArray + index0, pointArray + index1, pointArray + index2, &computedNormal); - + realNormal = ioGeometry->triNormalArray->vectors + ioGeometry->triNormalIndexArray->indices[itr]; - + UUmAssert(computedNormal.x == realNormal->x); - + index0 = index1; index1 = index2; } #endif - + } return UUcError_None; @@ -1014,20 +1014,20 @@ UUtError Imp_Node_To_Geometry( UUmAssertWritePtr(outGeometry, sizeof(*outGeometry)); UUrMemory_Clear(outGeometry, sizeof(*outGeometry)); - + gTotal_NumObjects++; - - outGeometry->animation = NULL; + + outGeometry->animation = NULL; error = IMPiModel_Process_Points(inNode, outGeometry); IMPmError_ReturnOnError(error); error = IMPiModel_Process_TrisAndQuads(inNode, outGeometry); IMPmError_ReturnOnError(error); - + IMPiModel_Stripify(inNode); - + error = IMPiModel_Finish(outGeometry); - + return UUcError_None; } @@ -1038,33 +1038,33 @@ UUtError Imp_NodeMaterial_To_Geometry( { UUtError error; UUtUns16 *from_to; - + UUmAssertReadPtr(inNode, sizeof(*inNode)); UUmAssertWritePtr(outGeometry, sizeof(*outGeometry)); - + UUrMemory_Clear(outGeometry, sizeof(*outGeometry)); - + gTotal_NumObjects++; - - outGeometry->animation = NULL; - + + outGeometry->animation = NULL; + // allocate memory for the from_to array from_to = UUrMemory_Block_New(sizeof(UUtUns16) * inNode->numPoints); UUmError_ReturnOnNull(from_to); UUrMemory_Set16(from_to, UUcMaxUns16, sizeof(UUtUns16) * inNode->numPoints); - + error = IMPiModel_Process_MaterialPoints(inNode, inMaterialIndex, outGeometry, from_to); IMPmError_ReturnOnError(error); error = IMPiModel_Process_MaterialTrisAndQuads(inNode, inMaterialIndex, from_to, outGeometry); IMPmError_ReturnOnError(error); - + // dispose of the used memory UUrMemory_Block_Delete(from_to); - + IMPiModel_Stripify(inNode); - + error = IMPiModel_Finish(outGeometry); - + return UUcError_None; } @@ -1076,18 +1076,18 @@ Imp_RotateBoundBox( M3tBoundingBox_MinMax *min_max; M3tBoundingBox bbox; UUtUns32 i; - + min_max = &ioGeometry->pointArray->minmax_boundingBox; M3rMinMaxBBox_To_BBox(min_max, &bbox); - + for (i = 0; i < M3cNumBoundingPoints; i++) { MUrMatrix_MultiplyPoint(&bbox.localPoints[i], &inNode->matrix, &bbox.localPoints[i]); } - + MUmVector_Set(min_max->minPoint, 1e13f, 1e13f, 1e13f); MUmVector_Set(min_max->maxPoint, -1e13f, -1e13f, -1e13f); - + for (i = 0; i < M3cNumBoundingPoints; i++) { min_max->minPoint.x = UUmMin(min_max->minPoint.x, bbox.localPoints[i].x); @@ -1111,27 +1111,27 @@ UUtError Imp_Node_To_Geometry_ApplyMatrix( error = Imp_Node_To_Geometry(inNode, outGeometry); UUmError_ReturnOnError(error); - + MUrMatrix_MultiplyPoints( - outGeometry->pointArray->numPoints, + outGeometry->pointArray->numPoints, &inNode->matrix, outGeometry->pointArray->points, outGeometry->pointArray->points); MUrMatrix_MultiplyNormals( - outGeometry->triNormalArray->numVectors, + outGeometry->triNormalArray->numVectors, &inNode->matrix, outGeometry->triNormalArray->vectors, outGeometry->triNormalArray->vectors); MUrMatrix_MultiplyNormals( - outGeometry->vertexNormalArray->numVectors, + outGeometry->vertexNormalArray->numVectors, &inNode->matrix, outGeometry->vertexNormalArray->vectors, outGeometry->vertexNormalArray->vectors); - + Imp_RotateBoundBox(inNode, outGeometry); - + MUrMatrix_MultiplyPoint( &outGeometry->pointArray->boundingSphere.center, &inNode->matrix, @@ -1149,28 +1149,28 @@ UUtError Imp_NodeMaterial_To_Geometry_ApplyMatrix( UUmAssertReadPtr(inNode, sizeof(*inNode)); UUmAssertWritePtr(outGeometry, sizeof(*outGeometry)); - + error = Imp_NodeMaterial_To_Geometry(inNode, inMaterialIndex, outGeometry); UUmError_ReturnOnError(error); - + MUrMatrix_MultiplyPoints( - outGeometry->pointArray->numPoints, + outGeometry->pointArray->numPoints, &inNode->matrix, outGeometry->pointArray->points, outGeometry->pointArray->points); MUrMatrix_MultiplyNormals( - outGeometry->triNormalArray->numVectors, + outGeometry->triNormalArray->numVectors, &inNode->matrix, outGeometry->triNormalArray->vectors, outGeometry->triNormalArray->vectors); MUrMatrix_MultiplyNormals( - outGeometry->vertexNormalArray->numVectors, + outGeometry->vertexNormalArray->numVectors, &inNode->matrix, outGeometry->vertexNormalArray->vectors, outGeometry->vertexNormalArray->vectors); - + Imp_RotateBoundBox(inNode, outGeometry); MUrMatrix_MultiplyPoint( @@ -1200,7 +1200,7 @@ Imp_AddModel( UUtBool noMatrix; char mungedTextureName[BFcMaxFileNameLength]; - error = + error = Imp_Common_BuildInstance( inSourceFileRef, inSourceFileModDate, @@ -1211,7 +1211,7 @@ Imp_AddModel( &fileRef, &buildInstance); IMPmError_ReturnOnError(error); - + if (buildInstance != UUcTrue) { goto exit; } @@ -1226,9 +1226,9 @@ Imp_AddModel( 0, &geometry); IMPmError_ReturnOnError(error); - - geometry->animation = NULL; - + + geometry->animation = NULL; + if (header->numNodes > 1) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "model files can only have one node!"); } @@ -1246,17 +1246,17 @@ Imp_AddModel( { Imp_Node_To_Geometry_ApplyMatrix(header->nodes + 0, geometry); } - + // Add the texture error = GRrGroup_GetString(inGroup, "texture", &textureName); if (error != UUcError_None) { textureName = header->nodes[0].materials[0].maps[MXcMapping_DI].name; } - + // strip off the extension UUrString_Copy(mungedTextureName, textureName, BFcMaxFileNameLength); UUrString_StripExtension(mungedTextureName); - + UUmAssert(strchr(mungedTextureName, '.') == NULL); geometry->baseMap = M3rTextureMap_GetPlaceholder(mungedTextureName); @@ -1268,7 +1268,7 @@ Imp_AddModel( } geometry->geometryFlags = (M3tGeometryFlags) geometryFlags; - + exit: if (NULL != fileRef) { BFrFileRef_Dispose(fileRef); @@ -1277,7 +1277,7 @@ Imp_AddModel( if (NULL != header) { Imp_EnvFile_Delete(header); } - + return UUcError_None; } @@ -1296,12 +1296,12 @@ Imp_AddModelArray( M3tGeometryArray* geometryArray; Imp_PrintMessage(IMPcMsg_Cosmetic, "\tbuilding..."UUmNL); - + // open our group array error = GRrGroup_GetElement( - inGroup, - "modelList", - &elementType, + inGroup, + "modelList", + &elementType, &modelList); if ((error != UUcError_None) || (elementType != GRcElementType_Array)) @@ -1319,7 +1319,7 @@ Imp_AddModelArray( numModels, &geometryArray); IMPmError_ReturnOnError(error); - + for(itr = 0; itr < numModels; itr++) { char *instanceTag; @@ -1330,45 +1330,45 @@ Imp_AddModelArray( IMPmError_ReturnOnErrorMsg(error, "Imp_AddModelArray: could not get the tag"); error = TMrConstruction_Instance_GetPlaceHolder( - M3cTemplate_Geometry, - instanceTag, + M3cTemplate_Geometry, + instanceTag, (TMtPlaceHolder*)&model); IMPmError_ReturnOnErrorMsg(error, "Imp_AddAnimationCollection: could not find the animation"); geometryArray->geometries[itr] = model; } - + return UUcError_None; } UUtError IMPrModel_Initialize( void) -{ +{ IMPgModel_TriEdgeArray = AUrSharedEdgeArray_New(); UUmError_ReturnOnNull(IMPgModel_TriEdgeArray); - + IMPgModel_TriEdgeList = UUrMemory_Block_New(IMPcModel_MaxTris * sizeof(M3tTri)); UUmError_ReturnOnNull(IMPgModel_TriEdgeList); - + IMPgModel_VertexFinalList = UUrMemory_Block_New(IMPcModel_MaxTris * sizeof(IMPtModel_Tri)); UUmError_ReturnOnNull(IMPgModel_VertexFinalList); - + IMPgModel_TriUsedBV = UUrBitVector_New(IMPcModel_MaxTris); UUmError_ReturnOnNull(IMPgModel_TriUsedBV); - + IMPgModel_TriNormalList = UUrMemory_Block_New(IMPcModel_MaxTris * sizeof(M3tVector3D)); UUmError_ReturnOnNull(IMPgModel_TriNormalList); - + IMPgModel_TriList = UUrMemory_Block_New(IMPcModel_MaxTris * sizeof(M3tTri)); UUmError_ReturnOnNull(IMPgModel_TriList); - + IMPgModel_TriNormalIndexList = UUrMemory_Block_New(IMPcModel_MaxTris * sizeof(UUtUns16)); UUmError_ReturnOnNull(IMPgModel_TriNormalIndexList); - + IMPgModel_TriFinalList = UUrMemory_Block_New(IMPcModel_MaxTris * sizeof(UUtUns16)); UUmError_ReturnOnNull(IMPgModel_TriFinalList); - + return UUcError_None; } @@ -1376,11 +1376,11 @@ void IMPrModel_Terminate( void) { - + fprintf(stderr, "tris/strips %d / %d = %f\n", gTotal_NumTris, gTotal_NumStrips, (float)gTotal_NumTris / (float)gTotal_NumStrips); fprintf(stderr, "tris/obj %d / %d = %f\n", gTotal_NumTris, gTotal_NumObjects, (float)gTotal_NumTris / (float)gTotal_NumObjects); fprintf(stderr, "strips/obj %d / %d = %f\n", gTotal_NumStrips, gTotal_NumObjects, (float)gTotal_NumStrips / (float)gTotal_NumObjects); - + #if 0 { UUtUns16 itr; @@ -1390,7 +1390,7 @@ IMPrModel_Terminate( } } #endif - + AUrSharedEdgeArray_Delete(IMPgModel_TriEdgeArray); UUrMemory_Block_Delete(IMPgModel_TriEdgeList); UUrMemory_Block_Delete(IMPgModel_VertexFinalList); diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Model.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Model.h index a3e51b6..e34265c 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Model.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Model.h @@ -1,12 +1,12 @@ /* FILE: Imp_Model.h - + AUTHOR: Brent H. Pease - + CREATED: August 14, 1997 - + PURPOSE: Header file for the BMP file format - + Copyright 1997 */ @@ -65,12 +65,12 @@ UUtError Imp_Node_To_Geometry( UUtError Imp_Node_To_Geometry_ApplyMatrix( const MXtNode *inNode, M3tGeometry *inGeometry); - + UUtError Imp_NodeMaterial_To_Geometry( const MXtNode *inNode, UUtUns16 inMaterialIndex, M3tGeometry *outGeometry); - + UUtError Imp_NodeMaterial_To_Geometry_ApplyMatrix( const MXtNode *inNode, UUtUns16 inMaterialIndex, @@ -89,7 +89,7 @@ Imp_AddModelArray( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + #ifdef __cplusplus } #endif diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_ParseEnvFile.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_ParseEnvFile.c index beba33b..f392688 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_ParseEnvFile.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_ParseEnvFile.c @@ -1,12 +1,12 @@ /* FILE: Imp_ParseEnvFile.c - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: Nov 17, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -78,8 +78,8 @@ Imp_ParseEnvFile( MXtHeader* newHeader; char* curPtr; UUtUns32 length; - - error = + + error = BFrFileRef_LoadIntoMemory( inFileRef, &length, @@ -90,28 +90,28 @@ Imp_ParseEnvFile( return UUcError_Generic; } - + #if UUmEndian == UUmEndian_Big - + UUmSwapLittle_4Byte(&newHeader->version); UUmSwapLittle_2Byte(&newHeader->numNodes); - + #endif - + if(strncmp(newHeader->stringENVF, "ENVF", 4)) { UUmError_ReturnOnErrorMsgP( - UUcError_Generic, - "file %s is not a binary file", + UUcError_Generic, + "file %s is not a binary file", (UUtUns32) BFrFileRef_GetLeafName(inFileRef), 0, 0); } - + if(newHeader->version != 0) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "wrong version"); } - + if (0 == newHeader->numNodes) { newHeader->nodes = NULL; Imp_PrintWarning("This file (%s) had 0 nodes.", BFrFileRef_GetLeafName(inFileRef)); @@ -120,9 +120,9 @@ Imp_ParseEnvFile( newHeader->nodes = UUrMemory_Block_New(sizeof(MXtNode) * newHeader->numNodes); UUmError_ReturnOnNull(newHeader->nodes); } - + curPtr = (char*)newHeader + sizeof(MXtHeader); - + for(nodeItr = 0; nodeItr < newHeader->numNodes; nodeItr++) { error = iParseMXtNode(BFrFileRef_GetLeafName(inFileRef), &curPtr, newHeader->nodes + nodeItr); @@ -130,7 +130,7 @@ Imp_ParseEnvFile( } iMXtHeader_BuildHierarchy(newHeader); - + *outHeader = newHeader; if (IMPgBuildTextFiles) @@ -138,20 +138,20 @@ Imp_ParseEnvFile( BFtFileRef* newFileRef; const char *leafName = BFrFileRef_GetLeafName(inFileRef); char newName[256]; - + UUrString_Copy(newName, leafName, 256); - + newName[strlen(leafName) - 4] = '_'; - - UUrString_Cat(newName, ".txt", 256); + + UUrString_Cat(newName, ".txt", 256); error = BFrFileRef_DuplicateAndReplaceName( inFileRef, newName, &newFileRef); - + if (error != UUcError_None) { - AUrMessageBox(AUcMBType_OK, + AUrMessageBox(AUcMBType_OK, "Could not make file ref for %s\n", newName); } @@ -173,7 +173,7 @@ static UUtError iParseMXtNode(const char *inFileName, char **ioPtr, MXtNode *out MXtFace* curFace; char* curPtr; MXtPoint* curPoint; - + #if UUmEndian == UUmEndian_Big UUtUns16 itr2; float* p; @@ -184,61 +184,61 @@ static UUtError iParseMXtNode(const char *inFileName, char **ioPtr, MXtNode *out curFace; UUmAssertReadPtr(outNode, sizeof(*outNode)); - + curPtr = *ioPtr; - + *outNode = *(MXtNode*)curPtr; - + curPtr += sizeof(MXtNode); #if UUmEndian == UUmEndian_Big - + p = (float*)&outNode->matrix; for(itr = 0; itr < sizeof(M3tMatrix4x3) / sizeof(float); itr++) { UUmSwapLittle_4Byte(p); p++; } - + UUmSwapLittle_2Byte(&outNode->numPoints); UUmSwapLittle_2Byte(&outNode->numTriangles); UUmSwapLittle_2Byte(&outNode->numQuads); UUmSwapLittle_2Byte(&outNode->numMarkers); UUmSwapLittle_2Byte(&outNode->numMaterials); UUmSwapLittle_4Byte(&outNode->userDataCount); - + #endif - + outNode->userData = curPtr; curPtr += sizeof(char) * outNode->userDataCount; outNode->points = (MXtPoint*)curPtr; curPtr += sizeof(MXtPoint) * outNode->numPoints; - + outNode->triangles = (MXtFace*)curPtr; curPtr += sizeof(MXtFace) * outNode->numTriangles; - + outNode->quads = (MXtFace*)curPtr; curPtr += sizeof(MXtFace) * outNode->numQuads; - + if(outNode->numMarkers > 0) - { + { outNode->markers = UUrMemory_Block_New(sizeof(MXtMarker) * outNode->numMarkers); UUmError_ReturnOnNull(outNode->markers); - + for(itr = 0; itr < outNode->numMarkers; itr++) { error = iParseMXtMarker(&curPtr, outNode->markers + itr); UUmError_ReturnOnError(error); } } - + UUmAssertReadPtr(outNode->points, sizeof(M3tPoint3D) * outNode->numPoints); outNode->materials = (MXtMaterial*)curPtr; curPtr += sizeof(MXtMaterial) * outNode->numMaterials; - + for(itr = 0, curPoint = outNode->points; itr < outNode->numPoints; itr++, curPoint++) @@ -251,12 +251,12 @@ static UUtError iParseMXtNode(const char *inFileName, char **ioPtr, MXtNode *out UUmSwapLittle_4Byte(&curPoint->normal.z); UUmSwapLittle_4Byte(&curPoint->uv.u); UUmSwapLittle_4Byte(&curPoint->uv.v); - + curPoint->uv.v = 1.f - curPoint->uv.v; } - + #if UUmEndian == UUmEndian_Big - + for(itr = 0, curFace = outNode->triangles; itr < outNode->numTriangles; itr++, curFace++) @@ -265,14 +265,14 @@ static UUtError iParseMXtNode(const char *inFileName, char **ioPtr, MXtNode *out UUmSwapLittle_2Byte(&curFace->indices[1]); UUmSwapLittle_2Byte(&curFace->indices[2]); UUmSwapLittle_2Byte(&curFace->indices[3]); - + UUmSwapLittle_4Byte(&curFace->dont_use_this_normal.x); UUmSwapLittle_4Byte(&curFace->dont_use_this_normal.y); UUmSwapLittle_4Byte(&curFace->dont_use_this_normal.z); - + UUmSwapLittle_2Byte(&curFace->material); } - + for(itr = 0, curFace = outNode->quads; itr < outNode->numQuads; itr++, curFace++) @@ -281,14 +281,14 @@ static UUtError iParseMXtNode(const char *inFileName, char **ioPtr, MXtNode *out UUmSwapLittle_2Byte(&curFace->indices[1]); UUmSwapLittle_2Byte(&curFace->indices[2]); UUmSwapLittle_2Byte(&curFace->indices[3]); - + UUmSwapLittle_4Byte(&curFace->dont_use_this_normal.x); UUmSwapLittle_4Byte(&curFace->dont_use_this_normal.y); UUmSwapLittle_4Byte(&curFace->dont_use_this_normal.z); - + UUmSwapLittle_2Byte(&curFace->material); } - + for(itr = 0, curMaterial = outNode->materials; itr < outNode->numMaterials; itr++, curMaterial++) @@ -313,12 +313,12 @@ static UUtError iParseMXtNode(const char *inFileName, char **ioPtr, MXtNode *out { UUmSwapLittle_4Byte(&curMap->amount); } - + UUmSwapLittle_4Byte(&curMaterial->requirements); } - + #endif - + #if 0 for(itr = 0, curFace = outNode->quads; itr < outNode->numQuads; @@ -335,7 +335,7 @@ static UUtError iParseMXtNode(const char *inFileName, char **ioPtr, MXtNode *out if (!goodFace) { AUtMB_ButtonChoice choice; - choice = AUrMessageBox(AUcMBType_OKCancel, + choice = AUrMessageBox(AUcMBType_OKCancel, "Bad face in file %s node %s (%d,%d,%d,%d) of %d material %d of %d. Should I try to continue (most likely will crash later)?\n", inFileName, outNode->name, @@ -361,28 +361,28 @@ static UUtError iParseMXtNode(const char *inFileName, char **ioPtr, MXtNode *out #endif *ioPtr = curPtr; - + iClampTextureNames(outNode); - + return UUcError_None; } static UUtError iParseMXtMarker(char **ioPtr, MXtMarker *outMarker) { char* curPtr; - + #if UUmEndian == UUmEndian_Big UUtUns16 itr; float* p; #endif - + curPtr = *ioPtr; - + *outMarker = *(MXtMarker*)curPtr; curPtr += sizeof(MXtMarker); - + #if UUmEndian == UUmEndian_Big p = (float*)&outMarker->matrix; @@ -393,14 +393,14 @@ static UUtError iParseMXtMarker(char **ioPtr, MXtMarker *outMarker) } UUmSwapLittle_4Byte(&outMarker->userDataCount); - + #endif - + outMarker->userData = curPtr; curPtr += outMarker->userDataCount * sizeof(char); - + *ioPtr = curPtr; - + return UUcError_None; } @@ -469,7 +469,7 @@ Imp_WriteHierarchyRecursive( BFrFile_Printf(inFile, "%s"UUmNL, node->name); // draw chlidren - if (0 != node->child) + if (0 != node->child) { Imp_WriteHierarchyRecursive(inFile, inHeader, numSpaces + 1, node->child); } @@ -477,7 +477,7 @@ Imp_WriteHierarchyRecursive( return; } -static void +static void DumpNodeSummery( BFtFile* inFile, UUtUns16 inIndex, @@ -490,20 +490,20 @@ DumpNodeSummery( BFrFile_Printf(inFile, "child %d"UUmNL, inNode->child); BFrFile_Printf(inFile, "matrix:"UUmNL); - BFrFile_Printf(inFile, "%f %f %f %f"UUmNL, - inNode->matrix.m[0][0], - inNode->matrix.m[1][0], - inNode->matrix.m[2][0], + BFrFile_Printf(inFile, "%f %f %f %f"UUmNL, + inNode->matrix.m[0][0], + inNode->matrix.m[1][0], + inNode->matrix.m[2][0], inNode->matrix.m[3][0]); - BFrFile_Printf(inFile, "%f %f %f %f"UUmNL, - inNode->matrix.m[0][1], - inNode->matrix.m[1][1], - inNode->matrix.m[2][1], + BFrFile_Printf(inFile, "%f %f %f %f"UUmNL, + inNode->matrix.m[0][1], + inNode->matrix.m[1][1], + inNode->matrix.m[2][1], inNode->matrix.m[3][1]); - BFrFile_Printf(inFile, "%f %f %f %f"UUmNL, - inNode->matrix.m[0][2], - inNode->matrix.m[1][2], - inNode->matrix.m[2][2], + BFrFile_Printf(inFile, "%f %f %f %f"UUmNL, + inNode->matrix.m[0][2], + inNode->matrix.m[1][2], + inNode->matrix.m[2][2], inNode->matrix.m[3][2]); BFrFile_Printf(inFile, "numPoints %d"UUmNL, inNode->numPoints); @@ -516,7 +516,7 @@ DumpNodeSummery( return; } -static void +static void DumpNodeDetails( BFtFile* inFile, UUtUns16 inIndex, @@ -532,17 +532,17 @@ DumpNodeDetails( MXtPoint *curPoint = inNode->points + itr; BFrFile_Printf(inFile, "%d"UUmNL, itr); - BFrFile_Printf(inFile, "%f %f %f"UUmNL, + BFrFile_Printf(inFile, "%f %f %f"UUmNL, curPoint->point.x, curPoint->point.y, curPoint->point.z); - BFrFile_Printf(inFile, "%f %f %f"UUmNL, + BFrFile_Printf(inFile, "%f %f %f"UUmNL, curPoint->normal.x, curPoint->normal.y, curPoint->normal.z); - BFrFile_Printf(inFile, "%f %f"UUmNL, + BFrFile_Printf(inFile, "%f %f"UUmNL, curPoint->uv.u, curPoint->uv.v); @@ -556,17 +556,17 @@ DumpNodeDetails( BFrFile_Printf(inFile, "%d"UUmNL, itr); - BFrFile_Printf(inFile, "%d %d %d"UUmNL, + BFrFile_Printf(inFile, "%d %d %d"UUmNL, curTriangle->indices[0], curTriangle->indices[1], curTriangle->indices[2]); -// BFrFile_Printf(inFile, "%f %f %f"UUmNL, +// BFrFile_Printf(inFile, "%f %f %f"UUmNL, // curTriangle->normal.x, // curTriangle->normal.y, // curTriangle->normal.z); - BFrFile_Printf(inFile, "%d"UUmNL, + BFrFile_Printf(inFile, "%d"UUmNL, curTriangle->material); BFrFile_Printf(inFile, ""UUmNL); @@ -579,22 +579,22 @@ DumpNodeDetails( BFrFile_Printf(inFile, "%d"UUmNL, itr); - BFrFile_Printf(inFile, "%d %d %d %d"UUmNL, + BFrFile_Printf(inFile, "%d %d %d %d"UUmNL, curQuad->indices[0], curQuad->indices[1], curQuad->indices[2], curQuad->indices[3]); -// BFrFile_Printf(inFile, "%f %f %f"UUmNL, +// BFrFile_Printf(inFile, "%f %f %f"UUmNL, // curQuad->normal.x, // curQuad->normal.y, // curQuad->normal.z); - BFrFile_Printf(inFile, "%d"UUmNL, + BFrFile_Printf(inFile, "%d"UUmNL, curQuad->material); BFrFile_Printf(inFile, ""UUmNL); - } + } BFrFile_Printf(inFile, "materials (%d)"UUmNL, inNode->numMaterials); for(itr = 0; itr < inNode->numMaterials; itr++) @@ -609,9 +609,9 @@ DumpNodeDetails( BFrFile_Printf(inFile, "selfIllumination = %f"UUmNL, curMaterial->selfIllumination); BFrFile_Printf(inFile, "shininess = %f"UUmNL, curMaterial->name); BFrFile_Printf(inFile, "shininessStrength = %f"UUmNL, curMaterial->name); - BFrFile_Printf(inFile, "ambient (%f,%f,%f)"UUmNL, curMaterial->ambient[0], curMaterial->ambient[1], curMaterial->ambient[2]); - BFrFile_Printf(inFile, "diffuse (%f,%f,%f)"UUmNL, curMaterial->diffuse[0], curMaterial->diffuse[1], curMaterial->diffuse[2]); - BFrFile_Printf(inFile, "specular (%f,%f,%f)"UUmNL, curMaterial->specular[0], curMaterial->specular[1], curMaterial->specular[2]); + BFrFile_Printf(inFile, "ambient (%f,%f,%f)"UUmNL, curMaterial->ambient[0], curMaterial->ambient[1], curMaterial->ambient[2]); + BFrFile_Printf(inFile, "diffuse (%f,%f,%f)"UUmNL, curMaterial->diffuse[0], curMaterial->diffuse[1], curMaterial->diffuse[2]); + BFrFile_Printf(inFile, "specular (%f,%f,%f)"UUmNL, curMaterial->specular[0], curMaterial->specular[1], curMaterial->specular[2]); BFrFile_Printf(inFile, "requirements %08x"UUmNL, curMaterial->requirements); BFrFile_Printf(inFile, UUmNL); @@ -635,7 +635,7 @@ Imp_WriteTextEnvFile( UUtUns16 itr; UUtError error; BFtFile *file; - + error = BFrFile_Open(inFileRef, "w", &file); UUmAssert(UUcError_None == error); @@ -733,9 +733,9 @@ Imp_EnvFile_Delete( MXtHeader* inHeader) { UUtUns16 nodeItr; - + MXtNode* curNode; - + for(nodeItr = 0, curNode = inHeader->nodes; nodeItr < inHeader->numNodes; nodeItr++, curNode++) @@ -745,9 +745,9 @@ Imp_EnvFile_Delete( UUrMemory_Block_Delete(curNode->markers); } } - + UUrMemory_Block_Delete(inHeader->nodes); - + UUrMemory_Block_Delete(inHeader); } @@ -842,9 +842,9 @@ Imp_ParseEvaFile( UUmSwapLittle_2Byte(&header.endTime); UUmSwapLittle_2Byte(&header.pad); - length = + length = sizeof(AXtHeader) + - sizeof(AXtNode) * header.numNodes + + sizeof(AXtNode) * header.numNodes + sizeof(M3tMatrix4x3) * header.numNodes * header.numFrames; pDataBlock = UUrMemory_Block_New(length); @@ -856,7 +856,7 @@ Imp_ParseEvaFile( // attach node list to the header header.nodes = pNode; - + for(itr = 0; itr < header.numNodes; itr++) { error = Imp_ParseEvaNode(file, header.numFrames, pNode, pMatrix); @@ -879,4 +879,4 @@ Imp_EvaFile_Delete( UUrMemory_Block_Delete(inHeader); return; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_ParseEnvFile.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_ParseEnvFile.h index 8b5a228..c6e2bc2 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_ParseEnvFile.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_ParseEnvFile.h @@ -1,12 +1,12 @@ /* FILE: Imp_ParseEnvFile.h - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: Nov 17, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -47,4 +47,4 @@ Imp_EnvFile_GetMarker( UUtError Imp_WriteTextEnvFile( BFtFileRef* inFileRef, - const MXtHeader* inHeader); \ No newline at end of file + const MXtHeader* inHeader); diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_PartSpec.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_PartSpec.c index f78e1d0..360216e 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_PartSpec.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_PartSpec.c @@ -23,7 +23,7 @@ typedef struct tParts char *name; UUtUns16 row; UUtUns16 column; - + } tParts; // ====================================================================== @@ -58,19 +58,19 @@ IMPiAddPartSpecToUI( UUtError error; char *partspec_name; TMtPlaceHolder partspec_ref; - + error = GRrGroup_GetString(inGroup, inPartName, &partspec_name); IMPmError_ReturnOnError(error); - - error = + + error = TMrConstruction_Instance_GetPlaceHolder( PScTemplate_PartSpecification, partspec_name, &partspec_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get partspec placeholder"); - + *outPartSpec = (PStPartSpec*)partspec_ref; - + return UUcError_None; } @@ -88,7 +88,7 @@ IMPiProcessSingleTexture( BFtFileRef *texture_file_ref; const char *texture_name; TMtPlaceHolder texture_ref; - + error = GRrGroup_GetElement( inGroup, @@ -101,7 +101,7 @@ IMPiProcessSingleTexture( { Imp_PrintWarning("Unable to process the texture"); } - + return error; } @@ -112,10 +112,10 @@ IMPiProcessSingleTexture( texture_file_name, &texture_file_ref); IMPmError_ReturnOnErrorMsg(error, "texture file was not found"); - + // set the textures name texture_name = BFrFileRef_GetLeafName(texture_file_ref); - + // process the texture map file error = Imp_ProcessTexture_File( @@ -123,12 +123,12 @@ IMPiProcessSingleTexture( texture_name, &texture_ref); IMPmError_ReturnOnErrorMsg(error, "unable to process the texture"); - + BFrFileRef_Dispose(texture_file_ref); - + // save the texture ref *outTextureRef = texture_ref; - + return UUcError_None; } @@ -148,11 +148,11 @@ Imp_AddPartSpec( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(PScTemplate_PartSpecification, inInstanceName); - + if (build_instance) { GRtElementType element_type; @@ -161,7 +161,7 @@ Imp_AddPartSpec( UUtUns16 i; PStPartSpec *part_spec; TMtPlaceHolder texture; - + // get the texture error = IMPiProcessSingleTexture( @@ -182,14 +182,14 @@ Imp_AddPartSpec( 0, &part_spec); IMPmError_ReturnOnErrorMsg(error, "Could not create a part specification instance"); - + // set the texture part_spec->texture = (void*)texture; - + // clear the part matrices UUrMemory_Clear(part_spec->part_matrix_tl, sizeof(part_spec->part_matrix_tl)); UUrMemory_Clear(part_spec->part_matrix_br, sizeof(part_spec->part_matrix_br)); - + // get the parts specs error = GRrGroup_GetElement( @@ -201,9 +201,9 @@ Imp_AddPartSpec( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get part specs array"); } - + num_parts = (UUtUns16)GRrGroup_Array_GetLength(part_spec_array); - + // process the part specs for (i = 0; i < num_parts; i++) { @@ -215,7 +215,7 @@ Imp_AddPartSpec( UUtInt32 right; UUtInt32 bottom; tParts *parts; - + // get the element i from the part spec array error = GRrGroup_Array_GetElement( @@ -224,19 +224,19 @@ Imp_AddPartSpec( &element_type, &part_array); if ((error != UUcError_None) || (element_type != GRcElementType_Array)) - { + { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get part spec from array"); } - + if (GRrGroup_Array_GetLength(part_array) != 5) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "the part array in not correct"); } - + // ------------------------------ // process the elements of the part // ------------------------------ - + // get the part name error = GRrGroup_Array_GetElement( @@ -248,7 +248,7 @@ Imp_AddPartSpec( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "the part array in not correct"); } - + // get the left coordinate of the part left = 0; error = @@ -267,7 +267,7 @@ Imp_AddPartSpec( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "the part array in not correct"); } - + // get the top coordinate of the part top = 0; error = @@ -286,7 +286,7 @@ Imp_AddPartSpec( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "the part array in not correct"); } - + // get the right coordinate of the part right = 0; error = @@ -305,7 +305,7 @@ Imp_AddPartSpec( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "the part array in not correct"); } - + // get the bottom coordinate of the part bottom = 0; error = @@ -324,7 +324,7 @@ Imp_AddPartSpec( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "the part array in not correct"); } - + // stick the elements into the template for (parts = IMPgParts; parts->name != NULL; parts++) { @@ -339,7 +339,7 @@ Imp_AddPartSpec( } } } - + return UUcError_None; } @@ -354,11 +354,11 @@ Imp_AddPartSpecList( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(PScTemplate_PartSpecList, inInstanceName); - + if (build_instance) { GRtElementType element_type; @@ -366,7 +366,7 @@ Imp_AddPartSpecList( UUtUns32 num_partspecdescs; UUtUns32 i; PStPartSpecList *partspec_list; - + // get the array of partspec descriptions error = GRrGroup_GetElement( @@ -378,15 +378,15 @@ Imp_AddPartSpecList( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get part spec desc list array"); } - + // get the number of partspec descriptions in the array num_partspecdescs = GRrGroup_Array_GetLength(partspecdesc_array); - + if (num_partspecdescs == 0) { return UUcError_None; } - + // create a partspeclist instance error = TMrConstruction_Instance_Renew( @@ -395,14 +395,14 @@ Imp_AddPartSpecList( num_partspecdescs, &partspec_list); IMPmError_ReturnOnErrorMsg(error, "Could not create a part spec list instance"); - + for (i = 0; i < num_partspecdescs; i++) { GRtGroup *partspecdesc_group; UUtUns32 partspectype; char *partspec; TMtPlaceHolder partspec_ref; - + // get a partspec desc group from the array error = GRrGroup_Array_GetElement( @@ -414,7 +414,7 @@ Imp_AddPartSpecList( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get part spec desc group from array"); } - + // process the elements of the partspec description error = GRrGroup_GetUns32( @@ -422,27 +422,27 @@ Imp_AddPartSpecList( "partspectype", &partspectype); IMPmError_ReturnOnErrorMsg(error, "Unable to get partspectype"); - + error = GRrGroup_GetString( partspecdesc_group, "partspec", &partspec); IMPmError_ReturnOnErrorMsg(error, "Unable to get partspec"); - + // save the information partspec_list->partspec_descs[i].partspec_type = partspectype; - error = + error = TMrConstruction_Instance_GetPlaceHolder( PScTemplate_PartSpecification, partspec, &partspec_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get partspec placeholder"); - + partspec_list->partspec_descs[i].partspec = (void*)partspec_ref; } } - + return UUcError_None; } @@ -457,15 +457,15 @@ Imp_AddPartSpecUI( UUtError error; UUtBool build_instance; - - + + // check to see if the dialogs need to be built build_instance = !TMrConstruction_Instance_CheckExists(PScTemplate_PartSpecUI, inInstanceName); - + if (build_instance) { PStPartSpecUI *partspec_ui; - + // create a partspec_ui instance error = TMrConstruction_Instance_Renew( @@ -474,130 +474,130 @@ Imp_AddPartSpecUI( 0, &partspec_ui); IMPmError_ReturnOnErrorMsg(error, "Could not create a part spec ui instance"); - + error = IMPiAddPartSpecToUI(inGroup, "background", &partspec_ui->background); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "border", &partspec_ui->border); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "title", &partspec_ui->title); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "grow", &partspec_ui->grow); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "close_idle", &partspec_ui->close_idle); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "close_pressed", &partspec_ui->close_pressed); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "zoom_idle", &partspec_ui->zoom_idle); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "zoom_pressed", &partspec_ui->zoom_pressed); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "flatten_idle", &partspec_ui->flatten_idle); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "flatten_pressed", &partspec_ui->flatten_pressed); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "text_caret", &partspec_ui->text_caret); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "outline", &partspec_ui->outline); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "button_off", &partspec_ui->button_off); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); error = IMPiAddPartSpecToUI(inGroup, "default_button", &partspec_ui->default_button); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "button_on", &partspec_ui->button_on); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); error = IMPiAddPartSpecToUI(inGroup, "checkbox_on", &partspec_ui->checkbox_on); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "checkbox_off", &partspec_ui->checkbox_off); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "editfield", &partspec_ui->editfield); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "ef_hasfocus", &partspec_ui->ef_hasfocus); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "hilite", &partspec_ui->hilite); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "divider", &partspec_ui->divider); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "check", &partspec_ui->check); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "popup_menu", &partspec_ui->popup_menu); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "progressbar_track", &partspec_ui->progressbar_track); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "progressbar_fill", &partspec_ui->progressbar_fill); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "radio_button_on", &partspec_ui->radiobutton_on); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "radio_button_off", &partspec_ui->radiobutton_off); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "up_arrow", &partspec_ui->up_arrow); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "up_arrow_pressed", &partspec_ui->up_arrow_pressed); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "dn_arrow", &partspec_ui->dn_arrow); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "dn_arrow_pressed", &partspec_ui->dn_arrow_pressed); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "lt_arrow", &partspec_ui->lt_arrow); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "lt_arrow_pressed", &partspec_ui->lt_arrow_pressed); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "rt_arrow", &partspec_ui->rt_arrow); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "rt_arrow_pressed", &partspec_ui->rt_arrow_pressed); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "sb_thumb", &partspec_ui->sb_thumb); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "sb_v_track", &partspec_ui->sb_v_track); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "sb_h_track", &partspec_ui->sb_h_track); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "sl_thumb", &partspec_ui->sl_thumb); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "sl_track", &partspec_ui->sl_track); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "tab_active", &partspec_ui->tab_active); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); - + error = IMPiAddPartSpecToUI(inGroup, "tab_inactive", &partspec_ui->tab_inactive); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); @@ -607,6 +607,6 @@ Imp_AddPartSpecUI( error = IMPiAddPartSpecToUI(inGroup, "folder", &partspec_ui->folder); IMPmError_ReturnOnErrorMsg(error, "could not get partspec"); } - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_PartSpec.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_PartSpec.h index 9f9fed3..58746be 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_PartSpec.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_PartSpec.h @@ -18,7 +18,7 @@ Imp_AddPartSpec( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + UUtError Imp_AddPartSpecList( BFtFileRef* inSourceFile, @@ -32,6 +32,6 @@ Imp_AddPartSpecUI( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + // ====================================================================== -#endif /* IMP_PARTSPEC_H */ \ No newline at end of file +#endif /* IMP_PARTSPEC_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Particle.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Particle.h index c992c1c..ebc2611 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Particle.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Particle.h @@ -1,13 +1,13 @@ /* FILE: Imp_Particle.h - + AUTHOR: Michael Evans - + CREATED: Dec 10, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -24,7 +24,7 @@ UUtError Imp_AddParticleClass( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + UUtError Imp_AddStreamClass( BFtFileRef* inSourceFile, UUtUns32 inSourceFileModDate, @@ -36,5 +36,5 @@ UUtError Imp_AddLocalPhysicsClass( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + #endif /* IMP_PARTICLE_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Path.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Path.c index 6ec8711..fe4be1e 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Path.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Path.c @@ -1,8 +1,8 @@ /* Imp_Path.c - + This file contains all importer pathfinding related code - + Author: Quinn Dunki c1998 Bungie */ @@ -309,7 +309,7 @@ static UUtBool PHiQuadInBNV(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV *inBNV, // trivially accept quads which have any points inside the BNV for (i = 0; i < 4; i++) { points[i] = sharedPoints[curGQ->visibleQuad.indices[i]]; - + if (IMPiEnv_Process_BSP_PointInBSP(inBuildData, inBNV, &points[i], IMPcQuadInBNVTolerance)) { #if DEBUG_GRID if (IMPgTempDebugGrid) { @@ -374,9 +374,9 @@ static UUtBool PHiQuadInBNV(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV *inBNV, MUmVector_ScaleCopy(intersect_point, d1 / (d1 - d0), points[j]); MUmVector_ScaleIncrement(intersect_point, -d0 / (d1 - d0), points[(j + 1) % 4]); } - UUmAssert(UUmFloat_LooseCompareZero(intersect_point.x * side_plane.a + intersect_point.y * side_plane.b + + UUmAssert(UUmFloat_LooseCompareZero(intersect_point.x * side_plane.a + intersect_point.y * side_plane.b + intersect_point.z * side_plane.c + side_plane.d)); - UUmAssert(UUmFloat_LooseCompareZero(intersect_point.x * quad_plane.a + intersect_point.y * quad_plane.b + + UUmAssert(UUmFloat_LooseCompareZero(intersect_point.x * quad_plane.a + intersect_point.y * quad_plane.b + intersect_point.z * quad_plane.c + quad_plane.d)); for (k = 0; k < side->numBNVQuads; k++) { @@ -398,10 +398,10 @@ static UUtBool PHiQuadInBNV(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV *inBNV, side_quad_points[k] = sharedPoints[side_quad->indices[k]]; d[k] = side_quad_points[k].x * quad_plane.a + side_quad_points[k].y * quad_plane.b + side_quad_points[k].z * quad_plane.c + quad_plane.d; - UUmAssert(UUmFloat_LooseCompareZero(side_quad_points[k].x * side_plane.a + side_quad_points[k].y * side_plane.b + + UUmAssert(UUmFloat_LooseCompareZero(side_quad_points[k].x * side_plane.a + side_quad_points[k].y * side_plane.b + side_quad_points[k].z * side_plane.c + side_plane.d)); } - + for (k = 0; k < 4; k++) { // check the points that make up this edge against the side's plane d0 = d[k]; d1 = d[(k + 1) % 4]; @@ -418,9 +418,9 @@ static UUtBool PHiQuadInBNV(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV *inBNV, MUmVector_ScaleCopy(intersect_point, d1 / (d1 - d0), side_quad_points[k]); MUmVector_ScaleIncrement(intersect_point, -d0 / (d1 - d0), side_quad_points[(k + 1) % 4]); } - UUmAssert(UUmFloat_LooseCompareZero(intersect_point.x * quad_plane.a + intersect_point.y * quad_plane.b + + UUmAssert(UUmFloat_LooseCompareZero(intersect_point.x * quad_plane.a + intersect_point.y * quad_plane.b + intersect_point.z * quad_plane.c + quad_plane.d)); - UUmAssert(UUmFloat_LooseCompareZero(intersect_point.x * side_plane.a + intersect_point.y * side_plane.b + + UUmAssert(UUmFloat_LooseCompareZero(intersect_point.x * side_plane.a + intersect_point.y * side_plane.b + intersect_point.z * side_plane.c + side_plane.d)); if (CLrQuad_PointInQuad(CLcProjection_Unknown, sharedPoints, &curGQ->visibleQuad, &intersect_point)) { @@ -467,7 +467,7 @@ static UUtBool PHiQuadBelowStairs( UUtUns32 i; float d; M3tPoint3D *p; - + for (i=0; i<4; i++) { p = inPoints + inQuad->visibleQuad.indices[i]; @@ -566,7 +566,7 @@ static void PHrRasterizeFloorQuad(IMPtEnv_BuildData *inBuildData, UUtUns32 inGQI #if DEBUG_GRID if (IMPgTempDebugGrid) { Imp_PrintMessage(IMPcMsg_Important, " floor quad %d maps to (%d %d), (%d %d), (%d %d), (%d %d)\n", inGQIndex, - grid_points[0].x, grid_points[0].y, grid_points[1].x, grid_points[1].y, + grid_points[0].x, grid_points[0].y, grid_points[1].x, grid_points[1].y, grid_points[2].x, grid_points[2].y, grid_points[3].x, grid_points[3].y); } #endif @@ -597,7 +597,7 @@ static void PHrRasterizeFloorQuad(IMPtEnv_BuildData *inBuildData, UUtUns32 inGQI static void PHrCreatePathfindingGrid(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV *inBNV, AKtBNVNode *node, AKtEnvironment *env) { - #define PHcMaxRoomSize 250.0f + #define PHcMaxRoomSize 250.0f PHtSquare *srcptr, *destptr; PHtRoomData *room = &node->roomData; UUtUns32 size_of_pathfinding_grid; @@ -650,12 +650,12 @@ static void PHrCreatePathfindingGrid(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV // STEP 1: find the gqs that are intersecting with this BNV IMPrFixedOctTree_Test( - inBuildData, - inBNV->minX - 2.f, - inBNV->maxX + 2.f, - inBNV->minY - 2.f, - inBNV->maxY + 2.f, - inBNV->minZ - 2.f, + inBuildData, + inBNV->minX - 2.f, + inBNV->maxX + 2.f, + inBNV->minY - 2.f, + inBNV->maxY + 2.f, + inBNV->minZ - 2.f, inBNV->maxZ + 2.f); gq_list_size = inBuildData->fixed_oct_tree_temp_list->numPages; @@ -709,8 +709,8 @@ static void PHrCreatePathfindingGrid(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV // no longer needs to be even because byte alignment is not an issue - we are doing RLE instead // room->gridX += room->gridX % 2; -// room->gridY += room->gridY % 2; - +// room->gridY += room->gridY % 2; + PHgTempGridX = room->gridX + 2 * IMPcGridBufferTemp; PHgTempGridY = room->gridY + 2 * IMPcGridBufferTemp; @@ -728,7 +728,7 @@ static void PHrCreatePathfindingGrid(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV isStairs = UUcFalse; stair_plane = NULL; } - + // STEP 3: initialize the temporary grid to PHcDanger - as AIs should never, ever be // walking anywhere that there's no floor UUrMemory_Set8(PHgTempGrid, PHcDanger, size_of_pathfinding_grid * sizeof(PHtSquare)); @@ -806,9 +806,9 @@ static void PHrCreatePathfindingGrid(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV current_quad = gq->visibleQuad; Imp_PrintMessage(IMPcMsg_Important, "checking gq #%d as floor, (%f %f %f) (%f %f %f), (%f %f %f), (%f %f %f)\n", gq_index, - points[current_quad.indices[0]].x, points[current_quad.indices[0]].y, points[current_quad.indices[0]].z, - points[current_quad.indices[1]].x, points[current_quad.indices[1]].y, points[current_quad.indices[1]].z, - points[current_quad.indices[2]].x, points[current_quad.indices[2]].y, points[current_quad.indices[2]].z, + points[current_quad.indices[0]].x, points[current_quad.indices[0]].y, points[current_quad.indices[0]].z, + points[current_quad.indices[1]].x, points[current_quad.indices[1]].y, points[current_quad.indices[1]].z, + points[current_quad.indices[2]].x, points[current_quad.indices[2]].y, points[current_quad.indices[2]].z, points[current_quad.indices[3]].x, points[current_quad.indices[3]].y, points[current_quad.indices[3]].z); } #endif @@ -835,9 +835,9 @@ static void PHrCreatePathfindingGrid(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV current_quad = gq->visibleQuad; Imp_PrintMessage(IMPcMsg_Important, "gq #%d is danger, (%f %f %f) (%f %f %f), (%f %f %f), (%f %f %f)\n", gq_index, - points[current_quad.indices[0]].x, points[current_quad.indices[0]].y, points[current_quad.indices[0]].z, - points[current_quad.indices[1]].x, points[current_quad.indices[1]].y, points[current_quad.indices[1]].z, - points[current_quad.indices[2]].x, points[current_quad.indices[2]].y, points[current_quad.indices[2]].z, + points[current_quad.indices[0]].x, points[current_quad.indices[0]].y, points[current_quad.indices[0]].z, + points[current_quad.indices[1]].x, points[current_quad.indices[1]].y, points[current_quad.indices[1]].z, + points[current_quad.indices[2]].x, points[current_quad.indices[2]].y, points[current_quad.indices[2]].z, points[current_quad.indices[3]].x, points[current_quad.indices[3]].y, points[current_quad.indices[3]].z); } #endif @@ -863,9 +863,9 @@ static void PHrCreatePathfindingGrid(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV current_quad = gq->visibleQuad; Imp_PrintMessage(IMPcMsg_Important, "gq #%d is impassable, (%f %f %f) (%f %f %f), (%f %f %f), (%f %f %f)\n", gq_index, - points[current_quad.indices[0]].x, points[current_quad.indices[0]].y, points[current_quad.indices[0]].z, - points[current_quad.indices[1]].x, points[current_quad.indices[1]].y, points[current_quad.indices[1]].z, - points[current_quad.indices[2]].x, points[current_quad.indices[2]].y, points[current_quad.indices[2]].z, + points[current_quad.indices[0]].x, points[current_quad.indices[0]].y, points[current_quad.indices[0]].z, + points[current_quad.indices[1]].x, points[current_quad.indices[1]].y, points[current_quad.indices[1]].z, + points[current_quad.indices[2]].x, points[current_quad.indices[2]].y, points[current_quad.indices[2]].z, points[current_quad.indices[3]].x, points[current_quad.indices[3]].y, points[current_quad.indices[3]].z); } #endif @@ -897,7 +897,7 @@ static void PHrCreatePathfindingGrid(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV if (UUrBitVector_TestBit(outside_bv, itr)) continue; - if (gq->flags & AKcGQ_Flag_SAT_Mask) { + if (gq->flags & AKcGQ_Flag_SAT_Mask) { PHrChooseAndWeightQuad(inBuildData, gq_index, env, room); } } @@ -969,7 +969,7 @@ void PHrCreateRoomData(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV *inBNV, AKtBN } UUrMemory_Clear(room, sizeof(*room)); - + room->origin = inBNV->origin; room->antiOrigin = inBNV->antiOrigin; room->compressed_grid = NULL; @@ -981,7 +981,7 @@ void PHrCreateRoomData(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV *inBNV, AKtBN // gox and goy are offsets that are added to grid-space to get worldspace coordinates relative // to the BNV. room->gox = room->goy = -IMPcGridBuffer; - room->gridX = (UUtUns32)((room->antiOrigin.x - room->origin.x) / room->squareSize) - 2*room->gox + 1; + room->gridX = (UUtUns32)((room->antiOrigin.x - room->origin.x) / room->squareSize) - 2*room->gox + 1; room->gridY = (UUtUns32)((room->antiOrigin.z - room->origin.z) / room->squareSize) - 2*room->gox + 1; if (node->flags & AKcBNV_Flag_NonAI) { @@ -993,7 +993,7 @@ void PHrCreateRoomData(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV *inBNV, AKtBN if (node->flags & AKcBNV_Flag_SimplePathfinding) { goto exit; } - + PHrCreatePathfindingGrid(inBuildData, inBNV, node, env); @@ -1031,7 +1031,7 @@ static void PHiFindSATs(AKtEnvironment *inEnvironment, IMPtEnv_BuildData *inBuil // this stops us from mistakenly getting two up SATs or whatever in BNVs that touch // each other AUrQuad_LowestPoints(&gq->visibleQuad, inEnvironment->pointArray->points, &p0, &p1); - + if ((inNode->roomData.origin.x - p0->x > IMPcSAT_InsideBNVTolerance) || (p0->x - inNode->roomData.antiOrigin.x > IMPcSAT_InsideBNVTolerance) || (inNode->roomData.origin.x - p1->x > IMPcSAT_InsideBNVTolerance) || @@ -1307,9 +1307,9 @@ static UUtBool PHiQuadInRoom( /****************** * Returns true if any of the points are in the room (not just the BNV) */ - + UUtUns32 i; - + for (i=0; i<4; i++) { if (PHrPointInRoom(inEnv,inRoom,inPoints + inQuad->visibleQuad.indices[i])) return UUcTrue; @@ -1319,9 +1319,9 @@ static UUtBool PHiQuadInRoom( } void PHrChooseAndWeightQuad( - IMPtEnv_BuildData *inBuildData, - UUtUns32 gqIndex, - AKtEnvironment *env, + IMPtEnv_BuildData *inBuildData, + UUtUns32 gqIndex, + AKtEnvironment *env, PHtRoomData *room) { /*************** @@ -1340,7 +1340,7 @@ void PHrChooseAndWeightQuad( o = &room->origin; points = env->pointArray->points; if (gunk->flags & (AKcGQ_Flag_SAT_Up | AKcGQ_Flag_SAT_Down)) isSAT = UUcTrue; - + /* CB: this is irrelevant now, stair BNVs are not rasterized as normal @@ -1352,8 +1352,8 @@ void PHrChooseAndWeightQuad( AKmPlaneEqu_GetComponents( gunk->planeEquIndex, env->planeArray->planes, planeA, planeB, planeC, planeD); - - + + // Eliminate curbs from collision if (UUmFloat_CompareEqu(planeB,0) && (float)fabs(gunk->hi1->y - o->y) < 4.0f && @@ -1376,7 +1376,7 @@ void PHrChooseAndWeightQuad( // If this quad can be walked on and is on the floor, skip it. if ((float)fabs(planeB) > PHcFlatNormal && (float)fabs(gunk->lo1->y - o->y)<4.0 && (float)fabs(gunk->hi1->y - o->y)<4.0) return; - + // If this quad is entirely below the floor, then skip it if (gunk->hi1->y <= o->y && gunk->hi2->y <= o->y) return; @@ -1402,7 +1402,7 @@ void PHrChooseAndWeightQuad( return; #endif } - + // If this quad is vertical, short and touching the floor, skip it // (Makes curbs work) if ((float)fabs(gunk->hi1->y - gunk->lo1->y) < 4.0f && @@ -1440,8 +1440,8 @@ void PHrChooseAndWeightQuad( void PHrRasterizeSlopedQuad( - IMPtEnv_GQ *gunk, - AKtEnvironment *env, + IMPtEnv_GQ *gunk, + AKtEnvironment *env, PHtRoomData *room) { /*************************** @@ -1477,7 +1477,7 @@ void PHrRasterizeSlopedQuad( t1 = gunk->hi2; t2 = gunk->hi1; } - + /* if (IMPgTempDebugGrid) { Imp_PrintMessage(IMPcMsg_Important, "sloping quad in room origin %f %f %f\n", o->x, o->y, o->z); Imp_PrintMessage(IMPcMsg_Important, " st: %f %f %f\n", st->x, st->y, st->z); @@ -1499,7 +1499,7 @@ void PHrRasterizeSlopedQuad( ex1.y = ex2.y = 0.0f; length = MUrPoint_Distance(&ex1,&ex2); step = PHcSquareSize-1.0f; - + // Step up the quad until the point of no return is found while (step < length) { @@ -1511,19 +1511,19 @@ void PHrRasterizeSlopedQuad( if (!MUmPoint_Compare(*t2,*ed)) MUrVector_SetLength(&edge2,step); MUmVector_Increment(ex1,edge1); MUmVector_Increment(ex2,edge2); - + if ((float)fabs(ex1.y - o->y) > IMPcWalkUnderHeight || (float)fabs(ex2.y - o->y) > IMPcWalkUnderHeight) break; step += PHcSquareSize; } - + // Rasterize out to that point IMPmGetGridPoint(p1, ex1, room); IMPmGetGridPoint(p2, *st, room); PHrBresenhamAA(p1.x, p1.y, p2.x, p2.y, PHgTempGrid,PHgTempGridX,PHgTempGridY,&fill,&blend,callback); - + IMPmGetGridPoint(p1, ex2, room); IMPmGetGridPoint(p2, *ed, room); @@ -1555,7 +1555,7 @@ void PHrRasterizeSlopedQuad( } } #endif*/ - + overhang_height = o->y + IMPcWalkUnderHeight; /* if (IMPgTempDebugGrid) { @@ -1869,12 +1869,12 @@ void PHrRasterizeSlopedQuad( } void PHrFatDot( - UUtUns16 x, - UUtUns16 y, - PHtSquare *grid, - UUtInt32 inWidth, + UUtUns16 x, + UUtUns16 y, + PHtSquare *grid, + UUtInt32 inWidth, UUtInt32 inHeight, - PHtRasterizationCallback callback) + PHtRasterizationCallback callback) { /************** * Draws a fat dot in the grid at (x,y), clipping that @@ -1887,12 +1887,12 @@ void PHrFatDot( PHtSquare tight = { PHcSemiPassable }; PHmFatDot_PutCell(x,y,&blocked,callback); - + PHmFatDot_PutCell(x-1,y,&tight,callback); PHmFatDot_PutCell(x+1,y,&tight,callback); PHmFatDot_PutCell(x,y-1,&tight,callback); PHmFatDot_PutCell(x,y+1,&tight,callback); - + PHmFatDot_PutCell(x-1,y-1,&tight,callback); PHmFatDot_PutCell(x+1,y-1,&tight,callback); PHmFatDot_PutCell(x+1,y+1,&tight,callback); @@ -1905,17 +1905,17 @@ void IMPiCalculateNodeOrigins(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV *inNod /******************* * Calculates the upper left and bottom right corners of the node */ - + float low1,low2,low3,ly; IMPtEnv_BNV_Side* curSide; M3tQuad *quad; M3tPoint3D *points = AUrSharedPointArray_GetList(inBuildData->sharedPointArray); M3tQuad *quads = AUrSharedQuadArray_GetList(inBuildData->sharedBNVQuadArray); UUtUns16 q,c,curSideIndex; - + // Find the origin of the node by looking for the bottom-upper-left corner of the BNV low1 = low2 = low3 = 1e9; - + for(curSideIndex = 0, curSide = inNode->sides; curSideIndex < inNode->numSides; curSideIndex++, curSide++) @@ -1923,7 +1923,7 @@ void IMPiCalculateNodeOrigins(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV *inNod for (q = 0; q < curSide->numBNVQuads; q++) { quad = &quads[curSide->bnvQuadList[q]]; - + for (c=0; c<4; c++) { ly = points[quad->indices[c]].x; @@ -1947,10 +1947,10 @@ void IMPiCalculateNodeOrigins(IMPtEnv_BuildData *inBuildData, IMPtEnv_BNV *inNod } } } - + // Find the opposite corner of the node (upper-top-right corner of the BNV) low1 = low2 = low3 = -1e9; - + for(curSideIndex = 0, curSide = inNode->sides; curSideIndex < inNode->numSides; curSideIndex++, curSide++) @@ -1990,7 +1990,7 @@ static void PHrMarkBorderValues(UUtUns8 inBaseValue, UUtUns8 inSeedValue, UUtUns for(y = 0; y < PHgTempGridY; y++) { - for(x = 0; x < PHgTempGridX; x++) + for(x = 0; x < PHgTempGridX; x++) { if (scan_line[x].weight == inSeedValue) { diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Path.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Path.h index c34172d..d8a2752 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Path.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Path.h @@ -1,8 +1,8 @@ /* Imp_Path.h - + This file contains all pathfinding header stuff - + Author: Quinn Dunki c1998 Bungie */ @@ -10,20 +10,20 @@ #include "Oni_Path.h" void PHrChooseAndWeightQuad( - IMPtEnv_BuildData *inBuildData, - UUtUns32 gqIndex, - AKtEnvironment *env, + IMPtEnv_BuildData *inBuildData, + UUtUns32 gqIndex, + AKtEnvironment *env, PHtRoomData *room); void PHrFatDot( - UUtUns16 x, - UUtUns16 y, - PHtSquare *grid, - UUtInt32 inWidth, + UUtUns16 x, + UUtUns16 y, + PHtSquare *grid, + UUtInt32 inWidth, UUtInt32 inHeight, PHtRasterizationCallback callback); void PHrRasterizeSlopedQuad( - IMPtEnv_GQ *gunk, - AKtEnvironment *env, + IMPtEnv_GQ *gunk, + AKtEnvironment *env, PHtRoomData *room); diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sky.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sky.c index 95b0fe3..dff6e87 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sky.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sky.c @@ -70,7 +70,7 @@ UUtError Imp_AddSky( { sky->skybox[M3cSkyFront] = M3rTextureMap_GetPlaceholder(temp_name); UUmAssert(sky->skybox[M3cSkyFront]); - } + } error = GRrGroup_GetString(inGroup, "back", &temp_name); if( error == UUcError_None ) diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sky.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sky.h index 3d91e08..9fe5b55 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sky.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sky.h @@ -5,8 +5,8 @@ CREATED: Sept 3, 1997 - PURPOSE: - + PURPOSE: + Copyright 1997 */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound.c index d56c8f2..a921efb 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound.c @@ -1 +1 @@ -// obsolete \ No newline at end of file +// obsolete diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound.h index d56c8f2..a921efb 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound.h @@ -1 +1 @@ -// obsolete \ No newline at end of file +// obsolete diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound2.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound2.c index f3aecaa..78f52fa 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound2.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound2.c @@ -30,7 +30,7 @@ IMPiIsAIFFFile( { char *extension; const char *leaf_name; - + leaf_name = BFrFileRef_GetLeafName(inFileRef); extension = strrchr(leaf_name, '.'); if (UUrString_Compare_NoCase(extension, ".aiff") == 0) @@ -45,7 +45,7 @@ IMPiIsAIFFFile( { return UUcTrue; } - + return UUcFalse; } @@ -56,14 +56,14 @@ IMPiIsWavFile( { char *extension; const char *leaf_name; - + leaf_name = BFrFileRef_GetLeafName(inFileRef); extension = strrchr(leaf_name, '.'); if (UUrString_Compare_NoCase(extension, ".wav") == 0) { return UUcTrue; } - + return UUcFalse; } @@ -80,7 +80,7 @@ IMPiLoadCallback_AllocSoundData_ImportTime( UUrString_Copy(instance_name, BFrFileRef_GetLeafName(inFileRef), BFcMaxFileNameLength); UUrString_MakeLowerCase(instance_name, BFcMaxFileNameLength); - error = + error = TMrConstruction_Instance_Renew( SScTemplate_SoundData, instance_name, @@ -100,11 +100,11 @@ IMPiLoadCallback_SoundStoreData( UUtError error; char instance_name[BFcMaxFileNameLength]; SStSoundData *sound_data; - + // make the instance name UUrString_Copy(instance_name, inSoundName, BFcMaxFileNameLength); UUrString_MakeLowerCase(instance_name, BFcMaxFileNameLength); - + // create the template instance error = TMrConstruction_Instance_Renew( @@ -113,7 +113,7 @@ IMPiLoadCallback_SoundStoreData( 0, &sound_data); UUmError_ReturnOnError(error); - + // copy inSoundData into the sound_data UUrMemory_MoveFast(inSoundData, sound_data, sizeof(SStSoundData)); @@ -126,13 +126,13 @@ IMPiLoadCallback_SoundStoreData( if (sound_data->data == NULL) { return UUcError_Generic; } - + // copy inSoundData data into sound_data data UUrMemory_MoveFast(inSoundData->data, sound_data->data, inSoundData->num_bytes); - + // save the sound data sound_data->data = TMrConstruction_Raw_Write(sound_data->data); - + return UUcError_None; } @@ -143,9 +143,9 @@ IMPiProcess_SoundData_File( { UUtError error; SStSoundData *sound_data; - + Imp_PrintMessage(IMPcMsg_Important, "\t\tsoundFileName: %s"UUmNL, BFrFileRef_GetLeafName(inFileRef)); - + // load the sound data from file error = SSrSoundData_Load( @@ -153,7 +153,7 @@ IMPiProcess_SoundData_File( IMPiLoadCallback_SoundStoreData, &sound_data); IMPmError_ReturnOnError(error); - + // dispose of the sound data if (sound_data != NULL) { @@ -164,7 +164,7 @@ IMPiProcess_SoundData_File( UUrMemory_Block_Delete(sound_data); sound_data = NULL; } - + return UUcError_None; } @@ -175,22 +175,22 @@ IMPiProcess_SoundData_Directory( { UUtError error; BFtFileIterator *file_iterator; - + UUmAssert(inDirRef); - + // create a directory iterator error = BFrDirectory_FileIterator_New(inDirRef, NULL, NULL, &file_iterator); IMPmError_ReturnOnError(error); - + // process all of the files in the directory while (1) { BFtFileRef file_ref; - + // get the next file error = BFrDirectory_FileIterator_Next(file_iterator, &file_ref); if (error != UUcError_None) { break; } - + if (BFrFileRef_IsDirectory(&file_ref) == UUcTrue) { // process the directory @@ -206,16 +206,16 @@ IMPiProcess_SoundData_Directory( // process the file IMPiProcess_SoundData_File(&file_ref); } - - - IMPmError_ReturnOnError(error); + + + IMPmError_ReturnOnError(error); continue; } - + // delete the file iterator BFrDirectory_FileIterator_Delete(file_iterator); file_iterator = NULL; - + return UUcError_None; } @@ -227,22 +227,22 @@ IMPiProcess_SoundDirectory( { UUtError error; BFtFileIterator *file_iterator; - + // build a file iterator error = BFrDirectory_FileIterator_New(inDirRef, NULL, NULL, &file_iterator); IMPmError_ReturnOnErrorMsg(error, "Unable to create file iterator for directory"); - + // loop over the entire directory while (1) { BFtFileRef file_ref; UUtBool result; UUtUns32 index; - + // get a file ref error = BFrDirectory_FileIterator_Next(file_iterator, &file_ref); if (error != UUcError_None) { break; } - + // determine if this is a file or directory if (BFrFileRef_IsDirectory(&file_ref) == UUcTrue) { @@ -251,20 +251,20 @@ IMPiProcess_SoundDirectory( else if (strcmp(BFrFileRef_GetSuffixName(&file_ref), "aif") == 0) { char file_name[BFcMaxPathLength]; - + // make the name lowercase UUrString_Copy(file_name, BFrFileRef_GetLeafName(&file_ref), BFcMaxPathLength); UUrString_MakeLowerCase(file_name, BFcMaxPathLength); - + // determine if the file is in the list result = AUrSharedStringArray_GetIndex(inFileNameList, file_name, &index); if (result == UUcFalse) { continue; } - + // process the file IMPiProcess_SoundData_File(&file_ref); } } - + return UUcError_None; } @@ -278,18 +278,18 @@ IMPiProcess_FileList( AUtSharedStringArray *string_array; UUtUns32 num_elements; UUtUns32 itr; - + // build a shared string list from the file list string_array = AUrSharedStringArray_New(); UUmError_ReturnOnNull(string_array); - + num_elements = GRrGroup_Array_GetLength(inFileList); for (itr = 0; itr < num_elements; itr++) { UUtUns32 index; char *string; GRtElementType element_type; - + // get the element from the array error = GRrGroup_Array_GetElement( @@ -302,9 +302,9 @@ IMPiProcess_FileList( Imp_PrintWarning("Unable to get element from file list array"); continue; } - + UUrString_MakeLowerCase(string, BFcMaxFileNameLength); - + // add the file name to the list error = AUrSharedStringArray_AddString( @@ -318,11 +318,11 @@ IMPiProcess_FileList( continue; } } - + // process the directory error = IMPiProcess_SoundDirectory(inDirRef, string_array); - UUmError_ReturnOnErrorMsg(error, "Unable to process the sound directory"); - + UUmError_ReturnOnErrorMsg(error, "Unable to process the sound directory"); + return UUcError_None; } @@ -338,10 +338,10 @@ IMPrImport_AddSound2( BFtFileRef *dir_ref; GRtElementArray *file_list_array; GRtElementType element_type; - + // don't process sounds if (IMPgNoSound == UUcTrue) { return UUcError_None; } - + // get the file list file_list_array = NULL; error = @@ -357,15 +357,15 @@ IMPrImport_AddSound2( else if ((file_list_array != NULL) && (element_type == GRcElementType_Array)) { char *dir_name; - + // get the name of the directory the aif's are in. It can have sub-folders error = GRrGroup_GetString(inGroup, "folder", &dir_name); IMPmError_ReturnOnErrorMsg(error, "Unable to get the directory name"); - + // create a dir ref error = BFrFileRef_DuplicateAndReplaceName(inSourceFileRef, dir_name, &dir_ref); IMPmError_ReturnOnErrorMsg(error, "Unable to create directory reference."); - + // process the file list error = IMPiProcess_FileList(dir_ref, file_list_array); IMPmError_ReturnOnErrorMsg(error, "Unable to process the aiff list"); @@ -375,15 +375,15 @@ IMPrImport_AddSound2( // create a dir ref error = BFrFileRef_DuplicateAndReplaceName(inSourceFileRef, inInstanceName, &dir_ref); IMPmError_ReturnOnErrorMsg(error, "Unable to create directory reference."); - + // process the sound data directory error = IMPiProcess_SoundData_Directory(dir_ref); IMPmError_ReturnOnErrorMsg(error, "Error processing sound data"); } - + // delete the directory ref UUrMemory_Block_Delete(dir_ref); - + return UUcError_None; } @@ -407,11 +407,11 @@ Imp_Process_SoundBin( &data_length, &data); IMPmError_ReturnOnErrorMsg(error, "Unable to load binary file into memory"); - + if (data_length > 0) { OStBinaryData *binary_data; - + // create an instance of a binary data template error = TMrConstruction_Instance_Renew( @@ -420,23 +420,23 @@ Imp_Process_SoundBin( 0, &binary_data); IMPmError_ReturnOnErrorMsg(error, "Unable to create dialog data instance"); - + // copy the file data into the raw template data separate_data = TMrConstruction_Separate_New(data_length, OScTemplate_SoundBinaryData); UUrMemory_MoveFast(data, separate_data, data_length); - + binary_data->data_size = data_length; binary_data->data_index = (TMtSeparateFileOffset) TMrConstruction_Separate_Write(separate_data); - + Imp_PrintMessage(IMPcMsg_Important, "\tsoundBinaryFileName: %s"UUmNL, curFileName); } - + // dispose of the allocated memory if (data != NULL) { UUrMemory_Block_Delete(data); } - + return UUcError_None; } @@ -451,15 +451,15 @@ IMPiImport_SoundBins( // create a file iterator error = BFrDirectory_FileIterator_New(inDirectoryRef, NULL, NULL, &file_iterator); UUmError_ReturnOnErrorMsg(error, "Unable to make a file iterator."); - + while (1) { BFtFileRef ref; - + // get the next ref error = BFrDirectory_FileIterator_Next(file_iterator, &ref); if (error != UUcError_None) { break; } - + if (BFrFileRef_IsDirectory(&ref) == UUcTrue) { error = IMPiImport_SoundBins(&ref); @@ -468,7 +468,7 @@ IMPiImport_SoundBins( else { const char *file_ext; - + file_ext = BFrFileRef_GetSuffixName(&ref); if ((UUrString_Compare_NoCase(file_ext, OScAmbientSuffix) == 0) || (UUrString_Compare_NoCase(file_ext, OScGroupSuffix) == 0) || @@ -479,10 +479,10 @@ IMPiImport_SoundBins( } } } - + BFrDirectory_FileIterator_Delete(file_iterator); file_iterator = NULL; - + return UUcError_None; } @@ -496,18 +496,18 @@ IMPrImport_AddSoundBin( { UUtError error; BFtFileRef *dir_ref; - + // get the parent directory error = BFrFileRef_GetParentDirectory(inSourceFileRef, &dir_ref); UUmError_ReturnOnErrorMsg(error, "Unable to get the files parent directory"); UUmAssert(BFrFileRef_IsDirectory(dir_ref)); - + // import all of the sound bin files in the hierarchy starting at dir_ref IMPiImport_SoundBins(dir_ref); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + return UUcError_None; } @@ -534,11 +534,11 @@ IMPrImport_AddSubtitles( // ok read the file { BFtTextFile *text_file; - + error = Imp_Common_GetFileRefAndModDate(inSourceFileRef, inGroup, "file", &file_ref); if (error) { return error; } - // ok, now we need to read the file, line by line + // ok, now we need to read the file, line by line error = BFrTextFile_MapForRead(file_ref, &text_file); if (error) { return error; } @@ -547,7 +547,7 @@ IMPrImport_AddSubtitles( char *subtitle_instance = BFrTextFile_GetNextStr(text_file); char *subtitle_text = BFrTextFile_GetNextStr(text_file); char *end_marker = BFrTextFile_GetNextStr(text_file); - + if ((NULL == subtitle_instance) || (NULL == subtitle_text) || (NULL == end_marker)) { diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound2.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound2.h index e16546d..75c6b2f 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound2.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Sound2.h @@ -35,6 +35,6 @@ IMPrImport_AddSubtitles( GRtGroup* inGroup, char* inInstanceName); - + // ====================================================================== -#endif /* IMP_SOUND2_H */ \ No newline at end of file +#endif /* IMP_SOUND2_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Texture.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Texture.c index 1de3845..f4bd274 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Texture.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Texture.c @@ -1,12 +1,12 @@ /* FILE: Imp_Texture.c - + AUTHOR: Brent H. Pease - + CREATED: August 14, 1997 - + PURPOSE: Header file for the BMP file format - + Copyright 1997 */ @@ -24,7 +24,7 @@ #include "Imp_Texture.h" #include "Imp_TextureFlags.h" -UUtUns16 gSizeTable[9][9] = +UUtUns16 gSizeTable[9][9] = { {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, @@ -64,7 +64,7 @@ Imp_AddTexture( BFtFileRef* file; char mungedInstanceName[BFcMaxFileNameLength]; tTextureFlags flags; - + error = Imp_Common_GetFileRefAndModDate( inSourceFileRef, @@ -72,10 +72,10 @@ Imp_AddTexture( "file", &file); IMPmError_ReturnOnErrorMsg(error, "Could not get file name"); - + UUrString_Copy(mungedInstanceName, inInstanceName, BFcMaxFileNameLength); UUrString_StripExtension(mungedInstanceName); - + // setup default flags Imp_ClearTextureFlags(&flags); flags.flags = 0; @@ -83,7 +83,7 @@ Imp_AddTexture( flags.hasFlagFile = cTextureFlagFile_No; Imp_ProcessTextureFlags(inGroup, mungedInstanceName, &flags); - + error = Imp_ProcessTexture(file, 0, &flags, NULL, mungedInstanceName, IMPcIgnoreTextureRef); BFrFileRef_Dispose(file); @@ -145,9 +145,9 @@ static UUtError iIsValidTextureMapSize(UUtUns32 inWidth, UUtUns32 inHeight) } static UUtError iMakeAnimFrameFileRef( - BFtFileRef *inDirectoryRef, + BFtFileRef *inDirectoryRef, char *inBaseName, - UUtUns16 itr, + UUtUns16 itr, char *suffixName, BFtFileRef **outFileRef) { @@ -157,9 +157,9 @@ static UUtError iMakeAnimFrameFileRef( BFtFileRef *frameFileRef; UUtBool retry; const char* dirLeafName; - + dirLeafName = BFrFileRef_GetLeafName(inDirectoryRef); - + do { retry = UUcFalse; @@ -168,8 +168,8 @@ static UUtError iMakeAnimFrameFileRef( inBaseName, itr + 1, suffixName); - - error = + + error = BFrFileRef_DuplicateAndAppendName( inDirectoryRef, frameName1, @@ -185,8 +185,8 @@ static UUtError iMakeAnimFrameFileRef( inBaseName, itr + 1, suffixName); - - error = + + error = BFrFileRef_DuplicateAndAppendName( inDirectoryRef, frameName2, @@ -194,7 +194,7 @@ static UUtError iMakeAnimFrameFileRef( UUmError_ReturnOnErrorMsg(error, "could not create file ref for anim frame"); } - if (!BFrFileRef_FileExists(frameFileRef)) + if (!BFrFileRef_FileExists(frameFileRef)) { BFrFileRef_Dispose(frameFileRef); frameFileRef = NULL; @@ -287,14 +287,14 @@ Imp_ProcessTextureAnimation( IMPcUniqueTextureName, &frameTexture); UUmError_ReturnOnErrorMsg(error, "failed to read anim frame"); - + BFrFileRef_Dispose(frameFileRef); - + animation->maps[itr] = frameTexture; } - + BFrFileRef_Dispose(animDirectoryRef); - + *outTextureAnimationRef = animation; return UUcError_None; @@ -360,7 +360,7 @@ static void iUpdateTextureSizeTable(const M3tTextureMap *inTexture) { if (gNumInvalidTextures < cMaxInvalidTextures) { tInvalidTextureInfo *new_invalid_texture; - + new_invalid_texture = gInvalidTextureInfo + gNumInvalidTextures; gNumInvalidTextures++; @@ -368,7 +368,7 @@ static void iUpdateTextureSizeTable(const M3tTextureMap *inTexture) new_invalid_texture->texelType = inTexture->texelType; new_invalid_texture->width = inTexture->width; - new_invalid_texture->height = inTexture->height; + new_invalid_texture->height = inTexture->height; } } @@ -387,7 +387,7 @@ Imp_ProcessTexture( { UUtError error; M3tTextureMap* textureMap; - + UUtUns16 width; UUtUns16 height; IMtMipMap mipMap; @@ -396,17 +396,17 @@ Imp_ProcessTexture( UUtUns32 imageBytes; UUtUns32 totalMapBytes; - + UUtBool buildInstance; - + const char* leafName; UUtBool fileExists; tTextureFlags local_flags; IMtPixelType pixel_type; - + FFtFileInfo file_info; - + BFtFileRef* localFrameRef; BFtFileRef* ddsFrameRef = NULL; char suffixName[BFcMaxFileNameLength]; @@ -414,7 +414,7 @@ Imp_ProcessTexture( if (inInstanceName) { char* cp; - + cp = strchr(inInstanceName, '.'); UUmAssert(cp == NULL); } @@ -424,29 +424,29 @@ Imp_ProcessTexture( // Imp_PrintMessage(IMPcMsg_Critical, "**** creating texture %s"UUmNL, name); } - + // copy the default flags local_flags = *inDefaultTextureFlags; - - do + + do { leafName = BFrFileRef_GetLeafName(inFileRef); fileExists = BFrFileRef_FileExists(inFileRef); - + if(!fileExists) { // try to add .bmp extension first BFrFileRef_SetLeafNameSuffex(inFileRef, "BMP"); fileExists = BFrFileRef_FileExists(inFileRef); } - + if(!fileExists) { // try to add .psd extension next BFrFileRef_SetLeafNameSuffex(inFileRef, "PSD"); fileExists = BFrFileRef_FileExists(inFileRef); } - + if(!fileExists) { AUtMB_ButtonChoice choice = AUrMessageBox(AUcMBType_AbortRetryIgnore, "Could not find file %s."UUmNL, leafName); @@ -473,30 +473,30 @@ Imp_ProcessTexture( { buildInstance = UUcFalse; } - + if(buildInstance != UUcTrue) { return UUcError_None; } - + // process the flags file Imp_ProcessTextureFlags_FromFileRef(inFileRef, &local_flags); - + // Set the first frame localFrameRef = inFileRef; - + if((local_flags.flags & M3cTextureFlags_PixelType) && IMrPixelType_HasAlpha(local_flags.pixelType)) { // get the suffix name UUrString_Copy(suffixName, BFrFileRef_GetSuffixName(inFileRef), BFcMaxFileNameLength); UUrString_Capitalize(suffixName, BFcMaxFileNameLength); - + if(strcmp(suffixName, "PSD")) { BFrFileRef_SetLeafNameSuffex(localFrameRef, "PSD"); } - } + } else { UUtBool compressed; @@ -531,7 +531,7 @@ Imp_ProcessTexture( localFrameRef = ddsFrameRef; } else { - Imp_PrintWarning("file %s is newer then %s", + Imp_PrintWarning("file %s is newer then %s", BFrFileRef_GetLeafName(localFrameRef), BFrFileRef_GetLeafName(ddsFrameRef)); @@ -541,13 +541,13 @@ Imp_ProcessTexture( } - + // get the file info error = FFrPeek_2D(localFrameRef, &file_info); UUmError_ReturnOnErrorMsgP(error, "failed to get file info on %s", (UUtUns32) BFrFileRef_GetLeafName(localFrameRef), 0, 0); - + // XXX - ONE DAY MAKE SURE WE HANDLE DDS ALPHA CORRECTLY - + switch(file_info.format) { case FFcFormat_2D_PSD: @@ -571,7 +571,7 @@ Imp_ProcessTexture( width = width >> inReduceAmount; height = height >> inReduceAmount; - + // set the pixel type if (local_flags.flags & M3cTextureFlags_PixelType) { @@ -590,16 +590,16 @@ Imp_ProcessTexture( { local_flags.pixelType = pixel_type; } - + if (local_flags.flags & M3cTextureFlags_HasMipMap) { - totalMapBytes = IMrImage_ComputeSize(pixel_type, IMcHasMipMap, width, height); - } + totalMapBytes = IMrImage_ComputeSize(pixel_type, IMcHasMipMap, width, height); + } else { totalMapBytes = IMrImage_ComputeSize(pixel_type, IMcNoMipMap, width, height); } - + /* * Create the texture map instance */ @@ -612,7 +612,7 @@ Imp_ProcessTexture( IMPmError_ReturnOnError(error); strncpy(textureMap->debugName, "imported unique texture", 128); } - else + else { error = TMrConstruction_Instance_Renew( @@ -623,7 +623,7 @@ Imp_ProcessTexture( IMPmError_ReturnOnError(error); strncpy(textureMap->debugName, inInstanceName, 128); } - + textureMap->flags = local_flags.flags; textureMap->texelType = pixel_type; textureMap->width = width; @@ -642,16 +642,16 @@ Imp_ProcessTexture( #else separateData = TMrConstruction_Separate_New(totalMapBytes, M3cTemplate_TextureMap); #endif - + if (!BFrFileRef_FileExists(localFrameRef)) { - UUmError_ReturnOnErrorMsgP(UUcError_Generic, "File %s does not exist.", + UUmError_ReturnOnErrorMsgP(UUcError_Generic, "File %s does not exist.", (UUtUns32) BFrFileRef_GetLeafName(inFileRef), 0, 0); } // read the image data UUrMemory_Block_VerifyList(); - error = + error = FFrRead_2D_Reduce( localFrameRef, pixel_type, @@ -661,27 +661,27 @@ Imp_ProcessTexture( &height, &mipMap, &imageData); - UUmError_ReturnOnErrorMsgP(error, "File %s could not be read.", + UUmError_ReturnOnErrorMsgP(error, "File %s could not be read.", (UUtUns32) BFrFileRef_GetLeafName(localFrameRef), 0, 0); UUrMemory_Block_VerifyList(); // no means no - if (0 == (local_flags.flags & M3cTextureFlags_HasMipMap)) + if (0 == (local_flags.flags & M3cTextureFlags_HasMipMap)) { mipMap = IMcNoMipMap; } - + error = iIsValidTextureMapSize(width, height); if(error != UUcError_None) { - Imp_PrintWarning("File %s had an invalid texture map size (%d,%d)"UUmNL"(1 to 256 and 8x1 ratio only)", + Imp_PrintWarning("File %s had an invalid texture map size (%d,%d)"UUmNL"(1 to 256 and 8x1 ratio only)", BFrFileRef_GetLeafName(inFileRef), width, height); return error; } - + /* * Copy the image into the texture map */ @@ -693,7 +693,7 @@ Imp_ProcessTexture( if (separateData != NULL) { UUrMemory_MoveFast(imageData, separateData, imageBytes); } - + // if we want a mip map and our file lacks one, build it if ((textureMap->flags & M3cTextureFlags_HasMipMap) && (IMcNoMipMap == mipMap)) { @@ -706,12 +706,12 @@ Imp_ProcessTexture( error = M3rTextureMap_BuildMipMap(scale_mode, width, height, pixel_type, separateData); } - if (error != UUcError_None) + if (error != UUcError_None) { textureMap->flags &= ~M3cTextureFlags_HasMipMap; } } - + UUrMemory_Block_Delete(imageData); if (local_flags.numFrames > 1) @@ -736,9 +736,9 @@ Imp_ProcessTexture( UUmAssertReadPtr(outTextureRef, sizeof(*outTextureRef)); *outTextureRef = textureMap; } - + if (ddsFrameRef) BFrFileRef_Dispose(ddsFrameRef); - + if(outNewTextureFlags != NULL) { *outNewTextureFlags = local_flags; @@ -754,7 +754,7 @@ Imp_ProcessTexture( if (separateData != NULL) { textureMap->pixelStorage = (TMtSeparateFileOffset) TMrConstruction_Separate_Write(separateData); } - + return UUcError_None; } @@ -770,17 +770,17 @@ static UUtError AddTexturesInDirectory(BFtFileRef *inDirectoryRef, texture_in_di { UUtError error; BFtFileIterator *file_iterator; - + // create the file iterator for the directory error = BFrDirectory_FileIterator_New( inDirectoryRef, NULL, NULL, &file_iterator); IMPmError_ReturnOnError(error); - + while (1) { BFtFileRef file_ref; char name[BFcMaxFileNameLength]; TMtPlaceHolder texture_ref; - + // get file ref for the file error = BFrDirectory_FileIterator_Next(file_iterator, &file_ref); if (error != UUcError_None) { break; } @@ -795,9 +795,9 @@ static UUtError AddTexturesInDirectory(BFtFileRef *inDirectoryRef, texture_in_di valid_image_suffix = UUmString_IsEqual_NoCase(file_suffix, "bmp") | UUmString_IsEqual_NoCase(file_suffix, "psd"); if (!valid_image_suffix) { continue; } } - + // get the file name - UUrString_Copy(name, BFrFileRef_GetLeafName(&file_ref), BFcMaxFileNameLength); + UUrString_Copy(name, BFrFileRef_GetLeafName(&file_ref), BFcMaxFileNameLength); switch(texture_case) { @@ -814,14 +814,14 @@ static UUtError AddTexturesInDirectory(BFtFileRef *inDirectoryRef, texture_in_di } UUrString_StripExtension(name); - + error = Imp_ProcessTexture_File(&file_ref, name, &texture_ref); IMPmError_ReturnOnError(error); } - + BFrDirectory_FileIterator_Delete(file_iterator); file_iterator = NULL; - + return UUcError_None; } @@ -833,16 +833,16 @@ Imp_AddTextureDirectory( char* inInstanceName) { UUtError error; - + char* textureFileDirName; - BFtFileRef textureFileDirRef = *inSourceFileRef; - + BFtFileRef textureFileDirRef = *inSourceFileRef; + error = GRrGroup_GetString(inGroup, "file", &textureFileDirName); IMPmError_ReturnOnErrorMsg(error, "Could not get texture file info"); error = BFrFileRef_SetName(&textureFileDirRef, textureFileDirName); IMPmError_ReturnOnErrorMsg(error, "Could not make texture file dir ref"); - + AddTexturesInDirectory(&textureFileDirRef, textures_in_directory_upper_case); return UUcError_None; @@ -856,10 +856,10 @@ Imp_WriteTextureSize( UUtUns16 width, height; UUtUns16 curWidth, curHeight; UUtUns32 invalid_texture_loop; - + file = fopen("textureSize.txt", "wb"); if(file == NULL) return; - + curWidth = 1; for(width = 0; width <= 8; width++) { @@ -887,14 +887,14 @@ Imp_WriteTextureSize( { tInvalidTextureInfo *cur_invalid_texture = gInvalidTextureInfo + invalid_texture_loop; const char *texture_format_string = IMrPixelTypeToString(cur_invalid_texture->texelType); - - fprintf(file, "%s is resolution = %d by %d format = %s"UUmNL, - cur_invalid_texture->name, - cur_invalid_texture->width, + + fprintf(file, "%s is resolution = %d by %d format = %s"UUmNL, + cur_invalid_texture->name, + cur_invalid_texture->width, cur_invalid_texture->height, texture_format_string); } - + fclose(file); } @@ -909,7 +909,7 @@ Imp_ProcessTexture_File( UUtUns32 file_mod_date; tTextureFlags flags; char mungedInstanceName[BFcMaxFileNameLength]; - + UUmAssert(inFileRef); UUmAssert(outTextureRef); UUmAssert(inInstanceName); @@ -917,20 +917,20 @@ Imp_ProcessTexture_File( if (!BFrFileRef_FileExists(inFileRef)) { Imp_PrintWarning("Could not find file %s", BFrFileRef_GetLeafName(inFileRef)); } - + // get the modification time of the file error = BFrFileRef_GetModTime(inFileRef, &file_mod_date); IMPmError_ReturnOnErrorMsg(error, "Could not get file ref mod date"); - + // set the texture flags Imp_ClearTextureFlags(&flags); flags.hasFlagFile = cTextureFlagFile_Yes; flags.flags = M3cTextureFlags_None; - + //strip off extension UUrString_Copy(mungedInstanceName, inInstanceName, BFcMaxFileNameLength); UUrString_StripExtension(mungedInstanceName); - + // process M3cTextureMap_Big error = Imp_ProcessTexture( @@ -941,7 +941,7 @@ Imp_ProcessTexture_File( mungedInstanceName, IMPcIgnoreTextureRef); IMPmError_ReturnOnError(error); - + // get a placeholder for the M3tTextureMap_Big instance of texture_name { M3tTextureMap *texture = M3rTextureMap_GetPlaceholder(mungedInstanceName); @@ -964,15 +964,15 @@ Imp_ProcessTexture_Dir( UUtUns32 file_mod_date; tTextureFlags flags; char mungedInstanceName[BFcMaxFileNameLength]; - + UUmAssert(inFileRef); UUmAssert(outTextureRef); UUmAssert(inInstanceName); - + // get the modification time of the file //error = BFrFileRef_GetModTime(inFileRef, &file_mod_date); //IMPmError_ReturnOnErrorMsg(error, "Could not get file ref mod date"); - + file_mod_date = 0; // set the texture flags @@ -984,7 +984,7 @@ Imp_ProcessTexture_Dir( UUrString_Copy(mungedInstanceName, inInstanceName, BFcMaxFileNameLength); UUrString_StripExtension(mungedInstanceName); UUrString_MakeLowerCase(mungedInstanceName, BFcMaxFileNameLength); - + // process M3cTextureMap_Big error = Imp_ProcessTexture( @@ -995,7 +995,7 @@ Imp_ProcessTexture_Dir( mungedInstanceName, IMPcIgnoreTextureRef); IMPmError_ReturnOnError(error); - + // get a placeholder for the M3tTextureMap_Big instance of texture_name error = TMrConstruction_Instance_GetPlaceHolder( @@ -1003,7 +1003,7 @@ Imp_ProcessTexture_Dir( mungedInstanceName, outTextureRef); IMPmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Texture.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Texture.h index a6503a1..fe8a100 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Texture.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Texture.h @@ -1,12 +1,12 @@ /* FILE: Imp_Texture.h - + AUTHOR: Brent H. Pease - + CREATED: August 14, 1997 - + PURPOSE: Header file for the BMP file format - + Copyright 1997 */ @@ -34,7 +34,7 @@ Imp_AddTexture_Big( UUtUns32 inSourceFileModDate, GRtGroup *inGroup, char *inInstanceName); - + UUtError Imp_AddTextureDirectory( BFtFileRef* inSourceFileRef, @@ -59,7 +59,7 @@ void iBuildMipMap(M3tTextureMap *inTextureMap, UUtUns16 width, UUtUns16 height, void Imp_WriteTextureSize( void); - + UUtError Imp_ProcessTexture_File( BFtFileRef *inFileRef, @@ -75,5 +75,5 @@ Imp_ProcessTexture_Big_File( UUtError Imp_AddLocalTexture( BFtFileRef* inSourceFileRef, char* inTextureName, M3tTextureMap **ioTextureMap ); UUtError Imp_AddLocalTextures( BFtFileRef *inDirectoryRef ); - + #endif /* IMP_TEXTURE_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_TextureFlags.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_TextureFlags.c index fdec891..ec1b5a4 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_TextureFlags.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_TextureFlags.c @@ -24,13 +24,13 @@ typedef struct tFlagTable { char *flagName; UUtUns32 flagValue; - + } tFlagTable; // ====================================================================== // globals // ====================================================================== -tFlagTable gFlagTable[] = +tFlagTable gFlagTable[] = { { "mipmap", M3cTextureFlags_HasMipMap }, { "trilinear", M3cTextureFlags_Trilinear }, @@ -46,7 +46,7 @@ tFlagTable gFlagTable[] = { NULL, 0} }; -tFlagTable gPixelTypeTable[] = +tFlagTable gPixelTypeTable[] = { { "argb4444", IMcPixelType_ARGB4444 }, { "rgb555", IMcPixelType_RGB555 }, @@ -60,7 +60,7 @@ tFlagTable gPixelTypeTable[] = { NULL, 0 }, }; -AUtFlagElement IMPgAnimTextureFlags[] = +AUtFlagElement IMPgAnimTextureFlags[] = { { "pingpong", @@ -113,12 +113,12 @@ Imp_ProcessTextureFlags_FromFileRef( BFtFileRef *flagFileRef; char flagFileLeafName[BFcMaxFileNameLength * 2]; - + GRtGroup_Context *context; GRtGroup *group; - + leafName = BFrFileRef_GetLeafName(inFileRef); - + UUrString_Copy(flagFileLeafName, leafName, BFcMaxFileNameLength * 2); flagFileLeafName[strlen(leafName) - 4] = '\0'; UUrString_Cat(flagFileLeafName, "_ins.txt", BFcMaxFileNameLength * 2); @@ -131,7 +131,7 @@ Imp_ProcessTextureFlags_FromFileRef( flagFileRef = NULL; } } - else + else { flagFileRef = NULL; } @@ -170,20 +170,20 @@ Imp_ProcessTextureFlags( char* elem; UUtUns32 effectFlags; M3tColorRGB reflectivity_color; - + UUmAssert(inGroup); UUmAssert(outTextureFlags); - + outTextureFlags->timePerFrame = 1; outTextureFlags->numFrames = 1; outTextureFlags->reflectivity_specified = UUcFalse; outTextureFlags->reflectivity_color.r = IMPcTexture_DefaultReflectivity_value; outTextureFlags->reflectivity_color.g = IMPcTexture_DefaultReflectivity_value; outTextureFlags->reflectivity_color.b = IMPcTexture_DefaultReflectivity_value; - + outTextureFlags->envMapPlaceHolder = NULL; - - error = + + error = M3rGroup_GetColor( inGroup, "reflectivity", @@ -193,8 +193,8 @@ Imp_ProcessTextureFlags( outTextureFlags->reflectivity_specified = UUcTrue; outTextureFlags->reflectivity_color = reflectivity_color; } - - error = + + error = GRrGroup_GetElement( inGroup, "anim", @@ -205,7 +205,7 @@ Imp_ProcessTextureFlags( if(elemType == GRcElementType_Group) { outTextureFlags->timePerFrame = 1; - error = + error = GRrGroup_GetElement( animGroup, "tpf", @@ -221,7 +221,7 @@ Imp_ProcessTextureFlags( sscanf(elem, "%d", &tempu32); outTextureFlags->timePerFrame = (UUtUns16)tempu32; } - error = + error = GRrGroup_GetElement( animGroup, "numFrames", @@ -237,8 +237,8 @@ Imp_ProcessTextureFlags( sscanf(elem, "%d", &tempu32); outTextureFlags->numFrames = (UUtUns16)tempu32; } - - error = + + error = GRrGroup_GetElement( animGroup, "effect", @@ -246,7 +246,7 @@ Imp_ProcessTextureFlags( &elem); if(error == UUcError_None) { - error = + error = AUrFlags_ParseFromGroupArray( IMPgAnimTextureFlags, elemType, @@ -266,18 +266,18 @@ Imp_ProcessTextureFlags( AUrMessageBox(AUcMBType_OK, "illegal anim group"); } } - + // process all of the possible flags for (curFlag = gFlagTable; curFlag->flagName != NULL; curFlag++) { switch (curFlag->flagValue) - { + { case M3cTextureFlags_PixelType: { UUtUns16 value; - + error = GRrGroup_GetString(inGroup, curFlag->flagName, &string); if (error == UUcError_None) { @@ -298,10 +298,10 @@ Imp_ProcessTextureFlags( default: { UUtBool bool_val; - + error = GRrGroup_GetBool(inGroup, curFlag->flagName, &bool_val); if (error == UUcError_None) - { + { // if the flag exists, then override the existing value if (bool_val) outTextureFlags->flags |= curFlag->flagValue; @@ -324,11 +324,11 @@ Imp_ProcessTextureFlags( else { char mungedTextureName[BFcMaxFileNameLength]; - + UUrString_Copy(mungedTextureName, string, BFcMaxFileNameLength); UUrString_StripExtension(mungedTextureName); - - error = + + error = TMrConstruction_Instance_GetPlaceHolder( M3cTemplate_TextureMap, mungedTextureName, @@ -339,7 +339,7 @@ Imp_ProcessTextureFlags( } } } -} +} void Imp_ClearTextureFlags(tTextureFlags *outFlags) { diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_TextureFlags.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_TextureFlags.h index c0b0b02..7727358 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_TextureFlags.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_TextureFlags.h @@ -14,7 +14,7 @@ // ====================================================================== // typedefs // ====================================================================== -typedef enum +typedef enum { cTextureFlagFile_No, cTextureFlagFile_Yes @@ -30,7 +30,7 @@ typedef struct tTextureFlags UUtBool reflectivity_specified; M3tColorRGB reflectivity_color; M3tTextureMap* envMapPlaceHolder; - + } tTextureFlags; // ====================================================================== @@ -52,4 +52,4 @@ Imp_ProcessTextureFlags_FromFileRef( tTextureFlags* ioTextureFlags); // ====================================================================== -#endif /* IMP_TEXTUREFLAGS_H */ \ No newline at end of file +#endif /* IMP_TEXTUREFLAGS_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Texture_Big.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Texture_Big.c index d9a59a7..9fce88f 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Texture_Big.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Texture_Big.c @@ -36,7 +36,7 @@ static UUtError BTiIsValidTextureMapSize( UUtUns32 inWidth, UUtUns32 inHeight); - + // ====================================================================== // functions // ====================================================================== @@ -57,18 +57,18 @@ BTiTextureMap_New( UUtError error; UUtUns8 size_of_texel; UUtUns32 total_map_bytes; - + // make sure that the parameters are good UUmAssert(inWidth > 0); UUmAssert(inHeight > 0); UUmAssertReadPtr(outTextureMap, sizeof(*outTextureMap)); - + // calculate the width, height, and rowbytes of the texture M3rTextureMap_GetTextureSize(inWidth, inHeight, &width, &height); size_of_texel = IMrPixel_GetSize(inTexelType); total_map_bytes = width * height * size_of_texel; - + // create a new instance of the texture error = TMrConstruction_Instance_Renew( @@ -77,7 +77,7 @@ BTiTextureMap_New( 0, &new_texture_map); UUmError_ReturnOnErrorMsg(error, "Unable to create a new texture."); - + // set up the texture map if (NULL != inInstanceName) { strncpy(new_texture_map->debugName, inInstanceName, 128); } else { strncpy(new_texture_map->debugName, "imported unique big texture", 128); } @@ -99,11 +99,11 @@ BTiTextureMap_New( #else separateData = TMrConstruction_Separate_New(total_map_bytes, M3cTemplate_TextureMap); #endif - + // save the outgoing variables *outTextureMap = new_texture_map; *outSeparateData = separateData; - + return UUcError_None; } @@ -117,7 +117,7 @@ BTiIsValidTextureMapSize( // set results initial value result = UUcError_None; - + // check width and height switch(inWidth) { @@ -197,48 +197,48 @@ Imp_ProcessTexture_Big( void *separate_data; const char *leaf_name; M3tTextureMap_Big *big_texture; - + UUtUns16 num_x; UUtUns16 num_y; - + UUtUns16 x; UUtUns16 y; - + char texture_group_name[BFcMaxFileNameLength * 2]; - + BFtFileRef *flagFileRef; char flagFileLeafName[BFcMaxFileNameLength * 2]; - + tTextureFlags local_flags; IMtPixelType pixel_type; - + GRtGroup_Context *context; GRtGroup *group; - + FFtFileInfo file_info; - + // copy the default flags local_flags = *inDefaultTextureFlags; - + // find out if the file exists - do + do { // get the name of the file without the path leaf_name = BFrFileRef_GetLeafName(inFileRef); - + // see if the file exists file_exists = BFrFileRef_FileExists(inFileRef); - + if (file_exists == UUcFalse) { AUtMB_ButtonChoice choice; - - choice = + + choice = AUrMessageBox( AUcMBType_AbortRetryIgnore, "Could not find file %s."UUmNL, leaf_name); - + if (choice == AUcMBChoice_Abort) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Could not find texture file"); @@ -250,7 +250,7 @@ Imp_ProcessTexture_Big( } } while (!file_exists); - + // find out if the instance exists build_instance = !TMrConstruction_Instance_CheckExists( @@ -261,11 +261,11 @@ Imp_ProcessTexture_Big( { return UUcError_None; } - + // get the file info error = FFrPeek_2D(inFileRef, &file_info); UUmError_ReturnOnErrorMsg(error, "Could not get file info."); - + // set the default pixel format if (file_info.format == FFcFormat_2D_PSD) { @@ -275,7 +275,7 @@ Imp_ProcessTexture_Big( { pixel_type = IMcPixelType_RGB555; } - + // process the flags file UUrString_Copy(flagFileLeafName, leaf_name, BFcMaxFileNameLength * 2); flagFileLeafName[strlen(leaf_name) - 4] = '\0'; @@ -289,7 +289,7 @@ Imp_ProcessTexture_Big( flagFileRef = NULL; } } - else + else { flagFileRef = NULL; } @@ -314,9 +314,9 @@ Imp_ProcessTexture_Big( { pixel_type = local_flags.pixelType; } - + // read the data from the file - error = + error = FFrRead_2D( inFileRef, pixel_type, @@ -325,28 +325,28 @@ Imp_ProcessTexture_Big( &mipMap, &image_data); UUmError_ReturnOnError(error); - + row_bytes = IMrImage_ComputeRowBytes(pixel_type, width); /* error = BTiIsValidTextureMapSize(width, height); if(error != UUcError_None) { Imp_PrintWarning( - "File %s had an invalid texture map size (%d, %d)"UUmNL"(1 to 256 and 8x1 ratio only)", + "File %s had an invalid texture map size (%d, %d)"UUmNL"(1 to 256 and 8x1 ratio only)", BFrFileRef_GetLeafName(inFileRef), width, height); - + return error; }*/ - + // calculate the number of M3tTextureMaps it will take to hold the texture num_x = width / M3cTextureMap_MaxWidth; num_y = height / M3cTextureMap_MaxHeight; - + if ((width & (M3cTextureMap_MaxWidth - 1)) > 0) num_x++; if ((height & (M3cTextureMap_MaxHeight - 1)) > 0) num_y++; - + // Create the texture map instance error = TMrConstruction_Instance_Renew( @@ -355,17 +355,17 @@ Imp_ProcessTexture_Big( num_x * num_y, (void **)&big_texture); IMPmError_ReturnOnError(error); - + big_texture->texelType = pixel_type; big_texture->width = width; big_texture->height = height; big_texture->num_x = num_x; big_texture->num_y = num_y; - + // set the texture_group_name UUrString_Copy(texture_group_name, leaf_name, BFcMaxFileNameLength * 2); texture_group_name[strlen(leaf_name) - 4] = '\0'; - + // Copy the image into the texture maps for (y = 0; y < num_y; y++) { @@ -375,24 +375,24 @@ Imp_ProcessTexture_Big( UUtUns16 top; UUtUns16 texture_width; UUtUns16 texture_height; - + UUtUns16 index; - + M3tTextureMap *texture; char texture_name[BFcMaxFileNameLength * 2]; - + // calculate the index number of the texture index = x + (y * num_x); - + // calculate the texture width and height left = (x * M3cTextureMap_MaxWidth); top = (y * M3cTextureMap_MaxHeight); texture_width = UUmMin(M3cTextureMap_MaxWidth, width - left); texture_height = UUmMin(M3cTextureMap_MaxHeight, height - top); - + // set the texture_name sprintf(texture_name, "%s_%d", texture_group_name, index); - + // create a new texture error = BTiTextureMap_New( @@ -403,41 +403,41 @@ Imp_ProcessTexture_Big( &texture, &separate_data); IMPmError_ReturnOnErrorMsg(error, "Unable to create texture map"); - + // save the texture pointer big_texture->textures[index] = texture; - + // copy the data from the image_data to the texture { UUtUns16 w; UUtUns16 h; - + UUtUns16 texel_size; - + UUtUns8 *src; UUtUns32 src_row_bytes; - + UUtUns8 *dst1, *dst2; UUtUns32 dst_row_bytes; - + // get the texel size texel_size = (UUtUns16)IMrPixel_GetSize(big_texture->texelType); - + // set the src src_row_bytes = row_bytes; - src = + src = (UUtUns8*)image_data + (top * src_row_bytes) + (left * texel_size); - + // set the dst dst_row_bytes = texture->width * texel_size; dst1 = (UUtUns8*)texture->pixels; dst2 = (UUtUns8*)separate_data; - + w = texture_width * texel_size; h = texture_height; - + while (h--) { if (dst1 != NULL) { @@ -449,7 +449,7 @@ Imp_ProcessTexture_Big( UUrMemory_MoveFast(src, dst2, w); dst2 += dst_row_bytes; } - + // advance to next line src += src_row_bytes; } @@ -467,10 +467,10 @@ Imp_ProcessTexture_Big( #endif } } - + // dispose of the image_data UUrMemory_Block_Delete(image_data); - + return UUcError_None; } @@ -490,7 +490,7 @@ Imp_AddTexture_Big( UUtError error; BFtFileRef* file; tTextureFlags flags; - + // get a reference to the file error = Imp_Common_GetFileRefAndModDate( @@ -499,19 +499,19 @@ Imp_AddTexture_Big( "file", &file); IMPmError_ReturnOnErrorMsg(error, "Could not get file name"); - + // set the flags Imp_ClearTextureFlags(&flags); flags.hasFlagFile = cTextureFlagFile_No; flags.flags = M3cTextureFlags_None; - + // process the texture error = Imp_ProcessTexture_Big( file, &flags, inInstanceName); - + // dispose of the file reference BFrFileRef_Dispose(file); @@ -528,20 +528,20 @@ Imp_ProcessTexture_Big_File( UUtError error; UUtUns32 file_mod_date; tTextureFlags flags; - + UUmAssert(inFileRef); UUmAssert(outTextureRef); UUmAssert(inInstanceName); - + // get the modification time of the file error = BFrFileRef_GetModTime(inFileRef, &file_mod_date); IMPmError_ReturnOnErrorMsg(error, "Could not get file ref mod date"); - + // set the texture flags Imp_ClearTextureFlags(&flags); flags.hasFlagFile = cTextureFlagFile_Yes; flags.flags = M3cTextureFlags_None; - + // process M3cTextureMap_Big error = Imp_ProcessTexture_Big( @@ -549,7 +549,7 @@ Imp_ProcessTexture_Big_File( &flags, inInstanceName); IMPmError_ReturnOnError(error); - + // get a placeholder for the M3tTextureMap_Big instance of texture_name error = TMrConstruction_Instance_GetPlaceHolder( @@ -557,6 +557,6 @@ Imp_ProcessTexture_Big_File( inInstanceName, outTextureRef); IMPmError_ReturnOnError(error); - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Trigger.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Trigger.c index 9026279..eff8968 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Trigger.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Trigger.c @@ -57,11 +57,11 @@ UUtError Imp_AddTriggerEmitter( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFi // dispose of the file ref BFrFileRef_Dispose( model_file ); - if (header->numNodes > 1) + if (header->numNodes > 1) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Emitter file had > 1 node!"); } - + // build the geometry instance error = TMrConstruction_Instance_NewUnique( M3cTemplate_Geometry, 0, &emitter->geometry ); IMPmError_ReturnOnError(error); @@ -81,7 +81,7 @@ UUtError Imp_AddTriggerEmitter( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFi MUmVector_Subtract(emitter->emit_vector, to, from); MUrNormalize(&emitter->emit_vector); MUmVector_Copy(emitter->emit_position, from); - } + } else { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Trigger emitter did not have a 'Laser' marker!"); @@ -89,16 +89,16 @@ UUtError Imp_AddTriggerEmitter( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFi // get the GQ flags emitter->gq_flags = IMPrEnv_GetNodeFlags( header->nodes ); - + // put the tris and quads associated with material m into a geometry Imp_NodeMaterial_To_Geometry_ApplyMatrix( header->nodes, (UUtUns16)0, emitter->geometry ); - + // get the texture name temp_name = header->nodes[0].materials[0].maps[MXcMapping_DI].name; emitter->geometry->baseMap = M3rTextureMap_GetPlaceholder_StripExtension_UpperCase(temp_name); UUmAssert(emitter->geometry->baseMap); - + // delete the header Imp_EnvFile_Delete(header); @@ -133,7 +133,7 @@ UUtError Imp_AddTrigger( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFileModDa BFrFileRef_Dispose(model_file); - if (header->numNodes > 1) + if (header->numNodes > 1) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Trigger base model had > 1 node!"); } @@ -143,13 +143,13 @@ UUtError Imp_AddTrigger( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFileModDa // get the GQ flags trigger->base_gq_flags = IMPrEnv_GetNodeFlags( header->nodes ); - + error = Imp_Node_To_Geometry_ApplyMatrix( header->nodes, trigger->base_geometry ); UUmError_ReturnOnErrorMsg(error, "failed to build the geometry"); - + // get the light data //IMPiTurret_GetLightData( &header->nodes[0], 0, &trigger->base_ls_data ); - + // get the texture name temp_name = header->nodes[0].materials[0].maps[MXcMapping_DI].name; @@ -160,8 +160,8 @@ UUtError Imp_AddTrigger( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFileModDa // delete env file Imp_EnvFile_Delete(header); } - - // emitter + + // emitter { error = GRrGroup_GetString(inGroup, "emitter", &temp_name); IMPmError_ReturnOnErrorMsg(error, "Trigger has no emitter"); @@ -190,7 +190,7 @@ UUtError Imp_AddTrigger( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFileModDa trigger->time_on = 0; trigger->time_off = 0; trigger->color = 0x7FFF0000; - + // read properties error = GRrGroup_GetFloat( inGroup, "start_offset", &temp_float ); if(error == UUcError_None ) @@ -247,6 +247,6 @@ UUtError Imp_AddTrigger( BFtFileRef* inSourceFileRef, UUtUns32 inSourceFileModDa trigger->active_sound = NULL; trigger->trigger_sound = NULL; - return UUcError_None; + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Trigger.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Trigger.h index a65d203..1adc87c 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Trigger.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Trigger.h @@ -27,4 +27,4 @@ Imp_AddTriggerEmitter( char* inInstanceName); // ====================================================================== -#endif /* IMP_Trigger_H */ \ No newline at end of file +#endif /* IMP_Trigger_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Turret.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Turret.c index afb9355..2dcac72 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Turret.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Turret.c @@ -42,12 +42,12 @@ IMPiTurret_GetLightData( GRtGroup *group; GRtElementType groupType; GRtGroup *ls_group; - + IMPtLS_LightType light_type; IMPtLS_Distribution light_distribution; - OBJtLSData *ls_data = NULL; - - // init + OBJtLSData *ls_data = NULL; + + // init groupContext = NULL; // make sure there is user data to process @@ -55,7 +55,7 @@ IMPiTurret_GetLightData( { goto cleanup; } - + // create a GRtGroup from the user data error = GRrGroup_Context_NewFromString( @@ -65,7 +65,7 @@ IMPiTurret_GetLightData( &groupContext, &group); if (error != UUcError_None) { goto cleanup; } - + // get the ls group from the user data group error = GRrGroup_GetElement( @@ -74,7 +74,7 @@ IMPiTurret_GetLightData( &groupType, &ls_group); if (error != UUcError_None) { goto cleanup; } - + // create the OBJtLSData instance error = TMrConstruction_Instance_Renew( @@ -83,11 +83,11 @@ IMPiTurret_GetLightData( 0, &ls_data); if (error != UUcError_None) { goto cleanup; } - + // init ls_data->index = inIndex; ls_data->light_flags = OBJcLightFlag_HasLight; - + // process the user data error = IMPrEnv_GetLSData( @@ -99,7 +99,7 @@ IMPiTurret_GetLightData( &ls_data->beam_angle, &ls_data->field_angle); if (error != UUcError_None) { goto cleanup; } - + // set the light type flags if (light_type == IMPcLS_LightType_Area) { @@ -113,7 +113,7 @@ IMPiTurret_GetLightData( { ls_data->light_flags |= OBJcLightFlag_Type_Point; } - + // set the light distribution flags if (light_distribution == IMPcLS_Distribution_Diffuse) { @@ -123,7 +123,7 @@ IMPiTurret_GetLightData( { ls_data->light_flags |= OBJcLightFlag_Dist_Spot; } - + cleanup: *ioLSData = ls_data; if (groupContext) @@ -166,7 +166,7 @@ Imp_AddTurret( M3tVector3D marker_pos, marker_z, attach_x, attach_y, attach_z; float tempfloat, axial_dot; OBJtTurretClass *turret; - + // build the turret instance error = TMrConstruction_Instance_Renew( OBJcTemplate_TurretClass, inInstanceName, 0, &turret); IMPmError_ReturnOnError(error); @@ -184,7 +184,7 @@ Imp_AddTurret( BFrFileRef_Dispose(modelFileRef); - if (header->numNodes > 1) + if (header->numNodes > 1) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Turret base model had > 1 node!"); } @@ -197,7 +197,7 @@ Imp_AddTurret( error = Imp_Node_To_Geometry_ApplyMatrix(header->nodes, turret->base_geometry); UUmError_ReturnOnErrorMsg(error, "failed to build the geometry"); - + // get the light data IMPiTurret_GetLightData( &header->nodes[0], 0, &turret->base_ls_data ); @@ -231,7 +231,7 @@ Imp_AddTurret( BFrFileRef_Dispose(modelFileRef); - if (header->numNodes > 1) + if (header->numNodes > 1) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Turret turret model file had > 1 node!"); } @@ -253,7 +253,7 @@ Imp_AddTurret( UUmAssert(turret->turret_geometry->baseMap); - // grab the texture + // grab the texture //error = Imp_AddLocalTexture( inSourceFileRef, textureName, &turret->turret_geometry->baseMap ); //IMPmError_ReturnOnErrorMsg(error, "Could not create texture place holder"); @@ -280,7 +280,7 @@ Imp_AddTurret( BFrFileRef_Dispose(modelFileRef); - if (header->numNodes > 1) + if (header->numNodes > 1) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Turret barrel model file had > 1 node!"); } @@ -315,7 +315,7 @@ Imp_AddTurret( //static M3tVector3D weapon_orient_dir = {1, 0, 0}; // WEAPON static M3tVector3D weapon_orient_dir = {0, 0, 1}; // TURRET M3tQuaternion ai_shooter_inverse_quat; - + // set up defaults turret->attachment_count = 0; turret->shooter_count = 0; @@ -328,30 +328,30 @@ Imp_AddTurret( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "attachments must be an array"); } - + turret->attachment_count = (UUtUns16) GRrGroup_Array_GetLength(attachmentArray); found_shooter = UUcFalse; - + for(itr = 0, attachment = turret->attachment; itr < turret->attachment_count; itr++, attachment++) { error = GRrGroup_Array_GetElement(attachmentArray, itr, &elementType, &attachmentGroup); - if (error != UUcError_None) + if (error != UUcError_None) { sprintf(errmsg, "could not get attachment #%d from group", itr); UUmError_ReturnOnErrorMsg(error, errmsg); } - + if(elementType != GRcElementType_Group) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "every element of 'attachments' array must be a group"); } - + // find the marker on the weapon that this is attached to error = GRrGroup_GetString(attachmentGroup, "marker", &tempstring); UUmError_ReturnOnErrorMsg(error, "every attachment entry must have a 'marker'"); - marker = Imp_EnvFile_GetMarker(header->nodes + 0, tempstring); - if (marker) + marker = Imp_EnvFile_GetMarker(header->nodes + 0, tempstring); + if (marker) { // it's important that the attachment matrix should be a rigid body transformation matrix // i.e. no scale or shear. so we do this orthonormal basis construction thang. @@ -370,18 +370,18 @@ Imp_AddTurret( marker_pos = MUrMatrix_GetTranslation(&marker->matrix); MUrMatrix_SetTranslation(&attachment->matrix, &marker_pos); - } - else + } + else { sprintf(errmsg, "couldn't find marker %s on the weapon geometry", tempstring); UUmError_ReturnOnErrorMsg(UUcError_Generic, errmsg); - } + } // find the particle class error = GRrGroup_GetString(attachmentGroup, "particle_class", &tempstring); UUmError_ReturnOnErrorMsg(error, "every attachment entry must have a 'particle_class'"); - - if ((strlen(tempstring) < 1) || (strlen(tempstring) > P3cParticleClassNameLength)) + + if ((strlen(tempstring) < 1) || (strlen(tempstring) > P3cParticleClassNameLength)) { sprintf(errmsg, "particle class name '%s' is not within range 1-%d chars", tempstring, P3cParticleClassNameLength); UUmError_ReturnOnErrorMsg(UUcError_Generic, errmsg); @@ -391,28 +391,28 @@ Imp_AddTurret( // find the index of this attachment error = GRrGroup_GetInt32(attachmentGroup, "index", &tempint); - if (error == UUcError_None) + if (error == UUcError_None) { attachment->shooter_index = (UUtUns16) tempint; - } - else + } + else { attachment->shooter_index = (UUtUns16) -1; } // get the shooter properties (if they're there...) error = GRrGroup_GetFloat(attachmentGroup, "rof", &tempfloat); - if (error == UUcError_None) + if (error == UUcError_None) { attachment->chamber_time = (UUtUns16) MUrUnsignedSmallFloat_To_Uns_Round(UUcFramesPerSecond / tempfloat); // this attachment is a shooter. it must have an index. - if (attachment->shooter_index == (UUtUns16) -1) + if (attachment->shooter_index == (UUtUns16) -1) { attachment->shooter_index = turret->shooter_count; } turret->shooter_count++; - if (!found_shooter) + if (!found_shooter) { // this is the first shooter attached to this weapon. // @@ -439,7 +439,7 @@ Imp_AddTurret( } } } - if (!found_shooter) + if (!found_shooter) { MUrMatrix_Identity(&turret->ai_params.shooter_inversematrix); MUmVector_Set(turret->ai_params.shooterdir_gunspace, 1, 0, 0); @@ -498,18 +498,18 @@ Imp_AddTurret( if (error != UUcError_None) { turret->timeout = 900; } - + // free time error = GRrGroup_GetUns16(inGroup, "freeTime", &(turret->freeTime)); if (error != UUcError_None) turret->freeTime = 0; - + error = Imp_Turret_ReadCombatBehavior( inSourceFileRef, inSourceFileModDate, inGroup, inInstanceName, turret); - if (error != UUcError_None) + if (error != UUcError_None) IMPmError_ReturnOnErrorMsg(error, "error reading turret AI params"); // name @@ -539,7 +539,7 @@ Imp_AddTurret( UUrString_Copy(turret->active_soundname, soundName, SScMaxNameLength); turret->active_sound = NULL; - return UUcError_None; + return UUcError_None; } @@ -561,7 +561,7 @@ UUtError Imp_Turret_ReadCombatBehavior( inInstanceName, UUcFalse, &inTurret->ai_params ); - if (error != UUcError_None) + if (error != UUcError_None) IMPmError_ReturnOnErrorMsg(error, "error reading turret AI params"); @@ -584,7 +584,7 @@ UUtError Imp_Turret_ReadCombatBehavior( inTurret->targeting_params.startle_miss_angle_min *= M3cDegToRad; error = GRrGroup_GetFloat(inGroup, "startle_miss_angle_max", &inTurret->targeting_params.startle_miss_angle_max); - if (error != UUcError_None) + if (error != UUcError_None) inTurret->targeting_params.startle_miss_angle_max = 30.0f; inTurret->targeting_params.startle_miss_angle_max *= M3cDegToRad; @@ -593,7 +593,7 @@ UUtError Imp_Turret_ReadCombatBehavior( inTurret->targeting_params.startle_miss_decay = 0.5f; #else error = GRrGroup_GetFloat(inGroup, "startle_miss_angle", &inTurret->targeting_params.startle_miss_angle); - if (error != UUcError_None) + if (error != UUcError_None) inTurret->targeting_params.startle_miss_angle = 30.0f; inTurret->targeting_params.startle_miss_angle = UUmPin(inTurret->targeting_params.startle_miss_angle, 0.f, 80.0f); @@ -608,19 +608,19 @@ UUtError Imp_Turret_ReadCombatBehavior( */ error = GRrGroup_GetFloat(inGroup, "predict_amount", &inTurret->targeting_params.predict_amount); - if (error != UUcError_None) + if (error != UUcError_None) inTurret->targeting_params.predict_amount = 1.0f; error = GRrGroup_GetUns32(inGroup, "predict_delayframes", &inTurret->targeting_params.predict_delayframes); - if (error != UUcError_None) + if (error != UUcError_None) inTurret->targeting_params.predict_delayframes = 5; error = GRrGroup_GetUns32(inGroup, "predict_velocityframes", &inTurret->targeting_params.predict_velocityframes); - if (error != UUcError_None) + if (error != UUcError_None) inTurret->targeting_params.predict_velocityframes = 15; error = GRrGroup_GetUns32(inGroup, "predict_trendframes", &inTurret->targeting_params.predict_trendframes); - if (error != UUcError_None) + if (error != UUcError_None) inTurret->targeting_params.predict_trendframes = 60; @@ -640,33 +640,33 @@ UUtError Imp_Turret_ReadCombatBehavior( skill = &inTurret->shooting_skill; error = GRrGroup_GetFloat(inGroup, "skill_recoil_compensation", &skill->recoil_compensation); - if (error != UUcError_None) + if (error != UUcError_None) skill->recoil_compensation = 0.3f; // best_aiming_angle is read as degrees, stored as sin(theta) error = GRrGroup_GetFloat(inGroup, "skill_best_aiming_angle", &skill->best_aiming_angle); - if (error != UUcError_None) + if (error != UUcError_None) skill->best_aiming_angle = 0.5f; skill->best_aiming_angle = MUrSin(skill->best_aiming_angle * M3cDegToRad); error = GRrGroup_GetFloat(inGroup, "skill_shot_error", &skill->shot_error); - if (error != UUcError_None) + if (error != UUcError_None) skill->shot_error = 0.0f; error = GRrGroup_GetFloat(inGroup, "skill_shot_decay", &skill->shot_decay); - if (error != UUcError_None) + if (error != UUcError_None) skill->shot_decay = 0.5f; error = GRrGroup_GetFloat(inGroup, "skill_inaccuracy", &skill->gun_inaccuracy); - if (error != UUcError_None) + if (error != UUcError_None) skill->gun_inaccuracy = 1.0f; error = GRrGroup_GetUns16(inGroup, "skill_delay_min", &skill->delay_min); - if (error != UUcError_None) + if (error != UUcError_None) skill->delay_min = 0; error = GRrGroup_GetUns16(inGroup, "skill_delay_max", &skill->delay_max); - if (error != UUcError_None) + if (error != UUcError_None) skill->delay_max = 0; return UUcError_None; diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Turret.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Turret.h index 00c638b..8cc3064 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Turret.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Turret.h @@ -20,4 +20,4 @@ Imp_AddTurret( char* inInstanceName); // ====================================================================== -#endif /* IMP_Turret_H */ \ No newline at end of file +#endif /* IMP_Turret_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_UnitViewer.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_UnitViewer.c index e280fa8..de6b48d 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_UnitViewer.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_UnitViewer.c @@ -44,10 +44,10 @@ Imp_AddDataList( UUtBool bool_result; UUtBool build_instance; - + UUtUns32 create_date; UUtUns32 compile_date; - + // check to see if the dialogs need to be built bool_result = TMrConstruction_Instance_CheckExists( @@ -57,7 +57,7 @@ Imp_AddDataList( if (bool_result) { compile_date = UUrConvertStrToSecsSince1900(gUVCompileTime); - + build_instance = (UUtBool)(create_date < inSourceFileModDate || create_date < compile_date); } @@ -65,17 +65,17 @@ Imp_AddDataList( { build_instance = UUcTrue; } - + if (build_instance) { UUtUns32 i; UUtUns32 num_groups; char *type; - + GRtElementType element_type; GRtElementArray *data_array; UVtDataList *data_list; - + // get the data array error = GRrGroup_GetElement( @@ -87,10 +87,10 @@ Imp_AddDataList( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Can't process the data"); } - + // get the number of data groups in the data array num_groups = GRrGroup_Array_GetLength(data_array); - + // create an view template instance error = TMrConstruction_Instance_Renew( @@ -107,7 +107,7 @@ Imp_AddDataList( "type", &type); IMPmError_ReturnOnErrorMsg(error, "Data list type not found in _ins.txt"); - + error = AUrFlags_ParseFromString( type, @@ -115,14 +115,14 @@ Imp_AddDataList( IMPgDataTypeFlags, &data_list->data_type); IMPmError_ReturnOnErrorMsg(error, "Unknown data list type"); - + // process the elements of the data array for (i = 0; i < num_groups; i++) { GRtGroup *data_group; char *name; char *template_name; - + // ------------------------------ // get the data group at index i // ------------------------------ @@ -136,7 +136,7 @@ Imp_AddDataList( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Could not get the data group"); } - + // ------------------------------ // get the template ref // ------------------------------ @@ -146,12 +146,12 @@ Imp_AddDataList( "template", &template_name); IMPmError_ReturnOnErrorMsg(error, "Unable to get template name"); - + UUrString_Copy( data_list->data[i].instance_name, template_name, UVcMaxInstNameLength); - + // ------------------------------ // get the name // ------------------------------ @@ -160,13 +160,13 @@ Imp_AddDataList( data_group, "name", &name); - + UUrString_Copy( data_list->data[i].name, name, UVcMaxDataNameLength); } } - + return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_UnitViewer.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_UnitViewer.h index 68c49f4..d879898 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_UnitViewer.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_UnitViewer.h @@ -15,4 +15,4 @@ Imp_AddDataList( char* inInstanceName); // ====================================================================== -#endif /* IMP_UNITVIEWER_H */ \ No newline at end of file +#endif /* IMP_UNITVIEWER_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_View.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_View.c index e493210..5a0f317 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_View.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_View.c @@ -46,7 +46,7 @@ typedef struct tViewProc char *name; UUtUns16 type; IMPiViewProc view_proc; - + } tViewProc; typedef struct tParts @@ -54,7 +54,7 @@ typedef struct tParts char *name; UUtUns16 row; UUtUns16 column; - + } tParts; // ====================================================================== @@ -70,7 +70,7 @@ static AUtFlagElement IMPgDialogFlags[] = { NULL, 0 } }; -static AUtFlagElement IMPgViewFlags[] = +static AUtFlagElement IMPgViewFlags[] = { { "none", VMcViewFlag_None }, { "view_visible", VMcViewFlag_Visible }, @@ -130,13 +130,13 @@ IMPiProcessViewFlags( GRtElementType element_type; GRtElementArray *flag_array; UUtUns32 flags; - + // init the flags *outFlags = 0; flags = 0; - + // get the flag string - error = + error = GRrGroup_GetElement( inGroup, flag_name, @@ -147,7 +147,7 @@ IMPiProcessViewFlags( { IMPmError_ReturnOnErrorMsg(error, "Error getting flags"); } - + // process the flags error = AUrFlags_ParseFromGroupArray( @@ -159,10 +159,10 @@ IMPiProcessViewFlags( { IMPmError_ReturnOnErrorMsg(error, "Unable to parse the flags."); } - + // set the outgoing string *outFlags = (UUtUns16)flags; - + return UUcError_None; } @@ -176,11 +176,11 @@ IMPiProcessLocation( UUtError error; GRtElementType element_type; GRtGroup *location; - + // initialize outLocation outLocation->x = 0; outLocation->y = 0; - + // get the location group error = GRrGroup_GetElement( @@ -197,15 +197,15 @@ IMPiProcessLocation( Imp_PrintWarning("Could not get location"); return UUcError_Generic; } - + // get the location x error = GRrGroup_GetUns16(location, "x", (UUtUns16*)&outLocation->x); IMPmError_ReturnOnError(error); - + // get the location y error = GRrGroup_GetUns16(location, "y", (UUtUns16*)&outLocation->y); IMPmError_ReturnOnError(error); - + return UUcError_None; } @@ -223,9 +223,9 @@ IMPiProcessPartSpecification( char *instance_name; TMtPlaceHolder part_spec_ref; UUtUns32 sourceModDate; - + *outPartSpecificationRef = NULL; - + // get the element // it is okay if it doesn't exist error = @@ -235,7 +235,7 @@ IMPiProcessPartSpecification( &element_type, &part_specification); if (error != UUcError_None) return UUcError_None; - + if (element_type == GRcElementType_String) { instance_name = (char*)part_specification; @@ -249,7 +249,7 @@ IMPiProcessPartSpecification( "instance", &instance_name); IMPmError_ReturnOnErrorMsg(error, "Could not get instance name"); - + // get the mod date of this file error = BFrFileRef_GetModTime( @@ -266,17 +266,17 @@ IMPiProcessPartSpecification( instance_name); IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - - // get a place holder for the - error = + + // get a place holder for the + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_PartSpecification, instance_name, &part_spec_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get view placeholder for dialog"); - + *outPartSpecificationRef = (void*)part_spec_ref; - + return UUcError_None; } @@ -294,7 +294,7 @@ IMPiProcessSingleTexture( BFtFileRef *texture_file_ref; const char *texture_name; TMtPlaceHolder texture_ref; - + error = GRrGroup_GetElement( inGroup, @@ -307,7 +307,7 @@ IMPiProcessSingleTexture( { Imp_PrintWarning("Unable to process the texture"); } - + return error; } @@ -318,10 +318,10 @@ IMPiProcessSingleTexture( texture_file_name, &texture_file_ref); IMPmError_ReturnOnErrorMsg(error, "texture file was not found"); - + // set the textures name texture_name = BFrFileRef_GetLeafName(texture_file_ref); - + // process the texture map file error = Imp_ProcessTexture_File( @@ -329,12 +329,12 @@ IMPiProcessSingleTexture( texture_name, &texture_ref); IMPmError_ReturnOnErrorMsg(error, "unable to process the texture"); - + BFrFileRef_Dispose(texture_file_ref); - + // save the texture ref *outTextureRef = texture_ref; - + return UUcError_None; } @@ -354,7 +354,7 @@ IMPiProcessTextures( // get pointer to texture list // it is okay for the list not to exist - error = + error = GRrGroup_GetElement( inGroup, inTextureListName, @@ -362,16 +362,16 @@ IMPiProcessTextures( &texture_list); if (error != UUcError_None) return UUcError_None; - + if (element_type != GRcElementType_Array) { Imp_PrintWarning("Could not get the texture list"); return UUcError_Generic; } - + // get the number of textures in the texture_list num_textures = (UUtUns16)GRrGroup_Array_GetLength(texture_list); - + // create a new texture list template error = TMrConstruction_Instance_NewUnique( @@ -379,7 +379,7 @@ IMPiProcessTextures( num_textures, inTextureList); IMPmError_ReturnOnError(error); - + // process the textures for (i = 0; i < num_textures; i++) { @@ -388,9 +388,9 @@ IMPiProcessTextures( const char *texture_name; TMtPlaceHolder texture_ref; FFtFileInfo format; - + // get the name of texture[i] - error = + error = GRrGroup_Array_GetElement( texture_list, i, @@ -401,7 +401,7 @@ IMPiProcessTextures( Imp_PrintWarning("Could not get the texture file name"); return UUcError_Generic; } - + // create a new file ref using the texture's file name error = BFrFileRef_DuplicateAndReplaceName( @@ -409,14 +409,14 @@ IMPiProcessTextures( texture_file, &texture_file_ref); IMPmError_ReturnOnErrorMsg(error, "texture file was not found"); - + // set the textures name - texture_name = BFrFileRef_GetLeafName(texture_file_ref); - + texture_name = BFrFileRef_GetLeafName(texture_file_ref); + // look into the texture error = FFrPeek_2D(texture_file_ref, &format); IMPmError_ReturnOnErrorMsg(error, "could not get info about the file."); - + if ((format.width > M3cTextureMap_MaxWidth) || (format.height > M3cTextureMap_MaxHeight)) { @@ -430,14 +430,14 @@ IMPiProcessTextures( error = Imp_ProcessTexture_File(texture_file_ref, texture_name, &texture_ref); IMPmError_ReturnOnErrorMsg(error, "Could not import the texture file."); } - + // save the texture ref (*inTextureList)->textures[i].texture_ref = (void*)texture_ref; // dispose of the file ref BFrFileRef_Dispose(texture_file_ref); } - + return UUcError_None; } @@ -457,7 +457,7 @@ IMPiView_Process_Box( UUtError error; VMtView_Box *box; TMtPlaceHolder box_ref; - + // create the dialog template error = TMrConstruction_Instance_Renew( @@ -466,7 +466,7 @@ IMPiView_Process_Box( 0, &box); IMPmError_ReturnOnErrorMsg(error, "Could not create a template"); - + // initialize the fields box->box = NULL; @@ -483,15 +483,15 @@ IMPiView_Process_Box( } // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View_Box, inInstanceName, &box_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the template"); - + *outViewData = box_ref; - + return UUcError_None; } @@ -509,7 +509,7 @@ IMPiView_Process_Button( UUtUns16 common_flags; UUtUns16 animation_flags; char *button_title; - + // create the template error = TMrConstruction_Instance_Renew( @@ -518,7 +518,7 @@ IMPiView_Process_Button( 0, &button); IMPmError_ReturnOnErrorMsg(error, "Could not create the template"); - + // read the title error = GRrGroup_GetString( @@ -535,12 +535,12 @@ IMPiView_Process_Button( } else { - // only if the title exists does the text need to be copied, the + // only if the title exists does the text need to be copied, the // common flags read, and the text offset location processed - + // copy the title text UUrString_Copy(button->title, button_title, VMcMaxTitleLength); - + // read the flags error = IMPiProcessViewFlags( @@ -558,7 +558,7 @@ IMPiView_Process_Button( &button->text_location_offset); IMPmError_ReturnOnErrorMsg(error, "Unable to get the location"); } - + // read the animation rate error = GRrGroup_GetUns16( @@ -567,7 +567,7 @@ IMPiView_Process_Button( &button->animation_rate); if (error != UUcError_None) button->animation_rate = VMcView_Button_DefaultAnimationRate; - + // read the animation flags error = IMPiProcessViewFlags( @@ -577,9 +577,9 @@ IMPiView_Process_Button( &animation_flags); if ((error != UUcError_None) && (error != GRcError_ElementNotFound)) IMPmError_ReturnOnErrorMsg(error, "Unable to process button flags"); - + button->flags = common_flags | animation_flags; - + // process the part specifications error = IMPiProcessPartSpecification( @@ -591,7 +591,7 @@ IMPiView_Process_Button( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + error = IMPiProcessPartSpecification( inSourceFile, @@ -602,7 +602,7 @@ IMPiView_Process_Button( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + error = IMPiProcessPartSpecification( inSourceFile, @@ -613,17 +613,17 @@ IMPiView_Process_Button( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View_Button, inInstanceName, &button_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the template"); - + *outViewData = button_ref; - + return UUcError_None; } @@ -639,7 +639,7 @@ IMPiView_Process_CheckBox( VMtView_CheckBox *checkbox; TMtPlaceHolder checkbox_ref; char *checkbox_title; - + // create the dialog template error = TMrConstruction_Instance_Renew( @@ -648,7 +648,7 @@ IMPiView_Process_CheckBox( 0, &checkbox); IMPmError_ReturnOnErrorMsg(error, "Could not create a template"); - + // initialize the fields checkbox->flags = VMcCommonFlag_None; checkbox->reserved = 0; @@ -664,7 +664,7 @@ IMPiView_Process_CheckBox( "common_flags", &checkbox->flags); IMPmError_ReturnOnErrorMsg(error, "Unable to get the flags"); - + // get the title location offset error = IMPiProcessLocation( @@ -672,7 +672,7 @@ IMPiView_Process_CheckBox( "title_location_offset", &checkbox->title_location_offset); IMPmError_ReturnOnErrorMsg(error, "Unable to get the location"); - + // process the part specifications error = IMPiProcessPartSpecification( @@ -684,7 +684,7 @@ IMPiView_Process_CheckBox( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // process the part specifications error = IMPiProcessPartSpecification( @@ -696,7 +696,7 @@ IMPiView_Process_CheckBox( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // process the part specifications error = IMPiProcessPartSpecification( @@ -708,7 +708,7 @@ IMPiView_Process_CheckBox( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // read the title error = GRrGroup_GetString( @@ -716,19 +716,19 @@ IMPiView_Process_CheckBox( "title", &checkbox_title); IMPmError_ReturnOnErrorMsg(error, "Unable to get string"); - + UUrString_Copy(checkbox->title, checkbox_title, VMcMaxTitleLength); // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View_CheckBox, inInstanceName, &checkbox_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the template"); - + *outViewData = checkbox_ref; - + return UUcError_None; } @@ -743,7 +743,7 @@ IMPiView_Process_Dialog( UUtError error; DMtDialogData *dialog; TMtPlaceHolder dialog_ref; - + // create the dialog template error = TMrConstruction_Instance_Renew( @@ -752,7 +752,7 @@ IMPiView_Process_Dialog( 0, &dialog); IMPmError_ReturnOnErrorMsg(error, "Could not create a dialog template"); - + // process the part specifications error = IMPiProcessPartSpecification( @@ -764,7 +764,7 @@ IMPiView_Process_Dialog( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // read the background textures error = IMPiProcessTextures( @@ -773,7 +773,7 @@ IMPiView_Process_Dialog( &dialog->b_textures, "b_list"); IMPmError_ReturnOnErrorMsg(error, "Could not get the background textures"); - + // read the flags error = IMPiProcessViewFlags( @@ -782,20 +782,20 @@ IMPiView_Process_Dialog( "dialog_flags", &dialog->flags); IMPmError_ReturnOnErrorMsg(error, "Unable to get view flags"); - + // initialize the fields dialog->reserved = 0; - + // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( DMcTemplate_DialogData, inInstanceName, &dialog_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the dialog"); - + *outViewData = dialog_ref; - + return UUcError_None; } @@ -811,7 +811,7 @@ IMPiView_Process_EditField( VMtView_EditField *editfield; TMtPlaceHolder editfield_ref; UUtUns16 temp; - + // create the template error = TMrConstruction_Instance_Renew( @@ -820,13 +820,13 @@ IMPiView_Process_EditField( 0, &editfield); IMPmError_ReturnOnErrorMsg(error, "Could not create the template"); - + // initialize the text editfield->flags = 0; editfield->max_chars = DMcControl_EditField_MaxChars; editfield->text_location_offset.x = 0; editfield->text_location_offset.y = 0; - + // read the flags error = IMPiProcessViewFlags( @@ -835,7 +835,7 @@ IMPiView_Process_EditField( "common_flags", &editfield->flags); IMPmError_ReturnOnErrorMsg(error, "Unable to get flags"); - + // read the max_chars error = GRrGroup_GetUns16( @@ -850,7 +850,7 @@ IMPiView_Process_EditField( { editfield->max_chars = temp; } - + // get the text location offset error = IMPiProcessLocation( @@ -858,7 +858,7 @@ IMPiView_Process_EditField( "text_location_offset", &editfield->text_location_offset); IMPmError_ReturnOnErrorMsg(error, "Unable to get the location"); - + // process the part specifications error = IMPiProcessPartSpecification( @@ -870,17 +870,17 @@ IMPiView_Process_EditField( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View_EditField, inInstanceName, &editfield_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the template"); - + *outViewData = editfield_ref; - + return UUcError_None; } @@ -895,7 +895,7 @@ IMPiView_Process_ListBox( UUtError error; VMtView_ListBox *listbox; TMtPlaceHolder listbox_ref; - + // create the template error = TMrConstruction_Instance_Renew( @@ -904,7 +904,7 @@ IMPiView_Process_ListBox( 0, &listbox); IMPmError_ReturnOnErrorMsg(error, "Could not create the template"); - + // initialize the fields listbox->backborder = NULL; listbox->flags = VMcCommonFlag_None; @@ -930,17 +930,17 @@ IMPiView_Process_ListBox( "common_flags", &listbox->flags); IMPmError_ReturnOnErrorMsg(error, "Unable to get the flags"); - + // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View_ListBox, inInstanceName, &listbox_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the template"); - + *outViewData = listbox_ref; - + return UUcError_None; } @@ -955,7 +955,7 @@ IMPiView_Process_Picture( UUtError error; VMtView_Picture *picture; TMtPlaceHolder picture_ref; - + // create the template error = TMrConstruction_Instance_Renew( @@ -964,7 +964,7 @@ IMPiView_Process_Picture( 0, &picture); IMPmError_ReturnOnErrorMsg(error, "Could not create the template"); - + // read the background textures error = IMPiProcessTextures( @@ -976,7 +976,7 @@ IMPiView_Process_Picture( { IMPmError_ReturnOnErrorMsg(error, "Could not get the background textures"); } - + // process the part specifications error = IMPiProcessPartSpecification( @@ -988,23 +988,23 @@ IMPiView_Process_Picture( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + if ((picture->b_textures == NULL) && (picture->partspec == NULL)) { IMPmError_ReturnOnErrorMsg(error, "Picture is not complete"); } - + // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View_Picture, inInstanceName, &picture_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the template"); - + *outViewData = picture_ref; - + return UUcError_None; } @@ -1020,7 +1020,7 @@ IMPiView_Process_RadioButton( VMtView_RadioButton *radiobutton; TMtPlaceHolder radiobutton_ref; char *radiobutton_title; - + // create the dialog template error = TMrConstruction_Instance_Renew( @@ -1029,7 +1029,7 @@ IMPiView_Process_RadioButton( 0, &radiobutton); IMPmError_ReturnOnErrorMsg(error, "Could not create a template"); - + // initialize the fields radiobutton->flags = VMcCommonFlag_None; radiobutton->reserved = 0; @@ -1043,7 +1043,7 @@ IMPiView_Process_RadioButton( "common_flags", &radiobutton->flags); IMPmError_ReturnOnErrorMsg(error, "Unable to get the flags"); - + // process the part specifications error = IMPiProcessPartSpecification( @@ -1055,7 +1055,7 @@ IMPiView_Process_RadioButton( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // process the part specifications error = IMPiProcessPartSpecification( @@ -1075,19 +1075,19 @@ IMPiView_Process_RadioButton( "title", &radiobutton_title); IMPmError_ReturnOnErrorMsg(error, "Unable to get string"); - + UUrString_Copy(radiobutton->title, radiobutton_title, VMcMaxTitleLength); // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View_RadioButton, inInstanceName, &radiobutton_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the template"); - + *outViewData = radiobutton_ref; - + return UUcError_None; } @@ -1102,7 +1102,7 @@ IMPiView_Process_RadioGroup( UUtError error; VMtView_RadioGroup *radiogroup; TMtPlaceHolder radiogroup_ref; - + // create the dialog template error = TMrConstruction_Instance_Renew( @@ -1111,7 +1111,7 @@ IMPiView_Process_RadioGroup( 0, &radiogroup); IMPmError_ReturnOnErrorMsg(error, "Could not create a template"); - + // initialize the fields radiogroup->outline = NULL; @@ -1128,15 +1128,15 @@ IMPiView_Process_RadioGroup( } // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View_RadioGroup, inInstanceName, &radiogroup_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the template"); - + *outViewData = radiogroup_ref; - + return UUcError_None; } @@ -1151,7 +1151,7 @@ IMPiView_Process_Scrollbar( UUtError error; VMtView_Scrollbar *scrollbar; TMtPlaceHolder scrollbar_ref; - + // create the dialog template error = TMrConstruction_Instance_Renew( @@ -1160,13 +1160,13 @@ IMPiView_Process_Scrollbar( 0, &scrollbar); IMPmError_ReturnOnErrorMsg(error, "Could not create a template"); - + // initialize the fields scrollbar->vertical_scrollbar = NULL; scrollbar->vertical_thumb = NULL; scrollbar->horizontal_scrollbar = NULL; scrollbar->horizontal_thumb = NULL; - + // process the part specifications error = IMPiProcessPartSpecification( @@ -1190,7 +1190,7 @@ IMPiView_Process_Scrollbar( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // process the part specifications error = IMPiProcessPartSpecification( @@ -1214,17 +1214,17 @@ IMPiView_Process_Scrollbar( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View_Scrollbar, inInstanceName, &scrollbar_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the template"); - + *outViewData = scrollbar_ref; - + return UUcError_None; } @@ -1240,7 +1240,7 @@ IMPiView_Process_Slider( VMtView_Slider *slider; TMtPlaceHolder slider_ref; char *title; - + // create the dialog template error = TMrConstruction_Instance_Renew( @@ -1249,13 +1249,13 @@ IMPiView_Process_Slider( 0, &slider); IMPmError_ReturnOnErrorMsg(error, "Could not create a template"); - + // initialize the fields slider->flags = 0; slider->reserved = 0; slider->outline = NULL; slider->title[0] = '\0'; - + // read the title error = GRrGroup_GetString( @@ -1263,9 +1263,9 @@ IMPiView_Process_Slider( "title", &title); IMPmError_ReturnOnErrorMsg(error, "Unable to get view type"); - + UUrString_Copy(slider->title, title, VMcMaxTitleLength); - + // process the part specifications error = IMPiProcessPartSpecification( @@ -1277,7 +1277,7 @@ IMPiView_Process_Slider( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // read the flags error = IMPiProcessViewFlags( @@ -1288,15 +1288,15 @@ IMPiView_Process_Slider( IMPmError_ReturnOnErrorMsg(error, "Unable to get flags"); // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View_Slider, inInstanceName, &slider_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the template"); - + *outViewData = slider_ref; - + return UUcError_None; } @@ -1311,7 +1311,7 @@ IMPiView_Process_Tab( UUtError error; VMtView_Tab *tab; TMtPlaceHolder tab_ref; - + // create the template error = TMrConstruction_Instance_Renew( @@ -1320,10 +1320,10 @@ IMPiView_Process_Tab( 0, &tab); IMPmError_ReturnOnErrorMsg(error, "Could not create the template"); - + tab->tab_button = NULL; tab->outline = NULL; - + // process the part specifications error = IMPiProcessPartSpecification( @@ -1335,7 +1335,7 @@ IMPiView_Process_Tab( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // process the part specifications error = IMPiProcessPartSpecification( @@ -1347,17 +1347,17 @@ IMPiView_Process_Tab( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View_Tab, inInstanceName, &tab_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the template"); - + *outViewData = tab_ref; - + return UUcError_None; } @@ -1385,7 +1385,7 @@ IMPiView_Process_Text( VMtView_Text *text; TMtPlaceHolder text_ref; char *string; - + // create the template error = TMrConstruction_Instance_Renew( @@ -1394,14 +1394,14 @@ IMPiView_Process_Text( 0, &text); IMPmError_ReturnOnErrorMsg(error, "Could not create the template"); - + // initialize the text text->flags = 0; text->text_location_offset.x = 0; text->text_location_offset.y = 0; text->outline = NULL; text->string[0] = '\0'; - + // read the flags error = IMPiProcessViewFlags( @@ -1410,7 +1410,7 @@ IMPiView_Process_Text( "common_flags", &text->flags); IMPmError_ReturnOnErrorMsg(error, "Unable to get view flags"); - + // get the text location offset error = IMPiProcessLocation( @@ -1418,7 +1418,7 @@ IMPiView_Process_Text( "text_location_offset", &text->text_location_offset); IMPmError_ReturnOnErrorMsg(error, "Unable to get the location"); - + // get the string error = GRrGroup_GetString( @@ -1426,9 +1426,9 @@ IMPiView_Process_Text( "string", &string); IMPmError_ReturnOnErrorMsg(error, "Unable to get the string"); - + UUrString_Copy(text->string, string, VMcView_Text_MaxStringLength); - + // process the part specifications error = IMPiProcessPartSpecification( @@ -1440,17 +1440,17 @@ IMPiView_Process_Text( { IMPmError_ReturnOnErrorMsg(error, "Could not process part specification"); } - + // get a placeholder - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View_Text, inInstanceName, &text_ref); IMPmError_ReturnOnErrorMsg(error, "Could not get placeholder for the template"); - + *outViewData = text_ref; - + return UUcError_None; } @@ -1491,10 +1491,10 @@ Imp_AddPartSpecification( UUtBool bool_result; UUtBool build_instance; - + UUtUns32 create_date; UUtUns32 compile_date; - + // check to see if the dialogs need to be built bool_result = TMrConstruction_Instance_CheckExists( @@ -1504,7 +1504,7 @@ Imp_AddPartSpecification( if (bool_result) { compile_date = UUrConvertStrToSecsSince1900(gViewCompileTime); - + build_instance = (UUtBool)(create_date < inSourceFileModDate || create_date < compile_date); } @@ -1512,7 +1512,7 @@ Imp_AddPartSpecification( { build_instance = UUcTrue; } - + if (build_instance) { GRtElementType element_type; @@ -1521,7 +1521,7 @@ Imp_AddPartSpecification( UUtUns16 i; VMtPartSpec *part_spec; TMtPlaceHolder texture; - + // get the texture error = IMPiProcessSingleTexture( @@ -1542,14 +1542,14 @@ Imp_AddPartSpecification( 0, &part_spec); IMPmError_ReturnOnErrorMsg(error, "Could not create a part specification template"); - + // set the texture part_spec->texture = (void*)texture; - + // clear the part matrices UUrMemory_Clear(part_spec->part_matrix_tl, sizeof(part_spec->part_matrix_tl)); UUrMemory_Clear(part_spec->part_matrix_br, sizeof(part_spec->part_matrix_br)); - + // get the parts specs error = GRrGroup_GetElement( @@ -1561,9 +1561,9 @@ Imp_AddPartSpecification( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get part specs array"); } - + num_parts = (UUtUns16)GRrGroup_Array_GetLength(part_spec_array); - + // process the part specs for (i = 0; i < num_parts; i++) { @@ -1575,7 +1575,7 @@ Imp_AddPartSpecification( UUtInt32 right; UUtInt32 bottom; tParts *parts; - + // get the element i from the part spec array error = GRrGroup_Array_GetElement( @@ -1584,19 +1584,19 @@ Imp_AddPartSpecification( &element_type, &part_array); if ((error != UUcError_None) || (element_type != GRcElementType_Array)) - { + { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get part spec from array"); } - + if (GRrGroup_Array_GetLength(part_array) != 5) { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "the part array in not correct"); } - + // ------------------------------ // process the elements of the part // ------------------------------ - + // get the part name error = GRrGroup_Array_GetElement( @@ -1608,7 +1608,7 @@ Imp_AddPartSpecification( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "the part array in not correct"); } - + // get the left coordinate of the part left = 0; error = @@ -1627,7 +1627,7 @@ Imp_AddPartSpecification( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "the part array in not correct"); } - + // get the top coordinate of the part top = 0; error = @@ -1646,7 +1646,7 @@ Imp_AddPartSpecification( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "the part array in not correct"); } - + // get the right coordinate of the part right = 0; error = @@ -1665,7 +1665,7 @@ Imp_AddPartSpecification( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "the part array in not correct"); } - + // get the bottom coordinate of the part bottom = 0; error = @@ -1684,7 +1684,7 @@ Imp_AddPartSpecification( { IMPmError_ReturnOnErrorMsg(UUcError_Generic, "the part array in not correct"); } - + // stick the elements into the template for (parts = IMPgParts; parts->name != NULL; parts++) { @@ -1699,7 +1699,7 @@ Imp_AddPartSpecification( } } } - + return UUcError_None; } @@ -1715,10 +1715,10 @@ Imp_AddView( UUtBool bool_result; UUtBool build_instance; - + UUtUns32 create_date; UUtUns32 compile_date; - + // check to see if the dialogs need to be built bool_result = TMrConstruction_Instance_CheckExists( @@ -1728,7 +1728,7 @@ Imp_AddView( if (bool_result) { compile_date = UUrConvertStrToSecsSince1900(gViewCompileTime); - + build_instance = (UUtBool)(create_date < inSourceFileModDate || create_date < compile_date); } @@ -1736,7 +1736,7 @@ Imp_AddView( { build_instance = UUcTrue; } - + if (build_instance) { UUtUns16 id; @@ -1753,7 +1753,7 @@ Imp_AddView( TMtPlaceHolder view_data; UUtUns16 i; tViewProc *viewproc; - + // get the id error = GRrGroup_GetUns16( @@ -1761,7 +1761,7 @@ Imp_AddView( "id", &id); IMPmError_ReturnOnErrorMsg(error, "Unable to get view id"); - + // get the type name error = GRrGroup_GetString( @@ -1769,7 +1769,7 @@ Imp_AddView( "type", &type_name); IMPmError_ReturnOnErrorMsg(error, "Unable to get view type"); - + // get the flags error = IMPiProcessViewFlags( @@ -1778,7 +1778,7 @@ Imp_AddView( "view_flags", &flags); IMPmError_ReturnOnErrorMsg(error, "Unable to get view flags"); - + // get the location error = IMPiProcessLocation( @@ -1786,7 +1786,7 @@ Imp_AddView( "location", &location); IMPmError_ReturnOnErrorMsg(error, "Unable to get view location"); - + // get the width error = GRrGroup_GetInt16( @@ -1802,7 +1802,7 @@ Imp_AddView( "height", &height); IMPmError_ReturnOnErrorMsg(error, "Unable to get view height"); - + // get the view data view_data = 0; for (viewproc = IMPgViewProc; @@ -1816,7 +1816,7 @@ Imp_AddView( break; } } - + // get the views array error = GRrGroup_GetElement( @@ -1837,13 +1837,13 @@ Imp_AddView( views_array = NULL; } } - + // get the number of elements in the views array if (views_array) num_child_views = (UUtUns16)GRrGroup_Array_GetLength(views_array); else num_child_views = 0; - + // create an view template instance error = TMrConstruction_Instance_Renew( @@ -1852,7 +1852,7 @@ Imp_AddView( num_child_views, &view); IMPmError_ReturnOnErrorMsg(error, "Could not create a view template"); - + // set the fields of view view->id = id; view->type = type; @@ -1861,14 +1861,14 @@ Imp_AddView( view->width = width; view->height = height; view->view_data = (TMtPlaceHolder*)view_data; - + // copy the views from the views_array for (i = 0; i < num_child_views; i++) { void *view_description; TMtPlaceHolder view_ref; char *instance_name; - + // get the name of the view error = GRrGroup_Array_GetElement( @@ -1877,7 +1877,7 @@ Imp_AddView( &element_type, &view_description); IMPmError_ReturnOnErrorMsg(error, "Could not get view ref name"); - + if (element_type == GRcElementType_String) { instance_name = view_description; @@ -1891,7 +1891,7 @@ Imp_AddView( "instance", &instance_name); IMPmError_ReturnOnErrorMsg(error, "Could not get instance name"); - + // process the group error = Imp_AddView( @@ -1903,7 +1903,7 @@ Imp_AddView( } // get a place holder for the view - error = + error = TMrConstruction_Instance_GetPlaceHolder( VMcTemplate_View, instance_name, @@ -1913,7 +1913,7 @@ Imp_AddView( view->child_views[i].view_ref = (void*)view_ref; } } - + return UUcError_None; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_View.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_View.h index e87cdee..39543a4 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_View.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_View.h @@ -19,7 +19,7 @@ Imp_AddPartSpecification( UUtUns32 inSourceFileModDate, GRtGroup* inGroup, char* inInstanceName); - + UUtError Imp_AddView( BFtFileRef* inSourceFile, diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Weapon.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Weapon.c index 25fc31b..68636b3 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Weapon.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Weapon.c @@ -1,12 +1,12 @@ /* FILE: Imp_Weapon.c - + AUTHOR: Michael Evans - + CREATED: 3/18/1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 Bungie Software */ @@ -29,7 +29,7 @@ #define IMPcBarrelLineLen 6 -AUtFlagElement IMPgWeaponClassFlags[] = +AUtFlagElement IMPgWeaponClassFlags[] = { { "big", @@ -80,11 +80,11 @@ AUtFlagElement IMPgWeaponClassFlags[] = WPcWeaponClassFlag_HasLaser }, { - "no_cursor_scale", + "no_cursor_scale", WPcWeaponClassFlag_NoScale }, { - "half_cursor_scale", + "half_cursor_scale", WPcWeaponClassFlag_HalfScale }, { @@ -121,7 +121,7 @@ AUtFlagElement IMPgWeaponClassFlags[] = } }; -AUtFlagElement IMPgWeaponTargetingFlags[] = +AUtFlagElement IMPgWeaponTargetingFlags[] = { { "no-wild-shots", @@ -198,7 +198,7 @@ Imp_AddWeapon( UUtBool twoHanded = UUcFalse; UUtInt32 tempint; float tempfloat; - + if (TMrConstruction_Instance_CheckExists(WPcTemplate_WeaponClass, inInstanceName)) { return UUcError_None; } @@ -278,7 +278,7 @@ Imp_AddWeapon( static M3tVector3D weapon_orient_dir = {1, 0, 0}; M3tQuaternion ai_shooter_inverse_quat; AI2tWeaponParameters *parameters; - + // set up defaults weapon->attachment_count = 0; weapon->shooter_count = 0; @@ -290,10 +290,10 @@ Imp_AddWeapon( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "attachments must be an array"); } - + weapon->attachment_count = (UUtUns16) GRrGroup_Array_GetLength(attachmentArray); found_shooters = 0; - + for(itr = 0, attachment = weapon->attachment; itr < weapon->attachment_count; itr++, attachment++) { error = GRrGroup_Array_GetElement(attachmentArray, itr, @@ -302,17 +302,17 @@ Imp_AddWeapon( sprintf(errmsg, "could not get attachment #%d from group", itr); UUmError_ReturnOnErrorMsg(error, errmsg); } - + if(elementType != GRcElementType_Group) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "every element of 'attachments' array must be a group"); } - + // find the marker on the weapon that this is attached to error = GRrGroup_GetString(attachmentGroup, "marker", &tempstring); UUmError_ReturnOnErrorMsg(error, "every attachment entry must have a 'marker'"); - marker = Imp_EnvFile_GetMarker(header->nodes + 0, tempstring); + marker = Imp_EnvFile_GetMarker(header->nodes + 0, tempstring); if (marker) { // it's important that the attachment matrix should be a rigid body transformation matrix // i.e. no scale or shear. so we do this orthonormal basis construction thang. @@ -335,12 +335,12 @@ Imp_AddWeapon( sprintf(errmsg, "couldn't find marker %s on the weapon geometry", tempstring); UUmError_ReturnOnErrorMsg(UUcError_Generic, errmsg); } - + // find the particle class error = GRrGroup_GetString(attachmentGroup, "particle_class", &tempstring); UUmError_ReturnOnErrorMsg(error, "every attachment entry must have a 'particle_class'"); - + if ((strlen(tempstring) < 1) || (strlen(tempstring) > P3cParticleClassNameLength)) { sprintf(errmsg, "particle class name '%s' is not within range 1-%d chars", tempstring, P3cParticleClassNameLength); UUmError_ReturnOnErrorMsg(UUcError_Generic, errmsg); @@ -430,7 +430,7 @@ Imp_AddWeapon( } } - if (found_shooters < 0) + if (found_shooters < 0) { MUrMatrix_Identity(&weapon->ai_parameters_alt.shooter_inversematrix); MUmVector_Set(weapon->ai_parameters.shooterdir_gunspace, 1, 0, 0); @@ -446,14 +446,14 @@ Imp_AddWeapon( if (UUcError_None == error) { char mungedTextureName[BFcMaxFileNameLength]; - + UUrString_Copy(mungedTextureName, textureName, BFcMaxFileNameLength); UUrString_StripExtension(mungedTextureName); weapon->geometry->baseMap = M3rTextureMap_GetPlaceholder(mungedTextureName); } - // maximum sight distance + // maximum sight distance error = GRrGroup_GetFloat(inGroup, "maximum_sight_distance", &weapon->maximum_sight_distance); if (UUcError_None != error) { weapon->maximum_sight_distance = 5000.f; @@ -549,7 +549,7 @@ Imp_AddWeapon( // free time error = GRrGroup_GetUns16(inGroup, "freeTime", &(weapon->freeTime)); if (error != UUcError_None) weapon->freeTime = 0; - + // name UUrString_Copy(weapon->name,inInstanceName,WPcMaxWeaponName); @@ -598,7 +598,7 @@ Imp_AddWeapon( weapon->flags |= WPcWeaponClassFlag_RecoilDirect; } } - + // okay if icon is NULL error = GRrGroup_GetString(inGroup, "icon", &icon_name); if (error == UUcError_None) @@ -729,7 +729,7 @@ UUtError Imp_Weapon_ReadAIParameters( void *element; GRtElementType element_type; - + // NB: ai_parameters.shooterdir_gunspace and shooter_inversematrix must be set up separately to this // call! @@ -803,4 +803,4 @@ UUtError Imp_Weapon_ReadAIParameters( } return UUcError_None; -} \ No newline at end of file +} diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Weapon.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Weapon.h index 74cfd69..d31849a 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Weapon.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/Imp_Weapon.h @@ -1,12 +1,12 @@ /* FILE: Imp_Weapon.h - + AUTHOR: Michael Evans - + CREATED: 3/18/1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 Bungie Software */ @@ -34,4 +34,4 @@ UUtError Imp_Weapon_ReadAIParameters( UUtBool inAlternateParameters, AI2tWeaponParameters *inParameters); -#endif \ No newline at end of file +#endif diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/machdep.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/machdep.h index f34b3b8..1882090 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/machdep.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/machdep.h @@ -4,23 +4,23 @@ * Copyright (c) 1988, 1989, 1990, 1991 Sam Leffler * Copyright (c) 1991 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/prototypes.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/prototypes.h index bea49c1..f9064d1 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/prototypes.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/prototypes.h @@ -4,23 +4,23 @@ * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/t4.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/t4.h index ce86d48..5a5dc1e 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/t4.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/t4.h @@ -4,23 +4,23 @@ * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_aux.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_aux.c index 7697b79..1b80621 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_aux.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_aux.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_ccittrle.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_ccittrle.c index 10013d5..c3da5e4 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_ccittrle.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_ccittrle.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_close.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_close.c index 298162f..0d75e74 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_close.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_close.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_compat.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_compat.c index 732e20a..98dcd50 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_compat.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_compat.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -78,7 +78,7 @@ TIFFUnmapFileContents(base, size) #include /* - * Table for storing information on current open sections. + * Table for storing information on current open sections. * (You may want to substitute a linked list...) */ #define MAX_MAPPED 100 @@ -89,8 +89,8 @@ static struct { unsigned channel; } map_table[MAX_MAPPED]; -/* - * This routine maps a file into a private section. Note that this +/* + * This routine maps a file into a private section. Note that this * method of accessing a file is by far the fastest under VMS. * The routine may fail (i.e. return 0) for several reasons, for * example: @@ -114,7 +114,7 @@ TIFFMapFileContents(fd, pbase, psize) void *inadr[2], *retadr[2]; unsigned long status; long size; - + if (no_mapped >= MAX_MAPPED) return(0); /* @@ -160,7 +160,7 @@ TIFFMapFileContents(fd, pbase, psize) } /* - * This routine unmaps a section from the virtual address space of + * This routine unmaps a section from the virtual address space of * the process, but only if the base was the one returned from a * call to TIFFMapFileContents. */ @@ -171,7 +171,7 @@ TIFFUnmapFileContents(base, size) { void *inadr[2]; int i, j; - + /* Find the section in the table */ for (i = 0;i < no_mapped; i++) { if (map_table[i].base == base) { @@ -195,7 +195,7 @@ long TIFFGetFileSize(int fd) { long pos, eof; - + pos = lseek(fd, 0, SEEK_CUR); eof = lseek(fd, 0, SEEK_END); lseek(fd, pos, SEEK_SET); @@ -213,11 +213,11 @@ mpw_lseek(int fd, long offset, int whence) { long filepos, filesize, newpos; short macfd; - + if ((filepos = lseek(fd, 0, SEEK_CUR)) < 0 || (filesize = lseek(fd, 0, SEEK_END)) < 0) return (EOF); - newpos = offset + (whence == SEEK_SET ? 0 : + newpos = offset + (whence == SEEK_SET ? 0 : whence == SEEK_CUR ? filepos : filesize); if (newpos > filesize) diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_compress.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_compress.c index 6e8977c..df6d9e2 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_compress.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_compress.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dir.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dir.c index 1e40cbd..2929ab6 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dir.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dir.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -249,7 +249,7 @@ TIFFSetField1(tif, tag, ap) goto badvalue; if (v > 4) { TIFFError(tif->tif_name, - "Cannot handle %ld-channel data", v); + "Cannot handle %ld-channel data", v); status = 0; } else td->td_samplesperpixel = v; diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dirinfo.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dirinfo.c index fd090b0..85f0b2a 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dirinfo.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dirinfo.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dirread.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dirread.c index d31f24f..b8b4835 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dirread.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dirread.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -298,7 +298,7 @@ TIFFReadDirectory(tif) MissingRequired(tif, "PlanarConfiguration"); goto bad; } - /* + /* * Setup appropriate structures (by strip or by tile) */ if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { @@ -562,7 +562,7 @@ EstimateStripByteCounts(tif, dir, dircount) * should begin. Since a strip of data must be contiguous, * it's safe to assume that we've overestimated the amount * of data in the strip and trim this number back accordingly. - */ + */ if (td->td_stripoffset[0] + td->td_stripbytecount[0] > filesize) td->td_stripbytecount[0] = filesize - td->td_stripoffset[0]; @@ -952,7 +952,7 @@ TIFFFetchNormalTag(tif, dp) } /* - * Fetch samples/pixel short values for + * Fetch samples/pixel short values for * the specified tag and verify that * all values are the same. */ @@ -1187,7 +1187,7 @@ TIFFFetchExtraSamples(tif, dp) TIFFDirEntry *dp; { int type; - + if (dp->tdir_count != 1) { TIFFError(tif->tif_name, "Can not handle more than 1 extra sample/pixel"); diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dirwrite.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dirwrite.c index b22bac7..35e0773 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dirwrite.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dirwrite.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dumpmode.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dumpmode.c index 30f818c..7d0156c 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dumpmode.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_dumpmode.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_error.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_error.c index a85a3f4..a09e595 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_error.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_error.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_fax3.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_fax3.c index b4c7ba7..16d7678 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_fax3.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_fax3.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -258,7 +258,7 @@ Fax3SetupState(tif, space) sp = (Fax3BaseState *)tif->tif_data; sp->rowbytes = rowbytes; sp->rowpixels = rowpixels; - sp->bitmap = (tif->tif_fillorder != td->td_fillorder ? + sp->bitmap = (tif->tif_fillorder != td->td_fillorder ? TIFFBitRevTable : TIFFNoBitRevTable); sp->white = (td->td_photometric == PHOTOMETRIC_MINISBLACK); if (is2DEncoding(tif) || td->td_compression == COMPRESSION_CCITTFAX4) { diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_fax3.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_fax3.h index 41e1c7a..c2681a7 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_fax3.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_fax3.h @@ -4,23 +4,23 @@ * Copyright (c) 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_fax4.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_fax4.c index f72ce80..78559bb 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_fax4.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_fax4.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_flush.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_flush.c index 3e3b220..b4b3f31 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_flush.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_flush.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_getimage.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_getimage.c index bb14413..5172fc2 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_getimage.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_getimage.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -229,7 +229,7 @@ gt(tif, w, h, raster) gtTileSeparate(tif, raster, Map, h, w) : gtStripSeparate(tif, raster, Map, h, w); } else { - e = TIFFIsTiled(tif) ? + e = TIFFIsTiled(tif) ? gtTileContig(tif, raster, Map, h, w) : gtStripContig(tif, raster, Map, h, w); } @@ -284,7 +284,7 @@ static tileContigRoutine pickTileContigCase(); * PlanarConfiguration contiguous if SamplesPerPixel > 1 * or * SamplesPerPixel == 1 - */ + */ static gtTileContig(tif, raster, Map, h, w) TIFF *tif; @@ -350,7 +350,7 @@ static tileSeparateRoutine pickTileSeparateCase(); * SamplesPerPixel > 1 * PlanarConfiguration separated * We assume that all such images are RGB. - */ + */ static gtTileSeparate(tif, raster, Map, h, w) TIFF *tif; @@ -416,7 +416,7 @@ gtTileSeparate(tif, raster, Map, h, w) * PlanarConfiguration contiguous if SamplesPerPixel > 1 * or * SamplesPerPixel == 1 - */ + */ static gtStripContig(tif, raster, Map, h, w) TIFF *tif; @@ -683,7 +683,7 @@ c = x; *p++ = PACK(rmap[c]&0xff, gmap[c]&0xff, bmap[c]&0xff); op2; \ } \ } - + #define SKEW(r,g,b,skew) { r += skew; g += skew; b += skew; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_jpeg.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_jpeg.c index 881cbfa..6d79d53 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_jpeg.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_jpeg.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_lzw.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_lzw.c index 00fd6b0..65d1982 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_lzw.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_lzw.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -446,7 +446,7 @@ LZWDecode(tif, op0, occ0, s) sp->lzw_nbits = BITS_MAX; SetMaxCode(sp, MAXCODE(sp->lzw_nbits)); } - } + } oldcode = incode; } sp->dec_stackp = stackp; @@ -646,16 +646,16 @@ LZWPreEncode(tif) /* * Encode a scanline of pixels. * - * Uses an open addressing double hashing (no chaining) on the + * Uses an open addressing double hashing (no chaining) on the * prefix code/next character combination. We do a variant of * Knuth's algorithm D (vol. 3, sec. 6.4) along with G. Knott's * relatively-prime secondary probe. Here, the modular division - * first probe is gives way to a faster exclusive-or manipulation. + * first probe is gives way to a faster exclusive-or manipulation. * Also do block compression with an adaptive reset, whereby the * code table is cleared when the compression ratio decreases, * but after the table fills. The variable-length output codes * are re-sized at this point, and a CODE_CLEAR is generated - * for the decoder. + * for the decoder. */ static LZWEncode(tif, bp, cc, s) @@ -846,7 +846,7 @@ PutNextCode(tif, c) * be updated for the mainline write code in TIFFWriteScanline() * so that data is flushed when the end of a strip is reached. * Note that the latter is rounded up to ensure that a non-zero - * byte count is present. + * byte count is present. */ sp->enc_outcount += sp->lzw_nbits; sp->lzw_bitoff += sp->lzw_nbits; diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_machdep.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_machdep.c index f08a0cd..08d06a2 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_machdep.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_machdep.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1992 Sam Leffler * Copyright (c) 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_next.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_next.c index 272b441..aa5e233 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_next.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_next.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_open.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_open.c index ed4868a..6e12d00 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_open.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_open.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -241,7 +241,7 @@ TIFFFdOpen(fd, name, mode) TIFFError(name, "Not a TIFF file, bad version number %d (0x%x)", tif->tif_header.tiff_version, - tif->tif_header.tiff_version); + tif->tif_header.tiff_version); goto bad; } tif->tif_flags |= TIFF_MYBUFFER; @@ -297,7 +297,7 @@ TIFFScanlineSize(tif) { TIFFDirectory *td = &tif->tif_dir; long scanline; - + scanline = td->td_bitspersample * td->td_imagewidth; if (td->td_planarconfig == PLANARCONFIG_CONTIG) scanline *= td->td_samplesperpixel; diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_packbits.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_packbits.c index 451d02d..a75820c 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_packbits.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_packbits.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_print.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_print.c index 283a79f..29ae186 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_print.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_print.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_read.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_read.c index a7f43e0..ba1d2e2 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_read.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_read.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -159,7 +159,7 @@ TIFFReadEncodedStrip(tif, strip, buf, size) size = stripsize; else if (size > stripsize) size = stripsize; - return (TIFFFillStrip(tif, strip) && + return (TIFFFillStrip(tif, strip) && (*tif->tif_decodestrip)(tif, buf, size, strip / td->td_stripsperimage) ? size : -1); } @@ -227,7 +227,7 @@ TIFFReadRawStrip1(tif, strip, buf, size, module) } /* - * Read the specified strip and setup for decoding. + * Read the specified strip and setup for decoding. * The data buffer is expanded, as necessary, to * hold the strip's data. */ @@ -356,7 +356,7 @@ TIFFReadEncodedTile(tif, tile, buf, size) size = tilesize; else if (size > tilesize ) size = tilesize; - return (TIFFFillTile(tif, tile) && + return (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif, buf, size, tile/td->td_stripsperimage) ? size : -1); } @@ -424,7 +424,7 @@ TIFFReadRawTile1(tif, tile, buf, size, module) } /* - * Read the specified tile and setup for decoding. + * Read the specified tile and setup for decoding. * The data buffer is expanded, as necessary, to * hold the tile's data. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_strip.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_strip.c index 68cb5d6..5010ba4 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_strip.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_strip.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_swab.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_swab.c index 82c461a..80db2d2 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_swab.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_swab.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -145,38 +145,38 @@ const unsigned char TIFFNoBitRevTable[256] = { #else unsigned char TIFFNoBitRevTable[256] = { #endif - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, }; TIFFReverseBits(cp, n) diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_thunder.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_thunder.c index 63e8085..dcf00ac 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_thunder.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_thunder.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -135,7 +135,7 @@ ThunderDecodeRow(tif, buf, occ, s) u_int s; { u_char *row = buf; - + while (occ > 0) { if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth)) return (0); diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_tile.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_tile.c index 0863378..05697a9 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_tile.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_tile.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -57,11 +57,11 @@ TIFFComputeTile(tif, x, y, s, z) if (dz == (u_long) -1) dz = td->td_imagedepth; if (dx != 0 && dy != 0 && dz != 0) { - u_int xpt = howmany(td->td_imagewidth, dx); - u_int ypt = howmany(td->td_imagelength, dy); - u_int zpt = howmany(td->td_imagedepth, dz); + u_int xpt = howmany(td->td_imagewidth, dx); + u_int ypt = howmany(td->td_imagelength, dy); + u_int zpt = howmany(td->td_imagedepth, dz); - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) tile = (xpt*ypt*zpt)*s + (xpt*ypt)*(z/dz) + xpt*(y/dy) + @@ -142,7 +142,7 @@ TIFFTileRowSize(tif) { TIFFDirectory *td = &tif->tif_dir; u_long rowsize; - + if (td->td_tilelength == 0 || td->td_tilewidth == 0) return (0); rowsize = td->td_bitspersample * td->td_tilewidth; diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_version.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_version.c index 91b7fd8..ed9909c 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_version.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_version.c @@ -2,23 +2,23 @@ * Copyright (c) 1992 Sam Leffler * Copyright (c) 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include "tiffcompat.h" diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_warning.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_warning.c index 54cae77..d19f471 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_warning.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_warning.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_write.c b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_write.c index 5d45ec3..97df54c 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_write.c +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tif_write.c @@ -6,23 +6,23 @@ static char rcsid[] = "$Header$"; * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -308,7 +308,7 @@ TIFFWriteEncodedTile(tif, tile, data, cc) tif->tif_flags |= TIFF_BUFFERSETUP; } tif->tif_curtile = tile; - /* + /* * Compute tiles per row & per column to compute * current row and column */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiff.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiff.h index c71cc09..ae9abdb 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiff.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiff.h @@ -4,23 +4,23 @@ * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiffcompat.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiffcompat.h index 631ea5a..cf71845 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiffcompat.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiffcompat.h @@ -4,23 +4,23 @@ * Copyright (c) 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -55,7 +55,7 @@ #pragma warning( disable : 4514) // unreferenced inline function #pragma warning( disable : 4761) // integral size mismatch -#pragma warning( disable : 4003) // not enough actual parameters for macro +#pragma warning( disable : 4003) // not enough actual parameters for macro #pragma warning( disable : 4018) // signed/unsigned mismatch #pragma warning( disable : 4101) // unused local variable #pragma warning( disable : 4113) // differing parameter lists diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiffio.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiffio.h index 43d59cd..2c763b0 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiffio.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiffio.h @@ -4,23 +4,23 @@ * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiffioP.h b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiffioP.h index 1b629e9..6625001 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiffioP.h +++ b/BungieFrameWork/BFW_ToolSource/Common/Imp/libtiff/tiffioP.h @@ -4,23 +4,23 @@ * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler * Copyright (c) 1991, 1992 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -209,9 +209,9 @@ typedef struct { extern const TIFFFieldInfo tiffFieldInfo[];/* table of field descriptors */ extern const int tiffDataWidth[]; /* table of tag datatype widths */ -#define BITn(n) (((unsigned)1L)<<((n)&0x1f)) -#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32]) -#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) +#define BITn(n) (((unsigned)1L)<<((n)&0x1f)) +#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32]) +#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field)) #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field)) diff --git a/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/BFW_LSSolution.c b/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/BFW_LSSolution.c index b923e52..520f886 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/BFW_LSSolution.c +++ b/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/BFW_LSSolution.c @@ -1,12 +1,12 @@ /* FILE: BFW_LSSolution.c - + AUTHOR: Brent H. Pease - + CREATED: Jan 1, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -35,7 +35,7 @@ LSrData_WriteBinary( error = BFrFile_Open(inFileRef, "w", &file); UUmError_ReturnOnError(error); - + // Write the endian detector endianDetector = LScEndianDetector; @@ -60,7 +60,7 @@ LSrData_WriteBinary( // Write the point array error = BFrFile_Write(file, inData->num_points * sizeof(LStPoint), inData->the_point_list); UUmError_ReturnOnError(error); - + BFrFile_Close(file); return UUcError_None; @@ -79,7 +79,7 @@ LSrData_ReadBinary( UUtUns32 endianDetector; UUtUns32 i; LStPoint* curPoint; - + error = BFrFile_Open(inFileRef, "r", &file); UUmError_ReturnOnError(error); @@ -88,7 +88,7 @@ LSrData_ReadBinary( { return UUcError_OutOfMemory; } - + // Read the endian detector error = BFrFile_Read(file, 4, &endianDetector); UUmError_ReturnOnError(error); @@ -104,13 +104,13 @@ LSrData_ReadBinary( UUmError_ReturnOnErrorMsg(UUcError_Generic, "ilegal file type"); } } - + error = BFrFile_ReadPos(file, curFilePos, LScPrepVersion_Length, newData->prepVersion); UUmError_ReturnOnError(error); curFilePos += LScPrepVersion_Length; - + if(strcmp(newData->prepVersion, LScPrepVersion)) return UUcError_Generic; - + // Read the number of points and faces error = BFrFile_Read(file, 4, &newData->num_points); UUmError_ReturnOnError(error); @@ -127,7 +127,7 @@ LSrData_ReadBinary( { UUrSwap_4Byte(&newData->brightness); } - + error = BFrFile_Read(file, 4, &newData->contrast); UUmError_ReturnOnError(error); @@ -135,7 +135,7 @@ LSrData_ReadBinary( { UUrSwap_4Byte(&newData->contrast); } - + error = BFrFile_Read(file, 4, &newData->flags); UUmError_ReturnOnError(error); @@ -143,7 +143,7 @@ LSrData_ReadBinary( { UUrSwap_4Byte(&newData->flags); } - + // Allocate memory for the points and faces newData->the_point_list = UUrMemory_Block_New(newData->num_points * sizeof(LStPoint)); if(newData->the_point_list == NULL) @@ -178,7 +178,7 @@ LSrData_ReadBinary( } BFrFile_Close(file); - + *outNewData = newData; return UUcError_None; @@ -188,7 +188,7 @@ UUtUns32 LSrData_GetSize( LStData* inData) { - return sizeof(UUtUns32) * 4 + + return sizeof(UUtUns32) * 4 + inData->num_points * sizeof(LStPoint); } diff --git a/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/BFW_LSSolution.h b/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/BFW_LSSolution.h index b0b717a..6f6f569 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/BFW_LSSolution.h +++ b/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/BFW_LSSolution.h @@ -1,12 +1,12 @@ /* FILE: BFW_LSSolution.h - + AUTHOR: Brent H. Pease - + CREATED: Jan 1, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -47,7 +47,7 @@ typedef struct LStVertex { UUtUns32 pointIndex; float r, g, b; - + } LStVertex; typedef struct LStFace @@ -81,14 +81,14 @@ typedef struct LStData LStPoint *the_point_list; M3tBoundingBox_MinMax bbox; - + float contrast; float brightness; - + char prepVersion[LScPrepVersion_Length]; - + UUtUns32 flags; - + } LStData; UUtError @@ -111,13 +111,13 @@ LSrData_GetSize( LSrData_CreateFromLSFile( const char* inLSFilePath, LStData* *outNewData); - + UUtError LSrPreperationFile_Create( struct IMPtEnv_BuildData* inBuildData, const char* inGQFileName, const char* inLPFilePath); - + #endif void diff --git a/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/LPWriter/BFW_LSPreperation.h b/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/LPWriter/BFW_LSPreperation.h index f4d32c8..93ce4c0 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/LPWriter/BFW_LSPreperation.h +++ b/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/LPWriter/BFW_LSPreperation.h @@ -1,12 +1,12 @@ /* FILE: BFW_LSPreperation.h - + AUTHOR: Brent H. Pease - + CREATED: Nov 20, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -45,7 +45,7 @@ class BFW_LPWriter : public LtTPrepfileExport { void calcTotalArea(); LtTParameterWizard params; // Parameter wizard - + const char* gqFileName; IMPtEnv_BuildData* buildData; diff --git a/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/LSReader/BFW_LSBuilder.h b/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/LSReader/BFW_LSBuilder.h index 830bf57..06cce3b 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/LSReader/BFW_LSBuilder.h +++ b/BungieFrameWork/BFW_ToolSource/Common/LSSolutionFileIO/LSReader/BFW_LSBuilder.h @@ -1,12 +1,12 @@ /* FILE: BFW_LSBuilder.h - + AUTHOR: Brent H. Pease - + CREATED: Jan 1, 1998 - - PURPOSE: - + + PURPOSE: + Copyright 1998 */ @@ -24,7 +24,7 @@ class BFW_LSBuilder; //----------------------------------------------------------------------- -// +// // Factory Classes // @@ -32,7 +32,7 @@ class BFW_LSBuilder; //----------------------------------------------------------------------- //Class BFW_LSBuilderFactory // -//Main factory class for all BFW_LS*Builder classes. +//Main factory class for all BFW_LS*Builder classes. // class BFW_LSBuilderFactory : public LtTBuilderFactory { @@ -41,7 +41,7 @@ class BFW_LSBuilderFactory : public LtTBuilderFactory virtual LtTBool Finish(); BFW_LSBuilderFactory(LStData* lsData, UUtBool build); -protected: +protected: virtual LtTParameterBuilderApi *OnGetParameterBuilder(); virtual LtTInfoBuilderApi *OnGetInfoBuilder(); virtual LtTViewBuilderApi *OnGetViewBuilder(); @@ -61,7 +61,7 @@ class BFW_LSBuilderFactory : public LtTBuilderFactory //----------------------------------------------------------------------- -// +// // Builder Classes // @@ -75,7 +75,7 @@ class BFW_LSInfoBuilder : public LtTBaseInfoBuilder protected: BFW_LSInfoBuilder( LtTBuilderFactory *f, LStData* lsData, UUtBool inBuild); - LtTBool Finish(); + LtTBool Finish(); private: LStData* m_lsData; @@ -92,7 +92,7 @@ class BFW_LSParameterBuilder : public LtTBaseParameterBuilder protected: BFW_LSParameterBuilder( LtTBuilderFactory *f, LStData* lsData, UUtBool inBuild); - LtTBool Finish(); + LtTBool Finish(); private: LStData* m_lsData; @@ -109,7 +109,7 @@ class BFW_LSViewBuilder : public LtTBaseViewBuilder protected: BFW_LSViewBuilder( LtTBuilderFactory *f, LStData* lsData, UUtBool inBuild); - LtTBool Finish(); + LtTBool Finish(); private: LStData* m_lsData; @@ -126,7 +126,7 @@ class BFW_LSLayerBuilder : public LtTBaseLayerBuilder protected: BFW_LSLayerBuilder( LtTBuilderFactory *f, LStData* lsData, UUtBool inBuild); - LtTBool Finish(); + LtTBool Finish(); private: LStData* m_lsData; @@ -143,7 +143,7 @@ class BFW_LSMaterialBuilder : public LtTBaseMaterialBuilder protected: BFW_LSMaterialBuilder( LtTBuilderFactory *f, LStData* lsData, UUtBool inBuild); - LtTBool Finish(); + LtTBool Finish(); private: LStData* m_lsData; @@ -161,7 +161,7 @@ class BFW_LSLampBuilder : public LtTBaseLampBuilder protected: BFW_LSLampBuilder( LtTBuilderFactory *f, LStData* lsData, UUtBool inBuild); - LtTBool Finish(); + LtTBool Finish(); private: LStData* m_lsData; @@ -178,7 +178,7 @@ class BFW_LSTextureBuilder : public LtTBaseTextureBuilder protected: BFW_LSTextureBuilder( LtTBuilderFactory *f, LStData* lsData, UUtBool inBuild); - LtTBool Finish(); + LtTBool Finish(); private: LStData* m_lsData; @@ -191,11 +191,11 @@ class BFW_LSTextureBuilder : public LtTBaseTextureBuilder // //The most complicated class. Notice that for each face, the vertices, //irradiances, uvws, norms and faces are found by the appropriate Get*() -//member function. +//member function. // -//The face information is stored in a LtTFace object, described in +//The face information is stored in a LtTFace object, described in //LtTTypes.h. It is important that you understand the order of the faces -//that are present in the list of faces for the mesh. In particular, +//that are present in the list of faces for the mesh. In particular, //any face that is not a leaf face is followed immediately by its //descendants. // @@ -208,13 +208,13 @@ class BFW_LSMeshBuilder : public LtTBaseMeshBuilder protected: BFW_LSMeshBuilder( LtTBuilderFactory *f, LStData* lsData, UUtBool inBuild); ~BFW_LSMeshBuilder(); - LtTBool Finish(); + LtTBool Finish(); private: LStData* m_lsData; UUtBool m_build; - + RadianceMap rmap; }; -#endif \ No newline at end of file +#endif diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c index e23376d..f550abd 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.c @@ -1,14 +1,14 @@ /* FILE: TE_Extract.c - + AUTHOR: Brent H. Pease - + CREATED: June 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - + */ #include @@ -29,7 +29,7 @@ TEiExtract_ComputeSwapCodeSize( UUtInt16 value16; TEtType *curType; UUtUns32 curSize = 0; - + UUmAssertReadPtr(inType, sizeof(TEtType)); switch(inType->kind) @@ -43,36 +43,36 @@ TEiExtract_ComputeSwapCodeSize( curType = curType->next; } break; - + case TEcTypeKind_Field: switch(inType->u.fieldInfo.fieldType) { case TEcFieldType_Regular: curSize += TEiExtract_ComputeSwapCodeSize(inType->baseType); break; - + case TEcFieldType_VarIndex: case TEcFieldType_VarArray: curSize++; curSize += TEiExtract_ComputeSwapCodeSize(inType->baseType); break; - + default: UUmAssert(!"Illegal case"); } break; - + case TEcTypeKind_TemplatePtr: curSize += 5; break; - + case TEcTypeKind_Array: value16 = (short)inType->u.arrayInfo.arrayLength; - + while(value16 > 0) { curSize += 3; - + UUmAssert(inType->baseType != NULL); curSize += TEiExtract_ComputeSwapCodeSize(inType->baseType); value16 -= 255; @@ -81,7 +81,7 @@ TEiExtract_ComputeSwapCodeSize( case TEcTypeKind_RawPtr: break; - + case TEcTypeKind_SeparateIndex: case TEcTypeKind_Enum: case TEcTypeKind_8Byte: @@ -90,11 +90,11 @@ TEiExtract_ComputeSwapCodeSize( case TEcTypeKind_1Byte: curSize++; break; - + default: UUmAssert(!"Illegal case"); } - + return curSize; } @@ -106,11 +106,11 @@ TEiExtract_WriteSwapCodes_Recursive( UUtInt16 value16; TEtType *curType; UUtUns8* curSwapCodePtr; - + UUmAssertReadPtr(inType, sizeof(TEtType)); curSwapCodePtr = *ioSwapCodePtr; - + switch(inType->kind) { case TEcTypeKind_Struct: @@ -124,7 +124,7 @@ TEiExtract_WriteSwapCodes_Recursive( curType = curType->next; } break; - + case TEcTypeKind_Field: switch(inType->u.fieldInfo.fieldType) { @@ -133,26 +133,26 @@ TEiExtract_WriteSwapCodes_Recursive( &curSwapCodePtr, inType->baseType); break; - + case TEcFieldType_VarIndex: *curSwapCodePtr++ = TMcSwapCode_BeginVarArray; TEiExtract_WriteSwapCodes_Recursive( &curSwapCodePtr, inType->baseType); break; - + case TEcFieldType_VarArray: TEiExtract_WriteSwapCodes_Recursive( &curSwapCodePtr, inType->baseType); *curSwapCodePtr++ = TMcSwapCode_EndVarArray; break; - + default: UUmAssert(!"Illegal case"); } break; - + case TEcTypeKind_TemplatePtr: *curSwapCodePtr++ = TMcSwapCode_TemplatePtr; if(inType->baseType != NULL) @@ -170,14 +170,14 @@ TEiExtract_WriteSwapCodes_Recursive( case TEcTypeKind_RawPtr: *curSwapCodePtr++ = TMcSwapCode_RawPtr; break; - + case TEcTypeKind_Array: value16 = (short)inType->u.arrayInfo.arrayLength; - + while(value16 > 0) { *curSwapCodePtr++ = TMcSwapCode_BeginArray; - + if(value16 > 255) { *curSwapCodePtr++ = 255; @@ -186,35 +186,35 @@ TEiExtract_WriteSwapCodes_Recursive( { *curSwapCodePtr++ = (UUtUns8)value16; } - + UUmAssert(inType->baseType != NULL); TEiExtract_WriteSwapCodes_Recursive( &curSwapCodePtr, inType->baseType); - + *curSwapCodePtr++ = TMcSwapCode_EndArray; - + value16 -= 255; } break; - + case TEcTypeKind_8Byte: *curSwapCodePtr++ = TMcSwapCode_8Byte; break; - + case TEcTypeKind_Enum: case TEcTypeKind_4Byte: *curSwapCodePtr++ = TMcSwapCode_4Byte; break; - + case TEcTypeKind_2Byte: *curSwapCodePtr++ = TMcSwapCode_2Byte; break; - + case TEcTypeKind_1Byte: *curSwapCodePtr++ = TMcSwapCode_1Byte; break; - + case TEcTypeKind_SeparateIndex: *curSwapCodePtr++ = TMcSwapCode_SeparateIndex; break; @@ -222,7 +222,7 @@ TEiExtract_WriteSwapCodes_Recursive( default: UUmAssert(!"Illegal case"); } - + *ioSwapCodePtr = curSwapCodePtr; } @@ -235,7 +235,7 @@ TEiExtract_WriteOutSwapCodes( { UUtUns32 itr; UUtUns8* p = inSwapCode; - + BFrFile_Printf(inFile, "static UUtUns8 gSwapCodes_%c%c%c%c[%d] ="UUmNL, (inTag >> 24) & 0xFF, (inTag >> 16) & 0xFF, @@ -243,7 +243,7 @@ TEiExtract_WriteOutSwapCodes( (inTag >> 0) & 0xFF, inLength); BFrFile_Printf(inFile, "{"); - + for(itr = 0, p = inSwapCode; itr < inLength; itr++, p++) { if(itr % 8 == 0) BFrFile_Printf(inFile, UUmNL"\t"); @@ -261,22 +261,22 @@ TEiExtract_WriteOutSwapCodes( BFrFile_Printf(inFile, "};"UUmNL); } -static void +static void TEiExtract_DumpFile( void) { TEtType *curSymbol; FILE* infoFile; - + infoFile = fopen("templateInfo.txt", "wb"); - + curSymbol = TEgSymbolList; while(curSymbol) { if(curSymbol->kind == TEcTypeKind_Template) { fprintf(infoFile, "template: %s"UUmNL, curSymbol->name); - fprintf(infoFile, "\tTag: %c%c%c%c"UUmNL, + fprintf(infoFile, "\tTag: %c%c%c%c"UUmNL, (curSymbol->u.templateInfo.templateTag >> 24) & 0xFF, (curSymbol->u.templateInfo.templateTag >> 16) & 0xFF, (curSymbol->u.templateInfo.templateTag >> 8) & 0xFF, @@ -293,10 +293,10 @@ TEiExtract_DumpFile( fprintf(infoFile, "\tsizeof: %d"UUmNL, curSymbol->sizeofSize); fprintf(infoFile, "*******************************************"UUmNL); } - + curSymbol = curSymbol->next; } - + fclose(infoFile); } @@ -319,11 +319,11 @@ TErExtract( char dateBuffer[128]; UUtUns32 length; UUtUns32 itr; - + // first compute the total template checksum totalChecksumFactor = 0; totalChecksum = 0; - + curSymbol = TEgSymbolList; while(curSymbol) { @@ -334,30 +334,30 @@ TErExtract( } curSymbol = curSymbol->next; } - + // If we are here then we need to output templatechecksum.c - + // Write out the dumpfile TEiExtract_DumpFile(); - + // Append the log file error = BFrFileRef_MakeFromName("templatechangelog.txt", &logFileRef); UUmError_ReturnOnError(error); - + error = BFrFile_Open(logFileRef, "w", &logFile); UUmError_ReturnOnError(error); - + error = BFrFile_GetLength(logFile, &length); UUmError_ReturnOnError(error); - + error = BFrFile_SetPos(logFile, length); UUmError_ReturnOnError(error); - + UUrConvertSecsSince1900ToStr(UUrGetSecsSince1900(), dateBuffer); BFrFile_Printf(logFile, "********************************************"UUmNL); BFrFile_Printf(logFile, "* %s *"UUmNL, dateBuffer); BFrFile_Printf(logFile, "********************************************"UUmNL); - + BFrFile_Printf(logFile, "* Templates added"UUmNL); curSymbol = TEgSymbolList; while(curSymbol) @@ -415,7 +415,7 @@ TErExtract( } curSymbol = curSymbol->next; } - + if(curSymbol == NULL) { BFrFile_Printf(logFile, "\t%c%c%c%c: %s"UUmNL, @@ -426,7 +426,7 @@ TErExtract( curTemplate->name); } } - + BFrFile_Close(logFile); BFrFileRef_Dispose(logFileRef); @@ -442,7 +442,7 @@ TErExtract( UUmError_ReturnOnError(error); error = BFrFile_Open(cFileRef, "w", &cFile); UUmError_ReturnOnError(error); - + BFrFile_Printf(cFile, "#include \"BFW.h\""UUmNL); BFrFile_Printf(cFile, "#include \"BFW_TemplateManager.h\""UUmNL); BFrFile_Printf(cFile, "#include \"BFW_TM_Private.h\""UUmNL); @@ -453,10 +453,10 @@ TErExtract( // first build the new template data structures TMgTemplateDefinitionArray = TMgTemplateDefinitionsAlloced = UUrMemory_Block_New(TMgNumTemplateDefinitions * sizeof(TMtTemplateDefinition)); UUmError_ReturnOnNull(TMgTemplateDefinitionArray); - + TMgTemplateNameAlloced = UUrMemory_String_New(30 * 1024); UUmError_ReturnOnNull(TMgTemplateNameAlloced); - + curTemplate = TMgTemplateDefinitionArray; curSymbol = TEgSymbolList; while(curSymbol) @@ -467,35 +467,35 @@ TErExtract( curTemplate->tag = curSymbol->u.templateInfo.templateTag; curTemplate->name = UUrMemory_String_GetStr(TMgTemplateNameAlloced, curSymbol->u.templateInfo.templateName); UUmError_ReturnOnNull(curTemplate->name); - + curTemplate->flags = curSymbol->u.templateInfo.flags; curTemplate->size = curSymbol->sizeofSize; curTemplate->varArrayElemSize = curSymbol->u.templateInfo.varElemSize; curTemplate->magicCookie = TMcMagicCookie; curTemplate->timer = NULL; - + swapCodeSize = TEiExtract_ComputeSwapCodeSize(curSymbol) + 1; - + curTemplate->swapCodes = swapCodePtr = UUrMemory_Block_New(swapCodeSize); - + TEiExtract_WriteSwapCodes_Recursive(&swapCodePtr, curSymbol); - + *swapCodePtr = TMcSwapCode_EndArray; - + TEiExtract_WriteOutSwapCodes( cFile, curTemplate->tag, curTemplate->swapCodes, swapCodeSize); - + curTemplate++; } curSymbol = curSymbol->next; } - + BFrFile_Printf(cFile, "static TMtTemplateDefinition TMgTemplateDefinitionArray_Mem[%d] ="UUmNL, TMgNumTemplateDefinitions); BFrFile_Printf(cFile, "{"UUmNL); - + curSymbol = TEgSymbolList; curTemplate = TMgTemplateDefinitionArray; count = 0; @@ -505,7 +505,7 @@ TErExtract( { BFrFile_Printf(cFile, "\t// #%d"UUmNL, count); BFrFile_Printf(cFile, "\t{"UUmNL); - + BFrFile_Printf(cFile, "\t\t" UUmFS_UUtUns64 "," UUmNL, curTemplate->checksum); BFrFile_Printf(cFile, "\t\t0x%x," UUmNL, curTemplate->tag); BFrFile_Printf(cFile, "\t\t\"%s\","UUmNL, curTemplate->name); @@ -516,7 +516,7 @@ TErExtract( BFrFile_Printf(cFile, "\t\tNULL," UUmNL); BFrFile_Printf(cFile, "\t\t0x%x," UUmNL, curTemplate->magicCookie); BFrFile_Printf(cFile, "\t\tNULL," UUmNL); - + if(count == TMgNumTemplateDefinitions - 1) { BFrFile_Printf(cFile, "\t}"UUmNL); @@ -525,7 +525,7 @@ TErExtract( { BFrFile_Printf(cFile, "\t},"UUmNL); } - + curTemplate++; count++; } @@ -536,7 +536,7 @@ TErExtract( BFrFile_Printf(cFile, "void" UUmNL "TMrTemplate_BuildList(" UUmNL "\tvoid)"UUmNL); BFrFile_Printf(cFile, "{"UUmNL); - + curSymbol = TEgSymbolList; curTemplate = TMgTemplateDefinitionArray; count = 0; @@ -550,17 +550,17 @@ TErExtract( (curTemplate->tag >> 16) & 0xFF, (curTemplate->tag >> 8) & 0xFF, (curTemplate->tag >> 0) & 0xFF); - + curTemplate++; count++; } curSymbol = curSymbol->next; } - + BFrFile_Printf(cFile, "\tTMgTemplateDefinitionArray = TMgTemplateDefinitionArray_Mem;"UUmNL); - + BFrFile_Printf(cFile, "}"UUmNL); - + BFrFile_SetEOF(cFile); BFrFile_Close(cFile); BFrFileRef_Dispose(cFileRef); diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.h b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.h index 158d268..c8be6ec 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.h +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Extract.h @@ -1,14 +1,14 @@ /* FILE: TE_Extract.h - + AUTHOR: Brent H. Pease - + CREATED: June 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - + */ #ifndef TE_EXTRACTOR_H #define TE_EXTRACTOR_H diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Parser.c b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Parser.c index e1bbe51..1c01614 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Parser.c +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Parser.c @@ -1,14 +1,14 @@ /* FILE: TE_Parser.c - + AUTHOR: Brent H. Pease - + CREATED: June 22, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - + */ #include @@ -29,12 +29,12 @@ typedef enum TEtToken TEcToken_Struct, TEcToken_Template, TEcToken_Enum, - + TEcToken_VarIndex, TEcToken_VarArray, TEcToken_Pad, TEcToken_TemplateReference, - + TEcToken_SemiColon, TEcToken_Comma, TEcToken_LeftParen, @@ -44,21 +44,21 @@ typedef enum TEtToken TEcToken_LeftCurly, TEcToken_RightCurly, TEcToken_Star, - + TEcToken_8Byte, TEcToken_4Byte, TEcToken_2Byte, TEcToken_1Byte, - + TEcToken_AsciiConst, TEcToken_Number, TEcToken_ID, TEcToken_String, TEcToken_Raw, TEcToken_Separate, - + TEcToken_EOF - + } TEtToken; char *TEgCurInputFileName; @@ -78,7 +78,7 @@ extern FILE* TEgErrorFile; static void TEiParser_ReportSyntaxErrorAndDie( char *msg) { - + if(TEgErrorFile != NULL) { fprintf(TEgErrorFile, @@ -88,7 +88,7 @@ static void TEiParser_ReportSyntaxErrorAndDie( msg, TEgLexem); } - + TEgError = UUcTrue; } @@ -101,20 +101,20 @@ static TEtToken TEiParser_GetNextToken( char c; UUtInt32 lexemLength; char *lexem; - - + + if(TEgUngotToken != TEcToken_None) { returnToken = TEgUngotToken; TEgUngotToken = TEcToken_None; - + return returnToken; } - + returnToken = TEcToken_None; start: - + while(src < TEgEndDataPtr) { c = *src++; @@ -133,50 +133,50 @@ static TEtToken TEiParser_GetNextToken( break; } } - + if(src >= TEgEndDataPtr) { return TEcToken_EOF; } - + switch(c) { case '[': returnToken = TEcToken_LeftBracket; goto found; - + case ']': returnToken = TEcToken_RightBracket; goto found; - + case '{': returnToken = TEcToken_LeftCurly; goto found; - + case '}': returnToken = TEcToken_RightCurly; goto found; - + case '(': returnToken = TEcToken_LeftParen; goto found; - + case ')': returnToken = TEcToken_RightParen; goto found; - + case ',': returnToken = TEcToken_Comma; goto found; - + case '*': returnToken = TEcToken_Star; goto found; - + case ';': returnToken = TEcToken_SemiColon; goto found; - + case '\'': while(1) { @@ -185,14 +185,14 @@ static TEtToken TEiParser_GetNextToken( *dst++ = c; } *dst++ = 0; - + if(c != '\'') { TEiParser_ReportSyntaxErrorAndDie("Expecting an end quote for the 4char"); } returnToken = TEcToken_AsciiConst; goto found; - + case '\"': while(1) { @@ -201,7 +201,7 @@ static TEtToken TEiParser_GetNextToken( *dst++ = c; } *dst++ = 0; - + if(c != '\"') { fprintf(stderr, "%s"UUmNL, TEgLexem); @@ -209,7 +209,7 @@ static TEtToken TEiParser_GetNextToken( } returnToken = TEcToken_String; goto found; - + case '/': c = *src++; if(c == '/') @@ -219,9 +219,9 @@ static TEtToken TEiParser_GetNextToken( c = *src++; if(c == '\n' || c == '\r' || src >= TEgEndDataPtr) break; } - + src--; - + goto start; } else if(c == '*') @@ -229,9 +229,9 @@ static TEtToken TEiParser_GetNextToken( while(1) { c = *src++; - + if(src >= TEgEndDataPtr) break; - + if(c == '\n') { if(*src == '\r') src++; @@ -249,12 +249,12 @@ static TEtToken TEiParser_GetNextToken( src--; } } - + goto start; } goto found; } - + if(isalpha(c) || c == '_') { while(1) @@ -263,18 +263,18 @@ static TEtToken TEiParser_GetNextToken( c = *src++; if(!(isalpha(c) || c == '_' || isdigit(c)) || src >= TEgEndDataPtr) break; } - + src--; - + *dst++ = 0; - - if(TEgLexem[0] == 't' && + + if(TEgLexem[0] == 't' && TEgLexem[1] == 'm' && TEgLexem[2] == '_') { lexem = TEgLexem + 3; lexemLength = strlen(lexem); - + switch(lexemLength) { case 3: @@ -291,7 +291,7 @@ static TEtToken TEiParser_GetNextToken( { TEiParser_ReportSyntaxErrorAndDie("Expecting a '(' for tm_raw"); } - + src++; src = strpbrk(src, ")\n\r"); @@ -308,7 +308,7 @@ static TEtToken TEiParser_GetNextToken( goto found; } break; - + case 4: if(!strcmp(lexem, "enum")) { @@ -316,7 +316,7 @@ static TEtToken TEiParser_GetNextToken( goto found; } break; - + case 6: if(!strcmp(lexem, "struct")) { @@ -324,7 +324,7 @@ static TEtToken TEiParser_GetNextToken( goto found; } break; - + case 8: if(!strcmp(lexem, "template")) { @@ -347,7 +347,7 @@ static TEtToken TEiParser_GetNextToken( goto found; } break; - + case 11: if(!strcmp(lexem, "templateref")) { @@ -355,7 +355,7 @@ static TEtToken TEiParser_GetNextToken( goto found; } break; - + } } else if(TEgLexem[0] == 'U' && @@ -420,7 +420,7 @@ static TEtToken TEiParser_GetNextToken( returnToken = TEcToken_1Byte; goto found; } - + returnToken = TEcToken_ID; } else if(isdigit(c)) @@ -431,18 +431,18 @@ static TEtToken TEiParser_GetNextToken( c = *src++; if(!isdigit(c) || src >= TEgEndDataPtr) break; } - + src--; - + *dst++ = 0; - + returnToken = TEcToken_Number; } found: - + TEgCurDataPtr = src; - + return returnToken; } @@ -451,7 +451,7 @@ TEiParser_UngetToken( TEtToken inToken) { UUmAssert(inToken != TEcToken_None); - + TEgUngotToken = inToken; } @@ -460,9 +460,9 @@ TEiParser_MatchToken( TEtToken inToken) { TEtToken token; - + token = TEiParser_GetNextToken(); - + if(token != inToken) { TEiParser_ReportSyntaxErrorAndDie("Illegal Token"); @@ -484,7 +484,7 @@ TEiParser_Field( { case TEcToken_Raw: TErSymbolTable_Field_RawRef(); - + TEiParser_MatchToken(TEcToken_ID); TErSymbolTable_Field_AddID(); TEiParser_MatchToken(TEcToken_SemiColon); @@ -500,58 +500,58 @@ TEiParser_Field( case TEcToken_VarIndex: TErSymbolTable_Field_VarIndex(); goto start; - + case TEcToken_VarArray: TErSymbolTable_Field_VarArray(); goto start; - + case TEcToken_TemplateReference: TErSymbolTable_Field_TemplateRef(); TEiParser_MatchToken(TEcToken_ID); TErSymbolTable_Field_AddID(); TEiParser_MatchToken(TEcToken_SemiColon); return; - + case TEcToken_Pad: TErSymbolTable_Field_Pad(); TEiParser_MatchToken(TEcToken_ID); TErSymbolTable_Field_AddID(); break; - + case TEcToken_8Byte: TErSymbolTable_Field_8Byte(); - + TEiParser_MatchToken(TEcToken_ID); TErSymbolTable_Field_AddID(); break; - + case TEcToken_4Byte: TErSymbolTable_Field_4Byte(); - + TEiParser_MatchToken(TEcToken_ID); TErSymbolTable_Field_AddID(); break; - + case TEcToken_2Byte: TErSymbolTable_Field_2Byte(); TEiParser_MatchToken(TEcToken_ID); TErSymbolTable_Field_AddID(); break; - + case TEcToken_1Byte: TErSymbolTable_Field_1Byte(); TEiParser_MatchToken(TEcToken_ID); TErSymbolTable_Field_AddID(); break; - + case TEcToken_ID: TErSymbolTable_Field_TypeName(); - + token = TEiParser_GetNextToken(); - + if(token == TEcToken_ID) { TErSymbolTable_Field_AddID(); @@ -559,7 +559,7 @@ TEiParser_Field( else if(token == TEcToken_Star) { TErSymbolTable_Field_Star(); - + TEiParser_MatchToken(TEcToken_ID); TErSymbolTable_Field_AddID(); } @@ -568,13 +568,13 @@ TEiParser_Field( TEiParser_ReportSyntaxErrorAndDie("Illegal token"); } break; - + default: TEiParser_ReportSyntaxErrorAndDie("Illegal token"); } token = TEiParser_GetNextToken(); - + if(token == TEcToken_LeftBracket) { while(token != TEcToken_SemiColon) @@ -586,9 +586,9 @@ TEiParser_Field( TEiParser_MatchToken(TEcToken_Number); TErSymbolTable_Field_Array(); - + TEiParser_MatchToken(TEcToken_RightBracket); - + token = TEiParser_GetNextToken(); } } @@ -603,33 +603,33 @@ TEiParser_Struct( void) { TEtToken token; - + TEiParser_MatchToken(TEcToken_ID); - + TErSymbolTable_AddID(); - + TEiParser_MatchToken(TEcToken_LeftCurly); - + while(1) { token = TEiParser_GetNextToken(); - + if(token == TEcToken_RightCurly) { break; } - + if(token == TEcToken_None) { TEiParser_ReportSyntaxErrorAndDie("Illegal Token"); } - + TEiParser_UngetToken(token); - + TErSymbolTable_StartField(); - + TEiParser_Field(); - + TErSymbolTable_EndField(); } } @@ -639,11 +639,11 @@ TEiParser_Template( void) { char c0, c1, c2, c3; - + TEiParser_MatchToken(TEcToken_LeftParen); TEiParser_MatchToken(TEcToken_AsciiConst); c0 = TEgLexem[0]; - + TEiParser_MatchToken(TEcToken_Comma); TEiParser_MatchToken(TEcToken_AsciiConst); c1 = TEgLexem[0]; @@ -655,16 +655,16 @@ TEiParser_Template( TEiParser_MatchToken(TEcToken_Comma); TEiParser_MatchToken(TEcToken_AsciiConst); c3 = TEgLexem[0]; - + TErSymbolTable_AddTag(UUm4CharToUns32(c0, c1, c2, c3)); - + TEiParser_MatchToken(TEcToken_Comma); TEiParser_MatchToken(TEcToken_String); - + TErSymbolTable_AddToolName(); - + TEiParser_MatchToken(TEcToken_RightParen); - + TEiParser_Struct(); } @@ -674,7 +674,7 @@ TEiParser_Enum( { TEiParser_MatchToken(TEcToken_ID); TErSymbolTable_AddID(); - + } void TErParser_Initialize( @@ -687,7 +687,7 @@ void TErParser_Terminate( void) { -} +} void TErParser_ProcessFile( @@ -695,24 +695,24 @@ TErParser_ProcessFile( char *inFileData) { TEtToken token = TEcToken_None; - + TEgCurDataPtr = inFileData; TEgEndDataPtr = inFileData + inFileLength; - + while(token != TEcToken_EOF) { token = TEiParser_GetNextToken(); - + switch(token) { case TEcToken_Struct: TErSymbolTable_StartStruct(); - + TEiParser_Struct(); - + TErSymbolTable_EndStruct(); break; - + case TEcToken_Template: TErSymbolTable_StartTemplate(); @@ -720,12 +720,12 @@ TErParser_ProcessFile( TErSymbolTable_EndTemplate(); break; - + case TEcToken_Enum: TErSymbolTable_StartEnum(); - + TEiParser_Enum(); - + TErSymbolTable_EndEnum(); break; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Parser.h b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Parser.h index 527034f..e0b6e18 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Parser.h +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Parser.h @@ -1,14 +1,14 @@ /* FILE: TE_Parser.h - + AUTHOR: Brent H. Pease - + CREATED: June 22, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - + */ #ifndef TE_PARSER_H #define TE_PARSER_H @@ -21,7 +21,7 @@ void TErParser_Initialize( void TErParser_Terminate( void); - + void TErParser_ProcessFile( UUtUns32 inFileLength, char *inFileData); diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Private.h b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Private.h index 13c5823..428850d 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Private.h +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Private.h @@ -1,14 +1,14 @@ /* FILE: TE_Private.h - + AUTHOR: Brent H. Pease - + CREATED: June 20, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - + */ #ifndef TE_PRIVATE_H #define TE_PRIVATE_H @@ -31,7 +31,7 @@ typedef enum TEtType_Kind TEcTypeKind_2Byte, TEcTypeKind_1Byte, TEcTypeKind_SeparateIndex - + } TEtType_Kind; typedef enum TEtField_Type @@ -40,7 +40,7 @@ typedef enum TEtField_Type TEcFieldType_VarIndex, TEcFieldType_VarArray //TEcFieldType_TemplateReference - + } TEtField_Type; typedef struct TEtType TEtType; @@ -55,7 +55,7 @@ typedef struct TEtType_Template UUtUns32 varArrayStartOffset; TMtTemplateFlags flags; UUtUns64 checksum; - + } TEtType_Template; typedef struct TEtType_Array @@ -69,7 +69,7 @@ typedef struct TEtType_Field TEtField_Type fieldType; UUtUns32 fieldOffset; UUtBool extraVarField; - + } TEtType_Field; struct TEtType @@ -81,23 +81,23 @@ struct TEtType UUtBool usedInArray; // true if this type is array'd - it affects how we pad it UUtBool hasBeenPadded; // true if run through padding correction UUtBool isPad; - + union { TEtType_Template templateInfo; TEtType_Array arrayInfo; TEtType_Field fieldInfo; - } u; - - UUtUns32 sizeofSize; // Total size to match C sizeof + } u; + + UUtUns32 sizeofSize; // Total size to match C sizeof UUtUns32 alignmentRequirement; // 1 -> byte alignment, 2 -> short alignment, 4 -> long alignment, 8 -> 8byte alignment - + TEtType* baseType; TEtType* next; - + char* fileName; UUtUns32 line; - + }; extern char *TEgCurInputFileName; diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Symbol.c b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Symbol.c index 8a616a2..f001e2f 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Symbol.c +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Symbol.c @@ -1,14 +1,14 @@ /* FILE: TE_Symbol.c - + AUTHOR: Brent H. Pease - + CREATED: June 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - + */ #include @@ -40,7 +40,7 @@ TEtType* TEgCurType = NULL; TEtType* TEgCurField = NULL; TEtType* TEgVarArrayField = NULL; -static void +static void TEiReportSemanticErrorAndDie( char *msg) { @@ -53,7 +53,7 @@ TEiReportSemanticErrorAndDie( TEgCurInputFileLine, msg); } - + TEgError = UUcTrue; } @@ -63,40 +63,40 @@ TEiSymbolTable_NewString( { UUtInt32 length; char *p; - + p = TEgStringArray; - + while(1) { length = *p++; - + if(length == 0) { break; } - + if(!strcmp(p, inStr)) { return p; } - + p += length + 1; } - + p--; - + length = strlen(inStr); - + if((p - TEgStringArray) + length > TEcStringArraySize) { TEiReportSemanticErrorAndDie("Ran out of space in string array"); } - + *p++ = (char)length; strcpy(p, inStr); *(p + length) = 0; *(p + length + 1) = 0; - + return p; } @@ -105,13 +105,13 @@ TEiSymbolTable_NewType( TEtType_Kind inTypeKind) { TEtType *newType; - + newType = UUrMemory_Pool_Block_New(TEgMemoryPool, sizeof(TEtType)); if(newType == NULL) { return NULL; } - + newType->kind = inTypeKind; newType->name = NULL; newType->baseType = NULL; @@ -121,9 +121,9 @@ TEiSymbolTable_NewType( newType->usedInArray = UUcFalse; newType->hasBeenPadded = UUcFalse; newType->isPad = UUcFalse; - + newType->alignmentRequirement = UUcMaxUns32; - + if(TEgCurInputFileName == NULL) { newType->fileName = "implicitly defined"; @@ -133,7 +133,7 @@ TEiSymbolTable_NewType( newType->fileName = TEiSymbolTable_NewString(TEgCurInputFileName); } newType->line = TEgCurInputFileLine; - + switch(inTypeKind) { case TEcTypeKind_Template: @@ -144,22 +144,22 @@ TEiSymbolTable_NewType( newType->u.templateInfo.flags = TMcTemplateFlag_None; newType->isLeaf = (UUtBool)0x03; break; - + case TEcTypeKind_Struct: newType->isLeaf = (UUtBool)0x03; break; - + case TEcTypeKind_Enum: newType->sizeofSize = newType->alignmentRequirement = 4; newType->isLeaf = UUcTrue; break; - + case TEcTypeKind_Field: newType->u.fieldInfo.fieldType = (TEtField_Type)-1; newType->u.fieldInfo.fieldOffset = 0; newType->isLeaf = (UUtBool)0x03; break; - + case TEcTypeKind_TemplatePtr: newType->sizeofSize = newType->alignmentRequirement = 4; newType->isLeaf = UUcFalse; @@ -169,17 +169,17 @@ TEiSymbolTable_NewType( newType->sizeofSize = newType->alignmentRequirement = 4; newType->isLeaf = UUcTrue; break; - + case TEcTypeKind_SeparateIndex: newType->sizeofSize = newType->alignmentRequirement = 4; newType->isLeaf = UUcTrue; break; - + case TEcTypeKind_Array: newType->u.arrayInfo.arrayLength = 0; newType->isLeaf = (UUtBool)0x03; break; - + case TEcTypeKind_8Byte: newType->sizeofSize = newType->alignmentRequirement = 8; newType->isLeaf = UUcTrue; @@ -189,21 +189,21 @@ TEiSymbolTable_NewType( newType->sizeofSize = newType->alignmentRequirement = 4; newType->isLeaf = UUcTrue; break; - + case TEcTypeKind_2Byte: newType->sizeofSize = newType->alignmentRequirement = 2; newType->isLeaf = UUcTrue; break; - + case TEcTypeKind_1Byte: newType->sizeofSize = newType->alignmentRequirement = 1; newType->isLeaf = UUcTrue; break; - + default: UUmAssert(!"Unknown type"); } - + return newType; } @@ -216,15 +216,15 @@ TEiSymbolTable_AddType( curType = TEgSymbolList; prevType = NULL; - + while(curType) { if(strcmp(curType->name, inType->name) > 0) break; - + prevType = curType; curType = curType->next; } - + if(prevType == NULL) { inType->next = TEgSymbolList; @@ -243,19 +243,19 @@ TEiSymbolTable_FindField( char *inName) { TEtType *curType; - + curType = TEgCurType->baseType; - + while(curType) { if(curType->name && !strcmp(curType->name, inName)) { return curType; } - + curType = curType->next; } - + return NULL; } @@ -264,23 +264,23 @@ TEiSymbolTable_Find( char *inName) { TEtType *curType; - + curType = TEgSymbolList; - + while(curType) { if(curType->name && !strcmp(curType->name, inName)) { return curType; } - + curType = curType->next; } - + return NULL; } -void +void TErSymbolTable_StartStruct( void) { @@ -289,23 +289,23 @@ TErSymbolTable_StartStruct( UUmAssert(TEgCurType != NULL); } -void +void TErSymbolTable_EndStruct( void) { UUmAssert(TEgCurType != NULL); - + TEgCurType = NULL; } -void +void TErSymbolTable_StartTemplate( void) { UUmAssert(TEgCurType == NULL); TEgCurType = TEiSymbolTable_NewType(TEcTypeKind_Template); UUmAssert(TEgCurType != NULL); - + TErSymbolTable_StartField(); TErSymbolTable_Field_Preamble(); TErSymbolTable_EndField(); @@ -314,46 +314,46 @@ TErSymbolTable_StartTemplate( TErSymbolTable_EndField(); } -void +void TErSymbolTable_EndTemplate( void) { UUmAssert(TEgVarArrayField!= NULL); UUmAssert(TEgVarArrayField->baseType != NULL); - + TEgCurType->u.templateInfo.varArrayType = TEgVarArrayField->baseType; TEgCurType = NULL; } -void +void TErSymbolTable_StartEnum( void) { UUmAssert(TEgCurType == NULL); TEgCurType = TEiSymbolTable_NewType(TEcTypeKind_Enum); UUmAssert(TEgCurType != NULL); - + TEgCurType->baseType = TEg4ByteType; } -void +void TErSymbolTable_EndEnum( void) { TEgCurType = NULL; } -void +void TErSymbolTable_AddTag( UUtUns32 inTag) { TEtType* curSymbol; - + UUmAssert(TEgCurType->kind == TEcTypeKind_Template); - + TEgCurType->u.templateInfo.templateTag = inTag; - + for(curSymbol = TEgSymbolList; curSymbol; curSymbol = curSymbol->next) { if(curSymbol->kind == TEcTypeKind_Template) @@ -371,16 +371,16 @@ TErSymbolTable_AddTag( } } -void +void TErSymbolTable_AddToolName( void) { UUmAssert(TEgCurType->kind == TEcTypeKind_Template); - + TEgCurType->u.templateInfo.templateName = TEiSymbolTable_NewString(TEgLexem); } -void +void TErSymbolTable_AddID( void) { @@ -389,18 +389,18 @@ TErSymbolTable_AddID( TEiSymbolTable_AddType(TEgCurType); } -void +void TErSymbolTable_StartField( void) { TEtType *curSymbol, *prevSymbol; - + UUmAssert(TEgCurType->kind == TEcTypeKind_Template || TEgCurType->kind == TEcTypeKind_Struct); UUmAssert(TEgCurField == NULL); - + TEgCurField = TEiSymbolTable_NewType(TEcTypeKind_Field); UUmAssert(TEgCurField != NULL); - + prevSymbol = NULL; curSymbol = TEgCurType->baseType; while(curSymbol) @@ -408,7 +408,7 @@ TErSymbolTable_StartField( prevSymbol = curSymbol; curSymbol = curSymbol->next; } - + if(prevSymbol == NULL) { TEgCurType->baseType = TEgCurField; @@ -417,19 +417,19 @@ TErSymbolTable_StartField( { prevSymbol->next = TEgCurField; } - + TEgCurField->u.fieldInfo.fieldType = TEcFieldType_Regular; } -void +void TErSymbolTable_EndField( void) { - + TEgCurField = NULL; } -void +void TErSymbolTable_Field_VarIndex( void) { @@ -437,11 +437,11 @@ TErSymbolTable_Field_VarIndex( { TEiReportSemanticErrorAndDie("Illegal field"); } - + TEgCurField->u.fieldInfo.fieldType = TEcFieldType_VarIndex; } - -void + +void TErSymbolTable_Field_VarArray( void) { @@ -449,13 +449,13 @@ TErSymbolTable_Field_VarArray( { TEiReportSemanticErrorAndDie("Illegal field"); } - + TEgCurField->u.fieldInfo.fieldType = TEcFieldType_VarArray; TEgVarArrayField = TEgCurField; } -void +void TErSymbolTable_Field_TemplateRef( void) { @@ -463,7 +463,7 @@ TErSymbolTable_Field_TemplateRef( { TEiReportSemanticErrorAndDie("Illegal field"); } - + TEgCurField->baseType = TEiSymbolTable_NewType(TEcTypeKind_TemplatePtr); } @@ -481,7 +481,7 @@ TErSymbolTable_Field_SeparateIndex( TEgCurField->baseType = TEg4ByteType; } -void +void TErSymbolTable_Field_Pad( void) { @@ -500,21 +500,21 @@ TErSymbolTable_Field_Preamble( TEgCurField->baseType = TEiSymbolTable_NewType(TEcTypeKind_4Byte); UUmAssert(TEgCurField->baseType != NULL); - + if(TEgCurType->kind != TEcTypeKind_Template) { TEiReportSemanticErrorAndDie("preamble can only be within templates"); } } -void +void TErSymbolTable_Field_AddID( void) { TEgCurField->name = TEiSymbolTable_NewString(TEgLexem); } -void +void TErSymbolTable_Field_8Byte( void) { @@ -522,14 +522,14 @@ TErSymbolTable_Field_8Byte( } -void +void TErSymbolTable_Field_4Byte( void) { TEgCurField->baseType = TEg4ByteType; } - -void + +void TErSymbolTable_Field_2Byte( void) { @@ -543,12 +543,12 @@ TErSymbolTable_Field_1Byte( TEgCurField->baseType = TEg1ByteType; } -void +void TErSymbolTable_Field_TypeName( void) { UUmAssert(TEgCurField->baseType == NULL); - + TEgCurField->baseType = TEiSymbolTable_Find(TEgLexem); if(TEgCurField->baseType == NULL) { @@ -556,31 +556,31 @@ TErSymbolTable_Field_TypeName( } } -void +void TErSymbolTable_Field_Star( void) { TEtType* newType; - - if(TEgCurField->baseType == NULL || + + if(TEgCurField->baseType == NULL || TEgCurField->baseType->kind != TEcTypeKind_Template) { TEiReportSemanticErrorAndDie("can only have pointers to templates"); } - + newType = TEiSymbolTable_NewType(TEcTypeKind_TemplatePtr); newType->baseType = TEgCurField->baseType; TEgCurField->baseType = newType; } -void +void TErSymbolTable_Field_Array( void) { TEtType* newType; - + UUtUns32 length; - + sscanf(TEgLexem, "%d", &length); if(TEgCurField->u.fieldInfo.fieldType == TEcFieldType_VarArray) @@ -592,17 +592,17 @@ TErSymbolTable_Field_Array( } TEgCurField->u.fieldInfo.extraVarField = UUcFalse; if(length == 1) return; - + TEiReportSemanticErrorAndDie("The length of a var length array must be one or 2"); return; } - + if(TEgCurField->baseType == NULL || TEgCurField->baseType->kind == TEcTypeKind_Template) { TEiReportSemanticErrorAndDie("Illegal array base type"); } - + UUmAssert(TEgCurField->baseType != NULL); if(TEgCurField->baseType->kind == TEcTypeKind_Array) @@ -613,50 +613,50 @@ TErSymbolTable_Field_Array( { newType = TEiSymbolTable_NewType(TEcTypeKind_Array); newType->u.arrayInfo.arrayLength = length; - + newType->baseType = TEgCurField->baseType; TEgCurField->baseType = newType; - + TEgCurField->baseType->usedInArray = UUcTrue; } } -void +void TErSymbolTable_Initialize( void) { - + TEgStringArray = UUrMemory_Block_New(TEcStringArraySize); - + if(TEgStringArray == NULL) { TEiReportSemanticErrorAndDie("Could not allocate string array"); } TEgStringArray[0] = 0; - - TEgMemoryPool = + + TEgMemoryPool = UUrMemory_Pool_New( 10 * 1024, UUcPool_Growable); - + UUmAssert(TEgMemoryPool != NULL); - + TEgPadType = TEiSymbolTable_NewType(TEcTypeKind_1Byte); TEgPadType->isPad = UUcTrue; - - TEg8ByteType = TEiSymbolTable_NewType(TEcTypeKind_8Byte); + + TEg8ByteType = TEiSymbolTable_NewType(TEcTypeKind_8Byte); TEg4ByteType = TEiSymbolTable_NewType(TEcTypeKind_4Byte); TEg2ByteType = TEiSymbolTable_NewType(TEcTypeKind_2Byte); TEg1ByteType = TEiSymbolTable_NewType(TEcTypeKind_1Byte); TEgRawType = TEiSymbolTable_NewType(TEcTypeKind_RawPtr); TEgSeparateType = TEiSymbolTable_NewType(TEcTypeKind_SeparateIndex); - + UUmAssert(TEg8ByteType != NULL); UUmAssert(TEg4ByteType != NULL); UUmAssert(TEg2ByteType != NULL); UUmAssert(TEg1ByteType != NULL); UUmAssert(TEgRawType != NULL); - + TEgPadType->name = TEiSymbolTable_NewString("pad"); TEg8ByteType->name = TEiSymbolTable_NewString("8byte"); TEg4ByteType->name = TEiSymbolTable_NewString("4byte"); @@ -666,12 +666,12 @@ TErSymbolTable_Initialize( TEgSeparateType->name = TEiSymbolTable_NewString("separateIndex"); } -void +void TErSymbolTable_Terminate( void) { UUrMemory_Block_Delete(TEgStringArray); - + UUrMemory_Pool_Delete(TEgMemoryPool); } @@ -682,20 +682,20 @@ TEiSymbolTable_ChecksumName( { UUtUns64 factor, result; UUtUns8* p = (UUtUns8*)inName; - + if(p == NULL) { return; } - + result = 0; factor = 1; - + while(*p != 0) { result += (UUtUns64)(*p++) * factor++; } - + *outCummulativeChecksum = result; } @@ -708,18 +708,18 @@ TEiSymbolTable_ComputeChecksum( UUtInt16 value16; TEtType *curType; UUtUns64 nameChecksum; - + UUmAssertReadPtr(inType, sizeof(TEtType)); UUmAssertReadPtr(ioChecksumFactor, sizeof(UUtUns64)); UUmAssertReadPtr(outCummulativeChecksum, sizeof(UUtUns64)); - + if(inType->name != NULL) { TEiSymbolTable_ChecksumName(inType->name, &nameChecksum); *ioChecksumFactor += 1; *outCummulativeChecksum += nameChecksum * *ioChecksumFactor; } - + switch(inType->kind) { case TEcTypeKind_Struct: @@ -734,7 +734,7 @@ TEiSymbolTable_ComputeChecksum( curType = curType->next; } break; - + case TEcTypeKind_Field: switch(inType->u.fieldInfo.fieldType) { @@ -744,7 +744,7 @@ TEiSymbolTable_ComputeChecksum( ioChecksumFactor, outCummulativeChecksum); break; - + case TEcFieldType_VarIndex: *ioChecksumFactor += 1; *outCummulativeChecksum += TMcSwapCode_BeginVarArray * *ioChecksumFactor; @@ -753,28 +753,28 @@ TEiSymbolTable_ComputeChecksum( ioChecksumFactor, outCummulativeChecksum); break; - + case TEcFieldType_VarArray: - + *ioChecksumFactor += 1; *outCummulativeChecksum += TMcSwapCode_EndVarArray * *ioChecksumFactor; - + if(inType->u.fieldInfo.extraVarField) { *outCummulativeChecksum += TMcSwapCode_EndVarArray * *ioChecksumFactor; } - + TEiSymbolTable_ComputeChecksum( inType->baseType, ioChecksumFactor, outCummulativeChecksum); break; - + default: UUmAssert(!"Illegal case"); } break; - + case TEcTypeKind_TemplatePtr: *ioChecksumFactor += 1; *outCummulativeChecksum += TMcSwapCode_TemplatePtr * *ioChecksumFactor; @@ -791,23 +791,23 @@ TEiSymbolTable_ComputeChecksum( *ioChecksumFactor += 1; *outCummulativeChecksum += TMcSwapCode_4Byte * *ioChecksumFactor; break; - + case TEcTypeKind_SeparateIndex: *ioChecksumFactor += 1; *outCummulativeChecksum += TMcSwapCode_4Byte * *ioChecksumFactor; break; - + case TEcTypeKind_Array: value16 = (short)inType->u.arrayInfo.arrayLength; - + while(value16 > 0) { *ioChecksumFactor += 1; *outCummulativeChecksum += TMcSwapCode_BeginArray * *ioChecksumFactor; - + *ioChecksumFactor += 1; *outCummulativeChecksum += inType->u.arrayInfo.arrayLength * *ioChecksumFactor; - + UUmAssert(inType->baseType != NULL); TEiSymbolTable_ComputeChecksum( inType->baseType, @@ -815,12 +815,12 @@ TEiSymbolTable_ComputeChecksum( outCummulativeChecksum); *ioChecksumFactor += 1; *outCummulativeChecksum += TMcSwapCode_EndArray * *ioChecksumFactor; - + value16 -= 255; } break; - - + + case TEcTypeKind_8Byte: *ioChecksumFactor += 1; *outCummulativeChecksum += TMcSwapCode_8Byte * *ioChecksumFactor; @@ -831,17 +831,17 @@ TEiSymbolTable_ComputeChecksum( *ioChecksumFactor += 1; *outCummulativeChecksum += TMcSwapCode_4Byte * *ioChecksumFactor; break; - + case TEcTypeKind_2Byte: *ioChecksumFactor += 1; *outCummulativeChecksum += TMcSwapCode_2Byte * *ioChecksumFactor; break; - + case TEcTypeKind_1Byte: *ioChecksumFactor += 1; *outCummulativeChecksum += TMcSwapCode_1Byte * *ioChecksumFactor; break; - + default: UUmAssert(!"Illegal case"); } @@ -861,55 +861,55 @@ TEiSymbolTable_ProcessAttributes_Recursive( UUtBool any2Byte; UUtBool any4Byte; UUtBool any8Byte; - + UUmAssert(inType != NULL); - + if(inType->sizeofSize != 0) { return; } - + switch(inType->kind) { case TEcTypeKind_Template: curType = inType->baseType; - + isLeaf = UUcTrue; isVarArrayLeaf = UUcTrue; - + checksumFactor = 0; inType->u.templateInfo.checksum = 0; - + TEiSymbolTable_ComputeChecksum( inType, &checksumFactor, &inType->u.templateInfo.checksum); - + while(curType != NULL) { UUmAssert(curType->kind == TEcTypeKind_Field); - + TEiSymbolTable_ProcessAttributes_Recursive(curType); - + UUmAssert(curType->isLeaf == UUcFalse || curType->isLeaf == UUcTrue); - + if(curType->isLeaf == UUcFalse) isLeaf = UUcFalse; - + UUmAssert(curType->baseType != NULL); - + curType->u.fieldInfo.fieldOffset = curSizeofSize; - + switch(curType->u.fieldInfo.fieldType) { case TEcFieldType_Regular: UUmAssert(curType->baseType != NULL); - + case TEcFieldType_VarIndex: break; - + case TEcFieldType_VarArray: inType->u.templateInfo.varArrayStartOffset = curSizeofSize; - + inType->u.templateInfo.varElemSize = curType->sizeofSize; if(curType->u.fieldInfo.extraVarField == UUcTrue) { @@ -917,61 +917,61 @@ TEiSymbolTable_ProcessAttributes_Recursive( } isVarArrayLeaf = curType->isLeaf; break; - + default: UUmAssert(!"Illegal state"); } - + if(curType->u.fieldInfo.fieldType != TEcFieldType_VarArray) { curSizeofSize += curType->sizeofSize; } - + curPersistentSize += curType->sizeofSize; - + curType = curType->next; } - + inType->isLeaf = isLeaf; - + inType->sizeofSize = curSizeofSize; - + inType->u.templateInfo.persistentSize = curPersistentSize; inType->u.templateInfo.flags = isLeaf ? TMcTemplateFlag_Leaf : TMcTemplateFlag_None; if(isVarArrayLeaf) inType->u.templateInfo.flags |= TMcTemplateFlag_VarArrayIsLeaf; break; - + case TEcTypeKind_Struct: curType = inType->baseType; - + isLeaf = UUcTrue; - + any1Byte = UUcFalse; any2Byte = UUcFalse; any4Byte = UUcFalse; any8Byte = UUcFalse; - + while(curType != NULL) { UUmAssert(curType->kind == TEcTypeKind_Field); - + TEiSymbolTable_ProcessAttributes_Recursive(curType); - + UUmAssert(curType->isLeaf == UUcFalse || curType->isLeaf == UUcTrue); if(curType->isLeaf == UUcFalse) isLeaf = UUcFalse; - + curSizeofSize += curType->sizeofSize; - + if(curType->alignmentRequirement == 1) any1Byte = UUcTrue; else if(curType->alignmentRequirement == 2) any2Byte = UUcTrue; else if(curType->alignmentRequirement == 4) any4Byte = UUcTrue; else if(curType->alignmentRequirement == 8) any8Byte = UUcTrue; else UUmAssert(0); - + curType = curType->next; } - + if(inType->baseType->alignmentRequirement == 8) { inType->alignmentRequirement = 8; @@ -1006,19 +1006,19 @@ TEiSymbolTable_ProcessAttributes_Recursive( inType->alignmentRequirement = 1; } } - + inType->isLeaf = isLeaf; inType->sizeofSize = curSizeofSize; break; - + case TEcTypeKind_Field: UUmAssert(inType->baseType != NULL); - + TEiSymbolTable_ProcessAttributes_Recursive(inType->baseType); UUmAssert(inType->baseType->isLeaf == UUcFalse || inType->baseType->isLeaf == UUcTrue); - + inType->alignmentRequirement = inType->baseType->alignmentRequirement; - + switch(inType->u.fieldInfo.fieldType) { case TEcFieldType_Regular: @@ -1033,7 +1033,7 @@ TEiSymbolTable_ProcessAttributes_Recursive( UUmAssert(!"Illegal state"); } break; - + case TEcTypeKind_Array: UUmAssert(inType->baseType != NULL); TEiSymbolTable_ProcessAttributes_Recursive(inType->baseType); @@ -1042,7 +1042,7 @@ TEiSymbolTable_ProcessAttributes_Recursive( inType->sizeofSize = inType->baseType->sizeofSize * inType->u.arrayInfo.arrayLength; inType->alignmentRequirement = inType->baseType->alignmentRequirement; break; - + case TEcTypeKind_SeparateIndex: case TEcTypeKind_RawPtr: case TEcTypeKind_TemplatePtr: @@ -1052,7 +1052,7 @@ TEiSymbolTable_ProcessAttributes_Recursive( case TEcTypeKind_2Byte: case TEcTypeKind_1Byte: break; - + default: UUmAssert(!"Illegal state"); } @@ -1060,18 +1060,18 @@ TEiSymbolTable_ProcessAttributes_Recursive( UUmAssert(inType->isLeaf == UUcFalse || inType->isLeaf == UUcTrue); } -static void +static void TEiSymbolTable_ProcessAttributes( void) { TEtType *curSymbol; - + curSymbol = TEgSymbolList; - + while(curSymbol != NULL) { TEiSymbolTable_ProcessAttributes_Recursive(curSymbol); - + curSymbol = curSymbol->next; } } @@ -1082,13 +1082,13 @@ TEiSymbolTable_Indent( UUtInt32 inIndentLevel) { UUtInt32 i; - + for(i = inIndentLevel; i-- > 0;) { fprintf(inFile, "\t"); } } - + static void TEiSymbolTable_Dump_Recursive( FILE *inFile, @@ -1098,15 +1098,15 @@ TEiSymbolTable_Dump_Recursive( { TEtType *curType; char *charPtr; - + switch(inType->kind) { case TEcTypeKind_Template: TEiSymbolTable_Indent(inFile, inLevel); fprintf(inFile, "Template:%s(%d)"UUmNL, inType->name ? inType->name : "no name", inType->sizeofSize); - + if(!inPrintDetailed) break; - + TEiSymbolTable_Indent(inFile, inLevel+1); charPtr = (char *)&inType->u.templateInfo.templateTag; fprintf(inFile, "Tag: %c%c%c%c"UUmNL, charPtr[0], charPtr[1], charPtr[2], charPtr[3]); @@ -1129,13 +1129,13 @@ TEiSymbolTable_Dump_Recursive( fprintf(inFile, "varindex: %s(%d) ", curType->name, curType->u.fieldInfo.fieldOffset); TEiSymbolTable_Dump_Recursive(inFile, inLevel+2, UUcFalse, curType->baseType); break; - + case TEcFieldType_Regular: TEiSymbolTable_Indent(inFile, inLevel+2); fprintf(inFile, "regular: %s(%d) ", curType->name, curType->u.fieldInfo.fieldOffset); TEiSymbolTable_Dump_Recursive(inFile, inLevel+2, UUcFalse, curType->baseType); break; - + case TEcFieldType_VarArray: TEiSymbolTable_Indent(inFile, inLevel+2); fprintf(inFile, "vararray: %s(%d) ", curType->name, curType->u.fieldInfo.fieldOffset); @@ -1148,14 +1148,14 @@ TEiSymbolTable_Dump_Recursive( curType = curType->next; } break; - + case TEcTypeKind_Struct: TEiSymbolTable_Indent(inFile, inLevel); fprintf(inFile, "Struct:%s(%d)"UUmNL, inType->name ? inType->name : "no name", inType->sizeofSize); - + if(!inPrintDetailed) break; - - + + curType = inType->baseType; while(curType) { @@ -1172,7 +1172,7 @@ TEiSymbolTable_Dump_Recursive( curType = curType->next; } break; - + case TEcTypeKind_TemplatePtr: if(inType->baseType == NULL) { @@ -1183,12 +1183,12 @@ TEiSymbolTable_Dump_Recursive( fprintf(inFile, "* %s"UUmNL, inType->baseType->name); } break; - + case TEcTypeKind_Array: fprintf(inFile, "[] "); TEiSymbolTable_Dump_Recursive(inFile, inLevel+1, UUcFalse, inType->baseType); break; - + case TEcTypeKind_Enum: TEiSymbolTable_Indent(inFile, inLevel); fprintf(inFile, "Enum:%s(%d)"UUmNL, inType->name ? inType->name : "no name", inType->sizeofSize); @@ -1198,12 +1198,12 @@ TEiSymbolTable_Dump_Recursive( TEiSymbolTable_Indent(inFile, inLevel); fprintf(inFile, "TEcTypeKind_RawPtr(%d)"UUmNL, inType->sizeofSize); break; - + case TEcTypeKind_SeparateIndex: TEiSymbolTable_Indent(inFile, inLevel); fprintf(inFile, "TEcTypeKind_SeparateIndex(%d)"UUmNL, inType->sizeofSize); break; - + case TEcTypeKind_8Byte: TEiSymbolTable_Indent(inFile, inLevel); fprintf(inFile, "TEcTypeKind_8Byte(%d)"UUmNL, inType->sizeofSize); @@ -1213,36 +1213,36 @@ TEiSymbolTable_Dump_Recursive( TEiSymbolTable_Indent(inFile, inLevel); fprintf(inFile, "TEcTypeKind_4Byte(%d)"UUmNL, inType->sizeofSize); break; - + case TEcTypeKind_2Byte: TEiSymbolTable_Indent(inFile, inLevel); fprintf(inFile, "TEcTypeKind_2Byte(%d)"UUmNL, inType->sizeofSize); break; - + case TEcTypeKind_1Byte: TEiSymbolTable_Indent(inFile, inLevel); fprintf(inFile, "TEcTypeKind_1Byte(%d)"UUmNL, inType->sizeofSize); break; - + default: - UUmAssert(!"Illegal state"); + UUmAssert(!"Illegal state"); } } -static void +static void TEiSymbolTable_Dump( FILE *inFile) { TEtType *curSymbol; - + curSymbol = TEgSymbolList; - + while(curSymbol != NULL) { TEiSymbolTable_Dump_Recursive(inFile, 0, UUcTrue, curSymbol); - + fprintf(inFile, "***"UUmNL); - + curSymbol = curSymbol->next; } } @@ -1257,10 +1257,10 @@ TEiSymbolTable_CheckAndReportErrors_Recursive( UUtBool errorFound = UUcFalse; TEtType *curType; char msgBuffer[TEcMsgBufferSize]; - + UUmAssertReadPtr(inType, sizeof(TEtType)); UUmAssertReadPtr(inMsg, 1); - + switch(inType->kind) { case TEcTypeKind_Struct: @@ -1283,7 +1283,7 @@ TEiSymbolTable_CheckAndReportErrors_Recursive( curType = curType->next; } break; - + case TEcTypeKind_Field: switch(inType->u.fieldInfo.fieldType) { @@ -1302,7 +1302,7 @@ TEiSymbolTable_CheckAndReportErrors_Recursive( errorFound = UUcTrue; } break; - + case TEcFieldType_VarArray: sprintf( msgBuffer, @@ -1316,7 +1316,7 @@ TEiSymbolTable_CheckAndReportErrors_Recursive( msgBuffer, 32 - (inType->u.fieldInfo.fieldOffset % 32)); errorFound = UUcTrue; } - + if(TEiSymbolTable_CheckAndReportErrors_Recursive( inType->baseType, msgBuffer, @@ -1324,7 +1324,7 @@ TEiSymbolTable_CheckAndReportErrors_Recursive( { errorFound = UUcTrue; } - + // Check again for array alignment problems if(TEiSymbolTable_CheckAndReportErrors_Recursive( inType->baseType, @@ -1334,17 +1334,17 @@ TEiSymbolTable_CheckAndReportErrors_Recursive( errorFound = UUcTrue; } break; - + default: UUmAssert(!"Illegal case"); } break; - + case TEcTypeKind_RawPtr: break; case TEcTypeKind_TemplatePtr: break; - + case TEcTypeKind_Array: if(TEiSymbolTable_CheckAndReportErrors_Recursive( inType->baseType, @@ -1365,8 +1365,8 @@ TEiSymbolTable_CheckAndReportErrors_Recursive( } } break; - - + + case TEcTypeKind_8Byte: if(inCurOffset % 8 != 0) { @@ -1386,7 +1386,7 @@ TEiSymbolTable_CheckAndReportErrors_Recursive( errorFound = UUcTrue; } break; - + case TEcTypeKind_2Byte: if(inCurOffset % 2 != 0) { @@ -1395,23 +1395,23 @@ TEiSymbolTable_CheckAndReportErrors_Recursive( errorFound = UUcTrue; } break; - + case TEcTypeKind_1Byte: break; - + case TEcTypeKind_Template: fprintf( TEgErrorFile, "%s: Can't directly include a template struct, must have a pointer to it.\n", inMsg); - + errorFound = UUcTrue; break; - + default: UUmAssert(!"Illegal case"); } - + return errorFound; } #endif @@ -1428,14 +1428,14 @@ TEiSymbolTable_FixPad_Static_Field( { UUtUns32 neededPad; TEtType* existingField; - + *outPadBytesAdded = 0; - + if(inField->baseType->kind == TEcTypeKind_Struct && inField->baseType->error == UUcTrue) { TEiSymbolTable_FixPad(inField->baseType); } - + inField->u.fieldInfo.fieldOffset = inCurOffset; neededPad = inCurOffset % inField->alignmentRequirement; @@ -1443,11 +1443,11 @@ TEiSymbolTable_FixPad_Static_Field( { return inField->sizeofSize; } - + // need to do some padding to achieve required alignment - + // allocate new memory for the existing field - + existingField = UUrMemory_Pool_Block_New(TEgMemoryPool, sizeof(TEtType)); if(existingField == NULL) { @@ -1455,15 +1455,15 @@ TEiSymbolTable_FixPad_Static_Field( fprintf(stderr, "out of memory - \n"); return 0; } - + // assign our inField to existingField *existingField = *inField; - + // now munge the next field so that inField points to existing field, now everthing should be linked correctly inField->next = existingField; - + inField->name = TEiSymbolTable_NewString("addedPad"); - + if(neededPad == 4) { inField->baseType = TEg4ByteType; @@ -1481,17 +1481,17 @@ TEiSymbolTable_FixPad_Static_Field( fprintf(stderr, "Needed to insert a 3-byte pad, can't (must be 1, 2 or 4)\n"); return 0; } - + *outPadBytesAdded = neededPad; - + // update - + inField->sizeofSize = inField->baseType->sizeofSize; inField->alignmentRequirement = inField->baseType->alignmentRequirement; inField->u.fieldInfo.fieldOffset = inCurOffset; inField->u.fieldInfo.fieldType = TEcFieldType_Regular; inField->isPad = UUcTrue; - + return inField->sizeofSize; } @@ -1509,7 +1509,7 @@ TEiSymbolTable_FixPad_Static( UUtBool hasVarArray = UUcFalse; UUtUns32 padBytesAdded; UUtUns32 totalPadBytesAdded = 0; - + while(curField) { if(curField->u.fieldInfo.fieldType == TEcFieldType_VarArray) @@ -1517,19 +1517,19 @@ TEiSymbolTable_FixPad_Static( hasVarArray = UUcTrue; break; } - + fieldSize = TEiSymbolTable_FixPad_Static_Field(curField, curOffset, &padBytesAdded); - + totalPadBytesAdded += padBytesAdded; curOffset += fieldSize; - + curField = curField->next; } - + *outPreVarArraySize = curOffset; *outHasVarArray = hasVarArray; *outPadBytesAdded = totalPadBytesAdded; - + } static TEtType* @@ -1539,25 +1539,25 @@ TEiSymbolTable_FixPad_StripOldPad( TEtType* curField = inFirstField; TEtType* prevField = NULL; TEtType* returnField = NULL; - + if(curField->isPad == UUcTrue) while(curField != NULL && curField->isPad == UUcTrue) curField = curField->next; - + UUmAssert(curField != NULL); - + returnField = curField; - + while(curField != NULL) { while(curField != NULL && curField->isPad) curField = curField->next; - + if(prevField != NULL) prevField->next = curField; - + if(curField == NULL) break; - + prevField = curField; curField = curField->next; } - + return returnField; } @@ -1568,42 +1568,42 @@ TEiSymbolTable_FixPad_Print_BaseType( UUtBool inIsPad) { *outArrayLength = 0; - + if(inIsPad) { fprintf(TEgErrorFile, "tm_pad"); - + switch(inType->kind) { case TEcTypeKind_Array: *outArrayLength = inType->u.arrayInfo.arrayLength; break; - + case TEcTypeKind_4Byte: *outArrayLength = 4; break; - + case TEcTypeKind_2Byte: *outArrayLength = 2; break; - + case TEcTypeKind_1Byte: *outArrayLength = 1; break; - + default: UUmAssert(0); } - + return; } - + switch(inType->kind) { case TEcTypeKind_Struct: fprintf(TEgErrorFile, "struct %s", inType->name); break; - + case TEcTypeKind_Enum: fprintf(TEgErrorFile, "enum %s", inType->name); break; @@ -1626,28 +1626,28 @@ TEiSymbolTable_FixPad_Print_BaseType( fprintf(TEgErrorFile, "%s*", inType->baseType->name); } break; - + case TEcTypeKind_Array: TEiSymbolTable_FixPad_Print_BaseType(inType->baseType, outArrayLength, UUcFalse); *outArrayLength = inType->u.arrayInfo.arrayLength; break; - + case TEcTypeKind_8Byte: fprintf(TEgErrorFile, "UUtUns64"); break; - + case TEcTypeKind_4Byte: fprintf(TEgErrorFile, "UUtUns32"); break; - + case TEcTypeKind_2Byte: fprintf(TEgErrorFile, "UUtUns16"); break; - + case TEcTypeKind_1Byte: fprintf(TEgErrorFile, "UUtUns8"); break; - + default: UUmAssert(0); } @@ -1659,7 +1659,7 @@ TEiSymbolTable_FixPad_Print( { TEtType* curField; UUtUns32 arrayLength; - + if(inType->kind == TEcTypeKind_Template) { fprintf(TEgErrorFile, "tm_template "); @@ -1672,16 +1672,16 @@ TEiSymbolTable_FixPad_Print( { UUmAssert(0); } - + fprintf(TEgErrorFile, "%s\n{\n", inType->name); - - + + for(curField = inType->baseType; curField != NULL; curField = curField->next) { if(curField->name == NULL) continue; // skip over implicit fields - + fprintf(TEgErrorFile, "\t"); - + if(curField->u.fieldInfo.fieldType == TEcFieldType_VarIndex) { fprintf(TEgErrorFile, "tm_varindex "); @@ -1690,20 +1690,20 @@ TEiSymbolTable_FixPad_Print( { fprintf(TEgErrorFile, "tm_vararray "); } - + TEiSymbolTable_FixPad_Print_BaseType(curField->baseType, &arrayLength, curField->isPad); - + fprintf(TEgErrorFile, " %s", curField->name); - + if(arrayLength > 0) { fprintf(TEgErrorFile, "[%d]", arrayLength); } - + fprintf(TEgErrorFile, ";\n"); } - - + + fprintf(TEgErrorFile, "}\n"); } @@ -1718,15 +1718,15 @@ TEiSymbolTable_FixPad( TEtType* lastImpliedField; UUtUns32 padBytesAdded; UUtUns32 leftOverPad; - + if(inType->hasBeenPadded == UUcTrue) return; - + inType->hasBeenPadded = UUcTrue; - + //UUmAssert(strcmp(inType->name, "AItCharacterSetup") != 0); - + inType->baseType = TEiSymbolTable_FixPad_StripOldPad(inType->baseType); - + // pad out everything up till the var array TEiSymbolTable_FixPad_Static( inType->baseType, @@ -1734,19 +1734,19 @@ TEiSymbolTable_FixPad( &hasVarArray, &padBytesAdded, 0); - + if((preVarArraySize & 0x1F) != 0) { initialPad = 32 - (preVarArraySize & 0x1F); } - + if(hasVarArray == UUcTrue && initialPad != 0) { - + // initial pad needs to be a multiple of 4 leftOverPad = initialPad % 4; initialPad -= leftOverPad; - + if(initialPad > 0) { // need to add additional pad to make var array cache line aligned @@ -1756,7 +1756,7 @@ TEiSymbolTable_FixPad( UUmAssert(!"Out of memory"); return; } - + padField->baseType = TEiSymbolTable_NewType(TEcTypeKind_Array); if(padField == NULL) { @@ -1775,22 +1775,22 @@ TEiSymbolTable_FixPad( padField->u.fieldInfo.fieldType = TEcFieldType_Regular; padField->name = TEiSymbolTable_NewString("pad"); padField->alignmentRequirement = 1; - + padField->baseType->isLeaf = UUcTrue; padField->baseType->alignmentRequirement = 1; - + padField->sizeofSize = padField->baseType->u.arrayInfo.arrayLength = initialPad; - + lastImpliedField = inType->baseType->next; padField->next = lastImpliedField->next; lastImpliedField->next = padField; } - + if(leftOverPad > 0) { TEtType* curField; TEtType* prevField; - + // this pad needs to go before the var index field padField = TEiSymbolTable_NewType(TEcTypeKind_Field); if(padField == NULL) @@ -1798,7 +1798,7 @@ TEiSymbolTable_FixPad( UUmAssert(!"Out of memory"); return; } - + padField->baseType = TEiSymbolTable_NewType(TEcTypeKind_Array); if(padField == NULL) { @@ -1817,22 +1817,22 @@ TEiSymbolTable_FixPad( padField->u.fieldInfo.fieldType = TEcFieldType_Regular; padField->name = TEiSymbolTable_NewString("pad"); padField->alignmentRequirement = 1; - + padField->baseType->isLeaf = UUcTrue; padField->baseType->alignmentRequirement = 1; - + padField->sizeofSize = padField->baseType->u.arrayInfo.arrayLength = leftOverPad; - + curField = inType->baseType; while(curField != NULL && curField->u.fieldInfo.fieldType != TEcFieldType_VarIndex) { prevField = curField; curField = curField->next; } - + UUmAssert(prevField != NULL); UUmAssert(curField != NULL); - + padField->next = curField; prevField->next = padField; } @@ -1844,13 +1844,13 @@ TEiSymbolTable_FixPad( &hasVarArray, &padBytesAdded, 0); - + if(padBytesAdded != 0) { fprintf(TEgErrorFile, "Could not properly fix this structure, talk to brent\n"); } - - TEiSymbolTable_FixPad_Print(inType); + + TEiSymbolTable_FixPad_Print(inType); } static UUtBool @@ -1861,7 +1861,7 @@ TEiSymbolTable_CheckAndReportErrors( TEtType* curField; UUtBool errorFound = UUcFalse; char msgBuffer[TEcMsgBufferSize]; - + curSymbol = TEgSymbolList; while(curSymbol) { @@ -1871,7 +1871,7 @@ TEiSymbolTable_CheckAndReportErrors( msgBuffer, "(template %s, file: %s, line: %d): ", curSymbol->name, curSymbol->fileName, curSymbol->line); - + curField = curSymbol->baseType; while(curField) { @@ -1880,21 +1880,21 @@ TEiSymbolTable_CheckAndReportErrors( curSymbol->error = UUcTrue; errorFound = UUcTrue; } - + if(curField->u.fieldInfo.fieldType == TEcFieldType_VarArray && (curField->u.fieldInfo.fieldOffset % 32 != 0)) { curSymbol->error = UUcTrue; errorFound = UUcTrue; } - + curField = curField->next; } - + } curSymbol = curSymbol->next; } - + if(errorFound) { fprintf(TEgErrorFile, "*** Corrected structures\n"); @@ -1907,11 +1907,11 @@ TEiSymbolTable_CheckAndReportErrors( { TEiSymbolTable_FixPad(curSymbol); } - + curSymbol = curSymbol->next; } } - + return errorFound; } @@ -1924,16 +1924,16 @@ TErSymbolTable_FinishUp( // First compute all attributes TEiSymbolTable_ProcessAttributes(); - + // Next check for errors foundErrors = TEiSymbolTable_CheckAndReportErrors(); - + // finally write out the dump file outFile = fopen("TE.out", "w"); UUmAssert(outFile != NULL); - + TEiSymbolTable_Dump(outFile); - + fclose(outFile); // set TEgError if we found any errors diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Symbol.h b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Symbol.h index 722a9e2..dcb20e5 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Symbol.h +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TE_Symbol.h @@ -1,14 +1,14 @@ /* FILE: TE_Symbol.h - + AUTHOR: Brent H. Pease - + CREATED: June 18, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - + */ #ifndef TE_SYMBOL_H #define TE_SYMBOL_H @@ -52,7 +52,7 @@ TErSymbolTable_AddID( void TErSymbolTable_StartField( void); - + void TErSymbolTable_EndField( void); @@ -60,7 +60,7 @@ TErSymbolTable_EndField( void TErSymbolTable_Field_VarIndex( void); - + void TErSymbolTable_Field_VarArray( void); @@ -72,11 +72,11 @@ TErSymbolTable_Field_TemplateRef( void TErSymbolTable_Field_RawRef( void); - + void TErSymbolTable_Field_SeparateIndex( void); - + void TErSymbolTable_Field_Pad( void); @@ -100,7 +100,7 @@ TErSymbolTable_Field_8Byte( void TErSymbolTable_Field_4Byte( void); - + void TErSymbolTable_Field_2Byte( void); @@ -132,13 +132,13 @@ TErSymbolTable_EndEnum( void TErSymbolTable_FinishUp( void); - + void TErSymbolTable_Initialize( void); - + void TErSymbolTable_Terminate( void); - + #endif /* TE_SYMBOL_H */ diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TemplateExtractor.c b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TemplateExtractor.c index 63293db..57eb471 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TemplateExtractor.c +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TemplateExtractor.c @@ -1,14 +1,14 @@ /* FILE: TemplateExtractor.c - + AUTHOR: Brent H. Pease - + CREATED: June 17, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - + */ #include @@ -59,25 +59,25 @@ TEiProcessMainInputFile( { BFtFileRef *curInputFileRef; BFtFile *curInputFile; - + char *endPtr; char *startLinePtr; char *curPtr; char c; UUtUns32 curInputFileLength; char *curInputFileData; - + UUtError error; - + curPtr = inInputFileData; endPtr = inInputFileData + inInputFileLength; - + fprintf(stderr, "Extracting template files"UUmNL); while(curPtr < endPtr) { startLinePtr = curPtr; - + while(1) { c = *curPtr++; @@ -88,27 +88,27 @@ TEiProcessMainInputFile( if(curPtr >= endPtr) break; } - + *(curPtr - 1) = 0; c = *curPtr; if(c == '\n' || c == '\r') curPtr++; if ('\0' == startLinePtr[0]) { continue; } // skip lines with just a newline - - error = + + error = BFrFileRef_MakeFromName( startLinePtr, &curInputFileRef); if(error != UUcError_None) { char msg[256]; - + sprintf(msg, "could not find file \"%s\""UUmNL, startLinePtr); - + UUrError_Report(UUcError_Generic, msg); } - - error = + + error = BFrFile_Open( curInputFileRef, "r", @@ -116,39 +116,39 @@ TEiProcessMainInputFile( if(error != UUcError_None) { char msg[256]; - + sprintf(msg, "could not open file \"%s\""UUmNL, startLinePtr); - + UUrError_Report(UUcError_Generic, msg); } - + BFrFileRef_Dispose(curInputFileRef); - - error = + + error = BFrFile_GetLength( curInputFile, &curInputFileLength); if(error != UUcError_None) { char msg[256]; - + sprintf(msg, "could not get file length \"%s\""UUmNL, startLinePtr); - + UUrError_Report(UUcError_Generic, msg); } - - curInputFileData = + + curInputFileData = UUrMemory_Block_New(curInputFileLength + 1); if(curInputFileData == NULL) { char msg[256]; - + sprintf(msg, "could not get file length \"%s\""UUmNL, startLinePtr); - + UUrError_Report(UUcError_Generic, msg); } - - error = + + error = BFrFile_Read( curInputFile, curInputFileLength, @@ -156,23 +156,23 @@ TEiProcessMainInputFile( if(error != UUcError_None) { char msg[256]; - + sprintf(msg, "could not read file \"%s\""UUmNL, startLinePtr); - + UUrError_Report(UUcError_Generic, msg); } - + BFrFile_Close(curInputFile); - + /* process */ //fprintf(stderr, "Processing file \"%s\""UUmNL, startLinePtr); fprintf(stderr, "."); - + TEgCurInputFileLine = 1; TEgCurInputFileName = startLinePtr; - + TErParser_ProcessFile(curInputFileLength, curInputFileData); - + UUrMemory_Block_Delete(curInputFileData); } fprintf(stderr, UUmNL); @@ -183,13 +183,13 @@ TErRun( void) { UUtError error; - + BFtFileRef *masterInputFileRef; BFtFile *masterInputFile; - + char *masterInputFileData; UUtUns32 masterInputFileLength; - + /* * Create error file */ @@ -198,32 +198,32 @@ TErRun( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Could not create error file"); } - + /* * Initialize */ TErParser_Initialize(); - - TErSymbolTable_Initialize(); - + + TErSymbolTable_Initialize(); + /* * Open master input file */ - error = + error = BFrFileRef_MakeFromName( TEcInputFileName, &masterInputFileRef); - + if(error != UUcError_None) { char msg[256]; - + sprintf(msg, "could not find file \"%s\""UUmNL, TEcInputFileName); - + UUmError_ReturnOnErrorMsg(UUcError_Generic, msg); } - - error = + + error = BFrFile_Open( masterInputFileRef, "r", @@ -231,39 +231,39 @@ TErRun( if(error != UUcError_None) { char msg[256]; - + sprintf(msg, "could not open file \"%s\""UUmNL, TEcInputFileName); - + UUmError_ReturnOnErrorMsg(UUcError_Generic, msg); } - + BFrFileRef_Dispose(masterInputFileRef); - - error = + + error = BFrFile_GetLength( masterInputFile, &masterInputFileLength); if(error != UUcError_None) { char msg[256]; - + sprintf(msg, "could not get file length \"%s\""UUmNL, TEcInputFileName); - + UUmError_ReturnOnErrorMsg(UUcError_Generic, msg); } - - masterInputFileData = + + masterInputFileData = UUrMemory_Block_New(masterInputFileLength + 1); if(masterInputFileData == NULL) { char msg[256]; - + sprintf(msg, "could not get file length \"%s\""UUmNL, TEcInputFileName); - + UUmError_ReturnOnErrorMsg(UUcError_Generic, msg); } - - error = + + error = BFrFile_Read( masterInputFile, masterInputFileLength, @@ -271,66 +271,66 @@ TErRun( if(error != UUcError_None) { char msg[256]; - + sprintf(msg, "could not read file \"%s\""UUmNL, TEcInputFileName); - + UUmError_ReturnOnErrorMsg(UUcError_Generic, msg); } - + BFrFile_Close(masterInputFile); - + /* * Process the file */ TEiProcessMainInputFile(masterInputFileLength, masterInputFileData); - + if(TEgError == UUcTrue) { goto errorExit; } - + //fprintf(stderr, "Processing attributes..."UUmNL); - + TErSymbolTable_FinishUp(); if(TEgError == UUcTrue) { goto errorExit; } - + // - + error = TErExtract(); if(error != UUcError_None) goto errorExit; - + //fprintf(stderr, "Writing to disk..."UUmNL); - + #if 0 if(1) { FILE *outTemplateDatFile; FILE *outTemplateNameDatFile; - + outTemplateDatFile = UUrFOpen(TEcTemplateDatFileName, "wb"); if(outTemplateDatFile == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "could not open file template.dat"); } - + outTemplateNameDatFile = UUrFOpen(TEcTemplateNameDatFileName, "wb"); if(outTemplateNameDatFile == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "could not open file template.nam"); } - + TErSymbolTable_WriteFile(outTemplateDatFile, outTemplateNameDatFile); - + fclose(outTemplateDatFile); fclose(outTemplateNameDatFile); } { FILE *file; - + file = UUrFOpen("test.out", "wb"); TErSymbolTable_Dump(file); fclose(file); @@ -341,7 +341,7 @@ TErRun( { FILE *outTemplateDatFile; char c; - + outTemplateDatFile = UUrFOpen(TEcTemplateDatFileName, "b"); while(!feof(outTemplateDatFile)) { @@ -350,38 +350,38 @@ TErRun( } } #endif - + { FILE* file; - + file = fopen("templateSwapCodes.txt", "w"); if(file != NULL) { TMrSwapCode_DumpAll(file); - + fclose(file); } } - + UUrMemory_Block_Delete(masterInputFileData); - + TErSymbolTable_Terminate(); TErParser_Terminate(); - + if(TEgError == UUcTrue) { goto errorExit; } - + fclose(TEgErrorFile); - + return UUcError_None; errorExit: fclose(TEgErrorFile); - + return UUcError_Generic; } diff --git a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TemplateExtractor.h b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TemplateExtractor.h index ac2af16..ba03e93 100644 --- a/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TemplateExtractor.h +++ b/BungieFrameWork/BFW_ToolSource/Common/TemplateExtractor/TemplateExtractor.h @@ -1,14 +1,14 @@ /* FILE: TemplateExtractor.h - + AUTHOR: Brent H. Pease - + CREATED: June 17, 1997 - - PURPOSE: - + + PURPOSE: + Copyright 1997 - + */ UUtError diff --git a/BungieFrameWork/BFW_ToolSource/Win32/ModelExporter/EnvFileFormat.h b/BungieFrameWork/BFW_ToolSource/Win32/ModelExporter/EnvFileFormat.h index 70b881f..a226cc9 100644 --- a/BungieFrameWork/BFW_ToolSource/Win32/ModelExporter/EnvFileFormat.h +++ b/BungieFrameWork/BFW_ToolSource/Win32/ModelExporter/EnvFileFormat.h @@ -24,24 +24,24 @@ typedef short UUtInt16; typedef unsigned char UUtUns8; typedef signed char UUtInt8; -typedef struct M3tTextureCoord +typedef struct M3tTextureCoord { float u; - float v; + float v; } M3tTextureCoord; -typedef struct M3tPoint3D +typedef struct M3tPoint3D { - float x; - float y; - float z; + float x; + float y; + float z; } M3tPoint3D; -typedef struct M3tVector3D +typedef struct M3tVector3D { - float x; - float y; - float z; + float x; + float y; + float z; } M3tVector3D; typedef struct M3tMatrix4x3 @@ -86,10 +86,10 @@ typedef struct MXtMarker #define MXcMapping_SI 5 // self-illumination #define MXcMapping_OP 6 // opacity #define MXcMapping_FI 7 // filter color -#define MXcMapping_BU 8 // bump +#define MXcMapping_BU 8 // bump #define MXcMapping_RL 9 // reflection -#define MXcMapping_RR 10 // refraction -#define MXcMapping_Count 11 // total +#define MXcMapping_RR 10 // refraction +#define MXcMapping_Count 11 // total typedef struct MXtMapping { @@ -100,7 +100,7 @@ typedef struct MXtMapping typedef struct MXtMaterial { char name[MXcMaxName]; - + float alpha; float selfIllumination; @@ -173,8 +173,8 @@ struct AXtNode UUtUns16 sibling; // written as 0, build on read in UUtUns16 child; // written as 0, build on read in - UUtUns32 flags; - + UUtUns32 flags; + M3tMatrix4x3 objectTM; M3tMatrix4x3 *matricies; }; @@ -199,4 +199,4 @@ typedef struct AXtHeader AXtNode *nodes; } AXtHeader; -#endif // _ENVFILEFORMAT_H_ \ No newline at end of file +#endif // _ENVFILEFORMAT_H_ diff --git a/BungieFrameWork/BFW_ToolSource/Win32/ModelExporter/ExportTools.h b/BungieFrameWork/BFW_ToolSource/Win32/ModelExporter/ExportTools.h index 4087e50..b761630 100644 --- a/BungieFrameWork/BFW_ToolSource/Win32/ModelExporter/ExportTools.h +++ b/BungieFrameWork/BFW_ToolSource/Win32/ModelExporter/ExportTools.h @@ -76,14 +76,14 @@ typedef struct { INode *node; // node this edge came from unsigned long v1, v2; // v1 to v2 edge - bool visable; // is it supposed to be + bool visable; // is it supposed to be unsigned long f1, f2; // used internally (faces this edge is from) } ExportEdge; typedef struct { bool valid; // internal, true if any points in it, false otherwise - + float xmin, xmax; float ymin, ymax; float zmin, zmax; @@ -104,7 +104,7 @@ typedef enum { kCountAllNodes, kCountNormalNodes, - kCountDualTextureNormalNodes, + kCountDualTextureNormalNodes, kCountNormalPlusBiped, kCountCoreBiped, kCountMarkerNodes @@ -116,7 +116,7 @@ void GetTextureName(INode *node, char *buf); char *GetMaxTextureName(INode *node); unsigned long FindChild(INode *node, INode **list, unsigned long count); unsigned long FindSibling(unsigned long index, INode **list, unsigned long count); - + class NodeCounter : public ITreeEnumProc { public: @@ -124,7 +124,7 @@ class NodeCounter : public ITreeEnumProc static int CountNormalNodes(IScene *scene); private: - int callback(INode *node); + int callback(INode *node); CountType fCountType; TimeValue fTime; @@ -160,7 +160,7 @@ bool INodeHasTexture2(INode *node, TimeValue time); * */ -class Scene +class Scene { public: Scene(IScene *scene, TimeValue t, Interface *i); @@ -244,7 +244,7 @@ class Scene ExportPoint *fPoints; unsigned long fNumPoints; - + ExportFace *fFaces; unsigned long fNumFaces; @@ -253,7 +253,7 @@ class Scene unsigned long fAllocatedEdges; bool fWarnNonUnitNormals; - bool fWarnIdenticalUV; + bool fWarnIdenticalUV; bool fQuads; bool fWarnMapping; @@ -262,7 +262,7 @@ class Scene char *fMaxNormalDistanceName; public: - // given a face and an offset to our internal representation of + // given a face and an offset to our internal representation of // verts it will add this edge to our edge list void AddEdges(INode *node, Face *inFace, unsigned long faceIndex, const unsigned long vertOffset); void AddEdgeIfUnique(ExportEdge &edge, unsigned long faceIndex); @@ -286,7 +286,7 @@ class Scene void VerifyEdge(ExportEdge *edge); bool FaceHasVertex(ExportFace *face, unsigned long vertex); - enum + enum { QuadOptions_Exact = 0x00000001 }; @@ -295,7 +295,7 @@ class Scene void RoundPoints(void); // rounds all the points to their nearest integer void ClearUV(void); // clears all the texture coordinates void CompressPoints(void); // finds duplicate points and removes them - + private: void DoExportPoint(Mesh *mesh, Matrix3 &tm, int i, ExportPoint *outPoint); @@ -303,12 +303,12 @@ class Scene static Matrix3 CoordinateFix(void); static Point3 TranslateNormal(Point3 normal, Matrix3 tm); -static Point3 TranslatePoint(Point3 point, Matrix3 tm); +static Point3 TranslatePoint(Point3 point, Matrix3 tm); // changes coordinate system from max to oni - void CoordinateSystemMaxToOni(void); + void CoordinateSystemMaxToOni(void); -// static Point3 &FixCoordinates(Point3 inPoint); +// static Point3 &FixCoordinates(Point3 inPoint); // static Matrix3 &FixMatrix(Matrix3 inMatrix); // functions related to point compression diff --git a/BungieFrameWork/BFW_ToolSource/Win32/ModelExporter/resource.h b/BungieFrameWork/BFW_ToolSource/Win32/ModelExporter/resource.h index cb53d71..e0a7b89 100644 --- a/BungieFrameWork/BFW_ToolSource/Win32/ModelExporter/resource.h +++ b/BungieFrameWork/BFW_ToolSource/Win32/ModelExporter/resource.h @@ -6,7 +6,7 @@ #define IDC_CLOSEBUTTON 1000 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 diff --git a/OniProj/OniCMakeProjs/BinkProj/CMakeLists.txt b/OniProj/OniCMakeProjs/BinkProj/CMakeLists.txt index 2555646..3167628 100644 --- a/OniProj/OniCMakeProjs/BinkProj/CMakeLists.txt +++ b/OniProj/OniCMakeProjs/BinkProj/CMakeLists.txt @@ -1,32 +1,32 @@ -if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) - if(CMAKE_C_COMPILER_ID MATCHES "MSVC") - set(BINKW32_IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/binkw32.dll.lib") - add_custom_command( - OUTPUT "${BINKW32_IMPLIB}" - COMMAND ${CMAKE_AR} ${CMAKE_STATIC_LINKER_FLAGS} /DEF:binkw32.def /OUT:"${BINKW32_IMPLIB}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - DEPENDS binkw32.def - ) - else() - set(BINKW32_IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/libbinkw32.dll.a") - add_custom_command( - OUTPUT "${BINKW32_IMPLIB}" - COMMAND ${CMAKE_DLLTOOL} ${CMAKE_STATIC_LINKER_FLAGS} --input-def binkw32.def --output-lib "${BINKW32_IMPLIB}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - DEPENDS binkw32.def - ) - endif() - add_custom_target(binkw32-implib DEPENDS "${BINKW32_IMPLIB}") - target_sources(binkw32-implib PRIVATE binkw32.def) - set(BINK_LIB "${BINKW32_IMPLIB}") - set(BINK_DEP "binkw32-implib") -endif() - -if(BINK_LIB) - add_library(bink INTERFACE) - target_link_libraries(bink - INTERFACE - "${BINK_LIB}" - ) - add_dependencies(bink ${BINK_DEP}) -endif() +if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) + if(CMAKE_C_COMPILER_ID MATCHES "MSVC") + set(BINKW32_IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/binkw32.dll.lib") + add_custom_command( + OUTPUT "${BINKW32_IMPLIB}" + COMMAND ${CMAKE_AR} ${CMAKE_STATIC_LINKER_FLAGS} /DEF:binkw32.def /OUT:"${BINKW32_IMPLIB}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + DEPENDS binkw32.def + ) + else() + set(BINKW32_IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/libbinkw32.dll.a") + add_custom_command( + OUTPUT "${BINKW32_IMPLIB}" + COMMAND ${CMAKE_DLLTOOL} ${CMAKE_STATIC_LINKER_FLAGS} --input-def binkw32.def --output-lib "${BINKW32_IMPLIB}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + DEPENDS binkw32.def + ) + endif() + add_custom_target(binkw32-implib DEPENDS "${BINKW32_IMPLIB}") + target_sources(binkw32-implib PRIVATE binkw32.def) + set(BINK_LIB "${BINKW32_IMPLIB}") + set(BINK_DEP "binkw32-implib") +endif() + +if(BINK_LIB) + add_library(bink INTERFACE) + target_link_libraries(bink + INTERFACE + "${BINK_LIB}" + ) + add_dependencies(bink ${BINK_DEP}) +endif() diff --git a/OniProj/OniGameSource/Oni.c b/OniProj/OniGameSource/Oni.c index d5d9d8b..4112b9c 100644 --- a/OniProj/OniGameSource/Oni.c +++ b/OniProj/OniGameSource/Oni.c @@ -1,12 +1,12 @@ /* FILE: Oni.c - + AUTHOR: Brent H. Pease - + CREATED: April 2, 1997 - + PURPOSE: main .c file for Oni - + Copyright 1997 */ @@ -87,7 +87,7 @@ OniParseCommandLine( ONgCommandLine.useOpenGL = UUcFalse; ONgCommandLine.useGlide = UUcFalse; ONgCommandLine.useSound = UUcTrue; - + for(itr = 1; itr < argc; itr++) { char *current_parameter = argv[itr]; @@ -166,9 +166,9 @@ ONiInitializeAll( UUtError error; UUrStartupMessage("begin initializing oni"); - + ONgTerminateGame = UUcFalse; - + /* * Initialize the template management system */ @@ -179,10 +179,10 @@ ONiInitializeAll( if(error != UUcError_None) { UUrStartupMessage("Unable to find game data folder at %s", ONcGameDataFolder1); - + error = BFrFileRef_Search(ONcGameDataFolder2, &ONgGameDataFolder); } - + if (UUcError_None != error) { UUrStartupMessage("Unable to find game data folder at %s", ONcGameDataFolder2); error = ONcError_NoDataFolder; @@ -193,10 +193,10 @@ ONiInitializeAll( UUrStartupMessage("initializing the template manager"); error = TMrInitialize(UUcTrue, &ONgGameDataFolder); UUmError_ReturnOnError(error); - + UUrStartupMessage("calling TMrRegisterTemplates"); TMrRegisterTemplates(); - + UUrStartupMessage("calling ONrRegisterTemplates"); ONrRegisterTemplates(); @@ -210,19 +210,19 @@ ONiInitializeAll( UUrStartupMessage("initializing oni persistance"); ONrPersistance_Initialize(); - + UUrStartupMessage("initializing scripting"); error = SLrScript_Initialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing binary data system"); error = BDrInitialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing imaging"); error = IMrInitialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing motoko"); error = M3rInitialize(); UUmError_ReturnOnError(error); @@ -234,7 +234,7 @@ ONiInitializeAll( UUrStartupMessage("initializing oni motoko"); error = ONrMotoko_Initialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing local input"); error = LIrInitialize(outPlatformData->appInstance, outPlatformData->gameWindow); UUmError_ReturnOnError(error); @@ -242,11 +242,11 @@ ONiInitializeAll( UUrStartupMessage("initializing animation system"); error = TRrInitialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing environment"); error = AKrInitialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing text system"); error = TSrInitialize(); UUmError_ReturnOnError(error); @@ -258,11 +258,11 @@ ONiInitializeAll( UUrStartupMessage("initializing the materials"); error = MArMaterials_Initialize(); UUmError_ReturnOnErrorMsg(error, "Could not initialize the materials"); - + UUrStartupMessage("initializing the full sound system 2"); error = SS2rInitializeFull(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing particle 3"); error = P3rInitialize(); UUmError_ReturnOnError(error); @@ -274,7 +274,7 @@ ONiInitializeAll( UUrStartupMessage("initializing env particle system"); error = EPrInitialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing physics"); error = PHrPhysics_Initialize(); @@ -283,55 +283,55 @@ ONiInitializeAll( UUrStartupMessage("initializing game state"); error = ONrGameState_Initialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing AI 2"); error = AI2rInitialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing window manager"); error = WMrInitialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing film system"); error = ONrFilm_Initialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing level"); error = ONrLevel_Initialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing oni scripting"); error = ONrScript_Initialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing OBDr"); error = OBDrInitialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing OBJr"); error = OBJrInitialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing oni cinematics"); error = OCrInitialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing oni sound"); error = OSrInitialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing oni movie"); error = ONrMovie_Initialize(); UUmError_ReturnOnError(error); - + UUrStartupMessage("initializing the pause screen"); error = ONrInGameUI_Initialize(); UUmError_ReturnOnError(error); CLrInitialize(); - + UUrStartupMessage("finished oni initializing"); - + return UUcError_None; } @@ -357,15 +357,15 @@ ONiRunGame( UUtUns32 game_ticks; UUtInt64 time_frame_start, time_frame_end; - + #if defined(BRENTS_CHEESY_GAME_PERF) && BRENTS_CHEESY_GAME_PERF #define RECENT_FRAME_COUNT 128 - + UUtInt64 time_gamestateupdate_start; UUtInt64 time_gamestateupdate_end; UUtInt64 time_gamestatedisplay_start; - + UUtUns32 time_frame_cur; static UUtUns32 time_frame_recent[RECENT_FRAME_COUNT]; static UUtUns32 time_frame_count; @@ -373,34 +373,34 @@ ONiRunGame( UUtUns32 time_gamestateupdate_cur; UUtUns32 time_gamestateupdate_total = 0; UUtUns32 time_gamestatedisplay_cur; - UUtUns32 time_gamestatedisplay_total = 0; + UUtUns32 time_gamestatedisplay_total = 0; #endif - + //UUrProfile_State_Set(UUcProfile_State_On); - + while(!ONgTerminateGame) { time_frame_start = UUrMachineTime_High(); - + #if defined(SScMSADPCMTimer) && (SScMSADPCMTimer == 1) SS2rFrame_Start(); #endif - + // step 0 update the local input LIrUpdate(); - + // step 1 clear the matrix stack, frame start ? M3rMatrixStack_Clear(); - + // step 2 update the windows WMrUpdate(); OWrUpdate(); - + if (!ONrGameState_IsPaused()) { // step 3 process local input LIrActionBuffer_Get(&numActionsInBuffer, &actionBuffer); - + { UUtUns32 itr; @@ -415,35 +415,35 @@ ONiRunGame( // step 4 update the console time error = COrConsole_Update(numActionsInBuffer); UUmError_ReturnOnErrorMsg(error, "Could not update the console."); - + ONrGameState_UpdateServerTime(ONgGameState); #if defined(BRENTS_CHEESY_GAME_PERF) && BRENTS_CHEESY_GAME_PERF - + time_gamestateupdate_start = UUrMachineTime_High(); - + #endif - + // step 6 update the game error = ONrGameState_Update(numActionsInBuffer, actionBuffer, &game_ticks); UUmError_ReturnOnErrorMsg(error, "Could not update game state."); - + #if defined(BRENTS_CHEESY_GAME_PERF) && BRENTS_CHEESY_GAME_PERF - + time_gamestateupdate_end = UUrMachineTime_High(); - + #endif } // step 7 play the sounds SS2rUpdate(); - + // step 8 draw current game state #if defined(BRENTS_CHEESY_GAME_PERF) && BRENTS_CHEESY_GAME_PERF - + time_gamestatedisplay_start = UUrMachineTime_High(); - + #endif if (ONgGameState->local.pending_splash_screen[0] != '\0') { @@ -466,22 +466,22 @@ ONiRunGame( } time_frame_end = UUrMachineTime_High(); - + // step 9 calculate the fps - + ONgNumFrames++; - + #if defined(BRENTS_CHEESY_GAME_PERF) && BRENTS_CHEESY_GAME_PERF { extern UUtBool ONgShowPerformance_Overall; - + time_frame_cur = (UUtUns32)(time_frame_end - time_frame_start); time_frame_total += time_frame_cur; time_frame_recent[time_frame_count] = time_frame_cur; time_frame_count = (time_frame_count + 1) % RECENT_FRAME_COUNT; time_gamestateupdate_cur = (UUtUns32)(time_gamestateupdate_end - time_gamestateupdate_start); time_gamestateupdate_total += time_gamestateupdate_cur; - + time_gamestatedisplay_cur = (UUtUns32)(time_frame_end - time_gamestatedisplay_start); time_gamestatedisplay_total += time_gamestatedisplay_cur; @@ -491,7 +491,7 @@ ONiRunGame( char s1[128]; char s2[128]; char s3[128]; - + float frames_per_second_cur; float frames_per_second_avg; @@ -499,20 +499,20 @@ ONiRunGame( float time_gamestateupdate_per_frame_avg; float time_gamestatedisplay_per_frame_cur; float time_gamestatedisplay_per_frame_avg; - + frames_per_second_cur = (float)(1.0 / (double)time_frame_cur * UUgMachineTime_High_Frequency); frames_per_second_avg = (float)(((double)ONgNumFrames / (double)time_frame_total) * UUgMachineTime_High_Frequency); - + time_gamestateupdate_per_frame_cur = (float)time_gamestateupdate_cur / (float)time_frame_cur; time_gamestateupdate_per_frame_avg = (float)time_gamestateupdate_total / (float)time_frame_total; - + time_gamestatedisplay_per_frame_cur = (float)time_gamestatedisplay_cur / (float)time_frame_cur; time_gamestatedisplay_per_frame_avg = (float)time_gamestatedisplay_total / (float)time_frame_total; - + sprintf(s1, "fps_cur: %03.1f, fps_avg: %03.1f", frames_per_second_cur, frames_per_second_avg); sprintf(s2, "gsu/f cur: %02.1f, gsu/f avg: %02.1f", time_gamestateupdate_per_frame_cur * 100.0f, time_gamestateupdate_per_frame_avg * 100.0f); sprintf(s3, "gsd/f cur: %02.1f, gsd/f avg: %02.1f", time_gamestatedisplay_per_frame_cur * 100.0f, time_gamestatedisplay_per_frame_avg * 100.0f); - + ONrGameState_Performance_UpdateOverall( s1, s2, @@ -526,21 +526,21 @@ ONiRunGame( UUtUns32 time_frame_index; UUtUns32 time_frame_recent_total; extern UUtUns32 triCounter, quadCounter, pentCounter; - + float frames_per_second_recent; time_frame_recent_total = 0; for (time_frame_index = 0; time_frame_index < RECENT_FRAME_COUNT; time_frame_index++) { time_frame_recent_total += time_frame_recent[time_frame_index]; } - + frames_per_second_recent = (float)(RECENT_FRAME_COUNT / (double)time_frame_recent_total * UUgMachineTime_High_Frequency); - + sprintf(s1, "fps:%03.1f 3:%d 4:%d 5:%d", frames_per_second_recent, triCounter, quadCounter, pentCounter); sprintf(s2, "tc:%d tm:%d", gl->num_loaded_textures, gl->current_texture_memory); ONrGameState_Performance_UpdateOverall(s1, s2, NULL); - + triCounter = 0; quadCounter = 0; pentCounter = 0; @@ -548,7 +548,7 @@ ONiRunGame( #endif } #endif - + #if defined(SScMSADPCMTimer) && (SScMSADPCMTimer == 1) SS2rFrame_End(); #endif @@ -560,7 +560,7 @@ ONiRunGame( ONgGameState->local.pending_pause_screen = UUcFalse; } - + switch(ONgGameState->victory) { case ONcWin: @@ -569,7 +569,7 @@ ONiRunGame( UUtUns16 next_level = ONrLevel_GetNextLevel(ONgGameState->levelNumber); ONrGameState_ClearContinue(); - + ONrGameState_SplashScreen(ONcWinSplashScreen, OScMusicScore_Win, UUcTrue); ONrLevel_Unload(); @@ -588,7 +588,7 @@ ONiRunGame( ONgTerminateGame = UUcTrue; } else if (next_level != 0) { - ONrLevel_Load(next_level, UUcTrue); + ONrLevel_Load(next_level, UUcTrue); } else { ONgTerminateGame = UUcTrue; @@ -599,10 +599,10 @@ ONiRunGame( case ONcLose: { UUtUns16 old_level = ONgGameState->levelNumber; - + ONrGameState_SplashScreen(ONcFailSplashScreen, OScMusicScore_Lose, UUcTrue); ONrLevel_Unload(); - ONrLevel_Load(ONgGameState->levelNumber, UUcTrue); + ONrLevel_Load(ONgGameState->levelNumber, UUcTrue); } break; } @@ -623,9 +623,9 @@ ONiConsole_Platform_Report( static UUtError ONiCreateConsoleVariables(void) { - + #if 0 - error = + error = COrCommand_New( "platform_report", "reports information about the target platform", @@ -633,7 +633,7 @@ static UUtError ONiCreateConsoleVariables(void) NULL); UUmError_ReturnOnError(error); #endif - + return UUcError_None; } @@ -643,12 +643,12 @@ static void RunKeyConfigFile(const char *inFileName) BFtFileRef configFileRef; BFtTextFile* configFile; char* curLine; - + error = BFrFileRef_Search(inFileName, &configFileRef); if(error != UUcError_None) { goto exit; } - + if (!BFrFileRef_FileExists(&configFileRef)) { goto exit; } @@ -658,7 +658,7 @@ static void RunKeyConfigFile(const char *inFileName) if (error != UUcError_None) { goto exit; } - + while(1) { curLine = BFrTextFile_GetNextStr(configFile); @@ -723,10 +723,10 @@ static void RunKeyConfigFile(const char *inFileName) } } } - + BFrTextFile_Close(configFile); -exit: +exit: return; } @@ -819,23 +819,23 @@ void OniExit( ONrMotoko_TearDownDrawing(); UUrMemory_Block_VerifyList(); - + // destropy the oni windows OWrTerminate(); - + // destroy the window manager before unloading level 0 WMrTerminate(); // Unload level 0 TMrLevel_Unload(0); - + UUrMemory_Block_VerifyList(); TMrTerminate(); UUrMemory_Block_VerifyList(); M3rTerminate(); - + #ifndef USE_OPENGL_WITH_BINK // now is the time to play the ending movie if we're going to do it in software // (after Motoko is terminated but while local input is still working) @@ -844,9 +844,9 @@ void OniExit( ONrMovie_Play("outro.bik", BKcScale_Fill_Window); } #endif - + LIrTerminate(); - + ONrInGameUI_Terminate(); WPrTerminate(); ONrImpactEffects_Terminate(); @@ -876,7 +876,7 @@ void OniExit( IMrTerminate(); ONrScript_Terminate(); SLrScript_Terminate(); - + UUrMemory_Block_VerifyList(); UUrStartupMessage("oni exit complete, shutting down..."); @@ -892,42 +892,42 @@ ONiMain( char** argv) { UUtError error; - + ONtGameState* gameState = NULL; - - + + // Brents debugging stuff #if 0 { #define ns (30) - + UUtUns32 i; UUtInt64* samples; UUtUns32 final[ns]; - + samples = UUrMemory_Block_New(sizeof(UUtInt64) * ns); UUmError_ReturnOnNull(samples); - + for(i = 0; i < ns; i++) { Microseconds((UnsignedWide*)&samples[i]); Delay(60, &final[i]); } - + for(i = 1; i < ns; i++) { fprintf(stderr, "%d, %d\n", (UUtInt32)(samples[i] - samples[i-1]), final[i]); } - + return; } #endif - + if(OniParseCommandLine(argc, argv) != UUcError_None) { return UUcError_BadCommandLine; } - + /* * Initialize the Universal Utilities. This does a base level platform init. So if * this succedes we can bring up error dialogs @@ -940,26 +940,26 @@ ONiMain( /* XXX - This is really bad - should never happen */ return error; } - + #if defined(PROFILE) && PROFILE error = UUrProfile_Initialize(); UUmError_ReturnOnErrorMsg(error, "Could not initialize profiler."); - + UUrProfile_State_Set(UUcProfile_State_Off); #endif - + /* * Initialize all components */ error = ONiInitializeAll(&ONgPlatformData); UUmError_ReturnOnErrorMsg(error, "Could not initialize components."); - + /* * Load Level Zero */ error = ONrLevel_LoadZero(); UUmError_ReturnOnErrorMsg(error, "Could not load level zero"); - + #ifndef USE_OPENGL_WITH_BINK /* * play movie before OpenGL takes over @@ -970,18 +970,18 @@ ONiMain( /* * Get the motoko drawing context */ - error = + error = ONrMotoko_SetupDrawing( &ONgPlatformData); UUmError_ReturnOnError(error); - + // Now new texture maps can be created, so aiming can make its texture AMrInitialize(); - + /* * initialize the Oni Window */ - UUrStartupMessage("Initializing the Oni Window..."); + UUrStartupMessage("Initializing the Oni Window..."); error = OWrInitialize(); UUmError_ReturnOnErrorMsg(error, "Unable to initialize the Oni Window"); @@ -1010,7 +1010,7 @@ ONiMain( #endif KeyConfig(); - + /* * run the main menu */ @@ -1023,31 +1023,31 @@ ONiMain( /* * Load the level */ - + #if TOOL_VERSION - // Run the console config file + // Run the console config file UUrStartupMessage("loading config file..."); if (COcConfigFile_Read == ONgCommandLine.readConfigFile) COrRunConfigFile("oni_config.txt"); #endif - + /* * Run the game */ - + UUrStartupMessage("running game..."); error = ONiRunGame(); UUmError_ReturnOnErrorMsg(error, "error running game"); - + #if defined(PROFILE) && PROFILE - + UUrProfile_State_Set(UUcProfile_State_Off); - + UUrProfile_Dump("OniProfile"); UUrProfile_Terminate(); - + #endif - + UUrMemory_Block_VerifyList(); if (NULL != ONgLevel) { @@ -1055,7 +1055,7 @@ ONiMain( ONrLevel_Unload(); } } - + OniExit(); return UUcError_None; @@ -1077,7 +1077,7 @@ main( #else // shift key reads in command line params if (LIrTestKey(LIcKeyCode_LeftShift) || LIrTestKey(LIcKeyCode_RightShift)) #endif - { + { argc= CLrGetCommandLine(argc, argv, &argv); } diff --git a/OniProj/OniGameSource/Oni.h b/OniProj/OniGameSource/Oni.h index 68e5bf0..df8827c 100644 --- a/OniProj/OniGameSource/Oni.h +++ b/OniProj/OniGameSource/Oni.h @@ -1,13 +1,13 @@ #pragma once /* FILE: Oni.h - + AUTHOR: Brent H. Pease - + CREATED: Jan 10, 1998 - + PURPOSE: main .c file for Oni - + Copyright 1997 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI.c b/OniProj/OniGameSource/Oni_AI/Oni_AI.c index 4a24bbd..aab5dd4 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI.c @@ -1,8 +1,8 @@ /* Oni_AI.c - + Top level AI stuff - + Author: Quinn Dunki c1998 Bungie */ @@ -34,19 +34,19 @@ UUtError AIrRegisterTemplates( /************** * Register templates */ - + UUtError error; - + error = TMrTemplate_Register(AIcTemplate_WaypointArray,sizeof(AItWaypointArray),TMcFolding_Allow); UUmError_ReturnOnError(error); error = TMrTemplate_Register(AIcTemplate_CharacterSetupArray,sizeof(AItCharacterSetupArray),TMcFolding_Allow); UUmError_ReturnOnError(error); error = TMrTemplate_Register(NMcTemplate_SpawnPointArray,sizeof(NMtSpawnPointArray),TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(AIcTemplate_ScriptTriggerClassArray,sizeof(AItScriptTriggerClassArray),TMcFolding_Allow); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI.h b/OniProj/OniGameSource/Oni_AI/Oni_AI.h index 933857b..2a91a80 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI.h @@ -1,8 +1,8 @@ /* Oni_AI.h - + Top level AI header stuff - + Author: Quinn Dunki c1998 Bungie */ @@ -35,7 +35,7 @@ extern UUtBool AIgBeCute; #define AIcMaxTeams 32 -typedef struct AItActivity AItActivity; +typedef struct AItActivity AItActivity; typedef struct AItBehaviour AItBehaviour; typedef struct AItGroup AItGroup; @@ -87,7 +87,7 @@ typedef enum AItArmed enum { AIcPath_Idle = 0, - AIcPath_Follow = 1 // on if path following is enabled + AIcPath_Follow = 1 // on if path following is enabled }; @@ -96,29 +96,29 @@ enum UUtError AIrInitialize( void); - + void AIrTerminate( void); UUtError AIrRegisterTemplates( void); - + void AIrDisplay( void); void AIrDisplay_Character( - ONtCharacter *inCharacter); - + ONtCharacter *inCharacter); + UUtBool AIrH2H_ShouldBlock( ONtCharacter *inCharacter); - + void AIrFrameStart( ONtCharacter *inCharacter); void AIrFrameEnd( ONtCharacter *inCharacter); - + UUtError AIrInitialize_Display( void); @@ -127,7 +127,7 @@ void AIrNotify_Collision_Object( void AIrNotify_Collision_Environment( ONtCharacter *inCharacter); - + UUtError AIrLevelBegin( void); @@ -139,5 +139,5 @@ void AIrDisplay_GraphNode( AKtBNVNode *inNode, UUtUns32 inShade); - + #endif diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2.c index 45d265f..13daebd 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2.c - + AUTHOR: Michael Evans, Chris Butcher - + CREATED: November 15, 1999 - + PURPOSE: AI for characters in Oni - + Copyright (c) 1999 */ @@ -179,7 +179,7 @@ void AI2rUpdateAI(void) player_character = ONrGameState_GetPlayerCharacter(); living_character_list = ONrGameState_LivingCharacterList_Get(); living_character_count = ONrGameState_LivingCharacterList_Count(); - + for (character_index = 0; character_index < living_character_count; character_index++) { character = living_character_list[character_index]; @@ -272,7 +272,7 @@ void AI2rUpdateAI(void) AI2rVocalize(character, AI2cVocalization_Alert, UUcFalse); character->ai2State.flags |= AI2cFlag_SaidAlertSound; } - } + } if (character->ai2State.daze_timer > 0) { ONtActiveCharacter *active_character = ONrGetActiveCharacter(character); @@ -283,8 +283,8 @@ void AI2rUpdateAI(void) #if AI_DEBUG_DAZE if (active_character != NULL) { COrConsole_Printf("%s: %d: not yet on ground (states %s -> %s)", - character->player_name, ONrGameState_GetGameTime(), - ONrAnimStateToString(active_character->curFromState), + character->player_name, ONrGameState_GetGameTime(), + ONrAnimStateToString(active_character->curFromState), ONrAnimStateToString(active_character->nextAnimState)); } #endif @@ -377,19 +377,19 @@ void AI2rUpdateAI(void) case AI2cGoal_Idle: AI2rIdle_Update(character); break; - + case AI2cGoal_Patrol: AI2rPatrol_Update(character); break; - + case AI2cGoal_Pursuit: AI2rPursuit_Update(character); break; - + case AI2cGoal_Alarm: AI2rAlarm_Update(character); break; - + case AI2cGoal_Combat: AI2rCombat_Update(character); break; @@ -423,7 +423,7 @@ void AI2rUpdateAI(void) AI2rKnowledge_ImmediatePost(UUcFalse); AI2rMelee_GlobalFinish(); } -} +} // start the AI2 system for a particular level UUtError AI2rLevelBegin(void) @@ -478,7 +478,7 @@ static UUtBool AI2iEnumCallback_StartCharacters(OBJtObject *inObject, UUtUns32 i UUmAssert(inObject->object_type == OBJcType_Character); char_osd = (OBJtOSD_Character *) inObject->object_data; - + // reset 'spawned' flag for this level char_osd->flags &= ~OBJcCharFlags_Spawned; @@ -502,7 +502,7 @@ static UUtBool AI2iEnumCallback_Spawn(OBJtObject *inObject, UUtUns32 inUserData) UUmAssert(inObject->object_type == OBJcType_Character); char_osd = (OBJtOSD_Character *) inObject->object_data; - + if (strcmp(char_osd->character_name, user_data->name) == 0) { if ((!user_data->force) && (char_osd->flags & OBJcCharFlags_Spawned) && ((char_osd->flags & OBJcCharFlags_SpawnMultiple) == 0)) { // can't spawn this character multiple times @@ -529,7 +529,7 @@ static UUtBool AI2iEnumCallback_SpawnPlayer(OBJtObject *inObject, UUtUns32 inUse UUmAssert(inObject->object_type == OBJcType_Character); char_osd = (OBJtOSD_Character *) inObject->object_data; - + if ((char_osd->flags & OBJcCharFlags_Player) == 0) { return UUcTrue; } @@ -556,13 +556,13 @@ UUtError AI2rStartAllCharacters(UUtBool inStartPlayer, UUtBool inOverride) // we spawn the player first so that they are always character 0 (makes // debugging easier) if (inStartPlayer) { - OBJrObjectType_EnumerateObjects(OBJcType_Character, AI2iEnumCallback_SpawnPlayer, (UUtUns32) &player); + OBJrObjectType_EnumerateObjects(OBJcType_Character, AI2iEnumCallback_SpawnPlayer, (UUtUns32) &player); } // enumerate all characters user_data.spawn_player = UUcFalse; user_data.spawn_all = inOverride; - OBJrObjectType_EnumerateObjects(OBJcType_Character, AI2iEnumCallback_StartCharacters, (UUtUns32) &user_data); + OBJrObjectType_EnumerateObjects(OBJcType_Character, AI2iEnumCallback_StartCharacters, (UUtUns32) &user_data); return UUcError_None; } @@ -577,7 +577,7 @@ UUtError AI2rSpawnCharacter(char *inName, UUtBool inForce) // enumerate until we find this character user_data.name = inName; user_data.force = inForce; - OBJrObjectType_EnumerateObjects(OBJcType_Character, AI2iEnumCallback_Spawn, (UUtUns32) &user_data); + OBJrObjectType_EnumerateObjects(OBJcType_Character, AI2iEnumCallback_Spawn, (UUtUns32) &user_data); return UUcError_None; } @@ -588,7 +588,7 @@ ONtCharacter *AI2rRecreatePlayer(void) ONtCharacter *player = NULL; // enumerate until we find the player - OBJrObjectType_EnumerateObjects(OBJcType_Character, AI2iEnumCallback_SpawnPlayer, (UUtUns32) &player); + OBJrObjectType_EnumerateObjects(OBJcType_Character, AI2iEnumCallback_SpawnPlayer, (UUtUns32) &player); return player; } @@ -763,7 +763,7 @@ UUtError AI2rInitializeCharacter(ONtCharacter *ioCharacter, const OBJtOSD_Charac omniscient = UUcFalse; } } - + if (ioCharacter->charType != ONcChar_AI2) return UUcError_None; @@ -781,7 +781,7 @@ UUtError AI2rInitializeCharacter(ONtCharacter *ioCharacter, const OBJtOSD_Charac ioCharacter->ai2State.flags |= AI2cFlag_Omniscient; } AI2rExecutor_Initialize(ioCharacter); - AI2rKnowledgeState_Initialize(&ioCharacter->ai2State.knowledgeState); + AI2rKnowledgeState_Initialize(&ioCharacter->ai2State.knowledgeState); AI2rPath_Initialize(ioCharacter); /**** set up alert status */ @@ -872,7 +872,7 @@ UUtError AI2rInitializeCharacter(ONtCharacter *ioCharacter, const OBJtOSD_Charac if (combat_found) { ioCharacter->ai2State.combatSettings.flags = combat_data.flags; ioCharacter->ai2State.combatSettings.medium_range = combat_data.medium_range; - + for (itr = 0; itr < AI2cCombatRange_NumStoredRanges; itr++) { ioCharacter->ai2State.combatSettings.behavior[itr] = (AI2tBehaviorType)combat_data.behavior[itr]; } @@ -1024,7 +1024,7 @@ void AI2rEnterState(ONtCharacter *ioCharacter) void AI2rExitState(ONtCharacter *ioCharacter) { // UUrDebuggerMessage("*** exiting state %s\n", AI2cGoalName[ioCharacter->ai2State.currentGoal]); - + if (ioCharacter->ai2State.flags & AI2cFlag_StateTransition) { UUmAssert(!"AI2rExitState called while in state transition"); UUrDebuggerMessage("*** AI ERROR: AI %s tried to exit-state while in the middle of a state transition", ioCharacter->player_name); @@ -1216,7 +1216,7 @@ void AI2rPassive(ONtCharacter *ioCharacter, UUtBool inPassive) // so that everyone doesn't play idle anims at the end of a long scripting sequence ioCharacter->lastActiveAnimationTime = ONrGameState_GetGameTime(); } - + if (ioCharacter->charType != ONcChar_AI2) return; @@ -1275,7 +1275,7 @@ UUtBool AI2rCharacter_PotentiallyHostile(ONtCharacter *inCharacter, ONtCharacter entry = AI2rKnowledge_FindEntry(inCharacter, &inCharacter->ai2State.knowledgeState, inTarget); if ((entry != NULL) && ((entry->has_been_hostile) || (entry->priority >= AI2cContactPriority_Hostile_Threat))) { return UUcTrue; - } + } } } @@ -1289,7 +1289,7 @@ UUtBool AI2rCharacter_PotentiallyHostile(ONtCharacter *inCharacter, ONtCharacter return UUcTrue; } } - + return UUcFalse; } @@ -1590,7 +1590,7 @@ void AI2rNotifyAttackLanded(ONtCharacter *inAttacker, ONtCharacter *inDefender) if ((inDefender->charType != ONcChar_AI2) || (inDefender->ai2State.currentGoal != AI2cGoal_Combat)) return; - + melee_state = &inDefender->ai2State.currentState->state.combat.melee; if ((melee_state->target == inAttacker) && (melee_state->currently_blocking)) { @@ -1708,7 +1708,7 @@ UUtBool AI2rBlockFunction(ONtCharacter *inCharacter) if (melee_state->fight_info.fight_owner != NULL) { num_attackers = melee_state->fight_info.fight_owner->num_attackers; - + if (num_attackers >= AI2cMelee_GroupNumAttackers) { // we are fighting in a large group block_percentage = (float) profile->blockgroup_percentage; @@ -1800,7 +1800,7 @@ UUtBool AI2rVocalize(ONtCharacter *ioCharacter, UUtUns32 inVocalizationType, UUt if ((ioCharacter->charType == ONcChar_AI2) && (inVocalizationType == AI2cVocalization_Taunt)) { // check to see this taunt is part of a check-body sound... if so then don't play it - if ((ioCharacter->ai2State.currentGoal == AI2cGoal_Combat) && + if ((ioCharacter->ai2State.currentGoal == AI2cGoal_Combat) && (ioCharacter->ai2State.currentState->state.combat.dead_done_taunt)) { return UUcFalse; } @@ -1838,7 +1838,7 @@ UUtBool AI2rTryNeutralInteraction(ONtCharacter *ioCharacter, UUtBool inActivate) UUtUns32 num_chars, itr; AI2tNeutralState *neutral_state; UUtBool found_char_already_triggered; - + if (ioCharacter->neutral_interaction_char != NULL) { // we are already involved in a neutral interaction return UUcTrue; @@ -2034,7 +2034,7 @@ void AI2rSmite(ONtCharacter *inCharacter, UUtBool inSpareCharacter) continue; // smite one character - ONrCharacter_TakeDamage(*charptr, (*charptr)->hitPoints, 0.f, NULL, NULL, + ONrCharacter_TakeDamage(*charptr, (*charptr)->hitPoints, 0.f, NULL, NULL, WPcDamageOwner_ActOfGod, ONcAnimType_None); } } @@ -2267,7 +2267,7 @@ void AI2rDisplayGlobalDebuggingInfo(void) } else { shade = PHgPathfindingWeightColor[AI2gDebugLocalPath_Weight[itr]]; } - + if (count == 1) { MUmVector_Copy(p0, AI2gDebugLocalPath_Point); p0.y += 0.5f; @@ -2276,7 +2276,7 @@ void AI2rDisplayGlobalDebuggingInfo(void) p1.y += 0.5f; M3rGeom_Line_Light(&p0, &p1, shade); - } else { + } else { MUmVector_Copy(p1, AI2gDebugLocalPath_EndPoint[itr]); p1.y += 9.0f; @@ -2349,7 +2349,7 @@ void AI2rDisplayDebuggingInfo(ONtCharacter *ioCharacter) M3tPoint3D position; UUtError error; char name[96]; - + if (!AI2gDebugName_Initialized) { error = AI2rDebugName_Initialize(); if (error != UUcError_None) @@ -2359,7 +2359,7 @@ void AI2rDisplayDebuggingInfo(ONtCharacter *ioCharacter) // erase the texture and set the text contexts shade M3rTextureMap_Fill(AI2gDebugName_Texture, AI2gDebugName_WhiteColor, NULL); TSrContext_SetShade(AI2gDebugName_TextContext, IMcShade_Black); - + // get the string if (AI2gShowHealth) { if (AI2gShowNames) { @@ -2502,7 +2502,7 @@ void AI2rDisplayDebuggingInfo(ONtCharacter *ioCharacter) AI2rPath_RenderPath(ioCharacter); AI2rMovement_RenderPath(ioCharacter); } - + // *** everything beyond here is only done for AI characters if (ioCharacter->charType != ONcChar_AI2) { return; @@ -2563,7 +2563,7 @@ void AI2rDisplayDebuggingInfo(ONtCharacter *ioCharacter) p0.x += 6.0f; p1.x -= 6.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_Green); - + p0.x -= 6.0f; p1.x += 6.0f; p0.z += 6.0f; @@ -2588,21 +2588,21 @@ void AI2rDisplayDebuggingInfo(ONtCharacter *ioCharacter) /* * draw debugging info about our targeting vectors */ - + // draw a cross at the current aim point (where we want to hit) MUmVector_Copy(p0, targeting_state->current_aim_pt); MUmVector_Copy(p1, targeting_state->current_aim_pt); - + p0.x += 3.0f; p1.x -= 3.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_Blue); - + p0.x -= 3.0f; p1.x += 3.0f; p0.y += 3.0f; p1.y -= 3.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_Blue); - + p0.y -= 3.0f; p1.y += 3.0f; p0.z += 3.0f; @@ -2613,17 +2613,17 @@ void AI2rDisplayDebuggingInfo(ONtCharacter *ioCharacter) MUmVector_Add(aim_at, targeting_state->weapon_pt, targeting_state->desired_shooting_vector); MUmVector_Copy(p0, aim_at); MUmVector_Copy(p1, aim_at); - + p0.x += 3.0f; p1.x -= 3.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_LightBlue); - + p0.x -= 3.0f; p1.x += 3.0f; p0.y += 3.0f; p1.y -= 3.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_LightBlue); - + p0.y -= 3.0f; p1.y += 3.0f; p0.z += 3.0f; @@ -2694,38 +2694,38 @@ void AI2rDisplayDebuggingInfo(ONtCharacter *ioCharacter) M3rGeom_Line_Light(&p0, &p1, IMcShade_Blue); } } - + if ((AI2gDebug_ShowPrediction) && (targeting_state->predictionbuf != NULL)) { /* * draw debugging info about our prediction vectors */ - + UUtUns32 itr, sample_trend, sample_vel, sample_now; - UUtUns32 trend_frames, velocity_frames, delay_frames; - + UUtUns32 trend_frames, velocity_frames, delay_frames; + trend_frames = targeting_state->targeting_params->predict_trendframes; velocity_frames = targeting_state->targeting_params->predict_velocityframes; delay_frames = targeting_state->targeting_params->predict_delayframes; - + // draw our prediction buffer for (itr = 0; itr < trend_frames; itr++) { // work out which indices we're using to build the current motion estimate sample_trend = targeting_state->next_sample + UUmMin(targeting_state->num_samples_taken, trend_frames); sample_vel = targeting_state->next_sample + UUmMin(targeting_state->num_samples_taken, velocity_frames); sample_now = targeting_state->next_sample + UUmMin(targeting_state->num_samples_taken, delay_frames); - + // the buffer is predict_trendframes long sample_trend %= trend_frames; sample_vel %= trend_frames; sample_now %= trend_frames; - + if ((targeting_state->num_samples_taken >= trend_frames) || (itr > targeting_state->next_sample)) { MUmVector_Copy(p0, targeting_state->predictionbuf[itr]); MUmVector_Copy(p1, targeting_state->predictionbuf[itr]); p0.y += 5.0f; p1.y -= 5.0f; - + if (itr == sample_now) { shade = IMcShade_Yellow; } else if (itr == sample_vel) { @@ -2735,44 +2735,44 @@ void AI2rDisplayDebuggingInfo(ONtCharacter *ioCharacter) } else { shade = IMcShade_White; } - + M3rGeom_Line_Light(&p0, &p1, shade); } } - + if (targeting_state->valid_target_pt) { // draw our target point MUmVector_Copy(p0, targeting_state->target_pt); MUmVector_Copy(p1, p0); - + p0.x += 3.0f; p1.x -= 3.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_Purple); - + p0.x -= 3.0f; p1.x += 3.0f; p0.y += 3.0f; p1.y -= 3.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_Purple); - + p0.y -= 3.0f; p1.y += 3.0f; p0.z += 3.0f; p1.z -= 3.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_Purple); } - + if (combat_state->target != NULL) { // draw the target's predicted velocity and trend vectors MUmVector_Copy(p0, targeting_state->target->location); p0.y += targeting_state->target->heightThisFrame; - + MUmVector_Add(p1, p0, targeting_state->predicted_trend); M3rGeom_Line_Light(&p0, &p1, IMcShade_LightBlue); - + MUmVector_Add(p1, p0, targeting_state->predicted_velocity); M3rGeom_Line_Light(&p0, &p1, IMcShade_Blue); - + // draw a little tick on the velocity vector MUmVector_ScaleIncrement(p0, targeting_state->current_prediction_accuracy, targeting_state->predicted_velocity); MUmVector_Copy(p1, p0); @@ -2803,9 +2803,9 @@ void AI2rDisplayDebuggingInfo(ONtCharacter *ioCharacter) float x, y, delta_x, vertical_max, vertical_min, vertical_range, horiz_angle, dist; M3tPoint3D points[9], p0, p1; AI2tExecutorState *executor = &active_character->executor_state; - + ONrCharacter_GetEyePosition(ioCharacter, &points[0]); - + vertical_range = MUrACos(vision->vertical_range); if (active_character->isAiming) { @@ -2937,7 +2937,7 @@ static UUtError AI2rDebugName_Initialize(void) */ M3rDrawEngine_FindGrayscalePixelType(&textureFormat); - + AI2gDebugName_WhiteColor = IMrPixel_FromShade(textureFormat, IMcShade_White); error = TSrFontFamily_Get(TScFontFamily_Default, &font_family); @@ -2945,20 +2945,20 @@ static UUtError AI2rDebugName_Initialize(void) { goto cleanup; } - + error = TSrContext_New(font_family, TScFontSize_Default, TScStyle_Bold, TSc_SingleLine, UUcFalse, &AI2gDebugName_TextContext); if (error != UUcError_None) { goto cleanup; } - + AI2gDebugName_Dest.x = 2; AI2gDebugName_Dest.y = TSrFont_GetLeadingHeight(TSrContext_GetFont(AI2gDebugName_TextContext, TScStyle_InUse)) + TSrFont_GetAscendingHeight(TSrContext_GetFont(AI2gDebugName_TextContext, TScStyle_InUse)); - + TSrContext_GetStringRect(AI2gDebugName_TextContext, "maximum_length_of_character_name", &AI2gDebugName_TextureBounds); - + error = M3rTextureMap_New( AI2gDebugName_TextureBounds.right, @@ -2977,12 +2977,12 @@ static UUtError AI2rDebugName_Initialize(void) M3rTextureRef_GetSize((void *) AI2gDebugName_Texture, (UUtUns16*)&AI2gDebugName_TextureBounds.right, (UUtUns16*)&AI2gDebugName_TextureBounds.bottom); - + AI2gDebugName_TextureWidth = AI2gDebugName_TextureBounds.right; AI2gDebugName_TextureHeight = AI2gDebugName_TextureBounds.bottom; - + AI2gDebugName_WidthRatio = (float)AI2gDebugName_TextureWidth / (float)AI2gDebugName_TextureHeight; - + AI2gDebugName_Initialized = UUcTrue; return UUcError_None; diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2.h index e01e847..a1d3197 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2.h - + AUTHOR: Michael Evans - + CREATED: November 15, 1999 - + PURPOSE: AI for characters in Oni - + Copyright (c) 1999 */ @@ -76,7 +76,7 @@ enum { AI2cFlag_InUse = (1 << 0), AI2cFlag_Passive = (1 << 1), AI2cFlag_NonCombatant = (1 << 2), - AI2cFlag_RunCombatScript = (1 << 3), // these scripts are called in main AI update so that unexpected state + AI2cFlag_RunCombatScript = (1 << 3), // these scripts are called in main AI update so that unexpected state AI2cFlag_RunAlarmScript = (1 << 4), // changes don't happen in the knowledge code AI2cFlag_RunNeutralScript = (1 << 5), // similar rationale to combat and alarm scripts AI2cFlag_RunOutOfAmmoScript = (1 << 6), // ditto @@ -142,7 +142,7 @@ typedef struct AI2tState { // global settings UUtUns32 flags; - + // goal and job control AI2tGoal jobGoal; AI2tGoal currentGoal; @@ -371,4 +371,4 @@ void AI2rForget(ONtCharacter *inCharacter, ONtCharacter *forgetCharacter); // drop into the debugger next update loop void AI2rDebug_BreakPoint(void); -#endif // ONI_AI2_H \ No newline at end of file +#endif // ONI_AI2_H diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alarm.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alarm.c index fa2ceb1..f39c477 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alarm.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alarm.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Alarm.c - + AUTHOR: Chris Butcher - + CREATED: September 2, 2000 - + PURPOSE: Alarm AI for Oni - + Copyright (c) 2000 Bungie Software */ @@ -137,7 +137,7 @@ void AI2rAlarm_Update(ONtCharacter *ioCharacter) // attack this character AI2iAlarm_Finish(ioCharacter, alarm_state, entry); } - + if (!ioCharacter->pathState.at_finalpoint) { // keep running to alarm! @@ -279,7 +279,7 @@ UUtBool AI2rAlarm_Setup(ONtCharacter *ioCharacter, ONtActionMarker *inActionMark void AI2rAlarm_Stop(ONtCharacter *ioCharacter, UUtBool inSuccess) { UUmAssert(ioCharacter->charType == ONcChar_AI2); - + #if DEBUG_VERBOSE_ALARM COrConsole_Printf("alarm: stop"); #endif diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alarm.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alarm.h index ee971b6..1fb4da3 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alarm.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alarm.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Alarm.h - + AUTHOR: Chris Butcher - + CREATED: September 2, 2000 - + PURPOSE: Alarm AI for Oni - + Copyright (c) 2000 Bungie Software */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alert.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alert.c index 39da1ca..ffbeec8 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alert.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alert.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Alert.c - + AUTHOR: Chris Butcher - + CREATED: April 19, 2000 - + PURPOSE: Alert Status for Oni's AI - + Copyright (c) 2000 */ @@ -298,7 +298,7 @@ static UUtBool AI2iAlert_Startle(ONtCharacter *ioCharacter, AI2tAlertStatus inFr // don't startle if this isn't a high alert that we're going to if (ioCharacter->ai2State.alertStatus < AI2cAlertStatus_High) return UUcFalse; - + // don't startle if this is not a result of a contact, but an alarm if (inContact == NULL) return UUcFalse; diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alert.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alert.h index 890574e..deba9b7 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alert.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Alert.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Alert.h - + AUTHOR: Chris Butcher - + CREATED: April 19, 2000 - + PURPOSE: Alert Status for Oni's AI - + Copyright (c) 2000 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Combat.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Combat.c index bdf4dca..c72cd61 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Combat.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Combat.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Combat.c - + AUTHOR: Chris Butcher - + CREATED: April 20, 2000 - + PURPOSE: Combat Manager for Oni AI system - + Copyright (c) 2000 */ @@ -151,7 +151,7 @@ UUtUns32 AI2gCombat_LOSUsedPoints, AI2gCombat_LOSNextPoint; // -- internal function prototypes // behavior control -static void AI2iCombat_ChangeBehavior(ONtCharacter *ioCharacter, AI2tCombatState *ioCombatState); +static void AI2iCombat_ChangeBehavior(ONtCharacter *ioCharacter, AI2tCombatState *ioCombatState); static void AI2iCombat_RevertToBasicBehavior(ONtCharacter *ioCharacter, AI2tCombatState *ioCombatState); // contact and knowledge handling @@ -295,7 +295,7 @@ void AI2rCombat_Enter(ONtCharacter *ioCharacter) { AI2tCombatState *combat_state; AI2tTargetingOwner targeting_owner; - + UUmAssert(ioCharacter->charType == ONcChar_AI2); UUmAssert(ioCharacter->ai2State.currentGoal == AI2cGoal_Combat); combat_state = &ioCharacter->ai2State.currentState->state.combat; @@ -326,7 +326,7 @@ void AI2rCombat_Enter(ONtCharacter *ioCharacter) combat_state->alternate_trigger_pressed = UUcFalse; combat_state->no_technique_timer = 0; combat_state->try_advance_timer = 0; - + // we don't respond to stimuli in the same way any more ioCharacter->ai2State.knowledgeState.callback = &AI2rCombat_NotifyKnowledge; @@ -407,7 +407,7 @@ void AI2rCombat_Update(ONtCharacter *ioCharacter) // TEMPORARY DEBUGGING // UUrDebuggerMessage("AI2rCombat_Update: target knowledge ptr is 0x%08X\n", (UUtUns32) combat_state->target_knowledge); -// UUmAssert((combat_state->target_knowledge >= AI2gKnowledgeBase) && +// UUmAssert((combat_state->target_knowledge >= AI2gKnowledgeBase) && // (combat_state->target_knowledge < AI2gKnowledgeBase + AI2gKnowledge_ClearSpaceIndex)); // check that our target is still valid... may also change targets or drop us out of the combat manager @@ -454,7 +454,7 @@ void AI2rCombat_Update(ONtCharacter *ioCharacter) // check to see if we are dazed from a fall if (AI2rCombat_Behavior(ioCharacter, combat_state, AI2cCombatMessage_Fallen, &handled, 0, 0, 0)) { // lie still - AI2rPath_Halt(ioCharacter); + AI2rPath_Halt(ioCharacter); AI2rMovement_StopAiming(ioCharacter); AI2iCombat_Trigger(ioCharacter, combat_state, UUcFalse); return; @@ -493,7 +493,7 @@ void AI2rCombat_Update(ONtCharacter *ioCharacter) AI2iCombat_ChangeBehavior(ioCharacter, combat_state); } -/* COrConsole_Printf("%s: combat range %s -> %s, new behavior %s", ioCharacter->player_name, +/* COrConsole_Printf("%s: combat range %s -> %s, new behavior %s", ioCharacter->player_name, AI2cCombatRangeName[old_range], AI2cCombatRangeName[target_range], AI2cBehaviorName[ioCharacter->ai2State.combatSettings.behavior[target_range - 1]]);*/ } @@ -645,7 +645,7 @@ void AI2rCombat_Update(ONtCharacter *ioCharacter) combat_state->runningpickup_enable ? "YES" : "NO"); } } - + // maybe try to pick up the gun that we are going for 'on the run' combat_state->maneuver.gun_running_pickup = combat_state->runningpickup_enable && AI2rManeuver_TryRunningGunPickup(ioCharacter, combat_state); } else { @@ -752,7 +752,7 @@ void AI2rCombat_Update(ONtCharacter *ioCharacter) if (ioCharacter->ai2State.alarmStatus.action_marker != NULL) { // we are in combat instead of going for our alarm if (combat_state->distance_to_target < ioCharacter->ai2State.alarmSettings.chase_enemy_dist) { - // we are close enough to reset our timer + // we are close enough to reset our timer #if DEBUG_VERBOSE_ALARM COrConsole_Printf("in combat, close enough (%f < %f) to reset fight timer", combat_state->distance_to_target, ioCharacter->ai2State.alarmSettings.chase_enemy_dist); @@ -776,7 +776,7 @@ void AI2rCombat_Update(ONtCharacter *ioCharacter) /* * targeting update */ - + disable_shooting = able_to_melee; disable_shooting = disable_shooting || ONrCharacter_IsStartling(ioCharacter, &startle_frame); disable_shooting = disable_shooting || ((too_close_weight > 0.2f) && (combat_state->maneuver.primary_movement == AI2cPrimaryMovement_Retreat)); @@ -811,7 +811,7 @@ void AI2rCombat_Update(ONtCharacter *ioCharacter) // don't run targeting at all looking_at_target = UUcFalse; } - + if (!looking_at_target) { // just look in our direction of motion AI2rMovement_StopAiming(ioCharacter); @@ -1116,7 +1116,7 @@ void AI2rCombat_NotifyKnowledge(ONtCharacter *ioCharacter, AI2tKnowledgeEntry *i } else { priority_differential = AI2rKnowledge_CompareFunc(combat_state->target_knowledge, inEntry, UUcTrue, ioCharacter); - + if (priority_differential > 0) { // higher priority target overrules change_targets = UUcTrue; @@ -1128,7 +1128,7 @@ void AI2rCombat_NotifyKnowledge(ONtCharacter *ioCharacter, AI2tKnowledgeEntry *i } if ((combat_state->target_knowledge != NULL) && (inEntry->strength == AI2cContactStrength_Definite)) { - // attack people who are significantly closer than our current target - don't attack + // attack people who are significantly closer than our current target - don't attack // people who are a long distance further away newcontact_distance = MUmVector_GetDistanceSquared(combat_state->targeting.targeting_frompt, inEntry->last_location); oldcontact_distance = MUmVector_GetDistanceSquared(combat_state->targeting.targeting_frompt, combat_state->target_knowledge->last_location); @@ -1157,7 +1157,7 @@ void AI2rCombat_NotifyKnowledge(ONtCharacter *ioCharacter, AI2tKnowledgeEntry *i change_targets = UUcTrue; } } - + if (change_targets) { if (clear_hurt_me && (combat_state->target_knowledge != NULL)) { combat_state->target_knowledge->has_hurt_me = UUcFalse; @@ -1245,7 +1245,7 @@ static UUtBool AI2iCombat_CheckTarget(ONtCharacter *ioCharacter, AI2tCombatState (ioCombatState->investigate_body_timer < ioCombatState->combat_parameters->investigate_body_delay / 2)) { UUtUns32 random_val, random_chance; ONtActiveCharacter *active_character = ONrForceActiveCharacter(ioCharacter); - + ioCombatState->dead_done_taunt = UUcTrue; ioCombatState->dead_taunt_enable = UUcFalse; @@ -1792,7 +1792,7 @@ static UUtBool AI2iCheckFightBack(ONtCharacter *ioCharacter, AI2tCombatState *io return UUcFalse; } - + static UUtUns32 AI2iTryToFindGunBehavior(ONtCharacter *ioCharacter, AI2tCombatState *ioCombatState, AI2tCombatMessage inMsg, UUtBool *inHandled, UUtUns32 inParam1, UUtUns32 inParam2, UUtUns32 inParam3) @@ -2047,7 +2047,7 @@ static UUtUns32 AI2iBehavior_Stare(ONtCharacter *ioCharacter, AI2tCombatState *i case AI2cCombatMessage_BeginBehavior: // nothing to set up in our internal state return 0; - + case AI2cCombatMessage_PrimaryMovement: // stand still ioCombatState->maneuver.primary_movement_weights[AI2cPrimaryMovement_Hold] = 1.0f; @@ -2093,7 +2093,7 @@ static UUtUns32 AI2iBehavior_HoldAndFire(ONtCharacter *ioCharacter, AI2tCombatSt case AI2cCombatMessage_BeginBehavior: // nothing to set up in our internal state return 0; - + case AI2cCombatMessage_PrimaryMovement: // stand still ioCombatState->maneuver.primary_movement_weights[AI2cPrimaryMovement_Hold] = 1.0f; @@ -2140,7 +2140,7 @@ static UUtUns32 AI2iBehavior_FiringCharge(ONtCharacter *ioCharacter, AI2tCombatS case AI2cCombatMessage_BeginBehavior: // nothing to set up in our internal state return 0; - + case AI2cCombatMessage_PrimaryMovement: // move towards the target ioCombatState->maneuver.primary_movement_weights[AI2cPrimaryMovement_Advance] = 1.0f; @@ -2183,7 +2183,7 @@ static UUtUns32 AI2iBehavior_Melee(ONtCharacter *ioCharacter, AI2tCombatState *i case AI2cCombatMessage_BeginBehavior: // nothing to set up in our internal state return 0; - + case AI2cCombatMessage_PrimaryMovement: // go into melee ioCombatState->maneuver.primary_movement_weights[AI2cPrimaryMovement_Melee] = 1.0f; @@ -2224,7 +2224,7 @@ static UUtUns32 AI2iBehavior_RunForAlarm(ONtCharacter *ioCharacter, AI2tCombatSt ioCombatState->maneuver.primary_movement_weights[AI2cPrimaryMovement_FindAlarm] = 1.2f; } - if ((ioCombatState->behavior_state.alarm.tried_alarm) && + if ((ioCombatState->behavior_state.alarm.tried_alarm) && (inMsg != AI2cCombatMessage_BeginBehavior) && (inMsg != AI2cCombatMessage_EndBehavior)) { // we can't find an alarm - run our try to find gun behavior if ((ioCharacter->inventory.weapons[0] == NULL) || ONrCharacter_OutOfAmmo(ioCharacter)) { @@ -2236,7 +2236,7 @@ static UUtUns32 AI2iBehavior_RunForAlarm(ONtCharacter *ioCharacter, AI2tCombatSt case AI2cCombatMessage_BeginBehavior: ioCombatState->behavior_state.alarm.tried_alarm = UUcFalse; return 0; - + case AI2cCombatMessage_PrimaryMovement: // if we can't find an alarm, run away ioCombatState->maneuver.primary_movement_weights[AI2cPrimaryMovement_Retreat] = 0.8f; @@ -2429,7 +2429,7 @@ static UUtUns32 AI2iBehavior_Barabbas(ONtCharacter *ioCharacter, AI2tCombatState break; } return 0; - + case AI2cCombatMessage_PrimaryMovement: if (barabbas_state->disable_beam_timer > AI2cCombat_UpdateFrames) { barabbas_state->disable_beam_timer -= AI2cCombat_UpdateFrames; @@ -2665,7 +2665,7 @@ static UUtUns32 AI2iBehavior_BarabbasShoot(ONtCharacter *ioCharacter, AI2tCombat AI2rMovement_ChangeMovementMode(ioCharacter, AI2cMovementMode_Walk); } break; - + case AI2cCombatMessage_PrimaryMovement: if (ioCombatState->behavior_state.barabbas.disable_beam_timer) { ioCombatState->behavior_state.barabbas.barabbas_mode = AI2cBarabbas_WaitForWeapon; @@ -2708,7 +2708,7 @@ static UUtUns32 AI2iBehavior_BarabbasAdvance(ONtCharacter *ioCharacter, AI2tComb case AI2cCombatMessage_BeginBehavior: ioCombatState->behavior_state.barabbas.barabbas_mode = AI2cBarabbas_ShootBeam; break; - + case AI2cCombatMessage_PrimaryMovement: if (ioCombatState->behavior_state.barabbas.disable_beam_timer) { ioCombatState->behavior_state.barabbas.barabbas_mode = AI2cBarabbas_AdvanceGrenading; @@ -2749,7 +2749,7 @@ static UUtUns32 AI2iBehavior_BarabbasMelee(ONtCharacter *ioCharacter, AI2tCombat case AI2cCombatMessage_BeginBehavior: ioCombatState->behavior_state.barabbas.barabbas_mode = AI2cBarabbas_Melee; break; - + case AI2cCombatMessage_PrimaryMovement: if ((ioCharacter->inventory.weapons[0] != NULL) && (WPrIsFiring(ioCharacter->inventory.weapons[0]))) { // barabbas has to wait for his gun to finish firing @@ -2869,12 +2869,12 @@ static UUtBool AI2iBehavior_SuperNinjaCheckTeleportFlee(ONtCharacter *ioCharacte AI2tBehaviorState_SuperNinja *ioNinjaState) { // don't teleport while invisible - if (ioCharacter->inventory.invisibilityRemaining > 0) + if (ioCharacter->inventory.invisibilityRemaining > 0) return UUcFalse; if (ioNinjaState->flee_damage_taken < AI2cSuperNinja_FleeTeleportDamage) return UUcFalse; - + if (ioCombatState->distance_to_target >= AI2cSuperNinja_FleeTeleportRange) { return UUcFalse; } @@ -2888,12 +2888,12 @@ static UUtBool AI2iBehavior_SuperNinjaCheckTeleportAdvance(ONtCharacter *ioChara AI2tBehaviorState_SuperNinja *ioNinjaState) { // don't teleport while invisible - if (ioCharacter->inventory.invisibilityRemaining > 0) + if (ioCharacter->inventory.invisibilityRemaining > 0) return UUcFalse; if (ioNinjaState->superninja_mode != AI2cSuperNinja_Advance) return UUcFalse; - + if (ioCombatState->distance_to_target < AI2cSuperNinja_AdvanceTeleportRange) { #if AI_DEBUG_SUPERNINJA COrConsole_Printf("superninja advance: too close to teleport (%f < %f)", @@ -2944,7 +2944,7 @@ static UUtUns32 AI2iBehavior_SuperNinja(ONtCharacter *ioCharacter, AI2tCombatSta break; } return 0; - + case AI2cCombatMessage_PrimaryMovement: if (superninja_state->disable_fireball_timer > AI2cCombat_UpdateFrames) { superninja_state->disable_fireball_timer -= AI2cCombat_UpdateFrames; @@ -2972,13 +2972,13 @@ static UUtUns32 AI2iBehavior_SuperNinja(ONtCharacter *ioCharacter, AI2tCombatSta #if AI_DEBUG_SUPERNINJA COrConsole_Printf("superninja: flee damage staying at %d (%d more frames)", superninja_state->flee_damage_taken, superninja_state->flee_damagestay_timer); -#endif +#endif } else { if (superninja_state->flee_damage_taken > AI2cSuperNinja_DamageDecayAmount) { superninja_state->flee_damage_taken -= AI2cSuperNinja_DamageDecayAmount; #if AI_DEBUG_SUPERNINJA COrConsole_Printf("superninja: flee damage decays to %d", superninja_state->flee_damage_taken); -#endif +#endif } else { superninja_state->flee_damage_taken = 0; } @@ -2996,14 +2996,14 @@ static UUtUns32 AI2iBehavior_SuperNinja(ONtCharacter *ioCharacter, AI2tCombatSta superninja_state->superninja_mode = AI2cSuperNinja_TeleportFlee; #if AI_DEBUG_SUPERNINJA COrConsole_Printf("superninja: starting flee teleport"); -#endif +#endif } else if (AI2iBehavior_SuperNinjaCheckTeleportAdvance(ioCharacter, ioCombatState, superninja_state)) { // super ninja would rather close the distance to target by teleporting in superninja_state->superninja_mode = AI2cSuperNinja_TeleportAdvance; #if AI_DEBUG_SUPERNINJA COrConsole_Printf("superninja: starting close teleport"); -#endif +#endif } else if (AI2iBehavior_SuperNinjaCheckInvis(ioCharacter, ioCombatState, superninja_state)) { // super ninja wants to turn invisible @@ -3050,7 +3050,7 @@ static UUtUns32 AI2iBehavior_SuperNinja(ONtCharacter *ioCharacter, AI2tCombatSta superninja_state->superninja_mode = AI2cSuperNinja_Melee; #if AI_DEBUG_SUPERNINJA COrConsole_Printf("superninja: found no suitable points to teleport retreat to, aborting"); -#endif +#endif } break; @@ -3076,7 +3076,7 @@ static UUtUns32 AI2iBehavior_SuperNinja(ONtCharacter *ioCharacter, AI2tCombatSta superninja_state->superninja_mode = AI2cSuperNinja_Advance; #if AI_DEBUG_SUPERNINJA COrConsole_Printf("superninja: found no suitable points to teleport behind, aborting"); -#endif +#endif } break; } @@ -3094,7 +3094,7 @@ static UUtUns32 AI2iBehavior_SuperNinja(ONtCharacter *ioCharacter, AI2tCombatSta COrConsole_Printf("superninja: animtype %s curstate %s fromstate %s [queued %s] -> inactive and upright, do special move", ONrAnimTypeToString(active_character->curAnimType), ONrAnimStateToString(active_character->curFromState), ONrAnimStateToString(active_character->nextAnimState), ONrAnimTypeToString(active_character->nextAnimType)); -#endif +#endif // perform our fireball attack ONrCharacter_FightMode(ioCharacter); animation = ONrCharacter_DoAnimation(ioCharacter, active_character, ONcAnimPriority_Appropriate, ONcAnimType_Ninja_Fireball); @@ -3124,7 +3124,7 @@ static UUtUns32 AI2iBehavior_SuperNinja(ONtCharacter *ioCharacter, AI2tCombatSta COrConsole_Printf("superninja: animtype %s curstate %s fromstate %s [queued %s] -> inactive and upright, do special move", ONrAnimTypeToString(active_character->curAnimType), ONrAnimStateToString(active_character->curFromState), ONrAnimStateToString(active_character->nextAnimState), ONrAnimTypeToString(active_character->nextAnimType)); -#endif +#endif // perform our invisibility move ONrCharacter_FightMode(ioCharacter); animation = ONrCharacter_DoAnimation(ioCharacter, active_character, ONcAnimPriority_Appropriate, ONcAnimType_Ninja_Invisible); @@ -3155,7 +3155,7 @@ static UUtUns32 AI2iBehavior_SuperNinja(ONtCharacter *ioCharacter, AI2tCombatSta COrConsole_Printf("superninja: animtype %s curstate %s fromstate %s [queued %s] -> inactive and upright, do special move", ONrAnimTypeToString(active_character->curAnimType), ONrAnimStateToString(active_character->curFromState), ONrAnimStateToString(active_character->nextAnimState), ONrAnimTypeToString(active_character->nextAnimType)); -#endif +#endif // perform our teleport-in move ONrCharacter_FightMode(ioCharacter); animation = ONrCharacter_DoAnimation(ioCharacter, active_character, ONcAnimPriority_Appropriate, ONcAnimType_Teleport_In); @@ -3366,7 +3366,7 @@ static UUtUns32 AI2iBehavior_SuperNinjaFireball(ONtCharacter *ioCharacter, AI2tC case AI2cCombatMessage_BeginBehavior: ioCombatState->behavior_state.superNinja.superninja_mode = AI2cSuperNinja_Fireball; break; - + case AI2cCombatMessage_PrimaryMovement: if ((ioCombatState->behavior_state.superNinja.disable_fireball_timer == 0) && (ONrCharacter_IsInactiveUpright(ioCharacter))) { ioCombatState->behavior_state.superNinja.superninja_mode = AI2cSuperNinja_Fireball; @@ -3393,7 +3393,7 @@ static UUtUns32 AI2iBehavior_SuperNinjaAdvance(ONtCharacter *ioCharacter, AI2tCo case AI2cCombatMessage_BeginBehavior: ioCombatState->behavior_state.superNinja.superninja_mode = AI2cSuperNinja_Advance; break; - + case AI2cCombatMessage_PrimaryMovement: ioCombatState->behavior_state.superNinja.superninja_mode = AI2cSuperNinja_Advance; break; @@ -3416,7 +3416,7 @@ static UUtUns32 AI2iBehavior_SuperNinjaMelee(ONtCharacter *ioCharacter, AI2tComb case AI2cCombatMessage_BeginBehavior: ioCombatState->behavior_state.superNinja.superninja_mode = AI2cSuperNinja_Melee; break; - + case AI2cCombatMessage_PrimaryMovement: // FIXME: trigger off super ninja's damage taken field to see if we want to escape ioCombatState->behavior_state.superNinja.superninja_mode = AI2cSuperNinja_Melee; @@ -3433,7 +3433,7 @@ static UUtUns32 AI2iBehavior_SuperNinjaMelee(ONtCharacter *ioCharacter, AI2tComb // ------------------------------------------------------------------------------------ // -- mutant muro's special-case behavior functions -static void AI2iMutantMuro_DisableShield(AI2tBehaviorState_MutantMuro *ioMuroState, +static void AI2iMutantMuro_DisableShield(AI2tBehaviorState_MutantMuro *ioMuroState, UUtUns32 inDecayTime, UUtUns32 inDisableTime) { if ((ioMuroState->shield_disable_timer > 0) || (ioMuroState->shield_decay_timer > 0)) { @@ -3483,7 +3483,7 @@ static UUtUns32 AI2iBehavior_MutantMuro(ONtCharacter *ioCharacter, AI2tCombatSta break; } return 0; - + case AI2cCombatMessage_PrimaryMovement: // track muro's shield @@ -3624,7 +3624,7 @@ static UUtUns32 AI2iBehavior_MutantMuroZeus(ONtCharacter *ioCharacter, AI2tComba ioCombatState->maneuver.primary_movement_weights[AI2cPrimaryMovement_GetUp] = 1.0f; break; } - + lightning_enable = (ioCombatState->distance_to_target > AI2cMutantMuro_ZeusTargetDistance); lightning_enable = lightning_enable || (ioCombatState->have_los); @@ -3692,7 +3692,7 @@ static UUtUns32 AI2iBehavior_MutantMuroZeus(ONtCharacter *ioCharacter, AI2tComba COrConsole_Printf("mutantmuro: animtype %s curstate %s fromstate %s [queued %s] -> inactive and upright, do special move", ONrAnimTypeToString(active_character->curAnimType), ONrAnimStateToString(active_character->curFromState), ONrAnimStateToString(active_character->nextAnimState), ONrAnimTypeToString(active_character->nextAnimType)); -#endif +#endif ONrCharacter_FightMode(ioCharacter); animation = ONrCharacter_DoAnimation(ioCharacter, active_character, ONcAnimPriority_Appropriate, ONcAnimType_Muro_Thunderbolt); if (animation == NULL) { @@ -3807,9 +3807,9 @@ static UUtUns32 AI2iBehavior_MutantMuroMelee(ONtCharacter *ioCharacter, AI2tComb COrConsole_Printf("mutantmuro: animtype %s curstate %s fromstate %s [queued %s] -> inactive and upright, do special move", ONrAnimTypeToString(active_character->curAnimType), ONrAnimStateToString(active_character->curFromState), ONrAnimStateToString(active_character->nextAnimState), ONrAnimTypeToString(active_character->nextAnimType)); -#endif +#endif - // kill stun while trying to turtle + // kill stun while trying to turtle active_character->hitStun = 0; active_character->blockStun = 0; active_character->staggerStun = 0; @@ -4066,4 +4066,4 @@ void AI2rCombat_Report(ONtCharacter *ioCharacter, AI2tCombatState *ioCombatState if (inVerbose) { AI2rCombat_Behavior(ioCharacter, ioCombatState, AI2cCombatMessage_Report, &handled, 0, 0, 0); } -} +} diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Combat.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Combat.h index d4092aa..4da4192 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Combat.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Combat.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Combat.h - + AUTHOR: Chris Butcher - + CREATED: April 20, 2000 - + PURPOSE: Combat Manager for Oni AI system - + Copyright (c) 2000 */ @@ -270,7 +270,7 @@ typedef struct AI2tBehaviorState_SuperNinja { UUtBool fireball_started; UUtBool invis_started; UUtBool teleport_started; - + // medium-range controls UUtBool set_mediumrange_behavior; UUtBool mediumrange_enable_teleport; @@ -475,7 +475,7 @@ static UUcInline UUtUns32 AI2rCombat_Behavior(ONtCharacter *ioCharacter, struct { UUtUns32 returnval; AI2tBehaviorFunction function = ioCombatState->current_behavior.function; - + if (function == NULL) { *inHandled = UUcFalse; return 0; diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Error.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Error.c index baccd48..1405ae5 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Error.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Error.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Error.c - + AUTHOR: Chris Butcher - + CREATED: April 12, 2000 - + PURPOSE: Error handler for Oni's AI system - + Copyright (c) Bungie Software, 2000 */ @@ -409,7 +409,7 @@ UUtBool AI2rHandleError(AI2tErrorSubsystem inSystem, UUtUns32 inErrorID, ONtChar // try to handle using default error handler handled = AI2rError_DefaultPathfindingHandler(inCharacter, inErrorID, inParam1, inParam2, inParam3, inParam4); if (handled) - return UUcTrue; + return UUcTrue; } if (errorptr->handle_function) { @@ -579,7 +579,7 @@ void AI2rError_SetReportLevel(AI2tErrorSubsystem inSystem, AI2tErrorSeverity inR AI2_ERROR(AI2cBug, AI2cSubsystem_Error, AI2cError_Error_InvalidSubsystem, NULL, 0, 0, 0, 0); return; } - + if (inSystem == AI2cSubsystem_All) { for (itr = 0; itr < AI2cSubsystem_Max; itr++) { AI2gError_ReportLevel[itr] = inReportLevel; @@ -597,7 +597,7 @@ void AI2rError_SetLogLevel(AI2tErrorSubsystem inSystem, AI2tErrorSeverity inLogL AI2_ERROR(AI2cBug, AI2cSubsystem_Error, AI2cError_Error_InvalidSubsystem, NULL, 0, 0, 0, 0); return; } - + if (inSystem == AI2cSubsystem_All) { for (itr = 0; itr < AI2cSubsystem_Max; itr++) { AI2gError_LogLevel[itr] = inLogLevel; @@ -615,7 +615,7 @@ void AI2rError_SetSilentHandling(AI2tErrorSubsystem inSystem, UUtBool inSilentHa AI2_ERROR(AI2cBug, AI2cSubsystem_Error, AI2cError_Error_InvalidSubsystem, NULL, 0, 0, 0, 0); return; } - + if (inSystem == AI2cSubsystem_All) { for (itr = 0; itr < AI2cSubsystem_Max; itr++) { AI2gError_SilentHandling[itr] = inSilentHandling; @@ -948,14 +948,14 @@ static void AI2iReport_Patrol_AtWaypoint(ONtCharacter *inCharacter, break; case AI2cWaypointType_MoveToPoint: - sprintf(AI2gErrorBuf, " move to point (%f %f %f)", + sprintf(AI2gErrorBuf, " move to point (%f %f %f)", waypoint->data.moveToPoint.point.x, waypoint->data.moveToPoint.point.y, waypoint->data.moveToPoint.point.z); break; case AI2cWaypointType_MoveThroughFlag: - sprintf(AI2gErrorBuf, " move through flag %d (dist %f)", + sprintf(AI2gErrorBuf, " move through flag %d (dist %f)", waypoint->data.moveThroughFlag.flag, waypoint->data.moveThroughFlag.required_distance); break; @@ -1255,10 +1255,10 @@ static void AI2iReport_Melee_PreComputeBroken(ONtCharacter *inCharacter, if (itr >= profile->num_actions + profile->num_reactions) { sprintf(techniquebuf, "", move_index); } else if (itr >= profile->num_actions) { - sprintf(techniquebuf, "technique reaction %d(%s) move %d", + sprintf(techniquebuf, "technique reaction %d(%s) move %d", itr - profile->num_actions, technique->name, move_index - technique->start_index); } else { - sprintf(techniquebuf, "technique action %d(%s) move %d", + sprintf(techniquebuf, "technique action %d(%s) move %d", itr, technique->name, move_index - technique->start_index); } } @@ -1476,14 +1476,14 @@ UUtBool AI2rError_DefaultPathfindingHandler(ONtCharacter *inCharacter, UUtUns32 } } break; - + case AI2cError_Pathfinding_AStarFailed: AI2gPathfindingErrorStorage.no_astar = UUcTrue; AI2gPathfindingErrorStorage.astar_start = *((M3tPoint3D *) inParam1); AI2gPathfindingErrorStorage.astar_end = *((M3tPoint3D *) inParam2); AI2gPathfindingErrorStorage.astar_room = (PHtRoomData *) inParam3; AI2gPathfindingErrorStorage.astar_node = (PHtNode *) inParam4; - + ASrGetLocalStart(&AI2gPathfindingErrorStorage.astar_gridstart); ASrGetLocalEnd(&AI2gPathfindingErrorStorage.astar_gridend); break; diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Error.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Error.h index 093725f..8c9518a 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Error.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Error.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Error.h - + AUTHOR: Chris Butcher - + CREATED: April 12, 1999 - + PURPOSE: Error handler for Oni's AI system - + Copyright (c) 2000, Bungie Software */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Executor.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Executor.c index baec36f..feeac8e 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Executor.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Executor.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Executor.c - + AUTHOR: Michael Evans, Chris Butcher - + CREATED: November 15, 1999 - + PURPOSE: Low Level AI for Oni - + Copyright (c) 1999 */ @@ -182,10 +182,10 @@ void AI2rExecutor_Update(ONtCharacter *ioCharacter) facing_goal += ioCharacter->facingModifier; UUmTrig_Clip(facing_goal); - + delta_facing_goal = facing_goal - ioCharacter->facing; UUmTrig_Clip(delta_facing_goal); - + max_turn = AI2rExecutor_GetMaxDeltaFacingPerFrame(ioCharacter->characterClass, current_movement_mode, executor->turn_danger); if (executor->turn_override) { #if AI2_ERROR_REPORT @@ -197,10 +197,10 @@ void AI2rExecutor_Update(ONtCharacter *ioCharacter) max_turn = executor->turn_override; executor->turn_override = 0.0f; } - + delta_facing_goal = (delta_facing_goal > M3cPi) ? (delta_facing_goal - M3c2Pi) : delta_facing_goal; delta_facing_goal = UUmPin(delta_facing_goal, -max_turn, max_turn); - + active_character->pleaseTurnLeft = active_character->pleaseTurnRight = UUcFalse; if (delta_facing_goal < -0.001f) { active_character->pleaseTurnLeft = UUcTrue; @@ -212,11 +212,11 @@ void AI2rExecutor_Update(ONtCharacter *ioCharacter) // we're at our desired facing, just face forward from now on AI2rMovement_FreeFacing(ioCharacter); } - + new_facing = delta_facing_goal + ioCharacter->facing; UUmTrig_Clip(new_facing); - - ONrCharacter_SetFacing(ioCharacter, new_facing); + + ONrCharacter_SetFacing(ioCharacter, new_facing); } // movement and facing overrides persist for only a single tick @@ -237,7 +237,7 @@ void AI2rExecutor_Update(ONtCharacter *ioCharacter) if (executor->attack_override_requiredcombotype == ONcAnimType_None) { active_character->lastAttack = ONcAnimType_None; } - + input.buttonIsDown |= executor->attack_override_keys_isdown; input.buttonWentDown |= executor->attack_override_keys_wentdown; } @@ -692,7 +692,7 @@ void AI2rExecutor_UpdateAim(ONtCharacter *ioCharacter) desired_aiming_vector.x = aim_length * MUrSin(desired_theta) * cos_phi; desired_aiming_vector.y = aim_length * MUrSin(desired_phi); desired_aiming_vector.z = aim_length * MUrCos(desired_theta) * cos_phi; - + // set the character's aiming vector MUmVector_Add(active_character->aimingTarget, desired_aiming_vector, charfrom_vector); active_character->isAiming = UUcTrue; diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Executor.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Executor.h index 3457b2d..c30ebfd 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Executor.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Executor.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Executor.h - + AUTHOR: Michael Evans, Chris Butcher - + CREATED: November 15, 1999 - + PURPOSE: Low Level AI for Oni - + Copyright (c) 1999 */ @@ -105,4 +105,4 @@ static void UUcInline AI2rExecutor_Stop(ONtCharacter *ioCharacter, float inFacin // report in void AI2rExecutor_Report(ONtCharacter *ioCharacter, UUtBool inVerbose, AI2tReportFunction inFunction); -#endif // ONI_AI2_EXECUTOR_H \ No newline at end of file +#endif // ONI_AI2_EXECUTOR_H diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Fight.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Fight.c index 79bc79c..b8c8153 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Fight.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Fight.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Fight.c - + AUTHOR: Chris Butcher - + CREATED: September 17, 2000 - + PURPOSE: Fight AI for Oni - + Copyright (c) 2000 */ @@ -241,7 +241,7 @@ static UUtBool AI2iFight_DiscardAttackCookie(AI2tFightState *ioFightState, AI2tF { if (!ioFightInfo->has_attack_cookie) return UUcFalse; - + ioFightInfo->has_attack_cookie = UUcFalse; UUmAssert(ioFightState->num_attack_cookies > 0); diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Fight.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Fight.h index c37e504..10ba40a 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Fight.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Fight.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Fight.h - + AUTHOR: Chris Butcher - + CREATED: September 17, 2000 - + PURPOSE: Fight AI for Oni - + Copyright (c) 2000 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Guard.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Guard.c index 26d75d3..6ef701f 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Guard.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Guard.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Guard.c - + AUTHOR: Chris Butcher - + CREATED: June 22, 2000 - + PURPOSE: Guard AI for Oni - + Copyright (c) 2000 */ @@ -95,13 +95,13 @@ void AI2rGuard_NewDirection(ONtCharacter *ioCharacter, AI2tGuardDirState *ioDirS continue; } } - + // form this look vector UUmTrig_Clip(try_direction); MUmVector_Set(ioDirState->cur_direction, AI2cGuard_ClearDistance * MUrSin(try_direction), 0, AI2cGuard_ClearDistance * MUrCos(try_direction)); - if ((attempts >= AI2cGuard_MaxClearAttempts) || + if ((attempts >= AI2cGuard_MaxClearAttempts) || (!AKrCollision_Point(environment, &eye_point, &ioDirState->cur_direction, AKcGQ_Flag_LOS_CanSee_Skip_AI, 0))) { // return this direction ioDirState->has_cur_direction = UUcTrue; @@ -181,7 +181,7 @@ void AI2rGuard_RecalcScanDir(ONtCharacter *ioCharacter, AI2tScanState *ioScanSta theta += ioScanState->cur_angle; UUmTrig_Clip(theta); - + ioScanState->facing_vector.x = horiz_dist * MUrSin(theta); ioScanState->facing_vector.z = horiz_dist * MUrCos(theta); ioScanState->facing_vector.y = ioScanState->dir_state.cur_direction.y; diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Guard.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Guard.h index 32b74b4..dbd2046 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Guard.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Guard.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Guard.h - + AUTHOR: Chris Butcher - + CREATED: June 22, 2000 - + PURPOSE: Guard AI for Oni - + Copyright (c) 2000 */ @@ -70,4 +70,4 @@ void AI2rGuard_UpdateScan(ONtCharacter *ioCharacter, AI2tScanState *ioScanState) void AI2rGuard_RecalcScanDir(ONtCharacter *ioCharacter, AI2tScanState *ioScanState); -#endif // ONI_AI2_GUARD_H \ No newline at end of file +#endif // ONI_AI2_GUARD_H diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Idle.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Idle.c index d6f0e82..d040b44 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Idle.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Idle.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Idle.c - + AUTHOR: Chris Butcher - + CREATED: April 27, 2000 - + PURPOSE: Idle AI for Oni - + Copyright (c) 2000 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Idle.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Idle.h index d51bbf7..b9441fd 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Idle.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Idle.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Idle.h - + AUTHOR: Chris Butcher - + CREATED: April 27, 2000 - + PURPOSE: Idle AI for Oni - + Copyright (c) 2000 */ @@ -33,4 +33,4 @@ void AI2rIdle_Enter(ONtCharacter *ioCharacter); void AI2rIdle_Exit(ONtCharacter *ioCharacter); void AI2rIdle_Update(ONtCharacter *ioCharacter); -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Knowledge.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Knowledge.c index 3ea3835..50a5670 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Knowledge.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Knowledge.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Knowledge.c - + AUTHOR: Chris Butcher - + CREATED: April 18, 2000 - + PURPOSE: Knowledge base for Oni AI - + Copyright (c) 2000 */ @@ -123,11 +123,11 @@ const IMtShade AI2gKnowledge_DebugSoundShade[AI2cContactType_Max] = {IMcShade_Bl static void AI2iKnowledge_AddPending(void); static void AI2iKnowledge_PostContact(ONtCharacter *inCharacter, AI2tContactType inType, AI2tContactStrength inStrength, M3tPoint3D *inLocation, - ONtCharacter *inTarget, UUtUns32 inAIUserData, + ONtCharacter *inTarget, UUtUns32 inAIUserData, UUtBool inDisableNotify, UUtBool inForceTarget); static void AI2iKnowledge_AddContact(ONtCharacter *inCharacter, AI2tContactType inType, AI2tContactStrength inStrength, M3tPoint3D *inLocation, - ONtCharacter *inTarget, UUtUns32 inAIUserData, + ONtCharacter *inTarget, UUtUns32 inAIUserData, UUtBool inDisableNotify, UUtBool inForceTarget); static void AI2iKnowledge_CheckVisible(ONtCharacter *inCharacter, ONtActiveCharacter *inActiveCharacter, UUtUns32 inCheckCount, ONtCharacter **inCheckList); @@ -215,7 +215,7 @@ void AI2rKnowledge_Update(void) for (itr = 0, entry = AI2gKnowledgeBase; itr < AI2gKnowledge_ClearSpaceIndex; itr++, entry++) { if (entry->owner == NULL) // skip unused entries continue; - + if (entry->strength <= AI2cContactStrength_Forgotten) continue; @@ -230,7 +230,7 @@ void AI2rKnowledge_Update(void) degrade_hostility = degrade_forget = degrade_dead = UUcFalse; - if ((entry->enemy != NULL) && + if ((entry->enemy != NULL) && (((entry->enemy->flags & ONcCharacterFlag_InUse) == 0) || (entry->enemy->flags & ONcCharacterFlag_Dead))) { // target has died @@ -273,7 +273,7 @@ void AI2rKnowledge_Update(void) // sort this entry to where it belongs in the contact list AI2iKnowledge_MoveContactDown(entry->owner, knowledge_state, entry); - + if (knowledge_state->callback != NULL) { (knowledge_state->callback)(entry->owner, entry, UUcTrue); } @@ -288,17 +288,17 @@ void AI2rKnowledge_Update(void) // loop over all AIs character_list = ONrGameState_LivingCharacterList_Get(); character_list_count = ONrGameState_LivingCharacterList_Count(); - + // only check roughly every second check_index = current_time % AI2cKnowledge_VisibilityFrames; - + for (itr = 0; itr < character_list_count; itr++) { looking_character = character_list[itr]; if (((looking_character->flags & ONcCharacterFlag_InUse) == 0) || (looking_character->flags & ONcCharacterFlag_Dead) || (looking_character->charType != ONcChar_AI2)) continue; - + if ((looking_character->ai2State.flags & AI2cFlag_Passive) || (looking_character->ai2State.flags & AI2cFlag_Blind)) continue; @@ -307,7 +307,7 @@ void AI2rKnowledge_Update(void) // FIXME: would it be more efficient to maintain character lists for // each team and loop over only the relevant ones? - + run_vision = UUcFalse; // respect the delay timer (used so that AIs which are looking towards the source of a sound @@ -376,7 +376,7 @@ void AI2rKnowledge_Update(void) // every so often character_list = ONrGameState_LivingCharacterList_Get(); character_list_count = ONrGameState_LivingCharacterList_Count(); - + for (itr = 0; itr < character_list_count; itr++) { update_character = character_list[itr]; if (((looking_character->flags & ONcCharacterFlag_InUse) == 0) || @@ -450,7 +450,7 @@ void AI2rKnowledge_CharacterDeath(ONtCharacter *inDeadCharacter) for (itr = 0, entry = AI2gKnowledgeBase; itr < AI2gKnowledge_ClearSpaceIndex; itr++, entry++) { if (entry->owner == NULL) // skip unused entries continue; - + if (entry->enemy != inDeadCharacter) continue; @@ -477,7 +477,7 @@ void AI2rKnowledge_CharacterDeath(ONtCharacter *inDeadCharacter) // sort this entry to where it belongs in the contact list AI2iKnowledge_MoveContactDown(entry->owner, knowledge_state, entry); - + if (knowledge_state->callback != NULL) { (knowledge_state->callback)(entry->owner, entry, UUcTrue); } @@ -546,7 +546,7 @@ void AI2rKnowledge_Sound(AI2tContactType inImportance, M3tPoint3D *inLocation, f if (AI2gShowSounds && (AI2gKnowledge_DebugNumSounds < AI2cKnowledge_DebugMaxNumSounds)) { // add this sound to the global sound debugging buffer AI2tKnowledgeDebugSound *sound = &AI2gKnowledge_DebugSounds[AI2gKnowledge_DebugNumSounds++]; - + sound->location = *inLocation; sound->radius = inVolume; sound->time = ONrGameState_GetGameTime(); @@ -928,7 +928,7 @@ static void AI2iKnowledge_CheckVisible(ONtCharacter *inCharacter, ONtActiveChara contact_strength = AI2cContactStrength_Definite; } } else { - + // what viewing distance and centrality does this translate to? if (aimrel_along < periph_max) { // not visible @@ -1050,7 +1050,7 @@ static void AI2iKnowledge_CheckVisible(ONtCharacter *inCharacter, ONtActiveChara // new knowledge has been received static void AI2iKnowledge_PostContact(ONtCharacter *inCharacter, AI2tContactType inType, AI2tContactStrength inStrength, M3tPoint3D *inLocation, - ONtCharacter *inTarget, UUtUns32 inAIUserData, + ONtCharacter *inTarget, UUtUns32 inAIUserData, UUtBool inDisableNotify, UUtBool inForceTarget) { AI2tKnowledgePending *pending; @@ -1150,10 +1150,10 @@ static void AI2iKnowledge_AddContact(ONtCharacter *inCharacter, AI2tContactType // we can't respond to this return; } - + entry->owner = inCharacter; entry->enemy = inTarget; - + // by default all contacts are just interesting information, not a threat entry->priority = AI2cContactPriority_Friendly; if (entry->enemy != NULL) { @@ -1164,7 +1164,7 @@ static void AI2iKnowledge_AddContact(ONtCharacter *inCharacter, AI2tContactType entry->priority = AI2cContactPriority_Hostile_NoThreat; } } - + entry->first_time = current_time; entry->highest_strength = AI2cContactStrength_Forgotten; entry->has_hurt_me = UUcFalse; @@ -1178,7 +1178,7 @@ static void AI2iKnowledge_AddContact(ONtCharacter *inCharacter, AI2tContactType entry->last_type = AI2cContactType_Sound_Ignore; entry->last_strength = AI2cContactStrength_Forgotten; } - + if (inForceTarget) { entry->priority = AI2cContactPriority_ForceTarget; } @@ -1202,7 +1202,7 @@ static void AI2iKnowledge_AddContact(ONtCharacter *inCharacter, AI2tContactType entry->last_location = *inLocation; entry->last_type = inType; entry->last_user_data = inAIUserData; - + // update the strength of our contact with this character if (inStrength > entry->highest_strength) { entry->highest_strength = inStrength; @@ -1210,12 +1210,12 @@ static void AI2iKnowledge_AddContact(ONtCharacter *inCharacter, AI2tContactType } else { entry->first_sighting = UUcFalse; } - + if (inStrength >= entry->strength) { entry->strength = inStrength; entry->degrade_time = current_time + AI2iKnowledge_GetDegradeTime(entry->owner, entry->strength, entry->highest_strength); } - + if ((inType == AI2cContactType_Hit_Weapon) || (inType == AI2cContactType_Hit_Melee)) { // user data for hurt events is the amount of damage taken entry->has_hurt_me = UUcTrue; @@ -1258,12 +1258,12 @@ static void AI2iKnowledge_AddContact(ONtCharacter *inCharacter, AI2tContactType } else if ((inType == AI2cContactType_Sound_Melee) || (inType == AI2cContactType_Sound_Gunshot)) { // determine whether someone is attacking or shooting a friend of ours ONtCharacter *target_character = (ONtCharacter *) inAIUserData; - + if ((entry->enemy != NULL) && (target_character != NULL)) { UUtUns32 enemy_status = AI2rTeam_FriendOrFoe(inCharacter->teamNumber, entry->enemy->teamNumber); UUtUns32 target_status = AI2rTeam_FriendOrFoe(inCharacter->teamNumber, target_character->teamNumber); - if ((entry->priority == AI2cContactPriority_Friendly) && (entry->strength == AI2cContactStrength_Definite) && + if ((entry->priority == AI2cContactPriority_Friendly) && (entry->strength == AI2cContactStrength_Definite) && (enemy_status == AI2cTeam_Neutral) && (target_status == AI2cTeam_Friend)) { // a character that we are neutral towards is attacking a friend of ours, and we saw it. if our friend considers // this a hostile attack, so will we. @@ -1297,7 +1297,7 @@ static void AI2iKnowledge_AddContact(ONtCharacter *inCharacter, AI2tContactType // sort this entry to where it belongs in the contact list AI2iKnowledge_MoveContactUp(inCharacter, knowledge_state, entry); - + entry->last_notify_time = current_time; if (!inDisableNotify && (knowledge_state->callback != NULL)) { (knowledge_state->callback)(inCharacter, entry, UUcFalse); @@ -1360,7 +1360,7 @@ static AI2tKnowledgeEntry *AI2iKnowledge_NewEntry(ONtCharacter *inOwner, AI2tKno } entry = AI2gKnowledge_NextFreeEntry; - + #if defined(DEBUGGING) && DEBUGGING UUmAssertReadPtr(entry, sizeof(AI2tKnowledgeEntry)); UUmAssert(entry >= AI2gKnowledgeBase); @@ -1400,7 +1400,7 @@ static void AI2iKnowledge_RemoveEntry(AI2tKnowledgeEntry *ioEntry, UUtBool inRem UUmAssertReadPtr(ioEntry, sizeof(AI2tKnowledgeEntry)); UUmAssert(ioEntry->owner != NULL); - + if ((ioEntry->owner->flags & ONcCharacterFlag_InUse) && (ioEntry->owner->charType == ONcChar_AI2)) { @@ -1543,7 +1543,7 @@ UUtInt32 AI2rKnowledge_CompareFunc(AI2tKnowledgeEntry *inEntry1, AI2tKnowledgeEn return -1; else if (inEntry1->priority < inEntry2->priority) return +1; - + if (inHostileCheck != NULL) { // potentially hostile takes precedence over not potentially hostile hostile1 = (inEntry1->enemy != NULL) && AI2rCharacter_PotentiallyHostile(inEntry1->enemy, inHostileCheck, UUcTrue); @@ -1651,7 +1651,7 @@ static UUtUns32 AI2iKnowledge_GetDegradeTime(ONtCharacter *inCharacter, AI2tCont const ONtMemoryConstants *memory = &inCharacter->characterClass->memory; UUtUns32 degrade_time; - switch(inStrength) + switch(inStrength) { case AI2cContactStrength_Dead: case AI2cContactStrength_Forgotten: @@ -1683,7 +1683,7 @@ static UUtBool AI2iIgnoreEvents(ONtCharacter *inUpdatingCharacter, ONtCharacter { if (AI2gEveryonePassive || (inUpdatingCharacter->ai2State.flags & AI2cFlag_Passive)) return UUcTrue; - + if (inUpdatingCharacter == inCause) return UUcTrue; @@ -1823,7 +1823,7 @@ void AI2iKnowledge_UpdateDodgeProjectile(AI2tDodgeProjectile *ioProjectile) { M3tVector3D *velocity; - UUmAssert((ioProjectile >= &AI2gKnowledge_DodgeProjectile[0]) && + UUmAssert((ioProjectile >= &AI2gKnowledge_DodgeProjectile[0]) && (ioProjectile < &AI2gKnowledge_DodgeProjectile[AI2gKnowledge_NumDodgeProjectiles])); UUmAssert(ioProjectile->flags & AI2cDodgeProjectileFlag_InUse); @@ -1912,7 +1912,7 @@ void AI2rKnowledge_FindNearbyProjectiles(ONtCharacter *ioCharacter, AI2tManeuver // next AI2cProjectile_DodgeTrajectoryFrames MUmVector_Subtract(projectile_start, projectile->position, pelvis_pt); MUmVector_ScaleCopy(projectile_vel, ((float) AI2cProjectile_DodgeTrajectoryFrames) / UUcFramesPerSecond, projectile->velocity); - + r = active_character->boundingSphere.radius + projectile->dodge_radius; a = MUmVector_GetLengthSquared(projectile_vel); b = 2 * MUrVector_DotProduct(&projectile_start, &projectile_vel); @@ -2048,7 +2048,7 @@ static void AI2iKnowledge_UpdateDodgeFiringSpread(AI2tDodgeFiringSpread *ioSprea WPtWeaponClass *weapon_class; M3tMatrix4x3 *matrix; - UUmAssert((ioSpread >= &AI2gKnowledge_DodgeFiringSpread[0]) && + UUmAssert((ioSpread >= &AI2gKnowledge_DodgeFiringSpread[0]) && (ioSpread < &AI2gKnowledge_DodgeFiringSpread[AI2gKnowledge_NumDodgeFiringSpreads])); UUmAssert(ioSpread->flags & AI2cDodgeFiringSpreadFlag_InUse); @@ -2173,14 +2173,14 @@ static void AI2iKnowledge_UpdateProjectileAlertness(void) // this projectile alerts nearby AIs... precalculate constants for its motion this frame MUmVector_Subtract(projectile_vel, projectile->position, projectile->prev_position); a = MUmVector_GetLengthSquared(projectile_vel); - + for (itr2 = 0; itr2 < character_list_count; itr2++) { character = character_list[itr2]; if (((character->flags & ONcCharacterFlag_InUse) == 0) || (character->flags & ONcCharacterFlag_Dead) || (character->charType != ONcChar_AI2)) continue; - + if (character->ai2State.flags & (AI2cFlag_Passive | AI2cFlag_Deaf)) continue; @@ -2192,7 +2192,7 @@ static void AI2iKnowledge_UpdateProjectileAlertness(void) // calculate the projectile's location relative to us and the remaining terms of // the quadratic equation for the intersection of its alertness sphere with our location ONrCharacter_GetPelvisPosition(character, &pelvis_pt); - MUmVector_Subtract(projectile_start, projectile->prev_position, pelvis_pt); + MUmVector_Subtract(projectile_start, projectile->prev_position, pelvis_pt); b = 2 * MUrVector_DotProduct(&projectile_start, &projectile_vel); c = MUmVector_GetLengthSquared(projectile_start) - UUmSQR(projectile->alert_radius); @@ -2360,7 +2360,7 @@ void AI2rKnowledgeState_Report(ONtCharacter *ioCharacter, AI2tKnowledgeState *io if (inVerbose) { inFunction(longbuf); } - + entry = ioKnowledgeState->contacts; while (entry != NULL) { UUmAssert(entry->owner == ioCharacter); @@ -2388,7 +2388,7 @@ void AI2rKnowledgeState_Report(ONtCharacter *ioCharacter, AI2tKnowledgeState *io } else { strcat(reportbuf, AI2cContactStrengthName[entry->highest_strength]); } - + strcat(reportbuf, ")"); } @@ -2549,4 +2549,4 @@ void AI2rKnowledge_DisplaySounds(void) itr++; } #endif -} \ No newline at end of file +} diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Knowledge.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Knowledge.h index 06cd389..a9c84ad 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Knowledge.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Knowledge.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Knowledge.h - + AUTHOR: Chris Butcher - + CREATED: April 17, 2000 - + PURPOSE: Knowledge base for Oni AI - + Copyright (c) 2000 */ @@ -272,4 +272,4 @@ void AI2rKnowledge_Verify(void); #define AI2rKnowledge_Verify() #endif -#endif // ONI_AI2_KNOWLEDGE_H \ No newline at end of file +#endif // ONI_AI2_KNOWLEDGE_H diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_LocalPath.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_LocalPath.c index fb53c74..391e25a 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_LocalPath.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_LocalPath.c @@ -1,10 +1,10 @@ /* FILE: Oni_AI2_LocalPath.c - + AUTHOR: Chris Butcher - + CREATED: May 08, 1999 - + PURPOSE: Local-grid pathfinding for Oni AI Copyright (c) 2000 @@ -215,7 +215,7 @@ UUtError AI2rFindNearbyPoint(ONtCharacter *ioCharacter, PHtPathMode inPathMode, MUmVector_Set(AI2gLocalPath.end_point, MUrSin(current_direction), 0, MUrCos(current_direction)); MUmVector_Scale(AI2gLocalPath.end_point, inDistance); MUmVector_Add(AI2gLocalPath.end_point, AI2gLocalPath.end_point, AI2gLocalPath.start_point); - + // try the local path in this direction AI2gLocalPath.nodes_crossed = 0; cur_path_ok = AI2rDoLocalMovement(&cur_weight, &cur_escape_path, &cur_stop_point); @@ -228,7 +228,7 @@ UUtError AI2rFindNearbyPoint(ONtCharacter *ioCharacter, PHtPathMode inPathMode, *outSuccess = UUcTrue; return UUcError_None; } - + cur_distsq = MUmVector_GetDistanceSquared(cur_stop_point, AI2gLocalPath.start_point); if (!found || (cur_distsq > found_distsq)) { // this path is longer than our current best one. store its values. @@ -347,7 +347,7 @@ UUtError AI2rFindLocalPath(ONtCharacter *ioCharacter, PHtPathMode inPathMode, M3 MUmVector_Set(AI2gLocalPath.end_point, MUrSin(current_direction), 0, MUrCos(current_direction)); MUmVector_Scale(AI2gLocalPath.end_point, inDistance); MUmVector_Add(AI2gLocalPath.end_point, AI2gLocalPath.end_point, AI2gLocalPath.start_point); - + // try the local path in this direction AI2gLocalPath.nodes_crossed = 0; path_ok = AI2rDoLocalMovement(&found_weight, &escape_path, &stop_point); diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_LocalPath.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_LocalPath.h index 838033f..d0ff7d9 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_LocalPath.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_LocalPath.h @@ -4,11 +4,11 @@ /* FILE: Oni_AI2_LocalPath.h - + AUTHOR: Chris Butcher - + CREATED: May 08, 1999 - + PURPOSE: Local-grid pathfinding for Oni AI Copyright (c) 2000 diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Maneuver.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Maneuver.c index 91ce9d7..25287a5 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Maneuver.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Maneuver.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Maneuver.c - + AUTHOR: Chris Butcher - + CREATED: April 20, 1999 - + PURPOSE: Maneuvering code for Oni AI system - + Copyright (c) 2000 */ @@ -183,7 +183,7 @@ void AI2rManeuver_DecidePrimaryMovement(ONtCharacter *ioCharacter, AI2tCombatSta // we can get stuck in an infinite loop here UUmAssert((ioCombatState->maneuver.primary_movement_weights[best_choice] < second_weight) || (second_weight == 0)); } - + // otherwise keep looking } while (1); @@ -244,7 +244,7 @@ static UUtBool AI2iManeuver_CheckAdvance(ONtCharacter *ioCharacter, AI2tCombatSt // we are trying to avoid hazards at the moment, don't advance into them delta_dir = move_direction - ioManeuverState->dodge_avoid_angle; UUmTrig_ClipAbsPi(delta_dir); - + if ((float)fabs(delta_dir) < AI2cManeuver_Advance_AvoidAngle) { // we can't advance, because we're avoiding a hazard nearby ioManeuverState->primary_movement_weights[AI2cPrimaryMovement_Advance] = 0.0f; @@ -336,7 +336,7 @@ static UUtBool AI2iManeuver_CheckAdvance(ONtCharacter *ioCharacter, AI2tCombatSt AI2rPath_Halt(ioCharacter); ioManeuverState->primary_movement_weights[AI2cPrimaryMovement_Advance] = 0.0f; return UUcFalse; - } + } // we must always have at least some urgency if we're trying to move ioManeuverState->primary_movement_weights[AI2cPrimaryMovement_Advance] *= UUmMax(urgency, 0.5f); @@ -602,7 +602,7 @@ static UUtBool AI2iManeuver_CheckGun(ONtCharacter *ioCharacter, AI2tCombatState AI2rPath_Halt(ioCharacter); weapon_class = WPrGetClass(ioManeuverState->gun_target); - found_animation = ONrCharacter_DoAnimation(ioCharacter, active_character, ONcAnimPriority_Appropriate, + found_animation = ONrCharacter_DoAnimation(ioCharacter, active_character, ONcAnimPriority_Appropriate, (weapon_class->flags & WPcWeaponClassFlag_TwoHanded) ? ONcAnimType_Pickup_Rifle : ONcAnimType_Pickup_Pistol); if (found_animation) { @@ -615,7 +615,7 @@ static UUtBool AI2iManeuver_CheckGun(ONtCharacter *ioCharacter, AI2tCombatState } } } - + // continue performing the movement return UUcTrue; } else { @@ -659,7 +659,7 @@ static UUtBool AI2iManeuver_CheckGun(ONtCharacter *ioCharacter, AI2tCombatState } thwarted = UUcTrue; } - + // check to see if we should abort our action if (thwarted) { // try to find this gun in our existing thwarted array @@ -686,7 +686,7 @@ static UUtBool AI2iManeuver_CheckGun(ONtCharacter *ioCharacter, AI2tCombatState ioManeuverState->gun_target = NULL; return UUcFalse; } - + distance = ioManeuverState->gun_search_maxradius; path_to_gun = AI2iManeuver_TryPathToGun(ioCharacter, ioManeuverState, inWeightToBeat, &destination, &distance); if (path_to_gun) { @@ -771,7 +771,7 @@ static UUtBool AI2iManeuver_CheckGun(ONtCharacter *ioCharacter, AI2tCombatState ioManeuverState->gun_target = weapon; } } - + if (ioManeuverState->gun_target == NULL) { // no weapons are available nearby that we can pathfind to. give up. ioManeuverState->primary_movement_weights[AI2cPrimaryMovement_Gun] = 0.0f; @@ -882,7 +882,7 @@ static UUtBool AI2iManeuver_PathfindAndCheckViability(ONtCharacter *ioCharacter, // so that we will get up rather than lying on the ground aiming! AI2rExecutor_MoveOverride(ioCharacter, LIc_BitMask_Forward); return UUcTrue; - + } else { // we will get up because we are already running some kind of get-up animation. maneuver_state->primary_movement_weights[AI2cPrimaryMovement_GetUp] = 0.0f; @@ -942,7 +942,7 @@ UUtBool AI2rManeuver_CheckBlockage(ONtCharacter *ioCharacter, M3tPoint3D *inTarg if (AKrCollision_Point(environment, &ray_from, &ray_dir, AKcGQ_Flag_Chr_Col_Skip, 0)) { return UUcTrue; } - + // we must normalize the ray's direction in order to use AMrRayToObject test_dist = MUmVector_GetLength(ray_dir); if (test_dist > 1e-03f) { @@ -999,7 +999,7 @@ UUtBool AI2rManeuver_CheckInterveningCharacters(ONtCharacter *ioCharacter, M3tPo return UUcFalse; } -// try colliding with a spheretree against the environment +// try colliding with a spheretree against the environment UUtBool AI2rManeuver_TrySphereTreeCollision(PHtSphereTree *inSphereTree, M3tVector3D *inMovementVector) { AKtEnvironment *environment = ONrGameState_GetEnvironment(); @@ -1017,7 +1017,7 @@ UUtBool AI2rManeuver_TrySphereTreeCollision(PHtSphereTree *inSphereTree, M3tVect M3tVector3D to_plane_vec, endpoint; M3tPoint3D collision_point; M3tPlaneEquation plane; - + AKmPlaneEqu_GetComponents( gqCollision->planeEquIndex, environment->planeArray->planes, @@ -1066,7 +1066,7 @@ UUtBool AI2rManeuver_TrySphereTreeCollision(PHtSphereTree *inSphereTree, M3tVect // this is a valid wall collision return UUcTrue; } - + return UUcFalse; } @@ -1248,7 +1248,7 @@ UUtBool AI2rManeuver_TryRunningGunPickup(ONtCharacter *ioCharacter, AI2tCombatSt // check we aren't so close that we would miss the gun if we did an escape move if (gun_dist_sq < UUmSQR(AI2cManeuver_GunMinRunningPickupRange)) { #if DEBUG_GUN_PICKUP - COrConsole_Printf("%s: guncheck is too close (%f < min %f)", + COrConsole_Printf("%s: guncheck is too close (%f < min %f)", ioCharacter->player_name, MUrSqrt(gun_dist_sq), ONcPickupRadius); #endif return UUcFalse; @@ -1291,7 +1291,7 @@ UUtBool AI2rManeuver_TryRunningGunPickup(ONtCharacter *ioCharacter, AI2tCombatSt } // how far away is this endpoint along the gun angle? - endpoint_dist = MUrSin(gun_angle) * (endpoint.x - ioCharacter->actual_position.x) + + endpoint_dist = MUrSin(gun_angle) * (endpoint.x - ioCharacter->actual_position.x) + MUrCos(gun_angle) * (endpoint.z - ioCharacter->actual_position.z); if (endpoint_dist < MUrSqrt(gun_dist_sq) + AI2cManeuver_GunRunningPickupOvershootRange) { // this escape move doesn't bring us close enough to the gun, but it will in the future @@ -1408,7 +1408,7 @@ void AI2rManeuver_ApplyDodge(ONtCharacter *ioCharacter, AI2tCombatState *ioComba return; } - error = AI2rFindLocalPath(ioCharacter, PHcPathMode_CasualMovement, NULL, NULL, NULL, AI2cDodge_LocalPathDistance, + error = AI2rFindLocalPath(ioCharacter, PHcPathMode_CasualMovement, NULL, NULL, NULL, AI2cDodge_LocalPathDistance, ioCombatState->maneuver.dodge_accum_angle, AI2cDodge_LocalPathAngle / 4, 4, PHcBorder3, 3, &localpath_success, &localpath_point, &localpath_weight, &localpath_escape); if ((error == UUcError_None) && (localpath_success)) { @@ -1421,7 +1421,7 @@ void AI2rManeuver_ApplyDodge(ONtCharacter *ioCharacter, AI2tCombatState *ioComba } // apply our avoid-angle - if ((ioCombatState->maneuver.dodge_max_weight > AI2cDodge_MinimumAvoidWeight) && + if ((ioCombatState->maneuver.dodge_max_weight > AI2cDodge_MinimumAvoidWeight) && (ioCombatState->maneuver.dodge_avoid_angle != AI2cAngle_None)) { AI2rMovement_MovementModifierAvoidAngle(ioCharacter, ioCombatState->maneuver.dodge_avoid_angle); } else { diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Maneuver.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Maneuver.h index c5c8c4b..9b72ffd 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Maneuver.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Maneuver.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Maneuver.h - + AUTHOR: Chris Butcher - + CREATED: May 02, 2000 - + PURPOSE: Maneuvering code for Oni AI system - + Copyright (c) 2000 */ @@ -170,7 +170,7 @@ UUtBool AI2rManeuver_CheckBlockage(ONtCharacter *ioCharacter, M3tPoint3D *inTarg // determine whether there are any characters between us and some point UUtBool AI2rManeuver_CheckInterveningCharacters(ONtCharacter *ioCharacter, M3tPoint3D *inTargetPoint); -// try colliding with a spheretree against the environment +// try colliding with a spheretree against the environment UUtBool AI2rManeuver_TrySphereTreeCollision(PHtSphereTree *inSphereTree, M3tVector3D *inMovementVector); // check to see if we can perform an escape move diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Melee.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Melee.c index 56d3066..7581046 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Melee.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Melee.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Melee.c - + AUTHOR: Chris Butcher - + CREATED: May 19, 2000 - + PURPOSE: Melee AI for Oni - + Copyright (c) 2000 */ @@ -394,35 +394,35 @@ enum { const UUtUns32 AI2cMeleeNumMoveTypes = (AI2cMoveType_Max >> AI2cMoveType_Shift); const AI2tMeleeMoveType AI2cMeleeMoveTypes[AI2cMoveType_Max >> AI2cMoveType_Shift] = { - {"Attack", - AI2iMelee_Attack_Iterate, - AI2iMelee_Attack_GetName, - AI2iMelee_Attack_GetParams, - AI2iMelee_Attack_GetAnimType, + {"Attack", + AI2iMelee_Attack_Iterate, + AI2iMelee_Attack_GetName, + AI2iMelee_Attack_GetParams, + AI2iMelee_Attack_GetAnimType, AI2iMelee_Attack_CanFollow, AI2iMelee_Attack_Start, AI2iMelee_Attack_Update, AI2iMelee_Attack_Finish, AI2iMelee_Attack_FaceTarget, AI2iMelee_Attack_CanEvade}, - - {"Position", - AI2iMelee_Position_Iterate, - AI2iMelee_Position_GetName, - AI2iMelee_Position_GetParams, - AI2iMelee_Position_GetAnimType, + + {"Position", + AI2iMelee_Position_Iterate, + AI2iMelee_Position_GetName, + AI2iMelee_Position_GetParams, + AI2iMelee_Position_GetAnimType, AI2iMelee_Position_CanFollow, AI2iMelee_Position_Start, AI2iMelee_Position_Update, AI2iMelee_Position_Finish, AI2iMelee_Position_FaceTarget, AI2iMelee_Position_CanEvade}, - - {"Maneuver", - AI2iMelee_Maneuver_Iterate, - AI2iMelee_Maneuver_GetName, - AI2iMelee_Maneuver_GetParams, - AI2iMelee_Maneuver_GetAnimType, + + {"Maneuver", + AI2iMelee_Maneuver_Iterate, + AI2iMelee_Maneuver_GetName, + AI2iMelee_Maneuver_GetParams, + AI2iMelee_Maneuver_GetAnimType, AI2iMelee_Maneuver_CanFollow, AI2iMelee_Maneuver_Start, AI2iMelee_Maneuver_Update, @@ -430,11 +430,11 @@ const AI2tMeleeMoveType AI2cMeleeMoveTypes[AI2cMoveType_Max >> AI2cMoveType_Shif AI2iMelee_Maneuver_FaceTarget, AI2iMelee_Maneuver_CanEvade}, - {"Evade", - AI2iMelee_Evade_Iterate, - AI2iMelee_Evade_GetName, - AI2iMelee_Evade_GetParams, - AI2iMelee_Evade_GetAnimType, + {"Evade", + AI2iMelee_Evade_Iterate, + AI2iMelee_Evade_GetName, + AI2iMelee_Evade_GetParams, + AI2iMelee_Evade_GetAnimType, AI2iMelee_Evade_CanFollow, AI2iMelee_Evade_Start, AI2iMelee_Evade_Update, @@ -442,18 +442,18 @@ const AI2tMeleeMoveType AI2cMeleeMoveTypes[AI2cMoveType_Max >> AI2cMoveType_Shif AI2iMelee_Evade_FaceTarget, AI2iMelee_Evade_CanEvade}, - {"Throw", - AI2iMelee_Throw_Iterate, - AI2iMelee_Throw_GetName, - AI2iMelee_Throw_GetParams, - AI2iMelee_Throw_GetAnimType, + {"Throw", + AI2iMelee_Throw_Iterate, + AI2iMelee_Throw_GetName, + AI2iMelee_Throw_GetParams, + AI2iMelee_Throw_GetAnimType, AI2iMelee_Throw_CanFollow, AI2iMelee_Throw_Start, AI2iMelee_Throw_Update, AI2iMelee_Throw_Finish, AI2iMelee_Throw_FaceTarget, AI2iMelee_Throw_CanEvade}}; - + // *** translation from AI2tMeleeMoveState to TRtAnimState const TRtAnimState AI2cMelee_TotoroAnimState[AI2cMeleeMoveState_Max] = @@ -473,21 +473,21 @@ const TRtAnimType AI2cMelee_DelayAnimType[AI2cMeleeMoveState_Max] = ONcAnimType_Fly, ONcAnimType_Fly, ONcAnimType_Fly, ONcAnimType_Fly, ONcAnimType_Fly}; // *** whether we block crouching by preference when we're in a given melee state -const UUtBool AI2cMeleeState_BlockCrouching[AI2cMeleeMoveState_Max] = +const UUtBool AI2cMeleeState_BlockCrouching[AI2cMeleeMoveState_Max] = {UUcFalse, UUcFalse, UUcTrue, UUcTrue, UUcFalse, UUcFalse, UUcFalse, UUcFalse, UUcFalse, UUcFalse, UUcFalse, UUcFalse, UUcFalse, UUcFalse, UUcFalse, UUcFalse, UUcFalse, UUcFalse}; // *** whether we can turn on the spot in order to line up an attack while in this move state -const UUtBool AI2cMeleeState_CanTurnForAttack[AI2cMeleeMoveState_Max] = +const UUtBool AI2cMeleeState_CanTurnForAttack[AI2cMeleeMoveState_Max] = {UUcTrue, UUcTrue, UUcTrue, UUcFalse, UUcFalse, UUcTrue, UUcTrue, UUcTrue, UUcTrue, UUcTrue, UUcTrue, UUcTrue, UUcTrue, UUcFalse, UUcFalse, UUcFalse, UUcFalse, UUcFalse}; // *** keys to hold down in order to stay in this melee state -const LItButtonBits AI2cMeleeState_MaintainStateKeys[AI2cMeleeMoveState_Max] = +const LItButtonBits AI2cMeleeState_MaintainStateKeys[AI2cMeleeMoveState_Max] = {0, 0, LIc_BitMask_Crouch, LIc_BitMask_Crouch, 0, LIc_BitMask_Forward, LIc_BitMask_Backward, LIc_BitMask_StepLeft, LIc_BitMask_StepRight, LIc_BitMask_Forward, LIc_BitMask_Backward, LIc_BitMask_StepLeft, LIc_BitMask_StepRight, @@ -1564,7 +1564,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState if (ioMeleeState->target->animCounter == ioMeleeState->current_react_anim_index) { if (active_target != NULL) { const TRtAnimation *animation = active_target->animation; - + if (TRrAnimation_IsAttack(animation) && (TRrAnimation_GetThrowType(animation) == 0)) { // this is an attack, block until it lands if (active_target->animFrame < TRrAnimation_GetLastAttackFrame(animation)) { @@ -1588,9 +1588,9 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState // run the update for our current move executing_move = UUcFalse; - ioMeleeState->running_active_animation = ((TRrAnimation_IsAttack(active_character->animation)) || + ioMeleeState->running_active_animation = ((TRrAnimation_IsAttack(active_character->animation)) || (TRrAnimation_TestFlag(active_character->animation, ONcAnimFlag_ThrowSource)) || - (AI2rExecutor_HasAttackOverride(ioCharacter, NULL)) || + (AI2rExecutor_HasAttackOverride(ioCharacter, NULL)) || (ONrCharacter_InAir(ioCharacter))); if (ioMeleeState->current_move != NULL) { UUmAssert(ioMeleeState->current_technique != NULL); @@ -1603,13 +1603,13 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState // update this move, and determine whether it has finished move_type = (ioMeleeState->current_move->move & AI2cMoveType_Mask) >> AI2cMoveType_Shift; UUmAssert((move_type >= 0) && (move_type < AI2cMeleeNumMoveTypes)); - + if (AI2gMelee_ShowCurrentProfile) { sprintf(status_line, "%s move #%d", ioMeleeState->current_technique->name, ioMeleeState->move_index + 1); } finished = AI2cMeleeMoveTypes[move_type].func_update(ioCharacter, ioMeleeState, ioMeleeState->current_move); - + if (AI2gMelee_ShowCurrentProfile) { if (finished) { strcat(status_line, " (done)"); @@ -1624,7 +1624,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState // don't consider changing moves / techniques until all of our attack moves are done and we're on the ground if (ioMeleeState->running_active_animation) { #if DEBUG_VERBOSE_MELEE - COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: can't change technique, waiting for animation %s to complete", + COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: can't change technique, waiting for animation %s to complete", ioCharacter->player_name, TMrInstance_GetInstanceName(active_character->animation)); #endif if (ioMeleeState->current_technique == NULL) { @@ -1678,7 +1678,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState - + // we are considering a defense. we need animcheck_location_matrix to account for if the opponent // has moved since starting their attack. basically this matrix must give our position // relative to where the start of the opponent's animation would have been. @@ -1693,7 +1693,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState intersect_context.current_location_matrix.m[3][0] += position_pt->location_x * TRcPositionGranularity; intersect_context.current_location_matrix.m[3][1] += position_pt->location_y * TRcPositionGranularity; */ - + // look to see whether the attack will hit us try_react = TRrCheckAnimationBounds(&evade_context); if (try_react) { @@ -1723,7 +1723,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState cur_state = AI2iMelee_TranslateTotoroAnimState(ioCharacter, cur_to_state); #if DEBUG_VERBOSE_MELEE - COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: to_state %s -> current melee state '%s'", + COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: to_state %s -> current melee state '%s'", ioCharacter->player_name, ONrAnimStateToString(cur_to_state), AI2cMeleeMoveStateName[cur_state]); #endif @@ -1737,7 +1737,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState // stay with the current technique if possible new_technique = ioMeleeState->current_technique; - if ((ioMeleeState->current_technique == NULL) || (AI2gUltraMode) || + if ((ioMeleeState->current_technique == NULL) || (AI2gUltraMode) || (ioCharacter->flags2 & ONcCharacterFlag2_UltraMode) || (!ioMeleeState->committed_to_technique)) { // we either have no technique, or are between moves in an interruptable technique (or Ultra Mode is on, // which makes all techniques interruptable). @@ -1875,7 +1875,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState AI2_ERROR(AI2cBug, AI2cSubsystem_Melee, AI2cError_Melee_BrokenTechnique, ioCharacter, ioMeleeState, ioMeleeState->current_technique, 0, 0); #if DEBUG_VERBOSE_MELEE - COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: technique %s start state NONE, error.", + COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: technique %s start state NONE, error.", ioCharacter->player_name, technique_itr->name); #endif current_choice->weight = 0; @@ -1884,7 +1884,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState // we would need to execute a state transition in order to run this technique if ((technique_itr->computed_flags & AI2cTechniqueComputedFlag_AllowTransition) == 0) { #if DEBUG_VERBOSE_MELEE - COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: technique %s start state %s requires exact match. don't consider.", + COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: technique %s start state %s requires exact match. don't consider.", ioCharacter->player_name, technique_itr->name, AI2cMeleeMoveStateName[technique_fromstate]); #endif current_choice->weight = 0; @@ -2020,7 +2020,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState // we would need to execute a state transition in order to run this technique if ((technique_itr->computed_flags & AI2cTechniqueComputedFlag_AllowTransition) == 0) { #if DEBUG_VERBOSE_MELEE - COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: technique %s start state %s requires exact match. don't consider.", + COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: technique %s start state %s requires exact match. don't consider.", ioCharacter->player_name, technique_itr->name, AI2cMeleeMoveStateName[technique_fromstate]); #endif current_choice->weight = 0; @@ -2060,7 +2060,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState num_choices++; } } - + // no selected technique yet new_technique = NULL; @@ -2150,22 +2150,22 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState // we can hit our target before they hit us. act, don't react. try_react = UUcFalse; } - + } else { // this technique is not viable. forget about it. #if DEBUG_VERBOSE_MELEE - COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: technique %s is not viable, reject this choice.", + COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: technique %s is not viable, reject this choice.", ioCharacter->player_name, new_technique->name); #endif total_weight -= current_choice->weight; current_choice->weight = 0; num_choices--; new_technique = NULL; - } + } } } } - + /* * REACTION SELECTION */ @@ -2232,7 +2232,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState UUmAssert(current_choice->weight > 0); num_choices++; } - + if (num_choices > 0) { // pick techniques at random, using weight factors to bias random_weight = (total_weight * ioMeleeState->reaction_seed) / UUcMaxUns16 - 0.01f; // fudge to ensure always < total_weight @@ -2311,7 +2311,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState if (new_technique == NULL) { if (fallen) { // we are fallen and must get up - but didn't find any get-up maneuvers - AI2rExecutor_MoveOverride(ioCharacter, LIc_BitMask_Forward); + AI2rExecutor_MoveOverride(ioCharacter, LIc_BitMask_Forward); return UUcTrue; } else { // we are standing and we didn't find any viable techniques. return to the combat manager, @@ -2347,7 +2347,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState ioCharacter->player_name, (ioMeleeState->current_technique == NULL) ? "" : ioMeleeState->current_technique->name); #endif - + AI2iMelee_UpdateFacing(ioCharacter, ioMeleeState); AI2iMelee_ApplyFacing(ioCharacter, ioMeleeState); @@ -2368,7 +2368,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState #if DEBUG_VERBOSE_MELEE COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: beginning move 0x%08X (%s)", - ioCharacter->player_name, ioMeleeState->current_move->move, + ioCharacter->player_name, ioMeleeState->current_move->move, (ioMeleeState->current_move->animation == NULL) ? "" : TMrInstance_GetInstanceName(ioMeleeState->current_move->animation)); #endif @@ -2383,7 +2383,7 @@ UUtBool AI2rMelee_Update(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState // execute. move_type = (ioMeleeState->current_move->move & AI2cMoveType_Mask) >> AI2cMoveType_Shift; UUmAssert((move_type >= 0) && (move_type < AI2cMeleeNumMoveTypes)); - + #if DEBUG_VERBOSE_MELEE COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: calling start routine for move 0x%08X", ioCharacter->player_name, ioMeleeState->current_move->move); @@ -2541,7 +2541,7 @@ static UUtBool AI2iMelee_StartNextMove(ONtCharacter *ioCharacter, AI2tMeleeState COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: done %d moves, technique %s is complete", ioCharacter->player_name, ioMeleeState->move_index, ioMeleeState->current_technique->name); #endif - // the technique is complete and has no moves left. however we don't finish the technique until + // the technique is complete and has no moves left. however we don't finish the technique until // all of our attack moves have completed executing. ioMeleeState->current_move = NULL; ioMeleeState->current_attackanim = NULL; @@ -3030,7 +3030,7 @@ static UUtBool AI2iMelee_TargetIsThrowable(ONtCharacter *ioCharacter, ONtActiveC // consider and weight an attacking technique static void AI2iMelee_WeightTechnique(ONtCharacter *ioCharacter, AI2tMeleeState *ioMeleeState, AI2tMeleeProfile *ioMeleeProfile, TRtAnimIntersectContext *ioContext, UUtBool inConsiderAttack, TRtDirection inDirection, - AI2tMeleeMoveState inCurrentState, TRtAnimState inCurrentAnimState, + AI2tMeleeMoveState inCurrentState, TRtAnimState inCurrentAnimState, UUtBool inCanBlock, UUtBool inBlockLow, UUtBool inBlockHigh, struct AI2tConsideredTechnique *ioTechnique) { @@ -3477,7 +3477,7 @@ static void AI2iMelee_WeightTechnique(ONtCharacter *ioCharacter, AI2tMeleeState COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, " - delay-distance %f < %f, skip positioning move (%d)", delay_distance, -AI2cMelee_SkipPositioningDistance, ioTechnique->positionmove_skip); #endif - } + } } if (skip_positioning) { @@ -3504,7 +3504,7 @@ static void AI2iMelee_WeightTechnique(ONtCharacter *ioCharacter, AI2tMeleeState delay_distance -= adjust_frames * target_closing_velocity; } delay_distance = UUmMax(delay_distance, 0); - + // how does this affect our technique's weight? if (delay_distance > max_delay) { // outside acceptable bounds @@ -3566,7 +3566,7 @@ static void AI2iMelee_WeightTechnique(ONtCharacter *ioCharacter, AI2tMeleeState #endif return; } - + adjust_distance += delay_distance; adjust_frames += delay_frames; } @@ -3602,7 +3602,7 @@ static void AI2iMelee_WeightTechnique(ONtCharacter *ioCharacter, AI2tMeleeState #endif ioTechnique->weight = 0; return; - } + } // check to make sure that we won't encounter danger in performing this move test_dist = adjust_distance + ioTechnique->jump_velocity * ioMeleeProfile->min_jumpframes + move->attack_endpos; @@ -3859,7 +3859,7 @@ static void AI2iMelee_WeightTechnique(ONtCharacter *ioCharacter, AI2tMeleeState #endif ioTechnique->weight = 0; return; - } + } #if DEBUG_VERBOSE_WEIGHT COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, " PREDELAY: transition chain %s -> %s, length %d dist %f frames %f\n", @@ -3951,7 +3951,7 @@ static void AI2iMelee_WeightTechnique(ONtCharacter *ioCharacter, AI2tMeleeState #endif ioTechnique->weight = 0; return; - } + } #if DEBUG_VERBOSE_WEIGHT COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, " POSTDELAY: transition chain %s -> %s, length %d dist %f frames %f\n", @@ -4090,7 +4090,7 @@ static void AI2iMelee_WeightTechnique(ONtCharacter *ioCharacter, AI2tMeleeState angle_to_edge = UUmMin(target_rel_angle - move->param[1], move->param[2] - target_rel_angle); } else { - angle_to_edge = UUmMin(target_rel_angle - move->param[2], + angle_to_edge = UUmMin(target_rel_angle - move->param[2], move->param[1] - target_rel_angle); } @@ -4121,7 +4121,7 @@ static void AI2iMelee_WeightTechnique(ONtCharacter *ioCharacter, AI2tMeleeState case AI2cMeleeManeuver_RandomStop: // immediately stop weighting the technique; return whatever weight we already have return; - + case AI2cMeleeManeuver_Pause: case AI2cMeleeManeuver_Crouch: case AI2cMeleeManeuver_Jump: @@ -4272,7 +4272,7 @@ static void AI2iMelee_WeightTechnique(ONtCharacter *ioCharacter, AI2tMeleeState /* * double-check that we are in the right position with respect to the target */ - + animtype = TRrAnimation_GetType(move->animation); if (currently_behind_target) { @@ -4735,7 +4735,7 @@ static void AI2iMelee_WeightSpacingBehavior(ONtCharacter *ioCharacter, AI2tMelee case AI2cMeleeManeuver_RandomStop: // immediately stop weighting the technique; return whatever weight we already have return; - + case AI2cMeleeManeuver_Pause: case AI2cMeleeManeuver_Crouch: case AI2cMeleeManeuver_Jump: @@ -4961,7 +4961,7 @@ static UUtBool AI2iMelee_AddLocalMovement(ONtCharacter *ioCharacter, AI2tMeleeSt MUmVector_Copy(localmove_dest, from_pt); MUmVector_ScaleIncrement(localmove_dest, AI2cMelee_PositionLocalMoveDist, localmove_dir); - error = AI2rTryLocalMovement(ioCharacter, PHcPathMode_CasualMovement, &from_pt, &localmove_dest, + error = AI2rTryLocalMovement(ioCharacter, PHcPathMode_CasualMovement, &from_pt, &localmove_dest, 3, &localmove_success, &localmove_pt, &localmove_weight, &localmove_escape); found_dir = ((error == UUcError_None) && (localmove_success)); @@ -5050,28 +5050,28 @@ UUtError AI2rMelee_PrepareForUse(AI2tMeleeProfile *ioMeleeProfile) ONcAnimState_Running_Right_Down, ONcAnimVarientMask_Fight); if (lookup_anim != NULL) { TRrAnimation_GetPosition(lookup_anim, 0, &thisframe_vel); - ioMeleeProfile->jump_vel[AI2cMeleeJumpType_RunForward] = thisframe_vel.z; + ioMeleeProfile->jump_vel[AI2cMeleeJumpType_RunForward] = thisframe_vel.z; } lookup_anim = (TRtAnimation *) TRrCollection_Lookup(anim_collection, ONcAnimType_Run_Backwards, ONcAnimState_Running_Back_Right_Down, ONcAnimVarientMask_Fight); if (lookup_anim != NULL) { TRrAnimation_GetPosition(lookup_anim, 0, &thisframe_vel); - ioMeleeProfile->jump_vel[AI2cMeleeJumpType_RunBack] = -thisframe_vel.z; + ioMeleeProfile->jump_vel[AI2cMeleeJumpType_RunBack] = -thisframe_vel.z; } lookup_anim = (TRtAnimation *) TRrCollection_Lookup(anim_collection, ONcAnimType_Run_Sidestep_Left, ONcAnimState_Sidestep_Left_Right_Down, ONcAnimVarientMask_Fight); if (lookup_anim != NULL) { TRrAnimation_GetPosition(lookup_anim, 0, &thisframe_vel); - ioMeleeProfile->jump_vel[AI2cMeleeJumpType_RunLeft] = thisframe_vel.x; + ioMeleeProfile->jump_vel[AI2cMeleeJumpType_RunLeft] = thisframe_vel.x; } lookup_anim = (TRtAnimation *) TRrCollection_Lookup(anim_collection, ONcAnimType_Run_Sidestep_Right, ONcAnimState_Sidestep_Right_Right_Down, ONcAnimVarientMask_Fight); if (lookup_anim != NULL) { TRrAnimation_GetPosition(lookup_anim, 0, &thisframe_vel); - ioMeleeProfile->jump_vel[AI2cMeleeJumpType_RunRight] = -thisframe_vel.x; + ioMeleeProfile->jump_vel[AI2cMeleeJumpType_RunRight] = -thisframe_vel.x; } // we must be travelling at least half as fast sideways as we are up - if this constant from Oni_GameState.c @@ -5172,7 +5172,7 @@ UUtError AI2rMelee_PrepareForUse(AI2tMeleeProfile *ioMeleeProfile) transition->anim_distance = -end_position->location_y * TRcPositionGranularity; transition->anim_endvelocity = -vel_estimate.z; break; - + default: UUmAssert(0); transition->anim_distance = 0; @@ -5183,7 +5183,7 @@ UUtError AI2rMelee_PrepareForUse(AI2tMeleeProfile *ioMeleeProfile) transition++; ioMeleeProfile->num_transitions++; } - + if (ioMeleeProfile->num_transitions >= AI2cMeleeProfile_MaxTransitions) { overflowed = UUcTrue; } @@ -5438,7 +5438,7 @@ UUtError AI2rMelee_PrepareForUse(AI2tMeleeProfile *ioMeleeProfile) extent_info = TRrAnimation_GetExtentInfo(move->animation); technique->computed_flags |= AI2cTechniqueComputedFlag_IsAttack; - + if (TRrAnimation_TestAttackFlag(move->animation, (TRtAnimTime) -1, (UUtUns32) -1, ONcAttackFlag_AttackHigh)) technique->computed_flags |= AI2cTechniqueComputedFlag_IsHigh; @@ -5455,7 +5455,7 @@ UUtError AI2rMelee_PrepareForUse(AI2tMeleeProfile *ioMeleeProfile) technique->computed_flags |= AI2cTechniqueComputedFlag_HasStagger; technique->max_damage += TRrAnimation_GetMaximumDamage(move->animation); - + technique->attack_maxrange = extent_info->attack_ring.max_distance; technique->attack_idealrange = technique->attack_maxrange - AI2cMelee_IdealRangeSubtractFraction * extent_info->maxAttack.attack_dist; technique->attack_initialframes = extent_info->firstAttack.frame_index; @@ -5609,7 +5609,7 @@ UUtBool AI2rMelee_MoveIsValid(TRtAnimationCollection *inCollection, UUtUns32 inM return UUcTrue; } - + from_state = *ioFromState; anim_type = AI2cMeleeMoveTypes[move_type >> AI2cMoveType_Shift].func_getanimtype(inMove, @@ -5640,7 +5640,7 @@ UUtBool AI2rMelee_MoveIsValid(TRtAnimationCollection *inCollection, UUtUns32 inM // any from-state will do (this probably won't ever happen) anim_state = ONcAnimState_Anything; } - + if (move_type != AI2cMoveType_Throw) { // look up the animation in our collection lookup_anim = (TRtAnimation *) TRrCollection_Lookup(inCollection, anim_type, anim_state, ONcAnimVarientMask_Fight); @@ -5806,7 +5806,7 @@ static UUtBool AI2iMelee_Attack_Update(ONtCharacter *ioCharacter, AI2tMeleeState // just wait until it is realised (or discarded) return UUcFalse; } - + // we have launched an attack; we cannot change our facing for this technique any longer. ioMeleeState->lock_facing_for_technique = UUcTrue; ioMeleeState->technique_face_direction = ioCharacter->facing; @@ -5849,7 +5849,7 @@ static UUtBool AI2iMelee_Attack_Update(ONtCharacter *ioCharacter, AI2tMeleeState if (((ioCharacter->flags2 & ONcCharacterFlag2_UltraMode) || AI2gUltraMode || (!ioMeleeState->committed_to_technique)) && (ioMeleeState->technique_face_direction != AI2cAngle_None)) { // we want to turn to face the target before we start our attack - + if (ioMeleeState->facing_delta > AI2cMeleeDirectionalAttackMax) { // we are facing in a very wrong direction, abort this attack #if DEBUG_VERBOSE_ATTACK @@ -5864,7 +5864,7 @@ static UUtBool AI2iMelee_Attack_Update(ONtCharacter *ioCharacter, AI2tMeleeState return UUcTrue; } - + if (ioMeleeState->facing_delta > AI2cMeleeMinStartAttackAngle) { // we are facing in the wrong direction - delay ONrSetupAnimIntersectionContext(ioCharacter, ioMeleeState->target, UUcTrue, &intersect_context); @@ -5997,7 +5997,7 @@ static UUtBool AI2iMelee_Attack_Update(ONtCharacter *ioCharacter, AI2tMeleeState // what turning radius is required to reach the facing before we get to the target? if (distance_perp - intersect_context.target_cylinder_radius > 0.1f) { distance_perp -= intersect_context.target_cylinder_radius; - + // trigonometry tells us that r = (perp^2 + fwd^2) / 2 * perp required_turning_radius = (UUmSQR(distance_perp) + UUmSQR(distance_fwd)) / (2.0f * distance_perp); @@ -6111,7 +6111,7 @@ static UUtBool AI2iMelee_Attack_Update(ONtCharacter *ioCharacter, AI2tMeleeState #if DEBUG_VERBOSE_ATTACK COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: attack 0x%08X: animation %s (type %s) direct lookup! (current tostate %s, fromstate %s)", ioCharacter->player_name, inMove->move, TMrInstance_GetInstanceName(inMove->animation), - ONrAnimTypeToString(TRrAnimation_GetType(inMove->animation)), ONrAnimStateToString(next_animstate), + ONrAnimTypeToString(TRrAnimation_GetType(inMove->animation)), ONrAnimStateToString(next_animstate), ONrAnimStateToString(TRrAnimation_GetFrom(inMove->animation))); #endif } else if (TRrAnimation_IsShortcut(inMove->animation, next_animstate)) { @@ -6119,7 +6119,7 @@ static UUtBool AI2iMelee_Attack_Update(ONtCharacter *ioCharacter, AI2tMeleeState #if DEBUG_VERBOSE_ATTACK COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: attack 0x%08X: animation %s (type %s) shortcut lookup! (current tostate %s, fromstate %s)", ioCharacter->player_name, inMove->move, TMrInstance_GetInstanceName(inMove->animation), - ONrAnimTypeToString(TRrAnimation_GetType(inMove->animation)), ONrAnimStateToString(next_animstate), + ONrAnimTypeToString(TRrAnimation_GetType(inMove->animation)), ONrAnimStateToString(next_animstate), ONrAnimStateToString(TRrAnimation_GetFrom(inMove->animation))); #endif } @@ -6544,7 +6544,7 @@ static UUtBool AI2iMelee_Position_Update(ONtCharacter *ioCharacter, AI2tMeleeSta // that we have to abort the technique as well... AI2iMeleeState_AbortTechnique(ioCharacter, ioMeleeState); return UUcTrue; - } + } #if DEBUG_VERBOSE_POSITION COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, " PositionEndTrans: transition chain %s -> %s, length %d dist %f frames %f\n", @@ -6637,7 +6637,7 @@ static UUtBool AI2iMelee_Position_Update(ONtCharacter *ioCharacter, AI2tMeleeSta AI2iMelee_SetupAttackerState(ioCharacter, ioCharacter->ai2State.meleeProfile, &anim_context.attacker, ioMeleeState->current_technique_ends_in_jump, ioMeleeState->current_technique_jump_vel, position_move->direction, ioMeleeState->current_technique->attack_anim); - + // check to see if we can intersect with the target. if (!TRrCheckAnimationBounds(&anim_context)) { #if DEBUG_VERBOSE_POSITION @@ -6758,7 +6758,7 @@ static UUtBool AI2iMelee_Position_Update(ONtCharacter *ioCharacter, AI2tMeleeSta ioMeleeState->position_desired_state = position_move->states[0]; ioMeleeState->position_current_transition = NULL; ioMeleeState->position_skipped_delay = UUcFalse; - return UUcFalse; + return UUcFalse; } if ((!position_move->can_delay) || (ioMeleeState->position_state_index != 0)) { @@ -6912,7 +6912,7 @@ static UUtBool AI2iMelee_Position_Update(ONtCharacter *ioCharacter, AI2tMeleeSta ioMeleeState->position_desired_state = position_move->states[0]; ioMeleeState->position_current_transition = NULL; ioMeleeState->position_skipped_delay = UUcFalse; - return UUcFalse; + return UUcFalse; } if ((!position_move->can_delay) || (ioMeleeState->position_state_index != 0)) { @@ -6928,7 +6928,7 @@ static UUtBool AI2iMelee_Position_Update(ONtCharacter *ioCharacter, AI2tMeleeSta // we are colliding with the target and can't get into range, abort #if (DEBUG_VERBOSE_POSITION || DEBUG_VERBOSE_TECHNIQUE) COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: colliding with target but can't throw. aborting!", ioCharacter->player_name); -#endif +#endif AI2iMeleeState_AbortTechnique(ioCharacter, ioMeleeState); return UUcTrue; } @@ -6952,7 +6952,7 @@ static UUtBool AI2iMelee_Position_Update(ONtCharacter *ioCharacter, AI2tMeleeSta ioMeleeState->attack_waspositioned = UUcTrue; return AI2iMelee_StartNextMove(ioCharacter, ioMeleeState, inMove); } - + ioMeleeState->position_desired_state = position_move->states[ioMeleeState->position_state_index]; #if DEBUG_VERBOSE_POSITION COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: position update: looking for next state %s (%d)", @@ -7372,7 +7372,7 @@ static UUtBool AI2iMelee_Maneuver_Update(ONtCharacter *ioCharacter, AI2tMeleeSta // just wait until it is realised (or discarded) return UUcFalse; } - + // we have actually performed this technique, we can't again for a while AI2iMeleeState_ApplyTechniqueDelay(ioCharacter, ioMeleeState); @@ -7442,7 +7442,7 @@ static UUtBool AI2iMelee_Maneuver_Update(ONtCharacter *ioCharacter, AI2tMeleeSta #endif ioMeleeState->maneuver_started = UUcTrue; } - + if (current_time > ioMeleeState->maneuver_endtime) { #if DEBUG_VERBOSE_MANEUVER COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "maneuver timer expired (%d > %d)", current_time, ioMeleeState->maneuver_endtime); @@ -7480,7 +7480,7 @@ static UUtBool AI2iMelee_Maneuver_Update(ONtCharacter *ioCharacter, AI2tMeleeSta } UUmAssert(!ioMeleeState->lock_facing_for_technique); - localmove_success = AI2iMelee_AddLocalMovement(ioCharacter, ioMeleeState, + localmove_success = AI2iMelee_AddLocalMovement(ioCharacter, ioMeleeState, maneuver_def->maneuver_direction, UUcTrue); if (!localmove_success) { #if DEBUG_VERBOSE_MANEUVER @@ -7732,7 +7732,7 @@ static UUtBool AI2iMelee_Evade_Update(ONtCharacter *ioCharacter, AI2tMeleeState #if DEBUG_VERBOSE_EVADE COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: evasion 0x%08X: animation %s (type %s) direct lookup! (current tostate %s, fromstate %s)", ioCharacter->player_name, inMove->move, TMrInstance_GetInstanceName(inMove->animation), - ONrAnimTypeToString(TRrAnimation_GetType(inMove->animation)), ONrAnimStateToString(next_animstate), + ONrAnimTypeToString(TRrAnimation_GetType(inMove->animation)), ONrAnimStateToString(next_animstate), ONrAnimStateToString(TRrAnimation_GetFrom(inMove->animation))); #endif } else if (TRrAnimation_IsShortcut(inMove->animation, next_animstate)) { @@ -7740,7 +7740,7 @@ static UUtBool AI2iMelee_Evade_Update(ONtCharacter *ioCharacter, AI2tMeleeState #if DEBUG_VERBOSE_EVADE COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: evasion 0x%08X: animation %s (type %s) shortcut lookup! (current tostate %s, fromstate %s)", ioCharacter->player_name, inMove->move, TMrInstance_GetInstanceName(inMove->animation), - ONrAnimTypeToString(TRrAnimation_GetType(inMove->animation)), ONrAnimStateToString(next_animstate), + ONrAnimTypeToString(TRrAnimation_GetType(inMove->animation)), ONrAnimStateToString(next_animstate), ONrAnimStateToString(TRrAnimation_GetFrom(inMove->animation))); #endif } @@ -7772,7 +7772,7 @@ static UUtBool AI2iMelee_Evade_Update(ONtCharacter *ioCharacter, AI2tMeleeState // queue up the evasion move. #if DEBUG_VERBOSE_EVADE COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: evasion 0x%08X: executing '%s' - wait-for-state %s", - ioCharacter->player_name, inMove->move, evade_move->name, + ioCharacter->player_name, inMove->move, evade_move->name, ONrAnimTypeToString(AI2mMelee_EvadeAnimType(evade_move->evademove_flags))); #endif AI2rExecutor_AttackOverride(ioCharacter, evade_move->keys_isdown, evade_move->keys_wentdown, @@ -7991,7 +7991,7 @@ static UUtBool AI2iMelee_Throw_Update(ONtCharacter *ioCharacter, AI2tMeleeState AI2iMeleeState_AbortTechnique(ioCharacter, ioMeleeState); return UUcTrue; } - + if (throw_move->throwmove_flags & AI2cMelee_Throw_DisarmPistol) { // the target must still have their pistol out desired_varient = ONcAnimVarientMask_Righty_Pistol; @@ -8085,7 +8085,7 @@ static UUtBool AI2iMelee_Throw_Update(ONtCharacter *ioCharacter, AI2tMeleeState COrConsole_Printf_Color(UUcTrue, 0xFFFF9090, 0xFFFF3030, "%s: throw source distance %f sends us into danger, abort", ioCharacter->player_name, inMove->attack_endpos); #endif - } + } if (should_abort) { AI2iMeleeState_AbortTechnique(ioCharacter, ioMeleeState); diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Melee.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Melee.h index 7e78ffa..f358be7 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Melee.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Melee.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Melee.h - + AUTHOR: Chris Butcher - + CREATED: May 19, 2000 - + PURPOSE: Melee AI for Oni - + Copyright (c) 2000 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_MeleeProfile.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_MeleeProfile.h index a1431c7..b17b805 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_MeleeProfile.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_MeleeProfile.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_MeleeProfile.h - + AUTHOR: Chris Butcher - + CREATED: May 19, 2000 - + PURPOSE: Definitions for Oni AI's Melee Profiles - + Copyright (c) 2000 */ @@ -182,7 +182,7 @@ typedef struct AI2tMeleeProfile UUtUns32 dodge_damage_threshold; // attacks with dmg >= threshold have chance = base + additional UUtUns32 blockskill_percentage; UUtUns32 blockgroup_percentage; - + // weight values which control technique selection... each attack is multiplied by exactly // one of these. typically the order given here will be their order from high to low. float weight_notblocking_any; diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Movement.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Movement.c index e1e4cac..8d05b3e 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Movement.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Movement.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Movement.c - + AUTHOR: Michael Evans, Chris Butcher - + CREATED: November 15, 1999 - + PURPOSE: Movement AI for Oni - + Copyright (c) Bungie Software, 1999 */ @@ -113,7 +113,7 @@ void AI2rMovement_DontForceAim(ONtCharacter *ioCharacter) UUmAssert(active_character != NULL); AI2rMovementState_ResetAimingVarient(ioCharacter, &active_character->movement_state); - } + } } void AI2rMovement_Force_AimWithWeapon(ONtCharacter *ioCharacter, UUtBool inAimWithWeapon) @@ -126,7 +126,7 @@ void AI2rMovement_Force_AimWithWeapon(ONtCharacter *ioCharacter, UUtBool inAimWi UUmAssert(active_character != NULL); AI2rMovementState_ResetAimingVarient(ioCharacter, &active_character->movement_state); - } + } } /* @@ -223,7 +223,7 @@ void AI2rMovement_NotifyAlertChange(ONtCharacter *ioCharacter) UUmAssert(active_character != NULL); AI2rMovementState_NotifyAlertChange(ioCharacter, &active_character->movement_state); - } + } } UUtError AI2rMovement_MovementModifier(ONtCharacter *ioCharacter, float inDirection, float inWeight) @@ -292,7 +292,7 @@ UUtBool AI2rMovement_IsKeepingMoving(ONtCharacter *ioCharacter) return AI2rMovementState_IsKeepingMoving(ioCharacter, &active_character->movement_state); } else { return UUcFalse; - } + } } float AI2rMovement_GetMoveDirection(ONtCharacter *ioCharacter) @@ -304,7 +304,7 @@ float AI2rMovement_GetMoveDirection(ONtCharacter *ioCharacter) return AI2rMovementState_GetMoveDirection(ioCharacter, &active_character->movement_state); } else { return AI2rMovementStub_GetMoveDirection(ioCharacter); - } + } } UUtBool AI2rMovement_SimplePath(ONtCharacter *ioCharacter) @@ -316,7 +316,7 @@ UUtBool AI2rMovement_SimplePath(ONtCharacter *ioCharacter) return AI2rMovementState_SimplePath(ioCharacter, &active_character->movement_state); } else { return UUcTrue; - } + } } // ------------------------------------------------------------------------------------ @@ -359,7 +359,7 @@ void AI2rMovement_NewDestination(ONtCharacter *ioCharacter) AI2rMovementState_NewDestination(ioCharacter, &active_character->movement_state); } else { AI2rMovementStub_NewDestination(ioCharacter); - } + } } void AI2rMovement_ClearPath(ONtCharacter *ioCharacter) @@ -371,7 +371,7 @@ void AI2rMovement_ClearPath(ONtCharacter *ioCharacter) AI2rMovementState_ClearPath(ioCharacter, &active_character->movement_state); } else { AI2rMovementStub_ClearPath(ioCharacter); - } + } } UUtBool AI2rMovement_AdvanceThroughGrid(ONtCharacter *ioCharacter) @@ -383,7 +383,7 @@ UUtBool AI2rMovement_AdvanceThroughGrid(ONtCharacter *ioCharacter) return AI2rMovementState_AdvanceThroughGrid(ioCharacter, &active_character->movement_state); } else { return AI2rMovementStub_AdvanceThroughGrid(ioCharacter); - } + } } void AI2rMovement_Update(ONtCharacter *ioCharacter) @@ -414,7 +414,7 @@ void AI2rMovement_Update(ONtCharacter *ioCharacter) ioCharacter->facing = ioCharacter->movementStub.cur_facing; ONrCharacter_Teleport(ioCharacter, &ioCharacter->movementStub.cur_point, UUcFalse); } - } + } } UUtBool AI2rMovement_DestinationFacing(ONtCharacter *ioCharacter) @@ -426,7 +426,7 @@ UUtBool AI2rMovement_DestinationFacing(ONtCharacter *ioCharacter) return AI2rMovementState_DestinationFacing(ioCharacter, &active_character->movement_state); } else { return AI2rMovementStub_DestinationFacing(ioCharacter); - } + } } UUtBool AI2rMovement_CheckFailure(ONtCharacter *ioCharacter) @@ -438,7 +438,7 @@ UUtBool AI2rMovement_CheckFailure(ONtCharacter *ioCharacter) return AI2rMovementState_CheckFailure(ioCharacter, &active_character->movement_state); } else { return AI2rMovementStub_CheckFailure(ioCharacter); - } + } } UUtBool AI2rMovement_MakePath(ONtCharacter *ioCharacter, UUtBool inReusePath) @@ -450,7 +450,7 @@ UUtBool AI2rMovement_MakePath(ONtCharacter *ioCharacter, UUtBool inReusePath) return AI2rMovementState_MakePath(ioCharacter, &active_character->movement_state, inReusePath); } else { return AI2rMovementStub_MakePath(ioCharacter); - } + } } void AI2rMovement_Report(ONtCharacter *ioCharacter, UUtBool inVerbose, AI2tReportFunction inFunction) @@ -477,7 +477,7 @@ void AI2rMovement_Report(ONtCharacter *ioCharacter, UUtBool inVerbose, AI2tRepor default: sprintf(reportbuf, " ", ioCharacter->movementOrders.facingMode); break; - } + } inFunction(reportbuf); switch(ioCharacter->movementOrders.aimingMode) { @@ -488,14 +488,14 @@ void AI2rMovement_Report(ONtCharacter *ioCharacter, UUtBool inVerbose, AI2tRepor case AI2cAimingMode_LookAtPoint: sprintf(reportbuf, " aiming at %f, %f, %f", ioCharacter->movementOrders.aimingData.lookAtPoint.point.x, - ioCharacter->movementOrders.aimingData.lookAtPoint.point.y, + ioCharacter->movementOrders.aimingData.lookAtPoint.point.y, ioCharacter->movementOrders.aimingData.lookAtPoint.point.z); break; case AI2cAimingMode_LookInDirection: sprintf(reportbuf, " aiming in direction %f, %f, %f", ioCharacter->movementOrders.aimingData.lookInDirection.vector.x, - ioCharacter->movementOrders.aimingData.lookInDirection.vector.y, + ioCharacter->movementOrders.aimingData.lookInDirection.vector.y, ioCharacter->movementOrders.aimingData.lookInDirection.vector.z); break; @@ -513,7 +513,7 @@ void AI2rMovement_Report(ONtCharacter *ioCharacter, UUtBool inVerbose, AI2tRepor default: sprintf(reportbuf, " "); break; - } + } if (ioCharacter->movementOrders.force_aim) { strcat(reportbuf, (ioCharacter->movementOrders.force_withweapon) ? " (forced to aim weapon)" : " (forced not to aim weapon)"); @@ -523,26 +523,26 @@ void AI2rMovement_Report(ONtCharacter *ioCharacter, UUtBool inVerbose, AI2tRepor if (ioCharacter->movementOrders.glance_timer) { switch(ioCharacter->movementOrders.glanceAimingMode) { case AI2cAimingMode_None: - sprintf(reportbuf, " ", + sprintf(reportbuf, " ", ioCharacter->movementOrders.glance_timer, ioCharacter->movementOrders.glance_delay); break; - + case AI2cAimingMode_LookAtPoint: sprintf(reportbuf, " glancing(%d delay %d) at %f, %f, %f", ioCharacter->movementOrders.glance_timer, ioCharacter->movementOrders.glance_delay, ioCharacter->movementOrders.glanceAimingData.lookAtPoint.point.x, - ioCharacter->movementOrders.glanceAimingData.lookAtPoint.point.y, + ioCharacter->movementOrders.glanceAimingData.lookAtPoint.point.y, ioCharacter->movementOrders.glanceAimingData.lookAtPoint.point.z); break; - + case AI2cAimingMode_LookInDirection: sprintf(reportbuf, " glancing(%d delay %d) in direction %f, %f, %f", ioCharacter->movementOrders.glance_timer, ioCharacter->movementOrders.glance_delay, ioCharacter->movementOrders.glanceAimingData.lookInDirection.vector.x, - ioCharacter->movementOrders.glanceAimingData.lookInDirection.vector.y, + ioCharacter->movementOrders.glanceAimingData.lookInDirection.vector.y, ioCharacter->movementOrders.glanceAimingData.lookInDirection.vector.z); break; - + case AI2cAimingMode_LookAtCharacter: look_character = ioCharacter->movementOrders.glanceAimingData.lookAtCharacter.character; if ((look_character == NULL) || ((look_character->flags & ONcCharacterFlag_InUse) == 0)) { @@ -550,15 +550,15 @@ void AI2rMovement_Report(ONtCharacter *ioCharacter, UUtBool inVerbose, AI2tRepor } else { strcpy(namebuf, look_character->player_name); } - + sprintf(reportbuf, " glancing(%d delay %d) at %s", ioCharacter->movementOrders.glance_timer, ioCharacter->movementOrders.glance_delay, namebuf); break; - + default: sprintf(reportbuf, " ", ioCharacter->movementOrders.glanceAimingMode); break; - } + } inFunction(reportbuf); } @@ -569,7 +569,7 @@ void AI2rMovement_Report(ONtCharacter *ioCharacter, UUtBool inVerbose, AI2tRepor AI2rMovementState_Report(ioCharacter, &active_character->movement_state, inVerbose, inFunction); } else { AI2rMovementStub_Report(ioCharacter, inVerbose, inFunction); - } + } } void AI2rMovement_RenderPath(ONtCharacter *ioCharacter) @@ -630,7 +630,7 @@ void AI2rMovement_RenderPath(ONtCharacter *ioCharacter) AI2rMovementState_RenderPath(ioCharacter, &active_character->movement_state); } else { AI2rMovementStub_RenderPath(ioCharacter); - } + } } // ------------------------------------------------------------------------------------ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Movement.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Movement.h index cf544ce..96a1e8a 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Movement.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Movement.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Movement.h - + AUTHOR: Chris Butcher - + CREATED: November 15, 1999 - + PURPOSE: Movement AI for Oni - + Copyright (c) Bungie Software, 1999 */ @@ -148,7 +148,7 @@ typedef struct AI2tMovementOrders { // walk, run, creep etc AI2tMovementMode movementMode; UUtBool slowdownDisabled; - + // character to attempt to pathfind through ONtCharacter *curPathIgnoreChar; diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementState.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementState.c index 9168b62..c6fd0d6 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementState.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementState.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_MovementState.c - + AUTHOR: Chris Butcher - + CREATED: July 29, 2000 - + PURPOSE: Incarnated Movement AI for Oni - + Copyright (c) Bungie Software, 2000 */ @@ -149,7 +149,7 @@ static PHtNode *AI2iMovementState_GetCurrentNode(ONtCharacter *ioCharacter, AI2t void AI2rMovementState_Initialize(ONtCharacter *ioCharacter, AI2tMovementState *ioMovementState, AI2tMovementStub *inStub) -{ +{ UUtBool moved; M3tPoint3D position; @@ -274,7 +274,7 @@ static UUtBool AI2iMovementState_FindClearPoint(ONtCharacter *ioCharacter, M3tPo } // we are standing inside an obstruction! try to find a clear point. - error = AI2rFindNearbyPoint(ioCharacter, PHcPathMode_CheckClearSpace, ioPoint, + error = AI2rFindNearbyPoint(ioCharacter, PHcPathMode_CheckClearSpace, ioPoint, AI2cMovementState_ObstructionCheckDistance, AI2cMovementState_ObstructionMinDistance, ioCharacter->facing, M3cPi / AI2cMovementState_ObstructionCheckAttempts, AI2cMovementState_ObstructionCheckAttempts, PHcDanger, 5, &localpath_success, &localpath_point, &localpath_weight, &localpath_escape); @@ -376,7 +376,7 @@ static void AI2iMovementState_FindCurrentPoint(ONtCharacter *ioCharacter, AI2tMo void AI2rMovementState_NewMovementMode(ONtCharacter *ioCharacter, AI2tMovementState *ioMovementState) { AI2tMovementMode new_mode, slow_mode; - + new_mode = ioCharacter->movementOrders.movementMode; if (ioMovementState->temporarily_slowed) { @@ -442,18 +442,18 @@ void AI2rMovementState_ResetAimingVarient(ONtCharacter *ioCharacter, AI2tMovemen } else { // determine aiming/looking status based on movement mode switch(mode) { - + case AI2cMovementMode_NoAim_Walk: case AI2cMovementMode_NoAim_Run: ioMovementState->aiming_weapon = UUcFalse; break; - + case AI2cMovementMode_Creep: case AI2cMovementMode_Walk: case AI2cMovementMode_Run: ioMovementState->aiming_weapon = UUcTrue; break; - + default: UUmAssert(!"AI2rMovementState_ChangeMovementMode: unknown movement mode"); break; @@ -574,7 +574,7 @@ UUtBool AI2rMovementState_AdvanceThroughGrid(ONtCharacter *ioCharacter, AI2tMove return UUcFalse; } - while (AI2iMovementState_CheckPathPointHit(ioCharacter, ioMovementState)) { + while (AI2iMovementState_CheckPathPointHit(ioCharacter, ioMovementState)) { ioMovementState->grid_current_point++; if (ioMovementState->grid_current_point >= ioMovementState->grid_num_points) { @@ -757,7 +757,7 @@ static UUtBool AI2iMovementState_SetupPath(ONtCharacter *ioCharacter, AI2tMoveme success = ASrPath_SetParams(ASgAstar_Path, inNode, room, &ioMovementState->grid_path_start, &ioMovementState->grid_path_end, ioCharacter, ioCharacter->pathState.moving_onto_stairs, (inActiveTransition && AI2gDebug_ShowActivationPaths), AI2gDebug_ShowAstarEvaluation); - + if (success) { success = ASrPath_Generate(ASgAstar_Path, AI2cMax_PathPoints, &ioMovementState->grid_num_points, ioMovementState->grid_path, ioCharacter, UUcTrue, (inActiveTransition || ioMovementState->grid_failure)); @@ -778,7 +778,7 @@ static UUtBool AI2iMovementState_SetupPath(ONtCharacter *ioCharacter, AI2tMoveme return UUcTrue; } -static UUtBool AI2iMovementState_AdjustPathPoint(ONtCharacter *ioCharacter, AI2tMovementState *ioMovementState, +static UUtBool AI2iMovementState_AdjustPathPoint(ONtCharacter *ioCharacter, AI2tMovementState *ioMovementState, UUtUns32 inPointIndex, M3tPoint3D *inNewPoint) { UUtBool success; @@ -819,8 +819,8 @@ static UUtBool AI2iMovementState_AdjustPathPoint(ONtCharacter *ioCharacter, AI2t // one or more of the points lies off the grid; we cannot make this adjustment #if DEBUG_PATH_REUSE COrConsole_Printf_Color(UUcTrue, 0xFF700D6F, 0xFF300030, "%d %s: adjustpt off grid (%d,%d)->(%d,%d) on %dx%d, fail", - ONrGameState_GetGameTime(), ioCharacter->player_name, - old_point.x, old_point.y, new_point.x, new_point.y, + ONrGameState_GetGameTime(), ioCharacter->player_name, + old_point.x, old_point.y, new_point.x, new_point.y, ioMovementState->grid_room->gridX, ioMovementState->grid_room->gridY); #endif success = UUcFalse; @@ -837,7 +837,7 @@ static UUtBool AI2iMovementState_AdjustPathPoint(ONtCharacter *ioCharacter, AI2t path_is_clear = PHrLocalPathWeight(ioCharacter, PHcPathMode_DirectedMovement, cur_pathnode, ioMovementState->grid_room, obstruction_bv, PHcBorder2, 3, old_point.x, old_point.y, new_point.x, new_point.y, - &escape_path, &low_weight, &high_weight, &dummy_stop_x, &dummy_stop_y); + &escape_path, &low_weight, &high_weight, &dummy_stop_x, &dummy_stop_y); success = (path_is_clear) && (!escape_path); #if DEBUG_PATH_REUSE if (success) { @@ -903,9 +903,9 @@ UUtBool AI2rMovementState_MakePath(ONtCharacter *ioCharacter, AI2tMovementState #endif inReusePath = inReusePath && (ioMovementState->grid_num_points > 0); - inReusePath = inReusePath && AI2iMovementState_AdjustPathPoint(ioCharacter, ioMovementState, + inReusePath = inReusePath && AI2iMovementState_AdjustPathPoint(ioCharacter, ioMovementState, 0, &ioMovementState->grid_path_start); - inReusePath = inReusePath && AI2iMovementState_AdjustPathPoint(ioCharacter, ioMovementState, + inReusePath = inReusePath && AI2iMovementState_AdjustPathPoint(ioCharacter, ioMovementState, ioMovementState->grid_num_points - 1, &ioMovementState->grid_path_end); if (inReusePath) { @@ -1005,9 +1005,9 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t UUmAssert(ioMovementState->grid_current_point >= 0); UUmAssert(ioMovementState->grid_current_point < ioMovementState->grid_num_points); UUmAssertReadPtr(ioMovementState->next_path_point, sizeof(AStPathPoint)); - + // we have somewhere to go, and a way to get there - ioMovementState->move_direction = MUrATan2(ioMovementState->vector_to_point.x, + ioMovementState->move_direction = MUrATan2(ioMovementState->vector_to_point.x, ioMovementState->vector_to_point.z); UUmTrig_ClipLow(ioMovementState->move_direction); @@ -1129,7 +1129,7 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t AI2gMovementState_BadnessCharacter = ioCharacter; /* determine which directions we should be moving in by building the badness structure */ - AI2iMovementState_ResetBadness(&AI2gMovementState_NumBadnessValues, AI2cMovementState_MaxBadnessValues, + AI2iMovementState_ResetBadness(&AI2gMovementState_NumBadnessValues, AI2cMovementState_MaxBadnessValues, AI2gMovementState_BadnessValues); for (itr = 0, collision = ioMovementState->collision; itr < ioMovementState->numCollisions; itr++, collision++) { AI2iMovementState_AddBadnessFromCollision(&AI2gMovementState_NumBadnessValues, AI2cMovementState_MaxBadnessValues, @@ -1139,7 +1139,7 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t #if TOOL_VERSION /* copy the current badness ring into the character for storage */ ioMovementState->numBadnessValues = AI2gMovementState_NumBadnessValues; - UUrMemory_MoveFast(AI2gMovementState_BadnessValues, ioMovementState->badnesslist, + UUrMemory_MoveFast(AI2gMovementState_BadnessValues, ioMovementState->badnesslist, AI2cMovementState_MaxBadnessValues * sizeof(AI2tBadnessValue)); #endif @@ -1152,7 +1152,7 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t } } - ioMovementState->move_direction = AI2iMovementState_LeastBadDirection(&AI2gMovementState_NumBadnessValues, AI2cMovementState_MaxBadnessValues, + ioMovementState->move_direction = AI2iMovementState_LeastBadDirection(&AI2gMovementState_NumBadnessValues, AI2cMovementState_MaxBadnessValues, AI2gMovementState_BadnessValues, starting_dir); AI2gMovementState_BadnessCharacter = NULL; @@ -1197,7 +1197,7 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t } else { // we aren't standing still, so unset this field ioMovementState->turning_to_face_direction = AI2cAngle_None; - + // we are moving and face in a fixed direction based on our current movement direction. // however, we may change this movement direction, **UNLESS** we are locked to a particular // direction by a PathRelative facing command. @@ -1221,7 +1221,7 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t } /* looking or aiming? */ - if ((ioCharacter->inventory.weapons[0] != NULL) && ((movement_mode != AI2cMovementMode_NoAim_Run) && + if ((ioCharacter->inventory.weapons[0] != NULL) && ((movement_mode != AI2cMovementMode_NoAim_Run) && (movement_mode != AI2cMovementMode_NoAim_Walk))) { currently_aiming = UUcTrue; } else { @@ -1263,7 +1263,7 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t break; case AI2cAimingMode_LookInDirection: - aim_direction = MUrATan2(aim_data->lookInDirection.vector.x, + aim_direction = MUrATan2(aim_data->lookInDirection.vector.x, aim_data->lookInDirection.vector.z); UUmTrig_ClipLow(aim_direction); @@ -1307,7 +1307,7 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t case AI2cMovementMode_Walk: disable_sidestep = ioMovementState->no_walking_sidestep; break; - + case AI2cMovementMode_NoAim_Run: case AI2cMovementMode_Run: disable_sidestep = ioMovementState->no_running_sidestep; @@ -1365,21 +1365,21 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t } } else { /* determine whether we need to change facing direction in order to keep aiming where we are */ - + if (ioMovementState->move_direction == AI2cAngle_None) { // we aren't trying to move, so unset this field ioMovementState->turning_on_spot = UUcFalse; - + if (ioMovementState->turning_to_face_direction != AI2cAngle_None) { // if we're already turning to a particular direction, then stay // with those orders if we can facing_direction = ioMovementState->turning_to_face_direction; } - + // how well will our current facing direction satisfy our aiming? delta_aim = desired_facing_direction - facing_direction; UUmTrig_Clip(delta_aim); - + cur_anim_type = ONrCharacter_GetAnimType(ioCharacter); switch(cur_anim_type) { case ONcAnimType_Muro_Thunderbolt: @@ -1423,7 +1423,7 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t } else { aim_range = AI2cMovement_StandingLookRange; } - + // if this isn't satisfied, turn to where we're aiming. if ((delta_aim > aim_range) && (delta_aim < M3c2Pi - aim_range)) { facing_direction = desired_facing_direction; @@ -1433,7 +1433,7 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t // calculate which direction we want to aim in relative to our currently planned facing direction delta_aim = desired_facing_direction - facing_direction; UUmTrig_ClipAbsPi(delta_aim); - + if (in_melee && !disable_sidestep) { // facing range is deliberately made small so that we face directly at target // and can block if necessary @@ -1454,7 +1454,7 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t ioMovementState->move_direction, disable_sidestep, disable_walk_backwards); /* COrConsole_Printf("try new direction (facing %f desired %f -> delta %f, invalid %s), found %s from (desire %f, move %f) [was %s]", facing_direction, desired_facing_direction, delta_aim, - (ioMovementState->invalid_movement_direction) ? "yes" : "no", AI2cMovementDirectionName[new_movement_direction], + (ioMovementState->invalid_movement_direction) ? "yes" : "no", AI2cMovementDirectionName[new_movement_direction], desired_facing_direction, ioMovementState->move_direction, AI2cMovementDirectionName[ioMovementState->current_direction]);*/ if (new_movement_direction != ioMovementState->current_direction) { @@ -1465,7 +1465,7 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t ioMovementState->invalid_movement_direction = UUcFalse; } - + // update our facing direction for this new movement direction facing_direction = ioMovementState->move_direction - AI2cMovementDirection_Offset[ioMovementState->current_direction]; @@ -1530,31 +1530,31 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t // use these to determine our forward and perpendicular distance to the path point. theta = ioCharacter->facing - AI2cMovementDirection_Offset[ioMovementState->current_direction]; UUmTrig_ClipLow(theta); - + costheta = MUrCos(theta); sintheta = MUrSin(theta); - + distance_fwd = (float)fabs(sintheta * ioMovementState->vector_to_point.x + costheta * ioMovementState->vector_to_point.z); distance_perp = (float)fabs(costheta * ioMovementState->vector_to_point.x - sintheta * ioMovementState->vector_to_point.z); - + // only execute this code if it's relevant will_overturn = UUcFalse; if (check_overturn) { // how closely must we hit this point? point_hit_distance = AI2iMovementState_GetPointHitDistance(ioCharacter, ioMovementState, ioMovementState->next_path_point); - + // what turning radius is required to hit this point with the desired precision? if (distance_perp - point_hit_distance > 0.1f) { distance_perp -= point_hit_distance; - + // trigonometry tells us that r = (perp^2 + fwd^2) / 2 * perp required_turning_radius = (UUmSQR(distance_perp) + UUmSQR(distance_fwd)) / (2.0f * distance_perp); } else { // we are already on target to hit the point within the point hit distance, don't worry about it required_turning_radius = 1000.0f; } - + // what is our current turning radius? if ((ioCharacter->inventory.weapons[0] == NULL) || (!currently_aiming)) { have_weapon = UUcFalse; @@ -1567,11 +1567,11 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t movement_rate = ONrCharacterClass_MovementSpeed(ioCharacter->characterClass, ioMovementState->current_direction, movement_mode, have_weapon, have_twohanded_weapon); turning_radius = movement_rate / turning_rate; - + // can we make it to the point? - will_overturn = (turning_radius > AI2cTurningRadius_SafetyMargin * required_turning_radius); + will_overturn = (turning_radius > AI2cTurningRadius_SafetyMargin * required_turning_radius); } - + // work out if we need to check overshoot will_overshoot = UUcFalse; check_overshoot = AI2iMovementState_StopAtPathPoint(ioCharacter, ioMovementState, &stopatpoint_radius); @@ -1597,11 +1597,11 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t stopping_distance = ONrCharacterClass_StoppingDistance(ioCharacter->characterClass, ioMovementState->current_direction, movement_mode); distance_to_stop_in = AI2cStoppingDistance_SafetyMargin * (distance_fwd + stopatpoint_radius); - + will_overshoot = (stopping_distance > distance_to_stop_in); } } - + if ((will_overturn || will_overshoot) && can_slow_down) { // could we make it to the point if walking? if (check_overturn) { @@ -1611,20 +1611,20 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t turning_radius = movement_rate / turning_rate; will_overturn = (turning_radius > AI2cTurningRadius_SafetyMargin * required_turning_radius); } - + if (check_overshoot) { // what is our current stopping distance? - stopping_distance = ONrCharacterClass_StoppingDistance(ioCharacter->characterClass, ioMovementState->current_direction, slow_mode); + stopping_distance = ONrCharacterClass_StoppingDistance(ioCharacter->characterClass, ioMovementState->current_direction, slow_mode); will_overshoot = (stopping_distance > distance_to_stop_in); } - + if (!(will_overturn || will_overshoot)) { // slow to a walking pace until we reach desired facing, or hit this point successfully ioMovementState->temporarily_slowed = UUcTrue; ioMovementState->temporary_mode = movement_mode = slow_mode; } } - + if (will_overturn) { // stop and turn on the spot until we reach 'close enough' to the desired facing ioMovementState->turning_on_spot = UUcTrue; @@ -1646,7 +1646,7 @@ static void AI2iMovementState_Calculate_Movement(ONtCharacter *ioCharacter, AI2t } } } - + // stop so we don't overshoot if (ioMovementState->overshoot_timer) { actual_movement_direction = AI2cMovementDirection_Stopped; @@ -1720,7 +1720,7 @@ static UUtBool AI2iMovementState_FinalPathPoint(ONtCharacter *ioCharacter, AI2tM { if (ioMovementState->grid_current_point < ioMovementState->grid_num_points - 1) return UUcFalse; - + return (ioCharacter->pathState.path_current_node == ioCharacter->pathState.path_num_nodes - 1); } @@ -1729,10 +1729,10 @@ static UUtBool AI2iMovementState_StopAtPathPoint(ONtCharacter *ioCharacter, AI2t // only consider stopping at destination if (!AI2iMovementState_FinalPathPoint(ioCharacter, ioMovementState)) return UUcFalse; - + return AI2rPath_StopAtDest(ioCharacter, outRadius); } - + static float AI2iMovementState_GetPointHitDistance(ONtCharacter *ioCharacter, AI2tMovementState *ioMovementState, AStPathPoint *inPathPoint) { float stopping_tolerance, hit_tolerance; @@ -1919,7 +1919,7 @@ static void AI2iMovementState_AddBadnessIncrements(UUtUns32 *ioNumValues, UUtUns } } -static AI2tBadnessValue *AI2iMovementState_NewBadnessValue(UUtUns32 *ioNumValues, UUtUns32 inMaxNumValues, AI2tBadnessValue *ioValues, +static AI2tBadnessValue *AI2iMovementState_NewBadnessValue(UUtUns32 *ioNumValues, UUtUns32 inMaxNumValues, AI2tBadnessValue *ioValues, AI2tBadnessValue *inInsertPtr) { AI2tBadnessValue *newptr; @@ -2241,7 +2241,7 @@ static AI2tCollision *AI2iMovementState_FindCollision(ONtCharacter *ioCharacter, return collision; } else { return NULL; - } + } } // find an existing collision or create a new collision if we don't already have one @@ -2271,8 +2271,8 @@ static AI2tCollision *AI2iMovementState_MakeCollision(ONtCharacter *ioCharacter, // the direction to the collision is the inverse of the normal collision->direction = MUrATan2(-inPlane->a, -inPlane->c); - UUmTrig_ClipLow(collision->direction); - + UUmTrig_ClipLow(collision->direction); + AI2_ERROR(AI2cStatus, AI2cSubsystem_Movement, AI2cError_Movement_Collision, ioCharacter, inCollisionID, inPoint, inPlane, &collision->direction); } else { @@ -2465,7 +2465,7 @@ void AI2rMovementState_RenderCollision(M3tPoint3D *inPoint, UUtUns32 inNumCollis do { angle += AI2cMovementState_Render_BadnessAngle; - + if (angle > nextptr->angle) { angle = nextptr->angle; value = nextptr->value; @@ -2481,7 +2481,7 @@ void AI2rMovementState_RenderCollision(M3tPoint3D *inPoint, UUtUns32 inNumCollis MUmVector_Add(line_end, line_end, center_pt); M3rGeom_Line_Light(&line_start, &line_end, IMcShade_Red); } while (!exit); - + ptr = nextptr; } while (ptr != inBadnessValues); @@ -2498,7 +2498,7 @@ void AI2rMovementState_RenderPath(ONtCharacter *ioCharacter, AI2tMovementState * #if TOOL_VERSION // draw our wall collisions - AI2rMovementState_RenderCollision(&ioCharacter->actual_position, ioMovementState->numCollisions, ioMovementState->collision, + AI2rMovementState_RenderCollision(&ioCharacter->actual_position, ioMovementState->numCollisions, ioMovementState->collision, ioMovementState->numBadnessValues, ioMovementState->badnesslist); #endif @@ -2536,13 +2536,13 @@ void AI2rMovementState_RenderPath(ONtCharacter *ioCharacter, AI2tMovementState * line_end.z += radius; M3rGeom_Line_Light(&line_start, &line_end, IMcShade_Blue); - line_start.x -= 2 * radius; + line_start.x -= 2 * radius; M3rGeom_Line_Light(&line_start, &line_end, IMcShade_Blue); line_end.z -= 2 * radius; M3rGeom_Line_Light(&line_start, &line_end, IMcShade_Blue); - line_start.x += 2 * radius; + line_start.x += 2 * radius; M3rGeom_Line_Light(&line_start, &line_end, IMcShade_Blue); jack_shade = IMcShade_Red; diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementState.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementState.h index 3a65b44..6294010 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementState.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementState.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_MovementState.h - + AUTHOR: Chris Butcher - + CREATED: July 29, 2000 - + PURPOSE: Incarnated Movement AI for Oni - + Copyright (c) Bungie Software, 2000 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementStub.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementStub.c index 8bc31a0..3b32d65 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementStub.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementStub.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_MovementStub.c - + AUTHOR: Chris Butcher - + CREATED: July 29, 2000 - + PURPOSE: Non-incarnated Movement AI for Oni - + Copyright (c) Bungie Software, 2000 */ @@ -35,7 +35,7 @@ void AI2iMovementStub_SetupPath(ONtCharacter *ioCharacter); // -- high-level control functions void AI2rMovementStub_Initialize(ONtCharacter *ioCharacter, AI2tMovementState *inState) -{ +{ ioCharacter->movementStub.cur_facing = ioCharacter->facing; ioCharacter->movementStub.cur_point = ioCharacter->location; @@ -115,7 +115,7 @@ void AI2rMovementStub_Update(ONtCharacter *ioCharacter) movement_mode = ioCharacter->movementOrders.movementMode; if (movement_mode == AI2cMovementMode_Default) movement_mode = AI2rMovement_Default(ioCharacter); - + ioCharacter->movementStub.cur_distance += ONrCharacterClass_MovementSpeed(ioCharacter->characterClass, AI2cMovementDirection_Forward, movement_mode, has_weapon, twohanded_weapon); if (ioCharacter->movementStub.cur_distance > ioCharacter->movementStub.path_distance) { @@ -168,7 +168,7 @@ void AI2rMovementStub_Update(ONtCharacter *ioCharacter) floor_height = UUmMax(floor_height, ioCharacter->currentNode->roomData.origin.y + 2.0f); } - if ((ioCharacter->movementStub.cur_point.y < floor_height + AI2cMovementStub_StickToFloorHeight) && + if ((ioCharacter->movementStub.cur_point.y < floor_height + AI2cMovementStub_StickToFloorHeight) && (ioCharacter->movementStub.cur_point.y > floor_height - AI2cMovementStub_StickToFloorHeight)) { ioCharacter->movementStub.cur_point.y = floor_height; } @@ -177,8 +177,8 @@ void AI2rMovementStub_Update(ONtCharacter *ioCharacter) /* COrConsole_Printf("dist %f of %f, position (%f %f %f)... path (%f %f %f) - (%f %f %f)", ioCharacter->movementStub.cur_distance, ioCharacter->movementStub.path_distance, - ioCharacter->movementStub.cur_point.x, ioCharacter->movementStub.cur_point.y, ioCharacter->movementStub.cur_point.z, - ioCharacter->movementStub.path_start.x, ioCharacter->movementStub.path_start.y, ioCharacter->movementStub.path_start.z, + ioCharacter->movementStub.cur_point.x, ioCharacter->movementStub.cur_point.y, ioCharacter->movementStub.cur_point.z, + ioCharacter->movementStub.path_start.x, ioCharacter->movementStub.path_start.y, ioCharacter->movementStub.path_start.z, ioCharacter->movementStub.path_end.x, ioCharacter->movementStub.path_end.y, ioCharacter->movementStub.path_end.z);*/ } } diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementStub.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementStub.h index 74919ff..f6c9231 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementStub.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_MovementStub.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_MovementStub.h - + AUTHOR: Chris Butcher - + CREATED: July 29, 2000 - + PURPOSE: Non-incarnated Movement AI for Oni - + Copyright (c) Bungie Software, 2000 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Neutral.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Neutral.c index 7a3fdd5..335e20c 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Neutral.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Neutral.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Neutral.c - + AUTHOR: Chris Butcher - + CREATED: July 13, 2000 - + PURPOSE: Neutral AI for Oni - + Copyright (c) Bungie Software, 2000 */ @@ -61,7 +61,7 @@ UUtBool AI2rNeutral_ChangeBehavior(ONtCharacter *ioCharacter, UUtUns16 inNeutral if (ioCharacter->charType != ONcChar_AI2) { return UUcFalse; } - + if (!inInitialize && (ioCharacter->ai2State.neutralBehaviorID == inNeutralID)) { // we already have this neutral behavior return (ioCharacter->ai2State.neutralBehaviorID != (UUtUns16) -1); @@ -98,7 +98,7 @@ static UUtBool AI2iNeutral_CheckStraightLinePath(ONtCharacter *ioCharacter, ONtC UUtUns8 stop_weight; UUtBool found_path, localmove_escape; ONtCharacter *prev_ignorechar; - + ONrCharacter_GetPathfindingLocation(ioCharacter, &our_pt); ONrCharacter_GetPathfindingLocation(inTarget, &player_pt); @@ -242,7 +242,7 @@ UUtBool AI2rNeutral_CheckTrigger(ONtCharacter *ioCharacter, ONtCharacter *inTarg ioCharacter->ai2State.neutralLastCheck = current_time + AI2cNeutral_EnemyScareFrames; return UUcFalse; } - } + } } #if 0 @@ -403,7 +403,7 @@ void AI2rNeutral_Exit(ONtCharacter *ioCharacter) { UUtBool we_are_aborting; - + we_are_aborting = ((neutral_state->current_line == -1) || (neutral_state->current_line < neutral_state->behavior.num_lines)); AI2rNeutral_Stop(ioCharacter, UUcTrue, we_are_aborting, UUcFalse, UUcFalse); @@ -618,7 +618,7 @@ void AI2rNeutral_Update(ONtCharacter *ioCharacter) ONtActiveCharacter *target_active, *active_character = ONrGetActiveCharacter(ioCharacter); UUmAssert(ioCharacter->ai2State.currentGoal == AI2cGoal_Neutral); - neutral_state = &ioCharacter->ai2State.currentState->state.neutral; + neutral_state = &ioCharacter->ai2State.currentState->state.neutral; UUmAssertReadPtr(active_character, sizeof(ONtActiveCharacter)); if ((active_character == NULL) || @@ -692,7 +692,7 @@ void AI2rNeutral_Update(ONtCharacter *ioCharacter) if (neutral_state->behavior.flags & AI2cNeutralBehaviorFlag_NoResume) { ioCharacter->ai2State.neutralFlags |= AI2cNeutralFlag_DisableResume; } - + // make note of the neutral interaction ioCharacter->neutral_interaction_char = neutral_state->target_character; neutral_state->target_character->neutral_interaction_char = ioCharacter; @@ -753,7 +753,7 @@ void AI2rNeutral_Update(ONtCharacter *ioCharacter) } else { // reset our timer, and hail the target neutral_state->hail_timer = AI2cNeutral_HailRepeatTimer + UUmRandomRange(0, AI2cNeutral_HailRandomTimer); - + AI2iNeutral_PlayTriggerSound(ioCharacter, neutral_state); if (active_character != NULL) { @@ -923,7 +923,7 @@ void AI2rNeutral_Update(ONtCharacter *ioCharacter) } } -static UUtBool AI2iNeutral_ConversationAnimation(ONtCharacter *ioCharacter, UUtUns16 inAnimType, +static UUtBool AI2iNeutral_ConversationAnimation(ONtCharacter *ioCharacter, UUtUns16 inAnimType, UUtBool inAnimateOnce, UUtBool inRepeatAnimation, UUtBool *ioAnimStarted) { ONtActiveCharacter *active_character = ONrGetActiveCharacter(ioCharacter); @@ -937,7 +937,7 @@ static UUtBool AI2iNeutral_ConversationAnimation(ONtCharacter *ioCharacter, UUtU if (active_character->curAnimType == inAnimType) { // we're playing the animation *ioAnimStarted = UUcTrue; - + // block until animation finishes return UUcTrue; diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Neutral.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Neutral.h index 24fab04..2b2cb9d 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Neutral.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Neutral.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Neutral.h - + AUTHOR: Chris Butcher - + CREATED: July 13, 2000 - + PURPOSE: Neutral-Character Interaction AI for Oni - + Copyright (c) Bungie Software, 2000 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Panic.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Panic.c index 04ac112..7fa756f 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Panic.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Panic.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Panic.c - + AUTHOR: Chris Butcher - + CREATED: July 16, 2000 - + PURPOSE: Noncombatant AI for Oni - + Copyright (c) Bungie Software, 2000 */ @@ -88,7 +88,7 @@ void AI2rPanic_Update(ONtCharacter *ioCharacter) ONtActiveCharacter *active_character; UUmAssert(ioCharacter->ai2State.currentGoal == AI2cGoal_Panic); - panic_state = &ioCharacter->ai2State.currentState->state.panic; + panic_state = &ioCharacter->ai2State.currentState->state.panic; current_time = ONrGameState_GetGameTime(); if (current_time > panic_state->panic_endtime) { @@ -150,7 +150,7 @@ void AI2rPanic_Update(ONtCharacter *ioCharacter) enemy_behind = UUcTrue; } } - + // send a keypress through to the executor telling us to get up AI2rExecutor_MoveOverride(ioCharacter, ((enemy_behind) ? LIc_BitMask_Forward : LIc_BitMask_Backward) | ((panic_state->kneeling) ? LIc_BitMask_Crouch : 0)); @@ -166,13 +166,13 @@ void AI2rPanic_Update(ONtCharacter *ioCharacter) AI2rMovement_ChangeMovementMode(ioCharacter, AI2cMovementMode_Creep); AI2rMovement_StopAiming(ioCharacter); } - + if (panic_state->currently_dazed) { // don't move - AI2rPath_Halt(ioCharacter); + AI2rPath_Halt(ioCharacter); AI2rMovement_StopAiming(ioCharacter); AI2rMovement_StopGlancing(ioCharacter); - } + } } } @@ -284,7 +284,7 @@ UUtBool AI2rCharacter_IsDangerousContact(ONtCharacter *ioCharacter, ONtCharacter if (inEntry->strength <= AI2cContactStrength_Forgotten) { // this is no longer a factor return UUcFalse; - + } else if (AI2rKnowledge_IsHurtEvent(inEntry->last_type)) { // always worry about this return UUcTrue; @@ -452,7 +452,7 @@ void AI2rCharacter_Panic(ONtCharacter *ioCharacter, AI2tKnowledgeEntry *inEntry, #if AI_VERBOSE_PANIC COrConsole_Printf("%s: now being panicked by %s (previous %s)", ioCharacter->player_name, inEntry->enemy->player_name, - (panic_state->panic_cause == NULL) ? "none" : + (panic_state->panic_cause == NULL) ? "none" : ((panic_state->panic_cause->enemy == NULL) ? "none" : panic_state->panic_cause->enemy->player_name)); #endif // switch to being panicked by this character diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Panic.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Panic.h index a404865..975e2a6 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Panic.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Panic.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Panic.h - + AUTHOR: Chris Butcher - + CREATED: July 16, 2000 - + PURPOSE: Noncombatant AI for Oni - + Copyright (c) Bungie Software, 2000 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Path.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Path.c index e1d2351..c3f6f0b 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Path.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Path.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Path.c - + AUTHOR: Chris Butcher - + CREATED: July 29, 2000 - + PURPOSE: High-level Pathfinding AI for Oni - + Copyright (c) Bungie Software, 2000 */ @@ -73,7 +73,7 @@ static void AI2iPath_CheckDestination(ONtCharacter *ioCharacter); // -- global routines void AI2rPath_Initialize(ONtCharacter *ioCharacter) -{ +{ // we have no destination ioCharacter->pathState.at_destination = UUcTrue; ioCharacter->pathState.at_finalpoint = UUcTrue; @@ -196,10 +196,10 @@ void AI2rPath_Update(ONtCharacter *ioCharacter) if (ioCharacter->pathState.destinationType == AI2cDestinationType_None) { // we are halted, stop our pathfinding AI2rPath_Repath(ioCharacter, UUcTrue); - } else { + } else { // check to see whether we've received a new destination this frame if ((ioCharacter->pathState.at_destination != ioCharacter->pathState.prev_at_destination) || - (MUmVector_GetDistanceSquared(ioCharacter->pathState.destinationLocation, ioCharacter->pathState.prev_destination) > + (MUmVector_GetDistanceSquared(ioCharacter->pathState.destinationLocation, ioCharacter->pathState.prev_destination) > UUmSQR(AI2cNewDestination_Distance))) { AI2iPath_NewDestination(ioCharacter); } @@ -295,7 +295,7 @@ void AI2rPath_FindGhostWaypoint(ONtCharacter *ioCharacter, M3tPoint3D *inStartPo static UUtBool AI2iPath_FindGlobalPath(ONtCharacter *ioCharacter, PHtGraph *inGraph) { UUtBool gotpath; - + if (ioCharacter->pathState.path_start_node == ioCharacter->pathState.path_end_node) { // the path is entirely within one node ioCharacter->pathState.path_num_nodes = 1; @@ -324,7 +324,7 @@ static UUtBool AI2iPath_FindGlobalPath(ONtCharacter *ioCharacter, PHtGraph *inGr } // set up to follow this path - ioCharacter->pathState.path_current_node = 0; + ioCharacter->pathState.path_current_node = 0; ioCharacter->pathState.last_pathfinding_error = AI2cError_Pathfinding_NoError; return UUcTrue; @@ -372,7 +372,7 @@ static UUtBool AI2iPath_NextNode(ONtCharacter *ioCharacter) UUtBool success; ioCharacter->pathState.path_current_node += 1; - + if (ioCharacter->pathState.path_current_node >= ioCharacter->pathState.path_num_nodes) { // we hit the end of our path ioCharacter->pathState.path_current_node = 0; @@ -435,7 +435,7 @@ static UUtBool AI2iPath_MakePath(ONtCharacter *ioCharacter, UUtBool inForce) } #endif - // calculate the path nodes at the start and end of this path + // calculate the path nodes at the start and end of this path locationStart = ioCharacter->actual_position; locationEnd = ioCharacter->pathState.destinationLocation; locationEnd.y += PHcWorldCoord_YOffset; @@ -624,7 +624,7 @@ UUtBool AI2rPath_StopAtDest(ONtCharacter *ioCharacter, float *outDestRadius) { if (ioCharacter->pathState.destinationType == AI2cDestinationType_None) { if (AI2rMovement_HasMovementModifiers(ioCharacter)) { - // we are being completely controlled by our movement modifiers - + // we are being completely controlled by our movement modifiers - // never stop moving if (outDestRadius != NULL) { *outDestRadius = 0; @@ -720,9 +720,9 @@ void AI2rPath_Report(ONtCharacter *ioCharacter, UUtBool inVerbose, AI2tReportFun break; case AI2cDestinationType_Point: - sprintf(reportbuf, " destination: point %f %f %f, tolerance %f", - ioCharacter->pathState.destinationLocation.x, - ioCharacter->pathState.destinationLocation.y, + sprintf(reportbuf, " destination: point %f %f %f, tolerance %f", + ioCharacter->pathState.destinationLocation.x, + ioCharacter->pathState.destinationLocation.y, ioCharacter->pathState.destinationLocation.z, ioCharacter->pathState.destinationData.point_data.required_distance); strcat(reportbuf, (ioCharacter->pathState.destinationData.point_data.stop_at_point) ? " (stop)" : " (keep moving)"); @@ -734,8 +734,8 @@ void AI2rPath_Report(ONtCharacter *ioCharacter, UUtBool inVerbose, AI2tReportFun case AI2cDestinationType_FollowCharacter: sprintf(reportbuf, " following %s (currently going to %f %f %f)", ioCharacter->pathState.destinationData.followcharacter_data.character->player_name, - ioCharacter->pathState.destinationLocation.x, - ioCharacter->pathState.destinationLocation.y, + ioCharacter->pathState.destinationLocation.x, + ioCharacter->pathState.destinationLocation.y, ioCharacter->pathState.destinationLocation.z); break; @@ -752,7 +752,7 @@ void AI2rPath_Report(ONtCharacter *ioCharacter, UUtBool inVerbose, AI2tReportFun } else if (ioCharacter->pathState.at_finalpoint) { sprintf(reportbuf, " at final point, orienting"); inFunction(reportbuf); - + } else { sprintf(reportbuf, " path from %f %f %f (BNV %d) to %f %f %f (BNV %d), currently in %d of %d nodes", ioCharacter->pathState.path_start_location.x, ioCharacter->pathState.path_start_location.y, ioCharacter->pathState.path_start_location.z, @@ -853,13 +853,13 @@ void AI2rPath_RenderPath(ONtCharacter *ioCharacter) line_end.z += radius; M3rGeom_Line_Light(&line_start, &line_end, shade); - line_start.x -= 2 * radius; + line_start.x -= 2 * radius; M3rGeom_Line_Light(&line_start, &line_end, shade); line_end.z -= 2 * radius; M3rGeom_Line_Light(&line_start, &line_end, shade); - line_start.x += 2 * radius; + line_start.x += 2 * radius; M3rGeom_Line_Light(&line_start, &line_end, shade); } diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Path.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Path.h index 391740e..69627c4 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Path.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Path.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Path.h - + AUTHOR: Chris Butcher - + CREATED: July 29, 2000 - + PURPOSE: High-level Pathfinding AI for Oni - + Copyright (c) Bungie Software, 2000 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Patrol.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Patrol.c index 93d157f..5add4e2 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Patrol.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Patrol.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Patrol.c - + AUTHOR: Michael Evans, Chris Butcher - + CREATED: November 15, 1999 - + PURPOSE: Patrol AI for Oni - + Copyright (c) 1999 */ @@ -517,7 +517,7 @@ static void AI2iPatrol_Shooting_Setup(ONtCharacter *ioCharacter, AI2tPatrolState ioCharacter->characterClass->ai2_behavior.combat_parameters.shooting_skill); ioPatrolState->targeting_setup = UUcTrue; } - + // set up our current weapon state ioPatrolState->current_weapon = NULL; AI2iPatrol_CheckTargetingWeapon(ioCharacter, ioPatrolState); @@ -712,7 +712,7 @@ static void AI2iPatrol_DoWaypoint(ONtCharacter *ioCharacter, AI2tPatrolState *io case AI2cWaypointType_MoveToFlag: found = ONrLevel_Flag_ID_To_Flag(waypoint->data.moveToFlag.flag, &flag); - + if (!found) { AI2_ERROR(AI2cError, AI2cSubsystem_Patrol, AI2cError_Patrol_NoSuchFlag, ioCharacter, waypoint->data.moveToFlag.flag, inWaypointIndex, ioPatrolState, 0); @@ -735,7 +735,7 @@ static void AI2iPatrol_DoWaypoint(ONtCharacter *ioCharacter, AI2tPatrolState *io case AI2cWaypointType_LookAtFlag: found = ONrLevel_Flag_ID_To_Flag(waypoint->data.lookAtFlag.lookFlag, &flag); - + if (!found) { AI2_ERROR(AI2cError, AI2cSubsystem_Patrol, AI2cError_Patrol_NoSuchFlag, ioCharacter, waypoint->data.lookAtFlag.lookFlag, inWaypointIndex, ioPatrolState, 0); @@ -750,7 +750,7 @@ static void AI2iPatrol_DoWaypoint(ONtCharacter *ioCharacter, AI2tPatrolState *io case AI2cWaypointType_MoveAndFaceFlag: found = ONrLevel_Flag_ID_To_Flag(waypoint->data.moveAndFaceFlag.faceFlag, &flag); - + if (!found) { AI2_ERROR(AI2cError, AI2cSubsystem_Patrol, AI2cError_Patrol_NoSuchFlag, ioCharacter, waypoint->data.moveAndFaceFlag.faceFlag, inWaypointIndex, @@ -789,7 +789,7 @@ static void AI2iPatrol_DoWaypoint(ONtCharacter *ioCharacter, AI2tPatrolState *io case AI2cWaypointType_MoveThroughFlag: found = ONrLevel_Flag_ID_To_Flag(waypoint->data.moveToFlag.flag, &flag); - + if (!found) { AI2_ERROR(AI2cError, AI2cSubsystem_Patrol, AI2cError_Patrol_NoSuchFlag, ioCharacter, waypoint->data.moveToFlag.flag, inWaypointIndex, @@ -828,7 +828,7 @@ static void AI2iPatrol_DoWaypoint(ONtCharacter *ioCharacter, AI2tPatrolState *io case AI2cWaypointType_Guard: found = ONrLevel_Flag_ID_To_Flag(waypoint->data.guard.flag, &flag); - + if (!found) { AI2_ERROR(AI2cError, AI2cSubsystem_Patrol, AI2cError_Patrol_NoSuchFlag, ioCharacter, waypoint->data.guard.flag, inWaypointIndex, ioPatrolState, 0); @@ -844,7 +844,7 @@ static void AI2iPatrol_DoWaypoint(ONtCharacter *ioCharacter, AI2tPatrolState *io case AI2cWaypointType_MoveNearFlag: found = ONrLevel_Flag_ID_To_Flag(waypoint->data.moveNearFlag.flag, &flag); - + if (!found) { AI2_ERROR(AI2cError, AI2cSubsystem_Patrol, AI2cError_Patrol_NoSuchFlag, ioCharacter, waypoint->data.moveNearFlag.flag, inWaypointIndex, @@ -884,7 +884,7 @@ static void AI2iPatrol_DoWaypoint(ONtCharacter *ioCharacter, AI2tPatrolState *io case AI2cWaypointType_ShootAtFlag: found = ONrLevel_Flag_ID_To_Flag(waypoint->data.shootAtFlag.flag, &flag); - + if (!found) { AI2_ERROR(AI2cError, AI2cSubsystem_Patrol, AI2cError_Patrol_NoSuchFlag, ioCharacter, waypoint->data.shootAtFlag.flag, inWaypointIndex, diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Patrol.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Patrol.h index c8942d2..c1e0a37 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Patrol.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Patrol.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Patrol.h - + AUTHOR: Michael Evans - + CREATED: November 15, 1999 - + PURPOSE: Patrol AI for Oni - + Copyright (c) 1999 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Pursuit.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Pursuit.c index 09056c6..de5ecb7 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Pursuit.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Pursuit.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Pursuit.c - + AUTHOR: Chris Butcher - + CREATED: June 21, 2000 - + PURPOSE: Pursuit AI for Oni - + Copyright (c) 2000 */ @@ -55,7 +55,7 @@ enum { AI2cPursuitCheck_PostGlance, AI2cPursuitCheck_PostArrival, AI2cPursuitCheck_ChangeTarget, - + AI2cPursuitCheck_Max }; @@ -350,7 +350,7 @@ static UUtBool AI2iPursuit_ChangeMode(ONtCharacter *ioCharacter, AI2tPursuitStat UUmAssert((new_mode > AI2cPursuitMode_None) && (new_mode < AI2cPursuitMode_Max)); #if DEBUG_VERBOSE_PURSUIT - COrConsole_Printf("%s: new mode is %s%s", ioCharacter->player_name, + COrConsole_Printf("%s: new mode is %s%s", ioCharacter->player_name, AI2cPursuitModeName[new_mode], force_change ? " (forced)" : ""); #endif @@ -386,7 +386,7 @@ static void AI2iPursuit_BeginMode(ONtCharacter *ioCharacter, AI2tPursuitState *i M3tPoint3D vector_to_contact; float angle_to_contact; ONtActionMarker *found_alarm; - + UUmAssert((ioPursuitState->current_mode > AI2cPursuitMode_None) && (ioPursuitState->current_mode < AI2cPursuitMode_Max)); if ((ioPursuitState->pause_timer > 0) && (ioPursuitState->current_mode != AI2cPursuitMode_Forget)) { @@ -538,7 +538,7 @@ static void AI2iPursuit_NextMode(ONtCharacter *ioCharacter, AI2tPursuitState *io ioPursuitState->current_mode = AI2cPursuitMode_Forget; } break; - + case AI2cPursuitMode_Look: // we've finished looking around upon reaching the contact area. if (!AI2iPursuit_DesirePursuit(ioCharacter, ioPursuitState, AI2cPursuitCheck_PostArrival)) { @@ -588,7 +588,7 @@ static void AI2iPursuit_GoTo_Update(ONtCharacter *ioCharacter, AI2tPursuitState // have we reached a point where we should be able to see the source of the contact? finished_goto = UUcFalse; - if ((ioCharacter->pathState.at_destination) || + if ((ioCharacter->pathState.at_destination) || (ioCharacter->pathState.distance_to_destination_squared < UUmSQR(AI2cPursuit_GoToContact_CloseDist))) { // we are very close to the contact. finished_goto = UUcTrue; @@ -941,10 +941,10 @@ void AI2rPursuit_Report(ONtCharacter *ioCharacter, AI2tPursuitState *ioPursuitSt { char reportbuf[256], tempbuf[64]; - sprintf(reportbuf, " strength %s (max %s)", + sprintf(reportbuf, " strength %s (max %s)", AI2cContactStrengthName[ioPursuitState->target->strength], AI2cContactStrengthName[ioPursuitState->target->highest_strength]); - + if (ioPursuitState->pause_timer > 0) { sprintf(tempbuf, ", paused: %d frames", ioPursuitState->pause_timer); strcat(reportbuf, tempbuf); diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Pursuit.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Pursuit.h index 97286f7..754a12f 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Pursuit.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Pursuit.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Pursuit.h - + AUTHOR: Chris Butcher - + CREATED: June 21, 2000 - + PURPOSE: Pursuit AI for Oni - + Copyright (c) 2000 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Script.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Script.c index 81ca82e..50b4928 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Script.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Script.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Script.c - + AUTHOR: Chris Butcher - + CREATED: April 04, 2000 - + PURPOSE: AI interface to the scripting system for Oni - + Copyright (c) Bungie Software, 2000 */ @@ -246,7 +246,7 @@ static UUtError AI2iScript_Skill_Select(SLtErrorContext *inErrorContext, UUtUns3 UUrMemory_MoveFast(AI2gSkillEdit_TargetPtr, &AI2gSkillEdit_SavedCopy, sizeof(AI2tShootingSkill)); AI2gSkillEdit_Active = UUcTrue; - COrConsole_Printf("Now editing '%s' shooting skill with weapon %d '%s'", + COrConsole_Printf("Now editing '%s' shooting skill with weapon %d '%s'", TMrInstance_GetInstanceName(AI2gSkillEdit_TargetClass), AI2gSkillEdit_TargetIndex, TMrInstance_GetInstanceName(AI2gSkillEdit_TargetWeapon)); return UUcError_None; @@ -486,7 +486,7 @@ static UUtError AI2iScript_Reset(SLtErrorContext *inErrorContext, UUtUns32 inPar if (inParameterListLength >= 1) { reset_player = (UUtBool) inParameterList[0].val.i; } - + AI2rDeleteAllCharacters(reset_player); AI2rKnowledge_Reset(); @@ -718,7 +718,7 @@ static UUtError AI2iScript_SetState_Alarm(SLtErrorContext *inErrorContext, UUtUn action_marker = AI2rAlarm_FindAlarmConsole(character); #if DEBUG_VERBOSE_ALARM - COrConsole_Printf("%s: action_marker %sfound (%f %f %f)", character->player_name, + COrConsole_Printf("%s: action_marker %sfound (%f %f %f)", character->player_name, (action_marker == NULL) ? "not " : "", (action_marker == NULL) ? 0 : action_marker->position.x, (action_marker == NULL) ? 0 : action_marker->position.y, @@ -773,11 +773,11 @@ static UUtError AI2iScript_SetState_Alarm(SLtErrorContext *inErrorContext, UUtUn #if DEBUG_VERBOSE_ALARM if (character->ai2State.currentGoal == AI2cGoal_Alarm) { UUmAssertReadPtr(character->ai2State.alarmStatus.action_marker, sizeof(ONtActionMarker)); - COrConsole_Printf("%s: ai2_doalarm completed, running for alarm at (%f %f %f)", + COrConsole_Printf("%s: ai2_doalarm completed, running for alarm at (%f %f %f)", character->player_name, character->ai2State.alarmStatus.action_marker->position.x, character->ai2State.alarmStatus.action_marker->position.y, character->ai2State.alarmStatus.action_marker->position.z); } else { - COrConsole_Printf("%s: ai2_doalarm completed, but not running for alarm (behavior is %s)", + COrConsole_Printf("%s: ai2_doalarm completed, but not running for alarm (behavior is %s)", character->player_name, AI2cGoalName[character->ai2State.currentGoal]); } #endif @@ -918,7 +918,7 @@ static UUtError AI2iScript_Debug_SetMovementMode(SLtErrorContext *inErrorContext COrConsole_Printf("### ai2_setmovementmode: cannot move player character without first using ai2_takecontrol 1"); return UUcError_None; } - + UUmAssert(inParameterListLength >= 2); for (itr = 0; itr < AI2cMovementMode_Max; itr++) { @@ -944,9 +944,9 @@ static UUtError AI2iScript_MoveToFlag(SLtErrorContext *inErrorContext, UUtUns32 UUtInt32 flag_id = inParameterList[1].val.i; ONtFlag flag; UUtBool found, setfacing = UUcFalse; - + found = ONrLevel_Flag_ID_To_Flag((UUtUns16) flag_id, &flag); - + if (character == NULL) { AI2rScript_NoCharacterError(inParameterList, "ai2_movetoflag", inErrorContext); return UUcError_None; @@ -995,7 +995,7 @@ static UUtError AI2iScript_LookAtChar(SLtErrorContext *inErrorContext, UUtUns32 } // calculate the relative angle - angle = MUrATan2(target->actual_position.x - character->actual_position.x, + angle = MUrATan2(target->actual_position.x - character->actual_position.x, target->actual_position.z - character->actual_position.z); UUmTrig_ClipLow(angle); @@ -1064,7 +1064,7 @@ static UUtError AI2iScript_GivePowerup(SLtErrorContext *inErrorContext, UUtUns32 if (inParameterListLength < 3) { amount = WPrPowerup_DefaultAmount(itr); - } + } else { amount = (UUtUns16) inParameterList[2].val.i; } @@ -1379,7 +1379,7 @@ static UUtError AI2iScript_Debug_SetAlert(SLtErrorContext *inErrorContext, UUtUn AI2rScript_NoCharacterError(inParameterList, "ai2_setalert", inErrorContext); return UUcError_None; } - + UUmAssert(inParameterListLength >= 2); for (itr = 0; itr < AI2cAlertStatus_Max; itr++) { if (strcmp(inParameterList[1].val.str, AI2cAlertStatusName[itr]) == 0) { @@ -1403,7 +1403,7 @@ static UUtError AI2iScript_Debug_SetAlert(SLtErrorContext *inErrorContext, UUtUn return UUcError_None; } -// Game mechanics +// Game mechanics // triggers static UUtError AI2iScript_Trigger_Activate( @@ -1464,7 +1464,7 @@ static UUtError AI2iScript_Trigger_Hide(SLtErrorContext *inErrorContext, UUtUn UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { UUtUns16 trigger_id = (UUtUns16) inParameterList[0].val.i; - + OBJrTrigger_Hide_ID(trigger_id); return UUcError_None; @@ -1475,7 +1475,7 @@ static UUtError AI2iScript_Trigger_Show(SLtErrorContext *inErrorContext, UUtUn UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { UUtUns16 trigger_id = (UUtUns16) inParameterList[0].val.i; - + OBJrTrigger_Show_ID(trigger_id); return UUcError_None; @@ -1487,7 +1487,7 @@ static UUtError AI2iScript_Trigger_Speed(SLtErrorContext *inErrorContext, UUtU { UUtUns16 trigger_id = (UUtUns16) inParameterList[0].val.i; float speed = inParameterList[1].val.f; - + OBJrTrigger_SetSpeed_ID(trigger_id, speed); return UUcError_None; @@ -1673,7 +1673,7 @@ AI2iScript_Debug_Chump( temp_osd->combat_id = 0; temp_osd->melee_id = 0; temp_osd->neutral_id = 0; - + // create the chump error = ONrGameState_NewCharacter(temp_object, NULL, NULL, &chump_index); @@ -1748,7 +1748,7 @@ static UUtError AI2iScript_PathDebugSquare(SLtErrorContext *inErrorContext, UUtU for (itr = 0, debug_info = room->debug_info; itr < room->debug_info_count; itr++, debug_info++) { if ((debug_info->x != PHgDebugSquareX) || (debug_info->y != PHgDebugSquareY)) continue; - + if ((debug_info->event >= 0) && (debug_info->event < PHcDebugEvent_Max)) { UUrString_Copy(event_name, PHcDebugEventName[debug_info->event], 32); } else { @@ -1873,9 +1873,9 @@ AI2iScript_FaceToFlag( UUtInt32 flag_id = inParameterList[1].val.i; ONtFlag flag; UUtBool found; - + found = ONrLevel_Flag_ID_To_Flag((UUtUns16) flag_id, &flag); - + if (NULL == character) { AI2rScript_NoCharacterError(&inParameterList[0], "chr_facetoflag", inErrorContext); return UUcError_None; @@ -1889,7 +1889,7 @@ AI2iScript_FaceToFlag( character->facingModifier = 0; character->desiredFacing = flag.rotation; } - + return UUcError_None; } @@ -1908,9 +1908,9 @@ AI2iScript_Teleport( UUtInt32 flag_id = inParameterList[1].val.i; ONtFlag flag; UUtBool found; - + found = ONrLevel_Flag_ID_To_Flag((UUtUns16) flag_id, &flag); - + if (NULL == character) { AI2rScript_NoCharacterError(&inParameterList[0], "chr_teleport", inErrorContext); return UUcError_None; @@ -1922,7 +1922,7 @@ AI2iScript_Teleport( } else { ONrCharacter_Teleport(character, &flag.location, UUcTrue); } - + return UUcError_None; } @@ -1938,7 +1938,7 @@ static UUtError AI2iScript_NoCollision(SLtErrorContext *inErrorContext, UUtUns32 AI2rScript_NoCharacterError(&inParameterList[0], "chr_nocollision", inErrorContext); return UUcError_None; } - + if (inParameterList[1].val.i) { character->flags |= ONcCharacterFlag_NoCollision; } else { @@ -1961,7 +1961,7 @@ static ONtFilm *AI2iScript_Playback_Internal(SLtErrorContext *inErrorContext, UU UUtUns32 film_mode, interp_frames; UUtBool played_film; - if (character == NULL) { + if (character == NULL) { AI2rScript_NoCharacterError(inParameterList, "playback", inErrorContext); return NULL; } @@ -1971,7 +1971,7 @@ static ONtFilm *AI2iScript_Playback_Internal(SLtErrorContext *inErrorContext, UU SLrScript_ReportError(inErrorContext, "character (%s) cannot be made active!", character->player_name); return NULL; } - + AI2iScript_CancelEnvAnim(character, active_character); film_name = inParameterList[1].val.str; @@ -2029,7 +2029,7 @@ static UUtError AI2iScript_Playback(SLtErrorContext *inErrorContext, UUtUns32 in ONtFilm* film; film = AI2iScript_Playback_Internal(inErrorContext, inParameterListLength, inParameterList); - if (film == NULL) { + if (film == NULL) { return UUcError_None; } else { return UUcError_None; @@ -2048,7 +2048,7 @@ static UUtError AI2iScript_Playback_Block(SLtErrorContext *inErrorContext, UUtUn ONtFilm* film; film = AI2iScript_Playback_Internal(inErrorContext, inParameterListLength, inParameterList); - if (film == NULL) { + if (film == NULL) { return UUcError_None; } else { *outTicksTillCompletion = film->length; @@ -2102,18 +2102,18 @@ static UUtError AI2iScript_Animate_Internal(SLtErrorContext *inErrorContext, UUt if ((active_character->animationLockFrames > 1) && (inBlock)) { // stall until this character is unlocked - *outStall = UUcTrue; + *outStall = UUcTrue; return UUcError_None; } - + { - char *animString; - + char *animString; + animString = inParameterList[1].val.str; animation = TRrAnimation_GetFromName(animString); if (NULL == animation) - { + { SLrScript_ReportError(inErrorContext, "failed to find animation \"%s\"", animString); return UUcError_None; } @@ -2130,7 +2130,7 @@ static UUtError AI2iScript_Animate_Internal(SLtErrorContext *inErrorContext, UUt } // COrConsole_Printf("chr_animate %s %s %d %d", character->player_name, TRrAnimation_GetName(animation), numFramesOfAnimation, numFramesOfInterpolation); - + ONrCharacter_SetAnimation_External(character, active_character->curFromState, animation, numFramesOfInterpolation); character->flags |= ONcCharacterFlag_ChrAnimate; @@ -2143,7 +2143,7 @@ static UUtError AI2iScript_Animate_Internal(SLtErrorContext *inErrorContext, UUt else { active_character->animationLockFrames = 0; } - + return UUcError_None; } @@ -2155,7 +2155,7 @@ static UUtError AI2iScript_Animate_Block(SLtErrorContext *inErrorContext, UUtUns SLtParameter_Actual *inParameterList, UUtUns32 *outTicksTillCompletion, UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { - return AI2iScript_Animate_Internal(inErrorContext, inParameterListLength, inParameterList, + return AI2iScript_Animate_Internal(inErrorContext, inParameterListLength, inParameterList, outTicksTillCompletion, outStall, ioReturnValue, UUcTrue); } @@ -2167,7 +2167,7 @@ static UUtError AI2iScript_Animate_NoBlock(SLtErrorContext *inErrorContext, UUtU SLtParameter_Actual *inParameterList, UUtUns32 *outTicksTillCompletion, UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { - return AI2iScript_Animate_Internal(inErrorContext, inParameterListLength, inParameterList, + return AI2iScript_Animate_Internal(inErrorContext, inParameterListLength, inParameterList, outTicksTillCompletion, outStall, ioReturnValue, UUcFalse); } @@ -2240,7 +2240,7 @@ static UUtError AI2iScript_EnvAnimate_Internal(SLtErrorContext *inErrorContext, if (inParameterListLength > 2) { const char *flag_string; - + flag_string = inParameterList[2].val.str; if (UUmString_IsEqual(flag_string, "norotation")) @@ -2510,7 +2510,7 @@ static UUtError AI2iScript_ChrCreate(SLtErrorContext *inErrorContext, UUtUns32 i setupID = (UUtUns16)inParameterList[0].val.i; setup = ONrLevel_CharacterSetup_ID_To_Pointer(setupID); if (NULL == setup) - { + { SLrScript_ReportError(inErrorContext, "can not find character id %d", inParameterList[0].val.i); { @@ -2526,7 +2526,7 @@ static UUtError AI2iScript_ChrCreate(SLtErrorContext *inErrorContext, UUtUns32 i return UUcError_None; } - + // CB: optional parameter 2 was start/create. 'create' was only ever used when spawning characters // as part of gameplay (so the player doesn't see them). this command is only ever used for cinematics now // so it's irrelevant. @@ -2551,13 +2551,13 @@ static UUtError AI2iScript_ChrCreate(SLtErrorContext *inErrorContext, UUtUns32 i return UUcError_None; } - + error = ONrGameState_NewCharacter(NULL, setup, &flag, NULL); if (error != UUcError_None) { SLrScript_ReportError(inErrorContext, "failed to create a new character"); return UUcError_None; } - + return UUcError_None; } @@ -2685,7 +2685,7 @@ static LItButtonBits AI2iScript_GetKeyMask(const char *inKeyName) break; } } - + return tableptr->mask; } @@ -2698,7 +2698,7 @@ static UUtError AI2iScript_HoldKey(SLtErrorContext *inErrorContext, UUtUns32 inP ONtCharacter *character = AI2rScript_ParseCharacter(inParameterList, UUcFalse); ONtActiveCharacter *active_character; const char *keyname; - + if (character == NULL) { AI2rScript_NoCharacterError(inParameterList, "chr_holdkey", inErrorContext); return UUcError_None; @@ -2715,7 +2715,7 @@ static UUtError AI2iScript_HoldKey(SLtErrorContext *inErrorContext, UUtUns32 inP *outStall = UUcTrue; return UUcError_None; } - + // part 2 is what keys (or clear) keyname = inParameterList[1].val.str; if (UUmString_IsEqual("clear", keyname)) @@ -2772,7 +2772,7 @@ static UUtBool AI2iScript_TriggerVolume_Callback(OBJtObject *inObject, UUtUns32 #endif trig_osd = (OBJtOSD_TriggerVolume *) inObject->object_data; - + if (UUmString_IsEqual(data->name, trig_osd->name)) { data->found++; @@ -3565,7 +3565,7 @@ static UUtError AI2iScript_LockActive(SLtErrorContext *inErrorContext, UUtUns3 character->flags |= ONcCharacterFlag_ActiveLock; } - + return UUcError_None; } @@ -3581,7 +3581,7 @@ static UUtError AI2iScript_UnlockActive(SLtErrorContext *inErrorContext, UUtUn else { character->flags &= ~ONcCharacterFlag_ActiveLock; } - + return UUcError_None; } @@ -3593,7 +3593,7 @@ static UUtError AI2iScript_Unstoppable(SLtErrorContext *inErrorContext, UUtUns32 { ONtCharacter *character; UUtBool unstoppable = UUcTrue; - + character = AI2rScript_ParseCharacter(&inParameterList[0], UUcFalse); if (character == NULL) { AI2rScript_NoCharacterError(&inParameterList[0], "chr_unstoppable", inErrorContext); @@ -3605,7 +3605,7 @@ static UUtError AI2iScript_Unstoppable(SLtErrorContext *inErrorContext, UUtUns32 } else { character->flags &= ~ONcCharacterFlag_Unstoppable; } - + return UUcError_None; } @@ -3617,7 +3617,7 @@ static UUtError AI2iScript_Invincible(SLtErrorContext *inErrorContext, UUtUns32 { ONtCharacter *character; UUtBool unstoppable = UUcTrue; - + character = AI2rScript_ParseCharacter(&inParameterList[0], UUcFalse); if (character == NULL) { AI2rScript_NoCharacterError(&inParameterList[0], "chr_invincible", inErrorContext); @@ -3629,7 +3629,7 @@ static UUtError AI2iScript_Invincible(SLtErrorContext *inErrorContext, UUtUns32 } else { character->flags &= ~ONcCharacterFlag_Invincible; } - + return UUcError_None; } @@ -3641,7 +3641,7 @@ static UUtError AI2iScript_Unkillable(SLtErrorContext *inErrorContext, UUtUns32 { ONtCharacter *character; UUtBool unstoppable = UUcTrue; - + character = AI2rScript_ParseCharacter(&inParameterList[0], UUcFalse); if (character == NULL) { AI2rScript_NoCharacterError(&inParameterList[0], "chr_unkillable", inErrorContext); @@ -3653,7 +3653,7 @@ static UUtError AI2iScript_Unkillable(SLtErrorContext *inErrorContext, UUtUns32 } else { character->flags &= ~ONcCharacterFlag_Unkillable; } - + return UUcError_None; } @@ -3708,7 +3708,7 @@ static UUtError AI2iScript_Who(SLtErrorContext *inErrorContext, UUtUns32 inParam } COrConsole_Printf("Listing all AIs near %s's location (%f %f %f)", location_type, cur_location.x, cur_location.y, cur_location.z); - + character_list = ONrGameState_PresentCharacterList_Get(); character_list_count = ONrGameState_PresentCharacterList_Count(); @@ -3720,7 +3720,7 @@ static UUtError AI2iScript_Who(SLtErrorContext *inErrorContext, UUtUns32 inParam sprintf(msgbuf, " %s (class %s, #%d)", character->player_name, TMrInstance_GetInstanceName(character->characterClass), ONrCharacter_GetIndex(character)); - + if (character->charType == ONcChar_AI2) { // print out a tiny amount of AI debugging information sprintf(tempbuf, " (state %s)", AI2cGoalName[character->ai2State.currentGoal]); @@ -3795,7 +3795,7 @@ static UUtError AI2iScript_Holograph(SLtErrorContext *inErrorContext, UUtUns32 { ONtCharacter *character; UUtBool holograph_mode; - + if (inParameterListLength != 2) { COrConsole_Printf("chr_holograph had an invalid parameter list length"); goto exit; @@ -3864,7 +3864,7 @@ static UUtError AI2iScript_Talk(SLtErrorContext *inErrorContext, UUtUns32 inPara return UUcError_None; } - UUrString_Copy(AI2gScript_TalkBuffer[itr], inParameterList[1].val.str, BFcMaxFileNameLength); + UUrString_Copy(AI2gScript_TalkBuffer[itr], inParameterList[1].val.str, BFcMaxFileNameLength); if (inParameterListLength < 5) { speech_type = ONcSpeechType_Override; @@ -3924,7 +3924,7 @@ static UUtError AI2iScript_Vocalize(SLtErrorContext *inErrorContext, UUtUns32 in COrConsole_Printf(" %s", AI2cVocalizationTypeName[itr]); } return UUcError_None; - } + } result = AI2rVocalize(character, itr, UUcTrue); if (!result) { @@ -4058,7 +4058,7 @@ static UUtError AI2iScript_Reset_Inventory(SLtErrorContext *inErrorContext, UUtU if (NULL != character->inventory.weapons[0]) { ONrCharacter_UseNewWeapon(character, NULL); } - + UUmAssert(NULL == character->inventory.weapons[WPcPrimarySlot]); { @@ -4068,7 +4068,7 @@ static UUtError AI2iScript_Reset_Inventory(SLtErrorContext *inErrorContext, UUtU { WPtWeapon *weapon = character->inventory.weapons[itr]; - if (weapon != NULL) { + if (weapon != NULL) { WPrDelete(weapon); } @@ -4268,8 +4268,8 @@ UUtError AI2rInstallConsoleVariables(void) {"chr_forceholster", NULL, NULL, "forces a character to holster their weapon", "[ai_name:string | script_id:int] holster:int{0 | 1} [force_draw:int{0 | 1} | ]", AI2iScript_ForceHolster}, {"chr_changeteam", NULL, NULL, "changes a character's team", "[ai_name:string | script_id:int] team_name:string", AI2iScript_ChangeTeam}, {"chr_unstoppable", NULL, NULL, "makes a character unstoppable", "[ai_name:string | script_id:int] [on_off:int{0 | 1}]", AI2iScript_Unstoppable}, - {"chr_invincible", NULL, NULL, "makes a character invincible", "[ai_name:string | script_id:int] [on_off:int{0 | 1}]", AI2iScript_Invincible}, - {"chr_unkillable", NULL, NULL, "makes a character unkillable", "[ai_name:string | script_id:int] [on_off:int{0 | 1}]", AI2iScript_Unkillable}, + {"chr_invincible", NULL, NULL, "makes a character invincible", "[ai_name:string | script_id:int] [on_off:int{0 | 1}]", AI2iScript_Invincible}, + {"chr_unkillable", NULL, NULL, "makes a character unkillable", "[ai_name:string | script_id:int] [on_off:int{0 | 1}]", AI2iScript_Unkillable}, {"chr_talk", NULL, NULL, "causes a character to play a line of dialogue", "[ai_name:string | script_id:int] sound_name:string pre_pause:int post_pause:int [priority:string | ]", AI2iScript_Talk}, {"chr_vocalize", NULL, NULL, "makes a character utter a vocalization", "[ai_name:string | script_id:int] type:string", AI2iScript_Vocalize}, {"chr_inv_reset", NULL, NULL, "clears a characters inventory", "[ai_name:string | script_id:int]", AI2iScript_Reset_Inventory}, @@ -4387,7 +4387,7 @@ UUtError AI2rInstallConsoleVariables(void) {"trigvolume_reset", NULL, NULL, "reset a trigger volume to its level-load state", "name:string", AI2iScript_TriggerVolume_Reset}, {"trigvolume_corpse", NULL, NULL, "kills all the corpses inside a trigger volume", "trig_id:int", AI2iScript_TriggerVolume_DeleteCorpses}, {"trigvolume_kill", NULL, NULL, "kills all the characters inside a trigger volume", "trig_id:int", AI2iScript_TriggerVolume_DeleteCharacters}, - + // powerups {"weapon_spawn", NULL, NULL, "creates a new weapon", "weapontype:string flag:int", AI2iScript_WeaponSpawn}, {"powerup_spawn", NULL, NULL, "creates a new powerup", "poweruptype:string flag:int", AI2iScript_PowerupSpawn}, @@ -4434,7 +4434,7 @@ UUtError AI2rInstallConsoleVariables(void) // pathfinding {"ai2_showpaths", SLcType_Bool, "shows the path each AI is following", &AI2gDrawPaths}, {"ai2_showgrids", SLcType_Bool, "turns on pathfinding grid rendering", &AI2gShowPathfindingGrids}, - {"ai2_showdynamicgrids", SLcType_Bool, "turns on pathfinding dynamic grid display", &PHgRenderDynamicGrid}, + {"ai2_showdynamicgrids", SLcType_Bool, "turns on pathfinding dynamic grid display", &PHgRenderDynamicGrid}, {"ai2_showpathfindingerrors", SLcType_Bool, "enables visual display of pathfinding errors", &AI2gShowPathfindingErrors}, {"ai2_showconnections", SLcType_Bool, "turns on pathfinding connection rendering", &AI2gDebugDisplayGraph}, {"ai2_showactivationpaths", SLcType_Bool, "turns on inactive -> active pathfinding rendering", &AI2gDebug_ShowActivationPaths}, @@ -4495,7 +4495,7 @@ UUtError AI2rInstallConsoleVariables(void) {"ai2_debug_localmove_lines", SLcType_Int32, "number of lines to cast to debug local-movement code", &AI2gDebugLocalPath_LineCount}, #endif {"ai2_debug_showsettingIDs", SLcType_Bool, "shows ID numbers for combat, melee and neutral settings", &AI2gDebugShowSettingIDs}, -#endif +#endif {NULL, SLcType_Void, NULL, NULL} }; @@ -4552,4 +4552,4 @@ UUtError AI2rInstallConsoleVariables(void) UUrMemory_Clear(AI2gScript_TalkBufferInUse, sizeof(AI2gScript_TalkBufferInUse)); return UUcError_None; -} \ No newline at end of file +} diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Script.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Script.h index 5f9281d..30f370e 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Script.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Script.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Script.h - + AUTHOR: Chris Butcher - + CREATED: April 04, 2000 - + PURPOSE: AI interface to the scripting system for Oni - + Copyright (c) Bungie Software, 2000 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Targeting.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Targeting.c index 5959e71..7336860 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Targeting.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Targeting.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Targeting.h - + AUTHOR: Chris Butcher - + CREATED: April 20, 1999 - + PURPOSE: Targeting infrastructure for Oni AI system - + Copyright (c) 2000 */ @@ -85,7 +85,7 @@ void AI2rTargeting_Initialize(AI2tTargetingOwner inOwner, AI2tTargetingState *io ioTargetingState->targeting_params = inTargetingParams; ioTargetingState->shooting_skillarray = inShootingSkillArray; ioTargetingState->callback = inCallbacks; - + ioTargetingState->current_aim_state = AI2cCombatAiming_ByMovementMode; ioTargetingState->predictionbuf = NULL; ioTargetingState->valid_target_pt = UUcFalse; @@ -99,7 +99,7 @@ void AI2rTargeting_Update(AI2tTargetingState *ioTargetingState, UUtBool inPredic UUtBool inShootWeapon, float *outTooCloseWeight) { ioTargetingState->last_computation_success = UUcFalse; - ioTargetingState->predict_position = inPredict && + ioTargetingState->predict_position = inPredict && (ioTargetingState->weapon_parameters != NULL); if (ioTargetingState->target == NULL) { @@ -197,7 +197,7 @@ void AI2rTargeting_SetupNewTarget(AI2tTargetingState *ioTargetingState, ONtChara MUmVector_Set(ioTargetingState->error_vector, 0, 0, 0); #if TARGETING_MISS_DECAY - // set up missing - if there is any, it will be modified down + // set up missing - if there is any, it will be modified down // by weapon max in calculatemissdirection ioTargetingState->miss_count = (inInitialTarget) ? 100 : 0; #else @@ -315,7 +315,7 @@ static void AI2iTargeting_NextMissDirection(AI2tTargetingState *ioTargetingState // calculate the new miss rotation matrix MUrQuat_SetValue(&miss_quaternion, ioTargetingState->miss_axis.x, - ioTargetingState->miss_axis.y, + ioTargetingState->miss_axis.y, ioTargetingState->miss_axis.z, ioTargetingState->miss_angle); MUrQuatToMatrix(&miss_quaternion, &ioTargetingState->miss_matrix); @@ -354,7 +354,7 @@ static void AI2iTargeting_CalculateMissDirection(AI2tTargetingState *ioTargeting MUmVector_Copy(target_point, ioTargetingState->target->location); target_point.y += ioTargetingState->target->heightThisFrame; - + MUmVector_Subtract(target_vector, target_point, our_point); // work out where our weapon is currently pointing and get its angle from @@ -402,7 +402,7 @@ static void AI2iTargeting_CalculateMissDirection(AI2tTargetingState *ioTargeting // miss angle must start between the two values specified in the character class miss_angle = UUmPin(miss_angle, ioTargetingState->targeting_params->startle_miss_angle_min, ioTargetingState->targeting_params->startle_miss_angle_max); - + // store the current miss quaternion and matrix ioTargetingState->miss_angle = miss_angle; MUmVector_Set(ioTargetingState->miss_axis, qx, qy, qz); @@ -441,12 +441,12 @@ static void AI2iTargeting_UpdatePrediction(AI2tTargetingState *ioTargetingState, sample_trend = ioTargetingState->next_sample + UUmMin(ioTargetingState->num_samples_taken, trend_frames); sample_vel = ioTargetingState->next_sample + UUmMin(ioTargetingState->num_samples_taken, velocity_frames); sample_now = ioTargetingState->next_sample + UUmMin(ioTargetingState->num_samples_taken, delay_frames); - + // the buffer is trend_frames long sample_trend %= bufsize; sample_vel %= bufsize; sample_now %= bufsize; - + if ((ioTargetingState->targeting_params->predict_positiondelayframes > 0) && (ioTargetingState->num_samples_taken > 0)) { // we predict velocity starting from where they were some number of frames in the past sample_base = ioTargetingState->next_sample + UUmMin(ioTargetingState->num_samples_taken, ioTargetingState->targeting_params->predict_positiondelayframes); @@ -464,10 +464,10 @@ static void AI2iTargeting_UpdatePrediction(AI2tTargetingState *ioTargetingState, MUmVector_Set(ioTargetingState->predicted_velocity, 0, 0, 0); } else { // estimate the enemy's velocity in units per second by averaging their motion over this time period - MUmVector_Subtract(enemy_velocity, ioTargetingState->predictionbuf[sample_now], + MUmVector_Subtract(enemy_velocity, ioTargetingState->predictionbuf[sample_now], ioTargetingState->predictionbuf[sample_vel]); MUmVector_Scale(enemy_velocity, ((float) UUcFramesPerSecond) / (velocity_frames - delay_frames)); - + current_enemy_speed = MUmVector_GetLength(enemy_velocity); MUmVector_Copy(ioTargetingState->predicted_velocity, enemy_velocity); @@ -477,7 +477,7 @@ static void AI2iTargeting_UpdatePrediction(AI2tTargetingState *ioTargetingState, can_predict = UUcFalse; } } - + if (sample_trend == sample_now) { // no samples yet! can_predict = UUcFalse; @@ -495,11 +495,11 @@ static void AI2iTargeting_UpdatePrediction(AI2tTargetingState *ioTargetingState, can_predict = UUcFalse; } } - + // sample the new enemy location next_sample = ioTargetingState->predictionbuf + ioTargetingState->next_sample; *next_sample = sample_pt; - + ioTargetingState->num_samples_taken++; if (ioTargetingState->next_sample == 0) { ioTargetingState->next_sample = trend_frames - 1; @@ -510,7 +510,7 @@ static void AI2iTargeting_UpdatePrediction(AI2tTargetingState *ioTargetingState, if (can_predict) { // determine how well our current leading velocity matches the character's general trend of movement // recently. - + // both vectors should be pointing in the same direction dir_accuracy = MUrVector_DotProduct(&enemy_velocity, &trend_motion) / (current_enemy_speed * current_trend_speed); @@ -612,7 +612,7 @@ static void AI2iTargeting_ApplyTargetingError(AI2tTargetingState *ioTargetingSta void ONrCreateTargetingVector( const M3tVector3D *current_aim_pt, // point to aim the gun at, include prediction if required const M3tVector3D *targeting_frompt, // characters location + height this frame - const AI2tWeaponParameters *weapon_parameters, // + const AI2tWeaponParameters *weapon_parameters, // const M3tMatrix4x3 *weapon_matrix, // character's weapon_matrix M3tVector3D *targeting_vector) // the final vector we should be aiming along { @@ -640,7 +640,7 @@ void ONrCreateTargetingVector( // and it's away from the enemy. this ensures that we don't get wacky stuff happening when people // stand so close that the barrel of our gun goes through their chest (damn collision) MUmVector_Copy(weapon_pt, weapon_parameters->shooter_perpoffset_gunspace); - weapon_pt.x -= AI2cCombat_WeaponTargetingOffsetShooterReverse * reverse_offset; + weapon_pt.x -= AI2cCombat_WeaponTargetingOffsetShooterReverse * reverse_offset; MUrMatrix_MultiplyPoint(&weapon_pt, weapon_matrix, &weapon_pt); // adjust the target's location by weapon_pt rather than targeting_frompt so that we hit the target @@ -676,14 +676,14 @@ static void AI2iTargeting_UpdateTargeting(AI2tTargetingState *ioTargetingState, desired_aim_state = AI2cCombatAiming_ForceLook; aim_with_weapon = UUcFalse; } - + if (ioTargetingState->current_aim_state != desired_aim_state) { if (ioTargetingState->callback->rForceAimWithWeapon) { ioTargetingState->callback->rForceAimWithWeapon(ioTargetingState, aim_with_weapon); } ioTargetingState->current_aim_state = desired_aim_state; } - + if (aim_with_weapon) { // work out where we are aiming at MUmVector_Subtract(orig_aiming_vector, ioTargetingState->current_aim_pt, @@ -707,7 +707,7 @@ static void AI2iTargeting_UpdateTargeting(AI2tTargetingState *ioTargetingState, gravity = ioTargetingState->weapon_parameters->ballistic_gravity * P3gGravityAccel; gravity_sq = UUmSQR(gravity); - + // in order to hit the point at (dist, height) at time t we must have: // x = dist / t // y = height / t + 1/2 * gravity * t @@ -762,7 +762,7 @@ static void AI2iTargeting_UpdateTargeting(AI2tTargetingState *ioTargetingState, // and it's away from the enemy. this ensures that we don't get wacky stuff happening when people // stand so close that the barrel of our gun goes through their chest (damn collision) MUmVector_Copy(ioTargetingState->weapon_pt, ioTargetingState->weapon_parameters->shooter_perpoffset_gunspace); - ioTargetingState->weapon_pt.x -= AI2cCombat_WeaponTargetingOffsetShooterReverse * reverse_offset; + ioTargetingState->weapon_pt.x -= AI2cCombat_WeaponTargetingOffsetShooterReverse * reverse_offset; MUrMatrix_MultiplyPoint(&ioTargetingState->weapon_pt, ioTargetingState->weapon_matrix, &ioTargetingState->weapon_pt); // calculate the aiming vector required from weapon_pt rather than from targeting_frompt @@ -871,7 +871,7 @@ static UUtBool AI2iTargeting_Fire(AI2tTargetingState *ioTargetingState) UUmAssert(ioTargetingState->owner.type == AI2cTargetingOwnerType_Turret); aiming_accuracy = MUrSqrt(UUmSQR(shooter_dir.x) + UUmSQR(shooter_dir.y)); aim_axial = shooter_dir.z; - } + } // there is a minimum alignment below which we will never fire... prevents // stupid firing behavior when the enemy is in close. it's a ratio of axial @@ -915,7 +915,7 @@ static UUtBool AI2iTargeting_Fire(AI2tTargetingState *ioTargetingState) // if we are randomly jittering our target point, add this to the aiming tolerance aiming_tolerance += AI2cCombat_Targeting_AimingErrorScale * ioTargetingState->error_distance; - + #if TARGETING_MISS_DECAY // if we are still in the initial-missing phase, increase our aiming tolerance if (ioTargetingState->miss_count > 0) { @@ -962,7 +962,7 @@ static UUtBool AI2iTargeting_Fire(AI2tTargetingState *ioTargetingState) #endif aiming_tolerance *= 1.0f + increase_tolerance; } else { - // the enemy is outside our max interpolation range. ensure that our + // the enemy is outside our max interpolation range. ensure that our // aiming tolerance never sinks below some class-specific angle... so we are actively // incapable of aiming precisely at a distance min_aiming_tolerance = ioTargetingState->shooting_skill->best_aiming_angle * aim_axial; @@ -1046,7 +1046,7 @@ static UUtBool AI2iTargeting_Fire(AI2tTargetingState *ioTargetingState) #if AI_DEBUG_TARGETING COrConsole_Printf("on target. accuracy %f, tolerance %f", aiming_accuracy, aiming_tolerance); #endif - + // we are on target. fire. return UUcTrue; } @@ -1078,7 +1078,7 @@ void AI2rTargeting_ChangeWeapon(AI2tTargetingState *ioTargetingState, AI2tWeapon index = ioTargetingState->weapon_parameters->shootskill_index; UUmAssert((index >= 0) && (index < AI2cCombat_MaxWeapons)); ioTargetingState->shooting_skill = &ioTargetingState->shooting_skillarray[index]; - + // set up the prediction buffer ioTargetingState->predict_position = UUcTrue; ioTargetingState->next_sample = ioTargetingState->targeting_params->predict_trendframes - 1; diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Targeting.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Targeting.h index 34e3fbc..fdc9359 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_Targeting.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_Targeting.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Targeting.h - + AUTHOR: Chris Butcher - + CREATED: April 20, 1999 - + PURPOSE: Targeting infrastructure for Oni AI system - + Copyright (c) 2000 */ @@ -54,7 +54,7 @@ typedef struct AI2tTargetingOwner { } AI2tTargetingOwner; // describes a character class's ability to shoot a particular weapon -typedef tm_struct AI2tShootingSkill +typedef tm_struct AI2tShootingSkill { float recoil_compensation; // 0-1, 1 is no recoil float best_aiming_angle; // read as degrees, stored as sin(theta) @@ -67,7 +67,7 @@ typedef tm_struct AI2tShootingSkill UUtUns16 delay_max; // timers for delay after firing } AI2tShootingSkill; -typedef tm_struct AI2tTargetingParameters +typedef tm_struct AI2tTargetingParameters { // parameters for the initial deliberately-missed shots // float startle_miss_angle_min; @@ -229,7 +229,7 @@ void AI2rTargeting_SetupNewTarget(AI2tTargetingState *ioTargetingState, ONtChara UUtBool inInitialTarget); // set up targeting for a game tick -void AI2rTargeting_Update(AI2tTargetingState *ioTargetingState, +void AI2rTargeting_Update(AI2tTargetingState *ioTargetingState, UUtBool inPredict, UUtBool inPointWeapon, UUtBool inShootWeapon, float *outTooCloseWeight); @@ -244,7 +244,7 @@ void AI2rTargeting_Terminate(AI2tTargetingState *ioTargetingState); void ONrCreateTargetingVector( const M3tVector3D *current_aim_pt, // point to aim the gun at, include prediction if required const M3tVector3D *targeting_frompt, // characters location + height this frame - const AI2tWeaponParameters *weapon_parameters, // + const AI2tWeaponParameters *weapon_parameters, // const M3tMatrix4x3 *weapon_matrix, // character's weapon_matrix M3tVector3D *targeting_vector); // the final vector we should be aiming along diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_TeamBattle.c b/OniProj/OniGameSource/Oni_AI/Oni_AI2_TeamBattle.c index 460a274..aef46c6 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_TeamBattle.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_TeamBattle.c @@ -1,12 +1,12 @@ /* FILE: Oni_AI2_Patrol.c - + AUTHOR: Michael Evans - + CREATED: November 15, 1999 - + PURPOSE: Patrol AI for Oni - + Copyright (c) 1999 */ diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI2_TeamBattle.h b/OniProj/OniGameSource/Oni_AI/Oni_AI2_TeamBattle.h index 7865813..36ba88c 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI2_TeamBattle.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI2_TeamBattle.h @@ -4,13 +4,13 @@ /* FILE: Oni_AI2_Patrol.h - + AUTHOR: Michael Evans - + CREATED: November 15, 1999 - + PURPOSE: Patrol AI for Oni - + Copyright (c) 1999 */ @@ -20,4 +20,4 @@ typedef struct AI2tTeamBattleState UUtInt32 target; } AI2tTeamBattleState; -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Action.c b/OniProj/OniGameSource/Oni_AI/Oni_AI_Action.c index 9372d9d..9aa30fb 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Action.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Action.c @@ -1 +1 @@ -#error this file is obsolete \ No newline at end of file +#error this file is obsolete diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Action.h b/OniProj/OniGameSource/Oni_AI/Oni_AI_Action.h index 9372d9d..9aa30fb 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Action.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Action.h @@ -1 +1 @@ -#error this file is obsolete \ No newline at end of file +#error this file is obsolete diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Activity.c b/OniProj/OniGameSource/Oni_AI/Oni_AI_Activity.c index 9372d9d..9aa30fb 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Activity.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Activity.c @@ -1 +1 @@ -#error this file is obsolete \ No newline at end of file +#error this file is obsolete diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Activity.h b/OniProj/OniGameSource/Oni_AI/Oni_AI_Activity.h index 9372d9d..9aa30fb 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Activity.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Activity.h @@ -1 +1 @@ -#error this file is obsolete \ No newline at end of file +#error this file is obsolete diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Behaviour.h b/OniProj/OniGameSource/Oni_AI/Oni_AI_Behaviour.h index 9372d9d..9aa30fb 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Behaviour.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Behaviour.h @@ -1 +1 @@ -#error this file is obsolete \ No newline at end of file +#error this file is obsolete diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Group.c b/OniProj/OniGameSource/Oni_AI/Oni_AI_Group.c index 9372d9d..9aa30fb 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Group.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Group.c @@ -1 +1 @@ -#error this file is obsolete \ No newline at end of file +#error this file is obsolete diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Group.h b/OniProj/OniGameSource/Oni_AI/Oni_AI_Group.h index 9372d9d..9aa30fb 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Group.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Group.h @@ -1 +1 @@ -#error this file is obsolete \ No newline at end of file +#error this file is obsolete diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Learning.h b/OniProj/OniGameSource/Oni_AI/Oni_AI_Learning.h index f457220..068cf25 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Learning.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Learning.h @@ -1 +1 @@ -#error THIS FILE IS NOW OBSOLETE \ No newline at end of file +#error THIS FILE IS NOW OBSOLETE diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Profile.c b/OniProj/OniGameSource/Oni_AI/Oni_AI_Profile.c index 9372d9d..9aa30fb 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Profile.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Profile.c @@ -1 +1 @@ -#error this file is obsolete \ No newline at end of file +#error this file is obsolete diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Profile.h b/OniProj/OniGameSource/Oni_AI/Oni_AI_Profile.h index 9372d9d..9aa30fb 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Profile.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Profile.h @@ -1 +1 @@ -#error this file is obsolete \ No newline at end of file +#error this file is obsolete diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Script.c b/OniProj/OniGameSource/Oni_AI/Oni_AI_Script.c index 29c629c..703c3b4 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Script.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Script.c @@ -1,8 +1,8 @@ /* Oni_AI_Script.c - + Script level AI stuff - + Author: Quinn Dunki, Michael Evans Copyright (c) 1998 Bungie Software @@ -48,13 +48,13 @@ static void AIiObjectsFromScript( /**************** * Finds the objects matching a scripting ID. Returns a list of object pointers. */ - + UUtUns16 i,count; OBtObject *object; OBtObjectList *objects; UUtUns32 id_low = UUmMin(inScriptID1, inScriptID2); UUtUns32 id_high = UUmMax(inScriptID1, inScriptID2); - + objects = ONrGameState_GetObjectList(); *outNumObjects=0; @@ -64,11 +64,11 @@ static void AIiObjectsFromScript( } count = objects->numObjects; - + for (i=0; iobject_list + i; - + if ((object->flags & OBcFlags_InUse) == 0) continue; @@ -105,7 +105,7 @@ UUtError AIrScript_LevelBegin_Triggers( if ((ONgLevel->scriptTriggerArray == NULL) || (ONgLevel->scriptTriggerArray->numTriggers == 0)) { return UUcError_None; } - + ONgGameState->triggers.triggers = UUrMemory_Block_New(sizeof(AItScriptTrigger) * ONgLevel->scriptTriggerArray->numTriggers); if (!ONgGameState->triggers.triggers) { @@ -169,13 +169,13 @@ AIrUtility_New_GetCharacterFromID( curChr = present_character_list[itr]; UUmAssert(curChr->flags & ONcCharacterFlag_InUse); - + if (curChr->scriptID == inID) { result = curChr; break; } } - + if ((result == NULL) && (inExhaustive)) { // search the entire character array, not just the present list present_character_count = ONrGameState_GetNumCharacters(); @@ -207,7 +207,7 @@ AIiScript_CameraInterpolate_Internal( /********** * cm_interpolate animation number-of-frames */ - + CAtCamera* camera = ONgGameState->local.camera; OBtAnimation* animation; M3tMatrix4x3 matrix; @@ -235,7 +235,7 @@ AIiScript_CameraInterpolate_Internal( numFrames = (UUtUns32) UUmMax(inParameterList[1].val.i, 1); CArInterpolate_Enter_Matrix(&matrix, numFrames); - + return UUcError_None; } @@ -299,7 +299,7 @@ AIiScript_CameraAnim_Internal( /********** * cm_anim [move/look/both] animation */ - + UUtError error; CAtCamera* camera = ONgGameState->local.camera; OBtAnimation* animation; @@ -312,7 +312,7 @@ AIiScript_CameraAnim_Internal( *outStalled = UUcFalse; } - + // Load the named animation error = TMrInstance_GetDataPtr( @@ -331,7 +331,7 @@ AIiScript_CameraAnim_Internal( } CArAnimate_Enter(animation); - + return UUcError_None; } @@ -484,11 +484,11 @@ AIiScript_ForceDraw( /****************** * obj_force_draw id id */ - + OBtObject *objects[AIcMaxObjectsOfOneID]; UUtUns32 i, count; UUtInt32 p0, p1; - + p0 = inParameterList[0].val.i; p1 = (inParameterListLength >= 2) ? inParameterList[1].val.i : p0; @@ -498,7 +498,7 @@ AIiScript_ForceDraw( { objects[i]->flags |= OBcFlags_ForceDraw; } - + return UUcError_None; } @@ -514,11 +514,11 @@ AIiScript_ObjShow( /****************** * obj_show id id */ - + OBtObject *objects[AIcMaxObjectsOfOneID]; UUtUns32 i, count; UUtInt32 p0, p1; - + p0 = inParameterList[0].val.i; p1 = (inParameterListLength >= 2) ? inParameterList[1].val.i : p0; @@ -528,7 +528,7 @@ AIiScript_ObjShow( { OBrShow(objects[i], UUcTrue); } - + return UUcError_None; } @@ -544,7 +544,7 @@ AIiScript_ObjHide( /****************** * obj_hide id id */ - + OBtObject *objects[AIcMaxObjectsOfOneID]; UUtUns32 i, count; UUtInt32 p0, p1; @@ -558,7 +558,7 @@ AIiScript_ObjHide( { OBrShow(objects[i], UUcFalse); } - + return UUcError_None; } @@ -574,9 +574,9 @@ AIiScript_ObjKill( { /****************** - * obj_kill id id + * obj_kill id id */ - + OBtObject *objects[AIcMaxObjectsOfOneID]; UUtUns32 i, count; UUtInt32 p0, p1; @@ -590,7 +590,7 @@ AIiScript_ObjKill( { OBrDelete(objects[i]); } - + return UUcError_None; } @@ -607,9 +607,9 @@ AIiScript_ObjShade( { /****************** - * obj_shade id id + * obj_shade id id */ - + OBtObject *objects[AIcMaxObjectsOfOneID]; UUtUns32 i, count; UUtInt32 p0, p1; @@ -635,7 +635,7 @@ AIiScript_ObjShade( objects[i]->flags |= OBcFlags_FlatLighting; objects[i]->flat_lighting_shade = shade; } - + return UUcError_None; } @@ -652,8 +652,8 @@ AIiScript_ObjCreate( /****************** * obj_create id id */ - - + + UUtUns32 i; UUtUns32 id_low; UUtUns32 id_high; @@ -669,24 +669,24 @@ AIiScript_ObjCreate( id_low = UUmMin(i0, i1); id_high = UUmMax(i0, i1); } - + for (i=0; i < ONgGameState->level->objectSetupArray->numObjects; i++) { OBtObjectSetup *setup = ONgGameState->level->objectSetupArray->objects + i; - if ((setup->scriptID >= id_low) && (setup->scriptID <= id_high)) { + if ((setup->scriptID >= id_low) && (setup->scriptID <= id_high)) { OBtObject *object; if (!(setup->flags & OBcFlags_InUse)) continue; object = OBrList_Add(ONgGameState->objects); - OBrInit(object,setup); + OBrInit(object,setup); } } - + return UUcError_None; } - + static UUtError AIiScript_EnvSetAnim_Internal( @@ -701,7 +701,7 @@ AIiScript_EnvSetAnim_Internal( /**************** * env_setanim object newanim */ - + OBtObject *objects[AIcMaxObjectsOfOneID]; UUtUns32 i,count; UUtError error; @@ -741,7 +741,7 @@ AIiScript_EnvSetAnim_Internal( for (i=0; i < count; i++) { error = OBrSetAnimationByName(objects[i], name); - + if (error != UUcError_None) { SLrScript_ReportError(inErrorContext, "Couldn't load animation for scripted swap"); return error; @@ -798,7 +798,7 @@ AIiScript_EnvAnim_Internal( /**************** * env_anim object_id object_id */ - + OBtObject *objects[AIcMaxObjectsOfOneID]; UUtUns32 count; UUtUns32 i; @@ -887,7 +887,7 @@ AIiScript_Letterbox( /********** * letterbox [0|1] */ - + UUtUns16 state = (UUtUns16)inParameterList[0].val.i; if (state) { @@ -1018,7 +1018,7 @@ AIiScript_Input( /************** * input [0/1] */ - + UUtUns16 value; value = (UUtUns16)inParameterList[0].val.i; @@ -1068,11 +1068,11 @@ AIiScript_FadeOut( float r; float g; float b; - + r = (inParameterList[0].type == SLcType_Int32) ? inParameterList[0].val.i : inParameterList[0].val.f; g = (inParameterList[1].type == SLcType_Int32) ? inParameterList[1].val.i : inParameterList[1].val.f; b = (inParameterList[2].type == SLcType_Int32) ? inParameterList[2].val.i : inParameterList[2].val.f; - + numFrames = inParameterList[3].val.i; r = UUmPin(r, 0.f, 1.f); @@ -1096,19 +1096,19 @@ AIiScript_EnvTexSwap( /**************** * env_texswap gqstart texname */ - + UUtError error; UUtUns32 gqS,i,gq; - + M3tTextureMap *texture; AKtEnvironment *env = ONgGameState->level->environment; char texname[AIcMaxScriptName]; COrConsole_Printf("obsolete env_texswap called"); - + gqS = inParameterList[0].val.i; - - for (i=0; i<=env->envQuadRemaps->numIndices; i++) + + for (i=0; i<=env->envQuadRemaps->numIndices; i++) { UUtUns16 texture_map_index; @@ -1119,25 +1119,25 @@ AIiScript_EnvTexSwap( UUrString_Copy(texname, inParameterList[1].val.str,AIcMaxScriptName); UUrString_StripExtension(texname); UUrString_Capitalize(texname, AIcMaxScriptName); - + error = TMrInstance_GetDataPtr( M3cTemplate_TextureMap, texname, &texture); - + if (error != UUcError_None) { SLrScript_ReportError(inErrorContext, "caCould not load texture map \"%s\" for scripted swap", texname); return UUcError_Generic; } - + // Find the index for that texture for (texture_map_index = 0; texture_map_index < env->textureMapArray->numMaps; texture_map_index++) { if (env->textureMapArray->maps[texture_map_index] == texture) break; } - + UUmAssert(texture_map_index < env->textureMapArray->numMaps); env->gqRenderArray->gqRender[gq].textureMapIndex = texture_map_index; @@ -1158,15 +1158,15 @@ AIiScript_EnvShow( /**************** * env_show ref [0/1] */ - + UUtUns32 ref,i,gq; UUtBool t; AKtEnvironment *env = ONgGameState->level->environment; - + ref = inParameterList[0].val.i; t = (UUtBool)inParameterList[1].val.i; - - for (i=0; i<=env->envQuadRemaps->numIndices; i++) + + for (i=0; i<=env->envQuadRemaps->numIndices; i++) { if (env->envQuadRemaps->indices[i] != ref) continue; gq = env->envQuadRemapIndices->indices[i]; @@ -1198,7 +1198,7 @@ AIiScript_EnvBroken( /**************** * env_broken ref */ - + UUtUns32 refstart,refend,i,gq,flags,bv_index; UUtUns32 unbroken_bv[AIcEnvBroken_BVLength]; UUtUns32 num_unbroken, num_broken; @@ -1213,7 +1213,7 @@ AIiScript_EnvBroken( } else { refend = refstart; } - + if (refend >= refstart + 32 * AIcEnvBroken_BVLength) { COrConsole_Printf("### env_broken: trying to read objects %d-%d, exceeded max object count of %d", refstart, refend, 32 * AIcEnvBroken_BVLength); @@ -1222,7 +1222,7 @@ AIiScript_EnvBroken( num_unbroken = 0; UUrBitVector_ClearBitAll(unbroken_bv, AIcEnvBroken_BVLength); - for (i = 0; i <= env->envQuadRemaps->numIndices; i++) + for (i = 0; i <= env->envQuadRemaps->numIndices; i++) { if ((env->envQuadRemaps->indices[i] < refstart) || (env->envQuadRemaps->indices[i] > refend)) continue; @@ -1261,14 +1261,14 @@ AIiScript_EnvShade( /**************** * env_shade ref ref r g b */ - + UUtUns32 ref_low; UUtUns32 ref_high; UUtUns32 shade; UUtUns32 i; AKtEnvironment *env = ONgGameState->level->environment; - + ref_low = UUmMin(inParameterList[0].val.i, inParameterList[1].val.i); ref_high = UUmMax(inParameterList[0].val.i, inParameterList[1].val.i); @@ -1286,8 +1286,8 @@ AIiScript_EnvShade( shade |= (MUrUnsignedSmallFloat_To_Uns_Round(g * 255) << 8); shade |= (MUrUnsignedSmallFloat_To_Uns_Round(b * 255) << 0); } - - for (i=0; i<=env->envQuadRemaps->numIndices; i++) + + for (i=0; i<=env->envQuadRemaps->numIndices; i++) { if ((env->envQuadRemaps->indices[i] >= ref_low) && (env->envQuadRemaps->indices[i] <= ref_high)) { UUtUns32 gq_index; @@ -1510,7 +1510,7 @@ static UUtError AIiScript_MessageRemove( SLtParameter_Actual *ioReturnValue) { const char *message_tag = NULL; - + if (inParameterListLength > 0) { message_tag = inParameterList[0].val.str; } @@ -1631,7 +1631,7 @@ UUtError AIrScript_Initialize( */ UUtError error; SLtRegisterVoidFunctionTable table[] = - { + { { "cm_anim", "initiates a camera animation", "cam_spec:string{\"move\" | \"look\" | \"both\"} anim_name:string", AIiScript_CameraAnim_NoBlock }, { "cm_anim_block", "initiates a camera animation", "cam_spec:string{\"move\" | \"look\" | \"both\"} anim_name:string", AIiScript_CameraAnim_Block }, @@ -1661,7 +1661,7 @@ UUtError AIrScript_Initialize( { "env_setanim", "sets up an animation for an object", "obj_id:int object_name:string", AIiScript_EnvSetAnim_NoBlock }, { "env_setanim_block", "sets up an animation for an object", "obj_id:int object_name:string", AIiScript_EnvSetAnim_Block }, - + { "letterbox", "starts or stops letterboxing", "start_stop:int{0 | 1}", AIiScript_Letterbox }, { "input", "turns input on or off", "on_off:int{0 | 1}", AIiScript_Input }, { "fade_in", "fades the screen in", "ticks:int", AIiScript_FadeIn }, @@ -1671,7 +1671,7 @@ UUtError AIrScript_Initialize( { "env_shade", "sets the shade of a block of objects", "gq_ref:int gq_ref:int r:float g:float b:float", AIiScript_EnvShade }, { "begin_cutscene", "begins a cutscene", NULL, AIiScript_BeginCutScene }, { "end_cutscene", "ends a cutscene", "", AIiScript_EndCutScene }, - { "cutscene_sync", "marks a point in a cutscene", NULL, AIiScript_CutsceneSyncMark }, + { "cutscene_sync", "marks a point in a cutscene", NULL, AIiScript_CutsceneSyncMark }, { "dprint", "debugging print", "astring:string", AIiScript_DPrint }, { "dmsg", "debugging message", "astring:string", AIiScript_DMsg }, { "win", "win this level", NULL, AIiScript_Win }, @@ -1706,6 +1706,6 @@ void AIrScript_Terminate( /******************* * Game shutdown */ - + return; } diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Script.h b/OniProj/OniGameSource/Oni_AI/Oni_AI_Script.h index 0caf7ac..a298f2d 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Script.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Script.h @@ -1,8 +1,8 @@ /* Oni_AI_Script.h - + Script level AI stuff - + Author: Quinn Dunki, Michael Evans Copyright (c) 1998-2000 Bungie Software @@ -84,7 +84,7 @@ typedef enum AItScriptTriggerType AIcTriggerType_Character, AIcTriggerType_Laser } AItScriptTriggerType; - + typedef tm_struct AItScriptTriggerClass { UUtInt16 id; @@ -94,10 +94,10 @@ typedef tm_struct AItScriptTriggerClass UUtUns16 flags; // AItTriggerClassFlags UUtUns16 team; UUtUns16 refRestrict; - + float radius_h; float radius_v; - + char refName[64]; // Must match AIcMaxRefName above } AItScriptTriggerClass; @@ -107,7 +107,7 @@ typedef tm_template('A','I','T','R',"AI script trigger array") AItScriptTriggerClassArray { tm_pad pad0[22]; - + tm_varindex UUtUns16 numTriggers; tm_vararray AItScriptTriggerClass triggers[1]; } AItScriptTriggerClassArray; @@ -148,13 +148,13 @@ typedef struct AItScriptTriggerList UUtUns16 numTriggers; AItScriptTrigger *triggers; } AItScriptTriggerList; - + UUtError AIrScript_Initialize( void); void AIrScript_Terminate( void); - + void AIrScript_Render( void); @@ -163,7 +163,7 @@ UUtError AIrScript_LevelBegin_Triggers( void AIrScript_LevelEnd_Triggers( void); - + ONtCharacter* AIrUtility_New_GetCharacterFromID( UUtUns16 inID, diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Setup.c b/OniProj/OniGameSource/Oni_AI/Oni_AI_Setup.c index 9372d9d..9aa30fb 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Setup.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Setup.c @@ -1 +1 @@ -#error this file is obsolete \ No newline at end of file +#error this file is obsolete diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AI_Setup.h b/OniProj/OniGameSource/Oni_AI/Oni_AI_Setup.h index f59ee5f..e1ae461 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AI_Setup.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AI_Setup.h @@ -1,8 +1,8 @@ /* Oni_AI_Setup.h - + This file contains all top-level AI header code - + Author: Quinn Dunki Copyright 1998-1999 Bungie */ @@ -23,7 +23,7 @@ /* * Character setup stuff */ - + enum { AIcSetup_Flag_AI = 0x0001, AIcSetup_Flag_AutoFreeze = 0x0002, @@ -45,7 +45,7 @@ typedef tm_template('A','I','W','A', "AI Imported Waypoint Array") AItWaypointArray { tm_pad pad0[22]; - + tm_varindex UUtUns16 numWaypoints; tm_vararray AItWaypoint waypoints[1]; } AItWaypointArray; @@ -57,13 +57,13 @@ tm_struct AItCharacterSetup UUtUns16 defaultScriptID; // default scriptID (how you are refered) UUtInt16 defaultFlagID; // default flagID (location and facing) - UUtUns16 flags; - UUtUns16 teamNumber; // + UUtUns16 flags; + UUtUns16 teamNumber; // ONtCharacterClass *characterClass; - char variable[32]; // variable to decrement on death or - + char variable[32]; // variable to decrement on death or + AItScriptTable scripts; WPtWeaponClass *weapon; @@ -80,7 +80,7 @@ typedef tm_template('A','I','S','A', "AI Character Setup Array") AItCharacterSetupArray { tm_pad pad0[22]; - + tm_varindex UUtUns16 numCharacterSetups; tm_vararray AItCharacterSetup characterSetups[1]; } AItCharacterSetupArray; @@ -96,11 +96,11 @@ typedef tm_template('N','M','S','A', "Network Spawn Point Array") NMtSpawnPointArray { tm_pad pad0[22]; - + tm_varindex UUtUns16 numSpawnPoints; tm_vararray NMtSpawnPoint spawnPoints[1]; } NMtSpawnPointArray; - + // Initialization UUtError AIrST_Initialize(void); @@ -110,4 +110,4 @@ struct OBJtOSD_Character; UUtError AIrST_InitializeCharacter(struct ONtCharacter *ioCharacter, const struct OBJtOSD_Character *inStartingData, const struct AItCharacterSetup *inSetup, const ONtFlag *inFlag); -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AStar.c b/OniProj/OniGameSource/Oni_AI/Oni_AStar.c index 3fea00b..955f9fc 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AStar.c +++ b/OniProj/OniGameSource/Oni_AI/Oni_AStar.c @@ -75,7 +75,7 @@ struct AStPathNode UUtUns16 adjacent; // during pathfinding, points to previous node in the path; // after path is found, points to next node in the path AStGridPoint loc; // location in the grid - + float f; // g + estimated cost to reach finish float g; // actual cost to reach this node }; @@ -106,7 +106,7 @@ struct AStPath UUtUns16 *index_array; // stores the index in the node array // of the node that lies at a particular location - + AStGridPoint start; // start location in room AStGridPoint end; // end location in room AStGridPoint reachable_end; // end location of path @@ -126,9 +126,9 @@ struct AStPath UUtBool finished; // true if a path has been found AStPathNode *node_array; // an array of nodes UUtUns16 num_allocs; // num nodes alloced so far - + UUtBool params_set; // true if required parameters are set - + UUtUns16 dir_index; // index of ASgDir to use UUtUns32 *obstruction_bv;// bitvector that indicates whether obstructions @@ -150,11 +150,11 @@ struct AStPath // ====================================================================== AStPath *ASgAstar_Path; -static UUtUns16 ASgDir[AScNumDirLists][8] = +static UUtUns16 ASgDir[AScNumDirLists][8] = { {0, 1, 2, 3, 4, 5, 6, 7}, {7, 6, 5, 4, 3, 2, 1, 0}, - {0, 2, 4, 6, 1, 3, 5, 7}, + {0, 2, 4, 6, 1, 3, 5, 7}, {1, 3, 5, 7, 0, 2, 4, 6} }; @@ -227,14 +227,14 @@ ASiBuildDebugGridEvaluation( static UUtBool ASiCollisionTest( AStPath *inAstar, - UUtBool inStartTest, + UUtBool inStartTest, AStGridPoint *inPoint); -static UUtBool +static UUtBool ASiDetermineEndPoint( AStPath *inAstar); -static UUtBool +static UUtBool ASiTryEndPoint( AStPath *inAstar, UUtInt16 inX, @@ -251,7 +251,7 @@ ASiAstarHeap_CompareFunc( static void ASiAstarHeap_NotifyLocation( UUtUns32 inUserData, - UUtUns16 inElement, + UUtUns16 inElement, UUtUns16 inHeapLocation); static void @@ -310,7 +310,7 @@ ASiDistEstimate( static UUtError iDetectLoop( UUtUns32 inNodeArraySize, - AStPathNode *inNodeArray, + AStPathNode *inNodeArray, AStPathNode *inNode); // ====================================================================== @@ -338,7 +338,7 @@ ASrInitialize( #if PERFORMANCE_TIMER ASgPath_Generate_Timer = UUrPerformanceTimer_New("AS_Path_Generate"); #endif - + return UUcError_None; } @@ -361,12 +361,12 @@ ASrPath_New( void) { AStPath *astar; - + astar = (AStPath *) UUrMemory_Block_NewClear(sizeof(AStPath)); if (astar == NULL) { goto fail; } - + // initialize astar astar->room = NULL; astar->path_start = NULL; @@ -383,9 +383,9 @@ ASrPath_New( if (astar->index_array == NULL) { goto fail; } - + astar->dir_index = 0; - + astar->obstruction_bv = UUrBitVector_New(2 * PHcMaxObstructions); if (astar->obstruction_bv == NULL) { goto fail; @@ -429,17 +429,17 @@ ASrPath_Delete( UUrMemory_Block_Delete((*ioAstar)->node_array); (*ioAstar)->node_array = NULL; } - + if ((*ioAstar)->index_array) { UUrMemory_Block_Delete((*ioAstar)->index_array); (*ioAstar)->index_array = NULL; } - + if ((*ioAstar)->obstruction_bv) { UUrBitVector_Dispose((*ioAstar)->obstruction_bv); (*ioAstar)->obstruction_bv = NULL; } - + #if ASTAR_USE_HEAP if ((*ioAstar)->open_heap.heap) { UUrMemory_Block_Delete((*ioAstar)->open_heap.heap); @@ -476,7 +476,7 @@ ASrPath_Generate( #if PERFORMANCE_TIMER UUrPerformanceTimer_Enter(ASgPath_Generate_Timer); #endif - + UUmAssert(ioAstar); UUmAssert(ioAstar->params_set != UUcFalse); @@ -504,7 +504,7 @@ ASrPath_Generate( // create a new path path = &ioAstar->node_array[ioAstar->num_allocs]; UUmAssert(path != NULL); - + ioAstar->num_allocs++; UUrMemory_Clear(path, sizeof(*path)); @@ -532,7 +532,7 @@ ASrPath_Generate( // node is now the last node in the found path ioAstar->path_end = path; ioAstar->finished = UUcTrue; - + // calculate the generated path ASiList_CalcWaypoints( ioAstar, @@ -593,7 +593,7 @@ ASrPath_Generate( // get the lowest cost node out of the open list path = ASiList_RemoveFirstNode(&ioAstar->open_list); #endif - + // try all of the grid locations around the current node, see if they // are possible, and calculate the location and cost if they are. for (i = 0; i < 8; i++) { @@ -621,7 +621,7 @@ ASrPath_Generate( // we don't insert the children in the same order each time we consider a node. // CB: not really sure why this is necessary, it's ordered by weight anyway... ? ioAstar->dir_index = (ioAstar->dir_index + 1) % AScNumDirLists; - + // insert all children of the current node for (i = 0; i < 8; i++) { @@ -654,7 +654,7 @@ ASrPath_Generate( // allocate the node and set up its entry in the cost array node_index = ioAstar->num_allocs++; - node = &ioAstar->node_array[node_index]; + node = &ioAstar->node_array[node_index]; ioAstar->index_array[location_index] = node_index; ASrIndexArray_Use(ioAstar, location_index); @@ -676,7 +676,7 @@ ASrPath_Generate( #endif // get a pointer to the node - node = &ioAstar->node_array[node_index]; + node = &ioAstar->node_array[node_index]; if (new_cost[dir] >= node->g) { // the new path is longer than the existing path, don't use it continue; @@ -713,7 +713,7 @@ ASrPath_Generate( // node is now the last node in the found path ioAstar->path_end = node; ioAstar->finished = UUcTrue; - + // calculate the generated path ASiList_CalcWaypoints( ioAstar, @@ -741,7 +741,7 @@ ASrPath_Generate( } UUmAssert(UUcError_None == iDetectLoop(ioAstar->num_allocs, ioAstar->node_array, node)); - + #if ASTAR_USE_HEAP if (newly_allocated_node) { ASiHeap_Insert(&ioAstar->open_heap, (UUtUns16) node_index); @@ -778,7 +778,7 @@ ASrPath_Generate( #if PERFORMANCE_TIMER UUrPerformanceTimer_Exit(ASgPath_Generate_Timer); #endif - + return result; } @@ -799,7 +799,7 @@ ASrPath_SetParams( IMtPoint2D end; UUmAssert(ioAstar && inRoom && inStart && inEnd); - + ioAstar->roomnode = inNode; ioAstar->room = inRoom; ioAstar->owner = inCharacter; @@ -831,17 +831,17 @@ ASrPath_SetParams( } ioAstar->index_array_used_count = 0; - + // clear the allocated nodes from the node_array ioAstar->num_allocs = 0; // no path has been found ioAstar->path_end = NULL; ioAstar->finished = UUcFalse; - + // the spheretree at the end point will need to be generated ioAstar->spheretree_set = UUcFalse; - + // don't allow the stair region unless we're trying to go there ioAstar->allow_stairs = inAllowStairs; @@ -866,13 +866,13 @@ UUtError ASrGetWorldGridValue( * Returns whether there's a big X in the path grid * at 'inPoint' */ - + AKtBNVNode *node; PHtNode *path_node; UUtUns16 gx,gy; UUtUns32 width; PHtSquare *grid; - + node = AKrNodeFromPoint(inPoint); if (!node) return UUcError_Generic; @@ -880,7 +880,7 @@ UUtError ASrGetWorldGridValue( outValue->weight = PHcClear; return UUcError_None; } - + path_node = PHrAkiraNodeToGraphNode(node, ONrGameState_GetGraph()); if (path_node == NULL) { return UUcError_Generic; @@ -892,13 +892,13 @@ UUtError ASrGetWorldGridValue( outValue->weight = PHcClear; } else { width = ASgAstar_Path->roomnode->gridX; - + PHrWorldToGridSpace(&gx,&gy,inPoint,&node->roomData); *outValue = GetCell(gx,gy); } return UUcError_None; } - + // ====================================================================== #if UUmCompiler == UUmCompiler_MWerks #pragma mark - @@ -926,7 +926,7 @@ ASiList_CalcWaypoints( // these values used by GetCell macro grid = ASgAstar_Path->roomnode->static_grid; width = ASgAstar_Path->roomnode->gridX; - + num_waypoints = 1; pointbuf[0] = inAstar->start; @@ -937,7 +937,7 @@ ASiList_CalcWaypoints( current_node = inAstar->path_end; prev_adjacent = (UUtUns16) -1; next_adjacent = current_node->adjacent; - + while (next_adjacent != (UUtUns16) -1) { UUmAssert((next_adjacent >= 0) && (next_adjacent < inAstar->num_allocs)); @@ -987,27 +987,27 @@ ASiList_CalcWaypoints( { UUtInt16 diff_x1; UUtInt16 diff_y1; - + UUtInt16 diff_x2; UUtInt16 diff_y2; diff_x1 = parent_node->loc.x - current_node->loc.x; diff_y1 = parent_node->loc.y - current_node->loc.y; - + diff_x2 = current_node->loc.x - child_node->loc.x; diff_y2 = current_node->loc.y - child_node->loc.y; - + if ((diff_x1 != diff_x2) || (diff_y1 != diff_y2)) { pointbuf[num_waypoints++] = current_node->loc; } } - + // go to the next child in the list parent_node = current_node; current_node = child_node; } } - + if ((inAstar->reachable_end.x != inAstar->end.x) || (inAstar->reachable_end.y != inAstar->end.y)) { // add a waypoint for the reachable end (where we actually were able to pathfind to) UUmAssert(num_waypoints < AI2cMax_PathPoints); @@ -1061,7 +1061,7 @@ ASiList_CalcWaypoints( // this point is our destination outWaypoints[(*outNumWaypoints)].point = inAstar->worldEnd; } - + // get the weight at this point if (grid != NULL) { square_val = GetCell(pointbuf[itr].x, pointbuf[itr].y); @@ -1122,7 +1122,7 @@ ASiBuildDebugPath( } UUmAssert(ASgDebugPath[ASgDebugPath_StartIndex].valid); - + // advance the start index along the buffer until we reach the end of the first path UUmAssert(ASgDebugPath_NumPaths > 0); ASgDebugPath_NumPaths--; @@ -1375,26 +1375,26 @@ ASiDistEstimate( // estimate the distance from this point to the desired destination diff_x = fabs(inEnd->x - inNode->loc.x); diff_y = fabs(inEnd->y - inNode->loc.y); - + return (diff_x > diff_y ? diff_x : diff_y); } - + if (0) // Euclidian { // estimate the distance from this point to the desired destination diff_x = inEnd->x - inNode->loc.x; diff_y = inEnd->y - inNode->loc.y; - + return (sqrt((diff_x * diff_x) + (diff_y * diff_y))); } - + if (1) // Manhattan { #endif // estimate the distance from this point to the desired destination diff_x = abs(inEnd->x - inNode->loc.x); diff_y = abs(inEnd->y - inNode->loc.y); - + return (float)(diff_x + diff_y); #if 0 } @@ -1431,42 +1431,42 @@ ASiPassable( x = inNode->loc.x; y = inNode->loc.y - 1; break; - + case 1: // up & right x = inNode->loc.x + 1; y = inNode->loc.y - 1; break; - + case 2: // right x = inNode->loc.x + 1; y = inNode->loc.y; break; - + case 3: // dn & right x = inNode->loc.x + 1; y = inNode->loc.y + 1; break; - + case 4: // dn x = inNode->loc.x; y = inNode->loc.y + 1; break; - + case 5: // dn & left x = inNode->loc.x - 1; y = inNode->loc.y + 1; break; - + case 6: // left x = inNode->loc.x - 1; y = inNode->loc.y; break; - + case 7: // up & left x = inNode->loc.x - 1; y = inNode->loc.y - 1; break; - + default: UUmAssert(!"ASiPassable: unknown direction (not in 0..7)"); break; @@ -1483,15 +1483,15 @@ ASiPassable( return UUcFalse; } } - + // set the new location outNewLoc->x = x; outNewLoc->y = y; - + // check to see that the square is passable for us new_flags = 0; if (!PHrSquareIsPassable(inAstar->owner, PHcPathMode_DirectedMovement, - inAstar->roomnode, inAstar->room, + inAstar->roomnode, inAstar->room, inAstar->obstruction_bv, x, y, &obstructed, &weight)) { new_flags |= AScStatusFlag_Impassable; } @@ -1537,7 +1537,7 @@ ASiPassable( // calculate the grid cost UUmAssert((weight >= 0) && (weight < PHcMax)); grid_cost = PHcPathWeight[weight]; - + // diagonal or orthogonal? if ((inNode->loc.x != outNewLoc->x) && (inNode->loc.y != outNewLoc->y)) { @@ -1549,7 +1549,7 @@ ASiPassable( // movement is orthogonal *outNewCost = (1.0f * grid_cost) + inNode->g; } - + *outNewFlags = new_flags; return UUcTrue; @@ -1560,7 +1560,7 @@ const PHtRoomData *ASrGetCurrentRoom(void) /********************* * Returns current room */ - + return ASgAstar_Path->room; } @@ -1591,13 +1591,13 @@ static UUtError iDetectLoop(UUtUns32 inNodeArraySize, AStPathNode *inNodeArray, AStPathNode *current_node = inNode; UUtUns16 depth; UUtUns16 itr; - + depth = 0; - + while(current_node != NULL) { nodeTable[depth] = current_node; - + if (current_node->adjacent == (UUtUns16) -1) { current_node = NULL; } else { @@ -1626,11 +1626,11 @@ void ASrDisplayWorkingGrid(void) /********** * Displays 'grid' for debugging */ - + UUtInt32 c,d,width,height; char ch; PHtSquare *grid,cell; - + grid = ASgAstar_Path->roomnode->static_grid; if (grid == NULL) @@ -1638,7 +1638,7 @@ void ASrDisplayWorkingGrid(void) width = ASgAstar_Path->roomnode->gridX; height = ASgAstar_Path->roomnode->gridY; - + for (c=0; cstart.x && d==ASgAstar_Path->start.y) ch = 'S'; else if (c==ASgAstar_Path->end.x && d==ASgAstar_Path->end.y) ch = 'E'; - + printf("%c", ch); } printf(""UUmNL); } - + getchar(); } @@ -1749,7 +1749,7 @@ static UUtBool ASiDetermineEndPoint(AStPath *inAstar) UUtInt16 v0, v1, test_v; // check to see if the endpoint is in fact passable - if so, don't bother with this - if (PHrSquareIsPassable(inAstar->owner, PHcPathMode_DirectedMovement, + if (PHrSquareIsPassable(inAstar->owner, PHcPathMode_DirectedMovement, inAstar->roomnode, inAstar->room, inAstar->obstruction_bv, inAstar->end.x, inAstar->end.y, NULL, NULL)) { inAstar->reachable_end = inAstar->end; @@ -1758,20 +1758,20 @@ static UUtBool ASiDetermineEndPoint(AStPath *inAstar) for (radius = 1; radius <= AScMaxDestImpassableRadius; radius++) { // try + and -x - v0 = inAstar->end.x - radius; + v0 = inAstar->end.x - radius; v1 = inAstar->end.x + radius; for (test_v = inAstar->end.y - radius; test_v <= inAstar->end.y + radius; test_v++) { if (ASiTryEndPoint(inAstar, v0, test_v)) { return UUcTrue; } - + if (ASiTryEndPoint(inAstar, v1, test_v)) { return UUcTrue; } } // try + and -y - v0 = inAstar->end.y - radius; + v0 = inAstar->end.y - radius; v1 = inAstar->end.y + radius; for (test_v = inAstar->end.x - (radius - 1); test_v <= inAstar->end.x + (radius - 1); test_v++) { if (ASiTryEndPoint(inAstar, test_v, v0)) { @@ -1798,8 +1798,8 @@ static UUtBool ASiTryEndPoint(AStPath *inAstar, UUtInt16 inX, UUtInt16 inY) } // can only go to passable squares - if (!PHrSquareIsPassable(inAstar->owner, PHcPathMode_DirectedMovement, - inAstar->roomnode, inAstar->room, + if (!PHrSquareIsPassable(inAstar->owner, PHcPathMode_DirectedMovement, + inAstar->roomnode, inAstar->room, inAstar->obstruction_bv, inX, inY, NULL, NULL)) { return UUcFalse; } @@ -1955,7 +1955,7 @@ ASiHeap_ReorderElement( // check to see whether we need to bubble up parent_location = inHeapLocation >> 1; - if (ioHeap->func_compare(ioHeap->heap_userdata, ioHeap->heap[inHeapLocation], + if (ioHeap->func_compare(ioHeap->heap_userdata, ioHeap->heap[inHeapLocation], ioHeap->heap[parent_location]) > 0) { // this element is a higher priority than its parent ASiHeap_BubbleUp(ioHeap, inHeapLocation); @@ -1994,7 +1994,7 @@ ASiAstarHeap_CompareFunc( static void ASiAstarHeap_NotifyLocation( UUtUns32 inUserData, - UUtUns16 inElement, + UUtUns16 inElement, UUtUns16 inHeapLocation) { AStPath *astar = (AStPath *) inUserData; @@ -2029,7 +2029,7 @@ ASiList_InsertNode( temp = *inList; prev = NULL; - + while (temp) { if (temp->f >= inNode->f) @@ -2038,7 +2038,7 @@ ASiList_InsertNode( inNode->next = temp; inNode->prev = temp->prev; temp->prev = inNode; - + if (inNode->prev) { // set the previous node's next to point to inNode @@ -2058,7 +2058,7 @@ ASiList_InsertNode( temp = temp->next; } } - + if (temp == NULL) { // insert at the end of the list @@ -2098,21 +2098,21 @@ ASiList_RemoveFirstNode( AStPathNode **inList) { AStPathNode *return_node; - + if (*inList) { // save the first node in the list return_node = *inList; - + // point list to next node in the list *inList = (*inList)->next; - + // update the prev pointer for the new first node in the list if (*inList) { (*inList)->prev = NULL; } - + // the return_node doesn't point to anything anymore return_node->next = NULL; } @@ -2120,7 +2120,7 @@ ASiList_RemoveFirstNode( { return_node = NULL; } - + // return the first node in the list return return_node; } @@ -2132,7 +2132,7 @@ ASiList_RemoveNode_Fast( AStPathNode *inNode) { // remove this node from the list - + // update the next pointer of the prev node in the list if (inNode->prev) { @@ -2143,13 +2143,13 @@ ASiList_RemoveNode_Fast( // this is the start of the list *inList = inNode->next; } - + // update the prev pointer of the next node in the list if (inNode->next) { inNode->next->prev = inNode->prev; } - + // inNode no longer points to anything inNode->prev = inNode->next = NULL; } diff --git a/OniProj/OniGameSource/Oni_AI/Oni_AStar.h b/OniProj/OniGameSource/Oni_AI/Oni_AStar.h index 202f2be..8bd9174 100644 --- a/OniProj/OniGameSource/Oni_AI/Oni_AStar.h +++ b/OniProj/OniGameSource/Oni_AI/Oni_AStar.h @@ -44,11 +44,11 @@ extern AStPath *ASgAstar_Path; UUtError ASrInitialize( void); - + void ASrTerminate( void); - + // ---------------------------------------------------------------------- // allocates a data for a new path. You really only need one of these // per game. Use ASrPath_SetParams when a room has changed @@ -93,7 +93,7 @@ ASrPath_SetParams( UUtBool inAllowStairs, UUtBool inShowDebug, UUtBool inShowEvaluation); - + // Misc UUtError ASrGetWorldGridValue( @@ -113,4 +113,4 @@ void ASrDisplayDebuggingInfo(void); // CB: just for debugging access to variables void ASrDebugGetGridPoints(AStPath *inPath, IMtPoint2D *outStart, IMtPoint2D *outEnd); -#endif /* ONI_ASTAR_H */ \ No newline at end of file +#endif /* ONI_ASTAR_H */ diff --git a/OniProj/OniGameSource/Oni_Action.h b/OniProj/OniGameSource/Oni_Action.h index 6c64233..de723f9 100644 --- a/OniProj/OniGameSource/Oni_Action.h +++ b/OniProj/OniGameSource/Oni_Action.h @@ -1 +1 @@ -#error "Oni_Action.h is obsolete" \ No newline at end of file +#error "Oni_Action.h is obsolete" diff --git a/OniProj/OniGameSource/Oni_Aiming.c b/OniProj/OniGameSource/Oni_Aiming.c index 8158ca1..43ae546 100644 --- a/OniProj/OniGameSource/Oni_Aiming.c +++ b/OniProj/OniGameSource/Oni_Aiming.c @@ -1,8 +1,8 @@ /* Oni_Aiming.c - + This file contains all aiming related code - + Author: Quinn Dunki, Michael Evans c1998 Bungie */ @@ -37,7 +37,7 @@ void AMrInitialize(void) /********************* * One time initialization */ - + UUtError error; error; @@ -66,7 +66,7 @@ static void AMiDrawAxes( M3tGeometry *axes = NULL; UUtBool axesExists; M3tPoint3D x={50.0f,0,0}, y={0,50.0f,0}, z={0,0,50.0f}; - + UUmAssertReadPtr(inLocation, sizeof(*inLocation)); error = TMrInstance_GetDataPtr(M3cTemplate_Geometry, "axes", (void **) &axes); @@ -90,7 +90,7 @@ static void AMiDrawAxes( M3rMatrixStack_UniformScale(inScale); M3rGeometry_Draw(axes); M3rMatrixStack_Pop(); - + MUmVector_Increment(x,*inLocation); MUmVector_Increment(y,*inLocation); MUmVector_Increment(z,*inLocation); @@ -147,7 +147,7 @@ void AMrRayToEverything( * ray (which is pretty unlikely) the outResult->resultType * will be AMcRayResult_None. */ - + M3tPoint3D rayp = *inRayOrigin; M3tVector3D rayv = *inRayDir; ONtCharacter *hitCharacter; @@ -179,7 +179,7 @@ void AMrRayToEverything( // Check for character collision if( inIgnoreCharacterIndex != (UUtUns16) -2 ) AMrRayToCharacter(inIgnoreCharacterIndex, &rayp,&rayv,UUcFalse,&hitCharacter,&hitPartIndex,&charPoint); - + // Check for object collision AMrRayToObject(&rayp,&rayv,AMcPickLimit,&hitObject,&objPoint); @@ -224,7 +224,7 @@ void AMrRayToEverything( returnWhat = AMcRayResult_Environment; } } - + #if TOOL_VERSION if (character_laser_sight) { if (AMgShow_Closest && collision) { @@ -232,10 +232,10 @@ void AMrRayToEverything( AKtGQ_Render* gq = env->gqRenderArray->gqRender + AKgCollisionList[0].gqIndex; AKtGQ_Collision* gqCol = env->gqCollisionArray->gqCollision + AKgCollisionList[0].gqIndex; M3tTextureMap* textureMap = env->textureMapArray->maps[gq->textureMapIndex]; - + COrConsole_Printf("%d, %s, %x", AKgCollisionList[0].gqIndex, textureMap->debugName, gqCol->planeEquIndex); } - + if (AMgShow_Filenames) { { UUtUns32 clear_itr; @@ -288,12 +288,12 @@ void AMrRayToEverything( } sprintf(ONgAimingLine[1].text, "Gunk [%d]", AKgCollisionList[0].gqIndex); - sprintf(ONgAimingLine[2].text, "%s in file %s", - (gqDebug == NULL) ? "UNKNOWN" : gqDebug->object_name, + sprintf(ONgAimingLine[2].text, "%s in file %s", + (gqDebug == NULL) ? "UNKNOWN" : gqDebug->object_name, (gqDebug == NULL) ? "UNKNOWN" : gqDebug->file_name); sprintf(ONgAimingLine[3].text, "%s %s %s", texture_name, type_string, mip_map_string); sprintf(ONgAimingLine[4].text, "gq flags = %x", gq_general->flags); - sprintf(ONgAimingLine[5].text, "2sd %d !c %d !oc %d !cc %d !ocl %d", + sprintf(ONgAimingLine[5].text, "2sd %d !c %d !oc %d !cc %d !ocl %d", (gq_general->flags & AKcGQ_Flag_DrawBothSides) ? 1 : 0, (gq_general->flags & AKcGQ_Flag_No_Collision) ? 1 : 0, (gq_general->flags & AKcGQ_Flag_No_Object_Collision) ? 1 : 0, @@ -311,28 +311,28 @@ void AMrRayToEverything( sprintf(ONgAimingLine[9].text, "%2.2f %2.2f %2.2f", this_environment_point->x, this_environment_point->y, this_environment_point->z); this_environment_point = environment_points + gq_general->m3Quad.vertexIndices.indices[3]; - sprintf(ONgAimingLine[10].text, "%2.2f %2.2f %2.2f", this_environment_point->x, this_environment_point->y, this_environment_point->z); + sprintf(ONgAimingLine[10].text, "%2.2f %2.2f %2.2f", this_environment_point->x, this_environment_point->y, this_environment_point->z); } } } #endif // TOOL_VERSION - + switch(returnWhat) { - case AMcRayResult_Character: + case AMcRayResult_Character: outResult->resultType = AMcRayResult_Character; outResult->resultData.rayToCharacter.hitPartIndex = hitPartIndex; outResult->resultData.rayToCharacter.hitCharacter = hitCharacter; outResult->intersection = charPoint; break; - case AMcRayResult_Object: + case AMcRayResult_Object: outResult->resultType = AMcRayResult_Object; outResult->resultData.rayToObject.hitObject = hitObject; outResult->intersection = objPoint; break; - case AMcRayResult_Environment: + case AMcRayResult_Environment: outResult->resultType = AMcRayResult_Environment; outResult->resultData.rayToEnvironment.hitGQIndex = AKgCollisionList[0].gqIndex; outResult->intersection = AKgCollisionList[0].collisionPoint; @@ -343,18 +343,18 @@ void AMrRayToEverything( MUmVector_Add(outResult->intersection, rayv, rayp); break; - default: + default: UUmAssert(!"unhandled case"); } } UUtBool AMrRayToCharacter( UUtUns16 inIgnoreCharacterIndex, - const M3tPoint3D *inRayOrigin, + const M3tPoint3D *inRayOrigin, const M3tVector3D *inRayDir, UUtBool inStopAtOneT, - ONtCharacter **outCharacter, - UUtUns16 *outPartIndex, + ONtCharacter **outCharacter, + UUtUns16 *outPartIndex, M3tPoint3D *outIntersection) { /************************ @@ -368,7 +368,7 @@ UUtBool AMrRayToCharacter( * Also returns UUcTrue if there was a collision, UUcFalse otherwise. * */ - + ONtCharacter *closestCharacter = NULL; float current_distance_squared; @@ -395,14 +395,14 @@ UUtBool AMrRayToCharacter( active_character_count = ONrGameState_ActiveCharacterList_Count(); stop_at_first_intersection = ((outCharacter == NULL) && (outPartIndex == NULL) && (outIntersection == NULL)); - + for(itr = 0; itr < active_character_count; itr++) { ONtCharacter *curCharacter = active_character_list[itr]; ONtActiveCharacter *active_character = ONrGetActiveCharacter(curCharacter); TRtBody *curBody = ONrCharacter_GetBody(curCharacter, TRcBody_SuperHigh); UUtBool intersection; - + if (curCharacter->index == inIgnoreCharacterIndex) { continue; } @@ -432,7 +432,7 @@ UUtBool AMrRayToCharacter( closestIntersection = curIntersection; } } - + if (closestCharacter != NULL) { if (outCharacter != NULL) { @@ -466,10 +466,10 @@ UUtBool PHrCollision_Point(const PHtPhysicsContext *inContext, M3tPoint3D *inFro } UUtBool AMrRayToObject( - const M3tPoint3D *inRayOrigin, + const M3tPoint3D *inRayOrigin, const M3tVector3D *inRayDir, float inMaxDistance, - OBtObject **outObject, + OBtObject **outObject, M3tPoint3D *outIntersection) { /************************ @@ -482,7 +482,7 @@ UUtBool AMrRayToObject( * Also returns UUcTrue if there was a collision, UUcFalse otherwise. * */ - + OBtObject *closestObject = NULL; float current_distance_squared; @@ -508,7 +508,7 @@ UUtBool AMrRayToObject( for (objectIndex = 0; objectIndex < ONgGameState->objects->numObjects; objectIndex++) { OBtObject *curObject = ONgGameState->objects->object_list + objectIndex; - + if (0 == (curObject->flags & OBcFlags_InUse)) { continue; } @@ -528,7 +528,7 @@ UUtBool AMrRayToObject( intersection = AMrRaySphereIntersection(&curObject->physics->sphereTree->sphere, inRayOrigin, inRayDir, &curIntersection); } - + if (intersection) { // CB: I do not understand why this was a good idea, surely we want the closest intersection rather than the intersection with // the closest object? @@ -552,7 +552,7 @@ UUtBool AMrRayToObject( } } } - + if (closestObject != NULL) { if (outObject != NULL) { *outObject = closestObject; @@ -574,7 +574,7 @@ UUtBool AMrRaySphereIntersection(const M3tBoundingSphere *inSphere, const M3tPoi * * outIntersection is optional */ - + UUtBool intersection; float v,disc,d, EO_sq, r_sq; @@ -584,7 +584,7 @@ UUtBool AMrRaySphereIntersection(const M3tBoundingSphere *inSphere, const M3tPoi UUmAssertReadPtr(inRayDir, sizeof(*inRayDir)); UUmAssert(MUmVector_IsNormalized(*inRayDir)); UUmAssert(UUmFloat_CompareEquSloppy(MUmVector_GetLength(*inRayDir), 1.f)); - + MUmVector_Subtract(EO,inSphere->center,(*inRayOrigin)); EO_sq = MUrVector_DotProduct(&EO,&EO); r_sq = UUmSQR(inSphere->radius); @@ -595,7 +595,7 @@ UUtBool AMrRaySphereIntersection(const M3tBoundingSphere *inSphere, const M3tPoi v = MUrVector_DotProduct(&EO,inRayDir); disc = r_sq - ((EO_sq - v*v)); - + if (disc < 0) { intersection = UUcFalse; } @@ -603,7 +603,7 @@ UUtBool AMrRaySphereIntersection(const M3tBoundingSphere *inSphere, const M3tPoi M3tVector3D rayToIntersection; M3tPoint3D intersectionPoint; float dot; - + d = MUrSqrt(disc); rayDir = *inRayDir; MUmVector_Scale(rayDir,v-d); diff --git a/OniProj/OniGameSource/Oni_Aiming.h b/OniProj/OniGameSource/Oni_Aiming.h index d94d39f..80ca8ca 100644 --- a/OniProj/OniGameSource/Oni_Aiming.h +++ b/OniProj/OniGameSource/Oni_Aiming.h @@ -2,9 +2,9 @@ /* Oni_Aiming.h - + This file contains all aiming related header code - + Author: Quinn Dunki c1998 Bungie */ @@ -41,7 +41,7 @@ typedef struct OBtObject *hitObject; } AMtRayData_Object; -typedef struct +typedef struct { UUtUns32 hitGQIndex; } AMtRayData_Environment; @@ -64,7 +64,7 @@ typedef struct { AMtRayResultType resultType; AMtRayData resultData; - + M3tPoint3D intersection; } AMtRayResults; @@ -94,18 +94,18 @@ UUtBool AMrRaySphereIntersection( UUtBool AMrRayToCharacter( UUtUns16 inIgnoreCharacterIndex, - const M3tPoint3D *inRayOrigin, + const M3tPoint3D *inRayOrigin, const M3tVector3D *inRayDir, UUtBool inStopAtOneT, - ONtCharacter **outCharacter, - UUtUns16 *outPartIndex, + ONtCharacter **outCharacter, + UUtUns16 *outPartIndex, M3tPoint3D *outIntersection); UUtBool AMrRayToObject( - const M3tPoint3D *inRayOrigin, + const M3tPoint3D *inRayOrigin, const M3tVector3D *inRayDir, float inMaxDistance, - OBtObject **outObject, + OBtObject **outObject, M3tPoint3D *outIntersection); UUtBool PHrCollision_Point(const PHtPhysicsContext *inContext, M3tPoint3D *inFrom, M3tVector3D *inVector); diff --git a/OniProj/OniGameSource/Oni_BinaryData/Oni_BinaryData.c b/OniProj/OniGameSource/Oni_BinaryData/Oni_BinaryData.c index 0c0dfad..a8062c2 100644 --- a/OniProj/OniGameSource/Oni_BinaryData/Oni_BinaryData.c +++ b/OniProj/OniGameSource/Oni_BinaryData/Oni_BinaryData.c @@ -39,7 +39,7 @@ typedef struct OBDtClassPath { BDtClassType class_type; char *path; - + } OBDtClassPath; // ====================================================================== @@ -83,12 +83,12 @@ OBDiGetDirectoryRef( GRtGroup* prefGroup; char *binaryDirName; char binaryDirNameStr[256]; - + *outFileRef = NULL; #if STAND_ALONE_ONLY return UUcError_Generic; -#endif +#endif if (OBDgBinaryDataFolder == NULL) { // CB: if we've already tried to find the binary data folder, @@ -109,31 +109,31 @@ OBDiGetDirectoryRef( error = GRrGroup_Context_NewFromFileRef(&prefFileRef, NULL, NULL, &prefGroupContext, &prefGroup); - + if (error != UUcError_None) return error; - + // look for the BinDir in the preferences.txt error = GRrGroup_GetString(prefGroup, "BinFileDir", &binaryDirName); if (error != UUcError_None) { char * dataFileDir; - + // if it wasn't found get teh DataFileDir error = GRrGroup_GetString(prefGroup, "DataFileDir", &dataFileDir); if (error != UUcError_None) { return error; } - + // and append the binary data path to the data file dir name sprintf(binaryDirNameStr, "%s\\%s", dataFileDir, OBDgBinaryPath); binaryDirName = binaryDirNameStr; } - + // make a file ref for the binary data folder error = BFrFileRef_MakeFromName(binaryDirName, &OBDgBinaryDataFolder); if (error != UUcError_None) { return error; } - + GRrGroup_Context_Delete(prefGroupContext); - + // CB: check that the binary directory exists if (BFrFileRef_FileExists(OBDgBinaryDataFolder) == UUcFalse) { @@ -182,16 +182,16 @@ OBDiGetDirectoryRef( break; } } - + // CB: must not be unknown class type. UUmAssert(class_path->path != NULL); // CB: build directory for this class error = BFrFileRef_DuplicateAndAppendName(&subdirFileRef, class_path->path, - outFileRef); + outFileRef); UUmError_ReturnOnErrorMsg(error, "Could not form binarydata class-folder"); - + // CB: check that the directory exists if (BFrFileRef_FileExists(*outFileRef) == UUcFalse) { @@ -232,18 +232,18 @@ OBDrBinaryData_Load( UUtUns32 data_size; char identifier[BFcMaxFileNameLength]; UUtBool locked; - + // load the file into memory error = BFrFileRef_LoadIntoMemory(inFileRef, &data_size, &data); UUmError_ReturnOnError(error); - + // get the identifier UUrString_Copy(identifier, BFrFileRef_GetLeafName(inFileRef), BFcMaxFileNameLength); UUrString_StripExtension(identifier); - + // get the locked status of the file locked = BFrFileRef_IsLocked(inFileRef); - + // process the file error = BDrBinaryLoader( @@ -254,7 +254,7 @@ OBDrBinaryData_Load( UUcTrue); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -275,16 +275,16 @@ OBDrBinaryData_Save( char file_name[BFcMaxFileNameLength]; UUrMemory_Block_VerifyList(); - + // create the diretory ref error = OBDiGetDirectoryRef(inClassType, inLevelNumber, UUcTrue, &dir_ref); if (error != UUcError_None) { return error; } if (dir_ref == NULL) { return UUcError_Generic; } - + // make the identifier into a file name UUrString_Copy(file_name, inIdentifier, BFcMaxFileNameLength); UUrString_Cat(file_name, (inAutosave) ? ".sav" : ".bin", BFcMaxFileNameLength); - + // create the file ref error = BFrFileRef_DuplicateAndAppendName( @@ -292,17 +292,17 @@ OBDrBinaryData_Save( file_name, &file_ref); UUmError_ReturnOnError(error); - + // dispose of the directory ref UUrMemory_Block_Delete(dir_ref); - + // create the file if it doesn't exist if (BFrFileRef_FileExists(file_ref) == UUcFalse) { error = BFrFile_Create(file_ref); UUmError_ReturnOnErrorMsg(error, "Could not create the file."); } - + // open the file for writing error = BFrFile_Open( @@ -314,7 +314,7 @@ OBDrBinaryData_Save( inIdentifier, inLevelNumber); return UUcError_None; } - + // write to the file error = BDrBinaryData_Write( @@ -323,14 +323,14 @@ OBDrBinaryData_Save( inBufferSize, file); UUmError_ReturnOnErrorMsg(error, "Unable to write to file."); - + // set the EOF BFrFile_SetEOF(file); - + // close the file BFrFile_Close(file); UUrMemory_Block_Delete(file_ref); - + return error; } @@ -345,8 +345,8 @@ OBDrLevel_Load( UUtUns16 inLevelNumber) { UUtError error; - OBDtClassPath *class_path; - + OBDtClassPath *class_path; + // load the binary data files for (class_path = OBDgClassPaths; class_path->path != NULL; @@ -354,7 +354,7 @@ OBDrLevel_Load( { BFtFileRef *dir_ref; BFtFileIterator *file_iterator; - + // create a directory ref for the class path error = OBDiGetDirectoryRef(class_path->class_type, inLevelNumber, UUcFalse, &dir_ref); if (error != UUcError_None) @@ -367,7 +367,7 @@ OBDrLevel_Load( { continue; } - + // see if it exists if (BFrFileRef_FileExists(dir_ref)) { @@ -379,17 +379,17 @@ OBDrLevel_Load( NULL, &file_iterator); if (error != UUcError_None) { continue; } - + // iterate over the files while (1) { BFtFileRef file_ref; const char *file_ext; - + // get the file ref error = BFrDirectory_FileIterator_Next(file_iterator, &file_ref); if (error != UUcError_None) { break; } - + file_ext = BFrFileRef_GetSuffixName(&file_ref); if ((file_ext != NULL) && (UUrString_Compare_NoCase(file_ext, "bin") == 0)) { // load the file @@ -397,14 +397,14 @@ OBDrLevel_Load( if (error != UUcError_None) { continue; } } } - + // dispose of the directory file iterator BFrDirectory_FileIterator_Delete(file_iterator); } // dispose of the directory ref UUrMemory_Block_Delete(dir_ref); } - + return UUcError_None; } @@ -457,7 +457,7 @@ OBDrInitialize( // initialize globals OBDgBinaryDataFolder = NULL; OBDgLookedForBinaryData = UUcFalse; - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_BinaryData/Oni_BinaryData.h b/OniProj/OniGameSource/Oni_BinaryData/Oni_BinaryData.h index 4acf680..456e069 100644 --- a/OniProj/OniGameSource/Oni_BinaryData/Oni_BinaryData.h +++ b/OniProj/OniGameSource/Oni_BinaryData/Oni_BinaryData.h @@ -55,7 +55,7 @@ OBDrLevel_Load( void OBDrLevel_Unload( void); - + // ---------------------------------------------------------------------- void OBDrMakeDirty( @@ -80,4 +80,4 @@ OBDrUpdate( UUtUns32 inTime); // ====================================================================== -#endif /* ONI_BINARYDATA_H */ \ No newline at end of file +#endif /* ONI_BINARYDATA_H */ diff --git a/OniProj/OniGameSource/Oni_Bink.c b/OniProj/OniGameSource/Oni_Bink.c index 1c1a2c7..9585ead 100644 --- a/OniProj/OniGameSource/Oni_Bink.c +++ b/OniProj/OniGameSource/Oni_Bink.c @@ -27,28 +27,28 @@ ONrMovie_Play( UUtWindow window; BFtFileRef *dir_ref; BFtFileRef *movie_ref; - + // get a pointer to the window window = ONgPlatformData.gameWindow; - + // get the DataFileDirectory error = BFrFileRef_Duplicate(&ONgGameDataFolder, &dir_ref); UUmError_ReturnOnError(error); - + // create a file ref for the movie error = BFrFileRef_DuplicateAndAppendName(dir_ref, inMovieName, &movie_ref); UUmError_ReturnOnError(error); - + // play the movie error = BKrMovie_Play(movie_ref, window, inScale); UUmError_ReturnOnError(error); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + BFrFileRef_Dispose(movie_ref); movie_ref = NULL; - + return UUcError_None; } @@ -67,28 +67,28 @@ ONrMovie_Play_Hardware( UUtWindow window; BFtFileRef *dir_ref; BFtFileRef *movie_ref; - + // get a pointer to the window window = ONgPlatformData.gameWindow; - + // get the DataFileDirectory error = BFrFileRef_Duplicate(&ONgGameDataFolder, &dir_ref); UUmError_ReturnOnError(error); - + // create a file ref for the movie error = BFrFileRef_DuplicateAndAppendName(dir_ref, inMovieName, &movie_ref); UUmError_ReturnOnError(error); - + // play the movie error = BKrMovie_Play_OpenGL(movie_ref, window, inScale); UUmError_ReturnOnError(error); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + BFrFileRef_Dispose(movie_ref); movie_ref = NULL; - + return UUcError_None; } @@ -104,19 +104,19 @@ ONiMovie_Play( { UUtError error; char name[BFcMaxFileNameLength]; - + if (strlen(inParameterList[0].val.str) >= (BFcMaxFileNameLength - strlen(".bik"))) { COrConsole_Printf("The movie name is too long."); return UUcError_None; } - + UUrString_Copy(name, inParameterList[0].val.str, BFcMaxFileNameLength); UUrString_Cat(name, ".bik", BFcMaxFileNameLength); - + error = ONrMovie_Play(name, BKcScale_Default); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -126,8 +126,8 @@ ONrMovie_Initialize( void) { UUtError error; - - error = + + error = SLrScript_Command_Register_Void( "movie_play", "function to start a movie playing", @@ -136,4 +136,4 @@ ONrMovie_Initialize( UUmError_ReturnOnError(error); return UUcError_None; -} \ No newline at end of file +} diff --git a/OniProj/OniGameSource/Oni_Bink.h b/OniProj/OniGameSource/Oni_Bink.h index 33bec7a..b848fd7 100644 --- a/OniProj/OniGameSource/Oni_Bink.h +++ b/OniProj/OniGameSource/Oni_Bink.h @@ -31,6 +31,6 @@ ONrMovie_Play_Hardware( UUtError ONrMovie_Initialize( void); - + // ====================================================================== -#endif /* ONI_BINK */ \ No newline at end of file +#endif /* ONI_BINK */ diff --git a/OniProj/OniGameSource/Oni_Camera.c b/OniProj/OniGameSource/Oni_Camera.c index 1a6cfd5..0f6fbd4 100644 --- a/OniProj/OniGameSource/Oni_Camera.c +++ b/OniProj/OniGameSource/Oni_Camera.c @@ -1,12 +1,12 @@ /* FILE: BFW.h - + AUTHOR: Michael Evans, Quinn Dunki - + CREATED: May 17, 1997 - + PURPOSE: camera code - + Copyright 1997 - 1999 */ @@ -77,7 +77,7 @@ CAiJello( float M3rPlaneEquation_Evaluate(M3tPlaneEquation *inPlaneEquation, M3tPoint3D *inPoint) { float result; - + result =inPlaneEquation->a * inPoint->x + inPlaneEquation->b * inPoint->y + inPlaneEquation->c * inPoint->z + inPlaneEquation->d; return result; @@ -100,7 +100,7 @@ static void CAiTrackJello(CAtCamera *inCamera) AKtGQ_Collision *gq_collision_array = env->gqCollisionArray->gqCollision; M3tPlaneEquation *plane_array = env->planeArray->planes; - typedef struct JelloRayOffset + typedef struct JelloRayOffset { float x; float y; @@ -109,7 +109,7 @@ static void CAiTrackJello(CAtCamera *inCamera) if (!CAgJello) { return; } - + MUrVector_CrossProduct(&inCamera->viewData.upVector,&inCamera->viewData.viewVector,&sideVector); sideVector.y+=2.0f; MUmVector_Scale(sideVector,3.0f); @@ -122,7 +122,7 @@ static void CAiTrackJello(CAtCamera *inCamera) CAgNumJelloRays = UUmPin(CAgNumJelloRays, 0, CAcMaxJelloRays); for (rayIndex=0; rayIndex < CAgNumJelloRays; rayIndex++) - { + { if (rayIndex == 1 || rayIndex == 3) { sideVector.y = -sideVector.y; } @@ -144,7 +144,7 @@ static void CAiTrackJello(CAtCamera *inCamera) float length_to_focus = MUmVector_GetLength(toFocus); M3tVector3D jello_vector = toFocus; - MUrVector_SetLength(&jello_vector, UUmMax(length_to_focus - CAgJello_Radius, 1.f)); + MUrVector_SetLength(&jello_vector, UUmMax(length_to_focus - CAgJello_Radius, 1.f)); sphere.center = inCamera->viewData.location; sphere.radius = CAgJello_Radius; @@ -234,7 +234,7 @@ static void CAiTrackJello(CAtCamera *inCamera) char_side_1_positive = M3rPlaneEquation_Evaluate(plane_equation, &character_location_1) > 0; char_side_2_positive = M3rPlaneEquation_Evaluate(plane_equation, &character_location_2) > 0; - if ((camera_side_positive & char_side_1_positive & char_side_1_positive) == (camera_side_positive | char_side_1_positive | char_side_2_positive)) + if ((camera_side_positive & char_side_1_positive & char_side_1_positive) == (camera_side_positive | char_side_1_positive | char_side_2_positive)) { continue; } @@ -249,7 +249,7 @@ static void CAiTrackJello(CAtCamera *inCamera) // given a view vector, builds a trivial up vector M3tVector3D CArBuildUpVector(const M3tVector3D *inViewVector) -{ +{ M3tVector3D upVector; M3tVector3D sideVector; @@ -258,7 +258,7 @@ M3tVector3D CArBuildUpVector(const M3tVector3D *inViewVector) sideVector.y = 0; sideVector.z = -inViewVector->x; MUrVector_CrossProduct(inViewVector,&sideVector,&upVector); - + // Keep things on the level MUrNormalize(&upVector); @@ -276,7 +276,7 @@ UUtError CArLevelBegin(void) void CArLevelEnd( void) { - + } @@ -408,7 +408,7 @@ static UUtBool CArOrbit_Update(UUtUns32 ticks, UUtUns32 inNumActions, const LItA UUtBool activate = UUcFalse; ONtActiveCharacter *active_character; - if (ticks > 0) + if (ticks > 0) { CAtCamera *camera = ONgGameState->local.camera; CAtOrbitData *orbitData = &camera->modeData.orbit; @@ -421,7 +421,7 @@ static UUtBool CArOrbit_Update(UUtUns32 ticks, UUtUns32 inNumActions, const LItA if (orbitData->stop_angle >= 0) { UUtBool stop = UUcFalse; float new_angle = orbitData->current_angle; - + stop |= (old_angle <= stop_angle) & (new_angle >= stop_angle); stop |= (old_angle >= stop_angle) & (new_angle <= stop_angle); stop |= (old_angle <= (stop_angle + M3c2Pi)) & (new_angle >= (stop_angle + M3c2Pi)); @@ -474,7 +474,7 @@ static UUtBool CArAnimate_Update(UUtUns32 ticks, UUtUns32 inNumActions, const LI { UUtBool activate = UUcFalse; - if (ticks > 0) + if (ticks > 0) { CAtCamera *camera = ONgGameState->local.camera; CAtAnimateData *modeData = &camera->modeData.animate; @@ -513,7 +513,7 @@ static void CArUpdate_Internal(UUtUns32 ticks, UUtUns32 numActions, const LItAct /********** * Performs camera maintenance for a frame */ - + CAtCamera *camera = ONgGameState->local.camera; UUtBool activate = UUcFalse; @@ -544,12 +544,12 @@ static void CArUpdate_Internal(UUtUns32 ticks, UUtUns32 numActions, const LItAct default: UUmAssert(!"blam"); } - + // 11) notify the geometry context if (activate) { CAiActivateCamera(camera); } - + return; } @@ -584,7 +584,7 @@ void CArOrbit_Enter(float inSpeed, float inStopAngle) camera->mode = CAcMode_Orbit; camera->is_busy = UUcFalse; - + return; } @@ -605,7 +605,7 @@ static M3tPoint3D CArFollow_Get_GoalPosition(CAtCamera *inCamera) if (active_character == NULL) { MUmVector_Set(goal_position, 0, 0, 0); - } + } else { M3tVector3D camera_vector = active_character->cameraVector; @@ -737,7 +737,7 @@ static UUtBool CArFollow_Update(UUtUns32 ticks, UUtUns32 inNumActions, const LIt desired_canter *= 1.f + percent_to_double_canter; } } - + if (canter < desired_canter) { canter = UUmMin(desired_canter, canter + canter_delta * ticks); } @@ -809,9 +809,9 @@ void CArFollow_Enter(void) CArFollow_Set(&goal_position, &goal_focus); } - + camera->is_busy = UUcFalse; - + return; } @@ -848,7 +848,7 @@ void CArManual_Enter(void) camera->mode = CAcMode_Manual; camera->is_busy = UUcFalse; - + return; } @@ -856,14 +856,14 @@ void CArManual_LookAt(M3tPoint3D *inLocation, float inDistance) { CAtCamera *camera = ONgGameState->local.camera; M3tVector3D vector; - + if (camera->mode != CAcMode_Manual) { return; } - + vector = camera->viewData.viewVector; MUmVector_Negate(vector); MUmVector_Scale(vector, inDistance); MUmVector_Increment(vector, *inLocation); - + camera->viewData.location = vector; camera->viewData.upVector = CArBuildUpVector(&camera->viewData.viewVector); @@ -874,7 +874,7 @@ static UUtBool CArManual_Update(UUtUns32 inTicks, UUtUns32 inNumActions, const L { UUtBool activate = UUcFalse; - if (inNumActions > 0) + if (inNumActions > 0) { CAtCamera *camera = ONgGameState->local.camera; CAtManualData *manualData = &camera->modeData.manual; @@ -914,26 +914,26 @@ static UUtBool CArManual_Update(UUtUns32 inTicks, UUtUns32 inNumActions, const L camera->viewData.location.x += sideVector.x * stepLR; camera->viewData.location.x += camera->viewData.viewVector.x * moveFB; - + camera->viewData.location.y += action->analogValues[LIc_ManCam_Move_UD]; if (manualData->useMouseLook) { camera->viewData.location.y += camera->viewData.viewVector.y * moveFB; } - - camera->viewData.location.z += sideVector.z * (stepLR); + + camera->viewData.location.z += sideVector.z * (stepLR); camera->viewData.location.z += camera->viewData.viewVector.z * (moveFB); - + UUmTrig_ClipLow(panUD); UUmTrig_ClipLow(panLR); - + MUrPoint_RotateAboutAxis( &camera->viewData.viewVector, &camera->viewData.upVector, panLR, &camera->viewData.viewVector); - + MUrPoint_RotateAboutAxis( &camera->viewData.viewVector, &sideVector, @@ -941,7 +941,7 @@ static UUtBool CArManual_Update(UUtUns32 inTicks, UUtUns32 inNumActions, const L &camera->viewData.viewVector); MUmVector_Normalize(camera->viewData.viewVector); - + camera->viewData.upVector = CArBuildUpVector(&camera->viewData.viewVector); } @@ -971,7 +971,7 @@ void CArInterpolate_Enter_Matrix(const M3tMatrix4x3 *inMatrix, UUtUns32 inNumFra interpolateData->endFrame = inNumFrames; camera->is_busy = UUcTrue; - + return; } @@ -990,7 +990,7 @@ void CArInterpolate_Enter_ViewData(CAtViewData *inViewData, UUtUns32 inNumFrames interpolateData->endFrame = inNumFrames; camera->is_busy = UUcTrue; - + return; } @@ -1065,6 +1065,6 @@ static void CArMatrix_To_ViewData(const M3tMatrix4x3 *inMatrix, CAtViewData *out UUtBool CArIsBusy(void) { CAtCamera *camera = ONgGameState->local.camera; - + return camera->is_busy; -} \ No newline at end of file +} diff --git a/OniProj/OniGameSource/Oni_Camera.h b/OniProj/OniGameSource/Oni_Camera.h index 5eac2bb..dc8c42b 100644 --- a/OniProj/OniGameSource/Oni_Camera.h +++ b/OniProj/OniGameSource/Oni_Camera.h @@ -2,9 +2,9 @@ /* Oni_Camera.h - + Header file for camera AI stuff - + Author: Quinn Dunki c1998 Bungie */ @@ -26,7 +26,7 @@ typedef struct CAtViewData typedef struct CAtOrbitData { - float current_angle; + float current_angle; float stop_angle; float speed; } CAtOrbitData; @@ -98,7 +98,7 @@ CAtCameraMode CArGetMode(void); void CArGetMatrix(const CAtCamera *inCamera, M3tMatrix4x3 *outMatrix); void CArFollow_Enter(void); void CArAnimate_Enter(OBtAnimation *inAnimation); -void CArOrbit_Enter(float inSpeed, float inStopAngle); +void CArOrbit_Enter(float inSpeed, float inStopAngle); void CArManual_Enter(void); void CArManual_LookAt(M3tPoint3D *inLocation, float inDistance); void CArInterpolate_Enter_Matrix(const M3tMatrix4x3 *inMatrix, UUtUns32 inNumFrames); @@ -108,7 +108,7 @@ void CArInterpolate_Enter_Detached(void); M3tVector3D CArBuildUpVector(const M3tVector3D *inViewVector); void CArUpdate( - UUtUns32 ticks, + UUtUns32 ticks, UUtUns32 numActions, const struct LItAction *actionBuffer); @@ -117,7 +117,7 @@ UUtError CArLevelBegin( void CArLevelEnd( void); - + UUtError CArInitialize( void); @@ -133,7 +133,7 @@ static UUcInline M3tPoint3D CArGetFacing(void) { return CAgCamera.viewData.viewVector; } - + void CArEnableJello(UUtBool inJello); -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_Character.c b/OniProj/OniGameSource/Oni_Character.c index e02cdd6..1a75d03 100644 --- a/OniProj/OniGameSource/Oni_Character.c +++ b/OniProj/OniGameSource/Oni_Character.c @@ -1,12 +1,12 @@ /* FILE: Oni_Character.c - + AUTHOR: Michael Evans - + CREATED: April 2, 1997 - + PURPOSE: control of characters in ONI - + Copyright 1997-2000 */ @@ -204,10 +204,10 @@ ONiTempDebug_AttackExtent( #endif static void ONrCharacter_Stitch( - ONtCharacter *ioCharacter, - ONtActiveCharacter *ioActiveCharacter, - TRtAnimState fromState, - const TRtAnimation *inNewAnim, + ONtCharacter *ioCharacter, + ONtActiveCharacter *ioActiveCharacter, + TRtAnimState fromState, + const TRtAnimation *inNewAnim, UUtInt32 inStitchCount); const ONtAirConstants *ONrCharacter_GetAirConstants(const ONtCharacter *inCharacter); static const TRtAnimation *ONiAnimation_FindBlock(const ONtCharacter *inCharacter, ONtActiveCharacter *ioActiveCharacter); @@ -215,7 +215,7 @@ static const TRtAnimation *ONiAnimation_FindBlock(const ONtCharacter *inCharacte static UUtBool ONrCharacter_Collide_With_GQ( UUtUns16 inGQIndex, const M3tPoint3D *inIntersection, - const ONtCharacter *inCharacter, + const ONtCharacter *inCharacter, const M3tVector3D *inVector); // hit control stuff @@ -256,7 +256,7 @@ static void ONrCharacter_Callback_ReceiveForce( const M3tVector3D *inForce); static ONtCharacter *ONiCharacter_FindNearestOpponent( - ONtCharacter *inCharacter, + ONtCharacter *inCharacter, float inFacingOffset, float inMaxDistance, float inMaxAngle, @@ -299,7 +299,7 @@ static UUtBool ONgAnimStateToStringTableSorted = UUcFalse; static UUtUns32 ONgAnimTypeToStringTableLength; static UUtUns32 ONgAnimStateToStringTableLength; -static ONtAnimTypeToStringTable ONcAnimTypeToStringTable[] = +static ONtAnimTypeToStringTable ONcAnimTypeToStringTable[] = { { ONcAnimType_None, "None" }, // 0 { ONcAnimType_Anything, "Anything" }, @@ -308,7 +308,7 @@ static ONtAnimTypeToStringTable ONcAnimTypeToStringTable[] = { ONcAnimType_Slide, "Slide" }, { ONcAnimType_Jump, "Jump" }, // 5 - { ONcAnimType_Stand, "Stand" }, + { ONcAnimType_Stand, "Stand" }, { ONcAnimType_Standing_Turn_Left, "Standing_Turn_Left" }, { ONcAnimType_Standing_Turn_Right, "Standing_Turn_Right" }, { ONcAnimType_Run_Backwards, "Run_Backwards" }, @@ -324,13 +324,13 @@ static ONtAnimTypeToStringTable ONcAnimTypeToStringTable[] = { ONcAnimType_Crouch, "Crouch" }, { ONcAnimType_Jump_Forward, "Jump_Forward" }, { ONcAnimType_Jump_Backward, "Jump_Backward" }, - + { ONcAnimType_Jump_Left, "Jump_Left" }, // 20 { ONcAnimType_Jump_Right, "Jump_Right" }, { ONcAnimType_Punch, "Punch" }, { ONcAnimType_Block, "Block" }, { ONcAnimType_Land, "Land" }, - + { ONcAnimType_Fly, "Fly" }, // 25 { ONcAnimType_Kick_Forward, "Kick_Forward" }, { ONcAnimType_Kick_Left, "Kick_Left" }, @@ -371,10 +371,10 @@ static ONtAnimTypeToStringTable ONcAnimTypeToStringTable[] = { ONcAnimType_Punch_Forward_Heavy, "Punch_Forward_Heavy" }, { ONcAnimType_Kick_Forward_Heavy, "Kick_Forward_Heavy" }, // 55 - { ONcAnimType_Aiming_Overlay, "Aiming_Overlay" }, - { ONcAnimType_Hit_Overlay, "Hit_Overlay" }, + { ONcAnimType_Aiming_Overlay, "Aiming_Overlay" }, + { ONcAnimType_Hit_Overlay, "Hit_Overlay" }, - { ONcAnimType_Crouch_Run, "Crouch_Run" }, + { ONcAnimType_Crouch_Run, "Crouch_Run" }, { ONcAnimType_Crouch_Walk, "Crouch_Walk" }, { ONcAnimType_Crouch_Run_Backwards, "Crouch_Run_Backwards" }, // 60 @@ -388,7 +388,7 @@ static ONtAnimTypeToStringTable ONcAnimTypeToStringTable[] = { ONcAnimType_Run_Kick, "Run_Kick" }, { ONcAnimType_Run_Punch, "Run_Punch" }, - + { ONcAnimType_Run_Back_Punch, "Run_Back_Punch" }, { ONcAnimType_Run_Back_Kick, "Run_Back_Kick" }, @@ -529,10 +529,10 @@ static ONtAnimTypeToStringTable ONcAnimTypeToStringTable[] = { ONcAnimType_PL_PL, "PL_PL" }, { ONcAnimType_PL_PL_PL, "PL_PL_PL" }, - + { ONcAnimType_PR_PR, "PR_PR" }, { ONcAnimType_PR_PR_PR, "PR_PR_PR" }, - + { ONcAnimType_PB_PB, "PB_PB" }, { ONcAnimType_PB_PB_PB, "PB_PB_PB" }, @@ -544,10 +544,10 @@ static ONtAnimTypeToStringTable ONcAnimTypeToStringTable[] = { ONcAnimType_KL_KL, "KL_KL" }, { ONcAnimType_KL_KL_KL, "KL_KL_KL" }, - + { ONcAnimType_KR_KR, "KR_KR" }, { ONcAnimType_KR_KR_KR, "KR_KR_KR" }, - + { ONcAnimType_KB_KB, "KB_KB" }, { ONcAnimType_KB_KB_KB, "KB_KB_KB" }, @@ -558,10 +558,10 @@ static ONtAnimTypeToStringTable ONcAnimTypeToStringTable[] = { ONcAnimType_Startle_Right, "Startle_Right" }, { ONcAnimType_Startle_Back, "Startle_Back" }, { ONcAnimType_Startle_Forward, "Startle_Forward" }, - + { ONcAnimType_Console, "Console" }, { ONcAnimType_Console_Walk, "Console_Walk" }, - + { ONcAnimType_Stagger, "Stagger" }, { ONcAnimType_Watch, "Watch" }, @@ -614,7 +614,7 @@ static ONtAnimTypeToStringTable ONcAnimTypeToStringTable[] = { 0, NULL } }; -static ONtAnimStateToStringTable ONcAnimStateToStringTable[] = +static ONtAnimStateToStringTable ONcAnimStateToStringTable[] = { {ONcAnimState_None, "None"}, // 0 {ONcAnimState_Anything, "Anything"}, @@ -791,7 +791,7 @@ typedef struct StringNumLookup { UUtUns16 num; char *string; -} StringNumLookup; +} StringNumLookup; // more debugging code UUtInt32 gDebugCharacterMovement = 0; @@ -839,7 +839,7 @@ void ONrCharacter_ApplyOverlay(ONtCharacter *ioCharacter, ONtActiveCharacter *io { if (inOverlay->animation != NULL) { TRrOverlay_Apply( - inOverlay->animation, + inOverlay->animation, inOverlay->frame, ioActiveCharacter->curOrientations, ioActiveCharacter->curOrientations, @@ -999,7 +999,7 @@ static void ONrCharacter_ResetAnimation(ONtCharacter *ioCharacter, ONtActiveChar } break; } - + switch(mode) { case AI2cMovementMode_NoAim_Walk: case AI2cMovementMode_NoAim_Run: @@ -1031,7 +1031,7 @@ static void ONrCharacter_ResetAnimation(ONtCharacter *ioCharacter, ONtActiveChar UUmAssert(ioCharacter->characterClass->animations != NULL); newAnimation = TRrCollection_Lookup(ioCharacter->characterClass->animations, newType, ioActiveCharacter->nextAnimState, ioActiveCharacter->animVarient); UUmAssertReadPtr(newAnimation, sizeof(*newAnimation)); - + if (NULL != newAnimation) { ONrCharacter_SetAnimationInternal(ioCharacter, ioActiveCharacter, ioActiveCharacter->nextAnimState, ONcAnimType_None, newAnimation); } @@ -1158,7 +1158,7 @@ iSetCharacterWeapon( if (0 == (character->flags & ONcCharacterFlag_InUse)) { return UUcError_None; } - + if(inParameterList[1].type == SLcType_String) { error = ONrCharacter_ArmByName(character, inParameterList[1].val.str); @@ -1170,7 +1170,7 @@ iSetCharacterWeapon( else { UUtUns32 weaponNum; - + weaponNum = inParameterList[1].val.i; error = ONrCharacter_ArmByNumber(character, weaponNum); @@ -1245,7 +1245,7 @@ ONrCharacter_ArmByNumber( if (UUcError_None == error) { ONrCharacter_UseNewWeapon(inCharacter, weapon); } - + return error; } @@ -1328,7 +1328,7 @@ iDiplayCharacterCombatStats( ONtCharacter *character_list; ONtCharacter *character; UUtUns32 character_index; - + // get the character index character_index = inParameterList[0].val.i; @@ -1337,27 +1337,27 @@ iDiplayCharacterCombatStats( COrConsole_Printf("Character Number out of range"); return UUcError_Generic; } - + // get a pointer to the character list character_list = ONrGameState_GetCharacterList(); - + // get a pointer to the character character = &character_list[character_index]; - + // make sure the character is in use if (!(character->flags & ONcCharacterFlag_InUse)) { COrConsole_Printf("Invalid Character Number"); return UUcError_Generic; } - + // display the character stats COrConsole_Printf( "Character %d: Damage Inflicted %d, Number of Kills %d", character_index, character->damageInflicted, character->numKills); - + return UUcError_None; } @@ -1395,9 +1395,9 @@ iSetMainCharacterClass( error = TMrInstance_GetDataPtr_ByNumber(TRcTemplate_CharacterClass, characterNum, &characterClass); if (UUcError_None == error) - { + { ONrCharacter_SetCharacterClass(character, characterClass); - + COrConsole_Printf("changed to %s (%d / %d)", TMrInstance_GetInstanceName(character->characterClass), characterNum, TMrInstance_GetTagCount(TRcTemplate_CharacterClass)); changed = UUcTrue; } @@ -1422,13 +1422,13 @@ iSetCharacterClass( UUtError error; ONtCharacter *character_list; UUtUns32 character_index; - + // get a pointer to the character_list character_list = ONrGameState_GetCharacterList(); - + // get the character index character_index = inParameterList[0].val.i; - + if (character_index > ONgGameState->numCharacters) { COrConsole_Printf("character index out of range"); return UUcError_Generic; @@ -1437,7 +1437,7 @@ iSetCharacterClass( if (inParameterListLength == 2) { ONtCharacterClass *character_class; - + if (SLcType_String == inParameterList[1].type) { // get the character class the user wants to set all the character to @@ -1458,10 +1458,10 @@ iSetCharacterClass( { // user entered a class number UUtUns32 character_class_number; - + // get the character class number character_class_number = inParameterList[1].val.i; - + // get the instance of the character class error = TMrInstance_GetDataPtr_ByNumber( @@ -1473,7 +1473,7 @@ iSetCharacterClass( COrConsole_Printf("character class was not changed"); return UUcError_None; } - + // set the character class ONrCharacter_SetCharacterClass(&character_list[character_index], character_class); COrConsole_Printf( @@ -1485,14 +1485,14 @@ iSetCharacterClass( } } else if (inParameterListLength == 1) - { + { // print the current character class name of the character COrConsole_Printf( "character %d class name is %s", character_index, TMrInstance_GetInstanceName(character_list[character_index].characterClass)); } - + return UUcError_None; } @@ -1513,7 +1513,7 @@ static void ONrFall(ONtCharacter *inCharacter, TRtAnimState inState) ONrCharacter_FightMode(inCharacter); active_character->lastAttack = ONcAnimType_None; active_character->lastAttackTime = 0; - active_character->animationLockFrames = 0; // stop looping an anim + active_character->animationLockFrames = 0; // stop looping an anim newAnimType = ONcAnimType_Stand; animation = TRrCollection_Lookup(collection, ONcAnimType_Stand, inState, active_character->animVarient); @@ -1778,7 +1778,7 @@ void ONrCharacter_SetCharacterClass( prev_class = ioCharacter->characterClass; ioCharacter->characterClass = inClass; - + if (active_character != NULL) { if (ioCharacter->characterClass->leftHanded) { ONrCharacter_SetHand(active_character->extraBody, ONcCharacterIsLeftHanded); @@ -1803,7 +1803,7 @@ static float iMoveTowardsZero(float inNumber, float inAmtTowardsZero) { float result; - if (inNumber > inAmtTowardsZero) { + if (inNumber > inAmtTowardsZero) { result = inNumber - inAmtTowardsZero; } else if (inNumber < -inAmtTowardsZero) { @@ -1953,13 +1953,13 @@ static void ONiCharacter_DoAiming_Vector(ONtCharacter *ioCharacter, ONtActiveCha ioActiveCharacter->aimingVectorLR = angleLR; ioActiveCharacter->aimingVectorUD = angleUD; -} +} void ONrCharacter_DoAiming(ONtCharacter *ioCharacter, ONtActiveCharacter *ioActiveCharacter) { if (ONrCharacter_IsAI(ioCharacter) && !ONrCharacter_IsPlayingFilm(ioCharacter)) { ONiCharacter_DoAiming_Location(ioCharacter, ioActiveCharacter); - } else { + } else { ONiCharacter_DoAiming_Vector(ioCharacter, ioActiveCharacter); } } @@ -1994,7 +1994,7 @@ iDrawDot( ONgDrawDot = UUcFalse; } } - + ONgDot.x = buffer[0]; ONgDot.y = buffer[1]; ONgDot.z = buffer[2]; @@ -2013,7 +2013,7 @@ iCharacterLocation( if (inDestination != NULL) { ONrCharacter_Teleport(ioCharacter, inDestination, UUcTrue); - + COrConsole_Printf("%s new %3.1f %3.1f %3.1f", ioCharacter->player_name, ioCharacter->location.x, ioCharacter->location.y, ioCharacter->location.z); } @@ -2042,21 +2042,21 @@ iSetAnyCharacterLocation( if ((ONgGameState->characters[whichCharacter].flags & ONcCharacterFlag_InUse) == 0) { goto errorExit; } - + if (settingLocation) { newLocation.x = inParameterList[1].val.f; newLocation.y = inParameterList[2].val.f; newLocation.z = inParameterList[3].val.f; } - + iCharacterLocation(&ONgGameState->characters[whichCharacter], (settingLocation) ? &newLocation : NULL); return UUcError_None; errorExit: COrConsole_Printf("bad parameters on chr_location"); - + return UUcError_None; } @@ -2099,7 +2099,7 @@ iSetAnyCharacterHealth( UUtBool settingHealth = 2 == inParameterListLength; UUtBool readingHealth = 1 == inParameterListLength; ONtCharacter *targetCharacter = NULL; - + if (!settingHealth && !readingHealth) { goto errorExit; } @@ -2113,7 +2113,7 @@ iSetAnyCharacterHealth( goto errorExit; } } - + if ((whichCharacter < 0) || (whichCharacter > ONgGameState->numCharacters)) { goto errorExit; } @@ -2132,10 +2132,10 @@ iSetAnyCharacterHealth( if (settingHealth) { ONrCharacter_SetHitPoints(targetCharacter, newHP); - + COrConsole_Printf("char %d new health %u", whichCharacter, targetCharacter->hitPoints); } - + return UUcError_None; errorExit: @@ -2154,7 +2154,7 @@ SetMainCharacter( SLtParameter_Actual *ioReturnValue) { int which_character_index; - + which_character_index = inParameterList[0].val.i; if (which_character_index < ONgGameState->numCharacters) { @@ -2180,9 +2180,9 @@ iSetAnyCharacterWeapon( ONtCharacter **present_character_list = ONrGameState_PresentCharacterList_Get(); UUtUns32 present_character_count = ONrGameState_PresentCharacterList_Count(); UUtUns32 itr; - + whichCharacter = inParameterList[0].val.i; - + if ((whichCharacter < -1) || (whichCharacter > ONgGameState->numCharacters)) { return UUcError_Generic; } @@ -2195,7 +2195,7 @@ iSetAnyCharacterWeapon( ONrCharacter_DropWeapon(character,UUcFalse,WPcPrimarySlot,UUcFalse); } } - + return UUcError_None; } @@ -2212,9 +2212,9 @@ iCharacterLocation_SetFromCamera( M3tPoint3D cameraLocation; M3rCamera_GetViewData(ONgActiveCamera, &cameraLocation, NULL, NULL); - + whichCharacter = inParameterList[0].val.i; - + if ((whichCharacter < 0) || (whichCharacter > ONgGameState->numCharacters)) { return UUcError_None; @@ -2230,7 +2230,7 @@ iCharacterLocation_SetFromCamera( } static UUtError ONrBuildParticleClasses(void) -{ +{ return UUcError_None; } @@ -2261,12 +2261,12 @@ UUtError ONrCharacter_LevelBegin(void) // for safety's sake clear the characters UUrMemory_Clear( - ONgGameState->characters, - sizeof(ONtCharacter) * ONcMaxCharacters); + ONgGameState->characters, + sizeof(ONtCharacter) * ONcMaxCharacters); UUrMemory_Clear( - ONgGameState->activeCharacterStorage, - sizeof(ONtActiveCharacter) * ONcMaxActiveCharacters); + ONgGameState->activeCharacterStorage, + sizeof(ONtActiveCharacter) * ONcMaxActiveCharacters); // reset character salt ONgGameState->nextCharacterSalt = 1; @@ -2286,11 +2286,11 @@ UUtError ONrCharacter_LevelBegin(void) &num_classes, character_class_list); UUmAssert(error == UUcError_None); - + for (i = 0; i < num_classes; i++) { const char *name; - + name = TMrInstance_GetInstanceName(character_class_list[i]); if (character_class_list[i]->variant == NULL) { UUrDebuggerMessage("ERROR: character class %s has no variant!\n", name); @@ -2317,7 +2317,7 @@ UUtError ONrCharacter_LevelEnd(void) UUtError ONrGameState_InstallConsoleVariables(void) { - SLtRegisterBoolTable bool_table[] = + SLtRegisterBoolTable bool_table[] = { #if CONSOLE_DEBUGGING_COMMANDS { "spatial_footsteps", "spatial footsteps", &ONgSpatialFootsteps }, @@ -2367,7 +2367,7 @@ ONrGameState_InstallConsoleVariables(void) { NULL, NULL, NULL } }; - SLtRegisterInt32Table int32_table[] = + SLtRegisterInt32Table int32_table[] = { #if CONSOLE_DEBUGGING_COMMANDS { "saved_film_character_offset", "saved_film_character_offset", &saved_film_character_offset }, @@ -2380,7 +2380,7 @@ ONrGameState_InstallConsoleVariables(void) { NULL, NULL, NULL } }; - SLtRegisterFloatTable float_table[] = + SLtRegisterFloatTable float_table[] = { #if CONSOLE_DEBUGGING_COMMANDS { "cm_lookspring_percent", "at what percent of lookspring fight mode turns off", &ONgLookspringFightModePercent }, @@ -2397,7 +2397,7 @@ ONrGameState_InstallConsoleVariables(void) { NULL, NULL, NULL } }; - SLtRegisterVoidFunctionTable scripting_function_table[] = + SLtRegisterVoidFunctionTable scripting_function_table[] = { #if CONSOLE_DEBUGGING_COMMANDS { "chr_focus", "Selects what character to control", "chr_index:int", SetMainCharacter }, @@ -2424,14 +2424,14 @@ ONrGameState_InstallConsoleVariables(void) #endif { NULL, NULL, NULL, NULL } }; - + TRrInstallConsoleVariables(); SLrGlobalVariable_Register_Bool_Table(bool_table); SLrGlobalVariable_Register_Int32_Table(int32_table); SLrGlobalVariable_Register_Float_Table(float_table); SLrScript_CommandTable_Register_Void(scripting_function_table); - + #if CONSOLE_DEBUGGING_COMMANDS SLrGlobalVariable_Register_Bool("chr_show_bnv", "shows the bnv of the main character", &gShowBNV); SLrGlobalVariable_Register_Bool("chr_show_lod", "shows the current lod of the main character", &gShowLOD); @@ -2529,7 +2529,7 @@ ONiGameState_GetFreeCharacter( void) { UUtUns16 i; - + for (i = 0; i < ONcMaxCharacters; i++) { if ((ONgGameState->characters[i].flags & ONcCharacterFlag_InUse) == 0) @@ -2537,7 +2537,7 @@ ONiGameState_GetFreeCharacter( return i; } } - + return ONcMaxCharacters; } @@ -2546,13 +2546,13 @@ ONiGameState_GetFreeActiveCharacter( void) { UUtUns16 i; - + for (i = 0; i < ONcMaxActiveCharacters; i++) { if (ONgGameState->activeCharacterStorage[i].index == ONcCharacterIndex_None) { return i; } } - + return ONcMaxActiveCharacters; } @@ -2580,7 +2580,7 @@ ONrGameState_NewCharacter( const char *desired_variant; UUmAssert(inStartPosition || inSetup); - + /****** memory allocation */ // set the character's index @@ -2589,7 +2589,7 @@ ONrGameState_NewCharacter( { return UUcError_Generic; } - + // set the number of characters in the gamestate if (index >= ONgGameState->numCharacters) { @@ -2603,7 +2603,7 @@ ONrGameState_NewCharacter( // get a pointer to the character thisCharacter = ONgGameState->characters + index; UUrMemory_Clear(thisCharacter, sizeof(*thisCharacter)); - + /****** initialize constant variables */ // calculate the pseudo-unique character index @@ -2663,7 +2663,7 @@ ONrGameState_NewCharacter( // either look for random people of our variant, or the next harder variant desired_variant = thisCharacter->characterClass->variant->name; - if ((char_osd->flags & OBJcCharFlags_UpgradeDifficulty) && + if ((char_osd->flags & OBJcCharFlags_UpgradeDifficulty) && (ONrPersist_GetDifficulty() >= ONcDifficultyLevel_Hard) && (thisCharacter->characterClass->variant->upgrade_name[0] != '\0')) { desired_variant = thisCharacter->characterClass->variant->upgrade_name; @@ -2713,7 +2713,7 @@ ONrGameState_NewCharacter( UUmAssert(thisCharacter->inventory.weapons[0] != NULL); WPrSetAmmoPercentage(thisCharacter->inventory.weapons[0], (UUtUns16) char_osd->ammo_percentage); } - + // set the character's position thisCharacter->location = inStartPosition->position; thisCharacter->actual_position = thisCharacter->location; @@ -2731,7 +2731,7 @@ ONrGameState_NewCharacter( thisCharacter->inventory.ammo = char_osd->inventory[OBJcCharInv_AmmoBallistic][OBJcCharSlot_Use]; thisCharacter->inventory.cell = char_osd->inventory[OBJcCharInv_AmmoEnergy][OBJcCharSlot_Use]; thisCharacter->inventory.hypo = char_osd->inventory[OBJcCharInv_Hypo][OBJcCharSlot_Use]; - + thisCharacter->inventory.drop_ammo = char_osd->inventory[OBJcCharInv_AmmoBallistic][OBJcCharSlot_Drop]; thisCharacter->inventory.drop_cell = char_osd->inventory[OBJcCharInv_AmmoEnergy][OBJcCharSlot_Drop]; thisCharacter->inventory.drop_hypo = char_osd->inventory[OBJcCharInv_Hypo][OBJcCharSlot_Drop]; @@ -2753,7 +2753,7 @@ ONrGameState_NewCharacter( thisCharacter->inventory.numInvisibleFrames = (thisCharacter->inventory.invisibilityRemaining > 0) ? 600 : 0; thisCharacter->inventory.has_lsi = (char_osd->flags & OBJcCharFlags_HasLSI) > 0; - + // FIXME: handle LSIs } else if (inSetup != NULL) { /* @@ -2787,7 +2787,7 @@ ONrGameState_NewCharacter( ONcMaxPlayerNameLength); } else - { + { // Create default name sprintf(thisCharacter->player_name, "ai_%d", index); } @@ -2803,7 +2803,7 @@ ONrGameState_NewCharacter( thisCharacter->actual_position = thisCharacter->location; thisCharacter->actual_position.y += PHcWorldCoord_YOffset; thisCharacter->facing = flag.rotation; - + // Weapons WPrInventory_Reset(thisCharacter->characterClass, &thisCharacter->inventory); ONrCharacter_UseNewWeapon(thisCharacter, inSetup->weapon); @@ -2811,12 +2811,12 @@ ONrGameState_NewCharacter( { WPrSetAmmo(thisCharacter->inventory.weapons[0], inSetup->ammo); } - + } else { UUrDebuggerMessage("ONrGameState_NewCharacter: neither starting position or character setup specified!"); return UUcError_Generic; } - + /****** AI setup */ // set up this character to be controlled by the AI2 system AI2rInitializeCharacter(thisCharacter, char_osd, inSetup, &flag, default_melee_profile); @@ -2851,7 +2851,7 @@ ONrGameState_NewCharacter( // character control thisCharacter->prev_location = thisCharacter->location; thisCharacter->desiredFacing = thisCharacter->facing; - + // Camera ONrCharacter_GetFacingVector(thisCharacter,&thisCharacter->facingVector); ONrCharacter_FindOurNode(thisCharacter); @@ -2872,7 +2872,7 @@ ONrGameState_NewCharacter( ONrGameState_PresentCharacterList_Add(thisCharacter); ONrGameState_LivingCharacterList_Add(thisCharacter); - + /**** done */ if (outCharacterIndex != NULL) { @@ -2910,7 +2910,7 @@ ONrGameState_NewCharacter( if (ONcChar_AI2 == thisCharacter->charType) { UUmAssert(AI2cFlag_InUse & thisCharacter->ai2State.flags); } - + return UUcError_None; } @@ -2939,7 +2939,7 @@ ONrGameState_NewActiveCharacter( { return UUcError_Generic; } - + #if DEBUG_CHARACTER_CREATION UUrDebuggerMessage("activate character %d -> activecharacter %d\n", ONrCharacter_GetIndex(ioCharacter), index); #endif @@ -3009,7 +3009,7 @@ ONrGameState_NewActiveCharacter( for(overlay_index = 0; overlay_index < ONcOverlayIndex_Count; overlay_index++) { ONrOverlay_Initialize(activeCharacter->overlay + overlay_index); } - + // clear pose for(itr = 0; itr < ONcNumCharacterParts; itr++) { activeCharacter->curOrientations[itr] = MUgZeroQuat; @@ -3030,7 +3030,7 @@ ONrGameState_NewActiveCharacter( UUmAssert(0 == activeCharacter->blockStun); UUmAssert(0 == activeCharacter->dizzyStun); UUmAssert(0 == activeCharacter->staggerStun); - + // clear attacks activeCharacter->lastAttack = ONcAnimType_None; UUmAssert(0 == activeCharacter->lastAttackTime); @@ -3126,7 +3126,7 @@ ONrGameState_NewActiveCharacter( activeCharacter->trigger_points[1] = ioCharacter->location; activeCharacter->trigger_points[1].y += 12.f; ONiCharacter_BuildTriggerSphere(activeCharacter); - + /****** done */ ONrGameState_ActiveCharacterList_Add(ioCharacter); @@ -3143,7 +3143,7 @@ ONrCharacter_ArmByName( { WPtWeaponClass *weapon; UUtError error; - + if (NULL == weaponName) { weaponName = "StrMP10HC"; } @@ -3191,7 +3191,7 @@ float ONrCharacter_GetLeafSphereRadius(ONtCharacter *ioCharacter) if (ONrCharacter_IsAI(ioCharacter)) { leaf_sphere_radius = 3.0f; - } + } else { leaf_sphere_radius = 4.0f; } @@ -3209,7 +3209,7 @@ void ONrCharacter_RecalculateIdleDelay(ONtCharacter *ioCharacter) static void ONrCharacter_UpdateSphereTree( ONtCharacter *ioCharacter, ONtActiveCharacter *activeCharacter) -{ +{ float sub_radius = ONrCharacter_GetLeafSphereRadius(ioCharacter); float increment; float height; @@ -3356,7 +3356,7 @@ ONrGameState_DeleteCharacter( AI2rFight_StopFight(inCharacter); WPrSlots_DeleteAll(&inCharacter->inventory); - + if ((ONrCharacter_GetIndex(inCharacter) + 1) == ONgGameState->numCharacters) { // find the index of the highest character still in use while ((ONgGameState->numCharacters > 0) && @@ -3364,7 +3364,7 @@ ONrGameState_DeleteCharacter( ONgGameState->numCharacters -= 1; } } - + UUrMemory_Clear(inCharacter, sizeof(*inCharacter)); // tell the AI knowledgebase that this character was deleted @@ -3462,7 +3462,7 @@ ONrGameState_DeleteActiveCharacter( ONgGameState->usedActiveCharacters -= 1; } } - + UUrMemory_Clear(ioActiveCharacter, sizeof(*ioActiveCharacter)); return; @@ -3531,7 +3531,7 @@ static void ONiCharacter_StartJumping(ONtCharacter *ioCharacter, ONtActiveCharac } else if (ioActiveCharacter->inputState.buttonIsDown & LIc_BitMask_StepLeft) { - speed.x = UUmMax(speed.x, boost); + speed.x = UUmMax(speed.x, boost); } else if (ioActiveCharacter->inputState.buttonIsDown & LIc_BitMask_StepRight) { @@ -3637,9 +3637,9 @@ static void ONiCharacter_SuperParticle_Create(ONtCharacter *ioCharacter, ONtActi // we don't have an animation to tell us the part index, we can't attach this particle continue; } - + particle->bodypart_index = particle_def->override_partindex; - particle->particle = ONiCharacter_AttachParticle(ioCharacter, ioActiveCharacter, + particle->particle = ONiCharacter_AttachParticle(ioCharacter, ioActiveCharacter, particle_def->particle_class, particle->bodypart_index); if (particle->particle == NULL) { // could not create and attach the particle @@ -3749,7 +3749,7 @@ static void ONrCharacter_DebugKeys(ONtCharacter *ioCharacter, ONtActiveCharacter * debugging keys */ - if (ONrDebugKey_WentDown(ONcDebugKey_Test_One)) { + if (ONrDebugKey_WentDown(ONcDebugKey_Test_One)) { P3rRemoveDangerousProjectiles(); } @@ -3773,12 +3773,12 @@ static void ONrCharacter_DebugKeys(ONtCharacter *ioCharacter, ONtActiveCharacter ONrCharacter_FightMode(ioCharacter); startle = TRrCollection_Lookup( - ioCharacter->characterClass->animations, + ioCharacter->characterClass->animations, ONcAnimType_Startle_Back, - ioActiveCharacter->nextAnimState, + ioActiveCharacter->nextAnimState, ioActiveCharacter->animVarient); - + if (NULL != startle) { ONrCharacter_SetAnimation_External(ioCharacter, ioActiveCharacter->nextAnimState, startle, 6); } @@ -3786,12 +3786,12 @@ static void ONrCharacter_DebugKeys(ONtCharacter *ioCharacter, ONtActiveCharacter COrConsole_Printf("no startle to be found"); } } - + if (ONrDebugKey_WentDown(ONcDebugKey_KillParticles)) { // kill all particles ONrParticle3_KillAll(UUcFalse); } - + if (ONrDebugKey_WentDown(ONcDebugKey_ResetParticles)) { // kill all particles and then recreate from definitions ONrParticle3_KillAll(UUcTrue); @@ -3825,7 +3825,7 @@ static void ONrGameState_DoCharacterFrame( ONrSpeech_Update(ioCharacter); ONrCharacter_Pickup(ioCharacter); - WPrInventory_Update(ioCharacter); + WPrInventory_Update(ioCharacter); if (active_character == NULL) { // build an approximate bounding box since we aren't actually running animations @@ -3833,7 +3833,7 @@ static void ONrGameState_DoCharacterFrame( } else { /***************** PRELIMINARY INPUT */ - + if (ONcChar_Player == ioCharacter->charType) { ONrCharacter_VerifyExtraBody(ioCharacter, active_character); } @@ -3841,7 +3841,7 @@ static void ONrGameState_DoCharacterFrame( if (ONcChar_Player == ioCharacter->charType) { ONrCharacter_DebugKeys(ioCharacter, active_character); } - + /* * keyboard input */ @@ -3870,7 +3870,7 @@ static void ONrGameState_DoCharacterFrame( if (ioCharacter->charType == ONcChar_Player) { if (0xFFFFFFFF == active_character->last_forward_tap) { ONrCharacter_SetSprintVarient(ioCharacter, UUcTrue); - + if (active_character->inputState.buttonIsUp & LIc_BitMask_Forward) { active_character->last_forward_tap = 0; } @@ -3880,17 +3880,17 @@ static void ONrGameState_DoCharacterFrame( if (active_character->inputState.buttonWentDown & LIc_BitMask_Forward) { UUtUns32 how_long_ago_did_we_forward_tap = ONgGameState->gameTime - active_character->last_forward_tap; - + if (how_long_ago_did_we_forward_tap < 15) { active_character->last_forward_tap = 0xFFFFFFFF; } else { - active_character->last_forward_tap = ONgGameState->gameTime; + active_character->last_forward_tap = ONgGameState->gameTime; } } } } - + /* * player aiming control */ @@ -3973,7 +3973,7 @@ static void ONrGameState_DoCharacterFrame( auto_aiming_distance_percent /= zero_auto_aiming - max_auto_aiming; auto_aiming_distance_percent = UUmPin(auto_aiming_distance_percent, 0.f, 1.f); auto_aiming_distance_percent = 1.f - auto_aiming_distance_percent; - + active_character->autoAimAdjustmentLR *= auto_aiming_distance_percent; active_character->autoAimAdjustmentUD *= auto_aiming_distance_percent; } @@ -3998,7 +3998,7 @@ static void ONrGameState_DoCharacterFrame( if (active_character->softPauseFrames > 0) { active_character->softPauseFrames -= 1; } - + if (active_character->hardPauseFrames > 0) { active_character->hardPauseFrames -= 1; } @@ -4045,7 +4045,7 @@ static void ONrGameState_DoCharacterFrame( UUmAssert(active_character->stitch.count > 0); height = (active_character->stitch.height * fromAmt) + (height * toAmt); } - UUmAssert((height > -128.f) && (height < 128.f)); + UUmAssert((height > -128.f) && (height < 128.f)); ioCharacter->heightThisFrame = height; @@ -4064,7 +4064,7 @@ static void ONrGameState_DoCharacterFrame( } if ((active_character->physics != NULL) && (active_character->physics->animContext.animation != NULL)) { - if (active_character->physics->animContext.animationFrame >= + if (active_character->physics->animContext.animationFrame >= (active_character->physics->animContext.animation->numFrames - 1)) { active_character->physics->animContext.animation = NULL; @@ -4100,18 +4100,18 @@ static void ONrGameState_DoCharacterFrame( { UUtBool on_the_ground = (0 == active_character->offGroundFrames) && (0 == active_character->inAirControl.numFramesInAir); - + if (on_the_ground) { active_character->death_velocity.x *= 0.5f; active_character->death_velocity.z *= 0.5f; - active_character->death_velocity.y = -0.5f; + active_character->death_velocity.y = -0.5f; } else { active_character->death_velocity.x *= 0.8f; active_character->death_velocity.z *= 0.8f; - active_character->death_velocity.y -= 0.5f; + active_character->death_velocity.y -= 0.5f; active_character->death_velocity.y = UUmPin(active_character->death_velocity.y, -10.f, 2.f); } } @@ -4236,7 +4236,7 @@ static void ONrGameState_DoCharacterFrame( // dead people obey slightly different rules active_character->inAirControl.velocity.y -= airConstants->jumpGravity; active_character->inAirControl.velocity.y = UUmMax(active_character->inAirControl.velocity.y, airConstants->maxVelocity); - } + } else if (active_character->stitch.stitching) { float toAmt = ((float) active_character->stitch.itr) / ((float) active_character->stitch.count); float fromAmt = 1 - toAmt; @@ -4248,7 +4248,7 @@ static void ONrGameState_DoCharacterFrame( moved.y -= ONrGameState_CalculateGravity(ioCharacter, active_character); - } + } else { TRrAnimation_GetPosition(active_character->animation, active_character->animFrame, &moved); moved.y -= ONrGameState_CalculateGravity(ioCharacter, active_character); @@ -4262,8 +4262,8 @@ static void ONrGameState_DoCharacterFrame( gSmoothedMovement = (M3tPoint3D *) UUrMemory_Block_Realloc(gSmoothedMovement, sizeof(M3tPoint3D) * gDebugCharacterMovement); gDebugCharacterMovement_Old = gDebugCharacterMovement; } - - if (NULL != gSmoothedMovement) + + if (NULL != gSmoothedMovement) { M3tPoint3D smooth = MUgZeroPoint; UUtInt32 smooth_itr; @@ -4275,14 +4275,14 @@ static void ONrGameState_DoCharacterFrame( { MUmVector_Add(smooth, smooth, gSmoothedMovement[smooth_itr]); } - + MUmVector_Scale(smooth, 1.f/((float) gDebugCharacterMovement)); - + COrConsole_Printf("movement = %4.4f,%4.4f", smooth.x, smooth.z); } } } - + MUmAssertVector(moved, 1000.f); MUrPoint_RotateYAxis(&moved, ioCharacter->facing, &moved); @@ -4366,11 +4366,11 @@ static void ONrGameState_DoCharacterFrame( } /***************** POST-MOVEMENT ANIMATION */ - + // determine if this is a sound frame is_sound_frame = TRrAnimation_IsSoundFrame(active_character->animation, active_character->animFrame); new_sound_name = TRrAnimation_GetNewSoundForFrame(active_character->animation, active_character->animFrame); - + if (active_character->animFrame == active_character->animation->actionFrame) { // if we are throwing then the animation action frame is swap weapon if (active_character->throwTarget != NULL) { @@ -4454,7 +4454,7 @@ static void ONrGameState_DoCharacterFrame( impact_type = MArImpactType_GetByName("Self_Damage_Killed"); if (impact_type == MAcImpact_Base) { continue; - } + } ONrCharacter_GetPartLocation(ioCharacter, active_character, (UUtUns16) particle->bodypart_index, &part_location); // set up effect data and play the appropriate impact effect @@ -4544,7 +4544,7 @@ static void ONrGameState_DoCharacterFrame( } if (active_character->overlay[overlay_index].frame == active_character->overlay[overlay_index].animation->actionFrame) { - switch(overlay_index) + switch(overlay_index) { case ONcOverlayIndex_Recoil: break; @@ -4605,7 +4605,7 @@ static void ONrGameState_DoCharacterFrame( overlay_finished = ONrOverlay_DoFrame(ioCharacter, active_character->overlay + overlay_index); if (overlay_finished) { - switch(overlay_index) + switch(overlay_index) { case ONcOverlayIndex_Recoil: break; @@ -4626,7 +4626,7 @@ static void ONrGameState_DoCharacterFrame( NULL, NULL); } - + if (new_sound_name != NULL) { OSrImpulse_PlayByName( @@ -4673,7 +4673,7 @@ static void ONrGameState_DoCharacterFrame( if (ONgDebugFootstepFlash) { active_character->flash_count = 5; - switch(footstep) + switch(footstep) { case TRcFootstep_Left: active_character->flash_parts = (1 << ONcLFoot_Index); @@ -4753,7 +4753,7 @@ static void ONrGameState_DoCharacterFrame( if ((ioCharacter->flags & ONcCharacterFlag_HastyAnim) && (!TRrAnimation_IsAtomic(active_character->animation, active_character->animFrame))) { ONrCharacter_NextAnimation(ioCharacter, active_character); } - + // pose update ONrCharacter_DoAiming(ioCharacter, active_character); ONrCharacter_BuildQuaternions(ioCharacter, active_character); @@ -4823,7 +4823,7 @@ static void ONrGameState_DoCharacterFrame( ONiCharacter_StopFiring(ioCharacter, active_character); active_character->pleaseReleaseAlternateTrigger = UUcFalse; } - + /***************** NEXT FRAME PREPARATION */ // zero collision counters for the next frame @@ -4884,7 +4884,7 @@ static void ONrGameState_DoCharacterDebugFrame( UUtUns64 keys_low; UUtUns32 death_level; UUtInt32 itr; - + atomicString = (active_character == NULL) ? "INACTIVE" : (TRrAnimation_IsAtomic(active_character->animation, active_character->animFrame)) ? "ATOMIC" : "NOTATOMIC"; @@ -4915,7 +4915,7 @@ static void ONrGameState_DoCharacterDebugFrame( { death_level = 1; } - else + else { death_level = 0; } @@ -5146,7 +5146,7 @@ static UUtBool ONrGameState_UpdateTrigger(OBJtObject *inObject, UUtUns32 inUserD parent_search_osd.osd.trigger_volume_osd.id = trigger_osd->parent_id; parent_trigger_object = OBJrObjectType_Search(OBJcType_TriggerVolume, OBJcSearch_TriggerVolumeID, &parent_search_osd); - + if (NULL == parent_trigger_object) { COrConsole_Printf("trigger %d failed to locate parent trigger %d", trigger_osd->id, trigger_osd->parent_id); } @@ -5286,7 +5286,7 @@ void ONrGameState_UpdateCharacters(void) ONrCharacter_BuildMatriciesAll(ONgGameState->local.playerCharacter, ONgGameState->local.playerActiveCharacter); } } - + if (!gPauseCharacters) return; present_character_list = ONrGameState_PresentCharacterList_Get(); @@ -5295,7 +5295,7 @@ void ONrGameState_UpdateCharacters(void) for(itr = 0; itr < present_character_count; itr++) { character = present_character_list[itr]; active_character = ONrGetActiveCharacter(character); - + if (ONgCharactersAllActive && (active_character == NULL)) { // debugging - force all characters to be active ONrCharacter_MakeActive(character, UUcTrue); @@ -5303,7 +5303,7 @@ void ONrGameState_UpdateCharacters(void) if (character->death_delete_timer) { character->death_delete_timer--; - + if (character->death_delete_timer == 0) { // timer has run out, delete the character if (character->charType != ONcChar_Player) { @@ -5314,7 +5314,7 @@ void ONrGameState_UpdateCharacters(void) } if (character->flags & ONcCharacterFlag_Dead_3_Cosmetic) { - if ((active_character != NULL) && + if ((active_character != NULL) && ((active_character->shield_active) || (active_character->invis_active) || (character->flags & ONcCharacterFlag_Teleporting))) { ONrCharacter_Shield_Update(character, active_character); ONrCharacter_Invis_Update(character, active_character); @@ -5346,7 +5346,7 @@ void ONrGameState_UpdateCharacters(void) if (ready_for_ground_death) { active_character->death_still_timer++; - + ready_for_ground_death = active_character->death_still_timer > 120; } else { @@ -5354,7 +5354,7 @@ void ONrGameState_UpdateCharacters(void) } active_character->death_moving_timer++; - + if (active_character->death_moving_timer > (60 * 15)) { COrConsole_Printf("dieing for to long, aborting"); @@ -5386,10 +5386,10 @@ void ONrGameState_UpdateCharacters(void) if (character->flags & ONcCharacterFlag_Dead_2_Moving) { continue; } - + ONrCharacter_HandleHeartbeatInput(character, active_character); } - + if (must_unlock) { ONrCharacter_Unlock_Scripts(); ONrCharacter_Commit_Scripts(); @@ -5402,7 +5402,7 @@ void ONrGameState_UpdateCharacters(void) for(itr = 0; itr < present_character_count; itr++) { character = present_character_list[itr]; - + if (character->flags & ONcCharacterFlag_InUse) { ONtCharacterIndexType index = ONrCharacter_GetIndex(character); @@ -5433,9 +5433,9 @@ void ONrGameState_UpdateCharacters(void) ONtActiveCharacter *active_target = ONrGetActiveCharacter(active_character->throwTarget); UUmAssertReadPtr(active_target, sizeof(*active_target)); - if ((!(active_character->throwTarget->flags & ONcCharacterFlag_Dead_1_Animating)) && + if ((!(active_character->throwTarget->flags & ONcCharacterFlag_Dead_1_Animating)) && (active_character->throwTarget->flags & ONcCharacterFlag_InUse)) - { + { ONiCharacter_ThrowPhysics(character, active_character, active_character->throwTarget, active_target); } } @@ -5535,7 +5535,7 @@ void ONrGameState_UpdateCharacters(void) } if (character->flags & ONcCharacterFlag_Dead) { - // do not make dead characters inactive, they need to + // do not make dead characters inactive, they need to // fall, land and get made into corpses continue; } @@ -5609,7 +5609,7 @@ void ONrDrawSphere( M3rMatrixStack_UniformScale(inScale); M3rGeometry_Draw(sphere); M3rMatrixStack_Pop(); - + return; } @@ -5706,7 +5706,7 @@ ONiTempDebug_AttackExtent( COrConsole_Printf("### no player character"); return UUcError_Generic; } - + UUmAssert(inParameterListLength >= 1); error = TMrInstance_GetDataPtr(TRcTemplate_Animation, inParameterList[0].val.str, (void **) &animation); if ((error != UUcError_None) || (animation == NULL)) { @@ -5777,8 +5777,8 @@ static void ONiCharacter_TempDebug_DrawAttackExtent(ONtCharacter *inCharacter) + ONgTempDebug_AttackExtent_SinTheta * ONgTempDebug_AttackExtent_CurDelta[1]; cur_location.z += - ONgTempDebug_AttackExtent_SinTheta * ONgTempDebug_AttackExtent_CurDelta[0] + ONgTempDebug_AttackExtent_CosTheta * ONgTempDebug_AttackExtent_CurDelta[1]; - - + + cur_position = ONgTempDebug_AttackExtent_Animation->positionPoints + ONgTempDebug_AttackExtent_Frame; // draw a little X on the floor under the character (for depth cueing) @@ -5789,7 +5789,7 @@ static void ONiCharacter_TempDebug_DrawAttackExtent(ONtCharacter *inCharacter) points[1].x += 2.0f * ONgTempDebug_AttackExtent_CosTheta; points[1].z -= 2.0f * ONgTempDebug_AttackExtent_SinTheta; M3rGeom_Line_Light(&points[0], &points[1], IMcShade_White); - + points[0] = cur_location; points[1] = cur_location; points[0].x -= 2.0f * ONgTempDebug_AttackExtent_SinTheta; @@ -5879,7 +5879,7 @@ static void ONiCharacter_TempDebug_DrawAttackExtent(ONtCharacter *inCharacter) points[0].z += radius * MUrCos(theta); points[0].y += extent_info->attack_ring.min_height; - theta = ONgTempDebug_AttackExtent_Facing + + theta = ONgTempDebug_AttackExtent_Facing + ((itr2 + 1) % TRcExtentRingSamples) * M3c2Pi / TRcExtentRingSamples; UUmTrig_ClipHigh(theta); radius = extent_info->attack_ring.distance[((itr2 + 1) % TRcExtentRingSamples)]; @@ -5916,7 +5916,7 @@ static void ONiCharacter_TempDebug_DrawAttackExtent(ONtCharacter *inCharacter) } extent_index += (UUtUns16) (ONgTempDebug_AttackExtent_Frame - attacks[itr].firstDamageFrame); - + UUmAssert((extent_index >= 0) && (extent_index < extent_info->numAttackExtents)); cur_extent = extent_info->attackExtents + extent_index; @@ -5991,7 +5991,7 @@ static void ONiCharacter_Display_Body( float distanceToCameraSquared; TRtBodySelector resolution; float alphaAmount = 1.f; - + UUmAssertReadPtr(inCharacter, sizeof(inCharacter)); UUmAssert(inActiveCharacter->curBody >= TRcBody_SuperLow); UUmAssert(inActiveCharacter->curBody <= TRcBody_SuperHigh); @@ -6002,7 +6002,7 @@ static void ONiCharacter_Display_Body( UUmAssert(!(inCharacter->flags & ONcCharacterFlag_Dead_4_Gone)); UUmAssert(inCharacter->flags & ONcCharacterFlag_InUse); - + distanceToCameraSquared = MUrPoint_Distance_Squared(inCameraLocation, &(inCharacter->location)); if (alphaAmount < 1.f) { @@ -6019,7 +6019,7 @@ static void ONiCharacter_Display_Body( body = ONrCharacter_GetBody(inCharacter, resolution); TRrBody_SetMaps(body, inCharacter->characterClass->textures); - + M3rGeom_State_Push(); /* // CB: I needed a character flag and removed ONcCharacterFlag_Holograph @@ -6044,7 +6044,7 @@ static void ONiCharacter_Display_Body( M3rMatrixStack_Translate(0.f, holograph_translate_up, 0.f); } - + // setup lighting for the holograph ONiHolograph_Lighting(); }*/ @@ -6055,7 +6055,7 @@ static void ONiCharacter_Display_Body( M3rDraw_State_SetInt(M3cDrawStateIntType_FrameBufferBlendWithConstantAlpha, UUcTrue); M3rDraw_State_SetInt(M3cDrawStateIntType_ZWrite, M3cDrawState_ZWrite_Off); // S.S. - + M3rGeom_State_Set(M3cGeomStateIntType_SubmitMode, M3cGeomState_SubmitMode_SortAlphaTris); M3rGeom_State_Set(M3cGeomStateIntType_Alpha, alphaInt); M3rGeom_State_Commit(); @@ -6085,7 +6085,7 @@ static void ONiCharacter_Display_Body( M3tTextureMap *shield_texture = NULL; TRtBody *magic_shield_body = ONrCharacter_GetBody(inCharacter, UUmMin(inActiveCharacter->curBody, TRcBody_Low)); const char *shield_name; - + if (inActiveCharacter->daodan_shield_effect) { shield_name = "DAODAN_SHIELD"; } @@ -6125,7 +6125,7 @@ static void ONiCharacter_Display_Body( } M3rGeom_State_Pop(); - + // CB: I needed a character flag and removed ONcCharacterFlag_Holograph /* if (inCharacter->flags & ONcCharacterFlag_Holograph) { @@ -6148,8 +6148,8 @@ static void ONrDrawLaserDot(M3tPoint3D *inPoint) M3rCamera_GetViewData(ONgActiveCamera, &cameraLocation, NULL, NULL); error = TMrInstance_GetDataPtr( - M3cTemplate_TextureMap, - "dot", + M3cTemplate_TextureMap, + "dot", (void **) &dotTexture); UUmAssert(UUcError_None == error); @@ -6213,7 +6213,7 @@ void WPrDrawSprite(WPtSprite *inSprite, M3tPoint3D *inLocation, WPtScaleMode inS if (NULL == inSprite->texture) { goto exit; } - + M3rCamera_GetViewData(ONgActiveCamera, &camera_location, NULL, NULL); camera_distance = MUmVector_GetDistance(camera_location, *inLocation); @@ -6342,22 +6342,22 @@ static void ONiDrawWeaponSight(ONtCharacter *inCharacter) WPrGetMarker(inCharacter->inventory.weapons[0], laser_marker, &from, &sight_vector); - if (MUmVector_IsZero(laser_marker->vector)) + if (MUmVector_IsZero(laser_marker->vector)) return; MUmAssertVector(sight_vector, weapon_class->maximum_sight_distance); - + AMgCharacterLaserSight = UUcTrue; - AMrRayToEverything(index, &from, &sight_vector, &ray_results); + AMrRayToEverything(index, &from, &sight_vector, &ray_results); - if (ray_results.resultType != AMcRayResult_None) + if (ray_results.resultType != AMcRayResult_None) { float distance; - if (gConsole_show_laser_env_collision) + if (gConsole_show_laser_env_collision) { - if (AMcRayResult_Environment == ray_results.resultType) + if (AMcRayResult_Environment == ray_results.resultType) { AKtGQ_General *flash_gq; flash_gq = ONgGameState->level->environment->gqGeneralArray->gqGeneral; @@ -6378,7 +6378,7 @@ static void ONiDrawWeaponSight(ONtCharacter *inCharacter) ray_results.resultType = AMcRayResult_None; } - else if (distance > UUcEpsilon) + else if (distance > UUcEpsilon) { float uAmt = 1.f; float offsetAmt = 2.f; @@ -6390,9 +6390,9 @@ static void ONiDrawWeaponSight(ONtCharacter *inCharacter) MUrLineSegment_ComputePoint(&from, &to, uAmt, &to); } - + } - else + else { MUmVector_Scale(sight_vector, weapon_class->maximum_sight_distance); MUmVector_Add(to, from, sight_vector); @@ -6477,7 +6477,7 @@ static void ONiCharacter_DeleteShadow(ONtActiveCharacter *ioActiveCharacter) // we don't have a shadow return; } - + P3rDeleteDecal(&ioActiveCharacter->shadow_decal, P3cDecalFlag_Manual); // set the shadow decal data back to an 'unused' state @@ -6499,7 +6499,7 @@ static void ONiCharacter_Display( float character_alpha; UUtBool support_shadow; UUtError error; - + UUmAssertReadPtr(inCharacter, sizeof(*inCharacter)); UUmAssertReadPtr(inCameraLocation, sizeof(*inCameraLocation)); UUmAssert(inCharacter->flags & ONcCharacterFlag_InUse); @@ -6527,7 +6527,7 @@ static void ONiCharacter_Display( if (gShowBNV && isMainCharacter) { sprintf(ONgBNVStatus[1].text, "%d", inCharacter->currentNode - ONgGameState->level->environment->bnvNodeArray->nodes); } - + if (gDrawFacingVector) { ONiDrawFacingVector(inCharacter); } @@ -6550,10 +6550,10 @@ static void ONiCharacter_Display( support_shadow = support_shadow && ((inCharacter->flags & ONcCharacterFlag_Dead_3_Cosmetic) == 0); support_shadow = support_shadow && (character_alpha > 0); support_shadow = support_shadow && (!(inCharacter->flags & ONcCharacterFlag_NoShadow)); - + if (support_shadow) { - M3tTextureMap *texture; + M3tTextureMap *texture; ONtShadowConstants *shadow_constants; #if defined(DEBUGGING) && DEBUGGING P3tDecalData debug_orig_decaldata = inActiveCharacter->shadow_decal; @@ -6570,7 +6570,7 @@ static void ONiCharacter_Display( texture = shadow_constants->shadow_texture; if (texture == NULL) { TMrInstance_GetDataPtr(M3cTemplate_TextureMap, "notfoundtex", (void **) &texture); - } + } if ((inActiveCharacter->shadow_decal.decal_header != NULL) && (texture != NULL)) { M3tVector3D fwd_vec, up_vec, right_vec, position; @@ -6642,7 +6642,7 @@ static void ONiCharacter_Display( } if (gq_index != (UUtUns32) -1) { - error = P3rCreateDecal(texture, gq_index, P3cDecalFlag_Manual | P3cDecalFlag_CullBackFacing | + error = P3rCreateDecal(texture, gq_index, P3cDecalFlag_Manual | P3cDecalFlag_CullBackFacing | P3cDecalFlag_IgnoreAdjacency | P3cDecalFlag_FullBright, 80.0f * M3cDegToRad, NULL, &position, &fwd_vec, &up_vec, &right_vec, size, size, alpha, IMcShade_White, &inActiveCharacter->shadow_decal, ONcShadowDecalStaticBufferSize); @@ -6681,10 +6681,10 @@ static UUtBool ONiCharacter_NeedsRendering(ONtCharacter *inCharacter, CAtCamera M3tPoint3D viewVector; #define fovFudge (0.25f * M3cHalfPi) - + M3rCamera_GetStaticData(ONgVisibilityCamera,&fov,NULL,NULL,&farP); M3rCamera_GetViewData(ONgVisibilityCamera, &cameraLocation, &viewVector, NULL); - + MUmVector_Subtract(toObj,inCharacter->location,cameraLocation); MUrNormalize(&toObj); @@ -6711,19 +6711,19 @@ static UUtBool ONiCharacter_NeedsRendering(ONtCharacter *inCharacter, CAtCamera inCharacter->num_frames_offscreen++; } - // if our active character exists, we have only been offscreen for + // if our active character exists, we have only been offscreen for // a short while and our body is not !drawn then consider us visible if ((!is_visible) && (inCharacter->num_frames_offscreen < 4)) { ONtActiveCharacter *active_character = ONrGetActiveCharacter(inCharacter); - if (NULL != active_character) { + if (NULL != active_character) { if (active_character->curBody != TRcBody_NotDrawn) { is_visible = UUcTrue; } } } - + return is_visible; } @@ -6777,7 +6777,7 @@ static UUtInt32 ONrCharacterList_GetPolygonCount(ONtCharacter **inCharacters, ON // 6. compute ideal LOD by distance & bias + 1 // 7. count polygons -// 8. if polygons > polygons_for_characters goto +// 8. if polygons > polygons_for_characters goto // 9. bias += 1 // 10. goto 6 @@ -6785,7 +6785,7 @@ static UUtInt32 ONrCharacterList_GetPolygonCount(ONtCharacter **inCharacters, ON // 12. count polygons // 13. compute ideal LOD by distance & bias + 1 // 14. count polygons -// 13. if polygons < polygons_for_characters goto +// 13. if polygons < polygons_for_characters goto // 14. if bias = -4 goto done: // 15. goto 11 @@ -6866,7 +6866,7 @@ static void ONrGameState_ComputeCharacterVisibility(UUtUns32 *outNumVisible, ONt if (active_character == NULL) { continue; } - + current_character->flags |= ONcCharacterFlag_Draw; outVisibleChars[num_visible] = current_character; outVisibleActiveChars[num_visible] = active_character; @@ -6895,7 +6895,7 @@ static void ONrGameState_ComputeCharacterLOD(UUtUns32 inNumVisible, ONtCharacter inVisibleActiveChars[itr]->desiredBodyFrames = 0; } return; - } + } // step 2: sort the visible chracacters by distance from camera AUrQSort_32(inVisibleChars, inNumVisible, distance_from_camera_compare); @@ -7021,7 +7021,7 @@ static void ONrGameState_ComputeCharacterLOD(UUtUns32 inNumVisible, ONtCharacter active_character->curBody = UUmMax(active_character->curBody, TRcBody_Low); } } - + return; } @@ -7051,13 +7051,13 @@ void ONrGameState_DisplayCharacters(void) ONtCharacter *character; ONtCharacter *vis_list[ONcMaxCharacters]; ONtActiveCharacter *vis_active_list[ONcMaxCharacters]; - + M3rCamera_GetViewData(ONgVisibilityCamera, &cameraLocation, NULL, NULL); if (ONgShow_Corpses) { ONrCorpse_Display(&cameraLocation); } - + ONrGameState_ComputeCharacterVisibility(&vis_count, vis_list, vis_active_list); ONrGameState_ComputeCharacterLOD(vis_count, vis_list, vis_active_list); @@ -7112,7 +7112,7 @@ void ONrGameState_DisplayCharacters(void) // get rid of all of our old shadows ONrCharacter_PurgeShadows(); - + for(itr = 0; itr < vis_count; itr++) { character = vis_list[itr]; @@ -7120,7 +7120,7 @@ void ONrGameState_DisplayCharacters(void) if (0 == (character->flags & ONcCharacterFlag_Draw)) continue; UUmAssert(!(character->flags & ONcCharacterFlag_Dead_4_Gone)); - + ONiCharacter_Display(character, vis_active_list[itr], &cameraLocation); } } @@ -7134,9 +7134,9 @@ void ONrCharacter_SetAnimationInternal(ONtCharacter *ioCharacter, ONtActiveChara UUtUns16 animType; UUmAssert(NULL != inAnimation); - + animType = TRrAnimation_GetType(inAnimation); - + ioActiveCharacter->animation = inAnimation; ioActiveCharacter->animFrame = 0; ioActiveCharacter->curFromState = inFromState; @@ -7147,10 +7147,10 @@ void ONrCharacter_SetAnimationInternal(ONtCharacter *ioCharacter, ONtActiveChara UUmAssertTrigRange(ioCharacter->facing); if (gDebugCharacters && (index == gDebugCharacterTarget)) { - COrConsole_Printf("anim %s state %s type %s length %d", - TRrAnimation_GetName(inAnimation), - ONrAnimStateToString(TRrAnimation_GetTo(inAnimation)), - ONrAnimTypeToString(TRrAnimation_GetType(inAnimation)), + COrConsole_Printf("anim %s state %s type %s length %d", + TRrAnimation_GetName(inAnimation), + ONrAnimStateToString(TRrAnimation_GetTo(inAnimation)), + ONrAnimTypeToString(TRrAnimation_GetType(inAnimation)), TRrAnimation_GetDuration(inAnimation)); } @@ -7308,7 +7308,7 @@ float ONrCharacter_GetDesiredFacingOffset(const ONtCharacter *inCharacter) facing_to_desired_facing = inCharacter->desiredFacing - inCharacter->facing; - if ((forward_to_desired_angle > 0.f) && (facing_to_forward_angle > 0.f)) + if ((forward_to_desired_angle > 0.f) && (facing_to_forward_angle > 0.f)) { // always turn positive if (facing_to_desired_facing < 0.f) { @@ -7322,7 +7322,7 @@ float ONrCharacter_GetDesiredFacingOffset(const ONtCharacter *inCharacter) facing_to_desired_facing -= M3c2Pi; } } - else + else { facing_to_desired_facing = angle_to_relative_angle(facing_to_desired_facing); } @@ -7337,7 +7337,7 @@ static float iSignAngle(float angle) UUmAssertTrigRange(angle); - if (angle >= M3cPi) { + if (angle >= M3cPi) { result = angle - M3c2Pi; } @@ -7419,13 +7419,13 @@ void ONrCharacter_GetFacingVector(const ONtCharacter *inCharacter, M3tVector3D * * Returns a normalized vector corrosponding to the character's heading, * and a damped version of the same thing. */ - + const M3tPoint3D defFacing = {0,0,1}; float facing = ONrCharacter_GetCosmeticFacing(inCharacter); UUmAssertReadPtr(inCharacter, sizeof(*inCharacter)); UUmAssertWritePtr(outVector, sizeof(*outVector)); - + MUrPoint_RotateYAxis(&defFacing, facing, outVector); MUrNormalize(outVector); @@ -7438,7 +7438,7 @@ void ONrCharacter_GetAttackVector(const ONtCharacter *inCharacter, ONtActiveChar TRtDirection direction = TRrAnimation_GetDirection(inActiveCharacter->animation, UUcFalse); ONrCharacter_GetFacingVector(inCharacter, outVector); - + switch(direction) { case TRcDirection_None: case TRcDirection_360: @@ -7489,9 +7489,9 @@ UUtBool ONrAnimType_IsVictimType(TRtAnimType inAnimType) /****************** * Returns true if the character is running knockdown, throw, hit */ - + UUtBool busy; - + switch(inAnimType) { case ONcAnimType_Land_Dead: @@ -7552,7 +7552,7 @@ UUtBool ONrAnimType_IsVictimType(TRtAnimType inAnimType) busy = UUcFalse; break; } - + return busy; } @@ -7566,7 +7566,7 @@ UUtBool ONrCharacter_IsDefensive(const ONtCharacter *inCharacter) /****************** * Returns true if the character is standing still */ - + const TRtAnimation *animation; TRtAnimType type; TRtAnimState fromState, toState; @@ -7593,14 +7593,14 @@ UUtBool ONrCharacter_IsDefensive(const ONtCharacter *inCharacter) UUtBool fromIsCrouchOrStand, toIsCrouchOrStand; UUtBool typeIsCrouchStandTurnOrBlock; - fromIsCrouchOrStand = - (ONcAnimState_Crouch == fromState) || - (ONcAnimState_Crouch_Start == fromState) || + fromIsCrouchOrStand = + (ONcAnimState_Crouch == fromState) || + (ONcAnimState_Crouch_Start == fromState) || (ONcAnimState_Standing == fromState); - toIsCrouchOrStand = - (ONcAnimState_Crouch == fromState) || - (ONcAnimState_Crouch_Start == fromState) || + toIsCrouchOrStand = + (ONcAnimState_Crouch == fromState) || + (ONcAnimState_Crouch_Start == fromState) || (ONcAnimState_Standing == fromState); typeIsCrouchStandTurnOrBlock = @@ -7638,7 +7638,7 @@ UUtBool ONrCharacter_IsIdle(const ONtCharacter *inCharacter) UUtBool ONrCharacter_IsMovingBack(const ONtCharacter *inCharacter) { - switch(ONrCharacter_GetAnimType(inCharacter)) + switch(ONrCharacter_GetAnimType(inCharacter)) { case ONcAnimType_Run_Backwards_Start: case ONcAnimType_Walk_Backwards_Start: @@ -7660,7 +7660,7 @@ UUtBool ONrCharacter_IsPoweringUp(const ONtCharacter *inCharacter) return UUcFalse; } - return ((active_character->curAnimType == ONcAnimType_Powerup) && + return ((active_character->curAnimType == ONcAnimType_Powerup) && (TRrAnimation_GetFrom(active_character->animation) == ONcAnimState_Powerup)); } @@ -7692,7 +7692,7 @@ UUtBool ONrCharacter_IsInactiveUpright(const ONtCharacter *inCharacter) return UUcFalse; } - switch(active_character->curAnimType) + switch(active_character->curAnimType) { case ONcAnimType_Stand: case ONcAnimType_Idle: @@ -7735,7 +7735,7 @@ UUtBool ONrCharacter_IsInactiveUpright(const ONtCharacter *inCharacter) UUtBool ONrCharacter_IsStandingRunning(const ONtCharacter *inCharacter) { - switch(ONrCharacter_GetAnimType(inCharacter)) + switch(ONrCharacter_GetAnimType(inCharacter)) { case ONcAnimType_Run_Start: case ONcAnimType_Run_Backwards_Start: @@ -7780,7 +7780,7 @@ UUtBool ONrCharacter_IsUnableToTurn(const ONtCharacter *inCharacter) unable_to_turn = UUcFalse; break; } - } + } else { // player characters can never turn in these animtypes return UUcTrue; @@ -7904,7 +7904,7 @@ UUtBool ONrCharacter_IsKeepingMoving(ONtCharacter *inCharacter) return UUcFalse; } - switch(TRrAnimation_GetTo(active_character->animation)) + switch(TRrAnimation_GetTo(active_character->animation)) { case ONcAnimState_Running_Left_Down: case ONcAnimState_Running_Right_Down: @@ -7960,7 +7960,7 @@ UUtBool ONrCharacter_IsStandingRunningForward(const ONtCharacter *inCharacter) toState = TRrAnimation_GetTo(animation); type = TRrAnimation_GetType(animation); - switch(type) + switch(type) { case ONcAnimType_Run: case ONcAnimType_Run_Start: @@ -7997,14 +7997,14 @@ static void ONrCharacter_Stitch(ONtCharacter *ioCharacter, ONtActiveCharacter *i ioActiveCharacter->stitch.stitching = UUcTrue; ONrCharacter_GetVelocityEstimate(ioCharacter, ioActiveCharacter, &(ioActiveCharacter->stitch.velocity)); ioActiveCharacter->stitch.height = ioCharacter->heightThisFrame; - ioActiveCharacter->stitch.count = UUmMax(inStitchCount, ioActiveCharacter->stitch.count - ioActiveCharacter->stitch.itr); + ioActiveCharacter->stitch.count = UUmMax(inStitchCount, ioActiveCharacter->stitch.count - ioActiveCharacter->stitch.itr); ioActiveCharacter->stitch.itr = 0; ioActiveCharacter->stitch.fromState = fromState; if (ioActiveCharacter->stitch.stitching) { - ioActiveCharacter->stitch.count = UUmMax(inStitchCount, ioActiveCharacter->stitch.count - ioActiveCharacter->stitch.itr); + ioActiveCharacter->stitch.count = UUmMax(inStitchCount, ioActiveCharacter->stitch.count - ioActiveCharacter->stitch.itr); } else { - ioActiveCharacter->stitch.count = (UUtUns16) inStitchCount; + ioActiveCharacter->stitch.count = (UUtUns16) inStitchCount; } ONrCharacter_SetAnimationInternal(ioCharacter, ioActiveCharacter, fromState, ONcAnimType_None, inNewAnim); @@ -8045,27 +8045,27 @@ static ONtAnimPriority iCharacter_BuildPriority(ONtCharacter *inCharacter, ONtAc atomic = TRrAnimation_IsAtomic(oldAnimation, ioActiveCharacter->animFrame); if (type_is_equal && varient_is_equal && to_state_is_equal) { - result |= ONcAnimPriority_Queue; + result |= ONcAnimPriority_Queue; } else if (ONrCharacter_IsVictimAnimation(inCharacter)) { - result |= ONcAnimPriority_Queue; + result |= ONcAnimPriority_Queue; } else if (TRrAnimation_TestFlag(oldAnimation, ONcAnimFlag_ThrowTarget)) { - result |= ONcAnimPriority_Queue; + result |= ONcAnimPriority_Queue; } else if (TRrAnimation_TestFlag(oldAnimation, ONcAnimFlag_ThrowSource)) { - result |= ONcAnimPriority_Queue; + result |= ONcAnimPriority_Queue; } else if (ONrAnimType_IsKnockdown(oldAnimation->type)) { - result |= ONcAnimPriority_Queue; + result |= ONcAnimPriority_Queue; } - else if (!atomic) { - result |= ONcAnimPriority_Force; + else if (!atomic) { + result |= ONcAnimPriority_Force; } else if (isShortcut && TRrAnimation_TestShortcutFlag(inAnimation, oldToState, ONcShortcutFlag_Nuke)) { result |= ONcAnimPriority_Force; } - else { + else { result |= ONcAnimPriority_Queue; } @@ -8181,7 +8181,7 @@ const TRtAnimation *ONrCharacter_DoAnimation(ONtCharacter *ioCharacter, ONtActiv // lookup animation doStandingStillAnimation = (ONcAnimType_Stand == inAnimType) && (ONcAnimState_Standing == ioActiveCharacter->nextAnimState); animation = TRrCollection_Lookup(collection, inAnimType, ioActiveCharacter->nextAnimState, ioActiveCharacter->animVarient); - + if ((NULL == animation) && (ioActiveCharacter->animFrame < cMaxBacklook ) && (inPriority & ONcAnimPriority_BackInTime)) { animation = TRrCollection_Lookup(collection, inAnimType, ioActiveCharacter->curFromState, ioActiveCharacter->animVarient); @@ -8196,7 +8196,7 @@ const TRtAnimation *ONrCharacter_DoAnimation(ONtCharacter *ioCharacter, ONtActiv ioCharacter->flags &= ~ONcCharacterFlag_BeingThrown; //COrConsole_Printf("Character no longer being thrown"); } - + if (NULL == animation) { return NULL; } // check for pausing @@ -8204,11 +8204,11 @@ const TRtAnimation *ONrCharacter_DoAnimation(ONtCharacter *ioCharacter, ONtActiv UUtBool softPause; UUtBool hardPause; UUtBool valid; - - softPause = - ioActiveCharacter->hitStun || - ioActiveCharacter->blockStun || - ioActiveCharacter->softPauseFrames || + + softPause = + ioActiveCharacter->hitStun || + ioActiveCharacter->blockStun || + ioActiveCharacter->softPauseFrames || (TRrAnimation_GetSoftPause(ioActiveCharacter->animation, animation) > 0); hardPause = ioActiveCharacter->hardPauseFrames || (TRrAnimation_GetHardPause(ioActiveCharacter->animation, animation) > 0); @@ -8235,7 +8235,7 @@ const TRtAnimation *ONrCharacter_DoAnimation(ONtCharacter *ioCharacter, ONtActiv ioCharacter->flags &= ~ONcCharacterFlag_HastyAnim; - if ((!ONrCharacter_InBadVarientState(ioCharacter, ioActiveCharacter) && ONrCharacter_DisallowStitch(ioActiveCharacter->curAnimType, inAnimType)) || + if ((!ONrCharacter_InBadVarientState(ioCharacter, ioActiveCharacter) && ONrCharacter_DisallowStitch(ioActiveCharacter->curAnimType, inAnimType)) || (ONcAnimPriority_Queue & inPriority)) { // queue up the animation ioActiveCharacter->nextAnimType = inAnimType; @@ -8248,7 +8248,7 @@ const TRtAnimation *ONrCharacter_DoAnimation(ONtCharacter *ioCharacter, ONtActiv if (NULL != animation) { UUtUns8 stitchAmt = UUmMax(ONcNumStitchingFrames, ioActiveCharacter->minStitchingFrames); TRtAnimState fromState = ioActiveCharacter->nextAnimState; - + animation = RemapAnimationHook(ioCharacter, ioActiveCharacter, animation); if (NULL != ioActiveCharacter->animation) { @@ -8267,7 +8267,7 @@ const TRtAnimation *ONrCharacter_DoAnimation(ONtCharacter *ioCharacter, ONtActiv else { ONrCharacter_Stitch(ioCharacter, ioActiveCharacter, ioActiveCharacter->nextAnimState, animation, stitchAmt); } - + ONrCharacter_NewAnimationHook(ioCharacter, ioActiveCharacter); } @@ -8307,7 +8307,7 @@ static void ONiCharacter_DropInventoryItems(ONtCharacter *ioCharacter) if (ioCharacter->inventory.drop_invisibility) { // drop a full-strength invisibility WPrPowerup_Drop(WPcPowerup_Invisibility, WPcMaxInvisibility, ioCharacter, UUcFalse); - } + } if (((ioCharacter->flags & ONcCharacterFlag_NoAutoDrop) == 0) && (ioCharacter->charType != ONcChar_Player)) { /* @@ -8339,11 +8339,11 @@ void ONrCharacter_DropWeapon(ONtCharacter *ioCharacter, UUtBool inWantKnockAway, UUmAssert(ioCharacter->flags & ONcCharacterFlag_InUse); - if (inSlotNum == WPcAllSlots) + if (inSlotNum == WPcAllSlots) { WPrSlots_DropAll(&ioCharacter->inventory, inWantKnockAway, inStoreOnly); } - else + else { WPrSlot_Drop(&ioCharacter->inventory, inSlotNum, inWantKnockAway, inStoreOnly); } @@ -8355,7 +8355,7 @@ void ONrCharacter_DropWeapon(ONtCharacter *ioCharacter, UUtBool inWantKnockAway, if (active_character->extraBody != NULL) { active_character->extraBody->parts[0].geometry = NULL; } - + active_character->pleaseFire = UUcFalse; active_character->pleaseFireAlternate = UUcFalse; active_character->pleaseAutoFire = UUcFalse; @@ -8386,7 +8386,7 @@ ONrCharacter_UseWeapon( ONtActiveCharacter *active_character; UUmAssertWritePtr(ioCharacter, sizeof(*ioCharacter)); - + if (NULL == inWeapon) { // no weapon was specified so store the current weapon @@ -8396,20 +8396,20 @@ ONrCharacter_UseWeapon( { M3tGeometry *marker; WPtWeaponClass *weapon_class; - + UUmAssert(inWeapon); weapon_class = WPrGetClass(inWeapon); - + // don't arm dead characters if (ioCharacter->flags & ONcCharacterFlag_Dead_1_Animating) return; - + marker = NULL; - + active_character = ONrGetActiveCharacter(ioCharacter); // set the character's weapon ioCharacter->inventory.weapons[WPcPrimarySlot] = inWeapon; - + if (active_character != NULL) { active_character->extraBody->parts[0].geometry = WPrGetClass(inWeapon)->geometry; @@ -8418,7 +8418,7 @@ ONrCharacter_UseWeapon( active_character->matricies[ONcWeapon_Index] = MUgIdentityMatrix; } - + // tell the weapon it's been picked up WPrAssign(inWeapon,ioCharacter); @@ -8430,7 +8430,7 @@ ONrCharacter_UseWeapon( } } } - + return; } @@ -8440,7 +8440,7 @@ static TRtAnimType AdjustForCrouch(TRtAnimType type) switch(type) { - case ONcAnimType_Hit_Head: + case ONcAnimType_Hit_Head: case ONcAnimType_Hit_Body: case ONcAnimType_Hit_Foot: result = ONcAnimType_Hit_Crouch; @@ -8509,41 +8509,41 @@ static TRtAnimType AdjustForBehind(TRtAnimType inType) switch(inType) { - case ONcAnimType_Hit_Head: - result = ONcAnimType_Hit_Head_Behind; + case ONcAnimType_Hit_Head: + result = ONcAnimType_Hit_Head_Behind; break; - case ONcAnimType_Hit_Body: - result = ONcAnimType_Hit_Body_Behind; + case ONcAnimType_Hit_Body: + result = ONcAnimType_Hit_Body_Behind; break; case ONcAnimType_Hit_Jewels: case ONcAnimType_Hit_Foot_Ouch: - case ONcAnimType_Hit_Foot: - result = ONcAnimType_Hit_Body_Behind; + case ONcAnimType_Hit_Foot: + result = ONcAnimType_Hit_Body_Behind; break; - case ONcAnimType_Knockdown_Head: - result = ONcAnimType_Knockdown_Head_Behind; + case ONcAnimType_Knockdown_Head: + result = ONcAnimType_Knockdown_Head_Behind; break; - case ONcAnimType_Knockdown_Body: - result = ONcAnimType_Knockdown_Body_Behind; + case ONcAnimType_Knockdown_Body: + result = ONcAnimType_Knockdown_Body_Behind; break; - case ONcAnimType_Knockdown_Foot: - result = ONcAnimType_Knockdown_Foot_Behind; + case ONcAnimType_Knockdown_Foot: + result = ONcAnimType_Knockdown_Foot_Behind; break; - case ONcAnimType_Hit_Crouch: - result = ONcAnimType_Hit_Crouch_Behind; + case ONcAnimType_Hit_Crouch: + result = ONcAnimType_Hit_Crouch_Behind; break; - case ONcAnimType_Knockdown_Crouch: - result = ONcAnimType_Knockdown_Crouch_Behind; + case ONcAnimType_Knockdown_Crouch: + result = ONcAnimType_Knockdown_Crouch_Behind; break; - case ONcAnimType_Blownup: + case ONcAnimType_Blownup: result = ONcAnimType_Blownup_Behind; break; @@ -8726,7 +8726,7 @@ void ONrCharacter_Knockdown(ONtCharacter *attacker, ONtCharacter *defender, UUtU defender_activechar->lastAttack = ONcAnimType_None; defender_activechar->lastAttackTime = 0; - defender_activechar->animationLockFrames = 0; // stop looping an anim + defender_activechar->animationLockFrames = 0; // stop looping an anim newAnimType = ONrCharacter_CalculateAnimType(attacker, defender, defender_activechar, UUcFalse, inAnimType); @@ -8774,8 +8774,8 @@ void ONrCharacter_Knockdown(ONtCharacter *attacker, ONtCharacter *defender, UUtU case ONcAnimState_Falling_Right: break; - - default: + + default: try_falling = UUcFalse; } @@ -8817,9 +8817,9 @@ void ONrCharacter_Block(ONtCharacter *ioCharacter, ONtActiveCharacter *ioActiveC ONrCharacter_FightMode(ioCharacter); - ioActiveCharacter->animationLockFrames = 0; // stop looping an anim + ioActiveCharacter->animationLockFrames = 0; // stop looping an anim - if (ioActiveCharacter->curAnimType != ONcAnimType_Block) { + if (ioActiveCharacter->curAnimType != ONcAnimType_Block) { blockAnim = ONrCharacter_DoAnimation(ioCharacter, ioActiveCharacter, ONcAnimPriority_Force, ONcAnimType_Block); if (NULL == blockAnim) { @@ -8908,7 +8908,7 @@ static TRtAnimType ONrCharacter_NextScreenType(TRtAnimType inType) case ONcAnimType_Crouch_Walk: newType = ONcAnimType_Crouch; break; - + case ONcAnimType_Anything: newType = ONcAnimType_None; break; @@ -8952,7 +8952,7 @@ const TRtAimingScreen *ONrCharacter_GetAimingScreen(ONtCharacter *ioCharacter, O else { TRtAnimVarient old_varient = TRrAnimation_GetVarient(TRrAimingScreen_GetAnimation(result_aiming_screen)); TRtAnimVarient new_varient = TRrAnimation_GetVarient(TRrAimingScreen_GetAnimation(new_aiming_screen)); - + if (new_varient > old_varient) { result_aiming_screen = new_aiming_screen; } @@ -8960,7 +8960,7 @@ const TRtAimingScreen *ONrCharacter_GetAimingScreen(ONtCharacter *ioCharacter, O } type = ONrCharacter_NextScreenType(type); - } + } exit: return result_aiming_screen; @@ -8991,8 +8991,8 @@ void ONrCharacter_BuildQuaternions(ONtCharacter *ioCharacter, ONtActiveCharacter } UUrMemory_MoveFast( - ioActiveCharacter->curAnimOrientations, - ioActiveCharacter->curOrientations, + ioActiveCharacter->curAnimOrientations, + ioActiveCharacter->curOrientations, sizeof(M3tQuaternion) * numParts); { @@ -9014,7 +9014,7 @@ void ONrCharacter_BuildQuaternions(ONtCharacter *ioCharacter, ONtActiveCharacter // do aiming if we have a screen to aim with aimingScreen = NULL; - if (TRrAnimation_TestFlag(ioActiveCharacter->animation, ONcAnimFlag_DoAim) && !overlay_says_dont_aim) { + if (TRrAnimation_TestFlag(ioActiveCharacter->animation, ONcAnimFlag_DoAim) && !overlay_says_dont_aim) { if (ONcAnimType_Block != ioActiveCharacter->animation->type) { if (!ONrAnimType_IsVictimType(ioActiveCharacter->animation->type)) { aimingScreen = ONrCharacter_GetAimingScreen(ioCharacter, ioActiveCharacter); @@ -9048,7 +9048,7 @@ void ONrCharacter_BuildQuaternions(ONtCharacter *ioCharacter, ONtActiveCharacter aimLR += ioActiveCharacter->autoAimAdjustmentLR; aimUD += ioActiveCharacter->autoAimAdjustmentUD; - + if ((aimLR != 0.f) || (aimUD != 0.f)) { UUtUns32 num_interp_frames = 8; @@ -9144,7 +9144,7 @@ static void ONrCharacter_DoExactAiming(ONtCharacter *ioCharacter, ONtActiveChara pinned_ud += ioActiveCharacter->autoAimAdjustmentUD; TRrAimingScreen_Clip(ioActiveCharacter->aimingScreen, &pinned_lr, &pinned_ud); - + pinned_lr += ioCharacter->facing; UUmTrig_Clip(pinned_lr); @@ -9156,7 +9156,7 @@ static void ONrCharacter_DoExactAiming(ONtCharacter *ioCharacter, ONtActiveChara aimEuler = Euler_( 0, - pinned_lr, + pinned_lr, pinned_ud, MUcEulerOrderZYXr); @@ -9165,20 +9165,20 @@ static void ONrCharacter_DoExactAiming(ONtCharacter *ioCharacter, ONtActiveChara goal_matrix = MUgIdentityMatrix; MUrMatrixStack_Translate(&goal_matrix, &translation); - MUrMatrixStack_RotateX(&goal_matrix, M3c2Pi - M3cHalfPi); + MUrMatrixStack_RotateX(&goal_matrix, M3c2Pi - M3cHalfPi); { float lr; float ud; - + lr = pinned_lr - M3cHalfPi; UUmTrig_Clip(lr); ud = M3c2Pi - pinned_ud; - - MUrMatrixStack_RotateZ(&goal_matrix, lr); - MUrMatrixStack_RotateY(&goal_matrix, ud); + + MUrMatrixStack_RotateZ(&goal_matrix, lr); + MUrMatrixStack_RotateY(&goal_matrix, ud); } if (1.f == amount_exact_aiming) { @@ -9228,7 +9228,7 @@ void ONrCharacter_BuildMatricies(ONtCharacter *ioCharacter, ONtActiveCharacter * MUrMatrixStack_Scale(&chrBaseMatrix, ioCharacter->scale); } - if (!running_environment_animation) + if (!running_environment_animation) { M3tPoint3D height; @@ -9293,11 +9293,11 @@ void ONrCharacter_BuildMatricies(ONtCharacter *ioCharacter, ONtActiveCharacter * hand_up.x = 0.f; hand_up.y = 1.f; hand_up.z = 0.f; - + inverse_kinematics_adjust_matrices( - &hand_location, - &hand_forward, - &hand_up, + &hand_location, + &hand_forward, + &hand_up, ioActiveCharacter->matricies + ONcLArm1_Index, ioActiveCharacter->matricies + ONcLArm2_Index, ioActiveCharacter->matricies + ONcLHand_Index); @@ -9361,11 +9361,11 @@ void ONrCharacter_BuildBoundingVolumes(ONtCharacter *ioCharacter, ONtActiveChara for(itr = 1; itr < ONcNumCharacterParts; itr++) { UUtBool skip; - + // get the body part's location in worldspace curSphere = body->geometries[itr]->pointArray->boundingSphere; MUrMatrix_MultiplyPoints(1, &ioActiveCharacter->matricies[itr], &curSphere.center, &curSphere.center); - + // expand the collision bounding sphere by this part part_radius = MUmVector_GetDistance(ioActiveCharacter->boundingSphere.center, curSphere.center) + curSphere.radius; ioActiveCharacter->boundingSphere.radius = UUmMax(ioActiveCharacter->boundingSphere.radius, part_radius); @@ -9405,7 +9405,7 @@ void ONrCharacter_BuildBoundingVolumes(ONtCharacter *ioCharacter, ONtActiveChara MUrMinMaxBBox_ExpandBySphere(NULL, &bottomSphere, &ioCharacter->boundingBox); } - + // COrConsole_Printf("bot %2.2f/%2.2f top %2.2f", ioCharacter->boundingBox.minPoint.y, ioCharacter->location.y, ioCharacter->boundingBox.maxPoint.y); @@ -9441,7 +9441,7 @@ static TRtAnimType ONiRemapAnimType_For_Direction(TRtAnimType anim_type, ONtChar angle = angle - facing; UUmTrig_ClipLow(angle); - // ok now the angle is the difference between the defenders facing + // ok now the angle is the difference between the defenders facing // and the angle from the defender to the attacker if (angle > M3cPi) { @@ -9466,13 +9466,13 @@ ONiCharacter_GetPrimaryPartFromBits( UUtUns16 i; TRtBody *body; UUtUns16 part; - + if (inBodyPartBits == 0) { return ONcPelvis_Index; } - + part = ONcPelvis_Index; body = ONrCharacter_GetBody(inCharacter, TRcBody_SuperHigh); UUmAssert(body); - + for (i = body->numParts; i <= body->numParts; i--) { if (inBodyPartBits & (1 << i)) @@ -9481,7 +9481,7 @@ ONiCharacter_GetPrimaryPartFromBits( break; } } - + return part; } @@ -9505,7 +9505,7 @@ ONrCharacter_GetMaterialType( } } - if ((inPartIndex >= 0) && (inPartIndex < ONrCharacter_GetNumParts(inCharacter)) && + if ((inPartIndex >= 0) && (inPartIndex < ONrCharacter_GetNumParts(inCharacter)) && (inCharacter->characterClass->bodyPartMaterials->materials[inPartIndex] != NULL)) { type = inCharacter->characterClass->bodyPartMaterials->materials[inPartIndex]->id; } else { @@ -9523,7 +9523,7 @@ ONiCharacter_GetMaterialTypeFromMask( UUtUns32 inBodyPartBits) { UUtUns32 part; - + part = ONiCharacter_GetPrimaryPartFromBits(inCharacter, inBodyPartBits); return ONrCharacter_GetMaterialType(inCharacter, part, UUcTrue); @@ -9538,7 +9538,7 @@ ONiCharacter_GetSpecificImpactType( UUtUns32 itr; ONtCharacterImpactArray *impacts = inCharacter->characterClass->impacts; const char *attack_name; - + attack_name = TRrAnimation_GetAttackName(inActiveCharacter->animation); if (attack_name[0] == '\0') { if (ONgDebugCharacterImpacts) { @@ -9730,7 +9730,7 @@ UUtBool ONrCharacter_CouldBlock(ONtCharacter *inDefender, ONtCharacter *inAttack static float ONiCharacter_GetAttackPotency(ONtCharacter *ioCharacter, UUtBool *outOmnipotent) { float overhealth, potency; - + if (outOmnipotent != NULL) { *outOmnipotent = (ONgPlayerOmnipotent && (ioCharacter->charType == ONcChar_Player)); } @@ -9764,11 +9764,11 @@ static void ONiCharacter_BecomeTemporarilyVisible(ONtCharacter *inAttacker, ONtA } static void HandleAttackMask( - ONtCharacter *inAttacker, - ONtCharacter *inDefender, + ONtCharacter *inAttacker, + ONtCharacter *inDefender, ONtActiveCharacter *inActiveAttacker, ONtActiveCharacter *inActiveDefender, - const TRtAttack *inAttack, + const TRtAttack *inAttack, UUtUns32 inAttackIndex, UUtUns32 inAttackerParts, UUtUns32 inDefenderParts) @@ -9881,7 +9881,7 @@ static void HandleAttackMask( COrConsole_Printf("hit defender part %d, material type %d (%s)", defender_part, material_type, MArMaterialType_GetName(material_type)); } - + // get the attack's damage and knockback attack_owner = WPrOwner_MakeMeleeDamageFromCharacter(inAttacker); damage_multiplier = ONiCharacter_GetAttackPotency(inAttacker, &isOmnipotent); @@ -9938,7 +9938,7 @@ static void HandleAttackMask( if (isUnstoppable) { // CB: unstoppable characters can block without being blockstunned inDefender->flags |= ONcCharacterFlag_PleaseBlock; - } + } else if (inAttack->stagger > 0) { inActiveDefender->pendingDamageAnimType = ONcAnimType_Stagger; inActiveDefender->staggerStun = inAttack->stagger; @@ -9949,7 +9949,7 @@ static void HandleAttackMask( } } } - else { + else { // this is a valid hit! attack_result = ONcAttack_Hit; @@ -9972,7 +9972,7 @@ static void HandleAttackMask( if ((!isUnstoppable) && (damage_animation_type != ONcAnimType_None)) { TRtAnimType new_anim_type = damage_animation_type; - float damage_animation_adjustment_angle; + float damage_animation_adjustment_angle; new_anim_type = ONrCharacter_CalculateAnimType(inAttacker, inDefender, inActiveDefender, UUcTrue, new_anim_type); if (new_anim_type == ONcAnimType_None) { @@ -10003,7 +10003,7 @@ static void HandleAttackMask( inActiveDefender->pendingDamageAnimType = new_anim_type; // COrConsole_Printf("knockdown %d %s", new_anim_type, ONrAnimTypeToString(new_anim_type)); - + if (DamageAnimTypeHasFacing(new_anim_type)) { damage_animation_adjustment_angle = ONrCharacter_RelativeAngleToCharacter_Raw(inDefender, inAttacker); inDefender->facing += damage_animation_adjustment_angle; @@ -10034,7 +10034,7 @@ static void HandleAttackMask( else { if (NULL != inActiveDefender) { inActiveDefender->hitStun = hitstun_amount; - } + } } } @@ -10074,10 +10074,10 @@ static void HandleAttackMask( } // tell this particle about the impact; disable the hitflash, because we are pulsing a particle - P3rSendEvent(particle->particle_def->particle_class, particle->particle, + P3rSendEvent(particle->particle_def->particle_class, particle->particle, P3cEvent_Pulse, current_time); } - } + } else { if (ONgDebugCharacterImpacts) { COrConsole_Printf("attack has %d particles, but at current frame %d none are active", @@ -10124,12 +10124,12 @@ static void HandleAttackMask( P3rSetGlobalTint(ONrCharacter_GetHealthShade(inDefender->hitPoints, inDefender->maxHitPoints)); ONrImpactEffect(impact_type, material_type, impact_modifier, &effect_data, ai_sound_volumemodifier, inAttacker, inDefender); P3rClearGlobalTint(); - + return; } static void HandleGenericMask( - ONtCharacter *inAttacker, + ONtCharacter *inAttacker, ONtCharacter *inDefender) { ONtActiveCharacter *activeAttacker; @@ -10200,7 +10200,7 @@ static UUtUns32 BuildAttackCollisionList( *outAttackerParts = 0; *outDefenderParts = 0; - + UUmAssertReadPtr(attacker, sizeof(*attacker)); UUmAssertReadPtr(defender, sizeof(*defender)); @@ -10267,10 +10267,10 @@ static void iCollideTwoLikelyCharacters( const M3tGeometry* inGeometryB = bodyB->geometries[itrB]; UUtBool collide; - collide = M3rIntersect_GeomGeom( - inMatrixA, + collide = M3rIntersect_GeomGeom( + inMatrixA, inGeometryA, - inMatrixB, + inMatrixB, inGeometryB); if (collide) { @@ -10363,7 +10363,7 @@ static void iCollideTwoCharacters( if (inCharA->flags & ONcCharacterFlag_Dead_2_Moving) { goto exit; } - + if (inCharB->flags & ONcCharacterFlag_Dead_2_Moving) { goto exit; } @@ -10517,12 +10517,12 @@ void ONrCharacter_TakeDamage( ONiCharacter_Defeated(ioCharacter); return; } - + if (active_character != NULL) { // store damage direction and amount for use by weapon and powerup dropping if (inDirection == NULL) { MUmVector_Set(active_character->lastImpact, 0, 0, 0); - } + } else { // don't generate tremendously huge or unnoticably small impacts damage_scale = UUmPin(inDamage, 5, 15); @@ -10553,7 +10553,7 @@ void ONrCharacter_TakeDamage( } } - if ((ioCharacter->flags & ONcCharacterFlag_Unkillable) && (ioCharacter->hitPoints <= inDamage)) + if ((ioCharacter->flags & ONcCharacterFlag_Unkillable) && (ioCharacter->hitPoints <= inDamage)) { if (WPcDamageOwner_ActOfGod == (inDamageOwner & WPcDamageOwner_TypeMask)) { COrConsole_Printf("killing %s (act of god)", ioCharacter->player_name); @@ -10644,18 +10644,18 @@ void ONrCharacter_TakeDamage( ONiCharacter_RunDeathAnimation(ioCharacter, active_character, TRcAnimType_None); } } - + // record the damage done by the attacker if (attacker) { attacker->damageInflicted += inDamage; - + if (ioCharacter->hitPoints <= 0) { attacker->numKills++; } } - + if (!unstoppable) { // handle knockback of charcters from hit, blocked hit knockback ? if ((active_character != NULL) && (inKnockback != 0.f) && (NULL != inDirection)) @@ -10668,7 +10668,7 @@ void ONrCharacter_TakeDamage( MUmVector_Add(active_character->knockback, active_character->knockback, newKnockbackVector); } } - + ONrCharacter_DamageCompass(ioCharacter, inDirection); ONrCharacter_Commit_Scripts(); @@ -10685,7 +10685,7 @@ void ONrCharacter_Die(ONtCharacter *ioCharacter) ioCharacter->hitPoints = 0; ONrCharacter_Die_1_Animating_Hook(ioCharacter, NULL); } - + return; } @@ -10745,7 +10745,7 @@ static void ONiGameState_DoCharacterCollision(void) active_char->pendingDamageAnimType = ONcAnimType_None; } else if (curChar->flags & ONcCharacterFlag_PleaseBlock) { - ONrCharacter_Block(curChar, active_char); + ONrCharacter_Block(curChar, active_char); } curChar->flags &= ~ONcCharacterFlag_PleaseBlock; @@ -10871,13 +10871,13 @@ static void ONiCharacter_Fire(ONtCharacter *ioCharacter, ONtActiveCharacter *ioA MUmVector_Verify(ioActiveCharacter->aimingVector); - if (ioCharacter->flags & ONcCharacterFlag_Dead) { + if (ioCharacter->flags & ONcCharacterFlag_Dead) { return; } // mark you as not idle ONrCharacter_NotIdle(ioCharacter); - + // fire the gun fired = WPrDepressTrigger(ioCharacter->inventory.weapons[0], UUcFalse, (inFireMode == ONcFireMode_Alternate), &out_of_ammo); if (out_of_ammo) { @@ -10886,11 +10886,11 @@ static void ONiCharacter_Fire(ONtCharacter *ioCharacter, ONtActiveCharacter *ioA // try to reload is_autofire = ((inFireMode == ONcFireMode_Autofire) || (inFireMode == ONcFireMode_Continuous)); - + if (!is_autofire || is_ai) { reloaded = WPrTryReload(ioCharacter, ioCharacter->inventory.weapons[0], NULL, &out_of_ammo); play_click = out_of_ammo; - } + } else { // we can't reload our weapon by just holding the trigger down play_click = UUcTrue; @@ -10953,7 +10953,7 @@ void ONrCharacter_Teleport(ONtCharacter *ioCharacter, M3tPoint3D *inPoint, UUtBo ioCharacter->location = *inPoint; ioCharacter->actual_position = *inPoint; ioCharacter->actual_position.y += PHcWorldCoord_YOffset; - + if ((active_character != NULL) && (active_character->physics != NULL)) { active_character->physics->position = *inPoint; active_character->deferred_maximum_height = inPoint->y; @@ -10979,7 +10979,7 @@ void ONrCharacter_Teleport_With_Collision(ONtCharacter *ioCharacter, M3tPoint3D M3tPoint3D movement_vector; MUmVector_Subtract(movement_vector, *inPoint, active_character->physics->position); - + if (OBrPhysics_Update_Reflect(active_character->physics, &movement_vector)) { OBrPhysics_Update_ReflectHalt(active_character->physics, &movement_vector); } @@ -10998,14 +10998,14 @@ UUtBool ONrCharacter_LineOfSight(ONtCharacter *inLooker, ONtCharacter *inLookee) * Returns whether 'inLooker' can see 'inLookee'. Does not respect * fields of view. */ - + M3tPoint3D src,dest; - + src = inLooker->location; dest = inLookee->location; src.y += ONcCharacterHeight; dest.y+= ONcCharacterHeight; - + return AKrLineOfSight(&src,&dest); } @@ -11018,7 +11018,7 @@ float ONrCharacter_RelativeAngleToPoint_Raw(const ONtCharacter *inFromChar, cons MUmVector_Subtract(toVector, *inPoint, inFromChar->location); angle = (float) MUrATan2(toVector.x, toVector.z); UUmTrig_ClipLow(angle); - + if (angle < 0.f) { angle += M3c2Pi; } @@ -11093,7 +11093,7 @@ float ONrCharacter_RelativeAngleToCharacter(const ONtCharacter *inFromChar, cons MUmVector_Subtract(toVector, inToChar->location, inFromChar->location); angle = (float) MUrATan2(toVector.x, toVector.z); UUmTrig_ClipLow(angle); - + if (angle < 0.f) { angle += M3c2Pi; } @@ -11107,7 +11107,7 @@ float ONrCharacter_RelativeAngleToCharacter(const ONtCharacter *inFromChar, cons } static ONtCharacter *ONiCharacter_FindNearestOpponent( - ONtCharacter *inCharacter, + ONtCharacter *inCharacter, float inFacingOffset, float inMaxDistance, float inMaxAngle, @@ -11140,8 +11140,8 @@ static ONtCharacter *ONiCharacter_FindNearestOpponent( continue; } - if (characterItr == inCharacter) { - continue; + if (characterItr == inCharacter) { + continue; } if (AI2rTeam_FriendOrFoe(characterItr->teamNumber, inCharacter->teamNumber) == AI2cTeam_Friend) { @@ -11151,7 +11151,7 @@ static ONtCharacter *ONiCharacter_FindNearestOpponent( if (inSkipInvulnerable) { ONtActiveCharacter *active_character = ONrGetActiveCharacter(characterItr); - if (ONrCharacter_IsUnstoppable(characterItr) || (characterItr->flags & ONcCharacterFlag_Teleporting) || + if (ONrCharacter_IsUnstoppable(characterItr) || (characterItr->flags & ONcCharacterFlag_Teleporting) || ONrCharacter_IsKnockdownResistant(characterItr) || ((active_character != NULL) && TRrAnimation_TestFlag(active_character->animation, ONcAnimFlag_Invulnerable))) { continue; @@ -11170,8 +11170,8 @@ static ONtCharacter *ONiCharacter_FindNearestOpponent( if (angle > M3cPi) { angle -= M3c2Pi; } - - if (distance > inMaxDistance) { + + if (distance > inMaxDistance) { continue; } @@ -11228,7 +11228,7 @@ static void ONiCharacter_FaceOpponent(ONtCharacter *ioCharacter, ONtActiveCharac } target = ONiCharacter_FindNearestOpponent( - ioCharacter, + ioCharacter, attackFacing, ONgAutoAim_Distance, ONgAutoAim_Arc * M3cDegToRad, @@ -11392,7 +11392,7 @@ static P3tParticle *ONiCharacter_AttachParticle(ONtCharacter *ioCharacter, ONtAc bbox = &attach_geometry->pointArray->minmax_boundingBox; MUmVector_Add(effect_data.position, bbox->minPoint, bbox->maxPoint); MUmVector_Scale(effect_data.position, 0.5); - + // create the particle particle = P3rCreateEffect(&effect_spec, &effect_data); if (particle == NULL) { @@ -11500,7 +11500,7 @@ void ONrCharacter_NewAnimationHook(ONtCharacter *ioCharacter, ONtActiveCharacter UUmAssertReadPtr(active_target, sizeof(*active_target)); if ((!(target->flags & ONcCharacterFlag_Dead_1_Animating)) && (target->flags & ONcCharacterFlag_InUse)) - { + { if (TRrAnimation_GetVarient(animation) & ONcAnimVarientMask_Fight) { ONrCharacter_FightMode(target); } @@ -11516,11 +11516,11 @@ void ONrCharacter_NewAnimationHook(ONtCharacter *ioCharacter, ONtActiveCharacter ONrCharacter_SetAnimation_External(target, active_target->nextAnimState, ioActiveCharacter->targetThrow, 6); ONiCharacter_ThrowPhysics(ioCharacter, ioActiveCharacter, target, active_target); - + ioActiveCharacter->throwing = ONrCharacter_GetIndex(target); target->facing = ioCharacter->facing + animation->throwInfo->relativeThrowFacing; UUmTrig_ClipHigh(target->facing); - + target->flags |= ONcCharacterFlag_BeingThrown; } } @@ -11542,10 +11542,10 @@ void ONrCharacter_NewAnimationHook(ONtCharacter *ioCharacter, ONtActiveCharacter if ((ioCharacter->flags & ONcCharacterFlag_Dead_1_Animating) && (!ONrCharacter_IsVictimAnimation(ioCharacter))) { ONrCharacter_Die_2_Moving_Hook(ioCharacter); } - + if (ONrAnimation_IsFlying(ioActiveCharacter->animation)) { ioActiveCharacter->pleaseJump = UUcTrue; - + if (ioActiveCharacter->inAirControl.numFramesInAir == 0) { // COrConsole_Printf("jump_start mark flying %f", ioCharacter->physics->position.y); ioActiveCharacter->inAirControl.jump_height = ioActiveCharacter->physics->position.y; @@ -11610,7 +11610,7 @@ void ONrCharacter_NewAnimationHook(ONtCharacter *ioCharacter, ONtActiveCharacter if (particle->particle_def->particle_class != NULL) { // create the particle - particle->particle = ONiCharacter_AttachParticle(ioCharacter, ioActiveCharacter, + particle->particle = ONiCharacter_AttachParticle(ioCharacter, ioActiveCharacter, particle->particle_def->particle_class, particle->bodypart_index); } @@ -11647,11 +11647,11 @@ static void AttemptSpecificThrow( UUtUns32 score; if (UUmSQR(TRrAnimation_GetThrowDistance(inThrow)) >= inDistanceSquared) { - targetThrow = + targetThrow = TRrCollection_Lookup( - inSrcCharcter->characterClass->animations, - inThrow->throwInfo->throwType, - inDstActiveCharacter->nextAnimState, + inSrcCharcter->characterClass->animations, + inThrow->throwInfo->throwType, + inDstActiveCharacter->nextAnimState, inDstActiveCharacter->animVarient | ONcAnimVarientMask_Fight); if (targetThrow != NULL) { @@ -11755,7 +11755,7 @@ static const TRtAnimation *AttemptThrow( } distance_squared = MUrPoint_Distance_Squared(&ioCharacter->location, &target->location); - + { TRtAnimVarient not_my_varients = ~(ioActiveCharacter->animVarient | ONcAnimVarientMask_Fight); UUtInt32 itr; @@ -11763,10 +11763,10 @@ static const TRtAnimation *AttemptThrow( TRtAnimationCollectionPart *collection_entry; TRtAnimationCollection *collection = ioCharacter->characterClass->animations; - for(collection = ioCharacter->characterClass->animations; collection != NULL; collection = TRrCollection_GetRecursive(collection)) + for(collection = ioCharacter->characterClass->animations; collection != NULL; collection = TRrCollection_GetRecursive(collection)) { TRrCollection_Lookup_Range( - collection, + collection, animType, ioActiveCharacter->nextAnimState, &collection_entry, @@ -11777,7 +11777,7 @@ static const TRtAnimation *AttemptThrow( if ((varient_mask & not_my_varients) != 0) { // animation required varients that I do not posses - continue; + continue; } AttemptSpecificThrow(ioCharacter, ioActiveCharacter, target, target_active, distance_squared, collection_entry->animation, &specificThrow); @@ -11818,7 +11818,7 @@ static const TRtAnimation *RemapAnimationHook(ONtCharacter *ioCharacter, ONtActi specific_throw.facingOffset = ONrCharacter_RelativeAngleToCharacter(ioCharacter, target); if ((float)fabs(specific_throw.facingOffset) > M3cQuarterPi) { COrConsole_Printf("### RemapAnimationHook: AI %s tried to throw %s but facing delta %f > 45 degrees", - ioCharacter->player_name, target->player_name, specific_throw.facingOffset * M3cRadToDeg); + ioCharacter->player_name, target->player_name, specific_throw.facingOffset * M3cRadToDeg); } else { // attempt the throw @@ -11836,7 +11836,7 @@ static const TRtAnimation *RemapAnimationHook(ONtCharacter *ioCharacter, ONtActi return specific_throw.srcThrow; } else { COrConsole_Printf("### RemapAnimationHook: AI %s tried to throw %s (%s/%s) but was unable to", - ioCharacter->player_name, target->player_name, + ioCharacter->player_name, target->player_name, TMrInstance_GetInstanceName(throwanim), TMrInstance_GetInstanceName(specific_throw.dstThrow)); } } @@ -11919,14 +11919,14 @@ static void ONiCharacter_OldAnimationHook(ONtCharacter *ioCharacter, ONtActiveCh if (ioCharacter->flags & ONcCharacterFlag_ChrAnimate) { if (0 == ioActiveCharacter->animationLockFrames) { - ioCharacter->flags &= ~ONcCharacterFlag_ChrAnimate; + ioCharacter->flags &= ~ONcCharacterFlag_ChrAnimate; } } // UUmAssert((TRrAnimation_GetDuration(ioCharacter->animation) == ioCharacter->animFrame) || (!TRrAnimation_TestFlag(ioCharacter->animation, ONcAnimFlag_ThrowTarget))); - if ((ioActiveCharacter->curAnimType == ioActiveCharacter->lastAttack) && - (ioActiveCharacter->lastAttackTime == ONcLastAttackTime_StillActive)) + if ((ioActiveCharacter->curAnimType == ioActiveCharacter->lastAttack) && + (ioActiveCharacter->lastAttackTime == ONcLastAttackTime_StillActive)) { ioActiveCharacter->lastAttackTime = ONgGameState->gameTime; } @@ -12018,13 +12018,13 @@ void ONrCharacter_GetVelocityEstimate(const ONtCharacter *inCharacter, ONtActive MUmVector_Add(runningTotal, runningTotal, curSample); sampleSize++; - if (0 == animTime) { - break; + if (0 == animTime) { + break; } animTime--; } - + MUmVector_Scale(runningTotal, 1.f / sampleSize); *outVelocity = runningTotal; @@ -12039,7 +12039,7 @@ void ONrCharacter_GetVelocityEstimate(const ONtCharacter *inCharacter, ONtActive void ONrCharacter_FightMode(ONtCharacter *ioCharacter) { ONtActiveCharacter *active_character = ONrForceActiveCharacter(ioCharacter); - + if (active_character == NULL) { return; } @@ -12055,7 +12055,7 @@ void ONrCharacter_FightMode(ONtCharacter *ioCharacter) void ONrCharacter_ExitFightMode(ONtCharacter *ioCharacter) { ONtActiveCharacter *active_character = ONrForceActiveCharacter(ioCharacter); - + if (active_character == NULL) { return; } @@ -12091,7 +12091,7 @@ void ONrCharacter_UpdateAnimationForVarient(ONtCharacter *ioCharacter, ONtActive if (newAnimation) { oldVarient = TRrAnimation_GetVarient(ioActiveCharacter->animation); newVarient = TRrAnimation_GetVarient(newAnimation); - + if (newVarient > oldVarient) { ONrCharacter_Stitch(ioCharacter, ioActiveCharacter, ioActiveCharacter->curFromState, newAnimation, 8); } @@ -12141,9 +12141,9 @@ ONrCharacter_SetHitPoints( UUtUns32 inHitPoints) { UUmAssert(ioCharacter); - + ioCharacter->hitPoints = inHitPoints; - + if ((inHitPoints > 0) && (ioCharacter->flags & ONcCharacterFlag_Dead_1_Animating)) { ONrCharacter_Live_Hook(ioCharacter); @@ -12209,9 +12209,9 @@ static UUtBool ONiCharacter_TestAndSetHit(ONtCharacter *ioCharacter, ONtActiveCh } void ONrCharacter_SetAnimation_External( - ONtCharacter *ioCharacter, - TRtAnimState fromState, - const TRtAnimation *inNewAnim, + ONtCharacter *ioCharacter, + TRtAnimState fromState, + const TRtAnimation *inNewAnim, UUtInt32 inStitchCount) { ONtActiveCharacter *active_character = ONrForceActiveCharacter(ioCharacter); @@ -12292,7 +12292,7 @@ static void ONrCharacter_Die_1_Animating_Hook(ONtCharacter *ioCharacter, ONtChar // tell the AI2 system that a character is dying AI2rNotify_Death(ioCharacter, inKiller); - + if (ioCharacter->charType == ONcChar_AI2) { // delete this AI AI2rDeleteState(ioCharacter); @@ -12327,7 +12327,7 @@ static void ONrCharacter_Die_1_Animating_Hook(ONtCharacter *ioCharacter, ONtChar ioCharacter->flags |= ONcCharacterFlag_Dead_1_Animating; ioCharacter->time_of_death = ONgGameState->gameTime; ioCharacter->death_delete_timer = ioCharacter->characterClass->death_deletedelay; - + // stop any super particle effects ioCharacter->super_amount = 0.0f; @@ -12356,7 +12356,7 @@ static void ONrCharacter_Die_1_Animating_Hook(ONtCharacter *ioCharacter, ONtChar static void ONrCharacter_Die_2_Moving_Hook(ONtCharacter *ioCharacter) { - ONtActiveCharacter *active_character = ONrGetActiveCharacter(ioCharacter); + ONtActiveCharacter *active_character = ONrGetActiveCharacter(ioCharacter); UUmAssert(0 == (ioCharacter->flags & ONcCharacterFlag_Dead_2_Moving)); UUmAssert(0 == (ioCharacter->flags & ONcCharacterFlag_Dead_3_Cosmetic)); @@ -12404,7 +12404,7 @@ static void ONrCharacter_Die_3_Cosmetic_Hook(ONtCharacter *ioCharacter) ioCharacter->flags |= ONcCharacterFlag_Dead_3_Cosmetic; ONrCharacter_DisablePhysics(ioCharacter); - + if (!ONrCharacter_IsActive(ioCharacter)) { // delete this character immediately ONrCharacter_Die_4_Gone_Hook(ioCharacter); @@ -12477,10 +12477,10 @@ static UUtBool ONrCharacter_Collide_With_Part(UUtUns16 inPart) switch(inPart) { - case ONcLLeg_Index: + case ONcLLeg_Index: case ONcLLeg1_Index: case ONcLFoot_Index: - case ONcRLeg_Index: + case ONcRLeg_Index: case ONcRLeg1_Index: case ONcRFoot_Index: @@ -12548,7 +12548,7 @@ ONrCharacter_Callback_FindEnvCollisions( PHtCollider *newCollider; UUtBool collide; M3tPoint3D intersection; - + collide = PHrCollision_Quad_SphereTreeVector( inEnvironment, curCollision->gqIndex, active_character->sphereTree, &localVelocity, &intersection); @@ -12612,7 +12612,7 @@ ONrCharacter_Callback_FindEnvCollisions( (*ioNumColliders)++; } } - + return; } @@ -12660,10 +12660,10 @@ static void ONrCharacter_Land(ONtCharacter *inCharacter, ONtActiveCharacter *ioA else { float falling_delta; float fall_percent; - + falling_delta = character_class->airConstants.damage_end - character_class->airConstants.damage_start; fall_percent = (falling_height - character_class->airConstants.damage_start) / falling_delta; - falling_damage = fall_percent * inCharacter->maxHitPoints; + falling_damage = fall_percent * inCharacter->maxHitPoints; } if (falling_damage > 0.f) { @@ -12674,13 +12674,13 @@ static void ONrCharacter_Land(ONtCharacter *inCharacter, ONtActiveCharacter *ioA float falling_knockback = 0.f; ONrCharacter_TakeDamage( - inCharacter, - int_falling_damage, - falling_knockback, - NULL, - NULL, - WPcDamageOwner_Falling, - ONcAnimType_Land_Dead); + inCharacter, + int_falling_damage, + falling_knockback, + NULL, + NULL, + WPcDamageOwner_Falling, + ONcAnimType_Land_Dead); } ioActiveCharacter->inAirControl.velocity.x = 0; @@ -12744,18 +12744,18 @@ static UUtBool FindGroundCollision(ONtCharacter *inCharacter, ONtActiveCharacter velocity.y -= foot_offset + solid_offset; if (gChrDebugFall) { - COrConsole_Printf("ground collision %s frame %d {fh %3.3f max %3.3f feet %3.3f} %3.3f -> %3.3f", - inCharacter->player_name, - ONgGameState->gameTime, + COrConsole_Printf("ground collision %s frame %d {fh %3.3f max %3.3f feet %3.3f} %3.3f -> %3.3f", + inCharacter->player_name, + ONgGameState->gameTime, foot_offset, height, feet_location, - sphere.center.y, + sphere.center.y, sphere.center.y + velocity.y); } AKrCollision_Sphere( - ONgGameState->level->environment, + ONgGameState->level->environment, &sphere, &velocity, AKcGQ_Flag_Chr_Col_Skip | AKcGQ_Flag_Wall, @@ -12785,9 +12785,9 @@ static UUtBool FindGroundCollision(ONtCharacter *inCharacter, ONtActiveCharacter float gq_plane_d, sphere_d; UUtBool gq_is_floor; UUtBool gq_is_ceiling; - + AKmPlaneEqu_GetComponents( - gqCollision->planeEquIndex, + gqCollision->planeEquIndex, environment->planeArray->planes, gq_plane_normal.x, gq_plane_normal.y, @@ -12820,7 +12820,7 @@ static UUtBool FindGroundCollision(ONtCharacter *inCharacter, ONtActiveCharacter float new_max; float debug_min_y = UUcFloat_Max; float debug_max_y = UUcFloat_Min; - + for(point_itr = 0; point_itr < num_points; point_itr++) { @@ -12932,7 +12932,7 @@ ONrCharacter_Callback_PrivateMovement( active_character->inAirControl.jump_height = active_character->physics->position.y; } - active_character->offGroundFrames++; + active_character->offGroundFrames++; } else { @@ -13010,7 +13010,7 @@ ONrCharacter_Callback_FindPhyCollisions( // player does not push weapons skip_weapons = (character->charType == ONcChar_Player); has_any_physics_collisions = !(character->flags & ONcCharacterFlag_Dead_2_Moving); - + if (has_any_physics_collisions) { for (i=0; i < PHgPhysicsContextArray->num_contexts; i++) { @@ -13022,7 +13022,7 @@ ONrCharacter_Callback_FindPhyCollisions( if (targetContext->callback->type == PHcCallback_Character) continue; if (skip_weapons && (targetContext->callback->type == PHcCallback_Weapon)) continue; if (targetContext->callback->type == PHcCallback_Powerup) continue; - if (targetContext->flags & PHcFlags_Physics_DontBlock) continue; + if (targetContext->flags & PHcFlags_Physics_DontBlock) continue; PHrPhysics_Single_PhyCollision(inContext, targetContext, inVelocity, outColliders, ioNumColliders); } @@ -13178,7 +13178,7 @@ ONtCharacterClass *ONrGetCharacterClass(const char *inString) inString, &result); - if (UUcError_None != error) { + if (UUcError_None != error) { result = NULL; } @@ -13209,13 +13209,13 @@ static void ONrCharacter_SetWeaponVarient(ONtCharacter *ioCharacter, ONtActiveCh WPtWeaponClass *weaponClass; UUtBool two_handed_weapon; UUtBool lefty; - + weaponClass = WPrGetClass(ioCharacter->inventory.weapons[0]); UUmAssertReadPtr(weaponClass, sizeof(WPtWeaponClass)); two_handed_weapon = (weaponClass->flags & WPcWeaponClassFlag_TwoHanded) ? UUcTrue : UUcFalse; lefty = ioCharacter->characterClass->leftHanded; - + if (lefty & two_handed_weapon) { ioActiveCharacter->animVarient |= ONcAnimVarientMask_Lefty_Rifle; } @@ -13325,7 +13325,7 @@ void ONrCharacter_BuildPhysicsFlags(ONtCharacter *ioCharacter, ONtActiveCharacte else { myPhysics->flags &= ~PHcFlags_Physics_TwoReflectionPasses; } - + if (ioCharacter->flags & ONcCharacterFlag_Dead_2_Moving) { myPhysics->flags |= PHcFlags_Physics_DontBlock; } @@ -13593,7 +13593,7 @@ void ONrCharacter_PickupWeapon( if (WPrSlot_FindEmpty(&inCharacter->inventory, &stowedSlot, UUcTrue)) { WPrSlot_Swap(&inCharacter->inventory, stowedSlot, WPcPrimarySlot); ONrCharacter_UseWeapon(inCharacter, NULL); - } + } else { // no slots found. we must drop the weapon. ONrCharacter_DropWeapon(inCharacter, UUcFalse, WPcPrimarySlot, UUcFalse); @@ -13616,7 +13616,7 @@ void ONrCharacter_PickupPowerup( WPtPowerup *inPowerup) { if (inPowerup == NULL) { return; } - + if (WPrPowerup_Give(inCharacter, inPowerup->type, inPowerup->amount, UUcFalse, UUcTrue)) { WPrPowerup_Delete(inPowerup); @@ -13633,7 +13633,7 @@ void ONrCharacter_HandlePickupInput( { WPtWeapon *weapon = NULL; WPtPowerup *powerup = NULL; - + // can't do a pickup while running a reload or holster animation if (ONrOverlay_IsActive(inActiveCharacter->overlay + ONcOverlayIndex_InventoryManagement)) { return; @@ -14059,9 +14059,9 @@ UUtBool ONrCharacter_Reload(ONtCharacter *ioCharacter, ONtActiveCharacter *ioAct return UUcTrue; } - reload_animation = TRrCollection_Lookup(ioCharacter->characterClass->animations, - WPrGetClass(ioCharacter->inventory.weapons[0])->reloadAnimType, - ONcAnimState_Standing, + reload_animation = TRrCollection_Lookup(ioCharacter->characterClass->animations, + WPrGetClass(ioCharacter->inventory.weapons[0])->reloadAnimType, + ONcAnimState_Standing, ioActiveCharacter->animVarient); if (reload_animation != NULL) { // use the ammo and start the reload @@ -14098,9 +14098,9 @@ UUtBool ONrCharacter_Holster(ONtCharacter *ioCharacter, ONtActiveCharacter *ioAc holster_animation = TRrCollection_Lookup( - ioCharacter->characterClass->animations, - holster_anim_type, - ONcAnimState_Standing, + ioCharacter->characterClass->animations, + holster_anim_type, + ONcAnimState_Standing, ioActiveCharacter->animVarient); if (NULL != holster_animation) { @@ -14134,9 +14134,9 @@ void ONrCharacter_Draw(ONtCharacter *ioCharacter, ONtActiveCharacter *ioActiveCh draw_animation = TRrCollection_Lookup( - ioCharacter->characterClass->animations, - draw_anim_type, - ONcAnimState_Standing, + ioCharacter->characterClass->animations, + draw_anim_type, + ONcAnimState_Standing, ioActiveCharacter->animVarient); if (NULL != draw_animation) { @@ -14312,7 +14312,7 @@ void ONrCharacter_ConsoleAction_Begin(ONtCharacter *inCharacter, ONtActionMarker UUmAssert( inCharacter ); UUmAssert( inActionMarker ); UUmAssert( !inCharacter->console_marker ); - + // mark character as moving towards marker inCharacter->console_marker = inActionMarker; @@ -14345,7 +14345,7 @@ void ONrCharacter_ConsoleAction_Finish(ONtCharacter *inCharacter, UUtBool inSucc // tell the AI that the console action completed, successfully or unsuccessfully AI2rNotifyConsoleAction(inCharacter, inSuccess); } - } + } else { // we have been knocked out of the console action, don't try to draw our weapon ever WPrInventory_Weapon_Purge_Magic(&inCharacter->inventory); @@ -14371,8 +14371,8 @@ void ONrCharacter_ConsoleAction_Update(ONtCharacter *inCharacter, ONtActiveChara float new_facing; float min_distance = UUmFeet(4.0); float distance; - UUtBool is_running_a_console_animation = - (ioActiveCharacter->curAnimType == ONcAnimType_Console) || + UUtBool is_running_a_console_animation = + (ioActiveCharacter->curAnimType == ONcAnimType_Console) || (ioActiveCharacter->curAnimType == ONcAnimType_Console_Punch); UUmAssert( inCharacter ); @@ -14407,7 +14407,7 @@ void ONrCharacter_ConsoleAction_Update(ONtCharacter *inCharacter, ONtActiveChara if (is_running_a_console_animation) { action_frame = UUmMin(ioActiveCharacter->animation->actionFrame, ioActiveCharacter->animation->numFrames - 1); - + UUmAssert( action_frame != -1 ); if (ioActiveCharacter->animFrame == action_frame) @@ -14416,13 +14416,13 @@ void ONrCharacter_ConsoleAction_Update(ONtCharacter *inCharacter, ONtActiveChara OBJrConsole_OnActivate( object, inCharacter ); ONrCharacter_ConsoleAction_Finish( inCharacter, UUcTrue ); } - return; + return; } new_position.x = action_marker->position.x; new_position.y = object->position.y; new_position.z = action_marker->position.z; - + distance = MUmVector_GetDistance( inCharacter->location, new_position ); MUmVector_Subtract( new_vector, new_position, inCharacter->location ); @@ -14430,7 +14430,7 @@ void ONrCharacter_ConsoleAction_Update(ONtCharacter *inCharacter, ONtActiveChara new_facing = MUrATan2( new_vector.x, new_vector.z ); UUmTrig_Clip( new_facing ); - + // if we are close enough to the console... if (distance < 2.f) { // face the console... @@ -14444,7 +14444,7 @@ void ONrCharacter_ConsoleAction_Update(ONtCharacter *inCharacter, ONtActiveChara // run the console animation... if (!ONrCharacter_IsReloading(inCharacter)) { const TRtAnimation *new_animation; - + new_animation = ONrCharacter_DoAnimation( inCharacter, ioActiveCharacter, ONcAnimPriority_Force, (console_osd->flags & OBJcConsoleFlag_Punch) ? ONcAnimType_Console_Punch : ONcAnimType_Console ); if (NULL == new_animation) { @@ -14465,18 +14465,18 @@ void ONrCharacter_ConsoleAction_Update(ONtCharacter *inCharacter, ONtActiveChara if (ioActiveCharacter->curAnimType != ONcAnimType_Console_Walk) { const TRtAnimation *animation = TRrCollection_Lookup(inCharacter->characterClass->animations, ONcAnimType_Console_Walk, ioActiveCharacter->nextAnimState, ioActiveCharacter->animVarient); - if (NULL != animation) { + if (NULL != animation) { ONrCharacter_SetAnimation_External(inCharacter, ioActiveCharacter->nextAnimState, animation, 12); } } - + inCharacter->desiredFacing = action_marker->direction; MUmVector_Normalize(new_vector); MUmVector_Scale( new_vector, (float)UUmMin( 0.25, distance ) ); new_position.x = inCharacter->location.x + new_vector.x; new_position.y = inCharacter->location.y + new_vector.y; - new_position.z = inCharacter->location.z + new_vector.z; + new_position.z = inCharacter->location.z + new_vector.z; ONrCharacter_Teleport(inCharacter, &new_position, UUcFalse); } @@ -14519,7 +14519,7 @@ static void ONiSetupCharacterIntersectState(ONtCharacter *inCharacter, TRtCharac outState->original_position = outState->position; outState->dirty_position = UUcFalse; } - + // set up an animation intersection context for determining whether one character can strike another void ONrSetupAnimIntersectionContext(ONtCharacter *inAttacker, ONtCharacter *inTarget, UUtBool inConsiderAttack, TRtAnimIntersectContext *outContext) @@ -14594,10 +14594,10 @@ void ONrSetupAnimIntersectionContext(ONtCharacter *inAttacker, ONtCharacter *inT costheta = MUrCos(inTarget->facing); sintheta = MUrSin(inTarget->facing); outContext->target_velocity_estimate.y = sintheta * delta_position.x + costheta * delta_position.z; outContext->target_velocity_estimate.x = costheta * delta_position.x - sintheta * delta_position.x; - } else { + } else { // get a velocity estimate for the target - in XZ space, then transform to XY animspace. ONrCharacter_GetVelocityEstimate(inTarget, target_active, &outContext->target_velocity_estimate); - outContext->target_velocity_estimate.y = outContext->target_velocity_estimate.z; + outContext->target_velocity_estimate.y = outContext->target_velocity_estimate.z; } // use the delta-position to get the target's vertical motion @@ -14922,7 +14922,7 @@ static UUtBool GetQuadRangeClipped(UUtInt32 inNumPoints, const M3tPoint3D **inPo if (0 == new_total_points) { goto exit; } if (new_total_points >= 3) { - for(itr = 0; itr < new_total_points; itr++) + for(itr = 0; itr < new_total_points; itr++) { float y0 = clipped_points1[itr].y; float y1 = clipped_points1[(itr + 1) % new_total_points].y; @@ -14972,7 +14972,7 @@ static void ONrCorpse_Create(ONtCharacter *inCharacter) ONrCorpse_Create_VisibleList(new_corpse); } - + next++; if (next >= count) { @@ -15049,9 +15049,9 @@ static void ONrCorpse_Display(M3tPoint3D *inCameraLocation) } // ONrCorpse_Print_NodeList(this_corpse->node_list); - + corpse_is_visible = AKrEnvironment_NodeList_Visible(this_corpse->node_list); - + if (corpse_is_visible) { if (character_class != NULL) { @@ -15125,7 +15125,7 @@ void ONrCharacter_Invis_Update(ONtCharacter *ioCharacter, ONtActiveCharacter *io ioActiveCharacter->invis_active = UUcTrue; } else if ((invis_remaining > 0) || (ioActiveCharacter->invis_active)) { - + const UUtUns32 fade_out = 120; float goal_invis_character_alpha = (invis_remaining > fade_out) ? 0.f : 1.f; float fade_in_alpha_speed = 0.02f; @@ -15432,7 +15432,7 @@ UUtBool ONrCharacter_AutoAim(ONtCharacter *ioCharacter, ONtActiveCharacter *ioAc if (MUrPoint_Distance_Squared(&ioCharacter->location, &target->location) > UUmSQR(500.f)) { goto exit; } - + if (!gWeaponAutoAim) { goto exit; } @@ -15462,8 +15462,8 @@ UUtBool ONrCharacter_AutoAim(ONtCharacter *ioCharacter, ONtActiveCharacter *ioAc M3tVector3D aiming_vector; ONrCreateTargetingVector( - &shoot_location, - &src_location, + &shoot_location, + &src_location, &WPrGetClass(ioCharacter->inventory.weapons[0])->ai_parameters, ioActiveCharacter->matricies + ONcWeapon_Index, &aiming_vector); @@ -15536,7 +15536,7 @@ void ONrCharacter_CinematicEndHolster(ONtCharacter *inCharacter, UUtBool inForce if (inCharacter->inventory.weapons[0] != NULL) { return; - } + } { ONtActiveCharacter *active_character = ONrGetActiveCharacter(inCharacter); @@ -15585,8 +15585,8 @@ UUtBool ONrCharacter_IsGunThroughWall(ONtCharacter *inCharacter, ONtActiveCharac { UUtUns32 attachment_index; - - for (attachment_index = 0; attachment_index < weapon_class->attachment_count; attachment_index++) + + for (attachment_index = 0; attachment_index < weapon_class->attachment_count; attachment_index++) { WPtParticleAttachment *attachment = weapon_class->attachment + attachment_index; @@ -15621,7 +15621,7 @@ UUtBool ONrCharacter_IsGunThroughWall(ONtCharacter *inCharacter, ONtActiveCharac // NOTE: if the character is shooting over a ledge with a long weapon this function may fail when it should // pass, fix later. -Michael Evans july 1, 2000 - + exit: return gun_is_through_wall; } @@ -15790,14 +15790,14 @@ UUtUns16 ONrCharacter_GetAnimationImpactType(UUtUns16 inAnimType) {ONcAnimType_Walk_Start, ONcAnimationImpact_Walk}, {ONcAnimType_Walk_Sidestep_Left, ONcAnimationImpact_Walk}, {ONcAnimType_Walk_Sidestep_Right, ONcAnimationImpact_Walk}, - {ONcAnimType_Walk_Backwards, ONcAnimationImpact_Walk}, + {ONcAnimType_Walk_Backwards, ONcAnimationImpact_Walk}, {ONcAnimType_Console_Walk, ONcAnimationImpact_Walk}, {ONcAnimType_Walk_Stop, ONcAnimationImpact_WalkStop}, // running footsteps {ONcAnimType_Run, ONcAnimationImpact_Run}, {ONcAnimType_Run_Backwards, ONcAnimationImpact_Run}, - {ONcAnimType_Run_Sidestep_Left, ONcAnimationImpact_Run}, + {ONcAnimType_Run_Sidestep_Left, ONcAnimationImpact_Run}, {ONcAnimType_Run_Sidestep_Right, ONcAnimationImpact_Run}, {ONcAnimType_Run_Start, ONcAnimationImpact_RunStart}, {ONcAnimType_Run_Backwards_Start, ONcAnimationImpact_RunStart}, @@ -15807,28 +15807,28 @@ UUtUns16 ONrCharacter_GetAnimationImpactType(UUtUns16 inAnimType) {ONcAnimType_1Step_Stop, ONcAnimationImpact_1Step}, // crouching footsteps - {ONcAnimType_Crouch_Run, ONcAnimationImpact_Crouch}, - {ONcAnimType_Crouch_Run_Backwards, ONcAnimationImpact_Crouch}, + {ONcAnimType_Crouch_Run, ONcAnimationImpact_Crouch}, + {ONcAnimType_Crouch_Run_Backwards, ONcAnimationImpact_Crouch}, {ONcAnimType_Crouch_Run_Sidestep_Left, ONcAnimationImpact_Crouch}, {ONcAnimType_Crouch_Run_Sidestep_Right, ONcAnimationImpact_Crouch}, {ONcAnimType_Crouch_Walk, ONcAnimationImpact_Crouch}, {ONcAnimType_Crouch_Walk_Backwards, ONcAnimationImpact_Crouch}, {ONcAnimType_Crouch_Walk_Sidestep_Left, ONcAnimationImpact_Crouch}, - {ONcAnimType_Crouch_Walk_Sidestep_Right, ONcAnimationImpact_Crouch}, + {ONcAnimType_Crouch_Walk_Sidestep_Right, ONcAnimationImpact_Crouch}, // sliding {ONcAnimType_Slide, ONcAnimationImpact_Slide}, // knockdowns {ONcAnimType_Blownup, ONcAnimationImpact_Knockdown}, - {ONcAnimType_Blownup_Behind, ONcAnimationImpact_Knockdown}, + {ONcAnimType_Blownup_Behind, ONcAnimationImpact_Knockdown}, {ONcAnimType_Knockdown_Head, ONcAnimationImpact_Knockdown}, - {ONcAnimType_Knockdown_Body, ONcAnimationImpact_Knockdown}, + {ONcAnimType_Knockdown_Body, ONcAnimationImpact_Knockdown}, {ONcAnimType_Knockdown_Foot, ONcAnimationImpact_Knockdown}, {ONcAnimType_Knockdown_Crouch, ONcAnimationImpact_Knockdown}, {ONcAnimType_Knockdown_Head_Behind, ONcAnimationImpact_Knockdown}, {ONcAnimType_Knockdown_Body_Behind, ONcAnimationImpact_Knockdown}, - {ONcAnimType_Knockdown_Foot_Behind, ONcAnimationImpact_Knockdown}, + {ONcAnimType_Knockdown_Foot_Behind, ONcAnimationImpact_Knockdown}, {ONcAnimType_Knockdown_Crouch_Behind, ONcAnimationImpact_Knockdown}, // been thrown @@ -15852,7 +15852,7 @@ UUtUns16 ONrCharacter_GetAnimationImpactType(UUtUns16 inAnimType) // landing {ONcAnimType_Land, ONcAnimationImpact_Land}, - {ONcAnimType_Land_Forward, ONcAnimationImpact_Land}, + {ONcAnimType_Land_Forward, ONcAnimationImpact_Land}, {ONcAnimType_Land_Right, ONcAnimationImpact_Land}, {ONcAnimType_Land_Left, ONcAnimationImpact_Land}, {ONcAnimType_Land_Back, ONcAnimationImpact_Land}, @@ -15874,12 +15874,12 @@ UUtUns16 ONrCharacter_GetAnimationImpactType(UUtUns16 inAnimType) {ONcAnimType_Kick_Left, ONcAnimationImpact_Land}, {ONcAnimType_Kick_Right, ONcAnimationImpact_Land}, {ONcAnimType_Kick_Back, ONcAnimationImpact_Land}, - {ONcAnimType_Kick_Low, ONcAnimationImpact_Land}, + {ONcAnimType_Kick_Low, ONcAnimationImpact_Land}, {ONcAnimType_Punch_Forward, ONcAnimationImpact_Land}, {ONcAnimType_Punch_Left, ONcAnimationImpact_Land}, {ONcAnimType_Punch_Right, ONcAnimationImpact_Land}, {ONcAnimType_Punch_Back, ONcAnimationImpact_Land}, - {ONcAnimType_Punch_Low, ONcAnimationImpact_Land}, + {ONcAnimType_Punch_Low, ONcAnimationImpact_Land}, {ONcAnimType_Kick2, ONcAnimationImpact_Land}, {ONcAnimType_Kick3, ONcAnimationImpact_Land}, {ONcAnimType_Kick3_Forward, ONcAnimationImpact_Land}, @@ -15887,12 +15887,12 @@ UUtUns16 ONrCharacter_GetAnimationImpactType(UUtUns16 inAnimType) {ONcAnimType_Punch3, ONcAnimationImpact_Land}, {ONcAnimType_Punch4, ONcAnimationImpact_Land}, {ONcAnimType_PPK, ONcAnimationImpact_Land}, - {ONcAnimType_PKK, ONcAnimationImpact_Land}, + {ONcAnimType_PKK, ONcAnimationImpact_Land}, {ONcAnimType_PKP, ONcAnimationImpact_Land}, {ONcAnimType_KPK, ONcAnimationImpact_Land}, {ONcAnimType_KPP, ONcAnimationImpact_Land}, {ONcAnimType_KKP, ONcAnimationImpact_Land}, - {ONcAnimType_PK, ONcAnimationImpact_Land}, + {ONcAnimType_PK, ONcAnimationImpact_Land}, {ONcAnimType_KP, ONcAnimationImpact_Land}, {ONcAnimType_PPKK, ONcAnimationImpact_Land}, {ONcAnimType_PPKKK, ONcAnimationImpact_Land}, @@ -15900,12 +15900,12 @@ UUtUns16 ONrCharacter_GetAnimationImpactType(UUtUns16 inAnimType) {ONcAnimType_Punch_Heavy, ONcAnimationImpact_Land}, {ONcAnimType_Kick_Heavy, ONcAnimationImpact_Land}, {ONcAnimType_Punch_Forward_Heavy, ONcAnimationImpact_Land}, - {ONcAnimType_Kick_Forward_Heavy, ONcAnimationImpact_Land}, + {ONcAnimType_Kick_Forward_Heavy, ONcAnimationImpact_Land}, {ONcAnimType_Run_Kick, ONcAnimationImpact_Land}, {ONcAnimType_Run_Punch, ONcAnimationImpact_Land}, {ONcAnimType_Run_Back_Punch, ONcAnimationImpact_Land}, {ONcAnimType_Run_Back_Kick, ONcAnimationImpact_Land}, - {ONcAnimType_Sidestep_Left_Kick, ONcAnimationImpact_Land}, + {ONcAnimType_Sidestep_Left_Kick, ONcAnimationImpact_Land}, {ONcAnimType_Sidestep_Left_Punch, ONcAnimationImpact_Land}, {ONcAnimType_Sidestep_Right_Kick, ONcAnimationImpact_Land}, {ONcAnimType_Sidestep_Right_Punch, ONcAnimationImpact_Land}, @@ -15991,8 +15991,8 @@ void ONrCharacter_PlayAnimationImpact(ONtCharacter *ioCharacter, ONtActiveCharac sprintf(msgbuf, "%s(%s) %s%d", TMrInstance_GetInstanceName(ioActiveCharacter->animation), ONrAnimTypeToString(ioActiveCharacter->curAnimType), (inFootstep == TRcFootstep_None) ? "" : - (inFootstep == TRcFootstep_Left) ? "L" : - (inFootstep == TRcFootstep_Right) ? "R" : + (inFootstep == TRcFootstep_Left) ? "L" : + (inFootstep == TRcFootstep_Right) ? "R" : (inFootstep == TRcFootstep_Single) ? "S" : "?", ioActiveCharacter->animFrame); anim_impact_type = ONrCharacter_GetAnimationImpactType(ioActiveCharacter->curAnimType); @@ -16026,7 +16026,7 @@ void ONrCharacter_PlayAnimationImpact(ONtCharacter *ioCharacter, ONtActiveCharac } } COrConsole_Printf("%s: anim_impact_type %s -> impact %s (floor %s)", msgbuf, - (impact_type->name == NULL) ? "" : impact_type->name, MArImpactType_GetName(impact->impact_type), + (impact_type->name == NULL) ? "" : impact_type->name, MArImpactType_GetName(impact->impact_type), MArMaterialType_GetName(material_type)); } @@ -16084,7 +16084,7 @@ UUtError ONrCharacter_MakeInactive(ONtCharacter *ioCharacter) active_index = ONrCharacter_GetActiveIndex(ioCharacter); UUmAssert((active_index >= 0) && (active_index < ONgGameState->usedActiveCharacters)); activeCharacter = ONgGameState->activeCharacterStorage + active_index; - + UUmAssert(activeCharacter->active_index == ioCharacter->active_index); if (activeCharacter->index == ioCharacter->index) { ONrGameState_DeleteActiveCharacter(activeCharacter, UUcTrue); @@ -16137,17 +16137,17 @@ void ONrCharacter_MinorHitReaction(ONtCharacter *ioCharacter) hit_overlay = TRrCollection_Lookup( - ioCharacter->characterClass->animations, - hit_overlay_anim_type, - ONcAnimState_Anything, + ioCharacter->characterClass->animations, + hit_overlay_anim_type, + ONcAnimState_Anything, active_character->animVarient); if (NULL == hit_overlay) { hit_overlay = TRrCollection_Lookup( - ioCharacter->characterClass->animations, - ONcAnimType_Hit_Overlay, - ONcAnimState_Anything, + ioCharacter->characterClass->animations, + ONcAnimType_Hit_Overlay, + ONcAnimState_Anything, active_character->animVarient); } @@ -16191,7 +16191,7 @@ const TRtAnimation *ONrCharacter_TryImmediateAnimation(ONtCharacter *ioCharacter M3tMatrix4x3 *ONrCharacter_GetMatrix(ONtCharacter *inCharacter, UUtUns32 inIndex) { ONtActiveCharacter *active_character = ONrGetActiveCharacter(inCharacter); - + if (active_character == NULL) { return NULL; } else { @@ -16229,7 +16229,7 @@ void ONrCharacter_ForceStand(ONtCharacter *inCharacter) UUtBool ONrActiveCharacter_IsPlayingThisAnimationName(ONtActiveCharacter *inActiveCharacter, const char *inDesiredAnimationName) { UUtBool is_playing_the_animation = UUcFalse; - + if (NULL != inActiveCharacter) { const char *animation_instance_name; @@ -16320,7 +16320,7 @@ UUtBool ONrCharacter_Collide_Ray(ONtCharacter *inCharacter, M3tPoint3D *inPoint, bbox.maxPoint.x += ONgCharacterCollision_Grow; bbox.maxPoint.y += ONgCharacterCollision_Grow; bbox.maxPoint.z += ONgCharacterCollision_Grow; - + if ((bbox.minPoint.x >= bbox.maxPoint.x) || (bbox.minPoint.y >= bbox.maxPoint.y) || (bbox.minPoint.z >= bbox.maxPoint.z)) { @@ -16552,7 +16552,7 @@ void ONrGameState_NotifyCameraCut(void) for(itr = 0; itr < count; itr++) { ONtActiveCharacter *active_character = ONrGetActiveCharacter(characters[itr]); - + if (NULL != active_character) { active_character->curBody = TRcBody_NotDrawn; } @@ -16612,7 +16612,7 @@ void ONrGameState_DisplayAiming(void) M3rDraw_State_SetInt(M3cDrawStateIntType_Fog, M3cDrawStateFogDisable); M3rGeom_State_Commit(); - + WPrDrawSprite(sprite, &ONgLaserStop, scale_mode); M3rGeom_State_Pop(); @@ -16740,7 +16740,7 @@ static void ONiCharacter_PainUpdate(ONtCharacter *ioCharacter) { ONtPainConstants *pain_constants = &ioCharacter->characterClass->painConstants; UUtUns32 current_time = ONrGameState_GetGameTime(); - + if (ioCharacter->painState.decay_timer > 0) { ioCharacter->painState.decay_timer--; @@ -16792,7 +16792,7 @@ static void ONiCharacter_QueueHurtSound(ONtCharacter *ioCharacter, UUtUns32 inHu } ioCharacter->painState.queue_timer = ONcPain_DelayFrames; - ioCharacter->painState.queue_type = inHurtType; + ioCharacter->painState.queue_type = inHurtType; ioCharacter->painState.queue_volume = inVolume; } @@ -16885,7 +16885,7 @@ void ONrCharacter_Pain(ONtCharacter *ioCharacter, UUtUns32 inDamage, UUtUns32 in // play the sound ONiCharacter_QueueHurtSound(ioCharacter, pain_type, volume); -/* COrConsole_Printf(" done %s, now %d / %d, timer frames %d", +/* COrConsole_Printf(" done %s, now %d / %d, timer frames %d", ONcPainTypeName[ioCharacter->painState.last_sound_type], ioCharacter->painState.num_light, ioCharacter->painState.num_medium, ioCharacter->painState.last_sound_time + pain_constants->hurt_min_timer - current_time);*/ } @@ -16939,7 +16939,7 @@ UUtError ONrCharacterClass_ProcHandler(TMtTemplateProc_Message inMessage, void * void *inPrivateData) { ONtCharacterClass *character_class = (ONtCharacterClass *) inInstancePtr; - + // handle the message switch (inMessage) { @@ -16950,7 +16950,7 @@ UUtError ONrCharacterClass_ProcHandler(TMtTemplateProc_Message inMessage, void * } break; } - + return UUcError_None; } @@ -17042,7 +17042,7 @@ static void ONrCharacter_VerifyExtraBody(ONtCharacter *ioCharacter, ONtActiveCha if (character_has_weapon_in_hand && !character_has_extra_body) { COrConsole_Printf("character has a weapon but no extra body"); - ioActiveCharacter->extraBody->parts[0].geometry = WPrGetClass(ioCharacter->inventory.weapons[0])->geometry; + ioActiveCharacter->extraBody->parts[0].geometry = WPrGetClass(ioCharacter->inventory.weapons[0])->geometry; } else if (!character_has_weapon_in_hand && character_has_extra_body) { COrConsole_Printf("character has no weapon but does have extra body"); @@ -17133,7 +17133,7 @@ static void ONrCharacter_SetMovementThisFrame(ONtCharacter *inCharacter, ONtActi inActiveCharacter->movementThisFrame.x = inVector->x; inActiveCharacter->movementThisFrame.z = inVector->z; - + if (inVector->y < 0.f) { inActiveCharacter->movementThisFrame.y = 0.f; inActiveCharacter->gravityThisFrame = inVector->y; diff --git a/OniProj/OniGameSource/Oni_Character.h b/OniProj/OniGameSource/Oni_Character.h index 896d10a..b98b2bd 100644 --- a/OniProj/OniGameSource/Oni_Character.h +++ b/OniProj/OniGameSource/Oni_Character.h @@ -1,13 +1,13 @@ #pragma once /* FILE: Oni_Character.h - + AUTHOR: Michael Evans - + CREATED: January 8, 1998 - + PURPOSE: control of characters in ONI - + Copyright 1998, 1999 */ @@ -52,10 +52,10 @@ enum { ONcRArm1_Index = 16, // 0x10000 ONcRArm2_Index = 17, // 0x20000 ONcRHand_Index = 18, // 0x40000 - - ONcWeapon_Index = 19, - ONcMuzzle_Index = 20 - + + ONcWeapon_Index = 19, + ONcMuzzle_Index = 20 + }; #define ONcCharacter_InactiveFrames 90 @@ -228,7 +228,7 @@ ONtCharacterVariant tm_templateref parent; // pointer to parent at runtime char name[32]; // must match ONcMaxVariantNameLength above char upgrade_name[32]; - + } ONtCharacterVariant; #define ONcTemplate_VariantList UUm4CharToUns32('O', 'N', 'V', 'L') @@ -238,7 +238,7 @@ ONtVariantList tm_pad pad[20]; tm_varindex UUtUns32 numVariants; tm_vararray ONtCharacterVariant *variant[1]; - + } ONtVariantList; /* @@ -270,7 +270,7 @@ ONtCharacterParticleArray tm_pad pad2[3]; tm_varindex UUtUns32 numParticles; tm_vararray ONtCharacterParticle particle[1]; - + } ONtCharacterParticleArray; /* @@ -300,7 +300,7 @@ ONtCharacterImpactArray tm_pad pad2[3]; tm_varindex UUtUns32 numImpacts; tm_vararray ONtCharacterAttackImpact impact[1]; - + } ONtCharacterImpactArray; #define ONcAnimationImpact_None ((UUtUns16) -1) @@ -359,7 +359,7 @@ ONtBodyPartImpacts MAtImpact *hit_impacts[19]; // must match ONcNumCharacterParts MAtImpact *blocked_impacts[19]; // must match ONcNumCharacterParts MAtImpact *killed_impacts[19]; // must match ONcNumCharacterParts - + } ONtBodyPartImpacts; /* @@ -470,7 +470,7 @@ ONtCharacterClass // variant could pick comguy_1, comguy_2 or comguy_3 because they all have the same variant // tag of "comguy". ONtCharacterVariant *variant; - + ONtCharacterParticleArray *particles; ONtCharacterImpactArray *impacts; // attack impacts ONtCharacterAnimationImpacts anim_impacts; // animation impacts (footsteps, landing, etc) @@ -496,7 +496,7 @@ ONtCharacterClass TRtAnimationCollection *animations; TRtScreenCollection *aimingScreens; - + UUtUns16 shottime; // AI ROF UUtUns16 death_deletedelay; // frames after death to delete character UUtBool leftHanded; @@ -517,12 +517,12 @@ typedef enum { ONcCharacterFlag_Unkillable = 0x00000020, // the character cannot be killed, only defeated ONcCharacterFlag_InfiniteAmmo = 0x00000040, // the character always has infinite ammo ONcCharacterFlag_PleaseBlock = 0x00000080, // set if the character should block, cleared once block begins - + ONcCharacterFlag_Unstoppable = 0x00000100, // this character cannot be knocked down, staggered, stunned, etc ONcCharacterFlag_ScriptControl = 0x00000200, // set if the character is completely under script control ONcCharacterFlag_DeathLock = 0x00000400, // this character should never die all the way ONcCharacterFlag_WasUpdated = 0x00000800, // this character's animation was changed - + ONcCharacterFlag_BeingThrown = 0x00001000, // this character is being thrown ONcCharacterFlag_DontUseGunVarient = 0x00002000, // this character should not use a weapon varient ONcCharacterFlag_Draw = 0x00004000, // DoFrame has been executed for this character @@ -538,7 +538,7 @@ typedef enum { ONcCharacterFlag_AIMovement = 0x00400000, // the character is using AI movement ONcCharacterFlag_NeutralUninterruptable = 0x00800000, // running an uninterruptable neutral interaction - ONcCharacterFlag_NoShadow = 0x01000000, // + ONcCharacterFlag_NoShadow = 0x01000000, // ONcCharacterFlag_Invincible = 0x02000000, // character is invincible ONcCharacterFlag_NoAutoDrop = 0x04000000, // character should not automatically drop items when killed (invisibility, shield, LSI) ONcCharacterFlag_RestrictedMovement = 0x08000000, // character cannot move fast (used for player holding barabbas' gun) @@ -612,7 +612,7 @@ typedef struct ONtHitTable } ONtHitTable; -enum +enum { ONcOverlayIndex_Recoil, ONcOverlayIndex_InventoryManagement, @@ -676,11 +676,11 @@ typedef struct ONtPainState struct ONtCharacter { - ONtCharacterIndexType index; // index in ONgGameState->characters list + ONtCharacterIndexType index; // index in ONgGameState->characters list ONtCharacterIndexType active_index; // index in ONgGameState->activeCharacters or ONcCharacterIndex_None // general properties - UUtUns32 flags; + UUtUns32 flags; UUtUns32 flags2; ONtCharacterClass * characterClass; UUtUns16 characterClassNumber; @@ -754,14 +754,14 @@ struct ONtCharacter }; struct ONtActiveCharacter { - ONtCharacterIndexType index; // parent's index in ONgGameState->characters list... may be - ONtCharacterIndexType active_index; // index in ONgGameState->activeCharacters list + ONtCharacterIndexType index; // parent's index in ONgGameState->characters list... may be + ONtCharacterIndexType active_index; // index in ONgGameState->activeCharacters list /* * physics, collision, movement */ - PHtPhysicsContext * physics; + PHtPhysicsContext * physics; PHtSphereTree sphereTree[1]; PHtSphereTree leafNodes[ONcSubSphereCount]; PHtSphereTree midNodes[ONcSubSphereCount_Mid]; @@ -772,7 +772,7 @@ struct ONtActiveCharacter { UUtBool collidingWithTarget; UUtUns8 pad0; - M3tVector3D knockback; + M3tVector3D knockback; M3tVector3D movementThisFrame; float gravityThisFrame; M3tVector3D lastImpact; // used for weapon and powerup dropping @@ -783,7 +783,7 @@ struct ONtActiveCharacter { UUtUns32 pickup_percentage; UUtInt32 last_floor_gq; // gq index or -1 float deferred_maximum_height; - + M3tBoundingSphere boundingSphere; M3tPoint3D trigger_points[2]; M3tBoundingSphere trigger_sphere; @@ -821,7 +821,7 @@ struct ONtActiveCharacter { ONtStitchControl stitch; ONtOverlay overlay[ONcOverlayIndex_Count]; - + // timers UUtUns16 animFrame; UUtUns16 softPauseFrames; @@ -859,7 +859,7 @@ struct ONtActiveCharacter { UUtUns16 thrownBy; // character index of who I am being thrown by ONtCharacter * throwTarget; const TRtAnimation * targetThrow; - + // aiming screens const TRtAimingScreen * aimingScreen; UUtUns32 oldAimingScreenTime; @@ -883,8 +883,8 @@ struct ONtActiveCharacter { // aiming UUtBool isAiming; M3tPoint3D aimingTarget; - M3tVector3D aimingVector; - M3tVector3D cameraVector; + M3tVector3D aimingVector; + M3tVector3D cameraVector; float aimingLR; float aimingUD; float aimingVectorLR; @@ -892,7 +892,7 @@ struct ONtActiveCharacter { float autoAimAdjustmentLR; float autoAimAdjustmentUD; UUtBool oldExactAiming; - UUtUns32 oldExactAimingTime; + UUtUns32 oldExactAimingTime; // action flags UUtBool pleaseJump; @@ -910,7 +910,7 @@ struct ONtActiveCharacter { // script control LItButtonBits keyHoldMask; - UUtUns16 keyHoldFrames; + UUtUns16 keyHoldFrames; ONtFilmState filmState; @@ -1013,7 +1013,7 @@ UUtUns16 ONrCharacter_ForcedFollowingAnimType(ONtCharacter *ioCharacter, UUtUns1 void ONrCharacter_NextAnimation(ONtCharacter *ioCharacter, ONtActiveCharacter *ioActiveCharacter); // -// === facing === +// === facing === // // @@ -1028,7 +1028,7 @@ void ONrCharacter_SetDesiredFacing(ONtCharacter *ioCharacter, float inFacing); void ONrCharacter_AdjustFacing(ONtCharacter *ioCharacter, float inFacingDelta); void ONrCharacter_AdjustDesiredFacing(ONtCharacter *ioCharacter, float inFacingDelta); -// +// // gets the difference (in signed angle format) to add to reality to get the desire // // range is -2 Pi to + 2Pi and the direction around the circle we pick is the direction @@ -1085,7 +1085,7 @@ ONrGameState_NewActiveCharacter( void ONrGameState_DeleteCharacter( ONtCharacter *inCharacter); - + void ONrGameState_DeleteActiveCharacter( ONtActiveCharacter *ioActiveCharacter, @@ -1195,7 +1195,7 @@ void ONrCharacter_ReleaseAlternateTrigger(ONtCharacter *ioCharacter, ONtActiveCh void ONrCharacters_Collision( UUtUns16 inIgnoreCharacterIndex, const M3tVector3D *inVector, - const M3tMatrix4x3 *inGeometryMatrix, + const M3tMatrix4x3 *inGeometryMatrix, const M3tGeometry *inGeometry, ONtCharacter **outCharacterPtr, UUtUns16 *outPartIndex); @@ -1213,7 +1213,7 @@ void ONrCharacter_Teleport_With_Collision(ONtCharacter *ioCharacter, M3tPoint3D void ONrCharacter_FindOurNode(ONtCharacter *inCharacter); UUtBool ONrCharacter_LineOfSight(ONtCharacter *inLooker, ONtCharacter *inLookee); -typedef enum +typedef enum { ONcVision_UseVisionCone, ONcVision_Look360 @@ -1242,7 +1242,7 @@ void ONrDrawSphere( M3tTextureMap *inTexture, float inScale, M3tPoint3D *inLocation); - + void ONrCharacter_DoAiming(ONtCharacter *ioCharacter, ONtActiveCharacter *ioActiveCharacter); UUtBool ONiPointInSphere(const M3tPoint3D *inPoint, const M3tBoundingSphere *inSphere); UUtBool ONrAnimation_IsFlying(const TRtAnimation *inAnimation); @@ -1268,7 +1268,7 @@ void ONrCharacter_SetHitPoints( ONtCharacter *ioCharacter, UUtUns32 inHitPoints); - + void ONrCharacter_Spawn( ONtCharacter *ioCharacter); @@ -1339,7 +1339,7 @@ void ONrCharacter_PickupWeapon( void ONrCharacter_PickupPowerup( ONtCharacter *inCharacter, WPtPowerup *inPowerup); - + float ONrCharacter_GetTorsoHeight(const ONtCharacter *inCharacter); float ONrCharacter_GetHeadHeight(const ONtCharacter *inCharacter); diff --git a/OniProj/OniGameSource/Oni_Character_Animation.h b/OniProj/OniGameSource/Oni_Character_Animation.h index 0ae6699..f44821d 100644 --- a/OniProj/OniGameSource/Oni_Character_Animation.h +++ b/OniProj/OniGameSource/Oni_Character_Animation.h @@ -4,13 +4,13 @@ /* FILE: Oni_Character_Animation.h - + AUTHOR: Michael Evans - + CREATED: January 8, 1998 - + PURPOSE: animation types for oni - + Copyright 1998 - 1999 */ @@ -28,7 +28,7 @@ enum ONcAnimType_Slide, ONcAnimType_Jump, // 5 - ONcAnimType_Stand, + ONcAnimType_Stand, ONcAnimType_Standing_Turn_Left, ONcAnimType_Standing_Turn_Right, ONcAnimType_Run_Backwards, @@ -44,13 +44,13 @@ enum ONcAnimType_Crouch, ONcAnimType_Jump_Forward, ONcAnimType_Jump_Backward, - + ONcAnimType_Jump_Left, // 20 ONcAnimType_Jump_Right, ONcAnimType_Punch, ONcAnimType_Block, ONcAnimType_Land, - + ONcAnimType_Fly, // 25 ONcAnimType_Kick_Forward, ONcAnimType_Kick_Left, @@ -91,10 +91,10 @@ enum ONcAnimType_Punch_Forward_Heavy, ONcAnimType_Kick_Forward_Heavy, // 55 - ONcAnimType_Aiming_Overlay, - ONcAnimType_Hit_Overlay, + ONcAnimType_Aiming_Overlay, + ONcAnimType_Hit_Overlay, - ONcAnimType_Crouch_Run, + ONcAnimType_Crouch_Run, ONcAnimType_Crouch_Walk, ONcAnimType_Crouch_Run_Backwards, // 60 @@ -108,7 +108,7 @@ enum ONcAnimType_Run_Kick, ONcAnimType_Run_Punch, - + ONcAnimType_Run_Back_Punch, ONcAnimType_Run_Back_Kick, @@ -249,10 +249,10 @@ enum ONcAnimType_PL_PL, ONcAnimType_PL_PL_PL, - + ONcAnimType_PR_PR, ONcAnimType_PR_PR_PR, - + ONcAnimType_PB_PB, ONcAnimType_PB_PB_PB, @@ -264,10 +264,10 @@ enum ONcAnimType_KL_KL, ONcAnimType_KL_KL_KL, - + ONcAnimType_KR_KR, ONcAnimType_KR_KR_KR, - + ONcAnimType_KB_KB, ONcAnimType_KB_KB_KB, @@ -278,10 +278,10 @@ enum ONcAnimType_Startle_Right, ONcAnimType_Startle_Back, ONcAnimType_Startle_Forward, - + ONcAnimType_Console, // use a console ONcAnimType_Console_Walk, // walk up to console - + ONcAnimType_Stagger, ONcAnimType_Watch, @@ -447,9 +447,9 @@ enum // this in greater detail and it doesn't make sense to replicate the same info in // two places. they are read in from the INS file, but then used to set an animation's // moveDirection and zeroed -enum +enum { - ONcAnimFlag_Invulnerable = + ONcAnimFlag_Invulnerable = TRcAnimFlag_FirstPublic, // mask = 0x00000002 ONcAnimFlag_BlockHigh, // mask = 0x00000004 @@ -509,4 +509,4 @@ typedef struct ONtCharacterAnimationImpactType { extern const ONtCharacterAnimationImpactType ONcAnimImpactTypes[]; -#endif // __ONI_CHARACTER_ANIMATION_H__ \ No newline at end of file +#endif // __ONI_CHARACTER_ANIMATION_H__ diff --git a/OniProj/OniGameSource/Oni_Cinematics.c b/OniProj/OniGameSource/Oni_Cinematics.c index 203dd66..e3c0100 100644 --- a/OniProj/OniGameSource/Oni_Cinematics.c +++ b/OniProj/OniGameSource/Oni_Cinematics.c @@ -38,7 +38,7 @@ typedef enum OCtPart OCcPart_TopLeft = (OCcPart_Top | OCcPart_Left), OCcPart_TopCenter = (OCcPart_Top | OCcPart_Col_Center), OCcPart_TopRight = (OCcPart_Top | OCcPart_Right), - + OCcPart_CenterLeft = (OCcPart_Row_Center | OCcPart_Left), OCcPart_CenterCenter = (OCcPart_Row_Center | OCcPart_Col_Center), OCcPart_CenterRight = (OCcPart_Row_Center | OCcPart_Right), @@ -72,17 +72,17 @@ enum typedef struct OCtCinematic { UUtUns32 flags; - + M3tTextureMap *texture; UUtInt16 draw_width; UUtInt16 draw_height; - + M3tPointScreen position; M3tPoint3D delta; UUtUns32 steps; UUtUns8 start; UUtUns8 end; - + } OCtCinematic; typedef enum OCtMod @@ -100,7 +100,7 @@ typedef struct OCtIndexPositions UUtBool add_screen_width; UUtBool add_screen_height; OCtPart part; - + } OCtIndexPositions; // ====================================================================== @@ -114,7 +114,7 @@ static PStPartSpec *OCgBorder; static OCtIndexPositions ONgIndexPositions[26] = { { OCcMod_None, OCcMod_None, UUcFalse, UUcFalse, OCcPart_None }, // 0 - + { OCcMod_Add, OCcMod_Add, UUcFalse, UUcFalse, OCcPart_TopLeft }, // 1 { OCcMod_None, OCcMod_Add, UUcFalse, UUcFalse, OCcPart_TopCenter }, // 2 { OCcMod_Sub, OCcMod_Add, UUcTrue, UUcFalse, OCcPart_TopRight }, // 3 @@ -124,22 +124,22 @@ static OCtIndexPositions ONgIndexPositions[26] = { OCcMod_Add, OCcMod_Sub, UUcFalse, UUcTrue, OCcPart_BottomLeft }, // 7 { OCcMod_None, OCcMod_Sub, UUcFalse, UUcTrue, OCcPart_BottomCenter }, // 8 { OCcMod_Sub, OCcMod_Sub, UUcTrue, UUcTrue, OCcPart_BottomRight }, // 9 - + { OCcMod_Sub, OCcMod_Sub, UUcFalse, UUcFalse, OCcPart_BottomRight }, // 10 { OCcMod_Add, OCcMod_Sub, UUcFalse, UUcFalse, OCcPart_BottomLeft }, // 11 { OCcMod_None, OCcMod_Sub, UUcFalse, UUcFalse, OCcPart_BottomCenter }, // 12 { OCcMod_Sub, OCcMod_Sub, UUcTrue, UUcFalse, OCcPart_BottomRight }, // 13 { OCcMod_Add, OCcMod_Sub, UUcTrue, UUcFalse, OCcPart_BottomLeft }, // 14 - + { OCcMod_Sub, OCcMod_Add, UUcFalse, UUcFalse, OCcPart_TopRight }, // 15 { OCcMod_Add, OCcMod_Add, UUcTrue, UUcFalse, OCcPart_TopLeft }, // 16 - + { OCcMod_Sub, OCcMod_None, UUcFalse, UUcFalse, OCcPart_CenterRight }, // 17 { OCcMod_Add, OCcMod_None, UUcTrue, UUcFalse, OCcPart_CenterLeft }, // 18 - + { OCcMod_Sub, OCcMod_Sub, UUcFalse, UUcTrue, OCcPart_BottomRight }, // 19 { OCcMod_Add, OCcMod_Sub, UUcTrue, UUcTrue, OCcPart_BottomLeft }, // 20 - + { OCcMod_Sub, OCcMod_Add, UUcFalse, UUcTrue, OCcPart_TopRight }, // 21 { OCcMod_Add, OCcMod_Add, UUcFalse, UUcTrue, OCcPart_TopLeft }, // 22 { OCcMod_None, OCcMod_Add, UUcFalse, UUcTrue, OCcPart_TopCenter }, // 23 @@ -173,7 +173,7 @@ OCiGetIndexPosition( outPosition->x = -ONgXOffset; break; } - + switch (ONgIndexPositions[inIndex].y_mod) { case OCcMod_None: @@ -190,7 +190,7 @@ OCiGetIndexPosition( } outPosition->z = 0.0f; - + // move to the right or bottom of the screen if necessary if (ONgIndexPositions[inIndex].add_screen_width) { @@ -217,33 +217,33 @@ OCiCinematic_CalcPositionFromIndex( { // get the position of inIndex OCiGetIndexPosition(inIndex, outPosition); - + // offset the position based on the part to set the position to switch (ONgIndexPositions[inIndex].part & (OCcPart_Top | OCcPart_Row_Center | OCcPart_Bottom)) { case OCcPart_Top: break; - + case OCcPart_Row_Center: outPosition->y = (float)(OCcCinematic_Height - ioCinematic->draw_height) / 2.0f; break; - + case OCcPart_Bottom: outPosition->y -= (float)ioCinematic->draw_height; break; } - + switch (ONgIndexPositions[inIndex].part & (OCcPart_Left | OCcPart_Col_Center | OCcPart_Right)) { case OCcPart_Left: break; - + case OCcPart_Col_Center: outPosition->x = (float)(OCcCinematic_Width - ioCinematic->draw_width) / 2.0f; break; - + case OCcPart_Right: outPosition->x -= (float)ioCinematic->draw_width; break; @@ -262,7 +262,7 @@ OCiCinematic_Draw( UUtInt32 draw_width; UUtInt32 draw_height; - + // set UVs if (inCinematic->flags & OCcCinematicFlag_Mirror) { @@ -273,7 +273,7 @@ OCiCinematic_Draw( // tr uv[1].u = 0.0f; uv[1].v = 0.0f; - + // bl uv[2].u = 1.0f; uv[2].v = 1.0f; @@ -287,11 +287,11 @@ OCiCinematic_Draw( // tl uv[0].u = 0.0f; uv[0].v = 0.0f; - + // tr uv[1].u = 1.0f; uv[1].v = 0.0f; - + // bl uv[2].u = 0.0f; uv[2].v = 1.0f; @@ -300,11 +300,11 @@ OCiCinematic_Draw( uv[3].u = 1.0f; uv[3].v = 1.0f; } - + // set the dest dest[0] = inCinematic->position; dest[1] = inCinematic->position; - + dest[1].x += (float)inCinematic->draw_width; dest[1].y += (float)inCinematic->draw_height; @@ -315,45 +315,45 @@ OCiCinematic_Draw( draw_width = MUrFloat_Round_To_Int(dest[1].x - dest[0].x); draw_height = MUrFloat_Round_To_Int(dest[1].y - dest[0].y); - + M3rDraw_State_Push(); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Appearence, M3cDrawState_Appearence_Texture_Unlit); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Fill, M3cDrawState_Fill_Solid); - + M3rDraw_State_SetInt( M3cDrawStateIntType_ConstantColor, IMcShade_White); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Alpha, M3cMaxAlpha); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, inCinematic->texture); - + M3rDraw_State_Commit(); - + M3rDraw_Sprite( dest, uv); - + M3rDraw_State_Pop(); // draw the border dest[0].x -= 3.0f; dest[0].y -= 3.0f; - + // get a pointer to the border if one doesn't already exist if (OCgBorder == NULL) { @@ -362,7 +362,7 @@ OCiCinematic_Draw( "cinematic_border", &OCgBorder); } - + PSrPartSpec_Draw( OCgBorder, PScPart_All, @@ -391,11 +391,11 @@ OCrCinematic_Draw( if (ONrGameState_IsSkippingCutscene()) { return; } - + // get a pointer to the cinematics array cinematics = (OCtCinematic*)UUrMemory_Array_GetMemory(ONgCinematics); if (cinematics == NULL) { return; } - + // draw the cinematics num_cinematics = UUrMemory_Array_GetUsedElems(ONgCinematics); for (i = 0; i < num_cinematics; i++) @@ -423,7 +423,7 @@ OCrCinematic_Start( M3tPoint3D start; M3tPoint3D end; - + // make sure the parameters are valid if ((inTextureName == NULL) || (inTextureName[0] == '\0')) { return; } if (inStart > OCcNumStartPositions) { return; } @@ -433,21 +433,21 @@ OCrCinematic_Start( { return; } - + // find the texture error = TMrInstance_GetDataPtr(M3cTemplate_TextureMap, inTextureName, &texture); if (error != UUcError_None) { return; } - + if (inDrawWidth == -1) { inDrawWidth = texture->width; } if (inDrawHeight == -1) { inDrawHeight = texture->height; } - + // add the cinematic to the array error = UUrMemory_Array_GetNewElement(ONgCinematics, &index, &mem_moved); if (error != UUcError_None) { return; } - + cinematics = UUrMemory_Array_GetMemory(ONgCinematics); if (cinematics == NULL) { return; } - + // initialize the cinematic cinematics[index].flags = inMirror ? OCcCinematicFlag_Mirror : OCcCinematicFlag_None; cinematics[index].texture = texture; @@ -460,7 +460,7 @@ OCrCinematic_Start( cinematics[index].steps = 0; cinematics[index].start = inStart; cinematics[index].end = inEnd; - + // set the position based on the start OCiCinematic_CalcPositionFromIndex( &cinematics[index], @@ -468,7 +468,7 @@ OCrCinematic_Start( &start); cinematics[index].position.x = start.x; cinematics[index].position.y = start.y; - + if (inEnd == inStart) { MUmVector_Set(cinematics[index].delta, 0.0f, 0.0f, 0.0f); @@ -476,16 +476,16 @@ OCrCinematic_Start( else { float distance; - + // get the end position OCiCinematic_CalcPositionFromIndex(&cinematics[index], inEnd, &end); - + // calculate the movement delta MUmVector_Subtract(cinematics[index].delta, end, start); distance = MUrVector_Length(&cinematics[index].delta); MUrNormalize(&cinematics[index].delta); MUmVector_Scale(cinematics[index].delta, inVelocity); - + // calculate the number of steps needed to read the end cinematics[index].steps = (UUtUns32)(distance/inVelocity); } @@ -506,11 +506,11 @@ OCrCinematic_Stop( M3tPoint3D end; UUtUns32 i; UUtUns32 index; - + // get a pointer to the cinematics array cinematics = (OCtCinematic*)UUrMemory_Array_GetMemory(ONgCinematics); if (cinematics == NULL) { return; } - + // find the texture error = TMrInstance_GetDataPtr(M3cTemplate_TextureMap, inTextureName, &texture); if (error != UUcError_None) { return; } @@ -526,16 +526,16 @@ OCrCinematic_Stop( } } if (index == OCcInvalidCinematic) { return; } - + // clear out all the flags other than the mirror flag cinematics[index].flags &= OCcCinematicFlag_Mirror; - + // set the needed fields cinematics[index].flags |= OCcCinematicFlag_Stop; cinematics[index].steps = 0; cinematics[index].start = cinematics[index].end; cinematics[index].end = inEnd; - + // set the position based on the start OCiCinematic_CalcPositionFromIndex( &cinematics[index], @@ -543,7 +543,7 @@ OCrCinematic_Stop( &start); cinematics[index].position.x = start.x; cinematics[index].position.y = start.y; - + if (inEnd == cinematics[index].start) { MUmVector_Set(cinematics[index].delta, 0.0f, 0.0f, 0.0f); @@ -551,16 +551,16 @@ OCrCinematic_Stop( else { float distance; - + // get the end position OCiCinematic_CalcPositionFromIndex(&cinematics[index], inEnd, &end); - + // calculate the movement delta MUmVector_Subtract(cinematics[index].delta, end, start); distance = MUrVector_Length(&cinematics[index].delta); MUrNormalize(&cinematics[index].delta); MUmVector_Scale(cinematics[index].delta, inVelocity); - + // calculate the number of steps needed to read the end cinematics[index].steps = (UUtUns32)(distance/inVelocity); } @@ -583,14 +583,14 @@ OCrCinematic_Update( OCtCinematic *cinematics; UUtUns32 num_cinematics; UUtInt32 i; - + // make sure there are cinematics to draw num_cinematics = UUrMemory_Array_GetUsedElems(ONgCinematics); if (num_cinematics == 0) { return; } - + // get a pointer to the cinematics array cinematics = (OCtCinematic*)UUrMemory_Array_GetMemory(ONgCinematics); - + // update the cinematics for (i = 0; i < (UUtInt32)num_cinematics; i++) { @@ -604,7 +604,7 @@ OCrCinematic_Update( else if ((cinematics[i].flags & OCcCinematicFlag_AtEnd) == 0) { M3tPoint3D position; - + // put the cinematic exactly at the desired position OCiCinematic_CalcPositionFromIndex( &cinematics[i], @@ -612,9 +612,9 @@ OCrCinematic_Update( &position); cinematics[i].position.x = position.x; cinematics[i].position.y = position.y; - + cinematics[i].flags |= OCcCinematicFlag_AtEnd; - + // if stopping delete the element if ((cinematics[i].flags & OCcCinematicFlag_Stop) != 0) { @@ -622,7 +622,7 @@ OCrCinematic_Update( } } } - + // delete the cinematics that are marked for deletion for (i = (UUtInt32)(UUrMemory_Array_GetUsedElems(ONgCinematics)) - 1; i >= 0; i--) { @@ -630,7 +630,7 @@ OCrCinematic_Update( { // delete the element UUrMemory_Array_DeleteElement(ONgCinematics, (UUtUns32)i); - + // the delete element call may have moved the array cinematics = (OCtCinematic*)UUrMemory_Array_GetMemory(ONgCinematics); } @@ -661,7 +661,7 @@ OCiCinematic_ScriptStart( if (inParameterList[4].type != SLcType_Int32) { return UUcError_Generic; } if (inParameterList[5].type != SLcType_Float) { return UUcError_Generic; } if (inParameterList[6].type != SLcType_Bool) { return UUcError_Generic; } - + OCrCinematic_Start( (char*)inParameterList[0].val.str, (UUtInt16)inParameterList[1].val.i, @@ -670,10 +670,10 @@ OCiCinematic_ScriptStart( (UUtUns8)inParameterList[4].val.i, (float)inParameterList[5].val.f, (UUtBool)inParameterList[6].val.b); - + *outTicksTillCompletion = 0; *outStall = UUcFalse; - + return UUcError_None; } @@ -691,15 +691,15 @@ OCiCinematic_ScriptStop( if (inParameterList[0].type != SLcType_String) { return UUcError_Generic; } if (inParameterList[1].type != SLcType_Int32) { return UUcError_Generic; } if (inParameterList[2].type != SLcType_Float) { return UUcError_Generic; } - + OCrCinematic_Stop( (char*)inParameterList[0].val.str, (UUtUns8)inParameterList[1].val.i, (float)inParameterList[2].val.f); - + *outTicksTillCompletion = 0; *outStall = UUcFalse; - + return UUcError_None; } @@ -714,11 +714,11 @@ OCrInitialize( void) { UUtError error; - + ONgCinematicRef = 0; ONgXOffset = 20.0f; ONgYOffset = 65.0f; - + // allocate memory for the cinematics array ONgCinematics = UUrMemory_Array_New( @@ -744,7 +744,7 @@ OCrInitialize( &ONgYOffset); UUmError_ReturnOnError(error); #endif - + // register the script commands error = SLrScript_Command_Register_Void( @@ -753,7 +753,7 @@ OCrInitialize( "bitmap_name:string draw_width:int draw_height:int start:int end:int velocity:float mirror:bool", OCiCinematic_ScriptStart); UUmError_ReturnOnError(error); - + error = SLrScript_Command_Register_Void( "cinematic_stop", @@ -775,4 +775,4 @@ OCrTerminate( UUrMemory_Array_Delete(ONgCinematics); ONgCinematics = NULL; } -} \ No newline at end of file +} diff --git a/OniProj/OniGameSource/Oni_Cinematics.h b/OniProj/OniGameSource/Oni_Cinematics.h index 55b1e17..83b93b0 100644 --- a/OniProj/OniGameSource/Oni_Cinematics.h +++ b/OniProj/OniGameSource/Oni_Cinematics.h @@ -22,7 +22,7 @@ void OCrCinematic_Draw( void); - + void OCrCinematic_Start( char *inTextureName, @@ -32,7 +32,7 @@ OCrCinematic_Start( UUtUns8 inEnd, float inVelocity, UUtBool inMirror); - + void OCrCinematic_Stop( char *inTextureName, @@ -46,7 +46,7 @@ OCrCinematic_DeleteAll( void OCrCinematic_Update( void); - + // ---------------------------------------------------------------------- UUtError OCrInitialize( @@ -55,6 +55,6 @@ OCrInitialize( void OCrTerminate( void); - + // ====================================================================== -#endif /* ONI_CINEMATICS_H */ \ No newline at end of file +#endif /* ONI_CINEMATICS_H */ diff --git a/OniProj/OniGameSource/Oni_Combos.c b/OniProj/OniGameSource/Oni_Combos.c index acfb51f..6caf687 100644 --- a/OniProj/OniGameSource/Oni_Combos.c +++ b/OniProj/OniGameSource/Oni_Combos.c @@ -25,7 +25,7 @@ ONtMoveLookup ONgComboTable[] = { // 1 down mask w/ 1 moves combo getup moves { LIc_BitMask_Kick, LIc_BitMask_Backward, ONcAnimType_None, ONcAnimType_Getup_Kick_Back, UUcTrue }, - + // 1 down mask w/ 1 moves combo { LIc_BitMask_Punch, LIc_BitMask_Forward, ONcAnimType_None, ONcAnimType_Punch_Forward, UUcTrue }, { LIc_BitMask_Punch, LIc_BitMask_StepLeft, ONcAnimType_None, ONcAnimType_Punch_Left, UUcTrue }, diff --git a/OniProj/OniGameSource/Oni_DataConsole.c b/OniProj/OniGameSource/Oni_DataConsole.c index 6471314..82cd99d 100644 --- a/OniProj/OniGameSource/Oni_DataConsole.c +++ b/OniProj/OniGameSource/Oni_DataConsole.c @@ -1,11 +1,11 @@ /* FILE: Oni_DataConsole.c - + AUTHOR: Quinn Dunki - + CREATED: April 2, 1999 - + PURPOSE: control of interactive consoles in ONI - + Copyright 1998 */ @@ -94,7 +94,7 @@ void ONrDataConsole_Notify_Trigger( console = ONiDataConsoleFromTrigger(inTrigger); UUmAssert(console); - + if (inActivated) ONrDataConsole_Activate(console,inCharacter); else ONrDataConsole_Deactivate(console,inCharacter); } @@ -131,7 +131,7 @@ void ONrDataConsole_Activate( door = ONgGameState->doors.doors + i; if (door->doorClass->openKey != inConsole->idg && door->doorClass->closeKey != inConsole->idg) continue; - + if (door->flags & OBcDoorFlag_Locked) door->flags &=~OBcDoorFlag_Locked; else door->flags |= OBcDoorFlag_Locked; } @@ -192,7 +192,7 @@ void ONrDataConsole_Update( default: break; } - } + } } UUtError ONrDataConsole_LevelBegin( diff --git a/OniProj/OniGameSource/Oni_DataConsole.h b/OniProj/OniGameSource/Oni_DataConsole.h index 4a5ccfa..a76b78f 100644 --- a/OniProj/OniGameSource/Oni_DataConsole.h +++ b/OniProj/OniGameSource/Oni_DataConsole.h @@ -1,13 +1,13 @@ #pragma once /* FILE: Oni_DataConsole.h - + AUTHOR: Quinn Dunki - + CREATED: April 2 1999 - + PURPOSE: control of interactive consoles in ONI - + Copyright 1998 */ @@ -32,7 +32,7 @@ typedef struct ONtDataConsole ONtCharacter *owner; // Who is currently using us // Multipurpose data: - UUtUns16 timer; + UUtUns16 timer; UUtUns16 idl,idg; void *pointer; } ONtDataConsole; diff --git a/OniProj/OniGameSource/Oni_Dialogs.c b/OniProj/OniGameSource/Oni_Dialogs.c index 5cacec5..3097402 100644 --- a/OniProj/OniGameSource/Oni_Dialogs.c +++ b/OniProj/OniGameSource/Oni_Dialogs.c @@ -44,7 +44,7 @@ typedef struct ONtMP_PlayerInfo char host_address[ONcMaxHostAddressLength]; char password[ONcMaxPasswordLength]; UUtBool remember_password; - + } ONtMP_PlayerInfo; typedef struct ONtMP_HostInfo @@ -52,14 +52,14 @@ typedef struct ONtMP_HostInfo char host_name[ONcMaxHostNameLength]; UUtUns16 level_number; ONtNetGameOptions game_options; - + } ONtMP_HostInfo; typedef struct ONtNet_ServerArrayInfo { ONtNet_ServerInfo server_info; NMtNetAddress server_address; - + } ONtNet_ServerArrayInfo; // ====================================================================== @@ -92,22 +92,22 @@ ONiLevelList_Initialize( { UUtError error; UUtUns16 num_descriptors; - + // get the number of descriptors num_descriptors = (UUtUns16)TMrInstance_GetTagCount(ONcTemplate_Level_Descriptor); if (num_descriptors > 0) { UUtUns16 i; VMtView *levels; - + // get a pointer to the level list levels = DMrDialog_GetViewByID(inDialog, view_id); if (levels == NULL) return; - + for (i = 0; i < num_descriptors; i++) { ONtLevel_Descriptor *descriptor; - + // get a pointer to the first descriptor error = TMrInstance_GetDataPtr_ByNumber( @@ -115,11 +115,11 @@ ONiLevelList_Initialize( i, &descriptor); if (error != UUcError_None) return; - + // if the level in the descriptor doesn't exist, move on // to the next descriptor if (!TMrLevel_Exists(descriptor->level_number)) continue; - + // add the name of the level to the list VMrView_SendMessage( levels, @@ -127,7 +127,7 @@ ONiLevelList_Initialize( 0, (UUtUns32)descriptor->level_name); } - + // set the selection to the first entry VMrView_SendMessage( levels, @@ -145,10 +145,10 @@ ONiLevelList_GetLevelNumber( { UUtUns16 num_descriptors; UUtUns16 level_number; - + // set the level number to the default level_number = (UUtUns16)(-1); - + // get the number of descriptors num_descriptors = (UUtUns16)TMrInstance_GetTagCount(ONcTemplate_Level_Descriptor); if (num_descriptors > 0) @@ -157,18 +157,18 @@ ONiLevelList_GetLevelNumber( VMtView *levels; char level_name[ONcMaxLevelName]; UUtUns16 i; - + // get a pointer to the levels listbox levels = DMrDialog_GetViewByID(inDialog, inViewID); if (levels == NULL) return level_number; - + // get the current selection name VMrView_SendMessage( levels, LBcMessage_GetText, (UUtUns32)(-1), (UUtUns32)(&level_name)); - + // find the level number for (i = 0; i < num_descriptors; i++) { @@ -189,7 +189,7 @@ ONiLevelList_GetLevelNumber( } } } - + return level_number; } @@ -214,7 +214,7 @@ ONiMP_JoinGame( UUrError_Report(error, "Unable to start client"); return UUcFalse; } - + // join the host error = ONrNet_Client_Join( @@ -226,16 +226,16 @@ ONiMP_JoinGame( if (error != UUcError_None) { UUrError_Report(error, "Unable to join host"); - + error = ONrNet_Client_Stop(); if (error != UUcError_None) { UUrError_Report(error, "Unable to stop client"); } - + return UUcFalse; } - + return UUcTrue; } @@ -246,14 +246,14 @@ ONiMP_HostGame( { UUtError error; UUtBool result; - + // make sure that the level number is valid if ((ONgMP_HostInfo.level_number == (UUtUns16)(-1)) || (ONgMP_HostInfo.level_number == 0)) { return UUcFalse; } - + // start a host error = ONrNet_Server_Start( @@ -266,7 +266,7 @@ ONiMP_HostGame( UUrError_Report(error, "Unable to start host"); return UUcFalse; } - + // join the host on this machine result = ONiMP_JoinGame( @@ -276,10 +276,10 @@ ONiMP_HostGame( error = ONrNet_Server_Stop(); if (error != UUcError_None) UUrError_Report(error, "Unable to stop host"); - + return UUcFalse; } - + return UUcTrue; } @@ -305,51 +305,51 @@ ONiMP_RestoreMPInfo( DMtDialog *inDialog) { VMtView *view; - + // ------------------------------ // host tab // ------------------------------ // set the host name view = DMrDialog_GetViewByID(inDialog, ONcMPHG_EF_HostName); VMrView_SetValue(view, (UUtUns32)&ONgMP_HostInfo.host_name); - + // set the number of bots if (ONgMP_HostInfo.game_options.game_parameters & ONcNetGameParam_HasAIs) { char string[32]; - + string[0] = '\0'; - + sprintf(string, "%d", ONgMP_HostInfo.game_options.num_AIs); view = DMrDialog_GetViewByID(inDialog, ONcMPHG_EF_NumBots); VMrView_SetValue(view, (UUtUns32)string); } - + // ------------------------------ // join tab // ------------------------------ // set the host address view = DMrDialog_GetViewByID(inDialog, ONcMPJG_EF_HostAddress); VMrView_SetValue(view, (UUtUns32)&ONgMP_PlayerInfo.host_address); - + // set the password view = DMrDialog_GetViewByID(inDialog, ONcMPJG_EF_Password); VMrView_SetValue(view, (UUtUns32)&ONgMP_PlayerInfo.password); - + // set the remember password checkbox view = DMrDialog_GetViewByID(inDialog, ONcMPJG_CB_RememberPassword); VMrView_SetValue(view, (UUtUns32)ONgMP_PlayerInfo.remember_password); - + // ------------------------------ // options tab // ------------------------------ // set the players name view = DMrDialog_GetViewByID(inDialog, ONcMPO_EF_PlayerName); VMrView_SetValue(view, (UUtUns32)&ONgMP_PlayerInfo.player_name); - + // set the team name view = DMrDialog_GetViewByID(inDialog, ONcMPO_EF_TeamName); - VMrView_SetValue(view, (UUtUns32)&ONgMP_PlayerInfo.team_name); + VMrView_SetValue(view, (UUtUns32)&ONgMP_PlayerInfo.team_name); } // ---------------------------------------------------------------------- @@ -360,7 +360,7 @@ ONiMP_SaveMPInfo( VMtView *view; UUtUns32 value; UUtUns32 num_bots; - + // ------------------------------ // host tab // ------------------------------ @@ -368,7 +368,7 @@ ONiMP_SaveMPInfo( view = DMrDialog_GetViewByID(inDialog, ONcMPHG_EF_HostName); value = VMrView_GetValue(view); UUrString_Copy((char*)ONgMP_HostInfo.host_name, (char*)value, ONcMaxHostNameLength); - + // get the number of bots view = DMrDialog_GetViewByID(inDialog, ONcMPHG_EF_NumBots); value = VMrView_GetValue(view); @@ -378,10 +378,10 @@ ONiMP_SaveMPInfo( ONgMP_HostInfo.game_options.game_parameters |= ONcNetGameParam_HasAIs; ONgMP_HostInfo.game_options.num_AIs = (UUtUns16)num_bots; } - + // get the level number ONgMP_HostInfo.level_number = ONiLevelList_GetLevelNumber(inDialog, ONcMPHG_LB_Level); - + // ------------------------------ // join tab // ------------------------------ @@ -389,16 +389,16 @@ ONiMP_SaveMPInfo( view = DMrDialog_GetViewByID(inDialog, ONcMPJG_EF_HostAddress); value = VMrView_GetValue(view); UUrString_Copy((char*)ONgMP_PlayerInfo.host_address, (char*)value, ONcMaxHostAddressLength); - + // get the password view = DMrDialog_GetViewByID(inDialog, ONcMPJG_EF_Password); value = VMrView_GetValue(view); UUrString_Copy((char*)ONgMP_PlayerInfo.password, (char*)value, ONcMaxPasswordLength); - + // get the remember password checkbox view = DMrDialog_GetViewByID(inDialog, ONcMPJG_CB_RememberPassword); ONgMP_PlayerInfo.remember_password = (UUtBool)VMrView_GetValue(view); - + // ------------------------------ // options tab // ------------------------------ @@ -406,7 +406,7 @@ ONiMP_SaveMPInfo( view = DMrDialog_GetViewByID(inDialog, ONcMPO_EF_PlayerName); value = VMrView_GetValue(view); UUrString_Copy((char*)ONgMP_PlayerInfo.player_name, (char*)value, ONcMaxPlayerNameLength); - + // get the team name view = DMrDialog_GetViewByID(inDialog, ONcMPO_EF_TeamName); value = VMrView_GetValue(view); @@ -416,7 +416,7 @@ ONiMP_SaveMPInfo( // ---------------------------------------------------------------------- static void ONiMPJG_FindServers_Callback( - ONtNet_ServerInfo *inServerInfo, + ONtNet_ServerInfo *inServerInfo, NMtNetAddress *inServerAddress, UUtUns32 inUserParam) { @@ -428,12 +428,12 @@ ONiMPJG_FindServers_Callback( UUtBool server_in_list; ONtNet_ServerArrayInfo *server_info_array; UUtBool mem_moved; - + UUmAssert(inServerInfo); UUmAssert(inUserParam); - + if (ONgMPJG_Servers == NULL) return; - + // ------------------------------ // get pointers // ------------------------------ @@ -441,21 +441,21 @@ ONiMPJG_FindServers_Callback( tab_view = (VMtView*)inUserParam; list_view = DMrDialog_GetViewByID(tab_view, ONcMPJG_LB_Hosts); UUmAssert(list_view); - + if (list_view == NULL) return; - + // ------------------------------ // check to see if this server's info has already been received // ------------------------------ // get the array pointer server_info_array = (ONtNet_ServerArrayInfo*)UUrMemory_Array_GetMemory(ONgMPJG_Servers); num_servers = (UUtUns16)UUrMemory_Array_GetUsedElems(ONgMPJG_Servers); - + server_in_list = UUcFalse; for (index = 0; index < num_servers; index++) { UUtBool result; - + result = strcmp(server_info_array[index].server_info.server_name, inServerInfo->server_name); if (result == 0) { @@ -463,9 +463,9 @@ ONiMPJG_FindServers_Callback( break; } } - + if (server_in_list) return; - + // ------------------------------ // store inServerInfo in an array // ------------------------------ @@ -476,7 +476,7 @@ ONiMPJG_FindServers_Callback( &index, &mem_moved); if (error != UUcError_None) return; - + // get a fresh pointer to the memory server_info_array = (ONtNet_ServerArrayInfo*)UUrMemory_Array_GetMemory(ONgMPJG_Servers); @@ -485,12 +485,12 @@ ONiMPJG_FindServers_Callback( inServerInfo, &server_info_array[index].server_info, sizeof(ONtNet_ServerInfo)); - + UUrMemory_MoveFast( inServerAddress, &server_info_array[index].server_address, sizeof(NMtNetAddress)); - + // add the server info to the listbox VMrView_SendMessage( list_view, @@ -508,11 +508,11 @@ ONiMPJG_SetIPAddress( VMtView *server_address; UUtUns32 current_selection; char *server_address_string; - + // get pointer to the views server_list = DMrDialog_GetViewByID(inTab, ONcMPJG_LB_Hosts); server_address = DMrDialog_GetViewByID(inTab, ONcMPJG_EF_HostAddress); - + // get the index of the currently selected server current_selection = VMrView_SendMessage( @@ -520,7 +520,7 @@ ONiMPJG_SetIPAddress( LBcMessage_GetCurrentSelection, 0, 0); - + // set the server address server_address_string = ""; @@ -536,16 +536,16 @@ ONiMPJG_SetIPAddress( else { ONtNet_ServerArrayInfo *server_info_array; - + // get a fresh pointer to the memory server_info_array = (ONtNet_ServerArrayInfo*)UUrMemory_Array_GetMemory(ONgMPJG_Servers); - + if (server_info_array) { - server_address_string = + server_address_string = NMrAddressToString( &server_info_array[current_selection].server_address); - + // set the addres to the address of the server VMrView_SendMessage( server_address, @@ -566,9 +566,9 @@ ONiMPJG_TabCallback( { UUtBool handled; UUtError error; - + handled = UUcTrue; - + switch (inMessage) { case TbcMessage_InitTab: @@ -593,14 +593,14 @@ ONiMPJG_TabCallback( 0); } break; - + case VMcMessage_Destroy: // stop finding servers ONrNet_FindServers_Stop(); - + // stop the timer VMrView_Timer_Stop(inTab, 1); - + // release the server info array if (ONgMPJG_Servers) { @@ -608,12 +608,12 @@ ONiMPJG_TabCallback( ONgMPJG_Servers = NULL; } break; - + case VMcMessage_Timer: // update networking ONrNet_FindServers_Update(); break; - + case VMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -623,18 +623,18 @@ ONiMPJG_TabCallback( ONiMPJG_SetIPAddress(inTab); } break; - + default: handled = UUcFalse; break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -647,59 +647,59 @@ ONrDialogCallback_Multiplayer( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case DMcMessage_InitDialog: - { + { VMtView *tab_view; - + ONiMP_RestoreMPInfo(inDialog); ONiLevelList_Initialize(inDialog, ONcMPHG_LB_Level); handled = UUcFalse; - + // set the tab callbacks tab_view = DMrDialog_GetViewByID(inDialog, ONcMP_Tab_JoinGame); UUmAssert(tab_view); VMrView_Tab_SetTabCallback(tab_view, ONiMPJG_TabCallback); } break; - + case VMcMessage_Destroy: ONiMP_SaveMPInfo(inDialog); break; - + case VMcMessage_KeyDown: if (inParam1 == LIcKeyCode_Escape) DMrDialog_Stop(inDialog, 0); break; - + case VMcMessage_Command: switch (UUmLowWord(inParam1)) { case ONcBtn_Back: DMrDialog_Stop(inDialog, 0); break; - + case ONcMP_Btn_HostGame: DMrDialog_ActivateTab(inDialog, ONcMP_Tab_HostGame); break; - + case ONcMP_Btn_JoinGame: DMrDialog_ActivateTab(inDialog, ONcMP_Tab_JoinGame); break; - + case ONcMP_Btn_Options: DMrDialog_ActivateTab(inDialog, ONcMP_Tab_Options); break; - + case ONcMPJG_Btn_Join: ONiMP_SaveMPInfo(inDialog); DMrDialog_Stop(inDialog, ONcMPJG_Btn_Join); break; - + case ONcMPHG_Btn_StartHost: ONiMP_SaveMPInfo(inDialog); if ((ONgMP_HostInfo.level_number != (UUtUns16)(-1)) && @@ -710,12 +710,12 @@ ONrDialogCallback_Multiplayer( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -730,16 +730,16 @@ ONiNG_Start( DMtDialog *inDialog) { UUtUns16 num_descriptors; - + // get the number of descriptors num_descriptors = (UUtUns16)TMrInstance_GetTagCount(ONcTemplate_Level_Descriptor); if (num_descriptors > 0) { UUtUns16 level_number; - + // get the level number level_number = ONiLevelList_GetLevelNumber(inDialog, ONcNG_LB_Level); - + if (level_number != (UUtUns16)(-1)) { // stop the dialog @@ -759,32 +759,32 @@ ONrDialogCallback_NewGame( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case DMcMessage_InitDialog: ONiLevelList_Initialize(inDialog, ONcNG_LB_Level); handled = UUcFalse; break; - + case VMcMessage_KeyDown: if (inParam1 == LIcKeyCode_Escape) DMrDialog_Stop(inDialog, 0); break; - + case VMcMessage_Command: switch (UUmLowWord(inParam1)) { case ONcBtn_Back: DMrDialog_Stop(inDialog, 0); break; - + case ONcNG_Btn_Start: ONiNG_Start(inDialog); break; - + case ONcNG_LB_Level: if (UUmHighWord(inParam1) == VMcNotify_DoubleClick) { @@ -793,12 +793,12 @@ ONrDialogCallback_NewGame( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -819,10 +819,10 @@ ONiOptns_Control_Set( char *string; char input_name[LIcMaxInputNameLength]; UUtUns16 id; - + tab_view = (VMtView*)inUserParam; UUmAssert(tab_view); - + switch (inActionType) { case LIc_Bit_Forward: id = ONcOC_EF_Forward1; break; @@ -847,7 +847,7 @@ ONiOptns_Control_Set( VMrView_SendMessage(control_view, VMcMessage_SetValue, (UUtUns32)input_name, 0); return UUcTrue; } - + switch (inActionType) { case LIc_Bit_Forward: id = ONcOC_EF_Forward2; break; @@ -861,7 +861,7 @@ ONiOptns_Control_Set( case LIc_Bit_Punch: id = ONcOC_EF_Punch2; break; case LIc_Bit_Kick: id = ONcOC_EF_Kick2; break; } - + control_view = DMrDialog_GetViewByID(tab_view, id); UUmAssert(control_view); string = (char*)VMrView_SendMessage(control_view, VMcMessage_GetValue, 0, 0); @@ -871,7 +871,7 @@ ONiOptns_Control_Set( VMrView_SendMessage(control_view, VMcMessage_SetValue, (UUtUns32)input_name, 0); return UUcTrue; } - + return UUcTrue; } @@ -885,9 +885,9 @@ ONiOptns_Tab_AVCallback( { UUtBool handled; VMtView *view; - + handled = UUcTrue; - + switch(inMessage) { case TbcMessage_InitTab: @@ -895,7 +895,7 @@ ONiOptns_Tab_AVCallback( UUtInt32 min_gamma; UUtInt32 max_gamma; UUtInt32 current_gamma; - + // set the gamma ONrPlatform_GetGammaParams(&min_gamma, &max_gamma, ¤t_gamma); view = DMrDialog_GetViewByID(inTab, ONcOAV_Sldr_Gamma); @@ -904,11 +904,11 @@ ONiOptns_Tab_AVCallback( VMrView_Slider_SetPosition(view, current_gamma); } break; - + case VMcMessage_Destroy: { UUtInt32 new_gamma; - + // set the gamma view = DMrDialog_GetViewByID(inTab, ONcOAV_Sldr_Gamma); UUmAssert(view); @@ -916,7 +916,7 @@ ONiOptns_Tab_AVCallback( ONrPlatform_SetGamma(new_gamma); } break; - + case VMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -930,12 +930,12 @@ ONiOptns_Tab_AVCallback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -950,20 +950,20 @@ ONiOptns_Tab_CntrlsCallback( UUtBool handled; VMtView *view; UUtUns32 result; - + handled = UUcTrue; - + switch(inMessage) { case TbcMessage_InitTab: LIrBindings_Enumerate(ONiOptns_Control_Set, (UUtUns32)inTab); - + // set invert mouse checkbox view = DMrDialog_GetViewByID(inTab, ONcOC_CB_InvertMouse); UUmAssert(view); VMrView_SendMessage(view, VMcMessage_SetValue, LIrMouse_Invert_Get(), 0); break; - + case VMcMessage_Destroy: // set invert mouse view = DMrDialog_GetViewByID(inTab, ONcOC_CB_InvertMouse); @@ -971,12 +971,12 @@ ONiOptns_Tab_CntrlsCallback( result = VMrView_SendMessage(view, VMcMessage_GetValue, 0, 0); LIrMouse_Invert_Set((UUtBool)result); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -989,62 +989,62 @@ ONrDialogCallback_Options( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case DMcMessage_InitDialog: { VMtView *tab_view; - + handled = UUcFalse; - + // set the tab callbacks tab_view = DMrDialog_GetViewByID(inDialog, ONcOptns_Tab_Controls); UUmAssert(tab_view); VMrView_Tab_SetTabCallback(tab_view, ONiOptns_Tab_CntrlsCallback); - + // set the gamma tab_view = DMrDialog_GetViewByID(inDialog, ONcOptns_Tab_AV); UUmAssert(tab_view); VMrView_Tab_SetTabCallback(tab_view, ONiOptns_Tab_AVCallback); } break; - + case VMcMessage_KeyDown: if (inParam1 == LIcKeyCode_Escape) { DMrDialog_Stop(inDialog, 0); } break; - + case VMcMessage_Command: switch (UUmLowWord(inParam1)) { case ONcBtn_Back: DMrDialog_Stop(inDialog, 0); break; - + case ONcOptns_Btn_AV: DMrDialog_ActivateTab(inDialog, ONcOptns_Tab_AV); break; - + case ONcOptns_Btn_Controls: DMrDialog_ActivateTab(inDialog, ONcOptns_Tab_Controls); break; - + case ONcOptns_Btn_Advanced: DMrDialog_ActivateTab(inDialog, ONcOptns_Tab_Advanced); break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -1062,31 +1062,31 @@ ONrDialogCallback_LoadSave( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case DMcMessage_InitDialog: handled = UUcFalse; break; - + case VMcMessage_KeyDown: if (inParam1 == LIcKeyCode_Escape) DMrDialog_Stop(inDialog, 0); break; - + case VMcMessage_Command: switch (UUmLowWord(inParam1)) { case ONcBtn_Back: DMrDialog_Stop(inDialog, 0); break; - + case ONcLS_Btn_Load: DMrDialog_ActivateTab(inDialog, ONcLS_Tab_Load); break; - + case ONcLS_Btn_Save: DMrDialog_ActivateTab(inDialog, ONcLS_Tab_Save); break; @@ -1096,12 +1096,12 @@ ONrDialogCallback_LoadSave( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -1119,9 +1119,9 @@ ONrDialogCallback_Quit( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case VMcMessage_KeyDown: @@ -1130,13 +1130,13 @@ ONrDialogCallback_Quit( case LIcKeyCode_Escape: DMrDialog_Stop(inDialog, ONcQuit_Btn_Yes); break; - + case LIcKeyCode_Return: DMrDialog_Stop(inDialog, ONcQuit_Btn_No); break; - } + } break; - + case VMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -1144,21 +1144,21 @@ ONrDialogCallback_Quit( case ONcQuit_Btn_No: DMrDialog_Stop(inDialog, ONcQuit_Btn_No); break; - + case ONcQuit_Btn_Yes: DMrDialog_Stop(inDialog, ONcQuit_Btn_Yes); break; } break; - + default: handled = UUcFalse; break; } - + return handled; } - + // ====================================================================== #if 0 #pragma mark - @@ -1174,9 +1174,9 @@ ONrDialogCallback_Joining( { UUtBool handled; UUtError error; - + handled = UUcTrue; - + switch (inMessage) { case DMcMessage_InitDialog: @@ -1185,20 +1185,20 @@ ONrDialogCallback_Joining( { DMrDialog_Stop(inDialog, error); } - + if (ONiMP_JoinGame(ONgMP_PlayerInfo.host_address) == UUcFalse) { DMrDialog_Stop(inDialog, UUcError_Generic); } - + ONrNet_Level_Callback_Register(ONiMP_Net_Level_Callback); break; - + case VMcMessage_Destroy: VMrView_Timer_Stop(inDialog, 1); ONrNet_Level_Callback_Unregister(); break; - + case VMcMessage_Timer: ONrNet_Update(); if (ONgJoining_LevelHasLoaded) @@ -1206,12 +1206,12 @@ ONrDialogCallback_Joining( DMrDialog_Stop(inDialog, UUcError_None); } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -1225,19 +1225,19 @@ ONrDialogCallback_MainMenu( { UUtUns32 message; UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case DMcMessage_InitDialog: ONrGameState_Pause(UUcTrue); break; - + case VMcMessage_Destroy: ONrGameState_Pause(UUcFalse); break; - + case VMcMessage_KeyDown: if (inParam1 == LIcKeyCode_Escape) { @@ -1252,7 +1252,7 @@ ONrDialogCallback_MainMenu( DMrDialog_Stop(inDialog, ONcMM_Btn_Quit); } break; - + case VMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -1269,7 +1269,7 @@ ONrDialogCallback_MainMenu( UUmMakeLong(UUmHighWord(message), ONcMM_Btn_NewGame)); } break; - + case ONcMM_Btn_LoadSave: DMrDialog_Run( ONcDialogID_LoadSave, @@ -1277,7 +1277,7 @@ ONrDialogCallback_MainMenu( inDialog, &message); break; - + case ONcMM_Btn_Multiplayer: DMrDialog_Run( ONcDialogID_Multiplayer, @@ -1290,7 +1290,7 @@ ONrDialogCallback_MainMenu( DMrDialog_Stop(inDialog, message); } break; - + case ONcMM_Btn_Options: DMrDialog_Run( ONcDialogID_Options, @@ -1298,7 +1298,7 @@ ONrDialogCallback_MainMenu( inDialog, &message); break; - + case ONcMM_Btn_Quit: DMrDialog_Run( ONcDialogID_Quit, @@ -1312,12 +1312,12 @@ ONrDialogCallback_MainMenu( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -1343,17 +1343,17 @@ ONrDialogCallback_PasswordSplashScreen( case DMcMessage_InitDialog: UUrMemory_Clear(entered_password, sizeof(entered_password)); break; - + case VMcMessage_KeyDown: if (isalnum(inParam1)) { char append_me[2]; - + if (len < cMaxPasswordChars) { append_me[0] = (char) inParam1; append_me[1] = 0; - + strncat(entered_password, append_me, cMaxPasswordChars); } } @@ -1369,23 +1369,23 @@ ONrDialogCallback_PasswordSplashScreen( else if ((inParam1 == LIcKeyCode_Return) || (inParam1 == LIcKeyCode_NumPadEnter)) { UUtBool success; - - success = + + success = UUrOneWayFunction_CompareString( entered_password, (char*)ONgMungedPassword, len); - + DMrDialog_Stop(inDialog, success); } } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -1402,25 +1402,25 @@ ONrDialog_MainMenu( void) { UUtUns32 message; - + if (ONgTerminateGame) return; - + // load level the UnitViewer Level ONrLevel_Load(ONcUnitViewer_Level); - + // display the bungie logo - + // display the oni logo - + // run the unit viewer dialog DMrDialog_Run( ONcDialogID_UnitViewer, ONrDialogCallback_UnitViewer, NULL, &message); - + // display the coming soon picture - + ONgTerminateGame = UUcTrue; } @@ -1432,12 +1432,12 @@ ONrDialog_MainMenu( { UUtError error; UUtUns32 message; - + if (ONgTerminateGame) return; - + // make sure this is set to true ONgRunMainMenu = UUcTrue; - + do { ONrGameState_Pause(UUcTrue); @@ -1447,37 +1447,37 @@ ONrDialog_MainMenu( NULL, &message); ONrGameState_Pause(UUcFalse); - + switch (UUmLowWord(message)) { case ONcReturnToGame: ONgRunMainMenu = UUcFalse; break; - + case ONcMM_Btn_Quit: // terminate an active network session before quitting if (ONrNet_IsActive()) { ONrNet_Terminate(); } - + ONgTerminateGame = UUcTrue; ONgRunMainMenu = UUcFalse; break; - + case ONcMM_Btn_NewGame: { UUtUns16 new_level; - + // unload any level other than 0 if (ONrLevel_GetCurrentLevel() != 0) { ONrLevel_Unload(); } - + // get the new level to laod new_level = (UUtUns16)UUmHighWord(message); - + // try to load the new level error = ONrLevel_Load(new_level); if (error != UUcError_None) @@ -1486,37 +1486,37 @@ ONrDialog_MainMenu( ONgRunMainMenu = UUcFalse; } break; - + case ONcMPHG_Btn_StartHost: if (ONiMP_HostGame() == UUcFalse) break; - + ONgRunMainMenu = UUcFalse; break; - + case ONcMPJG_Btn_Join: { UUtUns32 stop_time; - + if (ONiMP_JoinGame(ONgMP_PlayerInfo.host_address) == UUcFalse) break; - + ONrNet_Level_Callback_Register(ONiMP_Net_Level_Callback); - + stop_time = UUrMachineTime_GameTicks() + (10 * 60); - + while ((ONgJoining_LevelHasLoaded == UUcFalse) && (stop_time > UUrMachineTime_GameTicks())) { ONrNet_Update(); } - + if (ONgJoining_LevelHasLoaded) { // the game has joined a server and a level has been loaded // put the input into game mode LIrMode_Set(LIcMode_Game); - + ONgRunMainMenu = UUcFalse; } } @@ -1524,7 +1524,7 @@ ONrDialog_MainMenu( } } while (ONgRunMainMenu); - + ONgMainMenu_SwitchTime = UUrMachineTime_GameTicks(); } @@ -1537,7 +1537,7 @@ ONrDialog_SplashScreen( { DMtDialog *dialog; UUtUns16 tryCount = 0; - + #ifndef UUmPasswordProtect #define UUmPasswordProtect 0 #endif @@ -1545,7 +1545,7 @@ ONrDialog_SplashScreen( if (UUmPasswordProtect) { UUtUns32 message; - + tryAgain: DMrDialog_Run( ONcDialogID_SplashScreen, @@ -1558,7 +1558,7 @@ ONrDialog_SplashScreen( { TMrMameAndDestroy(); UUrPlatform_MameAndDestroy(); - + // quit the app ONgTerminateGame = UUcTrue; ONgRunMainMenu = UUcFalse; @@ -1577,11 +1577,11 @@ ONrDialog_SplashScreen( NULL, NULL, &dialog); - + M3rGeom_Frame_Start(0); DMrDialog_Display(dialog); M3rGeom_Frame_End(); - + DMrDialog_Stop(dialog, 0); DMrDialog_Update(dialog); } @@ -1598,7 +1598,7 @@ ONrDialog_Initialize( void) { ONgMainMenu_SwitchTime = 0; - + UUrString_Copy(ONgMP_PlayerInfo.player_name, "Player", ONcMaxPlayerNameLength); UUrString_Copy(ONgMP_PlayerInfo.team_name, "Player Team", ONcMaxTeamNameLength); UUrString_Copy(ONgMP_PlayerInfo.character_class, "konoko_generic", AIcMaxClassNameLen); @@ -1614,7 +1614,7 @@ ONrDialog_Initialize( ONgMP_HostInfo.game_options.time_limit = 5 * 60 * 60; // 5 minutes in ticks ONgMP_HostInfo.game_options.kill_limit = 0; ONgMP_HostInfo.game_options.num_AIs = 0; - + return UUcError_None; } @@ -1625,4 +1625,4 @@ ONrDialog_Terminate( { } -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_Dialogs.h b/OniProj/OniGameSource/Oni_Dialogs.h index 6f3f807..9070bd0 100644 --- a/OniProj/OniGameSource/Oni_Dialogs.h +++ b/OniProj/OniGameSource/Oni_Dialogs.h @@ -63,19 +63,19 @@ enum ONcLS_Btn_Load = 100, ONcLS_Btn_Save = 101, ONcLS_Btn_Film = 102, - + ONcLS_Tab_Load = 400, ONcLSL_LB_SavedGames = 401, ONcLSL_EF_NewName = 402, ONcLSL_Btn_Delete = 403, ONcLSL_Btn_Rename = 404, ONcLSL_Btn_Load = 405, - + ONcLS_Tab_Save = 500, ONcLSS_LB_SavedGames = 501, ONcLSS_EF_NewSavedGame = 502, ONcLSS_Btn_Save = 503, - + ONcLS_Tab_Film = 600, ONcLSF_LB_SavedFilms = 601, ONcLSF_EF_NewName = 602, @@ -91,10 +91,10 @@ enum ONcOptns_Btn_AV = 100, ONcOptns_Btn_Controls = 101, ONcOptns_Btn_Advanced = 102, - + ONcOptns_Tab_Presets = 400, ONcOP_LB_Presets = 401, - + ONcOptns_Tab_AV = 500, ONcOAV_Sldr_Volume = 501, ONcOAV_Sldr_Music = 502, @@ -103,7 +103,7 @@ enum ONcOAV_List_Resolution = 505, ONcOAV_List_Driver = 506, ONcOAV_Sldr_Gamma = 507, - + ONcOptns_Tab_Controls = 600, ONcOC_EF_Forward1 = 601, ONcOC_EF_Forward2 = 602, @@ -128,7 +128,7 @@ enum ONcOC_EF_Special1 = 621, ONcOC_EF_Special2 = 622, ONcOC_CB_InvertMouse = 624, - + ONcOptns_Tab_Advanced = 700, ONcOA_CB_Blood = 701, ONcOA_CB_MotionBlur = 702, @@ -142,21 +142,21 @@ enum ONcMP_Btn_HostGame = 100, ONcMP_Btn_JoinGame = 101, ONcMP_Btn_Options = 102, - + ONcMP_Tab_HostGame = 500, ONcMPHG_Btn_StartHost = 501, ONcMPHG_EF_HostName = 502, ONcMPHG_EF_Description = 503, ONcMPHG_LB_Level = 504, ONcMPHG_EF_NumBots = 509, - + ONcMP_Tab_JoinGame = 600, ONcMPJG_Btn_Join = 601, ONcMPJG_EF_HostAddress = 602, ONcMPJG_EF_Password = 603, ONcMPJG_CB_RememberPassword = 604, ONcMPJG_LB_Hosts = 605, - + ONcMP_Tab_Options = 700, ONcMPO_EF_PlayerName = 701, ONcMPO_EF_TeamName = 702 @@ -186,7 +186,7 @@ ONrDialogCallback_Joining( DMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2); - + UUtBool ONrDialogCallback_MainMenu( DMtDialog *inDialog, @@ -229,16 +229,16 @@ ONrDialogCallback_Quit( DMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2); - + // ---------------------------------------------------------------------- void ONrDialog_MainMenu( void); - + void ONrDialog_SplashScreen( void); - + // ---------------------------------------------------------------------- UUtError ONrDialog_Initialize( @@ -248,4 +248,4 @@ void ONrDialog_Terminate( void); -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_Event.c b/OniProj/OniGameSource/Oni_Event.c index de3ef21..4c89a25 100644 --- a/OniProj/OniGameSource/Oni_Event.c +++ b/OniProj/OniGameSource/Oni_Event.c @@ -153,7 +153,7 @@ UUtUns32 ONrEventList_Read( ONtEventList *inEventList, UUtUns16 inVersion, UUtBo for( i = 0; i < inEventList->event_count; i++ ) { UUtUns16 event_type; - + event = &inEventList->events[i]; OBJmGet2BytesFromBuffer( inBuffer, event_type, UUtUns16, inSwapIt ); @@ -162,7 +162,7 @@ UUtUns32 ONrEventList_Read( ONtEventList *inEventList, UUtUns16 inVersion, UUtBo num_bytes += sizeof(UUtUns16); desc = ONrEvent_GetDescription( event->event_type ); - + UUmAssert( desc ); switch( desc->params_type ) @@ -194,12 +194,12 @@ UUtError ONrEventList_Write( ONtEventList *inEventList, UUtUns8 *ioBuffer, UUtUn UUtUns32 i; ONtEvent *event; ONtEventDescription *desc; - + // set the number of bytes available bytes_available = *ioBufferSize; OBJmWrite2BytesToBuffer( ioBuffer, inEventList->event_count, UUtUns16, bytes_available, OBJcWrite_Little); - + for( i = 0; i < inEventList->event_count; i++ ) { event = &inEventList->events[i]; @@ -207,7 +207,7 @@ UUtError ONrEventList_Write( ONtEventList *inEventList, UUtUns8 *ioBuffer, UUtUn OBJmWrite2BytesToBuffer(ioBuffer, event->event_type, UUtInt16, bytes_available, OBJcWrite_Little); desc = ONrEvent_GetDescription( event->event_type ); - + UUmAssert( desc ); switch( desc->params_type ) @@ -249,7 +249,7 @@ UUtUns32 ONrEventList_GetWriteSize( ONtEventList *inEventList ) num_bytes += sizeof(UUtUns16); desc = ONrEvent_GetDescription( event->event_type ); - + UUmAssert( desc ); switch( desc->params_type ) @@ -293,9 +293,9 @@ UUtError ONrEventList_Execute( ONtEventList *inEventList, ONtCharacter *inCharac { ONtEvent *event; UUtUns32 i; - + ONgEvent_Character = inCharacter; - + for( i = 0; i < inEventList->event_count; i++ ) { event = &inEventList->events[i]; @@ -357,7 +357,7 @@ void ONrEvent_Handle_DoorLock( ONtEvent *inEvent ) UUmAssert( inEvent ); id = (UUtUns16) inEvent->params.params_id16.id; - + OBJrDoor_Lock_ID( id ); } @@ -414,9 +414,9 @@ UUtError ONrEvent_GetName( ONtEvent *inEvent, char* ioName, UUtUns32 inMaxLength char temp_name[100]; desc = ONrEvent_GetDescription( inEvent->event_type ); - + UUmAssert( desc ); - + switch( desc->params_type ) { case ONcEventParams_None: diff --git a/OniProj/OniGameSource/Oni_Event.h b/OniProj/OniGameSource/Oni_Event.h index 0494c46..e425a49 100644 --- a/OniProj/OniGameSource/Oni_Event.h +++ b/OniProj/OniGameSource/Oni_Event.h @@ -49,7 +49,7 @@ typedef enum ONtEventParams_Type ONcEventParams_ID32 = 2, ONcEventParams_Text = 3 } ONtEventParams_Type; - + typedef struct ONtEventParams_ID16 { UUtUns16 id; diff --git a/OniProj/OniGameSource/Oni_FX.c b/OniProj/OniGameSource/Oni_FX.c index 7a12283..30372dd 100644 --- a/OniProj/OniGameSource/Oni_FX.c +++ b/OniProj/OniGameSource/Oni_FX.c @@ -55,12 +55,12 @@ void FXrDrawLaserDot(M3tPoint3D *inPoint) error = TMrInstance_GetDataPtr(M3cTemplate_TextureMap, "dot", (void **) &dotTexture); UUmAssert(UUcError_None == error); - if (error) + if (error) return; cam_sphere_dist = MUmVector_GetDistance( cameraLocation, (*inPoint)); - if (cam_sphere_dist > .001f) + if (cam_sphere_dist > .001f) { scale *= cam_sphere_dist; M3rSimpleSprite_Draw(dotTexture, inPoint, scale, scale, IMcShade_Red, M3cMaxAlpha); @@ -79,11 +79,11 @@ void FXrDrawLaser( M3tPoint3D *inFrom, M3tPoint3D *inTo, UUtUns32 inColor ) M3tGeomCamera *activeCamera; float width; float scale; - UUtUns32 color; - UUtUns16 alpha; + UUtUns32 color; + UUtUns16 alpha; M3tMatrix4x3* stack_matrix; M3tMatrix4x3 matrix; - + M3rGeom_State_Push(); M3rDraw_State_SetInt(M3cDrawStateIntType_ZWrite, M3cDrawState_ZWrite_Off); @@ -98,7 +98,7 @@ void FXrDrawLaser( M3tPoint3D *inFrom, M3tPoint3D *inTo, UUtUns32 inColor ) MUrMatrix_MultiplyPoint(&cameraPos, &matrix, &cameraPos); - MUmVector_Subtract(cameraDir, laser_from, cameraPos); + MUmVector_Subtract(cameraDir, laser_from, cameraPos); MUmVector_Subtract(contrailDir, laser_to, laser_from); // the contrail is still oriented from one point towards the other, but rotates to face the camera (i.e. perpendicular to cameraDir) @@ -159,10 +159,10 @@ void FXrDrawCursorTunnel(M3tPoint3D *inFrom, M3tPoint3D *inTo, UUtUns32 inColor, MUrMatrix3x3_Identity(&matrix); MUmVector_Subtract( sight_vector, *inTo, *inFrom ); - + max_distance = MUrPoint_Length( &sight_vector ); - MUmVector_Normalize( sight_vector ); + MUmVector_Normalize( sight_vector ); up.x = 0; up.y = 1; @@ -171,8 +171,8 @@ void FXrDrawCursorTunnel(M3tPoint3D *inFrom, M3tPoint3D *inTo, UUtUns32 inColor, MUrVector_CrossProduct( &sight_vector, &up, &right ); MUrVector_CrossProduct( &sight_vector, &right, &up ); - MUmVector_Normalize(right); - MUmVector_Normalize(up); + MUmVector_Normalize(right); + MUmVector_Normalize(up); matrix.m[0][0] = right.x; matrix.m[0][1] = right.y; @@ -196,21 +196,21 @@ void FXrDrawCursorTunnel(M3tPoint3D *inFrom, M3tPoint3D *inTo, UUtUns32 inColor, float temp; next_distance += UUmFeetToUnits( 12 ); - position.x = inFrom->x + sight_vector.x * dist; - position.y = inFrom->y + sight_vector.y * dist; + position.x = inFrom->x + sight_vector.x * dist; + position.y = inFrom->y + sight_vector.y * dist; position.z = inFrom->z + sight_vector.z * dist; if (next_distance >= max_distance) { break; } - + M3rSimpleSprite_Draw(inTexture, &position, scale, scale, IMcShade_Red, (UUtUns16) alpha); alpha = MUrUnsignedSmallFloat_To_Uns_Round(alpha * 0.85f); if (alpha < (M3cMaxAlpha * 0.1f)) { break; } - + temp = dist; dist = next_distance; next_distance = temp; diff --git a/OniProj/OniGameSource/Oni_FX.h b/OniProj/OniGameSource/Oni_FX.h index fad29f2..6f337fa 100644 --- a/OniProj/OniGameSource/Oni_FX.h +++ b/OniProj/OniGameSource/Oni_FX.h @@ -1,11 +1,11 @@ /* FILE: Oni_FX.h - + AUTHOR: Jason Duncan, Michael Evans - + CREATED: April 2, 1999 - + PURPOSE: control of FX in ONI - + Copyright (c) 1999, 2000 */ diff --git a/OniProj/OniGameSource/Oni_Film.c b/OniProj/OniGameSource/Oni_Film.c index 7e555bf..b5c9572 100644 --- a/OniProj/OniGameSource/Oni_Film.c +++ b/OniProj/OniGameSource/Oni_Film.c @@ -1,8 +1,8 @@ /* Oni_Film.c - + Film recording stuff - + Author: Quinn Dunki c1998 Bungie */ @@ -41,7 +41,7 @@ ONiSetFocus( { ONtCharacter *ch; UUtUns16 playerNum; - + playerNum = (UUtUns16)inParameterList[0].val.i; ONrGameState_SetPlayerNum(playerNum); @@ -61,8 +61,8 @@ UUtError ONrFilm_Initialize( /******************* * Initializes film recording */ - - UUtError error; + + UUtError error; error; @@ -70,7 +70,7 @@ UUtError ONrFilm_Initialize( strcpy(ONgBoundF3, ""); #if CONSOLE_DEBUGGING_COMMANDS - // Console + // Console error = SLrScript_Command_Register_Void( "sc_focus", "sets which character we're authoring for a film", @@ -112,7 +112,7 @@ void ONrFilm_GetFrame(const ONtFilmState *inFilmState, ONtInputState *outInputSt } } - + if (0 == itr) { outInputState->turnLR = key->turnLR; @@ -167,7 +167,7 @@ void ONrFilm_AppendFrame(ONtFilmState *inFilmState, ONtInputState *inInputState) else { const ONtFilmKey *oldKey = curFilm->keys + curFilm->numKeys - 1; - addKey = + addKey = (inInputState->turnLR != 0.f) || (inInputState->turnUD != 0.f) || (oldKey->current != inInputState->buttonIsDown); @@ -276,7 +276,7 @@ void ONrFilm_Swap(ONtFilm *ioFilm, ONtFilm_SwapSrc inSwapSrc) for(itr = 0; itr < numKeys; itr++) { ONtFilmKey *key = ioFilm->keys + itr; - + UUmSwapBig_4Byte(&key->turnUD); UUmSwapBig_4Byte(&key->turnLR); UUmSwapBig_8Byte(&key->current); @@ -300,7 +300,7 @@ void ONrFilm_Swap_DiskFormat(ONtFilm_DiskFormat *ioFilm, ONtFilmKey *ioKeys) for(itr = 0; itr < ioFilm->numKeys; itr++) { ONtFilmKey *key = ioKeys + itr; - + UUmSwapBig_4Byte(&key->turnUD); UUmSwapBig_4Byte(&key->turnLR); UUmSwapBig_8Byte(&key->current); @@ -353,7 +353,7 @@ void ONrFilm_WriteToDisk(ONtFilm *inFilm) error = BFrFile_Write(file, fileLength, inFilm->keys); } - if (UUcError_None != error) { + if (UUcError_None != error) { COrConsole_Printf("failed to write file"); } @@ -392,11 +392,11 @@ void ONrFilm_DisplayStats(ONtFilm *inFilm) instance_name = (NULL == instance_name) ? "no-name" : instance_name; COrConsole_Printf("%s length %d keys %d loc %f,%f,%f", - instance_name, - inFilm->length, - inFilm->numKeys, - inFilm->initialLocation.x, - inFilm->initialLocation.y, + instance_name, + inFilm->length, + inFilm->numKeys, + inFilm->initialLocation.x, + inFilm->initialLocation.y, inFilm->initialLocation.z); } -} \ No newline at end of file +} diff --git a/OniProj/OniGameSource/Oni_Film.h b/OniProj/OniGameSource/Oni_Film.h index d27086f..7b15db3 100644 --- a/OniProj/OniGameSource/Oni_Film.h +++ b/OniProj/OniGameSource/Oni_Film.h @@ -2,9 +2,9 @@ /* Oni_Film.h - + Film recording stuff - + Author: Michael Evans, Quinn Dunki c1998 Bungie */ @@ -47,7 +47,7 @@ typedef tm_template('F', 'I', 'L', 'M', "Film") ONtFilm { // implied 8 bytes here - + M3tPoint3D initialLocation; float initialFacing; float initialDesiredFacing; @@ -56,7 +56,7 @@ ONtFilm UUtUns32 length; TRtAnimation *special_anim[2]; - + tm_pad pad[12]; tm_varindex UUtUns32 numKeys; @@ -66,7 +66,7 @@ ONtFilm typedef struct ONtFilm_DiskFormat { // implied 8 bytes here - + M3tPoint3D initialLocation; float initialFacing; float initialDesiredFacing; @@ -98,8 +98,8 @@ typedef struct ONtFilmState ONtFilm *film; } ONtFilmState; -UUtError ONrFilm_Initialize(void); -void ONrFilm_Terminate(void); +UUtError ONrFilm_Initialize(void); +void ONrFilm_Terminate(void); void ONrFilm_GetFrame(const ONtFilmState *inFilm, ONtInputState *outInputState); void ONrFilm_Create(ONtFilmState *ioFilm); diff --git a/OniProj/OniGameSource/Oni_Game.h b/OniProj/OniGameSource/Oni_Game.h index c3216b7..acd0648 100644 --- a/OniProj/OniGameSource/Oni_Game.h +++ b/OniProj/OniGameSource/Oni_Game.h @@ -1 +1 @@ -#error "This file is obsolete" \ No newline at end of file +#error "This file is obsolete" diff --git a/OniProj/OniGameSource/Oni_GameSettings.c b/OniProj/OniGameSource/Oni_GameSettings.c index c64921f..ba84cf6 100644 --- a/OniProj/OniGameSource/Oni_GameSettings.c +++ b/OniProj/OniGameSource/Oni_GameSettings.c @@ -1,12 +1,12 @@ /* FILE: Oni_GameSettings.c - + AUTHOR: Chris Butcher - + CREATED: September 25, 2000 - + PURPOSE: Global game settings for Oni - + Copyright Bungie Software, 2000 */ @@ -39,7 +39,7 @@ ONtGameSettingsRuntime ONgGameSettingsRuntime; UUtError ONrGameSettings_Initialize(void) { UUtError error; - + UUrMemory_Clear(&ONgGameSettingsRuntime, sizeof(ONgGameSettingsRuntime)); error = TMrInstance_GetDataPtr( ONcTemplate_GameSettings, "game_settings", &ONgGameSettings ); diff --git a/OniProj/OniGameSource/Oni_GameSettings.h b/OniProj/OniGameSource/Oni_GameSettings.h index 301d8f8..1e331d1 100644 --- a/OniProj/OniGameSource/Oni_GameSettings.h +++ b/OniProj/OniGameSource/Oni_GameSettings.h @@ -2,13 +2,13 @@ /* FILE: Oni_GameSettings.h - + AUTHOR: Chris Butcher - + CREATED: September 25, 2000 - + PURPOSE: Global game settings for Oni - + Copyright Bungie Software, 2000 */ diff --git a/OniProj/OniGameSource/Oni_GameState.c b/OniProj/OniGameSource/Oni_GameState.c index b040ff8..6a0cdcb 100644 --- a/OniProj/OniGameSource/Oni_GameState.c +++ b/OniProj/OniGameSource/Oni_GameState.c @@ -1,12 +1,12 @@ /* FILE: Oni_GameState.c - + AUTHOR: Brent H. Pease, Michael Evans - + CREATED: May 31, 1997 - + PURPOSE: - + Copyright 1997-2000 */ @@ -134,7 +134,7 @@ COtStatusLine script_count_display[2]; #endif #if PERFORMANCE_TIMER -COtStatusLine perf_overall[14]; +COtStatusLine perf_overall[14]; #else COtStatusLine game_fps[1]; COtStatusLine texture_info[1]; @@ -212,7 +212,7 @@ typedef enum { static UUtError ONrGameState_UpdateSoundManager(ONtGameState *ioGameState, UUtUns32 deltaTicks); -static const TRtAnimation *DoTableLookup(const ONtInputState *inInput, ONtCharacter *ioCharacter, +static const TRtAnimation *DoTableLookup(const ONtInputState *inInput, ONtCharacter *ioCharacter, ONtActiveCharacter *ioActiveCharacter, const ONtMoveLookup *table, TRtAnimType *outAnimType); static UUtBool DoTableAnimation(const ONtInputState *inInput, ONtCharacter *ioCharacter, ONtActiveCharacter *ioActiveCharacter, const ONtMoveLookup *table, ONtAnimPriority priority, ONtAttackMove attackMove, const TRtAnimation **outAnimation); @@ -363,14 +363,14 @@ ONrGameState_FarClipPlane_Set( SLtParameter_Actual *ioReturnValue) { ONgMotoko_FarPlane = inParameterList[0].val.f; - + M3rCamera_SetStaticData( ONgActiveCamera, ONgMotoko_FieldOfView, ONcMotoko_AspectRatio, ONcMotoko_NearPlane, ONgMotoko_FarPlane); - + return UUcError_None; } @@ -384,9 +384,9 @@ ONrGameState_FieldOfView_Set( SLtParameter_Actual *ioReturnValue) { float new_fov; - + new_fov = inParameterList[0].val.f; - + ONgMotoko_FieldOfView = new_fov * (M3c2Pi / 360.f); M3rCamera_SetStaticData( @@ -395,7 +395,7 @@ ONrGameState_FieldOfView_Set( ONcMotoko_AspectRatio, ONcMotoko_NearPlane, ONgMotoko_FarPlane); - + return UUcError_None; } @@ -429,7 +429,7 @@ UUtError ONrGameState_SetupDefaultLighting(void) directionalLightList[0].color.r = 0.7f; directionalLightList[0].color.g = 0.7f; directionalLightList[0].color.b = 0.7f; - + directionalLightList[1].direction.x = 0.5f; directionalLightList[1].direction.y = 0.5f; directionalLightList[1].direction.z = 1.0f; @@ -437,7 +437,7 @@ UUtError ONrGameState_SetupDefaultLighting(void) directionalLightList[1].color.r = 0.3f; directionalLightList[1].color.g = 0.3f; directionalLightList[1].color.b = 0.3f; - + // data is copied into motoko M3rLightList_Ambient(ambientLight); M3rLightList_Directional(num_directional_lights, directionalLightList); @@ -456,20 +456,20 @@ static UUtError ONrGameState_CreateAndSetupCamera(void) ONgCurrentCamera = 0; - for(itr = 0; itr < 2; itr++) + for(itr = 0; itr < 2; itr++) { error = M3rCamera_New(&ONgInternalCamera[itr]); UUmError_ReturnOnError(error); - + ONgMotoko_FarPlane = 10000.0f; - + M3rCamera_SetStaticData( ONgInternalCamera[itr], ONgMotoko_FieldOfView, ONcMotoko_AspectRatio, ONcMotoko_NearPlane, ONgMotoko_FarPlane); - + cameraLoc.x = cameraLoc.y = cameraLoc.z = 0.0f; viewDir.x = 1.0f; viewDir.y = 0.0f; @@ -477,20 +477,20 @@ static UUtError ONrGameState_CreateAndSetupCamera(void) upDir.x = 0.0f; upDir.y = 1.0f; upDir.z = 0.0f; - + M3rCamera_SetViewData( ONgInternalCamera[itr], &cameraLoc, &viewDir, &upDir); - + } ONgVisibilityCamera = ONgInternalCamera[0]; ONgActiveCamera = ONgInternalCamera[0]; M3rCamera_SetActive(ONgActiveCamera); - + return UUcError_None; } @@ -566,7 +566,7 @@ static void WaitForKey(UUtUns32 inTimeOut) if (KeyWentDown()) { break; } - + if (current_time > end_time) { break; } @@ -597,7 +597,7 @@ static void splash_screen_internal(M3tTextureMap_Big *splash_screen, float inBla M3rDraw_State_SetInt(M3cDrawStateIntType_ZCompare, M3cDrawState_ZCompare_Off); M3rDraw_State_SetInt(M3cDrawStateIntType_Fog, M3cDrawStateFogDisable); M3rGeom_State_Commit(); - + if (NULL != splash_screen) { UUtUns16 x_location = (M3rDraw_GetWidth() - splash_screen->width) / 2; UUtUns16 y_location = (M3rDraw_GetHeight() - splash_screen->height) / 2; @@ -642,18 +642,18 @@ ONrGameState_SplashScreen( if (NULL == splash_screen) { goto exit; } - + // stop all currently playing sounds if (inStopPlayingSounds) { OSrSetScriptOnly(UUcTrue); SSrStopAll(); } - + // start the music OSrMusic_Start(inMusicName, 0.0f); OSrMusic_SetVolume(1.0f, 1.0f); - + // fade in from black start_time = UUrMachineTime_Sixtieths(); end_time = start_time + timeout_length; @@ -679,7 +679,7 @@ ONrGameState_SplashScreen( blanket_amount = get_cosmetic_ramp(1.f - blanket_amount); splash_screen_internal(splash_screen, blanket_amount); - + // update the sound SS2rUpdate(); ONrGameState_UpdateSoundManager(ONgGameState, 0); @@ -712,20 +712,20 @@ ONrGameState_SplashScreen( fade_out: // stop the music OSrMusic_SetVolume(0.0f, 1.0f); - + // fade out (can skip with a second keypress) start_time = UUrMachineTime_Sixtieths(); end_time = start_time + fade_length; - + while(1) { UUtUns32 hasty_time = 30; UUtUns32 current_time = UUrMachineTime_Sixtieths(); float blanket_amount = 0.f; - + // update the music SS2rUpdate(); - + if (current_time >= end_time) { break; } @@ -750,7 +750,7 @@ ONrGameState_SplashScreen( } OSrMusic_Halt(); - + if (ONgGameState->local.in_cutscene) { ONgGameState->local.time_cutscene_started_or_wait_for_key_returned_in_machine_time = UUrMachineTime_Sixtieths(); } @@ -787,7 +787,7 @@ ONrGameState_LevelBegin(UUtUns16 inLevelNumber) ONrPersist_SetPlace(&place); } - + ONrUnlockLevel(inLevelNumber); UUrMemory_Clear(ONgGameState, sizeof(*ONgGameState)); @@ -799,7 +799,7 @@ ONrGameState_LevelBegin(UUtUns16 inLevelNumber) M3rGeom_Frame_End(); WaitForKey(60 * 15); } - + ONgGameState->inputEnable = UUcTrue; ONgGameState->inside_console_action = UUcFalse; @@ -814,7 +814,7 @@ ONrGameState_LevelBegin(UUtUns16 inLevelNumber) ONgGameState->local.cameraPlay = UUcFalse; ONgGameState->local.cameraRecording = NULL; ONgGameState->local.cameraActive = UUcFalse; - + // Set up opacity ONgGameState->displayOpacity = UUcTrue; ONgGameState->geometryOpacity = NULL; @@ -826,14 +826,14 @@ ONrGameState_LevelBegin(UUtUns16 inLevelNumber) ONgGameState->local.slowMotionEnable = UUcFalse; ONgGameState->local.slowMotionTimer = 0; - ONgGameState->local.currentPromptMessage = NULL; + ONgGameState->local.currentPromptMessage = NULL; // load the level & set the environment error = TMrInstance_GetDataPtr_ByNumber(ONcTemplate_Level, 0, &ONgLevel); UUmError_ReturnOnErrorMsg(error, "could not load level"); ONgGameState->level = ONgLevel; AKgEnvironment = ONgGameState->level->environment; - + // Allocate physics contexts error = PHrPhysicsContext_New(ONcMaxPhysics); UUmError_ReturnOnError(error); @@ -844,17 +844,17 @@ ONrGameState_LevelBegin(UUtUns16 inLevelNumber) UUmError_ReturnOnErrorMsg(error, "could not create and setup UI"); */ error = ONrCharacter_LevelBegin(); - UUmError_ReturnOnErrorMsg(error, "ONrCharacter_LevelBegin failed"); + UUmError_ReturnOnErrorMsg(error, "ONrCharacter_LevelBegin failed"); ONiGameState_Performance_Install(); // make sure that we have allocated the white texture for the letterbox if (ONgLetterboxTexture == NULL) { IMtPixelType pixelType; - + error = M3rDrawEngine_FindGrayscalePixelType(&pixelType); if (error == UUcError_None) { - error = M3rTextureMap_New(4, 4, pixelType, M3cTexture_AllocMemory, + error = M3rTextureMap_New(4, 4, pixelType, M3cTexture_AllocMemory, M3cTextureFlags_None, "white texture", &ONgLetterboxTexture); if (error == UUcError_None) { @@ -870,10 +870,10 @@ ONrGameState_LevelBegin(UUtUns16 inLevelNumber) ONgGameState->local.fadeInfo.active = UUcFalse; // FX - error = + error = M3rGeomContext_SetEnvironment( ONgGameState->level->environment); - UUmError_ReturnOnErrorMsg(error, "could not set environment"); + UUmError_ReturnOnErrorMsg(error, "could not set environment"); COrConsole_StatusLine_LevelBegin(); ONrGameState_Timer_LevelBegin(); @@ -974,7 +974,7 @@ static void iWriteScreenToFile(BFtFileRef *inFileRef, UUtUns32 inScaleDown) } IMrImage_Scale(IMcScaleMode_Box, width, height, IMcPixelType_RGB888, dst_buffer, scaled_width, scaled_height, dst_buffer_scaled); - + if (NULL != inFileRef) { BFrFile_Delete(inFileRef); @@ -1022,7 +1022,7 @@ static float iGetTurnPerFrame(const ONtInputState *inInput, ONtCharacter *ioChar const float slowTurn = (M3cPi * 1.5f) / 120.f; float turnAmt; - if (ONrCharacter_IsAI(ioCharacter)) { + if (ONrCharacter_IsAI(ioCharacter)) { turnAmt = aiRunningTurn; } else if (inInput->buttonIsDown & LIc_BitMask_Walk) { @@ -1105,7 +1105,7 @@ static void HandleTurnInput(const ONtInputState *inInput, float mousex, float mo // == handle turning if we are in an animation where turning is legal== - if (!TRrAnimation_TestFlag(ioActiveCharacter->animation, ONcAnimFlag_NoTurn)) + if (!TRrAnimation_TestFlag(ioActiveCharacter->animation, ONcAnimFlag_NoTurn)) { float btnTurnAmt = iGetTurnPerFrame(inInput, ioCharacter); @@ -1204,7 +1204,7 @@ static void HandleTurning(const ONtInputState *inInput, float mousex, float mous else { turn = UUcFalse; } - + if (turn) { UUmAssertTrigRange(ioCharacter->facing); @@ -1238,7 +1238,7 @@ UUtBool ONrGameState_TryActionMarker(ONtCharacter *inCharacter, ONtActionMarker if (inActionMarker == NULL) return UUcFalse; - + // check the character is in a valid animtype to use the console if (!ONrCharacter_CanUseConsole(inCharacter)) { if (ONgDebugConsoleAction) { @@ -1368,7 +1368,7 @@ static UUtBool HandleStartTauntOrAction(const ONtInputState *inInput, ONtCharact ONrCharacter_ConsoleAction_Update(ioCharacter, ioActiveCharacter); return UUcTrue; } - + // if the action key wasnt pressed, exit... if ((inInput->buttonWentDown & LIc_BitMask_Action) == 0) { return UUcFalse; @@ -1509,7 +1509,7 @@ static UUtBool HandlePriorAction(const ONtInputState *inInput, ONtCharacter *ioC case ONcAnimType_Run_Kick: case ONcAnimType_Run_Punch: - + case ONcAnimType_Run_Back_Punch: case ONcAnimType_Run_Back_Kick: @@ -1848,7 +1848,7 @@ static UUtBool HandleStartSidestep(const ONtInputState *inInput, ONtCharacter *i animFound = UUcFalse; - for(itr = 0; itr < 4; itr++) + for(itr = 0; itr < 4; itr++) { if (ONcAnimType_None != runWalk[itr]) { @@ -1862,7 +1862,7 @@ static UUtBool HandleStartSidestep(const ONtInputState *inInput, ONtCharacter *i } // second, try starting to move in this direction - switch(runWalk[itr]) + switch(runWalk[itr]) { case ONcAnimType_Run: start_type = ONcAnimType_Run_Start; @@ -1921,7 +1921,7 @@ static UUtBool HandleStartSidestep(const ONtInputState *inInput, ONtCharacter *i if (animFound) { // if we actually ended up finding a forwards or backwards animation, set up // the facing modifier appropriately - switch(TRrAnimation_GetType(ioActiveCharacter->animation)) + switch(TRrAnimation_GetType(ioActiveCharacter->animation)) { case ONcAnimType_Crouch_Walk: case ONcAnimType_Crouch_Run: @@ -1958,7 +1958,7 @@ static UUtBool HandleStartRunning(const ONtInputState *inInput, ONtCharacter *io { 0, LIc_BitMask_Forward | LIc_BitMask_Walk, ONcAnimType_None, ONcAnimType_Walk , UUcFalse }, { 0, LIc_BitMask_Backward | LIc_BitMask_Walk, ONcAnimType_None, ONcAnimType_Walk_Backwards_Start , UUcFalse }, { 0, LIc_BitMask_Backward | LIc_BitMask_Walk, ONcAnimType_None, ONcAnimType_Walk_Backwards , UUcFalse }, - + { 0, LIc_BitMask_Forward, ONcAnimType_None, ONcAnimType_Run_Start , UUcFalse }, { 0, LIc_BitMask_Forward, ONcAnimType_None, ONcAnimType_Run , UUcFalse }, { 0, LIc_BitMask_Forward, ONcAnimType_None, ONcAnimType_Walk_Start , UUcFalse }, @@ -1983,12 +1983,12 @@ static UUtBool HandleStartRunning(const ONtInputState *inInput, ONtCharacter *io const ONtMoveLookup crouch_table[] = { - { 0, LIc_BitMask_Crouch | + { 0, LIc_BitMask_Crouch | LIc_BitMask_Walk | LIc_BitMask_Forward, ONcAnimType_None, ONcAnimType_Crouch_Walk , UUcFalse }, { 0, LIc_BitMask_Crouch | LIc_BitMask_Forward, ONcAnimType_None, ONcAnimType_Crouch_Run , UUcFalse }, { 0, LIc_BitMask_Crouch | LIc_BitMask_Forward, ONcAnimType_None, ONcAnimType_Crouch_Walk , UUcFalse }, - { 0, LIc_BitMask_Crouch | + { 0, LIc_BitMask_Crouch | LIc_BitMask_Walk | LIc_BitMask_Backward, ONcAnimType_None, ONcAnimType_Crouch_Walk_Backwards , UUcFalse }, { 0, LIc_BitMask_Crouch | LIc_BitMask_Backward, ONcAnimType_None, ONcAnimType_Crouch_Run_Backwards , UUcFalse }, { 0, LIc_BitMask_Crouch | LIc_BitMask_Backward, ONcAnimType_None, ONcAnimType_Crouch_Walk_Backwards , UUcFalse }, @@ -2029,7 +2029,7 @@ static UUtBool HandleStartRunning(const ONtInputState *inInput, ONtCharacter *io } // ok if you are running and sidestepping you get rotation - switch(TRrAnimation_GetType(found_anim)) + switch(TRrAnimation_GetType(found_anim)) { case ONcAnimType_Walk_Backwards: case ONcAnimType_Walk_Backwards_Start: @@ -2109,7 +2109,7 @@ static UUtBool HandleStop(const ONtInputState *inInput, ONtCharacter *ioCharacte case ONcAnimType_Walk_Sidestep_Left: case ONcAnimType_Walk_Sidestep_Right: - case ONcAnimType_Crouch_Run: + case ONcAnimType_Crouch_Run: case ONcAnimType_Crouch_Run_Backwards: case ONcAnimType_Crouch_Run_Sidestep_Left: case ONcAnimType_Crouch_Run_Sidestep_Right: @@ -2134,7 +2134,7 @@ static UUtBool HandleLeaveStun(const ONtInputState *inInput, ONtCharacter *ioCha { 0, LIc_BitMask_Crouch, ONcAnimType_None, ONcAnimType_Crouch, UUcFalse }, { 0, 0, ONcAnimType_None, ONcAnimType_Stand, UUcFalse }, { 0, 0, ONcAnimType_None, ONcAnimType_Crouch, UUcFalse }, - { 0, 0, ONcAnimType_None, ONcAnimType_None, UUcFalse }, + { 0, 0, ONcAnimType_None, ONcAnimType_None, UUcFalse }, }; switch(ioActiveCharacter->curAnimType) @@ -2160,13 +2160,13 @@ static UUtBool HandleChangeStance(const ONtInputState *inInput, ONtCharacter *io const ONtMoveLookup crouchTable[] = { { 0, LIc_BitMask_Crouch, ONcAnimType_None, ONcAnimType_Crouch, UUcFalse }, - { 0, 0, ONcAnimType_None, ONcAnimType_None, UUcFalse }, + { 0, 0, ONcAnimType_None, ONcAnimType_None, UUcFalse }, }; const ONtMoveLookup standTable[] = { { 0, 0, ONcAnimType_None, ONcAnimType_Stand, UUcFalse }, - { 0, 0, ONcAnimType_None, ONcAnimType_None, UUcFalse }, + { 0, 0, ONcAnimType_None, ONcAnimType_None, UUcFalse }, }; switch(ioActiveCharacter->nextAnimState) @@ -2193,7 +2193,7 @@ static UUtBool HandleChangeStance(const ONtInputState *inInput, ONtCharacter *io animFound = DoTableAnimation(inInput, ioCharacter, ioActiveCharacter, standTable, ONcAnimPriority_Appropriate, ONcNormalMove, NULL); if (animFound) { goto exit; } } - break; + break; } exit: @@ -2213,7 +2213,7 @@ static UUtBool HandleFallThrough(const ONtInputState *inInput, ONtCharacter *ioC { { 0, LIc_BitMask_Crouch, ONcAnimType_None, ONcAnimType_Crouch, UUcFalse }, { 0, LIc_BitMask_Crouch, ONcAnimType_None, ONcAnimType_Prone, UUcFalse }, - { 0, 0, ONcAnimType_None, ONcAnimType_None , UUcFalse }, + { 0, 0, ONcAnimType_None, ONcAnimType_None , UUcFalse }, }; const ONtMoveLookup standTable[] = @@ -2226,7 +2226,7 @@ static UUtBool HandleFallThrough(const ONtInputState *inInput, ONtCharacter *ioC { 0, 0, ONcAnimType_None, ONcAnimType_Stand, UUcFalse }, { 0, 0, ONcAnimType_None, ONcAnimType_Crouch, UUcFalse }, { 0, 0, ONcAnimType_None, ONcAnimType_Prone, UUcFalse }, - { 0, 0, ONcAnimType_None, ONcAnimType_None, UUcFalse }, + { 0, 0, ONcAnimType_None, ONcAnimType_None, UUcFalse }, }; in_bad_varient = ONrCharacter_InBadVarientState(ioCharacter, ioActiveCharacter); @@ -2269,9 +2269,9 @@ static UUtBool HandleFallThrough(const ONtInputState *inInput, ONtCharacter *ioC goto exit; } } - + // if we are in a jump then the default action is to fly - switch(ioActiveCharacter->curAnimType) + switch(ioActiveCharacter->curAnimType) { case ONcAnimType_Fly: case ONcAnimType_Jump: @@ -2375,7 +2375,7 @@ static UUtBool HandleStandingTurn(const ONtInputState *inInput, ONtCharacter *io const float turnStart = ONgAimingWidth * M3cDegToRad; UUtBool found; const float desire = ONrCharacter_GetDesiredFacingOffset(ioCharacter); - float turnPerFrame = iGetTurnPerFrame(inInput, ioCharacter); + float turnPerFrame = iGetTurnPerFrame(inInput, ioCharacter); const ONtMoveLookup turn_left_table[] = { @@ -2417,7 +2417,7 @@ static const TRtAnimation *DoTableLookup(const ONtInputState *inInput, ONtCharac const ONtMoveLookup *curEntry; ONtCharacterClass *characterClass = ioCharacter->characterClass; TRtAnimationCollection *collection = characterClass->animations; - + UUmAssertReadPtr(inInput, sizeof(*inInput)); UUmAssertWritePtr(ioCharacter, sizeof(*ioCharacter)); UUmAssertReadPtr(table, sizeof(*table)); @@ -2433,7 +2433,7 @@ static const TRtAnimation *DoTableLookup(const ONtInputState *inInput, ONtCharac *outAnimType = curEntry->moveType; } - return animFound; + return animFound; } } @@ -2451,7 +2451,7 @@ static UUtBool DoTableAnimation(const ONtInputState *inInput, ONtCharacter *ioCh const ONtMoveLookup *curEntry; UUtBool call_fight_mode = ONcAttackMove == attackMove; TRtAnimVarient originalVarient = ioActiveCharacter->animVarient; - + animFound = UUcFalse; UUmAssertReadPtr(inInput, sizeof(*inInput)); @@ -2478,7 +2478,7 @@ static UUtBool DoTableAnimation(const ONtInputState *inInput, ONtCharacter *ioCh } if (animFound) { - break; + break; } } @@ -2489,7 +2489,7 @@ static UUtBool DoTableAnimation(const ONtInputState *inInput, ONtCharacter *ioCh if (call_fight_mode) { if (NULL != animFound) { TRtAnimVarient varient = TRrAnimation_GetVarient(animFound); - + if (varient & ONcAnimVarientMask_Fight) { ONrCharacter_FightMode(ioCharacter); } @@ -2530,7 +2530,7 @@ static UUtBool HandleStartJumping(const ONtInputState *inInput, ONtCharacter *io { 0, 0, ONcAnimType_None, ONcAnimType_Jump, UUcFalse }, { 0, 0, ONcAnimType_None, ONcAnimType_None, UUcFalse }, }; - + if (!(inInput->buttonWentDown & LIc_BitMask_Jump)) { return UUcFalse; @@ -2546,7 +2546,7 @@ static UUtBool HandleStartJumping(const ONtInputState *inInput, ONtCharacter *io return UUcFalse; break; } - + ONrCharacter_BuildJump(ioCharacter, ioActiveCharacter); animFound = DoTableAnimation(inInput, ioCharacter, ioActiveCharacter, table, ONcAnimPriority_Appropriate, ONcNormalMove, NULL); @@ -2559,7 +2559,7 @@ static UUtBool HandleStartJumping(const ONtInputState *inInput, ONtCharacter *io return animFound; } -static void ONiGameState_FindPickupItems(ONtCharacter *ioCharacter, WPtWeapon **outWeapon, +static void ONiGameState_FindPickupItems(ONtCharacter *ioCharacter, WPtWeapon **outWeapon, WPtPowerup **outPowerup, UUtBool *outPowerupInventoryFull) { float min_y = ioCharacter->location.y + ONcStartPickupMinY; @@ -2687,7 +2687,7 @@ static UUtBool HandleStartLanding(const ONtInputState *inInput, ONtCharacter *io { 0, 0, ONcAnimType_None, ONcAnimType_Land, UUcFalse }, { 0, 0, ONcAnimType_None, ONcAnimType_None, UUcFalse } }; - + if (!(ioActiveCharacter->pleaseLand)) { return UUcFalse; } @@ -2696,7 +2696,7 @@ static UUtBool HandleStartLanding(const ONtInputState *inInput, ONtCharacter *io TRtAnimState old_anim_state = ioActiveCharacter->nextAnimState; animFound = DoTableAnimation(inInput, ioCharacter, ioActiveCharacter, land_hard_table, ONcAnimPriority_Force, ONcNormalMove, NULL); - + if (!animFound) { ioActiveCharacter->nextAnimState = ONcAnimState_Falling; animFound = DoTableAnimation(inInput, ioCharacter, ioActiveCharacter, land_hard_table, ONcAnimPriority_Force, ONcNormalMove, NULL); @@ -2711,7 +2711,7 @@ static UUtBool HandleStartLanding(const ONtInputState *inInput, ONtCharacter *io ioActiveCharacter->nextAnimState = old_anim_state; } } - + if (!animFound) { animFound = DoTableAnimation(inInput, ioCharacter, ioActiveCharacter, land_table, ONcAnimPriority_Force, ONcNormalMove, NULL); } @@ -2811,7 +2811,7 @@ static void ONiCycle_Weapon(const ONtInputState *inInput) WPtWeaponClass *weapon_class[64]; UUtUns32 num_classes; UUtUns32 i; - + UUmAssertReadPtr(localActiveCharacter, sizeof(*localActiveCharacter)); // can't do this while running a reload or holster animation @@ -2826,7 +2826,7 @@ static void ONiCycle_Weapon(const ONtInputState *inInput) 64, &num_classes, weapon_class); - + // find the weapon class of the weapon currently in use by the character if (localCharacter->inventory.weapons[0]) { @@ -2839,12 +2839,12 @@ static void ONiCycle_Weapon(const ONtInputState *inInput) { i = 0; } - + // pick the index of the next weapon to use if (inInput->buttonIsDown & LIc_BitMask_Crouch) { i--; - + if (i >= num_classes) { i = num_classes - 1; @@ -2853,7 +2853,7 @@ static void ONiCycle_Weapon(const ONtInputState *inInput) else { i++; - + if (i >= num_classes) { i = 0; @@ -2874,7 +2874,7 @@ static void ONiCycle_Class(const ONtInputState *inInput) UUtUns16 numClasses = (UUtUns16)TMrInstance_GetTagCount(TRcTemplate_CharacterClass); if (localCharacter == NULL) return; - + if (inInput->buttonIsDown & LIc_BitMask_Crouch) { localCharacter->characterClassNumber += numClasses - 1; } @@ -2885,13 +2885,13 @@ static void ONiCycle_Class(const ONtInputState *inInput) if (numClasses > 0) { localCharacter->characterClassNumber = localCharacter->characterClassNumber % numClasses; - error = TMrInstance_GetDataPtr_ByNumber(TRcTemplate_CharacterClass, localCharacter->characterClassNumber, &newClass); + error = TMrInstance_GetDataPtr_ByNumber(TRcTemplate_CharacterClass, localCharacter->characterClassNumber, &newClass); if ((newClass != NULL) && (UUcError_None == error)) { ONrCharacter_SetCharacterClass(localCharacter, newClass); - COrConsole_Printf("character class %d %s", - localCharacter->characterClassNumber, + COrConsole_Printf("character class %d %s", + localCharacter->characterClassNumber, TMrInstance_GetInstanceName(newClass)); } } @@ -3145,7 +3145,7 @@ void ONrGameState_HandleCheats(const LItInputEvent *inEvent) //COrConsole_Printf("cheater %s", test_cheat->cheat_string); enabled = ONrCheater(test_cheat->cheat_code); message = (enabled) ? test_cheat->cheat_message1 : test_cheat->cheat_message2; - + if (message != NULL) { ONrPauseScreen_OverrideMessage(message); } @@ -3170,10 +3170,10 @@ ONrGameState_DropFlag( OBJtObject *object; M3tPoint3D rotation; UUtError error; - + // calculate the facing MUmVector_Set(rotation, 0.0f, inDesiredFacing * M3cRadToDeg, 0.0f); - + // create the new object error = OBJrObject_New(OBJcType_Flag, inLocation, &rotation, NULL); if (error != UUcError_None) { @@ -3190,14 +3190,14 @@ ONrGameState_DropFlag( if (inPrintMsg) { char name[OBJcMaxNameLength + 1]; - + OBJrObject_GetName(object, name, OBJcMaxNameLength); COrConsole_Printf("flag %s added", name); } UUmAssert(object->object_type == OBJcType_Flag); flag_osd = (OBJtOSD_Flag *) object->object_data; - + if (outID) *outID = flag_osd->id_number; return UUcTrue; @@ -3213,7 +3213,7 @@ DeleteFlag( ONtFlag flag; float max_distance_squared = UUmSQR(15.f); UUtBool found; - + // get the closest flag found = ONrLevel_Flag_Location_To_Flag(inLocation, &flag); if (found == UUcFalse) @@ -3221,13 +3221,13 @@ DeleteFlag( COrConsole_Printf("could not find flag"); return; } - + if (MUrPoint_Distance_Squared(inLocation, &flag.location) > max_distance_squared) { COrConsole_Printf("not close enough to flag"); return; } - + ONrLevel_Flag_Delete(flag.idNumber); } @@ -3245,7 +3245,7 @@ static void WriteCameraRecord(void) UUtInt32 fileRefItr; BFtFileRef *fileRef; - for(fileRefItr = 0; fileRefItr < 100; fileRefItr++) + for(fileRefItr = 0; fileRefItr < 100; fileRefItr++) { char fileString[128]; sprintf(fileString, "cameraRecord%d.eva", fileRefItr); @@ -3283,7 +3283,7 @@ static void WriteCameraRecord(void) } // write animation data - BFrFile_Write(file, sizeof(*pHeader), pHeader); + BFrFile_Write(file, sizeof(*pHeader), pHeader); BFrFile_Write(file, sizeof(AXtNode), pHeader->nodes); BFrFile_Write(file, sizeof(M3tMatrix4x3) * pHeader->numFrames, pHeader->nodes[0].matricies); @@ -3445,7 +3445,7 @@ void ONrGameState_HandleUtilityInput(const ONtInputState* inInput) if (inInput->buttonWentDown & LIc_BitMask_F7) { if (inInput->buttonIsDown & LIc_BitMask_Action) { ONrCharacter_Knockdown(NULL, localCharacter, ONcAnimType_Knockdown_Head); - } + } else { ONiCycle_Weapon(inInput); } @@ -3505,7 +3505,7 @@ void ONrGameState_HandleUtilityInput(const ONtInputState* inInput) float unstick_z; unstick_r = M3c2Pi - localCharacter->facing; - unstick_r += M3cHalfPi; + unstick_r += M3cHalfPi; UUmTrig_Clip(unstick_r); unstick_x = MUrCos(unstick_r); @@ -3526,7 +3526,7 @@ void ONrGameState_HandleUtilityInput(const ONtInputState* inInput) if (ONrDebugKey_WentDown(ONcDebugKey_CharToCamera)) { ONtCharacter *character; - + // set the character's location to the camera's location character = ONrGameState_GetPlayerCharacter(); @@ -3550,10 +3550,10 @@ void ONrGameState_HandleUtilityInput(const ONtInputState* inInput) ONrCharacter_EnablePhysics(localCharacter); UUmAssert(localActiveCharacter->physics != NULL); } - + localActiveCharacter->physics->position = CArGetLocation(); character->location = localActiveCharacter->physics->position; - + // set the camera to follow mode CArFollow_Enter(); } @@ -3633,8 +3633,8 @@ static UUtBool HandleSpecialAnim(const ONtInputState *inInput, ONtCharacter *ioC if (newAnimation != NULL) { ONrCharacter_SetAnimation_External( - ioCharacter, - ioActiveCharacter->nextAnimState, + ioCharacter, + ioActiveCharacter->nextAnimState, newAnimation, interpolation); @@ -3682,7 +3682,7 @@ static UUtBool ONrCharacter_IsBeingThrown(ONtActiveCharacter *ioActiveCharacter) return is_being_thrown; } - + // handle input for a character for a single game tick void ONrCharacter_HandleHeartbeatInput(ONtCharacter *ioCharacter, ONtActiveCharacter *ioActiveCharacter) @@ -3713,7 +3713,7 @@ void ONrCharacter_HandleHeartbeatInput(ONtCharacter *ioCharacter, ONtActiveChara if (ioActiveCharacter->animationLockFrames > 0) { goto exit; } - + // make sure we are called <= once per tick UUmAssert(ioActiveCharacter->lastHeartbeat != ONgGameState->gameTime); ioActiveCharacter->lastHeartbeat = ONgGameState->gameTime; @@ -3753,7 +3753,7 @@ void ONrCharacter_HandleHeartbeatInput(ONtCharacter *ioCharacter, ONtActiveChara } } - if ((ioCharacter->flags2 & ONcCharacterFlag2_WeaponEmpty) || + if ((ioCharacter->flags2 & ONcCharacterFlag2_WeaponEmpty) || ONrOverlay_IsActive(ioActiveCharacter->overlay + ONcOverlayIndex_InventoryManagement)) { // character cannot fire @@ -3793,7 +3793,7 @@ void ONrCharacter_HandleHeartbeatInput(ONtCharacter *ioCharacter, ONtActiveChara } HandleMouseInput(&input, input.turnLR, input.turnUD, ioCharacter, ioActiveCharacter); - + ONrCharacter_HandlePickupInput(&input, ioCharacter, ioActiveCharacter); old_next_anim_type = ioActiveCharacter->nextAnimType; @@ -3807,7 +3807,7 @@ void ONrCharacter_HandleHeartbeatInput(ONtCharacter *ioCharacter, ONtActiveChara found = HandleSpecialAnim(&input, ioCharacter, ioActiveCharacter); if (found) { ONrCharacter_DebugHandle("HandleSpecialAnim"); break; } - + found = HandleStartLanding(&input, ioCharacter, ioActiveCharacter); if (found) { ONrCharacter_DebugHandle("HandleStartLanding"); break; } @@ -3816,7 +3816,7 @@ void ONrCharacter_HandleHeartbeatInput(ONtCharacter *ioCharacter, ONtActiveChara found = HandleStun(&input, ioCharacter, ioActiveCharacter); if (found) { ONrCharacter_DebugHandle("HandleStun"); break; } - + found = HandleLeaveStun(&input, ioCharacter, ioActiveCharacter); if (found) { ONrCharacter_DebugHandle("HandleLeaveStun"); break; } @@ -3911,14 +3911,14 @@ ONrInput_Update_Keys( LItButtonBits wentUp; UUmAssertWritePtr(ioInput, sizeof(ONtInputState)); - + lastUp = ioInput->buttonIsUp; lastDown = ioInput->buttonIsDown; currentUp = ~inNewDown; currentDown = inNewDown; - wentUp = (currentUp) & (lastDown); + wentUp = (currentUp) & (lastDown); wentDown = (currentDown) & (lastUp); ioInput->buttonIsUp = currentUp; @@ -3975,24 +3975,24 @@ static void ONiGameState_ProcessMiscActions(ONtGameState *ioGameState) } } } - + if (!ONgDeveloperAccess) { return; } - + if (ioGameState->local.localInput.buttonWentDown & LIc_BitMask_Console) { COrConsole_Activate(); - + // OWrConsole_Toggle(); } - + if (ONrDebugKey_WentDown(ONcDebugKey_ProfileToggle)) { #if defined(PROFILE) && PROFILE UUtProfileState profileState = UUrProfile_State_Get(); - + profileState = (UUtProfileState)!profileState; - + if(profileState == UUcProfile_State_On) { COrConsole_Printf("Profile on"); @@ -4001,9 +4001,9 @@ static void ONiGameState_ProcessMiscActions(ONtGameState *ioGameState) { COrConsole_Printf("Profile off"); } - + UUrProfile_State_Set(profileState); - + #endif } } @@ -4014,7 +4014,7 @@ UUtError ONrGameState_ProcessActions( if (NULL != inActionBuffer) { ONiGameState_ProcessMiscActions(ONgGameState); } - + return UUcError_None; } @@ -4029,7 +4029,7 @@ LItButtonBits ONiRemapKeys(LItButtonBits currentDown) if (localCharacter->neutral_interaction_char != NULL) { // neutral-character interaction... mask out user input but still allow illusion of control. - + if (currentDown & LIc_BitMask_NeutralAbort) { // the character wants to abort right now, let them AI2rNeutral_Stop(localCharacter, UUcFalse, UUcTrue, UUcFalse, UUcTrue); @@ -4050,7 +4050,7 @@ LItButtonBits ONiRemapKeys(LItButtonBits currentDown) localCharacter->neutral_keyabort_frames -= 2; } } - + if (localCharacter->neutral_interaction_char != NULL) { // lock out any keypresses that would stop the neutral interaction currentDown &= ~LIc_BitMask_NeutralLockOut; @@ -4118,7 +4118,7 @@ static void ONrGameState_UpdateConditionSounds(void) } else { ONrGameState_ConditionSound_Stop(ONcConditionSound_HealthLow); } - + if (player->hitPoints > player->maxHitPoints) { // determine the amount of boosted health volume = (player->hitPoints - player->maxHitPoints) / @@ -4187,7 +4187,7 @@ ONrGameState_ProcessHeartbeat( UUtStallTimer heartbeat; UUtStallTimer heartbeat_internal; - + #if defined(BRENTS_CHEESY_GSU_PERF) && BRENTS_CHEESY_GSU_PERF UUtUns64 time_start; @@ -4198,20 +4198,20 @@ ONrGameState_ProcessHeartbeat( UUtInt64 time_chr_start; UUtUns32 time_chr = 0; float time_chr_per_gsu; - + UUtInt64 time_phs_start; UUtUns32 time_phs = 0; float time_phs_per_gsu; - + UUtInt64 time_prt_start; UUtUns32 time_prt = 0; float time_prt_per_gsu; - + char s1[128], s2[128]; - + time_start = UUrMachineTime_High(); - // clear the timing counts + // clear the timing counts time_ai = 0; #endif @@ -4289,7 +4289,7 @@ ONrGameState_ProcessHeartbeat( currentDown = ONiGameState_ScanButtons(inAction); currentDown = ONiRemapKeys(currentDown); - + ONrInput_Update_Keys(&(ONgGameState->local.localInput), currentDown); if (ONgGameState->gameTime < 14) { @@ -4309,7 +4309,7 @@ ONrGameState_ProcessHeartbeat( } // ONrNet_NetCharacterUpdate(); - + // Update the AI UUrStallTimer_Begin(&heartbeat_internal); @@ -4326,19 +4326,19 @@ ONrGameState_ProcessHeartbeat( // Update the characters #if defined(BRENTS_CHEESY_GSU_PERF) && BRENTS_CHEESY_GSU_PERF - + time_chr_start = UUrMachineTime_High(); - + #endif ONrGameState_UpdateCharacters(); - + #if defined(BRENTS_CHEESY_GSU_PERF) && BRENTS_CHEESY_GSU_PERF - + time_chr += (UUtUns32)(UUrMachineTime_High() - time_chr_start); - + #endif - + // update the sky //ONrSky_Update( &ONgGameState->sky ); @@ -4352,45 +4352,45 @@ ONrGameState_ProcessHeartbeat( // Update the physics #if defined(BRENTS_CHEESY_GSU_PERF) && BRENTS_CHEESY_GSU_PERF - + time_phs_start = UUrMachineTime_High(); - + #endif PHrPhysicsContext_Update(); - + #if defined(BRENTS_CHEESY_GSU_PERF) && BRENTS_CHEESY_GSU_PERF - + time_phs += (UUtUns32)(UUrMachineTime_High() - time_phs_start); - + #endif - + // Update the particles #if defined(BRENTS_CHEESY_GSU_PERF) && BRENTS_CHEESY_GSU_PERF - + time_prt_start = UUrMachineTime_High(); - + #endif // update all essential P3 particles for one heartbeat P3rUpdate(ONgGameState->gameTime + 1, UUcTrue); - + #if defined(BRENTS_CHEESY_GSU_PERF) && BRENTS_CHEESY_GSU_PERF - + time_prt += (UUtUns32)(UUrMachineTime_High() - time_prt_start); - + #endif UUrStallTimer_Begin(&heartbeat_internal); OBrList_Update(ONgGameState->objects); UUrStallTimer_End(&heartbeat_internal, "ONrGameState_ProcessHeartbeat - OBrList_Update"); - + // update the cinematics UUrStallTimer_Begin(&heartbeat_internal); OCrCinematic_Update(); UUrStallTimer_End(&heartbeat_internal, "ONrGameState_ProcessHeartbeat - OCrCinematic_Update"); - + // update the in-game UI UUrStallTimer_Begin(&heartbeat_internal); ONrInGameUI_Update(); @@ -4405,17 +4405,17 @@ ONrGameState_ProcessHeartbeat( } #if defined(BRENTS_CHEESY_GSU_PERF) && BRENTS_CHEESY_GSU_PERF - + if(ONgShowPerformance_GSU) { - + time_total = (UUtUns32)(UUrMachineTime_High() - time_start); - + time_ai_per_gsu = (float)time_ai / (float)time_total; time_chr_per_gsu = (float)time_chr / (float)time_total; time_phs_per_gsu = (float)time_phs / (float)time_total; time_prt_per_gsu = (float)time_prt / (float)time_total; - + sprintf( s1, "gsu, ai: %02.1f, chr: %02.1f", @@ -4426,13 +4426,13 @@ ONrGameState_ProcessHeartbeat( "gsu, phs: %02.1f, prt: %02.1f", time_phs_per_gsu * 100.0f, time_prt_per_gsu * 100.0f); - + ONrGameState_Performance_UpdateGSU( s1, s2, ""); } - + #endif UUrStallTimer_End(&heartbeat, "ONrGameState_ProcessHeartbeat"); @@ -4452,9 +4452,9 @@ static UUtError ONrGameState_UpdateSoundManager(ONtGameState *ioGameState, UUtUn M3tPoint3D location; M3tPoint3D facing; CAtCamera *camera; - + camera = ONgGameState->local.camera; - + // determine which mode to use if ((camera->mode == CAcMode_Follow) && (ONgGameState->local.playerCharacter != NULL)) { // set listener at character @@ -4471,9 +4471,9 @@ static UUtError ONrGameState_UpdateSoundManager(ONtGameState *ioGameState, UUtUn location = CArGetLocation(); facing = CArGetFacing(); } - + OSrUpdate(&location, &facing); - + return UUcError_None; } @@ -4501,7 +4501,7 @@ static UUtUns8 iComputeDeltaTicks(ONtGameState *ioGameState) ioGameState->local.sync_frames_behind = 0; } - engine_delta_ticks = timing_delta_ticks; + engine_delta_ticks = timing_delta_ticks; engine_delta_ticks = UUmMin(engine_delta_ticks, cMaxTicksPerFrame); @@ -4512,7 +4512,7 @@ static UUtUns8 iComputeDeltaTicks(ONtGameState *ioGameState) if (ONrDebugKey_WentDown(ONcDebugKey_SingleStep)) { engine_delta_ticks = 1; } - } + } else if ((ONgDrawEveryFrame) || (ONgGameState->local.recordScreen)) { engine_delta_ticks = ONgDrawEveryFrameMultiple; } @@ -4558,7 +4558,7 @@ static void Testing_Update(void) }; KeyBindEntry *current_binding; - + for(current_binding = key_bindings; current_binding->variable != NULL; current_binding++) { if (ONrDebugKey_WentDown(current_binding->keyCode)) { @@ -4591,7 +4591,7 @@ UUtError ONrGameState_Update( if (ONgGameState->local.in_cutscene) { static UUtBool old_space_was_down = UUcFalse; UUtBool space_went_down = LIrKeyWentDown(LIcKeyCode_Space, &old_space_was_down); - + if (space_went_down) { // ONrGameState_SkipCutscene(); } @@ -4606,15 +4606,15 @@ UUtError ONrGameState_Update( deltaTicks = 2; #endif #endif - + // ** call the heartbeat for(itr = 0; itr < deltaTicks; itr++) { LItAction *action; - + if (itr < numActionsInBuffer) { action = actionBuffer + itr; - } + } else { action = NULL; } @@ -4630,13 +4630,13 @@ UUtError ONrGameState_Update( #endif CArUpdate(0, numActionsInBuffer, actionBuffer); - + // record the screen if requested if (ONgGameState->local.recordScreen) { iScreenShot(ONgScreenShotReduceAmount); } - + // update all decorative particles to match the current game time P3rUpdate(ONgGameState->gameTime, UUcFalse); @@ -4645,7 +4645,7 @@ UUtError ONrGameState_Update( error = ONrGameState_UpdateSoundManager(ONgGameState, deltaTicks); // update_status_bar(deltaTicks) - + // check to see if we need to autosave binary data files OBDrUpdate(ONgGameState->gameTime); @@ -4679,7 +4679,7 @@ typedef struct Display_Performance_Variables UUtInt64 time_obj; UUtInt64 time_prt; } Display_Performance_Variables; - + static void ONi_GameState_Display_All_UI_Elements(Display_Performance_Variables *inPerfVar) { const UUtUns16 screen_width = M3rDraw_GetWidth(); @@ -4698,24 +4698,24 @@ static void ONi_GameState_Display_All_UI_Elements(Display_Performance_Variables } #if defined(BRENTS_CHEESY_GSD_PERF) && BRENTS_CHEESY_GSD_PERF - + if(ONgShowPerformance_GSD) - { - double time_total = (double) inPerfVar->time_total; + { + double time_total = (double) inPerfVar->time_total; double time_env_per_gsd; double time_chr_per_gsd; double time_obj_per_gsd; double time_prt_per_gsd; - + char s1[128], s2[128], s3[128]; extern UUtUns16 ONgNumCharactersDrawn; - + time_env_per_gsd = inPerfVar->time_env / time_total; time_chr_per_gsd = inPerfVar->time_chr / time_total; time_obj_per_gsd = inPerfVar->time_obj / time_total; time_prt_per_gsd = inPerfVar->time_prt / time_total; - + sprintf( s1, "gsd, env: %02.1f, chr: %02.1f obj: %02.1f, prt: %02.1f", @@ -4729,8 +4729,8 @@ static void ONi_GameState_Display_All_UI_Elements(Display_Performance_Variables static UUtUns32 highDownloadTime = 0; char downloadStr[32]; char maxDownloadStr[32]; - - + + if ((ONgPerformanceData.textureDownload > highDownload) || (UUrMachineTime_Sixtieths() > (highDownloadTime+120))) { highDownload = ONgPerformanceData.textureDownload; @@ -4744,7 +4744,7 @@ static void ONi_GameState_Display_All_UI_Elements(Display_Performance_Variables s2, "gsd, texture = %s max %s M", downloadStr, maxDownloadStr); } - + sprintf( s3, "nc: %02d, np: %04d, nq: %05d, na: %04d", @@ -4752,7 +4752,7 @@ static void ONi_GameState_Display_All_UI_Elements(Display_Performance_Variables 0, // counter for num particles goes here ONgPerformanceData.numTriSplits + ONgPerformanceData.numQuadSplits * 2 + ONgPerformanceData.numPentSplits * 3, ONgPerformanceData.numAlphaSortedObjs); - + ONrGameState_Performance_UpdateGSD( s1, s2, @@ -4804,22 +4804,22 @@ static void ONrBlanketScreen(float inA, float inR, float inG, float inB) intB = (UUtUns8) MUrUnsignedSmallFloat_To_Uns_Round(inB * 255.f); intShade = (intR << 16) | (intG << 8) | (intB); - + M3rDraw_State_Push(); - + M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, intShade); M3rDraw_State_SetInt(M3cDrawStateIntType_Alpha, MUrUnsignedSmallFloat_To_Uns_Round(M3cMaxAlpha * inA)); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, ONgLetterboxTexture); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); - + M3rDraw_State_Commit(); - + M3rDraw_Sprite( dest, uv); @@ -4956,7 +4956,7 @@ static void ONiGameState_Display_Overlay_Elements(Display_Performance_Variables #else ONi_GameState_Display_All_UI_Elements(NULL); #endif - + SSrShowDebugInfo(); if (ONgFontCache_Display) { @@ -4965,20 +4965,20 @@ static void ONiGameState_Display_Overlay_Elements(Display_Performance_Variables COrConsole_StatusLine_Display(); - ONi_GameState_Display_FadeInOut(); + ONi_GameState_Display_FadeInOut(); if ((!ONgGameState->local.letterbox.active) && (!ONgGameState->local.fadeInfo.active)) { // Display the text messages COrConsole_Display_Messages(); } - + // Display the console COrConsole_Display_Lines(); // draw the cinematics OCrCinematic_Draw(); - ONi_GameState_Display_SkipCutsceneFade(); + ONi_GameState_Display_SkipCutsceneFade(); COrConsole_Display_Console(); M3rGeom_State_Pop(); @@ -4990,7 +4990,7 @@ static void ONiGameState_Display_Overlay_Elements(Display_Performance_Variables static void ONiGameState_Display_NonReflectable_Tool(Display_Performance_Variables *ioPerfVars) { if (ONgShowQuadCount) { - sprintf(quad_count_display[1].text, "quad count %d / %d", + sprintf(quad_count_display[1].text, "quad count %d / %d", AKrEnvironment_GetVisCount(ONgGameState->level->environment), ONgGameState->level->environment->gqRenderArray->numGQs); } @@ -5006,10 +5006,10 @@ static void ONiGameState_Display_NonReflectable_Tool(Display_Performance_Variabl } } - sprintf(object_count_display[1].text, "object count %d/%d [watermark %d]", + sprintf(object_count_display[1].text, "object count %d/%d [watermark %d]", object_count, ONgGameState->objects->maxObjects, ONgGameState->objects->numObjects); } - + if (ONgShowPhysicsCount) { UUtUns32 physics_itr; UUtUns32 physics_count = 0; @@ -5043,21 +5043,21 @@ ONiGameState_Display_NonReflectable( M3tGeomCamera* activeCamera; UUtBool render_sky_this_frame = UUcTrue; UUtBool is_skipping_cutscene = (ONgGameState->local.in_cutscene) && (ONcCutsceneSkip_skipping == ONgGameState->local.cutscene_skip_mode); - + // start the environment if (ONgShow_Environment) - { + { #if defined(BRENTS_CHEESY_GSD_PERF) && BRENTS_CHEESY_GSD_PERF ioPerfVars->time_env -= UUrMachineTime_High(); #endif - + M3rCamera_GetActive(&activeCamera); - + error = AKrEnvironment_StartFrame(ONgGameState->level->environment, ONgVisibilityCamera, &render_sky_this_frame); UUmError_ReturnOnError(error); render_sky_this_frame &= !is_skipping_cutscene; - + #if defined(BRENTS_CHEESY_GSD_PERF) && BRENTS_CHEESY_GSD_PERF ioPerfVars->time_env += UUrMachineTime_High(); #endif @@ -5065,13 +5065,13 @@ ONiGameState_Display_NonReflectable( #if 0 M3rMinMaxBBox_Draw_Line(&ONgGameState->level->environment->visible_bbox, IMcShade_White); - COrConsole_Printf("x %f, %f", + COrConsole_Printf("x %f, %f", ONgGameState->level->environment->visible_bbox.minPoint.x, ONgGameState->level->environment->visible_bbox.maxPoint.x); - COrConsole_Printf("y %f, %f", + COrConsole_Printf("y %f, %f", ONgGameState->level->environment->visible_bbox.minPoint.y, ONgGameState->level->environment->visible_bbox.maxPoint.y); - COrConsole_Printf("z %f, %f", + COrConsole_Printf("z %f, %f", ONgGameState->level->environment->visible_bbox.minPoint.z, ONgGameState->level->environment->visible_bbox.maxPoint.z); #endif @@ -5109,9 +5109,9 @@ ONiGameState_Display_NonReflectable( M3rGeom_Line_Light(&ONgGameState->local.playerCharacter->actual_position, &midpoint, IMcShade_Yellow); } - + P3rNotifySkyVisible(render_sky_this_frame); - + // End the environment if (ONgShow_Environment) { @@ -5133,9 +5133,9 @@ ONiGameState_Display_NonReflectable( ONiGameState_Display_NonReflectable_Tool(ioPerfVars); #endif - // Draw the cross hair + // Draw the cross hair AMrRenderCrosshair(); - + return UUcError_None; } @@ -5158,30 +5158,30 @@ ONiGameState_Display_Reflectable( UUrStallTimer_End(&reflectable_internal, "ONiGameState_Display_Reflectable - line drawing"); - + UUrStallTimer_Begin(&reflectable_internal); // Draw the characters if(ONgShow_Characters) { UUtUns32 itr=0; - + #if defined(BRENTS_CHEESY_GSD_PERF) && BRENTS_CHEESY_GSD_PERF ioPerfVars->time_chr -= UUrMachineTime_High(); #endif - + M3rDraw_State_SetInt(M3cDrawStateIntType_Time, ONgGameState->gameTime); ONrGameState_DisplayCharacters(); ONrGameState_MotionBlur_Display(); - + #if defined(BRENTS_CHEESY_GSD_PERF) && BRENTS_CHEESY_GSD_PERF ioPerfVars->time_chr += UUrMachineTime_High(); #endif } UUrStallTimer_End(&reflectable_internal, "ONiGameState_Display_Reflectable - characters"); - + // Draw the object list #if defined(BRENTS_CHEESY_GSD_PERF) && BRENTS_CHEESY_GSD_PERF ioPerfVars->time_obj -= UUrMachineTime_High(); @@ -5208,7 +5208,7 @@ ONiGameState_Display_Reflectable( #if defined(BRENTS_CHEESY_GSD_PERF) && BRENTS_CHEESY_GSD_PERF ioPerfVars->time_obj += UUrMachineTime_High(); #endif - + // Draw the weapons UUrStallTimer_Begin(&reflectable_internal); @@ -5229,7 +5229,7 @@ ONiGameState_Display_Reflectable( M3rGeom_State_Set(M3cGeomStateIntType_SubmitMode, M3cGeomState_SubmitMode_Normal); M3rGeom_State_Commit(); P3rDisplayStaticDecals( ); - P3rDisplayDynamicDecals( ); + P3rDisplayDynamicDecals( ); M3rGeom_State_Set(M3cGeomStateIntType_SubmitMode, M3cGeomState_SubmitMode_SortAlphaTris); M3rGeom_State_Commit(); } @@ -5245,18 +5245,18 @@ ONiGameState_Display_Reflectable( } UUrStallTimer_End(&reflectable_internal, "ONiGameState_Display_Reflectable - particles"); - + #if defined(BRENTS_CHEESY_GSD_PERF) && BRENTS_CHEESY_GSD_PERF ioPerfVars->time_prt += UUrMachineTime_High(); #endif - + UUrStallTimer_Begin(&reflectable_internal); // Draw the ammo WPrPowerup_Display(); UUrStallTimer_End(&reflectable_internal, "ONiGameState_Display_Reflectable - powerup display"); - + #if TOOL_VERSION UUrStallTimer_Begin(&reflectable_internal); // DEBUGGING: draw currently selected AI path @@ -5286,7 +5286,7 @@ void ONrGameState_Display(void) #endif UUrStallTimer_Begin(&stall_timer_display); - + AKrEnvironment_FastMode(ONrGameState_IsSkippingCutscene()); UUmAssertReadPtr(ONgGameState->level->environment,sizeof(AKtEnvironment)); @@ -5294,7 +5294,7 @@ void ONrGameState_Display(void) #if defined(BRENTS_CHEESY_GSD_PERF) && BRENTS_CHEESY_GSD_PERF perf_var.time_total -= UUrMachineTime_High(); #endif - + MUmVector_Verify(ONgGameState->local.camera->viewData.viewVector); M3rGeom_State_Set(M3cGeomStateIntType_SubmitMode, M3cGeomState_SubmitMode_SortAlphaTris); @@ -5302,7 +5302,7 @@ void ONrGameState_Display(void) M3rGeom_State_Set(M3cGeomStateIntType_Fill, ONgMotoko_FillSolid ? M3cGeomState_Fill_Solid : M3cGeomState_Fill_Line); M3rGeom_State_Set(M3cGeomStateIntType_Appearance, ONgMotoko_Texture ? M3cGeomState_Appearance_Texture : M3cGeomState_Appearance_Gouraud); M3rGeom_State_Set(M3cGeomStateIntType_FastMode, ONrGameState_IsSkippingCutscene()); - + M3rGeom_State_Set(M3cGeomStateIntType_Alpha, 0xff); // These have no geom state equivalent @@ -5312,7 +5312,7 @@ void ONrGameState_Display(void) M3rDraw_State_SetInt(M3cDrawStateIntType_ZWrite, M3cDrawState_ZWrite_On); M3rDraw_State_SetInt(M3cDrawStateIntType_ClearColor, ONgMotoko_ClearColor); M3rGeom_State_Commit(); - + // main drawing UUrStallTimer_Begin(&stall_timer_display_internal); ONiGameState_Display_NonReflectable(&perf_var); @@ -5369,8 +5369,8 @@ iDebugExportGunk( SLtErrorContext* inErrorContext, UUtUns32 inParameterListLength, SLtParameter_Actual *inParameterList, - UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtUns32 *outTicksTillCompletion, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { UUtError error; @@ -5387,8 +5387,8 @@ iDebugEnvAnim( SLtErrorContext* inErrorContext, UUtUns32 inParameterListLength, SLtParameter_Actual *inParameterList, - UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtUns32 *outTicksTillCompletion, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { char *animation_name = inParameterList[0].val.str; @@ -5401,11 +5401,11 @@ iDebugEnvAnim( if (UUcError_None == error) { ONgLineSize = animation->numFrames; - COrConsole_Printf("found %d frames", ONgLineSize); + COrConsole_Printf("found %d frames", ONgLineSize); } else { ONgLineSize = 0; - COrConsole_Printf("not found"); + COrConsole_Printf("not found"); } ONgLine = UUrMemory_Block_Realloc(ONgLine, sizeof(M3tPoint3D) * ONgLineSize); @@ -5413,7 +5413,7 @@ iDebugEnvAnim( { UUtInt32 itr; - for(itr = 0; itr < ONgLineSize; itr++) + for(itr = 0; itr < ONgLineSize; itr++) { M3tMatrix4x3 matrix; @@ -5432,7 +5432,7 @@ ONrGameState_Initialize( void) { UUtError error; - SLtRegisterBoolTable bool_table[] = + SLtRegisterBoolTable bool_table[] = { #if CONSOLE_DEBUGGING_COMMANDS { "gs_show_particles", "Turns on the drawing of particles", &ONgParticle_Display }, @@ -5467,7 +5467,7 @@ ONrGameState_Initialize( { NULL, NULL, NULL } }; - SLtRegisterFloatTable float_table[] = + SLtRegisterFloatTable float_table[] = { #if CONSOLE_DEBUGGING_COMMANDS { "gs_input_accel", "Use this to control the input sensitivity", &ONgGameState_InputAccel }, @@ -5475,7 +5475,7 @@ ONrGameState_Initialize( { NULL, NULL, NULL } }; - SLtRegisterInt32Table int32_table[] = + SLtRegisterInt32Table int32_table[] = { #if CONSOLE_DEBUGGING_COMMANDS { "gs_screen_shot_reduce", "2^n amount of reduction", &ONgScreenShotReduceAmount }, @@ -5545,7 +5545,7 @@ ONrGameState_Initialize( strcpy(script_count_display[0].text, "*** script count display ***"); strcpy(script_count_display[1].text, ""); #endif - + ONgGameState = (ONtGameState *) UUrMemory_Block_NewClear(sizeof(ONtGameState)); if (NULL == ONgGameState) { @@ -5556,7 +5556,7 @@ ONrGameState_Initialize( error = AI2rInstallConsoleVariables(); UUmError_ReturnOnError(error); - + // initialize the gamestate dialogs /* error = ONrGameState_Dialog_Initialize(); UUmError_ReturnOnError(error);*/ @@ -5564,7 +5564,7 @@ ONrGameState_Initialize( // Install the console variables for the characters error = ONrGameState_InstallConsoleVariables(); UUmError_ReturnOnError(error); - + // Install the console variables for the weapons error = WPrInitialize(); UUmError_ReturnOnError(error); @@ -5583,7 +5583,7 @@ ONrGameState_Terminate( if(ONgGameState != NULL) { UUmAssert(ONgGameState == ONgGameState); - + // Delete the ganestate UUrMemory_Block_Delete(ONgGameState); ONgGameState = NULL; @@ -5706,7 +5706,7 @@ ONrGameState_Pause( static UUtProfileState savedProfileState = UUcProfile_State_Off; ONgGameState->paused = inPause; - + if (inPause == UUcFalse) { // have to remove cMaxTicksPerFrame or else the @@ -5714,21 +5714,21 @@ ONrGameState_Pause( ONgGameState->server.machineTimeLast = UUrMachineTime_Sixtieths() - cMaxTicksPerFrame; - + #if defined(PROFILE) && PROFILE - + UUrProfile_State_Set(savedProfileState); - + #endif } else { #if defined(PROFILE) && PROFILE - + savedProfileState = UUrProfile_State_Get(); - + UUrProfile_State_Set(UUcProfile_State_Off); - + #endif } } @@ -5738,10 +5738,10 @@ UUtError ONrGameState_LevelBegin_Objects(void) /**************** * Sets up objects for a level */ - + ONgGameState->objects = OBrList_New(ONcMaxObjects); if (!ONgGameState->objects) return UUcError_OutOfMemory; - + return UUcError_None; } @@ -5750,7 +5750,7 @@ void ONrGameState_LevelEnd_Objects(void) /**************** * Kills objects for a level */ - + OBrList_Delete(ONgGameState->objects); } @@ -5769,7 +5769,7 @@ ONrGameState_ResetCharacters( void) { UUtUns16 i; - + // delete all of the characters for (i = 0; i < ONgGameState->numCharacters; i++) { @@ -5844,9 +5844,9 @@ void ONrGameState_ActiveCharacterList_Remove(ONtCharacter *inCharacter) if (curCharacter == inCharacter) { ONgGameState->numActiveCharacters--; - ONgGameState->activeCharacters[itr] = + ONgGameState->activeCharacters[itr] = ONgGameState->activeCharacters[ONgGameState->numActiveCharacters]; - return; + return; } } @@ -5911,9 +5911,9 @@ void ONrGameState_LivingCharacterList_Remove(ONtCharacter *inCharacter) if (curCharacter == inCharacter) { ONgGameState->numLivingCharacters--; - ONgGameState->livingCharacters[itr] = + ONgGameState->livingCharacters[itr] = ONgGameState->livingCharacters[ONgGameState->numLivingCharacters]; - return; + return; } } @@ -5973,9 +5973,9 @@ void ONrGameState_PresentCharacterList_Remove(ONtCharacter *inCharacter) if (curCharacter == inCharacter) { ONgGameState->numPresentCharacters--; - ONgGameState->presentCharacters[itr] = + ONgGameState->presentCharacters[itr] = ONgGameState->presentCharacters[ONgGameState->numPresentCharacters]; - return; + return; } } @@ -6003,7 +6003,7 @@ void ONrGameState_FadeOut(UUtUns32 inNumFrames, float inR, float inG, float inB) void ONrGameState_FadeIn(UUtUns32 inNumFrames) { - if (ONgGameState->local.fadeInfo.active) + if (ONgGameState->local.fadeInfo.active) { ONgGameState->local.fadeInfo.startTime = ONgGameState->gameTime; ONgGameState->local.fadeInfo.endTime = ONgGameState->gameTime + inNumFrames; @@ -6056,7 +6056,7 @@ static void ONrGameState_MotionBlur_Display_One(ONtMotionBlur *inMotionBlur) M3rMatrixStack_Push(); M3rMatrixStack_Multiply(&inMotionBlur->matrix); - + inMotionBlur->geometry->baseMap = inMotionBlur->texture; M3rGeometry_Draw(inMotionBlur->geometry); M3rMatrixStack_Pop(); @@ -6148,7 +6148,7 @@ void ONrGameState_LetterBox_Update(ONtLetterBox *ioLetterBox, UUtUns32 inTicks) { if (ioLetterBox->active) { ioLetterBox->position += ONcLetterBox_Increment * inTicks; - + if (ioLetterBox->position >= ONcLetterBox_Depth) { ioLetterBox->position = ONcLetterBox_Depth; ioLetterBox->updating = UUcFalse; @@ -6156,13 +6156,13 @@ void ONrGameState_LetterBox_Update(ONtLetterBox *ioLetterBox, UUtUns32 inTicks) } else { ioLetterBox->position -= ONcLetterBox_Increment * inTicks; - + if (ioLetterBox->position <= 0) { ioLetterBox->position = 0; ioLetterBox->updating = UUcFalse; } } - + return; } @@ -6186,17 +6186,17 @@ void ONrGameState_LetterBox_Display(ONtLetterBox *ioLetterBox) screen_width = M3rDraw_GetWidth(); screen_height = M3rDraw_GetHeight(); - + if ((ioLetterBox->position > 0) && (ONgLetterboxTexture != NULL)) { float relative_position = ioLetterBox->position * (screen_height / 480.f); M3tPointScreen points[2]; M3tTextureCoord uv[4]; - + M3rDraw_State_Push(); - + M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_Black); M3rDraw_State_SetInt(M3cDrawStateIntType_Alpha, M3cMaxAlpha); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, ONgLetterboxTexture); @@ -6204,7 +6204,7 @@ void ONrGameState_LetterBox_Display(ONtLetterBox *ioLetterBox) M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); - + points[0].x = 0.f; points[0].y = 0.f; points[0].z = 0.5f; @@ -6214,20 +6214,20 @@ void ONrGameState_LetterBox_Display(ONtLetterBox *ioLetterBox) points[1].y = relative_position; points[1].z = 0.5f; points[1].invW = 2.f; - + M3rDraw_State_Commit(); - + M3rDraw_Sprite( - points, + points, uv); points[0].y = (float) (screen_height - relative_position); points[1].y = (float) (screen_height); M3rDraw_Sprite( - points, + points, uv); - + M3rDraw_State_Pop(); } @@ -6257,7 +6257,7 @@ void ONrGameState_BeginCutscene(UUtUns32 inCutsceneFlags) if (!(inCutsceneFlags & ONcCutsceneFlag_RetainAnimation)) { ONrCharacter_ForceStand(player_character); - + if (player_active_character != NULL) { player_active_character->stitch.velocity = MUgZeroVector; } @@ -6384,7 +6384,7 @@ void ONrGameState_SkipCutscene(void) ONgGameState->local.cutscene_skip_timer = ONcNumber_of_frames_for_cutscene_skip_timer; ONgGameState->local.cutscene_skip_mode = ONcCutsceneSkip_starting; - + OSrSetEnabled(UUcFalse); } } @@ -6478,7 +6478,7 @@ void ONrGameState_Timer_Update(void) if (0 == timer->ticks_remaining) { timer->timer_mode = ONcTimerMode_Fail; timer->ticks_remaining = 5 * UUcFramesPerSecond; // 5 seconds of 00:00 blinking - SLrScript_ExecuteOnce(timer->script, 0, NULL, NULL, NULL); + SLrScript_ExecuteOnce(timer->script, 0, NULL, NULL, NULL); } break; @@ -6505,7 +6505,7 @@ void ONrGameState_Timer_Update(void) void ONrGameState_Timer_Display(const M3tPointScreen *inCenter) { ONtTimer *timer = &ONgGameState->local.timer; - + { if (ONcTimerMode_Off == timer->timer_mode) { goto exit; @@ -6578,7 +6578,7 @@ void ONrGameState_Timer_Display(const M3tPointScreen *inCenter) break; } - + { UUtRect rect; IMtPoint2D draw_location; @@ -6586,7 +6586,7 @@ void ONrGameState_Timer_Display(const M3tPointScreen *inCenter) const UUtUns16 screen_height = M3rDraw_GetHeight(); UUtUns16 string_width; UUtUns16 string_height; - + TSrContext_GetStringRect(ONgTimerTextContext, display_string, &rect); string_width = rect.right - rect.left; string_height = TSrFont_GetAscendingHeight(TSrContext_GetFont(ONgTimerTextContext, TScStyle_Plain)); @@ -6703,7 +6703,7 @@ void ONrGameState_MakeContinue(UUtUns32 inSavePoint, UUtBool inAutoSave) ONrPersist_SetPlace(&place); } - + return; } @@ -6819,13 +6819,13 @@ void ONrGameState_ConditionSound_Start(UUtUns32 inCondition, float inVolume) if ((ONgGameState->condition_active & mask) == 0) { // start the sound! ONgGameState->condition_active |= mask; - + if (ONgGameSettingsRuntime.condition_sound[inCondition] != NULL) { ONgGameState->condition_playid[inCondition] = SSrAmbient_Start_Simple(ONgGameSettingsRuntime.condition_sound[inCondition], &inVolume); } // COrConsole_Printf("condition %s start %f", ONcConditionSoundName[inCondition], inVolume); - + } else if (ONgGameState->condition_playid[inCondition] != SScInvalidID) { // the sound is already playing, just change its volume SSrAmbient_SetVolume(ONgGameState->condition_playid[inCondition], inVolume, 1.0f); @@ -6969,7 +6969,7 @@ static void ONrGameState_UpdateAutoPrompt(void) // hypo usage has a higher priority than using consoles if (player->inventory.hypo > 0) { if (player->hitPoints <= (player->maxHitPoints * ONcIGUI_HealthWarnLevel) / 100) { - ONiGameState_FindAutoPromptMessage("usehypo", &message); + ONiGameState_FindAutoPromptMessage("usehypo", &message); } } } diff --git a/OniProj/OniGameSource/Oni_GameState.h b/OniProj/OniGameSource/Oni_GameState.h index 6326d1d..3a8217e 100644 --- a/OniProj/OniGameSource/Oni_GameState.h +++ b/OniProj/OniGameSource/Oni_GameState.h @@ -2,13 +2,13 @@ /* FILE: Oni_GameState.h - + AUTHOR: Brent Pease, Michael Evans, Quinn Dunki, Kevin Armstrong - + CREATED: May 31, 1997 - + PURPOSE: - + Copyright 1997 - 2000 */ @@ -28,11 +28,11 @@ typedef enum ONtDifficultyLevel ONcDifficultyLevel_Normal = 1,// medium ONcDifficultyLevel_Hard = 2,// hard ONcDifficultyLevel_Count = 3, - + ONcDifficultyLevel_Min = ONcDifficultyLevel_Easy, ONcDifficultyLevel_Default = ONcDifficultyLevel_Normal, ONcDifficultyLevel_Max = ONcDifficultyLevel_Hard - + } ONtDifficultyLevel; typedef struct ONtGameState ONtGameState; @@ -126,7 +126,7 @@ extern ONtGameState *ONgGameState; UUtError ONrGameState_Initialize( void); - + void ONrGameState_Terminate( void); @@ -151,7 +151,7 @@ UUtError ONrGameState_LevelBegin_Objects( void); void ONrGameState_LevelEnd_Objects( void); - + void ONrGameState_Delete( ONtGameState* inGameState); @@ -229,15 +229,15 @@ ONrGameState_GetGameTime( PHtGraph* ONrGameState_GetGraph( void); - + ONtCharacter* ONrGameState_GetPlayerCharacter( void); - + UUtUns16 ONrGameState_GetPlayerNum( void); - + UUtUns16 ONrGameState_GetNumCharacters( void); @@ -245,7 +245,7 @@ ONrGameState_GetNumCharacters( struct OBtObjectList* ONrGameState_GetObjectList( void); - + ONtLetterBox *ONrGameState_GetLetterBox(void); void @@ -255,7 +255,7 @@ ONrGameState_SetPlayerNum( UUtBool ONrGameState_IsPaused( void); - + UUtBool ONrGameState_IsSingleStep( void); diff --git a/OniProj/OniGameSource/Oni_GameStatePrivate.h b/OniProj/OniGameSource/Oni_GameStatePrivate.h index 5bcb73f..ad18499 100644 --- a/OniProj/OniGameSource/Oni_GameStatePrivate.h +++ b/OniProj/OniGameSource/Oni_GameStatePrivate.h @@ -2,13 +2,13 @@ /* FILE: Oni_GameStatePrivate.h - + AUTHOR: Michael Evans - + CREATED: Jan, 1998 - + PURPOSE: - + Copyright 1997, 1998 */ @@ -30,7 +30,7 @@ #define ONcMaxObjects 40 #define ONcMaxTriggers 32 - + typedef struct ONtServerState { UUtUns32 machineTimeLast; // machine time last time we did an update @@ -111,14 +111,14 @@ typedef struct ONtLocalGameState UUtBool sync_enabled; UUtUns32 cutscene_skip_timer; - UUtUns32 time_cutscene_started_or_wait_for_key_returned_in_machine_time; + UUtUns32 time_cutscene_started_or_wait_for_key_returned_in_machine_time; ONtFadeInfo fadeInfo; CAtCamera *camera; - + PHtGraph pathGraph; // Pathfinding digraph for environment - + ONtCharacter *playerCharacter; // active character on local machine ONtActiveCharacter *playerActiveCharacter; // active character on local machine ONtInputState localInput; @@ -160,14 +160,14 @@ struct ONtGameState { ONtLocalGameState local; // local data (different on different machines) ONtServerState server; - + UUtUns32 gameTime; // time in heartbeats of the game (on our local machine) UUtUns32 serverTime; // server time (we have gotten all commands up to this time) M3tGeometry* geometryOpacity; - + ONtLevel* level; - + UUtBool displayOpacity; // motion blurs @@ -177,7 +177,7 @@ struct ONtGameState // character salt indices UUtUns16 nextCharacterSalt; UUtUns16 nextActiveCharacterSalt; - + // all characters ONtCharacter characters[ONcMaxCharacters]; UUtUns16 numCharacters; @@ -244,4 +244,4 @@ struct ONtGameState -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_ImpactEffect.c b/OniProj/OniGameSource/Oni_ImpactEffect.c index b3466df..f237ebf 100644 --- a/OniProj/OniGameSource/Oni_ImpactEffect.c +++ b/OniProj/OniGameSource/Oni_ImpactEffect.c @@ -30,7 +30,7 @@ enum { ONcIEVersion_1 = 1, ONcIEVersion_2 = 2, - + ONcIECurrentVersion = ONcIEVersion_2 }; @@ -174,7 +174,7 @@ static UUtError ONiImpactEffect_MakeDynamicArray( // already dynamic return UUcError_None; } - + // impact entries new_array = UUrMemory_Array_New(inFinalSize, ONcIE_ChunkSize, inNumElements, inNumElements + ONcIE_ChunkSize); UUmError_ReturnOnNull(new_array); @@ -406,7 +406,7 @@ ONrImpactEffect_VerifyStructure( // check particles particle = ONiImpactEffect_GetParticle(0, 0); for (itr = 0; itr < ONgNumImpactParticles; itr++, particle++) { - UUmAssert((particle->effect_spec.collision_orientation >= 0) && + UUmAssert((particle->effect_spec.collision_orientation >= 0) && (particle->effect_spec.collision_orientation < P3cEnumCollisionOrientation_Max)); UUmAssert((particle->effect_spec.location_type >= 0) && (particle->effect_spec.location_type < P3cEffectLocationType_Max)); @@ -431,9 +431,9 @@ ONrImpactEffect_VerifyStructure( if (entry->sound_index != ONcIESound_None) { UUmAssert((entry->sound_index >= 0) && (entry->sound_index < ONgNumImpactSounds)); } - + if (entry->num_particles > 0) { - UUmAssert((entry->particle_baseindex >= 0) && + UUmAssert((entry->particle_baseindex >= 0) && (entry->particle_baseindex + entry->num_particles <= ONgNumImpactParticles)); } } @@ -504,7 +504,7 @@ ONiImpactEffect_NewParticle( particle = ONiImpactEffect_GetParticle(move_index, inNumParticles); UUrMemory_MoveOverlap(particle, particle + inNumParticles, (ONgNumImpactParticles - move_index - inNumParticles) * sizeof(ONtIEParticle)); *outParticle = particle; - + // update all impact entries' particle indices entry = ONiImpactEffect_GetEntry(0, 0); for (itr = 0; itr < ONgNumImpactEntries; itr++, entry++) { @@ -546,7 +546,7 @@ ONiImpactEffect_DeleteParticle( particle = ONiImpactEffect_GetParticle(inParticleIndex, inNumParticles); UUrMemory_MoveOverlap(particle + inNumParticles, particle, (ONgNumImpactParticles - inParticleIndex - inNumParticles) * sizeof(ONtIEParticle)); ONgNumImpactParticles -= inNumParticles; - + // update all impact entries' particle indices found_entry = UUcFalse; entry = ONiImpactEffect_GetEntry(0, 0); @@ -632,7 +632,7 @@ ONrImpactEffect_DeleteSound( sound = ONiImpactEffect_GetSound(inSoundIndex, 1); UUrMemory_MoveOverlap(sound + 1, sound, (ONgNumImpactSounds - inSoundIndex - 1) * sizeof(ONtIESound)); ONgNumImpactSounds -= 1; - + // update all impact entries' sound indices found_entry = UUcFalse; entry = ONiImpactEffect_GetEntry(0, 0); @@ -693,7 +693,7 @@ ONiImpactEffect_NewEntry( UUrMemory_MoveOverlap(entry, entry + 1, (ONgNumImpactEntries - move_index - 1) * sizeof(ONtImpactEntry)); *outEntryIndex = move_index; *outEntry = entry; - + // update all material indices' entry indices matindex = ONiImpactEffect_GetMaterialIndex(0, 0); for (itr = 0; itr < ONgNumImpactMaterialIndices; itr++, matindex++) { @@ -752,7 +752,7 @@ ONiImpactEffect_DeallocateEntry( // move all impact entries after this one up UUrMemory_MoveOverlap(entry + 1, entry, (ONgNumImpactEntries - inEntryIndex - 1) * sizeof(ONtImpactEntry)); ONgNumImpactEntries -= 1; - + // update all material indices' impact entry indices found_matindex = UUcFalse; if (outMaterialIndex) { @@ -818,7 +818,7 @@ ONiImpactEffect_NewMaterialIndex( UUrMemory_MoveOverlap(matindex, matindex + 1, (ONgNumImpactMaterialIndices - inDesiredIndex - 1) * sizeof(ONtImpactMaterialIndex)); *outMaterialIndex = matindex; - + // update the lookup table's material indices lookup = ONgImpactLookupTable; for (itr = 0; itr < num_types; itr++, lookup++) { @@ -868,7 +868,7 @@ ONiImpactEffect_DeleteMaterialIndex( // move all material indices after this one up UUrMemory_MoveOverlap(matindex + 1, matindex, (ONgNumImpactMaterialIndices - inMaterialIndex - 1) * sizeof(ONtImpactMaterialIndex)); ONgNumImpactMaterialIndices -= 1; - + // update the lookup table's material indices found_lookup = UUcFalse; lookup = ONgImpactLookupTable; @@ -928,7 +928,7 @@ OWiImpactEffect_AllocateSpecificEntry( // get this impact type's lookup element UUmAssert((inImpactType >= 0) && (inImpactType < MArImpacts_GetNumTypes())); lookup = ONgImpactLookupTable + inImpactType; - + // find the material index that corresponds to this material type matindex = ONiImpactEffect_GetMaterialIndex(lookup->index_base, lookup->num_indices); for (itr = 0; itr < lookup->num_indices; itr++, matindex++) { @@ -1047,7 +1047,7 @@ ONrImpactEffect_GetImpactEntries( // get this impact type's lookup element UUmAssert((inImpactType >= 0) && (inImpactType < MArImpacts_GetNumTypes())); lookup = ONgImpactLookupTable + inImpactType; - + // find the first material index that hasn't yet been returned. matindex = ONiImpactEffect_GetMaterialIndex(lookup->index_base, lookup->num_indices); for (itr = 0; itr < lookup->num_indices; itr++, matindex++) { @@ -1388,7 +1388,7 @@ ONrImpactEffect( for (itr = 0; itr < ONcIEComponent_Max; itr++) { // play each component of the effect - if (found_indices[itr] == (UUtUns32) -1) + if (found_indices[itr] == (UUtUns32) -1) continue; entry = ONiImpactEffect_GetEntry(found_indices[itr], 1); @@ -1479,7 +1479,7 @@ ONrImpactEffect_Lookup( material_type = inMaterialType; for (itr = lookup->num_indices - 1; itr >= 0; ) { - + if (matindex->material > material_type) { // keep looking further up the array itr--; @@ -1487,7 +1487,7 @@ ONrImpactEffect_Lookup( continue; } - + if (matindex->material == material_type) { // we have found a material that has impact entries for this impact type. entry = ONiImpactEffect_GetEntry(matindex->entry_index, matindex->num_entries); @@ -1599,7 +1599,7 @@ ONiIESwap_Particles( for (itr = 0; itr < inNumParticles; itr++, particle++) { if (inSwap) { - P3iSwap_EffectSpecification((void *) &particle->effect_spec, !inLoad); + P3iSwap_EffectSpecification((void *) &particle->effect_spec, !inLoad); } if (inLoad) { @@ -1733,7 +1733,7 @@ ONiIESwap_Entries( if (entry->num_particles > 0) { // check that this is a valid index into the particle array - if ((entry->particle_baseindex < 0) || + if ((entry->particle_baseindex < 0) || (entry->particle_baseindex + (UUtUns32) entry->num_particles > ONgNumImpactParticles)) { UUrDebuggerMessage("Impact Effect Load: entry %d particle index %d len %d outside array bounds (%d)!\n", itr, entry->particle_baseindex, entry->num_particles, ONgNumImpactParticles); @@ -1841,7 +1841,7 @@ ONiIESwap_MaterialIndices( } // check that this is a valid index into the impact entry array - if ((matindex->entry_index < 0) || + if ((matindex->entry_index < 0) || (matindex->entry_index + matindex->num_entries > ONgNumImpactEntries)) { UUrDebuggerMessage("Impact Effect Load: materialindex %d entry index %d len %d outside array bounds (%d)!\n", itr, matindex->entry_index, matindex->num_entries, ONgNumImpactEntries); @@ -2010,10 +2010,10 @@ UUtError ONrIEBinaryData_Process(void) if (NULL == ONgImpactEffectsBuffer) { return UUcError_Generic; } - + buffer = ONgImpactEffectsBuffer; buffer_size = ONgImpactEffectsBuffer_Size; - + // read the version number buffer_size -= OBDmGet4BytesFromBuffer(buffer, version, UUtUns32, ONgImpactEffectsBuffer_SwapIt); @@ -2089,7 +2089,7 @@ UUtError ONrIEBinaryData_Process(void) /* * read the translation tables */ - + ONgIE_ImpactTranslation = (ONtImpactTranslator *) buffer; buffer += ONgIE_FileNumImpactTypes * sizeof(ONtImpactTranslator); ONiIEReadImpactTranslation(); @@ -2141,7 +2141,7 @@ UUtError ONrIEBinaryData_Process(void) /* * read the particles */ - + ONgImpactParticles = (ONtIEParticle *) buffer; buffer += ONgNumImpactParticles * sizeof(ONtIEParticle); error = ONiIESwap_Particles(ONgNumImpactParticles, ONiImpactEffect_GetParticle(0, 0), ONgImpactEffectsBuffer_SwapIt, UUcTrue); @@ -2154,7 +2154,7 @@ UUtError ONrIEBinaryData_Process(void) /* * read the sounds */ - + if (version >= ONcIEVersion_2) { // sounds are the correct size, no padding necessary. we can byte-swap in place. ONgImpactSounds = (ONtIESound *) buffer; @@ -2179,7 +2179,7 @@ UUtError ONrIEBinaryData_Process(void) /* * read the impact entries */ - + ONgImpactEntries = (ONtImpactEntry *) buffer; buffer += ONgNumImpactEntries * sizeof(ONtImpactEntry); error = ONiIESwap_Entries(ONgNumImpactEntries, ONiImpactEffect_GetEntry(0, 0), ONgImpactEffectsBuffer_SwapIt, UUcTrue); @@ -2192,7 +2192,7 @@ UUtError ONrIEBinaryData_Process(void) /* * read the material indices */ - + ONgImpactMaterialIndices = (ONtImpactMaterialIndex *) buffer; buffer += ONgNumImpactMaterialIndices * sizeof(ONtImpactMaterialIndex); error = ONiIESwap_MaterialIndices(ONgNumImpactMaterialIndices, ONiImpactEffect_GetMaterialIndex(0, 0), @@ -2253,7 +2253,7 @@ ONiIEWriteImpactTranslation( { ONtImpactTranslator *translator = (ONtImpactTranslator *) *inBuffer; UUtUns32 itr, write_size, num_types = MArImpacts_GetNumTypes(); - + write_size = num_types * sizeof(ONtImpactTranslator); UUmAssert(*ioNumBytes >= write_size); @@ -2275,7 +2275,7 @@ ONiIEWriteMaterialTranslation( { ONtMaterialTranslator *translator = (ONtMaterialTranslator *) *inBuffer; UUtUns32 itr, write_size, num_types = MArMaterials_GetNumTypes(); - + write_size = num_types * sizeof(ONtMaterialTranslator); UUmAssert(*ioNumBytes >= write_size); @@ -2309,13 +2309,13 @@ ONiIEBinaryData_Save( num_impact_types = MArImpacts_GetNumTypes(); num_material_types = MArMaterials_GetNumTypes(); - + #if UUmEndian == UUmEndian_Big swap_data = UUcTrue; #elif UUmEndian == UUmEndian_Little swap_data = UUcFalse; #else - #pragma error + #pragma error #endif if (ONgNumImpactEntries == 0) { @@ -2339,7 +2339,7 @@ ONiIEBinaryData_Save( UUrDebuggerMessage("Impact Effect Save: can't allocate buffer for data save!\n"); goto cleanup; } - + // set up to write at the start of this block buffer = data; num_bytes = data_size; @@ -2357,7 +2357,7 @@ ONiIEBinaryData_Save( /* * write the translation tables */ - + error = ONiIEWriteImpactTranslation(&buffer, &num_bytes); if (error != UUcError_None) { UUrDebuggerMessage("Impact Effect Save: could not write impact-type translation!\n"); @@ -2386,12 +2386,12 @@ ONiIEBinaryData_Save( } num_bytes -= write_size; buffer += write_size; - + /* * write the particles */ - + write_size = ONgNumImpactParticles * sizeof(ONtIEParticle); UUmAssert(num_bytes >= write_size); UUrMemory_MoveFast(ONiImpactEffect_GetParticle(0, 0), buffer, write_size); @@ -2404,11 +2404,11 @@ ONiIEBinaryData_Save( num_bytes -= write_size; buffer += write_size; - + /* * write the sounds */ - + write_size = ONgNumImpactSounds * sizeof(ONtIESound); UUmAssert(num_bytes >= write_size); UUrMemory_MoveFast(ONiImpactEffect_GetSound(0, 0), buffer, write_size); @@ -2420,11 +2420,11 @@ ONiIEBinaryData_Save( } num_bytes -= write_size; buffer += write_size; - + /* * write the impact entries */ - + write_size = ONgNumImpactEntries * sizeof(ONtImpactEntry); UUmAssert(num_bytes >= write_size); UUrMemory_MoveFast(ONiImpactEffect_GetEntry(0, 0), buffer, write_size); @@ -2436,12 +2436,12 @@ ONiIEBinaryData_Save( } num_bytes -= write_size; buffer += write_size; - - + + /* * write the material indices */ - + write_size = ONgNumImpactMaterialIndices * sizeof(ONtImpactMaterialIndex); UUmAssert(num_bytes >= write_size); UUrMemory_MoveFast(ONiImpactEffect_GetMaterialIndex(0, 0), buffer, write_size); @@ -2460,7 +2460,7 @@ ONiIEBinaryData_Save( * save the data */ UUmAssert(num_bytes == 0); - error = + error = OBDrBinaryData_Save( ONcIEBinaryDataClass, "impact_effects", @@ -2478,7 +2478,7 @@ ONiIEBinaryData_Save( if (inAutoSave == UUcFalse) { ONgImpactEffect_Dirty = UUcFalse; } - + ONgImpactEffect_AutomaticModificationsOnly = UUcFalse; return UUcError_None; @@ -2510,7 +2510,7 @@ ONiIEClearStorage( ONgNumImpactSounds = 0; ONgNumImpactParticles = 0; ONgNumImpactMaterialIndices = 0; - + ONgImpactEntries = NULL; ONgImpactSounds = NULL; ONgImpactParticles = NULL; @@ -2575,12 +2575,12 @@ ONiIEBinaryData_Register( { UUtError error; BDtMethods methods; - + methods.rLoad = ONiIEBinaryData_Load; - + error = BDrRegisterClass(ONcIEBinaryDataClass, &methods); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2593,31 +2593,31 @@ ONrImpactEffects_ListBrokenLinks( UUtUns32 num_impacts; UUtUns32 num_materials; UUtUns16 i; - + // sprintf a header sprintf(text, "********** Animation Sound Links **********\n\n"); BFrFile_Write(inFile, strlen(text), text); sprintf(text, "Impact\tMaterial\tModifier\tImpulse Sound Name\n"); BFrFile_Write(inFile, strlen(text), text); - + num_impacts = MArImpacts_GetNumTypes(); num_materials = MArMaterials_GetNumTypes(); - + for (i = 0; i < num_impacts; i++) { UUtUns16 j; - + for (j = 0; j < num_materials; j++) { UUtUns16 k; - + for (k = 0; k < ONcIEModType_NumTypes; k++) { UUtUns32 itr; UUtUns32 found_indices[ONcIEComponent_Max]; - + ONrImpactEffect_Lookup(i, j, k, found_indices); - + for (itr = 0; itr < ONcIEComponent_Max; itr++) { ONtImpactEntry *entry; @@ -2626,23 +2626,23 @@ ONrImpactEffects_ListBrokenLinks( const char *material_name; const char *mod_name; SStImpulse *impulse; - + // get the entry if (found_indices[itr] == (UUtUns32) -1) { continue; } entry = ONiImpactEffect_GetEntry(found_indices[itr], 1); if (entry == NULL) { continue; } if (entry->sound_index == ONcIESound_None) { continue; } - + // get teh impact effect sound sound = ONiImpactEffect_GetSound(entry->sound_index, 1); - impulse = OSrImpulse_GetByName(sound->sound_name); + impulse = OSrImpulse_GetByName(sound->sound_name); if (impulse != NULL) { continue; } - + // get the names impact_name = MArImpactType_GetName(entry->impact_type); material_name = MArMaterialType_GetName(entry->material_type); mod_name = ONgIEModTypeName[entry->modifier]; - + sprintf( text, "%s\t%s\t%s\t%s\n", @@ -2667,13 +2667,13 @@ ONrImpactEffects_Initialize( void) { UUtError error; - + // register the binary data error = ONiIEBinaryData_Register(); UUmError_ReturnOnError(error); - + ONiIEClearStorage(); - + return UUcError_None; } @@ -2722,7 +2722,7 @@ ONrImpactEffects_CreateBlank( void) { UUtUns32 itr, num_types; - + if (ONgImpactEffect_Loaded) return UUcError_None; @@ -2753,7 +2753,7 @@ ONrImpactEffects_CreateBlank( return UUcError_None; } - + // ====================================================================== #if 0 @@ -2772,15 +2772,15 @@ ONiImpactEffect_Write( const char *sound_name; char string[2048]; UUtUns32 i; - + impact_name = MArImpactType_GetName(inEntry->impact_type); material_name = MArMaterialType_GetName(inEntry->material_type); mod_name = ONgIEModTypeName[inEntry->modifier]; - + if (inEntry->sound_index != ONcIESound_None) { ONtIESound *sound; - + sound = ONiImpactEffect_GetSound(inEntry->sound_index, 1); sound_name = sound->sound_name; } @@ -2788,17 +2788,17 @@ ONiImpactEffect_Write( { sound_name = "(NONE)"; } - + sprintf(string, "%s\t%s\t%s\t%s\n", impact_name, material_name, mod_name, sound_name); BFrFile_Write(inFile, strlen(string), string); - + for (i = 0; i < inEntry->num_particles; i++) { ONtIEParticle *particle; - + particle = ONiImpactEffect_GetParticle(inEntry->particle_baseindex, inEntry->num_particles); if (particle == NULL) { continue; } - + sprintf(string, "%d\t%s\n", i, particle->particle_class_name); BFrFile_Write(inFile, strlen(string), string); } @@ -2812,34 +2812,34 @@ ONiImpactEffects_Write( UUtUns32 num_impacts; UUtUns32 num_materials; UUtUns16 i; - + num_impacts = MArImpacts_GetNumTypes(); num_materials = MArMaterials_GetNumTypes(); - + for (i = 0; i < num_impacts; i++) { UUtUns16 j; - + for (j = 0; j < num_materials; j++) { UUtUns16 k; - + for (k = 0; k < ONcIEModType_NumTypes; k++) { UUtUns32 itr; UUtUns32 found_indices[ONcIEComponent_Max]; - + ONrImpactEffect_Lookup(i, j, k, found_indices); - + for (itr = 0; itr < ONcIEComponent_Max; itr++) { ONtImpactEntry *entry; - + if (found_indices[itr] == (UUtUns32) -1) { continue; } - + entry = ONiImpactEffect_GetEntry(found_indices[itr], 1); if (entry == NULL) { continue; } - + ONiImpactEffect_Write(inFile, entry); } } @@ -2855,11 +2855,11 @@ ONrImpactEffects_WriteTextFile( UUtError error; BFtFileRef *file_ref; BFtFile *file; - + // create the file ref error = BFrFileRef_MakeFromName("ImpactEffects.txt", &file_ref); UUmError_ReturnOnError(error); - + // create the .TXT file if it doesn't already exist if (BFrFileRef_FileExists(file_ref) == UUcFalse) { @@ -2867,28 +2867,28 @@ ONrImpactEffects_WriteTextFile( error = BFrFile_Create(file_ref); UUmError_ReturnOnError(error); } - + // open the file error = BFrFile_Open(file_ref, "rw", &file); UUmError_ReturnOnError(error); - + // set the position to 0 error = BFrFile_SetPos(file, 0); UUmError_ReturnOnError(error); - + // write the items ONiImpactEffects_Write(file); - + // set the end of the file BFrFile_SetEOF(file); - + // close the file BFrFile_Close(file); file = NULL; - + // delete the file ref BFrFileRef_Dispose(file_ref); file_ref = NULL; - + return UUcError_None; -} \ No newline at end of file +} diff --git a/OniProj/OniGameSource/Oni_ImpactEffect.h b/OniProj/OniGameSource/Oni_ImpactEffect.h index ed679ce..01a2514 100644 --- a/OniProj/OniGameSource/Oni_ImpactEffect.h +++ b/OniProj/OniGameSource/Oni_ImpactEffect.h @@ -30,9 +30,9 @@ enum ONcIEModType_HeavyDamage, ONcIEModType_MediumDamage, ONcIEModType_LightDamage, - + ONcIEModType_NumTypes, - + ONcIEModType_None = 0xFFFFFFFF }; @@ -67,7 +67,7 @@ typedef struct ONtIEParticle { char particle_class_name[P3cParticleClassNameLength + 1]; P3tEffectSpecification effect_spec; - + } ONtIEParticle; typedef struct ONtIESound_Version1 @@ -199,7 +199,7 @@ ONrImpactEffect( float inAIVolumeModifier, struct ONtCharacter *inAICharacter1, struct ONtCharacter *inAICharacter2); - + void ONrImpactEffect_Lookup( MAtImpactType inImpactType, @@ -257,7 +257,7 @@ ONrImpactEffects_SetupSoundPointers( UUtError ONrImpactEffects_CreateBlank( void); - + UUtError ONrImpactEffects_Save( UUtBool inAutoSave); @@ -282,4 +282,4 @@ ONrImpactEffects_WriteTextFile( void); // ====================================================================== -#endif /* ONI_IMPACTEFFECT_H */ \ No newline at end of file +#endif /* ONI_IMPACTEFFECT_H */ diff --git a/OniProj/OniGameSource/Oni_InGameUI.c b/OniProj/OniGameSource/Oni_InGameUI.c index 35619ae..f7d3181 100644 --- a/OniProj/OniGameSource/Oni_InGameUI.c +++ b/OniProj/OniGameSource/Oni_InGameUI.c @@ -20,7 +20,7 @@ #include "Oni_InGameUI.h" #include "Oni_Sound2.h" #include "Oni_Persistance.h" - + // ====================================================================== // defines @@ -229,7 +229,7 @@ typedef struct ONtInGameUI_Arc M3tTextureCoord *outer_UVs; M3tTextureCoord *inner_UVs; M3tTextureMap *texture; - + } ONtInGameUI_Arc; typedef struct tStartEnd @@ -244,27 +244,27 @@ typedef struct ONtPauseScreenData UUtUns32 highlighted_sections; UUtUns32 start_time; UUtInt16 current_level; - + ONtObjectivePage *objective; UUtInt16 objective_number; UUtInt16 objective_page_num; - + ONtDiaryPage *diary[ONcIGU_MaxDiaryPages]; UUtInt16 num_diary_pages; UUtInt16 diary_page_num; - + ONtItemPage *items[ONcIGU_MaxItems]; UUtInt16 num_items; UUtInt16 item_page_num; - + ONtWeaponPage *weapons[ONcIGU_MaxWeapons]; UUtInt16 num_weapon_pages; UUtInt16 weapon_page_num; - + ONtHelpPage *help[ONcIGU_MaxHelpPages]; UUtInt16 num_help_pages; UUtInt16 help_page_num; - + } ONtPauseScreenData; typedef struct ONtInGameUI_Meter @@ -277,14 +277,14 @@ typedef struct ONtInGameUI_Meter M3tPointScreen *draw_secondary_points; M3tTextureCoord *draw_primary_UVs; M3tTextureCoord *draw_secondary_UVs; - + } ONtInGameUI_Meter; typedef struct ONtTextConsoleData { ONtTextConsole *text_console; UUtInt32 page; - + } ONtTextConsoleData; typedef struct ONtIGUIElementDescriptionEntry @@ -544,8 +544,8 @@ ONiInGameUI_FlashElement( SLtParameter_Actual *ioReturnValue); -// void -static UUtBool ONrGameState_EventSound_InCutscene(void) +// void +static UUtBool ONrGameState_EventSound_InCutscene(void) { UUtBool result = ONgGameState->local.in_cutscene; @@ -568,7 +568,7 @@ ONiInGameUI_DrawArc( M3tPointScreen dest[3]; M3tTextureCoord uv[3]; UUtUns32 i; - + // set the shade, alpha and texture M3rDraw_State_Push(); M3rDraw_State_SetInt(M3cDrawStateIntType_Alpha, inAlpha); @@ -578,7 +578,7 @@ ONiInGameUI_DrawArc( } M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, ioArc->texture); M3rDraw_State_Commit(); - + // draw the arc for (i = 0; i < inNumSegmentsToDraw; i++) { @@ -613,36 +613,36 @@ ONiInGameUI_CalcArc( float uv_inner_radius; radians_per_segment = (inEnd - inStart) / ioArc->num_segments; - + uv_outer_radius = ioArc->outer_radius / (float)(ioArc->texture->width >> 1); uv_inner_radius = ioArc->inner_radius / (float)(ioArc->texture->width >> 1); - + // calculate the arc points for (i = 0; i < ioArc->num_points; i++) { float theta; float cos_theta; float sin_theta; - + theta = (inStart + (i * radians_per_segment)); while (theta < 0.0f) { theta += M3c2Pi; } while (theta > M3c2Pi) { theta -= M3c2Pi; } cos_theta = MUrCos(theta); sin_theta = MUrSin(theta); - + ioArc->outer_points[i].x = (cos_theta * ioArc->outer_radius) + ioArc->center.x; ioArc->outer_points[i].y = (sin_theta * ioArc->outer_radius) + ioArc->center.y; ioArc->outer_points[i].z = 0.5f; ioArc->outer_points[i].invW = 2.0f; - + ioArc->inner_points[i].x = (cos_theta * ioArc->inner_radius) + ioArc->center.x; ioArc->inner_points[i].y = (sin_theta * ioArc->inner_radius) + ioArc->center.y; ioArc->inner_points[i].z = 0.5f; ioArc->inner_points[i].invW = 2.0f; - + ioArc->outer_UVs[i].u = (cos_theta * 0.5f) * uv_outer_radius + 0.5f; ioArc->outer_UVs[i].v = (sin_theta * 0.5f) * uv_outer_radius + 0.5f; - + ioArc->inner_UVs[i].u = (cos_theta * 0.5f) * uv_inner_radius + 0.5f; ioArc->inner_UVs[i].v = (sin_theta * 0.5f) * uv_inner_radius + 0.5f; } @@ -662,13 +662,13 @@ ONiInGameUI_MakeArc( { UUtUns32 num_points; ONtInGameUI_Arc *arc; - + UUmAssert(inCenter); UUmAssert(inTextureMap); UUmAssert(outArc); - + num_points = inNumSegments + 1; - + // allocate memory for the arc arc = UUrMemory_Block_NewClear( @@ -676,7 +676,7 @@ ONiInGameUI_MakeArc( ((sizeof(M3tPointScreen) * num_points) * 2) + ((sizeof(M3tTextureCoord) * num_points) * 2)); UUmError_ReturnOnNull(arc); - + // set up the vars arc->outer_radius = inOuterRadius; arc->inner_radius = inInnerRadius; @@ -688,9 +688,9 @@ ONiInGameUI_MakeArc( arc->inner_points = (arc->outer_points + num_points); arc->outer_UVs = (M3tTextureCoord*)(arc->inner_points + num_points); arc->inner_UVs = (arc->outer_UVs + num_points); - + ONiInGameUI_CalcArc(inStart, inEnd, arc); - + *outArc = arc; return UUcError_None; } @@ -703,14 +703,14 @@ ONiInGameUI_SetArcTexture( { UUmAssert(inArc); UUmAssert(inTextureMap); - + // the texture must be the same size as the previous texture UUmAssert((inTextureMap->width == inArc->texture->width) && (inTextureMap->width == inArc->texture->width)); - + inArc->texture = inTextureMap; } - + // ---------------------------------------------------------------------- static void ONiInGameUI_DrawMeter( @@ -719,12 +719,12 @@ ONiInGameUI_DrawMeter( { M3tPointScreen dest[3]; M3tTextureCoord uv[3]; - + // set the shade and texture M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, inShade); M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, inMeter->texture); M3rDraw_State_Commit(); - + dest[0] = inMeter->draw_primary_points[3]; dest[1] = inMeter->draw_primary_points[0]; dest[2] = inMeter->draw_primary_points[1]; @@ -763,27 +763,27 @@ ONiInGameUI_CalcMeter( UUtBool is_vertical; float h_diff; float v_diff; - + h_diff = inMeter->original_primary_points[1].x - inMeter->original_primary_points[0].x; v_diff = inMeter->original_primary_points[3].y - inMeter->original_primary_points[0].y; - + is_vertical = (fabs(v_diff) > fabs(h_diff)) ? UUcTrue : UUcFalse; - + if (is_vertical) { float sec_v_diff; - + // copy [0], and [1] inMeter->draw_primary_points[0] = inMeter->original_primary_points[0]; inMeter->draw_primary_points[1] = inMeter->original_primary_points[1]; - + // calc [3], and [2] inMeter->draw_primary_points[3].x = inMeter->draw_primary_points[0].x; inMeter->draw_primary_points[3].y = inMeter->draw_primary_points[0].y + (v_diff * inPercentage); inMeter->draw_primary_points[2].x = inMeter->draw_primary_points[1].x; inMeter->draw_primary_points[2].y = inMeter->draw_primary_points[1].y + (v_diff * inPercentage); - + // calculate the secondary points sec_v_diff = inMeter->original_secondary_points[0].y - inMeter->draw_primary_points[2].y; if (((sec_v_diff < 0) && (v_diff > 0)) || ((sec_v_diff > 0) && (v_diff < 0))) @@ -795,11 +795,11 @@ ONiInGameUI_CalcMeter( // calc [2] inMeter->draw_secondary_points[2].x = inMeter->original_secondary_points[2].x; inMeter->draw_secondary_points[2].y = inMeter->draw_primary_points[2].y; - + // calc [3] inMeter->draw_secondary_points[3].x = inMeter->original_secondary_points[3].x; inMeter->draw_secondary_points[3].y = inMeter->draw_primary_points[2].y; - + // clip sec_v_diff = inMeter->draw_secondary_points[2].y - inMeter->original_secondary_points[1].y; if (((sec_v_diff < 0) && (v_diff > 0)) || ((sec_v_diff > 0) && (v_diff < 0))) @@ -814,11 +814,11 @@ ONiInGameUI_CalcMeter( else { float sec_h_diff; - + // copy [0], and [3] inMeter->draw_primary_points[0] = inMeter->original_primary_points[0]; inMeter->draw_primary_points[3] = inMeter->original_primary_points[3]; - + // calc [1], and [2] inMeter->draw_primary_points[1].x = inMeter->draw_primary_points[0].x + (h_diff * inPercentage); inMeter->draw_primary_points[1].y = inMeter->draw_primary_points[0].y; @@ -833,15 +833,15 @@ ONiInGameUI_CalcMeter( // copy [0], and [3] inMeter->draw_secondary_points[0] = inMeter->original_secondary_points[0]; inMeter->draw_secondary_points[3] = inMeter->original_secondary_points[3]; - + // calc [2] inMeter->draw_secondary_points[2].x = inMeter->draw_primary_points[1].x; inMeter->draw_secondary_points[2].y = inMeter->original_secondary_points[2].y; - + // calc[1] inMeter->draw_secondary_points[1].x = inMeter->draw_secondary_points[2].x; inMeter->draw_secondary_points[1].y = inMeter->original_secondary_points[1].y; - + // clip sec_h_diff = inMeter->draw_secondary_points[1].x - inMeter->draw_secondary_points[0].x; if (((sec_h_diff < 0) && (h_diff > 0)) || ((sec_h_diff > 0) && (h_diff < 0))) @@ -866,12 +866,12 @@ ONiInGameUI_MakeMeter( { ONtInGameUI_Meter *meter; UUtUns32 i; - + UUmAssert(inPrimaryPoints); UUmAssert(inSecondaryPoints); UUmAssert(inTextureMap); UUmAssert(outMeter); - + // allocate memory for the meter meter = UUrMemory_Block_NewClear( @@ -883,7 +883,7 @@ ONiInGameUI_MakeMeter( (sizeof(M3tTextureCoord) * 4) + // draw primary UVs (sizeof(M3tTextureCoord) * 4)); // draw secondary UVs UUmError_ReturnOnNull(meter); - + // set up the vars meter->texture = inTextureMap; meter->original_primary_points = (M3tPointScreen*)(((UUtUns8*)meter) + sizeof(ONtInGameUI_Meter)); @@ -892,7 +892,7 @@ ONiInGameUI_MakeMeter( meter->draw_secondary_points = (meter->draw_primary_points + 4); meter->draw_primary_UVs = (M3tTextureCoord*)(meter->draw_secondary_points + 4); meter->draw_secondary_UVs = (meter->draw_primary_UVs + 4); - + // save the points for (i = 0; i < 4; i++) { @@ -901,7 +901,7 @@ ONiInGameUI_MakeMeter( } ONiInGameUI_CalcMeter(inPercentage, meter); - + *outMeter = meter; return UUcError_None; } @@ -927,9 +927,9 @@ ONiInGameUI_DisplayAmmoClips( } else { draw_clips = UUmMin(cMaxNumAmmo, inPlayer->inventory.ammo); } - + if (draw_clips == 0) { return; } - + // draw the arc ONiInGameUI_DrawArc(gAmmoArc, draw_clips, cAmmoColor, (UUtUns8) alpha); } @@ -941,7 +941,7 @@ ONiInGameUI_DisplayCellClips( { UUtUns16 draw_clips; UUtUns32 alpha; - + alpha = (ONmIGUIElement_Flashing(ONcIGUIElement_EnergyCells) ? gFlashAlpha : M3cMaxAlpha); // set the number of segments to draw @@ -952,7 +952,7 @@ ONiInGameUI_DisplayCellClips( } if (draw_clips == 0) { return; } - + // draw the arc ONiInGameUI_DrawArc(gCellArc, draw_clips, cCellColor, (UUtUns8) alpha); } @@ -967,7 +967,7 @@ ONiInGameUI_DisplayHealth( IMtShade health_shade; UUtUns32 itr, health_colorval; UUtUns16 main_alpha, shadow_alpha; - + if (ONmIGUIElement_Filled(ONcIGUIElement_Health)) { // draw a full health bar gHealth.draw_arc[0] = UUcTrue; @@ -994,7 +994,7 @@ ONiInGameUI_DisplayHealth( // work out primary arc start = cHealthStart; end = start + ((cHealthEnd - start) * UUmMin(1.0f, health_percentage)); - + gHealth.draw_arc[0] = UUcTrue; ONiInGameUI_CalcArc(start, end, gHealthArc[0]); @@ -1002,10 +1002,10 @@ ONiInGameUI_DisplayHealth( { // work out secondary arc super_health_percentage = (UUmMin(health_percentage, ONgGameSettings->boosted_health) - 1.0f); - + start = cSuperHealthStart; end = start + ((cSuperHealthEnd - start) * super_health_percentage); - + gHealth.draw_arc[1] = UUcTrue; ONiInGameUI_CalcArc(start, end, gHealthArc[1]); } @@ -1027,7 +1027,7 @@ ONiInGameUI_DisplayHealth( // work out primary shadow arc start = cHealthStart + health_percentage * (cHealthEnd - cHealthStart); end = cHealthStart + UUmMin(shadow_percentage, 1.0f) * (cHealthEnd - cHealthStart); - + gHealth.draw_arc[2] = UUcTrue; ONiInGameUI_CalcArc(start, end, gHealthArc[2]); } @@ -1036,14 +1036,14 @@ ONiInGameUI_DisplayHealth( { // work out secondary shadow arc super_shadow_percentage = (UUmMin(shadow_percentage, ONgGameSettings->boosted_health) - 1.0f); - + if (super_health_percentage > 0.0f) { start = cSuperHealthStart + super_health_percentage * (cSuperHealthEnd - cSuperHealthStart); } else { start = cSuperHealthStart; } end = cSuperHealthStart + ((cSuperHealthEnd - cSuperHealthStart) * super_shadow_percentage); - + gHealth.draw_arc[3] = UUcTrue; ONiInGameUI_CalcArc(start, end, gHealthArc[3]); } @@ -1058,7 +1058,7 @@ ONiInGameUI_DisplayHealth( gHealth.needs_update = UUcFalse; } - + if (gHealth.has_aftershadow) { // health color is based on the current value of our shadow health_colorval = MUrUnsignedSmallFloat_To_Uns_Round(gHealth.shadow_val); @@ -1078,7 +1078,7 @@ ONiInGameUI_DisplayHealth( main_alpha = (UUtUns16) ((gFlashAlpha * main_alpha) / M3cMaxAlpha); shadow_alpha = (UUtUns16) ((gFlashAlpha * shadow_alpha) / M3cMaxAlpha); } - + if (!gHealth.has_foreshadow) { low_health_amount = (((float) inPlayer->hitPoints) / inPlayer->maxHitPoints) / (ONcIGUI_HealthWarnLevel / 100.0f); if (low_health_amount < 1.0f) { @@ -1138,7 +1138,7 @@ ONiInGameUI_DisplayHypos( UUtUns16 i; UUtUns16 draw_hypos; UUtUns32 alpha; - + alpha = (ONmIGUIElement_Flashing(ONcIGUIElement_Hypos) ? gFlashAlpha : M3cMaxAlpha); // set the number of segments to draw @@ -1169,7 +1169,7 @@ ONiInGameUI_DisplayInGun( M3tPointScreen dest[3]; UUtUns16 outslot; UUtUns32 alpha; - + weapon = inPlayer->inventory.weapons[0]; if (weapon == NULL) { @@ -1178,7 +1178,7 @@ ONiInGameUI_DisplayInGun( } weapon_class = WPrGetClass(weapon); if (weapon_class->hud_empty == NULL) { return; } - + alpha = (ONmIGUIElement_Flashing(ONcIGUIElement_CurrentAmmo) ? gFlashAlpha : M3cMaxAlpha); // set the number of segments to draw @@ -1193,13 +1193,13 @@ ONiInGameUI_DisplayInGun( dest[0].invW = 2.0f; dest[1].z = 0.5f; dest[1].invW = 2.0f; - + // draw the empty ammo slots dest[0].x = gLeftCenter.x - (gLeft->width >> 1); dest[0].y = gLeftCenter.y - (gLeft->height >> 1); dest[1].x = dest[0].x + gLeft->width; dest[1].y = dest[0].y + gLeft->height; - + M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_White); M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, weapon_class->hud_empty); M3rDraw_State_Commit(); @@ -1222,10 +1222,10 @@ ONiInGameUI_DisplayInGun( start = cInGunStart; end = start + ((cInGunEnd - start) * rounds_percentage); - + ONiInGameUI_CalcArc(start, end, gInGunArc); } - + // draw the arc if (weapon_class->hud_fill != NULL) { @@ -1248,24 +1248,24 @@ ONiInGameUI_DisplayInvisibility( } else { if (inPlayer->inventory.invisibilityRemaining == 0) { return; } - + if (gPrevInvisibilityRemaining != inPlayer->inventory.invisibilityRemaining) { float invis_percentage; float start; float end; - + invis_percentage = (float)inPlayer->inventory.invisibilityRemaining / (float)WPcMaxInvisibility; - + start = cInvisStart; end = start + ((cInvisEnd - start) * invis_percentage); - + ONiInGameUI_CalcArc(start, end, gInvisArc); - + gPrevInvisibilityRemaining = inPlayer->inventory.invisibilityRemaining; } } - + // draw the arc alpha = (ONmIGUIElement_Flashing(ONcIGUIElement_Invisibility) ? gFlashAlpha : M3cMaxAlpha); ONiInGameUI_DrawArc(gInvisArc, gInvisArc->num_segments, cInvisColor, (UUtUns8) alpha); @@ -1311,7 +1311,7 @@ ONiInGameUI_DisplayRadar( } else if (gHasLSITarget) { // calculate what the angle is to our target MUmVector_Subtract(player_to_target, gLSITarget, inPlayer->location); - + distance = MUmVector_GetLengthSquared(player_to_target); if (distance < gMinDistanceSquared) { @@ -1326,11 +1326,11 @@ ONiInGameUI_DisplayRadar( arc_length = M3cHalfPi - (M3cHalfPi * (distance / gMaxDistanceSquared)); } arc_length = UUmPin(arc_length, cMinArcLength, cMaxArcLength); - + delta_x = gLSITarget.x - inPlayer->location.x; delta_z = gLSITarget.z - inPlayer->location.z; target_angle = MUrATan2(delta_x, delta_z); - + angle = ONrCharacter_GetCosmeticFacing(inPlayer) - target_angle; UUmTrig_ClipAbsPi(angle); @@ -1344,12 +1344,12 @@ ONiInGameUI_DisplayRadar( end = M3c2Pi; draw_ring = UUcTrue; } - + if (draw_ring) { ONiInGameUI_CalcArc(start, end, gRadarArc); ONiInGameUI_DrawArc(gRadarArc, gRadarArc->num_segments, cRadarColor, alpha); } - + /* * draw the height arrow */ @@ -1359,7 +1359,7 @@ ONiInGameUI_DisplayRadar( } else { alpha = M3cMaxAlpha; } - + draw_uparrow = UUcFalse; draw_downarrow = UUcFalse; if (gHasLSITarget) { @@ -1382,17 +1382,17 @@ ONiInGameUI_DisplayRadar( dest[0].y = gLeftCenter.y - (cUpDnArrowDiameter * 0.5f); dest[0].z = 0.5f; dest[0].invW = 2.0f; - + dest[1].x = dest[0].x + cUpDnArrowDiameter; dest[1].y = dest[0].y + cUpDnArrowDiameter; dest[1].z = 0.5f; dest[1].invW = 2.0f; - + M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_White); M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, gUpDnArrow); M3rDraw_State_SetInt(M3cDrawStateIntType_Alpha, alpha); M3rDraw_State_Commit(); - + if (draw_uparrow) { M3rDraw_Sprite(dest, gFullTextureUVs); @@ -1405,7 +1405,7 @@ ONiInGameUI_DisplayRadar( if (alpha < M3cMaxAlpha) { // restore alpha to full M3rDraw_State_SetInt(M3cDrawStateIntType_Alpha, M3cMaxAlpha); - } + } } } @@ -1437,7 +1437,7 @@ ONiInGameUI_DisplayShield( // work out primary arc start = cShieldStart; end = start + ((cShieldEnd - start) * UUmMin(1.0f, shield_percentage)); - + gShield.draw_arc[0] = UUcTrue; ONiInGameUI_CalcArc(start, end, gShieldArc[0]); } @@ -1449,7 +1449,7 @@ ONiInGameUI_DisplayShield( // work out shadow arc start = cShieldStart + shield_percentage * (cShieldEnd - cShieldStart); end = cShieldStart + UUmMin(1.0f, shadow_percentage) * (cShieldEnd - cShieldStart); - + gShield.draw_arc[1] = UUcTrue; ONiInGameUI_CalcArc(start, end, gShieldArc[1]); } else { @@ -1458,7 +1458,7 @@ ONiInGameUI_DisplayShield( gShield.needs_update = UUcFalse; } - + main_alpha = M3cMaxAlpha; shadow_alpha = cShieldShadowAlpha; @@ -1487,7 +1487,7 @@ ONiInGameUI_DisplayWeaponIcon( UUtUns32 alpha; // WPtWeapon *stored_weapon; // UUtUns16 outslot; - + weapon = inPlayer->inventory.weapons[0]; if (weapon != NULL) { @@ -1496,7 +1496,7 @@ ONiInGameUI_DisplayWeaponIcon( { UUmAssert(weapon_class->icon->width == 64); UUmAssert(weapon_class->icon->height == 64); - + if (ONmIGUIElement_Flashing(ONcIGUIElement_Weapon)) { alpha = gFlashAlpha; } else { @@ -1507,17 +1507,17 @@ ONiInGameUI_DisplayWeaponIcon( dest[0].y = gLeftCenter.y - (cIconDrawnDiameter * 0.5f); dest[0].z = 0.5f; dest[0].invW = 2.0f; - + dest[1].x = dest[0].x + cIconDrawnDiameter; dest[1].y = dest[0].y + cIconDrawnDiameter; dest[1].z = 0.5f; dest[1].invW = 2.0f; - + M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_White); M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, weapon_class->icon); M3rDraw_State_SetInt(M3cDrawStateIntType_Alpha, alpha); M3rDraw_State_Commit(); - + M3rDraw_Sprite(dest, gFullTextureUVs); if (alpha < M3cMaxAlpha) { @@ -1525,7 +1525,7 @@ ONiInGameUI_DisplayWeaponIcon( } } } - + /* // draw the one in the holster stored_weapon = WPrSlot_FindLastStowed(inPlayer->inventory.weapons, WPcPrimarySlot, &outslot); if (stored_weapon != NULL) @@ -1535,21 +1535,21 @@ ONiInGameUI_DisplayWeaponIcon( { UUmAssert(weapon_class->icon->width == 64); UUmAssert(weapon_class->icon->height == 64); - + dest[0].x = gLeftCenter.x - (cIconStoredDiameter * 0.5f) + cIconStoredOffsetX; dest[0].y = gLeftCenter.y - (cIconStoredDiameter * 0.5f); dest[0].z = 0.5f; dest[0].invW = 2.0f; - + dest[1].x = dest[0].x + cIconStoredDiameter; dest[1].y = dest[0].y + cIconStoredDiameter; dest[1].z = 0.5f; dest[1].invW = 2.0f; - + M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_White); M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, weapon_class->icon); M3rDraw_State_Commit(); - + M3rDraw_Sprite(dest, gFullTextureUVs); } }*/ @@ -1562,12 +1562,12 @@ ONiInGameUI_DisplayLSIIcon( UUtUns16 inAlpha) { M3tPointScreen dest[2]; - + if (inPlayer->inventory.has_lsi && (gLSIIcon != NULL)) { UUmAssert(gLSIIcon->width == 64); UUmAssert(gLSIIcon->height == 64); - + if (ONmIGUIElement_Flashing(ONcIGUIElement_ItemDisplay)) { inAlpha = (UUtUns16) ((inAlpha * gFlashAlpha) / M3cMaxAlpha); } @@ -1576,7 +1576,7 @@ ONiInGameUI_DisplayLSIIcon( dest[0].y = gRightCenter.y - (cLSIIconDiameter * 0.5f); dest[0].z = 0.5f; dest[0].invW = 2.0f; - + dest[1].x = dest[0].x + cLSIIconDiameter; dest[1].y = dest[0].y + cLSIIconDiameter; dest[1].z = 0.5f; @@ -1589,7 +1589,7 @@ ONiInGameUI_DisplayLSIIcon( M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_White); M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, gLSIIcon); M3rGeom_State_Commit(); - + M3rDraw_Sprite(dest, gFullTextureUVs); if (inAlpha < M3cMaxAlpha) { @@ -1657,7 +1657,7 @@ ONiInGameUI_DisplayHelp( dest[0].y = left_position.y; dest[0].z = 0.5f; dest[0].invW = 2.0f; - + dest[1].x = dest[0].x + gHUDHelp->left_texture->width; dest[1].y = dest[0].y + gHUDHelp->left_texture->height; dest[1].z = 0.5f; @@ -1666,7 +1666,7 @@ ONiInGameUI_DisplayHelp( M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_White); M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, gHUDHelp->left_texture); M3rDraw_State_Commit(); - + M3rDraw_Sprite(dest, gFullTextureUVs); } @@ -1676,7 +1676,7 @@ ONiInGameUI_DisplayHelp( dest[0].y = right_position.y; dest[0].z = 0.5f; dest[0].invW = 2.0f; - + dest[1].x = dest[0].x + gHUDHelp->right_texture->width; dest[1].y = dest[0].y + gHUDHelp->right_texture->height; dest[1].z = 0.5f; @@ -1685,7 +1685,7 @@ ONiInGameUI_DisplayHelp( M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_White); M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, gHUDHelp->right_texture); M3rDraw_State_Commit(); - + M3rDraw_Sprite(dest, gFullTextureUVs); } @@ -1776,7 +1776,7 @@ ONrInGameUI_Display( M3tPointScreen dest[3]; UUtUns16 alpha; UUtUns32 cur_time; - + // get a pointer to the player's character player = ONrGameState_GetPlayerCharacter(); if (player == NULL) { return; } @@ -1811,28 +1811,28 @@ ONrInGameUI_Display( dest[0].y = gLeftCenter.y - (gLeft->height >> 1); dest[1].x = dest[0].x + gLeft->width; dest[1].y = dest[0].y + gLeft->height; - + M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_White); M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, gLeft); M3rDraw_State_Commit(); M3rDraw_Sprite(dest, gFullTextureUVs); - + // draw the ballistic clips arc ONiInGameUI_DisplayAmmoClips(player); - - // draw the energy clips arc + + // draw the energy clips arc ONiInGameUI_DisplayCellClips(player); // draw the radar arc ONiInGameUI_DisplayRadar(player); - + // draw the ammo arc ONiInGameUI_DisplayInGun(player); - + // draw the weapon icon ONiInGameUI_DisplayWeaponIcon(player); } - + if (gRightEnable) { // ---------------------------------------- // draw the right grid @@ -1840,7 +1840,7 @@ ONrInGameUI_Display( dest[0].y = gRightCenter.y - (gRight->height >> 1);; dest[1].x = dest[0].x + gRight->width; dest[1].y = dest[0].y + gRight->height; - + M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_White); M3rDraw_State_SetPtr(M3cDrawStatePtrType_BaseTextureMap, gRight); M3rDraw_State_Commit(); @@ -1848,10 +1848,10 @@ ONrInGameUI_Display( // draw the health arc ONiInGameUI_DisplayHealth(player); - + // draw the invisibility arc ONiInGameUI_DisplayInvisibility(player); - + // draw the shield arc ONiInGameUI_DisplayShield(player); @@ -1874,7 +1874,7 @@ ONrInGameUI_Display( // draw the help overlays ONiInGameUI_DisplayHelp(); - + M3rDraw_State_Pop(); } @@ -1884,7 +1884,7 @@ ONrInGameUI_SetArcPoints( void) { UUtUns32 i; - + // calculate the left and right centers gLeftCenter.x = 10.0f + (gLeft->width >> 1); gLeftCenter.y = (float)M3rDraw_GetHeight() - (gLeft->height >> 1); @@ -1895,7 +1895,7 @@ ONrInGameUI_SetArcPoints( gRightCenter.y = (float)M3rDraw_GetHeight() - (gRight->height >> 1); gRightCenter.z = 0.5f; gRightCenter.invW = 2.0f; - + // make the arcs for (i = 0; i < 2; i++) { ONiInGameUI_MakeArc( @@ -1918,7 +1918,7 @@ ONrInGameUI_SetArcPoints( gRightRing, &gHealthArc[2*i + 1]); } - + ONiInGameUI_MakeArc( cInvisStart, cInvisEnd, @@ -1928,7 +1928,7 @@ ONrInGameUI_SetArcPoints( 8, gRightRing, &gInvisArc); - + ONiInGameUI_MakeArc( cShieldStart, cShieldEnd, @@ -1938,7 +1938,7 @@ ONrInGameUI_SetArcPoints( 8, gRightRing, &gShieldArc[0]); - + ONiInGameUI_MakeArc( cShieldStart, cShieldEnd, @@ -1948,7 +1948,7 @@ ONrInGameUI_SetArcPoints( 8, gRightRing, &gShieldArc[1]); - + ONiInGameUI_MakeArc( cAmmoStart, cAmmoEnd, @@ -1958,7 +1958,7 @@ ONrInGameUI_SetArcPoints( cMaxNumAmmo, gLeftRing, &gAmmoArc); - + ONiInGameUI_MakeArc( cCellStart, cCellEnd, @@ -1988,7 +1988,7 @@ ONrInGameUI_SetArcPoints( 32, gLeftRing, &gRadarArc); - + for (i = 0; i < cMaxNumHypos; i++) { ONiInGameUI_MakeArc( @@ -2001,7 +2001,7 @@ ONrInGameUI_SetArcPoints( gRightRing, &gHyposArcs[i]); } - + for (i = 0; i < cMaxNumHits; i++) { ONiInGameUI_MakeArc( @@ -2022,7 +2022,7 @@ ONiInGameUI_LevelLoad( void) { UUtError error; - + // load the textures error = TMrInstance_GetDataPtr(M3cTemplate_TextureMap, "left", &gLeft); error = TMrInstance_GetDataPtr(M3cTemplate_TextureMap, "right", &gRight); @@ -2041,7 +2041,7 @@ ONiInGameUI_LevelLoad( error = TMrInstance_GetDataPtr(M3cTemplate_TextureMap, "updn_arrow", &gUpDnArrow); ONrInGameUI_SetArcPoints(); - + // set initial HUD state ONgObjectiveNumber = 0; ONgDiaryPageUnlocked = 0; // no diary pages have been read yet @@ -2076,14 +2076,14 @@ ONiInGameUI_LevelUnload( void) { UUtUns32 i; - + gLeft = NULL; gRight = NULL; gLeftRing = NULL; gRightRing = NULL; gWhite = NULL; gUpDnArrow = NULL; - + for (i = 0; i < 4; i++) { UUrMemory_Block_Delete(gHealthArc[i]); gHealthArc[i] = NULL; } @@ -2102,7 +2102,7 @@ ONiInGameUI_LevelUnload( { UUrMemory_Block_Delete(gHyposArcs[i]); gHyposArcs[i] = NULL; } - + for (i = 0; i < cMaxNumHits; i++) { UUrMemory_Block_Delete(gHitArcs[i]); gHitArcs[i] = NULL; @@ -2128,12 +2128,12 @@ ONiFIStack_Init( IMtShade inFontShade) { UUmAssert(inFontFamily); - + ONgFIStack[0].font_family = inFontFamily; ONgFIStack[0].font_size = inFontSize; ONgFIStack[0].font_style = inFontStyle; ONgFIStack[0].font_shade = inFontShade; - + ONgFIStackIndex = 0; } @@ -2143,9 +2143,9 @@ ONiFIStack_Push( ONtIGUI_FontInfo *inFontInfo) { if ((ONgFIStackIndex + 1) == ONcMaxFIStackItems) { return; } - + ONgFIStackIndex++; - + // copy all of the entries ONgFIStack[ONgFIStackIndex] = ONgFIStack[ONgFIStackIndex - 1]; @@ -2156,23 +2156,23 @@ ONiFIStack_Push( { ONgFIStack[ONgFIStackIndex].font_family = inFontInfo->font_family; } - + if ((inFontInfo->flags & IGUIcFontInfoFlag_FontSize) != 0) { ONgFIStack[ONgFIStackIndex].font_size = inFontInfo->font_size; } - + if ((inFontInfo->flags & IGUIcFontInfoFlag_FontStyle) != 0) { ONgFIStack[ONgFIStackIndex].font_style = inFontInfo->font_style; } - + if ((inFontInfo->flags & IGUIcFontInfoFlag_FontShade) != 0) { ONgFIStack[ONgFIStackIndex].font_shade = inFontInfo->font_shade; } } - + // set the new font info DCrText_SetFontInfo(&ONgFIStack[ONgFIStackIndex]); } @@ -2186,7 +2186,7 @@ ONiFIStack_Pop( { ONgFIStackIndex--; } - + // set the font info DCrText_SetFontInfo(&ONgFIStack[ONgFIStackIndex]); } @@ -2205,36 +2205,36 @@ ONiIGUI_Page_Paint( IMtPoint2D dest; UUtUns32 itr; UUtRect rect; - + if (inPage == NULL) { return; } - + // push the font info ONiFIStack_Push(&inPage->font_info); - + // set the initial dest dest.x = 0; dest.y = 0; - + if (inDrawItem->window_id == ONcPS_Txt_MainArea) { if (inPage->pict) { UUtInt16 win_width; - + WMrWindow_GetSize(inDrawItem->window, &win_width, NULL); - + switch (TMrInstance_GetTemplateTag(inPage->pict)) { case M3cTemplate_TextureMap: { UUtUns16 pict_width; UUtUns16 pict_height; - + M3rTextureRef_GetSize(inPage->pict, &pict_width, &pict_height); - + dest.x = (win_width - (UUtInt16)pict_width) >> 1; - - // draw the picture + + // draw the picture DCrDraw_TextureRef( inDrawItem->draw_context, inPage->pict, @@ -2243,19 +2243,19 @@ ONiIGUI_Page_Paint( -1, UUcFalse, M3cMaxAlpha); - + dest.y += pict_height; } break; - + case PScTemplate_PartSpecification: { UUtInt16 part_height; - + PSrPartSpec_GetSize(inPage->pict, PScPart_LeftTop, NULL, &part_height); - + dest.x = 0; - + // draw the partspec DCrDraw_PartSpec( inDrawItem->draw_context, @@ -2265,16 +2265,16 @@ ONiIGUI_Page_Paint( win_width, part_height, M3cMaxAlpha); - + dest.y += part_height; } break; } - + // leave some space between the picture and the text dest.y += 10; } - + if (inPage->text) { // draw the item text @@ -2283,19 +2283,19 @@ ONiIGUI_Page_Paint( for (itr = 0; itr < inPage->text->numStrings; itr++) { if (inPage->text->string[itr] == NULL) { continue; } - + // set the font info ONiFIStack_Push(&inPage->text->string[itr]->font_info); - + DCrDraw_String2( inDrawItem->draw_context, inPage->text->string[itr]->string, NULL, &dest, &rect); - + dest.y += (rect.bottom - rect.top); - + // restore the font info ONiFIStack_Pop(); } @@ -2310,17 +2310,17 @@ ONiIGUI_Page_Paint( for (itr = 0; itr < inPage->hint->numStrings; itr++) { if (inPage->hint->string[itr] == NULL) { continue; } - + // set the font info ONiFIStack_Push(&inPage->hint->string[itr]->font_info); - + DCrDraw_String2( inDrawItem->draw_context, inPage->hint->string[itr]->string, NULL, &dest, &rect); - + dest.y += (rect.bottom - rect.top); // restore the font info @@ -2328,7 +2328,7 @@ ONiIGUI_Page_Paint( } } } - + // pop the font info ONiFIStack_Pop(); } @@ -2342,23 +2342,23 @@ ONiIGUI_Page_PaintOverlay( IMtPoint2D dest; UUtUns32 itr; UUtRect rect; - + if (inPage == NULL) { return; } - + // push the font info ONiFIStack_Push(&inPage->font_info); - + // set the initial dest dest.x = 0; dest.y = 0; - + if (inDrawItem->window_id == ONcPS_Txt_MainArea) { UUtUns16 pict_width; UUtUns16 pict_height; UUtInt16 win_width; UUtInt16 win_height; - + if (inPage->text) { // draw the item text @@ -2367,34 +2367,34 @@ ONiIGUI_Page_PaintOverlay( for (itr = 0; itr < inPage->text->numStrings; itr++) { if (inPage->text->string[itr] == NULL) { continue; } - + // set the font info ONiFIStack_Push(&inPage->text->string[itr]->font_info); - + DCrDraw_String2( inDrawItem->draw_context, inPage->text->string[itr]->string, NULL, &dest, &rect); - + dest.y += (rect.bottom - rect.top); - + // restore the font info ONiFIStack_Pop(); } } - + if ((inPage->pict) && (TMrInstance_GetTemplateTag(inPage->pict) == M3cTemplate_TextureMap)) { WMrWindow_GetSize(inDrawItem->window, &win_width, &win_height); M3rTextureRef_GetSize(inPage->pict, &pict_width, &pict_height); - + dest.x = (win_width - (UUtInt16)pict_width) >> 1; dest.y = (win_height - (UUtInt16)pict_height) >> 1; - - // draw the picture + + // draw the picture DCrDraw_TextureRef( inDrawItem->draw_context, inPage->pict, @@ -2414,17 +2414,17 @@ ONiIGUI_Page_PaintOverlay( for (itr = 0; itr < inPage->hint->numStrings; itr++) { if (inPage->hint->string[itr] == NULL) { continue; } - + // set the font info ONiFIStack_Push(&inPage->hint->string[itr]->font_info); - + DCrDraw_String2( inDrawItem->draw_context, inPage->hint->string[itr]->string, NULL, &dest, &rect); - + dest.y += (rect.bottom - rect.top); // restore the font info @@ -2432,7 +2432,7 @@ ONiIGUI_Page_PaintOverlay( } } } - + // pop the font info ONiFIStack_Pop(); } @@ -2453,20 +2453,20 @@ ONiPS_ShowHintArea( WMtWindow *next; WMtWindow *hint_text; WMtWindow *hint_box; - + prev = WMrDialog_GetItemByID(inDialog, ONcPS_Btn_Previous); next = WMrDialog_GetItemByID(inDialog, ONcPS_Btn_Next); hint_text = WMrDialog_GetItemByID(inDialog, ONcPS_Txt_SubArea); hint_box = WMrDialog_GetItemByID(inDialog, ONcPS_Box_SubArea); - + WMrWindow_SetVisible(prev, inShow); WMrWindow_SetVisible(next, inShow); WMrWindow_SetVisible(hint_text, inShow); WMrWindow_SetVisible(hint_box, inShow); - + prev = WMrDialog_GetItemByID(inDialog, ONcPS_Btn_HelpPrevious); next = WMrDialog_GetItemByID(inDialog, ONcPS_Btn_HelpNext); - + // remove the UUcFalse if you want to have multiple pages for help WMrWindow_SetVisible(prev, UUcFalse/*!inShow*/); WMrWindow_SetVisible(next, UUcFalse/*!inShow*/); @@ -2480,22 +2480,22 @@ ONiPS_EnableButtons( { UUtBool prev_on; UUtBool next_on; - + WMtWindow *prev; WMtWindow *next; - + prev_on = UUcTrue; next_on = UUcTrue; - + prev = WMrDialog_GetItemByID(inDialog, ONcPS_Btn_Previous); next = WMrDialog_GetItemByID(inDialog, ONcPS_Btn_Next); - + switch (inData->state) { case ONcPSState_Objective: { UUtInt16 max_objective; - + if (inData->objective == NULL) { // CB: no objectives, so no buttons prev_on = next_on = UUcFalse; @@ -2505,7 +2505,7 @@ ONiPS_EnableButtons( (UUtInt16)inData->objective->objectives->num_pages, ONgObjectiveNumber); max_objective = UUmPin(max_objective, 0, (UUtInt16)inData->objective->objectives->num_pages); - + if (inData->objective_page_num == 0) { next_on = UUcFalse; } if ((inData->objective_page_num + 1 >= max_objective) || (ONgObjectiveNumber == 0)) { @@ -2514,7 +2514,7 @@ ONiPS_EnableButtons( } } break; - + case ONcPSState_Items: if (inData->num_items == 0) { @@ -2525,7 +2525,7 @@ ONiPS_EnableButtons( if (inData->item_page_num == 0) { prev_on = UUcFalse; } if (inData->item_page_num + 1 >= inData->num_items) { next_on = UUcFalse; } break; - + case ONcPSState_Weapons: if (inData->num_weapon_pages == 0) { @@ -2536,7 +2536,7 @@ ONiPS_EnableButtons( if (inData->weapon_page_num == 0) { prev_on = UUcFalse; } if (inData->weapon_page_num + 1 >= inData->num_weapon_pages) { next_on = UUcFalse; } break; - + case ONcPSState_Diary: if (inData->num_diary_pages == 0) { @@ -2562,7 +2562,7 @@ ONiPS_EnableButtons( if (inData->help_page_num + 1 >= inData->num_help_pages) { next_on = UUcFalse; }*/ break; } - + WMrWindow_SetEnabled(prev, prev_on); WMrWindow_SetEnabled(next, next_on); } @@ -2576,10 +2576,10 @@ ONiDP_SortByLevel( const ONtDiaryPage *page1; const ONtDiaryPage *page2; int result; - + page1 = *((ONtDiaryPage**)inItem1); page2 = *((ONtDiaryPage**)inItem2); - + result = (page1->level_number - page2->level_number); return result; @@ -2593,12 +2593,12 @@ ONiDP_SortByPage( const ONtDiaryPage *page1; const ONtDiaryPage *page2; int result; - + page1 = *((ONtDiaryPage**)inItem1); page2 = *((ONtDiaryPage**)inItem2); - + result = (page1->page_number - page2->page_number); - + return result; } @@ -2614,14 +2614,14 @@ ONiPS_DiaryPage_Init( UUtInt16 index; UUtInt16 first_page_index, target_page_index; UUtInt16 target_page, prev_unlocked_page; - + prev_unlocked_page = ONgDiaryPageUnlocked; ONgDiaryPageUnlocked = inUnlockedPage; // default initializations inData->num_diary_pages = 0; inData->diary_page_num = 0; - + // get a list of pointers error = TMrInstance_GetDataPtr_List( @@ -2630,7 +2630,7 @@ ONiPS_DiaryPage_Init( &num_pages, pages); UUmError_ReturnOnError(error); - + // add all of the valid diary pages to the list for (itr = 0; itr < (UUtInt16)num_pages; itr++) { @@ -2642,12 +2642,12 @@ ONiPS_DiaryPage_Init( if ((pages[itr]->level_number == inData->current_level) && (inUnlockedPage != -1) && (pages[itr]->page_number > inUnlockedPage)) { continue; } - + // add the page to the data inData->diary[inData->num_diary_pages] = pages[itr]; inData->num_diary_pages++; } - + // sort by level number and page number qsort( inData->diary, @@ -2660,9 +2660,9 @@ ONiPS_DiaryPage_Init( { UUtInt16 num_level_pages; UUtInt16 sort_level; - + if (index == inData->num_diary_pages) { break; } - + sort_level = inData->diary[index]->level_number; num_level_pages = 0; for (itr = index; itr < inData->num_diary_pages ; itr++) @@ -2670,7 +2670,7 @@ ONiPS_DiaryPage_Init( if (inData->diary[itr]->level_number != sort_level) { break; } num_level_pages++; } - + // sort the level pages if (num_level_pages > 1) { @@ -2680,12 +2680,12 @@ ONiPS_DiaryPage_Init( sizeof(ONtDiaryPage*), ONiDP_SortByPage); } - + // start at the next set of level pages index += num_level_pages; } while (1); - + // find the target page of the current level target_page = (inUnlockedPage == -1) ? 1 : inUnlockedPage; first_page_index = -1; @@ -2714,7 +2714,7 @@ ONiPS_DiaryPage_Init( target_page_index = itr; } } - + if (target_page_index != -1) { inData->diary_page_num = target_page_index; @@ -2741,7 +2741,7 @@ ONiPS_ItemPage_Init( UUtUns32 i; UUtUns32 pages_added; UUtBool page_enabled; - + inData->num_items = 0; // get a list of pointers @@ -2752,11 +2752,11 @@ ONiPS_ItemPage_Init( &num_pages, pages); UUmError_ReturnOnError(error); - + // count the items player = ONrGameState_GetPlayerCharacter(); pages_added = 0; - + // by default, show the first page inData->item_page_num = 0; @@ -2792,7 +2792,7 @@ ONiPS_ItemPage_Init( break; } } - + return UUcError_None; } @@ -2805,11 +2805,11 @@ ONiPS_ObjectivePage_Init( ONtObjectivePage *pages[1024]; UUtUns32 num_pages; UUtUns32 i; - + // clear the vars inData->objective_number = 0; inData->objective_page_num = 0; - + // get a list of pointers error = TMrInstance_GetDataPtr_List( @@ -2818,7 +2818,7 @@ ONiPS_ObjectivePage_Init( &num_pages, pages); UUmError_ReturnOnError(error); - + // get the objective pages for this level for (i = 0; i < num_pages; i++) { @@ -2827,7 +2827,7 @@ ONiPS_ObjectivePage_Init( inData->objective = pages[i]; break; } - + return UUcError_None; } @@ -2848,7 +2848,7 @@ ONiPS_WeaponPage_Init( // initialize the vars inData->num_weapon_pages = 0; inData->weapon_page_num = 0; - + // get a list of pointers error = TMrInstance_GetDataPtr_List( @@ -2857,7 +2857,7 @@ ONiPS_WeaponPage_Init( &num_pages, pages); UUmError_ReturnOnError(error); - + #if 1 // CB: this displays weapon pages for all weapons that we have unlocked for (i = 0; i < num_pages; i++) { @@ -2908,10 +2908,10 @@ ONiPS_WeaponPage_Init( { WPtWeapon *weapon; UUtBool found; - + weapon = player->inventory.weapons[i]; if (weapon == NULL) { continue; } - + // see if this weapon already has a page found = UUcFalse; for (j = 0; j < inData->num_weapon_pages; j++) @@ -2923,25 +2923,25 @@ ONiPS_WeaponPage_Init( } } if (found == UUcTrue) { continue; } - + // find an open page for the weapon for (j = 0; j < ONcIGU_MaxWeapons; j++) { if (inData->weapons[j] != NULL) { continue; } break; } - + // break if there are no more available pages if (j == ONcIGU_MaxWeapons) { break; } // find the page to store for (j = 0; j < (UUtInt16)num_pages; j++) - { + { if (pages[j]->weaponClass != WPrGetClass(weapon)) { continue; } - + inData->weapons[inData->num_weapon_pages] = pages[j]; inData->num_weapon_pages++; break; @@ -2949,7 +2949,7 @@ ONiPS_WeaponPage_Init( } } #endif - + return UUcError_None; } @@ -2962,12 +2962,12 @@ ONiHP_SortByPage( const ONtHelpPage *page1; const ONtHelpPage *page2; int result; - + page1 = *((ONtHelpPage**)inItem1); page2 = *((ONtHelpPage**)inItem2); - + result = (page1->page_number - page2->page_number); - + return result; } @@ -2980,11 +2980,11 @@ ONiPS_HelpPage_Init( ONtHelpPage *pages[1024]; UUtUns32 num_pages; UUtUns32 itr; - + // initialize the vars inData->num_help_pages = 0; inData->help_page_num = 0; - + // get a list of pointers error = TMrInstance_GetDataPtr_List( @@ -2993,21 +2993,21 @@ ONiPS_HelpPage_Init( &num_pages, pages); UUmError_ReturnOnError(error); - + // put pointers to all of the help pages into the list for (itr = 0; itr < num_pages; itr++) { inData->help[inData->num_help_pages] = pages[itr]; inData->num_help_pages++; } - + // sort the help pages by page number qsort( inData->help, inData->num_help_pages, sizeof(ONtHelpPage*), ONiHP_SortByPage); - + return UUcError_None; } @@ -3019,14 +3019,14 @@ ONiPS_Paint_Diary( WMtDrawItem *inDrawItem) { ONtDiaryPage *page; - + page = inData->diary[inData->diary_page_num]; // mark that we have now read this page inData->highlighted_sections &= ~(1 << ONcPSState_Diary); ONgInGameUI_NewMove = UUcFalse; ONrPersist_MarkDiaryPageRead(page->level_number, page->page_number); - + // draw the diary page // if (inDrawItem->window_id == ONcPS_Txt_MainArea) { @@ -3041,9 +3041,9 @@ ONiPS_Paint_Diary( UUtInt16 num_keys; UUtInt16 keys_width; UUtInt16 window_width; - + WMrWindow_GetSize(inDrawItem->window, &window_width, NULL); - + // count the keys num_keys = 0; for (i = 0; i < ONcMaxNumKeys; i++) @@ -3051,23 +3051,23 @@ ONiPS_Paint_Diary( if (page->keys[i] == 0) { break; } num_keys++; } - + // calculate the starting points for the keys keys_width = (ONcKeyWidth + ONcKeySpace) * num_keys; - + // draw the keys dest.x = (window_width - keys_width) >> 1; dest.y = 5; - + // draw the move icons for (i = 0; i < ONcMaxNumKeys; i++) { M3tTextureMap *icon; - + if (page->keys[i] == 0) { break; } - + icon = NULL; - + switch (page->keys[i] & ONcKey_Action) { case ONcKey_Punch: icon = ONgKeyIcons->punch; break; @@ -3079,22 +3079,22 @@ ONiPS_Paint_Diary( case ONcKey_Crouch: icon = ONgKeyIcons->crouch; break; case ONcKey_Jump: icon = ONgKeyIcons->jump; break; } - + switch (page->keys[i]) { case ONcKey_Plus: icon = ONgKeyIcons->plus; break; case ONcKey_Wait: /* no icon on purpose */ break; } - + if (icon != NULL) { if (page->keys[i] & ONcKey_Quick) { IMtPoint2D quick_dest; - + quick_dest = dest; quick_dest.y += (icon->height >> 1); - + DCrDraw_TextureRef( inDrawItem->draw_context, icon, @@ -3116,7 +3116,7 @@ ONiPS_Paint_Diary( M3cMaxAlpha); } } - + // draw a ring around the icon if it is a hold if (page->keys[i] & ONcKey_Hold) { @@ -3129,7 +3129,7 @@ ONiPS_Paint_Diary( UUcFalse, M3cMaxAlpha); } - + // move to the next position dest.x += 34; } @@ -3160,7 +3160,7 @@ ONiPS_Paint_Objective( { ONtIGUI_FontInfo font_info; UUtInt16 page_num; - + // we are looking at the objectives page, stop highlighting it inData->highlighted_sections &= ~(1 << ONcPSState_Objective); ONgInGameUI_NewObjective = UUcFalse; @@ -3172,7 +3172,7 @@ ONiPS_Paint_Objective( { return; } - + // set the font color if (inData->objective_page_num == inData->objective_number) { @@ -3184,14 +3184,14 @@ ONiPS_Paint_Objective( font_info.flags = IGUIcFontInfoFlag_FontShade; font_info.font_shade = IMcShade_Red; } - + ONiFIStack_Push(&font_info); - + page_num = UUmMax((ONgObjectiveNumber - inData->objective_page_num) - 1, 0); ONiIGUI_Page_Paint( inData->objective->objectives->pages[page_num], inDrawItem); - + ONiFIStack_Pop(); } @@ -3232,7 +3232,7 @@ ONiPS_Previous( case ONcPSState_Objective: { UUtInt16 max_objective; - + inData->objective_page_num++; max_objective = UUmMin( @@ -3245,17 +3245,17 @@ ONiPS_Previous( } } break; - + case ONcPSState_Items: inData->item_page_num--; if (inData->item_page_num < 0) { inData->item_page_num = 0; } break; - + case ONcPSState_Weapons: inData->weapon_page_num--; if (inData->weapon_page_num < 0) { inData->weapon_page_num = 0; } break; - + case ONcPSState_Diary: inData->diary_page_num--; if (inData->diary_page_num < 0) { inData->diary_page_num = 0; } @@ -3266,7 +3266,7 @@ ONiPS_Previous( if (inData->help_page_num < 0) { inData->help_page_num = 0; } break; } - + ONiPS_EnableButtons(inDialog, inData); } @@ -3282,7 +3282,7 @@ ONiPS_Next( inData->objective_page_num--; if (inData->objective_page_num < 0) { inData->objective_page_num = 0; } break; - + case ONcPSState_Items: inData->item_page_num++; if (inData->item_page_num >= inData->num_items) @@ -3290,7 +3290,7 @@ ONiPS_Next( inData->item_page_num = (inData->num_items - 1); } break; - + case ONcPSState_Weapons: inData->weapon_page_num++; if (inData->weapon_page_num >= inData->num_weapon_pages) @@ -3298,7 +3298,7 @@ ONiPS_Next( inData->weapon_page_num = (inData->num_weapon_pages - 1); } break; - + case ONcPSState_Diary: inData->diary_page_num++; if (inData->diary_page_num >= inData->num_diary_pages) @@ -3324,11 +3324,11 @@ ONiPauseScreen_InitDialog( { UUtError error; ONtPauseScreenData *data; - + // create the data data = &ONgPauseScreenData; WMrDialog_SetUserData(inDialog, (UUtUns32)data); - + // initialize error = ONiPS_ItemPage_Init(inDialog, data); if (error != UUcError_None) { WMrDialog_ModalEnd(inDialog, 0); return; } @@ -3337,7 +3337,7 @@ ONiPauseScreen_InitDialog( error = ONiPS_WeaponPage_Init(inDialog, data); if (error != UUcError_None) { WMrDialog_ModalEnd(inDialog, 0); return; } - + error = ONiPS_HelpPage_Init(inDialog, data); if (error != UUcError_None) { WMrDialog_ModalEnd(inDialog, 0); return; } @@ -3359,10 +3359,10 @@ ONiPauseScreen_InitDialog( // select the objective screen WMrDialog_ToggleButtonCheck(inDialog, ONcPS_Btn_Objective, ONcPS_Btn_Help, ONcPS_Btn_Objective); data->state = ONcPSState_Objective; - + // set the start time data->start_time = UUrMachineTime_Sixtieths() + (ONcPauseScreen_KeyAcceptDelay * 60); - + // hide the hint area ONiPS_ShowHintArea(inDialog, data, UUcTrue); @@ -3392,9 +3392,9 @@ ONiPauseScreen_DrawItem( { ONtPauseScreenData *data; TStFontInfo font_info; - + WMrWindow_GetFontInfo(inDrawItem->window, &font_info); - + ONiFIStack_Init( font_info.font_family, font_info.font_size, @@ -3409,32 +3409,32 @@ ONiPauseScreen_DrawItem( // draw the override text instead of the normal hint text dest.x = 0; dest.y = DCrText_GetAscendingHeight(); - + DCrDraw_String2( inDrawItem->draw_context, ONgPauseScreenOverrideMessage, NULL, &dest, - &rect); + &rect); return; } - + data = (ONtPauseScreenData*)WMrDialog_GetUserData(inDialog); switch (data->state) { case ONcPSState_Objective: ONiPS_Paint_Objective(inDialog, data, inDrawItem); break; - + case ONcPSState_Items: ONiPS_Paint_Items(inDialog, data, inDrawItem); break; - + case ONcPSState_Weapons: ONiPS_Paint_Weapons(inDialog, data, inDrawItem); break; - + case ONcPSState_Diary: ONiPS_Paint_Diary(inDialog, data, inDrawItem); break; @@ -3455,29 +3455,29 @@ ONiPauseScreen_HandleCommand( UUtUns16 control_id; ONtPauseScreenData *data; UUtBool show_help; - + data = (ONtPauseScreenData*)WMrDialog_GetUserData(inDialog); - + control_id = UUmLowWord(inParam1); - + switch (control_id) { case ONcPS_Btn_Objective: data->state = ONcPSState_Objective; break; - + case ONcPS_Btn_Items: data->state = ONcPSState_Items; break; - + case ONcPS_Btn_Weapons: data->state = ONcPSState_Weapons; break; - + case ONcPS_Btn_Diary: data->state = ONcPSState_Diary; break; - + case ONcPS_Btn_Help: data->state = ONcPSState_Help; break; @@ -3486,17 +3486,17 @@ ONiPauseScreen_HandleCommand( case ONcPS_Btn_HelpPrevious: ONiPS_Previous(inDialog, data); break; - + case ONcPS_Btn_Next: case ONcPS_Btn_HelpNext: ONiPS_Next(inDialog, data); break; - + case WMcDialogItem_Cancel: WMrDialog_ModalEnd(inDialog, 0); break; } - + switch (control_id) { case ONcPS_Btn_Objective: @@ -3512,7 +3512,7 @@ ONiPauseScreen_HandleCommand( ONrInGameUI_EnableHelpDisplay(show_help); break; } - + // enable the buttons ONiPS_EnableButtons(inDialog, data); } @@ -3533,7 +3533,7 @@ ONiPauseScreen_Paint( IMtShade selected_shade, highlighted_shade, unselected_shade; data = (ONtPauseScreenData*)WMrDialog_GetUserData(inDialog); - + if (data->start_time < UUrMachineTime_Sixtieths()) { if (LIrTestKey(LIcKeyCode_F1) == UUcTrue) @@ -3591,36 +3591,36 @@ ONiPauseScreen_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: ONiPauseScreen_InitDialog(inDialog); break; - + case WMcMessage_Destroy: ONiPauseScreen_Destroy(inDialog); break; - + case WMcMessage_Command: ONiPauseScreen_HandleCommand(inDialog, inParam1, (WMtWindow*)inParam2); break; - + case WMcMessage_DrawItem: ONiPauseScreen_DrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + case WMcMessage_Paint: ONiPauseScreen_Paint(inDialog); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -3634,46 +3634,46 @@ ONrPauseScreen_Display( LItMode mode; float orig_volume; SStImpulse *impulse; - + // save the current ui partspec_ui = PSrPartSpecUI_GetActive(); - + // set the ui to the out of game ui temp_ui = PSrPartSpecUI_GetByName(ONcInGameUIName); if (temp_ui != NULL) { PSrPartSpecUI_SetActive(temp_ui); } - + mode = LIrMode_Get(); LIrMode_Set(LIcMode_Normal); WMrActivate(); - + // play the open pause screen sound impulse = OSrImpulse_GetByName(ONcPauseScreen_OpenSound); if (impulse != NULL) { OSrImpulse_Play(impulse, NULL, NULL, NULL, NULL); } - + // lower the volume orig_volume = SS2rVolume_Get(); SS2rVolume_Set(orig_volume * ONcPauseScreen_VolumeCut); - + WMrDialog_ModalBegin( ONcPauseScreenID, NULL, ONiPauseScreen_Callback, 0, NULL); - + // restore the volume SS2rVolume_Set(orig_volume); - + // play the close pause screen sound impulse = OSrImpulse_GetByName(ONcPauseScreen_CloseSound); if (impulse != NULL) { OSrImpulse_Play(impulse, NULL, NULL, NULL, NULL); } - + WMrDeactivate(); LIrMode_Set(mode); - + // reset the active ui PSrPartSpecUI_SetActive(partspec_ui); - + // clear any override messages ONrPauseScreen_OverrideMessage(NULL); } @@ -3697,7 +3697,7 @@ ONiPauseScreen_RegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register( ONcTemplate_IGUI_String, @@ -3725,7 +3725,7 @@ ONiPauseScreen_RegisterTemplates( sizeof(ONtIGUI_PageArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register( ONcTemplate_DiaryPage, @@ -3777,11 +3777,11 @@ ONiPauseScreen_Initialize( void) { UUtError error; - + // register the templates error = ONiPauseScreen_RegisterTemplates(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -3791,19 +3791,19 @@ ONiPauseScreen_LevelLoad( UUtUns32 inLevelNum) { UUtError error; - + // intialize the pause screen data UUrMemory_Clear(&ONgPauseScreenData, sizeof(ONtPauseScreenData)); ONgPauseScreenData.current_level = (UUtInt16)inLevelNum; - + // initialize the objective page error = ONiPS_ObjectivePage_Init(&ONgPauseScreenData); UUmError_ReturnOnError(error); - + // initialize the diary page error = ONiPS_DiaryPage_Init(&ONgPauseScreenData, -1); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -3872,14 +3872,14 @@ ONiInGameUI_ObjectiveSet( return UUcError_None; } ONgObjectiveNumber = new_objective; - + if ((inParameterListLength >= 2) && (inParameterList[1].type == SLcType_String) && (UUrString_Compare_NoCase(inParameterList[1].val.str, "silent") == 0)) { // this objective is set silently - no prompting silent = UUcTrue; } - if ((ONgInGameUI_LastRestoreGame != (UUtUns32) -1) && + if ((ONgInGameUI_LastRestoreGame != (UUtUns32) -1) && (ONrGameState_GetGameTime() < ONgInGameUI_LastRestoreGame + ONcObjective_IgnoreAfterRestoreGame)) { // we restored our game recently, this objective should be silent silent = UUcTrue; @@ -3924,7 +3924,7 @@ ONiInGameUI_TargetSet( UUtInt16 flag_number; UUtBool result; M3tPoint3D location; - + // if the distance value is 0.0f, then turn off the radar if (inParameterList[1].val.f == 0.0f) { @@ -3934,13 +3934,13 @@ ONiInGameUI_TargetSet( // get the number of the flag to make the target flag_number = (UUtInt16)inParameterList[0].val.i; - + result = ONrLevel_Flag_ID_To_Location(flag_number, &location); if (result == UUcTrue) { ONtCharacter *player; M3tVector3D player_to_target; - + if (gHasLSITarget && (MUrPoint_Distance_Squared(&location, &gLSITarget) < UUmSQR(ONcObjective_SuperimposedObjective))) { // we already have this target set, ignore the subsequent event return UUcError_None; @@ -3952,10 +3952,10 @@ ONiInGameUI_TargetSet( player = ONrGameState_GetPlayerCharacter(); MUmVector_Subtract(player_to_target, gLSITarget, player->location); gMaxDistanceSquared = MUmVector_GetLengthSquared(player_to_target); - + // set the minimum distance squared gMinDistanceSquared = inParameterList[1].val.f * inParameterList[1].val.f; - + gHasLSITarget = UUcTrue; } else @@ -3963,7 +3963,7 @@ ONiInGameUI_TargetSet( COrConsole_Printf("No Flag %d exists.", flag_number); gHasLSITarget = UUcFalse; } - + if (!ONrGameState_EventSound_InCutscene()) { ONrGameState_EventSound_Play(ONcEventSound_CompassNew, NULL); } @@ -3982,11 +3982,11 @@ ONrInGameUI_Initialize( void) { UUtError error; - + // initialize error = ONiPauseScreen_Initialize(); UUmError_ReturnOnError(error); - + // preset the UVs gFullTextureUVs[0].u = 0.0f; gFullTextureUVs[0].v = 0.0f; @@ -3996,7 +3996,7 @@ ONrInGameUI_Initialize( gFullTextureUVs[2].v = 1.0f; gFullTextureUVs[3].u = 1.0f; gFullTextureUVs[3].v = 1.0f; - + gFullTextureUVsInvert[0].u = 0.0f; gFullTextureUVsInvert[0].v = 1.0f; gFullTextureUVsInvert[1].u = 1.0f; @@ -4008,7 +4008,7 @@ ONrInGameUI_Initialize( // create the script command #if CONSOLE_DEBUGGING_COMMANDS - error = + error = SLrScript_Command_Register_Void( "diary_page_unlock", "Unlocks a specific diary page on the current level.", @@ -4016,7 +4016,7 @@ ONrInGameUI_Initialize( ONiInGameUI_DiaryPageUnlock); UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "objective_complete", "Plays the objective-complete sound.", @@ -4024,7 +4024,7 @@ ONrInGameUI_Initialize( ONiInGameUI_ObjectiveComplete); UUmError_ReturnOnError(error); - error = + error = SLrGlobalVariable_Register_Float( "target_max_distance", "Sets the distance at which the radar will start to change from its minimum.", @@ -4048,7 +4048,7 @@ ONrInGameUI_Initialize( UUmError_ReturnOnError(error); #endif - error = + error = SLrScript_Command_Register_Void( "objective_set", "Sets the current objective page.", @@ -4056,16 +4056,16 @@ ONrInGameUI_Initialize( ONiInGameUI_ObjectiveSet); UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "target_set", "Sets the target to the specified flag", "flag_id:int min_distance:float", ONiInGameUI_TargetSet); UUmError_ReturnOnError(error); - + gMaxDistanceSquared = 75000.0f; - + error = SLrScript_Command_Register_Void( "text_console", @@ -4091,7 +4091,7 @@ ONrInGameUI_Initialize( ONiInGameUI_FlashElement); UUmError_ReturnOnError(error); - error = + error = SLrGlobalVariable_Register_Bool( "ui_suppress_prompt", "Suppresses UI prompting about new objectives or moves.", @@ -4107,10 +4107,10 @@ ONrInGameUI_LevelLoad( UUtUns32 inLevelNum) { UUtError error; - + error = ONiInGameUI_LevelLoad(); UUmError_ReturnOnError(error); - + error = ONiPauseScreen_LevelLoad(inLevelNum); UUmError_ReturnOnError(error); @@ -4152,10 +4152,10 @@ ONrInGameUI_RegisterTemplates( void) { UUtError error; - + error = ONiPauseScreen_RegisterTemplates(); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register( ONcTemplate_KeyIcons, @@ -4249,7 +4249,7 @@ ONrInGameUI_Update( const char *message_name, *message; UUtUns32 i, current_time; UUtInt16 hits; - + // get a pointer to the player's character player = ONrGameState_GetPlayerCharacter(); if (player == NULL) { return; } @@ -4323,16 +4323,16 @@ ONiTC_SetPicture( { WMtWindow *picture; UUtInt32 i; - + // get a pointer to the picture control picture = WMrDialog_GetItemByID(inDialog, ONcTC_Pt_Picture); if (picture == NULL) { return; } - + // set the console_data picture for (i = inTCD->page; i >= 0; i--) { if (inTCD->text_console->console_data->pages[i]->pict == NULL) { continue; } - + WMrPicture_SetPicture( picture, inTCD->text_console->console_data->pages[i]->pict); @@ -4348,10 +4348,10 @@ ONiTC_SetButtons( { WMtWindow *next; WMtWindow *close; - + next = WMrDialog_GetItemByID(inDialog, ONcTC_Btn_Next); close = WMrDialog_GetItemByID(inDialog, ONcTC_Btn_Close); - + if (inTCD->page >= ((UUtInt32)inTCD->text_console->console_data->num_pages) - 1) { WMrWindow_SetVisible(next, UUcFalse); @@ -4370,17 +4370,17 @@ ONiTC_InitDialog( WMtDialog *inDialog) { ONtTextConsoleData *tcd; - + // get a pointer to the text console data tcd = (ONtTextConsoleData*)WMrDialog_GetUserData(inDialog); if (tcd == NULL) { goto end; } - + tcd->page = 0; - + ONiTC_SetButtons(inDialog, tcd); - + return; - + end: WMrDialog_ModalEnd(inDialog, 0); } @@ -4393,10 +4393,10 @@ ONiTC_HandleDrawItem( { ONtTextConsoleData *tcd; TStFontInfo font_info; - + // get a pointer to the text console data tcd = (ONtTextConsoleData*)WMrDialog_GetUserData(inDialog); - + WMrWindow_GetFontInfo(inDrawItem->window , &font_info); ONiFIStack_Init( font_info.font_family, @@ -4418,13 +4418,13 @@ ONiTC_HandleCommand( ONtTextConsoleData *tcd; UUtUns16 command_type; UUtUns16 control_id; - + // get a pointer to the text console data tcd = (ONtTextConsoleData*)WMrDialog_GetUserData(inDialog); command_type = UUmHighWord(inParam1); control_id = UUmLowWord(inParam1); - + switch (control_id) { case ONcTC_Btn_Next: @@ -4435,12 +4435,12 @@ ONiTC_HandleCommand( WMrDialog_ModalEnd(inDialog, 0); } break; - + case ONcTC_Btn_Close: WMrDialog_ModalEnd(inDialog, 0); break; } - + ONiTC_SetButtons(inDialog, tcd); } @@ -4451,18 +4451,18 @@ ONiTC_HandleKeyDown( UUtUns32 inKey) { WMtWindow *control; - + switch (inKey) { case LIcKeyCode_Escape: control = WMrDialog_GetItemByID(inDialog, ONcTC_Btn_Close); break; - + case LIcKeyCode_Space: control = WMrDialog_GetItemByID(inDialog, ONcTC_Btn_Next); break; } - + // simulate a button click WMrMessage_Send( inDialog, @@ -4480,15 +4480,15 @@ ONiTextConsole_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: ONiTC_InitDialog(inDialog); break; - + case WMcMessage_Command: ONiTC_HandleCommand(inDialog, inParam1, (WMtWindow*)inParam2); if (UUmLowWord(inParam1) == ONcTC_Btn_Close) @@ -4496,11 +4496,11 @@ ONiTextConsole_Callback( WMrDialog_ModalEnd(inDialog, 0); } break; - + case WMcMessage_KeyDown: ONiTC_HandleKeyDown(inDialog, inParam1); break; - + case WMcMessage_DrawItem: if (inParam1 != ONcTC_Txt_Text) { break; } ONiTC_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); @@ -4510,7 +4510,7 @@ ONiTextConsole_Callback( handled = UUcFalse; break; } - + return handled; } @@ -4523,12 +4523,12 @@ ONrInGameUI_TextConsole_Display( PStPartSpecUI *partspec_ui; PStPartSpecUI *temp_ui; LItMode mode; - + if (inTextConsole == NULL) { return; } - + // save the current ui partspec_ui = PSrPartSpecUI_GetActive(); - + // set the ui to the out of game ui temp_ui = PSrPartSpecUI_GetByName(ONcInGameUIName); if (temp_ui != NULL) { PSrPartSpecUI_SetActive(temp_ui); } @@ -4536,17 +4536,17 @@ ONrInGameUI_TextConsole_Display( mode = LIrMode_Get(); LIrMode_Set(LIcMode_Normal); WMrActivate(); - + tcd.text_console = inTextConsole; tcd.page = 0; - + WMrDialog_ModalBegin( ONcTextConsoleID, NULL, ONiTextConsole_Callback, (UUtUns32)&tcd, NULL); - + WMrDeactivate(); LIrMode_Set(mode); @@ -4565,18 +4565,18 @@ ONiTextConsole_Display( SLtParameter_Actual *ioReturnValue) { ONtTextConsole *text_console; - + if (inParameterListLength != 1) { return UUcError_Generic; } if (inParameterList == NULL) { return UUcError_Generic; } - + text_console = (ONtTextConsole*)TMrInstance_GetFromName( ONcTemplate_TextConsole, inParameterList[0].val.str); if (text_console == NULL) { return UUcError_Generic; } - + ONrInGameUI_TextConsole_Display(text_console); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_InGameUI.h b/OniProj/OniGameSource/Oni_InGameUI.h index a420f68..b6d99a7 100644 --- a/OniProj/OniGameSource/Oni_InGameUI.h +++ b/OniProj/OniGameSource/Oni_InGameUI.h @@ -42,43 +42,43 @@ typedef tm_enum ONtKey ONcKey_Plus = 0x0100, ONcKey_Wait = 0x0200, - + ONcKey_Punch = 0x0001, ONcKey_Kick = 0x0002, - + ONcKey_Forward = 0x0004, ONcKey_Backward = 0x0008, ONcKey_Left = 0x0010, ONcKey_Right = 0x0020, - + ONcKey_Crouch = 0x0040, ONcKey_Jump = 0x0060, - + ONcKey_HoldPunch = (ONcKey_Hold | ONcKey_Punch), ONcKey_HoldKick = (ONcKey_Hold | ONcKey_Kick), - + ONcKey_HoldForward = (ONcKey_Hold | ONcKey_Forward), ONcKey_HoldBackward = (ONcKey_Hold | ONcKey_Backward), ONcKey_HoldLeft = (ONcKey_Hold | ONcKey_Left), ONcKey_HoldRight = (ONcKey_Hold | ONcKey_Right), - + ONcKey_HoldCrouch = (ONcKey_Hold | ONcKey_Crouch), ONcKey_HoldJump = (ONcKey_Hold | ONcKey_Jump), - + ONcKey_QuickPunch = (ONcKey_Quick | ONcKey_Punch), ONcKey_QuickKick = (ONcKey_Quick | ONcKey_Kick), - + ONcKey_QuickForward = (ONcKey_Quick | ONcKey_Forward), ONcKey_QuickBackward = (ONcKey_Quick | ONcKey_Backward), ONcKey_QuickLeft = (ONcKey_Quick | ONcKey_Left), ONcKey_QuickRight = (ONcKey_Quick | ONcKey_Right), - + ONcKey_QuickCrouch = (ONcKey_Quick | ONcKey_Crouch), ONcKey_QuickJump = (ONcKey_Quick | ONcKey_Jump), - + ONcKey_Action = 0x00FF, ONcKey_Modifier = 0xF000 - + } ONtKey; enum @@ -89,30 +89,30 @@ enum ONcWeaponStr_Range, ONcWeaponStr_FireRate, ONcWeaponStr_Hint, - + ONcWeaponStr_NumStrs }; enum { ONcItemStr_Name, - + // shield ONcShieldStr_PowerRemaining = 1, ONcShieldStr_Hint, ONcShieldStr_NumStrs, - + // hypo ONcHypoStr_Dosage = 1, ONcHypoStr_WarningLabels, ONcHypoStr_Hint, ONcHypoStr_NumStrs, - + // ammo ONcAmmoStr_Type = 1, ONcAmmoStr_Hint, ONcAmmoStr_NumStrs, - + // LSIs ONcLSIStr_Description }; @@ -135,7 +135,7 @@ typedef tm_struct ONtImagePlacement UUtBool visible; // used at runtime IMtPoint2D dest; M3tTextureMap *image; - + } ONtImagePlacement; // ---------------------------------------------------------------------- @@ -147,7 +147,7 @@ ONtIGUI_FontInfo UUtUns32 font_shade; UUtUns16 font_size; UUtUns16 flags; - + } ONtIGUI_FontInfo; #define ONcTemplate_IGUI_String UUm4CharToUns32('I', 'G', 'S', 't') @@ -164,10 +164,10 @@ typedef tm_template('I', 'G', 'S', 'A', "IGUI String Array") ONtIGUI_StringArray { tm_pad pad0[20]; - + tm_varindex UUtUns32 numStrings; tm_vararray ONtIGUI_String *string[1]; - + } ONtIGUI_StringArray; #define ONcTemplate_IGUI_Page UUm4CharToUns32('I', 'G', 'P', 'G') @@ -189,7 +189,7 @@ ONtIGUI_PageArray tm_varindex UUtUns32 num_pages; tm_vararray ONtIGUI_Page *pages[1]; - + } ONtIGUI_PageArray; @@ -202,10 +202,10 @@ ONtDiaryPage UUtInt16 page_number; UUtBool has_new_move; tm_pad pad[3]; - + ONtKey keys[12]; // must match ONcMaxNumKeys above ONtIGUI_Page *page; - + } ONtDiaryPage; #define ONcTemplate_ItemPage UUm4CharToUns32('I', 'P', 'g', 'e') @@ -214,7 +214,7 @@ ONtItemPage { WPtPowerupType powerup_type; ONtIGUI_Page *page; - + } ONtItemPage; #define ONcTemplate_ObjectivePage UUm4CharToUns32('O', 'P', 'g', 'e') @@ -225,7 +225,7 @@ ONtObjectivePage UUtInt16 level_number; ONtIGUI_PageArray *objectives; - + } ONtObjectivePage; #define ONcTemplate_WeaponPage UUm4CharToUns32('W', 'P', 'g', 'e') @@ -234,7 +234,7 @@ ONtWeaponPage { WPtWeaponClass *weaponClass; ONtIGUI_Page *page; - + } ONtWeaponPage; #define ONcTemplate_HelpPage UUm4CharToUns32('H', 'P', 'g', 'e') @@ -242,10 +242,10 @@ typedef tm_template('H', 'P', 'g', 'e', "Help Page") ONtHelpPage { tm_pad pad[2]; - + UUtInt16 page_number; ONtIGUI_Page *page; - + } ONtHelpPage; #define ONcTemplate_KeyIcons UUm4CharToUns32('K', 'e', 'y', 'I') @@ -259,13 +259,13 @@ ONtKeyIcons M3tTextureMap *backward; M3tTextureMap *left; M3tTextureMap *right; - + M3tTextureMap *crouch; M3tTextureMap *jump; - + M3tTextureMap *hold; M3tTextureMap *plus; - + } ONtKeyIcons; // -------------------------------------------- @@ -273,8 +273,8 @@ ONtKeyIcons typedef tm_template('T', 'x', 't', 'C', "Text Console") ONtTextConsole { - ONtIGUI_PageArray *console_data; - + ONtIGUI_PageArray *console_data; + } ONtTextConsole; // -------------------------------------------- @@ -301,7 +301,7 @@ ONtIGUI_HUDHelp tm_varindex UUtUns32 num_text_items; tm_vararray ONtIGUI_HUDTextItem text_items[1]; - + } ONtIGUI_HUDHelp; // ====================================================================== @@ -310,7 +310,7 @@ ONtIGUI_HUDHelp void ONrInGameUI_Display( void); - + // ---------------------------------------------------------------------- void ONrPauseScreen_Display( @@ -324,7 +324,7 @@ ONrPauseScreen_OverrideMessage( void ONrEnemyScanner_Display( void); - + UUtBool ONrEnemyScanner_IsOn( void); @@ -337,7 +337,7 @@ ONrEnemyScanner_Stop( UUtError ONrInGameUI_Initialize( void); - + UUtError ONrInGameUI_LevelLoad( UUtUns32 inLevelNum); @@ -349,11 +349,11 @@ ONrInGameUI_LevelUnload( UUtError ONrInGameUI_RegisterTemplates( void); - + void ONrInGameUI_Terminate( void); - + void ONrInGameUI_Update( void); @@ -378,6 +378,6 @@ ONrInGameUI_NotifyRestoreGame( void ONrInGameUI_TextConsole_Display( ONtTextConsole *inTextConsole); - + // ====================================================================== -#endif /* ONI_INGAMEUI_H */ \ No newline at end of file +#endif /* ONI_INGAMEUI_H */ diff --git a/OniProj/OniGameSource/Oni_InputBindings.h b/OniProj/OniGameSource/Oni_InputBindings.h index 7f5603a..e8b95f9 100644 --- a/OniProj/OniGameSource/Oni_InputBindings.h +++ b/OniProj/OniGameSource/Oni_InputBindings.h @@ -1,12 +1,12 @@ /* FILE: Oni_InputBindings.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 11, 1997 - + PURPOSE: - + Copyright 1997 */ diff --git a/OniProj/OniGameSource/Oni_KeyBindings.c b/OniProj/OniGameSource/Oni_KeyBindings.c index 221e040..6bd48d8 100644 --- a/OniProj/OniGameSource/Oni_KeyBindings.c +++ b/OniProj/OniGameSource/Oni_KeyBindings.c @@ -1,12 +1,12 @@ /* FILE: Oni_KeyBindings.c - + AUTHOR: Michael Evans - + CREATED: January 26, 2000 - + PURPOSE: - + Copyright 2000 */ @@ -23,7 +23,7 @@ typedef enum ONtDebugKeyModifiers { ONcDebugKey_Needs_Modifier, ONcDebugKey_Without_Modifier - + } ONtDebugKeyModifiers; typedef enum ONtDebugKeyWhen @@ -45,9 +45,9 @@ typedef struct ONtDebugKeyBinding const ONtDebugKeyBinding bindings[ONcDebugKey_Num] = { - { ONcDebugKey_Occl, ONcDebugKey_Tool, ONcDebugKey_Needs_Modifier, LIcKeyCode_None, LIcKeyCode_O }, + { ONcDebugKey_Occl, ONcDebugKey_Tool, ONcDebugKey_Needs_Modifier, LIcKeyCode_None, LIcKeyCode_O }, { ONcDebugKey_Invis, ONcDebugKey_Tool, ONcDebugKey_Needs_Modifier, LIcKeyCode_None, LIcKeyCode_I }, - { ONcDebugKey_Perf_Overall, ONcDebugKey_Game, ONcDebugKey_Needs_Modifier, LIcKeyCode_None, LIcKeyCode_Y }, + { ONcDebugKey_Perf_Overall, ONcDebugKey_Game, ONcDebugKey_Needs_Modifier, LIcKeyCode_None, LIcKeyCode_Y }, { ONcDebugKey_Character_Collision, ONcDebugKey_Tool, ONcDebugKey_Needs_Modifier, LIcKeyCode_None, LIcKeyCode_T }, { ONcDebugKey_Object_Collision, ONcDebugKey_Tool, ONcDebugKey_Needs_Modifier, LIcKeyCode_None, LIcKeyCode_R }, { ONcDebugKey_FastMode, ONcDebugKey_Tool, ONcDebugKey_Needs_Modifier, LIcKeyCode_None, LIcKeyCode_F }, @@ -112,7 +112,7 @@ UUtBool ONrDebugKey_WentDown(ONtDebuggingKey inKey) return UUcFalse; } - if (LIrTestKey(LIcKeyCode_LeftControl) || LIrTestKey(LIcKeyCode_RightControl)) + if (LIrTestKey(LIcKeyCode_LeftControl) || LIrTestKey(LIcKeyCode_RightControl)) { UUtBool shift_down = LIrTestKey(LIcKeyCode_LeftShift) || LIrTestKey(LIcKeyCode_RightShift); UUtBool alt_down = LIrTestKey(LIcKeyCode_LeftAlt) || LIrTestKey(LIcKeyCode_RightAlt); diff --git a/OniProj/OniGameSource/Oni_KeyBindings.h b/OniProj/OniGameSource/Oni_KeyBindings.h index 97b5f28..83bdf00 100644 --- a/OniProj/OniGameSource/Oni_KeyBindings.h +++ b/OniProj/OniGameSource/Oni_KeyBindings.h @@ -4,13 +4,13 @@ /* FILE: Oni_KeyBindings.h - + AUTHOR: Michael Evans - + CREATED: January 26, 2000 - + PURPOSE: - + Copyright 2000 */ @@ -55,7 +55,7 @@ typedef enum ONtDebuggingKey ONcDebugKey_ToggleActiveCamera, ONcDebugKey_SingleStepMode, - + ONcDebugKey_CharToCamera, ONcDebugKey_KillParticles, @@ -81,10 +81,10 @@ typedef enum ONtDebuggingKey ONcDebugKey_Num, ONcDebugKey_None - + } ONtDebuggingKey; UUtBool ONrDebugKey_WentDown(ONtDebuggingKey inKey); -#endif // __ONI_KEYBINDINGS_H__ \ No newline at end of file +#endif // __ONI_KEYBINDINGS_H__ diff --git a/OniProj/OniGameSource/Oni_Level.c b/OniProj/OniGameSource/Oni_Level.c index 21b4fef..85f9747 100644 --- a/OniProj/OniGameSource/Oni_Level.c +++ b/OniProj/OniGameSource/Oni_Level.c @@ -1,8 +1,8 @@ /* Oni_Level.c - + Level stuff - + Author: Quinn Dunki c1998 Bungie */ @@ -45,7 +45,7 @@ UUtError AIrCreatePlayerFromTextFile(void) ONtFlag flag; UUtError error; UUtUns16 itr, char_index; - + // player character is denoted by script ID 0 setup = ONrLevel_CharacterSetup_ID_To_Pointer(0); if (setup == NULL) { @@ -74,10 +74,10 @@ UUtError AIrCreatePlayerFromTextFile(void) // create the character at this flag error = ONrGameState_NewCharacter(NULL, setup, &flag, &char_index); UUmError_ReturnOnError(error); - + // set this character to be the player controlled character ONrGameState_SetPlayerNum(char_index); - + return UUcError_None; } @@ -86,7 +86,7 @@ typedef struct ONtLevel_FindLocation const OBJtObject *closest_object; float closest_distance; /* distance of the closest_object from position */ M3tPoint3D position; /* find object closest to this position */ - + } ONtLevel_FindLocation; // --- @@ -124,7 +124,7 @@ ONiLevel_SetDefaultReverb( { UUtUns16 num_descriptors; UUtError error; - + num_descriptors = (UUtUns16)TMrInstance_GetTagCount(ONcTemplate_Level_Descriptor); if (num_descriptors > 0) @@ -134,7 +134,7 @@ ONiLevel_SetDefaultReverb( for (i = 0; i < num_descriptors; i++) { ONtLevel_Descriptor *descriptor; - + // get a pointer to the first descriptor error = TMrInstance_GetDataPtr_ByNumber( @@ -142,17 +142,17 @@ ONiLevel_SetDefaultReverb( i, &descriptor); if (error != UUcError_None) return error; - + if (descriptor->level_number == inLevelNum) { -#if 0 +#if 0 // set the default reverb for the level SSrReverb_SetDefault(descriptor->default_reverb); #endif } } } - + return UUcError_None; } @@ -165,27 +165,27 @@ ONiDialog_LevelLoadProgress( { UUtBool handled; WMtWindow *progress_bar; - + handled = UUcTrue; - + // get the progress bar progress_bar = WMrDialog_GetItemByID(inDialog, OWcLevelLoad_ProgressBar); - + switch (inMessage) { case WMcMessage_InitDialog: WMrMessage_Send(progress_bar, WMcMessage_SetValue, 0, 0); break; - + case WMcMessage_SetValue: WMrMessage_Send(progress_bar, WMcMessage_SetValue, inParam1, 0); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -196,9 +196,9 @@ ONiLevel_LevelLoadDialog_Start( void) { WMtDialogID id; - + if (ONgLevelLoadProgress != NULL) { return; } - + // load the dialog #if SHIPPING_VERSION id = OWcDialog_OGU_LevelLoadProgress; @@ -207,14 +207,14 @@ ONiLevel_LevelLoadDialog_Start( #else id = OWcDialog_LevelLoadProgress; #endif - + WMrDialog_Create( id, NULL, ONiDialog_LevelLoadProgress, (UUtUns32) -1, &ONgLevelLoadProgress); - + // display the dialog on the screen M3rGeom_Frame_Start(0); WMrDisplay(); @@ -226,7 +226,7 @@ ONiLevel_LevelLoadDialog_Stop( void) { if (ONgLevelLoadProgress == NULL) { return; } - + // tell the dialog to stop and do one more update so it // can process the stop order WMrWindow_Delete(ONgLevelLoadProgress); @@ -245,7 +245,7 @@ ONrLevel_LevelLoadDialog_Update( // update the dialog's progress bar WMrMessage_Send(ONgLevelLoadProgress, WMcMessage_SetValue, (UUtUns32)inPercentComplete, 0); - + // display the dialog on the screen M3rGeom_Frame_Start(0); WMrDisplay(); @@ -274,7 +274,7 @@ ONrLevel_Unload( ONrMechanics_LevelEnd(); OBJrObject_LevelEnd(); - + ONrInGameUI_LevelUnload(); AIrLevelEnd(); AI2rLevelEnd(); @@ -294,9 +294,9 @@ ONrLevel_Unload( TMrLevel_Unload(ONgCurrentLevel); SS2rSoundData_FlushDeallocatedPointers(); // CB: must come after TMrLevel_Unload, it flushes pointers to disposed sound data WMrLevel_Unload(); - + UUrMemory_Leak_StopAndReport(); - + if (ONgCurrentLevel == 0) { ONgCurrentLevel = (UUtUns16)(-1); @@ -320,20 +320,20 @@ static UUtError ONrLevel_TemplateHandler( /************** * Level template handler */ - + ONtLevel *level = (ONtLevel *)inDataPtr; - + switch(inMessage) { case TMcTemplateProcMessage_Update: case TMcTemplateProcMessage_DisposePreProcess: break; - - case TMcTemplateProcMessage_NewPostProcess: - case TMcTemplateProcMessage_LoadPostProcess: + + case TMcTemplateProcMessage_NewPostProcess: + case TMcTemplateProcMessage_LoadPostProcess: break; - - + + default: UUmAssert(!"Illegal message"); } @@ -348,9 +348,9 @@ UUtError ONrLevel_Initialize( /****************** * Performs game launch init for level data structures */ - + UUtError error; - + // Install level template's private data error = TMrTemplate_PrivateData_New( ONcTemplate_Level, @@ -358,7 +358,7 @@ UUtError ONrLevel_Initialize( ONrLevel_TemplateHandler, &ONgTemplate_Level_PrivateData); UUmError_ReturnOnError(error); - + // Install flag array template's proc handler error = TMrTemplate_PrivateData_New( ONcTemplate_FlagArray, @@ -366,10 +366,10 @@ UUtError ONrLevel_Initialize( ONiFlagArray_TemplateHandler, &ONgTemplate_FlagArray_PrivateData); UUmError_ReturnOnError(error); - + ONgCurrentLevel = 0; // ONgLevelLoadDialog = NULL; - + return UUcError_None; } @@ -379,7 +379,7 @@ void ONrLevel_Terminate( /**************** * Performs game shutdown of level data structures */ - + // can't possibly imagine what might go here, because the // template manager handles private data shutdown } @@ -389,13 +389,13 @@ ONrLevel_LoadZero( void) { UUtError error; - + UUrStartupMessage("loading level 0..."); // load the texture materials error = ONrTextureMaterials_Initialize(); UUmError_ReturnOnErrorMsg(error, "Could not initialize the texture materials"); - + // initialize the impact effects error = ONrImpactEffects_Initialize(); UUmError_ReturnOnErrorMsg(error, "Could not initialize the impact effects"); @@ -417,11 +417,11 @@ ONrLevel_LoadZero( // initialize the oni sound variant list error = OSrLevel_Load(0); UUmError_ReturnOnErrorMsg(error, "The sound system didn't like level 0"); - + // load binary data files (p3 particles, sounds, etc) error = OBDrLevel_Load(0); UUmError_ReturnOnErrorMsg(error, "Could not load binary data for level 0"); - + ONrIEBinaryData_Process(); ONrTextureMaterials_PreProcess(); @@ -457,7 +457,7 @@ static UUtError ONrLevel_ParticleLoad() // begin particles for the level EPrLevelStart(0); - + return UUcError_None; } @@ -472,10 +472,10 @@ UUtError ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar) TRgLevelNumber = inLevelNum; UUrMemory_Leak_Start("These leaks are between level load and unload"); - + // disable all sound except stuff coming from scripts OSrSetScriptOnly(UUcTrue); - + // display the level load dialog if (inProgressBar) { ONiLevel_LevelLoadDialog_Start(); @@ -485,15 +485,15 @@ UUtError ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar) // load the level from storage error = TMrLevel_Load(inLevelNum, TMcPrivateData_Yes); UUmError_ReturnOnError(error); - + if (inProgressBar) { ONrLevel_LevelLoadDialog_Update(20); } - + // prepare the object system for data read by the binary data loader error = OBJrLevel_Load(inLevelNum); UUmError_ReturnOnError(error); - + if (inProgressBar) { ONrLevel_LevelLoadDialog_Update(24); } @@ -501,14 +501,14 @@ UUtError ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar) // load binary data for the level (p3 particles, furniture, object placement etc) error = OBDrLevel_Load(inLevelNum); UUmError_ReturnOnErrorMsg(error, "Could not load binary data"); - + if (inProgressBar) { ONrLevel_LevelLoadDialog_Update(25); } // Reset all the textures for the card M3rDrawContext_ResetTextures(); - + if (inProgressBar) { ONrLevel_LevelLoadDialog_Update(28); } @@ -523,11 +523,11 @@ UUtError ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar) // texture materials must be loaded before akira (needed to set up breakable flag) ONrTextureMaterials_LevelLoad(); - + // akira error = AKrLevel_Begin(ONgGameState->level->environment); UUmError_ReturnOnError(error); - + if (inProgressBar) { ONrLevel_LevelLoadDialog_Update(35); } @@ -535,10 +535,10 @@ UUtError ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar) // Sound error = ONiLevel_SetDefaultReverb(inLevelNum); UUmError_ReturnOnError(error); - + error = OSrLevel_Load(inLevelNum); UUmError_ReturnOnError(error); - + // particles must be after AKrLevel_Begin due to decal creation against the environment error = ONrLevel_ParticleLoad(); UUmError_ReturnOnError(error); @@ -573,7 +573,7 @@ UUtError ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar) // Doors (after objects) error = OBrDoor_Array_LevelBegin(&ONgGameState->doors,ONgGameState->level->doorArray); - UUmError_ReturnOnErrorMsg(error, "Door init failed"); + UUmError_ReturnOnErrorMsg(error, "Door init failed"); if (inProgressBar) { ONrLevel_LevelLoadDialog_Update(65); @@ -596,10 +596,10 @@ UUtError ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar) error = OBJrFurniture_CreateParticles(); UUmError_ReturnOnError(error); - // initialize the AI + // initialize the AI error = AIrLevelBegin(); UUmError_ReturnOnError(error); - + // Initialize the script system - this must come before the AI2 system is initialized // or else spawn scripts will not function on characters error = ONrScript_LevelBegin(ONgGameState->level->name); @@ -608,7 +608,7 @@ UUtError ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar) // initialize the new AI system: // creates characters from OBJcType_Character objects error = AI2rLevelBegin(); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); // make sure that we have a player character by now. if there has not been one made // by the AI2 system, creates character 0 as player character. @@ -638,16 +638,16 @@ UUtError ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar) // set the input mode to game LIrMode_Set(LIcMode_Game); - + // enable the console display COrConsole_TemporaryDisable(UUcFalse); COrMessage_TemporaryDisable(UUcFalse); #if TOOL_VERSION - // Run the console config file + // Run the console config file if (COcConfigFile_Read == ONgCommandLine.readConfigFile) COrRunConfigFile("oni_config.txt"); #endif - + if (inProgressBar) { ONrLevel_LevelLoadDialog_Update(85); } @@ -659,14 +659,14 @@ UUtError ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar) error = ONrMechanics_LevelBegin( ); UUmError_ReturnOnError(error); - + if (inProgressBar) { ONrLevel_LevelLoadDialog_Update(87); } error = ONrInGameUI_LevelLoad(inLevelNum); UUmError_ReturnOnError(error); - + if (inProgressBar) { ONrLevel_LevelLoadDialog_Update(90); } @@ -679,7 +679,7 @@ UUtError ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar) // hide level load dialog ONiLevel_LevelLoadDialog_Stop(); - + // save the loaded level number ONgCurrentLevel = inLevelNum; @@ -688,7 +688,7 @@ UUtError ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar) // find appropriate AItCharacterSetup instances. error = SLrScript_ExecuteOnce("main", 0, NULL, NULL, NULL); - + ONrGameState_SplashScreen("intro_splash_screen", NULL, UUcFalse); // enable all sound @@ -703,10 +703,10 @@ ONiFlagsExist( UUtUns32 inUserData) { UUtBool *found; - + found = (UUtBool*)inUserData; *found = UUcTrue; - + return UUcFalse; } @@ -717,33 +717,33 @@ ONiFlagArray_TemplateHandler( void* inPrivateData) { ONtFlagArray *flag_array; - + flag_array = (ONtFlagArray*)inDataPtr; UUmAssert(flag_array); - + switch(inMessage) { case TMcTemplateProcMessage_Update: case TMcTemplateProcMessage_DisposePreProcess: - case TMcTemplateProcMessage_NewPostProcess: + case TMcTemplateProcMessage_NewPostProcess: break; - + case TMcTemplateProcMessage_LoadPostProcess: { UUtUns32 i; UUtBool flags_exist; UUtError error; OBJtOSD_All osd_all; - + // don't create any flags from the flag array if // any flags have already been created flags_exist = UUcFalse; OBJrObjectType_EnumerateObjects( OBJcType_Flag, ONiFlagsExist, - (UUtUns32)&flags_exist); + (UUtUns32)&flags_exist); if (flags_exist) { break; } - + // set up default flag properties error = OBJrObject_OSD_SetDefaults(OBJcType_Flag, &osd_all); UUmError_ReturnOnError(error); @@ -753,20 +753,20 @@ ONiFlagArray_TemplateHandler( { M3tPoint3D rotation; ONtFlag *flag; - + flag = &flag_array->flags[i]; - + osd_all.osd.flag_osd.shade = IMcShade_Green; osd_all.osd.flag_osd.id_prefix = 'MX'; osd_all.osd.flag_osd.id_number = flag->idNumber; #if TOOL_VERSION osd_all.osd.flag_osd.note[0] = '\0'; #endif - + rotation.x = 0.0f; - rotation.y = flag->rotation * M3cRadToDeg; + rotation.y = flag->rotation * M3cRadToDeg; rotation.z = 0.0f; - + OBJrObject_New( OBJcType_Flag, &flag->location, @@ -774,8 +774,8 @@ ONiFlagArray_TemplateHandler( &osd_all); } } - break; - + break; + default: UUmAssert(!"Illegal message"); break; @@ -791,16 +791,16 @@ ONiLevel_Flag_GetByLocation( { ONtLevel_FindLocation *find_loc; float distance_squared; - + find_loc = (ONtLevel_FindLocation*)inUserData; - + distance_squared = MUrPoint_Distance_Squared(&inObject->position, &find_loc->position); if (distance_squared < find_loc->closest_distance) { find_loc->closest_distance = distance_squared; find_loc->closest_object = inObject; } - + return UUcTrue; } @@ -811,17 +811,17 @@ ONrLevel_Flag_ID_To_Location( { OBJtOSD_All osd_all; OBJtObject *object; - + // set the search params osd_all.osd.flag_osd.id_number = inID; - + // find the object object = OBJrObjectType_Search(OBJcType_Flag, OBJcSearch_FlagID, &osd_all); if (object == NULL) { return UUcFalse; } - + // return the object location OBJrObject_GetPosition(object, outLocation, NULL); - + return UUcTrue; } @@ -829,19 +829,19 @@ UUtBool ONrLevel_Path_ID_To_Path(UUtInt16 inID, OBJtOSD_PatrolPath *outPath) { OBJtOSD_All osd_all; OBJtObject *object; - + // set the search params osd_all.osd.patrolpath_osd.id_number = inID; - + // find the object object = OBJrObjectType_Search(OBJcType_PatrolPath, OBJcSearch_PatrolPathID, &osd_all); if (object == NULL) { return UUcFalse; } OBJrObject_GetObjectSpecificData(object, &osd_all); - - // build an ONtFlag + + // build an ONtFlag *outPath = osd_all.osd.patrolpath_osd; - + return UUcTrue; } @@ -849,19 +849,19 @@ UUtBool ONrLevel_Combat_ID_To_Combat(UUtUns16 inID, OBJtOSD_Combat *outCombat) { OBJtOSD_All osd_all; OBJtObject *object; - + // set the search params osd_all.osd.combat_osd.id = inID; - + // find the object object = OBJrObjectType_Search(OBJcType_Combat, OBJcSearch_CombatID, &osd_all); if (object == NULL) { return UUcFalse; } OBJrObject_GetObjectSpecificData(object, &osd_all); - + // store the combat settings *outCombat = osd_all.osd.combat_osd; - + return UUcTrue; } @@ -873,7 +873,7 @@ UUtBool ONrLevel_Melee_ID_To_Melee_Ptr(UUtUns16 inID, OBJtOSD_Melee **outMelee) { OBJtOSD_All osd_all; OBJtObject *object; - + // find the object with this ID osd_all.osd.melee_osd.id = inID; object = OBJrObjectType_Search(OBJcType_Melee, OBJcSearch_MeleeID, &osd_all); @@ -890,19 +890,19 @@ UUtBool ONrLevel_Neutral_ID_To_Neutral(UUtUns16 inID, OBJtOSD_Neutral *outNeutra { OBJtOSD_All osd_all; OBJtObject *object; - + // set the search params osd_all.osd.neutral_osd.id = inID; - + // find the object object = OBJrObjectType_Search(OBJcType_Neutral, OBJcSearch_NeutralID, &osd_all); if (object == NULL) { return UUcFalse; } OBJrObject_GetObjectSpecificData(object, &osd_all); - - // store the neutral behavior + + // store the neutral behavior *outNeutral = osd_all.osd.neutral_osd; - + return UUcTrue; } @@ -914,17 +914,17 @@ ONrLevel_Flag_ID_To_Flag( OBJtOSD_All osd_all; OBJtObject *object; M3tPoint3D z_axis; - + // set the search params osd_all.osd.flag_osd.id_number = inID; - + // find the object object = OBJrObjectType_Search(OBJcType_Flag, OBJcSearch_FlagID, &osd_all); if (object == NULL) { return UUcFalse; } - - // build an ONtFlag + + // build an ONtFlag OBJrObject_GetObjectSpecificData(object, &osd_all); - + // CB: to make sure that the flag's *actual* rotation is drawn we don't just use // the euler Y angle any more, but rather work out where the rotation matrix takes // the +Z axis to. @@ -936,7 +936,7 @@ ONrLevel_Flag_ID_To_Flag( outFlag->idNumber = osd_all.osd.flag_osd.id_number; outFlag->deleted = UUcFalse; outFlag->maxFlag = UUcFalse; - + return UUcTrue; } @@ -946,10 +946,10 @@ ONrLevel_Flag_GetVector( M3tVector3D *outVector) { const M3tPoint3D defFacing = {0,0,1.0f}; - + UUmAssertReadPtr(inFlag, sizeof(*inFlag)); UUmAssertWritePtr(outVector, sizeof(*outVector)); - + MUrPoint_RotateYAxis(&defFacing, inFlag->rotation, outVector); MUrNormalize(outVector); } @@ -977,28 +977,28 @@ ONrLevel_Flag_Location_To_Flag( { ONtLevel_FindLocation find_loc; OBJtOSD_All osd_all; - + UUrMemory_Clear(outFlag, sizeof(ONtFlag)); - + // setup the find_id struct find_loc.closest_object = NULL; find_loc.closest_distance = UUcFloat_Max; find_loc.position = *inLocation; - + // enumerate the objects OBJrObjectType_EnumerateObjects(OBJcType_Flag, ONiLevel_Flag_GetByLocation, (UUtUns32)&find_loc); - + // if no object was found, return NULL if (find_loc.closest_object == NULL) { return UUcFalse; } - + OBJrObject_GetObjectSpecificData(find_loc.closest_object, &osd_all); - + outFlag->location = find_loc.closest_object->position; outFlag->rotation = (find_loc.closest_object->rotation.y * M3cDegToRad); outFlag->idNumber = osd_all.osd.flag_osd.id_number; outFlag->deleted = UUcFalse; outFlag->maxFlag = UUcFalse; - + return UUcTrue; } @@ -1008,14 +1008,14 @@ ONrLevel_Flag_Delete( { OBJtOSD_All osd_all; OBJtObject *object; - + // set the search params osd_all.osd.flag_osd.id_number = inID; - + // find the object object = OBJrObjectType_Search(OBJcType_Flag, OBJcSearch_FlagID, &osd_all); if (object == NULL) { return; } - + OBJrObject_Delete(object); } @@ -1120,14 +1120,14 @@ UUtUns16 ONrLevel_GetNextLevel(UUtUns16 inLevelNum) UUtUns32 num_descriptors; UUtUns32 i; UUtUns16 next_level = 0xFFFF; - + // get the number of descriptors num_descriptors = TMrInstance_GetTagCount(ONcTemplate_Level_Descriptor); for (i = 0; i < num_descriptors; i++) { ONtLevel_Descriptor *descriptor; - + // get a pointer to the first descriptor error = TMrInstance_GetDataPtr_ByNumber(ONcTemplate_Level_Descriptor, i, &descriptor); UUmAssert(UUcError_None == error); diff --git a/OniProj/OniGameSource/Oni_Level.h b/OniProj/OniGameSource/Oni_Level.h index 29306c1..3f4e1f5 100644 --- a/OniProj/OniGameSource/Oni_Level.h +++ b/OniProj/OniGameSource/Oni_Level.h @@ -2,9 +2,9 @@ /* Oni_Level.h - + Level stuff - + Author: Quinn Dunki c1998 Bungie */ @@ -50,7 +50,7 @@ typedef tm_template('O','N','M','A', "Imported Marker Node Array") ONtMarkerArray { tm_pad pad0[22]; - + tm_varindex UUtUns16 numMarkers; tm_vararray ONtMarker markers[1]; } ONtMarkerArray; @@ -90,7 +90,7 @@ ONtSpawnArray typedef tm_struct ONtObjectGunk { UUtUns32 object_tag; - TMtIndexArray *gq_array; + TMtIndexArray *gq_array; } ONtObjectGunk; #define ONcTemplate_ObjectGunkArray UUm4CharToUns32('O', 'N', 'O', 'A') @@ -130,19 +130,19 @@ ONtTriggerArray tm_vararray ONtTrigger triggers[1]; } ONtTriggerArray; - + #define ONcTemplate_Level UUm4CharToUns32('O','N','L','V') typedef tm_template('O','N','L','V', "Oni Game Level") ONtLevel { char name[64]; // Must be same as ONcMaxLevelName above (for TE) - + AKtEnvironment *environment; OBtObjectSetupArray *objectSetupArray; ONtMarkerArray *markerArray; ONtFlagArray *flagArray; ONtTriggerArray *triggerArray; - + ONtSkyClass *sky_class; float sky_height; @@ -150,7 +150,7 @@ ONtLevel AItScriptTriggerClassArray *scriptTriggerArray; ONtSpawnArray *spawnArray; OBtDoorClassArray *doorArray; - + ONtObjectGunkArray *object_gunk_array; EPtEnvParticleArray *envParticleArray; @@ -165,11 +165,11 @@ ONtLevel typedef tm_template('O', 'N', 'L', 'D', "Oni Game Level Descriptor") ONtLevel_Descriptor { - + UUtUns16 level_number; UUtUns16 next_level_number; char level_name[64]; // must be the same as ONcMaxLevelName - + } ONtLevel_Descriptor; @@ -206,7 +206,7 @@ ONrLevel_LevelLoadDialog_Update( UUtUns16 ONrLevel_GetCurrentLevel( void); - + void ONrLevel_Unload( void); @@ -224,7 +224,7 @@ ONrLevel_Load(UUtUns16 inLevelNum, UUtBool inProgressBar); void ONrLevel_Terminate( void); - + UUtError ONrLevel_Initialize( void); @@ -241,14 +241,14 @@ ONrLevel_Trigger_Display( ONtTrigger *inTrigger, UUtUns32 inShade); -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // action markers ONtActionMarker* ONrLevel_ActionMarker_New( void); ONtActionMarker* ONrLevel_ActionMarker_FindNearest(const M3tPoint3D *inLocation); -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // object ids UUtBool ONrLevel_FindObjectTag( UUtUns32 inObjectTag ); @@ -256,9 +256,9 @@ ONtObjectGunk *ONrLevel_FindObjectGunk( UUtUns32 inObjectTag ); IMtShade ONrLevel_ObjectGunk_GetShade(ONtObjectGunk *inObjectGunk); void ONrLevel_ObjectGunk_SetShade(ONtObjectGunk *inObjectGunk, IMtShade inShade); -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // preload textures void ONrLevel_Preload_Textures(void); -#endif /* ONI_LEVEL_H */ \ No newline at end of file +#endif /* ONI_LEVEL_H */ diff --git a/OniProj/OniGameSource/Oni_Mechanics.c b/OniProj/OniGameSource/Oni_Mechanics.c index 78748df..44e5803 100644 --- a/OniProj/OniGameSource/Oni_Mechanics.c +++ b/OniProj/OniGameSource/Oni_Mechanics.c @@ -21,7 +21,7 @@ UUtUns16 ONrMechanics_GetNextID( OBJtObjectType inObjectType ) UUtUns32 object_count; OBJtObject **object_list; UUtError error; - + mechanics_class = OBJrObjectType_GetMechanicsByType( inObjectType ); UUmAssert( mechanics_class ); if( !mechanics_class ) return 0xFFFF; @@ -58,7 +58,7 @@ UUtError ONrMechanics_Default_ClassMethod_LevelBegin( struct ONtMechanicsClass * OBJtObject **object_list; OBJtObject *object; UUtError error; - + UUmAssert( inClass ); error = OBJrObjectType_GetObjectList( inClass->object_type, &object_list, &object_count ); UUmAssert( error == UUcError_None ); @@ -70,7 +70,7 @@ UUtError ONrMechanics_Default_ClassMethod_LevelBegin( struct ONtMechanicsClass * object = object_list[i]; UUmAssert( object ); - + inClass->methods.rInitialize( object ); } return UUcError_None; @@ -83,7 +83,7 @@ UUtError ONrMechanics_Default_ClassMethod_LevelEnd( struct ONtMechanicsClass *in OBJtObject **object_list; OBJtObject *object; UUtError error; - + UUmAssert( inClass ); error = OBJrObjectType_GetObjectList( inClass->object_type, &object_list, &object_count ); UUmAssert( error == UUcError_None ); @@ -95,7 +95,7 @@ UUtError ONrMechanics_Default_ClassMethod_LevelEnd( struct ONtMechanicsClass *in object = object_list[i]; UUmAssert( object ); - + inClass->methods.rTerminate( object ); } return UUcError_None; @@ -108,7 +108,7 @@ UUtError ONrMechanics_Default_ClassMethod_Reset( struct ONtMechanicsClass *inCla OBJtObject **object_list; OBJtObject *object; UUtError error; - + UUmAssert( inClass ); error = OBJrObjectType_GetObjectList( inClass->object_type, &object_list, &object_count ); UUmAssert( error == UUcError_None ); @@ -120,7 +120,7 @@ UUtError ONrMechanics_Default_ClassMethod_Reset( struct ONtMechanicsClass *inCla object = object_list[i]; UUmAssert( object ); - + inClass->methods.rReset( object ); } return UUcError_None; @@ -133,7 +133,7 @@ void ONrMechanics_Default_ClassMethod_Update( struct ONtMechanicsClass *inClass OBJtObject **object_list; OBJtObject *object; UUtError error; - + UUmAssert( inClass ); error = OBJrObjectType_GetObjectList( inClass->object_type, &object_list, &object_count ); UUmAssert( error == UUcError_None ); @@ -145,7 +145,7 @@ void ONrMechanics_Default_ClassMethod_Update( struct ONtMechanicsClass *inClass object = object_list[i]; UUmAssert( object ); - + inClass->methods.rUpdate( object ); } } @@ -155,19 +155,19 @@ void ONrMechanics_DeleteClass( ONtMechanicsClass *inMechanicsClass ) ONtMechanicsClass **class_list; UUtUns32 num_classes; UUtUns32 i; - + class_list = (ONtMechanicsClass**) UUrMemory_Array_GetMemory(ONgMechanicsClasses); UUmAssert(class_list); - - num_classes = UUrMemory_Array_GetUsedElems(ONgMechanicsClasses); + + num_classes = UUrMemory_Array_GetUsedElems(ONgMechanicsClasses); for (i = 0; i < num_classes; i++) { if (class_list[i] == inMechanicsClass) { UUrMemory_Array_Delete(inMechanicsClass->object_array); inMechanicsClass->object_array = NULL; - + UUrMemory_Array_DeleteElement(ONgMechanicsClasses, i); break; } @@ -194,11 +194,11 @@ UUtError ONrMechanics_Register( OBJtObjectType inObjectType, UUtUns32 inObjectTy // create a new group entry in the mechanics class array error = UUrMemory_Array_GetNewElement(ONgMechanicsClasses, &index, NULL); UUmError_ReturnOnError(error); - + // allocate memory for the class new_class = (ONtMechanicsClass*)UUrMemory_Block_NewClear(sizeof(ONtMechanicsClass)); UUmError_ReturnOnNull(new_class); - + // initialize this class new_class->object_type = inObjectType; new_class->methods = *inMechanicsMethods; @@ -224,7 +224,7 @@ UUtError ONrMechanics_Register( OBJtObjectType inObjectType, UUtUns32 inObjectTy // register mechanics with group error = OBJrObjectType_RegisterMechanics( inObjectType, new_class ); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -236,7 +236,7 @@ UUtError ONrMechanics_Initialize( ) { ONgMechanicsClasses = UUrMemory_Array_New( sizeof(ONtMechanicsClass*), 1, 0, 0); UUmError_ReturnOnNull(ONgMechanicsClasses); - + return UUcError_None; } @@ -278,9 +278,9 @@ UUtError ONrMechanics_LevelBegin( ) for( i = 0; i < class_count; i++ ) { mechanics_class = class_list[i]; - + UUmAssert( mechanics_class ); - + if( mechanics_class->methods.rClassLevelBegin ) mechanics_class->methods.rClassLevelBegin( mechanics_class ); } @@ -304,7 +304,7 @@ UUtError ONrMechanics_LevelEnd( ) for( i = 0; i < class_count; i++ ) { mechanics_class = class_list[i]; - + UUmAssert( mechanics_class ); if( mechanics_class->methods.rClassLevelEnd ) @@ -334,9 +334,9 @@ UUtError ONrMechanics_Reset( ) for( i = 0; i < class_count; i++ ) { mechanics_class = class_list[i]; - + UUmAssert( mechanics_class ); - + if( mechanics_class->methods.rClassReset ) mechanics_class->methods.rClassReset( mechanics_class ); } @@ -380,7 +380,7 @@ OBJtObject* ONrMechanics_GetObjectWithID( OBJtObjectType inObjectType, UUtUns16 UUtUns16 id; UUtUns32 i; UUtError error; - + mechanics_class = OBJrObjectType_GetMechanicsByType( inObjectType ); UUmAssert( mechanics_class ); if( !mechanics_class ) diff --git a/OniProj/OniGameSource/Oni_Mechanics.h b/OniProj/OniGameSource/Oni_Mechanics.h index 83a99f3..93fe7c4 100644 --- a/OniProj/OniGameSource/Oni_Mechanics.h +++ b/OniProj/OniGameSource/Oni_Mechanics.h @@ -49,7 +49,7 @@ UUtError ONrMechanics_Default_ClassMethod_Reset( struct ONtMechanicsClass *inCla // mechanics management UUtError ONrMechanics_Register( OBJtObjectType inObjectType, UUtUns32 inObjectTypeIndex, char *inGroupName, - UUtUns32 inSizeInMemory, OBJtMethods *inMethods, UUtUns32 inFlags, + UUtUns32 inSizeInMemory, OBJtMethods *inMethods, UUtUns32 inFlags, ONtMechanicsMethods* inMechanicsMethods ); OBJtObject* ONrMechanics_GetObjectWithID( OBJtObjectType inObjectType, UUtUns16 inID ); diff --git a/OniProj/OniGameSource/Oni_Motoko.c b/OniProj/OniGameSource/Oni_Motoko.c index 879cdc0..d436eb5 100644 --- a/OniProj/OniGameSource/Oni_Motoko.c +++ b/OniProj/OniGameSource/Oni_Motoko.c @@ -1,12 +1,12 @@ /* FILE: Oni_Motoko.c - + AUTHOR: Brent H. Pease - + CREATED: Sept 28, 1998 - + PURPOSE: Motoko stuff for Oni - + Copyright 1998 */ @@ -55,19 +55,19 @@ ONiMotoko_DrawEngine_List( UUtUns16 numEngines; UUtUns16 itr; M3tDrawEngineCaps* curCaps; - + numEngines = M3rDrawEngine_GetNumber(); - + for(itr = 0; itr < numEngines; itr++) { curCaps = M3rDrawEngine_GetCaps(itr); - + COrConsole_Printf("%s%d: name: %s", ONgMotoko_ActiveDrawEngineIndex == itr ? "*" : "" ,itr, curCaps->engineName); COrConsole_Printf("%s%d: driver: %s", ONgMotoko_ActiveDrawEngineIndex == itr ? "*" : "", itr, curCaps->engineDriver); COrConsole_Printf("%s%d: version: %d", ONgMotoko_ActiveDrawEngineIndex == itr ? "*" : "", itr, curCaps->engineVersion); COrConsole_Printf("%s%d: numDevices: %d", ONgMotoko_ActiveDrawEngineIndex == itr ? "*" : "", itr, curCaps->numDisplayDevices); } - + return UUcError_None; } @@ -83,13 +83,13 @@ ONiMotoko_Engine_Set( UUtUns16 newGeomEngineIndex; UUtUns16 newDrawEngineIndex; M3tGeomEngineCaps* curCaps; - + newGeomEngineIndex = (UUtUns16)inParameterList[0].val.i; newDrawEngineIndex = (UUtUns16)inParameterList[1].val.i; - + if(newGeomEngineIndex < M3rGeomEngine_GetNumber() && newDrawEngineIndex < M3rDrawEngine_GetNumber()) { - + // make sure that the draw and geom engine are compatable curCaps = M3rGeomEngine_GetCaps(newGeomEngineIndex); if(((1 << newDrawEngineIndex) & curCaps->compatibleDrawEngineBV) == 0) @@ -97,12 +97,12 @@ ONiMotoko_Engine_Set( COrConsole_Printf("draw engine and geom engine are not compatable"); return UUcError_None; } - + ONgMotoko_ActiveGeomEngineIndex = newGeomEngineIndex; ONgMotoko_ActiveDrawEngineIndex = newDrawEngineIndex; - + UUrMemory_Leak_ForceGlobal_Begin(); - + M3rGeomContext_SetEnvironment( NULL); ONrMotoko_TearDownDrawing(); @@ -128,13 +128,13 @@ ONiMotoko_GeomEngine_List( UUtUns16 numEngines; UUtUns16 itr; M3tGeomEngineCaps* curCaps; - + numEngines = M3rGeomEngine_GetNumber(); - + for(itr = 0; itr < numEngines; itr++) { curCaps = M3rGeomEngine_GetCaps(itr); - + COrConsole_Printf("%s%d: name: %s", ONgMotoko_ActiveGeomEngineIndex == itr ? "*" : "" ,itr, curCaps->engineName); COrConsole_Printf("%s%d: driver: %s", ONgMotoko_ActiveGeomEngineIndex == itr ? "*" : "", itr, curCaps->engineDriver); COrConsole_Printf("%s%d: version: %d", ONgMotoko_ActiveGeomEngineIndex == itr ? "*" : "", itr, curCaps->engineVersion); @@ -162,7 +162,7 @@ ONiMotoko_Display_List( for(itrDevice = 0; itrDevice < curCaps->numDisplayDevices; itrDevice++) { COrConsole_Printf("Device %d: numModes = %d", itrDevice, curCaps->displayDevices[itrDevice].numDisplayModes); - + for(itrMode = 0; itrMode < curCaps->displayDevices[itrDevice].numDisplayModes; itrMode++) { COrConsole_Printf( @@ -190,10 +190,10 @@ ONiMotoko_Display_Set( UUtUns16 newDeviceIndex; UUtUns16 newModeIndex; M3tDrawEngineCaps* curCaps; - + newDeviceIndex = (UUtUns16)inParameterList[0].val.i; newModeIndex = (UUtUns16)inParameterList[1].val.i; - + curCaps = M3rDrawEngine_GetCaps(ONgMotoko_ActiveDrawEngineIndex); if(newDeviceIndex < curCaps->numDisplayDevices && @@ -223,7 +223,7 @@ ONiMotoko_Quality_Set( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { typedef struct { @@ -266,20 +266,20 @@ static UUtBool ONrMotoko_SetResolution_Internal(M3tDisplayMode *inResolution) M3tDisplayMode* curDisplayMode; UUtUns16 itrDrawEngine; UUtBool resolution_set = UUcFalse; - + geomEngineCaps = M3rGeomEngine_GetCaps(ONgMotoko_ActiveGeomEngineIndex); - + for(itrDrawEngine = 0; itrDrawEngine < M3cMaxNumEngines; itrDrawEngine++) { if((1 << itrDrawEngine) & geomEngineCaps->compatibleDrawEngineBV) break; } - + UUmAssert(itrDrawEngine < M3cMaxNumEngines); - + ONgMotoko_ActiveDrawEngineIndex = itrDrawEngine; - + drawEngineCaps = M3rDrawEngine_GetCaps(ONgMotoko_ActiveDrawEngineIndex); - + for(modeItr = 0; modeItr < drawEngineCaps->displayDevices[0].numDisplayModes; modeItr++) { curDisplayMode = &drawEngineCaps->displayDevices[0].displayModes[modeItr]; @@ -289,14 +289,14 @@ static UUtBool ONrMotoko_SetResolution_Internal(M3tDisplayMode *inResolution) break; } } - + if (modeItr < drawEngineCaps->displayDevices[0].numDisplayModes) { ONgMotoko_ActiveModeIndex = modeItr; } M3rDrawEngine_MakeActive(ONgMotoko_ActiveDrawEngineIndex, ONgMotoko_ActiveDeviceIndex, UUcFalse, ONgMotoko_ActiveModeIndex); - + return resolution_set; } @@ -330,7 +330,7 @@ ONrMotoko_Initialize( error = SLrGlobalVariable_Register_Bool("m3_double_buffer", "Toggles double buffer mode", &ONgMotoko_DoubleBuffer); error = SLrGlobalVariable_Register_Bool("m3_buffer_clear", "Toggles buffer clear", &ONgMotoko_BufferClear); - error = + error = SLrScript_Command_Register_Void( "m3_draw_engine_list", "lists all the engines", @@ -338,7 +338,7 @@ ONrMotoko_Initialize( ONiMotoko_DrawEngine_List); UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "m3_geom_engine_list", "lists all the engines", @@ -346,31 +346,31 @@ ONrMotoko_Initialize( ONiMotoko_GeomEngine_List); UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "m3_engine_set", "sets the active engine", "geom_engine:int draw_engine:int", ONiMotoko_Engine_Set); UUmError_ReturnOnError(error); - - error = + + error = SLrScript_Command_Register_Void( "m3_display_list", "lists all the display modes", "", ONiMotoko_Display_List); UUmError_ReturnOnError(error); - - error = + + error = SLrScript_Command_Register_Void( "m3_display_set", "sets the active display mode", "device_index:int mode_index:int", ONiMotoko_Display_Set); UUmError_ReturnOnError(error); - - error = + + error = SLrScript_Command_Register_Void( "m3_quality_set", "sets the current graphics quality", @@ -390,12 +390,12 @@ ONrMotoko_Initialize( resolution.bitDepth = 16; resolution.width = 640; resolution.height = 480; - + ONrMotoko_SetResolution_Internal(&resolution); } } - + return UUcError_None; } @@ -417,26 +417,26 @@ ONrMotoko_SetupDrawing( UUtUns16 targetHeight; UUtUns16 targetWidth; M3tDisplayMode* targetDisplayMode; - + UUrStartupMessage("setting up 3d engine..."); - + drawEngineCaps = M3rDrawEngine_GetCaps(ONgMotoko_ActiveDrawEngineIndex); targetDisplayMode = &drawEngineCaps->displayDevices[ONgMotoko_ActiveDeviceIndex].displayModes[ONgMotoko_ActiveModeIndex]; targetWidth = targetDisplayMode->width; targetHeight = targetDisplayMode->height; - + M3rDrawEngine_MakeActive(ONgMotoko_ActiveDrawEngineIndex, ONgMotoko_ActiveDeviceIndex, UUcFalse, ONgMotoko_ActiveModeIndex); M3rGeomEngine_MakeActive(ONgMotoko_ActiveGeomEngineIndex); - + contextDescriptor.type = M3cDrawContextType_OnScreen; - + contextDescriptor.drawContext.onScreen.appInstance = inPlatformData->appInstance; contextDescriptor.drawContext.onScreen.window = inPlatformData->gameWindow; contextDescriptor.drawContext.onScreen.rect.top = 20; contextDescriptor.drawContext.onScreen.rect.left = 0; contextDescriptor.drawContext.onScreen.rect.bottom = 20 + targetHeight; contextDescriptor.drawContext.onScreen.rect.right = targetWidth; - + error = M3rGeomContext_New(&contextDescriptor); UUmError_ReturnOnError(error); @@ -458,9 +458,9 @@ ONrMotoko_SetupDrawing( M3rDraw_State_Commit(); ONrGameState_PrepareGeometryEngine(); - + COrConfigure(); - + return UUcError_None; } @@ -476,13 +476,13 @@ UUtInt32 ONrMotoko_GraphicsQuality_CharacterPolygonCount(void) { ONtGraphicsQuality quality = ONrPersist_GetGraphicsQuality(); UUtInt32 polygon_count; - UUtInt32 polygon_count_table[5] = + UUtInt32 polygon_count_table[5] = { 1500, 2200, 3000, 3400, - 4000 + 4000 }; quality = UUmPin(quality, 0, 4); @@ -496,13 +496,13 @@ UUtInt32 ONrMotoko_GraphicsQuality_RayCastCount(void) { ONtGraphicsQuality quality = ONrPersist_GetGraphicsQuality(); UUtInt32 raycast_count; - UUtInt32 raycast_count_table[5] = + UUtInt32 raycast_count_table[5] = { 1, 1, 1, 1, - 2 + 2 }; quality = UUmPin(quality, 0, 4); @@ -516,13 +516,13 @@ UUtInt32 ONrMotoko_GraphicsQuality_NumDirectionalLights(void) { ONtGraphicsQuality quality = ONrPersist_GetGraphicsQuality(); UUtInt32 directional_light_count; - UUtInt32 directional_light_count_table[5] = + UUtInt32 directional_light_count_table[5] = { 1, 1, 2, 2, - 2 + 2 }; quality = UUmPin(quality, 0, 4); @@ -537,13 +537,13 @@ UUtInt32 ONrMotoko_GraphicsQuality_RayCount(void) { ONtGraphicsQuality quality = ONrPersist_GetGraphicsQuality(); UUtInt32 ray_count; - UUtInt32 ray_count_table[5] = + UUtInt32 ray_count_table[5] = { 16, 18, 20, 20, - 20 + 20 }; quality = UUmPin(quality, 0, 4); diff --git a/OniProj/OniGameSource/Oni_Motoko.h b/OniProj/OniGameSource/Oni_Motoko.h index 3c62cf6..dc00cac 100644 --- a/OniProj/OniGameSource/Oni_Motoko.h +++ b/OniProj/OniGameSource/Oni_Motoko.h @@ -2,13 +2,13 @@ /* FILE: Oni_Motoko.h - + AUTHOR: Brent H. Pease - + CREATED: Sept 28, 1998 - + PURPOSE: Motoko stuff for Oni - + Copyright 1999 */ @@ -30,7 +30,7 @@ typedef enum ONtGraphicsQuality ONcGraphicsQuality_Medium = ONcGraphicsQuality_2, ONcGraphicsQuality_High = ONcGraphicsQuality_3, ONcGraphicsQuality_SuperHigh = ONcGraphicsQuality_4, - + ONcGraphicsQuality_Min = ONcGraphicsQuality_0, ONcGraphicsQuality_Max = ONcGraphicsQuality_4, ONcGraphicsQuality_Default = ONcGraphicsQuality_Max @@ -45,7 +45,7 @@ ONrMotoko_Initialize( void ONrMotoko_Terminate( void); - + UUtError ONrMotoko_SetupDrawing( ONtPlatformData* inPlatformData); @@ -68,7 +68,7 @@ UUtBool ONrMotoko_GraphicsQuality_SupportHighQualityCorpses(void); UUtBool ONrMotoko_GraphicsQuality_NeverUseSuperLow(void); UUtBool ONrMotoko_GraphicsQuality_HardwareBink(void); UUtInt32 ONrMotoko_GraphicsQuality_RayCount(void); - + extern float ONgMotoko_FieldOfView; #define ONcMotoko_NearPlane 2.0f //#define ONcMotoko_FarPlane 1000.0f diff --git a/OniProj/OniGameSource/Oni_Networking/Oni_Net_Private.h b/OniProj/OniGameSource/Oni_Networking/Oni_Net_Private.h index 8cc5bb6..b647d3d 100644 --- a/OniProj/OniGameSource/Oni_Networking/Oni_Net_Private.h +++ b/OniProj/OniGameSource/Oni_Networking/Oni_Net_Private.h @@ -39,9 +39,9 @@ typedef enum ONtDebugLevel ONcDebugLevel_Major, ONcDebugLevel_Medium, ONcDebugLevel_Minor, - + ONcNumDebugLevels - + } ONtDebugLevel; typedef enum ONtNet_JoinStage @@ -49,7 +49,7 @@ typedef enum ONtNet_JoinStage ONcNet_JoinStage_None, ONcNet_JoinStage_GameInfo, ONcNet_JoinStage_CreateCharacter - + } ONtNet_JoinStage; // ---------------------------------------------------------------------- @@ -70,9 +70,9 @@ enum ONcNet_Update_aimingTarget, ONcNet_Update_aimingVector, ONcNet_Update_animName, - + ONcNet_NumUpdates - + }; // ====================================================================== @@ -88,7 +88,7 @@ typedef struct ONtNet_PacketHeader UUtUns16 packet_version; UUtUns16 player_index; UUtUns16 packet_length; - + } ONtNet_PacketHeader; #define ONcNet_PacketDataSize (NMcPacketDataSize - sizeof(ONtNet_PacketHeader)) @@ -105,7 +105,7 @@ typedef struct ONtNet_DataTypeInfo { UUtUns16 num_datatypes; UUtUns16 datatypes_offset; - + } ONtNet_DataTypeInfo; typedef struct ONtNet_PacketData @@ -114,7 +114,7 @@ typedef struct ONtNet_PacketData UUtUns8 *data_ptr; ONtNet_DataTypeInfo *datatype_info; ONtNet_DataType datatypes[ONcNet_MaxDataTypesPerPacket]; - + } ONtNet_PacketData; // ====================================================================== @@ -124,30 +124,30 @@ typedef struct ONtNet_UC_Data UUtBool isAiming; // 1 UUtBool validTarget; // 1 UUtBool fire; // 1 - + UUtUns16 fightFramesRemaining; // 2 UUtUns16 throwing; // 2 UUtUns16 throwFrame; // 2 UUtUns16 inAirFlags; // 2 UUtUns16 numFramesInAir; // 2 - + float facing; // 4 float desiredFacing; // 4 float aimingLR; // 4 float aimingUD; // 4 - + LItButtonBits buttonIsDown; // 8 - + M3tPoint3D aimingTarget; // 12 M3tVector3D aimingVector; // 12 M3tVector3D inAirVelocity; // 12 - + char anim_name[ONcMaxInstNameLength]; // 32 char throw_name[ONcMaxInstNameLength]; // 32 - + // make sure there is room for the datatypes char datatypes[ONcNet_NumUpdates]; - + } ONtNet_UC_Data; // ====================================================================== @@ -158,7 +158,7 @@ typedef enum ONtNet_RequestType ONcNet_Request_Info_Server, ONcNet_Request_Join, ONcNet_Request_Quit - + } ONtNet_RequestType; typedef struct ONtNet_Request @@ -184,7 +184,7 @@ typedef struct ONtNet_Players UUtBool updateACKNeeded[ONcMaxCharacters]; UUtBool weaponACKNeeded[WPcMaxWeapons]; - + } ONtNet_Players; // ---------------------------------------------------------------------- @@ -193,46 +193,46 @@ typedef struct ONtNet_Common ONtCharacter *character_list; UUtUns32 game_time; UUtUns16 level_number; - + } ONtNet_Common; typedef struct ONtNet_Client { NMtNetContext *client_context; - + ONtCharacter *character; UUtUns16 player_index; - + NMtNetAddress server_address; ONtNet_JoinStage join_stage; - + UUtUns16 request_id; ONtNet_Request requests[ONcNet_MaxClientRequests]; - + UUtUns32 packet_number; - + ONtNet_PacketData packet_data; - + UUtUns32 cupdate_bits; - + UUtUns32 previous_packet_time; UUtUns32 previous_packet_number; ONtNet_UC_Data prev_update; - + UUtUns32 heartbeat_time; - + UUtUns16 teamNumber; char characterClassName[AIcMaxClassNameLen]; char playerName[ONcMaxPlayerNameLength]; - + UUtUns32 client_send_time; UUtInt32 client_send_delta; UUtBool client_adjust_this_frame; - + UUtUns32 packets_sent; UUtUns32 bytes_sent; UUtUns32 performance_time; - + } ONtNet_Client; typedef struct ONtNet_Server @@ -242,32 +242,32 @@ typedef struct ONtNet_Server ONtNet_Players *players; ONtNetGameOptions game_options; UUtUns16 num_players; - + UUtUns32 packet_number; - + ONtNet_PacketData mass_packet_data; - + ONtNet_UC_Data prev_update[ONcMaxCharacters]; UUtUns32 updateFlags[ONcMaxCharacters]; UUtUns16 weaponFlags[WPcMaxWeapons]; - + char server_name[ONcMaxHostNameLength]; - + UUtUns32 server_send_time; UUtInt32 server_send_delta; UUtBool server_adjust_this_frame; - + UUtUns32 raw_packets_sent; UUtUns32 raw_bytes_sent; - + UUtUns32 player_packets_sent; UUtUns32 player_bytes_sent; - + UUtUns32 mass_packets_sent; UUtUns32 mass_bytes_sent; - + UUtUns32 performance_time; - + } ONtNet_Server; typedef struct ONtNet_FindServer @@ -277,7 +277,7 @@ typedef struct ONtNet_FindServer UUtUns32 broadcast_time; ONtNet_FindServers_Callback callback; UUtUns32 user_param; - + } ONtNet_FindServer; // ---------------------------------------------------------------------- @@ -288,10 +288,10 @@ typedef struct ONtNet_ProcessGroup ONtNet_Packet packet; // original packet received UUtUns16 packet_length; // length of packet received UUtUns8 *data; // current point of processing in packet_data - + ONtNet_DataType *datatypes; // pointer to the datatypes ONtNet_DataTypeInfo *datatype_info; // pointer to the datatype info - + UUtBool swap_it; // this packet needs to be byte-swapped } ONtNet_ProcessGroup; @@ -309,29 +309,29 @@ UUtError ONrNet_LevelLoad( ONtNet_Common *ioCommon, UUtUns16 inLevelNumber); - + // ---------------------------------------------------------------------- void ONrNet_Client_JoinStage_Advance( ONtNet_Client *ioClient, ONtNet_Common *ioCommon); - + void ONrNet_Client_Rejected( ONtNet_Client *ioClient); - + // ---------------------------------------------------------------------- void ONrNet_Client_Request_Add( ONtNet_Client *ioClient, ONtNet_RequestType inRequestType, UUtUns32 inGameTime); - + void ONrNet_Client_Request_ResponseReceived( ONtNet_Client *ioClient, UUtUns32 inRequestID); - + // ====================================================================== -#endif /* ONI_NET_PRIVATE_H */ \ No newline at end of file +#endif /* ONI_NET_PRIVATE_H */ diff --git a/OniProj/OniGameSource/Oni_Networking/Oni_Net_Support.c b/OniProj/OniGameSource/Oni_Networking/Oni_Net_Support.c index 39cdacb..f055dfb 100644 --- a/OniProj/OniGameSource/Oni_Networking/Oni_Net_Support.c +++ b/OniProj/OniGameSource/Oni_Networking/Oni_Net_Support.c @@ -40,7 +40,7 @@ #define ONmNet_GetDataType(src_data, data_type) \ data_type = *((ONtNet_DataType*)src_data); \ src_data += ONcNet_DataType_Length; - + // ---------------------------------------------------------------------- #define ONmNet_GetDataPtr(group, type) \ (type*)group->data; \ @@ -57,7 +57,7 @@ ONmNet_AddDataType(data_type,dst_data); \ (*((src_type*)dst_data)) = src_data; \ ((UUtUns8*)dst_data) += sizeof(src_type); - + #define ONmNet_AddStruct(data_type,src_data,src_type,dst_data) \ ONmNet_AddDataType(data_type,dst_data); \ UUrMemory_MoveFast(src_data,dst_data,sizeof(src_type)); \ @@ -89,7 +89,7 @@ #define ONmNet_Update(type,var_name) \ character->var_name = *(type*)update_data; \ update_data += sizeof(type); - + #define ONmNet_SwapUpdate(swap_func,type,var_name) \ character->var_name = *(type*)update_data; \ if (ioProcessGroup->swap_it) { swap_func(&character->var_name); } \ @@ -139,14 +139,14 @@ static M3tPoint3D ONgNet_WeaponPosition[WPcMaxWeapons]; enum { ONcNone, // this starts the count - + // Client to Server ACKs ONcC2S_ACK_Critical_Update, ONcC2S_ACK_Weapon_Update, - + // Client to Server Heartbeat ONcC2S_Heartbeat, - + // Client to Server Requests ONcC2S_Request_CharacterCreate, ONcC2S_Request_CharacterInfo, @@ -154,28 +154,28 @@ enum ONcC2S_Request_Spawn, ONcC2S_Request_Quit, ONcC2S_Request_WeaponInfo, - + // Client to Server Updates ONcC2S_Update_Character, ONcC2S_Update_Critical, - + // Server to Client ACKs ONcS2C_ACK_Critical_Update, ONcS2C_ACK_Quit, - + // Server to Client Info ONcS2C_Info_Character, ONcS2C_Info_CharacterCreate, ONcS2C_Info_Game, - + // Server to Client Reject ONcS2C_Reject_Join, - + // Server to Client Updates ONcS2C_Update_Character, ONcS2C_Update_Critical, ONcS2C_Update_Weapon, - + // FindServer ONcC2S_Request_ServerInfo, ONcS2C_ServerInfo @@ -193,7 +193,7 @@ enum ONcNet_CU_Class, ONcNet_CU_Spawn, ONcNet_CU_Gone, - + ONcNet_NumCUpdates }; @@ -205,7 +205,7 @@ enum ONcNet_WU_Delete, ONcNet_WU_Ammo, ONcNet_WU_Position, - + ONcNet_NumWUpdates }; @@ -213,19 +213,19 @@ enum // typedefs // ====================================================================== // ---------------------------------------------------------------------- -// NOTE: All of these structs must have a sizeof() that is divisible by 4 +// NOTE: All of these structs must have a sizeof() that is divisible by 4 // ---------------------------------------------------------------------- typedef struct ONtNet_TwoUns16 { UUtUns16 uns16_0; UUtUns16 uns16_1; - + } ONtNet_TwoUns16; typedef struct ONtNet_OneUns32 { UUtUns32 uns32_0; - + } ONtNet_OneUns32; // ------------------------------ @@ -239,16 +239,16 @@ typedef struct ONtNet_Info_Character UUtUns16 character_index; // 2 UUtUns16 team_number; // 2 UUtUns16 anim_frame; // 2 - + UUtUns16 pad; // 2 *** - + float facing; // 4 M3tPoint3D position; // 12 - + char character_class_name[AIcMaxClassNameLen]; // 64 char player_name[ONcMaxPlayerNameLength]; // 32 char animName[ONcMaxInstNameLength]; // 32 - + } ONtNet_Info_Character; typedef struct ONtNet_Info_CharacterCreate @@ -258,7 +258,7 @@ typedef struct ONtNet_Info_CharacterCreate UUtUns16 pad; // 2 *** float facing; // 4 M3tPoint3D position; // 12 - + } ONtNet_Info_CharacterCreate; typedef struct ONtNet_Info_Game @@ -266,14 +266,14 @@ typedef struct ONtNet_Info_Game UUtUns32 request_id; // 2 UUtUns16 player_index; // 2 UUtUns16 level_number; // 2 - + } ONtNet_Info_Game; typedef struct ONtNet_Info_Spawn { float facing; // 4 M3tPoint3D position; // 12 - + } ONtNet_Info_Spawn; // ------------------------------ @@ -287,7 +287,7 @@ typedef struct ONtNet_Request_CharacterCreate UUtUns16 pad; // 2 *** char characterClassName[AIcMaxClassNameLen]; // 64 char playerName[ONcMaxPlayerNameLength]; // 32 - + } ONtNet_Request_CharacterCreate; typedef ONtNet_TwoUns16 ONtNet_Request_CharacterInfo; // uns16_0 = character_index @@ -304,18 +304,18 @@ typedef struct ONtNet_Update_Header M3tPoint3D position; // 12 the current position of the character char animName[ONcMaxInstNameLength]; // 32 - + } ONtNet_Update_Header; typedef struct ONtNet_Update_Character { ONtNet_Update_Header hdr; UUtUns8 data[sizeof(ONtNet_UC_Data)]; // the updated data - + } ONtNet_Update_Character; // this is the minimum size of an ONtNet_Update_Character -const UUtUns32 ONcNet_Update_Character_MinSize = sizeof(ONtNet_Update_Header); +const UUtUns32 ONcNet_Update_Character_MinSize = sizeof(ONtNet_Update_Header); // ------------------------------ typedef struct ONtNet_CU_Data @@ -324,33 +324,33 @@ typedef struct ONtNet_CU_Data UUtUns32 numKills; // 4 UUtUns32 damageInflicted; // 4 UUtUns32 weaponIndex; // 4 - + ONtNet_Info_Spawn spawnInfo; // 16 - + char playerName[ONcMaxPlayerNameLength]; // 32 char characterClassName[AIcMaxClassNameLen]; // 64 - + // make sure there is room for the datatypes ONtNet_DataType datatypes[ONcNet_NumCUpdates]; - + } ONtNet_CU_Data; typedef struct ONtNet_CUpdate_Header { UUtUns16 character_index; // 2 the index of the character being updated - UUtUns16 pad; // 2 - + UUtUns16 pad; // 2 + } ONtNet_CUpdate_Header; typedef struct ONtNet_Critical_Update { ONtNet_CUpdate_Header hdr; UUtUns8 data[sizeof(ONtNet_CU_Data)]; // the update data - + } ONtNet_Critical_Update; // this is the minimum size of an ONtNet_Critical_Update -const UUtUns32 ONcNet_CUpdate_MinSize = sizeof(ONtNet_CUpdate_Header); +const UUtUns32 ONcNet_CUpdate_MinSize = sizeof(ONtNet_CUpdate_Header); // ---------------------------------------------------------------------- typedef struct ONtNet_WU_Data @@ -358,28 +358,28 @@ typedef struct ONtNet_WU_Data char weapon_class_name[ONcMaxInstNameLength]; // 32 M3tPoint3D position; // 12 WPtAmmoGroup ammo_group; // 16 - + // make sure there is room for the datatypes ONtNet_DataType datatypes[ONcNet_NumWUpdates]; - + } ONtNet_WU_Data; typedef struct ONtNet_WUpdate_Header { UUtUns16 weapon_index; // 2 the index of the weapon being updated - UUtUns16 pad; // 2 - + UUtUns16 pad; // 2 + } ONtNet_WUpdate_Header; typedef struct ONtNet_Weapon_Update { ONtNet_WUpdate_Header hdr; UUtUns8 data[sizeof(ONtNet_WU_Data)]; // the update data - + } ONtNet_Weapon_Update; // this is the minimum size of an ONtNet_Weapon_Update -const UUtUns32 ONcNet_WUpdate_MinSize = sizeof(ONtNet_WUpdate_Header); +const UUtUns32 ONcNet_WUpdate_MinSize = sizeof(ONtNet_WUpdate_Header); typedef struct ONtNet_Inventory { @@ -387,7 +387,7 @@ typedef struct ONtNet_Inventory UUtUns16 ammo; UUtUns16 hypo; UUtUns16 cell; - + } ONtNet_Inventory; typedef ONtNet_TwoUns16 ONtNet_Request_WeaponInfo; // uns16_0 = weapon_index @@ -398,7 +398,7 @@ typedef struct ONtNet_inAir UUtUns16 numFramesInAir; UUtUns16 flags; M3tVector3D velocity; - + } ONtNet_inAir; typedef struct ONtNet_throw @@ -406,7 +406,7 @@ typedef struct ONtNet_throw UUtUns16 throwing; UUtUns16 throwFrame; char throwName[ONcMaxInstNameLength]; - + } ONtNet_throw; // ---------------------------------------------------------------------- @@ -415,10 +415,10 @@ typedef struct ONtNet_BufferData UUtUns8 *data; // start of the buffer UUtUns8 *data_ptr; // current point to add data in the buffer ONtNet_DataTypeInfo *datatype_info; // datatype info - ONtNet_DataType datatypes[ONcNet_MaxDataTypesPerPacket]; + ONtNet_DataType datatypes[ONcNet_MaxDataTypesPerPacket]; // storage for the datatypes until they are // copied into the buffer - + } ONtNet_BufferData; // ====================================================================== @@ -430,15 +430,15 @@ ONiNet_Swap_PacketHeader( ONtNet_Packet *inPacket) { if (inPacket->packet_header.packet_swap != ONcNet_SwapIt) - { + { UUrSwap_4Byte(&inPacket->packet_header.packet_number); UUrSwap_2Byte(&inPacket->packet_header.packet_version); UUrSwap_2Byte(&inPacket->packet_header.player_index); UUrSwap_2Byte(&inPacket->packet_header.packet_length); - + return UUcTrue; } - + return UUcFalse; } @@ -471,7 +471,7 @@ ONiNet_DataType_GetDataSize( ONtNet_DataType inDataType) { UUtUns16 size; - + switch (inDataType) { case ONcNone: size = 0; break; @@ -490,7 +490,7 @@ ONiNet_DataType_GetDataSize( case ONcNet_Update_aimingVector: size = sizeof(M3tVector3D); break; default: UUmAssert(!"unknown datatype"); break; } - + return size; } @@ -508,18 +508,18 @@ ONiNet_Buffer_AddData( UUtUns16 inDataLength) { UUtUns16 index; - + UUmAssert(ioBufferData->datatype_info->num_datatypes < ONcNet_MaxDataTypesPerPacket); - + // add the data if (inData) { UUrMemory_MoveFast(inData, ioBufferData->data_ptr, inDataLength); - + // advance the data pointer ioBufferData->data_ptr += inDataLength; } - + // add the datatypes index = ioBufferData->datatype_info->num_datatypes++; ioBufferData->datatypes[index] = inDataType; @@ -542,7 +542,7 @@ ONiNet_Buffer_Align4Byte( ONtNet_BufferData *ioBufferData) { *((UUtUns32*)ioBufferData->data_ptr) = 'PPPP'; - + // set the data_ptr at the next 4byte boundary ioBufferData->data_ptr = (UUtUns8*)((UUtUns32)(ioBufferData->data_ptr + 3) & ~3); } @@ -554,15 +554,15 @@ ONiNet_Buffer_Build( { UUtUns16 buffer_size; UUtUns16 datatypes_size; - + // get the number of bytes used by the datatypes datatypes_size = ONiNet_DataTypes_GetSize(ioBufferData->datatype_info); - + // calculate the final buffer size buffer_size = (UUtUns16)(ioBufferData->data_ptr - ioBufferData->data) + datatypes_size; - + // copy the datatypes to the end of the data if (datatypes_size > 0) { @@ -571,11 +571,11 @@ ONiNet_Buffer_Build( ioBufferData->data_ptr, datatypes_size); } - + // set the datatypes offset ioBufferData->datatype_info->datatypes_offset = ioBufferData->data_ptr - ioBufferData->data; - + return buffer_size; } @@ -587,13 +587,13 @@ ONiNet_Buffer_Init( { // set the pointer to the data ioBufferData->data = inData; - + // the datatype_info is the first piece of data in the buffer ioBufferData->datatype_info = (ONtNet_DataTypeInfo*)ioBufferData->data; // set the data ptr ioBufferData->data_ptr = ioBufferData->data + sizeof(ONtNet_DataTypeInfo); - + // initialize the datatype_info ioBufferData->datatype_info->num_datatypes = 0; ioBufferData->datatype_info->datatypes_offset = 0; @@ -613,15 +613,15 @@ ONiNet_Generate_Update( { ONtNet_BufferData buffer_data; UUtBool is_server; - + is_server = ONrNet_IsServer(); - + // --------------------------------- // create the minimum sized update // --------------------------------- // initialize the buffer data ONiNet_Buffer_Init(&buffer_data, outUpdate->data); - + // initialize the update header outUpdate->hdr.character_index = inCharacter->index; outUpdate->hdr.animFrame = inCharacter->animFrame; @@ -655,64 +655,64 @@ ONiNet_Generate_Update( NULL, 0); } - + // --------------------------------- // add 1 byte updates // --------------------------------- ONiNet_Buffer_Align4Byte(&buffer_data); - + // check the character's isAiming ONmNet_SimpleAdd2(&buffer_data, inCharacter->isAiming, ioPrevUpdate->isAiming, UUtBool, ONcNet_Update_isAiming); - + // check the character's validTarget ONmNet_SimpleAdd2(&buffer_data, inCharacter->validTarget, ioPrevUpdate->validTarget, UUtBool, ONcNet_Update_validTarget); - + // --------------------------------- // add 2 byte updates // --------------------------------- ONiNet_Buffer_Align2Byte(&buffer_data); - + // check the character's fightFramesRemaining ONmNet_SimpleAdd2(&buffer_data, inCharacter->fightFramesRemaining, ioPrevUpdate->fightFramesRemaining, UUtUns16, ONcNet_Update_fightFramesRemaining); - + // --------------------------------- // add 4 byte or more updates // --------------------------------- ONiNet_Buffer_Align4Byte(&buffer_data); - + // check the character's facing ONmNet_ComplexAdd2(&buffer_data, UUmFloat_CompareEqu, inCharacter->facing, ioPrevUpdate->facing, float, ONcNet_Update_facing); - + // check the character's desired facing ONmNet_ComplexAdd2(&buffer_data, UUmFloat_CompareEqu, inCharacter->desiredFacing, ioPrevUpdate->desiredFacing, float, ONcNet_Update_desiredFacing); - + // check the character's aimingLR ONmNet_ComplexAdd2(&buffer_data, UUmFloat_CompareEqu, inCharacter->aimingLR, ioPrevUpdate->aimingLR, float, ONcNet_Update_aimingLR); - + // check the character's aimingUD ONmNet_ComplexAdd2(&buffer_data, UUmFloat_CompareEqu, inCharacter->aimingUD, ioPrevUpdate->aimingUD, float, ONcNet_Update_aimingUD); - + // check the character's buttonIsDown if (is_server) { LItButtonBits buttonIsDown; - + buttonIsDown = inCharacter->inputState.buttonIsDown & ~ONcNet_InventoryBits; - + ONmNet_SimpleAdd2(&buffer_data, buttonIsDown, ioPrevUpdate->buttonIsDown, LItButtonBits, ONcNet_Update_buttonIsDown); @@ -723,31 +723,31 @@ ONiNet_Generate_Update( inCharacter->inputState.buttonIsDown, ioPrevUpdate->buttonIsDown, LItButtonBits, ONcNet_Update_buttonIsDown); } - + // check the character's aimingTarget ONmNet_ComplexAdd2(&buffer_data, MUmPoint_Compare, inCharacter->aimingTarget, ioPrevUpdate->aimingTarget, M3tPoint3D, ONcNet_Update_aimingTarget); - + // check the character's aimingVector ONmNet_ComplexAdd2(&buffer_data, MUmPoint_Compare, inCharacter->aimingVector, ioPrevUpdate->aimingVector, M3tPoint3D, ONcNet_Update_aimingVector); - + // --------------------------------- // add group updates // --------------------------------- ONiNet_Buffer_Align4Byte(&buffer_data); - + // check the inAirControls if (inCharacter->inAirControl.numFramesInAir > 0) { ONtNet_inAir inAir; - + inAir.numFramesInAir = inCharacter->inAirControl.numFramesInAir; inAir.flags = inCharacter->inAirControl.flags; inAir.velocity = inCharacter->inAirControl.velocity; - + // add inAir ONiNet_Buffer_AddData( &buffer_data, @@ -757,12 +757,12 @@ ONiNet_Generate_Update( ONiNet_Buffer_Align4Byte(&buffer_data); } - + // check the throws if (inCharacter->targetThrow) { ONtNet_throw throw_data; - + UUmAssertReadPtr(inCharacter, sizeof(ONtCharacter)); UUmAssertReadPtr(inCharacter->throwTarget, sizeof(ONtCharacter)); @@ -772,7 +772,7 @@ ONiNet_Generate_Update( throw_data.throwName, TMrInstance_GetInstanceName(inCharacter->targetThrow), ONcMaxInstNameLength); - + // add throws ONiNet_Buffer_AddData( &buffer_data, @@ -782,7 +782,7 @@ ONiNet_Generate_Update( ONiNet_Buffer_Align4Byte(&buffer_data); } - + // return the size return (UUtUns16)(ONcNet_Update_Character_MinSize + ONiNet_Buffer_Build(&buffer_data)); } @@ -796,15 +796,15 @@ ONiNet_Generate_Update_Authoritative( { ONtNet_BufferData buffer_data; UUtBool is_server; - + is_server = ONrNet_IsServer(); - + // --------------------------------- // create the minimum sized update // --------------------------------- // initialize the buffer data ONiNet_Buffer_Init(&buffer_data, outUpdate->data); - + // initialize the update header outUpdate->hdr.character_index = inCharacter->index; outUpdate->hdr.animFrame = inCharacter->animFrame; @@ -838,30 +838,30 @@ ONiNet_Generate_Update_Authoritative( NULL, 0); } - + // --------------------------------- // add 1 byte updates // --------------------------------- ONiNet_Buffer_Align4Byte(&buffer_data); - + if (is_server) { // check the character's isAiming ONmNet_SimpleAdd2(&buffer_data, inCharacter->isAiming, ioPrevUpdate->isAiming, UUtBool, ONcNet_Update_isAiming); - + // check the character's validTarget ONmNet_SimpleAdd2(&buffer_data, inCharacter->validTarget, ioPrevUpdate->validTarget, UUtBool, ONcNet_Update_validTarget); } - + // --------------------------------- // add 2 byte updates // --------------------------------- ONiNet_Buffer_Align2Byte(&buffer_data); - + if (is_server) { // check the character's fightFramesRemaining @@ -869,39 +869,39 @@ ONiNet_Generate_Update_Authoritative( inCharacter->fightFramesRemaining, ioPrevUpdate->fightFramesRemaining, UUtUns16, ONcNet_Update_fightFramesRemaining); } - + // --------------------------------- // add 4 byte or more updates // --------------------------------- ONiNet_Buffer_Align4Byte(&buffer_data); - + // check the character's facing ONmNet_ComplexAdd2(&buffer_data, UUmFloat_CompareEqu, inCharacter->facing, ioPrevUpdate->facing, float, ONcNet_Update_facing); - + // check the character's desired facing ONmNet_ComplexAdd2(&buffer_data, UUmFloat_CompareEqu, inCharacter->desiredFacing, ioPrevUpdate->desiredFacing, float, ONcNet_Update_desiredFacing); - + // check the character's aimingLR ONmNet_ComplexAdd2(&buffer_data, UUmFloat_CompareEqu, inCharacter->aimingLR, ioPrevUpdate->aimingLR, float, ONcNet_Update_aimingLR); - + // check the character's aimingUD ONmNet_ComplexAdd2(&buffer_data, UUmFloat_CompareEqu, inCharacter->aimingUD, ioPrevUpdate->aimingUD, float, ONcNet_Update_aimingUD); - + // check the character's buttonIsDown if (is_server) { LItButtonBits buttonIsDown; - + buttonIsDown = inCharacter->inputState.buttonIsDown & ~ONcNet_InventoryBits; - + ONmNet_SimpleAdd2(&buffer_data, buttonIsDown, ioPrevUpdate->buttonIsDown, LItButtonBits, ONcNet_Update_buttonIsDown); @@ -912,20 +912,20 @@ ONiNet_Generate_Update_Authoritative( inCharacter->inputState.buttonIsDown, ioPrevUpdate->buttonIsDown, LItButtonBits, ONcNet_Update_buttonIsDown); } - + if (is_server) { // check the character's aimingTarget ONmNet_ComplexAdd2(&buffer_data, MUmPoint_Compare, inCharacter->aimingTarget, ioPrevUpdate->aimingTarget, M3tPoint3D, ONcNet_Update_aimingTarget); - + // check the character's aimingVector ONmNet_ComplexAdd2(&buffer_data, MUmPoint_Compare, inCharacter->aimingVector, ioPrevUpdate->aimingVector, M3tPoint3D, ONcNet_Update_aimingVector); } - + // --------------------------------- // add group updates // --------------------------------- @@ -937,46 +937,46 @@ ONiNet_Generate_Update_Authoritative( if (inCharacter->inAirControl.numFramesInAir > 0) { ONtNet_inAir inAir; - + inAir.numFramesInAir = inCharacter->inAirControl.numFramesInAir; inAir.flags = inCharacter->inAirControl.flags; inAir.velocity = inCharacter->inAirControl.velocity; - + // add inAir ONiNet_Buffer_AddData( &buffer_data, ONcNet_Update_inAir, (UUtUns8*)&inAir, sizeof(ONtNet_inAir)); - + ONiNet_Buffer_Align4Byte(&buffer_data); } - + // check the throws if (inCharacter->targetThrow) { ONtNet_throw throw_data; - + UUmAssertReadPtr(inCharacter, sizeof(ONtCharacter)); UUmAssertReadPtr(inCharacter->throwTarget, sizeof(ONtCharacter)); - + throw_data.throwing = inCharacter->throwing; throw_data.throwFrame = inCharacter->throwTarget->animFrame; UUrString_Copy( throw_data.throwName, TMrInstance_GetInstanceName(inCharacter->targetThrow), ONcMaxInstNameLength); - + // add throws ONiNet_Buffer_AddData( &buffer_data, ONcNet_Update_throw, (UUtUns8*)&throw_data, sizeof(ONtNet_throw)); - + ONiNet_Buffer_Align4Byte(&buffer_data); } - } + } // return the size return (UUtUns16)(ONcNet_Update_Character_MinSize + ONiNet_Buffer_Build(&buffer_data)); @@ -990,7 +990,7 @@ ONiNet_Skip_Update( { ONtNet_DataTypeInfo *datatype_info; UUtUns16 skip_bytes; - + // get a pointer to the datatype info datatype_info = (ONtNet_DataTypeInfo*)ioUpdate->data; if (ioProcessGroup->swap_it) @@ -998,10 +998,10 @@ ONiNet_Skip_Update( UUrSwap_2Byte(&datatype_info->num_datatypes); UUrSwap_2Byte(&datatype_info->datatypes_offset); } - + // calculate the number of bytes that are in the update skip_bytes = (datatype_info->datatypes_offset + datatype_info->num_datatypes + 3) & ~3; - + // advance the data by the number of bytes processed ONiNet_DataAdvance(ioProcessGroup, skip_bytes); } @@ -1013,7 +1013,7 @@ ONiNet_Process_Update( ONtNet_Update_Character *ioUpdate) { UUtError error; - + ONtNet_DataTypeInfo *datatype_info; UUtUns8 *data_ptr; ONtNet_DataType *datatypes; @@ -1021,14 +1021,14 @@ ONiNet_Process_Update( ONtNet_DataType prev_datatype; UUtBool swap_it; UUtUns16 bytes_processed; - + ONtCharacter *character; ONtNet_inAir *inAir; ONtNet_throw *throw_data; - + TRtAnimation *animation; const TRtAnimation *prev_character_animation; - + // get a pointer to the character character = &ioProcessGroup->common->character_list[ioUpdate->hdr.character_index]; if (!(character->flags & ONcCharacterFlag_InUse) || @@ -1037,7 +1037,7 @@ ONiNet_Process_Update( ONiNet_Skip_Update(ioProcessGroup, ioUpdate); return; } - + swap_it = ioProcessGroup->swap_it; inAir = NULL; throw_data = NULL; @@ -1050,14 +1050,14 @@ ONiNet_Process_Update( UUrSwap_2Byte(&datatype_info->num_datatypes); UUrSwap_2Byte(&datatype_info->datatypes_offset); } - + // set the other pointers data_ptr = ioUpdate->data + sizeof(ONtNet_DataTypeInfo); datatypes = ioUpdate->data + datatype_info->datatypes_offset; - + // set the character position character->physics->position = character->location = ioUpdate->hdr.position; - + // process the data prev_datatype = ONcNone; for (i = 0; i < datatype_info->num_datatypes; i++) @@ -1065,9 +1065,9 @@ ONiNet_Process_Update( ONtNet_DataType datatype; UUtUns16 prev_datatype_size; UUtUns16 datatype_size; - + datatype = datatypes[i]; - + // align the data_ptr prev_datatype_size = ONiNet_DataType_GetDataSize(prev_datatype); if (prev_datatype_size == 1) @@ -1086,47 +1086,47 @@ ONiNet_Process_Update( else if (prev_datatype_size == 2) { datatype_size = ONiNet_DataType_GetDataSize(datatype); - + if (datatype_size != 2) { data_ptr = (UUtUns8*)(((UUtUns32)data_ptr + 3) & ~3); } } - + // process the datatype switch (datatype) { case ONcNet_Update_isAiming: ONmNet_Update2(UUtBool, character->isAiming, data_ptr); break; - + case ONcNet_Update_validTarget: ONmNet_Update2(UUtBool, character->validTarget, data_ptr); break; - + case ONcNet_Update_fightFramesRemaining: ONmNet_SwapUpdate2Byte(UUtUns16, character->fightFramesRemaining, data_ptr, swap_it); break; - + case ONcNet_Update_fire: character->pleaseFire = UUcTrue; break; - + case ONcNet_Update_throw: throw_data = (ONtNet_throw*)data_ptr; data_ptr += sizeof(ONtNet_throw); - + if (swap_it) { UUrSwap_2Byte(&throw_data->throwing); UUrSwap_2Byte(&throw_data->throwFrame); } break; - + case ONcNet_Update_inAir: inAir = (ONtNet_inAir*)data_ptr; data_ptr += sizeof(ONtNet_inAir); - + if (swap_it) { UUrSwap_2Byte(&inAir->numFramesInAir); @@ -1134,53 +1134,53 @@ ONiNet_Process_Update( MUmPoint3D_Swap(inAir->velocity); } break; - + case ONcNet_Update_facing: ONmNet_SwapUpdate4Byte(float, character->facing, data_ptr, swap_it); break; - + case ONcNet_Update_desiredFacing: ONmNet_SwapUpdate4Byte(float, character->desiredFacing, data_ptr, swap_it); break; - + case ONcNet_Update_aimingLR: ONmNet_SwapUpdate4Byte(float, character->aimingLR, data_ptr, swap_it); break; - + case ONcNet_Update_aimingUD: ONmNet_SwapUpdate4Byte(float, character->aimingUD, data_ptr, swap_it); break; - + case ONcNet_Update_buttonIsDown: { LItButtonBits *button_bits; - + button_bits = (LItButtonBits*)data_ptr; data_ptr += sizeof(LItButtonBits); - + if (swap_it) { UUrSwap_8Byte(button_bits); } - + ONrInput_Update_Keys(&character->inputState, *button_bits); } break; - + case ONcNet_Update_aimingTarget: ONmNet_SwapUpdateFunc(M3tPoint3D, character->aimingTarget, data_ptr, swap_it, MUmPoint3D_Swap); break; - + case ONcNet_Update_aimingVector: ONmNet_SwapUpdateFunc(M3tVector3D, character->aimingVector, data_ptr, swap_it, MUmPoint3D_Swap); break; - + default: break; } - + prev_datatype = datatype; } - + // handle inAir if (inAir) { @@ -1188,7 +1188,7 @@ ONiNet_Process_Update( character->inAirControl.flags = inAir->flags; character->inAirControl.velocity = inAir->velocity; } - + if (!(character->flags & ONcCharacterFlag_BeingThrown) && (ioUpdate->hdr.animName[0] != '\0')) { @@ -1202,13 +1202,13 @@ ONiNet_Process_Update( { UUtUns16 num_frames; UUtBool updateAnimation = UUcTrue; - + // if the character is dead, make sure this animation is appropriate for death if (character->flags & ONcCharacterFlag_Dead) { TRtAnimState curToState = TRrAnimation_GetTo(character->animation); TRtAnimState newToState = TRrAnimation_GetTo(animation); - + // if we are currently heading towards fallen and the new animation would not // then this is a better animation to run when we are dead if ((ONrAnimState_IsFallen(curToState)) && @@ -1217,18 +1217,18 @@ ONiNet_Process_Update( updateAnimation = UUcFalse; } } - + if ((updateAnimation) && (character->animation == animation)) { UUtInt32 oldFrame = character->animFrame; UUtInt32 newFrame = ioUpdate->hdr.animFrame; - + if (UUmABS(oldFrame - newFrame) < 2) { updateAnimation = UUcFalse; } } - + if (updateAnimation) { // set the characters animation @@ -1238,7 +1238,7 @@ ONiNet_Process_Update( ONcAnimType_None, animation); } - + num_frames = TRrAnimation_GetDuration(character->animation); if (ioUpdate->hdr.animFrame >= num_frames) @@ -1251,7 +1251,7 @@ ONiNet_Process_Update( } } } - + // handle throwing if (throw_data) { @@ -1260,7 +1260,7 @@ ONiNet_Process_Update( (throw_data->throwFrame < 10)) { TRtAnimation *throw_animation; - + // get the animation error = TMrInstance_GetDataPtr( @@ -1268,10 +1268,10 @@ ONiNet_Process_Update( throw_data->throwName, &throw_animation); if (error != UUcError_None) return; - + // set the throw target character->throwTarget = &ioProcessGroup->common->character_list[throw_data->throwing]; - + if ((character->throwTarget->animation != throw_animation) && (prev_character_animation != animation) && !(character->throwTarget->flags & ONcCharacterFlag_BeingThrown)) @@ -1279,7 +1279,7 @@ ONiNet_Process_Update( // set the throw variables character->targetThrow = throw_animation; character->throwing = throw_data->throwing; - + // run the throw ONrCharacter_NewAnimationHook(character); if (character->throwTarget) @@ -1303,7 +1303,7 @@ ONiNet_Process_Update_Authoritative( ONtNet_Update_Character *ioUpdate) { UUtError error; - + ONtNet_DataTypeInfo *datatype_info; UUtUns8 *data_ptr; ONtNet_DataType *datatypes; @@ -1311,18 +1311,18 @@ ONiNet_Process_Update_Authoritative( ONtNet_DataType prev_datatype; UUtBool swap_it; UUtUns16 bytes_processed; - + ONtCharacter *character; ONtNet_inAir *inAir; ONtNet_throw *throw_data; - + TRtAnimation *animation; const TRtAnimation *prev_character_animation; - + UUtBool is_server; - + is_server = ONrNet_IsServer(); - + // get a pointer to the character character = &ioProcessGroup->common->character_list[ioUpdate->hdr.character_index]; if (!(character->flags & ONcCharacterFlag_InUse) || @@ -1331,7 +1331,7 @@ ONiNet_Process_Update_Authoritative( ONiNet_Skip_Update(ioProcessGroup, ioUpdate); return; } - + swap_it = ioProcessGroup->swap_it; inAir = NULL; throw_data = NULL; @@ -1344,14 +1344,14 @@ ONiNet_Process_Update_Authoritative( UUrSwap_2Byte(&datatype_info->num_datatypes); UUrSwap_2Byte(&datatype_info->datatypes_offset); } - + // set the other pointers data_ptr = ioUpdate->data + sizeof(ONtNet_DataTypeInfo); datatypes = ioUpdate->data + datatype_info->datatypes_offset; - + // set the character position character->physics->position = character->location = ioUpdate->hdr.position; - + // process the data prev_datatype = ONcNone; for (i = 0; i < datatype_info->num_datatypes; i++) @@ -1359,9 +1359,9 @@ ONiNet_Process_Update_Authoritative( ONtNet_DataType datatype; UUtUns16 prev_datatype_size; UUtUns16 datatype_size; - + datatype = datatypes[i]; - + // align the data_ptr prev_datatype_size = ONiNet_DataType_GetDataSize(prev_datatype); if (prev_datatype_size == 1) @@ -1380,47 +1380,47 @@ ONiNet_Process_Update_Authoritative( else if (prev_datatype_size == 2) { datatype_size = ONiNet_DataType_GetDataSize(datatype); - + if (datatype_size != 2) { data_ptr = (UUtUns8*)(((UUtUns32)data_ptr + 3) & ~3); } } - + // process the datatype switch (datatype) { case ONcNet_Update_isAiming: ONmNet_Update2(UUtBool, character->isAiming, data_ptr); break; - + case ONcNet_Update_validTarget: ONmNet_Update2(UUtBool, character->validTarget, data_ptr); break; - + case ONcNet_Update_fightFramesRemaining: ONmNet_SwapUpdate2Byte(UUtUns16, character->fightFramesRemaining, data_ptr, swap_it); break; - + case ONcNet_Update_fire: character->pleaseFire = UUcTrue; break; - + case ONcNet_Update_throw: throw_data = (ONtNet_throw*)data_ptr; data_ptr += sizeof(ONtNet_throw); - + if (swap_it) { UUrSwap_2Byte(&throw_data->throwing); UUrSwap_2Byte(&throw_data->throwFrame); } break; - + case ONcNet_Update_inAir: inAir = (ONtNet_inAir*)data_ptr; data_ptr += sizeof(ONtNet_inAir); - + if (swap_it) { UUrSwap_2Byte(&inAir->numFramesInAir); @@ -1428,53 +1428,53 @@ ONiNet_Process_Update_Authoritative( MUmPoint3D_Swap(inAir->velocity); } break; - + case ONcNet_Update_facing: ONmNet_SwapUpdate4Byte(float, character->facing, data_ptr, swap_it); break; - + case ONcNet_Update_desiredFacing: ONmNet_SwapUpdate4Byte(float, character->desiredFacing, data_ptr, swap_it); break; - + case ONcNet_Update_aimingLR: ONmNet_SwapUpdate4Byte(float, character->aimingLR, data_ptr, swap_it); break; - + case ONcNet_Update_aimingUD: ONmNet_SwapUpdate4Byte(float, character->aimingUD, data_ptr, swap_it); break; - + case ONcNet_Update_buttonIsDown: { LItButtonBits *button_bits; - + button_bits = (LItButtonBits*)data_ptr; data_ptr += sizeof(LItButtonBits); - + if (swap_it) { UUrSwap_8Byte(button_bits); } - + ONrInput_Update_Keys(&character->inputState, *button_bits); } break; - + case ONcNet_Update_aimingTarget: ONmNet_SwapUpdateFunc(M3tPoint3D, character->aimingTarget, data_ptr, swap_it, MUmPoint3D_Swap); break; - + case ONcNet_Update_aimingVector: ONmNet_SwapUpdateFunc(M3tVector3D, character->aimingVector, data_ptr, swap_it, MUmPoint3D_Swap); break; - + default: break; } - + prev_datatype = datatype; } - + // handle inAir if (inAir) { @@ -1482,7 +1482,7 @@ ONiNet_Process_Update_Authoritative( character->inAirControl.flags = inAir->flags; character->inAirControl.velocity = inAir->velocity; } - + if ((is_server == UUcFalse) && (!(character->flags & ONcCharacterFlag_BeingThrown)) && (ioUpdate->hdr.animName[0] != '\0')) @@ -1497,13 +1497,13 @@ ONiNet_Process_Update_Authoritative( { UUtUns16 num_frames; UUtBool updateAnimation = UUcTrue; - + // if the character is dead, make sure this animation is appropriate for death if (character->flags & ONcCharacterFlag_Dead) { TRtAnimState curToState = TRrAnimation_GetTo(character->animation); TRtAnimState newToState = TRrAnimation_GetTo(animation); - + // if we are currently heading towards fallen and the new animation would not // then this is a better animation to run when we are dead if ((ONrAnimState_IsFallen(curToState)) && @@ -1512,18 +1512,18 @@ ONiNet_Process_Update_Authoritative( updateAnimation = UUcFalse; } } - + if ((updateAnimation) && (character->animation == animation)) { UUtInt32 oldFrame = character->animFrame; UUtInt32 newFrame = ioUpdate->hdr.animFrame; - + if (UUmABS(oldFrame - newFrame) < 2) { updateAnimation = UUcFalse; } } - + if (updateAnimation) { // set the characters animation @@ -1533,7 +1533,7 @@ ONiNet_Process_Update_Authoritative( ONcAnimType_None, animation); } - + num_frames = TRrAnimation_GetDuration(character->animation); if (ioUpdate->hdr.animFrame >= num_frames) @@ -1546,7 +1546,7 @@ ONiNet_Process_Update_Authoritative( } } } - + // handle throwing if (throw_data) { @@ -1555,7 +1555,7 @@ ONiNet_Process_Update_Authoritative( (throw_data->throwFrame < 10)) { TRtAnimation *throw_animation; - + // get the animation error = TMrInstance_GetDataPtr( @@ -1563,10 +1563,10 @@ ONiNet_Process_Update_Authoritative( throw_data->throwName, &throw_animation); if (error != UUcError_None) return; - + // set the throw target character->throwTarget = &ioProcessGroup->common->character_list[throw_data->throwing]; - + if ((character->throwTarget->animation != throw_animation) && (prev_character_animation != animation) && !(character->throwTarget->flags & ONcCharacterFlag_BeingThrown)) @@ -1574,7 +1574,7 @@ ONiNet_Process_Update_Authoritative( // set the throw variables character->targetThrow = throw_animation; character->throwing = throw_data->throwing; - + // run the throw ONrCharacter_NewAnimationHook(character); if (character->throwTarget) @@ -1605,15 +1605,15 @@ ONiNet_Generate_Critical_Update( { ONtNet_BufferData buffer_data; UUtBool is_server; - + // initialize the buffer data ONiNet_Buffer_Init(&buffer_data, outCUpdate->data); - + // initialize the critical update header outCUpdate->hdr.character_index = inCharacter->index; - + is_server = ONrNet_IsServer(); - + // check the character's health only on the server if ((is_server) && (inUpdateFlags & ONcCharacterUpdateFlag_HitPoints)) @@ -1622,9 +1622,9 @@ ONiNet_Generate_Critical_Update( &buffer_data, ONcNet_CU_Health, (UUtUns8*)&inCharacter->hitPoints, - sizeof(UUtUns32)); + sizeof(UUtUns32)); } - + // check the character's numKills if ((is_server) && (inUpdateFlags & ONcCharacterUpdateFlag_NumKills)) { @@ -1632,9 +1632,9 @@ ONiNet_Generate_Critical_Update( &buffer_data, ONcNet_CU_NumKills, (UUtUns8*)&inCharacter->numKills, - sizeof(UUtUns32)); + sizeof(UUtUns32)); } - + // check the character's damageInflicted if ((is_server) && (inUpdateFlags & ONcCharacterUpdateFlag_DamageInflicted)) { @@ -1642,15 +1642,15 @@ ONiNet_Generate_Critical_Update( &buffer_data, ONcNet_CU_DamageInflicted, (UUtUns8*)&inCharacter->damageInflicted, - sizeof(UUtUns32)); + sizeof(UUtUns32)); } - + // check the character's inventory if ((is_server) && (inUpdateFlags & ONcCharacterUpdateFlag_Inventory)) { ONtNet_Inventory inventory; UUtUns32 i; - + for (i = 0; i < WPcMaxSlots; i++) { if (inCharacter->inventory.weapons[i].weapon) @@ -1666,7 +1666,7 @@ ONiNet_Generate_Critical_Update( inventory.ammo = inCharacter->inventory.ammo; inventory.hypo = inCharacter->inventory.hypo; inventory.cell = inCharacter->inventory.cell; - + // add weapon index ONiNet_Buffer_AddData( &buffer_data, @@ -1674,7 +1674,7 @@ ONiNet_Generate_Critical_Update( (UUtUns8*)&inventory, sizeof(ONtNet_Inventory)); } - + // check the character's name if (inUpdateFlags & ONcCharacterUpdateFlag_Name) { @@ -1684,7 +1684,7 @@ ONiNet_Generate_Critical_Update( (UUtUns8*)inCharacter->player_name, ONcMaxPlayerNameLength); } - + // check the character's class if (inUpdateFlags & ONcCharacterUpdateFlag_Class) { @@ -1694,22 +1694,22 @@ ONiNet_Generate_Critical_Update( (UUtUns8*)TMrInstance_GetInstanceName(inCharacter->characterClass), AIcMaxClassNameLen); } - + // check for spawn if ((is_server) && (inUpdateFlags & ONcCharacterUpdateFlag_Spawn)) { ONtNet_Info_Spawn spawn_info; - + spawn_info.facing = inCharacter->facing; spawn_info.position = inCharacter->physics->position; - + ONiNet_Buffer_AddData( &buffer_data, ONcNet_CU_Spawn, (UUtUns8*)&spawn_info, sizeof(ONtNet_Info_Spawn)); } - + // check for character gone if ((is_server) && (inUpdateFlags & ONcCharacterUpdateFlag_Gone)) { @@ -1719,7 +1719,7 @@ ONiNet_Generate_Critical_Update( NULL, 0); } - + // return the size return (UUtUns16)(ONcNet_CUpdate_MinSize + ONiNet_Buffer_Build(&buffer_data)); } @@ -1732,7 +1732,7 @@ ONiNet_Skip_Critical_Update( { ONtNet_DataTypeInfo *datatype_info; UUtUns16 skip_bytes; - + // get a pointer to the datatype info datatype_info = (ONtNet_DataTypeInfo*)ioCUpdate->data; if (ioProcessGroup->swap_it) @@ -1740,10 +1740,10 @@ ONiNet_Skip_Critical_Update( UUrSwap_2Byte(&datatype_info->num_datatypes); UUrSwap_2Byte(&datatype_info->datatypes_offset); } - + // calculate the number of bytes that are in the update skip_bytes = (datatype_info->datatypes_offset + datatype_info->num_datatypes + 3) & ~3; - + // advance the data by the number of bytes processed ONiNet_DataAdvance(ioProcessGroup, skip_bytes); } @@ -1756,7 +1756,7 @@ ONiNet_Process_Critical_Update( const ONtCharacter *inClientCharacter) { UUtError error; - + ONtNet_DataTypeInfo *datatype_info; UUtUns8 *data_ptr; ONtNet_DataType *datatypes; @@ -1765,9 +1765,9 @@ ONiNet_Process_Critical_Update( UUtBool swap_it; UUtBool is_server; UUtUns16 bytes_processed; - + ONtCharacter *character; - + // get a pointer to the character character = &ioProcessGroup->common->character_list[ioCUpdate->hdr.character_index]; if (!(character->flags & ONcCharacterFlag_InUse)) @@ -1775,10 +1775,10 @@ ONiNet_Process_Critical_Update( ONiNet_Skip_Critical_Update(ioProcessGroup, ioCUpdate); return; } - + swap_it = ioProcessGroup->swap_it; is_server = ONrNet_IsServer(); - + // get a pointer to the datatype info datatype_info = (ONtNet_DataTypeInfo*)ioCUpdate->data; if (swap_it) @@ -1786,19 +1786,19 @@ ONiNet_Process_Critical_Update( UUrSwap_2Byte(&datatype_info->num_datatypes); UUrSwap_2Byte(&datatype_info->datatypes_offset); } - + // set the other pointers data_ptr = ioCUpdate->data + sizeof(ONtNet_DataTypeInfo); datatypes = ioCUpdate->data + datatype_info->datatypes_offset; - + // process the data prev_datatype = ONcNone; for (i = 0; i < datatype_info->num_datatypes; i++) { ONtNet_DataType datatype; - + datatype = datatypes[i]; - + // process the datatype switch (datatype) { @@ -1812,13 +1812,13 @@ ONiNet_Process_Critical_Update( else { ONmNet_SwapUpdate4Byte(UUtUns32, character->hitPoints, data_ptr, swap_it); - + // even though the hitPoints field was already updated, call // this function to do some extra processing ONrCharacter_SetHitPoints(character, character->hitPoints); } break; - + case ONcNet_CU_NumKills: if (is_server) { @@ -1829,7 +1829,7 @@ ONiNet_Process_Critical_Update( ONmNet_SwapUpdate4Byte(UUtUns32, character->numKills, data_ptr, swap_it); } break; - + case ONcNet_CU_DamageInflicted: if (is_server) { @@ -1840,7 +1840,7 @@ ONiNet_Process_Critical_Update( ONmNet_SwapUpdate4Byte(UUtUns32, character->damageInflicted, data_ptr, swap_it); } break; - + case ONcNet_CU_Inventory: // servers do not process inventory updates if (is_server) @@ -1851,27 +1851,27 @@ ONiNet_Process_Critical_Update( { ONtNet_Inventory inventory; UUtUns32 i; - + //COrConsole_Printf("Critical Update: Inventory"); inventory = *(ONtNet_Inventory*)data_ptr; data_ptr += sizeof(ONtNet_Inventory); - + if (swap_it) { for (i = 0; i < WPcMaxSlots; i++) { UUrSwap_2Byte(&inventory.weapons[i]); } - + UUrSwap_2Byte(&inventory.ammo); UUrSwap_2Byte(&inventory.hypo); UUrSwap_2Byte(&inventory.cell); } - + // get rid of the weapon currently being held by the character if any ONrCharacter_DropWeapon(character, UUcFalse, WPcPrimarySlot, UUcFalse); - + // empty the inventory slots of the character for (i = 0; i < WPcMaxSlots; i++) { @@ -1881,7 +1881,7 @@ ONiNet_Process_Critical_Update( character->inventory.weapons[i].weapon = NULL; } } - + // fill the inventory slots of the character for (i = 0; i < WPcMaxSlots; i++) { @@ -1889,36 +1889,36 @@ ONiNet_Process_Critical_Update( { // put the weapon in the inventory slot character->inventory.weapons[i].weapon = WPrGetWeapon(inventory.weapons[i]); - + // assign the weapon to the character WPrAssign(character->inventory.weapons[i].weapon, character); } } - + // set the character weapon matrix to the identity matrix. This prevents hitting // an assert in the weapon code when the matrix is all 0.0f and their is a weapon // in a slot other than the primary slot. MUrMatrix_Identity(&character->matricies[ONcWeapon_Index]); - + // make the character use the weapon in WPcPrimarySlot if (WPrInUse(character->inventory.weapons[WPcPrimarySlot].weapon)) { ONrCharacter_UseWeapon(character, character->inventory.weapons[WPcPrimarySlot].weapon); } - + character->inventory.ammo = inventory.ammo; character->inventory.hypo = inventory.hypo; character->inventory.cell = inventory.cell; } break; - + case ONcNet_CU_Name: { char *player_name; - + player_name = (char*)data_ptr; data_ptr += ONcMaxPlayerNameLength; - + UUrString_Copy(character->player_name, player_name, ONcMaxPlayerNameLength); } break; @@ -1927,49 +1927,49 @@ ONiNet_Process_Critical_Update( { char *characterClassName; ONtCharacterClass *characterClass; - + characterClassName = (char*)data_ptr; data_ptr += AIcMaxClassNameLen; - + // don't update the class of the character of the client on this machine if (inClientCharacter == character) break; - + error = TMrInstance_GetDataPtr( TRcTemplate_CharacterClass, characterClassName, &characterClass); if (error != UUcError_None) continue; - + // set the class instance of the character ONrCharacter_SetCharacterClass(character, characterClass); } break; - + case ONcNet_CU_Spawn: // only clients process Spawn updates if (is_server == UUcFalse) { ONtNet_Info_Spawn *spawn_info; - + // get a pointer to the spawn info spawn_info = (ONtNet_Info_Spawn*)data_ptr; data_ptr += sizeof(ONtNet_Info_Spawn); - + if (swap_it) { UUrSwap_4Byte(&spawn_info->facing); MUmPoint3D_Swap(spawn_info->position); } - + character->facing = character->previousFacing = spawn_info->facing; character->physics->position = character->location = spawn_info->position; - + // update the character's node ONrCharacter_FindOurNode(character); } break; - + case ONcNet_CU_Gone: // only clients process Gone updates if (is_server == UUcFalse) @@ -1977,25 +1977,25 @@ ONiNet_Process_Critical_Update( ONrGameState_DeleteCharacter(character); } break; - + default: UUmAssert(!"unknown data type"); break; } - + prev_datatype = datatype; } - + // clients clear the character update flags so that a vicious cycle isn't entered if (is_server == UUcFalse) { character->updateFlags = ONcCharacterUpdateFlag_None; } - + // advance the data by the number of bytes processed bytes_processed = ONiNet_DataTypes_GetSize(datatype_info) + (data_ptr - ioCUpdate->data); ONiNet_DataAdvance(ioProcessGroup, bytes_processed); - + #if defined(DEBUGGING) && (DEBUGGING > 0) - // try to find spawn bugs + // try to find spawn bugs if ((character->hitPoints > 0) && (character->flags & ONcCharacterFlag_Dead)) { @@ -2021,7 +2021,7 @@ ONiNet_Generate_Weapon_Update( // initialize the buffer data ONiNet_Buffer_Init(&buffer_data, outWeaponUpdate->data); - + // initialize the weapon update header outWeaponUpdate->hdr.weapon_index = inWeaponIndex; outWeaponUpdate->hdr.pad = 0; @@ -2032,14 +2032,14 @@ ONiNet_Generate_Weapon_Update( if (inUpdateFlags & WPcWeaponUpdateFlag_Create) { ONtCharacter *owner; - + // add 32 bytes ONiNet_Buffer_AddData( &buffer_data, ONcNet_WU_Create, (UUtUns8*)TMrInstance_GetInstanceName(WPrGetClass(ioWeapon)), ONcMaxInstNameLength); - + // make sure the the owner of the weapon is set owner = WPrGetOwner(ioWeapon); if (owner) @@ -2061,16 +2061,16 @@ ONiNet_Generate_Weapon_Update( NULL, 0); } - + // --------------------------------- // add multi-byte updates // --------------------------------- if (inUpdateFlags & WPcWeaponUpdateFlag_Position) { M3tPoint3D position; - + WPrGetPosition(ioWeapon, &position); - + // add 12 bytes ONiNet_Buffer_AddData( &buffer_data, @@ -2079,13 +2079,13 @@ ONiNet_Generate_Weapon_Update( sizeof(M3tPoint3D)); //COrConsole_Printf("Generate Weapon %d Position Update", WPrGetIndex(ioWeapon)); } - + if (inUpdateFlags & WPcWeaponUpdateFlag_Ammo) { WPtAmmoGroup ammo_group; - + WPrGetAmmoGroup(ioWeapon, &ammo_group); - + // add 16 bytes ONiNet_Buffer_AddData( &buffer_data, @@ -2096,7 +2096,7 @@ ONiNet_Generate_Weapon_Update( // clear the weapon's update flags WPrSetUpdateFlags(ioWeapon, WPcWeaponUpdateFlag_None); - + // return the size return (UUtUns16)(ONcNet_WUpdate_MinSize + ONiNet_Buffer_Build(&buffer_data)); } @@ -2109,7 +2109,7 @@ ONiNet_Skip_Weapon_Update( { ONtNet_DataTypeInfo *datatype_info; UUtUns16 skip_bytes; - + // get a pointer to the datatype info datatype_info = (ONtNet_DataTypeInfo*)ioWeaponUpdate->data; if (ioProcessGroup->swap_it) @@ -2117,10 +2117,10 @@ ONiNet_Skip_Weapon_Update( UUrSwap_2Byte(&datatype_info->num_datatypes); UUrSwap_2Byte(&datatype_info->datatypes_offset); } - + // calculate the number of bytes that are in the update skip_bytes = (datatype_info->datatypes_offset + datatype_info->num_datatypes + 3) & ~3; - + // advance the data by the number of bytes processed ONiNet_DataAdvance(ioProcessGroup, skip_bytes); } @@ -2132,7 +2132,7 @@ ONiNet_Process_Weapon_Update( ONtNet_Weapon_Update *ioWeaponUpdate) { UUtError error; - + WPtWeapon *weapon; ONtNet_DataTypeInfo *datatype_info; @@ -2142,12 +2142,12 @@ ONiNet_Process_Weapon_Update( ONtNet_DataType prev_datatype; UUtBool swap_it; UUtUns16 bytes_processed; - + // get a pointer to the weapon weapon = WPrGetWeapon(ioWeaponUpdate->hdr.weapon_index); - + swap_it = ioProcessGroup->swap_it; - + // get a pointer to the datatype info datatype_info = (ONtNet_DataTypeInfo*)ioWeaponUpdate->data; if (swap_it) @@ -2155,19 +2155,19 @@ ONiNet_Process_Weapon_Update( UUrSwap_2Byte(&datatype_info->num_datatypes); UUrSwap_2Byte(&datatype_info->datatypes_offset); } - + // set the other pointers data_ptr = ioWeaponUpdate->data + sizeof(ONtNet_DataTypeInfo); datatypes = ioWeaponUpdate->data + datatype_info->datatypes_offset; - + // process the data prev_datatype = ONcNone; for (i = 0; i < datatype_info->num_datatypes; i++) { ONtNet_DataType datatype; - + datatype = datatypes[i]; - + // process the datatype switch (datatype) { @@ -2175,34 +2175,34 @@ ONiNet_Process_Weapon_Update( { WPtWeaponClass *weapon_class; char *weapon_class_name; - + weapon_class_name = (char*)data_ptr; data_ptr += ONcMaxInstNameLength; - + error = TMrInstance_GetDataPtr( WPcTemplate_WeaponClass, weapon_class_name, &weapon_class); if (error != UUcError_None) { break; } - + WPrInitAtIndex(weapon, ioWeaponUpdate->hdr.weapon_index, weapon_class); //COrConsole_Printf("create weapon %d", ioWeaponUpdate->hdr.weapon_index); } break; - + case ONcNet_WU_Delete: WPrDelete(weapon); break; - + case ONcNet_WU_Ammo: { WPtAmmoGroup ammo_group; - + // get the ammo group ammo_group = *(WPtAmmoGroup*)data_ptr; data_ptr += sizeof(WPtAmmoGroup); - + // swap and set the ammo group if there is a weapon if (swap_it) { @@ -2212,7 +2212,7 @@ ONiNet_Process_Weapon_Update( UUrSwap_2Byte(&ammo_group.ammo[x]); } } - + // set the ammo amount if (WPrInUse(weapon)) { @@ -2220,18 +2220,18 @@ ONiNet_Process_Weapon_Update( } } break; - + case ONcNet_WU_Position: { M3tPoint3D position; - + ONmNet_SwapUpdateFunc( M3tPoint3D, position, data_ptr, swap_it, MUmPoint3D_Swap); - + if (WPrInUse(weapon)) { WPrSetPosition(weapon, &position); @@ -2239,13 +2239,13 @@ ONiNet_Process_Weapon_Update( } } break; - + default: UUmAssert(!"unknown data type"); break; } - + prev_datatype = datatype; } - + // advance the data by the number of bytes processed bytes_processed = ONiNet_DataTypes_GetSize(datatype_info) + (data_ptr - ioWeaponUpdate->data); ONiNet_DataAdvance(ioProcessGroup, bytes_processed); @@ -2266,16 +2266,16 @@ ONiNet_Packet_AddData( { UUtUns16 new_packet_length; UUtUns16 index; - + // UUmAssert(ioPacketData->datatype_info->num_datatypes < ONcNet_MaxDataTypesPerPacket); - + // return if the maximum number of datatypes has been added if (ioPacketData->datatype_info->num_datatypes >= ONcNet_MaxDataTypesPerPacket) { -COrConsole_Printf("Max Data Types Per Packet Exceeded"); +COrConsole_Printf("Max Data Types Per Packet Exceeded"); return UUcFalse; } - + // make sure there is enough room in the packet new_packet_length = (UUtUns16)(ioPacketData->data_ptr - ioPacketData->packet.packet_data) + @@ -2285,7 +2285,7 @@ COrConsole_Printf("Max Data Types Per Packet Exceeded"); { return UUcFalse; } - + // add the data if (inData) { @@ -2293,16 +2293,16 @@ COrConsole_Printf("Max Data Types Per Packet Exceeded"); inData, ioPacketData->data_ptr, inDataLength); - + // set data_ptr at next 4byte boundary ioPacketData->data_ptr = (UUtUns8*)((UUtUns32)(ioPacketData->data_ptr + inDataLength + 3) & ~3); } - + // add the datatype index = ioPacketData->datatype_info->num_datatypes++; ioPacketData->datatypes[index] = inDataType; - + return UUcTrue; } @@ -2312,24 +2312,24 @@ ONiNet_Packet_Build( ONtNet_PacketData *ioPacketData) { UUtUns16 packet_size; - + // calculate the final packet size of the packet packet_size = sizeof(ONtNet_PacketHeader) + (UUtUns16)(ioPacketData->data_ptr - ioPacketData->packet.packet_data) + ONiNet_DataTypes_GetSize(ioPacketData->datatype_info); UUmAssert(packet_size < (sizeof(ONtNet_Packet) - sizeof(ONtNet_PacketHeader))); - + // copy the datatypes to the end of the data UUrMemory_MoveFast( ioPacketData->datatypes, ioPacketData->data_ptr, ONiNet_DataTypes_GetSize(ioPacketData->datatype_info)); - + // set the datatypes offset ioPacketData->datatype_info->datatypes_offset = ioPacketData->data_ptr - ioPacketData->packet.packet_data; - + return packet_size; } @@ -2340,12 +2340,12 @@ ONrNet_Packet_Init( { // the datatype_info is the first piece of data in the packet ioPacketData->datatype_info = (ONtNet_DataTypeInfo*)ioPacketData->packet.packet_data; - + // set the data ptr ioPacketData->data_ptr = ioPacketData->packet.packet_data + sizeof(ONtNet_DataTypeInfo); - + // initialize the datatype_info ioPacketData->datatype_info->num_datatypes = 0; ioPacketData->datatype_info->datatypes_offset = 0; @@ -2365,7 +2365,7 @@ ONiNet_Client_Packet_Build( const UUtUns16 inDataLength) { UUtBool status; - + // add the data to the packet status = ONiNet_Packet_AddData( @@ -2378,7 +2378,7 @@ ONiNet_Client_Packet_Build( // there is not enough room in the packet. Send the current data // and then add the data ONrNet_Client_Packet_Send(ioClient); - + status = ONiNet_Packet_AddData( &ioClient->packet_data, @@ -2398,10 +2398,10 @@ ONrNet_Client_Packet_Send( ONtNet_Client *ioClient) { UUtUns16 packet_length; - + // build the final packet to send packet_length = ONiNet_Packet_Build(&ioClient->packet_data); - + // make sure there is data to send if (packet_length == 0) return; @@ -2411,18 +2411,18 @@ ONrNet_Client_Packet_Send( ioClient->packet_data.packet.packet_header.packet_version = ONcNet_VersionNumber; ioClient->packet_data.packet.packet_header.player_index = ioClient->player_index; ioClient->packet_data.packet.packet_header.packet_length = packet_length; - + // send it NMrNetContext_WriteData( ioClient->client_context, - &ioClient->server_address, - (UUtUns8*)&ioClient->packet_data.packet, - packet_length, + &ioClient->server_address, + (UUtUns8*)&ioClient->packet_data.packet, + packet_length, NMcPacketFlags_None); - + ioClient->packets_sent++; ioClient->bytes_sent += packet_length; - + // there is no more data in the update packet ONrNet_Packet_Init(&ioClient->packet_data); } @@ -2440,9 +2440,9 @@ ONiNet_CS_ACK_Critical_Update( UUtUns16 inCharacterIndex) { ONtNet_Ack_CriticalUpdate ack; - + ack.uns16_0 = inCharacterIndex; - + // add ack to packet ONiNet_Client_Packet_Build( ioClient, @@ -2459,9 +2459,9 @@ ONiNet_CS_ACK_Weapon_Update( UUtUns16 inWeaponIndex) { ONtNet_Ack_WeaponUpdate ack; - + ack.uns16_0 = inWeaponIndex; - + // add ack to packet ONiNet_Client_Packet_Build( ioClient, @@ -2492,7 +2492,7 @@ ONrNet_CS_Request_CharacterCreate( UUtUns32 inRequestID) { ONtNet_Request_CharacterCreate create_request; - + // initialize the create request create_request.request_id = inRequestID; create_request.teamNumber = ioClient->teamNumber; @@ -2504,7 +2504,7 @@ ONrNet_CS_Request_CharacterCreate( create_request.characterClassName, ioClient->characterClassName, AIcMaxClassNameLen); - + // add request to packet ONiNet_Client_Packet_Build( ioClient, @@ -2522,21 +2522,21 @@ ONiNet_CS_Request_CharacterInfo( { ONtNet_Request_CharacterInfo info_request; ONtCharacter *character; - + // get a pointer to the character character = &ioProcessGroup->common->character_list[inCharacterIndex]; - + // send request only if the character info request hasn't already been made if (character->updateFlags & ONcCharacterUpdateFlag_NeedInfo) { return; } - + character->updateFlags |= ONcCharacterUpdateFlag_NeedInfo; - + // initialize the info request info_request.uns16_0 = inCharacterIndex; - + // add request to packet ONiNet_Client_Packet_Build( ioClient, @@ -2553,10 +2553,10 @@ ONrNet_CS_Request_Join( UUtUns32 inRequestID) { ONtNet_Request_Join join_request; - + // initialize the join request join_request.uns32_0 = inRequestID; - + // add request to packet ONiNet_Client_Packet_Build( ioClient, @@ -2587,10 +2587,10 @@ ONrNet_CS_Request_Quit( UUtUns32 inRequestID) { ONtNet_Request_Quit quit_request; - + // initialize the quit request quit_request.uns32_0 = inRequestID; - + // add request to packet ONiNet_Client_Packet_Build( ioClient, @@ -2609,22 +2609,22 @@ ONiNet_CS_Request_WeaponInfo( ONtNet_Request_WeaponInfo info_request; WPtWeapon *weapon; UUtUns16 updateFlags; - + // get a pointer to the weapon weapon = WPrGetWeapon(inWeaponIndex); - + // send request only if the weapon info request hasn't already been made updateFlags = WPrGetUpdateFlags(weapon); if (updateFlags & WPcWeaponUpdateFlag_NeedInfo) { return; } - + WPrSetUpdateFlags(weapon, updateFlags | WPcWeaponUpdateFlag_NeedInfo); - + // initialize the info request info_request.uns16_0 = inWeaponIndex; - + // add request to packet ONiNet_Client_Packet_Build( ioClient, @@ -2643,7 +2643,7 @@ ONrNet_CS_Update_Character( { ONtNet_Update_Character character_update; UUtUns16 update_size; - + // make sure the character can be updated if ((ioClient->character == NULL) || (ioClient->character->animation == NULL) || @@ -2651,7 +2651,7 @@ ONrNet_CS_Update_Character( { return; } - + // generate the update data if (ONgNet_Authoritative_Server == UUcTrue) { @@ -2669,7 +2669,7 @@ ONrNet_CS_Update_Character( &ioClient->prev_update, &character_update); } - + // add the update to packet ONiNet_Client_Packet_Build( ioClient, @@ -2686,23 +2686,23 @@ ONrNet_CS_Update_Critical( { ONtNet_Critical_Update critical_update; UUtUns16 update_size; - + // make sure the critical update can be done if (ioClient->character == NULL) { return; } - + // make sure a critical update is needed if ((ioClient->cupdate_bits == ONcCharacterUpdateFlag_None) && (ioClient->character->updateFlags == ONcCharacterUpdateFlag_None)) { return; } - + // a response is needed ioClient->cupdate_bits |= ioClient->character->updateFlags; - + // clear the character's updateFlags ioClient->character->updateFlags = ONcCharacterUpdateFlag_None; @@ -2712,7 +2712,7 @@ ONrNet_CS_Update_Critical( ioClient->character, ioClient->cupdate_bits, &critical_update); - + if (update_size > ONcNet_CUpdate_MinSize) { // add the update to packet @@ -2745,17 +2745,17 @@ ONiNet_CH_ACK_Quit( { ONtNet_Ack_Quit *ack_quit; UUtUns32 request_id; - + // get a pointer to the ack quit ack_quit = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_Ack_Quit); - + // get the request id request_id = ack_quit->uns32_0; if (ioProcessGroup->swap_it) { UUrSwap_4Byte(&request_id); } - + // the request was completed ONrNet_Client_Request_ResponseReceived(ioClient, request_id); } @@ -2772,45 +2772,45 @@ ONiNet_CH_Info_Character( AItCharacterSetup setup; UUtError error; TRtAnimation *animation; - + // get a pointer to the character create info character_info = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_Info_Character); - + // get the data from the packet character_index = character_info->character_index; - + if (ioProcessGroup->swap_it) { UUrSwap_2Byte(&character_index); } - + // get a pointer to the character character = &ioProcessGroup->common->character_list[character_index]; - + // if this character is already in use, then assume that a duplicate // character info response was received if (character->flags & ONcCharacterFlag_InUse) return; - + // initialize the character setup UUrMemory_Clear(&setup, sizeof(AItCharacterSetup)); setup.characterClass = ONrGetCharacterClass(character_info->character_class_name); - + // create the character error = ONrGameState_NewCharacter_atIndex(NULL, &setup, NULL, character_index); if (error != UUcError_None) return; - + // copy the player name UUrString_Copy( character->player_name, character_info->player_name, ONcMaxPlayerNameLength); - + // set the character's position, facing, and team number character->teamNumber = character_info->team_number; character->animFrame = character_info->anim_frame; character->facing = character_info->facing; character->physics->position = character_info->position; - + if (ioProcessGroup->swap_it) { UUrSwap_2Byte(&character->teamNumber); @@ -2820,7 +2820,7 @@ ONiNet_CH_Info_Character( } character->desiredFacing = character->facing; character->location = character->physics->position; - + // get the animation error = TMrInstance_GetDataPtr( @@ -2851,19 +2851,19 @@ ONiNet_CH_Info_CharacterCreate( M3tPoint3D position; float facing; UUtError error; - + // get a pointer to the character create info create_info = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_Info_CharacterCreate); - + // the client has to be in the join stage character create to handle this type of data if (ioClient->join_stage != ONcNet_JoinStage_CreateCharacter) return; - + // copy the data request_id = create_info->request_id; character_index = create_info->character_index; position = create_info->position; facing = create_info->facing; - + // swap the data if (ioProcessGroup->swap_it) { @@ -2872,7 +2872,7 @@ ONiNet_CH_Info_CharacterCreate( MUmPoint3D_Swap(position); UUrSwap_4Byte(&facing); } - + if (ONrNet_IsServer() == UUcFalse) { // initialize the setup @@ -2883,7 +2883,7 @@ ONiNet_CH_Info_CharacterCreate( setup.playerName, ioClient->playerName, ONcMaxPlayerNameLength); - + // create the character error = ONrGameState_NewCharacter_atIndex(NULL, &setup, NULL, character_index); if (error != UUcError_None) @@ -2923,18 +2923,18 @@ ONiNet_CH_Info_Game( ONtNet_Info_Game *game_info; UUtUns32 request_id; UUtUns16 level_number; - + // get a pointer to the game info game_info = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_Info_Game); - + // the client has to be in join stage game info to handle this type of data if (ioClient->join_stage != ONcNet_JoinStage_GameInfo) return; - + // process the game info request_id = game_info->request_id; ioClient->player_index = game_info->player_index; level_number = game_info->level_number; - + // swap the data if (ioProcessGroup->swap_it) { @@ -2942,16 +2942,16 @@ ONiNet_CH_Info_Game( UUrSwap_2Byte(&ioClient->player_index); UUrSwap_2Byte(&level_number); } - + // the request was completed ONrNet_Client_Request_ResponseReceived(ioClient, request_id); - + // load the level if (ONrNet_IsServer() == UUcFalse) { ONrNet_LevelLoad(ioProcessGroup->common, level_number); } - + // advance to the next stage of joining ONrNet_Client_JoinStage_Advance(ioClient, ioProcessGroup->common); } @@ -2963,13 +2963,13 @@ ONiNet_CH_Reject_Join( ONtNet_ProcessGroup *ioProcessGroup) { ONtNet_Reject_Join *rejection; - + // get a pointer to the join rejection rejection = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_Reject_Join); - + // the client has to be in the join stage game info to handle this type of data if (ioClient->join_stage != ONcNet_JoinStage_GameInfo) return; - + // swap the data if (ioProcessGroup->swap_it) { @@ -2978,7 +2978,7 @@ ONiNet_CH_Reject_Join( // process the rejection ONrNet_Client_Request_ResponseReceived(ioClient, rejection->uns32_0); - + // handle the rejection ONrNet_Client_Rejected(ioClient); } @@ -2992,18 +2992,18 @@ ONiNet_CH_Update_Character( ONtNet_Update_Character *character_update; ONtCharacter *character; UUtUns16 character_index; - + // get a pointer to the character update character_update = (ONtNet_Update_Character*)ioProcessGroup->data; ONiNet_DataAdvance(ioProcessGroup, (UUtUns16)ONcNet_Update_Character_MinSize); - + // don't process character updates on the server if (ONrNet_IsServer() == UUcTrue) { ONiNet_Skip_Update(ioProcessGroup, character_update); return; } - + // swap the header data if (ioProcessGroup->swap_it) { @@ -3011,11 +3011,11 @@ ONiNet_CH_Update_Character( UUrSwap_2Byte(&character_update->hdr.animFrame); MUmPoint3D_Swap(character_update->hdr.position); } - + // get a local copy of the data character_index = character_update->hdr.character_index; UUmAssert(character_index < ONcMaxCharacters); - + if (ONgNet_Authoritative_Server == UUcFalse) { // don't process the update for the character controlled by this machine @@ -3027,10 +3027,10 @@ ONiNet_CH_Update_Character( return; } } - + // get a pointer to the character character = &ioProcessGroup->common->character_list[character_index]; - + // if the character isn't in use, request info on the character if (!(character->flags & ONcCharacterFlag_InUse)) { @@ -3041,7 +3041,7 @@ ONiNet_CH_Update_Character( ONiNet_Skip_Update(ioProcessGroup, character_update); return; } - + // process the character update if (ONgNet_Authoritative_Server == UUcTrue) { @@ -3051,7 +3051,7 @@ ONiNet_CH_Update_Character( { ONiNet_Process_Update(ioProcessGroup, character_update); } - + // cleanup if ((ONgNet_Authoritative_Server == UUcTrue) && (ioClient->character != NULL) && @@ -3070,17 +3070,17 @@ ONiNet_CH_Update_Critical( ONtNet_Critical_Update *critical_update; ONtCharacter *character; UUtUns16 character_index; - + // get a pointer to the critical update critical_update = (ONtNet_Critical_Update*)ioProcessGroup->data; ONiNet_DataAdvance(ioProcessGroup, (UUtUns16)ONcNet_CUpdate_MinSize); - + // swap the standard data if (ioProcessGroup->swap_it) { UUrSwap_2Byte(&critical_update->hdr.character_index); } - + // get a local copy of the data character_index = critical_update->hdr.character_index; @@ -3096,16 +3096,16 @@ ONiNet_CH_Update_Critical( // acknowledge the critical update ONiNet_CS_ACK_Critical_Update(ioClient, ioProcessGroup, character_index); - + return; } - + // process the critical update ONiNet_Process_Critical_Update(ioProcessGroup, critical_update, ioClient->character); - + // acknowledge the critical update ONiNet_CS_ACK_Critical_Update(ioClient, ioProcessGroup, character_index); - + // request info about the weapon in the primary slot if the weapon isn't in use if ((character->inventory.weapons[WPcPrimarySlot].weapon) && (WPrInUse(character->inventory.weapons[WPcPrimarySlot].weapon) == UUcFalse)) @@ -3125,17 +3125,17 @@ ONiNet_CH_Update_Weapons( { ONtNet_Weapon_Update *weapon_update; WPtWeapon *weapon; - + // get a pointer to the weapon update weapon_update = (ONtNet_Weapon_Update*)ioProcessGroup->data; ONiNet_DataAdvance(ioProcessGroup, (UUtUns16)ONcNet_WUpdate_MinSize); - + // swap the standard data if (ioProcessGroup->swap_it) { UUrSwap_2Byte(&weapon_update->hdr.weapon_index); } - + // don't process weapon updates on the server if (ONrNet_IsServer() == UUcTrue) { @@ -3143,22 +3143,22 @@ ONiNet_CH_Update_Weapons( ONiNet_CS_ACK_Weapon_Update(ioClient, ioProcessGroup, weapon_update->hdr.weapon_index); return; } - + // if the weapon is unknown, send a request for info weapon = WPrGetWeapon(weapon_update->hdr.weapon_index); if ((WPrInUse(weapon) == UUcFalse) && ((WPrGetUpdateFlags(weapon) & WPcWeaponUpdateFlag_NeedInfo) == 0)) { ONiNet_CS_Request_WeaponInfo(ioClient, ioProcessGroup, weapon_update->hdr.weapon_index); - + ONiNet_Skip_Weapon_Update(ioProcessGroup, weapon_update); ONiNet_CS_ACK_Weapon_Update(ioClient, ioProcessGroup, weapon_update->hdr.weapon_index); return; } - + // process the weapon update ONiNet_Process_Weapon_Update(ioProcessGroup, weapon_update); - + // acknowledge the weapon update ONiNet_CS_ACK_Weapon_Update(ioClient, ioProcessGroup, weapon_update->hdr.weapon_index); } @@ -3176,32 +3176,32 @@ ONiNet_Client_IsLegalPacket( { const ONtNet_Packet *packet; UUtUns16 packet_length; - + // get the packet and packet_length from ioProcessGroup packet = &ioProcessGroup->packet; packet_length = ioProcessGroup->packet_length; - + // make sure the packet version is supported if (packet->packet_header.packet_version != ONcNet_VersionNumber) { return UUcFalse; } - + // check the packet's number against the previously received packet if (ioClient->previous_packet_number >= packet->packet_header.packet_number) { return UUcFalse; } - + // make sure the packet sizes are okay if (packet->packet_header.packet_length > packet_length) { return UUcFalse; } - + // save the packet number ioClient->previous_packet_number = packet->packet_header.packet_number; - + // save the packet time ioClient->previous_packet_time = ioProcessGroup->common->game_time; @@ -3217,16 +3217,16 @@ ONrNet_Client_ProcessPacket( UUtBool is_legal_packet; ONtNet_DataType prev_datatype; UUtUns16 i; - + // swap the packet header // NOTE: byte-swapping is only done on incoming data if it needs to be swapped. // All outgoing data is written in the processors native endian format ioProcessGroup->swap_it = ONiNet_Swap_PacketHeader(&ioProcessGroup->packet); - + // make sure the packet can be used is_legal_packet = ONiNet_Client_IsLegalPacket(ioClient, ioProcessGroup); if (is_legal_packet == UUcFalse) return; - + // set the pointers ioProcessGroup->datatype_info = (ONtNet_DataTypeInfo*)ioProcessGroup->packet.packet_data; @@ -3235,24 +3235,24 @@ ONrNet_Client_ProcessPacket( UUrSwap_2Byte(&ioProcessGroup->datatype_info->num_datatypes); UUrSwap_2Byte(&ioProcessGroup->datatype_info->datatypes_offset); } - + ioProcessGroup->data = ioProcessGroup->packet.packet_data + sizeof(ONtNet_DataTypeInfo); - + ioProcessGroup->datatypes = ioProcessGroup->packet.packet_data + ioProcessGroup->datatype_info->datatypes_offset; - + // process the data prev_datatype = ONcNone; for (i = 0; i < ioProcessGroup->datatype_info->num_datatypes; i++) { ONtNet_DataType datatype; - + // get the ONtNet_DataType datatype = ioProcessGroup->datatypes[i]; - + UUmAssert(((UUtUns32)ioProcessGroup->data & 3) == 0); switch (datatype) @@ -3268,7 +3268,7 @@ UUmAssert(((UUtUns32)ioProcessGroup->data & 3) == 0); case ONcS2C_Update_Weapon: ONiNet_CH_Update_Weapons(ioClient, ioProcessGroup); break; default: UUmAssert(!"unknown data type"); break; } - + prev_datatype = datatype; } } @@ -3284,12 +3284,12 @@ ONiNet_Server_GetFreePlayer( ONtNet_Server *ioServer) { UUtUns16 i; - + for (i = 0; i < ioServer->game_options.max_players; i++) { if (ioServer->players[i].inUse == UUcFalse) break; } - + return i; } @@ -3310,13 +3310,13 @@ ONiNet_Server_RawPacket_Send( inPacket->packet_header.packet_version = ONcNet_VersionNumber; inPacket->packet_header.player_index = ONcNet_ServerIndex; inPacket->packet_header.packet_length = inPacketLength; - + // send it NMrNetContext_WriteData( ioServer->server_context, - inToAddress, - (UUtUns8*)inPacket, - inPacketLength, + inToAddress, + (UUtUns8*)inPacket, + inPacketLength, NMcPacketFlags_None); ioServer->raw_packets_sent++; @@ -3331,31 +3331,31 @@ ONrNet_Server_PlayerPacket_Send( { ONtNet_Players *player; UUtUns16 packet_length; - + // get a pointer to the player player = &ioServer->players[inPlayerIndex]; - + // make sure there is data to send if (player->player_packet_data.datatype_info->num_datatypes == 0) return; // build the packet packet_length = ONiNet_Packet_Build(&player->player_packet_data); - + // initialize the packet header player->player_packet_data.packet.packet_header.packet_swap = ONcNet_SwapIt; player->player_packet_data.packet.packet_header.packet_number = ioServer->packet_number++; player->player_packet_data.packet.packet_header.packet_version = ONcNet_VersionNumber; player->player_packet_data.packet.packet_header.player_index = ONcNet_ServerIndex; player->player_packet_data.packet.packet_header.packet_length = packet_length; - + // send it NMrNetContext_WriteData( ioServer->server_context, - &player->player_address, - (UUtUns8*)&player->player_packet_data.packet, - packet_length, + &player->player_address, + (UUtUns8*)&player->player_packet_data.packet, + packet_length, NMcPacketFlags_None); - + ioServer->player_packets_sent++; ioServer->player_bytes_sent += packet_length; @@ -3375,16 +3375,16 @@ ONiNet_Server_PlayerPacket_Build( { UUtBool status; UUtUns16 packet_length; - + if (inPlayerIndex == ONcNet_UnknownPlayer) { // The client requesting data has not joined this server yet so it has no // outgoing packet to use ONtNet_PacketData packet_data; - + // initialize the packet data ONrNet_Packet_Init(&packet_data); - + // add the data to the packet status = ONiNet_Packet_AddData( @@ -3396,10 +3396,10 @@ ONiNet_Server_PlayerPacket_Build( { UUmAssert(!"should never get here"); } - + // build the packet packet_length = ONiNet_Packet_Build(&packet_data); - + // send the response_packet ONiNet_Server_RawPacket_Send( ioServer, @@ -3412,10 +3412,10 @@ ONiNet_Server_PlayerPacket_Build( // add inData to this players outgoing data if there is room, if not, send // the current outgoing data, and start a new packet ONtNet_Players *player; - + // get a pointer to the player player = &ioServer->players[inPlayerIndex]; - + // add the datat to the packet status = ONiNet_Packet_AddData( @@ -3428,7 +3428,7 @@ ONiNet_Server_PlayerPacket_Build( // there is not enough room in the packet. Send the current data // and then add the new data ONrNet_Server_PlayerPacket_Send(ioServer, inPlayerIndex); - + status = ONiNet_Packet_AddData( &player->player_packet_data, @@ -3457,7 +3457,7 @@ ONrNet_Server_MassPacket_PrepareForSend( ONtNet_Server *ioServer) { UUtUns16 packet_length; - + // initialize the packet data packet_length = ONiNet_Packet_Build(&ioServer->mass_packet_data); @@ -3476,16 +3476,16 @@ ONrNet_Server_MassPacket_SendToAddress( { // make sure there is data to send if (ioServer->mass_packet_data.datatype_info->num_datatypes == 0) return; - + // set the packet number ioServer->mass_packet_data.packet.packet_header.packet_number = ioServer->packet_number++; - + // send the packet NMrNetContext_WriteData( ioServer->server_context, - inToAddress, - (UUtUns8*)&ioServer->mass_packet_data.packet, - ioServer->mass_packet_data.packet.packet_header.packet_length, + inToAddress, + (UUtUns8*)&ioServer->mass_packet_data.packet, + ioServer->mass_packet_data.packet.packet_header.packet_length, NMcPacketFlags_None); ioServer->mass_packets_sent++; @@ -3498,14 +3498,14 @@ ONiNet_Server_MassPacket_Send( ONtNet_Server *ioServer) { UUtUns16 i; - + // make sure there is data to send if (ioServer->mass_packet_data.datatype_info->num_datatypes == 0) return; - + // initialize the mass packet ONrNet_Server_MassPacket_PrepareForSend(ioServer); - // go through all the players + // go through all the players for (i = 0; i < ioServer->game_options.max_players; i++) { if (ioServer->players[i].send_updates) @@ -3530,7 +3530,7 @@ ONiNet_Server_MassPacket_Build( const UUtUns16 inDataLength) { UUtBool status; - + // add the data to the packet status = ONiNet_Packet_AddData( @@ -3543,7 +3543,7 @@ ONiNet_Server_MassPacket_Build( // there is not enough room in the packet. Send the current data // and then add the data ONiNet_Server_MassPacket_Send(ioServer); - + status = ONiNet_Packet_AddData( &ioServer->mass_packet_data, @@ -3587,9 +3587,9 @@ ONiNet_SS_ACK_Quit( UUtUns32 inRequestID) { ONtNet_Ack_Quit ack_quit; - + ack_quit.uns32_0 = inRequestID; - + // add ack to packet ONiNet_Server_PlayerPacket_Build( ioServer, @@ -3609,11 +3609,11 @@ ONiNet_SS_Info_Game( UUtUns32 inRequestID) { ONtNet_Info_Game game_info; - + game_info.request_id = inRequestID; game_info.player_index = inPlayerIndex; game_info.level_number = ioProcessGroup->common->level_number; - + // add info to packet ONiNet_Server_PlayerPacket_Build( ioServer, @@ -3632,9 +3632,9 @@ ONiNet_SS_Reject_Join( UUtUns32 inRequestID) { ONtNet_Reject_Join rejection; - + rejection.uns32_0 = inRequestID; - + // add ack to packet ONiNet_Server_PlayerPacket_Build( ioServer, @@ -3654,7 +3654,7 @@ ONrNet_SS_Update_Character( { ONtNet_Update_Character character_update; UUtUns16 update_size; - + // make sure the character can be updated if ((inCharacter == NULL) || (inCharacter->animation == NULL) || @@ -3662,7 +3662,7 @@ ONrNet_SS_Update_Character( { return; } - + // generate the update data if (ONgNet_Authoritative_Server == UUcTrue) { @@ -3680,7 +3680,7 @@ ONrNet_SS_Update_Character( &ioServer->prev_update[inCharacter->index], &character_update); } - + // add the data to the update packet ONiNet_Server_MassPacket_Build( ioServer, @@ -3700,27 +3700,27 @@ ONrNet_SS_Update_Critical( { ONtNet_Critical_Update critical_update; UUtUns16 update_size; - + // set the update bits *outUpdateFlags = inCharacter->updateFlags; - + // make sure the character can be updated and an update is needed if ((inCharacter == NULL) || (inCharacter->updateFlags == ONcCharacterUpdateFlag_None)) { return; } - + // clear the character's updateFlags inCharacter->updateFlags = ONcCharacterUpdateFlag_None; - + // generate the update data update_size = ONiNet_Generate_Critical_Update( inCharacter, *outUpdateFlags, &critical_update); - + if (update_size > ONcNet_CUpdate_MinSize) { // add the data to the update packet @@ -3744,17 +3744,17 @@ ONrNet_SS_Update_Critical_Force( { ONtNet_Critical_Update critical_update; UUtUns16 update_size; - + // make sure the character can be updated if (inCharacter == NULL) return; - + // generate the update data update_size = ONiNet_Generate_Critical_Update( inCharacter, inUpdateFlags, &critical_update); - + if (update_size > ONcNet_CUpdate_MinSize) { // add the data to the response packet @@ -3780,30 +3780,30 @@ ONrNet_SS_Update_Weapons( ONtNet_ProcessGroup *ioProcessGroup) { UUtUns16 i; - + // check the weapon positions for (i = 0; i < WPcMaxWeapons; i++) { WPtWeapon *weapon; - + weapon = WPrGetWeapon(i); if (WPrInUse(weapon) && (WPrGetOwner(weapon) == NULL)) { M3tPoint3D position; - + WPrGetPosition(weapon, &position); - + if ((position.x != ONgNet_WeaponPosition[i].x) || (position.y != ONgNet_WeaponPosition[i].y) || (position.z != ONgNet_WeaponPosition[i].z)) { WPrSetUpdateFlags(weapon, WPrGetUpdateFlags(weapon) | WPcWeaponUpdateFlag_Position); } - + ONgNet_WeaponPosition[i] = position; } } - + // update each weapon for (i = 0; i < WPcMaxWeapons; i++) { @@ -3812,18 +3812,18 @@ ONrNet_SS_Update_Weapons( UUtUns16 update_size; UUtUns16 j; UUtUns16 updateFlags; - + // get a pointer to the weapon weapon = WPrGetWeapon(i); if (WPrInUse(weapon) == UUcFalse) { continue; } - + // if the weapon's updateFlags are set, then do a mass update updateFlags = WPrGetUpdateFlags(weapon); if (updateFlags != WPcWeaponUpdateFlag_None) { // save the update flags - ioServer->updateFlags[i] |= updateFlags; - + ioServer->updateFlags[i] |= updateFlags; + // generate the update update_size = ONiNet_Generate_Weapon_Update( @@ -3831,7 +3831,7 @@ ONrNet_SS_Update_Weapons( i, updateFlags, &weapon_update); - + // add the data to the packet for all the clients ONiNet_Server_MassPacket_Build( ioServer, @@ -3844,7 +3844,7 @@ ONrNet_SS_Update_Weapons( for (j = 0; j < ioServer->game_options.max_players; j++) { if (ioServer->players[j].inUse == UUcFalse) { continue; } - + // if this player failed to acknowledge a previous weapon update then // generate a new one and send it to the that player if (ioServer->players[j].weaponACKNeeded[i]) @@ -3856,7 +3856,7 @@ ONrNet_SS_Update_Weapons( i, ioServer->weaponFlags[i], &weapon_update); - + // add the update to the player packet ONiNet_Server_PlayerPacket_Build( ioServer, @@ -3866,7 +3866,7 @@ ONrNet_SS_Update_Weapons( (UUtUns8*)&weapon_update, update_size); } - + // the mass packet needs to be updated ioServer->players[j].weaponACKNeeded[i] = UUcTrue; } @@ -3874,9 +3874,9 @@ ONrNet_SS_Update_Weapons( else { UUtBool forced_update; - + forced_update = UUcFalse; - + for (j = 0; j < ioServer->game_options.max_players; j++) { if (ioServer->players[j].inUse == UUcFalse) { continue; } @@ -3892,7 +3892,7 @@ ONrNet_SS_Update_Weapons( i, ioServer->weaponFlags[i], &weapon_update); - + // add the update to the player packet ONiNet_Server_PlayerPacket_Build( ioServer, @@ -3905,7 +3905,7 @@ ONrNet_SS_Update_Weapons( forced_update = UUcTrue; } } - + if (forced_update == UUcFalse) { ioServer->weaponFlags[i] = WPcWeaponUpdateFlag_None; @@ -3929,21 +3929,21 @@ ONiNet_SH_ACK_Critical_Update( UUtUns16 player_index; UUtUns16 character_index; ONtNet_Ack_CriticalUpdate *ack; - + // get the critical update ack = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_Ack_CriticalUpdate); - + if (ioProcessGroup->swap_it) { UUrSwap_2Byte(&ack->uns16_0); } - + // get the character index character_index = ack->uns16_0; - + // get the player's index player_index = ioProcessGroup->packet.packet_header.player_index; - + // update ACK received ioServer->players[player_index].updateACKNeeded[character_index] = UUcFalse; } @@ -3957,21 +3957,21 @@ ONiNet_SH_ACK_Weapon_Update( UUtUns16 player_index; UUtUns16 weapon_index; ONtNet_Ack_CriticalUpdate *ack; - + // get the weapon update ack = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_Ack_WeaponUpdate); - + if (ioProcessGroup->swap_it) { UUrSwap_2Byte(&ack->uns16_0); } - + // get the weapon index weapon_index = ack->uns16_0; - + // get the player's index player_index = ioProcessGroup->packet.packet_header.player_index; - + // update the ACK received ioServer->players[player_index].weaponACKNeeded[weapon_index] = UUcFalse; } @@ -3988,22 +3988,22 @@ ONiNet_SH_Request_CharacterCreate( UUtUns16 player_index; ONtNet_Players *player; ONtNet_Info_CharacterCreate create_info; - + // ------------------------------ // confirm some information // ------------------------------ // get a pointer to the create request create_request = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_Request_CharacterCreate); - + request_id = create_request->request_id; team_number = create_request->teamNumber; - + if (ioProcessGroup->swap_it) { UUrSwap_2Byte(&request_id); UUrSwap_2Byte(&team_number); } - + // ------------------------------ // create a new character if necessary // ------------------------------ @@ -4017,10 +4017,10 @@ ONiNet_SH_Request_CharacterCreate( ONtFlag start_flag; ONtCharacter *character; UUtBool found; - + // setup the character setup based on info in the character create request UUrMemory_Clear(&character_setup, sizeof(AItCharacterSetup)); - + // initialize the needed data of the character setup character_setup.teamNumber = team_number; character_setup.characterClass = ONrGetCharacterClass(create_request->characterClassName); @@ -4028,11 +4028,11 @@ ONiNet_SH_Request_CharacterCreate( character_setup.playerName, create_request->playerName, ONcMaxPlayerNameLength); - + // get the starting location and facing from the level found = ONrLevel_Flag_ID_To_Flag(ONrGameState_GetPlayerStart(), &start_flag); if (found == UUcFalse) { return; } - + // create a new character for the player error = ONrGameState_NewCharacter(NULL, &character_setup, &start_flag, &character_index); if (error != UUcError_None) @@ -4046,18 +4046,18 @@ ONiNet_SH_Request_CharacterCreate( // set the players character player->character = character; - + // change the team number to the character index if the team number is 0xFFFF if (team_number == 0xFFFF) character->teamNumber = character_index; - + // clear the update flags so that the previous use of this character (if any) // doesn't cause the character to be deleted again when ONrNet_Server_Update() // is run ioServer->updateFlags[character_index] = ONcCharacterUpdateFlag_None; } - + UUmAssert(player->character); - + // ------------------------------ // tell the player about its character // ------------------------------ @@ -4092,23 +4092,23 @@ ONiNet_SH_Request_CharacterInfo( UUtUns16 character_index; ONtCharacter *character; ONtNet_Info_Character character_info; - + // get a pointer to the character info request info_request = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_Request_CharacterInfo); - + // get the character index character_index = info_request->uns16_0; if (ioProcessGroup->swap_it) { UUrSwap_2Byte(&character_index); } - + // get a pointer to the character character = &ioProcessGroup->common->character_list[character_index]; if (character->flags & ONcCharacterFlag_InUse) { UUtUns16 player_index; - + // set the character info data character_info.character_index = character->index; character_info.team_number = character->teamNumber; @@ -4134,10 +4134,10 @@ ONiNet_SH_Request_CharacterInfo( { character_info.animName[0] = '\0'; } - + // get the player's index player_index = ioProcessGroup->packet.packet_header.player_index; - + // add the data to the response packet ONiNet_Server_PlayerPacket_Build( ioServer, @@ -4146,9 +4146,9 @@ ONiNet_SH_Request_CharacterInfo( ONcS2C_Info_Character, (UUtUns8*)(&character_info), sizeof(ONtNet_Info_Character)); - + // make the character generate a critical update the next time through - ioServer->updateFlags[character_index] = + ioServer->updateFlags[character_index] = (ONcCharacterUpdateFlag_HitPoints | ONcCharacterUpdateFlag_Inventory | ONcCharacterUpdateFlag_Name | @@ -4169,8 +4169,8 @@ ONiNet_SH_Request_Join( UUtUns16 i; ONtNet_Request_Join *join_request; UUtUns32 request_id; - - // see if the player is already in the game + + // see if the player is already in the game player_in_game = UUcFalse; for (i = 0; i < ioServer->game_options.max_players; i++) { @@ -4186,22 +4186,22 @@ ONiNet_SH_Request_Join( break; } } - + // get a pointer to the join request join_request = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_Request_Join); - + // get a local copy of the requst_id request_id = join_request->uns32_0; - + if (ioProcessGroup->swap_it) { UUrSwap_2Byte(&request_id); } - + if (player_in_game == UUcFalse) { ONtNet_Players *player; - + // get an available player index player_index = ONiNet_Server_GetFreePlayer(ioServer); if (player_index == ioServer->game_options.max_players) @@ -4209,11 +4209,11 @@ ONiNet_SH_Request_Join( ONiNet_SS_Reject_Join(ioServer, ioProcessGroup, request_id); return; } - + // get a pointer to the player player = &ioServer->players[player_index]; UUrMemory_Clear(player, sizeof(ONtNet_Players)); - + // initialize the player player->inUse = UUcTrue; player->send_updates = UUcFalse; @@ -4230,11 +4230,11 @@ ONiNet_SH_Request_Join( UUrMemory_Clear( player->weaponACKNeeded, sizeof(UUtBool) * WPcMaxWeapons); - + // increment the number of players ioServer->num_players++; } - + // send the game info ONiNet_SS_Info_Game(ioServer, ioProcessGroup, player_index, request_id); } @@ -4246,17 +4246,17 @@ ONiNet_SH_Request_ServerInfo( ONtNet_ProcessGroup *ioProcessGroup) { ONtNet_ServerInfo server_info; - + // set the server info server_info.max_players = ioServer->game_options.max_players; server_info.num_players = ioServer->num_players; server_info.level_number = ioProcessGroup->common->level_number; - + UUrMemory_MoveFast( ioServer->server_name, server_info.server_name, ONcMaxHostNameLength); - + // add ack to packet ONiNet_Server_PlayerPacket_Build( ioServer, @@ -4275,14 +4275,14 @@ ONiNet_SH_Request_Spawn( { UUtUns16 player_index; ONtCharacter *character; - + // get the player's index player_index = ioProcessGroup->packet.packet_header.player_index; if (player_index == ONcNet_UnknownPlayer) return; - + // get a pointer to the character character = ioServer->players[player_index].character; - + // spawn the character if (character->flags & ONcCharacterFlag_Dead) { @@ -4303,27 +4303,27 @@ ONiNet_SH_Request_Quit( ONtCharacter *character; ONtNet_Request_Quit *quit_request; UUtUns32 request_id; - + // get the player's index player_index = ioProcessGroup->packet.packet_header.player_index; if (player_index == ONcNet_UnknownPlayer) return; - + // get a pointer to the quit request quit_request = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_Request_Quit); - + // get the request id request_id = quit_request->uns32_0; if (ioProcessGroup->swap_it) { UUrSwap_4Byte(&request_id); } - + // get a pointer to the character character = ioServer->players[player_index].character; - + // the character is leaving character->updateFlags |= ONcCharacterUpdateFlag_Gone; - + // send acknowledgement ONiNet_SS_ACK_Quit(ioServer, ioProcessGroup, player_index, request_id); } @@ -4335,16 +4335,16 @@ ONiNet_SH_Request_WeaponInfo( ONtNet_ProcessGroup *ioProcessGroup) { ONtNet_Request_WeaponInfo *weapon_info_request; - + // get a pointer to the weapon info request weapon_info_request = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_Request_WeaponInfo); - + // get the weapon's index if (ioProcessGroup->swap_it) { UUrSwap_2Byte(&weapon_info_request->uns16_0); } - + // set the update flags for the weapon WPrNetPropogate(weapon_info_request->uns16_0); } @@ -4356,19 +4356,19 @@ ONiNet_SH_Update_Character( { ONtNet_Update_Character *character_update; UUtUns16 player_index; - + // get a pointer to the character update character_update = (ONtNet_Update_Character*)ioProcessGroup->data; ONiNet_DataAdvance(ioProcessGroup, (UUtUns16)ONcNet_Update_Character_MinSize); - + // get the player's index player_index = ioProcessGroup->packet.packet_header.player_index; - if (player_index == ONcNet_UnknownPlayer) + if (player_index == ONcNet_UnknownPlayer) { ONiNet_Skip_Update(ioProcessGroup, character_update); return; } - + // swap the header data if (ioProcessGroup->swap_it) { @@ -4376,7 +4376,7 @@ ONiNet_SH_Update_Character( UUrSwap_2Byte(&character_update->hdr.animFrame); MUmPoint3D_Swap(character_update->hdr.position); } - + // process the character update if (ONgNet_Authoritative_Server == UUcTrue) { @@ -4397,23 +4397,23 @@ ONiNet_SH_Update_Critical( ONtNet_Critical_Update *critical_update; ONtCharacter *character; UUtUns16 character_index; - + // get a pointer to the critical update critical_update = (ONtNet_Critical_Update*)ioProcessGroup->data; ONiNet_DataAdvance(ioProcessGroup, (UUtUns16)ONcNet_CUpdate_MinSize); - + // swap the standard data if (ioProcessGroup->swap_it) { UUrSwap_2Byte(&critical_update->hdr.character_index); } - + // get a local copy of the data character_index = critical_update->hdr.character_index; - + // get a pointer to the character character = &ioProcessGroup->common->character_list[character_index]; - + // if the character isn't in use, skip the critical update if (!(character->flags & ONcCharacterFlag_InUse)) { @@ -4424,7 +4424,7 @@ ONiNet_SH_Update_Critical( // process the critical update ONiNet_Process_Critical_Update(ioProcessGroup, critical_update, NULL); - + // acknowledge the critical update ONiNet_SS_ACK_Critical_Update(ioServer, ioProcessGroup); } @@ -4443,45 +4443,45 @@ ONiNet_Server_IsLegalPacket( UUtUns16 player_index; const ONtNet_Packet *packet; UUtUns16 packet_length; - + // get the packet and packet_length from ioProcessGroup packet = &ioProcessGroup->packet; packet_length = ioProcessGroup->packet_length; - + // make sure the packet version is supported if (packet->packet_header.packet_version != ONcNet_VersionNumber) { return UUcFalse; } - + // get the player index of the sender player_index = packet->packet_header.player_index; if (player_index == ONcNet_UnknownPlayer) { return UUcTrue; } - + // check the packet's number against the previously received packet if (ioServer->players[player_index].previous_packet_number >= packet->packet_header.packet_number) { return UUcFalse; } - + // make sure the packet sizes are okay if (packet->packet_header.packet_length > packet_length) { return UUcFalse; } - + // save the packet number ioServer->players[player_index].previous_packet_number = packet->packet_header.packet_number; - + // save the packet time ioServer->players[player_index].previous_packet_time = ioProcessGroup->common->game_time; - + return UUcTrue; } @@ -4494,19 +4494,19 @@ ONrNet_Server_ProcessPacket( UUtBool is_legal_packet; ONtNet_DataType prev_datatype; UUtUns16 i; - + // swap the packet header // NOTE: byte-swapping is only done on incoming data if it needs to be swapped. // All outgoing data is written in the processors native endian format ioProcessGroup->swap_it = ONiNet_Swap_PacketHeader(&ioProcessGroup->packet); - + // make sure the packet can be used is_legal_packet = ONiNet_Server_IsLegalPacket( ioServer, ioProcessGroup); if (is_legal_packet == UUcFalse) return; - + // set the pointers ioProcessGroup->datatype_info = (ONtNet_DataTypeInfo*)ioProcessGroup->packet.packet_data; @@ -4515,11 +4515,11 @@ ONrNet_Server_ProcessPacket( UUrSwap_2Byte(&ioProcessGroup->datatype_info->num_datatypes); UUrSwap_2Byte(&ioProcessGroup->datatype_info->datatypes_offset); } - + ioProcessGroup->data = ioProcessGroup->packet.packet_data + sizeof(ONtNet_DataTypeInfo); - + ioProcessGroup->datatypes = ioProcessGroup->packet.packet_data + ioProcessGroup->datatype_info->datatypes_offset; @@ -4529,10 +4529,10 @@ ONrNet_Server_ProcessPacket( for (i = 0; i < ioProcessGroup->datatype_info->num_datatypes; i++) { ONtNet_DataType datatype; - + // get the ONtNet_DataType datatype = ioProcessGroup->datatypes[i]; - + UUmAssert(((UUtUns32)ioProcessGroup->data & 3) == 0); switch (datatype) @@ -4551,7 +4551,7 @@ UUmAssert(((UUtUns32)ioProcessGroup->data & 3) == 0); case ONcC2S_Request_ServerInfo: ONiNet_SH_Request_ServerInfo(ioServer, ioProcessGroup); break; default: UUmAssert(!"unknown data type"); break; } - + prev_datatype = datatype; } } @@ -4565,19 +4565,19 @@ ONrNet_Server_FS_ProcessPacket( UUtBool is_legal_packet; ONtNet_DataType prev_datatype; UUtUns16 i; - + // swap the packet header // NOTE: byte-swapping is only done on incoming data if it needs to be swapped. // All outgoing data is written in the processors native endian format ioProcessGroup->swap_it = ONiNet_Swap_PacketHeader(&ioProcessGroup->packet); - + // make sure the packet can be used is_legal_packet = ONiNet_Server_IsLegalPacket( ioServer, ioProcessGroup); if (is_legal_packet == UUcFalse) return; - + // set the pointers ioProcessGroup->datatype_info = (ONtNet_DataTypeInfo*)ioProcessGroup->packet.packet_data; @@ -4586,11 +4586,11 @@ ONrNet_Server_FS_ProcessPacket( UUrSwap_2Byte(&ioProcessGroup->datatype_info->num_datatypes); UUrSwap_2Byte(&ioProcessGroup->datatype_info->datatypes_offset); } - + ioProcessGroup->data = ioProcessGroup->packet.packet_data + sizeof(ONtNet_DataTypeInfo); - + ioProcessGroup->datatypes = ioProcessGroup->packet.packet_data + ioProcessGroup->datatype_info->datatypes_offset; @@ -4600,10 +4600,10 @@ ONrNet_Server_FS_ProcessPacket( for (i = 0; i < ioProcessGroup->datatype_info->num_datatypes; i++) { ONtNet_DataType datatype; - + // get the ONtNet_DataType datatype = ioProcessGroup->datatypes[i]; - + UUmAssert(((UUtUns32)ioProcessGroup->data & 3) == 0); switch (datatype) @@ -4611,7 +4611,7 @@ UUmAssert(((UUtUns32)ioProcessGroup->data & 3) == 0); case ONcC2S_Request_ServerInfo: ONiNet_SH_Request_ServerInfo(ioServer, ioProcessGroup); break; default: UUmAssert(!"unknown data type"); break; } - + prev_datatype = datatype; } } @@ -4628,32 +4628,32 @@ ONrNet_FindServer_Broadcast( { ONtNet_PacketData packet_data; UUtUns16 packet_length; - + // initialize the packet data ONrNet_Packet_Init(&packet_data); - + // add the request ONiNet_Packet_AddData( &packet_data, ONcC2S_Request_ServerInfo, NULL, 0); - + // build the packet packet_length = ONiNet_Packet_Build(&packet_data); - + // initialize the packet header packet_data.packet.packet_header.packet_swap = ONcNet_SwapIt; packet_data.packet.packet_header.packet_number = ioFindServer->packet_number++; packet_data.packet.packet_header.packet_version = ONcNet_VersionNumber; packet_data.packet.packet_header.player_index = ONcNet_UnknownPlayer; packet_data.packet.packet_header.packet_length = packet_length; - + // broadcast it NMrNetContext_Broadcast( ioFindServer->findserver_context, ONcNet_FindServerPort, - (UUtUns8*)&packet_data.packet, + (UUtUns8*)&packet_data.packet, packet_data.packet.packet_header.packet_length); } @@ -4664,17 +4664,17 @@ ONiNet_FSH_ServerInfo( ONtNet_ProcessGroup *ioProcessGroup) { ONtNet_ServerInfo *server_info; - + // get the server info server_info = ONmNet_GetDataPtr(ioProcessGroup, ONtNet_ServerInfo); - + if (ioProcessGroup->swap_it) { UUrSwap_2Byte(&server_info->max_players); UUrSwap_2Byte(&server_info->num_players); UUrSwap_2Byte(&server_info->level_number); } - + // call the callback ioFindServer->callback(server_info, &ioProcessGroup->from, ioFindServer->user_param); } @@ -4687,23 +4687,23 @@ ONiNet_FindServer_IsLegalPacket( { const ONtNet_Packet *packet; UUtUns16 packet_length; - + // get the packet and packet_length from ioProcessGroup packet = &ioProcessGroup->packet; packet_length = ioProcessGroup->packet_length; - + // make sure the packet version is supported if (packet->packet_header.packet_version != ONcNet_VersionNumber) { return UUcFalse; } - + // make sure the packet sizes are okay if (packet->packet_header.packet_length > packet_length) { return UUcFalse; } - + return UUcTrue; } @@ -4716,19 +4716,19 @@ ONrNet_FindServer_ProcessPacket( UUtBool is_legal_packet; ONtNet_DataType prev_datatype; UUtUns16 i; - + // swap the packet header // NOTE: byte-swapping is only done on incoming data if it needs to be swapped. // All outgoing data is written in the processors native endian format ioProcessGroup->swap_it = ONiNet_Swap_PacketHeader(&ioProcessGroup->packet); - + // make sure the packet can be used is_legal_packet = ONiNet_FindServer_IsLegalPacket( ioFindServer, ioProcessGroup); if (is_legal_packet == UUcFalse) return; - + // set the pointers ioProcessGroup->datatype_info = (ONtNet_DataTypeInfo*)ioProcessGroup->packet.packet_data; @@ -4737,11 +4737,11 @@ ONrNet_FindServer_ProcessPacket( UUrSwap_2Byte(&ioProcessGroup->datatype_info->num_datatypes); UUrSwap_2Byte(&ioProcessGroup->datatype_info->datatypes_offset); } - + ioProcessGroup->data = ioProcessGroup->packet.packet_data + sizeof(ONtNet_DataTypeInfo); - + ioProcessGroup->datatypes = ioProcessGroup->packet.packet_data + ioProcessGroup->datatype_info->datatypes_offset; @@ -4751,10 +4751,10 @@ ONrNet_FindServer_ProcessPacket( for (i = 0; i < ioProcessGroup->datatype_info->num_datatypes; i++) { ONtNet_DataType datatype; - + // get the ONtNet_DataType datatype = ioProcessGroup->datatypes[i]; - + UUmAssert(((UUtUns32)ioProcessGroup->data & 3) == 0); switch (datatype) @@ -4763,7 +4763,7 @@ UUmAssert(((UUtUns32)ioProcessGroup->data & 3) == 0); case ONcC2S_Request_ServerInfo: ONiNet_DataAdvance(ioProcessGroup, sizeof(ONtNet_ServerInfo)); break; default: UUmAssert(!"unknown data type"); break; } - + prev_datatype = datatype; } } diff --git a/OniProj/OniGameSource/Oni_Networking/Oni_Net_Support.h b/OniProj/OniGameSource/Oni_Networking/Oni_Net_Support.h index 22d8dc1..3654d98 100644 --- a/OniProj/OniGameSource/Oni_Networking/Oni_Net_Support.h +++ b/OniProj/OniGameSource/Oni_Networking/Oni_Net_Support.h @@ -16,62 +16,62 @@ void ONrNet_Packet_Init( ONtNet_PacketData *ioPacketData); - + // ---------------------------------------------------------------------- void ONrNet_Client_Packet_Send( ONtNet_Client *ioClient); - + // ---------------------------------------------------------------------- void ONrNet_CS_Heartbeat( ONtNet_Client *ioClient, ONtNet_ProcessGroup *ioProcessGroup); - + void ONrNet_CS_Request_CharacterCreate( ONtNet_Client *ioClient, ONtNet_ProcessGroup *ioProcessGroup, UUtUns32 inRequestID); - + void ONrNet_CS_Request_Join( ONtNet_Client *ioClient, ONtNet_ProcessGroup *ioProcessGroup, UUtUns32 inRequestID); - + void ONrNet_CS_Request_Spawn( ONtNet_Client *ioClient, ONtNet_ProcessGroup *ioProcessGroup); - + void ONrNet_CS_Request_Quit( ONtNet_Client *ioClient, ONtNet_ProcessGroup *ioProcessGroup, UUtUns32 inRequestID); - + void ONrNet_CS_Update_Character( ONtNet_Client *ioClient, ONtNet_ProcessGroup *ioProcessGroup); - + void ONrNet_CS_Update_Critical( ONtNet_Client *ioClient, ONtNet_ProcessGroup *ioProcessGroup); - + void ONrNet_Client_ProcessPacket( ONtNet_Client *ioClient, ONtNet_ProcessGroup *ioProcessGroup); - + // ---------------------------------------------------------------------- void ONrNet_Server_PlayerPacket_Send( ONtNet_Server *ioServer, UUtUns16 inPlayerIndex); - + void ONrNet_Server_MassPacket_Clear( ONtNet_Server *ioServer); @@ -84,7 +84,7 @@ void ONrNet_Server_MassPacket_SendToAddress( ONtNet_Server *ioServer, NMtNetAddress *inToAddress); - + // ---------------------------------------------------------------------- void ONrNet_SS_Update_Character( @@ -98,7 +98,7 @@ ONrNet_SS_Update_Critical( ONtNet_ProcessGroup *ioProcessGroup, ONtCharacter *inCharacter, UUtUns32 *outUpdateBits); - + void ONrNet_SS_Update_Critical_Force( ONtNet_Server *ioServer, @@ -106,12 +106,12 @@ ONrNet_SS_Update_Critical_Force( ONtCharacter *inCharacter, UUtUns32 inUpdateFlags, UUtUns16 inPlayerIndex); - + void ONrNet_SS_Update_Weapons( ONtNet_Server *ioServer, ONtNet_ProcessGroup *ioProcessGroup); - + void ONrNet_Server_ProcessPacket( ONtNet_Server *ioServer, @@ -133,4 +133,4 @@ ONrNet_FindServer_ProcessPacket( ONtNet_ProcessGroup *ioProcessGroup); // ====================================================================== -#endif /* ONI_NET_SUPPORT_H */ \ No newline at end of file +#endif /* ONI_NET_SUPPORT_H */ diff --git a/OniProj/OniGameSource/Oni_Networking/Oni_Networking.c b/OniProj/OniGameSource/Oni_Networking/Oni_Networking.c index 0c1f133..f8e253a 100644 --- a/OniProj/OniGameSource/Oni_Networking/Oni_Networking.c +++ b/OniProj/OniGameSource/Oni_Networking/Oni_Networking.c @@ -45,11 +45,11 @@ typedef struct ONtNet_Performance TStTextContext *text_context; M3tTextureMap *texture_map; UUtRect bounds; - + // client UUtUns32 client_packets_sent; UUtUns32 client_bytes_sent; - + // server UUtUns32 raw_packets_sent; UUtUns32 raw_bytes_sent; @@ -59,9 +59,9 @@ typedef struct ONtNet_Performance UUtUns32 mass_packets_sent; UUtUns32 mass_bytes_sent; - + } ONtNet_Performance; - + // ====================================================================== // globals // ====================================================================== @@ -99,7 +99,7 @@ ONiDebugLevel_Callback( { char *levels[ONcNumDebugLevels] = { "none", "major", "medium", "minor" }; char *command_format = "%s [none|major|medium|minor]"; - + if (inParameterListLength == 0) { // display the current value @@ -108,7 +108,7 @@ ONiDebugLevel_Callback( else { UUtUns16 i; - + // set a new value for (i = 0; i < ONcNumDebugLevels; i++) { @@ -119,7 +119,7 @@ ONiDebugLevel_Callback( } } } - + return UUcError_None; } @@ -134,7 +134,7 @@ ONiNet_Client_Start_Callback( SLtParameter_Actual *ioReturnValue) { UUtError error; - + // start the client error = ONrNet_Client_Start(ONcNet_DefaultClientPort); if (error == UUcError_None) @@ -145,7 +145,7 @@ ONiNet_Client_Start_Callback( { COrConsole_Printf("Unable to start client."); } - + return UUcError_None; } @@ -160,7 +160,7 @@ ONiNet_Client_Stop_Callback( SLtParameter_Actual *ioReturnValue) { UUtError error; - + // stop the client error = ONrNet_Client_Stop(); if (error == UUcError_None) @@ -187,15 +187,15 @@ ONiNet_Server_Start_Callback( UUtError error; UUtInt32 max_num_players; ONtNetGameOptions options; - + // set the maximum number of players max_num_players = ONcNet_DefaultMaxNumPlayers; - + // check to see if the user wants to set a different maximum number of players if (inParameterListLength == 1) { max_num_players = inParameterList[0].val.i; - + if (max_num_players > ONcNet_MaxNumPlayers) { COrConsole_Printf( @@ -209,7 +209,7 @@ ONiNet_Server_Start_Callback( return UUcError_None; } } - + // start the server options.max_players = (UUtUns16)max_num_players; options.game_parameters = ONcNetGameParam_None; @@ -244,7 +244,7 @@ ONiNet_Server_Stop_Callback( SLtParameter_Actual *ioReturnValue) { UUtError error; - + // stop the server error = ONrNet_Server_Stop(); if (error == UUcError_None) @@ -270,15 +270,15 @@ ONiNet_Join_Callback( { UUtError error; char *character_class_name; - + // process the character class if it was supplied if (inParameterListLength == 2) { ONtCharacterClass *temp; - + // set the class name character_class_name = inParameterList[1].val.str; - + // get a pointer to the character class error = TMrInstance_GetDataPtr( @@ -298,13 +298,13 @@ ONiNet_Join_Callback( // set the character class name character_class_name = "konoko_generic"; } - + // start the client if it isn't already running if (ONgNet_Client == NULL) { ONiNet_Client_Start_Callback(inErrorContext, 0, NULL, NULL, NULL, NULL); } - + // join the specified host error = ONrNet_Client_Join( @@ -321,7 +321,7 @@ ONiNet_Join_Callback( { COrConsole_Printf("Unable to connect to desired address."); } - + return UUcError_None; } @@ -332,23 +332,23 @@ ONrNet_LevelLoad( UUtUns16 inLevelNumber) { UUtError error; - + // unload the current level if (ONrLevel_GetCurrentLevel() != 0) { ONrLevel_Unload(); } - + // load the new level error = ONrLevel_Load(inLevelNumber, UUcTrue); UUmError_ReturnOnError(error); - + // reset the charaters ONrGameState_ResetCharacters(); // save the level number ioCommon->level_number = inLevelNumber; - + return UUcError_None; } @@ -372,16 +372,16 @@ ONiNet_Common_Initialize( ONtNet_Common *ioNetCommon) { UUmAssert(ioNetCommon); - + // clear the common structure UUrMemory_Clear(ioNetCommon, sizeof(ONtNet_Common)); - + // get a pointer to the character list ioNetCommon->character_list = ONrGameState_GetCharacterList(); - + // set the game time ioNetCommon->game_time = UUrMachineTime_Sixtieths(); - + return UUcError_None; } @@ -406,14 +406,14 @@ ONrNet_Client_Request_Add( UUtUns32 inGameTime) { UUtUns16 i; - + for (i = 0; i < ONcNet_MaxClientRequests; i++) { ONtNet_Request *request; - + // get a local pointer to the request request = &ioClient->requests[i]; - + if (request->request_type == ONcNet_Request_None) { request->request_type = inRequestType; @@ -423,7 +423,7 @@ ONrNet_Client_Request_Add( break; } } - + if (i == ONcNet_MaxClientRequests) UUmAssert(!"No requests available"); } @@ -443,14 +443,14 @@ ONrNet_Client_Request_ResponseReceived( UUtUns32 inRequestID) { UUtUns16 i; - + for (i = 0; i < ONcNet_MaxClientRequests; i++) { ONtNet_Request *request; - + // get a local pointer to the request request = &ioClient->requests[i]; - + if (request->request_id == inRequestID) { // this request is no longer being used @@ -468,13 +468,13 @@ ONiNet_Client_Request_Update( { UUtUns16 i; UUtBool failed_request; - + failed_request = 0; - + for (i = 0; i < ONcNet_MaxClientRequests; i++) { ONtNet_Request *request; - + // get a local pointer to the request request = &ioClient->requests[i]; @@ -485,44 +485,44 @@ ONiNet_Client_Request_Update( // update the request time and count request->request_time = ioProcessGroup->common->game_time + ONcNet_Request_Delta; request->request_counter--; - + // when the counter reaches 0, stop processing this packet if (request->request_counter == 0) { // call the callback ONiNet_Client_Request_Failed(ioClient); - + // note the failed request failed_request = request->request_type; - + // this request is no longer being used request->request_type = ONcNet_Request_None; - + // exit the for loop break; } - + // make a request on behalf of this counter switch (request->request_type) { case ONcNet_Request_Character_Create: ONrNet_CS_Request_CharacterCreate(ioClient, ioProcessGroup, request->request_id); break; - + case ONcNet_Request_Info_Server: break; - + case ONcNet_Request_Join: ONrNet_CS_Request_Join(ioClient, ioProcessGroup, request->request_id); break; - + case ONcNet_Request_Quit: ONrNet_CS_Request_Quit(ioClient, ioProcessGroup, request->request_id); break; } } } - + return failed_request; } @@ -539,7 +539,7 @@ ONiNet_Client_Heartbeat( { // don't update if there is no character if (ioClient->character == NULL) { return UUcTrue; } - + // make sure the server is still talking to the client if (ONgNet_No_Disconnect == UUcFalse) { @@ -547,23 +547,23 @@ ONiNet_Client_Heartbeat( ioProcessGroup->common->game_time) { COrConsole_Printf("Client: host not responding, disconnecting from host"); - + // server hasn't sent a message in the required amount of time, // disconnect from the server ONrNet_Client_Stop(); return UUcFalse; } } - + // send a heartbeat to the server if ((ioClient->heartbeat_time + ONcNet_HeartbeatDelta) < ioProcessGroup->common->game_time) { ioClient->heartbeat_time = ioProcessGroup->common->game_time + ONcNet_HeartbeatDelta; - + ONrNet_CS_Heartbeat(ioClient, ioProcessGroup); } - + return UUcTrue; } @@ -574,17 +574,17 @@ ONiNet_Client_Initialize( UUtUns16 inClientPortNumber) { UUtError error; - + UUmAssert(ioClient); - + // clear the client structure UUrMemory_Clear(ioClient, sizeof(ONtNet_Client)); - + // initialize some variables ioClient->player_index = ONcNet_UnknownPlayer; ioClient->packet_number = 1; ONrNet_Packet_Init(&ioClient->packet_data); - + // create a client context error = NMrNetContext_New( @@ -593,7 +593,7 @@ ONiNet_Client_Initialize( NMcFlag_None, &ioClient->client_context); UUmError_ReturnOnErrorMsg(error, "Unable to create client context."); - + return UUcError_None; } @@ -608,14 +608,14 @@ ONrNet_Client_JoinStage_Advance( case ONcNet_JoinStage_GameInfo: // advance to the next join stage ioClient->join_stage = ONcNet_JoinStage_CreateCharacter; - + // request that the character be created ONrNet_Client_Request_Add( ioClient, ONcNet_Request_Character_Create, ioCommon->game_time); break; - + case ONcNet_JoinStage_CreateCharacter: // the character has been created, joining has completed ioClient->join_stage = ONcNet_JoinStage_None; @@ -630,13 +630,13 @@ ONrNet_Client_Rejected( { // stop the client ONrNet_Client_Stop(); - + // inform the user COrConsole_Printf("Unable to connect with host"); - + // unload the level ONrLevel_Unload(); - + // run the main menu ONgRunMainMenu = UUcTrue; } @@ -647,7 +647,7 @@ ONiNet_Client_Spawn( ONtNet_Client *ioClient, ONtNet_ProcessGroup *ioProcessGroup) { - // if the client's character exists and it is dead and the + // if the client's character exists and it is dead and the // minimum amount of time it can be dead has passed and the character // has pushed the fire/kick key, then send a respawn request if ((ioClient->character != NULL) && @@ -666,17 +666,17 @@ ONiNet_Client_Terminate( ONtNet_Client *ioClient) { UUtError error; - + UUmAssert(ioClient); - + // stop the client error = NMrNetContext_CloseProtocol(ioClient->client_context); UUmError_ReturnOnError(error); - + // delete the client context NMrNetContext_Delete(&ioClient->client_context); ioClient->client_context = NULL; - + return UUcError_None; } @@ -690,18 +690,18 @@ ONiNet_Client_Update_Receive( if (ioClient == NULL) return; UUmAssert(ioCommon); - + // ------------------------------ // update the network context // ------------------------------ NMrNetContext_Update(ioClient->client_context); - + // ------------------------------ // process the incoming packets // ------------------------------ // set up the process group process_group.common = ioCommon; - + // process all available packets while ( NMrNetContext_ReadData( @@ -726,7 +726,7 @@ ONiNet_Client_Update_Send( if (ioClient == NULL) return; UUmAssert(ioCommon); - + // ------------------------------ // only send when it's time // ------------------------------ @@ -735,7 +735,7 @@ ONiNet_Client_Update_Send( return; } ioClient->client_send_time = ioCommon->game_time; - + // ------------------------------ // update the requests // ------------------------------ @@ -751,20 +751,20 @@ ONiNet_Client_Update_Send( ONrNet_Client_Stop(); return; } - + // ------------------------------ // Build the update packet // ------------------------------ if (ONrNet_IsServer() == UUcFalse) { ONrNet_CS_Update_Character(ioClient, &process_group); - + ONrNet_CS_Update_Critical(ioClient, &process_group); } - + ONiNet_Client_Spawn(ioClient, &process_group); if (ONiNet_Client_Heartbeat(ioClient, &process_group) == UUcFalse) { return; } - + // ------------------------------ // send the update packet // ------------------------------ @@ -786,10 +786,10 @@ ONrNet_Client_Join( char *inTeamName) { UUtError error; - + UUmAssert(ONgNet_Client); UUmAssert(inServerAddressString); - + // change the address string into a real address error = NMrNetContext_StringToAddress( @@ -798,10 +798,10 @@ ONrNet_Client_Join( inServerPortNumber, &ONgNet_Client->server_address); UUmError_ReturnOnErrorMsg(error, "Invalid ip address"); - + // put the client in join mode ONgNet_Client->join_stage = ONcNet_JoinStage_GameInfo; - + // copy the information into the client ONgNet_Client->teamNumber = 0xFFFF; UUrString_Copy( @@ -812,13 +812,13 @@ ONrNet_Client_Join( ONgNet_Client->playerName, inPlayerName, ONcMaxPlayerNameLength); - + // request join ONrNet_Client_Request_Add( ONgNet_Client, ONcNet_Request_Join, ONgNet_Common->game_time); - + return UUcError_None; } @@ -828,25 +828,25 @@ ONrNet_Client_Start( UUtUns16 inClientPortNumber) { UUmAssert(ONgNet_Client == NULL); - + // allocate memory for the common data if (ONrNet_IsServer() == UUcFalse) { ONgNet_Common = UUrMemory_Block_New(sizeof(ONtNet_Common)); UUmError_ReturnOnNull(ONgNet_Common); } - + // allocate memory for the client data ONgNet_Client = UUrMemory_Block_New(sizeof(ONtNet_Client)); UUmError_ReturnOnNull(ONgNet_Client); - + // initialize the data if (ONrNet_IsServer() == UUcFalse) { ONiNet_Common_Initialize(ONgNet_Common); } ONiNet_Client_Initialize(ONgNet_Client, inClientPortNumber); - + return UUcError_None; } @@ -857,13 +857,13 @@ ONrNet_Client_Stop( { UUtError error; UUtUns16 i; - + if (ONgNet_Client == NULL) return UUcError_None; - + // prevent multiple entries into this function if (ONgNet_Client_Stop) return UUcError_None; ONgNet_Client_Stop = UUcTrue; - + // tell the server the client is leaving ONrNet_Client_Request_Add( ONgNet_Client, @@ -874,7 +874,7 @@ ONrNet_Client_Stop( ONiNet_Client_Update_Receive(ONgNet_Client, ONgNet_Common); ONiNet_Client_Update_Send(ONgNet_Client, ONgNet_Common); } - + // terminate the client data error = ONiNet_Client_Terminate(ONgNet_Client); if (error != UUcError_None) @@ -882,11 +882,11 @@ ONrNet_Client_Stop( ONgNet_Client_Stop = UUcFalse; UUmError_ReturnOnError(error); } - + // delete the client data UUrMemory_Block_Delete(ONgNet_Client); ONgNet_Client = NULL; - + // terminate the common data if ((ONrNet_IsServer() == UUcFalse) && (ONgNet_Common)) { @@ -894,7 +894,7 @@ ONrNet_Client_Stop( UUrMemory_Block_Delete(ONgNet_Common); ONgNet_Common = NULL; } - + ONgNet_Client_Stop = UUcFalse; return UUcError_None; } @@ -913,14 +913,14 @@ ONiNet_Server_CreateAIs( { UUtUns16 i; UUtError error; - const ONtFlag *prev_flag; - + const ONtFlag *prev_flag; + // don't make more AIs than spawn points available if (inGameOptions->num_AIs > ONgLevel->spawnArray->numSpawnFlagIDs) { inGameOptions->num_AIs = ONgLevel->spawnArray->numSpawnFlagIDs; } - + // generate the AIs prev_flag = NULL; for (i = 0; i < inGameOptions->num_AIs; i++) @@ -930,22 +930,22 @@ ONiNet_Server_CreateAIs( ONtCharacter *character; UUtUns16 random_index; UUtUns16 character_id; - + // get a random character setup from the level's characterSetupArray random_index = UUmRandomRange(1, ONgLevel->characterSetupArray->numCharacterSetups - 1); setup = &ONgLevel->characterSetupArray->characterSetups[random_index]; - + // get a random flag that the character can start at ONrLevel_Flag_ID_To_Flag(ONrGameState_GetPlayerStart(), &flag); - + // create the AI error = ONrGameState_NewCharacter(NULL, setup, &flag, &character_id); if (error != UUcError_None) return error; - + character = &ioCommon->character_list[character_id]; character->teamNumber = i; } - + return UUcError_None; } @@ -957,12 +957,12 @@ ONiNet_Server_Initialize( ONtNetGameOptions *inGameOptions) { UUtError error; - + UUmAssert(ioServer); - + // clear the ioServer structure UUrMemory_Clear(ioServer, sizeof(ONtNet_Server)); - + // create the server context error = NMrNetContext_New( @@ -971,18 +971,18 @@ ONiNet_Server_Initialize( NMcFlag_None, &ioServer->server_context); UUmError_ReturnOnErrorMsg(error, "Unable to create server context"); - + // allocate memory for the players ioServer->players = (ONtNet_Players*)UUrMemory_Block_NewClear( sizeof(ONtNet_Players) * inGameOptions->max_players); UUmError_ReturnOnNull(ioServer->players); - + // init some of the vars ioServer->game_options = *inGameOptions; ioServer->packet_number = 1; ONrNet_Packet_Init(&ioServer->mass_packet_data); - + // create the server findserver context error = NMrNetContext_New( @@ -991,7 +991,7 @@ ONiNet_Server_Initialize( NMcFlag_Broadcast, &ioServer->findserver_context); UUmError_ReturnOnErrorMsg(error, "Unable to create findserver context"); - + return UUcError_None; } @@ -1001,20 +1001,20 @@ ONiNet_Server_Terminate( ONtNet_Server *ioServer) { UUtError error; - + UUmAssert(ioServer); - + // close the server context error = NMrNetContext_CloseProtocol(ioServer->server_context); UUmError_ReturnOnError(error); - + // delete the players UUrMemory_Block_Delete(ioServer->players); - + // delete the server context NMrNetContext_Delete(&ioServer->server_context); ioServer->server_context = NULL; - + return UUcError_None; } @@ -1031,7 +1031,7 @@ ONiNet_Server_UpdateAI( { const AItCharacterSetup *setup; UUtUns16 random_index; - + // ------------------------------ // spawn the AI // ------------------------------ @@ -1040,12 +1040,12 @@ ONiNet_Server_UpdateAI( // ------------------------------ // change to a random character class // ------------------------------ - + // get a random character setup from the level's characterSetupArray random_index = UUmRandomRange(1, ONgLevel->characterSetupArray->numCharacterSetups - 1); setup = &ONgLevel->characterSetupArray->characterSetups[random_index]; - - ONrCharacter_SetCharacterClass(ioCharacter, setup->characterClass); + + ONrCharacter_SetCharacterClass(ioCharacter, setup->characterClass); } } @@ -1056,10 +1056,10 @@ ONiNet_Server_Update_Receive( ONtNet_Common *ioCommon) { ONtNet_ProcessGroup process_group; - + if (ioServer == NULL) return; UUmAssert(ioCommon); - + // ------------------------------ // update the network context // ------------------------------ @@ -1083,7 +1083,7 @@ ONiNet_Server_Update_Receive( // process the packet ONrNet_Server_ProcessPacket(ioServer, &process_group); } - + // process all available findserver packets while ( NMrNetContext_ReadData( @@ -1107,10 +1107,10 @@ ONiNet_Server_Update_Send( ONtCharacter *character; UUtUns16 i; UUtUns16 j; - + if (ioServer == NULL) return; UUmAssert(ioCommon); - + // ------------------------------ // only send when it's time // ------------------------------ @@ -1135,7 +1135,7 @@ ONiNet_Server_Update_Send( { continue; } - + // if this player needs to ack an update and it hasn't been heard from // in the designated amount of time, then it is gone. if ((ioServer->players[i].previous_packet_time + ONcNet_DelinquentDelta) < ioCommon->game_time) @@ -1144,41 +1144,41 @@ ONiNet_Server_Update_Send( } } } - + // ------------------------------ // Build the update packet // ------------------------------ // update the weapons ONrNet_SS_Update_Weapons(ioServer, &process_group); - + // go through the characters and build the update packet for (i = 0; i < ONrGameState_GetNumCharacters(); i++) { UUtUns32 updateFlags; UUtBool update_forced; UUtUns16 owning_player_index; - + // get a pointer to the character character = &ioCommon->character_list[i]; - + update_forced = UUcFalse; owning_player_index = ONcNet_UnknownPlayer; - + // if the character is active, add to update list if (!(character->flags & ONcCharacterFlag_InUse)) continue; - + ONrNet_SS_Update_Character( ioServer, &process_group, character); - + ONrNet_SS_Update_Critical( ioServer, &process_group, character, &updateFlags); - + // if updateFlags == ONcCharacterUpdateFlag_None then no critical // update for the player was added by ONrNet_SS_Update_Critical. // If it did change then keep the old critical update flags for the @@ -1190,13 +1190,13 @@ ONiNet_Server_Update_Send( ioServer->updateFlags[i] |= updateFlags; update_forced = UUcTrue; } - + // set the need ACK field for the players for (j = 0; j < ioServer->game_options.max_players; j++) { if (ioServer->players[j].inUse == UUcFalse) continue; if (ioServer->players[j].character == character) owning_player_index = j; - + if (updateFlags != ONcCharacterUpdateFlag_None) { ioServer->players[j].updateACKNeeded[i] = UUcTrue; @@ -1209,11 +1209,11 @@ ONiNet_Server_Update_Send( character, ioServer->updateFlags[i], j); - + update_forced = UUcTrue; } } - + // the Gone update flag is set when the player isn't responding. Delete the // character and make the player is no longer in use if ((ioServer->updateFlags[i] & ONcCharacterUpdateFlag_Gone) && @@ -1230,28 +1230,28 @@ ONiNet_Server_Update_Send( { ioServer->updateFlags[i] = ONcCharacterUpdateFlag_None; } - + // do any special processing for AIs if (character->charType != ONcChar_AI) { ONiNet_Server_UpdateAI(ioServer, &process_group, character); } } - + // ------------------------------ // send the outgoing packet // ------------------------------ // initialize the mass packet ONrNet_Server_MassPacket_PrepareForSend(ioServer); - - // go through all the players + + // go through all the players for (i = 0; i < ioServer->game_options.max_players; i++) { if (ioServer->players[i].inUse == UUcFalse) continue; // send the info packet ONrNet_Server_PlayerPacket_Send(ioServer, i); - + // send the update packet if (ioServer->players[i].send_updates) { @@ -1260,7 +1260,7 @@ ONiNet_Server_Update_Send( &ioServer->players[i].player_address); } } - + // clear the mass packet ONrNet_Server_MassPacket_Clear(ioServer); } @@ -1277,7 +1277,7 @@ ONrNet_Server_GetAddress( { // make sure the host is initialized if (ONgNet_Server == NULL) return NULL; - + return NMrNetContext_GetAddress(ONgNet_Server->server_context); } @@ -1290,36 +1290,36 @@ ONrNet_Server_Start( UUtUns16 inLevelNumber) { UUtError error; - + UUmAssert(ONgNet_Common == NULL); UUmAssert(ONgNet_Server == NULL); - + // allocate the common data ONgNet_Common = UUrMemory_Block_New(sizeof(ONtNet_Common)); UUmError_ReturnOnNull(ONgNet_Common); - + // allocate the server data ONgNet_Server = UUrMemory_Block_New(sizeof(ONtNet_Server)); UUmError_ReturnOnNull(ONgNet_Server); - + // initialize the common data error = ONiNet_Common_Initialize(ONgNet_Common); UUmError_ReturnOnError(error); - + // initialize the server error = ONiNet_Server_Initialize(ONgNet_Server, inServerPortNumber, inGameOptions); UUmError_ReturnOnError(error); - + UUrMemory_MoveFast(inHostName, ONgNet_Server->server_name, ONcMaxHostNameLength); - + // load the level error = ONrNet_LevelLoad(ONgNet_Common, inLevelNumber); UUmError_ReturnOnError(error); - + // create the AIs error = ONiNet_Server_CreateAIs(ONgNet_Server, ONgNet_Common, inGameOptions); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1329,13 +1329,13 @@ ONrNet_Server_Stop( void) { UUtError error; - + if (ONgNet_Server == NULL) return UUcError_None; - + // terminate the server data error = ONiNet_Server_Terminate(ONgNet_Server); UUmError_ReturnOnError(error); - + // delete the server memory UUrMemory_Block_Delete(ONgNet_Server); ONgNet_Server = NULL; @@ -1344,7 +1344,7 @@ ONrNet_Server_Stop( ONiNet_Common_Terminate(ONgNet_Common); UUrMemory_Block_Delete(ONgNet_Common); ONgNet_Common = NULL; - + return error; } @@ -1360,18 +1360,18 @@ ONrNet_FindServers_Start( UUtUns32 inUserParam) { UUtError error; - + UUmAssert(ONgNet_FindServer == NULL); - + // allocate the findserver data ONgNet_FindServer = UUrMemory_Block_New(sizeof(ONtNet_FindServer)); UUmError_ReturnOnNull(ONgNet_FindServer); - + // initialize UUrMemory_Clear(ONgNet_FindServer, sizeof(ONtNet_FindServer)); ONgNet_FindServer->callback = inFS_Callback; ONgNet_FindServer->user_param = inUserParam; - + // create the context error = NMrNetContext_New( @@ -1380,7 +1380,7 @@ ONrNet_FindServers_Start( NMcFlag_Broadcast, &ONgNet_FindServer->findserver_context); UUmError_ReturnOnErrorMsg(error, "Unable to create findserver context."); - + return UUcError_None; } @@ -1390,22 +1390,22 @@ ONrNet_FindServers_Stop( void) { UUtError error; - + if (ONgNet_FindServer) { // close the findserver context error = NMrNetContext_CloseProtocol(ONgNet_FindServer->findserver_context); UUmError_ReturnOnError(error); - + // delete the findserver network context NMrNetContext_Delete(&ONgNet_FindServer->findserver_context); ONgNet_FindServer->findserver_context = NULL; - + // delete ONgNet_FindServer UUrMemory_Block_Delete(ONgNet_FindServer); ONgNet_FindServer = NULL; } - + return UUcError_None; } @@ -1416,21 +1416,21 @@ ONrNet_FindServers_Update( { UUtUns32 game_time; ONtNet_ProcessGroup process_group; - + UUmAssert(ONgNet_FindServer); - + game_time = UUrMachineTime_Sixtieths(); - + // ------------------------------ // broadcast the server request // ------------------------------ if (ONgNet_FindServer->broadcast_time < game_time) { ONgNet_FindServer->broadcast_time = game_time + ONcNet_FindServer_Broadcast_Interval; - + ONrNet_FindServer_Broadcast(ONgNet_FindServer); } - + // ------------------------------ // update the networking // ------------------------------ @@ -1468,24 +1468,24 @@ ONiNet_Performance_Initialize( UUtError error; TStFontFamily *fontFamily; IMtPixelType pixel_type; - + UUtUns16 width = 256; UUtUns16 height = 256; - + // set defaults ONgNet_Performance.text_context = NULL; ONgNet_Performance.texture_map = NULL; - + ONgNet_Performance.dest[0].x = 640.0f - (float)width; ONgNet_Performance.dest[0].y = 480.0f - (float)height; ONgNet_Performance.dest[0].z = -1e5f; ONgNet_Performance.dest[0].invW = 10.0f; - + ONgNet_Performance.dest[1].x = 639.0f; ONgNet_Performance.dest[1].y = 479.0f; ONgNet_Performance.dest[1].z = -1e5f; ONgNet_Performance.dest[1].invW = 10.0f; - + ONgNet_Performance.uv[0].u = 0.0f; ONgNet_Performance.uv[0].v = 0.0f; ONgNet_Performance.uv[1].u = 1.0f; @@ -1494,15 +1494,15 @@ ONiNet_Performance_Initialize( ONgNet_Performance.uv[2].v = 1.0f; ONgNet_Performance.uv[3].u = 1.0f; ONgNet_Performance.uv[3].v = 1.0f; - + ONgNet_Performance.bounds.left = 0; ONgNet_Performance.bounds.top = 0; ONgNet_Performance.bounds.right = width; ONgNet_Performance.bounds.bottom = height; - + error = M3rDrawEngine_FindGrayscalePixelType(&pixel_type); UUmError_ReturnOnError(error); - + // create the text context if (ONgNet_Performance.text_context == NULL) { @@ -1512,7 +1512,7 @@ ONiNet_Performance_Initialize( TScFontFamily_RomanSmall, &fontFamily); UUmError_ReturnOnError(error); - + error = TSrContext_New( fontFamily, @@ -1520,11 +1520,11 @@ ONiNet_Performance_Initialize( TSc_HLeft, &ONgNet_Performance.text_context); UUmError_ReturnOnError(error); - + error = TSrContext_SetShade(ONgNet_Performance.text_context, IMcShade_White); UUmError_ReturnOnError(error); } - + // create the texture_map if (ONgNet_Performance.texture_map == NULL) { @@ -1539,7 +1539,7 @@ ONiNet_Performance_Initialize( &ONgNet_Performance.texture_map); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -1549,7 +1549,7 @@ ONiNet_Performance_Terminate( void) { ONgNet_Performance.display = UUcFalse; - + // delete the text context if (ONgNet_Performance.text_context) { @@ -1573,7 +1573,7 @@ ONiNet_Performance_Update( char player[128]; char mass[128]; static UUtBool done_once = UUcFalse; - + // update the stats if (ioClient && ((ioClient->performance_time + 60) < inGameTime)) { @@ -1593,17 +1593,17 @@ ONiNet_Performance_Update( } } } - + // update the stats ONgNet_Performance.client_packets_sent = ioClient->packets_sent; ONgNet_Performance.client_bytes_sent = ioClient->bytes_sent; ioClient->packets_sent = 0; ioClient->bytes_sent = 0; - + ioClient->performance_time = inGameTime; ioClient->client_adjust_this_frame = !ioClient->client_adjust_this_frame; } - + if (ioServer && ((ioServer->performance_time + 60) < inGameTime)) { // adjust the send delta @@ -1622,7 +1622,7 @@ ONiNet_Performance_Update( } } } - + // update the stats ONgNet_Performance.raw_packets_sent = ioServer->raw_packets_sent; ONgNet_Performance.raw_bytes_sent = ioServer->raw_bytes_sent; @@ -1638,14 +1638,14 @@ ONiNet_Performance_Update( ONgNet_Performance.mass_bytes_sent = ioServer->mass_bytes_sent; ioServer->mass_packets_sent = 0; ioServer->mass_bytes_sent = 0; - + ioServer->performance_time = inGameTime; ioServer->server_adjust_this_frame = !ioServer->server_adjust_this_frame; } - + // only draw when the player wants to if (ONgNet_Performance.display == UUcFalse) return UUcError_None; - + // initialize the stats if ((ONgNet_Performance.text_context == NULL) || (ONgNet_Performance.texture_map == NULL)) @@ -1656,17 +1656,17 @@ ONiNet_Performance_Update( ONgNet_Performance.display = UUcFalse; } } - + // draw the stats font_height = TSrFont_GetLineHeight(TSrContext_GetFont(ONgNet_Performance.text_context, TScStyle_InUse)); M3rTextureMap_Fill_Shade( ONgNet_Performance.texture_map, IMcShade_Black, &ONgNet_Performance.bounds); - + dest.x = 4; dest.y = font_height; - + if (ioClient) { // draw the client packet stats @@ -1675,8 +1675,8 @@ ONiNet_Performance_Update( "Client: PPS %d, BPS %d", ONgNet_Performance.client_packets_sent, ONgNet_Performance.client_bytes_sent); - - error = + + error = TSrContext_DrawString( ONgNet_Performance.text_context, ONgNet_Performance.texture_map, @@ -1684,13 +1684,13 @@ ONiNet_Performance_Update( &ONgNet_Performance.bounds, &dest); UUmError_ReturnOnError(error); - + dest.y += font_height; - + // draw the client packet stats sprintf(client, "Client: Send Delta %d", ioClient->client_send_delta); - - error = + + error = TSrContext_DrawString( ONgNet_Performance.text_context, ONgNet_Performance.texture_map, @@ -1698,13 +1698,13 @@ ONiNet_Performance_Update( &ONgNet_Performance.bounds, &dest); UUmError_ReturnOnError(error); - + if (ioServer) { dest.y += font_height; } } - + if (ioServer) { // draw server raw packet stats @@ -1713,8 +1713,8 @@ ONiNet_Performance_Update( "Server: Raw PPS %d, BPS %d", ONgNet_Performance.raw_packets_sent, ONgNet_Performance.raw_bytes_sent); - - error = + + error = TSrContext_DrawString( ONgNet_Performance.text_context, ONgNet_Performance.texture_map, @@ -1722,7 +1722,7 @@ ONiNet_Performance_Update( &ONgNet_Performance.bounds, &dest); UUmError_ReturnOnError(error); - + dest.y += font_height; // draw server player packet stats @@ -1731,8 +1731,8 @@ ONiNet_Performance_Update( "Server: Player PPS %d, BPS %d", ONgNet_Performance.player_packets_sent, ONgNet_Performance.player_bytes_sent); - - error = + + error = TSrContext_DrawString( ONgNet_Performance.text_context, ONgNet_Performance.texture_map, @@ -1740,17 +1740,17 @@ ONiNet_Performance_Update( &ONgNet_Performance.bounds, &dest); UUmError_ReturnOnError(error); - + dest.y += font_height; - + // draw server mass packet stats sprintf( mass, "Server: Mass PPS %d, BPS %d", ONgNet_Performance.mass_packets_sent, ONgNet_Performance.mass_bytes_sent); - - error = + + error = TSrContext_DrawString( ONgNet_Performance.text_context, ONgNet_Performance.texture_map, @@ -1758,13 +1758,13 @@ ONiNet_Performance_Update( &ONgNet_Performance.bounds, &dest); UUmError_ReturnOnError(error); - + dest.y += font_height; // draw the client packet stats sprintf(client, "Server: Send Delta %d", ioServer->server_send_delta); - - error = + + error = TSrContext_DrawString( ONgNet_Performance.text_context, ONgNet_Performance.texture_map, @@ -1773,18 +1773,18 @@ ONiNet_Performance_Update( &dest); UUmError_ReturnOnError(error); } - + // make the texture_map draw nice if ((!done_once) && (dest.y < M3cTextureMap_MaxHeight)) { float dest_y; - + done_once = UUcTrue; - + dest.y += TSrFont_GetDescendingHeight(TSrContext_GetFont(ONgNet_Performance.text_context, TScStyle_InUse)); dest_y = (float)dest.y; - + ONgNet_Performance.dest[0].y = 480.0f - dest_y; ONgNet_Performance.uv[0].u = 0.0f; @@ -1796,7 +1796,7 @@ ONiNet_Performance_Update( ONgNet_Performance.uv[3].u = 1.0f; ONgNet_Performance.uv[3].v = dest_y / ONgNet_Performance.texture_map->height; } - + return UUcError_None; } @@ -1806,26 +1806,26 @@ ONrNet_Performance_Display( void) { if (ONgNet_Performance.display == UUcFalse) return; - + M3rDraw_State_Push(); - + M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor, IMcShade_White); M3rDraw_State_SetInt(M3cDrawStateIntType_Alpha, M3cMaxAlpha); - + M3rDraw_State_SetPtr( M3cDrawStatePtrType_BaseTextureMap, ONgNet_Performance.texture_map); - + M3rDraw_State_SetInt( M3cDrawStateIntType_Interpolation, M3cDrawState_Interpolation_None); - + M3rDraw_State_Commit(); - + M3rDraw_Sprite( ONgNet_Performance.dest, ONgNet_Performance.uv); - + M3rDraw_State_Pop(); } @@ -1840,18 +1840,18 @@ ONrNet_Initialize( void) { UUtError error; - + UUmAssert(ONgNet_Common == NULL); UUmAssert(ONgNet_Client == NULL); UUmAssert(ONgNet_Server == NULL); - + // install exit routine UUrAtExit_Register(ONiNet_Terminate_AtExit); - + // initialize the network manager error = NMrInitialize(); UUmError_ReturnOnError(error); - + // initialize the data ONgNet_Common = NULL; ONgNet_Client = NULL; @@ -1859,7 +1859,7 @@ ONrNet_Initialize( ONgNet_FindServer = NULL; ONgNet_Level_Callback = NULL; ONgNet_SpawnDelta = 3 * 60; // 3 seconds in ticks - + // setup the console variables error = COrVariable_New( @@ -1870,7 +1870,7 @@ ONrNet_Initialize( &ONgNet_No_Disconnect, NULL); UUmError_ReturnOnErrorMsg(error, "Unable to create a new variable."); - + error = COrVariable_New( "net_authoritative", @@ -1880,7 +1880,7 @@ ONrNet_Initialize( &ONgNet_Authoritative_Server, NULL); UUmError_ReturnOnErrorMsg(error, "Unable to create a new variable."); - + error = COrVariable_New( "net_performance", @@ -1890,7 +1890,7 @@ ONrNet_Initialize( &ONgNet_Performance.display, NULL); UUmError_ReturnOnErrorMsg(error, "Unable to create a new variable."); - + error = COrVariable_New( "net_pps_target", @@ -1910,7 +1910,7 @@ ONrNet_Initialize( ONiDebugLevel_Callback); UUmError_ReturnOnErrorMsg(error, "Unable to create a new command."); - error = + error = SLrScript_Command_Register_Void( "net_server_stop", "stop the server", @@ -1918,7 +1918,7 @@ ONrNet_Initialize( ONiNet_Server_Stop_Callback); UUmError_ReturnOnErrorMsg(error, "Unable to create a new command."); - error = + error = SLrScript_Command_Register_Void( "net_server_start", "start the server", @@ -1926,7 +1926,7 @@ ONrNet_Initialize( ONiNet_Server_Start_Callback); UUmError_ReturnOnErrorMsg(error, "Unable to create a new command."); - error = + error = SLrScript_Command_Register_Void( "net_client_stop", "stop the client", @@ -1934,7 +1934,7 @@ ONrNet_Initialize( ONiNet_Client_Stop_Callback); UUmError_ReturnOnErrorMsg(error, "Unable to create a new command."); - error = + error = SLrScript_Command_Register_Void( "net_client_start", "start the client", @@ -1942,7 +1942,7 @@ ONrNet_Initialize( ONiNet_Client_Start_Callback); UUmError_ReturnOnErrorMsg(error, "Unable to create a new command."); - error = + error = SLrScript_Command_Register_Void( "net_client_join", "join the host's game", @@ -1959,7 +1959,7 @@ ONrNet_IsActive( void) { if (ONgNet_Client || ONgNet_Server) return UUcTrue; - + return UUcFalse; } @@ -1969,7 +1969,7 @@ ONrNet_IsClient( void) { if (ONgNet_Client) return UUcTrue; - + return UUcFalse; } @@ -1979,7 +1979,7 @@ ONrNet_IsServer( void) { if (ONgNet_Server) return UUcTrue; - + return UUcFalse; } @@ -1992,7 +1992,7 @@ ONrNet_Level_Begin( { ONgNet_Level_Callback(UUcTrue, ONgNet_Common->level_number); } - + return UUcError_None; } @@ -2006,7 +2006,7 @@ ONrNet_Level_Callback_Register( ONgNet_Level_Callback = inLevelCallback; } } - + // ---------------------------------------------------------------------- void ONrNet_Level_Callback_Unregister( @@ -2014,7 +2014,7 @@ ONrNet_Level_Callback_Unregister( { ONgNet_Level_Callback = NULL; } - + // ---------------------------------------------------------------------- void ONrNet_Level_End( @@ -2036,7 +2036,7 @@ ONrNet_Override( { return UUcTrue; } - + return UUcFalse; } @@ -2047,14 +2047,14 @@ ONrNet_Terminate( { // stop performance monitor ONiNet_Performance_Terminate(); - + // close down ONrNet_Client_Stop(); ONrNet_Server_Stop(); - + // terminate the network manager NMrTerminate(); - + // make sure things got shut down properly UUmAssert(ONgNet_Client == NULL); UUmAssert(ONgNet_Common == NULL); @@ -2067,13 +2067,13 @@ ONrNet_Update_Receive( void) { UUtUns32 game_time; - + if ((ONgNet_Server == NULL) && (ONgNet_Client == NULL)) return; - + // update the game time game_time = UUrMachineTime_Sixtieths(); ONgNet_Common->game_time = game_time; - + // update the client and the server with the data received ONiNet_Client_Update_Receive(ONgNet_Client, ONgNet_Common); ONiNet_Server_Update_Receive(ONgNet_Server, ONgNet_Common); @@ -2092,4 +2092,4 @@ ONrNet_Update_Send( // display performance data ONiNet_Performance_Update(ONgNet_Server, ONgNet_Client, UUrMachineTime_Sixtieths()); -} \ No newline at end of file +} diff --git a/OniProj/OniGameSource/Oni_Networking/Oni_Networking.h b/OniProj/OniGameSource/Oni_Networking/Oni_Networking.h index af20be6..bd75023 100644 --- a/OniProj/OniGameSource/Oni_Networking/Oni_Networking.h +++ b/OniProj/OniGameSource/Oni_Networking/Oni_Networking.h @@ -39,7 +39,7 @@ typedef enum ONtNetType ONcNetType_Server = 0x0001, // server only ONcNetType_Client = 0x0002, // client only ONcNetType_ServerClient = 0x0003 // server and client - + } ONtNetType; typedef enum ONtNetGameParams @@ -48,7 +48,7 @@ typedef enum ONtNetGameParams ONcNetGameParam_TimeLimit = 0x0001, ONcNetGameParam_KillLimit = 0x0002, ONcNetGameParam_HasAIs = 0x0004 - + } ONtNetGameParams; // ====================================================================== @@ -62,7 +62,7 @@ typedef struct ONtNetGameOptions UUtUns32 time_limit; UUtUns16 kill_limit; UUtUns16 num_AIs; - + } ONtNetGameOptions; typedef struct ONtNet_ServerInfo @@ -71,7 +71,7 @@ typedef struct ONtNet_ServerInfo UUtUns16 num_players; UUtUns16 level_number; char server_name[ONcMaxHostNameLength]; - + } ONtNet_ServerInfo; typedef @@ -90,7 +90,7 @@ ONrNet_Client_Join( char *inCharacterClass, char *inPlayerName, char *inTeamName); - + UUtError ONrNet_Client_Start( UUtUns16 inClientPortNumber); @@ -103,7 +103,7 @@ ONrNet_Client_Stop( char* ONrNet_Server_GetAddress( void); - + UUtError ONrNet_Server_Start( UUtUns16 inServerPortNumber, @@ -114,7 +114,7 @@ ONrNet_Server_Start( UUtError ONrNet_Server_Stop( void); - + // ====================================================================== typedef void @@ -131,16 +131,16 @@ ONrNet_FindServers_Start( UUtError ONrNet_FindServers_Stop( void); - + void ONrNet_FindServers_Update( void); - + // ====================================================================== void ONrNet_Performance_Display( void); - + // ====================================================================== UUtError ONrNet_Initialize( @@ -153,11 +153,11 @@ ONrNet_IsActive( UUtBool ONrNet_IsClient( void); - + UUtBool ONrNet_IsServer( void); - + UUtError ONrNet_Level_Begin( UUtUns16 inLevelNumber); @@ -165,11 +165,11 @@ ONrNet_Level_Begin( void ONrNet_Level_Callback_Register( ONtNet_Level_Callback inLevelCallback); - + void ONrNet_Level_Callback_Unregister( void); - + void ONrNet_Level_End( void); @@ -185,10 +185,10 @@ ONrNet_Terminate( void ONrNet_Update_Receive( void); - + void ONrNet_Update_Send( void); - + // ====================================================================== -#endif /* ONI_NETWORKING_H */ \ No newline at end of file +#endif /* ONI_NETWORKING_H */ diff --git a/OniProj/OniGameSource/Oni_Object/OT_PatrolPoint.c b/OniProj/OniGameSource/Oni_Object/OT_PatrolPoint.c index 59d37fd..aec20f6 100644 --- a/OniProj/OniGameSource/Oni_Object/OT_PatrolPoint.c +++ b/OniProj/OniGameSource/Oni_Object/OT_PatrolPoint.c @@ -55,14 +55,14 @@ static float OBJgPatrolPath_WidthRatio; UUtError OBJrPatrolPath_DrawInitialize( void) -{ +{ if (!OBJgPatrolPath_DrawInitialized) { UUtError error; TStFontFamily *font_family; IMtPixelType textureFormat; M3rDrawEngine_FindGrayscalePixelType(&textureFormat); - + OBJgPatrolPath_WhiteColor = IMrPixel_FromShade(textureFormat, IMcShade_White); error = TSrFontFamily_Get(TScFontFamily_Default, &font_family); @@ -70,20 +70,20 @@ OBJrPatrolPath_DrawInitialize( { goto cleanup; } - + error = TSrContext_New(font_family, TScFontSize_Default, TScStyle_Bold, TSc_SingleLine, UUcFalse, &OBJgPatrolPath_TextContext); if (error != UUcError_None) { goto cleanup; } - + OBJgPatrolPath_Dest.x = 2; OBJgPatrolPath_Dest.y = TSrFont_GetLeadingHeight(TSrContext_GetFont(OBJgPatrolPath_TextContext, TScStyle_InUse)) + TSrFont_GetAscendingHeight(TSrContext_GetFont(OBJgPatrolPath_TextContext, TScStyle_InUse)); - + TSrContext_GetStringRect(OBJgPatrolPath_TextContext, "maximum_length_of_patrol_pt_name", &OBJgPatrolPath_TextureBounds); - + error = M3rTextureMap_New( OBJgPatrolPath_TextureBounds.right, @@ -103,15 +103,15 @@ OBJrPatrolPath_DrawInitialize( (void *) OBJgPatrolPath_Texture, (UUtUns16 *)&OBJgPatrolPath_TextureBounds.right, (UUtUns16 *)&OBJgPatrolPath_TextureBounds.bottom); - + OBJgPatrolPath_TextureWidth = OBJgPatrolPath_TextureBounds.right; OBJgPatrolPath_TextureHeight = OBJgPatrolPath_TextureBounds.bottom; - + OBJgPatrolPath_WidthRatio = (float)OBJgPatrolPath_TextureWidth / (float)OBJgPatrolPath_TextureHeight; - + OBJgPatrolPath_DrawInitialized = UUcTrue; } - + return UUcError_None; cleanup: @@ -139,14 +139,14 @@ OBJiPatrolPath_DrawName( UUtUns16 string_width; IMtPoint2D text_dest; float sprite_size; - + // erase the texture and set the text contexts shade M3rTextureMap_Fill(OBJgPatrolPath_Texture, OBJgPatrolPath_WhiteColor, NULL); TSrContext_SetShade(OBJgPatrolPath_TextContext, IMcShade_Black); - + // get the patrol path's name OBJrObject_GetName(inObject, name, OBJcMaxNameLength); - + // work out how big the string is going to be TSrContext_GetStringRect(OBJgPatrolPath_TextContext, name, &string_bounds); string_width = string_bounds.right - string_bounds.left; @@ -163,7 +163,7 @@ OBJiPatrolPath_DrawName( name, &OBJgPatrolPath_TextureBounds, &text_dest); - + // draw the sprite M3rGeom_State_Set(M3cGeomStateIntType_SpriteMode, M3cGeomState_SpriteMode_Normal); M3rGeom_State_Commit(); @@ -181,7 +181,7 @@ OBJiPatrolPath_DrawName( 0, 1.0f - sprite_size, 0); } - + return; } @@ -233,7 +233,7 @@ OBJiPatrolPath_Draw( M3tPoint3D camera_location; // KNA: replaced size with OBJcPatrolPath_DrawSize so that CodeWarrior would compile - M3tPoint3D points[6] = + M3tPoint3D points[6] = { {-OBJcPatrolPath_DrawSize, 0, 0}, {+OBJcPatrolPath_DrawSize, 0, 0}, @@ -242,17 +242,17 @@ OBJiPatrolPath_Draw( {0, 0, -OBJcPatrolPath_DrawSize}, {0, 0, +OBJcPatrolPath_DrawSize} }; - + if (OBJgPatrolPath_DrawPositions == UUcFalse) { return; } - + // get a pointer to the object osd pp_osd = (OBJtOSD_PatrolPath *)inObject->object_data; - + // set up the matrix stack M3rMatrixStack_Push(); M3rMatrixStack_ApplyTranslate(inObject->position); M3rGeom_State_Commit(); - + // draw the inside star if this patrol path is selected if (inDrawFlags & OBJcDrawFlag_Selected) { M3rGeom_Line_Light(points + 0, points + 1, IMcShade_White); @@ -273,14 +273,14 @@ OBJiPatrolPath_Draw( M3rGeom_Line_Light(points + 2, points + 5, OBJcPatrolPath_DrawShade); M3rGeom_Line_Light(points + 3, points + 4, OBJcPatrolPath_DrawShade); M3rGeom_Line_Light(points + 3, points + 5, OBJcPatrolPath_DrawShade); - + // draw the name camera_location = CArGetLocation(); if (MUrPoint_Distance(&inObject->position, &camera_location) < OBJgPatrolPath_DrawNameDistance) { OBJiPatrolPath_DrawName(inObject, points + 3); } - + M3rMatrixStack_Pop(); #endif @@ -295,10 +295,10 @@ OBJiPatrolPath_Enumerate( UUtUns32 inUserData) { char name[OBJcMaxNameLength + 1]; - + OBJrObject_GetName(inObject, name, OBJcMaxNameLength); inEnumCallback(name, inUserData); - + return UUcError_None; } @@ -322,7 +322,7 @@ OBJiPatrolPath_OSDGetName( UUtUns32 inNameLength) { const OBJtOSD_PatrolPath *pp_osd = &inOSD->osd.patrolpath_osd; - + UUrString_Copy(outName, pp_osd->name, inNameLength); return; @@ -335,7 +335,7 @@ OBJiPatrolPath_OSDSetName( const char *inName) { OBJtOSD_PatrolPath *pp_osd = &inOSD->osd.patrolpath_osd; - + UUrString_Copy(pp_osd->name, inName, sizeof(pp_osd->name)); return; @@ -351,7 +351,7 @@ OBJiPatrolPath_GetOSD( // get a pointer to the object osd pp_osd = (OBJtOSD_PatrolPath *)inObject->object_data; - + outOSD->osd.patrolpath_osd = *pp_osd; } @@ -362,10 +362,10 @@ OBJiPatrolPath_GetOSDWriteSize( { UUtUns32 size, itr; OBJtOSD_PatrolPath *pp_osd; - + // get a pointer to the object osd pp_osd = (OBJtOSD_PatrolPath *)inObject->object_data; - + size = SLcScript_MaxNameLength + sizeof(UUtUns32) + sizeof(UUtUns16) + sizeof(UUtUns16); // name, num_waypoints, id_number, flags for (itr = 0; itr < pp_osd->num_waypoints; itr++) { // waypoint type @@ -548,7 +548,7 @@ OBJiPatrolPath_GetUniqueOSD( prev_object = OBJrObjectType_Search(OBJcType_PatrolPath, OBJcSearch_PatrolPathID, inOSD); if (prev_object != NULL) { continue; } - + break; } @@ -569,14 +569,14 @@ OBJiPatrolPath_IntersectsLine( M3tBoundingSphere sphere; UUrMemory_Clear(&sphere, sizeof(M3tBoundingSphere)); - + // get the bounding sphere OBJrObject_GetBoundingSphere(inObject, &sphere); - + sphere.center.x += inObject->position.x; sphere.center.y += inObject->position.y; sphere.center.z += inObject->position.z; - + return CLrSphere_Line(inStartPoint, inEndPoint, &sphere); } @@ -600,7 +600,7 @@ OBJiPatrolPath_New( { OBJtOSD_All osd_all; UUtError error; - + if (inOSD == NULL) { error = OBJiPatrolPath_SetDefaults(&osd_all); @@ -610,11 +610,11 @@ OBJiPatrolPath_New( { OBJiPatrolPath_DuplicateOSD(inOSD, &osd_all); } - + // set the object specific data and position error = OBJrObject_SetObjectSpecificData(inObject, &osd_all); UUmError_ReturnOnError(error); - + OBJrObject_UpdatePosition(inObject); UUrMemory_Block_VerifyList(); @@ -634,7 +634,7 @@ OBJiPatrolPath_Read( AI2tWaypoint *waypoint; UUtUns32 itr; UUtUns32 bytes_read = 0; - + bytes_read += OBJmGetStringFromBuffer(inBuffer, pp_osd->name, SLcScript_MaxNameLength, inSwapIt); bytes_read += OBJmGet4BytesFromBuffer(inBuffer, pp_osd->num_waypoints, UUtUns32, inSwapIt); @@ -656,7 +656,7 @@ OBJiPatrolPath_Read( // waypoint type bytes_read += OBJmGet4BytesFromBuffer(inBuffer, waypoint->type, AI2tWaypointType, inSwapIt); - switch(waypoint->type) + switch(waypoint->type) { case AI2cWaypointType_MoveToFlag: bytes_read += OBJmGet2BytesFromBuffer(inBuffer, waypoint->data.moveToFlag.flag, UUtInt16, inSwapIt); @@ -778,7 +778,7 @@ OBJiPatrolPath_Read( // bring the object up to date OBJrObject_UpdatePosition(inObject); - + return bytes_read; } @@ -790,12 +790,12 @@ OBJiPatrolPath_SetOSD( { OBJtOSD_PatrolPath *pp_osd; UUtUns32 itr; - + UUmAssert(inOSD); - + // get a pointer to the object osd pp_osd = (OBJtOSD_PatrolPath *)inObject->object_data; - + // copy the data from inOSD to char_osd UUrString_Copy(pp_osd->name, inOSD->osd.patrolpath_osd.name, SLcScript_MaxNameLength); @@ -806,9 +806,9 @@ OBJiPatrolPath_SetOSD( for (itr = 0; itr < pp_osd->num_waypoints; itr++) { pp_osd->waypoints[itr] = inOSD->osd.patrolpath_osd.waypoints[itr]; } - + UUrMemory_Block_VerifyList(); - + return UUcError_None; } @@ -830,7 +830,7 @@ OBJiPatrolPath_Write( OBJtOSD_PatrolPath *pp_osd; AI2tWaypoint *waypoint; UUtUns32 itr, bytes_available; - + pp_osd = (OBJtOSD_PatrolPath *) inObject->object_data; bytes_available = *ioBufferSize; @@ -959,7 +959,7 @@ OBJiPatrolPath_Write( // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = *ioBufferSize - bytes_available; - + return UUcError_None; } @@ -993,10 +993,10 @@ OBJiPatrolPath_Search( { OBJtOSD_PatrolPath *pp_osd; UUtBool found; - + // get a pointer to the object osd pp_osd = (OBJtOSD_PatrolPath *)inObject->object_data; - + // perform the check switch (inSearchType) { @@ -1012,7 +1012,7 @@ OBJiPatrolPath_Search( found = UUcFalse; break; } - + return found; } @@ -1028,10 +1028,10 @@ OBJrPatrolPath_Initialize( { UUtError error; OBJtMethods methods; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiPatrolPath_New; methods.rSetDefaults = OBJiPatrolPath_SetDefaults; @@ -1052,7 +1052,7 @@ OBJrPatrolPath_Initialize( methods.rSearch = OBJiPatrolPath_Search; methods.rSetClassVisible = OBJiPatrolPath_SetVisible; methods.rGetUniqueOSD = OBJiPatrolPath_GetUniqueOSD; - + // register the furniture methods error = OBJrObjectGroup_Register( @@ -1063,7 +1063,7 @@ OBJrPatrolPath_Initialize( &methods, OBJcObjectGroupFlag_CanSetName | OBJcObjectGroupFlag_HasUniqueName); UUmError_ReturnOnError(error); - + #if CONSOLE_DEBUGGING_COMMANDS error = SLrGlobalVariable_Register_Bool( @@ -1071,7 +1071,7 @@ OBJrPatrolPath_Initialize( "Enables the display of AI patrol path objects", &OBJgPatrolPath_DrawPositions); UUmError_ReturnOnError(error); - + error = SLrGlobalVariable_Register_Float( "patrolpath_name_distance", @@ -1079,10 +1079,10 @@ OBJrPatrolPath_Initialize( &OBJgPatrolPath_DrawNameDistance); UUmError_ReturnOnError(error); #endif - + // intialize the globals OBJgPatrolPath_DrawNameDistance = OBJcPatrolPath_DefaultDrawNameDistance; - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/Oni_Object.c b/OniProj/OniGameSource/Oni_Object/Oni_Object.c index d8d68f9..66e7a22 100644 --- a/OniProj/OniGameSource/Oni_Object/Oni_Object.c +++ b/OniProj/OniGameSource/Oni_Object/Oni_Object.c @@ -50,7 +50,7 @@ enum { OBJcObjectGroupFlag_Dirty = 0x0001, OBJcObjectGroupFlag_Locked = 0x0002 - + }; // ====================================================================== @@ -76,7 +76,7 @@ typedef enum OBJtRotateAxis OBJcRotate_XAxis, OBJcRotate_YAxis, OBJcRotate_ZAxis - + } OBJtRotateAxis; // ====================================================================== @@ -90,7 +90,7 @@ static UUtMemory_Array *OBJgSelectedObjects; static OBJtRotateAxis OBJgRotateAxis; -static AUtFlagElement OBJgGunkFlags[] = +static AUtFlagElement OBJgGunkFlags[] = { { "ghost", AKcGQ_Flag_Ghost }, { "stairsup", AKcGQ_Flag_SAT_Up }, @@ -124,17 +124,17 @@ static UUtUns32 OBJgAutoSaveTime; static UUtBool OBJiObjectGroup_IsLocked( OBJtObjectGroup *inObjectGroup); - + static void OBJiObjectGroup_RemoveObject( OBJtObjectGroup *inObjectGroup, OBJtObject *inObject); - + static void OBJiObjectGroup_SetDirty( OBJtObjectGroup *inObjectGroup, UUtBool inLocked); - + // ====================================================================== // functions // ====================================================================== @@ -148,19 +148,19 @@ OBJiObjectGroup_AddObject( UUtUns32 index; UUtBool mem_moved; OBJtObject **object_list; - + UUmAssert(inObjectGroup); - - if (OBJiObjectGroup_IsLocked(inObjectGroup)) { -#if defined(DEBUGGING) && DEBUGGING + if (OBJiObjectGroup_IsLocked(inObjectGroup)) { + +#if defined(DEBUGGING) && DEBUGGING UUrDebuggerMessage("failed to add object (object group %s was locked)", inObjectGroup->group_name); #endif UUmAssert(!"blam"); - return UUcError_Generic; + return UUcError_Generic; } - + // create the object list if it doesn't already exist if (inObjectGroup->object_list == NULL) { @@ -171,22 +171,22 @@ OBJiObjectGroup_AddObject( 0, 1); } - + // get a new element in the object group's object list error = UUrMemory_Array_GetNewElement(inObjectGroup->object_list, &index, &mem_moved); UUmAssert(!error); UUmError_ReturnOnError(error); - + // get a pointer to the object list object_list = (OBJtObject**)UUrMemory_Array_GetMemory(inObjectGroup->object_list); UUmAssert(object_list); - + // add the object to the object list object_list[index] = inObject; - + // the object group is now dirty OBJiObjectGroup_SetDirty(inObjectGroup, UUcTrue); - + return UUcError_None; } @@ -203,19 +203,19 @@ OBJiObjectGroup_DeleteAllObjects( { OBJtObject **object_list; OBJtObject *delete_me; - + object_list = (OBJtObject**)UUrMemory_Array_GetMemory(inObjectGroup->object_list); if (object_list == NULL) { break; } - + delete_me = object_list[0]; if (delete_me == NULL) { continue; } - + // remove the object from the object group OBJiObjectGroup_RemoveObject(inObjectGroup, delete_me); // delete the object specific data delete_me->methods->rDelete(delete_me); - + // release the memory used by the object UUrMemory_Block_Delete(delete_me); } @@ -234,10 +234,10 @@ OBJiObjectGroup_Delete( OBJtObjectGroup **object_group_list; UUtUns32 num_groups; UUtUns32 i; - + // delete the objects OBJiObjectGroup_DeleteAllObjects(inObjectGroup); - + // find the object group in the list object_group_list = (OBJtObjectGroup**)UUrMemory_Array_GetMemory(OBJgObjectGroups); num_groups = UUrMemory_Array_GetUsedElems(OBJgObjectGroups); @@ -248,7 +248,7 @@ OBJiObjectGroup_Delete( UUrMemory_Array_DeleteElement(OBJgObjectGroups, i); } } - + // delete the object group if( inObjectGroup->mechanics_class ) ONrMechanics_DeleteClass( inObjectGroup->mechanics_class ); @@ -263,12 +263,12 @@ OBJiObjectGroup_Draw( UUtUns32 num_objects; UUtUns32 i; OBJtObject **object_list; - + if (inObjectGroup->object_list == NULL) { return; } - + object_list = (OBJtObject**)UUrMemory_Array_GetMemory(inObjectGroup->object_list); if (object_list == NULL) { return; } - + num_objects = UUrMemory_Array_GetUsedElems(inObjectGroup->object_list); for (i = 0; i < num_objects; i++) { @@ -286,21 +286,21 @@ OBJiObjectGroup_EnumerateObjects( UUtUns32 num_objects; UUtUns32 i; OBJtObject **object_list; - + UUmAssert(inObjectGroup); - + if (inObjectGroup->object_list == NULL) { return 0; } object_list = (OBJtObject**)UUrMemory_Array_GetMemory(inObjectGroup->object_list); if (object_list == NULL) { return 0; } - + num_objects = UUrMemory_Array_GetUsedElems(inObjectGroup->object_list); if (NULL != inEnumCallback) { for (i = 0; i < num_objects; i++) { UUtBool result; - + result = inEnumCallback(object_list[i], inUserData); if (result == UUcFalse) { break; } } @@ -316,19 +316,19 @@ OBJiObjectGroup_GetByName( { OBJtObjectGroup *object_group; OBJtObjectGroup **object_group_list; - + UUmAssert(inGroupName); - + // intialize object_group = NULL; - + // make sure the object group list exists object_group_list = (OBJtObjectGroup**)UUrMemory_Array_GetMemory(OBJgObjectGroups); if (object_group_list) { UUtUns32 num_groups; UUtUns32 i; - + // go through all the groups and find the object group that // has inObjectType associated with it num_groups = UUrMemory_Array_GetUsedElems(OBJgObjectGroups); @@ -341,7 +341,7 @@ OBJiObjectGroup_GetByName( } } } - + return object_group; } @@ -352,17 +352,17 @@ OBJiObjectGroup_GetByType( { OBJtObjectGroup *object_group; OBJtObjectGroup **object_group_list; - + // intialize object_group = NULL; - + // make sure the object group list exists object_group_list = (OBJtObjectGroup**)UUrMemory_Array_GetMemory(OBJgObjectGroups); if (object_group_list) { UUtUns32 num_groups; UUtUns32 i; - + // go through all the groups and find the object group that // has an object type of inObjectType num_groups = UUrMemory_Array_GetUsedElems(OBJgObjectGroups); @@ -375,7 +375,7 @@ OBJiObjectGroup_GetByType( } } } - + return object_group; } @@ -399,9 +399,9 @@ OBJiObjectGroup_GetNumObjects( OBJtObjectGroup *inObjectGroup) { UUtUns32 num_objects; - + UUmAssert(inObjectGroup); - + if (inObjectGroup->object_list) { num_objects = UUrMemory_Array_GetUsedElems(inObjectGroup->object_list); @@ -422,15 +422,15 @@ OBJiObjectGroup_GetObject( { OBJtObject **object_list; UUtUns32 num_objects; - + UUmAssert(inObjectGroup); - + num_objects = UUrMemory_Array_GetUsedElems(inObjectGroup->object_list); UUmAssert(inIndex < num_objects); - + object_list = (OBJtObject**)UUrMemory_Array_GetMemory(inObjectGroup->object_list); if (object_list == NULL) { return NULL; } - + return object_list[inIndex]; } @@ -440,7 +440,7 @@ OBJiObjectGroup_GetOSDSize( OBJtObjectGroup *inObjectGroup) { UUmAssert(inObjectGroup); - + return inObjectGroup->osd_size_in_memory; } @@ -452,7 +452,7 @@ OBJiObjectGroup_GetWriteSize( UUtUns32 size; UUtUns32 i; UUtUns32 count; - + size = 0; count = OBJiObjectGroup_GetNumObjects(inObjectGroup); for (i = 0; i < count; i++) @@ -460,17 +460,17 @@ OBJiObjectGroup_GetWriteSize( OBJtObject *object; UUtUns32 osd_write_size; UUtUns32 chunk_size; - + object = OBJiObjectGroup_GetObject(inObjectGroup, i); if (object == NULL) { continue; } - + osd_write_size = OBJrObject_GetOSDWriteSize(object); chunk_size = osd_write_size + OBJcObjectGenericWriteSize; chunk_size = UUmMakeMultiple(chunk_size, 4); - + size += chunk_size; } - + return size; } @@ -507,7 +507,7 @@ OBJiObjectGroup_VerifyMethods( #if defined(DEBUGGING) && DEBUGGING void **methods; UUtUns32 i; - + UUmAssert(inMethods->rNew); UUmAssert(inMethods->rDelete); UUmAssert(inMethods->rDraw); @@ -545,39 +545,39 @@ OBJrObjectGroup_Register( UUtBool mem_moved; OBJtObjectGroup *object_group; OBJtObjectGroup **object_group_list; - + UUmAssert(inGroupName); UUmAssert(inGroupName[0] != '\0'); - + // see if inObjectType is already in use if (OBJiObjectGroup_GetByType(inObjectType) != NULL) { // this object type has already been registered return UUcError_Generic; } - + // see if inName is already in use if (OBJiObjectGroup_GetByName(inGroupName) != NULL) { // this object type has already been registered return UUcError_Generic; } - + // index must be a single nonzero byte if ((inObjectTypeIndex <= 0) || (inObjectTypeIndex >= 256)) { return UUcError_Generic; } OBJiObjectGroup_VerifyMethods(inMethods); - + // create a new group entry in the object groups array error = UUrMemory_Array_GetNewElement(OBJgObjectGroups, &index, &mem_moved); UUmError_ReturnOnError(error); - + // allocate memory for the group object_group = (OBJtObjectGroup*)UUrMemory_Block_New(sizeof(OBJtObjectGroup)); UUmError_ReturnOnNull(object_group); - + // initialize this group object_group->object_list = NULL; object_group->object_type = inObjectType; @@ -587,12 +587,12 @@ OBJrObjectGroup_Register( object_group->methods = *inMethods; object_group->mechanics_class = NULL; UUrString_Copy(object_group->group_name, inGroupName, OBJcMaxNameLength); - + // add the object_group to the object group array object_group_list = (OBJtObjectGroup**)UUrMemory_Array_GetMemory(OBJgObjectGroups); UUmAssert(object_group_list); object_group_list[index] = object_group; - + return UUcError_None; } @@ -605,26 +605,26 @@ OBJiObjectGroup_RemoveObject( OBJtObject **object_list; UUtUns32 i; UUtUns32 num_objects; - + UUmAssert(inObjectGroup); UUmAssert(inObject); - + // get a pointer to the object list object_list = (OBJtObject**)UUrMemory_Array_GetMemory(inObjectGroup->object_list); if (object_list == NULL) { return; } - + // find the object in the object list and delete it num_objects = UUrMemory_Array_GetUsedElems(inObjectGroup->object_list); for (i = 0; i < num_objects; i++) { if (object_list[i] != inObject) { continue; } - + // delete the object from the list UUrMemory_Array_DeleteElement(inObjectGroup->object_list, i); - + // the object group is now dirty OBJiObjectGroup_SetDirty(inObjectGroup, UUcTrue); - + break; } } @@ -674,12 +674,12 @@ OBJiObjectGroups_Draw( UUtUns32 i; UUtUns32 num_groups; OBJtObjectGroup **object_group_list; - + UUmAssert(OBJgObjectGroups); object_group_list = (OBJtObjectGroup**)UUrMemory_Array_GetMemory(OBJgObjectGroups); if (object_group_list == NULL) { return; } - + num_groups = UUrMemory_Array_GetUsedElems(OBJgObjectGroups); for (i = 0; i < num_groups; i++) { @@ -699,18 +699,18 @@ OBJiObjectGroups_Enumerate( UUtUns32 i; UUtUns32 num_groups; OBJtObjectGroup **object_group_list; - + UUmAssert(OBJgObjectGroups); UUmAssert(inEnumCallback); - + object_group_list = (OBJtObjectGroup**)UUrMemory_Array_GetMemory(OBJgObjectGroups); if (object_group_list == NULL) { return; } - + num_groups = UUrMemory_Array_GetUsedElems(OBJgObjectGroups); for (i = 0; i < num_groups; i++) { UUtBool result; - + result = inEnumCallback( object_group_list[i]->object_type, @@ -727,15 +727,15 @@ OBJiObjectGroups_GetGroupByIndex( { OBJtObjectGroup **object_group_list; UUtUns32 num_groups; - + UUmAssert(OBJgObjectGroups); - + num_groups = UUrMemory_Array_GetUsedElems(OBJgObjectGroups); UUmAssert(inGroupIndex < num_groups); - + object_group_list = (OBJtObjectGroup**)UUrMemory_Array_GetMemory(OBJgObjectGroups); UUmAssert(object_group_list); - + return object_group_list[inGroupIndex]; } @@ -745,7 +745,7 @@ OBJiObjectGroups_GetNumGroups( void) { UUmAssert(OBJgObjectGroups); - + return UUrMemory_Array_GetUsedElems(OBJgObjectGroups); } @@ -767,7 +767,7 @@ OBJiObjectGroups_Initialize( 0, 0); UUmError_ReturnOnNull(OBJgObjectGroups); - + return UUcError_None; } @@ -787,9 +787,9 @@ OBJiObjectGroups_LevelUnload( OBJtObjectGroup **object_group_list; UUtUns32 num_groups; UUtUns32 i; - + if (OBJgObjectGroups == NULL) { return; } - + // delete the objects in the object groups object_group_list = (OBJtObjectGroup**)UUrMemory_Array_GetMemory(OBJgObjectGroups); num_groups = UUrMemory_Array_GetUsedElems(OBJgObjectGroups); @@ -801,7 +801,7 @@ OBJiObjectGroups_LevelUnload( // delete the objects in the object group OBJiObjectGroup_DeleteAllObjects(object_group_list[i]); - + // clear the object groups locked status OBJiObjectGroup_SetLocked(object_group_list[i], UUcFalse); } @@ -822,7 +822,7 @@ OBJiObjectGroups_Terminate( object_group_list = (OBJtObjectGroup**)UUrMemory_Array_GetMemory(OBJgObjectGroups); OBJiObjectGroup_Delete(object_group_list[0]); } - + // delete the object group array UUrMemory_Array_Delete(OBJgObjectGroups); OBJgObjectGroups = NULL; @@ -843,7 +843,7 @@ OBJrObjectType_EnumerateObjects( { OBJtObjectGroup *object_group; UUtUns32 num_objects; - + object_group = OBJiObjectGroup_GetByType(inObjectType); if (object_group == NULL) { return 0; } num_objects = OBJiObjectGroup_EnumerateObjects(object_group, inEnumCallback, inUserData); @@ -859,10 +859,10 @@ OBJtObject *OBJrObjectType_GetObject_ByNumber( OBJtObjectGroup *object_group; // UUtUns32 num_objects; // OBJtObject **object_list; - + object_group = OBJiObjectGroup_GetByType(inObjectType); return OBJiObjectGroup_GetObject(object_group, inIndex); - + /* if (NULL == object_group) { return NULL; } if (NULL == object_group->object_list) { return NULL; } @@ -883,7 +883,7 @@ OBJrObjectType_GetName( OBJtObjectType inObjectType) { OBJtObjectGroup *object_group; - + object_group = OBJiObjectGroup_GetByType(inObjectType); if (object_group == NULL) { @@ -900,10 +900,10 @@ OBJrObjectType_GetUniqueOSD( OBJtOSD_All *outOSD) { OBJtObjectGroup *object_group; - + object_group = OBJiObjectGroup_GetByType(inObjectType); if (object_group == NULL) { return; } - + object_group->methods.rGetUniqueOSD(outOSD); return; @@ -915,10 +915,10 @@ OBJrObjectType_GetVisible( OBJtObjectType inObjectType) { OBJtObjectGroup *object_group; - + object_group = OBJiObjectGroup_GetByType(inObjectType); if (object_group == NULL) { return UUcFalse; } - + return object_group->methods.rGetClassVisible(); } @@ -929,10 +929,10 @@ OBJrObjectType_IsLocked( { OBJtObjectGroup *object_group; UUtBool is_locked = UUcFalse; - + object_group = OBJiObjectGroup_GetByType(inObjectType); if (object_group == NULL) { goto exit; } - + is_locked = OBJiObjectGroup_IsLocked(object_group); exit: @@ -950,10 +950,10 @@ OBJrObjectType_Search( OBJtObject *found_object; UUtUns32 i; UUtUns32 num_objects; - + object_group = OBJiObjectGroup_GetByType(inObjectType); if (object_group == NULL) { return NULL; } - + // find the object in the list found_object = NULL; num_objects = OBJiObjectGroup_GetNumObjects(object_group); @@ -961,10 +961,10 @@ OBJrObjectType_Search( { UUtBool found; OBJtObject *object; - + object = OBJiObjectGroup_GetObject(object_group, i); if (object == NULL) { continue; } - + found = object_group->methods.rSearch( object, @@ -976,7 +976,7 @@ OBJrObjectType_Search( break; } } - + return found_object; } @@ -987,10 +987,10 @@ OBJrObjectType_SetVisible( UUtBool inIsVisible) { OBJtObjectGroup *object_group; - + object_group = OBJiObjectGroup_GetByType(inObjectType); if (object_group == NULL) { return; } - + object_group->methods.rSetClassVisible(inIsVisible); } @@ -1011,7 +1011,7 @@ OBJrObjectTypes_Enumerate( UUtError OBJrObjectType_RegisterMechanics( OBJtObjectType inObjectType, ONtMechanicsClass *inMechanicsClass ) { OBJtObjectGroup *object_group; - + if (!(object_group = OBJiObjectGroup_GetByType(inObjectType))) return UUcError_Generic; @@ -1023,7 +1023,7 @@ UUtError OBJrObjectType_RegisterMechanics( OBJtObjectType inObjectType, ONtMecha ONtMechanicsClass* OBJrObjectType_GetMechanicsByType( OBJtObjectType inObjectType ) { OBJtObjectGroup *object_group; - + if (!(object_group = OBJiObjectGroup_GetByType(inObjectType))) return NULL; @@ -1043,9 +1043,9 @@ OBJiObject_Read_1( UUtUns8 *inBuffer) { UUtUns32 num_bytes; - + num_bytes = 0; - + // read the position OBDmGet4BytesFromBuffer(inBuffer, inObject->position.x, float, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, inObject->position.y, float, inSwapIt); @@ -1069,12 +1069,12 @@ OBJiObject_Read_3( UUtUns8 *inBuffer) { UUtUns32 num_bytes; - + num_bytes = 0; - + // read the flags num_bytes += OBDmGet4BytesFromBuffer(inBuffer, inObject->flags, UUtUns32, inSwapIt); - + // read the position num_bytes += OBDmGet4BytesFromBuffer(inBuffer, inObject->position.x, float, inSwapIt); num_bytes += OBDmGet4BytesFromBuffer(inBuffer, inObject->position.y, float, inSwapIt); @@ -1096,15 +1096,15 @@ OBJiObject_Read_7( UUtUns8 *inBuffer) { UUtUns32 num_bytes; - + num_bytes = 0; - + // read the ID num_bytes += OBDmGet4BytesFromBuffer(inBuffer, inObject->object_id, UUtUns32, inSwapIt); - + // read the flags num_bytes += OBDmGet4BytesFromBuffer(inBuffer, inObject->flags, UUtUns32, inSwapIt); - + // read the position num_bytes += OBDmGet4BytesFromBuffer(inBuffer, inObject->position.x, float, inSwapIt); num_bytes += OBDmGet4BytesFromBuffer(inBuffer, inObject->position.y, float, inSwapIt); @@ -1127,9 +1127,9 @@ OBJiObject_Read_7( UUtError OBJrObject_OSD_SetDefaults(OBJtObjectType inType, OBJtOSD_All *outOSD) { OBJtObjectGroup *object_group; - + object_group = OBJiObjectGroup_GetByType(inType); - UUmAssert(object_group != NULL); + UUmAssert(object_group != NULL); if (object_group == NULL) { return UUcError_Generic; } @@ -1141,9 +1141,9 @@ UUtError OBJrObject_OSD_SetDefaults(OBJtObjectType inType, OBJtOSD_All *outOSD) void OBJrObject_OSD_GetName(OBJtObjectType inType, const OBJtOSD_All *inOSD, char *outName, UUtUns32 inNameLength) { OBJtObjectGroup *object_group; - + object_group = OBJiObjectGroup_GetByType(inType); - UUmAssert(object_group != NULL); + UUmAssert(object_group != NULL); if (object_group == NULL) { return; } object_group->methods.rOSDGetName(inOSD, outName, inNameLength); @@ -1155,9 +1155,9 @@ void OBJrObject_OSD_GetName(OBJtObjectType inType, const OBJtOSD_All *inOSD, cha void OBJrObject_OSD_SetName(OBJtObjectType inType, OBJtOSD_All *inOSD, const char *inName) { OBJtObjectGroup *object_group; - + object_group = OBJiObjectGroup_GetByType(inType); - UUmAssert(object_group != NULL); + UUmAssert(object_group != NULL); if (object_group == NULL) { return; } object_group->methods.rOSDSetName(inOSD, inName); @@ -1185,25 +1185,25 @@ OBJrObject_CreateFromBuffer( UUtUns32 num_bytes; UUtUns32 total_bytes; OBJtObjectGroup *object_group; - + // init the returning values *outNumBytesRead = 0; total_bytes = 0; - + // read the object type OBDmGet4BytesFromBuffer(inBuffer, object_type, OBJtObjectType, inSwapIt); num_bytes = sizeof(OBJtObjectType); total_bytes += num_bytes; - + // make sure the object type is valid object_group = OBJiObjectGroup_GetByType(object_type); if (object_group == NULL) { return UUcError_Generic; } - + // allocate memory for the new object object_size = sizeof(OBJtObject) + OBJiObjectGroup_GetOSDSize(object_group); object = (OBJtObject*)UUrMemory_Block_NewClear(object_size); UUmError_ReturnOnNull(object); - + // set the objects methods object->object_type = object_type; object->methods = &object_group->methods; @@ -1215,26 +1215,26 @@ OBJrObject_CreateFromBuffer( UUmAssert(inVersion <= OBJcCurrentVersion); // process the common object data - if (inVersion >= 7) + if (inVersion >= 7) { num_bytes = OBJiObject_Read_7(object, inSwapIt, inBuffer); - } - else if (inVersion >= 3) + } + else if (inVersion >= 3) { num_bytes = OBJiObject_Read_3(object, inSwapIt, inBuffer); - } - else if (inVersion >= 1) + } + else if (inVersion >= 1) { num_bytes = OBJiObject_Read_1(object, inSwapIt, inBuffer); - } - else + } + else { UUmAssert(!"Unknown Version file version"); } inBuffer += num_bytes; total_bytes += num_bytes; - + // process the object specific data num_bytes = object->methods->rRead(object, inVersion, inSwapIt, inBuffer); num_bytes = UUmMakeMultiple(num_bytes, 4); @@ -1253,17 +1253,17 @@ OBJrObject_CreateFromBuffer( if( object->object_id >= OBJgNextObjectID ) OBJgNextObjectID = object->object_id + 1; } - + // add the object to the object list error = OBJiObjectGroup_AddObject(object_group, object); if (error != UUcError_None) { UUmAssert(!"OBJrObject_CreateFromBuffer failed"); UUrDebuggerMessage("OBJrObject_CreateFromBuffer: unable to add object to group %s", object_group->group_name); } - + // return the number of bytes read *outNumBytesRead = total_bytes; - + return UUcError_None; } @@ -1273,29 +1273,29 @@ OBJrObject_Delete( OBJtObject *inObject) { OBJtObjectGroup *object_group; - + UUmAssert(inObject); - + // make sure the object isn't locked if (OBJrObject_IsLocked(inObject)) { return; } - + // get the object group that inObject belongs to object_group = OBJiObjectGroup_GetByType(inObject->object_type); if (object_group == NULL) { return; } if (OBJiObjectGroup_IsLocked(object_group)) { return; } - + // remove the object from the object group OBJiObjectGroup_RemoveObject(object_group, inObject); - + // delete the object specific data inObject->methods->rDelete(inObject); - + // make sure this object isn't selected if (OBJrSelectedObjects_IsObjectSelected(inObject)) { OBJrSelectedObjects_Unselect(inObject); } - + // release the memory used by inObject UUrMemory_Block_Delete(inObject); UUrMemory_Block_VerifyList(); @@ -1307,39 +1307,39 @@ OBJrObject_Draw( OBJtObject *inObject) { UUtUns32 draw_flags; - + UUmAssert(inObject); - + draw_flags = 0; if (OBJrSelectedObjects_IsObjectSelected(inObject)) { draw_flags |= OBJcDrawFlag_Selected; } - + if (inObject->flags & OBJcObjectFlag_Locked) { draw_flags |= OBJcDrawFlag_Locked; } - + switch (OBJgRotateMode) { case OBJcRotateMode_XYZ: draw_flags |= (OBJcDrawFlag_RingX | OBJcDrawFlag_RingY | OBJcDrawFlag_RingZ); break; - + case OBJcRotateMode_XY: draw_flags |= OBJcDrawFlag_RingZ; break; - + case OBJcRotateMode_XZ: draw_flags |= OBJcDrawFlag_RingY; break; - + case OBJcRotateMode_YZ: draw_flags |= OBJcDrawFlag_RingX; break; } - + inObject->methods->rDraw(inObject, draw_flags); } @@ -1351,12 +1351,12 @@ OBJrObject_GetPosition( M3tPoint3D *outRotation) { UUmAssert(inObject); - + if (outPosition) { *outPosition = inObject->position; } - + if (outRotation) { *outRotation = inObject->rotation; @@ -1399,17 +1399,17 @@ OBJrObject_New( UUtUns32 object_size; OBJtObject *object; OBJtObjectGroup *object_group; - + // get the object group that the object will be added to object_group = OBJiObjectGroup_GetByType(inObjectType); if (object_group == NULL) { return UUcError_Generic; } if (OBJiObjectGroup_IsLocked(object_group)) { return UUcError_Generic; } - + // allocate memory for the new object object_size = sizeof(OBJtObject) + OBJiObjectGroup_GetOSDSize(object_group); object = (OBJtObject*)UUrMemory_Block_NewClear(object_size); UUmError_ReturnOnNull(object); - + // initialize the object object->object_type = inObjectType; object->object_id = OBJrObject_GetNextAvailableID(); @@ -1418,19 +1418,19 @@ OBJrObject_New( object->rotation = *inRotation; object->methods = &object_group->methods; object->mechanics_class = object_group->mechanics_class; - + error = object->methods->rNew(object, inObjectSpecificData); UUmError_ReturnOnError(error); - + // add the object to the object group error = OBJiObjectGroup_AddObject(object_group, object); UUmError_ReturnOnError(error); - + // select the newly created object OBJrSelectedObjects_Select(object, UUcFalse); UUrMemory_Block_VerifyList(); - + return UUcError_None; } @@ -1443,7 +1443,7 @@ OBJrObject_LevelBegin( UUtUns32 num_groups; UUtUns32 i; UUtError error; - + UUmAssert( ONgLevel ); if (OBJgObjectGroups == NULL) { return UUcError_Generic; } @@ -1455,13 +1455,13 @@ OBJrObject_LevelBegin( UUmAssert(object_group_list); for (i = 0; i < num_groups; i++) - { + { OBJtObjectGroup *object_group; UUtUns32 num_objects; UUtUns32 j, tag; OBJtObject **object_list; OBJtObject *object; - + object_group = object_group_list[i]; UUmAssert(object_group); @@ -1476,7 +1476,7 @@ OBJrObject_LevelBegin( object_list = (OBJtObject**)UUrMemory_Array_GetMemory(object_group->object_list); if (object_list == NULL) continue; - + num_objects = UUrMemory_Array_GetUsedElems(object_group->object_list); for (j = 0; j < num_objects; j++) @@ -1502,7 +1502,7 @@ UUtError OBJrObject_LevelEnd(void) UUtUns32 num_groups; UUtUns32 i; UUtError error; - + UUmAssert( ONgLevel ); // clear the selected objects @@ -1518,9 +1518,9 @@ UUtError OBJrObject_LevelEnd(void) UUmAssert(object_group_list); for (i = 0; i < num_groups; i++) - { + { OBJtObjectGroup *object_group; - + object_group = object_group_list[i]; UUmAssert(object_group); @@ -1549,15 +1549,15 @@ OBJrObject_MouseMove( M3tVector3D new_object_rotation; float delta_x; float delta_y; - + // make sure the object isn't locked if (OBJrObject_IsLocked(inObject)) { return; } - + // make sure the object group isn't locked object_group = OBJiObjectGroup_GetByType(inObject->object_type); if (object_group == NULL) { return; } if (OBJiObjectGroup_IsLocked(object_group)) { return; } - + // make sure the start point and end point aren't the same if ((inStartPoint->x == inEndPoint->x) && (inStartPoint->y == inEndPoint->y)) @@ -1574,15 +1574,15 @@ OBJrObject_MouseMove( last_object = inObject; } - + // calculate the delta between the points delta_x = (float)(inEndPoint->x - inStartPoint->x); delta_y = (float)(inStartPoint->y - inEndPoint->y); - + set_rotation = UUcFalse; new_object_position = inObject->position; new_object_rotation = inObject->rotation; - + // restrict left/right or forward/backward movement if ((OBJgMoveMode & OBJcMoveMode_LR) == 0) { @@ -1677,7 +1677,7 @@ OBJrObject_MouseMove( else if (OBJgMoveMode & OBJcMoveMode_UD) { M3tVector3D y_vector; - + // move up and down MUmVector_Set(y_vector, 0.0f, 1.0f, 0.0f); MUmVector_Scale(y_vector, delta_y * 0.1f); @@ -1688,32 +1688,32 @@ OBJrObject_MouseMove( M3tVector3D up; M3tVector3D cross; M3tVector3D view_vector; - + // get the vector in the direction the camera is looking view_vector = CArGetFacing(); MUrNormalize(&view_vector); - + // get the vector which is orthogonal to the view vector and // is in the same xz plane MUmVector_Copy(up, view_vector); up.y += 1.0f; MUrVector_CrossProduct(&up, &view_vector, &cross); MUrNormalize(&cross); - + // no y movement view_vector.y = 0.0f; cross.y = 0.0f; - + // scale the vectors by the movement of the mouse MUmVector_Scale(view_vector, delta_y * 0.2f); MUmVector_Negate(cross); MUmVector_Scale(cross, delta_x * 0.1f); - + // add the movement vectors to the object's position MUmVector_Increment(new_object_position, view_vector); MUmVector_Increment(new_object_position, cross); } - + // set the object's new position OBJrObject_SetPosition(inObject, &new_object_position, (set_rotation) ? &new_object_rotation : NULL); } @@ -1727,122 +1727,122 @@ OBJrObject_MouseRotate_Begin( M3tGeomCamera *camera; M3tPoint3D camera_position; M3tPoint3D start_world_point; - + M3tVector3D obj_center; M3tVector3D cam_to_obj; M3tVector3D cam_to_start; M3tPoint3D cam_through_start; - + float cam_to_obj_dist; - + M3tVector3D origin; M3tVector3D x_vector; M3tVector3D y_vector; M3tVector3D z_vector; - + M3tVector3D obj_origin; M3tVector3D obj_x_vector; M3tVector3D obj_y_vector; M3tVector3D obj_z_vector; - + M3tPlaneEquation xy_plane; M3tPlaneEquation xz_plane; M3tPlaneEquation yz_plane; - + M3tMatrix4x3 matrix; - + M3tPoint3D xy_start_intersect; M3tPoint3D xz_start_intersect; M3tPoint3D yz_start_intersect; - + M3tBoundingSphere bounding_sphere; - + M3tVector3D xy_dist_vector; M3tVector3D xz_dist_vector; M3tVector3D yz_dist_vector; - + float xy_distance; float xz_distance; float yz_distance; - + UUtBool xy_int; UUtBool xz_int; UUtBool yz_int; - + OBJtObjectGroup *object_group; - + // make sure the object isn't locked if (OBJrObject_IsLocked(inObject)) { return; } - + // make sure the object group isn't locked object_group = OBJiObjectGroup_GetByType(inObject->object_type); if (object_group == NULL) { return; } if (OBJiObjectGroup_IsLocked(object_group)) { return; } - + // get the active camera M3rCamera_GetActive(&camera); UUmAssert(camera); - + // get the camera position camera_position = CArGetLocation(); - + // get the point on the near clip plane where the user clicked M3rPick_ScreenToWorld( camera, (UUtUns16)inMousePosition->x, (UUtUns16)inMousePosition->y, &start_world_point); - + // get the bounding sphere OBJrObject_GetBoundingSphere(inObject, &bounding_sphere); - - // calculate the object center + + // calculate the object center MUmVector_Add(obj_center, bounding_sphere.center, inObject->position); - + // calculate the distance from the camera to the object - MUmVector_Subtract(cam_to_obj, obj_center, camera_position); + MUmVector_Subtract(cam_to_obj, obj_center, camera_position); cam_to_obj_dist = MUrVector_Length(&cam_to_obj); - + // get a point on the line from the camera through the start point to a point // that doesn't quite reach the other side of the bounding sphere MUmVector_Subtract(cam_to_start, start_world_point, camera_position); MUrNormalize(&cam_to_start); MUmVector_Scale(cam_to_start, cam_to_obj_dist + (bounding_sphere.radius / 2)); MUmVector_Add(cam_through_start, cam_to_start, camera_position); - + // initialize unit vectors MUmVector_Set(origin, 0.0f, 0.0f, 0.0f); MUmVector_Set(x_vector, 1.0f, 0.0f, 0.0f); MUmVector_Set(y_vector, 0.0f, 1.0f, 0.0f); MUmVector_Set(z_vector, 0.0f, 0.0f, 1.0f); - + // rotate the unit vectors MUrMatrix_Identity(&matrix); MUrMatrix_RotateX(&matrix, (inObject->rotation.x * M3cDegToRad)); MUrMatrix_RotateY(&matrix, (inObject->rotation.y * M3cDegToRad)); MUrMatrix_RotateZ(&matrix, (inObject->rotation.z * M3cDegToRad)); - + MUrMatrix_MultiplyPoint(&origin, &matrix, &obj_origin); MUrMatrix_MultiplyPoint(&x_vector, &matrix, &obj_x_vector); MUrMatrix_MultiplyPoint(&y_vector, &matrix, &obj_y_vector); MUrMatrix_MultiplyPoint(&z_vector, &matrix, &obj_z_vector); - + // move the rotated unit vectors to the object center MUmVector_Increment(obj_origin, obj_center); MUmVector_Increment(obj_x_vector, obj_center); MUmVector_Increment(obj_y_vector, obj_center); MUmVector_Increment(obj_z_vector, obj_center); - + // build plane equations MUrVector_PlaneFromEdges(&obj_origin, &obj_x_vector, &obj_origin, &obj_y_vector, &xy_plane); MUrVector_PlaneFromEdges(&obj_origin, &obj_x_vector, &obj_origin, &obj_z_vector, &xz_plane); MUrVector_PlaneFromEdges(&obj_origin, &obj_y_vector, &obj_origin, &obj_z_vector, &yz_plane); - + // intersect points xy_int = CLrLine_Plane(&camera_position, &cam_through_start, &xy_plane, &xy_start_intersect); xz_int = CLrLine_Plane(&camera_position, &cam_through_start, &xz_plane, &xz_start_intersect); yz_int = CLrLine_Plane(&camera_position, &cam_through_start, &yz_plane, &yz_start_intersect); - + // calculate distance from bounding sphere edge to intersecting point xy_distance = UUcFloat_Max; xz_distance = UUcFloat_Max; @@ -1853,19 +1853,19 @@ OBJrObject_MouseRotate_Begin( MUmVector_Subtract(xy_dist_vector, xy_start_intersect, obj_origin); xy_distance = (float)fabs(MUrVector_Length(&xy_dist_vector) - bounding_sphere.radius); } - + if (xz_int) { MUmVector_Subtract(xz_dist_vector, xz_start_intersect, obj_origin); xz_distance = (float)fabs(MUrVector_Length(&xz_dist_vector) - bounding_sphere.radius); } - + if (yz_int) { MUmVector_Subtract(yz_dist_vector, yz_start_intersect, obj_origin); yz_distance = (float)fabs(MUrVector_Length(&yz_dist_vector) - bounding_sphere.radius); } - + // determine which axis to rotate OBJgRotateAxis = OBJcRotate_None; if ((OBJgRotateMode & OBJcRotateMode_XYZ) == OBJcRotateMode_XYZ) @@ -1918,15 +1918,15 @@ OBJrObject_MouseRotate_Update( float mouse_units_to_radians = ((float) M3cDegToRad); // 1 mouse unit = 1 degree works well OBJtObjectGroup *object_group; - + // make sure the object isn't locked if (OBJrObject_IsLocked(inObject)) { return; } - + // make sure the object group isn't locked object_group = OBJiObjectGroup_GetByType(inObject->object_type); if (object_group == NULL) { return; } if (OBJiObjectGroup_IsLocked(object_group)) { return; } - + // get the axis to rotate about axis_for_rotation = MUgZeroPoint; @@ -1935,11 +1935,11 @@ OBJrObject_MouseRotate_Update( case OBJcRotate_ZAxis: axis_for_rotation.z = 1.0f; break; - + case OBJcRotate_YAxis: axis_for_rotation.y = 1.0f; break; - + case OBJcRotate_XAxis: axis_for_rotation.x = 1.0f; break; @@ -1953,7 +1953,7 @@ OBJrObject_MouseRotate_Update( radians = inPositionDelta->x * mouse_units_to_radians; radians = UUmPin(radians, -M3cPi, M3cPi); // pinning simplifies the clip UUmTrig_Clip(radians); - + // build the rotation matrix for the amount of rotation this mouse movement caused MUrMatrix_BuildRotate(radians, axis_for_rotation.x, axis_for_rotation.y, axis_for_rotation.z, &delta_rotation_matrix); @@ -1986,7 +1986,7 @@ OBJrObject_SetLocked( object_group = OBJiObjectGroup_GetByType(ioObject->object_type); if (object_group == NULL) { return; } if (OBJiObjectGroup_IsLocked(object_group)) { return; } - + if (inIsLocked) { ioObject->flags |= OBJcObjectFlag_Locked; @@ -1995,7 +1995,7 @@ OBJrObject_SetLocked( { ioObject->flags &= ~OBJcObjectFlag_Locked; } - + // the object group is now dirty OBJiObjectGroup_SetDirty(object_group, UUcTrue); } @@ -2008,18 +2008,18 @@ OBJrObject_SetObjectSpecificData( { UUtError error; OBJtObjectGroup *object_group; - + UUmAssert(ioObject); UUmAssert(inObjectSpecificData); - + // make sure the object group isn't locked object_group = OBJiObjectGroup_GetByType(ioObject->object_type); if (object_group == NULL) { return UUcError_Generic; } if (OBJiObjectGroup_IsLocked(object_group)) { return UUcError_Generic; } - + error = ioObject->methods->rSetOSD(ioObject, inObjectSpecificData); UUmError_ReturnOnError(error); - + // the object group is now dirty OBJiObjectGroup_SetDirty(object_group, UUcTrue); @@ -2034,36 +2034,36 @@ OBJrObject_SetPosition( const M3tPoint3D *inRotation) { OBJtObjectGroup *object_group; - + UUmAssert(ioObject); - + // make sure the object isn't locked if (OBJrObject_IsLocked(ioObject)) { return; } - + // make sure the object group isn't locked object_group = OBJiObjectGroup_GetByType(ioObject->object_type); if (object_group == NULL) { return; } if (OBJiObjectGroup_IsLocked(object_group)) { return; } - + if (inPosition != NULL) { ioObject->position = *inPosition; } - + if (inRotation != NULL) { ioObject->rotation = *inRotation; - + while (ioObject->rotation.x < 0.0f) { ioObject->rotation.x += 360.0f; } while (ioObject->rotation.x >= 360.0f) { ioObject->rotation.x -= 360.0f; } - + while (ioObject->rotation.y < 0.0f) { ioObject->rotation.y += 360.0f; } while (ioObject->rotation.y >= 360.0f) { ioObject->rotation.y -= 360.0f; } while (ioObject->rotation.z < 0.0f) { ioObject->rotation.z += 360.0f; } while (ioObject->rotation.z >= 360.0f) { ioObject->rotation.z -= 360.0f; } } - + OBJrObject_UpdatePosition(ioObject); // clear the gunk flag @@ -2084,7 +2084,7 @@ OBJrObject_SetRotationMatrix( // make sure the object isn't locked if (OBJrObject_IsLocked(ioObject)) { return; } - + // construct the euler euler.order = MUcEulerOrderXYZs; euler = MUrMatrixToEuler(inMatrix, MUcEulerOrderXYZs); @@ -2109,10 +2109,10 @@ OBJrObject_Write( UUtUns32 bytes_available; UUtUns32 bytes_used; OBJtObjectGroup *object_group; - + // get the object group - object_group = OBJiObjectGroup_GetByType(inObject->object_type); - + object_group = OBJiObjectGroup_GetByType(inObject->object_type); + // don't write into the buffer if there isn't enough space bytes_available = *ioNumBytes; bytes_used = OBJcObjectGenericWriteSize + OBJrObject_GetOSDWriteSize(inObject); @@ -2121,38 +2121,38 @@ OBJrObject_Write( { // set the number of bytes written to the buffer *ioNumBytes = 0; - + return; } - + // write the object type OBDmWrite4BytesToBuffer(ioBuffer, inObject->object_type, UUtUns32, bytes_available, OBJcWrite_Little); - + // write the object ID OBDmWrite4BytesToBuffer(ioBuffer, inObject->object_id, UUtUns32, bytes_available, OBJcWrite_Little); - + // write the flag OBDmWrite4BytesToBuffer(ioBuffer, inObject->flags, UUtUns32, bytes_available, OBJcWrite_Little); - + // write the position OBDmWrite4BytesToBuffer(ioBuffer, inObject->position.x, float, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, inObject->position.y, float, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, inObject->position.z, float, bytes_available, OBJcWrite_Little); - + // write the rotation OBDmWrite4BytesToBuffer(ioBuffer, inObject->rotation.x, float, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, inObject->rotation.y, float, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, inObject->rotation.z, float, bytes_available, OBJcWrite_Little); - + // save the number of bytes used so far bytes_used = *ioNumBytes - bytes_available; - + // write the object specific data inObject->methods->rWrite(inObject, ioBuffer, &bytes_available); - + // bytes_available is now the number of bytes written into // the buffer by OBJmObject_Write() - + // return the number of bytes written into the buffer *ioNumBytes = bytes_used + bytes_available; } @@ -2175,10 +2175,10 @@ OBJiBinaryData_Load( UUtUns32 version; UUtUns32 num_bytes; OBJtObjectGroup *object_group; - + UUmAssert(inIdentifier); UUmAssert(ioBinaryData); - + object_group = OBJiObjectGroup_GetByName(inIdentifier); if (NULL == object_group) { @@ -2186,36 +2186,36 @@ OBJiBinaryData_Load( } OBJiObjectGroup_DeleteAllObjects(object_group); - + buffer = ioBinaryData->data; - + // read the version number OBDmGet4BytesFromBuffer(buffer, version, UUtUns32, inSwapIt); - + // get the size of the data chunk OBDmGet4BytesFromBuffer(buffer, num_bytes, UUtUns32, inSwapIt); while (num_bytes > 0) { UUtUns32 read_bytes; - + // process the data chunk OBJrObject_CreateFromBuffer((UUtUns16)version, inSwapIt, buffer, &read_bytes); - + // advance to next data chunk buffer += num_bytes; - + // get the size of the data chunk OBDmGet4BytesFromBuffer(buffer, num_bytes, UUtUns32, inSwapIt); } - + // set the locked and dirty flags OBJiObjectGroup_SetLocked(object_group, inLocked); OBJiObjectGroup_SetDirty(object_group, UUcFalse); - + if (inAllocated) { UUrMemory_Block_Delete(ioBinaryData); } - + return UUcError_None; } @@ -2226,15 +2226,15 @@ OBJiBinaryData_Register( { UUtError error; BDtMethods methods; - + methods.rLoad = OBJiBinaryData_Load; - + error = BDrRegisterClass( OBJcBinaryDataClass, &methods); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2251,7 +2251,7 @@ OBJiBinaryData_Save( UUtUns8 *temp_buffer = UUrAlignMemory(block); UUrMemory_Block_VerifyList(); - + // save the objects for (i = 0; i < OBJiObjectGroups_GetNumGroups(); i++) { @@ -2262,65 +2262,65 @@ OBJiBinaryData_Save( UUtUns8 *data; UUtUns8 *buffer; UUtUns32 num_bytes; - + object_group = OBJiObjectGroups_GetGroupByIndex(i); if (object_group == NULL) { continue; } if (OBJiObjectGroup_IsLocked(object_group) == UUcTrue) { continue; } if (OBJiObjectGroup_IsDirty(object_group) == UUcFalse) { continue; } if ((inObjectType != OBJcType_None) && (OBJiObjectGroup_GetType(object_group) != inObjectType)) { continue; } - + num_objects = OBJiObjectGroup_GetNumObjects(object_group); - + data_size = - sizeof(UUtUns32) + // version number - (sizeof(UUtUns32) * num_objects) + // sizes of the object data - OBJiObjectGroup_GetWriteSize(object_group) + // object data - sizeof(UUtUns32); // zero at end of file - + sizeof(UUtUns32) + // version number + (sizeof(UUtUns32) * num_objects) + // sizes of the object data + OBJiObjectGroup_GetWriteSize(object_group) + // object data + sizeof(UUtUns32); // zero at end of file + data = UUrMemory_Block_NewClear(data_size); if (data == NULL) { UUmAssert(!"Unable to allocate memory to save objects"); continue; } - + // set write variables buffer = data; num_bytes = data_size; - + // write the version number into the buffer OBDmWrite4BytesToBuffer(buffer, OBJcCurrentVersion, UUtUns32, num_bytes, OBJcWrite_Little); - + for (j = 0; j < num_objects; j++) { OBJtObject *object; UUtUns32 temp_num_bytes; - + UUrMemory_Clear(temp_buffer, OBJcMaxBufferSize); UUrMemory_Block_VerifyList(); - + object = OBJiObjectGroup_GetObject(object_group, j); if (object == NULL) continue; if (object->flags & OBJcObjectFlag_Temporary) continue; - + // write the object into the temp buffer temp_num_bytes = OBJcMaxBufferSize; OBJrObject_Write(object, temp_buffer, &temp_num_bytes); UUmAssert(temp_num_bytes == (OBJcObjectGenericWriteSize + OBJrObject_GetOSDWriteSize(object))); - + // align temp_num_bytes = UUmMakeMultiple(temp_num_bytes, 4); // write the number of bytes OBDmWrite4BytesToBuffer(buffer, temp_num_bytes, UUtUns32, num_bytes, OBJcWrite_Little); UUmAssert(temp_num_bytes <= num_bytes); - + // write the temp_buffer UUrMemory_MoveFast(temp_buffer, buffer, temp_num_bytes); - + buffer += temp_num_bytes; num_bytes -= temp_num_bytes; UUrMemory_Block_VerifyList(); } - + /* for (j = 0; j < num_objects; j++) { OBJtObject *object; @@ -2328,7 +2328,7 @@ OBJiBinaryData_Save( UUtUns32 length_of_chunk; UUrMemory_Block_VerifyList(); - + object = OBJiObjectGroup_GetObject(object_group, j); if (object == NULL) { continue; } @@ -2337,7 +2337,7 @@ OBJiBinaryData_Save( buffer += 4; UUmAssert(num_bytes > 4); num_bytes -= 4; - + // write the object into the buffer length_of_chunk = num_bytes; OBJrObject_Write(object, buffer, &length_of_chunk); @@ -2355,15 +2355,15 @@ OBJiBinaryData_Save( UUrMemory_Block_VerifyList(); }*/ - + UUrMemory_Block_VerifyList(); // there are no more objects for this file, write a size of zero, use j to hold the zero j = 0; OBDmWrite4BytesToBuffer(buffer, j, UUtUns32, num_bytes, OBJcWrite_Little); - + UUrMemory_Block_VerifyList(); - + level_id = (object_group->flags & OBJcObjectGroupFlag_CommonToAllLevels) ? 0 : ONrLevel_GetCurrentLevel(); // write the buffer to the binary datafile @@ -2376,10 +2376,10 @@ OBJiBinaryData_Save( inAutoSave); UUrMemory_Block_VerifyList(); - + // dispose of the buffer UUrMemory_Block_Delete(data); - + // the object group is no longer dirty if this wasn't an autosave if (inAutoSave == UUcFalse) { @@ -2402,13 +2402,13 @@ OBJrLevel_Load( UUtUns16 inLevelNumber) { UUtError error; - + // initialize the object list error = OBJiObjectGroups_LevelLoad(); UUmError_ReturnOnError(error); - + OBJrSelectedObjects_Select(NULL, UUcFalse); - + return UUcError_None; } @@ -2421,7 +2421,7 @@ OBJrLevel_Unload( // save the objects OBJiBinaryData_Save(OBJcType_None, UUcFalse); #endif - + OBJiObjectGroups_LevelUnload(); return; @@ -2443,24 +2443,24 @@ OBJiENVFile_GetNumNodes( UUtUns32 num_objects; UUtUns32 i; UUtUns32 num_nodes; - + num_nodes = 0; //////////////////////////////////////////////////////////////////////////////////////////////// //Furniture object_group = OBJiObjectGroup_GetByType(OBJcType_Furniture); if (object_group == NULL) { return 0; } - + num_objects = OBJiObjectGroup_GetNumObjects(object_group); - + for (i = 0; i < num_objects; i++) { OBJtOSD_Furniture *furniture_osd; - + object = OBJiObjectGroup_GetObject(object_group, i); if( !object ) return 0; if( object->object_type != OBJcType_Furniture) { continue; } - + furniture_osd = (OBJtOSD_Furniture*)object->object_data; num_nodes += (furniture_osd->furn_geom_array != NULL) ? furniture_osd->furn_geom_array->num_furn_geoms : 0; } @@ -2470,7 +2470,7 @@ OBJiENVFile_GetNumNodes( //////////////////////////////////////////////////////////////////////////////////////////////// //Turrets object_group = OBJiObjectGroup_GetByType(OBJcType_Turret); - num_objects = OBJiObjectGroup_GetNumObjects(object_group); + num_objects = OBJiObjectGroup_GetNumObjects(object_group); for (i = 0; i < num_objects; i++) { @@ -2487,7 +2487,7 @@ OBJiENVFile_GetNumNodes( //////////////////////////////////////////////////////////////////////////////////////////////// //Triggers object_group = OBJiObjectGroup_GetByType(OBJcType_Trigger); - num_objects = OBJiObjectGroup_GetNumObjects(object_group); + num_objects = OBJiObjectGroup_GetNumObjects(object_group); for (i = 0; i < num_objects; i++) { @@ -2505,18 +2505,18 @@ OBJiENVFile_GetNumNodes( //Consoles object_group = OBJiObjectGroup_GetByType(OBJcType_Console); if (object_group == NULL) { return 0; } - + num_objects = OBJiObjectGroup_GetNumObjects(object_group); - + for (i = 0; i < num_objects; i++) { OBJtOSD_Console *console_osd; - + object = OBJiObjectGroup_GetObject(object_group, i); if( !object ) continue; if( object->object_type != OBJcType_Console) { continue; } if( object->flags & OBJcObjectFlag_Temporary ) continue; - + console_osd = (OBJtOSD_Console*) object->object_data; num_nodes += console_osd->console_class->geometry_array->num_furn_geoms; } @@ -2527,18 +2527,18 @@ OBJiENVFile_GetNumNodes( object_group = OBJiObjectGroup_GetByType(OBJcType_Door); if (object_group == NULL) { return 0; } - + num_objects = OBJiObjectGroup_GetNumObjects(object_group); - + for (i = 0; i < num_objects; i++) { OBJtOSD_Door *door_osd; - + object = OBJiObjectGroup_GetObject(object_group, i); if( !object ) continue; if( object->object_type != OBJcType_Door) continue; if( object->flags & OBJcObjectFlag_Temporary ) continue; - + door_osd = (OBJtOSD_Door*) object->object_data; if (door_osd->door_class != NULL) { @@ -2556,7 +2556,7 @@ OBJiENVFile_GetNumNodes( } //COrConsole_Printf("doors %d", num_nodes); - + return num_nodes; } @@ -2577,7 +2577,7 @@ OBJiENVFile_WriteNode_Geometry( BFtFile *inDebugFile) { UUtError error; - char object_name[255]; + char object_name[255]; char *geom_name; MXtNode *node; MXtNode *optimized_node; @@ -2594,7 +2594,7 @@ OBJiENVFile_WriteNode_Geometry( UUtUns32 tri_faces_size; UUtUns32 materials_size; UUtUns32 markers_size; - + UUtUns32 index0; UUtUns32 index1; UUtUns32 index2; @@ -2603,14 +2603,14 @@ OBJiENVFile_WriteNode_Geometry( EPtEnvParticle *particle; M3tMatrix4x3 deform_matrix; - + char user_data[2048]; UUtUns32 user_data_length; char *particle_user_data_buf; char **particle_user_data; UUtUns32 *particle_user_data_length; - + if( inName ) UUrString_Copy( object_name, inName, 255 ); else @@ -2625,7 +2625,7 @@ OBJiENVFile_WriteNode_Geometry( { geom_name = object_name; } - + if( inDeformMatrix ) deform_matrix = *inDeformMatrix; else @@ -2639,7 +2639,7 @@ OBJiENVFile_WriteNode_Geometry( if (inGQFlags != 0) { strcat(user_data, "$type = ["UUmNL); - + for (i = 0; i < 32; i++) { if (inGQFlags & (1 << i)) @@ -2652,10 +2652,10 @@ OBJiENVFile_WriteNode_Geometry( } } } - + strcat(user_data, "]"UUmNL); } - + if (inLsData) { OBJtLSData *ls_data; @@ -2663,10 +2663,10 @@ OBJiENVFile_WriteNode_Geometry( ls_data = inLsData; // find the ls_data corresponding to this geometry if (ls_data != NULL) - { + { // write the light data strcat(user_data, "$ls = {"UUmNL); - + // write the light filter color strcat(user_data, "$filterColor = [ "); sprintf( @@ -2676,7 +2676,7 @@ OBJiENVFile_WriteNode_Geometry( ls_data->filter_color[1], ls_data->filter_color[2]); strcat(user_data, temp_buffer); - + // write the light type strcat(user_data, "$type = "); if (ls_data->light_flags & OBJcLightFlag_Type_Area) @@ -2692,7 +2692,7 @@ OBJiENVFile_WriteNode_Geometry( sprintf(temp_buffer, "point"UUmNL); } strcat(user_data, temp_buffer); - + // write the light distribution strcat(user_data, "$distribution = "); if (ls_data->light_flags & OBJcLightFlag_Dist_Diffuse) @@ -2704,15 +2704,15 @@ OBJiENVFile_WriteNode_Geometry( sprintf(temp_buffer, "spot"UUmNL); } strcat(user_data, temp_buffer); - + // write the light intensity sprintf(temp_buffer, "$intensity = %f"UUmNL, ls_data->light_intensity); strcat(user_data, temp_buffer); - + // write the light beam angle sprintf(temp_buffer, "$beamAngle = %f"UUmNL, ls_data->beam_angle); strcat(user_data, temp_buffer); - + // write the light field angle sprintf(temp_buffer, "$fieldAngle = %f"UUmNL, ls_data->field_angle); strcat(user_data, temp_buffer); @@ -2727,9 +2727,9 @@ OBJiENVFile_WriteNode_Geometry( if( inUserData ) strcat( user_data, inUserData ); strcat(user_data, "\0"); - + user_data_length = strlen(user_data) + 1; - + // ------------------------------ // allocate memory for the node node = (MXtNode*)UUrMemory_Block_NewClear(sizeof(MXtNode)); @@ -2738,7 +2738,7 @@ OBJiENVFile_WriteNode_Geometry( // copy the name and parentName into the node UUrString_Copy(node->name, geom_name, MXcMaxName); UUrString_Copy(node->parentName, "", MXcMaxName); - + // set the node data node->numPoints = (UUtUns16) geometry->pointArray->numPoints; node->numTriangles = (UUtUns16) geometry->triNormalIndexArray->numIndices; @@ -2753,7 +2753,7 @@ OBJiENVFile_WriteNode_Geometry( UUrSwap_2Byte(&node->numMaterials); UUrSwap_2Byte(&node->numMarkers); UUrSwap_4Byte(&node->userDataCount); - + for (i = 0; i < 4; i++) { UUrSwap_4Byte(&node->matrix.m[i][0]); @@ -2761,13 +2761,13 @@ OBJiENVFile_WriteNode_Geometry( UUrSwap_4Byte(&node->matrix.m[i][2]); } #endif - + // ------------------------------ // make the points points_size = sizeof(MXtPoint) * geometry->pointArray->numPoints; points = (MXtPoint*)UUrMemory_Block_NewClear(points_size); UUmError_ReturnOnNull(points); - + for (i = 0; i < geometry->pointArray->numPoints; i++) { #if 1 @@ -2778,9 +2778,9 @@ OBJiENVFile_WriteNode_Geometry( #endif points[i].normal = geometry->vertexNormalArray->vectors[i]; points[i].uv = geometry->texCoordArray->textureCoords[i]; - + points[i].uv.v = 1.0f - points[i].uv.v; - + #if (UUmEndian == UUmEndian_Big) UUrSwap_4Byte(&points[i].point.x); UUrSwap_4Byte(&points[i].point.y); @@ -2792,48 +2792,48 @@ OBJiENVFile_WriteNode_Geometry( UUrSwap_4Byte(&points[i].uv.v); #endif } - + // ------------------------------ // make the triangles tri_faces_size = sizeof(MXtFace) * geometry->triNormalIndexArray->numIndices; tri_faces = (MXtFace*)UUrMemory_Block_NewClear(tri_faces_size); UUmError_ReturnOnNull(tri_faces); - + curIndexPtr = geometry->triStripArray->indices; - + for (i = 0; i < geometry->triNormalIndexArray->numIndices; i++) { UUtUns32 normal_index; M3tVector3D v1; M3tVector3D v2; - + index2 = *curIndexPtr++; - + if (index2 & 0x80000000) { index0 = index2 & 0x7FFFFFFF; index1 = *curIndexPtr++; index2 = *curIndexPtr++; - + UUmAssert((index0 & 0x80000000) != 0x80000000); UUmAssert((index1 & 0x80000000) != 0x80000000); UUmAssert((index2 & 0x80000000) != 0x80000000); } - + normal_index = geometry->triNormalIndexArray->indices[i]; UUmAssert((normal_index & 0x80000000) != 0x80000000); - + UUmAssert(index0 < UUcMaxUns16); UUmAssert(index1 < UUcMaxUns16); UUmAssert(index2 < UUcMaxUns16); - + MUmVector_Subtract(v1, geometry->pointArray->points[index1], geometry->pointArray->points[index0]); MUmVector_Subtract(v2, geometry->pointArray->points[index2], geometry->pointArray->points[index0]); - + tri_faces[i].indices[0] = (UUtUns16) index0; tri_faces[i].indices[1] = (UUtUns16) index1; tri_faces[i].indices[2] = (UUtUns16) index2; - tri_faces[i].indices[3] = 0; + tri_faces[i].indices[3] = 0; tri_faces[i].dont_use_this_normal = geometry->triNormalArray->vectors[normal_index]; tri_faces[i].material = 0; tri_faces[i].pad = 0; @@ -2852,17 +2852,17 @@ OBJiENVFile_WriteNode_Geometry( index0 = index1; index1 = index2; } - + // ------------------------------ // make the materials materials_size = sizeof(MXtMaterial); materials = (MXtMaterial*)UUrMemory_Block_NewClear(materials_size); UUmError_ReturnOnNull(materials); - + { M3tTextureMap *texture; char texture_name[ MXcMaxName]; - + if( inTextureMap ) { texture = inTextureMap; @@ -2872,33 +2872,33 @@ OBJiENVFile_WriteNode_Geometry( texture = geometry->baseMap; } - if( !texture ) + if( !texture ) { UUrString_Copy( texture_name, "null_material", MXcMaxName); - } - else + } + else { UUrString_Copy( texture_name, TMrInstance_GetInstanceName(texture), MXcMaxName); } UUrString_Copy(materials->name, texture_name, MXcMaxName); materials->alpha = 1.0f; - + for (i = 0; i < MXcMapping_Count; i++) { UUrString_Copy(materials->maps[i].name, "", MXcMaxName); } - + UUrString_Copy(materials->maps[MXcMapping_DI].name, texture_name, MXcMaxName); materials->maps[MXcMapping_DI].amount = 1.0f; } - + #if (UUmEndian == UUmEndian_Big) UUrSwap_4Byte(&materials->alpha); UUrSwap_4Byte(&materials->maps[MXcMapping_DI].amount); #endif - - if (inParticleCount > 0) + + if (inParticleCount > 0) { char temp_buffer[256]; @@ -2978,21 +2978,21 @@ OBJiENVFile_WriteNode_Geometry( // write the node error = BFrFile_Write(inFile, sizeof(MXtNode), node); UUmError_ReturnOnError(error); - + // ------------------------------ // write user data BFrFile_Write(inFile, user_data_length, user_data); - + // ------------------------------ // write points error = BFrFile_Write(inFile, sizeof(MXtPoint) * node->numPoints, node->points); UUmError_ReturnOnError(error); - + // ------------------------------ // write triangles error = BFrFile_Write(inFile, sizeof(MXtFace) * node->numTriangles, node->triangles); UUmError_ReturnOnError(error); - + // ------------------------------ // write quads error = BFrFile_Write(inFile, sizeof(MXtFace) * node->numQuads, node->quads); @@ -3003,7 +3003,7 @@ OBJiENVFile_WriteNode_Geometry( for (i = 0; i < inParticleCount; i++) { error = BFrFile_Write(inFile, sizeof(MXtMarker), &markers[i]); UUmError_ReturnOnError(error); - + error = BFrFile_Write(inFile, particle_user_data_length[i], particle_user_data[i]); UUmError_ReturnOnError(error); } @@ -3012,7 +3012,7 @@ OBJiENVFile_WriteNode_Geometry( // write materials error = BFrFile_Write(inFile, materials_size, materials); UUmError_ReturnOnError(error); - + // ------------------------------ // free the memory UUrMemory_Block_Delete(node); @@ -3077,11 +3077,11 @@ static UUtError OBJiENVFile_WriteNode_GeometryArray( ls_data = NULL; } } - + sprintf( user_data, "$node_index = %d"UUmNL, g ); if( inUserData ) strcat( user_data, inUserData ); - + new_flags = inFurnGeomArray->furn_geom[g].gq_flags; if (((new_flags & inTestFlags_Require) == inTestFlags_Require) && @@ -3089,7 +3089,7 @@ static UUtError OBJiENVFile_WriteNode_GeometryArray( new_flags = (new_flags & ~inTestFlags_TurnOff) | inTestFlags_TurnOn; } new_flags = ((new_flags & ~inGQFlags_TurnOff) | inGQFlags_TurnOn); - + error = OBJiENVFile_WriteNode_Geometry( inFile, inMatrix, inFurnGeomArray->furn_geom[g].geometry, new_flags, ls_data, inName, user_data, inDeformMatrix, inParticleCount, inParticleArray, inTextureMap, inDebugFile ); @@ -3121,16 +3121,16 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) M3tMatrix4x3 m1, m2; M3tMatrix4x3 m1b, m2b; UUtUns32 flags, tag; - + // get the current level number level_num = ONrLevel_GetCurrentLevel(); if (level_num == 0) { return UUcError_Generic; } - + // create the env file ref sprintf(filename, "L%d_Gunk.ENV", level_num); error = BFrFileRef_MakeFromName(filename, &env_file_ref); UUmError_ReturnOnError(error); - + // create the .ENV file if it doesn't already exist if (BFrFileRef_FileExists(env_file_ref) == UUcFalse) { @@ -3138,11 +3138,11 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) error = BFrFile_Create(env_file_ref); UUmError_ReturnOnError(error); } - + // open the object.env file error = BFrFile_Open(env_file_ref, "rw", &env_file); UUmError_ReturnOnError(error); - + // set the position to 0 error = BFrFile_SetPos(env_file, 0); UUmError_ReturnOnError(error); @@ -3152,7 +3152,7 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) sprintf(filename, "L%d_GunkDebug.txt", level_num); error = BFrFileRef_MakeFromName(filename, &debug_file_ref); UUmError_ReturnOnError(error); - + // create the debug file if it doesn't already exist if (BFrFileRef_FileExists(debug_file_ref) == UUcFalse) { @@ -3160,22 +3160,22 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) error = BFrFile_Create(debug_file_ref); UUmError_ReturnOnError(error); } - + // open the debug file error = BFrFile_Open(debug_file_ref, "w", &debug_file); - UUmError_ReturnOnError(error); - + UUmError_ReturnOnError(error); + BFrFile_Printf(debug_file, "debug info for level %d gunk file..."UUmNL, level_num); BFrFile_Printf(debug_file, UUmNL); } else { debug_file_ref = NULL; debug_file = NULL; } - + // create the MXtHeader header = (MXtHeader*)UUrMemory_Block_NewClear(sizeof(MXtHeader)); UUmError_ReturnOnNull(header); - + UUrString_Copy(header->stringENVF, "ENVF", 5); header->version = 0; header->numNodes = (UUtUns16) OBJiENVFile_GetNumNodes(); @@ -3184,17 +3184,17 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) OBJgNodeCount = OBJiENVFile_GetNumNodes(); OBJgNodeActual = 0; - + #if (UUmEndian == UUmEndian_Big) UUrSwap_4Byte(&header->version); UUrSwap_2Byte(&header->numNodes); - UUrSwap_2Byte(&header->time); + UUrSwap_2Byte(&header->time); #endif - + // write the header error = BFrFile_Write(env_file, sizeof(MXtHeader), header); UUmError_ReturnOnError(error); - + // dispose of the memory UUrMemory_Block_Delete(header); header = NULL; @@ -3217,7 +3217,7 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) object = OBJiObjectGroup_GetObject(object_group, i); if ((object == NULL) || (object->object_type != OBJcType_Furniture)) { continue; } if( object->flags & OBJcObjectFlag_Temporary ) continue; - + furniture_osd = (OBJtOSD_Furniture*) object->object_data; tag = OBJmMakeObjectTag(object_group->object_typeindex, object); @@ -3229,7 +3229,7 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) MUrMatrix_Identity(&matrix); MUrMatrixStack_Translate(&matrix, &object->position); MUrMatrixStack_Matrix(&matrix, &m1); - + if (debug_file) { BFrFile_Printf(debug_file, "furniture #%d geom %s furntag %s, typeindex %d objID %d -> tag %d"UUmNL, i, furniture_osd->furn_geom_name, furniture_osd->furn_tag, object_group->object_typeindex, object->object_id, tag); @@ -3240,8 +3240,8 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) // make sure that they get tagged as AI impassable. error = OBJiENVFile_WriteNode_GeometryArray(env_file, &matrix, furniture_osd->furn_geom_array, furniture_osd->ls_data_array, object_name, user_data, NULL, furniture_osd->num_particles, furniture_osd->particle, - AKcGQ_Flag_No_Occlusion | AKcGQ_Flag_Furniture, 0, - AKcGQ_Flag_No_Object_Collision | AKcGQ_Flag_Invisible, AKcGQ_Flag_No_Collision | AKcGQ_Flag_No_Character_Collision, + AKcGQ_Flag_No_Occlusion | AKcGQ_Flag_Furniture, 0, + AKcGQ_Flag_No_Object_Collision | AKcGQ_Flag_Invisible, AKcGQ_Flag_No_Collision | AKcGQ_Flag_No_Character_Collision, AKcGQ_Flag_AIImpassable, 0, NULL, debug_file); if (error != UUcError_None) { break; } } @@ -3253,7 +3253,7 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) //Turrets object_group = OBJiObjectGroup_GetByType(OBJcType_Turret); if (object_group == NULL) { return UUcError_Generic; } - + if (debug_file) { BFrFile_Printf(debug_file, "TURRETS"UUmNL); BFrFile_Printf(debug_file, "======="UUmNL); @@ -3268,7 +3268,7 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) object = OBJiObjectGroup_GetObject(object_group, i); if ((object == NULL) || (object->object_type != OBJcType_Turret)) { continue; } if( object->flags & OBJcObjectFlag_Temporary ) continue; - + turret_osd = (OBJtOSD_Turret*) object->object_data; tag = OBJmMakeObjectTag(object_group->object_typeindex, object); @@ -3280,10 +3280,10 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) MUrMatrix_Identity(&matrix); MUrMatrixStack_Translate(&matrix, &object->position); MUrMatrixStack_Matrix(&matrix, &m1); - + // always set the no occlusion flag flags = (turret_osd->turret_class->base_gq_flags | AKcGQ_Flag_No_Occlusion); - + if (debug_file) { BFrFile_Printf(debug_file, "turret #%d class %s ID %d, typeindex %d objID %d -> tag %d"UUmNL, i, turret_osd->turret_class_name, turret_osd->id, object_group->object_typeindex, object->object_id, tag); @@ -3299,7 +3299,7 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) // Triggers object_group = OBJiObjectGroup_GetByType(OBJcType_Trigger); if (object_group == NULL) { return UUcError_Generic; } - + if (debug_file) { BFrFile_Printf(debug_file, "TRIGGERS"UUmNL); BFrFile_Printf(debug_file, "========"UUmNL); @@ -3314,7 +3314,7 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) object = OBJiObjectGroup_GetObject(object_group, i); if ((object == NULL) || (object->object_type != OBJcType_Trigger)) { continue; } if( object->flags & OBJcObjectFlag_Temporary ) continue; - + trigger_osd = (OBJtOSD_Trigger*) object->object_data; tag = OBJmMakeObjectTag(object_group->object_typeindex, object); @@ -3329,7 +3329,7 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) // always set the no occlusion flag flags = (trigger_osd->trigger_class->base_gq_flags | AKcGQ_Flag_No_Occlusion); - + if (debug_file) { BFrFile_Printf(debug_file, "trigger #%d class %s ID %d, typeindex %d objID %d -> tag %d"UUmNL, i, trigger_osd->trigger_class_name, trigger_osd->id, object_group->object_typeindex, object->object_id, tag); @@ -3360,7 +3360,7 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) object = OBJiObjectGroup_GetObject(object_group, i); if ((object == NULL) || (object->object_type != OBJcType_Console)) { continue; } if( object->flags & OBJcObjectFlag_Temporary ) continue; - + console_osd = (OBJtOSD_Console*) object->object_data; OBJrObject_GetRotationMatrix(object, &m1); @@ -3383,7 +3383,7 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) } //COrConsole_Printf("consoles %d", OBJgNodeActual); - + //////////////////////////////////////////////////////////////////////////////////////////////////// // The Doors @@ -3405,9 +3405,9 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) object = OBJiObjectGroup_GetObject(object_group, i); if( !object || (object->object_type != OBJcType_Door)) continue; if( object->flags & OBJcObjectFlag_Temporary ) continue; - + door_osd = (OBJtOSD_Door*) object->object_data; - + if (door_osd->door_class == NULL) continue; @@ -3454,19 +3454,19 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) error = OBJiENVFile_WriteNode_GeometryArray(env_file, &m2b, door_osd->door_class->geometry_array[0], NULL, object_name, user_data, NULL, 0, NULL, gq_flags, 0, 0, 0, 0, 0, door_osd->door_texture_ptr[1], debug_file ); } if (error != UUcError_None) { break; } - + } } //COrConsole_Printf("doors %d", OBJgNodeActual); - + // set the end of the file BFrFile_SetEOF(env_file); - + // close the file BFrFile_Close(env_file); env_file = NULL; - + // delete the file ref BFrFileRef_Dispose(env_file_ref); env_file_ref = NULL; @@ -3486,7 +3486,7 @@ UUtError OBJrENVFile_Write(UUtBool inDebug) if (OBJgNodeCount != OBJgNodeActual) { COrConsole_Printf("FAILED TO WRITE OUT ENV FILE, predicted %d wrote %d", OBJgNodeCount, OBJgNodeActual); } - + return UUcError_None; } @@ -3509,20 +3509,20 @@ OBJrFlagTXTFile_Write( UUtUns32 i; UUtUns32 num_objects; OBJtObjectGroup *object_group; - + // get the object group object_group = OBJiObjectGroup_GetByType(OBJcType_Flag); if (object_group == NULL) { return UUcError_Generic; } - + // get the current level number level_num = ONrLevel_GetCurrentLevel(); if (level_num == 0) { return UUcError_Generic; } - + // create the env file ref sprintf(filename, "L%d_Flags.txt", level_num); error = BFrFileRef_MakeFromName(filename, &flag_file_ref); UUmError_ReturnOnError(error); - + // create the .TXT file if it doesn't already exist if (BFrFileRef_FileExists(flag_file_ref) == UUcFalse) { @@ -3530,15 +3530,15 @@ OBJrFlagTXTFile_Write( error = BFrFile_Create(flag_file_ref); UUmError_ReturnOnError(error); } - + // open the object.env file error = BFrFile_Open(flag_file_ref, "rw", &flag_file); UUmError_ReturnOnError(error); - + // set the position to 0 error = BFrFile_SetPos(flag_file, 0); UUmError_ReturnOnError(error); - + // write the flags num_objects = OBJiObjectGroup_GetNumObjects(object_group); for (i = 0; i < num_objects; i++) @@ -3546,33 +3546,33 @@ OBJrFlagTXTFile_Write( OBJtObject *object; OBJtOSD_All osd_all; char string[1024]; - + object = OBJiObjectGroup_GetObject(object_group, i); if (object == NULL) { continue; } - + OBJrObject_GetObjectSpecificData(object, &osd_all); - + // format each line as: // flag_name flag_note OBJrObject_GetName(object, string, 1024); strcat(string, "\t"); strcat(string, osd_all.osd.flag_osd.note); strcat(string, UUmNL); - + BFrFile_Write(flag_file, strlen(string), string); } - + // set the end of the file BFrFile_SetEOF(flag_file); - + // close the file BFrFile_Close(flag_file); flag_file = NULL; - + // delete the file ref BFrFileRef_Dispose(flag_file_ref); flag_file_ref = NULL; - + return UUcError_None; } #endif @@ -3589,21 +3589,21 @@ OBJrSelectedObjects_Delete( { UUtUns32 num_objects; UUtUns32 i; - + // delete all of the selected objects pointers num_objects = UUrMemory_Array_GetUsedElems(OBJgSelectedObjects); for (i = 0; i < num_objects; i++) { OBJtObject *object; - + // get a currently selected object object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { continue; } - + // delete the object OBJrObject_Delete(object); } - + // there are no longer any objects selected so the selection can't be locked OBJrSelectedObjects_Lock_Set(UUcFalse); } @@ -3614,7 +3614,7 @@ OBJrSelectedObjects_GetNumSelected( void) { return UUrMemory_Array_GetUsedElems(OBJgSelectedObjects); -} +} // ---------------------------------------------------------------------- OBJtObject* @@ -3623,15 +3623,15 @@ OBJrSelectedObjects_GetSelectedObject( { OBJtObject **object_list; UUtUns32 num_objects; - + num_objects = OBJrSelectedObjects_GetNumSelected(); if ((inIndex >= num_objects) || (num_objects == 0)) { return NULL; } - + object_list = (OBJtObject**)UUrMemory_Array_GetMemory(OBJgSelectedObjects); - + return object_list[inIndex]; } @@ -3648,9 +3648,9 @@ OBJiSelectedObjects_Initialize( 0, 10); UUmError_ReturnOnNull(OBJgSelectedObjects); - + OBJrSelectedObjects_Lock_Set(UUcFalse); - + return UUcError_None; } @@ -3677,7 +3677,7 @@ OBJrSelectedObjects_MoveCameraToSelection( MUmVector_Add(position_sum, position_sum, object->position); num_found++; } - + if (num_found == 0) { return; } @@ -3704,11 +3704,11 @@ OBJrSelectedObjects_IsObjectSelected( UUtUns32 num_objects; UUtUns32 i; UUtBool found; - + // find inObject in the selected objects list object_list = (OBJtObject**)UUrMemory_Array_GetMemory(OBJgSelectedObjects); num_objects = OBJrSelectedObjects_GetNumSelected(); - + found = UUcFalse; for (i = 0; i < num_objects; i++) { @@ -3718,7 +3718,7 @@ OBJrSelectedObjects_IsObjectSelected( break; } } - + return found; } @@ -3748,22 +3748,22 @@ OBJrSelectedObjects_Select( UUtUns32 index; UUtBool mem_moved; OBJtObject **object_list; - + if (OBJgSelectedObjects_Locked == UUcTrue) { return; } - + // clear the list if the item isn't being added to the current list if (inAddToList == UUcFalse) { OBJrSelectedObjects_UnselectAll(); } - + // if inObject is null then there is nothing to add so leave if (inObject == NULL) { return; } - + // make room in the list for a new element error = UUrMemory_Array_GetNewElement(OBJgSelectedObjects, &index, &mem_moved); if (error != UUcError_None) { return; } - + // add the element to the list object_list = (OBJtObject**)UUrMemory_Array_GetMemory(OBJgSelectedObjects); object_list[index] = inObject; @@ -3785,11 +3785,11 @@ OBJrSelectedObjects_Unselect( { UUtUns32 i; OBJtObject **object_list; - + if (OBJgSelectedObjects_Locked == UUcTrue) { return; } object_list = (OBJtObject**)UUrMemory_Array_GetMemory(OBJgSelectedObjects); - + for (i = 0; i < OBJrSelectedObjects_GetNumSelected(); i++) { if (object_list[i] == inObject) @@ -3882,7 +3882,7 @@ OBJrDrawObjects( UUrStallTimer_End(&draw_objects_timer, "OBJrDrawObjects - OBJiObjectGroups_Draw"); // autosave -#if TOOL_VERSION +#if TOOL_VERSION if (OBJgAutoSaveTime < UUrMachineTime_Sixtieths()) { UUrStallTimer_Begin(&draw_objects_timer); @@ -3909,38 +3909,38 @@ OBJrGetObjectUnderPoint( M3tPoint3D camera_position; M3tVector3D intersect_vector; OBJtObject *closest_to_camera; - + UUtUns32 i; UUtUns32 num_objects; - + float min_distance; M3tPoint3D start_point; M3tPoint3D end_point; - + UUtUns32 j; UUtUns32 num_groups; - + // get the active camera M3rCamera_GetActive(&camera); UUmAssert(camera); - + // get the point on the near clip plane where the user clicked M3rPick_ScreenToWorld(camera, (UUtUns16)inPoint->x, (UUtUns16)inPoint->y, &world_point); - + // get the camera position camera_position = CArGetLocation(); - + // build a vector from the camera to the point on the near clip plane intersect_vector.x = world_point.x - camera_position.x; intersect_vector.y = world_point.y - camera_position.y; intersect_vector.z = world_point.z - camera_position.z; - + // normalize MUrNormalize(&intersect_vector); - + // multiply by some large number (5,000) to get a long line MUrVector_SetLength(&intersect_vector, 5000.0f); - + // set up vars for collision detection closest_to_camera = NULL; min_distance = 1000000.0f; @@ -3948,45 +3948,45 @@ OBJrGetObjectUnderPoint( end_point.x += intersect_vector.x; end_point.y += intersect_vector.y; end_point.z += intersect_vector.z; - + // go through all of the object groups num_groups = OBJiObjectGroups_GetNumGroups(); for (j = 0; j < num_groups; j++) { OBJtObjectGroup *object_group; - + // get the object group object_group = OBJiObjectGroups_GetGroupByIndex(j); - + // don't select objects which aren't visible if (OBJrObjectType_GetVisible(OBJiObjectGroup_GetType(object_group)) == UUcFalse) { continue; } - + // loop through each object and find the one closest to the camera that // collides with the line num_objects = OBJiObjectGroup_GetNumObjects(object_group); for (i = 0; i < num_objects; i++) { OBJtObject *object; - + object = OBJiObjectGroup_GetObject(object_group, i); - + // if the object collides with the line, see if it is the closest to the camera if (OBJrObject_IntersectsLine(object, &start_point, &end_point)) { M3tVector3D camera_to_object; float distance_to_object; - + // make the vector from the camera to the object camera_to_object.x = object->position.x - camera_position.x; camera_to_object.y = object->position.y - camera_position.y; camera_to_object.z = object->position.z - camera_position.z; - + // calculate the length from the camera to the object distance_to_object = MUrVector_Length(&camera_to_object); - + if (distance_to_object < min_distance) { // save closest object to camera @@ -3996,7 +3996,7 @@ OBJrGetObjectUnderPoint( } } } - + return closest_to_camera; } @@ -4010,71 +4010,71 @@ OBJrInitialize( // Initialize game Mechanics error = ONrMechanics_Initialize(); UUmError_ReturnOnError(error); - + OBJiSelectedObjects_Initialize(); - + // initialize the binary data class error = OBJiBinaryData_Register(); UUmError_ReturnOnError(error); - + // initialize the object groups error = OBJiObjectGroups_Initialize(); UUmError_ReturnOnError(error); - + // initialize the object types error = OBJrCharacter_Initialize(); UUmError_ReturnOnError(error); error = OBJrCombat_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrConsole_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrDoor_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrFlag_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrFurniture_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrMelee_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrNeutral_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrParticle_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrPatrolPath_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrPowerUp_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrSound_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrTrigger_Initialize(); UUmError_ReturnOnError(error); error = OBJrTriggerVolume_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrTurret_Initialize(); UUmError_ReturnOnError(error); - + error = OBJrWeapon_Initialize(); UUmError_ReturnOnError(error); - + // init vars OBJrMoveMode_Set(OBJcMoveMode_All); OBJrRotateMode_Set(OBJcRotateMode_XYZ); OBJgAutoSaveTime = UUrMachineTime_Sixtieths() + OBJcAutoSaveDelta; - + return UUcError_None; } @@ -4103,7 +4103,7 @@ OBJrTerminate( #endif OBJiSelectedObjects_Terminate(); - + // terminate the object groups OBJiObjectGroups_Terminate(); @@ -4135,7 +4135,7 @@ static UUtBool OWiCompare_Object_By_Name(UUtUns32 inA, UUtUns32 inB) void OBJrObjectType_BuildListBox(OBJtObjectType inObjectType, WMtWindow *ioListBox, UUtBool inAllowNone) { - // construct the initial state of the listbox + // construct the initial state of the listbox OBJtObject **list = NULL; UUtUns32 count; UUtUns32 itr, base; @@ -4207,7 +4207,7 @@ static UUtBool OBJiObject_Enum_ObjectType( OBJtObjectType inObjectType, const ch { return UUcTrue; } - + static UUtBool OBJiObject_Enum_SearchRequest( OBJtObject *inObject, UUtUns32 inUserData ) { OBJtObjectSearchRequest *request; @@ -4228,11 +4228,11 @@ OBJtObject* OBJrObject_FindByID( UUtUns32 inID ) OBJtObjectGroup **object_group_list; UUtUns32 num_groups; UUtUns32 i; - + // intialize request.object = NULL; request.id = inID; - + // make sure the object group list exists object_group_list = (OBJtObjectGroup**)UUrMemory_Array_GetMemory(OBJgObjectGroups); if (object_group_list) @@ -4245,7 +4245,7 @@ OBJtObject* OBJrObject_FindByID( UUtUns32 inID ) return request.object; } } - + return NULL; } @@ -4257,7 +4257,7 @@ UUtError StringToBitMask( UUtUns32 *ioMask, char* inString ) UUtUns32 value; UUtUns32 bit; UUtError error; - + internal = NULL; mask = 0; @@ -4267,7 +4267,7 @@ UUtError StringToBitMask( UUtUns32 *ioMask, char* inString ) error = UUrString_To_Uns32( str, &value ); if( error != UUcError_None ) return error; - + bit = 1 << value; mask = mask | bit; @@ -4318,12 +4318,12 @@ static UUtBool OWrOSD_ChooseName(OBJtObjectType inObjectType, OBJtOSD_All *inOSD OBJrObject_OSD_GetName(inObjectType, inOSD, new_src_string, sizeof(new_src_string)); gotten_string = WMrDialog_GetString( - NULL, - inPrompt, - inPrompt, - new_src_string, - new_dst_string, - SLcScript_MaxNameLength, + NULL, + inPrompt, + inPrompt, + new_src_string, + new_dst_string, + SLcScript_MaxNameLength, NULL); if (gotten_string != NULL) { @@ -4399,7 +4399,7 @@ OWiChooseObject_Callback( rebuild_list_box = UUcTrue; break; - + case WMcMessage_Destroy: break; @@ -4408,7 +4408,7 @@ OWiChooseObject_Callback( { } break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -4430,7 +4430,7 @@ OWiChooseObject_Callback( error = OBJrObject_OSD_SetDefaults(object_type, &new_object_data); // OBJrObjectType_GetUniqueOSD(object_type, &new_object_data); if (error == UUcError_None) { - got_new_name = OWrOSD_ChooseName(object_type, &new_object_data, "New Name"); + got_new_name = OWrOSD_ChooseName(object_type, &new_object_data, "New Name"); if (got_new_name) { error = OWrTools_CreateObject(object_type, &new_object_data); @@ -4438,7 +4438,7 @@ OWiChooseObject_Callback( selected_object = OBJrSelectedObjects_GetSelectedObject(0); rebuild_list_box = UUcTrue; } - } + } } } break; @@ -4458,18 +4458,18 @@ OWiChooseObject_Callback( got_duplicate_name = OWrOSD_ChooseName(object_type, &duplicate_object, "Duplicate's Name"); if (got_duplicate_name) { - OBJrObject_New(object_type, &duplicate_position, &duplicate_rotation, &duplicate_object); + OBJrObject_New(object_type, &duplicate_position, &duplicate_rotation, &duplicate_object); selected_object = OBJrSelectedObjects_GetSelectedObject(0); rebuild_list_box = UUcTrue; - } - } + } + } break; case cChooseObject_Delete: if (NULL != selected_object) { OBJrObject_Delete(selected_object); rebuild_list_box = UUcTrue; - } + } break; case cChooseObject_GoTo: @@ -4490,7 +4490,7 @@ OWiChooseObject_Callback( break; } break; - + default: handled = UUcFalse; break; @@ -4532,7 +4532,7 @@ OWiChooseObject_Callback( WMrDialog_ModalEnd(inDialog, result_object); } - + return handled; } @@ -4570,7 +4570,7 @@ UUtError OBJrObjectType_GetObjectList( OBJtObjectType inObjectType, OBJtObject * group = OBJiObjectGroup_GetByType( inObjectType ); UUmAssert( group ); UUmError_ReturnOnNull( group ); - if( !group->object_list ) + if( !group->object_list ) { *ioObjectCount = 0; *ioList = NULL; diff --git a/OniProj/OniGameSource/Oni_Object/Oni_Object.h b/OniProj/OniGameSource/Oni_Object/Oni_Object.h index 0da2955..684eb87 100644 --- a/OniProj/OniGameSource/Oni_Object/Oni_Object.h +++ b/OniProj/OniGameSource/Oni_Object/Oni_Object.h @@ -173,7 +173,7 @@ enum OBJcMoveMode_UD = 0x0002, /* up/down */ OBJcMoveMode_FB = 0x0004, /* forward/backward */ OBJcMoveMode_Wall = 0x0008, /* stick to walls (overrides forward/backward) */ - + OBJcMoveMode_All = (OBJcMoveMode_LR | OBJcMoveMode_UD | OBJcMoveMode_FB) }; @@ -182,7 +182,7 @@ enum OBJcRotateMode_XY = 0x0001, OBJcRotateMode_XZ = 0x0002, OBJcRotateMode_YZ = 0x0004, - + OBJcRotateMode_XYZ = (OBJcRotateMode_XY | OBJcRotateMode_XZ | OBJcRotateMode_XY) }; @@ -214,13 +214,13 @@ enum OBJcSearch_PatrolPathID = 0x0002 }; -enum +enum { OBJcSearch_CombatName = 0x0001, OBJcSearch_CombatID = 0x0002 }; -enum +enum { OBJcSearch_MeleeName = 0x0001, OBJcSearch_MeleeID = 0x0002 @@ -232,7 +232,7 @@ enum OBJcSearch_TriggerVolumeID = 0x0002 }; -enum +enum { OBJcSearch_NeutralName = 0x0001, OBJcSearch_NeutralID = 0x0002 @@ -262,14 +262,14 @@ enum { OBJcLightFlag_None = 0x0000, OBJcLightFlag_HasLight = 0x0001, - + OBJcLightFlag_Type_Point = 0x0010, OBJcLightFlag_Type_Linear = 0x0020, OBJcLightFlag_Type_Area = 0x0040, - + OBJcLightFlag_Dist_Diffuse = 0x0100, OBJcLightFlag_Dist_Spot = 0x0200 - + }; // ====================================================================== @@ -285,12 +285,12 @@ typedef UUtBool OBJtObjectType inObjectType, const char *inName, UUtUns32 inUserData); - + typedef UUtBool (*OBJtEnumCallback_Object)( OBJtObject *inObject, UUtUns32 inUserData); - + typedef UUtBool (*OBJtEnumCallback_ObjectName)( const char *inName, @@ -326,7 +326,7 @@ typedef void (*OBJtMethod_OSD_SetName)( OBJtOSD_All *inObject, const char *inName); - + typedef void (*OBJtMethod_GetOSD)( const OBJtObject *inObject, @@ -346,11 +346,11 @@ typedef UUtError (*OBJtMethod_New)( OBJtObject *inObject, const OBJtOSD_All *inOSD); - + typedef UUtError (*OBJtMethod_SetDefaults)( OBJtOSD_All *outOSD); - + typedef UUtUns32 (*OBJtMethod_Read)( OBJtObject *inObject, @@ -361,7 +361,7 @@ typedef UUtUns32 typedef void (*OBJtMethod_UpdatePosition)( OBJtObject *inObject); - + typedef UUtError (*OBJtMethod_SetOSD)( OBJtObject *inObject, @@ -372,7 +372,7 @@ typedef UUtError OBJtObject *inObject, UUtUns8 *ioBuffer, UUtUns32 *ioBufferSize); - + typedef const char * (*OBJtMethod_IsInvalid)( OBJtObject *inObject); @@ -380,7 +380,7 @@ typedef const char * typedef UUtError (*OBJtMethod_LevelBegin)( void); - + typedef UUtError (*OBJtMethod_LevelEnd)( void); @@ -420,11 +420,11 @@ typedef struct OBJtMethods OBJtMethod_OSD_SetName rOSDSetName; OBJtMethod_IntersectsLine rIntersectsLine; OBJtMethod_UpdatePosition rUpdatePosition; - + OBJtMethod_GetOSD rGetOSD; OBJtMethod_GetOSDWriteSize rGetOSDWriteSize; OBJtMethod_SetOSD rSetOSD; - + OBJtMethod_Write rWrite; OBJtMethod_Read rRead; @@ -434,7 +434,7 @@ typedef struct OBJtMethods OBJtMethod_SetClassVisible rSetClassVisible; OBJtMethod_GetUniqueOSD rGetUniqueOSD; - + } OBJtMethods; struct OBJtObject @@ -446,7 +446,7 @@ struct OBJtObject M3tPoint3D rotation; OBJtMethods *methods; ONtMechanicsClass *mechanics_class; - UUtUns32 object_data[0]; + UUtUns32 object_data[0]; }; // ---------------------------------------------------------------------- #define OBJcTemplate_LSData UUm4CharToUns32('O', 'B', 'L', 'S') @@ -459,7 +459,7 @@ OBJtLSData UUtUns32 light_intensity; float beam_angle; float field_angle; - + } OBJtLSData; typedef tm_struct OBJtFurnGeom @@ -467,7 +467,7 @@ typedef tm_struct OBJtFurnGeom UUtUns32 gq_flags; M3tGeometry *geometry; OBJtLSData *ls_data; - + } OBJtFurnGeom; #define OBJcTemplate_FurnGeomArray UUm4CharToUns32('O', 'F', 'G', 'A') @@ -497,17 +497,17 @@ OBJtTriggerEmitterClass typedef tm_template ('T', 'R', 'I', 'G', "Trigger") OBJtTriggerClass { - UUtUns32 color; + UUtUns32 color; UUtUns16 time_on; UUtUns16 time_off; - + float start_offset; float anim_scale; M3tGeometry *base_geometry; OBJtLSData *base_ls_data; UUtUns32 base_gq_flags; - + OBJtTriggerEmitterClass *emitter; OBtAnimation *animation; @@ -538,11 +538,11 @@ OBJtTurretClass { char name[32]; char base_name[32]; - + UUtUns16 flags; UUtUns16 freeTime; - UUtUns16 reloadTime; + UUtUns16 reloadTime; UUtUns16 barrelCount; UUtUns16 recoilAnimType; @@ -578,13 +578,13 @@ OBJtTurretClass UUtUns32 timeout; - float min_vert_angle; - float max_vert_angle; + float min_vert_angle; + float max_vert_angle; float min_horiz_angle; float max_horiz_angle; - float max_vert_speed; + float max_vert_speed; float max_horiz_speed; char active_soundname[32]; // SScMaxNameLength @@ -896,7 +896,7 @@ typedef struct OBJtOSD_Flag char note[OBJcMaxNoteChars + 1]; #endif M3tMatrix4x3 rotation_matrix; /* internal use only */ - + } OBJtOSD_Flag; typedef struct OBJtOSD_Furniture @@ -910,7 +910,7 @@ typedef struct OBJtOSD_Furniture M3tBoundingSphere bounding_sphere; /* internal use only */ UUtUns32 num_particles; /* internal use only */ EPtEnvParticle *particle; /* internal use only */ - + } OBJtOSD_Furniture; // these are kept only for compatibility with object versions before 13 @@ -926,14 +926,14 @@ typedef struct OBJtOSD_Particle UUtBool is_decal; /* internal use only */ struct OBJtObject *owner; /* internal use only */ - + } OBJtOSD_Particle; typedef struct OBJtOSD_PowerUp { WPtPowerupType powerup_type; WPtPowerup *powerup; /* internal use only */ - + } OBJtOSD_PowerUp; // ------------------------------ @@ -941,40 +941,40 @@ typedef enum OBJtSoundType { OBJcSoundType_Spheres = 'SPHR', OBJcSoundType_BVolume = 'VLME' - + } OBJtSoundType; typedef struct OBJtOSD_Sound_Spheres { float max_volume_distance; float min_volume_distance; - + } OBJtOSD_Sound_Spheres; typedef struct OBJtOSD_Sound_BVolume { M3tBoundingBox_MinMax bbox; M3tBoundingVolume bvolume; - + } OBJtOSD_Sound_BVolume; typedef struct OBJtOSD_Sound { OBJtSoundType type; - + char ambient_name[SScMaxNameLength]; SStAmbient *ambient; /* internal use only */ - + float pitch; float volume; - + union { OBJtOSD_Sound_Spheres spheres; OBJtOSD_Sound_BVolume bvolume; - + } u; - + } OBJtOSD_Sound; // ------------------------------ @@ -1010,7 +1010,7 @@ typedef struct OBJtOSD_Trigger ONtEventList event_list; // persist OBJtLSData *base_ls_data; // internal - OBJtTriggerEmitterInstance *emitters; // internal + OBJtTriggerEmitterInstance *emitters; // internal UUtUns16 change_time; // internal UUtBool laser_on; // internal @@ -1023,22 +1023,22 @@ typedef struct OBJtOSD_Trigger SStPlayID playing_sound; // internal M3tPoint3D *cached_points; // internal - + } OBJtOSD_Trigger; typedef struct OBJtOSD_Turret { - UUtUns16 id; // persist + UUtUns16 id; // persist UUtUns16 flags; // persist UUtUns16 state; // internal char turret_class_name[OBJcMaxNameLength]; // persist OBJtTurretClass *turret_class; // internal - + UUtUns32 target_teams; // persist - targeting OBJtLSData *base_ls_data; // internal - + float vert_angle; // internal - actual positioning float horiz_angle; // internal float desired_horiz_angle; // internal - desired positioning @@ -1050,7 +1050,7 @@ typedef struct OBJtOSD_Turret M3tMatrix4x3 barrel_matrix; // internal M3tMatrix4x3 projectile_matrix; // internal UUtBool target_los; // internal - + UUtUns16 chamber_time; // internal - timing UUtUns16 check_target_time; // internal UUtUns32 active_time; // internal @@ -1086,7 +1086,7 @@ typedef struct OBJtOSD_Console char screen_inactive[OBJcMaxNameLength]; // persist char screen_active[OBJcMaxNameLength]; // persist char screen_triggered[OBJcMaxNameLength]; // persist - + ONtEventList event_list; // persist OBJtLSData *ls_data_array; // internal @@ -1123,12 +1123,12 @@ typedef struct OBJtOSD_Door OBJtDoorClass *door_class; // internal AKtDoorFrame *door_frame; // internal - OBtObject *internal_door_object[2]; // internal + OBtObject *internal_door_object[2]; // internal OBtObjectSetup *internal_door_object_setup[2]; // setup for those objects char door_texture[2][32]; // persist M3tTextureMap *door_texture_ptr[2]; // internal - + M3tPoint3D door_frame_position; // persist ONtEventList event_list; // persist @@ -1143,7 +1143,7 @@ typedef struct OBJtOSD_Door IMtShade shade; // internal M3tBoundingBox_MinMax bBox; // internal - + M3tMatrix4x3 door_matrix[2]; // internal OBtAnimationContext animation_context; // internal - for testing non-object-gunked doors @@ -1159,7 +1159,7 @@ typedef struct OBJtOSD_Door } OBJtOSD_Door; // ================================================================================================================== -// +// // ================================================================================================================== enum @@ -1204,7 +1204,7 @@ typedef struct OBJtOSD_Weapon { char weapon_class_name[WPcMaxWeaponName]; WPtWeaponClass *weapon_class; // internal - + } OBJtOSD_Weapon; struct OBJtOSD_All @@ -1228,7 +1228,7 @@ struct OBJtOSD_All OBJtOSD_Melee melee_osd; OBJtOSD_Neutral neutral_osd; } osd; - + }; // ====================================================================== @@ -1261,8 +1261,8 @@ static UUcInline OBJtObjectType OBJrObject_GetType(const OBJtObject *inObject) } static UUcInline UUtError OBJrObject_Enumerate( - OBJtObject *inObject, - OBJtEnumCallback_ObjectName inEnumCallback, + OBJtObject *inObject, + OBJtEnumCallback_ObjectName inEnumCallback, UUtUns32 inUserData) { return inObject->methods->rEnumerate(inObject, inEnumCallback, inUserData); @@ -1313,14 +1313,14 @@ static UUcInline UUtBool OBJrObject_IntersectsLine( const M3tPoint3D *inEndPoint) { return inObject->methods->rIntersectsLine(inObject, inStartPoint, inEndPoint); -} +} static UUcInline UUtUns32 OBJrObject_GetOSDWriteSize(const OBJtObject *inObject) { return inObject->methods->rGetOSDWriteSize(inObject); } - -static UUcInline UUtUns32 OBJrObject_Read( + +static UUcInline UUtUns32 OBJrObject_Read( OBJtObject *inObject, UUtUns16 inVersion, UUtBool inSwapIt, @@ -1339,26 +1339,26 @@ OBJrObject_CreateFromBuffer( void OBJrObject_Delete( OBJtObject *inObject); - + void OBJrObject_Draw( OBJtObject *inObject); - + void OBJrObject_GetPosition( const OBJtObject *inObject, M3tPoint3D *outPosition, M3tPoint3D *outRotation); - + void OBJrObject_GetRotationMatrix( const OBJtObject *inObject, M3tMatrix4x3 *outMatrix); - + UUtBool OBJrObject_IsLocked( const OBJtObject *inObject); - + UUtError OBJrObject_New( const OBJtObjectType inObjectType, @@ -1376,40 +1376,40 @@ void OBJrObject_MouseRotate_Begin( OBJtObject *inObject, IMtPoint2D *inMousePosition); - + void OBJrObject_MouseRotate_Update( OBJtObject *inObject, IMtPoint2D *inPositionDelta); - + void OBJrObject_MouseRotate_End( void); - + void OBJrObject_SetLocked( OBJtObject *ioObject, UUtBool inIsLocked); - + void OBJrObject_SetPosition( OBJtObject *ioObject, const M3tPoint3D *inPosition, const M3tPoint3D *inRotation); - + void OBJrObject_SetRotationMatrix( OBJtObject *ioObject, M3tMatrix4x3 *inMatrix); - + void OBJrObject_Write( OBJtObject *inObject, UUtUns8 *ioBuffer, UUtUns32 *ioNumBytes); -OBJtObject* -OBJrObject_FindByID( +OBJtObject* +OBJrObject_FindByID( UUtUns32 inID ); // ---------------------------------------------------------------------- @@ -1422,7 +1422,7 @@ OBJrObjectType_EnumerateObjects( OBJtObject *OBJrObjectType_GetObject_ByNumber( OBJtObjectType inObjectType, UUtUns32 inIndex); - + void OBJrObjectType_GetUniqueOSD( OBJtObjectType inObjectType, @@ -1431,27 +1431,27 @@ OBJrObjectType_GetUniqueOSD( UUtBool OBJrObjectType_GetVisible( OBJtObjectType inObjectType); - + UUtBool OBJrObjectType_IsLocked( OBJtObjectType inObjectType); - + OBJtObject* OBJrObjectType_Search( OBJtObjectType inObjectType, UUtUns32 inSearchType, const OBJtOSD_All *inSearchParams); - + void OBJrObjectType_SetVisible( OBJtObjectType inObjectType, UUtBool inIsVisible); - + void OBJrObjectTypes_Enumerate( OBJtEnumCallback_ObjectType inEnumCallback, UUtUns32 inUserData); - + const char * OBJrObjectType_GetName( OBJtObjectType inObjectType); @@ -1491,24 +1491,24 @@ OBJrPatrolPath_WritePathData( UUtError OBJrLevel_Load( UUtUns16 inLevelNumber); - + void OBJrLevel_Unload( void); - + // ---------------------------------------------------------------------- void OBJrSelectedObjects_Delete( void); - + UUtUns32 OBJrSelectedObjects_GetNumSelected( void); - + OBJtObject* OBJrSelectedObjects_GetSelectedObject( UUtUns32 inIndex); - + UUtBool OBJrSelectedObjects_IsObjectSelected( const OBJtObject *inObject); @@ -1516,24 +1516,24 @@ OBJrSelectedObjects_IsObjectSelected( UUtBool OBJrSelectedObjects_Lock_Get( void); - + void OBJrSelectedObjects_Lock_Set( UUtBool inLock); - + void OBJrSelectedObjects_Select( OBJtObject *inObject, UUtBool inAddToList); - + void OBJrSelectedObjects_Unselect( OBJtObject *inObject); - + void OBJrSelectedObjects_UnselectAll( void); - + void OBJrSelectedObjects_MoveCameraToSelection( void); @@ -1546,24 +1546,24 @@ OBJrMoveMode_Get( void OBJrMoveMode_Set( UUtUns32 inMoveMode); - + UUtUns32 OBJrRotateMode_Get( void); - + void OBJrRotateMode_Set( UUtUns32 inRotateMode); - + // ---------------------------------------------------------------------- void OBJrDrawObjects( void); - + OBJtObject* OBJrGetObjectUnderPoint( IMtPoint2D *inPoint); - + UUtError OBJrInitialize( void); @@ -1571,11 +1571,11 @@ OBJrInitialize( UUtError OBJrRegisterTemplates( void); - + void OBJrSaveObjects( UUtUns32 inObjectType); - + void OBJrTerminate( void); @@ -1600,19 +1600,19 @@ OBJrSound_GetMinMaxDistances( const OBJtObject *inObject, float *outMaxVolumeDistance, float *outMinVolumeDistance); - + float OBJrSound_GetPitch( const OBJtObject *inObject); - + OBJtSoundType OBJrSound_GetType( const OBJtObject *inObject); - + float OBJrSound_GetVolume( const OBJtObject *inObject); - + UUtBool OBJrSound_PointIn( const OBJtObject *inObject, @@ -1730,12 +1730,12 @@ OBJrPowerUp_NameToType( UUtError OBJrObject_LevelBegin(void); UUtError OBJrObject_LevelEnd(void); -// resets and add all objects of inType +// resets and add all objects of inType // into the listbox sorted with the item // data equal tobject pointers void OBJrObjectType_BuildListBox( - OBJtObjectType inObjectType, + OBJtObjectType inObjectType, WMtWindow *ioListBox, UUtBool inAllowNone); diff --git a/OniProj/OniGameSource/Oni_Object/Oni_ObjectFile.c b/OniProj/OniGameSource/Oni_Object/Oni_ObjectFile.c index 256f363..83fa55a 100644 --- a/OniProj/OniGameSource/Oni_Object/Oni_ObjectFile.c +++ b/OniProj/OniGameSource/Oni_Object/Oni_ObjectFile.c @@ -33,7 +33,7 @@ typedef struct OBJtTypeToFile UUtUns32 object_types[OBJcMaxTTFObjectsTypes]; BFtFileRef *file_ref; BFtFile *file; - + } OBJtTypeToFile; @@ -65,13 +65,13 @@ OBJiObjectFile_Process( UUtBool swap_it; UUtUns16 uns16; UUtUns32 num_bytes; - + UUmAssert(inData); UUmAssert(inDataLength >= 4); - + // read the swap flag buffer = (UUtUns8*)inData; - + // determine if the file needs to be swapped swap_it = UUcFalse; uns16 = *(UUtUns16*)(buffer); @@ -79,31 +79,31 @@ OBJiObjectFile_Process( { UUrSwap_2Byte(&uns16); if (uns16 != OBJcSwap) { return UUcError_Generic; } - + swap_it = UUcTrue; } buffer += 2; - + // read the version number OBJmGet2BytesFromBuffer(buffer, version, UUtUns16, swap_it); - + // get the size of the data chunk OBJmGet4BytesFromBuffer(buffer, num_bytes, UUtUns32, swap_it); while (num_bytes > 0) { UUtUns32 read_bytes; - + // process the data chunck OBJrObject_CreateFromBuffer(version, swap_it, buffer, &read_bytes); UUmAssert(read_bytes == num_bytes); - + // advance to next data chunk buffer += num_bytes; - + // get the size of the data chunk OBJmGet4BytesFromBuffer(buffer, num_bytes, UUtUns32, swap_it); } - + return UUcError_None; } @@ -135,7 +135,7 @@ OBJiObjectFile_Load( BFtFileRef *inObjectFileRef) { UUtError error; - + error = UUcError_None; // check to see if the file exists @@ -144,26 +144,26 @@ OBJiObjectFile_Load( BFtFile *file; UUtUns32 length; void *data; - + // open the file error = OBJiObjectFile_Open(inObjectFileRef, &file); UUmError_ReturnOnError(error); - + // load the file into memory error = BFrFileRef_LoadIntoMemory(inObjectFileRef, &length, &data); UUmError_ReturnOnError(error); - + // process the file error = OBJiObjectFile_Process(data, length); - + // dispose of the memory UUrMemory_Block_Delete(data); data = NULL; - + // close the file OBJiObjectFile_Close(file); } - + return error; } @@ -177,10 +177,10 @@ OBJiObjectFile_MakeFileName( UUmAssert(inSubName); UUmAssert(strlen(inSubName) <= OBJcMaxSubNameLength); UUmAssertWritePtr(outName, (OBJcMaxFileNameLength + 1)); - + // clear the filename outName[0] = '\0'; - + // make the file name sprintf(outName, "L%d_%s.%s", inLevelNumber, inSubName, OBJcObjectFileSuffix); } @@ -194,19 +194,19 @@ OBJiObjectFile_MakeFileRef( { UUtError error; BFtFileRef *object_file_ref; - + UUmAssert(outObjectFileRef); - + *outObjectFileRef = NULL; - + // find the appropriate directory - + // make the file ref error = BFrFileRef_MakeFromName(inFileName, &object_file_ref); UUmError_ReturnOnError(error); - + *outObjectFileRef = object_file_ref; - + return UUcError_None; } @@ -216,11 +216,11 @@ OBJiObjectFile_New( BFtFileRef *inObjectFileRef) { UUtError error; - + // create the object file error = BFrFile_Create(inObjectFileRef); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -232,13 +232,13 @@ OBJiObjectFile_Open( { UUtError error; BFtFile *object_file; - + // open the object file error = BFrFile_Open(inObjectFileRef, "rw", &object_file); UUmError_ReturnOnError(error); - + *outObjectFile = object_file; - + return UUcError_None; } @@ -251,28 +251,28 @@ OBJiObjectFile_SaveBegin( UUtError error; UUtUns16 swap_flag; UUtUns16 version; - + swap_flag = OBJcSwap; version = OBJcCurrentVersion; - + // open the file if (*inObjectFile == NULL) { error = OBJiObjectFile_Open(inObjectFileRef, inObjectFile); UUmError_ReturnOnError(error); } - + // set the position to the beginning of the file error = BFrFile_SetPos(*inObjectFile, 0); UUmError_ReturnOnError(error); - + // write the swap flag into the file error = BFrFile_Write(*inObjectFile, sizeof(UUtUns16), &swap_flag); UUmError_ReturnOnError(error); error = BFrFile_Write(*inObjectFile, sizeof(UUtUns16), &version); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -283,16 +283,16 @@ OBJiObjectFile_SaveEnd( { UUtError error; UUtUns32 zero; - + zero = 0; - + // write an UUtUns32 with value 0 to indicate the end of the file error = BFrFile_Write(inObjectFile, sizeof(UUtUns32), &zero); UUmError_ReturnOnError(error); - + // close the file BFrFile_Close(inObjectFile); - + return UUcError_None; } @@ -304,15 +304,15 @@ OBJiObjectFile_Write( UUtUns32 inNumBytes) { UUtError error; - + // write the number of bytes error = BFrFile_Write(inObjectFile, sizeof(UUtUns32), &inNumBytes); UUmError_ReturnOnError(error); - + // write the data to the file error = BFrFile_Write(inObjectFile, inNumBytes, (void*)inBuffer); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -327,11 +327,11 @@ OBJrObjectFiles_Close( void) { UUtUns32 i; - + for (i = 0; i < OBJgNumTypeToFiles; i++) { if (OBJgTypeToFile[i].file == NULL) { continue; } - + OBJiObjectFile_Close(OBJgTypeToFile[i].file); OBJgTypeToFile[i].file = NULL; } @@ -345,7 +345,7 @@ OBJrObjectFiles_Initialize( // initialize the OBJgTypeToFiles UUrMemory_Clear(OBJgTypeToFile, sizeof(OBJtTypeToFile) * OBJcMaxTypeToFiles); OBJgNumTypeToFiles = 0; - + return UUcError_None; } @@ -356,37 +356,37 @@ OBJrObjectFiles_LevelLoad( { UUtError error; UUtUns32 i; - + // create file refs for each OBJgTypeToFiles for (i = 0; i < OBJgNumTypeToFiles; i++) { char file_name[OBJcMaxFileNameLength + 1]; BFtFileRef *object_file_ref; - + // initialize the object file OBJgTypeToFile[i].file_ref = NULL; - + // make the file name OBJiObjectFile_MakeFileName( inLevelNumber, OBJgTypeToFile[i].sub_name, file_name); - + // make the file ref for the file - error = + error = OBJiObjectFile_MakeFileRef( inLevelNumber, file_name, &object_file_ref); UUmError_ReturnOnError(error); - + // save the object file ref OBJgTypeToFile[i].file_ref = object_file_ref; - + // load the objects from the file OBJiObjectFile_Load(OBJgTypeToFile[i].file_ref); } - + return UUcError_None; } @@ -396,7 +396,7 @@ OBJrObjectFiles_LevelUnload( void) { UUtUns32 i; - + // dispose of all of the file refs for (i = 0; i < OBJgNumTypeToFiles; i++) { @@ -412,14 +412,14 @@ OBJrObjectFiles_Open( { UUtUns32 i; UUtError error; - + for (i = 0; i < OBJgNumTypeToFiles; i++) { if (OBJiObjectFile_FileExists(OBJgTypeToFile[i].file_ref) == UUcFalse) { continue; } - + // open the file error = OBJiObjectFile_Open(OBJgTypeToFile[i].file_ref, &OBJgTypeToFile[i].file); if (error != UUcError_None) { continue; } @@ -441,7 +441,7 @@ OBJrObjectFiles_SaveBegin( { continue; } - + // open the file and prepare for writing of objects error = OBJiObjectFile_SaveBegin( @@ -449,7 +449,7 @@ OBJrObjectFiles_SaveBegin( &OBJgTypeToFile[i].file); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -468,12 +468,12 @@ OBJrObjectFiles_SaveEnd( { continue; } - + // close the file error = OBJiObjectFile_SaveEnd(OBJgTypeToFile[i].file); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -486,16 +486,16 @@ OBJrObjectFiles_RegisterObjectType( UUtUns32 i; UUtBool is_associated; OBJtTypeToFile *type_to_file; - + // see if inObjectType is already associated with an OBJgTypeToFile is_associated = UUcFalse; for (i = 0; i < OBJgNumTypeToFiles; i++) { UUtUns32 j; - + // get a pointer to the OBJgTypeToFile type_to_file = &OBJgTypeToFile[i]; - + for (j = 0; j < type_to_file->num_object_types; j++) { if (type_to_file->object_types[j] == inObjectType) @@ -505,7 +505,7 @@ OBJrObjectFiles_RegisterObjectType( } } } - + // if it is associated with an OBJgTypeToFile make sure that the OBJgTypeToFile // that it is associated with has the same sub name if (is_associated) @@ -514,19 +514,19 @@ OBJrObjectFiles_RegisterObjectType( { return UUcError_Generic; } - + // inObjectType is already associated with the correct sub name, // so there is nothing left to do except return return UUcError_None; } - + // no OBJgTypeToFiles are associated with inObjectType, add a new one type_to_file = &OBJgTypeToFile[OBJgNumTypeToFiles]; UUrString_Copy(type_to_file->sub_name, inSubName, OBJcMaxSubNameLength); type_to_file->object_types[type_to_file->num_object_types] = inObjectType; type_to_file->num_object_types++; OBJgNumTypeToFiles++; - + return UUcError_None; } @@ -548,13 +548,13 @@ OBJrObjectFiles_Write( UUtUns32 i; OBJtTypeToFile *type_to_file; UUtBool found; - + // find the associated object file found = UUcFalse; for (i = 0; i < OBJgNumTypeToFiles; i++) { UUtUns32 j; - + // get a pointer to the OBJgTypeToFile type_to_file = &OBJgTypeToFile[i]; @@ -565,26 +565,26 @@ OBJrObjectFiles_Write( found = UUcTrue; } } - + if (found) { break; } } - - // if type_to_file is NULL return an error + + // if type_to_file is NULL return an error if (type_to_file == NULL) { return UUcError_Generic; } - + // if type_to_file's file is NULL then open the file and prepare it for saving if (type_to_file->file == NULL) { error = OBJiObjectFile_SaveBegin(OBJgTypeToFile[i].file_ref, &OBJgTypeToFile[i].file); UUmError_ReturnOnError(error); } - + // write the data into the appropriate file error = OBJiObjectFile_Write(type_to_file->file, inBuffer, inNumBytes); UUmError_ReturnOnError(error); - - return UUcError_None; + + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/Oni_ObjectFile.h b/OniProj/OniGameSource/Oni_Object/Oni_ObjectFile.h index df67842..2a094a1 100644 --- a/OniProj/OniGameSource/Oni_Object/Oni_ObjectFile.h +++ b/OniProj/OniGameSource/Oni_Object/Oni_ObjectFile.h @@ -23,7 +23,7 @@ #define OBJmGet4BytesFromBuffer(src,dst,type,swap_it) \ (dst) = *((type*)(src)); \ ((UUtUns8*)(src)) += sizeof(type); \ - if ((swap_it)) { UUrSwap_4Byte(&(dst)); } + if ((swap_it)) { UUrSwap_4Byte(&(dst)); } #define OBJmWrite4BytesToBuffer(buf,val,type,num_bytes) \ *((type*)(buf)) = (val); \ @@ -33,7 +33,7 @@ #define OBJmGet2BytesFromBuffer(src,dst,type,swap_it) \ (dst) = *((type*)(src)); \ ((UUtUns8*)(src)) += sizeof(type); \ - if ((swap_it)) { UUrSwap_2Byte(&(dst)); } + if ((swap_it)) { UUrSwap_2Byte(&(dst)); } #define OBJmWrite2BytesToBuffer(buf,val,type,num_bytes) \ *((type*)(buf)) = (val); \ @@ -46,7 +46,7 @@ void OBJrObjectFiles_Close( void); - + UUtError OBJrObjectFiles_LevelLoad( UUtUns16 inLevelNumber); @@ -58,20 +58,20 @@ OBJrObjectFiles_LevelUnload( void OBJrObjectFiles_Open( void); - + UUtError OBJrObjectFiles_RegisterObjectType( UUtUns32 inObjectType, char *inSubName); - + UUtError OBJrObjectFiles_SaveBegin( void); - + UUtError OBJrObjectFiles_SaveEnd( void); - + UUtError OBJrObjectFiles_Write( UUtUns32 inObjectType, @@ -86,6 +86,6 @@ OBJrObjectFiles_Initialize( void OBJrObjectFiles_Terminate( void); - + // ====================================================================== -#endif /* ONI_OBJECTFILE_H */ \ No newline at end of file +#endif /* ONI_OBJECTFILE_H */ diff --git a/OniProj/OniGameSource/Oni_Object/Oni_Object_Private.h b/OniProj/OniGameSource/Oni_Object/Oni_Object_Private.h index c549262..54643e7 100644 --- a/OniProj/OniGameSource/Oni_Object/Oni_Object_Private.h +++ b/OniProj/OniGameSource/Oni_Object/Oni_Object_Private.h @@ -52,9 +52,9 @@ enum OBJcDrawFlag_RingX = 0x0002, OBJcDrawFlag_RingY = 0x0004, OBJcDrawFlag_RingZ = 0x0008, - + OBJcDrawFlag_Locked = 0x8000 - + }; // ====================================================================== @@ -88,25 +88,25 @@ OBJrObjectGroup_Register( void OBJrObjectUtil_DrawAxes( const float inLength); - + void OBJrObjectUtil_DrawRotationRings( const OBJtObject *inObject, const M3tBoundingSphere *inBoundingSphere, UUtUns32 inDrawRings); - + UUtError OBJrObjectUtil_EnumerateTemplate( char *inPrefix, TMtTemplateTag inTemplateTag, OBJtEnumCallback_ObjectName inEnumCallback, UUtUns32 inUserData); - + // ---------------------------------------------------------------------- UUtError OBJrConsole_Initialize( void); - + // ---------------------------------------------------------------------- UUtError OBJrDoor_Initialize( @@ -143,7 +143,7 @@ void OBJrCharacter_DrawTerminate( void); #endif - + // ---------------------------------------------------------------------- UUtError OBJrParticle_Initialize( @@ -159,7 +159,7 @@ void OBJrPatrolPath_DrawTerminate( void); #endif - + // ---------------------------------------------------------------------- UUtError OBJrSound_Initialize( @@ -170,7 +170,7 @@ void OBJrSound_DrawTerminate( void); #endif - + // ---------------------------------------------------------------------- UUtError OBJrTrigger_Initialize( @@ -182,12 +182,12 @@ OBJrTriggerVolume_Initialize( void); // ---------------------------------------------------------------------- -UUtError +UUtError OBJrCombat_Initialize( void); // ---------------------------------------------------------------------- -UUtError +UUtError OBJrMelee_Initialize( void); @@ -217,12 +217,12 @@ UUtError OBJrDoor_Initialize(void); UUtError OBJrPowerUp_Initialize( void); - + // ---------------------------------------------------------------------- UUtError OBJrWeapon_Initialize( void); - + // ====================================================================== -#endif /* ONI_OBJECT_PRIVATE_H */ \ No newline at end of file +#endif /* ONI_OBJECT_PRIVATE_H */ diff --git a/OniProj/OniGameSource/Oni_Object/Oni_Object_RegisterTemplates.c b/OniProj/OniGameSource/Oni_Object/Oni_Object_RegisterTemplates.c index de4dc1d..e7be609 100644 --- a/OniProj/OniGameSource/Oni_Object/Oni_Object_RegisterTemplates.c +++ b/OniProj/OniGameSource/Oni_Object/Oni_Object_RegisterTemplates.c @@ -19,7 +19,7 @@ OBJrRegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register( OBJcTemplate_LSData, diff --git a/OniProj/OniGameSource/Oni_Object/Oni_Object_Utils.c b/OniProj/OniGameSource/Oni_Object/Oni_Object_Utils.c index b857c35..b723ed6 100644 --- a/OniProj/OniGameSource/Oni_Object/Oni_Object_Utils.c +++ b/OniProj/OniGameSource/Oni_Object/Oni_Object_Utils.c @@ -20,21 +20,21 @@ OBJrObjectUtil_DrawAxes( { UUtUns8 block_XYZ[(sizeof(M3tPoint3D) * 2) + (2 * UUcProcessor_CacheLineSize)]; M3tPoint3D *axes_XYZ = UUrAlignMemory(block_XYZ); - + axes_XYZ[0].x = 0.0f; axes_XYZ[0].y = 0.0f; axes_XYZ[0].z = 0.0f; - + axes_XYZ[1].x = inLength; axes_XYZ[1].y = 0.0f; axes_XYZ[1].z = 0.0f; M3rGeometry_LineDraw(2, axes_XYZ, IMcShade_Green); - + axes_XYZ[1].x = 0.0f; axes_XYZ[1].y = inLength; axes_XYZ[1].z = 0.0f; M3rGeometry_LineDraw(2, axes_XYZ, IMcShade_Red); - + axes_XYZ[1].x = 0.0f; axes_XYZ[1].y = 0.0f; axes_XYZ[1].z = inLength; @@ -49,7 +49,7 @@ OBJrObjectUtil_DrawRotationRings( UUtUns32 inDrawRings) { IMtShade shade; - + #define cNumPoints 24 // one times cache line size should be plenty but why risk it @@ -57,7 +57,7 @@ OBJrObjectUtil_DrawRotationRings( UUtUns8 block_XY[(sizeof(M3tPoint3D) * (cNumPoints + 1)) + (2 * UUcProcessor_CacheLineSize)]; UUtUns8 block_YZ[(sizeof(M3tPoint3D) * (cNumPoints + 1)) + (2 * UUcProcessor_CacheLineSize)]; UUtUns8 block_ticks[(sizeof(M3tPoint3D) * (2)) + (2 * UUcProcessor_CacheLineSize)]; - + M3tPoint3D *ring_XZ = UUrAlignMemory(block_XZ); M3tPoint3D *ring_XY = UUrAlignMemory(block_XY); M3tPoint3D *ring_YZ = UUrAlignMemory(block_YZ); @@ -69,15 +69,15 @@ OBJrObjectUtil_DrawRotationRings( float theta; float cos_theta_radius; float sin_theta_radius; - + theta = M3c2Pi * (((float) itr) / cNumPoints); cos_theta_radius = MUrCos(theta) * inBoundingSphere->radius; sin_theta_radius = MUrSin(theta) * inBoundingSphere->radius; - + ring_XZ[itr].x = cos_theta_radius + inBoundingSphere->center.x; ring_XZ[itr].y = inBoundingSphere->center.y; ring_XZ[itr].z = sin_theta_radius + inBoundingSphere->center.z; - + ring_XY[itr].x = cos_theta_radius + inBoundingSphere->center.x; ring_XY[itr].y = sin_theta_radius + inBoundingSphere->center.y; ring_XY[itr].z = inBoundingSphere->center.z; @@ -86,58 +86,58 @@ OBJrObjectUtil_DrawRotationRings( ring_YZ[itr].y = cos_theta_radius + inBoundingSphere->center.y; ring_YZ[itr].z = sin_theta_radius + inBoundingSphere->center.z; } - + ring_XZ[cNumPoints] = ring_XZ[0]; ring_XY[cNumPoints] = ring_XY[0]; ring_YZ[cNumPoints] = ring_YZ[0]; - + if (inDrawRings & OBJcDrawFlag_RingY) { shade = (inDrawRings & OBJcDrawFlag_Locked) ? shade = IMcShade_Gray50 : IMcShade_Red; M3rGeometry_LineDraw(cNumPoints + 1, ring_XZ, shade); } - + if (inDrawRings & OBJcDrawFlag_RingZ) { shade = (inDrawRings & OBJcDrawFlag_Locked) ? shade = IMcShade_Gray50 : IMcShade_Yellow; M3rGeometry_LineDraw(cNumPoints + 1, ring_XY, shade); } - + if (inDrawRings & OBJcDrawFlag_RingX) { shade = (inDrawRings & OBJcDrawFlag_Locked) ? shade = IMcShade_Gray50 : IMcShade_Green; M3rGeometry_LineDraw(cNumPoints + 1, ring_YZ, shade); } - + for (itr = 0; itr < cNumPoints; itr += 2) { ticks[0] = ring_XZ[itr]; MUmVector_Subtract(ticks[1], inBoundingSphere->center, ticks[0]); MUmVector_Scale(ticks[1], 0.1f); MUmVector_Add(ticks[1], ticks[1], ticks[0]); - + if (inDrawRings & OBJcDrawFlag_RingY) { shade = (inDrawRings & OBJcDrawFlag_Locked) ? shade = IMcShade_Gray50 : IMcShade_Red; M3rGeometry_LineDraw(2, ticks, shade); } - + ticks[0] = ring_XY[itr]; MUmVector_Subtract(ticks[1], inBoundingSphere->center, ticks[0]); MUmVector_Scale(ticks[1], 0.1f); MUmVector_Add(ticks[1], ticks[1], ticks[0]); - + if (inDrawRings & OBJcDrawFlag_RingZ) { shade = (inDrawRings & OBJcDrawFlag_Locked) ? shade = IMcShade_Gray50 : IMcShade_Yellow; M3rGeometry_LineDraw(2, ticks, shade); } - + ticks[0] = ring_YZ[itr]; MUmVector_Subtract(ticks[1], inBoundingSphere->center, ticks[0]); MUmVector_Scale(ticks[1], 0.1f); MUmVector_Add(ticks[1], ticks[1], ticks[0]); - + if (inDrawRings & OBJcDrawFlag_RingX) { shade = (inDrawRings & OBJcDrawFlag_Locked) ? shade = IMcShade_Gray50 : IMcShade_Green; @@ -168,7 +168,7 @@ OBJrObjectUtil_EnumerateTemplate( &num_instances, instances); UUmError_ReturnOnError(error); - + if (inPrefix) { prefix_length = strlen(inPrefix); @@ -177,15 +177,15 @@ OBJrObjectUtil_EnumerateTemplate( { prefix_length = 0; } - + for (i = 0; i < num_instances; i++) { char *instance_name; UUtBool result = UUcTrue; - + // get the name of the template instance instance_name = TMrInstance_GetInstanceName(instances[i]); - + // send the information to the callback if (prefix_length == 0) { @@ -206,6 +206,6 @@ OBJrObjectUtil_EnumerateTemplate( // stop if the result of the callback is false if (!result) { break; } } - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Character.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Character.c index e184bba..a9a5553 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Character.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Character.c @@ -66,9 +66,9 @@ OBJrCharacter_DrawInitialize( UUtError error; TStFontFamily *font_family; IMtPixelType textureFormat; - + M3rDrawEngine_FindGrayscalePixelType(&textureFormat); - + OBJgCharacter_WhiteColor = IMrPixel_FromShade(textureFormat, IMcShade_White); error = TSrFontFamily_Get(TScFontFamily_Default, &font_family); @@ -76,20 +76,20 @@ OBJrCharacter_DrawInitialize( { goto cleanup; } - + error = TSrContext_New(font_family, TScFontSize_Default, TScStyle_Bold, TSc_SingleLine, UUcFalse, &OBJgCharacter_TextContext); if (error != UUcError_None) { goto cleanup; } - + OBJgCharacter_Dest.x = 2; OBJgCharacter_Dest.y = TSrFont_GetLeadingHeight(TSrContext_GetFont(OBJgCharacter_TextContext, TScStyle_InUse)) + TSrFont_GetAscendingHeight(TSrContext_GetFont(OBJgCharacter_TextContext, TScStyle_InUse)); - + TSrContext_GetStringRect(OBJgCharacter_TextContext, "maximum_length_of_character_name", &OBJgCharacter_TextureBounds); - + error = M3rTextureMap_New( OBJgCharacter_TextureBounds.right, @@ -108,10 +108,10 @@ OBJrCharacter_DrawInitialize( M3rTextureRef_GetSize((void *) OBJgCharacter_Texture, (UUtUns16*)&OBJgCharacter_TextureBounds.right, (UUtUns16*)&OBJgCharacter_TextureBounds.bottom); - + OBJgCharacter_TextureWidth = OBJgCharacter_TextureBounds.right; OBJgCharacter_TextureHeight = OBJgCharacter_TextureBounds.bottom; - + OBJgCharacter_WidthRatio = (float)OBJgCharacter_TextureWidth / (float)OBJgCharacter_TextureHeight; OBJgCharacter_DrawInitialized = UUcTrue; @@ -144,14 +144,14 @@ OBJiCharacter_DrawName( UUtUns16 string_width; IMtPoint2D text_dest; float sprite_size; - + // erase the texture and set the text contexts shade M3rTextureMap_Fill(OBJgCharacter_Texture, OBJgCharacter_WhiteColor, NULL); TSrContext_SetShade(OBJgCharacter_TextContext, IMcShade_Black); - + // get the character's name OBJrObject_GetName(inObject, name, OBJcMaxNameLength); - + // work out how big the string is going to be TSrContext_GetStringRect(OBJgCharacter_TextContext, name, &string_bounds); string_width = string_bounds.right - string_bounds.left; @@ -168,7 +168,7 @@ OBJiCharacter_DrawName( name, &OBJgCharacter_TextureBounds, &text_dest); - + // draw the sprite M3rGeom_State_Set(M3cGeomStateIntType_SpriteMode, M3cGeomState_SpriteMode_Normal); M3rGeom_State_Commit(); @@ -186,7 +186,7 @@ OBJiCharacter_DrawName( 0, 1.0f - sprite_size, 0); } - + return; } @@ -231,7 +231,7 @@ OBJiCharacter_Draw( IMtShade char_shade; // KNA: replaced size with OBJcCharacter_DrawSize so that CodeWarrior would compile - M3tPoint3D points[8] = + M3tPoint3D points[8] = { { 0.00f * OBJcCharacter_DrawSize, 0.00f * OBJcCharacter_DrawSize, 0.0f }, { 0.25f * OBJcCharacter_DrawSize, 0.75f * OBJcCharacter_DrawSize, 0.0f }, @@ -242,18 +242,18 @@ OBJiCharacter_Draw( { 0.05f * OBJcCharacter_DrawSize, 0.75f * OBJcCharacter_DrawSize, 0.4f * OBJcCharacter_DrawSize }, {-0.05f * OBJcCharacter_DrawSize, 0.75f * OBJcCharacter_DrawSize, 0.4f * OBJcCharacter_DrawSize } }; - + if (OBJgCharacter_DrawPositions == UUcFalse) { return; } - + // get a pointer to the object osd char_osd = (OBJtOSD_Character *)inObject->object_data; - + // set up the matrix stack M3rMatrixStack_Push(); M3rMatrixStack_ApplyTranslate(inObject->position); M3rMatrixStack_RotateYAxis(char_osd->facing); M3rGeom_State_Commit(); - + // draw the character position marker if (char_osd->team_number < OBJcCharacter_TeamMaxNamed) char_shade = OBJgCharacter_TeamColor[char_osd->team_number]; @@ -268,19 +268,19 @@ OBJiCharacter_Draw( M3rGeom_Line_Light(points + 4, points + 5, char_shade); M3rGeom_Line_Light(points + 5, points + 6, char_shade); M3rGeom_Line_Light(points + 5, points + 7, char_shade); - + // draw the name camera_location = CArGetLocation(); if (MUrPoint_Distance(&inObject->position, &camera_location) < OBJgCharacter_DrawNameDistance) { OBJiCharacter_DrawName(inObject, points + 2); } - + // draw the rotation ring if this character is selected if (inDrawFlags & OBJcDrawFlag_Selected) { M3tBoundingSphere bounding_sphere; - + OBJrObject_GetBoundingSphere(inObject, &bounding_sphere); OBJrObjectUtil_DrawRotationRings(inObject, &bounding_sphere, OBJcDrawFlag_RingY); } @@ -299,10 +299,10 @@ OBJiCharacter_Enumerate( UUtUns32 inUserData) { char name[OBJcMaxNameLength + 1]; - + OBJrObject_GetName(inObject, name, OBJcMaxNameLength); inEnumCallback(name, inUserData); - + return UUcError_None; } @@ -326,7 +326,7 @@ OBJiCharacter_OSDGetName( UUtUns32 inNameLength) { const OBJtOSD_Character *char_osd = &inOSD->osd.character_osd; - + UUrString_Copy(outName, char_osd->character_name, inNameLength); return; @@ -340,7 +340,7 @@ OBJiCharacter_OSDSetName( const char *inName) { OBJtOSD_Character *char_osd = &inOSD->osd.character_osd; - + UUrString_Copy(char_osd->character_name, inName, sizeof(char_osd->character_name)); return; @@ -357,7 +357,7 @@ OBJiCharacter_GetOSD( // get a pointer to the object osd char_osd = (OBJtOSD_Character *)inObject->object_data; - + outOSD->osd.character_osd = *char_osd; } @@ -367,7 +367,7 @@ OBJiCharacter_GetOSDWriteSize( const OBJtObject *inObject) { UUtUns32 size; - + size = sizeof(AI2tAlertStatus) + // initial alert sizeof(AI2tAlertStatus) + // minimum alert @@ -397,7 +397,7 @@ OBJiCharacter_GetOSDWriteSize( sizeof(UUtUns32) + // alarm groups 4*sizeof(AI2tPursuitMode) + // pursuit modes sizeof(AI2tPursuitLostBehavior);// target lost behavior - + return size; } @@ -486,14 +486,14 @@ OBJiCharacter_IntersectsLine( M3tBoundingSphere sphere; UUrMemory_Clear(&sphere, sizeof(M3tBoundingSphere)); - + // get the bounding sphere OBJrObject_GetBoundingSphere(inObject, &sphere); - + sphere.center.x += inObject->position.x; sphere.center.y += inObject->position.y; sphere.center.z += inObject->position.z; - + return CLrSphere_Line(inStartPoint, inEndPoint, &sphere); } @@ -514,10 +514,10 @@ OBJiCharacter_New( { UUtError error; OBJtOSD_Character *char_osd; - + // get a pointer to the object osd char_osd = (OBJtOSD_Character *)inObject->object_data; - + if (inOSD == NULL) { error = OBJiCharacter_SetDefaults((OBJtOSD_All *) char_osd); @@ -527,7 +527,7 @@ OBJiCharacter_New( { *char_osd = inOSD->osd.character_osd; } - + // set the object specific data and position OBJrObject_UpdatePosition(inObject); @@ -547,7 +547,7 @@ OBJiCharacter_Read( OBJtOSD_Character *character = (OBJtOSD_Character *) inObject->object_data; UUtUns32 num_bytes = 0; UUtUns32 itr, itr2; - + // read the data num_bytes += OBJmGet4BytesFromBuffer(inBuffer, character->flags, UUtUns32, inSwapIt); character->flags &= ~OBJcCharFlags_Spawned; // clear runtime-only flags @@ -555,29 +555,29 @@ OBJiCharacter_Read( num_bytes += OBJmGetStringFromBuffer(inBuffer, character->character_class, 64, inSwapIt); num_bytes += OBJmGetStringFromBuffer(inBuffer, character->character_name, ONcMaxPlayerNameLength, inSwapIt); num_bytes += OBJmGetStringFromBuffer(inBuffer, character->weapon_class_name, 64, inSwapIt); - num_bytes += OBJmGetStringFromBuffer(inBuffer, character->spawn_script, SLcScript_MaxNameLength,inSwapIt); + num_bytes += OBJmGetStringFromBuffer(inBuffer, character->spawn_script, SLcScript_MaxNameLength,inSwapIt); if (inVersion >= OBJcVersion_8) { - num_bytes += OBJmGetStringFromBuffer(inBuffer, character->die_script, SLcScript_MaxNameLength,inSwapIt); - num_bytes += OBJmGetStringFromBuffer(inBuffer, character->combat_script, SLcScript_MaxNameLength,inSwapIt); - num_bytes += OBJmGetStringFromBuffer(inBuffer, character->alarm_script, SLcScript_MaxNameLength,inSwapIt); + num_bytes += OBJmGetStringFromBuffer(inBuffer, character->die_script, SLcScript_MaxNameLength,inSwapIt); + num_bytes += OBJmGetStringFromBuffer(inBuffer, character->combat_script, SLcScript_MaxNameLength,inSwapIt); + num_bytes += OBJmGetStringFromBuffer(inBuffer, character->alarm_script, SLcScript_MaxNameLength,inSwapIt); } else { character->die_script[0] = '\0'; character->combat_script[0] = '\0'; character->alarm_script[0] = '\0'; } if (inVersion >= OBJcVersion_21) { - num_bytes += OBJmGetStringFromBuffer(inBuffer, character->hurt_script, SLcScript_MaxNameLength,inSwapIt); + num_bytes += OBJmGetStringFromBuffer(inBuffer, character->hurt_script, SLcScript_MaxNameLength,inSwapIt); } else { character->hurt_script[0] = '\0'; } if (inVersion >= OBJcVersion_29) { - num_bytes += OBJmGetStringFromBuffer(inBuffer, character->defeated_script, SLcScript_MaxNameLength,inSwapIt); + num_bytes += OBJmGetStringFromBuffer(inBuffer, character->defeated_script, SLcScript_MaxNameLength,inSwapIt); } else { character->defeated_script[0] = '\0'; } if (inVersion >= OBJcVersion_34) { - num_bytes += OBJmGetStringFromBuffer(inBuffer, character->outofammo_script, SLcScript_MaxNameLength,inSwapIt); - num_bytes += OBJmGetStringFromBuffer(inBuffer, character->nopath_script, SLcScript_MaxNameLength,inSwapIt); + num_bytes += OBJmGetStringFromBuffer(inBuffer, character->outofammo_script, SLcScript_MaxNameLength,inSwapIt); + num_bytes += OBJmGetStringFromBuffer(inBuffer, character->nopath_script, SLcScript_MaxNameLength,inSwapIt); } else { character->outofammo_script[0] = '\0'; character->nopath_script[0] = '\0'; @@ -632,7 +632,7 @@ OBJiCharacter_Read( } num_bytes += OBJmGet4BytesFromBuffer(inBuffer, character->team_number, UUtUns32, inSwapIt); num_bytes += OBJmGet4BytesFromBuffer(inBuffer, character->ammo_percentage, UUtUns32, inSwapIt); - + if (inVersion >= OBJcVersion_8) { num_bytes += OBJmGet4BytesFromBuffer(inBuffer, character->initial_alert, AI2tAlertStatus, inSwapIt); num_bytes += OBJmGet4BytesFromBuffer(inBuffer, character->minimum_alert, AI2tAlertStatus, inSwapIt); @@ -677,7 +677,7 @@ OBJiCharacter_Read( // bring the object up to date OBJrObject_UpdatePosition(inObject); - + return num_bytes; } @@ -693,7 +693,7 @@ OBJiCharacter_SetOSD( UUtError error; UUmAssert(inOSD); - + // get a pointer to the object osd char_osd = (OBJtOSD_Character *)inObject->object_data; @@ -708,7 +708,7 @@ OBJiCharacter_SetOSD( } UUrMemory_MoveFast(&inOSD->osd.character_osd, char_osd, sizeof(OBJtOSD_Character)); - + UUrMemory_Block_VerifyList(); // get the new character class's default combat and melee settings @@ -734,10 +734,10 @@ OBJiCharacter_UpdatePosition( OBJtObject *inObject) { OBJtOSD_Character *char_osd; - + // get a pointer to the object osd char_osd = (OBJtOSD_Character *)inObject->object_data; - + // convert the rotation to radians char_osd->facing = inObject->rotation.y * M3cDegToRad; } @@ -754,22 +754,22 @@ OBJiCharacter_Write( // get a pointer to the object osd char_osd = (OBJtOSD_Character *)inObject->object_data; - + // set the number of bytes available bytes_available = *ioBufferSize; - + OBJmWrite4BytesToBuffer(ioBuffer, char_osd->flags, UUtUns32, bytes_available, OBJcWrite_Little); OBJmWriteStringToBuffer(ioBuffer, char_osd->character_class, 64, bytes_available, OBJcWrite_Little); OBJmWriteStringToBuffer(ioBuffer, char_osd->character_name, ONcMaxPlayerNameLength, bytes_available, OBJcWrite_Little); OBJmWriteStringToBuffer(ioBuffer, char_osd->weapon_class_name, 64, bytes_available, OBJcWrite_Little); - OBJmWriteStringToBuffer(ioBuffer, char_osd->spawn_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); - OBJmWriteStringToBuffer(ioBuffer, char_osd->die_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); - OBJmWriteStringToBuffer(ioBuffer, char_osd->combat_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); - OBJmWriteStringToBuffer(ioBuffer, char_osd->alarm_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); - OBJmWriteStringToBuffer(ioBuffer, char_osd->hurt_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); - OBJmWriteStringToBuffer(ioBuffer, char_osd->defeated_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); - OBJmWriteStringToBuffer(ioBuffer, char_osd->outofammo_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); - OBJmWriteStringToBuffer(ioBuffer, char_osd->nopath_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); + OBJmWriteStringToBuffer(ioBuffer, char_osd->spawn_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); + OBJmWriteStringToBuffer(ioBuffer, char_osd->die_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); + OBJmWriteStringToBuffer(ioBuffer, char_osd->combat_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); + OBJmWriteStringToBuffer(ioBuffer, char_osd->alarm_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); + OBJmWriteStringToBuffer(ioBuffer, char_osd->hurt_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); + OBJmWriteStringToBuffer(ioBuffer, char_osd->defeated_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); + OBJmWriteStringToBuffer(ioBuffer, char_osd->outofammo_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); + OBJmWriteStringToBuffer(ioBuffer, char_osd->nopath_script, SLcScript_MaxNameLength,bytes_available, OBJcWrite_Little); OBJmWrite4BytesToBuffer(ioBuffer, char_osd->hit_points, UUtInt32, bytes_available, OBJcWrite_Little); OBJmWrite4BytesToBuffer(ioBuffer, char_osd->job, UUtUns32, bytes_available, OBJcWrite_Little); @@ -803,7 +803,7 @@ OBJiCharacter_Write( // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = *ioBufferSize - bytes_available; - + return UUcError_None; } @@ -837,10 +837,10 @@ OBJiCharacter_Search( { OBJtOSD_Character *char_osd; UUtBool found; - + // get a pointer to the object osd char_osd = (OBJtOSD_Character *)inObject->object_data; - + // perform the check found = UUcFalse; switch (inSearchType) @@ -859,7 +859,7 @@ OBJiCharacter_Search( } break; } - + return found; } @@ -875,10 +875,10 @@ OBJrCharacter_Initialize( { UUtError error; OBJtMethods methods; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiCharacter_New; methods.rSetDefaults = OBJiCharacter_SetDefaults; @@ -899,7 +899,7 @@ OBJrCharacter_Initialize( methods.rSearch = OBJiCharacter_Search; methods.rSetClassVisible = OBJiCharacter_SetVisible; methods.rGetUniqueOSD = OBJiCharacter_GetUniqueOSD; - + // register the furniture methods error = OBJrObjectGroup_Register( @@ -910,7 +910,7 @@ OBJrCharacter_Initialize( &methods, OBJcObjectGroupFlag_CanSetName); UUmError_ReturnOnError(error); - + #if CONSOLE_DEBUGGING_COMMANDS error = SLrGlobalVariable_Register_Bool( @@ -918,7 +918,7 @@ OBJrCharacter_Initialize( "Enables the display of character starting positions", &OBJgCharacter_DrawPositions); UUmError_ReturnOnError(error); - + error = SLrGlobalVariable_Register_Float( "character_name_distance", @@ -926,10 +926,10 @@ OBJrCharacter_Initialize( &OBJgCharacter_DrawNameDistance); UUmError_ReturnOnError(error); #endif - + // intialize the globals OBJgCharacter_DrawNameDistance = OBJcCharacter_DefaultDrawNameDistance; - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Combat.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Combat.c index cce5e35..3482026 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Combat.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Combat.c @@ -60,10 +60,10 @@ OBJiCombat_Enumerate( UUtUns32 inUserData) { char name[OBJcMaxNameLength + 1]; - + OBJrObject_GetName(inObject, name, OBJcMaxNameLength); inEnumCallback(name, inUserData); - + return UUcError_None; } @@ -92,9 +92,9 @@ OBJiCombat_OSDGetName( // get a pointer to the object osd com_osd = &inOSD->osd.combat_osd; - + UUrString_Copy(outName, com_osd->name, inNameLength); - + return; } @@ -107,7 +107,7 @@ OBJiCombat_OSDSetName( // get a pointer to the object osd com_osd = &inOSD->osd.combat_osd; - + UUrString_Copy(com_osd->name, outName, sizeof(com_osd->name)); return; @@ -125,7 +125,7 @@ OBJiCombat_GetOSD( // get a pointer to the object osd com_osd = (OBJtOSD_Combat *)inObject->object_data; - + outOSD->osd.combat_osd = *com_osd; return; @@ -140,7 +140,7 @@ OBJiCombat_GetOSDWriteSize( OBJtOSD_All osd; osd; - + combat_size = 0; combat_size += sizeof(osd.osd.combat_osd.name); combat_size += sizeof(osd.osd.combat_osd.id); @@ -250,7 +250,7 @@ OBJiCombat_SetDefaults( OBJtOSD_All *outOSD) { UUtUns32 itr; - + OBJiCombat_GetUniqueOSD(outOSD); outOSD->osd.combat_osd.flags = 0; @@ -285,7 +285,7 @@ OBJiCombat_New( { OBJtOSD_All osd_all; UUtError error; - + if (NULL == inOSD) { error = OBJiCombat_SetDefaults(&osd_all); UUmError_ReturnOnError(error); @@ -294,11 +294,11 @@ OBJiCombat_New( { OBJiCombat_DuplicateOSD(inOSD, &osd_all); } - + // set the object specific data and position error = OBJrObject_SetObjectSpecificData(inObject, &osd_all); UUmError_ReturnOnError(error); - + OBJrObject_UpdatePosition(inObject); return UUcError_None; @@ -315,7 +315,7 @@ OBJiCombat_Read( OBJtOSD_Combat *com_osd = (OBJtOSD_Combat *) inObject->object_data; UUtUns32 itr; UUtUns32 bytes_read = 0; - + bytes_read += OBJmGetStringFromBuffer(inBuffer, com_osd->name, sizeof(com_osd->name), inSwapIt); bytes_read += OBJmGet2BytesFromBuffer(inBuffer, com_osd->id, UUtUns16, inSwapIt); @@ -386,7 +386,7 @@ OBJiCombat_Read( // bring the object up to date OBJrObject_UpdatePosition(inObject); - + return bytes_read; } @@ -398,12 +398,12 @@ OBJiCombat_SetOSD( { OBJtOSD_Combat *com_osd; UUtUns32 itr; - + UUmAssert(inOSD); - + // get a pointer to the object osd com_osd = (OBJtOSD_Combat *)inObject->object_data; - + // copy the data from inOSD to char_osd UUrString_Copy(com_osd->name, inOSD->osd.combat_osd.name, sizeof(inOSD->osd.combat_osd.name)); @@ -421,7 +421,7 @@ OBJiCombat_SetOSD( com_osd->short_range = inOSD->osd.combat_osd.short_range; com_osd->pursuit_distance = inOSD->osd.combat_osd.pursuit_distance; - + com_osd->panic_melee = inOSD->osd.combat_osd.panic_melee; com_osd->panic_gunfire = inOSD->osd.combat_osd.panic_gunfire; com_osd->panic_sight = inOSD->osd.combat_osd.panic_sight; @@ -453,7 +453,7 @@ OBJiCombat_Write( { OBJtOSD_Combat *com_osd; UUtUns32 itr, bytes_available; - + com_osd = (OBJtOSD_Combat *) inObject->object_data; bytes_available = *ioBufferSize; @@ -482,7 +482,7 @@ OBJiCombat_Write( // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = *ioBufferSize - bytes_available; - + return UUcError_None; } @@ -490,7 +490,7 @@ OBJiCombat_Write( static const char *OBJiCombat_IsInvalid( OBJtObject *inObject) { - // construct the initial state of the listbox + // construct the initial state of the listbox UUtUns32 count; UUtUns32 itr; @@ -551,10 +551,10 @@ OBJiCombat_Search( { OBJtOSD_Combat *com_osd; UUtBool found; - + // get a pointer to the object osd com_osd = (OBJtOSD_Combat *)inObject->object_data; - + // perform the check switch (inSearchType) { @@ -570,7 +570,7 @@ OBJiCombat_Search( found = UUcFalse; break; } - + return found; } @@ -586,10 +586,10 @@ OBJrCombat_Initialize( { UUtError error; OBJtMethods methods; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiCombat_New; methods.rSetDefaults = OBJiCombat_SetDefaults; @@ -610,7 +610,7 @@ OBJrCombat_Initialize( methods.rSearch = OBJiCombat_Search; methods.rSetClassVisible = OBJiCombat_SetVisible; methods.rGetUniqueOSD = OBJiCombat_GetUniqueOSD; - + // register the furniture methods error = OBJrObjectGroup_Register( @@ -621,7 +621,7 @@ OBJrCombat_Initialize( &methods, OBJcObjectGroupFlag_CanSetName | OBJcObjectGroupFlag_CommonToAllLevels); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Console.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Console.c index 826f476..7d64396 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Console.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Console.c @@ -9,7 +9,7 @@ #include "EulerAngles.h" #include "Oni_Object.h" #include "Oni_Object_Private.h" -#include "Oni_BinaryData.h" +#include "Oni_BinaryData.h" #include "Oni_GameStatePrivate.h" #include "Oni_Mechanics.h" @@ -51,7 +51,7 @@ static void _DrawDot(M3tPoint3D *inPoint) cam_sphere_dist = MUmVector_GetDistance( cameraLocation, (*inPoint)); - //if (cam_sphere_dist > .001f) + //if (cam_sphere_dist > .001f) //{ //scale *= cam_sphere_dist; //M3rSprite_Draw( dotTexture, inPoint, scale, scale, IMcShade_Red, M3cMaxAlpha, 0, NULL, NULL, 0, 0, 0); @@ -66,11 +66,11 @@ static void OBJiConsole_CreateBoundingSphere( OBJtObject *inObject, OBJtOSD_Cons M3tBoundingSphere *sphere; M3tPoint3D new_center; float new_radius; - + new_center.x = 0.0f; new_center.y = 0.0f; new_center.z = 0.0f; - + if( !inOSD->console_class ) return; @@ -80,22 +80,22 @@ static void OBJiConsole_CreateBoundingSphere( OBJtObject *inObject, OBJtOSD_Cons sphere = &inOSD->console_class->geometry_array->furn_geom[i].geometry->pointArray->boundingSphere; MUmVector_Increment(new_center, sphere->center); } - + new_center.x /= inOSD->console_class->geometry_array->num_furn_geoms; new_center.y /= inOSD->console_class->geometry_array->num_furn_geoms; new_center.z /= inOSD->console_class->geometry_array->num_furn_geoms; - + // caculate the new radius new_radius = 0.0f; for (i = 0; i < inOSD->console_class->geometry_array->num_furn_geoms; i++) { - M3tVector3D vector; + M3tVector3D vector; float temp_radius; - + sphere = &inOSD->console_class->geometry_array->furn_geom[i].geometry->pointArray->boundingSphere; MUmVector_Subtract(vector, new_center, sphere->center); temp_radius = MUrVector_Length(&vector) + sphere->radius; - + new_radius = UUmMax(new_radius, temp_radius); } // set the bounding sphere @@ -115,7 +115,7 @@ static void OBJiConsole_Delete( OBJtObject *inObject) // get a pointer to the object osd console_osd = (OBJtOSD_Console*)inObject->object_data; - + // delete the memory allocated for the ls_data_array if (console_osd->ls_data_array) { @@ -123,9 +123,9 @@ static void OBJiConsole_Delete( OBJtObject *inObject) console_osd->ls_data_array = NULL; console_osd->num_ls_datas = 0; } - + ONrEventList_Destroy(&console_osd->event_list); - + return; } @@ -139,7 +139,7 @@ static void OBJiConsole_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) if (OBJgConsole_DrawConsole == UUcFalse) { return; } // don't draw when the non-occluding geometry is hidden if (AKgDraw_Occl == UUcTrue) { return; } - + console_osd = (OBJtOSD_Console*)inObject->object_data; if (console_osd->console_class == NULL) { return; } if (console_osd->console_class->geometry_array == NULL) { return; } @@ -147,7 +147,7 @@ static void OBJiConsole_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) MUrMatrix_BuildTranslate(inObject->position.x, inObject->position.y, inObject->position.z, &console_matrix); MUrMatrixStack_Matrix(&console_matrix, &console_osd->rotation_matrix); -#if TOOL_VERSION +#if TOOL_VERSION // dont draw the main geometry if its been gunkified if(!(inObject->flags & OBJcObjectFlag_Gunk)) { @@ -157,11 +157,11 @@ static void OBJiConsole_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) for (i = 0; i < console_osd->console_class->geometry_array->num_furn_geoms; i++) { UUtUns32 flags; - + // check the visibility flags flags = console_osd->console_class->geometry_array->furn_geom[i].gq_flags; if (((flags & AKcGQ_Flag_Invisible) != 0) && (AKgDraw_Invis == UUcFalse)) continue; - + // draw the bounding box if this is the selected object if (inDrawFlags & OBJcDrawFlag_Selected) { @@ -170,7 +170,7 @@ static void OBJiConsole_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) M3rBBox_Draw_Line(&bBox, IMcShade_White); } - + AKrEnvironment_DrawIfVisible(console_osd->console_class->geometry_array->furn_geom[i].geometry, &console_matrix); } @@ -187,14 +187,14 @@ static void OBJiConsole_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) if (console_osd->flags & OBJcConsoleFlag_Active) { if( console_osd->flags & OBJcConsoleFlag_Triggered ) { - cur_texture = console_osd->triggered_screen_texture; + cur_texture = console_osd->triggered_screen_texture; } else { - cur_texture = console_osd->active_screen_texture; + cur_texture = console_osd->active_screen_texture; } } else { - cur_texture = console_osd->inactive_screen_texture; + cur_texture = console_osd->inactive_screen_texture; } old_texture = console_osd->console_class->screen_geometry->baseMap; @@ -202,11 +202,11 @@ static void OBJiConsole_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) AKrEnvironment_DrawIfVisible(console_osd->console_class->screen_geometry, &console_matrix); console_osd->console_class->screen_geometry->baseMap = old_texture; } - + #if TOOL_VERSION // draw the rotation rings if this is the selected object if (inDrawFlags & OBJcDrawFlag_Selected) - { + { M3tPoint3D laserFrom; M3tPoint3D laserTo; M3tVector3D laserVector; @@ -238,7 +238,7 @@ static UUtError OBJiConsole_Enumerate( OBJtObject *inObject, OBJtEnumCallback_Ob static void OBJiConsole_GetBoundingSphere( const OBJtObject *inObject, M3tBoundingSphere *outBoundingSphere ) { OBJtOSD_Console *console_osd; - + console_osd = (OBJtOSD_Console*)inObject->object_data; *outBoundingSphere = console_osd->bounding_sphere; @@ -248,7 +248,7 @@ static void OBJiConsole_GetBoundingSphere( const OBJtObject *inObject, M3tBoundi static void OBJiConsole_OSDGetName( const OBJtOSD_All *inOSD, char *outName, UUtUns32 inNameLength ) { const OBJtOSD_Console *console_osd; - + console_osd = &inOSD->osd.console_osd; sprintf(outName, "%s_%d", console_osd->console_class_name, console_osd->id); @@ -264,9 +264,9 @@ static void OBJiConsole_OSDSetName(OBJtOSD_All *inOSD, const char *inName) static void OBJiConsole_GetOSD( const OBJtObject *inObject, OBJtOSD_All *outOSD) { OBJtOSD_Console *console_osd; - + console_osd = (OBJtOSD_Console*)inObject->object_data; - + UUrMemory_MoveFast( console_osd, &outOSD->osd.console_osd, sizeof(OBJtOSD_Console) ); ONrEventList_Copy( &console_osd->event_list, &outOSD->osd.console_osd.event_list ); @@ -280,14 +280,14 @@ static UUtBool OBJiConsole_IntersectsLine( const OBJtObject *inObject, const M3t UUtBool result; UUrMemory_Clear(&sphere, sizeof(M3tBoundingSphere)); - + // get the bounding sphere OBJrObject_GetBoundingSphere(inObject, &sphere); - + sphere.center.x += inObject->position.x; sphere.center.y += inObject->position.y; sphere.center.z += inObject->position.z; - + // do the fast test to see if the line is colliding with the bounding sphere result = CLrSphere_Line(inStartPoint, inEndPoint, &sphere); if (result) { @@ -297,25 +297,25 @@ static UUtBool OBJiConsole_IntersectsLine( const OBJtObject *inObject, const M3t M3tPoint3D end_point; M3tMatrix4x3 inverse_matrix; M3tVector3D neg_position; - + result = UUcFalse; - + // because the line collided with the bounding sphere, test to see if the line // collides with the bounding box of the geometries console_osd = (OBJtOSD_Console*)inObject->object_data; if (console_osd->console_class == NULL) { return UUcFalse; } if (console_osd->console_class->geometry_array == NULL) { return UUcFalse; } - + // calculate the inverse of the rotation matrix MUrMatrix_Inverse(&console_osd->rotation_matrix, &inverse_matrix); neg_position = inObject->position; MUmVector_Negate(neg_position); MUrMatrix_Translate(&inverse_matrix, &neg_position); - + // calculate a start point and an end poing in object space MUrMatrix_MultiplyPoint(inStartPoint, &inverse_matrix, &start_point); MUrMatrix_MultiplyPoint(inEndPoint, &inverse_matrix, &end_point); - + // check the bounding box of each geometry to see if the line intersects the geometry for (i = 0; i < console_osd->console_class->geometry_array->num_furn_geoms; i++) { @@ -326,10 +326,10 @@ static UUtBool OBJiConsole_IntersectsLine( const OBJtObject *inObject, const M3t &end_point); if (result == UUcTrue) { break; } } - + return result; } - + return UUcFalse; } @@ -340,20 +340,20 @@ static UUtError OBJiConsole_SetDefaults(OBJtOSD_All *outOSD) void *instances[OBJcMaxInstances]; UUtUns32 num_instances; char *instance_name; - + // clear the osd UUrMemory_Clear(&outOSD->osd.console_osd, sizeof(OBJtOSD_Console)); - + // get a list of instances of the class error = TMrInstance_GetDataPtr_List( OBJcTemplate_ConsoleClass, OBJcMaxInstances, &num_instances, instances); UUmError_ReturnOnError(error); - + // error out if we have no console instances if(!num_instances) return UUcError_Generic; // copy the name of the first console template name - instance_name = TMrInstance_GetInstanceName(instances[0]); - + instance_name = TMrInstance_GetInstanceName(instances[0]); + UUrString_Copy( outOSD->osd.console_osd.console_class_name, instance_name, OBJcMaxNameLength); // default initial data @@ -362,7 +362,7 @@ static UUtError OBJiConsole_SetDefaults(OBJtOSD_All *outOSD) // initialize the event list ONrEventList_Initialize( &outOSD->osd.console_osd.event_list ); - + return UUcError_None; } @@ -371,7 +371,7 @@ static UUtError OBJiConsole_New(OBJtObject *inObject, const OBJtOSD_All *inOSD) { OBJtOSD_All osd_all; UUtError error; - + if (inOSD == NULL) { error = OBJiConsole_SetDefaults(&osd_all); @@ -379,11 +379,11 @@ static UUtError OBJiConsole_New(OBJtObject *inObject, const OBJtOSD_All *inOSD) inOSD = &osd_all; } - + // set the object specific data and position OBJiConsole_SetOSD(inObject, inOSD); OBJrObject_UpdatePosition(inObject); - + return UUcError_None; } @@ -426,7 +426,7 @@ static UUtError OBJiConsole_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inO UUmError_ReturnOnErrorMsg(error, "failed to find any console class"); - inObject->flags |= OBJcObjectFlag_Temporary; + inObject->flags |= OBJcObjectFlag_Temporary; console = NULL; } @@ -439,7 +439,7 @@ static UUtError OBJiConsole_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inO console_osd->ls_data_array = NULL; console_osd->num_ls_datas = 0; } - + // calculate the size for the ls_data_array and the number of OBJtLSData's in it size = 0; console_osd->num_ls_datas = 0; @@ -448,11 +448,11 @@ static UUtError OBJiConsole_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inO for (i = 0; i < console_osd->console_class->geometry_array->num_furn_geoms; i++) { if (console_osd->console_class->geometry_array->furn_geom[i].ls_data == NULL) { continue; } - + size += sizeof(OBJtLSData); console_osd->num_ls_datas++; } - + if (size > 0) { // allocate memory for the ls_data_array @@ -467,17 +467,17 @@ static UUtError OBJiConsole_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inO } else { - UUtUns32 j; + UUtUns32 j; // copy the data from the OBJtLSData template instance in the furn_geom for (i = 0, j = 0; i < console_osd->console_class->geometry_array->num_furn_geoms; i++) { if (console_osd->console_class->geometry_array->furn_geom[i].ls_data == NULL) { continue; } - UUrMemory_MoveFast( console_osd->console_class->geometry_array->furn_geom[i].ls_data, (console_osd->ls_data_array + j), sizeof(OBJtLSData)); + UUrMemory_MoveFast( console_osd->console_class->geometry_array->furn_geom[i].ls_data, (console_osd->ls_data_array + j), sizeof(OBJtLSData)); j++; } } } - + // create action marker if( ONgLevel && !console_osd->action_marker ) { @@ -513,7 +513,7 @@ static UUtError OBJiConsole_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inO else { console_osd->active_screen_texture = M3rTextureMap_GetFromName_UpperCase(console_osd->console_class->screen_active); } - + if (console_osd->screen_triggered[0]) { console_osd->triggered_screen_texture = M3rTextureMap_GetFromName_UpperCase(console_osd->screen_triggered); } @@ -539,7 +539,7 @@ static UUtError OBJiConsole_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inO // create the bounding sphere OBJiConsole_CreateBoundingSphere(inObject, console_osd); - + return UUcError_None; } @@ -554,12 +554,12 @@ static void OBJiConsole_UpdatePosition( OBJtObject *inObject) // get a pointer to the object osd console_osd = (OBJtOSD_Console*)inObject->object_data; - + // convert the rotation to radians rot_x = inObject->rotation.x * M3cDegToRad; rot_y = inObject->rotation.y * M3cDegToRad; rot_z = inObject->rotation.z * M3cDegToRad; - + // update the rotation matrix euler.order = MUcEulerOrderXYZs; euler.x = rot_x; @@ -592,12 +592,12 @@ static UUtUns32 OBJiConsole_Read( OBJtObject *inObject, UUtUns16 inVersion, UUtB console_osd->flags &= OBJcConsoleFlag_Persist; - num_bytes = - OBJcMaxNameLength + - sizeof(UUtUns16) + + num_bytes = + OBJcMaxNameLength + sizeof(UUtUns16) + - OBJcMaxNameLength + - OBJcMaxNameLength + + sizeof(UUtUns16) + + OBJcMaxNameLength + + OBJcMaxNameLength + OBJcMaxNameLength; // initialize and read the event list @@ -616,10 +616,10 @@ static UUtUns32 OBJiConsole_Read( OBJtObject *inObject, UUtUns16 inVersion, UUtB for (i = 0; i < console_osd->num_ls_datas; i++) { OBJtLSData *ls_data; - + // get a pointer to the ls_data ls_data = console_osd->ls_data_array + i; - + // read the data from the buffer OBDmGet4BytesFromBuffer(inBuffer, ls_data->index, UUtUns32, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, ls_data->light_flags, UUtUns32, inSwapIt); @@ -629,13 +629,13 @@ static UUtUns32 OBJiConsole_Read( OBJtObject *inObject, UUtUns16 inVersion, UUtB OBDmGet4BytesFromBuffer(inBuffer, ls_data->light_intensity, UUtUns32, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, ls_data->beam_angle, float, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, ls_data->field_angle, float, inSwapIt); - + // set the number of bytes read num_bytes += ((sizeof(UUtUns32) * 3) + (sizeof(float) * 5)); } OBJrObject_UpdatePosition(inObject); - + return num_bytes; } @@ -645,12 +645,12 @@ static UUtError OBJiConsole_Write( OBJtObject *inObject, UUtUns8 *ioBuffer, UUtU OBJtOSD_Console *console_osd; UUtUns32 bytes_available; UUtUns32 i; - + console_osd = (OBJtOSD_Console*)inObject->object_data; - + // set the number of bytes available bytes_available = *ioBufferSize; - + // put the geometry name in the buffer OBJmWriteStringToBuffer(ioBuffer, console_osd->console_class_name, OBJcMaxNameLength, bytes_available, OBJcWrite_Little); OBJmWrite2BytesToBuffer(ioBuffer, console_osd->id, UUtInt16, bytes_available, OBJcWrite_Little); @@ -665,9 +665,9 @@ static UUtError OBJiConsole_Write( OBJtObject *inObject, UUtUns8 *ioBuffer, UUtU for (i = 0; i < console_osd->num_ls_datas; i++) { OBJtLSData *ls_data; - + ls_data = console_osd->ls_data_array + i; - + OBDmWrite4BytesToBuffer(ioBuffer, ls_data->index, UUtUns32, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, ls_data->light_flags, UUtUns32, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, ls_data->filter_color[0], float, bytes_available, OBJcWrite_Little); @@ -680,7 +680,7 @@ static UUtError OBJiConsole_Write( OBJtObject *inObject, UUtUns8 *ioBuffer, UUtU // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = *ioBufferSize - bytes_available; - + return UUcError_None; } // ---------------------------------------------------------------------- @@ -690,17 +690,17 @@ OBJiConsole_GetOSDWriteSize( { OBJtOSD_Console *console_osd; UUtUns32 size; - + // get a pointer to the console_osd console_osd = (OBJtOSD_Console*)inObject->object_data; - + // calculate the number of bytes needed to save the OSD - size = - OBJcMaxNameLength + - sizeof(UUtUns16) + + size = + OBJcMaxNameLength + + sizeof(UUtUns16) + sizeof(UUtUns16) + - OBJcMaxNameLength + - OBJcMaxNameLength + + OBJcMaxNameLength + + OBJcMaxNameLength + OBJcMaxNameLength + (sizeof(OBJtLSData) * console_osd->num_ls_datas); @@ -808,7 +808,7 @@ UUtError OBJrConsole_OnActivate( OBJtObject *inObject, ONtCharacter* inCharacter UUtBool console_is_active; UUtBool console_is_triggered; M3tPoint3D sound_location; - + UUmAssert( inObject->object_type == OBJcType_Console ); console_osd = (OBJtOSD_Console*) inObject->object_data; @@ -828,7 +828,7 @@ UUtError OBJrConsole_OnActivate( OBJtObject *inObject, ONtCharacter* inCharacter else { SSrImpulse_Play_Simple("console_activate", &sound_location); console_osd->flags |= OBJcConsoleFlag_Triggered; - + error = ONrEventList_Execute( &console_osd->event_list, inCharacter ); UUmAssert( error == UUcError_None ); } @@ -837,13 +837,13 @@ UUtError OBJrConsole_OnActivate( OBJtObject *inObject, ONtCharacter* inCharacter } UUtError OBJrConsole_AddEvent( OBJtOSD_Console *inConsole_osd, ONtEvent *inEvent ) -{ +{ ONrEventList_AddEvent( &inConsole_osd->event_list, inEvent ); return UUcError_None; } UUtError OBJrConsole_DeleteEvent( OBJtOSD_Console *inConsole_osd, UUtUns32 inIndex ) -{ +{ ONrEventList_DeleteEvent( &inConsole_osd->event_list, inIndex ); return UUcError_None; } @@ -913,7 +913,7 @@ OBJtObject *OBJrConsole_GetByID(UUtUns16 inID) find_struct.id = inID; find_struct.object = NULL; - OBJrObjectType_EnumerateObjects(OBJcType_Console, OBJrConsole_Find_ID_Enum, (UUtUns32) &find_struct); + OBJrObjectType_EnumerateObjects(OBJcType_Console, OBJrConsole_Find_ID_Enum, (UUtUns32) &find_struct); return find_struct.object; } @@ -925,7 +925,7 @@ static UUtBool OBJrConsole_Activate_ID_Enum(OBJtObject *inObject, UUtUns32 inUse UUmAssert( inObject->object_type == OBJcType_Console ); console_osd = (OBJtOSD_Console*) inObject->object_data; - + if( inUserData == 0xffff || console_osd->id == inUserData ) { OBJrConsole_Activate( (OBJtObject*) inObject ); @@ -940,7 +940,7 @@ void OBJrConsole_Activate_ID( UUtUns16 inID ) inID = 0xffff; } - OBJrObjectType_EnumerateObjects( OBJcType_Console, OBJrConsole_Activate_ID_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Console, OBJrConsole_Activate_ID_Enum, (UUtUns32) inID ); return; } @@ -967,7 +967,7 @@ void OBJrConsole_Deactivate_ID( UUtUns16 inID ) inID = 0xffff; } - OBJrObjectType_EnumerateObjects( OBJcType_Console, OBJrConsole_Deactivate_ID_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Console, OBJrConsole_Deactivate_ID_Enum, (UUtUns32) inID ); return; } @@ -993,7 +993,7 @@ void OBJrConsole_Reset_ID(UUtUns16 inID) inID = 0xffff; } - OBJrObjectType_EnumerateObjects( OBJcType_Console, OBJrConsole_Reset_ID_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Console, OBJrConsole_Reset_ID_Enum, (UUtUns32) inID ); return; } @@ -1006,7 +1006,7 @@ void OBJrConsole_Reset_ID(UUtUns16 inID) static UUtError OBJiConsole_Reset( OBJtObject *inObject ) { OBJtOSD_Console *console_osd; - + UUmAssert( inObject->object_type == OBJcType_Console ); console_osd = (OBJtOSD_Console*) inObject->object_data; @@ -1032,7 +1032,7 @@ static UUtError OBJiConsole_LevelEnd( OBJtObject *inObject ) static UUtError OBJiConsole_LevelBegin( OBJtObject *inObject ) { OBJtOSD_Console *console_osd; - + UUmAssert( inObject->object_type == OBJcType_Console ); console_osd = (OBJtOSD_Console*) inObject->object_data; @@ -1067,11 +1067,11 @@ UUtError OBJrConsole_Initialize(void) ONtMechanicsMethods mechanics_methods; // initialize globals - OBJgConsole_DrawConsole = UUcTrue; + OBJgConsole_DrawConsole = UUcTrue; // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiConsole_New; methods.rSetDefaults = OBJiConsole_SetDefaults; @@ -1088,12 +1088,12 @@ UUtError OBJrConsole_Initialize(void) methods.rSetOSD = OBJiConsole_SetOSD; methods.rRead = OBJiConsole_Read; methods.rWrite = OBJiConsole_Write; - + // class methods methods.rSearch = OBJiConsole_Search; methods.rGetClassVisible = OBJiConsole_GetVisible; - methods.rSetClassVisible = OBJiConsole_SetVisible; - + methods.rSetClassVisible = OBJiConsole_SetVisible; + // mechanics methods mechanics_methods.rInitialize = OBJiConsole_LevelBegin; mechanics_methods.rTerminate = OBJiConsole_LevelEnd; @@ -1109,9 +1109,9 @@ UUtError OBJrConsole_Initialize(void) // register the console methods error = ONrMechanics_Register( OBJcType_Console, OBJcTypeIndex_Console, "Console", sizeof(OBJtOSD_Console), &methods, OBJcObjectGroupFlag_CanSetName, &mechanics_methods ); UUmError_ReturnOnError(error); - + // console is initially visible OBJiConsole_SetVisible(UUcTrue); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Door.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Door.c index eb1a9d1..813bd49 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Door.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Door.c @@ -10,7 +10,7 @@ #include "EulerAngles.h" #include "Oni_Object.h" #include "Oni_Object_Private.h" -#include "Oni_BinaryData.h" +#include "Oni_BinaryData.h" #include "Oni_GameStatePrivate.h" #include "BFW_TM_Construction.h" #include "Oni_Mechanics.h" @@ -52,7 +52,7 @@ static UUtUns32 OBJgDoor_CurrentDoor; // ====================================================================== // prototypes // ====================================================================== - + #define OBcDoorFaceAngle 1.4f // 80 degrees #define OBcDoorOpenUpwardsHeight 15.0f @@ -107,7 +107,7 @@ static void OBJiDoor_CreateBoundingSphere( OBJtObject *inObject, OBJtOSD_Door *i M3tPoint3D new_center; float new_radius; OBJtOSD_Door *door_osd; - + new_center.x = 0.0f; new_center.y = 0.0f; new_center.z = 0.0f; @@ -127,20 +127,20 @@ static void OBJiDoor_CreateBoundingSphere( OBJtObject *inObject, OBJtOSD_Door *i sphere = &door_osd->door_class->geometry_array[0]->furn_geom[i].geometry->pointArray->boundingSphere; MUmVector_Increment(new_center, sphere->center); } - + new_center.x /= door_osd->door_class->geometry_array[0]->num_furn_geoms; new_center.y /= door_osd->door_class->geometry_array[0]->num_furn_geoms; new_center.z /= door_osd->door_class->geometry_array[0]->num_furn_geoms; - + // caculate the new radius new_radius = 0.0f; for (i = 0; i < door_osd->door_class->geometry_array[0]->num_furn_geoms; i++) { - M3tVector3D vector; + M3tVector3D vector; float temp_radius; sphere = &door_osd->door_class->geometry_array[0]->furn_geom[i].geometry->pointArray->boundingSphere; MUmVector_Subtract(vector, new_center, sphere->center); - temp_radius = MUrVector_Length(&vector) + sphere->radius; + temp_radius = MUrVector_Length(&vector) + sphere->radius; new_radius = UUmMax(new_radius, temp_radius); } if( door_osd->flags & OBJcDoorFlag_DoubleDoors ) @@ -225,7 +225,7 @@ static AKtDoorFrame* OBJrDoor_FindDoorFrameAt( M3tPoint3D *position ) AKtDoorFrame* door_frame; UUtUns32 i; UUtUns32 door_count; - + door_count = ONgLevel->environment->door_frames->door_count; for( i = 0; i < door_count; i++ ) @@ -335,7 +335,7 @@ UUtError OBJrDoor_Lock_ID( UUtUns16 inID ) COrConsole_Printf("locking doors of id %d", inID); } - OBJrObjectType_EnumerateObjects( OBJcType_Door, OBJiDoor_LockDoors_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Door, OBJiDoor_LockDoors_Enum, (UUtUns32) inID ); return UUcError_None; } @@ -350,7 +350,7 @@ UUtError OBJrDoor_Unlock_ID( UUtUns16 inID ) COrConsole_Printf("unlocking doors of id %d", inID); } - OBJrObjectType_EnumerateObjects( OBJcType_Door, OBJiDoor_UnlockDoors_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Door, OBJiDoor_UnlockDoors_Enum, (UUtUns32) inID ); return UUcError_None; } @@ -507,7 +507,7 @@ void OBJrDoor_MakeConnectionLink(struct PHtConnection *ioConnection, M3tPoint3D user_data.connection = ioConnection; user_data.side_test_point = inSidePoint; - OBJrObjectType_EnumerateObjects(OBJcType_Door, OBJiDoor_MakeConnectionLink_Enum, (UUtUns32) &user_data); + OBJrObjectType_EnumerateObjects(OBJcType_Door, OBJiDoor_MakeConnectionLink_Enum, (UUtUns32) &user_data); } // ---------------------------------------------------------------------- @@ -527,17 +527,17 @@ static void OBJiDoor_DrawName( OBJtObject *inObject, M3tPoint3D *inLocation ) M3rTextureMap_Fill( OBJgDoor_Texture, OBJgDoor_WhiteColor, NULL); TSrContext_SetShade(OBJgDoor_TextContext, IMcShade_Black); - + // get the flag's title OBJrObject_GetName(inObject, name, OBJcMaxNameLength); - + // draw the string to the texture TSrContext_DrawString( OBJgDoor_TextContext, OBJgDoor_Texture, name, &OBJgDoor_TextureBounds, &OBJgDoor_Dest); - + // draw the sprite M3rSimpleSprite_Draw( OBJgDoor_Texture, inLocation, OBJgDoor_WidthRatio, 1.0f, IMcShade_White, M3cMaxAlpha ); } - + return; } @@ -549,7 +549,7 @@ static void OBJiDoor_Draw_Frame( OBJtObject *inObject, UUtUns32 inDrawFlags) AKtDoorFrame *frame; M3tPoint3D center_point = { 0,0,0 }; - M3tPoint3D points[4] = + M3tPoint3D points[4] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, @@ -560,7 +560,7 @@ static void OBJiDoor_Draw_Frame( OBJtObject *inObject, UUtUns32 inDrawFlags) door_osd = (OBJtOSD_Door*)inObject->object_data; center_point = door_osd->center_offset; - + frame = door_osd->door_frame; UUmAssert( frame ); @@ -576,7 +576,7 @@ static void OBJiDoor_Draw_Frame( OBJtObject *inObject, UUtUns32 inDrawFlags) door_osd->general_quad->flags &= ~AKcGQ_Flag_Invisible; } - M3rMatrixStack_Push(); + M3rMatrixStack_Push(); M3rMatrixStack_ApplyTranslate(inObject->position); M3rMatrixStack_Multiply(&door_osd->rotation_matrix); @@ -604,7 +604,7 @@ static void OBJiDoor_Draw_Frame( OBJtObject *inObject, UUtUns32 inDrawFlags) M3rGeom_Line_Light(&points[0], &points[2], shade); M3rGeom_Line_Light(&points[1], &points[3], shade); - + camera_location = CArGetLocation(); if( MUrPoint_Distance( &frame->position, &camera_location ) < 300 ) { @@ -639,7 +639,7 @@ static void _OBJrFurniture_DrawArray( OBJtFurnGeomArray* inGeometryArray, M3tMat if (inDrawFlags & OBJcDrawFlag_Selected) { M3rMinMaxBBox_To_BBox( &inGeometryArray->furn_geom[i].geometry->pointArray->minmax_boundingBox, &bBox); - + M3rBBox_Draw_Line(&bBox, IMcShade_White); } // draw the geometry @@ -678,7 +678,7 @@ static void OBJiDoor_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) OBJtFurnGeomArray *geometry_array; - M3tPoint3D points[4] = + M3tPoint3D points[4] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, @@ -686,7 +686,7 @@ static void OBJiDoor_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) { 0.0f, 0.0f, 0.0f } }; - if( !OBJgDoor_DrawDoor ) return; + if( !OBJgDoor_DrawDoor ) return; door_osd = (OBJtOSD_Door*)inObject->object_data; @@ -706,21 +706,21 @@ static void OBJiDoor_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) M3tMatrix4x3 matrix_stack[2]; UUmAssert(door_osd->door_class->geometry_array[0]); - + if (door_osd->door_class->geometry_array[0] == NULL) return; - + { MUrMatrix_BuildTranslate(inObject->position.x, inObject->position.y, inObject->position.z, matrix_stack + 0); MUrMatrixStack_Matrix(matrix_stack + 0, &door_osd->rotation_matrix); - + MUrMatrix_BuildRotateX(M3c2Pi -M3cHalfPi,&m1); - + // door 1 { matrix_stack[1] = matrix_stack[0]; - MUrMatrixStack_Matrix(matrix_stack + 1, &door_osd->door_matrix[0]); + MUrMatrixStack_Matrix(matrix_stack + 1, &door_osd->door_matrix[0]); MUrMatrixStack_Matrix(matrix_stack + 1, &m1); - MUrMatrixStack_Matrix(matrix_stack + 1, &door_osd->animation_matrix); + MUrMatrixStack_Matrix(matrix_stack + 1, &door_osd->animation_matrix); _OBJrFurniture_DrawArray(door_osd->door_class->geometry_array[0], matrix_stack + 1, inDrawFlags, door_osd->door_texture_ptr[0] ); } @@ -734,7 +734,7 @@ static void OBJiDoor_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) MUrMatrixStack_Matrix(matrix_stack + 1, &m1); if( door_osd->flags & OBJcDoorFlag_TestMode ) - { + { MUrMatrix_BuildRotateY( M3cPi, &m1 ); MUrMatrix_RotateZ( &m1, M3cPi ); MUrMatrixStack_Matrix(matrix_stack + 1, &m1); @@ -760,7 +760,7 @@ static void OBJiDoor_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) // draw the rotation rings if this is the selected object if (inDrawFlags & OBJcDrawFlag_Selected) { - M3rMatrixStack_Push(); + M3rMatrixStack_Push(); { MUrMatrix_BuildRotateX(M3c2Pi-M3cHalfPi,&m1); M3rMatrixStack_ApplyTranslate(inObject->position); @@ -771,30 +771,30 @@ static void OBJiDoor_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) if( door_osd->door_class ) { - M3rMatrixStack_Push(); + M3rMatrixStack_Push(); M3rMatrixStack_Multiply(&door_osd->door_matrix[0]); M3rMatrixStack_Multiply(&m1); for (i = 0; i < door_osd->door_class->geometry_array[0]->num_furn_geoms; i++) { M3rMinMaxBBox_To_BBox( &door_osd->door_class->geometry_array[0]->furn_geom[i].geometry->pointArray->minmax_boundingBox, &bBox); - + M3rBBox_Draw_Line(&bBox, IMcShade_White); - } - M3rMatrixStack_Pop(); + } + M3rMatrixStack_Pop(); if( door_osd->flags & OBJcDoorFlag_DoubleDoors ) { geometry_array = door_osd->door_class->geometry_array[1] ? door_osd->door_class->geometry_array[1] : door_osd->door_class->geometry_array[0]; - M3rMatrixStack_Push(); + M3rMatrixStack_Push(); M3rMatrixStack_Multiply(&door_osd->door_matrix[1]); M3rMatrixStack_Multiply(&m1); for (i = 0; i < geometry_array->num_furn_geoms; i++) { M3rMinMaxBBox_To_BBox( &geometry_array->furn_geom[i].geometry->pointArray->minmax_boundingBox, &bBox); - + M3rBBox_Draw_Line(&bBox, IMcShade_White); } - M3rMatrixStack_Pop(); - } + M3rMatrixStack_Pop(); + } } else if( door_osd->door_frame ) { @@ -805,7 +805,7 @@ static void OBJiDoor_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) else if( OBJgDoor_ShowActivationCircles ) { M3tPoint3D circle_center = { 0,0.5,0 }; - M3rMatrixStack_Push(); + M3rMatrixStack_Push(); M3rMatrixStack_ApplyTranslate(inObject->position); M3rMatrixStack_Multiply(&door_osd->rotation_matrix); M3rGeom_State_Commit(); @@ -825,7 +825,7 @@ static UUtError OBJiDoor_Enumerate( OBJtObject *inObject, OBJtEnumCallback_Objec static void OBJiDoor_GetBoundingSphere( const OBJtObject *inObject, M3tBoundingSphere *outBoundingSphere ) { OBJtOSD_Door *door_osd; - + door_osd = (OBJtOSD_Door*)inObject->object_data; *outBoundingSphere = door_osd->bounding_sphere; @@ -838,20 +838,20 @@ static void OBJiDoor_OSDGetName( const OBJtOSD_All *inObject, char *outName, UUt char name[100]; if( door_osd->door_class ) - sprintf( name, "door_%02d", door_osd->id ); + sprintf( name, "door_%02d", door_osd->id ); else - sprintf( name, "door_frame_%02d", door_osd->id ); + sprintf( name, "door_frame_%02d", door_osd->id ); - UUrString_Copy(outName, name, inNameLength); + UUrString_Copy(outName, name, inNameLength); } // ---------------------------------------------------------------------- static void OBJiDoor_GetOSD( const OBJtObject *inObject, OBJtOSD_All *outOSD) { OBJtOSD_Door *door_osd; - + door_osd = (OBJtOSD_Door*)inObject->object_data; - + UUrMemory_MoveFast( door_osd, &outOSD->osd.door_osd, sizeof(OBJtOSD_Door) ); ONrEventList_Copy( &door_osd->event_list, &outOSD->osd.door_osd.event_list ); @@ -868,14 +868,14 @@ static UUtBool OBJiDoor_IntersectsLine( const OBJtObject *inObject, const M3tPoi { UUrMemory_Clear(&sphere, sizeof(M3tBoundingSphere)); - + // get the bounding sphere OBJiDoor_GetBoundingSphere(inObject, &sphere); - + sphere.center.x += inObject->position.x; sphere.center.y += inObject->position.y; sphere.center.z += inObject->position.z; - + // do the fast test to see if the line is colliding with the bounding sphere result = CLrSphere_Line(inStartPoint, inEndPoint, &sphere); if (result == UUcTrue) @@ -910,7 +910,7 @@ static UUtBool OBJiDoor_IntersectsLine( const OBJtObject *inObject, const M3tPoi // calculate a start point and an end poing in object space MUrMatrix_MultiplyPoint(inStartPoint, &inverse_matrix, &start_point); MUrMatrix_MultiplyPoint(inEndPoint, &inverse_matrix, &end_point); - + if (door_osd->door_class == NULL) { // CB: just a door frame... return TRUE if intersects anywhere on bounding sphere // this isn't the best solution, but it's quick and doesn't crash @@ -922,7 +922,7 @@ static UUtBool OBJiDoor_IntersectsLine( const OBJtObject *inObject, const M3tPoi if (result == UUcTrue) break; } } - + if( !result && ( door_osd->flags & OBJcDoorFlag_DoubleDoors ) && (door_osd->door_class != NULL)) { geometry_array = door_osd->door_class->geometry_array[1] ? door_osd->door_class->geometry_array[1] : door_osd->door_class->geometry_array[0]; @@ -937,7 +937,7 @@ static UUtBool OBJiDoor_IntersectsLine( const OBJtObject *inObject, const M3tPoi MUrMatrix_Translate(&inverse_matrix, &neg_position); MUrMatrix_Multiply( &max_matrix, &inverse_matrix, &inverse_matrix ); - + // calculate a start point and an end poing in object space MUrMatrix_MultiplyPoint(inStartPoint, &inverse_matrix, &start_point); MUrMatrix_MultiplyPoint(inEndPoint, &inverse_matrix, &end_point); @@ -963,20 +963,20 @@ static UUtError OBJiDoor_SetDefaults(OBJtOSD_All *outOSD) void *instances[OBJcMaxInstances]; UUtUns32 num_instances; char *instance_name; - + // clear the osd UUrMemory_Clear(&outOSD->osd.door_osd, sizeof(OBJtOSD_Door)); - + // get a list of instances of the class error = TMrInstance_GetDataPtr_List( OBJcTemplate_DoorClass, OBJcMaxInstances, &num_instances, instances); UUmError_ReturnOnError(error); - + // error out if we have no door instances if(!num_instances) return UUcError_Generic; // copy the name of the first door template name - instance_name = TMrInstance_GetInstanceName(instances[0]); - + instance_name = TMrInstance_GetInstanceName(instances[0]); + UUrString_Copy( outOSD->osd.door_osd.door_class_name, instance_name, OBJcMaxNameLength); // default initial data @@ -985,7 +985,7 @@ static UUtError OBJiDoor_SetDefaults(OBJtOSD_All *outOSD) outOSD->osd.door_osd.activation_radius_squared = UUmSQR( UUmFeetToUnits( 10 ) ); outOSD->osd.door_osd.door_texture[0][0] = 0; outOSD->osd.door_osd.door_texture[1][0] = 0; - + // initialize the event list ONrEventList_Initialize( &outOSD->osd.door_osd.event_list ); @@ -997,9 +997,9 @@ static UUtError OBJiDoor_New( OBJtObject *inObject, const OBJtOSD_All *inOSD) { OBJtOSD_All osd_all; UUtError error; - + if (inOSD == NULL) - { + { error = OBJiDoor_SetDefaults(&osd_all); UUmError_ReturnOnError(error); @@ -1007,8 +1007,8 @@ static UUtError OBJiDoor_New( OBJtObject *inObject, const OBJtOSD_All *inOSD) } else { - // this is a door frame created at level load - if( inOSD->osd.door_osd.id == 0xFFFF ) + // this is a door frame created at level load + if( inOSD->osd.door_osd.id == 0xFFFF ) { osd_all.osd.door_osd.id = ONrMechanics_GetNextID( OBJcType_Door ); osd_all.osd.door_osd.flags = OBJcDoorFlag_InDoorFrame | OBJcDoorFlag_TestMode; @@ -1022,17 +1022,17 @@ static UUtError OBJiDoor_New( OBJtObject *inObject, const OBJtOSD_All *inOSD) osd_all.osd.door_osd.activation_radius_squared = inOSD->osd.door_osd.activation_radius_squared; UUrString_Copy( osd_all.osd.door_osd.door_texture[0], inOSD->osd.door_osd.door_texture[0], OBJcMaxNameLength ); UUrString_Copy( osd_all.osd.door_osd.door_texture[1], inOSD->osd.door_osd.door_texture[1], OBJcMaxNameLength ); - + ONrEventList_Initialize( &osd_all.osd.door_osd.event_list ); inOSD = &osd_all; } } - + // set the object specific data and position OBJiDoor_SetOSD(inObject, inOSD); OBJiDoor_UpdatePosition(inObject); - + return UUcError_None; } // ---------------------------------------------------------------------- @@ -1115,7 +1115,7 @@ static UUtError OBJiDoor_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inOSD) door_osd->center_offset.x = 0; door_osd->center_offset.z = 0; } - + if( door_osd->flags & OBJcDoorFlag_DoubleDoors ) { //door_osd->center_offset @@ -1200,12 +1200,12 @@ static void OBJiDoor_UpdatePosition( OBJtObject *inObject) // get a pointer to the object osd door_osd = (OBJtOSD_Door*)inObject->object_data; - + // convert the rotation to radians rot_x = inObject->rotation.x * M3cDegToRad; rot_y = inObject->rotation.y * M3cDegToRad; rot_z = inObject->rotation.z * M3cDegToRad; - + // update the rotation matrix euler.order = MUcEulerOrderXYZs; euler.x = rot_x; @@ -1238,14 +1238,14 @@ static UUtUns32 OBJiDoor_Read_v1( OBJtObject *inObject, UUtUns16 inVersion, UUtB door_osd->flags &= OBJcDoorFlag_Persist; - num_bytes = - OBJcMaxNameLength + - sizeof(UUtUns16) + + num_bytes = + OBJcMaxNameLength + + sizeof(UUtUns16) + sizeof(UUtUns16) + sizeof(UUtUns16) + - sizeof(float) + - sizeof(float) + - sizeof(float) + + sizeof(float) + + sizeof(float) + + sizeof(float) + sizeof(float); // initialize and read the event list @@ -1256,7 +1256,7 @@ static UUtUns32 OBJiDoor_Read_v1( OBJtObject *inObject, UUtUns16 inVersion, UUtB OBJiDoor_SetOSD(inObject, &osd_all); OBJiDoor_UpdatePosition(inObject); - + return num_bytes; } @@ -1286,16 +1286,16 @@ static UUtUns32 OBJiDoor_Read_v2( OBJtObject *inObject, UUtUns16 inVersion, UUtB door_osd->flags &= OBJcDoorFlag_Persist; - num_bytes = - OBJcMaxNameLength + - sizeof(UUtUns16) + + num_bytes = + OBJcMaxNameLength + + sizeof(UUtUns16) + sizeof(UUtUns16) + sizeof(UUtUns16) + - sizeof(float) + - sizeof(float) + - sizeof(float) + sizeof(float) + - OBJcMaxNameLength + + sizeof(float) + + sizeof(float) + + sizeof(float) + + OBJcMaxNameLength + OBJcMaxNameLength; // initialize and read the event list @@ -1306,7 +1306,7 @@ static UUtUns32 OBJiDoor_Read_v2( OBJtObject *inObject, UUtUns16 inVersion, UUtB OBJiDoor_SetOSD(inObject, &osd_all); OBJiDoor_UpdatePosition(inObject); - + return num_bytes; } @@ -1332,10 +1332,10 @@ static UUtError OBJiDoor_Write( OBJtObject *inObject, UUtUns8 *ioBuffer, UUtUns3 UUtUns32 bytes_available; door_osd = (OBJtOSD_Door*)inObject->object_data; - + // set the number of bytes available bytes_available = *ioBufferSize; - + // put the geometry name in the buffer OBJmWriteStringToBuffer(ioBuffer, door_osd->door_class_name, OBJcMaxNameLength, bytes_available, OBJcWrite_Little); OBJmWrite2BytesToBuffer(ioBuffer, door_osd->id, UUtUns16, bytes_available, OBJcWrite_Little); @@ -1352,7 +1352,7 @@ static UUtError OBJiDoor_Write( OBJtObject *inObject, UUtUns8 *ioBuffer, UUtUns3 // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = *ioBufferSize - bytes_available; - + return UUcError_None; } // ---------------------------------------------------------------------- @@ -1360,21 +1360,21 @@ static UUtUns32 OBJiDoor_GetOSDWriteSize( const OBJtObject *inObject ) { OBJtOSD_Door *door_osd; UUtUns32 size; - + // get a pointer to the door_osd door_osd = (OBJtOSD_Door*)inObject->object_data; - + // calculate the number of bytes needed to save the OSD - size = - OBJcMaxNameLength + - sizeof(UUtUns16) + - sizeof(UUtUns16) + + size = + OBJcMaxNameLength + + sizeof(UUtUns16) + + sizeof(UUtUns16) + sizeof(UUtUns16) + sizeof(float) + sizeof(float) + sizeof(float) + sizeof(float) + - OBJcMaxNameLength + + OBJcMaxNameLength + OBJcMaxNameLength; size += ONrEventList_GetWriteSize( &door_osd->event_list ); @@ -1391,10 +1391,10 @@ static UUtBool OBJiDoor_Search( const OBJtObject *inObject, const UUtUns32 inSea { OBJtOSD_Door *door_osd; UUtBool found; - + // get a pointer to the object osd door_osd = (OBJtOSD_Door *) inObject->object_data; - + // perform the check switch (inSearchType) { @@ -1406,7 +1406,7 @@ static UUtBool OBJiDoor_Search( const OBJtObject *inObject, const UUtUns32 inSea found = UUcFalse; break; } - + return found; } @@ -1447,9 +1447,9 @@ UUtError OBJrDoor_DrawInitialize(void) UUtError error; TStFontFamily *font_family; IMtPixelType textureFormat; - + M3rDrawEngine_FindGrayscalePixelType(&textureFormat); - + OBJgDoor_WhiteColor = IMrPixel_FromShade(textureFormat, IMcShade_White); error = TSrFontFamily_Get(TScFontFamily_Default, &font_family); @@ -1457,23 +1457,23 @@ UUtError OBJrDoor_DrawInitialize(void) { goto cleanup; } - + error = TSrContext_New(font_family, TScFontSize_Default, TScStyle_Bold, TSc_HLeft, UUcFalse, &OBJgDoor_TextContext); if (error != UUcError_None) { goto cleanup; } - + OBJgDoor_Dest.x = 2; OBJgDoor_Dest.y = TSrFont_GetLeadingHeight(TSrContext_GetFont(OBJgDoor_TextContext, TScStyle_InUse)) + TSrFont_GetAscendingHeight(TSrContext_GetFont(OBJgDoor_TextContext, TScStyle_InUse)); - + TSrContext_GetStringRect(OBJgDoor_TextContext, "XXXX-XXXXX-XX", &OBJgDoor_TextureBounds); - + OBJgDoor_TextureWidth = OBJgDoor_TextureBounds.right; OBJgDoor_TextureHeight = OBJgDoor_TextureBounds.bottom; - + OBJgDoor_WidthRatio = (float)OBJgDoor_TextureWidth / (float)OBJgDoor_TextureHeight; - + error = M3rTextureMap_New( OBJgDoor_TextureWidth, OBJgDoor_TextureHeight, textureFormat, M3cTexture_AllocMemory, M3cTextureFlags_None, "Door texture", &OBJgDoor_Texture); if (error != UUcError_None) { @@ -1482,7 +1482,7 @@ UUtError OBJrDoor_DrawInitialize(void) OBJgDoor_DrawInitialized = UUcTrue; } - + return UUcError_None; cleanup: @@ -1515,13 +1515,13 @@ OBJrDoor_DrawTerminate( // ========================================================================================== static UUtError OBJrDoor_AddEvent( OBJtOSD_Door *inDoor_osd, ONtEvent *inEvent ) -{ +{ ONrEventList_AddEvent( &inDoor_osd->event_list, inEvent ); return UUcError_None; } static UUtError OBJrDoor_DeleteEvent( OBJtOSD_Door *inDoor_osd, UUtUns32 inIndex ) -{ +{ ONrEventList_DeleteEvent( &inDoor_osd->event_list, inIndex ); return UUcError_None; } @@ -1588,7 +1588,7 @@ static UUtBool OBJrDoor_CharacterOnSide( ONtCharacter* inCharacter, OBJtObject * static UUtBool OBJrDoor_NeedToCheckNearbyCharacters(OBJtObject *inObject) { OBJtOSD_Door *door_osd; - + UUmAssert( inObject->object_type == OBJcType_Door ); door_osd = (OBJtOSD_Door*)inObject->object_data; @@ -1624,29 +1624,29 @@ static UUtBool OBJrDoor_NeedToCheckNearbyCharacters(OBJtObject *inObject) UUtBool OBJrDoor_IsOpen(OBJtObject *inObject) { OBJtOSD_Door *door_osd; - + UUmAssert( inObject->object_type == OBJcType_Door ); door_osd = (OBJtOSD_Door*)inObject->object_data; - + return (door_osd->state == OBJcDoorState_Open); } UUtBool OBJrDoor_OpensManually(OBJtObject *inObject) { OBJtOSD_Door *door_osd; - + UUmAssert( inObject->object_type == OBJcType_Door ); door_osd = (OBJtOSD_Door*)inObject->object_data; - + return (door_osd->flags & OBJcDoorFlag_Manual); } UUtBool OBJrDoor_CharacterCanOpen( ONtCharacter* inCharacter, OBJtObject *inObject, UUtUns8 inSide ) { OBJtOSD_Door *door_osd; - + UUmAssert( inObject->object_type == OBJcType_Door ); door_osd = (OBJtOSD_Door*)inObject->object_data; @@ -1687,7 +1687,7 @@ UUtBool OBJrDoor_CharacterOpen( ONtCharacter* inCharacter, OBJtObject *inObject { UUtUns8 side = OBJrDoor_CharacterOnSide(inCharacter, inObject); - // see if we can open + // see if we can open if (OBJrDoor_CharacterCanOpen( inCharacter, inObject, side)) { OBJrDoor_Open( inObject, inCharacter ); @@ -1721,7 +1721,7 @@ static void OBJrDoor_Close( OBJtObject *inObject ) } if( door_osd->state != OBJcDoorState_Closed ) - { + { door_osd->state = OBJcDoorState_Closed; if (door_osd->flags & OBJcDoorFlag_Busy) { @@ -1828,7 +1828,7 @@ static void OBJrDoor_HideShowGunk(OBJtOSD_Door *door_osd, OBJtDoor_HideShowGunk UUtUns32 itr; if (OBJcDoor_HideGunk == hideShow) { - for(itr = 0; itr < count; itr++) + for(itr = 0; itr < count; itr++) { UUtUns32 gq_index = indices[itr]; @@ -1836,7 +1836,7 @@ static void OBJrDoor_HideShowGunk(OBJtOSD_Door *door_osd, OBJtDoor_HideShowGunk } } else { - for(itr = 0; itr < count; itr++) + for(itr = 0; itr < count; itr++) { UUtUns32 gq_index = indices[itr]; @@ -1852,7 +1852,7 @@ static void OBJrDoor_HideShowGunk(OBJtOSD_Door *door_osd, OBJtDoor_HideShowGunk void OBJrDoor_Open( OBJtObject *inObject, ONtCharacter *inCharacter ) { - + OBJtOSD_Door *door_osd; UUtUns16 frame_start; UUtUns16 frame_stop; @@ -1863,18 +1863,18 @@ void OBJrDoor_Open( OBJtObject *inObject, ONtCharacter *inCharacter ) UUmAssert( inObject->object_type == OBJcType_Door ); - door_osd = (OBJtOSD_Door*) inObject->object_data; + door_osd = (OBJtOSD_Door*) inObject->object_data; if (door_osd->door_class == NULL) { goto exit; } - + anim = door_osd->door_class->animation; if (!anim) { goto exit; } if( door_osd->state != OBJcDoorState_Open ) - { + { if (door_osd->flags & OBJcDoorFlag_Busy) { // we are opening a door that was in the process of closing UUmAssert(door_osd->internal_door_object[0] != NULL); @@ -1902,7 +1902,7 @@ void OBJrDoor_Open( OBJtObject *inObject, ONtCharacter *inCharacter ) door_object = door_osd->internal_door_object[0]; anim_context = &door_object->physics->animContext; - + // if( anim_context->animationFrame == 0 ) // Handles doors that have never animated yet // anim_context->animationFrame = anim->numFrames-1; @@ -1911,14 +1911,14 @@ void OBJrDoor_Open( OBJtObject *inObject, ONtCharacter *inCharacter ) OBrSetAnimation( door_object, anim, frame_start, frame_stop ); // anim_context->animationFrame = anim->numFrames - anim_context->animationFrame - 1; - + OBrShow( door_object, UUcTrue ); if( door_osd->internal_door_object[1] ) { door_object = door_osd->internal_door_object[1]; anim_context = &door_object->physics->animContext; - + // if( anim_context->animationFrame == 0 ) // Handles doors that have never animated yet // anim_context->animationFrame = anim->numFrames-1; @@ -1927,10 +1927,10 @@ void OBJrDoor_Open( OBJtObject *inObject, ONtCharacter *inCharacter ) OBrSetAnimation( door_object, anim, frame_start, frame_stop ); // anim_context->animationFrame = anim->numFrames - anim_context->animationFrame - 1; - + OBrShow( door_object, UUcTrue ); } - + } else { @@ -2002,7 +2002,7 @@ UUtBool OBJrDoor_CharacterProximity( OBJtObject *inObject, ONtCharacter *inChara float distance_squared; UUtBool proximate; OBJtOSD_Door *door_osd; - + UUmAssert( inObject ); UUmAssert( inObject->object_type == OBJcType_Door ); @@ -2035,7 +2035,7 @@ static ONtCharacter* OBJiDoor_ProximityDetection( OBJtObject* inObject ) UUmAssert( character->flags & ONcCharacterFlag_InUse ); UUmAssert(!(character->flags & ONcCharacterFlag_Dead)); - if (OBJrDoor_CharacterProximity(inObject,character)) + if (OBJrDoor_CharacterProximity(inObject,character)) { side = OBJrDoor_CharacterOnSide(character, inObject); if (OBJrDoor_CharacterCanOpen(character, inObject, side)) { @@ -2107,7 +2107,7 @@ static void OBJiDoor_UpdateAnimation( OBJtObject *inObject ) { anim_context->animationFrame = anim_context->animationStop; } - + anim_context->animation = anim; OBrAnim_Matrix( anim_context, &door_osd->animation_matrix); @@ -2119,7 +2119,7 @@ static void OBJrDoor_Update( OBJtObject *inObject ) ONtCharacter *character; UUtUns16 anim_frame; PHtPhysicsContext *blocking_context; - + UUmAssert( inObject && inObject->object_type == OBJcType_Door ); door_osd = (OBJtOSD_Door*) inObject->object_data; @@ -2127,7 +2127,7 @@ static void OBJrDoor_Update( OBJtObject *inObject ) // ok, we skip out of this function immediately if the door is in a closed state if( !door_osd->internal_door_object[0] && !door_osd->door_class ) { - return; + return; } else if( door_osd->internal_door_object[0] ) { @@ -2236,12 +2236,12 @@ static void OBJrDoor_Update( OBJtObject *inObject ) character = OBJiDoor_ProximityDetection(inObject); if (character) { - if( door_osd->state == OBJcDoorState_Closed ) + if( door_osd->state == OBJcDoorState_Closed ) OBJrDoor_Open(inObject, character); } else if ((door_osd->flags & OBJcDoorFlag_Busy) == 0) { - if( door_osd->state == OBJcDoorState_Open ) + if( door_osd->state == OBJcDoorState_Open ) OBJrDoor_Close( inObject ); } } @@ -2342,7 +2342,7 @@ UUtBool OBJrDoor_TryDoorAction(ONtCharacter *inCharacter, OBJtObject **outCloses user_data.best_door = NULL; user_data.best_door_canopen = UUcFalse; - OBJrObjectType_EnumerateObjects(OBJcType_Door, OBJiDoor_TryActionEvent_Enum, (UUtUns32) &user_data); + OBJrObjectType_EnumerateObjects(OBJcType_Door, OBJiDoor_TryActionEvent_Enum, (UUtUns32) &user_data); *outClosestDoor = user_data.best_door; return user_data.best_door_canopen; @@ -2399,7 +2399,7 @@ static void OBJrDoor_JumpToDoor( UUtUns32 inIndex ) void OBJrDoor_JumpToNextDoor() { UUtUns32 count; - + count = OBJrObjectType_GetNumObjects( OBJcType_Door ); if( count == 0 ) @@ -2415,7 +2415,7 @@ void OBJrDoor_JumpToNextDoor() void OBJrDoor_JumpToPrevDoor() { UUtUns32 count; - + count = OBJrObjectType_GetNumObjects( OBJcType_Door ); if( count == 0 ) @@ -2497,7 +2497,7 @@ static OBJtObject* OBJrDoor_CreateDoorFrame( AKtDoorFrame* inDoorFrame ) osd = &door_osd; level = ONgLevel; - env = level->environment; + env = level->environment; door_frame = inDoorFrame; gq_index = door_frame->gq_index; @@ -2538,8 +2538,8 @@ static OBJtObject* OBJrDoor_CreateDoorFrame( AKtDoorFrame* inDoorFrame ) object = OBJrSelectedObjects_GetSelectedObject(0); - object->flags |= OBJcObjectFlag_Temporary; - + object->flags |= OBJcObjectFlag_Temporary; + OBJiDoor_CreateBoundingSphere( object, &door_osd ); return UUcError_None; @@ -2550,20 +2550,20 @@ static OBtObjectSetup *GetDoorSetup(UUtUns16 inID) /****************** * obj_create id id */ - + OBtObjectSetup *setup = NULL; UUtUns32 i; - + for (i=0; i < ONgGameState->level->objectSetupArray->numObjects; i++) { OBtObjectSetup *test_setup = ONgGameState->level->objectSetupArray->objects + i; - if (inID == test_setup->doorScriptID) { + if (inID == test_setup->doorScriptID) { setup = test_setup; break; } } - + return setup; } @@ -2575,9 +2575,9 @@ static void CreateDoorObjects(OBJtObject *inDoor) if (door_osd->internal_door_object_setup[0]) { door_osd->internal_door_object_setup[0]->flags = OBcFlags_InUse | OBcFlags_FaceCollision; object = OBrList_Add(ONgGameState->objects); - - OBrInit(object, door_osd->internal_door_object_setup[0]); - + + OBrInit(object, door_osd->internal_door_object_setup[0]); + object->flags |= OBcFlags_FlatLighting; object->flat_lighting_shade = door_osd->shade; @@ -2588,7 +2588,7 @@ static void CreateDoorObjects(OBJtObject *inDoor) door_osd->internal_door_object_setup[1]->flags = OBcFlags_InUse | OBcFlags_FaceCollision; object = OBrList_Add(ONgGameState->objects); - OBrInit(object, door_osd->internal_door_object_setup[1]); + OBrInit(object, door_osd->internal_door_object_setup[1]); object->flags |= OBcFlags_FlatLighting; object->flat_lighting_shade = door_osd->shade; @@ -2652,7 +2652,7 @@ static UUtError OBJrDoor_LevelBegin( OBJtObject* object ) OBJtOSD_Door* osd; UUtUns32 gq_index; UUtUns32 tag; - ONtObjectGunk* gunk; + ONtObjectGunk* gunk; UUmAssert( ONgLevel && ONgLevel->environment ); @@ -2661,12 +2661,12 @@ static UUtError OBJrDoor_LevelBegin( OBJtObject* object ) env = level->environment; osd = (OBJtOSD_Door*) object->object_data; - + // if this door has a frame, setup frame attachment if( osd->flags & OBJcDoorFlag_InDoorFrame ) { door_frame = OBJrDoor_FindDoorFrameAt( &osd->door_frame_position ); - + if( !door_frame) { osd->door_frame = NULL; osd->render_quad = NULL; @@ -2678,7 +2678,7 @@ static UUtError OBJrDoor_LevelBegin( OBJtObject* object ) quad = &env->gqGeneralArray->gqGeneral[ gq_index ]; rend = &env->gqRenderArray->gqRender[ gq_index ]; collision = &env->gqCollisionArray->gqCollision[ gq_index ]; - + osd->door_frame = door_frame; osd->render_quad = rend; osd->general_quad = quad; @@ -2717,7 +2717,7 @@ static UUtError OBJrDoor_LevelBegin( OBJtObject* object ) } osd->flags |= OBJcDoorFlag_TestMode; - + OBJtDoor_Reset( object ); return UUcError_None; @@ -2744,7 +2744,7 @@ static UUtError OBJtDoor_Mechanics_LevelBegin( ONtMechanicsClass* inClass ) // init all the loaded objects ONrMechanics_Default_ClassMethod_LevelBegin( inClass ); - if( !OBJrObjectType_IsLocked(OBJcTemplate_DoorClass) ) + if( !OBJrObjectType_IsLocked(OBJcTemplate_DoorClass) ) { // setup empty door frames... for( i = 0; i < env->door_frames->door_count; i++ ) @@ -2774,7 +2774,7 @@ void OBJrDoor_GetExportMatricies( OBJtObject *inObject, M3tMatrix4x3 *ioMatrix1A osd = (OBJtOSD_Door*) inObject->object_data; if( osd->flags & OBJcDoorFlag_DoubleDoors ) - { + { width = OBJiDoor_GetGeometryWidth( inObject ); offset_pos[0].x = osd->center_offset.x + ( width / 2 ); offset_pos[1].x = osd->center_offset.x - ( width / 2 ); @@ -2808,7 +2808,7 @@ void OBJrDoor_GetExportMatricies( OBJtObject *inObject, M3tMatrix4x3 *ioMatrix1A } if( ioMatrix1B ) - { + { // build door 1 closed matrix MUrMatrix_Identity(ioMatrix1B); MUrMatrixStack_Translate(ioMatrix1B, &inObject->position); @@ -2823,22 +2823,22 @@ void OBJrDoor_GetExportMatricies( OBJtObject *inObject, M3tMatrix4x3 *ioMatrix1A { // build door 2 closed matrix MUrMatrix_Identity(ioMatrix2A); - MUrMatrixStack_Translate(ioMatrix2A, &inObject->position); - MUrMatrixStack_Matrix(ioMatrix2A, &rotation_matrix); + MUrMatrixStack_Translate(ioMatrix2A, &inObject->position); + MUrMatrixStack_Matrix(ioMatrix2A, &rotation_matrix); MUrMatrixStack_Translate(ioMatrix2A, &offset_pos[1]); if( !(osd->flags & OBJcDoorFlag_Mirror) ) MUrMatrixStack_RotateY( ioMatrix2A, M3cPi ); - MUrMatrixStack_Matrix(ioMatrix2A, &max_matrix); + MUrMatrixStack_Matrix(ioMatrix2A, &max_matrix); } if( ioMatrix2B ) { // build door 2 opening matrix MUrMatrix_Identity(ioMatrix2B); - MUrMatrixStack_Translate(ioMatrix2B, &inObject->position); - MUrMatrixStack_Matrix(ioMatrix2B, &rotation_matrix); + MUrMatrixStack_Translate(ioMatrix2B, &inObject->position); + MUrMatrixStack_Matrix(ioMatrix2B, &rotation_matrix); MUrMatrixStack_Translate(ioMatrix2B, &offset_pos[1]); - MUrMatrixStack_Matrix(ioMatrix2B, &max_matrix); + MUrMatrixStack_Matrix(ioMatrix2B, &max_matrix); if( !(osd->flags & OBJcDoorFlag_Mirror) ) MUrMatrixStack_RotateY( ioMatrix2B, M3cPi ); } @@ -2897,10 +2897,10 @@ UUtUns32 OBJrDoor_ComputeObstruction(OBJtObject *inObject, UUtUns32 *outDoorID, // the rotation is a homomorphism) MUrMatrix_BuildRotateX(M3cPi, &doubledoor_matrix); - MUrMatrix_MultiplyPoints(2, &doubledoor_matrix, &outDoorPoints[2], &outDoorPoints[2]); + MUrMatrix_MultiplyPoints(2, &doubledoor_matrix, &outDoorPoints[2], &outDoorPoints[2]); MUrMatrix_MultiplyPoints(2, &door_anim_matrix, &outDoorPoints[2], &outDoorPoints[2]); - MUrMatrix_MultiplyPoints(2, &doubledoor_matrix, &outDoorPoints[2], &outDoorPoints[2]); - } + MUrMatrix_MultiplyPoints(2, &doubledoor_matrix, &outDoorPoints[2], &outDoorPoints[2]); + } // apply the rotation from Max space to Oni space for (itr = 0; itr < num_points; itr++) { @@ -3072,7 +3072,7 @@ UUtError OBJrDoor_DumpAll(void) } } - OBJrObjectType_EnumerateObjects(OBJcType_Door, OBJiDoor_DebugDump_Enum, (UUtUns32) &dump_structure); + OBJrObjectType_EnumerateObjects(OBJcType_Door, OBJiDoor_DebugDump_Enum, (UUtUns32) &dump_structure); if (dump_structure.dump_file != NULL) { BFrFile_Close(dump_structure.dump_file); @@ -3090,7 +3090,7 @@ UUtError OBJrDoor_DumpNearby(M3tPoint3D *inPoint, float inRadius) dump_structure.radius = inRadius; dump_structure.dump_file = NULL; - OBJrObjectType_EnumerateObjects(OBJcType_Door, OBJiDoor_DebugDump_Enum, (UUtUns32) &dump_structure); + OBJrObjectType_EnumerateObjects(OBJcType_Door, OBJiDoor_DebugDump_Enum, (UUtUns32) &dump_structure); return UUcError_None; } @@ -3107,7 +3107,7 @@ UUtError OBJrDoor_Initialize( ) ONtMechanicsMethods mechanics_methods; // initialize globals - OBJgDoor_DrawDoor = UUcTrue; + OBJgDoor_DrawDoor = UUcTrue; OBJgDoor_CurrentDoor = 0xFFFF; OBJgDoor_Shade = IMcShade_White; OBJgDoor_IgnoreLocks = UUcFalse; @@ -3116,7 +3116,7 @@ UUtError OBJrDoor_Initialize( ) // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiDoor_New; methods.rSetDefaults = OBJiDoor_SetDefaults; @@ -3132,12 +3132,12 @@ UUtError OBJrDoor_Initialize( ) methods.rSetOSD = OBJiDoor_SetOSD; methods.rRead = OBJiDoor_Read; methods.rWrite = OBJiDoor_Write; - + // set up the type methods methods.rGetClassVisible = OBJiDoor_GetVisible; methods.rSearch = OBJiDoor_Search; methods.rSetClassVisible = OBJiDoor_SetVisible; - + // set up the mechanics methods mechanics_methods.rInitialize = OBJrDoor_LevelBegin; mechanics_methods.rTerminate = OBJtDoor_Mechanics_Terminate; @@ -3153,7 +3153,7 @@ UUtError OBJrDoor_Initialize( ) // register the door methods error = ONrMechanics_Register( OBJcType_Door, OBJcTypeIndex_Door, "Door", sizeof(OBJtOSD_Door), &methods, 0, &mechanics_methods ); UUmError_ReturnOnError(error); - + #if CONSOLE_DEBUGGING_COMMANDS error = SLrGlobalVariable_Register_Bool( "door_show_debug", "Shows debug geometry", &OBJgDoor_ShowDebug ); UUmError_ReturnOnError(error); diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Flags.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Flags.c index 0a94ccc..a415094 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Flags.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Flags.c @@ -66,9 +66,9 @@ OBJrFlag_DrawInitialize( UUtError error; TStFontFamily *font_family; IMtPixelType textureFormat; - + M3rDrawEngine_FindGrayscalePixelType(&textureFormat); - + OBJgFlag_WhiteColor = IMrPixel_FromShade(textureFormat, IMcShade_White); error = TSrFontFamily_Get(TScFontFamily_Default, &font_family); @@ -76,25 +76,25 @@ OBJrFlag_DrawInitialize( { goto cleanup; } - + error = TSrContext_New(font_family, TScFontSize_Default, TScStyle_Bold, TSc_HLeft, UUcFalse, &OBJgFlag_TextContext); if (error != UUcError_None) { goto cleanup; } - + OBJgFlag_Dest.x = 2; OBJgFlag_Dest.y = TSrFont_GetLeadingHeight(TSrContext_GetFont(OBJgFlag_TextContext, TScStyle_InUse)) + TSrFont_GetAscendingHeight(TSrContext_GetFont(OBJgFlag_TextContext, TScStyle_InUse)); - + TSrContext_GetStringRect(OBJgFlag_TextContext, "XX-XXXX", &OBJgFlag_TextureBounds); - + OBJgFlag_TextureWidth = OBJgFlag_TextureBounds.right; OBJgFlag_TextureHeight = OBJgFlag_TextureBounds.bottom; - + OBJgFlag_WidthRatio = (float)OBJgFlag_TextureWidth / (float)OBJgFlag_TextureHeight; - + error = M3rTextureMap_New( OBJgFlag_TextureWidth, @@ -108,7 +108,7 @@ OBJrFlag_DrawInitialize( { goto cleanup; } - + OBJgFlag_DrawingInitialized = UUcTrue; } @@ -135,14 +135,14 @@ OBJiFlag_DrawName( error = OBJrFlag_DrawInitialize(); if (error == UUcError_None) { char name[OBJcMaxNameLength + 1]; - + // erase the texture and set the text contexts shade M3rTextureMap_Fill(OBJgFlag_Texture, OBJgFlag_WhiteColor, NULL); TSrContext_SetShade(OBJgFlag_TextContext, IMcShade_Black); - + // get the flag's title OBJrObject_GetName(inObject, name, OBJcMaxNameLength); - + // draw the string to the texture TSrContext_DrawString( OBJgFlag_TextContext, @@ -150,7 +150,7 @@ OBJiFlag_DrawName( name, &OBJgFlag_TextureBounds, &OBJgFlag_Dest); - + M3rGeom_State_Set(M3cGeomStateIntType_SpriteMode, M3cGeomState_SpriteMode_Normal); M3rGeom_State_Commit(); @@ -163,7 +163,7 @@ OBJiFlag_DrawName( IMcShade_White, M3cMaxAlpha); } - + return; } @@ -192,9 +192,9 @@ OBJrFlag_GetUniqueID( { ONtFlag flag; UUtBool found; - + OBJgFlag_ID++; - + // make sure the id_number isn't a duplicate found = ONrLevel_Flag_ID_To_Flag((UUtUns16)OBJgFlag_ID, &flag); while (found) @@ -272,45 +272,45 @@ OBJiFlag_Draw( #if TOOL_VERSION OBJtOSD_Flag *flag_osd; M3tPoint3D camera_location; - - M3tPoint3D points[4] = + + M3tPoint3D points[4] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 10.0f, 0.0f }, { 0.0f, 8.0f, 4.0f }, { 0.0f, 6.0f, 0.0f } }; - + if (OBJgFlag_DrawFlags == UUcFalse) { return; } - + // get a pointer to the object osd flag_osd = (OBJtOSD_Flag*)inObject->object_data; - + if ((OBJgFlag_ViewPrefix != 0) && (OBJgFlag_ViewPrefix != flag_osd->id_prefix)) { return; } - + // set up the matrix stack M3rMatrixStack_Push(); M3rMatrixStack_ApplyTranslate(inObject->position); M3rMatrixStack_Multiply(&flag_osd->rotation_matrix); M3rGeom_State_Commit(); - + // draw the flag M3rGeom_Line_Light(points + 0, points + 1, flag_osd->shade); M3rGeom_Line_Light(points + 1, points + 2, flag_osd->shade); M3rGeom_Line_Light(points + 2, points + 3, flag_osd->shade); - + // draw the name camera_location = CArGetLocation(); if (MUrPoint_Distance(&inObject->position, &camera_location) < OBJgFlag_DrawNameDistance) { OBJiFlag_DrawName(inObject, points + 1); } - + // draw the rotation ring if this flag is selected if (inDrawFlags & OBJcDrawFlag_Selected) { M3tBoundingSphere bounding_sphere; - + OBJrObject_GetBoundingSphere(inObject, &bounding_sphere); OBJrObjectUtil_DrawRotationRings(inObject, &bounding_sphere, OBJcDrawFlag_RingY); } @@ -329,10 +329,10 @@ OBJiFlag_Enumerate( UUtUns32 inUserData) { char name[OBJcMaxNameLength + 1]; - + OBJrObject_GetName(inObject, name, OBJcMaxNameLength); inEnumCallback(name, inUserData); - + return UUcError_None; } @@ -362,11 +362,11 @@ OBJiFlag_OSDGetName( // get a pointer to the object osd flag_osd = &inOSD->osd.flag_osd; - + // put the name into outName char_1 = UUmHighByte(flag_osd->id_prefix); char_2 = UUmLowByte(flag_osd->id_prefix); - + if ((char_1 == 0) && (char_2 == 0)) { sprintf(buffer, "%d", flag_osd->id_number); @@ -410,7 +410,7 @@ OBJiFlag_GetOSD( // get a pointer to the object osd flag_osd = (OBJtOSD_Flag*)inObject->object_data; - + outOSD->osd.flag_osd = *flag_osd; } @@ -420,13 +420,13 @@ OBJiFlag_GetOSDWriteSize( const OBJtObject *inObject) { UUtUns32 size; - + size = sizeof(IMtShade) + sizeof(UUtUns16) + sizeof(UUtUns16) + (OBJcMaxNoteChars + 1); - + return size; } @@ -440,14 +440,14 @@ OBJiFlag_IntersectsLine( M3tBoundingSphere sphere; UUrMemory_Clear(&sphere, sizeof(M3tBoundingSphere)); - + // get the bounding sphere OBJrObject_GetBoundingSphere(inObject, &sphere); - + sphere.center.x += inObject->position.x; sphere.center.y += inObject->position.y; sphere.center.z += inObject->position.z; - + return CLrSphere_Line(inStartPoint, inEndPoint, &sphere); } @@ -487,10 +487,10 @@ OBJiFlag_New( OBJtOSD_All osd_all; OBJtOSD_Flag *flag_osd; UUtError error; - + // get a pointer to the object osd flag_osd = (OBJtOSD_Flag*)inObject->object_data; - + if (inOSD == NULL) { error = OBJiFlag_SetDefaults(&osd_all); @@ -500,11 +500,11 @@ OBJiFlag_New( { osd_all = *inOSD; } - + // set the object specific data and position error = OBJiFlag_SetOSD(inObject, &osd_all); // UUmError_ReturnOnError(error); - + OBJrObject_UpdatePosition(inObject); UUrMemory_Block_VerifyList(); @@ -522,7 +522,7 @@ OBJiFlag_Read( { OBJtOSD_All osd_all; UUtUns32 num_bytes; - + // read the data OBJmGet4BytesFromBuffer(inBuffer, osd_all.osd.flag_osd.shade, UUtUns32, inSwapIt); OBJmGet2BytesFromBuffer(inBuffer, osd_all.osd.flag_osd.id_prefix, UUtUns16, inSwapIt); @@ -532,11 +532,11 @@ OBJiFlag_Read( #endif num_bytes = sizeof(UUtUns32) + sizeof(UUtUns16) + sizeof(UUtUns16) + (OBJcMaxNoteChars + 1); - + // bring the object up to date OBJiFlag_SetOSD(inObject, &osd_all); OBJrObject_UpdatePosition(inObject); - + return num_bytes; } @@ -547,12 +547,12 @@ OBJiFlag_SetOSD( const OBJtOSD_All *inOSD) { OBJtOSD_Flag *flag_osd; - + UUmAssert(inOSD); - + // get a pointer to the object osd flag_osd = (OBJtOSD_Flag*)inObject->object_data; - + // copy the from inOSD to flag_osd flag_osd->shade = inOSD->osd.flag_osd.shade; flag_osd->id_prefix = inOSD->osd.flag_osd.id_prefix; @@ -560,14 +560,14 @@ OBJiFlag_SetOSD( #if TOOL_VERSION UUrString_Copy(flag_osd->note, inOSD->osd.flag_osd.note, OBJcMaxNoteChars); #endif - + // save the last used id number OBJiFlag_SetFlagShade(flag_osd->shade); OBJiFlag_SetFlagPrefix(flag_osd->id_prefix); OBJiFlag_SetFlagID(flag_osd->id_number); - + UUrMemory_Block_VerifyList(); - + return UUcError_None; } @@ -581,15 +581,15 @@ OBJiFlag_UpdatePosition( float rot_y; float rot_z; MUtEuler euler; - + // get a pointer to the object osd flag_osd = (OBJtOSD_Flag*)inObject->object_data; - + // convert the rotation to radians rot_x = inObject->rotation.x * M3cDegToRad; rot_y = inObject->rotation.y * M3cDegToRad; rot_z = inObject->rotation.z * M3cDegToRad; - + // update the rotation matrix euler.order = MUcEulerOrderXYZs; euler.x = rot_x; @@ -610,10 +610,10 @@ OBJiFlag_Write( // get a pointer to the object osd flag_osd = (OBJtOSD_Flag*)inObject->object_data; - + // set the number of bytes available bytes_available = *ioBufferSize; - + // put the shade, id_prefix, id_number, and note OBJmWrite4BytesToBuffer(ioBuffer, flag_osd->shade, UUtUns32, bytes_available, OBJcWrite_Little); OBJmWrite2BytesToBuffer(ioBuffer, flag_osd->id_prefix, UUtUns16, bytes_available, OBJcWrite_Little); @@ -623,10 +623,10 @@ OBJiFlag_Write( #else OBJmWriteStringToBuffer(ioBuffer, "", OBJcMaxNoteChars + 1, bytes_available, OBJcWrite_Little); #endif - + // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = *ioBufferSize - bytes_available; - + return UUcError_None; } @@ -652,10 +652,10 @@ OBJiFlag_Search( { OBJtOSD_Flag *flag_osd; UUtBool found; - + // get a pointer to the object osd flag_osd = (OBJtOSD_Flag*)inObject->object_data; - + // perform the check found = UUcFalse; switch (inSearchType) @@ -667,7 +667,7 @@ OBJiFlag_Search( } break; } - + return found; } @@ -696,10 +696,10 @@ OBJiFlag_SetViewPrefix( { UUtUns8 char_1; UUtUns8 char_2; - + if (inParameterListLength > 1) { return UUcError_Generic; } if (inParameterList[0].type != SLcType_String) { return UUcError_Generic; } - + if (inParameterList[0].val.str == NULL) { OBJgFlag_ViewPrefix = 0; @@ -708,7 +708,7 @@ OBJiFlag_SetViewPrefix( { char_1 = inParameterList[0].val.str[0]; char_2 = inParameterList[0].val.str[1]; - + if (char_2 == 0) { OBJgFlag_ViewPrefix = char_1; @@ -718,10 +718,10 @@ OBJiFlag_SetViewPrefix( OBJgFlag_ViewPrefix = UUmMakeShort(char_1, char_2); } } - + *outTicksTillCompletion = 0; *outStall = UUcFalse; - + return UUcError_None; } @@ -732,10 +732,10 @@ OBJrFlag_Initialize( { UUtError error; OBJtMethods methods; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiFlag_New; methods.rSetDefaults = OBJiFlag_SetDefaults; @@ -756,7 +756,7 @@ OBJrFlag_Initialize( methods.rSearch = OBJiFlag_Search; methods.rSetClassVisible = OBJiFlag_SetVisible; methods.rGetUniqueOSD = OBJiFlag_GetUniqueOSD; - + // register the furniture methods error = OBJrObjectGroup_Register( @@ -767,7 +767,7 @@ OBJrFlag_Initialize( &methods, OBJcObjectGroupFlag_None); UUmError_ReturnOnError(error); - + #if CONSOLE_DEBUGGING_COMMANDS // register the id set function error = @@ -783,14 +783,14 @@ OBJrFlag_Initialize( "Enables the display of flags", &OBJgFlag_DrawFlags); UUmError_ReturnOnError(error); - + error = SLrGlobalVariable_Register_Float( "flag_name_distance", "Specifies the distance from the camera that flag names no longer draw.", &OBJgFlag_DrawNameDistance); UUmError_ReturnOnError(error); - + error = SLrScript_Command_Register_Void( "flag_view_prefix", @@ -806,6 +806,6 @@ OBJrFlag_Initialize( OBJgFlag_ID = 0; OBJgFlag_DrawNameDistance = OBJcFlag_DefaultDrawNameDistance; OBJgFlag_ViewPrefix = 0; - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Furniture.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Furniture.c index cac97f0..cfd0a5d 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Furniture.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Furniture.c @@ -42,36 +42,36 @@ OBJiFurniture_CreateBoundingSphere( M3tBoundingSphere *sphere; M3tPoint3D new_center; float new_radius; - + new_center.x = 0.0f; new_center.y = 0.0f; new_center.z = 0.0f; - + // calculate the center of the sphere for (i = 0; i < inOSD->furn_geom_array->num_furn_geoms; i++) { sphere = &inOSD->furn_geom_array->furn_geom[i].geometry->pointArray->boundingSphere; MUmVector_Increment(new_center, sphere->center); } - + new_center.x /= inOSD->furn_geom_array->num_furn_geoms; new_center.y /= inOSD->furn_geom_array->num_furn_geoms; new_center.z /= inOSD->furn_geom_array->num_furn_geoms; - + // caculate the new radius new_radius = 0.0f; for (i = 0; i < inOSD->furn_geom_array->num_furn_geoms; i++) { - M3tVector3D vector; + M3tVector3D vector; float temp_radius; - + sphere = &inOSD->furn_geom_array->furn_geom[i].geometry->pointArray->boundingSphere; MUmVector_Subtract(vector, new_center, sphere->center); temp_radius = MUrVector_Length(&vector) + sphere->radius; - + new_radius = UUmMax(new_radius, temp_radius); } - + // set the bounding sphere inOSD->bounding_sphere.center = new_center; inOSD->bounding_sphere.radius = new_radius; @@ -106,13 +106,13 @@ OBJiFurniture_Read_Version2( OBJtOSD_Furniture *furniture_osd; UUtUns32 bytes_read; UUtUns32 i; - + // read the version 1 data bytes_read = OBJiFurniture_Read_Version1(inObject, inSwapIt, inBuffer); - + // move to the beginning of the version 2 data inBuffer += bytes_read; - + // get a pointer to the object osd furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; @@ -120,10 +120,10 @@ OBJiFurniture_Read_Version2( for (i = 0; i < furniture_osd->num_ls_datas; i++) { OBJtLSData *ls_data; - + // get a pointer to the ls_data ls_data = furniture_osd->ls_data_array + i; - + // read the data from the buffer OBDmGet4BytesFromBuffer(inBuffer, ls_data->index, UUtUns32, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, ls_data->light_flags, UUtUns32, inSwapIt); @@ -133,11 +133,11 @@ OBJiFurniture_Read_Version2( OBDmGet4BytesFromBuffer(inBuffer, ls_data->light_intensity, UUtUns32, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, ls_data->beam_angle, float, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, ls_data->field_angle, float, inSwapIt); - + // set the number of bytes read bytes_read += ((sizeof(UUtUns32) * 3) + (sizeof(float) * 5)); } - + return bytes_read; } @@ -150,19 +150,19 @@ OBJiFurniture_Read_Version14( { OBJtOSD_Furniture *furniture_osd; UUtUns32 bytes_read; - + // read the version 2 data bytes_read = OBJiFurniture_Read_Version2(inObject, inSwapIt, inBuffer); - + // move to the beginning of the version 14 data inBuffer += bytes_read; - + // get a pointer to the object osd furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; // read the tag name bytes_read += OBDmGetStringFromBuffer(inBuffer, furniture_osd->furn_tag, EPcParticleTagNameLength + 1, inSwapIt); - + return bytes_read; } @@ -182,7 +182,7 @@ OBJiFurniture_Delete( // get a pointer to the object osd furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; - + // delete the memory allocated for the ls_data_array if (furniture_osd->ls_data_array) { @@ -220,7 +220,7 @@ void OBJrFurniture_DrawArray( OBJtFurnGeomArray* inGeometryArray, UUtUns32 inDra if (inDrawFlags & OBJcDrawFlag_Selected) { M3rMinMaxBBox_To_BBox( &inGeometryArray->furn_geom[i].geometry->pointArray->minmax_boundingBox, &bBox); - + M3rBBox_Draw_Line(&bBox, IMcShade_White); } // draw the geometry @@ -240,50 +240,50 @@ OBJiFurniture_Draw( OBJtOSD_Furniture *furniture_osd; M3tBoundingBox bBox; UUtUns32 i; - + if (OBJgFurniture_DrawFurniture == UUcFalse) { return; } - + // don't draw when the non-occluding geometry is hidden if (AKgDraw_Occl == UUcTrue) { return; } - + furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; - + if (furniture_osd->furn_geom_array == NULL) return; - + if (!(inObject->flags & OBJcObjectFlag_Gunk)) { for (i = 0; i < furniture_osd->furn_geom_array->num_furn_geoms; i++) { UUtUns32 flags; - + // check the visibility flags flags = furniture_osd->furn_geom_array->furn_geom[i].gq_flags; if (((flags & AKcGQ_Flag_Invisible) != 0) && (AKgDraw_Invis == UUcFalse)) { continue; } - + // draw the geometry AKrEnvironment_DrawIfVisible(furniture_osd->furn_geom_array->furn_geom[i].geometry, &furniture_osd->matrix); } } - + // draw the rotation rings if this is the selected object if (inDrawFlags & OBJcDrawFlag_Selected) { M3rMatrixStack_Push(); M3rMatrixStack_Multiply(&furniture_osd->matrix); M3rGeom_State_Commit(); - + for (i = 0; i < furniture_osd->furn_geom_array->num_furn_geoms; i++) { // draw the bounding box if this is the selected object M3rMinMaxBBox_To_BBox( &furniture_osd->furn_geom_array->furn_geom[i].geometry->pointArray->minmax_boundingBox, &bBox); - + M3rBBox_Draw_Line(&bBox, IMcShade_White); } - + OBJrObjectUtil_DrawRotationRings(inObject, &furniture_osd->bounding_sphere, inDrawFlags); - + M3rMatrixStack_Pop(); } #endif @@ -299,7 +299,7 @@ OBJiFurniture_Enumerate( UUtUns32 inUserData) { UUtError error; - + error = OBJrObjectUtil_EnumerateTemplate( // inObject->object_type, @@ -308,7 +308,7 @@ OBJiFurniture_Enumerate( inEnumCallback, inUserData); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -319,7 +319,7 @@ OBJiFurniture_GetBoundingSphere( M3tBoundingSphere *outBoundingSphere) { OBJtOSD_Furniture *furniture_osd; - + furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; *outBoundingSphere = furniture_osd->bounding_sphere; @@ -334,7 +334,7 @@ OBJiFurniture_OSDGetName( { const OBJtOSD_Furniture *furniture_osd = &inOSD->osd.furniture_osd; - UUrString_Copy(outName, furniture_osd->furn_geom_name, inNameLength); + UUrString_Copy(outName, furniture_osd->furn_geom_name, inNameLength); if (furniture_osd->furn_tag[0] != '\0') { UUrString_Cat(outName, "_", inNameLength); UUrString_Cat(outName, furniture_osd->furn_tag, inNameLength); @@ -351,7 +351,7 @@ OBJiFurniture_OSDSetName( { // OBJtOSD_Furniture *furniture_osd = &inOSD->osd.furniture_osd; -// UUrString_Copy(furniture_osd->furn_geom_name, inName, sizeof(inNameLength)); +// UUrString_Copy(furniture_osd->furn_geom_name, inName, sizeof(inNameLength)); return; } @@ -363,9 +363,9 @@ OBJiFurniture_GetOSD( OBJtOSD_All *outOSD) { OBJtOSD_Furniture *furniture_osd; - + furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; - + outOSD->osd.furniture_osd = *furniture_osd; // copies of the OSD have no particles in them @@ -380,13 +380,13 @@ OBJiFurniture_GetOSDWriteSize( { OBJtOSD_Furniture *furniture_osd; UUtUns32 size; - + // get a pointer to the furniture_osd furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; - + // calculate the number of bytes needed to save the OSD size = BFcMaxFileNameLength + (sizeof(OBJtLSData) * furniture_osd->num_ls_datas) + (EPcParticleTagNameLength + 1); - + return size; } @@ -402,18 +402,18 @@ OBJiFurniture_IntersectsLine( OBJtOSD_Furniture *furniture_osd; UUrMemory_Clear(&sphere, sizeof(M3tBoundingSphere)); - + // if the line collides with the bounding sphere, test to see if the line // collides with the bounding box of the geometries furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; if (furniture_osd->furn_geom_array == NULL) { return UUcFalse; } - + // get the bounding sphere OBJrObject_GetBoundingSphere(inObject, &sphere); - + // put the sphere at the proper place in the world MUrMatrix_MultiplyPoint(&sphere.center, &furniture_osd->matrix, &sphere.center); - + // do the fast test to see if the line is colliding with the bounding sphere result = CLrSphere_Line(inStartPoint, inEndPoint, &sphere); if (result == UUcTrue) @@ -422,16 +422,16 @@ OBJiFurniture_IntersectsLine( M3tPoint3D start_point; M3tPoint3D end_point; M3tMatrix4x3 inverse_matrix; - + result = UUcFalse; - + // calculate the inverse of the location matrix MUrMatrix_Inverse(&furniture_osd->matrix, &inverse_matrix); - + // calculate a start point and an end poing in object space MUrMatrix_MultiplyPoint(inStartPoint, &inverse_matrix, &start_point); MUrMatrix_MultiplyPoint(inEndPoint, &inverse_matrix, &end_point); - + // check the bounding box of each geometry to see if the line intersects the geometry for (i = 0; i < furniture_osd->furn_geom_array->num_furn_geoms; i++) { @@ -442,10 +442,10 @@ OBJiFurniture_IntersectsLine( &end_point); if (result == UUcTrue) { break; } } - + return result; } - + return UUcFalse; } @@ -459,10 +459,10 @@ OBJiFurniture_SetDefaults( UUtUns32 num_instances; UUtUns32 prefix_length; UUtUns32 i; - + // clear the osd UUrMemory_Clear(&outOSD->osd.furniture_osd, sizeof(OBJtOSD_Furniture)); - + // get a list of instances of the class error = TMrInstance_GetDataPtr_List( @@ -471,17 +471,17 @@ OBJiFurniture_SetDefaults( &num_instances, instances); UUmError_ReturnOnError(error); - + prefix_length = strlen(OBJcFurniturePrefix); - - // copy the name of the first furniture geometry array instance into + + // copy the name of the first furniture geometry array instance into // the osd_all. for (i = 0; i < num_instances; i++) { char *instance_name; - + instance_name = TMrInstance_GetInstanceName(instances[i]); - + if (strncmp(instance_name, OBJcFurniturePrefix, prefix_length) == 0) { UUrString_Copy( @@ -491,7 +491,7 @@ OBJiFurniture_SetDefaults( break; } } - + // no tag name outOSD->osd.furniture_osd.furn_tag[0] = '\0'; @@ -499,7 +499,7 @@ OBJiFurniture_SetDefaults( { return UUcError_Generic; } - + return UUcError_None; } @@ -512,20 +512,20 @@ OBJiFurniture_New( OBJtOSD_All osd_all; OBJtOSD_Furniture *furn_osd = (OBJtOSD_Furniture *) inObject->object_data; UUtError error; - + if (inOSD == NULL) { error = OBJiFurniture_SetDefaults(&osd_all); UUmError_ReturnOnError(error); - + // send osd_all to OBJiFurniture_SetOSD() inOSD = &osd_all; } - + // set the object specific data and position OBJiFurniture_SetOSD(inObject, inOSD); OBJrObject_UpdatePosition(inObject); - + return UUcError_None; } @@ -538,7 +538,7 @@ OBJiFurniture_Read( UUtUns8 *inBuffer) { UUtUns32 read_bytes; - + if(inVersion >= OBJcVersion_14) { read_bytes = OBJiFurniture_Read_Version14(inObject, inSwapIt, inBuffer); @@ -636,9 +636,9 @@ OBJiFurniture_SetOSD( EPtEnvParticle *particle; UUtUns32 size; UUtUns32 i, itr; - + UUmAssert(inOSD); - + // get a pointer to the object osd furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; @@ -652,7 +652,7 @@ OBJiFurniture_SetOSD( furn_geom_name, inOSD->osd.furniture_osd.furn_geom_name, BFcMaxFileNameLength); - + // get a pointer to the new furn_geom_array error = TMrInstance_GetDataPtr( @@ -663,28 +663,28 @@ OBJiFurniture_SetOSD( UUrDebuggerMessage("failed to locate instance %s\n", (UUtUns32) furn_geom_name, 0, 0); return error; } - + // don't update anything if the values haven't changed if ((furn_geom_array == furniture_osd->furn_geom_array) && (UUmString_IsEqual(furniture_osd->furn_tag, inOSD->osd.furniture_osd.furn_tag))) { return UUcError_None; } - + // save the pointer to the new furn_geom_array furniture_osd->furn_geom_array = furn_geom_array; - + // save the new furn_geom_name UUrString_Copy( furniture_osd->furn_geom_name, inOSD->osd.furniture_osd.furn_geom_name, BFcMaxFileNameLength); - + // save the new furn_tag UUrString_Copy( furniture_osd->furn_tag, inOSD->osd.furniture_osd.furn_tag, EPcParticleTagNameLength + 1); - + // delete the old ls_data_array if (furniture_osd->ls_data_array) { @@ -692,7 +692,7 @@ OBJiFurniture_SetOSD( furniture_osd->ls_data_array = NULL; furniture_osd->num_ls_datas = 0; } - + // delete the old particle array if (furniture_osd->num_particles > 0) { @@ -711,17 +711,17 @@ OBJiFurniture_SetOSD( for (i = 0; i < furniture_osd->furn_geom_array->num_furn_geoms; i++) { if (furniture_osd->furn_geom_array->furn_geom[i].ls_data == NULL) { continue; } - + size += sizeof(OBJtLSData); furniture_osd->num_ls_datas++; } - + if (size > 0) { // allocate memory for the ls_data_array furniture_osd->ls_data_array = (OBJtLSData*)UUrMemory_Block_NewClear(size); UUmError_ReturnOnNull(furniture_osd->ls_data_array); - + // if inOSD has a ls_data_array, then copy the data from it into the furniture->ls_data_array // otherwise copy the ones from the furn_geom_array if (inOSD->osd.furniture_osd.ls_data_array != NULL) @@ -735,17 +735,17 @@ OBJiFurniture_SetOSD( else { UUtUns32 j; - + // copy the data from the OBJtLSData template instance in the furn_geom for (i = 0, j = 0; i < furniture_osd->furn_geom_array->num_furn_geoms; i++) { if (furniture_osd->furn_geom_array->furn_geom[i].ls_data == NULL) { continue; } - + UUrMemory_MoveFast( furniture_osd->furn_geom_array->furn_geom[i].ls_data, (furniture_osd->ls_data_array + j), sizeof(OBJtLSData)); - + j++; } } @@ -762,7 +762,7 @@ OBJiFurniture_SetOSD( // create the bounding sphere OBJiFurniture_CreateBoundingSphere(inObject, furniture_osd); - + return UUcError_None; } @@ -776,22 +776,22 @@ OBJiFurniture_UpdatePosition( float rot_y; float rot_z; MUtEuler euler; - + // get a pointer to the object osd furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; - + // convert the rotation to radians rot_x = inObject->rotation.x * M3cDegToRad; rot_y = inObject->rotation.y * M3cDegToRad; rot_z = inObject->rotation.z * M3cDegToRad; - + // update the rotation component of the matrix euler.order = MUcEulerOrderXYZs; euler.x = rot_x; euler.y = rot_y; euler.z = rot_z; MUrEulerToMatrix(&euler, &furniture_osd->matrix); - + // set the translation component of the matrix MUrMatrix_SetTranslation(&furniture_osd->matrix, &inObject->position); } @@ -806,12 +806,12 @@ OBJiFurniture_Write( OBJtOSD_Furniture *furniture_osd; UUtUns32 bytes_available; UUtUns32 i; - + furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; - + // set the number of bytes available bytes_available = *ioBufferSize; - + // put the geometry name in the buffer UUrString_Copy_Length( (char*)ioBuffer, @@ -820,14 +820,14 @@ OBJiFurniture_Write( BFcMaxFileNameLength); ioBuffer += BFcMaxFileNameLength; bytes_available -= BFcMaxFileNameLength; - + // put the light data into the buffer for (i = 0; i < furniture_osd->num_ls_datas; i++) { OBJtLSData *ls_data; - + ls_data = furniture_osd->ls_data_array + i; - + OBDmWrite4BytesToBuffer(ioBuffer, ls_data->index, UUtUns32, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, ls_data->light_flags, UUtUns32, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, ls_data->filter_color[0], float, bytes_available, OBJcWrite_Little); @@ -837,13 +837,13 @@ OBJiFurniture_Write( OBDmWrite4BytesToBuffer(ioBuffer, ls_data->beam_angle, float, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, ls_data->field_angle, float, bytes_available, OBJcWrite_Little); } - + // write the tag name OBDmWriteStringToBuffer(ioBuffer, furniture_osd->furn_tag, (EPcParticleTagNameLength + 1), bytes_available, OBJcWrite_Little); // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = *ioBufferSize - bytes_available; - + return UUcError_None; } @@ -890,10 +890,10 @@ OBJrFurniture_Initialize( { UUtError error; OBJtMethods methods; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiFurniture_New; methods.rSetDefaults = OBJiFurniture_SetDefaults; @@ -913,7 +913,7 @@ OBJrFurniture_Initialize( methods.rGetClassVisible = OBJiFurniture_GetVisible; methods.rSearch = OBJiFurniture_Search; methods.rSetClassVisible = OBJiFurniture_SetVisible; - + // register the furniture methods error = OBJrObjectGroup_Register( @@ -924,10 +924,10 @@ OBJrFurniture_Initialize( &methods, OBJcObjectGroupFlag_None); UUmError_ReturnOnError(error); - + // furniture is initially visible OBJiFurniture_SetVisible(UUcTrue); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Melee.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Melee.c index e72ec0a..5817f70 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Melee.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Melee.c @@ -72,10 +72,10 @@ OBJiMelee_Enumerate( UUtUns32 inUserData) { char name[OBJcMaxNameLength + 1]; - + OBJrObject_GetName(inObject, name, OBJcMaxNameLength); inEnumCallback(name, inUserData); - + return UUcError_None; } @@ -103,9 +103,9 @@ OBJiMelee_OSDGetName( const AI2tMeleeProfile *profile; profile = &inOSD->osd.melee_osd; - + UUrString_Copy(outName, profile->name, inNameLength); - + return; } @@ -117,7 +117,7 @@ OBJiMelee_OSDSetName( AI2tMeleeProfile *profile; profile = &inOSD->osd.melee_osd; - + UUrString_Copy(profile->name, outName, sizeof(profile->name)); return; @@ -135,7 +135,7 @@ OBJiMelee_GetOSD( UUtUns32 blocksize; profile = (AI2tMeleeProfile *) inObject->object_data; - + outOSD->osd.melee_osd = *profile; // *** allocate and copy the variable-length arrays @@ -181,7 +181,7 @@ OBJiMelee_GetOSDWriteSize( { UUtUns32 profile_size, technique_size, move_size; AI2tMeleeProfile *profile = (AI2tMeleeProfile *) inObject->object_data; - + technique_size = 0; technique_size += sizeof(profile->technique->name); technique_size += sizeof(profile->technique->user_flags); @@ -387,7 +387,7 @@ OBJiMelee_New( { OBJtOSD_All osd_all; UUtError error; - + if (NULL == inOSD) { error = OBJiMelee_SetDefaults(&osd_all); UUmError_ReturnOnError(error); @@ -396,11 +396,11 @@ OBJiMelee_New( { OBJiMelee_DuplicateOSD(inOSD, &osd_all); } - + // set the object specific data and position error = OBJrObject_SetObjectSpecificData(inObject, &osd_all); UUmError_ReturnOnError(error); - + OBJrObject_UpdatePosition(inObject); return UUcError_None; @@ -419,7 +419,7 @@ OBJiMelee_Read( AI2tMeleeMove *move; UUtUns32 itr, num_techniques; UUtUns32 bytes_read = 0; - + bytes_read += OBJmGet4BytesFromBuffer(inBuffer, profile->id, UUtUns32, inSwapIt); bytes_read += OBJmGetStringFromBuffer(inBuffer, profile->name, sizeof(profile->name), inSwapIt); bytes_read += OBJmGetStringFromBuffer(inBuffer, profile->char_classname, sizeof(profile->char_classname),inSwapIt); @@ -510,7 +510,7 @@ OBJiMelee_Read( // bring the object up to date OBJrObject_UpdatePosition(inObject); - + return bytes_read; } @@ -522,11 +522,11 @@ OBJiMelee_SetOSD( { AI2tMeleeProfile *profile; UUtUns32 blocksize; - + UUmAssert(inOSD); - + profile = (AI2tMeleeProfile *) inObject->object_data; - + // *** copy the data from inOSD to the melee profile UUrString_Copy(profile->name, inOSD->osd.melee_osd.name, sizeof(inOSD->osd.melee_osd.name)); @@ -578,7 +578,7 @@ OBJiMelee_SetOSD( } profile->char_class = inOSD->osd.melee_osd.char_class; - + return UUcError_None; } @@ -601,7 +601,7 @@ OBJiMelee_Write( AI2tMeleeTechnique *technique; AI2tMeleeMove *move; UUtUns32 itr, bytes_available, num_techniques; - + bytes_available = *ioBufferSize; OBJmWrite4BytesToBuffer(ioBuffer, profile->id, UUtUns32, bytes_available, OBJcWrite_Little); @@ -623,7 +623,7 @@ OBJiMelee_Write( OBJmWrite4BytesToBuffer(ioBuffer, profile->weight_blocking, float, bytes_available, OBJcWrite_Little); OBJmWrite4BytesToBuffer(ioBuffer, profile->weight_throwdanger, float, bytes_available, OBJcWrite_Little); - + OBJmWrite2BytesToBuffer(ioBuffer, profile->dazed_minframes, UUtUns16, bytes_available, OBJcWrite_Little); OBJmWrite2BytesToBuffer(ioBuffer, profile->dazed_maxframes, UUtUns16, bytes_available, OBJcWrite_Little); @@ -726,10 +726,10 @@ OBJiMelee_Search( { OBJtOSD_Melee *melee_osd; UUtBool found; - + // get a pointer to the object osd melee_osd = (OBJtOSD_Melee *)inObject->object_data; - + // perform the check switch (inSearchType) { @@ -745,7 +745,7 @@ OBJiMelee_Search( found = UUcFalse; break; } - + return found; } @@ -784,10 +784,10 @@ OBJrMelee_Initialize( { UUtError error; OBJtMethods methods; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiMelee_New; methods.rSetDefaults = OBJiMelee_SetDefaults; @@ -809,7 +809,7 @@ OBJrMelee_Initialize( methods.rSetClassVisible = OBJiMelee_SetVisible; methods.rGetUniqueOSD = OBJiMelee_GetUniqueOSD; methods.rLevelBegin = OBJiMelee_LevelBegin; - + // register the furniture methods error = OBJrObjectGroup_Register( @@ -820,7 +820,7 @@ OBJrMelee_Initialize( &methods, OBJcObjectGroupFlag_CanSetName | OBJcObjectGroupFlag_CommonToAllLevels); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Neutral.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Neutral.c index e6932d0..83a1d02 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Neutral.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Neutral.c @@ -60,10 +60,10 @@ OBJiNeutral_Enumerate( UUtUns32 inUserData) { char name[OBJcMaxNameLength + 1]; - + OBJrObject_GetName(inObject, name, OBJcMaxNameLength); inEnumCallback(name, inUserData); - + return UUcError_None; } @@ -92,9 +92,9 @@ OBJiNeutral_OSDGetName( // get a pointer to the object osd neutral_osd = &inOSD->osd.neutral_osd; - + UUrString_Copy(outName, neutral_osd->name, inNameLength); - + return; } @@ -107,7 +107,7 @@ OBJiNeutral_OSDSetName( // get a pointer to the object osd neutral_osd = &inOSD->osd.neutral_osd; - + UUrString_Copy(neutral_osd->name, outName, sizeof(neutral_osd->name)); return; @@ -125,7 +125,7 @@ OBJiNeutral_GetOSD( // get a pointer to the object osd neutral_osd = (OBJtOSD_Neutral *) inObject->object_data; - + outOSD->osd.neutral_osd = *neutral_osd; return; @@ -295,7 +295,7 @@ OBJiNeutral_New( { OBJtOSD_All osd_all; UUtError error; - + if (NULL == inOSD) { error = OBJiNeutral_SetDefaults(&osd_all); UUmError_ReturnOnError(error); @@ -304,11 +304,11 @@ OBJiNeutral_New( { OBJiNeutral_DuplicateOSD(inOSD, &osd_all); } - + // set the object specific data and position error = OBJrObject_SetObjectSpecificData(inObject, &osd_all); UUmError_ReturnOnError(error); - + OBJrObject_UpdatePosition(inObject); return UUcError_None; @@ -365,7 +365,7 @@ OBJiNeutral_Read( // bring the object up to date OBJrObject_UpdatePosition(inObject); - + return bytes_read; } @@ -377,12 +377,12 @@ OBJiNeutral_SetOSD( { OBJtOSD_Neutral *neutral_osd; UUtUns32 itr; - + UUmAssert(inOSD); - + // get a pointer to the object osd neutral_osd = (OBJtOSD_Neutral *) inObject->object_data; - + // copy the data from inOSD to char_osd UUrString_Copy(neutral_osd->name, inOSD->osd.neutral_osd.name, sizeof(inOSD->osd.neutral_osd.name)); @@ -433,7 +433,7 @@ OBJiNeutral_Write( { OBJtOSD_Neutral *neutral_osd; UUtUns32 itr, bytes_available; - + neutral_osd = (OBJtOSD_Neutral *) inObject->object_data; bytes_available = *ioBufferSize; @@ -468,7 +468,7 @@ OBJiNeutral_Write( // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = *ioBufferSize - bytes_available; - + return UUcError_None; } @@ -503,10 +503,10 @@ OBJiNeutral_Search( { OBJtOSD_Neutral *neutral_osd; UUtBool found; - + // get a pointer to the object osd neutral_osd = (OBJtOSD_Neutral *) inObject->object_data; - + // perform the check switch (inSearchType) { @@ -522,7 +522,7 @@ OBJiNeutral_Search( found = UUcFalse; break; } - + return found; } @@ -538,10 +538,10 @@ OBJrNeutral_Initialize( { UUtError error; OBJtMethods methods; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiNeutral_New; methods.rSetDefaults = OBJiNeutral_SetDefaults; @@ -562,7 +562,7 @@ OBJrNeutral_Initialize( methods.rSearch = OBJiNeutral_Search; methods.rSetClassVisible = OBJiNeutral_SetVisible; methods.rGetUniqueOSD = OBJiNeutral_GetUniqueOSD; - + // register the neutral behavior methods error = OBJrObjectGroup_Register( @@ -573,7 +573,7 @@ OBJrNeutral_Initialize( &methods, OBJcObjectGroupFlag_CanSetName); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Particle.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Particle.c index 326ba32..2c2a17b 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Particle.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Particle.c @@ -44,12 +44,12 @@ OBJiParticle_UpdateObjectPosition( // get a pointer to the particle_osd particle_osd = (OBJtOSD_Particle*)inObject->object_data; - + // convert the rotation to radians rot_x = inObject->rotation.x * M3cDegToRad; rot_y = inObject->rotation.y * M3cDegToRad; rot_z = inObject->rotation.z * M3cDegToRad; - + // update the rotation matrix euler.order = MUcEulerOrderXYZs; euler.x = rot_x; @@ -65,7 +65,7 @@ OBJiParticle_UpdateObjectPosition( } particle_osd->particle.dynamic_matrix = NULL; } - + // ====================================================================== #if 0 #pragma mark - @@ -77,7 +77,7 @@ OBJiParticle_Delete( OBJtObject *inObject) { OBJtOSD_Particle *particle_osd = (OBJtOSD_Particle*)inObject->object_data; - + EPrDelete(&particle_osd->particle); } @@ -99,7 +99,7 @@ OBJiParticle_Draw( // this changes the way that the user interacts with us particle_osd->is_decal = ((particle_osd->particle.particle_class != NULL) && (particle_osd->particle.particle_class->definition->flags2 & P3cParticleClassFlag2_Appearance_Decal)); - + // setup the matrix stack M3rMatrixStack_Push(); M3rMatrixStack_Multiply(&particle_osd->particle.matrix); @@ -107,7 +107,7 @@ OBJiParticle_Draw( OBJrObject_GetBoundingSphere(inObject, &bounding_sphere); OBJrObjectUtil_DrawRotationRings(inObject, &bounding_sphere, inDrawFlags); - + M3rMatrixStack_Pop(); } #endif @@ -123,22 +123,22 @@ OBJiParticle_Enumerate( UUtUns32 inUserData) { P3tParticleClassIterateState itr; - + itr = P3cParticleClass_None; while (1) { UUtBool result; P3tParticleClass *particle_class; - + // iterate over all particle classes and pass their names to the // callback function (for storage in a listbox) result = P3rIterateClasses(&itr, &particle_class); if (result == UUcFalse) { break; } - + result = inEnumCallback(particle_class->classname, inUserData); if (result == UUcFalse) { break; } } - + return UUcError_None; } @@ -160,7 +160,7 @@ OBJiParticle_OSDGetName( UUtUns32 inNameLength) { const OBJtOSD_Particle *particle_osd = &inOSD->osd.particle_osd; - + UUrString_Copy(outName, particle_osd->particle.classname, inNameLength); if (particle_osd->particle.tagname[0] != '\0') { UUrString_Cat(outName, "_", inNameLength); @@ -177,7 +177,7 @@ OBJiParticle_OSDSetName( const char *inName) { OBJtOSD_Particle *particle_osd = &inOSD->osd.particle_osd; - + if (strcmp(particle_osd->particle.classname, inName) != 0) { // set up the new name UUrString_Copy(particle_osd->particle.classname, inName, @@ -194,9 +194,9 @@ OBJiParticle_GetOSD( OBJtOSD_All *outOSD) { OBJtOSD_Particle *particle_osd; - + particle_osd = &((OBJtOSD_All *)inObject->object_data)->osd.particle_osd; - + UUrMemory_MoveFast(particle_osd, &outOSD->osd.particle_osd, sizeof(OBJtOSD_Particle)); } @@ -206,12 +206,12 @@ OBJiParticle_GetOSDWriteSize( const OBJtObject *inObject) { UUtUns32 result; - + result = (P3cParticleClassNameLength + 1); /* particle class name */ result += (EPcParticleTagNameLength + 1); /* particle tag name */ result += sizeof(UUtUns16); /* flags */ result += 2 * sizeof(float); /* decal x, y scale */ - + return result; } @@ -225,14 +225,14 @@ OBJiParticle_IntersectsLine( M3tBoundingSphere sphere; UUrMemory_Clear(&sphere, sizeof(M3tBoundingSphere)); - + // get the bounding sphere OBJrObject_GetBoundingSphere(inObject, &sphere); - + sphere.center.x += inObject->position.x; sphere.center.y += inObject->position.y; sphere.center.z += inObject->position.z; - + return CLrSphere_Line(inStartPoint, inEndPoint, &sphere); } @@ -277,7 +277,7 @@ OBJiParticle_New( // set the particle's position OBJrObject_UpdatePosition(inObject); - + if (inOSD != NULL) { // copy the persistent fields from the input OSD; this // is only class, tag and flags. @@ -296,11 +296,11 @@ OBJiParticle_Read_Version1( { OBJtOSD_All *osd_all; UUtUns32 bytes_read; - + // get a pointer to the object osd osd_all = (OBJtOSD_All*)inObject->object_data; bytes_read = 0; - + // read the Particle data UUrString_Copy( osd_all->osd.particle_osd.particle.classname, @@ -308,7 +308,7 @@ OBJiParticle_Read_Version1( (P3cParticleClassNameLength + 1)); inBuffer += (P3cParticleClassNameLength + 1); bytes_read += (P3cParticleClassNameLength + 1); - + // these values did not exist in version 1 osd_all->osd.particle_osd.particle.tagname[0] = '\0'; osd_all->osd.particle_osd.particle.flags = 0; @@ -327,10 +327,10 @@ OBJiParticle_Read_Version6( { OBJtOSD_All *osd_all; UUtUns32 bytes_read, flags; - + // get a pointer to the object osd osd_all = (OBJtOSD_All*)inObject->object_data; - + // read the version 1 data and advance past it bytes_read = OBJiParticle_Read_Version1(inObject, inSwapIt, inBuffer); inBuffer += bytes_read; @@ -349,7 +349,7 @@ OBJiParticle_Read_Version6( (OBJcParticleTagNameLength + 1)); inBuffer += (OBJcParticleTagNameLength + 1); bytes_read += (OBJcParticleTagNameLength + 1); - + // get the flags and convert them from the old 32-bit format to the new 16-bit format bytes_read += OBJmGet4BytesFromBuffer(inBuffer, flags, UUtUns32, inSwapIt); @@ -376,10 +376,10 @@ OBJiParticle_Read_Version13( { OBJtOSD_All *osd_all; UUtUns32 bytes_read; - + // get a pointer to the object osd osd_all = (OBJtOSD_All*)inObject->object_data; - + /* * read the version 13 data */ @@ -393,7 +393,7 @@ OBJiParticle_Read_Version13( (P3cParticleClassNameLength + 1)); inBuffer += (P3cParticleClassNameLength + 1); bytes_read += (P3cParticleClassNameLength + 1); - + // read the tag name (all 48 chars of it) UUrString_Copy( osd_all->osd.particle_osd.particle.tagname, @@ -401,7 +401,7 @@ OBJiParticle_Read_Version13( (EPcParticleTagNameLength + 1)); inBuffer += (EPcParticleTagNameLength + 1); bytes_read += (EPcParticleTagNameLength + 1); - + // read the 16-bit flags bytes_read += OBJmGet2BytesFromBuffer(inBuffer, osd_all->osd.particle_osd.particle.flags, UUtUns16, inSwapIt); @@ -424,10 +424,10 @@ OBJiParticle_Read_Version32( { OBJtOSD_All *osd_all; UUtUns32 bytes_read; - + // get a pointer to the object osd osd_all = (OBJtOSD_All*)inObject->object_data; - + /* * read the version 32 data */ @@ -441,7 +441,7 @@ OBJiParticle_Read_Version32( (P3cParticleClassNameLength + 1)); inBuffer += (P3cParticleClassNameLength + 1); bytes_read += (P3cParticleClassNameLength + 1); - + // read the tag name (all 48 chars of it) UUrString_Copy( osd_all->osd.particle_osd.particle.tagname, @@ -449,7 +449,7 @@ OBJiParticle_Read_Version32( (EPcParticleTagNameLength + 1)); inBuffer += (EPcParticleTagNameLength + 1); bytes_read += (EPcParticleTagNameLength + 1); - + // read the 16-bit flags bytes_read += OBJmGet2BytesFromBuffer(inBuffer, osd_all->osd.particle_osd.particle.flags, UUtUns16, inSwapIt); @@ -494,7 +494,7 @@ OBJiParticle_Read( // clear flags that don't persist particle_osd->particle.flags &= EPcParticleFlag_PersistentMask; - + // notify the env particle system that this particle exists EPrNew(&particle_osd->particle, 0); @@ -512,19 +512,19 @@ OBJiParticle_SetOSD( const OBJtOSD_All *inOSD) { OBJtOSD_Particle *particle_osd; - + // get a pointer to the particle_osd particle_osd = (OBJtOSD_Particle*)inObject->object_data; particle_osd->owner = inObject; - - if (strcmp(particle_osd->particle.classname, inOSD->osd.particle_osd.particle.classname) != 0) { + + if (strcmp(particle_osd->particle.classname, inOSD->osd.particle_osd.particle.classname) != 0) { // the particle class has changed. UUrString_Copy(particle_osd->particle.classname, inOSD->osd.particle_osd.particle.classname, (P3cParticleClassNameLength + 1)); EPrNotifyClassChange(&particle_osd->particle, ONrGameState_GetGameTime()); } - + if (strcmp(particle_osd->particle.tagname, inOSD->osd.particle_osd.particle.tagname) != 0) { // the tag name has changed. EPrPreNotifyTagChange(&particle_osd->particle); @@ -574,13 +574,13 @@ OBJiParticle_Write( { OBJtOSD_Particle *particle_osd; UUtUns32 bytes_available; - + // get a pointer to the particle_osd particle_osd = (OBJtOSD_Particle*)inObject->object_data; - + // get the number of bytes available bytes_available = *ioBufferSize; - + // write the data into the buffer UUrString_Copy((char*)ioBuffer, particle_osd->particle.classname, P3cParticleClassNameLength + 1); bytes_available -= (P3cParticleClassNameLength + 1); @@ -589,7 +589,7 @@ OBJiParticle_Write( UUrString_Copy((char*)ioBuffer, particle_osd->particle.tagname, EPcParticleTagNameLength + 1); bytes_available -= (EPcParticleTagNameLength + 1); ioBuffer += (EPcParticleTagNameLength + 1); - + OBJmWrite2BytesToBuffer(ioBuffer, particle_osd->particle.flags, UUtUns16, bytes_available, OBJcWrite_Little); OBJmWrite4BytesToBuffer(ioBuffer, particle_osd->particle.decal_xscale, float, bytes_available, OBJcWrite_Little); @@ -597,7 +597,7 @@ OBJiParticle_Write( // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = *ioBufferSize - bytes_available; - + return UUcError_None; } @@ -644,10 +644,10 @@ OBJrParticle_Initialize( { UUtError error; OBJtMethods methods; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiParticle_New; methods.rSetDefaults = OBJiParticle_SetDefaults; @@ -667,7 +667,7 @@ OBJrParticle_Initialize( methods.rGetClassVisible = OBJiParticle_GetVisible; methods.rSearch = OBJiParticle_Search; methods.rSetClassVisible = OBJiParticle_SetVisible; - + // register the particles methods error = OBJrObjectGroup_Register( @@ -678,10 +678,10 @@ OBJrParticle_Initialize( &methods, OBJcObjectGroupFlag_CanSetName); UUmError_ReturnOnError(error); - + // particle placement points are not initially visible OBJiParticle_SetVisible(UUcFalse); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_PowerUps.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_PowerUps.c index d634197..50e597d 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_PowerUps.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_PowerUps.c @@ -19,7 +19,7 @@ typedef struct OBJtPowerUpTypeNames WPtPowerupType type; UUtUns32 type_chars; char *type_name; - + } OBJtPowerUpTypeNames; // ====================================================================== @@ -46,7 +46,7 @@ static UUtError OBJiPowerUp_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inOSD); - + // ====================================================================== // functions // ====================================================================== @@ -56,7 +56,7 @@ OBJiPowerUp_Delete( OBJtObject *inObject) { OBJtOSD_PowerUp *powerup_osd; - + // get a pointer to the object osd powerup_osd = (OBJtOSD_PowerUp*)inObject->object_data; } @@ -77,7 +77,7 @@ OBJiPowerUp_Draw( M3rMatrixStack_ApplyTranslate(inObject->position); M3rMatrixStack_RotateZAxis(M3cHalfPi); M3rGeom_State_Commit(); - + if ((powerup_osd->powerup) && (powerup_osd->powerup->geometry)) { M3rMinMaxBBox_To_BBox(&powerup_osd->powerup->geometry->pointArray->minmax_boundingBox, &bBox); @@ -89,7 +89,7 @@ OBJiPowerUp_Draw( M3rMinMaxBBox_To_BBox(&min_max, &bBox); M3rBBox_Draw_Line(&bBox, IMcShade_White); } - + #if TOOL_VERSION // draw the bounding box if this is the selected object if ((inDrawFlags & OBJcDrawFlag_Selected) != 0) @@ -100,7 +100,7 @@ OBJiPowerUp_Draw( OBJrObjectUtil_DrawRotationRings(inObject, &sphere, inDrawFlags); } #endif - + M3rMatrixStack_Pop(); } @@ -112,12 +112,12 @@ OBJiPowerUp_Enumerate( UUtUns32 inUserData) { OBJtPowerUpTypeNames *type_name; - + for (type_name = OBJgPowerUpTypeNames; type_name->type_name != NULL; type_name++) { inEnumCallback(type_name->type_name, inUserData); } - + return UUcError_None; } @@ -128,7 +128,7 @@ OBJiPowerUp_GetBoundingSphere( M3tBoundingSphere *outBoundingSphere) { OBJtOSD_PowerUp *powerup_osd; - + powerup_osd = (OBJtOSD_PowerUp*)inObject->object_data; if ((powerup_osd->powerup != NULL) && (powerup_osd->powerup->geometry != NULL)) { @@ -150,13 +150,13 @@ OBJiPowerUp_OSDGetName( { // return the name of the powerup type OBJtPowerUpTypeNames *type_name; - + outName[0] = '\0'; - + for (type_name = OBJgPowerUpTypeNames; type_name->type_name != NULL; type_name++) { if (type_name->type != inOSD->osd.powerup_osd.powerup_type) { continue; } - + UUrString_Copy(outName, type_name->type_name, inNameLength); break; } @@ -179,7 +179,7 @@ OBJiPowerUp_GetOSD( OBJtOSD_PowerUp *powerup_osd; powerup_osd = (OBJtOSD_PowerUp*)inObject->object_data; - + outOSD->osd.powerup_osd = *powerup_osd; } @@ -190,13 +190,13 @@ OBJiPowerUp_GetOSDWriteSize( { UUtUns32 size; OBJtOSD_PowerUp *powerup_osd; - + powerup_osd = (OBJtOSD_PowerUp*)inObject->object_data; // save the powerup type size = (sizeof(UUtUns8) * 4); /* powerup type */ - + return size; } @@ -208,16 +208,16 @@ OBJiPowerUp_IntersectsLine( const M3tPoint3D *inEndPoint) { M3tBoundingSphere sphere; - + UUrMemory_Clear(&sphere, sizeof(M3tBoundingSphere)); - + // get the bounding sphere OBJrObject_GetBoundingSphere(inObject, &sphere); - + sphere.center.x += inObject->position.x; sphere.center.y += inObject->position.y; sphere.center.z += inObject->position.z; - + // do the fast test to see if the line is colliding with the bounding sphere return CLrSphere_Line(inStartPoint, inEndPoint, &sphere); } @@ -229,10 +229,10 @@ OBJiPowerUp_SetDefaults( { // clear the osd UUrMemory_Clear(&outOSD->osd.powerup_osd, sizeof(OBJtOSD_PowerUp)); - + outOSD->osd.powerup_osd.powerup_type = WPcPowerup_AmmoBallistic; outOSD->osd.powerup_osd.powerup = NULL; - + return UUcError_None; } @@ -249,15 +249,15 @@ OBJiPowerUp_New( { error = OBJiPowerUp_SetDefaults(&osd_all); UUmError_ReturnOnError(error); - + // send osd_all to OBJiPowerUp_SetOSD() inOSD = &osd_all; } - + // set the object specific data and position OBJiPowerUp_SetOSD(inObject, inOSD); OBJrObject_UpdatePosition(inObject); - + return UUcError_None; } @@ -274,26 +274,26 @@ OBJiPowerUp_Read( UUtUns8 chars[4]; UUtUns32 i; UUtUns32 type; - + powerup_osd = (OBJtOSD_PowerUp*)inObject->object_data; - + read_bytes = 0; - + // read the powerup type read_bytes += BDmGet4CharsFromBuffer(inBuffer, chars[0], chars[1], chars[2], chars[3]); type = UUm4CharToUns32(chars[0], chars[1], chars[2], chars[3]); - + for (i = 0; i < WPcPowerup_NumTypes; i++) { if (type != OBJgPowerUpTypeNames[i].type_chars) { continue; } - + powerup_osd->powerup_type = OBJgPowerUpTypeNames[i].type; } - + // set the osd and update the position OBJiPowerUp_SetOSD(inObject, (OBJtOSD_All*)inObject->object_data); OBJrObject_UpdatePosition(inObject); - + return read_bytes; } @@ -304,12 +304,12 @@ OBJiPowerUp_SetOSD( const OBJtOSD_All *inOSD) { OBJtOSD_PowerUp *powerup_osd; - + powerup_osd = (OBJtOSD_PowerUp*)inObject->object_data; - + powerup_osd->powerup_type = inOSD->osd.powerup_osd.powerup_type; powerup_osd->powerup = inOSD->osd.powerup_osd.powerup; - + return UUcError_None; } @@ -346,27 +346,27 @@ OBJiPowerUp_Write( OBJtOSD_PowerUp *powerup_osd; UUtUns32 bytes_available; OBJtPowerUpTypeNames *type_name; - + powerup_osd = (OBJtOSD_PowerUp*)inObject->object_data; - + // set the number of bytes available bytes_available = *ioBufferSize; - + for (type_name = OBJgPowerUpTypeNames; type_name->type_name != NULL; type_name++) { char chars[4]; - + if (type_name->type != powerup_osd->powerup_type) { continue; } - + chars[0] = (UUtUns8)(type_name->type_chars >> 24); chars[1] = (UUtUns8)(type_name->type_chars >> 16); chars[2] = (UUtUns8)(type_name->type_chars >> 8); chars[3] = (UUtUns8)(type_name->type_chars); - + BDmWrite4CharsToBuffer(ioBuffer, chars[0], chars[1], chars[2], chars[3], bytes_available); break; } - + // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = *ioBufferSize - bytes_available; @@ -416,10 +416,10 @@ OBJrPowerUp_Initialize( { UUtError error; OBJtMethods methods; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiPowerUp_New; methods.rSetDefaults = OBJiPowerUp_SetDefaults; @@ -439,7 +439,7 @@ OBJrPowerUp_Initialize( methods.rGetClassVisible = OBJiPowerUp_GetVisible; methods.rSearch = OBJiPowerUp_Search; methods.rSetClassVisible = OBJiPowerUp_SetVisible; - + // register the furniture methods error = OBJrObjectGroup_Register( @@ -450,7 +450,7 @@ OBJrPowerUp_Initialize( &methods, OBJcObjectGroupFlag_None); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -461,12 +461,12 @@ OBJrPowerUp_NameToType( { OBJtPowerUpTypeNames *type_name; WPtPowerupType type; - - type = WPcPowerup_None; + + type = WPcPowerup_None; for (type_name = OBJgPowerUpTypeNames; type_name->type_name != NULL; type_name++) { UUtInt32 result; - + result = UUrString_Compare_NoCase(inPowerUpName, type_name->type_name); if (result == 0) { @@ -474,7 +474,7 @@ OBJrPowerUp_NameToType( break; } } - + return type; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Sound.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Sound.c index 74d6e6d..f60e1ed 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Sound.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Sound.c @@ -66,14 +66,14 @@ OBJiSound_CalcBoundingVolume( M3tPoint3D *points; M3tBoundingBox bbox; UUtInt32 itr; - + volume = &inSoundOSD->u.bvolume.bvolume; points = volume->worldPoints; - + // calculate the offset matrix MUrMatrix_Identity(&matrix); MUrMatrixStack_Translate(&matrix, &inObject->position); - + // expand into bounding box, then copy M3rMinMaxBBox_To_BBox(&inSoundOSD->u.bvolume.bbox, &bbox); UUrMemory_MoveFast(&bbox, points, sizeof(M3tPoint3D) * M3cNumBoundingPoints); @@ -82,7 +82,7 @@ OBJiSound_CalcBoundingVolume( // compute faces UUrMemory_MoveFast(M3gBBox_QuadList, volume->faces, sizeof(M3tQuad) * M3cNumBoundingFaces); - // compute normals + // compute normals for (itr = 0; itr < M3cNumBoundingFaces; itr++) { MUrVector_NormalFromPoints( @@ -100,7 +100,7 @@ OBJiSound_CalcBoundingVolume( M3tPoint3D *point; normal = volume->normals[itr]; - + point = volume->worldPoints + volume->faces[itr].indices[0]; plane = volume->curPlanes + itr; @@ -109,7 +109,7 @@ OBJiSound_CalcBoundingVolume( plane->c = normal.z; plane->d = -(normal.x*point->x + normal.y*point->y + normal.z*point->z); - volume->curProjections[itr] = (UUtUns16) + volume->curProjections[itr] = (UUtUns16) CLrQuad_FindProjection(volume->worldPoints, volume->faces + itr); // degenerate quads should be culled at import time @@ -137,21 +137,21 @@ OBJiSound_DrawSphere( M3tPoint3D *ring_XY = UUrAlignMemory(block_XY); M3tPoint3D *ring_YZ = UUrAlignMemory(block_YZ); UUtUns32 itr; - + for(itr = 0; itr < OBJcNumPointsInRing; itr++) { float theta; float cos_theta_radius; float sin_theta_radius; - + theta = M3c2Pi * (((float) itr) / OBJcNumPointsInRing); cos_theta_radius = MUrCos(theta) * inRadius; sin_theta_radius = MUrSin(theta) * inRadius; - + ring_XZ[itr].x = cos_theta_radius + inDest->x; ring_XZ[itr].y = inDest->y; ring_XZ[itr].z = sin_theta_radius + inDest->z; - + ring_XY[itr].x = cos_theta_radius + inDest->x; ring_XY[itr].y = sin_theta_radius + inDest->y; ring_XY[itr].z = inDest->z; @@ -165,7 +165,7 @@ OBJiSound_DrawSphere( ring_XZ[OBJcNumPointsInRing] = ring_XZ[0]; ring_XY[OBJcNumPointsInRing] = ring_XY[0]; ring_YZ[OBJcNumPointsInRing] = ring_YZ[0]; - + // draw the rings M3rGeometry_LineDraw((OBJcNumPointsInRing + 1), ring_XZ, inShade); M3rGeometry_LineDraw((OBJcNumPointsInRing + 1), ring_XY, inShade); @@ -180,11 +180,11 @@ OBJrSound_DrawInitialize( { if (!OBJgSound_DrawInitialized) { IMtPixelType textureFormat; - + // create the diamond OBJgSound_Diamond = (M3tPoint3D*)UUrMemory_Block_New(sizeof(M3tPoint3D) * 13); UUmError_ReturnOnNull(OBJgSound_Diamond); - + MUmVector_Set(OBJgSound_Diamond[0], 0.0f, 1.0f, 0.0f); MUmVector_Set(OBJgSound_Diamond[1], -1.0f, 0.0f, 1.0f); MUmVector_Set(OBJgSound_Diamond[2], 1.0f, 0.0f, 1.0f); @@ -198,26 +198,26 @@ OBJrSound_DrawInitialize( MUmVector_Set(OBJgSound_Diamond[10], 1.0f, 0.0f, -1.0f); MUmVector_Set(OBJgSound_Diamond[11], 1.0f, 0.0f, 1.0f); MUmVector_Set(OBJgSound_Diamond[12], 0.0f, 1.0f, 0.0f); - + // create the name texture M3rDrawEngine_FindGrayscalePixelType(&textureFormat); OBJgSound_WhiteColor = IMrPixel_FromShade(textureFormat, IMcShade_White); - + TSrFontFamily_Get(TScFontFamily_Default, &OBJgSound_FontFamily); DCrText_SetFontFamily(OBJgSound_FontFamily); DCrText_SetSize(TScFontSize_Default); DCrText_SetStyle(TScFontStyle_Default); - + OBJgSound_Dest.x = 2; OBJgSound_Dest.y = DCrText_GetLeadingHeight() + DCrText_GetAscendingHeight(); - + DCrText_GetStringRect("01234567890123456789012345 p0.00 v0.00", &OBJgSound_TextureBounds); - + OBJgSound_TextureWidth = OBJgSound_TextureBounds.right; OBJgSound_TextureHeight = OBJgSound_TextureBounds.bottom; OBJgSound_WidthRatio = (float)OBJgSound_TextureWidth / (float)OBJgSound_TextureHeight; OBJgSound_HeightRatio = (float)OBJgSound_TextureHeight / (float)OBJgSound_TextureWidth; - + M3rTextureMap_New( OBJgSound_TextureWidth, OBJgSound_TextureHeight, @@ -229,7 +229,7 @@ OBJrSound_DrawInitialize( OBJgSound_DrawInitialized = UUcTrue; } - + return UUcError_None; } @@ -241,25 +241,25 @@ OBJiSound_DrawName( M3tPoint3D *inLocation) { char name[128]; - + if (OBJgSound_Texture == NULL) { return; } - + // erase the texture and set the text contexts shade M3rTextureMap_Fill(OBJgSound_Texture, OBJgSound_WhiteColor, NULL); - + // draw the string to the texture DCrText_SetFontFamily(OBJgSound_FontFamily); DCrText_SetSize(TScFontSize_Default); DCrText_SetStyle(TScFontStyle_Default); DCrText_SetShade(IMcShade_Black); DCrText_SetFormat(TSc_HCenter | TSc_VCenter); - + sprintf(name, "%s p%1.2f v%1.2f", inSoundOSD->ambient_name, inSoundOSD->pitch, inSoundOSD->volume); DCrText_DrawString(OBJgSound_Texture, name, &OBJgSound_TextureBounds, &OBJgSound_Dest); - + M3rGeom_State_Set(M3cGeomStateIntType_SpriteMode, M3cGeomState_SpriteMode_Normal); M3rGeom_State_Commit(); - + // draw the sprite M3rSimpleSprite_Draw( OBJgSound_Texture, @@ -313,18 +313,18 @@ OBJiSound_Draw( OBJtOSD_Sound *sound_osd; M3tPoint3D dest; M3tPoint3D camera_location; - + // get a pointer to the object osd sound_osd = (OBJtOSD_Sound*)inObject->object_data; - + // setup the matrix stack M3rMatrixStack_Push(); M3rMatrixStack_ApplyTranslate(inObject->position); M3rGeom_State_Commit(); - + // draw the diamond M3rGeometry_LineDraw(13, OBJgSound_Diamond, IMcShade_Yellow); - + MUmVector_Set(dest, 0.0f, 0.0f, 0.0f); // draw the appropriate type @@ -341,7 +341,7 @@ OBJiSound_Draw( sound_osd->u.spheres.max_volume_distance * UUmFeet(1), &dest, IMcShade_Red); - + // draw the Min Volume Sphere MUmVector_Set(dest, 0.0f, 0.0f, 0.0f); OBJiSound_DrawSphere( @@ -350,7 +350,7 @@ OBJiSound_Draw( IMcShade_Green); } break; - + case OBJcSoundType_BVolume: if ((OBJgSound_AlwaysDraw == UUcTrue) || (OBJgSound_AlwaysDrawVolumes == UUcTrue) || @@ -358,13 +358,13 @@ OBJiSound_Draw( { M3tBoundingBox bBox; IMtShade shade; - + shade = ((inDrawFlags & OBJcDrawFlag_Selected) != 0) ? IMcShade_Green : IMcShade_Red; - + // draw the bounding box if this is the selected object M3rMinMaxBBox_To_BBox(&sound_osd->u.bvolume.bbox, &bBox); M3rBBox_Draw_Line(&bBox, shade); - + M3rGeom_Line_Light(&bBox.localPoints[0], &bBox.localPoints[7], shade); M3rGeom_Line_Light(&bBox.localPoints[1], &bBox.localPoints[6], shade); M3rGeom_Line_Light(&bBox.localPoints[2], &bBox.localPoints[5], shade); @@ -372,7 +372,7 @@ OBJiSound_Draw( } break; } - + // draw the name camera_location = CArGetLocation(); if (MUrPoint_Distance(&inObject->position, &camera_location) < 150.0f) @@ -380,16 +380,16 @@ OBJiSound_Draw( dest.y += 1.0f; OBJiSound_DrawName(inObject, sound_osd, &dest); } - + // draw the rotation rings if this is the selected object if (inDrawFlags & OBJcDrawFlag_Selected) { M3tBoundingSphere bounding_sphere; - + OBJrObject_GetBoundingSphere(inObject, &bounding_sphere); OBJrObjectUtil_DrawRotationRings(inObject, &bounding_sphere, inDrawFlags); } - + M3rMatrixStack_Pop(); } #endif @@ -441,9 +441,9 @@ OBJiSound_GetOSD( OBJtOSD_All *outOSD) { OBJtOSD_All *sound_osd; - + sound_osd = (OBJtOSD_All*)inObject->object_data; - + outOSD->osd.sound_osd = sound_osd->osd.sound_osd; return; @@ -455,7 +455,7 @@ OBJiSound_GetOSDWriteSize( const OBJtObject *inObject) { UUtUns32 result; - + result = BFcMaxFileNameLength + /* ambient name */ sizeof(OBJtSoundType) + /* sound type */ @@ -464,7 +464,7 @@ OBJiSound_GetOSDWriteSize( sizeof(M3tBoundingBox_MinMax)) + sizeof(float) + /* pitch */ sizeof(float); /* volume */ - + return result; } @@ -478,14 +478,14 @@ OBJiSound_IntersectsLine( M3tBoundingSphere sphere; UUrMemory_Clear(&sphere, sizeof(M3tBoundingSphere)); - + // get the bounding sphere OBJrObject_GetBoundingSphere(inObject, &sphere); - + sphere.center.x += inObject->position.x; sphere.center.y += inObject->position.y; sphere.center.z += inObject->position.z; - + return CLrSphere_Line(inStartPoint, inEndPoint, &sphere); } @@ -501,7 +501,7 @@ OBJiSound_SetDefaults( outOSD->osd.sound_osd.volume = 1.0f; outOSD->osd.sound_osd.u.spheres.max_volume_distance = 5.0f; outOSD->osd.sound_osd.u.spheres.min_volume_distance = 10.0f; - + return UUcError_None; } @@ -513,20 +513,20 @@ OBJiSound_New( { OBJtOSD_All osd_all; UUtError error; - + if (inOSD == NULL) { error = OBJiSound_SetDefaults(&osd_all); UUmError_ReturnOnError(error); - + // send osd_all to OBJmObject_SetOSD() inOSD = &osd_all; } - + // set the object specific data and position OBJiSound_SetOSD(inObject, inOSD); OBJiSound_UpdatePosition(inObject); - + return UUcError_None; } @@ -540,23 +540,23 @@ OBJiSound_Read( { OBJtOSD_Sound *sound_osd; UUtUns32 bytes_read; - + // get a pointer to the object osd sound_osd = (OBJtOSD_Sound*)inObject->object_data; UUrMemory_Clear(sound_osd, sizeof(OBJtOSD_Sound)); - + // read the sound data OBDmGetStringFromBuffer(inBuffer, sound_osd->ambient_name, BFcMaxFileNameLength, inSwapIt); - + if (inVersion < OBJcVersion_30) { sound_osd->type = OBJcSoundType_Spheres; OBDmGet4BytesFromBuffer(inBuffer, sound_osd->u.spheres.max_volume_distance, float, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, sound_osd->u.spheres.min_volume_distance, float, inSwapIt); - + sound_osd->pitch = 1.0f; sound_osd->volume = 1.0f; - + // set the number of bytes read bytes_read = BFcMaxFileNameLength + // name @@ -566,30 +566,30 @@ OBJiSound_Read( else { OBDmGet4BytesFromBuffer(inBuffer, sound_osd->type, OBJtSoundType, inSwapIt); - + switch (sound_osd->type) { case OBJcSoundType_Spheres: OBDmGet4BytesFromBuffer(inBuffer, sound_osd->u.spheres.max_volume_distance, float, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, sound_osd->u.spheres.min_volume_distance, float, inSwapIt); break; - + case OBJcSoundType_BVolume: OBDmGet4BytesFromBuffer(inBuffer, sound_osd->u.bvolume.bbox.minPoint.x, float, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, sound_osd->u.bvolume.bbox.minPoint.y, float, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, sound_osd->u.bvolume.bbox.minPoint.z, float, inSwapIt); - + OBDmGet4BytesFromBuffer(inBuffer, sound_osd->u.bvolume.bbox.maxPoint.x, float, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, sound_osd->u.bvolume.bbox.maxPoint.y, float, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, sound_osd->u.bvolume.bbox.maxPoint.z, float, inSwapIt); break; } - + if (inVersion < OBJcVersion_33) { sound_osd->pitch = 1.0f; sound_osd->volume = 1.0f; - + bytes_read = BFcMaxFileNameLength + /* ambient name */ sizeof(OBJtSoundType) + /* sound type */ @@ -606,11 +606,11 @@ OBJiSound_Read( bytes_read = OBJiSound_GetOSDWriteSize(inObject); } } - + // set the osd and update the position OBJiSound_SetOSD(inObject, (OBJtOSD_All*)inObject->object_data); OBJrObject_UpdatePosition(inObject); - + return bytes_read; } @@ -621,16 +621,16 @@ OBJiSound_SetOSD( const OBJtOSD_All *inOSD) { OBJtOSD_Sound *sound_osd; - + // get a pointer to the sound_osd sound_osd = (OBJtOSD_Sound*)inObject->object_data; - + // copy the data from inOSD into sound_osd *sound_osd = inOSD->osd.sound_osd; - + // set the pointer to the ambient sound sound_osd->ambient = OSrAmbient_GetByName(sound_osd->ambient_name); - + if (sound_osd->type == OBJcSoundType_BVolume) { // recalculate the bounding volume @@ -638,7 +638,7 @@ OBJiSound_SetOSD( } UUrMemory_Block_VerifyList(); - + return UUcError_None; } @@ -648,15 +648,15 @@ OBJiSound_UpdatePosition( OBJtObject *inObject) { OBJtOSD_Sound *sound_osd; - + // no rotation inObject->rotation.x = 0.0f; inObject->rotation.y = 0.0f; inObject->rotation.z = 0.0f; - + // get a pointer to the sound_osd sound_osd = (OBJtOSD_Sound*)inObject->object_data; - + if (sound_osd->type == OBJcSoundType_BVolume) { // recalculate the bounding volume @@ -673,24 +673,24 @@ OBJiSound_Write( { OBJtOSD_Sound *sound_osd; UUtUns32 bytes_available; - + // get a pointer to the sound_osd sound_osd = (OBJtOSD_Sound*)inObject->object_data; - + // set the number of bytes available bytes_available = *ioBufferSize; - + // read the data from the buffer OBDmWriteStringToBuffer(ioBuffer, sound_osd->ambient_name, BFcMaxFileNameLength, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, sound_osd->type, OBJtSoundType, bytes_available, OBJcWrite_Little); - + switch (sound_osd->type) { case OBJcSoundType_Spheres: OBDmWrite4BytesToBuffer(ioBuffer, sound_osd->u.spheres.max_volume_distance, float, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, sound_osd->u.spheres.min_volume_distance, float, bytes_available, OBJcWrite_Little); break; - + case OBJcSoundType_BVolume: OBDmWrite4BytesToBuffer(ioBuffer, sound_osd->u.bvolume.bbox.minPoint.x, float, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, sound_osd->u.bvolume.bbox.minPoint.y, float, bytes_available, OBJcWrite_Little); @@ -701,13 +701,13 @@ OBJiSound_Write( OBDmWrite4BytesToBuffer(ioBuffer, sound_osd->u.bvolume.bbox.maxPoint.z, float, bytes_available, OBJcWrite_Little); break; } - + OBDmWrite4BytesToBuffer(ioBuffer, sound_osd->pitch, float, bytes_available, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, sound_osd->volume, float, bytes_available, OBJcWrite_Little); // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = OBJiSound_GetOSDWriteSize(inObject); // *ioBufferSize - bytes_available; - + return UUcError_None; } @@ -753,15 +753,15 @@ OBJrSound_GetAmbient( const OBJtObject *inObject) { OBJtOSD_Sound *sound_osd; - + // get a pointer to the sound osd sound_osd = (OBJtOSD_Sound*)inObject->object_data; - + if (sound_osd->ambient == NULL) { sound_osd->ambient = OSrAmbient_GetByName(sound_osd->ambient_name); } - + return sound_osd->ambient; } @@ -773,14 +773,14 @@ OBJrSound_GetMinMaxDistances( float *outMinVolumeDistance) { OBJtOSD_Sound *sound_osd; - + // get a pointer to the sound osd sound_osd = (OBJtOSD_Sound*)inObject->object_data; if (sound_osd->type != OBJcSoundType_Spheres) { return UUcFalse; } - + *outMaxVolumeDistance = sound_osd->u.spheres.max_volume_distance; *outMinVolumeDistance = sound_osd->u.spheres.min_volume_distance; - + return UUcTrue; } @@ -790,7 +790,7 @@ OBJrSound_GetPitch( const OBJtObject *inObject) { OBJtOSD_Sound *sound_osd; - + // get a pointer to the sound osd sound_osd = (OBJtOSD_Sound*)inObject->object_data; return sound_osd->pitch; @@ -802,7 +802,7 @@ OBJrSound_GetType( const OBJtObject *inObject) { OBJtOSD_Sound *sound_osd; - + // get a pointer to the sound osd sound_osd = (OBJtOSD_Sound*)inObject->object_data; return sound_osd->type; @@ -814,7 +814,7 @@ OBJrSound_GetVolume( const OBJtObject *inObject) { OBJtOSD_Sound *sound_osd; - + // get a pointer to the sound osd sound_osd = (OBJtOSD_Sound*)inObject->object_data; return sound_osd->volume; @@ -827,10 +827,10 @@ OBJrSound_Initialize( { UUtError error; OBJtMethods methods; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiSound_New; methods.rSetDefaults = OBJiSound_SetDefaults; @@ -847,12 +847,12 @@ OBJrSound_Initialize( methods.rSetOSD = OBJiSound_SetOSD; methods.rRead = OBJiSound_Read; methods.rWrite = OBJiSound_Write; - + // set up the type methods methods.rGetClassVisible = OBJiSound_GetVisible; methods.rSearch = OBJiSound_Search; methods.rSetClassVisible = OBJiSound_SetVisible; - + // register the furniture methods error = OBJrObjectGroup_Register( @@ -863,7 +863,7 @@ OBJrSound_Initialize( &methods, OBJcObjectGroupFlag_None); UUmError_ReturnOnError(error); - + #if CONSOLE_DEBUGGING_COMMANDS // register the variables error = @@ -889,7 +889,7 @@ OBJrSound_Initialize( #endif OBJgSound_DrawSounds = UUcFalse; - + return UUcError_None; } @@ -901,28 +901,28 @@ OBJrSound_PointIn( { OBJtOSD_Sound *sound_osd; UUtBool point_in_object; - + // get a pointer to the sound osd sound_osd = (OBJtOSD_Sound*)inObject->object_data; - + point_in_object = UUcFalse; switch (sound_osd->type) { case OBJcSoundType_Spheres: { float distance; - + distance = MUrPoint_Distance_Squared(inPoint, &inObject->position) * UUmSQR(SScFootToDist); point_in_object = (distance <= UUmSQR(sound_osd->u.spheres.min_volume_distance)); } break; - + case OBJcSoundType_BVolume: point_in_object = PHrCollision_Volume_Point_Inside(&sound_osd->u.bvolume.bvolume, inPoint); break; } - + return point_in_object; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Trigger.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Trigger.c index 3724c0d..0254c7c 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Trigger.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Trigger.c @@ -81,12 +81,12 @@ static void OBJrTrigger_OnTrigger( OBJtObject* inObject, ONtCharacter *inCharact UUtError error; trigger_osd = (OBJtOSD_Trigger*)inObject->object_data; - + if( trigger_osd->flags & OBJcTriggerFlag_Triggered ) return; trigger_osd->flags |= OBJcTriggerFlag_Triggered; - + COrConsole_Printf("Trigger Triggered (%d)", trigger_osd->id ); if ((trigger_osd->trigger_class != NULL) && (trigger_osd->trigger_class->trigger_sound != NULL)) { @@ -110,15 +110,15 @@ static void OBJiTrigger_Delete( OBJtObject *inObject ) OBJtOSD_Trigger *trigger_osd; trigger_osd= (OBJtOSD_Trigger*) inObject->object_data; - + OBJiTrigger_StopActiveSound(inObject, trigger_osd); - + if (trigger_osd->flags & OBJcTriggerFlag_Initialized) { UUmAssert(trigger_osd->anim_points); UUrMemory_Block_Delete(trigger_osd->anim_points); - + trigger_osd->anim_points= NULL; trigger_osd->flags&= ~OBJcTriggerFlag_Initialized; } @@ -150,8 +150,8 @@ static void OBJiTrigger_DrawLaserDot(M3tPoint3D *inPoint) M3rCamera_GetViewData(ONgActiveCamera, &cameraLocation, NULL, NULL); error = TMrInstance_GetDataPtr( - M3cTemplate_TextureMap, - "dot", + M3cTemplate_TextureMap, + "dot", (void **) &dotTexture); UUmAssert(UUcError_None == error); @@ -305,7 +305,7 @@ static void OBJrTrigger_GetWorldPoint(OBJtOSD_Trigger *trigger_osd, M3tPoint3D * // expensive collision test against the environment once { OBJtTriggerEmitterInstance *instance= &trigger_osd->emitters[i]; - + if (instance) { UUtUns16 current_frame_index= (UUtInt16)instance->anim_frame; @@ -356,17 +356,17 @@ static void OBJiTrigger_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) M3tMatrix4x3 matrix_stack[2]; - + if (OBJgTrigger_DrawTriggers == UUcFalse) { return; } // don't draw when the non-occluding geometry is hidden if (AKgDraw_Occl == UUcTrue) { return; } - + trigger_osd = (OBJtOSD_Trigger*)inObject->object_data; UUmAssert( trigger_osd->trigger_class && trigger_osd->trigger_class->emitter && trigger_osd->trigger_class->base_geometry ); emitter = trigger_osd->trigger_class->emitter; - + MUrMatrix_BuildTranslate(inObject->position.x, inObject->position.y, inObject->position.z, matrix_stack + 0); MUrMatrixStack_Matrix(matrix_stack + 0, &trigger_osd->rotation_matrix); @@ -390,33 +390,33 @@ static void OBJiTrigger_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) { MUrMatrixStack_Matrix(matrix_stack + 1, &trigger_osd->emitters[i].matrix); - + AKrEnvironment_DrawIfVisible_Point(trigger_osd->trigger_class->emitter->geometry, matrix_stack + 1); // draw the laser if active if ((trigger_osd->flags & OBJcTriggerFlag_Active) && trigger_osd->laser_on) { M3tVector3D world_dir; - + // shoot ray to find endpoint - { + { UUtBool hit_player_character = UUcFalse; M3tVector3D laserVector; - + laserFrom = emitter->emit_position; laserVector = emitter->emit_vector; MUmVector_Normalize(laserVector); MUmVector_Add( world_points[1], laserFrom, laserVector); - + world_points[0] = laserFrom; MUrMatrix_MultiplyPoints(2, matrix_stack + 1, world_points, world_points); // velocity and position MUmVector_Subtract(world_dir, world_points[1], world_points[0]); - + // do the collision { M3tPoint3D environment_end_point; @@ -462,7 +462,7 @@ static void OBJiTrigger_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) uAmt = UUmPin(uAmt, 0.f, 1.f); uAmt = 1.f - uAmt; } - + MUrLineSegment_ComputePoint(&world_points[0], &world_points[1], uAmt, &world_points[1]); MUmVector_Scale( laserVector, distance * uAmt ); @@ -483,7 +483,7 @@ static void OBJiTrigger_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) //if (AKrEnvironment_IsBoundingBoxMinMaxVisible(&laser_bbox)) { UUtUns32 color= trigger_osd->color; - + #if defined(UUmPlatform) && (UUmPlatform == UUmPlatform_Mac) color= ((color&0xFF000000)>>24)|((color& 0x00FF0000)>>8)|((color&0x0000FF00)<<8)|((color&0x000000FF)<<24); #endif @@ -509,7 +509,7 @@ static void OBJiTrigger_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) if( trigger_osd->flags & OBJcTriggerFlag_Active && trigger_osd->flags & OBJcTriggerFlag_Initialized ) { M3rGeometry_LineDraw((UUtUns16) trigger_osd->trigger_class->animation->numFrames, trigger_osd->anim_points, IMcShade_Blue); - M3rMinMaxBBox_To_BBox( &trigger_osd->bounding_box, &bBox); + M3rMinMaxBBox_To_BBox( &trigger_osd->bounding_box, &bBox); M3rBBox_Draw_Line(&bBox, IMcShade_Yellow ); } @@ -518,7 +518,7 @@ static void OBJiTrigger_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) M3rMatrixStack_Multiply(&trigger_osd->rotation_matrix); // Draw the base boxes - M3rMinMaxBBox_To_BBox( &trigger_osd->trigger_class->base_geometry->pointArray->minmax_boundingBox, &bBox); + M3rMinMaxBBox_To_BBox( &trigger_osd->trigger_class->base_geometry->pointArray->minmax_boundingBox, &bBox); M3rBBox_Draw_Line(&bBox, IMcShade_White); // draw the rings @@ -527,11 +527,11 @@ static void OBJiTrigger_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) // draw the animation points if( trigger_osd->trigger_class->animation ) { - if (trigger_osd->trigger_class->animation->numFrames > 0) + if (trigger_osd->trigger_class->animation->numFrames > 0) { M3tPoint3D *anim_points = NULL; anim_points = UUrMemory_Block_New( sizeof(M3tPoint3D) * trigger_osd->trigger_class->animation->numFrames); - for(i = 0; i < trigger_osd->trigger_class->animation->numFrames; i++) + for(i = 0; i < trigger_osd->trigger_class->animation->numFrames; i++) { M3tMatrix4x3 anim_matrix; OBrAnimation_GetMatrix(trigger_osd->trigger_class->animation, i, 0, &anim_matrix); @@ -545,7 +545,7 @@ static void OBJiTrigger_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) // draw emitter boxes for( i = 0; i < trigger_osd->emitter_count; i++ ) { - M3rMatrixStack_Push(); + M3rMatrixStack_Push(); M3rMatrixStack_Multiply(&trigger_osd->emitters[i].matrix); M3rMinMaxBBox_To_BBox( &trigger_osd->trigger_class->emitter->geometry->pointArray->minmax_boundingBox, &bBox); M3rBBox_Draw_Line(&bBox, IMcShade_White); @@ -568,7 +568,7 @@ OBJiTrigger_Enumerate( OBJtObject *inObject, OBJtEnumCallback_ObjectName inEnumC static void OBJiTrigger_GetBoundingSphere( const OBJtObject *inObject, M3tBoundingSphere *outBoundingSphere) { OBJtOSD_Trigger *trigger_osd; - + trigger_osd = (OBJtOSD_Trigger*)inObject->object_data; *outBoundingSphere = trigger_osd->bounding_sphere; @@ -578,7 +578,7 @@ static void OBJiTrigger_GetBoundingSphere( const OBJtObject *inObject, M3tBoundi static void OBJiTrigger_OSDGetName( const OBJtOSD_All *inObject, char *outName, UUtUns32 inNameLength) { const OBJtOSD_Trigger *trigger_osd = &inObject->osd.trigger_osd; - + sprintf(outName, "%s_%d", trigger_osd->trigger_class_name, trigger_osd->id); return; @@ -589,9 +589,9 @@ static void OBJiTrigger_GetOSD( const OBJtObject *inObject, OBJtOSD_All *outOSD) OBJtOSD_Trigger *trigger_osd; trigger_osd = (OBJtOSD_Trigger*)inObject->object_data; - + UUrMemory_MoveFast( trigger_osd, &outOSD->osd.trigger_osd, sizeof(OBJtOSD_Trigger) ); - + ONrEventList_Copy( &trigger_osd->event_list, &outOSD->osd.trigger_osd.event_list ); } @@ -605,35 +605,35 @@ OBJiTrigger_IntersectsLine( M3tBoundingSphere sphere; UUrMemory_Clear(&sphere, sizeof(M3tBoundingSphere)); - + // get the bounding sphere OBJiTrigger_GetBoundingSphere(inObject, &sphere); - + sphere.center.x += inObject->position.x; sphere.center.y += inObject->position.y; sphere.center.z += inObject->position.z; - + return CLrSphere_Line(inStartPoint, inEndPoint, &sphere); } // ---------------------------------------------------------------------- static UUtError OBJiTrigger_SetDefaults(OBJtOSD_All *outOSD) { - UUtError error; + UUtError error; void *instances[OBJcMaxInstances]; UUtUns32 num_instances; char *instance_name; // clear the osd UUrMemory_Clear(&outOSD->osd.trigger_osd, sizeof(OBJtOSD_Trigger)); - + // get a list of instances of the class error = TMrInstance_GetDataPtr_List( OBJcTemplate_TriggerClass, OBJcMaxInstances, &num_instances, instances); UUmError_ReturnOnError(error); - // copy the name of the first trigger instance into the osd_all. + // copy the name of the first trigger instance into the osd_all. instance_name = TMrInstance_GetInstanceName(instances[0]); - + UUrString_Copy(outOSD->osd.trigger_osd.trigger_class_name,instance_name,OBJcMaxNameLength); // default initial data @@ -659,7 +659,7 @@ static UUtError OBJiTrigger_New( OBJtObject *inObject, const OBJtOSD_All *inOSD { OBJtOSD_All osd_all; UUtError error; - + if (inOSD == NULL) { error = OBJiTrigger_SetDefaults(&osd_all); @@ -675,7 +675,7 @@ static UUtError OBJiTrigger_New( OBJtObject *inObject, const OBJtOSD_All *inOSD // set the object specific data and position error = OBJiTrigger_SetOSD(inObject, &osd_all); UUmError_ReturnOnError(error); - + OBJiTrigger_UpdatePosition(inObject); UUrMemory_Block_VerifyList(); @@ -707,12 +707,12 @@ OBJiTrigger_Read( OBJmGet2BytesFromBuffer(inBuffer, osd_all.osd.trigger_osd.time_on, UUtUns16, inSwapIt); OBJmGet2BytesFromBuffer(inBuffer, osd_all.osd.trigger_osd.time_off, UUtUns16, inSwapIt); - num_bytes = - OBJcMaxNameLength + + num_bytes = + OBJcMaxNameLength + + sizeof(UUtUns16) + sizeof(UUtUns16) + - sizeof(UUtUns16) + - sizeof(UUtUns32) + - sizeof(float) + + sizeof(UUtUns32) + + sizeof(float) + sizeof(float) + sizeof(UUtUns16) + sizeof(UUtUns16) + @@ -724,9 +724,9 @@ OBJiTrigger_Read( // bring the object up to date OBJiTrigger_SetOSD(inObject, &osd_all); - + ONrEventList_Destroy(&osd_all.osd.trigger_osd.event_list); - + OBJiTrigger_UpdatePosition(inObject); return num_bytes; @@ -738,16 +738,16 @@ OBJiTrigger_Write( UUtUns8 *ioBuffer, UUtUns32 *ioBufferSize) { - + OBJtOSD_Trigger *trigger_osd; UUtUns32 bytes_available; // get a pointer to the object osd trigger_osd = (OBJtOSD_Trigger*)inObject->object_data; - + // set the number of bytes available bytes_available = *ioBufferSize; - + // put the trigger name, shade, id, and note OBJmWriteStringToBuffer(ioBuffer, trigger_osd->trigger_class_name, OBJcMaxNameLength, bytes_available, OBJcWrite_Little); OBJmWrite2BytesToBuffer(ioBuffer, trigger_osd->id, UUtInt16, bytes_available, OBJcWrite_Little); @@ -758,11 +758,11 @@ OBJiTrigger_Write( OBJmWrite2BytesToBuffer(ioBuffer, trigger_osd->emitter_count, UUtInt16, bytes_available, OBJcWrite_Little); OBJmWrite2BytesToBuffer(ioBuffer, trigger_osd->time_on, UUtInt16, bytes_available, OBJcWrite_Little); OBJmWrite2BytesToBuffer(ioBuffer, trigger_osd->time_off, UUtInt16, bytes_available, OBJcWrite_Little); - + ONrEventList_Write( &trigger_osd->event_list, ioBuffer, &bytes_available ); *ioBufferSize -= bytes_available; - + return UUcError_None; } @@ -773,13 +773,13 @@ static UUtUns32 OBJiTrigger_GetOSDWriteSize( const OBJtObject *inObject ) OBJtOSD_Trigger *trigger_osd; trigger_osd = (OBJtOSD_Trigger*) inObject->object_data; - - size = + + size = OBJcMaxNameLength + sizeof(UUtUns16) + - sizeof(UUtUns16) + - sizeof(UUtUns32) + - sizeof(float) + + sizeof(UUtUns16) + + sizeof(UUtUns32) + + sizeof(float) + sizeof(float) + sizeof(UUtUns16) + sizeof(UUtUns16) + @@ -800,7 +800,7 @@ static void OBJiTrigger_StartActiveSound(OBJtObject *inObject, OBJtOSD_Trigger * } else { ioTriggerOSD->playing_sound = SScInvalidID; } - + ioTriggerOSD->flags |= OBJcTriggerFlag_PlayingSound; } } @@ -831,7 +831,7 @@ static UUtError OBJiTrigger_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inO // get a pointer to the object osd trigger_osd = (OBJtOSD_Trigger*)inObject->object_data; - + OBJiTrigger_StopActiveSound(inObject, trigger_osd); // copy persistant data @@ -860,7 +860,7 @@ static UUtError OBJiTrigger_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inO trigger_osd->emitters = UUrMemory_Block_Realloc( trigger_osd->emitters, sizeof(OBJtTriggerEmitterInstance) * trigger_osd->emitter_count ); // grab the template - error = TMrInstance_GetDataPtr( OBJcTemplate_TriggerClass, trigger_osd->trigger_class_name, &trigger_class ); + error = TMrInstance_GetDataPtr( OBJcTemplate_TriggerClass, trigger_osd->trigger_class_name, &trigger_class ); if( error != UUcError_None ) { UUrDebuggerMessage("failed to find trigger class %s", trigger_osd->trigger_class_name); @@ -869,7 +869,7 @@ static UUtError OBJiTrigger_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inO UUmError_ReturnOnErrorMsg(error, "failed to find any trigger class"); - inObject->flags |= OBJcObjectFlag_Temporary; + inObject->flags |= OBJcObjectFlag_Temporary; trigger_osd->trigger_class = NULL; } @@ -880,7 +880,7 @@ static UUtError OBJiTrigger_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inO // build the position matrix OBJiTrigger_UpdatePosition(inObject); - + // create the bounding sphere OBJiTrigger_CreateBoundingSphere(inObject, trigger_osd); @@ -907,21 +907,21 @@ static UUtError OBJiTrigger_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inO // ---------------------------------------------------------------------- static void OBJiTrigger_UpdatePosition(OBJtObject *inObject) { - + OBJtOSD_Trigger *trigger_osd; float rot_x; float rot_y; float rot_z; MUtEuler euler; - + // get a pointer to the object osd trigger_osd = (OBJtOSD_Trigger*)inObject->object_data; - + // convert the rotation to radians rot_x = inObject->rotation.x * M3cDegToRad; rot_y = inObject->rotation.y * M3cDegToRad; rot_z = inObject->rotation.z * M3cDegToRad; - + // update the rotation matrix euler.order = MUcEulerOrderXYZs; euler.x = rot_x; @@ -949,13 +949,13 @@ static UUtBool OBJiTrigger_GetVisible(void) // ---------------------------------------------------------------------- static UUtBool OBJiTrigger_Search( const OBJtObject *inObject, const UUtUns32 inSearchType, const OBJtOSD_All *inSearchParams) { - + OBJtOSD_Trigger *trigger_osd; UUtBool found; - + // get a pointer to the object osd trigger_osd = (OBJtOSD_Trigger*)inObject->object_data; - + // perform the check found = UUcFalse; switch (inSearchType) @@ -985,7 +985,7 @@ static UUtError OBJrTrigger_Activate( OBJtObject *inObject ) UUmAssert( inObject->object_type == OBJcType_Trigger ); trigger_osd = (OBJtOSD_Trigger*) inObject->object_data; - + trigger_osd->flags |= OBJcTriggerFlag_Active; trigger_osd->laser_on = UUcTrue; @@ -1008,7 +1008,7 @@ static UUtError OBJrTrigger_Deactivate( OBJtObject *inObject ) UUmAssert( inObject->object_type == OBJcType_Trigger ); trigger_osd = (OBJtOSD_Trigger*) inObject->object_data; - + trigger_osd->flags &= ~OBJcTriggerFlag_Active; return UUcError_None; @@ -1021,7 +1021,7 @@ static UUtBool OBJrTrigger_Activate_Enum(OBJtObject *inObject, UUtUns32 inUserDa UUmAssert( inObject->object_type == OBJcType_Trigger ); trigger_osd = (OBJtOSD_Trigger*) inObject->object_data; - + if( trigger_osd->id == inUserData ) { OBJrTrigger_Activate( (OBJtObject*) inObject ); @@ -1057,7 +1057,7 @@ UUtError OBJrTrigger_Reset(OBJtObject* inObject) trigger_osd = (OBJtOSD_Trigger*) inObject->object_data; // setup time - trigger_osd->laser_on = UUcTrue; + trigger_osd->laser_on = UUcTrue; if( trigger_osd->time_on || trigger_osd->time_off ) trigger_osd->change_time = trigger_osd->time_on; @@ -1071,7 +1071,7 @@ UUtError OBJrTrigger_Reset(OBJtObject* inObject) space = (float)trigger_osd->trigger_class->animation->numFrames / (float)trigger_osd->emitter_count; for( i = 0; i < trigger_osd->emitter_count; i++ ) { - instance = &trigger_osd->emitters[i]; + instance = &trigger_osd->emitters[i]; instance->anim_context.animation = trigger_osd->trigger_class->animation; instance->anim_context.animationFrame = 0; instance->anim_context.animationStep = 1; @@ -1080,7 +1080,7 @@ UUtError OBJrTrigger_Reset(OBJtObject* inObject) instance->anim_context.frameStartTime = 0; OBrAnim_Start(&instance->anim_context); - //instance->anim_frame = (float) fmod( ( (float) (space * i) + ( trigger_osd->start_offset * trigger_osd->trigger_class->animation->numFrames )), trigger_osd->trigger_class->animation->numFrames ); + //instance->anim_frame = (float) fmod( ( (float) (space * i) + ( trigger_osd->start_offset * trigger_osd->trigger_class->animation->numFrames )), trigger_osd->trigger_class->animation->numFrames ); if( trigger_osd->start_offset == 1.0f ) { instance->anim_frame = trigger_osd->trigger_class->animation->numFrames - 1.f; } @@ -1225,7 +1225,7 @@ void OBJrTrigger_Activate_ID( UUtUns16 inID ) inID = OBJcTriggerSelectAll; } - OBJrObjectType_EnumerateObjects( OBJcType_Trigger, OBJrTrigger_Activate_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Trigger, OBJrTrigger_Activate_Enum, (UUtUns32) inID ); return; } @@ -1236,7 +1236,7 @@ void OBJrTrigger_Deactivate_ID( UUtUns16 inID ) inID = OBJcTriggerSelectAll; } - OBJrObjectType_EnumerateObjects( OBJcType_Trigger, OBJrTrigger_Deactivate_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Trigger, OBJrTrigger_Deactivate_Enum, (UUtUns32) inID ); return; } @@ -1244,10 +1244,10 @@ void OBJrTrigger_Deactivate_ID( UUtUns16 inID ) void OBJrTrigger_Reset_ID( UUtUns16 inID ) { if (inID == (UUtUns16) -1) { - inID = OBJcTriggerSelectAll; + inID = OBJcTriggerSelectAll; } - OBJrObjectType_EnumerateObjects( OBJcType_Trigger, OBJrTrigger_Reset_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Trigger, OBJrTrigger_Reset_Enum, (UUtUns32) inID ); return; } @@ -1258,7 +1258,7 @@ void OBJrTrigger_Hide_ID(UUtUns16 inID) inID = OBJcTriggerSelectAll; } - OBJrObjectType_EnumerateObjects( OBJcType_Trigger, OBJrTrigger_Hide_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Trigger, OBJrTrigger_Hide_Enum, (UUtUns32) inID ); return; } @@ -1269,7 +1269,7 @@ void OBJrTrigger_Show_ID(UUtUns16 inID) inID = OBJcTriggerSelectAll; } - OBJrObjectType_EnumerateObjects( OBJcType_Trigger, OBJrTrigger_Show_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Trigger, OBJrTrigger_Show_Enum, (UUtUns32) inID ); return; } @@ -1282,7 +1282,7 @@ void OBJrTrigger_SetSpeed_ID(UUtUns16 inID, float inSpeed) OBJgTrigger_SetSpeedValue = inSpeed; - OBJrObjectType_EnumerateObjects( OBJcType_Trigger, OBJrTrigger_SetSpeed_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Trigger, OBJrTrigger_SetSpeed_Enum, (UUtUns32) inID ); return; } @@ -1291,14 +1291,14 @@ void OBJrTrigger_SetSpeed_ID(UUtUns16 inID, float inSpeed) // ---------------------------------------------------------------------- void OBJrTrigger_AddEvent( OBJtOSD_Trigger *inTrigger_osd, ONtEvent *inEvent ) -{ +{ ONrEventList_AddEvent( &inTrigger_osd->event_list, inEvent ); return; } void OBJrTrigger_DeleteEvent( OBJtOSD_Trigger *inTrigger_osd, UUtUns32 inIndex ) -{ +{ ONrEventList_DeleteEvent( &inTrigger_osd->event_list, inIndex ); return; @@ -1316,17 +1316,17 @@ extern UUtBool FXgLaser_UseAlpha; // ---------------------------------------------------------------------- UUtError OBJrTrigger_Initialize(void) { - + UUtError error; OBJtMethods methods; ONtMechanicsMethods mechanics_methods; - + // intialize the globals OBJgTrigger_DrawTriggers = UUcTrue; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiTrigger_New; methods.rSetDefaults = OBJiTrigger_SetDefaults; @@ -1342,12 +1342,12 @@ UUtError OBJrTrigger_Initialize(void) methods.rSetOSD = OBJiTrigger_SetOSD; methods.rRead = OBJiTrigger_Read; methods.rWrite = OBJiTrigger_Write; - + // set up the type methods methods.rGetClassVisible = OBJiTrigger_GetVisible; methods.rSearch = OBJiTrigger_Search; methods.rSetClassVisible = OBJiTrigger_SetVisible; - + // set up the mechanics methods mechanics_methods.rInitialize = NULL; mechanics_methods.rTerminate = NULL; @@ -1359,7 +1359,7 @@ UUtError OBJrTrigger_Initialize(void) mechanics_methods.rClassLevelEnd = NULL; mechanics_methods.rClassReset = NULL; mechanics_methods.rClassUpdate = NULL; - + // register the trigger methods error = ONrMechanics_Register( OBJcType_Trigger, OBJcTypeIndex_Trigger, "Trigger", sizeof(OBJtOSD_Trigger), &methods, 0, &mechanics_methods ); UUmError_ReturnOnError(error); diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_TriggerVolume.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_TriggerVolume.c index d5dab82..eac79d4 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_TriggerVolume.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_TriggerVolume.c @@ -196,7 +196,7 @@ static void Trigger_BuildVolume(OBJtObject *inObject) M3tPoint3D *point; normal = volume->normals[itr]; - + point = volume->worldPoints + volume->faces[itr].indices[0]; plane = volume->curPlanes + itr; @@ -205,7 +205,7 @@ static void Trigger_BuildVolume(OBJtObject *inObject) plane->c = normal.z; plane->d = -(normal.x*point->x + normal.y*point->y + normal.z*point->z); - volume->curProjections[itr] = (UUtUns16) + volume->curProjections[itr] = (UUtUns16) CLrQuad_FindProjection(volume->worldPoints, volume->faces + itr); // degenerate quads should be culled at import time @@ -309,10 +309,10 @@ OBJiTriggerVolume_Enumerate( UUtUns32 inUserData) { char name[OBJcMaxNameLength + 1]; - + OBJrObject_GetName(inObject, name, OBJcMaxNameLength); inEnumCallback(name, inUserData); - + return UUcError_None; } @@ -341,9 +341,9 @@ OBJiTriggerVolume_OSDGetName( // get a pointer to the object osd trigger_osd = &inOSD->osd.trigger_volume_osd; - + UUrString_Copy(outName, trigger_osd->name, inNameLength); - + return; } @@ -356,7 +356,7 @@ OBJiTriggerVolume_OSDSetName( // get a pointer to the object osd trigger_osd = &inOSD->osd.trigger_volume_osd; - + UUrString_Copy(trigger_osd->name, outName, sizeof(trigger_osd->name)); return; @@ -372,7 +372,7 @@ OBJiTriggerVolume_GetOSD( // get a pointer to the object osd trigger_osd = (OBJtOSD_TriggerVolume *)inObject->object_data; - + outOSD->osd.trigger_volume_osd = *trigger_osd; return; @@ -524,7 +524,7 @@ OBJiTriggerVolume_New( { OBJtOSD_All osd_all; UUtError error; - + if (NULL == inOSD) { error = OBJiTriggerVolume_SetDefaults(&osd_all); UUmError_ReturnOnError(error); @@ -533,11 +533,11 @@ OBJiTriggerVolume_New( { OBJiTriggerVolume_DuplicateOSD(inOSD, &osd_all); } - + // set the object specific data and position error = OBJrObject_SetObjectSpecificData(inObject, &osd_all); UUmError_ReturnOnError(error); - + OBJrObject_UpdatePosition(inObject); return UUcError_None; @@ -562,7 +562,7 @@ OBJrTriggerVolume_Reset( UUrString_Copy(trig_osd->cur_exit_script, trig_osd->exit_script, sizeof(trig_osd->cur_exit_script)); Trigger_BuildVolume(inObject); - + return UUcError_None; } @@ -600,7 +600,7 @@ OBJiTriggerVolume_Read( // bring the object up to date OBJrObject_UpdatePosition(inObject); - + return bytes_read; } @@ -611,7 +611,7 @@ OBJiTriggerVolume_SetOSD( const OBJtOSD_All *inOSD) { OBJtOSD_TriggerVolume *dst_osd = (OBJtOSD_TriggerVolume *) inObject->object_data; - + UUmAssert(inOSD); UUrMemory_MoveFast(inOSD, dst_osd, sizeof(*dst_osd)); @@ -729,10 +729,10 @@ OBJiTriggerVolume_Search( { OBJtOSD_TriggerVolume *trigger_osd; UUtBool found; - + // get a pointer to the object osd trigger_osd = (OBJtOSD_TriggerVolume *)inObject->object_data; - + // perform the check switch (inSearchType) { @@ -748,7 +748,7 @@ OBJiTriggerVolume_Search( found = UUcFalse; break; } - + return found; } @@ -765,10 +765,10 @@ OBJrTriggerVolume_Initialize( UUtError error; OBJtMethods methods; ONtMechanicsMethods mechanics_methods; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiTriggerVolume_New; methods.rSetDefaults = OBJiTriggerVolume_SetDefaults; @@ -789,7 +789,7 @@ OBJrTriggerVolume_Initialize( methods.rSearch = OBJiTriggerVolume_Search; methods.rSetClassVisible = OBJiTriggerVolume_SetVisible; methods.rGetUniqueOSD = OBJiTriggerVolume_GetUniqueOSD; - + // set up the mechanics methods UUrMemory_Clear(&mechanics_methods, sizeof(ONtMechanicsMethods)); mechanics_methods.rInitialize = NULL; @@ -807,7 +807,7 @@ OBJrTriggerVolume_Initialize( error = ONrMechanics_Register(OBJcType_TriggerVolume, OBJcTypeIndex_TriggerVolume, "Trigger Volume", sizeof(OBJtOSD_TriggerVolume), &methods, OBJcObjectGroupFlag_CanSetName, &mechanics_methods ); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Turret.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Turret.c index 481d670..8c0114b 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Turret.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Turret.c @@ -77,7 +77,7 @@ static void OBJiTurret_StopActiveSound(OBJtObject *inObject, OBJtOSD_Turret *ioT static void OBJiTurret_VisibleNodeList_Invalidate(OBJtOSD_Turret *turret_osd); static void OBJiTurret_VisibleNodeList_Build(OBJtOSD_Turret *turret_osd); -AI2tTargetingCallbacks OBJgTurret_TargetingCallbacks = +AI2tTargetingCallbacks OBJgTurret_TargetingCallbacks = { OBJiTurret_TargetingCallback_Fire, NULL, //OBJiTurret_TargetingCallback_SetAimSpeed, @@ -103,7 +103,7 @@ static void OBJiTurret_StartActiveSound(OBJtObject *inObject, OBJtOSD_Turret *io } else { ioTurretOSD->playing_sound = SScInvalidID; } - + ioTurretOSD->flags |= OBJcTurretFlag_PlayingSound; } } @@ -134,7 +134,7 @@ static void OBJrTurret_LookAtPoint(OBJtObject *inObject, M3tVector3D* inPoint) M3tMatrix4x3 inverse_matrix; M3tVector3D neg_position; - + UUmAssert( inObject->object_type == OBJcType_Turret ); turret_osd = (OBJtOSD_Turret*) inObject->object_data; @@ -186,46 +186,46 @@ static void OBJiTurret_CreateBoundingSphere( OBJtObject *inObject, OBJtOSD_Turre M3tBoundingSphere *sphere; M3tPoint3D new_center; float new_radius; - + new_center.x = 0.0f; new_center.y = 0.0f; new_center.z = 0.0f; - + if( !inOSD->turret_class ) return; // calculate the center of the sphere sphere = &inOSD->turret_class->base_geometry->pointArray->boundingSphere; MUmVector_Increment(new_center, sphere->center); - + sphere = &inOSD->turret_class->turret_geometry->pointArray->boundingSphere; MUmVector_Increment(new_center, sphere->center); - + sphere = &inOSD->turret_class->barrel_geometry->pointArray->boundingSphere; MUmVector_Increment(new_center, sphere->center); - + new_center.x /= 3; new_center.y /= 3; new_center.z /= 3; - + // caculate the new radius new_radius = 0.0f; //for (i = 0; i < inOSD->furn_geom_array->num_furn_geoms; i++) { // M3tVector3D vector; // float temp_radius; -/* +/* sphere = &inOSD->furn_geom_array->furn_geom[i].geometry->pointArray->boundingSphere; MUmVector_Subtract(vector, new_center, sphere->center); temp_radius = MUrVector_Length(&vector) + sphere->radius; */ // new_radius = UUmMax(new_radius, temp_radius); } - + // set the bounding sphere inOSD->bounding_sphere.center = new_center; inOSD->bounding_sphere.radius = new_radius; - + //inOSD->bounding_sphere.center = sphere->center; inOSD->bounding_sphere.center = inOSD->turret_class->turret_position; inOSD->bounding_sphere.radius = (float) ( sphere->radius * 2.0 ); @@ -332,7 +332,7 @@ static void OBJiTurret_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) if (OBJgTurret_DrawTurrets == UUcFalse) { return; } // don't draw when the non-occluding geometry is hidden if (AKgDraw_Occl == UUcTrue) { return; } - + turret_osd = (OBJtOSD_Turret*)inObject->object_data; if( !turret_osd->turret_class ) @@ -342,7 +342,7 @@ static void OBJiTurret_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) OBJiTurret_BuildMatricies( inObject ); OBJiTurret_VisibleNodeList_Build(turret_osd); - + if (AKrEnvironment_NodeList_Visible(turret_osd->visible_node_list)) { M3tMatrix4x3 draw_matrix; @@ -350,7 +350,7 @@ static void OBJiTurret_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) // apply position and orientation matrix draw_matrix = turret_osd->matrix; - + #if TOOL_VERSION if(!(inObject->flags & OBJcObjectFlag_Gunk)) { M3rGeometry_MultiplyAndDraw(turret_osd->turret_class->base_geometry, &draw_matrix); @@ -358,10 +358,10 @@ static void OBJiTurret_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) #endif // apply turret matrix MUrMatrixStack_Matrix(&draw_matrix, &turret_osd->turret_matrix); - + // draw the turret geometry M3rGeometry_MultiplyAndDraw(turret_osd->turret_class->turret_geometry, &draw_matrix); - + // apply barrel matrix MUrMatrixStack_Matrix(&draw_matrix, &turret_osd->barrel_matrix); @@ -397,27 +397,27 @@ static void OBJiTurret_Draw( OBJtObject *inObject, UUtUns32 inDrawFlags) M3rMatrixStack_Multiply(&turret_osd->matrix); // base box and object rotation rings - M3rMinMaxBBox_To_BBox( &turret_osd->turret_class->base_geometry->pointArray->minmax_boundingBox, &bBox); - M3rBBox_Draw_Line(&bBox, IMcShade_White); + M3rMinMaxBBox_To_BBox( &turret_osd->turret_class->base_geometry->pointArray->minmax_boundingBox, &bBox); + M3rBBox_Draw_Line(&bBox, IMcShade_White); OBJrObjectUtil_DrawRotationRings(inObject, &turret_osd->bounding_sphere, inDrawFlags); // apply turret matrix - M3rMatrixStack_Multiply(&turret_osd->turret_matrix); - + M3rMatrixStack_Multiply(&turret_osd->turret_matrix); + // turret box - M3rMinMaxBBox_To_BBox( &turret_osd->turret_class->turret_geometry->pointArray->minmax_boundingBox, &bBox); + M3rMinMaxBBox_To_BBox( &turret_osd->turret_class->turret_geometry->pointArray->minmax_boundingBox, &bBox); M3rBBox_Draw_Line(&bBox, IMcShade_White); // apply barrel matrix - M3rMatrixStack_Multiply(&turret_osd->barrel_matrix); + M3rMatrixStack_Multiply(&turret_osd->barrel_matrix); // barrel box - M3rMinMaxBBox_To_BBox( &turret_osd->turret_class->barrel_geometry->pointArray->minmax_boundingBox, &bBox); + M3rMinMaxBBox_To_BBox( &turret_osd->turret_class->barrel_geometry->pointArray->minmax_boundingBox, &bBox); M3rBBox_Draw_Line(&bBox, IMcShade_White); } M3rMatrixStack_Pop(); } - + if( OBJgTurret_DrawTurretDebugInfo ) OBJrTurretDisplayDebuggingInfo(inObject); #endif @@ -433,7 +433,7 @@ static UUtError OBJiTurret_Enumerate( OBJtObject *inObject, OBJtEnumCallback_Obj static void OBJiTurret_GetBoundingSphere( const OBJtObject *inObject, M3tBoundingSphere *outBoundingSphere ) { OBJtOSD_Turret *Turret_osd; - + Turret_osd = (OBJtOSD_Turret*)inObject->object_data; *outBoundingSphere = Turret_osd->bounding_sphere; @@ -443,7 +443,7 @@ static void OBJiTurret_GetBoundingSphere( const OBJtObject *inObject, M3tBoundin static void OBJiTurret_OSDGetName( const OBJtOSD_All *inOSD, char *outName, UUtUns32 inNameLength ) { const OBJtOSD_Turret *turret_osd = &inOSD->osd.turret_osd; - + sprintf(outName, "%s_%d", turret_osd->turret_class_name, turret_osd->id); } @@ -453,7 +453,7 @@ static void OBJiTurret_GetOSD( const OBJtObject *inObject, OBJtOSD_All *outOSD ) OBJtOSD_Turret *Turret_osd; Turret_osd = (OBJtOSD_Turret*)inObject->object_data; - + outOSD->osd.turret_osd = *Turret_osd; } @@ -470,14 +470,14 @@ static UUtBool OBJiTurret_IntersectsLine( const OBJtObject *inObject, const M3tP if( !turret_osd->turret_class ) return UUcFalse; - + // get the bounding sphere OBJiTurret_GetBoundingSphere(inObject, &sphere); - + sphere.center.x += inObject->position.x; sphere.center.y += inObject->position.y; sphere.center.z += inObject->position.z; - + // do the fast test to see if the line is colliding with the bounding sphere result = CLrSphere_Line(inStartPoint, inEndPoint, &sphere); //if (result == UUcTrue) @@ -486,13 +486,13 @@ static UUtBool OBJiTurret_IntersectsLine( const OBJtObject *inObject, const M3tP M3tPoint3D end_point; M3tMatrix4x3 inverse_matrix; M3tVector3D neg_position; - + result = UUcFalse; - + // because the line collided with the bounding sphere, test to see if the line // collides with the bounding box of the geometries - - // move + + // move MUrMatrix_Inverse(&turret_osd->rotation_matrix, &inverse_matrix); neg_position = inObject->position; MUmVector_Negate(neg_position); @@ -503,7 +503,7 @@ static UUtBool OBJiTurret_IntersectsLine( const OBJtObject *inObject, const M3tP // base - { + { result = CLrBox_Line( &turret_osd->turret_class->base_geometry->pointArray->minmax_boundingBox, &start_point, &end_point ); if (result) return UUcTrue; } @@ -530,10 +530,10 @@ static UUtBool OBJiTurret_IntersectsLine( const OBJtObject *inObject, const M3tP { result = CLrBox_Line( &turret_osd->turret_class->barrel_geometry->pointArray->minmax_boundingBox, &start_point, &end_point ); if (result) return UUcTrue; - } + } return result; } - + return UUcFalse; } @@ -547,7 +547,7 @@ static UUtError OBJiTurret_SetDefaults(OBJtOSD_All *outOSD) // clear the osd UUrMemory_Clear(&outOSD->osd.turret_osd, sizeof(OBJtOSD_Turret)); - + // setup default properties outOSD->osd.turret_osd.id = ONrMechanics_GetNextID( OBJcType_Turret ); outOSD->osd.turret_osd.target_teams = 1; // team 0 @@ -557,15 +557,15 @@ static UUtError OBJiTurret_SetDefaults(OBJtOSD_All *outOSD) outOSD->osd.turret_osd.flags = OBJcTurretFlag_None; outOSD->osd.turret_osd.state = OBJcTurretState_Inactive; outOSD->osd.turret_osd.playing_sound = SScInvalidID; - + // get a list of instances of the class error = TMrInstance_GetDataPtr_List( OBJcTemplate_TurretClass, OBJcMaxInstances, &num_instances, instances); UUmError_ReturnOnError(error); - // copy the name of the first turret instance into the osd_all. + // copy the name of the first turret instance into the osd_all. instance_name = TMrInstance_GetInstanceName(instances[0]); instance_name = (instance_name != NULL) ? instance_name : ""; - + UUrString_Copy( outOSD->osd.turret_osd.turret_class_name, (instance_name ), OBJcMaxNameLength); @@ -578,7 +578,7 @@ static UUtError OBJiTurret_New( OBJtObject *inObject, const OBJtOSD_All *inOSD) OBJtOSD_All osd_all; UUtError error; - + if (inOSD == NULL) { error = OBJiTurret_SetDefaults(&osd_all); @@ -598,7 +598,7 @@ static UUtError OBJiTurret_New( OBJtObject *inObject, const OBJtOSD_All *inOSD) // set the object specific data and position error = OBJiTurret_SetOSD(inObject, &osd_all); UUmError_ReturnOnError(error); - + OBJiTurret_UpdatePosition(inObject); UUrMemory_Block_VerifyList(); @@ -643,10 +643,10 @@ static UUtUns32 OBJiTurret_Read( OBJtObject *inObject, UUtUns16 inVersion, UUtBo osd->flags &= OBJcTurretFlag_Persist; - num_bytes = OBJcMaxNameLength + - sizeof(UUtUns16) + - sizeof(UUtUns16) + - sizeof(UUtUns32) + + num_bytes = OBJcMaxNameLength + + sizeof(UUtUns16) + + sizeof(UUtUns16) + + sizeof(UUtUns32) + ( sizeof( float ) * 8 ) + sizeof(UUtUns32); @@ -654,13 +654,13 @@ static UUtUns32 OBJiTurret_Read( OBJtObject *inObject, UUtUns16 inVersion, UUtBo // bring the object up to date OBJiTurret_SetOSD(inObject, &osd_all); - + return num_bytes; } // ---------------------------------------------------------------------- static UUtError OBJiTurret_Write( OBJtObject *inObject, UUtUns8 *ioBuffer, UUtUns32 *ioBufferSize) { - + OBJtOSD_Turret *turret_osd; UUtUns32 bytes_available; @@ -677,7 +677,7 @@ static UUtError OBJiTurret_Write( OBJtObject *inObject, UUtUns8 *ioBuffer, UUtUn // get a pointer to the object osd turret_osd = (OBJtOSD_Turret*)inObject->object_data; - + // set the number of bytes available bytes_available = *ioBufferSize; @@ -697,7 +697,7 @@ static UUtError OBJiTurret_Write( OBJtObject *inObject, UUtUns8 *ioBuffer, UUtUn // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = *ioBufferSize - bytes_available; - + return UUcError_None; } @@ -705,14 +705,14 @@ static UUtError OBJiTurret_Write( OBJtObject *inObject, UUtUns8 *ioBuffer, UUtUn static UUtUns32 OBJiTurret_GetOSDWriteSize( const OBJtObject *inObject ) { UUtUns32 size; - - size = OBJcMaxNameLength + - sizeof(UUtUns16) + - sizeof(UUtUns16) + - sizeof(UUtUns32) + + + size = OBJcMaxNameLength + + sizeof(UUtUns16) + + sizeof(UUtUns16) + + sizeof(UUtUns32) + ( sizeof( float ) * 8 ) + sizeof(UUtUns32); - + return size; } @@ -723,7 +723,7 @@ static void OBJiTurret_FindParticleClasses(OBJtTurretClass *inTurret) UUtUns16 itr; OBJtTurretParticleAttachment *attachment; - for (itr = 0, attachment = inTurret->attachment; itr < inTurret->attachment_count; itr++, attachment++) + for (itr = 0, attachment = inTurret->attachment; itr < inTurret->attachment_count; itr++, attachment++) { attachment->particle_class = P3rGetParticleClass(attachment->particle_class_name); } @@ -752,9 +752,9 @@ static UUtError OBJiTurret_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inOS UUtError error; OBJtTurretClass *turret_class; OBJtOSD_Turret *turret_osd; - + UUmAssert(inOSD); - + OBJiTurret_Shutdown( inObject ); // get a pointer to the object osd @@ -767,7 +767,7 @@ static UUtError OBJiTurret_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inOS turret_osd->id = inOSD->osd.turret_osd.id; turret_osd->flags = (turret_osd->flags & ~OBJcTurretFlag_Persist) | (inOSD->osd.turret_osd.flags & OBJcTurretFlag_Persist); turret_osd->target_teams = inOSD->osd.turret_osd.target_teams; - + error = TMrInstance_GetDataPtr( OBJcTemplate_TurretClass, turret_osd->turret_class_name, &turret_class ); if( error != UUcError_None ) { @@ -782,14 +782,14 @@ static UUtError OBJiTurret_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inOS } - turret_osd->turret_class = turret_class; + turret_osd->turret_class = turret_class; // setup internals MUrMatrix_Identity(&turret_osd->matrix); MUrMatrix_Identity(&turret_osd->turret_matrix); MUrMatrix_Identity(&turret_osd->barrel_matrix); turret_osd->notvisible_time = 0; - + if( ONgLevel ) { OBJrTurret_SetupParticles( inObject ); @@ -801,7 +801,7 @@ static UUtError OBJiTurret_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inOS // create the bounding sphere OBJiTurret_CreateBoundingSphere(inObject, turret_osd); - // set active state + // set active state if( inOSD->osd.turret_osd.state == OBJcTurretState_Active ) OBJrTurret_Activate( inObject ); @@ -813,16 +813,16 @@ static UUtError OBJiTurret_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inOS // ---------------------------------------------------------------------- static void OBJiTurret_UpdatePosition(OBJtObject *inObject) { - + OBJtOSD_Turret *Turret_osd; float rot_x; float rot_y; float rot_z; MUtEuler euler; - + // get a pointer to the object osd Turret_osd = (OBJtOSD_Turret*)inObject->object_data; - + // convert the rotation to radians rot_x = inObject->rotation.x * M3cDegToRad; rot_y = inObject->rotation.y * M3cDegToRad; @@ -857,15 +857,15 @@ static UUtBool OBJiTurret_GetVisible( void) // ---------------------------------------------------------------------- static UUtBool OBJiTurret_Search( const OBJtObject *inObject, const UUtUns32 inSearchType, const OBJtOSD_All *inSearchParams) { - + OBJtOSD_Turret *Turret_osd; UUtBool found; - + // get a pointer to the object osd Turret_osd = (OBJtOSD_Turret*)inObject->object_data; found = UUcFalse; -/* +/* // perform the check switch (inSearchType) { @@ -916,16 +916,16 @@ static void OBJiTurret_CreateParticles( OBJtOSD_Turret *inTurret_osd ) return; // loop through each attachment on the turret template and create a particle for the turret osd - for (itr = 0, attachment = turret->attachment; itr < turret->attachment_count; itr++, attachment++) + for (itr = 0, attachment = turret->attachment; itr < turret->attachment_count; itr++, attachment++) { - if (!attachment->particle_class) + if (!attachment->particle_class) { inTurret_osd->particle[itr] = NULL; continue; } - + particle = P3rCreateParticle(attachment->particle_class, creation_time); - if (particle == NULL) + if (particle == NULL) { inTurret_osd->particle[itr] = NULL; continue; @@ -940,31 +940,31 @@ static void OBJiTurret_CreateParticles( OBJtOSD_Turret *inTurret_osd ) // orientation is the 3x3 matrix part of attachment->matrix p_orientation = P3rGetOrientationPtr(attachment->particle_class, particle); - if (p_orientation != NULL) + if (p_orientation != NULL) { UUrMemory_MoveFast(&attachment->matrix, p_orientation, sizeof(M3tMatrix3x3)); } // velocity and offset are zero if they exist p_velocity = P3rGetVelocityPtr(attachment->particle_class, particle); - if (p_velocity != NULL) + if (p_velocity != NULL) { MUmVector_Set(*p_velocity, 0, 0, 0); } p_offset = P3rGetOffsetPosPtr(attachment->particle_class, particle); - if (p_offset != NULL) + if (p_offset != NULL) { MUmVector_Set(*p_offset, 0, 0, 0); } // dynamic matrix ensures that the particles stay attached to the weapon p_dynamicmatrix = P3rGetDynamicMatrixPtr(attachment->particle_class, particle); - if (p_dynamicmatrix != NULL) + if (p_dynamicmatrix != NULL) { *p_dynamicmatrix = &inTurret_osd->projectile_matrix; particle->header.flags |= P3cParticleFlag_AlwaysUpdatePosition; - } - else + } + else { COrConsole_Printf("### particle class '%s' attached to turret but no dynamic matrix", attachment->particle_class_name); } @@ -972,21 +972,21 @@ static void OBJiTurret_CreateParticles( OBJtOSD_Turret *inTurret_osd ) // the particle's owner is our owner pointer. note that since our owner may change // the particles need to refer to our pointer rather than taking a copy of it p_owner = P3rGetOwnerPtr(attachment->particle_class, particle); - if (p_owner != NULL) + if (p_owner != NULL) { *p_owner = WPrOwner_MakeFromTurret(inTurret_osd); } // randomise texture start index p_texture = P3rGetTextureIndexPtr(attachment->particle_class, particle); - if (p_texture != NULL) + if (p_texture != NULL) { *p_texture = (UUtUns32) UUrLocalRandom(); } // set texture time index to be now p_texture = P3rGetTextureTimePtr(attachment->particle_class, particle); - if (p_texture != NULL) + if (p_texture != NULL) { *p_texture = creation_time; } @@ -1039,7 +1039,7 @@ static void OBJiTurret_SendParticleEvent( OBJtObject *inObject, UUtUns16 inEvent if( !turret_osd->turret_class ) return; - for (itr = 0, attachment = turret_osd->turret_class->attachment; itr < turret_osd->turret_class->attachment_count; itr++, attachment++) + for (itr = 0, attachment = turret_osd->turret_class->attachment; itr < turret_osd->turret_class->attachment_count; itr++, attachment++) { // only send the event to attachments with the correct shooter index - this // check is bypassed if either index is -1, which matches everything @@ -1048,7 +1048,7 @@ static void OBJiTurret_SendParticleEvent( OBJtObject *inObject, UUtUns16 inEvent particle = turret_osd->particle[itr]; - if ((particle == NULL) || (particle->header.self_ref != turret_osd->particle_ref[itr])) + if ((particle == NULL) || (particle->header.self_ref != turret_osd->particle_ref[itr])) { // this particle has died! turret_osd->particle[itr] = NULL; @@ -1060,7 +1060,7 @@ static void OBJiTurret_SendParticleEvent( OBJtObject *inObject, UUtUns16 inEvent { // we must set up this particle's velocity as equal to the owner's so that emitters which are tagged as "emit parent's velocity" have something to use p_velocity = P3rGetVelocityPtr(attachment->particle_class, particle); - if (p_velocity != NULL) + if (p_velocity != NULL) { p_velocity->x = 0; p_velocity->y = 0; @@ -1090,17 +1090,17 @@ UUtBool OBJiTurret_FireProjectile( OBJtObject *inObject, UUtUns16 shooter_index if( !turret_osd->turret_class ) return UUcFalse; - + // only active turrets should be firing! UUmAssert(turret_osd->state == OBJcTurretState_Active ); UUmAssert((shooter_index >= 0) && (shooter_index < turret_osd->turret_class->shooter_count)); - + // wait for chamber delay if (turret_osd->chamber_time) return UUcFalse; // find the shooter's attachment - for (attachment_index = 0, shooter = turret_osd->turret_class->attachment; attachment_index < turret_osd->turret_class->attachment_count; attachment_index++, shooter++) + for (attachment_index = 0, shooter = turret_osd->turret_class->attachment; attachment_index < turret_osd->turret_class->attachment_count; attachment_index++, shooter++) { if( shooter->shooter_index == shooter_index ) break; @@ -1111,7 +1111,7 @@ UUtBool OBJiTurret_FireProjectile( OBJtObject *inObject, UUtUns16 shooter_index return UUcFalse; // we will now fire. - if((turret_osd->flags & OBJcTurretFlag_IsFiring) == 0) + if((turret_osd->flags & OBJcTurretFlag_IsFiring) == 0) { turret_osd->flags |= OBJcTurretFlag_IsFiring; OBJiTurret_SendParticleEvent(inObject, P3cEvent_Start, shooter_index); @@ -1135,7 +1135,7 @@ void OBJrTurret_RecreateParticles(void) OBJrObjectType_GetObjectList( OBJcType_Turret, &object_list, &object_count ); - for(i = 0; i < object_count; i++) + for(i = 0; i < object_count; i++) { object = object_list[i]; UUmAssert( object ); @@ -1164,8 +1164,8 @@ UUtError OBJrTurret_DestroyParticles( OBJtObject *inObject ) if( !turret ) return UUcError_None; - - for (itr = 0; itr < turret->attachment_count; itr++ ) + + for (itr = 0; itr < turret->attachment_count; itr++ ) { if( !turret_osd->particle[itr] ) continue; @@ -1191,7 +1191,7 @@ UUtError OBJrTurret_SetupParticles( OBJtObject *inObject ) OBJiTurret_FindParticleClasses( turret_osd->turret_class ); OBJiTurret_CreateParticles( turret_osd ); - + // FIXME: make sure weapons cant fire for a second..... (particles crash otherwise!) turret_osd->chamber_time = 60; @@ -1242,7 +1242,7 @@ void OBJrTurret_Deactivate( OBJtObject *inObject ) // end the combat AI OBJiTurretCombat_Exit((OBJtObject*) inObject); - if( turret_osd->flags & OBJcTurretFlag_IsFiring ) + if( turret_osd->flags & OBJcTurretFlag_IsFiring ) { turret_osd->flags |= ~OBJcTurretFlag_IsFiring; OBJiTurret_SendParticleEvent( inObject, P3cEvent_Stop, -1 ); @@ -1265,7 +1265,7 @@ static UUtBool OBJrTurret_Activate_ID_Enum(OBJtObject *inObject, UUtUns32 inUser UUmAssert( inObject->object_type == OBJcType_Turret ); turret_osd = (OBJtOSD_Turret*) inObject->object_data; - + if( inUserData == OBJcTurretSelectAll || turret_osd->id == inUserData ) { OBJrTurret_Activate( (OBJtObject*) inObject ); @@ -1278,7 +1278,7 @@ UUtError OBJrTurret_Activate_ID( UUtUns16 inID ) { if( inID == (UUtUns16) -1 ) inID = OBJcTurretSelectAll; - OBJrObjectType_EnumerateObjects( OBJcType_Turret, OBJrTurret_Activate_ID_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Turret, OBJrTurret_Activate_ID_Enum, (UUtUns32) inID ); return UUcError_None; } @@ -1302,7 +1302,7 @@ UUtError OBJrTurret_Deactivate_ID( UUtUns16 inID ) { if( inID == (UUtUns16) -1 ) inID = OBJcTurretSelectAll; - OBJrObjectType_EnumerateObjects( OBJcType_Turret, OBJrTurret_Deactivate_ID_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Turret, OBJrTurret_Deactivate_ID_Enum, (UUtUns32) inID ); return UUcError_None; } @@ -1326,7 +1326,7 @@ UUtError OBJrTurret_Reset_ID( UUtUns16 inID ) { if( inID == (UUtUns16) -1 ) inID = OBJcTurretSelectAll; - OBJrObjectType_EnumerateObjects( OBJcType_Turret, OBJrTurret_Reset_ID_Enum, (UUtUns32) inID ); + OBJrObjectType_EnumerateObjects( OBJcType_Turret, OBJrTurret_Reset_ID_Enum, (UUtUns32) inID ); return UUcError_None; } @@ -1350,7 +1350,7 @@ void OBJiTurretCombat_Enter(OBJtObject *ioObject) // set up our targeting targeting_owner.type = AI2cTargetingOwnerType_Turret; targeting_owner.owner.turret = ioObject; - + // init the targeting AI2rTargeting_Initialize(targeting_owner, &turret_osd->targeting, &OBJgTurret_TargetingCallbacks, &turret_osd->turret_class->ai_params, &turret_osd->projectile_matrix, &turret_osd->turret_class->targeting_params, &turret_osd->turret_class->shooting_skill); } @@ -1361,7 +1361,7 @@ void OBJiTurretCombat_Enter(OBJtObject *ioObject) static UUtBool OBJrTurret_PerformLOS(OBJtObject *inObject) { OBJtOSD_Turret *turret_osd; - + UUmAssert( inObject->object_type == OBJcType_Turret ); @@ -1370,7 +1370,7 @@ static UUtBool OBJrTurret_PerformLOS(OBJtObject *inObject) if( !turret_osd->turret_class ) return UUcFalse; -/* if(turret_osd->targeting.miss_enable) +/* if(turret_osd->targeting.miss_enable) { // we don't care about LOS for the time being return UUcFalse; @@ -1434,7 +1434,7 @@ static ONtCharacter* OBJiTurretCombat_FindClosestTarget( OBJtObject *ioObject ) for( i = 0; i < character_count; i++ ) { character = character_list[i]; - + team_mask = 1 << character->teamNumber; if(!(turret_osd->target_teams & team_mask)) @@ -1463,11 +1463,11 @@ static UUtBool OBJiTurretCombat_CheckTarget(OBJtObject *ioObject) { target_currently_dead = (UUtBool) (turret_osd->targeting.target->flags & ONcCharacterFlag_Dead); } - + turret_osd->check_target_time = (UUtUns32) ( UUcFramesPerSecond / 4.0 ); turret_osd->targeting.target = OBJiTurretCombat_FindClosestTarget( ioObject ); - + return ( turret_osd->targeting.target != NULL ); } @@ -1524,7 +1524,7 @@ void OBJiTurretCombat_Update(OBJtObject *ioObject) current_time = ONrGameState_GetGameTime(); this_turret_has_a_target = (turret_osd->targeting.target != NULL) ? UUcTrue : UUcFalse; - + if( turret_osd->check_target_time ) { turret_osd->check_target_time--; } @@ -1563,7 +1563,7 @@ void OBJiTurretCombat_Exit(OBJtObject *ioObject) UUmAssert(ioObject->object_data); turret_osd = (OBJtOSD_Turret*) ioObject->object_data; - + turret_osd->targeting.target = NULL; AI2rTargeting_Terminate(&turret_osd->targeting); @@ -1595,7 +1595,7 @@ static void OBJiTurret_TargetingCallback_GetPosition(AI2tTargetingState *inTarge OBJtObject* object; UUmAssert(inTargetingState->owner.type == AI2cTargetingOwnerType_Turret); - + object = (OBJtObject*) inTargetingState->owner.owner.turret; UUmAssert(object->object_type == OBJcType_Turret); @@ -1640,7 +1640,7 @@ static void OBJiTurret_TargetingCallback_AimVector(AI2tTargetingState *inTargeti OBJtObject* object; UUmAssert(inTargetingState->owner.type == AI2cTargetingOwnerType_Turret); - + object = (OBJtObject*) inTargetingState->owner.owner.turret; UUmAssert(object->object_type == OBJcType_Turret); @@ -1700,7 +1700,7 @@ void OBJrTurretDisplayDebuggingInfo(OBJtObject *inObject) laserTo.x = 0; laserTo.y = 0; laserTo.z = dist; - + MUrPoint_RotateXAxis( &laserTo, turret_osd->vert_angle , &laserTo ); MUrPoint_RotateYAxis( &laserTo, turret_osd->horiz_angle , &laserTo ); @@ -1712,7 +1712,7 @@ void OBJrTurretDisplayDebuggingInfo(OBJtObject *inObject) } #endif // display combat debugging info - if ( targeting_state->last_computation_success) + if ( targeting_state->last_computation_success) { M3tMatrix3x3 shooter_matrix, worldmatrix; M3tPoint3D weapon_dir, shoot_at; @@ -1720,22 +1720,22 @@ void OBJrTurretDisplayDebuggingInfo(OBJtObject *inObject) /* * draw debugging info about our targeting vectors */ - + shade = (targeting_state->last_computed_ontarget) ? IMcShade_Green : IMcShade_Red; MUmVector_Copy(p0, targeting_state->current_aim_pt); MUmVector_Copy(p1, p0); - + p0.x += 3.0f; p1.x -= 3.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_Blue); - + p0.x -= 3.0f; p1.x += 3.0f; p0.y += 3.0f; p1.y -= 3.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_Blue); - + p0.y -= 3.0f; p1.y += 3.0f; p0.z += 3.0f; @@ -1797,38 +1797,38 @@ void OBJrTurretDisplayDebuggingInfo(OBJtObject *inObject) M3rGeom_Line_Light(&p0, &p1, IMcShade_Blue); } } - + if ( (targeting_state->predictionbuf != NULL)) { /* * draw debugging info about our prediction vectors */ - + UUtUns32 itr, sample_trend, sample_vel, sample_now; - UUtUns32 trend_frames, velocity_frames, delay_frames; - + UUtUns32 trend_frames, velocity_frames, delay_frames; + trend_frames = targeting_state->targeting_params->predict_trendframes; velocity_frames = targeting_state->targeting_params->predict_velocityframes; delay_frames = targeting_state->targeting_params->predict_delayframes; - + // draw our prediction buffer for (itr = 0; itr < trend_frames; itr++) { // work out which indices we're using to build the current motion estimate sample_trend = targeting_state->next_sample + UUmMin(targeting_state->num_samples_taken, trend_frames); sample_vel = targeting_state->next_sample + UUmMin(targeting_state->num_samples_taken, velocity_frames); sample_now = targeting_state->next_sample + UUmMin(targeting_state->num_samples_taken, delay_frames); - + // the buffer is predict_trendframes long sample_trend %= trend_frames; sample_vel %= trend_frames; sample_now %= trend_frames; - + if ((targeting_state->num_samples_taken >= trend_frames) || (itr > targeting_state->next_sample)) { MUmVector_Copy(p0, targeting_state->predictionbuf[itr]); MUmVector_Copy(p1, targeting_state->predictionbuf[itr]); p0.y += 5.0f; p1.y -= 5.0f; - + if (itr == sample_now) { shade = IMcShade_Yellow; } else if (itr == sample_vel) { @@ -1838,7 +1838,7 @@ void OBJrTurretDisplayDebuggingInfo(OBJtObject *inObject) } else { shade = IMcShade_White; } - + M3rGeom_Line_Light(&p0, &p1, shade); } } @@ -1847,36 +1847,36 @@ void OBJrTurretDisplayDebuggingInfo(OBJtObject *inObject) // draw our target point MUmVector_Copy(p0, targeting_state->target_pt); MUmVector_Copy(p1, p0); - + p0.x += 3.0f; p1.x -= 3.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_Purple); - + p0.x -= 3.0f; p1.x += 3.0f; p0.y += 3.0f; p1.y -= 3.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_Purple); - + p0.y -= 3.0f; p1.y += 3.0f; p0.z += 3.0f; p1.z -= 3.0f; M3rGeom_Line_Light(&p0, &p1, IMcShade_Purple); } - - if (targeting_state->target != NULL) + + if (targeting_state->target != NULL) { // draw the target's predicted velocity and trend vectors MUmVector_Copy(p0, targeting_state->target->location); p0.y += targeting_state->target->heightThisFrame; - + MUmVector_Add(p1, p0, targeting_state->predicted_trend); M3rGeom_Line_Light(&p0, &p1, IMcShade_LightBlue); - + MUmVector_Add(p1, p0, targeting_state->predicted_velocity); M3rGeom_Line_Light(&p0, &p1, IMcShade_Blue); - + // draw a little tick on the velocity vector MUmVector_ScaleIncrement(p0, targeting_state->current_prediction_accuracy, targeting_state->predicted_velocity); MUmVector_Copy(p1, p0); @@ -1983,7 +1983,7 @@ static void OBJiTurret_Update( OBJtObject *inObject ) } // if we are active... - if( turret_osd->state == OBJcTurretState_Active ) + if( turret_osd->state == OBJcTurretState_Active ) { // check for timeout if (turret_osd->turret_class->timeout && turret_osd->active_time > turret_osd->turret_class->timeout) { @@ -2003,7 +2003,7 @@ static void OBJiTurret_Update( OBJtObject *inObject ) { turret_osd->fire_weapon = UUcFalse; } - + // clip desired angle to limits turret_osd->desired_vert_angle = OBJiTurret_ClipAngle( turret_osd->desired_vert_angle, turret_osd->turret_class->min_vert_angle, turret_osd->turret_class->max_vert_angle ); turret_osd->desired_horiz_angle = OBJiTurret_ClipAngle( turret_osd->desired_horiz_angle, turret_osd->turret_class->min_horiz_angle, turret_osd->turret_class->max_horiz_angle ); @@ -2067,14 +2067,14 @@ UUtError OBJrTurret_Initialize(void) UUtError error; OBJtMethods methods; ONtMechanicsMethods mechanics_methods; - + // intialize the globals OBJgTurret_DrawTurretDebugInfo = UUcFalse; OBJgTurret_DrawTurrets = UUcTrue; // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiTurret_New; methods.rSetDefaults = OBJiTurret_SetDefaults; @@ -2090,12 +2090,12 @@ UUtError OBJrTurret_Initialize(void) methods.rSetOSD = OBJiTurret_SetOSD; methods.rRead = OBJiTurret_Read; methods.rWrite = OBJiTurret_Write; - + // set up the type methods methods.rGetClassVisible = OBJiTurret_GetVisible; methods.rSetClassVisible = OBJiTurret_SetVisible; methods.rSearch = OBJiTurret_Search; - + // set up the mechanics methods mechanics_methods.rInitialize = OBJiTurret_LevelBegin; mechanics_methods.rTerminate = OBJiTurret_LevelEnd; @@ -2107,11 +2107,11 @@ UUtError OBJrTurret_Initialize(void) mechanics_methods.rClassLevelEnd = NULL; mechanics_methods.rClassReset = NULL; mechanics_methods.rClassUpdate = NULL; - + // register the methods error = ONrMechanics_Register( OBJcType_Turret, OBJcTypeIndex_Turret, "Turret", sizeof(OBJtOSD_Turret), &methods, 0, &mechanics_methods ); UUmError_ReturnOnError(error); - + #if CONSOLE_DEBUGGING_COMMANDS // register the id set function error = SLrGlobalVariable_Register_Bool( "turret_show_debug", "Enables the display of turret debug lines", &OBJgTurret_DrawTurretDebugInfo); @@ -2121,7 +2121,7 @@ UUtError OBJrTurret_Initialize(void) error = SLrGlobalVariable_Register_Bool( "show_turrets", "Enables the display of turrets", &OBJgTurret_DrawTurrets); UUmError_ReturnOnError(error); #endif - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Object/object_types/OT_Weapon.c b/OniProj/OniGameSource/Oni_Object/object_types/OT_Weapon.c index ee686ab..48688ed 100644 --- a/OniProj/OniGameSource/Oni_Object/object_types/OT_Weapon.c +++ b/OniProj/OniGameSource/Oni_Object/object_types/OT_Weapon.c @@ -25,7 +25,7 @@ static UUtError OBJiWeapon_SetOSD( OBJtObject *inObject, const OBJtOSD_All *inOSD); - + // ====================================================================== // functions // ====================================================================== @@ -35,7 +35,7 @@ OBJiWeapon_Delete( OBJtObject *inObject) { /* OBJtOSD_Weapon *weapon_osd; - + // get a pointer to the object osd weapon_osd = (OBJtOSD_Weapon*)inObject->object_data; if (weapon_osd->weapon) @@ -61,14 +61,14 @@ OBJiWeapon_Draw( M3rMatrixStack_Push(); M3rMatrixStack_ApplyTranslate(inObject->position); M3rGeom_State_Commit(); - + if (weapon_osd->weapon_class) { geometry = weapon_osd->weapon_class->geometry; M3rMinMaxBBox_To_BBox(&geometry->pointArray->minmax_boundingBox, &bBox); M3rBBox_Draw_Line(&bBox, IMcShade_White); } - + #if TOOL_VERSION // draw the bounding box if this is the selected object if ((inDrawFlags & OBJcDrawFlag_Selected) != 0) @@ -79,7 +79,7 @@ OBJiWeapon_Draw( OBJrObjectUtil_DrawRotationRings(inObject, &sphere, inDrawFlags); } #endif - + M3rMatrixStack_Pop(); } @@ -94,7 +94,7 @@ OBJiWeapon_Enumerate( UUtUns32 num_weapon_classes; WPtWeaponClass *weapon_class_list[128]; UUtUns32 i; - + error = TMrInstance_GetDataPtr_List( WPcTemplate_WeaponClass, @@ -102,18 +102,18 @@ OBJiWeapon_Enumerate( &num_weapon_classes, weapon_class_list); UUmError_ReturnOnError(error); - + for (i = 0; i < num_weapon_classes; i++) { UUtBool result; - + result = inEnumCallback( TMrInstance_GetInstanceName(weapon_class_list[i]), inUserData); if (result == UUcFalse) { break; } } - + return UUcError_None; } @@ -124,12 +124,12 @@ OBJiWeapon_GetBoundingSphere( M3tBoundingSphere *outBoundingSphere) { OBJtOSD_Weapon *weapon_osd; - + weapon_osd = (OBJtOSD_Weapon*)inObject->object_data; if (weapon_osd->weapon_class != NULL) { M3tGeometry *geometry; - + geometry = weapon_osd->weapon_class->geometry; *outBoundingSphere = geometry->pointArray->boundingSphere; } @@ -168,7 +168,7 @@ OBJiWeapon_GetOSD( OBJtOSD_Weapon *weapon_osd; weapon_osd = (OBJtOSD_Weapon*)inObject->object_data; - + outOSD->osd.weapon_osd = *weapon_osd; } @@ -179,13 +179,13 @@ OBJiWeapon_GetOSDWriteSize( { UUtUns32 size; OBJtOSD_Weapon *weapon_osd; - + weapon_osd = (OBJtOSD_Weapon*)inObject->object_data; // save the weapon type size = WPcMaxWeaponName; /* weapon class name */ - + return size; } @@ -197,16 +197,16 @@ OBJiWeapon_IntersectsLine( const M3tPoint3D *inEndPoint) { M3tBoundingSphere sphere; - + UUrMemory_Clear(&sphere, sizeof(M3tBoundingSphere)); - + // get the bounding sphere OBJrObject_GetBoundingSphere(inObject, &sphere); - + sphere.center.x += inObject->position.x; sphere.center.y += inObject->position.y; sphere.center.z += inObject->position.z; - + // do the fast test to see if the line is colliding with the bounding sphere return CLrSphere_Line(inStartPoint, inEndPoint, &sphere); } @@ -218,10 +218,10 @@ OBJiWeapon_SetDefaults( { // clear the osd UUrMemory_Clear(&outOSD->osd.weapon_osd, sizeof(OBJtOSD_Weapon)); - + UUrString_Copy(outOSD->osd.weapon_osd.weapon_class_name, "w1_tap", WPcMaxWeaponName); // outOSD->osd.weapon_osd.weapon = NULL; - + return UUcError_None; } @@ -238,15 +238,15 @@ OBJiWeapon_New( { error = OBJiWeapon_SetDefaults(&osd_all); UUmError_ReturnOnError(error); - + // send osd_all to OBJiWeapon_SetOSD() inOSD = &osd_all; } - + // set the object specific data and position OBJiWeapon_SetOSD(inObject, inOSD); OBJrObject_UpdatePosition(inObject); - + return UUcError_None; } @@ -260,20 +260,20 @@ OBJiWeapon_Read( { OBJtOSD_Weapon *weapon_osd; UUtUns32 read_bytes; - + weapon_osd = (OBJtOSD_Weapon*)inObject->object_data; - + read_bytes = 0; - + // read the weapon type UUrString_Copy(weapon_osd->weapon_class_name, (char*)inBuffer, WPcMaxWeaponName); inBuffer += WPcMaxWeaponName; read_bytes += WPcMaxWeaponName; - + // set the osd and update the position OBJiWeapon_SetOSD(inObject, (OBJtOSD_All*)inObject->object_data); OBJrObject_UpdatePosition(inObject); - + return read_bytes; } @@ -286,7 +286,7 @@ OBJiWeapon_SetOSD( OBJtOSD_Weapon *weapon_osd; // WPtWeaponClass *weapon_class; UUtError error; - + weapon_osd = (OBJtOSD_Weapon*)inObject->object_data; /* if (weapon_osd->weapon) { @@ -294,16 +294,16 @@ OBJiWeapon_SetOSD( WPrDelete(weapon_osd->weapon); weapon_osd->weapon = NULL; }*/ - + UUrString_Copy( weapon_osd->weapon_class_name, inOSD->osd.weapon_osd.weapon_class_name, WPcMaxWeaponName); - + error = TMrInstance_GetDataPtr( WPcTemplate_WeaponClass, - weapon_osd->weapon_class_name, + weapon_osd->weapon_class_name, &weapon_osd->weapon_class); UUmError_ReturnOnError(error); @@ -335,19 +335,19 @@ OBJiWeapon_Write( UUtUns32 bytes_available; // WPtWeaponClass *weapon_class; // char *weapon_class_name; - + weapon_osd = (OBJtOSD_Weapon*)inObject->object_data; - + // set the number of bytes available bytes_available = *ioBufferSize; - + // weapon_class = WPrGetClass(weapon_osd->weapon); // weapon_class_name = TMrInstance_GetInstanceName(weapon_class); - + UUrString_Copy((char*)ioBuffer, weapon_osd->weapon_class_name, WPcMaxWeaponName); ioBuffer += WPcMaxWeaponName; bytes_available -= WPcMaxWeaponName; - + // set ioBufferSize to the number of bytes written to the buffer *ioBufferSize = *ioBufferSize - bytes_available; @@ -397,10 +397,10 @@ OBJrWeapon_Initialize( { UUtError error; OBJtMethods methods; - + // clear the methods structure UUrMemory_Clear(&methods, sizeof(OBJtMethods)); - + // set up the methods structure methods.rNew = OBJiWeapon_New; methods.rSetDefaults = OBJiWeapon_SetDefaults; @@ -420,7 +420,7 @@ OBJrWeapon_Initialize( methods.rGetClassVisible = OBJiWeapon_GetVisible; methods.rSearch = OBJiWeapon_Search; methods.rSetClassVisible = OBJiWeapon_SetVisible; - + // register the furniture methods error = OBJrObjectGroup_Register( @@ -431,6 +431,6 @@ OBJrWeapon_Initialize( &methods, OBJcObjectGroupFlag_None); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_OutGameUI/Oni_OutGameUI.c b/OniProj/OniGameSource/Oni_OutGameUI/Oni_OutGameUI.c index 8917300..6e77c72 100644 --- a/OniProj/OniGameSource/Oni_OutGameUI/Oni_OutGameUI.c +++ b/OniProj/OniGameSource/Oni_OutGameUI/Oni_OutGameUI.c @@ -108,21 +108,21 @@ ONiOGU_ChangeRestart_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_Command: if (UUmHighWord(inParam1) != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, UUmLowWord(inParam1)); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -134,14 +134,14 @@ ONiOutGameUI_ChangeRestart_Display( PStPartSpecUI *partspec_ui; PStPartSpecUI *temp_ui; UUtUns32 message; - + // save the current ui partspec_ui = PSrPartSpecUI_GetActive(); - + // set the ui to the out of game ui temp_ui = PSrPartSpecUI_GetByName(ONcOutGameUIName); if (temp_ui != NULL) { PSrPartSpecUI_SetActive(temp_ui); } - + // display the dialog WMrDialog_ModalBegin( ONcOGU_ChangeRestart, @@ -149,10 +149,10 @@ ONiOutGameUI_ChangeRestart_Display( ONiOGU_ChangeRestart_Callback, 0, &message); - + // reset the active ui PSrPartSpecUI_SetActive(partspec_ui); - + return message; } @@ -170,21 +170,21 @@ ONiOGU_QuitYesNo_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_Command: if (UUmHighWord(inParam1) != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, UUmLowWord(inParam1)); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -196,14 +196,14 @@ ONrOutGameUI_QuitYesNo_Display( PStPartSpecUI *partspec_ui; PStPartSpecUI *temp_ui; UUtUns32 message; - + // save the current ui partspec_ui = PSrPartSpecUI_GetActive(); - + // set the ui to the out of game ui temp_ui = PSrPartSpecUI_GetByName(ONcOutGameUIName); if (temp_ui != NULL) { PSrPartSpecUI_SetActive(temp_ui); } - + // display the dialog WMrDialog_ModalBegin( ONcOGU_QuitYesNoID, @@ -211,10 +211,10 @@ ONrOutGameUI_QuitYesNo_Display( ONiOGU_QuitYesNo_Callback, 0, &message); - + // reset the active ui PSrPartSpecUI_SetActive(partspec_ui); - + return message; } @@ -248,9 +248,9 @@ ONiResolution_Switch( // get a pointer to the current draw engine's caps current_draw_engine_caps = M3rDrawEngine_GetCaps(activeDrawEngine); if (current_draw_engine_caps == NULL) { return; } - + new_resolution = current_draw_engine_caps->displayDevices[activeDevice].displayModes[inMode]; - + restart = UUcFalse; voodoo_fullscreen= gl_voodoo_card_full_screen(); @@ -261,12 +261,12 @@ ONiResolution_Switch( // so we force a restart OSErr err; unsigned long value; - + err= Gestalt(gestaltSystemVersion, &value); if (err == noErr) { unsigned long major_version; - + // value will look like this: 0x00000904 (OS 9.0.4) major_version= (value & 0x0000FF00)>>8; if (major_version >= 10) @@ -300,13 +300,13 @@ ONiResolution_Switch( if (voodoo_fullscreen || s3_crappy_card_fullscreen || osx) { extern void OniExit(void); // Oni.c - + // alert won't be visible afterwards AUrMessageBox(AUcMBType_OK, "You must restart Oni for your changes to take effect; Oni will now exit."); OniExit(); exit(0); } - + if (restart == UUcTrue) { // tell the user they have to restart the game @@ -353,7 +353,7 @@ OWiResolution_Switch( options_y= UUmMax(((new_resolution.height - dialog_height)/2), 0); // center main menu in main window - if ((main_game_menu != NULL) && + if ((main_game_menu != NULL) && WMrWindow_GetSize(main_game_menu, &main_menu_width, &main_menu_height)) { @@ -397,30 +397,30 @@ ONiResolutions_AddToPopup( UUtUns16 activeMode; UUtUns16 i; UUtUns16 num_modes; - + // reset the popup WMrPopupMenu_Reset(inPopupMenu); - + // get the index of the active draw engine M3rManager_GetActiveDrawEngine(&activeDrawEngine, &activeDevice, &activeMode); // get a pointer to the current draw engine's caps current_draw_engine_caps = M3rDrawEngine_GetCaps(activeDrawEngine); if (current_draw_engine_caps == NULL) { return; } - + // add a list of all of the available num_modes = current_draw_engine_caps->displayDevices[activeDevice].numDisplayModes; for (i = 0; i < num_modes; i++) { M3tDisplayMode *mode; char title[128]; - + mode = ¤t_draw_engine_caps->displayDevices[activeDevice].displayModes[i]; - + sprintf(title, "%d x %d x %d bit", mode->width, mode->height, mode->bitDepth); WMrPopupMenu_AppendItem_Light(inPopupMenu, i, title); } - + // select the current item WMrPopupMenu_SetSelection(inPopupMenu, activeMode); } @@ -433,7 +433,7 @@ ONiOBU_Options_SetControls( WMtWindow *slider; WMtWindow *popup; WMtWindow *checkbox; - + // set the sliders slider = WMrDialog_GetItemByID(inDialog, ONcOptions_Sldr_Quality); WMrSlider_SetPosition(slider, (UUtInt32)ONrPersist_GetGraphicsQuality()); @@ -442,16 +442,16 @@ ONiOBU_Options_SetControls( if (slider != NULL) { WMrSlider_SetPosition(slider, MUrFloat_Round_To_Int(100 * ONrPersist_GetGamma())); } - + slider = WMrDialog_GetItemByID(inDialog, ONcOptions_Sldr_OverallVol); WMrSlider_SetPosition(slider, (UUtInt32)(ONrPersist_GetOverallVolume() * 100.0f)); - + // slider = WMrDialog_GetItemByID(inDialog, ONcOptions_Sldr_DialogVol); // WMrSlider_SetPosition(slider, (UUtInt32)(ONrPersist_GetDialogVolume() * 100.0f)); - + // slider = WMrDialog_GetItemByID(inDialog, ONcOptions_Sldr_MusicVol); // WMrSlider_SetPosition(slider, (UUtInt32)(ONrPersist_GetMusicVolume() * 100.0f)); - + // set the checkbox // checkbox = WMrDialog_GetItemByID(inDialog, ONcOptions_CB_DialogOn); // WMrCheckBox_SetCheck(checkbox, ONrPersist_IsDialogOn()); @@ -461,10 +461,10 @@ ONiOBU_Options_SetControls( checkbox = WMrDialog_GetItemByID(inDialog, ONcOptions_CB_SubtitlesOn); WMrCheckBox_SetCheck(checkbox, ONrPersist_AreSubtitlesOn()); - + checkbox = WMrDialog_GetItemByID(inDialog, ONcOptions_CB_InvertMouseOn); WMrCheckBox_SetCheck(checkbox, ONrPersist_IsInvertMouseOn()); - + // set the popup menu popup = WMrDialog_GetItemByID(inDialog, ONcOptions_PM_Difficulty); WMrPopupMenu_SetSelection(popup, (UUtInt16)ONrPersist_GetDifficulty()); @@ -477,7 +477,7 @@ ONiOGU_Options_InitDialog( { WMtWindow *slider; WMtWindow *popup; - + // set the range on the sliders slider = WMrDialog_GetItemByID(inDialog, ONcOptions_Sldr_Quality); WMrSlider_SetRange( @@ -489,20 +489,20 @@ ONiOGU_Options_InitDialog( if (slider != NULL) { WMrSlider_SetRange(slider, 0, 100); } - + slider = WMrDialog_GetItemByID(inDialog, ONcOptions_Sldr_OverallVol); WMrSlider_SetRange(slider, 0, 100); - + // slider = WMrDialog_GetItemByID(inDialog, ONcOptions_Sldr_DialogVol); // WMrSlider_SetRange(slider, 0, 100); - + // slider = WMrDialog_GetItemByID(inDialog, ONcOptions_Sldr_MusicVol); // WMrSlider_SetRange(slider, 0, 100); - + // build the popup menu popup = WMrDialog_GetItemByID(inDialog, ONcOptions_PM_Resolution); ONiResolutions_AddToPopup(popup); - + // set the fields ONiOBU_Options_SetControls(inDialog); } @@ -517,10 +517,10 @@ ONiOGU_Options_HandleCommand( UUtUns16 control_id; UUtUns16 command_type; float volume; - + control_id = UUmLowWord(inParam1); command_type = UUmHighWord(inParam1); - + switch (control_id) { case ONcOptions_Sldr_Gamma: @@ -536,45 +536,45 @@ ONiOGU_Options_HandleCommand( if (command_type == SLcNotify_NewPosition) { ONtGraphicsQuality quality; - + quality = (ONtGraphicsQuality)WMrSlider_GetPosition(inControl); ONrPersist_SetGraphicsQuality(quality); } break; - + case ONcOptions_Sldr_OverallVol: if (command_type != SLcNotify_NewPosition) { break; } volume = ((float)WMrSlider_GetPosition(inControl)) / 100.0f; ONrPersist_SetOverallVolume(volume); break; - + /* case ONcOptions_CB_DialogOn: if (command_type != WMcNotify_Click) { break; } ONrPersist_SetDialogOn(WMrCheckBox_GetCheck(inControl)); break; - + case ONcOptions_Sldr_DialogVol: if (command_type != SLcNotify_NewPosition) { break; } volume = ((float)WMrSlider_GetPosition(inControl)) / 100.0f; ONrPersist_SetDialogVolume(volume); break; - + case ONcOptions_CB_MusicOn: if (command_type != WMcNotify_Click) { break; } ONrPersist_SetMusicOn(WMrCheckBox_GetCheck(inControl)); break; - + case ONcOptions_Sldr_MusicVol: if (command_type != SLcNotify_NewPosition) { break; } volume = ((float)WMrSlider_GetPosition(inControl)) / 100.0f; ONrPersist_SetMusicVolume(volume); break;*/ - + case ONcOptions_CB_SubtitlesOn: if (command_type != WMcNotify_Click) { break; } ONrPersist_SetSubtitlesOn(WMrCheckBox_GetCheck(inControl)); break; - + case ONcOptions_CB_InvertMouseOn: if (command_type != WMcNotify_Click) { break; } ONrPersist_SetInvertMouseOn(WMrCheckBox_GetCheck(inControl)); @@ -595,15 +595,15 @@ ONiOGU_Options_HandleMenuCommand( WMtWindow *inMenu) { UUtUns16 item_id; - + item_id = UUmLowWord(inParam1); - + switch (WMrWindow_GetID(inMenu)) { case ONcOptions_PM_Resolution: ONiResolution_Switch(inDialog, inMenu, item_id); break; - + case ONcOptions_PM_Difficulty: ONrPersist_SetDifficulty((ONtDifficultyLevel)item_id); break; @@ -619,28 +619,28 @@ ONiOGU_Options_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: ONiOGU_Options_InitDialog(inDialog); break; - + case WMcMessage_Command: ONiOGU_Options_HandleCommand(inDialog, inParam1, (WMtWindow*)inParam2); break; - + case WMcMessage_MenuCommand: ONiOGU_Options_HandleMenuCommand(inDialog, inParam1, (WMtWindow*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -656,7 +656,7 @@ ONrOutGameUI_Options_Display( // save the current ui partspec_ui = PSrPartSpecUI_GetActive(); - + // set the ui to the out of game ui temp_ui = PSrPartSpecUI_GetByName(ONcOutGameUIName); if (temp_ui != NULL) { PSrPartSpecUI_SetActive(temp_ui); } @@ -675,10 +675,10 @@ ONrOutGameUI_Options_Display( ONiOGU_Options_Callback, 0, &message); - + // reset the active ui PSrPartSpecUI_SetActive(partspec_ui); - + return message; } @@ -706,10 +706,10 @@ ONiOGU_LoadGame_HandleCommand( UUtUns16 control_id; UUtUns16 command_type; UUtUns32 level; - + control_id = UUmLowWord(inParam1); command_type = UUmHighWord(inParam1); - + switch (control_id) { case ONcLoadGame_LB_Levels: @@ -720,7 +720,7 @@ ONiOGU_LoadGame_HandleCommand( WMrDialog_ModalEnd(inDialog, level); } break; - + case ONcLoadGame_Btn_Load: if (command_type != WMcNotify_Click) { break; } level = OWrLevelList_GetLevelNumber(inDialog, ONcLoadGame_LB_Levels); @@ -729,7 +729,7 @@ ONiOGU_LoadGame_HandleCommand( WMrDialog_ModalEnd(inDialog, level); } break; - + case ONcLoadGame_Btn_Cancel: if (command_type != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, 0); @@ -746,24 +746,24 @@ ONiOGU_LoadGame_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: ONiOGU_LoadGame_InitDialog(inDialog); break; - + case WMcMessage_Command: ONiOGU_LoadGame_HandleCommand(inDialog, inParam1, (WMtWindow*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -775,14 +775,14 @@ ONrOutGameUI_LoadGame_Display( PStPartSpecUI *partspec_ui; PStPartSpecUI *temp_ui; UUtUns32 message; - + // save the current ui partspec_ui = PSrPartSpecUI_GetActive(); - + // set the ui to the out of game ui temp_ui = PSrPartSpecUI_GetByName(ONcOutGameUIName); if (temp_ui != NULL) { PSrPartSpecUI_SetActive(temp_ui); } - + // display the dialog WMrDialog_ModalBegin( ONcOGU_LoadGameID, @@ -790,10 +790,10 @@ ONrOutGameUI_LoadGame_Display( ONiOGU_LoadGame_Callback, 0, &message); - + // reset the active ui PSrPartSpecUI_SetActive(partspec_ui); - + return message; } @@ -811,21 +811,21 @@ ONiOGU_NewGame_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_Command: if (UUmHighWord(inParam1) != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, UUmLowWord(inParam1)); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -837,14 +837,14 @@ ONrOutGameUI_NewGame_Display( PStPartSpecUI *partspec_ui; PStPartSpecUI *temp_ui; UUtUns32 message; - + // save the current ui partspec_ui = PSrPartSpecUI_GetActive(); - + // set the ui to the out of game ui temp_ui = PSrPartSpecUI_GetByName(ONcOutGameUIName); if (temp_ui != NULL) { PSrPartSpecUI_SetActive(temp_ui); } - + // display the dialog WMrDialog_ModalBegin( ONcOGU_NewGameID, @@ -852,10 +852,10 @@ ONrOutGameUI_NewGame_Display( ONiOGU_NewGame_Callback, 0, &message); - + // reset the active ui PSrPartSpecUI_SetActive(partspec_ui); - + return message; } @@ -875,13 +875,13 @@ ONiOGU_MainMenu_FadeMusic( M3tPoint3D position; M3tVector3D facing; UUtUns32 count; - + MUmVector_Set(position, 0.0f, 0.0f, 0.0f); MUmVector_Set(facing, 0.0f, 0.0f, 0.0f); - + OSrMusic_SetVolume(0.0f, OScMainMusic_FadeOutTime); OSrMusic_Stop(); - + count = UUrMachineTime_Sixtieths() + (UUtUns32)(60.0f * OScMainMusic_FadeOutTime); do { @@ -889,11 +889,11 @@ ONiOGU_MainMenu_FadeMusic( SS2rUpdate(); } while (count > UUrMachineTime_Sixtieths()); - + OSrMusic_Halt(); } } - + // ---------------------------------------------------------------------- static void ONiOGU_MainMenu_InitDialog( @@ -901,10 +901,10 @@ ONiOGU_MainMenu_InitDialog( { WMtWindow *options; WMtWindow *resume; - + options = WMrDialog_GetItemByID(inDialog, ONcMainMenu_Btn_Options); resume = WMrDialog_GetItemByID(inDialog, ONcMainMenu_Btn_Resume); - + if (ONrLevel_GetCurrentLevel() > 0) { WMrWindow_SetVisible(options, UUcFalse); @@ -915,11 +915,11 @@ ONiOGU_MainMenu_InitDialog( WMrWindow_SetVisible(options, UUcTrue); WMrWindow_SetVisible(resume, UUcFalse); } - + // stop all currently playing sounds, only allow music OSrSetScriptOnly(UUcTrue); SSrPlayingChannels_Pause(); - + OSrMusic_Start(OScMusicScore_Win, 0.0f); OSrMusic_SetVolume(1.0f, OScMainMusic_FadeInTime); } @@ -934,7 +934,7 @@ ONiOGU_MainMenu_Destroy( OSrMusic_SetVolume(0.0f, 0.5f); OSrMusic_Stop(); } - + // allow more than just music OSrSetScriptOnly(UUcFalse); SSrPlayingChannels_Resume(); @@ -946,21 +946,21 @@ ONiOGU_MainMenu_HandleNewGame( WMtDialog *inDialog) { UUtUns32 result; - + // display the new game dialog result = ONrOutGameUI_NewGame_Display(); if (result == ONcNewGame_Btn_Yes) { // fade out the music first ONiOGU_MainMenu_FadeMusic(); - + // if the user selects start, then close the main menu WMrDialog_ModalEnd(inDialog, 0); // update the screen WMrUpdate(); WMrDisplay(); - + // load the level OWrLevelLoad_StartLevel(1); } @@ -972,21 +972,21 @@ ONiOGU_MainMenu_HandleLoadGame( WMtDialog *inDialog) { UUtUns16 result; - + // display the load game dialog result = (UUtUns16)ONrOutGameUI_LoadGame_Display(); if (result != 0) { // fade out the music first ONiOGU_MainMenu_FadeMusic(); - + // if the user selects load, then close the main menu WMrDialog_ModalEnd(inDialog, 0); // update the screen WMrUpdate(); WMrDisplay(); - + // load the level OWrLevelLoad_StartLevel(result); } @@ -1006,7 +1006,7 @@ ONiOGU_MainMenu_HandleQuit( WMtDialog *inDialog) { UUtUns32 result; - + // display the Are you sure you want to quit dialog result = ONrOutGameUI_QuitYesNo_Display(); if (result == ONcQuitYesNo_Btn_Yes) @@ -1016,7 +1016,7 @@ ONiOGU_MainMenu_HandleQuit( // if the user selects load, then close the main menu WMrDialog_ModalEnd(inDialog, 0); - + WMrMessage_Post(NULL, WMcMessage_Quit, 0, 0); // end the game @@ -1033,10 +1033,10 @@ ONiOGU_MainMenu_HandleCommand( { UUtUns16 control_id; UUtUns16 command_type; - + control_id = UUmLowWord(inParam1); command_type = UUmHighWord(inParam1); - + if (command_type != WMcNotify_Click) { return; } switch (control_id) @@ -1044,23 +1044,23 @@ ONiOGU_MainMenu_HandleCommand( case ONcMainMenu_Btn_NewGame: ONiOGU_MainMenu_HandleNewGame(inDialog); break; - + case ONcMainMenu_Btn_LoadGame: ONiOGU_MainMenu_HandleLoadGame(inDialog); break; - + case ONcMainMenu_Btn_Options: ONiOGU_MainMenu_HandleOptions(inDialog); break; - + case ONcMainMenu_Btn_Quit: ONiOGU_MainMenu_HandleQuit(inDialog); break; - + case ONcMainMenu_Btn_Resume: WMrDialog_ModalEnd(inDialog, 0); break; - + case WMcDialogItem_Cancel: if (ONrLevel_GetCurrentLevel() != 0) { @@ -1079,31 +1079,31 @@ ONiOGU_MainMenu_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: ONiOGU_MainMenu_InitDialog(inDialog); break; - + case WMcMessage_Destroy: ONiOGU_MainMenu_Destroy(inDialog); break; - + case WMcMessage_Command: ONiOGU_MainMenu_HandleCommand( inDialog, inParam1, (WMtWindow*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -1114,17 +1114,17 @@ ONrOutGameUI_MainMenu_Display( { PStPartSpecUI *partspec_ui; PStPartSpecUI *temp_ui; - + // save the current ui partspec_ui = PSrPartSpecUI_GetActive(); - + // set the ui to the out of game ui temp_ui = PSrPartSpecUI_GetByName(ONcOutGameUIName); if (temp_ui != NULL) { PSrPartSpecUI_SetActive(temp_ui); } - + // set the background to black WMrSetDesktopBackground(PSrPartSpec_LoadByType(PScPartSpecType_BackgroundColor_Black)); - + // display the dialog WMrDialog_ModalBegin( ONcOGU_MainMenuID, @@ -1132,12 +1132,12 @@ ONrOutGameUI_MainMenu_Display( ONiOGU_MainMenu_Callback, 0, NULL); - + // set the desktop background to none WMrSetDesktopBackground(PSrPartSpec_LoadByType(PScPartSpecType_BackgroundColor_None)); // reset the active ui PSrPartSpecUI_SetActive(partspec_ui); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_OutGameUI/Oni_OutGameUI.h b/OniProj/OniGameSource/Oni_OutGameUI/Oni_OutGameUI.h index 4fb1479..889f834 100644 --- a/OniProj/OniGameSource/Oni_OutGameUI/Oni_OutGameUI.h +++ b/OniProj/OniGameSource/Oni_OutGameUI/Oni_OutGameUI.h @@ -26,11 +26,11 @@ ONrOutGameUI_MainMenu_Display( UUtUns32 ONrOutGameUI_NewGame_Display( void); - + UUtUns32 ONrOutGameUI_LoadGame_Display( void); - + UUtUns32 ONrOutGameUI_Options_Display( void); @@ -38,6 +38,6 @@ ONrOutGameUI_Options_Display( UUtUns32 ONrOutGameUI_QuitYesNo_Display( void); - + // ====================================================================== -#endif /* ONI_OUTGAMEUI_H */ \ No newline at end of file +#endif /* ONI_OUTGAMEUI_H */ diff --git a/OniProj/OniGameSource/Oni_Particle3.c b/OniProj/OniGameSource/Oni_Particle3.c index 3230083..4d0d031 100644 --- a/OniProj/OniGameSource/Oni_Particle3.c +++ b/OniProj/OniGameSource/Oni_Particle3.c @@ -114,7 +114,7 @@ ONiParticle3_Debug_SpawnParticle( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -123,7 +123,7 @@ ONiParticle3_Debug_KillAllParticles( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -132,7 +132,7 @@ ONiParticle3_Debug_KillNearestParticle( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -141,7 +141,7 @@ ONiParticle3_Debug_Count( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -150,7 +150,7 @@ ONiParticle3_Debug_CallEvent( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -168,7 +168,7 @@ ONiParticle3_Temporary_Start( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -177,7 +177,7 @@ ONiParticle3_Temporary_Stop( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -186,7 +186,7 @@ ONiParticle3_Temporary_Kill( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -195,7 +195,7 @@ ONiParticle3_PrintTags( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -204,7 +204,7 @@ ONiParticle3_RemoveDangerous( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -213,7 +213,7 @@ ONiParticle3_DumpParticles( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); #if TOOL_VERSION @@ -223,7 +223,7 @@ ONiParticle3_ListCollision( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); #endif @@ -233,7 +233,7 @@ ONiParticle3_StartAll( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -242,7 +242,7 @@ ONiParticle3_StopAll( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -251,7 +251,7 @@ ONiParticle3_DaodanShieldDisable( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static UUtError @@ -260,7 +260,7 @@ ONiParticle3_WriteUsedParticles( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); #if PARTICLE_PERF_ENABLE @@ -270,7 +270,7 @@ ONiParticle3_Perf( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); #endif @@ -286,7 +286,7 @@ UUtError ONrParticle3_Initialize(void) P3rRegisterCallbacks(ONiParticle3_CreationCallback, ONiParticle3_DeletionCallback, NULL, ONiParticle3_SettingsCallback); // set up console commands - error = + error = SLrScript_Command_Register_Void( "p3_spawn", "Spawns a new P3 particle", @@ -294,144 +294,144 @@ UUtError ONrParticle3_Initialize(void) ONiParticle3_Debug_SpawnParticle); UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "p3_killall", "Kills all P3 particles", "", ONiParticle3_Debug_KillAllParticles); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "p3_killnearest", "Kills the nearest P3 particle", "[no_recreate:bool | ]", ONiParticle3_Debug_KillNearestParticle); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "p3_count", "Lists a count of P3 particles", "", ONiParticle3_Debug_Count); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "p3_callevent", "Triggers an event on all P3 particles of a specified class", "particle_class:string event_index:int", ONiParticle3_Debug_CallEvent); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "particle_temp_start", "Starts temporary-particle-creation mode", NULL, ONiParticle3_Temporary_Start); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "particle_temp_stop", "Stops temporary-particle-creation mode", NULL, ONiParticle3_Temporary_Stop); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "particle_temp_kill", "Kills any temporary particles", NULL, ONiParticle3_Temporary_Kill); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "particle", "Sends a command to environmental particles with a given tag", NULL, ONiParticle3_Command); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "p3_printtags", "Prints out all environmental particles with tags", "", ONiParticle3_PrintTags); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "p3_removedangerous", "Removes all 'dangerous projectile' particles by making their lifetime expire", "", ONiParticle3_RemoveDangerous); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "p3_dumpparticles", "Dump all particles to a text file", "", ONiParticle3_DumpParticles); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); #if TOOL_VERSION - error = + error = SLrScript_Command_Register_Void( "p3_listcollision", "Dump all particle classes with collision to a text file", "", ONiParticle3_ListCollision); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); #endif - error = + error = SLrScript_Command_Register_Void( "p3_writeusedparticles", "Writes all particles used on this level to a text file", "", ONiParticle3_WriteUsedParticles); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "p3_startall", "Creates and starts all environmental particles", "", ONiParticle3_StartAll); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "p3_stopall", "Stops all environmental particles", "", ONiParticle3_StopAll); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "p3_daodan_disable", "Disables parts of the daodan shield (for debugging)", NULL, ONiParticle3_DaodanShieldDisable); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); #if PARTICLE_PERF_ENABLE - error = + error = SLrScript_Command_Register_Void( "p3_perf", "Toggles particle performance display and sets event masks", NULL, ONiParticle3_Perf); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); #endif error = SLrGlobalVariable_Register_Bool("p3_show_env_collision", "Draws particle / environment collisions.", &P3gDrawEnvCollisions); @@ -469,7 +469,7 @@ void ONrParticle3_LevelZeroLoaded(void) ONgParticle3_DaodanShield = P3rGetParticleClass("daodanshield_e01"); } - + UUtError ONrParticle3_LevelBegin(void) { #if PARTICLE_RECORD @@ -580,7 +580,7 @@ void ONrParticle3_UpdateGraphicsQuality(void) // emit breaking glass from a quad void ONrParticle3_EmitGlassPieces(AKtGQ_General *inQuad, float inDamage, - M3tVector3D *inBlastSource, M3tVector3D *inBlastNormal, + M3tVector3D *inBlastSource, M3tVector3D *inBlastNormal, M3tVector3D *inBlastDir, float inBlastRadius) { M3tQuad *quad; @@ -700,18 +700,18 @@ void ONrParticle3_EmitGlassPieces(AKtGQ_General *inQuad, float inDamage, for (itr = 0; itr < num_shards; itr++) { pos_x = x + P3rRandom(); pos_z = z + P3rRandom(); - + exact_interp = pos_z / cells_z; MUmVector_Copy(emit_point, *points[0]); - + MUmVector_ScaleIncrement(emit_point, pos_z, side_z); MUmVector_ScaleIncrement(emit_point, pos_x * (1.0f - exact_interp), side_x0); MUmVector_ScaleIncrement(emit_point, pos_x * exact_interp, side_x1); ONiParticle3_EmitGlassPiece(&ONgParticle3_GlassShards, &glassdata, - &emit_point, current_time, - inDamage, inBlastSource, inBlastNormal, + &emit_point, current_time, + inDamage, inBlastSource, inBlastNormal, inBlastDir, inBlastRadius); } } @@ -721,7 +721,7 @@ void ONrParticle3_EmitGlassPieces(AKtGQ_General *inQuad, float inDamage, // emit a piece of breaking glass from a quad static void ONiParticle3_EmitGlassPiece(P3tEffectSpecification *inGlassType, ONtGlassData *inGlassData, M3tPoint3D *inPoint, UUtUns32 inTime, - float inDamage, M3tVector3D *inBlastSource, M3tVector3D *inBlastNormal, + float inDamage, M3tVector3D *inBlastSource, M3tVector3D *inBlastNormal, M3tVector3D *inBlastDir, float inBlastRadius) { float velocity_mag, blast_distance, outwards_interp; @@ -845,7 +845,7 @@ UUtBool ONrParticle3_FindBodySurfacePosition(UUtUns32 inCharacterOwner, float in CHECK_PART_FACE(Pos_Y, y, maxPoint, z, x); CHECK_PART_FACE(Neg_Z, z, minPoint, x, y); CHECK_PART_FACE(Pos_Z, z, maxPoint, x, y); - + // should never reach here UUmAssert(0); MUmVector_Set(*outPoint, 0, 0, 0); @@ -898,7 +898,7 @@ UUtBool ONrParticle3_FindBodySurfacePosition(UUtUns32 inCharacterOwner, float in // we are at the precise top of the cap MUmVector_Set(right_vector, 0, 0, x_upvector); } - + MUrVector_CrossProduct(&outward_vector, &right_vector, &up_vector); if (MUrVector_Normalize_ZeroTest(&up_vector)) { // there is a problem building the orientation! @@ -929,7 +929,7 @@ UUtBool ONrParticle3_FindBodySurfacePosition(UUtUns32 inCharacterOwner, float in outPoint->y += inRadius * outward_vector.y; outPoint->z += inRadius * outward_vector.z; - } + } return UUcTrue; } @@ -995,7 +995,7 @@ UUtBool ONrParticle3_FindBodyBonePosition(UUtUns32 inCharacterOwner, float inRad x_min = pos_cap + inRadius; x_max = neg_cap - inRadius; - + } else { x_min = body_part->bbox.minPoint.x; x_max = body_part->bbox.maxPoint.x; @@ -1049,13 +1049,13 @@ static char *ONiParticle3_GetFileName(void) static char buffer[1024]; sprintf(buffer, "%s particles.txt", ONgLevel->name); - + return buffer; } -static void ONiParticle3_Record_CreateParticle(char *inParticleClassString, M3tPoint3D *inLocation, M3tVector3D *inVector, float inVelocity) +static void ONiParticle3_Record_CreateParticle(char *inParticleClassString, M3tPoint3D *inLocation, M3tVector3D *inVector, float inVelocity) { if (NULL == particle_record) { particle_record = fopen(ONiParticle3_GetFileName(), "a+"); @@ -1076,7 +1076,7 @@ static void ONiParticle3_Record_CreateParticle(char *inParticleClassString, M3tP } #endif -static UUtError ONiParticle3_CreateParticle(char *inParticleClassString, M3tPoint3D *inLocation, M3tVector3D *inVector, float inVelocity) +static UUtError ONiParticle3_CreateParticle(char *inParticleClassString, M3tPoint3D *inLocation, M3tVector3D *inVector, float inVelocity) { P3tParticleClass *particle_class; P3tParticle *new_particle; @@ -1089,7 +1089,7 @@ static UUtError ONiParticle3_CreateParticle(char *inParticleClassString, M3tPoin AKtOctNodeIndexCache *p_envcache; UUtUns32 *p_texture, *p_lensframes, current_time; UUtBool is_dead; - + particle_class = P3rGetParticleClass(inParticleClassString); if (particle_class == NULL) { COrConsole_Printf("### unknown particle class '%s'", inParticleClassString); @@ -1185,7 +1185,7 @@ static UUtError ONiParticle3_CreateParticle(char *inParticleClassString, M3tPoin } #if PARTICLE_RECORD -static void ONiParticle3_Record_Kill(void) +static void ONiParticle3_Record_Kill(void) { if (NULL != particle_record) { fclose(particle_record); @@ -1202,7 +1202,7 @@ static void ONiParticle3_Record_Kill(void) } } -static void ONiParticle3_Record_Play(void) +static void ONiParticle3_Record_Play(void) { if (NULL != particle_record) { fclose(particle_record); @@ -1273,7 +1273,7 @@ ONiParticle3_Temporary_Start( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { P3rSetTemporaryCreation(UUcTrue); @@ -1287,7 +1287,7 @@ ONiParticle3_Temporary_Stop( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { P3rSetTemporaryCreation(UUcFalse); @@ -1301,7 +1301,7 @@ ONiParticle3_Temporary_Kill( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { P3rKillTemporaryParticles(); @@ -1380,7 +1380,7 @@ ONiParticle3_Debug_KillNearestParticle( UUtBool is_dead; UUmAssert(inParameterListLength == 0); - + player_character = ONrGameState_GetPlayerCharacter(); // no particles found yet @@ -1623,7 +1623,7 @@ ONiParticle3_Command( // iterate over all environmental particles with this tag EPrEnumerateByTag(inParameterList[0].val.str, ONiParticle3_CommandCallback, (UUtUns32) &command_data); - + return UUcError_None; } @@ -1632,7 +1632,7 @@ void ONrParticle3_Explode(UUtUns32 inExplodeID) { ONtParticleCommandData command_data; char temptag[32]; - + command_data.type = ONcParticleCommandType_Do; command_data.event_index = P3cEvent_Explode; command_data.num_params = 0; @@ -1648,7 +1648,7 @@ ONiParticle3_PrintTags( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { EPrPrintTags(); @@ -1661,7 +1661,7 @@ ONiParticle3_RemoveDangerous( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { P3rRemoveDangerousProjectiles(); @@ -1674,7 +1674,7 @@ ONiParticle3_DumpParticles( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { P3rDumpParticles(); @@ -1714,7 +1714,7 @@ ONiParticle3_StartAll( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { ONtParticle3_AllEnvParticleData user_data; @@ -1733,7 +1733,7 @@ ONiParticle3_StopAll( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { ONtParticle3_AllEnvParticleData user_data; @@ -1753,7 +1753,7 @@ ONiParticle3_ListCollision( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { P3rListCollision(); @@ -1767,7 +1767,7 @@ ONiParticle3_DaodanShieldDisable( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { UUtUns32 itr, part; @@ -1842,7 +1842,7 @@ ONiParticle3_WriteUsedParticles( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { UUtError error; @@ -1854,14 +1854,14 @@ ONiParticle3_WriteUsedParticles( sprintf(filename, "L%d_Particles.txt", ONrLevel_GetCurrentLevel()); error = BFrFileRef_MakeFromName(filename, &file_ref); UUmError_ReturnOnError(error); - + // create the text file if it doesn't already exist if (BFrFileRef_FileExists(file_ref) == UUcFalse) { error = BFrFile_Create(file_ref); UUmError_ReturnOnError(error); } - + // open the file error = BFrFile_Open(file_ref, "w", &user_data.file); UUmError_ReturnOnError(error); @@ -1870,11 +1870,11 @@ ONiParticle3_WriteUsedParticles( user_data.num_classes = 0; EPrEnumerateParticleClassesRecursively(ONiParticle3_WriteUsedParticles_EnumCallback, (UUtUns32) &user_data); COrConsole_Printf("Wrote %d particle classes to file %s...", user_data.num_classes, filename); - + // cleanup BFrFile_Close(user_data.file); BFrFileRef_Dispose(file_ref); - + return UUcError_None; } @@ -1885,7 +1885,7 @@ ONiParticle3_Perf( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { UUtUns32 itr, itr2, mask; diff --git a/OniProj/OniGameSource/Oni_Path.c b/OniProj/OniGameSource/Oni_Path.c index e9794d0..270f7eb 100644 --- a/OniProj/OniGameSource/Oni_Path.c +++ b/OniProj/OniGameSource/Oni_Path.c @@ -1,8 +1,8 @@ /* Oni_Path.c - + This file contains all enemy pathfinding related code - + Author: Quinn Dunki c1998 Bungie */ @@ -75,7 +75,7 @@ UUtError PHrBuildGraph(PHtGraph *ioGraph, AKtEnvironment *inEnv) /**************** * Initializes the new graph 'ioGraph' based on 'inEnv' */ - + UUtError error; UUtBool totally_blocked; UUtUns16 block_start, block_end; @@ -84,12 +84,12 @@ UUtError PHrBuildGraph(PHtGraph *ioGraph, AKtEnvironment *inEnv) PHtConnection *conn, *conn2; AKtBNVNode_Side *side; float weight, blockages[PHcMaxBlockages * 2]; - + if (!inEnv) return UUcError_Generic; //printf("Building pathfinding graph..."); - + ioGraph->env = inEnv; - + // Allocate memory for the graph nodeCount = 0; for (c=0; cbnvNodeArray->numNodes; c++) @@ -106,7 +106,7 @@ UUtError PHrBuildGraph(PHtGraph *ioGraph, AKtEnvironment *inEnv) } else { ioGraph->nodes = NULL; } - + // initialize the lrar cache which is used to allocate the pathfinding grids ioGraph->grid_cache = lrar_new("pathfinding grid cache", 0, PHcGridCacheSize, (UUtUns16) nodeCount, 2, NONE, PHiLRAR_NewProc, PHiLRAR_PurgeProc); @@ -124,18 +124,18 @@ UUtError PHrBuildGraph(PHtGraph *ioGraph, AKtEnvironment *inEnv) nodeCount++; } } - + // Create all the connections between nodes connCount = 0; for (c=0; cnumNodes; c++) { node = &ioGraph->nodes[c]; - + // For each room, check all the sides for (s=node->location->sideStartIndex; slocation->sideEndIndex; s++) { side = &inEnv->bnvSideArray->sides[s]; - + for (a=side->adjacencyStartIndex; aadjacencyEndIndex; a++) { if (PHrBuildConnection(ioGraph, inEnv, node->location, node, s, a)) { @@ -181,7 +181,7 @@ UUtError PHrBuildGraph(PHtGraph *ioGraph, AKtEnvironment *inEnv) UUmAssert(conn->to == node); UUmAssert(conn2->from == node); UUrDebuggerMessage("PHrBuildGraph: detected superposed connections between BNVs %d -> %d and %d -> %d, removing; details follow:\n", - conn->from->location->index, conn->to->location->index, + conn->from->location->index, conn->to->location->index, conn2->from->location->index, conn2->to->location->index); UUrDebuggerMessage(" FromBNV (%d): [%f,%f,%f]-[%f,%f,%f]\n", conn->from->location->index, @@ -280,7 +280,7 @@ UUtError PHrBuildGraph(PHtGraph *ioGraph, AKtEnvironment *inEnv) ioGraph->open = ioGraph->closed = NULL; //printf("done. %d nodes and %d connections."UUmNL,ioGraph->numNodes,connCount); //PHrDisplayGraph(ioGraph); getchar(); - + return UUcError_None; } @@ -324,11 +324,11 @@ void PHrDisposeGraph(PHtGraph *ioGraph) /****************** * Releases all the memory used by 'ioGraph' */ - + UUtUns16 c; PHtConnection *conn, *next; PHtNode *node; - + for (c = 0, node = ioGraph->nodes; c < ioGraph->numNodes; c++, node++) { // remove all outgoing connections @@ -338,7 +338,7 @@ void PHrDisposeGraph(PHtGraph *ioGraph) PHrRemoveConnection(conn, UUcFalse); UUrMemory_Block_Delete(conn); } - + // remove all incoming connections for (conn = node->connections_in; conn != NULL; conn = next) { next = conn->next_in; @@ -357,7 +357,7 @@ void PHrDisposeGraph(PHtGraph *ioGraph) UUrMemory_Block_Delete(ioGraph->nodes); ioGraph->nodes = NULL; } - + if (ioGraph->weight_storage != NULL) { UUrMemory_Block_Delete(ioGraph->weight_storage); ioGraph->weight_storage = NULL; @@ -384,7 +384,7 @@ void PHrResetNode(PHtNode *ioNode) /***************** * Resets 'ioNode' to a default state */ - + ioNode->g = ioNode->h = ioNode->f = 0.0f; ioNode->weight_multiplier = 1.0f; ioNode->next = NULL; @@ -412,7 +412,7 @@ UUtBool PHrGeneratePath( float *ioDistance, // NULL for no distance calc, otherwise read = max distance, write = actual distance PHtConnection **outConnections, // either NULL or a pointer to an array of pointers PHcMaxPathLength-1 long UUtUns32 *outNumNodes) -{ +{ UUtUns16 index_in, index_out; UUtUns32 reset_itr, itr, weight_index; UUtInt32 delta_path; @@ -461,7 +461,7 @@ UUtBool PHrGeneratePath( PHtNode *node; UUmAssert(numNodes < PHcMaxPathLength); - + for (itr = numNodes - 1, node = cheap; itr > 0; itr--, node = node->predecessor) { UUmAssert(node != NULL); UUmAssert(node->predecessor_conn != NULL); @@ -489,7 +489,7 @@ UUtBool PHrGeneratePath( return UUcTrue; } - + for (itr = 0, con = cheap->connections_out; con != NULL; con = con->next_out, itr++) { if (con->to == cheap->predecessor) { // don't check the node we came in from @@ -582,7 +582,7 @@ UUtBool PHrGeneratePath( new_g = cheap->g + weight * cheap->weight_multiplier; new_h = cheap->weight_multiplier * PHrEstimateDistance(check, &con->connection_midpoint, inEndNode, inEndPoint); new_f = new_g + new_h; - + // we must have an admissible heuristic in order to be A*, where h >= sum(g) to goal, and // so f must never decrease by traversing a connection /* if (new_f < cheap->f - 0.01f) { @@ -652,8 +652,8 @@ UUtBool PHrGeneratePath( PHrAppendToList(cheap,&ioGraph->closed); cheap->pathStatus = PHcPath_Closed; } - - return UUcFalse; + + return UUcFalse; } static void PHiPropagateShorterPath(PHtNode *inNode, float inDeltaWeight, UUtInt32 inDeltaPath) @@ -705,13 +705,13 @@ PHtNode *PHrPopCheapest(PHtNode **inHead) * Finds the node in the list with the lowest Dijkstra F value, * removes it from the list, and returns it to the caller */ - + PHtNode *head = *inHead; PHtNode *lowN; float low = UUcFloat_Max; - + if (!head) return NULL; - + // Find cheapest do { @@ -722,9 +722,9 @@ PHtNode *PHrPopCheapest(PHtNode **inHead) head = head->next; } while(head != NULL); - + PHrRemoveFromList(lowN,inHead); - + return lowN; } @@ -733,14 +733,14 @@ static PHtConnection *PHiClosestConnection(PHtConnection **inConnectionList, UUt /************ * Returns the closest connection from a list to a given point */ - + PHtConnection *closest_connection=NULL; PHtConnection *connection; float shortest_distance_squared = UUcFloat_Max; M3tPoint3D *p0, *p1; UUtUns32 i; AKtEnvironment *environment = ONrGameState_GetEnvironment(); - + for (i=0; i < inConnectionCount; i++) { float distance_squared; @@ -749,7 +749,7 @@ static PHtConnection *PHiClosestConnection(PHtConnection **inConnectionList, UUt p0 = PHmConnection_Point0(environment, connection); p1 = PHmConnection_Point1(environment, connection); - + // find the distance to closest point to this connection // this is actually kinda wrong since you might be near the middle distance_squared = UUmMin(MUrPoint_Distance_Squared(inPoint, p0), MUrPoint_Distance_Squared(inPoint, p1)); @@ -759,7 +759,7 @@ static PHtConnection *PHiClosestConnection(PHtConnection **inConnectionList, UUt closest_connection = connection; } } - + UUmAssert(closest_connection != NULL); return closest_connection; @@ -772,11 +772,11 @@ PHtConnection *PHrFindConnection(PHtNode *inA, PHtNode *inB, M3tPoint3D *inPoint * Returns the first available edge connection between A and B, * assuming we wish to get to pointB in B. */ - + #define PHcMaxConnections 32 PHtConnection *conlist[PHcMaxConnections],*con = inA->connections_out; UUtUns16 concount = 0; - + while (con) { UUmAssert(con->from == inA); @@ -788,13 +788,13 @@ PHtConnection *PHrFindConnection(PHtNode *inA, PHtNode *inB, M3tPoint3D *inPoint } con = con->next_out; } - + if (concount) { // Found a list of connections from A to B. Return best choice return PHiClosestConnection(conlist,concount,inPointB); } - + return NULL; } @@ -812,10 +812,10 @@ PHtRoomData *PHrRoomFromPoint(AKtEnvironment *inEnv, M3tPoint3D *inPoint) * return what you expect. It returns the first room it finds containing your * point, which is not necessarily the only room that contains it. */ - + AKtBNVNode *node; PHtRoomData *room; - + node = AKrNodeFromPoint(inPoint); if (NULL == node) { @@ -836,7 +836,7 @@ UUtBool PHrPointInRoom(AKtEnvironment *inEnv, PHtRoomData *inRoom, M3tPoint3D *i * created by the volume node and the 3D extrusion of the room * pathfinding grid. */ - + UUtInt16 gridX,gridY; M3tPoint3D checkPoint; AKtBNVNode *parent = PHrFindRoomParent(inRoom,inEnv); @@ -844,15 +844,15 @@ UUtBool PHrPointInRoom(AKtEnvironment *inEnv, PHtRoomData *inRoom, M3tPoint3D *i // CB: this assertion is a hindrance because I want to call it from the importer // before compressed_grid has actually been calculated - + PHrWorldToGridSpaceDangerous(&gridX,&gridY,inPoint,inRoom); - + if ((gridX >= 0) && ((UUtUns32) gridX < inRoom->gridX) && (gridY >= 0) && ((UUtUns32) gridY < inRoom->gridY)) { // For stairs, that's close enough if (parent->flags & AKcBNV_Flag_Stairs) return UUcTrue; - + // CB: this function is used only for debugging purposes, and in the // importer for determining which quads need to be rasterized into the // pathfinding grid. it's now pretty well obsolete so the use of @@ -874,7 +874,7 @@ void PHrAddCharacterToGrid(UUtUns32 inIndex, ONtCharacter *inCharacter, PHtDynam * described by the inGrid parms. 'inGrid' is assumed * to be in the same coordinate space as 'inRoom' */ - + UUtUns8 obstruction; UUtInt16 gx,gy; UUtUns16 width = inGridX,height = inGridY; @@ -909,27 +909,27 @@ void PHrAddCharacterToGrid(UUtUns32 inIndex, ONtCharacter *inCharacter, PHtDynam PHrPutObstruction(grid,height,width,gx-1,gy-1,obstruction); // E PHrPutObstruction(grid,height,width,gx,gy-1,obstruction); PHrPutObstruction(grid,height,width,gx+1,gy-1,obstruction); - + PHrPutObstruction(grid,height,width,gx-1,gy,obstruction); // F PHrPutObstruction(grid,height,width,gx,gy,obstruction); PHrPutObstruction(grid,height,width,gx+1,gy,obstruction); - + PHrPutObstruction(grid,height,width,gx-1,gy+1,obstruction); // F PHrPutObstruction(grid,height,width,gx,gy+1,obstruction); PHrPutObstruction(grid,height,width,gx+1,gy+1,obstruction); - + PHrPutObstruction(grid,height,width,gx-1,gy-2,obstruction); // a PHrPutObstruction(grid,height,width,gx,gy-2,obstruction); PHrPutObstruction(grid,height,width,gx+1,gy-2,obstruction); - + PHrPutObstruction(grid,height,width,gx-2,gy-1,obstruction); // b PHrPutObstruction(grid,height,width,gx-2,gy,obstruction); PHrPutObstruction(grid,height,width,gx-2,gy+1,obstruction); - + PHrPutObstruction(grid,height,width,gx+2,gy-1,obstruction); // c PHrPutObstruction(grid,height,width,gx+2,gy,obstruction); PHrPutObstruction(grid,height,width,gx+2,gy+1,obstruction); - + PHrPutObstruction(grid,height,width,gx-1,gy+2,obstruction); // d PHrPutObstruction(grid,height,width,gx,gy+2,obstruction); PHrPutObstruction(grid,height,width,gx+1,gy+2,obstruction); @@ -1036,7 +1036,7 @@ void PHrAddDoorToGrid(UUtUns32 inIndex, M3tPoint3D *inPoint0, M3tPoint3D *inPoin ((p0y >= height) && (p1y >= height))) { continue; } - + // get an obstruction index for this object if (obstruction == UUcMaxUns8) { // make an entry for this door in the obstruction table of the room @@ -1058,17 +1058,17 @@ void PHrAddDoorToGrid(UUtUns32 inIndex, M3tPoint3D *inPoint0, M3tPoint3D *inPoin return; } - + UUtUns32 PHrAkiraNodeToIndex(AKtBNVNode *inNode, AKtEnvironment *inEnv) { /*************************** * Returns the absolute Akira index corrosponding to the * Akira node 'inNode' */ - + UUtUns32 node_index = inNode->index; - + return node_index; } @@ -1077,9 +1077,9 @@ void PHrAppendToList(PHtNode *inElem, PHtNode **inHead) /******************* * Appends 'inElem' to 'inHead' */ - + PHtNode *head = *inHead; - + if (!head) { *inHead = inElem; @@ -1088,7 +1088,7 @@ void PHrAppendToList(PHtNode *inElem, PHtNode **inHead) { while (head->next) head = head->next; head->next = inElem; - } + } inElem->next = NULL; } @@ -1097,9 +1097,9 @@ void PHrRemoveFromList(PHtNode *inVictim, PHtNode **inHead) /******************** * Removes 'inVictim' from 'inHead' */ - + PHtNode *head; - + head = *inHead; if (head == inVictim) *inHead = head->next; else do @@ -1110,7 +1110,7 @@ void PHrRemoveFromList(PHtNode *inVictim, PHtNode **inHead) } else head = head->next; } while (head); - + inVictim->pathStatus = PHcPath_Undef; } @@ -1128,8 +1128,8 @@ void PHrAddNode(PHtGraph *ioGraph, AKtBNVNode *inRoom, UUtUns32 inSlot) /************************* * Creates a new node for 'inRoom' in 'ioGraph' at 'inSlot'. */ - - PHtNode *node = &ioGraph->nodes[inSlot]; + + PHtNode *node = &ioGraph->nodes[inSlot]; inRoom->pathnodeIndex = inSlot; node->num_connections_in = 0; @@ -1196,7 +1196,7 @@ static UUtBool PHrBuildConnection(PHtGraph *ioGraph, AKtEnvironment *inEnvironme p1_index = itr; } } - + UUmAssert((p0_index >= 0) && (p0_index < 4)); UUmAssert((p1_index >= 0) && (p1_index < 4)); @@ -1248,7 +1248,7 @@ static UUtBool PHrBuildConnection(PHtGraph *ioGraph, AKtEnvironment *inEnvironme if (conn == NULL) { return UUcFalse; } - + conn->flags = 0; if ((inNodeSrc->location->flags & AKcBNV_Flag_Stairs_Standard) || (dest_node->location->flags & AKcBNV_Flag_Stairs_Standard)) { @@ -1377,10 +1377,10 @@ void PHrDisplayGraph(PHtGraph *inGraph) /*********** * Outputs an ASCII version of the pathfinding graph */ - + UUtUns32 i; PHtConnection *conn; - + for (i=0; i < inGraph->numNodes; i++) { fprintf(stderr,"BNV %d:\tfrom: ",i); @@ -1417,7 +1417,7 @@ void PHrRenderGrid(PHtNode *inNode, PHtRoomData *inRoom, IMtPoint2D *inErrStart, PHtSquare chk; float h, line_y; PHtSquare *grid; - + if (inRoom->debug_render_time == current_time) { // don't draw the same grid twice return; @@ -1436,13 +1436,13 @@ void PHrRenderGrid(PHtNode *inNode, PHtRoomData *inRoom, IMtPoint2D *inErrStart, if (NULL == grid) { return; } - + h = inRoom->squareSize / 2.0f; width = (short) inRoom->gridX; line_y = inRoom->origin.y + 1.0f; PHrGrid_Decompress(inRoom->compressed_grid, inRoom->compressed_grid_size, grid); - + for (p=0; p < inRoom->gridX; p++) // | | | | | { PHrGridToWorldSpace(p,0,NULL,&c,inRoom); @@ -1475,7 +1475,7 @@ void PHrRenderGrid(PHtNode *inNode, PHtRoomData *inRoom, IMtPoint2D *inErrStart, line_points[2].x = c.x+h; line_points[2].y = line_y; line_points[2].z = c.z-h; M3rGeom_Line_Light(line_points,line_points+1,IMcShade_Gray50); M3rGeom_Line_Light(line_points+1,line_points+2,IMcShade_Gray50); - + for (p=0; pgridY; p++) { for (r=0; rgridX; r++) @@ -1493,7 +1493,7 @@ void PHrRenderGrid(PHtNode *inNode, PHtRoomData *inRoom, IMtPoint2D *inErrStart, M3rGeom_Line_Light(line_points,line_points+1,IMcShade_Pink); line_points[0].x = c.x+h; line_points[0].z = c.z-h; line_points[0].y = line_y + 2.0f; line_points[1].x = c.x-h; line_points[1].z = c.z+h; line_points[1].y = line_y + 2.0f; - M3rGeom_Line_Light(line_points,line_points+1,IMcShade_Pink); + M3rGeom_Line_Light(line_points,line_points+1,IMcShade_Pink); } if ((r == PHgDebugSquareX) && (p == PHgDebugSquareY)) { @@ -1541,7 +1541,7 @@ void PHrRenderGrid(PHtNode *inNode, PHtRoomData *inRoom, IMtPoint2D *inErrStart, shade = PHgPathfindingWeightColor[chk.weight]; } - // Scale size of X + // Scale size of X h = inRoom->squareSize/2.0f; h = UUmPin(h,0.0f,inRoom->squareSize/2.0f); @@ -1578,7 +1578,7 @@ void PHrDebugGraph_TraverseConnections(PHtGraph *ioGraph, PHtNode *inStartNode, env = ONrGameState_GetEnvironment(); // none of the nodes are currently in the accessible set - for (reset_itr = 0; reset_itr < ioGraph->numNodes; reset_itr++) + for (reset_itr = 0; reset_itr < ioGraph->numNodes; reset_itr++) { ioGraph->nodes[reset_itr].traverse_dist = (UUtUns32) -1; ioGraph->nodes[reset_itr].pathStatus = PHcPath_Undef; @@ -1587,7 +1587,7 @@ void PHrDebugGraph_TraverseConnections(PHtGraph *ioGraph, PHtNode *inStartNode, inStartNode->traverse_dist = 0; PHrAppendToList(inStartNode, &ioGraph->open); inStartNode->pathStatus = PHcPath_Open; - + while ((node = ioGraph->open) || (inOtherNode != NULL)) { if (node == NULL) { @@ -1633,7 +1633,7 @@ void PHrDebugGraph_TraverseConnections(PHtGraph *ioGraph, PHtNode *inStartNode, } } } - + return; } @@ -1766,7 +1766,7 @@ void PHrPrepareRoomForPath(PHtNode *inNode, const PHtRoomData *inRoom) UUmAssertReadPtr(inRoom, sizeof(PHtRoomData)); UUmAssert((inRoom->gridX > UUcMinUns16) && (inRoom->gridX < UUcMaxUns16)); // casting later UUmAssert((inRoom->gridY > UUcMinUns16) && (inRoom->gridY < UUcMaxUns16)); // casting later - + current_time = ONrGameState_GetGameTime(); if (!inNode->grids_allocated) { @@ -1813,7 +1813,7 @@ void PHrPrepareRoomForPath(PHtNode *inNode, const PHtRoomData *inRoom) UUtUns32 active_character_itr; UUtUns32 object_index; static UUtUns32 unique_gridpreparation_index = 0; - + UUmAssertWritePtr(inNode->dynamic_grid, inNode->array_size); UUrMemory_Clear(inNode->dynamic_grid, inNode->array_size); @@ -1835,7 +1835,7 @@ void PHrPrepareRoomForPath(PHtNode *inNode, const PHtRoomData *inRoom) PHrAddCharacterToGrid(index, current_character, inNode->dynamic_grid, (UUtUns16) inNode->gridX, (UUtUns16) inNode->gridY, inNode, inRoom); } - + // Add the objects to the grid numObjects = ONgGameState->objects->numObjects; for (object_index = 0; object_index < numObjects; object_index++) @@ -1843,7 +1843,7 @@ void PHrPrepareRoomForPath(PHtNode *inNode, const PHtRoomData *inRoom) object = ONgGameState->objects->object_list + object_index; if (!(object->flags & OBcFlags_InUse)) continue; - + // Include animated objects, but not small projectiles if (object->physics->flags & PHcFlags_Physics_Projectile) continue; @@ -1916,7 +1916,7 @@ UUtBool PHrObstructionIsCharacter(UUtUns16 inObstruction, ONtCharacter **outChar if ((inObstruction & PHcObstructionTypeMask) != PHcObstructionType_Character) return UUcFalse; - + character_index = inObstruction & PHcObstructionIndexMask; UUmAssert((character_index >= 0) && (character_index < ONcMaxCharacters)); character = &ONgGameState->characters[character_index ]; @@ -1956,15 +1956,15 @@ UUtBool PHrIgnoreObstruction(ONtCharacter *inCharacter, PHtPathMode inPathMode, case PHcObstructionType_Character: { ONtCharacter *character; - + inObstruction &= PHcObstructionIndexMask; UUmAssert((inObstruction >= 0) && (inObstruction < ONcMaxCharacters)); character = &ONgGameState->characters[inObstruction]; - + // this obstruction is a character - we may ignore it in some cases if (character == inCharacter) { ignore = UUcTrue; - + } else if (inPathMode == PHcPathMode_CheckClearSpace) { ignore = UUcFalse; @@ -1977,16 +1977,16 @@ UUtBool PHrIgnoreObstruction(ONtCharacter *inCharacter, PHtPathMode inPathMode, case PHcObstructionType_Object: { OBtObject *object; - + inObstruction &= PHcObstructionIndexMask; UUmAssert((inObstruction >= 0) && (inObstruction < ONgGameState->objects->numObjects)); object = ONgGameState->objects->object_list + inObstruction; - + /* // this is an object - all objects are marked as impassable // EXCEPT at present all doors. [this may change in future when AIs // can only open some doors] - + if (object->flags & OBcFlags_InUse) { if (object->flags & OBcFlags_IsDoor) { UUmAssertReadPtr(object->owner, sizeof(OBJtObject)); @@ -2058,7 +2058,7 @@ UUtBool PHrSquareIsPassable(ONtCharacter *inCharacter, PHtPathMode inPathMode, // calculate the grid index index = inX + (inY * inRoom->gridX); - + if (inNode->no_static_grid) { weight = PHcClear; } else { @@ -2072,7 +2072,7 @@ UUtBool PHrSquareIsPassable(ONtCharacter *inCharacter, PHtPathMode inPathMode, return UUcFalse; } } - + UUmAssertReadPtr(inNode->dynamic_grid, inNode->array_size); obstruction = inNode->dynamic_grid[index].obstruction; if (obstruction) { @@ -2097,7 +2097,7 @@ UUtBool PHrSquareIsPassable(ONtCharacter *inCharacter, PHtPathMode inPathMode, // perform the test - can we safely ignore this obstruction? ignore = PHrIgnoreObstruction(inCharacter, inPathMode, inNode->obstruction[obstruction]); - + // flag that we have tested this obstruction already UUrBitVector_SetBit(inObstructionBV, 2*obstruction); @@ -2161,7 +2161,7 @@ UUtBool PHrLocalPathWeight( dy = y2-y1; ax = UUmABS(x2-x1); ay = UUmABS(y2-y1); - + if (dx < 0) { xdir = -1; } @@ -2181,10 +2181,10 @@ UUtBool PHrLocalPathWeight( else { ydir = 1; } - + x = x1; y = y1; - + *escape_path = UUcFalse; prev_obstruction = UUcFalse; *last_x = x; @@ -2225,7 +2225,7 @@ UUtBool PHrLocalPathWeight( *lowest_weight = lowest; return UUcFalse; } - + if (first_square) { // we are actually standing on an 'impassable' square. this is an escape path. *escape_path = UUcTrue; @@ -2243,7 +2243,7 @@ UUtBool PHrLocalPathWeight( return UUcTrue; } } - + if (e>=0) { y+=ydir; @@ -2292,7 +2292,7 @@ UUtBool PHrLocalPathWeight( *lowest_weight = lowest; return UUcFalse; } - + if (first_square) { // we are actually standing on an 'impassable' square. this is an escape path. *escape_path = UUcTrue; @@ -2460,7 +2460,7 @@ static void PHiCheckForBlockages(PHtNode *inNode, M3tPoint3D *inPoint0, M3tPoint ax = UUmABS(dx); ay = UUmABS(dy); MUmVector_Subtract(edge_vector, *inPoint1, *inPoint0); - + // offset the start point away from the end point by a max of 2 squares MUmVector_Copy(start_pt, *inPoint0); if (ax != 0) { @@ -2583,7 +2583,7 @@ static void PHiCheckForBlockages(PHtNode *inNode, M3tPoint3D *inPoint0, M3tPoint dy = end_y - start_y; ax = UUmABS(dx); ay = UUmABS(dy); - + if (dx < 0) { xdir = -1; } else if (dx == 0) { @@ -2599,11 +2599,11 @@ static void PHiCheckForBlockages(PHtNode *inNode, M3tPoint3D *inPoint0, M3tPoint } else { ydir = 1; } - + x = start_x; y = start_y; cur_t = start_t; - + if (ax > ay) { e = (ay - ax) / 2; while (1) { @@ -2616,7 +2616,7 @@ static void PHiCheckForBlockages(PHtNode *inNode, M3tPoint3D *inPoint0, M3tPoint if ((x == end_x) && (y == end_y)) { goto exit; } - + if (e>=0) { y += ydir; e -= ax; @@ -2639,7 +2639,7 @@ static void PHiCheckForBlockages(PHtNode *inNode, M3tPoint3D *inPoint0, M3tPoint if ((x == end_x) && (y == end_y)) { goto exit; } - + if (e >= 0) { x += xdir; e -= ay; @@ -2656,7 +2656,7 @@ static void PHiCheckForBlockages(PHtNode *inNode, M3tPoint3D *inPoint0, M3tPoint UUrMemory_Block_Delete(grid); } -static UUtUns32 PHrFindBlockages(AKtEnvironment *inEnvironment, PHtConnection *inConnection, +static UUtUns32 PHrFindBlockages(AKtEnvironment *inEnvironment, PHtConnection *inConnection, UUtUns32 inMaxBlockages, float *inBlockageArray, UUtBool *outTotallyBlocked) { UUtUns32 num_blockages; @@ -2821,10 +2821,10 @@ UUtError PHrPathDistance(ONtCharacter *inCharacter, UUtUns32 inSoundType, PHtGraph *graph; AKtBNVNode *bnv_node; UUtBool gotpath; - + env = ONrGameState_GetEnvironment(); graph = ONrGameState_GetGraph(); - + // set up the starting point if (inFromNode == NULL) { bnv_node = AKrNodeFromPoint(inFrom); diff --git a/OniProj/OniGameSource/Oni_Path.h b/OniProj/OniGameSource/Oni_Path.h index 55c5121..bab727c 100644 --- a/OniProj/OniGameSource/Oni_Path.h +++ b/OniProj/OniGameSource/Oni_Path.h @@ -2,9 +2,9 @@ /* Oni_Path.h - + This file contains all pathfinding header stuff - + Author: Quinn Dunki, Michael Evans Copyright (c) Bungie Software 1998, 2000 */ @@ -89,7 +89,7 @@ enum { // Path status types struct PHtConnection { UUtUns32 flags; - + PHtNode *from; PHtNode *to; // Who we connect (note that connections are ONE WAY) UUtUns16 from_connectionindex; // index of this connection in from->out_connections @@ -98,7 +98,7 @@ struct PHtConnection AKtGQ_General *gunk; // Gunk quad that this connection represents M3tPoint3D connection_midpoint; float connection_width; - + UUtBool door_side; UUtUns32 last_gridindex; // unique grid construction index for the last pass we were added to struct OBJtObject *door_link; // the door that blocks this connection @@ -125,7 +125,7 @@ struct PHtNode PHtConnection *connections_in; // List of paths that lead to us AKtBNVNode *location; // Corresponding BNV UUtUns32 weight_baseindex; // index into PHtGraph->weight_storage - + /* * cached room grids - both static and dynamic */ @@ -148,7 +148,7 @@ struct PHtNode PHtNode *predecessor; // how we got to this node (NULL if initial node) PHtConnection *predecessor_conn; - + #if TOOL_VERSION UUtUns32 traverse_dist; // debugging - for traversing the graph and displaying it #endif @@ -159,10 +159,10 @@ struct PHtGraph PHtNode *nodes; // Array of graph nodes UUtUns32 numNodes; AKtEnvironment *env; // The Akira environment we represent - + PHtNode *open; // Shortest determined nodes PHtNode *closed; // Retired Dijkstra nodes - + lrar_cache *grid_cache; // lrar cache for pathfinding grids UUtUns8 *grid_storage; // memory storage for pathfinding grids diff --git a/OniProj/OniGameSource/Oni_Performance.c b/OniProj/OniGameSource/Oni_Performance.c index 3b47694..b58819c 100644 --- a/OniProj/OniGameSource/Oni_Performance.c +++ b/OniProj/OniGameSource/Oni_Performance.c @@ -1,12 +1,12 @@ /* FILE: Oni_Performance.c - + AUTHOR: Brent H. Pease - + CREATED: April 2, 1997 - + PURPOSE: main .c file for Oni - + Copyright 1997 */ @@ -38,15 +38,15 @@ void ONrPerformance_Measure_Gouraud( //unsigned long startTimeHi, startTimeLo, stopTimeHi, stopTimeLo; //double elapsedTime; float offset; - + vCoords = (M3tPointScreen *)UUrMemory_Block_New(sizeof(M3tPointScreen) * 320 * 240); - + UUmAssert(vCoords != NULL); - + vShades = (UUtUns16 *)UUrMemory_Block_New(sizeof(UUtUns16) * 320 * 240); - + UUmAssert(vShades != NULL); - + for(offset = 0.0f; offset <= 1.0f; offset += 0.1f) { for(triWidth = 2; triWidth <= 10; triWidth += 1) @@ -55,22 +55,22 @@ void ONrPerformance_Measure_Gouraud( { numXTris = 638 / triWidth; numYTris = 478 / triHeight; - + for(x = 0; x < numXTris; x++) { for(y = 0; y < numYTris; y++) { curVCoord = vCoords + y * numXTris + x; curVShade = vShades + y * numXTris + x; - + curVCoord->x = (float)x * (float)(triWidth) + offset; curVCoord->y = (float)y * (float)(triHeight) + offset; curVCoord->z = 0.5; - + *curVShade = ((x & 1 ? 0 : 0x1F) << 10) | (0x1F << 5) | (y & 1 ? 0 : 0x1F); } } - + if(M3rFrame_Start(drawContext) != UUcError_None) { UUrError_Report(UUcError_Generic, "Could not start frame"); @@ -109,33 +109,33 @@ void ONrPerformance_Measure_Gouraud( //elapsedTime *= 0x10000; //elapsedTime *= 0x10000; //elapsedTime += (stopTimeLo - startTimeLo); - + numTris[triWidth / 2 - 1][triHeight / 2 - 1] = numXTris * numYTris * 2; // time[triWidth / 2 - 1][triHeight / 2 - 1] = elapsedTime / getTimeBaseMhz(); - + if(M3rFrame_End(drawContext) != UUcError_None) { UUrError_Report(UUcError_Generic, "Could not start frame"); return; } - + } } } - + if(0) { FILE *file; long x, y; - + file = UUrFOpen("triRasterPerf.out", "wb"); fprintf(file, "triWidth\ttriHeight\tnumTris\tframeTime\t|\ttrisPerSec\tpixelsPerSec"UUmNL); - + for(x = 0; x < 25; x++) { for(y = 0; y < 25; y++) { - fprintf(file, "%8d\t%9d\t%7d\t%9f\t|\t%10f\t\t%f"UUmNL, + fprintf(file, "%8d\t%9d\t%7d\t%9f\t|\t%10f\t\t%f"UUmNL, x * 2 + 2, y * 2 + 2, numTris[x][y], @@ -144,10 +144,10 @@ void ONrPerformance_Measure_Gouraud( (double)((x * 2 + 2) * (y * 2 + 2) * numTris[x][y]) / (time[x][y] * 2.0)); } } - + fclose(file); } - + UUrMemory_Block_Delete(vCoords); UUrMemory_Block_Delete(vShades); } @@ -165,11 +165,11 @@ void ONrPerformance_Measure_GouraudFlat( //unsigned long startTimeHi, startTimeLo, stopTimeHi, stopTimeLo; //double elapsedTime; float offset; - + vCoords = (M3tPointScreen *)UUrMemory_Block_New(sizeof(M3tPointScreen) * 320 * 240); - + UUmAssert(vCoords != NULL); - + for(offset = 0.0f; offset <= 1.0f; offset += 0.1f) { for(triWidth = 2; triWidth <= 10; triWidth += 1) @@ -178,20 +178,20 @@ void ONrPerformance_Measure_GouraudFlat( { numXTris = 638 / triWidth; numYTris = 478 / triHeight; - + for(x = 0; x < numXTris; x++) { for(y = 0; y < numYTris; y++) { curVCoord = vCoords + y * numXTris + x; - + curVCoord->x = (float)x * (float)(triWidth) + offset; curVCoord->y = (float)y * (float)(triHeight) + offset; curVCoord->z = 0.5; - + } } - + if(M3rFrame_Start(drawContext) != UUcError_None) { @@ -208,7 +208,7 @@ void ONrPerformance_Measure_GouraudFlat( for(y = 0; y < numYTris - 1; y ++) { vShade = ((rand() % 32) << 10) | ((rand() % 32) << 5) | ((rand() % 32)); - + #if 0 M3rDraw_TriFlat( drawContext, @@ -235,33 +235,33 @@ void ONrPerformance_Measure_GouraudFlat( //elapsedTime *= 0x10000; //elapsedTime *= 0x10000; //elapsedTime += (stopTimeLo - startTimeLo); - + numTris[triWidth / 2 - 1][triHeight / 2 - 1] = numXTris * numYTris * 2; // time[triWidth / 2 - 1][triHeight / 2 - 1] = elapsedTime / getTimeBaseMhz(); - + if(M3rFrame_End(drawContext) != UUcError_None) { UUrError_Report(UUcError_Generic, "Could not start frame"); return; } - + } } } - + if(0) { FILE *file; long x, y; - + file = UUrFOpen("triRasterPerf.out", "wb"); fprintf(file, "triWidth\ttriHeight\tnumTris\tframeTime\t|\ttrisPerSec\tpixelsPerSec"UUmNL); - + for(x = 0; x < 25; x++) { for(y = 0; y < 25; y++) { - fprintf(file, "%8d\t%9d\t%7d\t%9f\t|\t%10f\t\t%f"UUmNL, + fprintf(file, "%8d\t%9d\t%7d\t%9f\t|\t%10f\t\t%f"UUmNL, x * 2 + 2, y * 2 + 2, numTris[x][y], @@ -270,10 +270,10 @@ void ONrPerformance_Measure_GouraudFlat( (double)((x * 2 + 2) * (y * 2 + 2) * numTris[x][y]) / (time[x][y] * 2.0)); } } - + fclose(file); } - + UUrMemory_Block_Delete(vCoords); } @@ -290,16 +290,16 @@ ONrPerformance_Measure_Texture( M3tPointScreen *vCoords, *curVCoord; UUtUns16 *vShades, *curVShade; M3tTextureCoord* vTextureCoords, *curVTextureCoord; - + //unsigned long startTimeHi, startTimeLo, stopTimeHi, stopTimeLo; //double elapsedTime; float offset; M3tTextureMap *myTexture; UUtError error; - + { char objectIndex; - + for(objectIndex = '0'; objectIndex <= '9'; objectIndex++) { error = @@ -312,7 +312,7 @@ ONrPerformance_Measure_Texture( } } UUmError_ReturnOnError(error); - + #if 0 for(x = 0; x < 256; x++) { @@ -324,27 +324,27 @@ ONrPerformance_Measure_Texture( } } #endif - + { M3tPointScreen vc[4]; UUtUns16 vs[4]; M3tTextureCoord vt[4]; - + vs[0] = vs[1] = vs[2] = vs[3] = 0xFFFF; - + vc[0].x = 0.0; vc[0].y = 0.0; vc[0].z = 0.5; vc[0].invW = 1.0f / vc[0].z; - + vt[0].u = 0; vt[0].v = 1 << 8; - + vc[1].x = 0.0; vc[1].y = 256.0; vc[1].z = 0.5; vc[1].invW = 1.0f / vc[1].z; - + vt[1].u = 0; vt[1].v = 0; @@ -352,7 +352,7 @@ ONrPerformance_Measure_Texture( vc[2].y = 0.0; vc[2].z = 0.5; vc[2].invW = 1.0f / vc[2].z; - + vt[2].u = 1 << 8; vt[2].v = 1 << 8; @@ -360,7 +360,7 @@ ONrPerformance_Measure_Texture( vc[3].y = 256.0; vc[3].z = 0.5; vc[3].invW = 1.0f / vc[3].z; - + vt[3].u = 1 << 8; vt[3].v = 0; @@ -374,7 +374,7 @@ ONrPerformance_Measure_Texture( M3rDraw_State_SetPtr(drawContext, M3cDrawStatePtrType_ScreenShadeArray_DC, vs); M3rDraw_State_SetPtr(drawContext, M3cDrawStatePtrType_TextureCoordArray, vt); M3rDraw_State_SetPtr(drawContext, M3cDrawStatePtrType_BaseTextureMap, myTexture); - + M3rDraw_TriInterpolate( drawContext, 0, @@ -393,20 +393,20 @@ ONrPerformance_Measure_Texture( return UUcError_Generic; } } - - + + vCoords = (M3tPointScreen *)UUrMemory_Block_New(sizeof(M3tPointScreen) * 320 * 240); - + UUmAssert(vCoords != NULL); - + vShades = (UUtUns16 *)UUrMemory_Block_New(sizeof(UUtUns16) * 320 * 240); - + UUmAssert(vShades != NULL); - + vTextureCoords = (M3tTextureCoord*)UUrMemory_Block_New(sizeof(M3tTextureCoord) * 320 * 240); - + UUmAssert(vTextureCoords != NULL); - + for(offset = 0.0f; offset <= 1.0f; offset += 0.1f) { for(triWidth = 10; triWidth <= 25; triWidth += 2) @@ -415,7 +415,7 @@ ONrPerformance_Measure_Texture( { numXTris = 638 / triWidth; numYTris = 478 / triHeight; - + for(x = 0; x < numXTris; x++) { for(y = 0; y < numYTris; y++) @@ -423,21 +423,21 @@ ONrPerformance_Measure_Texture( curVCoord = vCoords + y * numXTris + x; curVShade = vShades + y * numXTris + x; curVTextureCoord = vTextureCoords + y * numXTris + x; - + curVCoord->x = (float)x * (float)(triWidth) + offset; curVCoord->y = (float)y * (float)(triHeight) + offset; curVCoord->z = 0.5; curVCoord->invW = 1.0f / curVCoord->z; - + *curVShade = ((x & 1 ? 0 : 0x1F) << 10) | (0x1F << 5) | (y & 1 ? 0 : 0x1F); - + // NOTE: if something breaks around here I added this cast without // looking at the code - Michael Evans curVTextureCoord->u = (float) (x & 1 ? 0 : 255); curVTextureCoord->v = (float) (y & 1 ? 0 : 255); } } - + if(M3rFrame_Start(drawContext) != UUcError_None) { UUrError_Report(UUcError_Generic, "Could not start frame"); @@ -448,7 +448,7 @@ ONrPerformance_Measure_Texture( M3rDraw_State_SetPtr(drawContext, M3cDrawStatePtrType_ScreenShadeArray_DC, vShades); M3rDraw_State_SetPtr(drawContext, M3cDrawStatePtrType_TextureCoordArray, vTextureCoords); M3rDraw_State_SetPtr(drawContext, M3cDrawStatePtrType_BaseTextureMap, myTexture); - + //get604Time(&startTimeHi,&startTimeLo); for(x = 0; x < numXTris - 1; x ++) @@ -478,32 +478,32 @@ ONrPerformance_Measure_Texture( //elapsedTime *= 0x10000; //elapsedTime *= 0x10000; //elapsedTime += (stopTimeLo - startTimeLo); - + numTris[triWidth / 2 - 1][triHeight / 2 - 1] = numXTris * numYTris * 2; // time[triWidth / 2 - 1][triHeight / 2 - 1] = elapsedTime / getTimeBaseMhz(); - + if(M3rFrame_End(drawContext) != UUcError_None) { UUrError_Report(UUcError_Generic, "Could not start frame"); return UUcError_Generic; } - + } } } - + if(0) { FILE *file; - + file = UUrFOpen("triRasterPerf.out", "wb"); fprintf(file, "triWidth\ttriHeight\tnumTris\tframeTime\t|\ttrisPerSec\tpixelsPerSec"UUmNL); - + for(x = 0; x < 25; x++) { for(y = 0; y < 25; y++) { - fprintf(file, "%8d\t%9d\t%7d\t%9f\t|\t%10f\t\t%f"UUmNL, + fprintf(file, "%8d\t%9d\t%7d\t%9f\t|\t%10f\t\t%f"UUmNL, x * 2 + 2, y * 2 + 2, numTris[x][y], @@ -512,13 +512,13 @@ ONrPerformance_Measure_Texture( (double)((x * 2 + 2) * (y * 2 + 2) * numTris[x][y]) / (time[x][y] * 2.0)); } } - + fclose(file); } - + UUrMemory_Block_Delete(vCoords); UUrMemory_Block_Delete(vShades); #endif return UUcError_None; } -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_Performance.h b/OniProj/OniGameSource/Oni_Performance.h index 39b34bd..9e23a2e 100644 --- a/OniProj/OniGameSource/Oni_Performance.h +++ b/OniProj/OniGameSource/Oni_Performance.h @@ -2,13 +2,13 @@ /* FILE: Oni_Performance.h - + AUTHOR: Brent H. Pease - + CREATED: April 2, 1997 - + PURPOSE: main .c file for Oni - + Copyright 1997 */ diff --git a/OniProj/OniGameSource/Oni_Persistance.c b/OniProj/OniGameSource/Oni_Persistance.c index 8b6b2a2..5cd9dbd 100644 --- a/OniProj/OniGameSource/Oni_Persistance.c +++ b/OniProj/OniGameSource/Oni_Persistance.c @@ -1,12 +1,12 @@ /* FILE: Oni_Persistance.c - + AUTHOR: Michael Evans - + CREATED: June 19, 2000 - + PURPOSE: Persistant data storage - + Copyright (c) Microsoft */ @@ -47,7 +47,7 @@ typedef struct ONtPersistance UUtUns32 item_bit_field; UUtUns32 max_diary_level; UUtUns32 max_diary_page; - + // game options ONtGraphicsQuality quality; float overall_volume; @@ -58,7 +58,7 @@ typedef struct ONtPersistance ONtPlace place; ONtContinue continues[ONcPersist_NumLevels][ONcPersist_NumContinues]; // we save up to 20 levels and 10 continues per level - + } ONtPersistance; static ONtPersistance ONgPersistance; @@ -99,7 +99,7 @@ void ONrPersistance_Initialize(void) BFtFile *stream; UUtError error; UUtBool invalid_file; - + stream = BFrFile_FOpen(ONcPersistance_FileName, "r"); invalid_file = (NULL == stream); @@ -111,7 +111,7 @@ void ONrPersistance_Initialize(void) invalid_file = invalid_file || (UUcError_None != error); invalid_file = invalid_file || (ONcPersistance_Version != ONgPersistance.version); invalid_file = invalid_file || (ONcPersistance_SwapCode != ONgPersistance.swap_code); - + if (invalid_file) { UUrMemory_Clear(&ONgPersistance, sizeof(ONgPersistance)); ONgPersistance.version = ONcPersistance_Version; @@ -242,7 +242,7 @@ void ONrPersist_SetOverallVolume(float inVolume) ONrPersist(); SS2rVolume_Set(inVolume); - + return; } @@ -270,7 +270,7 @@ void ONrPersist_SetInvertMouseOn(UUtBool inOn) } ONrPersist(); - + return; } @@ -468,6 +468,6 @@ void ONrPersist_MarkWonGame(void) UUtBool ONrPersist_GetWonGame(void) { UUtBool has_won_game = (ONgPersistance.option_flags & ONcOptionFlag_WonGame) > 0; - + return has_won_game; } diff --git a/OniProj/OniGameSource/Oni_Persistance.h b/OniProj/OniGameSource/Oni_Persistance.h index 3d60603..44b02ad 100644 --- a/OniProj/OniGameSource/Oni_Persistance.h +++ b/OniProj/OniGameSource/Oni_Persistance.h @@ -1,13 +1,13 @@ #pragma once /* FILE: Oni_Persistance.h - + AUTHOR: Michael Evans - + CREATED: June 19, 2000 - + PURPOSE: Persistant data storage - + Copyright (c) Microsoft */ diff --git a/OniProj/OniGameSource/Oni_Platform.h b/OniProj/OniGameSource/Oni_Platform.h index 999ad9d..9bf85d3 100644 --- a/OniProj/OniGameSource/Oni_Platform.h +++ b/OniProj/OniGameSource/Oni_Platform.h @@ -2,13 +2,13 @@ /* FILE: Oni_Platform.h - + AUTHOR: Brent H. Pease - + CREATED: April 2, 1997 - + PURPOSE: platform header file - + Copyright 1997 */ @@ -40,14 +40,14 @@ typedef struct ONtPlatformData { UUtAppInstance appInstance; UUtWindow gameWindow; - + #if defined(DEBUGGING) && DEBUGGING - + UUtWindow akiraWindow; UUtWindow debugWindow; - + #endif - + } ONtPlatformData; // data is in Oni.c @@ -61,7 +61,7 @@ void ONrPlatform_Terminate( void ONrPlatform_Update( void); - + void ONrPlatform_ErrorHandler( UUtError theError, char *debugDescription, @@ -71,6 +71,6 @@ void ONrPlatform_ErrorHandler( UUtBool ONrPlatform_IsForegroundApp( void); - + #endif /* ONI_PLATFORM_H */ diff --git a/OniProj/OniGameSource/Oni_Script.c b/OniProj/OniGameSource/Oni_Script.c index 3237179..7da2e00 100644 --- a/OniProj/OniGameSource/Oni_Script.c +++ b/OniProj/OniGameSource/Oni_Script.c @@ -1,12 +1,12 @@ /* FILE: Oni_Script.c - + AUTHOR: Brent H. Pease - + CREATED: Nov 13, 1999 - + PURPOSE: - + Copyright 1997, 1998 */ @@ -48,7 +48,7 @@ ONiScript_LoadDirectory( BFtFileRef curFileRef; UUrMemory_Clear(&curFileRef, sizeof(curFileRef)); - + error = BFrDirectory_FileIterator_New( inDirectoryRef, @@ -56,23 +56,23 @@ ONiScript_LoadDirectory( ".bsl", &fileIterator); if(error != UUcError_None) goto abort; - + while(1) { error = BFrDirectory_FileIterator_Next(fileIterator, &curFileRef); if(error != UUcError_None) break; - + error = BFrFileRef_LoadIntoMemory(&curFileRef, &length, &textFile); if(error != UUcError_None) goto abort; - + error = SLrScript_Database_Add(BFrFileRef_GetLeafName(&curFileRef), textFile); if(error != UUcError_None) goto abort; - + UUrMemory_Block_Delete(textFile); } - + BFrDirectory_FileIterator_Delete(fileIterator); - + return UUcError_None; abort: @@ -93,7 +93,7 @@ ONiScript_Reload( UUtError error; BFtFileRef levelRef; char buffer[256]; - + SLrScript_Database_Reset(); levelRef = TMgDataFolderRef; @@ -107,7 +107,7 @@ ONiScript_Reload( COrConsole_Printf("Could not find \"%s\" IGMD directory", ONgScript_LevelName); return UUcError_None; } - + // load all script files error = ONiScript_LoadDirectory(&levelRef); if(error != UUcError_None) @@ -115,7 +115,7 @@ ONiScript_Reload( COrConsole_Printf("Could not load \"%s\" IGMD directory", ONgScript_LevelName); return UUcError_None; } - + return UUcError_None; } @@ -124,7 +124,7 @@ ONrScript_Initialize( void) { UUtError error; - + error = SLrScript_Command_Register_Void( "script_reload", @@ -132,7 +132,7 @@ ONrScript_Initialize( "", ONiScript_Reload); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -151,7 +151,7 @@ ONrScript_LevelBegin( SLrScript_LevelBegin(); ONgScript_LevelName = inLevelName; - + ONgScript_StaticParameterBaseOverflowed = UUcFalse; ONgScript_NextStaticParameterOffset = 0; UUrMemory_Clear(&ONgScript_StaticParameterBase, ONcScript_StaticParameterSize); diff --git a/OniProj/OniGameSource/Oni_Script.h b/OniProj/OniGameSource/Oni_Script.h index 6c1f06f..c7ff906 100644 --- a/OniProj/OniGameSource/Oni_Script.h +++ b/OniProj/OniGameSource/Oni_Script.h @@ -1,13 +1,13 @@ #pragma once /* FILE: Oni_Script.h - + AUTHOR: Brent H. Pease - + CREATED: Nov 13, 1999 - + PURPOSE: - + Copyright 1997, 1998 */ diff --git a/OniProj/OniGameSource/Oni_Sky.c b/OniProj/OniGameSource/Oni_Sky.c index ec91202..2fc5fa0 100644 --- a/OniProj/OniGameSource/Oni_Sky.c +++ b/OniProj/OniGameSource/Oni_Sky.c @@ -1,11 +1,11 @@ /* FILE: Oni_Sky.c - + AUTHOR: Jason Duncan - + CREATED: May, 2000 - + PURPOSE: the sky - + Copyright 2000 */ @@ -94,7 +94,7 @@ UUtError ONrSky_Initialize( ) static void ONiSky_GetYIQ( float r, float g, float b, M3tVector3D *ioYIQ ) { M3tPoint3D color; - static M3tMatrix3x3 m = + static M3tMatrix3x3 m = { 0.30f, 0.60f, 0.21f, 0.59f, -0.28f, -0.52f, 0.11f, -0.32f, -0.31f }; color.x = r; @@ -120,7 +120,7 @@ static void ONiSky_TextureCoords( float inU, float inV, M3tTextureCoord *ioCoord { inU = UUmPin( inU, -1000.0f, 1000.0f ); inV = UUmPin( inV, -1000.0f, 1000.0f ); - + ioCoord->u = (( inU + 1000.0f ) / 2000.0f); ioCoord->v = -(( inV - 1000.0f ) / 2000.0f); } @@ -133,29 +133,29 @@ UUtBool ONiSky_LinePlaneIntersection( { float Xm,Ym,Zm,denom,t; M3tPoint3D newPoint; - + Xm = (inLineB->x - inLineA->x); Ym = (inLineB->y - inLineA->y); Zm = (inLineB->z - inLineA->z); - + denom = inPlane->a * Xm +inPlane->b * Ym + inPlane->c * Zm; - + if (denom == 0.0f) { return UUcFalse; } - + t = -(inPlane->a * inLineA->x + inPlane->b * inLineA->y + inPlane->c * inLineA->z + inPlane->d) / denom; if (t < 0.0f || t > 1.0f) { return UUcFalse; } - + newPoint.x = Xm * t + inLineA->x; newPoint.y = Ym * t + inLineA->y; newPoint.z = Zm * t + inLineA->z; - + if (outIntersection) *outIntersection = newPoint; return UUcTrue; } @@ -190,13 +190,13 @@ static void ONiSky_SkyboxIntercept( M3tPoint3D *inPoint, M3tPoint3D *inCenter, M UUmTrig_Clip( theta_horiz ); quarter_pi = M3cPi / 4.0f; - + point_to.x = inPoint->x + ray.x * 10000.0f; point_to.y = inPoint->y + ray.y * 10000.0f; point_to.z = inPoint->z + ray.z * 10000.0f; point_to = *inPoint; - + side_plane.a = 0; side_plane.b = 0; side_plane.c = 0; @@ -243,7 +243,7 @@ static void ONiSky_SkyboxIntercept( M3tPoint3D *inPoint, M3tPoint3D *inCenter, M if( dist_side > dist_top ) { hit_point = top_hit_point; - plane = M3cSkyTop; + plane = M3cSkyTop; } } @@ -254,14 +254,14 @@ static void ONiSky_SkyboxIntercept( M3tPoint3D *inPoint, M3tPoint3D *inCenter, M break; case M3cSkyRight: // east ONiSky_TextureCoords( hit_point.z, hit_point.y, ioCoords ); - break; + break; case M3cSkyFront: // north ONiSky_TextureCoords( -hit_point.x, hit_point.y, ioCoords ); break; case M3cSkyBack: // south ONiSky_TextureCoords( hit_point.x, hit_point.y, ioCoords ); break; - case M3cSkyTop: // up + case M3cSkyTop: // up ONiSky_TextureCoords( hit_point.x, hit_point.z, ioCoords ); break; } @@ -327,7 +327,7 @@ UUtError ONrSky_LevelBegin( ONtSky *inSky, ONtSkyClass *inSkyClass ) // grab view distance M3rCamera_GetStaticData( ONgActiveCamera, NULL, NULL, &view_distance_near, &view_distance_far); - + radius = view_distance_far * 0.5f; // inSky->skyClass->sunglow->baseMap->flags |= M3cTextureFlags_Blend_Additive; // TMrInstance_GetDataPtr(M3cTemplate_TextureMap, "caution01", (void **) &inSky->skyClass->skydome->baseMap); @@ -335,7 +335,7 @@ UUtError ONrSky_LevelBegin( ONtSky *inSky, ONtSkyClass *inSkyClass ) M3rDraw_CreateSkybox( &inSky->skybox, inSkyClass->skybox ); ONgSky_Height = ONgLevel->sky_height; - + if( inSkyClass->star_count ) { if( inSkyClass->star_seed ) @@ -356,7 +356,7 @@ UUtError ONrSky_LevelBegin( ONtSky *inSky, ONtSkyClass *inSkyClass ) float scale = UUmRandomRangeFloat( 10.0f, 40.0f ); P3rGetRandomUnitVector3D(&position); - + if( position.y < 0.0f ) position.y = -position.y; @@ -365,7 +365,7 @@ UUtError ONrSky_LevelBegin( ONtSky *inSky, ONtSkyClass *inSkyClass ) position.z *= radius; height = ONgSky_Height * 1000.0f; - + //center.y += height; //position.y += height; @@ -403,12 +403,12 @@ UUtError ONrSky_LevelBegin( ONtSky *inSky, ONtSkyClass *inSkyClass ) star_sprites[star_sprite_count].alpha = (UUtUns8)alpha; star_sprite_count++; } - } + } inSky->star_sprite_array = (M3tSpriteArray*)UUrMemory_Block_New( sizeof(M3tSpriteArray) + sizeof(M3tSpriteInstance) * (star_sprite_count-1) ); inSky->star_sprite_array->texture_map = inSkyClass->star_textures[0]; inSky->star_sprite_array->sprite_count = star_sprite_count; - + for( i = 0; i < star_sprite_count; i++ ) { inSky->star_sprite_array->sprites[i].position = star_sprites[i].position; @@ -419,14 +419,14 @@ UUtError ONrSky_LevelBegin( ONtSky *inSky, ONtSkyClass *inSkyClass ) UUrMemory_Block_Delete( star_sprites ); - inSky->twinkle_count = star_sprite_count; + inSky->twinkle_count = star_sprite_count; inSky->twinkle_indices = UUrMemory_Block_New( sizeof( UUtUns16 ) * inSky->twinkle_count ); for( i = 0; i < inSky->twinkle_count; i++ ) { inSky->twinkle_indices[i] = UUmRandomRange( 0, (1024 * 16) - 1 ); } } - + for (i = 0; i < inSkyClass->num_planets; i++) { float planet_distance; @@ -441,7 +441,7 @@ UUtError ONrSky_LevelBegin( ONtSky *inSky, ONtSkyClass *inSkyClass ) offset_vector = inSky->planet_position[i]; MUmVector_Normalize( offset_vector ); - + inSky->flare.cutoff_angle = 0.6f; inSky->flare.falloff_angle = 0.3f; inSky->flare.cosine_cutoff_angle = (float) cos( inSky->flare.cutoff_angle ); @@ -464,7 +464,7 @@ UUtError ONrSky_LevelBegin( ONtSky *inSky, ONtSkyClass *inSkyClass ) inSkyClass->lens_flare->flags |= M3cTextureFlags_Blend_Additive; - // FIXME: find better points + // FIXME: find better points // build 2d visiblity test points { int j; @@ -548,8 +548,8 @@ void ONrSky_Draw( ONtSky *inSky ) inSky->star_sprite_array->sprites[i].alpha = (UUtUns8) MUrUnsignedSmallFloat_To_Uns_Round( (max_alpha*0.25f) + (ONgSky_NoiseTable[noise_index] * (max_alpha*0.75f))); } - - + + inSky->skybox.height = ONgSky_Height; inSky->skybox.height = 0.0f; @@ -631,7 +631,7 @@ void ONrSky_DrawLensFlare( ONtSky* inSky ) MUmVector_Normalize( eye_to_light_vector ); - direction_dot_radius = MUrVector_DotProduct( &CAgCamera.viewData.viewVector, &eye_to_light_vector ); + direction_dot_radius = MUrVector_DotProduct( &CAgCamera.viewData.viewVector, &eye_to_light_vector ); if (direction_dot_radius < inSky->flare.cosine_cutoff_angle) { alpha = 0; @@ -655,7 +655,7 @@ void ONrSky_DrawLensFlare( ONtSky* inSky ) float delta; float delta_per_tick; delta = alpha - inSky->flare.alpha; - if( delta > 0 ) + if( delta > 0 ) { delta_per_tick = 75.0f; alpha = UUmMin( alpha, inSky->flare.alpha + delta_per_tick * ticks ); diff --git a/OniProj/OniGameSource/Oni_Sky.h b/OniProj/OniGameSource/Oni_Sky.h index 1717818..3b75e0c 100644 --- a/OniProj/OniGameSource/Oni_Sky.h +++ b/OniProj/OniGameSource/Oni_Sky.h @@ -1,11 +1,11 @@ /* FILE: Oni_Sky.h - + AUTHOR: Quinn Dunki - + CREATED: April 2, 1999 - + PURPOSE: control of sky in ONI - + Copyright 1998 */ @@ -57,7 +57,7 @@ typedef struct ONtSkyFlare typedef struct ONtSky { ONtSkyClass *sky_class; - + M3tPoint3D planet_position[ONcSky_MaxPlanets]; M3tSpriteArray *star_sprite_array; diff --git a/OniProj/OniGameSource/Oni_Sound.c b/OniProj/OniGameSource/Oni_Sound.c index 2c646a7..0dd41b2 100644 --- a/OniProj/OniGameSource/Oni_Sound.c +++ b/OniProj/OniGameSource/Oni_Sound.c @@ -40,7 +40,7 @@ #define OScGroupWriteSize(num_perms) \ (sizeof(OStItem) + sizeof(UUtUns32) + (OScPermutationWriteSize * num_perms)) /* OStItem + num_permutations + permutations */ - + // ====================================================================== // enums // ====================================================================== @@ -59,7 +59,7 @@ struct OStItem UUtUns32 id; UUtUns32 category_id; char name[OScMaxNameLength]; - + }; // ---------------------------------------------------------------------- @@ -75,9 +75,9 @@ struct OStCollection { OStCollectionType type; UUtUns32 flags; - + UUtMemory_Array *categories; - + OStItemDeleteProc item_delete_proc; UUtMemory_Array *items; }; @@ -87,7 +87,7 @@ typedef struct OStPlayingAmbient { const OBJtObject *object; SStPlayID play_id; - + } OStPlayingAmbient; // ---------------------------------------------------------------------- @@ -95,7 +95,7 @@ typedef struct OStPlayingMusic { SStPlayID play_id; char name[OScMaxNameLength]; - + } OStPlayingMusic; // ====================================================================== @@ -127,13 +127,13 @@ OSiCollection_GetNextCategoryID( OStCategory *categories; UUtUns32 i; UUtUns32 next_category_id; - + // get the number of categories num_categories = UUrMemory_Array_GetUsedElems(inCollection->categories); - + // get a pointer to the categories categories = (OStCategory*)UUrMemory_Array_GetMemory(inCollection->categories); - + // search for the next available category id next_category_id = 1; while(1) @@ -146,18 +146,18 @@ OSiCollection_GetNextCategoryID( break; } } - + // if all the category ids were checked and none matched next_category_id // then stop looking if (i == num_categories) { break; } - + // increment next_category_id and search again next_category_id++; } - + return next_category_id; } @@ -189,7 +189,7 @@ OSiCollections_AddType( OStCollection *collections; UUtUns32 i; UUtUns32 num_elements; - + // get a pointer to the array memory collections = (OStCollection*)UUrMemory_Array_GetMemory(OSgCollections); if (collections != NULL) @@ -201,17 +201,17 @@ OSiCollections_AddType( if (collections[i].type == inType) { return UUcError_Generic; } } } - + // get a new element from the array error = UUrMemory_Array_GetNewElement(OSgCollections, &index, &mem_moved); UUmError_ReturnOnError(error); - + // if the memory moved, get another pointer to the collections if (mem_moved) { collections = (OStCollection*)UUrMemory_Array_GetMemory(OSgCollections); } - + // initialize the new collection collections[index].type = inType; collections[index].flags = OScCollectionFlag_None; @@ -231,7 +231,7 @@ OSiCollections_AddType( UUmError_ReturnOnNull(collections[index].categories); UUmError_ReturnOnNull(collections[index].items); - + return UUcError_None; } @@ -248,7 +248,7 @@ OSiCollections_Initialize( 0, 3); UUmError_ReturnOnNull(OSgCollections); - + return UUcError_None; } @@ -261,14 +261,14 @@ OSiCollections_Terminate( if (OSgCollections) { OStCollection *collections; - + // get a pointer to the collections collections = UUrMemory_Array_GetMemory(OSgCollections); if (collections != NULL) { UUtUns32 i; UUtUns32 num_collections; - + num_collections = UUrMemory_Array_GetUsedElems(OSgCollections); for (i = 0; i < num_collections; i++) { @@ -276,13 +276,13 @@ OSiCollections_Terminate( OStItem *items; UUtUns32 j; UUtUns32 num_items; - + // get a pointer to the collection collection = &collections[i]; - + // delete the categories array UUrMemory_Array_Delete(collection->categories); - + // delete all of the items' data items = (OStItem*)UUrMemory_Array_GetMemory(collection->items); num_items = UUrMemory_Array_GetUsedElems(collection->items); @@ -290,12 +290,12 @@ OSiCollections_Terminate( { collection->item_delete_proc(items[j].id); } - + // delte the items array UUrMemory_Array_Delete(collection->items); } } - + // delete the collection array UUrMemory_Array_Delete(OSgCollections); OSgCollections = NULL; @@ -379,14 +379,14 @@ OSiCollection_CalcMemoryUsed( UUtUns32 num_items; UUtUns32 bytes_used; UUtUns32 i; - + bytes_used = 0; - + // Add the categories bytes_used += ((sizeof(UUtUns8) * 4) + sizeof(UUtUns32) + sizeof(OStCategory))* UUrMemory_Array_GetUsedElems(inCollection->categories); - + // Add the items num_items = UUrMemory_Array_GetUsedElems(inCollection->items); bytes_used += ((sizeof(UUtUns8) * 4) + sizeof(UUtUns32)) * num_items; @@ -398,22 +398,22 @@ OSiCollection_CalcMemoryUsed( { OStItem *item; SStGroup *group; - + item = OSrCollection_Item_GetByIndex(inCollection, i); group = SSrGroup_GetByID(OSrItem_GetID(item)); - + bytes_used += OScGroupWriteSize(UUrMemory_Array_GetUsedElems(group->permutations)); } } break; - + case OScCollectionType_Impulse: for (i = 0; i < num_items; i++) { bytes_used += OScImpulseWriteSize; } break; - + case OScCollectionType_Ambient: for (i = 0; i < num_items; i++) { @@ -421,14 +421,14 @@ OSiCollection_CalcMemoryUsed( } break; } - + return bytes_used; } // ---------------------------------------------------------------------- static UUtError OSiCollection_Category_CreateFromBuffer( - OStCollection *ioCollection, + OStCollection *ioCollection, UUtUns32 inVersion, UUtBool inSwapIt, UUtUns8 *inBuffer, @@ -440,19 +440,19 @@ OSiCollection_Category_CreateFromBuffer( char *name; UUtUns32 temp_id; OStCategory *category; - + // init the returning value *outNumBytesRead = 0; - + // read the OStCategory OBDmGet4BytesFromBuffer(inBuffer, id, UUtUns32, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, parent_id, UUtUns32, inSwapIt); name = (char*)inBuffer; inBuffer += OScMaxNameLength; - + // make sure no other categories exist with this id category = OSrCollection_Category_GetByID(ioCollection, id); if (category != NULL) { return UUcError_Generic; } - + // add the category to the collection error = OSrCollection_Category_New( @@ -464,7 +464,7 @@ OSiCollection_Category_CreateFromBuffer( { OSrCollection_Category_Delete(ioCollection, temp_id); } - + // get a pointer to the new category category = OSrCollection_Category_GetByID(ioCollection, temp_id); if (category == NULL) @@ -472,13 +472,13 @@ OSiCollection_Category_CreateFromBuffer( UUmAssert(!"This should never happen"); return UUcError_Generic; } - + // set the category's id category->id = id; - + // set the number of bytes read *outNumBytesRead = sizeof(OStCategory); - + return UUcError_None; } @@ -493,9 +493,9 @@ OSrCollection_Category_Delete( UUtUns32 i; UUtUns32 num_categories; UUtUns32 num_items; - + if ((ioCollection->flags & OScCollectionFlag_Locked) != 0) { return; } - + // delete the category with inCategoryID categories = (OStCategory*)UUrMemory_Array_GetMemory(ioCollection->categories); num_categories = UUrMemory_Array_GetUsedElems(ioCollection->categories); @@ -510,7 +510,7 @@ OSrCollection_Category_Delete( OSrCollection_Category_Delete(ioCollection, categories[i].id); } } - + // delete the items in the category items = (OStItem*)UUrMemory_Array_GetMemory(ioCollection->items); num_items = UUrMemory_Array_GetUsedElems(ioCollection->items); @@ -540,13 +540,13 @@ OSrCollection_Category_GetByID( OStCategory *category; UUtUns32 i; UUtUns32 num_elements; - + UUmAssert(inCollection); - + // get the category array categories = (OStCategory*)UUrMemory_Array_GetMemory(inCollection->categories); if (categories == NULL) { return NULL; } - + // find the category with inCategoryID in the array category = NULL; num_elements = UUrMemory_Array_GetUsedElems(inCollection->categories); @@ -558,7 +558,7 @@ OSrCollection_Category_GetByID( break; } } - + return category; } @@ -571,17 +571,17 @@ OSrCollection_Category_GetByIndex( OStCategory *categories; UUmAssert(inCollection); - + // make sure inCategoryIndex is in range if (inCategoryIndex >= UUrMemory_Array_GetUsedElems(inCollection->categories)) { return NULL; } - + // get a pointer to the categories array categories = (OStCategory*)UUrMemory_Array_GetMemory(inCollection->categories); if (categories == NULL) { return NULL; } - + // return the categery return &categories[inCategoryIndex]; } @@ -600,21 +600,21 @@ OSrCollection_Category_New( UUtUns32 index; UUtBool mem_moved; UUtUns32 num_categories; - + UUmAssert(ioCollection); UUmAssert(inCategoryName && (inCategoryName[0] != '\0')); - + if ((ioCollection->flags & OScCollectionFlag_Locked) != 0) { return UUcError_Generic; } *outCategoryID = UUcMaxUns32; - + num_categories = UUrMemory_Array_GetUsedElems(ioCollection->categories); if (num_categories > 0) { // get a pointer to the array's memory categories = (OStCategory*)UUrMemory_Array_GetMemory(ioCollection->categories); UUmAssert(categories); - + // if this category name already exists in the parent category, then // return its id number for (i = 0; i < num_categories; i++) @@ -626,25 +626,25 @@ OSrCollection_Category_New( } } } - + // add the item to the categories array error = UUrMemory_Array_GetNewElement(ioCollection->categories, &index, &mem_moved); UUmError_ReturnOnError(error); - + // get a pointer to the array's memory categories = (OStCategory*)UUrMemory_Array_GetMemory(ioCollection->categories); UUmAssert(categories); - + // initialize the category categories[index].parent_id = inParentCategoryID; categories[index].id = OSiCollection_GetNextCategoryID(ioCollection); UUrString_Copy(categories[index].name, inCategoryName, BFcMaxFileNameLength); - + *outCategoryID = categories[index].id; - + // the collection is now dirty ioCollection->flags |= OScCollectionFlag_Dirty; - + return UUcError_None; } @@ -657,28 +657,28 @@ OSrCollection_Category_SetName( { OStCategory *category; UUtUns32 num_categories; - + UUmAssert(ioCollection); UUmAssert(inCategoryName); - + // make sure the item can be changed if ((ioCollection->flags & OScCollectionFlag_Locked) != 0) { return UUcError_Generic; } - + // get a pointer to the category category = OSrCollection_Category_GetByID(ioCollection, inCategoryID); if (category == NULL) { return UUcError_None; } - + // make sure that no other categories with this name exist num_categories = UUrMemory_Array_GetUsedElems(ioCollection->categories); if (num_categories > 0) { OStCategory *categories; UUtUns32 i; - + // get a pointer to the array's memory categories = (OStCategory*)UUrMemory_Array_GetMemory(ioCollection->categories); UUmAssert(categories); - + // if this category name already exists in the parent category, then // return its id number for (i = 0; i < num_categories; i++) @@ -695,10 +695,10 @@ OSrCollection_Category_SetName( // change the category name UUrString_Copy(category->name, inCategoryName, OScMaxNameLength); - + // the collection is now dirty ioCollection->flags |= OScCollectionFlag_Dirty; - + return UUcError_None; } @@ -713,7 +713,7 @@ OSiCollection_Category_WriteByIndex( OStCategory *category; UUtUns32 bytes_avail; UUtUns32 bytes_used; - + // make sure that inItemIndex is in range if (inCategoryIndex > UUrMemory_Array_GetUsedElems(ioCollection->categories)) { @@ -721,7 +721,7 @@ OSiCollection_Category_WriteByIndex( *ioNumBytes = 0; return; } - + // make sure there is enough room to write the category bytes_avail = *ioNumBytes; bytes_used = sizeof(OStCategory); @@ -731,17 +731,17 @@ OSiCollection_Category_WriteByIndex( *ioNumBytes = 0; return; } - + // get a pointer to the category category = OSrCollection_Category_GetByIndex(ioCollection, inCategoryIndex); - + // write the category OBDmWrite4BytesToBuffer(ioBuffer, category->id, UUtUns32, bytes_avail, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, category->parent_id, UUtUns32, bytes_avail, OBJcWrite_Little); UUrString_Copy((char*)ioBuffer, category->name, OScMaxNameLength); ioBuffer += OScMaxNameLength; bytes_avail -= OScMaxNameLength; - + // calculate the number of bytes written *ioNumBytes = *ioNumBytes - bytes_avail; UUmAssert(*ioNumBytes == bytes_used); @@ -755,7 +755,7 @@ OSiCollection_DeleteAll( OStItem *item_array; UUtUns32 i; UUtUns32 num_elements; - + // delete all of the items item_array = (OStItem*)UUrMemory_Array_GetMemory(ioCollection->items); num_elements = UUrMemory_Array_GetUsedElems(ioCollection->items); @@ -763,11 +763,11 @@ OSiCollection_DeleteAll( { ioCollection->item_delete_proc(item_array[i].id); } - + // delete the arrays UUrMemory_Array_Delete(ioCollection->categories); UUrMemory_Array_Delete(ioCollection->items); - + // allocate new arrays ioCollection->categories = UUrMemory_Array_New( @@ -784,7 +784,7 @@ OSiCollection_DeleteAll( UUmError_ReturnOnNull(ioCollection->categories); UUmError_ReturnOnNull(ioCollection->items); - + return UUcError_None; } @@ -796,18 +796,18 @@ OSrCollection_GetByType( OStCollection *collections; UUtUns32 i; UUtUns32 num_elements; - + // get a pointer to the collections collections = (OStCollection*)UUrMemory_Array_GetMemory(OSgCollections); if (collections == NULL) { return NULL; } - + // find a collection where type == inType num_elements = UUrMemory_Array_GetUsedElems(OSgCollections); for (i = 0; i < num_elements; i++) { if (collections[i].type == inCollectionType) { return &collections[i]; } } - + return NULL; } @@ -857,7 +857,7 @@ OSrCollection_IsLocked( // ---------------------------------------------------------------------- static UUtError OSiCollection_Item_CreateFromBuffer( - OStCollection *ioCollection, + OStCollection *ioCollection, UUtUns32 inVersion, UUtBool inSwapIt, UUtUns8 *inBuffer, @@ -868,21 +868,21 @@ OSiCollection_Item_CreateFromBuffer( UUtUns32 category_id; char *name; UUtUns32 bytes_read; - + // init the outgoing value *outNumBytesRead = 0; - + // read the OStItem OBDmGet4BytesFromBuffer(inBuffer, id, UUtUns32, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, category_id, UUtUns32, inSwapIt); name = (char*)inBuffer; inBuffer += OScMaxNameLength; - + bytes_read = sizeof(OStItem); - + // create the OStItem error = OSrCollection_Item_New(ioCollection, category_id, id, name); UUmError_ReturnOnError(error); - + // read the SSt____ data switch (OSrCollection_GetType(ioCollection)) { @@ -893,11 +893,11 @@ OSiCollection_Item_CreateFromBuffer( SStPermutation *perm_array; UUtUns32 i; SStGroup *group; - + // get the number of permutations OBDmGet4BytesFromBuffer(inBuffer, num_permutations, UUtUns32, inSwapIt); bytes_read += sizeof(UUtUns32); - + // create a memory array to hold the permutations permutations = UUrMemory_Array_New( @@ -906,7 +906,7 @@ OSiCollection_Item_CreateFromBuffer( num_permutations, num_permutations); UUmError_ReturnOnNull(permutations); - + // read the permutations perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(permutations); for (i = 0; i < num_permutations; i++) @@ -919,24 +919,24 @@ OSiCollection_Item_CreateFromBuffer( OBDmGet4BytesFromBuffer(inBuffer, perm_array[i].max_pitch_percent, float, inSwapIt); UUrString_Copy(perm_array[i].sound_data_name, (char*)inBuffer, BFcMaxFileNameLength); inBuffer += BFcMaxFileNameLength; - + // get a pointer to the sound buffer perm_array[i].sound_data = NULL; perm_array[i].sound_data = SSrSoundData_GetByName( perm_array[i].sound_data_name, UUcTrue); - + bytes_read += (sizeof(UUtUns32) * 5) + BFcMaxFileNameLength; } - + // create a new SStGroup error = SSrGroup_New(NULL, &group); UUmError_ReturnOnError(error); - + // dispose of the permutations array in the new group UUrMemory_Array_Delete(group->permutations); - + // set the fields of the group group->id = id; // group->played_sound = 0; @@ -948,7 +948,7 @@ OSiCollection_Item_CreateFromBuffer( } } break; - + case OScCollectionType_Impulse: { UUtUns32 impulse_sound_id; @@ -959,7 +959,7 @@ OSiCollection_Item_CreateFromBuffer( float min_vol_angle; float min_angle_attn; SStImpulse *impulse; - + // read the OStImpulse data OBDmGet4BytesFromBuffer(inBuffer, impulse_sound_id, UUtUns32, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, priority, SStPriority2, inSwapIt); @@ -968,13 +968,13 @@ OSiCollection_Item_CreateFromBuffer( OBDmGet4BytesFromBuffer(inBuffer, max_vol_angle, float, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, min_vol_angle, float, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, min_angle_attn, float, inSwapIt); - + bytes_read += sizeof(UUtUns32) + sizeof(SStPriority2) + (sizeof(float) * 5); - + // create a new SStImpulse error = SSrImpulse_New(NULL, &impulse); UUmError_ReturnOnError(error); - + // set the fields of the impulse sound impulse->id = id; impulse->impulse_sound = NULL; @@ -987,7 +987,7 @@ OSiCollection_Item_CreateFromBuffer( impulse->min_angle_attenuation = min_angle_attn; } break; - + case OScCollectionType_Ambient: { SStPriority2 priority; @@ -1003,7 +1003,7 @@ OSiCollection_Item_CreateFromBuffer( UUtUns32 in_sound_id; UUtUns32 out_sound_id; SStAmbient *ambient; - + // read the OStAmbient from the buffer OBDmGet4BytesFromBuffer(inBuffer, priority, SStPriority2, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, flags, UUtUns32, inSwapIt); @@ -1017,17 +1017,17 @@ OSiCollection_Item_CreateFromBuffer( OBDmGet4BytesFromBuffer(inBuffer, base_track2_id, UUtUns32, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, in_sound_id, UUtUns32, inSwapIt); OBDmGet4BytesFromBuffer(inBuffer, out_sound_id, UUtUns32, inSwapIt); - + bytes_read += (sizeof(SStPriority2) + sizeof(UUtUns32) + (sizeof(float) * 5) + (sizeof(UUtUns32) * 5)); - + // make a new SStAmbient error = SSrAmbient_New(NULL, &ambient); UUmError_ReturnOnError(error); - + // set the fields of the ambient sound ambient->id = id; ambient->priority = priority; @@ -1045,10 +1045,10 @@ OSiCollection_Item_CreateFromBuffer( } break; } - + // set the outgoing size *outNumBytesRead = bytes_read; - + return UUcError_None; } @@ -1061,13 +1061,13 @@ OSrCollection_Item_Delete( UUtUns32 i; OStItem *items; UUtUns32 num_elements; - + UUmAssert(ioCollection); - + // get a pointer to the items items = (OStItem*)UUrMemory_Array_GetMemory(ioCollection->items); if (items == NULL) { return; } - + // find the item in the items array and delete it num_elements = UUrMemory_Array_GetUsedElems(ioCollection->items); for (i = 0; i < num_elements; i++) @@ -1076,10 +1076,10 @@ OSrCollection_Item_Delete( { // delete the item ioCollection->item_delete_proc(inItemID); - + // delete the item from the items array UUrMemory_Array_DeleteElement(ioCollection->items, i); - + break; } } @@ -1097,13 +1097,13 @@ OSrCollection_Item_GetByID( UUtUns32 i; OStItem *items; UUtUns32 num_elements; - + UUmAssert(inCollection); - + // get a pointer to the items items = (OStItem*)UUrMemory_Array_GetMemory(inCollection->items); if (items == NULL) { return NULL; } - + // find the itme in the items array num_elements = UUrMemory_Array_GetUsedElems(inCollection->items); for (i = 0; i < num_elements; i++) @@ -1113,7 +1113,7 @@ OSrCollection_Item_GetByID( return &items[i]; } } - + return NULL; } @@ -1126,17 +1126,17 @@ OSrCollection_Item_GetByIndex( OStItem *items; UUmAssert(inCollection); - + // make sure inItemIndex is in range if (inItemIndex >= UUrMemory_Array_GetUsedElems(inCollection->items)) { return NULL; } - + // get a pointer to the items array items = (OStItem*)UUrMemory_Array_GetMemory(inCollection->items); if (items == NULL) { return NULL; } - + // return the item return &items[inItemIndex]; } @@ -1151,14 +1151,14 @@ OSrCollection_Item_GetByName( UUtUns32 num_items; OStItem *item_array; OStItem *found_item; - + found_item = NULL; num_items = UUrMemory_Array_GetUsedElems(inCollection->items); item_array = (OStItem*)UUrMemory_Array_GetMemory(inCollection->items); for (i = 0; i < num_items; i++) { UUtInt32 result; - + result = UUrString_Compare_NoCase(item_array[i].name, inItemName); if (result == 0) { @@ -1166,7 +1166,7 @@ OSrCollection_Item_GetByName( break; } } - + return found_item; } @@ -1184,10 +1184,10 @@ OSrCollection_Item_New( UUtUns32 index; UUtBool mem_moved; UUtUns32 num_items; - + UUmAssert(ioCollection); UUmAssert(inItemName); - + // check for an existing item with the same name num_items = UUrMemory_Array_GetUsedElems(ioCollection->items); if (num_items > 0) @@ -1195,34 +1195,34 @@ OSrCollection_Item_New( // get a pointer to the items array items = (OStItem*)UUrMemory_Array_GetMemory(ioCollection->items); UUmAssert(items); - + // if the item name already exists in the parent category, then return its id number for (i = 0; i < num_items; i++) { if ((items[i].category_id == inCategoryID) && (UUrString_Compare_NoCase(items[i].name, inItemName) == 0)) { - return UUcError_Generic; + return UUcError_Generic; } } } - + // add the item to the items array error = UUrMemory_Array_GetNewElement(ioCollection->items, &index, &mem_moved); UUmError_ReturnOnError(error); - + // get a pointer to the items array items = (OStItem*)UUrMemory_Array_GetMemory(ioCollection->items); UUmAssert(items); - + // initialize the item items[index].id = inItemID; items[index].category_id = inCategoryID; - UUrString_Copy(items[index].name, inItemName, OScMaxNameLength); - + UUrString_Copy(items[index].name, inItemName, OScMaxNameLength); + // the collection is now dirty ioCollection->flags |= OScCollectionFlag_Dirty; - + return UUcError_None; } @@ -1234,23 +1234,23 @@ OSrCollection_Item_SetName( const char *inItemName) { OStItem *item; - + UUmAssert(ioCollection); UUmAssert(inItemName); - + // make sure the item can be changed if ((ioCollection->flags & OScCollectionFlag_Locked) != 0) { return UUcError_Generic; } - + // get a pointer to the item item = OSrCollection_Item_GetByID(ioCollection, inItemID); if (item == NULL) { return UUcError_None; } - + // change the item name UUrString_Copy(item->name, inItemName, OScMaxNameLength); - + // the collection is now dirty ioCollection->flags |= OScCollectionFlag_Dirty; - + return UUcError_None; } @@ -1265,7 +1265,7 @@ OSiCollection_Item_WriteByIndex( OStItem *item; UUtUns32 bytes_avail; UUtUns32 bytes_used; - + // make sure that inItemIndex is in range if (inItemIndex > UUrMemory_Array_GetUsedElems(ioCollection->items)) { @@ -1273,10 +1273,10 @@ OSiCollection_Item_WriteByIndex( *ioNumBytes = 0; return; } - + // get a pointer to the item item = OSrCollection_Item_GetByIndex(ioCollection, inItemIndex); - + // write the SSt_____ data switch (OSrCollection_GetType(ioCollection)) { @@ -1286,13 +1286,13 @@ OSiCollection_Item_WriteByIndex( UUtUns32 num_permutations; SStPermutation *perm_array; UUtUns32 i; - + // get a pointer to the group group = SSrGroup_GetByID(item->id); - + // get the number of permutations num_permutations = UUrMemory_Array_GetUsedElems(group->permutations); - + // don't write into the buffer if there isn't enough space bytes_avail = *ioNumBytes; bytes_used = OScGroupWriteSize(num_permutations); @@ -1302,32 +1302,32 @@ OSiCollection_Item_WriteByIndex( *ioNumBytes = 0; return; } - + // write the OStItem OBDmWrite4BytesToBuffer(ioBuffer, item->id, UUtUns32, bytes_avail, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, item->category_id, UUtUns32, bytes_avail, OBJcWrite_Little); UUrString_Copy((char*)ioBuffer, item->name, OScMaxNameLength); ioBuffer += OScMaxNameLength; bytes_avail -= OScMaxNameLength; - + // write the number of permutations OBDmWrite4BytesToBuffer(ioBuffer, num_permutations, UUtUns32, bytes_avail, OBJcWrite_Little); - + // write the permutations perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(group->permutations); for (i = 0; i < num_permutations; i++) { SStPermutation *perm; - + perm = &perm_array[i]; - + // write the permutation OBDmWrite4BytesToBuffer(ioBuffer, perm->weight, UUtUns32, bytes_avail, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, perm->min_volume_percent, float, bytes_avail, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, perm->max_volume_percent, float, bytes_avail, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, perm->min_pitch_percent, float, bytes_avail, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, perm->max_pitch_percent, float, bytes_avail, OBJcWrite_Little); - + // write the SStSoundData's name UUrString_Copy( (char*)ioBuffer, @@ -1338,13 +1338,13 @@ OSiCollection_Item_WriteByIndex( } } break; - + case OScCollectionType_Impulse: { SStImpulse *impulse; - + impulse = SSrImpulse_GetByID(item->id); - + // don't write into the buffer if there isn't enough space bytes_avail = *ioNumBytes; bytes_used = OScImpulseWriteSize; @@ -1354,14 +1354,14 @@ OSiCollection_Item_WriteByIndex( *ioNumBytes = 0; return; } - + // write the item data OBDmWrite4BytesToBuffer(ioBuffer, item->id, UUtUns32, bytes_avail, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, item->category_id, UUtUns32, bytes_avail, OBJcWrite_Little); UUrString_Copy((char*)ioBuffer, item->name, OScMaxNameLength); ioBuffer += OScMaxNameLength; bytes_avail -= OScMaxNameLength; - + // write the impulse sound OBDmWrite4BytesToBuffer(ioBuffer, impulse->impulse_sound_id, UUtUns32, bytes_avail, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, impulse->priority, SStPriority2, bytes_avail, OBJcWrite_Little); @@ -1372,13 +1372,13 @@ OSiCollection_Item_WriteByIndex( OBDmWrite4BytesToBuffer(ioBuffer, impulse->min_angle_attenuation, float, bytes_avail, OBJcWrite_Little); } break; - + case OScCollectionType_Ambient: { SStAmbient *ambient; - + ambient = SSrAmbient_GetByID(item->id); - + // don't write into the buffer if there isn't enough space bytes_avail = *ioNumBytes; bytes_used = OScAmbientWriteSize; @@ -1388,14 +1388,14 @@ OSiCollection_Item_WriteByIndex( *ioNumBytes = 0; return; } - + // write the item data OBDmWrite4BytesToBuffer(ioBuffer, item->id, UUtUns32, bytes_avail, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, item->category_id, UUtUns32, bytes_avail, OBJcWrite_Little); UUrString_Copy((char*)ioBuffer, item->name, OScMaxNameLength); ioBuffer += OScMaxNameLength; bytes_avail -= OScMaxNameLength; - + // write the ambient sound OBDmWrite4BytesToBuffer(ioBuffer, ambient->priority, SStPriority2, bytes_avail, OBJcWrite_Little); OBDmWrite4BytesToBuffer(ioBuffer, ambient->flags, UUtUns32, bytes_avail, OBJcWrite_Little); @@ -1412,7 +1412,7 @@ OSiCollection_Item_WriteByIndex( } break; } - + *ioNumBytes = *ioNumBytes - bytes_avail; UUmAssert(*ioNumBytes == bytes_used); } @@ -1457,36 +1457,36 @@ OSiBinaryData_Load( UUtUns32 num_items; UUtUns32 i; UUtUns32 read_bytes; - + UUmAssert(inIdentifier); UUmAssert(ioBinaryData); - + buffer = ioBinaryData->data; buffer_size = ioBinaryData->header.data_size; - + // read the version number OBDmGet4BytesFromBuffer(buffer, version, UUtUns32, inSwapIt); - + // read the collection type OBDmGet4BytesFromBuffer(buffer, collection_type, OStCollectionType, inSwapIt); collection = OSrCollection_GetByType(collection_type); if (collection == NULL) { return UUcError_Generic; } - + // delete all current items in the collection OSiCollection_DeleteAll(collection); - + // read the number of categories OBDmGet4BytesFromBuffer(buffer, num_categories, UUtUns32, inSwapIt); - + // read the number of items OBDmGet4BytesFromBuffer(buffer, num_items, UUtUns32, inSwapIt); - + // process the categories for (i = 0; i < num_categories; i++) { UUtUns8 *cat_data; UUtUns32 cat_data_length; - + // find the tags error = UUrFindTagData( @@ -1497,28 +1497,28 @@ OSiBinaryData_Load( &cat_data, &cat_data_length); UUmError_ReturnOnError(error); - + // process the data chunk error = OSiCollection_Category_CreateFromBuffer( - collection, + collection, version, inSwapIt, cat_data, &read_bytes); UUmError_ReturnOnError(error); UUmAssert(read_bytes == cat_data_length); - + // advance to next data chunk buffer = cat_data + cat_data_length; } - + // process the items for (i = 0; i < num_items; i++) { UUtUns8 *item_data; UUtUns32 item_data_length; - + // find the tags error = UUrFindTagData( @@ -1529,35 +1529,35 @@ OSiBinaryData_Load( &item_data, &item_data_length); UUmError_ReturnOnError(error); - + // process the data chunk error = OSiCollection_Item_CreateFromBuffer( - collection, + collection, version, inSwapIt, item_data, &read_bytes); UUmError_ReturnOnError(error); UUmAssert(read_bytes == item_data_length); - + // advance to next data chunk buffer = item_data + item_data_length; } - + // update all of the pointers for the groups SSrImpulse_UpdateGroupPointers(SScInvalidID); SSrAmbient_UpdateGroupPointers(SScInvalidID); - + // set the locked and dirty flags collection->flags = OScCollectionFlag_None; if (inLocked) { collection->flags |= OScCollectionFlag_Locked; } - + if (inAllocated) { UUrMemory_Block_Delete(ioBinaryData); } - + return UUcError_None; } @@ -1568,12 +1568,12 @@ OSiBinaryData_Register( { UUtError error; BDtMethods methods; - + methods.rLoad = OSiBinaryData_Load; - + error = BDrRegisterClass(OScBinaryDataClass, &methods); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1585,7 +1585,7 @@ OSiBinaryData_Save( UUtUns32 i; OStCollection *collection_array; UUtUns32 num_elements; - + // save all of the collections collection_array = (OStCollection*)UUrMemory_Array_GetMemory(OSgCollections); num_elements = UUrMemory_Array_GetUsedElems(OSgCollections); @@ -1603,15 +1603,15 @@ OSiBinaryData_Save( UUtUns32 temp_num_bytes; UUtUns32 bytes_written; char *name; - + collection = &collection_array[i]; if (OSrCollection_IsLocked(collection) == UUcTrue) { continue; } if (OSrCollection_IsDirty(collection) == UUcFalse) { continue; } - + // get the number of categories and items num_categories = UUrMemory_Array_GetUsedElems(collection->categories); num_items = UUrMemory_Array_GetUsedElems(collection->items); - + // determine the number of bytes to write data_size = sizeof(UUtUns32) + /* version number */ @@ -1619,21 +1619,21 @@ OSiBinaryData_Save( sizeof(UUtUns32) + /* number of categories */ sizeof(UUtUns32) + /* number of items */ OSiCollection_CalcMemoryUsed(collection); /* size of categories and items */ - + data = UUrMemory_Block_NewClear(data_size); if (data == NULL) { UUmAssert(!"Unable to allocate memory to save sounds"); continue; } - + // set write variables buffer = data; num_bytes = data_size; - + // write the version OBDmWrite4BytesToBuffer(buffer, OScCurrentVersion, UUtUns32, num_bytes, OBJcWrite_Little); - + // write the collection type OBDmWrite4BytesToBuffer( buffer, @@ -1641,19 +1641,19 @@ OSiBinaryData_Save( OStCollectionType, num_bytes, OBJcWrite_Little); - + // write the number of categories OBDmWrite4BytesToBuffer(buffer, num_categories, UUtUns32, num_bytes, OBJcWrite_Little); - + // write the number of items OBDmWrite4BytesToBuffer(buffer, num_items, UUtUns32, num_bytes, OBJcWrite_Little); - + // write the categories for (j = 0; j < num_categories; j++) { UUrMemory_Clear(temp_buffer, OScMaxBufferSize); temp_num_bytes = OScMaxBufferSize; - + // write the category OSiCollection_Category_WriteByIndex( collection, @@ -1661,7 +1661,7 @@ OSiBinaryData_Save( temp_buffer, &temp_num_bytes); temp_num_bytes = ((temp_num_bytes + 3) & ~3); - + // write the item marker bytes_written = UUrWriteTagDataToBuffer( @@ -1671,18 +1671,18 @@ OSiBinaryData_Save( temp_buffer, temp_num_bytes, UUcFile_LittleEndian); - + // advance the buffer buffer += bytes_written; num_bytes -= bytes_written; } - + // write the items for (j = 0; j < num_items; j++) { UUrMemory_Clear(temp_buffer, OScMaxBufferSize); temp_num_bytes = OScMaxBufferSize; - + // write the item OSiCollection_Item_WriteByIndex( collection, @@ -1690,7 +1690,7 @@ OSiBinaryData_Save( temp_buffer, &temp_num_bytes); temp_num_bytes = ((temp_num_bytes + 3) & ~3); - + // write the item marker bytes_written = UUrWriteTagDataToBuffer( @@ -1700,18 +1700,18 @@ OSiBinaryData_Save( temp_buffer, temp_num_bytes, UUcFile_LittleEndian); - + // advance the buffer buffer += bytes_written; num_bytes -= bytes_written; } - + switch (OSrCollection_GetType(collection)) { case OScCollectionType_Group: name = "Group"; break; - + case OScCollectionType_Ambient: name = "Ambient"; break; @@ -1720,7 +1720,7 @@ OSiBinaryData_Save( name = "Impulse"; break; } - + // write the buffer to the binary datafile OBDrBinaryData_Save( OScBinaryDataClass, @@ -1729,14 +1729,14 @@ OSiBinaryData_Save( (data_size - num_bytes), 0, UUcFalse); - + // dispose of the buffer UUrMemory_Block_Delete(data); - + // the collection is no longer dirty OSrCollection_SetDirty(collection, UUcFalse); } - + return UUcError_None; } @@ -1758,28 +1758,28 @@ OSiDialog_Play( OStCollection *collection; OStItem *item; SStAmbient *ambient; - + // don't play a dialog if other dialog is already playing if (OSgDialog_PlayID == SScInvalidID) { // get the collection collection = OSrCollection_GetByType(OScCollectionType_Ambient); if (collection == NULL) { return UUcError_None; } - + // get the ambient sound item = OSrCollection_Item_GetByName(collection, inParameterList[0].val.str); if (item == NULL) { return UUcError_None; } - + ambient = SSrAmbient_GetByID(item->id); if (ambient == NULL) { return UUcError_None; } - + // start the ambient sound playing OSgDialog_PlayID = SSrAmbient_Start(ambient, NULL, NULL, NULL, 0.0f, 0.0f); } - + // *outTicksTillCompletion = 0; // *outStall = UUcFalse; - + // ioReturnValue->type = SLcType_Void; // ioReturnValue->val.i = 0; @@ -1801,21 +1801,21 @@ OSiDialog_Play_Blocked( OStCollection *collection; OStItem *item; SStAmbient *ambient; - + // get the collection collection = OSrCollection_GetByType(OScCollectionType_Ambient); if (collection == NULL) { return UUcError_None; } - + // get the ambient sound item = OSrCollection_Item_GetByName(collection, inParameterList[0].val.str); if (item == NULL) { return UUcError_None; } - + ambient = SSrAmbient_GetByID(item->id); if (ambient == NULL) { return UUcError_None; } - + // start the ambient sound playing OSgDialog_PlayID = SSrAmbient_Start(ambient, NULL, NULL, NULL, 0.0f, 0.0f); - + // *outTicksTillCompletion = 0; *outStall = UUcFalse; } @@ -1824,7 +1824,7 @@ OSiDialog_Play_Blocked( // *outTicksTillCompletion = 2; *outStall = UUcTrue; } - + // ioReturnValue->type = SLcType_Void; // ioReturnValue->val.i = 0; @@ -1847,37 +1847,37 @@ OSiMusic_Start( UUtError error; OStPlayingMusic *playing_music_array; UUtUns32 index; - + // get the collection collection = OSrCollection_GetByType(OScCollectionType_Ambient); if (collection == NULL) { return UUcError_None; } - + // get the ambient sound item = OSrCollection_Item_GetByName(collection, inParameterList[0].val.str); if (item == NULL) { return UUcError_None; } - + // start the music ambient = SSrAmbient_GetByID(item->id); if (ambient == NULL) { return UUcError_None; } - + // add an element to the play list error = UUrMemory_Array_GetNewElement(OSgPlayingMusic, &index, NULL); if (error != UUcError_None) { return UUcError_None; } - + playing_music_array = (OStPlayingMusic*)UUrMemory_Array_GetMemory(OSgPlayingMusic); UUmAssert(playing_music_array); - + UUrString_Copy( playing_music_array[index].name, inParameterList[0].val.str, OScMaxNameLength); playing_music_array[index].play_id = SSrAmbient_Start(ambient, NULL, NULL, NULL, 0.0f, 0.0f); - + /* *outTicksTillCompletion = 0; *outStall = UUcFalse; ioReturnValue->type = SLcType_Void; ioReturnValue->val.i = 0;*/ - + return UUcError_None; } @@ -1894,28 +1894,28 @@ OSiMusic_Stop( OStPlayingMusic *playing_music_array; UUtUns32 num_elements; UUtUns32 i; - + playing_music_array = (OStPlayingMusic*)UUrMemory_Array_GetMemory(OSgPlayingMusic); num_elements = UUrMemory_Array_GetUsedElems(OSgPlayingMusic); for (i = 0; i < num_elements; i++) { UUtInt32 result; - + result = UUrString_Compare_NoCase(playing_music_array[i].name, inParameterList[0].val.str); if (result != 0) { continue; } - + // stop the music SSrAmbient_Stop(playing_music_array[i].play_id); - + UUrMemory_Array_DeleteElement(OSgPlayingMusic, i); break; } - + /* *outTicksTillCompletion = 0; *outStall = UUcFalse; ioReturnValue->type = SLcType_Void; ioReturnValue->val.i = 0;*/ - + return UUcError_None; } @@ -1925,10 +1925,10 @@ OSiScriptCommands_Initialize( void) { UUtError error; - + // initialize the globals OSgDialog_PlayID = SScInvalidID; - + OSgPlayingMusic = UUrMemory_Array_New( sizeof(OStPlayingMusic*), @@ -1936,25 +1936,25 @@ OSiScriptCommands_Initialize( 0, 1); UUmError_ReturnOnNull(OSgPlayingMusic); - + // initialize the commands - error = + error = SLrScript_Command_Register_Void( "sound_music_start", "function to start music playing", "name:string", OSiMusic_Start); UUmError_ReturnOnError(error); - - error = + + error = SLrScript_Command_Register_Void( "sound_music_stop", "function to start music playing", "name:string", OSiMusic_Stop); UUmError_ReturnOnError(error); - - error = + + error = SLrScript_Command_Register_Void( "sound_dialog_play", "function to start character dialog playing", @@ -1962,7 +1962,7 @@ OSiScriptCommands_Initialize( OSiDialog_Play); UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "sound_dialog_play_block", "function to start character dialog playing after the current dialog finishes", @@ -1993,7 +1993,7 @@ OSiScriptCommands_Update( if (OSgDialog_PlayID != SScInvalidID) { UUtBool active; - + active = SSrAmbient_Update(OSgDialog_PlayID, NULL, NULL, NULL); if (active == UUcFalse) { @@ -2017,22 +2017,22 @@ OSiSoundObject_BuildPlayList( OBJtOSD_All osd_all; UUtUns32 index; OStPlayingAmbient *playing_ambient_array; - + // get the object specific data OBJrObject_GetObjectSpecificData(inObject, &osd_all); - + // get the ambient sound error = UUrMemory_Array_GetNewElement(OSgPlayingAmbient, &index, NULL); if (error != UUcError_None) { return UUcFalse; } - + // get a pointer to the memory array playing_ambient_array = (OStPlayingAmbient*)UUrMemory_Array_GetMemory(OSgPlayingAmbient); if (playing_ambient_array == NULL) { return UUcFalse; } - + // initialize the array element playing_ambient_array[index].object = inObject; playing_ambient_array[index].play_id = SScInvalidID; - + return UUcTrue; } @@ -2042,7 +2042,7 @@ OSrLevel_Load( UUtUns32 inLevelNumber) { UUtError error; - + if (inLevelNumber == 0) { error = OSrVariantList_Initialize(); @@ -2058,17 +2058,17 @@ OSrLevel_Load( 0, 10); UUmError_ReturnOnNull(OSgPlayingAmbient); - + // build a list of the spatial and evironmental ambient sounds in the level OBJrObjectType_EnumerateObjects( OBJcType_Sound, OSiSoundObject_BuildPlayList, 0); - + // update the variant list's sound animation pointers OSrVariantList_LevelLoad(); } - + // set up all of the impact effect's impulse IDs ONrImpactEffects_UpdateImpulseIDs(SScInvalidID); @@ -2083,22 +2083,22 @@ OSrLevel_Unload( UUtUns32 i; OStPlayingAmbient *playing_ambient_array; UUtUns32 num_elements; - + // go through the ambient sound play list and stop the playing sounds playing_ambient_array = (OStPlayingAmbient*)UUrMemory_Array_GetMemory(OSgPlayingAmbient); num_elements = UUrMemory_Array_GetUsedElems(OSgPlayingAmbient); for (i = 0; i < num_elements; i++) { if (playing_ambient_array[i].play_id == SScInvalidID) { continue; } - + SSrAmbient_Stop(playing_ambient_array[i].play_id); playing_ambient_array[i].play_id = SScInvalidID; } - + // delete the ambient sound play list UUrMemory_Array_Delete(OSgPlayingAmbient); OSgPlayingAmbient = NULL; - + // unload the variant list OSrVariantList_LevelUnload(); } @@ -2112,13 +2112,13 @@ OSrUpdate( UUtUns32 i; OStPlayingAmbient *playing_ambient_array; UUtUns32 num_elements; - + // update the script commands OSiScriptCommands_Update(); - + // set the listener's position SSrListener_SetPosition(inPosition, inFacing); - + // go through the ambient sound play list and update the playing sounds playing_ambient_array = (OStPlayingAmbient*)UUrMemory_Array_GetMemory(OSgPlayingAmbient); num_elements = UUrMemory_Array_GetUsedElems(OSgPlayingAmbient); @@ -2129,11 +2129,11 @@ OSrUpdate( SStAmbient *ambient; M3tVector3D velocity; float distance; - + // calculate the distance from the object to the listener OBJrObject_GetPosition(playing_ambient_array[i].object, &position, NULL); OBJrObject_GetObjectSpecificData(playing_ambient_array[i].object, &osd_all); - + // see if the ambient sound is in range to be played distance = MUrPoint_Distance(inPosition, &position) * SScFootToDist; if ((distance < osd_all.sound_osd.min_volume_distance) == UUcFalse) @@ -2144,13 +2144,13 @@ OSrUpdate( SSrAmbient_Stop(playing_ambient_array[i].play_id); playing_ambient_array[i].play_id = SScInvalidID; } - + continue; } - + // if the ambient sound is already playing then go to the next sound if (playing_ambient_array[i].play_id != SScInvalidID) { continue; } - + // play the amient sound ambient = SSrAmbient_GetByID(osd_all.sound_osd.ambient_id); @@ -2184,19 +2184,19 @@ OSiTextFile_WriteAmbient( UUtUns32 num_items; UUtUns32 i; char string[2048]; - + // get the ambient collection ambient_collection = OSrCollection_GetByType(OScCollectionType_Ambient); if (ambient_collection == NULL) { return UUcError_None; } - + // get the group collection group_collection = OSrCollection_GetByType(OScCollectionType_Group); if (group_collection == NULL) { return UUcError_None; } - + // write the header sprintf(string, "Name\tGroup\tPriority\tIn Sound\tOut Sound\tBase Track 1\tBase Track 2\tDetail Track\tMin Detail Time\tMax Detail Time\tSphere Radius\tMax Volume Distance\tMin Volume Distance\tInterrupt On Stop\tPlay Once\n"); BFrFile_Write(inFile, strlen(string), string); - + // write the items num_items = OSrCollection_GetNumItems(ambient_collection); for (i = 0; i < num_items; i++) @@ -2206,22 +2206,22 @@ OSiTextFile_WriteAmbient( SStAmbient *ambient; OStItem *group; char number[128]; - + item = OSrCollection_Item_GetByIndex(ambient_collection, i); if (item == NULL) { continue; } - + category = OSrCollection_Category_GetByID(ambient_collection, OSrItem_GetCategoryID(item)); - + ambient = SSrAmbient_GetByID(item->id); if (ambient == NULL) { continue; } - + string[0] = '\0'; - + strcat(string, OSrItem_GetName(item)); strcat(string, "\t"); if (category) { strcat(string, OSrCategory_GetName(category)); } strcat(string, "\t"); - + strcat(string, OSgPriority_Name[ambient->priority]); strcat(string, "\t"); - + group = OSrCollection_Item_GetByID(group_collection, ambient->in_sound_id); if (group) { strcat(string, OSrItem_GetName(group)); } strcat(string, "\t"); @@ -2241,7 +2241,7 @@ OSiTextFile_WriteAmbient( group = OSrCollection_Item_GetByID(group_collection, ambient->detail_id); if (group) { strcat(string, OSrItem_GetName(group)); } strcat(string, "\t"); - + sprintf(number, "5.3f", ambient->min_detail_time); strcat(string, number); strcat(string, "\t"); sprintf(number, "5.3f", ambient->max_detail_time); strcat(string, number); strcat(string, "\t"); sprintf(number, "5.3f", ambient->sphere_radius); strcat(string, number); strcat(string, "\t"); @@ -2252,12 +2252,12 @@ OSiTextFile_WriteAmbient( strcat(string, "\t"); if ((ambient->flags & SScAmbientFlag_PlayOnce) != 0) { strcat(string, "Y"); } - + strcat(string, "\n"); BFrFile_Write(inFile, strlen(string), string); } - + return UUcError_None; } @@ -2271,19 +2271,19 @@ OSiTextFile_WriteImpulse( UUtUns32 num_items; UUtUns32 i; char string[2048]; - + // get the impulse collection impulse_collection = OSrCollection_GetByType(OScCollectionType_Impulse); if (impulse_collection == NULL) { return UUcError_None; } - + // get the group collection group_collection = OSrCollection_GetByType(OScCollectionType_Group); if (group_collection == NULL) { return UUcError_None; } - + // write the header sprintf(string, "Name\tGroup\tPriority\tSound\tMax Volume Distance\tMin Volume Distance\n"); BFrFile_Write(inFile, strlen(string), string); - + // write the items num_items = OSrCollection_GetNumItems(impulse_collection); for (i = 0; i < num_items; i++) @@ -2293,26 +2293,26 @@ OSiTextFile_WriteImpulse( SStImpulse *impulse; OStItem *group; char number[128]; - + item = OSrCollection_Item_GetByIndex(impulse_collection, i); if (item == NULL) { continue; } - + category = OSrCollection_Category_GetByID(impulse_collection, OSrItem_GetCategoryID(item)); - + impulse = SSrImpulse_GetByID(item->id); if (impulse == NULL) { continue; } - + string[0] = '\0'; - + strcat(string, OSrItem_GetName(item)); strcat(string, "\t"); if (category) { strcat(string, OSrCategory_GetName(category)); } strcat(string, "\t"); - + strcat(string, OSgPriority_Name[impulse->priority]); strcat(string, "\t"); group = OSrCollection_Item_GetByID(group_collection, impulse->impulse_sound_id); if (group) { strcat(string, OSrItem_GetName(group)); } strcat(string, "\t"); - + sprintf(number, "5.3f", impulse->min_volume_distance); strcat(string, number); strcat(string, "\t"); sprintf(number, "5.3f", impulse->max_volume_distance); strcat(string, number); @@ -2320,7 +2320,7 @@ OSiTextFile_WriteImpulse( BFrFile_Write(inFile, strlen(string), string); } - + return UUcError_None; } @@ -2333,15 +2333,15 @@ OSiTextFile_WriteGroup( UUtUns32 num_items; UUtUns32 i; char string[2048]; - + // get the group collection group_collection = OSrCollection_GetByType(OScCollectionType_Group); if (group_collection == NULL) { return UUcError_None; } - + // write the header sprintf(string, "Name\tGroup\tFile Name\tWeight\tMin Volume Percent\tMax Volume Percent\tMin Pitch Percent\tMax Pitch Percent\n"); BFrFile_Write(inFile, strlen(string), string); - + // write the items num_items = OSrCollection_GetNumItems(group_collection); for (i = 0; i < num_items; i++) @@ -2351,28 +2351,28 @@ OSiTextFile_WriteGroup( SStGroup *group; SStPermutation *perm_array; UUtUns32 num_permutations; - + item = OSrCollection_Item_GetByIndex(group_collection, i); if (item == NULL) { continue; } - + category = OSrCollection_Category_GetByID(group_collection, OSrItem_GetCategoryID(item)); - + group = SSrGroup_GetByID(item->id); if (group == NULL) { continue; } - + string[0] = '\0'; - + strcat(string, OSrItem_GetName(item)); strcat(string, "\t"); if (category) { strcat(string, OSrCategory_GetName(category)); } strcat(string, "\n"); - + BFrFile_Write(inFile, strlen(string), string); - + perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(group->permutations); num_permutations = UUrMemory_Array_GetUsedElems(group->permutations); for (i = 0; i < num_permutations; i++) { SStPermutation *perm; - + perm = &perm_array[i]; sprintf( string, @@ -2386,7 +2386,7 @@ OSiTextFile_WriteGroup( BFrFile_Write(inFile, strlen(string), string); } } - + return UUcError_None; } @@ -2399,25 +2399,25 @@ OSiTextFile_Write( char filename[128]; BFtFileRef *file_ref; BFtFile *file; - + // create the env file ref switch (inCollectionType) { case OScCollectionType_Ambient: sprintf(filename, "Sound_Ambient.txt"); break; - + case OScCollectionType_Impulse: sprintf(filename, "Sound_Impulse.txt"); break; - + case OScCollectionType_Group: sprintf(filename, "Sound_Group.txt"); break; } error = BFrFileRef_MakeFromName(filename, &file_ref); UUmError_ReturnOnError(error); - + // create the .TXT file if it doesn't already exist if (BFrFileRef_FileExists(file_ref) == UUcFalse) { @@ -2425,26 +2425,26 @@ OSiTextFile_Write( error = BFrFile_Create(file_ref); UUmError_ReturnOnError(error); } - + // open the file error = BFrFile_Open(file_ref, "rw", &file); UUmError_ReturnOnError(error); - + // set the position to 0 error = BFrFile_SetPos(file, 0); UUmError_ReturnOnError(error); - + // write the items switch (inCollectionType) { case OScCollectionType_Ambient: OSiTextFile_WriteAmbient(file); break; - + case OScCollectionType_Impulse: OSiTextFile_WriteImpulse(file); break; - + case OScCollectionType_Group: OSiTextFile_WriteGroup(file); break; @@ -2452,15 +2452,15 @@ OSiTextFile_Write( // set the end of the file BFrFile_SetEOF(file); - + // close the file BFrFile_Close(file); file = NULL; - + // delete the file ref BFrFileRef_Dispose(file_ref); file_ref = NULL; - + return UUcError_None; } @@ -2470,7 +2470,7 @@ OSrTextFile_Write( void) { UUtError error; - + error = OSiTextFile_Write(OScCollectionType_Ambient); UUmError_ReturnOnError(error); @@ -2479,7 +2479,7 @@ OSrTextFile_Write( error = OSiTextFile_Write(OScCollectionType_Group); UUmError_ReturnOnError(error); - + return error; } @@ -2494,32 +2494,32 @@ OSrInitialize( void) { UUtError error; - + // intialize the collections error = OSiCollections_Initialize(); UUmError_ReturnOnError(error); - + // initialize the sound animations error = OSrSA_Initialize(); UUmError_ReturnOnError(error); - + // initialize the script commands error = OSiScriptCommands_Initialize(); UUmError_ReturnOnError(error); - + // initialize the categories error = OSiCollections_AddType( OScCollectionType_Group, (OStItemDeleteProc)SSrGroup_Delete); UUmError_ReturnOnError(error); - + error = OSiCollections_AddType( OScCollectionType_Ambient, (OStItemDeleteProc)SSrAmbient_Delete); UUmError_ReturnOnError(error); - + // CB: OSiImpulseSound_Delete is a wrapper for SSrImpulse_Delete that informs Oni_ImpactEffect // that the impulse sound is being deleted error = @@ -2527,11 +2527,11 @@ OSrInitialize( OScCollectionType_Impulse, (OStItemDeleteProc)OSiImpulseSound_Delete); UUmError_ReturnOnError(error); - + // initialize the binary data class error = OSiBinaryData_Register(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2551,4 +2551,4 @@ OSrTerminate( OSiCollections_Terminate(); OSrVariantList_Terminate(); OSiScriptCommands_Terminate(); -} \ No newline at end of file +} diff --git a/OniProj/OniGameSource/Oni_Sound.h b/OniProj/OniGameSource/Oni_Sound.h index b157210..a457ba8 100644 --- a/OniProj/OniGameSource/Oni_Sound.h +++ b/OniProj/OniGameSource/Oni_Sound.h @@ -24,7 +24,7 @@ enum { OScVersion_1 = 1, - + OScCurrentVersion = OScVersion_1 }; @@ -33,7 +33,7 @@ typedef enum OStCollectionType OScCollectionType_Group = UUm4CharToUns32('C', 'T', 'G', 'R'), OScCollectionType_Ambient = UUm4CharToUns32('C', 'T', 'A', 'M'), OScCollectionType_Impulse = UUm4CharToUns32('C', 'T', 'I', 'M') - + } OStCollectionType; @@ -57,11 +57,11 @@ typedef void UUtError OSrLevel_Load( UUtUns32 inLevelNumber); - + void OSrLevel_Unload( void); - + void OSrUpdate( const M3tPoint3D *inPosition, @@ -73,15 +73,15 @@ OSrUpdate( UUtUns32 OSrItem_GetCategoryID( const OStItem *inItem); - + UUtUns32 OSrItem_GetID( const OStItem *inItem); - + const char* OSrItem_GetName( const OStItem *inItem); - + // ---------------------------------------------------------------------- UUtUns32 OSrCategory_GetID( @@ -90,48 +90,48 @@ OSrCategory_GetID( const char* OSrCategory_GetName( const OStCategory *inCategory); - + UUtUns32 OSrCategory_GetParentCategoryID( const OStCategory *inCategory); - + // ---------------------------------------------------------------------- void OSrCollection_Category_Delete( OStCollection *ioCollection, UUtUns32 inCategoryID); - + OStCategory* OSrCollection_Category_GetByID( OStCollection *inCollection, UUtUns32 inCategoryID); - + OStCategory* OSrCollection_Category_GetByIndex( OStCollection *inCollection, UUtUns32 inCategoryIndex); - + UUtError OSrCollection_Category_New( OStCollection *ioCollection, UUtUns32 inParentCategoryID, const char *inCategoryName, UUtUns32 *outCategoryID); - + UUtError OSrCollection_Category_SetName( OStCollection *ioCollection, UUtUns32 inCategoryID, const char *inCategoryName); - + OStCollection* OSrCollection_GetByType( OStCollectionType inCollectionType); - + UUtUns32 OSrCollection_GetNumCategories( const OStCollection *inCollection); - + UUtUns32 OSrCollection_GetNumItems( const OStCollection *inCollection); @@ -139,53 +139,53 @@ OSrCollection_GetNumItems( OStCollectionType OSrCollection_GetType( const OStCollection *inCollection); - + UUtBool OSrCollection_IsDirty( const OStCollection *inCollection); - + UUtBool OSrCollection_IsLocked( const OStCollection *inCollection); - + void OSrCollection_Item_Delete( OStCollection *ioCollection, UUtUns32 inItemID); - + OStItem* OSrCollection_Item_GetByID( const OStCollection *inCollection, UUtUns32 inItemIndex); - + OStItem* OSrCollection_Item_GetByIndex( const OStCollection *inCollection, UUtUns32 inItemIndex); - + OStItem* OSrCollection_Item_GetByName( const OStCollection *inCollection, const char *inItemName); - + UUtError OSrCollection_Item_New( OStCollection *ioCollection, UUtUns32 inCategoryID, UUtUns32 inItemID, char *inItemName); - + void OSrCollection_SetDirty( OStCollection *ioCollection, UUtBool inDirty); - + UUtError OSrCollection_Item_SetName( OStCollection *ioCollection, UUtUns32 inItemID, const char *inItemName); - + // ---------------------------------------------------------------------- UUtError OSrTextFile_Write( @@ -201,10 +201,10 @@ OSrInitialize( void OSrSave( void); - + void OSrTerminate( void); - + // ====================================================================== -#endif /* ONI_SOUND_H */ \ No newline at end of file +#endif /* ONI_SOUND_H */ diff --git a/OniProj/OniGameSource/Oni_Sound2.c b/OniProj/OniGameSource/Oni_Sound2.c index c000902..46b02a8 100644 --- a/OniProj/OniGameSource/Oni_Sound2.c +++ b/OniProj/OniGameSource/Oni_Sound2.c @@ -87,7 +87,7 @@ typedef struct OStHashElement SStGroup *group; SStImpulse *impulse; } u; - + } OStHashElement; // ---------------------------------------------------------------------- @@ -108,12 +108,12 @@ typedef struct OStPlayingAmbient SStPlayID ambient_id; const SStAmbient *ambient; SStPlayID play_id; - + UUtBool has_position; M3tPoint3D position; float max_volume_distance; float min_volume_distance; - + float volume; OStOcclusionCache occlusion_cache; @@ -124,16 +124,16 @@ typedef struct OStPlayingObject { const OBJtObject *object; SStPlayID play_id; - + float volume; float transition_volume; float object_volume; - + UUtUns32 state; // for sound volumes UUtUns32 start_time; OStOcclusionCache occlusion_cache; - + } OStPlayingObject; // ---------------------------------------------------------------------- @@ -254,25 +254,25 @@ OSrDebugDisplay( void) { UUtUns32 i; - + if (SSgShowDebugInfo) { // go through all of the ambient sources that are active // and draw them for (i = 0; i < OScMaxPlayingAmbientHandles; i++) { OStPlayingAmbient *playing_ambient; - + playing_ambient = OSiPlayingAmbient_GetByID(i); if (playing_ambient == NULL) { continue; } - + M3rGeom_Draw_DebugSphere( &playing_ambient->position, - playing_ambient->max_volume_distance * UUmFeet(1), + playing_ambient->max_volume_distance * UUmFeet(1), IMcShade_Red); M3rGeom_Draw_DebugSphere( &playing_ambient->position, - playing_ambient->min_volume_distance * UUmFeet(1), + playing_ambient->min_volume_distance * UUmFeet(1), IMcShade_Green); } } @@ -281,7 +281,7 @@ OSrDebugDisplay( if (OSgShowOcclusions) { IMtShade shade; M3tPoint3D p0, p1; - + // draw occlusion lines and points for (i = 0; i < OSgNumOcclusionLines; i++) { M3rGeom_Line_Light(&OSgOcclusionLines[i][0], &OSgOcclusionLines[i][1], IMcShade_White); @@ -349,11 +349,11 @@ OSiIsOccluded( UUtUns16 num_collisions, itr; UUtUns32 inside_object_tag; float dot, dist_tolerance; - + if (env == NULL) { return OScMaxCollisions; } - + MUmVector_Subtract(sightline, *inListener, *inSource); - + #if TOOL_VERSION if ((OSgShowOcclusions) && (OSgNumOcclusionLines < 64)) { OSgOcclusionLines[OSgNumOcclusionLines][0] = *inSource; @@ -361,13 +361,13 @@ OSiIsOccluded( OSgNumOcclusionLines++; } #endif - + had_collision = AKrCollision_Point_SpatialCache(env, inSource, &sightline, AKcGQ_Flag_SoundOcclude_Skip, AKcMaxNumCollisions, ioSourceCache, &OSgListener_OctreeCache); if (!had_collision) { return 0; } - + // process the collision list inside_object_tag = (UUtUns32) -1; num_collisions = 0; @@ -378,13 +378,13 @@ OSiIsOccluded( for(itr = 0, collision = AKgCollisionList; itr < AKgNumCollisions; itr++, collision++) { AKtGQ_General *general_gq; AKtGQ_Collision *collision_gq; - + if (collision->collisionType != CLcCollision_Face) { continue; } - + general_gq = env->gqGeneralArray->gqGeneral + collision->gqIndex; - + if (num_collisions == 0) { if (MUmVector_GetDistanceSquared(*inSource, collision->collisionPoint) < UUmSQR(OScOcclusion_CoplanarDistance)) { // ignore this collision so that we don't get occluded when we create a sound that is exactly @@ -499,7 +499,7 @@ OSiIsOccluded( lastpoint_was_collision = UUcTrue; last_collision_point = last_point; } - + return num_collisions; } @@ -532,13 +532,13 @@ OSiCalc_PositionAndVolume( M3tPoint3D position; float direct_dist; UUtUns32 current_time = ONrGameState_GetGameTime(); - + // NULL position indicates non-spatialized audio, // but must be handled outside this function! UUmAssert(inPosition != NULL); position = *outPosition = *inPosition; *outVolume = 0.0f; - + // determine if the sound is within the minimum volume distance direct_dist = MUrPoint_Distance_Squared(&position, &OSgListener_Position) * UUmSQR(SScFootToDist); if (direct_dist > UUmSQR(inMinVolumeDistance)) { return UUcFalse; } @@ -591,7 +591,7 @@ OSiCalc_PositionAndVolume( // COrConsole_Printf("%d: occlusion calc %f", current_time, *outVolume); } } - + if (ioOcclusionCache != NULL) { ioOcclusionCache->occlusion_volume = *outVolume; } @@ -612,15 +612,15 @@ OSiHasElement_GetByName( { OStHashElement find_me; OStHashElement *hash_elem; - + if (inHashTable == NULL) { return NULL; } if (inName == NULL) { return NULL; } - + find_me.name = inName; find_me.u.ambient = NULL; - + hash_elem = (OStHashElement*)AUrHashTable_Find(inHashTable, &find_me); - + return hash_elem; } @@ -631,10 +631,10 @@ OSiHashElement_GetHashValue( { OStHashElement *hash_elem; UUtUns32 hash_value; - + hash_elem = (OStHashElement*)inElement; hash_value = AUrString_GetHashValue(hash_elem->name); - + return hash_value; } @@ -647,12 +647,12 @@ OSiHashElement_IsEqual( OStHashElement *hash_elem1; OStHashElement *hash_elem2; UUtBool result; - + hash_elem1 = (OStHashElement*)inElement1; hash_elem2 = (OStHashElement*)inElement2; - + result = UUrString_Compare_NoCase(hash_elem1->name, hash_elem2->name) == 0; - + return result; } @@ -669,9 +669,9 @@ OSiPlayingAmbientHandles_Update( OStPlayingAmbient *playing_ambient_array; UUtUns32 num_elements; UUtUns32 i; - + UUrMemory_Clear(OSgPlayingAmbientHandles, (sizeof(OStPlayingAmbient*) * OScMaxPlayingAmbientHandles)); - + playing_ambient_array = (OStPlayingAmbient*)UUrMemory_Array_GetMemory(OSgPlayingAmbient); num_elements = UUrMemory_Array_GetUsedElems(OSgPlayingAmbient); for (i = 0; i < num_elements; i++) @@ -691,7 +691,7 @@ OSiPlayingAmbient_FreeElement( UUmAssert(inPlayingAmbient != NULL); UUmAssert(inPlayingAmbient->ambient_id < OScMaxPlayingAmbientHandles); UUmAssert(inPlayingAmbient->play_id == SScInvalidID); - + UUrMemory_Array_DeleteElement(OSgPlayingAmbient, inPlayingAmbient->index); OSiPlayingAmbientHandles_Update(); } @@ -707,40 +707,40 @@ OSiPlayingAmbient_GetNewElement( UUtUns32 index; UUtBool mem_moved; UUtUns32 i; - + *outPlayingAmbient = NULL; - + if (UUrMemory_Array_GetUsedElems(OSgPlayingAmbient) >= OScMaxPlayingAmbientHandles) { return UUcError_Generic; } - + // get a new element from the array error = UUrMemory_Array_GetNewElement(OSgPlayingAmbient, &index, &mem_moved); UUmError_ReturnOnError(error); - + playing_ambient_array = (OStPlayingAmbient*)UUrMemory_Array_GetMemory(OSgPlayingAmbient); - + // set the index playing_ambient_array[index].index = index; - + // add a link to the playing ambient to the handle array for (i = 0; i < OScMaxPlayingAmbientHandles; i++) { if (OSgPlayingAmbientHandles[i] != NULL) { continue; } - + // set the ambient_id playing_ambient_array[index].ambient_id = i; - + if (mem_moved == UUcFalse) { OSgPlayingAmbientHandles[i] = &playing_ambient_array[index]; } break; } - + if (mem_moved) { OSiPlayingAmbientHandles_Update(); } - + // set the outgoing playing ambient *outPlayingAmbient = &playing_ambient_array[index]; *outIndex = index; @@ -754,11 +754,11 @@ OSiPlayingAmbient_GetByID( UUtUns32 inAmbientID) { OStPlayingAmbient *playing_ambient; - + UUmAssert(inAmbientID < OScMaxPlayingAmbientHandles); - + playing_ambient = OSgPlayingAmbientHandles[inAmbientID]; - + return playing_ambient; } @@ -771,11 +771,11 @@ OSiPlayingAmbient_Initialize( OSgPlayingAmbientHandles = (OStPlayingAmbient**)UUrMemory_Block_NewClear(sizeof(OStPlayingAmbient*) * OScMaxPlayingAmbientHandles); UUmError_ReturnOnNull(OSgPlayingAmbientHandles); - + // initialize the playing ambient array OSgPlayingAmbient = UUrMemory_Array_New(sizeof(OStPlayingAmbient), 16, 0, 0); UUmError_ReturnOnNull(OSgPlayingAmbient); - + return UUcError_None; } @@ -786,7 +786,7 @@ OSiPlayingAmbient_Terminate( { UUrMemory_Array_Delete(OSgPlayingAmbient); OSgPlayingAmbient = NULL; - + UUrMemory_Block_Delete(OSgPlayingAmbientHandles); OSgPlayingAmbientHandles = NULL; } @@ -803,14 +803,14 @@ OSrAmbient_BuildHashTable( { UUtUns32 num_ambients; UUtUns32 i; - + // delete the old table if (OSgAmbientTable != NULL) { AUrHashTable_Delete(OSgAmbientTable); OSgAmbientTable = NULL; } - + // allocate a new table OSgAmbientTable = AUrHashTable_New( @@ -819,23 +819,23 @@ OSrAmbient_BuildHashTable( OSiHashElement_GetHashValue, OSiHashElement_IsEqual); UUmError_ReturnOnNull(OSgAmbientTable); - + // add the ambient sounds to the table num_ambients = SSrAmbient_GetNumAmbientSounds(); for (i = 0; i < num_ambients; i++) { SStAmbient *ambient; OStHashElement hash_elem; - + ambient = SSrAmbient_GetByIndex(i); if (ambient == NULL) { break; } - + hash_elem.name = ambient->ambient_name; hash_elem.u.ambient = ambient; - + AUrHashTable_Add(OSgAmbientTable, &hash_elem); } - + return UUcError_None; } @@ -846,18 +846,18 @@ OSrAmbient_ChangeName( const char *inName) { char name[SScMaxNameLength]; - + UUmAssert(inAmbient); UUmAssert(inName); - + // save the old name UUrString_Copy(name, inAmbient->ambient_name, SScMaxNameLength); - + // change the ambients's name UUrString_Copy(inAmbient->ambient_name, inName, SScMaxNameLength); - + // update the name - + // rebuild the hash table OSrAmbient_BuildHashTable(); } @@ -868,12 +868,12 @@ OSrAmbient_Delete( const char *inName) { UUtError error; - + SSrAmbient_Delete(inName, UUcTrue); - + error = OSrAmbient_BuildHashTable(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -885,11 +885,11 @@ OSrAmbient_GetByName( const char *inName) { OStHashElement *hash_elem; - + // find the hash element for the ambient sound named inName hash_elem = OSiHasElement_GetByName(OSgAmbientTable, inName); if (hash_elem == NULL) { return NULL; } - + // return the ambient pointer return hash_elem->u.ambient; } @@ -901,13 +901,13 @@ OSrAmbient_Halt( SStPlayID inAmbientID) { OStPlayingAmbient *playing_ambient; - + if (inAmbientID == SScInvalidID) { return; } - + // go through and find the ambient to halt playing_ambient = OSiPlayingAmbient_GetByID(inAmbientID); if (playing_ambient == NULL) { return; } - + if (playing_ambient->play_id != SScInvalidID) { SSrAmbient_Halt(playing_ambient->play_id); @@ -919,10 +919,10 @@ OSrAmbient_Halt( playing_ambient->play_id, playing_ambient->ambient->ambient_name); }*/ - + playing_ambient->play_id = SScInvalidID; } - + OSiPlayingAmbient_FreeElement(playing_ambient); } @@ -937,21 +937,21 @@ OSiAmbient_Load( { UUtError error; SStAmbient *ambient; - + UUtUns8 *buffer; UUtUns32 buffer_size; UUtUns32 version; - + char name[SScMaxNameLength]; - + UUmAssert(inIdentifier); UUmAssert(ioBinaryData); - + // ------------------------------ // create a new ambient sound // ------------------------------ OSrMakeGoodName(inIdentifier, name); - + // if no ambient sound with this name exists, create a new one, // if one does exist, take it over ambient = SSrAmbient_GetByName(name); @@ -969,7 +969,7 @@ OSiAmbient_Load( ambient->base_track2 = NULL; ambient->detail = NULL; } - + // ------------------------------ // read the binary data // ------------------------------ @@ -978,7 +978,7 @@ OSiAmbient_Load( // read the version number BDmGet4BytesFromBuffer(buffer, version, UUtUns32, inSwapIt); - + BDmGet4BytesFromBuffer(buffer, ambient->priority, SStPriority2, inSwapIt); BDmGet4BytesFromBuffer(buffer, ambient->flags, UUtUns32, inSwapIt); BDmGet4BytesFromBuffer(buffer, ambient->sphere_radius, float, inSwapIt); @@ -991,7 +991,7 @@ OSiAmbient_Load( BDmGetStringFromBuffer(buffer, ambient->base_track2_name, SScMaxNameLength, inSwapIt); BDmGetStringFromBuffer(buffer, ambient->in_sound_name, SScMaxNameLength, inSwapIt); BDmGetStringFromBuffer(buffer, ambient->out_sound_name, SScMaxNameLength, inSwapIt); - + if (version < OS2cVersion_5) { ambient->threshold = SScAmbientThreshold; @@ -1000,7 +1000,7 @@ OSiAmbient_Load( { BDmGet4BytesFromBuffer(buffer, ambient->threshold, UUtUns32, inSwapIt); } - + if (version < OS2cVersion_6) { ambient->min_occlusion = 0.0f; @@ -1009,12 +1009,12 @@ OSiAmbient_Load( { BDmGet4BytesFromBuffer(buffer, ambient->min_occlusion, float, inSwapIt); } - + if (inAllocated == UUcTrue) { UUrMemory_Block_Delete(ioBinaryData); } - + return UUcError_None; } @@ -1024,10 +1024,10 @@ OSiAmbient_LevelLoad( void) { UUtError error; - + error = OSrAmbient_BuildHashTable(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1052,15 +1052,15 @@ OSrAmbient_New( { UUtError error; char name[SScMaxNameLength]; - + OSrMakeGoodName(inName, name); - + error = SSrAmbient_New(name, outAmbient); UUmError_ReturnOnError(error); - + error = OSrAmbient_BuildHashTable(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1083,36 +1083,36 @@ OSrAmbient_Save( sprintf(name, "%s.%s", inAmbient->ambient_name, OScAmbientSuffix); error = BFrFileRef_DuplicateAndAppendName(inParentDirRef, name, &file_ref); UUmError_ReturnOnError(error); - + // create the file if it doesn't exist if (BFrFileRef_FileExists(file_ref) == UUcFalse) { error = BFrFile_Create(file_ref); UUmError_ReturnOnErrorMsg(error, "Could not create the file."); } - + // see if the file is locked if (BFrFileRef_IsLocked(file_ref) == UUcTrue) { char error_string[1024]; - + sprintf( error_string, "Unable to save ambient sound, because the file %s is locked", name); - + WMrDialog_MessageBox( NULL, "Error", error_string, WMcMessageBoxStyle_OK); - + BFrFileRef_Dispose(file_ref); file_ref = NULL; - + return UUcError_None; } - + // open the file for writing error = BFrFile_Open( @@ -1120,17 +1120,17 @@ OSrAmbient_Save( "w", &file); UUmError_ReturnOnErrorMsg(error, "Could not open the group file."); - + // set the pos to the beginning of the file BFrFile_SetPos(file, 0); - + // setup the buffer pointer buffer = data; bytes_avail = OScMaxBufferSize; - + // write the version BDmWrite4BytesToBuffer(buffer, OS2cCurrentVersion, UUtUns32, bytes_avail, BDcWrite_Little); - + // write the ambient sound to the buffer BDmWrite4BytesToBuffer(buffer, inAmbient->priority, SStPriority2, bytes_avail, BDcWrite_Little); BDmWrite4BytesToBuffer(buffer, inAmbient->flags, UUtUns32, bytes_avail, BDcWrite_Little); @@ -1146,7 +1146,7 @@ OSrAmbient_Save( BDmWriteStringToBuffer(buffer, inAmbient->out_sound_name, SScMaxNameLength, bytes_avail, BDcWrite_Little); BDmWrite4BytesToBuffer(buffer, inAmbient->threshold, UUtUns32, bytes_avail, BDcWrite_Little); BDmWrite4BytesToBuffer(buffer, inAmbient->min_occlusion, float, bytes_avail, BDcWrite_Little); - + // write the ambient sound error = BDrBinaryData_Write( @@ -1155,17 +1155,17 @@ OSrAmbient_Save( (OScMaxBufferSize - bytes_avail), file); UUmError_ReturnOnErrorMsg(error, "Unable to write to file."); - + // set the EOF BFrFile_SetEOF(file); - + // close the file BFrFile_Close(file); file = NULL; - + UUrMemory_Block_Delete(file_ref); file_ref = NULL; - + return UUcError_None; } @@ -1186,9 +1186,9 @@ OSrAmbient_Start( float volume; float max_volume_distance; float min_volume_distance; - + OStPlayingAmbient *playing_ambient; - + // set the min and max volume distances if (inMaxVolDistance == NULL) { @@ -1198,7 +1198,7 @@ OSrAmbient_Start( { max_volume_distance = *inMaxVolDistance; } - + if (inMinVolDistance == NULL) { min_volume_distance = inAmbient->min_volume_distance; @@ -1207,7 +1207,7 @@ OSrAmbient_Start( { min_volume_distance = *inMinVolDistance; } - + // get an entry in the playing ambient array error = OSiPlayingAmbient_GetNewElement(&playing_ambient, &playing_ambient_index); if (error != UUcError_None) @@ -1220,10 +1220,10 @@ OSrAmbient_Start( }*/ return SScInvalidID; } - + /* { float dist = MUrPoint_Distance(inPosition, &OSgListener_Position); - + COrConsole_Printf( "OSrAmbient_Start %d: %s %d at (%f, %f, %f) %f", ONrGameState_GetGameTime(), @@ -1234,7 +1234,7 @@ OSrAmbient_Start( inPosition->z, dist); }*/ - + // initialize the playing ambient playing_ambient->play_id = SScInvalidID; playing_ambient->ambient = inAmbient; @@ -1242,14 +1242,14 @@ OSrAmbient_Start( playing_ambient->min_volume_distance = min_volume_distance; playing_ambient->has_position = UUcFalse; OSiSetupOcclusionCache(playing_ambient_index, &playing_ambient->occlusion_cache); - + // play the ambient sound if possible if (inPosition == NULL) { if (OSgScriptOnly == UUcFalse) { playing_ambient->play_id = SSrAmbient_Start_Simple(inAmbient, NULL); - + /* if (SSgShowDebugInfo) { COrConsole_Printf( @@ -1263,7 +1263,7 @@ OSrAmbient_Start( { playing_ambient->position = *inPosition; playing_ambient->has_position = UUcTrue; - + // calculate the position and volume of the sound can_play = OSiCalc_PositionAndVolume( @@ -1288,7 +1288,7 @@ OSrAmbient_Start( min_volume_distance, &volume); playing_ambient->volume = volume; - + /* if (SSgShowDebugInfo) { if (playing_ambient->play_id == SScInvalidID) @@ -1300,7 +1300,7 @@ OSrAmbient_Start( else { float direct_dist = MUrPoint_Distance(&position, &OSgListener_Position) * SScFootToDist; - + COrConsole_Printf( "SSrAmbient_Start: %d %s, %f <=> %f, (%f, %f, %f), (%f, %f, %f)", playing_ambient->play_id, @@ -1334,7 +1334,7 @@ OSrAmbient_Start( playing_ambient->ambient->ambient_name); }*/ } - + return playing_ambient->ambient_id; } @@ -1344,13 +1344,13 @@ OSrAmbient_Stop( SStPlayID inAmbientID) { OStPlayingAmbient *playing_ambient; - + if (inAmbientID == SScInvalidID) { return; } - + // go through and find the ambient to stop playing_ambient = OSiPlayingAmbient_GetByID(inAmbientID); if (playing_ambient == NULL) { return; } - + if (playing_ambient->play_id != SScInvalidID) { SSrAmbient_Stop(playing_ambient->play_id); @@ -1363,10 +1363,10 @@ OSrAmbient_Stop( playing_ambient->ambient->ambient_name, inAmbientID); }*/ - + playing_ambient->play_id = SScInvalidID; } - + OSiPlayingAmbient_FreeElement(playing_ambient); } @@ -1380,18 +1380,18 @@ OSiAmbient_Update( const M3tVector3D *inVelocity) { UUmAssert(inPlayingAmbient); - + if (inPosition != NULL) { UUtBool is_playing; UUtBool can_play; M3tPoint3D position; float volume; - + // update the playing ambient inPlayingAmbient->position = *inPosition; inPlayingAmbient->has_position = UUcTrue; - + can_play = OSiCalc_PositionAndVolume( &inPlayingAmbient->position, @@ -1409,11 +1409,11 @@ OSiAmbient_Update( // that the sound system code can deal with stopping it if // necessary if (inPlayingAmbient->play_id == SScInvalidID) { return UUcTrue; } - + /* if (SSgShowDebugInfo) { float direct_dist = MUrPoint_Distance(&position, &OSgListener_Position) * SScFootToDist; - + COrConsole_Printf( "SSrAmbient_Update: %d %s, %f <=> %f, (%f, %f, %f), (%f, %f, %f)", inPlayingAmbient->play_id, @@ -1447,7 +1447,7 @@ OSiAmbient_Update( inPlayingAmbient->play_id, inPlayingAmbient->ambient->ambient_name); }*/ - + OSrAmbient_Stop(inAmbientID); return UUcFalse; } @@ -1462,14 +1462,14 @@ OSiAmbient_Update( inPlayingAmbient->play_id, inPlayingAmbient->ambient->ambient_name); }*/ - + SSrAmbient_Halt(inPlayingAmbient->play_id); inPlayingAmbient->play_id = SScInvalidID; } - + return UUcTrue; } - + if (inPlayingAmbient->play_id == SScInvalidID) { if (OSgScriptOnly == UUcFalse) @@ -1499,7 +1499,7 @@ OSiAmbient_Update( else { float volume_delta; - + // COrConsole_Printf("volume changing, %f -> %f", inPlayingAmbient->volume, volume); // update occluding volumes over time @@ -1520,7 +1520,7 @@ OSiAmbient_Update( 0.0f, 1.0f); } - + // update the ambient sound // COrConsole_Printf("volume makechange %f", inPlayingAmbient->volume, volume); is_playing = @@ -1541,10 +1541,10 @@ OSiAmbient_Update( } } } - + inPlayingAmbient->volume = volume; } - + return UUcTrue; } @@ -1558,16 +1558,16 @@ OSrAmbient_Update( { OStPlayingAmbient *playing_ambient; UUtBool result; - + if (inAmbientID == SScInvalidID) { return UUcFalse; } - + // get the a pointer to the playing ambient playing_ambient = OSiPlayingAmbient_GetByID(inAmbientID); if (playing_ambient == NULL) { return UUcFalse; } - + /* { float dist = MUrPoint_Distance(inPosition, &OSgListener_Position); - + COrConsole_Printf( "OSrAmbient_Update %d: %s %d at (%f, %f, %f) %f", ONrGameState_GetGameTime(), @@ -1578,9 +1578,9 @@ OSrAmbient_Update( inPosition->z, dist); }*/ - + result = OSiAmbient_Update(inAmbientID, playing_ambient, inPosition, inDirection, inVelocity); - + return result; } @@ -1590,15 +1590,15 @@ OSiAmbient_UpdateAll( void) { UUtUns32 i; - + for (i = 0; i < OScMaxPlayingAmbientHandles; i++) { OStPlayingAmbient *playing_ambient; - + playing_ambient = OSiPlayingAmbient_GetByID(i); if (playing_ambient == NULL) { continue; } if (playing_ambient->has_position == UUcFalse) { continue; } - + // COrConsole_Printf("update playingambient %s", playing_ambient->ambient->ambient_name); OSiAmbient_Update(i, playing_ambient, &playing_ambient->position, NULL, NULL); } @@ -1635,7 +1635,7 @@ OSiAmbient_GetSimpleDuration( return SSrSoundData_GetDuration(permutation->sound_data); } - + // found no non-NULL permutations return 0; } @@ -1652,14 +1652,14 @@ OSrGroup_BuildHashTable( { UUtUns32 num_groups; UUtUns32 i; - + // delete the old table if (OSgGroupTable != NULL) { AUrHashTable_Delete(OSgGroupTable); OSgGroupTable = NULL; } - + // allocate a new table OSgGroupTable = AUrHashTable_New( @@ -1668,23 +1668,23 @@ OSrGroup_BuildHashTable( OSiHashElement_GetHashValue, OSiHashElement_IsEqual); UUmError_ReturnOnNull(OSgGroupTable); - + // add the sound groups to the table num_groups = SSrGroup_GetNumSoundGroups(); for (i = 0; i < num_groups; i++) { SStGroup *group; OStHashElement hash_elem; - + group = SSrGroup_GetByIndex(i); if (group == NULL) { break; } - + hash_elem.name = group->group_name; hash_elem.u.group = group; - + AUrHashTable_Add(OSgGroupTable, &hash_elem); } - + return UUcError_None; } @@ -1695,20 +1695,20 @@ OSrGroup_ChangeName( const char *inName) { char name[SScMaxNameLength]; - + UUmAssert(inGroup); UUmAssert(inName); - + // save the old name UUrString_Copy(name, inGroup->group_name, SScMaxNameLength); - + // change the group's name UUrString_Copy(inGroup->group_name, inName, SScMaxNameLength); - + // update the ambient and impulse sounds SSrAmbient_UpdateGroupName(name, inName); SSrImpulse_UpdateGroupName(name, inName); - + // rebuild the hash table OSrGroup_BuildHashTable(); } @@ -1719,13 +1719,13 @@ OSrGroup_Delete( const char *inName) { UUtError error; - + // delete the group SSrGroup_Delete(inName, UUcTrue); - + error = OSrGroup_BuildHashTable(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1735,11 +1735,11 @@ OSrGroup_GetByName( const char *inName) { OStHashElement *hash_elem; - + // find the hash element for the sound group named inName hash_elem = OSiHasElement_GetByName(OSgGroupTable, inName); if (hash_elem == NULL) { return NULL; } - + // return the group pointer return hash_elem->u.group; } @@ -1755,26 +1755,26 @@ OSiGroup_Load( { UUtError error; SStGroup *group; - + UUtUns8 *buffer; UUtUns32 buffer_size; UUtUns32 version; - + UUtUns32 i; UUtUns32 num_permutations; UUtMemory_Array *permutations; SStPermutation *perm_array; - + char name[SScMaxNameLength]; - + UUmAssert(inIdentifier); UUmAssert(ioBinaryData); - + // ------------------------------ // create a new group sound // ------------------------------ OSrMakeGoodName(inIdentifier, name); - + // if no group with this name exists, create a new one, // if one does exist, take it over group = SSrGroup_GetByName(name); @@ -1789,7 +1789,7 @@ OSiGroup_Load( UUrMemory_Array_Delete(group->permutations); group->permutations = NULL; } - + // ------------------------------ // read the binary data // ------------------------------ @@ -1798,7 +1798,7 @@ OSiGroup_Load( // read the version number BDmGet4BytesFromBuffer(buffer, version, UUtUns32, inSwapIt); - + // read the group volume in file versions 2 or higher, before then, use // a default of 1.0f if (version < OS2cVersion_2) @@ -1809,7 +1809,7 @@ OSiGroup_Load( { BDmGet4BytesFromBuffer(buffer, group->group_volume, float, inSwapIt); } - + // read the group pitch in file versions 3 or higher, before then, use // a default of 1.0f if (version < OS2cVersion_3) @@ -1820,7 +1820,7 @@ OSiGroup_Load( { BDmGet4BytesFromBuffer(buffer, group->group_pitch, float, inSwapIt); } - + // read the group flags from files version 6 or higher if (version < OS2cVersion_6) { @@ -1832,17 +1832,17 @@ OSiGroup_Load( BDmGet2BytesFromBuffer(buffer, group->flags, UUtUns16, inSwapIt); BDmGet2BytesFromBuffer(buffer, group->flag_data, UUtUns16, inSwapIt); } - + BDmGet4BytesFromBuffer(buffer, group->num_channels, UUtUns32, inSwapIt); BDmGet4BytesFromBuffer(buffer, num_permutations, UUtUns32, inSwapIt); - + // for older groups, default to SScGroupFlag_PreventRepeats if // num_permutations >= SScPreventRepeats_Default if ((version < OS2cVersion_6) && (num_permutations >= SScPreventRepeats_Default)) { group->flags |= SScGroupFlag_PreventRepeats; } - + // create a memory array to hold the permutations permutations = UUrMemory_Array_New( @@ -1851,13 +1851,13 @@ OSiGroup_Load( num_permutations, num_permutations); UUmError_ReturnOnNull(permutations); - + if (group->permutations) { UUrMemory_Array_Delete(group->permutations); } group->permutations = permutations; - + // read the permutations perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(permutations); for (i = 0; i < num_permutations; i++) @@ -1869,16 +1869,16 @@ OSiGroup_Load( BDmGet4BytesFromBuffer(buffer, perm_array[i].min_pitch_percent, float, inSwapIt); BDmGet4BytesFromBuffer(buffer, perm_array[i].max_pitch_percent, float, inSwapIt); BDmGetStringFromBuffer(buffer, perm_array[i].sound_data_name, BFcMaxFileNameLength, inSwapIt); - + // get a pointer to the sound buffer perm_array[i].sound_data = NULL; } - + if (inAllocated == UUcTrue) { UUrMemory_Block_Delete(ioBinaryData); } - + return UUcError_None; } @@ -1888,12 +1888,12 @@ OSiGroup_LevelLoad( void) { UUtError error; - + error = OSrGroup_BuildHashTable(); UUmError_ReturnOnError(error); - + SSrGroup_UpdateSoundDataPointers(); - + return UUcError_None; } @@ -1919,20 +1919,20 @@ OSrGroup_New( UUtError error; SStGroup *group; char name[SScMaxNameLength]; - + *outGroup = NULL; - + OSrMakeGoodName(inName, name); - + group = OSrGroup_GetByName(name); if (group != NULL) { return UUcError_Generic; } - + error = SSrGroup_New(name, outGroup); UUmError_ReturnOnError(error); - + error = OSrGroup_BuildHashTable(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1956,19 +1956,19 @@ OSrGroup_Save( char name[BFcMaxFileNameLength]; UUtUns32 bytes_needed; UUtBool mem_allocated; - + // create the file ref sprintf(name, "%s.%s", inGroup->group_name, OScGroupSuffix); error = BFrFileRef_DuplicateAndAppendName(inParentDirRef, name, &file_ref); UUmError_ReturnOnError(error); - + // create the file if it doesn't exist if (BFrFileRef_FileExists(file_ref) == UUcFalse) { error = BFrFile_Create(file_ref); UUmError_ReturnOnErrorMsg(error, "Could not create the file."); } - + // open the file for writing error = BFrFile_Open( @@ -1976,13 +1976,13 @@ OSrGroup_Save( "w", &file); UUmError_ReturnOnErrorMsg(error, "Could not open the group file."); - + // set the pos to the beginning of the file BFrFile_SetPos(file, 0); - + // get the number of permutations num_permutations = UUrMemory_Array_GetUsedElems(inGroup->permutations); - + // determine if memory needs to be allocated mem_allocated = UUcFalse; bytes_needed = @@ -1994,7 +1994,7 @@ OSrGroup_Save( { data = UUrMemory_Block_New(bytes_needed); UUmError_ReturnOnNull(data); - + data_size = bytes_needed; mem_allocated = UUcTrue; } @@ -2002,29 +2002,29 @@ OSrGroup_Save( // setup the buffer pointer buffer = data; bytes_avail = data_size; - + // write the version BDmWrite4BytesToBuffer(buffer, OS2cCurrentVersion, UUtUns32, bytes_avail, BDcWrite_Little); - + // write the group volume and pitch BDmWrite4BytesToBuffer(buffer, inGroup->group_volume, float, bytes_avail, BDcWrite_Little); BDmWrite4BytesToBuffer(buffer, inGroup->group_pitch, float, bytes_avail, BDcWrite_Little); - + // write the flag and flag data BDmWrite2BytesToBuffer(buffer, (inGroup->flags & SScGroupFlag_WriteMask), UUtUns16, bytes_avail, BDcWrite_Little); BDmWrite2BytesToBuffer(buffer, inGroup->flag_data, UUtUns16, bytes_avail, BDcWrite_Little); - + // write the group channels and permutations to the buffer BDmWrite4BytesToBuffer(buffer, inGroup->num_channels, UUtUns32, bytes_avail, BDcWrite_Little); BDmWrite4BytesToBuffer(buffer, num_permutations, UUtUns32, bytes_avail, BDcWrite_Little); - + perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(inGroup->permutations); for (i = 0; i < num_permutations; i++) { SStPermutation *perm; - + perm = &perm_array[i]; - + BDmWrite4BytesToBuffer(buffer, perm->weight, UUtUns32, bytes_avail, BDcWrite_Little); BDmWrite4BytesToBuffer(buffer, perm->min_volume_percent, float, bytes_avail, BDcWrite_Little); BDmWrite4BytesToBuffer(buffer, perm->max_volume_percent, float, bytes_avail, BDcWrite_Little); @@ -2032,7 +2032,7 @@ OSrGroup_Save( BDmWrite4BytesToBuffer(buffer, perm->max_pitch_percent, float, bytes_avail, BDcWrite_Little); BDmWriteStringToBuffer(buffer, perm->sound_data_name, SScMaxNameLength, bytes_avail, BDcWrite_Little); } - + // write the group error = BDrBinaryData_Write( @@ -2041,23 +2041,23 @@ OSrGroup_Save( (data_size - bytes_avail), file); UUmError_ReturnOnErrorMsg(error, "Unable to write to file."); - + if (mem_allocated) { UUrMemory_Block_Delete(data); data = NULL; } - + // set the EOF BFrFile_SetEOF(file); - + // close the file BFrFile_Close(file); file = NULL; - + UUrMemory_Block_Delete(file_ref); file_ref = NULL; - + return UUcError_None; } @@ -2073,14 +2073,14 @@ OSrImpulse_BuildHashTable( { UUtUns32 num_impulses; UUtUns32 i; - + // delete the old table if (OSgImpulseTable != NULL) { AUrHashTable_Delete(OSgImpulseTable); OSgImpulseTable = NULL; } - + // allocate a new table OSgImpulseTable = AUrHashTable_New( @@ -2089,23 +2089,23 @@ OSrImpulse_BuildHashTable( OSiHashElement_GetHashValue, OSiHashElement_IsEqual); UUmError_ReturnOnNull(OSgImpulseTable); - + // add the ipulse sounds to the table num_impulses = SSrImpulse_GetNumImpulseSounds(); for (i = 0; i < num_impulses; i++) { SStImpulse *impulse; OStHashElement hash_elem; - + impulse = SSrImpulse_GetByIndex(i); if (impulse == NULL) { break; } - + hash_elem.name = impulse->impulse_name; hash_elem.u.impulse = impulse; - + AUrHashTable_Add(OSgImpulseTable, &hash_elem); } - + return UUcError_None; } @@ -2119,16 +2119,16 @@ OSrImpulse_ChangeName( UUmAssert(inImpulse); UUmAssert(inName); - + // save the old name UUrString_Copy(name, inImpulse->impulse_name, SScMaxNameLength); - + // change the impulse's name UUrString_Copy(inImpulse->impulse_name, inName, SScMaxNameLength); - + // update the impulse names OSrVariantList_UpdateImpulseName(name, inName); - + // rebuild the hash table OSrImpulse_BuildHashTable(); } @@ -2139,15 +2139,15 @@ OSrImpulse_Delete( const char *inName) { UUtError error; - + SSrImpulse_Delete(inName, UUcTrue); - + error = OSrImpulse_BuildHashTable(); UUmError_ReturnOnError(error); // an impulse sound has been deleted, we must possibly delete its pointer ONrImpactEffects_SetupSoundPointers(); - + return UUcError_None; } @@ -2157,11 +2157,11 @@ OSrImpulse_GetByName( const char *inName) { OStHashElement *hash_elem; - + // find the hash element for the impulse sound named inName hash_elem = OSiHasElement_GetByName(OSgImpulseTable, inName); if (hash_elem == NULL) { return NULL; } - + // return the impulse pointer return hash_elem->u.impulse; } @@ -2177,21 +2177,21 @@ OSiImpulse_Load( { UUtError error; SStImpulse *impulse; - + UUtUns8 *buffer; UUtUns32 buffer_size; UUtUns32 version; - + char name[SScMaxNameLength]; - + UUmAssert(inIdentifier); UUmAssert(ioBinaryData); - + // ------------------------------ // create a new impulse sound // ------------------------------ OSrMakeGoodName(inIdentifier, name); - + // if no group with this name exists, create a new one, // if one does exist, take it over impulse = SSrImpulse_GetByName(name); @@ -2206,16 +2206,16 @@ OSiImpulse_Load( impulse->impulse_group = NULL; impulse->alt_impulse = NULL; } - + // ------------------------------ // read the binary data // ------------------------------ buffer = ioBinaryData->data; buffer_size = ioBinaryData->header.data_size; - + // read the version number BDmGet4BytesFromBuffer(buffer, version, UUtUns32, inSwapIt); - + BDmGetStringFromBuffer(buffer, impulse->impulse_group_name, SScMaxNameLength, inSwapIt); BDmGet4BytesFromBuffer(buffer, impulse->priority, SStPriority2, inSwapIt); BDmGet4BytesFromBuffer(buffer, impulse->max_volume_distance, float, inSwapIt); @@ -2223,7 +2223,7 @@ OSiImpulse_Load( BDmGet4BytesFromBuffer(buffer, impulse->max_volume_angle, float, inSwapIt); BDmGet4BytesFromBuffer(buffer, impulse->min_volume_angle, float, inSwapIt); BDmGet4BytesFromBuffer(buffer, impulse->min_angle_attenuation, float, inSwapIt); - + if (version < OS2cVersion_4) { impulse->alt_threshold = 0; @@ -2235,7 +2235,7 @@ OSiImpulse_Load( BDmGet4BytesFromBuffer(buffer, impulse->alt_threshold, UUtUns32, inSwapIt); BDmGetStringFromBuffer(buffer, impulse->alt_impulse_name, SScMaxNameLength, inSwapIt); } - + if (version < OS2cVersion_5) { impulse->impact_velocity = 0; @@ -2244,7 +2244,7 @@ OSiImpulse_Load( { BDmGet4BytesFromBuffer(buffer, impulse->impact_velocity, float, inSwapIt); } - + if (version < OS2cVersion_6) { impulse->min_occlusion = 0.0f; @@ -2253,12 +2253,12 @@ OSiImpulse_Load( { BDmGet4BytesFromBuffer(buffer, impulse->min_occlusion, float, inSwapIt); } - + if (inAllocated == UUcTrue) { UUrMemory_Block_Delete(ioBinaryData); } - + return UUcError_None; } @@ -2268,10 +2268,10 @@ OSiImpulse_LevelLoad( void) { UUtError error; - + error = OSrImpulse_BuildHashTable(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2296,15 +2296,15 @@ OSrImpulse_New( { UUtError error; char name[SScMaxNameLength]; - + OSrMakeGoodName(inName, name); error = SSrImpulse_New(name, outImpulse); UUmError_ReturnOnError(error); - + error = OSrImpulse_BuildHashTable(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2320,9 +2320,9 @@ OSrImpulse_Play( UUtBool play; M3tPoint3D position; float volume; - + UUmAssert(inImpulse); - + if (inPosition == NULL) { // do not play spatialized volume = 1.0f; @@ -2340,12 +2340,12 @@ OSrImpulse_Play( UUcFalse, NULL); } - + if (inVolume != NULL) { volume *= (*inVolume); } - + if ((play) && (OSgScriptOnly == UUcFalse)) { SSrImpulse_Play(inImpulse, inPosition, inDirection, inVelocity, &volume); @@ -2366,10 +2366,10 @@ OSrImpulse_PlayByName( float *inVolume) { SStImpulse *impulse; - + impulse = OSrImpulse_GetByName(inImpulseName); if (impulse == NULL) { return; } - + OSrImpulse_Play(impulse, inPosition, inDirection, inVelocity, inVolume); } @@ -2387,19 +2387,19 @@ OSrImpulse_Save( UUtUns8 *buffer; UUtUns32 bytes_avail; char name[BFcMaxFileNameLength]; - + // create the file ref sprintf(name, "%s.%s", inImpulse->impulse_name, OScImpulseSuffix); error = BFrFileRef_DuplicateAndAppendName(inParentDirRef, name, &file_ref); UUmError_ReturnOnError(error); - + // create the file if it doesn't exist if (BFrFileRef_FileExists(file_ref) == UUcFalse) { error = BFrFile_Create(file_ref); UUmError_ReturnOnErrorMsg(error, "Could not create the file."); } - + // open the file for writing error = BFrFile_Open( @@ -2407,17 +2407,17 @@ OSrImpulse_Save( "w", &file); UUmError_ReturnOnErrorMsg(error, "Could not open the group file."); - + // set the pos to the beginning of the file BFrFile_SetPos(file, 0); - + // setup the buffer pointer buffer = data; bytes_avail = OScMaxBufferSize; - + // write the version BDmWrite4BytesToBuffer(buffer, OS2cCurrentVersion, UUtUns32, bytes_avail, BDcWrite_Little); - + // write the ambient sound to the buffer BDmWriteStringToBuffer(buffer, inImpulse->impulse_group_name, SScMaxNameLength, bytes_avail, BDcWrite_Little); BDmWrite4BytesToBuffer(buffer, inImpulse->priority, SStPriority2, bytes_avail, BDcWrite_Little); @@ -2430,7 +2430,7 @@ OSrImpulse_Save( BDmWriteStringToBuffer(buffer, inImpulse->alt_impulse_name, SScMaxNameLength, bytes_avail, BDcWrite_Little); BDmWrite4BytesToBuffer(buffer, inImpulse->impact_velocity, float, bytes_avail, BDcWrite_Little); BDmWrite4BytesToBuffer(buffer, inImpulse->min_occlusion, float, bytes_avail, BDcWrite_Little); - + // write the impulse sound error = BDrBinaryData_Write( @@ -2439,17 +2439,17 @@ OSrImpulse_Save( (OScMaxBufferSize - bytes_avail), file); UUmError_ReturnOnErrorMsg(error, "Unable to write to file."); - + // set the EOF BFrFile_SetEOF(file); - + // close the file BFrFile_Close(file); file = NULL; - + UUrMemory_Block_Delete(file_ref); file_ref = NULL; - + return UUcError_None; } @@ -2465,13 +2465,13 @@ OSiTest( { UUtUns32 itr; UUtUns32 num_items; - + // test groups num_items = SSrGroup_GetNumSoundGroups(); for (itr = 0; itr < num_items; itr++) { SStGroup *group; - + group = SSrGroup_GetByIndex(itr); if (group != OSrGroup_GetByName(group->group_name)) { @@ -2484,7 +2484,7 @@ OSiTest( for (itr = 0; itr < num_items; itr++) { SStImpulse *impulse; - + impulse = SSrImpulse_GetByIndex(itr); if (impulse != OSrImpulse_GetByName(impulse->impulse_name)) { @@ -2498,7 +2498,7 @@ OSiTest( for (itr = 0; itr < num_items; itr++) { SStAmbient *ambient; - + ambient = SSrAmbient_GetByIndex(itr); if (ambient != OSrAmbient_GetByName(ambient->ambient_name)) { @@ -2529,20 +2529,20 @@ OSrInGameDialog_Play( if (ambient == NULL) { goto exit; } - + has_all_sounds = SSrAmbient_CheckSoundData(ambient); if (has_all_sounds) { // we found all the sound data not_found = UUcFalse; } - + play_id = OSrAmbient_Start(ambient, inLocation, NULL, NULL, NULL, NULL); sound_duration = OSiAmbient_GetSimpleDuration(ambient); if (sound_duration == 0) { // could not successfully get a duration from the sound, get a default duration sound_duration = 120; } - + OSrSubtitle_Draw(ambient, sound_duration + OScSubtitleStayTime); exit: @@ -2567,7 +2567,7 @@ OSiDialog_Start( float volume; UUtUns32 sound_duration; UUtBool setup_endcue; - + if (OSgDialog_Playing) { // there is already dialogue playing if (inInterrupt) { @@ -2582,21 +2582,21 @@ OSiDialog_Start( return UUcTrue; } } - + ambient = OSrAmbient_GetByName(inName); if (ambient == NULL) { return UUcFalse; } - + OSgDialog_Playing = UUcTrue; - + // scripted dialog is always highest priority ambient->priority = SScPriority2_Highest; - + // start the ambient sound playing volume = 1.0f; OSgDialog_PlayID = SSrAmbient_Start_Simple(ambient, &volume); - + setup_endcue = UUcTrue; sound_duration = OSiAmbient_GetSimpleDuration(ambient); if (sound_duration == 0) { @@ -2610,7 +2610,7 @@ OSiDialog_Start( setup_endcue = UUcFalse; } } - + if (setup_endcue) { // cue up the dialogue to stop blocking at the correct game tick, even if the sound is // still playing (maybe because we are in fast-forward mode) @@ -2618,9 +2618,9 @@ OSiDialog_Start( } else { OSgDialog_EndTime = 0; } - + OSrSubtitle_Draw(ambient, sound_duration + OScSubtitleStayTime); - + // we completed, don't stall any longer return UUcFalse; } @@ -2636,7 +2636,7 @@ OSiDialog_Play( SLtParameter_Actual *ioReturnValue) { OSiDialog_Start(inParameterList[0].val.str, UUcFalse); - + return UUcError_None; } @@ -2651,7 +2651,7 @@ OSiDialog_Play_Blocked( SLtParameter_Actual *ioReturnValue) { *outStall = OSiDialog_Start(inParameterList[0].val.str, UUcFalse); - + return UUcError_None; } @@ -2678,13 +2678,13 @@ OSrListBrokenSounds( UUtError error; BFtFileRef *file_ref; BFtFile *file; - + // create a file ref error = BFrFileRef_MakeFromName("BrokenSoundLinks.txt", &file_ref); if (error != UUcError_None) { return; } - + // create the .TXT file if it doesn't already exist if (BFrFileRef_FileExists(file_ref) == UUcFalse) { @@ -2694,19 +2694,19 @@ OSrListBrokenSounds( return; } } - + // open the file error = BFrFile_Open(file_ref, "rw", &file); if (error != UUcError_None) { return; } - + // set the position to 0 error = BFrFile_SetPos(file, 0); if (error != UUcError_None) { return; } - + // write the broken links SSrListBrokenSounds(file); OSrSA_ListBrokenSounds(file); @@ -2716,11 +2716,11 @@ OSrListBrokenSounds( // set the end of the file BFrFile_SetEOF(file); - + // close the file BFrFile_Close(file); file = NULL; - + // delete the file ref BFrFileRef_Dispose(file_ref); file_ref = NULL; @@ -2755,11 +2755,11 @@ OSiScriptAmbient_Start( float volume; UUtUns32 itr; OStScriptAmbient *script_ambient; - + // get the ambient sound from the name ambient = OSrAmbient_GetByName(inParameterList[0].val.str); if (ambient == NULL) { return UUcError_None; } - + // get the volume if (inParameterListLength == 2) { @@ -2769,7 +2769,7 @@ OSiScriptAmbient_Start( { volume = 1.0f; } - + // Find an available slot to play the script ambient script_ambient = NULL; for (itr = 0; itr < OScMaxScriptAmbients; itr++) @@ -2778,17 +2778,17 @@ OSiScriptAmbient_Start( if (OSgScriptAmbients[itr].play_id == SScInvalidID) { break; } } if (itr == OScMaxScriptAmbients) { return UUcError_None; } - + // save the name for later scripts and save the user desired volume UUrString_Copy(script_ambient->name, inParameterList[0].val.str, SScMaxNameLength); script_ambient->volume = volume; - + // scripted ambients are always highest priority ambient->priority = SScPriority2_Highest; - + // start the ambient sound script_ambient->play_id = SSrAmbient_Start_Simple(ambient, &volume); - + return UUcError_None; } @@ -2803,23 +2803,23 @@ OSiScriptAmbient_Stop( SLtParameter_Actual *ioReturnValue) { UUtUns32 itr; - + for (itr = 0; itr < OScMaxScriptAmbients; itr++) { OStScriptAmbient *script_ambient; UUtInt32 result; - + script_ambient = &OSgScriptAmbients[itr]; if (script_ambient->play_id == SScInvalidID) { continue; } result = UUrString_Compare_NoCase(script_ambient->name, inParameterList[0].val.str); if (result != 0) { continue; } - + // stop the music SSrAmbient_Stop(script_ambient->play_id); break; } - + return UUcError_None; } @@ -2836,9 +2836,9 @@ OSiScriptAmbient_Volume( UUtUns32 itr; float volume; float time; - + volume = UUmPin(inParameterList[1].val.f, 0.0f, 1.0f); - + if (inParameterListLength == 3) { time = inParameterList[2].val.f; @@ -2847,26 +2847,26 @@ OSiScriptAmbient_Volume( { time = 0.0f; } - + for (itr = 0; itr < OScMaxScriptAmbients; itr++) { OStScriptAmbient *script_ambient; UUtInt32 result; - + script_ambient = &OSgScriptAmbients[itr]; - + result = UUrString_Compare_NoCase(script_ambient->name, inParameterList[0].val.str); if (result != 0) { continue; } - + // save the music volume script_ambient->volume = inParameterList[1].val.f; // set the volume SSrAmbient_SetVolume(script_ambient->play_id, volume, time); - + break; } - + return UUcError_None; } @@ -2882,10 +2882,10 @@ OSiSound_Impulse_Play( { SStImpulse *impulse; float volume; - + impulse = OSrImpulse_GetByName(inParameterList[0].val.str); if (impulse == NULL) { return UUcError_None; } - + if (inParameterListLength == 2) { volume = UUmPin(inParameterList[1].val.f, 0.0f, 1.0f); @@ -2894,9 +2894,9 @@ OSiSound_Impulse_Play( { volume = 1.0f; } - + OSrImpulse_Play(impulse, NULL, NULL, NULL, &volume); - + return UUcError_None; } @@ -2907,43 +2907,43 @@ OSiScriptCommands_Initialize( { UUtError error; UUtUns32 itr; - + // initialize the globals OSgDialog_Playing = UUcFalse; OSgDialog_PlayID = SScInvalidID; OSgDialog_EndTime = 0; - + for (itr = 0; itr < OScMaxScriptAmbients; itr++) { OSgScriptAmbients[itr].play_id = SScInvalidID; } - + // initialize the commands - error = + error = SLrScript_Command_Register_Void( "sound_music_start", "function to start music playing", "name:string [volume:float | ]", OSiScriptAmbient_Start); UUmError_ReturnOnError(error); - - error = + + error = SLrScript_Command_Register_Void( "sound_music_stop", "function to stop playing music", "name:string", OSiScriptAmbient_Stop); UUmError_ReturnOnError(error); - - error = + + error = SLrScript_Command_Register_Void( "sound_music_volume", "function to set the volume of playing music", "name:string volume:float [time:float | ]", OSiScriptAmbient_Volume); UUmError_ReturnOnError(error); - - error = + + error = SLrScript_Command_Register_Void( "sound_dialog_play", "function to start character dialog playing", @@ -2951,22 +2951,22 @@ OSiScriptCommands_Initialize( OSiDialog_Play); UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "sound_dialog_play_block", "function to start character dialog playing after the current dialog finishes", "name:string", OSiDialog_Play_Blocked); UUmError_ReturnOnError(error); - - error = + + error = SLrScript_Command_Register_Void( "sound_dialog_play_interrupt", "function to interrupt the current character dialog and play a new one", "name:string", OSiDialog_Play_Interrupted); UUmError_ReturnOnError(error); - + error = SLrScript_Command_Register_Void( "sound_ambient_start", @@ -2998,7 +2998,7 @@ OSiScriptCommands_Initialize( "name:string [volume:float | ]", OSiSound_Impulse_Play); UUmError_ReturnOnError(error); - + error = SLrScript_Command_Register_Void( "sound_list_broken_links", @@ -3024,11 +3024,11 @@ OSiScriptCommands_Terminate( void) { UUtUns32 itr; - + for (itr = 0; itr < OScMaxScriptAmbients; itr++) { if (OSgScriptAmbients[itr].play_id == SScInvalidID) { continue; } - + SSrAmbient_Halt(OSgScriptAmbients[itr].play_id); OSgScriptAmbients[itr].play_id = SScInvalidID; } @@ -3047,27 +3047,27 @@ OSiScriptCommands_Update( { UUtInt32 result; OStScriptAmbient *script_ambient; - + script_ambient = &OSgScriptAmbients[itr]; if (script_ambient->play_id == SScInvalidID) { continue; } - + result = SSrAmbient_Update(script_ambient->play_id, NULL, NULL, NULL, NULL); if (result == UUcFalse) { script_ambient->play_id = SScInvalidID; } } - + if (!OSgDialog_Playing) { UUmAssert(OSgDialog_PlayID == SScInvalidID); return; } - + current_time = ONrGameState_GetGameTime(); if (OSgDialog_PlayID != SScInvalidID) { UUtBool active; - + active = SSrAmbient_Update(OSgDialog_PlayID, NULL, NULL, NULL, NULL); if (active == UUcFalse) { @@ -3078,7 +3078,7 @@ OSiScriptCommands_Update( return; } } - + if (current_time >= OSgDialog_EndTime) { // the dialogue's time is up, even if the sound is still playing we // should go on to the next one (i.e. stop blocking). this makes fast-forwarding @@ -3100,7 +3100,7 @@ OSrMusic_Halt( void) { if (OSgMusic_PlayID == SScInvalidID) { return; } - + SSrAmbient_Halt(OSgMusic_PlayID); OSgMusic_PlayID = SScInvalidID; } @@ -3120,7 +3120,7 @@ OSrMusic_SetVolume( float inTime) { if (OSgMusic_PlayID == SScInvalidID) { return; } - + SSrAmbient_SetVolume(OSgMusic_PlayID, inVolume, inTime); } @@ -3132,15 +3132,15 @@ OSrMusic_Start( { SStAmbient *ambient; float volume; - + if ((inMusicName == NULL) /*|| (OSgMusic_PlayID != SScInvalidID)*/) { return; } - + ambient = OSrAmbient_GetByName(inMusicName); if (ambient == NULL) { return; } - + // music is always highest priority ambient->priority = SScPriority2_Highest; - + volume = inVolume; OSgMusic_PlayID = SSrAmbient_Start_Simple(ambient, &volume); } @@ -3151,7 +3151,7 @@ OSrMusic_Stop( void) { if (OSgMusic_PlayID == SScInvalidID) { return; } - + SSrAmbient_Stop(OSgMusic_PlayID); } @@ -3161,7 +3161,7 @@ OSiMusic_Update( void) { if (OSgMusic_PlayID == SScInvalidID) { return; } - + if (SSrAmbient_Update(OSgMusic_PlayID, NULL, NULL, NULL, NULL) == UUcFalse) { OSgMusic_PlayID = SScInvalidID; @@ -3187,18 +3187,18 @@ OSiBinFile_Load( UUtUns32 data_size; char identifier[BFcMaxFileNameLength]; UUtBool locked; - + // load the file into memory error = BFrFileRef_LoadIntoMemory(inFileRef, &data_size, &data); UUmError_ReturnOnError(error); - + // get the identifier UUrString_Copy(identifier, BFrFileRef_GetLeafName(inFileRef), BFcMaxFileNameLength); UUrString_StripExtension(identifier); - + // get the locked status of the file locked = BFrFileRef_IsLocked(inFileRef); - + // process the file error = BDrBinaryLoader( @@ -3209,7 +3209,7 @@ OSiBinFile_Load( UUcTrue); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -3227,9 +3227,9 @@ OSiBinFiles_GetDirectory( char binaryDirNameStr[BFcMaxPathLength]; BFtFileRef *binaryDataFolder; BFtFileRef *soundDirRef; - + UUmAssert(outDirectoryRef); - + // find the preferences file #if defined(SHIPPING_VERSION) && (!SHIPPING_VERSION) error = BFrFileRef_Search("Preferences.txt", &prefFileRef); @@ -3241,7 +3241,7 @@ OSiBinFiles_GetDirectory( *outDirectoryRef = NULL; return UUcError_Generic; } - + // create a group from the file error = GRrGroup_Context_NewFromFileRef( @@ -3249,28 +3249,28 @@ OSiBinFiles_GetDirectory( NULL, NULL, &prefGroupContext, - &prefGroup); + &prefGroup); if (error != UUcError_None) { return error; } - + // get the data file directory error = GRrGroup_GetString(prefGroup, "BinFileDir", &binaryDirName); if (error != UUcError_None) { char *dataFileDir; - + // get the data file directory error = GRrGroup_GetString(prefGroup, "DataFileDir", &dataFileDir); if (error != UUcError_None) { return error; } - + // and append the binary data path to the data file dir name sprintf(binaryDirNameStr, "%s\\Binary", dataFileDir); binaryDirName = binaryDirNameStr; - } + } // make a file ref for the binary data folder error = BFrFileRef_MakeFromName(binaryDirName, &binaryDataFolder); if (error != UUcError_None) { return error; } - + GRrGroup_Context_Delete(prefGroupContext); // make sure the binary data folder exists @@ -3278,11 +3278,11 @@ OSiBinFiles_GetDirectory( { UUrMemory_Block_Delete(binaryDataFolder); binaryDataFolder = NULL; - + *outDirectoryRef = NULL; return UUcError_Generic; } - + // find the level0\sound directory error = BFrFileRef_DuplicateAndAppendName( @@ -3290,11 +3290,11 @@ OSiBinFiles_GetDirectory( "Level0\\Sounds", &soundDirRef); UUmError_ReturnOnErrorMsg(error, "Could not create a file ref for Binary\\Level0\\Sounds"); - + // delete the binary data folder UUrMemory_Block_Delete(binaryDataFolder); binaryDataFolder = NULL; - + // make sure the sound directory exists if (BFrFileRef_FileExists(soundDirRef) == UUcFalse) { @@ -3309,13 +3309,13 @@ OSiBinFiles_GetDirectory( // can't find the directory UUrMemory_Block_Delete(soundDirRef); soundDirRef = NULL; - + return UUcError_Generic; } } - + *outDirectoryRef = soundDirRef; - + return UUcError_None; } @@ -3328,7 +3328,7 @@ OSiBinFiles_Load( UUtError error; UUtUns32 count = BFrFileCache_Count(OSgBinFiles_Load_Cache); UUtUns32 itr; - + for(itr = 0; itr < count; itr++) { BFtFileRef *file_ref = BFrFileCache_GetIndex(OSgBinFiles_Load_Cache, itr); @@ -3340,7 +3340,7 @@ OSiBinFiles_Load( if (error != UUcError_None) { break; } } } - + return UUcError_None; } @@ -3362,7 +3362,7 @@ OSiLoadNothing( { UUrMemory_Block_Delete(ioBinaryData); } - + return UUcError_None; } @@ -3373,7 +3373,7 @@ OSiBinaryData_Register( { UUtError error; BDtMethods methods; - + methods.rLoad = OSiAmbient_Load; error = BDrRegisterClass(OScAmbientDataClass, &methods); UUmError_ReturnOnError(error); @@ -3385,11 +3385,11 @@ OSiBinaryData_Register( methods.rLoad = OSiImpulse_Load; error = BDrRegisterClass(OScImpulseDataClass, &methods); UUmError_ReturnOnError(error); - + methods.rLoad = OSiLoadNothing; error = BDrRegisterClass(OScBinaryDataClass, &methods); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -3471,7 +3471,7 @@ OSiNeutral_ListBrokenSounds( UUmAssert(inObject->object_type == OBJcType_Neutral); neutral_osd = (OBJtOSD_Neutral *) inObject->object_data; file = (BFtFile *)inUserData; - + OSrCheckBrokenAmbientSound(file, neutral_osd->name, "abort", neutral_osd->abort_sound); OSrCheckBrokenAmbientSound(file, neutral_osd->name, "trigger", neutral_osd->trigger_sound); OSrCheckBrokenAmbientSound(file, neutral_osd->name, "enemy", neutral_osd->enemy_sound); @@ -3512,17 +3512,17 @@ OSiGroup_AddToList( UUtError error; UUtUns32 num_permutations; UUtUns32 itr; - + num_permutations = SSrGroup_GetNumPermutations(inGroup); - + for (itr = 0; itr < num_permutations; itr++) { SStPermutation *permutation; UUtUns32 index; - + permutation = SSrGroup_Permutation_Get(inGroup, itr); if (permutation == NULL) { continue; } - + error = AUrSharedStringArray_AddString( inStringArray, @@ -3535,7 +3535,7 @@ OSiGroup_AddToList( return error; } } - + return UUcError_None; } @@ -3561,7 +3561,7 @@ OSrAmbient_AddToStringList( return; } } - + if (inAmbient->base_track1) { error = OSiGroup_AddToList(inAmbient->base_track1, inStringArray); @@ -3571,7 +3571,7 @@ OSrAmbient_AddToStringList( return; } } - + if (inAmbient->base_track2) { error = OSiGroup_AddToList(inAmbient->base_track2, inStringArray); @@ -3581,7 +3581,7 @@ OSrAmbient_AddToStringList( return; } } - + if (inAmbient->in_sound) { error = OSiGroup_AddToList(inAmbient->in_sound, inStringArray); @@ -3591,7 +3591,7 @@ OSrAmbient_AddToStringList( return; } } - + if (inAmbient->out_sound) { error = OSiGroup_AddToList(inAmbient->out_sound, inStringArray); @@ -3610,10 +3610,10 @@ OSiSoundObject_BuildStringList( UUtUns32 inUserData) { SStAmbient *ambient; - + ambient = OBJrSound_GetAmbient(inObject); OSrAmbient_AddToStringList(ambient, (AUtSharedStringArray *) inUserData); - + return UUcTrue; } @@ -3632,7 +3632,7 @@ OSiNeutralInteraction_BuildStringList( UUmAssert(inObject->object_type == OBJcType_Neutral); neutral_osd = (OBJtOSD_Neutral *) inObject->object_data; string_array = (AUtSharedStringArray*)inUserData; - + ambient = OSrAmbient_GetByName(neutral_osd->abort_sound); OSrAmbient_AddToStringList(ambient, string_array); @@ -3665,35 +3665,35 @@ OSiObjects_WriteAiffList( UUtUns32 itr; char file_name[BFcMaxFileNameLength]; UUtUns32 num_strings; - + // create the list string_array = AUrSharedStringArray_New(); UUmError_ReturnOnNull(string_array); - + // fill in the list OBJrObjectType_EnumerateObjects( inObjectType, inAddSoundCallback, (UUtUns32)string_array); - + // set the file_name sprintf(file_name, "L%d_%s_aiff.txt", ONrLevel_GetCurrentLevel(), inObjectName); - + // make file ref error = BFrFileRef_MakeFromName(file_name, &file_ref); UUmError_ReturnOnErrorMsg(error, "Unable to create file."); - + // create file if it doesn't exist if (BFrFileRef_FileExists(file_ref) == UUcFalse) { error = BFrFile_Create(file_ref); UUmError_ReturnOnErrorMsg(error, "Unable to create file."); } - + // open the file error = BFrFile_Open(file_ref, "rw", &file); UUmError_ReturnOnErrorMsg(error, "Unable to open file."); - + // set the position to 0 error = BFrFile_SetPos(file, 0); UUmError_ReturnOnError(error); @@ -3705,20 +3705,20 @@ OSiObjects_WriteAiffList( { BFrFile_Printf(file, "%s"UUmNL, string_list[itr].string); } - + // close the file BFrFile_Close(file); file = NULL; - + // delete the file ref BFrFileRef_Dispose(file_ref); file_ref = NULL; - + // delete the list AUrSharedStringArray_Delete(string_array); string_array = NULL; string_list = NULL; - + COrConsole_Printf("Finished writing %s AIFF list to file.", inObjectName); return UUcError_None; @@ -3755,18 +3755,18 @@ OSiSoundObject_BuildPlayList( OBJtOSD_All osd_all; UUtUns32 index; OStPlayingObject *playing_object_array; - + // get the object specific data OBJrObject_GetObjectSpecificData(inObject, &osd_all); - + // get the ambient sound error = UUrMemory_Array_GetNewElement(OSgPlayingObjects, &index, NULL); if (error != UUcError_None) { return UUcFalse; } - + // get a pointer to the memory array playing_object_array = (OStPlayingObject*)UUrMemory_Array_GetMemory(OSgPlayingObjects); if (playing_object_array == NULL) { return UUcFalse; } - + // initialize the array element playing_object_array[index].object = inObject; playing_object_array[index].play_id = SScInvalidID; @@ -3775,7 +3775,7 @@ OSiSoundObject_BuildPlayList( playing_object_array[index].transition_volume = 0.0f; playing_object_array[index].object_volume = OBJrSound_GetVolume(inObject); OSiSetupOcclusionCache(index, &playing_object_array[index].occlusion_cache); - + return UUcTrue; } @@ -3787,34 +3787,34 @@ OSrPlayList_Build( UUtUns32 i; OStPlayingObject *playing_object_array; UUtUns32 num_elements; - + // go through the ambient sound play list and stop the playing sounds playing_object_array = (OStPlayingObject*)UUrMemory_Array_GetMemory(OSgPlayingObjects); num_elements = UUrMemory_Array_GetUsedElems(OSgPlayingObjects); for (i = 0; i < num_elements; i++) { if (playing_object_array[i].play_id == SScInvalidID) { continue; } - + switch (OBJrSound_GetType(playing_object_array[i].object)) { case OBJcSoundType_Spheres: SSrAmbient_Stop(playing_object_array[i].play_id); break; - + case OBJcSoundType_BVolume: SSrAmbient_Stop(playing_object_array[i].play_id); break; } - + playing_object_array[i].play_id = SScInvalidID; } - + // there are no more objects in the playing object array UUrMemory_Array_SetUsedElems(OSgPlayingObjects, 0, NULL); - + // rebuild the list OBJrObjectType_EnumerateObjects(OBJcType_Sound, OSiSoundObject_BuildPlayList, 0); - + return UUcError_None; } @@ -3831,13 +3831,13 @@ OSiPlayList_Initialize( 0, 10); UUmError_ReturnOnNull(OSgPlayingObjects); - + // build a list of the spatial and evironmental ambient sounds in the level OBJrObjectType_EnumerateObjects( OBJcType_Sound, OSiSoundObject_BuildPlayList, 0); - + return UUcError_None; } @@ -3849,28 +3849,28 @@ OSiPlayList_Terminate( UUtUns32 i; OStPlayingObject *playing_object_array; UUtUns32 num_elements; - + // go through the ambient sound play list and stop the playing sounds playing_object_array = (OStPlayingObject*)UUrMemory_Array_GetMemory(OSgPlayingObjects); num_elements = UUrMemory_Array_GetUsedElems(OSgPlayingObjects); for (i = 0; i < num_elements; i++) { if (playing_object_array[i].play_id == SScInvalidID) { continue; } - + switch (OBJrSound_GetType(playing_object_array[i].object)) { case OBJcSoundType_Spheres: SSrAmbient_Stop(playing_object_array[i].play_id); break; - + case OBJcSoundType_BVolume: SSrAmbient_Stop(playing_object_array[i].play_id); break; } - + playing_object_array[i].play_id = SScInvalidID; } - + // delete the ambient sound play list UUrMemory_Array_Delete(OSgPlayingObjects); OSgPlayingObjects = NULL; @@ -3884,7 +3884,7 @@ OSiPlayList_CalcSphereVolume( { float volume; float volume_delta; - + // update occluding volumes over time volume = inVolume; volume_delta = inPlayingObject->transition_volume - volume; @@ -3921,7 +3921,7 @@ OSiPlayList_Update_Spheres( float min_volume_distance; UUtBool can_play; float volume; - + if (OSgScriptOnly == UUcTrue) { return; } if (OBJrSound_PointIn(inPlayingObject->object, inPosition) == UUcFalse) @@ -3931,28 +3931,28 @@ OSiPlayList_Update_Spheres( SSrAmbient_Stop(inPlayingObject->play_id); inPlayingObject->play_id = SScInvalidID; } - + return; } - + // get the ambient sound to play ambient = OBJrSound_GetAmbient(inPlayingObject->object); if (ambient == NULL) { return; } - + // sound objects are always low priority ambient->priority = SScPriority2_Low; - + if (inPlayingObject->play_id != SScInvalidID) { UUtBool is_playing; - + is_playing = SSrAmbient_Update(inPlayingObject->play_id, NULL, NULL, NULL, NULL); if (is_playing == UUcFalse) { inPlayingObject->play_id = SScInvalidID; return; } - + OBJrSound_GetMinMaxDistances( inPlayingObject->object, &max_volume_distance, @@ -3976,17 +3976,17 @@ OSiPlayList_Update_Spheres( OSiPlayList_CalcSphereVolume(inPlayingObject, volume); SSrAmbient_SetVolume(inPlayingObject->play_id, inPlayingObject->volume, 0.0f); } - + return; } - + // play the ambient sound OBJrObject_GetPosition(inPlayingObject->object, &position, NULL); OBJrSound_GetMinMaxDistances( inPlayingObject->object, &max_volume_distance, &min_volume_distance); - + // calculate the position and volume of the sound can_play = OSiCalc_PositionAndVolume( @@ -4001,12 +4001,12 @@ OSiPlayList_Update_Spheres( if (can_play) { OSiPlayList_CalcSphereVolume(inPlayingObject, volume); - + MUmVector_Set(velocity, 0.0f, 0.0f, 0.0f); - + // reuse the volume variable volume = 0.0f; - + inPlayingObject->play_id = SSrAmbient_Start( ambient, @@ -4016,7 +4016,7 @@ OSiPlayList_Update_Spheres( max_volume_distance, min_volume_distance, &volume); - + SSrAmbient_SetVolume(inPlayingObject->play_id, inPlayingObject->volume, 0.25f); } } @@ -4041,11 +4041,11 @@ OSiPL_CalcFadeInVol( float volume; float x_minus_n; float n_squared; - + x_minus_n = (inTicks - OScPL_FadeInTimeTicks); n_squared = OScPL_FadeInTimeTicks * OScPL_FadeInTimeTicks; volume = 1.0f - ((x_minus_n * x_minus_n) / n_squared); - + return volume; } @@ -4056,11 +4056,11 @@ OSiPL_CalcFadeOutVol( float volume; float x_squared; float n_squared; - + x_squared = (inTicks * inTicks); n_squared = (OScPL_FadeInTimeTicks * OScPL_FadeInTimeTicks); volume = 1.0f - (x_squared / n_squared); - + return volume; } @@ -4069,9 +4069,9 @@ OSiPL_CalcFadeInStartTime( float inVolume) { UUtUns32 time; - + time = (UUtUns32)(OScPL_FadeInTimeTicks - (OScPL_FadeInTimeTicks * MUrSqrt(1 - inVolume))); - + return time; } @@ -4085,37 +4085,37 @@ OSiPlayList_Transfer( OStPlayingObject *playing_object_array; UUtUns32 num_elements; UUtBool result; - + result = UUcFalse; - + // go through the ambient sound play list and update the playing sounds playing_object_array = (OStPlayingObject*)UUrMemory_Array_GetMemory(OSgPlayingObjects); num_elements = UUrMemory_Array_GetUsedElems(OSgPlayingObjects); for (i = 0; i < num_elements; i++) { OStPlayingObject *playing_object; - + playing_object = &playing_object_array[i]; - + if (OBJrSound_GetType(playing_object->object) != OBJcSoundType_BVolume) { continue; } if (playing_object->play_id == SScInvalidID) { continue; } if (OBJrSound_GetAmbient(playing_object->object) != inAmbient) { continue; } - + // transfer control of this ambient sound to inPlayingObject inPlayingObject->play_id = playing_object->play_id; inPlayingObject->state = OScPOState_Starting; inPlayingObject->volume = playing_object->volume; inPlayingObject->start_time = inTime - OSiPL_CalcFadeInStartTime(playing_object->volume); - + // release control from the playing ambient playing_object->play_id = SScInvalidID; playing_object->state = OScPOState_Off; playing_object->volume = 0.0f; - + result = UUcTrue; break; } - + return result; } @@ -4130,43 +4130,43 @@ OSiPlayList_Update_BVolume( float ticks; UUtUns32 time; UUtBool is_playing; - + time = UUrMachineTime_Sixtieths(); ticks = (float)(time - inPlayingObject->start_time); - + if (OSgScriptOnly == UUcTrue) { return; } - + if (inPlayingObject->state == OScPOState_Off) { UUtBool result; - + if (OBJrSound_PointIn(inPlayingObject->object, inPosition) == UUcFalse) { return; } - + ambient = OBJrSound_GetAmbient(inPlayingObject->object); if (ambient == NULL) { return; } - + result = OSiPlayList_Transfer(inPlayingObject, ambient, time); if (result == UUcTrue) { return; } - + // sound objects are always low priority ambient->priority = SScPriority2_Low; - + inPlayingObject->state = OScPOState_Starting; inPlayingObject->volume = 0.0f; - + inPlayingObject->play_id = SSrAmbient_Start_Simple(ambient, &inPlayingObject->volume); inPlayingObject->start_time = time; - + return; } - + // handle the starting and stopping states if (inPlayingObject->state == OScPOState_Starting) { if (ticks > OScPL_FadeInTimeTicks) { ticks = OScPL_FadeInTimeTicks; } inPlayingObject->volume = OSiPL_CalcFadeInVol(ticks); - - + + if (inPlayingObject->volume >= 1.0f) { inPlayingObject->volume = 1.0f; @@ -4177,7 +4177,7 @@ OSiPlayList_Update_BVolume( { if (ticks > OScPL_FadeOutTimeTicks) { ticks = OScPL_FadeOutTimeTicks; } inPlayingObject->volume = OSiPL_CalcFadeOutVol(ticks); - + if (inPlayingObject->volume <= 0.0f) { inPlayingObject->volume = 0.0f; @@ -4186,7 +4186,7 @@ OSiPlayList_Update_BVolume( inPlayingObject->play_id = SScInvalidID; } } - + is_playing = SSrAmbient_Update(inPlayingObject->play_id, NULL, NULL, NULL, NULL); if (is_playing == UUcFalse) { @@ -4195,10 +4195,10 @@ OSiPlayList_Update_BVolume( inPlayingObject->play_id = SScInvalidID; return; } - + volume = inPlayingObject->volume * inPlayingObject->object_volume; SSrAmbient_SetVolume(inPlayingObject->play_id, volume, 0.0f); - + // handle general playing if (inPlayingObject->state != OScPOState_Off) { @@ -4208,7 +4208,7 @@ OSiPlayList_Update_BVolume( { inPlayingObject->start_time = time; } - + // user has moved out of the sound volume so stop playing inPlayingObject->state = OScPOState_Stopping; } @@ -4232,7 +4232,7 @@ OSiPlayList_Reset( { OSiPlayList_Terminate(); OSiPlayList_Initialize(); - + return UUcError_None; } @@ -4245,9 +4245,9 @@ OSiPlayList_Update( UUtUns32 i; OStPlayingObject *playing_object_array; UUtUns32 num_elements; - + if (OSgPlayingObjects == NULL) { return; } - + // go through the ambient sound play list and update the playing sounds playing_object_array = (OStPlayingObject*)UUrMemory_Array_GetMemory(OSgPlayingObjects); num_elements = UUrMemory_Array_GetUsedElems(OSgPlayingObjects); @@ -4258,7 +4258,7 @@ OSiPlayList_Update( case OBJcSoundType_Spheres: OSiPlayList_Update_Spheres(&playing_object_array[i], inPosition, inFacing); break; - + case OBJcSoundType_BVolume: OSiPlayList_Update_BVolume( &playing_object_array[i], @@ -4282,9 +4282,9 @@ OSrSubtitle_Draw( { const char *subtitle; ONtLetterBox *letterbox; - + if (!ONrPersist_AreSubtitlesOn()) { return; } - + // get a pointer to the subtitle text subtitle = SSrAmbient_GetSubtitle(inAmbient); if (subtitle == NULL) { return; } @@ -4307,7 +4307,7 @@ OSrRegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register( OScTemplate_SoundBinaryData, @@ -4331,10 +4331,10 @@ OSiBinaryData_ProcHandler( BDtData *data= NULL; UUtBool swap_it; char name[BFcMaxFileNameLength]; - + #if (UUmEndian == UUmEndian_Big) swap_it = UUcTrue; -// uhh hey this is a NULL pointer... -S.S. +// uhh hey this is a NULL pointer... -S.S. // UUrSwap_4Byte(&data->header.class_type); // UUrSwap_4Byte(&data->header.data_size); #else @@ -4342,7 +4342,7 @@ OSiBinaryData_ProcHandler( #endif binary_data = (OStBinaryData*)inInstancePtr; - + switch (inMessage) { case TMcTemplateProcMessage_LoadPostProcess: @@ -4362,17 +4362,17 @@ OSiBinaryData_ProcHandler( UUrSwap_4Byte(&data->header.class_type); UUrSwap_4Byte(&data->header.data_size); } - + UUrString_Copy( name, TMrInstance_GetInstanceName(inInstancePtr), BFcMaxFileNameLength); UUrString_StripExtension(name); - + switch (data->header.class_type) { case OScAmbientDataClass: - error = + error = OSiAmbient_Load( name, data, @@ -4381,7 +4381,7 @@ OSiBinaryData_ProcHandler( UUcTrue); UUmError_ReturnOnError(error); break; - + case OScGroupDataClass: error = OSiGroup_Load( @@ -4392,7 +4392,7 @@ OSiBinaryData_ProcHandler( UUcTrue); UUmError_ReturnOnError(error); break; - + case OScImpulseDataClass: error = OSiImpulse_Load( @@ -4407,7 +4407,7 @@ OSiBinaryData_ProcHandler( } break; } - + return UUcError_None; } @@ -4422,14 +4422,14 @@ OSrGetSoundBinaryDirectory( BFtFileRef **outDirRef) { UUtError error; - + UUmAssert(outDirRef); - + *outDirRef = NULL; - + error = OSiBinFiles_GetDirectory(outDirRef, UUcTrue); UUmError_ReturnOnError(error); - + return error; } @@ -4443,14 +4443,14 @@ OSrGetSoundFileRef( { UUtError error; BFtFileIterator *file_iterator; - + UUmAssert(inName); UUmAssert(inSuffix); UUmAssert(inDirRef); UUmAssert(outFileRef); - + *outFileRef = NULL; - + // make a file iterator error = BFrDirectory_FileIterator_New( @@ -4459,29 +4459,29 @@ OSrGetSoundFileRef( NULL, &file_iterator); UUmError_ReturnOnError(error); - + while (1) { BFtFileRef ref; - + // get the next ref error = BFrDirectory_FileIterator_Next(file_iterator, &ref); if (error != UUcError_None) { break; } - + // process the ref if (BFrFileRef_IsDirectory(&ref) == UUcTrue) { error = OSrGetSoundFileRef(inName, inSuffix, &ref, outFileRef); - + UUmError_ReturnOnError(error); - + if (*outFileRef != NULL) { break; } } else { const char *file_name; char find_name[BFcMaxFileNameLength]; - + file_name = BFrFileRef_GetLeafName(&ref); sprintf(find_name, "%s.%s", inName, inSuffix); if (UUrString_Compare_NoCase(file_name, find_name) == 0) @@ -4491,11 +4491,11 @@ OSrGetSoundFileRef( } } } - + // delete the file iterator BFrDirectory_FileIterator_Delete(file_iterator); file_iterator = NULL; - + return UUcError_None; } @@ -4505,11 +4505,11 @@ OSrInitialize( void) { UUtError error; - + // register the binary data classes error = OSiBinaryData_Register(); UUmError_ReturnOnError(error); - + // get the binary directory for the sound files #if TOOL_VERSION { @@ -4526,33 +4526,33 @@ OSrInitialize( } } #endif - + // register the script commands error = OSiScriptCommands_Initialize(); UUmError_ReturnOnError(error); - + // initialize the sound animations error = OSrSA_Initialize(); UUmError_ReturnOnError(error); - + // intitialize the hash tables error = OSrAmbient_BuildHashTable(); UUmError_ReturnOnError(error); - + error = OSrGroup_BuildHashTable(); UUmError_ReturnOnError(error); - + error = OSrImpulse_BuildHashTable(); UUmError_ReturnOnError(error); - + // initialize the playing ambient array error = OSiPlayingAmbient_Initialize(); UUmError_ReturnOnError(error); - + // initialize the binary data error = OSrRegisterTemplates(); UUmError_ReturnOnError(error); - + // install the proc handler error = TMrTemplate_PrivateData_New( @@ -4566,11 +4566,11 @@ OSrInitialize( OSgEnabled = UUcTrue; OSgScriptOnly = UUcFalse; OSgMusic_PlayID = SScInvalidID; - + // install pointer-update handlers into BFW_SoundSystem2 SS2rInstallPointerHandlers(OSrUpdateImpulsePointers, OSrUpdateAmbientPointers); - error = + error = SLrScript_Command_Register_Void( "sound_objects_reset", "reloads the sounds objects", @@ -4587,32 +4587,32 @@ OSrLevel_Load( UUtUns32 inLevelNum) { UUtError error; - + // start the sound data file cache SSrSoundData_GetByName_StartCache(); - + // enable the playing of sounds OSgEnabled = UUcTrue; - + // set the sound volume SS2rVolume_Set(ONrPersist_GetOverallVolume()); - + if (inLevelNum == 0) { // initialize the variant list error = OSrVariantList_Initialize(); UUmError_ReturnOnError(error); - + // build the hash tables out of the data loaded from the .dat file error = OSrAmbient_BuildHashTable(); UUmError_ReturnOnError(error); - + error = OSrGroup_BuildHashTable(); UUmError_ReturnOnError(error); - + error = OSrImpulse_BuildHashTable(); UUmError_ReturnOnError(error); - + #if TOOL_VERSION if (SSgSearchOnDisk || SSgSearchBinariesOnDisk) { @@ -4624,32 +4624,32 @@ OSrLevel_Load( // load the binary data error = OSiBinFiles_Load(OSgBinaryDir, OScAmbientSuffix); UUmError_ReturnOnError(error); - + error = OSiBinFiles_Load(OSgBinaryDir, OScGroupSuffix); UUmError_ReturnOnError(error); - + error = OSiBinFiles_Load(OSgBinaryDir, OScImpulseSuffix); UUmError_ReturnOnError(error); BFrFileCache_Dispose(OSgBinFiles_Load_Cache); OSgBinFiles_Load_Cache = NULL; } - + // build the hash tables out of the data loaded from the .dat file // and the binary files error = OSrAmbient_BuildHashTable(); UUmError_ReturnOnError(error); - + error = OSrGroup_BuildHashTable(); UUmError_ReturnOnError(error); - + error = OSrImpulse_BuildHashTable(); UUmError_ReturnOnError(error); } // OSiTest(); -#endif - +#endif + // update the pointers SSrGroup_UpdateSoundDataPointers(); SSrAmbient_UpdateGroupPointers(); @@ -4661,24 +4661,24 @@ OSrLevel_Load( OSiAmbient_LevelLoad(); OSiGroup_LevelLoad(); OSiImpulse_LevelLoad(); - + // initialize the playlist OSiPlayList_Initialize(); } - + error = OSrVariantList_LevelLoad(); UUmError_ReturnOnError(error); - + OSrUpdateSoundPointers(); - + SSrSoundData_GetByName_StopCache(); - + OSiFlybyProjectile_Clear(); AKrCollision_InitializeSpatialCache(&OSgListener_OctreeCache); - + SSrLevel_Begin(); - + return UUcError_None; } @@ -4731,13 +4731,13 @@ OSrLevel_Unload( void) { SSrStopAll(); - + OSrVariantList_LevelUnload(); OSiAmbient_LevelUnload(); OSiGroup_LevelUnload(); OSiImpulse_LevelUnload(); - + OSiPlayList_Terminate(); } @@ -4748,23 +4748,23 @@ OSrMakeGoodName( char *outName) { UUtUns32 itr; - + UUmAssert(inName); UUmAssert(outName); - + for(itr = 0; (itr < (SScMaxNameLength - 1)) && (*inName != 0); itr++) { char letter; - + letter = *inName++; - + if (letter == ' ') { letter = '_'; } - + *outName++ = letter; } - + *outName = 0; } @@ -4774,11 +4774,11 @@ OSrSetEnabled( UUtBool inEnabled) { UUtBool prev; - + prev = OSgEnabled; - + OSgEnabled = inEnabled; - + if (OSgEnabled == UUcFalse) { if (prev == UUcTrue) @@ -4816,11 +4816,11 @@ OSrTerminate( OSiPlayingAmbient_Terminate(); OSrVariantList_Terminate(); OSiScriptCommands_Terminate(); - + OSiAmbient_LevelUnload(); OSiGroup_LevelUnload(); OSiImpulse_LevelUnload(); - + #if TOOL_VERSION { if (OSgBinaryDir != NULL) @@ -4830,7 +4830,7 @@ OSrTerminate( } } #endif - + if (OSgPlayingAmbient != NULL) { UUrMemory_Array_Delete(OSgPlayingAmbient); @@ -4848,24 +4848,24 @@ OSrUpdate( OSgNumOcclusionLines = 0; OSgNumOcclusionPoints = 0; #endif - + // set the listener's position SSrListener_SetPosition(inPosition, inFacing); OSgListener_Position = *inPosition; OSgListener_Facing = *inFacing; - + // update the playing ambient sounds OSiAmbient_UpdateAll(); - + // update flyby sounds OSiFlybyProjectiles_Update(); - + // update the sound object play list OSiPlayList_Update(inPosition, inFacing); - + // update the script commands. OSiScriptCommands_Update(); - + // update the music OSiMusic_Update(); } @@ -4910,7 +4910,7 @@ OSrFlybyProjectile_Create( return UUcFalse; } - // calculate + // calculate projectile->prev_position = projectile->position; @@ -5020,7 +5020,7 @@ OSiFlybyProjectiles_Update( { UUtUns32 itr; OStFlybyProjectile *projectile; - + if (OSgFlybyProjectile == NULL) { return; } for (itr = 0, projectile = OSgFlybyProjectile; itr < OSgNumFlybyProjectiles; itr++, projectile++) { diff --git a/OniProj/OniGameSource/Oni_Sound2.h b/OniProj/OniGameSource/Oni_Sound2.h index 53d8abf..2686540 100644 --- a/OniProj/OniGameSource/Oni_Sound2.h +++ b/OniProj/OniGameSource/Oni_Sound2.h @@ -37,7 +37,7 @@ enum OS2cVersion_4 = 4, /* added alternate impulse to SStImpulse */ OS2cVersion_5 = 5, /* added threshold to SStAmbient */ OS2cVersion_6 = 6, /* added flag and flag_data to SStGroup and min_occlusion to SStAmbient and SStImpulse */ - + OS2cCurrentVersion = OS2cVersion_6 }; @@ -50,7 +50,7 @@ OStBinaryData { UUtUns32 data_size; tm_separate data_index; - + } OStBinaryData; // ====================================================================== @@ -71,15 +71,15 @@ void OSrAmbient_ChangeName( SStAmbient *inAmbient, const char *inName); - + UUtError OSrAmbient_Delete( const char *inName); - + SStAmbient* OSrAmbient_GetByName( const char *inName); - + void OSrAmbient_Halt( SStPlayID inAmbientID); @@ -93,7 +93,7 @@ UUtError OSrAmbient_Save( SStAmbient *inAmbient, BFtFileRef *inParentDirRef); - + SStPlayID OSrAmbient_Start( const SStAmbient *inAmbient, @@ -113,7 +113,7 @@ OSrAmbient_Update( const M3tPoint3D *inPosition, const M3tVector3D *inDirection, const M3tVector3D *inVelocity); - + // ---------------------------------------------------------------------- UUtError OSrGroup_BuildHashTable( @@ -123,39 +123,39 @@ void OSrGroup_ChangeName( SStGroup *inGroup, const char *inName); - + UUtError OSrGroup_Delete( const char *inName); - + SStGroup* OSrGroup_GetByName( const char *inName); - + UUtError OSrGroup_New( const char *inName, SStGroup **outGroup); - + UUtError OSrGroup_Save( SStGroup *inGroup, BFtFileRef *inParentDirRef); - + // ---------------------------------------------------------------------- void OSrImpulse_ChangeName( SStImpulse *inImpulse, const char *inName); - + UUtError OSrImpulse_Delete( const char *inName); - + SStImpulse* OSrImpulse_GetByName( const char *inName); - + UUtError OSrImpulse_New( const char *inName, @@ -168,7 +168,7 @@ OSrImpulse_Play( const M3tVector3D *inDirection, const M3tVector3D *inVelocity, float *inVolume); - + void OSrImpulse_PlayByName( const char *inImpulseName, @@ -176,12 +176,12 @@ OSrImpulse_PlayByName( const M3tVector3D *inDirection, const M3tVector3D *inVelocity, float *inVolume); - + UUtError OSrImpulse_Save( SStImpulse *inImpulse, BFtFileRef *inParentDirRef); - + // ---------------------------------------------------------------------- UUtError OSrGetSoundBinaryDirectory( @@ -193,7 +193,7 @@ OSrGetSoundFileRef( const char *inSuffix, BFtFileRef *inDirRef, BFtFileRef **outFileRef); - + // ---------------------------------------------------------------------- UUtError OSrPlayList_Build( @@ -202,7 +202,7 @@ OSrPlayList_Build( UUtError OSrSoundObjects_WriteAiffList( void); - + UUtError OSrNeutralInteractions_WriteAiffList( void); @@ -239,25 +239,25 @@ OSrMusic_Halt( UUtBool OSrMusic_IsPlaying( void); - + void OSrMusic_SetVolume( float inVolume, float inTime); - + void OSrMusic_Start( const char *inMusicName, float inVolume); - + void OSrMusic_Stop( void); - + // ---------------------------------------------------------------------- void OSrMusic_SetIsOn_Hook(UUtBool inIsOn); - + void OSrMusic_SetVolume_Hook(float oldVolume, float newVolume); @@ -281,7 +281,7 @@ OSrInitialize( UUtError OSrLevel_Load( UUtUns32 inLevelNum); - + void OSrUpdateSoundPointers( void); @@ -289,29 +289,29 @@ OSrUpdateSoundPointers( void OSrLevel_Unload( void); - + void OSrMakeGoodName( const char *inName, char *outName); - + void OSrSetEnabled( UUtBool inEnabled); - + void OSrSetScriptOnly( UUtBool inIsScriptOnly); - + void OSrTerminate( void); - + void OSrUpdate( const M3tPoint3D *inPosition, const M3tVector3D *inFacing); - + // ---------------------------------------------------------------------- UUtError OSrRegisterTemplates( @@ -329,4 +329,4 @@ OSrFlybyProjectile_Delete( P3tParticle *inParticle); // ====================================================================== -#endif /* ONI_SOUND2_H */ \ No newline at end of file +#endif /* ONI_SOUND2_H */ diff --git a/OniProj/OniGameSource/Oni_Sound_Animation.c b/OniProj/OniGameSource/Oni_Sound_Animation.c index 6d0245b..dbbf831 100644 --- a/OniProj/OniGameSource/Oni_Sound_Animation.c +++ b/OniProj/OniGameSource/Oni_Sound_Animation.c @@ -32,7 +32,7 @@ struct OStVariant { const ONtCharacterVariant *character_variant; - UUtMemory_Array *anim_type_sounds[OScAnimType_NumTypes]; + UUtMemory_Array *anim_type_sounds[OScAnimType_NumTypes]; }; typedef struct OStTotoroToSound @@ -40,7 +40,7 @@ typedef struct OStTotoroToSound TRtAnimType totoro_anim_type; OStAnimType sound_anim_type; OStModType sound_mod_type; - + } OStTotoroToSound; // ====================================================================== @@ -70,7 +70,7 @@ static OStTypeName OSgAnimTypeName[] = { "Getting Hit", OScAnimType_GettingHit }, { "Holster", OScAnimType_Holster }, { "Kick", OScAnimType_Kick }, - { "Knockdown", OScAnimType_Knockdown }, + { "Knockdown", OScAnimType_Knockdown }, { "Land", OScAnimType_Land }, { "Jump", OScAnimType_Jump }, { "Pickup", OScAnimType_Pickup }, @@ -86,12 +86,12 @@ static OStTypeName OSgAnimTypeName[] = { "Run", OScAnimType_Run }, { "Slide", OScAnimType_Slide }, { "Stand", OScAnimType_Stand }, - { "Startle", OScAnimType_Startle }, + { "Startle", OScAnimType_Startle }, { "Walk", OScAnimType_Walk }, { "Powerup", OScAnimType_Powerup }, { "Roll", OScAnimType_Roll }, { "Falling Flail", OScAnimType_FallingFlail }, - + { NULL, OScAnimType_None } }; @@ -104,10 +104,10 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_Slide, OScAnimType_Slide, OScModType_Any }, { ONcAnimType_Jump, OScAnimType_Jump, OScModType_Any }, { ONcAnimType_Stand, OScAnimType_Stand, OScModType_Any }, - + { ONcAnimType_Standing_Turn_Left, OScAnimType_None, OScModType_Any }, { ONcAnimType_Standing_Turn_Right, OScAnimType_None, OScModType_Any }, - + { ONcAnimType_Run_Backwards, OScAnimType_Run, OScModType_Any }, { ONcAnimType_Run_Sidestep_Left, OScAnimType_Run, OScModType_Any }, { ONcAnimType_Run_Sidestep_Right, OScAnimType_Run, OScModType_Any }, @@ -116,9 +116,9 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_Walk_Sidestep_Right, OScAnimType_Walk, OScModType_Any }, { ONcAnimType_Walk_Backwards, OScAnimType_Walk, OScModType_Any }, { ONcAnimType_Stance, OScAnimType_Stand, OScModType_Any }, - + { ONcAnimType_Crouch, OScAnimType_None, OScModType_Any }, - + { ONcAnimType_Jump_Forward, OScAnimType_Jump, OScModType_Any }, { ONcAnimType_Jump_Backward, OScAnimType_Jump, OScModType_Any }, { ONcAnimType_Jump_Left, OScAnimType_Jump, OScModType_Any }, @@ -157,7 +157,7 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_Kick_Heavy, OScAnimType_Kick, OScModType_Any }, { ONcAnimType_Punch_Forward_Heavy, OScAnimType_Punch, OScModType_Any }, { ONcAnimType_Kick_Forward_Heavy, OScAnimType_Kick, OScModType_Any }, - + { ONcAnimType_Aiming_Overlay, OScAnimType_None, OScModType_Any }, { ONcAnimType_Hit_Overlay, OScAnimType_GettingHit, OScModType_Any }, { ONcAnimType_Crouch_Run, OScAnimType_None, OScModType_Crouch }, @@ -168,7 +168,7 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_Crouch_Run_Sidestep_Right, OScAnimType_None, OScModType_Crouch }, { ONcAnimType_Crouch_Walk_Sidestep_Left, OScAnimType_None, OScModType_Crouch }, { ONcAnimType_Crouch_Walk_Sidestep_Right, OScAnimType_None, OScModType_Crouch }, - + { ONcAnimType_Run_Kick, OScAnimType_Kick, OScModType_Any }, { ONcAnimType_Run_Punch, OScAnimType_Punch, OScModType_Any }, { ONcAnimType_Run_Back_Punch, OScAnimType_Punch, OScModType_Any }, @@ -178,7 +178,7 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_Sidestep_Right_Kick, OScAnimType_Kick, OScModType_Any }, { ONcAnimType_Sidestep_Right_Punch, OScAnimType_Punch, OScModType_Any }, { ONcAnimType_Prone, OScAnimType_Fall, OScModType_Any }, - + { ONcAnimType_Flip, OScAnimType_None, OScModType_Any }, { ONcAnimType_Hit_Head, OScAnimType_GettingHit, OScModType_Any }, { ONcAnimType_Hit_Body, OScAnimType_GettingHit, OScModType_Any }, @@ -199,7 +199,7 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_Knockdown_Crouch_Behind, OScAnimType_Knockdown, OScModType_Any }, { ONcAnimType_Idle, OScAnimType_None, OScModType_Any }, { ONcAnimType_Taunt, OScAnimType_None, OScModType_Any }, - + { ONcAnimType_Throw, OScAnimType_None, OScModType_Any }, { ONcAnimType_Thrown1, OScAnimType_None, OScModType_Any }, { ONcAnimType_Thrown2, OScAnimType_None, OScModType_Any }, @@ -211,7 +211,7 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_Special2, OScAnimType_None, OScModType_Any }, { ONcAnimType_Special3, OScAnimType_None, OScModType_Any }, { ONcAnimType_Special4, OScAnimType_None, OScModType_Any }, - + { ONcAnimType_Throw_Forward_Punch, OScAnimType_Punch, OScModType_Any }, { ONcAnimType_Throw_Forward_Kick, OScAnimType_Kick, OScModType_Any }, { ONcAnimType_Throw_Behind_Punch, OScAnimType_Punch, OScModType_Any }, @@ -220,32 +220,32 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_Run_Throw_Behind_Punch, OScAnimType_Punch, OScModType_Any }, { ONcAnimType_Run_Throw_Forward_Kick, OScAnimType_Kick, OScModType_Any }, { ONcAnimType_Run_Throw_Behind_Kick, OScAnimType_Kick, OScModType_Any }, - + { ONcAnimType_Thrown7, OScAnimType_None, OScModType_Any }, { ONcAnimType_Thrown8, OScAnimType_None, OScModType_Any }, { ONcAnimType_Thrown9, OScAnimType_None, OScModType_Any }, { ONcAnimType_Thrown10, OScAnimType_None, OScModType_Any }, { ONcAnimType_Thrown11, OScAnimType_None, OScModType_Any }, { ONcAnimType_Thrown12, OScAnimType_None, OScModType_Any }, - + { ONcAnimType_Startle_Left_Unused, OScAnimType_Startle, OScModType_Any }, { ONcAnimType_Startle_Right_Unused, OScAnimType_Startle, OScModType_Any }, - + { ONcAnimType_Sit, OScAnimType_None, OScModType_Any }, { ONcAnimType_Stand_Special, OScAnimType_None, OScModType_Any }, { ONcAnimType_Act, OScAnimType_None, OScModType_Any }, - + { ONcAnimType_Kick3_Forward, OScAnimType_Kick, OScModType_Any }, - + { ONcAnimType_Hit_Foot_Ouch, OScAnimType_GettingHit, OScModType_Any }, { ONcAnimType_Hit_Jewels, OScAnimType_GettingHit, OScModType_Any }, - + { ONcAnimType_Thrown13, OScAnimType_None, OScModType_Any }, { ONcAnimType_Thrown14, OScAnimType_None, OScModType_Any }, { ONcAnimType_Thrown15, OScAnimType_None, OScModType_Any }, { ONcAnimType_Thrown16, OScAnimType_None, OScModType_Any }, { ONcAnimType_Thrown17, OScAnimType_None, OScModType_Any }, - + { ONcAnimType_PPKK, OScAnimType_Kick, OScModType_Any }, { ONcAnimType_PPKKK, OScAnimType_Kick, OScModType_Any }, { ONcAnimType_PPKKKK, OScAnimType_Kick, OScModType_Any }, @@ -255,16 +255,16 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_Land_Left_Hard, OScAnimType_Land, OScModType_Any }, { ONcAnimType_Land_Back_Hard, OScAnimType_Land, OScModType_Any }, { ONcAnimType_Land_Dead, OScAnimType_Land, OScModType_Any }, - + { ONcAnimType_Crouch_Turn_Left, OScAnimType_None, OScModType_Crouch }, { ONcAnimType_Crouch_Turn_Right, OScAnimType_None, OScModType_Crouch }, { ONcAnimType_Crouch_Forward, OScAnimType_Roll, OScModType_Crouch }, { ONcAnimType_Crouch_Back, OScAnimType_Roll, OScModType_Crouch }, { ONcAnimType_Crouch_Left, OScAnimType_Roll, OScModType_Crouch }, { ONcAnimType_Crouch_Right, OScAnimType_Roll, OScModType_Crouch }, - + { ONcAnimType_Getup_Kick_Back, OScAnimType_Kick, OScModType_Any }, - + { ONcAnimType_Autopistol_Recoil, OScAnimType_None, OScModType_Any }, { ONcAnimType_Phase_Rifle_Recoil, OScAnimType_None, OScModType_Any }, { ONcAnimType_Phase_Stream_Recoil, OScAnimType_None, OScModType_Any }, @@ -273,17 +273,17 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_Scram_Cannon_Recoil, OScAnimType_None, OScModType_Any }, { ONcAnimType_Mercury_Bow_Recoil, OScAnimType_None, OScModType_Any }, { ONcAnimType_Screamer_Recoil, OScAnimType_None, OScModType_Any }, - + { ONcAnimType_Pickup_Object, OScAnimType_None, OScModType_Any }, { ONcAnimType_Pickup_Pistol, OScAnimType_None, OScModType_Any }, { ONcAnimType_Pickup_Rifle, OScAnimType_None, OScModType_Any }, - + { ONcAnimType_Holster, OScAnimType_Holster, OScModType_Any }, { ONcAnimType_Draw_Pistol, OScAnimType_DrawWeapon, OScModType_Any }, { ONcAnimType_Draw_Rifle, OScAnimType_DrawWeapon, OScModType_Any }, - + { ONcAnimType_Punch4, OScAnimType_Punch, OScModType_Any }, - + { ONcAnimType_Reload_Pistol, OScAnimType_Reload_Pistol, OScModType_Any }, { ONcAnimType_Reload_Rifle, OScAnimType_Reload_Rifle, OScModType_Any }, { ONcAnimType_Reload_Stream, OScAnimType_Reload_Stream, OScModType_Any }, @@ -292,7 +292,7 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_Reload_Scram_Cannon, OScAnimType_Reload_Scram_Cannon, OScModType_Any }, { ONcAnimType_Reload_MercuryBow, OScAnimType_Reload_MercuryBow, OScModType_Any }, { ONcAnimType_Reload_Screamer, OScAnimType_Reload_Screamer, OScModType_Any }, - + { ONcAnimType_PF_PF, OScAnimType_Punch, OScModType_Any }, { ONcAnimType_PF_PF_PF, OScAnimType_Punch, OScModType_Any }, { ONcAnimType_PL_PL, OScAnimType_Punch, OScModType_Any }, @@ -313,7 +313,7 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_KB_KB_KB, OScAnimType_Kick, OScModType_Any }, { ONcAnimType_KD_KD, OScAnimType_Kick, OScModType_Any }, { ONcAnimType_KD_KD_KD, OScAnimType_Kick, OScModType_Any }, - + { ONcAnimType_Startle_Left, OScAnimType_Startle, OScModType_Any }, { ONcAnimType_Startle_Right, OScAnimType_Startle, OScModType_Any }, { ONcAnimType_Startle_Back, OScAnimType_Startle, OScModType_Any }, @@ -321,7 +321,7 @@ static OStTotoroToSound OSgTotoroToSoundInternal[ONcAnimType_Num] = { ONcAnimType_Console, OScAnimType_None, OScModType_Any }, { ONcAnimType_Console_Walk, OScAnimType_Walk, OScModType_Any }, { ONcAnimType_Stagger, OScAnimType_None, OScModType_Any }, - + { ONcAnimType_Watch, OScAnimType_None, OScModType_Any }, { ONcAnimType_Act_No, OScAnimType_None, OScModType_Any }, @@ -381,9 +381,9 @@ OSiTotoroToSound( #if defined(DEBUGGING) && (DEBUGGING) { static UUtBool once = UUcTrue; - + if (once) { - UUtUns32 itr; + UUtUns32 itr; for(itr = 0; itr < ONcAnimType_Num; itr++) { @@ -419,14 +419,14 @@ OSiVariant_CalcWriteSize( UUtUns32 i; UUtUns32 element_size; UUtUns32 size; - + // calculate the total number of elements in the variant num_elements = 0; for (i = 0; i < OScAnimType_NumTypes; i++) { num_elements += UUrMemory_Array_GetUsedElems(inVariant->anim_type_sounds[i]); } - + // calculate the number of bytes needed to save one OStSoundAnimation element_size = sizeof(UUtTag) + /* tag */ @@ -437,10 +437,10 @@ OSiVariant_CalcWriteSize( SScMaxNameLength + /* anim_type base name */ OScMaxAnimNameLength + /* OScMaxAnimNameLength */ SScMaxNameLength; /* impulse sound name */ - + // calculate the total number of bytes needed to save all of the OStSoundAnimations size = num_elements * element_size; - + return size; } @@ -453,9 +453,9 @@ OSiVariant_DeleteAllSounds( UUtMemory_Array *type_array; OStSoundAnimation *sound_array; UUtUns32 num_elements; - + UUmAssert(ioVariant); - + // clear the sound of all animations type_array = ioVariant->anim_type_sounds[OScAnimType_Animation]; sound_array = (OStSoundAnimation*)UUrMemory_Array_GetMemory(type_array); @@ -463,10 +463,10 @@ OSiVariant_DeleteAllSounds( for (itr = 0; itr < num_elements; itr++) { TRtAnimation *animation; - + animation = sound_array[itr].animation; if (animation == NULL) { continue; } - + TRrAnimation_SetSoundName(animation, NULL, (TRtAnimTime)0); } @@ -493,15 +493,15 @@ OSrVariant_GetNumSounds( { UUtUns32 i; UUtUns32 num_sounds; - + UUmAssert(inVariant); - + num_sounds = 0; for (i = 0; i < OScAnimType_NumTypes; i++) { num_sounds += UUrMemory_Array_GetUsedElems(inVariant->anim_type_sounds[i]); } - + return num_sounds; } @@ -519,13 +519,13 @@ OSiVariant_Impulse_Get( UUmAssert(inVariant); out_impulse = NULL; - + // see if the animation has a valid impulse sound if (inAnimation != NULL) { impulse_name = TRrAnimation_GetSoundName(inAnimation); - if (impulse_name != NULL) + if (impulse_name != NULL) { out_impulse = OSrImpulse_GetByName(impulse_name); if (out_impulse == NULL) { @@ -536,14 +536,14 @@ OSiVariant_Impulse_Get( goto exit; } } - + if ((out_impulse == NULL) && (inAnimType != OScAnimType_Animation)) { UUtMemory_Array *type_array; OStSoundAnimation *sound_array; UUtUns32 i; UUtUns32 num_elements; - + // search the inAnimType sound array for the best sound type_array = inVariant->anim_type_sounds[inAnimType]; sound_array = (OStSoundAnimation*)UUrMemory_Array_GetMemory(type_array); @@ -556,11 +556,11 @@ OSiVariant_Impulse_Get( (sound_array[i].mod_type == inModType)) { out_impulse = OSrImpulse_GetByName(sound_array[i].impulse_name); - + if (sound_array[i].mod_type == inModType) { break; } } } - + if (out_impulse == NULL) { // search the OScAnimType_Any sound array for the best sound @@ -573,17 +573,17 @@ OSiVariant_Impulse_Get( (sound_array[i].mod_type == inModType)) { out_impulse = OSrImpulse_GetByName(sound_array[i].impulse_name); - + if (sound_array[i].mod_type == inModType) { break; } } } } } - + exit: return out_impulse; } - + // ---------------------------------------------------------------------- static SStImpulse* OSiVariant_Impulse_GetExact( @@ -594,7 +594,7 @@ OSiVariant_Impulse_GetExact( { SStImpulse *out_impulse; const char *impulse_name; - + UUmAssert(inVariant); out_impulse = NULL; @@ -615,7 +615,7 @@ OSiVariant_Impulse_GetExact( OStSoundAnimation *sound_array; UUtUns32 i; UUtUns32 num_elements; - + // search the inAnimType sound array for the best sound type_array = inVariant->anim_type_sounds[inAnimType]; sound_array = (OStSoundAnimation*)UUrMemory_Array_GetMemory(type_array); @@ -628,10 +628,10 @@ OSiVariant_Impulse_GetExact( break; } } - + return out_impulse; } - + // ---------------------------------------------------------------------- static UUtError OSiVariant_Initialize( @@ -639,13 +639,13 @@ OSiVariant_Initialize( ONtCharacterVariant *inCharacterVariant) { UUtUns32 i; - + UUmAssert(ioVariant); UUmAssert(inCharacterVariant); - + // set the character variant ioVariant->character_variant = inCharacterVariant; - + // allocate the memory arrays for (i = 0; i < OScAnimType_NumTypes; i++) { @@ -657,7 +657,7 @@ OSiVariant_Initialize( 0); UUmError_ReturnOnNull(ioVariant->anim_type_sounds[i]); } - + return UUcError_None; } @@ -678,7 +678,7 @@ OSrVariant_SoundAnimation_Add( UUtUns32 index; OStSoundAnimation *sound_array; const char *anim_name; - + UUmAssert(ioVariant); UUmAssert(inImpulseName); @@ -686,9 +686,9 @@ OSrVariant_SoundAnimation_Add( if (inAnimType == OScAnimType_Animation) { UUmAssert(inAnimationName); - + error = TMrInstance_GetDataPtr(TRcTemplate_Animation, inAnimationName, &animation); - if (error != UUcError_None) { animation = NULL; } + if (error != UUcError_None) { animation = NULL; } anim_name = inAnimationName; } else @@ -696,19 +696,19 @@ OSrVariant_SoundAnimation_Add( animation = NULL; anim_name = ""; } - + // see if a sound animation already exists for these parameters impulse = OSiVariant_Impulse_GetExact(ioVariant, animation, inAnimType, inModType); if (impulse != NULL) { return UUcError_Generic; } - + // add the sound animation to the variant type_array = ioVariant->anim_type_sounds[inAnimType]; error = UUrMemory_Array_GetNewElement(type_array, &index, NULL); UUmError_ReturnOnError(error); - + sound_array = (OStSoundAnimation*)UUrMemory_Array_GetMemory(type_array); UUmAssert(sound_array); - + // initialize the element sound_array[index].anim_type = inAnimType; sound_array[index].mod_type = inModType; @@ -717,13 +717,13 @@ OSrVariant_SoundAnimation_Add( sound_array[index].animation = animation; UUrString_Copy(sound_array[index].anim_name, anim_name, OScMaxAnimNameLength); UUrString_Copy(sound_array[index].impulse_name, inImpulseName, SScMaxNameLength); - + // set the sound id of the animation if (animation != NULL) { TRrAnimation_SetSoundName(animation, sound_array[index].impulse_name, (TRtAnimTime)inFrame); } - + return UUcError_None; } @@ -735,17 +735,17 @@ OSrVariant_SoundAnimation_DeleteByIndex( { UUtUns32 i; UUtUns32 index; - + UUmAssert(ioVariant); - + index = inIndex; - + // go through all of the anim types and find the one which has this index // then delete the OStSoundAnimation from the anim type sound array for (i = 0; i < OScAnimType_NumTypes; i++) { UUtUns32 num_elements; - + num_elements = UUrMemory_Array_GetUsedElems(ioVariant->anim_type_sounds[i]); if (index < num_elements) { @@ -753,7 +753,7 @@ OSrVariant_SoundAnimation_DeleteByIndex( if (i == OScAnimType_Animation) { OStSoundAnimation *sound_array; - + sound_array = (OStSoundAnimation*)UUrMemory_Array_GetMemory(ioVariant->anim_type_sounds[i]); if (sound_array[index].animation) @@ -761,11 +761,11 @@ OSrVariant_SoundAnimation_DeleteByIndex( TRrAnimation_SetSoundName(sound_array[index].animation, NULL, 0); } } - + UUrMemory_Array_DeleteElement(ioVariant->anim_type_sounds[i], index); break; } - + index -= num_elements; } } @@ -779,30 +779,30 @@ OSrVariant_SoundAnimation_GetByIndex( OStSoundAnimation *sound_animation; UUtUns32 i; UUtUns32 index; - + UUmAssert(inVariant); - + sound_animation = NULL; index = inIndex; - + // go through all of the anim types and find the one which has this index // then get the OStSoundAnimation from the anim type sound array for (i = 0; i < OScAnimType_NumTypes; i++) { UUtUns32 num_elements; - + num_elements = UUrMemory_Array_GetUsedElems(inVariant->anim_type_sounds[i]); if (index < num_elements) { OStSoundAnimation *sound_array; - + sound_array = (OStSoundAnimation*)UUrMemory_Array_GetMemory(inVariant->anim_type_sounds[i]); sound_animation = &sound_array[index]; - + break; } - + index -= num_elements; } @@ -815,7 +815,7 @@ OSiVariant_Terminate( OStVariant *ioVariant) { UUtUns32 i; - + UUmAssert(ioVariant); // delete the memory arrays @@ -834,14 +834,14 @@ OSiVariant_UpdateImpulseName( const char *inNewImpulseName) { UUtUns32 i; - + for (i = 0; i < OScAnimType_NumTypes; i++) { UUtMemory_Array *type_array; OStSoundAnimation *sound_array; UUtUns32 num_elements; UUtUns32 j; - + type_array = ioVariant->anim_type_sounds[i]; sound_array = (OStSoundAnimation*)UUrMemory_Array_GetMemory(type_array); num_elements = UUrMemory_Array_GetUsedElems(type_array); @@ -895,11 +895,11 @@ OSiSABinaryData_Load( UUtUns32 variant_data_length; char *variant_name; OStVariant *variant; - - + + UUmAssert(inIdentifier); UUmAssert(ioBinaryData); - + UUrMemory_Block_VerifyList(); // make sure the variant list is initialized @@ -908,10 +908,10 @@ UUrMemory_Block_VerifyList(); error = OSrVariantList_Initialize(); UUmError_ReturnOnError(error); } - + buffer = ioBinaryData->data; buffer_size = ioBinaryData->header.data_size; - + // find the tags error = UUrFindTagData( @@ -922,10 +922,10 @@ UUrMemory_Block_VerifyList(); &sa_file_data, &sa_file_data_length); UUmError_ReturnOnError(error); - + // read the version number OBDmGet4BytesFromBuffer(sa_file_data, version, UUtUns32, inSwapIt); - + // find the variant tags error = UUrFindTagData( @@ -936,11 +936,11 @@ UUrMemory_Block_VerifyList(); &variant_data, &variant_data_length); UUmError_ReturnOnError(error); - + // read the variant name variant_name = (char*)variant_data; variant_data += ONcMaxVariantNameLength; - + // get a pointer to the variant variant = OSrVariantList_Variant_GetByName(variant_name); if (variant != NULL) @@ -948,10 +948,10 @@ UUrMemory_Block_VerifyList(); // delete all of the sound animations in the variant OSiVariant_DeleteAllSounds(variant); } - + buffer = variant_data; /* variant_data should be at the end of the VariantTag block */ buffer_size = ioBinaryData->header.data_size - (buffer - ioBinaryData->data); - + // process the sound animations // NOTE: the sound animations for a variant MUST be grouped together after // the OScVariantTag @@ -966,7 +966,7 @@ UUrMemory_Block_VerifyList(); char *anim_name; const char *impulse_name; UUtUns32 frame; - + // find the sound animation tag error = UUrFindTagData( @@ -977,42 +977,42 @@ UUrMemory_Block_VerifyList(); &sa_data, &sa_data_length); if (error != UUcError_None) { break; } - + // read the frame OBDmGet4BytesFromBuffer(sa_data, frame, UUtUns32, inSwapIt); - + // get the mod_type and anim_type mod_name = (char*)sa_data; sa_data += SScMaxNameLength; - + base_name = (char*)sa_data; sa_data += SScMaxNameLength; - + anim_type = OSrAnimType_GetByName(base_name); mod_type = OSrModType_GetByName(mod_name); - + // read the anim name anim_name = (char*)sa_data; sa_data += OScMaxAnimNameLength; - + // read the impulse name impulse_name = (char*)sa_data; sa_data += SScMaxNameLength; - + // get a pointer to the animation and add the sound to the variant OSrVariant_SoundAnimation_Add(variant, anim_type, mod_type, anim_name, frame, impulse_name); - + // move to a location in the buffer after the tag that was just processed buffer = sa_data; buffer_size = ioBinaryData->header.data_size - (buffer - ioBinaryData->data); } - + // dispose of allocated memory if (inAllocated) { UUrMemory_Block_Delete(ioBinaryData); } - + UUrMemory_Block_VerifyList(); return UUcError_None; @@ -1025,12 +1025,12 @@ OSiSABinaryData_Register( { UUtError error; BDtMethods methods; - + methods.rLoad = OSiSABinaryData_Load; - + error = BDrRegisterClass(OScSABinaryDataClass, &methods); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1052,13 +1052,13 @@ OSiSABinaryData_WriteSoundAnimation( temp_buffer = aligned_block; temp_buffer_size = OSgMaxBufferSize; UUrMemory_Clear(temp_buffer, OSgMaxBufferSize); - + // write the impulse id // OBDmWrite4BytesToBuffer(temp_buffer, inSoundAnimation->impulse_id, UUtUns32, temp_buffer_size, OBJcWrite_Little); - + // write the frame OBDmWrite4BytesToBuffer(temp_buffer, inSoundAnimation->frame, UUtUns32, temp_buffer_size, OBJcWrite_Little); - + // write the mod type name UUrString_Copy( (char*)temp_buffer, @@ -1074,7 +1074,7 @@ OSiSABinaryData_WriteSoundAnimation( SScMaxNameLength); temp_buffer += SScMaxNameLength; temp_buffer_size -= SScMaxNameLength; - + // write the animation name if (inSoundAnimation->animation) { @@ -1092,7 +1092,7 @@ OSiSABinaryData_WriteSoundAnimation( } temp_buffer += SScMaxNameLength; temp_buffer_size -= OScMaxAnimNameLength; - + // write the impulse name UUrString_Copy( (char*)temp_buffer, @@ -1100,7 +1100,7 @@ OSiSABinaryData_WriteSoundAnimation( SScMaxNameLength); temp_buffer += SScMaxNameLength; temp_buffer_size -= SScMaxNameLength; - + // write the tag bytes_written = UUrWriteTagDataToBuffer( @@ -1110,7 +1110,7 @@ OSiSABinaryData_WriteSoundAnimation( aligned_block, (OSgMaxBufferSize - temp_buffer_size), UUcFile_LittleEndian); - + return bytes_written; } @@ -1122,34 +1122,34 @@ OSiSABinaryData_Save( UUtUns32 i; OStVariant *variant_array; UUtUns32 num_variants; - + // write each variant to it's own file variant_array = (OStVariant*)UUrMemory_Array_GetMemory(OSgVariants); num_variants = UUrMemory_Array_GetUsedElems(OSgVariants); for (i = 0; i < num_variants; i++) { OStVariant *variant; - + UUtUns32 sa_file_tag_size; UUtUns32 variant_tag_size; UUtUns32 sound_animations_size; UUtUns8 *buffer; UUtUns32 buffer_size; - + UUtUns8 *write_buffer; UUtUns32 num_bytes; UUtUns32 bytes_written; - + UUtUns8 block[OSgMaxBufferSize + (2 * UUcProcessor_CacheLineSize)]; UUtUns8 *aligned_block; UUtUns8 *temp_buffer; UUtUns32 temp_buffer_size; - + UUtUns32 j; OStSoundAnimation *sound_animation_array; - + variant = &variant_array[i]; - + sa_file_tag_size = sizeof(UUtTag) + /* tag */ sizeof(UUtUns32); /* version */ @@ -1158,24 +1158,24 @@ OSiSABinaryData_Save( ONcMaxVariantNameLength; /* variant name */ sound_animations_size = OSiVariant_CalcWriteSize(variant); /* size of all animation sounds and their tags */ - + buffer_size = sa_file_tag_size + variant_tag_size + sound_animations_size; buffer = (UUtUns8*)UUrMemory_Block_New(buffer_size); - + write_buffer = buffer; num_bytes = buffer_size; aligned_block = UUrAlignMemory(block); - + // ------------------------------ // write the Sound Animation File Tag // ------------------------------ temp_buffer = aligned_block; temp_buffer_size = OSgMaxBufferSize; UUrMemory_Clear(temp_buffer, OSgMaxBufferSize); - + // write the version OBDmWrite4BytesToBuffer(temp_buffer, OS2cCurrentVersion, UUtUns32, temp_buffer_size, OBJcWrite_Little); - + // write the tag bytes_written = UUrWriteTagDataToBuffer( @@ -1187,14 +1187,14 @@ OSiSABinaryData_Save( UUcFile_LittleEndian); write_buffer += bytes_written; num_bytes -= bytes_written; - + // ------------------------------ // write the Variant File Tag // ------------------------------ temp_buffer = aligned_block; temp_buffer_size = OSgMaxBufferSize; UUrMemory_Clear(temp_buffer, OSgMaxBufferSize); - + // write the variant name UUrString_Copy( (char*)temp_buffer, @@ -1202,7 +1202,7 @@ OSiSABinaryData_Save( ONcMaxVariantNameLength); temp_buffer += ONcMaxVariantNameLength; temp_buffer_size -= ONcMaxVariantNameLength; - + // write the tag bytes_written = UUrWriteTagDataToBuffer( @@ -1214,7 +1214,7 @@ OSiSABinaryData_Save( UUcFile_LittleEndian); write_buffer += bytes_written; num_bytes -= bytes_written; - + // ------------------------------ // write the sound animations // ------------------------------ @@ -1222,9 +1222,9 @@ OSiSABinaryData_Save( { UUtUns32 k; UUtMemory_Array *type_array; - + type_array = variant->anim_type_sounds[j]; - + sound_animation_array = (OStSoundAnimation*)UUrMemory_Array_GetMemory(type_array); for (k = 0; k < UUrMemory_Array_GetUsedElems(type_array); k++) { @@ -1233,12 +1233,12 @@ OSiSABinaryData_Save( &sound_animation_array[k], write_buffer, num_bytes); - + write_buffer += bytes_written; num_bytes -= bytes_written; } } - + // ------------------------------ // write the buffer to the binary datafile // ------------------------------ @@ -1249,12 +1249,12 @@ OSiSABinaryData_Save( (buffer_size - num_bytes), 0, inAutoSave); - + // delete the buffer UUrMemory_Block_Delete(buffer); buffer = NULL; } - + return UUcError_None; } @@ -1271,10 +1271,10 @@ OSiCompareAnimations( { OStSoundAnimation *a; OStSoundAnimation *b; - + a = (OStSoundAnimation*)inA; b = (OStSoundAnimation*)inB; - + return ((int)a->animation - (int)b->animation); } @@ -1286,10 +1286,10 @@ OSiCompareVariants( { OStVariant *a; OStVariant *b; - + a = (OStVariant*)inA; b = (OStVariant*)inB; - + return ((int)a->character_variant - (int)b->character_variant); } @@ -1311,11 +1311,11 @@ OSrVariantList_Initialize( OStVariant *variant_array; UUtUns32 i; UUtUns32 num_elements; - + // if OSgVariants != NULL then assume that it has already been // initialized properly if (OSgVariants != NULL) { return UUcError_None; } - + // get a pointer to the variant list error = TMrInstance_GetDataPtr( @@ -1323,7 +1323,7 @@ OSrVariantList_Initialize( "variant_list", &variant_list); UUmError_ReturnOnError(error); - + // make sure all of the variants except "Any" have a parent #if defined(DEBUGGING) && (DEBUGGING) for (i = 0; i < variant_list->numVariants; i++) @@ -1335,7 +1335,7 @@ OSrVariantList_Initialize( } } #endif - + // allocate the memory array OSgVariants = UUrMemory_Array_New( @@ -1344,7 +1344,7 @@ OSrVariantList_Initialize( variant_list->numVariants, variant_list->numVariants); UUmError_ReturnOnNull(OSgVariants); - + // initialize the variants variant_array = (OStVariant*)UUrMemory_Array_GetMemory(OSgVariants); num_elements = UUrMemory_Array_GetUsedElems(OSgVariants); @@ -1353,10 +1353,10 @@ OSrVariantList_Initialize( error = OSiVariant_Initialize(&variant_array[i], variant_list->variant[i]); UUmError_ReturnOnError(error); } - + // qsort the variant_array qsort(variant_array, num_elements, sizeof(OStVariant), OSiCompareVariants); - + return UUcError_None; } @@ -1368,7 +1368,7 @@ OSrVariantList_LevelLoad( OStVariant *variant_array; UUtUns32 i; UUtUns32 num_variants; - + // go through all of the OStSoundAnimations in every variant // and get a pointer to the animation variant_array = (OStVariant*)UUrMemory_Array_GetMemory(OSgVariants); @@ -1381,19 +1381,19 @@ OSrVariantList_LevelLoad( UUtUns32 j; UUtUns32 num_elements; TRtAnimation *animation; - + variant = &variant_array[i]; - + animation_type_array = variant->anim_type_sounds[OScAnimType_Animation]; sound_array = (OStSoundAnimation*)UUrMemory_Array_GetMemory(animation_type_array); num_elements = UUrMemory_Array_GetUsedElems(animation_type_array); for (j = 0; j < num_elements; j++) { UUtError error; - + // get a pointer to the animation sound_array[j].animation = NULL; - + error = TMrInstance_GetDataPtr( TRcTemplate_Animation, @@ -1403,11 +1403,11 @@ OSrVariantList_LevelLoad( sound_array[j].animation = animation; } - + // sort the animations qsort(sound_array, num_elements, sizeof(OStSoundAnimation), OSiCompareAnimations); } - + // This next stage must come after the qsort() above // go through all of the OStSoundAnimations in every variant // and set the sound name for the animation @@ -1420,23 +1420,23 @@ OSrVariantList_LevelLoad( OStSoundAnimation *sound_array; UUtUns32 j; UUtUns32 num_elements; - + variant = &variant_array[i]; - + animation_type_array = variant->anim_type_sounds[OScAnimType_Animation]; sound_array = (OStSoundAnimation*)UUrMemory_Array_GetMemory(animation_type_array); num_elements = UUrMemory_Array_GetUsedElems(animation_type_array); for (j = 0; j < num_elements; j++) { if (sound_array[j].animation == NULL) { continue; } - + TRrAnimation_SetSoundName( sound_array[j].animation, sound_array[j].impulse_name, (UUtUns16)sound_array[j].frame); } } - + return UUcError_None; } @@ -1450,7 +1450,7 @@ OSrVariantList_LevelUnload( UUtUns32 i; if (OSgVariants == NULL) { return; } - + // go through all the variants and clear tha animation sounds variant_array = (OStVariant*)UUrMemory_Array_GetMemory(OSgVariants); num_variants = UUrMemory_Array_GetUsedElems(OSgVariants); @@ -1461,9 +1461,9 @@ OSrVariantList_LevelUnload( OStSoundAnimation *sound_array; UUtUns32 j; UUtUns32 num_elements; - + variant = &variant_array[i]; - + // clear the animation pointers animation_type_array = variant->anim_type_sounds[OScAnimType_Animation]; sound_array = (OStSoundAnimation*)UUrMemory_Array_GetMemory(animation_type_array); @@ -1478,7 +1478,7 @@ OSrVariantList_LevelUnload( NULL, 0); } - + // clear the animation pointer sound_array[j].animation = NULL; } @@ -1501,10 +1501,10 @@ OSrVariantList_Terminate( OStVariant *variant_array; UUtUns32 num_variants; UUtUns32 i; - + // CB: don't terminate unless we have previously initialized if (OSgVariants == NULL) { return; } - + // terminate the variants variant_array = (OStVariant*)UUrMemory_Array_GetMemory(OSgVariants); num_variants = UUrMemory_Array_GetUsedElems(OSgVariants); @@ -1512,7 +1512,7 @@ OSrVariantList_Terminate( { OSiVariant_Terminate(&variant_array[i]); } - + UUrMemory_Array_Delete(OSgVariants); OSgVariants = NULL; } @@ -1523,13 +1523,13 @@ OSrVariantList_Variant_GetByIndex( UUtUns32 inIndex) { OStVariant *variant_array; - + // check the range if (inIndex >= UUrMemory_Array_GetUsedElems(OSgVariants)) { return NULL; } - + // get a pointer to the variant array variant_array = (OStVariant*)UUrMemory_Array_GetMemory(OSgVariants); - + return &variant_array[inIndex]; } @@ -1542,11 +1542,11 @@ OSrVariantList_Variant_GetByName( OStVariant *variant_array; UUtUns32 num_variants; UUtUns32 i; - + UUmAssert(inVariantName); - + out_variant = NULL; - + // find the variant with the name inVariantName variant_array = (OStVariant*)UUrMemory_Array_GetMemory(OSgVariants); num_variants = UUrMemory_Array_GetUsedElems(OSgVariants); @@ -1558,7 +1558,7 @@ OSrVariantList_Variant_GetByName( break; } } - + return out_variant; } @@ -1571,16 +1571,16 @@ OSrVariantList_Variant_GetByVariant( OStVariant find_me; OStVariant *out_variant; UUtUns32 num_elements; - + UUmAssert(inCharacterVariant); - + // get a pointer to the variant array and the number of elements in the array variant_array = (OStVariant*)UUrMemory_Array_GetMemory(OSgVariants); num_elements = UUrMemory_Array_GetUsedElems(OSgVariants); - + // set the find parameter find_me.character_variant = inCharacterVariant; - + // find the variant out_variant = (OStVariant*)bsearch( @@ -1589,7 +1589,7 @@ OSrVariantList_Variant_GetByVariant( num_elements, sizeof(OStVariant), OSiCompareVariants); - + return out_variant; } @@ -1602,7 +1602,7 @@ OSrVariantList_UpdateImpulseName( OStVariant *variant_array; UUtUns32 num_variants; UUtUns32 i; - + // get a pointer to the variant array and the number of elements in the array variant_array = (OStVariant*)UUrMemory_Array_GetMemory(OSgVariants); num_variants = UUrMemory_Array_GetUsedElems(OSgVariants); @@ -1624,7 +1624,7 @@ OSrAnimType_GetName( { UUmAssert(inAnimType < OScAnimType_NumTypes); UUmAssert(OSgAnimTypeName[inAnimType].type == inAnimType); - + return OSgAnimTypeName[inAnimType].name; } @@ -1636,9 +1636,9 @@ OSrAnimType_GetByName( OStTypeName *atn; OStAnimType anim_type; UUtInt32 result; - - anim_type = OScAnimType_Any; - + + anim_type = OScAnimType_Any; + for (atn = OSgAnimTypeName; atn->name != NULL; atn++) { result = UUrString_Compare_NoCase(atn->name, inAnimTypeName); @@ -1648,7 +1648,7 @@ OSrAnimType_GetByName( break; } } - + return anim_type; } @@ -1659,7 +1659,7 @@ OSrModType_GetName( { UUmAssert(inModType < OScModType_NumTypes); UUmAssert(OSgModTypeName[inModType].type == inModType); - + return OSgModTypeName[inModType].name; } @@ -1671,9 +1671,9 @@ OSrModType_GetByName( OStTypeName *mtn; OStAnimType mod_type; UUtInt32 result; - - mod_type = OScModType_Any; - + + mod_type = OScModType_Any; + for (mtn = OSgModTypeName; mtn->name != NULL; mtn++) { result = UUrString_Compare_NoCase(mtn->name, inModTypeName); @@ -1683,7 +1683,7 @@ OSrModType_GetByName( break; } } - + return mod_type; } @@ -1698,11 +1698,11 @@ OSrSA_Initialize( void) { UUtError error; - + // initialize the binary data class error = OSiSABinaryData_Register(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1715,11 +1715,11 @@ OSrSA_ListBrokenSounds( UUtUns32 i; UUtUns32 num_variants; char text[2048]; - + // printf a header BFrFile_Printf(inFile, "********** Animation Sound Links **********"UUmNL); BFrFile_Printf(inFile, "Anim Type\tModifier\tImpulse Sound Name"UUmNL); - + variant_array = (OStVariant*)UUrMemory_Array_GetMemory(OSgVariants); num_variants = UUrMemory_Array_GetUsedElems(OSgVariants); for (i = 0; i < num_variants; i++) @@ -1730,9 +1730,9 @@ OSrSA_ListBrokenSounds( UUtUns32 j; UUtUns32 num_elements; UUtUns32 itr2; - + variant = &variant_array[i]; - + for (itr2 = 0; itr2 < OScAnimType_NumTypes; itr2++) { animation_type_array = variant->anim_type_sounds[itr2]; @@ -1741,10 +1741,10 @@ OSrSA_ListBrokenSounds( for (j = 0; j < num_elements; j++) { SStImpulse *impulse; - + impulse = OSrImpulse_GetByName(sound_array[j].impulse_name); if (impulse != NULL) { continue; } - + sprintf( text, "%s\t%s\t%s", @@ -1770,7 +1770,7 @@ OSrSA_UpdatePointers( OStVariant *variant_array; UUtUns32 num_variants; UUtUns32 itr; - + variant_array = (OStVariant*)UUrMemory_Array_GetMemory(OSgVariants); num_variants = UUrMemory_Array_GetUsedElems(OSgVariants); for (itr = 0; itr < num_variants; itr++) @@ -1780,13 +1780,13 @@ OSrSA_UpdatePointers( OStSoundAnimation *sound_array; UUtUns32 itr2; UUtUns32 num_elements; - + variant = &variant_array[itr]; - + for (itr2 = 0; itr2 < OScAnimType_NumTypes; itr2++) { UUtUns32 itr3; - + animation_type_array = variant->anim_type_sounds[itr2]; sound_array = (OStSoundAnimation*)UUrMemory_Array_GetMemory(animation_type_array); num_elements = UUrMemory_Array_GetUsedElems(animation_type_array); @@ -1822,12 +1822,12 @@ OSrSoundAnimation_Play( OStModType sound_mod_type; SStImpulse *impulse = NULL; UUtBool has_sound; - + UUmAssert(inCharacterVariant); UUmAssert(inPosition); // UUmAssert(inDirection); // UUmAssert(inVelocity); - + // get the anim type totoro_anim_type = TRrAnimation_GetType(inAnimation); UUmAssert(OSiTotoroToSound(totoro_anim_type)->totoro_anim_type == totoro_anim_type); @@ -1835,14 +1835,14 @@ OSrSoundAnimation_Play( sound_mod_type = OSiTotoroToSound(totoro_anim_type)->sound_mod_type; has_sound = (TRrAnimation_GetSoundName(inAnimation) != NULL); if ((sound_anim_type == OScAnimType_None) && (has_sound == UUcFalse)) { return; } - + // get a mod type based on damage if (sound_mod_type == OScModType_Any) { UUtUns32 damage; - + damage = TRrAnimation_GetMaximumDamage(inAnimation); - + if (damage >= ONcAnimDamage_Heavy) { sound_mod_type = OScModType_HeavyDamage; @@ -1856,7 +1856,7 @@ OSrSoundAnimation_Play( sound_mod_type = OScModType_LightDamage; } } - + // get a pointer to the variant variant = OSrVariantList_Variant_GetByVariant(inCharacterVariant); while (variant != NULL) @@ -1864,13 +1864,13 @@ OSrSoundAnimation_Play( // get the impulse sound from the variant impulse = OSiVariant_Impulse_Get(variant, inAnimation, sound_anim_type, sound_mod_type); if (impulse != NULL) { break; } - + // get the parent variant if (variant->character_variant->parent == NULL) { break; } variant = OSrVariantList_Variant_GetByVariant(variant->character_variant->parent); UUmAssert(variant); } - + // play the impulse sound if (impulse != NULL) { diff --git a/OniProj/OniGameSource/Oni_Sound_Animation.h b/OniProj/OniGameSource/Oni_Sound_Animation.h index 543aba1..8c8dca0 100644 --- a/OniProj/OniGameSource/Oni_Sound_Animation.h +++ b/OniProj/OniGameSource/Oni_Sound_Animation.h @@ -35,9 +35,9 @@ enum OScModType_HeavyDamage, OScModType_MediumDamage, OScModType_LightDamage, - + OScModType_NumTypes, - + OScModType_None = 0xFFFFFFFF }; @@ -80,9 +80,9 @@ enum OScAnimType_Powerup, OScAnimType_Roll, OScAnimType_FallingFlail, - + OScAnimType_NumTypes, - + OScAnimType_None = 0xFFFFFFFF }; @@ -103,7 +103,7 @@ typedef struct OStSoundAnimation TRtAnimation *animation; char anim_name[OScMaxAnimNameLength]; char impulse_name[SScMaxNameLength]; - + } OStSoundAnimation; // ====================================================================== @@ -116,15 +116,15 @@ OSrAnimType_GetName( OStAnimType OSrAnimType_GetByName( const char *inAnimTypeName); - + const char* OSrModType_GetName( OStModType inModType); - + OStModType OSrModType_GetByName( const char *inModTypeName); - + // ---------------------------------------------------------------------- void OSrSoundAnimation_Play( @@ -156,29 +156,29 @@ void OSrVariant_SoundAnimation_DeleteByIndex( OStVariant *ioVariant, UUtUns32 inIndex); - + const OStSoundAnimation* OSrVariant_SoundAnimation_GetByIndex( OStVariant *inVariant, UUtUns32 inIndex); - + // ---------------------------------------------------------------------- UUtUns32 OSrVariantList_GetNumVariants( void); - + UUtError OSrVariantList_Save( UUtBool inAutoSave); - + OStVariant* OSrVariantList_Variant_GetByIndex( UUtUns32 inIndex); - + OStVariant* OSrVariantList_Variant_GetByName( const char *inVariantName); - + OStVariant* OSrVariantList_Variant_GetByVariant( const ONtCharacterVariant *inCharacterVariant); @@ -187,7 +187,7 @@ void OSrVariantList_UpdateImpulseName( const char *inOldImpulseName, const char *inNewImpulseName); - + // ---------------------------------------------------------------------- UUtError OSrSA_Initialize( @@ -196,10 +196,10 @@ OSrSA_Initialize( void OSrSA_ListBrokenSounds( BFtFile *inFile); - + void OSrSA_UpdatePointers( void); - + // ====================================================================== -#endif /* ONI_SOUND_ANIMATION_H */ \ No newline at end of file +#endif /* ONI_SOUND_ANIMATION_H */ diff --git a/OniProj/OniGameSource/Oni_Sound_Private.h b/OniProj/OniGameSource/Oni_Sound_Private.h index 670879c..a808a27 100644 --- a/OniProj/OniGameSource/Oni_Sound_Private.h +++ b/OniProj/OniGameSource/Oni_Sound_Private.h @@ -18,7 +18,7 @@ typedef struct OStTypeName { char *name; UUtUns32 type; - + } OStTypeName; // ====================================================================== @@ -27,18 +27,18 @@ typedef struct OStTypeName UUtError OSrVariantList_Initialize( void); - + UUtError OSrVariantList_LevelLoad( void); - + void OSrVariantList_LevelUnload( void); - + void OSrVariantList_Terminate( void); // ====================================================================== -#endif /* ONI_SOUND_PRIVATE_H */ \ No newline at end of file +#endif /* ONI_SOUND_PRIVATE_H */ diff --git a/OniProj/OniGameSource/Oni_Speech.c b/OniProj/OniGameSource/Oni_Speech.c index f065419..1c2b906 100644 --- a/OniProj/OniGameSource/Oni_Speech.c +++ b/OniProj/OniGameSource/Oni_Speech.c @@ -1,12 +1,12 @@ /* FILE: Oni_Speech.c - + AUTHOR: Chris Butcher - + CREATED: July 15, 2000 - + PURPOSE: Speech handling for Oni Characters - + Copyright (c) 2000 */ @@ -28,7 +28,7 @@ const char *ONcSpeechTypeName[ONcSpeechType_Max] = static void ONiSpeech_Play(ONtCharacter *ioCharacter) { - UUmAssert((ioCharacter->speech.current.speech_type > ONcSpeechType_None) && + UUmAssert((ioCharacter->speech.current.speech_type > ONcSpeechType_None) && (ioCharacter->speech.current.speech_type < ONcSpeechType_Max)); UUmAssert(!ioCharacter->speech.currently_speaking); @@ -113,7 +113,7 @@ UUtBool ONrSpeech_Saying(struct ONtCharacter *ioCharacter) ONtSpeech *ONrSpeech_Current(ONtCharacter *ioCharacter) { if (ioCharacter->speech.currently_speaking) { - UUmAssert((ioCharacter->speech.current.speech_type > ONcSpeechType_None) && + UUmAssert((ioCharacter->speech.current.speech_type > ONcSpeechType_None) && (ioCharacter->speech.current.speech_type < ONcSpeechType_Max)); return &ioCharacter->speech.current; } else { @@ -168,7 +168,7 @@ void ONrSpeech_Update(ONtCharacter *ioCharacter) ONrCharacter_GetEyePosition(ioCharacter, &speech_location); ioCharacter->speech.playing_sound_id = OSrInGameDialog_Play(ioCharacter->speech.current.sound_name, &speech_location, &duration, &sound_missing); ioCharacter->speech.playing_sound_endtime = current_time + duration; - + if (sound_missing == UUcTrue) { COrConsole_Printf("### %s: can't find sound '%s'", ioCharacter->player_name, ioCharacter->speech.current.sound_name); ioCharacter->speech.finished_sound = UUcTrue; diff --git a/OniProj/OniGameSource/Oni_Speech.h b/OniProj/OniGameSource/Oni_Speech.h index 0c75cf0..475c8dc 100644 --- a/OniProj/OniGameSource/Oni_Speech.h +++ b/OniProj/OniGameSource/Oni_Speech.h @@ -4,13 +4,13 @@ /* FILE: Oni_Speech.h - + AUTHOR: Chris Butcher - + CREATED: July 15, 2000 - + PURPOSE: Speech handling for Oni Characters - + Copyright (c) 2000 */ @@ -59,7 +59,7 @@ typedef struct ONtCharacterSpeech { SStPlayID playing_sound_id; UUtUns32 playing_sound_endtime; - + ONtSpeech current; ONtSpeech next; diff --git a/OniProj/OniGameSource/Oni_Templates.c b/OniProj/OniGameSource/Oni_Templates.c index 4f67c52..c81e6cb 100644 --- a/OniProj/OniGameSource/Oni_Templates.c +++ b/OniProj/OniGameSource/Oni_Templates.c @@ -1,15 +1,15 @@ /* FILE: Oni_Templates.c - + AUTHOR: Michael Evans - + CREATED: Jan, 1998 - + PURPOSE: This contains code to register all the Oni templates. - + Copyright 1998 */ @@ -34,7 +34,7 @@ ONrRegisterTemplates(void) error = TMrTemplate_Register(ONcTemplate_Film, sizeof(ONtFilm), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(ONcTemplate_FlagArray, sizeof(ONtFlagArray), TMcFolding_Allow); UUmError_ReturnOnError(error); @@ -43,13 +43,13 @@ ONrRegisterTemplates(void) error = TMrTemplate_Register(TMcTemplate_StringArray, sizeof(TMtStringArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(ONcTemplate_Level, sizeof(ONtLevel), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(ONcTemplate_Level_Descriptor, sizeof(ONtLevel_Descriptor), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(ONcTemplate_MarkerArray, sizeof(ONtMarkerArray), TMcFolding_Allow); UUmError_ReturnOnError(error); @@ -58,7 +58,7 @@ ONrRegisterTemplates(void) error = TMrTemplate_Register(ONcTemplate_CharacterVariant, sizeof(ONtCharacterVariant), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(ONcTemplate_BodyPartMaterials, sizeof(ONtBodyPartMaterials), TMcFolding_Allow); UUmError_ReturnOnError(error); @@ -73,7 +73,7 @@ ONrRegisterTemplates(void) error = TMrTemplate_Register(ONcTemplate_CharacterParticleArray, sizeof(ONtCharacterParticleArray), TMcFolding_Allow); UUmError_ReturnOnError(error); - + error = TMrTemplate_Register(ONcTemplate_SpawnArray, sizeof(ONtSpawnArray), TMcFolding_Allow); UUmError_ReturnOnError(error); @@ -103,7 +103,7 @@ ONrRegisterTemplates(void) error = AIrRegisterTemplates(); UUmError_ReturnOnError(error); - + error = OBJrRegisterTemplates(); UUmError_ReturnOnError(error); diff --git a/OniProj/OniGameSource/Oni_Templates.h b/OniProj/OniGameSource/Oni_Templates.h index be43032..f39e12d 100644 --- a/OniProj/OniGameSource/Oni_Templates.h +++ b/OniProj/OniGameSource/Oni_Templates.h @@ -1,15 +1,15 @@ #pragma once /* FILE: Oni_Templates.c - + AUTHOR: Michael Evans - + CREATED: Jan, 1998 - + PURPOSE: This contains code to register all the Oni templates. - + Copyright 1998 */ diff --git a/OniProj/OniGameSource/Oni_Testbed.h b/OniProj/OniGameSource/Oni_Testbed.h index 5203261..ef23798 100644 --- a/OniProj/OniGameSource/Oni_Testbed.h +++ b/OniProj/OniGameSource/Oni_Testbed.h @@ -1 +1 @@ -#error "Oni_Testbed.h is obsolete" \ No newline at end of file +#error "Oni_Testbed.h is obsolete" diff --git a/OniProj/OniGameSource/Oni_TextureMaterials.c b/OniProj/OniGameSource/Oni_TextureMaterials.c index 0634725..ff2cc34 100644 --- a/OniProj/OniGameSource/Oni_TextureMaterials.c +++ b/OniProj/OniGameSource/Oni_TextureMaterials.c @@ -23,7 +23,7 @@ enum { ONcTMVersion_1 = 1, - + ONcTMCurrentVersion = ONcTMVersion_1 }; @@ -36,7 +36,7 @@ typedef struct ONtTextureMaterial const char *material_name; // only valid between load and preprocess M3tTextureMap *texture; char texture_name[ONcMaxNameLength]; - + } ONtTextureMaterial; // ====================================================================== @@ -65,13 +65,13 @@ ONiTextureMaterial_GetByTextureName( ONtTextureMaterial *materials_array; UUtUns32 num_elements; UUtUns32 i; - + found_texture_material = NULL; - + // get a pointer to the materials array materials_array = (ONtTextureMaterial*)UUrMemory_Array_GetMemory(ONgTextureMaterials); if (materials_array == NULL) { return NULL; } - + // search the array for the texture name num_elements = UUrMemory_Array_GetUsedElems(ONgTextureMaterials); for (i = 0; i < num_elements; i++) @@ -82,7 +82,7 @@ ONiTextureMaterial_GetByTextureName( break; } } - + return found_texture_material; } @@ -107,44 +107,44 @@ ONiTMBinaryData_Load( UUtUns32 num_elements; ONtTextureMaterial *materials_array; UUtUns32 i; - + UUmAssert(inIdentifier); UUmAssert(ioBinaryData); - + buffer = ioBinaryData->data; buffer_size = ioBinaryData->header.data_size; - + // read the version number buffer_size -= OBDmGet4BytesFromBuffer(buffer, version, UUtUns32, inSwapIt); - + // read the number of elements buffer_size -= OBDmGet4BytesFromBuffer(buffer, num_elements, UUtUns32, inSwapIt); - + // is there enough data - UUmAssert(((ONcMaxNameLength + ONcMaxNameLength) * num_elements) == buffer_size); - + UUmAssert(((ONcMaxNameLength + ONcMaxNameLength) * num_elements) == buffer_size); + // set the number of elements in the array error = UUrMemory_Array_SetUsedElems(ONgTextureMaterials, num_elements, NULL); UUmError_ReturnOnError(error); - + // get a pointer to the array materials_array = (ONtTextureMaterial*)UUrMemory_Array_GetMemory(ONgTextureMaterials); UUmAssert((materials_array != NULL) || (0 == num_elements)); - + // process the elements for (i = 0; i < num_elements; i++) { char *material_name; char *texture_name; - + // get a pointer to the material name material_name = (char*)buffer; buffer += ONcMaxNameLength; - + // get a pointer to the texture name texture_name = (char*)buffer; buffer += ONcMaxNameLength; - + // initialize the element materials_array[i].material_name = material_name; materials_array[i].type = MAcInvalidID; // will be set up from name in a preprocess phase @@ -152,7 +152,7 @@ ONiTMBinaryData_Load( UUrString_Copy(materials_array[i].texture_name, texture_name, ONcMaxNameLength); materials_array[i].texture = NULL; // will be set up at level load time } - + // CB: we do not dispose of allocated memory here because we still have pointers to it // in the form of material_name in each texturematerial. these pointers will be used and // removed in ONrTextureMaterials_PreProcess. instead store the memory. @@ -160,7 +160,7 @@ ONiTMBinaryData_Load( ONgTextureMaterialsBinaryData = ioBinaryData; return UUcError_None; -} +} // ---------------------------------------------------------------------- static UUtError @@ -169,12 +169,12 @@ ONiTMBinaryData_Register( { UUtError error; BDtMethods methods; - + methods.rLoad = ONiTMBinaryData_Load; - + error = BDrRegisterClass(ONcTMBinaryDataClass, &methods); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -193,39 +193,39 @@ ONiTMBinaryData_Save( UUtUns32 i; UUtUns8 *num_elements_ptr; UUtUns32 num_elements_written; - + // get the number of elements that need to be saved num_elements = UUrMemory_Array_GetUsedElems(ONgTextureMaterials); - + // calculate the size of the data data_size = sizeof(UUtUns32) + /* version */ sizeof(UUtUns32) + /* number of elements */ (ONcMaxNameLength + ONcMaxNameLength) * num_elements; /* elements */ - + // allocate memory to hold that many elements data = (UUtUns8*)UUrMemory_Block_NewClear(data_size); - + // init the temp pointers buffer = data; num_bytes = data_size; - + // write the version OBDmWrite4BytesToBuffer(buffer, ONcTMCurrentVersion, UUtUns32, num_bytes, OBJcWrite_Little); - + // save the num_elements pointer num_elements_ptr = buffer; buffer += sizeof(UUtUns32); - + // get a pointer to the materials array materials_array = (ONtTextureMaterial*)UUrMemory_Array_GetMemory(ONgTextureMaterials); - + // write the elements num_elements_written = 0; for (i = 0; i < num_elements; i++) { if (materials_array[i].type == MAcInvalidID) { continue; } - + // write the material instance name UUrString_Copy( (char*)buffer, @@ -233,21 +233,21 @@ ONiTMBinaryData_Save( ONcMaxNameLength); buffer += ONcMaxNameLength; num_bytes -= ONcMaxNameLength; - + // write the texture name UUrString_Copy((char*)buffer, materials_array[i].texture_name, ONcMaxNameLength); buffer += ONcMaxNameLength; num_bytes -= ONcMaxNameLength; - + // increment the number of elements written num_elements_written++; } - + // write the number of elements OBDmWrite4BytesToBuffer(num_elements_ptr, num_elements_written, UUtUns32, num_bytes, OBJcWrite_Little); - + // save the material data - error = + error = OBDrBinaryData_Save( ONcTMBinaryDataClass, "TextureMaterials", @@ -258,11 +258,11 @@ ONiTMBinaryData_Save( if (error != UUcError_None) { UUrDebuggerMessage("ONiTMBinaryData_Save: WARNING - could not save texture materials binary file!\n"); } - + // dispose of memory UUrMemory_Block_Delete(data); data = NULL; - + return UUcError_None; } @@ -279,10 +279,10 @@ ONiCompareTextures( { ONtTextureMaterial *a; ONtTextureMaterial *b; - + a = (ONtTextureMaterial*)inA; b = (ONtTextureMaterial*)inB; - + return ((int)a->texture - (int)b->texture); } @@ -299,7 +299,7 @@ ONiTextureMaterialList_Initialize( 0, 0); UUmError_ReturnOnNull(ONgTextureMaterials); - + return UUcError_None; } @@ -312,14 +312,14 @@ ONiTextureMaterialList_LevelLoad( UUtUns32 i; ONtTextureMaterial *materials_array; UUtUns32 num_elements; - + // update the pointers to all the textures in the level materials_array = (ONtTextureMaterial*)UUrMemory_Array_GetMemory(ONgTextureMaterials); num_elements = UUrMemory_Array_GetUsedElems(ONgTextureMaterials); for (i = 0; i < num_elements; i++) { M3tTextureMap *texture; - + error = TMrInstance_GetDataPtr( M3cTemplate_TextureMap, @@ -336,10 +336,10 @@ ONiTextureMaterialList_LevelLoad( M3rTextureMap_SetMaterialType(texture, MAcMaterial_Base); } } - + // sort the materials ONiTextureMaterialList_SortByTexture(); - + return UUcError_None; } @@ -357,11 +357,11 @@ ONiTextureMaterialList_SortByTexture( void) { ONtTextureMaterial *materials_array; - + // get a pointer to the material array materials_array = (ONtTextureMaterial*)UUrMemory_Array_GetMemory(ONgTextureMaterials); if (materials_array == NULL) { return; } - + // sort the materials array qsort( materials_array, @@ -388,25 +388,25 @@ ONrTextureMaterialList_TextureMaterial_Set( ONtTextureMaterial *texture_material; UUtError error; ONtTextureMaterial *materials_array; - + // find the texture in the list texture_material = ONiTextureMaterial_GetByTextureName(inTextureName); if ((texture_material == NULL) && (inMaterialType != MAcInvalidID)) { UUtUns32 index; - + // get a new element from the array error = UUrMemory_Array_GetNewElement(ONgTextureMaterials, &index, NULL); UUmError_ReturnOnError(error); - + // get a pointer to the material array materials_array = (ONtTextureMaterial*)UUrMemory_Array_GetMemory(ONgTextureMaterials); UUmAssert(materials_array); - + // set the texture material texture_material = &materials_array[index]; } - + if (texture_material != NULL) { // re-set up the texture material @@ -419,7 +419,7 @@ ONrTextureMaterialList_TextureMaterial_Set( if (texture_material->texture != NULL) { M3rTextureMap_SetMaterialType(texture_material->texture, texture_material->type); } - + // sort the materials ONiTextureMaterialList_SortByTexture(); } @@ -438,16 +438,16 @@ ONrTextureMaterials_Initialize( void) { UUtError error; - + ONgTextureMaterialsBinaryDataAllocated = UUcFalse; ONgTextureMaterialsBinaryData = NULL; error = ONiTMBinaryData_Register(); UUmError_ReturnOnError(error); - + error = ONiTextureMaterialList_Initialize(); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -464,11 +464,11 @@ void ONrTextureMaterials_LevelLoad(void) ONtTextureMaterial *materials_array; UUtUns32 num_elements; UUtUns32 i; - + num_elements = UUrMemory_Array_GetUsedElems(ONgTextureMaterials); materials_array = (ONtTextureMaterial*) UUrMemory_Array_GetMemory(ONgTextureMaterials); - - // find the texture for each element, and set up + + // find the texture for each element, and set up for (i = 0; i < num_elements; i++) { ONtTextureMaterial *material = materials_array + i; @@ -480,7 +480,7 @@ void ONrTextureMaterials_LevelLoad(void) M3rTextureMap_SetMaterialType(material->texture, material->type); } } - + return; } @@ -492,7 +492,7 @@ ONrTextureMaterials_PreProcess( ONtTextureMaterial *materials_array; UUtUns32 num_elements; UUtUns32 i; - + num_elements = UUrMemory_Array_GetUsedElems(ONgTextureMaterials); if (num_elements == 0) { @@ -501,7 +501,7 @@ ONrTextureMaterials_PreProcess( // we must have loaded binary data in order for this to be true UUmAssert(ONgTextureMaterialsBinaryData != NULL); } - + materials_array = (ONtTextureMaterial*) UUrMemory_Array_GetMemory(ONgTextureMaterials); // set up the material type for each element from the stored material name pointer @@ -516,7 +516,7 @@ ONrTextureMaterials_PreProcess( if (material->type == MAcInvalidID) { // the material was not found! material->type = MAcMaterial_Base; - } + } } // now that we have finshed using the stored string pointers, we can @@ -527,6 +527,6 @@ ONrTextureMaterials_PreProcess( UUrMemory_Block_VerifyList(); } ONgTextureMaterialsBinaryData = NULL; - } + } } diff --git a/OniProj/OniGameSource/Oni_TextureMaterials.h b/OniProj/OniGameSource/Oni_TextureMaterials.h index 0720bbc..aa39456 100644 --- a/OniProj/OniGameSource/Oni_TextureMaterials.h +++ b/OniProj/OniGameSource/Oni_TextureMaterials.h @@ -28,7 +28,7 @@ UUtError ONrTextureMaterialList_TextureMaterial_Set( const char *inTextureName, MAtMaterialType inMaterialType); - + // ---------------------------------------------------------------------- UUtError ONrTextureMaterials_Initialize( @@ -49,4 +49,4 @@ ONrTextureMaterials_LevelLoad( void); // ====================================================================== -#endif /* ONI_TEXTUREMATERIALS_H */ \ No newline at end of file +#endif /* ONI_TEXTUREMATERIALS_H */ diff --git a/OniProj/OniGameSource/Oni_UnitViewer.c b/OniProj/OniGameSource/Oni_UnitViewer.c index 2314200..a333f0a 100644 --- a/OniProj/OniGameSource/Oni_UnitViewer.c +++ b/OniProj/OniGameSource/Oni_UnitViewer.c @@ -43,7 +43,7 @@ #if defined(UUmPlatform) && (UUmPlatform == UUmPlatform_Mac) #define ONcUV_Creator '????' #endif - + // ====================================================================== // enums // ====================================================================== @@ -58,14 +58,14 @@ enum ONcUV_Btn_Select = 105, ONcUV_Btn_Stats = 106, ONcUV_Btn_Info = 107, - + ONcUV_Box_CharView = 140, - + ONcUV_Pict_CharLine = 150, ONcUV_Pict_CharSelectLine = 151, ONcUV_Pict_WeapLine = 160, ONcUV_Pict_WeapSelectLine = 161, - + ONcUV_LB_Characters = 400, ONcUV_LB_Weapons = 401 }; @@ -91,7 +91,7 @@ ONrDialogCallbac_UnitViewerControls( DMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2); - + // ====================================================================== // functions // ====================================================================== @@ -105,13 +105,13 @@ ONiCharViewBoxCallback( { // let the box callback handle all of the received messages VMrView_Box_Callback(inView, inMessage, inParam1, inParam2); - + // draw the character on top of the box if (inMessage == VMcMessage_Paint) { ONrUnitViewer_Character_Update(1, &ONgUV_ActionBuffer); } - + return 0; } @@ -132,27 +132,27 @@ ONiUnitViewer_Characters( VMtView *char_select_line; VMtView *weap_line; VMtView *weap_select_line; - + // get character related views characters_list = DMrDialog_GetViewByID(inDialog, ONcUV_LB_Characters); UUmAssert(characters_list); - + char_line = DMrDialog_GetViewByID(inDialog, ONcUV_Pict_CharLine); UUmAssert(char_line); - + char_select_line = DMrDialog_GetViewByID(inDialog, ONcUV_Pict_CharSelectLine); UUmAssert(char_select_line); - + // get weapon related views weapons_list = DMrDialog_GetViewByID(inDialog, ONcUV_LB_Weapons); UUmAssert(weapons_list); - + weap_line = DMrDialog_GetViewByID(inDialog, ONcUV_Pict_WeapLine); UUmAssert(weap_line); - + weap_select_line = DMrDialog_GetViewByID(inDialog, ONcUV_Pict_WeapSelectLine); UUmAssert(weap_select_line); - + // set the visibility of the views VMrView_SetVisible(characters_list, UUcTrue); VMrView_SetVisible(char_line, UUcTrue); @@ -161,10 +161,10 @@ ONiUnitViewer_Characters( VMrView_SetVisible(weapons_list, UUcFalse); VMrView_SetVisible(weap_line, UUcFalse); VMrView_SetVisible(weap_select_line, UUcFalse); - + // set the current list ID ONgUV_CurrentListID = ONcUV_LB_Characters; - + // select the first character in the list if (inSetSelection) { @@ -174,10 +174,10 @@ ONiUnitViewer_Characters( 0, 0); } - + // set the focus DMrDialog_SetFocus(inDialog, characters_list); - + return UUcError_None; } @@ -204,19 +204,19 @@ ONiUnitViewer_OniWebsite( ICError err; UUtInt32 oni_website_url_len; UUtInt32 oni_website_url_start; - UUtInt32 oni_website_url_end; - + UUtInt32 oni_website_url_end; + err = ICStart(&UV_ICInstance, ONcUV_Creator); if (err != noErr) return UUcError_Generic; - + err = ICFindConfigFile(UV_ICInstance, 0, nil); if (err != noErr) return UUcError_Generic; - + oni_website_url_len = strlen(oni_website_url); c2pstr(oni_website_url); oni_website_url_start = 0; oni_website_url_end = oni_website_url[0]; - + err = ICLaunchURL( UV_ICInstance, @@ -226,7 +226,7 @@ ONiUnitViewer_OniWebsite( &oni_website_url_start, &oni_website_url_end); if (err != noErr) return UUcError_Generic; - + ICStop(UV_ICInstance); } #elif defined(UUmPlatform) && (UUmPlatform == UUmPlatform_Win32) @@ -247,7 +247,7 @@ ONiUnitViewer_Controls( { UUtError error; UUtUns32 message; - + error = DMrDialog_Run( ONcDialogID_UnitViewerControls, @@ -255,7 +255,7 @@ ONiUnitViewer_Controls( inDialog, &message); if (error != UUcError_None) return error; - + return UUcError_None; } @@ -287,27 +287,27 @@ ONiUnitViewer_Weapons( VMtView *char_select_line; VMtView *weap_line; VMtView *weap_select_line; - + // get character related views characters_list = DMrDialog_GetViewByID(inDialog, ONcUV_LB_Characters); UUmAssert(characters_list); - + char_line = DMrDialog_GetViewByID(inDialog, ONcUV_Pict_CharLine); UUmAssert(char_line); - + char_select_line = DMrDialog_GetViewByID(inDialog, ONcUV_Pict_CharSelectLine); UUmAssert(char_select_line); - + // get weapon related views weapons_list = DMrDialog_GetViewByID(inDialog, ONcUV_LB_Weapons); UUmAssert(weapons_list); - + weap_line = DMrDialog_GetViewByID(inDialog, ONcUV_Pict_WeapLine); UUmAssert(weap_line); - + weap_select_line = DMrDialog_GetViewByID(inDialog, ONcUV_Pict_WeapSelectLine); UUmAssert(weap_select_line); - + // set the visibility of the views VMrView_SetVisible(characters_list, UUcFalse); VMrView_SetVisible(char_line, UUcFalse); @@ -316,10 +316,10 @@ ONiUnitViewer_Weapons( VMrView_SetVisible(weapons_list, UUcTrue); VMrView_SetVisible(weap_line, UUcTrue); VMrView_SetVisible(weap_select_line, UUcTrue); - + // set the current list ID ONgUV_CurrentListID = ONcUV_LB_Characters; - + // select the first weapon in the list if (inSetSelection) { @@ -329,7 +329,7 @@ ONiUnitViewer_Weapons( 0, 0); } - + // set the focus DMrDialog_SetFocus(inDialog, weapons_list); @@ -347,7 +347,7 @@ ONiUnitViewer_Character_SetClass( ONtCharacterClass *inCharacterClass) { ONrCharacter_SetCharacterClass(&ONgGameState->characters[0], inCharacterClass); - + return UUcError_None; } @@ -357,7 +357,7 @@ ONiUnitViewer_Weapon_SetClass( WPtWeaponClass *inWeaponClass) { ONrCharacter_UseNewWeapon(&ONgGameState->characters[0], inWeaponClass); - + return UUcError_None; } @@ -378,22 +378,22 @@ ONiUnitViewer_ListBox_Initialize( UUtUns32 i; IMtPixel gray; IMtPixel white; - + // get the list box view listbox = DMrDialog_GetViewByID(inDialog, inListBoxID); - if (listbox == NULL) return UUcError_Generic; - + if (listbox == NULL) return UUcError_Generic; + // get default gray and white gray = IMrPixel_FromShade(VMcControl_PixelType, IMcShade_Gray50); white = IMrPixel_FromShade(VMcControl_PixelType, IMcShade_White); - + // fill in the lines of the text boxes for (i = 0; i < inDataList->num_data_entries; i++) { UUtInt32 index; void *instance; UUtBool instance_available; - + // add the name to the list index = VMrView_SendMessage( @@ -401,7 +401,7 @@ ONiUnitViewer_ListBox_Initialize( LBcMessage_AddString, 0, (UUtUns32)inDataList->data[i].name); - + // set the color switch (inDataList->data_type) { @@ -412,7 +412,7 @@ ONiUnitViewer_ListBox_Initialize( inDataList->data[i].instance_name, &instance); break; - + case UVcDataType_Weapon: error = TMrInstance_GetDataPtr( @@ -421,7 +421,7 @@ ONiUnitViewer_ListBox_Initialize( &instance); break; } - + if ((error == UUcError_None) && (instance != NULL)) { instance_available = UUcTrue; @@ -430,7 +430,7 @@ ONiUnitViewer_ListBox_Initialize( { instance_available = UUcFalse; } - + if (instance_available) { VMrView_SendMessage( @@ -448,7 +448,7 @@ ONiUnitViewer_ListBox_Initialize( (UUtUns32)(&gray)); } } - + return UUcError_None; } @@ -462,27 +462,27 @@ ONiUnitViewer_ListBox_Scroll( VMtView *listbox; UUtUns32 current_selection; UUtUns32 num_lines; - + // get the list box view listbox = DMrDialog_GetViewByID(inDialog, inListBoxID); if (listbox == NULL) return; - + // get the current_selection from the list box - current_selection = + current_selection = VMrView_SendMessage( listbox, LBcMessage_GetCurrentSelection, 0, 0); - + // get the number of lines from the list box - num_lines = + num_lines = VMrView_SendMessage( listbox, LBcMessage_GetNumLines, 0, 0); - + if (inDirection) { if (current_selection > 0) @@ -497,7 +497,7 @@ ONiUnitViewer_ListBox_Scroll( current_selection++; } } - + // tell the list to scroll VMrView_SendMessage( listbox, @@ -515,7 +515,7 @@ ONiUnitViewer_ListBox_SelectionChange( { UUtError error; UUtInt32 selected_item; - + // get the currently selected item of the listbox selected_item = (UUtInt32)VMrView_SendMessage( @@ -523,47 +523,47 @@ ONiUnitViewer_ListBox_SelectionChange( LBcMessage_GetCurrentSelection, 0, 0); - + if ((selected_item < 0) || (selected_item >= (UUtInt32)inDataList->num_data_entries)) { // avoid recursion if (inDataList->num_data_entries == 0) return UUcError_None; - + // the selected item is out of the range, select the first item // in the list selected_item = 0; - + VMrView_SendMessage( inListBox, LBcMessage_SetSelection, selected_item, 0); - + return UUcError_None; } - + // a new item was selected, make use of it switch (inDataList->data_type) { case UVcDataType_Character: { ONtCharacterClass *character_class; - + error = TMrInstance_GetDataPtr( TRcTemplate_CharacterClass, ONgUV_CharacterList->data[selected_item].instance_name, &character_class); if (error != UUcError_None) return error; - + error = ONiUnitViewer_Character_SetClass(character_class); } break; - + case UVcDataType_Weapon: { WPtWeaponClass *weapon_class; - + error = TMrInstance_GetDataPtr( WPcTemplate_WeaponClass, @@ -575,7 +575,7 @@ ONiUnitViewer_ListBox_SelectionChange( } break; } - + return UUcError_None; } @@ -591,7 +591,7 @@ ONiUnitViewer_Destroy( { // terminate the character display ONrUnitViewer_Character_Terminate(); - + // terminate the timer VMrView_Timer_Stop(inDialog, ONcUV_UpdateTimerID); } @@ -606,7 +606,7 @@ ONiUnitViewer_Initialize( UUtUns32 num_datalists; UUtUns32 i; VMtView *character_view; - + // get the uv data lists error = TMrInstance_GetDataPtr_List( @@ -615,7 +615,7 @@ ONiUnitViewer_Initialize( &num_datalists, datalists); UUmError_ReturnOnError(error); - + for (i = 0; i < num_datalists; i++) { switch (datalists[i]->data_type) @@ -627,27 +627,27 @@ ONiUnitViewer_Initialize( case UVcDataType_Weapon: ONgUV_WeaponList = datalists[i]; break; - + case UVcDataType_URL: ONgUV_URLList = datalists[i]; break; - + default: return UUcError_Generic; break; } } - + if ((ONgUV_CharacterList == NULL) || (ONgUV_WeaponList == NULL) || (ONgUV_URLList == NULL)) { return UUcError_Generic; } - + // initialize the character display error = ONrUnitViewer_Character_Initialize(); - + // initialize the list boxes error = ONiUnitViewer_ListBox_Initialize( @@ -655,28 +655,28 @@ ONiUnitViewer_Initialize( ONcUV_LB_Characters, ONgUV_CharacterList); UUmError_ReturnOnError(error); - + error = ONiUnitViewer_ListBox_Initialize( inDialog, ONcUV_LB_Weapons, ONgUV_WeaponList); UUmError_ReturnOnError(error); - + ONiUnitViewer_Weapons(inDialog, UUcTrue); ONiUnitViewer_Characters(inDialog, UUcTrue); - + // replace the view proc of the character view box character_view = DMrDialog_GetViewByID(inDialog, ONcUV_Box_CharView); UUmAssert(character_view); VMrView_SetCallback(character_view, ONiCharViewBoxCallback); - + // clear the action buffer UUrMemory_Clear(&ONgUV_ActionBuffer, sizeof(LItAction)); - + // set the timer VMrView_Timer_Start(inDialog, ONcUV_UpdateTimerID, ONcUV_UpdateFrequency); - + return UUcError_None; } @@ -689,7 +689,7 @@ ONiUnitViewer_HandleCommand( VMtView *inView) { UUtError error; - + if (inCommandType == VMcNotify_Click) { switch (inViewID) @@ -697,15 +697,15 @@ ONiUnitViewer_HandleCommand( case ONcUV_Btn_Quit: DMrDialog_Stop(inDialog, 0); break; - + case ONcUV_Btn_Characters: error = ONiUnitViewer_Characters(inDialog, UUcFalse); break; - + case ONcUV_Btn_Weapons: error = ONiUnitViewer_Weapons(inDialog, UUcFalse); break; - + case ONcUV_Btn_Controls: error = ONiUnitViewer_Controls(inDialog); break; @@ -717,15 +717,15 @@ ONiUnitViewer_HandleCommand( DMrDialog_Stop(inDialog, 0); } break; - + case ONcUV_Btn_Select: error = ONiUnitViewer_Select(inDialog); break; - + case ONcUV_Btn_Stats: error = ONiUnitViewer_Stats(inDialog); break; - + case ONcUV_Btn_Info: error = ONiUnitViewer_Info(inDialog); break; @@ -750,7 +750,7 @@ ONiUnitViewer_HandleCommand( ONgUV_WeaponList); } } - + return UUcError_None; } @@ -759,20 +759,20 @@ static UUtError ONiUnitViewer_HandleKeyDown( DMtDialog *inDialog, UUtUns32 inKey) -{ +{ switch (inKey) { case LIcKeyCode_Escape: DMrDialog_Stop(inDialog, 0); break; - + /* case LIcKeyCode_UpArrow: ONiUnitViewer_ListBox_Scroll( inDialog, ONgUV_CurrentListID, UUcTrue); break; - + case LIcKeyCode_DownArrow: ONiUnitViewer_ListBox_Scroll( inDialog, @@ -780,7 +780,7 @@ ONiUnitViewer_HandleKeyDown( UUcFalse); break;*/ } - + return UUcError_None; } @@ -790,14 +790,14 @@ ONrUnitViewer_RegisterTemplates( void) { UUtError error; - + error = TMrTemplate_Register( UVcTemplate_DataList, sizeof(UVtDataList), TMcFolding_Allow); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -807,38 +807,38 @@ ONiUnitViewer_Update( DMtDialog *inDialog) { ONgUV_ActionBuffer.buttonBits = 0; - + // test the keys if (LIrTestKey(ONcUV_Forward)) ONgUV_ActionBuffer.buttonBits |= LIc_BitMask_Forward; - + if (LIrTestKey(ONcUV_Backward)) ONgUV_ActionBuffer.buttonBits |= LIc_BitMask_Backward; - + if (LIrTestKey(ONcUV_StepLeft)) ONgUV_ActionBuffer.buttonBits |= LIc_BitMask_StepLeft; - + if (LIrTestKey(ONcUV_StepRight)) ONgUV_ActionBuffer.buttonBits |= LIc_BitMask_StepRight; - + if (LIrTestKey(ONcUV_TurnLeft)) ONgUV_ActionBuffer.buttonBits |= LIc_BitMask_TurnLeft; - + if (LIrTestKey(ONcUV_TurnRight)) ONgUV_ActionBuffer.buttonBits |= LIc_BitMask_TurnRight; - + if (LIrTestKey(ONcUV_FirePunch)) ONgUV_ActionBuffer.buttonBits |= LIc_BitMask_Fire1; - + if (LIrTestKey(ONcUV_Kick)) ONgUV_ActionBuffer.buttonBits |= LIc_BitMask_Kick; - + if (LIrTestKey(ONcUV_Crouch)) ONgUV_ActionBuffer.buttonBits |= LIc_BitMask_Crouch; - + if (LIrTestKey(ONcUV_Jump)) ONgUV_ActionBuffer.buttonBits |= LIc_BitMask_Jump; - + return UUcError_None; } @@ -857,9 +857,9 @@ ONrDialogCallback_UnitViewer( { UUtBool handled; UUtError error; - + handled = UUcTrue; - + switch (inMessage) { case DMcMessage_InitDialog: @@ -869,11 +869,11 @@ ONrDialogCallback_UnitViewer( DMrDialog_Stop(inDialog, 0); } break; - + case VMcMessage_Destroy: ONiUnitViewer_Destroy(inDialog); break; - + case VMcMessage_Command: error = ONiUnitViewer_HandleCommand( @@ -886,7 +886,7 @@ ONrDialogCallback_UnitViewer( DMrDialog_Stop(inDialog, 0); } break; - + case VMcMessage_KeyDown: error = ONiUnitViewer_HandleKeyDown(inDialog, inParam1); if (error != UUcError_None) @@ -894,7 +894,7 @@ ONrDialogCallback_UnitViewer( DMrDialog_Stop(inDialog, 0); } break; - + case VMcMessage_Timer: error = ONiUnitViewer_Update(inDialog); if (error != UUcError_None) @@ -902,12 +902,12 @@ ONrDialogCallback_UnitViewer( DMrDialog_Stop(inDialog, 0); } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -920,29 +920,29 @@ ONrDialogCallbac_UnitViewerControls( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case DMcMessage_InitDialog: DMrDialog_SetMouseFocusView(inDialog, inDialog); break; - + case VMcMessage_Destroy: DMrDialog_ReleaseMouseFocusView(inDialog, inDialog); break; - + case VMcMessage_LMouseUp: case VMcMessage_KeyDown: DMrDialog_Stop(inDialog, 0); break; - + default: handled = UUcFalse; break; } - + return handled; } diff --git a/OniProj/OniGameSource/Oni_UnitViewer.h b/OniProj/OniGameSource/Oni_UnitViewer.h index ba2ad4f..10fad2d 100644 --- a/OniProj/OniGameSource/Oni_UnitViewer.h +++ b/OniProj/OniGameSource/Oni_UnitViewer.h @@ -33,7 +33,7 @@ enum UVcDataType_Character, UVcDataType_Weapon, UVcDataType_URL - + }; // ====================================================================== @@ -43,7 +43,7 @@ typedef tm_struct UVtData { char instance_name[32]; /* UVcMaxInstNameLength */ char name[32]; /* UVcMaxDataNameLength */ - + } UVtData; #define UVcTemplate_DataList UUm4CharToUns32('U', 'V', 'D', 'L') @@ -51,12 +51,12 @@ typedef tm_template('U', 'V', 'D', 'L', "UV Data List") UVtDataList { tm_pad pad[16]; - + UUtUns32 data_type; - + tm_varindex UUtUns32 num_data_entries; tm_vararray UVtData data[1]; - + } UVtDataList; @@ -88,4 +88,4 @@ ONrUnitViewer_Character_Update( LItAction *actionBuffer); // ====================================================================== -#endif /* ONI_UNITVIEWER_H */ \ No newline at end of file +#endif /* ONI_UNITVIEWER_H */ diff --git a/OniProj/OniGameSource/Oni_Weapon.c b/OniProj/OniGameSource/Oni_Weapon.c index 0af9e4d..d7cd835 100644 --- a/OniProj/OniGameSource/Oni_Weapon.c +++ b/OniProj/OniGameSource/Oni_Weapon.c @@ -1,11 +1,11 @@ /* FILE: Oni_Weapon.c - + AUTHOR: Quinn Dunki, Michael Evans, Chris Butcher - + CREATED: April 2, 1999 - + PURPOSE: control of weapons in ONI - + Copyright 1998, 2000 */ @@ -80,7 +80,7 @@ struct WPtWeapon UUtUns16 fadeTime; UUtUns16 freeTime; UUtUns32 birthDate; - + // state variables UUtUns16 chamber_time; UUtUns16 chamber_time_total; @@ -144,7 +144,7 @@ WPiCommand_GivePowerup( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue); static void WPrPowerup_AddPhysics( @@ -186,7 +186,7 @@ static void FaceKnockdown(ONtCharacter *ioCharacter, M3tVector3D *inDirection, T return; } -static UUtBool InflictDamage(ONtCharacter *inCharacter, float inRadius, M3tPoint3D *inHitPoint, M3tVector3D *inDirection, +static UUtBool InflictDamage(ONtCharacter *inCharacter, float inRadius, M3tPoint3D *inHitPoint, M3tVector3D *inDirection, P3tEnumDamageType inDamageType, UUtUns32 inDamage, UUtUns32 inStun, float inKnockback, P3tParticleReference inParticleRef, UUtUns32 inOwner) { @@ -200,7 +200,7 @@ static UUtBool InflictDamage(ONtCharacter *inCharacter, float inRadius, M3tPoint return UUcFalse; } - + if (inParticleRef != P3cParticleReference_Null) { if (active_character->lastParticleDamageRef == inParticleRef) { // this particle cannot collide twice with the same character, @@ -222,7 +222,7 @@ static UUtBool InflictDamage(ONtCharacter *inCharacter, float inRadius, M3tPoint // this character is totally immune to weapon damage } else if (inCharacter->inventory.shieldRemaining > 0) { - if (inCharacter->inventory.shieldRemaining >= inDamage) { + if (inCharacter->inventory.shieldRemaining >= inDamage) { inCharacter->inventory.shieldRemaining -= (UUtUns16) inDamage; } else { @@ -377,7 +377,7 @@ UUtBool WPrHitChar(void *inHitChar, M3tPoint3D *inHitPoint, M3tVector3D *inDirec } - UUmAssert((character >= ONgGameState->characters) && + UUmAssert((character >= ONgGameState->characters) && (character < &ONgGameState->characters[ONgGameState->numCharacters])); MUmVector_Copy(hit_dir, *inDirection); @@ -386,7 +386,7 @@ UUtBool WPrHitChar(void *inHitChar, M3tPoint3D *inHitPoint, M3tVector3D *inDirec ONrCharacter_GetPelvisPosition(character, &pelvis_pt); MUmVector_Subtract(hit_dir, pelvis_pt, *inHitPoint); if (MUrVector_Normalize_ZeroTest(&hit_dir)) { - // we have been hit exactly at our pelvis, no hit direction is available - + // we have been hit exactly at our pelvis, no hit direction is available - // build a hit direction from our front MUmVector_Set(hit_dir, -MUrSin(character->facing), 0, -MUrCos(character->facing)); } @@ -453,12 +453,12 @@ void WPrBlast(M3tPoint3D *inLocation, P3tEnumDamageType inDamageType, float inDa continue; } - switch(inFalloffType) + switch(inFalloffType) { case P3cEnumFalloff_None: percent_effect = 1.0f; break; - + case P3cEnumFalloff_Linear: percent_effect = 1.0f - distance; break; @@ -471,7 +471,7 @@ void WPrBlast(M3tPoint3D *inLocation, P3tEnumDamageType inDamageType, float inDa default: percent_effect = 1.0f; } - + MUrNormalize(&blast_vector); damage_integer = MUrUnsignedSmallFloat_To_Uns_Round(percent_effect * inDamage); @@ -550,7 +550,7 @@ static void WPiWeaponPhysics_PostCollision_Callback( PHtCollider *collider; PHtPhysicsContext *otherContext = NULL; WPtWeapon *weapon = (WPtWeapon *)ioContext->callbackData; - + UUmAssert(ioContext->callback->type == PHcCallback_Weapon); UUmAssert(ioContext->flags & PHcFlags_Physics_InUse); UUmAssert(!ioContext->sphereTree->child); @@ -559,13 +559,13 @@ static void WPiWeaponPhysics_PostCollision_Callback( for (i=0; i<*ioNumColliders; i++) { collider = ioColliders + i; - + // Determine what we hit switch (collider->type) { case PHcCollider_Env: - if ((float)fabs(ioContext->velocity.x * collider->plane.a + - ioContext->velocity.y * collider->plane.b + + if ((float)fabs(ioContext->velocity.x * collider->plane.a + + ioContext->velocity.y * collider->plane.b + ioContext->velocity.z * collider->plane.c) > WPcImpact_MinVelocity) { WPiGenerateFallImpact(collider, WPgWeaponImpactType); } @@ -635,7 +635,7 @@ static void WPiPowerupPhysics_PostCollision_Callback( PHtCollider *collider; PHtPhysicsContext *otherContext = NULL; WPtPowerup *powerup = (WPtPowerup *)ioContext->callbackData; - + UUmAssert(ioContext->callback->type == PHcCallback_Powerup); UUmAssert(ioContext->flags & PHcFlags_Physics_InUse); UUmAssert(!ioContext->sphereTree->child); @@ -657,8 +657,8 @@ static void WPiPowerupPhysics_PostCollision_Callback( } else if (collider->type == PHcCollider_Env) { if ((!played_impact) && - ((float)fabs(ioContext->velocity.x * collider->plane.a + - ioContext->velocity.y * collider->plane.b + + ((float)fabs(ioContext->velocity.x * collider->plane.a + + ioContext->velocity.y * collider->plane.b + ioContext->velocity.z * collider->plane.c) > WPcImpact_MinVelocity)) { WPiGenerateFallImpact(collider, WPgPowerupImpactType); played_impact = UUcTrue; @@ -682,7 +682,7 @@ UUtError WPrRegisterTemplates( error = TMrTemplate_Register(WPcTemplate_WeaponClass, sizeof(WPtWeaponClass), TMcFolding_Allow); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -786,7 +786,7 @@ static void WPiWeaponPhysics_Callback_ReceiveForce( } PHrPhysics_Accelerate(ioContext, inForce); - + return; } @@ -817,7 +817,7 @@ static void WPiFindParticleClasses(WPtWeaponClass *inClass) for (itr = 0, attachment = inClass->attachment; itr < inClass->attachment_count; itr++, attachment++) { attachment->classptr = P3rGetParticleClass(attachment->classname); } - + inClass->flags |= WPcWeaponClassFlag_ParticlesFound; } @@ -850,7 +850,7 @@ static void WPiNewParticles(WPtWeaponClass *inClass, WPtWeapon *ioWeapon) ioWeapon->particle_ref[itr] = P3cParticleReference_Null; continue; } - + particle = P3rCreateParticle(attachment->classptr, creation_time); if (particle == NULL) { ioWeapon->particle[itr] = NULL; @@ -1024,7 +1024,7 @@ static void WPiInit( { static UUtBool once = UUcTrue; - if (once) { + if (once) { WPrSetupCallbacks(); once = UUcFalse; @@ -1108,7 +1108,7 @@ static WPtWeapon *WPiFindOldest( for (i=0; iflags & WPcWeaponFlag_InUse)) { continue; } if (weapon->flags & WPcWeaponFlag_Untouchable) continue; @@ -1165,7 +1165,7 @@ WPrGetPosition( *outPosition = MUrMatrix_GetTranslation(&inWeapon->matrix); return; -} +} void WPrGetPickupPosition( @@ -1179,7 +1179,7 @@ WPrGetPickupPosition( MUmVector_Add(*outPosition, inWeapon->weaponClass->pickup_offset, MUrMatrix_GetTranslation(&inWeapon->matrix)); return; -} +} M3tGeometry* WPrGetGeometry( @@ -1202,12 +1202,12 @@ WPrInUse( const WPtWeapon *inWeapon) { UUtBool result = UUcFalse; - + if (inWeapon) { result = ((inWeapon->flags & WPcWeaponFlag_InUse) != 0); } - + return result; } @@ -1238,7 +1238,7 @@ WPtWeapon *WPrNew(WPtWeaponClass *inClass, WPtPlacedWeapon inPlacedWeapon) } WPiInit(inClass, weapon, inPlacedWeapon); - + return weapon; } @@ -1267,12 +1267,12 @@ void WPrDelete( /***************** * Deletes a weapon */ - + UUtUns16 itr; P3tParticleClass *this_class; if ((inWeapon->flags & WPcWeaponFlag_InUse) == 0) { return; } - + // shut down the weapon WPrReleaseTrigger(inWeapon, UUcTrue); WPrStopChamberDelay(inWeapon); @@ -1287,13 +1287,13 @@ void WPrDelete( } } } - + // release the physics context if (inWeapon->physics) { PHrPhysicsContext_Remove(inWeapon->physics); inWeapon->physics = NULL; } - + // tell the AI that we've stopped firing if (inWeapon->ai_firingspread_index != (UUtUns32) -1) { AI2rKnowledge_DeleteDodgeFiringSpread(inWeapon->ai_firingspread_index); @@ -1392,7 +1392,7 @@ static void WPiUpdate(WPtWeapon *ioWeapon) if (matrixptr == NULL) { MUrMatrix_SetTranslation(&ioWeapon->matrix, &ioWeapon->owner->actual_position); ioWeapon->matrix.m[3][1] += ioWeapon->owner->heightThisFrame; - } + } else { ioWeapon->matrix = *matrixptr; } @@ -1573,11 +1573,11 @@ void WPrDisplay( M3tPoint3D glow_center; UUtUns32 alpha_i; UUtBool is_visible; - M3tMatrix4x3 weapon_matrix; + M3tMatrix4x3 weapon_matrix; M3tBoundingBox_MinMax bbox; M3rGeom_State_Push(); - + // powerup glow sprite alpha is unsorted M3rGeom_State_Set(M3cGeomStateIntType_SubmitMode, M3cGeomState_SubmitMode_Normal); M3rGeom_State_Set(M3cGeomStateIntType_SpriteMode, M3cGeomState_SpriteMode_Flat); @@ -1591,7 +1591,7 @@ void WPrDisplay( if (!(weapon->flags & WPcWeaponFlag_InUse)) continue; UUmAssert(weaponClass->geometry); - + // Note: owned weapons are displayed as an extra body part if (!weapon->owner) { @@ -1635,10 +1635,10 @@ void WPrDisplay( AKrEnvironment_NodeList_Get(&bbox, WPcWeaponNodeCount, weapon->oct_tree_node_index, 0); weapon->last_position= center; } - + is_visible= AKrEnvironment_NodeList_Visible(weapon->oct_tree_node_index); } - + if (is_visible) { M3rGeom_State_Push(); @@ -1763,7 +1763,7 @@ static void WPiPulseShooter(WPtWeapon *inWeapon, UUtUns16 inIndex, WPtParticleAt // pulse all particles attached to this shooter WPrSendEvent(inWeapon, P3cEvent_Pulse, inShooter->shooter_index); - + // this is the shooter and it's being started - i.e. the weapon is actually firing. if ((owner->flags & ONcCharacterFlag_InfiniteAmmo) == 0) { // use ammo @@ -1796,18 +1796,18 @@ static void WPiPulseShooter(WPtWeapon *inWeapon, UUtUns16 inIndex, WPtParticleAt TRtAnimType recoil_anim_type = inWeapon->weaponClass->recoilAnimType; const WPtRecoil *recoil_info = WPrClass_GetRecoilInfo(inWeapon->weaponClass); const TRtAnimation *recoil; - + recoil = TRrCollection_Lookup( - owner->characterClass->animations, - recoil_anim_type, - ONcAnimState_Anything, + owner->characterClass->animations, + recoil_anim_type, + ONcAnimState_Anything, active_character->animVarient); - + if (NULL != recoil) { ONrOverlay_Set(active_character->overlay + ONcOverlayIndex_Recoil, recoil, 0); } - + recoil_amount = recoil_info->base; if (WPgGatlingCheat && (owner->charType == ONcChar_Player)) { recoil_amount = (recoil_amount * inShooter->cheat_chamber_time) / inShooter->chamber_time; @@ -1823,7 +1823,7 @@ static void WPiPulseShooter(WPtWeapon *inWeapon, UUtUns16 inIndex, WPtParticleAt recoil_amount *= (1.0f - shooting_skill->recoil_compensation); } - + owner->recoilSpeed += recoil_amount; } @@ -2072,14 +2072,14 @@ void WPrReleaseTrigger(WPtWeapon *ioWeapon, UUtBool inForceImmediate) return; } - if ((ioWeapon->weaponClass->flags & WPcWeaponClassFlag_DontStopWhileFiring) && + if ((ioWeapon->weaponClass->flags & WPcWeaponClassFlag_DontStopWhileFiring) && (ioWeapon->chamber_time > ioWeapon->weaponClass->stopChamberThreshold)) { // delay the release of the trigger until the chamber time is finished ioWeapon->flags |= WPcWeaponFlag_DelayRelease; return; } } - + // stop firing ioWeapon->flags &= ~WPcWeaponFlag_DelayRelease; ioWeapon->must_fire_time = 0; @@ -2130,9 +2130,9 @@ void WPrAssign( /************** * Assigns a weapon to a character */ - + if ((inWeapon->flags & WPcWeaponFlag_InUse) == 0) { return; } - + // Assign owner inWeapon->owner = inOwner; inWeapon->reloadTime = 0; @@ -2146,7 +2146,7 @@ void WPrAssign( // Setup timers inWeapon->freeTime = 0; inWeapon->fadeTime = 0; - + inWeapon->flags |= WPcWeaponFlag_InHand; // don't go inactive, since we have been picked up @@ -2268,7 +2268,7 @@ void WPrGetMarker( MUmVector_Add(worldMuzzle[1], inMarker->position, inMarker->vector); worldMuzzle[0] = inMarker->position; - + MUrMatrix_MultiplyPoints(2, (M3tMatrix4x3 *)&inWeapon->matrix, worldMuzzle, worldMuzzle); // velocity and position @@ -2348,13 +2348,13 @@ WPiCreateWeapon_Callback( UUtError error; OBJtOSD_Weapon *weapon_osd; WPtWeaponClass *weapon_class; - + weapon_osd = (OBJtOSD_Weapon*)inObject->object_data; error = TMrInstance_GetDataPtr( WPcTemplate_WeaponClass, - weapon_osd->weapon_class_name, + weapon_osd->weapon_class_name, &weapon_class); if (error == UUcError_None) { @@ -2368,7 +2368,7 @@ WPiCreateWeapon_Callback( WPrSetPosition(weapon, &position, inObject->rotation.x * M3cDegToRad); weapon->flags |= WPcWeaponFlag_Object; } - + return UUcTrue; } @@ -2381,7 +2381,7 @@ WPiCreateWeaponsFromObjects( WPiCreateWeapon_Callback, 0); } - + static UUtError WPiWeapons_Reset( SLtErrorContext* inErrorContext, @@ -2393,13 +2393,13 @@ WPiWeapons_Reset( { WPtWeapon *weapon; UUtUns32 itr; - + // delete the unheld weapons currently in use for (itr = 0, weapon = WPgWeapons; itr < WPcMaxWeapons; itr++, weapon++) { if ((weapon->flags & WPcWeaponFlag_InUse) == 0) { continue; } if (weapon->owner != NULL) { continue; } - + // delete the weapon WPrDelete(weapon); } @@ -2422,13 +2422,13 @@ WPiCreatePowerup_Callback( if (powerup_osd->powerup != NULL) { powerup_osd->powerup->flags |= WPcPowerupFlag_PlacedAsObject; - + if (powerup_osd->powerup->geometry != NULL) { // don't create powerups embedded in floor powerup_osd->powerup->position.y -= powerup_osd->powerup->geometry->pointArray->minmax_boundingBox.minPoint.y; } } - + return UUcTrue; } @@ -2453,7 +2453,7 @@ WPiPowerups_Reset( { WPtPowerup *powerup; UUtUns32 itr; - + // delete all powerups... note that we must do this from the end of the array // because the delete operation moves the last powerup up to fill the hole made by // deleting one @@ -2461,9 +2461,9 @@ WPiPowerups_Reset( // delete the powerup WPrPowerup_Delete(powerup); } - + WPiCreatePowerupsFromObjects(); - + return UUcError_None; } @@ -2487,10 +2487,10 @@ UUtError WPrInitialize( error = SLrGlobalVariable_Register_Float("recoil_max", "max", &WPgRecoil_Edited.max); error = SLrGlobalVariable_Register_Float("recoil_factor", "factor", &WPgRecoil_Edited.factor); error = SLrGlobalVariable_Register_Float("recoil_return_speed", "return speed", &WPgRecoil_Edited.returnSpeed); - + error = SLrGlobalVariable_Register_Int32("wp_hypostrength", "Sets strength of hypo spray", &WPgHypoStrength); UUmError_ReturnOnError(error); - + error = SLrGlobalVariable_Register_Int32("wp_fadetime", "Sets free time for powerups", &WPgFadeTime); UUmError_ReturnOnError(error); #endif @@ -2502,16 +2502,16 @@ UUtError WPrInitialize( error = SLrGlobalVariable_Register_Bool("wp_disable_fade", "Disables weapon fading", &WPgDisableFade); UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "give_powerup", "Gives a powerup to a character", "powerup_name:string [amount:int | ] [character:int | ]", WPiCommand_GivePowerup); - UUmError_ReturnOnError(error); + UUmError_ReturnOnError(error); #if CONSOLE_DEBUGGING_COMMANDS - error = + error = SLrScript_Command_Register_Void( "weapon_reset", "resets all unheld weapons to their starting state", @@ -2519,7 +2519,7 @@ UUtError WPrInitialize( WPiWeapons_Reset); UUmError_ReturnOnError(error); - error = + error = SLrScript_Command_Register_Void( "powerup_reset", "resets all placed powerups to their starting points", @@ -2530,12 +2530,12 @@ UUtError WPrInitialize( // clear the weapon array UUrMemory_Clear(WPgWeapons, sizeof(WPtWeapon) * WPcMaxWeapons); - + for (i = 0, weapon = WPgWeapons; i < WPcMaxWeapons; i++, weapon++) { weapon->index = i; } - + return UUcError_None; } @@ -2553,23 +2553,23 @@ UUtError WPrLevel_Begin(void) WPgPowerupImpactType = MArImpactType_GetByName("Powerup"); WPgNumPowerups = 0; - + WPiCreateWeaponsFromObjects(); WPiCreatePowerupsFromObjects(); - + return UUcError_None; } void WPrLevel_End(void) { UUtUns16 i; - + // Delete weapons for (i=0; iflags & WPcWeaponFlag_InUse)) continue; - + WPrDelete(curWeapon); } @@ -2671,7 +2671,7 @@ UUtUns32 WPrLocateNearbyWeapons(const M3tPoint3D *inLocation, float inMaxRadius) if (!WPrCanBePickedUp(weapon)) continue; - + WPrGetPickupPosition(weapon, &pickup_position); weapon->nearby_distance_squared = MUrPoint_Distance_Squared(inLocation, &pickup_position); @@ -2754,8 +2754,8 @@ WPtPowerup *WPrFind_Powerup_XZ_Squared( WPtPowerup *powerup = WPgPowerups + i; float distance_squared; - if ((NULL != inPowerup) && (inPowerup != powerup)) continue; - + if ((NULL != inPowerup) && (inPowerup != powerup)) continue; + if ((powerup->position.y < inMinY) || (powerup->position.y > inMaxY)) { continue; } @@ -2811,7 +2811,7 @@ void WPrSlot_Drop( // want to delete our particles. weapon->flags |= (WPcWeaponFlag_DeferUpdate_GoInactive | WPcWeaponFlag_DeferUpdate_StopFiring); weapon->flags &= ~WPcWeaponFlag_InHand; - } + } else { // we are dropping a weapon directly from inventory... update its position before // we drop it. also note that weapon_index won't be being updated because we don't have @@ -2909,7 +2909,7 @@ void WPrMagicDrop(ONtCharacter *inCharacter, WPtWeapon *inWeapon, UUtBool inWant // character is inactive, choose approximate location MUrMatrix_SetTranslation(&inWeapon->matrix, &inCharacter->actual_position); inWeapon->matrix.m[3][1] += inCharacter->heightThisFrame; - } + } else { inWeapon->matrix = *matrix_ptr; } @@ -3050,7 +3050,7 @@ UUtBool WPrSlot_FindEmpty( if ((inAllowMagic) && (NULL == inInventory->weapons[WPcMagicSlot])) { did_find_slot = UUcTrue; result_slot = WPcMagicSlot; - + goto exit; } @@ -3100,7 +3100,7 @@ WPtWeapon *WPrSlot_FindLastStowed( *outSlotNum = WPcMagicSlot; } - return inInventory->weapons[WPcMagicSlot]; + return inInventory->weapons[WPcMagicSlot]; } for (i=WPcMaxSlots-1; i>=0; i--) @@ -3338,11 +3338,11 @@ WPtPowerup *WPrPowerup_New( powerup = WPgPowerups + WPgNumPowerups; reusing = UUcFalse; } - + UUrMemory_Clear(powerup,sizeof(WPtPowerup)); error = WPrPowerup_SetType(powerup, inType); if (error != UUcError_None) return NULL; - + pos = *inPosition; powerup->flags = 0; powerup->amount = inAmount; @@ -3367,7 +3367,7 @@ WPtPowerup *WPrPowerup_SpawnAtFlag( return NULL; } - powerup->flags |= WPcPowerupFlag_PlacedAsObject; + powerup->flags |= WPcPowerupFlag_PlacedAsObject; if (powerup->geometry != NULL) { // don't create powerups embedded in floor powerup->position.y -= powerup->geometry->pointArray->minmax_boundingBox.minPoint.y; @@ -3375,7 +3375,7 @@ WPtPowerup *WPrPowerup_SpawnAtFlag( return powerup; } - + void WPrPowerup_Display( void) { @@ -3408,7 +3408,7 @@ void WPrPowerup_Display( // level is 0..31 // float_level = level * (1.0f / 31.0f); // ONrGameState_ConstantColorLighting(float_level, float_level, float_level); - + M3rGeom_State_Set(M3cGeomStateIntType_SpriteMode, M3cGeomState_SpriteMode_Flat); M3rGeom_State_Commit(); @@ -3423,16 +3423,16 @@ void WPrPowerup_Display( { // draw debugging physics collision UUtUns32 index = powerup->physics - PHgPhysicsContextArray->contexts; - + M3rGeom_State_Push(); - + // Draw bounding spheres and boxes M3rGeom_State_Set(M3cGeomStateIntType_Fill, M3cGeomState_Fill_Line); M3rDraw_State_SetInt(M3cDrawStateIntType_ConstantColor,IMcShade_White); M3rGeom_State_Set(M3cGeomStateIntType_Appearance, M3cGeomState_Appearance_Gouraud); - + if (powerup->physics->sphereTree) PHrSphereTree_Draw(powerup->physics->sphereTree); - + M3rGeom_State_Pop(); } @@ -3444,7 +3444,7 @@ void WPrPowerup_Display( alpha_i = (UUtUns32)(255.0f * alpha_f); M3rGeom_State_Set(M3cGeomStateIntType_Alpha, alpha_i); } - + M3rGeom_State_Set(M3cGeomStateIntType_Alpha, alpha_i); M3rGeom_State_Commit();*/ @@ -3474,7 +3474,7 @@ void WPrPowerup_Display( AKrEnvironment_NodeList_Get(&bbox, WPcPowerupNodeCount, powerup->oct_tree_node_index, 0); powerup->last_position= powerup->position; } - + is_visible= AKrEnvironment_NodeList_Visible(powerup->oct_tree_node_index); } @@ -3604,11 +3604,11 @@ UUtBool WPrTryReload(ONtCharacter *inCharacter, WPtWeapon *inWeapon, UUtBool *ou // we use the powerup here and start the reload animation { const TRtAnimation *reload_animation; - + reload_animation = TRrCollection_Lookup( - inCharacter->characterClass->animations, - WPrGetClass(inCharacter->inventory.weapons[0])->reloadAnimType, - ONcAnimState_Standing, + inCharacter->characterClass->animations, + WPrGetClass(inCharacter->inventory.weapons[0])->reloadAnimType, + ONcAnimState_Standing, active_character->animVarient); if (NULL == reload_animation) { @@ -3706,7 +3706,7 @@ UUtBool WPrPowerup_Use(ONtCharacter *inCharacter, // once we reach max amount_remaining = 1.0f - (inCharacter->maxHitPoints - targetHitPoints) / ((float) hypoAmount); hypoAmount = MUrUnsignedSmallFloat_To_Uns_Round(amount_remaining * inCharacter->maxHitPoints - * ONgGameSettings->hypo_boost_amount); + * ONgGameSettings->hypo_boost_amount); targetHitPoints = inCharacter->maxHitPoints + hypoAmount; } else { // this hypo does not take us past the character's max hit points @@ -3724,7 +3724,7 @@ UUtBool WPrPowerup_Use(ONtCharacter *inCharacter, inCharacter->inventory.hypo--; return UUcTrue; } - + case WPcPowerup_None: return UUcFalse; @@ -3740,7 +3740,7 @@ WPiCommand_GivePowerup( UUtUns32 inParameterListLength, SLtParameter_Actual* inParameterList, UUtUns32 *outTicksTillCompletion, - UUtBool *outStall, + UUtBool *outStall, SLtParameter_Actual *ioReturnValue) { WPtPowerupType p_type; @@ -3768,7 +3768,7 @@ WPiCommand_GivePowerup( if (inParameterListLength < 2) { amount = WPrPowerup_DefaultAmount(p_type); - } + } else { amount = (UUtUns16) inParameterList[1].val.i; } @@ -3784,7 +3784,7 @@ WPiCommand_GivePowerup( UUtUns32 itr; UUtUns32 count = ONrGameState_LivingCharacterList_Count(); ONtCharacter **list = ONrGameState_LivingCharacterList_Get(); - + for(itr = 0; itr < count; itr++) { index = ONrCharacter_GetIndex(list[itr]); @@ -3834,7 +3834,7 @@ UUtUns16 WPrPowerup_CouldReceive(ONtCharacter *inCharacter, WPtPowerupType inTyp case WPcPowerup_Hypo: return WPrPowerup_BoundsCheck(inCharacter->inventory.hypo, WPcMaxHypos, inAmount, UUcTrue); - + case WPcPowerup_ShieldBelt: return WPrPowerup_BoundsCheck(inCharacter->inventory.shieldRemaining, WPcMaxShields, inAmount, UUcFalse); @@ -3891,7 +3891,7 @@ UUtUns16 WPrPowerup_Give(ONtCharacter *inCharacter, WPtPowerupType inType, UUtUn ONrGameState_EventSound_Play(ONcEventSound_ReceiveHypo, NULL); } break; - + case WPcPowerup_ShieldBelt: inCharacter->inventory.shieldRemaining += give_amount; break; @@ -3929,17 +3929,17 @@ UUtUns16 WPrPowerup_Give(ONtCharacter *inCharacter, WPtPowerupType inType, UUtUn } } } - + return give_amount; } -UUtError +UUtError WPrPowerup_SetType( WPtPowerup *ioPowerup, WPtPowerupType inPowerupType) { UUmAssert(ioPowerup); - + ioPowerup->type = inPowerupType; ioPowerup->geometry = NULL; ioPowerup->glow_texture = NULL; @@ -4057,7 +4057,7 @@ const WPtRecoil *WPrClass_GetRecoilInfo( } void WPrRecoil_UserTo_Internal( - const WPtRecoil *inUserRecoil, + const WPtRecoil *inUserRecoil, WPtRecoil *outInternalRecoil) { outInternalRecoil->base = inUserRecoil->base * (M3c2Pi / 360.f); diff --git a/OniProj/OniGameSource/Oni_Weapon.h b/OniProj/OniGameSource/Oni_Weapon.h index 05cb99f..09427de 100644 --- a/OniProj/OniGameSource/Oni_Weapon.h +++ b/OniProj/OniGameSource/Oni_Weapon.h @@ -1,12 +1,12 @@ #pragma once /* FILE: Oni_Weapon.h - + AUTHOR: Quinn Dunki - + CREATED: April 2 1999 - + PURPOSE: control of weapons in ONI - + Copyright 1998 */ @@ -149,7 +149,7 @@ typedef tm_struct WPtSprite float scale; } WPtSprite; -typedef enum WPtScaleMode +typedef enum WPtScaleMode { WPcScaleMode_Scale, WPcScaleMode_HalfScale, @@ -178,7 +178,7 @@ WPtWeaponClass WPtSprite tunnel; UUtUns32 tunnel_count; float tunnel_spacing; - + M3tTextureMap *icon; M3tTextureMap *hud_empty; M3tTextureMap *hud_fill; @@ -196,7 +196,7 @@ WPtWeaponClass UUtUns16 freeTime; UUtUns16 recoilAnimType; UUtUns16 reloadAnimType; - UUtUns16 reloadTime; + UUtUns16 reloadTime; UUtUns16 max_ammo; UUtUns16 attachment_count; UUtUns16 shooter_count; @@ -242,7 +242,7 @@ typedef enum WPtWeaponFlags WPcWeaponFlag_NoWeaponCollision = 0x2000, WPcWeaponFlag_DeferUpdate_StopFiring = 0x4000, WPcWeaponFlag_DeferUpdate_GoInactive = 0x8000 - + } WPtWeaponFlags; typedef enum WPtDamageOwnerType @@ -306,11 +306,11 @@ typedef tm_enum WPtPowerupType WPcPowerup_ShieldBelt, WPcPowerup_Invisibility, WPcPowerup_LSI, - + WPcPowerup_NumTypes, - + WPcPowerup_None = 0xFFFFFFFF - + } WPtPowerupType; extern const char *WPgPowerupName[]; @@ -477,7 +477,7 @@ UUtUns16 WPrMaxAmmo( M3tGeometry* WPrGetGeometry( const WPtWeapon *inWeapon); - + WPtWeapon *WPrFind_Weapon_XZ_Squared( const M3tPoint3D *inLocation, float inMinY, @@ -609,7 +609,7 @@ UUtError WPrPowerup_SetType( WPtPowerup *ioPowerup, WPtPowerupType inPowerupType); - + WPtPowerupType WPrAmmoType( WPtWeapon *inWeapon); @@ -644,7 +644,7 @@ const WPtRecoil *WPrClass_GetRecoilInfo( const WPtWeaponClass *inClass); void WPrRecoil_UserTo_Internal( - const WPtRecoil *inUserRecoil, + const WPtRecoil *inUserRecoil, WPtRecoil *outInternalRecoil); // send an event to all particles attached to a weapon diff --git a/OniProj/OniGameSource/Oni_Windows.c b/OniProj/OniGameSource/Oni_Windows.c index 6a0320e..a361c00 100644 --- a/OniProj/OniGameSource/Oni_Windows.c +++ b/OniProj/OniGameSource/Oni_Windows.c @@ -82,29 +82,29 @@ OWrLevelList_Initialize( UUtError error; UUtUns32 num_descriptors; UUtBool vidmaster = UUcFalse; - + // get the number of descriptors num_descriptors = (UUtUns16)TMrInstance_GetTagCount(ONcTemplate_Level_Descriptor); if (num_descriptors > 0) { UUtUns32 i; WMtListBox *levels; - + // get a pointer to the level list levels = WMrDialog_GetItemByID(inDialog, inItemID); if (levels == NULL) return; - + for (i = 0; i < num_descriptors; i++) { ONtLevel_Descriptor *descriptor; UUtUns32 index; - + // get a pointer to the first descriptor error = TMrInstance_GetDataPtr_ByNumber(ONcTemplate_Level_Descriptor, i, &descriptor); if (error != UUcError_None) { return; } - + // if the level in the descriptor doesn't exist, move on // to the next descriptor if (!TMrLevel_Exists(descriptor->level_number)) { @@ -117,7 +117,7 @@ OWrLevelList_Initialize( continue; } } -#endif +#endif // add the name of the level to the list index = WMrListBox_AddString(levels, descriptor->level_name); @@ -130,7 +130,7 @@ OWrLevelList_Initialize( const ONtContinue *save_point; for(save_point_index = 0; save_point_index < ONcPersist_NumContinues; save_point_index++) - { + { save_point = ONrPersist_GetContinue(descriptor->level_number, save_point_index); if (save_point != NULL) { @@ -160,11 +160,11 @@ OWrLevelList_GetLevelNumber( { WMtWindow *levels; UUtUns16 level_number; - + // get a pointer to the levels listbox levels = WMrDialog_GetItemByID(inDialog, inItemID); if (levels == NULL) { return (UUtUns16)(-1); } - + // get the level number of the selected item level_number = (UUtUns16)WMrListBox_GetItemData(levels, (UUtUns32)(-1)); return level_number; @@ -178,10 +178,10 @@ OWrLevelList_GetLevelNumber( { UUtUns16 num_descriptors; UUtUns16 level_number; - + // set the level number to the default level_number = (UUtUns16)(-1); - + // get the number of descriptors num_descriptors = (UUtUns16)TMrInstance_GetTagCount(ONcTemplate_Level_Descriptor); if (num_descriptors > 0) @@ -190,18 +190,18 @@ OWrLevelList_GetLevelNumber( WMtWindow *levels; char level_name[ONcMaxLevelName]; UUtUns16 i; - + // get a pointer to the levels listbox levels = WMrDialog_GetItemByID(inDialog, inItemID); if (levels == NULL) return level_number; - + // get the current selection name WMrMessage_Send( levels, LBcMessage_GetText, (UUtUns32)(&level_name), (UUtUns32)(-1)); - + // find the level number for (i = 0; i < num_descriptors; i++) { @@ -222,7 +222,7 @@ OWrLevelList_GetLevelNumber( } } } - + return level_number; } */ @@ -236,7 +236,7 @@ static UUtBool OWiOKToQuit(void) { #if TOOL_VERSION - if (P3rAnyDirty()) { + if (P3rAnyDirty()) { UUtUns32 message; message = WMrDialog_MessageBox(NULL, "Save particles?", @@ -262,9 +262,9 @@ OWiLevelLoad_Init( WMtDialog *inDialog) { WMtListBox *levels; - + OWrLevelList_Initialize(inDialog, OWcLevelLoad_LB_Level); - + levels = WMrDialog_GetItemByID(inDialog, OWcLevelLoad_LB_Level); if (levels) { @@ -277,10 +277,10 @@ void OWrLevelLoad_StartLevel( UUtUns16 inLevel) { - UUtUns16 num_descriptors; + UUtUns16 num_descriptors; UUtUns16 level_number = inLevel & 0x00ff; UUtUns16 save_point = (inLevel & 0xff00) >> 8; - + // get the number of descriptors num_descriptors = (UUtUns16)TMrInstance_GetTagCount(ONcTemplate_Level_Descriptor); if (num_descriptors > 0) @@ -298,13 +298,13 @@ OWrLevelLoad_StartLevel( { ONrLevel_Unload(); } - + // try to load the new level ONrGameState_ClearContinue(); if (save_point != 0) { const ONtContinue *save_point_data = ONrPersist_GetContinue(level_number, save_point); - + UUmAssert(save_point_data != NULL); if (NULL != save_point_data) { @@ -312,7 +312,7 @@ OWrLevelLoad_StartLevel( } } - ONrLevel_Load(OWgLevelNumber, UUcTrue); + ONrLevel_Load(OWgLevelNumber, UUcTrue); // run the game WMrMessage_Post(NULL, OWcMessage_RunGame, 0, 0); @@ -329,15 +329,15 @@ OWiLevelLoad_Callback( { UUtBool handled; UUtUns32 level; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiLevelLoad_Init(inDialog); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -345,12 +345,12 @@ OWiLevelLoad_Callback( level = (UUtUns32)OWrLevelList_GetLevelNumber(inDialog, OWcLevelLoad_LB_Level); WMrDialog_ModalEnd(inDialog, level); break; - + case WMcDialogItem_Cancel: level = (UUtUns32)(-1); WMrDialog_ModalEnd(inDialog, level); break; - + case OWcLevelLoad_LB_Level: if (UUmHighWord(inParam1) == WMcNotify_DoubleClick) { @@ -360,12 +360,12 @@ OWiLevelLoad_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -383,9 +383,9 @@ OWiTest_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -394,26 +394,26 @@ OWiTest_Callback( WMtWindow *listbox; WMtWindow *button; UUtUns32 i; - + WMrTimer_Start(10, 10, inDialog); WMrDialog_RadioButtonCheck( inDialog, OWcTest_RadioButton_1, OWcTest_RadioButton_2, OWcTest_RadioButton_1); - + button = WMrDialog_GetItemByID(inDialog, WMcDialogItem_OK); if (button) { // WMrWindow_SetLocation(button, 150, -3); } - + slider = WMrDialog_GetItemByID(inDialog, OWcTest_Slider); if (slider) { WMrSlider_SetRange(slider, 0, 100); } - + listbox = WMrDialog_GetItemByID(inDialog, OWcTest_ListBox); if (listbox) { @@ -422,20 +422,20 @@ OWiTest_Callback( for (i = 0; i < 30; i++) { char string[255]; - + sprintf(string, "line %d", i); - + WMrMessage_Send(listbox, LBcMessage_AddString, (UUtUns32)string, 0); } } - + listbox = WMrDialog_GetItemByID(inDialog, OWcTest_ListBox2); if (listbox) { UUtUns32 nothing[1]; - + nothing[0] = 0; - + for (i = 0; i < 30; i++) { WMrMessage_Send(listbox, LBcMessage_AddString, (UUtUns32)nothing, 0); @@ -443,25 +443,25 @@ OWiTest_Callback( } } break; - + case WMcMessage_Destroy: WMrTimer_Stop(10, inDialog); break; - + case WMcMessage_Timer: { UUtUns32 current_val; WMtWindow *progressbar; - + progressbar = WMrDialog_GetItemByID(inDialog, OWcTest_ProgressBar); current_val = WMrMessage_Send(progressbar, WMcMessage_GetValue, 0, 0) + 1; if (current_val > 100) { current_val = 0; } - + WMrMessage_Send(progressbar, WMcMessage_SetValue, current_val, 0); } break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -490,7 +490,7 @@ OWiTest_Callback( "This is a test of the Yes No Cancel message box", WMcMessageBoxStyle_Yes_No_Cancel); break; - + case OWcTest_RadioButton_1: case OWcTest_RadioButton_2: if (UUmHighWord(inParam1) == WMcNotify_Click) @@ -502,7 +502,7 @@ OWiTest_Callback( (UUtUns16)UUmLowWord(inParam1)); } break; - + case WMcDialogItem_Cancel: if (UUmHighWord(inParam1) == WMcNotify_Click) { @@ -510,33 +510,33 @@ OWiTest_Callback( WMrWindow_Delete(inDialog); } break; - + case OWcTest_TestChild: { WMtDialog *dialog; - + WMrDialog_Create(OWcDialog_Test, inDialog, OWiTest_Callback, (UUtUns32) -1, &dialog); } break; } break; - + case WMcMessage_DrawItem: { WMtDrawItem *draw_item; UUtUns32 i; IMtPoint2D dest; char string[32]; - + draw_item = (WMtDrawItem*)inParam2; - + /* if (draw_item->state & WMcDrawItemState_Selected) { PStPartSpecUI *partspec_ui; PStPartSpec *draw_this; - + partspec_ui = PSrPartSpecUI_GetActive(); - + if (WMrWindow_GetFocus() == draw_item->window) { draw_this = partspec_ui->hilite; @@ -545,10 +545,10 @@ OWiTest_Callback( { draw_this = partspec_ui->background; } - + dest.x = draw_item->rect.left; dest.y = draw_item->rect.top; - + DCrDraw_PartSpec( draw_item->draw_context, draw_this, @@ -561,7 +561,7 @@ OWiTest_Callback( dest.x = draw_item->rect.left; dest.y = draw_item->rect.top + DCrText_GetAscendingHeight(); - + for (i = 0; i < 3; i++) { sprintf(string, "[%d][%d]", draw_item->item_id, i); @@ -569,15 +569,15 @@ OWiTest_Callback( DCrDraw_String(draw_item->draw_context, string, &draw_item->rect, &dest); dest.x += 40; } - + } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -592,14 +592,14 @@ OWiOniWindow_Create( WMtWindow *inWindow) { WMtWindow *menubar; - + // load the menu bar menubar = WMrMenuBar_Create(inWindow, "menubar_oniwindow"); if (menubar == NULL) { return UUcError_Generic; } - + WMrWindow_SetLong(inWindow, 0, (UUtUns32)menubar); return UUcError_None; @@ -613,10 +613,10 @@ OWiOniWindow_HandleMenuInit( UUtUns32 inParam2) { WMtMenu *menu; - + menu = (WMtMenu*)inParam1; if (menu == NULL) { return; } - + switch (UUmHighWord(inParam2)) { case OWcMenu_Game: @@ -625,19 +625,19 @@ OWiOniWindow_HandleMenuInit( case OWcMenu_Settings: break; - + #if TOOL_VERSION - + case OWcMenu_Objects: { UUtUns32 num_objects; - + num_objects = OBJrSelectedObjects_GetNumSelected(); WMrMenu_EnableItem(menu, OWcMenu_Obj_New, !OWrObjNew_IsVisible()); WMrMenu_EnableItem(menu, OWcMenu_Obj_Duplicate, (num_objects >= 1)); WMrMenu_EnableItem(menu, OWcMenu_Obj_Save, UUcTrue); - + if (num_objects == 1) { WMrMenu_EnableItem(menu, OWcMenu_Obj_Delete, UUcTrue); @@ -665,7 +665,7 @@ OWiOniWindow_HandleMenuInit( OWrLightProp_HasLight()); } break; - + case OWcMenu_Particle: WMrMenu_EnableItem(menu, OWcMenu_Particle_Save, P3rAnyDirty()); WMrMenu_EnableItem(menu, OWcMenu_Particle_Discard, P3rAnyDirty()); @@ -690,12 +690,12 @@ OWiOniWindow_HandleMenuCommand( WMtMenu *menu; UUtUns16 menu_item_id; UUtUns32 message; - + menu = (WMtMenu*)inParam2; UUmAssert(menu); - + menu_item_id = UUmLowWord(inParam1); - + switch (WMrWindow_GetID(menu)) { // ------------------------------ @@ -708,7 +708,7 @@ OWiOniWindow_HandleMenuCommand( OWcDialog_LevelLoad, NULL, OWiLevelLoad_Callback, - (UUtUns32) -1, + (UUtUns32) -1, &message); if (error == UUcError_None) { @@ -718,21 +718,21 @@ OWiOniWindow_HandleMenuCommand( } } break; - + case OWcMenu_Game_Resume: if (OWgRunStartup == UUcFalse) { OWrOniWindow_Toggle(); } break; - + case OWcMenu_Game_Quit: WMrMessage_Post(NULL, WMcMessage_Quit, 0, 0); WMrWindow_SetVisible(inWindow, UUcFalse); break; } break; - + #if TOOL_VERSION // ------------------------------ @@ -748,25 +748,25 @@ OWiOniWindow_HandleMenuCommand( (UUtUns32) -1, &message); break; - + case OWcMenu_Settings_Options: ONrOutGameUI_Options_Display(); break; - + case OWcMenu_Settings_MainMenu: ONrOutGameUI_MainMenu_Display(); break; - + case OWcMenu_Settings_LoadGame: ONrOutGameUI_LoadGame_Display(); break; - + case OWcMenu_Settings_QuitGame: ONrOutGameUI_QuitYesNo_Display(); break; } break; - + // ------------------------------ case OWcMenu_Objects: switch (menu_item_id) @@ -774,24 +774,24 @@ OWiOniWindow_HandleMenuCommand( case OWcMenu_Obj_New: OWrObjNew_Display(); break; - + case OWcMenu_Obj_Delete: OBJrSelectedObjects_Delete(); break; - + case OWcMenu_Obj_Duplicate: OWiDuplicateSelectedObjects(); break; - + case OWcMenu_Obj_Save: OBJrSaveObjects(OBJcType_None); WMrDialog_MessageBox(NULL, "Save Confirmation", "The Objects were saved.", WMcMessageBoxStyle_OK); break; - + case OWcMenu_Obj_Position: OWrEOPos_Display(); break; - + case OWcMenu_Obj_Properties: OWrProp_Display(NULL); break; @@ -807,11 +807,11 @@ OWiOniWindow_HandleMenuCommand( WMrDialog_MessageBox(NULL, "Unable to Save", "The .ENV file was not written.", WMcMessageBoxStyle_OK); } break; - + case OWcMenu_Obj_LightProperties: OWrLightProp_Display(); break; - + case OWcMenu_Obj_ExportFlag: error = OBJrFlagTXTFile_Write(); if (error == UUcError_None) @@ -823,13 +823,13 @@ OWiOniWindow_HandleMenuCommand( WMrDialog_MessageBox(NULL, "Unable to Save", "The LX_Flag.TXT file was not written.", WMcMessageBoxStyle_OK); } break; - + default: OWrHandleObjectVisibilityMenu(menu, menu_item_id); break; } break; - + // ------------------------------ case OWcMenu_Particle: switch (menu_item_id) @@ -852,8 +852,8 @@ OWiOniWindow_HandleMenuCommand( break; } break; - - + + // ------------------------------ case OWcMenu_Sound: switch (menu_item_id) @@ -861,28 +861,28 @@ OWiOniWindow_HandleMenuCommand( case OWcMenu_Sound_Groups: OWrSM_Display(OWcSMType_Group); break; - + case OWcMenu_Ambient_Sounds: OWrSM_Display(OWcSMType_Ambient); break; - + case OWcMenu_Impulse_Sounds: OWrSM_Display(OWcSMType_Impulse); break; - + case OWcMenu_Animations: OWrSoundToAnim_Display(); break; - + case OWcMenu_ExportSoundInfo: SSrTextFile_Write(); break; - + case OWcMenu_CreateDialogue: OWrCreateDialogue_Display(); break; - + case OWcMenu_CreateImpulse: OWrCreateImpulse_Display(); break; @@ -902,7 +902,7 @@ OWiOniWindow_HandleMenuCommand( case OWcMenu_WriteNeutralAiffList: OSrNeutralInteractions_WriteAiffList(); break; - + case OWcMenu_FixMinMaxDist: OWrMinMax_Fixer(); break; @@ -910,7 +910,7 @@ OWiOniWindow_HandleMenuCommand( case OWcMenu_FindBrokenSound: OSrListBrokenSounds(); break; - + case OWcMenu_FixSpeechAmbients: OWrSpeech_Fixer(); break; @@ -921,7 +921,7 @@ OWiOniWindow_HandleMenuCommand( case OWcMenu_AI: OWrAI_Menu_HandleMenuCommand(menu, menu_item_id); break; - + // ------------------------------ case OWcMenu_Misc: switch (menu_item_id) @@ -929,11 +929,11 @@ OWiOniWindow_HandleMenuCommand( case OWcMenu_Impact_Effect: OWrImpactEffect_Display(); break; - + case OWcMenu_Texture_Materials: OWrTextureToMaterial_Display(); break; - + case OWcMenu_Impact_Effect_Write: ONrImpactEffects_WriteTextFile(); break; @@ -963,15 +963,15 @@ OWiOniWindow_HandleResolutionChanged( UUtInt16 inHeight) { WMtWindow *menubar; - + WMrWindow_SetSize(inWindow, inWidth, inHeight); - + // update the width of the main menu menubar = (WMtWindow*)WMrWindow_GetLong(inWindow, 0); if (menubar != NULL) { UUtInt16 menubar_height; - + WMrWindow_GetSize(menubar, NULL, &menubar_height); WMrWindow_SetSize(menubar, inWidth, menubar_height); } @@ -990,22 +990,22 @@ OWiIsLockedInSelection( UUtUns32 i; UUtUns32 num_selected; UUtUns32 num_locked; - + num_locked = 0; - + num_selected = OBJrSelectedObjects_GetNumSelected(); for (i = 0; i < num_selected; i++) { OBJtObject *object; - + object = OBJrSelectedObjects_GetSelectedObject(i); - + if (OBJrObject_IsLocked(object)) { num_locked++; } } - + if (num_locked == 0) { return 0; } if (num_locked == num_selected) { return 2; } - + return 1; } @@ -1026,29 +1026,29 @@ OWiOniWindow_Paint( UUtInt16 part_bottom; UUtRect bounds; UUtUns32 mode; - + // don't draw the status bar unless OBJgShowStatus is true if (OBJgShowStatus == UUcFalse) { return; } - + // get a pointer to the partspec ui partspec_ui = PSrPartSpecUI_GetActive(); if (partspec_ui == NULL) { return; } - + draw_context = DCrDraw_Begin(inWindow); - + // get the width WMrWindow_GetSize(inWindow, &window_width, &window_height); - + PSrPartSpec_GetSize(partspec_ui->background, PScPart_LeftTop, &part_left, &part_top); PSrPartSpec_GetSize(partspec_ui->background, PScPart_RightBottom, &part_right, &part_bottom); - + // calculate the height height = DCrText_GetLineHeight() + part_top + part_bottom + 2; - + // set the dest dest.x = 0; dest.y = window_height - height; - + // draw the background DCrDraw_PartSpec( draw_context, @@ -1058,14 +1058,14 @@ OWiOniWindow_Paint( window_width, height, M3cMaxAlpha); - + DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrText_SetStyle(TScStyle_Plain); // set the starting position for the status dest.x = 0; dest.y += part_top + DCrText_GetAscendingHeight(); - + // set the bounds bounds.left = 0; bounds.top = window_height - height; @@ -1076,7 +1076,7 @@ OWiOniWindow_Paint( dest.x = window_width - (480 - 395); DCrText_SetShade(IMcShade_Black); DCrText_DrawText("Selection:", &bounds, &dest); - + dest.x = window_width - (480 - 440); if (OBJrSelectedObjects_Lock_Get() == UUcTrue) { @@ -1087,7 +1087,7 @@ OWiOniWindow_Paint( DCrText_SetShade(IMcShade_Gray75); DCrText_DrawText("Locked", &bounds, &dest); } - + // draw the rotation axis dest.x = window_width - (480 - 335); DCrText_SetShade(IMcShade_Black); @@ -1100,25 +1100,25 @@ OWiOniWindow_Paint( case OBJcRotateMode_XY: DCrText_DrawText("Z", &bounds, &dest); break; - + case OBJcRotateMode_XZ: DCrText_DrawText("Y", &bounds, &dest); break; - + case OBJcRotateMode_YZ: DCrText_DrawText("X", &bounds, &dest); break; - + case OBJcRotateMode_XYZ: DCrText_DrawText("All", &bounds, &dest); break; } - + // draw the move axis dest.x = window_width - (480 - 265); DCrText_SetShade(IMcShade_Black); DCrText_DrawText("Move:", &bounds, &dest); - + dest.x = window_width - (480 - 295); mode = OBJrMoveMode_Get(); switch (mode) @@ -1126,15 +1126,15 @@ OWiOniWindow_Paint( case OBJcMoveMode_LR: DCrText_DrawText("LR", &bounds, &dest); break; - + case OBJcMoveMode_UD: DCrText_DrawText("UD", &bounds, &dest); break; - + case OBJcMoveMode_FB: DCrText_DrawText("FB", &bounds, &dest); break; - + case (OBJcMoveMode_LR | OBJcMoveMode_FB): DCrText_DrawText("LR FB", &bounds, &dest); break; @@ -1151,14 +1151,14 @@ OWiOniWindow_Paint( DCrText_DrawText("WALL", &bounds, &dest); break; } - + // draw the object locked status if (OBJrSelectedObjects_GetNumSelected() > 0) { dest.x = 5; DCrText_SetShade(IMcShade_Black); DCrText_DrawText("Object:", &bounds, &dest); - + dest.x = 40; switch (OWiIsLockedInSelection()) { @@ -1166,19 +1166,19 @@ OWiOniWindow_Paint( DCrText_SetShade(IMcShade_Gray25); DCrText_DrawText("Unlocked", &bounds, &dest); break; - + case 1: DCrText_SetShade(IMcShade_Black); DCrText_DrawText("Some Locked", &bounds, &dest); break; - + case 2: DCrText_SetShade(IMcShade_Black); DCrText_DrawText("All Locked", &bounds, &dest); break; } } - + DCrDraw_End(draw_context, inWindow); } @@ -1191,7 +1191,7 @@ OWiOniWindow_Callback( UUtUns32 inParam2) { UUtError error; - + switch (inMessage) { case WMcMessage_Create: @@ -1201,15 +1201,15 @@ OWiOniWindow_Callback( return WMcResult_Error; } return WMcResult_Handled; - + case WMcMessage_MenuInit: OWiOniWindow_HandleMenuInit(inWindow, inParam1, inParam2); break; - + case WMcMessage_MenuCommand: OWiOniWindow_HandleMenuCommand(inWindow, inParam1, inParam2); return WMcResult_Handled; - + case WMcMessage_KeyDown: if ((UUmLowWord(inParam1) == LIcKeyCode_Escape) || (UUmLowWord(inParam1) == LIcKeyCode_Star)) @@ -1221,15 +1221,15 @@ OWiOniWindow_Callback( } } break; - + case WMcMessage_Activate: { WMtWindow *menubar; // WMtWindow *menu; - + menubar = WMrDialog_GetItemByID(inWindow, OWcOniWindow_MenuBar); if (menubar == NULL) { break; } - + // CB: the object and particle menus used to be disabled while on level 0... // however sometimes we want to do some editing there so I'm re-enabling them; 13 July 2000 /* menu = WMrMenuBar_GetMenu(menubar, OWcMenu_Objects); @@ -1237,7 +1237,7 @@ OWiOniWindow_Callback( { WMrWindow_SetEnabled(menu, (ONrLevel_GetCurrentLevel() != 0)); } - + menu = WMrMenuBar_GetMenu(menubar, OWcMenu_Particle); if (menu) { @@ -1245,11 +1245,11 @@ OWiOniWindow_Callback( }*/ } break; - + case WMcMessage_Paint: OWiOniWindow_Paint(inWindow); break; - + case WMcMessage_ResolutionChanged: OWiOniWindow_HandleResolutionChanged( inWindow, @@ -1257,7 +1257,7 @@ OWiOniWindow_Callback( UUmLowWord(inParam1)); return WMcResult_Handled; } - + return WMrWindow_DefaultCallback(inWindow, inMessage, inParam1, inParam2); } @@ -1268,10 +1268,10 @@ OWrOniWindow_Startup( { UUtError error; void *splash_screen; - + // set the input to normal LIrMode_Set(LIcMode_Normal); - + // set the desktop background error = TMrInstance_GetDataPtr( @@ -1286,14 +1286,14 @@ OWrOniWindow_Startup( { WMrSetDesktopBackground(PSrPartSpec_LoadByType(PScPartSpecType_BackgroundColor_Blue)); } - + // activate the window manager's update WMrActivate(); - + // display the oni window LIrMode_Set(LIcMode_Normal); WMrWindow_SetVisible(OWgOniWindow, UUcTrue); - + OWgRunStartup = UUcTrue; while ((OWgRunStartup) && (ONgTerminateGame == UUcFalse)) { @@ -1304,7 +1304,7 @@ OWrOniWindow_Startup( WMrUpdate(); OWrUpdate(); } - + // set the desktop background to none WMrSetDesktopBackground(PSrPartSpec_LoadByType(PScPartSpecType_BackgroundColor_None)); @@ -1317,7 +1317,7 @@ OWrOniWindow_Toggle( void) { if (OWgOniWindow == NULL) return; - + if (WMrWindow_GetVisible(OWgOniWindow) == UUcFalse) { WMrActivate(); @@ -1340,7 +1340,7 @@ OWrOniWindow_Visible( void) { if (OWgOniWindow == NULL) return UUcFalse; - + return WMrWindow_GetVisible(OWgOniWindow); } @@ -1373,7 +1373,7 @@ OWiDuplicateSelectedObjects( UUtUns32 i; OBJtObject **sol_mem_array; OBJtObject **nol_mem_array; - + // build an vector by which the position of the selected objects will // be offset so that they aren't exactly on top of the old ones /* camera_facing = CArGetFacing(); @@ -1382,23 +1382,23 @@ OWiDuplicateSelectedObjects( MUrNormalize(&offset_vector); MUmVector_Scale(offset_vector, 5.0f); offset_vector.y = 0.0f;*/ - + // get the number of objects that are about to be duplicated num_objects = OBJrSelectedObjects_GetNumSelected(); - + // create the memory arrays sol_mem_array = (OBJtObject**)UUrMemory_Block_New(sizeof(OBJtObject*) * num_objects); if (sol_mem_array == NULL) { goto cleanup; } - + nol_mem_array = (OBJtObject**)UUrMemory_Block_New(sizeof(OBJtObject*) * num_objects); if (nol_mem_array == NULL) { goto cleanup; } - + // put the selected object list into a new array for (i = 0; i < num_objects; i++) { sol_mem_array[i] = OBJrSelectedObjects_GetSelectedObject(i); } - + // duplicate all of the selected objects for (i = 0; i < num_objects; i++) { @@ -1407,44 +1407,44 @@ OWiDuplicateSelectedObjects( M3tPoint3D position; M3tPoint3D rotation; OBJtObjectType object_type; - + object = sol_mem_array[i]; object_type = OBJrObject_GetType(object); OBJrObject_GetPosition(object, &position, &rotation); OBJrObject_GetObjectSpecificData(object, &osd_all); - + // flags' id numbers must be unique if (object_type == OBJcType_Flag) { osd_all.osd.flag_osd.id_number = OBJrFlag_GetUniqueID(); } - + // offset the position in the direction the camera is facing // MUmVector_Increment(position, offset_vector); - + // create a new object with this data OBJrObject_New( OBJrObject_GetType(object), &position, &rotation, &osd_all); - + // get the newly created object nol_mem_array[i] = OBJrSelectedObjects_GetSelectedObject(0); } - + // select all of the newly created objects OBJrSelectedObjects_UnselectAll(); for (i = 0; i < num_objects; i++) { OBJrSelectedObjects_Select(nol_mem_array[i], UUcTrue); } - + cleanup: if (nol_mem_array) { UUrMemory_Block_Delete(nol_mem_array); } - + if (sol_mem_array) { UUrMemory_Block_Delete(sol_mem_array); @@ -1461,13 +1461,13 @@ OWiEnumCallback( (WMrWindow_GetVisible(inWindow) == UUcTrue)) { UUtBool *window_open; - + window_open = (UUtBool*)inUserData; *window_open = UUcTrue; - + return UUcFalse; } - + return UUcTrue; } @@ -1481,13 +1481,13 @@ OWiEnumCallback_FindFirstWindow( (WMrWindow_GetVisible(inWindow) == UUcTrue)) { WMtWindow **windowptr; - + windowptr = (WMtWindow **)inUserData; *windowptr = inWindow; - + return UUcFalse; } - + return UUcTrue; } @@ -1544,12 +1544,12 @@ OWiTranslateKeyDown( WMtEvent *inEvent) { UUtBool window_open; - + // check for windows being open window_open = UUcFalse; WMrEnumWindows(OWiEnumCallback, (UUtUns32)&window_open); if (window_open) { return; } - + inEvent->window = NULL; } @@ -1559,71 +1559,71 @@ OWiHandleCameraMove( UUtUns32 inParam1) { LItAction action; - + if (ONrLevel_GetCurrentLevel() == 0) { return; } - + UUrMemory_Clear(&action, sizeof(LItAction)); - + switch (UUmLowWord(inParam1)) { case LIcKeyCode_8: action.analogValues[LIc_ManCam_Move_FB] = 1.0f; break; - + case LIcKeyCode_5: action.analogValues[LIc_ManCam_Move_FB] = -1.0f; break; - + case LIcKeyCode_4: action.analogValues[LIc_ManCam_Pan_LR] = -1.0f; break; - + case LIcKeyCode_6: action.analogValues[LIc_ManCam_Pan_LR] = 1.0f; break; - + case LIcKeyCode_1: action.analogValues[LIc_ManCam_Move_LR] = 1.0f; break; - + case LIcKeyCode_3: action.analogValues[LIc_ManCam_Move_LR] = -1.0f; break; - + case LIcKeyCode_Minus: action.analogValues[LIc_ManCam_Move_UD] = -1.0f; break; - + case LIcKeyCode_Equals: case LIcKeyCode_Plus: action.analogValues[LIc_ManCam_Move_UD] = 1.0f; break; - + case LIcKeyCode_W: action.analogValues[LIc_ManCam_Move_FB] = 1.0f; break; - + case LIcKeyCode_S: action.analogValues[LIc_ManCam_Move_FB] = -1.0f; break; - + case LIcKeyCode_A: action.analogValues[LIc_ManCam_Move_LR] = 1.0f; break; - + case LIcKeyCode_D: action.analogValues[LIc_ManCam_Move_LR] = -1.0f; break; - + case LIcKeyCode_UpArrow: action.analogValues[LIc_ManCam_Pan_UD] = 1.0f; break; - + case LIcKeyCode_DownArrow: action.analogValues[LIc_ManCam_Pan_UD] = -1.0f; break; } - + CArUpdate(0, 1, &action); } @@ -1633,14 +1633,14 @@ OWiHandleSelectedObjects_SetLock( UUtBool inLock) { UUtUns32 i; - + for (i = 0; i < OBJrSelectedObjects_GetNumSelected(); i++) { OBJtObject *object; - + object = OBJrSelectedObjects_GetSelectedObject(i); if (object == NULL) { continue; } - + OBJrObject_SetLocked(object, inLock); } } @@ -1653,7 +1653,7 @@ OWiHandleObjectKeys( UUtError error; if (ONrLevel_GetCurrentLevel() == 0) { return; } - + switch (UUmLowWord(inParam1)) { case LIcKeyCode_F1: @@ -1663,7 +1663,7 @@ OWiHandleObjectKeys( OWrProp_Display(NULL); } break; - + case LIcKeyCode_F2: case LIcKeyCode_Slash: OBJrObjectType_SetVisible(OBJcType_Flag, UUcTrue); @@ -1672,7 +1672,7 @@ OWiHandleObjectKeys( OWrProp_Display(NULL); } break; - + case LIcKeyCode_F3: OBJrObjectType_SetVisible(OBJcType_Trigger, UUcTrue); error = OWrTools_CreateObject(OBJcType_Trigger, NULL); @@ -1680,7 +1680,7 @@ OWiHandleObjectKeys( OWrProp_Display(NULL); } break; - + case LIcKeyCode_F4: OBJrObjectType_SetVisible(OBJcType_Turret, UUcTrue); error = OWrTools_CreateObject(OBJcType_Turret, NULL); @@ -1688,26 +1688,26 @@ OWiHandleObjectKeys( OWrProp_Display(NULL); } break; - + case LIcKeyCode_F5: OBJrDoor_JumpToNextDoor(); break; - + case LIcKeyCode_F6: OBJrDoor_JumpToPrevDoor(); break; - + case LIcKeyCode_F7: OWrProp_Display(NULL); break; - + case LIcKeyCode_F8: break; - + case LIcKeyCode_F9: OWrEOPos_Display(); break; - + case LIcKeyCode_F10: // focus the manual camera on the selected object if (OBJrSelectedObjects_GetNumSelected() == 1) @@ -1715,16 +1715,16 @@ OWiHandleObjectKeys( OBJtObject *object; M3tPoint3D position; LItAction action; - + object = OBJrSelectedObjects_GetSelectedObject(0); OBJrObject_GetPosition(object, &position, NULL); CArManual_LookAt(&position, 50.0f); - + UUrMemory_Clear(&action, sizeof(LItAction)); CArUpdate(0, 1, &action); } break; - + case LIcKeyCode_F11: OWiDuplicateSelectedObjects(); break; @@ -1738,14 +1738,14 @@ OWiHandleKeyDown( UUtUns32 inParam2) { UUtUns32 mode; - + switch (UUmLowWord(inParam1)) { case LIcKeyCode_BackSpace: case LIcKeyCode_Delete: OBJrSelectedObjects_Delete(); break; - + case LIcKeyCode_Escape: case LIcKeyCode_Star: case LIcKeyCode_Multiply: @@ -1754,7 +1754,7 @@ OWiHandleKeyDown( OWrOniWindow_Toggle(); } break; - + case LIcKeyCode_8: case LIcKeyCode_5: case LIcKeyCode_4: @@ -1772,7 +1772,7 @@ OWiHandleKeyDown( case LIcKeyCode_DownArrow: OWiHandleCameraMove(inParam1); break; - + case LIcKeyCode_Slash: case LIcKeyCode_7: case LIcKeyCode_F1: @@ -1788,14 +1788,14 @@ OWiHandleKeyDown( case LIcKeyCode_F11: OWiHandleObjectKeys(inParam1); break; - + case LIcKeyCode_Space: if (OBJrSelectedObjects_GetNumSelected() != 0) { OBJrSelectedObjects_Lock_Set(!OBJrSelectedObjects_Lock_Get()); } break; - + case LIcKeyCode_Tab: mode = OBJrRotateMode_Get(); if (mode == OBJcRotateMode_XYZ) @@ -1815,7 +1815,7 @@ OWiHandleKeyDown( OBJrRotateMode_Set(OBJcRotateMode_XYZ); } break; - + case LIcKeyCode_Q: mode = OBJrMoveMode_Get(); if (mode == OBJcMoveMode_LR) @@ -1848,11 +1848,11 @@ OWiHandleKeyDown( OBJrMoveMode_Set(OBJcMoveMode_Wall | OBJcMoveMode_LR); } break; - + case LIcKeyCode_9: OWiHandleSelectedObjects_SetLock(UUcTrue); break; - + case LIcKeyCode_0: OWiHandleSelectedObjects_SetLock(UUcFalse); break; @@ -1868,22 +1868,22 @@ OWiHandleMouseMoveEvent( { OBJtObject *object; UUtUns32 i; - + // don't process clicks outside of a window if (OWrEOPos_IsVisible() || OWrProp_IsVisible() || OWrObjNew_IsVisible()) { return; } - + switch (inMessage) { case WMcMessage_MouseMove: - + if ((OWiIsLockedInSelection() == UUcFalse) && (OWgMoveDelta < UUrMachineTime_Sixtieths())) { UUtUns32 num_objects; UUtUns32 move_mode; - + move_mode = OBJrMoveMode_Get(); - + object = OBJrSelectedObjects_GetSelectedObject(0); if ((object != NULL) && (OBJrObject_GetType(object) == OBJcType_Particle) && ((OBJtOSD_Particle *) object->object_data)->is_decal) { @@ -1913,20 +1913,20 @@ OWiHandleMouseMoveEvent( for (i = 0; i < num_objects; i++) { object = OBJrSelectedObjects_GetSelectedObject(i); - + OBJrObject_MouseMove( object, &OWgPreviousMousePos, - inMousePos); + inMousePos); } - + OBJrMoveMode_Set(move_mode); } break; - + case WMcMessage_LMouseDown: OWgMoveDelta = UUrMachineTime_Sixtieths() + OWcMoveDelta; - + object = OBJrGetObjectUnderPoint(inMousePos); if (object == NULL) { @@ -1973,11 +1973,11 @@ OWiHandleMouseMoveEvent( } } break; - + case WMcMessage_LMouseDblClck: OWrProp_Display(NULL); break; - + case WMcMessage_LMouseUp: break; } @@ -1993,7 +1993,7 @@ OWiHandleMouseRotateEvent( OBJtObject *object; OBJtObject *selected; UUtUns32 num_selected; - + // get the currently selected object if there is only one num_selected = OBJrSelectedObjects_GetNumSelected(); if (num_selected == 1) @@ -2004,7 +2004,7 @@ OWiHandleMouseRotateEvent( { selected = NULL; } - + switch (inMessage) { case WMcMessage_MouseMove: @@ -2012,20 +2012,20 @@ OWiHandleMouseRotateEvent( if (selected != NULL) { IMtPoint2D delta; - + // calculate the mouse movement delta delta.x = inMousePos->x - OWgPreviousMousePos.x; delta.y = inMousePos->y - OWgPreviousMousePos.y; - + // rotate the objects OBJrObject_MouseRotate_Update(selected, &delta); } break; - + case WMcMessage_RMouseDown: // get the object under the point object = OBJrGetObjectUnderPoint(inMousePos); - + if (selected != NULL) { if (object == selected) @@ -2059,12 +2059,12 @@ OWiHandleMouseRotateEvent( OBJrSelectedObjects_Select(object, UUcFalse); } break; - + case WMcMessage_RMouseDblClck: OBJrObject_MouseRotate_End(); OWrEOPos_Display(); break; - + case WMcMessage_RMouseUp: OBJrObject_MouseRotate_End(); break; @@ -2079,11 +2079,11 @@ OWiHandleMouseEvent( UUtUns32 inParam2) { IMtPoint2D global_mouse; - + // get the global mouse location global_mouse.x = UUmHighWord(inParam1); global_mouse.y = UUmLowWord(inParam1); - + switch(inMessage) { case WMcMessage_MouseMove: @@ -2101,14 +2101,14 @@ OWiHandleMouseEvent( OWgPreviousMousePos = global_mouse; OBJgMouseMoved = UUcTrue; break; - + case WMcMessage_LMouseDown: case WMcMessage_LMouseUp: case WMcMessage_LMouseDblClck: OWiHandleMouseMoveEvent(inMessage, &global_mouse, inParam2); OBJgMouseMoved = UUcFalse; break; - + case WMcMessage_RMouseDown: case WMcMessage_RMouseDblClck: case WMcMessage_RMouseUp: @@ -2133,13 +2133,13 @@ OWrInitialize( WMtWindow *desktop; UUtInt16 width; UUtInt16 height; - + // ------------------------------ // startup the window manager // ------------------------------ error = WMrStartup(); UUmError_ReturnOnError(error); - + // ------------------------------ // register the windows // ------------------------------ @@ -2148,16 +2148,16 @@ OWrInitialize( window_class.type = OWcWindowType_Oni; window_class.callback = OWiOniWindow_Callback; window_class.private_data_size = 4; - + error = WMrWindowClass_Register(&window_class); UUmError_ReturnOnError(error); - + // get the size of the desktop window desktop = WMrGetDesktop(); if (desktop == NULL) { return UUcError_Generic; } - + WMrWindow_GetSize(desktop, &width, &height); - + // create the oni window OWgOniWindow = WMrWindow_New( @@ -2176,7 +2176,7 @@ OWrInitialize( { return UUcError_Generic; } - + // ------------------------------ OBJgShowStatus = UUcTrue; @@ -2188,13 +2188,13 @@ OWrInitialize( &OBJgShowStatus); UUmError_ReturnOnError(error); #endif - + // ------------------------------ // initialize the tools // ------------------------------ error = OWrTools_Initialize(); UUmError_ReturnOnError(error); - + // ------------------------------ // Initialize the settings dialogs // ------------------------------ @@ -2223,16 +2223,16 @@ OWrInitialize( OWgKeyboardCommands.commands[1] = LIcKeyCode_W; OWgKeyboardCommands.commands[2] = LIcKeyCode_K; OWgKeyboardCommands.commands[3] = LIcKeyCode_J; - + // ------------------------------ OWgPreviousMousePos.x = 0; OWgPreviousMousePos.y = 0; - + // ------------------------------ OBJrMoveMode_Set(OBJcMoveMode_LR | OBJcMoveMode_FB); OBJrRotateMode_Set(OBJcRotateMode_XYZ); OBJrSelectedObjects_Lock_Set(UUcFalse); - + return UUcError_None; } @@ -2243,7 +2243,7 @@ OWrInitialize( { UUtBool success= UUcFalse; WMtWindow *desktop= WMrGetDesktop(); - + if (OWgOniWindow) WMrWindow_SetSize(OWgOniWindow, new_width, new_height); if (desktop) WMrWindow_SetSize(desktop, new_width, new_height); success= (ONrMotoko_SetupDrawing(&ONgPlatformData) == UUcError_None) ? UUcTrue : UUcFalse; @@ -2282,24 +2282,24 @@ OWrLevelEnd( void) { } - + // ---------------------------------------------------------------------- void OWrUpdate( void) { WMtEvent event; - + while (WMrMessage_Get(&event)) { UUtUns32 handled; - + WMrMessage_TranslateKeyCommand(&event, &OWgKeyboardCommands, NULL); if (event.message == WMcMessage_KeyDown) { OWiTranslateKeyDown(&event); } - + handled = WMrMessage_Dispatch(&event); if (handled == WMcResult_NoWindow) { @@ -2308,13 +2308,13 @@ OWrUpdate( case WMcMessage_KeyCommand: OWiHandleKeyCommands(event.param1); break; - + case WMcMessage_Quit: if (OWiOKToQuit()) { ONgTerminateGame = UUcTrue; } break; - + case WMcMessage_MouseMove: case WMcMessage_LMouseDown: case WMcMessage_LMouseUp: @@ -2324,11 +2324,11 @@ OWrUpdate( case WMcMessage_RMouseDblClck: OWiHandleMouseEvent(event.message, event.param1, event.param2); break; - + case WMcMessage_KeyDown: OWiHandleKeyDown(event.param1, event.param2); break; - + // Oni defined messages case OWcMessage_RunGame: OWrOniWindow_Toggle(); @@ -2384,7 +2384,7 @@ OWrGetMask_Callback( WMrWindow_SetTitle(scratch, *current_string, WMcMaxTitleLength); WMrCheckBox_SetCheck(scratch, checkbox_set); - } + } if (valid) { count++; @@ -2395,24 +2395,24 @@ OWrGetMask_Callback( width = 300; height = (count * 25) + 35; WMrWindow_SetPosition(inDialog, NULL, 0, 0, width, height, WMcPosChangeFlag_NoMove | WMcPosChangeFlag_NoZOrder); - + WMrWindow_GetClientRect(inDialog, &client_rect); - WMrWindow_SetPosition(inDialog, NULL, 0, 0, - width + (width - client_rect.right + client_rect.left), + WMrWindow_SetPosition(inDialog, NULL, 0, 0, + width + (width - client_rect.right + client_rect.left), height + (height - client_rect.bottom + client_rect.top), WMcPosChangeFlag_NoMove | WMcPosChangeFlag_NoZOrder); scratch = WMrDialog_GetItemByID(inDialog, 1); WMrWindow_SetPosition(scratch, NULL, width - 80, height - 30, 0, 0, WMcPosChangeFlag_NoSize | WMcPosChangeFlag_NoZOrder); - + scratch = WMrDialog_GetItemByID(inDialog, 2); - WMrWindow_SetPosition(scratch, NULL, width - 160, height - 30, 0, 0, WMcPosChangeFlag_NoSize | WMcPosChangeFlag_NoZOrder); + WMrWindow_SetPosition(scratch, NULL, width - 160, height - 30, 0, 0, WMcPosChangeFlag_NoSize | WMcPosChangeFlag_NoZOrder); } break; case WMcMessage_Command: - switch(UUmLowWord(inParam1)) + switch(UUmLowWord(inParam1)) { case WMcDialogItem_OK: WMrDialog_ModalEnd(inDialog, 0); @@ -2461,7 +2461,7 @@ UUtUns32 OWrGetMask(UUtUns32 inMask, const char **inFlagList) internals.inMask = inMask; internals.inFlagList = inFlagList; internals.outMask = inMask; - + WMrDialog_ModalBegin(OWcDialog_GetMask, NULL, OWrGetMask_Callback, (UUtUns32) &internals, NULL); return internals.outMask; @@ -2483,7 +2483,7 @@ void OWrMaskToString(UUtUns32 inMask, const char **inFlagList, UUtUns32 inString UUtUns32 current_amount_to_copy = UUmMin(current_string_length, remaining_string_length); UUrMemory_MoveFast(*current_flag, current_target_string, current_amount_to_copy); - + remaining_string_length -= current_amount_to_copy; current_target_string += current_amount_to_copy; @@ -2505,7 +2505,7 @@ typedef struct visibility_match OBJtObjectType object_type; } visibility_match; -const visibility_match visibility_match_list[] = +const visibility_match visibility_match_list[] = { { OWcMenu_Obj_ShowCharacters, OBJcType_Character }, { OWcMenu_Obj_ShowPatrols, OBJcType_PatrolPath }, @@ -2541,7 +2541,7 @@ UUtBool OWrHandleObjectVisibilityMenu(WMtMenu *menu, UUtUns16 menu_item_id) { UUtBool new_visibility = !(flags & WMcMenuItemFlag_Checked); - + OBJrObjectType_SetVisible(cur_match->object_type, new_visibility); } @@ -2564,4 +2564,4 @@ void OWrBuildVisibilityMenu(WMtMenu *menu) return; } -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_Windows.h b/OniProj/OniGameSource/Oni_Windows.h index 0233f0c..91219bc 100644 --- a/OniProj/OniGameSource/Oni_Windows.h +++ b/OniProj/OniGameSource/Oni_Windows.h @@ -22,9 +22,9 @@ enum { OWcMessages = WMcMessage_User, - + OWcMessage_RunGame, - + OWcMessage_MPHost, OWcMessage_MPJoin, @@ -89,7 +89,7 @@ enum // Performance Menu // ------------------------------ enum -{ +{ OWcMenu_Perf_Overall = 100, OWcMenu_Perf_GSD = 101, OWcMenu_Perf_GSU = 102, @@ -100,7 +100,7 @@ enum // Test Menu // ------------------------------ enum -{ +{ OWcMenu_Test_TestDialog = 100 }; @@ -131,14 +131,14 @@ enum OWcMenu_Obj_ShowWeapons = 119, OWcMenu_Obj_ShowTriggerVolumes = 120, OWcMenu_Obj_ShowSounds = 121 - + }; // ------------------------------ // Particle Menu // ------------------------------ enum -{ +{ OWcMenu_Particle_Edit = 100, OWcMenu_Particle_Save = 200, OWcMenu_Particle_Discard = 300 @@ -199,19 +199,19 @@ enum OWcDialog_StringList = 102, OWcDialog_GetMask = 103, - + OWcDialog_MPHost = 128, OWcDialog_MPJoin = 129, OWcDialog_LevelLoadProgress = 130, OWcDialog_SetupPlayer = 132, OWcDialog_LevelLoad = 133, - + /* see Oni_OutGameUI.c for number 150 - ? */ OWcDialog_OGU_LevelLoadProgress = 155, - + OWcDialog_ObjNew = 200, OWcDialog_EditObjectPos = 201, - + OWcDialog_Prop_Generic = 210, OWcDialog_Prop_Char = 211, OWcDialog_Prop_TriggerVolume = 212, @@ -226,7 +226,7 @@ enum OWcDialog_Prop_Door = 221, OWcDialog_Prop_Event = 222, OWcDialog_Prop_Furniture = 223, - + OWcDialog_Particle_Edit = 250, OWcDialog_Particle_Class = 251, OWcDialog_Particle_Variables = 252, @@ -241,7 +241,7 @@ enum OWcDialog_Particle_Value_String = 262, OWcDialog_Particle_Value_Shade = 263, OWcDialog_Particle_Value_Enum = 264, - + OWcDialog_Particle_NewVar = 270, OWcDialog_Particle_RenameVar = 271, OWcDialog_Particle_NewAction = 272, @@ -252,7 +252,7 @@ enum OWcDialog_Particle_EmitterChoice= 277, OWcDialog_Particle_ClassName = 278, OWcDialog_Particle_Number = 279, - + OWcDialog_Particle_DecalTextures= 280, OWcDialog_AI_EditPaths = 300, @@ -265,7 +265,7 @@ enum OWcDialog_AI_ChooseCombat = 307, OWcDialog_AI_EditMelee = 308, OWcDialog_AI_EditNeutral = 309, - + OWcDialog_Sound_Group_Manager = 600, OWcDialog_Sound_Group_Prop = 601, OWcDialog_Sound_Perm_Prop = 602, @@ -284,7 +284,7 @@ enum OWcDialog_Create_Impulse = 615, OWcDialog_Create_Group = 616, OWcDialog_View_Animation = 620, - + OWcDialog_Impact_Effect = 700, OWcDialog_Impact_Effect_Prop = 701 }; @@ -371,7 +371,7 @@ UUtBool OWrWindow_Resize(int new_width, int new_height); void OWrTerminate( void); - + void OWrUpdate( void); @@ -383,20 +383,20 @@ OWrLevelBegin( void OWrLevelEnd( void); - + // ---------------------------------------------------------------------- void OWrConsole_Toggle( void); - + void OWrSplashScreen_Display( void); - + void OWrOniWindow_Startup( void); - + UUtBool OWrOniWindow_Visible( void); @@ -410,7 +410,7 @@ void OWrLevelList_Initialize( WMtDialog *inDialog, UUtUns16 inItemID); - + UUtUns16 OWrLevelList_GetLevelNumber( WMtDialog *inDialog, @@ -419,7 +419,7 @@ OWrLevelList_GetLevelNumber( void OWrLevelLoad_StartLevel( UUtUns16 inLevel); - + // ---------------------------------------------------------------------- UUtBool OWrSettings_Player_Callback( @@ -431,17 +431,17 @@ OWrSettings_Player_Callback( char* OWrSettings_GetCharacterClass( void); - + char* OWrSettings_GetPlayerName( void); - + UUtError OWrSettings_Initialize( void); UUtUns32 OWrGetMask(UUtUns32 inMask, const char **inFlagList); void OWrMaskToString(UUtUns32 inMask, const char **inFlagList, UUtUns32 inStringLength, char *outString); - + // ====================================================================== -#endif /* ONI_WINDOWS_H */ \ No newline at end of file +#endif /* ONI_WINDOWS_H */ diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Obj_Tools.c b/OniProj/OniGameSource/Oni_Windows/Oni_Obj_Tools.c index 60506ad..20a0508 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Obj_Tools.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Obj_Tools.c @@ -36,7 +36,7 @@ #define OBJmGet4BytesFromBuffer(src,dst,type,swap_it) \ (dst) = *((type*)(src)); \ ((UUtUns8*)(src)) += sizeof(type); \ - if ((swap_it)) { UUrSwap_4Byte(&(dst)); } + if ((swap_it)) { UUrSwap_4Byte(&(dst)); } #define OBJmWrite4BytesToBuffer(buf,val,type,num_bytes) \ *((type*)(buf)) = (val); \ @@ -52,26 +52,26 @@ struct OBJtObject M3tPoint3D position; M3tPoint3D rotation; UUtUns32 object_data[]; - + }; typedef struct OBJtObjectTypeNames { UUtUns32 type; char *name;//[OBJcMaxNameLength + 1]; - + } OBJtObjectTypeNames; typedef UUtError (*OBJtDataProcessor)( BFtFile *inObjectFile, UUtBool inSwapIt); - + typedef struct OBJtProcessors { UUtUns32 version; OBJtDataProcessor processor; - + } OBJtProcessors; @@ -112,14 +112,14 @@ OBJiObject_FillBuffer( OBJtObject *inObject, UUtUns8 *outBuffer, UUtUns32 *ioNumBytes); - + static UUtError OBJiOSD_ReadFromFile_1( BFtFile *inObjectFile, OBJtObjectType inObjectType, UUtBool inSwapIt, OBJtOSD_All *outOSD); - + // ====================================================================== // functions // ====================================================================== @@ -131,16 +131,16 @@ OBJiFlagToString( char *outString) { UUtUns32 i; - + UUmAssert(inFlagTypes); UUmAssert(outString); - + outString[0] = '\0'; - + for (i = 0; ; i++) { if (inFlagTypes[i].name == NULL) { break; } - + if (inFlag == inFlagTypes[i].type) { UUrString_Copy(outString, inFlagTypes[i].name, OBJcMaxNameLength); @@ -157,17 +157,17 @@ OBJiStringToFlag( UUtUns32 *outFlag) { UUtUns32 i; - + UUmAssert(inString); UUmAssert(inFlagTypes); UUmAssert(outFlag); - + *outFlag = 0; - + for (i = 0; ; i++) { if (inFlagTypes[i].name == NULL) { break; } - + if (strcmp(inFlagTypes[i].name, inString) == 0) { *outFlag = inFlagTypes[i].type; @@ -191,7 +191,7 @@ OBJiProcessor_1( UUtBool done; UUtUns8 data[OBJcMaxBytesInBuffer]; /* XXX - may need to align */ UUtUns8 *buffer; - + done = UUcFalse; do { @@ -199,50 +199,50 @@ OBJiProcessor_1( M3tPoint3D position; M3tPoint3D rotation; OBJtOSD_All osd_all; - + // get the object type error = BFrFile_Read(inObjectFile, sizeof(UUtUns32), data); UUmError_ReturnOnError(error); buffer = data; - + OBJmGet4BytesFromBuffer(buffer, object_type, OBJtObjectType, inSwapIt); if (object_type == OBJcEnd) { done = UUcTrue; continue; } - + // read the object position into memory error = BFrFile_Read(inObjectFile, sizeof(M3tPoint3D), data); UUmError_ReturnOnError(error); buffer = data; - + // get the position OBJmGet4BytesFromBuffer(buffer, position.x, float, inSwapIt); OBJmGet4BytesFromBuffer(buffer, position.y, float, inSwapIt); OBJmGet4BytesFromBuffer(buffer, position.z, float, inSwapIt); - + // read the object rotation into memory error = BFrFile_Read(inObjectFile, sizeof(M3tPoint3D), data); UUmError_ReturnOnError(error); buffer = data; - + // get the rotation OBJmGet4BytesFromBuffer(buffer, rotation.x, float, inSwapIt); OBJmGet4BytesFromBuffer(buffer, rotation.y, float, inSwapIt); OBJmGet4BytesFromBuffer(buffer, rotation.z, float, inSwapIt); - + // read the OSD UUrMemory_Clear(&osd_all, sizeof(OBJtOSD_All)); error = OBJiOSD_ReadFromFile_1(inObjectFile, object_type, inSwapIt, &osd_all); UUmError_ReturnOnError(error); - + // create a new object error = OBJrObject_New(object_type, &position, &rotation, (void*)&osd_all); UUmError_ReturnOnError(error); } while (!done); - + return UUcError_None; } @@ -257,7 +257,7 @@ OBJiObjectType_IsValid( OBJtObjectType inObjectType) { UUtBool result; - + switch (inObjectType) { case OBJcType_Character: @@ -271,13 +271,13 @@ OBJiObjectType_IsValid( case OBJcType_Weapon: result = UUcTrue; break; - + default: UUmAssert(!"invalid object type"); result = UUcFalse; break; } - + return result; } @@ -295,7 +295,7 @@ OBJiObjectList_AddObject( UUtUns32 index; UUtBool mem_moved; OBJtObject **object_list; - + // if the object list hasn't been created yet, then create it if (OBJgObjectArray == NULL) { @@ -307,17 +307,17 @@ OBJiObjectList_AddObject( 0); UUmError_ReturnOnNull(OBJgObjectArray); } - + // create a new element in the array error = UUrMemory_Array_GetNewElement(OBJgObjectArray, &index, &mem_moved); UUmError_ReturnOnError(error); - + // get a pointer to the memory array object_list = (OBJtObject**)UUrMemory_Array_GetMemory(OBJgObjectArray); if (object_list == NULL) { return UUcError_Generic; } - + object_list[index] = inObject; - + return UUcError_None; } @@ -329,13 +329,13 @@ OBJiObjectList_DeleteObject( if (OBJgObjectArray) { OBJtObject **object_list; - + object_list = (OBJtObject**)UUrMemory_Array_GetMemory(OBJgObjectArray); if (object_list) { // delete the object UUrMemory_Block_Delete(object_list[inIndex]); - + // delete the array entry UUrMemory_Array_DeleteElement(OBJgObjectArray, inIndex); } @@ -348,7 +348,7 @@ OBJiObjectList_GetNumObjects( void) { if (OBJgObjectArray == NULL) { return 0; } - + return UUrMemory_Array_GetUsedElems(OBJgObjectArray); } @@ -359,9 +359,9 @@ OBJiObjectList_GetObject( { OBJtObject *object; UUtUns32 num_objects; - + object = NULL; - + if (OBJgObjectArray) { // get the number of objects in the array and make sure @@ -370,7 +370,7 @@ OBJiObjectList_GetObject( if ((num_objects > 0) && (inIndex < num_objects)) { OBJtObject **object_list; - + // get the object from the object list object_list = (OBJtObject**)UUrMemory_Array_GetMemory(OBJgObjectArray); if (object_list) @@ -379,7 +379,7 @@ OBJiObjectList_GetObject( } } } - + return object; } @@ -389,9 +389,9 @@ OBJiObjectList_Initialize( void) { UUmAssert(OBJgObjectArray == NULL); - + OBJgObjectArray = NULL; - + return UUcError_None; } @@ -403,18 +403,18 @@ OBJiObjectList_Terminate( UUtUns32 num_objects; OBJtObject **object_list; UUtUns32 i; - + if (OBJgObjectArray == NULL) { return; } - + // delete the objects in the array num_objects = UUrMemory_Array_GetUsedElems(OBJgObjectArray); object_list = (OBJtObject**)UUrMemory_Array_GetMemory(OBJgObjectArray); - + for (i = 0; i < num_objects; i++) { UUrMemory_Block_Delete(object_list[i]); } - + // delete the array UUrMemory_Array_Delete(OBJgObjectArray); OBJgObjectArray = NULL; @@ -429,13 +429,13 @@ OBJrObjectList_DrawObjects( UUtUns32 num_objects; OBJtObject **object_list; UUtUns32 i; - + if (OBJgObjectArray == NULL) { return; } - + // draw the objects in the array num_objects = UUrMemory_Array_GetUsedElems(OBJgObjectArray); object_list = (OBJtObject**)UUrMemory_Array_GetMemory(OBJgObjectArray); - + for (i = 0; i < num_objects; i++) { OBJrObject_Draw(object_list[i]); @@ -474,31 +474,31 @@ OBJiObjectFile_CreateObjectsFromFile( UUtBool swap_it; UUtUns32 version; UUtUns32 i; - + UUmAssert(inObjectFile); - + // read the swap flag from file error = BFrFile_Read(inObjectFile, sizeof(UUtUns32), data); UUmError_ReturnOnError(error); buffer = data; - + // determine if the file needs to be swapped swap_it = UUcFalse; if (*(UUtUns32*)(buffer) != OBJcSwap) { UUrSwap_4Byte(buffer); if (*(UUtUns32*)(buffer) != OBJcSwap) { return UUcError_Generic; } - + swap_it = UUcTrue; } - + // read the version flag from the file error = BFrFile_Read(inObjectFile, sizeof(UUtUns32), data); UUmError_ReturnOnError(error); buffer = data; - + OBJmGet4BytesFromBuffer(buffer, version, UUtUns32, swap_it); - + // process the rest of the file for (i = 0; ; i++) { @@ -508,7 +508,7 @@ OBJiObjectFile_CreateObjectsFromFile( error = UUcError_Generic; break; } - + if (OBJgProcessors[i].version == version) { error = OBJgProcessors[i].processor(inObjectFile, swap_it); @@ -516,10 +516,10 @@ OBJiObjectFile_CreateObjectsFromFile( } } UUmError_ReturnOnError(error); - + // make sure no objects are selected OBJrObject_Select(NULL); - + return UUcError_None; } @@ -540,23 +540,23 @@ OBJiObjectFile_MakeFileRef( UUtError error; char filename[128]; BFtFileRef *object_file_ref; - + UUmAssert(outObjectFileRef); - + *outObjectFileRef = NULL; - + // find the appropriate directory - + // make the filename sprintf(filename, "Level%d_Objects.txt", inLevelNum); - + // make the file ref error = BFrFileRef_MakeFromName(filename, &object_file_ref); UUmError_ReturnOnError(error); - + *outObjectFileRef = object_file_ref; - - return UUcError_None; + + return UUcError_None; } // ---------------------------------------------------------------------- @@ -565,11 +565,11 @@ OBJiObjectFile_New( BFtFileRef *inObjectFileRef) { UUtError error; - + // create the object file error = BFrFile_Create(inObjectFileRef); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -581,13 +581,13 @@ OBJiObjectFile_Open( { UUtError error; BFtFile *object_file; - + // open the object file error = BFrFile_Open(inObjectFileRef, "rw", &object_file); UUmError_ReturnOnError(error); - + *outObjectFile = object_file; - + return UUcError_None; } @@ -601,48 +601,48 @@ OBJiObjectFile_SaveObjectsToFile( UUtUns32 i; UUtUns32 num_bytes; UUtUns8 buffer[OBJcMaxBytesInBuffer]; /* XXX - may need to align */ - + // set the pos to 0 error = BFrFile_SetPos(inObjectFile, 0); UUmError_ReturnOnError(error); - + // put swap flag into the file *(UUtUns32*)(buffer) = OBJcSwap; error = BFrFile_Write(inObjectFile, sizeof(UUtUns32), buffer); UUmError_ReturnOnError(error); - + // put the version number into the file *(UUtUns32*)(buffer) = OBJcObjectFileVersion; error = BFrFile_Write(inObjectFile, sizeof(UUtUns32), buffer); UUmError_ReturnOnError(error); - + // get the number of objects to save num_objects = OBJiObjectList_GetNumObjects(); for (i = 0; i < num_objects; i++) { OBJtObject *object; - + // get the object from the object list object = OBJiObjectList_GetObject(i); if (object == NULL) { continue; } - + // produce the necessary data to contain the object num_bytes = OBJcMaxBytesInBuffer; error = OBJiObject_FillBuffer(object, buffer, &num_bytes); UUmError_ReturnOnError(error); - + // save the object to the file error = BFrFile_Write(inObjectFile, num_bytes, buffer); UUmError_ReturnOnError(error); } - + // put end flag into the file *(UUtUns32*)(buffer) = OBJcEnd; error = BFrFile_Write(inObjectFile, sizeof(UUtUns32), buffer); UUmError_ReturnOnError(error); - + // if EOF needs to be set, try BFrFile_GetPos(inObjectFile, &pos), BFrFile_SetPos(inObjectFile, pos); - + return UUcError_None; } @@ -664,10 +664,10 @@ OBJiObject_Character_Delete( character_osd = (OBJtOSD_Character*)ioObject->object_data; if (character_osd->character_index == OBJcNoCharacter) { return; } - // get a pointer to the character + // get a pointer to the character character_list = ONrGameState_GetCharacterList(); character = &character_list[character_osd->character_index]; - + ONrGameState_DeleteCharacter(character); character_osd->character_index = OBJcNoCharacter; } @@ -680,11 +680,11 @@ OBJiObject_Character_FillBuffer( UUtUns32 *ioNumBytes) { OBJtOSD_Character *character_osd; - + character_osd = (OBJtOSD_Character*)inObject->object_data; - + if (*ioNumBytes < sizeof(OBJtOSD_Character)) { return UUcError_Generic; } - + return UUcError_None; } @@ -695,9 +695,9 @@ OBJiObject_Character_GetOSD( OBJtOSD_All *outObjectSpecificData) { OBJtOSD_Character *character_osd; - + character_osd = (OBJtOSD_Character*)inObject->object_data; - + outObjectSpecificData->character_osd = *character_osd; } @@ -710,15 +710,15 @@ OBJiObject_Character_New( OBJtOSD_Character *character_osd; AItCharacterSetup character_setup; ONtCharacterClass *character_class; - + // get a pointer to the object osd character_osd = (OBJtOSD_Character*)inObject->object_data; - + // init some fields of the character_osd UUrString_Copy(character_osd->character_class, "konoko_generic", 64); UUrString_Copy(character_osd->character_name, "none", ONcMaxPlayerNameLength); character_osd->character_index = OBJcNoCharacter; - + // get the character class error = TMrInstance_GetDataPtr( @@ -726,7 +726,7 @@ OBJiObject_Character_New( character_osd->character_class, &character_class); UUmError_ReturnOnError(error); - + // set the hitpoints character_osd->hit_points = character_class->maxHitPoints; @@ -745,11 +745,11 @@ OBJiObject_Character_New( character_setup.leaveClips = 0; character_setup.leaveHypos = 0; character_setup.leaveCells = 0; - + // create the new character error = ONrGameState_NewCharacter(&character_setup, NULL, &character_osd->character_index); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -774,23 +774,23 @@ OBJiObject_Character_SetOSD( ONtCharacter *character; UUtUns16 character_index; ONtCharacterClass *character_class; - + // get a pointer to the object osd character_osd = (OBJtOSD_Character*)ioObject->object_data; - + // set OSD *character_osd = inObjectSpecificData->character_osd; - + // restore the character index character_osd->character_index = character_index; - + // ------------------------------ // update the character - // ------------------------------ - // get a pointer to the character + // ------------------------------ + // get a pointer to the character character_list = ONrGameState_GetCharacterList(); character = &character_list[character_osd->character_index]; - + // set the character class error = TMrInstance_GetDataPtr( @@ -798,14 +798,14 @@ OBJiObject_Character_SetOSD( character_osd->character_class, &character_class); UUmError_ReturnOnError(error); - + character->characterClass = character_class; - + // set the character name UUrString_Copy(character->player_name, character_osd->character_name, ONcMaxPlayerNameLength); character->hitPoints = character_osd->hit_points; character->teamNumber = character_osd->team_number; - + return UUcError_None; } @@ -817,14 +817,14 @@ OBJiObject_Character_SetPosition( OBJtOSD_Character *character_osd; ONtCharacter *character; ONtCharacter *character_list; - + // get a pointer to the object osd character_osd = (OBJtOSD_Character*)inObject->object_data; - + // get the character character_list = ONrGameState_GetCharacterList(); character = &character_list[character_osd->character_index]; - + // set the character's position character->location = character->physics->position = inObject->position; } @@ -840,9 +840,9 @@ OBJiObject_Flag_Delete( OBJtObject *ioObject) { OBJtOSD_Flag *flag_osd; - + flag_osd = (OBJtOSD_Flag*)ioObject->object_data; - + ONrLevel_DeleteFlag(flag_osd->flag_index); } @@ -854,12 +854,12 @@ OBJiObject_Flag_FillBuffer( UUtUns32 *ioNumBytes) { OBJtOSD_Flag *flag_osd; - + flag_osd = (OBJtOSD_Flag*)inObject->object_data; - + if (*ioNumBytes < sizeof(UUtUns32)) { return UUcError_Generic; } OBJmWrite4BytesToBuffer(*ioBuffer, flag_osd->flag_type, UUtUns32, *ioNumBytes); - + return UUcError_None; } @@ -870,9 +870,9 @@ OBJiObject_Flag_GetOSD( OBJtOSD_All *outObjectSpecificData) { OBJtOSD_Flag *flag_osd; - + flag_osd = (OBJtOSD_Flag*)inObject->object_data; - + outObjectSpecificData->flag_osd = *flag_osd; } @@ -884,16 +884,16 @@ OBJiObject_Flag_New( ONtFlag flag; UUtInt16 flag_id; OBJtOSD_Flag *flag_osd; - + M3tPoint3D rotPoint; M3tMatrix4x3 rotMatrix; - + // setup the flag flag.location = ioObject->position; flag.idNumber = 0; flag.deleted = UUcFalse; flag.maxFlag = UUcFalse; - + MUrMatrix_Identity(&flag.matrix); MUrMatrixStack_Translate(&flag.matrix, (M3tVector3D*)&ioObject->position); @@ -901,7 +901,7 @@ OBJiObject_Flag_New( rotPoint.x = 1.0f; rotPoint.y = 0.0f; rotPoint.z = 0.0f; - + MUrMatrix_To_RotationMatrix(&flag.matrix, &rotMatrix); MUrMatrix_MultiplyPoint(&rotPoint, &rotMatrix, &rotPoint); @@ -922,13 +922,13 @@ OBJiObject_Flag_New( flag_id++; } flag.idNumber = flag_id; - + ONrLevel_AddFlag(&flag); // set the flag index flag_osd = (OBJtOSD_Flag*)ioObject->object_data; flag_osd->flag_index = ONrLevel_Flag_ID_To_Index(flag.idNumber); - + return UUcError_None; } @@ -947,10 +947,10 @@ OBJiObject_Flag_ReadFromFile_1( error = BFrFile_Read(inObjectFile, sizeof(UUtUns32), data); UUmError_ReturnOnError(error); buffer = data; - + // copy the data into the osd OBJmGet4BytesFromBuffer(buffer, outOSD->flag_osd.flag_type, OBJtFlagType, inSwapIt); - + return UUcError_None; } @@ -961,13 +961,13 @@ OBJiObject_Flag_SetOSD( OBJtOSD_All *inObjectSpecificData) { OBJtOSD_Flag *flag_osd; - + // get a pointer to the object osd flag_osd = (OBJtOSD_Flag*)ioObject->object_data; - + // set the flag type flag_osd->flag_type = inObjectSpecificData->flag_osd.flag_type; - + return UUcError_None; } @@ -977,10 +977,10 @@ OBJiObject_Flag_SetPosition( OBJtObject *inObject) { OBJtOSD_Flag *flag_osd; - + // get a pointer to the object osd flag_osd = (OBJtOSD_Flag*)inObject->object_data; - + // set the location of the flag ONrLevel_Flag_SetLocation( ONrLevel_Flag_Index_To_Pointer(flag_osd->flag_index), @@ -1006,23 +1006,23 @@ OBJiObject_Furniture_Draw( { OBJtOSD_Furniture *furniture_osd; M3tBoundingBox bBox; - + furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; if (furniture_osd->geometry == NULL) { return; } - - + + M3rMatrixStack_Push(); M3rMatrixStack_ApplyTranslate(inObject->position); M3rMatrixStack_Multiply(&furniture_osd->rotation_matrix); M3rGeom_State_Commit(); - + // draw the bounding box if this is the selected object if (inObject == OBJgSelectedObject) { M3rMinMaxBBox_To_BBox(&furniture_osd->geometry->pointArray->minmax_boundingBox, &bBox); M3rBBox_Draw_Line(&bBox, IMcShade_White); } - + M3rGeometry_Draw(furniture_osd->geometry); M3rMatrixStack_Pop(); @@ -1036,16 +1036,16 @@ OBJiObject_Furniture_FillBuffer( UUtUns32 *ioNumBytes) { OBJtOSD_Furniture *furniture_osd; - + furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; - + if (*ioNumBytes < BFcMaxFileNameLength) { return UUcError_Generic; } - + // put the geometry name in the buffer UUrString_Copy((char*)*ioBuffer, furniture_osd->geometry_name, *ioNumBytes); ((UUtUns8*)(*ioBuffer)) += BFcMaxFileNameLength; *ioNumBytes -= BFcMaxFileNameLength; - + return UUcError_None; } @@ -1056,9 +1056,9 @@ OBJiObject_Furniture_GetOSD( OBJtOSD_All *outObjectSpecificData) { OBJtOSD_Furniture *furniture_osd; - + furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; - + outObjectSpecificData->furniture_osd = *furniture_osd; } @@ -1080,12 +1080,12 @@ OBJiObject_Furniture_ReadFromFile_1( UUtError error; UUtUns8 data[sizeof(OBJtOSD_All)]; UUtUns8 *buffer; - + // read the data from the file error = BFrFile_Read(inObjectFile, BFcMaxFileNameLength, data); UUmError_ReturnOnError(error); buffer = data; - + // copy the data into the osd UUrString_Copy(outOSD->furniture_osd.geometry_name, (char*)buffer, BFcMaxFileNameLength); @@ -1100,18 +1100,18 @@ OBJiObject_Furniture_SetOSD( { UUtError error; OBJtOSD_Furniture *furniture_osd; - + UUmAssert(inObjectSpecificData); - + // get a pointer to the object osd furniture_osd = (OBJtOSD_Furniture*)ioObject->object_data; - + // set OSD UUrString_Copy( furniture_osd->geometry_name, inObjectSpecificData->furniture_osd.geometry_name, BFcMaxFileNameLength); - + // get a pointer to the geometry if (furniture_osd->geometry_name[0] != '\0') { @@ -1126,7 +1126,7 @@ OBJiObject_Furniture_SetOSD( { furniture_osd->geometry = NULL; } - + return UUcError_None; } @@ -1143,18 +1143,18 @@ OBJiObject_Furniture_SetPosition( // get a pointer to the object osd furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; - + // convert the rotation to radians rot_x = inObject->rotation.x * M3cDegToRad; rot_y = inObject->rotation.y * M3cDegToRad; rot_z = inObject->rotation.z * M3cDegToRad; - + // update the rotation matrix MUrMatrix3x3_Identity(&rotation_matrix); MUrMatrix3x3_RotateX(&rotation_matrix, rot_x); MUrMatrix3x3_RotateY(&rotation_matrix, rot_y); MUrMatrix3x3_RotateZ(&rotation_matrix, rot_z); - + MUrMatrix4x3_BuildFrom3x3(&furniture_osd->rotation_matrix, &rotation_matrix); } @@ -1169,10 +1169,10 @@ OBJiObject_PowerUp_Delete( OBJtObject *ioObject) { OBJtOSD_PowerUp *powerup_osd; - + // get a pointer to the object osd powerup_osd = (OBJtOSD_PowerUp*)ioObject->object_data; - + if (powerup_osd->powerup) { WPrPowerup_Delete(powerup_osd->powerup); @@ -1187,7 +1187,7 @@ OBJiObject_PowerUp_Draw( { OBJtOSD_PowerUp *powerup_osd; M3tBoundingBox bBox; - + // get a pointer to the object osd powerup_osd = (OBJtOSD_PowerUp*)inObject->object_data; @@ -1198,10 +1198,10 @@ OBJiObject_PowerUp_Draw( M3rMatrixStack_ApplyTranslate(powerup_osd->powerup->position); M3rMatrixStack_RotateZAxis(M3cHalfPi); M3rGeom_State_Commit(); - + M3rMinMaxBBox_To_BBox(&powerup_osd->powerup->geometry->pointArray->minmax_boundingBox, &bBox); M3rBBox_Draw_Line(&bBox, IMcShade_White); - + M3rMatrixStack_Pop(); } } @@ -1214,13 +1214,13 @@ OBJiObject_PowerUp_FillBuffer( UUtUns32 *ioNumBytes) { OBJtOSD_PowerUp *powerup_osd; - + // get a pointer to the object osd powerup_osd = (OBJtOSD_PowerUp*)inObject->object_data; - + if (*ioNumBytes < sizeof(UUtUns32)) { return UUcError_Generic; } OBJmWrite4BytesToBuffer(*ioBuffer, powerup_osd->powerup_type, UUtUns32, *ioNumBytes); - + return UUcError_None; } @@ -1231,10 +1231,10 @@ OBJiObject_PowerUp_GetOSD( OBJtOSD_All *outObjectSpecificData) { OBJtOSD_PowerUp *powerup_osd; - + // get a pointer to the object osd powerup_osd = (OBJtOSD_PowerUp*)inObject->object_data; - + outObjectSpecificData->powerup_osd = *powerup_osd; } @@ -1246,42 +1246,42 @@ OBJiObject_PowerUp_New( OBJtOSD_PowerUp *powerup_osd; WPtPowerup *powerup; WPtPowerupType type; - + // get a pointer to the object osd powerup_osd = (OBJtOSD_PowerUp*)inObject->object_data; - + switch (powerup_osd->powerup_type) { case OBJcPowerUpType_Hypo: type = WPcPowerup_Hypo; break; - + case OBJcPowerUpType_ShieldGreen: type = WPcPowerup_ShieldGreen; break; - + case OBJcPowerUpType_ShieldBlue: type = WPcPowerup_ShieldBlue; break; - + case OBJcPowerUpType_ShieldRed: type = WPcPowerup_ShieldRed; break; - + case OBJcPowerUpType_AmmoEnergy: type = WPcPowerup_AmmoEnergy; break; - + case OBJcPowerUpType_AmmoBallistic: type = WPcPowerup_AmmoBallistic; break; } - + powerup = WPrPowerup_New(type, &inObject->position, 0.0f); UUmError_ReturnOnNull(powerup); - + powerup_osd->powerup = powerup; - + return UUcError_None; } @@ -1295,12 +1295,12 @@ OBJiObject_PowerUp_ReadFromFile_1( UUtError error; UUtUns8 data[sizeof(OBJtOSD_All)]; UUtUns8 *buffer; - + // read the data from the file error = BFrFile_Read(inObjectFile, sizeof(UUtUns32), data); UUmError_ReturnOnError(error); buffer = data; - + // copy the data into the osd OBJmGet4BytesFromBuffer(buffer, outOSD->powerup_osd.powerup_type, OBJtPowerUpType, inSwapIt); @@ -1316,46 +1316,46 @@ OBJiObject_PowerUp_SetOSD( UUtError error; OBJtOSD_PowerUp *powerup_osd; WPtPowerupType type; - + UUmAssert(inObjectSpecificData); - + // get a pointer to the object osd powerup_osd = (OBJtOSD_PowerUp*)ioObject->object_data; - + // set OSD powerup_osd->powerup_type = inObjectSpecificData->powerup_osd.powerup_type; - + // set the objects data switch (powerup_osd->powerup_type) { case OBJcPowerUpType_Hypo: type = WPcPowerup_Hypo; break; - + case OBJcPowerUpType_ShieldGreen: type = WPcPowerup_ShieldGreen; break; - + case OBJcPowerUpType_ShieldBlue: type = WPcPowerup_ShieldBlue; break; - + case OBJcPowerUpType_ShieldRed: type = WPcPowerup_ShieldRed; break; - + case OBJcPowerUpType_AmmoEnergy: type = WPcPowerup_AmmoEnergy; break; - + case OBJcPowerUpType_AmmoBallistic: type = WPcPowerup_AmmoBallistic; break; } - + error = WPrPowerup_SetType(powerup_osd->powerup, type); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1365,13 +1365,13 @@ OBJiObject_PowerUp_SetPosition( OBJtObject *inObject) { OBJtOSD_PowerUp *powerup_osd; - + // get a pointer to the object osd powerup_osd = (OBJtOSD_PowerUp*)inObject->object_data; - + // set the position powerup_osd->powerup->position = inObject->position; - + // set the orientation } @@ -1395,11 +1395,11 @@ OBJiObject_Sound_FillBuffer( UUtUns32 *ioNumBytes) { OBJtOSD_Sound *sound_osd; - + sound_osd = (OBJtOSD_Sound*)inObject->object_data; - + if (*ioNumBytes < sizeof(UUtUns32)) { return UUcError_Generic; } - + return UUcError_None; } @@ -1410,9 +1410,9 @@ OBJiObject_Sound_GetOSD( OBJtOSD_All *outObjectSpecificData) { OBJtOSD_Sound *sound_osd; - + sound_osd = (OBJtOSD_Sound*)inObject->object_data; - + outObjectSpecificData->sound_osd = *sound_osd; } @@ -1441,15 +1441,15 @@ OBJiObject_Sound_SetOSD( OBJtOSD_All *inObjectSpecificData) { OBJtOSD_Sound *sound_osd; - + UUmAssert(inObjectSpecificData); - + // get a pointer to the object osd sound_osd = (OBJtOSD_Sound*)ioObject->object_data; - + // set OSD *sound_osd = inObjectSpecificData->sound_osd; - + return UUcError_None; } @@ -1478,12 +1478,12 @@ OBJiObject_TrigVol_Draw( OBJtObject *inObject) { OBJtOSD_TrigVol *trigvol_osd; - + trigvol_osd = (OBJtOSD_TrigVol*)inObject->object_data; if (trigvol_osd->trigger == NULL) { return; } - + M3rMatrixStack_Push(); - + // draw the bounding box if this is the selected object if (inObject == OBJgSelectedObject) { @@ -1493,7 +1493,7 @@ OBJiObject_TrigVol_Draw( { ONrLevel_Trigger_Display(trigvol_osd->trigger, IMcShade_Blue); } - + M3rMatrixStack_Pop(); } @@ -1505,12 +1505,12 @@ OBJiObject_TrigVol_FillBuffer( UUtUns32 *ioNumBytes) { OBJtOSD_TrigVol *trigvol_osd; - + // get a pointer to the object osd trigvol_osd = (OBJtOSD_TrigVol*)inObject->object_data; - + if (*ioNumBytes < (sizeof(M3tPoint3D) /*+ sizeof(M3tQuaternion)*/ + sizeof(UUtInt32))) { return UUcError_Generic; } - + OBJmWrite4BytesToBuffer(*ioBuffer, trigvol_osd->scale.x, float, *ioNumBytes); OBJmWrite4BytesToBuffer(*ioBuffer, trigvol_osd->scale.y, float, *ioNumBytes); OBJmWrite4BytesToBuffer(*ioBuffer, trigvol_osd->scale.z, float, *ioNumBytes); @@ -1519,7 +1519,7 @@ OBJiObject_TrigVol_FillBuffer( OBJmWrite4BytesToBuffer(*ioBuffer, trigvol_osd->orientation.z, float, *ioNumBytes); OBJmWrite4BytesToBuffer(*ioBuffer, trigvol_osd->orientation.w, float, *ioNumBytes);*/ OBJmWrite4BytesToBuffer(*ioBuffer, trigvol_osd->id, UUtInt32, *ioNumBytes); - + return UUcError_None; } @@ -1531,13 +1531,13 @@ OBJiObject_TrigVol_GetBoundingSphere( { OBJtOSD_TrigVol *trigvol_osd; float radius; - + // get a pointer to the object osd trigvol_osd = (OBJtOSD_TrigVol*)inObject->object_data; - + radius = UUmMax(trigvol_osd->scale.x, trigvol_osd->scale.y); radius = UUmMax(radius, trigvol_osd->scale.z); - + outBoundingSphere->center.x = 0; outBoundingSphere->center.y = 0; outBoundingSphere->center.z = 0; @@ -1551,10 +1551,10 @@ OBJiObject_TrigVol_GetOSD( OBJtOSD_All *outObjectSpecificData) { OBJtOSD_TrigVol *trigvol_osd; - + // get a pointer to the object osd trigvol_osd = (OBJtOSD_TrigVol*)inObject->object_data; - + outObjectSpecificData->trigvol_osd = *trigvol_osd; } @@ -1564,10 +1564,10 @@ OBJiObject_TrigVol_New( OBJtObject *inObject) { OBJtOSD_TrigVol *trigvol_osd; - + // get a pointer to the object osd trigvol_osd = (OBJtOSD_TrigVol*)inObject->object_data; - + trigvol_osd->trigger = ONrLevel_Trigger_New(); UUmError_ReturnOnNull(trigvol_osd->trigger); @@ -1579,9 +1579,9 @@ OBJiObject_TrigVol_New( trigvol_osd->trigger->orientation = MUgZeroQuat; trigvol_osd->trigger->scale = trigvol_osd->scale; trigvol_osd->trigger->idNumber = -1; - + ONrLevel_Trigger_TransformPoints(trigvol_osd->trigger); - + return UUcError_None; } @@ -1595,24 +1595,24 @@ OBJiObject_TrigVol_ReadFromFile_1( UUtError error; UUtUns8 data[sizeof(OBJtOSD_All)]; UUtUns8 *buffer; - + // read the data from the file error = BFrFile_Read(inObjectFile, sizeof(M3tPoint3D) /*+ sizeof(M3tQuaternion)*/ + sizeof(UUtInt32), data); UUmError_ReturnOnError(error); buffer = data; - + // copy the data into the osd OBJmGet4BytesFromBuffer(buffer, outOSD->trigvol_osd.scale.x, float, inSwapIt); OBJmGet4BytesFromBuffer(buffer, outOSD->trigvol_osd.scale.y, float, inSwapIt); OBJmGet4BytesFromBuffer(buffer, outOSD->trigvol_osd.scale.z, float, inSwapIt); - + /* OBJmGet4BytesFromBuffer(buffer, outOSD->trigvol_osd.orientation.x, float, inSwapIt); OBJmGet4BytesFromBuffer(buffer, outOSD->trigvol_osd.orientation.y, float, inSwapIt); OBJmGet4BytesFromBuffer(buffer, outOSD->trigvol_osd.orientation.z, float, inSwapIt); OBJmGet4BytesFromBuffer(buffer, outOSD->trigvol_osd.orientation.w, float, inSwapIt);*/ - - OBJmGet4BytesFromBuffer(buffer, outOSD->trigvol_osd.id, UUtInt32, inSwapIt); - + + OBJmGet4BytesFromBuffer(buffer, outOSD->trigvol_osd.id, UUtInt32, inSwapIt); + return UUcError_None; } @@ -1623,22 +1623,22 @@ OBJiObject_TrigVol_SetOSD( OBJtOSD_All *inObjectSpecificData) { OBJtOSD_TrigVol *trigvol_osd; - + UUmAssert(inObjectSpecificData); - + // get a pointer to the object osd trigvol_osd = (OBJtOSD_TrigVol*)ioObject->object_data; - + // set OSD trigvol_osd->scale = inObjectSpecificData->trigvol_osd.scale; // trigvol_osd->orientation = inObjectSpecificData->trigvol_osd.orientation; trigvol_osd->id = inObjectSpecificData->trigvol_osd.id; - + // update the trigger trigvol_osd->trigger->scale = trigvol_osd->scale; // trigvol_osd->trigger->orientation = trigvol_osd->orientation; trigvol_osd->trigger->idNumber = trigvol_osd->id; - + ONrLevel_Trigger_TransformPoints(trigvol_osd->trigger); return UUcError_None; @@ -1650,10 +1650,10 @@ OBJiObject_TrigVol_SetPosition( OBJtObject *inObject) { OBJtOSD_TrigVol *trigvol_osd; - + // get a pointer to the object osd trigvol_osd = (OBJtOSD_TrigVol*)inObject->object_data; - + // update the trigger trigvol_osd->trigger->location = inObject->position; @@ -1671,10 +1671,10 @@ OBJiObject_Weapon_Delete( OBJtObject *ioObject) { OBJtOSD_Weapon *weapon_osd; - + // get a pointer to the object osd weapon_osd = (OBJtOSD_Weapon*)ioObject->object_data; - + if (weapon_osd->weapon) { WPrDelete(weapon_osd->weapon); @@ -1689,22 +1689,22 @@ OBJiObject_Weapon_Draw( { OBJtOSD_Weapon *weapon_osd; M3tBoundingBox bBox; - + // get a pointer to the object osd weapon_osd = (OBJtOSD_Weapon*)inObject->object_data; - + if (weapon_osd->weapon == NULL) { return; } - + // draw the bounding box if this is the selected object if (inObject == OBJgSelectedObject) { M3rMatrixStack_Push(); M3rMatrixStack_ApplyTranslate(WPrGetPhysics(weapon_osd->weapon)->position); M3rGeom_State_Commit(); - + M3rMinMaxBBox_To_BBox(&WPrGetClass(weapon_osd->weapon)->geometry->pointArray->minmax_boundingBox, &bBox); M3rBBox_Draw_Line(&bBox, IMcShade_White); - + M3rMatrixStack_Pop(); } } @@ -1717,17 +1717,17 @@ OBJiObject_Weapon_FillBuffer( UUtUns32 *ioNumBytes) { OBJtOSD_Weapon *weapon_osd; - + // get a pointer to the object osd weapon_osd = (OBJtOSD_Weapon*)inObject->object_data; - + if (*ioNumBytes < BFcMaxFileNameLength) { return UUcError_Generic; } - + // put the weapon class name in the buffer UUrString_Copy((char*)*ioBuffer, weapon_osd->weapon_class_name, *ioNumBytes); ((UUtUns8*)(*ioBuffer)) += BFcMaxFileNameLength; *ioNumBytes -= BFcMaxFileNameLength; - + return UUcError_None; } @@ -1738,10 +1738,10 @@ OBJiObject_Weapon_GetOSD( OBJtOSD_All *outObjectSpecificData) { OBJtOSD_Weapon *weapon_osd; - + // get a pointer to the object osd weapon_osd = (OBJtOSD_Weapon*)inObject->object_data; - + outObjectSpecificData->weapon_osd = *weapon_osd; } @@ -1763,12 +1763,12 @@ OBJiObject_Weapon_ReadFromFile_1( UUtError error; UUtUns8 data[sizeof(OBJtOSD_All)]; UUtUns8 *buffer; - + // read the data from the file error = BFrFile_Read(inObjectFile, BFcMaxFileNameLength, data); UUmError_ReturnOnError(error); buffer = data; - + // copy the data into the osd UUrString_Copy(outOSD->weapon_osd.weapon_class_name, (char*)buffer, BFcMaxFileNameLength); @@ -1784,25 +1784,25 @@ OBJiObject_Weapon_SetOSD( UUtError error; OBJtOSD_Weapon *weapon_osd; WPtWeaponClass *weapon_class; - + UUmAssert(inObjectSpecificData); - + // get a pointer to the object osd weapon_osd = (OBJtOSD_Weapon*)ioObject->object_data; - + // delete the existing weapon if (weapon_osd->weapon) { WPrDelete(weapon_osd->weapon); weapon_osd->weapon = NULL; } - + // set OSD UUrString_Copy( weapon_osd->weapon_class_name, inObjectSpecificData->weapon_osd.weapon_class_name, BFcMaxFileNameLength); - + // get the weapon class error = TMrInstance_GetDataPtr( @@ -1810,14 +1810,14 @@ OBJiObject_Weapon_SetOSD( weapon_osd->weapon_class_name, &weapon_class); UUmError_ReturnOnError(error); - + // create a weapon using the weapon class weapon_osd->weapon = WPrNew(weapon_class); UUmError_ReturnOnNull(weapon_osd->weapon); - + // set the weapon's position OBJrObject_SetPosition(ioObject, &ioObject->position, &ioObject->rotation); - + return UUcError_None; } @@ -1827,10 +1827,10 @@ OBJiObject_Weapon_SetPosition( OBJtObject *inObject) { OBJtOSD_Weapon *weapon_osd; - + // get a pointer to the object osd weapon_osd = (OBJtOSD_Weapon*)inObject->object_data; - + WPrSetPosition(weapon_osd->weapon, &inObject->position); } @@ -1848,7 +1848,7 @@ OBJiObject_EnumerateTemplate( UUtUns32 inUserData) { #define cMaxInstances 1024 - + UUtError error; void *instances[cMaxInstances]; UUtUns32 num_instances; @@ -1863,7 +1863,7 @@ OBJiObject_EnumerateTemplate( &num_instances, instances); UUmError_ReturnOnError(error); - + for (i = 0; i < num_instances; i++) { result = @@ -1873,7 +1873,7 @@ OBJiObject_EnumerateTemplate( inUserData); if (result == UUcFalse) { break; } } - + return UUcError_None; } @@ -1891,7 +1891,7 @@ OBJiObject_EnumerateTypeNames( for (i = 0; ; i++) { if (inObjectTypeNames[i].type == OBJcFlagType_None) { break; } - + result = inObjectEnumCallback( inObjectType, @@ -1912,16 +1912,16 @@ OBJiObject_FillBuffer( { UUtError error; UUtUns8 *buffer; - + UUmAssert(inObject); UUmAssert(outBuffer); UUmAssert(ioNumBytes && (*ioNumBytes > sizeof(OBJtObject))); - + buffer = outBuffer; - + // make sure there is enough room for the basics if (*ioNumBytes < sizeof(OBJtObject)) { return UUcError_Generic; } - + // fill in the basic data OBJmWrite4BytesToBuffer(buffer, inObject->object_type, UUtUns32, *ioNumBytes); OBJmWrite4BytesToBuffer(buffer, inObject->position.x, float, *ioNumBytes); @@ -1930,53 +1930,53 @@ OBJiObject_FillBuffer( OBJmWrite4BytesToBuffer(buffer, inObject->rotation.x, float, *ioNumBytes); OBJmWrite4BytesToBuffer(buffer, inObject->rotation.y, float, *ioNumBytes); OBJmWrite4BytesToBuffer(buffer, inObject->rotation.z, float, *ioNumBytes); - + // fill in the type specific data switch (inObject->object_type) { case OBJcType_Character: error = OBJiObject_Character_FillBuffer(inObject, &buffer, ioNumBytes); break; - + case OBJcType_Flag: error = OBJiObject_Flag_FillBuffer(inObject, &buffer, ioNumBytes); break; - + case OBJcType_Furniture: error = OBJiObject_Furniture_FillBuffer(inObject, &buffer, ioNumBytes); break; - + case OBJcType_Machine: case OBJcType_LevelSpecificItem: error = UUcError_None; break; - + case OBJcType_PowerUp: error = OBJiObject_PowerUp_FillBuffer(inObject, &buffer, ioNumBytes); break; - + case OBJcType_Sound: error = OBJiObject_Sound_FillBuffer(inObject, &buffer, ioNumBytes); break; - + case OBJcType_TriggerVolume: error = OBJiObject_TrigVol_FillBuffer(inObject, &buffer, ioNumBytes);; break; - + case OBJcType_Weapon: error = OBJiObject_Weapon_FillBuffer(inObject, &buffer, ioNumBytes); break; - + default: UUmAssert(!"invalid object type"); error = UUcError_None; break; } UUmError_ReturnOnError(error); - + // set ioNumBytes to the number of bytes written into the buffer *ioNumBytes = buffer - outBuffer; - + return UUcError_None; } @@ -1991,37 +1991,37 @@ OBJrObject_Draw( OBJtObject *inObject) { UUmAssert(inObject); - + switch (inObject->object_type) { case OBJcType_Character: /* drawn elsewhere */ break; - + case OBJcType_Flag: break; - + case OBJcType_Furniture: OBJiObject_Furniture_Draw(inObject); break; - + case OBJcType_Machine: case OBJcType_LevelSpecificItem: break; - + case OBJcType_PowerUp: OBJiObject_PowerUp_Draw(inObject); break; - + case OBJcType_Sound: break; - + case OBJcType_TriggerVolume: if (OBJgDrawTriggers) { OBJiObject_TrigVol_Draw(inObject); } break; - + case OBJcType_Weapon: /* drawn elsewhere */ OBJiObject_Weapon_Draw(inObject); break; @@ -2036,45 +2036,45 @@ OBJrObject_Enumerate( UUtUns32 inUserData) { UUtError error; - + if (OBJiObjectType_IsValid(inObjectType) == UUcFalse) { return UUcError_Generic; } - + switch (inObjectType) { case OBJcType_Character: error = OBJiObject_EnumerateTemplate(TRcTemplate_CharacterClass, inObjectType, inObjectEnumCallback, inUserData); break; - + case OBJcType_Flag: error = OBJiObject_EnumerateTypeNames(OBJgFlagTypes, inObjectType, inObjectEnumCallback, inUserData); break; - + case OBJcType_Furniture: error = OBJiObject_EnumerateTemplate(M3cTemplate_Geometry, inObjectType, inObjectEnumCallback, inUserData); break; - + case OBJcType_Machine: case OBJcType_LevelSpecificItem: break; - + case OBJcType_PowerUp: error = OBJiObject_EnumerateTypeNames(OBJgPowerUpTypes, inObjectType, inObjectEnumCallback, inUserData); break; - + case OBJcType_Sound: // error = OBJiObject_EnumerateTypeNames(OBJgSoundTypes, inObjectType, inObjectEnumCallback, inUserData); break; - + case OBJcType_TriggerVolume: error = UUcError_None; break; - + case OBJcType_Weapon: error = OBJiObject_EnumerateTemplate(WPcTemplate_WeaponClass, inObjectType, inObjectEnumCallback, inUserData); break; } UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2086,40 +2086,40 @@ OBJrObject_GetObjectSpecificData( { UUmAssert(inObject); UUmAssert(outObjectSpecificData); - + // clear the object specific data structure UUrMemory_Clear(outObjectSpecificData, sizeof(OBJtOSD_All)); - + switch (inObject->object_type) { case OBJcType_Character: OBJiObject_Character_GetOSD(inObject, outObjectSpecificData); break; - + case OBJcType_Flag: OBJiObject_Flag_GetOSD(inObject, outObjectSpecificData); break; - + case OBJcType_Furniture: OBJiObject_Furniture_GetOSD(inObject, outObjectSpecificData); break; - + case OBJcType_Machine: case OBJcType_LevelSpecificItem: break; - + case OBJcType_PowerUp: OBJiObject_PowerUp_GetOSD(inObject, outObjectSpecificData); break; - + case OBJcType_Sound: OBJiObject_Sound_GetOSD(inObject, outObjectSpecificData); break; - + case OBJcType_TriggerVolume: OBJiObject_TrigVol_GetOSD(inObject, outObjectSpecificData); break; - + case OBJcType_Weapon: OBJiObject_Weapon_GetOSD(inObject, outObjectSpecificData); break; @@ -2136,7 +2136,7 @@ OBJrObject_GetPosition( UUmAssert(inObject); UUmAssert(outPosition); UUmAssert(outRotation); - + *outPosition = inObject->position; *outRotation = inObject->rotation; } @@ -2155,7 +2155,7 @@ OBJrObject_GetType( OBJtObject *inObject) { UUmAssert(inObject); - + return inObject->object_type; } @@ -2168,57 +2168,57 @@ OBJrObject_IntersectsLine( { M3tBoundingSphere sphere; OBJtOSD_All *osd_all; - + UUmAssert(inObject); UUmAssert(inStartPoint); UUmAssert(inEndPoint); UUrMemory_Clear(&sphere, sizeof(M3tBoundingSphere)); - + // get at pointer to the osd osd_all = (OBJtOSD_All*)inObject->object_data; - + switch (inObject->object_type) { case OBJcType_Character: break; - + case OBJcType_Flag: sphere.center.x = 0.0f; sphere.center.y = 0.0f; sphere.center.z = 0.0f; sphere.radius = 5.0f; break; - + case OBJcType_Furniture: sphere = osd_all->furniture_osd.geometry->pointArray->boundingSphere; break; - + case OBJcType_Machine: case OBJcType_LevelSpecificItem: break; - + case OBJcType_PowerUp: sphere = osd_all->powerup_osd.powerup->geometry->pointArray->boundingSphere; break; - + case OBJcType_Sound: break; - + case OBJcType_TriggerVolume: OBJiObject_TrigVol_GetBoundingSphere(inObject, &sphere); break; - + case OBJcType_Weapon: WPrGetPosition(osd_all->weapon_osd.weapon, &inObject->position); sphere = WPrGetClass(osd_all->weapon_osd.weapon)->geometry->pointArray->boundingSphere; break; } - + sphere.center.x += inObject->position.x; sphere.center.y += inObject->position.y; sphere.center.z += inObject->position.z; - + return CLrSphere_Line(inStartPoint, inEndPoint, &sphere); } @@ -2233,10 +2233,10 @@ OBJrObject_New( UUtError error; OBJtObject *object; UUtUns32 object_size; - + // make sure the object type is valid if (OBJiObjectType_IsValid(inObjectType) == UUcFalse) { return UUcError_Generic; } - + // calculate the amount of memory needed for the object object_size = sizeof(OBJtObject); switch (inObjectType) @@ -2244,99 +2244,99 @@ OBJrObject_New( case OBJcType_Character: object_size += sizeof(OBJtOSD_Character); break; - + case OBJcType_Flag: object_size += sizeof(OBJtOSD_Flag); break; - + case OBJcType_Furniture: object_size += sizeof(OBJtOSD_Furniture); break; - + case OBJcType_Machine: case OBJcType_LevelSpecificItem: break; - + case OBJcType_PowerUp: object_size += sizeof(OBJtOSD_PowerUp); break; - + case OBJcType_Sound: object_size += sizeof(OBJtOSD_Sound); break; - + case OBJcType_TriggerVolume: object_size += sizeof(OBJtOSD_TrigVol); break; - + case OBJcType_Weapon: object_size += sizeof(OBJtOSD_Weapon); break; } - + // allocate memory for the new object object = (OBJtObject*)UUrMemory_Block_NewClear(object_size); UUmError_ReturnOnNull(object); - + // add the object to the object list error = OBJiObjectList_AddObject(object); UUmError_ReturnOnError(error); - + // initialize the object object->object_type = inObjectType; object->position = *inPosition; object->rotation = *inRotation; - + switch (object->object_type) { case OBJcType_Character: error = OBJiObject_Character_New(object); break; - + case OBJcType_Flag: error = OBJiObject_Flag_New(object); break; - + case OBJcType_Furniture: error = OBJiObject_Furniture_New(object); break; - + case OBJcType_Machine: case OBJcType_LevelSpecificItem: error = UUcError_None; break; - + case OBJcType_PowerUp: error = OBJiObject_PowerUp_New(object); break; - + case OBJcType_Sound: error = OBJiObject_Sound_New(object); break; - + case OBJcType_TriggerVolume: error = OBJiObject_TrigVol_New(object);; break; - + case OBJcType_Weapon: error = OBJiObject_Weapon_New(object); break; } UUmError_ReturnOnError(error); - + // set the object specific data if (inObjectSpecificData != NULL) { error = OBJrObject_SetObjectSpecificData(object, inObjectSpecificData); UUmError_ReturnOnError(error); } - - // go through the set position code + + // go through the set position code OBJrObject_SetPosition(object, inPosition, inRotation); // select the newly created object OBJrObject_Select(object); - + return UUcError_None; } @@ -2347,66 +2347,66 @@ OBJrObject_Delete( { UUtUns32 i; UUtUns32 num_objects; - + UUmAssert(inObject); - + // get the number of objects to save num_objects = OBJiObjectList_GetNumObjects(); if (num_objects == 0) { return; } - + // find the index of the object to delete for (i = 0; i < num_objects; i++) { OBJtObject *object; - + // get the object object = OBJiObjectList_GetObject(i); if (object != inObject) { continue; } - + switch (object->object_type) { case OBJcType_Character: OBJiObject_Character_Delete(inObject); break; - + case OBJcType_Flag: OBJiObject_Flag_Delete(inObject); break; - + case OBJcType_Furniture: OBJiObject_Furniture_Delete(inObject); break; - + case OBJcType_Machine: case OBJcType_LevelSpecificItem: break; - + case OBJcType_PowerUp: OBJiObject_PowerUp_Delete(inObject); break; - + case OBJcType_Sound: OBJiObject_Sound_Delete(inObject); break; - + case OBJcType_TriggerVolume: OBJiObject_TrigVol_Delete(inObject); break; - + case OBJcType_Weapon: OBJiObject_Weapon_Delete(inObject); break; } - + // delete the object OBJiObjectList_DeleteObject(i); - + // set the selected object to NULL if it was the one deleted if (inObject == OBJgSelectedObject) { OBJgSelectedObject = NULL; } - + break; } } @@ -2439,52 +2439,52 @@ OBJrObject_SetObjectSpecificData( OBJtOSD_All *inObjectSpecificData) { UUtError error; - + UUmAssert(ioObject); UUmAssert(inObjectSpecificData); - + switch (ioObject->object_type) { case OBJcType_Character: error = OBJiObject_Character_SetOSD(ioObject, inObjectSpecificData); break; - + case OBJcType_Flag: error = OBJiObject_Flag_SetOSD(ioObject, inObjectSpecificData); break; - + case OBJcType_Furniture: error = OBJiObject_Furniture_SetOSD(ioObject, inObjectSpecificData); break; - + case OBJcType_Machine: case OBJcType_LevelSpecificItem: error = UUcError_None; break; - + case OBJcType_PowerUp: error = OBJiObject_PowerUp_SetOSD(ioObject, inObjectSpecificData); break; - + case OBJcType_Sound: error = OBJiObject_Sound_SetOSD(ioObject, inObjectSpecificData); break; - + case OBJcType_TriggerVolume: error = OBJiObject_TrigVol_SetOSD(ioObject, inObjectSpecificData);; break; - + case OBJcType_Weapon: error = OBJiObject_Weapon_SetOSD(ioObject, inObjectSpecificData); break; - + default: UUmAssert(!"invalid object type"); error = UUcError_Generic; break; } UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2498,40 +2498,40 @@ OBJrObject_SetPosition( UUmAssert(ioObject); UUmAssert(inPosition); UUmAssert(inRotation); - + ioObject->position = *inPosition; ioObject->rotation = *inRotation; - + switch (ioObject->object_type) { case OBJcType_Character: OBJiObject_Character_SetPosition(ioObject); break; - + case OBJcType_Flag: OBJiObject_Flag_SetPosition(ioObject); break; - + case OBJcType_Furniture: OBJiObject_Furniture_SetPosition(ioObject); break; - + case OBJcType_Machine: case OBJcType_LevelSpecificItem: break; - + case OBJcType_PowerUp: OBJiObject_PowerUp_SetPosition(ioObject); break; - + case OBJcType_Sound: OBJiObject_Sound_SetPosition(ioObject); break; - + case OBJcType_TriggerVolume: OBJiObject_TrigVol_SetPosition(ioObject); break; - + case OBJcType_Weapon: OBJiObject_Weapon_SetPosition(ioObject); break; @@ -2552,46 +2552,46 @@ OBJiOSD_ReadFromFile_1( OBJtOSD_All *outOSD) { UUtError error; - + UUmAssert(inObjectFile); UUmAssert(outOSD); - + switch (inObjectType) { case OBJcType_Character: error = OBJiObject_Flag_ReadFromFile_1(inObjectFile, inSwapIt, outOSD); break; - + case OBJcType_Flag: error = OBJiObject_Flag_ReadFromFile_1(inObjectFile, inSwapIt, outOSD); break; - + case OBJcType_Furniture: error = OBJiObject_Furniture_ReadFromFile_1(inObjectFile, inSwapIt, outOSD); break; - + case OBJcType_Machine: case OBJcType_LevelSpecificItem: break; - + case OBJcType_PowerUp: error = OBJiObject_PowerUp_ReadFromFile_1(inObjectFile, inSwapIt, outOSD); break; - + case OBJcType_Sound: error = OBJiObject_Sound_ReadFromFile_1(inObjectFile, inSwapIt, outOSD); break; - + case OBJcType_TriggerVolume: error = OBJiObject_TrigVol_ReadFromFile_1(inObjectFile, inSwapIt, outOSD); break; - + case OBJcType_Weapon: error = OBJiObject_Weapon_ReadFromFile_1(inObjectFile, inSwapIt, outOSD); break; } UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2603,27 +2603,27 @@ OBJrOSD_FlagToName( char *outName) { UUmAssert(outName); - + if (OBJiObjectType_IsValid(inObjectType) == UUcFalse) { return; } - + switch(inObjectType) { case OBJcType_Character: break; - + case OBJcType_Flag: OBJiFlagToString(inFlag, OBJgFlagTypes, outName); break; - + case OBJcType_Furniture: case OBJcType_Machine: case OBJcType_LevelSpecificItem: break; - + case OBJcType_PowerUp: OBJiFlagToString(inFlag, OBJgPowerUpTypes, outName); break; - + case OBJcType_Sound: case OBJcType_TriggerVolume: case OBJcType_Weapon: @@ -2640,27 +2640,27 @@ OBJrOSD_NameToFlag( { UUmAssert(inName); UUmAssert(outFlag); - + if (OBJiObjectType_IsValid(inObjectType) == UUcFalse) { return; } - + switch(inObjectType) { case OBJcType_Character: break; - + case OBJcType_Flag: OBJiStringToFlag(inName, OBJgFlagTypes, outFlag); break; - + case OBJcType_Furniture: case OBJcType_Machine: case OBJcType_LevelSpecificItem: break; - + case OBJcType_PowerUp: OBJiStringToFlag(inName, OBJgPowerUpTypes, outFlag); break; - + case OBJcType_Sound: case OBJcType_TriggerVolume: case OBJcType_Weapon: @@ -2681,39 +2681,39 @@ OBJrLevel_Load( UUtError error; BFtFileRef *object_file_ref; BFtFile *object_file; - + // no objects are selected OBJrObject_Select(NULL); // initialize the object list error = OBJiObjectList_Initialize(); UUmError_ReturnOnError(error); - + // initialize object file OBJgObjectFile = NULL; - + // create the object file ref error = OBJiObjectFile_MakeFileRef(inLevelNum, &object_file_ref); UUmError_ReturnOnError(error); - + // find the object file associated with this level if (OBJiObjectFile_FileExists(object_file_ref)) { // open the object file error = OBJiObjectFile_Open(object_file_ref, &object_file); UUmError_ReturnOnError(error); - + // parse the file and create the objects it contains error = OBJiObjectFile_CreateObjectsFromFile(object_file); UUmError_ReturnOnError(error); - + OBJgObjectFile = object_file; } - + // delete the file ref BFrFileRef_Dispose(object_file_ref); object_file_ref = NULL; - + return UUcError_None; } @@ -2724,7 +2724,7 @@ OBJrLevel_SaveObjects( { UUtError error; UUtUns16 level_num; - + // no objects are selected OBJrObject_Select(NULL); @@ -2733,15 +2733,15 @@ OBJrLevel_SaveObjects( { BFtFileRef *object_file_ref; BFtFile *object_file; - + // get the current level number level_num = ONrLevel_GetCurrentLevel(); if (level_num == 0) { return UUcError_Generic; } - + // create the object file ref error = OBJiObjectFile_MakeFileRef(level_num, &object_file_ref); UUmError_ReturnOnError(error); - + // if the file doesn't exist, create it if (OBJiObjectFile_FileExists(object_file_ref) == UUcFalse) { @@ -2749,23 +2749,23 @@ OBJrLevel_SaveObjects( error = OBJiObjectFile_New(object_file_ref); UUmError_ReturnOnError(error); } - + // open the object file error = OBJiObjectFile_Open(object_file_ref, &object_file); UUmError_ReturnOnError(error); - + OBJgObjectFile = object_file; - + // delete the file ref BFrFileRef_Dispose(object_file_ref); object_file_ref = NULL; - + if (OBJgObjectFile == NULL) { return UUcError_Generic; } } - + error = OBJiObjectFile_SaveObjectsToFile(OBJgObjectFile); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2776,12 +2776,12 @@ OBJrLevel_Unload( { // save the objects to the object file OBJrLevel_SaveObjects(); - + // close the object file OBJiObjectFile_Close(OBJgObjectFile); - + // terminate the object list - OBJiObjectList_Terminate(); + OBJiObjectList_Terminate(); } // ====================================================================== @@ -2799,35 +2799,35 @@ OBJrGetObjectUnderPoint( M3tPoint3D camera_position; M3tVector3D intersect_vector; OBJtObject *closest_to_camera; - + UUtUns32 i; UUtUns32 num_objects; - + float min_distance; M3tPoint3D start_point; M3tPoint3D end_point; - + // get the active camera M3rCamera_GetActive(&camera); UUmAssert(camera); - + // get the point on the near clip plane where the user clicked M3rPick_ScreenToWorld(camera, (UUtUns16)inPoint->x, (UUtUns16)inPoint->y, &world_point); - + // get the camera position CArGetPosition(&camera_position); - + // build a vector from the camera to the point on the near clip plane intersect_vector.x = world_point.x - camera_position.x; intersect_vector.y = world_point.y - camera_position.y; intersect_vector.z = world_point.z - camera_position.z; - + // normalize MUrNormalize(&intersect_vector); - + // multiply by some large number (5,000) to get a long line MUrVector_SetLength(&intersect_vector, 5000.0f); - + // set up vars for collision detection closest_to_camera = NULL; min_distance = 1000000.0f; @@ -2835,30 +2835,30 @@ OBJrGetObjectUnderPoint( end_point.x += intersect_vector.x; end_point.y += intersect_vector.y; end_point.z += intersect_vector.z; - + // loop through each object and find the one closest to the camera that // collides with the line num_objects = OBJiObjectList_GetNumObjects(); for (i = 0; i < num_objects; i++) { OBJtObject *object; - + object = OBJiObjectList_GetObject(i); - + // if the object collides with the line, see if it is the closest to the camera if (OBJrObject_IntersectsLine(object, &start_point, &end_point)) { M3tVector3D camera_to_object; float distance_to_object; - + // make the vector from the camera to the object camera_to_object.x = object->position.x - camera_position.x; camera_to_object.y = object->position.y - camera_position.y; camera_to_object.z = object->position.z - camera_position.z; - + // calculate the length from the camera to the object distance_to_object = MUrVector_Length(&camera_to_object); - + if (distance_to_object < min_distance) { // save closest object to camera @@ -2867,7 +2867,7 @@ OBJrGetObjectUnderPoint( } } } - + return closest_to_camera; } @@ -2892,23 +2892,23 @@ OBJiENVFile_GetNumGunkObjects( UUtUns32 num_objects; UUtUns32 i; UUtUns16 num_gunk_objects; - + num_objects = OBJiObjectList_GetNumObjects(); num_gunk_objects = 0; - + for (i = 0; i < num_objects; i++) { OBJtObject *object; - + object = OBJiObjectList_GetObject(i); if (object == NULL) { continue; } - + if (object->object_type == OBJcType_Furniture) { num_gunk_objects++; } } - + return num_gunk_objects; } @@ -2929,7 +2929,7 @@ OBJiENVFile_WriteNode( UUtUns32 points_size; UUtUns32 tri_faces_size; UUtUns32 materials_size; - + UUtUns16 index0; UUtUns16 index1; UUtUns16 index2; @@ -2938,44 +2938,44 @@ OBJiENVFile_WriteNode( // get a pointer to the geometry furniture_osd = (OBJtOSD_Furniture*)inObject->object_data; geometry = furniture_osd->geometry; - + // ------------------------------ // allocate memory for the node node = (MXtNode*)UUrMemory_Block_NewClear(sizeof(MXtNode)); - + // copy the name and parentName into the node UUrString_Copy(node->name, "", MXcMaxName); UUrString_Copy(node->parentName, "", MXcMaxName); - + // set the number of points node->numPoints = geometry->pointArray->numPoints; node->numTriangles = geometry->triNormalArray->numVectors; node->numMaterials = 1; - + #if (UUmEndian == UUmEndian_Big) UUrSwap_2Byte(&node->numPoints); UUrSwap_2Byte(&node->numTriangles); UUrSwap_2Byte(&node->numMaterials); #endif - + // write the node error = BFrFile_Write(inFile, sizeof(MXtNode), node); UUmError_ReturnOnError(error); - + UUrMemory_Block_Delete(node); node = NULL; - + // ------------------------------ // make the points points_size = sizeof(MXtPoint) * geometry->pointArray->numPoints; points = (MXtPoint*)UUrMemory_Block_NewClear(points_size); - + for (i = 0; i < geometry->pointArray->numPoints; i++) { points[i].point = geometry->pointArray->points[i]; points[i].normal = geometry->vertexNormalArray->vectors[i]; points[i].uv = geometry->texCoordArray->textureCoords[i]; - + #if (UUmEndian == UUmEndian_Big) UUrSwap_4Byte(&points[i].point.x); UUrSwap_4Byte(&points[i].point.y); @@ -2987,29 +2987,29 @@ OBJiENVFile_WriteNode( UUrSwap_4Byte(&points[i].uv.v); #endif } - + // ------------------------------ // make the triangles tri_faces_size = sizeof(MXtFace) * geometry->triNormalArray->numVectors; tri_faces = (MXtFace*)UUrMemory_Block_NewClear(tri_faces_size); curIndexPtr = geometry->triStripArray->indices; - + for (i = 0; i < geometry->triNormalArray->numVectors; i++) { index2 = *curIndexPtr++; - + if (index2 & 0x8000) { index0 = (index2 & 0x7FFF); index1 = *curIndexPtr++; index2 = *curIndexPtr++; } - + tri_faces[i].indicies[0] = index0; tri_faces[i].indicies[1] = index1; tri_faces[i].indicies[2] = index2; - tri_faces[i].indicies[3] = 0; + tri_faces[i].indicies[3] = 0; tri_faces[i].normal = geometry->triNormalArray->vectors[i]; tri_faces[i].material = 0; tri_faces[i].pad = 0; @@ -3028,57 +3028,57 @@ OBJiENVFile_WriteNode( index0 = index1; index1 = index2; } - + // ------------------------------ // make the materials materials_size = sizeof(MXtMaterial); materials = (MXtMaterial*)UUrMemory_Block_NewClear(materials_size); - + UUrString_Copy(materials->name, TMrInstance_GetInstanceName(geometry->baseMap), MXcMaxName); materials->alpha = 1.0f; - + for (i = 0; i < MXcMapping_Count; i++) { UUrString_Copy(materials->maps[i].name, "", MXcMaxName); } - + UUrString_Copy(materials->maps[1].name, TMrInstance_GetInstanceName(geometry->baseMap), MXcMaxName); materials->maps[1].amount = 1.0f; - + #if (UUmEndian == UUmEndian_Big) UUrSwap_4Byte(&materials->alpha); #endif - + // ------------------------------ // write user data - + // ------------------------------ // write points error = BFrFile_Write(inFile, points_size, points); UUmError_ReturnOnError(error); - + // ------------------------------ // write triangles error = BFrFile_Write(inFile, tri_faces_size, tri_faces); UUmError_ReturnOnError(error); - + // ------------------------------ // write quads - + // ------------------------------ // write markers - + // ------------------------------ // write materials error = BFrFile_Write(inFile, materials_size, materials); UUmError_ReturnOnError(error); - + // ------------------------------ // free the memory UUrMemory_Block_Delete(points); UUrMemory_Block_Delete(tri_faces); UUrMemory_Block_Delete(materials); - + return UUcError_None; } @@ -3094,16 +3094,16 @@ OBJrENVFile_Write( char filename[128]; MXtHeader *header; UUtUns32 i; - + // get the current level number level_num = ONrLevel_GetCurrentLevel(); if (level_num == 0) { return UUcError_Generic; } - + // create the env file ref sprintf(filename, "Level%d_Objects.ENV", level_num); error = BFrFileRef_MakeFromName(filename, &env_file_ref); UUmError_ReturnOnError(error); - + // create the .ENV file if it doesn't already exist if (BFrFileRef_FileExists(env_file_ref) == UUcFalse) { @@ -3111,58 +3111,58 @@ OBJrENVFile_Write( error = BFrFile_Create(env_file_ref); UUmError_ReturnOnError(error); } - + // open the object.env file error = BFrFile_Open(env_file_ref, "rw", &env_file); UUmError_ReturnOnError(error); - + // set the position to 0 error = BFrFile_SetPos(env_file, 0); UUmError_ReturnOnError(error); - + // create the MXtHeader header = (MXtHeader*)UUrMemory_Block_NewClear(sizeof(MXtHeader)); UUmError_ReturnOnNull(header); - + UUrString_Copy(header->stringENVF, "ENVF", 5); header->version = 0; header->numNodes = OBJiENVFile_GetNumGunkObjects(); header->time = 0; header->nodes = NULL; - + #if (UUmEndian == UUmEndian_Big) UUrSwap_4Byte(&header->version); UUrSwap_2Byte(&header->numNodes); - UUrSwap_2Byte(&header->time); + UUrSwap_2Byte(&header->time); #endif - + // write the header error = BFrFile_Write(env_file, sizeof(MXtHeader), header); UUmError_ReturnOnError(error); - + // dispose of the memory UUrMemory_Block_Delete(header); header = NULL; - + // create the MXtNodes for (i = 0; i < OBJiObjectList_GetNumObjects(); i++) { OBJtObject *object; - + object = OBJiObjectList_GetObject(i); if ((object == NULL) || (object->object_type != OBJcType_Furniture)) { continue; } - + error = OBJiENVFile_WriteNode(env_file, object); if (error != UUcError_None) { break; } } - + // close the file BFrFile_Close(env_file); env_file = NULL; - + // delete the file ref BFrFileRef_Dispose(env_file_ref); env_file_ref = NULL; - + return UUcError_None; -} \ No newline at end of file +} diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Obj_Tools.h b/OniProj/OniGameSource/Oni_Windows/Oni_Obj_Tools.h index 5d767d1..57fa50d 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Obj_Tools.h +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Obj_Tools.h @@ -28,7 +28,7 @@ typedef enum OBJtObjectType OBJcType_Sound = UUm4CharToUns32('S', 'N', 'D', 'G'), OBJcType_TriggerVolume = UUm4CharToUns32('T', 'R', 'G', 'V'), OBJcType_Weapon = UUm4CharToUns32('W', 'E', 'A', 'P') - + } OBJtObjectType; // ---------------------------------------------------------------------- @@ -38,7 +38,7 @@ typedef enum OBJtFlagType OBJcFlagType_CharacterStart = UUm4CharToUns32('C', 'H', 'A', 'R'), OBJcFlagType_MultiplayerSpawn = UUm4CharToUns32('M', 'P', 'S', 'P'), OBJcFlagType_Waypoint = UUm4CharToUns32('W', 'A', 'Y', 'P') - + } OBJtFlagType; typedef enum OBJtPowerUpType @@ -50,14 +50,14 @@ typedef enum OBJtPowerUpType OBJcPowerUpType_ShieldRed = UUm4CharToUns32('S', 'H', 'D', 'R'), OBJcPowerUpType_AmmoEnergy = UUm4CharToUns32('A', 'M', 'O', 'E'), OBJcPowerUpType_AmmoBallistic = UUm4CharToUns32('A', 'M', 'O', 'B') - + } OBJtPowerUpType; enum { WPcInventory_Use = 0, WPcInventory_Drop = 1 - + }; // ====================================================================== @@ -70,7 +70,7 @@ typedef UUtBool OBJtObjectType inObjectType, char *inObjectName, UUtUns32 inUserData); - + // ---------------------------------------------------------------------- // Object Specific Data structures // ---------------------------------------------------------------------- @@ -87,16 +87,16 @@ typedef struct OBJtOSD_Character UUtUns16 shield_blue[2]; UUtUns16 shield_red[2]; UUtUns16 team_number; - + UUtUns16 character_index; /* internal use only */ - + } OBJtOSD_Character; typedef struct OBJtOSD_Flag { OBJtFlagType flag_type; UUtUns16 flag_index; /* internal use only */ - + } OBJtOSD_Flag; typedef struct OBJtOSD_Furniture @@ -104,20 +104,20 @@ typedef struct OBJtOSD_Furniture char geometry_name[BFcMaxFileNameLength]; M3tGeometry *geometry; /* internal use only */ M3tMatrix4x3 rotation_matrix; /* internal use only */ - + } OBJtOSD_Furniture; typedef struct OBJtOSD_PowerUp { OBJtPowerUpType powerup_type; WPtPowerup *powerup; /* internal use only */ - + } OBJtOSD_PowerUp; typedef struct OBJtOSD_Sound { SStSound *sound; /* internal use only */ - + } OBJtOSD_Sound; typedef struct OBJtOSD_TrigVol @@ -126,14 +126,14 @@ typedef struct OBJtOSD_TrigVol M3tPoint3D scale; // M3tQuaternion orientation; UUtInt32 id; - + } OBJtOSD_TrigVol; typedef struct OBJtOSD_Weapon { char weapon_class_name[BFcMaxFileNameLength]; WPtWeapon *weapon; /* internal use only */ - + } OBJtOSD_Weapon; typedef struct OBJtOSD_All @@ -148,7 +148,7 @@ typedef struct OBJtOSD_All OBJtOSD_TrigVol trigvol_osd; OBJtOSD_Weapon weapon_osd; }; - + } OBJtOSD_All; // ====================================================================== @@ -159,29 +159,29 @@ OBJrOSD_FlagToName( UUtUns32 inFlag, OBJtObjectType inObjectType, char *outName); - + void OBJrOSD_NameToFlag( char *inName, OBJtObjectType inObjectType, UUtUns32 *outFlag); - + // ---------------------------------------------------------------------- void OBJrObjectList_DrawObjects( void); - + // ---------------------------------------------------------------------- void OBJrObject_Draw( OBJtObject *inObject); - + UUtError OBJrObject_Enumerate( OBJtObjectType inObjectType, OBJtObjectEnumCallback inObjectEnumCallback, UUtUns32 inUserData); - + void OBJrObject_GetObjectSpecificData( OBJtObject *inObject, @@ -196,17 +196,17 @@ OBJrObject_GetPosition( OBJtObject* OBJrObject_GetSelectedObject( void); - + OBJtObjectType OBJrObject_GetType( OBJtObject *inObject); - + UUtBool OBJrObject_IntersectsLine( OBJtObject *inObject, M3tPoint3D *inStartPoint, M3tPoint3D *inEndPoint); - + UUtError OBJrObject_New( OBJtObjectType inObjectType, @@ -217,7 +217,7 @@ OBJrObject_New( void OBJrObject_Delete( OBJtObject *inObject); - + void OBJrObject_DeleteSelected( void); @@ -225,18 +225,18 @@ OBJrObject_DeleteSelected( UUtError OBJrObject_Select( OBJtObject *inObject); - + UUtError OBJrObject_SetObjectSpecificData( OBJtObject *ioObject, OBJtOSD_All *inObjectSpecificData); - + void OBJrObject_SetPosition( OBJtObject *ioObject, M3tPoint3D *inPosition, M3tPoint3D *inRotation); - + // ---------------------------------------------------------------------- UUtError OBJrLevel_Load( @@ -249,7 +249,7 @@ OBJrLevel_SaveObjects( void OBJrLevel_Unload( void); - + // ---------------------------------------------------------------------- OBJtObject* OBJrGetObjectUnderPoint( @@ -265,4 +265,4 @@ OBJrENVFile_Write( void); // ====================================================================== -#endif /* ONI_OBJ_TOOLS_H */ \ No newline at end of file +#endif /* ONI_OBJ_TOOLS_H */ diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI.c index 0b1e1a2..e528756 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI.c @@ -1,13 +1,13 @@ #if TOOL_VERSION /* FILE: Oni_Win_AI.c - + AUTHOR: Michael Evans - + CREATED: April 11, 2000 - + PURPOSE: AI Windows - + Copyright (c) Bungie Software 2000 */ @@ -85,7 +85,7 @@ OWiChooseFlag_Callback( // ok, scan and select the correct current flag break; - + case WMcMessage_Destroy: break; @@ -94,7 +94,7 @@ OWiChooseFlag_Callback( { } break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -111,7 +111,7 @@ OWiChooseFlag_Callback( break; } break; - + default: handled = UUcFalse; break; @@ -128,7 +128,7 @@ OWiChooseFlag_Callback( WMrDialog_ModalEnd(inDialog, result_flag_id); } - + return handled; } @@ -187,7 +187,7 @@ OWiChoosePath_Callback( // ok, scan and select the correct current flag break; - + case WMcMessage_Destroy: break; @@ -196,7 +196,7 @@ OWiChoosePath_Callback( { } break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -216,7 +216,7 @@ OWiChoosePath_Callback( break; } break; - + default: handled = UUcFalse; break; @@ -233,7 +233,7 @@ OWiChoosePath_Callback( WMrDialog_ModalEnd(inDialog, result_path_id); } - + return handled; } @@ -245,7 +245,7 @@ UUtInt16 OWrChooseFlag(UUtInt16 inFlagID) object_specific_data.osd.flag_osd.id_number = inFlagID; object = OBJrObjectType_Search(OBJcType_Flag, OBJcSearch_FlagID, &object_specific_data); - + object = OWrSelectObject(OBJcType_Flag, object, UUcFalse, UUcTrue); if (NULL != object) { @@ -264,7 +264,7 @@ UUtUns16 OWrChoosePath(UUtUns16 inPathID) object_specific_data.osd.patrolpath_osd.id_number = inPathID; object = OBJrObjectType_Search(OBJcType_PatrolPath, OBJcSearch_PatrolPathID, &object_specific_data); - + object = OWrSelectObject(OBJcType_PatrolPath, object, UUcFalse, UUcFalse); if (NULL != object) { @@ -291,7 +291,7 @@ static UUtBool OWiIsPathNameValid(WMtDialog *inDialog, char *inString) } return string_is_valid; -} +} enum { @@ -395,10 +395,10 @@ void OWrAI_FindCurrentPath(void) { OBJtOSD_All osd_all; OBJtObject *object; - + // search for the currently selected patrol path osd_all.osd.patrolpath_osd.id_number = OWgCurrentPatrolPathID; - + // find the object object = OBJrObjectType_Search(OBJcType_PatrolPath, OBJcSearch_PatrolPathID, &osd_all); if (object == NULL) { @@ -557,4 +557,4 @@ void OWrAI_Display(void) } } -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI.h b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI.h index 8f37113..d9336a5 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI.h +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI.h @@ -1,13 +1,13 @@ #pragma once /* FILE: Oni_Win_AI.h - + AUTHOR: Michael Evans - + CREATED: April 11, 2000 - + PURPOSE: AI Windows - + Copyright (c) Bungie Software 2000 */ @@ -56,4 +56,4 @@ void OWrAI_Display(void); void OWrProp_BuildWeaponMenu(WMtPopupMenu *inPopupMenu, char *inCurrentClass); -#endif // ONI_WIN_AI_H \ No newline at end of file +#endif // ONI_WIN_AI_H diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Character.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Character.c index 3814af7..01fca4b 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Character.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Character.c @@ -1,13 +1,13 @@ #if TOOL_VERSION /* FILE: Oni_Win_AI_Character.c - + AUTHOR: Michael Evans - + CREATED: April 25, 2000 - + PURPOSE: AI Character Windows - + Copyright (c) Bungie Software 2000 */ @@ -109,7 +109,7 @@ static const char *OBJgJob_Name[AI2cGoal_Max] = "Neutral", "Panic" }; - + static const char *OBJgAlert_Name[AI2cAlertStatus_Max] = { "Lull", @@ -324,7 +324,7 @@ OWrProp_Char_Callback( WMtText *combat_description; WMtText *melee_description; WMtText *neutral_description; - + char string[100]; UUtUns32 alarm_bitmask; @@ -336,7 +336,7 @@ OWrProp_Char_Callback( UUtBool neutral_data_changed = UUcFalse; OBJrObject_GetObjectSpecificData(object, &object_specific_data); - + team_menu = (WMtPopupMenu *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_Team); weapon_menu = (WMtPopupMenu *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_Weapon); job_menu = (WMtPopupMenu *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_Job); @@ -373,13 +373,13 @@ OWrProp_Char_Callback( unkillable = (WMtCheckBox *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_Unkillable); infinite_ammo = (WMtCheckBox *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_InfiniteAmmo); omniscient = (WMtCheckBox *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_Omniscient); - has_lsi = (WMtCheckBox *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_HasLSI); + has_lsi = (WMtCheckBox *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_HasLSI); boss = (WMtCheckBox *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_Boss); upgrade_difficulty = (WMtCheckBox *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_UpgradeDifficulty); no_autodrop = (WMtCheckBox *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_NoAutoDrop); character_class = (WMtListBox *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_Class); - + job_data_prompt = (WMtText *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_JobDataPrompt); job_data_button = (WMtButton *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_JobDataSelect); job_data_edit = (WMtEditField *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_JobDataEdit); @@ -390,7 +390,7 @@ OWrProp_Char_Callback( neutral_description = (WMtText *) WMrDialog_GetItemByID(inDialog, OWTcCharProp_NeutralDescription); handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -484,13 +484,13 @@ OWrProp_Char_Callback( UUtUns16 item_id; WMtEditField *set_edit_field; - for(item_id = OWTcCharProp_InvUse; item_id < (OWTcCharProp_InvUse + OBJcCharInv_Max); item_id++) + for(item_id = OWTcCharProp_InvUse; item_id < (OWTcCharProp_InvUse + OBJcCharInv_Max); item_id++) { set_edit_field = (WMtEditField *) WMrDialog_GetItemByID(inDialog, item_id); WMrEditField_SetInt32(set_edit_field, object_specific_data.osd.character_osd.inventory[item_id - OWTcCharProp_InvUse][OBJcCharSlot_Use]); } - for(item_id = OWTcCharProp_InvDrop; item_id < (OWTcCharProp_InvDrop + OBJcCharInv_Max); item_id++) + for(item_id = OWTcCharProp_InvDrop; item_id < (OWTcCharProp_InvDrop + OBJcCharInv_Max); item_id++) { set_edit_field = (WMtEditField *) WMrDialog_GetItemByID(inDialog, item_id); WMrEditField_SetInt32(set_edit_field, object_specific_data.osd.character_osd.inventory[item_id - OWTcCharProp_InvDrop][OBJcCharSlot_Drop]); @@ -503,10 +503,10 @@ OWrProp_Char_Callback( melee_data_changed = UUcTrue; neutral_data_changed = UUcTrue; dirty = UUcTrue; - break; - + break; + case WMcMessage_Command: - switch(UUmLowWord(inParam1)) + switch(UUmLowWord(inParam1)) { case OWTcCharProp_JobDataSelect: if (AI2cGoal_Patrol == object_specific_data.osd.character_osd.job) { @@ -522,7 +522,7 @@ OWrProp_Char_Callback( job_data_changed = UUcTrue; dirty = UUcTrue; break; - + case WMcDialogItem_Cancel: WMrDialog_ModalEnd(inDialog, UUcFalse); break; @@ -750,7 +750,7 @@ OWrProp_Char_Callback( } dirty = UUcTrue; break; - + case OWTcCharProp_EditCombat: object_specific_data.osd.character_osd.combat_id = OWrChooseCombat(object_specific_data.osd.character_osd.combat_id); combat_data_changed = UUcTrue; @@ -772,7 +772,7 @@ OWrProp_Char_Callback( default: { UUtBool is_inventory = UUcFalse; - UUtUns16 *inventory_dataptr; + UUtUns16 *inventory_dataptr; UUtUns16 item_id = UUmLowWord(inParam1); if ((item_id >= OWTcCharProp_InvUse) && (item_id < (OWTcCharProp_InvUse + OBJcCharInv_Max))) { @@ -907,7 +907,7 @@ OWrProp_Char_Callback( dirty = UUcTrue; WMrWindow_SetTitle(job_data_description, "", WMcMaxTitleLength); - + switch(object_specific_data.osd.character_osd.job) { case AI2cGoal_Patrol: @@ -947,7 +947,7 @@ OWrProp_Char_Callback( melee_data_changed = UUcTrue; } } - + if (job_data_changed) { char job_data_changed_buffer[256]; @@ -980,7 +980,7 @@ OWrProp_Char_Callback( if (combat_data_changed) { OBJtOSD_Combat combat; char combat_description_buffer[256]; - UUtBool combat_found; + UUtBool combat_found; combat_found = ONrLevel_Combat_ID_To_Combat(object_specific_data.osd.character_osd.combat_id, &combat); @@ -1005,7 +1005,7 @@ OWrProp_Char_Callback( if (melee_data_changed) { AI2tMeleeProfile *profile; char melee_description_buffer[256]; - UUtBool melee_found; + UUtBool melee_found; melee_found = ONrLevel_Melee_ID_To_Melee_Ptr(object_specific_data.osd.character_osd.melee_id, &profile); @@ -1030,7 +1030,7 @@ OWrProp_Char_Callback( if (neutral_data_changed) { OBJtOSD_Neutral neutral; char neutral_description_buffer[256]; - UUtBool neutral_found; + UUtBool neutral_found; neutral_found = ONrLevel_Neutral_ID_To_Neutral(object_specific_data.osd.character_osd.neutral_id, &neutral); @@ -1055,4 +1055,4 @@ OWrProp_Char_Callback( return handled; } -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Combat.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Combat.c index 290c582..56d61cf 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Combat.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Combat.c @@ -1,13 +1,13 @@ #if TOOL_VERSION /* FILE: Oni_Win_Combat.c - + AUTHOR: Michael Evans - + CREATED: May 5, 2000 - + PURPOSE: AI Combat Windows - + Copyright (c) Bungie Software 2000 */ @@ -73,7 +73,7 @@ OWrEditCombat_Callback( WMtCheckBox *alarmknockdown_cb = WMrDialog_GetItemByID(inDialog, cEditCombat_AlarmKnockdown); WMtEditField *alarmattackdmg_edit = WMrDialog_GetItemByID(inDialog, cEditCombat_AlarmAttackDmg); WMtEditField *alarmfighttimer_edit = WMrDialog_GetItemByID(inDialog, cEditCombat_AlarmFightTimer); - + UUtBool checked, handled = UUcTrue, dirty = UUcFalse; OBJtObject *object = (OBJtObject *) WMrDialog_GetUserData(inDialog); @@ -107,7 +107,7 @@ OWrEditCombat_Callback( { UUtUns32 init_itr; - for(init_itr = 0; init_itr < AI2cCombatRange_NumStoredRanges; init_itr++) + for(init_itr = 0; init_itr < AI2cCombatRange_NumStoredRanges; init_itr++) { WMrPopupMenu_AppendStringList(behavior_menu[init_itr], AI2cBehavior_Max, AI2cBehaviorName); WMrPopupMenu_SetSelection(behavior_menu[init_itr], (UUtUns16) combat_osd->behavior[init_itr]); @@ -166,7 +166,7 @@ OWrEditCombat_Callback( case WMcMessage_Command: dirty = UUcTrue; - switch(UUmLowWord(inParam1)) + switch(UUmLowWord(inParam1)) { case cEditCombat_ID: combat_osd->id = (UUtUns16) WMrEditField_GetInt32(id_edit); @@ -260,7 +260,7 @@ UUtUns16 OWrChooseCombat(UUtUns16 inBehaviorID) object_specific_data.osd.combat_osd.id = inBehaviorID; object = OBJrObjectType_Search(OBJcType_Combat, OBJcSearch_CombatID, &object_specific_data); - + object = OWrSelectObject(OBJcType_Combat, object, UUcTrue, UUcFalse); if (NULL != object) { diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Combat.h b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Combat.h index e41ee1d..8562047 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Combat.h +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Combat.h @@ -1,13 +1,13 @@ #pragma once /* FILE: Oni_Win_Combat.h - + AUTHOR: Michael Evans - + CREATED: May 5, 2000 - + PURPOSE: AI Combat Windows - + Copyright (c) Bungie Software 2000 */ @@ -27,4 +27,4 @@ UUtBool OWrEditCombat_Callback( UUtUns32 inParam2); -#endif // ONI_WIN_AI_COMBAT_H \ No newline at end of file +#endif // ONI_WIN_AI_COMBAT_H diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Melee.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Melee.c index aaf5118..6d019ec 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Melee.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Melee.c @@ -1,13 +1,13 @@ #if TOOL_VERSION /* FILE: Oni_Win_AI_Melee.c - + AUTHOR: Chris Butcher - + CREATED: May 20, 2000 - + PURPOSE: AI Melee Profile Editor - + Copyright (c) Bungie Software 2000 */ @@ -88,7 +88,7 @@ enum typedef struct OWtEditMelee_UserData { OBJtObject *object; - + // pointers to all of the child windows WMtEditField *ef_id; WMtEditField *ef_name; @@ -201,7 +201,7 @@ OWiEditMelee_FillMoveList(WMtDialog *inDialog, // this is the first move of the technique current_state = AI2cMeleeMoveState_None; } - + // check to see if this would be a viable move here move_valid = AI2rMelee_MoveIsValid(inUserData->profile->char_class->animations, iterated_move, NULL, NULL, ¤t_state, NULL, &test_animation, &test_target, NULL); @@ -525,7 +525,7 @@ OWiEditMelee_FillTechniqueList(WMtDialog *inDialog, OWtEditMelee_UserData *inUse string_index = WMrListBox_AddString(inUserData->lb_techniquelist, item_text); - if (technique == inUserData->technique) + if (technique == inUserData->technique) selected_index = string_index; } @@ -543,7 +543,7 @@ OWiEditMelee_InitDialog(WMtDialog *inDialog) UUtError error; char *class_name; WMtMenuItemData menu_item; - + user_data = UUrMemory_Block_NewClear(sizeof(OWtEditMelee_UserData)); if (user_data == NULL) { // can't allocate space for user data, bail out @@ -626,7 +626,7 @@ OWiEditMelee_InitDialog(WMtDialog *inDialog) } } WMrListBox_SetSelection(user_data->lb_classlist, UUcFalse, class_index); - + // fill the move-type menu for (itr = 0; itr < AI2cMeleeNumMoveTypes; itr++) { menu_item.flags = WMcMenuItemFlag_Enabled; @@ -640,7 +640,7 @@ OWiEditMelee_InitDialog(WMtDialog *inDialog) // *** set up technique parameters WMrEditField_SetText(user_data->ef_name, user_data->profile->name); WMrEditField_SetInt32(user_data->ef_id, user_data->profile->id); - + WMrEditField_SetInt32(user_data->ef_notice, user_data->profile->attacknotice_percentage); WMrEditField_SetInt32(user_data->ef_dodgebase, user_data->profile->dodge_base_percentage); WMrEditField_SetInt32(user_data->ef_dmgamount, user_data->profile->dodge_damage_threshold); @@ -720,7 +720,7 @@ OWiEditMelee_MenuCommand(WMtDialog *inDialog, // switch to the new move type inUserData->current_movetype = inItemID; - // fill the move list with all moves of the new type that are + // fill the move list with all moves of the new type that are // valid considering our previous move OWiEditMelee_FillMoveList(inDialog, inUserData, prev_move); } @@ -878,7 +878,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, OWiEditMelee_FillTechniqueList(inDialog, inUserData); } break; - + case OWcEditMelee_TechniqueDelay: if (inUserData->technique != NULL) { inUserData->technique->delay_frames = WMrEditField_GetInt32(inUserData->ef_techniquedelay); @@ -966,7 +966,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, new_technique = &inUserData->profile->technique[inUserData->profile->num_actions + inUserData->profile->num_reactions]; // move all of the spacing behaviors down the array by one element - UUrMemory_MoveOverlap(new_technique, new_technique + 1, + UUrMemory_MoveOverlap(new_technique, new_technique + 1, inUserData->profile->num_spacing * sizeof(AI2tMeleeTechnique)); inUserData->profile->num_reactions++; @@ -974,7 +974,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, if (inUserData->profile->num_reactions > AI2cMeleeMaxTechniques) { char msg[200]; - sprintf(msg, "Melee profiles can currently only have %d techniques of a given category.", + sprintf(msg, "Melee profiles can currently only have %d techniques of a given category.", AI2cMeleeMaxTechniques); WMrDialog_MessageBox(inDialog, "Too many reactions", msg, WMcMessageBoxStyle_OK); } @@ -984,7 +984,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, new_technique = &inUserData->profile->technique[inUserData->profile->num_actions]; // move all of the reactions and spacing behaviors down the array by one element - UUrMemory_MoveOverlap(new_technique, new_technique + 1, + UUrMemory_MoveOverlap(new_technique, new_technique + 1, (inUserData->profile->num_reactions + inUserData->profile->num_spacing) * sizeof(AI2tMeleeTechnique)); inUserData->profile->num_actions++; @@ -992,7 +992,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, if (inUserData->profile->num_actions > AI2cMeleeMaxTechniques) { char msg[200]; - sprintf(msg, "Melee profiles can currently only have %d techniques of a given category.", + sprintf(msg, "Melee profiles can currently only have %d techniques of a given category.", AI2cMeleeMaxTechniques); WMrDialog_MessageBox(inDialog, "Too many actions", msg, WMcMessageBoxStyle_OK); } @@ -1020,7 +1020,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, WMrDialog_ModalEnd(inDialog, UUcFalse); return UUcTrue; } - + // display the new technique inUserData->technique = new_technique; OWiEditMelee_FillTechniqueList(inDialog, inUserData); @@ -1045,7 +1045,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, move_end = move_start + del_technique->num_moves; if ((move_end > move_start) && (move_end < inUserData->profile->num_moves)) { // we have to move all of the following moves up the array to pack them in - UUrMemory_MoveOverlap(inUserData->profile->move + move_end, inUserData->profile->move + move_start, + UUrMemory_MoveOverlap(inUserData->profile->move + move_end, inUserData->profile->move + move_start, (inUserData->profile->num_moves - move_end) * sizeof(AI2tMeleeMove)); // alter all of the techniques' stored move indices so that they still @@ -1069,7 +1069,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, if (technique_index < total_techniques - 1) { // move all of the techniques after this one up the array by one element - UUrMemory_MoveOverlap(del_technique + 1, del_technique, + UUrMemory_MoveOverlap(del_technique + 1, del_technique, (total_techniques - (technique_index + 1)) * sizeof(AI2tMeleeTechnique)); } @@ -1115,7 +1115,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, } else { UUmAssert(0); } - + // our techniques have changed - must re-prepare the profile for use and check // anim states error = AI2rMelee_PrepareForUse(inUserData->profile); @@ -1124,7 +1124,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, WMrDialog_ModalEnd(inDialog, UUcFalse); return UUcTrue; } - + // clear the technique pane inUserData->technique = NULL; OWiEditMelee_FillTechniqueList(inDialog, inUserData); @@ -1148,14 +1148,14 @@ OWiEditMelee_Command(WMtDialog *inDialog, // we are already at the top of one of the arrays break; } - + new_technique = inUserData->technique - 1; // swap the techniques in the array swap_technique = *(inUserData->technique); *(inUserData->technique) = *new_technique; *new_technique = swap_technique; - + // our techniques have changed - must re-prepare the profile for use and check // anim states error = AI2rMelee_PrepareForUse(inUserData->profile); @@ -1164,7 +1164,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, WMrDialog_ModalEnd(inDialog, UUcFalse); return UUcTrue; } - + // redraw the technique list inUserData->technique = new_technique; OWiEditMelee_FillTechniqueList(inDialog, inUserData); @@ -1188,14 +1188,14 @@ OWiEditMelee_Command(WMtDialog *inDialog, // we are already at the bottom of one of the arrays break; } - + new_technique = inUserData->technique + 1; // swap the techniques in the array swap_technique = *(inUserData->technique); *(inUserData->technique) = *new_technique; *new_technique = swap_technique; - + // our techniques have changed - must re-prepare the profile for use and check // anim states error = AI2rMelee_PrepareForUse(inUserData->profile); @@ -1204,7 +1204,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, WMrDialog_ModalEnd(inDialog, UUcFalse); return UUcTrue; } - + // redraw the technique list inUserData->technique = new_technique; OWiEditMelee_FillTechniqueList(inDialog, inUserData); @@ -1250,7 +1250,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, if (move_index < inUserData->profile->num_moves) { // this move is inserted in the middle of the move array - we must move all moves // following the insertion location down by one. - UUrMemory_MoveOverlap(new_move, new_move + 1, + UUrMemory_MoveOverlap(new_move, new_move + 1, (inUserData->profile->num_moves - move_index) * sizeof(AI2tMeleeMove)); // any techniques that stored their moves in this section of the array must have @@ -1294,7 +1294,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, WMrDialog_ModalEnd(inDialog, UUcFalse); return UUcTrue; } - + // display the new move - the technique may also be broken so redisplay its list OWiEditMelee_FillTechniqueList(inDialog, inUserData); OWiEditMelee_FillTechniqueMoveList(inDialog, inUserData); @@ -1323,7 +1323,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, if (move_index < inUserData->profile->num_moves - 1) { // this move is deleted from the middle of the move array - we must move all moves // following the insertion location up by one. - UUrMemory_MoveOverlap(inUserData->move + 1, inUserData->move, + UUrMemory_MoveOverlap(inUserData->move + 1, inUserData->move, (inUserData->profile->num_moves - (move_index + 1)) * sizeof(AI2tMeleeMove)); // any techniques that stored their moves in this section of the array must have @@ -1386,7 +1386,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, if (move_index == inUserData->technique->start_index) break; - + UUmAssert(move_index > 0); new_move = inUserData->move - 1; @@ -1394,7 +1394,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, swap_move = *(inUserData->move); *(inUserData->move) = *new_move; *new_move = swap_move; - + inUserData->move = new_move; // our moves have changed - must re-prepare the profile for use and check @@ -1433,7 +1433,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, if (move_index == inUserData->technique->start_index + inUserData->technique->num_moves - 1) break; - + UUmAssert(move_index < inUserData->profile->num_moves - 1); new_move = inUserData->move + 1; @@ -1441,7 +1441,7 @@ OWiEditMelee_Command(WMtDialog *inDialog, swap_move = *(inUserData->move); *(inUserData->move) = *new_move; *new_move = swap_move; - + inUserData->move = new_move; // our moves have changed - must re-prepare the profile for use and check @@ -1590,7 +1590,7 @@ OWrEditMelee_Callback( return handled; } - + @@ -1604,7 +1604,7 @@ UUtUns16 OWrChooseMelee(UUtUns16 inProfileID) object_specific_data.osd.melee_osd.id = inProfileID; object = OBJrObjectType_Search(OBJcType_Melee, OBJcSearch_MeleeID, &object_specific_data); - + object = OWrSelectObject(OBJcType_Melee, object, UUcTrue, UUcFalse); if (NULL != object) { @@ -1614,4 +1614,4 @@ UUtUns16 OWrChooseMelee(UUtUns16 inProfileID) return result; } -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Melee.h b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Melee.h index 712497a..e7ec038 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Melee.h +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Melee.h @@ -4,13 +4,13 @@ /* FILE: Oni_Win_AI_Melee.h - + AUTHOR: Chris Butcher - + CREATED: May 20, 2000 - + PURPOSE: AI Melee Profile Editor - + Copyright (c) Bungie Software 2000 */ diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Neutral.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Neutral.c index bd2e5a3..8be8d04 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Neutral.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Neutral.c @@ -1,13 +1,13 @@ #if TOOL_VERSION /* FILE: Oni_Win_AI_Neutral.c - + AUTHOR: Chris Butcher - + CREATED: July 13, 2000 - + PURPOSE: AI Neutral Behavior Windows - + Copyright (c) Bungie Software 2000 */ @@ -184,9 +184,9 @@ OWrEditNeutral_Callback( SStAmbient *new_sound; static UUtUns32 current_line; // ugly - would be better stored in user data but unfortunately userdata // is constrained by oni_win_tools to be a pointer to the object, no room - + OWtSelectResult result; - + OBJrObject_GetObjectSpecificData(object, &object_specific_data); neutral_osd = &object_specific_data.osd.neutral_osd; @@ -277,7 +277,7 @@ OWrEditNeutral_Callback( case WMcMessage_Command: dirty = UUcTrue; - switch(UUmLowWord(inParam1)) + switch(UUmLowWord(inParam1)) { case cEditNeutral_Name: WMrEditField_GetText(name_edit, neutral_osd->name, sizeof(neutral_osd->name)); @@ -290,7 +290,7 @@ OWrEditNeutral_Callback( dirty = UUcFalse; break; } - + if (new_sound == NULL) { neutral_osd->trigger_sound[0] = '\0'; } else { @@ -612,7 +612,7 @@ UUtUns16 OWrChooseNeutral(UUtUns16 inNeutralID) object_specific_data.osd.neutral_osd.id = inNeutralID; object = OBJrObjectType_Search(OBJcType_Neutral, OBJcSearch_NeutralID, &object_specific_data); - + object = OWrSelectObject(OBJcType_Neutral, object, UUcTrue, UUcFalse); if (object != NULL) { @@ -623,4 +623,4 @@ UUtUns16 OWrChooseNeutral(UUtUns16 inNeutralID) return result; } -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Neutral.h b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Neutral.h index ba2b1da..4400ea6 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Neutral.h +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Neutral.h @@ -1,13 +1,13 @@ #pragma once /* FILE: Oni_Win_Neutral.h - + AUTHOR: Chris Butcher - + CREATED: July 13, 2000 - + PURPOSE: AI Neutral Windows - + Copyright (c) Bungie Software 2000 */ diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Path.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Path.c index 5889ad2..f406501 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Path.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_AI_Path.c @@ -1,13 +1,13 @@ #if TOOL_VERSION /* FILE: Oni_Win_AI_Path.c - + AUTHOR: Michael Evans - + CREATED: April 24, 2000 - + PURPOSE: AI Pathing Windows - + Copyright (c) Bungie Software 2000 */ @@ -89,7 +89,7 @@ static char *cMovementModes[AI2cMovementMode_Max] = "Run" }; -static char *cMovementDirections[AI2cMovementDirection_Max] = +static char *cMovementDirections[AI2cMovementDirection_Max] = { "Forward", "Backpedal", @@ -119,7 +119,7 @@ static UUtInt16 AIrWaypoint_GetFlag(AI2tWaypoint *inWaypoint) case AI2cWaypointType_MoveThroughFlag: flag = inWaypoint->data.moveThroughFlag.flag; break; - + case AI2cWaypointType_GlanceAtFlag: flag = inWaypoint->data.glanceAtFlag.glanceFlag; break; @@ -163,7 +163,7 @@ static void AIrWaypoint_SetFlag(AI2tWaypoint *inWaypoint, UUtInt16 inFlag) case AI2cWaypointType_MoveThroughFlag: inWaypoint->data.moveThroughFlag.flag = inFlag; break; - + case AI2cWaypointType_GlanceAtFlag: inWaypoint->data.glanceAtFlag.glanceFlag = inFlag; break; @@ -201,7 +201,7 @@ static UUtBool AIrWaypoint_HasFlag(AI2tWaypoint *inWaypoint) case AI2cWaypointType_ShootAtFlag: has_flag = UUcTrue; break; - + default: has_flag = UUcFalse; break; @@ -604,7 +604,7 @@ OWiPathPoint_Edit_Callback( flag_id = OWgWaypointDefaultFlagID; } break; - + case WMcMessage_Destroy: break; @@ -678,7 +678,7 @@ OWiPathPoint_Edit_Callback( break; } break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -693,7 +693,7 @@ OWiPathPoint_Edit_Callback( case cPathPointEdit_Flag_Button: flag_id = OWrChooseFlag(flag_id); - + set_flag_id = UUcTrue; break; @@ -722,7 +722,7 @@ OWiPathPoint_Edit_Callback( break; } break; - + default: handled = UUcFalse; break; @@ -767,7 +767,7 @@ OWiPathPoint_Edit_Callback( } if (AI2cWaypointType_LookInDirection == waypoint->type) { - WMrPopupMenu_SetSelection(direction_popup, (UUtUns16) waypoint->data.lookInDirection.facing); + WMrPopupMenu_SetSelection(direction_popup, (UUtUns16) waypoint->data.lookInDirection.facing); } if (AIrWaypoint_HasIntParam(waypoint)) { @@ -784,7 +784,7 @@ OWiPathPoint_Edit_Callback( WMrEditField_SetInt32(flag_edittext, AIrWaypoint_GetFlag(waypoint)); } } - + return handled; } @@ -955,7 +955,7 @@ OWrPath_Edit_Callback( WMtEditField *id_edit = WMrDialog_GetItemByID(inDialog, cPathEdit_ID_Edit); WMtEditField *name_edit = WMrDialog_GetItemByID(inDialog, cPathEdit_Name_Edit); WMtCheckBox *cb_nearest = WMrDialog_GetItemByID(inDialog, cPathEdit_CB_ReturnToNearest); - + if (listbox != NULL) { selected_index = WMrMessage_Send(listbox, LBcMessage_GetSelection, 0, 0); } @@ -963,7 +963,7 @@ OWrPath_Edit_Callback( OBJrObject_GetObjectSpecificData(object, &object_specific_data); path = &object_specific_data.osd.patrolpath_osd; waypoints = path->waypoints; - + if (LBcError != selected_index) { selected_waypoint = waypoints + selected_index; } @@ -975,15 +975,15 @@ OWrPath_Edit_Callback( WMrEditField_SetInt32(id_edit, object_specific_data.osd.patrolpath_osd.id_number); WMrEditField_SetText(name_edit, object_specific_data.osd.patrolpath_osd.name); WMrCheckBox_SetCheck(cb_nearest, ((object_specific_data.osd.patrolpath_osd.flags & AI2cPatrolPathFlag_ReturnToNearest) > 0)); - + dirty = UUcTrue; object_name_changed = UUcTrue; } break; - + case WMcMessage_Destroy: break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -1000,8 +1000,8 @@ OWrPath_Edit_Callback( else { if (selected_index != LBcError) { UUrMemory_MoveOverlap( - waypoints + selected_index + 0, - waypoints + selected_index + 1, + waypoints + selected_index + 0, + waypoints + selected_index + 1, sizeof(AI2tWaypoint) * (path->num_waypoints - selected_index)); } else { @@ -1024,8 +1024,8 @@ OWrPath_Edit_Callback( else { if (selected_index != LBcError) { UUrMemory_MoveOverlap( - waypoints + selected_index + 1, - waypoints + selected_index + 2, + waypoints + selected_index + 1, + waypoints + selected_index + 2, sizeof(AI2tWaypoint) * (path->num_waypoints - selected_index - 1)); selected_index += 1; @@ -1046,8 +1046,8 @@ OWrPath_Edit_Callback( case cPathEdit_Delete: if (selected_index != LBcError) { UUrMemory_MoveOverlap( - waypoints + selected_index + 1, - waypoints + selected_index, + waypoints + selected_index + 1, + waypoints + selected_index, sizeof(AI2tWaypoint) * (path->num_waypoints - selected_index - 1)); path->num_waypoints -= 1; @@ -1055,7 +1055,7 @@ OWrPath_Edit_Callback( dirty = UUcTrue; } break; - + case cPathEdit_Edit: edit_selected_waypoint = UUcTrue; break; @@ -1072,7 +1072,7 @@ OWrPath_Edit_Callback( case cPathEdit_Up: if ((path->num_waypoints > 1) && (selected_index != LBcError) && (selected_index > 0)) { AI2tWaypoint swap_up; - + swap_up = waypoints[selected_index - 1]; waypoints[selected_index - 1] = waypoints[selected_index]; waypoints[selected_index] = swap_up; @@ -1081,11 +1081,11 @@ OWrPath_Edit_Callback( dirty = UUcTrue; } break; - + case cPathEdit_Down: if ((path->num_waypoints > 1) && (selected_index != LBcError) && ((selected_index + 1) < path->num_waypoints)) { AI2tWaypoint swap_down; - + swap_down = waypoints[selected_index + 1]; waypoints[selected_index + 1] = waypoints[selected_index]; waypoints[selected_index] = swap_down; @@ -1116,7 +1116,7 @@ OWrPath_Edit_Callback( } break; - + default: handled = UUcFalse; break; @@ -1162,7 +1162,7 @@ OWrPath_Edit_Callback( WMrDialog_ModalEnd(inDialog, UUcTrue); } - + return handled; } @@ -1223,7 +1223,7 @@ OWrAI_DropAndAddFlag( } else { OBJrObject_Delete(object); } - } + } if (!dialog_msg) { // user cancelled out of dialog @@ -1235,4 +1235,4 @@ OWrAI_DropAndAddFlag( OWgCurrentPatrolPath->name); return UUcTrue; } -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_ImpactEffects.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_ImpactEffects.c index 68a4a61..5806e6b 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_ImpactEffects.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_ImpactEffects.c @@ -35,7 +35,7 @@ typedef struct OWtIEprop { UUtUns32 entry_index; UUtUns32 selected_particle; - + } OWtIEprop; typedef struct OWtIEdata @@ -48,7 +48,7 @@ typedef struct OWtIEdata UUtUns32 entry_baseindex; UUtUns32 found_entries[ONcIEComponent_Max]; - + UUtBool clipboard_full; } OWtIEdata; @@ -72,7 +72,7 @@ OWiIEprop_EmptySound( return UUcFalse;*/ if (inSound->sound_name[0] != '\0') return UUcFalse; - + if (inSound->flags & ONcIESoundFlag_AICanHear) return UUcFalse; @@ -182,7 +182,7 @@ OWiIEprop_SetupParticleControls( // all decals created from impact effects are dynamic and have random rotation and default size sel_particle->effect_spec.location_data.decal.static_decal = UUcFalse; sel_particle->effect_spec.location_data.decal.random_rotation = UUcTrue; - for (itr = 0; itr < 5; itr++) + for (itr = 0; itr < 5; itr++) { WMrWindow_SetVisible(ef_params[itr], UUcFalse); WMrWindow_SetVisible(txt_params[itr], UUcFalse); @@ -271,13 +271,13 @@ OWiIEprop_DisplaySound( if (sound == NULL) { WMrCheckBox_SetCheck(ai_canhear, UUcFalse); WMrWindow_SetEnabled(ai_radius, UUcFalse); - WMrWindow_SetEnabled(ai_type, UUcFalse); + WMrWindow_SetEnabled(ai_type, UUcFalse); } else { // set the AI parameters if (sound->flags & ONcIESoundFlag_AICanHear) { WMrCheckBox_SetCheck(ai_canhear, UUcTrue); WMrWindow_SetEnabled(ai_radius, UUcTrue); - WMrWindow_SetEnabled(ai_type, UUcTrue); + WMrWindow_SetEnabled(ai_type, UUcTrue); WMrEditField_SetFloat(ai_radius, sound->ai_soundradius); if ((sound->ai_soundtype >= AI2cContactType_Sound_Ignore) && (sound->ai_soundtype <= AI2cContactType_Sound_Gunshot)) { @@ -288,7 +288,7 @@ OWiIEprop_DisplaySound( } else { WMrCheckBox_SetCheck(ai_canhear, UUcFalse); WMrWindow_SetEnabled(ai_radius, UUcFalse); - WMrWindow_SetEnabled(ai_type, UUcFalse); + WMrWindow_SetEnabled(ai_type, UUcFalse); } } @@ -371,7 +371,7 @@ OWiIEprop_InitDialog( // set up the popup menus mod_popup = WMrDialog_GetItemByID(inDialog, OWcIEprop_PM_ModType); WMrPopupMenu_SetSelection(mod_popup, entry->modifier); - + com_popup = WMrDialog_GetItemByID(inDialog, OWcIEprop_PM_Component); WMrPopupMenu_SetSelection(com_popup, entry->component); @@ -436,7 +436,7 @@ OWiIEprop_HandleCommand( UUtBool checked; properties = (OWtIEprop*)WMrDialog_GetUserData(inDialog); - + switch (UUmLowWord(inParam1)) { case OWcIEprop_Btn_OK: @@ -454,7 +454,7 @@ OWiIEprop_HandleCommand( { SStImpulse *impulse; OWtSelectResult result; - + sound = ONrImpactEffect_GetSound(properties->entry_index); if (sound == NULL) { error = OWiIEprop_NewSound(properties, &sound); @@ -468,9 +468,9 @@ OWiIEprop_HandleCommand( result = OWrSelect_ImpulseSound(&impulse); if (result == OWcSelectResult_Cancel) { break; } - + sound->impulse_ptr = impulse; - + if (sound->impulse_ptr == NULL) { UUrString_Copy(sound->sound_name, "", SScMaxNameLength); } else { @@ -479,7 +479,7 @@ OWiIEprop_HandleCommand( sound->impulse_ptr->impulse_name, SScMaxNameLength); } - + if (OWiIEprop_EmptySound(sound)) { // delete this empty sound entry entry = ONrImpactEffect_GetEntry(properties->entry_index); @@ -510,7 +510,7 @@ OWiIEprop_HandleCommand( if (sound == NULL) { break; } - + if (sound->impulse_ptr == NULL) { sound->impulse_ptr = OSrImpulse_GetByName(sound->sound_name); @@ -525,7 +525,7 @@ OWiIEprop_HandleCommand( break; } } - + // edit this sound OWrImpulseProperties_Display(inDialog, sound->impulse_ptr); @@ -574,7 +574,7 @@ OWiIEprop_HandleCommand( // we could set up proper defaults here if desired UUrMemory_Clear(&particle->effect_spec, sizeof(P3tEffectSpecification)); UUrString_Copy(particle->particle_class_name, "new_particle", P3cParticleClassNameLength + 1); - + // select the new particle ONrImpactEffect_GetParticles(properties->entry_index, &num_particles); properties->selected_particle = num_particles - 1; @@ -601,7 +601,7 @@ OWiIEprop_HandleCommand( if (properties->selected_particle == (UUtUns32) -1) { break; } - + WMrEditField_GetText((WMtEditField *) inControl, new_classname, P3cParticleClassNameLength + 1); particle = ONrImpactEffect_GetParticles(properties->entry_index, &num_particles); @@ -630,7 +630,7 @@ OWiIEprop_HandleCommand( if (properties->selected_particle == (UUtUns32) -1) { break; } - + particle = ONrImpactEffect_GetParticles(properties->entry_index, &num_particles); UUmAssert((properties->selected_particle >= 0) && (properties->selected_particle < num_particles)); sel_particle = particle + properties->selected_particle; @@ -656,7 +656,7 @@ OWiIEprop_HandleCommand( WMrEditField_GetFloat((WMtEditField *) inControl); } break; - + default: UUmAssert(!"OWiIEprop_HandleCommand: selected particle has unknown location type"); break; @@ -678,7 +678,7 @@ OWiIEprop_HandleCommand( if (properties->selected_particle == (UUtUns32) -1) { break; } - + particle = ONrImpactEffect_GetParticles(properties->entry_index, &num_particles); UUmAssert((properties->selected_particle >= 0) && (properties->selected_particle < num_particles)); sel_particle = particle + properties->selected_particle; @@ -700,7 +700,7 @@ OWiIEprop_HandleCommand( WMrCheckBox_GetCheck((WMtCheckBox *) inControl); } break; - + default: UUmAssert(!"OWiIEprop_HandleCommand: selected particle has unknown location type"); break; @@ -760,7 +760,7 @@ OWiIEprop_HandleCommand( } } break; - + case OWcIEprop_EF_AISoundRadius: sound = ONrImpactEffect_GetSound(properties->entry_index); @@ -790,9 +790,9 @@ OWiIEprop_HandleMenuCommand( ONtIESound *sound; UUtUns32 num_particles; UUtError error; - + properties = (OWtIEprop*)WMrDialog_GetUserData(inDialog); - + switch (WMrWindow_GetID(inPopupMenu)) { case OWcIEprop_PM_ModType: @@ -825,7 +825,7 @@ OWiIEprop_HandleMenuCommand( if (properties->selected_particle == (UUtUns32) -1) { break; } - + particle = ONrImpactEffect_GetParticles(properties->entry_index, &num_particles); UUmAssert((properties->selected_particle >= 0) && (properties->selected_particle < num_particles)); sel_particle = particle + properties->selected_particle; @@ -845,7 +845,7 @@ OWiIEprop_HandleMenuCommand( if (properties->selected_particle == (UUtUns32) -1) { break; } - + particle = ONrImpactEffect_GetParticles(properties->entry_index, &num_particles); UUmAssert((properties->selected_particle >= 0) && (properties->selected_particle < num_particles)); sel_particle = particle + properties->selected_particle; @@ -876,7 +876,7 @@ OWiIEprop_HandleMenuCommand( break; } } - break; + break; } } @@ -889,28 +889,28 @@ OWiIEprop_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiIEprop_InitDialog(inDialog); break; - + case WMcMessage_Command: OWiIEprop_HandleCommand(inDialog, inParam1, (WMtWindow*)inParam2); break; - + case WMcMessage_MenuCommand: OWiIEprop_HandleMenuCommand(inDialog, (WMtWindow*)inParam2, UUmLowWord(inParam1)); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -930,7 +930,7 @@ OWrIE_FillImpactListBox( UUtUns16 i; const char * item_name; char tempstring[64]; - + WMrMessage_Send(inListBox, LBcMessage_Reset, 0, 0); num_types = MArImpacts_GetNumTypes(); @@ -960,7 +960,7 @@ OWrIE_FillMaterialListBox( UUtUns16 i; const char * item_name; char tempstring[64]; - + WMrMessage_Send(inListBox, LBcMessage_Reset, 0, 0); num_types = MArMaterials_GetNumTypes(); @@ -994,10 +994,10 @@ OWiIE_FillEntryListBoxes( char textbuf[256]; MAtMaterialType material_type, parent_material_type; MAtMaterialType new_material_type; - + data = (OWtIEdata*)WMrDialog_GetUserData(inDialog); UUmAssert(data); - + // fill the attached entry list listbox = WMrDialog_GetItemByID(inDialog, OWcIE_LB_AttachedEntries); WMrMessage_Send(listbox, LBcMessage_Reset, 0, 0); @@ -1047,10 +1047,10 @@ OWiIE_FillEntryListBoxes( WMrMessage_Send(listbox, LBcMessage_AddString, index, 0); } - + material_type = new_material_type + 1; } while (material_type < MArMaterials_GetNumTypes()); - + // perform an impact lookup on the currently viewed node ONrImpactEffect_Lookup(data->cur_impact_type, data->cur_material_type, data->cur_mod_type, data->found_entries); @@ -1097,7 +1097,7 @@ OWiIE_HandleDelete( listbox = WMrDialog_GetItemByID(inDialog, OWcIE_LB_AttachedEntries); - result = + result = WMrDialog_MessageBox( inDialog, "Confirm Delete", @@ -1106,7 +1106,7 @@ OWiIE_HandleDelete( if (result == WMcDialogItem_No) { return; } - + selected = WMrMessage_Send(listbox, LBcMessage_GetSelection, 0, 0); if (selected == (UUtUns32) -1) { // nothing to delete! @@ -1145,13 +1145,13 @@ OWiIE_HandleEdit( UUtError error; UUtUns32 message; UUtBool doesnt_belong; - + data = (OWtIEdata*)WMrDialog_GetUserData(inDialog); UUmAssert(data); listbox = WMrDialog_GetItemByID(inDialog, OWcIE_LB_AttachedEntries); index = WMrMessage_Send(listbox, LBcMessage_GetItemData, 0, (UUtUns32)-1); - + if (index == (UUtUns32) -1) { // nothing selected return UUcError_None; @@ -1167,9 +1167,9 @@ OWiIE_HandleEdit( WMrListBox_SetSelection(listbox, UUcTrue, entry->material_type); } else { properties.entry_index = index; - + // edit the properties - error = + error = WMrDialog_ModalBegin( OWcDialog_Impact_Effect_Prop, inDialog, @@ -1177,7 +1177,7 @@ OWiIE_HandleEdit( (UUtUns32)&properties, &message); UUmError_ReturnOnError(error); - + // update the listboxes OWiIE_FillEntryListBoxes(inDialog); } @@ -1204,7 +1204,7 @@ OWiIE_HandleNew( WMcMessageBoxStyle_OK); return UUcError_None; } - + error = ONrImpactEffect_CreateImpactEntry(data->cur_impact_type, data->cur_material_type, &entry_index); if (error == UUcError_OutOfMemory) { errmsg = "Could not add new entry; out of memory!"; @@ -1219,7 +1219,7 @@ OWiIE_HandleNew( // re-fill the listboxes OWiIE_FillEntryListBoxes(inDialog); - + return UUcError_None; } @@ -1249,7 +1249,7 @@ OWiIE_InitDialog( listbox = WMrDialog_GetItemByID(inDialog, OWcIE_LB_Impact); OWrIE_FillImpactListBox(inDialog, listbox); WMrListBox_SetSelection(listbox, UUcFalse, MAcImpact_Base); - + listbox = WMrDialog_GetItemByID(inDialog, OWcIE_LB_Material); OWrIE_FillMaterialListBox(inDialog, listbox); WMrListBox_SetSelection(listbox, UUcFalse, MAcMaterial_Base); @@ -1280,7 +1280,7 @@ OWiIE_HandleCopy( listbox = WMrDialog_GetItemByID(inDialog, OWcIE_LB_AttachedEntries); index = WMrMessage_Send(listbox, LBcMessage_GetItemData, 0, (UUtUns32)-1); - + if (index == (UUtUns32) -1) { // nothing selected return; @@ -1337,9 +1337,9 @@ OWiIE_HandlePaste( WMrDialog_MessageBox(inDialog, "Error", errmsg, WMcMessageBoxStyle_OK); return; } - + // fill the entry listboxes - OWiIE_FillEntryListBoxes(inDialog); + OWiIE_FillEntryListBoxes(inDialog); } // ---------------------------------------------------------------------- @@ -1348,12 +1348,12 @@ OWiIE_Destroy( WMtDialog *inDialog) { OWtIEdata *data; - + data = (OWtIEdata *) WMrDialog_GetUserData(inDialog); if (data != NULL) { UUrMemory_Block_Delete(data); } - + // stop the timer and save the data WMrTimer_Stop(0, inDialog); ONrImpactEffects_Save(UUcFalse); @@ -1399,7 +1399,7 @@ OWiIE_HandleCommand( case WMcDialogItem_Cancel: WMrDialog_ModalEnd(inDialog, 0); break; - + case OWcIE_LB_Impact: data->cur_impact_type = (MAtImpactType) WMrListBox_GetSelection((WMtListBox *) inControl); OWiIE_FillEntryListBoxes(inDialog); @@ -1416,14 +1416,14 @@ OWiIE_HandleCommand( } selected_item = WMrMessage_Send(inControl, LBcMessage_GetSelection, 0, 0); - + // disable delete and copy buttons if nothing is selected button = WMrDialog_GetItemByID(inDialog, OWcIE_Btn_Delete); WMrWindow_SetEnabled(button, (selected_item != (UUtUns32) -1)); button = WMrDialog_GetItemByID(inDialog, OWcIE_Btn_Copy); WMrWindow_SetEnabled(button, (selected_item != (UUtUns32) -1)); break; - + case OWcIE_LB_FoundEntries: WMrMessage_Send(inControl, LBcMessage_SetSelection, UUcFalse, (UUtUns32) -1); break; @@ -1431,19 +1431,19 @@ OWiIE_HandleCommand( case OWcIE_Btn_Delete: OWiIE_HandleDelete(inDialog); break; - + case OWcIE_Btn_Copy: OWiIE_HandleCopy(inDialog); break; - + case OWcIE_Btn_Paste: OWiIE_HandlePaste(inDialog); break; - + case OWcIE_Btn_Edit: OWiIE_HandleEdit(inDialog); break; - + case OWcIE_Btn_New: OWiIE_HandleNew(inDialog); break; @@ -1472,15 +1472,15 @@ OWiIE_HandleDrawItem( // get a pointer to the partspec_ui partspec_ui = PSrPartSpecUI_GetActive(); UUmAssert(partspec_ui); - + // set the dest dest.x = inDrawItem->rect.left; dest.y = inDrawItem->rect.top; - + // calc the width and height of the line line_width = inDrawItem->rect.right - inDrawItem->rect.left; line_height = inDrawItem->rect.bottom - inDrawItem->rect.top; - + if (inDrawItem->rect.top > 5) { // draw a divider @@ -1493,23 +1493,23 @@ OWiIE_HandleDrawItem( 2, M3cMaxAlpha); } - + // draw the Text DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrText_SetStyle(TScStyle_Plain); DCrText_SetShade(doesnt_belong ? IMcShade_Gray50 : IMcShade_Black); - + dest.x = 5; dest.y += 1; // get the impact entry entry = ONrImpactEffect_GetEntry(index); - + // draw the impact type name name = MArImpactType_GetName(entry->impact_type); DCrDraw_String(inDrawItem->draw_context, name, &inDrawItem->rect, &dest); dest.x += 100; - + // draw the material type name name = MArMaterialType_GetName(entry->material_type); DCrDraw_String(inDrawItem->draw_context, name, &inDrawItem->rect, &dest); @@ -1519,15 +1519,15 @@ OWiIE_HandleDrawItem( name = ONrIEComponent_GetName(entry->component); DCrDraw_String(inDrawItem->draw_context, name, &inDrawItem->rect, &dest); dest.x += 60; - + // draw the modifier name name = ONrIEModType_GetName(entry->modifier); - DCrDraw_String(inDrawItem->draw_context, name, &inDrawItem->rect, &dest); + DCrDraw_String(inDrawItem->draw_context, name, &inDrawItem->rect, &dest); dest.x += 60; - + // get a description of the entry ONrImpactEffect_GetDescription(index, description); - DCrDraw_String(inDrawItem->draw_context, description, &inDrawItem->rect, &dest); + DCrDraw_String(inDrawItem->draw_context, description, &inDrawItem->rect, &dest); } // ---------------------------------------------------------------------- @@ -1539,9 +1539,9 @@ OWiIE_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + UUrMemory_Block_VerifyList(); ONrImpactEffect_VerifyStructure(UUcTrue); @@ -1550,32 +1550,32 @@ OWiIE_Callback( case WMcMessage_InitDialog: OWiIE_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiIE_Destroy(inDialog); break; - + case WMcMessage_Command: OWiIE_HandleCommand(inDialog, inParam1, (WMtWindow*)inParam2); break; - + case WMcMessage_MenuCommand: OWiIE_HandleMenuCommand(inDialog, (WMtWindow*)inParam2, UUmLowWord(inParam1)); break; - + case WMcMessage_Timer: ONrImpactEffects_Save(UUcTrue); break; - + case WMcMessage_DrawItem: OWiIE_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + UUrMemory_Block_VerifyList(); ONrImpactEffect_VerifyStructure(UUcTrue); @@ -1588,7 +1588,7 @@ OWrImpactEffect_Display( void) { UUtError error; - + error = WMrDialog_ModalBegin( OWcDialog_Impact_Effect, @@ -1597,7 +1597,7 @@ OWrImpactEffect_Display( 0, NULL); UUmError_ReturnOnError(error); - + return UUcError_None; } -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_ImpactEffects.h b/OniProj/OniGameSource/Oni_Windows/Oni_Win_ImpactEffects.h index d4e7447..73ab7ca 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_ImpactEffects.h +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_ImpactEffects.h @@ -29,7 +29,7 @@ enum OWcIE_Btn_Edit = 107, OWcIE_Btn_New = 108, OWcIE_Txt_Lookup = 109, - OWcIE_PM_Modifier = 111 + OWcIE_PM_Modifier = 111 }; // ------------------------------ @@ -88,4 +88,4 @@ OWrIE_FillImpactListBox( WMtListBox *inListBox); // ====================================================================== -#endif /* ONI_WIN_IMPACTEFFECTS_H */ \ No newline at end of file +#endif /* ONI_WIN_IMPACTEFFECTS_H */ diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Multiplayer.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Multiplayer.c index c3c03e0..b839487 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Multiplayer.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Multiplayer.c @@ -27,7 +27,7 @@ typedef struct OWtNet_ServerInfoArray { ONtNet_ServerInfo server_info; NMtNetAddress server_address; - + } OWtNet_ServerInfoArray; typedef struct OWtMPHost_Info @@ -35,7 +35,7 @@ typedef struct OWtMPHost_Info char host_name[ONcMaxHostNameLength + 1]; UUtUns16 level_number; ONtNetGameOptions game_options; - + } OWtMPHost_Info; typedef struct OWtMPJoin_Info @@ -49,7 +49,7 @@ typedef struct OWtMPJoin_Info typedef struct OWtMP_PlayerInfo { char team_name[ONcMaxTeamNameLength + 1]; - + } OWtMP_PlayerInfo; // ====================================================================== @@ -72,7 +72,7 @@ OWiMP_JoinServer( char *inHostAddress) { UUtError error; - + // start a client error = ONrNet_Client_Start(ONcNet_DefaultClientPort); if ((error != UUcError_None) && (error != UUcError_Client_AlreadyStarted)) @@ -80,7 +80,7 @@ OWiMP_JoinServer( UUrError_Report(error, "Unable to start the client"); return UUcFalse; } - + // join the host error = ONrNet_Client_Join( @@ -92,16 +92,16 @@ OWiMP_JoinServer( if (error != UUcError_None) { UUrError_Report(error, "Unable to join the server"); - + error = ONrNet_Client_Stop(); if (error != UUcError_None) { UUrError_Report(error, "Unable to stop the client"); } - + return UUcFalse; } - + return UUcTrue; } @@ -121,7 +121,7 @@ OWiMPHost_SaveInfo( UUtUns32 num_bots; UUtUns32 max_kills; UUtUns32 time_limit; - + OWgMPHost_Info.game_options.game_parameters = ONcNetGameParam_None; // save the host name @@ -134,7 +134,7 @@ OWiMPHost_SaveInfo( (UUtUns32)OWgMPHost_Info.host_name, ONcMaxHostNameLength); } - + // get the level number OWgMPHost_Info.level_number = OWrLevelList_GetLevelNumber(inDialog, OWcMPHost_LB_Level); @@ -150,7 +150,7 @@ OWiMPHost_SaveInfo( OWgMPHost_Info.game_options.num_AIs = (UUtUns16)num_bots; } } - + // save the max kills window = WMrDialog_GetItemByID(inDialog, OWcMPHost_EF_MaxKills); if (window) @@ -163,7 +163,7 @@ OWiMPHost_SaveInfo( OWgMPHost_Info.game_options.kill_limit = (UUtUns16)max_kills; } } - + // save the num minutes window = WMrDialog_GetItemByID(inDialog, OWcMPHost_EF_NumMinutes); if (window) @@ -185,14 +185,14 @@ OWiMPHost_SetInfo( { WMtWindow *window; char string[255]; - + // set the host name window = WMrDialog_GetItemByID(inDialog, OWcMPHost_EF_HostName); if (window != NULL) { WMrMessage_Send(window, EFcMessage_SetText, (UUtUns32)OWgMPHost_Info.host_name, 0); } - + // set the number of bots window = WMrDialog_GetItemByID(inDialog, OWcMPHost_EF_NumBots); if (window != NULL) @@ -200,7 +200,7 @@ OWiMPHost_SetInfo( sprintf(string, "%d", OWgMPHost_Info.game_options.num_AIs); WMrMessage_Send(window, EFcMessage_SetText, (UUtUns32)string, 0); } - + // set the kill limit window = WMrDialog_GetItemByID(inDialog, OWcMPHost_EF_MaxKills); if (window != NULL) @@ -208,7 +208,7 @@ OWiMPHost_SetInfo( sprintf(string, "%d", OWgMPHost_Info.game_options.kill_limit); WMrMessage_Send(window, EFcMessage_SetText, (UUtUns32)string, 0); } - + // set the time limit window = WMrDialog_GetItemByID(inDialog, OWcMPHost_EF_NumMinutes); if (window != NULL) @@ -227,42 +227,42 @@ OWrMPHost_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWrLevelList_Initialize(inDialog, OWcMPHost_LB_Level); OWiMPHost_SetInfo(inDialog); break; - + case WMcMessage_Destroy: OWiMPHost_SaveInfo(inDialog); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { case WMcDialogItem_OK: // only respond to clicks if (UUmHighWord(inParam1) != WMcNotify_Click) { break; } - + // save the MPHost info before deleting the dialog OWiMPHost_SaveInfo(inDialog); WMrWindow_Delete(inDialog); - + // post the message to start a multiplayer game WMrMessage_Post(NULL, OWcMessage_MPHost, 0, 0); break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -273,14 +273,14 @@ OWrMPHost_StartServer( { UUtError error; UUtBool result; - + // make sure that hte level number is valid if ((OWgMPHost_Info.level_number == (UUtUns16)(-1)) || (OWgMPHost_Info.level_number == 0)) { return UUcFalse; } - + // start the server error = ONrNet_Server_Start( @@ -293,7 +293,7 @@ OWrMPHost_StartServer( UUrError_Report(error, "Unable to start host"); return UUcFalse; } - + // join the host on this machine result = OWiMP_JoinServer(ONrNet_Server_GetAddress()); if (result == UUcFalse) @@ -303,10 +303,10 @@ OWrMPHost_StartServer( { UUrError_Report(error, "Unable to stop the host"); } - + return UUcFalse; } - + // run the game WMrMessage_Post(NULL, OWcMessage_RunGame, 0, 0); @@ -333,33 +333,33 @@ OWiMPJoin_FindServers_Callback( UUtBool server_in_list; UUtUns32 index; UUtBool mem_moved; - + UUmAssert(inServerInfo); UUmAssert(inServerAddress); - + UUmAssert(OWgMPJoin_Servers); if (OWgMPJoin_Servers == NULL) { return; } - + // get a pointer to the dialog mp_join_dialog = (WMtDialog*)inUserParam; UUmAssert(mp_join_dialog); if (mp_join_dialog == NULL) { return; } - + // get a pointer to the server listbox server_listbox = WMrDialog_GetItemByID(mp_join_dialog, OWcMPJoin_LB_Servers); UUmAssert(server_listbox); if (server_listbox == NULL) { return; } - + // get a pointer to the server info array server_info_array = (OWtNet_ServerInfoArray*)UUrMemory_Array_GetMemory(OWgMPJoin_Servers); num_servers = UUrMemory_Array_GetUsedElems(OWgMPJoin_Servers); - + // check to see if this server's info has already been received server_in_list = UUcFalse; for (index = 0; index < num_servers; index++) { UUtUns16 result; - + result = strcmp( server_info_array[index].server_info.server_name, @@ -370,9 +370,9 @@ OWiMPJoin_FindServers_Callback( break; } } - + if (server_in_list == UUcTrue) { return; } - + // add the server info to the array error = UUrMemory_Array_GetNewElement( @@ -380,23 +380,23 @@ OWiMPJoin_FindServers_Callback( &index, &mem_moved); if (error != UUcError_None) return; - + // get a fresh pointer to the memory server_info_array = (OWtNet_ServerInfoArray*)UUrMemory_Array_GetMemory(OWgMPJoin_Servers); UUmAssert(server_info_array); if (server_info_array == NULL) { return; } - + // copy the server info into the array UUrMemory_MoveFast( inServerInfo, &server_info_array[index].server_info, sizeof(ONtNet_ServerInfo)); - + UUrMemory_MoveFast( inServerAddress, &server_info_array[index].server_address, sizeof(NMtNetAddress)); - + // add the server info to the listbox WMrMessage_Send( server_listbox, @@ -414,26 +414,26 @@ OWiMPJoin_SaveInfo( OWtNet_ServerInfoArray *server_info_array; UUtUns32 current_selection; char *server_address_string; - + // get the server address listbox = WMrDialog_GetItemByID(inDialog, OWcMPJoin_LB_Servers); if (listbox == NULL) { return; } - + // get the current selection current_selection = WMrMessage_Send(listbox, LBcMessage_GetSelection, 0, 0); - + // get the server address if (current_selection == (UUtUns32)(-1)) { return; } - + // get the server info array server_info_array = (OWtNet_ServerInfoArray*)UUrMemory_Array_GetMemory(OWgMPJoin_Servers); if (server_info_array == NULL) { return; } - + server_address_string = NMrAddressToString(&server_info_array[current_selection].server_address); - + // save the address of the server - UUrString_Copy(OWgMPJoin_Info.server_address, server_address_string, OWcMaxHostAddressLength); + UUrString_Copy(OWgMPJoin_Info.server_address, server_address_string, OWcMaxHostAddressLength); } // ---------------------------------------------------------------------- @@ -442,21 +442,21 @@ OWiMPJoin_Initialize( WMtDialog *inDialog) { UUtBool status; - + status = WMrTimer_Start(20, 1, inDialog); if (status == UUcFalse) { return; } - + // allocate memory for the server info if (OWgMPJoin_Servers == NULL) { - OWgMPJoin_Servers = + OWgMPJoin_Servers = UUrMemory_Array_New( sizeof(OWtNet_ServerInfoArray), 1, 0, 0); } - + // find the available servers ONrNet_FindServers_Start(OWiMPJoin_FindServers_Callback, (UUtUns32)inDialog); } @@ -471,10 +471,10 @@ OWiMPJoin_Destroy( // stop finding servers ONrNet_FindServers_Stop(); - + // stop the timer WMrTimer_Stop(20, inDialog); - + // release the server info array if (OWgMPJoin_Servers) { @@ -508,47 +508,47 @@ OWrMPJoin_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiMPJoin_Initialize(inDialog); break; - + case WMcMessage_Destroy: OWiMPJoin_Destroy(inDialog); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { case WMcDialogItem_OK: /* join button */ // only respond to clicks if (UUmHighWord(inParam1) != WMcNotify_Click) { break; } - + // save the join information OWiMPJoin_SaveInfo(inDialog); WMrWindow_Delete(inDialog); OWgMPJoin_LevelHasLoaded = UUcFalse; - + // post the join message WMrMessage_Post(NULL, OWcMessage_MPJoin, 0, 0); break; } break; - + case WMcMessage_Timer: ONrNet_FindServers_Update(); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -564,13 +564,13 @@ OWrMPJoin_HandleMessage( { return; } - + // register the callback ONrNet_Level_Callback_Register(OWiMPJoin_LevelLoaded_Callback); - + // know when to stop stop_time = UUrMachineTime_Sixtieths() + (10 * 60); - + // wait for the level to load while ((OWgMPJoin_LevelHasLoaded == UUcFalse) && (stop_time > UUrMachineTime_Sixtieths())) @@ -578,7 +578,7 @@ OWrMPJoin_HandleMessage( ONrNet_Update_Receive(); ONrNet_Update_Send(); } - + // run the game if the level has loaded if (OWgMPJoin_LevelHasLoaded) { @@ -604,12 +604,12 @@ OWrMP_Initialize( OWgMPHost_Info.game_options.time_limit = 0; OWgMPHost_Info.game_options.kill_limit = 0; OWgMPHost_Info.game_options.num_AIs = 0; - + OWgMPJoin_Info.server_address[0] = '\0'; OWgMPJoin_Info.password[0] = '\0'; OWgMPJoin_Info.remember_password = UUcFalse; - + UUrString_Copy(OWgMP_PlayerInfo.team_name, "team_name", ONcMaxTeamNameLength); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Particle.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Particle.c index 9334177..0243cfe 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Particle.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Particle.c @@ -201,7 +201,7 @@ static void OWiFillVariableMenu(WMtPopupMenu *inMenu, P3tDataType inType, item_data.flags = WMcMenuItemFlag_Enabled; item_data.id = itr; strcpy(item_data.title, inDefinition->variable[itr].name); - + WMrPopupMenu_AppendItem(inMenu, &item_data); if ((select_item != NULL) && (strcmp(select_item, item_data.title) == 0)) @@ -224,19 +224,19 @@ static void OWiDescribeValue(P3tParticleClass *inClass, P3tDataType inDataType, (inValue->type == P3cValueType_String)) { const char *sound_name; SStAmbient *ambient; - + // get this ambient sound's name sound_name = inValue->u.string_const.val; - + // get the ambient sound ambient = OSrAmbient_GetByName(sound_name); if (ambient == NULL) { sprintf(outString, "ambient sound %s ''", sound_name); return; } - + sprintf(outString, "ambient sound '%s'", sound_name); - + /* UUtUns32 sound_id; OStCollection *ambient_collection; OStItem *sound_item; @@ -279,19 +279,19 @@ static void OWiDescribeValue(P3tParticleClass *inClass, P3tDataType inDataType, (inValue->type == P3cValueType_String)) { const char *sound_name; SStImpulse *impulse; - + // get this impulse sound's name sound_name = inValue->u.string_const.val; - + // get the impulse sound impulse = OSrImpulse_GetByName(sound_name); if (impulse == NULL) { sprintf(outString, "impulse sound %s ''", sound_name); return; } - + sprintf(outString, "impulse sound '%s'", sound_name); - + /* UUtUns32 sound_id; OStCollection *impulse_collection; OStItem *sound_item; @@ -449,9 +449,9 @@ OWrParticle_Edit_Callback( P3tParticleClass ** classarray; P3tString oldname; char newname[32]; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -482,11 +482,11 @@ OWrParticle_Edit_Callback( // delete the temporary array we allocated UUrMemory_Block_Delete(classarray); break; - + case WMcMessage_Destroy: // no destruction necessary break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -512,10 +512,10 @@ OWrParticle_Edit_Callback( // create a new decal class strcpy(newname, "d_newdecal"); WMrDialog_ModalBegin(OWcDialog_Particle_DecalTextures, inDialog, OWrParticle_DecalTextures_Callback, (UUtUns32) newname, &modalreturn); - if(((UUtBool) modalreturn == UUcTrue)) // && (P3rNewParticleClass(newname) != NULL)) + if(((UUtBool) modalreturn == UUcTrue)) // && (P3rNewParticleClass(newname) != NULL)) { listbox = WMrDialog_GetItemByID(inDialog, OWcParticle_Edit_Listbox); - if (listbox != NULL) + if (listbox != NULL) { index = WMrMessage_Send(listbox, LBcMessage_AddString, (UUtUns32) newname, 0); WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32) -1, index); @@ -564,12 +564,12 @@ OWrParticle_Edit_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -595,7 +595,7 @@ OWrParticle_Variables_Callback( UUtUns32 modaldialog_message; handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -620,7 +620,7 @@ OWrParticle_Variables_Callback( // register that we may need to be notified about changes OWiParticle_RegisterOpenWindow(inDialog); break; - + case WMcMessage_Destroy: // deallocate user data user_data = (OWtParticle_Edit_Data *) WMrDialog_GetUserData(inDialog); @@ -641,7 +641,7 @@ OWrParticle_Variables_Callback( P3rDescribeVariable(user_data->classptr, &user_data->classptr->definition->variable[inParam1], variablestring); WMrMessage_Send(listbox, LBcMessage_ReplaceString, (UUtUns32) variablestring, (UUtUns32) inParam1); - + break; case WMcMessage_Command: @@ -748,11 +748,11 @@ OWrParticle_Variables_Callback( WMrDialog_Create(OWcDialog_Particle_Value_Shade, NULL, OWrParticle_Value_Shade_Callback, (UUtUns32) val_user_data, &dialog); break; - + case P3cDataType_Sound_Ambient: OWrParticle_Value_Sound_Get(SScType_Ambient, val_user_data); break; - + case P3cDataType_Sound_Impulse: OWrParticle_Value_Sound_Get(SScType_Impulse, val_user_data); break; @@ -904,12 +904,12 @@ OWrParticle_Variables_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -929,7 +929,7 @@ static void OWiParticle_Appearance_UpdateFields(WMtDialog *inDialog) sprintf(textbuf, "Scale: %s", valuebuf); WMrWindow_SetTitle(text_string, textbuf, WMcMaxTitleLength); } - + // set up the X offset text_string = WMrDialog_GetItemByID(inDialog, OWcParticle_Appearance_XOffset); if (text_string != NULL) { @@ -1072,7 +1072,7 @@ OWrParticle_Appearance_Callback( handled = UUcTrue; user_data = (OWtParticle_Edit_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -1216,7 +1216,7 @@ OWrParticle_Appearance_Callback( // register that we are here and may need to be notified about changes OWiParticle_RegisterOpenWindow(inDialog); break; - + case WMcMessage_Destroy: // deallocate user data UUrMemory_Block_Delete(user_data); @@ -1227,7 +1227,7 @@ OWrParticle_Appearance_Callback( case OWcMessage_Particle_UpdateList: // one of our variables has changed. update all of them. - OWiParticle_Appearance_UpdateFields(inDialog); + OWiParticle_Appearance_UpdateFields(inDialog); break; case WMcMessage_Command: @@ -1504,19 +1504,19 @@ OWrParticle_Appearance_Callback( tex_user_data->classptr = user_data->classptr; tex_user_data->texture_name = user_data->classptr->definition->appearance.instance; sprintf(tex_user_data->title, "Select %s ", &user_data->classptr->classname); - if (user_data->classptr->definition->flags & P3cParticleClassFlag_Appearance_Geometry) + if (user_data->classptr->definition->flags & P3cParticleClassFlag_Appearance_Geometry) { strcat(tex_user_data->title, "geometry"); strcpy(tex_user_data->editmsg, "Geometry Instance:"); tex_user_data->name_type = OWcParticle_NameType_Geometry; - } + } else { - if (user_data->classptr->definition->flags2 & P3cParticleClassFlag2_Appearance_Decal) + if (user_data->classptr->definition->flags2 & P3cParticleClassFlag2_Appearance_Decal) { strcat(tex_user_data->title, "decal"); } - else + else { strcat(tex_user_data->title, "sprite"); } @@ -1548,7 +1548,7 @@ OWrParticle_Appearance_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags = new_flags; - + // we may now need to autosave OBDrMakeDirty(); } @@ -1572,7 +1572,7 @@ OWrParticle_Appearance_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags = new_flags; - + // we may now need to autosave OBDrMakeDirty(); } @@ -1596,7 +1596,7 @@ OWrParticle_Appearance_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags2 = new_flags2; - + // we may now need to autosave OBDrMakeDirty(); } @@ -1620,7 +1620,7 @@ OWrParticle_Appearance_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags2 = new_flags2; - + // we may now need to autosave OBDrMakeDirty(); } @@ -1644,7 +1644,7 @@ OWrParticle_Appearance_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags2 = new_flags2; - + // we may now need to autosave OBDrMakeDirty(); } @@ -1668,7 +1668,7 @@ OWrParticle_Appearance_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags = new_flags; - + // we now have to re-pack the variables inside each particle P3rPackVariables(user_data->classptr, UUcTrue); @@ -1695,7 +1695,7 @@ OWrParticle_Appearance_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags2 = new_flags2; - + // we may now need to autosave OBDrMakeDirty(); } @@ -1719,7 +1719,7 @@ OWrParticle_Appearance_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags2 = new_flags2; - + // we may now need to autosave OBDrMakeDirty(); } @@ -1743,7 +1743,7 @@ OWrParticle_Appearance_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags = new_flags; - + // we now have to re-pack the variables inside each particle // because there is or isn't an additional texture index to store P3rPackVariables(user_data->classptr, UUcTrue); @@ -1771,7 +1771,7 @@ OWrParticle_Appearance_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags = new_flags; - + // we may now need to autosave OBDrMakeDirty(); @@ -1799,7 +1799,7 @@ OWrParticle_Appearance_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags2 = new_flags2; - + // we may now need to autosave OBDrMakeDirty(); } @@ -1823,7 +1823,7 @@ OWrParticle_Appearance_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags2 = new_flags2; - + // we may now need to autosave OBDrMakeDirty(); } @@ -1831,7 +1831,7 @@ OWrParticle_Appearance_Callback( break; } break; - + case WMcMessage_MenuCommand: menu = (WMtMenu *) inParam2; switch (WMrWindow_GetID(menu)) @@ -1843,17 +1843,17 @@ OWrParticle_Appearance_Callback( if (selected_id != (UUtUns16) -1) { // check this is a valid selection UUmAssert((selected_id >= 0) && (selected_id < 8)); - + new_flags = user_data->classptr->definition->flags & ~P3cParticleClassFlag_Appearance_SpriteTypeMask; new_flags |= ((UUtUns32) selected_id) << P3cParticleClassFlags_SpriteTypeShift; - + if (new_flags != user_data->classptr->definition->flags) { // this particle class is now dirty. NB: must be called BEFORE we make any changes. P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags = new_flags; - + // we may now need to autosave OBDrMakeDirty(); } @@ -1869,15 +1869,15 @@ OWrParticle_Appearance_Callback( new_flags2 = user_data->classptr->definition->flags2 & ~(P3cParticleClassFlag2_Appearance_Decal | P3cParticleClassFlag2_Appearance_Vector); - if (selected_id == OWcParticle_DisplayType_Geometry) + if (selected_id == OWcParticle_DisplayType_Geometry) { new_flags |= P3cParticleClassFlag_Appearance_Geometry; - } - else if (selected_id == OWcParticle_DisplayType_Vector) + } + else if (selected_id == OWcParticle_DisplayType_Vector) { new_flags2 |= P3cParticleClassFlag2_Appearance_Vector; - } - else if (selected_id == OWcParticle_DisplayType_Decal) + } + else if (selected_id == OWcParticle_DisplayType_Decal) { new_flags |= P3cParticleClassFlag_HasDecalData | P3cParticleClassFlag_Decorative; new_flags2 |= P3cParticleClassFlag2_Appearance_Decal; @@ -1890,7 +1890,7 @@ OWrParticle_Appearance_Callback( user_data->classptr->definition->flags = new_flags; user_data->classptr->definition->flags2 = new_flags2; - + // we may now need to autosave OBDrMakeDirty(); @@ -1899,12 +1899,12 @@ OWrParticle_Appearance_Callback( } break; } - + default: handled = UUcFalse; break; } - + return handled; } @@ -1942,7 +1942,7 @@ static UUtBool OWiParticle_UpdateCheckbox(WMtDialog *inDialog, P3tParticleClass P3rMakeDirty(inClass, UUcTrue); *flagptr = new_flags; - + // we may now need to autosave OBDrMakeDirty(); @@ -1974,7 +1974,7 @@ static void OWiParticle_Attractor_UpdateFields(WMtDialog *inDialog) sprintf(textbuf, "Class/Tag Name: %s", user_data->classptr->definition->attractor.attractor_name); WMrWindow_SetTitle(text_string, textbuf, WMcMaxTitleLength); } - + // set up the max distance text_string = WMrDialog_GetItemByID(inDialog, OWcParticle_Attractor_Max_Distance); if (text_string != NULL) { @@ -2038,7 +2038,7 @@ OWrParticle_Attractor_Callback( handled = UUcTrue; user_data = (OWtParticle_Edit_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -2070,7 +2070,7 @@ OWrParticle_Attractor_Callback( // register that we are here and may need to be notified about changes OWiParticle_RegisterOpenWindow(inDialog); break; - + case WMcMessage_Destroy: // deallocate user data UUrMemory_Block_Delete(user_data); @@ -2081,7 +2081,7 @@ OWrParticle_Attractor_Callback( case OWcMessage_Particle_UpdateList: // one of our variables has changed. update all of them. - OWiParticle_Attractor_UpdateFields(inDialog); + OWiParticle_Attractor_UpdateFields(inDialog); break; case WMcMessage_Command: @@ -2183,7 +2183,7 @@ OWrParticle_Attractor_Callback( strcat(tex_user_data->title, "class"); strcpy(tex_user_data->editmsg, "Class Name:"); tex_user_data->name_type = OWcParticle_NameType_ParticleClass; - } + } else if (user_data->classptr->definition->attractor.iterator_type == P3cAttractorIterator_ParticleTag) { strcat(tex_user_data->title, "tag"); @@ -2221,7 +2221,7 @@ OWrParticle_Attractor_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags2 = new_flags2; - + // we may now need to autosave OBDrMakeDirty(); } @@ -2229,7 +2229,7 @@ OWrParticle_Attractor_Callback( break; } break; - + case WMcMessage_MenuCommand: menu = (WMtMenu *) inParam2; switch (WMrWindow_GetID(menu)) @@ -2241,13 +2241,13 @@ OWrParticle_Attractor_Callback( if (selected_id != (UUtUns16) -1) { // check this is a valid selection UUmAssert((selected_id >= 0) && (selected_id < P3cAttractorIterator_Max)); - + if (selected_id != user_data->classptr->definition->attractor.iterator_type) { // this particle class is now dirty. NB: must be called BEFORE we make any changes. P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->attractor.iterator_type = selected_id; - + // we may now need to autosave OBDrMakeDirty(); } @@ -2261,25 +2261,25 @@ OWrParticle_Attractor_Callback( if (selected_id != (UUtUns16) -1) { // check this is a valid selection UUmAssert((selected_id >= 0) && (selected_id < P3cAttractorSelector_Max)); - + if (selected_id != user_data->classptr->definition->attractor.selector_type) { // this particle class is now dirty. NB: must be called BEFORE we make any changes. P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->attractor.selector_type = selected_id; - + // we may now need to autosave OBDrMakeDirty(); } } break; } - + default: handled = UUcFalse; break; } - + return handled; } @@ -2305,7 +2305,7 @@ OWrParticle_Class_Callback( handled = UUcTrue; user_data = (OWtParticle_Edit_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -2384,14 +2384,14 @@ OWrParticle_Class_Callback( // register that we are here and may need to be notified about changes OWiParticle_RegisterOpenWindow(inDialog); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); // register that we are going away and shouldn't be notified about any further changes OWiParticle_RegisterCloseWindow(inDialog); break; - + case OWcMessage_Particle_UpdateList: // set the lifetime description text text = WMrDialog_GetItemByID(inDialog, OWcParticle_Class_LifetimeText); @@ -2534,7 +2534,7 @@ OWrParticle_Class_Callback( case OWcParticle_Class_CollideEnv: // CB: note that environment collision now requires an environment cache OWiParticle_UpdateCheckbox(inDialog, user_data->classptr, OWcParticle_Class_CollideEnv, 1, - (P3cParticleClassFlag_Physics_CollideEnv | P3cParticleClassFlag_HasEnvironmentCache), UUcTrue); + (P3cParticleClassFlag_Physics_CollideEnv | P3cParticleClassFlag_HasEnvironmentCache), UUcTrue); break; case OWcParticle_Class_CollideChar: @@ -2638,7 +2638,7 @@ OWrParticle_Class_Callback( case OWcParticle_Class_FlybyButton: { OWtSelectResult result; - + // select the impulse sound result = OWrSelect_ImpulseSound(&impulse_sound); if (result == OWcSelectResult_Cancel) { @@ -2668,7 +2668,7 @@ OWrParticle_Class_Callback( } } break; - + case WMcMessage_MenuCommand: switch (WMrWindow_GetID((WMtWindow *) inParam2)) { @@ -2685,14 +2685,14 @@ OWrParticle_Class_Callback( new_flags2 = user_data->classptr->definition->flags2 & ~(P3cParticleClassFlag2_MediumDetailDisable | P3cParticleClassFlag2_LowDetailDisable); - if (selection == OWcParticle_Disable_MediumDetail) + if (selection == OWcParticle_Disable_MediumDetail) { new_flags2 |= (P3cParticleClassFlag2_MediumDetailDisable | P3cParticleClassFlag2_LowDetailDisable); - } - else if (selection == OWcParticle_Disable_LowDetail) + } + else if (selection == OWcParticle_Disable_LowDetail) { new_flags2 |= P3cParticleClassFlag2_LowDetailDisable; - } + } if (new_flags2 != user_data->classptr->definition->flags2) { @@ -2700,7 +2700,7 @@ OWrParticle_Class_Callback( P3rMakeDirty(user_data->classptr, UUcTrue); user_data->classptr->definition->flags2 = new_flags2; - + // we may now need to autosave OBDrMakeDirty(); } @@ -2715,7 +2715,7 @@ OWrParticle_Class_Callback( handled = UUcFalse; break; } - + return handled; } @@ -2792,7 +2792,7 @@ static void OWiParticle_Value_Int_UpdateParameters(WMtDialog *inDialog) // read which radio button is selected user_data = (OWtParticle_Value_Data *) WMrDialog_GetUserData(inDialog); active_radio = 0; - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Int_Const); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -2801,7 +2801,7 @@ static void OWiParticle_Value_Int_UpdateParameters(WMtDialog *inDialog) new_val.type = P3cValueType_Integer; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Int_Range); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -2810,7 +2810,7 @@ static void OWiParticle_Value_Int_UpdateParameters(WMtDialog *inDialog) new_val.type = P3cValueType_IntegerRange; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Int_Variable); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -2821,10 +2821,10 @@ static void OWiParticle_Value_Int_UpdateParameters(WMtDialog *inDialog) new_val.type = P3cValueType_Variable; } } - + // is this a different type to the initial one? val_changed = (new_val.type != user_data->valptr->type); - + // read the modified value from whichever field is selected switch(active_radio) { case OWcParticle_Value_Int_Const: @@ -2837,7 +2837,7 @@ static void OWiParticle_Value_Int_UpdateParameters(WMtDialog *inDialog) val_changed = (new_val.u.integer_const.val != user_data->valptr->u.integer_const.val); } break; - + case OWcParticle_Value_Int_Range: new_val.u.integer_range.val_low = 0; new_val.u.integer_range.val_hi = 0; @@ -2984,7 +2984,7 @@ static void OWiParticle_Value_Float_UpdateParameters(WMtDialog *inDialog) // read which radio button is selected user_data = (OWtParticle_Value_Data *) WMrDialog_GetUserData(inDialog); active_radio = 0; - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Float_Const); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -2993,7 +2993,7 @@ static void OWiParticle_Value_Float_UpdateParameters(WMtDialog *inDialog) new_val.type = P3cValueType_Float; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Float_Range); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -3002,7 +3002,7 @@ static void OWiParticle_Value_Float_UpdateParameters(WMtDialog *inDialog) new_val.type = P3cValueType_FloatRange; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Float_Bellcurve); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -3011,7 +3011,7 @@ static void OWiParticle_Value_Float_UpdateParameters(WMtDialog *inDialog) new_val.type = P3cValueType_FloatBellcurve; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Float_Cycle); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -3020,7 +3020,7 @@ static void OWiParticle_Value_Float_UpdateParameters(WMtDialog *inDialog) new_val.type = P3cValueType_FloatTimeBased; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Float_Variable); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -3031,10 +3031,10 @@ static void OWiParticle_Value_Float_UpdateParameters(WMtDialog *inDialog) new_val.type = P3cValueType_Variable; } } - + // is this a different type to the initial one? val_changed = (new_val.type != user_data->valptr->type); - + // read the modified value from whichever field is selected switch(active_radio) { case OWcParticle_Value_Float_Const: @@ -3048,7 +3048,7 @@ static void OWiParticle_Value_Float_UpdateParameters(WMtDialog *inDialog) val_changed = (fabs(delta_val) > 1e-06f); } break; - + case OWcParticle_Value_Float_Range: new_val.u.float_range.val_low = 0; new_val.u.float_range.val_hi = 0; @@ -3199,7 +3199,7 @@ static void OWiParticle_Value_String_UpdateParameters(WMtDialog *inDialog) // read which radio button is selected user_data = (OWtParticle_Value_Data *) WMrDialog_GetUserData(inDialog); active_radio = 0; - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_String_Const); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -3208,7 +3208,7 @@ static void OWiParticle_Value_String_UpdateParameters(WMtDialog *inDialog) new_val.type = P3cValueType_String; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_String_Variable); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -3219,10 +3219,10 @@ static void OWiParticle_Value_String_UpdateParameters(WMtDialog *inDialog) new_val.type = P3cValueType_Variable; } } - + // is this a different type to the initial one? val_changed = (new_val.type != user_data->valptr->type); - + // read the modified value from whichever field is selected switch(active_radio) { case OWcParticle_Value_String_Const: @@ -3234,7 +3234,7 @@ static void OWiParticle_Value_String_UpdateParameters(WMtDialog *inDialog) user_data->valptr->u.string_const.val); } break; - + case OWcParticle_Value_String_Variable: menu = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_String_VarPopup); UUmAssert(menu != NULL); @@ -3347,7 +3347,7 @@ static UUtBool OWiParticle_Value_Shade_UpdateParameters(WMtDialog *inDialog, cha // read which radio button is selected user_data = (OWtParticle_Value_Data *) WMrDialog_GetUserData(inDialog); active_radio = 0; - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Shade_Const); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -3356,7 +3356,7 @@ static UUtBool OWiParticle_Value_Shade_UpdateParameters(WMtDialog *inDialog, cha new_val.type = P3cValueType_Shade; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Shade_Range); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -3365,7 +3365,7 @@ static UUtBool OWiParticle_Value_Shade_UpdateParameters(WMtDialog *inDialog, cha new_val.type = P3cValueType_ShadeRange; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Shade_Bellcurve); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -3374,7 +3374,7 @@ static UUtBool OWiParticle_Value_Shade_UpdateParameters(WMtDialog *inDialog, cha new_val.type = P3cValueType_ShadeBellcurve; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Shade_Variable); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -3385,10 +3385,10 @@ static UUtBool OWiParticle_Value_Shade_UpdateParameters(WMtDialog *inDialog, cha new_val.type = P3cValueType_Variable; } } - + // is this a different type to the initial one? val_changed = (new_val.type != user_data->valptr->type); - + // read the modified value from whichever field is selected switch(active_radio) { case OWcParticle_Value_Shade_Const: @@ -3404,7 +3404,7 @@ static UUtBool OWiParticle_Value_Shade_UpdateParameters(WMtDialog *inDialog, cha val_changed = (new_val.u.shade_const.val != user_data->valptr->u.shade_const.val); } break; - + case OWcParticle_Value_Shade_Range: edit_field = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Shade_RangeLow); UUmAssert(edit_field != NULL); @@ -3552,7 +3552,7 @@ static void OWiParticle_Value_Enum_UpdateParameters(WMtDialog *inDialog) // read which radio button is selected user_data = (OWtParticle_Value_Data *) WMrDialog_GetUserData(inDialog); active_radio = 0; - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Enum_Const); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -3561,7 +3561,7 @@ static void OWiParticle_Value_Enum_UpdateParameters(WMtDialog *inDialog) new_val.type = P3cValueType_Enum; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_Enum_Variable); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -3572,10 +3572,10 @@ static void OWiParticle_Value_Enum_UpdateParameters(WMtDialog *inDialog) new_val.type = P3cValueType_Variable; } } - + // is this a different type to the initial one? val_changed = (new_val.type != user_data->valptr->type); - + enumtype_index = (UUtUns16) (user_data->enum_info.type >> P3cEnumShift); UUmAssert((enumtype_index >= 0) && (enumtype_index < (P3cEnumType_Max >> P3cEnumShift))); @@ -3598,7 +3598,7 @@ static void OWiParticle_Value_Enum_UpdateParameters(WMtDialog *inDialog) val_changed = (new_val.u.enum_const.val != user_data->valptr->u.enum_const.val); } break; - + case OWcParticle_Value_Enum_Variable: varmenu = WMrDialog_GetItemByID(inDialog, OWcParticle_Value_String_VarPopup); UUmAssert(varmenu != NULL); @@ -3636,20 +3636,20 @@ OWrParticle_Value_Int_Callback( UUtBool handled; OWtParticle_Value_Data * user_data; UUtUns16 active_radio; - + handled = UUcTrue; user_data = (OWtParticle_Value_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: OWiParticle_Value_Int_InitDialog(inDialog); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -3681,12 +3681,12 @@ OWrParticle_Value_Int_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -3700,20 +3700,20 @@ OWrParticle_Value_Float_Callback( UUtBool handled; OWtParticle_Value_Data * user_data; UUtUns16 active_radio; - + handled = UUcTrue; user_data = (OWtParticle_Value_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: OWiParticle_Value_Float_InitDialog(inDialog); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -3747,12 +3747,12 @@ OWrParticle_Value_Float_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -3766,20 +3766,20 @@ OWrParticle_Value_String_Callback( UUtBool handled; OWtParticle_Value_Data * user_data; UUtUns16 active_radio; - + handled = UUcTrue; user_data = (OWtParticle_Value_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: OWiParticle_Value_String_InitDialog(inDialog); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -3810,12 +3810,12 @@ OWrParticle_Value_String_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -3829,20 +3829,20 @@ OWrParticle_Value_Enum_Callback( UUtBool handled; OWtParticle_Value_Data * user_data; UUtUns16 active_radio; - + handled = UUcTrue; user_data = (OWtParticle_Value_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: OWiParticle_Value_Enum_InitDialog(inDialog); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -3873,12 +3873,12 @@ OWrParticle_Value_Enum_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -3894,20 +3894,20 @@ OWrParticle_Value_Shade_Callback( UUtUns16 active_radio; char value_error[64]; char errormsg[256]; - + handled = UUcTrue; user_data = (OWtParticle_Value_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: OWiParticle_Value_Shade_InitDialog(inDialog); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -3956,12 +3956,12 @@ OWrParticle_Value_Shade_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -3981,9 +3981,9 @@ OWrParticle_NewVar_Callback( char typedname[64]; char messageboxstring[128]; WMtMenuItemData item_data; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -3996,14 +3996,14 @@ OWrParticle_NewVar_Callback( item_data.flags = WMcMenuItemFlag_Enabled; item_data.id = P3gEnumTypeInfo[itr].type; strcpy(item_data.title, P3gEnumTypeInfo[itr].name); - + WMrPopupMenu_AppendItem(enum_popup, &item_data); } break; - + case WMcMessage_Destroy: break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -4028,7 +4028,7 @@ OWrParticle_NewVar_Callback( break; } strcpy(user_data->name, typedname); - + // find the selected data type user_data->type = P3cDataType_Integer; @@ -4039,7 +4039,7 @@ OWrParticle_NewVar_Callback( user_data->type = P3cDataType_Integer; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_NewVar_Float); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -4047,7 +4047,7 @@ OWrParticle_NewVar_Callback( user_data->type = P3cDataType_Float; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_NewVar_String); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -4055,7 +4055,7 @@ OWrParticle_NewVar_Callback( user_data->type = P3cDataType_String; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_NewVar_Shade); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -4063,7 +4063,7 @@ OWrParticle_NewVar_Callback( user_data->type = P3cDataType_Shade; } } - + radio_button = WMrDialog_GetItemByID(inDialog, OWcParticle_NewVar_Enum); if (radio_button != NULL) { if (WMrMessage_Send(radio_button, WMcMessage_GetValue, @@ -4078,7 +4078,7 @@ OWrParticle_NewVar_Callback( user_data->type |= selected_enumtype; } } - + WMrDialog_ModalEnd(inDialog, (UUtUns32) UUcTrue); break; @@ -4097,12 +4097,12 @@ OWrParticle_NewVar_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -4118,10 +4118,10 @@ OWrParticle_RenameVar_Callback( char * newvar_name; char messageboxstring[64]; WMtWindow * edit_field; - + handled = UUcTrue; newvar_name = (char *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -4130,10 +4130,10 @@ OWrParticle_RenameVar_Callback( UUmAssert(edit_field != NULL); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32) newvar_name, 0); break; - + case WMcMessage_Destroy: break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -4160,12 +4160,12 @@ OWrParticle_RenameVar_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -4184,10 +4184,10 @@ OWrParticle_Texture_Callback( M3tGeometry * geomptr; P3tParticleClass * classptr; UUtError error; - + handled = UUcTrue; user_data = (OWtParticle_Texture_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -4205,11 +4205,11 @@ OWrParticle_Texture_Callback( UUmAssert(edit_field != NULL); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32) user_data->texture_name, 0); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -4295,12 +4295,12 @@ OWrParticle_Texture_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -4317,10 +4317,10 @@ OWrParticle_Number_Callback( OWtParticle_Number_Data * user_data; UUtUns16 new_number; float new_float; - + handled = UUcTrue; user_data = (OWtParticle_Number_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -4343,11 +4343,11 @@ OWrParticle_Number_Callback( } WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32) input_text, 0); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -4413,12 +4413,12 @@ OWrParticle_Number_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -4434,9 +4434,9 @@ OWrParticle_NewAction_Callback( WMtMenuItemData item_data; P3tActionTemplate ** output_template; UUtUns16 itr, act_index; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -4458,15 +4458,15 @@ OWrParticle_NewAction_Callback( item_data.flags = WMcMenuItemFlag_Enabled; item_data.id = itr; } - + WMrPopupMenu_AppendItem(menu, &item_data); } WMrPopupMenu_SetSelection(menu, 0); break; - + case WMcMessage_Destroy: break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -4489,12 +4489,12 @@ OWrParticle_NewAction_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -4510,11 +4510,11 @@ OWrParticle_VarRef_Callback( char * selected_var; UUtUns16 old_offset; WMtWindow * menu; - + kill_window = UUcFalse; handled = UUcTrue; user_data = (OWtParticle_VarRef_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -4530,12 +4530,12 @@ OWrParticle_VarRef_Callback( // set the title WMrWindow_SetTitle(inDialog, user_data->title, WMcMaxTitleLength); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -4573,12 +4573,12 @@ OWrParticle_VarRef_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -4594,10 +4594,10 @@ OWrParticle_ActionList_Callback( UUtUns16 orig_val; WMtWindow * edit_field; char editstring[64]; - + handled = UUcTrue; user_data = (OWtParticle_ActionList_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -4616,10 +4616,10 @@ OWrParticle_ActionList_Callback( // set the title WMrWindow_SetTitle(inDialog, user_data->title, WMcMaxTitleLength); break; - + case WMcMessage_Destroy: break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -4678,12 +4678,12 @@ OWrParticle_ActionList_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -4693,7 +4693,7 @@ void OWrParticle_Value_Sound_Get(SStType inType, OWtParticle_Value_Data *inValUs OWtSelectResult result; UUrString_Copy(name, "", P3cStringVarSize + 1); - + switch(inType) { case SScType_Ambient: @@ -4737,9 +4737,9 @@ void OWrParticle_Value_Sound_Get(SStType inType, OWtParticle_Value_Data *inValUs break; } } - + inValUserData->valptr->type = P3cValueType_String; - + OWiParticle_NotifyParent(inValUserData->notify_struct.notify_window, (UUtUns32) inValUserData->notify_struct.line_to_notify); } @@ -4776,7 +4776,7 @@ UUtError OWrSave_Particles(UUtBool inAutosave) if (!needs_saving) continue; - + // save the particle as a binary file binaryClass = P3rBuildBinaryData(swapbytes, classptr->definition, &binarySize); error = OBDrBinaryData_Save(P3cBinaryDataClass, classptr->classname, @@ -4822,7 +4822,7 @@ UUtError OWrSave_Particle(P3tParticleClass *inClassPtr) // save the particle as a binary file. note that this is not an autosave // (autosaves save all particles at once) binaryClass = P3rBuildBinaryData(swapbytes, inClassPtr->definition, &binarySize); - error = OBDrBinaryData_Save(P3cBinaryDataClass, inClassPtr->classname, + error = OBDrBinaryData_Save(P3cBinaryDataClass, inClassPtr->classname, binaryClass, binarySize, 0, UUcFalse); if (error) { COrConsole_Printf("can't save particle as binary data file"); @@ -4953,7 +4953,7 @@ static void OWiSetup_Listbox_Actions(WMtWindow *inListbox, OWtParticle_Action_Da /* * write the description into the inListbox */ - + // action's name sprintf(actionstring, "%s", act_template->name); if (can_disable) { @@ -4963,7 +4963,7 @@ static void OWiSetup_Listbox_Actions(WMtWindow *inListbox, OWtParticle_Action_Da WMrMessage_Send(inListbox, LBcMessage_AddString, (UUtUns32) actionstring, 0); listpos++; - + // action's variables for (itr2 = 0; itr2 < act_template->num_variables; itr2++) { if (act->action_var[itr2].name[0] == '\0') { @@ -4971,13 +4971,13 @@ static void OWiSetup_Listbox_Actions(WMtWindow *inListbox, OWtParticle_Action_Da sprintf(actionstring, " %s: NONE", act_template->info[itr2].name); } else { - sprintf(actionstring, " %s: %s", + sprintf(actionstring, " %s: %s", act_template->info[itr2].name, act->action_var[itr2].name); } WMrMessage_Send(inListbox, LBcMessage_AddString, (UUtUns32) actionstring, 0); listpos++; } - + // action's parameters for (itr2 = 0; itr2 < act_template->num_parameters; itr2++) { OWiDescribeValue(inUserData->classptr, @@ -5017,7 +5017,7 @@ OWrParticle_Actions_Callback( P3tActionList * actionlist; handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -5048,7 +5048,7 @@ OWrParticle_Actions_Callback( // register that we are here and may need to be notified about changes OWiParticle_RegisterOpenWindow(inDialog); break; - + case WMcMessage_Destroy: // deallocate user data user_data = (OWtParticle_Action_Data *) WMrDialog_GetUserData(inDialog); @@ -5089,7 +5089,7 @@ OWrParticle_Actions_Callback( act_entry->actiontemplate->num_variables].datatype; OWiDescribeValue(user_data->classptr, datatype, &act->action_value[item_index], tempstring); - sprintf(actionstring, " %s: %s", + sprintf(actionstring, " %s: %s", act_entry->actiontemplate->info[act_entry->actiontemplate->num_variables + item_index].name, tempstring); @@ -5227,7 +5227,7 @@ OWrParticle_Actions_Callback( val_user_data->classptr = user_data->classptr; val_user_data->valptr = &act->action_value[item_index]; val_user_data->variable_allowed = UUcTrue; - sprintf(val_user_data->title, "%s: parameter '%s'", + sprintf(val_user_data->title, "%s: parameter '%s'", act_template->name, act_template->info[act_template->num_variables + item_index].name); @@ -5255,15 +5255,15 @@ OWrParticle_Actions_Callback( WMrDialog_Create(OWcDialog_Particle_Value_Shade, NULL, OWrParticle_Value_Shade_Callback, (UUtUns32) val_user_data, &dialog); break; - + case P3cDataType_Sound_Ambient: OWrParticle_Value_Sound_Get(SScType_Ambient, val_user_data); break; - + case P3cDataType_Sound_Impulse: OWrParticle_Value_Sound_Get(SScType_Impulse, val_user_data); break; - + default: if (datatype & P3cDataType_Enum) { P3rGetEnumInfo(user_data->classptr, datatype, &val_user_data->enum_info); @@ -5320,7 +5320,7 @@ OWrParticle_Actions_Callback( UUrMemory_Block_New(sizeof(OWtParticle_VarRef_Data)); var_user_data->classptr = user_data->classptr; var_user_data->varptr = &act->action_var[item_index]; - sprintf(var_user_data->title, "%s: variable '%s'", + sprintf(var_user_data->title, "%s: variable '%s'", act_template->name, act_template->info[item_index].name); var_user_data->allowed_types = act_template->info[item_index].datatype; @@ -5401,7 +5401,7 @@ OWrParticle_Actions_Callback( // swap the actions in the particle class start_index = user_data->classptr->definition->eventlist[user_data->listindex].start_index; P3rSwapTwoActions(user_data->classptr, start_index + act_index - 1, start_index + act_index); - + // re-set up our listbox if (listbox != NULL) OWiSetup_Listbox_Actions(listbox, user_data); @@ -5438,7 +5438,7 @@ OWrParticle_Actions_Callback( // swap the actions in the particle class start_index = user_data->classptr->definition->eventlist[user_data->listindex].start_index; P3rSwapTwoActions(user_data->classptr, start_index + act_index + 1, start_index + act_index); - + // re-set up our listbox if (listbox != NULL) OWiSetup_Listbox_Actions(listbox, user_data); @@ -5484,12 +5484,12 @@ OWrParticle_Actions_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -5523,7 +5523,7 @@ static void OWiSetup_Listbox_Emitters(WMtWindow *inListbox, OWtParticle_Emitter_ /* * write the description into the inListbox */ - + // first line: particle class, flags, etc sprintf(listbox_line, "#%d: emits '%s' [", itr, emitter->classname); @@ -5655,7 +5655,7 @@ OWrParticle_Emitters_Callback( UUtUns32 modaldialog_message; handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -5675,7 +5675,7 @@ OWrParticle_Emitters_Callback( // register that we are here and may need to be notified about changes OWiParticle_RegisterOpenWindow(inDialog); break; - + case WMcMessage_Destroy: // deallocate allocated array and user data user_data = (OWtParticle_Emitter_Data *) WMrDialog_GetUserData(inDialog); @@ -5695,7 +5695,7 @@ OWrParticle_Emitters_Callback( if (user_data->set_percentage_chance) { UUmAssert(user_data->store_percentage_chance != NULL); - *(user_data->store_percentage_chance) = (UUtUns16) + *(user_data->store_percentage_chance) = (UUtUns16) MUrUnsignedSmallFloat_To_Uns_Round(UUcMaxUns16 * user_data->temp_percentage_chance / 100.0f); } @@ -5928,7 +5928,7 @@ OWrParticle_Emitters_Callback( // no changes were made break; } - + // this particle class is now dirty. NB: must be called BEFORE we make any changes. P3rMakeDirty(user_data->classptr, UUcTrue); @@ -5962,9 +5962,9 @@ OWrParticle_Emitters_Callback( val_user_data = (OWtParticle_Value_Data *) UUrMemory_Block_New(sizeof(OWtParticle_Value_Data)); val_user_data->classptr = user_data->classptr; - val_user_data->valptr = &emitter->emitter_value[offset_index + value_offset]; + val_user_data->valptr = &emitter->emitter_value[offset_index + value_offset]; val_user_data->variable_allowed = UUcTrue; - sprintf(val_user_data->title, "emitter #%d %s (%s): parameter '%s'", + sprintf(val_user_data->title, "emitter #%d %s (%s): parameter '%s'", emitter_index, section_name, class_desc[*current_param].setting_name, class_desc[*current_param].param_desc[offset_index].param_name); @@ -5978,34 +5978,34 @@ OWrParticle_Emitters_Callback( WMrDialog_Create(OWcDialog_Particle_Value_Int, NULL, OWrParticle_Value_Int_Callback, (UUtUns32) val_user_data, &dialog); break; - + case P3cDataType_Float: WMrDialog_Create(OWcDialog_Particle_Value_Float, NULL, OWrParticle_Value_Float_Callback, (UUtUns32) val_user_data, &dialog); break; - + case P3cDataType_String: WMrDialog_Create(OWcDialog_Particle_Value_String, NULL, OWrParticle_Value_String_Callback, (UUtUns32) val_user_data, &dialog); break; - + case P3cDataType_Shade: WMrDialog_Create(OWcDialog_Particle_Value_Shade, NULL, OWrParticle_Value_Shade_Callback, (UUtUns32) val_user_data, &dialog); break; - + case P3cDataType_Sound_Ambient: OWrParticle_Value_Sound_Get(SScType_Ambient, val_user_data); break; - + case P3cDataType_Sound_Impulse: OWrParticle_Value_Sound_Get(SScType_Impulse, val_user_data); break; - + default: if (datatype & P3cDataType_Enum) { P3rGetEnumInfo(user_data->classptr, datatype, &val_user_data->enum_info); - + if (val_user_data->enum_info.not_handled) { /* switch(val_user_data->enum_info.type) { case P3cEnumType_AmbientSoundID: @@ -6104,12 +6104,12 @@ OWrParticle_Emitters_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -6126,10 +6126,10 @@ OWrParticle_EmitterFlags_Callback( OWtParticle_EmitterFlags_Data * user_data; P3tParticleClass * new_classptr; UUtUns32 new_flags; - + handled = UUcTrue; user_data = (OWtParticle_EmitterFlags_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -6143,84 +6143,84 @@ OWrParticle_EmitterFlags_Callback( if (checkbox != NULL) { checked = (user_data->emitter->flags & P3cEmitterFlag_InitiallyActive) ? UUcTrue : UUcFalse; - WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); + WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); } checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_IncreaseCount); if (checkbox != NULL) { checked = (user_data->emitter->flags & P3cEmitterFlag_IncreaseEmitCount) ? UUcTrue : UUcFalse; - WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); + WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); } checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_OffAtThreshold); if (checkbox != NULL) { checked = (user_data->emitter->flags & P3cEmitterFlag_DeactivateWhenEmitCountThreshold) ? UUcTrue : UUcFalse; - WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); + WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); } checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_OnAtThreshold); if (checkbox != NULL) { checked = (user_data->emitter->flags & P3cEmitterFlag_ActivateWhenEmitCountThreshold) ? UUcTrue : UUcFalse; - WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); + WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); } checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_ParentVelocity); if (checkbox != NULL) { checked = (user_data->emitter->flags & P3cEmitterFlag_AddParentVelocity) ? UUcTrue : UUcFalse; - WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); + WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); } checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_DynamicMatrix); if (checkbox != NULL) { checked = (user_data->emitter->flags & P3cEmitterFlag_SameDynamicMatrix) ? UUcTrue : UUcFalse; - WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); + WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); } checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_OrientToVelocity); if (checkbox != NULL) { checked = (user_data->emitter->flags & P3cEmitterFlag_OrientToVelocity) ? UUcTrue : UUcFalse; - WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); + WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); } checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_InheritTint); if (checkbox != NULL) { checked = (user_data->emitter->flags & P3cEmitterFlag_InheritTint) ? UUcTrue : UUcFalse; - WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); + WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); } checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_OnePerAttractor); if (checkbox != NULL) { checked = (user_data->emitter->flags & P3cEmitterFlag_OnePerAttractor) ? UUcTrue : UUcFalse; - WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); + WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); } checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_AtLeastOne); if (checkbox != NULL) { checked = (user_data->emitter->flags & P3cEmitterFlag_AtLeastOne) ? UUcTrue : UUcFalse; - WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); + WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); } checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_RotateAttractors); if (checkbox != NULL) { checked = (user_data->emitter->flags & P3cEmitterFlag_RotateAttractors) ? UUcTrue : UUcFalse; - WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); + WMrMessage_Send(checkbox, CBcMessage_SetCheck, (UUtUns32) checked, (UUtUns32) -1); } break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); break; - + case WMcMessage_Command: close_window = UUcFalse; @@ -6274,7 +6274,7 @@ OWrParticle_EmitterFlags_Callback( if (checked) new_flags |= P3cEmitterFlag_InitiallyActive; } - + checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_IncreaseCount); if (checkbox != NULL) { checked = (UUtBool) WMrMessage_Send(checkbox, WMcMessage_GetValue, @@ -6282,7 +6282,7 @@ OWrParticle_EmitterFlags_Callback( if (checked) new_flags |= P3cEmitterFlag_IncreaseEmitCount; } - + checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_OffAtThreshold); if (checkbox != NULL) { checked = (UUtBool) WMrMessage_Send(checkbox, WMcMessage_GetValue, @@ -6290,7 +6290,7 @@ OWrParticle_EmitterFlags_Callback( if (checked) new_flags |= P3cEmitterFlag_DeactivateWhenEmitCountThreshold; } - + checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_OnAtThreshold); if (checkbox != NULL) { checked = (UUtBool) WMrMessage_Send(checkbox, WMcMessage_GetValue, @@ -6298,7 +6298,7 @@ OWrParticle_EmitterFlags_Callback( if (checked) new_flags |= P3cEmitterFlag_ActivateWhenEmitCountThreshold; } - + checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_ParentVelocity); if (checkbox != NULL) { checked = (UUtBool) WMrMessage_Send(checkbox, WMcMessage_GetValue, @@ -6306,7 +6306,7 @@ OWrParticle_EmitterFlags_Callback( if (checked) new_flags |= P3cEmitterFlag_AddParentVelocity; } - + checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_DynamicMatrix); if (checkbox != NULL) { checked = (UUtBool) WMrMessage_Send(checkbox, WMcMessage_GetValue, @@ -6314,7 +6314,7 @@ OWrParticle_EmitterFlags_Callback( if (checked) new_flags |= P3cEmitterFlag_SameDynamicMatrix; } - + checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_OrientToVelocity); if (checkbox != NULL) { checked = (UUtBool) WMrMessage_Send(checkbox, WMcMessage_GetValue, @@ -6322,7 +6322,7 @@ OWrParticle_EmitterFlags_Callback( if (checked) new_flags |= P3cEmitterFlag_OrientToVelocity; } - + checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_InheritTint); if (checkbox != NULL) { checked = (UUtBool) WMrMessage_Send(checkbox, WMcMessage_GetValue, @@ -6330,7 +6330,7 @@ OWrParticle_EmitterFlags_Callback( if (checked) new_flags |= P3cEmitterFlag_InheritTint; } - + checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_OnePerAttractor); if (checkbox != NULL) { checked = (UUtBool) WMrMessage_Send(checkbox, WMcMessage_GetValue, @@ -6338,7 +6338,7 @@ OWrParticle_EmitterFlags_Callback( if (checked) new_flags |= P3cEmitterFlag_OnePerAttractor; } - + checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_AtLeastOne); if (checkbox != NULL) { checked = (UUtBool) WMrMessage_Send(checkbox, WMcMessage_GetValue, @@ -6346,7 +6346,7 @@ OWrParticle_EmitterFlags_Callback( if (checked) new_flags |= P3cEmitterFlag_AtLeastOne; } - + checkbox = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterFlags_RotateAttractors); if (checkbox != NULL) { checked = (UUtBool) WMrMessage_Send(checkbox, WMcMessage_GetValue, @@ -6354,7 +6354,7 @@ OWrParticle_EmitterFlags_Callback( if (checked) new_flags |= P3cEmitterFlag_RotateAttractors; } - + // do we need to update the emitter? if (new_flags != user_data->emitter->flags) { if (!has_changed) { @@ -6380,12 +6380,12 @@ OWrParticle_EmitterFlags_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -6403,10 +6403,10 @@ OWrParticle_LinkType_Callback( OWtParticle_LinkType_Data * user_data; UUtUns32 itr; UUtUns16 new_linktype; - + handled = UUcTrue; user_data = (OWtParticle_LinkType_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -6435,13 +6435,13 @@ OWrParticle_LinkType_Callback( } } - WMrPopupMenu_SetSelection(menu, (UUtUns16) user_data->emitter->link_type); + WMrPopupMenu_SetSelection(menu, (UUtUns16) user_data->emitter->link_type); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -6475,12 +6475,12 @@ OWrParticle_LinkType_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -6499,10 +6499,10 @@ OWrParticle_EmitterChoice_Callback( char tempstring[64]; UUtUns16 itr, selected_id; WMtMenuItemData item_data; - + handled = UUcTrue; user_data = (OWtParticle_EmitterChoice_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -6510,7 +6510,7 @@ OWrParticle_EmitterChoice_Callback( sprintf(tempstring, "Set Emitter #%d %s", (user_data->emitter - user_data->classptr->definition->emitter), user_data->classname); WMrWindow_SetTitle(inDialog, tempstring, WMcMaxTitleLength); - + // set up the static text item text_field = WMrDialog_GetItemByID(inDialog, OWcParticle_EmitterChoice_Text); if (text_field != NULL) { @@ -6536,13 +6536,13 @@ OWrParticle_EmitterChoice_Callback( } } - WMrPopupMenu_SetSelection(menu, (UUtUns16) user_data->current_choice); + WMrPopupMenu_SetSelection(menu, (UUtUns16) user_data->current_choice); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -6562,12 +6562,12 @@ OWrParticle_EmitterChoice_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -6586,10 +6586,10 @@ OWrParticle_EventList_Callback( char title[64]; UUtUns16 itr, num_actions; P3tActionList * actionlist; - + handled = UUcTrue; user_data = (OWtParticle_Edit_Data *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -6622,14 +6622,14 @@ OWrParticle_EventList_Callback( // register that we are here and may need to be notified about changes OWiParticle_RegisterOpenWindow(inDialog); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(user_data); // register that we are going away and shouldn't be notified about any further changes OWiParticle_RegisterCloseWindow(inDialog); break; - + case OWcMessage_Particle_UpdateList: // set the event description text for whichever event has been updated text = WMrDialog_GetItemByID(inDialog, OWcParticle_EventList_DescBase + (UUtUns16) inParam1); @@ -6671,12 +6671,12 @@ OWrParticle_EventList_Callback( } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -6690,10 +6690,10 @@ OWrParticle_ClassName_Callback( UUtBool handled; char errormsg[256], *classname; WMtWindow * edit_field; - + handled = UUcTrue; classname = (char *) WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: @@ -6702,11 +6702,11 @@ OWrParticle_ClassName_Callback( UUmAssert(edit_field != NULL); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32) classname, 0); break; - + case WMcMessage_Destroy: // nothing to delete break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -6741,18 +6741,18 @@ OWrParticle_ClassName_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } //================================================================================================================ -// decal textures +// decal textures //================================================================================================================ static char *OWgParticle_DecalTexture_Name; @@ -6764,38 +6764,38 @@ static UUtError OWrParticle_DecalTextures_InitDialog( WMtDialog *inDialog ) UUtError error; UUtUns32 i; WMtWindow *listbox; - + // get the number of textures num_textures = TMrInstance_GetTagCount(M3cTemplate_TextureMap); if (num_textures == 0) { return UUcError_Generic; } - + // allocate memory to hold the list of textures texture_list = (M3tTextureMap**)UUrMemory_Block_New(sizeof(M3tTextureMap*) * num_textures); if (texture_list == NULL) { return UUcError_Generic; } - + OWgParticle_DecalTexture_Name = (char*) WMrDialog_GetUserData(inDialog); UUmAssert( OWgParticle_DecalTexture_Name ); WMrDialog_SetUserData(inDialog, (UUtUns32)texture_list); - + // get a list of the textures error = TMrInstance_GetDataPtr_List( M3cTemplate_TextureMap, num_textures, &num_textures, texture_list ); UUmError_ReturnOnError(error); - + // put the textures into the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcParticle_Decal_Textures); for (i = 0; i < num_textures; i++) { WMrMessage_Send(listbox, LBcMessage_AddString, i, 0); } - + // select the first item in the list WMrListBox_SetSelection(listbox, UUcTrue, 0); - + // set the focus WMrWindow_SetFocus(listbox); - + return UUcError_None; } @@ -6803,9 +6803,9 @@ static UUtError OWrParticle_DecalTextures_InitDialog( WMtDialog *inDialog ) static void OWrParticle_DecalTextures_Destroy( WMtDialog *inDialog ) { M3tTextureMap **texture_list; - + texture_list = (M3tTextureMap**)WMrDialog_GetUserData(inDialog); - + // delete the texture list UUrMemory_Block_Delete(texture_list); texture_list = NULL; @@ -6821,14 +6821,14 @@ static UUtError OWrParticle_DecalTextures_HandleCommand( WMtDialog *inDialog, UU M3tTextureMap **texture_list; UUtUns32 index; M3tTextureMap *texture; - + if (UUmHighWord(inParam1) != LBcNotify_SelectionChanged) { break; } - + // get a pointer to the texture texture_list = (M3tTextureMap**)WMrDialog_GetUserData(inDialog); index = WMrListBox_GetSelection(inControl); texture = texture_list[index]; - + WMrPicture_SetPicture(WMrDialog_GetItemByID(inDialog, OWcParticle_Decal_Picture),texture); } break; @@ -6844,7 +6844,7 @@ static UUtError OWrParticle_DecalTextures_HandleCommand( WMtDialog *inDialog, UU char class_name[256]; char texture_name[256]; UUtUns32 modalreturn; - + listbox = WMrDialog_GetItemByID(inDialog, OWcParticle_Decal_Textures); texture_list = (M3tTextureMap**)WMrDialog_GetUserData(inDialog); index = WMrListBox_GetSelection(listbox); @@ -6856,14 +6856,14 @@ static UUtError OWrParticle_DecalTextures_HandleCommand( WMtDialog *inDialog, UU if( strlen(class_name) > P3cStringVarSize ) class_name[P3cStringVarSize+1] = 0; - - WMrDialog_ModalBegin(OWcDialog_Particle_ClassName, inDialog, OWrParticle_ClassName_Callback, (UUtUns32) class_name, &modalreturn ); - if( (UUtBool) modalreturn == UUcTrue ) + + WMrDialog_ModalBegin(OWcDialog_Particle_ClassName, inDialog, OWrParticle_ClassName_Callback, (UUtUns32) class_name, &modalreturn ); + if( (UUtBool) modalreturn == UUcTrue ) { new_class = P3rNewParticleClass(class_name,UUcTrue); UUmAssert( new_class ); - + if( new_class ) { new_class->definition->flags |= P3cParticleClassFlag_HasDecalData | P3cParticleClassFlag_Decorative; @@ -6888,11 +6888,11 @@ static UUtError OWrParticle_DecalTextures_HandleCommand( WMtDialog *inDialog, UU // otherwise fall through to cancel.... } case OWcParticle_Decal_Cancel: - OWgParticle_DecalTexture_Name[0] = 0; + OWgParticle_DecalTexture_Name[0] = 0; WMrDialog_ModalEnd(inDialog, 0); break; } - + return UUcError_None; } @@ -6903,13 +6903,13 @@ static UUtError OWrParticle_DecalTextures_HandleMenuCommand( WMtDialog *inDialog M3tTextureMap **texture_list; UUtUns32 index; M3tTextureMap *texture; - + // get a pointer to the texture listbox = WMrDialog_GetItemByID(inDialog, OWcParticle_Decal_Textures); texture_list = (M3tTextureMap**)WMrDialog_GetUserData(inDialog); index = WMrListBox_GetSelection(listbox); texture = texture_list[index]; - + // set the focus WMrWindow_SetFocus(listbox); @@ -6925,20 +6925,20 @@ static void OWrParticle_DecalTextures_HandleDrawItem( WMtDialog *inDialog, WMtDr UUtInt16 line_height; M3tTextureMap **texture_list; M3tTextureMap *texture; - + texture_list = (M3tTextureMap**)WMrDialog_GetUserData(inDialog); UUmAssert(texture_list); - + // set the dest dest.x = inDrawItem->rect.left; dest.y = inDrawItem->rect.top; - + // calc the width and height of the line line_width = inDrawItem->rect.right - inDrawItem->rect.left; line_height = inDrawItem->rect.bottom - inDrawItem->rect.top; - + dest.x = 5; - + // draw the texture name texture = texture_list[inDrawItem->data]; @@ -6950,36 +6950,36 @@ static void OWrParticle_DecalTextures_HandleDrawItem( WMtDialog *inDialog, WMtDr static UUtBool OWrParticle_DecalTextures_Callback( WMtDialog *inDialog, WMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWrParticle_DecalTextures_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWrParticle_DecalTextures_Destroy(inDialog); break; - + case WMcMessage_Command: OWrParticle_DecalTextures_HandleCommand(inDialog, inParam1, (WMtWindow*)inParam2); break; - + case WMcMessage_MenuCommand: OWrParticle_DecalTextures_HandleMenuCommand(inDialog, (WMtWindow*)inParam2, UUmLowWord(inParam1)); break; - + case WMcMessage_DrawItem: OWrParticle_DecalTextures_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Particle.h b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Particle.h index feddac6..5fdbd53 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Particle.h +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Particle.h @@ -570,35 +570,35 @@ OWrParticle_Edit_Callback( WMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2); - + UUtBool OWrParticle_Class_Callback( WMtDialog *inDialog, WMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2); - + UUtBool OWrParticle_Variables_Callback( WMtDialog *inDialog, WMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2); - + UUtBool OWrParticle_Appearance_Callback( WMtDialog *inDialog, WMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2); - + UUtBool OWrParticle_Attractor_Callback( WMtDialog *inDialog, WMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2); - + UUtBool OWrParticle_Value_Int_Callback( WMtDialog *inDialog, @@ -647,7 +647,7 @@ OWrParticle_RenameVar_Callback( WMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2); - + UUtBool OWrParticle_Actions_Callback( WMtDialog *inDialog, @@ -738,4 +738,4 @@ UUtError OWrRevert_Particles(void); UUtError OWrRevert_Particle(P3tParticleClass *inClass); // ====================================================================== -#endif /* ONI_WIN_PARTICLE_H */ \ No newline at end of file +#endif /* ONI_WIN_PARTICLE_H */ diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Settings.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Settings.c index ac5610f..26b9c35 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Settings.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Settings.c @@ -18,7 +18,7 @@ typedef struct OWtSettings_Player { char player_name[ONcMaxPlayerNameLength + 1]; char character_class[AIcMaxClassNameLen + 1]; - + } OWtSettings_Player; // ====================================================================== @@ -35,7 +35,7 @@ OWiSettings_Player_Initialize( WMtDialog *inDialog) { WMtWindow *window; - + // set the player name window = WMrDialog_GetItemByID(inDialog, OWcSettings_Player_PlayerName); if (window != NULL) @@ -46,13 +46,13 @@ OWiSettings_Player_Initialize( (UUtUns32)OWgSettings_Player.player_name, 0); } - + // get the character class popup window = WMrDialog_GetItemByID(inDialog, OWcSettings_Player_CharacterClass); if (window == NULL) { // add the character classes to the popup - + // set the character class } } @@ -63,7 +63,7 @@ OWiSettings_Player_Destroy( WMtDialog *inDialog) { WMtWindow *window; - + // get the player name window = WMrDialog_GetItemByID(inDialog, OWcSettings_Player_PlayerName); if (window != NULL) @@ -74,7 +74,7 @@ OWiSettings_Player_Destroy( (UUtUns32)OWgSettings_Player.player_name, (UUtUns32)ONcMaxPlayerNameLength); } - + // get the character class window = WMrDialog_GetItemByID(inDialog, OWcSettings_Player_CharacterClass); if (window != NULL) @@ -91,19 +91,19 @@ OWrSettings_Player_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiSettings_Player_Initialize(inDialog); break; - + case WMcMessage_Destroy: OWiSettings_Player_Destroy(inDialog); break; - + case WMcMessage_Command: switch (UUmLowWord(inParam1)) { @@ -112,12 +112,12 @@ OWrSettings_Player_Callback( break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -150,6 +150,6 @@ OWrSettings_Initialize( // initialize the player settings UUrString_Copy(OWgSettings_Player.player_name, "Player", ONcMaxPlayerNameLength); UUrString_Copy(OWgSettings_Player.character_class, "konoko_generic", AIcMaxClassNameLen); - + return UUcError_None; -} \ No newline at end of file +} diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound.c index 2d41ccc..2444aa8 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound.c @@ -38,7 +38,7 @@ typedef struct OWtWS { UUtMemory_Array *dir_array; SStSoundData *selected_sound_data; - + } OWtWS; typedef struct OWtSGP @@ -48,7 +48,7 @@ typedef struct OWtSGP char item_name[OScMaxNameLength]; SStGroup *group; UUtUns32 group_id; - + } OWtSGP; typedef struct OWtASP @@ -59,7 +59,7 @@ typedef struct OWtASP SStAmbient *ambient; UUtUns32 ambient_id; SStPlayID play_id; - + } OWtASP; typedef struct OWtISP @@ -69,7 +69,7 @@ typedef struct OWtISP char item_name[OScMaxNameLength]; SStImpulse *impulse; UUtUns32 impulse_id; - + } OWtISP; typedef struct OWtSCM @@ -79,14 +79,14 @@ typedef struct OWtSCM UUtUns32 clip_ss_id; char clip_name[OScMaxNameLength]; - + } OWtSCM; typedef struct OWtSS { OStCollectionType type; UUtUns32 item_id; - + } OWtSS; typedef struct OWtStAP @@ -97,17 +97,17 @@ typedef struct OWtStAP TRtAnimation *animation; UUtUns32 frame; char variant_name[ONcMaxVariantNameLength]; - + } OWtStAP; typedef struct OWtSA { TRtAnimation *animation; /* in/out */ - + TRtAnimation **animation_list; /* internal use only */ UUtUns32 num_animations; /* internal use only */ UUtUns32 insert_from_index; /* internal use only */ - + } OWtSA; // ====================================================================== @@ -123,7 +123,7 @@ OWiSSG_Display( WMtDialog *inParentDialog, UUtUns32 *ioSoundGroupID, SStGroup **ioSoundGroup); - + // ====================================================================== // functions // ====================================================================== @@ -138,36 +138,36 @@ OWiCN_Callback( UUtBool handled; WMtWindow *editfield; char *name; - + handled = UUcTrue; - + // get a pointer to the name name = (char*)WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: // get a pointer to the edit field editfield = WMrDialog_GetItemByID(inDialog, OWcCN_EF_Name); UUmAssert(editfield); - + // set a limit on the length of the name WMrMessage_Send(editfield, EFcMessage_SetMaxChars, OScMaxNameLength, 0); - + // set the name WMrMessage_Send(editfield, EFcMessage_SetText, (UUtUns32)name, 0); - + // set focus to the editfield WMrWindow_SetFocus(editfield); break; - + case WMcMessage_Command: if (UUmHighWord(inParam1) != WMcNotify_Click) { break; } - + // get a pointer to the edit field editfield = WMrDialog_GetItemByID(inDialog, OWcCN_EF_Name); UUmAssert(editfield); - + switch (UUmLowWord(inParam1)) { case OWcCN_Btn_OK: @@ -177,23 +177,23 @@ OWiCN_Callback( EFcMessage_GetText, (UUtUns32)name, OScMaxNameLength); - + // end the dialog WMrDialog_ModalEnd(inDialog, OWcCN_Btn_OK); break; - + case OWcCN_Btn_Cancel: // end the dialog WMrDialog_ModalEnd(inDialog, OWcCN_Btn_Cancel); break; } break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -214,41 +214,41 @@ OWiWS_SelectSoundData( BFtFileRef **dir_array; BFtFileRef *current_directory; BFtFileRef *file_ref; - + file_ref = NULL; - + // get a pointer to the user data ws = (OWtWS*)WMrDialog_GetUserData(inDialog); UUmAssert(ws); - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcWS_LB_DirContents); UUmAssert(listbox); - + // get the selected file's name WMrMessage_Send(listbox, LBcMessage_GetText, (UUtUns32)selected_file_name, (UUtUns32)-1); UUrString_MakeLowerCase(selected_file_name, BFcMaxFileNameLength); - + // get the SStSoundData* corresponding to this file ws->selected_sound_data = SSrSoundData_GetByName(selected_file_name, UUcTrue); if (ws->selected_sound_data != NULL) { goto cleanup; } - + // the file doesn't have a corresponding SStSoundData* so import it on the fly - + // get a pointer to the directory array dir_array = (BFtFileRef**)UUrMemory_Array_GetMemory(ws->dir_array); UUmAssert(dir_array); - + current_directory = dir_array[(UUrMemory_Array_GetUsedElems(ws->dir_array) - 1)]; - + // create the file ref error = BFrFileRef_DuplicateAndAppendName(current_directory, selected_file_name, &file_ref); if (error != UUcError_None) { goto cleanup; } - + // create a new sound data error = SSrSoundData_New(file_ref, &ws->selected_sound_data); if (error != UUcError_None) { goto cleanup; } - + cleanup: // delete the file ref if (file_ref) @@ -256,7 +256,7 @@ OWiWS_SelectSoundData( UUrMemory_Block_Delete(file_ref); file_ref = NULL; } - + return error; } @@ -272,20 +272,20 @@ OWiWS_FillListbox( // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcWS_LB_DirContents); UUmAssert(listbox); - + // initialize the directory info directory_info.directory_ref = inFileRef; directory_info.flags = (LBcDirectoryInfoFlag_Files | LBcDirectoryInfoFlag_Directory); directory_info.prefix[0] = '\0'; UUrString_Copy(directory_info.suffix, ".wav", BFcMaxFileNameLength); - + // set the directory of the listbox WMrMessage_Send( listbox, LBcMessage_SetDirectoryInfo, (UUtUns32)&directory_info, (UUtUns32)UUcTrue); - + // add .aif files to listbox directory_info.flags = LBcDirectoryInfoFlag_Files; UUrString_Copy(directory_info.suffix, ".aif", BFcMaxFileNameLength); @@ -294,7 +294,7 @@ OWiWS_FillListbox( LBcMessage_SetDirectoryInfo, (UUtUns32)&directory_info, (UUtUns32)UUcFalse); - + // add .aif files to listbox directory_info.flags = LBcDirectoryInfoFlag_Files; UUrString_Copy(directory_info.suffix, ".aiff", BFcMaxFileNameLength); @@ -318,15 +318,15 @@ OWiWS_EnableButtons( WMtWindow *inListBox) { UUtUns32 item_data; - UUtBool can_select; + UUtBool can_select; WMtWindow *button; - + can_select = UUcFalse; - + // get the data of the currently selected item item_data = WMrMessage_Send(inListBox, LBcMessage_GetItemData, 0, (UUtUns32)-1); if (item_data == LBcDirItemType_File) { can_select = UUcTrue; } - + // enable or disable the select button depending on the type of // item currently selected button = WMrDialog_GetItemByID(inDialog, OWcWS_Btn_Select); @@ -343,11 +343,11 @@ OWiWS_SelectItem( UUtError error; OWtWS *ws; UUtUns32 item_data; - + // get a pointer to the user data ws = (OWtWS*)WMrDialog_GetUserData(inDialog); UUmAssert(ws); - + // get the data of the currently selected item item_data = WMrMessage_Send(inListBox, LBcMessage_GetItemData, 0, (UUtUns32)-1); if (item_data == LBcDirItemType_File) @@ -366,42 +366,42 @@ OWiWS_SelectItem( UUtUns32 index; UUtBool mem_moved; UUtUns32 num_elements; - + // get a pointer to the dir_array dir_array = UUrMemory_Array_GetMemory(ws->dir_array); UUmAssert(dir_array); - + // get the number of elements in the array num_elements = UUrMemory_Array_GetUsedElems(ws->dir_array); - + // get the selected directories name WMrMessage_Send(inListBox, LBcMessage_GetText, (UUtUns32)selected_dir_name, (UUtUns32)-1); - + // build a directory ref to the selected directory - error = + error = BFrFileRef_DuplicateAndAppendName( dir_array[(num_elements - 1)], selected_dir_name, &directory_ref); UUmError_ReturnOnError(error); - + // add the directory_ref to the dir_array error = UUrMemory_Array_GetNewElement(ws->dir_array, &index, &mem_moved); UUmError_ReturnOnError(error); - + if (mem_moved) { // get a pointer to the dir_array dir_array = UUrMemory_Array_GetMemory(ws->dir_array); UUmAssert(dir_array); } - + dir_array[index] = directory_ref; - + // get a pointer to the popup menu popup = WMrDialog_GetItemByID(inDialog, OWcWS_PM_Directory); UUmAssert(popup); - + // set the item data item_data.flags = WMcMenuItemFlag_Enabled; item_data.id = (UUtUns16)index; @@ -409,18 +409,18 @@ OWiWS_SelectItem( item_data.title, BFrFileRef_GetLeafName(directory_ref), BFcMaxFileNameLength); - + // put the directory name into the popup error = WMrPopupMenu_AppendItem(popup, &item_data); UUmError_ReturnOnError(error); - + error = WMrPopupMenu_SetSelection(popup, (UUtUns16)index); UUmError_ReturnOnError(error); - + // set the focus on the listbox WMrWindow_SetFocus(inListBox); } - + return UUcError_None; } @@ -436,11 +436,11 @@ OWiWS_InitDialog( WMtWindow *popup; WMtMenuItemData item_data; UUtUns32 index; - + // get the user data ws = (OWtWS*)WMrDialog_GetUserData(inDialog); if (ws == NULL) { goto cleanup; } - + // init ws ws->selected_sound_data = NULL; ws->dir_array = @@ -450,7 +450,7 @@ OWiWS_InitDialog( 0, 1); if (ws->dir_array == NULL) { goto cleanup; } - + // get the sound directory ref error = SSrGetSoundDirectory(&directory_ref); if (error != UUcError_None) @@ -463,22 +463,22 @@ OWiWS_InitDialog( goto cleanup; } - + // add an element to the array error = UUrMemory_Array_GetNewElement(ws->dir_array, &index, NULL); if (error != UUcError_None) { goto cleanup; } - + // get a pointer to the dir array dir_array = (BFtFileRef**)UUrMemory_Array_GetMemory(ws->dir_array); UUmAssert(dir_array); - + // add the directory_ref to the dir_array dir_array[index] = directory_ref; - + // get a pointer to the popup menu popup = WMrDialog_GetItemByID(inDialog, OWcWS_PM_Directory); UUmAssert(popup); - + // set the item data item_data.flags = WMcMenuItemFlag_Enabled; item_data.id = 0; @@ -486,16 +486,16 @@ OWiWS_InitDialog( item_data.title, BFrFileRef_GetLeafName(directory_ref), BFcMaxFileNameLength); - + // put the directory name into the popup error = WMrPopupMenu_AppendItem(popup, &item_data); if (error != UUcError_None) { goto cleanup; } - + error = WMrPopupMenu_SetSelection(popup, 0); if (error != UUcError_None) { goto cleanup; } - + return; - + cleanup: WMrDialog_ModalEnd(inDialog, OWcWS_Btn_Cancel); } @@ -509,24 +509,24 @@ OWiWS_Destroy( // get a pointer to the user data ws = (OWtWS*)WMrDialog_GetUserData(inDialog); - + // delete the dir_array if (ws->dir_array) { BFtFileRef **dir_array; UUtUns32 num_elements; UUtUns32 i; - + num_elements = UUrMemory_Array_GetUsedElems(ws->dir_array); dir_array = (BFtFileRef**)UUrMemory_Array_GetMemory(ws->dir_array); - + // delete the BFtFileRefs for (i = 0; i < num_elements; i++) { UUrMemory_Block_Delete(dir_array[i]); dir_array[i] = NULL; } - + // delete the memory array UUrMemory_Array_Delete(ws->dir_array); ws->dir_array = NULL; @@ -542,7 +542,7 @@ OWiWS_HandleCommand( { UUtUns16 command_type; UUtUns16 control_id; - + // interpret inParam1 command_type = UUmHighWord(inParam1); control_id = UUmLowWord(inParam1); @@ -553,11 +553,11 @@ OWiWS_HandleCommand( OWiWS_SelectSoundData(inDialog); WMrDialog_ModalEnd(inDialog, OWcWS_Btn_Select); break; - + case OWcWS_Btn_Cancel: WMrDialog_ModalEnd(inDialog, OWcWS_Btn_Cancel); break; - + case OWcWS_LB_DirContents: if (command_type == LBcNotify_SelectionChanged) { @@ -583,25 +583,25 @@ OWiWS_HandleMenuCommand( UUtUns32 num_dirs; BFtFileRef **dir_array; UUtBool mem_moved; - + // set the current depth ws = (OWtWS*)WMrDialog_GetUserData(inDialog); - + // get a pointer to the directory array dir_array = (BFtFileRef**)UUrMemory_Array_GetMemory(ws->dir_array); - + // delete the menu items after inItemID num_dirs = UUrMemory_Array_GetUsedElems(ws->dir_array); for (i = (inItemID + 1); i < num_dirs; i++) { // remove the directory from the popup menu WMrPopupMenu_RemoveItem(inPopupMenu, (UUtUns16)i); - + // delete the BFtFileRef UUrMemory_Block_Delete(dir_array[i]); dir_array[i] = NULL; } - + // remove the entry from the directory array UUrMemory_Array_SetUsedElems(ws->dir_array, (inItemID + 1), &mem_moved); @@ -618,35 +618,35 @@ OWiWS_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiWS_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiWS_Destroy(inDialog); break; - + case WMcMessage_Command: OWiWS_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_MenuCommand: OWiWS_HandleMenuCommand( inDialog, (WMtWindow*)inParam2, (UUtUns32)UUmLowWord(inParam1)); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -668,12 +668,12 @@ OWiSPP_SaveFields( float max_volume_percent; float min_pitch_percent; float max_pitch_percent; - + // get the fields editfield = WMrDialog_GetItemByID(inDialog, OWcSPP_EF_Weight); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, 128); sscanf(string, "%d", &weight); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSPP_EF_MinVol); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, 128); sscanf(string, "%f", &min_volume_percent); @@ -689,7 +689,7 @@ OWiSPP_SaveFields( editfield = WMrDialog_GetItemByID(inDialog, OWcSPP_EF_MaxPitch); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, 128); sscanf(string, "%f", &max_pitch_percent); - + // check ranges if (min_volume_percent > max_volume_percent) { @@ -711,18 +711,18 @@ OWiSPP_SaveFields( WMrWindow_SetFocus(WMrDialog_GetItemByID(inDialog, OWcSPP_EF_MinPitch)); return UUcFalse; } - + // get a pointer to the permutation perm = (SStPermutation*)WMrDialog_GetUserData(inDialog); UUmAssert(perm); - + // save the data perm->weight = weight; perm->min_volume_percent = min_volume_percent; perm->max_volume_percent = max_volume_percent; perm->min_pitch_percent = min_pitch_percent; perm->max_pitch_percent = max_pitch_percent; - + return UUcTrue; } @@ -736,7 +736,7 @@ OWiSPP_InitDialog( WMtWindow *editfield; const char *name; char string[128]; - + // get a pointer to the permutation perm = (SStPermutation*)WMrDialog_GetUserData(inDialog); if (perm == NULL) @@ -744,18 +744,18 @@ OWiSPP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcSPP_Btn_Cancel); return; } - + // set the name name = SSrPermutation_GetName(perm); text = WMrDialog_GetItemByID(inDialog, OWcSPP_Txt_Name); UUmAssert(text); WMrWindow_SetTitle(text, name, BFcMaxFileNameLength); - + // set the edit fields editfield = WMrDialog_GetItemByID(inDialog, OWcSPP_EF_Weight); sprintf(string, "%d", perm->weight); WMrMessage_Send(editfield, EFcMessage_SetText, (UUtUns32)string, 0); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSPP_EF_MinVol); sprintf(string, "%1.2f", perm->min_volume_percent); WMrMessage_Send(editfield, EFcMessage_SetText, (UUtUns32)string, 0); @@ -788,7 +788,7 @@ OWiSPP_HandleCommand( WMrDialog_ModalEnd(inDialog, OWcSPP_Btn_Save); } break; - + case OWcSPP_Btn_Cancel: WMrDialog_ModalEnd(inDialog, OWcSPP_Btn_Cancel); break; @@ -804,24 +804,24 @@ OWiSPP_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiSPP_InitDialog(inDialog); break; - + case WMcMessage_Command: OWiSPP_HandleCommand(inDialog, inParam1); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -839,7 +839,7 @@ OWiSGP_EnableButtons( WMtWindow *button; UUtBool permutation_selected; UUtBool can_save; - + // get a pointer to the listbox permutation_selected = UUcFalse; if (SSrGroup_GetNumPermutations(inSGP->group) > 0) @@ -850,20 +850,20 @@ OWiSGP_EnableButtons( permutation_selected = (WMrMessage_Send(listbox, LBcMessage_GetSelection, 0, 0) != LBcError); } - + // update the buttons can_save = OSrCollection_IsLocked(OSrCollection_GetByType(OScCollectionType_Group)) == UUcFalse; - + button = WMrDialog_GetItemByID(inDialog, OWcSGP_Btn_AddPerm); WMrWindow_SetEnabled(button, can_save); - + button = WMrDialog_GetItemByID(inDialog, OWcSGP_Btn_EditPerm); WMrWindow_SetEnabled(button, can_save && permutation_selected); - + button = WMrDialog_GetItemByID(inDialog, OWcSGP_Btn_PlayPerm); WMrWindow_SetEnabled(button, can_save && permutation_selected); - + button = WMrDialog_GetItemByID(inDialog, OWcSGP_Btn_DeletePerm); WMrWindow_SetEnabled(button, can_save && permutation_selected); } @@ -876,20 +876,20 @@ OWiSGP_SaveGroup( { char name[OScMaxNameLength]; SStGroup *item_group; - + // get the name from the editfield WMrMessage_Send( WMrDialog_GetItemByID(inDialog, OWcSGP_EF_Name), EFcMessage_GetText, (UUtUns32)name, OScMaxNameLength); - + // save the item name OSrCollection_Item_SetName( inSGP->collection, OSrItem_GetID(inSGP->item), name); - + // save the group data item_group = SSrGroup_GetByID(OSrItem_GetID(inSGP->item)); UUmAssert(inSGP->group->id == inSGP->group_id); @@ -906,7 +906,7 @@ OWiSGP_SetFields( WMtWindow *editfield; WMtWindow *listbox; UUtUns32 i; - + // set the name editfield = WMrDialog_GetItemByID(inDialog, OWcSGP_EF_Name); WMrMessage_Send( @@ -914,17 +914,17 @@ OWiSGP_SetFields( EFcMessage_SetText, (UUtUns32)inSGP->item_name, 0); - + // reset the permutations list box listbox = WMrDialog_GetItemByID(inDialog, OWcSGP_LB_Permutations); WMrMessage_Send(listbox, LBcMessage_Reset, 0, 0); - + // fill in the listbox for (i = 0; i < SSrGroup_GetNumPermutations(inSGP->group); i++) { WMrMessage_Send(listbox, LBcMessage_AddString, i, 0); } - + // select the first item WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcTrue, 0); } @@ -940,9 +940,9 @@ OWiSGP_AddPermutation( UUtUns32 perm_index; SStPermutation *perm; OWtWS ws; - + UUmAssert(inDialog); - + // select the wav file to use error = WMrDialog_ModalBegin( @@ -953,7 +953,7 @@ OWiSGP_AddPermutation( &message); UUmError_ReturnOnError(error); if (message == OWcWS_Btn_Cancel) { return UUcError_None; } - + // add the permutation to the group error = SSrGroup_Permutation_New( @@ -972,11 +972,11 @@ OWiSGP_AddPermutation( } return error; } - + // get a pointer to the permutation perm = SSrGroup_Permutation_Get(inSGP->group, perm_index); UUmAssert(perm); - + // edit the permutation error = WMrDialog_ModalBegin( @@ -986,22 +986,22 @@ OWiSGP_AddPermutation( (UUtUns32)perm, &message); UUmError_ReturnOnError(error); - + if (message == OWcSPP_Btn_Save) { WMtWindow *listbox; - + // update the dialog's fields OWiSGP_SetFields(inDialog, inSGP); - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSGP_LB_Permutations); UUmAssert(listbox); - + // select the permutation that was just added WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcTrue, perm_index); } - + return UUcError_None; } @@ -1016,23 +1016,23 @@ OWiSGP_EditPermutation( SStPermutation *perm; UUtUns32 perm_index; UUtUns32 message; - + UUmAssert(inDialog); - + if (SSrGroup_GetNumPermutations(inSGP->group) == 0) { return UUcError_None; } - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSGP_LB_Permutations); UUmAssert(listbox); - + // get the selected item id perm_index = WMrMessage_Send(listbox, LBcMessage_GetSelection, 0, 0); UUmAssert(perm_index < SSrGroup_GetNumPermutations(inSGP->group)); - + // get a pointer to the permutation perm = SSrGroup_Permutation_Get(inSGP->group, perm_index); UUmAssert(perm); - + // edit the permutation error = WMrDialog_ModalBegin( @@ -1042,7 +1042,7 @@ OWiSGP_EditPermutation( (UUtUns32)perm, &message); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1055,24 +1055,24 @@ OWiSGP_PlayPermutation( WMtWindow *listbox; UUtUns32 perm_index; SStPermutation *perm; - + UUmAssert(inDialog); - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSGP_LB_Permutations); UUmAssert(listbox); - + // get the selected item id perm_index = WMrMessage_Send(listbox, LBcMessage_GetSelection, 0, 0); UUmAssert(perm_index < SSrGroup_GetNumPermutations(inSGP->group)); - + // get a pointer to the permutation perm = SSrGroup_Permutation_Get(inSGP->group, perm_index); UUmAssert(perm); - + // play the permutation SSrPermutation_Play(perm, NULL); - + return UUcError_None; } @@ -1085,9 +1085,9 @@ OWiSGP_DeletePermutation( WMtWindow *listbox; UUtUns32 perm_index; UUtUns32 message; - + UUmAssert(inDialog); - + // ask the user to confirm delete message = WMrDialog_MessageBox( @@ -1096,21 +1096,21 @@ OWiSGP_DeletePermutation( "Are you sure you want to delete the selected permutation?", WMcMessageBoxStyle_Yes_No); if (message == WMcDialogItem_No) { return UUcError_None; } - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSGP_LB_Permutations); UUmAssert(listbox); - + // get the selected permutation's index perm_index = WMrMessage_Send(listbox, LBcMessage_GetSelection, 0, 0); UUmAssert(perm_index < SSrGroup_GetNumPermutations(inSGP->group)); - + // delete the permutation from the group SSrGroup_Permutation_Delete(inSGP->group, perm_index); - + // select the permutation WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcTrue, 0); - + return UUcError_None; } @@ -1124,7 +1124,7 @@ OWiSGP_InitDialog( WMtWindow *editfield; UUtError error; SStGroup *item_group; - + // get the item item = (OStItem*)WMrDialog_GetUserData(inDialog); if (item == NULL) @@ -1132,7 +1132,7 @@ OWiSGP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcSGP_Btn_Cancel); return; } - + // allocate memory for the OWtSGP sgp = (OWtSGP*)UUrMemory_Block_New(sizeof(OWtSGP)); if (sgp == NULL) @@ -1140,7 +1140,7 @@ OWiSGP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcSGP_Btn_Cancel); return; } - + // initialize the sgp sgp->collection = OSrCollection_GetByType(OScCollectionType_Group); sgp->item = item; @@ -1152,13 +1152,13 @@ OWiSGP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcSGP_Btn_Cancel); return; } - + // copy the data from the item's sound group to the sgp group UUmAssert(sgp->group->id == sgp->group_id); item_group = SSrGroup_GetByID(OSrItem_GetID(item)); sgp->group = SSrGroup_GetByID(sgp->group_id); // must update the group pointer UUmAssert(sgp->group->id == sgp->group_id); - error = + error = SSrGroup_Copy( item_group, sgp->group); @@ -1169,23 +1169,23 @@ OWiSGP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcSGP_Btn_Cancel); return; } - + // store the sgp in the user data WMrDialog_SetUserData(inDialog, (UUtUns32)sgp); - - // fill the editfield and the listbox + + // fill the editfield and the listbox OWiSGP_SetFields(inDialog, sgp); - + // enable button because new sound group's won't have permutations OWiSGP_EnableButtons(inDialog, sgp); - + // get a pointer to the edit field editfield = WMrDialog_GetItemByID(inDialog, OWcSGP_EF_Name); UUmAssert(editfield); - + // set a limit on the length of the name WMrMessage_Send(editfield, EFcMessage_SetMaxChars, OScMaxNameLength, 0); - + // make the edit field the text focus WMrWindow_SetFocus(editfield); } @@ -1200,12 +1200,12 @@ OWiSGP_Destroy( // get the sgp sgp = (OWtSGP*)WMrDialog_GetUserData(inDialog); if (sgp == NULL) { return; } - + // delete the allocated SStGroup SSrGroup_Delete(sgp->group_id); sgp->group_id = SScInvalidID; sgp->group = NULL; - + // delete the memory used by the sgp UUrMemory_Block_Delete(sgp); WMrDialog_SetUserData(inDialog, 0); @@ -1221,11 +1221,11 @@ OWiSGP_HandleCommand( UUtUns16 command_type; UUtUns16 control_id; OWtSGP *sgp; - + // interpret inParam1 command_type = UUmHighWord(inParam1); control_id = UUmLowWord(inParam1); - + // get the sgp sgp = (OWtSGP*)WMrDialog_GetUserData(inDialog); if (sgp == NULL) @@ -1233,7 +1233,7 @@ OWiSGP_HandleCommand( WMrDialog_ModalEnd(inDialog, OWcSGP_Btn_Cancel); return; } - + if (control_id == OWcSGP_LB_Permutations) { if (command_type == LBcNotify_SelectionChanged) @@ -1252,7 +1252,7 @@ OWiSGP_HandleCommand( case OWcSGP_Btn_Save: { char name[OScMaxNameLength]; - + WMrMessage_Send( WMrDialog_GetItemByID(inDialog, OWcSGP_EF_Name), EFcMessage_GetText, @@ -1265,7 +1265,7 @@ OWiSGP_HandleCommand( "Error", "You must supply a name for the sound group.", WMcMessageBoxStyle_OK); - + WMrWindow_SetFocus(WMrDialog_GetItemByID(inDialog, OWcSGP_EF_Name)); } else @@ -1275,27 +1275,27 @@ OWiSGP_HandleCommand( } } break; - + case OWcSGP_Btn_Cancel: WMrDialog_ModalEnd(inDialog, OWcSGP_Btn_Cancel); break; - + case OWcSGP_Btn_AddPerm: OWiSGP_AddPermutation(inDialog, sgp); break; - + case OWcSGP_Btn_EditPerm: OWiSGP_EditPermutation(inDialog, sgp); break; - + case OWcSGP_Btn_PlayPerm: OWiSGP_PlayPermutation(inDialog, sgp); break; - + case OWcSGP_Btn_DeletePerm: OWiSGP_DeletePermutation(inDialog, sgp); break; - + case OWcSGP_Btn_Play: SSrGroup_Play(sgp->group, NULL); break; @@ -1330,27 +1330,27 @@ OWiSGP_HandleDrawItem( UUtInt16 line_height; SStPermutation *perm; char string[128]; - + // get a pointer to the sgp sgp = (OWtSGP*)WMrDialog_GetUserData(inDialog); UUmAssert(sgp); - + // get a pointer to the permutation perm = SSrGroup_Permutation_Get(sgp->group, inDrawItem->data); if (perm == NULL) { return; } - + // get a pointer to the partspec_ui // partspec_ui = PSrPartSpecUI_GetActive(); // UUmAssert(partspec_ui); - + // set the dest dest.x = inDrawItem->rect.left; dest.y = inDrawItem->rect.top; - + // calc the width and height of the line line_width = inDrawItem->rect.right - inDrawItem->rect.left; line_height = inDrawItem->rect.bottom - inDrawItem->rect.top; - + /* if (inDrawItem->state & WMcDrawItemState_Selected) { // draw the hilite @@ -1363,12 +1363,12 @@ OWiSGP_HandleDrawItem( line_height, M3cMaxAlpha); }*/ - + // setup the text drawing DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrText_SetStyle(TScStyle_Plain); DCrText_SetShade(IMcShade_Black); - + // draw the perm's sound_data instance name dest.x = 4; DCrDraw_String( @@ -1376,28 +1376,28 @@ OWiSGP_HandleDrawItem( SSrPermutation_GetName(perm), &inDrawItem->rect, &dest); - + // draw the perm's weight dest.x = 160; sprintf(string, "%d", perm->weight); DCrDraw_String(inDrawItem->draw_context, string, &inDrawItem->rect, &dest); - - // draw the perm's min_volume_percent + + // draw the perm's min_volume_percent dest.x = 200; sprintf(string, "%1.2f", perm->min_volume_percent); DCrDraw_String(inDrawItem->draw_context, string, &inDrawItem->rect, &dest); - - // draw the perm's max_volume_percent + + // draw the perm's max_volume_percent dest.x = 230; sprintf(string, "%1.2f", perm->max_volume_percent); DCrDraw_String(inDrawItem->draw_context, string, &inDrawItem->rect, &dest); - // draw the perm's min_pitch_percent + // draw the perm's min_pitch_percent dest.x = 265; sprintf(string, "%1.2f", perm->min_pitch_percent); DCrDraw_String(inDrawItem->draw_context, string, &inDrawItem->rect, &dest); - - // draw the perm's max_volume_percent + + // draw the perm's max_volume_percent dest.x = 295; sprintf(string, "%1.2f", perm->max_pitch_percent); DCrDraw_String(inDrawItem->draw_context, string, &inDrawItem->rect, &dest); @@ -1412,32 +1412,32 @@ OWiSGP_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiSGP_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiSGP_Destroy(inDialog); break; - + case WMcMessage_Command: OWiSGP_HandleCommand(inDialog, inParam1, (WMtWindow*)inParam2); break; - + case WMcMessage_DrawItem: OWiSGP_HandleDrawItem(inDialog, (WMtWindow*)inParam1, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -1457,14 +1457,14 @@ OWiSetGroupText( WMtWindow *text; char string[1024]; UUtUns32 message; - + text = WMrDialog_GetItemByID(inDialog, (UUtUns16)inDialogItemID); WMrWindow_SetTitle(text, "", OScMaxNameLength); - + if (*ioSoundGroup) { OStItem *item; - + item = OSrCollection_Item_GetByID( OSrCollection_GetByType(OScCollectionType_Group), @@ -1484,7 +1484,7 @@ OWiSetGroupText( "The %s group no longer exists. The %s group is being cleared.", inSoundGroupName, inSoundGroupName); - + message = WMrDialog_MessageBox( inDialog, @@ -1503,14 +1503,14 @@ OWiEditGroup( { UUtError error; OStItem *item; - + // get the item item = OSrCollection_Item_GetByID( OSrCollection_GetByType(OScCollectionType_Group), inSoundGroup->id); if (item == NULL) { return UUcError_Generic; } - + // edit the properties of the group error = WMrDialog_ModalBegin( @@ -1520,7 +1520,7 @@ OWiEditGroup( (UUtUns32)item, NULL); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -1536,7 +1536,7 @@ OWiASP_EnableButtons( OWtASP *inASP) { WMtWindow *button; - + // set the buttons button = WMrDialog_GetItemByID(inDialog, OWcASP_Btn_InGroupEdit); WMrWindow_SetEnabled(button, (inASP->ambient->in_sound != NULL)); @@ -1552,7 +1552,7 @@ OWiASP_EnableButtons( button = WMrDialog_GetItemByID(inDialog, OWcASP_Btn_DetailEdit); WMrWindow_SetEnabled(button, (inASP->ambient->detail != NULL)); - + button = WMrDialog_GetItemByID(inDialog, OWcASP_Btn_Start); WMrWindow_SetEnabled(button, (inASP->play_id == SScInvalidID)); @@ -1569,24 +1569,24 @@ OWiASP_SaveAmbient( char name[OScMaxNameLength]; SStAmbient *item_ambient; UUtUns16 priority; - + // get the name from the editfield WMrMessage_Send( WMrDialog_GetItemByID(inDialog, OWcASP_EF_Name), EFcMessage_GetText, (UUtUns32)name, OScMaxNameLength); - + // get the priority from the popup menu WMrPopupMenu_GetItemID( WMrDialog_GetItemByID(inDialog, OWcASP_PM_Priority), -1, &priority); inASP->ambient->priority = (SStPriority2)priority; - + // save the item name OSrCollection_Item_SetName(inASP->collection, OSrItem_GetID(inASP->item), name); - + // check ranges if (inASP->ambient->min_detail_time > inASP->ambient->max_detail_time) { @@ -1618,11 +1618,11 @@ OWiASP_SaveAmbient( WMrWindow_SetFocus(WMrDialog_GetItemByID(inDialog, OWcASP_EF_MaxVolDist)); return UUcFalse; } - + // save the ambient data item_ambient = SSrAmbient_GetByID(OSrItem_GetID(inASP->item)); SSrAmbient_Copy(inASP->ambient, item_ambient); - + return UUcTrue; } @@ -1636,22 +1636,22 @@ OWiASP_SetFields( WMtWindow *popup; WMtWindow *checkbox; char string[128]; - + // set the ambient sound's name editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_Name); WMrMessage_Send(editfield, EFcMessage_SetText, (UUtUns32)inASP->item_name, 0); - + // set the priority popup = WMrDialog_GetItemByID(inDialog, OWcASP_PM_Priority); WMrPopupMenu_SetSelection(popup, (UUtUns16)inASP->ambient->priority); - + // set the group names OWiSetGroupText(inDialog, OWcASP_Txt_InGroup, &inASP->ambient->in_sound, "In Sound"); OWiSetGroupText(inDialog, OWcASP_Txt_OutGroup, &inASP->ambient->out_sound, "Out Sound"); OWiSetGroupText(inDialog, OWcASP_Txt_BT1, &inASP->ambient->base_track1, "Base Track 1"); OWiSetGroupText(inDialog, OWcASP_Txt_BT2, &inASP->ambient->base_track2, "Base Track 2"); OWiSetGroupText(inDialog, OWcASP_Txt_Detail, &inASP->ambient->detail, "Detail"); - + // set the interrupt tracks on stop checkbox checkbox = WMrDialog_GetItemByID(inDialog, OWcASP_CB_InterruptOnStop); WMrMessage_Send( @@ -1659,7 +1659,7 @@ OWiASP_SetFields( CBcMessage_SetCheck, (UUtUns32)((inASP->ambient->flags & SScAmbientFlag_InterruptOnStop) != 0), 0); - + // set the play once checkbox checkbox = WMrDialog_GetItemByID(inDialog, OWcASP_CB_PlayOnce); WMrMessage_Send( @@ -1667,12 +1667,12 @@ OWiASP_SetFields( CBcMessage_SetCheck, (UUtUns32)((inASP->ambient->flags & SScAmbientFlag_PlayOnce) != 0), 0); - + // set the minimum elapsed time editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_MinElapsedTime); sprintf(string, "%5.3f", inASP->ambient->min_detail_time); WMrMessage_Send(editfield, EFcMessage_SetText, (UUtUns32)string, 0); - + // set the maximum elapse time editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_MaxElapsedTime); sprintf(string, "%5.3f", inASP->ambient->max_detail_time); @@ -1692,7 +1692,7 @@ OWiASP_SetFields( editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_MinVolDist); sprintf(string, "%5.3f", inASP->ambient->min_volume_distance); WMrMessage_Send(editfield, EFcMessage_SetText, (UUtUns32)string, 0); - + OWiASP_EnableButtons(inDialog, inASP); } @@ -1705,7 +1705,7 @@ OWiASP_InitDialog( OWtASP *asp; UUtError error; WMtWindow *editfield; - + // get the item item = (OStItem*)WMrDialog_GetUserData(inDialog); if (item == NULL) @@ -1713,7 +1713,7 @@ OWiASP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcSGP_Btn_Cancel); return; } - + // allocate memory for the asp asp = (OWtASP*)UUrMemory_Block_New(sizeof(OWtSGP)); if (asp == NULL) @@ -1721,7 +1721,7 @@ OWiASP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcASP_Btn_Cancel); return; } - + // initialize the asp asp->collection = OSrCollection_GetByType(OScCollectionType_Ambient); asp->item = item; @@ -1734,9 +1734,9 @@ OWiASP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcASP_Btn_Cancel); return; } - + // copy the data from the item's ambient sound to the asp ambient - error = + error = SSrAmbient_Copy( SSrAmbient_GetByID(OSrItem_GetID(item)), asp->ambient); @@ -1746,23 +1746,23 @@ OWiASP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcSGP_Btn_Cancel); return; } - + // store the asp in the user data WMrDialog_SetUserData(inDialog, (UUtUns32)asp); - + // set the fields OWiASP_SetFields(inDialog, asp); - + // enable the buttons OWiASP_EnableButtons(inDialog, asp); - + // get a pointer to the edit field editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_Name); UUmAssert(editfield); - + // set a limit on the length of the name WMrMessage_Send(editfield, EFcMessage_SetMaxChars, OScMaxNameLength, 0); - + // set the focus on the name WMrWindow_SetFocus(editfield); } @@ -1773,22 +1773,22 @@ OWiASP_Destroy( WMtDialog *inDialog) { OWtASP *asp; - + // get a pointer to the asp asp = (OWtASP*)WMrDialog_GetUserData(inDialog); - + // stop any playing ambient sounds if (asp->play_id != SScInvalidID) { SSrAmbient_Stop(asp->play_id); asp->play_id = SScInvalidID; } - + // delete the allocated SStAmbient SSrAmbient_Delete(asp->ambient_id); asp->ambient_id = SScInvalidID; asp->ambient = NULL; - + // delete the memory used by the asp UUrMemory_Block_Delete(asp); WMrDialog_SetUserData(inDialog, 0); @@ -1805,16 +1805,16 @@ OWiASP_HandleCommand( UUtUns16 command_type; UUtUns16 control_id; UUtBool set_fields; - + // get a pointer to the asp asp = (OWtASP*)WMrDialog_GetUserData(inDialog); - + // interpret inParam1 command_type = UUmHighWord(inParam1); control_id = UUmLowWord(inParam1); - + set_fields = UUcFalse; - + if (command_type == WMcNotify_Click) { switch (control_id) @@ -1822,13 +1822,13 @@ OWiASP_HandleCommand( case OWcASP_Btn_Save: { char name[OScMaxNameLength]; - + WMrMessage_Send( WMrDialog_GetItemByID(inDialog, OWcASP_EF_Name), EFcMessage_GetText, (UUtUns32)name, OScMaxNameLength); - + if (TSrString_GetLength(name) == 0) { WMrDialog_MessageBox( @@ -1836,28 +1836,28 @@ OWiASP_HandleCommand( "Error", "You must supply a name for the ambient sound.", WMcMessageBoxStyle_OK); - + WMrWindow_SetFocus(WMrDialog_GetItemByID(inDialog, OWcASP_EF_Name)); - + break; } - + if (OWiASP_SaveAmbient(inDialog, asp) == UUcTrue) { WMrDialog_ModalEnd(inDialog, OWcASP_Btn_Save); } } break; - + case OWcASP_Btn_Cancel: WMrDialog_ModalEnd(inDialog, OWcASP_Btn_Cancel); break; - + case OWcASP_Btn_InGroupSet: OWiSSG_Display(inDialog, &asp->ambient->in_sound_id, &asp->ambient->in_sound); set_fields = UUcTrue; break; - + case OWcASP_Btn_InGroupEdit: OWiEditGroup(inDialog, asp->ambient->in_sound); break; @@ -1866,7 +1866,7 @@ OWiASP_HandleCommand( OWiSSG_Display(inDialog, &asp->ambient->out_sound_id, &asp->ambient->out_sound); set_fields = UUcTrue; break; - + case OWcASP_Btn_OutGroupEdit: OWiEditGroup(inDialog, asp->ambient->out_sound); break; @@ -1875,7 +1875,7 @@ OWiASP_HandleCommand( OWiSSG_Display(inDialog, &asp->ambient->detail_id, &asp->ambient->detail); set_fields = UUcTrue; break; - + case OWcASP_Btn_DetailEdit: OWiEditGroup(inDialog, asp->ambient->detail); break; @@ -1884,7 +1884,7 @@ OWiASP_HandleCommand( OWiSSG_Display(inDialog, &asp->ambient->base_track1_id, &asp->ambient->base_track1); set_fields = UUcTrue; break; - + case OWcASP_Btn_BT1Edit: OWiEditGroup(inDialog, asp->ambient->base_track1); break; @@ -1893,11 +1893,11 @@ OWiASP_HandleCommand( OWiSSG_Display(inDialog, &asp->ambient->base_track2_id, &asp->ambient->base_track2); set_fields = UUcTrue; break; - + case OWcASP_Btn_BT2Edit: OWiEditGroup(inDialog, asp->ambient->base_track2); break; - + case OWcASP_CB_InterruptOnStop: if (WMrMessage_Send(inControl, WMcMessage_GetValue, 0, 0)) { @@ -1908,7 +1908,7 @@ OWiASP_HandleCommand( asp->ambient->flags &= ~SScAmbientFlag_InterruptOnStop; } break; - + case OWcASP_Btn_Inc1: asp->ambient->sphere_radius += 1.0f; if (asp->ambient->sphere_radius > asp->ambient->min_volume_distance) @@ -1917,7 +1917,7 @@ OWiASP_HandleCommand( } set_fields = UUcTrue; break; - + case OWcASP_Btn_Dec1: asp->ambient->sphere_radius -= 1.0f; if (asp->ambient->sphere_radius < 0.0f) @@ -1926,7 +1926,7 @@ OWiASP_HandleCommand( } set_fields = UUcTrue; break; - + case OWcASP_Btn_Inc10: asp->ambient->sphere_radius += 10.0f; if (asp->ambient->sphere_radius > asp->ambient->min_volume_distance) @@ -1935,7 +1935,7 @@ OWiASP_HandleCommand( } set_fields = UUcTrue; break; - + case OWcASP_Btn_Dec10: asp->ambient->sphere_radius -= 10.0f; if (asp->ambient->sphere_radius < 0.0f) @@ -1944,11 +1944,11 @@ OWiASP_HandleCommand( } set_fields = UUcTrue; break; - + case OWcASP_Btn_Start: asp->play_id = SSrAmbient_Start(asp->ambient, NULL, NULL, NULL, 0.0f, 0.0f); break; - + case OWcASP_Btn_Stop: SSrAmbient_Stop(asp->play_id); asp->play_id = SScInvalidID; @@ -1964,40 +1964,40 @@ OWiASP_HandleCommand( asp->ambient->flags &= ~SScAmbientFlag_PlayOnce; } break; - + } - + // update the buttons OWiASP_EnableButtons(inDialog, asp); } else if (command_type == EFcNotify_ContentChanged) { char string[128]; - + WMrMessage_Send(inControl, EFcMessage_GetText, (UUtUns32)string, 128); - + switch (control_id) { case OWcASP_EF_Name: UUrString_Copy(asp->item_name, string, OScMaxNameLength); break; - + case OWcASP_EF_MinElapsedTime: sscanf(string, "%f", &asp->ambient->min_detail_time); break; - + case OWcASP_EF_MaxElapsedTime: sscanf(string, "%f", &asp->ambient->max_detail_time); break; - + case OWcASP_EF_SphereRadius: sscanf(string, "%f", &asp->ambient->sphere_radius); break; - + case OWcASP_EF_MinVolDist: sscanf(string, "%f", &asp->ambient->min_volume_distance); break; - + case OWcASP_EF_MaxVolDist: sscanf(string, "%f", &asp->ambient->max_volume_distance); break; @@ -2020,28 +2020,28 @@ OWiASP_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiASP_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiASP_Destroy(inDialog); break; - + case WMcMessage_Command: OWiASP_HandleCommand(inDialog, inParam1, (WMtWindow*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -2051,7 +2051,7 @@ OWrASP_Display( OStItem *inItem) { UUtError error; - + // edit the properties of the group error = WMrDialog_ModalBegin( @@ -2079,33 +2079,33 @@ OWiISP_SaveImpulse( SStImpulse *item_impulse; WMtWindow *editfield; char string[128]; - + // set the impulse sound's name editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_Name); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, 128); OSrCollection_Item_SetName(inISP->collection, OSrItem_GetID(inISP->item), string); - + // save the floats editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MaxVolDist); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, 128); sscanf(string, "%f", &inISP->impulse->max_volume_distance); - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MinVolDist); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, 128); sscanf(string, "%f", &inISP->impulse->min_volume_distance); - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MinVolAngle); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, 128); sscanf(string, "%f", &inISP->impulse->min_volume_angle); - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MaxVolAngle); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, 128); sscanf(string, "%f", &inISP->impulse->max_volume_angle); - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MinAngleAttn); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, 128); sscanf(string, "%f", &inISP->impulse->min_angle_attenuation); - + // check ranges if (inISP->impulse->max_volume_distance > inISP->impulse->min_volume_distance) { @@ -2131,7 +2131,7 @@ OWiISP_SaveImpulse( // save the impulse data item_impulse = SSrImpulse_GetByID(OSrItem_GetID(inISP->item)); SSrImpulse_Copy(inISP->impulse, item_impulse); - + return UUcTrue; } @@ -2144,18 +2144,18 @@ OWiISP_SetFields( WMtWindow *editfield; WMtWindow *popup; char string[128]; - + // set the impulse sound's name editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_Name); WMrMessage_Send(editfield, EFcMessage_SetText, (UUtUns32)inISP->item_name, 0); - + // set the group name OWiSetGroupText(inDialog, OWcISP_Txt_Group, &inISP->impulse->impulse_sound, "Impulse Sound"); - + // set the priority popup = WMrDialog_GetItemByID(inDialog, OWcISP_PM_Priority); WMrPopupMenu_SetSelection(popup, (UUtUns16)inISP->impulse->priority); - + // set the rest of the edit fields editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MaxVolDist); sprintf(string, "%5.3f", inISP->impulse->max_volume_distance); @@ -2179,7 +2179,7 @@ OWiISP_SetFields( sprintf(string, "%5.3f", inISP->impulse->min_angle_attenuation); WMrMessage_Send(editfield, EFcMessage_SetText, (UUtUns32)string, 0); WMrWindow_SetEnabled(editfield, UUcFalse); - + // set the button states if (inISP->impulse->impulse_sound != NULL) { @@ -2204,7 +2204,7 @@ OWiISP_InitDialog( OWtISP *isp; UUtError error; WMtWindow *editfield; - + // get the item item = (OStItem*)WMrDialog_GetUserData(inDialog); if (item == NULL) @@ -2212,7 +2212,7 @@ OWiISP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcISP_Btn_Cancel); return; } - + // allocate memory for the isp isp = (OWtISP*)UUrMemory_Block_New(sizeof(OWtISP)); if (isp == NULL) @@ -2220,7 +2220,7 @@ OWiISP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcISP_Btn_Cancel); return; } - + // initialize the isp isp->collection = OSrCollection_GetByType(OScCollectionType_Impulse); isp->item = item; @@ -2232,9 +2232,9 @@ OWiISP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcISP_Btn_Cancel); return; } - + // copy the data from the item's impulse sound to the isp impulse - error = + error = SSrImpulse_Copy( SSrImpulse_GetByID(OSrItem_GetID(item)), isp->impulse); @@ -2244,20 +2244,20 @@ OWiISP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcISP_Btn_Cancel); return; } - + // stop the isp in the user data WMrDialog_SetUserData(inDialog, (UUtUns32)isp); - + // set the fields OWiISP_SetFields(inDialog, isp); // get a pointer to the edit field editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_Name); UUmAssert(editfield); - + // set a limit on the length of the name WMrMessage_Send(editfield, EFcMessage_SetMaxChars, OScMaxNameLength, 0); - + // make the edit field the text focus WMrWindow_SetFocus(editfield); } @@ -2268,15 +2268,15 @@ OWiISP_Destroy( WMtDialog *inDialog) { OWtISP *isp; - + // get a pointer to the isp isp = (OWtISP*)WMrDialog_GetUserData(inDialog); - + // delete the allocated SStImpulse SSrImpulse_Delete(isp->impulse_id); isp->impulse_id = SScInvalidID; isp->impulse = NULL; - + // delete the memory used by the isp UUrMemory_Block_Delete(isp); WMrDialog_SetUserData(inDialog, 0); @@ -2290,10 +2290,10 @@ OWiISP_HandleCommand( WMtWindow *inControl) { OWtISP *isp; - + // get the isp isp = (OWtISP*)WMrDialog_GetUserData(inDialog); - + if (UUmHighWord(inParam1) == WMcNotify_Click) { switch (UUmLowWord(inParam1)) @@ -2301,13 +2301,13 @@ OWiISP_HandleCommand( case OWcISP_Btn_Save: { char name[OScMaxNameLength]; - + WMrMessage_Send( WMrDialog_GetItemByID(inDialog, OWcISP_EF_Name), EFcMessage_GetText, (UUtUns32)name, OScMaxNameLength); - + if (TSrString_GetLength(name) == 0) { WMrDialog_MessageBox( @@ -2315,12 +2315,12 @@ OWiISP_HandleCommand( "Error", "You must supply a name for the impulse sound.", WMcMessageBoxStyle_OK); - + WMrWindow_SetFocus(WMrDialog_GetItemByID(inDialog, OWcISP_EF_Name)); - + break; } - + if (OWiISP_SaveImpulse(inDialog, isp) == UUcTrue) { WMrDialog_ModalEnd(inDialog, OWcISP_Btn_Save); @@ -2331,11 +2331,11 @@ OWiISP_HandleCommand( case OWcISP_Btn_Cancel: WMrDialog_ModalEnd(inDialog, OWcISP_Btn_Cancel); break; - + case OWcISP_Btn_Set: { WMtWindow *text; - + // select a sound group OWiSSG_Display( inDialog, @@ -2353,7 +2353,7 @@ OWiISP_HandleCommand( WMrDialog_GetItemByID(inDialog, OWcISP_Btn_Edit), UUcFalse); } - + // put the name of the sound group into the text field text = WMrDialog_GetItemByID(inDialog, OWcISP_Txt_Group); WMrWindow_SetTitle(text, "", OScMaxNameLength); @@ -2368,14 +2368,14 @@ OWiISP_HandleCommand( } } break; - + case OWcISP_Btn_Edit: if (isp->impulse->impulse_sound != NULL) { OWiEditGroup(inDialog, isp->impulse->impulse_sound); } break; - + case OWcISP_Btn_Play: if (isp->impulse->impulse_sound == NULL) { @@ -2386,7 +2386,7 @@ OWiISP_HandleCommand( WMcMessageBoxStyle_OK); break; } - + SSrGroup_Play(isp->impulse->impulse_sound, NULL); break; } @@ -2414,7 +2414,7 @@ OWiISP_HandleMenuCommand( UUtUns32 inItemID) { OWtISP *isp; - + // get the isp isp = (OWtISP*)WMrDialog_GetUserData(inDialog); @@ -2431,35 +2431,35 @@ OWiISP_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiISP_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiISP_Destroy(inDialog); break; - + case WMcMessage_Command: OWiISP_HandleCommand(inDialog, inParam1, (WMtWindow*)inParam2); break; - + case WMcMessage_MenuCommand: OWiISP_HandleMenuCommand( inDialog, (WMtWindow*)inParam2, - (UUtUns32)UUmLowWord(inParam1)); + (UUtUns32)UUmLowWord(inParam1)); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -2493,31 +2493,31 @@ OWiSCM_Listbox_Fill( WMtWindow *popup; UUtUns32 i; UUtUns16 category_id; - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSCM_LB_Items); UUmAssert(listbox); - + // clear the listbox WMrMessage_Send(listbox, LBcMessage_Reset, 0, 0); - + // get a pointer to the popup popup = WMrDialog_GetItemByID(inDialog, OWcSCM_PM_Category); UUmAssert(popup); - + // get the id of the active category WMrPopupMenu_GetItemID(popup, -1, &category_id); - + // add categories to the listbox for (i = 0; i < OSrCollection_GetNumCategories(inSCM->collection); i++) { OStCategory *category; - + // get the category category = OSrCollection_Category_GetByIndex(inSCM->collection, i); if (category == NULL) { continue; } if (OSrCategory_GetParentCategoryID(category) != (UUtUns32)category_id) { continue; } - + // add the category WMrMessage_Send( listbox, @@ -2525,17 +2525,17 @@ OWiSCM_Listbox_Fill( (OWcCatToData | OSrCategory_GetID(category)), 0); } - + // add items to the listbox for (i = 0; i < OSrCollection_GetNumItems(inSCM->collection); i++) { OStItem *item; - + // get the item item = OSrCollection_Item_GetByIndex(inSCM->collection, i); if (item == NULL) { continue; } if (OSrItem_GetCategoryID(item) != category_id) { continue; } - + // add the item WMrMessage_Send( listbox, @@ -2543,10 +2543,10 @@ OWiSCM_Listbox_Fill( OSrItem_GetID(item), 0); } - + // select the first item in the list WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcTrue, 0); - + return UUcError_None; } @@ -2559,20 +2559,20 @@ OWiSCM_Popup_Init( UUtError error; WMtWindow *popup; WMtMenuItemData item_data; - + // get a pointer to the popup menu popup = WMrDialog_GetItemByID(inDialog, OWcSCM_PM_Category); UUmAssert(popup); - + // initialize the menu item item_data.id = 0; item_data.flags = WMcMenuItemFlag_Enabled; - UUrString_Copy(item_data.title, inSCM->collection_name, OScMaxNameLength); - + UUrString_Copy(item_data.title, inSCM->collection_name, OScMaxNameLength); + // append the type name to the popup error = WMrPopupMenu_AppendItem(popup, &item_data); UUmError_ReturnOnError(error); - + // select the first item WMrPopupMenu_SetSelection(popup, 0); @@ -2592,23 +2592,23 @@ OWiSCM_Enable_Buttons( UUtBool is_item; UUtBool can_paste; UUtUns32 result; - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSCM_LB_Items); UUmAssert(listbox); - + // find out of the currently selected item is a category is_category = UUcFalse; is_item = UUcFalse; can_paste = inSCM->clip_ss_id != SScInvalidID; - + result = WMrMessage_Send(listbox, LBcMessage_GetText, (UUtUns32)&item_id, (UUtUns32)-1); if (result != LBcError) { if (item_id & OWcCatToData) { is_category = UUcTrue; } - if ((item_id != SScInvalidID) && (is_category == UUcFalse)) { is_item = UUcTrue; } + if ((item_id != SScInvalidID) && (is_category == UUcFalse)) { is_item = UUcTrue; } } - + // if the collection is locked, then no changes can be made to the items or categories if (OSrCollection_IsLocked(inSCM->collection) == UUcTrue) { @@ -2616,26 +2616,26 @@ OWiSCM_Enable_Buttons( can_paste = UUcFalse; is_category = UUcFalse; } - + // enable/disable buttons button = WMrDialog_GetItemByID(inDialog, OWcSCM_Btn_EditItem); WMrWindow_SetEnabled(button, is_item); - + button = WMrDialog_GetItemByID(inDialog, OWcSCM_Btn_PlayItem); WMrWindow_SetEnabled(button, is_item); - + button = WMrDialog_GetItemByID(inDialog, OWcSCM_Btn_DeleteItem); WMrWindow_SetEnabled(button, is_item); - + button = WMrDialog_GetItemByID(inDialog, OWcSCM_Btn_CopyItem); WMrWindow_SetEnabled(button, is_item); - + button = WMrDialog_GetItemByID(inDialog, OWcSCM_Btn_PasteItem); WMrWindow_SetEnabled(button, can_paste); - + button = WMrDialog_GetItemByID(inDialog, OWcSCM_Btn_RenameCategory); WMrWindow_SetEnabled(button, is_category); - + button = WMrDialog_GetItemByID(inDialog, OWcSCM_Btn_DeleteCategory); WMrWindow_SetEnabled(button, is_category); } @@ -2651,7 +2651,7 @@ OWiSCM_OpenCategory( OStCategory *category; WMtWindow *popup; WMtMenuItemData item_data; - + // get a pointer to the category category = OSrCollection_Category_GetByID(inSCM->collection, inCategoryID); if (category == NULL) { return UUcError_Generic; } @@ -2659,22 +2659,22 @@ OWiSCM_OpenCategory( // get a pointer to the popup menu popup = WMrDialog_GetItemByID(inDialog, OWcSCM_PM_Category); UUmAssert(popup); - + // initialize the menu item item_data.id = (UUtUns16)inCategoryID; item_data.flags = WMcMenuItemFlag_Enabled; UUrString_Copy(item_data.title, OSrCategory_GetName(category), OScMaxNameLength); - + // append the type name to the popup error = WMrPopupMenu_AppendItem(popup, &item_data); UUmError_ReturnOnError(error); - + // select the item that was just added WMrPopupMenu_SetSelection(popup, (UUtUns16)inCategoryID); - + // update the buttons OWiSCM_Enable_Buttons(inDialog, inSCM); - + return UUcError_None; } @@ -2685,19 +2685,19 @@ OWiSCM_NewItem( OWtSCM *inSCM) { UUtError error; - + UUtUns32 new_ss_id; WMtDialogID dialog_id; WMtDialogCallback dialog_callback; - + UUtUns16 category_id; OStItem *item; - + WMtWindow *listbox; UUtUns32 list_index; - + UUtUns32 message; - + // set the dialog id and callback switch (OSrCollection_GetType(inSCM->collection)) { @@ -2706,34 +2706,34 @@ OWiSCM_NewItem( dialog_id = OWcDialog_Sound_Group_Prop; dialog_callback = OWiSGP_Callback; break; - + case OScCollectionType_Impulse: error = SSrImpulse_New(&new_ss_id, NULL); dialog_id = OWcDialog_Impulse_Sound_Prop; dialog_callback = OWiISP_Callback; break; - + case OScCollectionType_Ambient: error = SSrAmbient_New(&new_ss_id, NULL); dialog_id = OWcDialog_Ambient_Sound_Prop; dialog_callback = OWiASP_Callback; break; } - + // get the category_id WMrPopupMenu_GetItemID( WMrDialog_GetItemByID(inDialog, OWcSCM_PM_Category), -1, &category_id); - + // create a new item in the collection error = OSrCollection_Item_New(inSCM->collection, (UUtUns32)category_id, new_ss_id, ""); if (error != UUcError_None) { goto cleanup; } - + // get the item item = OSrCollection_Item_GetByID(inSCM->collection, new_ss_id); if (item == NULL) { goto cleanup; } - + // set the properties of the item error = WMrDialog_ModalBegin( @@ -2743,7 +2743,7 @@ OWiSCM_NewItem( (UUtUns32)item, &message); if (error != UUcError_None) { goto cleanup; } - + // if the user canceled the create, then delete the new items and exit if (message == WMcDialogItem_Cancel) { @@ -2751,19 +2751,19 @@ OWiSCM_NewItem( new_ss_id = SScInvalidID; return UUcError_None; } - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSCM_LB_Items); UUmAssert(listbox); - + // insert the new item's id into the listbox list_index = WMrMessage_Send(listbox, LBcMessage_AddString, new_ss_id, 0); - + // select the item that was just added WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcTrue, list_index); - + return UUcError_None; - + cleanup: if (new_ss_id != SScInvalidID) { @@ -2772,17 +2772,17 @@ OWiSCM_NewItem( case OScCollectionType_Group: SSrGroup_Delete(new_ss_id); break; - + case OScCollectionType_Impulse: SSrImpulse_Delete(new_ss_id); break; - + case OScCollectionType_Ambient: SSrAmbient_Delete(new_ss_id); break; } } - + return error; } @@ -2797,11 +2797,11 @@ OWiSCM_EditItem( WMtDialogID dialog_id; WMtDialogCallback dialog_callback; OStItem *item; - + // get a pointer to the item and it's ss_id item = OSrCollection_Item_GetByID(inSCM->collection, inItemID); if (item == NULL) { return UUcError_Generic; } - + // set the dialog id and callback switch (OSrCollection_GetType(inSCM->collection)) { @@ -2809,18 +2809,18 @@ OWiSCM_EditItem( dialog_id = OWcDialog_Sound_Group_Prop; dialog_callback = OWiSGP_Callback; break; - + case OScCollectionType_Impulse: dialog_id = OWcDialog_Impulse_Sound_Prop; dialog_callback = OWiISP_Callback; break; - + case OScCollectionType_Ambient: dialog_id = OWcDialog_Ambient_Sound_Prop; dialog_callback = OWiASP_Callback; break; } - + // edit the properties of the group error = WMrDialog_ModalBegin( @@ -2830,7 +2830,7 @@ OWiSCM_EditItem( (UUtUns32)item, NULL); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -2843,33 +2843,33 @@ OWiSCM_PlayItem( { OStItem *item; UUtUns32 item_ss_id; - + // get the item from the collection item = OSrCollection_Item_GetByID(inSCM->collection, inItemID); if (item == NULL) { return UUcError_Generic; } item_ss_id = OSrItem_GetID(item); - + switch (OSrCollection_GetType(inSCM->collection)) { case OScCollectionType_Group: SSrGroup_Play(SSrGroup_GetByID(item_ss_id), NULL); break; - + case OScCollectionType_Impulse: { M3tPoint3D position; M3tVector3D direction; M3tVector3D velocity; - + MUmVector_Set(position, 0.0f, 0.0f, 0.0f); MUmVector_Set(direction, 0.0f, 0.0f, 0.0f); MUmVector_Set(velocity, 0.0f, 0.0f, 0.0f); - + SSrImpulse_Play(SSrImpulse_GetByID(item_ss_id), &position, &direction, &velocity); } break; } - + return UUcError_None; } @@ -2881,7 +2881,7 @@ OWiSCM_DeleteItem( UUtUns32 inItemID) { UUtUns32 message; - + // ask the user to confirm the deleteion of the group message = WMrDialog_MessageBox( @@ -2893,41 +2893,41 @@ OWiSCM_DeleteItem( { WMtWindow *listbox; UUtUns32 item_index; - + // delete the item from the category OSrCollection_Item_Delete(inSCM->collection, inItemID); - + switch (OSrCollection_GetType(inSCM->collection)) { case OScCollectionType_Group: break; - + case OScCollectionType_Impulse: OSrVariantList_UpdateImpulseIDs(inItemID); ONrImpactEffects_UpdateImpulseIDs(inItemID); break; - + case OScCollectionType_Ambient: break; } - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSCM_LB_Items); if (listbox == NULL) { return UUcError_Generic; } - + // get the selected item's index item_index = WMrMessage_Send(listbox, LBcMessage_GetSelection, 0, 0); - + // remove the item's name from the list box WMrMessage_Send(listbox, LBcMessage_DeleteString, 0, item_index); - + // select the first item in the listbox WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcTrue, 0); - + // enabled the buttons OWiSCM_Enable_Buttons(inDialog, inSCM); } - + return UUcError_None; } @@ -2941,12 +2941,12 @@ OWiSCM_CopyItem( UUtError error; OStItem *item; UUtUns32 item_ss_id; - + // get the item from the collection item = OSrCollection_Item_GetByID(inSCM->collection, inItemID); if (item == NULL) { return UUcError_Generic; } item_ss_id = OSrItem_GetID(item); - + switch (OSrCollection_GetType(inSCM->collection)) { case OScCollectionType_Group: @@ -2955,50 +2955,50 @@ OWiSCM_CopyItem( error = SSrGroup_New(&inSCM->clip_ss_id, NULL); UUmError_ReturnOnError(error); } - + // copy the data from the item's data to group error = SSrGroup_Copy( SSrGroup_GetByID(item_ss_id), SSrGroup_GetByID(inSCM->clip_ss_id)); break; - + case OScCollectionType_Impulse: if (inSCM->clip_ss_id == SScInvalidID) { error = SSrImpulse_New(&inSCM->clip_ss_id, NULL); UUmError_ReturnOnError(error); } - + // copy the data from the item's data to impulse - error = + error = SSrImpulse_Copy( SSrImpulse_GetByID(item_ss_id), SSrImpulse_GetByID(inSCM->clip_ss_id)); break; - + case OScCollectionType_Ambient: if (inSCM->clip_ss_id == SScInvalidID) { error = SSrAmbient_New(&inSCM->clip_ss_id, NULL); UUmError_ReturnOnError(error); } - + // copy the data from the item's data to impulse - error = + error = SSrAmbient_Copy( SSrAmbient_GetByID(item_ss_id), SSrAmbient_GetByID(inSCM->clip_ss_id)); break; } UUmError_ReturnOnError(error); - + // copy the name UUrString_Copy(inSCM->clip_name, OSrItem_GetName(item), OScMaxNameLength); - + // update the button OWiSCM_Enable_Buttons(inDialog, inSCM); - + return UUcError_None; } @@ -3017,14 +3017,14 @@ OWiSCM_PasteItem( UUtUns32 new_ss_id; UUtUns32 num; char name[OScMaxNameLength]; - + // get a pointer to the popup popup = WMrDialog_GetItemByID(inDialog, OWcSCM_PM_Category); UUmAssert(popup); - + // get the category_id WMrPopupMenu_GetItemID(popup, -1, &category_id); - + // create a new ss_id and copy the clipboard ss_id into ss_id switch (OSrCollection_GetType(inSCM->collection)) { @@ -3036,7 +3036,7 @@ OWiSCM_PasteItem( SSrGroup_GetByID(inSCM->clip_ss_id), SSrGroup_GetByID(new_ss_id)); break; - + case OScCollectionType_Impulse: error = SSrImpulse_New(&new_ss_id, NULL); UUmError_ReturnOnError(error); @@ -3045,7 +3045,7 @@ OWiSCM_PasteItem( SSrImpulse_GetByID(inSCM->clip_ss_id), SSrImpulse_GetByID(new_ss_id)); break; - + case OScCollectionType_Ambient: error = SSrAmbient_New(&new_ss_id, NULL); UUmError_ReturnOnError(error); @@ -3056,9 +3056,9 @@ OWiSCM_PasteItem( break; } UUmError_ReturnOnError(error); - + UUrString_Copy(name, inSCM->clip_name, OScMaxNameLength); - + // paste the item num = 0; do @@ -3073,10 +3073,10 @@ OWiSCM_PasteItem( { UUtUns32 name_length; char num_string[OScMaxNameLength]; - + num++; if (num == 100) { goto cleanup; } - + sprintf(num_string, " %d", num); name_length = strlen(name); @@ -3087,12 +3087,12 @@ OWiSCM_PasteItem( else { char *term; - + term = strrchr(name, ' '); if (term != NULL) { char check_me; - + check_me = term[1]; if (isdigit(check_me)) { @@ -3100,22 +3100,22 @@ OWiSCM_PasteItem( } } } - + UUrString_Cat(name, num_string, OScMaxNameLength); } } while (error != UUcError_None); - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSCM_LB_Items); UUmAssert(listbox); - + // insert the new item's id into the listbox list_index = WMrMessage_Send(listbox, LBcMessage_AddString, new_ss_id, 0); - + // select the item that was just added WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcTrue, list_index); - + return UUcError_None; cleanup: @@ -3126,18 +3126,18 @@ OWiSCM_PasteItem( case OScCollectionType_Group: SSrGroup_Delete(new_ss_id); break; - + case OScCollectionType_Impulse: SSrImpulse_Delete(new_ss_id); break; - + case OScCollectionType_Ambient: SSrAmbient_Delete(new_ss_id); break; } new_ss_id = SScInvalidID; } - + return error; } @@ -3150,10 +3150,10 @@ OWiSCM_NewCategory( UUtError error; UUtUns32 message; char category_name[OScMaxNameLength]; - + // null terminate category name category_name[0] = '\0'; - + // get the name of the new category error = WMrDialog_ModalBegin( @@ -3163,7 +3163,7 @@ OWiSCM_NewCategory( (UUtUns32)category_name, &message); UUmError_ReturnOnError(error); - + if (message == OWcCN_Btn_OK) { UUtUns16 parent_category_id; @@ -3171,13 +3171,13 @@ OWiSCM_NewCategory( WMtWindow *listbox; UUtUns32 listbox_index; - + // get the id of the active category WMrPopupMenu_GetItemID( WMrDialog_GetItemByID(inDialog, OWcSCM_PM_Category), -1, &parent_category_id); - + // create the new category error = OSrCollection_Category_New( @@ -3192,14 +3192,14 @@ OWiSCM_NewCategory( "Error", "The new category could not be created. Make sure the category name is unique and the .bin file is not locked.", WMcMessageBoxStyle_OK); - + return error; } - + // add the category to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSCM_LB_Items); UUmAssert(listbox); - + // add the category to the listbox listbox_index = WMrMessage_Send( @@ -3207,11 +3207,11 @@ OWiSCM_NewCategory( LBcMessage_AddString, (OWcCatToData | category_id), 0); - + // select the new category WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcTrue, listbox_index); } - + return UUcError_None; } @@ -3226,10 +3226,10 @@ OWiSCM_RenameCategory( UUtUns32 message; char category_name[OScMaxNameLength]; OStCategory *category; - + // get a pointer to the category category = OSrCollection_Category_GetByID(inSCM->collection, inCategoryID); - + // get the current category's name UUrString_Copy(category_name, OSrCategory_GetName(category), OScMaxNameLength); @@ -3242,7 +3242,7 @@ OWiSCM_RenameCategory( (UUtUns32)category_name, &message); UUmError_ReturnOnError(error); - + if (message == OWcCN_Btn_OK) { // set the name of the category @@ -3256,7 +3256,7 @@ OWiSCM_RenameCategory( WMcMessageBoxStyle_OK); } } - + return UUcError_None; } @@ -3268,10 +3268,10 @@ OWiSCM_DeleteCategory( UUtUns32 inCategoryID) { UUtUns32 message; - + // ask the user to confirm the deletion of the category and // all the items in it - message = + message = WMrDialog_MessageBox( inDialog, "Confirm Category Deletion", @@ -3281,24 +3281,24 @@ OWiSCM_DeleteCategory( { WMtListBox *listbox; UUtUns32 selected_index; - + // delete the category OSrCollection_Category_Delete(inSCM->collection, inCategoryID); - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSCM_LB_Items); UUmAssert(listbox); - + // get the selected item index selected_index = WMrMessage_Send(listbox, LBcMessage_GetSelection, 0, 0); - + // delete the selected item WMrMessage_Send(listbox, LBcMessage_DeleteString, 0, selected_index); - + // select the first item in the listbox WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcTrue, 0); } - + return UUcError_None; } @@ -3311,10 +3311,10 @@ OWiSCM_InitDialog( OWtSCM *scm; OStCollectionType collection_type; OStCollection *collection; - + // get the collection type collection_type = (OStCollectionType)WMrDialog_GetUserData(inDialog); - + // get a pointer to the collection collection = OSrCollection_GetByType(collection_type); if (collection == NULL) @@ -3322,7 +3322,7 @@ OWiSCM_InitDialog( WMrDialog_ModalEnd(inDialog, 0); return; } - + // allocate memory for the scm scm = (OWtSCM*)UUrMemory_Block_New(sizeof(OWtSCM)); if (scm == NULL) @@ -3330,30 +3330,30 @@ OWiSCM_InitDialog( WMrDialog_ModalEnd(inDialog, 0); return; } - + // set up the scm scm->collection = collection; scm->clip_ss_id = SScInvalidID; scm->clip_name[0] = '\0'; - + switch (collection_type) { case OScCollectionType_Group: UUrString_Copy(scm->collection_name, "Group", OScMaxNameLength); break; - + case OScCollectionType_Impulse: UUrString_Copy(scm->collection_name, "Impulse", OScMaxNameLength); break; - + case OScCollectionType_Ambient: UUrString_Copy(scm->collection_name, "Ambient", OScMaxNameLength); break; } - + // save the scm WMrDialog_SetUserData(inDialog, (UUtUns32)scm); - + // initialize the popup menu error = OWiSCM_Popup_Init(inDialog, scm); if (error != UUcError_None) @@ -3362,7 +3362,7 @@ OWiSCM_InitDialog( WMrDialog_ModalEnd(inDialog, 0); return; } - + // Enable Buttons OWiSCM_Enable_Buttons(inDialog, scm); } @@ -3376,7 +3376,7 @@ OWiSCM_Destroy( // get a pointer to the scm scm = (OWtSCM*)WMrDialog_GetUserData(inDialog); - + // delete the data associated with the OWtSCM switch (OSrCollection_GetType(scm->collection)) { @@ -3387,13 +3387,13 @@ OWiSCM_Destroy( case OScCollectionType_Impulse: SSrImpulse_Delete(scm->clip_ss_id); break; - + case OScCollectionType_Ambient: SSrAmbient_Delete(scm->clip_ss_id); break; } scm->clip_ss_id = SScInvalidID; - + // delete the scm UUrMemory_Block_Delete(scm); WMrDialog_SetUserData(inDialog, 0); @@ -3420,15 +3420,15 @@ OWiSCM_HandleCommand( // interpret inParam1 command_type = UUmHighWord(inParam1); control_id = UUmLowWord(inParam1); - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSCM_LB_Items); UUmAssert(listbox); - + // get the selected item's item_id result = WMrMessage_Send(listbox, LBcMessage_GetText, (UUtUns32)&item_id, (UUtUns32)-1); if (result == LBcError) { item_id = UUcMaxUns32; } - + if (control_id == OWcSCM_LB_Items) { switch (command_type) @@ -3436,7 +3436,7 @@ OWiSCM_HandleCommand( case LBcNotify_SelectionChanged: OWiSCM_Enable_Buttons(inDialog, scm); break; - + case WMcNotify_DoubleClick: if (item_id & OWcCatToData) { @@ -3460,35 +3460,35 @@ OWiSCM_HandleCommand( case OWcSCM_Btn_NewItem: OWiSCM_NewItem(inDialog, scm); break; - + case OWcSCM_Btn_EditItem: OWiSCM_EditItem(inDialog, scm, item_id); break; - + case OWcSCM_Btn_PlayItem: OWiSCM_PlayItem(inDialog, scm, item_id); break; - + case OWcSCM_Btn_DeleteItem: OWiSCM_DeleteItem(inDialog, scm, item_id); break; - + case OWcSCM_Btn_CopyItem: OWiSCM_CopyItem(inDialog, scm, item_id); break; - + case OWcSCM_Btn_PasteItem: OWiSCM_PasteItem(inDialog, scm, item_id); break; - + case OWcSCM_Btn_NewCategory: OWiSCM_NewCategory(inDialog, scm); break; - + case OWcSCM_Btn_RenameCategory: OWiSCM_RenameCategory(inDialog, scm, (item_id & OWcDataToCat)); break; - + case OWcSCM_Btn_DeleteCategory: OWiSCM_DeleteCategory(inDialog, scm, (item_id & OWcDataToCat)); break; @@ -3508,7 +3508,7 @@ OWiSCM_HandleMenuCommand( UUtUns32 num_items; UUtBool result; UUtUns16 item_id; - + // go through the popup menu items and delete the ones after inItemID num_items = 0; for (i = 0;; i++) @@ -3517,21 +3517,21 @@ OWiSCM_HandleMenuCommand( if (result == UUcFalse) { break; } num_items++; } - + for (i = (num_items - 1); ; i--) { // get the item id result = WMrPopupMenu_GetItemID(inPopupMenu, (UUtInt16)i, &item_id); if (result == UUcFalse) { break; } if (item_id == inItemID) { break; } - + WMrPopupMenu_RemoveItem(inPopupMenu, item_id); } - + // get a pointer to the scm scm = (OWtSCM*)WMrDialog_GetUserData(inDialog); UUmAssert(scm); - + // fill the listbox OWiSCM_Listbox_Fill(inDialog, scm); } @@ -3547,23 +3547,23 @@ OWiSCM_HandleDrawItem( PStPartSpecUI *partspec_ui; UUtInt16 line_width; UUtInt16 line_height; - + // get a pointer to the scm scm = (OWtSCM*)WMrDialog_GetUserData(inDialog); UUmAssert(scm); - + // get a pointer to the partspec_ui partspec_ui = PSrPartSpecUI_GetActive(); UUmAssert(partspec_ui); - + // set the dest dest.x = inDrawItem->rect.left; dest.y = inDrawItem->rect.top; - + // calc the width and height of the line line_width = inDrawItem->rect.right - inDrawItem->rect.left; line_height = inDrawItem->rect.bottom - inDrawItem->rect.top; - + /* if (inDrawItem->state & WMcDrawItemState_Selected) { // draw the hilite @@ -3576,11 +3576,11 @@ OWiSCM_HandleDrawItem( line_height, M3cMaxAlpha); }*/ - + // set the text destination dest.x += 2; dest.y += 1; - + // draw the text DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrText_SetStyle(TScStyle_Plain); @@ -3588,13 +3588,13 @@ OWiSCM_HandleDrawItem( if (inDrawItem->data & OWcCatToData) { OStCategory *category; - - category = + + category = OSrCollection_Category_GetByID( scm->collection, (inDrawItem->data & OWcDataToCat)); if (category == NULL) { return; } - + // draw the folder DCrDraw_PartSpec( inDrawItem->draw_context, @@ -3604,7 +3604,7 @@ OWiSCM_HandleDrawItem( (line_height - 3), (line_height - 3), M3cMaxAlpha); - + // draw the name dest.x += line_height + 2; DCrDraw_String( @@ -3616,7 +3616,7 @@ OWiSCM_HandleDrawItem( else { OStItem *item; - + item = OSrCollection_Item_GetByID(scm->collection, inDrawItem->data); if (item == NULL) { return; } @@ -3629,7 +3629,7 @@ OWiSCM_HandleDrawItem( (line_height - 3), (line_height - 3), M3cMaxAlpha); - + // draw the name dest.x += line_height + 2; DCrDraw_String( @@ -3648,13 +3648,13 @@ OWiSCM_HandleCompareItems( { OWtSCM *scm; UUtInt32 result; - + // get a pointer to the scm scm = (OWtSCM*)WMrDialog_GetUserData(inDialog); UUmAssert(scm); - + // is one of the items a directory? - if ((inCompareItems->item1_data & OWcCatToData) != + if ((inCompareItems->item1_data & OWcCatToData) != (inCompareItems->item2_data & OWcCatToData)) { if (inCompareItems->item1_data & OWcCatToData) @@ -3674,20 +3674,20 @@ OWiSCM_HandleCompareItems( { OStCategory *category1; OStCategory *category2; - + // compare the categories category1 = OSrCollection_Category_GetByID( scm->collection, (inCompareItems->item1_data & OWcDataToCat)); UUmAssert(category1); - + category2 = OSrCollection_Category_GetByID( scm->collection, (inCompareItems->item2_data & OWcDataToCat)); UUmAssert(category2); - + result = UUrString_Compare_NoCase( OSrCategory_GetName(category1), @@ -3697,17 +3697,17 @@ OWiSCM_HandleCompareItems( { OStItem *item1; OStItem *item2; - + // compare the items item1 = OSrCollection_Item_GetByID(scm->collection, inCompareItems->item1_data); UUmAssert(item1); - + item2 = OSrCollection_Item_GetByID(scm->collection, inCompareItems->item2_data); UUmAssert(item2); - + result = UUrString_Compare_NoCase(OSrItem_GetName(item1), OSrItem_GetName(item2)); } - + return (UUtBool)result; } @@ -3720,43 +3720,43 @@ OWiSCM_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiSCM_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiSCM_Destroy(inDialog); break; - + case WMcMessage_Command: OWiSCM_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_MenuCommand: OWiSCM_HandleMenuCommand( inDialog, (WMtWindow*)inParam2, (UUtUns32)UUmLowWord(inParam1)); break; - + case WMcMessage_DrawItem: OWiSCM_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + case WMcMessage_CompareItems: handled = OWiSCM_HandleCompareItems(inDialog, (WMtCompareItems*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -3767,11 +3767,11 @@ OWrSCM_Display( { UUtError error; WMtDialogID dialog_id; - + if (OSrCollection_IsLocked(OSrCollection_GetByType(inCollectionType)) == UUcTrue) { UUtUns32 result; - result = + result = WMrDialog_MessageBox( NULL, "Unable to Save", @@ -3785,16 +3785,16 @@ OWrSCM_Display( case OScCollectionType_Group: dialog_id = OWcDialog_Sound_Group_Manager; break; - + case OScCollectionType_Impulse: dialog_id = OWcDialog_Impulse_Sound_Manager; break; - + case OScCollectionType_Ambient: dialog_id = OWcDialog_Ambient_Sound_Manager; break; } - + // display the Sound Group Manager Dialog error = WMrDialog_ModalBegin( @@ -3803,10 +3803,10 @@ OWrSCM_Display( OWiSCM_Callback, (UUtUns32)inCollectionType, NULL); - + // save OSrSave(); - + return UUcError_None; } @@ -3823,10 +3823,10 @@ OWiSS_Enable_Buttons( WMtWindow *button; WMtWindow *listbox; UUtUns32 item_id; - + button = WMrDialog_GetItemByID(inDialog, OWcSS_Btn_Select); WMrWindow_SetEnabled(button, UUcFalse); - + listbox = WMrDialog_GetItemByID(inDialog, OWcSS_LB_Items); item_id = WMrMessage_Send(listbox, LBcMessage_GetItemData, 0, (UUtUns32)-1); if ((item_id != SScInvalidID) && ((item_id & OWcCatToData) == 0)) @@ -3843,19 +3843,19 @@ OWiSS_InitDialog( UUtError error; OWtSCM *scm; OWtSS *ss; - + // get the user data ss = (OWtSS*)WMrDialog_GetUserData(inDialog); - + // get a pointer to the scm scm = (OWtSCM*)UUrMemory_Block_New(sizeof(OWtSCM)); if (scm == NULL) { goto cleanup; } - + // initialize the scm scm->collection = OSrCollection_GetByType(ss->type); scm->clip_ss_id = (UUtUns32)ss; scm->clip_name[0] = '\0'; - + switch (ss->type) { case OScCollectionType_Group: @@ -3870,10 +3870,10 @@ OWiSS_InitDialog( UUrString_Copy(scm->collection_name, "Impulse", OScMaxNameLength); break; } - + // save the scm WMrDialog_SetUserData(inDialog, (UUtUns32)scm); - + // initialize the popup menu error = OWiSCM_Popup_Init(inDialog, scm); if (error != UUcError_None) @@ -3881,17 +3881,17 @@ OWiSS_InitDialog( WMrDialog_ModalEnd(inDialog, OWcSS_Btn_Cancel); return; } - + // Enable Buttons OWiSS_Enable_Buttons(inDialog); - + return; - + cleanup: if (scm != NULL) { ss->item_id = SScInvalidID; - + UUrMemory_Block_Delete(scm); WMrDialog_ModalEnd(inDialog, OWcSS_Btn_Cancel); } @@ -3903,13 +3903,13 @@ OWiSS_Destroy( WMtDialog *inDialog) { OWtSCM *scm; - + // get a pointer to the scm scm = (OWtSCM*)WMrDialog_GetUserData(inDialog); - + // restore the out_ss_id WMrDialog_SetUserData(inDialog, scm->clip_ss_id); - + // dispose of the scm UUrMemory_Block_Delete(scm); } @@ -3928,26 +3928,26 @@ OWiSS_HandleCommand( UUtUns32 result; UUtUns32 item_id; OWtSS *ss; - + // get a pointer to the scm scm = (OWtSCM*)WMrDialog_GetUserData(inDialog); UUmAssert(scm); - + // interpret inParam1 control_id = UUmLowWord(inParam1); command_type = UUmHighWord(inParam1); - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSCM_LB_Items); UUmAssert(listbox); - + // get the selected item's item_id result = WMrMessage_Send(listbox, LBcMessage_GetText, (UUtUns32)&item_id, (UUtUns32)-1); if (result == LBcError) { item_id = UUcMaxUns32; } - + // get ss ss = (OWtSS*)scm->clip_ss_id; - + // handle the command if (control_id == OWcSCM_LB_Items) { @@ -3956,7 +3956,7 @@ OWiSS_HandleCommand( case LBcNotify_SelectionChanged: OWiSS_Enable_Buttons(inDialog); break; - + case WMcNotify_DoubleClick: if (item_id & OWcCatToData) { @@ -3977,7 +3977,7 @@ OWiSS_HandleCommand( case OWcSS_Btn_None: WMrDialog_ModalEnd(inDialog, OWcSS_Btn_None); break; - + case OWcSS_Btn_New: OWrSCM_Display(ss->type); OWiSCM_Listbox_Fill(inDialog, scm); @@ -3986,7 +3986,7 @@ OWiSS_HandleCommand( case OWcSS_Btn_Cancel: WMrDialog_ModalEnd(inDialog, OWcSS_Btn_Cancel); break; - + case OWcSS_Btn_Select: ss->item_id = item_id; WMrDialog_ModalEnd(inDialog, OWcSS_Btn_Select); @@ -4004,23 +4004,23 @@ OWiSS_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiSS_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiSS_Destroy(inDialog); break; - + case WMcMessage_Command: OWiSS_HandleCommand(inDialog, inParam1, (WMtWindow*)inParam2); break; - + case WMcMessage_MenuCommand: OWiSCM_HandleMenuCommand( inDialog, @@ -4031,16 +4031,16 @@ OWiSS_Callback( case WMcMessage_DrawItem: OWiSCM_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + case WMcMessage_CompareItems: handled = OWiSCM_HandleCompareItems(inDialog, (WMtCompareItems*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -4054,9 +4054,9 @@ OWiSSG_Display( UUtError error; UUtUns32 message; OWtSS ss; - + UUmAssert(ioSoundGroupID || ioSoundGroup); - + ss.type = OScCollectionType_Group; // select a group @@ -4068,7 +4068,7 @@ OWiSSG_Display( (UUtUns32)&ss, &message); UUmError_ReturnOnError(error); - + if (message == OWcSS_Btn_Select) { if (ioSoundGroupID) { *ioSoundGroupID = ss.item_id; } @@ -4079,7 +4079,7 @@ OWiSSG_Display( if (ioSoundGroupID) { *ioSoundGroupID = SScInvalidID; } if (ioSoundGroup) { *ioSoundGroup = NULL; } } - + return UUcError_None; } @@ -4093,11 +4093,11 @@ OWrSAS_Display( UUtError error; UUtUns32 message; OWtSS ss; - + UUmAssert(ioAmbientSoundID || ioAmbientSound); - + ss.type = OScCollectionType_Ambient; - + // select a group error = WMrDialog_ModalBegin( @@ -4107,7 +4107,7 @@ OWrSAS_Display( (UUtUns32)&ss, &message); UUmError_ReturnOnError(error); - + if (message == OWcSS_Btn_Select) { if (ioAmbientSoundID) { *ioAmbientSoundID = ss.item_id; } @@ -4118,7 +4118,7 @@ OWrSAS_Display( if (ioAmbientSoundID) { *ioAmbientSoundID = SScInvalidID; } if (ioAmbientSound) { *ioAmbientSound = NULL; } } - + return UUcError_None; } @@ -4132,11 +4132,11 @@ OWrSIS_Display( UUtError error; UUtUns32 message; OWtSS ss; - + UUmAssert(ioImpulseSoundID || ioImpulseSound); - + ss.type = OScCollectionType_Impulse; - + // select a group error = WMrDialog_ModalBegin( @@ -4146,7 +4146,7 @@ OWrSIS_Display( (UUtUns32)&ss, &message); UUmError_ReturnOnError(error); - + if (message == OWcSS_Btn_Select) { if (ioImpulseSoundID) { *ioImpulseSoundID = ss.item_id; } @@ -4157,7 +4157,7 @@ OWrSIS_Display( if (ioImpulseSoundID) { *ioImpulseSoundID = SScInvalidID; } if (ioImpulseSound) { *ioImpulseSound = NULL; } } - + return UUcError_None; } @@ -4177,22 +4177,22 @@ OWiSelectAnimation_InitDialog( WMtWindow *listbox; WMtWindow *progressbar; UUtUns32 i; - + // get a pointer to the user data sa = (OWtSA*)WMrDialog_GetUserData(inDialog); sa->insert_from_index = 0; - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSA_LB_Animations); // WMrWindow_SetVisible(listbox, UUcFalse); - + // get the number of animations sa->num_animations = TMrInstance_GetTagCount(TRcTemplate_Animation); if (sa->num_animations == 0) { return UUcError_Generic; } - + sa->animation_list = (TRtAnimation**)UUrMemory_Block_New(sizeof(TRtAnimation*) * sa->num_animations); if (sa->animation_list == NULL) { return UUcError_Generic; } - + // build the list of pointers to the animations error = TMrInstance_GetDataPtr_List( @@ -4202,29 +4202,29 @@ OWiSelectAnimation_InitDialog( sa->animation_list); UUmError_ReturnOnError(error); UUmAssert(sa->num_animations == num_anims); - + // set the number of lines the listbox is going to have WMrMessage_Send(listbox, LBcMessage_SetNumLines, sa->num_animations, 0); - + // create a timer // WMrTimer_Start(0, 1, inDialog); - + // add lines to the dialog for (i = 0; i < sa->num_animations; i++) { WMrMessage_Send(listbox, LBcMessage_AddString, 0, 0); } - + WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcFalse, 0); // init the progressbar progressbar = WMrDialog_GetItemByID(inDialog, OWcSA_PB_LoadProgress); // WMrMessage_Send(progressbar, WMcMessage_SetValue, 0, 0); WMrWindow_SetVisible(progressbar, UUcFalse); - + // set the focus to the listbox WMrWindow_SetFocus(listbox); - + return UUcError_None; } /* @@ -4237,22 +4237,22 @@ OWiSelectAnimation_InitDialog( UUtError error; WMtWindow *listbox; WMtWindow *progressbar; - + // get a pointer to the user data sa = (OWtSA*)WMrDialog_GetUserData(inDialog); sa->insert_from_index = 0; - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSA_LB_Animations); WMrWindow_SetVisible(listbox, UUcFalse); - + // get the number of animations sa->num_animations = TMrInstance_GetTagCount(TRcTemplate_Animation); if (sa->num_animations == 0) { return NULL; } - + sa->animation_list = (TRtAnimation**)UUrMemory_Block_New(sizeof(TRtAnimation*) * sa->num_animations); if (sa->animation_list == NULL) { return NULL; } - + // build the list of pointers to the animations error = TMrInstance_GetDataPtr_List( @@ -4262,20 +4262,20 @@ OWiSelectAnimation_InitDialog( sa->animation_list); UUmError_ReturnOnError(error); UUmAssert(sa->num_animations == num_anims); - + // set the number of lines the listbox is going to have WMrMessage_Send(listbox, LBcMessage_SetNumLines, sa->num_animations, 0); // create a timer WMrTimer_Start(0, 1, inDialog); - + // init the progressbar progressbar = WMrDialog_GetItemByID(inDialog, OWcSA_PB_LoadProgress); WMrMessage_Send(progressbar, WMcMessage_SetValue, 0, 0); - + // set the focus to the listbox WMrWindow_SetFocus(listbox); - + return UUcError_None; } */ @@ -4285,9 +4285,9 @@ OWiSelectAnimation_HandleDestroy( WMtDialog *inDialog) { OWtSA *sa; - + sa = (OWtSA*)WMrDialog_GetUserData(inDialog); - + if (sa->animation_list != NULL) { UUrMemory_Block_Delete(sa->animation_list); @@ -4303,9 +4303,9 @@ OWiSelectAnimation_HandleSelect( { WMtWindow *listbox; UUtUns32 result; - + listbox = WMrDialog_GetItemByID(inDialog, OWcSA_LB_Animations); - + result = WMrMessage_Send(listbox, LBcMessage_GetSelection, 0, 0); if (result != LBcError) { @@ -4322,9 +4322,9 @@ OWiSelectAnimation_HandleCommand( UUtUns32 inParam2) { OWtSA *sa; - + sa = (OWtSA*)WMrDialog_GetUserData(inDialog); - + switch(UUmLowWord(inParam1)) { case OWcSA_LB_Animations: @@ -4333,16 +4333,16 @@ OWiSelectAnimation_HandleCommand( OWiSelectAnimation_HandleSelect(inDialog, sa); } break; - + case OWcSA_Btn_None: sa->animation = NULL; WMrDialog_ModalEnd(inDialog, OWcSA_Btn_None); break; - + case OWcSA_Btn_Cancel: WMrDialog_ModalEnd(inDialog, OWcSA_Btn_Cancel); break; - + case OWcSA_Btn_Select: OWiSelectAnimation_HandleSelect(inDialog, sa); break; @@ -4360,35 +4360,35 @@ OWiSelectAnimation_HandleTimer( WMtWindow *listbox; WMtWindow *progressbar; UUtUns32 progress; - + sa = (OWtSA*)WMrDialog_GetUserData(inDialog); if (sa->insert_from_index == sa->num_animations) { return; } - + // calculate the stop_index stop_index = (sa->num_animations / 50) + sa->insert_from_index; if (stop_index > sa->num_animations) { stop_index = sa->num_animations; } - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSA_LB_Animations); - + // put the animations in the list for (i = sa->insert_from_index; i < stop_index; i++) { WMrMessage_Send( listbox, - LBcMessage_AddString, + LBcMessage_AddString, (UUtUns32)TMrInstance_GetInstanceName(sa->animation_list[i]), 0); } - + // update the inser_from_index sa->insert_from_index = stop_index; - + // update the progress bar progressbar = WMrDialog_GetItemByID(inDialog, OWcSA_PB_LoadProgress); progress = (UUtUns32)(((float)sa->insert_from_index / (float)sa->num_animations) * 100.0f); WMrMessage_Send(progressbar, WMcMessage_SetValue, progress, 0); - + // if there are no more animations to add, select the current animation or the first // and stop the timer if (stop_index == sa->num_animations) @@ -4405,16 +4405,16 @@ OWiSelectAnimation_HandleTimer( { WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcFalse, 0); } - + // stop the timer WMrTimer_Stop(0, inDialog); - + // hide the progressbar WMrWindow_SetVisible(progressbar, UUcFalse); - + // show the listbox WMrWindow_SetVisible(listbox, UUcTrue); - + // dipose of the animation_list UUrMemory_Block_Delete(sa->animation_list); sa->animation_list = NULL; @@ -4439,15 +4439,15 @@ OWiSelectAnimation_HandleDrawItem( // get a pointer to the partspec_ui // partspec_ui = PSrPartSpecUI_GetActive(); // UUmAssert(partspec_ui); - + // set the dest dest.x = inDrawItem->rect.left; dest.y = inDrawItem->rect.top; - + // calc the width and height of the line line_width = inDrawItem->rect.right - inDrawItem->rect.left; line_height = inDrawItem->rect.bottom - inDrawItem->rect.top; - + /* if (inDrawItem->state & WMcDrawItemState_Selected) { // draw the hilite @@ -4465,12 +4465,12 @@ OWiSelectAnimation_HandleDrawItem( DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrText_SetStyle(TScStyle_Plain); DCrText_SetShade(IMcShade_Black); - + dest.x = 5; dest.y += 1; - + animation = sa->animation_list[inDrawItem->item_id]; - + DCrDraw_String( inDrawItem->draw_context, TMrInstance_GetInstanceName(animation), @@ -4488,9 +4488,9 @@ OWiSelectAnimation_Callback( { UUtBool handled; UUtError error; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -4500,28 +4500,28 @@ OWiSelectAnimation_Callback( WMrDialog_ModalEnd(inDialog, OWcSA_Btn_Cancel); } break; - + case WMcMessage_Destroy: OWiSelectAnimation_HandleDestroy(inDialog); break; - + case WMcMessage_Command: OWiSelectAnimation_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_Timer: OWiSelectAnimation_HandleTimer(inDialog); break; - + case WMcMessage_DrawItem: OWiSelectAnimation_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -4540,16 +4540,16 @@ OWiStAP_EnableButtons( WMtWindow *popup; WMtWindow *editfield; WMtWindow *text; - + button = WMrDialog_GetItemByID(inDialog, OWcStAP_Btn_SetAnim); WMrWindow_SetEnabled(button, (inProperties->anim_type == OScAnimType_Animation)); - + popup = WMrDialog_GetItemByID(inDialog, OWcStAP_PM_Modifier); WMrWindow_SetEnabled(popup, (inProperties->anim_type != OScAnimType_Animation)); - + editfield = WMrDialog_GetItemByID(inDialog, OWcStAP_EF_Frame); WMrWindow_SetEnabled(editfield, (inProperties->anim_type == OScAnimType_Animation)); - + text = WMrDialog_GetItemByID(inDialog, OWcStAP_Txt_Duration); WMrWindow_SetVisible(text, (inProperties->anim_type == OScAnimType_Animation)); } @@ -4566,14 +4566,14 @@ OWiStAP_InitDialog( UUtError error; OStAnimType type; ONtVariantList *variant_list; - + properties = (OWtStAP*)WMrDialog_GetUserData(inDialog); if (properties == NULL) { WMrDialog_ModalEnd(inDialog, OWcStAP_Btn_Cancel); return; } - + // build the variant popup menu popup = WMrDialog_GetItemByID(inDialog, OWcStAP_PM_Variant); error = @@ -4586,13 +4586,13 @@ OWiStAP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcStAP_Btn_Cancel); return; } - + // add the variants to the popup for (i = 0; i < variant_list->numVariants; i++) { WMrPopupMenu_AppendItem_Light(popup, (UUtUns16)i, variant_list->variant[i]->name); } - + // set the variant if (properties->variant_name[0] == '\0') { @@ -4606,24 +4606,24 @@ OWiStAP_InitDialog( WMrPopupMenu_SetSelection(popup, 0); } } - + // build the anim type popup menu popup = WMrDialog_GetItemByID(inDialog, OWcStAP_PM_AnimType); for (type = 0; type < OScAnimType_NumTypes; type++) { const char *anim_name; - + anim_name = OSrAnimType_GetName(type); WMrPopupMenu_AppendItem_Light(popup, (UUtUns16)type, anim_name); } - + // set the anim type error = WMrPopupMenu_SetSelection(popup, (UUtUns16)properties->anim_type); if (error != UUcError_None) { WMrPopupMenu_SetSelection(popup, 0); } - + // set the mod type popup = WMrDialog_GetItemByID(inDialog, OWcStAP_PM_Modifier); error = WMrPopupMenu_SetSelection(popup, (UUtUns16)properties->mod_type); @@ -4631,17 +4631,17 @@ OWiStAP_InitDialog( { WMrPopupMenu_SetSelection(popup, 0); } - + // set the frame number editfield = WMrDialog_GetItemByID(inDialog, OWcStAP_EF_Frame); WMrEditField_SetInt32(editfield, (UUtInt32)properties->frame); - + // set the anim name edit field if (properties->anim_type == OScAnimType_Animation) { TRtAnimTime duration; char string[128]; - + // set the animation name WMrWindow_SetTitle( WMrDialog_GetItemByID(inDialog, OWcStAP_Txt_AnimName), @@ -4670,12 +4670,12 @@ OWiStAP_InitDialog( "0", OScMaxAnimNameLength); } - + // set the impulse edit field if ((properties->impulse_id != SScInvalidID) &&(SSrImpulse_GetByID(properties->impulse_id) != NULL)) { OStItem *item; - + item = OSrCollection_Item_GetByID( OSrCollection_GetByType(OScCollectionType_Impulse), @@ -4693,7 +4693,7 @@ OWiStAP_InitDialog( "", OScMaxNameLength); } - + // update the controls OWiStAP_EnableButtons(inDialog, properties); } @@ -4707,18 +4707,18 @@ OWiStAP_HandleCommand( { OWtStAP *properties; UUtError error; - + properties = (OWtStAP*)WMrDialog_GetUserData(inDialog); - + switch (UUmLowWord(inParam1)) { case OWcStAP_Btn_SetAnim: { OWtSA sa; UUtUns32 message; - + sa.animation = properties->animation; - + // select an animation error = WMrDialog_ModalBegin( @@ -4728,7 +4728,7 @@ OWiStAP_HandleCommand( (UUtUns32)&sa, &message); if (error != UUcError_None) { break; } - + if (message == OWcSA_Btn_None) { properties->animation = NULL; @@ -4737,12 +4737,12 @@ OWiStAP_HandleCommand( { properties->animation = sa.animation; } - + if (properties->animation) { TRtAnimTime duration; char string[128]; - + // set the animation name WMrWindow_SetTitle( WMrDialog_GetItemByID(inDialog, OWcStAP_Txt_AnimName), @@ -4773,14 +4773,14 @@ OWiStAP_HandleCommand( } } break; - + case OWcStAP_Btn_SetSound: { OStItem *item; - + error = OWrSIS_Display(inDialog, &properties->impulse_id, NULL); if (error != UUcError_None) { break; } - + if (properties->impulse_id != SScInvalidID) { item = @@ -4804,22 +4804,22 @@ OWiStAP_HandleCommand( } } break; - + case OWcStAP_EF_Frame: { WMtWindow *editfield; - + if (UUmHighWord(inParam1) != EFcNotify_ContentChanged) { break; } - + editfield = WMrDialog_GetItemByID(inDialog, OWcStAP_EF_Frame); properties->frame = (UUtUns32)WMrEditField_GetInt32(editfield); } break; - + case OWcStAP_Btn_Cancel: WMrDialog_ModalEnd(inDialog, OWcStAP_Btn_Cancel); break; - + case OWcStAP_Btn_Save: if ((properties->animation != NULL) && (properties->frame > TRrAnimation_GetDuration(properties->animation))) @@ -4832,7 +4832,7 @@ OWiStAP_HandleCommand( WMrWindow_SetFocus(WMrDialog_GetItemByID(inDialog, OWcStAP_EF_Frame)); break; } - + WMrDialog_ModalEnd(inDialog, OWcStAP_Btn_Save); break; } @@ -4847,10 +4847,10 @@ OWiStAP_HandleMenuCommand( { OWtStAP *properties; UUtUns32 item_id; - + properties = (OWtStAP*)WMrDialog_GetUserData(inDialog); item_id = (UUtUns32)(UUmLowWord(inItemID)); - + switch (WMrWindow_GetID(inPopupMenu)) { case OWcStAP_PM_Variant: @@ -4864,7 +4864,7 @@ OWiStAP_HandleMenuCommand( else { ONtVariantList *variant_list; - + TMrInstance_GetDataPtr( ONcTemplate_VariantList, "variant_list", @@ -4881,12 +4881,12 @@ OWiStAP_HandleMenuCommand( case OWcStAP_PM_AnimType: properties->anim_type = item_id; break; - + case OWcStAP_PM_Modifier: properties->mod_type = item_id; break; } - + // update the controls OWiStAP_EnableButtons(inDialog, properties); } @@ -4900,28 +4900,28 @@ OWiStAP_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiStAP_InitDialog(inDialog); break; - + case WMcMessage_Command: OWiStAP_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_MenuCommand: OWiStAP_HandleMenuCommand(inDialog, (WMtWindow*)inParam2, inParam1); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -4937,7 +4937,7 @@ OWiStA_FillListBox( { UUtUns32 i; UUtUns32 num_variants; - + WMrMessage_Send(inListBox, LBcMessage_Reset, 0, 0); num_variants = OSrVariantList_GetNumVariants(); @@ -4946,13 +4946,13 @@ OWiStA_FillListBox( OStVariant *variant; UUtUns32 num_sounds; UUtUns32 j; - + variant = OSrVariantList_Variant_GetByIndex(i); num_sounds = OSrVariant_GetNumSounds(variant); for (j = 0; j < num_sounds; j++) { UUtUns32 item_data; - + item_data = UUmMakeLong(i, j); WMrMessage_Send(inListBox, LBcMessage_AddString, (UUtUns32)item_data, 0); } @@ -4969,22 +4969,22 @@ OWiStA_HandleDelete( OStVariant *variant; UUtBool is_animation; UUtUns32 variant_index; - + listbox = WMrDialog_GetItemByID(inDialog, OWcStA_LB_Data); item_data = WMrMessage_Send(listbox, LBcMessage_GetItemData, 0, (UUtUns32)-1); - + is_animation = (item_data & 0x80000000) != 0; variant_index = UUmHighWord(item_data) & 0x7FFF; - + variant = OSrVariantList_Variant_GetByIndex(variant_index); if (variant == NULL) { return; } - + // delete the sound animation from the variant OSrVariant_SoundAnimation_DeleteByIndex(variant, UUmLowWord(item_data)); - + // save the data OSrVariantList_Save(UUcFalse); - + // fill the listbox OWiStA_FillListBox(listbox); } @@ -5004,28 +5004,28 @@ OWiStA_HandlePlay( SStImpulse *impulse; UUtBool is_animation; UUtUns32 variant_index; - + listbox = WMrDialog_GetItemByID(inDialog, OWcStA_LB_Data); item_data = WMrMessage_Send(listbox, LBcMessage_GetItemData, 0, (UUtUns32)-1); - + is_animation = (item_data & 0x80000000) != 0; variant_index = UUmHighWord(item_data) & 0x7FFF; - + variant = OSrVariantList_Variant_GetByIndex(variant_index); if (variant == NULL) { return; } - + sound_animation = OSrVariant_SoundAnimation_GetByIndex(variant, UUmLowWord(item_data)); if (sound_animation == NULL) { return; } - + // get the impulse sound impulse = SSrImpulse_GetByID(sound_animation->impulse_id); if (impulse == NULL) { return; } - + // set the listener position MUmVector_Set(position, 0.0f, 0.0f, 0.0f); MUmVector_Set(facing, 1.0f, 0.0f, 1.0f); SSrListener_SetPosition(&position, &facing); - + // play the sound MUmVector_Set(position, 5.0f, 0.0f, 5.0f); MUmVector_Set(velocity, 0.0f, 0.0f, 0.0f); @@ -5046,19 +5046,19 @@ OWiStA_HandleEdit( UUtUns32 message; UUtBool is_animation; UUtUns32 variant_index; - + listbox = WMrDialog_GetItemByID(inDialog, OWcStA_LB_Data); item_data = WMrMessage_Send(listbox, LBcMessage_GetItemData, 0, (UUtUns32)-1); - + is_animation = (item_data & 0x80000000) != 0; variant_index = UUmHighWord(item_data) & 0x7FFF; - + variant = OSrVariantList_Variant_GetByIndex(variant_index); if (variant == NULL) { return UUcError_Generic; } - + sound_animation = OSrVariant_SoundAnimation_GetByIndex(variant, UUmLowWord(item_data)); if (sound_animation == NULL) { return UUcError_Generic; } - + // initialize the properties properties.anim_type = sound_animation->anim_type; properties.mod_type = sound_animation->mod_type; @@ -5069,9 +5069,9 @@ OWiStA_HandleEdit( properties.variant_name, OSrVariant_GetName(variant), ONcMaxVariantNameLength); - + // edit the properties - error = + error = WMrDialog_ModalBegin( OWcDialog_Sound_to_Anim_Prop, inDialog, @@ -5079,18 +5079,18 @@ OWiStA_HandleEdit( (UUtUns32)&properties, &message); UUmError_ReturnOnError(error); - + if (message == OWcStAP_Btn_Save) { OStVariant *new_variant; - + // delete the old sound variant OSrVariant_SoundAnimation_DeleteByIndex(variant, UUmLowWord(item_data)); - + // if the variant changed, then delete the sound animation from the old variant new_variant = OSrVariantList_Variant_GetByName(properties.variant_name); if (new_variant == NULL) { return UUcError_Generic; } - + // add the sound animation to the new variant error = OSrVariant_SoundAnimation_Add( @@ -5101,14 +5101,14 @@ OWiStA_HandleEdit( properties.frame, properties.impulse_id); UUmError_ReturnOnError(error); - + // save the data OSrVariantList_Save(UUcFalse); - + // fill in the listbox OWiStA_FillListBox(WMrDialog_GetItemByID(inDialog, OWcStA_LB_Data)); } - + return UUcError_None; } @@ -5120,15 +5120,15 @@ OWiStA_HandleNew( UUtError error; UUtUns32 message; OWtStAP properties; - + UUrMemory_Clear(&properties, sizeof(OWtStAP)); properties.anim_type = OScAnimType_Any; properties.impulse_id = SScInvalidID; properties.animation = NULL; properties.frame = 0; properties.variant_name[0] = '\0'; - - error = + + error = WMrDialog_ModalBegin( OWcDialog_Sound_to_Anim_Prop, inDialog, @@ -5136,14 +5136,14 @@ OWiStA_HandleNew( (UUtUns32)&properties, &message); UUmError_ReturnOnError(error); - + if (message == OWcStAP_Btn_Save) { OStVariant *variant; - + variant = OSrVariantList_Variant_GetByName(properties.variant_name); if (variant == NULL) { return UUcError_Generic; } - + // add the item error = OSrVariant_SoundAnimation_Add( @@ -5154,14 +5154,14 @@ OWiStA_HandleNew( properties.frame, properties.impulse_id); UUmError_ReturnOnError(error); - + // save the data OSrVariantList_Save(UUcFalse); - + // fill in the listbox OWiStA_FillListBox(WMrDialog_GetItemByID(inDialog, OWcStA_LB_Data)); } - + return UUcError_None; } @@ -5171,7 +5171,7 @@ OWiStA_InitDialog( WMtDialog *inDialog) { WMtWindow *listbox; - + listbox = WMrDialog_GetItemByID(inDialog, OWcStA_LB_Data); // fill in the listbox @@ -5190,26 +5190,26 @@ OWiStA_HandleCommand( case WMcDialogItem_Cancel: WMrDialog_ModalEnd(inDialog, 0); break; - + case OWcStA_LB_Data: if (UUmHighWord(inParam1) == WMcNotify_DoubleClick) { OWiStA_HandleEdit(inDialog); } break; - + case OWcStA_Btn_Delete: OWiStA_HandleDelete(inDialog); break; - + case OWcStA_Btn_Play: OWiStA_HandlePlay(inDialog); break; - + case OWcStA_Btn_Edit: OWiStA_HandleEdit(inDialog); break; - + case OWcStA_Btn_New: OWiStA_HandleNew(inDialog); break; @@ -5237,15 +5237,15 @@ OWiStA_HandleDrawItem( // get a pointer to the partspec_ui partspec_ui = PSrPartSpecUI_GetActive(); UUmAssert(partspec_ui); - + // set the dest dest.x = inDrawItem->rect.left; dest.y = inDrawItem->rect.top; - + // calc the width and height of the line line_width = inDrawItem->rect.right - inDrawItem->rect.left; line_height = inDrawItem->rect.bottom - inDrawItem->rect.top; - + /* if (inDrawItem->state & WMcDrawItemState_Selected) { // draw the hilite @@ -5270,22 +5270,22 @@ OWiStA_HandleDrawItem( 2, M3cMaxAlpha); } - + is_animation = (inDrawItem->data & 0x80000000) != 0; variant_index = UUmHighWord(inDrawItem->data) & 0x7FFF; - + // get the variant and animation sound variant = OSrVariantList_Variant_GetByIndex(variant_index); if (variant == NULL) { return; } - + sound_animation = OSrVariant_SoundAnimation_GetByIndex(variant, UUmLowWord(inDrawItem->data)); if (sound_animation == NULL) { return; } - + // draw the Text DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrText_SetStyle(TScStyle_Plain); DCrText_SetShade(IMcShade_Black); - + dest.x = 5; dest.y += 1; @@ -5294,14 +5294,14 @@ OWiStA_HandleDrawItem( OSrVariant_GetName(variant), &inDrawItem->rect, &dest); - + dest.x = 125; - + anim_type = sound_animation->anim_type; if (anim_type == OScAnimType_Animation) { TRtAnimation *animation; - + animation = sound_animation->animation; if (animation == NULL) { @@ -5325,16 +5325,16 @@ OWiStA_HandleDrawItem( char string[128]; const char *mod_name; const char *anim_name; - + mod_name = OSrModType_GetName(sound_animation->mod_type); anim_name = OSrAnimType_GetName(anim_type); - + sprintf(string, "%s %s", mod_name, anim_name); DCrDraw_String(inDrawItem->draw_context, string, &inDrawItem->rect, &dest); } - + dest.x = 305; - + impulse_id = sound_animation->impulse_id; if ((impulse_id != SScInvalidID) && (SSrImpulse_GetByID(impulse_id) != NULL)) { @@ -5342,7 +5342,7 @@ OWiStA_HandleDrawItem( OSrCollection_Item_GetByID( OSrCollection_GetByType(OScCollectionType_Impulse), impulse_id); - + DCrDraw_String( inDrawItem->draw_context, OSrItem_GetName(item), @@ -5368,28 +5368,28 @@ OWiStA_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiStA_InitDialog(inDialog); break; - + case WMcMessage_Command: OWiStA_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_DrawItem: OWiStA_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -5399,7 +5399,7 @@ OWrSoundToAnim_Display( void) { UUtError error; - + // display the sound to animation dialog error = WMrDialog_ModalBegin( @@ -5409,7 +5409,7 @@ OWrSoundToAnim_Display( 0, NULL); UUmError_ReturnOnError(error); - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound.h b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound.h index 6d268fe..6daedee 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound.h +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound.h @@ -230,13 +230,13 @@ OWrSAS_Display( WMtDialog *inParentDialog, UUtUns32 *ioAmbientSoundID, SStAmbient **ioAmbientSound); - + UUtError OWrSIS_Display( WMtDialog *inParentDialog, UUtUns32 *ioImpulseSoundID, SStImpulse **ioImpulseSound); - + UUtError OWrSoundToAnim_Display( void); @@ -247,4 +247,4 @@ OWrImpulseSoundProp_Display( OStItem *inItem); // ====================================================================== -#endif /* ONI_WIN_SOUND_H */ \ No newline at end of file +#endif /* ONI_WIN_SOUND_H */ diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound2.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound2.c index 5c6636d..ac8877c 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound2.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound2.c @@ -159,8 +159,8 @@ enum OWcISP_Btn_SetImpulse = 112, OWcISP_Btn_EditImpulse = 113, OWcISP_EF_Threshold = 114, - OWcISP_EF_ImpactVelocity = 115, - OWcISP_EF_MinOcclusion = 116, + OWcISP_EF_ImpactVelocity = 115, + OWcISP_EF_MinOcclusion = 116, OWcISP_Btn_Cancel = WMcDialogItem_Cancel, OWcISP_Btn_Save = WMcDialogItem_OK }; @@ -268,7 +268,7 @@ typedef struct OWtSMData OWtSMType type; BFtFileRef *dir_ref; const char *extension; - + UUtBool can_paste; union { @@ -276,7 +276,7 @@ typedef struct OWtSMData SStGroup group; SStImpulse impulse; }u; - + } OWtSMData; typedef struct OWtAmbientProp @@ -284,11 +284,11 @@ typedef struct OWtAmbientProp BFtFileRef *parent_dir_ref; SStAmbient *ambient; SStPlayID play_id; - + SStAmbient ta; // temp ambient - + UUtBool can_save; - + } OWtAmbientProp; typedef struct OWtGroupProp @@ -299,18 +299,18 @@ typedef struct OWtGroupProp SStGroup tg; // temp group UUtBool can_save; - + } OWtGroupProp; typedef struct OWtImpulseProp { BFtFileRef *parent_dir_ref; SStImpulse *impulse; - + SStImpulse ti; // temp impulse - + UUtBool can_save; - + } OWtImpulseProp; typedef struct OWtWS @@ -319,7 +319,7 @@ typedef struct OWtWS BFtFileRef *base_dir_ref; SStSoundData *selected_sound_data; BFtFileRef *selected_category; - + } OWtWS; typedef struct OWtSelectData @@ -327,32 +327,32 @@ typedef struct OWtSelectData OWtSMType type; BFtFileRef *dir_ref; const char *extension; - + union { SStAmbient *ambient; SStGroup *group; SStImpulse *impulse; } u; - + } OWtSelectData; typedef struct OWtCreateDialogue { BFtFileRef *dir_ref; - + } OWtCreateDialogue; typedef struct OWtCreateImpulse { BFtFileRef *dir_ref; - + } OWtCreateImpulse; typedef struct OWtCreateGroup { BFtFileRef *dir_ref; - + } OWtCreateGroup; typedef struct OWtStAP @@ -365,17 +365,17 @@ typedef struct OWtStAP char anim_name[ONcMaxVariantNameLength]; char variant_name[ONcMaxVariantNameLength]; char impulse_name[SScMaxNameLength]; - + } OWtStAP; typedef struct OWtSA { TRtAnimation *animation; /* in/out */ - + TRtAnimation **animation_list; /* internal use only */ UUtUns32 num_animations; /* internal use only */ UUtUns32 insert_from_index; /* internal use only */ - + } OWtSA; // ====================================================================== @@ -396,12 +396,12 @@ static void OWiEditGroup( WMtDialog *inParentDialog, SStGroup *inGroup); - + static void OWiEditImpulse( WMtDialog *inParentDialog, SStImpulse *inImpulse); - + // ====================================================================== // functions // ====================================================================== @@ -452,36 +452,36 @@ OWiCN_Callback( UUtBool handled; WMtWindow *editfield; char *name; - + handled = UUcTrue; - + // get a pointer to the name name = (char*)WMrDialog_GetUserData(inDialog); - + switch (inMessage) { case WMcMessage_InitDialog: // get a pointer to the edit field editfield = WMrDialog_GetItemByID(inDialog, OWcCN_EF_Name); UUmAssert(editfield); - + // set a limit on the length of the name WMrMessage_Send(editfield, EFcMessage_SetMaxChars, (BFcMaxFileNameLength - 1), 0); - + // set the name WMrMessage_Send(editfield, EFcMessage_SetText, (UUtUns32)name, 0); - + // set focus to the editfield WMrWindow_SetFocus(editfield); break; - + case WMcMessage_Command: if (UUmHighWord(inParam1) != WMcNotify_Click) { break; } - + // get a pointer to the edit field editfield = WMrDialog_GetItemByID(inDialog, OWcCN_EF_Name); UUmAssert(editfield); - + switch (UUmLowWord(inParam1)) { case OWcCN_Btn_OK: @@ -491,7 +491,7 @@ OWiCN_Callback( EFcMessage_GetText, (UUtUns32)name, BFcMaxFileNameLength); - + if (name[0] == '\0') { WMrDialog_MessageBox( @@ -506,21 +506,21 @@ OWiCN_Callback( WMrDialog_ModalEnd(inDialog, OWcCN_Btn_OK); } break; - + case OWcCN_Btn_Cancel: // end the dialog WMrDialog_ModalEnd(inDialog, OWcCN_Btn_Cancel); break; } - - + + break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -542,33 +542,33 @@ OWiWS_SelectSoundData( UUtUns32 item_data; file_ref = NULL; - + // get a pointer to the user data ws = (OWtWS*)WMrDialog_GetUserData(inDialog); UUmAssert(ws); - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcWS_LB_DirContents); UUmAssert(listbox); - + ws->selected_sound_data = NULL; ws->selected_category = NULL; // get the data of the currently selected item item_data = WMrListBox_GetItemData(listbox, (UUtUns32)-1); - if (item_data == LBcDirItemType_File) { + if (item_data == LBcDirItemType_File) { // get the selected file's name WMrMessage_Send(listbox, LBcMessage_GetText, (UUtUns32)selected_file_name, (UUtUns32)-1); UUrString_MakeLowerCase(selected_file_name, BFcMaxFileNameLength); - + // get the SStSoundData* corresponding to this file ws->selected_sound_data = SSrSoundData_GetByName(selected_file_name, UUcTrue); if (ws->selected_sound_data != NULL) { goto cleanup; } - + // create the file ref error = BFrFileRef_DuplicateAndAppendName(OWgWS_DirRef, selected_file_name, &file_ref); if (error != UUcError_None) { goto cleanup; } - + // create a new sound data error = SSrSoundData_New(file_ref, &ws->selected_sound_data); if (error != UUcError_None) { goto cleanup; } @@ -579,7 +579,7 @@ OWiWS_SelectSoundData( // get the selected directory's name WMrMessage_Send(listbox, LBcMessage_GetText, (UUtUns32)selected_file_name, (UUtUns32)-1); UUrString_MakeLowerCase(selected_file_name, BFcMaxFileNameLength); - + // create the directory's file ref error = BFrFileRef_DuplicateAndAppendName(OWgWS_DirRef, selected_file_name, &ws->selected_category); if (error != UUcError_None) { goto cleanup; } @@ -596,7 +596,7 @@ OWiWS_SelectSoundData( UUrMemory_Block_Delete(file_ref); file_ref = NULL; } - + return error; } @@ -612,20 +612,20 @@ OWiWS_FillListbox( // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcWS_LB_DirContents); UUmAssert(listbox); - + // initialize the directory info directory_info.directory_ref = inFileRef; directory_info.flags = (LBcDirectoryInfoFlag_Files | LBcDirectoryInfoFlag_Directory); directory_info.prefix[0] = '\0'; UUrString_Copy(directory_info.suffix, ".wav", BFcMaxFileNameLength); - + // add .wav files and the folders to the listbox WMrMessage_Send( listbox, LBcMessage_SetDirectoryInfo, (UUtUns32)&directory_info, (UUtUns32)UUcTrue); - + // add .aif files to listbox directory_info.flags = LBcDirectoryInfoFlag_Files; UUrString_Copy(directory_info.suffix, ".aif", BFcMaxFileNameLength); @@ -634,7 +634,7 @@ OWiWS_FillListbox( LBcMessage_SetDirectoryInfo, (UUtUns32)&directory_info, (UUtUns32)UUcFalse); - + // add .aiff files to listbox directory_info.flags = LBcDirectoryInfoFlag_Files; UUrString_Copy(directory_info.suffix, ".aiff", BFcMaxFileNameLength); @@ -662,43 +662,43 @@ OWiWS_SetPopup( BFtFileRef *dir_ref; BFtFileRef *parent; UUtUns16 i; - + error = BFrFileRef_Duplicate(inDirRef, &dir_ref); UUmError_ReturnOnError(error); - + WMrPopupMenu_Reset(inPopup); i = 0; - + while (1) { WMtMenuItemData item_data; - + // add the current directory name to the popup item_data.flags = WMcMenuItemFlag_Enabled; item_data.id = i++; UUrString_Copy(item_data.title, BFrFileRef_GetLeafName(dir_ref), WMcMaxTitleLength); WMrPopupMenu_InsertItem(inPopup, &item_data, 0); - + // stop if the root binary sound directory was added if (BFrFileRef_IsEqual(inBaseDirRef, dir_ref) == UUcTrue) { break; } - - // get the parent directory + + // get the parent directory error = BFrFileRef_GetParentDirectory(dir_ref, &parent); if (error != UUcError_None) { break; } - + BFrFileRef_Dispose(dir_ref); dir_ref = parent; parent = NULL; } - + WMrPopupMenu_SetSelection(inPopup, 0); - + if (dir_ref) { BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } - + return UUcError_None; } @@ -709,21 +709,21 @@ OWiWS_EnableButtons( WMtWindow *inListBox) { UUtUns32 item_data; - UUtBool can_select; + UUtBool can_select; WMtWindow *button; OWtWS *ws; - + // get a pointer to the user data ws = (OWtWS*)WMrDialog_GetUserData(inDialog); UUmAssert(ws); - + can_select = UUcFalse; - + // get the data of the currently selected item item_data = WMrListBox_GetItemData(inListBox, (UUtUns32)-1); if (item_data == LBcDirItemType_File) { can_select = UUcTrue; } if ((ws->allow_categories) && (item_data == LBcDirItemType_Directory)) { can_select = UUcTrue; } - + // enable or disable the select button depending on the type of // item currently selected button = WMrDialog_GetItemByID(inDialog, OWcWS_Btn_Select); @@ -739,11 +739,11 @@ OWiWS_SelectItem( UUtError error; OWtWS *ws; UUtUns32 item_data; - + // get a pointer to the user data ws = (OWtWS*)WMrDialog_GetUserData(inDialog); UUmAssert(ws); - + // get the data of the currently selected item item_data = WMrListBox_GetItemData(inListBox, (UUtUns32)(-1)); if (item_data == LBcDirItemType_File) @@ -757,55 +757,55 @@ OWiWS_SelectItem( BFtFileRef *parent_dir_ref; BFtFileRef *open_dir_ref; char name[BFcMaxFileNameLength]; - + parent_dir_ref = NULL; open_dir_ref = NULL; name[0] = '\0'; - + // get the parent dir ref error = BFrFileRef_Duplicate(OWgWS_DirRef, &parent_dir_ref); if (error != UUcError_None) { goto cleanup; } - + // make a dir ref for the directory being opened WMrListBox_GetText(inListBox, name, (UUtUns32)(-1)); error = BFrFileRef_DuplicateAndAppendName(parent_dir_ref, name, &open_dir_ref); if (error != UUcError_None) { goto cleanup; } - + // fill in the listbox OWiWS_FillListbox(inDialog, open_dir_ref); - + // dispose of the current directory ref if (OWgWS_DirRef != NULL) { BFrFileRef_Dispose(OWgWS_DirRef); OWgWS_DirRef = NULL; } - + // set the new directory ref error = BFrFileRef_Duplicate(open_dir_ref, &OWgWS_DirRef); if (error != UUcError_None) { goto cleanup; } - + // fill the popup menu error = OWiWS_SetPopup( WMrDialog_GetItemByID(inDialog, OWcWS_PM_Directory), ws->base_dir_ref, OWgWS_DirRef); - + cleanup: if (parent_dir_ref != NULL) { BFrFileRef_Dispose(parent_dir_ref); parent_dir_ref = NULL; } - + if (open_dir_ref != NULL) { BFrFileRef_Dispose(open_dir_ref); open_dir_ref = NULL; } } - + return UUcError_None; } @@ -816,16 +816,16 @@ OWiWS_InitDialog( { UUtError error; OWtWS *ws; - + // get the user data ws = (OWtWS*)WMrDialog_GetUserData(inDialog); if (ws == NULL) { goto cleanup; } - + // init ws ws->base_dir_ref = NULL; ws->selected_sound_data = NULL; ws->selected_category = NULL; - + if (ws->allow_categories) { WMrWindow_SetTitle(inDialog, "Select Sound File or Directory", WMcMaxTitleLength); } else { @@ -844,16 +844,16 @@ OWiWS_InitDialog( goto cleanup; } - + if (OWgWS_DirRef == NULL) { error = BFrFileRef_Duplicate(ws->base_dir_ref, &OWgWS_DirRef); if (error != UUcError_None) { goto cleanup; } } - + // fill the directory OWiWS_FillListbox(inDialog, OWgWS_DirRef); - + // fill the popup menu error = OWiWS_SetPopup( @@ -861,9 +861,9 @@ OWiWS_InitDialog( ws->base_dir_ref, OWgWS_DirRef); if (error != UUcError_None) { goto cleanup; } - + return; - + cleanup: WMrDialog_ModalEnd(inDialog, OWcWS_Btn_Cancel); } @@ -877,7 +877,7 @@ OWiWS_Destroy( // get a pointer to the user data ws = (OWtWS*)WMrDialog_GetUserData(inDialog); - + if (ws->base_dir_ref) { BFrFileRef_Dispose(ws->base_dir_ref); @@ -894,7 +894,7 @@ OWiWS_HandleCommand( { UUtUns16 command_type; UUtUns16 control_id; - + // interpret inParam1 command_type = UUmHighWord(inParam1); control_id = UUmLowWord(inParam1); @@ -905,11 +905,11 @@ OWiWS_HandleCommand( OWiWS_SelectSoundData(inDialog); WMrDialog_ModalEnd(inDialog, OWcWS_Btn_Select); break; - + case OWcWS_Btn_Cancel: WMrDialog_ModalEnd(inDialog, OWcWS_Btn_Cancel); break; - + case OWcWS_LB_DirContents: if (command_type == LBcNotify_SelectionChanged) { @@ -933,33 +933,33 @@ OWiWS_HandleMenuCommand( UUtUns32 i; BFtFileRef *dir_ref; UUtError error; - + // if inItemID == 0 then the popup menu is still on the same item // so no updating needs to be done if (inItemID == 0) { return; } - + // get the dir ref of the current item in the popup menu error = BFrFileRef_Duplicate(OWgWS_DirRef, &dir_ref); if (error != UUcError_None) { return; } - + // go up the hierarchy of directories until the desired directory is found for (i = 0; i < (UUtUns32)inItemID; i++) { BFtFileRef *parent_ref; - + error = BFrFileRef_GetParentDirectory(dir_ref, &parent_ref); if (error != UUcError_None) { return; } - + BFrFileRef_Dispose(dir_ref); dir_ref = parent_ref; } - + // fill in the listbox OWiWS_FillListbox(inDialog, dir_ref); - + BFrFileRef_Dispose(OWgWS_DirRef); BFrFileRef_Duplicate(dir_ref, &OWgWS_DirRef); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } @@ -973,35 +973,35 @@ OWiWS_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiWS_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiWS_Destroy(inDialog); break; - + case WMcMessage_Command: OWiWS_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_MenuCommand: OWiWS_HandleMenuCommand( inDialog, (WMtWindow*)inParam2, (UUtUns32)UUmLowWord(inParam1)); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -1023,12 +1023,12 @@ OWiSPP_SaveFields( float max_volume_percent; float min_pitch_percent; float max_pitch_percent; - + // get the fields editfield = WMrDialog_GetItemByID(inDialog, OWcSPP_EF_Weight); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, 128); sscanf(string, "%d", &weight); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSPP_EF_MinVol); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, 128); sscanf(string, "%f", &min_volume_percent); @@ -1044,7 +1044,7 @@ OWiSPP_SaveFields( editfield = WMrDialog_GetItemByID(inDialog, OWcSPP_EF_MaxPitch); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, 128); sscanf(string, "%f", &max_pitch_percent); - + // check ranges if (min_volume_percent > max_volume_percent) { @@ -1066,18 +1066,18 @@ OWiSPP_SaveFields( WMrWindow_SetFocus(WMrDialog_GetItemByID(inDialog, OWcSPP_EF_MinPitch)); return UUcFalse; } - + // get a pointer to the permutation perm = (SStPermutation*)WMrDialog_GetUserData(inDialog); UUmAssert(perm); - + // save the data perm->weight = weight; perm->min_volume_percent = min_volume_percent; perm->max_volume_percent = max_volume_percent; perm->min_pitch_percent = min_pitch_percent; perm->max_pitch_percent = max_pitch_percent; - + return UUcTrue; } @@ -1091,7 +1091,7 @@ OWiSPP_InitDialog( WMtWindow *editfield; const char *name; char string[128]; - + // get a pointer to the permutation perm = (SStPermutation*)WMrDialog_GetUserData(inDialog); if (perm == NULL) @@ -1099,18 +1099,18 @@ OWiSPP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcSPP_Btn_Cancel); return; } - + // set the name name = SSrPermutation_GetName(perm); text = WMrDialog_GetItemByID(inDialog, OWcSPP_Txt_Name); UUmAssert(text); WMrWindow_SetTitle(text, name, BFcMaxFileNameLength); - + // set the edit fields editfield = WMrDialog_GetItemByID(inDialog, OWcSPP_EF_Weight); sprintf(string, "%d", perm->weight); WMrMessage_Send(editfield, EFcMessage_SetText, (UUtUns32)string, 0); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSPP_EF_MinVol); sprintf(string, "%1.2f", perm->min_volume_percent); WMrMessage_Send(editfield, EFcMessage_SetText, (UUtUns32)string, 0); @@ -1143,7 +1143,7 @@ OWiSPP_HandleCommand( WMrDialog_ModalEnd(inDialog, OWcSPP_Btn_Save); } break; - + case OWcSPP_Btn_Cancel: WMrDialog_ModalEnd(inDialog, OWcSPP_Btn_Cancel); break; @@ -1159,24 +1159,24 @@ OWiSPP_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiSPP_InitDialog(inDialog); break; - + case WMcMessage_Command: OWiSPP_HandleCommand(inDialog, inParam1); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -1196,11 +1196,11 @@ OWiASP_EnableButtons( char name[SScMaxNameLength]; SStAmbient *found_ambient; UUtBool no_name_conflict; - + // determine if there is a name conflict editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_Name); WMrEditField_GetText(editfield, name, SScMaxNameLength); - + found_ambient = OSrAmbient_GetByName(name); if (name[0] == '\0') { @@ -1214,7 +1214,7 @@ OWiASP_EnableButtons( { no_name_conflict = UUcFalse; } - + button = WMrDialog_GetItemByID(inDialog, OWcASP_Btn_InGroupEdit); WMrWindow_SetEnabled(button, (inAP->ta.in_sound != NULL)); @@ -1229,13 +1229,13 @@ OWiASP_EnableButtons( button = WMrDialog_GetItemByID(inDialog, OWcASP_Btn_DetailEdit); WMrWindow_SetEnabled(button, (inAP->ta.detail != NULL)); - + button = WMrDialog_GetItemByID(inDialog, OWcASP_Btn_Start); WMrWindow_SetEnabled(button, (inAP->play_id == SScInvalidID)); button = WMrDialog_GetItemByID(inDialog, OWcASP_Btn_Stop); WMrWindow_SetEnabled(button, (inAP->play_id != SScInvalidID)); - + button = WMrDialog_GetItemByID(inDialog, OWcASP_Btn_Save); WMrWindow_SetEnabled(button, inAP->can_save && no_name_conflict); } @@ -1251,15 +1251,15 @@ OWiASP_RecordData( WMtWindow *editfield; UUtUns16 priority; char name[SScMaxNameLength]; - + editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_Name); WMrEditField_GetText(editfield, name, SScMaxNameLength); UUrString_Copy(inAP->ta.ambient_name, name, SScMaxNameLength); - + popup = WMrDialog_GetItemByID(inDialog, OWcASP_PM_Priority); WMrPopupMenu_GetItemID(popup, -1, &priority); inAP->ta.priority = (SStPriority2)priority; - + checkbox = WMrDialog_GetItemByID(inDialog, OWcASP_CB_InterruptOnStop); if (WMrCheckBox_GetCheck(checkbox) == UUcTrue) { @@ -1269,7 +1269,7 @@ OWiASP_RecordData( { inAP->ta.flags &= ~SScAmbientFlag_InterruptOnStop; } - + checkbox = WMrDialog_GetItemByID(inDialog, OWcASP_CB_PlayOnce); if (WMrCheckBox_GetCheck(checkbox) == UUcTrue) { @@ -1279,7 +1279,7 @@ OWiASP_RecordData( { inAP->ta.flags &= ~SScAmbientFlag_PlayOnce; } - + checkbox = WMrDialog_GetItemByID(inDialog, OWcASP_CB_CanPan); if (WMrCheckBox_GetCheck(checkbox) == UUcTrue) { @@ -1289,7 +1289,7 @@ OWiASP_RecordData( { inAP->ta.flags &= ~SScAmbientFlag_Pan; } - + editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_SphereRadius); inAP->ta.sphere_radius = WMrEditField_GetFloat(editfield); @@ -1298,13 +1298,13 @@ OWiASP_RecordData( editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_MaxElapsedTime); inAP->ta.max_detail_time = WMrEditField_GetFloat(editfield); - + editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_MaxVolDist); inAP->ta.max_volume_distance = WMrEditField_GetFloat(editfield); - + editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_MinVolDist); inAP->ta.min_volume_distance = WMrEditField_GetFloat(editfield); - + editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_Threshold); inAP->ta.threshold = (UUtUns32)WMrEditField_GetInt32(editfield); @@ -1382,11 +1382,11 @@ OWiASP_Save( WMtWindow *editfield; char name[BFcMaxFileNameLength]; SStAmbient *found_ambient; - + // make sure the sound has a name editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_Name); WMrEditField_GetText(editfield, name, BFcMaxFileNameLength); - + if (strlen(name) == 0) { WMrDialog_MessageBox( @@ -1396,9 +1396,9 @@ OWiASP_Save( WMcMessageBoxStyle_OK); return UUcFalse; } - + OSrMakeGoodName(name, name); - + if (inAP->ambient == NULL) { found_ambient = OSrAmbient_GetByName(name); @@ -1411,7 +1411,7 @@ OWiASP_Save( WMcMessageBoxStyle_OK); return UUcFalse; } - + error = OSrAmbient_New(name, &inAP->ambient); if (error != UUcError_None) { @@ -1441,10 +1441,10 @@ OWiASP_Save( } } } - + // get the data - OWiASP_RecordData(inDialog, inAP); - + OWiASP_RecordData(inDialog, inAP); + if (inAP->ta.min_volume_distance < inAP->ta.max_volume_distance) { WMrDialog_MessageBox( @@ -1454,7 +1454,7 @@ OWiASP_Save( WMcMessageBoxStyle_OK); return UUcFalse; } - + // set the data for the ambient sound inAP->ambient->priority = inAP->ta.priority; inAP->ambient->flags = inAP->ta.flags; @@ -1475,10 +1475,10 @@ OWiASP_Save( UUrString_Copy(inAP->ambient->base_track2_name, inAP->ta.base_track2_name, SScMaxNameLength); UUrString_Copy(inAP->ambient->in_sound_name, inAP->ta.in_sound_name, SScMaxNameLength); UUrString_Copy(inAP->ambient->out_sound_name, inAP->ta.out_sound_name, SScMaxNameLength); - + // save the ambient sound to disk OSrAmbient_Save(inAP->ambient, inAP->parent_dir_ref); - + return UUcTrue; } @@ -1487,7 +1487,7 @@ static UUtBool OWiASP_CheckGroups( WMtDialog *inDialog, SStAmbient *inAmbient) -{ +{ if (inAmbient->base_track1 != NULL) { if ((inAmbient->in_sound != NULL) && @@ -1498,10 +1498,10 @@ OWiASP_CheckGroups( "Error", "The in sound and base track 1 must use the same number of sound channels.", WMcMessageBoxStyle_OK); - + return UUcFalse; } - + if ((inAmbient->out_sound != NULL) && (inAmbient->base_track1->num_channels != inAmbient->out_sound->num_channels)) { @@ -1510,10 +1510,10 @@ OWiASP_CheckGroups( "Error", "The out sound and base track 1 must use the same number of sound channels.", WMcMessageBoxStyle_OK); - + return UUcFalse; } - + if ((inAmbient->in_sound != NULL) && (inAmbient->out_sound != NULL)) { if (inAmbient->in_sound->num_channels != inAmbient->out_sound->num_channels) @@ -1523,7 +1523,7 @@ OWiASP_CheckGroups( "Error", "The in sound and the out sound must use the same number of sound channels.", WMcMessageBoxStyle_OK); - + return UUcFalse; } } @@ -1542,23 +1542,23 @@ OWiASP_SetFields( WMtWindow *text; WMtWindow *popup; WMtWindow *checkbox; - - if (inAP->ambient) + + if (inAP->ambient) { editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_Name); WMrEditField_SetText(editfield, inAP->ambient->ambient_name); } - + text = WMrDialog_GetItemByID(inDialog, OWcASP_Txt_InGroup); WMrWindow_SetTitle(text, inAP->ta.in_sound_name, SScMaxNameLength); if (inAP->ta.in_sound) { WMrText_SetShade(text, IMcShade_Black); } else { WMrText_SetShade(text, IMcShade_Red); } - + text = WMrDialog_GetItemByID(inDialog, OWcASP_Txt_OutGroup); WMrWindow_SetTitle(text, inAP->ta.out_sound_name, SScMaxNameLength); if (inAP->ta.out_sound) { WMrText_SetShade(text, IMcShade_Black); } else { WMrText_SetShade(text, IMcShade_Red); } - + text = WMrDialog_GetItemByID(inDialog, OWcASP_Txt_BT1); WMrWindow_SetTitle(text, inAP->ta.base_track1_name, SScMaxNameLength); if (inAP->ta.base_track1) { WMrText_SetShade(text, IMcShade_Black); } @@ -1573,31 +1573,31 @@ OWiASP_SetFields( WMrWindow_SetTitle(text, inAP->ta.detail_name, SScMaxNameLength); if (inAP->ta.detail) { WMrText_SetShade(text, IMcShade_Black); } else { WMrText_SetShade(text, IMcShade_Red); } - + editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_MinElapsedTime); WMrEditField_SetFloat(editfield, inAP->ta.min_detail_time); - + editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_MaxElapsedTime); WMrEditField_SetFloat(editfield, inAP->ta.max_detail_time); - + editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_SphereRadius); WMrEditField_SetFloat(editfield, inAP->ta.sphere_radius); - + editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_MinVolDist); WMrEditField_SetFloat(editfield, inAP->ta.min_volume_distance); - + editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_MaxVolDist); WMrEditField_SetFloat(editfield, inAP->ta.max_volume_distance); - + editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_Threshold); WMrEditField_SetInt32(editfield, inAP->ta.threshold); editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_MinOcclusion); WMrEditField_SetFloat(editfield, inAP->ta.min_occlusion); - + popup = WMrDialog_GetItemByID(inDialog, OWcASP_PM_Priority); WMrPopupMenu_SetSelection(popup, inAP->ta.priority); - + checkbox = WMrDialog_GetItemByID(inDialog, OWcASP_CB_InterruptOnStop); WMrCheckBox_SetCheck(checkbox, ((inAP->ta.flags & SScAmbientFlag_InterruptOnStop) != 0)); @@ -1616,7 +1616,7 @@ OWiASP_InitDialog( UUtError error; OWtAmbientProp *ap; WMtWindow *editfield; - + // get the ambient properties ap = (OWtAmbientProp*)WMrDialog_GetUserData(inDialog); if (ap == NULL) @@ -1624,7 +1624,7 @@ OWiASP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcASP_Btn_Cancel); return; } - + // initialize the ambient properties ap->play_id = SScInvalidID; UUrMemory_Clear(&ap->ta, sizeof(SStAmbient)); @@ -1634,24 +1634,24 @@ OWiASP_InitDialog( { ap->ta.priority = SScPriority2_Normal; ap->ta.flags = SScAmbientFlag_None; - + ap->ta.sphere_radius = 10.0f; ap->ta.min_detail_time = 1.0f; ap->ta.max_detail_time = 1.0f; - + ap->ta.max_volume_distance = 10.0f; ap->ta.min_volume_distance = 50.0f; - + ap->ta.threshold = SScAmbientThreshold; ap->ta.min_occlusion = 0.0f; - + ap->ta.base_track1 = NULL; ap->ta.base_track2 = NULL; ap->ta.detail = NULL; ap->ta.in_sound = NULL; ap->ta.out_sound = NULL; - - if ((ap->parent_dir_ref != NULL) && + + if ((ap->parent_dir_ref != NULL) && (BFrFileRef_FileExists(ap->parent_dir_ref) == UUcTrue)) { ap->can_save = UUcTrue; @@ -1660,15 +1660,15 @@ OWiASP_InitDialog( else { ap->ta = *ap->ambient; - + // does the ambient sound have a file ref if (ap->parent_dir_ref != NULL) { BFtFileRef *dir_ref; char name[SScMaxNameLength]; - + sprintf(name, "%s.%s", ap->ambient->ambient_name, OScAmbientSuffix); - + error = BFrFileRef_DuplicateAndAppendName( ap->parent_dir_ref, @@ -1680,13 +1680,13 @@ OWiASP_InitDialog( { ap->can_save = UUcTrue; } - + UUrMemory_Block_Delete(dir_ref); dir_ref = NULL; } } } - + // set the maximum number of characters for the ambient name editfield = WMrDialog_GetItemByID(inDialog, OWcASP_EF_Name); WMrMessage_Send( @@ -1694,13 +1694,13 @@ OWiASP_InitDialog( EFcMessage_SetMaxChars, BFcMaxFileNameLength - strlen(".abc"), 0); - + // set the fields OWiASP_SetFields(inDialog, ap); - + // enable the buttons OWiASP_EnableButtons(inDialog, ap); - + // set the focus to the name WMrWindow_SetFocus(editfield); } @@ -1718,31 +1718,31 @@ OWiASP_HandleCommand( UUtBool update_fields; SStGroup *group; OWtSelectResult result; - + ap = (OWtAmbientProp*)WMrDialog_GetUserData(inDialog); - + update_fields = UUcTrue; - + control_id = UUmLowWord(inParam); command_type = UUmHighWord(inParam); - + switch (control_id) { case OWcASP_EF_Name: if (command_type != EFcNotify_ContentChanged) { break; } - + // if the ambient sound was locked, then the can_save bool // is null. If the name changes, then the user wants to make // a new ambient sound so allow this by setting the ambient to // null and setting can_save to UUcTrue - if (ap->can_save == UUcFalse) + if (ap->can_save == UUcFalse) { ap->ambient = NULL; ap->can_save = UUcTrue; } update_fields = UUcFalse; break; - + case OWcASP_Btn_InGroupSet: if (command_type != WMcNotify_Click) { break; } result = OWrSelect_SoundGroup(&group); @@ -1752,7 +1752,7 @@ OWiASP_HandleCommand( { ap->ta.in_sound = NULL; } - + if (ap->ta.in_sound != NULL) { UUrString_Copy( @@ -1765,12 +1765,12 @@ OWiASP_HandleCommand( UUrMemory_Clear(ap->ta.in_sound_name, SScMaxNameLength); } break; - + case OWcASP_Btn_InGroupEdit: if (command_type != WMcNotify_Click) { break; } OWiEditGroup(inDialog, ap->ta.in_sound); break; - + case OWcASP_Btn_OutGroupSet: if (command_type != WMcNotify_Click) { break; } result = OWrSelect_SoundGroup(&group); @@ -1780,7 +1780,7 @@ OWiASP_HandleCommand( { ap->ta.out_sound = NULL; } - + if (ap->ta.out_sound != NULL) { UUrString_Copy( @@ -1793,12 +1793,12 @@ OWiASP_HandleCommand( UUrMemory_Clear(ap->ta.out_sound_name, SScMaxNameLength); } break; - + case OWcASP_Btn_OutGroupEdit: if (command_type != WMcNotify_Click) { break; } OWiEditGroup(inDialog, ap->ta.out_sound); break; - + case OWcASP_Btn_BT1Set: if (command_type != WMcNotify_Click) { break; } result = OWrSelect_SoundGroup(&group); @@ -1808,7 +1808,7 @@ OWiASP_HandleCommand( { ap->ta.base_track1 = NULL; } - + if (ap->ta.base_track1 != NULL) { UUrString_Copy( @@ -1821,12 +1821,12 @@ OWiASP_HandleCommand( UUrMemory_Clear(ap->ta.base_track1_name, SScMaxNameLength); } break; - + case OWcASP_Btn_BT1Edit: if (command_type != WMcNotify_Click) { break; } OWiEditGroup(inDialog, ap->ta.base_track1); break; - + case OWcASP_Btn_BT2Set: if (command_type != WMcNotify_Click) { break; } result = OWrSelect_SoundGroup(&group); @@ -1845,12 +1845,12 @@ OWiASP_HandleCommand( UUrMemory_Clear(ap->ta.base_track2_name, SScMaxNameLength); } break; - + case OWcASP_Btn_BT2Edit: if (command_type != WMcNotify_Click) { break; } OWiEditGroup(inDialog, ap->ta.base_track2); break; - + case OWcASP_Btn_DetailSet: if (command_type != WMcNotify_Click) { break; } result = OWrSelect_SoundGroup(&group); @@ -1869,12 +1869,12 @@ OWiASP_HandleCommand( UUrMemory_Clear(ap->ta.detail_name, SScMaxNameLength); } break; - + case OWcASP_Btn_DetailEdit: if (command_type != WMcNotify_Click) { break; } OWiEditGroup(inDialog, ap->ta.detail); break; - + case OWcASP_Btn_Inc1: if (command_type != WMcNotify_Click) { break; } ap->ta.sphere_radius += 1.0f; @@ -1883,7 +1883,7 @@ OWiASP_HandleCommand( ap->ta.sphere_radius = ap->ta.min_volume_distance; } break; - + case OWcASP_Btn_Dec1: if (command_type != WMcNotify_Click) { break; } ap->ta.sphere_radius -= 1.0f; @@ -1892,7 +1892,7 @@ OWiASP_HandleCommand( ap->ta.sphere_radius = 0.0f; } break; - + case OWcASP_Btn_Inc10: if (command_type != WMcNotify_Click) { break; } ap->ta.sphere_radius += 10.0f; @@ -1901,7 +1901,7 @@ OWiASP_HandleCommand( ap->ta.sphere_radius = ap->ta.min_volume_distance; } break; - + case OWcASP_Btn_Dec10: if (command_type != WMcNotify_Click) { break; } ap->ta.sphere_radius -= 10.0f; @@ -1910,7 +1910,7 @@ OWiASP_HandleCommand( ap->ta.sphere_radius = 0.0f; } break; - + case OWcASP_Btn_Start: if (command_type != WMcNotify_Click) { break; } if ((ap->play_id == SScInvalidID) || @@ -1920,7 +1920,7 @@ OWiASP_HandleCommand( ap->play_id = SSrAmbient_Start_Simple(&ap->ta, NULL); } break; - + case OWcASP_Btn_Stop: if (command_type != WMcNotify_Click) { break; } if (ap->play_id != SScInvalidID) @@ -1929,12 +1929,12 @@ OWiASP_HandleCommand( SSrAmbient_Stop(ap->play_id); } break; - + case OWcASP_Btn_Cancel: if (command_type != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, OWcASP_Btn_Cancel); break; - + case OWcASP_Btn_Save: if (command_type != WMcNotify_Click) { break; } if (OWiASP_Save(inDialog, ap) == UUcTrue) @@ -1942,17 +1942,17 @@ OWiASP_HandleCommand( WMrDialog_ModalEnd(inDialog, OWcASP_Btn_Save); } break; - + default: update_fields = UUcFalse; break; } - + if (update_fields) { OWiASP_SetFields(inDialog, ap); } - + // update the buttons OWiASP_EnableButtons(inDialog, ap); } @@ -1962,7 +1962,7 @@ OWiASP_HandleDestroy( WMtDialog *inDialog) { OWtAmbientProp *ap; - + ap = (OWtAmbientProp*)WMrDialog_GetUserData(inDialog); if ((ap->play_id != SScInvalidID) && (SSrAmbient_Update(ap->play_id, NULL, NULL, NULL, NULL) == UUcTrue)) @@ -1978,7 +1978,7 @@ OWiASP_Paint( WMtDialog *inDialog) { OWtAmbientProp *ap; - + ap = (OWtAmbientProp*)WMrDialog_GetUserData(inDialog); if ((ap->play_id != SScInvalidID) && (SSrAmbient_Update(ap->play_id, NULL, NULL, NULL, NULL) == UUcFalse)) @@ -1997,32 +1997,32 @@ OWiASP_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiASP_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiASP_HandleDestroy(inDialog); break; - + case WMcMessage_Command: OWiASP_HandleCommand(inDialog, (WMtWindow*)inParam2, inParam1); break; - + case WMcMessage_Paint: OWiASP_Paint(inDialog); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -2036,16 +2036,16 @@ OWrAmbientProperties_Display( OWtAmbientProp ap; BFtFileRef *file_ref; BFtFileRef *dir_ref; - + UUmAssert(inAmbient); - + dir_ref = NULL; file_ref = NULL; - + // get the sound binary directory error = OSrGetSoundBinaryDirectory(&dir_ref); if (error != UUcError_None) { goto error; } - + // get the file ref of the sound error = OSrGetSoundFileRef( @@ -2054,24 +2054,24 @@ OWrAmbientProperties_Display( dir_ref, &file_ref); if (error != UUcError_None) { goto error; } - + // dispose of the sound binary directory ref BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + // get the parent directory of the sound error = BFrFileRef_GetParentDirectory(file_ref, &dir_ref); if (error != UUcError_None) { goto error; } - + // dispose of the file ref of the sound BFrFileRef_Dispose(file_ref); file_ref = NULL; - + // set up the properties UUrMemory_Clear(&ap, sizeof(OWtAmbientProp)); ap.parent_dir_ref = dir_ref; ap.ambient = inAmbient; - + // edit the sound error = WMrDialog_ModalBegin( @@ -2081,28 +2081,28 @@ OWrAmbientProperties_Display( (UUtUns32)&ap, NULL); if (error != UUcError_None) { goto error; } - + // dispose of the parent directory of the sound BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + return UUcError_None; - + error: if (dir_ref) { BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } - + if (file_ref) { BFrFileRef_Dispose(file_ref); file_ref = NULL; } - + return error; -} +} // ====================================================================== #if 0 @@ -2122,7 +2122,7 @@ OWiSGP_EnableButtons( UUtBool no_name_conflict; SStGroup *found_group; char name[BFcMaxFileNameLength]; - + // get a pointer to the listbox permutation_selected = UUcFalse; if ((inGP->tg.permutations != NULL) && @@ -2131,11 +2131,11 @@ OWiSGP_EnableButtons( listbox = WMrDialog_GetItemByID(inDialog, OWcSGP_LB_Permutations); permutation_selected = (WMrListBox_GetSelection(listbox) != LBcError); } - + // determine if there is a name conflict editfield = WMrDialog_GetItemByID(inDialog, OWcSGP_EF_Name); WMrEditField_GetText(editfield, name, BFcMaxFileNameLength); - + found_group = OSrGroup_GetByName(name); if (name[0] == '\0') { @@ -2149,20 +2149,20 @@ OWiSGP_EnableButtons( { no_name_conflict = UUcFalse; } - + // update the buttons button = WMrDialog_GetItemByID(inDialog, OWcSGP_Btn_AddPerm); WMrWindow_SetEnabled(button, UUcTrue); - + button = WMrDialog_GetItemByID(inDialog, OWcSGP_Btn_EditPerm); WMrWindow_SetEnabled(button, permutation_selected); - + button = WMrDialog_GetItemByID(inDialog, OWcSGP_Btn_PlayPerm); WMrWindow_SetEnabled(button, permutation_selected); - + button = WMrDialog_GetItemByID(inDialog, OWcSGP_Btn_DeletePerm); WMrWindow_SetEnabled(button, permutation_selected); - + button = WMrDialog_GetItemByID(inDialog, OWcSGP_Btn_Save); WMrWindow_SetEnabled(button, inGP->can_save && no_name_conflict); } @@ -2176,23 +2176,23 @@ OWiSGP_FillListbox( WMtDialog *listbox; UUtUns32 i; UUtUns32 num_permutations; - + // get the group properties gp = (OWtGroupProp*)WMrDialog_GetUserData(inDialog); // get the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSGP_LB_Permutations); - + // reset the listbox WMrListBox_Reset(listbox); - + // add the permutations num_permutations = UUrMemory_Array_GetUsedElems(gp->tg.permutations); for (i = 0; i < num_permutations; i++) { WMrMessage_Send(listbox, LBcMessage_AddString, i, 0); } - + WMrListBox_SetSelection(listbox, UUcFalse, 0); } @@ -2222,7 +2222,7 @@ OWiSGP_Perm_Add( &message); UUmError_ReturnOnError(error); if (message == OWcWS_Btn_Cancel) { return UUcError_None; } - + if (inGP->tg.num_channels == 0) { inGP->tg.num_channels = SSrSound_GetNumChannels(ws.selected_sound_data); @@ -2234,17 +2234,17 @@ OWiSGP_Perm_Add( "Error", "The selected sound does not have the same number of channels as the other sounds.", WMcMessageBoxStyle_OK); - + return UUcError_None; } - + // add the permutation error = UUrMemory_Array_GetNewElement(inGP->tg.permutations, &index, NULL); if (error != UUcError_None) { goto error; } - + perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(inGP->tg.permutations); UUmAssert(perm_array); - + perm = &perm_array[index]; perm->weight = 10; @@ -2257,9 +2257,9 @@ OWiSGP_Perm_Add( perm->sound_data_name, SSrSoundData_GetName(ws.selected_sound_data), SScMaxNameLength); - + // edit the permutation -/* +/* NOTE: removed per Marty's request error = @@ -2270,24 +2270,24 @@ NOTE: removed per Marty's request (UUtUns32)perm, &message); UUmError_ReturnOnError(error); - + if (message == OWcSPP_Btn_Save)*/ { WMtWindow *listbox; - + // update the dialog's fields OWiSGP_FillListbox(inDialog); - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSGP_LB_Permutations); UUmAssert(listbox); - + // select the permutation that was just added WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcTrue, index); } return UUcError_None; - + error: // report the error WMrDialog_MessageBox( @@ -2321,14 +2321,14 @@ OWiSGP_Perm_Delete( // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSGP_LB_Permutations); UUmAssert(listbox); - + // get the selected permutation's index perm_index = WMrListBox_GetSelection(listbox); UUmAssert(perm_index < UUrMemory_Array_GetUsedElems(inGP->tg.permutations)); - + // delete the selected permutation UUrMemory_Array_DeleteElement(inGP->tg.permutations, perm_index); - + // update the listbox OWiSGP_FillListbox(inDialog); } @@ -2345,22 +2345,22 @@ OWiSGP_Perm_Edit( UUtError error; SStPermutation *perm; SStPermutation *perm_array; - + if (UUrMemory_Array_GetUsedElems(inGP->tg.permutations) == 0) { return; } - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSGP_LB_Permutations); UUmAssert(listbox); - + // get the selected permutation's index perm_index = WMrListBox_GetSelection(listbox); UUmAssert(perm_index < UUrMemory_Array_GetUsedElems(inGP->tg.permutations)); - + perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(inGP->tg.permutations); UUmAssert(perm_array); - + perm = &perm_array[perm_index]; - + // edit the permutation error = WMrDialog_ModalBegin( @@ -2386,14 +2386,14 @@ OWiSGP_Perm_Play( // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSGP_LB_Permutations); UUmAssert(listbox); - + // get the selected permutation's index perm_index = WMrListBox_GetSelection(listbox); UUmAssert(perm_index < UUrMemory_Array_GetUsedElems(inGP->tg.permutations)); - + perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(inGP->tg.permutations); UUmAssert(perm_array); - + perm = &perm_array[perm_index]; // play the permutation @@ -2410,11 +2410,11 @@ OWiSGP_Save( WMtWindow *editfield; char name[BFcMaxFileNameLength]; SStGroup *found_group; - + // make sure the group has a name editfield = WMrDialog_GetItemByID(inDialog, OWcSGP_EF_Name); WMrEditField_GetText(editfield, name, SScMaxNameLength); - + if (strlen(name) == 0) { WMrDialog_MessageBox( @@ -2424,7 +2424,7 @@ OWiSGP_Save( WMcMessageBoxStyle_OK); return UUcFalse; } - + OSrMakeGoodName(name, name); if (inGP->group == NULL) @@ -2439,7 +2439,7 @@ OWiSGP_Save( WMcMessageBoxStyle_OK); return UUcFalse; } - + // create the group error = OSrGroup_New(name, &inGP->group); if (error != UUcError_None) @@ -2470,22 +2470,22 @@ OWiSGP_Save( } } } - + // set the data for the group UUrMemory_Array_Delete(inGP->group->permutations); - + inGP->group->group_volume = inGP->tg.group_volume; inGP->group->group_pitch = inGP->tg.group_pitch; inGP->group->flags = inGP->tg.flags; inGP->group->flag_data = inGP->tg.flag_data; inGP->group->permutations = inGP->tg.permutations; inGP->group->num_channels = inGP->tg.num_channels; - + inGP->tg.permutations = NULL; - + // save the group to disk OSrGroup_Save(inGP->group, inGP->parent_dir_ref); - + return UUcTrue; } @@ -2498,7 +2498,7 @@ OWiSGP_InitDialog( WMtWindow *editfield; WMtWindow *checkbox; UUtError error; - + // get the group properties gp = (OWtGroupProp*)WMrDialog_GetUserData(inDialog); if (gp == NULL) @@ -2513,7 +2513,7 @@ OWiSGP_InitDialog( gp->tg.flag_data = 0; gp->tg.num_channels = 0; gp->can_save = UUcFalse; - + // set the maximum number of characters for the group name editfield = WMrDialog_GetItemByID(inDialog, OWcSGP_EF_Name); WMrMessage_Send( @@ -2521,7 +2521,7 @@ OWiSGP_InitDialog( EFcMessage_SetMaxChars, BFcMaxFileNameLength - strlen(".abc"), 0); - + // set the fields if (gp->group == NULL) { @@ -2536,7 +2536,7 @@ OWiSGP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcSGP_Btn_Cancel); return; } - + if ((gp->parent_dir_ref != NULL) && (BFrFileRef_FileExists(gp->parent_dir_ref) == UUcTrue)) { @@ -2550,7 +2550,7 @@ OWiSGP_InitDialog( // set the pitch field editfield = WMrDialog_GetItemByID(inDialog, OWcSGP_EF_Pitch); WMrEditField_SetFloat(editfield, gp->tg.group_pitch); - + // set the prevent repeats checkbox checkbox = WMrDialog_GetItemByID(inDialog, OWcSGP_CB_PreventRepeats); WMrCheckBox_SetCheck(checkbox, ((gp->tg.flags & SScGroupFlag_PreventRepeats) != 0)); @@ -2560,15 +2560,15 @@ OWiSGP_InitDialog( UUtUns32 i; UUtUns32 num_permutations; SStPermutation *perm_array; - + // get the values of the group gp->tg.group_volume = gp->group->group_volume; gp->tg.group_pitch = gp->group->group_pitch; gp->tg.num_channels = (UUtUns8)gp->group->num_channels; - + // set the name field WMrEditField_SetText(editfield, gp->group->group_name); - + // set the volume field editfield = WMrDialog_GetItemByID(inDialog, OWcSGP_EF_Volume); WMrEditField_SetFloat(editfield, gp->group->group_volume); @@ -2576,11 +2576,11 @@ OWiSGP_InitDialog( // set the pitch field editfield = WMrDialog_GetItemByID(inDialog, OWcSGP_EF_Pitch); WMrEditField_SetFloat(editfield, gp->group->group_pitch); - + // set the prevent repeats checkbox checkbox = WMrDialog_GetItemByID(inDialog, OWcSGP_CB_PreventRepeats); WMrCheckBox_SetCheck(checkbox, ((gp->group->flags & SScGroupFlag_PreventRepeats) != 0)); - + // create a temp permutation array num_permutations = UUrMemory_Array_GetUsedElems(gp->group->permutations); gp->tg.permutations = @@ -2594,27 +2594,27 @@ OWiSGP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcSGP_Btn_Cancel); return; } - + // copy the permutations perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(gp->tg.permutations); for (i = 0; i < num_permutations; i++) { SStPermutation *perm; - + perm = SSrGroup_Permutation_Get(gp->group, i); perm_array[i] = *perm; } - + OWiSGP_FillListbox(inDialog); - + // does the group have a file ref if (gp->parent_dir_ref != NULL) { BFtFileRef *dir_ref; char name[BFcMaxFileNameLength]; - + sprintf(name, "%s.%s", gp->group->group_name, OScGroupSuffix); - + error = BFrFileRef_DuplicateAndAppendName( gp->parent_dir_ref, @@ -2626,15 +2626,15 @@ OWiSGP_InitDialog( { gp->can_save = UUcTrue; } - + UUrMemory_Block_Delete(dir_ref); dir_ref = NULL; } } } - + OWiSGP_EnableButtons(inDialog, gp); - + // set the focus to the name WMrWindow_SetFocus(WMrDialog_GetItemByID(inDialog, OWcSGP_EF_Name)); } @@ -2649,80 +2649,80 @@ OWiSGP_HandleCommand( UUtUns16 control_id; UUtUns16 command_type; OWtGroupProp *gp; - + gp = (OWtGroupProp*)WMrDialog_GetUserData(inDialog); - + control_id = UUmLowWord(inParam); command_type = UUmHighWord(inParam); - + switch (control_id) { case OWcSGP_EF_Name: if (command_type != EFcNotify_ContentChanged) { break; } - + // if the sound group was locked, then the can_save bool // is null. If the name changes, then the user wants to make // a new sound group so allow this by setting the group to // null and setting can_save to UUcTrue - if (gp->can_save == UUcFalse) + if (gp->can_save == UUcFalse) { gp->group = NULL; gp->can_save = UUcTrue; } break; - + case OWcSGP_LB_Permutations: if (command_type == WMcNotify_DoubleClick) { OWiSGP_Perm_Edit(inDialog, gp); } break; - + case OWcSGP_Btn_AddPerm: if (command_type != WMcNotify_Click) { break; } OWiSGP_Perm_Add(inDialog, gp); break; - + case OWcSGP_Btn_EditPerm: if (command_type != WMcNotify_Click) { break; } OWiSGP_Perm_Edit(inDialog, gp); break; - + case OWcSGP_Btn_PlayPerm: if (command_type != WMcNotify_Click) { break; } OWiSGP_Perm_Play(inDialog, gp); break; - + case OWcSGP_Btn_DeletePerm: if (command_type != WMcNotify_Click) { break; } OWiSGP_Perm_Delete(inDialog, gp); break; - + case OWcSGP_Btn_Play: if (command_type != WMcNotify_Click) { break; } SSrGroup_Play(&gp->tg, NULL, NULL, NULL); break; - + case OWcSGP_EF_Volume: if (command_type != EFcNotify_ContentChanged) { break; } gp->tg.group_volume = WMrEditField_GetFloat(inControl); break; - + case OWcSGP_EF_Pitch: if (command_type != EFcNotify_ContentChanged) { break; } gp->tg.group_pitch = WMrEditField_GetFloat(inControl); break; - + case OWcSGP_CB_PreventRepeats: if (command_type != WMcNotify_Click) { break; } gp->tg.flags = WMrCheckBox_GetCheck(inControl); break; - + case OWcSGP_Btn_Cancel: if (command_type != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, OWcSGP_Btn_Cancel); break; - + case OWcSGP_Btn_Save: if (command_type != WMcNotify_Click) { break; } if (OWiSGP_Save(inDialog, gp)) @@ -2731,7 +2731,7 @@ OWiSGP_HandleCommand( } break; } - + OWiSGP_EnableButtons(inDialog, gp); } @@ -2741,7 +2741,7 @@ OWiSGP_HandleDestroy( WMtDialog *inDialog) { OWtGroupProp *gp; - + gp = (OWtGroupProp*)WMrDialog_GetUserData(inDialog); if ((gp) && (gp->tg.permutations)) { @@ -2763,23 +2763,23 @@ OWiSGP_HandleDrawItem( SStPermutation *perm_array; SStPermutation *perm; char string[128]; - + // get a pointer to the group properties gp = (OWtGroupProp*)WMrDialog_GetUserData(inDialog); if ((gp == NULL) || (gp->tg.permutations == NULL)) { return; } if (inDrawItem->data >= UUrMemory_Array_GetUsedElems(gp->tg.permutations)) { return; } - + // get a pointer to the permutation perm_array = (SStPermutation*)UUrMemory_Array_GetMemory(gp->tg.permutations); if (perm_array == NULL) { return; } - + perm = &perm_array[inDrawItem->data]; if (perm == NULL) { return; } - + // set the dest dest.x = inDrawItem->rect.left; dest.y = inDrawItem->rect.top; - + // calc the width and height of the line line_width = inDrawItem->rect.right - inDrawItem->rect.left; line_height = inDrawItem->rect.bottom - inDrawItem->rect.top; @@ -2789,7 +2789,7 @@ OWiSGP_HandleDrawItem( DCrText_SetStyle(TScStyle_Plain); if (perm->sound_data == NULL) { DCrText_SetShade(IMcShade_Red); } else { DCrText_SetShade(IMcShade_Black); } - + // draw the perm's sound_data instance name dest.x = 4; DCrDraw_String( @@ -2797,28 +2797,28 @@ OWiSGP_HandleDrawItem( SSrPermutation_GetName(perm), &inDrawItem->rect, &dest); - + // draw the perm's weight dest.x = 160; sprintf(string, "%d", perm->weight); DCrDraw_String(inDrawItem->draw_context, string, &inDrawItem->rect, &dest); - - // draw the perm's min_volume_percent + + // draw the perm's min_volume_percent dest.x = 200; sprintf(string, "%1.2f", perm->min_volume_percent); DCrDraw_String(inDrawItem->draw_context, string, &inDrawItem->rect, &dest); - - // draw the perm's max_volume_percent + + // draw the perm's max_volume_percent dest.x = 230; sprintf(string, "%1.2f", perm->max_volume_percent); DCrDraw_String(inDrawItem->draw_context, string, &inDrawItem->rect, &dest); - - // draw the perm's min_pitch_percent + + // draw the perm's min_pitch_percent dest.x = 265; sprintf(string, "%1.2f", perm->min_pitch_percent); DCrDraw_String(inDrawItem->draw_context, string, &inDrawItem->rect, &dest); - - // draw the perm's max_volume_percent + + // draw the perm's max_volume_percent dest.x = 295; sprintf(string, "%1.2f", perm->max_pitch_percent); DCrDraw_String(inDrawItem->draw_context, string, &inDrawItem->rect, &dest); @@ -2833,32 +2833,32 @@ OWiSGP_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiSGP_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiSGP_HandleDestroy(inDialog); break; - + case WMcMessage_Command: OWiSGP_HandleCommand(inDialog, (WMtWindow*)inParam2, inParam1); break; - + case WMcMessage_DrawItem: - OWiSGP_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); + OWiSGP_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -2878,24 +2878,24 @@ OWiEditGroup( BFtFileRef *start_ref; BFtFileRef *parent_dir_ref; OWtGroupProp gp; - + // get the parent directory of the sound error = OSrGetSoundBinaryDirectory(&start_ref); if (error != UUcError_None) { goto error; } - + error = OSrGetSoundFileRef(inGroup->group_name, OScGroupSuffix, start_ref, &file_ref); if (error != UUcError_None) { goto error; } - + error = BFrFileRef_GetParentDirectory(file_ref, &parent_dir_ref); if (error != UUcError_None) { goto error; } - + // set up the group properties UUrMemory_Clear(&gp, sizeof(OWtGroupProp)); gp.parent_dir_ref = parent_dir_ref; gp.group = inGroup; - + if (gp.parent_dir_ref == NULL) { goto error; } - + // edit the group error = WMrDialog_ModalBegin( @@ -2912,13 +2912,13 @@ OWiEditGroup( BFrFileRef_Dispose(start_ref); start_ref = NULL; } - + if (file_ref) { BFrFileRef_Dispose(file_ref); file_ref = NULL; } - + if (gp.parent_dir_ref != NULL) { BFrFileRef_Dispose(gp.parent_dir_ref); @@ -2926,20 +2926,20 @@ OWiEditGroup( } return; - + error: if (start_ref) { BFrFileRef_Dispose(start_ref); start_ref = NULL; } - + if (file_ref) { BFrFileRef_Dispose(file_ref); file_ref = NULL; } - + if (gp.parent_dir_ref != NULL) { BFrFileRef_Dispose(gp.parent_dir_ref); @@ -2969,11 +2969,11 @@ OWiISP_EnableButtons( char name[SScMaxNameLength]; SStImpulse *found_impulse; UUtBool no_name_conflict; - + // determine if there is a name conflict editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_Name); WMrEditField_GetText(editfield, name, SScMaxNameLength); - + found_impulse = OSrImpulse_GetByName(name); if (name[0] == '\0') { @@ -2987,16 +2987,16 @@ OWiISP_EnableButtons( { no_name_conflict = UUcFalse; } - + button = WMrDialog_GetItemByID(inDialog, OWcISP_Btn_Edit); WMrWindow_SetEnabled(button, (inIP->ti.impulse_group != NULL)); - + button = WMrDialog_GetItemByID(inDialog, OWcISP_Btn_Play); WMrWindow_SetEnabled(button, (inIP->ti.impulse_group != NULL)); button = WMrDialog_GetItemByID(inDialog, OWcISP_Btn_Save); WMrWindow_SetEnabled(button, inIP->can_save && no_name_conflict); - + button = WMrDialog_GetItemByID(inDialog, OWcISP_Btn_EditImpulse); WMrWindow_SetEnabled(button, (inIP->ti.alt_impulse != NULL)); } @@ -3011,15 +3011,15 @@ OWiISP_RecordData( WMtWindow *popup; UUtUns16 priority; char name[SScMaxNameLength]; - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_Name); WMrEditField_GetText(editfield, name, SScMaxNameLength); UUrString_Copy(inIP->ti.impulse_name, name, SScMaxNameLength); - + popup = WMrDialog_GetItemByID(inDialog, OWcISP_PM_Priority); WMrPopupMenu_GetItemID(popup, -1, &priority); inIP->ti.priority = (SStPriority2)priority; - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MinVolDist); inIP->ti.min_volume_distance = WMrEditField_GetFloat(editfield); @@ -3028,19 +3028,19 @@ OWiISP_RecordData( editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MaxVolAngle); inIP->ti.max_volume_angle = WMrEditField_GetFloat(editfield); - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MinVolAngle); inIP->ti.min_volume_angle = WMrEditField_GetFloat(editfield); - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MinAngleAttn); inIP->ti.min_angle_attenuation = WMrEditField_GetFloat(editfield); - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_ImpactVelocity); inIP->ti.impact_velocity = WMrEditField_GetFloat(editfield); - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MinOcclusion); inIP->ti.min_occlusion = WMrEditField_GetFloat(editfield); - + if (inIP->ti.impulse_group) { UUrString_Copy( @@ -3052,7 +3052,7 @@ OWiISP_RecordData( { UUrMemory_Clear(inIP->ti.impulse_group_name, SScMaxNameLength); } - + if (inIP->ti.alt_impulse) { UUrString_Copy( @@ -3064,7 +3064,7 @@ OWiISP_RecordData( { UUrMemory_Clear(inIP->ti.alt_impulse_name, SScMaxNameLength); } - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_Threshold); inIP->ti.alt_threshold = (UUtUns32)WMrEditField_GetInt32(editfield); } @@ -3079,11 +3079,11 @@ OWiISP_Save( WMtWindow *editfield; char name[SScMaxNameLength]; SStImpulse *found_impulse; - + // make sure the sound has a name editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_Name); WMrEditField_GetText(editfield, name, SScMaxNameLength); - + if (strlen(name) == 0) { WMrDialog_MessageBox( @@ -3093,7 +3093,7 @@ OWiISP_Save( WMcMessageBoxStyle_OK); return UUcFalse; } - + OSrMakeGoodName(name, name); if (inIP->impulse == NULL) @@ -3108,7 +3108,7 @@ OWiISP_Save( WMcMessageBoxStyle_OK); return UUcFalse; } - + error = OSrImpulse_New(name, &inIP->impulse); if (error != UUcError_None) { @@ -3138,10 +3138,10 @@ OWiISP_Save( } } } - + // record the data OWiISP_RecordData(inDialog, inIP); - + if (inIP->ti.min_volume_distance < inIP->ti.max_volume_distance) { WMrDialog_MessageBox( @@ -3151,7 +3151,7 @@ OWiISP_Save( WMcMessageBoxStyle_OK); return UUcFalse; } - + // set the data for the impulse sound inIP->impulse->impulse_group = inIP->ti.impulse_group; inIP->impulse->priority = inIP->ti.priority; @@ -3164,15 +3164,15 @@ OWiISP_Save( inIP->impulse->alt_impulse = inIP->ti.alt_impulse; inIP->impulse->impact_velocity = inIP->ti.impact_velocity; inIP->impulse->min_occlusion = inIP->ti.min_occlusion; - + if (inIP->impulse->impulse_group) { UUrString_Copy( inIP->impulse->impulse_group_name, - inIP->impulse->impulse_group->group_name, + inIP->impulse->impulse_group->group_name, SScMaxNameLength); } - + if (inIP->impulse->alt_impulse) { UUrString_Copy( @@ -3180,7 +3180,7 @@ OWiISP_Save( inIP->impulse->alt_impulse->impulse_name, SScMaxNameLength); } - + // save the impulse sound to disk OSrImpulse_Save(inIP->impulse, inIP->parent_dir_ref); @@ -3196,18 +3196,18 @@ OWiISP_SetFields( WMtWindow *editfield; WMtWindow *text; WMtWindow *popup; - + if (inIP->impulse) { editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_Name); WMrEditField_SetText(editfield, inIP->impulse->impulse_name); } - + text = WMrDialog_GetItemByID(inDialog, OWcISP_Txt_Group); WMrWindow_SetTitle(text, inIP->ti.impulse_group_name, SScMaxNameLength); if (inIP->ti.impulse_group) { WMrText_SetShade(text, IMcShade_Black); } else { WMrText_SetShade(text, IMcShade_Red); } - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MaxVolDist); WMrEditField_SetFloat(editfield, inIP->ti.max_volume_distance); @@ -3222,21 +3222,21 @@ OWiISP_SetFields( editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MinAngleAttn); WMrEditField_SetFloat(editfield, inIP->ti.min_angle_attenuation); - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_ImpactVelocity); WMrEditField_SetFloat(editfield, inIP->ti.impact_velocity); - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MinOcclusion); WMrEditField_SetFloat(editfield, inIP->ti.min_occlusion); - + popup = WMrDialog_GetItemByID(inDialog, OWcISP_PM_Priority); WMrPopupMenu_SetSelection(popup, inIP->ti.priority); - + text = WMrDialog_GetItemByID(inDialog, OWcISP_Txt_AltImpulse); WMrWindow_SetTitle(text, inIP->ti.alt_impulse_name, SScMaxNameLength); if (inIP->ti.alt_impulse_name) { WMrText_SetShade(text, IMcShade_Black); } else { WMrText_SetShade(text, IMcShade_Red); } - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_Threshold); WMrEditField_SetInt32(editfield, inIP->ti.alt_threshold); } @@ -3249,7 +3249,7 @@ OWiISP_InitDialog( UUtError error; OWtImpulseProp *ip; WMtWindow *editfield; - + // get the impulse properties ip = (OWtImpulseProp*)WMrDialog_GetUserData(inDialog); if (ip == NULL) @@ -3257,7 +3257,7 @@ OWiISP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcISP_Btn_Cancel); return; } - + // initialize the impulse properties if (ip->impulse == NULL) { @@ -3266,21 +3266,21 @@ OWiISP_InitDialog( ip->ti.impulse_group = NULL; ip->ti.priority = SScPriority2_Normal; - + ip->ti.max_volume_distance = 10.0f; ip->ti.min_volume_distance = 50.0f; - + ip->ti.min_volume_angle = 360.0f; ip->ti.max_volume_angle = 360.0f; ip->ti.min_angle_attenuation = 0.0f; - + ip->ti.alt_threshold = 0; ip->ti.alt_impulse = NULL; UUrMemory_Clear(ip->ti.alt_impulse_name, SScMaxNameLength); - + ip->ti.impact_velocity = 0.0f; ip->ti.min_occlusion = 0.0f; - + if ((ip->parent_dir_ref != NULL) && (BFrFileRef_FileExists(ip->parent_dir_ref) == UUcTrue)) { @@ -3292,31 +3292,31 @@ OWiISP_InitDialog( UUrString_Copy(ip->ti.impulse_name, ip->impulse->impulse_name, SScMaxNameLength); UUrString_Copy(ip->ti.impulse_group_name, ip->impulse->impulse_group_name, SScMaxNameLength); ip->ti.impulse_group = ip->impulse->impulse_group; - + ip->ti.priority = ip->impulse->priority; - + ip->ti.max_volume_distance = ip->impulse->max_volume_distance; ip->ti.min_volume_distance = ip->impulse->min_volume_distance; - + ip->ti.min_volume_angle = ip->impulse->min_volume_angle; ip->ti.max_volume_angle = ip->impulse->max_volume_angle; ip->ti.min_angle_attenuation = ip->impulse->min_angle_attenuation; - + ip->ti.alt_threshold = ip->impulse->alt_threshold; ip->ti.alt_impulse = ip->impulse->alt_impulse; UUrString_Copy(ip->ti.alt_impulse_name, ip->impulse->alt_impulse_name, SScMaxNameLength); - + ip->ti.impact_velocity = ip->impulse->impact_velocity; ip->ti.min_occlusion = ip->impulse->min_occlusion; - + // does the impulse sound have a file ref if (ip->parent_dir_ref != NULL) { BFtFileRef *dir_ref; char name[SScMaxNameLength]; - + sprintf(name, "%s.%s", ip->impulse->impulse_name, OScImpulseSuffix); - + error = BFrFileRef_DuplicateAndAppendName( ip->parent_dir_ref, @@ -3328,13 +3328,13 @@ OWiISP_InitDialog( { ip->can_save = UUcTrue; } - + UUrMemory_Block_Delete(dir_ref); dir_ref = NULL; } } } - + // set the maximum number of characters for the impulse name editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_Name); WMrMessage_Send( @@ -3342,23 +3342,23 @@ OWiISP_InitDialog( EFcMessage_SetMaxChars, BFcMaxFileNameLength - strlen(".abc"), 0); - + // set the fields OWiISP_SetFields(inDialog, ip); - + // enable the buttons OWiISP_EnableButtons(inDialog, ip); - + // disable the angle fields editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MinVolAngle); WMrWindow_SetEnabled(editfield, UUcFalse); - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MaxVolAngle); WMrWindow_SetEnabled(editfield, UUcFalse); - + editfield = WMrDialog_GetItemByID(inDialog, OWcISP_EF_MinAngleAttn); WMrWindow_SetEnabled(editfield, UUcFalse); - + // set the focus to the name WMrWindow_SetFocus(WMrDialog_GetItemByID(inDialog, OWcISP_EF_Name)); } @@ -3377,37 +3377,37 @@ OWiISP_HandleCommand( SStImpulse *impulse; UUtBool update_fields; OWtSelectResult result; - + ip = (OWtImpulseProp*)WMrDialog_GetUserData(inDialog); - + update_fields = UUcTrue; control_id = UUmLowWord(inParam); command_type = UUmHighWord(inParam); - + switch (control_id) { case OWcISP_EF_Name: if (command_type != EFcNotify_ContentChanged) { break; } - + // if the impulse sound was locked, then the can_save bool // is null. If the name changes, then the user wants to make // a new impulse sound so allow this by setting the impulse to // null and setting can_save to UUcTrue - if (ip->can_save == UUcFalse) + if (ip->can_save == UUcFalse) { ip->impulse = NULL; ip->can_save = UUcTrue; } update_fields = UUcFalse; break; - + case OWcISP_Btn_Set: if (command_type != WMcNotify_Click) { break; } result = OWrSelect_SoundGroup(&group); if (result == OWcSelectResult_Cancel) { break; } ip->ti.impulse_group = group; - + if (ip->ti.impulse_group != NULL) { UUrString_Copy( @@ -3420,24 +3420,24 @@ OWiISP_HandleCommand( UUrMemory_Clear(ip->ti.impulse_group_name, SScMaxNameLength); } break; - + case OWcISP_Btn_Edit: if (command_type != WMcNotify_Click) { break; } OWiEditGroup(inDialog, ip->ti.impulse_group); break; - + case OWcISP_Btn_Play: if (command_type != WMcNotify_Click) { break; } if (ip->ti.impulse_group) { M3tPoint3D position; float volume; - + OWiISP_RecordData(inDialog, ip); - + MUmVector_Set(position, 1.0f, 0.0f, 0.0f); SSrListener_SetPosition(&position, &position); - + MUmVector_Set(position, 0.0f, 0.0f, 1.0f); volume = 1.0f; @@ -3449,16 +3449,16 @@ OWiISP_HandleCommand( &volume); } break; - + case OWcISP_Btn_SetImpulse: { OWtSelectResult result; - + if (command_type != WMcNotify_Click) { break; } result = OWrSelect_ImpulseSound(&impulse); if (result == OWcSelectResult_Cancel) { break; } ip->ti.alt_impulse = impulse; - + if (ip->ti.alt_impulse != NULL) { UUrString_Copy( @@ -3472,17 +3472,17 @@ OWiISP_HandleCommand( } } break; - + case OWcISP_Btn_EditImpulse: if (command_type != WMcNotify_Click) { break; } OWiEditImpulse(inDialog, ip->ti.alt_impulse); break; - + case OWcISP_Btn_Cancel: if (command_type != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, OWcISP_Btn_Cancel); break; - + case OWcISP_Btn_Save: if (command_type != WMcNotify_Click) { break; } if (OWiISP_Save(inDialog, ip) == UUcTrue) @@ -3490,17 +3490,17 @@ OWiISP_HandleCommand( WMrDialog_ModalEnd(inDialog, OWcISP_Btn_Save); } break; - + default: update_fields = UUcFalse; break; } - + if (update_fields) { OWiISP_SetFields(inDialog, ip); } - + // update the buttons OWiISP_EnableButtons(inDialog, ip); } @@ -3514,24 +3514,24 @@ OWiISP_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiISP_InitDialog(inDialog); break; - + case WMcMessage_Command: OWiISP_HandleCommand(inDialog, (WMtWindow*)inParam2, inParam1); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -3545,16 +3545,16 @@ OWrImpulseProperties_Display( OWtImpulseProp ip; BFtFileRef *file_ref; BFtFileRef *dir_ref; - + UUmAssert(inImpulse); - + dir_ref = NULL; file_ref = NULL; - + // get the sound binary directory error = OSrGetSoundBinaryDirectory(&dir_ref); if (error != UUcError_None) { goto error; } - + // get the file ref of the sound error = OSrGetSoundFileRef( @@ -3563,24 +3563,24 @@ OWrImpulseProperties_Display( dir_ref, &file_ref); if (error != UUcError_None) { goto error; } - + // dispose of the sound binary directory ref BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + // get the parent directory of the sound error = BFrFileRef_GetParentDirectory(file_ref, &dir_ref); if (error != UUcError_None) { goto error; } - + // dispose of the file ref of the sound BFrFileRef_Dispose(file_ref); file_ref = NULL; - + // set up the properties UUrMemory_Clear(&ip, sizeof(OWtImpulseProp)); ip.parent_dir_ref = dir_ref; ip.impulse = inImpulse; - + // edit the sound error = WMrDialog_ModalBegin( @@ -3590,28 +3590,28 @@ OWrImpulseProperties_Display( (UUtUns32)&ip, NULL); if (error != UUcError_None) { goto error; } - + // dispose of the parent directory of the sound BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + return UUcError_None; - + error: if (dir_ref) { BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } - + if (file_ref) { BFrFileRef_Dispose(file_ref); file_ref = NULL; } - + return error; -} +} // ====================================================================== #if 0 @@ -3629,24 +3629,24 @@ OWiEditImpulse( BFtFileRef *start_ref; BFtFileRef *parent_dir_ref; OWtImpulseProp ip; - + // get the parent directory of the sound error = OSrGetSoundBinaryDirectory(&start_ref); if (error != UUcError_None) { goto error; } - + error = OSrGetSoundFileRef(inImpulse->impulse_name, OScImpulseSuffix, start_ref, &file_ref); if (error != UUcError_None) { goto error; } - + error = BFrFileRef_GetParentDirectory(file_ref, &parent_dir_ref); if (error != UUcError_None) { goto error; } - + // set up the impulse properties UUrMemory_Clear(&ip, sizeof(OWtImpulseProp)); ip.parent_dir_ref = parent_dir_ref; ip.impulse = inImpulse; - + if (ip.parent_dir_ref == NULL) { goto error; } - + // edit the impulse error = WMrDialog_ModalBegin( @@ -3663,13 +3663,13 @@ OWiEditImpulse( BFrFileRef_Dispose(start_ref); start_ref = NULL; } - + if (file_ref) { BFrFileRef_Dispose(file_ref); file_ref = NULL; } - + if (ip.parent_dir_ref != NULL) { BFrFileRef_Dispose(ip.parent_dir_ref); @@ -3677,20 +3677,20 @@ OWiEditImpulse( } return; - + error: if (start_ref) { BFrFileRef_Dispose(start_ref); start_ref = NULL; } - + if (file_ref) { BFrFileRef_Dispose(file_ref); file_ref = NULL; } - + if (ip.parent_dir_ref != NULL) { BFrFileRef_Dispose(ip.parent_dir_ref); @@ -3718,10 +3718,10 @@ OWiListDirectory( { UUtError error; BFtFileIterator *file_iterator; - + // reset the listbox WMrListBox_Reset(inListBox); - + // create a file iterator error = BFrDirectory_FileIterator_New( @@ -3730,7 +3730,7 @@ OWiListDirectory( NULL, &file_iterator); UUmError_ReturnOnError(error); - + // fill in the listbox while (1) { @@ -3738,32 +3738,32 @@ OWiListDirectory( char name[BFcMaxFileNameLength]; UUtUns32 index; UUtBool is_dir; - + // get the next file or dir ref error = BFrDirectory_FileIterator_Next(file_iterator, &ref); if (error != UUcError_None) { break; } - + // find out if this ref is a directory is_dir = BFrFileRef_IsDirectory(&ref); - + if ((!is_dir) && (UUrString_Compare_NoCase(inSuffix, BFrFileRef_GetSuffixName(&ref)) != 0)) { continue; } - + // add the file or dir to the listbox UUrString_Copy(name, BFrFileRef_GetLeafName(&ref), BFcMaxFileNameLength); UUrString_StripExtension(name); index = WMrListBox_AddString(inListBox, name); WMrListBox_SetItemData(inListBox, (UUtUns32)is_dir, index); } - + // delete the file iterator BFrDirectory_FileIterator_Delete(file_iterator); file_iterator = NULL; - + // set the selection to the first item in the list WMrListBox_SetSelection(inListBox, UUcTrue, 0); - + return UUcError_None; } @@ -3778,7 +3778,7 @@ OWiSetPopup( BFtFileRef *dir_ref; BFtFileRef *parent; UUtUns16 i; - + binary_sound_dir_ref = NULL; dir_ref = NULL; @@ -3791,11 +3791,11 @@ OWiSetPopup( WMrPopupMenu_Reset(inPopup); i = 0; - + while (1) { WMtMenuItemData item_data; - + // add the current directory name to the popup item_data.flags = WMcMenuItemFlag_Enabled; item_data.id = i++; @@ -3813,15 +3813,15 @@ OWiSetPopup( dir_ref = parent; parent = NULL; } - + WMrPopupMenu_SetSelection(inPopup, 0); - + BFrFileRef_Dispose(binary_sound_dir_ref); binary_sound_dir_ref = NULL; - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + return UUcError_None; } @@ -3842,7 +3842,7 @@ OWiSM_EnableButtons( UUtBool is_dir; UUtBool is_item; OWtSMData *sm_data; - + sm_data = (OWtSMData*)WMrDialog_GetUserData(inDialog); if (sm_data->dir_ref == NULL) { return; } @@ -3851,28 +3851,28 @@ OWiSM_EnableButtons( result = WMrListBox_GetItemData(listbox, selected_index); if (result == 0) { is_dir = UUcFalse; } else { is_dir = UUcTrue; } is_item = is_dir == UUcFalse; - + button = WMrDialog_GetItemByID(inDialog, OWcSM_Btn_EditItem); WMrWindow_SetEnabled(button, is_item); - + button = WMrDialog_GetItemByID(inDialog, OWcSM_Btn_DeleteItem); WMrWindow_SetEnabled(button, is_item); - + button = WMrDialog_GetItemByID(inDialog, OWcSM_Btn_PlayItem); if (button != NULL) { WMrWindow_SetEnabled(button, is_item); } - + button = WMrDialog_GetItemByID(inDialog, OWcSM_Btn_CopyItem); WMrWindow_SetEnabled(button, is_item); - + button = WMrDialog_GetItemByID(inDialog, OWcSM_Btn_PasteItem); WMrWindow_SetEnabled(button, sm_data->can_paste); - + button = WMrDialog_GetItemByID(inDialog, OWcSM_Btn_NewCategory); WMrWindow_SetEnabled(button, UUcTrue); button = WMrDialog_GetItemByID(inDialog, OWcSM_Btn_RenameCategory); WMrWindow_SetEnabled(button, UUcFalse); - + button = WMrDialog_GetItemByID(inDialog, OWcSM_Btn_DeleteCategory); WMrWindow_SetEnabled(button, UUcFalse); } @@ -3885,13 +3885,13 @@ OWiSM_GetDirectoryRef( UUtError error; BFtFileRef *out_ref; OWtSMData *sm_data; - + sm_data = (OWtSMData*)WMrDialog_GetUserData(inDialog); if (sm_data->dir_ref == NULL) { return NULL; } - + error = BFrFileRef_Duplicate(sm_data->dir_ref, &out_ref); if (error != UUcError_None) { return NULL; } - + return out_ref; } @@ -3901,10 +3901,10 @@ OWiSM_GetExtension( WMtDialog *inDialog) { OWtSMData *sm_data; - + sm_data = (OWtSMData*)WMrDialog_GetUserData(inDialog); UUmAssert(sm_data); - + return sm_data->extension; } @@ -3914,10 +3914,10 @@ OWiSM_GetType( WMtDialog *inDialog) { OWtSMData *sm_data; - + sm_data = (OWtSMData*)WMrDialog_GetUserData(inDialog); UUmAssert(sm_data); - + return sm_data->type; } @@ -3931,13 +3931,13 @@ OWiSM_SetDirectoryRef( BFtFileRef *old_ref; BFtFileRef *copy_ref; OWtSMData *sm_data; - + UUrMemory_Block_VerifyList(); - + // get the sound manipulator data sm_data = (OWtSMData*)WMrDialog_GetUserData(inDialog); UUmAssert(sm_data); - + // delete the old ref old_ref = sm_data->dir_ref; if (old_ref != NULL) @@ -3945,20 +3945,20 @@ OWiSM_SetDirectoryRef( BFrFileRef_Dispose(old_ref); old_ref = NULL; } - + if (inDirRef != NULL) { error = BFrFileRef_Duplicate(inDirRef, ©_ref); - if (error != UUcError_None) { copy_ref = NULL; } + if (error != UUcError_None) { copy_ref = NULL; } } else { copy_ref = NULL; } - + // set the new ref sm_data->dir_ref = copy_ref; - + error = OWiSetPopup(WMrDialog_GetItemByID(inDialog, OWcSM_PM_Category), copy_ref); UUrMemory_Block_VerifyList(); @@ -3974,35 +3974,35 @@ OWiSM_Category_Open( BFtFileRef *parent_dir_ref; BFtFileRef *open_dir_ref; char name[BFcMaxFileNameLength]; - + UUrMemory_Block_VerifyList(); - + parent_dir_ref = NULL; open_dir_ref = NULL; name[0] = '\0'; - + // get the parent dir ref parent_dir_ref = OWiSM_GetDirectoryRef(inDialog); if (parent_dir_ref == NULL) { return; } - + // make a dir ref for the directory being opened WMrListBox_GetText(inListBox, name, (UUtUns32)(-1)); error = BFrFileRef_DuplicateAndAppendName(parent_dir_ref, name, &open_dir_ref); if (error != UUcError_None) { goto cleanup; } - + // fill in the listbox error = OWiListDirectory(inListBox, open_dir_ref, OWiSM_GetExtension(inDialog)); if (error != UUcError_None) { goto cleanup; } - + OWiSM_SetDirectoryRef(inDialog, open_dir_ref); - + cleanup: if (parent_dir_ref != NULL) { BFrFileRef_Dispose(parent_dir_ref); parent_dir_ref = NULL; } - + if (open_dir_ref != NULL) { BFrFileRef_Dispose(open_dir_ref); @@ -4023,11 +4023,11 @@ OWiSM_Category_New( BFtFileRef *new_dir_ref; char name[BFcMaxFileNameLength]; char *error_string; - + parent_dir_ref = NULL; new_dir_ref = NULL; error_string = "Unable to create the category."; - + // get the name of the category UUrMemory_Clear(name, BFcMaxFileNameLength); error = @@ -4038,25 +4038,25 @@ OWiSM_Category_New( (UUtUns32)name, &message); if ((error != UUcError_None) || (message == OWcCN_Btn_Cancel)) { return; } - + // get the directory to place the category in parent_dir_ref = OWiSM_GetDirectoryRef(inDialog); - + // get a file ref for the directory error = BFrFileRef_DuplicateAndAppendName(parent_dir_ref, name, &new_dir_ref); if (error != UUcError_None) { goto error; } - + // see if this directory already exists if (BFrFileRef_FileExists(new_dir_ref) == UUcTrue) { error_string = "A category with this name already exists."; goto error; } - + // create the category as a directory on disk error = BFrDirectory_Create(new_dir_ref, NULL); if (error != UUcError_None) { goto error; } - + // set the directory as the focus OWiSM_SetDirectoryRef(inDialog, new_dir_ref); OWiListDirectory( @@ -4064,29 +4064,29 @@ OWiSM_Category_New( new_dir_ref, OWiSM_GetExtension(inDialog)); OWiSM_EnableButtons(inDialog); - + // cleanup BFrFileRef_Dispose(parent_dir_ref); parent_dir_ref = NULL; - + BFrFileRef_Dispose(new_dir_ref); new_dir_ref = NULL; - + return; - + error: if (parent_dir_ref != NULL) { BFrFileRef_Dispose(parent_dir_ref); parent_dir_ref = NULL; } - + if (new_dir_ref != NULL) { BFrFileRef_Dispose(new_dir_ref); new_dir_ref = NULL; } - + WMrDialog_MessageBox( inDialog, "Error", @@ -4101,7 +4101,7 @@ OWiSM_Category_Delete_Contents( { UUtError error; BFtFileIterator *file_iterator; - + error = BFrDirectory_FileIterator_New( inDirRef, @@ -4109,26 +4109,26 @@ OWiSM_Category_Delete_Contents( NULL, &file_iterator); if (error != UUcError_None) { return; } - + while (1) { BFtFileRef file_ref; char name[BFcMaxFileNameLength]; char ext[BFcMaxFileNameLength]; - + error = BFrDirectory_FileIterator_Next(file_iterator, &file_ref); if (error != UUcError_None) { break; } - + if (BFrFileRef_IsDirectory(&file_ref) == UUcTrue) { OWiSM_Category_Delete_Contents(&file_ref); continue; } - + UUrString_Copy(name, BFrFileRef_GetLeafName(&file_ref), BFcMaxFileNameLength); UUrString_Copy(ext, strrchr(name, '.'), BFcMaxFileNameLength); UUrString_StripExtension(name); - + if (UUrString_Compare_NoCase(ext, ".amb") == 0) { OSrAmbient_Delete(name); @@ -4142,7 +4142,7 @@ OWiSM_Category_Delete_Contents( OSrGroup_Delete(name); } } - + BFrDirectory_FileIterator_Delete(file_iterator); file_iterator = NULL; } @@ -4161,7 +4161,7 @@ OWiSM_Category_Delete( parent_dir_ref = NULL; delete_dir_ref = NULL; - + // make sure the user is aware of what is about to happen result = WMrDialog_MessageBox( @@ -4170,26 +4170,26 @@ OWiSM_Category_Delete( "Are you sure you want to delete the category, and all its contents?", WMcMessageBoxStyle_Yes_No); if (result == WMcDialogItem_No) { return; } - + // get the directory to delete the category from parent_dir_ref = OWiSM_GetDirectoryRef(inDialog); - + // get the name of the category listbox = WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items); WMrListBox_GetText(listbox, name, (UUtUns32)(-1)); - + // create a ref error = BFrFileRef_DuplicateAndAppendName(parent_dir_ref, name, &delete_dir_ref); if (error != UUcError_None) { goto error; } - - // delete the .amb, .imp, and .grp sounds seperately in order to + + // delete the .amb, .imp, and .grp sounds seperately in order to // update other systems that may use them. // OWiSM_Category_Delete_Contents(delete_dir_ref); - + // delete the directory and any remaining contents error = BFrDirectory_DeleteDirectoryAndContents(delete_dir_ref); if (error != UUcError_None) { goto error; } - + // set the directory as the focus OWiSM_SetDirectoryRef(inDialog, parent_dir_ref); OWiListDirectory( @@ -4197,29 +4197,29 @@ OWiSM_Category_Delete( parent_dir_ref, OWiSM_GetExtension(inDialog)); OWiSM_EnableButtons(inDialog); - + // cleanup BFrFileRef_Dispose(parent_dir_ref); parent_dir_ref = NULL; - + BFrFileRef_Dispose(delete_dir_ref); delete_dir_ref = NULL; - + return; - + error: if (parent_dir_ref != NULL) { BFrFileRef_Dispose(parent_dir_ref); parent_dir_ref = NULL; } - + if (delete_dir_ref != NULL) { BFrFileRef_Dispose(delete_dir_ref); delete_dir_ref = NULL; } - + WMrDialog_MessageBox( inDialog, "Error", @@ -4235,10 +4235,10 @@ OWiSM_Item_Copy( OWtSMData *sm_data; WMtWindow *listbox; char selected_name[BFcMaxFileNameLength]; - + sm_data = (OWtSMData*)WMrDialog_GetUserData(inDialog); if (sm_data->dir_ref == NULL) { return; } - + // get the name of the selected item the user wants to delete listbox = WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items); WMrListBox_GetText(listbox, selected_name, (UUtUns32)(-1)); @@ -4248,37 +4248,37 @@ OWiSM_Item_Copy( case OWcSMType_Ambient: { SStAmbient *ambient; - + ambient = SSrAmbient_GetByName(selected_name); - + UUrMemory_MoveFast(ambient, &sm_data->u.ambient, sizeof(SStAmbient)); UUrMemory_Clear(&sm_data->u.ambient.ambient_name, SScMaxNameLength); } break; - + case OWcSMType_Group: { SStGroup *group; - + group = SSrGroup_GetByName(selected_name); - + UUrMemory_MoveFast(group, &sm_data->u.group, sizeof(SStGroup)); UUrMemory_Clear(&sm_data->u.group.group_name, SScMaxNameLength); } break; - + case OWcSMType_Impulse: { SStImpulse *impulse; - + impulse = SSrImpulse_GetByName(selected_name); - + UUrMemory_MoveFast(impulse, &sm_data->u.impulse, sizeof(SStImpulse)); UUrMemory_Clear(&sm_data->u.impulse.impulse_name, SScMaxNameLength); } break; } - + sm_data->can_paste = UUcTrue; } @@ -4307,24 +4307,24 @@ OWiSM_Item_Delete( parent_dir_ref = NULL; file_ref = NULL; - + // get the name of the selected item the user wants to delete listbox = WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items); WMrListBox_GetText(listbox, selected_name, (UUtUns32)(-1)); - + // get the parent directory parent_dir_ref = OWiSM_GetDirectoryRef(inDialog); if (parent_dir_ref == NULL) { goto error; } - + // delete the file file_ref = NULL; sprintf(file_name, "%s.%s", selected_name, OWiSM_GetExtension(inDialog)); error = BFrFileRef_DuplicateAndAppendName(parent_dir_ref, file_name, &file_ref); if (error != UUcError_None) { goto error; } - + error = BFrFile_Delete(file_ref); if (error != UUcError_None) { goto error; } - + UUrMemory_Block_VerifyList(); // delete the selected item @@ -4333,29 +4333,29 @@ UUrMemory_Block_VerifyList(); case OWcSMType_Ambient: OSrAmbient_Delete(selected_name); break; - + case OWcSMType_Group: OSrGroup_Delete(selected_name); break; - + case OWcSMType_Impulse: OSrImpulse_Delete(selected_name); break; } - + UUrMemory_Block_VerifyList(); // update the listbox OWiListDirectory(listbox, parent_dir_ref, OWiSM_GetExtension(inDialog)); OWiSM_EnableButtons(inDialog); - + // cleanup BFrFileRef_Dispose(parent_dir_ref); parent_dir_ref = NULL; BFrFileRef_Dispose(file_ref); file_ref = NULL; - + UUrMemory_Block_VerifyList(); return; @@ -4366,7 +4366,7 @@ UUrMemory_Block_VerifyList(); BFrFileRef_Dispose(parent_dir_ref); parent_dir_ref = NULL; } - + if ((file_ref != NULL) && (BFrFileRef_IsLocked(file_ref) == UUcTrue)) { error_string = "Unable to delete the item because the file is locked."; @@ -4397,22 +4397,22 @@ OWiSM_Item_Edit_Ambient( char name[BFcMaxFileNameLength]; UUtUns32 message; OWtAmbientProp ap; - + // get the name of the ambient sound the user wants to edit listbox = WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items); WMrListBox_GetText(listbox, name, (UUtUns32)(-1)); - + // get the ambient to edit ambient = OSrAmbient_GetByName(name); if (ambient == NULL) { return; } - + // set up the ambient properties UUrMemory_Clear(&ap, sizeof(OWtAmbientProp)); ap.parent_dir_ref = OWiSM_GetDirectoryRef(inDialog); ap.ambient = ambient; - + if (ap.parent_dir_ref == NULL) { goto error; } - + // edit the ambient error = WMrDialog_ModalBegin( @@ -4427,14 +4427,14 @@ OWiSM_Item_Edit_Ambient( OWiListDirectory(listbox, ap.parent_dir_ref, OWiSM_GetExtension(inDialog)); WMrListBox_SelectString(listbox, name); OWiSM_EnableButtons(inDialog); - + // cleanup if (ap.parent_dir_ref != NULL) { BFrFileRef_Dispose(ap.parent_dir_ref); ap.parent_dir_ref = NULL; } - + return; error: @@ -4456,22 +4456,22 @@ OWiSM_Item_Edit_Group( WMtWindow *listbox; SStGroup *group; char name[BFcMaxFileNameLength]; - + // get the name of the group the user wants to edit listbox = WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items); WMrListBox_GetText(listbox, name, (UUtUns32)(-1)); - + // get the group to edit group = OSrGroup_GetByName(name); if (group == NULL) { return; } - + // set up the group properties UUrMemory_Clear(&gp, sizeof(OWtGroupProp)); gp.parent_dir_ref = OWiSM_GetDirectoryRef(inDialog); gp.group = group; - + if (gp.parent_dir_ref == NULL) { goto error; } - + // edit the group error = WMrDialog_ModalBegin( @@ -4486,14 +4486,14 @@ OWiSM_Item_Edit_Group( OWiListDirectory(listbox, gp.parent_dir_ref, OScGroupSuffix); WMrListBox_SelectString(listbox, name); OWiSM_EnableButtons(inDialog); - + // cleanup if (gp.parent_dir_ref != NULL) { BFrFileRef_Dispose(gp.parent_dir_ref); gp.parent_dir_ref = NULL; } - + return; error: @@ -4515,22 +4515,22 @@ OWiSM_Item_Edit_Impulse( char name[BFcMaxFileNameLength]; UUtUns32 message; OWtImpulseProp ip; - + // get the name of the impulse sound the user wants to edit listbox = WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items); WMrListBox_GetText(listbox, name, (UUtUns32)(-1)); - + // get the impulse sound to edit impulse = OSrImpulse_GetByName(name); if (impulse == NULL) { return; } - + // set up the impulse properties UUrMemory_Clear(&ip, sizeof(OWtImpulseProp)); ip.parent_dir_ref = OWiSM_GetDirectoryRef(inDialog); ip.impulse = impulse; - + if (ip.parent_dir_ref == NULL) { goto error; } - + // edit the impulse sound error = WMrDialog_ModalBegin( @@ -4545,14 +4545,14 @@ OWiSM_Item_Edit_Impulse( OWiListDirectory(listbox, ip.parent_dir_ref, OWiSM_GetExtension(inDialog)); WMrListBox_SelectString(listbox, name); OWiSM_EnableButtons(inDialog); - + // cleanup if (ip.parent_dir_ref != NULL) { BFrFileRef_Dispose(ip.parent_dir_ref); ip.parent_dir_ref = NULL; } - + return; error: @@ -4573,11 +4573,11 @@ OWiSM_Item_Edit( case OWcSMType_Ambient: OWiSM_Item_Edit_Ambient(inDialog); break; - + case OWcSMType_Group: OWiSM_Item_Edit_Group(inDialog); break; - + case OWcSMType_Impulse: OWiSM_Item_Edit_Impulse(inDialog); break; @@ -4592,11 +4592,11 @@ OWiSM_Item_New_Ambient( UUtError error; UUtUns32 message; OWtAmbientProp ap; - + // set up the ambient sound properties ap.parent_dir_ref = OWiSM_GetDirectoryRef(inDialog); ap.ambient = NULL; - + if (ap.parent_dir_ref == NULL) { WMrDialog_MessageBox( @@ -4606,7 +4606,7 @@ OWiSM_Item_New_Ambient( WMcMessageBoxStyle_OK); return; } - + // create the ambient sound error = WMrDialog_ModalBegin( @@ -4622,25 +4622,25 @@ OWiSM_Item_New_Ambient( "Error", "Unable to create the new ambient sound", WMcMessageBoxStyle_OK); - + return; } - + if (message == OWcASP_Btn_Save) { WMtWindow *listbox; - + listbox = WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items); - + // fill in the listbox error = OWiListDirectory(listbox, ap.parent_dir_ref, OWiSM_GetExtension(inDialog)); if (error != UUcError_None) { return; } - + // select the new group WMrListBox_SelectString(listbox, ap.ambient->ambient_name); OWiSM_EnableButtons(inDialog); } - + if (ap.parent_dir_ref != NULL) { BFrFileRef_Dispose(ap.parent_dir_ref); @@ -4656,11 +4656,11 @@ OWiSM_Item_New_Group( UUtError error; UUtUns32 message; OWtGroupProp gp; - + // set up the group properties gp.parent_dir_ref = OWiSM_GetDirectoryRef(inDialog); gp.group = NULL; - + if (gp.parent_dir_ref == NULL) { WMrDialog_MessageBox( @@ -4670,7 +4670,7 @@ OWiSM_Item_New_Group( WMcMessageBoxStyle_OK); return; } - + // create the group error = WMrDialog_ModalBegin( @@ -4686,25 +4686,25 @@ OWiSM_Item_New_Group( "Error", "Unable to create the new group", WMcMessageBoxStyle_OK); - + return; } - + if (message == OWcSGP_Btn_Save) { WMtWindow *listbox; - + listbox = WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items); - + // fill in the listbox error = OWiListDirectory(listbox, gp.parent_dir_ref, OWiSM_GetExtension(inDialog)); if (error != UUcError_None) { return; } - + // select the new group WMrListBox_SelectString(listbox, gp.group->group_name); OWiSM_EnableButtons(inDialog); } - + if (gp.parent_dir_ref != NULL) { BFrFileRef_Dispose(gp.parent_dir_ref); @@ -4720,11 +4720,11 @@ OWiSM_Item_New_Impulse( UUtError error; UUtUns32 message; OWtImpulseProp ip; - + // set up the group properties ip.parent_dir_ref = OWiSM_GetDirectoryRef(inDialog); ip.impulse = NULL; - + if (ip.parent_dir_ref == NULL) { WMrDialog_MessageBox( @@ -4734,7 +4734,7 @@ OWiSM_Item_New_Impulse( WMcMessageBoxStyle_OK); return; } - + // create the impulse sound error = WMrDialog_ModalBegin( @@ -4750,25 +4750,25 @@ OWiSM_Item_New_Impulse( "Error", "Unable to create the new group", WMcMessageBoxStyle_OK); - + return; } - + if (message == OWcISP_Btn_Save) { WMtWindow *listbox; - + listbox = WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items); - + // fill in the listbox error = OWiListDirectory(listbox, ip.parent_dir_ref, OWiSM_GetExtension(inDialog)); if (error != UUcError_None) { return; } - + // select the new impulse sound WMrListBox_SelectString(listbox, ip.impulse->impulse_name); OWiSM_EnableButtons(inDialog); } - + if (ip.parent_dir_ref != NULL) { BFrFileRef_Dispose(ip.parent_dir_ref); @@ -4786,11 +4786,11 @@ OWiSM_Item_New( case OWcSMType_Ambient: OWiSM_Item_New_Ambient(inDialog); break; - + case OWcSMType_Group: OWiSM_Item_New_Group(inDialog); break; - + case OWcSMType_Impulse: OWiSM_Item_New_Impulse(inDialog); break; @@ -4809,35 +4809,35 @@ OWiSM_Item_Paste( BFtFileRef *dir_ref; char name[SScMaxNameLength]; WMtWindow *listbox; - + sm_data = (OWtSMData*)WMrDialog_GetUserData(inDialog); if (sm_data->dir_ref == NULL) { goto error; } - + dir_ref = OWiSM_GetDirectoryRef(inDialog); if (dir_ref == NULL) { goto error; } - + done = UUcFalse; i = 1; do { sprintf(name, "temp_%03d", i); - + switch (OWiSM_GetType(inDialog)) { case OWcSMType_Ambient: { SStAmbient *ambient; - + ambient = OSrAmbient_GetByName(name); if (ambient == NULL) { // create the new ambient sound error = OSrAmbient_New(name, &ambient); if (error != UUcError_None) { goto error; } - + // set all of the data for the ambient sound SSrAmbient_Copy(&sm_data->u.ambient, ambient); - + // save the new ambient sound OSrAmbient_Save(ambient, dir_ref); @@ -4845,21 +4845,21 @@ OWiSM_Item_Paste( } } break; - + case OWcSMType_Group: { SStGroup *group; - + group = OSrGroup_GetByName(name); if (group == NULL) { // create the new sound group error = OSrGroup_New(name, &group); if (error != UUcError_None) { goto error; } - + // set all of the data for the sound group SSrGroup_Copy(&sm_data->u.group, group); - + // save the new sound group OSrGroup_Save(group, dir_ref); @@ -4867,21 +4867,21 @@ OWiSM_Item_Paste( } } break; - + case OWcSMType_Impulse: { SStImpulse *impulse; - + impulse = OSrImpulse_GetByName(name); if (impulse == NULL) { // create the new impulse sound error = OSrImpulse_New(name, &impulse); if (error != UUcError_None) { goto error; } - + // set all of the data for the impulse sound SSrImpulse_Copy(&sm_data->u.impulse, impulse); - + // save the new impulse sound OSrImpulse_Save(impulse, dir_ref); @@ -4890,22 +4890,22 @@ OWiSM_Item_Paste( } break; } - + i++; } while (done == UUcFalse); - + // refresh the listbox and select the item that was just added listbox = WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items), OWiListDirectory(listbox, dir_ref, sm_data->extension); WMrListBox_SelectString(listbox, name); - + if (dir_ref) { BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } - + return; error: @@ -4914,7 +4914,7 @@ OWiSM_Item_Paste( BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } - + WMrDialog_MessageBox( inDialog, "Error", @@ -4933,41 +4933,41 @@ OWiSM_Item_Play( // get the name of the group the user wants to edit listbox = WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items); WMrListBox_GetText(listbox, name, (UUtUns32)(-1)); - + switch (OWiSM_GetType(inDialog)) { case OWcSMType_Ambient: break; - + case OWcSMType_Group: { SStGroup *group; - + // get the group to play group = OSrGroup_GetByName(name); if (group == NULL) { break; } - + // play the group SSrGroup_Play(group, NULL, NULL, NULL); } break; - + case OWcSMType_Impulse: { SStImpulse *impulse; M3tPoint3D position; float volume; - + // get the impulse to play impulse = OSrImpulse_GetByName(name); if ((impulse == NULL) || (impulse->impulse_group == NULL)) { break; } - + MUmVector_Set(position, 1.0f, 0.0f, 0.0f); SSrListener_SetPosition(&position, &position); - + MUmVector_Set(position, 0.0f, 0.0f, 1.0f); volume = 1.0f; - + SSrImpulse_Play( impulse, &position, @@ -4989,62 +4989,62 @@ OWiSM_InitDialog( OWtSMData *sm_data; OWtSMType type; BFtFileRef *dir_ref; - + // get the type type = (OWtSMType)WMrDialog_GetUserData(inDialog); - - // allocate memory for the + + // allocate memory for the sm_data = UUrMemory_Block_New(sizeof(OWtSMData)); if (sm_data == NULL) { WMrDialog_ModalEnd(inDialog, 0); return; } - + WMrDialog_SetUserData(inDialog, (UUtUns32)sm_data); - + // set up the sm_data sm_data->type = type; sm_data->dir_ref = NULL; sm_data->can_paste = UUcFalse; - + switch (sm_data->type) { case OWcSMType_Ambient: sm_data->extension = OScAmbientSuffix; break; - + case OWcSMType_Group: sm_data->extension = OScGroupSuffix; break; - + case OWcSMType_Impulse: sm_data->extension = OScImpulseSuffix; break; } - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items); if (listbox == NULL) { goto cleanup; } - + // get the directory ref error = OSrGetSoundBinaryDirectory(&dir_ref); if (error != UUcError_None) { goto cleanup; } - + // fill in the listbox error = OWiListDirectory(listbox, dir_ref, sm_data->extension); if (error != UUcError_None) { goto cleanup; } - + // set the directory ref OWiSM_SetDirectoryRef(inDialog, dir_ref); - + OWiSM_EnableButtons(inDialog); BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + return; - + cleanup: if (dir_ref) { @@ -5063,17 +5063,17 @@ OWiSM_HandleCommand( { UUtUns16 control_id; UUtUns16 command_type; - + control_id = UUmLowWord(inParam); command_type = UUmHighWord(inParam); - + switch (control_id) { case WMcDialogItem_Cancel: if (command_type != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, 0); break; - + case OWcSM_LB_Items: if (command_type == LBcNotify_SelectionChanged) { @@ -5082,7 +5082,7 @@ OWiSM_HandleCommand( else if (command_type == WMcNotify_DoubleClick) { UUtUns32 item_data; - + item_data = WMrListBox_GetItemData(inControl, (UUtUns32)(-1)); if (item_data != 0) { @@ -5096,48 +5096,48 @@ OWiSM_HandleCommand( } } break; - + case OWcSM_Btn_NewItem: if (command_type != WMcNotify_Click) { break; } OWiSM_Item_New(inDialog); break; - + case OWcSM_Btn_EditItem: if (command_type != WMcNotify_Click) { break; } OWiSM_Item_Edit(inDialog); break; - + case OWcSM_Btn_PlayItem: if (command_type != WMcNotify_Click) { break; } OWiSM_Item_Play(inDialog); break; - + case OWcSM_Btn_DeleteItem: if (command_type != WMcNotify_Click) { break; } OWiSM_Item_Delete(inDialog); break; - + case OWcSM_Btn_CopyItem: if (command_type != WMcNotify_Click) { break; } OWiSM_Item_Copy(inDialog); break; - + case OWcSM_Btn_PasteItem: if (command_type != WMcNotify_Click) { break; } OWiSM_Item_Paste(inDialog); break; - + case OWcSM_Btn_NewCategory: if (command_type != WMcNotify_Click) { break; } OWiSM_Category_New(inDialog); break; - + case OWcSM_Btn_DeleteCategory: if (command_type != WMcNotify_Click) { break; } OWiSM_Category_Delete(inDialog); break; } - + OWiSM_EnableButtons(inDialog); } @@ -5147,9 +5147,9 @@ OWiSM_HandleDestroy( WMtDialog *inDialog) { OWtSMData *sm_data; - + UUrMemory_Block_VerifyList(); - + sm_data = (OWtSMData*)WMrDialog_GetUserData(inDialog); if (sm_data) { @@ -5158,11 +5158,11 @@ OWiSM_HandleDestroy( BFrFileRef_Dispose(sm_data->dir_ref); sm_data->dir_ref = NULL; } - + UUrMemory_Block_Delete(sm_data); WMrDialog_SetUserData(inDialog, 0); } - + UUrMemory_Block_VerifyList(); } @@ -5176,35 +5176,35 @@ OWiSM_HandleMenuCommand( UUtUns32 i; BFtFileRef *dir_ref; UUtError error; - + // if inItemID == 0 then the popup menu is still on the same item // so no updating needs to be done if (inItemID == 0) { return; } - + // get the dir ref of the current item in the popup menu dir_ref = OWiSM_GetDirectoryRef(inDialog); if (dir_ref == NULL) { return; } - + // go up the hierarchy of directories until the desired directory is found for (i = 0; i < (UUtUns32)inItemID; i++) { BFtFileRef *parent_ref; - + error = BFrFileRef_GetParentDirectory(dir_ref, &parent_ref); if (error != UUcError_None) { return; } - + BFrFileRef_Dispose(dir_ref); dir_ref = parent_ref; } - + // fill in the listbox OWiListDirectory( WMrDialog_GetItemByID(inDialog, OWcSM_LB_Items), dir_ref, OWiSM_GetExtension(inDialog)); - + OWiSM_SetDirectoryRef(inDialog, dir_ref); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } @@ -5220,23 +5220,23 @@ OWiSM_HandleDrawItem( UUtInt16 line_width; UUtInt16 line_height; PStPartSpec *partspec; - + // get a pointer to the partspec_ui partspec_ui = PSrPartSpecUI_GetActive(); UUmAssert(partspec_ui); - + // set the dest dest.x = inDrawItem->rect.left; dest.y = inDrawItem->rect.top; - + // calc the width and height of the line line_width = inDrawItem->rect.right - inDrawItem->rect.left; line_height = inDrawItem->rect.bottom - inDrawItem->rect.top; - + // set the text destination dest.x += 2; dest.y += 1; - + // draw the text DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrText_SetStyle(TScStyle_Plain); @@ -5249,7 +5249,7 @@ OWiSM_HandleDrawItem( { partspec = partspec_ui->file; } - + // draw the icon DCrDraw_PartSpec( inDrawItem->draw_context, @@ -5259,7 +5259,7 @@ OWiSM_HandleDrawItem( (line_height - 3), (line_height - 3), M3cMaxAlpha); - + // draw the name dest.x += line_height + 2; DCrDraw_String( @@ -5278,39 +5278,39 @@ OWiSM_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiSM_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiSM_HandleDestroy(inDialog); break; - + case WMcMessage_Command: OWiSM_HandleCommand(inDialog, (WMtWindow*)inParam2, inParam1); break; - + case WMcMessage_MenuCommand: OWiSM_HandleMenuCommand( inDialog, (WMtWindow*)inParam2, UUmLowWord(inParam1)); break; - + case WMcMessage_DrawItem: OWiSM_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -5321,14 +5321,14 @@ OWrSM_Display( { UUtError error; WMtDialogID dialog_id; - + switch (inType) { case OWcSMType_Ambient: dialog_id = OWcDialog_Ambient_Sound_Manager; break; case OWcSMType_Group: dialog_id = OWcDialog_Sound_Group_Manager; break; case OWcSMType_Impulse: dialog_id = OWcDialog_Impulse_Sound_Manager; break; } - + error = WMrDialog_ModalBegin( dialog_id, @@ -5337,7 +5337,7 @@ OWrSM_Display( inType, NULL); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -5354,10 +5354,10 @@ OWiSS_EnableButtons( WMtWindow *button; WMtWindow *listbox; UUtUns32 item_data; - + button = WMrDialog_GetItemByID(inDialog, OWcSS_Btn_Select); WMrWindow_SetEnabled(button, UUcFalse); - + listbox = WMrDialog_GetItemByID(inDialog, OWcSS_LB_Items); item_data = WMrListBox_GetItemData(listbox, (UUtUns32)(-1)); if (item_data != 0) @@ -5378,13 +5378,13 @@ OWiSS_GetDirectoryRef( UUtError error; BFtFileRef *out_ref; OWtSelectData *sd; - + sd = (OWtSelectData*)WMrDialog_GetUserData(inDialog); if (sd->dir_ref == NULL) { return NULL; } - + error = BFrFileRef_Duplicate(sd->dir_ref, &out_ref); if (error != UUcError_None) { return NULL; } - + return out_ref; } @@ -5396,7 +5396,7 @@ OWiSS_GetExtension( OWtSelectData *sd; sd = (OWtSelectData*)WMrDialog_GetUserData(inDialog); - + return sd->extension; } @@ -5410,13 +5410,13 @@ OWiSS_SetDirectoryRef( BFtFileRef *old_ref; BFtFileRef *copy_ref; OWtSelectData *sd; - + UUrMemory_Block_VerifyList(); - + // get the select data sd = (OWtSelectData*)WMrDialog_GetUserData(inDialog); UUmAssert(sd); - + // delete the old ref old_ref = sd->dir_ref; if (old_ref != NULL) @@ -5424,20 +5424,20 @@ OWiSS_SetDirectoryRef( BFrFileRef_Dispose(old_ref); old_ref = NULL; } - + if (inDirRef != NULL) { error = BFrFileRef_Duplicate(inDirRef, ©_ref); - if (error != UUcError_None) { copy_ref = NULL; } + if (error != UUcError_None) { copy_ref = NULL; } } else { copy_ref = NULL; } - + // set the new ref sd->dir_ref = copy_ref; - + error = OWiSetPopup(WMrDialog_GetItemByID(inDialog, OWcSM_PM_Category), copy_ref); UUrMemory_Block_VerifyList(); @@ -5451,25 +5451,25 @@ OWiSS_SetSelection( WMtWindow *listbox; char name[BFcMaxFileNameLength]; OWtSelectData *sd; - + // get the select data sd = (OWtSelectData*)WMrDialog_GetUserData(inDialog); - + // get the name of the selected item listbox = WMrDialog_GetItemByID(inDialog, OWcSS_LB_Items); WMrListBox_GetText(listbox, name, (UUtUns32)(-1)); - + // display the selected item switch (sd->type) { case OWcSMType_Ambient: sd->u.ambient = OSrAmbient_GetByName(name); break; - + case OWcSMType_Group: sd->u.group = OSrGroup_GetByName(name); break; - + case OWcSMType_Impulse: sd->u.impulse = OSrImpulse_GetByName(name); break; @@ -5486,35 +5486,35 @@ OWiSS_Category_Open( BFtFileRef *parent_dir_ref; BFtFileRef *open_dir_ref; char name[BFcMaxFileNameLength]; - + UUrMemory_Block_VerifyList(); - + parent_dir_ref = NULL; open_dir_ref = NULL; name[0] = '\0'; - + // get the parent dir ref parent_dir_ref = OWiSS_GetDirectoryRef(inDialog); if (parent_dir_ref == NULL) { return; } - + // make a dir ref for the directory being opened WMrListBox_GetText(inListBox, name, (UUtUns32)(-1)); error = BFrFileRef_DuplicateAndAppendName(parent_dir_ref, name, &open_dir_ref); if (error != UUcError_None) { goto cleanup; } - + // fill in the listbox error = OWiListDirectory(inListBox, open_dir_ref, OWiSS_GetExtension(inDialog)); if (error != UUcError_None) { goto cleanup; } - + OWiSS_SetDirectoryRef(inDialog, open_dir_ref); - + cleanup: if (parent_dir_ref != NULL) { BFrFileRef_Dispose(parent_dir_ref); parent_dir_ref = NULL; } - + if (open_dir_ref != NULL) { BFrFileRef_Dispose(open_dir_ref); @@ -5533,10 +5533,10 @@ OWiSS_InitDialog( OWtSelectData *sd; BFtFileRef *dir_ref; WMtWindow *listbox; - + // get the select data sd = (OWtSelectData*)WMrDialog_GetUserData(inDialog); - + // get the directory ref if (OWgSelectSound_DirRef == NULL) { @@ -5548,30 +5548,30 @@ OWiSS_InitDialog( error = BFrFileRef_Duplicate(OWgSelectSound_DirRef, &dir_ref); if (error != UUcError_None) { goto cleanup; } } - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSS_LB_Items); if (listbox == NULL) { goto cleanup; } - + // fill in the listbox error = OWiListDirectory(listbox, dir_ref, sd->extension); if (error != UUcError_None) { goto cleanup; } // set the directory ref OWiSS_SetDirectoryRef(inDialog, dir_ref); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + return; - + cleanup: if (dir_ref) { BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } - + WMrDialog_ModalEnd(inDialog, OWcSS_Btn_Cancel); } @@ -5585,12 +5585,12 @@ OWiSS_HandleCommand( UUtUns16 control_id; UUtUns16 command_type; OWtSelectData *sd; - + sd = (OWtSelectData*)WMrDialog_GetUserData(inDialog); - + control_id = UUmLowWord(inParam); command_type = UUmHighWord(inParam); - + switch (control_id) { case OWcSS_LB_Items: @@ -5601,7 +5601,7 @@ OWiSS_HandleCommand( else if (command_type == WMcNotify_DoubleClick) { UUtUns32 item_data; - + item_data = WMrListBox_GetItemData(inControl, (UUtUns32)(-1)); if (item_data != 0) { @@ -5616,12 +5616,12 @@ OWiSS_HandleCommand( } } break; - + case OWcSS_Btn_None: if (command_type != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, OWcSS_Btn_None); break; - + case OWcSS_Btn_New: if (command_type != WMcNotify_Click) { break; } OWrSM_Display(sd->type); @@ -5630,12 +5630,12 @@ OWiSS_HandleCommand( sd->dir_ref, sd->extension); break; - + case OWcSS_Btn_Cancel: if (command_type != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, OWcSS_Btn_Cancel); break; - + case OWcSS_Btn_Select: if (command_type != WMcNotify_Click) { break; } OWiSS_SetSelection(inDialog); @@ -5650,7 +5650,7 @@ OWiSS_HandleDestroy( WMtDialog *inDialog) { OWtSelectData *sd; - + sd = (OWtSelectData*)WMrDialog_GetUserData(inDialog); if (sd) { @@ -5661,7 +5661,7 @@ OWiSS_HandleDestroy( BFrFileRef_Dispose(OWgSelectSound_DirRef); OWgSelectSound_DirRef = NULL; } - + OWgSelectSound_DirRef = sd->dir_ref; sd->dir_ref = NULL; } @@ -5678,35 +5678,35 @@ OWiSS_HandleMenuCommand( UUtUns32 i; BFtFileRef *dir_ref; UUtError error; - + // if inItemID == 0 then the popup menu is still on the same item // so no updating needs to be done if (inItemID == 0) { return; } - + // get the dir ref of the current item in the popup menu dir_ref = OWiSS_GetDirectoryRef(inDialog); if (dir_ref == NULL) { return; } - + // go up the hierarchy of directories until the desired directory is found for (i = 0; i < (UUtUns32)inItemID; i++) { BFtFileRef *parent_ref; - + error = BFrFileRef_GetParentDirectory(dir_ref, &parent_ref); if (error != UUcError_None) { return; } - + BFrFileRef_Dispose(dir_ref); dir_ref = parent_ref; } - + // fill in the listbox OWiListDirectory( WMrDialog_GetItemByID(inDialog, OWcSS_LB_Items), dir_ref, OWiSS_GetExtension(inDialog)); - + OWiSS_SetDirectoryRef(inDialog, dir_ref); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } @@ -5720,36 +5720,36 @@ OWiSS_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiSS_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiSS_HandleDestroy(inDialog); break; - + case WMcMessage_Command: OWiSS_HandleCommand(inDialog, (WMtWindow*)inParam2, inParam1); break; - + case WMcMessage_MenuCommand: OWiSS_HandleMenuCommand(inDialog, (WMtWindow*)inParam2, UUmLowWord(inParam1)); break; - + case WMcMessage_DrawItem: OWiSM_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -5762,14 +5762,14 @@ OWrSelect_AmbientSound( OWtSelectData sd; UUtUns32 message; OWtSelectResult result; - + sd.type = OWcSMType_Ambient; sd.dir_ref = NULL; sd.extension = OScAmbientSuffix; sd.u.ambient = NULL; - + result = OWcSelectResult_Cancel; - + error = WMrDialog_ModalBegin( OWcDialog_Select_Sound, @@ -5778,7 +5778,7 @@ OWrSelect_AmbientSound( (UUtUns32)&sd, &message); if (error != UUcError_None) { return result; } - + if (message == OWcSS_Btn_Select) { *outAmbient = sd.u.ambient; @@ -5794,7 +5794,7 @@ OWrSelect_AmbientSound( *outAmbient = NULL; result = OWcSelectResult_Cancel; } - + return result; } @@ -5807,12 +5807,12 @@ OWrSelect_SoundGroup( OWtSelectData sd; UUtUns32 message; OWtSelectResult result; - + sd.type = OWcSMType_Group; sd.dir_ref = NULL; sd.extension = OScGroupSuffix; sd.u.group = NULL; - + result = OWcSelectResult_Cancel; error = @@ -5823,7 +5823,7 @@ OWrSelect_SoundGroup( (UUtUns32)&sd, &message); if (error != UUcError_None) { return result; } - + if (message == OWcSS_Btn_Select) { *outGroup = sd.u.group; @@ -5839,7 +5839,7 @@ OWrSelect_SoundGroup( *outGroup = NULL; result = OWcSelectResult_Cancel; } - + return result; } @@ -5852,12 +5852,12 @@ OWrSelect_ImpulseSound( OWtSelectData sd; UUtUns32 message; OWtSelectResult result; - + sd.type = OWcSMType_Impulse; sd.dir_ref = NULL; sd.extension = OScImpulseSuffix; sd.u.impulse = NULL; - + result = OWcSelectResult_Cancel; error = @@ -5868,7 +5868,7 @@ OWrSelect_ImpulseSound( (UUtUns32)&sd, &message); if (error != UUcError_None) { return result; } - + if (message == OWcSS_Btn_Select) { *outImpulse = sd.u.impulse; @@ -5884,7 +5884,7 @@ OWrSelect_ImpulseSound( *outImpulse = NULL; result = OWcSelectResult_Cancel; } - + return result; } @@ -5904,28 +5904,28 @@ OWiViewAnimation_InitDialog( WMtWindow *listbox; UUtUns32 i; UUtRect rect; - + // set the window's position to the left hand side of the screen WMrWindow_GetRect(inDialog, &rect); WMrWindow_SetLocation(inDialog, 0, rect.top); - + // get a pointer to the user data sa = (OWtSA*)UUrMemory_Block_NewClear(sizeof(OWtSA)); UUmError_ReturnOnNull(sa); WMrDialog_SetUserData(inDialog, (UUtUns32)sa); - + sa->insert_from_index = 0; - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSA_LB_Animations); - + // get the number of animations sa->num_animations = TMrInstance_GetTagCount(TRcTemplate_Animation); if (sa->num_animations == 0) { return UUcError_Generic; } - + sa->animation_list = (TRtAnimation**)UUrMemory_Block_New(sizeof(TRtAnimation*) * sa->num_animations); if (sa->animation_list == NULL) { return UUcError_Generic; } - + // build the list of pointers to the animations error = TMrInstance_GetDataPtr_List( @@ -5935,20 +5935,20 @@ OWiViewAnimation_InitDialog( sa->animation_list); UUmError_ReturnOnError(error); UUmAssert(sa->num_animations == num_anims); - + // set the number of lines the listbox is going to have WMrMessage_Send(listbox, LBcMessage_SetNumLines, sa->num_animations, 0); - + // add lines to the dialog for (i = 0; i < sa->num_animations; i++) { WMrMessage_Send(listbox, LBcMessage_AddString, 0, 0); } WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcFalse, 0); - + // set the focus to the listbox WMrWindow_SetFocus(listbox); - + // disable the play button if there is no character if (ONrGameState_GetPlayerCharacter() == NULL) { @@ -5957,7 +5957,7 @@ OWiViewAnimation_InitDialog( button = WMrDialog_GetItemByID(inDialog, OWcVA_Btn_Play); WMrWindow_SetEnabled(button, UUcFalse); } - + return UUcError_None; } @@ -5967,7 +5967,7 @@ OWiViewAnimation_HandleDestroy( WMtDialog *inDialog) { OWtSA *sa; - + sa = (OWtSA*)WMrDialog_GetUserData(inDialog); if (sa != NULL) { @@ -5979,7 +5979,7 @@ OWiViewAnimation_HandleDestroy( UUrMemory_Block_Delete(sa); sa = NULL; } - + OWgViewAnimation = NULL; } @@ -5994,23 +5994,23 @@ OWiViewAnimation_HandlePlay( TRtAnimation *animation; ONtCharacter *player; ONtActiveCharacter *active_character; - + // get the index of tha animation from the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSA_LB_Animations); result = WMrMessage_Send(listbox, LBcMessage_GetSelection, 0, 0); if (result == LBcError) { return; } - + // make sure the animation exists animation = inSA->animation_list[result]; if (animation == NULL) { return; } - + // get the player's character player = ONrGameState_GetPlayerCharacter(); if (player == NULL) { return; } - + active_character = ONrForceActiveCharacter(player); if (active_character == NULL) { return; } - + // play the animation if (1) { @@ -6025,11 +6025,11 @@ OWiViewAnimation_HandlePlay( else { /* ONtOverlay overlay; - + overlay.animation = animation; overlay.frame = 0; overlay.flags = 0; - + ONrOverlay_Set( &overlay, player->animation, @@ -6045,9 +6045,9 @@ OWiViewAnimation_HandleCommand( UUtUns32 inParam2) { OWtSA *sa; - + sa = (OWtSA*)WMrDialog_GetUserData(inDialog); - + switch(UUmLowWord(inParam1)) { case OWcVA_LB_Animations: @@ -6060,7 +6060,7 @@ OWiViewAnimation_HandleCommand( case OWcVA_Btn_Play: OWiViewAnimation_HandlePlay(inDialog, sa); break; - + case OWcVA_Btn_Close: WMrWindow_Delete(inDialog); break; @@ -6084,21 +6084,21 @@ OWiViewAnimation_HandleDrawItem( // set the dest dest.x = inDrawItem->rect.left; dest.y = inDrawItem->rect.top; - + // calc the width and height of the line line_width = inDrawItem->rect.right - inDrawItem->rect.left; line_height = inDrawItem->rect.bottom - inDrawItem->rect.top; - + // draw the Text DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrText_SetStyle(TScStyle_Plain); DCrText_SetShade(IMcShade_Black); - + dest.x = 5; dest.y += 1; - + animation = sa->animation_list[inDrawItem->item_id]; - + DCrDraw_String( inDrawItem->draw_context, TMrInstance_GetInstanceName(animation), @@ -6116,9 +6116,9 @@ OWiViewAnimation_Callback( { UUtBool handled; UUtError error; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -6128,24 +6128,24 @@ OWiViewAnimation_Callback( WMrWindow_Delete(inDialog); } break; - + case WMcMessage_Destroy: OWiViewAnimation_HandleDestroy(inDialog); break; - + case WMcMessage_Command: OWiViewAnimation_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_DrawItem: OWiViewAnimation_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -6155,9 +6155,9 @@ OWrViewAnimation_Display( void) { UUtError error; - + if (OWgViewAnimation != NULL) { return; } - + error = WMrDialog_Create( OWcDialog_View_Animation, @@ -6184,25 +6184,25 @@ OWiSelectAnimation_InitDialog( WMtWindow *listbox; UUtUns32 i; UUtRect rect; - + // set the window's position to the left hand side of the screen WMrWindow_GetRect(inDialog, &rect); WMrWindow_SetLocation(inDialog, 0, rect.top); - + // get a pointer to the user data sa = (OWtSA*)WMrDialog_GetUserData(inDialog); sa->insert_from_index = 0; - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcSA_LB_Animations); - + // get the number of animations sa->num_animations = TMrInstance_GetTagCount(TRcTemplate_Animation); if (sa->num_animations == 0) { return UUcError_Generic; } - + sa->animation_list = (TRtAnimation**)UUrMemory_Block_New(sizeof(TRtAnimation*) * sa->num_animations); if (sa->animation_list == NULL) { return UUcError_Generic; } - + // build the list of pointers to the animations error = TMrInstance_GetDataPtr_List( @@ -6212,20 +6212,20 @@ OWiSelectAnimation_InitDialog( sa->animation_list); UUmError_ReturnOnError(error); UUmAssert(sa->num_animations == num_anims); - + // set the number of lines the listbox is going to have WMrMessage_Send(listbox, LBcMessage_SetNumLines, sa->num_animations, 0); - + // add lines to the dialog for (i = 0; i < sa->num_animations; i++) { WMrMessage_Send(listbox, LBcMessage_AddString, 0, 0); } WMrMessage_Send(listbox, LBcMessage_SetSelection, (UUtUns32)UUcFalse, 0); - + // set the focus to the listbox WMrWindow_SetFocus(listbox); - + return UUcError_None; } @@ -6235,9 +6235,9 @@ OWiSelectAnimation_HandleDestroy( WMtDialog *inDialog) { OWtSA *sa; - + sa = (OWtSA*)WMrDialog_GetUserData(inDialog); - + if (sa->animation_list != NULL) { UUrMemory_Block_Delete(sa->animation_list); @@ -6253,9 +6253,9 @@ OWiSelectAnimation_HandleSelect( { WMtWindow *listbox; UUtUns32 result; - + listbox = WMrDialog_GetItemByID(inDialog, OWcSA_LB_Animations); - + result = WMrMessage_Send(listbox, LBcMessage_GetSelection, 0, 0); if (result != LBcError) { @@ -6272,9 +6272,9 @@ OWiSelectAnimation_HandleCommand( UUtUns32 inParam2) { OWtSA *sa; - + sa = (OWtSA*)WMrDialog_GetUserData(inDialog); - + switch(UUmLowWord(inParam1)) { case OWcSA_LB_Animations: @@ -6283,16 +6283,16 @@ OWiSelectAnimation_HandleCommand( OWiSelectAnimation_HandleSelect(inDialog, sa); } break; - + case OWcSA_Btn_None: sa->animation = NULL; WMrDialog_ModalEnd(inDialog, OWcSA_Btn_None); break; - + case OWcSA_Btn_Cancel: WMrDialog_ModalEnd(inDialog, OWcSA_Btn_Cancel); break; - + case OWcSA_Btn_Select: OWiSelectAnimation_HandleSelect(inDialog, sa); break; @@ -6316,21 +6316,21 @@ OWiSelectAnimation_HandleDrawItem( // set the dest dest.x = inDrawItem->rect.left; dest.y = inDrawItem->rect.top; - + // calc the width and height of the line line_width = inDrawItem->rect.right - inDrawItem->rect.left; line_height = inDrawItem->rect.bottom - inDrawItem->rect.top; - + // draw the Text DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrText_SetStyle(TScStyle_Plain); DCrText_SetShade(IMcShade_Black); - + dest.x = 5; dest.y += 1; - + animation = sa->animation_list[inDrawItem->item_id]; - + DCrDraw_String( inDrawItem->draw_context, TMrInstance_GetInstanceName(animation), @@ -6348,9 +6348,9 @@ OWiSelectAnimation_Callback( { UUtBool handled; UUtError error; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -6360,24 +6360,24 @@ OWiSelectAnimation_Callback( WMrDialog_ModalEnd(inDialog, OWcSA_Btn_Cancel); } break; - + case WMcMessage_Destroy: OWiSelectAnimation_HandleDestroy(inDialog); break; - + case WMcMessage_Command: OWiSelectAnimation_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_DrawItem: OWiSelectAnimation_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -6396,16 +6396,16 @@ OWiStAP_EnableButtons( WMtWindow *popup; WMtWindow *editfield; WMtWindow *text; - + button = WMrDialog_GetItemByID(inDialog, OWcStAP_Btn_SetAnim); WMrWindow_SetEnabled(button, (inProperties->anim_type == OScAnimType_Animation)); - + popup = WMrDialog_GetItemByID(inDialog, OWcStAP_PM_Modifier); WMrWindow_SetEnabled(popup, (inProperties->anim_type != OScAnimType_Animation)); - + editfield = WMrDialog_GetItemByID(inDialog, OWcStAP_EF_Frame); WMrWindow_SetEnabled(editfield, (inProperties->anim_type == OScAnimType_Animation)); - + text = WMrDialog_GetItemByID(inDialog, OWcStAP_Txt_Duration); WMrWindow_SetVisible(text, (inProperties->anim_type == OScAnimType_Animation)); } @@ -6419,9 +6419,9 @@ OWiStAP_HandleSetAnimation( UUtError error; OWtSA sa; UUtUns32 message; - + sa.animation = inProperties->animation; - + // select an animation WMrWindow_SetVisible(inDialog, UUcFalse); error = @@ -6433,7 +6433,7 @@ OWiStAP_HandleSetAnimation( &message); WMrWindow_SetVisible(inDialog, UUcTrue); if (error != UUcError_None) { return; } - + if (message == OWcSA_Btn_None) { inProperties->animation = NULL; @@ -6453,13 +6453,13 @@ OWiStAP_HandleSetAnimation( ONcMaxVariantNameLength); } } - + if (inProperties->animation) { WMtWindow *text; TRtAnimTime duration; char string[128]; - + // set the animation name text = WMrDialog_GetItemByID(inDialog, OWcStAP_Txt_AnimName); WMrText_SetShade(text, IMcShade_Black); @@ -6508,14 +6508,14 @@ OWiStAP_InitDialog( ONtVariantList *variant_list; WMtWindow *text; UUtRect rect; - + properties = (OWtStAP*)WMrDialog_GetUserData(inDialog); if (properties == NULL) { WMrDialog_ModalEnd(inDialog, OWcStAP_Btn_Cancel); return; } - + // set the window's position to the left hand side of the screen WMrWindow_GetRect(inDialog, &rect); WMrWindow_SetLocation(inDialog, 0, rect.top); @@ -6532,13 +6532,13 @@ OWiStAP_InitDialog( WMrDialog_ModalEnd(inDialog, OWcStAP_Btn_Cancel); return; } - + // add the variants to the popup for (i = 0; i < variant_list->numVariants; i++) { WMrPopupMenu_AppendItem_Light(popup, (UUtUns16)i, variant_list->variant[i]->name); } - + // set the variant if (properties->variant_name[0] == '\0') { @@ -6552,24 +6552,24 @@ OWiStAP_InitDialog( WMrPopupMenu_SetSelection(popup, 0); } } - + // build the anim type popup menu popup = WMrDialog_GetItemByID(inDialog, OWcStAP_PM_AnimType); for (type = 0; type < OScAnimType_NumTypes; type++) { const char *anim_name; - + anim_name = OSrAnimType_GetName(type); WMrPopupMenu_AppendItem_Light(popup, (UUtUns16)type, anim_name); } - + // set the anim type error = WMrPopupMenu_SetSelection(popup, (UUtUns16)properties->anim_type); if (error != UUcError_None) { WMrPopupMenu_SetSelection(popup, 0); } - + // set the mod type popup = WMrDialog_GetItemByID(inDialog, OWcStAP_PM_Modifier); error = WMrPopupMenu_SetSelection(popup, (UUtUns16)properties->mod_type); @@ -6577,11 +6577,11 @@ OWiStAP_InitDialog( { WMrPopupMenu_SetSelection(popup, 0); } - + // set the frame number editfield = WMrDialog_GetItemByID(inDialog, OWcStAP_EF_Frame); WMrEditField_SetInt32(editfield, (UUtInt32)properties->frame); - + // set the anim name edit field if (properties->anim_type == OScAnimType_Animation) { @@ -6589,7 +6589,7 @@ OWiStAP_InitDialog( char string[128]; const char *animation_name; IMtShade shade; - + if (properties->animation != NULL) { animation_name = TMrInstance_GetInstanceName(properties->animation); @@ -6602,7 +6602,7 @@ OWiStAP_InitDialog( duration = 0; shade = IMcShade_Red; } - + // set the animation name text = WMrDialog_GetItemByID(inDialog, OWcStAP_Txt_AnimName); WMrText_SetShade(text, shade); @@ -6636,13 +6636,13 @@ OWiStAP_InitDialog( "0", OScMaxAnimNameLength); } - + // set the impulse text field text = WMrDialog_GetItemByID(inDialog, OWcStAP_Txt_SoundName); WMrWindow_SetTitle(text, properties->impulse_name, SScMaxNameLength); if (properties->impulse == NULL) { WMrText_SetShade(text, IMcShade_Red); } else { WMrText_SetShade(text, IMcShade_Black); } - + // update the controls OWiStAP_EnableButtons(inDialog, properties); } @@ -6655,24 +6655,24 @@ OWiStAP_HandleCommand( UUtUns32 inParam2) { OWtStAP *properties; - + properties = (OWtStAP*)WMrDialog_GetUserData(inDialog); - + switch (UUmLowWord(inParam1)) { case OWcStAP_Btn_SetAnim: OWiStAP_HandleSetAnimation(inDialog, properties); break; - + case OWcStAP_Btn_SetSound: { SStImpulse *impulse; OWtSelectResult result; WMtWindow *text; - + result = OWrSelect_ImpulseSound(&impulse); if (result == OWcSelectResult_Cancel) { break; } - + properties->impulse = impulse; if (impulse == NULL) { @@ -6685,7 +6685,7 @@ OWiStAP_HandleCommand( impulse->impulse_name, SScMaxNameLength); } - + text = WMrDialog_GetItemByID(inDialog, OWcStAP_Txt_SoundName); WMrWindow_SetTitle( text, @@ -6695,22 +6695,22 @@ OWiStAP_HandleCommand( else { WMrText_SetShade(text, IMcShade_Black); } } break; - + case OWcStAP_EF_Frame: { WMtWindow *editfield; - + if (UUmHighWord(inParam1) != EFcNotify_ContentChanged) { break; } - + editfield = WMrDialog_GetItemByID(inDialog, OWcStAP_EF_Frame); properties->frame = (UUtUns32)WMrEditField_GetInt32(editfield); } break; - + case OWcStAP_Btn_Cancel: WMrDialog_ModalEnd(inDialog, OWcStAP_Btn_Cancel); break; - + case OWcStAP_Btn_Save: if ((properties->animation != NULL) && (properties->frame > TRrAnimation_GetDuration(properties->animation))) @@ -6723,7 +6723,7 @@ OWiStAP_HandleCommand( WMrWindow_SetFocus(WMrDialog_GetItemByID(inDialog, OWcStAP_EF_Frame)); break; } - + WMrDialog_ModalEnd(inDialog, OWcStAP_Btn_Save); break; } @@ -6738,10 +6738,10 @@ OWiStAP_HandleMenuCommand( { OWtStAP *properties; UUtUns32 item_id; - + properties = (OWtStAP*)WMrDialog_GetUserData(inDialog); item_id = (UUtUns32)(UUmLowWord(inItemID)); - + switch (WMrWindow_GetID(inPopupMenu)) { case OWcStAP_PM_Variant: @@ -6755,7 +6755,7 @@ OWiStAP_HandleMenuCommand( else { ONtVariantList *variant_list; - + TMrInstance_GetDataPtr( ONcTemplate_VariantList, "variant_list", @@ -6772,12 +6772,12 @@ OWiStAP_HandleMenuCommand( case OWcStAP_PM_AnimType: properties->anim_type = item_id; break; - + case OWcStAP_PM_Modifier: properties->mod_type = item_id; break; } - + // update the controls OWiStAP_EnableButtons(inDialog, properties); } @@ -6791,28 +6791,28 @@ OWiStAP_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiStAP_InitDialog(inDialog); break; - + case WMcMessage_Command: OWiStAP_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_MenuCommand: OWiStAP_HandleMenuCommand(inDialog, (WMtWindow*)inParam2, inParam1); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -6828,7 +6828,7 @@ OWiStA_FillListBox( { UUtUns32 i; UUtUns32 num_variants; - + WMrMessage_Send(inListBox, LBcMessage_Reset, 0, 0); num_variants = OSrVariantList_GetNumVariants(); @@ -6837,13 +6837,13 @@ OWiStA_FillListBox( OStVariant *variant; UUtUns32 num_sounds; UUtUns32 j; - + variant = OSrVariantList_Variant_GetByIndex(i); num_sounds = OSrVariant_GetNumSounds(variant); for (j = 0; j < num_sounds; j++) { UUtUns32 item_data; - + item_data = UUmMakeLong(i, j); WMrMessage_Send(inListBox, LBcMessage_AddString, (UUtUns32)item_data, 0); } @@ -6861,7 +6861,7 @@ OWiStA_HandleDelete( UUtBool is_animation; UUtUns32 variant_index; UUtUns32 result; - + // ask before deleting result = WMrDialog_MessageBox( @@ -6870,22 +6870,22 @@ OWiStA_HandleDelete( "Are you sure you want to delete the Animation Sound?", WMcMessageBoxStyle_Yes_No); if (result == WMcDialogItem_No) { return; } - + listbox = WMrDialog_GetItemByID(inDialog, OWcStA_LB_Data); item_data = WMrMessage_Send(listbox, LBcMessage_GetItemData, 0, (UUtUns32)-1); - + is_animation = (item_data & 0x80000000) != 0; variant_index = UUmHighWord(item_data) & 0x7FFF; - + variant = OSrVariantList_Variant_GetByIndex(variant_index); if (variant == NULL) { return; } - + // delete the sound animation from the variant OSrVariant_SoundAnimation_DeleteByIndex(variant, UUmLowWord(item_data)); - + // save the data OSrVariantList_Save(UUcFalse); - + // fill the listbox OWiStA_FillListBox(listbox); } @@ -6904,24 +6904,24 @@ OWiStA_HandlePlay( M3tVector3D velocity; UUtBool is_animation; UUtUns32 variant_index; - + listbox = WMrDialog_GetItemByID(inDialog, OWcStA_LB_Data); item_data = WMrMessage_Send(listbox, LBcMessage_GetItemData, 0, (UUtUns32)-1); - + is_animation = (item_data & 0x80000000) != 0; variant_index = UUmHighWord(item_data) & 0x7FFF; - + variant = OSrVariantList_Variant_GetByIndex(variant_index); if (variant == NULL) { return; } - + sound_animation = OSrVariant_SoundAnimation_GetByIndex(variant, UUmLowWord(item_data)); if (sound_animation == NULL) { return; } - + // set the listener position MUmVector_Set(position, 0.0f, 0.0f, 0.0f); MUmVector_Set(facing, 1.0f, 0.0f, 1.0f); SSrListener_SetPosition(&position, &facing); - + // play the sound MUmVector_Set(position, 5.0f, 0.0f, 5.0f); MUmVector_Set(velocity, 0.0f, 0.0f, 0.0f); @@ -6942,19 +6942,19 @@ OWiStA_HandleEdit( UUtUns32 message; UUtBool is_animation; UUtUns32 variant_index; - + listbox = WMrDialog_GetItemByID(inDialog, OWcStA_LB_Data); item_data = WMrMessage_Send(listbox, LBcMessage_GetItemData, 0, (UUtUns32)-1); - + is_animation = (item_data & 0x80000000) != 0; variant_index = UUmHighWord(item_data) & 0x7FFF; - + variant = OSrVariantList_Variant_GetByIndex(variant_index); if (variant == NULL) { return UUcError_Generic; } - + sound_animation = OSrVariant_SoundAnimation_GetByIndex(variant, UUmLowWord(item_data)); if (sound_animation == NULL) { return UUcError_Generic; } - + // initialize the properties properties.anim_type = sound_animation->anim_type; properties.mod_type = sound_animation->mod_type; @@ -6983,10 +6983,10 @@ OWiStA_HandleEdit( properties.impulse_name, sound_animation->impulse_name, SScMaxNameLength); - + // edit the properties WMrWindow_SetVisible(inDialog, UUcFalse); - error = + error = WMrDialog_ModalBegin( OWcDialog_Sound_to_Anim_Prop, inDialog, @@ -6995,18 +6995,18 @@ OWiStA_HandleEdit( &message); WMrWindow_SetVisible(inDialog, UUcTrue); UUmError_ReturnOnError(error); - + if (message == OWcStAP_Btn_Save) { OStVariant *new_variant; - + // delete the old sound variant OSrVariant_SoundAnimation_DeleteByIndex(variant, UUmLowWord(item_data)); - + // if the variant changed, then delete the sound animation from the old variant new_variant = OSrVariantList_Variant_GetByName(properties.variant_name); if (new_variant == NULL) { return UUcError_Generic; } - + // add the sound animation to the new variant error = OSrVariant_SoundAnimation_Add( @@ -7024,14 +7024,14 @@ OWiStA_HandleEdit( "Unable to update the sound to the variant.", WMcMessageBoxStyle_OK); } - + // save the data OSrVariantList_Save(UUcFalse); - + // fill in the listbox OWiStA_FillListBox(WMrDialog_GetItemByID(inDialog, OWcStA_LB_Data)); } - + return UUcError_None; } @@ -7043,7 +7043,7 @@ OWiStA_HandleNew( UUtError error; UUtUns32 message; OWtStAP properties; - + UUrMemory_Clear(&properties, sizeof(OWtStAP)); properties.anim_type = OScAnimType_Any; properties.impulse = NULL; @@ -7051,9 +7051,9 @@ OWiStA_HandleNew( properties.frame = 0; properties.variant_name[0] = '\0'; properties.impulse_name[0] = '\0'; - + WMrWindow_SetVisible(inDialog, UUcFalse); - error = + error = WMrDialog_ModalBegin( OWcDialog_Sound_to_Anim_Prop, inDialog, @@ -7062,14 +7062,14 @@ OWiStA_HandleNew( &message); WMrWindow_SetVisible(inDialog, UUcTrue); UUmError_ReturnOnError(error); - + if (message == OWcStAP_Btn_Save) { OStVariant *variant; - + variant = OSrVariantList_Variant_GetByName(properties.variant_name); if (variant == NULL) { return UUcError_Generic; } - + // add the item error = OSrVariant_SoundAnimation_Add( @@ -7087,14 +7087,14 @@ OWiStA_HandleNew( "Unable to add the sound to the variant.", WMcMessageBoxStyle_OK); } - + // save the data OSrVariantList_Save(UUcFalse); - + // fill in the listbox OWiStA_FillListBox(WMrDialog_GetItemByID(inDialog, OWcStA_LB_Data)); } - + return UUcError_None; } @@ -7105,11 +7105,11 @@ OWiStA_InitDialog( { WMtWindow *listbox; UUtRect rect; - + // set the window's position to the left hand side of the screen WMrWindow_GetRect(inDialog, &rect); WMrWindow_SetLocation(inDialog, 0, rect.top); - + // update the sound animation pointers OSrSA_UpdatePointers(); @@ -7130,26 +7130,26 @@ OWiStA_HandleCommand( case WMcDialogItem_Cancel: WMrDialog_ModalEnd(inDialog, 0); break; - + case OWcStA_LB_Data: if (UUmHighWord(inParam1) == WMcNotify_DoubleClick) { OWiStA_HandleEdit(inDialog); } break; - + case OWcStA_Btn_Delete: OWiStA_HandleDelete(inDialog); break; - + case OWcStA_Btn_Play: OWiStA_HandlePlay(inDialog); break; - + case OWcStA_Btn_Edit: OWiStA_HandleEdit(inDialog); break; - + case OWcStA_Btn_New: OWiStA_HandleNew(inDialog); break; @@ -7175,15 +7175,15 @@ OWiStA_HandleDrawItem( // get a pointer to the partspec_ui partspec_ui = PSrPartSpecUI_GetActive(); UUmAssert(partspec_ui); - + // set the dest dest.x = inDrawItem->rect.left; dest.y = inDrawItem->rect.top; - + // calc the width and height of the line line_width = inDrawItem->rect.right - inDrawItem->rect.left; line_height = inDrawItem->rect.bottom - inDrawItem->rect.top; - + if (inDrawItem->rect.top > 5) { // draw a divider @@ -7196,22 +7196,22 @@ OWiStA_HandleDrawItem( 2, M3cMaxAlpha); } - + is_animation = (inDrawItem->data & 0x80000000) != 0; variant_index = UUmHighWord(inDrawItem->data) & 0x7FFF; - + // get the variant and animation sound variant = OSrVariantList_Variant_GetByIndex(variant_index); if (variant == NULL) { return; } - + sound_animation = OSrVariant_SoundAnimation_GetByIndex(variant, UUmLowWord(inDrawItem->data)); if (sound_animation == NULL) { return; } - + // draw the Text DCrText_SetFormat(TSc_HLeft | TSc_VCenter); DCrText_SetStyle(TScStyle_Plain); DCrText_SetShade(IMcShade_Black); - + dest.x = 5; dest.y += 1; @@ -7220,14 +7220,14 @@ OWiStA_HandleDrawItem( OSrVariant_GetName(variant), &inDrawItem->rect, &dest); - + dest.x = 125; - + anim_type = sound_animation->anim_type; if (anim_type == OScAnimType_Animation) { TRtAnimation *animation; - + animation = sound_animation->animation; if (animation == NULL) { @@ -7252,22 +7252,22 @@ OWiStA_HandleDrawItem( char string[128]; const char *mod_name; const char *anim_name; - + mod_name = OSrModType_GetName(sound_animation->mod_type); anim_name = OSrAnimType_GetName(anim_type); - + sprintf(string, "%s %s", mod_name, anim_name); DCrDraw_String(inDrawItem->draw_context, string, &inDrawItem->rect, &dest); } DCrText_SetShade(IMcShade_Black); - + dest.x = 305; - + if (sound_animation->impulse == NULL) { DCrText_SetShade(IMcShade_Red); } - + DCrDraw_String( inDrawItem->draw_context, sound_animation->impulse_name, @@ -7284,28 +7284,28 @@ OWiStA_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiStA_InitDialog(inDialog); break; - + case WMcMessage_Command: OWiStA_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_DrawItem: OWiStA_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -7315,7 +7315,7 @@ OWrSoundToAnim_Display( void) { UUtError error; - + // display the sound to animation dialog error = WMrDialog_ModalBegin( @@ -7325,7 +7325,7 @@ OWrSoundToAnim_Display( 0, NULL); UUmError_ReturnOnError(error); - + return UUcError_None; } @@ -7342,13 +7342,13 @@ OWiCD_GetDirectoryRef( UUtError error; BFtFileRef *out_ref; OWtCreateDialogue *cd; - + cd = (OWtCreateDialogue*)WMrDialog_GetUserData(inDialog); if (cd->dir_ref == NULL) { return NULL; } - + error = BFrFileRef_Duplicate(cd->dir_ref, &out_ref); if (error != UUcError_None) { return NULL; } - + return out_ref; } @@ -7362,12 +7362,12 @@ OWiCD_SetDirectoryRef( BFtFileRef *old_ref; BFtFileRef *copy_ref; OWtCreateDialogue *cd; - + // get the create data cd = (OWtCreateDialogue*)WMrDialog_GetUserData(inDialog); - + UUrMemory_Block_VerifyList(); - + // delete the old ref old_ref = cd->dir_ref; if (old_ref != NULL) @@ -7375,7 +7375,7 @@ OWiCD_SetDirectoryRef( BFrFileRef_Dispose(old_ref); old_ref = NULL; } - + if (inDirRef != NULL) { error = BFrFileRef_Duplicate(inDirRef, ©_ref); @@ -7385,12 +7385,12 @@ OWiCD_SetDirectoryRef( { copy_ref = NULL; } - + // set the new ref cd->dir_ref = copy_ref; - + error = OWiSetPopup(WMrDialog_GetItemByID(inDialog, OWcCD_PM_Category), copy_ref); - + UUrMemory_Block_VerifyList(); } @@ -7409,17 +7409,17 @@ OWiCD_New( UUtUns32 index; UUtUns32 message; WMtWindow *listbox; - + group = NULL; ambient = NULL; dir_ref = NULL; - + // get the create data cd = (OWtCreateDialogue*)WMrDialog_GetUserData(inDialog); - + UUrMemory_Clear(&ws, sizeof(OWtWS)); ws.allow_categories = UUcFalse; - + // select the wav file to use error = WMrDialog_ModalBegin( @@ -7429,75 +7429,75 @@ OWiCD_New( (UUtUns32)&ws, &message); if ((error != UUcError_None) || (message == OWcWS_Btn_Cancel)) { return; } - + // get the name of the sound data UUrString_Copy(name, SSrSoundData_GetName(ws.selected_sound_data), SScMaxNameLength); UUrString_StripExtension(name); - + // create the sound group error = OSrGroup_New(name, &group); if (error != UUcError_None) { goto cleanup; } - + error = SSrGroup_Permutation_New(group, ws.selected_sound_data, &index); if (error != UUcError_None) { goto cleanup; } - + // create the ambient sound error = OSrAmbient_New(name, &ambient); if (error != UUcError_None) { goto cleanup; } - + // set the base track 1 ambient->base_track1 = group; UUrString_Copy(ambient->base_track1_name, name, SScMaxNameLength); - + // set the flags ambient->flags |= (SScAmbientFlag_PlayOnce | SScAmbientFlag_InterruptOnStop); - + // set the priority to highest ambient->priority = SScPriority2_Highest; - + // get the dir ref dir_ref = OWiCD_GetDirectoryRef(inDialog); if (dir_ref == NULL) { goto cleanup; } - + // save the sound group error = OSrGroup_Save(group, dir_ref); if (error != UUcError_None) { goto cleanup; } - + // save the ambient sound error = OSrAmbient_Save(ambient, dir_ref); if (error != UUcError_None) { goto cleanup; } - + // fill in the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcCD_LB_Items), OWiListDirectory(listbox, dir_ref, OScAmbientSuffix); - + // select the item that was just selected WMrListBox_SelectString(listbox, name); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + return; - + cleanup: if (group != NULL) { OSrGroup_Delete(name); group = NULL; } - + if (ambient != NULL) { OSrAmbient_Delete(name); ambient = NULL; } - + if (dir_ref != NULL) { BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } - + WMrDialog_MessageBox( inDialog, "Error", @@ -7515,35 +7515,35 @@ OWiCD_Category_Open( BFtFileRef *parent_dir_ref; BFtFileRef *open_dir_ref; char name[BFcMaxFileNameLength]; - + UUrMemory_Block_VerifyList(); - + parent_dir_ref = NULL; open_dir_ref = NULL; name[0] = '\0'; - + // get the parent dir ref parent_dir_ref = OWiCD_GetDirectoryRef(inDialog); if (parent_dir_ref == NULL) { return; } - + // make a dir ref for the directory being opened WMrListBox_GetText(inListBox, name, (UUtUns32)(-1)); error = BFrFileRef_DuplicateAndAppendName(parent_dir_ref, name, &open_dir_ref); if (error != UUcError_None) { goto cleanup; } - + // fill in the listbox error = OWiListDirectory(inListBox, open_dir_ref, OScAmbientSuffix); if (error != UUcError_None) { goto cleanup; } - + OWiCD_SetDirectoryRef(inDialog, open_dir_ref); - + cleanup: if (parent_dir_ref != NULL) { BFrFileRef_Dispose(parent_dir_ref); parent_dir_ref = NULL; } - + if (open_dir_ref != NULL) { BFrFileRef_Dispose(open_dir_ref); @@ -7562,13 +7562,13 @@ OWiCD_InitDialog( OWtCreateDialogue *cd; BFtFileRef *dir_ref; WMtWindow *listbox; - + SSrSoundData_GetByName_StartCache(); // get the create data cd = (OWtCreateDialogue*)WMrDialog_GetUserData(inDialog); if (cd == NULL) { goto cleanup; } - + // get the directory ref if (OWgCD_DirRef == NULL) { @@ -7580,30 +7580,30 @@ OWiCD_InitDialog( error = BFrFileRef_Duplicate(OWgCD_DirRef, &dir_ref); if (error != UUcError_None) { goto cleanup; } } - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcCD_LB_Items); if (listbox == NULL) { goto cleanup; } - + // fill in the listbox error = OWiListDirectory(listbox, dir_ref, OScAmbientSuffix); if (error != UUcError_None) { goto cleanup; } - + // save the directory ref OWiCD_SetDirectoryRef(inDialog, dir_ref); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + return; - + cleanup: if (dir_ref) { BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } - + WMrDialog_ModalEnd(inDialog, 0); } @@ -7617,19 +7617,19 @@ OWiCD_HandleCommand( UUtUns16 control_id; UUtUns16 command_type; OWtCreateDialogue *cd; - + cd = (OWtCreateDialogue*)WMrDialog_GetUserData(inDialog); - + control_id = UUmLowWord(inParam); command_type = UUmHighWord(inParam); - + switch (control_id) { case OWcCD_LB_Items: if (command_type == WMcNotify_DoubleClick) { UUtUns32 item_data; - + item_data = WMrListBox_GetItemData(inControl, (UUtUns32)(-1)); if (item_data != 0) { @@ -7637,12 +7637,12 @@ OWiCD_HandleCommand( } } break; - + case OWcCD_Btn_New: if (command_type != WMcNotify_Click) { break; } OWiCD_New(inDialog); break; - + case WMcDialogItem_Cancel: if (command_type != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, 0); @@ -7656,7 +7656,7 @@ OWiCD_HandleDestroy( WMtDialog *inDialog) { OWtCreateDialogue *cd; - + cd = (OWtCreateDialogue*)WMrDialog_GetUserData(inDialog); if (cd) { @@ -7667,7 +7667,7 @@ OWiCD_HandleDestroy( BFrFileRef_Dispose(OWgCD_DirRef); OWgCD_DirRef = NULL; } - + OWgCD_DirRef = cd->dir_ref; cd->dir_ref = NULL; } @@ -7686,35 +7686,35 @@ OWiCD_HandleMenuCommand( UUtUns32 i; BFtFileRef *dir_ref; UUtError error; - + // if inItemID == 0 then the popup menu is still on the same item // so no updating needs to be done if (inItemID == 0) { return; } - + // get the dir ref of the current item in the popup menu dir_ref = OWiCD_GetDirectoryRef(inDialog); if (dir_ref == NULL) { return; } - + // go up the hierarchy of directories until the desired directory is found for (i = 0; i < (UUtUns32)inItemID; i++) { BFtFileRef *parent_ref; - + error = BFrFileRef_GetParentDirectory(dir_ref, &parent_ref); if (error != UUcError_None) { return; } - + BFrFileRef_Dispose(dir_ref); dir_ref = parent_ref; } - + // fill in the listbox OWiListDirectory( WMrDialog_GetItemByID(inDialog, OWcCD_LB_Items), dir_ref, OScAmbientSuffix); - + OWiCD_SetDirectoryRef(inDialog, dir_ref); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } @@ -7728,23 +7728,23 @@ OWiCD_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiCD_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiCD_HandleDestroy(inDialog); break; - + case WMcMessage_Command: OWiCD_HandleCommand(inDialog, (WMtWindow*)inParam2, inParam1); break; - + case WMcMessage_MenuCommand: OWiCD_HandleMenuCommand(inDialog, (WMtWindow*)inParam2, UUmLowWord(inParam1)); break; @@ -7752,12 +7752,12 @@ OWiCD_Callback( case WMcMessage_DrawItem: OWiSM_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -7768,11 +7768,11 @@ OWrCreateDialogue_Display( { UUtError error; OWtCreateDialogue create_dialogue; - + UUrMemory_Clear(&create_dialogue, sizeof(OWtCreateDialogue)); - + // display the create dialogue dialog - error = + error = WMrDialog_ModalBegin( OWcDialog_Create_Dialogue, NULL, @@ -7797,13 +7797,13 @@ OWiCI_GetDirectoryRef( UUtError error; BFtFileRef *out_ref; OWtCreateImpulse *ci; - + ci = (OWtCreateImpulse *)WMrDialog_GetUserData(inDialog); if (ci->dir_ref == NULL) { return NULL; } - + error = BFrFileRef_Duplicate(ci->dir_ref, &out_ref); if (error != UUcError_None) { return NULL; } - + return out_ref; } @@ -7817,12 +7817,12 @@ OWiCI_SetDirectoryRef( BFtFileRef *old_ref; BFtFileRef *copy_ref; OWtCreateImpulse *ci; - + // get the create data ci = (OWtCreateImpulse *)WMrDialog_GetUserData(inDialog); - + UUrMemory_Block_VerifyList(); - + // delete the old ref old_ref = ci->dir_ref; if (old_ref != NULL) @@ -7830,7 +7830,7 @@ OWiCI_SetDirectoryRef( BFrFileRef_Dispose(old_ref); old_ref = NULL; } - + if (inDirRef != NULL) { error = BFrFileRef_Duplicate(inDirRef, ©_ref); @@ -7840,12 +7840,12 @@ OWiCI_SetDirectoryRef( { copy_ref = NULL; } - + // set the new ref ci->dir_ref = copy_ref; - + error = OWiSetPopup(WMrDialog_GetItemByID(inDialog, OWcCI_PM_Category), copy_ref); - + UUrMemory_Block_VerifyList(); } @@ -7864,14 +7864,14 @@ OWiCI_New( UUtUns32 index; UUtUns32 message; WMtWindow *listbox; - + group = NULL; impulse = NULL; dir_ref = NULL; - + // get the create data ci = (OWtCreateImpulse*)WMrDialog_GetUserData(inDialog); - + UUrMemory_Clear(&ws, sizeof(OWtWS)); ws.allow_categories = UUcTrue; @@ -7898,11 +7898,11 @@ OWiCI_New( // nothing selected goto cleanup; } - + // create the sound group error = OSrGroup_New(name, &group); if (error != UUcError_None) { goto cleanup; } - + if (ws.selected_sound_data != NULL) { // add a permutation for the sound data to the group error = SSrGroup_Permutation_New(group, ws.selected_sound_data, &index); @@ -7925,7 +7925,7 @@ OWiCI_New( BFtFileRef ref; char file_name[SScMaxNameLength]; SStSoundData *sound_data; - + // get the next ref error = BFrDirectory_FileIterator_Next(file_iterator, &ref); if (error != UUcError_None) { break; } @@ -7939,7 +7939,7 @@ OWiCI_New( // get the SStSoundData* corresponding to this file sound_data = SSrSoundData_GetByName(file_name, UUcTrue); - + if (sound_data == NULL) { // create a new sound data error = SSrSoundData_New(&ref, &sound_data); @@ -7951,7 +7951,7 @@ OWiCI_New( // add the sound data to the group error = SSrGroup_Permutation_New(group, sound_data, &index); } - + // delete the file iterator BFrDirectory_FileIterator_Delete(file_iterator); @@ -7962,11 +7962,11 @@ OWiCI_New( // create the impulse sound error = OSrImpulse_New(name, &impulse); if (error != UUcError_None) { goto cleanup; } - + // set the sound group impulse->impulse_group = group; UUrString_Copy(impulse->impulse_group_name, name, SScMaxNameLength); - + // set up defaults impulse->min_volume_distance = 15.0f; impulse->max_volume_distance = 80.0f; @@ -7974,46 +7974,46 @@ OWiCI_New( // get the dir ref dir_ref = OWiCI_GetDirectoryRef(inDialog); if (dir_ref == NULL) { goto cleanup; } - + // save the sound group error = OSrGroup_Save(group, dir_ref); if (error != UUcError_None) { goto cleanup; } - + // save the impulse sound error = OSrImpulse_Save(impulse, dir_ref); if (error != UUcError_None) { goto cleanup; } - + // fill in the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcCI_LB_Items), OWiListDirectory(listbox, dir_ref, OScImpulseSuffix); - + // select the item that was just selected WMrListBox_SelectString(listbox, name); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + return; - + cleanup: if (group != NULL) { OSrGroup_Delete(name); group = NULL; } - + if (impulse != NULL) { OSrImpulse_Delete(name); impulse = NULL; } - + if (dir_ref != NULL) { BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } - + WMrDialog_MessageBox( inDialog, "Error", @@ -8031,35 +8031,35 @@ OWiCI_Category_Open( BFtFileRef *parent_dir_ref; BFtFileRef *open_dir_ref; char name[BFcMaxFileNameLength]; - + UUrMemory_Block_VerifyList(); - + parent_dir_ref = NULL; open_dir_ref = NULL; name[0] = '\0'; - + // get the parent dir ref parent_dir_ref = OWiCI_GetDirectoryRef(inDialog); if (parent_dir_ref == NULL) { return; } - + // make a dir ref for the directory being opened WMrListBox_GetText(inListBox, name, (UUtUns32)(-1)); error = BFrFileRef_DuplicateAndAppendName(parent_dir_ref, name, &open_dir_ref); if (error != UUcError_None) { goto cleanup; } - + // fill in the listbox error = OWiListDirectory(inListBox, open_dir_ref, OScImpulseSuffix); if (error != UUcError_None) { goto cleanup; } - + OWiCI_SetDirectoryRef(inDialog, open_dir_ref); - + cleanup: if (parent_dir_ref != NULL) { BFrFileRef_Dispose(parent_dir_ref); parent_dir_ref = NULL; } - + if (open_dir_ref != NULL) { BFrFileRef_Dispose(open_dir_ref); @@ -8078,13 +8078,13 @@ OWiCI_InitDialog( OWtCreateImpulse *ci; BFtFileRef *dir_ref; WMtWindow *listbox; - + SSrSoundData_GetByName_StartCache(); // get the create data ci = (OWtCreateImpulse *)WMrDialog_GetUserData(inDialog); if (ci == NULL) { goto cleanup; } - + // get the directory ref if (OWgCI_DirRef == NULL) { @@ -8096,23 +8096,23 @@ OWiCI_InitDialog( error = BFrFileRef_Duplicate(OWgCI_DirRef, &dir_ref); if (error != UUcError_None) { goto cleanup; } } - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcCI_LB_Items); if (listbox == NULL) { goto cleanup; } - + // fill in the listbox error = OWiListDirectory(listbox, dir_ref, OScImpulseSuffix); if (error != UUcError_None) { goto cleanup; } - + // save the directory ref OWiCI_SetDirectoryRef(inDialog, dir_ref); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + return; - + cleanup: if (dir_ref) @@ -8120,7 +8120,7 @@ OWiCI_InitDialog( BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } - + WMrDialog_ModalEnd(inDialog, 0); } @@ -8134,19 +8134,19 @@ OWiCI_HandleCommand( UUtUns16 control_id; UUtUns16 command_type; OWtCreateImpulse *ci; - + ci = (OWtCreateImpulse *)WMrDialog_GetUserData(inDialog); - + control_id = UUmLowWord(inParam); command_type = UUmHighWord(inParam); - + switch (control_id) { case OWcCI_LB_Items: if (command_type == WMcNotify_DoubleClick) { UUtUns32 item_data; - + item_data = WMrListBox_GetItemData(inControl, (UUtUns32)(-1)); if (item_data != 0) { @@ -8154,12 +8154,12 @@ OWiCI_HandleCommand( } } break; - + case OWcCI_Btn_New: if (command_type != WMcNotify_Click) { break; } OWiCI_New(inDialog); break; - + case WMcDialogItem_Cancel: if (command_type != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, 0); @@ -8173,7 +8173,7 @@ OWiCI_HandleDestroy( WMtDialog *inDialog) { OWtCreateImpulse *ci; - + ci = (OWtCreateImpulse *)WMrDialog_GetUserData(inDialog); if (ci) { @@ -8184,7 +8184,7 @@ OWiCI_HandleDestroy( BFrFileRef_Dispose(OWgCI_DirRef); OWgCI_DirRef = NULL; } - + OWgCI_DirRef = ci->dir_ref; ci->dir_ref = NULL; } @@ -8203,35 +8203,35 @@ OWiCI_HandleMenuCommand( UUtUns32 i; BFtFileRef *dir_ref; UUtError error; - + // if inItemID == 0 then the popup menu is still on the same item // so no updating needs to be done if (inItemID == 0) { return; } - + // get the dir ref of the current item in the popup menu dir_ref = OWiCI_GetDirectoryRef(inDialog); if (dir_ref == NULL) { return; } - + // go up the hierarchy of directories until the desired directory is found for (i = 0; i < (UUtUns32)inItemID; i++) { BFtFileRef *parent_ref; - + error = BFrFileRef_GetParentDirectory(dir_ref, &parent_ref); if (error != UUcError_None) { return; } - + BFrFileRef_Dispose(dir_ref); dir_ref = parent_ref; } - + // fill in the listbox OWiListDirectory( WMrDialog_GetItemByID(inDialog, OWcCI_LB_Items), dir_ref, OScImpulseSuffix); - + OWiCI_SetDirectoryRef(inDialog, dir_ref); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } @@ -8245,23 +8245,23 @@ OWiCI_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiCI_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiCI_HandleDestroy(inDialog); break; - + case WMcMessage_Command: OWiCI_HandleCommand(inDialog, (WMtWindow*)inParam2, inParam1); break; - + case WMcMessage_MenuCommand: OWiCI_HandleMenuCommand(inDialog, (WMtWindow*)inParam2, UUmLowWord(inParam1)); break; @@ -8269,12 +8269,12 @@ OWiCI_Callback( case WMcMessage_DrawItem: OWiSM_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -8285,11 +8285,11 @@ OWrCreateImpulse_Display( { UUtError error; OWtCreateImpulse create_impulse; - + UUrMemory_Clear(&create_impulse, sizeof(OWtCreateImpulse)); - + // display the create dialogue dialog - error = + error = WMrDialog_ModalBegin( OWcDialog_Create_Impulse, NULL, @@ -8314,13 +8314,13 @@ OWiCG_GetDirectoryRef( UUtError error; BFtFileRef *out_ref; OWtCreateGroup *cg; - + cg = (OWtCreateGroup *)WMrDialog_GetUserData(inDialog); if (cg->dir_ref == NULL) { return NULL; } - + error = BFrFileRef_Duplicate(cg->dir_ref, &out_ref); if (error != UUcError_None) { return NULL; } - + return out_ref; } @@ -8334,12 +8334,12 @@ OWiCG_SetDirectoryRef( BFtFileRef *old_ref; BFtFileRef *copy_ref; OWtCreateGroup *cg; - + // get the create data cg = (OWtCreateGroup *)WMrDialog_GetUserData(inDialog); - + UUrMemory_Block_VerifyList(); - + // delete the old ref old_ref = cg->dir_ref; if (old_ref != NULL) @@ -8347,7 +8347,7 @@ OWiCG_SetDirectoryRef( BFrFileRef_Dispose(old_ref); old_ref = NULL; } - + if (inDirRef != NULL) { error = BFrFileRef_Duplicate(inDirRef, ©_ref); @@ -8357,12 +8357,12 @@ OWiCG_SetDirectoryRef( { copy_ref = NULL; } - + // set the new ref cg->dir_ref = copy_ref; - + error = OWiSetPopup(WMrDialog_GetItemByID(inDialog, OWcCG_PM_Category), copy_ref); - + UUrMemory_Block_VerifyList(); } @@ -8380,13 +8380,13 @@ OWiCG_New( UUtUns32 index; UUtUns32 message; WMtWindow *listbox; - + group = NULL; dir_ref = NULL; - + // get the create data cg = (OWtCreateGroup *) WMrDialog_GetUserData(inDialog); - + UUrMemory_Clear(&ws, sizeof(OWtWS)); ws.allow_categories = UUcTrue; @@ -8413,11 +8413,11 @@ OWiCG_New( // nothing selected goto cleanup; } - + // create the sound group error = OSrGroup_New(name, &group); if (error != UUcError_None) { goto cleanup; } - + if (ws.selected_sound_data != NULL) { // add a permutation for the sound data to the group error = SSrGroup_Permutation_New(group, ws.selected_sound_data, &index); @@ -8440,7 +8440,7 @@ OWiCG_New( BFtFileRef ref; char file_name[SScMaxNameLength]; SStSoundData *sound_data; - + // get the next ref error = BFrDirectory_FileIterator_Next(file_iterator, &ref); if (error != UUcError_None) { break; } @@ -8454,7 +8454,7 @@ OWiCG_New( // get the SStSoundData* corresponding to this file sound_data = SSrSoundData_GetByName(file_name, UUcTrue); - + if (sound_data == NULL) { // create a new sound data error = SSrSoundData_New(&ref, &sound_data); @@ -8466,7 +8466,7 @@ OWiCG_New( // add the sound data to the group error = SSrGroup_Permutation_New(group, sound_data, &index); } - + // delete the file iterator BFrDirectory_FileIterator_Delete(file_iterator); @@ -8477,36 +8477,36 @@ OWiCG_New( // get the dir ref dir_ref = OWiCG_GetDirectoryRef(inDialog); if (dir_ref == NULL) { goto cleanup; } - + // save the sound group error = OSrGroup_Save(group, dir_ref); if (error != UUcError_None) { goto cleanup; } - + // fill in the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcCG_LB_Items), OWiListDirectory(listbox, dir_ref, OScImpulseSuffix); - + // select the item that was just selected WMrListBox_SelectString(listbox, name); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + return; - + cleanup: if (group != NULL) { OSrGroup_Delete(name); group = NULL; } - + if (dir_ref != NULL) { BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } - + WMrDialog_MessageBox( inDialog, "Error", @@ -8524,35 +8524,35 @@ OWiCG_Category_Open( BFtFileRef *parent_dir_ref; BFtFileRef *open_dir_ref; char name[BFcMaxFileNameLength]; - + UUrMemory_Block_VerifyList(); - + parent_dir_ref = NULL; open_dir_ref = NULL; name[0] = '\0'; - + // get the parent dir ref parent_dir_ref = OWiCG_GetDirectoryRef(inDialog); if (parent_dir_ref == NULL) { return; } - + // make a dir ref for the directory being opened WMrListBox_GetText(inListBox, name, (UUtUns32)(-1)); error = BFrFileRef_DuplicateAndAppendName(parent_dir_ref, name, &open_dir_ref); if (error != UUcError_None) { goto cleanup; } - + // fill in the listbox error = OWiListDirectory(inListBox, open_dir_ref, OScImpulseSuffix); if (error != UUcError_None) { goto cleanup; } - + OWiCG_SetDirectoryRef(inDialog, open_dir_ref); - + cleanup: if (parent_dir_ref != NULL) { BFrFileRef_Dispose(parent_dir_ref); parent_dir_ref = NULL; } - + if (open_dir_ref != NULL) { BFrFileRef_Dispose(open_dir_ref); @@ -8571,13 +8571,13 @@ OWiCG_InitDialog( OWtCreateGroup *cg; BFtFileRef *dir_ref; WMtWindow *listbox; - + SSrSoundData_GetByName_StartCache(); // get the create data cg = (OWtCreateGroup *)WMrDialog_GetUserData(inDialog); if (cg == NULL) { goto cleanup; } - + // get the directory ref if (OWgCG_DirRef == NULL) { @@ -8589,23 +8589,23 @@ OWiCG_InitDialog( error = BFrFileRef_Duplicate(OWgCG_DirRef, &dir_ref); if (error != UUcError_None) { goto cleanup; } } - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcCG_LB_Items); if (listbox == NULL) { goto cleanup; } - + // fill in the listbox error = OWiListDirectory(listbox, dir_ref, OScImpulseSuffix); if (error != UUcError_None) { goto cleanup; } - + // save the directory ref OWiCG_SetDirectoryRef(inDialog, dir_ref); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; - + return; - + cleanup: if (dir_ref) @@ -8613,7 +8613,7 @@ OWiCG_InitDialog( BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } - + WMrDialog_ModalEnd(inDialog, 0); } @@ -8627,19 +8627,19 @@ OWiCG_HandleCommand( UUtUns16 control_id; UUtUns16 command_type; OWtCreateGroup *cg; - + cg = (OWtCreateGroup *)WMrDialog_GetUserData(inDialog); - + control_id = UUmLowWord(inParam); command_type = UUmHighWord(inParam); - + switch (control_id) { case OWcCG_LB_Items: if (command_type == WMcNotify_DoubleClick) { UUtUns32 item_data; - + item_data = WMrListBox_GetItemData(inControl, (UUtUns32)(-1)); if (item_data != 0) { @@ -8647,12 +8647,12 @@ OWiCG_HandleCommand( } } break; - + case OWcCG_Btn_New: if (command_type != WMcNotify_Click) { break; } OWiCG_New(inDialog); break; - + case WMcDialogItem_Cancel: if (command_type != WMcNotify_Click) { break; } WMrDialog_ModalEnd(inDialog, 0); @@ -8666,7 +8666,7 @@ OWiCG_HandleDestroy( WMtDialog *inDialog) { OWtCreateGroup *cg; - + cg = (OWtCreateGroup *)WMrDialog_GetUserData(inDialog); if (cg) { @@ -8677,7 +8677,7 @@ OWiCG_HandleDestroy( BFrFileRef_Dispose(OWgCG_DirRef); OWgCG_DirRef = NULL; } - + OWgCG_DirRef = cg->dir_ref; cg->dir_ref = NULL; } @@ -8696,35 +8696,35 @@ OWiCG_HandleMenuCommand( UUtUns32 i; BFtFileRef *dir_ref; UUtError error; - + // if inItemID == 0 then the popup menu is still on the same item // so no updating needs to be done if (inItemID == 0) { return; } - + // get the dir ref of the current item in the popup menu dir_ref = OWiCG_GetDirectoryRef(inDialog); if (dir_ref == NULL) { return; } - + // go up the hierarchy of directories until the desired directory is found for (i = 0; i < (UUtUns32)inItemID; i++) { BFtFileRef *parent_ref; - + error = BFrFileRef_GetParentDirectory(dir_ref, &parent_ref); if (error != UUcError_None) { return; } - + BFrFileRef_Dispose(dir_ref); dir_ref = parent_ref; } - + // fill in the listbox OWiListDirectory( WMrDialog_GetItemByID(inDialog, OWcCG_LB_Items), dir_ref, OScImpulseSuffix); - + OWiCG_SetDirectoryRef(inDialog, dir_ref); - + BFrFileRef_Dispose(dir_ref); dir_ref = NULL; } @@ -8738,23 +8738,23 @@ OWiCG_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiCG_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiCG_HandleDestroy(inDialog); break; - + case WMcMessage_Command: OWiCG_HandleCommand(inDialog, (WMtWindow*)inParam2, inParam1); break; - + case WMcMessage_MenuCommand: OWiCG_HandleMenuCommand(inDialog, (WMtWindow*)inParam2, UUmLowWord(inParam1)); break; @@ -8762,12 +8762,12 @@ OWiCG_Callback( case WMcMessage_DrawItem: OWiSM_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -8778,11 +8778,11 @@ OWrCreateGroup_Display( { UUtError error; OWtCreateGroup create_group; - + UUrMemory_Clear(&create_group, sizeof(OWtCreateGroup)); - + // display the create dialogue dialog - error = + error = WMrDialog_ModalBegin( OWcDialog_Create_Group, NULL, @@ -8807,7 +8807,7 @@ OWiMinMax_Fixer( { UUtError error; BFtFileIterator *file_iterator; - + // go through all of the ambient sounds and fix the ones whose // max volume distance is less than the min volume distance error = @@ -8817,17 +8817,17 @@ OWiMinMax_Fixer( NULL, &file_iterator); UUmError_ReturnOnError(error); - + while (1) { BFtFileRef ref; float temp_distance; char name[BFcMaxFileNameLength]; char out_string[1024]; - + error = BFrDirectory_FileIterator_Next(file_iterator, &ref); if (error != UUcError_None) { break; } - + if (BFrFileRef_IsDirectory(&ref)) { OWiMinMax_Fixer(&ref, inFile); @@ -8835,11 +8835,11 @@ OWiMinMax_Fixer( else if (UUrString_Compare_NoCase(OScAmbientSuffix, BFrFileRef_GetSuffixName(&ref)) == 0) { SStAmbient *ambient; - + UUrString_Copy(name, BFrFileRef_GetLeafName(&ref), BFcMaxFileNameLength); UUrString_StripExtension(name); UUrString_MakeLowerCase(name, BFcMaxFileNameLength); - + ambient = OSrAmbient_GetByName(name); if ((ambient != NULL) && (ambient->min_volume_distance < ambient->max_volume_distance)) @@ -8850,13 +8850,13 @@ OWiMinMax_Fixer( out_string, "Ambient sound file %s needs to be modified, but the file is locked." UUmNL, BFrFileRef_GetLeafName(&ref)); - + WMrDialog_MessageBox( NULL, "Error", out_string, WMcMessageBoxStyle_OK); - + sprintf(out_string, "File is locked, %s" UUmNL, BFrFileRef_GetLeafName(&ref)); BFrFile_Write(inFile, strlen(out_string), out_string); } @@ -8865,9 +8865,9 @@ OWiMinMax_Fixer( temp_distance = ambient->min_volume_distance; ambient->min_volume_distance = ambient->max_volume_distance; ambient->max_volume_distance = temp_distance; - + OSrAmbient_Save(ambient, inDirectoryRef); - + sprintf(out_string, "%s" UUmNL, BFrFileRef_GetLeafName(&ref)); BFrFile_Write(inFile, strlen(out_string), out_string); } @@ -8876,11 +8876,11 @@ OWiMinMax_Fixer( else if (UUrString_Compare_NoCase(OScImpulseSuffix, BFrFileRef_GetSuffixName(&ref)) == 0) { SStImpulse *impulse; - + UUrString_Copy(name, BFrFileRef_GetLeafName(&ref), BFcMaxFileNameLength); UUrString_StripExtension(name); UUrString_MakeLowerCase(name, BFcMaxFileNameLength); - + impulse = OSrImpulse_GetByName(name); if ((impulse != NULL) && (impulse->min_volume_distance < impulse->max_volume_distance)) @@ -8891,13 +8891,13 @@ OWiMinMax_Fixer( out_string, "Impulse sound file %s needs to be modified, but the file is locked." UUmNL, BFrFileRef_GetLeafName(&ref)); - + WMrDialog_MessageBox( NULL, "Error", out_string, WMcMessageBoxStyle_OK); - + sprintf(out_string, "File is locked, %s" UUmNL, BFrFileRef_GetLeafName(&ref)); BFrFile_Write(inFile, strlen(out_string), out_string); } @@ -8906,7 +8906,7 @@ OWiMinMax_Fixer( temp_distance = impulse->min_volume_distance; impulse->min_volume_distance = impulse->max_volume_distance; impulse->max_volume_distance = temp_distance; - + OSrImpulse_Save(impulse, inDirectoryRef); sprintf(out_string, "%s" UUmNL, BFrFileRef_GetLeafName(&ref)); @@ -8915,7 +8915,7 @@ OWiMinMax_Fixer( } } } - + if (file_iterator != NULL) { BFrDirectory_FileIterator_Delete(file_iterator); @@ -8934,26 +8934,26 @@ OWrMinMax_Fixer( BFtFileRef *binary_dir_ref; BFtFileRef *file_ref; BFtFile *file; - + // get the binary director reference error = OSrGetSoundBinaryDirectory(&binary_dir_ref); if (error != UUcError_None) { goto handle_error; } - + // make file ref error = BFrFileRef_MakeFromName("MinMaxDistFixes.txt", &file_ref); if (error != UUcError_None) { goto handle_error; } - + // create file if it doesn't exist if (BFrFileRef_FileExists(file_ref) == UUcFalse) { error = BFrFile_Create(file_ref); if (error != UUcError_None) { goto handle_error; } } - + // open the file error = BFrFile_Open(file_ref, "rw", &file); if (error != UUcError_None) { goto handle_error; } - + // set the position to 0 error = BFrFile_SetPos(file, 0); if (error != UUcError_None) { goto handle_error; } @@ -8961,23 +8961,23 @@ OWrMinMax_Fixer( // process the binary files error = OWiMinMax_Fixer(binary_dir_ref, file); if (error != UUcError_None) { goto handle_error; } - + // close the file BFrFile_Close(file); file = NULL; - + // delete the file ref BFrFileRef_Dispose(file_ref); file_ref = NULL; - + WMrDialog_MessageBox( NULL, "Success", "The Min/Max distance have been fixed", WMcMessageBoxStyle_OK); - + goto exit; - + handle_error: if (error != UUcError_None) { @@ -8987,14 +8987,14 @@ OWrMinMax_Fixer( "Unable to process the ambient and impulse files.", WMcMessageBoxStyle_OK); } - + exit: if (binary_dir_ref != NULL) { BFrFileRef_Dispose(binary_dir_ref); binary_dir_ref = NULL; } - + return error; } @@ -9006,7 +9006,7 @@ OWiSpeech_Fixer( { UUtError error; BFtFileIterator *file_iterator; - + // go through all of the ambient sounds and fix the ones whose // max volume distance is less than the min volume distance error = @@ -9016,16 +9016,16 @@ OWiSpeech_Fixer( NULL, &file_iterator); UUmError_ReturnOnError(error); - + while (1) { BFtFileRef ref; char name[BFcMaxFileNameLength]; char out_string[1024]; - + error = BFrDirectory_FileIterator_Next(file_iterator, &ref); if (error != UUcError_None) { break; } - + if (BFrFileRef_IsDirectory(&ref)) { OWiSpeech_Fixer(&ref, inFile); @@ -9034,14 +9034,14 @@ OWiSpeech_Fixer( { SStAmbient *ambient; UUtUns32 flags; - + UUrString_Copy(name, BFrFileRef_GetLeafName(&ref), BFcMaxFileNameLength); UUrString_StripExtension(name); UUrString_MakeLowerCase(name, BFcMaxFileNameLength); - + ambient = OSrAmbient_GetByName(name); if (ambient == NULL) { continue; } - + if ((ambient->min_volume_distance == 10.0f) && (ambient->max_volume_distance == 1.0f)) { if (BFrFileRef_IsLocked(&ref) == UUcTrue) @@ -9050,30 +9050,30 @@ OWiSpeech_Fixer( out_string, "Ambient sound file %s needs to be modified, but the file is locked." UUmNL, BFrFileRef_GetLeafName(&ref)); - + WMrDialog_MessageBox( NULL, "Error", out_string, WMcMessageBoxStyle_OK); - + sprintf(out_string, "File is locked, %s" UUmNL, BFrFileRef_GetLeafName(&ref)); BFrFile_Write(inFile, strlen(out_string), out_string); - + continue; } else { ambient->min_volume_distance = 50.0f; ambient->max_volume_distance = 10.0f; - + OSrAmbient_Save(ambient, inDirectoryRef); - + sprintf(out_string, "%s" UUmNL, BFrFileRef_GetLeafName(&ref)); BFrFile_Write(inFile, strlen(out_string), out_string); } } - + flags = (SScAmbientFlag_InterruptOnStop | SScAmbientFlag_PlayOnce); if (((ambient->flags & flags) == flags) && (ambient->priority != SScPriority2_Highest)) { @@ -9083,31 +9083,31 @@ OWiSpeech_Fixer( out_string, "Ambient sound file %s needs to be modified, but the file is locked." UUmNL, BFrFileRef_GetLeafName(&ref)); - + WMrDialog_MessageBox( NULL, "Error", out_string, WMcMessageBoxStyle_OK); - + sprintf(out_string, "File is locked, %s" UUmNL, BFrFileRef_GetLeafName(&ref)); BFrFile_Write(inFile, strlen(out_string), out_string); - + continue; } else { ambient->priority = SScPriority2_Highest; - + OSrAmbient_Save(ambient, inDirectoryRef); - + sprintf(out_string, "%s" UUmNL, BFrFileRef_GetLeafName(&ref)); BFrFile_Write(inFile, strlen(out_string), out_string); } } } } - + if (file_iterator != NULL) { BFrDirectory_FileIterator_Delete(file_iterator); @@ -9126,26 +9126,26 @@ OWrSpeech_Fixer( BFtFileRef *binary_dir_ref; BFtFileRef *file_ref; BFtFile *file; - + // get the binary director reference error = OSrGetSoundBinaryDirectory(&binary_dir_ref); if (error != UUcError_None) { goto handle_error; } - + // make file ref error = BFrFileRef_MakeFromName("SpeechFixes.txt", &file_ref); if (error != UUcError_None) { goto handle_error; } - + // create file if it doesn't exist if (BFrFileRef_FileExists(file_ref) == UUcFalse) { error = BFrFile_Create(file_ref); if (error != UUcError_None) { goto handle_error; } } - + // open the file error = BFrFile_Open(file_ref, "rw", &file); if (error != UUcError_None) { goto handle_error; } - + // set the position to 0 error = BFrFile_SetPos(file, 0); if (error != UUcError_None) { goto handle_error; } @@ -9153,23 +9153,23 @@ OWrSpeech_Fixer( // process the binary files error = OWiSpeech_Fixer(binary_dir_ref, file); if (error != UUcError_None) { goto handle_error; } - + // close the file BFrFile_Close(file); file = NULL; - + // delete the file ref BFrFileRef_Dispose(file_ref); file_ref = NULL; - + WMrDialog_MessageBox( NULL, "Success", "The speech ambients have been fixed", WMcMessageBoxStyle_OK); - + goto exit; - + handle_error: if (error != UUcError_None) { @@ -9179,14 +9179,14 @@ OWrSpeech_Fixer( "Unable to process the speech ambient files.", WMcMessageBoxStyle_OK); } - + exit: if (binary_dir_ref != NULL) { BFrFileRef_Dispose(binary_dir_ref); binary_dir_ref = NULL; } - + return error; } diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound2.h b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound2.h index d0863fe..b48cba6 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound2.h +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Sound2.h @@ -25,7 +25,7 @@ typedef enum OWtSMType OWcSMType_Ambient, OWcSMType_Group, OWcSMType_Impulse - + } OWtSMType; typedef enum OWtSelectResult @@ -33,7 +33,7 @@ typedef enum OWtSelectResult OWcSelectResult_Cancel, OWcSelectResult_Select, OWcSelectResult_None - + } OWtSelectResult; // ====================================================================== @@ -42,13 +42,13 @@ typedef enum OWtSelectResult void OWrSound2_Terminate( void); - + // ---------------------------------------------------------------------- UUtError OWrImpulseProperties_Display( WMtDialog *inParentDialog, SStImpulse *inImpulse); - + // ---------------------------------------------------------------------- UUtError OWrSM_Display( @@ -58,30 +58,30 @@ OWrSM_Display( OWtSelectResult OWrSelect_AmbientSound( SStAmbient **outAmbient); - + OWtSelectResult OWrSelect_SoundGroup( SStGroup **outGroup); - + OWtSelectResult OWrSelect_ImpulseSound( SStImpulse **outImpulse); - + // ---------------------------------------------------------------------- UUtError OWrAmbientProperties_Display( WMtDialog *inParentDialog, SStAmbient *inAmbient); - + UUtError OWrSoundToAnim_Display( void); - + // ---------------------------------------------------------------------- UUtError OWrCreateDialogue_Display( void); - + UUtError OWrCreateImpulse_Display( void); @@ -102,6 +102,6 @@ OWrMinMax_Fixer( UUtError OWrSpeech_Fixer( void); - + // ====================================================================== -#endif /* ONI_WIN_SOUND2_H */ \ No newline at end of file +#endif /* ONI_WIN_SOUND2_H */ diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_TextureMaterials.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_TextureMaterials.c index 5259a66..d2fe005 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_TextureMaterials.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_TextureMaterials.c @@ -39,17 +39,17 @@ OWiTtM_InitDialog( UUtError error; UUtUns32 i; WMtWindow *listbox; - + // get the number of textures num_textures = TMrInstance_GetTagCount(M3cTemplate_TextureMap); if (num_textures == 0) { return UUcError_Generic; } - + // allocate memory to hold the list of textures texture_list = (M3tTextureMap**)UUrMemory_Block_New(sizeof(M3tTextureMap*) * num_textures); if (texture_list == NULL) { return UUcError_Generic; } - + WMrDialog_SetUserData(inDialog, (UUtUns32)texture_list); - + // get a list of the textures error = TMrInstance_GetDataPtr_List( @@ -58,27 +58,27 @@ OWiTtM_InitDialog( &num_textures, texture_list); UUmError_ReturnOnError(error); - + // put the textures into the listbox listbox = WMrDialog_GetItemByID(inDialog, OWcTtM_LB_Textures); for (i = 0; i < num_textures; i++) { WMrMessage_Send(listbox, LBcMessage_AddString, i, 0); } - + // select the first item in the list WMrListBox_SetSelection(listbox, UUcTrue, 0); - + // fill the materials list listbox = WMrDialog_GetItemByID(inDialog, OWcTtM_LB_Materials); OWrIE_FillMaterialListBox(inDialog, listbox); - + // start a timer with a 1 minute frequency WMrTimer_Start(0, (60 * 60), inDialog); - + // set the focus WMrWindow_SetFocus(listbox); - + return UUcError_None; } @@ -88,13 +88,13 @@ OWiTtM_Destroy( WMtDialog *inDialog) { M3tTextureMap **texture_list; - + texture_list = (M3tTextureMap**)WMrDialog_GetUserData(inDialog); - + // stop the timer WMrTimer_Stop(0, inDialog); ONrTextureMaterialList_Save(UUcFalse); - + // delete the texture list UUrMemory_Block_Delete(texture_list); texture_list = NULL; @@ -113,53 +113,53 @@ OWiTtM_HandleCommand( WMtWindow *textures_listbox; M3tTextureMap **texture_list; M3tTextureMap *texture; - + // get pointers to the listboxes materials_listbox = WMrDialog_GetItemByID(inDialog, OWcTtM_LB_Materials); textures_listbox = WMrDialog_GetItemByID(inDialog, OWcTtM_LB_Textures); - + // get the selected texture index selected_texture = WMrListBox_GetSelection(textures_listbox); - + // get the pointer to the texture texture_list = (M3tTextureMap**)WMrDialog_GetUserData(inDialog); texture = texture_list[selected_texture]; - + switch (UUmLowWord(inParam1)) { case OWcTtM_LB_Textures: if (UUmHighWord(inParam1) != LBcNotify_SelectionChanged) { break; } - + // set the picture WMrPicture_SetPicture( WMrDialog_GetItemByID(inDialog, OWcTtM_PT_Picture), texture); - + // get the selected material selected_material = M3rTextureMap_GetMaterialType(texture); if (selected_material == MAcInvalidID) { selected_material = MAcMaterial_Base; } - + // select the material WMrListBox_SetSelection(materials_listbox, UUcFalse, selected_material); break; - + case OWcTtM_LB_Materials: if (UUmHighWord(inParam1) != LBcNotify_SelectionChanged) { break; } - + // get the selected material selected_material = (MAtMaterialType)WMrListBox_GetSelection(materials_listbox); - + // get a pointer to the texture ONrTextureMaterialList_TextureMaterial_Set( TMrInstance_GetInstanceName(texture), selected_material); break; - + case WMcDialogItem_Cancel: WMrDialog_ModalEnd(inDialog, 0); break; } - + return UUcError_None; } @@ -176,24 +176,24 @@ OWiTtM_HandleDrawItem( M3tTextureMap **texture_list; M3tTextureMap *texture; MAtMaterialType material_type; - + // get a pointer to the partspec_ui // partspec_ui = PSrPartSpecUI_GetActive(); // UUmAssert(partspec_ui); - + texture_list = (M3tTextureMap**)WMrDialog_GetUserData(inDialog); UUmAssert(texture_list); - + // set the dest dest.x = inDrawItem->rect.left; dest.y = inDrawItem->rect.top; - + // calc the width and height of the line line_width = inDrawItem->rect.right - inDrawItem->rect.left; line_height = inDrawItem->rect.bottom - inDrawItem->rect.top; - + dest.x = 5; - + // draw the texture name texture = texture_list[inDrawItem->data]; DCrDraw_String( @@ -201,14 +201,14 @@ OWiTtM_HandleDrawItem( TMrInstance_GetInstanceName(texture), &inDrawItem->rect, &dest); - + dest.x = 160; - + material_type = M3rTextureMap_GetMaterialType(texture); if (material_type != MAcMaterial_Base) { const char *name; - + name = MArMaterialType_GetName(material_type); if (name != NULL) { @@ -231,36 +231,36 @@ OWiTtM_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiTtM_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiTtM_Destroy(inDialog); break; - + case WMcMessage_Command: OWiTtM_HandleCommand(inDialog, inParam1, (WMtWindow*)inParam2); break; - + case WMcMessage_Timer: ONrTextureMaterialList_Save(UUcTrue); break; - + case WMcMessage_DrawItem: OWiTtM_HandleDrawItem(inDialog, (WMtDrawItem*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -270,7 +270,7 @@ OWrTextureToMaterial_Display( void) { UUtError error; - + error = WMrDialog_ModalBegin( OWcDialog_Texture_to_Material, @@ -279,8 +279,8 @@ OWrTextureToMaterial_Display( 0, NULL); UUmError_ReturnOnError(error); - + return UUcError_None; } -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_TextureMaterials.h b/OniProj/OniGameSource/Oni_Windows/Oni_Win_TextureMaterials.h index be05b4c..a192565 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_TextureMaterials.h +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_TextureMaterials.h @@ -19,4 +19,4 @@ OWrTextureToMaterial_Display( void); // ====================================================================== -#endif /* ONI_WIN_TEXTUREMATERIALS_H */ \ No newline at end of file +#endif /* ONI_WIN_TEXTUREMATERIALS_H */ diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Tools.c b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Tools.c index 9fe9be6..8930fc8 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Tools.c +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Tools.c @@ -50,7 +50,7 @@ typedef struct OWtEORevert OBJtObject *object; M3tPoint3D position; M3tPoint3D rotation; - + } OWtEORevert; typedef struct OWtEOPos @@ -62,20 +62,20 @@ typedef struct OWtEOPos M3tPoint3D position_current; M3tPoint3D rotation_current; - + } OWtEOPos; typedef struct OWtPTV { OBJtObject *object; - + UUtInt32 original_id; M3tPoint3D original_scale; - + UUtInt32 new_id; M3tPoint3D new_scale; - + } OWtPTV; @@ -83,14 +83,14 @@ typedef struct OWtCategory { UUtUns32 object_type; char name[OBJcMaxNameLength + 1]; - + } OWtCategory; typedef struct OWtColorPopup { char *name; IMtShade shade; - + } OWtColorPopup; typedef struct OWtLightProp @@ -99,7 +99,7 @@ typedef struct OWtLightProp UUtUns16 current_index; UUtUns32 num_ls_datas; OBJtLSData *ls_data_array; - + } OWtLightProp; typedef struct OWtCharListParams @@ -123,7 +123,7 @@ typedef struct OWtSoundProp OBJtObject *object; OBJtOSD_All osd; OBJtOSD_All backup_osd; - + } OWtSoundProp; // ====================================================================== @@ -154,10 +154,10 @@ static OWtColorPopup OWgColorPopup[] = }; static const char *AIgTeamList[] = { "konoko", "TCTF", "syndicate", "neutral", "security-guard", "rogue-konoko", "switzerland", "syndicate accessory", NULL }; -static const char *OWgTriggerVolumeFlagList[] = { - "", - "", - "", +static const char *OWgTriggerVolumeFlagList[] = { + "", + "", + "", "", "", "", @@ -189,18 +189,18 @@ OWiColorPopup_Init( { OWtColorPopup *data; UUtUns16 i; - + for (data = OWgColorPopup, i = 0; data->name != NULL; data++, i++) { UUtError error; WMtMenuItemData menu_item_data; - + menu_item_data.flags = WMcMenuItemFlag_Enabled; menu_item_data.id = i; UUrString_Copy(menu_item_data.title, data->name, WMcMaxTitleLength); - + error = WMrPopupMenu_AppendItem(inPopup, &menu_item_data); if (error != UUcError_None) { return; } } @@ -226,7 +226,7 @@ OWiColorPopup_SelectItemFromShade( { OWtColorPopup *data; UUtUns16 i; - + for (data = OWgColorPopup, i = 0; data->name != NULL; data++, i++) @@ -253,7 +253,7 @@ OWiEOPos_EnableButtons( { WMtWindow *button; UUtUns32 i; - + // enabled or disable the position buttons for (i = EOcBtn_LocX_Inc_0_1; i <= EOcBtn_LocZ_Dec_10_0; i++) { @@ -267,7 +267,7 @@ OWiEOPos_EnableButtons( button = WMrDialog_GetItemByID(inDialog, (UUtUns16)i); WMrWindow_SetEnabled(button, inEnabled); } - + // enable or disable the gravity button button = WMrDialog_GetItemByID(inDialog, EOcBtn_Gravity); WMrWindow_SetEnabled(button, inEnabled); @@ -282,17 +282,17 @@ OWiEOPos_GetValFromField( float value; WMtWindow *edit_field; char string[255]; - + value = 0.0f; - + // get the field edit_field = WMrDialog_GetItemByID(inDialog, inItemID); if (edit_field == NULL) { return value; } - + // get the value from the field WMrMessage_Send(edit_field, EFcMessage_GetText, (UUtUns32)string, 255); sscanf(string, "%f", &value); - + return value; } @@ -305,50 +305,50 @@ OWiEOPos_SetEditFields( WMtWindow *text_field; char string[255]; OWtEOPos *pos; - + // get pos pos = (OWtEOPos*)WMrDialog_GetUserData(inDialog); UUmAssert(pos); - + // absolute location edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_AbsLocX); sprintf(string, "%5.3f", pos->position_current.x); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); - + edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_AbsLocY); sprintf(string, "%5.3f", pos->position_current.y); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); - + edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_AbsLocZ); sprintf(string, "%5.3f", pos->position_current.z); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); - + // offset location edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_OffLocX); sprintf(string, "%5.3f", (pos->position_current.x - pos->position_original.x)); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); - + edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_OffLocY); sprintf(string, "%5.3f", (pos->position_current.y - pos->position_original.y)); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); - + edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_OffLocZ); sprintf(string, "%5.3f", (pos->position_current.z - pos->position_original.z)); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); - + // rotation edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_RotX); sprintf(string, "%5.3f", pos->rotation_current.x); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); - + edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_RotY); sprintf(string, "%5.3f", pos->rotation_current.y); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); - + edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_RotZ); sprintf(string, "%5.3f", pos->rotation_current.z); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); - + if (OBJrSelectedObjects_GetNumSelected() > 1) { text_field = WMrDialog_GetItemByID(inDialog, EOcTxt_RotType); @@ -372,7 +372,7 @@ OWiEOPos_OffsetPositions( { OBJtObject *object; M3tPoint3D position; - + object = OBJrSelectedObjects_GetSelectedObject(i); MUmVector_Add(position, object->position, *inPositionOffset); OBJrObject_SetPosition(object, &position, NULL); @@ -390,14 +390,14 @@ OWiEOPos_SetRotations( { UUtUns32 num_selected; OBJtObject *object; - + while (inRotation->x < 0.0f) { inRotation->x += 360.0f; } while (inRotation->y < 0.0f) { inRotation->y += 360.0f; } while (inRotation->z < 0.0f) { inRotation->z += 360.0f; } while (inRotation->x >= 360.0f) { inRotation->x -= 360.0f; } while (inRotation->y >= 360.0f) { inRotation->y -= 360.0f; } while (inRotation->z >= 360.0f) { inRotation->z -= 360.0f; } - + num_selected = OBJrSelectedObjects_GetNumSelected(); if (num_selected > 1) { @@ -406,12 +406,12 @@ OWiEOPos_SetRotations( float x_rad; float y_rad; float z_rad; - + // inRotation is an offset from the current rotation x_rad = inRotation->x * M3cDegToRad; y_rad = inRotation->y * M3cDegToRad; z_rad = inRotation->z * M3cDegToRad; - + MUrMatrix_Identity(&rotation_matrix); if (inRevert) { @@ -425,25 +425,25 @@ OWiEOPos_SetRotations( MUrMatrix_RotateY(&rotation_matrix, y_rad); MUrMatrix_RotateZ(&rotation_matrix, z_rad); } - + for (i = 0; i < num_selected; i++) { M3tPoint3D delta; M3tPoint3D position; M3tMatrix4x3 object_rotation_matrix; M3tMatrix4x3 rotation_result; - + object = OBJrSelectedObjects_GetSelectedObject(i); MUmVector_Subtract(delta, object->position, inPos->position_current); - + MUrMatrix_MultiplyPoint(&delta, &rotation_matrix, &position); MUmVector_Increment(position, inPos->position_current); - + OBJrObject_GetRotationMatrix(object, &object_rotation_matrix); MUrMatrix_Multiply(&rotation_matrix, &object_rotation_matrix, &rotation_result); - + OBJrObject_SetRotationMatrix(object, &rotation_result); - + OBJrObject_SetPosition(object, &position,NULL); } } @@ -464,32 +464,32 @@ OWiEOPos_Apply( M3tPoint3D position; M3tPoint3D rotation; M3tPoint3D delta; - + // get the position position.x = OWiEOPos_GetValFromField(inDialog, EOcEF_AbsLocX); position.y = OWiEOPos_GetValFromField(inDialog, EOcEF_AbsLocY); position.z = OWiEOPos_GetValFromField(inDialog, EOcEF_AbsLocZ); - + // calculate the difference in the typed in position and the current position MUmVector_Subtract(delta, position, inPos->position_current); - + // save the new position MUmVector_Copy(inPos->position_current, position); - + // offset the position of the objects OWiEOPos_OffsetPositions(&delta); - + // get the rotation rotation.x = OWiEOPos_GetValFromField(inDialog, EOcEF_RotX); rotation.y = OWiEOPos_GetValFromField(inDialog, EOcEF_RotY); rotation.z = OWiEOPos_GetValFromField(inDialog, EOcEF_RotZ); - + // calculate the difference in the typed in rotation and the current rotation MUmVector_Subtract(delta, rotation, inPos->rotation_current); - + // save the new rotation MUmVector_Copy(inPos->rotation_current, rotation); - + // offset the rotation of the objets OWiEOPos_SetRotations(inPos, &delta, UUcFalse); @@ -507,9 +507,9 @@ OWiEOPos_ContentChanged( float new_value; WMtWindow *edit_field; char string[128]; - + new_value = OWiEOPos_GetValFromField(inDialog, inControlID); - + switch (inControlID) { case EOcEF_AbsLocX: @@ -517,37 +517,37 @@ OWiEOPos_ContentChanged( sprintf(string, "%5.3f", (new_value - inPos->position_original.x)); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); break; - + case EOcEF_AbsLocY: edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_OffLocY); sprintf(string, "%5.3f", (new_value - inPos->position_original.y)); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); break; - + case EOcEF_AbsLocZ: edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_OffLocZ); sprintf(string, "%5.3f", (new_value - inPos->position_original.z)); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); break; - + case EOcEF_OffLocX: edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_AbsLocX); sprintf(string, "%5.3f", (inPos->position_original.x + new_value)); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); break; - + case EOcEF_OffLocY: edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_AbsLocY); sprintf(string, "%5.3f", (inPos->position_original.y + new_value)); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); break; - + case EOcEF_OffLocZ: edit_field = WMrDialog_GetItemByID(inDialog, EOcEF_AbsLocZ); sprintf(string, "%5.3f", (inPos->position_original.z + new_value)); WMrMessage_Send(edit_field, EFcMessage_SetText, (UUtUns32)string, 0); break; - + case EOcEF_RotX: case EOcEF_RotY: case EOcEF_RotZ: @@ -567,9 +567,9 @@ OWiEOPos_Gravity( UUtBool result; M3tVector3D vector; M3tPoint3D delta; - + MUmVector_Set(vector, 0.0f, -50000.0f, 0.0f); - + // calculate the intersection with the floor result = AKrCollision_Point( @@ -579,14 +579,14 @@ OWiEOPos_Gravity( AKcGQ_Flag_Obj_Col_Skip, AKcMaxNumCollisions); if (result == UUcFalse) { return; } - + // set the new position of the object MUmVector_Set(delta, 0.0f, (AKgCollisionList[0].collisionPoint.y - inPos->position_current.y), 0.0f); OWiEOPos_OffsetPositions(&delta); - + // update the position MUmVector_Increment(inPos->position_current, delta); - + // update the edit fields OWiEOPos_SetEditFields(inDialog); } @@ -599,26 +599,26 @@ OWiEOPos_Revert( { UUtUns32 i; OWtEORevert *revert_array; - + if (inPos->revert == NULL) { return; } - + // revert all of the objects to their original rotation and position revert_array = (OWtEORevert*)UUrMemory_Array_GetMemory(inPos->revert); for (i = 0; i < UUrMemory_Array_GetUsedElems(inPos->revert); i++) { OBJrObject_SetPosition( - revert_array[i].object, + revert_array[i].object, &revert_array[i].position, &revert_array[i].rotation); } - + // reset the current position and rotation MUmVector_Copy(inPos->position_current, inPos->position_original); MUmVector_Copy(inPos->rotation_current, inPos->rotation_original); - + // update the edit fields OWiEOPos_SetEditFields(inDialog); - + // disable the position buttons OWiEOPos_EnableButtons(inDialog, UUcTrue); } @@ -633,18 +633,18 @@ OWiEOPos_InitDialog( UUtUns32 num_selected; UUtUns32 i; UUtRect window_rect; - + num_selected = OBJrSelectedObjects_GetNumSelected(); // move the dialog to the left hand side of the screen WMrWindow_GetRect(inDialog, &window_rect); WMrWindow_SetLocation(inDialog, 0, window_rect.top); - + // allocate memory for the pos pos = (OWtEOPos*)UUrMemory_Block_NewClear(sizeof(OWtEOPos)); UUmAssert(pos); WMrDialog_SetUserData(inDialog, (UUtUns32)pos); - + // initialize the vars pos->revert = UUrMemory_Array_New( @@ -663,7 +663,7 @@ OWiEOPos_InitDialog( else { OWtEORevert *revert_array; - + revert_array = (OWtEORevert*)UUrMemory_Array_GetMemory(pos->revert); for (i = 0; i < num_selected; i++) { @@ -672,37 +672,37 @@ OWiEOPos_InitDialog( OBJrObject_GetPosition(object, &revert_array[i].position, &revert_array[i].rotation); } } - + MUmVector_Set(pos->position_original, 0.0f, 0.0f, 0.0f); MUmVector_Set(pos->rotation_original, 0.0f, 0.0f, 0.0f); MUmVector_Set(pos->position_current, 0.0f, 0.0f, 0.0f); MUmVector_Set(pos->rotation_current, 0.0f, 0.0f, 0.0f); - + // get the center of the selected objects and store the revert information for (i = 0; i < num_selected; i++) { object = OBJrSelectedObjects_GetSelectedObject(i); MUmVector_Increment(pos->position_original, object->position); } - + pos->position_original.x /= num_selected; pos->position_original.y /= num_selected; pos->position_original.z /= num_selected; - + // set the rotation if (num_selected == 1) { object = OBJrSelectedObjects_GetSelectedObject(0); MUmVector_Copy(pos->rotation_original, object->rotation); } - + // set the current position and rotation MUmVector_Copy(pos->position_current, pos->position_original); MUmVector_Copy(pos->rotation_current, pos->rotation_original); - + // update the edit fields - OWiEOPos_SetEditFields(inDialog); + OWiEOPos_SetEditFields(inDialog); } // ---------------------------------------------------------------------- @@ -711,7 +711,7 @@ OWiEOPos_Destroy( WMtDialog *inDialog) { OWtEOPos *pos; - + // get a pointer to the pos pos = (OWtEOPos*)WMrDialog_GetUserData(inDialog); if (pos) @@ -721,11 +721,11 @@ OWiEOPos_Destroy( UUrMemory_Array_Delete(pos->revert); pos->revert = NULL; } - + UUrMemory_Block_Delete(pos); WMrDialog_SetUserData(inDialog, 0); } - + OWgDialog_Pos = NULL; } @@ -737,21 +737,21 @@ OWiEOPos_HandleCommand( UUtUns32 inParam2) { OWtEOPos *pos; - + // get a pointer to the pos pos = (OWtEOPos*)WMrDialog_GetUserData(inDialog); UUmAssert(pos); - + if (UUmHighWord(inParam1) == WMcNotify_Click) { UUtUns16 field; UUtBool update; float val; - + field = 0; update = UUcTrue; val = 0.0f; - + switch (UUmLowWord(inParam1)) { // Location @@ -778,7 +778,7 @@ OWiEOPos_HandleCommand( case EOcBtn_LocX_Dec_10_0: field = EOcEF_AbsLocX; val = -10.0f; break; case EOcBtn_LocY_Dec_10_0: field = EOcEF_AbsLocY; val = -10.0f; break; case EOcBtn_LocZ_Dec_10_0: field = EOcEF_AbsLocZ; val = -10.0f; break; - + // Rotation case EOcBtn_RotX_Inc_1: field = EOcEF_RotX; val = 1.0f; break; case EOcBtn_RotY_Inc_1: field = EOcEF_RotY; val = 1.0f; break; @@ -803,12 +803,12 @@ OWiEOPos_HandleCommand( case EOcBtn_RotX_Dec_90: field = EOcEF_RotX; val = -90.0f; break; case EOcBtn_RotY_Dec_90: field = EOcEF_RotY; val = -90.0f; break; case EOcBtn_RotZ_Dec_90: field = EOcEF_RotZ; val = -90.0f; break; - + // buttons case EOcBtn_Revert: OWiEOPos_Revert(inDialog, pos); break; - + case EOcBtn_Gravity: OWiEOPos_Gravity(inDialog, pos); break; @@ -817,41 +817,41 @@ OWiEOPos_HandleCommand( OWiEOPos_Apply(inDialog, pos); update = UUcFalse; break; - + case WMcDialogItem_Cancel: WMrWindow_Delete(inDialog); update = UUcFalse; break; - + default: update = UUcFalse; break; } - + if (update) { M3tPoint3D delta_position; M3tPoint3D delta_rotation; - + // calculate the delta_position and delta_rotation MUmVector_Set(delta_position, 0.0f, 0.0f, 0.0f); MUmVector_Set(delta_rotation, 0.0f, 0.0f, 0.0f); - + switch (field) { case EOcEF_AbsLocX: delta_position.x += val; break; case EOcEF_AbsLocY: delta_position.y += val; break; case EOcEF_AbsLocZ: delta_position.z += val; break; - + case EOcEF_RotX: delta_rotation.x += val; break; case EOcEF_RotY: delta_rotation.y += val; break; case EOcEF_RotZ: delta_rotation.z += val; break; } - + // adjust the current position and rotation MUmVector_Increment(pos->position_current, delta_position); MUmVector_Increment(pos->rotation_current, delta_rotation); - + // check rotation ranges while (pos->rotation_current.x < 0.0f) { pos->rotation_current.x += 360.0f; } while (pos->rotation_current.y < 0.0f) { pos->rotation_current.y += 360.0f; } @@ -859,13 +859,13 @@ OWiEOPos_HandleCommand( while (pos->rotation_current.x >= 360.0f) { pos->rotation_current.x -= 360.0f; } while (pos->rotation_current.y >= 360.0f) { pos->rotation_current.y -= 360.0f; } while (pos->rotation_current.z >= 360.0f) { pos->rotation_current.z -= 360.0f; } - + // offset the selected object positions OWiEOPos_OffsetPositions(&delta_position); - + // set the selected object rotations OWiEOPos_SetRotations(pos, &delta_rotation, UUcFalse); - + // update the edit fields OWiEOPos_SetEditFields(inDialog); } @@ -885,28 +885,28 @@ OWiEOPos_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiEOPos_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiEOPos_Destroy(inDialog); return UUcFalse; - + case WMcMessage_Command: OWiEOPos_HandleCommand(inDialog, inParam1, inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -916,14 +916,14 @@ OWrEOPos_Display( void) { UUtError error; - + if ((OWgDialog_Pos == NULL) && (OWgDialog_Prop == NULL)) { // create the dialog error = WMrDialog_Create(OWcDialog_EditObjectPos, NULL, OWiEOPos_Callback, (UUtUns32) -1, &OWgDialog_Pos); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -933,7 +933,7 @@ OWrEOPos_IsVisible( void) { if (OWgDialog_Pos == NULL) { return UUcFalse; } - + return WMrWindow_GetVisible(OWgDialog_Pos); } @@ -949,14 +949,14 @@ OWiObjNew_CreateObject( { WMtWindow *popup; UUtUns16 item_id; - + // get the popup menu popup = WMrDialog_GetItemByID(inDialog, NOcPM_Category); if (popup == NULL) { return UUcError_Generic; } - + // get the item id of the currently selected menu item WMrPopupMenu_GetItemID(popup, (UUtUns16)(-1), &item_id); - + return OWrTools_CreateObject(OWgCategories[item_id].object_type, NULL); } @@ -967,27 +967,27 @@ OWiObjNew_InitDialog( { WMtWindow *popup; UUtUns16 i; - + // get the popup popup = WMrDialog_GetItemByID(inDialog, NOcPM_Category); if (popup == NULL) { return; } - + // fill in the categories for (i = 0; i < OWgNumCategories; i++) { WMtMenuItemData item_data; - + if (OWgCategories[i].name[0] == '\0') { continue; } - + // setup the item data item_data.flags = WMcMenuItemFlag_Enabled; item_data.id = i; UUrString_Copy(item_data.title, OWgCategories[i].name, WMcMaxTitleLength); - + // add the item to the popup menu WMrPopupMenu_AppendItem(popup, &item_data); } - + // select the first item in the popup WMrPopupMenu_SetSelection(popup, 0); } @@ -1008,7 +1008,7 @@ OWiObjNew_HandleCommand( { UUtBool object_created; OBJtObject *object; - + // create the object error = OWiObjNew_CreateObject(inDialog); @@ -1018,7 +1018,7 @@ OWiObjNew_HandleCommand( if (error == UUcError_None) { // get the object to work on object = OBJrSelectedObjects_GetSelectedObject(0); - + // display the properties dialog object_created = OWrProp_Display(object); @@ -1028,7 +1028,7 @@ OWiObjNew_HandleCommand( } } break; - + case WMcDialogItem_Cancel: WMrWindow_Delete(inDialog); break; @@ -1044,28 +1044,28 @@ OWiObjNew_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiObjNew_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWgDialog_ObjNew = NULL; break; - + case WMcMessage_Command: OWiObjNew_HandleCommand(inDialog, inParam1, inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -1075,15 +1075,15 @@ OWrObjNew_Display( void) { UUtError error; - + if ((OWgDialog_Pos == NULL) && (OWgDialog_Prop == NULL)) { // create the new object dialog - error = WMrDialog_Create(OWcDialog_ObjNew, NULL, OWiObjNew_Callback, (UUtUns32) -1, &OWgDialog_ObjNew); + error = WMrDialog_Create(OWcDialog_ObjNew, NULL, OWiObjNew_Callback, (UUtUns32) -1, &OWgDialog_ObjNew); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -1093,7 +1093,7 @@ OWrObjNew_IsVisible( void) { if (OWgDialog_ObjNew == NULL) { return UUcFalse; } - + return WMrWindow_GetVisible(OWgDialog_ObjNew); } // ====================================================================== @@ -1114,7 +1114,7 @@ static void OWiProp_Event_InitDialog( WMtDialog *inDialog ) ONtEventDescription *desc; char value[100]; char label[100]; - + event = (ONtEvent*)WMrDialog_GetUserData(inDialog); UUmAssert( event ); @@ -1138,7 +1138,7 @@ static void OWiProp_Event_InitDialog( WMtDialog *inDialog ) default: UUmAssert( UUcFalse ); } - + WMrWindow_SetTitle( (WMtWindow*) inDialog, "Event Properties", 32 ); window = WMrDialog_GetItemByID(inDialog, PEcEF_Type); UUmAssert( window ); @@ -1208,8 +1208,8 @@ static void OWiProp_Event_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam1, } // close the dialog WMrDialog_ModalEnd(inDialog, UUcTrue ); - break; - + break; + case WMcDialogItem_Cancel: WMrDialog_ModalEnd( inDialog, UUcFalse ); break; @@ -1222,9 +1222,9 @@ static void OWiProp_Event_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam1, static UUtBool OWiProp_Event_Callback( WMtDialog *inDialog, WMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -1233,16 +1233,16 @@ static UUtBool OWiProp_Event_Callback( WMtDialog *inDialog, WMtMessage inMessage //case WMcMessage_Destroy: //break; - + case WMcMessage_Command: OWiProp_Event_HandleCommand(inDialog, inParam1, inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } #endif @@ -1253,7 +1253,7 @@ static UUtBool OWiProp_Event_Display(ONtEvent* inEvent) { UUtError error; UUtUns32 return_val; - error = WMrDialog_ModalBegin(OWcDialog_Prop_Event, NULL, OWiProp_Event_Callback, (UUtUns32) inEvent, (UUtUns32*) &return_val ); + error = WMrDialog_ModalBegin(OWcDialog_Prop_Event, NULL, OWiProp_Event_Callback, (UUtUns32) inEvent, (UUtUns32*) &return_val ); UUmAssert( error == UUcError_None ); if( !return_val || error != UUcError_None ) return UUcFalse; @@ -1280,7 +1280,7 @@ static UUtBool OWiEvent_EnumEventTypes( const char *inName, UUtUns32 inUserData dlg = (OWtStringListDlgInstance*) inUserData; OWrStringListDialog_AddString( dlg, (char*) inName ); - + return UUcTrue; } #endif @@ -1310,7 +1310,7 @@ static UUtBool OWrEventList_NewEvent( ONtEventList* inEventList, WMtWindow* inWi OWrStringListDialog_DoModal( &dlg ); OWrStringListDialog_Destroy( &dlg ); - + if( !dlg.return_value || dlg.selected_index == -1 ) return UUcFalse; @@ -1322,15 +1322,15 @@ static UUtBool OWrEventList_NewEvent( ONtEventList* inEventList, WMtWindow* inWi if( !OWiProp_Event_Display( &event ) ) { - return UUcFalse; + return UUcFalse; } ONrEventList_AddEvent( inEventList, &event ); - + ONrEvent_GetName( &event, name, 100 ); WMrMessage_Send( inWindow, LBcMessage_AddString, (UUtUns32) name, 0); - + WMrWindow_SetFocus(inWindow); return UUcTrue; @@ -1345,8 +1345,8 @@ static UUtBool OWrEventList_DeleteEvent( ONtEventList* inEventList, WMtWindow* i UUmAssert( inEventList && inWindow ); selection = WMrMessage_Send( inWindow, LBcMessage_GetSelection, (UUtUns32)-1, (UUtUns32)-1 ); - - if( selection == LBcError) + + if( selection == LBcError) return UUcFalse; UUmAssert( selection <= inEventList->event_count ); @@ -1371,8 +1371,8 @@ static UUtBool OWrEventList_EditEvent( ONtEventList* inEventList, WMtWindow* inW UUmAssert( inEventList && inWindow ); selection = WMrMessage_Send( inWindow, LBcMessage_GetSelection, (UUtUns32)-1, (UUtUns32)-1 ); - - if( selection == LBcError) + + if( selection == LBcError) return UUcFalse; UUmAssert( selection < inEventList->event_count ); @@ -1493,15 +1493,15 @@ static void OWiProp_Door_SetFields( WMtDialog *inDialog ) static UUtBool OWiListBox_DoorType_EnumCallback( const char *inName, UUtUns32 inUserData ) { WMtWindow *window; - + UUmAssert( inUserData ); window = (WMtWindow*)inUserData; if (!window) return UUcFalse; - + WMrMessage_Send( window, LBcMessage_AddString, (UUtUns32) inName, 0); - + return UUcTrue; } #endif @@ -1513,7 +1513,7 @@ static void OWiProp_Door_SelectItem( WMtDialog *inDialog ) WMtWindow *window; OBJtObject *object; OBJtOSD_All *osd; - + // get a pointer to the osd osd = (OBJtOSD_All*)WMrDialog_GetUserData(inDialog); UUmAssert(osd); @@ -1525,7 +1525,7 @@ static void OWiProp_Door_SelectItem( WMtDialog *inDialog ) // get the currently selected object object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return; } - + // get the name of the selected object specific type if( !osd->osd.door_osd.door_class_name[0] ) { @@ -1554,7 +1554,7 @@ static UUtBool OWiListBox_DoorTextures_EnumCallback( const char *inName, UUtUns3 menu_item_data.flags = WMcMenuItemFlag_Enabled; menu_item_data.id = id++; UUrString_Copy(menu_item_data.title, inName, WMcMaxTitleLength); - + window = WMrDialog_GetItemByID( dialog, PDcPM_Texture0 ); UUmAssert( window ); error = WMrPopupMenu_AppendItem(window, &menu_item_data); @@ -1575,21 +1575,21 @@ static void OWiProp_Door_InitDialog( WMtDialog *inDialog ) OBJtObjectType object_type; OBJtOSD_All *osd; WMtWindow *editfield; - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, PDcLB_DoorTypes); if (listbox == NULL) { return; } - + // get the currently selected object object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return; } - + // get the object type object_type = OBJrObject_GetType(object); - + WMrMessage_Send( listbox, LBcMessage_AddString, (UUtUns32) "", 0); - // enumerate the object specific types + // enumerate the object specific types OBJrObject_Enumerate( object, OWiListBox_DoorType_EnumCallback, (UUtUns32)listbox); // enum the textures @@ -1619,7 +1619,7 @@ static void OWiProp_Door_InitDialog( WMtDialog *inDialog ) // set the keyboard focus to the listbox WMrWindow_SetFocus(listbox); - + // hilite the item currently in use OWiProp_Door_SelectItem(inDialog); @@ -1638,7 +1638,7 @@ static UUtError OWiProp_Door_SaveOSD( WMtDialog *inDialog ) UUtUns32 temp_int; float temp_float; char string[OBJcMaxNoteChars + 1]; - UUtUns32 result; + UUtUns32 result; OBJtOSD_Door *door_osd; UUtUns16 id; @@ -1647,10 +1647,10 @@ static UUtError OWiProp_Door_SaveOSD( WMtDialog *inDialog ) WMrDialog_MessageBox(inDialog, "Error", "The Door file is locked.", WMcMessageBoxStyle_OK); return UUcError_None; } - + // get a pointer to the object object = OBJrSelectedObjects_GetSelectedObject(0); - UUmAssert(object); + UUmAssert(object); // grab the temp OSD door_osd = (OBJtOSD_Door*)WMrDialog_GetUserData(inDialog); @@ -1675,19 +1675,19 @@ static UUtError OWiProp_Door_SaveOSD( WMtDialog *inDialog ) // id window = WMrDialog_GetItemByID(inDialog, PDcEF_ID); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 6); - sscanf(string, "%d", &temp_int ); + sscanf(string, "%d", &temp_int ); osd_all.osd.door_osd.id = (UUtUns16) temp_int; // key id window = WMrDialog_GetItemByID(inDialog, PDcEF_KeyID); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 6); - sscanf(string, "%d", &temp_int ); + sscanf(string, "%d", &temp_int ); osd_all.osd.door_osd.key_id = (UUtUns16) temp_int; // activation radius window = WMrDialog_GetItemByID(inDialog, PDcEF_ActivationRadius); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 6); - sscanf(string, "%f", &temp_float ); + sscanf(string, "%f", &temp_float ); //temp_float *= _FootToDist; temp_float = UUmFeet( temp_float ); osd_all.osd.door_osd.activation_radius_squared = temp_float * temp_float; @@ -1698,42 +1698,42 @@ static UUtError OWiProp_Door_SaveOSD( WMtDialog *inDialog ) osd_all.osd.door_osd.flags |= OBJcDoorFlag_Locked; else osd_all.osd.door_osd.flags &= ~OBJcDoorFlag_Locked; - + // Initial Locked window = WMrDialog_GetItemByID(inDialog, PDcCB_InitialLocked); if (WMrMessage_Send(window, WMcMessage_GetValue, (UUtUns32) -1, (UUtUns32) -1)) osd_all.osd.door_osd.flags |= OBJcDoorFlag_InitialLocked; else osd_all.osd.door_osd.flags &= ~OBJcDoorFlag_InitialLocked; - + // Double doors window = WMrDialog_GetItemByID(inDialog, PDcCB_DoubleDoors); if (WMrMessage_Send(window, WMcMessage_GetValue, (UUtUns32) -1, (UUtUns32) -1)) osd_all.osd.door_osd.flags |= OBJcDoorFlag_DoubleDoors; else osd_all.osd.door_osd.flags &= ~OBJcDoorFlag_DoubleDoors; - + // Manual Door window = WMrDialog_GetItemByID(inDialog, PDcCB_ManualDoor); if (WMrMessage_Send(window, WMcMessage_GetValue, (UUtUns32) -1, (UUtUns32) -1)) osd_all.osd.door_osd.flags |= OBJcDoorFlag_Manual; else osd_all.osd.door_osd.flags &= ~OBJcDoorFlag_Manual; - + // One way Door window = WMrDialog_GetItemByID(inDialog, PDcCB_OneWay); if (WMrMessage_Send(window, WMcMessage_GetValue, (UUtUns32) -1, (UUtUns32) -1)) osd_all.osd.door_osd.flags |= OBJcDoorFlag_OneWay; else osd_all.osd.door_osd.flags &= ~OBJcDoorFlag_OneWay; - + // Reversed Door window = WMrDialog_GetItemByID(inDialog, PDcCB_Reverse); if (WMrMessage_Send(window, WMcMessage_GetValue, (UUtUns32) -1, (UUtUns32) -1)) osd_all.osd.door_osd.flags |= OBJcDoorFlag_Reverse; else osd_all.osd.door_osd.flags &= ~OBJcDoorFlag_Reverse; - + // Test mode window = WMrDialog_GetItemByID(inDialog, PDcCB_Test); if (WMrMessage_Send(window, WMcMessage_GetValue, (UUtUns32) -1, (UUtUns32) -1)) @@ -1747,7 +1747,7 @@ static UUtError OWiProp_Door_SaveOSD( WMtDialog *inDialog ) osd_all.osd.door_osd.flags |= OBJcDoorFlag_Mirror; else osd_all.osd.door_osd.flags &= ~OBJcDoorFlag_Mirror; - + // grab the textures window = WMrDialog_GetItemByID(inDialog, PDcPM_Texture0); WMrPopupMenu_GetItemID(window, -1, &id); @@ -1788,18 +1788,18 @@ static void OWiProp_Door_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam1, OBJtObjectType object_type; OBJtOSD_All *osd; OBJtOSD_Door *door_osd; - + // get a pointer to the osd osd = (OBJtOSD_All*)WMrDialog_GetUserData(inDialog); UUmAssert(osd); door_osd = (OBJtOSD_Door*) osd; - + // get the object and object type object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return; } object_type = OBJrObject_GetType(object); - + switch (UUmLowWord(inParam1)) { case PDcBtn_NewEvent: @@ -1845,7 +1845,7 @@ static void OWiProp_Door_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam1, osd_all.osd.door_osd.door_class_name[0] = 0; } else - { + { result = WMrMessage_Send( listbox, LBcMessage_GetText, (UUtUns32)type_name, (UUtUns32)(-1)); if (result == LBcError) break; @@ -1866,12 +1866,12 @@ static void OWiProp_Door_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam1, { // set the object specific data OWrObjectProperties_SetOSD(inDialog, object, osd); - + // hilite the item currently in use OWiProp_Door_SelectItem(inDialog); } break; - + case PDcBtn_Cancel: if (UUmHighWord(inParam1) == WMcNotify_Click) { @@ -1882,7 +1882,7 @@ static void OWiProp_Door_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam1, if (UUmHighWord(inParam1) == WMcNotify_Click) { // save the object specific data - //error = + //error = OWiProp_Door_SaveOSD(inDialog); //if (error == UUcError_None) { @@ -1907,32 +1907,32 @@ static void OWiProp_Door_HandleMenuCommand( WMtDialog *inDialog, UUtUns32 inPara static UUtBool OWiProp_Door_Callback( WMtDialog *inDialog, WMtMessage inMessage, UUtUns32 inParam1, UUtUns32 inParam2 ) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiProp_Door_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWgDialog_Prop = NULL; return UUcFalse; - + case WMcMessage_Command: - OWiProp_Door_HandleCommand(inDialog, inParam1, inParam2); + OWiProp_Door_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_MenuCommand: OWiProp_Door_HandleMenuCommand(inDialog, inParam1, inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } #endif @@ -2032,14 +2032,14 @@ static void OWiProp_Trigger_SetFields( WMtDialog *inDialog ) static UUtBool OWiListBox_TriggerType_EnumCallback( const char *inName, UUtUns32 inUserData ) { WMtWindow *listbox; - + // get the list box listbox = (WMtWindow*)inUserData; if (listbox == NULL) { return UUcFalse; } - + // add the character to the list WMrMessage_Send( listbox, LBcMessage_AddString, (UUtUns32) inName, 0); - + return UUcTrue; } #endif @@ -2051,7 +2051,7 @@ static void OWiProp_Trigger_SelectItem( WMtDialog *inDialog ) WMtWindow *listbox; OBJtObject *object; OBJtOSD_Trigger *trigger_osd; - + // get a pointer to the osd trigger_osd = (OBJtOSD_Trigger *)WMrDialog_GetUserData(inDialog); UUmAssert(trigger_osd); @@ -2063,7 +2063,7 @@ static void OWiProp_Trigger_SelectItem( WMtDialog *inDialog ) // get the currently selected object object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return; } - + // select the appropriate item WMrMessage_Send( listbox, LBcMessage_SelectString, (UUtUns32)(-1), (UUtUns32) trigger_osd->trigger_class_name); } @@ -2079,19 +2079,19 @@ static void OWiProp_Trigger_InitDialog( WMtDialog *inDialog ) OBJtObjectType object_type; OBJtOSD_All *osd; WMtWindow *editfield; - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, PTcLB_TriggerTypes); if (listbox == NULL) { return; } - + // get the currently selected object object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return; } - + // get the object type object_type = OBJrObject_GetType(object); - - // enumerate the object specific types + + // enumerate the object specific types OBJrObject_Enumerate( object, OWiListBox_TriggerType_EnumCallback, (UUtUns32)listbox); osd = (OBJtOSD_All*)UUrMemory_Block_NewClear(sizeof(OBJtOSD_All)); @@ -2124,7 +2124,7 @@ static void OWiProp_Trigger_InitDialog( WMtDialog *inDialog ) // set the keyboard focus to the listbox WMrWindow_SetFocus(listbox); - + // hilite the item currently in use OWiProp_Trigger_SelectItem(inDialog); @@ -2143,18 +2143,18 @@ static UUtError OWiProp_Trigger_SaveOSD( WMtDialog *inDialog ) float temp; UUtUns32 temp_int; char string[OBJcMaxNoteChars + 1]; - + OBJtOSD_Trigger *trigger_osd; - + if (OBJrObjectType_IsLocked(OBJcType_Trigger) == UUcTrue) { WMrDialog_MessageBox(inDialog, "Error", "The Trigger file is locked.", WMcMessageBoxStyle_OK); return UUcError_None; } - + // get a pointer to the object object = OBJrSelectedObjects_GetSelectedObject(0); - UUmAssert(object); + UUmAssert(object); // grab the temp OSD trigger_osd = (OBJtOSD_Trigger*)WMrDialog_GetUserData(inDialog); @@ -2168,18 +2168,18 @@ static UUtError OWiProp_Trigger_SaveOSD( WMtDialog *inDialog ) // get the id window = WMrDialog_GetItemByID(inDialog, PTcEF_ID); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 6); - sscanf(string, "%d", &temp_int ); + sscanf(string, "%d", &temp_int ); osd_all.osd.trigger_osd.id = (UUtUns16) temp_int; // get the speed window = WMrDialog_GetItemByID(inDialog, PTcEF_Speed); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 6); - sscanf(string, "%f", &osd_all.osd.trigger_osd.persistant_anim_scale ); + sscanf(string, "%f", &osd_all.osd.trigger_osd.persistant_anim_scale ); // get the starting offset window = WMrDialog_GetItemByID(inDialog, PTcEF_StartOffset); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 6); - sscanf(string, "%f", &osd_all.osd.trigger_osd.start_offset ); + sscanf(string, "%f", &osd_all.osd.trigger_osd.start_offset ); // get the reversal window = WMrDialog_GetItemByID(inDialog, PTcCB_Reverse); @@ -2187,55 +2187,55 @@ static UUtError OWiProp_Trigger_SaveOSD( WMtDialog *inDialog ) osd_all.osd.trigger_osd.flags |= OBJcTriggerFlag_ReverseAnim; else osd_all.osd.trigger_osd.flags &= ~OBJcTriggerFlag_ReverseAnim; - + // get the pingpong window = WMrDialog_GetItemByID(inDialog, PTcCB_PingPong); if (WMrMessage_Send(window, WMcMessage_GetValue, (UUtUns32) -1, (UUtUns32) -1)) osd_all.osd.trigger_osd.flags |= OBJcTriggerFlag_PingPong; else osd_all.osd.trigger_osd.flags &= ~OBJcTriggerFlag_PingPong; - + // get the active state window = WMrDialog_GetItemByID(inDialog, PTcCB_Active); if (WMrMessage_Send(window, WMcMessage_GetValue, (UUtUns32) -1, (UUtUns32) -1)) osd_all.osd.trigger_osd.flags |= OBJcTriggerFlag_Active; else osd_all.osd.trigger_osd.flags &= ~OBJcTriggerFlag_Active; - + // get the initial active state window = WMrDialog_GetItemByID(inDialog, PTcCB_InitialActive); if (WMrMessage_Send(window, WMcMessage_GetValue, (UUtUns32) -1, (UUtUns32) -1)) osd_all.osd.trigger_osd.flags |= OBJcTriggerFlag_InitialActive; else osd_all.osd.trigger_osd.flags &= ~OBJcTriggerFlag_InitialActive; - + // get the time on window = WMrDialog_GetItemByID(inDialog, PTcEF_TimeOn); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 6); - sscanf(string, "%f", &temp ); + sscanf(string, "%f", &temp ); osd_all.osd.trigger_osd.time_on = (UUtUns16) ( temp * UUcFramesPerSecond ); - + // get the time off window = WMrDialog_GetItemByID(inDialog, PTcEF_TimeOff); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 6); - sscanf(string, "%f", &temp ); + sscanf(string, "%f", &temp ); osd_all.osd.trigger_osd.time_off = (UUtUns16) ( temp * UUcFramesPerSecond ); - + // get the color window = WMrDialog_GetItemByID(inDialog, PTcEF_Color); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 12 ); - sscanf(string, "%x", &temp_int ); + sscanf(string, "%x", &temp_int ); osd_all.osd.trigger_osd.color = temp_int; // get the emitter count window = WMrDialog_GetItemByID(inDialog, PTcEF_EmitterCount); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 6); - sscanf(string, "%d", &temp_int ); + sscanf(string, "%d", &temp_int ); osd_all.osd.trigger_osd.emitter_count = (UUtUns16) temp_int; // save the osd OWrObjectProperties_SetOSD(window, object, &osd_all); - + return UUcError_None; } #endif @@ -2248,18 +2248,18 @@ static void OWiProp_Trigger_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam OBJtObjectType object_type; OBJtOSD_All *osd; OBJtOSD_Trigger *trigger_osd; - + // get a pointer to the osd osd = (OBJtOSD_All*)WMrDialog_GetUserData(inDialog); UUmAssert(osd); trigger_osd = (OBJtOSD_Trigger*) osd; - + // get the object and object type object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return; } object_type = OBJrObject_GetType(object); - + switch (UUmLowWord(inParam1)) { case PTcBtn_NewEvent: @@ -2294,15 +2294,15 @@ static void OWiProp_Trigger_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam char type_name[256]; OBJtOSD_All osd_all; UUtUns32 result; - + // grab the box listbox = WMrDialog_GetItemByID(inDialog, PTcLB_TriggerTypes); UUmAssert( listbox ); if (listbox == NULL) { return; } - + // get the selected item text from the listbox result = WMrMessage_Send( listbox, LBcMessage_GetText, (UUtUns32)type_name, (UUtUns32)(-1)); if (result == LBcError) { break; } - + // set the OSD to reflect the change osd_all.osd.trigger_osd = osd->osd.trigger_osd; UUrString_Copy( osd_all.osd.trigger_osd.trigger_class_name, type_name, OBJcMaxNameLength ); @@ -2321,12 +2321,12 @@ static void OWiProp_Trigger_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam { // set the object specific data OWrObjectProperties_SetOSD(inDialog, object, osd); - + // hilite the item currently in use OWiProp_Trigger_SelectItem(inDialog); } break; - + case PTcBtn_Cancel: if (UUmHighWord(inParam1) == WMcNotify_Click) { @@ -2337,7 +2337,7 @@ static void OWiProp_Trigger_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam if (UUmHighWord(inParam1) == WMcNotify_Click) { // save the object specific data - //error = + //error = OWiProp_Trigger_SaveOSD(inDialog); //if (error == UUcError_None) { @@ -2375,32 +2375,32 @@ OWiProp_Trigger_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiProp_Trigger_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWgDialog_Prop = NULL; return UUcFalse; - + case WMcMessage_Command: - OWiProp_Trigger_HandleCommand(inDialog, inParam1, inParam2); + OWiProp_Trigger_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_MenuCommand: OWiProp_Trigger_HandleMenuCommand(inDialog, inParam1, inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } #endif @@ -2418,21 +2418,21 @@ OWiProp_Console_SetFields( WMtDialog *inDialog ) OBJtOSD_All *osd_all; WMtWindow *window; char string[255]; - + // get the Console properties osd_all = (OBJtOSD_All*)WMrDialog_GetUserData(inDialog); UUmAssert(osd_all); - + // update the controls // ID - window = WMrDialog_GetItemByID(inDialog, PCONcEF_ID); + window = WMrDialog_GetItemByID(inDialog, PCONcEF_ID); UUmAssert( window ); sprintf(string, "%d", osd_all->osd.console_osd.id ); WMrMessage_Send(window, EFcMessage_SetText, (UUtUns32)string, 0); - + // active - window = WMrDialog_GetItemByID(inDialog, PCONcCB_Active); + window = WMrDialog_GetItemByID(inDialog, PCONcCB_Active); UUmAssert( window ); WMrMessage_Send(window, CBcMessage_SetCheck, (UUtUns32) ((osd_all->osd.console_osd.flags & OBJcConsoleFlag_Active) ? UUcTrue : UUcFalse), (UUtUns32) -1); @@ -2449,12 +2449,12 @@ OWiProp_Console_SetFields( WMtDialog *inDialog ) WMrCheckBox_SetCheck(window, ((osd_all->osd.console_osd.flags & OBJcConsoleFlag_IsAlarm) ? UUcTrue : UUcFalse)); // triggered - window = WMrDialog_GetItemByID(inDialog, PCONcCB_Triggered); + window = WMrDialog_GetItemByID(inDialog, PCONcCB_Triggered); UUmAssert( window ); WMrMessage_Send(window, CBcMessage_SetCheck, (UUtUns32) ((osd_all->osd.console_osd.flags & OBJcConsoleFlag_Triggered) ? UUcTrue : UUcFalse), (UUtUns32) -1); // set the popup menus - window = WMrDialog_GetItemByID(inDialog, PCONcPM_InactiveScreen); + window = WMrDialog_GetItemByID(inDialog, PCONcPM_InactiveScreen); UUmAssert( window ); if( strlen( osd_all->osd.console_osd.screen_inactive ) > 4 ) { WMrPopupMenu_SelectString_NoCase( window, &osd_all->osd.console_osd.screen_inactive[4] ); @@ -2463,7 +2463,7 @@ OWiProp_Console_SetFields( WMtDialog *inDialog ) WMrPopupMenu_SelectString_NoCase( window, "" ); } - window = WMrDialog_GetItemByID(inDialog, PCONcPM_ActiveScreen); + window = WMrDialog_GetItemByID(inDialog, PCONcPM_ActiveScreen); UUmAssert( window ); if( strlen( osd_all->osd.console_osd.screen_active ) > 4 ) { WMrPopupMenu_SelectString_NoCase( window, &osd_all->osd.console_osd.screen_active[4] ); @@ -2472,17 +2472,17 @@ OWiProp_Console_SetFields( WMtDialog *inDialog ) WMrPopupMenu_SelectString_NoCase( window, "" ); } - window = WMrDialog_GetItemByID(inDialog, PCONcPM_TriggeredScreen); + window = WMrDialog_GetItemByID(inDialog, PCONcPM_TriggeredScreen); UUmAssert( window ); if( strlen( osd_all->osd.console_osd.screen_triggered ) > 4 ) { WMrPopupMenu_SelectString_NoCase( window, &osd_all->osd.console_osd.screen_triggered[4] ); } else { - WMrPopupMenu_SelectString_NoCase( window, "" ); + WMrPopupMenu_SelectString_NoCase( window, "" ); } - + // fill event list - window = WMrDialog_GetItemByID( inDialog, PCONcLB_Events ); + window = WMrDialog_GetItemByID( inDialog, PCONcLB_Events ); UUmAssert( window ); ONrEventList_FillListBox( &osd_all->osd.console_osd.event_list, window ); @@ -2510,7 +2510,7 @@ static UUtBool OWiListBox_ConsoleScreens_EnumCallback( const char *inName, UUtUn menu_item_data.flags = WMcMenuItemFlag_Enabled; menu_item_data.id = id++; UUrString_Copy(menu_item_data.title, inName, WMcMaxTitleLength); - + // fill the screen list window = WMrDialog_GetItemByID( dialog, PCONcPM_InactiveScreen ); UUmAssert( window ); error = WMrPopupMenu_AppendItem(window, &menu_item_data); @@ -2532,10 +2532,10 @@ static UUtBool OWiListBox_ConsoleType_EnumCallback( const char *inName, UUtUns32 // get the list box listbox = (WMtWindow*)inUserData; if (listbox == NULL) { return UUcFalse; } - + // add the character to the list WMrMessage_Send( listbox, LBcMessage_AddString, (UUtUns32) inName, 0); - + return UUcTrue; } #endif @@ -2547,7 +2547,7 @@ static void OWiProp_Console_SelectItem( WMtDialog *inDialog ) WMtWindow *listbox; OBJtObject *object; OBJtOSD_Console *console_osd; - + // get a pointer to the osd console_osd = (OBJtOSD_Console *) WMrDialog_GetUserData(inDialog); UUmAssert(console_osd); @@ -2555,7 +2555,7 @@ static void OWiProp_Console_SelectItem( WMtDialog *inDialog ) // get the currently selected object object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return; } - + // set the type list listbox = WMrDialog_GetItemByID(inDialog, PCONcLB_ConsoleTypes); UUmAssert( listbox ); @@ -2576,7 +2576,7 @@ OWiProp_Console_InitDialog( OBJtOSD_All *osd; UUtError error; WMtMenuItemData menu_item_data; - + // get the currently selected object object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return; } @@ -2597,7 +2597,7 @@ OWiProp_Console_InitDialog( // fill the type list window = WMrDialog_GetItemByID(inDialog, PCONcLB_ConsoleTypes); - if (window == NULL) { return; } + if (window == NULL) { return; } error = OBJrObject_Enumerate( object, OWiListBox_ConsoleType_EnumCallback, (UUtUns32)window ); error = OBJrObjectUtil_EnumerateTemplate( ONcConsoleTexturePrefix, M3cTemplate_TextureMap, OWiListBox_ConsoleScreens_EnumCallback, (UUtUns32) inDialog ); @@ -2612,18 +2612,18 @@ OWiProp_Console_InitDialog( // ID window = WMrDialog_GetItemByID(inDialog, PCONcEF_ID); WMrMessage_Send(window, EFcMessage_SetMaxChars, 6, 0); - + // set the keyboard focus to the listbox window = WMrDialog_GetItemByID(inDialog, PCONcLB_ConsoleTypes); - if (window == NULL) { return; } + if (window == NULL) { return; } WMrWindow_SetFocus(window); - + // hilite the item currently in use OWiProp_Console_SelectItem(inDialog); // set the fields OWiProp_Console_SetFields(inDialog); - + return; } #endif @@ -2638,17 +2638,17 @@ static UUtError OWiProp_Console_SaveOSD( WMtDialog *inDialog) char string[OBJcMaxNoteChars + 1]; OBJtOSD_Console *console_osd; UUtUns16 id; - + if (OBJrObjectType_IsLocked(OBJcType_Console) == UUcTrue) { WMrDialog_MessageBox(inDialog, "Error", "The Console file is locked.", WMcMessageBoxStyle_OK); return UUcError_None; } - + // get a pointer to the object object = OBJrSelectedObjects_GetSelectedObject(0); UUmAssert(object); - + // grab the temp OSD console_osd = (OBJtOSD_Console*)WMrDialog_GetUserData(inDialog); osd_all.osd.console_osd = *console_osd; @@ -2656,7 +2656,7 @@ static UUtError OWiProp_Console_SaveOSD( WMtDialog *inDialog) // get the id window = WMrDialog_GetItemByID(inDialog, PCONcEF_ID); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 6); - sscanf(string, "%d", &osd_all.osd.console_osd.id ); + sscanf(string, "%d", &osd_all.osd.console_osd.id ); // get the selected item text from the listbox window = WMrDialog_GetItemByID(inDialog, PCONcLB_ConsoleTypes); @@ -2669,7 +2669,7 @@ static UUtError OWiProp_Console_SaveOSD( WMtDialog *inDialog) osd_all.osd.console_osd.flags |= OBJcConsoleFlag_Active; else osd_all.osd.console_osd.flags &= ~OBJcConsoleFlag_Active; - + // get the initial active state window = WMrDialog_GetItemByID(inDialog, PCONcCB_InitialActive); if (WMrCheckBox_GetCheck(window)) { @@ -2742,7 +2742,7 @@ static UUtError OWiProp_Console_SaveOSD( WMtDialog *inDialog) } OWrObjectProperties_SetOSD(window, object, &osd_all); - + return UUcError_None; } #endif @@ -2758,20 +2758,20 @@ static void OWiProp_Console_HandleCommand( WMtWindow *listbox; OBJtObjectType object_type; OBJtOSD_All *osd; - + // get a pointer to the osd osd = (OBJtOSD_All*)WMrDialog_GetUserData(inDialog); UUmAssert(osd); - + // get the object and object type object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return; } object_type = OBJrObject_GetType(object); - + // get the listbox listbox = WMrDialog_GetItemByID(inDialog, PCONcLB_ConsoleTypes); if (listbox == NULL) { return; } - + switch (UUmLowWord(inParam1)) { case PTcEF_ID: @@ -2807,14 +2807,14 @@ static void OWiProp_Console_HandleCommand( char type_name[256]; OBJtOSD_All osd_all; UUtUns32 result; - + // get the selected item text from the listbox result = WMrMessage_Send( listbox, LBcMessage_GetText, (UUtUns32)type_name, (UUtUns32)(-1)); if (result == LBcError) { break; } - + // set the OSD to reflect the change osd_all.osd.console_osd = osd->osd.console_osd; - UUrString_Copy( osd_all.osd.console_osd.console_class_name, type_name, OBJcMaxNameLength); + UUrString_Copy( osd_all.osd.console_osd.console_class_name, type_name, OBJcMaxNameLength); // set the object specific data OWrObjectProperties_SetOSD(inDialog, object, &osd_all); } @@ -2829,12 +2829,12 @@ static void OWiProp_Console_HandleCommand( { // set the object specific data OWrObjectProperties_SetOSD(inDialog, object, osd); - + // hilite the item currently in use OWiProp_Console_SelectItem(inDialog); } break; - + case PTcBtn_Cancel: if (UUmHighWord(inParam1) == WMcNotify_Click) { @@ -2845,7 +2845,7 @@ static void OWiProp_Console_HandleCommand( if (UUmHighWord(inParam1) == WMcNotify_Click) { // save the object specific data - //error = + //error = OWiProp_Console_SaveOSD(inDialog); //if (error == UUcError_None) { @@ -2877,32 +2877,32 @@ static UUtBool OWiProp_Console_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiProp_Console_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWgDialog_Prop = NULL; return UUcFalse; - + case WMcMessage_Command: - OWiProp_Console_HandleCommand(inDialog, inParam1, inParam2); + OWiProp_Console_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_MenuCommand: OWiProp_Console_HandleMenuCommand(inDialog, inParam1, inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } #endif @@ -2920,7 +2920,7 @@ static void OWiProp_Turret_SetFields( WMtDialog *inDialog) char string[255]; OBJtObject *object = (OBJtObject *) WMrDialog_GetUserData(inDialog); OBJtOSD_All *osd_all = (OBJtOSD_All *) object->object_data; - + // update the controls // ID @@ -2992,14 +2992,14 @@ static void OWiProp_Turret_SetFields( WMtDialog *inDialog) static UUtBool OWiListBox_TurretType_EnumCallback( const char *inName, UUtUns32 inUserData ) { WMtWindow *listbox; - + // get the list box listbox = (WMtWindow*)inUserData; if (listbox == NULL) { return UUcFalse; } - + // add the character to the list WMrMessage_Send( listbox, LBcMessage_AddString, (UUtUns32) inName, 0); - + return UUcTrue; } #endif @@ -3011,7 +3011,7 @@ static void OWiProp_Turret_SelectItem( WMtDialog *inDialog) WMtWindow *listbox; OBJtObject *object; OBJtOSD_All *osd; - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, PTUcLB_TurretTypes); if (listbox == NULL) { return; } @@ -3021,7 +3021,7 @@ static void OWiProp_Turret_SelectItem( WMtDialog *inDialog) if (object == NULL) { return; } osd = (OBJtOSD_All *) object->object_data; - + // select the appropriate item WMrMessage_Send( listbox, LBcMessage_SelectString, (UUtUns32)(-1), (UUtUns32)osd->osd.turret_osd.turret_class_name); } @@ -3034,18 +3034,18 @@ static void OWiProp_Turret_InitDialog( WMtDialog *inDialog) WMtWindow *window; OBJtObject *object = (OBJtObject *) WMrDialog_GetUserData(inDialog); OBJtObjectType object_type = OBJrObject_GetType(object); - + // get a pointer to the listbox window = WMrDialog_GetItemByID(inDialog, PTUcLB_TurretTypes); UUmAssert( window ); if (window == NULL) { return; } - // enumerate the object specific types + // enumerate the object specific types OBJrObject_Enumerate( object, OWiListBox_TurretType_EnumCallback, (UUtUns32)window); // set the maximum number of characters in the editfields window = WMrDialog_GetItemByID(inDialog, PTUcEF_ID); WMrMessage_Send(window, EFcMessage_SetMaxChars, 6, 0); - + window = WMrDialog_GetItemByID(inDialog, PTUcEF_MaxHorizSpeed); WMrMessage_Send(window, EFcMessage_SetMaxChars, 6, 0); @@ -3073,7 +3073,7 @@ static void OWiProp_Turret_InitDialog( WMtDialog *inDialog) // set the keyboard focus to the listbox window = WMrDialog_GetItemByID(inDialog, PTUcLB_TurretTypes); UUmAssert( window ); WMrWindow_SetFocus(window); - + // hilite the item currently in use OWiProp_Turret_SelectItem(inDialog); @@ -3093,17 +3093,17 @@ static UUtError OWiProp_Turret_SaveOSD( WMtDialog *inDialog) OBJtOSD_All osd_all; OBJtOSD_Turret *turret_osd; char string[OBJcMaxNoteChars + 1]; - + if (OBJrObjectType_IsLocked(OBJcType_Turret) == UUcTrue) { WMrDialog_MessageBox(inDialog, "Error", "The Turret file is locked.", WMcMessageBoxStyle_OK); return UUcError_None; } - + // get a pointer to the object object = OBJrSelectedObjects_GetSelectedObject(0); UUmAssert(object); - + turret_osd = (OBJtOSD_Turret*) object->object_data; osd_all.osd.turret_osd = *turret_osd; @@ -3116,8 +3116,8 @@ static UUtError OWiProp_Turret_SaveOSD( WMtDialog *inDialog) // get the id window = WMrDialog_GetItemByID(inDialog, PTUcEF_ID); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, OBJcMaxNoteChars); - sscanf(string, "%d", &osd_all.osd.turret_osd.id ); - + sscanf(string, "%d", &osd_all.osd.turret_osd.id ); + // get the initial active state window = WMrDialog_GetItemByID(inDialog, PTUcCB_InitialActive); if (WMrMessage_Send(window, WMcMessage_GetValue, (UUtUns32) -1, (UUtUns32) -1)) @@ -3152,10 +3152,10 @@ static void OWiProp_Turret_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam1 OBJtObject *object = (OBJtObject *) WMrDialog_GetUserData(inDialog); OBJtObjectType object_type; const OBJtOSD_All *osd = (OBJtOSD_All *) object->object_data; - + // get the object and object type object_type = OBJrObject_GetType(object); - + switch (UUmLowWord(inParam1)) { case PTUcEF_ID: @@ -3172,7 +3172,7 @@ static void OWiProp_Turret_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam1 UUtUns32 result; WMtWindow *listbox; WMtWindow *window; - + // get the listbox listbox = WMrDialog_GetItemByID(inDialog, PTUcLB_TurretTypes); if (listbox == NULL) { return; } @@ -3180,10 +3180,10 @@ static void OWiProp_Turret_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam1 // get the selected item text from the listbox result = WMrMessage_Send( listbox, LBcMessage_GetText, (UUtUns32)type_name, (UUtUns32)(-1)); if (result == LBcError) { break; } - + // set the OSD to reflect the change osd_all.osd.turret_osd = osd->osd.turret_osd; - UUrString_Copy( osd_all.osd.turret_osd.turret_class_name, type_name, OBJcMaxNameLength); + UUrString_Copy( osd_all.osd.turret_osd.turret_class_name, type_name, OBJcMaxNameLength); // set the object specific data OWrObjectProperties_SetOSD(inDialog, object, &osd_all); @@ -3230,7 +3230,7 @@ static void OWiProp_Turret_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam1 { WMtWindow *team_number_window; UUtUns32 team_number; - + team_number_window = WMrDialog_GetItemByID(inDialog, PUTcEF_TargetTeamsNumber); team_number = (UUtUns32) WMrEditField_GetInt32(team_number_window); @@ -3257,12 +3257,12 @@ static void OWiProp_Turret_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam1 if (UUmHighWord(inParam1) == WMcNotify_Click) { OWiProp_Turret_SetFields(inDialog); - + // hilite the item currently in use OWiProp_Turret_SelectItem(inDialog); } break; - + case PTcBtn_Cancel: if (UUmHighWord(inParam1) == WMcNotify_Click) { OBJrSaveObjects(OBJcType_Turret); @@ -3279,7 +3279,7 @@ static void OWiProp_Turret_HandleCommand( WMtDialog *inDialog, UUtUns32 inParam1 break; } - return; + return; } #endif @@ -3292,7 +3292,7 @@ OWiProp_Turret_HandleMenuCommand( UUtUns32 inParam2) { IMtShade shade; - + // get the shade shade = OWiColorPopup_GetShadeFromID(UUmLowWord(inParam1)); @@ -3309,32 +3309,32 @@ OWiProp_Turret_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiProp_Turret_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWgDialog_Prop = NULL; return UUcFalse; - + case WMcMessage_Command: - OWiProp_Turret_HandleCommand(inDialog, inParam1, inParam2); + OWiProp_Turret_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_MenuCommand: OWiProp_Turret_HandleMenuCommand(inDialog, inParam1, inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } #endif @@ -3356,14 +3356,14 @@ OWiProp_Flag_SetFields( char string[255]; char char_1; char char_2; - + // get the flag properties object = (OBJtObject*)WMrDialog_GetUserData(inDialog); UUmAssert(object); - + // get the object specific data OBJrObject_GetObjectSpecificData(object, &osd_all); - + // update the controls window = WMrDialog_GetItemByID(inDialog, PFcEF_ID_Prefix); char_1 = UUmHighByte(osd_all.osd.flag_osd.id_prefix); @@ -3374,13 +3374,13 @@ OWiProp_Flag_SetFields( window = WMrDialog_GetItemByID(inDialog, PFcEF_ID_Number); sprintf(string, "%d", osd_all.osd.flag_osd.id_number); WMrMessage_Send(window, EFcMessage_SetText, (UUtUns32)string, 0); - + window = WMrDialog_GetItemByID(inDialog, PFcPM_Color); OWiColorPopup_SelectItemFromShade(window, osd_all.osd.flag_osd.shade); - + window = WMrDialog_GetItemByID(inDialog, PFcEF_Note); WMrMessage_Send(window, EFcMessage_SetText, (UUtUns32)osd_all.osd.flag_osd.note, 0); - + window = WMrDialog_GetItemByID(inDialog, WMcDialogItem_OK); WMrWindow_SetEnabled(window, !OBJrObjectType_IsLocked(OBJcType_Flag)); @@ -3405,21 +3405,21 @@ OWiProp_Flag_InitDialog( WMrDialog_ModalEnd(inDialog, UUcTrue); return; } - + // set the maximum number of characters in the editfields editfield = WMrDialog_GetItemByID(inDialog, PFcEF_ID_Prefix); WMrMessage_Send(editfield, EFcMessage_SetMaxChars, 3, 0); - + editfield = WMrDialog_GetItemByID(inDialog, PFcEF_ID_Number); WMrMessage_Send(editfield, EFcMessage_SetMaxChars, 6, 0); - + editfield = WMrDialog_GetItemByID(inDialog, PFcEF_Note); WMrMessage_Send(editfield, EFcMessage_SetMaxChars, OBJcMaxNoteChars, 0); // initialize the popup menu popup = WMrDialog_GetItemByID(inDialog, PFcPM_Color); OWiColorPopup_Init(popup); - + // set the fields OWiProp_Flag_SetFields(inDialog); } @@ -3439,41 +3439,41 @@ OWiProp_Flag_SaveOSD( char char_2; UUtUns32 id_number; UUtUns16 color_id; - + if (OBJrObjectType_IsLocked(OBJcType_Flag) == UUcTrue) { WMrDialog_MessageBox(inDialog, "Error", "The flag file is locked.", WMcMessageBoxStyle_OK); return UUcError_None; } - + // get a pointer to the object object = (OBJtObject*)WMrDialog_GetUserData(inDialog); UUmAssert(object); - + // get the id prefix window = WMrDialog_GetItemByID(inDialog, PFcEF_ID_Prefix); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, OBJcMaxNoteChars); - sscanf(string, "%c%c", &char_1, &char_2); + sscanf(string, "%c%c", &char_1, &char_2); osd_all.osd.flag_osd.id_prefix = UUmMakeShort(char_1, char_2); - + // get the id number window = WMrDialog_GetItemByID(inDialog, PFcEF_ID_Number); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, OBJcMaxNoteChars); sscanf(string, "%d", &id_number); osd_all.osd.flag_osd.id_number = (UUtInt16)id_number; - + // get the color window = WMrDialog_GetItemByID(inDialog, PFcPM_Color); WMrPopupMenu_GetItemID(window, -1, &color_id); osd_all.osd.flag_osd.shade = OWiColorPopup_GetShadeFromID(color_id); - + // get the note window = WMrDialog_GetItemByID(inDialog, PFcEF_Note); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, OBJcMaxNoteChars); UUrString_Copy(osd_all.osd.flag_osd.note, string, OBJcMaxNoteChars); - + OWrObjectProperties_SetOSD(window, object, &osd_all); - + return UUcError_None; } #endif @@ -3488,16 +3488,16 @@ OWiProp_Flag_HandleCommand( { OBJtObject *object; UUtError error; - + // get a pointer to the object object = (OBJtObject*)WMrDialog_GetUserData(inDialog); UUmAssert(object); - + switch (UUmLowWord(inParam1)) { case PFcEF_ID_Prefix: break; - + case PFcEF_ID_Number: { WMtWindow *editfield; @@ -3506,7 +3506,7 @@ OWiProp_Flag_HandleCommand( UUtUns32 id_number; OBJtObject *found_object; WMtWindow *save_button; - + // get the id number from the id number editfield and make sure it is in range editfield = WMrDialog_GetItemByID(inDialog, PFcEF_ID_Number); WMrMessage_Send(editfield, EFcMessage_GetText, (UUtUns32)string, OBJcMaxNoteChars); @@ -3522,7 +3522,7 @@ OWiProp_Flag_HandleCommand( { id_number = 0; } - + // set the save button to enabled or disabled depending on if the user has typed in // a duplicate id number or no id number at all osd_all.osd.flag_osd.id_number = (UUtUns16)id_number; @@ -3538,10 +3538,10 @@ OWiProp_Flag_HandleCommand( } } break; - + case PFcEF_Note: break; - + case WMcDialogItem_Cancel: if (UUmHighWord(inParam1) == WMcNotify_Click) { @@ -3549,7 +3549,7 @@ OWiProp_Flag_HandleCommand( WMrDialog_ModalEnd(inDialog, UUcFalse); } break; - + case WMcDialogItem_OK: if (UUmHighWord(inParam1) == WMcNotify_Click) { @@ -3575,7 +3575,7 @@ OWiProp_Flag_HandleMenuCommand( UUtUns32 inParam2) { IMtShade shade; - + // get the shade shade = OWiColorPopup_GetShadeFromID(UUmLowWord(inParam1)); } @@ -3591,32 +3591,32 @@ OWiProp_Flag_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiProp_Flag_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWgDialog_Prop = NULL; return UUcFalse; - + case WMcMessage_Command: - OWiProp_Flag_HandleCommand(inDialog, inParam1, inParam2); + OWiProp_Flag_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_MenuCommand: OWiProp_Flag_HandleMenuCommand(inDialog, inParam1, inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } #endif @@ -3637,15 +3637,15 @@ OWiProp_Sound_EnableButtons( WMtWindow *button; WMtWindow *editfield; UUtUns16 i; - + // get the sound_prop sound_prop = (OWtSoundProp*)WMrDialog_GetUserData(inDialog); sound_osd = &sound_prop->osd.osd.sound_osd; - + // set the edit button button = WMrDialog_GetItemByID(inDialog, OWcSP_Btn_Edit); WMrWindow_SetEnabled(button, (sound_osd->ambient != NULL)); - + // set the edit fields switch (sound_osd->type) { @@ -3659,7 +3659,7 @@ OWiProp_Sound_EnableButtons( editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Height); WMrWindow_SetEnabled(editfield, UUcFalse); - + for (i = OWcSP_Btn_LenInc1; i <= OWcSP_Btn_HgtDec10; i++) { editfield = WMrDialog_GetItemByID(inDialog, i); @@ -3673,7 +3673,7 @@ OWiProp_Sound_EnableButtons( editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_MinVolDist); WMrWindow_SetEnabled(editfield, UUcTrue); break; - + case OBJcSoundType_BVolume: // disable sphere editfields editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_MaxVolDist); @@ -3681,7 +3681,7 @@ OWiProp_Sound_EnableButtons( editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_MinVolDist); WMrWindow_SetEnabled(editfield, UUcFalse); - + // enable bounding volume editifields and buttons editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Length); WMrWindow_SetEnabled(editfield, UUcTrue); @@ -3691,7 +3691,7 @@ OWiProp_Sound_EnableButtons( editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Height); WMrWindow_SetEnabled(editfield, UUcTrue); - + for (i = OWcSP_Btn_LenInc1; i <= OWcSP_Btn_HgtDec10; i++) { editfield = WMrDialog_GetItemByID(inDialog, i); @@ -3699,7 +3699,7 @@ OWiProp_Sound_EnableButtons( } break; } - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Pitch); WMrWindow_SetEnabled(editfield, UUcFalse); } @@ -3715,69 +3715,69 @@ OWiProp_Sound_SetFields( OBJtOSD_Sound *sound_osd; WMtWindow *text; WMtWindow *editfield; - + // get the sound_prop sound_prop = (OWtSoundProp*)WMrDialog_GetUserData(inDialog); sound_osd = &sound_prop->osd.osd.sound_osd; - + // get the ambient sound // fill in the text fields text = WMrDialog_GetItemByID(inDialog, OWcSP_Txt_Name); WMrWindow_SetTitle(text, sound_osd->ambient_name, SScMaxNameLength); if (sound_osd->ambient == NULL) { WMrText_SetShade(text, IMcShade_Red); } else { WMrText_SetShade(text, IMcShade_Black); } - + switch (sound_osd->type) { case OBJcSoundType_Spheres: WMrDialog_RadioButtonCheck(inDialog, OWcSP_RB_Spheres, OWcSP_RB_Volume, OWcSP_RB_Spheres); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_MinVolDist); WMrEditField_SetFloat(editfield, sound_osd->u.spheres.min_volume_distance); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_MaxVolDist); WMrEditField_SetFloat(editfield, sound_osd->u.spheres.max_volume_distance); break; - + case OBJcSoundType_BVolume: { float length; float width; float height; - + length = sound_osd->u.bvolume.bbox.maxPoint.x + -sound_osd->u.bvolume.bbox.minPoint.x; - + width = sound_osd->u.bvolume.bbox.maxPoint.z + -sound_osd->u.bvolume.bbox.minPoint.z; - + height = sound_osd->u.bvolume.bbox.maxPoint.y + -sound_osd->u.bvolume.bbox.minPoint.y; - + WMrDialog_RadioButtonCheck(inDialog, OWcSP_RB_Spheres, OWcSP_RB_Volume, OWcSP_RB_Volume); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Length); WMrEditField_SetFloat(editfield, length); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Width); WMrEditField_SetFloat(editfield, width); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Height); WMrEditField_SetFloat(editfield, height); } break; - + default: UUmAssert(!"something is VERY wrong"); break; } - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Pitch); WMrEditField_SetFloat(editfield, sound_osd->pitch); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Volume); WMrEditField_SetFloat(editfield, sound_osd->volume); } @@ -3793,15 +3793,15 @@ OWiProp_Sound_SetAmbient( OBJtOSD_Sound *sound_osd; SStAmbient *ambient; OWtSelectResult result; - + // get the sound_prop sound_prop = (OWtSoundProp*)WMrDialog_GetUserData(inDialog); sound_osd = &sound_prop->osd.osd.sound_osd; - + // select the ambient sound result = OWrSelect_AmbientSound(&ambient); if (result == OWcSelectResult_Cancel) { return; } - + // set the sound osd data if (ambient == NULL) { @@ -3812,10 +3812,10 @@ OWiProp_Sound_SetAmbient( UUrString_Copy(sound_osd->ambient_name, ambient->ambient_name, SScMaxNameLength); } sound_osd->ambient = ambient; - + // fill in the fields OWiProp_Sound_SetFields(inDialog); - + // enable the buttons fields OWiProp_Sound_EnableButtons(inDialog); } @@ -3830,15 +3830,15 @@ OWiProp_Sound_EditAmbient( UUtError error; OWtSoundProp *sound_prop; OBJtOSD_Sound *sound_osd; - + // get the sound_prop sound_prop = (OWtSoundProp*)WMrDialog_GetUserData(inDialog); sound_osd = &sound_prop->osd.osd.sound_osd; - + // edit the properties of the ambient sound error = OWrAmbientProperties_Display(inDialog, sound_osd->ambient); UUmError_ReturnOnError(error); - + return UUcError_None; } #endif @@ -3852,55 +3852,55 @@ OWiProp_Sound_SaveData( OWtSoundProp *sound_prop; OBJtOSD_Sound *sound_osd; WMtWindow *editfield; - + // get the sound_prop sound_prop = (OWtSoundProp*)WMrDialog_GetUserData(inDialog); sound_osd = &sound_prop->osd.osd.sound_osd; - + // get the data from the fields switch (sound_osd->type) { case OBJcSoundType_Spheres: editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_MaxVolDist); sound_osd->u.spheres.max_volume_distance = WMrEditField_GetFloat(editfield); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_MinVolDist); sound_osd->u.spheres.min_volume_distance = WMrEditField_GetFloat(editfield); break; - + case OBJcSoundType_BVolume: { float length; float width; float height; - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Length); length = WMrEditField_GetFloat(editfield); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Width); width = WMrEditField_GetFloat(editfield); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Height); height = WMrEditField_GetFloat(editfield); - + // set the min max data based on the position of the object sound_osd->u.bvolume.bbox.minPoint.x = -(length * 0.5f); sound_osd->u.bvolume.bbox.minPoint.y = -(height * 0.5f); sound_osd->u.bvolume.bbox.minPoint.z = -(width * 0.5f); - + sound_osd->u.bvolume.bbox.maxPoint.x = (length * 0.5f); sound_osd->u.bvolume.bbox.maxPoint.y = (height * 0.5f); sound_osd->u.bvolume.bbox.maxPoint.z = (width * 0.5f); } break; } - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Pitch); sound_osd->pitch = WMrEditField_GetFloat(editfield); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Volume); sound_osd->volume = WMrEditField_GetFloat(editfield); - + // set the object specific data OBJrObject_SetObjectSpecificData(sound_prop->object, &sound_prop->osd); } @@ -3914,7 +3914,7 @@ OWiProp_Sound_InitDialog( { OBJtObject *object; OWtSoundProp *sound_prop; - + // get a pointer to the selected object object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) @@ -3922,26 +3922,26 @@ OWiProp_Sound_InitDialog( WMrDialog_ModalEnd(inDialog, UUcTrue); return; } - + sound_prop = (OWtSoundProp*)UUrMemory_Block_NewClear(sizeof(OWtSoundProp)); if (sound_prop == NULL) { WMrDialog_ModalEnd(inDialog, UUcTrue); return; } - + sound_prop->object = object; - + // get the object specific data OBJrObject_GetObjectSpecificData(object, &sound_prop->osd); OBJrObject_GetObjectSpecificData(object, &sound_prop->backup_osd); - + // set the user data WMrDialog_SetUserData(inDialog, (UUtUns32)sound_prop); - + // set the fields OWiProp_Sound_SetFields(inDialog); - + // enable buttons OWiProp_Sound_EnableButtons(inDialog); } @@ -3954,14 +3954,14 @@ OWiProp_Sound_Destroy( WMtDialog *inDialog) { OWtSoundProp *sound_prop; - + // get the sound_prop sound_prop = (OWtSoundProp*)WMrDialog_GetUserData(inDialog); if (sound_prop != NULL) { UUrMemory_Block_Delete(sound_prop); sound_prop = NULL; - + WMrDialog_SetUserData(inDialog, 0); } } @@ -3987,15 +3987,15 @@ OWiProp_Sound_HandleCommand( OBJtOSD_Sound *sound_osd; float value; WMtWindow *editfield; - + // get the sound_prop sound_prop = (OWtSoundProp*)WMrDialog_GetUserData(inDialog); sound_osd = &sound_prop->osd.osd.sound_osd; - + // interpret inParam1 command_type = UUmHighWord(inParam1); control_id = UUmLowWord(inParam1); - + // handle the command update_fields = UUcTrue; switch (control_id) @@ -4003,14 +4003,14 @@ OWiProp_Sound_HandleCommand( case OWcSP_Btn_Set: OWiProp_Sound_SetAmbient(inDialog); break; - + case OWcSP_Btn_Edit: OWiProp_Sound_EditAmbient(inDialog); break; - + case OWcSP_RB_Spheres: if (sound_osd->type == OBJcSoundType_Spheres) { break; } - + sound_osd->type = OBJcSoundType_Spheres; WMrDialog_RadioButtonCheck(inDialog, OWcSP_RB_Spheres, OWcSP_RB_Volume, control_id); @@ -4020,13 +4020,13 @@ OWiProp_Sound_HandleCommand( editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_MinVolDist); WMrEditField_SetFloat(editfield, 10.0f); break; - + case OWcSP_RB_Volume: if (sound_osd->type == OBJcSoundType_BVolume) { break; } - + sound_osd->type = OBJcSoundType_BVolume; WMrDialog_RadioButtonCheck(inDialog, OWcSP_RB_Spheres, OWcSP_RB_Volume, control_id); - + editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Length); WMrEditField_SetFloat(editfield, 100.0f); @@ -4036,46 +4036,46 @@ OWiProp_Sound_HandleCommand( editfield = WMrDialog_GetItemByID(inDialog, OWcSP_EF_Height); WMrEditField_SetFloat(editfield, 100.0f); break; - + case OWcSP_Btn_LenInc1: OWmInc(OWcSP_EF_Length, 1.0f); break; case OWcSP_Btn_WidInc1: OWmInc(OWcSP_EF_Width, 1.0f); break; case OWcSP_Btn_HgtInc1: OWmInc(OWcSP_EF_Height, 1.0f); break; - + case OWcSP_Btn_LenDec1: OWmInc(OWcSP_EF_Length, -1.0f); break; case OWcSP_Btn_WidDec1: OWmInc(OWcSP_EF_Width, -1.0f); break; case OWcSP_Btn_HgtDec1: OWmInc(OWcSP_EF_Height, -1.0f); break; - + case OWcSP_Btn_LenInc10: OWmInc(OWcSP_EF_Length, 10.0f); break; case OWcSP_Btn_WidInc10: OWmInc(OWcSP_EF_Width, 10.0f); break; case OWcSP_Btn_HgtInc10: OWmInc(OWcSP_EF_Height, 10.0f); break; - + case OWcSP_Btn_LenDec10: OWmInc(OWcSP_EF_Length, -10.0f); break; case OWcSP_Btn_WidDec10: OWmInc(OWcSP_EF_Width, -10.0f); break; case OWcSP_Btn_HgtDec10: OWmInc(OWcSP_EF_Height, -10.0f); break; - + case OWcSP_Btn_Cancel: OBJrObject_SetObjectSpecificData(sound_prop->object, &sound_prop->backup_osd); WMrDialog_ModalEnd(inDialog, UUcFalse); return; - + case OWcSP_Btn_Save: OWiProp_Sound_SaveData(inDialog); WMrDialog_ModalEnd(inDialog, UUcTrue); return; - + default: update_fields = UUcFalse; break; } - + OWiProp_Sound_SaveData(inDialog); - + // update the fields if (update_fields == UUcTrue) { OWiProp_Sound_SetFields(inDialog); } - + // enable buttons OWiProp_Sound_EnableButtons(inDialog); } @@ -4091,32 +4091,32 @@ OWiProp_Sound_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiProp_Sound_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiProp_Sound_Destroy(inDialog); OWgDialog_Prop = NULL; break; - + case WMcMessage_Command: OWiProp_Sound_HandleCommand( inDialog, inParam1, (WMtWindow*)inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } #endif @@ -4136,7 +4136,7 @@ OWiProp_Generic_SelectItem( OBJtObject *object; char osd_name[256]; OBJtOSD_All *osd; - + // get a pointer to the osd osd = (OBJtOSD_All*)WMrDialog_GetUserData(inDialog); UUmAssert(osd); @@ -4148,10 +4148,10 @@ OWiProp_Generic_SelectItem( // get the currently selected object object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return; } - + // get the name of the selected object specific type OBJrObject_GetName(object, osd_name, 256); - + // select the appropriate item WMrMessage_Send( listbox, @@ -4169,18 +4169,18 @@ OWiListBox_ObjectType_EnumCallback( UUtUns32 inUserData) { WMtWindow *listbox; - + // get the list box listbox = (WMtWindow*)inUserData; if (listbox == NULL) { return UUcFalse; } - + // add the character to the list WMrMessage_Send( listbox, LBcMessage_AddString, (UUtUns32) inName, 0); - + return UUcTrue; } #endif @@ -4195,24 +4195,24 @@ OWiProp_Generic_InitDialog( OBJtObject *object; OBJtObjectType object_type; OBJtOSD_All *osd; - + // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, PGcLB_ObjectTypes); if (listbox == NULL) { return; } - + // get the currently selected object object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return; } - + // get the object type object_type = OBJrObject_GetType(object); - - // enumerate the object specific types + + // enumerate the object specific types OBJrObject_Enumerate( object, OWiListBox_ObjectType_EnumCallback, (UUtUns32)listbox); - + // allocate memory for the osd osd = (OBJtOSD_All*)UUrMemory_Block_NewClear(sizeof(OBJtOSD_All)); UUmAssert(osd); @@ -4220,10 +4220,10 @@ OWiProp_Generic_InitDialog( // get the object specific data OBJrObject_GetObjectSpecificData(object, osd); - + // set the keyboard focus to the listbox WMrWindow_SetFocus(listbox); - + // hilite the item currently in use OWiProp_Generic_SelectItem(inDialog); } @@ -4236,13 +4236,13 @@ OWiProp_Generic_Destroy( WMtDialog *inDialog) { void *data; - + data = (void*)WMrDialog_GetUserData(inDialog); UUmAssert(data); - + UUrMemory_Block_Delete(data); WMrDialog_SetUserData(inDialog, 0); - + OWgDialog_Prop = NULL; } #endif @@ -4259,16 +4259,16 @@ OWiProp_Generic_HandleCommand( WMtWindow *listbox; OBJtObjectType object_type; OBJtOSD_All *osd; - + // get a pointer to the osd osd = (OBJtOSD_All*)WMrDialog_GetUserData(inDialog); UUmAssert(osd); - + // get the object and object type object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return UUcTrue; } object_type = OBJrObject_GetType(object); - + switch (UUmLowWord(inParam1)) { case PGcLB_ObjectTypes: @@ -4277,11 +4277,11 @@ OWiProp_Generic_HandleCommand( char type_name[256]; OBJtOSD_All osd_all; UUtUns32 result; - + // get the listbox listbox = WMrDialog_GetItemByID(inDialog, PGcLB_ObjectTypes); if (listbox == NULL) { return UUcTrue; } - + // clear the OSD so we don't have garbage in it UUrMemory_Clear(&osd_all, sizeof(OBJtOSD_All)); @@ -4293,7 +4293,7 @@ OWiProp_Generic_HandleCommand( (UUtUns32)type_name, (UUtUns32)(-1)); if (result == LBcError) { break; } - + // set the OSD to reflect the change switch (object_type) { @@ -4324,7 +4324,7 @@ OWiProp_Generic_HandleCommand( osd_all.osd.powerup_osd.powerup_type = OBJrPowerUp_NameToType(type_name); osd_all.osd.powerup_osd.powerup = NULL; break; - + case OBJcType_Weapon: // copy the existing OSD data osd_all.osd.weapon_osd = *((OBJtOSD_Weapon *) object->object_data); @@ -4356,7 +4356,7 @@ OWiProp_Generic_HandleCommand( UUrString_Copy(osd_all.osd.melee_osd.name, type_name, SLcScript_MaxNameLength); break; } - + // set the object specific data OWrObjectProperties_SetOSD(inDialog, object, &osd_all); } @@ -4371,12 +4371,12 @@ OWiProp_Generic_HandleCommand( { // set the object specific data OWrObjectProperties_SetOSD(inDialog, object, osd); - + // hilite the item currently in use OWiProp_Generic_SelectItem(inDialog); } break; - + case WMcDialogItem_Cancel: WMrDialog_ModalEnd(inDialog, UUcFalse); break; @@ -4405,28 +4405,28 @@ OWiProp_Generic_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiProp_Generic_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiProp_Generic_Destroy(inDialog); return UUcFalse; - + case WMcMessage_Command: handled = OWiProp_Generic_HandleCommand(inDialog, inParam1, inParam2); break; - + default: handled = UUcFalse; break; } - + return handled; } #endif @@ -4445,7 +4445,7 @@ OWiProp_Furniture_Callback( OBJtOSD_Furniture * furniture_osd; handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: @@ -4457,11 +4457,11 @@ OWiProp_Furniture_Callback( WMrEditField_SetText(editfield, furniture_osd->furn_tag); } break; - + case WMcMessage_Destroy: OWiProp_Generic_Destroy(inDialog); return UUcFalse; - + case WMcMessage_Command: handled = OWiProp_Generic_HandleCommand(inDialog, inParam1, inParam2); @@ -4498,14 +4498,14 @@ OWiProp_Furniture_Callback( break; } } - } + } break; - + default: handled = UUcFalse; break; } - + return handled; } #endif @@ -4606,7 +4606,7 @@ OWiProp_TriggerVolume_Callback( #define base_ptr ((OBJtOSD_TriggerVolume *) NULL) - OWtFloatIncrement float_increment_table[] = + OWtFloatIncrement float_increment_table[] = { { cEditTriggerVolume_ScaleX, &base_ptr->scale.x, cEditTriggerVolume_ScaleX_Plus_One, +1.f }, { cEditTriggerVolume_ScaleX, &base_ptr->scale.x, cEditTriggerVolume_ScaleX_Minus_One, -1.f }, @@ -4678,7 +4678,7 @@ OWiProp_TriggerVolume_Callback( dirty = UUcTrue; handled = UUcTrue; - switch(UUmLowWord(inParam1)) + switch(UUmLowWord(inParam1)) { case cEditTriggerVolume_Name: WMrEditField_GetText(name_edit, trigger_volume_osd->name, sizeof(trigger_volume_osd->name)); @@ -4858,7 +4858,7 @@ OWrProp_Display( { OBJcType_Neutral, OWcDialog_AI_EditNeutral, OWrEditNeutral_Callback }, { OBJcType_Generic, OWcDialog_Prop_Generic, OWiProp_Generic_Callback }, }; - + if (NULL == inObject) { num_obj = OBJrSelectedObjects_GetNumSelected(); @@ -4876,7 +4876,7 @@ OWrProp_Display( WMcMessageBoxStyle_OK); return UUcFalse; } - + // get a pointer to the selected object inObject = OBJrSelectedObjects_GetSelectedObject(0); if (NULL == inObject) { return UUcFalse; } @@ -4886,14 +4886,14 @@ OWrProp_Display( // select the object that was passed in OBJrSelectedObjects_Select(inObject, UUcFalse); } - + // get the osd OBJrObject_GetObjectSpecificData(inObject, &object_specific_data); - + // get the object type this_object_type = OBJrObject_GetType(inObject); error = UUcError_Generic; - + // display the properties dialog for the selected object for(this_setup = setup_list; 1; this_setup++) { @@ -4903,7 +4903,7 @@ OWrProp_Display( break; } } - + // if there was an error or the user decided not to keep their changes then restore the object specific data if ((error != UUcError_None) || (!message)) { @@ -4914,7 +4914,7 @@ OWrProp_Display( { success = UUcTrue; } - + return success; #else return UUcFalse; @@ -4927,7 +4927,7 @@ OWrProp_IsVisible( void) { if (OWgDialog_Prop == NULL) { return UUcFalse; } - + return WMrWindow_GetVisible(OWgDialog_Prop); } @@ -4945,27 +4945,27 @@ OWiLightProp_SaveFields( WMtWindow *window; UUtUns16 index; char string[255]; - + // get the light properties light_prop = (OWtLightProp*)WMrDialog_GetUserData(inDialog); UUmAssert(light_prop); - + // get the index index = light_prop->current_index; - + // get the filter color window = WMrDialog_GetItemByID(inDialog, PLcEF_R); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 255); sscanf(string, "%f", &light_prop->ls_data_array[index].filter_color[0]); - + window = WMrDialog_GetItemByID(inDialog, PLcEF_G); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 255); sscanf(string, "%f", &light_prop->ls_data_array[index].filter_color[1]); - + window = WMrDialog_GetItemByID(inDialog, PLcEF_B); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 255); sscanf(string, "%f", &light_prop->ls_data_array[index].filter_color[2]); - + // get the light type light_prop->ls_data_array[index].light_flags &= ~(OBJcLightFlag_Type_Area | OBJcLightFlag_Type_Linear | OBJcLightFlag_Type_Point); @@ -4987,7 +4987,7 @@ OWiLightProp_SaveFields( light_prop->ls_data_array[index].light_flags |= OBJcLightFlag_Type_Point; } } - + // get the light distribution light_prop->ls_data_array[index].light_flags &= ~(OBJcLightFlag_Dist_Diffuse | OBJcLightFlag_Dist_Spot); @@ -5000,17 +5000,17 @@ OWiLightProp_SaveFields( { light_prop->ls_data_array[index].light_flags |= OBJcLightFlag_Dist_Spot; } - + // get the light intensity window = WMrDialog_GetItemByID(inDialog, PLcEF_Intensity); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 255); sscanf(string, "%d", &light_prop->ls_data_array[index].light_intensity); - + // get the light beam angle window = WMrDialog_GetItemByID(inDialog, PLcEF_BeamAngle); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 255); sscanf(string, "%f", &light_prop->ls_data_array[index].beam_angle); - + // get the light field angle window = WMrDialog_GetItemByID(inDialog, PLcEF_FieldAngle); WMrMessage_Send(window, EFcMessage_GetText, (UUtUns32)string, 255); @@ -5025,17 +5025,17 @@ OWiLightProp_SaveToObject( OWtLightProp *light_prop; OBJtOSD_All osd_all; UUtUns32 size; - + // get the light properties light_prop = (OWtLightProp*)WMrDialog_GetUserData(inDialog); UUmAssert(light_prop); - + // get the object osd OBJrObject_GetObjectSpecificData(light_prop->object, &osd_all); - + // calculate the size of the ls_data_array size = sizeof(OBJtLSData) * light_prop->num_ls_datas; - + // copy the data from the light properties to the object's ls_data_array UUrMemory_MoveFast(light_prop->ls_data_array, osd_all.osd.furniture_osd.ls_data_array, size); } @@ -5050,31 +5050,31 @@ OWiLightProp_SetFields( UUtUns16 index; UUtUns16 radiobutton; char string[255]; - + // get the light properties light_prop = (OWtLightProp*)WMrDialog_GetUserData(inDialog); UUmAssert(light_prop); - + // get the current node being edited window = WMrDialog_GetItemByID(inDialog, PLcPM_NodeName); WMrPopupMenu_GetItemID(window, -1, &index); - + // save the current index number light_prop->current_index = index; - + // set the filter color window = WMrDialog_GetItemByID(inDialog, PLcEF_R); sprintf(string, "%5.3f", light_prop->ls_data_array[index].filter_color[0]); WMrMessage_Send(window, EFcMessage_SetText, (UUtUns32)string, 0); - + window = WMrDialog_GetItemByID(inDialog, PLcEF_G); sprintf(string, "%5.3f", light_prop->ls_data_array[index].filter_color[1]); WMrMessage_Send(window, EFcMessage_SetText, (UUtUns32)string, 0); - + window = WMrDialog_GetItemByID(inDialog, PLcEF_B); sprintf(string, "%5.3f", light_prop->ls_data_array[index].filter_color[2]); WMrMessage_Send(window, EFcMessage_SetText, (UUtUns32)string, 0); - + // set the light type if (light_prop->ls_data_array[index].light_flags & OBJcLightFlag_Type_Area) { @@ -5088,9 +5088,9 @@ OWiLightProp_SetFields( { radiobutton = (UUtUns16)PLcRB_Point; } - + WMrDialog_RadioButtonCheck(inDialog, PLcRB_Area, PLcRB_Point, radiobutton); - + // set the light distribution if (light_prop->ls_data_array[index].light_flags & OBJcLightFlag_Dist_Diffuse) { @@ -5100,19 +5100,19 @@ OWiLightProp_SetFields( { radiobutton = (UUtUns16)PLcRB_Spot; } - + WMrDialog_RadioButtonCheck(inDialog, PLcRB_Diffuse, PLcRB_Spot, radiobutton); - + // set the light intensity window = WMrDialog_GetItemByID(inDialog, PLcEF_Intensity); sprintf(string, "%d", light_prop->ls_data_array[index].light_intensity); WMrMessage_Send(window, EFcMessage_SetText, (UUtUns32)string, 0); - + // set the light beam angle window = WMrDialog_GetItemByID(inDialog, PLcEF_BeamAngle); sprintf(string, "%5.3f", light_prop->ls_data_array[index].beam_angle); WMrMessage_Send(window, EFcMessage_SetText, (UUtUns32)string, 0); - + // set the light field angle window = WMrDialog_GetItemByID(inDialog, PLcEF_FieldAngle); sprintf(string, "%5.3f", light_prop->ls_data_array[index].field_angle); @@ -5130,36 +5130,36 @@ OWiLightProp_InitDialog( WMtWindow *popup; OBJtOSD_All osd_all; UUtUns32 size; - + object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { WMrDialog_ModalEnd(inDialog, UUcTrue); return; } - + light_prop = (OWtLightProp*)UUrMemory_Block_NewClear(sizeof(OWtLightProp)); if (light_prop == NULL) { WMrDialog_ModalEnd(inDialog, UUcTrue); return; } - + // save the light properties WMrDialog_SetUserData(inDialog, (UUtUns32)light_prop); - + // get the object specific data OBJrObject_GetObjectSpecificData(object, &osd_all); - + // set the light prop data light_prop->object = object; light_prop->current_index = 0; light_prop->num_ls_datas = osd_all.osd.furniture_osd.num_ls_datas; light_prop->ls_data_array = NULL; - + // calculate the size of the ls_data_array size = sizeof(OBJtLSData) * light_prop->num_ls_datas; - + // allocate memory for the ls_data_array light_prop->ls_data_array = (OBJtLSData*)UUrMemory_Block_New(size); if (light_prop->ls_data_array == NULL) @@ -5168,17 +5168,17 @@ OWiLightProp_InitDialog( WMrDialog_ModalEnd(inDialog, UUcTrue); return; } - + // copy the gq_data_array from the osd to the light_prop UUrMemory_MoveFast(osd_all.osd.furniture_osd.ls_data_array, light_prop->ls_data_array, size); - + // build the popup menu popup = WMrDialog_GetItemByID(inDialog, PLcPM_NodeName); for (i = 0; i < light_prop->num_ls_datas; i++) { WMtMenuItemData item_data; UUtUns32 index; - + index = light_prop->ls_data_array[i].index; item_data.flags = WMcMenuItemFlag_Enabled; @@ -5187,10 +5187,10 @@ OWiLightProp_InitDialog( item_data.title, TMrInstance_GetInstanceName(osd_all.osd.furniture_osd.furn_geom_array->furn_geom[index].geometry), WMcMaxTitleLength); - + WMrPopupMenu_AppendItem(popup, &item_data); } - + WMrPopupMenu_SetSelection(popup, 0); } @@ -5200,7 +5200,7 @@ OWiLightProp_Destroy( WMtDialog *inDialog) { OWtLightProp *light_prop; - + // delete the memory used light_prop = (OWtLightProp*)WMrDialog_GetUserData(inDialog); if (light_prop) @@ -5210,10 +5210,10 @@ OWiLightProp_Destroy( UUrMemory_Block_Delete(light_prop->ls_data_array); light_prop->ls_data_array = NULL; } - + UUrMemory_Block_Delete(light_prop); } - + OWgDialog_LightProp = NULL; } @@ -5231,24 +5231,24 @@ OWiLightProp_HandleCommand( OWiLightProp_SaveToObject(inDialog); WMrDialog_ModalEnd(inDialog, UUcTrue); break; - + case WMcDialogItem_Cancel: WMrDialog_ModalEnd(inDialog, UUcFalse); break; - + case PLcRB_Area: case PLcRB_Linear: case PLcRB_Point: WMrDialog_RadioButtonCheck(inDialog, PLcRB_Area, PLcRB_Point, (UUtUns16)UUmLowWord(inParam1)); OWiLightProp_SaveFields(inDialog); break; - + case PLcRB_Diffuse: case PLcRB_Spot: WMrDialog_RadioButtonCheck(inDialog, PLcRB_Diffuse, PLcRB_Spot, (UUtUns16)UUmLowWord(inParam1)); OWiLightProp_SaveFields(inDialog); break; - + default: OWiLightProp_SaveFields(inDialog); break; @@ -5264,32 +5264,32 @@ OWiLightProp_Callback( UUtUns32 inParam2) { UUtBool handled; - + handled = UUcTrue; - + switch (inMessage) { case WMcMessage_InitDialog: OWiLightProp_InitDialog(inDialog); break; - + case WMcMessage_Destroy: OWiLightProp_Destroy(inDialog); return UUcFalse; - + case WMcMessage_Command: OWiLightProp_HandleCommand(inDialog, inParam1, inParam2); break; - + case WMcMessage_MenuCommand: OWiLightProp_SetFields(inDialog); break; - + default: handled = UUcFalse; break; } - + return handled; } @@ -5299,7 +5299,7 @@ OWrLightProp_Display( void) { UUtError error; - + if ((OWgDialog_Pos == NULL) && (OWgDialog_Prop == NULL) && (OBJrSelectedObjects_GetNumSelected() == 1) && @@ -5308,7 +5308,7 @@ OWrLightProp_Display( error = WMrDialog_Create(OWcDialog_Prop_Light, NULL, OWiLightProp_Callback, 0, &OWgDialog_LightProp); UUmError_ReturnOnError(error); } - + return UUcError_None; } @@ -5320,25 +5320,25 @@ OWrLightProp_HasLight( OBJtObject *object; OBJtOSD_All osd_all; UUtUns32 i; - + // must be only one object selected if (OBJrSelectedObjects_GetNumSelected() != 1) { return UUcFalse; } - + object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return UUcFalse; } - + // object must be of type furniture if (OBJrObject_GetType(object) != OBJcType_Furniture) { return UUcFalse; } - + // get the object specific data OBJrObject_GetObjectSpecificData(object, &osd_all); - + // see if any of the geometries have light data associated with them for (i = 0; i < osd_all.osd.furniture_osd.furn_geom_array->num_furn_geoms; i++) { if (osd_all.osd.furniture_osd.furn_geom_array->furn_geom[i].ls_data != NULL) { return UUcTrue; } } - + return UUcFalse; } @@ -5356,11 +5356,11 @@ OWiProp_Particle_SetFields( OBJtOSD_All *osd_all; WMtWindow *window; // char string[255]; - + // get the particle object's properties osd_all = (OBJtOSD_All*)WMrDialog_GetUserData(inDialog); UUmAssert(osd_all); - + // update the controls // particle class @@ -5414,11 +5414,11 @@ OWiProp_Particle_InitDialog( P3tParticleClass *particle_class; // WMtWindow *popup; WMtWindow *editfield; - + // get the currently selected object object = OBJrSelectedObjects_GetSelectedObject(0); if (object == NULL) { return; } - + // must be a particle object! object_type = OBJrObject_GetType(object); if (object_type != OBJcType_Particle) { @@ -5429,13 +5429,13 @@ OWiProp_Particle_InitDialog( // get a pointer to the listbox listbox = WMrDialog_GetItemByID(inDialog, PPcLB_ClassList); if (listbox == NULL) { return; } - + // iterate all particle classes and place their names in the list particle_itr = P3cParticleClass_None; while (P3rIterateClasses(&particle_itr, &particle_class)) { WMrMessage_Send(listbox, LBcMessage_AddString, (UUtUns32) particle_class->classname, 0); } - + // allocate memory for the dialog's OSD osd = (OBJtOSD_All*)UUrMemory_Block_NewClear(sizeof(OBJtOSD_All)); UUmAssert(osd); @@ -5446,10 +5446,10 @@ OWiProp_Particle_InitDialog( // set the maximum number of characters in the editfields editfield = WMrDialog_GetItemByID(inDialog, PPcEF_Tag); WMrMessage_Send(editfield, EFcMessage_SetMaxChars, OBJcParticleTagNameLength, 0); - + // set the keyboard focus to the listbox WMrWindow_SetFocus(listbox); - + // set the fields OWiProp_Particle_SetFields(inDialog); } @@ -5498,7 +5498,7 @@ OWiProp_Particle_NewClass( // get a pointer to the object object = OBJrSelectedObjects_GetSelectedObject(0); UUmAssert(object); - + // set the decal sizes and angle editfield = (WMtEditField *) WMrDialog_GetItemByID(inDialog, PPcEF_SizeX); WMrEditField_SetFloat(editfield, osd_all->osd.particle_osd.particle.decal_xscale); @@ -5527,7 +5527,7 @@ OWiProp_Particle_SaveOSD( OBJtOSD_Particle *particle_osd; char string[OBJcMaxNoteChars + 1]; float x_scale, y_scale, angle; - + if (OBJrObjectType_IsLocked(OBJcType_Particle) == UUcTrue) { WMrDialog_MessageBox(inDialog, "Error", "The Particle file is locked, you cannot make changes.", @@ -5535,11 +5535,11 @@ OWiProp_Particle_SaveOSD( WMrDialog_ModalEnd(inDialog, UUcFalse); return UUcError_Generic; } - + // get a pointer to the object object = OBJrSelectedObjects_GetSelectedObject(0); UUmAssert(object); - + particle_osd = (OBJtOSD_Particle *) object->object_data; osd_all.osd.particle_osd = *particle_osd; @@ -5591,7 +5591,7 @@ OWiProp_Particle_SaveOSD( OWrObjectProperties_SetOSD(inDialog, object, &osd_all); OBJrObject_UpdatePosition(object); - + return UUcError_None; } #endif @@ -5611,7 +5611,7 @@ OWrProp_Particle_Callback( float value, value_delta; OBJtOSD_All * osd_all; WMtWindow * window; - + handled = UUcTrue; osd_all = (OBJtOSD_All *) WMrDialog_GetUserData(inDialog); @@ -5620,7 +5620,7 @@ OWrProp_Particle_Callback( case WMcMessage_InitDialog: OWiProp_Particle_InitDialog(inDialog); break; - + case WMcMessage_Destroy: UUrMemory_Block_Delete(osd_all); break; @@ -5660,7 +5660,7 @@ OWrProp_Particle_Callback( error = OWiProp_Particle_SaveOSD(inDialog); WMrDialog_ModalEnd(inDialog, (error == UUcError_None) ? UUcTrue : UUcFalse); break; - + case WMcDialogItem_Cancel: WMrDialog_ModalEnd(inDialog, UUcFalse); break; @@ -5688,12 +5688,12 @@ OWrProp_Particle_Callback( OWiProp_Particle_SaveOSD(inDialog); } break; - + default: handled = UUcFalse; break; } - + return handled; } #endif @@ -5717,26 +5717,26 @@ OWrTools_CreateObject( float pitch; // determine the position of the object - switch(inObjectType) + switch(inObjectType) { case OBJcType_Door: case OBJcType_Console: - if (CAgCamera.mode == CAcMode_Follow) + if (CAgCamera.mode == CAcMode_Follow) { player_character = CAgCamera.star; UUmAssert(player_character != NULL); - + position = CArGetLocation(); facing = CArGetFacing(); MUmVector_Set(rotation, 0, player_character->facing * M3cRadToDeg, 0); - + rotation.y += 180; if( rotation.y > 360.0 ) rotation.y -= 360; - - position.x = player_character->location.x; - position.z = player_character->location.z; + + position.x = player_character->location.x; + position.z = player_character->location.z; position.x += MUrSin( player_character->facing ) * 10; position.z += MUrCos( player_character->facing ) * 10; @@ -5758,28 +5758,28 @@ OWrTools_CreateObject( position.x += facing.x; position.y += facing.y; position.z += facing.z; - + rotation.x = 0.0f; rotation.y = horiz_facing; rotation.z = 0.0f; } break; - + case OBJcType_Particle: { facing = CArGetFacing(); - + horiz_facing = MUrATan2(facing.x, facing.z); pitch = MUrASin( (float)fabs(facing.y) ); - + if( facing.y > 0 ) pitch = -pitch; UUmTrig_Clip( pitch ); UUmTrig_Clip( horiz_facing ); - - if (CAgCamera.mode == CAcMode_Follow) + + if (CAgCamera.mode == CAcMode_Follow) { ONrCharacter_GetEyePosition(CAgCamera.star, &position); MUmVector_ScaleIncrement(position, 10.0f, facing); @@ -5789,11 +5789,11 @@ OWrTools_CreateObject( position = CAgCamera.viewData.location; MUmVector_ScaleIncrement(position, 35.0f, facing); } - + MUmVector_Set(rotation, pitch * M3cRadToDeg, horiz_facing * M3cRadToDeg, 0); } break; - + case OBJcType_Character: case OBJcType_Flag: // appear at the position of the player character if possible @@ -5802,31 +5802,31 @@ OWrTools_CreateObject( UUmAssert(player_character != NULL); position = player_character->location; - + MUmVector_Set(rotation, 0, player_character->facing * M3cRadToDeg, 0); break; } // otherwise fall through - + default: // appear in front of the camera position = CArGetLocation(); facing = CArGetFacing(); - + MUmVector_Scale(facing, 35.0f); - + // put the object in front of the camera position.x += facing.x; position.y += facing.y; position.z += facing.z; - + rotation.x = 0.0f; rotation.y = 0.0f; rotation.z = 0.0f; break; } - + // apply gravity for specific object types switch (inObjectType) { @@ -5841,9 +5841,9 @@ OWrTools_CreateObject( { UUtBool result; M3tVector3D vector; - + MUmVector_Set(vector, 0.0f, -255.0f, 0.0f); - + result = AKrCollision_Point( ONrGameState_GetEnvironment(), @@ -5859,7 +5859,7 @@ OWrTools_CreateObject( } break; } - + // create the object based on its type and name error = OBJrObject_New( @@ -5889,7 +5889,7 @@ OWiTools_EnumCategories( OWgCategories[OWgNumCategories].object_type = inObjectType; UUrString_Copy(OWgCategories[OWgNumCategories].name, inName, OBJcMaxNameLength); OWgNumCategories++; - + return UUcTrue; } @@ -5900,17 +5900,17 @@ OWrTools_Initialize( { UUmAssert(OWgDialog_ObjNew == NULL); UUmAssert(OWgDialog_Prop == NULL); - + // clear the categories UUrMemory_Clear(OWgCategories, sizeof(OWtCategory) * OWcMaxCategories); OWgNumCategories = 0; - + // enumerate the object types OBJrObjectTypes_Enumerate(OWiTools_EnumCategories, 0); - + return UUcError_None; } - + // ---------------------------------------------------------------------- void OWrTools_Terminate(void) { @@ -5923,7 +5923,7 @@ void OWrTools_Terminate(void) UUtError OWrStringListDialog_Create( OWtStringListDlgInstance* inInstance ) { UUmAssert( inInstance ); - + inInstance->string_array = UUrMemory_Array_New( OWcStringListDlg_MaxStringLength, OWcStringListDlg_MaxStringLength, 0, 0 ); inInstance->dialog = NULL; inInstance->selected_index = -1; @@ -5937,9 +5937,9 @@ UUtError OWrStringListDialog_Destroy( OWtStringListDlgInstance* inInstance ) { UUmAssert( inInstance ); UUmAssert( inInstance->string_array ); - + UUrMemory_Array_Delete( inInstance->string_array ); - + inInstance->string_array = NULL; inInstance->dialog = NULL; @@ -5974,7 +5974,7 @@ static UUtBool OWiStringListDialog_Callback( WMtDialog *inDialog, WMtMessage inM instance = (OWtStringListDlgInstance*) WMrDialog_GetUserData(inDialog); UUmAssert( instance && instance->string_array ); - + handled = UUcTrue; switch (inMessage) @@ -5993,7 +5993,7 @@ static UUtBool OWiStringListDialog_Callback( WMtDialog *inDialog, WMtMessage inM { WMrWindow_SetTitle( (WMtWindow*) inDialog, instance->title, OWcStringListDlg_MaxStringLength ); } - + // set list title if( instance->list_title[0] ) { @@ -6014,12 +6014,12 @@ static UUtBool OWiStringListDialog_Callback( WMtDialog *inDialog, WMtMessage inM WMrMessage_Send( window, LBcMessage_SetSelection, (UUtUns32) 0, instance->selected_index ); WMrWindow_SetFocus( window ); } - break; + break; case WMcMessage_Destroy: UUmAssert( instance->dialog ); instance->dialog = NULL; - break; + break; case WMcMessage_Command: UUmAssert( instance->dialog ); @@ -6052,7 +6052,7 @@ static UUtBool OWiStringListDialog_Callback( WMtDialog *inDialog, WMtMessage inM } UUtError OWrStringListDialog_SetTitle( OWtStringListDlgInstance* inInstance, char* inTitle ) -{ +{ UUmAssert( inInstance && inInstance->string_array ); UUrString_Copy( inInstance->title, inTitle, OWcStringListDlg_MaxStringLength ); @@ -6066,7 +6066,7 @@ UUtError OWrStringListDialog_SetTitle( OWtStringListDlgInstance* inInstance, cha } UUtError OWrStringListDialog_SetListTitle( OWtStringListDlgInstance* inInstance, char* inTitle ) -{ +{ UUmAssert( inInstance && inInstance->string_array ); UUrString_Copy( inInstance->list_title, inTitle, OWcStringListDlg_MaxStringLength ); diff --git a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Tools.h b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Tools.h index 10e83fe..2af1a11 100644 --- a/OniProj/OniGameSource/Oni_Windows/Oni_Win_Tools.h +++ b/OniProj/OniGameSource/Oni_Windows/Oni_Win_Tools.h @@ -18,7 +18,7 @@ enum EOcEF_AbsLocX = 100, EOcEF_AbsLocY = 101, EOcEF_AbsLocZ = 102, - + EOcEF_OffLocX = 103, EOcEF_OffLocY = 104, EOcEF_OffLocZ = 105, @@ -29,7 +29,7 @@ enum EOcBtn_LocY_Dec_0_1 = 109, EOcBtn_LocZ_Inc_0_1 = 110, EOcBtn_LocZ_Dec_0_1 = 111, - + EOcBtn_LocX_Inc_1_0 = 112, EOcBtn_LocX_Dec_1_0 = 113, EOcBtn_LocY_Inc_1_0 = 114, @@ -43,19 +43,19 @@ enum EOcBtn_LocY_Dec_10_0 = 121, EOcBtn_LocZ_Inc_10_0 = 122, EOcBtn_LocZ_Dec_10_0 = 123, - + EOcTxt_RotType = 148, EOcEF_RotX = 124, EOcEF_RotY = 125, EOcEF_RotZ = 126, - + EOcBtn_RotX_Inc_1 = 127, EOcBtn_RotX_Dec_1 = 128, EOcBtn_RotY_Inc_1 = 129, EOcBtn_RotY_Dec_1 = 130, EOcBtn_RotZ_Inc_1 = 131, EOcBtn_RotZ_Dec_1 = 132, - + EOcBtn_RotX_Inc_15 = 133, EOcBtn_RotX_Dec_15 = 134, EOcBtn_RotY_Inc_15 = 135, @@ -69,7 +69,7 @@ enum EOcBtn_RotY_Dec_90 = 142, EOcBtn_RotZ_Inc_90 = 143, EOcBtn_RotZ_Dec_90 = 144, - + EOcBtn_Revert = 145, EOcBtn_Gravity = 147, EOcBtn_Apply = 146 @@ -93,7 +93,7 @@ enum { PDcLB_DoorTypes = 100, PDcEF_ID = 102, - + PDcCB_InitialLocked = 103, PDcCB_Locked = 104, PDcCB_Test = 105, @@ -101,7 +101,7 @@ enum PDcEF_ActivationRadius = 107, PDcCB_DoubleDoors = 108, PDcCB_ManualDoor = 109, - + PDcPM_Texture0 = 110, PDcPM_Texture1 = 111, @@ -270,13 +270,13 @@ enum PCcPM_GunshotHeard = 121, PCcPM_VisualContact = 122, PCcPM_Attacked = 123, - + PCcPM_LongRange = 124, PCcPM_MediumRange = 125, PCcPM_HandToHand = 126, PCcPM_MediumRetreat = 127, PCcPM_LongRetreat = 128, - + PCcBtn_Revert = 129, PCcBtn_Cancel = WMcDialogItem_Cancel, PCcBtn_Save = WMcDialogItem_OK @@ -305,7 +305,7 @@ enum PLcEF_Intensity = 109, PLcEF_BeamAngle = 110, PLcEF_FieldAngle = 111 - + }; enum @@ -386,7 +386,7 @@ UUtError OWrTools_CreateObject( OBJtObjectType inObjectType, const OBJtOSD_All *inObjectSpecificData); - + UUtError OWrTools_Initialize( void); @@ -396,29 +396,29 @@ OWrTools_Terminate( void); UUtBool OWrObjectProperties_SetOSD(WMtDialog *inDialog, OBJtObject *inObject, OBJtOSD_All *inOSD); - + // ---------------------------------------------------------------------- UUtError OWrEOPos_Display( void); - + UUtBool OWrEOPos_IsVisible( void); - + // ---------------------------------------------------------------------- UUtError OWrObjNew_Display( void); - + UUtBool OWrObjNew_IsVisible( void); - + // ---------------------------------------------------------------------- UUtBool OWrProp_Display(OBJtObject *inObject); - + UUtBool OWrProp_IsVisible( void); @@ -431,7 +431,7 @@ OWrLightProp_Display( UUtBool OWrLightProp_HasLight( void); - + UUtBool OWrLightProp_IsVisible( void); @@ -465,4 +465,4 @@ UUtError OWrStringListDialog_SetListTitle( OWtStringListDlgInstance* inInstance, // ====================================================================== -#endif /* ONI_WIN_TOOLS_H */ \ No newline at end of file +#endif /* ONI_WIN_TOOLS_H */ diff --git a/OniProj/OniGameSource/Oni_Windows2.c b/OniProj/OniGameSource/Oni_Windows2.c index b31000c..eb28920 100644 --- a/OniProj/OniGameSource/Oni_Windows2.c +++ b/OniProj/OniGameSource/Oni_Windows2.c @@ -37,29 +37,29 @@ OWrLevelList_Initialize( UUtError error; UUtUns32 num_descriptors; UUtBool vidmaster = UUcFalse; - + // get the number of descriptors num_descriptors = (UUtUns16)TMrInstance_GetTagCount(ONcTemplate_Level_Descriptor); if (num_descriptors > 0) { UUtUns32 i; WMtListBox *levels; - + // get a pointer to the level list levels = WMrDialog_GetItemByID(inDialog, inItemID); if (levels == NULL) return; - + for (i = 0; i < num_descriptors; i++) { ONtLevel_Descriptor *descriptor; UUtUns32 index; - + // get a pointer to the first descriptor error = TMrInstance_GetDataPtr_ByNumber(ONcTemplate_Level_Descriptor, i, &descriptor); if (error != UUcError_None) { return; } - + // if the level in the descriptor doesn't exist, move on // to the next descriptor if (!TMrLevel_Exists(descriptor->level_number)) { @@ -72,7 +72,7 @@ OWrLevelList_Initialize( continue; } } -#endif +#endif // add the name of the level to the list index = WMrListBox_AddString(levels, descriptor->level_name); @@ -85,7 +85,7 @@ OWrLevelList_Initialize( const ONtContinue *save_point; for(save_point_index = 0; save_point_index < ONcPersist_NumContinues; save_point_index++) - { + { save_point = ONrPersist_GetContinue(descriptor->level_number, save_point_index); if (save_point != NULL) { @@ -114,11 +114,11 @@ OWrLevelList_GetLevelNumber( { WMtWindow *levels; UUtUns16 level_number; - + // get a pointer to the levels listbox levels = WMrDialog_GetItemByID(inDialog, inItemID); if (levels == NULL) { return (UUtUns16)(-1); } - + // get the level number of the selected item level_number = (UUtUns16)WMrListBox_GetItemData(levels, (UUtUns32)(-1)); return level_number; @@ -129,10 +129,10 @@ void OWrLevelLoad_StartLevel( UUtUns16 inLevel) { - UUtUns16 num_descriptors; + UUtUns16 num_descriptors; UUtUns16 level_number = inLevel & 0x00ff; UUtUns16 save_point = (inLevel & 0xff00) >> 8; - + // get the number of descriptors num_descriptors = (UUtUns16)TMrInstance_GetTagCount(ONcTemplate_Level_Descriptor); if (num_descriptors > 0) @@ -150,13 +150,13 @@ OWrLevelLoad_StartLevel( { ONrLevel_Unload(); } - + // try to load the new level ONrGameState_ClearContinue(); if (save_point != 0) { const ONtContinue *save_point_data = ONrPersist_GetContinue(level_number, save_point); - + UUmAssert(save_point_data != NULL); if (NULL != save_point_data) { @@ -164,7 +164,7 @@ OWrLevelLoad_StartLevel( } } - ONrLevel_Load(OWgLevelNumber, UUcTrue); + ONrLevel_Load(OWgLevelNumber, UUcTrue); // run the game WMrMessage_Post(NULL, OWcMessage_RunGame, 0, 0); @@ -183,7 +183,7 @@ OWrOniWindow_Startup( { // set the desktop background to none WMrSetDesktopBackground(PSrPartSpec_LoadByType(PScPartSpecType_BackgroundColor_None)); - + // run the main menu OWrOniWindow_Toggle(); } @@ -195,9 +195,9 @@ OWrOniWindow_Toggle( { WMrActivate(); LIrMode_Set(LIcMode_Normal); - + ONrOutGameUI_MainMenu_Display(); - + LIrMode_Set(LIcMode_Game); WMrDeactivate(); } @@ -227,7 +227,7 @@ OWrInitialize( // ------------------------------ error = WMrStartup(); UUmError_ReturnOnError(error); - + OWgLevelNumber = (UUtUns16)0xFFFF; return UUcError_None; @@ -240,7 +240,7 @@ OWrInitialize( { UUtBool success= UUcFalse; WMtWindow *desktop= WMrGetDesktop(); - + if (OWgOniWindow) WMrWindow_SetSize(OWgOniWindow, new_width, new_height); if (desktop) WMrWindow_SetSize(desktop, new_width, new_height); success= (ONrMotoko_SetupDrawing(&ONgPlatformData) == UUcError_None) ? UUcTrue : UUcFalse; @@ -269,18 +269,18 @@ OWrLevelEnd( void) { } - + // ---------------------------------------------------------------------- void OWrUpdate( void) { WMtEvent event; - + while (WMrMessage_Get(&event)) { UUtUns32 handled; - + handled = WMrMessage_Dispatch(&event); if (handled == WMcResult_NoWindow) { @@ -289,7 +289,7 @@ OWrUpdate( case WMcMessage_Quit: ONgTerminateGame = UUcTrue; break; - + // Oni defined messages case OWcMessage_RunGame: OWgRunStartup = UUcFalse; @@ -342,4 +342,4 @@ UUtError OWrSave_Particles(UUtBool inAutosave) return UUcError_None; } -#endif \ No newline at end of file +#endif diff --git a/OniProj/OniGameSource/Platform_MacOS/Oni_Mac_Keys.h b/OniProj/OniGameSource/Platform_MacOS/Oni_Mac_Keys.h index 3c09066..61435eb 100644 --- a/OniProj/OniGameSource/Platform_MacOS/Oni_Mac_Keys.h +++ b/OniProj/OniGameSource/Platform_MacOS/Oni_Mac_Keys.h @@ -1,12 +1,12 @@ /* FILE: Oni_Mac_Keys.h - + AUTHOR: Brent H. Pease - + CREATED: April 2, 1997 - + PURPOSE: Macintosh specific code - + Copyright 1997 */ diff --git a/OniProj/OniGameSource/Platform_MacOS/Oni_Platform_Mac.c b/OniProj/OniGameSource/Platform_MacOS/Oni_Platform_Mac.c index 9cbace9..8c1e586 100644 --- a/OniProj/OniGameSource/Platform_MacOS/Oni_Platform_Mac.c +++ b/OniProj/OniGameSource/Platform_MacOS/Oni_Platform_Mac.c @@ -1,12 +1,12 @@ /* FILE: Oni_Platform_Mac.c - + AUTHOR: Brent H. Pease - + CREATED: April 2, 1997 - + PURPOSE: Macintosh specific code - + Copyright 1997 */ @@ -59,7 +59,7 @@ static Boolean changed_display_device= false; #if defined(DEBUGGING) && DEBUGGING #define DEBUG_AKIRA 1 - + #endif #if defined(DEBUG_AKIRA) && DEBUG_AKIRA @@ -87,7 +87,7 @@ static UUtUns32 macos_read_display_pref( { UUtUns32 pref= 0L; Handle pref_handle; - + pref_handle= GetResource('pref', MAC_PREF_RSRC_ID); if (pref_handle && (GetHandleSize(pref_handle) == sizeof(UUtUns32))) { @@ -96,7 +96,7 @@ static UUtUns32 macos_read_display_pref( HUnlock(pref_handle); ReleaseResource(pref_handle); } - + return pref; } @@ -104,7 +104,7 @@ static void macos_write_display_pref( UUtUns32 pref) { Handle pref_handle; - + pref_handle= GetResource('pref', MAC_PREF_RSRC_ID); if (pref_handle) { @@ -116,7 +116,7 @@ static void macos_write_display_pref( WriteResource(pref_handle); ReleaseResource(pref_handle); } - + return; } @@ -137,14 +137,14 @@ static pascal Boolean device_list_filter( if ((event->what == updateEvt) && (event->message == (UInt32)dialog)) { Cell item_cell; - + BeginUpdate((WindowPtr)dialog); - + LUpdate(GetPortVisibleRegion(GetDialogPort(dialog), NULL), device_list); - + item_cell.h= 0; item_cell.v= 0; - + while (item_cell.v < device_count) { LDraw(item_cell, device_list); @@ -155,7 +155,7 @@ static pascal Boolean device_list_filter( // push it outwards one pixel and frame the list InsetRect(&temp_rect, -1, -1); FrameRect(&temp_rect); - + EndUpdate((WindowPtr)dialog); } else @@ -174,7 +174,7 @@ static pascal Boolean device_list_filter( if (PtInRect(point, &temp_rect)) { Boolean clicked= LClick(point, nil, device_list); - + // if they double-clicked the list, return 1, as if the OK button had been pressed *item_hit= clicked ? _button_ok : _list_item; event_handled= true; @@ -200,39 +200,39 @@ static GDHandle mac_enumerate_display_devices( Rect item_rect; Handle item_handle; OSErr err= noErr; - + selected_device= DMGetFirstScreenDevice(true); dialog= GetNewDialog(MAC_DISPLAY_SELECT_RSRC_ID, nil, (WindowPtr)-1L); - + if (dialog) { //ModalFilterUPP modal_filter_UPP= (ModalFilterUPP)NewModalFilterProc(device_list_filter); ModalFilterUPP modal_filter_UPP= (ModalFilterUPP)device_list_filter; - + GetDialogItem(dialog, _list_item, &item_hit, &item_handle, &item_rect); item_rect.right-= 16; // make room for scroll bar - + device_list= LNew(&item_rect, &list_rect, item_cell, nil, (WindowPtr)dialog, false, false, false, true); if (device_list) { LSetDrawingMode(true, device_list); - + display_devices[0]= GetDeviceList(); - + while (display_devices[device_count] && (device_count < MAX_DISPLAY_DEVICES) && (err == noErr)) { DisplayIDType display_id; - + err= DMGetDisplayIDByGDevice(display_devices[device_count], &display_id, false); if (err == noErr) { Str255 display_name= "\p"; - + err= DMGetNameByAVID(display_id, 0L, display_name); if (err == noErr) { int list_count= LAddRow(1, device_count, device_list); - + UUmAssert(list_count == device_count); item_cell.h= 0; item_cell.v= list_count; @@ -248,11 +248,11 @@ static GDHandle mac_enumerate_display_devices( UUtUns32 display_pref; int saved_display_index; // will be saved as a base-1 integer UUtBool option_key_down; - + display_pref= macos_read_display_pref(); saved_display_index= (display_pref >> _mac_saved_display_index_pref_shift); option_key_down= LIrPlatform_TestKey(LIcKeyCode_LeftOption, 0); - + if (saved_display_index && (saved_display_index <= device_count) && (option_key_down == UUcFalse)) { // use saved display index @@ -265,20 +265,20 @@ static GDHandle mac_enumerate_display_devices( SetPort(GetDialogPort(dialog)); ShowWindow((WindowPtr)dialog); DrawDialog(dialog); - + item_cell.h= 0; item_cell.v= 0; - + while (item_cell.v < device_count) { LDraw(item_cell, device_list); item_cell.v++; } - + do { ModalDialog(modal_filter_UPP, &item_hit); - + if (item_hit == _save_device_check_box) { GetDialogItem(dialog, _save_device_check_box, &item_type, &item_handle, &item_rect); @@ -288,20 +288,20 @@ static GDHandle mac_enumerate_display_devices( } } } while ((item_hit != _button_ok) && (item_hit != _button_cancel)); - + if (item_hit == _button_ok) { item_cell.h= 0; item_cell.v= 0; - + if (LGetSelect(true, &item_cell, device_list)) { if (display_devices[item_cell.v] != NULL) { UUtUns32 save_device= 0; - + selected_device= display_devices[item_cell.v]; - + // do we need to save the selected display index? GetDialogItem(dialog, _save_device_check_box, &item_type, &item_handle, &item_rect); if (item_handle) @@ -321,19 +321,19 @@ static GDHandle mac_enumerate_display_devices( } } } - + LDispose(device_list); } - + DisposeModalFilterUPP(modal_filter_UPP); DisposeDialog(dialog); } - + if (selected_device == NULL) { selected_device= GetMainDevice(); } - + return selected_device; } @@ -343,7 +343,7 @@ static void mac_restore_original_display_device( if (changed_display_device) { OSErr err; - + // restore original device err= DMGetGDeviceByDisplayID(original_display_id, &original_device, true); if (err == noErr) @@ -355,7 +355,7 @@ static void mac_restore_original_display_device( err= DMEndConfigureDisplays(display_state_handle); UUmAssert(err == noErr); } - + return; } @@ -363,16 +363,16 @@ static Boolean mac_change_display_device( GDHandle new_device) { Boolean success= false; - + if (original_device == NULL) { original_device= GetMainDevice(); } - + if (new_device && (new_device != original_device)) { OSErr err; - + // save and change main device err= DMGetDisplayIDByGDevice(original_device, &original_display_id, true); if (err == noErr) @@ -395,7 +395,7 @@ static Boolean mac_change_display_device( { success= true; } - + return success; } @@ -421,7 +421,7 @@ static void mac_hide_menu_bar( HideMenuBar(); menu_bar_is_visible= FALSE; } - + return; } @@ -432,7 +432,7 @@ static void mac_show_menu_bar( { ShowMenuBar(); } - + return; } @@ -447,19 +447,19 @@ ONrPlatform_Initialize( GDHandle device; DisplayIDType displayID; DSpContextAttributes attributes; -#endif +#endif short width, height, depth; GDHandle selected_display_device; - + selected_display_device= mac_enumerate_display_devices(); UUmAssert(selected_display_device); - + if (mac_change_display_device(selected_display_device) == false) { AUrMessageBox(AUcMBType_OK, "Whoa, something bad happened while trying to change the display device. Try playing Oni from your main monitor next time."); exit(0); } - + depth= 16; if (GetQDGlobalsScreenBits(&screen_bits) != NULL) { @@ -471,7 +471,7 @@ ONrPlatform_Initialize( width= 640; height= 480; } - + #ifdef USE_DRAW_SPROCKET // start draw sprocket status = DSpStartup(); @@ -479,7 +479,7 @@ ONrPlatform_Initialize( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to start Draw Sprocket"); } - + // initialize the draw sprocket attributes ONgDSp_ContextAttributes.frequency = 0; ONgDSp_ContextAttributes.displayWidth = width; //ONgCommandLine.width; @@ -499,14 +499,14 @@ ONrPlatform_Initialize( ONgDSp_ContextAttributes.reserved3[1] = 0; ONgDSp_ContextAttributes.reserved3[2] = 0; ONgDSp_ContextAttributes.reserved3[3] = 0; - + // create the draw sprocket context status = DSpCanUserSelectContext(&ONgDSp_ContextAttributes, &select_possible); if (status != noErr) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Problem with Draw Sprockets"); } - + if (select_possible) { device = DMGetFirstScreenDevice(UUcTrue); @@ -514,13 +514,13 @@ ONrPlatform_Initialize( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "No Screen devices available"); } - + status = DMGetDisplayIDByGDevice(device, &displayID, UUcTrue); if (status != noErr) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to get Display ID from GDevice"); } - + status = DSpUserSelectContext( &ONgDSp_ContextAttributes, @@ -531,7 +531,7 @@ ONrPlatform_Initialize( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "User unable to select context"); } - + /* status = DSpContext_GetAttributes(ONgDSp_Context, &attributes); if (status != noErr) { @@ -546,13 +546,13 @@ ONrPlatform_Initialize( UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to find a suitable device"); } } - + status = DSpContext_Reserve(ONgDSp_Context, &ONgDSp_ContextAttributes); if (status != noErr) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to create the display"); } - + status = DSpContext_GetAttributes(ONgDSp_Context, &attributes); if (status != noErr) { @@ -564,19 +564,19 @@ ONrPlatform_Initialize( { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to fade the display"); } - + status = DSpContext_SetState(ONgDSp_Context, kDSpContextState_Active); if ((status != noErr) && (status != kDSpConfirmSwitchWarning)) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to set the display"); } - + status = DSpContext_FadeGammaIn(kDSpEveryContext, NULL); if (status != noErr) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to fade the display"); } -#endif // DrawSprocket setup +#endif // DrawSprocket setup // create a window { Point origin= {0,0}; @@ -585,35 +585,35 @@ ONrPlatform_Initialize( const RGBColor black_color= {0,0,0}; unsigned long value= 0; OSErr err= noErr; - + #ifdef USE_MAC_MENU Handle menu_bar= NULL; - + menu_bar= GetNewMBar(MAC_MBAR_RSRC_ID); // the memory for this is LEAKED. if(menu_bar) { SetMenuBar(menu_bar); } #endif - + #ifdef USE_DRAW_SPROCKET if (ONgDSp_Context) { DSpContext_LocalToGlobal(ONgDSp_Context, &origin); } #endif - + win_rect.left= origin.h; win_rect.top= origin.v; win_rect.right= win_rect.left + width; win_rect.bottom= win_rect.top + height; - + window = NewCWindow(NULL, &win_rect, "\p", 0, plainDBox, (WindowPtr)-1, 0, 0); if (window == NULL) { UUmError_ReturnOnErrorMsg(UUcError_Generic, "Unable to create a window"); } - + // set the context color of the window to black to avoid the white flash when the // window appears SetWindowContentColor(window, &black_color); @@ -629,7 +629,7 @@ ONrPlatform_Initialize( { short h= 0; short v= GetMBarHeight(); - + MoveWindow(window, h, v, true); } ShowWindow(window); @@ -643,7 +643,7 @@ ONrPlatform_Initialize( outPlatformData->gameWindow= window; oni_mac_window= window; } - + return UUcError_None; } @@ -661,7 +661,7 @@ void ONrPlatform_Terminate( // fade to black DSpContext_FadeGammaOut(kDSpEveryContext, NULL); } -#endif +#endif // dispose of the window if (ONgPlatformData.gameWindow) { @@ -671,7 +671,7 @@ void ONrPlatform_Terminate( // fade back to normal if (ONgDSp_Context) { - DSpContext_SetState(ONgDSp_Context, kDSpContextState_Inactive); + DSpContext_SetState(ONgDSp_Context, kDSpContextState_Inactive); DSpContext_FadeGammaIn(kDSpEveryContext, NULL); DSpContext_Release(ONgDSp_Context); ONgDSp_Context = NULL; @@ -691,7 +691,7 @@ ONrPlatform_CopyAkiraToScreen( UUtUns16 inBufferHeight, UUtUns16 inRowBytes, UUtUns16* inBaseAdddr); - + // ---------------------------------------------------------------------- void ONrPlatform_CopyAkiraToScreen( @@ -701,21 +701,21 @@ ONrPlatform_CopyAkiraToScreen( UUtUns16* inBaseAdddr) { #if 0//defined(DEBUG_AKIRA) && DEBUG_AKIRA - + UUtUns16 x, y; - + double* srcPtr, *dstPtr; - + for(y = 0; y < inBufferHeight; y++) { srcPtr = (double*)((char*)inBaseAdddr + y * inRowBytes); dstPtr = (double*)((char*)gAkiraBaseAddr + y * gAkiraRowBytes); - + for(x = 0; x < inBufferWidth >> 2; x++) { *dstPtr++ = *srcPtr++; } - + } #endif @@ -735,10 +735,10 @@ void ONrPlatform_ErrorHandler( char *message) { unsigned char pascalStr[256]; - + sprintf((char *)pascalStr+1,"%s (%s)", message, debugDescription); pascalStr[0] = strlen((char *)pascalStr+1); - + DebugStr(pascalStr); } @@ -760,7 +760,7 @@ ONrPlatform_GetGammaParams( *outMinGamma = ONcMinGamma; *outMaxGamma = ONcMaxGamma; *outCurrentGamma = 100; - + return UUcError_None; } @@ -772,21 +772,21 @@ ONrPlatform_SetGamma( #ifdef USE_DRAW_SPROCKET DSpContextReference dsp_context; RGBColor black; - + UUmAssert((inNewGamma >= ONcMinGamma) && (inNewGamma <= ONcMaxGamma)); // set the color black.red = 0; black.green = 0; black.blue = 0; - + // get the Draw Sprocket context dsp_context = (DSpContextReference)GetWRefCon(ONgPlatformData.gameWindow); if (dsp_context == NULL) return UUcError_Generic; - + // set the gamma of the context DSpContext_FadeGamma(dsp_context, inNewGamma, &black); #endif - + return UUcError_None; } diff --git a/OniProj/OniGameSource/Platform_MacOS/Oni_Platform_Mac.h b/OniProj/OniGameSource/Platform_MacOS/Oni_Platform_Mac.h index 12f71e4..587ebe5 100644 --- a/OniProj/OniGameSource/Platform_MacOS/Oni_Platform_Mac.h +++ b/OniProj/OniGameSource/Platform_MacOS/Oni_Platform_Mac.h @@ -1,12 +1,12 @@ /* FILE: Oni_Platform_Mac.h - + AUTHOR: Brent H. Pease - + CREATED: May 26, 1997 - + PURPOSE: MacOS specific code - + Copyright 1997 */ @@ -28,16 +28,16 @@ enum { _mac_always_search_any_opengl_pref_flag= 0x01, _mac_saved_display_index_pref_mask= 0xF0000000, _mac_saved_display_index_pref_shift= 28, - + CURS_RES_ID= 128, MAC_PREF_RSRC_ID= 128, - + KEY_CONFIG_FILENAME_STR_RSRC= 1000, COMMAND_LINE_ARGS_STR_RSRC= 1002, OPTIONS_DLOG_RSRC= 135, OPTIONS_DLOG_RSRC_OSX= 136, NUMBER_OF_CUSTOMIZE_KEYS= 14, - + _save_button= 1, _cancel_button, _rh_defaults_button, @@ -72,15 +72,15 @@ enum { _hypo_label, _reload_label, _quit_button= 35, - + _ok_button_osx= 1, _quit_button_osx, _args_edit_text_osx, - + MAC_MBAR_RSRC_ID= 128, - + MAC_DISPLAY_SELECT_RSRC_ID= 137, - + _button_ok= 1, _button_cancel= 2, _list_item= 3, diff --git a/OniProj/OniGameSource/Platform_SDL/Oni_Platform_SDL.c b/OniProj/OniGameSource/Platform_SDL/Oni_Platform_SDL.c index 4e1082b..c3e3931 100644 --- a/OniProj/OniGameSource/Platform_SDL/Oni_Platform_SDL.c +++ b/OniProj/OniGameSource/Platform_SDL/Oni_Platform_SDL.c @@ -1,6 +1,6 @@ /* FILE: Oni_Platform_SDL.c - + PURPOSE: SDL specific code */ @@ -65,11 +65,11 @@ UUtError ONrPlatform_Initialize( ONtPlatformData *outPlatformData) { SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER); - + ONiPlatform_CreateWindow(outPlatformData); SDL_ShowCursor(SDL_FALSE); - + return UUcError_None; } @@ -90,7 +90,7 @@ void ONrPlatform_Terminate( { fclose(ONgErrorFile); } - + SDL_Quit(); } @@ -117,7 +117,7 @@ void ONrPlatform_ErrorHandler( /* XXX - Someday bitch really loudly */ } } - + fprintf(ONgErrorFile, "InternalError: %s, %s\n\r", debugDescription, message); } @@ -127,7 +127,7 @@ ONrPlatform_CopyAkiraToScreen( UUtUns16 inBufferHeight, UUtUns16 inRowBytes, UUtUns16* inBaseAdddr); - + void ONrPlatform_CopyAkiraToScreen( UUtUns16 inBufferWidth, diff --git a/OniProj/OniGameSource/Platform_SDL/Oni_Platform_SDL.h b/OniProj/OniGameSource/Platform_SDL/Oni_Platform_SDL.h index fc71fc8..6b634e3 100644 --- a/OniProj/OniGameSource/Platform_SDL/Oni_Platform_SDL.h +++ b/OniProj/OniGameSource/Platform_SDL/Oni_Platform_SDL.h @@ -2,7 +2,7 @@ /* FILE: Oni_Platform_SDL.h - + PURPOSE: SDL specific code */ diff --git a/OniProj/OniGameSource/Platform_Win32/Oni_Platform_Win32.c b/OniProj/OniGameSource/Platform_Win32/Oni_Platform_Win32.c index 0962723..4dc9a9a 100644 --- a/OniProj/OniGameSource/Platform_Win32/Oni_Platform_Win32.c +++ b/OniProj/OniGameSource/Platform_Win32/Oni_Platform_Win32.c @@ -1,12 +1,12 @@ /* FILE: Oni_Platform_Win32.c - + AUTHOR: Brent H. Pease, Michael Evans, Kevin Armstrong - + CREATED: May 26, 1997 - + PURPOSE: Win32 specific code - + Copyright 1997, 2000 */ @@ -75,7 +75,7 @@ ONiHandleMouseEvent( { LItInputEventType event_type; IMtPoint2D mouse_pos; - + switch (iMsg) { case WM_MOUSEMOVE: event_type = LIcInputEvent_MouseMove; break; @@ -89,11 +89,11 @@ ONiHandleMouseEvent( case WM_MBUTTONDBLCLK: event_type = LIcInputEvent_MMouseDown; break; case WM_MBUTTONUP: event_type = LIcInputEvent_MMouseUp; break; } - + mouse_pos.x = LOWORD(lParam); mouse_pos.y = HIWORD(lParam); LIrInputEvent_Add(event_type, &mouse_pos, 0, wParam); -} +} // ---------------------------------------------------------------------- static LRESULT CALLBACK ONiPlatform_WindowProc( @@ -106,7 +106,7 @@ static LRESULT CALLBACK ONiPlatform_WindowProc( static UUtUns32 modifiers = 0; static UUtUns32 previous_key = 0; static UUtBool add_char; - + switch(iMsg) { case WM_CHAR: @@ -122,20 +122,20 @@ static LRESULT CALLBACK ONiPlatform_WindowProc( } } break; - + case WM_KEYDOWN: add_char = UUcFalse; - + switch(wParam) { case VK_SHIFT: modifiers |= MK_SHIFT; break; - + case VK_CONTROL: modifiers |= MK_CONTROL; break; - + case VK_TAB: case VK_UP: case VK_DOWN: @@ -165,27 +165,27 @@ static LRESULT CALLBACK ONiPlatform_WindowProc( LIrPlatform_Win32_TranslateVirtualKey(wParam), modifiers); break; - + default: add_char = UUcTrue; previous_key = LIrPlatform_Win32_TranslateVirtualKey(wParam); break; } break; - + case WM_KEYUP: switch(wParam) { case VK_SHIFT: modifiers &= ~MK_SHIFT; break; - + case VK_CONTROL: modifiers &= ~MK_CONTROL; break; } break; - + case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: @@ -198,11 +198,11 @@ static LRESULT CALLBACK ONiPlatform_WindowProc( case WM_MBUTTONUP: ONiHandleMouseEvent(iMsg, wParam, lParam); return 0; - + case WM_ACTIVATE: { if (LOWORD(wParam) == WA_INACTIVE) - { + { // set the current mode to normal input LIrGameIsActive(UUcFalse); } @@ -214,12 +214,12 @@ static LRESULT CALLBACK ONiPlatform_WindowProc( } } return 0; - + case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; - + hdc = BeginPaint(hWind, &ps); PatBlt(hdc, 0, 0, 4096, 4096, BLACKNESS); EndPaint(hWind, &ps); @@ -241,8 +241,8 @@ static UUtBool fullscreenCandidate(HWND hwnd) { // Quake II sets (WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS) // Heretic II sets (WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU) // TrueSpace4 sets (WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_BORDER | WS_SYSMENU | WS_THICKFRAME) - // This function needs to - // return 0 for TrueSpace4, which wants a window and + // This function needs to + // return 0 for TrueSpace4, which wants a window and // return 1 for Quake II and Heretic II, which want fullscreen if ( (style & WS_POPUP) && !(style & (WS_BORDER | WS_THICKFRAME))) @@ -273,7 +273,7 @@ ONiPlatform_CreateWindow( AUrMessageBox(AUcMBType_OK, "There is already an instance of the game running."); exit(0); } - + windClass.cbSize = sizeof(windClass); windClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; windClass.lpfnWndProc = ONiPlatform_WindowProc; @@ -316,7 +316,7 @@ ONiPlatform_CreateWindow( UUmAssert(fullscreenCandidate(ioPlatformData->gameWindow)); // UpdateWindow(ioPlatformData->gameWindow); - + #if 0 //defined(DEBUG_AKIRA) && DEBUG_AKIRA ioPlatformData->akiraWindow = @@ -333,9 +333,9 @@ ONiPlatform_CreateWindow( NULL, ioPlatformData->appInstance, NULL); - + ShowWindow(ioPlatformData->akiraWindow, 1); - + #endif } @@ -351,13 +351,13 @@ UUtError ONrPlatform_Initialize( ONtPlatformData *outPlatformData) { HRESULT ddReturn = DD_OK; - + outPlatformData->appInstance = ONgAppHInstance; - + ONiPlatform_CreateWindow(outPlatformData); ShowCursor(FALSE); // FALSE = hide the cursor - + return UUcError_None; } @@ -402,7 +402,7 @@ void ONrPlatform_ErrorHandler( /* XXX - Someday bitch really loudly */ } } - + fprintf(ONgErrorFile, "InternalError: %s, %s\n\r", debugDescription, message); } @@ -412,7 +412,7 @@ ONrPlatform_CopyAkiraToScreen( UUtUns16 inBufferHeight, UUtUns16 inRowBytes, UUtUns16* inBaseAdddr); - + void ONrPlatform_CopyAkiraToScreen( UUtUns16 inBufferWidth, diff --git a/OniProj/OniGameSource/Platform_Win32/Oni_Platform_Win32.h b/OniProj/OniGameSource/Platform_Win32/Oni_Platform_Win32.h index e993d78..469dc29 100644 --- a/OniProj/OniGameSource/Platform_Win32/Oni_Platform_Win32.h +++ b/OniProj/OniGameSource/Platform_Win32/Oni_Platform_Win32.h @@ -2,13 +2,13 @@ /* FILE: Oni_Platform_Win32.h - + AUTHOR: Brent H. Pease - + CREATED: May 26, 1997 - + PURPOSE: Win32 specific code - + Copyright 1997 */ diff --git a/OniProj/OniMWProjects/OniProj/OniPrefix/ImporterPrefix_MacOSOpt.h b/OniProj/OniMWProjects/OniProj/OniPrefix/ImporterPrefix_MacOSOpt.h index 92ca311..3423e4e 100644 --- a/OniProj/OniMWProjects/OniProj/OniPrefix/ImporterPrefix_MacOSOpt.h +++ b/OniProj/OniMWProjects/OniProj/OniPrefix/ImporterPrefix_MacOSOpt.h @@ -9,7 +9,7 @@ #define DEBUGGING 0 #define UUmDebugDelete 0 - + #define PROFILE 0 #define UUmDebuggerSymFileName "MacOSOpt_Imp.xSYM" diff --git a/OniProj/OniMWProjects/OniProj/OniPrefix/ImporterPrefix_Win32.h b/OniProj/OniMWProjects/OniProj/OniPrefix/ImporterPrefix_Win32.h index 2a3dd5e..5d85ae1 100644 --- a/OniProj/OniMWProjects/OniProj/OniPrefix/ImporterPrefix_Win32.h +++ b/OniProj/OniMWProjects/OniProj/OniPrefix/ImporterPrefix_Win32.h @@ -7,12 +7,12 @@ #if !defined(UUmPlatform) && !defined(UUmPlatform_Win32) #define UUmPlatform_Win32 1 #define UUmPlatform UUmPlatform_Win32 - + #include "gl_code_version.h" - + #undef UUmPlatform #undef UUmPlatform_Win32 - + #else #include "gl_code_version.h" diff --git a/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_MacOSDbg.h b/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_MacOSDbg.h index 1af2f8a..d6a9efa 100644 --- a/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_MacOSDbg.h +++ b/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_MacOSDbg.h @@ -10,29 +10,29 @@ #define DEBUGGING 1 #define MSmPixelTouch 0 - + #define DEBUGGING_STOPONERROR 1 - + #define UUmDebuggerSymFileName "OniDbg.xSYM" - + #define UUmPasswordProtect 0 - + #if !defined(UUmPlatform) && !defined(UUmPlatform_Mac) #define UUmPlatform_Mac 2 #define UUmPlatform UUmPlatform_Mac - + #include "gl_code_version.h" - + #undef UUmPlatform #undef UUmPlatform_Mac - + #else #include "gl_code_version.h" #endif #define SHIPPING_VERSION 0 - + #if SHIPPING_VERSION #define STAND_ALONE_ONLY 1 #else diff --git a/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_MacOSOpt.h b/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_MacOSOpt.h index f4e2b19..0e6a9f0 100644 --- a/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_MacOSOpt.h +++ b/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_MacOSOpt.h @@ -15,16 +15,16 @@ #define UUmDebuggerSymFileName "Oni.xSYM" #define UUmPasswordProtect 0 - + #if !defined(UUmPlatform) && !defined(UUmPlatform_Mac) #define UUmPlatform_Mac 2 #define UUmPlatform UUmPlatform_Mac - + #include "gl_code_version.h" - + #undef UUmPlatform #undef UUmPlatform_Mac - + #else #include "gl_code_version.h" @@ -44,4 +44,4 @@ #define TOOL_VERSION 1 #endif - \ No newline at end of file + diff --git a/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_MacOSProfile.h b/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_MacOSProfile.h index db781c7..8abfa9b 100644 --- a/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_MacOSProfile.h +++ b/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_MacOSProfile.h @@ -12,18 +12,18 @@ #define PROFILE 1 #define BRENTS_PROFILE - + #define UUmDebuggerSymFileName "OniProf.xSYM" - + #if !defined(UUmPlatform) && !defined(UUmPlatform_Mac) #define UUmPlatform_Mac 2 #define UUmPlatform UUmPlatform_Mac - + #include "gl_code_version.h" - + #undef UUmPlatform #undef UUmPlatform_Mac - + #else #include "gl_code_version.h" diff --git a/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_Win32Dbg.h b/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_Win32Dbg.h index 777110b..6c983aa 100644 --- a/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_Win32Dbg.h +++ b/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_Win32Dbg.h @@ -9,12 +9,12 @@ #if !defined(UUmPlatform) && !defined(UUmPlatform_Win32) #define UUmPlatform_Win32 1 #define UUmPlatform UUmPlatform_Win32 - + #include "gl_code_version.h" - + #undef UUmPlatform #undef UUmPlatform_Win32 - + #else #include "gl_code_version.h" @@ -26,7 +26,7 @@ #define USE_PROFILE_MEMDEBUG 0 #define UUmDebugDelete 0 - + // #define _WIN32 @@ -37,7 +37,7 @@ #define DIRECT3D_VERSION 0x0500 #define SHIPPING_VERSION 0 - + #if SHIPPING_VERSION #define STAND_ALONE_ONLY 1 #else diff --git a/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_Win32Opt.h b/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_Win32Opt.h index efebd4e..8dcb22b 100644 --- a/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_Win32Opt.h +++ b/OniProj/OniMWProjects/OniProj/OniPrefix/OniPrefix_Win32Opt.h @@ -9,12 +9,12 @@ #if !defined(UUmPlatform) && !defined(UUmPlatform_Win32) #define UUmPlatform_Win32 1 #define UUmPlatform UUmPlatform_Win32 - + #include "gl_code_version.h" - + #undef UUmPlatform #undef UUmPlatform_Win32 - + #else #include "gl_code_version.h" @@ -26,7 +26,7 @@ #define USE_PROFILE_MEMDEBUG 0 #define UUmDebugDelete 0 - + #define _WIN32 @@ -36,4 +36,4 @@ #define DIRECTDRAW_VERSION 0x0500 #define DIRECT3D_VERSION 0x0500 - #define SHIPPING_VERSION 0 \ No newline at end of file + #define SHIPPING_VERSION 0 diff --git a/OniProj/OniMWProjects/Oni_Film.h b/OniProj/OniMWProjects/Oni_Film.h index d27086f..7b15db3 100644 --- a/OniProj/OniMWProjects/Oni_Film.h +++ b/OniProj/OniMWProjects/Oni_Film.h @@ -2,9 +2,9 @@ /* Oni_Film.h - + Film recording stuff - + Author: Michael Evans, Quinn Dunki c1998 Bungie */ @@ -47,7 +47,7 @@ typedef tm_template('F', 'I', 'L', 'M', "Film") ONtFilm { // implied 8 bytes here - + M3tPoint3D initialLocation; float initialFacing; float initialDesiredFacing; @@ -56,7 +56,7 @@ ONtFilm UUtUns32 length; TRtAnimation *special_anim[2]; - + tm_pad pad[12]; tm_varindex UUtUns32 numKeys; @@ -66,7 +66,7 @@ ONtFilm typedef struct ONtFilm_DiskFormat { // implied 8 bytes here - + M3tPoint3D initialLocation; float initialFacing; float initialDesiredFacing; @@ -98,8 +98,8 @@ typedef struct ONtFilmState ONtFilm *film; } ONtFilmState; -UUtError ONrFilm_Initialize(void); -void ONrFilm_Terminate(void); +UUtError ONrFilm_Initialize(void); +void ONrFilm_Terminate(void); void ONrFilm_GetFrame(const ONtFilmState *inFilm, ONtInputState *outInputState); void ONrFilm_Create(ONtFilmState *ioFilm); diff --git a/OniProj/OniResources/resource.h b/OniProj/OniResources/resource.h index 7ccc394..e6e0daf 100644 --- a/OniProj/OniResources/resource.h +++ b/OniProj/OniResources/resource.h @@ -8,7 +8,7 @@ #define ID_EDIT1 1003 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 diff --git a/OniProj/OniWin32Projs/ImpConsole/templatechecksum.c b/OniProj/OniWin32Projs/ImpConsole/templatechecksum.c index de1d90f..ce2c1a3 100644 --- a/OniProj/OniWin32Projs/ImpConsole/templatechecksum.c +++ b/OniProj/OniWin32Projs/ImpConsole/templatechecksum.c @@ -1,2409 +1,2409 @@ -#include "BFW.h" -#include "BFW_TemplateManager.h" -#include "BFW_TM_Private.h" -UUtUns64 TMgTemplateChecksum = 1052091493724257; -UUtUns32 TMgNumTemplateDefinitions = 114; -TMtTemplateDefinition* TMgTemplateDefinitionArray = NULL; -static UUtUns8 gSwapCodes_AISA[74] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x05, 0x20, 0x04, 0x06, 0x03, 0x03, 0x03, 0x03, - 0x09, 0x43, 0x43, 0x4e, 0x4f, 0x05, 0x20, 0x04, - 0x06, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x04, 0x06, 0x09, 0x43, 0x57, 0x4e, 0x4f, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x05, 0x02, 0x04, 0x06, - 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AITR[22] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, - 0x05, 0x40, 0x04, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AIWA[21] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x05, - 0x02, 0x04, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AKAA[13] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ABNA[14] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AKVA[40] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AKBA[17] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, - 0x06 -}; -static UUtUns8 gSwapCodes_AKBP[13] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AKDA[23] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AKEV[101] = -{ - 0x02, 0x02, 0x09, 0x41, 0x54, 0x4e, 0x50, 0x09, - 0x41, 0x45, 0x4c, 0x50, 0x09, 0x41, 0x43, 0x58, - 0x54, 0x09, 0x47, 0x51, 0x47, 0x41, 0x09, 0x52, - 0x51, 0x47, 0x41, 0x09, 0x43, 0x51, 0x47, 0x41, - 0x09, 0x42, 0x44, 0x47, 0x41, 0x09, 0x41, 0x4d, - 0x58, 0x54, 0x09, 0x41, 0x56, 0x4b, 0x41, 0x09, - 0x41, 0x42, 0x4b, 0x41, 0x09, 0x41, 0x58, 0x44, - 0x49, 0x09, 0x41, 0x58, 0x44, 0x49, 0x09, 0x50, - 0x42, 0x4b, 0x41, 0x09, 0x41, 0x4e, 0x42, 0x41, - 0x09, 0x54, 0x4f, 0x4b, 0x41, 0x09, 0x41, 0x41, - 0x4b, 0x41, 0x09, 0x41, 0x44, 0x4b, 0x41, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_AGQC[17] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, - 0x06 -}; -static UUtUns8 gSwapCodes_AGDB[12] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AGQG[24] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x04, 0x02, 0x06, 0x05, 0x04, 0x02, 0x06, - 0x05, 0x04, 0x02, 0x06, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AGQM[7] = -{ - 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x06 -}; -static UUtUns8 gSwapCodes_AGQR[12] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x03, 0x03, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_AKOT[28] = -{ - 0x02, 0x02, 0x09, 0x54, 0x49, 0x54, 0x4f, 0x09, - 0x46, 0x4c, 0x54, 0x4f, 0x09, 0x41, 0x4e, 0x54, - 0x51, 0x09, 0x41, 0x58, 0x44, 0x49, 0x09, 0x41, - 0x58, 0x44, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_OTIT[14] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x08, 0x02, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_OTLF[17] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x05, 0x06, 0x02, 0x06, 0x02, 0x02, 0x08, - 0x06 -}; -static UUtUns8 gSwapCodes_QTNA[14] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x04, 0x02, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_BINA[5] = -{ - 0x02, 0x02, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_ENVP[35] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x05, 0x40, 0x04, 0x06, 0x05, 0x30, 0x04, 0x06, - 0x05, 0x0c, 0x02, 0x06, 0x02, 0x02, 0x03, 0x03, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_FXLR[14] = -{ - 0x02, 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, - 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x06 -}; -static UUtUns8 gSwapCodes_3CLA[13] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_EDIA[16] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x02, 0x03, 0x06, 0x03, 0x03, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_M3GM[44] = -{ - 0x02, 0x02, 0x02, 0x09, 0x41, 0x54, 0x4e, 0x50, - 0x09, 0x41, 0x52, 0x43, 0x56, 0x09, 0x41, 0x52, - 0x43, 0x56, 0x09, 0x41, 0x43, 0x58, 0x54, 0x09, - 0x41, 0x58, 0x44, 0x49, 0x09, 0x41, 0x58, 0x44, - 0x49, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x00, - 0x00, 0x00, 0x00, 0x06 -}; -static UUtUns8 gSwapCodes_GMAN[22] = -{ - 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x03, 0x03, - 0x03, 0x05, 0x02, 0x04, 0x06, 0x07, 0x02, 0x09, - 0x4d, 0x47, 0x33, 0x4d, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_M3GA[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_PLEA[14] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_PNTA[23] = -{ - 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x07, 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_QUDA[14] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x04, 0x02, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TXCA[12] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TXMP[30] = -{ - 0x02, 0x02, 0x05, 0x80, 0x04, 0x06, 0x02, 0x03, - 0x03, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x09, - 0x50, 0x4d, 0x58, 0x54, 0x02, 0x02, 0x02, 0x02, - 0x04, 0x05, 0x03, 0x04, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_TXAN[22] = -{ - 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x03, 0x03, - 0x03, 0x05, 0x02, 0x04, 0x06, 0x07, 0x02, 0x09, - 0x50, 0x4d, 0x58, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TXMA[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x09, 0x50, 0x4d, 0x58, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TXMB[20] = -{ - 0x02, 0x02, 0x05, 0x08, 0x04, 0x06, 0x03, 0x03, - 0x02, 0x03, 0x03, 0x07, 0x02, 0x09, 0x50, 0x4d, - 0x58, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TXPC[14] = -{ - 0x02, 0x02, 0x05, 0x08, 0x04, 0x06, 0x02, 0x02, - 0x02, 0x07, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_M3TA[14] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x03, 0x02, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_VCRA[13] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_Impt[15] = -{ - 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x03, 0x04, - 0x06, 0x09, 0x00, 0x00, 0x00, 0x00, 0x06 -}; -static UUtUns8 gSwapCodes_Mtrl[15] = -{ - 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x03, 0x04, - 0x06, 0x09, 0x00, 0x00, 0x00, 0x00, 0x06 -}; -static UUtUns8 gSwapCodes_NMSA[14] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_CONS[33] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x09, 0x41, 0x47, 0x46, 0x4f, 0x09, 0x4d, - 0x47, 0x33, 0x4d, 0x02, 0x05, 0x20, 0x04, 0x06, - 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, - 0x06 -}; -static UUtUns8 gSwapCodes_DOOR[30] = -{ - 0x02, 0x02, 0x05, 0x02, 0x09, 0x41, 0x47, 0x46, - 0x4f, 0x06, 0x09, 0x4e, 0x41, 0x42, 0x4f, 0x02, - 0x02, 0x02, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, - 0x20, 0x04, 0x06, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_OFGA[26] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x09, 0x50, - 0x56, 0x4e, 0x45, 0x07, 0x02, 0x02, 0x09, 0x4d, - 0x47, 0x33, 0x4d, 0x09, 0x53, 0x4c, 0x42, 0x4f, - 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_OBLS[12] = -{ - 0x02, 0x02, 0x02, 0x02, 0x05, 0x03, 0x02, 0x06, - 0x02, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_TRIG[39] = -{ - 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x09, - 0x4d, 0x47, 0x33, 0x4d, 0x09, 0x53, 0x4c, 0x42, - 0x4f, 0x02, 0x09, 0x45, 0x47, 0x52, 0x54, 0x09, - 0x4e, 0x41, 0x42, 0x4f, 0x05, 0x20, 0x04, 0x06, - 0x05, 0x20, 0x04, 0x06, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_TRGE[15] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_TURR[123] = -{ - 0x02, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x04, 0x06, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x05, 0x02, 0x04, 0x06, 0x02, - 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x09, 0x53, 0x4c, - 0x42, 0x4f, 0x02, 0x09, 0x4d, 0x47, 0x33, 0x4d, - 0x02, 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x10, 0x05, - 0x10, 0x04, 0x06, 0x02, 0x03, 0x03, 0x05, 0x0c, - 0x02, 0x06, 0x05, 0x04, 0x04, 0x06, 0x06, 0x02, - 0x05, 0x0c, 0x02, 0x06, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x20, 0x04, - 0x06, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_OBAN[30] = -{ - 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x02, 0x05, - 0x0c, 0x02, 0x06, 0x05, 0x0c, 0x02, 0x06, 0x03, - 0x03, 0x03, 0x07, 0x03, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_OBDC[23] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x03, 0x03, 0x09, 0x4e, 0x41, 0x42, 0x4f, 0x03, - 0x03, 0x02, 0x03, 0x03, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_OBOA[50] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x09, 0x41, 0x47, 0x33, 0x4d, 0x09, 0x4e, 0x41, - 0x42, 0x4f, 0x09, 0x50, 0x56, 0x4e, 0x45, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x05, 0x0c, 0x02, 0x06, - 0x05, 0x40, 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, - 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_CBPI[27] = -{ - 0x02, 0x02, 0x05, 0x13, 0x09, 0x74, 0x70, 0x6d, - 0x49, 0x06, 0x05, 0x13, 0x09, 0x74, 0x70, 0x6d, - 0x49, 0x06, 0x05, 0x13, 0x09, 0x74, 0x70, 0x6d, - 0x49, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_CBPM[11] = -{ - 0x02, 0x02, 0x05, 0x13, 0x09, 0x6c, 0x72, 0x74, - 0x4d, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_ONCC[233] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, - 0x03, 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, - 0x04, 0x04, 0x05, 0x02, 0x04, 0x06, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x03, 0x05, 0x02, 0x04, - 0x06, 0x05, 0x05, 0x02, 0x06, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x04, 0x05, 0x01, 0x04, 0x06, 0x02, 0x05, 0x20, - 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x05, 0x0d, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, - 0x03, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x03, 0x03, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x02, - 0x04, 0x06, 0x05, 0xff, 0x04, 0x06, 0x05, 0x41, - 0x04, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x09, 0x56, 0x43, 0x4e, 0x4f, 0x09, 0x50, 0x43, - 0x4e, 0x4f, 0x09, 0x41, 0x49, 0x4e, 0x4f, 0x04, - 0x04, 0x03, 0x05, 0x10, 0x04, 0x06, 0x05, 0x0f, - 0x05, 0x80, 0x04, 0x06, 0x03, 0x06, 0x05, 0x02, - 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, 0x02, 0x02, - 0x09, 0x53, 0x42, 0x52, 0x54, 0x09, 0x41, 0x4d, - 0x52, 0x54, 0x09, 0x4d, 0x50, 0x42, 0x43, 0x09, - 0x49, 0x50, 0x42, 0x43, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x05, 0x07, 0x02, 0x06, 0x02, - 0x09, 0x43, 0x41, 0x52, 0x54, 0x09, 0x43, 0x53, - 0x52, 0x54, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, - 0x06 -}; -static UUtUns8 gSwapCodes_ONIA[29] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x04, 0x05, - 0x03, 0x04, 0x06, 0x07, 0x02, 0x05, 0x10, 0x04, - 0x06, 0x05, 0x80, 0x04, 0x06, 0x05, 0x10, 0x04, - 0x06, 0x03, 0x03, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONCP[29] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x04, 0x05, - 0x03, 0x04, 0x06, 0x07, 0x02, 0x05, 0x10, 0x04, - 0x06, 0x05, 0x40, 0x04, 0x06, 0x03, 0x05, 0x02, - 0x04, 0x06, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONCV[16] = -{ - 0x02, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x05, - 0x20, 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_CRSA[38] = -{ - 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x02, 0x02, - 0x07, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, - 0x02, 0x06, 0x09, 0x43, 0x43, 0x4e, 0x4f, 0x05, - 0x13, 0x05, 0x0c, 0x02, 0x06, 0x06, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_DPge[19] = -{ - 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x03, 0x04, - 0x06, 0x05, 0x0c, 0x02, 0x06, 0x09, 0x47, 0x50, - 0x47, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_FILM[34] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x05, 0x02, 0x09, 0x4d, 0x41, 0x52, - 0x54, 0x06, 0x05, 0x0c, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x02, 0x01, 0x02, 0x05, 0x04, 0x04, 0x06, - 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONFA[22] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x03, 0x07, - 0x03, 0x05, 0x0c, 0x02, 0x06, 0x02, 0x02, 0x02, - 0x02, 0x03, 0x04, 0x04, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONGS[107] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x05, 0x10, 0x02, 0x06, 0x05, 0x10, 0x02, 0x06, - 0x05, 0xff, 0x04, 0x06, 0x05, 0xff, 0x04, 0x06, - 0x05, 0xff, 0x04, 0x06, 0x05, 0x83, 0x04, 0x06, - 0x05, 0xff, 0x04, 0x06, 0x05, 0xff, 0x04, 0x06, - 0x05, 0xff, 0x04, 0x06, 0x05, 0x83, 0x04, 0x06, - 0x05, 0x0e, 0x02, 0x06, 0x05, 0xff, 0x04, 0x06, - 0x05, 0xff, 0x04, 0x06, 0x05, 0x42, 0x04, 0x06, - 0x05, 0xa0, 0x04, 0x06, 0x05, 0x03, 0x02, 0x06, - 0x05, 0x03, 0x02, 0x06, 0x05, 0x03, 0x02, 0x06, - 0x05, 0x03, 0x02, 0x06, 0x05, 0x03, 0x02, 0x06, - 0x05, 0x03, 0x02, 0x06, 0x02, 0x05, 0x10, 0x05, - 0x20, 0x04, 0x06, 0x03, 0x03, 0x05, 0x20, 0x04, - 0x06, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_HPge[13] = -{ - 0x02, 0x02, 0x05, 0x02, 0x04, 0x06, 0x03, 0x09, - 0x47, 0x50, 0x47, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_IGHH[32] = -{ - 0x02, 0x02, 0x05, 0x1c, 0x04, 0x06, 0x09, 0x50, - 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, - 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x07, 0x02, - 0x05, 0x40, 0x04, 0x06, 0x03, 0x03, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_IGPG[27] = -{ - 0x02, 0x02, 0x09, 0x46, 0x46, 0x53, 0x54, 0x02, - 0x02, 0x03, 0x03, 0x09, 0x00, 0x00, 0x00, 0x00, - 0x09, 0x41, 0x53, 0x47, 0x49, 0x09, 0x41, 0x53, - 0x47, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_IGPA[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x09, 0x47, 0x50, 0x47, 0x49, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_IGSt[20] = -{ - 0x02, 0x02, 0x09, 0x46, 0x46, 0x53, 0x54, 0x02, - 0x02, 0x03, 0x03, 0x05, 0xff, 0x04, 0x06, 0x05, - 0x81, 0x04, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_IGSA[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x09, 0x74, 0x53, 0x47, 0x49, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_IPge[9] = -{ - 0x02, 0x02, 0x02, 0x09, 0x47, 0x50, 0x47, 0x49, - 0x06 -}; -static UUtUns8 gSwapCodes_KeyI[53] = -{ - 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, - 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, - 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, - 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, - 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, - 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, - 0x50, 0x4d, 0x58, 0x54, 0x06 -}; -static UUtUns8 gSwapCodes_ONLV[82] = -{ - 0x02, 0x02, 0x05, 0x40, 0x04, 0x06, 0x09, 0x56, - 0x45, 0x4b, 0x41, 0x09, 0x41, 0x4f, 0x42, 0x4f, - 0x09, 0x41, 0x4d, 0x4e, 0x4f, 0x09, 0x41, 0x46, - 0x4e, 0x4f, 0x09, 0x41, 0x54, 0x4e, 0x4f, 0x09, - 0x4b, 0x53, 0x4e, 0x4f, 0x02, 0x09, 0x41, 0x53, - 0x49, 0x41, 0x09, 0x52, 0x54, 0x49, 0x41, 0x09, - 0x41, 0x53, 0x4e, 0x4f, 0x09, 0x43, 0x44, 0x42, - 0x4f, 0x09, 0x41, 0x4f, 0x4e, 0x4f, 0x09, 0x50, - 0x56, 0x4e, 0x45, 0x02, 0x05, 0x20, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x06, 0x09, 0x41, 0x53, 0x52, - 0x43, 0x06 -}; -static UUtUns8 gSwapCodes_ONLD[9] = -{ - 0x02, 0x02, 0x03, 0x03, 0x05, 0x40, 0x04, 0x06, - 0x06 -}; -static UUtUns8 gSwapCodes_ONMA[20] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x05, 0x40, 0x04, 0x06, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONOA[16] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x09, 0x41, 0x58, 0x44, 0x49, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_OPge[13] = -{ - 0x02, 0x02, 0x05, 0x02, 0x04, 0x06, 0x03, 0x09, - 0x41, 0x50, 0x47, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_ONSK[55] = -{ - 0x02, 0x02, 0x05, 0x06, 0x09, 0x50, 0x4d, 0x58, - 0x54, 0x06, 0x05, 0x08, 0x09, 0x50, 0x4d, 0x58, - 0x54, 0x06, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x05, - 0x05, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x06, 0x02, - 0x02, 0x05, 0x08, 0x02, 0x06, 0x05, 0x08, 0x02, - 0x06, 0x05, 0x08, 0x02, 0x06, 0x05, 0x08, 0x02, - 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_ONSA[11] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x03, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TxtC[8] = -{ - 0x02, 0x02, 0x09, 0x41, 0x50, 0x47, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_ONTA[52] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x02, 0x07, - 0x02, 0x05, 0x08, 0x02, 0x02, 0x02, 0x06, 0x05, - 0x06, 0x05, 0x04, 0x02, 0x06, 0x06, 0x05, 0x06, - 0x02, 0x02, 0x02, 0x06, 0x05, 0x06, 0x02, 0x02, - 0x02, 0x02, 0x06, 0x05, 0x06, 0x03, 0x06, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONVL[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x09, 0x56, 0x43, 0x4e, 0x4f, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_WPge[13] = -{ - 0x02, 0x02, 0x09, 0x43, 0x57, 0x4e, 0x4f, 0x09, - 0x47, 0x50, 0x47, 0x49, 0x06 -}; -static UUtUns8 gSwapCodes_OSBD[5] = -{ - 0x02, 0x02, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_PSpc[18] = -{ - 0x02, 0x02, 0x05, 0x09, 0x03, 0x03, 0x06, 0x05, - 0x09, 0x03, 0x03, 0x06, 0x09, 0x00, 0x00, 0x00, - 0x00, 0x06 -}; -static UUtUns8 gSwapCodes_PSpL[16] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_PSUI[223] = -{ - 0x02, 0x02, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, - 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, - 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, - 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, - 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, - 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, - 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, - 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, - 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, - 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, - 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, - 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, - 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, - 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, - 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, - 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, - 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, - 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, - 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, - 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, - 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, - 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, - 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, - 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, - 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, - 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, - 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, - 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x06 -}; -static UUtUns8 gSwapCodes_SNDD[8] = -{ - 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x06 -}; -static UUtUns8 gSwapCodes_SUBT[12] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x02, 0x07, - 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_UUEA[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x05, 0x7e, 0x04, 0x06, 0x03, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TMFA[11] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_IDXA[11] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TStr[7] = -{ - 0x02, 0x02, 0x05, 0x80, 0x04, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_StNA[15] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x09, 0x72, 0x74, 0x53, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TMRA[15] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x09, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRAS[16] = -{ - 0x02, 0x02, 0x09, 0x4d, 0x41, 0x52, 0x54, 0x02, - 0x02, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x06 -}; -static UUtUns8 gSwapCodes_TRAM[94] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x05, 0x02, 0x09, 0x4d, 0x41, 0x52, 0x54, 0x06, - 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, - 0x05, 0x24, 0x02, 0x06, 0x03, 0x04, 0x04, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x04, - 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x03, - 0x03, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x04, 0x06 -}; -static UUtUns8 gSwapCodes_TRAC[24] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x09, 0x43, - 0x41, 0x52, 0x54, 0x03, 0x07, 0x03, 0x03, 0x03, - 0x02, 0x09, 0x4d, 0x41, 0x52, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRCM[31] = -{ - 0x02, 0x02, 0x02, 0x03, 0x05, 0x02, 0x04, 0x06, - 0x05, 0x40, 0x04, 0x06, 0x02, 0x02, 0x02, 0x09, - 0x41, 0x47, 0x52, 0x54, 0x09, 0x41, 0x54, 0x52, - 0x54, 0x09, 0x41, 0x49, 0x52, 0x54, 0x06 -}; -static UUtUns8 gSwapCodes_TRBS[11] = -{ - 0x02, 0x02, 0x05, 0x05, 0x09, 0x4d, 0x43, 0x52, - 0x54, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_TRMA[15] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x09, 0x50, 0x4d, 0x58, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRFT[11] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRGA[15] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRIA[14] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x04, 0x04, 0x04, 0x04, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRSC[15] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x09, 0x53, 0x41, 0x52, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TRTA[13] = -{ - 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, - 0x02, 0x02, 0x02, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TSFT[33] = -{ - 0x02, 0x02, 0x05, 0x06, 0x04, 0x06, 0x03, 0x02, - 0x03, 0x03, 0x03, 0x03, 0x05, 0xff, 0x09, 0x41, - 0x47, 0x53, 0x54, 0x06, 0x05, 0x01, 0x09, 0x41, - 0x47, 0x53, 0x54, 0x06, 0x07, 0x02, 0x02, 0x08, - 0x06 -}; -static UUtUns8 gSwapCodes_TSFF[20] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x09, 0x4c, - 0x46, 0x53, 0x54, 0x07, 0x02, 0x09, 0x54, 0x46, - 0x53, 0x54, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_TSFL[23] = -{ - 0x02, 0x02, 0x05, 0x40, 0x04, 0x06, 0x05, 0x40, - 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, 0x05, 0x40, - 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, 0x06 -}; -static UUtUns8 gSwapCodes_TSGA[25] = -{ - 0x02, 0x02, 0x05, 0xff, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x02, 0x02, 0x06, 0x05, 0x01, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x06, - 0x06 -}; -static UUtUns8 gSwapCodes_UVDL[19] = -{ - 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x02, 0x07, - 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, 0x04, - 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_WMCL[16] = -{ - 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, - 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_WMDD[50] = -{ - 0x02, 0x02, 0x05, 0xff, 0x04, 0x06, 0x05, 0x01, - 0x04, 0x06, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, - 0x03, 0x03, 0x07, 0x02, 0x05, 0xff, 0x04, 0x06, - 0x05, 0x01, 0x04, 0x06, 0x03, 0x03, 0x02, 0x02, - 0x03, 0x03, 0x03, 0x03, 0x09, 0x46, 0x46, 0x53, - 0x54, 0x02, 0x02, 0x05, 0x02, 0x04, 0x06, 0x03, - 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_WMMB[16] = -{ - 0x02, 0x02, 0x05, 0x12, 0x04, 0x06, 0x03, 0x07, - 0x02, 0x09, 0x5f, 0x4d, 0x4d, 0x57, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_WMM_[21] = -{ - 0x02, 0x02, 0x05, 0x12, 0x04, 0x06, 0x03, 0x05, - 0x40, 0x04, 0x06, 0x07, 0x02, 0x03, 0x03, 0x05, - 0x40, 0x04, 0x06, 0x08, 0x06 -}; -static UUtUns8 gSwapCodes_ONWC[175] = -{ - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x02, - 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x02, 0x02, - 0x09, 0x50, 0x4d, 0x58, 0x54, 0x02, 0x02, 0x02, - 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, - 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, - 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x05, 0x20, 0x04, - 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x02, 0x02, 0x05, 0x0c, 0x02, 0x06, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x0c, 0x02, - 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x10, 0x05, - 0x0c, 0x02, 0x06, 0x05, 0x10, 0x04, 0x06, 0x02, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06, 0x05, - 0x20, 0x04, 0x06, 0x02, 0x09, 0x50, 0x4d, 0x58, - 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x05, 0x02, - 0x02, 0x06, 0x02, 0x02, 0x02, 0x02, 0x06 -}; -static TMtTemplateDefinition TMgTemplateDefinitionArray_Mem[114] = -{ - // #0 - { - 180964060137, - 0x41495341, - "AI Character Setup Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x160, - NULL, - 0x4d41474b, - NULL, - }, - // #1 - { - 1763925, - 0x41495452, - "AI script trigger array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x54, - NULL, - 0x4d41474b, - NULL, - }, - // #2 - { - 1081091, - 0x41495741, - "AI Imported Waypoint Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x1c, - NULL, - 0x4d41474b, - NULL, - }, - // #3 - { - 1171063, - 0x414b4141, - "Adjacency Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #4 - { - 1207712, - 0x41424e41, - "bsp tree node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x10, - NULL, - 0x4d41474b, - NULL, - }, - // #5 - { - 14616032, - 0x414b5641, - "BNV Node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x74, - NULL, - 0x4d41474b, - NULL, - }, - // #6 - { - 3811460, - 0x414b4241, - "Side Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x1c, - NULL, - 0x4d41474b, - NULL, - }, - // #7 - { - 848969, - 0x414b4250, - "BSP node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #8 - { - 3036260, - 0x414b4441, - "Door Frame Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x34, - NULL, - 0x4d41474b, - NULL, - }, - // #9 - { - 584922226293, - 0x414b4556, - "Akira Environment", - NULL, - (TMtTemplateFlags)0x4, - 0x80, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #10 - { - 1887121, - 0x41475143, - "Gunk Quad Collision Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x1c, - NULL, - 0x4d41474b, - NULL, - }, - // #11 - { - 470551, - 0x41474442, - "Gunk Quad Debug Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x8, - NULL, - 0x4d41474b, - NULL, - }, - // #12 - { - 1835986, - 0x41475147, - "Gunk Quad General Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x38, - NULL, - 0x4d41474b, - NULL, - }, - // #13 - { - 281254, - 0x4147514d, - "Gunk Quad Material", - NULL, - (TMtTemplateFlags)0x6, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #14 - { - 539195, - 0x41475152, - "Gunk Quad Render Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #15 - { - 76902095368, - 0x414b4f54, - "Oct tree", - NULL, - (TMtTemplateFlags)0x4, - 0x1c, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #16 - { - 676306, - 0x4f544954, - "Oct tree interior node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x20, - NULL, - 0x4d41474b, - NULL, - }, - // #17 - { - 2010123, - 0x4f544c46, - "Oct tree leaf node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x24, - NULL, - 0x4d41474b, - NULL, - }, - // #18 - { - 421580, - 0x51544e41, - "Quad tree node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x10, - NULL, - 0x4d41474b, - NULL, - }, - // #19 - { - 89617, - 0x42494e41, - "Binary Data", - NULL, - (TMtTemplateFlags)0x6, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #20 - { - 6799811, - 0x454e5650, - "Env Particle Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xd0, - NULL, - 0x4d41474b, - NULL, - }, - // #21 - { - 28278257833, - 0x46584c52, - "FX Laser effect", - NULL, - (TMtTemplateFlags)0x4, - 0x14, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #22 - { - 321214, - 0x33434c41, - "RGB Color Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #23 - { - 505591, - 0x45444941, - "Edge Index Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x8, - NULL, - 0x4d41474b, - NULL, - }, - // #24 - { - 170196001846, - 0x4d33474d, - "Geometry", - NULL, - (TMtTemplateFlags)0x4, - 0x2c, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #25 - { - 41447257509, - 0x474d414e, - "Geometry Animation", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #26 - { - 22018728114, - 0x4d334741, - "GeometryArray", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #27 - { - 506936, - 0x504c4541, - "Plane Equation Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x10, - NULL, - 0x4d41474b, - NULL, - }, - // #28 - { - 3630956, - 0x504e5441, - "3D Point Array", - NULL, - (TMtTemplateFlags)0x6, - 0x40, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #29 - { - 220778, - 0x51554441, - "Quad array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x10, - NULL, - 0x4d41474b, - NULL, - }, - // #30 - { - 594970, - 0x54584341, - "Texture Coordinate Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x8, - NULL, - 0x4d41474b, - NULL, - }, - // #31 - { - 36794461023, - 0x54584d50, - "Texture Map", - NULL, - (TMtTemplateFlags)0x4, - 0xb0, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #32 - { - 45282968455, - 0x5458414e, - "Texture Map Animation", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #33 - { - 24056332176, - 0x54584d41, - "Texture map array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #34 - { - 45283174994, - 0x54584d42, - "Texture Map Big", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #35 - { - 763774, - 0x54585043, - "Texture Procedure Data", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #36 - { - 194497, - 0x4d335441, - "Triangle array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #37 - { - 345913, - 0x56435241, - "3D Vector Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #38 - { - 282390, - 0x496d7074, - "Impact", - NULL, - (TMtTemplateFlags)0x4, - 0x14, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #39 - { - 167437, - 0x4d74726c, - "Material", - NULL, - (TMtTemplateFlags)0x4, - 0x14, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #40 - { - 788892, - 0x4e4d5341, - "Network Spawn Point Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x10, - NULL, - 0x4d41474b, - NULL, - }, - // #41 - { - 85270924253, - 0x434f4e53, - "Console", - NULL, - (TMtTemplateFlags)0x4, - 0x90, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #42 - { - 26599423335, - 0x444f4f52, - "Door", - NULL, - (TMtTemplateFlags)0x4, - 0x6c, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #43 - { - 83566969698, - 0x4f464741, - "Object Furn Geom Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #44 - { - 749629, - 0x4f424c53, - "Object LS Data", - NULL, - (TMtTemplateFlags)0x6, - 0x28, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #45 - { - 145438592300, - 0x54524947, - "Trigger", - NULL, - (TMtTemplateFlags)0x4, - 0x74, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #46 - { - 36266490172, - 0x54524745, - "Trigger Emitter", - NULL, - (TMtTemplateFlags)0x4, - 0x28, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #47 - { - 316893824446, - 0x54555252, - "Turret", - NULL, - (TMtTemplateFlags)0x4, - 0x648, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #48 - { - 5114916, - 0x4f42414e, - "Object animation", - NULL, - (TMtTemplateFlags)0x6, - 0x80, - 0x20, - NULL, - 0x4d41474b, - NULL, - }, - // #49 - { - 33246071307, - 0x4f424443, - "Door class array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x18, - NULL, - 0x4d41474b, - NULL, - }, - // #50 - { - 82938791649, - 0x4f424f41, - "Starting Object Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0xf0, - NULL, - 0x4d41474b, - NULL, - }, - // #51 - { - 51740530370, - 0x43425049, - "Character Body Part Impacts", - NULL, - (TMtTemplateFlags)0x4, - 0xec, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #52 - { - 10395858207, - 0x4342504d, - "Character Body Part Material", - NULL, - (TMtTemplateFlags)0x4, - 0x54, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #53 - { - 5109581306351, - 0x4f4e4343, - "Oni Character Class", - NULL, - (TMtTemplateFlags)0x4, - 0xc98, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #54 - { - 2830234, - 0x4f4e4941, - "Oni Character Impact Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xa4, - NULL, - 0x4d41474b, - NULL, - }, - // #55 - { - 3109665, - 0x4f4e4350, - "Oni Character Particle Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x58, - NULL, - 0x4d41474b, - NULL, - }, - // #56 - { - 170485, - 0x4f4e4356, - "Oni Character Variant", - NULL, - (TMtTemplateFlags)0x4, - 0x4c, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #57 - { - 51896374476, - 0x43525341, - "Corpse Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x44c, - NULL, - 0x4d41474b, - NULL, - }, - // #58 - { - 33194403947, - 0x44506765, - "Diary Page", - NULL, - (TMtTemplateFlags)0x4, - 0x44, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #59 - { - 48102073005, - 0x46494c4d, - "Film", - NULL, - (TMtTemplateFlags)0x4, - 0x40, - 0x18, - NULL, - 0x4d41474b, - NULL, - }, - // #60 - { - 1772775, - 0x4f4e4641, - "Imported Flag Node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x44, - NULL, - 0x4d41474b, - NULL, - }, - // #61 - { - 36105142, - 0x4f4e4753, - "Oni Game Settings", - NULL, - (TMtTemplateFlags)0x6, - 0xf44, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #62 - { - 18441269563, - 0x48506765, - "Help Page", - NULL, - (TMtTemplateFlags)0x4, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #63 - { - 38211049694, - 0x49474848, - "IGUI HUD Help", - NULL, - (TMtTemplateFlags)0x4, - 0x40, - 0x44, - NULL, - 0x4d41474b, - NULL, - }, - // #64 - { - 76477335677, - 0x49475047, - "IGUI Page", - NULL, - (TMtTemplateFlags)0x4, - 0x24, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #65 - { - 20900088069, - 0x49475041, - "IGUI Page Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #66 - { - 11318621989, - 0x49475374, - "IGUI String", - NULL, - (TMtTemplateFlags)0x4, - 0x198, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #67 - { - 20900127752, - 0x49475341, - "IGUI String Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #68 - { - 11064797626, - 0x49506765, - "Item Page", - NULL, - (TMtTemplateFlags)0x4, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #69 - { - 275939547053, - 0x4b657949, - "Key Icons", - NULL, - (TMtTemplateFlags)0x4, - 0x30, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #70 - { - 539951247011, - 0x4f4e4c56, - "Oni Game Level", - NULL, - (TMtTemplateFlags)0x4, - 0x304, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #71 - { - 266913, - 0x4f4e4c44, - "Oni Game Level Descriptor", - NULL, - (TMtTemplateFlags)0x6, - 0x4c, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #72 - { - 1197945, - 0x4f4e4d41, - "Imported Marker Node Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x58, - NULL, - 0x4d41474b, - NULL, - }, - // #73 - { - 27043257468, - 0x4f4e4f41, - "Object Gunk Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x8, - NULL, - 0x4d41474b, - NULL, - }, - // #74 - { - 18441354235, - 0x4f506765, - "Objective Page", - NULL, - (TMtTemplateFlags)0x4, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #75 - { - 89156620391, - 0x4f4e534b, - "Oni Sky class", - NULL, - (TMtTemplateFlags)0x4, - 0xf4, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #76 - { - 280116, - 0x4f4e5341, - "Imported Spawn Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x2, - NULL, - 0x4d41474b, - NULL, - }, - // #77 - { - 7376505639, - 0x54787443, - "Text Console", - NULL, - (TMtTemplateFlags)0x4, - 0xc, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #78 - { - 10550464, - 0x4f4e5441, - "Trigger Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x1a0, - NULL, - 0x4d41474b, - NULL, - }, - // #79 - { - 22619145610, - 0x4f4e564c, - "Oni Variant List", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #80 - { - 19047942581, - 0x57506765, - "Weapon Page", - NULL, - (TMtTemplateFlags)0x4, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #81 - { - 89660, - 0x4f534244, - "Oni Sound Binary Data", - NULL, - (TMtTemplateFlags)0x6, - 0x10, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #82 - { - 534088, - 0x50537063, - "Part Specification", - NULL, - (TMtTemplateFlags)0x4, - 0x54, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #83 - { - 838661, - 0x5053704c, - "Part Specification List", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x8, - NULL, - 0x4d41474b, - NULL, - }, - // #84 - { - 4180417615611, - 0x50535549, - "Part Specifications UI", - NULL, - (TMtTemplateFlags)0x4, - 0xb8, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #85 - { - 266731, - 0x534e4444, - "Sound Data", - NULL, - (TMtTemplateFlags)0x6, - 0x18, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #86 - { - 289896, - 0x53554254, - "Subtitle Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #87 - { - 716476, - 0x55554541, - "Error Binding Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x80, - NULL, - 0x4d41474b, - NULL, - }, - // #88 - { - 152356, - 0x544d4641, - "Float Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #89 - { - 159887, - 0x49445841, - "Index Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #90 - { - 25760, - 0x54537472, - "String", - NULL, - (TMtTemplateFlags)0x6, - 0x88, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #91 - { - 24050971936, - 0x53744e41, - "String Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #92 - { - 472353, - 0x544d5241, - "Template Reference Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #93 - { - 8491477296, - 0x54524153, - "Totoro Aiming Screen", - NULL, - (TMtTemplateFlags)0x4, - 0x24, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #94 - { - 70837389592, - 0x5452414d, - "Totoro Animation Sequence", - NULL, - (TMtTemplateFlags)0x4, - 0x188, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #95 - { - 65077377839, - 0x54524143, - "Animation Collection", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #96 - { - 152787879246, - 0x5452434d, - "Totoro Quaternion Body", - NULL, - (TMtTemplateFlags)0x4, - 0x68, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #97 - { - 11317428793, - 0x54524253, - "Totoro Body Set", - NULL, - (TMtTemplateFlags)0x4, - 0x1c, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #98 - { - 24056327511, - 0x54524d41, - "Texture Map Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #99 - { - 139695, - 0x54524654, - "Totoro Facing Table", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #100 - { - 22018728184, - 0x54524741, - "Totoro Quaternion Body Geometry Array", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #101 - { - 705666, - 0x54524941, - "Totoro Quaternion Body Index Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #102 - { - 24049642263, - 0x54525343, - "Screen (aiming) Collection", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #103 - { - 481768, - 0x54525441, - "Totoro Quaternion Body Translation Array", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0xc, - NULL, - 0x4d41474b, - NULL, - }, - // #104 - { - 97619402474, - 0x54534654, - "Font", - NULL, - (TMtTemplateFlags)0x4, - 0x420, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #105 - { - 45272025226, - 0x54534646, - "Font Family", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #106 - { - 581161, - 0x5453464c, - "Font Language", - NULL, - (TMtTemplateFlags)0x6, - 0x148, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #107 - { - 2772632, - 0x54534741, - "Glyph Array", - NULL, - (TMtTemplateFlags)0x6, - 0x1408, - 0x0, - NULL, - 0x4d41474b, - NULL, - }, - // #108 - { - 661221, - 0x5556444c, - "UV Data List", - NULL, - (TMtTemplateFlags)0x6, - 0x20, - 0x40, - NULL, - 0x4d41474b, - NULL, - }, - // #109 - { - 643190, - 0x574d434c, - "WM Cursor List", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x8, - NULL, - 0x4d41474b, - NULL, - }, - // #110 - { - 120261047236, - 0x574d4444, - "WM Dialog Data", - NULL, - (TMtTemplateFlags)0x0, - 0x120, - 0x124, - NULL, - 0x4d41474b, - NULL, - }, - // #111 - { - 29293831991, - 0x574d4d42, - "WM Menu Bar", - NULL, - (TMtTemplateFlags)0x0, - 0x20, - 0x4, - NULL, - 0x4d41474b, - NULL, - }, - // #112 - { - 793144, - 0x574d4d5f, - "WM Menu", - NULL, - (TMtTemplateFlags)0x6, - 0x60, - 0x44, - NULL, - 0x4d41474b, - NULL, - }, - // #113 - { - 1733621247669, - 0x4f4e5743, - "Oni Weapon Class", - NULL, - (TMtTemplateFlags)0x4, - 0x71c, - 0x0, - NULL, - 0x4d41474b, - NULL, - } -}; -void -TMrTemplate_BuildList( - void) -{ - TMgTemplateDefinitionArray_Mem[0].swapCodes = gSwapCodes_AISA; - TMgTemplateDefinitionArray_Mem[1].swapCodes = gSwapCodes_AITR; - TMgTemplateDefinitionArray_Mem[2].swapCodes = gSwapCodes_AIWA; - TMgTemplateDefinitionArray_Mem[3].swapCodes = gSwapCodes_AKAA; - TMgTemplateDefinitionArray_Mem[4].swapCodes = gSwapCodes_ABNA; - TMgTemplateDefinitionArray_Mem[5].swapCodes = gSwapCodes_AKVA; - TMgTemplateDefinitionArray_Mem[6].swapCodes = gSwapCodes_AKBA; - TMgTemplateDefinitionArray_Mem[7].swapCodes = gSwapCodes_AKBP; - TMgTemplateDefinitionArray_Mem[8].swapCodes = gSwapCodes_AKDA; - TMgTemplateDefinitionArray_Mem[9].swapCodes = gSwapCodes_AKEV; - TMgTemplateDefinitionArray_Mem[10].swapCodes = gSwapCodes_AGQC; - TMgTemplateDefinitionArray_Mem[11].swapCodes = gSwapCodes_AGDB; - TMgTemplateDefinitionArray_Mem[12].swapCodes = gSwapCodes_AGQG; - TMgTemplateDefinitionArray_Mem[13].swapCodes = gSwapCodes_AGQM; - TMgTemplateDefinitionArray_Mem[14].swapCodes = gSwapCodes_AGQR; - TMgTemplateDefinitionArray_Mem[15].swapCodes = gSwapCodes_AKOT; - TMgTemplateDefinitionArray_Mem[16].swapCodes = gSwapCodes_OTIT; - TMgTemplateDefinitionArray_Mem[17].swapCodes = gSwapCodes_OTLF; - TMgTemplateDefinitionArray_Mem[18].swapCodes = gSwapCodes_QTNA; - TMgTemplateDefinitionArray_Mem[19].swapCodes = gSwapCodes_BINA; - TMgTemplateDefinitionArray_Mem[20].swapCodes = gSwapCodes_ENVP; - TMgTemplateDefinitionArray_Mem[21].swapCodes = gSwapCodes_FXLR; - TMgTemplateDefinitionArray_Mem[22].swapCodes = gSwapCodes_3CLA; - TMgTemplateDefinitionArray_Mem[23].swapCodes = gSwapCodes_EDIA; - TMgTemplateDefinitionArray_Mem[24].swapCodes = gSwapCodes_M3GM; - TMgTemplateDefinitionArray_Mem[25].swapCodes = gSwapCodes_GMAN; - TMgTemplateDefinitionArray_Mem[26].swapCodes = gSwapCodes_M3GA; - TMgTemplateDefinitionArray_Mem[27].swapCodes = gSwapCodes_PLEA; - TMgTemplateDefinitionArray_Mem[28].swapCodes = gSwapCodes_PNTA; - TMgTemplateDefinitionArray_Mem[29].swapCodes = gSwapCodes_QUDA; - TMgTemplateDefinitionArray_Mem[30].swapCodes = gSwapCodes_TXCA; - TMgTemplateDefinitionArray_Mem[31].swapCodes = gSwapCodes_TXMP; - TMgTemplateDefinitionArray_Mem[32].swapCodes = gSwapCodes_TXAN; - TMgTemplateDefinitionArray_Mem[33].swapCodes = gSwapCodes_TXMA; - TMgTemplateDefinitionArray_Mem[34].swapCodes = gSwapCodes_TXMB; - TMgTemplateDefinitionArray_Mem[35].swapCodes = gSwapCodes_TXPC; - TMgTemplateDefinitionArray_Mem[36].swapCodes = gSwapCodes_M3TA; - TMgTemplateDefinitionArray_Mem[37].swapCodes = gSwapCodes_VCRA; - TMgTemplateDefinitionArray_Mem[38].swapCodes = gSwapCodes_Impt; - TMgTemplateDefinitionArray_Mem[39].swapCodes = gSwapCodes_Mtrl; - TMgTemplateDefinitionArray_Mem[40].swapCodes = gSwapCodes_NMSA; - TMgTemplateDefinitionArray_Mem[41].swapCodes = gSwapCodes_CONS; - TMgTemplateDefinitionArray_Mem[42].swapCodes = gSwapCodes_DOOR; - TMgTemplateDefinitionArray_Mem[43].swapCodes = gSwapCodes_OFGA; - TMgTemplateDefinitionArray_Mem[44].swapCodes = gSwapCodes_OBLS; - TMgTemplateDefinitionArray_Mem[45].swapCodes = gSwapCodes_TRIG; - TMgTemplateDefinitionArray_Mem[46].swapCodes = gSwapCodes_TRGE; - TMgTemplateDefinitionArray_Mem[47].swapCodes = gSwapCodes_TURR; - TMgTemplateDefinitionArray_Mem[48].swapCodes = gSwapCodes_OBAN; - TMgTemplateDefinitionArray_Mem[49].swapCodes = gSwapCodes_OBDC; - TMgTemplateDefinitionArray_Mem[50].swapCodes = gSwapCodes_OBOA; - TMgTemplateDefinitionArray_Mem[51].swapCodes = gSwapCodes_CBPI; - TMgTemplateDefinitionArray_Mem[52].swapCodes = gSwapCodes_CBPM; - TMgTemplateDefinitionArray_Mem[53].swapCodes = gSwapCodes_ONCC; - TMgTemplateDefinitionArray_Mem[54].swapCodes = gSwapCodes_ONIA; - TMgTemplateDefinitionArray_Mem[55].swapCodes = gSwapCodes_ONCP; - TMgTemplateDefinitionArray_Mem[56].swapCodes = gSwapCodes_ONCV; - TMgTemplateDefinitionArray_Mem[57].swapCodes = gSwapCodes_CRSA; - TMgTemplateDefinitionArray_Mem[58].swapCodes = gSwapCodes_DPge; - TMgTemplateDefinitionArray_Mem[59].swapCodes = gSwapCodes_FILM; - TMgTemplateDefinitionArray_Mem[60].swapCodes = gSwapCodes_ONFA; - TMgTemplateDefinitionArray_Mem[61].swapCodes = gSwapCodes_ONGS; - TMgTemplateDefinitionArray_Mem[62].swapCodes = gSwapCodes_HPge; - TMgTemplateDefinitionArray_Mem[63].swapCodes = gSwapCodes_IGHH; - TMgTemplateDefinitionArray_Mem[64].swapCodes = gSwapCodes_IGPG; - TMgTemplateDefinitionArray_Mem[65].swapCodes = gSwapCodes_IGPA; - TMgTemplateDefinitionArray_Mem[66].swapCodes = gSwapCodes_IGSt; - TMgTemplateDefinitionArray_Mem[67].swapCodes = gSwapCodes_IGSA; - TMgTemplateDefinitionArray_Mem[68].swapCodes = gSwapCodes_IPge; - TMgTemplateDefinitionArray_Mem[69].swapCodes = gSwapCodes_KeyI; - TMgTemplateDefinitionArray_Mem[70].swapCodes = gSwapCodes_ONLV; - TMgTemplateDefinitionArray_Mem[71].swapCodes = gSwapCodes_ONLD; - TMgTemplateDefinitionArray_Mem[72].swapCodes = gSwapCodes_ONMA; - TMgTemplateDefinitionArray_Mem[73].swapCodes = gSwapCodes_ONOA; - TMgTemplateDefinitionArray_Mem[74].swapCodes = gSwapCodes_OPge; - TMgTemplateDefinitionArray_Mem[75].swapCodes = gSwapCodes_ONSK; - TMgTemplateDefinitionArray_Mem[76].swapCodes = gSwapCodes_ONSA; - TMgTemplateDefinitionArray_Mem[77].swapCodes = gSwapCodes_TxtC; - TMgTemplateDefinitionArray_Mem[78].swapCodes = gSwapCodes_ONTA; - TMgTemplateDefinitionArray_Mem[79].swapCodes = gSwapCodes_ONVL; - TMgTemplateDefinitionArray_Mem[80].swapCodes = gSwapCodes_WPge; - TMgTemplateDefinitionArray_Mem[81].swapCodes = gSwapCodes_OSBD; - TMgTemplateDefinitionArray_Mem[82].swapCodes = gSwapCodes_PSpc; - TMgTemplateDefinitionArray_Mem[83].swapCodes = gSwapCodes_PSpL; - TMgTemplateDefinitionArray_Mem[84].swapCodes = gSwapCodes_PSUI; - TMgTemplateDefinitionArray_Mem[85].swapCodes = gSwapCodes_SNDD; - TMgTemplateDefinitionArray_Mem[86].swapCodes = gSwapCodes_SUBT; - TMgTemplateDefinitionArray_Mem[87].swapCodes = gSwapCodes_UUEA; - TMgTemplateDefinitionArray_Mem[88].swapCodes = gSwapCodes_TMFA; - TMgTemplateDefinitionArray_Mem[89].swapCodes = gSwapCodes_IDXA; - TMgTemplateDefinitionArray_Mem[90].swapCodes = gSwapCodes_TStr; - TMgTemplateDefinitionArray_Mem[91].swapCodes = gSwapCodes_StNA; - TMgTemplateDefinitionArray_Mem[92].swapCodes = gSwapCodes_TMRA; - TMgTemplateDefinitionArray_Mem[93].swapCodes = gSwapCodes_TRAS; - TMgTemplateDefinitionArray_Mem[94].swapCodes = gSwapCodes_TRAM; - TMgTemplateDefinitionArray_Mem[95].swapCodes = gSwapCodes_TRAC; - TMgTemplateDefinitionArray_Mem[96].swapCodes = gSwapCodes_TRCM; - TMgTemplateDefinitionArray_Mem[97].swapCodes = gSwapCodes_TRBS; - TMgTemplateDefinitionArray_Mem[98].swapCodes = gSwapCodes_TRMA; - TMgTemplateDefinitionArray_Mem[99].swapCodes = gSwapCodes_TRFT; - TMgTemplateDefinitionArray_Mem[100].swapCodes = gSwapCodes_TRGA; - TMgTemplateDefinitionArray_Mem[101].swapCodes = gSwapCodes_TRIA; - TMgTemplateDefinitionArray_Mem[102].swapCodes = gSwapCodes_TRSC; - TMgTemplateDefinitionArray_Mem[103].swapCodes = gSwapCodes_TRTA; - TMgTemplateDefinitionArray_Mem[104].swapCodes = gSwapCodes_TSFT; - TMgTemplateDefinitionArray_Mem[105].swapCodes = gSwapCodes_TSFF; - TMgTemplateDefinitionArray_Mem[106].swapCodes = gSwapCodes_TSFL; - TMgTemplateDefinitionArray_Mem[107].swapCodes = gSwapCodes_TSGA; - TMgTemplateDefinitionArray_Mem[108].swapCodes = gSwapCodes_UVDL; - TMgTemplateDefinitionArray_Mem[109].swapCodes = gSwapCodes_WMCL; - TMgTemplateDefinitionArray_Mem[110].swapCodes = gSwapCodes_WMDD; - TMgTemplateDefinitionArray_Mem[111].swapCodes = gSwapCodes_WMMB; - TMgTemplateDefinitionArray_Mem[112].swapCodes = gSwapCodes_WMM_; - TMgTemplateDefinitionArray_Mem[113].swapCodes = gSwapCodes_ONWC; - TMgTemplateDefinitionArray = TMgTemplateDefinitionArray_Mem; -} +#include "BFW.h" +#include "BFW_TemplateManager.h" +#include "BFW_TM_Private.h" +UUtUns64 TMgTemplateChecksum = 1052091493724257; +UUtUns32 TMgNumTemplateDefinitions = 114; +TMtTemplateDefinition* TMgTemplateDefinitionArray = NULL; +static UUtUns8 gSwapCodes_AISA[74] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x05, 0x20, 0x04, 0x06, 0x03, 0x03, 0x03, 0x03, + 0x09, 0x43, 0x43, 0x4e, 0x4f, 0x05, 0x20, 0x04, + 0x06, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x04, 0x06, 0x09, 0x43, 0x57, 0x4e, 0x4f, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x05, 0x02, 0x04, 0x06, + 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AITR[22] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, + 0x05, 0x40, 0x04, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AIWA[21] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x05, + 0x02, 0x04, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AKAA[13] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ABNA[14] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AKVA[40] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AKBA[17] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, + 0x06 +}; +static UUtUns8 gSwapCodes_AKBP[13] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AKDA[23] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AKEV[101] = +{ + 0x02, 0x02, 0x09, 0x41, 0x54, 0x4e, 0x50, 0x09, + 0x41, 0x45, 0x4c, 0x50, 0x09, 0x41, 0x43, 0x58, + 0x54, 0x09, 0x47, 0x51, 0x47, 0x41, 0x09, 0x52, + 0x51, 0x47, 0x41, 0x09, 0x43, 0x51, 0x47, 0x41, + 0x09, 0x42, 0x44, 0x47, 0x41, 0x09, 0x41, 0x4d, + 0x58, 0x54, 0x09, 0x41, 0x56, 0x4b, 0x41, 0x09, + 0x41, 0x42, 0x4b, 0x41, 0x09, 0x41, 0x58, 0x44, + 0x49, 0x09, 0x41, 0x58, 0x44, 0x49, 0x09, 0x50, + 0x42, 0x4b, 0x41, 0x09, 0x41, 0x4e, 0x42, 0x41, + 0x09, 0x54, 0x4f, 0x4b, 0x41, 0x09, 0x41, 0x41, + 0x4b, 0x41, 0x09, 0x41, 0x44, 0x4b, 0x41, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_AGQC[17] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, + 0x06 +}; +static UUtUns8 gSwapCodes_AGDB[12] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AGQG[24] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x04, 0x02, 0x06, 0x05, 0x04, 0x02, 0x06, + 0x05, 0x04, 0x02, 0x06, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AGQM[7] = +{ + 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x06 +}; +static UUtUns8 gSwapCodes_AGQR[12] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x03, 0x03, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_AKOT[28] = +{ + 0x02, 0x02, 0x09, 0x54, 0x49, 0x54, 0x4f, 0x09, + 0x46, 0x4c, 0x54, 0x4f, 0x09, 0x41, 0x4e, 0x54, + 0x51, 0x09, 0x41, 0x58, 0x44, 0x49, 0x09, 0x41, + 0x58, 0x44, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_OTIT[14] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x08, 0x02, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_OTLF[17] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x05, 0x06, 0x02, 0x06, 0x02, 0x02, 0x08, + 0x06 +}; +static UUtUns8 gSwapCodes_QTNA[14] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x04, 0x02, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_BINA[5] = +{ + 0x02, 0x02, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_ENVP[35] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x05, 0x40, 0x04, 0x06, 0x05, 0x30, 0x04, 0x06, + 0x05, 0x0c, 0x02, 0x06, 0x02, 0x02, 0x03, 0x03, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_FXLR[14] = +{ + 0x02, 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, + 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x06 +}; +static UUtUns8 gSwapCodes_3CLA[13] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_EDIA[16] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x02, 0x03, 0x06, 0x03, 0x03, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_M3GM[44] = +{ + 0x02, 0x02, 0x02, 0x09, 0x41, 0x54, 0x4e, 0x50, + 0x09, 0x41, 0x52, 0x43, 0x56, 0x09, 0x41, 0x52, + 0x43, 0x56, 0x09, 0x41, 0x43, 0x58, 0x54, 0x09, + 0x41, 0x58, 0x44, 0x49, 0x09, 0x41, 0x58, 0x44, + 0x49, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x00, + 0x00, 0x00, 0x00, 0x06 +}; +static UUtUns8 gSwapCodes_GMAN[22] = +{ + 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x03, 0x03, + 0x03, 0x05, 0x02, 0x04, 0x06, 0x07, 0x02, 0x09, + 0x4d, 0x47, 0x33, 0x4d, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_M3GA[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_PLEA[14] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_PNTA[23] = +{ + 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x07, 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_QUDA[14] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x04, 0x02, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TXCA[12] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TXMP[30] = +{ + 0x02, 0x02, 0x05, 0x80, 0x04, 0x06, 0x02, 0x03, + 0x03, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x09, + 0x50, 0x4d, 0x58, 0x54, 0x02, 0x02, 0x02, 0x02, + 0x04, 0x05, 0x03, 0x04, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_TXAN[22] = +{ + 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x03, 0x03, + 0x03, 0x05, 0x02, 0x04, 0x06, 0x07, 0x02, 0x09, + 0x50, 0x4d, 0x58, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TXMA[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x09, 0x50, 0x4d, 0x58, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TXMB[20] = +{ + 0x02, 0x02, 0x05, 0x08, 0x04, 0x06, 0x03, 0x03, + 0x02, 0x03, 0x03, 0x07, 0x02, 0x09, 0x50, 0x4d, + 0x58, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TXPC[14] = +{ + 0x02, 0x02, 0x05, 0x08, 0x04, 0x06, 0x02, 0x02, + 0x02, 0x07, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_M3TA[14] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x03, 0x02, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_VCRA[13] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_Impt[15] = +{ + 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x03, 0x04, + 0x06, 0x09, 0x00, 0x00, 0x00, 0x00, 0x06 +}; +static UUtUns8 gSwapCodes_Mtrl[15] = +{ + 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x03, 0x04, + 0x06, 0x09, 0x00, 0x00, 0x00, 0x00, 0x06 +}; +static UUtUns8 gSwapCodes_NMSA[14] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_CONS[33] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x09, 0x41, 0x47, 0x46, 0x4f, 0x09, 0x4d, + 0x47, 0x33, 0x4d, 0x02, 0x05, 0x20, 0x04, 0x06, + 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, + 0x06 +}; +static UUtUns8 gSwapCodes_DOOR[30] = +{ + 0x02, 0x02, 0x05, 0x02, 0x09, 0x41, 0x47, 0x46, + 0x4f, 0x06, 0x09, 0x4e, 0x41, 0x42, 0x4f, 0x02, + 0x02, 0x02, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, + 0x20, 0x04, 0x06, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_OFGA[26] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x09, 0x50, + 0x56, 0x4e, 0x45, 0x07, 0x02, 0x02, 0x09, 0x4d, + 0x47, 0x33, 0x4d, 0x09, 0x53, 0x4c, 0x42, 0x4f, + 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_OBLS[12] = +{ + 0x02, 0x02, 0x02, 0x02, 0x05, 0x03, 0x02, 0x06, + 0x02, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_TRIG[39] = +{ + 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x09, + 0x4d, 0x47, 0x33, 0x4d, 0x09, 0x53, 0x4c, 0x42, + 0x4f, 0x02, 0x09, 0x45, 0x47, 0x52, 0x54, 0x09, + 0x4e, 0x41, 0x42, 0x4f, 0x05, 0x20, 0x04, 0x06, + 0x05, 0x20, 0x04, 0x06, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_TRGE[15] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_TURR[123] = +{ + 0x02, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x04, 0x06, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x05, 0x02, 0x04, 0x06, 0x02, + 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x09, 0x53, 0x4c, + 0x42, 0x4f, 0x02, 0x09, 0x4d, 0x47, 0x33, 0x4d, + 0x02, 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x10, 0x05, + 0x10, 0x04, 0x06, 0x02, 0x03, 0x03, 0x05, 0x0c, + 0x02, 0x06, 0x05, 0x04, 0x04, 0x06, 0x06, 0x02, + 0x05, 0x0c, 0x02, 0x06, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x20, 0x04, + 0x06, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_OBAN[30] = +{ + 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x02, 0x05, + 0x0c, 0x02, 0x06, 0x05, 0x0c, 0x02, 0x06, 0x03, + 0x03, 0x03, 0x07, 0x03, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_OBDC[23] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x03, 0x03, 0x09, 0x4e, 0x41, 0x42, 0x4f, 0x03, + 0x03, 0x02, 0x03, 0x03, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_OBOA[50] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x09, 0x41, 0x47, 0x33, 0x4d, 0x09, 0x4e, 0x41, + 0x42, 0x4f, 0x09, 0x50, 0x56, 0x4e, 0x45, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x05, 0x0c, 0x02, 0x06, + 0x05, 0x40, 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, + 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_CBPI[27] = +{ + 0x02, 0x02, 0x05, 0x13, 0x09, 0x74, 0x70, 0x6d, + 0x49, 0x06, 0x05, 0x13, 0x09, 0x74, 0x70, 0x6d, + 0x49, 0x06, 0x05, 0x13, 0x09, 0x74, 0x70, 0x6d, + 0x49, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_CBPM[11] = +{ + 0x02, 0x02, 0x05, 0x13, 0x09, 0x6c, 0x72, 0x74, + 0x4d, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_ONCC[233] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, + 0x03, 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, + 0x04, 0x04, 0x05, 0x02, 0x04, 0x06, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x03, 0x05, 0x02, 0x04, + 0x06, 0x05, 0x05, 0x02, 0x06, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x04, 0x05, 0x01, 0x04, 0x06, 0x02, 0x05, 0x20, + 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x05, 0x0d, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, + 0x03, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x03, 0x03, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x02, + 0x04, 0x06, 0x05, 0xff, 0x04, 0x06, 0x05, 0x41, + 0x04, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x09, 0x56, 0x43, 0x4e, 0x4f, 0x09, 0x50, 0x43, + 0x4e, 0x4f, 0x09, 0x41, 0x49, 0x4e, 0x4f, 0x04, + 0x04, 0x03, 0x05, 0x10, 0x04, 0x06, 0x05, 0x0f, + 0x05, 0x80, 0x04, 0x06, 0x03, 0x06, 0x05, 0x02, + 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, 0x02, 0x02, + 0x09, 0x53, 0x42, 0x52, 0x54, 0x09, 0x41, 0x4d, + 0x52, 0x54, 0x09, 0x4d, 0x50, 0x42, 0x43, 0x09, + 0x49, 0x50, 0x42, 0x43, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x05, 0x07, 0x02, 0x06, 0x02, + 0x09, 0x43, 0x41, 0x52, 0x54, 0x09, 0x43, 0x53, + 0x52, 0x54, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, + 0x06 +}; +static UUtUns8 gSwapCodes_ONIA[29] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x04, 0x05, + 0x03, 0x04, 0x06, 0x07, 0x02, 0x05, 0x10, 0x04, + 0x06, 0x05, 0x80, 0x04, 0x06, 0x05, 0x10, 0x04, + 0x06, 0x03, 0x03, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONCP[29] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x04, 0x05, + 0x03, 0x04, 0x06, 0x07, 0x02, 0x05, 0x10, 0x04, + 0x06, 0x05, 0x40, 0x04, 0x06, 0x03, 0x05, 0x02, + 0x04, 0x06, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONCV[16] = +{ + 0x02, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x05, + 0x20, 0x04, 0x06, 0x05, 0x20, 0x04, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_CRSA[38] = +{ + 0x02, 0x02, 0x05, 0x0c, 0x04, 0x06, 0x02, 0x02, + 0x07, 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, + 0x02, 0x06, 0x09, 0x43, 0x43, 0x4e, 0x4f, 0x05, + 0x13, 0x05, 0x0c, 0x02, 0x06, 0x06, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_DPge[19] = +{ + 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x03, 0x04, + 0x06, 0x05, 0x0c, 0x02, 0x06, 0x09, 0x47, 0x50, + 0x47, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_FILM[34] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x05, 0x02, 0x09, 0x4d, 0x41, 0x52, + 0x54, 0x06, 0x05, 0x0c, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x02, 0x01, 0x02, 0x05, 0x04, 0x04, 0x06, + 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONFA[22] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x03, 0x07, + 0x03, 0x05, 0x0c, 0x02, 0x06, 0x02, 0x02, 0x02, + 0x02, 0x03, 0x04, 0x04, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONGS[107] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x05, 0x10, 0x02, 0x06, 0x05, 0x10, 0x02, 0x06, + 0x05, 0xff, 0x04, 0x06, 0x05, 0xff, 0x04, 0x06, + 0x05, 0xff, 0x04, 0x06, 0x05, 0x83, 0x04, 0x06, + 0x05, 0xff, 0x04, 0x06, 0x05, 0xff, 0x04, 0x06, + 0x05, 0xff, 0x04, 0x06, 0x05, 0x83, 0x04, 0x06, + 0x05, 0x0e, 0x02, 0x06, 0x05, 0xff, 0x04, 0x06, + 0x05, 0xff, 0x04, 0x06, 0x05, 0x42, 0x04, 0x06, + 0x05, 0xa0, 0x04, 0x06, 0x05, 0x03, 0x02, 0x06, + 0x05, 0x03, 0x02, 0x06, 0x05, 0x03, 0x02, 0x06, + 0x05, 0x03, 0x02, 0x06, 0x05, 0x03, 0x02, 0x06, + 0x05, 0x03, 0x02, 0x06, 0x02, 0x05, 0x10, 0x05, + 0x20, 0x04, 0x06, 0x03, 0x03, 0x05, 0x20, 0x04, + 0x06, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_HPge[13] = +{ + 0x02, 0x02, 0x05, 0x02, 0x04, 0x06, 0x03, 0x09, + 0x47, 0x50, 0x47, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_IGHH[32] = +{ + 0x02, 0x02, 0x05, 0x1c, 0x04, 0x06, 0x09, 0x50, + 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, + 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x07, 0x02, + 0x05, 0x40, 0x04, 0x06, 0x03, 0x03, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_IGPG[27] = +{ + 0x02, 0x02, 0x09, 0x46, 0x46, 0x53, 0x54, 0x02, + 0x02, 0x03, 0x03, 0x09, 0x00, 0x00, 0x00, 0x00, + 0x09, 0x41, 0x53, 0x47, 0x49, 0x09, 0x41, 0x53, + 0x47, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_IGPA[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x09, 0x47, 0x50, 0x47, 0x49, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_IGSt[20] = +{ + 0x02, 0x02, 0x09, 0x46, 0x46, 0x53, 0x54, 0x02, + 0x02, 0x03, 0x03, 0x05, 0xff, 0x04, 0x06, 0x05, + 0x81, 0x04, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_IGSA[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x09, 0x74, 0x53, 0x47, 0x49, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_IPge[9] = +{ + 0x02, 0x02, 0x02, 0x09, 0x47, 0x50, 0x47, 0x49, + 0x06 +}; +static UUtUns8 gSwapCodes_KeyI[53] = +{ + 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, + 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, + 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, + 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, + 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, + 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, + 0x50, 0x4d, 0x58, 0x54, 0x06 +}; +static UUtUns8 gSwapCodes_ONLV[82] = +{ + 0x02, 0x02, 0x05, 0x40, 0x04, 0x06, 0x09, 0x56, + 0x45, 0x4b, 0x41, 0x09, 0x41, 0x4f, 0x42, 0x4f, + 0x09, 0x41, 0x4d, 0x4e, 0x4f, 0x09, 0x41, 0x46, + 0x4e, 0x4f, 0x09, 0x41, 0x54, 0x4e, 0x4f, 0x09, + 0x4b, 0x53, 0x4e, 0x4f, 0x02, 0x09, 0x41, 0x53, + 0x49, 0x41, 0x09, 0x52, 0x54, 0x49, 0x41, 0x09, + 0x41, 0x53, 0x4e, 0x4f, 0x09, 0x43, 0x44, 0x42, + 0x4f, 0x09, 0x41, 0x4f, 0x4e, 0x4f, 0x09, 0x50, + 0x56, 0x4e, 0x45, 0x02, 0x05, 0x20, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x06, 0x09, 0x41, 0x53, 0x52, + 0x43, 0x06 +}; +static UUtUns8 gSwapCodes_ONLD[9] = +{ + 0x02, 0x02, 0x03, 0x03, 0x05, 0x40, 0x04, 0x06, + 0x06 +}; +static UUtUns8 gSwapCodes_ONMA[20] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x05, 0x40, 0x04, 0x06, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONOA[16] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x09, 0x41, 0x58, 0x44, 0x49, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_OPge[13] = +{ + 0x02, 0x02, 0x05, 0x02, 0x04, 0x06, 0x03, 0x09, + 0x41, 0x50, 0x47, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_ONSK[55] = +{ + 0x02, 0x02, 0x05, 0x06, 0x09, 0x50, 0x4d, 0x58, + 0x54, 0x06, 0x05, 0x08, 0x09, 0x50, 0x4d, 0x58, + 0x54, 0x06, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x05, + 0x05, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x06, 0x02, + 0x02, 0x05, 0x08, 0x02, 0x06, 0x05, 0x08, 0x02, + 0x06, 0x05, 0x08, 0x02, 0x06, 0x05, 0x08, 0x02, + 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_ONSA[11] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x03, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TxtC[8] = +{ + 0x02, 0x02, 0x09, 0x41, 0x50, 0x47, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_ONTA[52] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x02, 0x07, + 0x02, 0x05, 0x08, 0x02, 0x02, 0x02, 0x06, 0x05, + 0x06, 0x05, 0x04, 0x02, 0x06, 0x06, 0x05, 0x06, + 0x02, 0x02, 0x02, 0x06, 0x05, 0x06, 0x02, 0x02, + 0x02, 0x02, 0x06, 0x05, 0x06, 0x03, 0x06, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONVL[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x09, 0x56, 0x43, 0x4e, 0x4f, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_WPge[13] = +{ + 0x02, 0x02, 0x09, 0x43, 0x57, 0x4e, 0x4f, 0x09, + 0x47, 0x50, 0x47, 0x49, 0x06 +}; +static UUtUns8 gSwapCodes_OSBD[5] = +{ + 0x02, 0x02, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_PSpc[18] = +{ + 0x02, 0x02, 0x05, 0x09, 0x03, 0x03, 0x06, 0x05, + 0x09, 0x03, 0x03, 0x06, 0x09, 0x00, 0x00, 0x00, + 0x00, 0x06 +}; +static UUtUns8 gSwapCodes_PSpL[16] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_PSUI[223] = +{ + 0x02, 0x02, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, + 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, + 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, + 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, + 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, + 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, + 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, + 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, + 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, + 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, + 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, + 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, + 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, + 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, + 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, + 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, + 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, + 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, + 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, + 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, + 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, + 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, + 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, + 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, + 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, + 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x09, + 0x63, 0x70, 0x53, 0x50, 0x09, 0x63, 0x70, 0x53, + 0x50, 0x09, 0x63, 0x70, 0x53, 0x50, 0x06 +}; +static UUtUns8 gSwapCodes_SNDD[8] = +{ + 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x06 +}; +static UUtUns8 gSwapCodes_SUBT[12] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x02, 0x07, + 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_UUEA[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x05, 0x7e, 0x04, 0x06, 0x03, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TMFA[11] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_IDXA[11] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TStr[7] = +{ + 0x02, 0x02, 0x05, 0x80, 0x04, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_StNA[15] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x09, 0x72, 0x74, 0x53, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TMRA[15] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x09, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRAS[16] = +{ + 0x02, 0x02, 0x09, 0x4d, 0x41, 0x52, 0x54, 0x02, + 0x02, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x06 +}; +static UUtUns8 gSwapCodes_TRAM[94] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x05, 0x02, 0x09, 0x4d, 0x41, 0x52, 0x54, 0x06, + 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, + 0x05, 0x24, 0x02, 0x06, 0x03, 0x04, 0x04, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x04, + 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x03, + 0x03, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x06 +}; +static UUtUns8 gSwapCodes_TRAC[24] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x09, 0x43, + 0x41, 0x52, 0x54, 0x03, 0x07, 0x03, 0x03, 0x03, + 0x02, 0x09, 0x4d, 0x41, 0x52, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRCM[31] = +{ + 0x02, 0x02, 0x02, 0x03, 0x05, 0x02, 0x04, 0x06, + 0x05, 0x40, 0x04, 0x06, 0x02, 0x02, 0x02, 0x09, + 0x41, 0x47, 0x52, 0x54, 0x09, 0x41, 0x54, 0x52, + 0x54, 0x09, 0x41, 0x49, 0x52, 0x54, 0x06 +}; +static UUtUns8 gSwapCodes_TRBS[11] = +{ + 0x02, 0x02, 0x05, 0x05, 0x09, 0x4d, 0x43, 0x52, + 0x54, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_TRMA[15] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x09, 0x50, 0x4d, 0x58, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRFT[11] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRGA[15] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRIA[14] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x04, 0x04, 0x04, 0x04, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRSC[15] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x09, 0x53, 0x41, 0x52, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TRTA[13] = +{ + 0x02, 0x02, 0x05, 0x16, 0x04, 0x06, 0x07, 0x03, + 0x02, 0x02, 0x02, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TSFT[33] = +{ + 0x02, 0x02, 0x05, 0x06, 0x04, 0x06, 0x03, 0x02, + 0x03, 0x03, 0x03, 0x03, 0x05, 0xff, 0x09, 0x41, + 0x47, 0x53, 0x54, 0x06, 0x05, 0x01, 0x09, 0x41, + 0x47, 0x53, 0x54, 0x06, 0x07, 0x02, 0x02, 0x08, + 0x06 +}; +static UUtUns8 gSwapCodes_TSFF[20] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x09, 0x4c, + 0x46, 0x53, 0x54, 0x07, 0x02, 0x09, 0x54, 0x46, + 0x53, 0x54, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_TSFL[23] = +{ + 0x02, 0x02, 0x05, 0x40, 0x04, 0x06, 0x05, 0x40, + 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, 0x05, 0x40, + 0x04, 0x06, 0x05, 0x40, 0x04, 0x06, 0x06 +}; +static UUtUns8 gSwapCodes_TSGA[25] = +{ + 0x02, 0x02, 0x05, 0xff, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x02, 0x02, 0x06, 0x05, 0x01, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x06, + 0x06 +}; +static UUtUns8 gSwapCodes_UVDL[19] = +{ + 0x02, 0x02, 0x05, 0x10, 0x04, 0x06, 0x02, 0x07, + 0x02, 0x05, 0x20, 0x04, 0x06, 0x05, 0x20, 0x04, + 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_WMCL[16] = +{ + 0x02, 0x02, 0x05, 0x14, 0x04, 0x06, 0x07, 0x02, + 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_WMDD[50] = +{ + 0x02, 0x02, 0x05, 0xff, 0x04, 0x06, 0x05, 0x01, + 0x04, 0x06, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, + 0x03, 0x03, 0x07, 0x02, 0x05, 0xff, 0x04, 0x06, + 0x05, 0x01, 0x04, 0x06, 0x03, 0x03, 0x02, 0x02, + 0x03, 0x03, 0x03, 0x03, 0x09, 0x46, 0x46, 0x53, + 0x54, 0x02, 0x02, 0x05, 0x02, 0x04, 0x06, 0x03, + 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_WMMB[16] = +{ + 0x02, 0x02, 0x05, 0x12, 0x04, 0x06, 0x03, 0x07, + 0x02, 0x09, 0x5f, 0x4d, 0x4d, 0x57, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_WMM_[21] = +{ + 0x02, 0x02, 0x05, 0x12, 0x04, 0x06, 0x03, 0x05, + 0x40, 0x04, 0x06, 0x07, 0x02, 0x03, 0x03, 0x05, + 0x40, 0x04, 0x06, 0x08, 0x06 +}; +static UUtUns8 gSwapCodes_ONWC[175] = +{ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x02, + 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x02, 0x02, + 0x09, 0x50, 0x4d, 0x58, 0x54, 0x02, 0x02, 0x02, + 0x02, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x09, 0x50, + 0x4d, 0x58, 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, + 0x09, 0x4d, 0x47, 0x33, 0x4d, 0x05, 0x20, 0x04, + 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x02, 0x02, 0x05, 0x0c, 0x02, 0x06, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x0c, 0x02, + 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x10, 0x05, + 0x0c, 0x02, 0x06, 0x05, 0x10, 0x04, 0x06, 0x02, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06, 0x05, + 0x20, 0x04, 0x06, 0x02, 0x09, 0x50, 0x4d, 0x58, + 0x54, 0x09, 0x50, 0x4d, 0x58, 0x54, 0x05, 0x02, + 0x02, 0x06, 0x02, 0x02, 0x02, 0x02, 0x06 +}; +static TMtTemplateDefinition TMgTemplateDefinitionArray_Mem[114] = +{ + // #0 + { + 180964060137, + 0x41495341, + "AI Character Setup Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x160, + NULL, + 0x4d41474b, + NULL, + }, + // #1 + { + 1763925, + 0x41495452, + "AI script trigger array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x54, + NULL, + 0x4d41474b, + NULL, + }, + // #2 + { + 1081091, + 0x41495741, + "AI Imported Waypoint Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x1c, + NULL, + 0x4d41474b, + NULL, + }, + // #3 + { + 1171063, + 0x414b4141, + "Adjacency Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #4 + { + 1207712, + 0x41424e41, + "bsp tree node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x10, + NULL, + 0x4d41474b, + NULL, + }, + // #5 + { + 14616032, + 0x414b5641, + "BNV Node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x74, + NULL, + 0x4d41474b, + NULL, + }, + // #6 + { + 3811460, + 0x414b4241, + "Side Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x1c, + NULL, + 0x4d41474b, + NULL, + }, + // #7 + { + 848969, + 0x414b4250, + "BSP node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #8 + { + 3036260, + 0x414b4441, + "Door Frame Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x34, + NULL, + 0x4d41474b, + NULL, + }, + // #9 + { + 584922226293, + 0x414b4556, + "Akira Environment", + NULL, + (TMtTemplateFlags)0x4, + 0x80, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #10 + { + 1887121, + 0x41475143, + "Gunk Quad Collision Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x1c, + NULL, + 0x4d41474b, + NULL, + }, + // #11 + { + 470551, + 0x41474442, + "Gunk Quad Debug Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x8, + NULL, + 0x4d41474b, + NULL, + }, + // #12 + { + 1835986, + 0x41475147, + "Gunk Quad General Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x38, + NULL, + 0x4d41474b, + NULL, + }, + // #13 + { + 281254, + 0x4147514d, + "Gunk Quad Material", + NULL, + (TMtTemplateFlags)0x6, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #14 + { + 539195, + 0x41475152, + "Gunk Quad Render Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #15 + { + 76902095368, + 0x414b4f54, + "Oct tree", + NULL, + (TMtTemplateFlags)0x4, + 0x1c, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #16 + { + 676306, + 0x4f544954, + "Oct tree interior node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x20, + NULL, + 0x4d41474b, + NULL, + }, + // #17 + { + 2010123, + 0x4f544c46, + "Oct tree leaf node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x24, + NULL, + 0x4d41474b, + NULL, + }, + // #18 + { + 421580, + 0x51544e41, + "Quad tree node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x10, + NULL, + 0x4d41474b, + NULL, + }, + // #19 + { + 89617, + 0x42494e41, + "Binary Data", + NULL, + (TMtTemplateFlags)0x6, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #20 + { + 6799811, + 0x454e5650, + "Env Particle Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xd0, + NULL, + 0x4d41474b, + NULL, + }, + // #21 + { + 28278257833, + 0x46584c52, + "FX Laser effect", + NULL, + (TMtTemplateFlags)0x4, + 0x14, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #22 + { + 321214, + 0x33434c41, + "RGB Color Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #23 + { + 505591, + 0x45444941, + "Edge Index Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x8, + NULL, + 0x4d41474b, + NULL, + }, + // #24 + { + 170196001846, + 0x4d33474d, + "Geometry", + NULL, + (TMtTemplateFlags)0x4, + 0x2c, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #25 + { + 41447257509, + 0x474d414e, + "Geometry Animation", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #26 + { + 22018728114, + 0x4d334741, + "GeometryArray", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #27 + { + 506936, + 0x504c4541, + "Plane Equation Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x10, + NULL, + 0x4d41474b, + NULL, + }, + // #28 + { + 3630956, + 0x504e5441, + "3D Point Array", + NULL, + (TMtTemplateFlags)0x6, + 0x40, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #29 + { + 220778, + 0x51554441, + "Quad array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x10, + NULL, + 0x4d41474b, + NULL, + }, + // #30 + { + 594970, + 0x54584341, + "Texture Coordinate Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x8, + NULL, + 0x4d41474b, + NULL, + }, + // #31 + { + 36794461023, + 0x54584d50, + "Texture Map", + NULL, + (TMtTemplateFlags)0x4, + 0xb0, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #32 + { + 45282968455, + 0x5458414e, + "Texture Map Animation", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #33 + { + 24056332176, + 0x54584d41, + "Texture map array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #34 + { + 45283174994, + 0x54584d42, + "Texture Map Big", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #35 + { + 763774, + 0x54585043, + "Texture Procedure Data", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #36 + { + 194497, + 0x4d335441, + "Triangle array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #37 + { + 345913, + 0x56435241, + "3D Vector Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #38 + { + 282390, + 0x496d7074, + "Impact", + NULL, + (TMtTemplateFlags)0x4, + 0x14, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #39 + { + 167437, + 0x4d74726c, + "Material", + NULL, + (TMtTemplateFlags)0x4, + 0x14, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #40 + { + 788892, + 0x4e4d5341, + "Network Spawn Point Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x10, + NULL, + 0x4d41474b, + NULL, + }, + // #41 + { + 85270924253, + 0x434f4e53, + "Console", + NULL, + (TMtTemplateFlags)0x4, + 0x90, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #42 + { + 26599423335, + 0x444f4f52, + "Door", + NULL, + (TMtTemplateFlags)0x4, + 0x6c, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #43 + { + 83566969698, + 0x4f464741, + "Object Furn Geom Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #44 + { + 749629, + 0x4f424c53, + "Object LS Data", + NULL, + (TMtTemplateFlags)0x6, + 0x28, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #45 + { + 145438592300, + 0x54524947, + "Trigger", + NULL, + (TMtTemplateFlags)0x4, + 0x74, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #46 + { + 36266490172, + 0x54524745, + "Trigger Emitter", + NULL, + (TMtTemplateFlags)0x4, + 0x28, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #47 + { + 316893824446, + 0x54555252, + "Turret", + NULL, + (TMtTemplateFlags)0x4, + 0x648, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #48 + { + 5114916, + 0x4f42414e, + "Object animation", + NULL, + (TMtTemplateFlags)0x6, + 0x80, + 0x20, + NULL, + 0x4d41474b, + NULL, + }, + // #49 + { + 33246071307, + 0x4f424443, + "Door class array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x18, + NULL, + 0x4d41474b, + NULL, + }, + // #50 + { + 82938791649, + 0x4f424f41, + "Starting Object Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0xf0, + NULL, + 0x4d41474b, + NULL, + }, + // #51 + { + 51740530370, + 0x43425049, + "Character Body Part Impacts", + NULL, + (TMtTemplateFlags)0x4, + 0xec, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #52 + { + 10395858207, + 0x4342504d, + "Character Body Part Material", + NULL, + (TMtTemplateFlags)0x4, + 0x54, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #53 + { + 5109581306351, + 0x4f4e4343, + "Oni Character Class", + NULL, + (TMtTemplateFlags)0x4, + 0xc98, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #54 + { + 2830234, + 0x4f4e4941, + "Oni Character Impact Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xa4, + NULL, + 0x4d41474b, + NULL, + }, + // #55 + { + 3109665, + 0x4f4e4350, + "Oni Character Particle Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x58, + NULL, + 0x4d41474b, + NULL, + }, + // #56 + { + 170485, + 0x4f4e4356, + "Oni Character Variant", + NULL, + (TMtTemplateFlags)0x4, + 0x4c, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #57 + { + 51896374476, + 0x43525341, + "Corpse Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x44c, + NULL, + 0x4d41474b, + NULL, + }, + // #58 + { + 33194403947, + 0x44506765, + "Diary Page", + NULL, + (TMtTemplateFlags)0x4, + 0x44, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #59 + { + 48102073005, + 0x46494c4d, + "Film", + NULL, + (TMtTemplateFlags)0x4, + 0x40, + 0x18, + NULL, + 0x4d41474b, + NULL, + }, + // #60 + { + 1772775, + 0x4f4e4641, + "Imported Flag Node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x44, + NULL, + 0x4d41474b, + NULL, + }, + // #61 + { + 36105142, + 0x4f4e4753, + "Oni Game Settings", + NULL, + (TMtTemplateFlags)0x6, + 0xf44, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #62 + { + 18441269563, + 0x48506765, + "Help Page", + NULL, + (TMtTemplateFlags)0x4, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #63 + { + 38211049694, + 0x49474848, + "IGUI HUD Help", + NULL, + (TMtTemplateFlags)0x4, + 0x40, + 0x44, + NULL, + 0x4d41474b, + NULL, + }, + // #64 + { + 76477335677, + 0x49475047, + "IGUI Page", + NULL, + (TMtTemplateFlags)0x4, + 0x24, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #65 + { + 20900088069, + 0x49475041, + "IGUI Page Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #66 + { + 11318621989, + 0x49475374, + "IGUI String", + NULL, + (TMtTemplateFlags)0x4, + 0x198, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #67 + { + 20900127752, + 0x49475341, + "IGUI String Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #68 + { + 11064797626, + 0x49506765, + "Item Page", + NULL, + (TMtTemplateFlags)0x4, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #69 + { + 275939547053, + 0x4b657949, + "Key Icons", + NULL, + (TMtTemplateFlags)0x4, + 0x30, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #70 + { + 539951247011, + 0x4f4e4c56, + "Oni Game Level", + NULL, + (TMtTemplateFlags)0x4, + 0x304, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #71 + { + 266913, + 0x4f4e4c44, + "Oni Game Level Descriptor", + NULL, + (TMtTemplateFlags)0x6, + 0x4c, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #72 + { + 1197945, + 0x4f4e4d41, + "Imported Marker Node Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x58, + NULL, + 0x4d41474b, + NULL, + }, + // #73 + { + 27043257468, + 0x4f4e4f41, + "Object Gunk Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x8, + NULL, + 0x4d41474b, + NULL, + }, + // #74 + { + 18441354235, + 0x4f506765, + "Objective Page", + NULL, + (TMtTemplateFlags)0x4, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #75 + { + 89156620391, + 0x4f4e534b, + "Oni Sky class", + NULL, + (TMtTemplateFlags)0x4, + 0xf4, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #76 + { + 280116, + 0x4f4e5341, + "Imported Spawn Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x2, + NULL, + 0x4d41474b, + NULL, + }, + // #77 + { + 7376505639, + 0x54787443, + "Text Console", + NULL, + (TMtTemplateFlags)0x4, + 0xc, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #78 + { + 10550464, + 0x4f4e5441, + "Trigger Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x1a0, + NULL, + 0x4d41474b, + NULL, + }, + // #79 + { + 22619145610, + 0x4f4e564c, + "Oni Variant List", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #80 + { + 19047942581, + 0x57506765, + "Weapon Page", + NULL, + (TMtTemplateFlags)0x4, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #81 + { + 89660, + 0x4f534244, + "Oni Sound Binary Data", + NULL, + (TMtTemplateFlags)0x6, + 0x10, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #82 + { + 534088, + 0x50537063, + "Part Specification", + NULL, + (TMtTemplateFlags)0x4, + 0x54, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #83 + { + 838661, + 0x5053704c, + "Part Specification List", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x8, + NULL, + 0x4d41474b, + NULL, + }, + // #84 + { + 4180417615611, + 0x50535549, + "Part Specifications UI", + NULL, + (TMtTemplateFlags)0x4, + 0xb8, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #85 + { + 266731, + 0x534e4444, + "Sound Data", + NULL, + (TMtTemplateFlags)0x6, + 0x18, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #86 + { + 289896, + 0x53554254, + "Subtitle Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #87 + { + 716476, + 0x55554541, + "Error Binding Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x80, + NULL, + 0x4d41474b, + NULL, + }, + // #88 + { + 152356, + 0x544d4641, + "Float Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #89 + { + 159887, + 0x49445841, + "Index Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #90 + { + 25760, + 0x54537472, + "String", + NULL, + (TMtTemplateFlags)0x6, + 0x88, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #91 + { + 24050971936, + 0x53744e41, + "String Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #92 + { + 472353, + 0x544d5241, + "Template Reference Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #93 + { + 8491477296, + 0x54524153, + "Totoro Aiming Screen", + NULL, + (TMtTemplateFlags)0x4, + 0x24, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #94 + { + 70837389592, + 0x5452414d, + "Totoro Animation Sequence", + NULL, + (TMtTemplateFlags)0x4, + 0x188, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #95 + { + 65077377839, + 0x54524143, + "Animation Collection", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #96 + { + 152787879246, + 0x5452434d, + "Totoro Quaternion Body", + NULL, + (TMtTemplateFlags)0x4, + 0x68, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #97 + { + 11317428793, + 0x54524253, + "Totoro Body Set", + NULL, + (TMtTemplateFlags)0x4, + 0x1c, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #98 + { + 24056327511, + 0x54524d41, + "Texture Map Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #99 + { + 139695, + 0x54524654, + "Totoro Facing Table", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #100 + { + 22018728184, + 0x54524741, + "Totoro Quaternion Body Geometry Array", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #101 + { + 705666, + 0x54524941, + "Totoro Quaternion Body Index Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #102 + { + 24049642263, + 0x54525343, + "Screen (aiming) Collection", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #103 + { + 481768, + 0x54525441, + "Totoro Quaternion Body Translation Array", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0xc, + NULL, + 0x4d41474b, + NULL, + }, + // #104 + { + 97619402474, + 0x54534654, + "Font", + NULL, + (TMtTemplateFlags)0x4, + 0x420, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #105 + { + 45272025226, + 0x54534646, + "Font Family", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #106 + { + 581161, + 0x5453464c, + "Font Language", + NULL, + (TMtTemplateFlags)0x6, + 0x148, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #107 + { + 2772632, + 0x54534741, + "Glyph Array", + NULL, + (TMtTemplateFlags)0x6, + 0x1408, + 0x0, + NULL, + 0x4d41474b, + NULL, + }, + // #108 + { + 661221, + 0x5556444c, + "UV Data List", + NULL, + (TMtTemplateFlags)0x6, + 0x20, + 0x40, + NULL, + 0x4d41474b, + NULL, + }, + // #109 + { + 643190, + 0x574d434c, + "WM Cursor List", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x8, + NULL, + 0x4d41474b, + NULL, + }, + // #110 + { + 120261047236, + 0x574d4444, + "WM Dialog Data", + NULL, + (TMtTemplateFlags)0x0, + 0x120, + 0x124, + NULL, + 0x4d41474b, + NULL, + }, + // #111 + { + 29293831991, + 0x574d4d42, + "WM Menu Bar", + NULL, + (TMtTemplateFlags)0x0, + 0x20, + 0x4, + NULL, + 0x4d41474b, + NULL, + }, + // #112 + { + 793144, + 0x574d4d5f, + "WM Menu", + NULL, + (TMtTemplateFlags)0x6, + 0x60, + 0x44, + NULL, + 0x4d41474b, + NULL, + }, + // #113 + { + 1733621247669, + 0x4f4e5743, + "Oni Weapon Class", + NULL, + (TMtTemplateFlags)0x4, + 0x71c, + 0x0, + NULL, + 0x4d41474b, + NULL, + } +}; +void +TMrTemplate_BuildList( + void) +{ + TMgTemplateDefinitionArray_Mem[0].swapCodes = gSwapCodes_AISA; + TMgTemplateDefinitionArray_Mem[1].swapCodes = gSwapCodes_AITR; + TMgTemplateDefinitionArray_Mem[2].swapCodes = gSwapCodes_AIWA; + TMgTemplateDefinitionArray_Mem[3].swapCodes = gSwapCodes_AKAA; + TMgTemplateDefinitionArray_Mem[4].swapCodes = gSwapCodes_ABNA; + TMgTemplateDefinitionArray_Mem[5].swapCodes = gSwapCodes_AKVA; + TMgTemplateDefinitionArray_Mem[6].swapCodes = gSwapCodes_AKBA; + TMgTemplateDefinitionArray_Mem[7].swapCodes = gSwapCodes_AKBP; + TMgTemplateDefinitionArray_Mem[8].swapCodes = gSwapCodes_AKDA; + TMgTemplateDefinitionArray_Mem[9].swapCodes = gSwapCodes_AKEV; + TMgTemplateDefinitionArray_Mem[10].swapCodes = gSwapCodes_AGQC; + TMgTemplateDefinitionArray_Mem[11].swapCodes = gSwapCodes_AGDB; + TMgTemplateDefinitionArray_Mem[12].swapCodes = gSwapCodes_AGQG; + TMgTemplateDefinitionArray_Mem[13].swapCodes = gSwapCodes_AGQM; + TMgTemplateDefinitionArray_Mem[14].swapCodes = gSwapCodes_AGQR; + TMgTemplateDefinitionArray_Mem[15].swapCodes = gSwapCodes_AKOT; + TMgTemplateDefinitionArray_Mem[16].swapCodes = gSwapCodes_OTIT; + TMgTemplateDefinitionArray_Mem[17].swapCodes = gSwapCodes_OTLF; + TMgTemplateDefinitionArray_Mem[18].swapCodes = gSwapCodes_QTNA; + TMgTemplateDefinitionArray_Mem[19].swapCodes = gSwapCodes_BINA; + TMgTemplateDefinitionArray_Mem[20].swapCodes = gSwapCodes_ENVP; + TMgTemplateDefinitionArray_Mem[21].swapCodes = gSwapCodes_FXLR; + TMgTemplateDefinitionArray_Mem[22].swapCodes = gSwapCodes_3CLA; + TMgTemplateDefinitionArray_Mem[23].swapCodes = gSwapCodes_EDIA; + TMgTemplateDefinitionArray_Mem[24].swapCodes = gSwapCodes_M3GM; + TMgTemplateDefinitionArray_Mem[25].swapCodes = gSwapCodes_GMAN; + TMgTemplateDefinitionArray_Mem[26].swapCodes = gSwapCodes_M3GA; + TMgTemplateDefinitionArray_Mem[27].swapCodes = gSwapCodes_PLEA; + TMgTemplateDefinitionArray_Mem[28].swapCodes = gSwapCodes_PNTA; + TMgTemplateDefinitionArray_Mem[29].swapCodes = gSwapCodes_QUDA; + TMgTemplateDefinitionArray_Mem[30].swapCodes = gSwapCodes_TXCA; + TMgTemplateDefinitionArray_Mem[31].swapCodes = gSwapCodes_TXMP; + TMgTemplateDefinitionArray_Mem[32].swapCodes = gSwapCodes_TXAN; + TMgTemplateDefinitionArray_Mem[33].swapCodes = gSwapCodes_TXMA; + TMgTemplateDefinitionArray_Mem[34].swapCodes = gSwapCodes_TXMB; + TMgTemplateDefinitionArray_Mem[35].swapCodes = gSwapCodes_TXPC; + TMgTemplateDefinitionArray_Mem[36].swapCodes = gSwapCodes_M3TA; + TMgTemplateDefinitionArray_Mem[37].swapCodes = gSwapCodes_VCRA; + TMgTemplateDefinitionArray_Mem[38].swapCodes = gSwapCodes_Impt; + TMgTemplateDefinitionArray_Mem[39].swapCodes = gSwapCodes_Mtrl; + TMgTemplateDefinitionArray_Mem[40].swapCodes = gSwapCodes_NMSA; + TMgTemplateDefinitionArray_Mem[41].swapCodes = gSwapCodes_CONS; + TMgTemplateDefinitionArray_Mem[42].swapCodes = gSwapCodes_DOOR; + TMgTemplateDefinitionArray_Mem[43].swapCodes = gSwapCodes_OFGA; + TMgTemplateDefinitionArray_Mem[44].swapCodes = gSwapCodes_OBLS; + TMgTemplateDefinitionArray_Mem[45].swapCodes = gSwapCodes_TRIG; + TMgTemplateDefinitionArray_Mem[46].swapCodes = gSwapCodes_TRGE; + TMgTemplateDefinitionArray_Mem[47].swapCodes = gSwapCodes_TURR; + TMgTemplateDefinitionArray_Mem[48].swapCodes = gSwapCodes_OBAN; + TMgTemplateDefinitionArray_Mem[49].swapCodes = gSwapCodes_OBDC; + TMgTemplateDefinitionArray_Mem[50].swapCodes = gSwapCodes_OBOA; + TMgTemplateDefinitionArray_Mem[51].swapCodes = gSwapCodes_CBPI; + TMgTemplateDefinitionArray_Mem[52].swapCodes = gSwapCodes_CBPM; + TMgTemplateDefinitionArray_Mem[53].swapCodes = gSwapCodes_ONCC; + TMgTemplateDefinitionArray_Mem[54].swapCodes = gSwapCodes_ONIA; + TMgTemplateDefinitionArray_Mem[55].swapCodes = gSwapCodes_ONCP; + TMgTemplateDefinitionArray_Mem[56].swapCodes = gSwapCodes_ONCV; + TMgTemplateDefinitionArray_Mem[57].swapCodes = gSwapCodes_CRSA; + TMgTemplateDefinitionArray_Mem[58].swapCodes = gSwapCodes_DPge; + TMgTemplateDefinitionArray_Mem[59].swapCodes = gSwapCodes_FILM; + TMgTemplateDefinitionArray_Mem[60].swapCodes = gSwapCodes_ONFA; + TMgTemplateDefinitionArray_Mem[61].swapCodes = gSwapCodes_ONGS; + TMgTemplateDefinitionArray_Mem[62].swapCodes = gSwapCodes_HPge; + TMgTemplateDefinitionArray_Mem[63].swapCodes = gSwapCodes_IGHH; + TMgTemplateDefinitionArray_Mem[64].swapCodes = gSwapCodes_IGPG; + TMgTemplateDefinitionArray_Mem[65].swapCodes = gSwapCodes_IGPA; + TMgTemplateDefinitionArray_Mem[66].swapCodes = gSwapCodes_IGSt; + TMgTemplateDefinitionArray_Mem[67].swapCodes = gSwapCodes_IGSA; + TMgTemplateDefinitionArray_Mem[68].swapCodes = gSwapCodes_IPge; + TMgTemplateDefinitionArray_Mem[69].swapCodes = gSwapCodes_KeyI; + TMgTemplateDefinitionArray_Mem[70].swapCodes = gSwapCodes_ONLV; + TMgTemplateDefinitionArray_Mem[71].swapCodes = gSwapCodes_ONLD; + TMgTemplateDefinitionArray_Mem[72].swapCodes = gSwapCodes_ONMA; + TMgTemplateDefinitionArray_Mem[73].swapCodes = gSwapCodes_ONOA; + TMgTemplateDefinitionArray_Mem[74].swapCodes = gSwapCodes_OPge; + TMgTemplateDefinitionArray_Mem[75].swapCodes = gSwapCodes_ONSK; + TMgTemplateDefinitionArray_Mem[76].swapCodes = gSwapCodes_ONSA; + TMgTemplateDefinitionArray_Mem[77].swapCodes = gSwapCodes_TxtC; + TMgTemplateDefinitionArray_Mem[78].swapCodes = gSwapCodes_ONTA; + TMgTemplateDefinitionArray_Mem[79].swapCodes = gSwapCodes_ONVL; + TMgTemplateDefinitionArray_Mem[80].swapCodes = gSwapCodes_WPge; + TMgTemplateDefinitionArray_Mem[81].swapCodes = gSwapCodes_OSBD; + TMgTemplateDefinitionArray_Mem[82].swapCodes = gSwapCodes_PSpc; + TMgTemplateDefinitionArray_Mem[83].swapCodes = gSwapCodes_PSpL; + TMgTemplateDefinitionArray_Mem[84].swapCodes = gSwapCodes_PSUI; + TMgTemplateDefinitionArray_Mem[85].swapCodes = gSwapCodes_SNDD; + TMgTemplateDefinitionArray_Mem[86].swapCodes = gSwapCodes_SUBT; + TMgTemplateDefinitionArray_Mem[87].swapCodes = gSwapCodes_UUEA; + TMgTemplateDefinitionArray_Mem[88].swapCodes = gSwapCodes_TMFA; + TMgTemplateDefinitionArray_Mem[89].swapCodes = gSwapCodes_IDXA; + TMgTemplateDefinitionArray_Mem[90].swapCodes = gSwapCodes_TStr; + TMgTemplateDefinitionArray_Mem[91].swapCodes = gSwapCodes_StNA; + TMgTemplateDefinitionArray_Mem[92].swapCodes = gSwapCodes_TMRA; + TMgTemplateDefinitionArray_Mem[93].swapCodes = gSwapCodes_TRAS; + TMgTemplateDefinitionArray_Mem[94].swapCodes = gSwapCodes_TRAM; + TMgTemplateDefinitionArray_Mem[95].swapCodes = gSwapCodes_TRAC; + TMgTemplateDefinitionArray_Mem[96].swapCodes = gSwapCodes_TRCM; + TMgTemplateDefinitionArray_Mem[97].swapCodes = gSwapCodes_TRBS; + TMgTemplateDefinitionArray_Mem[98].swapCodes = gSwapCodes_TRMA; + TMgTemplateDefinitionArray_Mem[99].swapCodes = gSwapCodes_TRFT; + TMgTemplateDefinitionArray_Mem[100].swapCodes = gSwapCodes_TRGA; + TMgTemplateDefinitionArray_Mem[101].swapCodes = gSwapCodes_TRIA; + TMgTemplateDefinitionArray_Mem[102].swapCodes = gSwapCodes_TRSC; + TMgTemplateDefinitionArray_Mem[103].swapCodes = gSwapCodes_TRTA; + TMgTemplateDefinitionArray_Mem[104].swapCodes = gSwapCodes_TSFT; + TMgTemplateDefinitionArray_Mem[105].swapCodes = gSwapCodes_TSFF; + TMgTemplateDefinitionArray_Mem[106].swapCodes = gSwapCodes_TSFL; + TMgTemplateDefinitionArray_Mem[107].swapCodes = gSwapCodes_TSGA; + TMgTemplateDefinitionArray_Mem[108].swapCodes = gSwapCodes_UVDL; + TMgTemplateDefinitionArray_Mem[109].swapCodes = gSwapCodes_WMCL; + TMgTemplateDefinitionArray_Mem[110].swapCodes = gSwapCodes_WMDD; + TMgTemplateDefinitionArray_Mem[111].swapCodes = gSwapCodes_WMMB; + TMgTemplateDefinitionArray_Mem[112].swapCodes = gSwapCodes_WMM_; + TMgTemplateDefinitionArray_Mem[113].swapCodes = gSwapCodes_ONWC; + TMgTemplateDefinitionArray = TMgTemplateDefinitionArray_Mem; +} diff --git a/OniProj/OniWin32Projs/LSSolutionConverter/LSVCDirectories.txt b/OniProj/OniWin32Projs/LSSolutionConverter/LSVCDirectories.txt index 256ceca..70c2909 100644 --- a/OniProj/OniWin32Projs/LSSolutionConverter/LSVCDirectories.txt +++ b/OniProj/OniWin32Projs/LSSolutionConverter/LSVCDirectories.txt @@ -23,4 +23,4 @@ /I..\BungieFrameWork\BFW_Source\BFW_Totoro\ /I..\BungieFrameWork\BFW_Source\BFW_Utility\ /I..\BungieFrameWork\BFW_ToolSource\Common\LSSolutionFileIO -/I..\BungieFrameWork\BFW_ToolSource\Common\LSSolutionFileIO\LSReader\ \ No newline at end of file +/I..\BungieFrameWork\BFW_ToolSource\Common\LSSolutionFileIO\LSReader\ diff --git a/OniProj/OniWin32Projs/LSSolutionConverter/lsConverter.c b/OniProj/OniWin32Projs/LSSolutionConverter/lsConverter.c index 3624eb4..62f8456 100644 --- a/OniProj/OniWin32Projs/LSSolutionConverter/lsConverter.c +++ b/OniProj/OniWin32Projs/LSSolutionConverter/lsConverter.c @@ -15,10 +15,10 @@ main( BFtFileRef* destFileRef; BFtFileIterator* fileIterator; LStData* lsData; - + UUrInitialize(UUcFalse); - error = + error = BFrFileRef_SearchAndMakeFromName( "LS2LSDPlease", &directory); @@ -37,17 +37,17 @@ main( { return 1; } - + while(1) { - error = + error = BFrDirectory_FileIterator_Next( fileIterator, &sourceFileRef); if(error != UUcError_None) break; fprintf(stderr, "Processing file: %s"UUmNL, BFrFileRef_GetLeafName(sourceFileRef)); - + error = BFrFileRef_Duplicate( sourceFileRef, @@ -57,14 +57,14 @@ main( BFrFileRef_SetLeafNameSuffex( destFileRef, "lsd"); - + error = LSrData_CreateFromLSFile(BFrFileRef_GetFullPath(sourceFileRef), &lsData); UUmAssert(error == UUcError_None); // Spit out the spewData fprintf(stderr, "\tNum Points: %d\n", lsData->numPoints); fprintf(stderr, "\tNum Faces: %d\n", lsData->numFaces); - + if(LSrData_GetSize(lsData) >= LScMaxDataSize) { fprintf(stderr, "WARNING: This LS file is too big(>50Meg)"UUmNL); @@ -79,7 +79,7 @@ main( BFrFileRef_Dispose(sourceFileRef); } - + BFrFileRef_Dispose(directory); BFrDirectory_FileIterator_Delete(fileIterator);