Revision | 8cb43c48b63213866e09cb89427cf5e9f0e86432 (tree) |
---|---|
Time | 2013-03-08 03:38:41 |
Author | Face |
Commiter | Face |
Genericvessel: refactored slash detection with generic code instead of duplication
@@ -106,16 +106,13 @@ | ||
106 | 106 | char *iniFile=NULL; |
107 | 107 | char *className=GetClassName(), *cn=NULL; |
108 | 108 | char *name=GetName(); |
109 | - strcpy(cn=new char[strlen(className)+1], className); | |
109 | + strcpy(cn=new char[(k=strlen(className))+1], className); | |
110 | 110 | strlwr(cn); |
111 | + for(i=0;i<k;i++)if(cn[i]=='/')cn[i]='\\'; | |
111 | 112 | if (strncmp(cn, SPACECRAFTCLASS, strlen(SPACECRAFTCLASS))==0){ |
112 | 113 | //INI file at legacy location - fixed prefix here, because it is not clear if SC3 respected custom config paths |
113 | 114 | iniFile=new char[strlen(name)+strlen(SPACECRAFTINIPATH)]; |
114 | 115 | sprintf(iniFile, SPACECRAFTINIPATH, name); |
115 | - }else if (strncmp(cn, SPACECRAFTCLASS2, strlen(SPACECRAFTCLASS2))==0){ | |
116 | - //INI file at legacy location - fixed prefix here, because it is not clear if SC3 respected custom config paths | |
117 | - iniFile=new char[strlen(name)+strlen(SPACECRAFTINIPATH)]; | |
118 | - sprintf(iniFile, SPACECRAFTINIPATH, name); | |
119 | 116 | }else{ |
120 | 117 | //configuration file is also INI file, read orbiter.cfg first to get custom config paths |
121 | 118 | FILEHANDLE f=oapiOpenFile(ORBITERCONFIG, FILE_IN); |
@@ -9,7 +9,6 @@ | ||
9 | 9 | #define CUSTOMDIRSLENGTH 1024 |
10 | 10 | //############################################################################// |
11 | 11 | #define SPACECRAFTCLASS "spacecraft\\spacecraft" |
12 | -#define SPACECRAFTCLASS2 "spacecraft/spacecraft" | |
13 | 12 | #define SPACECRAFTINIPATH ".\\Config\\Spacecraft\\%s.ini" |
14 | 13 | #define CONFIGDIRTAG "ConfigDir" |
15 | 14 | #define MESHDIRTAG "MeshDir" |