Compare commits

...
Sign in to create a new pull request.

8 commits

Author SHA1 Message Date
Xackery Xtal
e2f9926586 Cleaning up croak examples 2018-01-18 22:44:35 -08:00
Xackery Xtal
d284802447 Moved perlparse to generator 2018-01-18 22:17:28 -08:00
Xackery Xtal
468fd0ff6c Added Events 2018-01-15 22:35:37 -08:00
Xackery Xtal
4a92b71ae1 perlparse supports sorting among other fixes 2018-01-15 13:15:38 -08:00
Xackery Xtal
6fcc33b623 split perl into multiple files 2018-01-15 11:52:49 -08:00
Xackery Xtal
eeaf958c64 Added more changes to perl parser. #697 2018-01-14 19:52:19 -08:00
Xackery Xtal
af7550be59 Fixed croak syntax errors 2018-01-14 14:41:24 -08:00
Xackery Xtal
ec87a85a24 Added multiple file parsing 2018-01-13 22:05:56 -08:00
15 changed files with 14616 additions and 413 deletions

View file

@ -0,0 +1,2 @@
out/*
sample.yml

View file

@ -0,0 +1,9 @@
# perlparse
* Install golang.
* cmd: `go get ./...`
* cmd: `go run *.go`
* A lot of debug text will echo out
* The sample.yml file is a yaml overview of what is generated
* the out/ folder will have all markdowns, ready to be added to wiki

View file

@ -0,0 +1,167 @@
//Parses perl scripts
package main
import (
"log"
"strings"
"time"
"unicode"
)
//Path defines file related details
type path struct {
Name string
Scope string
Replace string
}
type RootYaml struct {
Scopes []*ScopeYaml
}
type ScopeYaml struct {
Name string
Functions []*FuncYaml
}
type FuncYaml struct {
Name string
Summary string
Example string
Argument string
}
type Functions []*API
func (s Functions) Len() int { return len(s) }
func (s Functions) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
type FunctionsByName struct{ Functions }
func (s FunctionsByName) Less(i, j int) bool { return s.Functions[i].Function < s.Functions[j].Function }
type Events []*Event
func (s Events) Len() int { return len(s) }
func (s Events) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
type EventsByName struct{ Events }
func (s EventsByName) Less(i, j int) bool { return s.Events[i].Name < s.Events[j].Name }
//API represents an endpoint
type API struct {
//This is the prefix to a function
Object string
//This is the raw functionname, e.g. attacknpc in quest::attacknpc()
Function string
//Summary of function
Summary string
//Description is pulled from a mapfile
Description string
//Scope is object type, e.g. quest in quest::attacknpc()
Scope string
//Return is the return type, e.g. bool, void, etc
Return string
//Arguments is a list of arguments
Arguments []*Argument
}
//Argument holds details about arguments
type Argument struct {
//Name of argument, e.g. item_id
Name string
//Type of argument, e.g. int or string
Type string
//API holds details about the function the argument is used, mainly for reporting
API *API
//Is optional?
Optional bool
}
type Event struct {
//Name of event, e.g. EVENT_SAY
Name string
//Arguments is a list of arguments
Arguments []*Argument
}
func main() {
var err error
start := time.Now()
if err = perlGenerate(); err != nil {
log.Fatalf("Error while generating perl: %s", err.Error())
}
log.Println("Finished in", time.Since(start))
}
func getNoun(function string) string {
function = strings.ToLower(function)
//first, strip any adjectives
for k, _ := range adjectives {
if strings.Index(function, strings.ToLower(k)) == 0 {
function = function[len(k):]
}
}
//now figure out noun
for k, v := range nouns {
if strings.Contains(function, strings.ToLower(k)) {
return v
}
}
return ""
}
func getAdjective(function string) string {
function = strings.ToLower(function)
for k, v := range adjectives {
if strings.Index(function, strings.ToLower(k)) == 0 {
return v
}
}
return ""
}
func splitFunctionParts(function string) (parts []string) {
//first, strip any adjectives
for k, _ := range adjectives {
if strings.Index(strings.ToLower(function), strings.ToLower(k)) == 0 {
function = function[len(k):]
}
}
//try snake
if strings.Contains(function, "_") { //snake notation
parts = strings.Split(function, "_")
return
}
//Split it by uppercase
l := 0
for s := function; s != ""; s = s[l:] {
l = strings.IndexFunc(s[1:], unicode.IsUpper) + 1
if l <= 0 {
l = len(s)
}
//The 3 conditionals below is my trying to fix the spaced capitalized words
if s[:l] == "I" && len(s) > l+1 && s[:l+1] == "ID" {
//log.Println("Found ID")
l += 2
}
if s[:l] == "M" && len(s) > l+2 && s[:l+2] == "MP3" {
l += 2
}
if s[:l] == "N" && len(s) > l+2 && s[:l+2] == "NPC" {
//log.Println(s[:l+2])
l += 3
}
parts = append(parts, s[:l])
}
return
}

View file

@ -0,0 +1,19 @@
package main
import ()
var adjectives = map[string]string{
"get": "gets",
"send": "sends",
"set": "sets",
"teleport": "teleports",
"is": "is",
"play": "plays",
"add": "adds",
}
var nouns = map[string]string{
"taskid": "[task](Task)",
"account_id": "[account](Task)",
"accountid": "[account](Task)",
}

View file

@ -0,0 +1,665 @@
package main
import (
"bufio"
"fmt"
"io/ioutil"
"log"
"os"
"regexp"
"sort"
"strings"
"time"
"github.com/go-yaml/yaml"
"github.com/pkg/errors"
)
func perlGenerate() (err error) {
//make an outfile to spit out generated markdowns
if err = os.Mkdir("out", 0744); err != nil {
if !os.IsExist(err) {
err = errors.Wrap(err, "Failed to make out dir")
return
}
err = nil
}
//functions hold the final function list, all functions get appended so we can group them by scope
functions := []*API{}
events := []*Event{}
//iterate all perl files
for _, path := range perlPaths {
newFunctions := []*API{}
newEvents := []*Event{}
newFunctions, newEvents, err = perlProcessFile(path)
if err != nil {
err = errors.Wrap(err, "Failed to read file")
return
}
//we append the newFunctions found from processing the file
//into functions, for later grouping/processing
for _, api := range newFunctions {
functions = append(functions, api)
}
for _, event := range newEvents {
events = append(events, event)
}
}
log.Println("loaded", len(functions), "functions")
//functionBuffer is grouped by scope
//I had to do this because not every perl file aligns to scope
sort.Sort(FunctionsByName{functions})
sort.Sort(EventsByName{events})
functionBuffer, eventBuffer, sampleYaml, err := perlGroupAndPrepareFunctions(functions, events)
if err != nil {
err = errors.Wrap(err, "Failed to prepare and group functions")
return
}
if err = perlWriteWikiPages(functionBuffer, eventBuffer, sampleYaml, events); err != nil {
err = errors.Wrap(err, "Failed to write wiki pages")
return
}
return
}
func perlProcessFile(path *path) (functions []*API, events []*Event, err error) {
var index int
inFile, err := os.Open(path.Name)
if err != nil {
err = errors.Wrap(err, "Failed to open file")
return
}
defer inFile.Close()
scanner := bufio.NewScanner(inFile)
scanner.Split(bufio.ScanLines)
arguments := map[string][]*Argument{}
reg, err := regexp.Compile(`\]+|\[+|\?+`)
if err != nil {
err = errors.Wrap(err, "Failed to compile regex")
return
}
regType, err := regexp.Compile(`(unsigned long|long|int32|bool|uint[0-9]+|int|auto|float|unsigned int|char[ \*]).+([. a-zA-Z]+=)`)
if err != nil {
err = errors.Wrap(err, "Failed to compile type regex")
return
}
lastArguments := []*Argument{}
lastAPI := &API{}
//since events are in cases
lastEvents := []*Event{}
lineNum := 0
for scanner.Scan() {
lineNum++
key := ""
line := scanner.Text()
if len(line) < 1 {
continue
}
//See if line has any event info
index = strings.Index(line, "case EVENT")
if index > 0 {
if len(lastEvents) > 0 && len(lastEvents[0].Arguments) > 0 {
for _, event := range lastEvents {
events = append(events, event)
}
//flush
lastEvents = []*Event{}
}
event := &Event{}
event.Name = line[index+5:]
index = strings.Index(event.Name, ":")
if index > 0 {
event.Name = event.Name[0:index]
}
lastEvents = append(lastEvents, event)
continue
}
index = strings.Index(line, `ExportVar(package_name.c_str(), "`)
if index > 0 {
arg := &Argument{}
arg.Name = line[index+33:]
index = strings.Index(arg.Name, `"`)
if index > 0 {
arg.Name = arg.Name[0:index]
}
for _, event := range lastEvents {
event.Arguments = append(event.Arguments, arg)
}
continue
}
//see if the line contains any valid return types
for key, val := range perlReturnTypes {
if strings.Contains(line, key) {
lastAPI.Return = val
break
}
}
if len(lastArguments) > 0 { //existing args to parse
for i, argument := range lastArguments {
key = fmt.Sprintf("ST(%d)", i)
if strings.Contains(line, key) {
if strings.Contains(lastAPI.Function, "attacknpc") {
log.Println("found argument for", i, lastAPI.Function)
}
if argument.Type != "" {
continue
}
match := regType.FindStringSubmatch(line)
if len(match) < 2 {
continue
}
//key = `int`
//function = line[strings.Index(line, key)+len(key):]
newType := ""
v := strings.TrimSpace(match[1])
switch v {
case "int":
newType = "int"
case "int32":
newType = "int"
case "float":
newType = "float"
case "unsigned int":
newType = "uint"
case "uint32":
newType = "uint"
case "uint8":
newType = "uint"
case "uint":
newType = "uint"
case "bool":
newType = "bool"
case "uint16":
newType = "uint"
case "long":
newType = "long"
case "unsigned long":
newType = "unsigned long"
default:
if strings.Contains(v, "auto") {
if strings.Contains(line, "glm::vec4") {
newType = "float"
}
}
if strings.Contains(v, "char") {
newType = "string"
}
}
if newType == "" {
log.Printf(`Unknown type: "%s" on line %d`, newType, lineNum)
}
//log.Println("Found arg type", newType, "on index", i, argument.Name)
lastArguments[i].Type = newType
}
}
}
function := ""
argLine := ""
args := []string{}
//Find line
key = `Perl_croak(aTHX_ "Usage:`
index = strings.Index(line, key)
if index > 0 {
function = line[index+len(key):]
}
for _, argument := range lastArguments {
arguments[argument.Name] = append(arguments[argument.Name], argument)
}
lastArguments = []*Argument{}
//Trim off the endings
key = `");`
if strings.Contains(function, key) {
function = function[0:strings.Index(function, key)]
}
//Strip out the arguments
key = `(`
if strings.Contains(function, key) {
argLine = function[strings.Index(function, key)+len(key):]
function = function[0:strings.Index(function, key)]
key = `)`
if strings.Contains(argLine, key) {
argLine = argLine[:strings.Index(argLine, key)]
}
key = `=`
if strings.Contains(argLine, key) {
argLine = argLine[:strings.Index(argLine, key)]
}
}
key = `,`
argLine = strings.TrimSpace(argLine)
if strings.Contains(argLine, key) { //there is a , in the argument list
args = strings.Split(argLine, key)
} else { //no , in argument list, look for single one
if len(argLine) > 0 {
args = []string{
argLine,
}
}
}
if len(function) < 1 {
continue
}
function = strings.TrimSpace(function)
newArgs := []string{}
for j, _ := range args {
args[j] = strings.TrimSpace(args[j])
if len(args[j]) == 0 {
continue
}
newArgs = append(newArgs, args[j])
}
if lastAPI != nil {
isNew := true
for _, oldFunc := range functions {
if oldFunc.Function == lastAPI.Function {
if len(oldFunc.Arguments) > len(lastAPI.Arguments) {
//log.Println("Skipping", oldFunc, "since less arguments")
isNew = false
}
}
}
if isNew {
functions = append(functions, lastAPI)
}
}
lastAPI = &API{
Function: function,
}
for _, arg := range newArgs {
isOptional := false
if strings.Contains(arg, "]") {
isOptional = true
}
arg = reg.ReplaceAllString(arg, "")
argType, _ := perlKnownTypes[arg]
argument := &Argument{
Name: arg,
Type: argType,
API: lastAPI,
Optional: isOptional,
}
lastArguments = append(lastArguments, argument)
}
lastAPI.Arguments = lastArguments
}
if len(lastEvents) > 0 {
for _, event := range lastEvents {
events = append(events, event)
}
}
fmt.Printf("==========%s==========\n", path.Scope)
foundCount := 0
failCount := 0
for key, val := range arguments {
if key == "THIS" {
continue
}
isMissing := false
line := ""
line = fmt.Sprintf("%s used by %d functions:", key, len(val))
for _, fnc := range val {
line += fmt.Sprintf("%s(%s %s), ", fnc.API.Function, fnc.Type, key)
if fnc.Type == "" {
isMissing = true
}
}
if isMissing {
fmt.Println(line)
failCount++
} else {
foundCount++
}
}
log.Println(foundCount, "functions properly identified,", failCount, "have errors")
for _, api := range functions {
if len(api.Function) == 0 {
continue
}
api.Function = strings.TrimSpace(api.Function)
if api.Function == `%s` {
continue
}
if api.Return == "" {
api.Return = "void"
}
if path.Replace == "" {
path.Replace = strings.ToLower(path.Scope)
}
//Figure out object
if path.Scope != "General" {
api.Object = "$" + strings.ToLower(api.Function)
if strings.Contains(strings.ToLower(api.Object), "hate") {
fmt.Println(api.Object)
}
api.Object = strings.Replace(api.Object, "entitylist", "entity_list", -1)
api.Object = strings.Replace(api.Object, "hateentry", "hate_entry", -1)
index = strings.Index(api.Object, "::")
if index > 0 {
api.Object = api.Object[0:index] + "->"
}
index = strings.Index(api.Object, "->")
if index > 0 {
api.Object = api.Object[0 : index+2]
}
/*if strings.Contains(api.Object, path.Scope+"::") {
api.Object = strings.Replace(api.Object, path.Scope+"::", strings.ToLower(path.Scope)+"->", -1)
api.Object = "$" + strings.TrimSpace(api.Object)
} else {
api.Object = "$" + strings.TrimSpace(strings.ToLower(api.Object)) + "->"
}
if strings.Contains(api.Object, "::") {
api.Object = strings.Replace(api.Object, "::", "->", -1)
}*/
} else {
if !strings.Contains(api.Object, path.Replace) {
api.Object = "quest::"
}
}
//Strip out object from function
if strings.Contains(api.Function, "::") {
api.Function = api.Function[strings.Index(api.Function, "::")+2:]
}
if strings.Contains(api.Function, "->") {
api.Function = api.Function[0:strings.Index(api.Function, "->")]
}
if strings.Contains(api.Function, "$") {
api.Function = api.Function[1:]
}
//Figure out scope
index = strings.Index(api.Object, "::")
if index > 0 {
api.Scope = api.Object[0:index]
}
index = strings.Index(api.Object, "->")
if index > 0 {
api.Scope = api.Object[0:index]
}
if strings.Contains(api.Scope, "$") {
api.Scope = api.Scope[strings.Index(api.Scope, "$")+1:]
}
api.Scope = strings.Title(api.Scope)
//manually override weirdly spelled ones
if strings.ToLower(api.Scope) == "entity_list" {
api.Scope = "EntityList"
}
if strings.ToLower(api.Scope) == "hate_entry" {
api.Scope = "HateEntry"
}
if strings.ToLower(api.Scope) == "npc" {
api.Scope = "NPC"
}
}
return
}
func perlGroupAndPrepareFunctions(functions []*API, events []*Event) (functionBuffer map[string]string, eventBuffer map[string]string, sampleYaml *RootYaml, err error) {
functionBuffer = make(map[string]string)
eventBuffer = make(map[string]string)
sampleYaml = &RootYaml{}
for _, event := range events {
line := fmt.Sprintf("* [[%s|Perl-%s]]\n", event.Name, event.Name)
eventBuffer[""] += line
}
//iterate functions for final output
for _, api := range functions {
if api.Scope == "" {
continue
}
if api.Summary == "" {
api.Summary = "Some summary of function here"
}
//prepare a new line
line := "* [["
line += fmt.Sprintf("%s%s(", api.Object, api.Function)
//build out arguments
for _, argument := range api.Arguments {
if strings.TrimSpace(argument.Name) == "THIS" {
continue
}
if len(strings.TrimSpace(argument.Type)) == 0 {
line += fmt.Sprintf("%s, ", argument.Name)
} else {
line += fmt.Sprintf("%s %s, ", argument.Type, argument.Name)
}
}
//if arguments were shown, remove last ,
if strings.Contains(line, ",") {
line = line[0 : len(line)-2]
}
//enclose function with a comment of return type
line += fmt.Sprintf(") # %s", api.Return)
line += fmt.Sprintf("|Perl-%s-%s]]\n", api.Scope, strings.Title(api.Function))
//add to functionBuffer based on scope
functionBuffer[api.Scope] += line
isScoped := false
for _, scope := range sampleYaml.Scopes {
if scope.Name == api.Scope {
isScoped = true
}
}
if !isScoped {
sampleYaml.Scopes = append(sampleYaml.Scopes, &ScopeYaml{
Name: api.Scope,
})
}
for _, scope := range sampleYaml.Scopes {
if scope.Name == api.Scope {
isExists := false
for _, function := range scope.Functions {
if function.Name == api.Function {
isExists = true
break
}
}
if !isExists {
summary := ""
adj := getAdjective(api.Function)
noun := getNoun(api.Function)
parts := splitFunctionParts(api.Function)
if len(parts) > 0 && len(adj) > 0 {
summary = fmt.Sprintf("%s a %s ", adj, strings.ToLower(scope.Name))
for _, part := range parts {
summary += fmt.Sprintf("%s ", strings.ToLower(part))
}
summary = summary[0:len(summary)-1] + "."
} else if len(adj) > 0 && len(noun) > 0 {
summary = fmt.Sprintf("%s a %s's %s.", adj, strings.ToLower(scope.Name), noun)
} else {
summary = fmt.Sprintf("%s.", api.Function)
}
arguments := ""
argCount := 0
examplePrep := ""
exampleArgs := ""
for _, argument := range api.Arguments {
if argument.Name == "THIS" {
continue
}
exampleType := "1"
if argument.Type == "string" {
exampleType = `"test"`
}
if strings.Contains(argument.Name, " ") { //this is a bug?
//fmt.Println("Argument", argument.Name, "in", api.Scope, "for", api.Function, "is jacked up?")
argument.Name = argument.Name[strings.Index(argument.Name, " ")+1:]
}
if strings.TrimSpace(argument.Name) != "..." {
examplePrep += fmt.Sprintf("my $%s = %s;\n", argument.Name, exampleType)
exampleArgs += fmt.Sprintf("$%s, ", argument.Name)
} else {
exampleArgs += fmt.Sprintf("%s, ", argument.Name)
}
argCount++
arguments += fmt.Sprintf("%s|%s|%s\n", argument.Name, argument.Type, "")
}
if argCount > 0 {
arguments = "**Name**|**Type**|**Description**\n:---|:---|:---\n" + arguments
exampleArgs = exampleArgs[0 : len(exampleArgs)-2]
}
example := fmt.Sprintf("\n```perl\n%s\n%s%s(%s); # Returns %s\n```", examplePrep, api.Object, api.Function, exampleArgs, api.Return)
if api.Return != "void" {
example = fmt.Sprintf("\n```perl\n%smy $val = %s%s(%s);\nquest::say($val); # Returns %s\n```", examplePrep, api.Object, api.Function, exampleArgs, api.Return)
}
function := &FuncYaml{
Name: api.Function,
Summary: summary,
Example: example,
Argument: arguments,
}
scope.Functions = append(scope.Functions, function)
}
}
}
}
return
}
func perlWriteWikiPages(functionBuffer map[string]string, eventBuffer map[string]string, sampleYaml *RootYaml, events []*Event) (err error) {
for _, v := range eventBuffer {
v += fmt.Sprintf("\n\nGenerated On %s", time.Now().Format(time.RFC3339))
if err = ioutil.WriteFile("out/Perl-Events.md", []byte(v), 0744); err != nil {
err = errors.Wrap(err, "Failed to write file")
log.Println(err)
}
}
for _, event := range events {
argLine := ""
buf := fmt.Sprintf("%s\n", event.Name)
if len(event.Arguments) > 0 {
buf += fmt.Sprintf("### Exports\n**Name**|**Type**|**Description**\n:-----|:-----|:-----\n")
for _, arg := range event.Arguments {
if arg.Name == "" {
continue
}
if arg.Type == "" {
arg.Type = "int"
}
buf += fmt.Sprintf("%s|%s|\n", arg.Name, arg.Type)
argLine += fmt.Sprintf(" quest::say($%s); # returns %s\n", arg.Name, arg.Type)
}
}
buf += fmt.Sprintf("### Example\n")
buf += fmt.Sprintf("```perl\nsub %s {\n%s}\n```", event.Name, argLine)
buf += fmt.Sprintf("\n\nGenerated On %s", time.Now().Format(time.RFC3339))
err = ioutil.WriteFile(fmt.Sprintf("out/Perl-%s.md", strings.Title(event.Name)), []byte(buf), 0744)
if err != nil {
err = errors.Wrapf(err, "Failed to write file %s", event.Name)
return
}
}
//iterate functionBuffer, which is grouped by scope
for k, v := range functionBuffer {
if k == "" {
continue
}
v += fmt.Sprintf("\n\nGenerated On %s", time.Now().Format(time.RFC3339))
//log.Println(k)
//v = fmt.Sprintf("**Function**|**Summary**\n:-----|:-----\n%s", v)
if err = ioutil.WriteFile("out/Perl-"+strings.Title(k)+".md", []byte(v), 0744); err != nil {
err = errors.Wrap(err, "Failed to write file")
log.Println(err)
}
}
//write new example functions
sData, err := yaml.Marshal(sampleYaml)
if err != nil {
err = errors.Wrap(err, "Failed to marshal sample")
return
}
if err = ioutil.WriteFile("perlsample.yml", []byte(sData), 0744); err != nil {
err = errors.Wrap(err, "Failed to write sample")
return
}
fmt.Println("Found", len(sampleYaml.Scopes), "scopes")
for _, scope := range sampleYaml.Scopes {
fmt.Println("Found", len(scope.Functions), "functions in", scope.Name)
for _, function := range scope.Functions {
buf := fmt.Sprintf("%s\n", function.Summary)
if len(function.Argument) > 0 {
buf += fmt.Sprintf("### Arguments\n%s\n", function.Argument)
}
buf += fmt.Sprintf("### Example\n%s\n", function.Example)
buf += fmt.Sprintf("\n\nGenerated On %s", time.Now().Format(time.RFC3339))
err = ioutil.WriteFile(fmt.Sprintf("out/Perl-%s-%s.md", strings.Title(scope.Name), function.Name), []byte(buf), 0744)
if err != nil {
err = errors.Wrapf(err, "Failed to write file %s %s", scope.Name, function.Name)
return
}
}
}
return
}

View file

@ -0,0 +1,322 @@
package main
import ()
//perlReturnTypes are mapped to identify what sort of return the script does
var perlReturnTypes = map[string]string{
"boolSV(": "bool",
"PUSHu(": "uint",
"PUSHi(": "int",
"sv_setpv(": "string",
"PUSHn(": "double",
"XPUSHs": "array",
}
//Paths are where every perl file is at
var perlPaths = []*path{
{
Name: "../../../zone/embparser_api.cpp",
Scope: "General",
Replace: "quest",
},
{
Name: "../../../zone/perl_client.cpp",
Scope: "Client",
},
{
Name: "../../../zone/perl_doors.cpp",
Scope: "Doors",
Replace: "door",
},
{
Name: "../../../zone/perl_entity.cpp",
Scope: "EntityList",
},
{
Name: "../../../zone/perl_groups.cpp",
Scope: "Group",
},
{
Name: "../../../zone/perl_hateentry.cpp",
Scope: "HateEntry",
},
{
Name: "../../../zone/perl_mob.cpp",
Scope: "Mob",
},
{
Name: "../../../zone/perl_npc.cpp",
Scope: "NPC",
},
{
Name: "../../../zone/perl_object.cpp",
Scope: "Object",
},
{
Name: "../../../zone/perl_perlpacket.cpp",
Scope: "PerlPacket",
Replace: "packet",
},
{
Name: "../../../zone/perl_player_corpse.cpp",
Scope: "Corpse",
},
{
Name: "../../../zone/perl_QuestItem.cpp",
Scope: "QuestItem",
},
{
Name: "../../../zone/perl_raids.cpp",
Scope: "Raid",
},
{
Name: "../../../zone/embparser.cpp",
Scope: "Event",
},
}
//These are known parameter types
var perlKnownTypes = map[string]string{
"activity_id": "uint",
"alt_mode": "bool",
"anim_num": "int",
"augment_id": "int",
"best_z": "float",
"buttons": "int",
"byte_position": "uint",
"channel_id": "int",
"char_id": "int",
"charges": "int",
"class_id": "int",
"class_name": "string",
"client": "client",
"client_name": "string",
"color": "int",
"color_id": "int",
"condition_id": "int",
"copper": "int",
"cost": "int",
"count": "int",
"debug_level": "int",
"decay_time": "int",
"dest_heading": "float",
"dest_x": "float",
"dest_y": "float",
"dest_z": "float",
"distance": "int",
"door_id": "int",
"duration": "int",
"effect_id": "int",
"elite_material_id": "int",
"enforce_level_requirement": "bool",
"equip_slot_id": "int",
"exp": "int",
"explore_id": "uint",
"faction_value": "int",
"fade_in": "int",
"fade_out": "int",
"fadeout": "uint",
"firstname": "string",
"float_value": "float",
"format": "string",
"from": "string",
"gender_id": "int",
"gold": "int",
"grid_id": "int",
"group_id": "int",
"guild_rank_id": "int",
"heading": "float",
"hero_forge_model_id": "int",
"icon_id": "int",
"iFromDB": "bool",
"ignore_quest_update": "bool",
"in_lastname": "string",
"index": "int",
"instance_id": "int",
"int_penalty": "int",
"int_unused": "int",
"int_value": "int",
"is_enabled": "bool",
"is_spell": "bool",
"is_strict": "bool",
"iSendToSelf": "int",
"item_id": "int",
"key": "string",
"language_id": "int",
"lastname": "string",
"leader_name": "string",
"length": "int",
"level": "int",
"link_name": "string",
"loot_slot": "int",
"macro_id": "int",
"max_level": "int",
"max_x": "float",
"max_y": "float",
"max_z": "float",
"message": "string",
"milliseconds": "int",
"min_level": "int",
"min_x": "float",
"min_y": "float",
"min_z": "float",
"mob": "mob",
"mob_caster": "mob",
"mob_other": "mob",
"mob_sender": "mob",
"name": "string",
"new_hour": "int",
"new_min": "int",
"node1": "int",
"node2": "int",
"npc_id": "int",
"npc_type_id": "int",
"number": "int",
"object_id": "int",
"object_type": "int",
"op_code": "string",
"options": "int",
"part13": "float",
"part19": "float",
"platinum": "int",
"popup_id": "int",
"priority": "int",
"quantity": "int",
"race_id": "int",
"remove_item": "bool",
"requested_id": "int",
"reset_base": "bool",
"reset_state": "bool",
"saveguard": "bool",
"scale_factor": "float",
"seconds": "int",
"send_to_world": "bool",
"signal_id": "int",
"silent": "bool",
"silver": "int",
"size": "int",
"slot": "int",
"spell_id": "int",
"stat_id": "int",
"str_value": "string",
"subject": "string",
"target_enum": "string",
"target_id": "int",
"task": "int",
"task_id": "uint",
"task_id1": "int",
"task_id10": "int",
"task_id2": "int",
"task_set": "int",
"taskid": "int",
"taskid1": "int",
"taskid2": "int",
"taskid3": "int",
"taskid4": "int",
"teleport": "int",
"temp": "int",
"texture_id": "int",
"theme_id": "int",
"type": "int",
"update_world": "int",
"updated_time_till_repop": "uint",
"value": "int",
"version": "int",
"wait_ms": "int",
"window_title": "string",
"x": "float",
"y": "float",
"z": "float",
"zone_id": "int",
"zone_short": "string",
`task_id%i`: "int",
}
var perlKnownEventArguments = map[string]string{}
var perlKnownEventTypes = map[string]string{
"activity_id": "int", //", sep.arg[1]);
"caster_id": "int", //", extradata);
"charid": "int", //", char_id);
"class": "int", //", GetClassIDName(mob->GetClass()));
"clicker_id": "int", //", extradata);
"combat_state": "int", //", data);
"copper": "int", //", GetVar("copper." + std::string(itoa(objid))).c_str());
"corpse": "int", //", sep.arg[2]);
"data": "string", //", "0");
"donecount": "int", //", sep.arg[0]);
"doorid": "int", //", data);
"env_damage": "int", //", sep.arg[0]);
"env_damage_type": "int", //", sep.arg[1]);
"env_final_damage": "int", //", sep.arg[2]);
"faction": "int", //", itoa(fac));
"fished_item": "int", //", extradata);
"foraged_item": "int", //", extradata);
"gold": "int", //", GetVar("gold." + std::string(itoa(objid))).c_str());
"grouped": "int", //", mob->IsGrouped());
"h": "int", //", npcmob->GetHeading() );
"hate_state": "int", //", data);
"hpevent": "int", //", "-1");
"hpratio": "int", //",npcmob->GetHPRatio());
"inchpevent": "int", //", "-1");
"instanceid": "int", //", zone->GetInstanceID());
"instanceversion": "int", //", zone->GetInstanceVersion());
"itemid": "int", //", extradata);
"itemname": "string", //", item_inst->GetItem()->Name);
"killed": "int", //", mob->GetNPCTypeID());
"killed_npc_id": "int", //", sep.arg[4]);
"killer_damage": "int", //", sep.arg[1]);
"killer_id": "int", //", sep.arg[0]);
"killer_skill": "int", //", sep.arg[3]);
"killer_spell": "int", //", sep.arg[2]);
"langid": "int", //", "0");
"looted_charges": "int", //", sep.arg[1]);
"looted_id": "int", //", sep.arg[0]);
"mlevel": "int", //", npcmob->GetLevel());
"mname": "string", //", npcmob->GetName());
"mobid": "int", //", npcmob->GetID());
"name": "string", //", mob->GetName());
"objectid": "int", //", data);
"option": "int", //", data);
"picked_up_entity_id": "int", //", extradata);
"picked_up_id": "int", //", data);
"platinum": "int", //", GetVar("platinum." + std::string(itoa(objid))).c_str());
"popupid": "int", //", data);
"quantity": "int", //", item_inst->IsStackable() ? item_inst->GetCharges() : 1);
"race": "int", //", GetRaceIDName(mob->GetRace()));
"raided": "int", //", mob->IsRaidGrouped());
"recipe_id": "int", //", extradata);
"recipe_name": "string", //", data);
"resurrect": "int", //", extradata);
"signal": "int", //", data);
"silver": "int", //", GetVar("silver." + std::string(itoa(objid))).c_str());
"skill_id": "int", //", sep.arg[0]);
"skill_level": "int", //", sep.arg[1]);
"slotid": "int", //", extradata);
"spawned_entity_id": "int", //", sep.arg[0]);
"spawned_npc_id": "int", //", sep.arg[1]);
"spell_id": "int", //", data);
"status": "int", //", mob->CastToClient()->Admin());
"target_zone_id": "int", //", data);
"targetid": "int", //", npcmob->GetTarget()->GetID());
"targetname": "string", //", npcmob->GetTarget()->GetName());
"task_id": "int", //", data);
"text": "string", //", data);
"timer": "int", //", data);
"uguild_id": "int", //", mob->CastToClient()->GuildID());
"uguildrank": "int", //", mob->CastToClient()->GuildRank());
"ulevel": "int", //", mob->GetLevel());
"userid": "int", //", mob->GetID());
"version": "int", //", zone->GetInstanceVersion());
"wp": "int", //", data);
"x": "int", //", npcmob->GetX() );
"y": "int", //", npcmob->GetY() );
"z": "int", //", npcmob->GetZ() );
"zonehour": "int", //", eqTime.hour - 1);
"zoneid": "int", //", zone->GetZoneID());
"zoneln": "string", //", zone->GetLongName());
"zonemin": "int", //", eqTime.minute);
"zonesn": "string", //", zone->GetShortName());
"zonetime": "int", //", (eqTime.hour - 1) * 100 + eqTime.minute);
"zoneweather": "int", //", zone->zone_weather);
}

File diff suppressed because it is too large Load diff

View file

@ -1,355 +0,0 @@
//Parses perl scripts
package main
import (
"bufio"
"fmt"
"log"
"os"
"regexp"
"strings"
"github.com/pkg/errors"
)
func main() {
path := "../../../zone/embparser_api.cpp"
err := readFile(path)
if err != nil {
log.Panicf("Failed to read file: %s", err.Error())
}
}
type API struct {
Function string
Arguments []*Argument
}
type Argument struct {
Name string
Type string
API *API
}
func readFile(path string) (err error) {
inFile, err := os.Open(path)
if err != nil {
err = errors.Wrap(err, "Failed to open file")
}
defer inFile.Close()
scanner := bufio.NewScanner(inFile)
scanner.Split(bufio.ScanLines)
arguments := map[string][]*Argument{}
functions := []*API{}
reg, err := regexp.Compile(`\]+|\[+|\?+|[...]+`)
if err != nil {
err = errors.Wrap(err, "Failed to compile regex")
return
}
regType, err := regexp.Compile(`(unsigned long|long|int32|bool|uint[0-9]+|int|auto|float|unsigned int|char[ \*]).+([. a-zA-Z]+=)`)
if err != nil {
err = errors.Wrap(err, "Failed to compile type regex")
return
}
lastArguments := []*Argument{}
lastAPI := &API{}
lineNum := 0
for scanner.Scan() {
lineNum++
key := ""
line := scanner.Text()
if len(line) < 1 {
continue
}
if len(lastArguments) > 0 { //existing args to parse
for i, argument := range lastArguments {
key = fmt.Sprintf("ST(%d)", i)
if strings.Contains(line, key) {
//We found a definition argument line
if argument.Type != "" {
continue
}
match := regType.FindStringSubmatch(line)
if len(match) < 2 {
continue
}
//key = `int`
//function = line[strings.Index(line, key)+len(key):]
newType := ""
switch v := strings.TrimSpace(match[1]); v {
case "int":
newType = "int"
case "int32":
newType = "int"
case "float":
newType = "float"
case "unsigned int":
newType = "uint"
case "uint32":
newType = "uint"
case "uint8":
newType = "uint"
case "uint":
newType = "uint"
case "bool":
newType = "bool"
case "uint16":
newType = "uint"
case "long":
newType = "long"
case "unsigned long":
newType = "unsigned long"
case "char":
newType = "string"
case "auto":
//Auto is tricky
if strings.Contains(line, "glm::vec4") {
newType = "float"
}
default:
log.Printf(`Unknown type: "%s" on line %d`, v, lineNum)
}
//log.Println("Found arg type", newType, "on index", i, argument.Name)
lastArguments[i].Type = newType
}
}
}
function := ""
argLine := ""
args := []string{}
//Find line
key = `Perl_croak(aTHX_ "Usage:`
if strings.Contains(line, key) {
function = line[strings.Index(line, key)+len(key):]
}
for _, argument := range lastArguments {
arguments[argument.Name] = append(arguments[argument.Name], argument)
}
lastArguments = []*Argument{}
//Trim off the endings
key = `");`
if strings.Contains(function, key) {
function = function[0:strings.Index(function, key)]
}
//Strip out the arguments
key = `(`
if strings.Contains(function, key) {
argLine = function[strings.Index(function, key)+len(key):]
function = function[0:strings.Index(function, key)]
key = `)`
if strings.Contains(argLine, key) {
argLine = argLine[:strings.Index(argLine, key)]
}
key = `=`
if strings.Contains(argLine, key) {
argLine = argLine[:strings.Index(argLine, key)]
}
argLine = reg.ReplaceAllString(argLine, "")
}
key = `,`
argLine = strings.TrimSpace(argLine)
if strings.Contains(argLine, key) {
args = strings.Split(argLine, key)
}
if len(function) < 1 {
continue
}
newArgs := []string{}
for j, _ := range args {
args[j] = strings.TrimSpace(args[j])
if len(args[j]) == 0 {
continue
}
newArgs = append(newArgs, args[j])
}
lastAPI = &API{
Function: function,
}
for _, arg := range newArgs {
argType, _ := knownTypes[arg]
argument := &Argument{
Name: arg,
Type: argType,
API: lastAPI,
}
lastArguments = append(lastArguments, argument)
}
lastAPI.Arguments = lastArguments
functions = append(functions, lastAPI)
}
foundCount := 0
failCount := 0
for key, val := range arguments {
isMissing := false
line := ""
line = fmt.Sprintf("%s used by %d functions:", key, len(val))
for _, fnc := range val {
line += fmt.Sprintf("%s(%s %s), ", fnc.API.Function, fnc.Type, key)
if fnc.Type == "" {
isMissing = true
}
}
if isMissing {
fmt.Println(line)
failCount++
} else {
foundCount++
}
}
log.Println(foundCount, "functions properly identified,", failCount, "have errors")
line := ""
for _, api := range functions {
line += fmt.Sprintf("void %s(", strings.TrimSpace(api.Function))
for _, argument := range api.Arguments {
line += fmt.Sprintf("%s %s, ", argument.Type, argument.Name)
}
if len(api.Arguments) > 0 {
line = line[0 : len(line)-2]
}
line += ")\n"
}
fmt.Println(line)
return
}
var knownTypes = map[string]string{
"activity_id": "uint",
"alt_mode": "bool",
"anim_num": "int",
"best_z": "float",
"buttons": "int",
"channel_id": "int",
"char_id": "int",
"charges": "int",
"class_id": "int",
"client_name": "string",
"color": "int",
"color_id": "int",
"condition_id": "int",
"copper": "int",
"count": "int",
"debug_level": "int",
"decay_time": "int",
"dest_heading": "float",
"dest_x": "float",
"dest_y": "float",
"dest_z": "float",
"distance": "int",
"door_id": "int",
"doorid": "uint",
"duration": "int",
"effect_id": "int",
"elite_material_id": "int",
"enforce_level_requirement": "bool",
"explore_id": "uint",
"faction_value": "int",
"fade_in": "int",
"fade_out": "int",
"fadeout": "uint",
"firstname": "string",
"from": "string",
"gender_id": "int",
"gold": "int",
"grid_id": "int",
"guild_rank_id": "int",
"heading": "float",
"hero_forge_model_id": "int",
"ignore_quest_update": "bool",
"instance_id": "int",
"int_unused": "int",
"int_value": "int",
"is_enabled": "bool",
"is_strict": "bool",
"item_id": "int",
"key": "string",
"language_id": "int",
"lastname": "string",
"leader_name": "string",
"level": "int",
"link_name": "string",
"macro_id": "int",
"max_level": "int",
"max_x": "float",
"max_y": "float",
"max_z": "float",
"message": "string",
"milliseconds": "int",
"min_level": "int",
"min_x": "float",
"min_y": "float",
"min_z": "float",
"name": "string",
"new_hour": "int",
"new_min": "int",
"node1": "int",
"node2": "int",
"npc_id": "int",
"npc_type_id": "int",
"object_type": "int",
"options": "int",
"platinum": "int",
"popup_id": "int",
"priority": "int",
"quantity": "int",
"race_id": "int",
"remove_item": "bool",
"requested_id": "int",
"reset_base": "bool",
"saveguard": "bool",
"seconds": "int",
"send_to_world": "bool",
"signal_id": "int",
"silent": "bool",
"silver": "int",
"size": "int",
"stat_id": "int",
"str_value": "string",
"subject": "string",
"target_enum": "string",
"target_id": "int",
"task": "int",
"task_id": "uint",
"task_id1": "int",
"task_id10": "int",
"task_id2": "int",
"task_set": "int",
"taskid": "int",
"taskid1": "int",
"taskid2": "int",
"taskid3": "int",
"taskid4": "int",
"teleport": "int",
"temp": "int",
"texture_id": "int",
"theme_id": "int",
"update_world": "int",
"updated_time_till_repop": "uint",
"version": "int",
"wait_ms": "int",
"window_title": "string",
"x": "float",
"y": "float",
"z": "float",
"zone_id": "int",
"zone_short": "string",
`task_id%i`: "int",
}

View file

@ -5503,7 +5503,7 @@ XS(XS_Client_Freeze)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Client:Freeze(THIS)");
Perl_croak(aTHX_ "Usage: Client::Freeze(THIS)");
{
Client * THIS;
@ -5526,7 +5526,7 @@ XS(XS_Client_UnFreeze)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Client:UnFreeze(THIS)");
Perl_croak(aTHX_ "Usage: Client::UnFreeze(THIS)");
{
Client * THIS;
@ -6212,7 +6212,7 @@ XS(XS_Client_SendSpellAnim)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: SendSpellAnim(uint16 spell_id, uint32 seq)");
Perl_croak(aTHX_ "Usage: Client::SendSpellAnim(uint16 spell_id, uint32 seq)");
{
Client * THIS;
uint16 targetid = (uint16)SvUV(ST(1));
@ -6316,7 +6316,7 @@ XS(XS_Client_CalcEXP)
{
dXSARGS;
if (items < 1 || items > 2)
Perl_croak(aTHX_ "Usage: CalcEXP(THIS, uint8 conlevel)");
Perl_croak(aTHX_ "Usage: Client::CalcEXP(THIS, uint8 conlevel)");
{
Client * THIS;
uint8 conlevel = 0xFF;
@ -6394,7 +6394,7 @@ XS(XS_Client_GetMoney)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: GetMoney(THIS, type, subtype)");
Perl_croak(aTHX_ "Usage: Client::GetMoney(THIS, type, subtype)");
{
Client* THIS;
uint32 RETVAL;
@ -6422,7 +6422,7 @@ XS(XS_Client_GetAccountAge);
XS(XS_Client_GetAccountAge) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: GetAccountAge(THIS)");
Perl_croak(aTHX_ "Usage: Client::GetAccountAge(THIS)");
{
Client* THIS;
int RETVAL;

View file

@ -7413,7 +7413,7 @@ XS(XS_Mob_GetGlobal)
{
dXSARGS;
if (items < 2)
Perl_croak(aTHX_ "Usage: GetGlobal(THIS, varname)");
Perl_croak(aTHX_ "Usage: Mob::GetGlobal(THIS, varname)");
{
Mob* THIS;
Const_char* varname = (Const_char*)SvPV_nolen(ST(1));
@ -7444,7 +7444,7 @@ XS(XS_Mob_SetGlobal)
{
dXSARGS;
if (items < 5 || items > 6)
Perl_croak(aTHX_ "Usage: SetGlobal(THIS, varname, newvalue, options, duration, other=nullptr)");
Perl_croak(aTHX_ "Usage: Mob::SetGlobal(THIS, varname, newvalue, options, duration, other=nullptr)");
{
Mob * THIS;
char * varname = (char *)SvPV_nolen(ST(1));
@ -7483,7 +7483,7 @@ XS(XS_Mob_TarGlobal)
{
dXSARGS;
if (items != 7)
Perl_croak(aTHX_ "Usage: TarGlobal(THIS, varname, value, duration, npcid, charid, zoneid)");
Perl_croak(aTHX_ "Usage: Mob::TarGlobal(THIS, varname, value, duration, npcid, charid, zoneid)");
{
Mob * THIS;
char * varname = (char *)SvPV_nolen(ST(1));
@ -7512,7 +7512,7 @@ XS(XS_Mob_DelGlobal)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: DelGlobal(THIS, varname)");
Perl_croak(aTHX_ "Usage: Mob::DelGlobal(THIS, varname)");
{
Mob * THIS;
char * varname = (char *)SvPV_nolen(ST(1));
@ -7680,7 +7680,7 @@ XS(XS_Mob_IsRunning)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Mob:::IsRunning(THIS)");
Perl_croak(aTHX_ "Usage: Mob::IsRunning(THIS)");
{
Mob * THIS;
bool RETVAL;

View file

@ -228,7 +228,7 @@ XS(XS_Object_SetID)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Object::SetID(THIS, set_id)");
Perl_croak(aTHX_ "Usage: Object::SetID(THIS, object_id)");
{
Object * THIS;
uint16 set_id = (uint16)SvUV(ST(1));
@ -539,7 +539,7 @@ XS(XS_Object_SetIcon)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Object::SetIcon(THIS, icon)");
Perl_croak(aTHX_ "Usage: Object::SetIcon(THIS, icon_id)");
{
Object * THIS;
uint32 icon = (uint32)SvUV(ST(1));
@ -591,7 +591,7 @@ XS(XS_Object_SetItemID)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Object::SetItemID(THIS, itemid)");
Perl_croak(aTHX_ "Usage: Object::SetItemID(THIS, item_id)");
{
Object * THIS;
uint32 itemid = (uint32)SvUV(ST(1));
@ -641,7 +641,7 @@ XS(XS_Object_SetX)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Object::SetX(THIS, XPos)");
Perl_croak(aTHX_ "Usage: Object::SetX(THIS, x)");
{
Object * THIS;
float pos = (float)SvNV(ST(1));
@ -665,7 +665,7 @@ XS(XS_Object_SetY)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Object::SetY(THIS, YPos)");
Perl_croak(aTHX_ "Usage: Object::SetY(THIS, y)");
{
Object * THIS;
float pos = (float)SvNV(ST(1));
@ -689,7 +689,7 @@ XS(XS_Object_SetZ)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Object::SetZ(THIS, ZPos)");
Perl_croak(aTHX_ "Usage: Object::SetZ(THIS, z)");
{
Object * THIS;
float pos = (float)SvNV(ST(1));
@ -835,7 +835,7 @@ XS(XS_Object_GetEntityVariable)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Object::GetEntityVariable(THIS, id)");
Perl_croak(aTHX_ "Usage: Object::GetEntityVariable(THIS, key)");
{
Object * THIS;
Const_char *id = SvPV_nolen(ST(1));
@ -862,7 +862,7 @@ XS(XS_Object_EntityVariableExists)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Object::EntityVariableExists(THIS, id)");
Perl_croak(aTHX_ "Usage: Object::EntityVariableExists(THIS, message)");
{
Object * THIS;
Const_char *id = SvPV_nolen(ST(1));
@ -889,7 +889,7 @@ XS(XS_Object_SetEntityVariable)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: Object::SetEntityVariable(THIS, id, var)");
Perl_croak(aTHX_ "Usage: Object::SetEntityVariable(THIS, key, message)");
{
Object * THIS;
Const_char *id = SvPV_nolen(ST(1));
@ -1016,7 +1016,7 @@ XS(XS_Object_SetTiltX)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Object::SetTiltX(THIS, pos)");
Perl_croak(aTHX_ "Usage: Object::SetTiltX(THIS, x)");
{
Object * THIS;
float pos = (float)SvNV(ST(1));
@ -1040,7 +1040,7 @@ XS(XS_Object_SetTiltY)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Object::SetTiltY(THIS, pos)");
Perl_croak(aTHX_ "Usage: Object::SetTiltY(THIS, y)");
{
Object * THIS;
float pos = (float)SvNV(ST(1));

View file

@ -46,7 +46,7 @@ XS(XS_PerlPacket_new)
{
dXSARGS;
if (items < 1 || items > 3)
Perl_croak(aTHX_ "Usage: PerlPacket::new(CLASS, opcode= \"OP_Unknown\", len= 0)");
Perl_croak(aTHX_ "Usage: PerlPacket::new(class_name, op_code= \"OP_Unknown\", length = 0)");
{
char *CLASS = (char *)SvPV_nolen(ST(0));
PerlPacket *RETVAL;
@ -100,7 +100,7 @@ XS(XS_PerlPacket_SetOpcode)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: PerlPacket::SetOpcode(THIS, opcode)");
Perl_croak(aTHX_ "Usage: PerlPacket::SetOpcode(THIS, op_code)");
{
PerlPacket * THIS;
bool RETVAL;
@ -127,7 +127,7 @@ XS(XS_PerlPacket_Resize)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: PerlPacket::Resize(THIS, len)");
Perl_croak(aTHX_ "Usage: PerlPacket::Resize(THIS, length)");
{
PerlPacket * THIS;
uint32 len = (uint32)SvUV(ST(1));
@ -151,7 +151,7 @@ XS(XS_PerlPacket_SendTo)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: PerlPacket::SendTo(THIS, who)");
Perl_croak(aTHX_ "Usage: PerlPacket::SendTo(THIS, client)");
{
PerlPacket * THIS;
Client * who;
@ -230,7 +230,7 @@ XS(XS_PerlPacket_FromArray)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: PerlPacket::FromArray(THIS, numbers, length)");
Perl_croak(aTHX_ "Usage: PerlPacket::FromArray(THIS, int_value, length)");
{
PerlPacket * THIS;
int * numbers;
@ -272,7 +272,7 @@ XS(XS_PerlPacket_SetByte)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: PerlPacket::SetByte(THIS, pos, val)");
Perl_croak(aTHX_ "Usage: PerlPacket::SetByte(THIS, byte_position, int_value)");
{
PerlPacket * THIS;
uint32 pos = (uint32)SvUV(ST(1));
@ -297,7 +297,7 @@ XS(XS_PerlPacket_SetShort)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: PerlPacket::SetShort(THIS, pos, val)");
Perl_croak(aTHX_ "Usage: PerlPacket::SetShort(THIS, byte_position, int_value)");
{
PerlPacket * THIS;
uint32 pos = (uint32)SvUV(ST(1));
@ -322,7 +322,7 @@ XS(XS_PerlPacket_SetLong)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: PerlPacket::SetLong(THIS, pos, val)");
Perl_croak(aTHX_ "Usage: PerlPacket::SetLong(THIS, byte_position, int_value)");
{
PerlPacket * THIS;
uint32 pos = (uint32)SvUV(ST(1));
@ -347,7 +347,7 @@ XS(XS_PerlPacket_SetFloat)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: PerlPacket::SetFloat(THIS, pos, val)");
Perl_croak(aTHX_ "Usage: PerlPacket::SetFloat(THIS, byte_position, float_value)");
{
PerlPacket * THIS;
uint32 pos = (uint32)SvUV(ST(1));
@ -372,7 +372,7 @@ XS(XS_PerlPacket_SetString)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: PerlPacket::SetString(THIS, pos, str)");
Perl_croak(aTHX_ "Usage: PerlPacket::SetString(THIS, byte_position, message)");
{
PerlPacket * THIS;
uint32 pos = (uint32)SvUV(ST(1));
@ -397,7 +397,7 @@ XS(XS_PerlPacket_SetEQ1319)
{
dXSARGS;
if (items != 4)
Perl_croak(aTHX_ "Usage: PerlPacket::SetEQ1319(THIS, pos, part13, part19)");
Perl_croak(aTHX_ "Usage: PerlPacket::SetEQ1319(THIS, byte_position, part13, part19)");
{
PerlPacket * THIS;
uint32 pos = (uint32)SvUV(ST(1));
@ -423,7 +423,7 @@ XS(XS_PerlPacket_SetEQ1913)
{
dXSARGS;
if (items != 4)
Perl_croak(aTHX_ "Usage: PerlPacket::SetEQ1913(THIS, pos, part19, part13)");
Perl_croak(aTHX_ "Usage: PerlPacket::SetEQ1913(THIS, byte_position, part19, part13)");
{
PerlPacket * THIS;
uint32 pos = (uint32)SvUV(ST(1));
@ -449,7 +449,7 @@ XS(XS_PerlPacket_GetByte)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: PerlPacket::GetByte(THIS, pos)");
Perl_croak(aTHX_ "Usage: PerlPacket::GetByte(THIS, byte_position)");
{
PerlPacket * THIS;
uint8 RETVAL;
@ -476,7 +476,7 @@ XS(XS_PerlPacket_GetShort)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: PerlPacket::GetShort(THIS, pos)");
Perl_croak(aTHX_ "Usage: PerlPacket::GetShort(THIS, byte_position)");
{
PerlPacket * THIS;
uint16 RETVAL;
@ -503,7 +503,7 @@ XS(XS_PerlPacket_GetLong)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: PerlPacket::GetLong(THIS, pos)");
Perl_croak(aTHX_ "Usage: PerlPacket::GetLong(THIS, byte_position)");
{
PerlPacket * THIS;
uint32 RETVAL;
@ -530,7 +530,7 @@ XS(XS_PerlPacket_GetFloat)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: PerlPacket::GetFloat(THIS, pos)");
Perl_croak(aTHX_ "Usage: PerlPacket::GetFloat(THIS, byte_position)");
{
PerlPacket * THIS;
float RETVAL;

View file

@ -245,7 +245,7 @@ XS(XS_Corpse_SetDecayTimer)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Corpse::SetDecayTimer(THIS, decaytime)");
Perl_croak(aTHX_ "Usage: Corpse::SetDecayTimer(THIS, decay_time)");
{
Corpse * THIS;
uint32 decaytime = (uint32)SvUV(ST(1));
@ -295,7 +295,7 @@ XS(XS_Corpse_AddItem)
{
dXSARGS;
if (items < 3 || items > 4)
Perl_croak(aTHX_ "Usage: Corpse::AddItem(THIS, itemnum, charges, slot= 0)");
Perl_croak(aTHX_ "Usage: Corpse::AddItem(THIS, item_id, charges, slot= 0)");
{
Corpse * THIS;
uint32 itemnum = (uint32)SvUV(ST(1));
@ -327,7 +327,7 @@ XS(XS_Corpse_GetWornItem)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Corpse::GetWornItem(THIS, equipSlot)");
Perl_croak(aTHX_ "Usage: Corpse::GetWornItem(THIS, equip_slot_id)");
{
Corpse * THIS;
uint32 RETVAL;
@ -354,7 +354,7 @@ XS(XS_Corpse_RemoveItem)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Corpse::RemoveItem(THIS, lootslot)");
Perl_croak(aTHX_ "Usage: Corpse::RemoveItem(THIS, loot_slot)");
{
Corpse * THIS;
uint16 lootslot = (uint16)SvUV(ST(1));
@ -378,7 +378,7 @@ XS(XS_Corpse_SetCash)
{
dXSARGS;
if (items != 5)
Perl_croak(aTHX_ "Usage: Corpse::SetCash(THIS, in_copper, in_silver, in_gold, in_platinum)");
Perl_croak(aTHX_ "Usage: Corpse::SetCash(THIS, copper, silver, gold, platinum)");
{
Corpse * THIS;
uint16 in_copper = (uint16)SvUV(ST(1));
@ -581,7 +581,7 @@ XS(XS_Corpse_Summon)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: Corpse::Summon(THIS, client, spell)");
Perl_croak(aTHX_ "Usage: Corpse::Summon(THIS, client, is_spell)");
{
Corpse * THIS;
Client* client;
@ -615,7 +615,7 @@ XS(XS_Corpse_CastRezz)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: Corpse::CastRezz(THIS, spellid, Caster)");
Perl_croak(aTHX_ "Usage: Corpse::CastRezz(THIS, spell_id, mob_caster)");
{
Corpse * THIS;
uint16 spellid = (uint16)SvUV(ST(1));
@ -672,7 +672,7 @@ XS(XS_Corpse_CanMobLoot)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Corpse::CanMobLoot(THIS, charid)");
Perl_croak(aTHX_ "Usage: Corpse::CanMobLoot(THIS, char_id)");
{
Corpse * THIS;
bool RETVAL;
@ -699,7 +699,7 @@ XS(XS_Corpse_AllowMobLoot)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: Corpse::AllowMobLoot(THIS, them, slot)");
Perl_croak(aTHX_ "Usage: Corpse::AllowMobLoot(THIS, mob, slot)");
{
Corpse * THIS;
Mob * them;
@ -733,7 +733,7 @@ XS(XS_Corpse_AddLooter)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Corpse::AddLooter(THIS, who)");
Perl_croak(aTHX_ "Usage: Corpse::AddLooter(THIS, mob)");
{
Corpse * THIS;
Mob * who;

View file

@ -62,7 +62,7 @@ XS(XS_QuestItem_SetScale)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: QuestItem::SetScale(THIS, scale factor)");
Perl_croak(aTHX_ "Usage: QuestItem::SetScale(THIS, scale_factor)");
{
EQEmu::ItemInstance * THIS;
float Mult;
@ -90,7 +90,7 @@ XS(XS_QuestItem_ItemSay)
{
dXSARGS;
if (items != 2 && items != 3)
Perl_croak(aTHX_ "Usage: QuestItem::ItemSay(THIS, text [, language])");
Perl_croak(aTHX_ "Usage: QuestItem::ItemSay(THIS, message, [language_id])");
{
EQEmu::ItemInstance* THIS;
Const_char* text;

View file

@ -74,7 +74,7 @@ XS(XS_Raid_CastGroupSpell)
{
dXSARGS;
if (items != 4)
Perl_croak(aTHX_ "Usage: Raid::CastGroupSpell(THIS, caster, spellid, gid)");
Perl_croak(aTHX_ "Usage: Raid::CastGroupSpell(THIS, mob_caster, spell_id, group_id)");
{
Raid * THIS;
Mob* caster;
@ -109,7 +109,7 @@ XS(XS_Raid_GroupCount)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Raid::GroupCount(THIS, gid)");
Perl_croak(aTHX_ "Usage: Raid::GroupCount(THIS, group_id)");
{
Raid * THIS;
uint8 RETVAL;
@ -189,7 +189,7 @@ XS(XS_Raid_SplitExp)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: Raid::SplitExp(THIS, exp, other)");
Perl_croak(aTHX_ "Usage: Raid::SplitExp(THIS, exp, mob_other)");
{
Raid * THIS;
uint32 exp = (uint32)SvUV(ST(1));
@ -223,7 +223,7 @@ XS(XS_Raid_GetTotalRaidDamage)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Raid::GetTotalRaidDamage(THIS, other)");
Perl_croak(aTHX_ "Usage: Raid::GetTotalRaidDamage(THIS, mob_other)");
{
Raid * THIS;
uint32 RETVAL;
@ -286,7 +286,7 @@ XS(XS_Raid_BalanceHP)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: Raid::BalanceHP(THIS, penalty, gid)");
Perl_croak(aTHX_ "Usage: Raid::BalanceHP(THIS, int_penalty, group_id)");
{
Raid * THIS;
int32 penalty = (int32)SvUV(ST(1));
@ -338,7 +338,7 @@ XS(XS_Raid_IsGroupLeader)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Raid::IsGroupLeader(THIS, who)");
Perl_croak(aTHX_ "Usage: Raid::IsGroupLeader(THIS, name)");
{
Raid * THIS;
bool RETVAL;
@ -444,7 +444,7 @@ XS(XS_Raid_TeleportGroup)
{
dXSARGS;
if (items != 8)
Perl_croak(aTHX_ "Usage: Raid::TeleportGroup(THIS, sender, zoneID, x, y, z, heading, gid)");
Perl_croak(aTHX_ "Usage: Raid::TeleportGroup(THIS, mob_sender, zone_id, x, y, z, heading, group_id)");
{
Raid * THIS;
Mob* sender;
@ -483,7 +483,7 @@ XS(XS_Raid_TeleportRaid)
{
dXSARGS;
if (items != 7)
Perl_croak(aTHX_ "Usage: Raid::TeleportRaid(THIS, sender, zoneID, x, y, z, heading)");
Perl_croak(aTHX_ "Usage: Raid::TeleportRaid(THIS, mob_sender, zone_id, x, y, z, heading)");
{
Raid * THIS;
Mob* sender;