Make console recognise element names

This commit is contained in:
jacksonmj 2011-01-31 02:42:34 +00:00
parent f85ef31b1f
commit cdd7399cc1
3 changed files with 50 additions and 17 deletions

View File

@ -228,5 +228,7 @@ int report_ui(pixel *vid_buf, char *save_id);
char *console_ui(pixel *vid_buf, char error[255]);
int console_get_type(char *element);
#endif

View File

@ -3927,3 +3927,19 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
}
int console_get_type(char *element)
{
int i;
char num[4];
i = atoi(element);
sprintf(num,"%d",i);
if (i>=0 && i<PT_NUM && strcmp(element,num)==0)
return i;
if (strcasecmp(element,"C4")==0) return PT_PLEX;
if (strcasecmp(element,"C5")==0) return PT_C5;
for (i=0; i<PT_NUM; i++) {
if (strcasecmp(element,ptypes[i].name)==0)
return i;
}
return -1;
}

View File

@ -1783,7 +1783,8 @@ int main(int argc, char *argv[])
if(parts[i].type)
parts[i].life = j;
}
} else
}
else
{
i = atoi(console4);
if(parts[i].type)
@ -1797,19 +1798,26 @@ int main(int argc, char *argv[])
{
if(strcmp(console4, "all")==0)
{
j = atoi(console5);
for(i=0; i<NPART; i++)
{
if(parts[i].type)
parts[i].type = j;
}
} else
j = console_get_type(console5);
if (j<0)
sprintf(error, "Particle type not recognised", console2);
else
for(i=0; i<NPART; i++)
{
if(parts[i].type)
parts[i].type = j;
}
}
else
{
i = atoi(console4);
if(parts[i].type)
{
j = atoi(console5);
parts[i].type = j;
j = console_get_type(console5);
if (j<0)
sprintf(error, "Particle type not recognised", console2);
else
parts[i].type = j;
}
}
}
@ -1823,7 +1831,8 @@ int main(int argc, char *argv[])
if(parts[i].type)
parts[i].temp = j;
}
} else
}
else
{
i = atoi(console4);
if(parts[i].type)
@ -1843,7 +1852,8 @@ int main(int argc, char *argv[])
if(parts[i].type)
parts[i].tmp = j;
}
} else
}
else
{
i = atoi(console4);
if(parts[i].type)
@ -1863,7 +1873,8 @@ int main(int argc, char *argv[])
if(parts[i].type)
parts[i].x = j;
}
} else
}
else
{
i = atoi(console4);
if(parts[i].type)
@ -1883,7 +1894,8 @@ int main(int argc, char *argv[])
if(parts[i].type)
parts[i].y = j;
}
} else
}
else
{
i = atoi(console4);
if(parts[i].type)
@ -1903,7 +1915,8 @@ int main(int argc, char *argv[])
if(parts[i].type)
parts[i].ctype = j;
}
} else
}
else
{
i = atoi(console4);
if(parts[i].type)
@ -1923,7 +1936,8 @@ int main(int argc, char *argv[])
if(parts[i].type)
parts[i].vx = j;
}
} else
}
else
{
i = atoi(console4);
if(parts[i].type)
@ -1943,7 +1957,8 @@ int main(int argc, char *argv[])
if(parts[i].type)
parts[i].vy = j;
}
} else
}
else
{
i = atoi(console4);
if(parts[i].type)