Skip to content

Commit

Permalink
Fix minor style / formatting nitpicks
Browse files Browse the repository at this point in the history
  • Loading branch information
appgurueu committed Jan 11, 2024
1 parent 3c3031d commit f00a72a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
24 changes: 12 additions & 12 deletions games/devtest/mods/unittests/misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ local function test_pseudo_random()
local gen1 = PseudoRandom(13)
assert(gen1:next() == 22290)
assert(gen1:next() == 13854)
for n=2,128 do

for n = 2, 128 do
gen1:next()
end

local gen2 = PseudoRandom(gen1:get_state())
for n=128,256 do
assert(gen1:next()==gen2:next())

for n = 128, 256 do
assert(gen1:next() == gen2:next())
end
end
unittests.register("test_pseudo_random", test_pseudo_random)

local function test_pcg_random()
local gen1 = PcgRandom(55)
for n=0,128 do

for n = 0, 128 do
gen1:next()
end

local gen2 = PcgRandom(26)
gen2:set_state(gen1:get_state())
for n=128,256 do
assert(gen1:next()==gen2:next())

for n = 128, 256 do
assert(gen1:next() == gen2:next())
end
end
unittests.register("test_pcg_random", test_pcg_random)
Expand Down
9 changes: 3 additions & 6 deletions src/script/lua_api/l_noise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,13 +534,10 @@ int LuaPcgRandom::l_set_state(lua_State *L)
NO_MAP_LOCK_REQUIRED;

LuaPcgRandom *o = checkObject<LuaPcgRandom>(L, 1);
if (!lua_isstring(L, 2)) {
throw LuaError("PcgRandom.set_state(): Expected hex strings");
}

std::string l_string = lua_tostring(L, 2);
if (l_string.size()!=32) {
throw LuaError("PcgRandom.set_state(): Expected hex strings of 32 characters");
std::string l_string = readParam<std::string>(L, 2);
if (l_string.size() != 32) {
throw LuaError("PcgRandom:set_state: Expected hex string of 32 characters");
}

std::istringstream s_state_0(l_string.substr(0, 16));
Expand Down

0 comments on commit f00a72a

Please sign in to comment.