/********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ***********************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "fcintl.h" #include "log.h" #include "mem.h" #include "chatline_g.h" #include "citydlg_g.h" #include "dialogs_g.h" #include "gui_main_g.h" #include "mapctrl_g.h" #include "mapview_g.h" #include "menu_g.h" #include "civclient.h" #include "clinet.h" #include "goto.h" #include "options.h" #include "tilespec.h" #include "sound.h" /* sound specific */ struct timeval timelast; int lastsound; void play_sound_unit (struct unit *punit, int action) { /* Actions: 0 : Activate 1 : Move 2 : Attack 3 : Special 4 : Destroyed */ char *name; char giveout[100]; int x = 0; struct timeval now; name = get_unit_type(punit->type)->name_orig; while (x < 52) { if (!strcoll(name, unit_sounds[x].name)) break; else x++; } sprintf (giveout, "play %s &", unit_sounds[x].file[action]); append_output_window(giveout); gettimeofday (&now, NULL); if ((now.tv_sec - timelast.tv_sec) > 2 || lastsound != action) { system (giveout); timelast = now; lastsound = action; } } void play_sound_event (int event) { /* see event IDs from header-file */ char giveout[100]; struct timeval now; sprintf (giveout, "play %s &", event_sounds[event].file); append_output_window(giveout); gettimeofday (&now, NULL); if ((now.tv_sec - timelast.tv_sec) > 2 || lastsound != event) { system (giveout); timelast = now; lastsound = event; } }