Skip to content

Commit

Permalink
Merge pull request #1004 from lukaspj/console-refactor
Browse files Browse the repository at this point in the history
Console Refactor
  • Loading branch information
Azaezel authored Sep 13, 2023
2 parents 626de07 + 83ea6cd commit ec8a829
Show file tree
Hide file tree
Showing 89 changed files with 1,937 additions and 1,727 deletions.
27 changes: 14 additions & 13 deletions Engine/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ endif (APPLE)

# When on Windows, we need to link against winsock and windows codecs
if (WIN32)
set(TORQUE_SOURCE_FILES ${TORQUE_SOURCE_FILES} ${TORQUE_PLATFORM_WIN_SOURCES})
set(TORQUE_SOURCE_FILES ${TORQUE_SOURCE_FILES} ${TORQUE_PLATFORM_WIN_SOURCES})
endif (WIN32)

# Linux requires X11 & freetype
if (UNIX AND NOT APPLE)
set(TORQUE_SOURCE_FILES ${TORQUE_SOURCE_FILES} ${TORQUE_PLATFORM_X11_SOURCES})
set(TORQUE_SOURCE_FILES ${TORQUE_SOURCE_FILES} ${TORQUE_PLATFORM_X11_SOURCES})
find_package(Freetype REQUIRED)
set(TORQUE_INCLUDE_DIRECTORIES ${TORQUE_INCLUDE_DIRECTORIES} ${FREETYPE_INCLUDE_DIRS})
endif (UNIX AND NOT APPLE)
Expand All @@ -50,11 +50,12 @@ torqueAddSourceDirectories("app" "app/net")

# Handle console
torqueAddSourceDirectories("console")
torqueAddSourceDirectories("console/torquescript")

# Handle Platform
torqueAddSourceDirectories("platform" "platform/threads" "platform/async"
"platform/input" "platform/output")

torqueAddSourceDirectories("platform/nativeDialogs")

# Handle T3D
Expand Down Expand Up @@ -291,7 +292,7 @@ endforeach()
# Prepare Windows RC file
if (WIN32)
set(APPLICATION_ICON_PATH "${CMAKE_SOURCE_DIR}/Tools/CMake/torque.ico")

configure_file("${CMAKE_SOURCE_DIR}/Tools/CMake/torque-win.rc.in" "${CMAKE_BINARY_DIR}/temp/torque.rc")
set(TORQUE_SOURCE_FILES ${TORQUE_SOURCE_FILES} "${CMAKE_BINARY_DIR}/temp/torque.rc")
endif (WIN32)
Expand All @@ -300,7 +301,7 @@ endif (WIN32)
if (APPLE)
set(TORQUE_SOURCE_FILES ${TORQUE_SOURCE_FILES} ${TORQUE_PLATFORM_MAC_SOURCES} "${CMAKE_SOURCE_DIR}/Tools/CMake/torque.icns")
set_source_files_properties("${CMAKE_SOURCE_DIR}/Tools/CMake/torque.icns" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")

set(EXECUTABLE_NAME "${TORQUE_APP_NAME}")
configure_file("${CMAKE_SOURCE_DIR}/Tools/CMake/Info.plist.in" "${CMAKE_BINARY_DIR}/temp/Info.plist" COPYONLY)
endif (APPLE)
Expand Down Expand Up @@ -348,25 +349,25 @@ if (APPLE)
set(CMAKE_XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks")
elseif (WIN32)
add_executable(${TORQUE_APP_NAME} WIN32 ${TORQUE_SOURCE_FILES})

set(TORQUE_CXX_FLAGS_COMMON_DEFAULT "-DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS /MP /Ob2 /Oi /Ot /Oy /GT /Zi /W4 /nologo /GF /EHsc /GS- /Gy- /Qpar- /fp:precise /fp:except- /GR /Zc:wchar_t-" )
if( TORQUE_CPU_X32 )
set(TORQUE_CXX_FLAGS_COMMON_DEFAULT "${TORQUE_CXX_FLAGS_COMMON_DEFAULT} /arch:SSE2")
endif()
set(TORQUE_CXX_FLAGS_COMMON ${TORQUE_CXX_FLAGS_COMMON_DEFAULT} CACHE STRING "")
mark_as_advanced(TORQUE_CXX_FLAGS_COMMON)

set(TORQUE_CXX_FLAGS_EXECUTABLES "/wd4018 /wd4100 /wd4121 /wd4127 /wd4130 /wd4244 /wd4245 /wd4389 /wd4511 /wd4512 /wd4800 /wd4995" CACHE STRING "")
mark_as_advanced(TORQUE_CXX_FLAGS_EXECUTABLES)

set(TORQUE_CXX_FLAGS "${TORQUE_CXX_FLAGS_COMMON_DEFAULT} ${TORQUE_CXX_FLAGS_EXECUTABLES}" CACHE STRING "")
mark_as_advanced(TORQUE_CXX_FLAGS)

# NOTE: On Windows, /Zc:wchar_t- is necessary otherwise you get unicode errors
set_target_properties(${TORQUE_APP_NAME} PROPERTIES COMPILE_FLAGS "${TORQUE_CXX_FLAGS}")
else()
add_executable(${TORQUE_APP_NAME} ${TORQUE_SOURCE_FILES})

# NOTE: On Linux, we set the rpath to ./ so that shared objects next to the executable are used
set_target_properties(${TORQUE_APP_NAME} PROPERTIES LINK_FLAGS "-Wl,-rpath,./")
endif()
Expand Down Expand Up @@ -423,9 +424,9 @@ if (UNIX)
# For eg. OSX some links are not valid targets - for example frameworks provided by OS
if (TARGET ${GAME_LINK_LIBRARY})
get_target_property(LINK_LIBRARY_TYPE ${GAME_LINK_LIBRARY} TYPE)

# Only pay attention to shared libraries and make them output to the app resources
if ("${LINK_LIBRARY_TYPE}" STREQUAL "SHARED_LIBRARY")
if ("${LINK_LIBRARY_TYPE}" STREQUAL "SHARED_LIBRARY")
if (APPLE)
set_target_properties(${GAME_LINK_LIBRARY} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks")
else()
Expand All @@ -434,4 +435,4 @@ if (UNIX)
endif()
endif()
endforeach()
endif (UNIX)
endif (UNIX)
5 changes: 3 additions & 2 deletions Engine/source/T3D/assets/CubemapAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#endif

// Debug Profiling.
#include "console/script.h"
#include "platform/profiler.h"

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -140,15 +141,15 @@ void CubemapAsset::initializeAsset()

mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
Con::executeFile(mScriptPath, false, false);
}

void CubemapAsset::onAssetRefresh()
{
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
Con::executeFile(mScriptPath, false, false);
}

Expand Down
9 changes: 5 additions & 4 deletions Engine/source/T3D/assets/GUIAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#endif

// Debug Profiling.
#include "console/script.h"
#include "platform/profiler.h"

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -118,25 +119,25 @@ void GUIAsset::initializeAsset()
{
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
Con::executeFile(mScriptPath, false, false);

mGUIPath = getOwned() ? expandAssetFilePath(mGUIFile) : mGUIPath;

if (Torque::FS::IsScriptFile(mGUIPath))
if (Con::isScriptFile(mGUIPath))
Con::executeFile(mGUIPath, false, false);
}

void GUIAsset::onAssetRefresh()
{
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
Con::executeFile(mScriptPath, false, false);

mGUIPath = getOwned() ? expandAssetFilePath(mGUIFile) : mGUIPath;

if (Torque::FS::IsScriptFile(mGUIPath))
if (Con::isScriptFile(mGUIPath))
Con::executeFile(mGUIPath, false, false);
}

Expand Down
5 changes: 3 additions & 2 deletions Engine/source/T3D/assets/GameObjectAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#endif

// Debug Profiling.
#include "console/script.h"
#include "platform/profiler.h"

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -134,7 +135,7 @@ void GameObjectAsset::initializeAsset()
//Ensure we have an expanded filepath
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
Con::executeFile(mScriptPath, false, false);

mTAMLPath = getOwned() ? expandAssetFilePath(mTAMLFile) : mTAMLPath;
Expand All @@ -145,7 +146,7 @@ void GameObjectAsset::onAssetRefresh()
//Ensure we have an expanded filepath
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
Con::executeFile(mScriptPath, false, false);

mTAMLPath = getOwned() ? expandAssetFilePath(mTAMLFile) : mTAMLPath;
Expand Down
5 changes: 3 additions & 2 deletions Engine/source/T3D/assets/MaterialAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "assets/assetPtr.h"
#endif

#include "console/script.h"
#include "T3D/assets/assetImporter.h"

StringTableEntry MaterialAsset::smNoMaterialAssetFallback = NULL;
Expand Down Expand Up @@ -179,7 +180,7 @@ void MaterialAsset::initializeAsset()
{
mLoadedState = EmbeddedDefinition;
}
else if (Torque::FS::IsScriptFile(mScriptPath))
else if (Con::isScriptFile(mScriptPath))
{
if (!Sim::findObject(mMatDefinitionName))
{
Expand Down Expand Up @@ -211,7 +212,7 @@ void MaterialAsset::onAssetRefresh()
return;
}

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
{
//Since we're refreshing, we can assume that the file we're executing WILL have an existing definition.
//But that definition, whatever it is, is the 'correct' one, so we enable the Replace Existing behavior
Expand Down
5 changes: 3 additions & 2 deletions Engine/source/T3D/assets/PostEffectAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#endif

// Debug Profiling.
#include "console/script.h"
#include "platform/profiler.h"

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -137,7 +138,7 @@ void PostEffectAsset::initializeAsset()
mHLSLShaderPath = getOwned() ? expandAssetFilePath(mHLSLShaderFile) : mHLSLShaderPath;
mGLSLShaderPath = getOwned() ? expandAssetFilePath(mGLSLShaderFile) : mGLSLShaderPath;

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
Con::executeFile(mScriptPath, false, false);
}

Expand All @@ -147,7 +148,7 @@ void PostEffectAsset::onAssetRefresh()
mHLSLShaderPath = getOwned() ? expandAssetFilePath(mHLSLShaderFile) : mHLSLShaderPath;
mGLSLShaderPath = getOwned() ? expandAssetFilePath(mGLSLShaderFile) : mGLSLShaderPath;

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
Con::executeFile(mScriptPath, false, false);
}

Expand Down
7 changes: 4 additions & 3 deletions Engine/source/T3D/assets/ScriptAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#endif

// Debug Profiling.
#include "console/script.h"
#include "platform/profiler.h"

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -140,7 +141,7 @@ void ScriptAsset::initializeAsset()

mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
{
//We're initialized properly, so we'll go ahead and kick along any dependencies we may have as well
AssetManager::typeAssetDependsOnHash::Iterator assetDependenciesItr = mpOwningAssetManager->getDependedOnAssets()->find(mpAssetDefinition->mAssetId);
Expand Down Expand Up @@ -170,7 +171,7 @@ void ScriptAsset::onAssetRefresh()
{
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
{
//Refresh any dependencies we may have
for (U32 i = 0; i < mScriptAssetDependencies.size(); i++)
Expand Down Expand Up @@ -215,7 +216,7 @@ bool ScriptAsset::execScript()
if (handle)
return true;

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
{
return Con::executeFile(mScriptPath, false, false);
}
Expand Down
5 changes: 3 additions & 2 deletions Engine/source/T3D/assets/TerrainMaterialAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "assets/assetPtr.h"
#endif

#include "console/script.h"
#include "T3D/assets/assetImporter.h"

StringTableEntry TerrainMaterialAsset::smNoTerrainMaterialAssetFallback = NULL;
Expand Down Expand Up @@ -182,7 +183,7 @@ void TerrainMaterialAsset::initializeAsset()
{
mLoadedState = EmbeddedDefinition;
}
else if (Torque::FS::IsScriptFile(mScriptPath))
else if (Con::isScriptFile(mScriptPath))
{
if (!Sim::findObject(mMatDefinitionName))
{
Expand Down Expand Up @@ -214,7 +215,7 @@ void TerrainMaterialAsset::onAssetRefresh()
return;
}

if (Torque::FS::IsScriptFile(mScriptPath))
if (Con::isScriptFile(mScriptPath))
{
//Since we're refreshing, we can assume that the file we're executing WILL have an existing definition.
//But that definition, whatever it is, is the 'correct' one, so we enable the Replace Existing behavior
Expand Down
3 changes: 2 additions & 1 deletion Engine/source/T3D/prefab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "console/consoleTypes.h"
#include "core/volume.h"
#include "console/engineAPI.h"
#include "console/script.h"
#include "T3D/physics/physicsShape.h"
#include "core/util/path.h"

Expand Down Expand Up @@ -344,7 +345,7 @@ void Prefab::_loadFile( bool addFileNotify )
if ( mFilename == StringTable->EmptyString())
return;

if ( !Torque::FS::IsScriptFile( mFilename ) )
if ( !Con::isScriptFile( mFilename ) )
{
Con::errorf( "Prefab::_loadFile() - file %s was not found.", mFilename );
return;
Expand Down
1 change: 1 addition & 0 deletions Engine/source/T3D/trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "console/consoleTypes.h"
#include "console/engineAPI.h"
#include "collision/boxConvex.h"
#include "console/script.h"

#include "core/stream/bitStream.h"
#include "math/mathIO.h"
Expand Down
3 changes: 2 additions & 1 deletion Engine/source/Verve/Core/VDataTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
//-----------------------------------------------------------------------------
#include "Verve/Core/VDataTable.h"

#include "console/script.h"
#include "console/simObject.h"

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -228,7 +229,7 @@ bool VDataTable::getValue( SimObject *pObject, const String &pFieldName, String
case VDataTable::k_TypeExpression :
{
// Evaluate.
pValue = Con::evaluate( fieldValue, false ).getString();
pValue = Con::evaluate( fieldValue, false ).value.getString();

} break;

Expand Down
1 change: 1 addition & 0 deletions Engine/source/Verve/Extension/Script/VScriptEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "Verve/Extension/Script/VScriptEvent.h"

#include "console/consoleTypes.h"
#include "console/script.h"

//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VScriptEvent );
Expand Down
9 changes: 4 additions & 5 deletions Engine/source/afx/afxChoreographer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include "afx/arcaneFX.h"

#include "console/engineAPI.h"
#include "console/script.h"
#include "T3D/gameBase/gameConnection.h"
#include "math/mathIO.h"
#include "console/compiler.h"

#include "afx/afxConstraint.h"
#include "afx/afxChoreographer.h"
Expand Down Expand Up @@ -108,12 +108,11 @@ bool afxChoreographerData::preload(bool server, String &errorStr)

if (!server && client_script_file != ST_NULLSTRING)
{
Compiler::gSyntaxError = false;
Con::evaluate(avar("exec(\"%s\");", client_script_file), false, 0);
if (Compiler::gSyntaxError)
Con::EvalResult result = Con::evaluate(avar("exec(\"%s\");", client_script_file), false, 0);

if (!result.valid)
{
Con::errorf("afxChoreographerData: failed to exec clientScriptFile \"%s\" -- syntax error", client_script_file);
Compiler::gSyntaxError = false;
}
}

Expand Down
5 changes: 3 additions & 2 deletions Engine/source/afx/arcaneFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
#include "T3D/gameBase/gameProcess.h"
#include "T3D/player.h"
#include "math/mathUtils.h"
#include "console/compiler.h"

#include "console/engineAPI.h"
#include "console/script.h"

#include "afx/afxChoreographer.h"
#include "afx/afxSelectron.h"
Expand Down Expand Up @@ -672,7 +673,7 @@ DefineEngineFunction(wasSyntaxError, bool, (),,
"for detecting syntax errors after reloading a script.\n\n"
"@ingroup AFX")
{
return Compiler::gSyntaxError;
return Con::getLastEvalResult().valid == false;
}

//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
Expand Down
Loading

0 comments on commit ec8a829

Please sign in to comment.