Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgavedissian committed May 31, 2019
1 parent 1051a94 commit 37f51c9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/dawn/resource/ResourceCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ void ResourceCache::addPackage(const String& package, UniquePtr<ResourcePackage>
resource_packages_.emplace(makePair(package, std::move(file)));
}

Result<SharedPtr<InputStream>> ResourceCache::loadRaw(
const ResourcePath &resource_path) {
Result<SharedPtr<InputStream>> ResourceCache::loadRaw(const ResourcePath& resource_path) {
// Parse resource path.
auto path = parseResourcePath(resource_path);
String package = path.first;
Expand Down
11 changes: 6 additions & 5 deletions src/dawn/script/LuaVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ void registerWorldLib(sol::state& state) {
} // namespace

LuaVM::LuaVM(Context* context) : Object(context) {
state_.open_libraries(sol::lib::base, sol::lib::package, sol::lib::coroutine, sol::lib::string, sol::lib::os, sol::lib::math, sol::lib::table, sol::lib::debug, sol::lib::bit32);
state_.set_function("__dw_write_log",
[this](const char* caller, const char* str) {
log().info("%s: %s", caller, str);
});
state_.open_libraries(sol::lib::base, sol::lib::package, sol::lib::coroutine, sol::lib::string,
sol::lib::os, sol::lib::math, sol::lib::table, sol::lib::debug,
sol::lib::bit32);
state_.set_function("__dw_write_log", [this](const char* caller, const char* str) {
log().info("%s: %s", caller, str);
});
redirectLuaPrintToLogger(*context, state_);
registerWorldLib(state_);
}
Expand Down
13 changes: 7 additions & 6 deletions src/lua_shooter/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class LuaGameSession : public GameSession {
}

// Create Lua VM and execute script.
auto script_result = rc->loadRaw(lua_script_file);
auto execute_result = lua_state_.execute(**script_result);
if (!execute_result) {
log().error("Failed to execute %s: %s", lua_script_file, execute_result.error());
}
auto script_result = rc->loadRaw(lua_script_file);
auto execute_result = lua_state_.execute(**script_result);
if (!execute_result) {
log().error("Failed to execute %s: %s", lua_script_file, execute_result.error());
}
}

~LuaGameSession() override {
Expand Down Expand Up @@ -70,7 +70,8 @@ class LuaShooter : public App {
void init(const CommandLine&) override {
module<ResourceCache>()->addPath("shooter", "../src/lua_shooter/data");

engine_->addSession(makeUnique<LuaGameSession>(context_, "shooter:script_idea.lua", GameSessionInfo{}));
engine_->addSession(
makeUnique<LuaGameSession>(context_, "shooter:script_idea.lua", GameSessionInfo{}));
}

void shutdown() override {
Expand Down

0 comments on commit 37f51c9

Please sign in to comment.