Skip to content

Commit

Permalink
Add sounds (#1179)
Browse files Browse the repository at this point in the history
* add new sounds for Prefecture, Engineer post, ConcreteMaker

* add sounds for plaza and roadblock

* add ambient sound "Rives"
  • Loading branch information
eugenikus8 authored Feb 3, 2025
1 parent 082d1f4 commit 52b15f9
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/sound/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum {

// city sounds (from buildings)
SOUND_CHANNEL_CITY_MIN = 48,
SOUND_CHANNEL_CITY_MAX = 155,
SOUND_CHANNEL_CITY_MAX = 158,

SOUND_CHANNEL_MAX = SOUND_CHANNEL_CITY_MAX + 1
};
Expand Down
16 changes: 9 additions & 7 deletions src/sound/city.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <string.h>

#define MAX_CHANNELS 80
#define MAX_CHANNELS 100

// for compatibility with the original game:
#define CITY_CHANNEL_OFFSET 18
Expand Down Expand Up @@ -93,7 +93,8 @@ enum {
SOUND_CHANNEL_CITY_BRICKWORKS = 135,
SOUND_CHANNEL_CITY_LIGHTHOUSE = 136,
SOUND_CHANNEL_CITY_DEPOT = 137,
SOUND_CHANNEL_CITY_CONSTRUCTION_SITE = 138,
SOUND_CHANNEL_CITY_CONCRETE_MAKER = 138,
SOUND_CHANNEL_CITY_CONSTRUCTION_SITE = 139,
};

typedef struct {
Expand All @@ -110,8 +111,8 @@ typedef struct {
} city_channel;

static city_channel channels[MAX_CHANNELS];
static int ambient_channels[] = { 61, 74, 75, }; // turn on "empty land" sound
static int ambient_channels_number = 3;
static int ambient_channels[] = { 61, 74, 75, 62}; // turn on "empty land" and river sound
static int ambient_channels_number = 4;

static const int BUILDING_TYPE_TO_CHANNEL_ID[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0-9
Expand All @@ -132,7 +133,7 @@ static const int BUILDING_TYPE_TO_CHANNEL_ID[] = {
0, 0, 44, 37, 68, 69, 0, 0, 66, 0, //150-159 MESS_HALL = 154[68], LIGHTHOUSE = 155[69], TAVERN = 158[66]
9, 0, 0, 0, 0, 0, 0, 0, 0, 0, //160-169
44, 44, 44, 71, 0, 0, 67, 0, 0, 0, //170-179 WATCHTOWER = 173[71], CARAVANSERAI = 176[67]
0, 0, 0, 0, 53, 72, 73, 55, 52, 0, //180-189 CITY_MINT = 185[72], DEPOT = 186[73]
0, 0, 0, 0, 53, 72, 73, 55, 52, 78, //180-189 CITY_MINT = 185[72], DEPOT = 186[73], CONCRETE_MAKER = 189[78]
77, 0, 0, 0, 0, 0, 0, 0, 0, 0, //190-199 BRICKWORKS = 190[77]
0, 0, 0, 65, 0, 0, 0, 0, 0, 0, //200-209
};
Expand Down Expand Up @@ -228,6 +229,7 @@ void sound_city_init(void)
channels[75].channel = SOUND_CHANNEL_CITY_EMPTY_LAND3;
//channels[76].channel = SOUND_CHANNEL_CITY_EMPTY_LAND4;
channels[77].channel = SOUND_CHANNEL_CITY_BRICKWORKS;
channels[78].channel = SOUND_CHANNEL_CITY_CONCRETE_MAKER;
}

void sound_city_set_volume(int percentage)
Expand Down Expand Up @@ -340,8 +342,8 @@ void sound_city_play(void)
}
}

if (now - last_update_time < 3000) {
// Only play 1 sound every 3 seconds
if (now - last_update_time < 2000) {
// Only play 1 sound every 2 seconds
return;
}
time_millis max_delay = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/sound/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ static char channel_filenames[SOUND_CHANNEL_MAX][CHANNEL_FILENAME_MAX] = {
ASSETS_DIRECTORY "/Sounds/Brickworks.wav",
ASSETS_DIRECTORY "/Sounds/Lighthouse.wav",
ASSETS_DIRECTORY "/Sounds/Ox.wav",
ASSETS_DIRECTORY "/Sounds/ConcreteMaker.wav",
ASSETS_DIRECTORY "/Sounds/Engineer.wav",
ASSETS_DIRECTORY "/Sounds/Prefect.wav",
};

static void correct_channel_filenames(void)
Expand Down
2 changes: 1 addition & 1 deletion src/window/building/culture.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ void window_building_draw_work_camp(building_info_context *c)

void window_building_draw_architect_guild(building_info_context *c)
{
window_building_play_sound(c, "wavs/eng_post.wav");
window_building_play_sound(c, ASSETS_DIRECTORY "/Sounds/Engineer.wav");
outer_panel_draw(c->x_offset, c->y_offset, c->width_blocks, c->height_blocks);
inner_panel_draw(c->x_offset + 16, c->y_offset + 136, c->width_blocks - 2, 4);
window_building_draw_employment(c, 138);
Expand Down
3 changes: 2 additions & 1 deletion src/window/building/government.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "assets/assets.h"
#include "building/building.h"
#include "city/constants.h"
#include "core/dir.h"
#include "game/resource.h"
#include "graphics/image.h"
#include "graphics/lang_text.h"
Expand Down Expand Up @@ -105,7 +106,7 @@ void window_building_draw_garden(building_info_context *c)
void window_building_draw_plaza(building_info_context *c)
{
c->help_id = 80;
window_building_play_sound(c, "wavs/plaza.wav");
window_building_play_sound(c, ASSETS_DIRECTORY "/Sounds/Road.wav");
window_building_prepare_figure_list(c);
outer_panel_draw(c->x_offset, c->y_offset, c->width_blocks, c->height_blocks);
lang_text_draw_centered(137, 0, c->x_offset, c->y_offset + 10, BLOCK_SIZE * c->width_blocks, FONT_LARGE_BLACK);
Expand Down
2 changes: 1 addition & 1 deletion src/window/building/industry.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void window_building_draw_brickworks(building_info_context *c)

void window_building_draw_concrete_maker(building_info_context *c)
{
draw_workshop(c, 1, "wavs/pottery_workshop.wav", CUSTOM_TRANSLATION, TR_BUILDING_CONCRETE_MAKER, RESOURCE_CONCRETE);
draw_workshop(c, 1, ASSETS_DIRECTORY "/Sounds/ConcreteMaker.wav", CUSTOM_TRANSLATION, TR_BUILDING_CONCRETE_MAKER, RESOURCE_CONCRETE);
}

static int governor_palace_is_allowed(void)
Expand Down
7 changes: 4 additions & 3 deletions src/window/building/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "building/roadblock.h"
#include "city/constants.h"
#include "city/finance.h"
#include "core/dir.h"
#include "core/image.h"
#include "graphics/button.h"
#include "graphics/generic_button.h"
Expand Down Expand Up @@ -73,7 +74,7 @@ void window_building_draw_engineers_post(building_info_context *c)
{
c->advisor_button = ADVISOR_CHIEF;
c->help_id = 81;
window_building_play_sound(c, "wavs/eng_post.wav");
window_building_play_sound(c, ASSETS_DIRECTORY "/Sounds/Engineer.wav");
outer_panel_draw(c->x_offset, c->y_offset, c->width_blocks, c->height_blocks);
lang_text_draw_centered(104, 0, c->x_offset, c->y_offset + 10, BLOCK_SIZE * c->width_blocks, FONT_LARGE_BLACK);

Expand Down Expand Up @@ -111,7 +112,7 @@ void window_building_draw_prefect(building_info_context *c)
{
c->advisor_button = ADVISOR_CHIEF;
c->help_id = 86;
window_building_play_sound(c, "wavs/prefecture.wav");
window_building_play_sound(c, ASSETS_DIRECTORY "/Sounds/Prefect.wav");
outer_panel_draw(c->x_offset, c->y_offset, c->width_blocks, c->height_blocks);
lang_text_draw_centered(88, 0, c->x_offset, c->y_offset + 10, BLOCK_SIZE * c->width_blocks, FONT_LARGE_BLACK);

Expand Down Expand Up @@ -168,7 +169,7 @@ static void draw_roadblock_orders_buttons(int x, int y, int focused)
void window_building_draw_roadblock(building_info_context *c)
{
c->help_id = 0;
window_building_play_sound(c, "wavs/prefecture.wav");
window_building_play_sound(c, ASSETS_DIRECTORY "/Sounds/Road.wav");
outer_panel_draw(c->x_offset, c->y_offset, c->width_blocks, c->height_blocks);
lang_text_draw_centered(28, 115, c->x_offset, c->y_offset + 10, 16 * c->width_blocks, FONT_LARGE_BLACK);
window_building_draw_description_at(c, 96, CUSTOM_TRANSLATION, TR_BUILDING_ROADBLOCK_DESC);
Expand Down

0 comments on commit 52b15f9

Please sign in to comment.