void finish(int result) {
  close(sockfd);
#ifdef __EMSCRIPTEN__
  REPORT_RESULT();
  emscripten_force_exit(result);
#else
  exit(result);
#endif
}
Beispiel #2
0
void dispose(int status) {
    fprintf(stdout, "dispose (%d)\n", status);
    free(output_data);

    #ifdef __EMSCRIPTEN__
        emscripten_force_exit(status);
    #endif

    exit(status);
}
Beispiel #3
0
void EngineExit(int code)
{
    GraphicsShutDown();

    #ifdef __EMSCRIPTEN__
        emscripten_force_exit(code);
    #endif

    exit(code); // Needed at least on iOS to forcibly shut down the wrapper main()
}
void finish(int result) {
  if (server.fd) {
    close(server.fd);
    server.fd = 0;
  }
#ifdef __EMSCRIPTEN__
  REPORT_RESULT();
  emscripten_force_exit(result);
#else
  exit(result);
#endif
}
Beispiel #5
0
void finish(int result) {
    if (state.sd) {
        SDLNet_TCP_Close(state.sd);
        SDLNet_Quit();
    }
#ifdef __EMSCRIPTEN__
    REPORT_RESULT();
    emscripten_force_exit(result);
#else
    exit(result);
#endif
}
Beispiel #6
0
// Expects errorhandler at index 1
void pcall(lua_State *state, int nargs) {
  if(lua_pcall(state, nargs, 0, 1)) {
    char const *msg = lua_tostring(state, -1);
    printf("Lua error: %s\n", msg);
    graphics_Font font;
    graphics_setBackgroundColor(0.64f, 0.27f, 0.26f, 1.0f);
    graphics_clear();
    graphics_setColor(1.0f, 1.0f, 1.0f, 0.8f);
    graphics_Font_new(&font, 0, 12);
    graphics_Font_render(&font, msg, 10, 40, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f); 
    graphics_swap();

    #ifdef EMSCRIPTEN
      emscripten_force_exit(1);
    #else
      exit(1);
    #endif
  }
}
Beispiel #7
0
void c3(char *data, int size, void *arg) { // tests calls different in different workers.
  int calls = *((int*)data);
  printf("%d: %d\n", (int)arg, calls);
  if ((int)arg == 7) {
    assert(c3_7 == 0);
    c3_7++;
    assert(calls == 5);
  } else {
    assert((int)arg == 8);
    assert(c3_8 == 0);
    c3_8++;
    assert(calls == 1);
  }
  if (c3_7 && c3_7) { // note: racey, responses from 2 workers here
    emscripten_destroy_worker(w1);
    int result = 11;
    REPORT_RESULT();
    emscripten_force_exit(0);
  }
}
Beispiel #8
0
void main_loop(void *data) {
  MainLoopData* loopData = (MainLoopData*)data;

  timer_step();
  lua_rawgeti(loopData->luaState, LUA_REGISTRYINDEX, loopData->errhand);
  lua_getglobal(loopData->luaState, "love");
  lua_pushstring(loopData->luaState, "update");

  lua_rawget(loopData->luaState, -2);
  lua_pushnumber(loopData->luaState, timer_getDelta());
  if (swap_At == 1){
      if(luaL_dofile(loopData->luaState, "main.lua")) {
          printf("Error: %s\n", lua_tostring(loopData->luaState, -1));
        }
    }

  if(lua_pcall(loopData->luaState, 1, 0, 0)) {
      printf("Lua error: %s\n", lua_tostring(loopData->luaState, -1));
#ifdef EMSCRIPTEN
      quit_function(loopData->luaState);
      emscripten_force_exit(1);
#else
      exit(1);
#endif
    }

  graphics_clear();

  lua_pushstring(loopData->luaState, "draw");
  lua_rawget(loopData->luaState, -2);

  if(lua_pcall(loopData->luaState, 0, 0, 0)) {
      printf("Lua error: %s\n", lua_tostring(loopData->luaState, -1));
#ifdef EMSCRIPTEN
      quit_function(loopData->luaState);
      emscripten_force_exit(1);
      l_running = 0;
#else
      l_running = 0;
#endif
    }

  graphics_swap();

  // silly hack for love.event.quit()
#ifdef WINDOWS
  event_force_quit = graphics_stop_windows();
  if(!event_force_quit)
    l_running = 0;
#endif //This will affect only Windows users
  //

  lua_pop(loopData->luaState, 1);
#ifdef UNIX
  SDL_Event event;
  while(SDL_PollEvent(&event)) {
      if (event.type == SDL_WINDOWEVENT) {
          switch (event.window.event) {
            case SDL_WINDOWEVENT_ENTER:
              graphics_setMouseFocus(1);
              break;
            case SDL_WINDOWEVENT_LEAVE:
              graphics_setMouseFocus(0);
              break;
            case SDL_WINDOWEVENT_FOCUS_LOST:
              graphics_setFocus(0);
              break;
            case SDL_WINDOWEVENT_FOCUS_GAINED:
              graphics_setFocus(1);
              break;
            default:
              break;
            }
        }
      switch(event.wheel.type)
        {
        case SDL_MOUSEWHEEL:
          mouse_mousewheel(event.wheel.y);
          int _what = event.wheel.y == 1 ? SDL_BUTTON_WHEEL_UP : SDL_BUTTON_WHEEL_DOWN;
          mouse_mousepressed(event.button.x, event.button.y,
                             _what);
          break;
        default:
          break;
        }
      switch(event.type) {
        case SDL_KEYDOWN:
          keyboard_keypressed(event.key.keysym.sym);
          break;
        case SDL_KEYUP:
          keyboard_keyreleased(event.key.keysym.sym);
          break;
        case SDL_TEXTINPUT:
          keyboard_textInput(event.text.text);
          break;
        case SDL_MOUSEMOTION:
          mouse_mousemoved(event.motion.x, event.motion.y);
          break;
        case SDL_MOUSEBUTTONDOWN:
          mouse_mousepressed(event.button.x, event.button.y,
                             event.button.button);
          break;
        case SDL_MOUSEBUTTONUP:
          mouse_mousereleased(event.button.x, event.button.y,
                              event.button.button);
          break;
#ifndef EMSCRIPTEN
        case SDL_QUIT:
          quit_function(loopData->luaState);
          l_running = 0;
#endif
        }
    }
#endif
}