Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions apps/amxxpc/src/amxxpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#include <cstdlib>

#ifdef BUILD_STATIC_AMXXPC
extern "C" {
#include <sc.h>
}
extern "C" void Compile32(int argc, char** argv);
#else
#if defined(EMSCRIPTEN)
Expand Down Expand Up @@ -96,7 +98,7 @@ int main(const int argc, char** argv)
pc_printf("Copyright (c) 2004-2013 AMX Mod X Team\n");
pc_printf("Copyright (c) 2025 hlds.run Team\n\n");

if (argc < 2) {
if (argc < 2 && (strlen(argv[1]) <= 2 || strncmp(argv[1], "-T", 2) != 0)) {
pc_printf("Usage: <file.sma> [options]\n");
pc_printf("Use -? or --help to see full options\n\n");
getchar();
Expand Down Expand Up @@ -337,6 +339,12 @@ char* FindFileName(const int argc, char** argv)
return swiext(argv[save], "amx", 0);
}

const char* file = pc_pop_first_source_file();

if (file != nullptr && *file != '\0') {
return swiext(file, "amx", 0);
}

return nullptr;
}

Expand All @@ -358,7 +366,8 @@ void show_help()
printf("\t-l create list file (preprocess only)\n");
printf("\t-o<name> set base name of output file\n");
printf("\t-p<name> set name of \"prefix\" file\n");
printf("\t-r[name] write cross reference report to console or to specified file\n");
printf("\t-r<name> write cross reference report to console or to specified file\n");
printf("\t-T<name> set name of the configuration file to use\n");
printf("\t-sui[+/-] show stack usage info\n");
printf("\tsym=val define constant \"sym\" with value \"val\"\n");
printf("\tsym= define constant \"sym\" with value 1\n");
Expand Down
5 changes: 5 additions & 0 deletions libs/amxxpc32/src/libpawnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ int pc_error(const int number, const char* message, char* filename, const int fi
return 0;
}

AMXXPC_API const char* pc_pop_first_source_file(void)
{
return pop_first_source_file();
}

typedef struct src_file_s {
FILE* fp; // Set if writing.
char* buffer; // IO buffer.
Expand Down
14 changes: 13 additions & 1 deletion libs/amxxpc32/src/sc.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ typedef struct s_valuepair {
#define opcodes(n) ((n) * sizeof(cell)) /* opcode size */
#define opargs(n) ((n) * sizeof(cell)) /* size of typical argument */

/* general purpose macros */
#if !defined sizearray
#define sizearray(a) (sizeof(a) / sizeof((a)[0]))
#endif
#if !defined makelong
#define makelong(low, high) ((long)(low) | ((long)(high) << (sizeof(long) * 4)))
#endif

/* Tokens recognized by lex()
* Some of these constants are assigned as well to the variable "lastst"
*/
Expand Down Expand Up @@ -459,11 +467,14 @@ int pc_enablewarning(int number, int enable);
#if PAWN_CELL_SIZE == 32
#if defined __WIN32__ || defined _WIN32 || defined WIN32
__declspec(dllexport) int pc_printf(const char* message, ...);
__declspec(dllexport) const char* pc_pop_first_source_file(void);
#else
extern int __attribute__((visibility("default"))) pc_printf(const char* message, ...);
__attribute__((visibility("default"))) extern int pc_printf(const char* message, ...);
__attribute__((visibility("default"))) extern const char* pc_pop_first_source_file(void);
#endif
#else
int pc_printf(const char* message, ...) INVISIBLE;
const char* pc_pop_first_source_file(void) INVISIBLE;
#endif

/* error report function */
Expand Down Expand Up @@ -700,6 +711,7 @@ SC_FUNC int get_subst(int index, char** pattern, char** substitution);
SC_FUNC stringpair* find_subst(const char* name, int length);
SC_FUNC int delete_subst(const char* name, int length);
SC_FUNC void delete_substtable(void);
SC_FUNC const char* pop_first_source_file(void);
SC_FUNC stringlist* insert_sourcefile(const char* string);
SC_FUNC char* get_sourcefile(int index);
SC_FUNC void delete_sourcefiletable(void);
Expand Down
Loading
Loading