]> git.sesse.net Git - nageru/blob - futatabi/util.cpp
Log a warning when we kill a client that is not keeping up.
[nageru] / futatabi / util.cpp
1 #include "util.h"
2
3 #include <assert.h>
4 #include <memory>
5 #include <stdio.h>
6
7 using namespace std;
8
9 Flow read_flow(const char *filename)
10 {
11         FILE *flowfp = fopen(filename, "rb");
12         uint32_t hdr, width, height;
13         fread(&hdr, sizeof(hdr), 1, flowfp);
14         fread(&width, sizeof(width), 1, flowfp);
15         fread(&height, sizeof(height), 1, flowfp);
16
17         unique_ptr<Vec2[]> flow(new Vec2[width * height]);
18         fread(flow.get(), width * height * sizeof(Vec2), 1, flowfp);
19         fclose(flowfp);
20
21         Flow ret;
22         ret.width = width;
23         ret.height = height;
24         ret.flow = move(flow);
25         return ret;
26 }