<commit_before>#include "sectiontable.h"

#include "game.h"

#include <stdlib.h>
#include <stdio.h>

#include <string.h>

#include <assert.h>

void setDefaultPBTimes(struct pb_table_t* pb)
{
    for (int i = 0; i < SECTION_COUNT_LONG; ++i)
    {
        pb->gameTime[i] = 3900 * (i + 1); // 01:05:00 for every section
        pb->goldST[i] = 3900;             // 01:05:00
    }
}

struct pb_table_t* _addPBTable(struct pb_table_t** map, int gameMode)
{
    struct pb_table_t* pb = _getPBTable(map, gameMode);

    if (pb == NULL)
    {
        pb = malloc(sizeof(struct pb_table_t));
        pb->gameMode = gameMode;

        setDefaultPBTimes(pb);

        printf("Adding pb table: %d\n", gameMode);

        HASH_ADD_INT(*map, gameMode, pb);
    }

    return pb;
}

void _deletePBTable(struct pb_table_t** map, int gameMode)
{
    struct pb_table_t* pb = _getPBTable(map, gameMode);

    if (pb != NULL)
    {
        HASH_DEL(*map, pb);
        free(pb);
    }
}

struct pb_table_t* _getPBTable(struct pb_table_t** map, int gameMode)
{
    struct pb_table_t* pb = NULL;

    HASH_FIND_INT(*map, &gameMode, pb); /* pb: output */
    return pb;
}

void section_table_init(struct section_table_t* table)
{
    for (int i = 0; i < SECTION_COUNT; ++i)
    {
        snprintf(table->sections[i].label, 8,
                 "%03d-%03d",
                 i * SECTION_LENGTH,
                 (i + 1) * SECTION_LENGTH - 1);
    }

    table->pbHash = NULL;

    readSectionRecords(table, "GoldST.txt");
    resetSectionTable(table);
}

void section_table_terminate(struct section_table_t* table)
{
    writeSectionRecords(table);
}<commit_msg>Section labels in X00 format instead of X99<commit_after>#include "sectiontable.h"

#include "game.h"

#include <stdlib.h>
#include <stdio.h>

#include <string.h>

#include <assert.h>

void setDefaultPBTimes(struct pb_table_t* pb)
{
    for (int i = 0; i < SECTION_COUNT_LONG; ++i)
    {
        pb->gameTime[i] = 3900 * (i + 1); // 01:05:00 for every section
        pb->goldST[i] = 3900;             // 01:05:00
    }
}

struct pb_table_t* _addPBTable(struct pb_table_t** map, int gameMode)
{
    struct pb_table_t* pb = _getPBTable(map, gameMode);

    if (pb == NULL)
    {
        pb = malloc(sizeof(struct pb_table_t));
        pb->gameMode = gameMode;

        setDefaultPBTimes(pb);

        printf("Adding pb table: %d\n", gameMode);

        HASH_ADD_INT(*map, gameMode, pb);
    }

    return pb;
}

void _deletePBTable(struct pb_table_t** map, int gameMode)
{
    struct pb_table_t* pb = _getPBTable(map, gameMode);

    if (pb != NULL)
    {
        HASH_DEL(*map, pb);
        free(pb);
    }
}

struct pb_table_t* _getPBTable(struct pb_table_t** map, int gameMode)
{
    struct pb_table_t* pb = NULL;

    HASH_FIND_INT(*map, &gameMode, pb); /* pb: output */
    return pb;
}

void section_table_init(struct section_table_t* table)
{
    for (int i = 0; i < SECTION_COUNT_LONG; ++i)
    {
        int begin = i * SECTION_LENGTH;
        int end   = (i + 1) * SECTION_LENGTH;

        if (end > LEVEL_MAX_LONG)
            end = LEVEL_MAX_LONG;

        snprintf(table->sections[i].label, 8,
                 "%03d-%03d", begin, end);
    }

    table->pbHash = NULL;

    readSectionRecords(table, "GoldST.txt");
    resetSectionTable(table);
}

void section_table_terminate(struct section_table_t* table)
{
    writeSectionRecords(table);
}
{'fraction_non_alphanumeric': 0.13557323902151489, 'fraction_numerical': 0.01856763925729443, 'mean_word_length': 2.7052401746724892, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 22, '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': '1259838', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1289, 'n_words': 277}