Added special cases for %% and % at end of phrase for formatting of phrases defined in language definition files.
This commit is contained in:
		| @@ -584,55 +584,64 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len) | |||||||
| 					if (*def == '%') | 					if (*def == '%') | ||||||
| 					{ | 					{ | ||||||
| 						++def; | 						++def; | ||||||
| 						static char format[32]; | 						if (*def == '%' || *def == 0) | ||||||
| 						format[0] = '%'; |  | ||||||
| 						char *ptr = format+1; |  | ||||||
| 						while (ptr-format<sizeof(format) && !isalpha(*ptr++ = *def++)) |  | ||||||
| 							/*nothing*/; |  | ||||||
| 						ZEROTERM(format); |  | ||||||
|  |  | ||||||
| 						*ptr = 0; |  | ||||||
| 						switch ( *(ptr-1) ) |  | ||||||
| 						{ | 						{ | ||||||
| 						case 's': | 							*outptr++ = '%'; | ||||||
| 							{ | 							++def; | ||||||
| 								static char tmpString[4096]; | 						} | ||||||
| 								char *tmpPtr = tmpString; | 						else | ||||||
| 								NEXT_PARAM(); | 						{ | ||||||
| 								cell *tmpCell = get_amxaddr(amx, params[parm++]); | 							static char format[32]; | ||||||
| 								while (tmpPtr-tmpString < sizeof(tmpString) && *tmpCell) | 							format[0] = '%'; | ||||||
| 									*tmpPtr++ = *tmpCell++; | 							char *ptr = format+1; | ||||||
|  | 							 | ||||||
| 								*tmpPtr = 0; | 							while (ptr-format<sizeof(format) && !isalpha(*ptr++ = *def++)) | ||||||
| 								sprintf(outptr, format, tmpString); | 								/*nothing*/; | ||||||
| 								ZEROTERM(outbuf); | 							ZEROTERM(format); | ||||||
| 								break; |  | ||||||
| 							} | 							*ptr = 0; | ||||||
| 						case 'g': | 							switch ( *(ptr-1) ) | ||||||
| 						case 'f': | 							{ | ||||||
| 							{ | 							case 's': | ||||||
| 								NEXT_PARAM(); | 								{ | ||||||
| 								sprintf(outptr, format, *(REAL*)get_amxaddr(amx, params[parm++])); | 									static char tmpString[4096]; | ||||||
| 								ZEROTERM(outbuf); | 									char *tmpPtr = tmpString; | ||||||
| 								break; | 									NEXT_PARAM(); | ||||||
| 							} | 									cell *tmpCell = get_amxaddr(amx, params[parm++]); | ||||||
| 						case 'i': | 									while (tmpPtr-tmpString < sizeof(tmpString) && *tmpCell) | ||||||
| 						case 'd': | 										*tmpPtr++ = *tmpCell++; | ||||||
| 						case 'c': |  | ||||||
| 							{ | 									*tmpPtr = 0; | ||||||
| 								NEXT_PARAM(); | 									sprintf(outptr, format, tmpString); | ||||||
| 								sprintf(outptr, format, (int)*get_amxaddr(amx, params[parm++])); | 									ZEROTERM(outbuf); | ||||||
| 								ZEROTERM(outbuf); | 									break; | ||||||
| 								break; | 								} | ||||||
| 							} | 							case 'g': | ||||||
| 						default: | 							case 'f': | ||||||
| 							{ | 								{ | ||||||
| 								CHECK_OUTPTR(strlen(format)+1); | 									NEXT_PARAM(); | ||||||
| 								strcpy(outptr, format); | 									sprintf(outptr, format, *(REAL*)get_amxaddr(amx, params[parm++])); | ||||||
| 								break; | 									ZEROTERM(outbuf); | ||||||
| 							} | 									break; | ||||||
|  | 								} | ||||||
|  | 							case 'i': | ||||||
|  | 							case 'd': | ||||||
|  | 							case 'c': | ||||||
|  | 								{ | ||||||
|  | 									NEXT_PARAM(); | ||||||
|  | 									sprintf(outptr, format, (int)*get_amxaddr(amx, params[parm++])); | ||||||
|  | 									ZEROTERM(outbuf); | ||||||
|  | 									break; | ||||||
|  | 								} | ||||||
|  | 							default: | ||||||
|  | 								{ | ||||||
|  | 									CHECK_OUTPTR(strlen(format)+1); | ||||||
|  | 									strcpy(outptr, format); | ||||||
|  | 									break; | ||||||
|  | 								} | ||||||
|  | 							} | ||||||
|  | 							outptr += strlen(outptr); | ||||||
| 						} | 						} | ||||||
| 						outptr += strlen(outptr); |  | ||||||
| 					} | 					} | ||||||
| 					else if (*def == '^') | 					else if (*def == '^') | ||||||
| 					{ | 					{ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user