Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/cxong/cdogs-sdl
Browse files Browse the repository at this point in the history
Hrvt2 committed Dec 5, 2024
2 parents f5e3a33 + 4992b43 commit 228610e
Showing 42 changed files with 970 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ on:
types: [published, created, edited]

env:
VERSION: 2.1.0
VERSION: 2.2.0
CTEST_EXT_COLOR_OUTPUT: TRUE
CTEST_OUTPUT_ON_FAILURE: 1
CTEST_BUILD_FLAGS: -j4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ install_manifest_Runtime.txt
__pycache__/
.cmake/
compile_commands.json
*.build/

# Generated files
src/cdogs/sys_config.h
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13)
project(cdogs-sdl C)

set(VERSION_MAJOR "2")
set(VERSION_MINOR "1")
set(VERSION_MINOR "2")
set(VERSION_PATCH "0")
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

@@ -238,7 +238,7 @@ install(FILES
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
install(FILES ${CMAKE_SOURCE_DIR}/build/linux/io.github.cxong.cdogs-sdl.desktop DESTINATION ${INSTALL_PREFIX}/share/applications)
install(FILES ${CMAKE_SOURCE_DIR}/build/linux/io.github.cxong.cdogs-sdl.appdata.xml DESTINATION ${INSTALL_PREFIX}/share/metainfo)
foreach(RES 16 22 32 48 128)
foreach(RES 16 22 32 48 64 128 256)
install(FILES ${CMAKE_SOURCE_DIR}/build/linux/cdogs-icon.${RES}.png
DESTINATION ${INSTALL_PREFIX}/share/icons/hicolor/${RES}x${RES}/apps
RENAME io.github.cxong.cdogs-sdl.png)
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2.1.0.{build}
version: 2.2.0.{build}

branches:
only:
@@ -19,7 +19,7 @@ environment:
SDL2_IMAGE_VERSION: 2.8.1
SDL2_MIXER_VERSION: 2.6.3
SDLDIR: C:\projects\cdogs-sdl
VERSION: 2.1.0
VERSION: 2.2.0

install:
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
Binary file modified build/linux/cdogs-icon.128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/linux/cdogs-icon.16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/linux/cdogs-icon.22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/linux/cdogs-icon.256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/linux/cdogs-icon.32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build/linux/cdogs-icon.48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/linux/cdogs-icon.64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions build/linux/io.github.cxong.cdogs-sdl.appdata.xml
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@
</screenshot>
</screenshots>
<releases>
<release version="2.2.0" date="2024-12-07"/>
<release version="2.1.0" date="2024-04-12"/>
<release version="2.0.0" date="2024-02-17"/>
<release version="1.5.0" date="2023-07-28"/>
Binary file modified build/macosx/cdogs-icon.icns
Binary file not shown.
Binary file modified build/windows/cdogs-icon.ico
Binary file not shown.
722 changes: 722 additions & 0 deletions data/.wolf3d/N3Ddata.cdogscpn/language.enu

Large diffs are not rendered by default.

Binary file modified graphics/chars/bodies/base/legs_idle_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/chars/bodies/base/legs_run_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/chars/bodies/base/src.blend
Binary file not shown.
Binary file modified graphics/chars/bodies/base/upper_idle_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/chars/bodies/base/upper_idle_dualgun_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/chars/bodies/base/upper_idle_handgun_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/chars/bodies/base/upper_idle_rifle_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/chars/bodies/base/upper_idle_riflefire_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/chars/bodies/base/upper_run_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/chars/bodies/base/upper_run_dualgun_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/chars/bodies/base/upper_run_handgun_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/chars/bodies/base/upper_run_rifle_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/chars/bodies/base/upper_run_riflefire_24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion graphics/chars/bodies/render.py
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@
platform.rotation_euler[axis] = 0
for i in range(0, 8):
# rotate
platform.rotation_euler[axis] = radians(angle) * i
platform.rotation_euler[axis] = radians(angle) * (i + 1)
# set filename so that up is first
render.filepath = path.format(name, (i + 6) % 8)
# render animation
78 changes: 46 additions & 32 deletions src/cdogs/cwolfmap/cwolfmap.c
Original file line number Diff line number Diff line change
@@ -167,38 +167,7 @@ int CWLoad(CWolfMap *map, const char *path, const int spearMission)
CWLevelN3DLoadDescription(languageBuf, i);
}

for (int q = 1;; q++)
{
char *question = CWLevelN3DLoadQuizQuestion(languageBuf, q);
if (question == NULL)
{
break;
}
map->nQuizzes++;
map->quizzes =
realloc(map->quizzes, map->nQuizzes * sizeof(CWN3DQuiz));
CWN3DQuiz *quiz = &map->quizzes[map->nQuizzes - 1];
memset(quiz, 0, sizeof *quiz);
quiz->question = question;
for (char a = 'A';; a++)
{
bool correct = false;
char *answer =
CWLevelN3DLoadQuizAnswer(languageBuf, q, a, &correct);
if (answer == NULL)
{
break;
}
quiz->nAnswers++;
quiz->answers =
realloc(quiz->answers, quiz->nAnswers * sizeof(char *));
quiz->answers[quiz->nAnswers - 1] = answer;
if (correct)
{
quiz->correctIdx = quiz->nAnswers - 1;
}
}
}
CWN3DLoadQuizzes(map, languageBuf);
free(languageBuf);
}

@@ -419,6 +388,7 @@ void CWFree(CWolfMap *map)
{
CWN3DQuizFree(&map->quizzes[i]);
}
free(map->quizzes);
memset(map, 0, sizeof *map);
}
static void LevelFree(CWLevel *level);
@@ -541,6 +511,50 @@ const char *CWGetDescription(CWolfMap *map, const int spearMission)
return NULL;
}

void CWN3DLoadQuizzes(CWolfMap *map, const char *languageBuf)
{
// May be reloading quizzes
for (int i = 0; i < map->nQuizzes; i++)
{
CWN3DQuizFree(&map->quizzes[i]);
}
free(map->quizzes);
map->quizzes = NULL;
map->nQuizzes = 0;
for (int q = 1;; q++)
{
char *question = CWLevelN3DLoadQuizQuestion(languageBuf, q);
if (question == NULL)
{
break;
}
map->nQuizzes++;
map->quizzes =
realloc(map->quizzes, map->nQuizzes * sizeof(CWN3DQuiz));
CWN3DQuiz *quiz = &map->quizzes[map->nQuizzes - 1];
memset(quiz, 0, sizeof *quiz);
quiz->question = question;
for (char a = 'A';; a++)
{
bool correct = false;
char *answer =
CWLevelN3DLoadQuizAnswer(languageBuf, q, a, &correct);
if (answer == NULL)
{
break;
}
quiz->nAnswers++;
quiz->answers =
realloc(quiz->answers, quiz->nAnswers * sizeof(char *));
quiz->answers[quiz->nAnswers - 1] = answer;
if (correct)
{
quiz->correctIdx = quiz->nAnswers - 1;
}
}
}
}

int CWGetAudioSampleRate(const CWolfMap *map)
{
switch (map->type)
2 changes: 2 additions & 0 deletions src/cdogs/cwolfmap/cwolfmap.h
Original file line number Diff line number Diff line change
@@ -62,6 +62,8 @@ void CWFree(CWolfMap *map);

const char *CWGetDescription(CWolfMap *map, const int spearMission);

void CWN3DLoadQuizzes(CWolfMap *map, const char *languageBuf);

int CWGetAudioSampleRate(const CWolfMap *map);

typedef enum
2 changes: 1 addition & 1 deletion src/cdogs/cwolfmap/n3d.h
Original file line number Diff line number Diff line change
@@ -16,4 +16,4 @@ char *CWLevelN3DLoadQuizQuestion(const char *buf, const int quiz);
char *CWLevelN3DLoadQuizAnswer(
const char *buf, const int quiz, const char answer, bool *correct);

void CWN3DQuizFree(CWN3DQuiz *quiz);
void CWN3DQuizFree(CWN3DQuiz *quiz);
15 changes: 7 additions & 8 deletions src/cdogs/emitter.c
Original file line number Diff line number Diff line change
@@ -29,12 +29,10 @@ POSSIBILITY OF SUCH DAMAGE.

#include "game_events.h"


void EmitterInit(
Emitter *em, const ParticleClass *p, const struct vec2 offset,
const float minSpeed, const float maxSpeed,
const int minDZ, const int maxDZ,
const double minRotation, const double maxRotation,
const float minSpeed, const float maxSpeed, const int minDZ,
const int maxDZ, const double minRotation, const double maxRotation,
const int ticksPerEmit)
{
memset(em, 0, sizeof *em);
@@ -62,18 +60,19 @@ void EmitterStart(Emitter *em, const AddParticle *data)
e.u.AddParticle.Class = em->p;
}
const float speed = RAND_FLOAT(em->minSpeed, em->maxSpeed);
const struct vec2 baseVel = svec2_rotate(
svec2(0, speed), RAND_FLOAT(0, MPI * 2));
const struct vec2 baseVel =
svec2_rotate(svec2(0, speed), RAND_FLOAT(0, MPI * 2));
e.u.AddParticle.Vel = svec2_add(data->Vel, baseVel);
if (isnan(data->Angle))
{
e.u.AddParticle.Angle = RAND_FLOAT(0, MPI * 2);
}
e.u.AddParticle.DZ = RAND_FLOAT(em->minDZ, em->maxDZ);
e.u.AddParticle.Spin = RAND_DOUBLE(em->minRotation, em->maxRotation);
if (strlen(e.u.AddParticle.Text) == 0 && em->p->Type == PARTICLE_TEXT)
if (strlen(e.u.AddParticle.Text) == 0 &&
e.u.AddParticle.Class->Type == PARTICLE_TEXT)
{
strcpy(e.u.AddParticle.Text, em->p->u.Text.Value);
strcpy(e.u.AddParticle.Text, e.u.AddParticle.Class->u.Text.Value);
}
GameEventsEnqueue(&gGameEvents, e);
}
49 changes: 1 addition & 48 deletions src/cdogs/map_archive.c
Original file line number Diff line number Diff line change
@@ -38,8 +38,6 @@
#include "pickup.h"
#include "player_template.h"

static char *ReadFileIntoBuf(const char *path, const char *mode, long *len);

static json_t *ReadArchiveJSON(const char *archive, const char *filename);
int MapNewScanArchive(const char *filename, char **title, int *numMissions)
{
@@ -198,8 +196,7 @@ static json_t *ReadArchiveJSON(const char *archive, const char *filename)
json_t *root = NULL;
char path[CDOGS_PATH_MAX];
sprintf(path, "%s/%s", archive, filename);
long len;
char *buf = ReadFileIntoBuf(path, "rb", &len);
char *buf = ReadFileIntoBuf(path, "rb");
if (buf == NULL)
goto bail;
const enum json_error e = json_parse_document(&root, buf);
@@ -233,50 +230,6 @@ static void LoadArchivePics(PicManager *pm, map_t cc, const char *archive)
CharSpriteClassesLoadDir(cc, archive);
}

static char *ReadFileIntoBuf(const char *path, const char *mode, long *len)
{
char *buf = NULL;
FILE *f = fopen(path, mode);
if (f == NULL)
{
goto bail;
}

// Read into buffer
if (fseek(f, 0L, SEEK_END) != 0)
{
goto bail;
}
*len = ftell(f);
if (*len == -1)
{
goto bail;
}
CCALLOC(buf, *len + 1);
if (fseek(f, 0L, SEEK_SET) != 0)
{
goto bail;
}
if (fread(buf, 1, *len, f) == 0)
{
goto bail;
}

goto end;

bail:
CFREE(buf);
buf = NULL;

end:
if (f != NULL && fclose(f) != 0)
{
LOG(LM_MAP, LL_ERROR, "Cannot close file %s: %s", path,
strerror(errno));
}
return buf;
}

static json_t *SaveMissions(CArray *a);
int MapArchiveSave(const char *filename, CampaignSetting *c)
{
107 changes: 97 additions & 10 deletions src/cdogs/map_wolf.c
Original file line number Diff line number Diff line change
@@ -891,17 +891,16 @@ static void LoadSounds(const SoundDevice *s, const CWolfMap *map)
while (name != NULL)
{
Mix_Chunk *data = LoadSoundData(map, i);
if (data == NULL)
if (data != NULL)
{
continue;
}
if (name[strlen(name) - 1] == '/')
{
AddRandomSound(s, name, data);
}
else
{
AddNormalSound(s, name, data);
if (name[strlen(name) - 1] == '/')
{
AddRandomSound(s, name, data);
}
else
{
AddNormalSound(s, name, data);
}
}
name = strtok(NULL, "|");
}
@@ -3541,3 +3540,91 @@ static bool TryLoadCampaign(CampaignList *list, const char *path)
}
return false;
}

void MapWolfN3DCheckAndLoadCustomQuiz(
const char *title, const CArray *playerDatas)
{
// Special case for N3D: Epic of Gilgamesh quiz easter egg
// This code is pretty cursed
if (strcmp(title, "Super 2D Noah's Ark") != 0)
{
return;
}
bool hasGilgameshName = false;
CA_FOREACH(const PlayerData, p, *playerDatas)
if (Stricmp(p->name, "Gilgamesh") == 0 ||
Stricmp(p->name, "Enkidu") == 0 ||
Stricmp(p->name, "Utnapishtim") == 0 ||
Stricmp(p->name, "Ziusudra") == 0 ||
Stricmp(p->name, "Atra-Hasis") == 0 ||
Stricmp(p->name, "Atrahasis") == 0)
{
hasGilgameshName = true;
break;
}
CA_FOREACH_END()
if (!hasGilgameshName)
{
return;
}

// Load new quizzes
char pathBuf[CDOGS_PATH_MAX];
GetDataFilePath(pathBuf, WOLF_DATA_DIR "N3Ddata.cdogscpn/language.enu");
char *languageBuf = ReadFileIntoBuf(pathBuf, "r");
CWolfMap map;
memset(&map, 0, sizeof map);
CWN3DLoadQuizzes(&map, languageBuf);
free(languageBuf);

// Copy the effects from the "scroll" pickup
const PickupClass *scroll = StrPickupClass("scroll");
const PickupEffect *menuEffect = CArrayGet(&scroll->Effects, 0);
const CArray *correctEffects =
&((const PickupMenuItem *)CArrayGet(&menuEffect->u.Menu.Items, 0))
->Effects;
const CArray *wrongEffects =
&((const PickupMenuItem *)CArrayGet(&menuEffect->u.Menu.Items, 1))
->Effects;

// Replace the scroll pickups with the quizzes
for (int i = 0;; i++)
{
char buf[256];
sprintf(buf, "scroll+%d", i);
PickupClass *c = StrPickupClass(buf);
if (c == NULL)
{
break;
}
CA_FOREACH(PickupEffect, e, c->Effects)
PickupEffectTerminate(e);
CA_FOREACH_END()
CArrayClear(&c->Effects);

PickupEffect e;
memset(&e, 0, sizeof e);
e.Type = PICKUP_MENU;
const CWN3DQuiz *quiz = &map.quizzes[i];
CSTRDUP(e.u.Menu.Text, quiz->question);

CArrayInit(&e.u.Menu.Items, sizeof(PickupMenuItem));
for (int j = 0; j < quiz->nAnswers; j++)
{
PickupMenuItem m;
PickupMenuItemInit(&m);
CSTRDUP(m.Text, quiz->answers[j]);
const CArray *effects =
j == quiz->correctIdx ? correctEffects : wrongEffects;
CA_FOREACH(const PickupEffect, pe, *effects)
PickupEffect ec = PickupEffectCopy(pe);
CArrayPushBack(&m.Effects, &ec);
CA_FOREACH_END()
CArrayPushBack(&e.u.Menu.Items, &m);
}

CArrayPushBack(&c->Effects, &e);
}

CWFree(&map);
}
5 changes: 4 additions & 1 deletion src/cdogs/map_wolf.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
C-Dogs SDL
A port of the legendary (and fun) action/arcade cdogs.
Copyright (c) 2020-2021 Cong Xu
Copyright (c) 2020-2021, 2024 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -40,3 +40,6 @@ int MapWolfLoad(
const char *filename, const int spearMission, CampaignSetting *c);

void MapWolfLoadCampaignsFromSystem(CampaignList *list);

void MapWolfN3DCheckAndLoadCustomQuiz(
const char *title, const CArray *playerDatas);
3 changes: 1 addition & 2 deletions src/cdogs/pickup_class.c
Original file line number Diff line number Diff line change
@@ -200,15 +200,14 @@ PickupEffect PickupEffectCopy(const PickupEffect *e)
}
return out;
}
static void PickupEffectTerminate(PickupEffect *e);
static void PickupMenuItemTerminate(PickupMenuItem *m)
{
CFREE(m->Text);
CA_FOREACH(PickupEffect, e, m->Effects)
PickupEffectTerminate(e);
CA_FOREACH_END()
}
static void PickupEffectTerminate(PickupEffect *e)
void PickupEffectTerminate(PickupEffect *e)
{
switch (e->Type)
{
2 changes: 2 additions & 0 deletions src/cdogs/pickup_class.h
Original file line number Diff line number Diff line change
@@ -111,6 +111,8 @@ void PickupMenuItemInit(PickupMenuItem *m);
PickupEffect PickupEffectCopy(const PickupEffect *e);
void PickupClassInit(PickupClass *c);

void PickupEffectTerminate(PickupEffect *e);

void PickupClassesInit(
PickupClasses *classes, const char *filename, const AmmoClasses *ammo,
const WeaponClasses *guns);
47 changes: 46 additions & 1 deletion src/cdogs/utils.c
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
This file incorporates work covered by the following copyright and
permission notice:
Copyright (c) 2013-2017, 2019-2022 Cong Xu
Copyright (c) 2013-2017, 2019-2022, 2024 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -62,6 +62,7 @@

#include "events.h"
#include "joystick.h"
#include "log.h"
#include "sys_config.h"

bool gTrue = true;
@@ -637,3 +638,47 @@ int Pulse256(const int t)
}
return alphaUnscaled;
}

char *ReadFileIntoBuf(const char *path, const char *mode)
{
char *buf = NULL;
FILE *f = fopen(path, mode);
if (f == NULL)
{
goto bail;
}

// Read into buffer
if (fseek(f, 0L, SEEK_END) != 0)
{
goto bail;
}
long len = ftell(f);
if (len == -1)
{
goto bail;
}
CCALLOC(buf, len + 1);
if (fseek(f, 0L, SEEK_SET) != 0)
{
goto bail;
}
if (fread(buf, 1, len, f) == 0)
{
goto bail;
}

goto end;

bail:
CFREE(buf);
buf = NULL;

end:
if (f != NULL && fclose(f) != 0)
{
LOG(LM_MAIN, LL_ERROR, "Cannot close file %s: %s", path,
strerror(errno));
}
return buf;
}
4 changes: 3 additions & 1 deletion src/cdogs/utils.h
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
This file incorporates work covered by the following copyright and
permission notice:
Copyright (c) 2013-2017, 2019-2023 Cong Xu
Copyright (c) 2013-2017, 2019-2024 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -249,3 +249,5 @@ typedef enum
} PlacementAccessFlags;

int Pulse256(const int t);

char *ReadFileIntoBuf(const char *path, const char *mode);
28 changes: 18 additions & 10 deletions src/game.c
Original file line number Diff line number Diff line change
@@ -352,16 +352,7 @@ static void RunGameInput(GameLoopData *data)
// or the last frame
data->SkipNextFrame = data->SuperhotMode && !lastCmdAll;

// Don't show map if pause menu is shown
if (PauseMenuIsShown(&rData->pm))
{
rData->isMap = false;
// Clear all user inputs if we're using the pause menu
memset(rData->cmds, 0, sizeof rData->cmds);
memset(rData->lastCmds, 0, sizeof rData->lastCmds);
KeyLockKeys(&gEventHandlers.keyboard);
JoyLock(&gEventHandlers.joysticks);
}
const bool wasPaused = PauseMenuIsShown(&rData->pm);

// Update and check if we want to quit
if (PauseMenuUpdate(&rData->pm, rData->cmds, rData->lastCmds))
@@ -385,6 +376,23 @@ static void RunGameInput(GameLoopData *data)
&gSoundDevice,
StrSound(rData->isMap ? "map_open" : "map_close"));
}
if (wasPaused)
{
// Clear all user inputs if we're using the pause menu
memset(rData->cmds, 0, sizeof rData->cmds);
memset(rData->lastCmds, 0, sizeof rData->lastCmds);
KeyLockKeys(&gEventHandlers.keyboard);
JoyLock(&gEventHandlers.joysticks);
}
}

if (!wasPaused && PauseMenuIsShown(&rData->pm))
{
// Don't show map if pause menu is shown
rData->isMap = false;
// Clear all user inputs if we're using the pause menu
memset(rData->cmds, 0, sizeof rData->cmds);
memset(rData->lastCmds, 0, sizeof rData->lastCmds);
}

CameraInput(&rData->Camera, rData->cmds[0], rData->lastCmds[0]);
19 changes: 12 additions & 7 deletions src/prep.c
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@
#include <cdogs/joystick.h>
#include <cdogs/keyboard.h>
#include <cdogs/log.h>
#include <cdogs/map_wolf.h>
#include <cdogs/music.h>
#include <cdogs/net_client.h>
#include <cdogs/net_server.h>
@@ -363,6 +364,8 @@ static void PlayerSelectionOnExit(GameLoopData *data)
{
gCampaign.MissionIndex = 0;
}
MapWolfN3DCheckAndLoadCustomQuiz(
gCampaign.Setting.Title, &gPlayerDatas);
}
else
{
@@ -391,13 +394,13 @@ static GameLoopResult PlayerSelectionUpdate(GameLoopData *data, LoopRunner *l)
LoopRunnerPop(l);
return UPDATE_RESULT_OK;
}

int idx = 0;
if (pData->endCounter == 0)
{
// Menu input
const int localHumanPlayers = GetNumPlayers(PLAYER_ANY, true, true);
const bool useMenuCmd = (localHumanPlayers <= 1);
const int localHumanPlayers = GetNumPlayers(PLAYER_ANY, true, true);
const bool useMenuCmd = (localHumanPlayers <= 1);
for (int i = 0; i < (int)gPlayerDatas.size; i++, idx++)
{
const PlayerData *p = CArrayGet(&gPlayerDatas, i);
@@ -412,13 +415,13 @@ static GameLoopResult PlayerSelectionUpdate(GameLoopData *data, LoopRunner *l)
if (ms->current->customPostUpdateFunc)
{
ms->current->customPostUpdateFunc(
ms->current, ms->current->customPostUpdateData);
ms->current, ms->current->customPostUpdateData);
}
MenuUpdateMouse(ms);
if (useMenuCmd)
{
cmds[idx] |=
GetMenuCmd(&gEventHandlers, ms->current->mouseHover);
GetMenuCmd(&gEventHandlers, ms->current->mouseHover);
}
if (!MenuIsExit(ms) && cmds[idx])
{
@@ -465,11 +468,13 @@ static GameLoopResult PlayerSelectionUpdate(GameLoopData *data, LoopRunner *l)
idx--;
continue;
}
if (p->inputDevice == INPUT_DEVICE_UNSET || p->inputDevice == INPUT_DEVICE_AI)
if (p->inputDevice == INPUT_DEVICE_UNSET ||
p->inputDevice == INPUT_DEVICE_AI)
{
hasAIPlayers = true;
PlayerTrySetInputDevice(p, INPUT_DEVICE_AI, 0);
pData->menus[idx].ms.current = MenuGetSubmenuByName(pData->menus[idx].ms.root, "Done");
pData->menus[idx].ms.current =
MenuGetSubmenuByName(pData->menus[idx].ms.root, "Done");
}
}
if (hasAIPlayers && pData->endCounter < 70)

0 comments on commit 228610e

Please sign in to comment.