From 79143d8b6e1cee3b716262025b5c78248982f69b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 31 Oct 2014 18:49:15 -0700 Subject: [PATCH] Port files.inc to transitional syntax. --- core/logic/smn_filesystem.cpp | 52 ++++- plugins/admin-flatfile/admin-simple.sp | 22 +-- plugins/adminmenu/dynamicmenu.sp | 8 +- plugins/include/files.inc | 261 ++++++++++++++++++++----- plugins/include/helpers.inc | 13 +- plugins/testsuite/filetest.sp | 45 +++-- sourcepawn/compiler/sc1.cpp | 8 +- sourcepawn/compiler/sc5-in.scp | 1 + 8 files changed, 317 insertions(+), 93 deletions(-) diff --git a/core/logic/smn_filesystem.cpp b/core/logic/smn_filesystem.cpp index e6576621..b1d2571f 100644 --- a/core/logic/smn_filesystem.cpp +++ b/core/logic/smn_filesystem.cpp @@ -181,7 +181,7 @@ public: } size_t Read(void *pOut, int size) KE_OVERRIDE { - return fread(pOut, size, 1, fp_); + return fread(pOut, 1, size, fp_); } char *ReadLine(char *pOut, int size) KE_OVERRIDE { return fgets(pOut, size, fp_); @@ -1104,6 +1104,35 @@ static cell_t sm_RemoveGameLogHook(IPluginContext *pContext, const cell_t *param return 1; } +template +static cell_t File_ReadTyped(IPluginContext *pContext, const cell_t *params) +{ + OpenHandle file(pContext, params[1], g_FileType); + if (!file.Ok()) + return 0; + + cell_t *data; + pContext->LocalToPhysAddr(params[2], &data); + + T value; + if (file->Read(&value, sizeof(value)) != sizeof(value)) + return 0; + + *data = value; + return 1; +} + +template +static cell_t File_WriteTyped(IPluginContext *pContext, const cell_t *params) +{ + OpenHandle file(pContext, params[1], g_FileType); + if (!file.Ok()) + return 0; + + T value = (T)params[2]; + return !!(file->Write(&value, sizeof(value)) == sizeof(value)); +} + REGISTER_NATIVES(filesystem) { {"OpenDirectory", sm_OpenDirectory}, @@ -1136,5 +1165,26 @@ REGISTER_NATIVES(filesystem) {"RemoveGameLogHook", sm_RemoveGameLogHook}, {"CreateDirectory", sm_CreateDirectory}, {"SetFilePermissions", sm_SetFilePermissions}, + + {"File.ReadLine", sm_ReadFileLine}, + {"File.Read", sm_ReadFile}, + {"File.ReadString", sm_ReadFileString}, + {"File.Write", sm_WriteFile}, + {"File.WriteString", sm_WriteFileString}, + {"File.WriteLine", sm_WriteFileLine}, + {"File.EndOfFile", sm_IsEndOfFile}, + {"File.Seek", sm_FileSeek}, + {"File.Position.get", sm_FilePosition}, + {"File.ReadInt8", File_ReadTyped}, + {"File.ReadUint8", File_ReadTyped}, + {"File.ReadInt16", File_ReadTyped}, + {"File.ReadInt32", File_ReadTyped}, + {"File.WriteInt8", File_WriteTyped}, + {"File.WriteInt16", File_WriteTyped}, + {"File.WriteInt32", File_WriteTyped}, + + // Transitional syntax support. + {"DirectoryListing.GetNext", sm_ReadDirEntry}, + {NULL, NULL}, }; diff --git a/plugins/admin-flatfile/admin-simple.sp b/plugins/admin-flatfile/admin-simple.sp index c04be2b7..947a0fa5 100644 --- a/plugins/admin-flatfile/admin-simple.sp +++ b/plugins/admin-flatfile/admin-simple.sp @@ -35,32 +35,28 @@ public ReadSimpleUsers() { BuildPath(Path_SM, g_Filename, sizeof(g_Filename), "configs/admins_simple.ini"); - new Handle:file = OpenFile(g_Filename, "rt"); - if (file == INVALID_HANDLE) + File file = OpenFile(g_Filename, "rt"); + if (!file) { ParseError("Could not open file!"); return; } - while (!IsEndOfFile(file)) + while (!file.EndOfFile()) { - decl String:line[255]; - if (!ReadFileLine(file, line, sizeof(line))) - { + char line[255]; + if (!file.ReadLine(line, sizeof(line))) break; - } /* Trim comments */ - new len = strlen(line); - new bool:ignoring = false; - for (new i=0; i max_size. + public native int ReadString(char[] buffer, int max_size, int read_count=-1); + + // Writes binary data to a file. + // + // @param items Array of items to write. The data is read directly. + // That is, in 1 or 2-byte mode, the lower byte(s) in + // each cell are used directly, rather than performing + // any casts from a 4-byte number to a smaller number. + // @param num_items Number of items in the array. + // @param size Size of each item in the array in bytes. + // Valid sizes are 1, 2, or 4. + // @return True on success, false on error. + public native bool Write(const int[] items, int num_items, int size); + + // Writes a binary string to a file. + // + // @param buffer String to write. + // @param term True to append NUL terminator, false otherwise. + // @return True on success, false on error. + public native bool WriteString(const char[] buffer, bool term); + + // Writes a line of text to a text file. A newline is automatically appended. + // + // @param hndl Handle to the file. + // @param format Formatting rules. + // @param ... Variable number of format parameters. + // @return True on success, false otherwise. + public native bool WriteLine(const char[] format, any:...); + + // Reads a single int8 (byte) from a file. The returned value is sign- + // extended to an int32. + // + // @param data Variable to store the data read. + // @return True on success, false on failure. + public native bool ReadInt8(int &data); + + // Reads a single uint8 (unsigned byte) from a file. The returned value is + // zero-extended to an int32. + // + // @param data Variable to store the data read. + // @return True on success, false on failure. + public native bool ReadUint8(int &data); + + // Reads a single int16 (short) from a file. The value is sign-extended to + // an int32. + // + // @param data Variable to store the data read. + // @return True on success, false on failure. + public native bool ReadInt16(int &data); + + // Reads a single unt16 (unsigned short) from a file. The value is zero- + // extended to an int32. + // + // @param data Variable to store the data read. + // @return True on success, false on failure. + public native bool ReadUint16(int &data); + + // Reads a single int32 (int/cell) from a file. + // + // @param data Variable to store the data read. + // @return True on success, false on failure. + public native bool ReadInt32(int &data); + + // Writes a single int8 (byte) to a file. + // + // @param data Data to write (truncated to an int8). + // @return True on success, false on failure. + public native bool WriteInt8(int data); + + // Writes a single int16 (short) to a file. + // + // @param data Data to write (truncated to an int16). + // @return True on success, false on failure. + public native bool WriteInt16(int data); + + // Writes a single int32 (int/cell) to a file. + // + // @param data Data to write. + // @return True on success, false on failure. + public native bool WriteInt32(int data); + + // Tests if the end of file has been reached. + // + // @return True if end of file has been reached, false otherwise. + public native bool EndOfFile(); + + // Sets the file position indicator. + // + // @param position Position relative to what is specified in whence. + // @param where SEEK_ constant value of where to see from. + // @return True on success, false otherwise. + public native bool Seek(int position, int where); + + // Get the current position in the file; returns -1 on failure. + property int Position { + public native get(); + } +} + /** * Builds a path relative to the SourceMod folder. This should be used instead of * directly referencing addons/sourcemod, in case users change the name of their @@ -98,12 +251,12 @@ enum PathType * @param ... Format arguments. * @return Number of bytes written to buffer (not including null terminator). */ -native BuildPath(PathType:type, String:buffer[], maxlength, const String:fmt[], any:...); +native int BuildPath(PathType type, char[] buffer, int maxlength, const char[] fmt, any:...); /** * Opens a directory/folder for contents enumeration. * - * @note Directories are closed with CloseHandle(). + * @note Directories are closed with CloseHandle() or delete. * @note Directories Handles can be cloned. * @note OpenDirectory() supports the "file://" notation. * @@ -113,9 +266,9 @@ native BuildPath(PathType:type, String:buffer[], maxlength, const String:fmt[], * the Valve search paths, rather than solely files * existing directly in the gamedir. * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. - * @return A Handle to the directory, INVALID_HANDLE on open error. + * @return A Handle to the directory, null on error. */ -native Handle:OpenDirectory(const String:path[], bool:use_valve_fs=false, const String:valve_path_id[]="GAME"); +native DirectoryListing OpenDirectory(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME"); /** * Reads the current directory entry as a local filename, then moves to the next file. @@ -130,14 +283,32 @@ native Handle:OpenDirectory(const String:path[], bool:use_valve_fs=false, const * @return True on success, false if there are no more files to read. * @error Invalid or corrupt Handle. */ -native bool:ReadDirEntry(Handle:dir, String:buffer[], maxlength, &FileType:type=FileType_Unknown); +native bool ReadDirEntry(Handle dir, char[] buffer, int maxlength, FileType &type=FileType_Unknown); /** - * Opens a file. + * Opens or creates a file, returning a File handle on success. File handles + * should be closed with delete or CloseHandle(). * - * @note Files are closed with CloseHandle(). - * @note File Handles can be cloned. - * @note OpenFile() supports the "file://" notation. + * The open mode may be one of the following strings: + * "r": Open an existing file for reading. + * "w": Create a file for writing, or truncate (delete the contents of) an + * existing file and then open it for writing. + * "a": Create a file for writing, or open an existing file such that writes + * will be appended to the end. + * "r+": Open an existing file for both reading and writing. + * "w+": Create a file for reading and writing, or truncate an existing file + * and then open it for reading and writing. + * "a+": Create a file for both reading and writing, or open an existing file + * such that writes will be appended to the end. + * + * The open mode may also contain an additional character after "r", "w", or "a", + * but before any "+" sign. This character may be "b" (indicating binary mode) or + * "t" (indicating text mode). By default, "text" mode is implied. On Linux and + * Mac, this has no distinction from binary mode. On Windows, it causes the '\n' + * character (0xA) to be written as "\r\n" (0xD, 0xA). + * + * Example: "rb" opens a binary file for writing; "at" opens a text file for + * appending. * * @param file File to open. * @param mode Open mode. @@ -146,9 +317,9 @@ native bool:ReadDirEntry(Handle:dir, String:buffer[], maxlength, &FileType:type= * search paths, rather than solely files existing directly * in the gamedir. * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. - * @return A Handle to the file, INVALID_HANDLE on open error. + * @return A File handle, or null if the file could not be opened. */ -native Handle:OpenFile(const String:file[], const String:mode[], bool:use_valve_fs=false, const String:valve_path_id[]="GAME"); +native File OpenFile(const char[] file, const char[] mode, bool use_valve_fs=false, const char[] valve_path_id="GAME"); /** * Deletes a file. @@ -161,7 +332,7 @@ native Handle:OpenFile(const String:file[], const String:mode[], bool:use_valve_ * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. * @return True on success, false on failure or if file not immediately removed. */ -native bool:DeleteFile(const String:path[], bool:use_valve_fs=false, const String:valve_path_id[]="DEFAULT_WRITE_PATH"); +native bool DeleteFile(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH"); /** * Reads a line from a text file. @@ -171,7 +342,7 @@ native bool:DeleteFile(const String:path[], bool:use_valve_fs=false, const Strin * @param maxlength Maximum size of string buffer. * @return True on success, false otherwise. */ -native bool:ReadFileLine(Handle:hndl, String:buffer[], maxlength); +native bool ReadFileLine(Handle hndl, char[] buffer, int maxlength); /** * Reads binary data from a file. @@ -183,7 +354,7 @@ native bool:ReadFileLine(Handle:hndl, String:buffer[], maxlength); * Valid sizes are 1, 2, or 4. * @return Number of elements read, or -1 on error. */ -native ReadFile(Handle:hndl, items[], num_items, size); +native int ReadFile(Handle hndl, int[] items, int num_items, int size); /** * Reads a UTF8 or ANSI string from a file. @@ -200,7 +371,7 @@ native ReadFile(Handle:hndl, items[], num_items, size); * if an error was encountered. * @error Invalid Handle, or read_count > max_size. */ -native ReadFileString(Handle:hndl, String:buffer[], max_size, read_count=-1); +native int ReadFileString(Handle hndl, char[] buffer, int max_size, int read_count=-1); /** * Writes binary data to a file. @@ -216,7 +387,7 @@ native ReadFileString(Handle:hndl, String:buffer[], max_size, read_count=-1); * @return True on success, false on error. * @error Invalid Handle. */ -native bool:WriteFile(Handle:hndl, const items[], num_items, size); +native bool WriteFile(Handle hndl, const int[] items, int num_items, int size); /** * Writes a binary string to a file. @@ -227,7 +398,7 @@ native bool:WriteFile(Handle:hndl, const items[], num_items, size); * @return True on success, false on error. * @error Invalid Handle. */ -native bool:WriteFileString(Handle:hndl, const String:buffer[], bool:term); +native bool WriteFileString(Handle hndl, const char[] buffer, bool term); /** * Writes a line of text to a text file. A newline is automatically appended. @@ -238,7 +409,7 @@ native bool:WriteFileString(Handle:hndl, const String:buffer[], bool:term); * @return True on success, false otherwise. * @error Invalid Handle. */ -native bool:WriteFileLine(Handle:hndl, const String:format[], any:...); +native bool WriteFileLine(Handle hndl, const char[] format, any:...); /** * Reads a single binary cell from a file. @@ -250,14 +421,13 @@ native bool:WriteFileLine(Handle:hndl, const String:format[], any:...); * @return Number of elements read (max 1), or -1 on error. * @error Invalid Handle. */ -stock ReadFileCell(Handle:hndl, &data, size) +stock int ReadFileCell(Handle hndl, int &data, int size) { - new array[1], ret; + int ret; + int array[1]; if ((ret = ReadFile(hndl, array, 1, size)) == 1) - { data = array[0]; - } return ret; } @@ -275,12 +445,11 @@ stock ReadFileCell(Handle:hndl, &data, size) * @return True on success, false on error. * @error Invalid Handle. */ -stock bool:WriteFileCell(Handle:hndl, data, size) +stock bool WriteFileCell(Handle hndl, int data, int size) { - new array[1]; + int array[1]; array[0] = data; - return WriteFile(hndl, array, 1, size); } @@ -291,7 +460,7 @@ stock bool:WriteFileCell(Handle:hndl, data, size) * @return True if end of file has been reached, false otherwise. * @error Invalid Handle. */ -native bool:IsEndOfFile(Handle:file); +native bool IsEndOfFile(Handle file); /** * Sets the file position indicator. @@ -302,7 +471,7 @@ native bool:IsEndOfFile(Handle:file); * @return True on success, false otherwise. * @error Invalid Handle. */ -native bool:FileSeek(Handle:file, position, where); +native bool FileSeek(Handle file, int position, int where); /** * Get current position in the file. @@ -311,7 +480,7 @@ native bool:FileSeek(Handle:file, position, where); * @return Value for the file position indicator. * @error Invalid Handle. */ -native FilePosition(Handle:file); +native int FilePosition(Handle file); /** * Checks if a file exists. @@ -324,7 +493,7 @@ native FilePosition(Handle:file); * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. * @return True if the file exists, false otherwise. */ -native bool:FileExists(const String:path[], bool:use_valve_fs=false, const String:valve_path_id[]="GAME"); +native bool FileExists(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME"); /** * Renames a file. @@ -337,7 +506,7 @@ native bool:FileExists(const String:path[], bool:use_valve_fs=false, const Strin * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. * @return True on success or use_valve_fs specified, false otherwise. */ -native bool:RenameFile(const String:newpath[], const String:oldpath[], bool:use_valve_fs=false, const String:valve_path_id[]="DEFAULT_WRITE_PATH"); +native bool RenameFile(const char[] newpath, const char[] oldpath, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH"); /** * Checks if a directory exists. @@ -350,7 +519,7 @@ native bool:RenameFile(const String:newpath[], const String:oldpath[], bool:use_ * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. * @return True if the directory exists, false otherwise. */ -native bool:DirExists(const String:path[], bool:use_valve_fs=false, const String:valve_path_id[]="GAME"); +native bool DirExists(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME"); /** * Get the file size in bytes. @@ -363,7 +532,7 @@ native bool:DirExists(const String:path[], bool:use_valve_fs=false, const String * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths. * @return File size in bytes, -1 if file not found. */ -native FileSize(const String:path[], bool:use_valve_fs=false, const String:valve_path_id[]="GAME"); +native int FileSize(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME"); /** * Flushes a file's buffered output; any buffered output @@ -373,7 +542,7 @@ native FileSize(const String:path[], bool:use_valve_fs=false, const String:valve * @return True on success or use_valve_fs specified with OpenFile, * otherwise false on failure. */ -native FlushFile(Handle:file); +native bool FlushFile(Handle file); /** * Removes a directory. @@ -382,7 +551,7 @@ native FlushFile(Handle:file); * @param path Path to the directory. * @return True on success, false otherwise. */ -native bool:RemoveDir(const String:path[]); +native bool RemoveDir(const char[] path); #define FPERM_U_READ 0x0100 /* User can read. */ #define FPERM_U_WRITE 0x0080 /* User can write. */ @@ -406,7 +575,7 @@ native bool:RemoveDir(const String:path[]); * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for default. * In this case, mode is ignored. */ -native bool:CreateDirectory(const String:path[], mode, bool:use_valve_fs=false, const String:valve_path_id[]="DEFAULT_WRITE_PATH"); +native bool CreateDirectory(const char[] path, int mode, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH"); /** * Changes a file or directories permissions. @@ -415,7 +584,7 @@ native bool:CreateDirectory(const String:path[], mode, bool:use_valve_fs=false, * @param mode Permissions to set. * @return True on success, false otherwise. */ -native bool:SetFilePermissions(const String:path[], mode); +native bool SetFilePermissions(const String:path[], int mode); /** * Returns a file timestamp as a unix timestamp. @@ -424,7 +593,7 @@ native bool:SetFilePermissions(const String:path[], mode); * @param tmode Time mode. * @return Time value, or -1 on failure. */ -native GetFileTime(const String:file[], FileTimeMode:tmode); +native GetFileTime(const char[] file, FileTimeMode tmode); /** * Same as LogToFile(), except uses an open file Handle. The file must @@ -433,10 +602,9 @@ native GetFileTime(const String:file[], FileTimeMode:tmode); * @param hndl Handle to the file. * @param message Message format. * @param ... Message format parameters. - * @noreturn * @error Invalid Handle. */ -native LogToOpenFile(Handle:hndl, const String:message[], any:...); +native void LogToOpenFile(Handle hndl, const char[] message, any:...); /** * Same as LogToFileEx(), except uses an open file Handle. The file must @@ -445,8 +613,7 @@ native LogToOpenFile(Handle:hndl, const String:message[], any:...); * @param hndl Handle to the file. * @param message Message format. * @param ... Message format parameters. - * @noreturn * @error Invalid Handle. */ -native LogToOpenFileEx(Handle:hndl, const String:message[], any:...); +native void LogToOpenFileEx(Handle hndl, const char[] message, any:...); diff --git a/plugins/include/helpers.inc b/plugins/include/helpers.inc index d4adc6fb..c4e92245 100644 --- a/plugins/include/helpers.inc +++ b/plugins/include/helpers.inc @@ -241,18 +241,17 @@ stock FindTarget(client, const String:target[], bool:nobots = false, bool:immuni ClearArray(array); - new Handle:file = OpenFile(mapPath, "rt"); - if (file == INVALID_HANDLE) - { + File file = OpenFile(mapPath, "rt"); + if (!file) { LogError("Could not open file: %s", mapPath); - return 0; } LogMessage("Loading maps from file: %s", mapPath); - decl String:buffer[64], len; - while (!IsEndOfFile(file) && ReadFileLine(file, buffer, sizeof(buffer))) + int len; + char buffer[64]; + while (!file.IsEndOfFile() && file.ReadLine(buffer, sizeof(buffer))) { TrimString(buffer); @@ -274,6 +273,6 @@ stock FindTarget(client, const String:target[], bool:nobots = false, bool:immuni PushArrayString(array, buffer); } - CloseHandle(file); + file.Close(); return GetArraySize(array); } diff --git a/plugins/testsuite/filetest.sp b/plugins/testsuite/filetest.sp index 7a6a1f1e..6c0a3d18 100644 --- a/plugins/testsuite/filetest.sp +++ b/plugins/testsuite/filetest.sp @@ -9,37 +9,37 @@ public Plugin:myinfo = url = "http://www.sourcemod.net/" }; -public OnPluginStart() +public void OnPluginStart() { RegServerCmd("test_fread1", Test_ReadBinStr); } -Handle:OpenFile2(const String:path[], const String:mode[]) +File OpenFile2(const String:path[], const String:mode[]) { - new Handle:file = OpenFile(path, mode); - if (file == INVALID_HANDLE) + File file = OpenFile(path, mode); + if (!file) PrintToServer("Failed to open file %s for %s", path, mode); else PrintToServer("Opened file handle %x: %s", file, path); return file; } -public Action:Test_ReadBinStr(args) +public Action Test_ReadBinStr(args) { - new items[] = {1, 3, 5, 7, 0, 92, 193, 26, 0, 84, 248, 2}; - new Handle:of = OpenFile2("smbintest", "wb"); - if (of == INVALID_HANDLE) + int items[] = {1, 3, 5, 7, 0, 92, 193, 26, 0, 84, 248, 2}; + File of = OpenFile2("smbintest", "wb"); + if (!of) return Plugin_Handled; - WriteFile(of, items, sizeof(items), 1); - CloseHandle(of); + of.Write(items, sizeof(items), 1); + of.Close(); - new Handle:inf = OpenFile2("smbintest", "rb"); - new String:buffer[sizeof(items)]; - ReadFileString(inf, buffer, sizeof(items), sizeof(items)); - FileSeek(inf, 0, SEEK_SET); - new items2[sizeof(items)]; - ReadFile(inf, items2, sizeof(items), 1); - CloseHandle(inf); + File inf = OpenFile2("smbintest", "rb"); + char buffer[sizeof(items)]; + inf.ReadString(buffer, sizeof(items), sizeof(items)); + inf.Seek(0, SEEK_SET); + int items2[sizeof(items)]; + inf.Read(items2, sizeof(items), 1); + inf.Close(); for (new i = 0; i < sizeof(items); i++) { @@ -55,6 +55,17 @@ public Action:Test_ReadBinStr(args) } } + inf = OpenFile2("smbintest", "rb"); + for (new i = 0; i < sizeof(items); i++) + { + new item; + if (!inf.ReadInt8(item) || item != items[i]) + { + PrintToServer("FAILED ON INDEX %d: %d != %d", i, item, items[i]); + return Plugin_Handled; + } + } + PrintToServer("Test passed!"); return Plugin_Handled; diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp index 23d002c4..c38c83ad 100644 --- a/sourcepawn/compiler/sc1.cpp +++ b/sourcepawn/compiler/sc1.cpp @@ -4170,7 +4170,7 @@ static void dodelete() switch (ident) { case iFUNCTN: case iREFFUNC: - error(115, "functions"); + error(167, "functions"); return; case iARRAY: @@ -4180,7 +4180,7 @@ static void dodelete() { symbol *sym = sval.val.sym; if (!sym || sym->dim.array.level > 0) { - error(115, "arrays"); + error(167, "arrays"); return; } break; @@ -4188,13 +4188,13 @@ static void dodelete() } if (sval.val.tag == 0) { - error(115, "primitive types or enums"); + error(167, "integers"); return; } methodmap_t *map = methodmap_find_by_tag(sval.val.tag); if (!map) { - error(115, pc_tagname(sval.val.tag)); + error(115, "type", pc_tagname(sval.val.tag)); return; } diff --git a/sourcepawn/compiler/sc5-in.scp b/sourcepawn/compiler/sc5-in.scp index 8b26bfba..842bef3c 100644 --- a/sourcepawn/compiler/sc5-in.scp +++ b/sourcepawn/compiler/sc5-in.scp @@ -210,6 +210,7 @@ static const char *errmsg[] = { /*164*/ "allocated array type '%s' doesn't match original type '%s'\n", /*165*/ "cannot create dynamic arrays in static scope - did you mean to create a fixed-length array with brackets after the variable name?\n", /*166*/ "cannot use 'this' outside of a methodmap method or property\n", +/*167*/ "cannot use delete, %s do not have destructors\n", #else "\315e\306\227\266k\217:\235\277bu\201fo\220\204\223\012", "\202l\224\250s\205g\346\356e\233\201(\243\315\214\267\202) \253 f\255low ea\305 \042c\353e\042\012",