ChrisOS Research ProjectOperating systems · language systems · graphics · machine emulation
DOCUMENTATION ARCHIVEMAIN BRANCH
ChrisOS/Referência de fonte: GAMES/MINE/SAVE.CC

Referência de fonte: GAMES/MINE/SAVE.CC

Registro determinístico da fonte. O conteúdo completo do arquivo é reproduzido abaixo; esta página não substitui a interpretação arquitetural dos capítulos autorais.

Identidade do arquivo

Campo Valor
Path GAMES/MINE/SAVE.CC
Lines 94
Bytes 1803
SHA-256 8a0f8e140c7717fb9e3c43a9a150dd342618745ab20f884143e1998f9fd4c04c
ChrisOS revision da3df29cb397932c43d32373871fb9380e688ade

Dependências sintáticas detectadas

Linha Include
— Nenhum include de preprocessor detectado.

Símbolos detectados

Linha Símbolo
1 snap_store
11 snap_load
26 note
31 save_pack
49 save_write
62 save_read
90 respawn

Fonte completa

O bloco seguinte é o arquivo textual integral na revisão indicada. Não há elisão, abreviação ou paráfrase.

void snap_store() {
    g_snap.x = g_act[0].x;
    g_snap.y = g_act[0].y;
    g_snap.z = g_act[0].z;
    g_snap.yaw = g_act[0].yaw;
    g_snap.pitch = g_act[0].pitch;
    g_snap.kind = g_act[0].kind;
    g_snap.bits = g_act[0].bits;
}

void snap_load() {
    struct Actor back;
    back = g_snap;
    g_act[0].x = back.x;
    g_act[0].y = back.y;
    g_act[0].z = back.z;
    g_act[0].yaw = back.yaw;
    g_act[0].pitch = back.pitch;
    g_act[0].vx = 0.0;
    g_act[0].vy = 0.0;
    g_act[0].vz = 0.0;
    g_act[0].kind = back.kind;
    g_act[0].bits = back.bits;
}

void note(int c) {
    g_note = c;
    g_toast = 50;
}

void save_pack() {
    int i;
    g_sav[0] = 77;
    g_sav[1] = g_phase;
    g_sav[2] = (int)g_act[0].x;
    g_sav[3] = (int)g_act[0].y;
    g_sav[4] = (int)g_act[0].z;
    g_sav[5] = (int)g_act[0].yaw;
    g_sav[6] = g_wood;
    g_sav[7] = g_pearl;
    g_sav[8] = g_arrows;
    i = 0;
    while (i < 16) {
        g_sav[10 + i] = g_inv[i];
        i = i + 1;
    }
}

int save_write() {
    int fd;
    save_pack();
    snap_store();
    fd = fopen("MINE.SAV");
    if (fd < 0)
        return 0;
    fwrite(fd, g_sav, 40);
    fclose(fd);
    note(1);
    return 1;
}

int save_read() {
    int fd;
    int i;
    fd = fopen("MINE.SAV");
    if (fd < 0)
        return 0;
    fread(fd, g_sav, 40);
    fclose(fd);
    if (g_sav[0] != 77)
        return 0;
    g_phase = g_sav[1];
    g_act[0].x = (float)g_sav[2];
    g_act[0].y = (float)g_sav[3];
    g_act[0].z = (float)g_sav[4];
    g_act[0].yaw = (float)g_sav[5];
    g_wood = g_sav[6];
    g_pearl = g_sav[7];
    g_arrows = g_sav[8];
    i = 0;
    while (i < 16) {
        g_inv[i] = g_sav[10 + i];
        i = i + 1;
    }
    snap_store();
    note(2);
    return 1;
}

void respawn() {
    snap_load();
    note(3);
}

Papel deste registro

O atlas garante rastreabilidade arquivo-a-arquivo. Responsabilidade, invariantes, ownership, concorrência, segurança, desempenho e interação entre subsistemas pertencem aos capítulos autorais e devem citar este arquivo quando aplicável.

Registro do documento ID: source-8a0f8e140c7717fb Reviewed source: da3df29cb397 Class: generated-source-reference