[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.
inline int dec_valid(char inp) {
static inline int dec_valid(char inp) {
if(cd64[(int)inp] == -1)
return 0;
return 1;
}
inline char dec_ch(char inp) {
static inline char dec_ch(char inp) {
return cd64[(int)inp];
}

View File

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

View File

@ -1012,13 +1012,19 @@ void space_render(double dt) {
else if(stars[i].y < -STAR_BUF) stars[i].y = gl_screen.h + STAR_BUF;
// Render.
glColor4d(1., 1., 1., stars[i].brightness);
glVertex2d(stars[i].x, stars[i].y);
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);
glVertex2d(stars[i].x, stars[i].y);
}
}
} else { // Just render.
for(i = 0; i < nstars; i++) {
glColor4d(1., 1., 1., stars[i].brightness);
glVertex2d(stars[i].x, stars[i].y);
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);
glVertex2d(stars[i].x, stars[i].y);
}
}
}
glEnd(); // GL_POINTS

View File

@ -1,11 +1,12 @@
#pragma once
#include "physics.h"
#include "opengl.h"
#define SPFX_LAYER_FRONT 0
#define SPFX_LAYER_BACK 1
#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.
int spfx_get(char* name);