diff --git a/CMakeLists.txt b/CMakeLists.txt index d743afcd7..6f779719d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ project(cdogs-sdl C) SET(VERSION_MAJOR "0") SET(VERSION_MINOR "6") -SET(VERSION_PATCH "3") +SET(VERSION_PATCH "4") SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") # this must be 4 numbers SET(VERSION_RC "${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},0") diff --git a/src/cdogs/game_events.c b/src/cdogs/game_events.c index 7bb222ebe..0a434d9a8 100644 --- a/src/cdogs/game_events.c +++ b/src/cdogs/game_events.c @@ -2,7 +2,7 @@ C-Dogs SDL A port of the legendary (and fun) action/arcade cdogs. - Copyright (c) 2013-2016, Cong Xu + Copyright (c) 2013-2017, Cong Xu All rights reserved. Redistribution and use in source and binary forms, with or without @@ -72,7 +72,7 @@ static GameEventEntry sGameEventEntries[] = { GAME_EVENT_SET_MESSAGE, false, false, true, true, NULL }, { GAME_EVENT_GAME_START, true, false, true, true, NULL }, - { GAME_EVENT_GAME_BEGIN, true, false, true, true, NULL }, + { GAME_EVENT_GAME_BEGIN, true, false, true, true, NGameBegin_fields }, { GAME_EVENT_ACTOR_ADD, true, false, true, true, NActorAdd_fields }, { GAME_EVENT_ACTOR_MOVE, true, true, true, true, NActorMove_fields }, diff --git a/src/cdogs/game_events.h b/src/cdogs/game_events.h index 41a61d18e..ca6fafb8d 100644 --- a/src/cdogs/game_events.h +++ b/src/cdogs/game_events.h @@ -2,7 +2,7 @@ C-Dogs SDL A port of the legendary (and fun) action/arcade cdogs. - Copyright (c) 2013-2016, Cong Xu + Copyright (c) 2013-2017, Cong Xu All rights reserved. Redistribution and use in source and binary forms, with or without @@ -112,7 +112,9 @@ typedef enum typedef struct { GameEventType Type; + // Whether this message is sent by server to clients bool Broadcast; + // Whether clients send this message to the server bool Submit; // Whether to simply enqueue as game event; otherwise processed by handler bool Enqueue; @@ -143,6 +145,7 @@ typedef struct char Message[256]; int Ticks; } SetMessage; + NGameBegin GameBegin; NActorAdd ActorAdd; NActorMove ActorMove; NActorState ActorState; diff --git a/src/cdogs/handle_game_events.c b/src/cdogs/handle_game_events.c index a67382e72..09d4255ee 100644 --- a/src/cdogs/handle_game_events.c +++ b/src/cdogs/handle_game_events.c @@ -1,7 +1,7 @@ /* C-Dogs SDL A port of the legendary (and fun) action/arcade cdogs. - Copyright (c) 2014-2016, Cong Xu + Copyright (c) 2014-2017, Cong Xu All rights reserved. Redistribution and use in source and binary forms, with or without @@ -179,7 +179,7 @@ static void HandleGameEvent( gMission.HasBegun = false; break; case GAME_EVENT_GAME_BEGIN: - MissionBegin(&gMission); + MissionBegin(&gMission, e.u.GameBegin); break; case GAME_EVENT_ACTOR_ADD: ActorAdd(e.u.ActorAdd); diff --git a/src/cdogs/mission.c b/src/cdogs/mission.c index 984553381..82be29b3e 100644 --- a/src/cdogs/mission.c +++ b/src/cdogs/mission.c @@ -22,7 +22,7 @@ This file incorporates work covered by the following copyright and permission notice: - Copyright (c) 2013-2016, Cong Xu + Copyright (c) 2013-2017, Cong Xu All rights reserved. Redistribution and use in source and binary forms, with or without @@ -363,7 +363,7 @@ bool MissionCanBegin(void) return GetNumPlayers(PLAYER_ALIVE_OR_DYING, false, false) > 0; } -void MissionBegin(struct MissionOptions *m) +void MissionBegin(struct MissionOptions *m, const NGameBegin gb) { m->HasBegun = true; m->state = MISSION_STATE_PLAY; @@ -378,7 +378,7 @@ void MissionBegin(struct MissionOptions *m) e.u.SetMessage.Ticks = FPS_FRAMELIMIT * 2; GameEventsEnqueue(&gGameEvents, e); } - m->time = 0; + m->time = gb.MissionTime; m->pickupTime = 0; } diff --git a/src/cdogs/mission.h b/src/cdogs/mission.h index 39b97b66f..09e3bf65a 100644 --- a/src/cdogs/mission.h +++ b/src/cdogs/mission.h @@ -22,7 +22,7 @@ This file incorporates work covered by the following copyright and permission notice: - Copyright (c) 2013-2016, Cong Xu + Copyright (c) 2013-2017, Cong Xu All rights reserved. Redistribution and use in source and binary forms, with or without @@ -52,6 +52,7 @@ #include "config.h" #include "objective.h" +#include "proto/msg.pb.h" #include "sys_config.h" #define ObjectiveFromTileItem(f) ((((f) & TILEITEM_OBJECTIVE) >> OBJECTIVE_SHIFT)-1) @@ -239,7 +240,7 @@ void UpdateMissionObjective( const struct MissionOptions *options, const int flags, const ObjectiveType type, const int count); bool MissionCanBegin(void); -void MissionBegin(struct MissionOptions *m); +void MissionBegin(struct MissionOptions *m, const NGameBegin gb); bool CanCompleteMission(const struct MissionOptions *options); bool MissionAllObjectivesComplete(const struct MissionOptions *mo); bool IsMissionComplete(const struct MissionOptions *options); diff --git a/src/cdogs/net_server.c b/src/cdogs/net_server.c index 8d7cf7dd3..16d5ed42f 100644 --- a/src/cdogs/net_server.c +++ b/src/cdogs/net_server.c @@ -2,7 +2,7 @@ C-Dogs SDL A port of the legendary (and fun) action/arcade cdogs. - Copyright (c) 2014-2016, Cong Xu + Copyright (c) 2014-2017, Cong Xu All rights reserved. Redistribution and use in source and binary forms, with or without @@ -331,7 +331,9 @@ static void OnReceive(NetServer *n, ENetEvent event) } if (gMission.HasBegun) { - NetServerSendMsg(n, peerId, GAME_EVENT_GAME_BEGIN, NULL); + NGameBegin gb = NGameBegin_init_default; + gb.MissionTime = gMission.time; + NetServerSendMsg(n, peerId, GAME_EVENT_GAME_BEGIN, &gb); } NetServerFlush(n); diff --git a/src/cdogs/pic_manager.c b/src/cdogs/pic_manager.c index a6a98dade..ef41c304f 100644 --- a/src/cdogs/pic_manager.c +++ b/src/cdogs/pic_manager.c @@ -191,8 +191,11 @@ void PicManagerLoadDir( tinydir_dir dir; if (tinydir_open(&dir, path) == -1) { - LOG(LM_MAIN, LL_ERROR, "Error opening image dir '%s': %s", - path, strerror(errno)); + if (errno != ENOENT) + { + LOG(LM_MAIN, LL_ERROR, "Error opening image dir '%s': %s", + path, strerror(errno)); + } goto bail; } diff --git a/src/cdogs/proto/msg.pb.c b/src/cdogs/proto/msg.pb.c index 27e811182..42d18477c 100644 --- a/src/cdogs/proto/msg.pb.c +++ b/src/cdogs/proto/msg.pb.c @@ -1,5 +1,5 @@ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.0 at Thu May 19 11:29:41 2016. */ +/* Generated by nanopb-0.3.0 at Sat Mar 04 22:48:22 2017. */ #include "msg.pb.h" @@ -149,6 +149,11 @@ const pb_field_t NVec2i_fields[3] = { PB_LAST_FIELD }; +const pb_field_t NGameBegin_fields[2] = { + PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, NGameBegin, MissionTime, MissionTime, 0), + PB_LAST_FIELD +}; + const pb_field_t NActorAdd_fields[8] = { PB_FIELD( 1, UINT32 , REQUIRED, STATIC , FIRST, NActorAdd, UID, UID, 0), PB_FIELD( 2, UINT32 , REQUIRED, STATIC , OTHER, NActorAdd, CharId, UID, 0), @@ -388,7 +393,7 @@ const pb_field_t NMissionEnd_fields[4] = { * numbers or field sizes that are larger than what can fit in 8 or 16 bit * field descriptors. */ -PB_STATIC_ASSERT((pb_membersize(NCharColors, Skin) < 65536 && pb_membersize(NCharColors, Arms) < 65536 && pb_membersize(NCharColors, Body) < 65536 && pb_membersize(NCharColors, Legs) < 65536 && pb_membersize(NCharColors, Hair) < 65536 && pb_membersize(NPlayerData, Colors) < 65536 && pb_membersize(NPlayerData, Stats) < 65536 && pb_membersize(NPlayerData, Totals) < 65536 && pb_membersize(NTileSet, Pos) < 65536 && pb_membersize(NMapObjectAdd, Pos) < 65536 && pb_membersize(NSound, Pos) < 65536 && pb_membersize(NActorAdd, FullPos) < 65536 && pb_membersize(NActorMove, Pos) < 65536 && pb_membersize(NActorMove, MoveVel) < 65536 && pb_membersize(NActorSlide, Vel) < 65536 && pb_membersize(NActorImpulse, Vel) < 65536 && pb_membersize(NActorImpulse, Pos) < 65536 && pb_membersize(NActorHit, Vel) < 65536 && pb_membersize(NAddPickup, Pos) < 65536 && pb_membersize(NBulletBounce, BouncePos) < 65536 && pb_membersize(NBulletBounce, BounceVel) < 65536 && pb_membersize(NGunReload, FullPos) < 65536 && pb_membersize(NGunFire, MuzzleFullPos) < 65536 && pb_membersize(NAddBullet, MuzzlePos) < 65536 && pb_membersize(NTrigger, Tile) < 65536 && pb_membersize(NExploreTiles, Runs[0]) < 65536 && pb_membersize(NExploreTiles_Run, Tile) < 65536 && pb_membersize(NAddKeys, Pos) < 65536 && pb_membersize(NMissionComplete, ExitStart) < 65536 && pb_membersize(NMissionComplete, ExitEnd) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_NServerInfo_NClientId_NCampaignDef_NColor_NCharColors_NPlayerStats_NPlayerData_NPlayerRemove_NConfig_NTileSet_NMapObjectAdd_NMapObjectDamage_NMapObjectRemove_NScore_NSound_NVec2i_NActorAdd_NActorMove_NActorState_NActorDir_NActorSlide_NActorImpulse_NActorSwitchGun_NActorPickupAll_NActorReplaceGun_NActorHeal_NActorHit_NActorAddAmmo_NActorUseAmmo_NActorDie_NActorMelee_NAddPickup_NRemovePickup_NBulletBounce_NRemoveBullet_NGunReload_NGunFire_NGunState_NAddBullet_NTrigger_NExploreTiles_NExploreTiles_Run_NRescueCharacter_NObjectiveUpdate_NAddKeys_NMissionComplete_NMissionEnd) +PB_STATIC_ASSERT((pb_membersize(NCharColors, Skin) < 65536 && pb_membersize(NCharColors, Arms) < 65536 && pb_membersize(NCharColors, Body) < 65536 && pb_membersize(NCharColors, Legs) < 65536 && pb_membersize(NCharColors, Hair) < 65536 && pb_membersize(NPlayerData, Colors) < 65536 && pb_membersize(NPlayerData, Stats) < 65536 && pb_membersize(NPlayerData, Totals) < 65536 && pb_membersize(NTileSet, Pos) < 65536 && pb_membersize(NMapObjectAdd, Pos) < 65536 && pb_membersize(NSound, Pos) < 65536 && pb_membersize(NActorAdd, FullPos) < 65536 && pb_membersize(NActorMove, Pos) < 65536 && pb_membersize(NActorMove, MoveVel) < 65536 && pb_membersize(NActorSlide, Vel) < 65536 && pb_membersize(NActorImpulse, Vel) < 65536 && pb_membersize(NActorImpulse, Pos) < 65536 && pb_membersize(NActorHit, Vel) < 65536 && pb_membersize(NAddPickup, Pos) < 65536 && pb_membersize(NBulletBounce, BouncePos) < 65536 && pb_membersize(NBulletBounce, BounceVel) < 65536 && pb_membersize(NGunReload, FullPos) < 65536 && pb_membersize(NGunFire, MuzzleFullPos) < 65536 && pb_membersize(NAddBullet, MuzzlePos) < 65536 && pb_membersize(NTrigger, Tile) < 65536 && pb_membersize(NExploreTiles, Runs[0]) < 65536 && pb_membersize(NExploreTiles_Run, Tile) < 65536 && pb_membersize(NAddKeys, Pos) < 65536 && pb_membersize(NMissionComplete, ExitStart) < 65536 && pb_membersize(NMissionComplete, ExitEnd) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_NServerInfo_NClientId_NCampaignDef_NColor_NCharColors_NPlayerStats_NPlayerData_NPlayerRemove_NConfig_NTileSet_NMapObjectAdd_NMapObjectDamage_NMapObjectRemove_NScore_NSound_NVec2i_NGameBegin_NActorAdd_NActorMove_NActorState_NActorDir_NActorSlide_NActorImpulse_NActorSwitchGun_NActorPickupAll_NActorReplaceGun_NActorHeal_NActorHit_NActorAddAmmo_NActorUseAmmo_NActorDie_NActorMelee_NAddPickup_NRemovePickup_NBulletBounce_NRemoveBullet_NGunReload_NGunFire_NGunState_NAddBullet_NTrigger_NExploreTiles_NExploreTiles_Run_NRescueCharacter_NObjectiveUpdate_NAddKeys_NMissionComplete_NMissionEnd) #endif #if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) diff --git a/src/cdogs/proto/msg.pb.h b/src/cdogs/proto/msg.pb.h index 0c654b496..b6720c9e0 100644 --- a/src/cdogs/proto/msg.pb.h +++ b/src/cdogs/proto/msg.pb.h @@ -1,5 +1,5 @@ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.0 at Thu May 19 11:29:41 2016. */ +/* Generated by nanopb-0.3.0 at Sat Mar 04 22:48:22 2017. */ #ifndef PB_MSG_PB_H_INCLUDED #define PB_MSG_PB_H_INCLUDED @@ -95,6 +95,10 @@ typedef struct _NConfig { char Value[128]; } NConfig; +typedef struct _NGameBegin { + int32_t MissionTime; +} NGameBegin; + typedef struct _NGunState { uint32_t ActorUID; int32_t State; @@ -358,6 +362,7 @@ extern const int32_t NAddBullet_ActorUID_default; #define NScore_init_default {0, 0} #define NSound_init_default {"", NVec2i_init_default, 0} #define NVec2i_init_default {0, 0} +#define NGameBegin_init_default {0} #define NActorAdd_init_default {0, 0, 4, 0, -1, 0, NVec2i_init_default} #define NActorMove_init_default {0, NVec2i_init_default, NVec2i_init_default} #define NActorState_init_default {0, 0} @@ -405,6 +410,7 @@ extern const int32_t NAddBullet_ActorUID_default; #define NScore_init_zero {0, 0} #define NSound_init_zero {"", NVec2i_init_zero, 0} #define NVec2i_init_zero {0, 0} +#define NGameBegin_init_zero {0} #define NActorAdd_init_zero {0, 0, 0, 0, 0, 0, NVec2i_init_zero} #define NActorMove_init_zero {0, NVec2i_init_zero, NVec2i_init_zero} #define NActorState_init_zero {0, 0} @@ -476,6 +482,7 @@ extern const int32_t NAddBullet_ActorUID_default; #define NColor_RGBA_tag 1 #define NConfig_Name_tag 1 #define NConfig_Value_tag 2 +#define NGameBegin_MissionTime_tag 1 #define NGunState_ActorUID_tag 1 #define NGunState_State_tag 2 #define NMapObjectDamage_UID_tag 1 @@ -623,6 +630,7 @@ extern const pb_field_t NMapObjectRemove_fields[5]; extern const pb_field_t NScore_fields[3]; extern const pb_field_t NSound_fields[4]; extern const pb_field_t NVec2i_fields[3]; +extern const pb_field_t NGameBegin_fields[2]; extern const pb_field_t NActorAdd_fields[8]; extern const pb_field_t NActorMove_fields[4]; extern const pb_field_t NActorState_fields[3]; @@ -672,6 +680,7 @@ extern const pb_field_t NMissionEnd_fields[4]; #define NScore_size 17 #define NSound_size 157 #define NVec2i_size 22 +#define NGameBegin_size 11 #define NActorAdd_size 75 #define NActorMove_size 54 #define NActorState_size 17 diff --git a/src/cdogs/proto/msg.proto b/src/cdogs/proto/msg.proto index d1e65a13c..a32bb30c0 100644 --- a/src/cdogs/proto/msg.proto +++ b/src/cdogs/proto/msg.proto @@ -110,6 +110,10 @@ message NVec2i { required int32 y = 2; } +message NGameBegin { + required int32 MissionTime = 1; +} + message NActorAdd { required uint32 UID = 1; required uint32 CharId = 2; diff --git a/src/cdogs/sounds.c b/src/cdogs/sounds.c index ff0481daa..620adebc0 100644 --- a/src/cdogs/sounds.c +++ b/src/cdogs/sounds.c @@ -194,7 +194,11 @@ void SoundLoadDir(map_t sounds, const char *path, const char *prefix) tinydir_dir dir; if (tinydir_open(&dir, path) == -1) { - LOG(LM_MAIN, LL_ERROR, "Cannot open sound dir '%s'", path); + if (errno != ENOENT) + { + LOG(LM_MAIN, LL_ERROR, "Cannot open sound dir '%s': %s", + path, strerror(errno)); + } goto bail; } for (; dir.has_next; tinydir_next(&dir)) diff --git a/src/game.c b/src/game.c index 7e406d0ff..0ab2075bf 100644 --- a/src/game.c +++ b/src/game.c @@ -22,7 +22,7 @@ This file incorporates work covered by the following copyright and permission notice: - Copyright (c) 2013-2016, Cong Xu + Copyright (c) 2013-2017, Cong Xu All rights reserved. Redistribution and use in source and binary forms, with or without @@ -441,6 +441,7 @@ static GameLoopResult RunGameUpdate(void *data) if (!rData->m->HasBegun && MissionCanBegin()) { GameEvent begin = GameEventNew(GAME_EVENT_GAME_BEGIN); + begin.u.GameBegin.MissionTime = gMission.time; GameEventsEnqueue(&gGameEvents, begin); }