string hostversion = ReadString();
bool version_mismatch = flags & 2;
bool version_check = flags & 4;
+ MapInfo_Map_titlestring = ReadString();
srv_minplayers = ReadByte();
srv_maxplayers = ReadByte();
string modifications = translate_modifications(ReadString());
msg = strcat(msg, "\n\n", _("Gametype:"), " ^1", MapInfo_Type_ToText(gametype), "\n");
- msg = strcat(msg, "\n", _("Map:"), " ^2");
- if (world.message == "")
- msg = strcat(msg, mi_shortname, "\n");
- else
- {
- int i = strstrofs(world.message, " by ", 0); // matches _MapInfo_Generate()
- string longname = i >= 0 ? substring(world.message, 0, i) : world.message;
- msg = strcat(msg, (strcasecmp(longname, mi_shortname) ? strcat(mi_shortname, " ^7// ^2") : ""), longname, "\n");
- }
+ msg = strcat(msg, "\n", _("Map:"), " ", MapInfo_Map_titlestring, "\n");
if (srv_minplayers || srv_maxplayers)
{
_MapInfo_Map_worldspawn_music = v;
else if(k == "noise")
_MapInfo_Map_worldspawn_music = v;
- else if(k == "message" && (!MapInfo_Map_title || MapInfo_Map_title == "<TITLE>"))
- {
- i = strstrofs(v, " by ", 0);
- if(MapInfo_Map_author == "<AUTHOR>" && i >= 0)
- {
- MapInfo_Map_title = substring(v, 0, i);
- MapInfo_Map_author = substring(v, i + 4, strlen(v) - (i + 4));
- }
- else
- MapInfo_Map_title = v;
- }
+ else if(k == "message" && (!MapInfo_Map_title || MapInfo_Map_title == "<TITLE>") && v != "")
+ MapInfo_Map_title = v;
}
else
{
}
}
-float MapInfo_isRedundant(string fn, string t)
+/// Removes author string from title (if found)
+/// and copies it to MapInfo_Map_author if that wasn't set.
+string MapInfo_title_sans_author(string title)
+{
+ int offset;
+
+ if ((offset = strstrofs(title, " by ", 0)) >= 0)
+ {
+ if (MapInfo_Map_author == "<AUTHOR>")
+ MapInfo_Map_author = substring(title, offset + 4, strlen(title) - (offset + 4));
+ title = substring(title, 0, offset);
+ }
+
+ return title != "" ? title : "<TITLE>";
+}
+
+bool MapInfo_isRedundant(string fn, string t)
{
// normalize file name
fn = strreplace("_", "", fn);
r = _MapInfo_Generate(pFilename);
if(!r)
return 0;
+ MapInfo_Map_title = MapInfo_title_sans_author(MapInfo_Map_title);
fh = fopen(fn, FILE_WRITE);
fputs(fh, strcat("title ", MapInfo_Map_title, "\n"));
fputs(fh, strcat("description ", MapInfo_Map_description, "\n"));
fclose(fh);
LABEL(mapinfo_handled)
+#ifdef SVQC
+ // if the map is currently loaded we can read worldspawn fields directly
+ if (pFilename == mi_shortname)
+ {
+ if (MapInfo_Map_title == "<TITLE>")
+ if (world.message != "")
+ MapInfo_Map_title = world.message;
+ }
+#endif
+ // Could skip removing author from title when it's source is .mapinfo
+ // but must always do it for world.message and .arena/.defi as VQ3 didn't support author
+ // so mappers tended to put it in world.message and/or longname.
+ MapInfo_Map_title = MapInfo_title_sans_author(MapInfo_Map_title); // may set author if not set
+
if(MapInfo_Map_title == "<TITLE>")
- MapInfo_Map_titlestring = MapInfo_Map_bspname;
+ MapInfo_Map_titlestring = strcat("^2", MapInfo_Map_bspname);
else if(MapInfo_isRedundant(MapInfo_Map_bspname, MapInfo_Map_title))
- MapInfo_Map_titlestring = MapInfo_Map_title;
+ MapInfo_Map_titlestring = strcat("^2", MapInfo_Map_title);
else
- MapInfo_Map_titlestring = sprintf("%s: %s", MapInfo_Map_bspname, MapInfo_Map_title);
+ MapInfo_Map_titlestring = sprintf("^2%s ^7// ^2%s", MapInfo_Map_bspname, MapInfo_Map_title);
MapInfo_Cache_Store();
if(MapInfo_Map_supportedGametypes != 0)
flags |= 2;
if (CS(this).version < autocvar_gameversion)
flags |= 4;
+ MapInfo_Get_ByName(mi_shortname, 0, NULL);
WriteByte(msg_type, flags);
WriteString(msg_type, autocvar_hostname);
WriteString(msg_type, autocvar_g_xonoticversion);
+ WriteString(msg_type, MapInfo_Map_titlestring);
+ MapInfo_ClearTemps();
+
WriteByte(msg_type, autocvar_g_warmup > 1 ? autocvar_g_warmup : map_minplayers);
WriteByte(msg_type, GetPlayerLimit());