<commit_before>/*
 * Copyright (c) 2016 <NAME>
 * All rights reserved.
 *
 * This file provides the implementation for the engine's C interface,
 * specifically tailored for LuaJIT's FFI facilities.
 *
 * General engine stuff
 */

#include "redcrane.hpp"

using namespace redc;

namespace redc
{
  Server::Server()
  {
    bt_config = std::make_unique<btDefaultCollisionConfiguration>();
    bt_dispatcher = std::make_unique<btCollisionDispatcher>(bt_config.get());
    bt_broadphase = std::make_unique<btDbvtBroadphase>();
    bt_solver = std::make_unique<btSequentialImpulseConstraintSolver>();

    bt_world = std::make_unique<btDiscreteDynamicsWorld>(bt_dispatcher.get(),
                                                         bt_broadphase.get(),
                                                         bt_solver.get(),
                                                         bt_config.get());

    bt_world->setGravity(btVector3(0.0f, -9.81f, 0.0f));
  }
}

obj_id redc_server_add_player(void *eng)
{
  auto rce = (Engine*) eng;
  REDC_ASSERT_HAS_SERVER(rce);

  // Add player to list of players, return obj id
  auto id = rce->server->index_gen.get();

  // Add local player controller action interface to player controller.
  rce->server->bt_world->addAction(&rce->server->players[id-1].controller);

  return id;
}

void redc_server_step(void *eng)
{
  auto rce = (Engine*) eng;
  REDC_ASSERT_HAS_SERVER(rce);

  rce->server->bt_world->stepSimulation(time_since(rce->start_time), 10);
}<commit_msg>Give player controller input for now so we don't crash<commit_after>/*
 * Copyright (c) 2016 <NAME>
 * All rights reserved.
 *
 * This file provides the implementation for the engine's C interface,
 * specifically tailored for LuaJIT's FFI facilities.
 *
 * General engine stuff
 */

#include "redcrane.hpp"

using namespace redc;

namespace redc
{
  Server::Server()
  {
    bt_config = std::make_unique<btDefaultCollisionConfiguration>();
    bt_dispatcher = std::make_unique<btCollisionDispatcher>(bt_config.get());
    bt_broadphase = std::make_unique<btDbvtBroadphase>();
    bt_solver = std::make_unique<btSequentialImpulseConstraintSolver>();

    bt_world = std::make_unique<btDiscreteDynamicsWorld>(bt_dispatcher.get(),
                                                         bt_broadphase.get(),
                                                         bt_solver.get(),
                                                         bt_config.get());

    bt_world->setGravity(btVector3(0.0f, -9.81f, 0.0f));
  }
}

obj_id redc_server_add_player(void *eng)
{
  auto rce = (Engine*) eng;
  REDC_ASSERT_HAS_SERVER(rce);

  // Add player to list of players, return obj id
  auto id = rce->server->index_gen.get();

  // Add local player controller action interface to player controller.
  rce->server->bt_world->addAction(&rce->server->players[id-1].controller);

  return id;
}

void redc_server_step(void *eng)
{
  auto rce = (Engine*) eng;
  REDC_ASSERT_HAS_SERVER(rce);

  Input input;
  rce->server->players[rce->server->active_player-1].controller.set_input_ref(&input);

  rce->server->bt_world->stepSimulation(time_since(rce->start_time), 10);
}
{'fraction_non_alphanumeric': 0.12034112444725205, 'fraction_numerical': 0.009791535060012634, 'mean_word_length': 2.914709517923362, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '769620', 'n_tokens_mistral': 1006, 'n_tokens_neox': 961, 'n_words': 198}