added support for protocol version check as first protocol command
[rocksndiamonds.git] / src / config.c
1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // config.c
10 // ============================================================================
11
12 #include "libgame/libgame.h"
13
14 #include "config.h"
15 #include "conftime.h"
16
17
18 char *getSourceDateString()
19 {
20   return SOURCE_DATE_STRING;
21 }
22
23 char *getProgramTitleString()
24 {
25   return program.program_title;
26 }
27
28 char *getProgramRealVersionString()
29 {
30   static char program_version_string[32];
31
32   sprintf(program_version_string, "%d.%d.%d.%d%s",
33           PROGRAM_VERSION_SUPER, PROGRAM_VERSION_MAJOR, PROGRAM_VERSION_MINOR,
34           PROGRAM_VERSION_PATCH, PROGRAM_VERSION_EXTRA);
35
36   return program_version_string;
37 }
38
39 char *getProgramVersionString()
40 {
41   return program.version_string;
42 }
43
44 char *getProgramInitString()
45 {
46   static char *program_init_string = NULL;
47
48   if (program_init_string == NULL)
49   {
50     program_init_string = checked_malloc(strlen(getProgramTitleString()) + 1 +
51                                          strlen(getProgramVersionString()) + 1);
52
53     sprintf(program_init_string, "%s %s",
54             getProgramTitleString(), getProgramVersionString());
55   }
56
57   return program_init_string;
58 }
59
60 char *getConfigProgramTitleString()
61 {
62   TreeInfo *graphics_current =
63     getArtworkTreeInfoForUserLevelSet(ARTWORK_TYPE_GRAPHICS);
64
65   return (leveldir_current->program_title ?
66           leveldir_current->program_title :
67           graphics_current->program_title ?
68           graphics_current->program_title :
69           setup.internal.program_title);
70 }
71
72 char *getConfigProgramCopyrightString()
73 {
74   TreeInfo *graphics_current =
75     getArtworkTreeInfoForUserLevelSet(ARTWORK_TYPE_GRAPHICS);
76
77   return (leveldir_current->program_copyright ?
78           leveldir_current->program_copyright :
79           graphics_current->program_copyright ?
80           graphics_current->program_copyright :
81           setup.internal.program_copyright);
82 }
83
84 char *getConfigProgramCompanyString()
85 {
86   TreeInfo *graphics_current =
87     getArtworkTreeInfoForUserLevelSet(ARTWORK_TYPE_GRAPHICS);
88
89   return (leveldir_current->program_company ?
90           leveldir_current->program_company :
91           graphics_current->program_company ?
92           graphics_current->program_company :
93           setup.internal.program_company);
94 }
95
96 char *getWindowTitleString()
97 {
98   static char *window_title_string = NULL;
99
100   checked_free(window_title_string);
101
102 #if defined(TARGET_SDL2)
103
104 #ifdef DEBUG
105   window_title_string = checked_malloc(strlen(getProgramInitString()) + 20 +
106                                        strlen(getSourceDateString()) + 2 + 1);
107
108   if (setup.internal.show_scaling_in_title)
109     sprintf(window_title_string, "%s (%d %%) [%s]",
110             getProgramInitString(), video.window_scaling_percent,
111             getSourceDateString());
112   else
113     sprintf(window_title_string, "%s [%s]",
114             getProgramInitString(),
115             getSourceDateString());
116 #else
117   window_title_string = checked_malloc(strlen(getProgramInitString()) + 20);
118
119   if (setup.internal.show_scaling_in_title)
120     sprintf(window_title_string, "%s (%d %%)",
121             getProgramInitString(), video.window_scaling_percent);
122   else
123     sprintf(window_title_string, "%s",
124             getProgramInitString());
125 #endif
126
127 #else
128
129 #ifdef DEBUG
130   window_title_string = checked_malloc(strlen(getProgramInitString()) + 1 +
131                                        strlen(getSourceDateString()) + 2 + 1);
132
133   sprintf(window_title_string, "%s [%s]",
134           getProgramInitString(), getSourceDateString());
135 #else
136   window_title_string = checked_malloc(strlen(getProgramInitString()) + 1);
137
138   sprintf(window_title_string, "%s",
139           getProgramInitString());
140 #endif
141
142 #endif
143
144   return window_title_string;
145 }