Skip to content

Commit

Permalink
Merge branch 'master' into v2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
MCJack123 authored Mar 26, 2020
2 parents 34bec7c + 973cf1d commit 0fbc8ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ int getNextEvent(lua_State *L, std::string filter) {
int count = lua_gettop(param);
if (!lua_checkstack(L, count + 1)) {
printf("Could not allocate enough space in the stack for %d elements, skipping event \"%s\"\n", count, ev.c_str());
lua_remove(computer->paramQueue, 1);
if (lua_gettop(computer->paramQueue) > 0) lua_remove(computer->paramQueue, 1);
return 0;
}
lua_pushstring(L, ev.c_str());
Expand Down
6 changes: 3 additions & 3 deletions src/peripheral/drive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ int drive::insertDisk(lua_State *L, bool init) {
mount_path = "disk" + (i == 0 ? "" : std::to_string(i + 1));
#ifdef WIN32
createDirectory((std::string(getBasePath()) + "\\computer\\disk\\" + std::to_string(id)).c_str());
addMount(get_comp(L), (std::string(getBasePath()) + "\\computer\\disk\\" + std::to_string(id)).c_str(), mount_path.c_str(), false);
addMount(comp, (std::string(getBasePath()) + "\\computer\\disk\\" + std::to_string(id)).c_str(), mount_path.c_str(), false);
#else
assert(createDirectory((std::string(getBasePath()) + "/computer/disk/" + std::to_string(id)).c_str()) == 0);
addMount(get_comp(L), (std::string(getBasePath()) + "/computer/disk/" + std::to_string(id)).c_str(), mount_path.c_str(), false);
addMount(comp, (std::string(getBasePath()) + "/computer/disk/" + std::to_string(id)).c_str(), mount_path.c_str(), false);
#endif
} else if (lua_isstring(L, arg)) {
path = lua_tostring(L, arg);
Expand All @@ -151,7 +151,7 @@ int drive::insertDisk(lua_State *L, bool init) {
for (i = 0; comp->usedDriveMounts.find(i) != comp->usedDriveMounts.end(); i++);
comp->usedDriveMounts.insert(i);
mount_path = "disk" + (i == 0 ? "" : std::to_string(i + 1));
addMount(get_comp(L), path.c_str(), mount_path.c_str(), false);
addMount(comp, path.c_str(), mount_path.c_str(), false);
}
#ifndef NO_MIXER
else {
Expand Down
11 changes: 6 additions & 5 deletions src/term.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,10 @@ void termRenderLoop() {
}

void termQueueProvider(Computer *comp, event_provider p, void* data) {
comp->event_provider_queue_mutex.lock();
comp->event_provider_queue.push(std::make_pair(p, data));
comp->event_provider_queue_mutex.unlock();
{
std::lock_guard<std::mutex> lock(comp->event_provider_queue_mutex);
comp->event_provider_queue.push(std::make_pair(p, data));
}
comp->event_lock.notify_all();
}

Expand Down Expand Up @@ -1097,8 +1098,8 @@ int term_getPixel(lua_State *L) {
Terminal * term = computer->term;
int x = lua_tointeger(L, 1);
int y = lua_tointeger(L, 2);
if (x > term->width * term->fontWidth || y > term->height * term->fontHeight || x < 0 || y < 0) return 0;
if (term->mode == 1) lua_pushinteger(L, 2^term->pixels[lua_tointeger(L, 2)][lua_tointeger(L, 1)]);
if (x > term->width * term->fontWidth || y > term->height * term->fontHeight || x < 0 || y < 0) lua_pushnil(L);
else if (term->mode == 1) lua_pushinteger(L, 2^term->pixels[lua_tointeger(L, 2)][lua_tointeger(L, 1)]);
else if (term->mode == 2) lua_pushinteger(L, term->pixels[lua_tointeger(L, 2)][lua_tointeger(L, 1)]);
else return 0;
return 1;
Expand Down

0 comments on commit 0fbc8ba

Please sign in to comment.