<commit_before>/*
 * This software is licensed under the terms of the MIT-License
 * See COPYING for further information. 
 * ---
 * Copyright (C) 2011, <NAME> <<EMAIL>>
 * Copyright (C) 2012, <NAME> <http://akari.thebadasschoobs.org/>
 */

#include <time.h>
#include "savereplay.h"
#include "options.h"
#include "global.h"
#include "replay.h"
#include "plrmodes.h"

void save_rpy(void *a) {
	Replay *rpy = &global.replay;
	char strtime[128], name[128];
	time_t rawtime;
	struct tm * timeinfo;
	
	// time when the game was *initiated*
	rawtime = (time_t)rpy->stages[0].seed;
	timeinfo = localtime(&rawtime);
	strftime(strtime, 128, "%Y%m%d_%H-%M-%S_%Z", timeinfo);
	
	char prepr[16];
	plrmode_repr(prepr, 16, rpy->stages[0].plr_char, rpy->stages[0].plr_shot);
	
	if(rpy->stgcount > 1)
		snprintf(name, 128, "taisei_%s_%s", prepr, strtime);
	else
		snprintf(name, 128, "taisei_stg%d_%s_%s", rpy->stages[0].stage, prepr, strtime);
	
	replay_save(rpy, name);
	((MenuData*)a)->quit = 2;
}

void dont_save_rpy(void *a) {
	((MenuData*)a)->quit = 2;
}

void create_saverpy_menu(MenuData *m) {
	create_menu(m);
	m->type = MT_Persistent;
	m->title = "Save replay?";
	
	add_menu_entry(m, "Yes",	save_rpy,		m);
	add_menu_entry(m, "No",		dont_save_rpy,	m);
}

void draw_saverpy_menu(MenuData *m) {
	draw_options_menu_bg(m);
	
	glPushMatrix();
	glTranslatef(SCREEN_W/2, SCREEN_H/2 - 100, 0);
	draw_text(AL_Center, 0, 0, m->title, _fonts.mainmenu);
	glTranslatef(0, 100, 0);
	
	int i; for(i = 0; i < m->ecount; i++) {
		MenuEntry *e = &(m->entries[i]);
		
		e->drawdata += 0.2 * (10*(i == m->cursor) - e->drawdata);
		float a = e->drawdata * 0.1;
		
		if(e->action == NULL)
			glColor4f(0.5, 0.5, 0.5, 0.5);<commit_msg>fix segfault<commit_after>/*
 * This software is licensed under the terms of the MIT-License
 * See COPYING for further information. 
 * ---
 * Copyright (C) 2011, <NAME> <<EMAIL>>
 * Copyright (C) 2012, <NAME> <http://akari.thebadasschoobs.org/>
 */

#include <time.h>
#include "savereplay.h"
#include "options.h"
#include "global.h"
#include "replay.h"
#include "plrmodes.h"

void save_rpy(void *a) {
	Replay *rpy = &global.replay;
	char strtime[128], name[128];
	time_t rawtime;
	struct tm * timeinfo;
	
	// time when the game was *initiated*
	rawtime = (time_t)rpy->stages[0].seed;
	timeinfo = localtime(&rawtime);
	strftime(strtime, 128, "%Y%m%d_%H-%M-%S_%Z", timeinfo);
	
	char prepr[16];
	plrmode_repr(prepr, 16, rpy->stages[0].plr_char, rpy->stages[0].plr_shot);
	
	if(rpy->stgcount > 1)
		snprintf(name, 128, "taisei_%s_%s", prepr, strtime);
	else
		snprintf(name, 128, "taisei_stg%d_%s_%s", rpy->stages[0].stage, prepr, strtime);
	
	replay_save(rpy, name);
	if(a) ((MenuData*)a)->quit = 2;
}

void dont_save_rpy(void *a) {
	((MenuData*)a)->quit = 2;
}

void create_saverpy_menu(MenuData *m) {
	create_menu(m);
	m->type = MT_Persistent;
	m->title = "Save replay?";
	
	add_menu_entry(m, "Yes",	save_rpy,		m);
	add_menu_entry(m, "No",		dont_save_rpy,	m);
}

void draw_saverpy_menu(MenuData *m) {
	draw_options_menu_bg(m);
	
	glPushMatrix();
	glTranslatef(SCREEN_W/2, SCREEN_H/2 - 100, 0);
	draw_text(AL_Center, 0, 0, m->title, _fonts.mainmenu);
	glTranslatef(0, 100, 0);
	
	int i; for(i = 0; i < m->ecount; i++) {
		MenuEntry *e = &(m->entries[i]);
		
		e->drawdata += 0.2 * (10*(i == m->cursor) - e->drawdata);
		float a = e->drawdata * 0.1;
		
		if(e->action == NULL)
			glColor4f(0.5, 0.5, 0.5, 0.5);
{'fraction_non_alphanumeric': 0.19267935578330894, 'fraction_numerical': 0.036896046852122985, 'mean_word_length': 4.329173166926677, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2720087', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1510, 'n_words': 309}