Skip to content

Commit

Permalink
Merge pull request #2 from DarkflameUniverse/script-stuff
Browse files Browse the repository at this point in the history
Script stuff
  • Loading branch information
Tiernan-Alderman authored May 13, 2024
2 parents f8019b7 + 0e4e1de commit 8e1b1c3
Show file tree
Hide file tree
Showing 7 changed files with 1,981 additions and 6 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ include_directories(
"tests/dCommonTests"
"tests/dGameTests"
"tests/dGameTests/dComponentsTests"
"tests/dGameTests/dScriptsTests"

SYSTEM "thirdparty/magic_enum/include/magic_enum"
SYSTEM "thirdparty/raknet/Source"
Expand Down
4 changes: 2 additions & 2 deletions dGame/dGameMessages/GameMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5354,14 +5354,14 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream& inStream, En
if (eInvType == eInventoryType::MODELS) {
item->DisassembleModel(iStackCount);
}

auto lot = item->GetLot();
item->SetCount(item->GetCount() - iStackCount, true);
Game::entityManager->SerializeEntity(entity);

auto* missionComponent = entity->GetComponent<MissionComponent>();

if (missionComponent != nullptr) {
missionComponent->Progress(eMissionTaskType::GATHER, item->GetLot(), LWOOBJID_EMPTY, "", -iStackCount);
missionComponent->Progress(eMissionTaskType::GATHER, lot, LWOOBJID_EMPTY, "", -iStackCount);
}
}
}
Expand Down
23 changes: 19 additions & 4 deletions tests/dGameTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,33 @@ list(APPEND DGAMETEST_SOURCES ${DCOMPONENTS_TESTS})
add_subdirectory(dGameMessagesTests)
list(APPEND DGAMETEST_SOURCES ${DGAMEMESSAGES_TESTS})

add_subdirectory(dScriptsTests)
list(APPEND DGAMETEST_SOURCES ${DSCRIPTS_TESTS})

include_directories(${CMAKE_SOURCE_DIR}/dScripts)

file(COPY ${GAMEMESSAGE_TESTBITSTREAMS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

# Add the executable. Remember to add all tests above this!
add_executable(dGameTests ${DGAMETEST_SOURCES})
add_dependencies(dGameTests conncpp_tests)

target_include_directories(dGameTests PRIVATE
$<TARGET_PROPERTY:dScriptsBase,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:dScriptsServer,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:dScriptsAI,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:dScriptsClient,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:dScriptsEquipmentScripts,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:dScriptsEquipmentTriggers,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:dScriptsZone,INTERFACE_INCLUDE_DIRECTORIES>
)

# Apple needs some special linkage for the mariadb connector for tests.
if(APPLE)
add_custom_command(TARGET dGameTests POST_BUILD
COMMAND install_name_tool ARGS -change libmariadbcpp.dylib @rpath/libmariadbcpp.dylib dGameTests
COMMAND otool ARGS -L dGameTests
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
add_custom_command(TARGET dGameTests POST_BUILD
COMMAND install_name_tool ARGS -change libmariadbcpp.dylib @rpath/libmariadbcpp.dylib dGameTests
COMMAND otool ARGS -L dGameTests
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()

target_link_libraries(dGameTests ${COMMON_LIBRARIES} GTest::gtest_main
Expand Down
11 changes: 11 additions & 0 deletions tests/dGameTests/dScriptsTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(DSCRIPTS_TESTS
"dScriptsTests.cpp"
"CppScriptsOld.cpp"
)

# Get the folder name and prepend it to the files above
get_filename_component(thisFolderName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
list(TRANSFORM DSCRIPTS_TESTS PREPEND "${thisFolderName}/")

# Export to parent scope
set(DSCRIPTS_TESTS ${DSCRIPTS_TESTS} PARENT_SCOPE)
Loading

0 comments on commit 8e1b1c3

Please sign in to comment.