View Single Post
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 09-14-2015 , 02:37   Re: Compiling AMXX Module
Reply With Quote #7

I made a lot of progress. I decided to use a static array of up to 16 arguments (should be more than enough, but I might still change this to a vector for infinitely many arguments). I chose to take the route to do formatting one argument at a time, e.g.:

Code:
for each argument in array:
    switch argument:
        case LOG_ARG_TIME: snprintf(buffer, len, format, time); break;
        case LOG_ARG_DATE: snprintf(buffer, len, format, date); break;
        ...
This has an issue where copying is not working as expected. I would like it to just replace the first instance of %s with the current argument and return the number of characters copied, however it returns a negative number instead (as per the specification because it isn't copying the entire string). I will need to get this working by keeping track of the current lengths and carefully incrementing. E.g. iteration sequence:

Code:

%s_%s
^
logger_%s
         ^
logger_2015-09-13
                 ^
I have this working for the time and date fields right now, but the others do not work yet. I also need to add the fill-in values for the calling function and plugin.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]
Tirant is offline