Skip to content

Instantly share code, notes, and snippets.

#include "space.h"
#include "shapes.h"
void Space::add_object(const Object& obj)
{
objects.push_back(obj);
shapes.push_back(std::unique_ptr<Shape>(obj.shape));
}
void Space::update(float dt)
@bqqbarbhg
bqqbarbhg / client.cpp
Last active December 19, 2015 13:29 — forked from anonymous/client.cpp
PacketPool outPool;
void client(Address addr)
{
Connection conn;
// Request a connection
ConnectionRequest request(0xDEADBEEF, 2000);
ConnectionRequest::Status status;
while ((status = request.status()) == ConnectionRequest::WAITING) {

Header

  • 4 Magic (ignore packets with wrong magic)
  • 4 Sequence
  • 4 Ack sequence
  • 4 Ack bitfield

For every message

  • 2 Channel ID

Packet fill algorithm

P := largest packet
while (true)
  while (P overflows)
    send part
  append P
  while (exists packets that won't overflow)
    append largest of them

if (exists packets that would be less fragmented if started here)

P = send_reliable.begin();
while (!send_reliable.empty()) {
unsigned int fragc = fragment_count(writer.write_amount(), P->packet.size());
unsigned int start = 0;
for (unsigned int i = 0; i < fragc - 1; i++) {
start += add_packet(writer, P->chan, P->packet, start, fragc);
send_packet(writer);
}
add_packet(writer, P->chan, P->packet, start, fragc);
send_reliable.erase(P);
#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#include <stdio.h>
#include <string.h>
typedef unsigned char uchar;
#define JMPSTACK_SIZE 1024
#define ADDRBUF_SIZE 1024
@bqqbarbhg
bqqbarbhg / gist:6188188
Last active December 20, 2015 20:08
error C2248: 'std::unique_ptr<_Ty>::unique_ptr' : cannot access private member declared in class 'std::unique_ptr<_Ty>'
class AstNode
{
public:
};
typedef std::unique_ptr<AstNode> AstPtr;
typedef std::vector<AstPtr> AstList;
class AstFuncImpl : public AstNode
{
#include <msp430.h>
#include <stdio.h>
int main(void)
{
printf("Hello World\n");
return 0;
}
int putchar(int c)
var $http = require('http');
var $url = require('url');
var $fs = require('fs');
var tick = 0;
var dwarves = [];
function rand(min, max)
{
#include "textrender.h"
#include <GL/glew.h>
#include <GL/glfw.h>
#include "glm/gtc/type_ptr.hpp"
int* font;
using namespace glm;