[Change] Just a few bits of cleanup.

This commit is contained in:
Allanis 2013-05-23 20:13:41 +01:00
parent ad212c78d1
commit 5060e9b7ba
4 changed files with 21 additions and 9 deletions

View File

@ -187,13 +187,13 @@ char* base64_encode(size_t* len, char* src, size_t sz) {
} }
// Decode the buffer, same syntax as base64_encode. // Decode the buffer, same syntax as base64_encode.
inline int dec_valid(char inp) { static inline int dec_valid(char inp) {
if(cd64[(int)inp] == -1) if(cd64[(int)inp] == -1)
return 0; return 0;
return 1; return 1;
} }
inline char dec_ch(char inp) { static inline char dec_ch(char inp) {
return cd64[(int)inp]; return cd64[(int)inp];
} }

View File

@ -422,6 +422,10 @@ MBuf* mbuf_create(int len, int alloc) {
MBuf* buf; MBuf* buf;
buf = malloc(sizeof(MBuf)); buf = malloc(sizeof(MBuf));
if(buf == NULL) {
WARN("Out of memory");
return NULL;
}
buf->data = 0; buf->data = 0;
buf->ndata = buf->mdata = 0; buf->ndata = buf->mdata = 0;
@ -462,6 +466,7 @@ int missions_save(xmlTextWriterPtr writer) {
MBuf* buf; MBuf* buf;
char* data; char* data;
int i, j; int i, j;
size_t sz;
xmlw_startElem(writer, "missions"); xmlw_startElem(writer, "missions");
@ -485,9 +490,9 @@ int missions_save(xmlTextWriterPtr writer) {
buf = mbuf_create(1, 128); buf = mbuf_create(1, 128);
lua_pushvalue(player_missions[i].L, LUA_GLOBALSINDEX); lua_pushvalue(player_missions[i].L, LUA_GLOBALSINDEX);
pluto_persist(player_missions[i].L, mission_writeLua, buf); pluto_persist(player_missions[i].L, mission_writeLua, buf);
data = base64_encode(&j, buf->data, buf->ndata); data = base64_encode(&sz, buf->data, buf->ndata);
mbuf_free(buf); mbuf_free(buf);
xmlw_raw(writer, data, j); xmlw_raw(writer, data, sz);
free(data); free(data);
xmlw_endElem(writer); // Lua. xmlw_endElem(writer); // Lua.

View File

@ -1012,15 +1012,21 @@ void space_render(double dt) {
else if(stars[i].y < -STAR_BUF) stars[i].y = gl_screen.h + STAR_BUF; else if(stars[i].y < -STAR_BUF) stars[i].y = gl_screen.h + STAR_BUF;
// Render. // Render.
if((stars[i].x < SCREEN_W) && (stars[i].x > 0) &&
(stars[i].y < SCREEN_H) && (stars[i].y > 0)) {
glColor4d(1., 1., 1., stars[i].brightness); glColor4d(1., 1., 1., stars[i].brightness);
glVertex2d(stars[i].x, stars[i].y); glVertex2d(stars[i].x, stars[i].y);
} }
}
} else { // Just render. } else { // Just render.
for(i = 0; i < nstars; i++) { for(i = 0; i < nstars; i++) {
if((stars[i].x < SCREEN_W) && (stars[i].x > 0) &&
(stars[i].y < SCREEN_H) && (stars[i].y > 0)) {
glColor4d(1., 1., 1., stars[i].brightness); glColor4d(1., 1., 1., stars[i].brightness);
glVertex2d(stars[i].x, stars[i].y); glVertex2d(stars[i].x, stars[i].y);
} }
} }
}
glEnd(); // GL_POINTS glEnd(); // GL_POINTS
} }
glPopMatrix(); // Translation matrix. glPopMatrix(); // Translation matrix.

View File

@ -1,11 +1,12 @@
#pragma once #pragma once
#include "physics.h" #include "physics.h"
#include "opengl.h"
#define SPFX_LAYER_FRONT 0 #define SPFX_LAYER_FRONT 0
#define SPFX_LAYER_BACK 1 #define SPFX_LAYER_BACK 1
#define SHAKE_DECAY 50. // Decay parameter. #define SHAKE_DECAY 50. // Decay parameter.
#define SHAKE_MAX 50. // Max parameter. #define SHAKE_MAX 50.*SCREEN_W*SCREEN_H/1024./768. // Max parameter.
// Stack manipulation. // Stack manipulation.
int spfx_get(char* name); int spfx_get(char* name);