Skip to content

Commit

Permalink
Cleanup some _NO_TMS-related stuff for utils
Browse files Browse the repository at this point in the history
  • Loading branch information
rollerozxa committed Mar 5, 2024
1 parent 160c031 commit 99739bf
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 44 deletions.
6 changes: 3 additions & 3 deletions src/src/crc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
#include <stdio.h>
#include <unistd.h>

#ifdef _NO_TMS
#include "no_tms.h"
#else
#ifndef _NO_TMS
#include "tms/backend/print.h"
#endif

Expand Down Expand Up @@ -36,9 +34,11 @@ crc32_uint32(uint32_t crc, uint32_t data)
uint32_t
crc32_level(const lvlinfo &lvl, const lvlbuf &lb, uint32_t timestamp, uint32_t last_score, int method)
{
#ifndef _NO_TMS
tms_assertf(method < 5, "only 5 methods of crc32_level are implemented.");

tms_infof("Using lastscore %" PRIu32 "in crc32_level.", last_score);
#endif

unsigned char crc_buf[CRC_BUFFER_SIZE];
size_t crc_buf_len;
Expand Down
6 changes: 0 additions & 6 deletions src/src/local_config.h.example

This file was deleted.

30 changes: 0 additions & 30 deletions src/src/no_tms.h

This file was deleted.

17 changes: 13 additions & 4 deletions src/src/pkgman.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@
#include "rand.h"

/* for lvledit command line tool */
#ifndef _NO_TMS
#include <tms/bindings/cpp/cpp.hh>
#ifdef _NO_TMS
#include <stdlib.h>
#include <stdio.h>

#define tms_infof(...)
#define tms_warnf(...)
#define tms_fatalf(...)
#define tms_errorf(...)

static const char *tbackend_get_storage_path() {
return "/tmp/";
}
#else
#include "no_tms.h"
#include <tms/bindings/cpp/cpp.hh>
#endif

static const char *_level_path[4];
Expand Down Expand Up @@ -480,7 +490,6 @@ lvlinfo::read(lvlbuf *lb, bool skip_description)

if (this->version >= LEVEL_VERSION_1_5) {
this->seed = lb->r_uint64();
tms_debugf("read seed: %" PRIu64, this->seed);
this->adventure_id = lb->r_uint32();
this->linear_damping = lb->r_float();
this->angular_damping = lb->r_float();
Expand Down
10 changes: 9 additions & 1 deletion src/src/progress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include <cstdlib>

#ifdef _NO_TMS
#include "no_tms.h"
#define tms_infof(...)
#define tms_errorf(...)
#else
#include <tms/bindings/cpp/cpp.hh>
#endif
Expand Down Expand Up @@ -49,8 +50,12 @@ progress::init(char *custom_path/*=0*/)
if (custom_path) {
strcpy(tmp, custom_path);
} else {
#ifdef _NO_TMS
return;
#else
const char *storage = tbackend_get_storage_path();
snprintf(tmp, 1023, "%s/data.bin", storage);
#endif
}

long crc_pos[4]={0,0,0,0};
Expand Down Expand Up @@ -218,6 +223,8 @@ progress::init(char *custom_path/*=0*/)
void
progress::commit()
{
#ifndef _NO_TMS

if (!initialized) {
return;
}
Expand Down Expand Up @@ -340,4 +347,5 @@ progress::commit()
} else {
tms_errorf("Error: could not save progress %s", filename);
}
#endif
}

0 comments on commit 99739bf

Please sign in to comment.